@ibyar/expressions 0.5.0 → 0.5.4
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 +96 -1
- package/api/abstract.d.ts +3 -4
- package/api/abstract.js +1 -1
- package/api/abstract.js.map +1 -1
- package/api/class/class.d.ts +196 -0
- package/api/class/class.js +594 -0
- package/api/class/class.js.map +1 -0
- package/api/class/decorator.d.ts +20 -0
- package/api/class/decorator.js +48 -0
- package/api/class/decorator.js.map +1 -0
- package/api/computing/call.d.ts +3 -1
- package/api/computing/call.js +16 -4
- package/api/computing/call.js.map +1 -1
- package/api/computing/new.d.ts +2 -1
- package/api/computing/new.js +4 -0
- package/api/computing/new.js.map +1 -1
- package/api/computing/rest.d.ts +3 -3
- package/api/computing/rest.js +5 -2
- package/api/computing/rest.js.map +1 -1
- package/api/computing/return.d.ts +2 -1
- package/api/computing/return.js +3 -0
- package/api/computing/return.js.map +1 -1
- package/api/computing/spread.d.ts +2 -1
- package/api/computing/spread.js +5 -2
- package/api/computing/spread.js.map +1 -1
- package/api/computing/throw.d.ts +2 -1
- package/api/computing/throw.js +3 -0
- package/api/computing/throw.js.map +1 -1
- package/api/computing/yield.d.ts +2 -1
- package/api/computing/yield.js +3 -0
- package/api/computing/yield.js.map +1 -1
- package/api/definition/array.d.ts +6 -7
- package/api/definition/array.js +13 -13
- package/api/definition/array.js.map +1 -1
- package/api/definition/bind.d.ts +2 -2
- package/api/definition/bind.js +1 -1
- package/api/definition/bind.js.map +1 -1
- package/api/definition/function.d.ts +8 -8
- package/api/definition/function.js +25 -25
- package/api/definition/function.js.map +1 -1
- package/api/definition/member.d.ts +2 -2
- package/api/definition/member.js +1 -1
- package/api/definition/member.js.map +1 -1
- package/api/definition/object.d.ts +7 -7
- package/api/definition/object.js +9 -9
- package/api/definition/object.js.map +1 -1
- package/api/definition/statement.d.ts +2 -2
- package/api/definition/statement.js +2 -2
- package/api/definition/statement.js.map +1 -1
- package/api/definition/values.d.ts +5 -4
- package/api/definition/values.js +7 -4
- package/api/definition/values.js.map +1 -1
- package/api/expression.d.ts +9 -12
- package/api/expression.js.map +1 -1
- package/api/{app → module/app}/program.d.ts +8 -9
- package/api/module/app/program.js +45 -0
- package/api/module/app/program.js.map +1 -0
- package/api/module/export.d.ts +60 -25
- package/api/module/export.js +230 -60
- package/api/module/export.js.map +1 -1
- package/api/module/import.d.ts +66 -25
- package/api/module/import.js +236 -68
- package/api/module/import.js.map +1 -1
- package/api/operators/assignment.d.ts +2 -2
- package/api/operators/assignment.js +1 -1
- package/api/operators/assignment.js.map +1 -1
- package/api/operators/await.d.ts +2 -2
- package/api/operators/await.js +1 -1
- package/api/operators/await.js.map +1 -1
- package/api/operators/binary.d.ts +2 -2
- package/api/operators/binary.js +1 -1
- package/api/operators/binary.js.map +1 -1
- package/api/operators/chaining.d.ts +2 -2
- package/api/operators/chaining.js +1 -1
- package/api/operators/chaining.js.map +1 -1
- package/api/operators/comma.d.ts +2 -2
- package/api/operators/comma.js +2 -2
- package/api/operators/comma.js.map +1 -1
- package/api/operators/grouping.d.ts +2 -2
- package/api/operators/grouping.js +1 -1
- package/api/operators/grouping.js.map +1 -1
- package/api/operators/logical.d.ts +2 -2
- package/api/operators/logical.js +1 -1
- package/api/operators/logical.js.map +1 -1
- package/api/operators/pipeline.d.ts +2 -2
- package/api/operators/pipeline.js +1 -1
- package/api/operators/pipeline.js.map +1 -1
- package/api/operators/ternary.d.ts +2 -2
- package/api/operators/ternary.js +1 -1
- package/api/operators/ternary.js.map +1 -1
- package/api/operators/unary.d.ts +3 -3
- package/api/operators/unary.js +4 -3
- package/api/operators/unary.js.map +1 -1
- package/api/operators/update.d.ts +2 -2
- package/api/operators/update.js +1 -1
- package/api/operators/update.js.map +1 -1
- package/api/statement/control/block.d.ts +3 -3
- package/api/statement/control/block.js +2 -2
- package/api/statement/control/block.js.map +1 -1
- package/api/statement/control/empty.d.ts +1 -1
- package/api/statement/control/empty.js.map +1 -1
- package/api/statement/control/if.d.ts +2 -2
- package/api/statement/control/if.js +1 -1
- package/api/statement/control/if.js.map +1 -1
- package/api/statement/control/switch.d.ts +4 -5
- package/api/statement/control/switch.js +5 -6
- package/api/statement/control/switch.js.map +1 -1
- package/api/statement/control/terminate.d.ts +3 -3
- package/api/statement/control/terminate.js +2 -2
- package/api/statement/control/terminate.js.map +1 -1
- package/api/statement/declarations/declares.d.ts +13 -11
- package/api/statement/declarations/declares.js +26 -18
- package/api/statement/declarations/declares.js.map +1 -1
- package/api/statement/iterations/for.d.ts +5 -5
- package/api/statement/iterations/for.js +7 -7
- package/api/statement/iterations/for.js.map +1 -1
- package/api/statement/iterations/while.d.ts +3 -3
- package/api/statement/iterations/while.js +2 -2
- package/api/statement/iterations/while.js.map +1 -1
- package/api/utils.d.ts +3 -0
- package/api/utils.js +2 -0
- package/api/utils.js.map +1 -0
- package/package.json +4 -4
- package/scope/event.d.ts +2 -2
- package/scope/event.js +8 -14
- package/scope/event.js.map +1 -1
- package/scope/finalizer.d.ts +4 -0
- package/scope/finalizer.js +11 -0
- package/scope/finalizer.js.map +1 -0
- package/scope/proxy.d.ts +2 -1
- package/scope/proxy.js +18 -2
- package/scope/proxy.js.map +1 -1
- package/scope/scope.d.ts +57 -40
- package/scope/scope.js +123 -106
- package/scope/scope.js.map +1 -1
- package/scope/stack.d.ts +41 -24
- package/scope/stack.js +148 -102
- package/scope/stack.js.map +1 -1
- package/v8/app.js.map +1 -1
- package/v8/parser.d.ts +1 -1
- package/v8/parser.js +3 -2
- package/v8/parser.js.map +1 -1
- package/visit/visitor.js +4 -7
- package/visit/visitor.js.map +1 -1
- package/api/app/class.d.ts +0 -117
- package/api/app/class.js +0 -292
- package/api/app/class.js.map +0 -1
- package/api/app/program.js +0 -39
- package/api/app/program.js.map +0 -1
- package/api/module/module.d.ts +0 -26
- package/api/module/module.js +0 -63
- package/api/module/module.js.map +0 -1
package/scope/scope.js
CHANGED
|
@@ -1,41 +1,19 @@
|
|
|
1
1
|
export class Scope {
|
|
2
|
-
constructor(context,
|
|
2
|
+
constructor(context, propertyKeys) {
|
|
3
3
|
this.context = context;
|
|
4
|
-
this.type = type;
|
|
5
4
|
this.scopeMap = new Map();
|
|
5
|
+
this.propertyKeys = propertyKeys;
|
|
6
|
+
if (Array.isArray(this.propertyKeys)) {
|
|
7
|
+
this.has = (propertyKey) => {
|
|
8
|
+
return this.propertyKeys.includes(propertyKey);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
6
11
|
}
|
|
7
|
-
static for(context,
|
|
8
|
-
return new Scope(context,
|
|
9
|
-
}
|
|
10
|
-
static blockScopeFor(context) {
|
|
11
|
-
return new Scope(context, 'block');
|
|
12
|
-
}
|
|
13
|
-
static functionScopeFor(context) {
|
|
14
|
-
return new Scope(context, 'function');
|
|
15
|
-
}
|
|
16
|
-
static classScopeFor(context) {
|
|
17
|
-
return new Scope(context, 'class');
|
|
18
|
-
}
|
|
19
|
-
static moduleScopeFor(context) {
|
|
20
|
-
return new Scope(context, 'module');
|
|
21
|
-
}
|
|
22
|
-
static globalScopeFor(context) {
|
|
23
|
-
return new Scope(context, 'global');
|
|
24
|
-
}
|
|
25
|
-
static blockScope() {
|
|
26
|
-
return new Scope({}, 'block');
|
|
27
|
-
}
|
|
28
|
-
static functionScope() {
|
|
29
|
-
return new Scope({}, 'function');
|
|
30
|
-
}
|
|
31
|
-
static classScope() {
|
|
32
|
-
return new Scope({}, 'class');
|
|
33
|
-
}
|
|
34
|
-
static moduleScope() {
|
|
35
|
-
return new Scope({}, 'module');
|
|
12
|
+
static for(context, propertyKeys) {
|
|
13
|
+
return new Scope(context, propertyKeys);
|
|
36
14
|
}
|
|
37
|
-
static
|
|
38
|
-
return new Scope({},
|
|
15
|
+
static blockScope(propertyKeys) {
|
|
16
|
+
return new Scope({}, propertyKeys);
|
|
39
17
|
}
|
|
40
18
|
get(propertyKey) {
|
|
41
19
|
return Reflect.get(this.context, propertyKey);
|
|
@@ -62,7 +40,7 @@ export class Scope {
|
|
|
62
40
|
if (typeof scopeContext !== 'object') {
|
|
63
41
|
return;
|
|
64
42
|
}
|
|
65
|
-
scope = new
|
|
43
|
+
scope = new (this.getClass())(scopeContext);
|
|
66
44
|
this.scopeMap.set(propertyKey, scope);
|
|
67
45
|
return scope;
|
|
68
46
|
}
|
|
@@ -73,44 +51,20 @@ export class Scope {
|
|
|
73
51
|
scope.context = scopeContext;
|
|
74
52
|
return scope;
|
|
75
53
|
}
|
|
76
|
-
scope = new
|
|
54
|
+
scope = new (this.getClass())(scopeContext);
|
|
77
55
|
this.scopeMap.set(propertyKey, scope);
|
|
78
56
|
return scope;
|
|
79
57
|
}
|
|
58
|
+
getClass() {
|
|
59
|
+
return Scope;
|
|
60
|
+
}
|
|
80
61
|
}
|
|
81
62
|
export class ReadOnlyScope extends Scope {
|
|
82
|
-
static for(context,
|
|
83
|
-
return new ReadOnlyScope(context,
|
|
84
|
-
}
|
|
85
|
-
static blockScopeFor(context) {
|
|
86
|
-
return new ReadOnlyScope(context, 'block');
|
|
87
|
-
}
|
|
88
|
-
static functionScopeFor(context) {
|
|
89
|
-
return new ReadOnlyScope(context, 'function');
|
|
90
|
-
}
|
|
91
|
-
static classScopeFor(context) {
|
|
92
|
-
return new ReadOnlyScope(context, 'class');
|
|
93
|
-
}
|
|
94
|
-
static moduleScopeFor(context) {
|
|
95
|
-
return new ReadOnlyScope(context, 'module');
|
|
96
|
-
}
|
|
97
|
-
static globalScopeFor(context) {
|
|
98
|
-
return new ReadOnlyScope(context, 'global');
|
|
99
|
-
}
|
|
100
|
-
static blockScope() {
|
|
101
|
-
return new ReadOnlyScope({}, 'block');
|
|
63
|
+
static for(context, propertyKeys) {
|
|
64
|
+
return new ReadOnlyScope(context, propertyKeys);
|
|
102
65
|
}
|
|
103
|
-
static
|
|
104
|
-
return new ReadOnlyScope({},
|
|
105
|
-
}
|
|
106
|
-
static classScope() {
|
|
107
|
-
return new ReadOnlyScope({}, 'class');
|
|
108
|
-
}
|
|
109
|
-
static moduleScope() {
|
|
110
|
-
return new ReadOnlyScope({}, 'module');
|
|
111
|
-
}
|
|
112
|
-
static globalScope() {
|
|
113
|
-
return new ReadOnlyScope({}, 'global');
|
|
66
|
+
static blockScope(propertyKeys) {
|
|
67
|
+
return new ReadOnlyScope({}, propertyKeys);
|
|
114
68
|
}
|
|
115
69
|
set(propertyKey, value, receiver) {
|
|
116
70
|
return false;
|
|
@@ -118,12 +72,21 @@ export class ReadOnlyScope extends Scope {
|
|
|
118
72
|
delete(propertyKey) {
|
|
119
73
|
return false;
|
|
120
74
|
}
|
|
75
|
+
getClass() {
|
|
76
|
+
return ReadOnlyScope;
|
|
77
|
+
}
|
|
121
78
|
}
|
|
122
79
|
export class ScopeSubscription {
|
|
123
80
|
constructor(propertyKey, observer) {
|
|
124
81
|
this.propertyKey = propertyKey;
|
|
125
82
|
this.observer = observer;
|
|
126
83
|
}
|
|
84
|
+
pause() {
|
|
85
|
+
this.observer.pause(this.propertyKey, this);
|
|
86
|
+
}
|
|
87
|
+
resume() {
|
|
88
|
+
this.observer.resume(this.propertyKey, this);
|
|
89
|
+
}
|
|
127
90
|
unsubscribe() {
|
|
128
91
|
this.observer.unsubscribe(this.propertyKey, this);
|
|
129
92
|
}
|
|
@@ -138,13 +101,16 @@ export class ValueChangeObserver {
|
|
|
138
101
|
return;
|
|
139
102
|
}
|
|
140
103
|
const subscribers = this.subscribers.get(propertyKey);
|
|
141
|
-
if (!subscribers) {
|
|
104
|
+
if (!subscribers || subscribers.size == 0) {
|
|
142
105
|
return;
|
|
143
106
|
}
|
|
144
107
|
this.propertiesLock.push(propertyKey);
|
|
145
|
-
subscribers?.forEach(
|
|
108
|
+
subscribers?.forEach(subscriptionInfo => {
|
|
109
|
+
if (!subscriptionInfo.enable) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
146
112
|
try {
|
|
147
|
-
|
|
113
|
+
subscriptionInfo.callback(newValue, oldValue);
|
|
148
114
|
}
|
|
149
115
|
catch (e) {
|
|
150
116
|
console.error(e);
|
|
@@ -162,7 +128,7 @@ export class ValueChangeObserver {
|
|
|
162
128
|
propertySubscribers = new Map();
|
|
163
129
|
this.subscribers.set(propertyKey, propertySubscribers);
|
|
164
130
|
}
|
|
165
|
-
propertySubscribers.set(subscription, callback);
|
|
131
|
+
propertySubscribers.set(subscription, { callback, enable: true });
|
|
166
132
|
return subscription;
|
|
167
133
|
}
|
|
168
134
|
unsubscribe(propertyKey, subscription) {
|
|
@@ -173,49 +139,35 @@ export class ValueChangeObserver {
|
|
|
173
139
|
this.subscribers.delete(propertyKey);
|
|
174
140
|
}
|
|
175
141
|
}
|
|
142
|
+
pause(propertyKey, subscription) {
|
|
143
|
+
const subscriptionInfo = this.subscribers.get(propertyKey)?.get(subscription);
|
|
144
|
+
subscriptionInfo && (subscriptionInfo.enable = false);
|
|
145
|
+
}
|
|
146
|
+
resume(propertyKey, subscription) {
|
|
147
|
+
const subscriptionInfo = this.subscribers.get(propertyKey)?.get(subscription);
|
|
148
|
+
subscriptionInfo && (subscriptionInfo.enable = true);
|
|
149
|
+
}
|
|
176
150
|
destroy() {
|
|
177
151
|
this.subscribers.clear();
|
|
178
152
|
}
|
|
179
153
|
}
|
|
180
154
|
export class ReactiveScope extends Scope {
|
|
181
|
-
constructor(context,
|
|
182
|
-
super(context,
|
|
183
|
-
this.name = name;
|
|
155
|
+
constructor(context, name, parent, propertyKeys) {
|
|
156
|
+
super(context, Array.isArray(name) ? name : propertyKeys);
|
|
184
157
|
this.parent = parent;
|
|
185
158
|
this.observer = new ValueChangeObserver();
|
|
159
|
+
if (typeof name == 'string') {
|
|
160
|
+
this.name = name;
|
|
161
|
+
}
|
|
162
|
+
if (Array.isArray(name)) {
|
|
163
|
+
this.propertyKeys = name;
|
|
164
|
+
}
|
|
186
165
|
}
|
|
187
|
-
static for(context,
|
|
188
|
-
return new ReactiveScope(context,
|
|
189
|
-
}
|
|
190
|
-
static blockScopeFor(context) {
|
|
191
|
-
return new ReactiveScope(context, 'block');
|
|
192
|
-
}
|
|
193
|
-
static functionScopeFor(context) {
|
|
194
|
-
return new ReactiveScope(context, 'function');
|
|
195
|
-
}
|
|
196
|
-
static classScopeFor(context) {
|
|
197
|
-
return new ReactiveScope(context, 'class');
|
|
198
|
-
}
|
|
199
|
-
static moduleScopeFor(context) {
|
|
200
|
-
return new ReactiveScope(context, 'module');
|
|
201
|
-
}
|
|
202
|
-
static globalScopeFor(context) {
|
|
203
|
-
return new ReactiveScope(context, 'global');
|
|
204
|
-
}
|
|
205
|
-
static blockScope() {
|
|
206
|
-
return new ReactiveScope({}, 'block');
|
|
207
|
-
}
|
|
208
|
-
static functionScope() {
|
|
209
|
-
return new ReactiveScope({}, 'function');
|
|
210
|
-
}
|
|
211
|
-
static classScope() {
|
|
212
|
-
return new ReactiveScope({}, 'class');
|
|
213
|
-
}
|
|
214
|
-
static moduleScope() {
|
|
215
|
-
return new ReactiveScope({}, 'module');
|
|
166
|
+
static for(context, propertyKeys) {
|
|
167
|
+
return new ReactiveScope(context, propertyKeys);
|
|
216
168
|
}
|
|
217
|
-
static
|
|
218
|
-
return new ReactiveScope({},
|
|
169
|
+
static blockScope(propertyKeys) {
|
|
170
|
+
return new ReactiveScope({}, propertyKeys);
|
|
219
171
|
}
|
|
220
172
|
set(propertyKey, newValue, receiver) {
|
|
221
173
|
const oldValue = Reflect.get(this.context, propertyKey);
|
|
@@ -243,7 +195,7 @@ export class ReactiveScope extends Scope {
|
|
|
243
195
|
if (typeof scopeContext !== 'object') {
|
|
244
196
|
return;
|
|
245
197
|
}
|
|
246
|
-
scope = new ReactiveScope(scopeContext,
|
|
198
|
+
scope = new ReactiveScope(scopeContext, propertyKey, this);
|
|
247
199
|
this.scopeMap.set(propertyKey, scope);
|
|
248
200
|
return scope;
|
|
249
201
|
}
|
|
@@ -254,7 +206,7 @@ export class ReactiveScope extends Scope {
|
|
|
254
206
|
scope.context = scopeContext;
|
|
255
207
|
return scope;
|
|
256
208
|
}
|
|
257
|
-
scope = new ReactiveScope(scopeContext,
|
|
209
|
+
scope = new ReactiveScope(scopeContext, propertyKey, this);
|
|
258
210
|
this.scopeMap.set(propertyKey, scope);
|
|
259
211
|
return scope;
|
|
260
212
|
}
|
|
@@ -276,5 +228,70 @@ export class ReactiveScope extends Scope {
|
|
|
276
228
|
this.observer.destroy();
|
|
277
229
|
}
|
|
278
230
|
}
|
|
231
|
+
getClass() {
|
|
232
|
+
return ReactiveScope;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
export class ReactiveScopeControl extends ReactiveScope {
|
|
236
|
+
constructor() {
|
|
237
|
+
super(...arguments);
|
|
238
|
+
this.attached = true;
|
|
239
|
+
this.marked = {};
|
|
240
|
+
}
|
|
241
|
+
static for(context, propertyKeys) {
|
|
242
|
+
return new ReactiveScopeControl(context, propertyKeys);
|
|
243
|
+
}
|
|
244
|
+
static blockScope(propertyKeys) {
|
|
245
|
+
return new ReactiveScopeControl({}, propertyKeys);
|
|
246
|
+
}
|
|
247
|
+
emit(propertyKey, newValue, oldValue) {
|
|
248
|
+
if (this.attached) {
|
|
249
|
+
super.emit(propertyKey, newValue, oldValue);
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
this.marked[propertyKey] = newValue;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
isAttached() {
|
|
256
|
+
return this.attached;
|
|
257
|
+
}
|
|
258
|
+
detach() {
|
|
259
|
+
this.attached = false;
|
|
260
|
+
}
|
|
261
|
+
reattach() {
|
|
262
|
+
this.attached = true;
|
|
263
|
+
this.emitChanges();
|
|
264
|
+
}
|
|
265
|
+
emitChanges(propertyKey, propertyValue) {
|
|
266
|
+
if (propertyKey) {
|
|
267
|
+
super.emit(propertyKey, propertyValue);
|
|
268
|
+
Reflect.deleteProperty(this.marked, propertyKey);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const latestChanges = this.marked;
|
|
272
|
+
this.marked = {};
|
|
273
|
+
Object.keys(latestChanges).forEach(propertyKey => {
|
|
274
|
+
super.emit(propertyKey, latestChanges[propertyKey]);
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
getClass() {
|
|
278
|
+
return ReactiveScopeControl;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
export class ModuleScope extends ReactiveScope {
|
|
282
|
+
constructor(context, propertyKeys) {
|
|
283
|
+
super(context, propertyKeys);
|
|
284
|
+
}
|
|
285
|
+
importModule(propertyKey, scope) {
|
|
286
|
+
this.scopeMap.set(propertyKey, scope);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
export class WebModuleScope extends ModuleScope {
|
|
290
|
+
constructor() {
|
|
291
|
+
super({});
|
|
292
|
+
}
|
|
293
|
+
updateContext(context) {
|
|
294
|
+
this.context = context;
|
|
295
|
+
}
|
|
279
296
|
}
|
|
280
297
|
//# sourceMappingURL=scope.js.map
|
package/scope/scope.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../../src/expressions/scope/scope.ts"],"names":[],"mappings":"AA2DA,MAAM,OAAO,KAAK;IAmCjB,YAAsB,OAAU,EAAS,IAAe;QAAlC,YAAO,GAAP,OAAO,CAAG;QAAS,SAAI,GAAJ,IAAI,CAAW;QAD9C,aAAQ,GAAG,IAAI,GAAG,EAAuB,CAAC;IACQ,CAAC;IAlC7D,MAAM,CAAC,GAAG,CAAyB,OAAU,EAAE,IAAe;QAC7D,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACjC,CAAC;IACD,MAAM,CAAC,aAAa,CAAyB,OAAU;QACtD,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC;IACD,MAAM,CAAC,gBAAgB,CAAyB,OAAU;QACzD,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACvC,CAAC;IACD,MAAM,CAAC,aAAa,CAAyB,OAAU;QACtD,OAAO,IAA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EAAE,QAAc;QACvD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACpD,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,IAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED,SAAS,CAAC,WAAoB,EAAE,QAA8B;QAC7D,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACvD,CAAC;IAED,WAAW,CAAC,WAAqB,EAAE,YAAmC;QACrE,IAAI,WAAW,IAAI,YAAY,EAAE;YAChC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;SACrD;aAAM,IAAI,WAAW,EAAE;YAEvB,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;SACvC;aAAM;YACN,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;SACxB;IACF,CAAC;CACD","sourcesContent":["\nexport type ScopeType = 'block' | 'function' | 'class' | 'module' | 'global';\n\nexport type ScopeContext = { [key: PropertyKey]: ScopeContext | any };\nexport interface Scope<T = ScopeContext> {\n\n\t/**\n\t * scope type\n\t */\n\ttype: ScopeType;\n\n\t/**\n\t * get value of `propertyKey` in current context\n\t * @param propertyKey \n\t */\n\tget(propertyKey: keyof T): any;\n\n\t/**\n\t * set the value of `propertyKey` in current context, could be instilled with `value`.\n\t * @param propertyKey \n\t * @param value \n\t * @param receiver \n\t */\n\tset(propertyKey: keyof T, value?: any, receiver?: any): boolean;\n\n\t/**\n\t * is current context has `propertyKey` in hash map keys\n\t * @param propertyKey \n\t */\n\thas(propertyKey: keyof T): boolean;\n\n\t/**\n\t * delete property from context\n\t * @param propertyKey \n\t */\n\tdelete(propertyKey: keyof T): boolean;\n\n\t/**\n\t * get current context object of this scope\n\t */\n\tgetContext(): T;\n\n\t/**\n\t * get a scope for an object named as `propertyKey` from cache map,\n\t * \n\t * if the current value is not type od `object`, will return `undefined`.\n\t * @param propertyKey the name of the property\n\t */\n\tgetScope<V extends ScopeContext>(propertyKey: keyof T): Scope<V> | undefined;\n\n\t/**\n\t * get a scope for an object named as `propertyKey` from cache map,\n\t * \n\t * if no scope found in the cache, will create a new one, add this one to the map, return a reference.\n\t * @param propertyKey\n\t */\n\tgetScopeOrCreat<V extends ScopeContext>(propertyKey: keyof T): Scope<V>;\n}\n\nexport class Scope<T extends ScopeContext> implements Scope<T> {\n\tstatic for<T extends ScopeContext>(context: T, type: ScopeType) {\n\t\treturn new Scope(context, type);\n\t}\n\tstatic blockScopeFor<T extends ScopeContext>(context: T) {\n\t\treturn new Scope(context, 'block');\n\t}\n\tstatic functionScopeFor<T extends ScopeContext>(context: T) {\n\t\treturn new Scope(context, 'function');\n\t}\n\tstatic classScopeFor<T extends ScopeContext>(context: T) {\n\t\treturn new Scope(context, 'class');\n\t}\n\tstatic moduleScopeFor<T extends ScopeContext>(context: T) {\n\t\treturn new Scope(context, 'module');\n\t}\n\tstatic globalScopeFor<T extends ScopeContext>(context: T) {\n\t\treturn new Scope(context, 'global');\n\t}\n\tstatic blockScope<T extends ScopeContext>() {\n\t\treturn new Scope({} as T, 'block');\n\t}\n\tstatic functionScope<T extends ScopeContext>() {\n\t\treturn new Scope({} as T, 'function');\n\t}\n\tstatic classScope<T extends ScopeContext>() {\n\t\treturn new Scope({} as T, 'class');\n\t}\n\tstatic moduleScope<T extends ScopeContext>() {\n\t\treturn new Scope({} as T, 'module');\n\t}\n\tstatic globalScope<T extends ScopeContext>() {\n\t\treturn new Scope({} as T, 'global');\n\t}\n\tprotected scopeMap = new Map<keyof T, Scope<any>>();\n\tconstructor(protected context: T, public type: ScopeType) { }\n\tget(propertyKey: keyof T): any {\n\t\treturn Reflect.get(this.context, propertyKey);\n\t}\n\tset(propertyKey: keyof T, value: any, receiver?: any): boolean {\n\t\treturn Reflect.set(this.context, propertyKey, value);\n\t}\n\thas(propertyKey: keyof T): boolean {\n\t\treturn propertyKey in this.context;\n\t}\n\tdelete(propertyKey: keyof T): boolean {\n\t\treturn Reflect.deleteProperty(this.context, propertyKey);\n\t}\n\tgetContext(): T {\n\t\treturn this.context;\n\t}\n\tgetScope<V extends ScopeContext>(propertyKey: keyof T): Scope<V> | undefined {\n\t\tconst scopeContext = this.get(propertyKey);\n\t\tlet scope = this.scopeMap.get(propertyKey);\n\t\tif (scope) {\n\t\t\tscope.context = scopeContext;\n\t\t\treturn scope;\n\t\t}\n\t\tif (typeof scopeContext !== 'object') {\n\t\t\treturn;\n\t\t}\n\t\tscope = new Scope(scopeContext, 'block');\n\t\tthis.scopeMap.set(propertyKey, scope);\n\t\treturn scope;\n\t}\n\tgetScopeOrCreat<V extends ScopeContext>(propertyKey: keyof T): Scope<V> {\n\t\tconst scopeContext = this.get(propertyKey);\n\t\tlet scope = this.scopeMap.get(propertyKey);\n\t\tif (scope) {\n\t\t\tscope.context = scopeContext;\n\t\t\treturn scope;\n\t\t}\n\t\tscope = new Scope(scopeContext, 'block');\n\t\tthis.scopeMap.set(propertyKey, scope);\n\t\treturn scope;\n\t}\n}\n\nexport class ReadOnlyScope<T extends ScopeContext> extends Scope<T> {\n\tstatic for<T extends ScopeContext>(context: T, type: ScopeType) {\n\t\treturn new ReadOnlyScope(context, type);\n\t}\n\tstatic blockScopeFor<T extends ScopeContext>(context: T) {\n\t\treturn new ReadOnlyScope(context, 'block');\n\t}\n\tstatic functionScopeFor<T extends ScopeContext>(context: T) {\n\t\treturn new ReadOnlyScope(context, 'function');\n\t}\n\tstatic classScopeFor<T extends ScopeContext>(context: T) {\n\t\treturn new ReadOnlyScope(context, 'class');\n\t}\n\tstatic moduleScopeFor<T extends ScopeContext>(context: T) {\n\t\treturn new ReadOnlyScope(context, 'module');\n\t}\n\tstatic globalScopeFor<T extends ScopeContext>(context: T) {\n\t\treturn new ReadOnlyScope(context, 'global');\n\t}\n\tstatic blockScope<T extends ScopeContext>() {\n\t\treturn new ReadOnlyScope({} as T, 'block');\n\t}\n\tstatic functionScope<T extends ScopeContext>() {\n\t\treturn new ReadOnlyScope({} as T, 'function');\n\t}\n\tstatic classScope<T extends ScopeContext>() {\n\t\treturn new ReadOnlyScope({} as T, 'class');\n\t}\n\tstatic moduleScope<T extends ScopeContext>() {\n\t\treturn new ReadOnlyScope({} as T, 'module');\n\t}\n\tstatic globalScope<T extends ScopeContext>() {\n\t\treturn new ReadOnlyScope({} as T, 'global');\n\t}\n\tset(propertyKey: keyof T, value: any, receiver?: any): boolean {\n\t\t// do nothing\n\t\treturn false;\n\t}\n\tdelete(propertyKey: keyof T): boolean {\n\t\t// do nothing\n\t\treturn false;\n\t}\n}\n\nexport class ScopeSubscription<T> {\n\tconstructor(private propertyKey: keyof T, private observer: ValueChangeObserver<T>,) { }\n\tunsubscribe(): void {\n\t\tthis.observer.unsubscribe(this.propertyKey, this);\n\t}\n}\n\nexport type ValueChangedCallback = (newValue: any, oldValue?: any) => void;\n\nexport class ValueChangeObserver<T> {\n\tprivate subscribers: Map<keyof T, Map<ScopeSubscription<T>, ValueChangedCallback>> = new Map();\n\tprivate propertiesLock: (keyof T)[] = [];\n\temit(propertyKey: keyof T, newValue: any, oldValue?: any): void {\n\t\tif (this.propertiesLock.includes(propertyKey)) {\n\t\t\treturn;\n\t\t}\n\t\tconst subscribers = this.subscribers.get(propertyKey);\n\t\tif (!subscribers) {\n\t\t\treturn;\n\t\t}\n\t\tthis.propertiesLock.push(propertyKey);\n\t\tsubscribers?.forEach((subscribe) => {\n\t\t\ttry {\n\t\t\t\tsubscribe(newValue, oldValue);\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(e);\n\t\t\t}\n\t\t});\n\t\tif (this.propertiesLock.pop() !== propertyKey) {\n\t\t\tconsole.error('lock error');\n\t\t};\n\t}\n\tsubscribe(propertyKey: keyof T, callback: ValueChangedCallback): ScopeSubscription<T> {\n\t\tconst subscription: ScopeSubscription<T> = new ScopeSubscription(propertyKey, this);\n\t\tlet propertySubscribers = this.subscribers.get(propertyKey);\n\t\tif (!propertySubscribers) {\n\t\t\tpropertySubscribers = new Map();\n\t\t\tthis.subscribers.set(propertyKey, propertySubscribers);\n\t\t}\n\t\tpropertySubscribers.set(subscription, callback);\n\t\treturn subscription;\n\t}\n\n\tunsubscribe(propertyKey: keyof T, subscription?: ScopeSubscription<T>) {\n\t\tif (subscription) {\n\t\t\tthis.subscribers.get(propertyKey)?.delete(subscription);\n\t\t} else {\n\t\t\tthis.subscribers.delete(propertyKey);\n\t\t}\n\t}\n\n\t/**\n\t * clear subscription map\n\t */\n\tdestroy() {\n\t\tthis.subscribers.clear();\n\t}\n}\n\nexport class ReactiveScope<T extends ScopeContext> extends Scope<T> {\n\tstatic for<T extends ScopeContext>(context: T, type: ScopeType) {\n\t\treturn new ReactiveScope(context, type);\n\t}\n\tstatic blockScopeFor<T extends ScopeContext>(context: T) {\n\t\treturn new ReactiveScope(context, 'block');\n\t}\n\tstatic functionScopeFor<T extends ScopeContext>(context: T) {\n\t\treturn new ReactiveScope(context, 'function');\n\t}\n\tstatic classScopeFor<T extends ScopeContext>(context: T) {\n\t\treturn new ReactiveScope(context, 'class');\n\t}\n\tstatic moduleScopeFor<T extends ScopeContext>(context: T) {\n\t\treturn new ReactiveScope(context, 'module');\n\t}\n\tstatic globalScopeFor<T extends ScopeContext>(context: T) {\n\t\treturn new ReactiveScope(context, 'global');\n\t}\n\tstatic blockScope<T extends ScopeContext>() {\n\t\treturn new ReactiveScope({} as T, 'block');\n\t}\n\tstatic functionScope<T extends ScopeContext>() {\n\t\treturn new ReactiveScope({} as T, 'function');\n\t}\n\tstatic classScope<T extends ScopeContext>() {\n\t\treturn new ReactiveScope({} as T, 'class');\n\t}\n\tstatic moduleScope<T extends ScopeContext>() {\n\t\treturn new ReactiveScope({} as T, 'module');\n\t}\n\tstatic globalScope<T extends ScopeContext>() {\n\t\treturn new ReactiveScope({} as T, 'global');\n\t}\n\n\tprotected observer: ValueChangeObserver<T> = new ValueChangeObserver<T>();\n\n\tconstructor(context: T, type: ScopeType);\n\tconstructor(context: T, type: ScopeType, name: string, parent: ReactiveScope<any>);\n\tconstructor(context: T, type: ScopeType, protected name?: string, protected parent?: ReactiveScope<any>) {\n\t\tsuper(context, type);\n\t}\n\n\tset(propertyKey: keyof T, newValue: any, receiver?: any): boolean {\n\t\tconst oldValue = Reflect.get(this.context, propertyKey);\n\t\tconst result = Reflect.set(this.context, propertyKey, newValue);\n\t\tif (result) {\n\t\t\tthis.emit(propertyKey, newValue, oldValue);\n\t\t}\n\t\treturn result;\n\t}\n\tdelete(propertyKey: keyof T): boolean {\n\t\tconst oldValue = Reflect.get(this.context, propertyKey);\n\t\tconst isDelete = Reflect.deleteProperty(this.context, propertyKey);\n\t\tif (isDelete && oldValue !== undefined) {\n\t\t\tthis.emit(propertyKey, undefined, oldValue);\n\t\t}\n\t\treturn isDelete;\n\t}\n\tgetScope<V extends ScopeContext>(propertyKey: keyof T): ReactiveScope<V> | undefined {\n\t\tconst scopeContext = this.get(propertyKey) as V;\n\t\tlet scope = this.scopeMap.get(propertyKey) as ReactiveScope<any> | undefined;\n\t\tif (scope) {\n\t\t\tscope.context = scopeContext;\n\t\t\treturn scope;\n\t\t}\n\t\tif (typeof scopeContext !== 'object') {\n\t\t\treturn;\n\t\t}\n\t\tscope = new ReactiveScope<V>(scopeContext, 'block', propertyKey as string, this);\n\t\tthis.scopeMap.set(propertyKey, scope);\n\t\treturn scope;\n\t}\n\tgetScopeOrCreat<V extends ScopeContext>(propertyKey: keyof T): ReactiveScope<V> {\n\t\tconst scopeContext = this.get(propertyKey) as V;\n\t\tlet scope = this.scopeMap.get(propertyKey) as ReactiveScope<any> | undefined;\n\t\tif (scope) {\n\t\t\tscope.context = scopeContext;\n\t\t\treturn scope;\n\t\t}\n\t\tscope = new ReactiveScope<V>(scopeContext, 'block', propertyKey as string, this);\n\t\tthis.scopeMap.set(propertyKey, scope);\n\t\treturn scope;\n\t}\n\n\temit(propertyKey: keyof T, newValue: any, oldValue?: any): void {\n\t\tthis.observer.emit(propertyKey, newValue, oldValue);\n\t\tthis.parent?.emit(this.name!, this.context);\n\t}\n\n\tsubscribe(propertyKey: keyof T, callback: ValueChangedCallback): ScopeSubscription<T> {\n\t\treturn this.observer.subscribe(propertyKey, callback);\n\t}\n\n\tunsubscribe(propertyKey?: keyof T, subscription?: ScopeSubscription<T>) {\n\t\tif (propertyKey && subscription) {\n\t\t\tthis.observer.unsubscribe(propertyKey, subscription);\n\t\t} else if (propertyKey) {\n\n\t\t\tthis.observer.unsubscribe(propertyKey);\n\t\t} else {\n\t\t\tthis.observer.destroy();\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../../src/expressions/scope/scope.ts"],"names":[],"mappings":"AA4DA,MAAM,OAAO,KAAK;IASjB,YAAsB,OAAU,EAAE,YAA0B;QAAtC,YAAO,GAAP,OAAO,CAAG;QAFtB,aAAQ,GAAG,IAAI,GAAG,EAAuB,CAAC;QAGnD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE;YACrC,IAAI,CAAC,GAAG,GAAG,CAAC,WAAoB,EAAW,EAAE;gBAC5C,OAAO,IAAI,CAAC,YAAa,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YACjD,CAAC,CAAC;SACF;IACF,CAAC;IAfD,MAAM,CAAC,GAAG,CAAyB,OAAU,EAAE,YAA0B;QACxE,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACzC,CAAC;IACD,MAAM,CAAC,UAAU,CAAyB,YAA0B;QACnE,OAAO,IAAI,KAAK,CAAC,EAAO,EAAE,YAAY,CAAC,CAAC;IACzC,CAAC;IAWD,GAAG,CAAC,WAAoB;QACvB,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,E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ACrB,IAAI,CAAC,WAAW,EAAE,CAAC;IACpB,CAAC;IACD,WAAW,CAAC,WAAqB,EAAE,aAAmB;QACrD,IAAI,WAAW,EAAE;YAChB,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;YACvC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YACjD,OAAO;SACP;QACD,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;YAChD,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;IACJ,CAAC;IACD,QAAQ;QACP,OAAO,oBAAoB,CAAC;IAC7B,CAAC;CACD;AAyBD,MAAM,OAAO,WAAY,SAAQ,aAA4B;IAC5D,YAAY,OAAsB,EAAE,YAAsC;QACzE,KAAK,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC9B,CAAC;IACD,YAAY,CAAC,WAAgC,EAAE,KAAkB;QAChE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;CACD;AACD,MAAM,OAAO,cAAe,SAAQ,WAAW;IAC9C;QACC,KAAK,CAAC,EAAmB,CAAC,CAAC;IAC5B,CAAC;IACD,aAAa,CAAC,OAAY;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;CACD","sourcesContent":["import { TypeOf } from '../api/utils.js';\n\nexport type ScopeContext = { [key: PropertyKey]: ScopeContext | any };\nexport interface Scope<T = ScopeContext> {\n\n\t/**\n\t * get value of `propertyKey` in current context\n\t * @param propertyKey \n\t */\n\tget(propertyKey: keyof T): any;\n\n\t/**\n\t * set the value of `propertyKey` in current context, could be instilled with `value`.\n\t * @param propertyKey \n\t * @param value \n\t * @param receiver \n\t */\n\tset(propertyKey: keyof T, value?: any, receiver?: any): boolean;\n\n\t/**\n\t * is current context has `propertyKey` in hash map keys\n\t * @param propertyKey \n\t */\n\thas(propertyKey: keyof T): boolean;\n\n\t/**\n\t * delete property from context\n\t * @param propertyKey \n\t */\n\tdelete(propertyKey: keyof T): boolean;\n\n\t/**\n\t * get current context object of this scope\n\t */\n\tgetContext(): T;\n\n\t/**\n\t * get a proxy of the current context object if exists. \n\t */\n\tgetContextProxy?(): T;\n\n\t/**\n\t * get a scope for an object named as `propertyKey` from cache map,\n\t * \n\t * if the current value is not type od `object`, will return `undefined`.\n\t * @param propertyKey the name of the property\n\t */\n\tgetScope<V extends ScopeContext>(propertyKey: keyof T): Scope<V> | undefined;\n\n\t/**\n\t * get a scope for an object named as `propertyKey` from cache map,\n\t * \n\t * if no scope found in the cache, will create a new one, add this one to the map, return a reference.\n\t * @param propertyKey\n\t */\n\tgetScopeOrCreat<V extends ScopeContext>(propertyKey: keyof T): Scope<V>;\n\n\tgetClass(): TypeOf<Scope<ScopeContext>>;\n}\n\nexport class Scope<T extends ScopeContext> implements Scope<T> {\n\tstatic for<T extends ScopeContext>(context: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new Scope(context, propertyKeys);\n\t}\n\tstatic blockScope<T extends ScopeContext>(propertyKeys?: (keyof T)[]) {\n\t\treturn new Scope({} as T, propertyKeys);\n\t}\n\tprotected scopeMap = new Map<keyof T, Scope<any>>();\n\tprotected propertyKeys?: (keyof T)[];\n\tconstructor(protected context: T, propertyKeys?: (keyof T)[]) {\n\t\tthis.propertyKeys = propertyKeys;\n\t\tif (Array.isArray(this.propertyKeys)) {\n\t\t\tthis.has = (propertyKey: keyof T): boolean => {\n\t\t\t\treturn this.propertyKeys!.includes(propertyKey);\n\t\t\t};\n\t\t}\n\t}\n\tget(propertyKey: keyof T): any {\n\t\treturn Reflect.get(this.context, propertyKey);\n\t}\n\tset(propertyKey: keyof T, value: any, receiver?: any): boolean {\n\t\treturn Reflect.set(this.context, propertyKey, value);\n\t}\n\thas(propertyKey: keyof T): boolean {\n\t\treturn propertyKey in this.context;\n\t}\n\tdelete(propertyKey: keyof T): boolean {\n\t\treturn Reflect.deleteProperty(this.context, propertyKey);\n\t}\n\tgetContext(): T {\n\t\treturn this.context;\n\t}\n\tgetScope<V extends ScopeContext>(propertyKey: keyof T): Scope<V> | undefined {\n\t\tconst scopeContext = this.get(propertyKey);\n\t\tlet scope = this.scopeMap.get(propertyKey);\n\t\tif (scope) {\n\t\t\tscope.context = scopeContext;\n\t\t\treturn scope;\n\t\t}\n\t\tif (typeof scopeContext !== 'object') {\n\t\t\treturn;\n\t\t}\n\t\tscope = new (this.getClass())(scopeContext);\n\t\tthis.scopeMap.set(propertyKey, scope);\n\t\treturn scope;\n\t}\n\tgetScopeOrCreat<V extends ScopeContext>(propertyKey: keyof T): Scope<V> {\n\t\tconst scopeContext = this.get(propertyKey);\n\t\tlet scope = this.scopeMap.get(propertyKey);\n\t\tif (scope) {\n\t\t\tscope.context = scopeContext;\n\t\t\treturn scope;\n\t\t}\n\t\tscope = new (this.getClass())(scopeContext);\n\t\tthis.scopeMap.set(propertyKey, scope);\n\t\treturn scope;\n\t}\n\tgetClass(): TypeOf<Scope<ScopeContext>> {\n\t\treturn Scope;\n\t}\n}\n\nexport class ReadOnlyScope<T extends ScopeContext> extends Scope<T> {\n\tstatic for<T extends ScopeContext>(context: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new ReadOnlyScope(context, propertyKeys);\n\t}\n\tstatic blockScope<T extends ScopeContext>(propertyKeys?: (keyof T)[]) {\n\t\treturn new ReadOnlyScope({} as T, propertyKeys);\n\t}\n\tset(propertyKey: keyof T, value: any, receiver?: any): boolean {\n\t\t// do nothing\n\t\treturn false;\n\t}\n\tdelete(propertyKey: keyof T): boolean {\n\t\t// do nothing\n\t\treturn false;\n\t}\n\tgetClass(): TypeOf<ReadOnlyScope<ScopeContext>> {\n\t\treturn ReadOnlyScope;\n\t}\n}\n\nexport class ScopeSubscription<T> {\n\tconstructor(private propertyKey: keyof T, private observer: ValueChangeObserver<T>) { }\n\tpause() {\n\t\tthis.observer.pause(this.propertyKey, this);\n\t}\n\tresume() {\n\t\tthis.observer.resume(this.propertyKey, this);\n\t}\n\tunsubscribe(): void {\n\t\tthis.observer.unsubscribe(this.propertyKey, this);\n\t}\n}\n\nexport type ValueChangedCallback = (newValue: any, oldValue?: any) => void;\n\ntype SubscriptionInfo = { callback: ValueChangedCallback, enable: boolean };\n\nexport class ValueChangeObserver<T> {\n\tprivate subscribers: Map<keyof T, Map<ScopeSubscription<T>, SubscriptionInfo>> = new Map();\n\tprivate propertiesLock: (keyof T)[] = [];\n\temit(propertyKey: keyof T, newValue: any, oldValue?: any): void {\n\t\tif (this.propertiesLock.includes(propertyKey)) {\n\t\t\treturn;\n\t\t}\n\t\tconst subscribers = this.subscribers.get(propertyKey);\n\t\tif (!subscribers || subscribers.size == 0) {\n\t\t\treturn;\n\t\t}\n\t\tthis.propertiesLock.push(propertyKey);\n\t\tsubscribers?.forEach(subscriptionInfo => {\n\t\t\tif (!subscriptionInfo.enable) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tsubscriptionInfo.callback(newValue, oldValue);\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(e);\n\t\t\t}\n\t\t});\n\t\tif (this.propertiesLock.pop() !== propertyKey) {\n\t\t\tconsole.error('lock error');\n\t\t};\n\t}\n\tsubscribe(propertyKey: keyof T, callback: ValueChangedCallback): ScopeSubscription<T> {\n\t\tconst subscription: ScopeSubscription<T> = new ScopeSubscription(propertyKey, this);\n\t\tlet propertySubscribers = this.subscribers.get(propertyKey);\n\t\tif (!propertySubscribers) {\n\t\t\tpropertySubscribers = new Map();\n\t\t\tthis.subscribers.set(propertyKey, propertySubscribers);\n\t\t}\n\t\tpropertySubscribers.set(subscription, { callback, enable: true });\n\t\treturn subscription;\n\t}\n\n\tunsubscribe(propertyKey: keyof T, subscription?: ScopeSubscription<T>) {\n\t\tif (subscription) {\n\t\t\tthis.subscribers.get(propertyKey)?.delete(subscription);\n\t\t} else {\n\t\t\tthis.subscribers.delete(propertyKey);\n\t\t}\n\t}\n\n\tpause(propertyKey: keyof T, subscription: ScopeSubscription<T>) {\n\t\tconst subscriptionInfo = this.subscribers.get(propertyKey)?.get(subscription);\n\t\tsubscriptionInfo && (subscriptionInfo.enable = false);\n\t}\n\n\tresume(propertyKey: keyof T, subscription: ScopeSubscription<T>) {\n\t\tconst subscriptionInfo = this.subscribers.get(propertyKey)?.get(subscription);\n\t\tsubscriptionInfo && (subscriptionInfo.enable = true);\n\t}\n\n\t/**\n\t * clear subscription maps\n\t */\n\tdestroy() {\n\t\tthis.subscribers.clear();\n\t}\n}\n\nexport class ReactiveScope<T extends ScopeContext> extends Scope<T> {\n\tstatic for<T extends ScopeContext>(context: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveScope(context, propertyKeys);\n\t}\n\tstatic blockScope<T extends ScopeContext>(propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveScope({} as T, propertyKeys);\n\t}\n\tprotected observer: ValueChangeObserver<T> = new ValueChangeObserver<T>();\n\tprotected name?: string;\n\n\tconstructor(context: T, propertyKeys?: (keyof T)[]);\n\tconstructor(context: T, name: string, parent: ReactiveScope<any>, propertyKeys?: (keyof T)[]);\n\tconstructor(context: T, name?: string | (keyof T)[], protected parent?: ReactiveScope<any>, propertyKeys?: (keyof T)[]) {\n\t\tsuper(context, Array.isArray(name) ? name : propertyKeys);\n\t\tif (typeof name == 'string') {\n\t\t\tthis.name = name;\n\t\t}\n\t\tif (Array.isArray(name)) {\n\t\t\tthis.propertyKeys = name;\n\t\t}\n\t}\n\n\tset(propertyKey: keyof T, newValue: any, receiver?: any): boolean {\n\t\tconst oldValue = Reflect.get(this.context, propertyKey);\n\t\tconst result = Reflect.set(this.context, propertyKey, newValue);\n\t\tif (result) {\n\t\t\tthis.emit(propertyKey, newValue, oldValue);\n\t\t}\n\t\treturn result;\n\t}\n\tdelete(propertyKey: keyof T): boolean {\n\t\tconst oldValue = Reflect.get(this.context, propertyKey);\n\t\tconst isDelete = Reflect.deleteProperty(this.context, propertyKey);\n\t\tif (isDelete && oldValue !== undefined) {\n\t\t\tthis.emit(propertyKey, undefined, oldValue);\n\t\t}\n\t\treturn isDelete;\n\t}\n\tgetScope<V extends ScopeContext>(propertyKey: keyof T): ReactiveScope<V> | undefined {\n\t\tconst scopeContext = this.get(propertyKey) as V;\n\t\tlet scope = this.scopeMap.get(propertyKey) as ReactiveScope<any> | undefined;\n\t\tif (scope) {\n\t\t\tscope.context = scopeContext;\n\t\t\treturn scope;\n\t\t}\n\t\tif (typeof scopeContext !== 'object') {\n\t\t\treturn;\n\t\t}\n\t\tscope = new ReactiveScope<V>(scopeContext, propertyKey as string, this);\n\t\tthis.scopeMap.set(propertyKey, scope);\n\t\treturn scope;\n\t}\n\tgetScopeOrCreat<V extends ScopeContext>(propertyKey: keyof T): ReactiveScope<V> {\n\t\tconst scopeContext = this.get(propertyKey) as V;\n\t\tlet scope = this.scopeMap.get(propertyKey) as ReactiveScope<any> | undefined;\n\t\tif (scope) {\n\t\t\tscope.context = scopeContext;\n\t\t\treturn scope;\n\t\t}\n\t\tscope = new ReactiveScope<V>(scopeContext, propertyKey as string, this);\n\t\tthis.scopeMap.set(propertyKey, scope);\n\t\treturn scope;\n\t}\n\temit(propertyKey: keyof T, newValue: any, oldValue?: any): void {\n\t\tthis.observer.emit(propertyKey, newValue, oldValue);\n\t\tthis.parent?.emit(this.name!, this.context);\n\t}\n\tsubscribe(propertyKey: keyof T, callback: ValueChangedCallback): ScopeSubscription<T> {\n\t\treturn this.observer.subscribe(propertyKey, callback);\n\t}\n\tunsubscribe(propertyKey?: keyof T, subscription?: ScopeSubscription<T>) {\n\t\tif (propertyKey && subscription) {\n\t\t\tthis.observer.unsubscribe(propertyKey, subscription);\n\t\t} else if (propertyKey) {\n\t\t\tthis.observer.unsubscribe(propertyKey);\n\t\t} else {\n\t\t\tthis.observer.destroy();\n\t\t}\n\t}\n\tgetClass(): TypeOf<ReactiveScope<ScopeContext>> {\n\t\treturn ReactiveScope;\n\t}\n}\n\n/**\n * used control/notify/pause scope about changes in current context\n */\nexport interface ScopeControl<T extends ScopeContext> {\n\n\t/**\n\t * get current stacte of applying change detection.\n\t */\n\tisAttached(): boolean;\n\n\t/**\n\t * used when want to update ui-view like, you want to replace an array with another \n\t * without reflect changes on view until reattached again.\n\t */\n\tdetach(): void;\n\n\t/**\n\t * apply all the not emitted changes, and continue emit in time.\n\t */\n\treattach(): void;\n\n\t/**\n\t * apply changes now,\n\t * will not effect the state of the detector wither if attached ot not.\n\t * \n\t * if a propertyKey is provided, will emit this property only \n\t * @param propertyKey \n\t */\n\temitChanges(propertyKey?: keyof T, propertyValue?: any): void;\n}\n\nexport class ReactiveScopeControl<T extends ScopeContext> extends ReactiveScope<T> implements ScopeControl<T> {\n\tstatic for<T extends ScopeContext>(context: T, propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveScopeControl(context, propertyKeys);\n\t}\n\tstatic blockScope<T extends ScopeContext>(propertyKeys?: (keyof T)[]) {\n\t\treturn new ReactiveScopeControl({} as T, propertyKeys);\n\t}\n\n\tprotected attached: boolean = true;\n\tprotected marked: ScopeContext = {};\n\toverride emit(propertyKey: keyof T, newValue: any, oldValue?: any): void {\n\t\tif (this.attached) {\n\t\t\tsuper.emit(propertyKey, newValue, oldValue);\n\t\t} else {\n\t\t\tthis.marked[propertyKey] = newValue;\n\t\t}\n\t}\n\tisAttached(): boolean {\n\t\treturn this.attached;\n\t}\n\tdetach(): void {\n\t\tthis.attached = false;\n\t}\n\treattach(): void {\n\t\tthis.attached = true;\n\t\tthis.emitChanges();\n\t}\n\temitChanges(propertyKey?: keyof T, propertyValue?: any): void {\n\t\tif (propertyKey) {\n\t\t\tsuper.emit(propertyKey, propertyValue);\n\t\t\tReflect.deleteProperty(this.marked, propertyKey);\n\t\t\treturn;\n\t\t}\n\t\tconst latestChanges = this.marked;\n\t\tthis.marked = {};\n\t\tObject.keys(latestChanges).forEach(propertyKey => {\n\t\t\tsuper.emit(propertyKey, latestChanges[propertyKey]);\n\t\t});\n\t}\n\tgetClass(): TypeOf<ReactiveScopeControl<ScopeContext>> {\n\t\treturn ReactiveScopeControl;\n\t}\n}\n\n\ninterface ImportMeta {\n\turl: URL;\n\t/**\n\t *\n\t * Provides a module-relative resolution function scoped to each module, returning\n\t * the URL string.\n\t *\n\t * @param specified The module specifier to resolve relative to `parent`.\n\t * @param parent The absolute parent module URL to resolve from. If none\n\t * is specified, the value of `import.meta.url` is used as the default.\n\t */\n\tresolve?(specified: string, parent?: string | URL): Promise<string>;\n}\n\nexport interface ModuleImport {\n\tmeta: ImportMeta\n}\n\nexport interface ModuleContext extends ScopeContext {\n\timport: ModuleImport & ((path: string) => Promise<any>);\n}\n\nexport class ModuleScope extends ReactiveScope<ModuleContext> {\n\tconstructor(context: ModuleContext, propertyKeys?: (keyof ModuleContext)[]) {\n\t\tsuper(context, propertyKeys);\n\t}\n\timportModule(propertyKey: keyof ModuleContext, scope: ModuleScope): void {\n\t\tthis.scopeMap.set(propertyKey, scope);\n\t}\n}\nexport class WebModuleScope extends ModuleScope {\n\tconstructor() {\n\t\tsuper({} as ModuleContext);\n\t}\n\tupdateContext(context: any) {\n\t\tthis.context = context;\n\t}\n}\n"]}
|
package/scope/stack.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { CanDeclareExpression } from '../api/expression.js';
|
|
2
|
-
import { ReactiveScope, Scope, ScopeContext,
|
|
2
|
+
import { ModuleScope, ReactiveScope, Scope, ScopeContext, WebModuleScope } from './scope.js';
|
|
3
3
|
export interface AwaitPromiseInfo {
|
|
4
4
|
promise: Promise<any>;
|
|
5
5
|
node: CanDeclareExpression;
|
|
6
6
|
declareVariable: boolean;
|
|
7
|
-
scopeType: ScopeType;
|
|
8
7
|
}
|
|
9
8
|
export interface AsyncIterableInfo {
|
|
10
9
|
iterable: AsyncIterable<any>;
|
|
@@ -16,7 +15,7 @@ export interface Stack {
|
|
|
16
15
|
has(propertyKey: PropertyKey): boolean;
|
|
17
16
|
get(propertyKey: PropertyKey): any;
|
|
18
17
|
set(propertyKey: PropertyKey, value: any, receiver?: any): boolean;
|
|
19
|
-
declareVariable(
|
|
18
|
+
declareVariable(propertyKey: PropertyKey, propertyValue?: any): any;
|
|
20
19
|
findScope<T extends ScopeContext>(propertyKey: PropertyKey): Scope<T>;
|
|
21
20
|
resolveAwait(value: AwaitPromiseInfo): void;
|
|
22
21
|
lastScope<T extends ScopeContext>(): Scope<T>;
|
|
@@ -26,32 +25,50 @@ export interface Stack {
|
|
|
26
25
|
removeScope<T extends ScopeContext>(scope: Scope<T>): void;
|
|
27
26
|
pushScope<T extends ScopeContext>(scope: Scope<T>): void;
|
|
28
27
|
pushBlockScope<T extends ScopeContext>(): Scope<T>;
|
|
29
|
-
pushFunctionScope<T extends ScopeContext>(): Scope<T>;
|
|
30
28
|
pushBlockScopeFor<T extends ScopeContext>(context: T): Scope<T>;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
pushFunctionReactiveScope<T extends ScopeContext>(): ReactiveScope<T>;
|
|
34
|
-
pushBlockReactiveScopeFor<T extends ScopeContext>(context: T): ReactiveScope<T>;
|
|
35
|
-
pushFunctionReactiveScopeFor<T extends ScopeContext>(context: T): ReactiveScope<T>;
|
|
29
|
+
pushReactiveScope<T extends ScopeContext>(): ReactiveScope<T>;
|
|
30
|
+
pushReactiveScopeFor<T extends ScopeContext>(context: T): ReactiveScope<T>;
|
|
36
31
|
copyStack(): Stack;
|
|
32
|
+
detach(): void;
|
|
33
|
+
reattach(): void;
|
|
34
|
+
importModule(source: string, importCallOptions?: ImportCallOptions): ModuleScope;
|
|
35
|
+
getModule(): ModuleScope | undefined;
|
|
36
|
+
onDestroy(action: () => void): void;
|
|
37
37
|
}
|
|
38
38
|
export declare class Stack implements Stack {
|
|
39
|
-
static for(...contexts: Scope<
|
|
40
|
-
static forScopes(...scopes: Scope<
|
|
39
|
+
static for(...contexts: Scope<ScopeContext>[]): Stack;
|
|
40
|
+
static forScopes(...scopes: Scope<ScopeContext>[]): Stack;
|
|
41
|
+
static moduleScope(resolver: ModuleScopeResolver, moduleSource: string, ...globalScopes: Scope<ScopeContext>[]): Stack;
|
|
41
42
|
awaitPromise: AwaitPromiseInfo[];
|
|
42
43
|
forAwaitAsyncIterable?: AsyncIterableInfo | undefined;
|
|
43
44
|
protected readonly stack: Array<Scope<any>>;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
45
|
+
protected readonly moduleScope?: ModuleScope;
|
|
46
|
+
protected readonly moduleSource?: string;
|
|
47
|
+
protected readonly resolver?: ModuleScopeResolver;
|
|
48
|
+
protected readonly onDestroyActions: (() => void)[];
|
|
49
|
+
constructor();
|
|
50
|
+
constructor(globalScope: Scope<ScopeContext>);
|
|
51
|
+
constructor(globalScope: Scope<ScopeContext>, resolver: ModuleScopeResolver, moduleSource: string);
|
|
52
|
+
constructor(stack: Array<Scope<ScopeContext>>);
|
|
53
|
+
constructor(stack: Array<Scope<ScopeContext>>, resolver: ModuleScopeResolver, moduleSource: string);
|
|
54
|
+
private initModuleContext;
|
|
55
|
+
private getReactiveScopeControls;
|
|
56
|
+
}
|
|
57
|
+
export interface ModuleScopeResolver {
|
|
58
|
+
resolve(source: string, moduleScope: ModuleScope, importCallOptions?: ImportCallOptions): ModuleScope;
|
|
59
|
+
resolveURL(specified: string, parent: string | URL): string;
|
|
60
|
+
}
|
|
61
|
+
export declare function createRootURL(source: string): URL;
|
|
62
|
+
export interface ResolverConfig {
|
|
63
|
+
allowImportExternal?: boolean;
|
|
64
|
+
}
|
|
65
|
+
export declare class ModuleScopeResolver implements ModuleScopeResolver {
|
|
66
|
+
protected config?: ResolverConfig | undefined;
|
|
67
|
+
protected modules: [string, ModuleScope][];
|
|
68
|
+
constructor(config?: ResolverConfig | undefined);
|
|
69
|
+
register(source: string, moduleScope: ModuleScope): void;
|
|
70
|
+
protected findScopeBySource(source: string, importCallOptions?: ImportCallOptions): ModuleScope;
|
|
71
|
+
protected findSourceByScope(moduleScope: ModuleScope): string;
|
|
72
|
+
protected resolveExternalModule(source: string, importCallOptions?: ImportCallOptions): WebModuleScope;
|
|
73
|
+
protected readonly isValidHTTPUrl: (string: string) => boolean;
|
|
57
74
|
}
|