@flowgram.ai/variable-core 0.1.0-alpha.7 → 0.1.0-alpha.8
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/esm/index.js +315 -241
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +546 -547
- package/dist/index.d.ts +546 -547
- package/dist/index.js +349 -276
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -43,7 +43,6 @@ __export(src_exports, {
|
|
|
43
43
|
CustomType: () => CustomType,
|
|
44
44
|
DataNode: () => DataNode,
|
|
45
45
|
EnumerateExpression: () => EnumerateExpression,
|
|
46
|
-
ExpressionList: () => ExpressionList,
|
|
47
46
|
IntegerType: () => IntegerType,
|
|
48
47
|
KeyPathExpression: () => KeyPathExpression,
|
|
49
48
|
KeyPathExpressionV2: () => KeyPathExpressionV2,
|
|
@@ -64,7 +63,7 @@ __export(src_exports, {
|
|
|
64
63
|
VariableEngine: () => VariableEngine,
|
|
65
64
|
VariableEngineProvider: () => VariableEngineProvider,
|
|
66
65
|
VariableFieldKeyRenameService: () => VariableFieldKeyRenameService,
|
|
67
|
-
|
|
66
|
+
WrapArrayExpression: () => WrapArrayExpression,
|
|
68
67
|
injectToAST: () => injectToAST,
|
|
69
68
|
isMatchAST: () => isMatchAST,
|
|
70
69
|
postConstructAST: () => postConstructAST,
|
|
@@ -76,13 +75,13 @@ __export(src_exports, {
|
|
|
76
75
|
module.exports = __toCommonJS(src_exports);
|
|
77
76
|
|
|
78
77
|
// src/variable-container-module.ts
|
|
79
|
-
var
|
|
78
|
+
var import_inversify8 = require("inversify");
|
|
80
79
|
|
|
81
80
|
// src/variable-engine.ts
|
|
82
81
|
var import_rxjs6 = require("rxjs");
|
|
83
|
-
var
|
|
84
|
-
var
|
|
85
|
-
var
|
|
82
|
+
var import_inversify6 = require("inversify");
|
|
83
|
+
var import_utils8 = require("@flowgram.ai/utils");
|
|
84
|
+
var import_utils9 = require("@flowgram.ai/utils");
|
|
86
85
|
|
|
87
86
|
// src/utils/toDisposable.tsx
|
|
88
87
|
var import_utils = require("@flowgram.ai/utils");
|
|
@@ -112,9 +111,121 @@ var createMemo = () => {
|
|
|
112
111
|
return memo;
|
|
113
112
|
};
|
|
114
113
|
|
|
114
|
+
// src/scope/variable-table.ts
|
|
115
|
+
var import_rxjs = require("rxjs");
|
|
116
|
+
var import_utils2 = require("@flowgram.ai/utils");
|
|
117
|
+
var VariableTable = class {
|
|
118
|
+
constructor(parentTable) {
|
|
119
|
+
this.parentTable = parentTable;
|
|
120
|
+
this.table = /* @__PURE__ */ new Map();
|
|
121
|
+
this.onDataChangeEmitter = new import_utils2.Emitter();
|
|
122
|
+
this.variables$ = new import_rxjs.Subject();
|
|
123
|
+
// 监听变量列表中的单个变量变化
|
|
124
|
+
this.anyVariableChange$ = this.variables$.pipe(
|
|
125
|
+
(0, import_rxjs.switchMap)(
|
|
126
|
+
(_variables) => (0, import_rxjs.merge)(
|
|
127
|
+
..._variables.map(
|
|
128
|
+
(_v) => _v.value$.pipe(
|
|
129
|
+
// 跳过 BehaviorSubject 第一个
|
|
130
|
+
(0, import_rxjs.skip)(1)
|
|
131
|
+
)
|
|
132
|
+
)
|
|
133
|
+
)
|
|
134
|
+
),
|
|
135
|
+
(0, import_rxjs.share)()
|
|
136
|
+
);
|
|
137
|
+
this.onDataChange = this.onDataChangeEmitter.event;
|
|
138
|
+
this._version = 0;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* 监听任意变量变化
|
|
142
|
+
* @param observer 监听器,变量变化时会吐出值
|
|
143
|
+
* @returns
|
|
144
|
+
*/
|
|
145
|
+
onAnyVariableChange(observer) {
|
|
146
|
+
return subsToDisposable(this.anyVariableChange$.subscribe(observer));
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* 列表或者任意变量变化
|
|
150
|
+
* @param observer
|
|
151
|
+
*/
|
|
152
|
+
onAnyChange(observer) {
|
|
153
|
+
const disposables = new import_utils2.DisposableCollection();
|
|
154
|
+
disposables.pushAll([this.onDataChange(observer), this.onAnyVariableChange(observer)]);
|
|
155
|
+
return disposables;
|
|
156
|
+
}
|
|
157
|
+
fireChange() {
|
|
158
|
+
var _a;
|
|
159
|
+
this._version++;
|
|
160
|
+
this.onDataChangeEmitter.fire();
|
|
161
|
+
(_a = this.parentTable) == null ? void 0 : _a.fireChange();
|
|
162
|
+
}
|
|
163
|
+
get version() {
|
|
164
|
+
return this._version;
|
|
165
|
+
}
|
|
166
|
+
get variables() {
|
|
167
|
+
return Array.from(this.table.values());
|
|
168
|
+
}
|
|
169
|
+
get variableKeys() {
|
|
170
|
+
return Array.from(this.table.keys());
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* 根据 keyPath 找到对应的变量,或 Property 节点
|
|
174
|
+
* @param keyPath
|
|
175
|
+
* @returns
|
|
176
|
+
*/
|
|
177
|
+
getByKeyPath(keyPath) {
|
|
178
|
+
const [variableKey, ...propertyKeys] = keyPath || [];
|
|
179
|
+
if (!variableKey) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const variable = this.getVariableByKey(variableKey);
|
|
183
|
+
return propertyKeys.length ? variable == null ? void 0 : variable.getByKeyPath(propertyKeys) : variable;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* 根据 key 值找到相应的变量
|
|
187
|
+
* @param key
|
|
188
|
+
* @returns
|
|
189
|
+
*/
|
|
190
|
+
getVariableByKey(key) {
|
|
191
|
+
return this.table.get(key);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* 往 variableTable 添加输出变量
|
|
195
|
+
* @param variable
|
|
196
|
+
*/
|
|
197
|
+
addVariableToTable(variable) {
|
|
198
|
+
this.table.set(variable.key, variable);
|
|
199
|
+
if (this.parentTable) {
|
|
200
|
+
this.parentTable.addVariableToTable(variable);
|
|
201
|
+
}
|
|
202
|
+
this.variables$.next(this.variables);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* 从 variableTable 中移除变量
|
|
206
|
+
* @param key
|
|
207
|
+
*/
|
|
208
|
+
removeVariableFromTable(key) {
|
|
209
|
+
this.table.delete(key);
|
|
210
|
+
if (this.parentTable) {
|
|
211
|
+
this.parentTable.removeVariableFromTable(key);
|
|
212
|
+
}
|
|
213
|
+
this.variables$.next(this.variables);
|
|
214
|
+
}
|
|
215
|
+
dispose() {
|
|
216
|
+
this.variableKeys.forEach(
|
|
217
|
+
(_key) => {
|
|
218
|
+
var _a;
|
|
219
|
+
return (_a = this.parentTable) == null ? void 0 : _a.removeVariableFromTable(_key);
|
|
220
|
+
}
|
|
221
|
+
);
|
|
222
|
+
this.onDataChangeEmitter.dispose();
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
|
|
115
226
|
// src/scope/scope-chain.ts
|
|
116
227
|
var import_inversify = require("inversify");
|
|
117
|
-
var
|
|
228
|
+
var import_utils3 = require("@flowgram.ai/utils");
|
|
118
229
|
|
|
119
230
|
// src/providers.ts
|
|
120
231
|
var VariableEngineProvider = Symbol("DynamicVariableEngine");
|
|
@@ -123,7 +234,7 @@ var ContainerProvider = Symbol("ContainerProvider");
|
|
|
123
234
|
// src/scope/scope-chain.ts
|
|
124
235
|
var ScopeChain = class {
|
|
125
236
|
constructor() {
|
|
126
|
-
this.toDispose = new
|
|
237
|
+
this.toDispose = new import_utils3.DisposableCollection();
|
|
127
238
|
}
|
|
128
239
|
get variableEngine() {
|
|
129
240
|
return this.variableEngineProvider();
|
|
@@ -155,7 +266,7 @@ ScopeChain = __decorateClass([
|
|
|
155
266
|
], ScopeChain);
|
|
156
267
|
|
|
157
268
|
// src/scope/scope.ts
|
|
158
|
-
var
|
|
269
|
+
var import_utils7 = require("@flowgram.ai/utils");
|
|
159
270
|
|
|
160
271
|
// src/ast/types.ts
|
|
161
272
|
var ASTKind = /* @__PURE__ */ ((ASTKind2) => {
|
|
@@ -174,7 +285,7 @@ var ASTKind = /* @__PURE__ */ ((ASTKind2) => {
|
|
|
174
285
|
ASTKind2["VariableDeclarationList"] = "VariableDeclarationList";
|
|
175
286
|
ASTKind2["KeyPathExpression"] = "KeyPathExpression";
|
|
176
287
|
ASTKind2["EnumerateExpression"] = "EnumerateExpression";
|
|
177
|
-
ASTKind2["
|
|
288
|
+
ASTKind2["WrapArrayExpression"] = "WrapArrayExpression";
|
|
178
289
|
ASTKind2["ListNode"] = "ListNode";
|
|
179
290
|
ASTKind2["DataNode"] = "DataNode";
|
|
180
291
|
ASTKind2["MapNode"] = "MapNode";
|
|
@@ -183,7 +294,7 @@ var ASTKind = /* @__PURE__ */ ((ASTKind2) => {
|
|
|
183
294
|
|
|
184
295
|
// src/ast/ast-registers.ts
|
|
185
296
|
var import_lodash3 = require("lodash");
|
|
186
|
-
var
|
|
297
|
+
var import_inversify3 = require("inversify");
|
|
187
298
|
|
|
188
299
|
// src/ast/utils/inversify.ts
|
|
189
300
|
var injectToAST = (serviceIdentifier) => function(target, propertyKey) {
|
|
@@ -216,21 +327,21 @@ var postConstructAST = () => (target, propertyKey) => {
|
|
|
216
327
|
// src/ast/match.ts
|
|
217
328
|
var ASTMatch;
|
|
218
329
|
((ASTMatch2) => {
|
|
219
|
-
ASTMatch2.isString = (node) => node
|
|
220
|
-
ASTMatch2.isNumber = (node) => node
|
|
221
|
-
ASTMatch2.isBoolean = (node) => node
|
|
222
|
-
ASTMatch2.isInteger = (node) => node
|
|
223
|
-
ASTMatch2.isObject = (node) => node
|
|
224
|
-
ASTMatch2.isArray = (node) => node
|
|
225
|
-
ASTMatch2.isMap = (node) => node
|
|
226
|
-
ASTMatch2.isCustomType = (node) => node
|
|
227
|
-
ASTMatch2.isVariableDeclaration = (node) => node
|
|
228
|
-
ASTMatch2.isProperty = (node) => node
|
|
229
|
-
ASTMatch2.isVariableDeclarationList = (node) => node
|
|
230
|
-
ASTMatch2.isEnumerateExpression = (node) => node
|
|
231
|
-
ASTMatch2.isKeyPathExpression = (node) => node
|
|
330
|
+
ASTMatch2.isString = (node) => (node == null ? void 0 : node.kind) === "String" /* String */;
|
|
331
|
+
ASTMatch2.isNumber = (node) => (node == null ? void 0 : node.kind) === "Number" /* Number */;
|
|
332
|
+
ASTMatch2.isBoolean = (node) => (node == null ? void 0 : node.kind) === "Boolean" /* Boolean */;
|
|
333
|
+
ASTMatch2.isInteger = (node) => (node == null ? void 0 : node.kind) === "Integer" /* Integer */;
|
|
334
|
+
ASTMatch2.isObject = (node) => (node == null ? void 0 : node.kind) === "Object" /* Object */;
|
|
335
|
+
ASTMatch2.isArray = (node) => (node == null ? void 0 : node.kind) === "Array" /* Array */;
|
|
336
|
+
ASTMatch2.isMap = (node) => (node == null ? void 0 : node.kind) === "Map" /* Map */;
|
|
337
|
+
ASTMatch2.isCustomType = (node) => (node == null ? void 0 : node.kind) === "CustomType" /* CustomType */;
|
|
338
|
+
ASTMatch2.isVariableDeclaration = (node) => (node == null ? void 0 : node.kind) === "VariableDeclaration" /* VariableDeclaration */;
|
|
339
|
+
ASTMatch2.isProperty = (node) => (node == null ? void 0 : node.kind) === "Property" /* Property */;
|
|
340
|
+
ASTMatch2.isVariableDeclarationList = (node) => (node == null ? void 0 : node.kind) === "VariableDeclarationList" /* VariableDeclarationList */;
|
|
341
|
+
ASTMatch2.isEnumerateExpression = (node) => (node == null ? void 0 : node.kind) === "EnumerateExpression" /* EnumerateExpression */;
|
|
342
|
+
ASTMatch2.isKeyPathExpression = (node) => (node == null ? void 0 : node.kind) === "KeyPathExpression" /* KeyPathExpression */;
|
|
232
343
|
function is(node, targetType) {
|
|
233
|
-
return node
|
|
344
|
+
return (node == null ? void 0 : node.kind) === (targetType == null ? void 0 : targetType.kind);
|
|
234
345
|
}
|
|
235
346
|
ASTMatch2.is = is;
|
|
236
347
|
})(ASTMatch || (ASTMatch = {}));
|
|
@@ -243,8 +354,8 @@ function updateChildNodeHelper({
|
|
|
243
354
|
nextJSON
|
|
244
355
|
}) {
|
|
245
356
|
const currNode = getChildNode();
|
|
246
|
-
const isNewKind = currNode
|
|
247
|
-
const isNewKey = nextJSON
|
|
357
|
+
const isNewKind = (currNode == null ? void 0 : currNode.kind) !== (nextJSON == null ? void 0 : nextJSON.kind);
|
|
358
|
+
const isNewKey = (nextJSON == null ? void 0 : nextJSON.key) && (nextJSON == null ? void 0 : nextJSON.key) !== (currNode == null ? void 0 : currNode.key);
|
|
248
359
|
if (isNewKind || isNewKey) {
|
|
249
360
|
if (currNode) {
|
|
250
361
|
currNode.dispose();
|
|
@@ -259,7 +370,7 @@ function updateChildNodeHelper({
|
|
|
259
370
|
this.fireChange();
|
|
260
371
|
}
|
|
261
372
|
} else if (nextJSON) {
|
|
262
|
-
currNode
|
|
373
|
+
currNode == null ? void 0 : currNode.fromJSON(nextJSON);
|
|
263
374
|
}
|
|
264
375
|
return currNode;
|
|
265
376
|
}
|
|
@@ -287,10 +398,10 @@ var ASTNodeFlags = /* @__PURE__ */ ((ASTNodeFlags2) => {
|
|
|
287
398
|
})(ASTNodeFlags || {});
|
|
288
399
|
|
|
289
400
|
// src/ast/ast-node.ts
|
|
290
|
-
var
|
|
401
|
+
var import_rxjs2 = require("rxjs");
|
|
291
402
|
var import_nanoid = require("nanoid");
|
|
292
403
|
var import_fast_equals = require("fast-equals");
|
|
293
|
-
var
|
|
404
|
+
var import_utils4 = require("@flowgram.ai/utils");
|
|
294
405
|
var ASTNode = class _ASTNode {
|
|
295
406
|
/**
|
|
296
407
|
* 构造函数
|
|
@@ -321,7 +432,7 @@ var ASTNode = class _ASTNode {
|
|
|
321
432
|
* AST 节点变化事件,基于 Rxjs 实现
|
|
322
433
|
* - 使用了 BehaviorSubject, 在订阅时会自动触发一次事件,事件为当前值
|
|
323
434
|
*/
|
|
324
|
-
this.value$ = new
|
|
435
|
+
this.value$ = new import_rxjs2.BehaviorSubject(this);
|
|
325
436
|
/**
|
|
326
437
|
* 子节点
|
|
327
438
|
*/
|
|
@@ -329,9 +440,10 @@ var ASTNode = class _ASTNode {
|
|
|
329
440
|
/**
|
|
330
441
|
* 删除节点处理事件列表
|
|
331
442
|
*/
|
|
332
|
-
this.toDispose = new
|
|
333
|
-
|
|
334
|
-
|
|
443
|
+
this.toDispose = new import_utils4.DisposableCollection(
|
|
444
|
+
import_utils4.Disposable.create(() => {
|
|
445
|
+
var _a;
|
|
446
|
+
(_a = this.parent) == null ? void 0 : _a.fireChange();
|
|
335
447
|
this.children.forEach((child) => child.dispose());
|
|
336
448
|
})
|
|
337
449
|
);
|
|
@@ -384,7 +496,7 @@ var ASTNode = class _ASTNode {
|
|
|
384
496
|
});
|
|
385
497
|
this._children.add(child);
|
|
386
498
|
child.toDispose.push(
|
|
387
|
-
|
|
499
|
+
import_utils4.Disposable.create(() => {
|
|
388
500
|
this._children.delete(child);
|
|
389
501
|
})
|
|
390
502
|
);
|
|
@@ -427,6 +539,7 @@ var ASTNode = class _ASTNode {
|
|
|
427
539
|
* 触发当前节点更新
|
|
428
540
|
*/
|
|
429
541
|
fireChange() {
|
|
542
|
+
var _a;
|
|
430
543
|
if (this.changeLocked || this.disposed) {
|
|
431
544
|
return;
|
|
432
545
|
}
|
|
@@ -437,7 +550,7 @@ var ASTNode = class _ASTNode {
|
|
|
437
550
|
this._version++;
|
|
438
551
|
this.value$.next(this);
|
|
439
552
|
this.dispatchGlobalEvent({ type: "UpdateAST" });
|
|
440
|
-
this.parent
|
|
553
|
+
(_a = this.parent) == null ? void 0 : _a.fireChange();
|
|
441
554
|
}
|
|
442
555
|
/**
|
|
443
556
|
* 节点的版本值
|
|
@@ -461,8 +574,8 @@ var ASTNode = class _ASTNode {
|
|
|
461
574
|
subscribe(observer, { selector, debounceAnimation, triggerOnInit } = {}) {
|
|
462
575
|
return subsToDisposable(
|
|
463
576
|
this.value$.pipe(
|
|
464
|
-
(0,
|
|
465
|
-
(0,
|
|
577
|
+
(0, import_rxjs2.map)(() => selector ? selector(this) : this),
|
|
578
|
+
(0, import_rxjs2.distinctUntilChanged)(
|
|
466
579
|
(a, b) => (0, import_fast_equals.shallowEqual)(a, b),
|
|
467
580
|
(value) => {
|
|
468
581
|
if (value instanceof _ASTNode) {
|
|
@@ -472,9 +585,9 @@ var ASTNode = class _ASTNode {
|
|
|
472
585
|
}
|
|
473
586
|
),
|
|
474
587
|
// 默认跳过 BehaviorSubject 第一次触发
|
|
475
|
-
triggerOnInit ? (0,
|
|
588
|
+
triggerOnInit ? (0, import_rxjs2.tap)(() => null) : (0, import_rxjs2.skip)(1),
|
|
476
589
|
// 每个 animationFrame 内所有更新合并成一个
|
|
477
|
-
debounceAnimation ? (0,
|
|
590
|
+
debounceAnimation ? (0, import_rxjs2.debounceTime)(0, import_rxjs2.animationFrameScheduler) : (0, import_rxjs2.tap)(() => null)
|
|
478
591
|
).subscribe(observer)
|
|
479
592
|
);
|
|
480
593
|
}
|
|
@@ -508,17 +621,18 @@ var BaseType = class extends ASTNode {
|
|
|
508
621
|
this.flags = 8 /* BasicType */;
|
|
509
622
|
}
|
|
510
623
|
/**
|
|
511
|
-
*
|
|
624
|
+
* 类型是否一致
|
|
512
625
|
* @param targetTypeJSON
|
|
513
626
|
*/
|
|
514
627
|
isTypeEqual(targetTypeJSONOrKind) {
|
|
628
|
+
var _a;
|
|
515
629
|
const targetTypeJSON = parseTypeJsonOrKind(targetTypeJSONOrKind);
|
|
516
|
-
if (targetTypeJSON
|
|
517
|
-
return (targetTypeJSON
|
|
630
|
+
if ((targetTypeJSON == null ? void 0 : targetTypeJSON.kind) === "Union" /* Union */) {
|
|
631
|
+
return (_a = (targetTypeJSON == null ? void 0 : targetTypeJSON.types) || []) == null ? void 0 : _a.some(
|
|
518
632
|
(_subType) => this.isTypeEqual(_subType)
|
|
519
633
|
);
|
|
520
634
|
}
|
|
521
|
-
return this.kind === targetTypeJSON
|
|
635
|
+
return this.kind === (targetTypeJSON == null ? void 0 : targetTypeJSON.kind);
|
|
522
636
|
}
|
|
523
637
|
/**
|
|
524
638
|
* 可下钻类型需实现
|
|
@@ -527,6 +641,10 @@ var BaseType = class extends ASTNode {
|
|
|
527
641
|
getByKeyPath(keyPath = []) {
|
|
528
642
|
throw new Error(`Get By Key Path is not implemented for Type: ${this.kind}`);
|
|
529
643
|
}
|
|
644
|
+
/**
|
|
645
|
+
* Get AST JSON for current base type
|
|
646
|
+
* @returns
|
|
647
|
+
*/
|
|
530
648
|
toJSON() {
|
|
531
649
|
return {
|
|
532
650
|
kind: this.kind
|
|
@@ -545,7 +663,8 @@ var ArrayType = class extends BaseType {
|
|
|
545
663
|
}
|
|
546
664
|
// items 类型是否可下钻
|
|
547
665
|
get canDrilldownItems() {
|
|
548
|
-
|
|
666
|
+
var _a;
|
|
667
|
+
return !!(((_a = this.items) == null ? void 0 : _a.flags) & 16 /* DrilldownType */);
|
|
549
668
|
}
|
|
550
669
|
getByKeyPath(keyPath) {
|
|
551
670
|
const [curr, ...rest] = keyPath || [];
|
|
@@ -557,11 +676,11 @@ var ArrayType = class extends BaseType {
|
|
|
557
676
|
isTypeEqual(targetTypeJSONOrKind) {
|
|
558
677
|
const targetTypeJSON = parseTypeJsonOrKind(targetTypeJSONOrKind);
|
|
559
678
|
const isSuperEqual = super.isTypeEqual(targetTypeJSONOrKind);
|
|
560
|
-
if (targetTypeJSON
|
|
679
|
+
if ((targetTypeJSON == null ? void 0 : targetTypeJSON.weak) || (targetTypeJSON == null ? void 0 : targetTypeJSON.kind) === "Union" /* Union */) {
|
|
561
680
|
return isSuperEqual;
|
|
562
681
|
}
|
|
563
682
|
return targetTypeJSON && isSuperEqual && // 弱比较,只需要比较 Kind 即可
|
|
564
|
-
(targetTypeJSON
|
|
683
|
+
((targetTypeJSON == null ? void 0 : targetTypeJSON.weak) || this.customStrongEqual(targetTypeJSON));
|
|
565
684
|
}
|
|
566
685
|
/**
|
|
567
686
|
* Array 强比较
|
|
@@ -569,15 +688,17 @@ var ArrayType = class extends BaseType {
|
|
|
569
688
|
* @returns
|
|
570
689
|
*/
|
|
571
690
|
customStrongEqual(targetTypeJSON) {
|
|
691
|
+
var _a;
|
|
572
692
|
if (!this.items) {
|
|
573
|
-
return !targetTypeJSON
|
|
693
|
+
return !(targetTypeJSON == null ? void 0 : targetTypeJSON.items);
|
|
574
694
|
}
|
|
575
|
-
return this.items
|
|
695
|
+
return (_a = this.items) == null ? void 0 : _a.isTypeEqual(targetTypeJSON.items);
|
|
576
696
|
}
|
|
577
697
|
toJSON() {
|
|
698
|
+
var _a;
|
|
578
699
|
return {
|
|
579
700
|
kind: "Array" /* Array */,
|
|
580
|
-
items: this.items
|
|
701
|
+
items: (_a = this.items) == null ? void 0 : _a.toJSON()
|
|
581
702
|
};
|
|
582
703
|
}
|
|
583
704
|
};
|
|
@@ -639,11 +760,11 @@ var MapType = class extends BaseType {
|
|
|
639
760
|
isTypeEqual(targetTypeJSONOrKind) {
|
|
640
761
|
const targetTypeJSON = parseTypeJsonOrKind(targetTypeJSONOrKind);
|
|
641
762
|
const isSuperEqual = super.isTypeEqual(targetTypeJSONOrKind);
|
|
642
|
-
if (targetTypeJSON
|
|
763
|
+
if ((targetTypeJSON == null ? void 0 : targetTypeJSON.weak) || (targetTypeJSON == null ? void 0 : targetTypeJSON.kind) === "Union" /* Union */) {
|
|
643
764
|
return isSuperEqual;
|
|
644
765
|
}
|
|
645
766
|
return targetTypeJSON && isSuperEqual && // 弱比较,只需要比较 Kind 即可
|
|
646
|
-
(targetTypeJSON
|
|
767
|
+
((targetTypeJSON == null ? void 0 : targetTypeJSON.weak) || this.customStrongEqual(targetTypeJSON));
|
|
647
768
|
}
|
|
648
769
|
/**
|
|
649
770
|
* Map 强比较
|
|
@@ -651,15 +772,17 @@ var MapType = class extends BaseType {
|
|
|
651
772
|
* @returns
|
|
652
773
|
*/
|
|
653
774
|
customStrongEqual(targetTypeJSON) {
|
|
775
|
+
var _a, _b;
|
|
654
776
|
const { keyType = "String" /* String */, valueType } = targetTypeJSON;
|
|
655
|
-
const isValueTypeEqual = !valueType && !this.valueType || this.valueType
|
|
656
|
-
return isValueTypeEqual && this.keyType
|
|
777
|
+
const isValueTypeEqual = !valueType && !this.valueType || ((_a = this.valueType) == null ? void 0 : _a.isTypeEqual(valueType));
|
|
778
|
+
return isValueTypeEqual && ((_b = this.keyType) == null ? void 0 : _b.isTypeEqual(keyType));
|
|
657
779
|
}
|
|
658
780
|
toJSON() {
|
|
781
|
+
var _a, _b;
|
|
659
782
|
return {
|
|
660
783
|
kind: "Map" /* Map */,
|
|
661
|
-
keyType: this.keyType
|
|
662
|
-
valueType: this.valueType
|
|
784
|
+
keyType: (_a = this.keyType) == null ? void 0 : _a.toJSON(),
|
|
785
|
+
valueType: (_b = this.valueType) == null ? void 0 : _b.toJSON()
|
|
663
786
|
};
|
|
664
787
|
}
|
|
665
788
|
};
|
|
@@ -695,7 +818,7 @@ var ObjectType = class extends BaseType {
|
|
|
695
818
|
});
|
|
696
819
|
removedKeys.forEach((key) => {
|
|
697
820
|
const property = this.propertyTable.get(key);
|
|
698
|
-
property
|
|
821
|
+
property == null ? void 0 : property.dispose();
|
|
699
822
|
this.propertyTable.delete(key);
|
|
700
823
|
this.fireChange();
|
|
701
824
|
});
|
|
@@ -719,12 +842,13 @@ var ObjectType = class extends BaseType {
|
|
|
719
842
|
* @returns
|
|
720
843
|
*/
|
|
721
844
|
getByKeyPath(keyPath) {
|
|
845
|
+
var _a;
|
|
722
846
|
const [curr, ...restKeyPath] = keyPath;
|
|
723
847
|
const property = this.propertyTable.get(curr);
|
|
724
848
|
if (!restKeyPath.length) {
|
|
725
849
|
return property;
|
|
726
850
|
}
|
|
727
|
-
if (property
|
|
851
|
+
if ((property == null ? void 0 : property.type) && ((_a = property == null ? void 0 : property.type) == null ? void 0 : _a.flags) & 16 /* DrilldownType */) {
|
|
728
852
|
return property.type.getByKeyPath(restKeyPath);
|
|
729
853
|
}
|
|
730
854
|
return void 0;
|
|
@@ -732,11 +856,11 @@ var ObjectType = class extends BaseType {
|
|
|
732
856
|
isTypeEqual(targetTypeJSONOrKind) {
|
|
733
857
|
const targetTypeJSON = parseTypeJsonOrKind(targetTypeJSONOrKind);
|
|
734
858
|
const isSuperEqual = super.isTypeEqual(targetTypeJSONOrKind);
|
|
735
|
-
if (targetTypeJSON
|
|
859
|
+
if ((targetTypeJSON == null ? void 0 : targetTypeJSON.weak) || (targetTypeJSON == null ? void 0 : targetTypeJSON.kind) === "Union" /* Union */) {
|
|
736
860
|
return isSuperEqual;
|
|
737
861
|
}
|
|
738
862
|
return targetTypeJSON && isSuperEqual && // 弱比较,只需要比较 Kind 即可
|
|
739
|
-
(targetTypeJSON
|
|
863
|
+
((targetTypeJSON == null ? void 0 : targetTypeJSON.weak) || this.customStrongEqual(targetTypeJSON));
|
|
740
864
|
}
|
|
741
865
|
/**
|
|
742
866
|
* Object 类型强比较
|
|
@@ -749,8 +873,9 @@ var ObjectType = class extends BaseType {
|
|
|
749
873
|
const targetPropertyKeys = targetProperties.map((_target) => _target.key);
|
|
750
874
|
const isKeyStrongEqual = !(0, import_lodash.xor)(sourcePropertyKeys, targetPropertyKeys).length;
|
|
751
875
|
return isKeyStrongEqual && targetProperties.every((targetProperty) => {
|
|
876
|
+
var _a;
|
|
752
877
|
const sourceProperty = this.propertyTable.get(targetProperty.key);
|
|
753
|
-
return sourceProperty && sourceProperty.key === targetProperty.key && sourceProperty.type
|
|
878
|
+
return sourceProperty && sourceProperty.key === targetProperty.key && ((_a = sourceProperty.type) == null ? void 0 : _a.isTypeEqual(targetProperty == null ? void 0 : targetProperty.type));
|
|
754
879
|
});
|
|
755
880
|
}
|
|
756
881
|
};
|
|
@@ -768,19 +893,20 @@ var CustomType = class extends BaseType {
|
|
|
768
893
|
}
|
|
769
894
|
}
|
|
770
895
|
isTypeEqual(targetTypeJSONOrKind) {
|
|
896
|
+
var _a;
|
|
771
897
|
const targetTypeJSON = parseTypeJsonOrKind(targetTypeJSONOrKind);
|
|
772
|
-
if (targetTypeJSON
|
|
773
|
-
return (targetTypeJSON
|
|
898
|
+
if ((targetTypeJSON == null ? void 0 : targetTypeJSON.kind) === "Union" /* Union */) {
|
|
899
|
+
return (_a = (targetTypeJSON == null ? void 0 : targetTypeJSON.types) || []) == null ? void 0 : _a.some(
|
|
774
900
|
(_subType) => this.isTypeEqual(_subType)
|
|
775
901
|
);
|
|
776
902
|
}
|
|
777
|
-
return targetTypeJSON
|
|
903
|
+
return (targetTypeJSON == null ? void 0 : targetTypeJSON.kind) === this.kind && (targetTypeJSON == null ? void 0 : targetTypeJSON.typeName) === this.typeName;
|
|
778
904
|
}
|
|
779
905
|
};
|
|
780
906
|
CustomType.kind = "CustomType" /* CustomType */;
|
|
781
907
|
|
|
782
908
|
// src/ast/expression/base-expression.ts
|
|
783
|
-
var
|
|
909
|
+
var import_rxjs3 = require("rxjs");
|
|
784
910
|
var import_fast_equals2 = require("fast-equals");
|
|
785
911
|
|
|
786
912
|
// src/ast/utils/variable-field.ts
|
|
@@ -805,22 +931,22 @@ var BaseExpression = class extends ASTNode {
|
|
|
805
931
|
* 引用变量
|
|
806
932
|
*/
|
|
807
933
|
this._refs = [];
|
|
808
|
-
this.refreshRefs$ = new
|
|
934
|
+
this.refreshRefs$ = new import_rxjs3.Subject();
|
|
809
935
|
/**
|
|
810
936
|
* 监听引用变量变化
|
|
811
937
|
* 监听 [a.b.c] -> [a.b]
|
|
812
938
|
*/
|
|
813
939
|
this.refs$ = this.refreshRefs$.pipe(
|
|
814
|
-
(0,
|
|
815
|
-
(0,
|
|
816
|
-
(0,
|
|
817
|
-
(refs) => !refs
|
|
940
|
+
(0, import_rxjs3.map)(() => this.getRefFields()),
|
|
941
|
+
(0, import_rxjs3.distinctUntilChanged)(import_fast_equals2.shallowEqual),
|
|
942
|
+
(0, import_rxjs3.switchMap)(
|
|
943
|
+
(refs) => !(refs == null ? void 0 : refs.length) ? (0, import_rxjs3.of)([]) : (0, import_rxjs3.combineLatest)(
|
|
818
944
|
refs.map(
|
|
819
|
-
(ref) => ref ? ref.value$ : (0,
|
|
945
|
+
(ref) => ref ? ref.value$ : (0, import_rxjs3.of)(void 0)
|
|
820
946
|
)
|
|
821
947
|
)
|
|
822
948
|
),
|
|
823
|
-
(0,
|
|
949
|
+
(0, import_rxjs3.share)()
|
|
824
950
|
);
|
|
825
951
|
this.toDispose.push(
|
|
826
952
|
subsToDisposable(
|
|
@@ -854,29 +980,6 @@ var BaseExpression = class extends ASTNode {
|
|
|
854
980
|
}
|
|
855
981
|
};
|
|
856
982
|
|
|
857
|
-
// src/ast/expression/expression-list.ts
|
|
858
|
-
var ExpressionList = class extends ASTNode {
|
|
859
|
-
fromJSON({ expressions }) {
|
|
860
|
-
this.expressions = expressions.map((_expression, idx) => {
|
|
861
|
-
const prevExpression = this.expressions[idx];
|
|
862
|
-
if (prevExpression.kind !== _expression.kind) {
|
|
863
|
-
prevExpression.dispose();
|
|
864
|
-
this.fireChange();
|
|
865
|
-
return this.createChildNode(_expression);
|
|
866
|
-
}
|
|
867
|
-
prevExpression.fromJSON(_expression);
|
|
868
|
-
return prevExpression;
|
|
869
|
-
});
|
|
870
|
-
}
|
|
871
|
-
toJSON() {
|
|
872
|
-
return {
|
|
873
|
-
kind: "ExpressionList" /* ExpressionList */,
|
|
874
|
-
properties: this.expressions.map((_expression) => _expression.toJSON())
|
|
875
|
-
};
|
|
876
|
-
}
|
|
877
|
-
};
|
|
878
|
-
ExpressionList.kind = "ExpressionList" /* ExpressionList */;
|
|
879
|
-
|
|
880
983
|
// src/ast/expression/keypath-expression.ts
|
|
881
984
|
var import_fast_equals3 = require("fast-equals");
|
|
882
985
|
var KeyPathExpression = class extends BaseExpression {
|
|
@@ -941,8 +1044,9 @@ var EnumerateExpression = class extends BaseExpression {
|
|
|
941
1044
|
return this._enumerateFor;
|
|
942
1045
|
}
|
|
943
1046
|
get returnType() {
|
|
944
|
-
|
|
945
|
-
|
|
1047
|
+
var _a;
|
|
1048
|
+
const childReturnType = (_a = this.enumerateFor) == null ? void 0 : _a.returnType;
|
|
1049
|
+
if ((childReturnType == null ? void 0 : childReturnType.kind) === "Array" /* Array */) {
|
|
946
1050
|
return childReturnType.items;
|
|
947
1051
|
}
|
|
948
1052
|
return void 0;
|
|
@@ -954,9 +1058,10 @@ var EnumerateExpression = class extends BaseExpression {
|
|
|
954
1058
|
this.updateChildNodeByKey("_enumerateFor", expression);
|
|
955
1059
|
}
|
|
956
1060
|
toJSON() {
|
|
1061
|
+
var _a;
|
|
957
1062
|
return {
|
|
958
1063
|
kind: "EnumerateExpression" /* EnumerateExpression */,
|
|
959
|
-
enumerateFor: this.enumerateFor
|
|
1064
|
+
enumerateFor: (_a = this.enumerateFor) == null ? void 0 : _a.toJSON()
|
|
960
1065
|
};
|
|
961
1066
|
}
|
|
962
1067
|
};
|
|
@@ -971,7 +1076,7 @@ function getAllRefs(ast) {
|
|
|
971
1076
|
return getAllChildren(ast).filter((_child) => _child.flags & 4 /* Expression */).map((_child) => _child.refs).flat().filter(Boolean);
|
|
972
1077
|
}
|
|
973
1078
|
function checkRefCycle(curr, refNodes) {
|
|
974
|
-
if ((0, import_lodash2.intersection)(curr.scope.coverScopes, refNodes.map((_ref) => _ref
|
|
1079
|
+
if ((0, import_lodash2.intersection)(curr.scope.coverScopes, refNodes.map((_ref) => _ref == null ? void 0 : _ref.scope).filter(Boolean)).length === 0) {
|
|
975
1080
|
return false;
|
|
976
1081
|
}
|
|
977
1082
|
const visited = /* @__PURE__ */ new Set();
|
|
@@ -1004,9 +1109,10 @@ var KeyPathExpressionV2 = class extends BaseExpression {
|
|
|
1004
1109
|
}),
|
|
1005
1110
|
subsToDisposable(
|
|
1006
1111
|
this.refs$.subscribe((_type) => {
|
|
1112
|
+
var _a, _b;
|
|
1007
1113
|
const [ref] = this._refs;
|
|
1008
|
-
if (this.prevRefTypeHash !== ref
|
|
1009
|
-
this.prevRefTypeHash = ref
|
|
1114
|
+
if (this.prevRefTypeHash !== ((_a = ref == null ? void 0 : ref.type) == null ? void 0 : _a.hash)) {
|
|
1115
|
+
this.prevRefTypeHash = (_b = ref == null ? void 0 : ref.type) == null ? void 0 : _b.hash;
|
|
1010
1116
|
this.updateChildNodeByKey("_returnType", this.getReturnTypeJSONByRef(ref));
|
|
1011
1117
|
}
|
|
1012
1118
|
})
|
|
@@ -1047,7 +1153,8 @@ var KeyPathExpressionV2 = class extends BaseExpression {
|
|
|
1047
1153
|
}
|
|
1048
1154
|
}
|
|
1049
1155
|
getReturnTypeJSONByRef(_ref) {
|
|
1050
|
-
|
|
1156
|
+
var _a;
|
|
1157
|
+
return (_a = _ref == null ? void 0 : _ref.type) == null ? void 0 : _a.toJSON();
|
|
1051
1158
|
}
|
|
1052
1159
|
toJSON() {
|
|
1053
1160
|
return {
|
|
@@ -1058,8 +1165,50 @@ var KeyPathExpressionV2 = class extends BaseExpression {
|
|
|
1058
1165
|
};
|
|
1059
1166
|
KeyPathExpressionV2.kind = "KeyPathExpression" /* KeyPathExpression */;
|
|
1060
1167
|
|
|
1061
|
-
// src/ast/
|
|
1062
|
-
var
|
|
1168
|
+
// src/ast/expression/wrap-array-expression.ts
|
|
1169
|
+
var WrapArrayExpression = class extends BaseExpression {
|
|
1170
|
+
get wrapFor() {
|
|
1171
|
+
return this._wrapFor;
|
|
1172
|
+
}
|
|
1173
|
+
get returnType() {
|
|
1174
|
+
return this._returnType;
|
|
1175
|
+
}
|
|
1176
|
+
refreshReturnType() {
|
|
1177
|
+
var _a, _b;
|
|
1178
|
+
const childReturnTypeJSON = (_b = (_a = this.wrapFor) == null ? void 0 : _a.returnType) == null ? void 0 : _b.toJSON();
|
|
1179
|
+
this.updateChildNodeByKey("_returnType", {
|
|
1180
|
+
kind: "Array" /* Array */,
|
|
1181
|
+
items: childReturnTypeJSON
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
getRefFields() {
|
|
1185
|
+
return [];
|
|
1186
|
+
}
|
|
1187
|
+
fromJSON({ wrapFor: expression }) {
|
|
1188
|
+
this.updateChildNodeByKey("_wrapFor", expression);
|
|
1189
|
+
}
|
|
1190
|
+
toJSON() {
|
|
1191
|
+
var _a;
|
|
1192
|
+
return {
|
|
1193
|
+
kind: "WrapArrayExpression" /* WrapArrayExpression */,
|
|
1194
|
+
wrapFor: (_a = this.wrapFor) == null ? void 0 : _a.toJSON()
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1197
|
+
init() {
|
|
1198
|
+
this.toDispose.push(
|
|
1199
|
+
this.subscribe(this.refreshReturnType, {
|
|
1200
|
+
selector: (curr) => {
|
|
1201
|
+
var _a;
|
|
1202
|
+
return (_a = curr.wrapFor) == null ? void 0 : _a.returnType;
|
|
1203
|
+
}
|
|
1204
|
+
})
|
|
1205
|
+
);
|
|
1206
|
+
}
|
|
1207
|
+
};
|
|
1208
|
+
WrapArrayExpression.kind = "WrapArrayExpression" /* WrapArrayExpression */;
|
|
1209
|
+
__decorateClass([
|
|
1210
|
+
postConstructAST()
|
|
1211
|
+
], WrapArrayExpression.prototype, "init", 1);
|
|
1063
1212
|
|
|
1064
1213
|
// src/ast/declaration/base-variable-field.ts
|
|
1065
1214
|
var import_fast_equals5 = require("fast-equals");
|
|
@@ -1079,7 +1228,8 @@ var BaseVariableField = class extends ASTNode {
|
|
|
1079
1228
|
return this._meta;
|
|
1080
1229
|
}
|
|
1081
1230
|
get type() {
|
|
1082
|
-
|
|
1231
|
+
var _a;
|
|
1232
|
+
return ((_a = this._initializer) == null ? void 0 : _a.returnType) || this._type;
|
|
1083
1233
|
}
|
|
1084
1234
|
get initializer() {
|
|
1085
1235
|
return this._initializer;
|
|
@@ -1111,7 +1261,8 @@ var BaseVariableField = class extends ASTNode {
|
|
|
1111
1261
|
* @returns
|
|
1112
1262
|
*/
|
|
1113
1263
|
getByKeyPath(keyPath) {
|
|
1114
|
-
|
|
1264
|
+
var _a;
|
|
1265
|
+
if (((_a = this.type) == null ? void 0 : _a.flags) & 16 /* DrilldownType */) {
|
|
1115
1266
|
return this.type.getByKeyPath(keyPath);
|
|
1116
1267
|
}
|
|
1117
1268
|
return void 0;
|
|
@@ -1129,11 +1280,12 @@ var BaseVariableField = class extends ASTNode {
|
|
|
1129
1280
|
* @returns
|
|
1130
1281
|
*/
|
|
1131
1282
|
toJSON() {
|
|
1283
|
+
var _a, _b;
|
|
1132
1284
|
return {
|
|
1133
1285
|
kind: this.kind,
|
|
1134
1286
|
key: this.key,
|
|
1135
|
-
type: this.type
|
|
1136
|
-
initializer: this.initializer
|
|
1287
|
+
type: (_a = this.type) == null ? void 0 : _a.toJSON(),
|
|
1288
|
+
initializer: (_b = this.initializer) == null ? void 0 : _b.toJSON(),
|
|
1137
1289
|
meta: this._meta
|
|
1138
1290
|
};
|
|
1139
1291
|
}
|
|
@@ -1144,13 +1296,6 @@ var VariableDeclaration = class extends BaseVariableField {
|
|
|
1144
1296
|
constructor(params) {
|
|
1145
1297
|
super(params);
|
|
1146
1298
|
this._order = 0;
|
|
1147
|
-
this.scope.output.addVariableToTable(this);
|
|
1148
|
-
this.toDispose.push(
|
|
1149
|
-
import_utils4.Disposable.create(() => {
|
|
1150
|
-
this.scope.output.setHasChanges();
|
|
1151
|
-
this.scope.output.removeVariableFromTable(this.key);
|
|
1152
|
-
})
|
|
1153
|
-
);
|
|
1154
1299
|
}
|
|
1155
1300
|
get order() {
|
|
1156
1301
|
return this._order;
|
|
@@ -1165,7 +1310,9 @@ var VariableDeclaration = class extends BaseVariableField {
|
|
|
1165
1310
|
updateOrder(order = 0) {
|
|
1166
1311
|
if (order !== this._order) {
|
|
1167
1312
|
this._order = order;
|
|
1168
|
-
this.
|
|
1313
|
+
this.dispatchGlobalEvent({
|
|
1314
|
+
type: "ReSortVariableDeclarations"
|
|
1315
|
+
});
|
|
1169
1316
|
this.fireChange();
|
|
1170
1317
|
}
|
|
1171
1318
|
}
|
|
@@ -1187,8 +1334,9 @@ var VariableDeclarationList = class extends ASTNode {
|
|
|
1187
1334
|
const prev = [...this.declarations || []];
|
|
1188
1335
|
this.declarations = (declarations || []).map(
|
|
1189
1336
|
(declaration, idx) => {
|
|
1337
|
+
var _a, _b;
|
|
1190
1338
|
const order = (startOrder || 0) + idx;
|
|
1191
|
-
const declarationKey = declaration.key || this.declarations
|
|
1339
|
+
const declarationKey = declaration.key || ((_b = (_a = this.declarations) == null ? void 0 : _a[idx]) == null ? void 0 : _b.key);
|
|
1192
1340
|
const existDeclaration = this.declarationTable.get(declarationKey);
|
|
1193
1341
|
if (declarationKey) {
|
|
1194
1342
|
removedKeys.delete(declarationKey);
|
|
@@ -1210,7 +1358,7 @@ var VariableDeclarationList = class extends ASTNode {
|
|
|
1210
1358
|
);
|
|
1211
1359
|
removedKeys.forEach((key) => {
|
|
1212
1360
|
const declaration = this.declarationTable.get(key);
|
|
1213
|
-
declaration
|
|
1361
|
+
declaration == null ? void 0 : declaration.dispose();
|
|
1214
1362
|
this.declarationTable.delete(key);
|
|
1215
1363
|
});
|
|
1216
1364
|
this.dispatchGlobalEvent({
|
|
@@ -1336,7 +1484,8 @@ var MapNode = class extends ASTNode {
|
|
|
1336
1484
|
* @param key
|
|
1337
1485
|
*/
|
|
1338
1486
|
remove(key) {
|
|
1339
|
-
|
|
1487
|
+
var _a;
|
|
1488
|
+
(_a = this.get(key)) == null ? void 0 : _a.dispose();
|
|
1340
1489
|
this.map.delete(key);
|
|
1341
1490
|
this.fireChange();
|
|
1342
1491
|
}
|
|
@@ -1370,9 +1519,9 @@ var ASTRegisters = class {
|
|
|
1370
1519
|
this.registerAST(Property);
|
|
1371
1520
|
this.registerAST(VariableDeclaration);
|
|
1372
1521
|
this.registerAST(VariableDeclarationList);
|
|
1373
|
-
this.registerAST(
|
|
1522
|
+
this.registerAST(KeyPathExpressionV2);
|
|
1374
1523
|
this.registerAST(EnumerateExpression);
|
|
1375
|
-
this.registerAST(
|
|
1524
|
+
this.registerAST(WrapArrayExpression);
|
|
1376
1525
|
this.registerAST(MapNode);
|
|
1377
1526
|
this.registerAST(DataNode);
|
|
1378
1527
|
}
|
|
@@ -1382,6 +1531,7 @@ var ASTRegisters = class {
|
|
|
1382
1531
|
* @returns
|
|
1383
1532
|
*/
|
|
1384
1533
|
createAST(json, { parent, scope }) {
|
|
1534
|
+
var _a;
|
|
1385
1535
|
const Registry = this.astMap.get(json.kind);
|
|
1386
1536
|
if (!Registry) {
|
|
1387
1537
|
throw Error(`ASTKind: ${String(json.kind)} can not find its ASTNode Registry`);
|
|
@@ -1393,14 +1543,14 @@ var ASTRegisters = class {
|
|
|
1393
1543
|
scope,
|
|
1394
1544
|
parent
|
|
1395
1545
|
},
|
|
1396
|
-
injector
|
|
1546
|
+
(injector == null ? void 0 : injector()) || {}
|
|
1397
1547
|
);
|
|
1398
1548
|
node.changeLocked = true;
|
|
1399
1549
|
node.fromJSON((0, import_lodash3.omit)(json, ["key", "kind"]));
|
|
1400
1550
|
node.changeLocked = false;
|
|
1401
1551
|
if (Reflect.hasMetadata(POST_CONSTRUCT_AST_SYMBOL, node)) {
|
|
1402
1552
|
const postConstructKey = Reflect.getMetadata(POST_CONSTRUCT_AST_SYMBOL, node);
|
|
1403
|
-
node[postConstructKey]
|
|
1553
|
+
(_a = node[postConstructKey]) == null ? void 0 : _a.call(node);
|
|
1404
1554
|
}
|
|
1405
1555
|
return node;
|
|
1406
1556
|
}
|
|
@@ -1425,7 +1575,7 @@ var ASTRegisters = class {
|
|
|
1425
1575
|
}
|
|
1426
1576
|
};
|
|
1427
1577
|
ASTRegisters = __decorateClass([
|
|
1428
|
-
(0,
|
|
1578
|
+
(0, import_inversify3.injectable)()
|
|
1429
1579
|
], ASTRegisters);
|
|
1430
1580
|
|
|
1431
1581
|
// src/ast/factory.ts
|
|
@@ -1475,116 +1625,13 @@ var ASTFactory;
|
|
|
1475
1625
|
kind: "KeyPathExpression" /* KeyPathExpression */,
|
|
1476
1626
|
...json
|
|
1477
1627
|
});
|
|
1628
|
+
ASTFactory2.createWrapArrayExpression = (json) => ({
|
|
1629
|
+
kind: "WrapArrayExpression" /* WrapArrayExpression */,
|
|
1630
|
+
...json
|
|
1631
|
+
});
|
|
1478
1632
|
ASTFactory2.create = (targetType, json) => ({ kind: targetType.kind, ...json });
|
|
1479
1633
|
})(ASTFactory || (ASTFactory = {}));
|
|
1480
1634
|
|
|
1481
|
-
// src/scope/variable-table.ts
|
|
1482
|
-
var import_rxjs3 = require("rxjs");
|
|
1483
|
-
var import_utils5 = require("@flowgram.ai/utils");
|
|
1484
|
-
var import_utils6 = require("@flowgram.ai/utils");
|
|
1485
|
-
var VariableTable = class {
|
|
1486
|
-
constructor(parentTable) {
|
|
1487
|
-
this.parentTable = parentTable;
|
|
1488
|
-
this.table = /* @__PURE__ */ new Map();
|
|
1489
|
-
this.onDataChangeEmitter = new import_utils5.Emitter();
|
|
1490
|
-
this.variables$ = new import_rxjs3.Subject();
|
|
1491
|
-
// 监听变量列表中的单个变量变化
|
|
1492
|
-
this.anyVariableChange$ = this.variables$.pipe(
|
|
1493
|
-
(0, import_rxjs3.switchMap)(
|
|
1494
|
-
(_variables) => (0, import_rxjs3.merge)(
|
|
1495
|
-
..._variables.map(
|
|
1496
|
-
(_v) => _v.value$.pipe(
|
|
1497
|
-
// 跳过 BehaviorSubject 第一个
|
|
1498
|
-
(0, import_rxjs3.skip)(1)
|
|
1499
|
-
)
|
|
1500
|
-
)
|
|
1501
|
-
)
|
|
1502
|
-
),
|
|
1503
|
-
(0, import_rxjs3.share)()
|
|
1504
|
-
);
|
|
1505
|
-
this.onDataChange = this.onDataChangeEmitter.event;
|
|
1506
|
-
this._version = 0;
|
|
1507
|
-
}
|
|
1508
|
-
/**
|
|
1509
|
-
* 监听任意变量变化
|
|
1510
|
-
* @param observer 监听器,变量变化时会吐出值
|
|
1511
|
-
* @returns
|
|
1512
|
-
*/
|
|
1513
|
-
onAnyVariableChange(observer) {
|
|
1514
|
-
return subsToDisposable(this.anyVariableChange$.subscribe(observer));
|
|
1515
|
-
}
|
|
1516
|
-
/**
|
|
1517
|
-
* 列表或者任意变量变化
|
|
1518
|
-
* @param observer
|
|
1519
|
-
*/
|
|
1520
|
-
onAnyChange(observer) {
|
|
1521
|
-
const disposables = new import_utils6.DisposableCollection();
|
|
1522
|
-
disposables.pushAll([this.onDataChange(observer), this.onAnyVariableChange(observer)]);
|
|
1523
|
-
return disposables;
|
|
1524
|
-
}
|
|
1525
|
-
fireChange() {
|
|
1526
|
-
this._version++;
|
|
1527
|
-
this.onDataChangeEmitter.fire();
|
|
1528
|
-
this.parentTable?.fireChange();
|
|
1529
|
-
}
|
|
1530
|
-
get version() {
|
|
1531
|
-
return this._version;
|
|
1532
|
-
}
|
|
1533
|
-
get variables() {
|
|
1534
|
-
return Array.from(this.table.values());
|
|
1535
|
-
}
|
|
1536
|
-
get variableKeys() {
|
|
1537
|
-
return Array.from(this.table.keys());
|
|
1538
|
-
}
|
|
1539
|
-
/**
|
|
1540
|
-
* 根据 keyPath 找到对应的变量,或 Property 节点
|
|
1541
|
-
* @param keyPath
|
|
1542
|
-
* @returns
|
|
1543
|
-
*/
|
|
1544
|
-
getByKeyPath(keyPath) {
|
|
1545
|
-
const [variableKey, ...propertyKeys] = keyPath || [];
|
|
1546
|
-
if (!variableKey) {
|
|
1547
|
-
return;
|
|
1548
|
-
}
|
|
1549
|
-
const variable = this.getVariableByKey(variableKey);
|
|
1550
|
-
return propertyKeys.length ? variable?.getByKeyPath(propertyKeys) : variable;
|
|
1551
|
-
}
|
|
1552
|
-
/**
|
|
1553
|
-
* 根据 key 值找到相应的变量
|
|
1554
|
-
* @param key
|
|
1555
|
-
* @returns
|
|
1556
|
-
*/
|
|
1557
|
-
getVariableByKey(key) {
|
|
1558
|
-
return this.table.get(key);
|
|
1559
|
-
}
|
|
1560
|
-
/**
|
|
1561
|
-
* 往 variableTable 添加输出变量
|
|
1562
|
-
* @param variable
|
|
1563
|
-
*/
|
|
1564
|
-
addVariableToTable(variable) {
|
|
1565
|
-
this.table.set(variable.key, variable);
|
|
1566
|
-
if (this.parentTable) {
|
|
1567
|
-
this.parentTable.addVariableToTable(variable);
|
|
1568
|
-
}
|
|
1569
|
-
this.variables$.next(this.variables);
|
|
1570
|
-
}
|
|
1571
|
-
/**
|
|
1572
|
-
* 从 variableTable 中移除变量
|
|
1573
|
-
* @param key
|
|
1574
|
-
*/
|
|
1575
|
-
removeVariableFromTable(key) {
|
|
1576
|
-
this.table.delete(key);
|
|
1577
|
-
if (this.parentTable) {
|
|
1578
|
-
this.parentTable.removeVariableFromTable(key);
|
|
1579
|
-
}
|
|
1580
|
-
this.variables$.next(this.variables);
|
|
1581
|
-
}
|
|
1582
|
-
dispose() {
|
|
1583
|
-
this.variableKeys.forEach((_key) => this.parentTable?.removeVariableFromTable(_key));
|
|
1584
|
-
this.onDataChangeEmitter.dispose();
|
|
1585
|
-
}
|
|
1586
|
-
};
|
|
1587
|
-
|
|
1588
1635
|
// src/scope/datas/scope-output-data.ts
|
|
1589
1636
|
var ScopeOutputData = class {
|
|
1590
1637
|
constructor(scope) {
|
|
@@ -1593,7 +1640,7 @@ var ScopeOutputData = class {
|
|
|
1593
1640
|
this._hasChanges = false;
|
|
1594
1641
|
this.variableTable = new VariableTable(scope.variableEngine.globalVariableTable);
|
|
1595
1642
|
this.scope.toDispose.pushAll([
|
|
1596
|
-
// AST
|
|
1643
|
+
// When root AST node is updated, check if there are any changes during this AST change
|
|
1597
1644
|
this.scope.ast.subscribe(() => {
|
|
1598
1645
|
if (this._hasChanges) {
|
|
1599
1646
|
this.memo.clear();
|
|
@@ -1602,6 +1649,21 @@ var ScopeOutputData = class {
|
|
|
1602
1649
|
this._hasChanges = false;
|
|
1603
1650
|
}
|
|
1604
1651
|
}),
|
|
1652
|
+
this.scope.event.on("DisposeAST", (_action) => {
|
|
1653
|
+
var _a;
|
|
1654
|
+
if (((_a = _action.ast) == null ? void 0 : _a.kind) === "VariableDeclaration" /* VariableDeclaration */) {
|
|
1655
|
+
this.removeVariableFromTable(_action.ast.key);
|
|
1656
|
+
}
|
|
1657
|
+
}),
|
|
1658
|
+
this.scope.event.on("NewAST", (_action) => {
|
|
1659
|
+
var _a;
|
|
1660
|
+
if (((_a = _action.ast) == null ? void 0 : _a.kind) === "VariableDeclaration" /* VariableDeclaration */) {
|
|
1661
|
+
this.addVariableToTable(_action.ast);
|
|
1662
|
+
}
|
|
1663
|
+
}),
|
|
1664
|
+
this.scope.event.on("ReSortVariableDeclarations", () => {
|
|
1665
|
+
this._hasChanges = true;
|
|
1666
|
+
}),
|
|
1605
1667
|
this.variableTable
|
|
1606
1668
|
]);
|
|
1607
1669
|
}
|
|
@@ -1618,7 +1680,7 @@ var ScopeOutputData = class {
|
|
|
1618
1680
|
return this.variableTable.onAnyVariableChange.bind(this.variableTable);
|
|
1619
1681
|
}
|
|
1620
1682
|
/**
|
|
1621
|
-
*
|
|
1683
|
+
* Scope Output Variable Declarations
|
|
1622
1684
|
*/
|
|
1623
1685
|
get variables() {
|
|
1624
1686
|
return this.memo(
|
|
@@ -1627,7 +1689,7 @@ var ScopeOutputData = class {
|
|
|
1627
1689
|
);
|
|
1628
1690
|
}
|
|
1629
1691
|
/**
|
|
1630
|
-
*
|
|
1692
|
+
* Output Variable Keys
|
|
1631
1693
|
*/
|
|
1632
1694
|
get variableKeys() {
|
|
1633
1695
|
return this.memo("variableKeys", () => this.variableTable.variableKeys);
|
|
@@ -1639,10 +1701,6 @@ var ScopeOutputData = class {
|
|
|
1639
1701
|
this.variableTable.addVariableToTable(variable);
|
|
1640
1702
|
this._hasChanges = true;
|
|
1641
1703
|
}
|
|
1642
|
-
// 标记为发生了变化,用于变量排序变化的场景
|
|
1643
|
-
setHasChanges() {
|
|
1644
|
-
this._hasChanges = true;
|
|
1645
|
-
}
|
|
1646
1704
|
removeVariableFromTable(key) {
|
|
1647
1705
|
this.variableTable.removeVariableFromTable(key);
|
|
1648
1706
|
this._hasChanges = true;
|
|
@@ -1650,7 +1708,9 @@ var ScopeOutputData = class {
|
|
|
1650
1708
|
getVariableByKey(key) {
|
|
1651
1709
|
return this.variableTable.getVariableByKey(key);
|
|
1652
1710
|
}
|
|
1653
|
-
|
|
1711
|
+
/**
|
|
1712
|
+
*
|
|
1713
|
+
*/
|
|
1654
1714
|
notifyCoversChange() {
|
|
1655
1715
|
this.scope.coverScopes.forEach((scope) => scope.available.refresh());
|
|
1656
1716
|
}
|
|
@@ -1660,8 +1720,8 @@ var ScopeOutputData = class {
|
|
|
1660
1720
|
var import_rxjs4 = require("rxjs");
|
|
1661
1721
|
var import_lodash4 = require("lodash");
|
|
1662
1722
|
var import_fast_equals7 = require("fast-equals");
|
|
1663
|
-
var
|
|
1664
|
-
var
|
|
1723
|
+
var import_utils5 = require("@flowgram.ai/utils");
|
|
1724
|
+
var import_utils6 = require("@flowgram.ai/utils");
|
|
1665
1725
|
var ScopeAvailableData = class {
|
|
1666
1726
|
constructor(scope) {
|
|
1667
1727
|
this.scope = scope;
|
|
@@ -1692,7 +1752,7 @@ var ScopeAvailableData = class {
|
|
|
1692
1752
|
),
|
|
1693
1753
|
(0, import_rxjs4.share)()
|
|
1694
1754
|
);
|
|
1695
|
-
this.onDataChangeEmitter = new
|
|
1755
|
+
this.onDataChangeEmitter = new import_utils6.Emitter();
|
|
1696
1756
|
/**
|
|
1697
1757
|
* 监听变量列表变化 + 任意子变量变化
|
|
1698
1758
|
*/
|
|
@@ -1706,7 +1766,7 @@ var ScopeAvailableData = class {
|
|
|
1706
1766
|
this.onAnyVariableChange(() => {
|
|
1707
1767
|
this.onDataChangeEmitter.fire(this._variables);
|
|
1708
1768
|
}),
|
|
1709
|
-
|
|
1769
|
+
import_utils5.Disposable.create(() => {
|
|
1710
1770
|
this.refresh$.complete();
|
|
1711
1771
|
this.refresh$.unsubscribe();
|
|
1712
1772
|
})
|
|
@@ -1804,7 +1864,7 @@ var Scope = class {
|
|
|
1804
1864
|
* 数据缓存
|
|
1805
1865
|
*/
|
|
1806
1866
|
this.memo = createMemo();
|
|
1807
|
-
this.toDispose = new
|
|
1867
|
+
this.toDispose = new import_utils7.DisposableCollection();
|
|
1808
1868
|
this.onDispose = this.toDispose.onDispose;
|
|
1809
1869
|
this.id = options.id;
|
|
1810
1870
|
this.meta = options.meta || {};
|
|
@@ -1813,7 +1873,7 @@ var Scope = class {
|
|
|
1813
1873
|
this.ast = this.variableEngine.astRegisters.createAST(
|
|
1814
1874
|
{
|
|
1815
1875
|
kind: "MapNode" /* MapNode */,
|
|
1816
|
-
key: this.id
|
|
1876
|
+
key: String(this.id)
|
|
1817
1877
|
},
|
|
1818
1878
|
{
|
|
1819
1879
|
scope: this
|
|
@@ -1832,13 +1892,13 @@ var Scope = class {
|
|
|
1832
1892
|
get depScopes() {
|
|
1833
1893
|
return this.memo(
|
|
1834
1894
|
"deps",
|
|
1835
|
-
() => this.variableEngine.chain.getDeps(this).filter((_scope) => Boolean(_scope) && !_scope
|
|
1895
|
+
() => this.variableEngine.chain.getDeps(this).filter((_scope) => Boolean(_scope) && !(_scope == null ? void 0 : _scope.disposed))
|
|
1836
1896
|
);
|
|
1837
1897
|
}
|
|
1838
1898
|
get coverScopes() {
|
|
1839
1899
|
return this.memo(
|
|
1840
1900
|
"covers",
|
|
1841
|
-
() => this.variableEngine.chain.getCovers(this).filter((_scope) => Boolean(_scope) && !_scope
|
|
1901
|
+
() => this.variableEngine.chain.getCovers(this).filter((_scope) => Boolean(_scope) && !(_scope == null ? void 0 : _scope.disposed))
|
|
1842
1902
|
);
|
|
1843
1903
|
}
|
|
1844
1904
|
dispose() {
|
|
@@ -1857,16 +1917,16 @@ var VariableEngine = class {
|
|
|
1857
1917
|
constructor(chain, astRegisters) {
|
|
1858
1918
|
this.chain = chain;
|
|
1859
1919
|
this.astRegisters = astRegisters;
|
|
1860
|
-
this.toDispose = new
|
|
1920
|
+
this.toDispose = new import_utils8.DisposableCollection();
|
|
1861
1921
|
this.memo = createMemo();
|
|
1862
1922
|
this.scopeMap = /* @__PURE__ */ new Map();
|
|
1863
1923
|
this.globalEvent$ = new import_rxjs6.Subject();
|
|
1864
|
-
this.onScopeChangeEmitter = new
|
|
1924
|
+
this.onScopeChangeEmitter = new import_utils9.Emitter();
|
|
1865
1925
|
this.globalVariableTable = new VariableTable();
|
|
1866
1926
|
this.onScopeChange = this.onScopeChangeEmitter.event;
|
|
1867
1927
|
this.toDispose.pushAll([
|
|
1868
1928
|
chain,
|
|
1869
|
-
|
|
1929
|
+
import_utils8.Disposable.create(() => {
|
|
1870
1930
|
this.getAllScopes().forEach((scope) => scope.dispose());
|
|
1871
1931
|
this.globalVariableTable.dispose();
|
|
1872
1932
|
})
|
|
@@ -1884,13 +1944,21 @@ var VariableEngine = class {
|
|
|
1884
1944
|
}
|
|
1885
1945
|
// 移除作用域
|
|
1886
1946
|
removeScopeById(scopeId) {
|
|
1887
|
-
|
|
1947
|
+
var _a;
|
|
1948
|
+
(_a = this.getScopeById(scopeId)) == null ? void 0 : _a.dispose();
|
|
1888
1949
|
}
|
|
1889
|
-
|
|
1890
|
-
|
|
1950
|
+
/**
|
|
1951
|
+
* Get Scope, if Scope exists and type is same, will use it directly
|
|
1952
|
+
* @param id scope id
|
|
1953
|
+
* @param meta scope meta, defined by user
|
|
1954
|
+
* @param ScopeConstructor scope constructor, default is Scope. you can extends Scope to create your own scope
|
|
1955
|
+
* @returns
|
|
1956
|
+
*/
|
|
1957
|
+
createScope(id, meta, options = {}) {
|
|
1958
|
+
const { ScopeConstructor = Scope } = options;
|
|
1891
1959
|
let scope = this.getScopeById(id);
|
|
1892
1960
|
if (!scope) {
|
|
1893
|
-
scope = new
|
|
1961
|
+
scope = new ScopeConstructor({ variableEngine: this, meta, id });
|
|
1894
1962
|
this.scopeMap.set(id, scope);
|
|
1895
1963
|
this.onScopeChangeEmitter.fire({ type: "add", scope });
|
|
1896
1964
|
scope.toDispose.pushAll([
|
|
@@ -1936,32 +2004,33 @@ var VariableEngine = class {
|
|
|
1936
2004
|
}
|
|
1937
2005
|
};
|
|
1938
2006
|
__decorateClass([
|
|
1939
|
-
(0,
|
|
2007
|
+
(0, import_inversify6.inject)(ContainerProvider)
|
|
1940
2008
|
], VariableEngine.prototype, "containerProvider", 2);
|
|
1941
2009
|
__decorateClass([
|
|
1942
|
-
(0,
|
|
2010
|
+
(0, import_inversify6.preDestroy)()
|
|
1943
2011
|
], VariableEngine.prototype, "dispose", 1);
|
|
1944
2012
|
VariableEngine = __decorateClass([
|
|
1945
|
-
(0,
|
|
1946
|
-
__decorateParam(0, (0,
|
|
1947
|
-
__decorateParam(1, (0,
|
|
2013
|
+
(0, import_inversify6.injectable)(),
|
|
2014
|
+
__decorateParam(0, (0, import_inversify6.inject)(ScopeChain)),
|
|
2015
|
+
__decorateParam(1, (0, import_inversify6.inject)(ASTRegisters))
|
|
1948
2016
|
], VariableEngine);
|
|
1949
2017
|
|
|
1950
2018
|
// src/services/variable-field-key-rename-service.ts
|
|
1951
2019
|
var import_lodash5 = require("lodash");
|
|
1952
|
-
var
|
|
1953
|
-
var
|
|
2020
|
+
var import_inversify7 = require("inversify");
|
|
2021
|
+
var import_utils10 = require("@flowgram.ai/utils");
|
|
1954
2022
|
var VariableFieldKeyRenameService = class {
|
|
1955
2023
|
constructor() {
|
|
1956
|
-
this.toDispose = new
|
|
1957
|
-
this.renameEmitter = new
|
|
2024
|
+
this.toDispose = new import_utils10.DisposableCollection();
|
|
2025
|
+
this.renameEmitter = new import_utils10.Emitter();
|
|
1958
2026
|
// 没有被 rename 的字段通过 disposeInList 透出,让业务区分变量是 rename 删除的,还是真正从列表中删除的
|
|
1959
|
-
this.disposeInListEmitter = new
|
|
2027
|
+
this.disposeInListEmitter = new import_utils10.Emitter();
|
|
1960
2028
|
this.onRename = this.renameEmitter.event;
|
|
1961
2029
|
this.onDisposeInList = this.disposeInListEmitter.event;
|
|
1962
2030
|
}
|
|
1963
2031
|
handleFieldListChange(ast, prev, next) {
|
|
1964
|
-
|
|
2032
|
+
var _a, _b;
|
|
2033
|
+
if (!ast || !(prev == null ? void 0 : prev.length) || !(next == null ? void 0 : next.length)) {
|
|
1965
2034
|
this.notifyFieldsDispose(prev, next);
|
|
1966
2035
|
return;
|
|
1967
2036
|
}
|
|
@@ -1979,7 +2048,7 @@ var VariableFieldKeyRenameService = class {
|
|
|
1979
2048
|
return;
|
|
1980
2049
|
}
|
|
1981
2050
|
existFieldChanged = true;
|
|
1982
|
-
if (prevField.type
|
|
2051
|
+
if (((_a = prevField.type) == null ? void 0 : _a.kind) === ((_b = nextField.type) == null ? void 0 : _b.kind)) {
|
|
1983
2052
|
renameNodeInfo = { before: prevField, after: nextField };
|
|
1984
2053
|
}
|
|
1985
2054
|
}
|
|
@@ -1999,13 +2068,15 @@ var VariableFieldKeyRenameService = class {
|
|
|
1999
2068
|
this.variableEngine.onGlobalEvent(
|
|
2000
2069
|
"VariableListChange",
|
|
2001
2070
|
(_action) => {
|
|
2002
|
-
|
|
2071
|
+
var _a, _b;
|
|
2072
|
+
this.handleFieldListChange(_action.ast, (_a = _action.payload) == null ? void 0 : _a.prev, (_b = _action.payload) == null ? void 0 : _b.next);
|
|
2003
2073
|
}
|
|
2004
2074
|
),
|
|
2005
2075
|
this.variableEngine.onGlobalEvent(
|
|
2006
2076
|
"ObjectPropertiesChange",
|
|
2007
2077
|
(_action) => {
|
|
2008
|
-
|
|
2078
|
+
var _a, _b;
|
|
2079
|
+
this.handleFieldListChange(_action.ast, (_a = _action.payload) == null ? void 0 : _a.prev, (_b = _action.payload) == null ? void 0 : _b.next);
|
|
2009
2080
|
}
|
|
2010
2081
|
)
|
|
2011
2082
|
]);
|
|
@@ -2015,20 +2086,20 @@ var VariableFieldKeyRenameService = class {
|
|
|
2015
2086
|
}
|
|
2016
2087
|
};
|
|
2017
2088
|
__decorateClass([
|
|
2018
|
-
(0,
|
|
2089
|
+
(0, import_inversify7.inject)(VariableEngine)
|
|
2019
2090
|
], VariableFieldKeyRenameService.prototype, "variableEngine", 2);
|
|
2020
2091
|
__decorateClass([
|
|
2021
|
-
(0,
|
|
2092
|
+
(0, import_inversify7.postConstruct)()
|
|
2022
2093
|
], VariableFieldKeyRenameService.prototype, "init", 1);
|
|
2023
2094
|
__decorateClass([
|
|
2024
|
-
(0,
|
|
2095
|
+
(0, import_inversify7.preDestroy)()
|
|
2025
2096
|
], VariableFieldKeyRenameService.prototype, "dispose", 1);
|
|
2026
2097
|
VariableFieldKeyRenameService = __decorateClass([
|
|
2027
|
-
(0,
|
|
2098
|
+
(0, import_inversify7.injectable)()
|
|
2028
2099
|
], VariableFieldKeyRenameService);
|
|
2029
2100
|
|
|
2030
2101
|
// src/variable-container-module.ts
|
|
2031
|
-
var VariableContainerModule = new
|
|
2102
|
+
var VariableContainerModule = new import_inversify8.ContainerModule((bind) => {
|
|
2032
2103
|
bind(VariableEngine).toSelf().inSingletonScope();
|
|
2033
2104
|
bind(ASTRegisters).toSelf().inSingletonScope();
|
|
2034
2105
|
bind(VariableFieldKeyRenameService).toSelf().inSingletonScope();
|
|
@@ -2041,7 +2112,10 @@ var import_react = require("react");
|
|
|
2041
2112
|
var ScopeContext = (0, import_react.createContext)(null);
|
|
2042
2113
|
var ScopeProvider = ScopeContext.Provider;
|
|
2043
2114
|
var useScopeContext = () => (0, import_react.useContext)(ScopeContext);
|
|
2044
|
-
var useCurrentScope = () =>
|
|
2115
|
+
var useCurrentScope = () => {
|
|
2116
|
+
var _a;
|
|
2117
|
+
return (_a = (0, import_react.useContext)(ScopeContext)) == null ? void 0 : _a.scope;
|
|
2118
|
+
};
|
|
2045
2119
|
|
|
2046
2120
|
// src/react/hooks/useScopeAvailable.ts
|
|
2047
2121
|
var import_react2 = require("react");
|
|
@@ -2095,7 +2169,6 @@ function useAvailableVariables() {
|
|
|
2095
2169
|
CustomType,
|
|
2096
2170
|
DataNode,
|
|
2097
2171
|
EnumerateExpression,
|
|
2098
|
-
ExpressionList,
|
|
2099
2172
|
IntegerType,
|
|
2100
2173
|
KeyPathExpression,
|
|
2101
2174
|
KeyPathExpressionV2,
|
|
@@ -2116,7 +2189,7 @@ function useAvailableVariables() {
|
|
|
2116
2189
|
VariableEngine,
|
|
2117
2190
|
VariableEngineProvider,
|
|
2118
2191
|
VariableFieldKeyRenameService,
|
|
2119
|
-
|
|
2192
|
+
WrapArrayExpression,
|
|
2120
2193
|
injectToAST,
|
|
2121
2194
|
isMatchAST,
|
|
2122
2195
|
postConstructAST,
|