@flowgram.ai/variable-core 0.1.0-alpha.7 → 0.1.0-alpha.9

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 CHANGED
@@ -16,7 +16,7 @@ import { ContainerModule } from "inversify";
16
16
  // src/variable-engine.ts
17
17
  import { Subject as Subject5 } from "rxjs";
18
18
  import { inject as inject2, injectable as injectable3, preDestroy } from "inversify";
19
- import { Disposable as Disposable6, DisposableCollection as DisposableCollection5 } from "@flowgram.ai/utils";
19
+ import { Disposable as Disposable4, DisposableCollection as DisposableCollection5 } from "@flowgram.ai/utils";
20
20
  import { Emitter as Emitter3 } from "@flowgram.ai/utils";
21
21
 
22
22
  // src/utils/toDisposable.tsx
@@ -47,9 +47,117 @@ var createMemo = () => {
47
47
  return memo;
48
48
  };
49
49
 
50
+ // src/scope/variable-table.ts
51
+ import { Subject, merge, share, skip, switchMap } from "rxjs";
52
+ import { DisposableCollection, Emitter } from "@flowgram.ai/utils";
53
+ var VariableTable = class {
54
+ constructor(parentTable) {
55
+ this.parentTable = parentTable;
56
+ this.table = /* @__PURE__ */ new Map();
57
+ this.onDataChangeEmitter = new Emitter();
58
+ this.variables$ = new Subject();
59
+ // 监听变量列表中的单个变量变化
60
+ this.anyVariableChange$ = this.variables$.pipe(
61
+ switchMap(
62
+ (_variables) => merge(
63
+ ..._variables.map(
64
+ (_v) => _v.value$.pipe(
65
+ // 跳过 BehaviorSubject 第一个
66
+ skip(1)
67
+ )
68
+ )
69
+ )
70
+ ),
71
+ share()
72
+ );
73
+ this.onDataChange = this.onDataChangeEmitter.event;
74
+ this._version = 0;
75
+ }
76
+ /**
77
+ * 监听任意变量变化
78
+ * @param observer 监听器,变量变化时会吐出值
79
+ * @returns
80
+ */
81
+ onAnyVariableChange(observer) {
82
+ return subsToDisposable(this.anyVariableChange$.subscribe(observer));
83
+ }
84
+ /**
85
+ * 列表或者任意变量变化
86
+ * @param observer
87
+ */
88
+ onAnyChange(observer) {
89
+ const disposables = new DisposableCollection();
90
+ disposables.pushAll([this.onDataChange(observer), this.onAnyVariableChange(observer)]);
91
+ return disposables;
92
+ }
93
+ fireChange() {
94
+ this._version++;
95
+ this.onDataChangeEmitter.fire();
96
+ this.parentTable?.fireChange();
97
+ }
98
+ get version() {
99
+ return this._version;
100
+ }
101
+ get variables() {
102
+ return Array.from(this.table.values());
103
+ }
104
+ get variableKeys() {
105
+ return Array.from(this.table.keys());
106
+ }
107
+ /**
108
+ * 根据 keyPath 找到对应的变量,或 Property 节点
109
+ * @param keyPath
110
+ * @returns
111
+ */
112
+ getByKeyPath(keyPath) {
113
+ const [variableKey, ...propertyKeys] = keyPath || [];
114
+ if (!variableKey) {
115
+ return;
116
+ }
117
+ const variable = this.getVariableByKey(variableKey);
118
+ return propertyKeys.length ? variable?.getByKeyPath(propertyKeys) : variable;
119
+ }
120
+ /**
121
+ * 根据 key 值找到相应的变量
122
+ * @param key
123
+ * @returns
124
+ */
125
+ getVariableByKey(key) {
126
+ return this.table.get(key);
127
+ }
128
+ /**
129
+ * 往 variableTable 添加输出变量
130
+ * @param variable
131
+ */
132
+ addVariableToTable(variable) {
133
+ this.table.set(variable.key, variable);
134
+ if (this.parentTable) {
135
+ this.parentTable.addVariableToTable(variable);
136
+ }
137
+ this.variables$.next(this.variables);
138
+ }
139
+ /**
140
+ * 从 variableTable 中移除变量
141
+ * @param key
142
+ */
143
+ removeVariableFromTable(key) {
144
+ this.table.delete(key);
145
+ if (this.parentTable) {
146
+ this.parentTable.removeVariableFromTable(key);
147
+ }
148
+ this.variables$.next(this.variables);
149
+ }
150
+ dispose() {
151
+ this.variableKeys.forEach(
152
+ (_key) => this.parentTable?.removeVariableFromTable(_key)
153
+ );
154
+ this.onDataChangeEmitter.dispose();
155
+ }
156
+ };
157
+
50
158
  // src/scope/scope-chain.ts
51
159
  import { inject, injectable } from "inversify";
52
- import { DisposableCollection } from "@flowgram.ai/utils";
160
+ import { DisposableCollection as DisposableCollection2 } from "@flowgram.ai/utils";
53
161
 
54
162
  // src/providers.ts
55
163
  var VariableEngineProvider = Symbol("DynamicVariableEngine");
@@ -58,7 +166,7 @@ var ContainerProvider = Symbol("ContainerProvider");
58
166
  // src/scope/scope-chain.ts
59
167
  var ScopeChain = class {
60
168
  constructor() {
61
- this.toDispose = new DisposableCollection();
169
+ this.toDispose = new DisposableCollection2();
62
170
  }
63
171
  get variableEngine() {
64
172
  return this.variableEngineProvider();
@@ -109,7 +217,7 @@ var ASTKind = /* @__PURE__ */ ((ASTKind2) => {
109
217
  ASTKind2["VariableDeclarationList"] = "VariableDeclarationList";
110
218
  ASTKind2["KeyPathExpression"] = "KeyPathExpression";
111
219
  ASTKind2["EnumerateExpression"] = "EnumerateExpression";
112
- ASTKind2["ExpressionList"] = "ExpressionList";
220
+ ASTKind2["WrapArrayExpression"] = "WrapArrayExpression";
113
221
  ASTKind2["ListNode"] = "ListNode";
114
222
  ASTKind2["DataNode"] = "DataNode";
115
223
  ASTKind2["MapNode"] = "MapNode";
@@ -228,12 +336,12 @@ import {
228
336
  debounceTime,
229
337
  distinctUntilChanged,
230
338
  map,
231
- skip,
339
+ skip as skip2,
232
340
  tap
233
341
  } from "rxjs";
234
342
  import { nanoid } from "nanoid";
235
343
  import { shallowEqual } from "fast-equals";
236
- import { Disposable as Disposable2, DisposableCollection as DisposableCollection2 } from "@flowgram.ai/utils";
344
+ import { Disposable as Disposable2, DisposableCollection as DisposableCollection3 } from "@flowgram.ai/utils";
237
345
  var ASTNode = class _ASTNode {
238
346
  /**
239
347
  * 构造函数
@@ -272,7 +380,7 @@ var ASTNode = class _ASTNode {
272
380
  /**
273
381
  * 删除节点处理事件列表
274
382
  */
275
- this.toDispose = new DisposableCollection2(
383
+ this.toDispose = new DisposableCollection3(
276
384
  Disposable2.create(() => {
277
385
  this.parent?.fireChange();
278
386
  this.children.forEach((child) => child.dispose());
@@ -415,7 +523,7 @@ var ASTNode = class _ASTNode {
415
523
  }
416
524
  ),
417
525
  // 默认跳过 BehaviorSubject 第一次触发
418
- triggerOnInit ? tap(() => null) : skip(1),
526
+ triggerOnInit ? tap(() => null) : skip2(1),
419
527
  // 每个 animationFrame 内所有更新合并成一个
420
528
  debounceAnimation ? debounceTime(0, animationFrameScheduler) : tap(() => null)
421
529
  ).subscribe(observer)
@@ -451,7 +559,7 @@ var BaseType = class extends ASTNode {
451
559
  this.flags = 8 /* BasicType */;
452
560
  }
453
561
  /**
454
- * 类型是否一致,节点有额外信息判断,请参考 extraTypeInfoEqual
562
+ * 类型是否一致
455
563
  * @param targetTypeJSON
456
564
  */
457
565
  isTypeEqual(targetTypeJSONOrKind) {
@@ -470,6 +578,10 @@ var BaseType = class extends ASTNode {
470
578
  getByKeyPath(keyPath = []) {
471
579
  throw new Error(`Get By Key Path is not implemented for Type: ${this.kind}`);
472
580
  }
581
+ /**
582
+ * Get AST JSON for current base type
583
+ * @returns
584
+ */
473
585
  toJSON() {
474
586
  return {
475
587
  kind: this.kind
@@ -726,11 +838,11 @@ CustomType.kind = "CustomType" /* CustomType */;
726
838
  import {
727
839
  distinctUntilChanged as distinctUntilChanged2,
728
840
  map as map2,
729
- switchMap,
841
+ switchMap as switchMap2,
730
842
  combineLatest,
731
843
  of,
732
- Subject,
733
- share
844
+ Subject as Subject2,
845
+ share as share2
734
846
  } from "rxjs";
735
847
  import { shallowEqual as shallowEqual2 } from "fast-equals";
736
848
 
@@ -756,7 +868,7 @@ var BaseExpression = class extends ASTNode {
756
868
  * 引用变量
757
869
  */
758
870
  this._refs = [];
759
- this.refreshRefs$ = new Subject();
871
+ this.refreshRefs$ = new Subject2();
760
872
  /**
761
873
  * 监听引用变量变化
762
874
  * 监听 [a.b.c] -> [a.b]
@@ -764,14 +876,14 @@ var BaseExpression = class extends ASTNode {
764
876
  this.refs$ = this.refreshRefs$.pipe(
765
877
  map2(() => this.getRefFields()),
766
878
  distinctUntilChanged2(shallowEqual2),
767
- switchMap(
879
+ switchMap2(
768
880
  (refs) => !refs?.length ? of([]) : combineLatest(
769
881
  refs.map(
770
882
  (ref) => ref ? ref.value$ : of(void 0)
771
883
  )
772
884
  )
773
885
  ),
774
- share()
886
+ share2()
775
887
  );
776
888
  this.toDispose.push(
777
889
  subsToDisposable(
@@ -805,29 +917,6 @@ var BaseExpression = class extends ASTNode {
805
917
  }
806
918
  };
807
919
 
808
- // src/ast/expression/expression-list.ts
809
- var ExpressionList = class extends ASTNode {
810
- fromJSON({ expressions }) {
811
- this.expressions = expressions.map((_expression, idx) => {
812
- const prevExpression = this.expressions[idx];
813
- if (prevExpression.kind !== _expression.kind) {
814
- prevExpression.dispose();
815
- this.fireChange();
816
- return this.createChildNode(_expression);
817
- }
818
- prevExpression.fromJSON(_expression);
819
- return prevExpression;
820
- });
821
- }
822
- toJSON() {
823
- return {
824
- kind: "ExpressionList" /* ExpressionList */,
825
- properties: this.expressions.map((_expression) => _expression.toJSON())
826
- };
827
- }
828
- };
829
- ExpressionList.kind = "ExpressionList" /* ExpressionList */;
830
-
831
920
  // src/ast/expression/keypath-expression.ts
832
921
  import { shallowEqual as shallowEqual3 } from "fast-equals";
833
922
  var KeyPathExpression = class extends BaseExpression {
@@ -1009,8 +1098,45 @@ var KeyPathExpressionV2 = class extends BaseExpression {
1009
1098
  };
1010
1099
  KeyPathExpressionV2.kind = "KeyPathExpression" /* KeyPathExpression */;
1011
1100
 
1012
- // src/ast/declaration/variable-declaration.ts
1013
- import { Disposable as Disposable3 } from "@flowgram.ai/utils";
1101
+ // src/ast/expression/wrap-array-expression.ts
1102
+ var WrapArrayExpression = class extends BaseExpression {
1103
+ get wrapFor() {
1104
+ return this._wrapFor;
1105
+ }
1106
+ get returnType() {
1107
+ return this._returnType;
1108
+ }
1109
+ refreshReturnType() {
1110
+ const childReturnTypeJSON = this.wrapFor?.returnType?.toJSON();
1111
+ this.updateChildNodeByKey("_returnType", {
1112
+ kind: "Array" /* Array */,
1113
+ items: childReturnTypeJSON
1114
+ });
1115
+ }
1116
+ getRefFields() {
1117
+ return [];
1118
+ }
1119
+ fromJSON({ wrapFor: expression }) {
1120
+ this.updateChildNodeByKey("_wrapFor", expression);
1121
+ }
1122
+ toJSON() {
1123
+ return {
1124
+ kind: "WrapArrayExpression" /* WrapArrayExpression */,
1125
+ wrapFor: this.wrapFor?.toJSON()
1126
+ };
1127
+ }
1128
+ init() {
1129
+ this.toDispose.push(
1130
+ this.subscribe(this.refreshReturnType, {
1131
+ selector: (curr) => curr.wrapFor?.returnType
1132
+ })
1133
+ );
1134
+ }
1135
+ };
1136
+ WrapArrayExpression.kind = "WrapArrayExpression" /* WrapArrayExpression */;
1137
+ __decorateClass([
1138
+ postConstructAST()
1139
+ ], WrapArrayExpression.prototype, "init", 1);
1014
1140
 
1015
1141
  // src/ast/declaration/base-variable-field.ts
1016
1142
  import { shallowEqual as shallowEqual5 } from "fast-equals";
@@ -1095,13 +1221,6 @@ var VariableDeclaration = class extends BaseVariableField {
1095
1221
  constructor(params) {
1096
1222
  super(params);
1097
1223
  this._order = 0;
1098
- this.scope.output.addVariableToTable(this);
1099
- this.toDispose.push(
1100
- Disposable3.create(() => {
1101
- this.scope.output.setHasChanges();
1102
- this.scope.output.removeVariableFromTable(this.key);
1103
- })
1104
- );
1105
1224
  }
1106
1225
  get order() {
1107
1226
  return this._order;
@@ -1116,7 +1235,9 @@ var VariableDeclaration = class extends BaseVariableField {
1116
1235
  updateOrder(order = 0) {
1117
1236
  if (order !== this._order) {
1118
1237
  this._order = order;
1119
- this.scope.output.setHasChanges();
1238
+ this.dispatchGlobalEvent({
1239
+ type: "ReSortVariableDeclarations"
1240
+ });
1120
1241
  this.fireChange();
1121
1242
  }
1122
1243
  }
@@ -1321,9 +1442,9 @@ var ASTRegisters = class {
1321
1442
  this.registerAST(Property);
1322
1443
  this.registerAST(VariableDeclaration);
1323
1444
  this.registerAST(VariableDeclarationList);
1324
- this.registerAST(KeyPathExpression);
1445
+ this.registerAST(KeyPathExpressionV2);
1325
1446
  this.registerAST(EnumerateExpression);
1326
- this.registerAST(ExpressionList);
1447
+ this.registerAST(WrapArrayExpression);
1327
1448
  this.registerAST(MapNode);
1328
1449
  this.registerAST(DataNode);
1329
1450
  }
@@ -1426,116 +1547,13 @@ var ASTFactory;
1426
1547
  kind: "KeyPathExpression" /* KeyPathExpression */,
1427
1548
  ...json
1428
1549
  });
1550
+ ASTFactory2.createWrapArrayExpression = (json) => ({
1551
+ kind: "WrapArrayExpression" /* WrapArrayExpression */,
1552
+ ...json
1553
+ });
1429
1554
  ASTFactory2.create = (targetType, json) => ({ kind: targetType.kind, ...json });
1430
1555
  })(ASTFactory || (ASTFactory = {}));
1431
1556
 
1432
- // src/scope/variable-table.ts
1433
- import { Subject as Subject2, merge, share as share2, skip as skip2, switchMap as switchMap2 } from "rxjs";
1434
- import { Emitter } from "@flowgram.ai/utils";
1435
- import { DisposableCollection as DisposableCollection3 } from "@flowgram.ai/utils";
1436
- var VariableTable = class {
1437
- constructor(parentTable) {
1438
- this.parentTable = parentTable;
1439
- this.table = /* @__PURE__ */ new Map();
1440
- this.onDataChangeEmitter = new Emitter();
1441
- this.variables$ = new Subject2();
1442
- // 监听变量列表中的单个变量变化
1443
- this.anyVariableChange$ = this.variables$.pipe(
1444
- switchMap2(
1445
- (_variables) => merge(
1446
- ..._variables.map(
1447
- (_v) => _v.value$.pipe(
1448
- // 跳过 BehaviorSubject 第一个
1449
- skip2(1)
1450
- )
1451
- )
1452
- )
1453
- ),
1454
- share2()
1455
- );
1456
- this.onDataChange = this.onDataChangeEmitter.event;
1457
- this._version = 0;
1458
- }
1459
- /**
1460
- * 监听任意变量变化
1461
- * @param observer 监听器,变量变化时会吐出值
1462
- * @returns
1463
- */
1464
- onAnyVariableChange(observer) {
1465
- return subsToDisposable(this.anyVariableChange$.subscribe(observer));
1466
- }
1467
- /**
1468
- * 列表或者任意变量变化
1469
- * @param observer
1470
- */
1471
- onAnyChange(observer) {
1472
- const disposables = new DisposableCollection3();
1473
- disposables.pushAll([this.onDataChange(observer), this.onAnyVariableChange(observer)]);
1474
- return disposables;
1475
- }
1476
- fireChange() {
1477
- this._version++;
1478
- this.onDataChangeEmitter.fire();
1479
- this.parentTable?.fireChange();
1480
- }
1481
- get version() {
1482
- return this._version;
1483
- }
1484
- get variables() {
1485
- return Array.from(this.table.values());
1486
- }
1487
- get variableKeys() {
1488
- return Array.from(this.table.keys());
1489
- }
1490
- /**
1491
- * 根据 keyPath 找到对应的变量,或 Property 节点
1492
- * @param keyPath
1493
- * @returns
1494
- */
1495
- getByKeyPath(keyPath) {
1496
- const [variableKey, ...propertyKeys] = keyPath || [];
1497
- if (!variableKey) {
1498
- return;
1499
- }
1500
- const variable = this.getVariableByKey(variableKey);
1501
- return propertyKeys.length ? variable?.getByKeyPath(propertyKeys) : variable;
1502
- }
1503
- /**
1504
- * 根据 key 值找到相应的变量
1505
- * @param key
1506
- * @returns
1507
- */
1508
- getVariableByKey(key) {
1509
- return this.table.get(key);
1510
- }
1511
- /**
1512
- * 往 variableTable 添加输出变量
1513
- * @param variable
1514
- */
1515
- addVariableToTable(variable) {
1516
- this.table.set(variable.key, variable);
1517
- if (this.parentTable) {
1518
- this.parentTable.addVariableToTable(variable);
1519
- }
1520
- this.variables$.next(this.variables);
1521
- }
1522
- /**
1523
- * 从 variableTable 中移除变量
1524
- * @param key
1525
- */
1526
- removeVariableFromTable(key) {
1527
- this.table.delete(key);
1528
- if (this.parentTable) {
1529
- this.parentTable.removeVariableFromTable(key);
1530
- }
1531
- this.variables$.next(this.variables);
1532
- }
1533
- dispose() {
1534
- this.variableKeys.forEach((_key) => this.parentTable?.removeVariableFromTable(_key));
1535
- this.onDataChangeEmitter.dispose();
1536
- }
1537
- };
1538
-
1539
1557
  // src/scope/datas/scope-output-data.ts
1540
1558
  var ScopeOutputData = class {
1541
1559
  constructor(scope) {
@@ -1544,7 +1562,7 @@ var ScopeOutputData = class {
1544
1562
  this._hasChanges = false;
1545
1563
  this.variableTable = new VariableTable(scope.variableEngine.globalVariableTable);
1546
1564
  this.scope.toDispose.pushAll([
1547
- // AST 根节点更新时,检查在这次 AST 变化期间节点是否有变化
1565
+ // When root AST node is updated, check if there are any changes during this AST change
1548
1566
  this.scope.ast.subscribe(() => {
1549
1567
  if (this._hasChanges) {
1550
1568
  this.memo.clear();
@@ -1553,6 +1571,19 @@ var ScopeOutputData = class {
1553
1571
  this._hasChanges = false;
1554
1572
  }
1555
1573
  }),
1574
+ this.scope.event.on("DisposeAST", (_action) => {
1575
+ if (_action.ast?.kind === "VariableDeclaration" /* VariableDeclaration */) {
1576
+ this.removeVariableFromTable(_action.ast.key);
1577
+ }
1578
+ }),
1579
+ this.scope.event.on("NewAST", (_action) => {
1580
+ if (_action.ast?.kind === "VariableDeclaration" /* VariableDeclaration */) {
1581
+ this.addVariableToTable(_action.ast);
1582
+ }
1583
+ }),
1584
+ this.scope.event.on("ReSortVariableDeclarations", () => {
1585
+ this._hasChanges = true;
1586
+ }),
1556
1587
  this.variableTable
1557
1588
  ]);
1558
1589
  }
@@ -1569,7 +1600,7 @@ var ScopeOutputData = class {
1569
1600
  return this.variableTable.onAnyVariableChange.bind(this.variableTable);
1570
1601
  }
1571
1602
  /**
1572
- * 作用域输出变量
1603
+ * Scope Output Variable Declarations
1573
1604
  */
1574
1605
  get variables() {
1575
1606
  return this.memo(
@@ -1578,7 +1609,7 @@ var ScopeOutputData = class {
1578
1609
  );
1579
1610
  }
1580
1611
  /**
1581
- * 输出的变量 keys
1612
+ * Output Variable Keys
1582
1613
  */
1583
1614
  get variableKeys() {
1584
1615
  return this.memo("variableKeys", () => this.variableTable.variableKeys);
@@ -1590,10 +1621,6 @@ var ScopeOutputData = class {
1590
1621
  this.variableTable.addVariableToTable(variable);
1591
1622
  this._hasChanges = true;
1592
1623
  }
1593
- // 标记为发生了变化,用于变量排序变化的场景
1594
- setHasChanges() {
1595
- this._hasChanges = true;
1596
- }
1597
1624
  removeVariableFromTable(key) {
1598
1625
  this.variableTable.removeVariableFromTable(key);
1599
1626
  this._hasChanges = true;
@@ -1601,7 +1628,9 @@ var ScopeOutputData = class {
1601
1628
  getVariableByKey(key) {
1602
1629
  return this.variableTable.getVariableByKey(key);
1603
1630
  }
1604
- // 通知覆盖作用域更新可用变量
1631
+ /**
1632
+ *
1633
+ */
1605
1634
  notifyCoversChange() {
1606
1635
  this.scope.coverScopes.forEach((scope) => scope.available.refresh());
1607
1636
  }
@@ -1619,7 +1648,7 @@ import {
1619
1648
  } from "rxjs";
1620
1649
  import { flatten } from "lodash";
1621
1650
  import { shallowEqual as shallowEqual7 } from "fast-equals";
1622
- import { Disposable as Disposable5 } from "@flowgram.ai/utils";
1651
+ import { Disposable as Disposable3 } from "@flowgram.ai/utils";
1623
1652
  import { Emitter as Emitter2 } from "@flowgram.ai/utils";
1624
1653
  var ScopeAvailableData = class {
1625
1654
  constructor(scope) {
@@ -1665,7 +1694,7 @@ var ScopeAvailableData = class {
1665
1694
  this.onAnyVariableChange(() => {
1666
1695
  this.onDataChangeEmitter.fire(this._variables);
1667
1696
  }),
1668
- Disposable5.create(() => {
1697
+ Disposable3.create(() => {
1669
1698
  this.refresh$.complete();
1670
1699
  this.refresh$.unsubscribe();
1671
1700
  })
@@ -1772,7 +1801,7 @@ var Scope = class {
1772
1801
  this.ast = this.variableEngine.astRegisters.createAST(
1773
1802
  {
1774
1803
  kind: "MapNode" /* MapNode */,
1775
- key: this.id
1804
+ key: String(this.id)
1776
1805
  },
1777
1806
  {
1778
1807
  scope: this
@@ -1825,7 +1854,7 @@ var VariableEngine = class {
1825
1854
  this.onScopeChange = this.onScopeChangeEmitter.event;
1826
1855
  this.toDispose.pushAll([
1827
1856
  chain,
1828
- Disposable6.create(() => {
1857
+ Disposable4.create(() => {
1829
1858
  this.getAllScopes().forEach((scope) => scope.dispose());
1830
1859
  this.globalVariableTable.dispose();
1831
1860
  })
@@ -1845,11 +1874,18 @@ var VariableEngine = class {
1845
1874
  removeScopeById(scopeId) {
1846
1875
  this.getScopeById(scopeId)?.dispose();
1847
1876
  }
1848
- // 获取 Scope,如果 Scope 存在且类型相同,则会直接使用
1849
- createScope(id, meta) {
1877
+ /**
1878
+ * Get Scope, if Scope exists and type is same, will use it directly
1879
+ * @param id scope id
1880
+ * @param meta scope meta, defined by user
1881
+ * @param ScopeConstructor scope constructor, default is Scope. you can extends Scope to create your own scope
1882
+ * @returns
1883
+ */
1884
+ createScope(id, meta, options = {}) {
1885
+ const { ScopeConstructor = Scope } = options;
1850
1886
  let scope = this.getScopeById(id);
1851
1887
  if (!scope) {
1852
- scope = new Scope({ variableEngine: this, meta, id });
1888
+ scope = new ScopeConstructor({ variableEngine: this, meta, id });
1853
1889
  this.scopeMap.set(id, scope);
1854
1890
  this.onScopeChangeEmitter.fire({ type: "add", scope });
1855
1891
  scope.toDispose.pushAll([
@@ -2053,7 +2089,6 @@ export {
2053
2089
  CustomType,
2054
2090
  DataNode,
2055
2091
  EnumerateExpression,
2056
- ExpressionList,
2057
2092
  IntegerType,
2058
2093
  KeyPathExpression,
2059
2094
  KeyPathExpressionV2,
@@ -2074,7 +2109,7 @@ export {
2074
2109
  VariableEngine,
2075
2110
  VariableEngineProvider,
2076
2111
  VariableFieldKeyRenameService,
2077
- VariableTable,
2112
+ WrapArrayExpression,
2078
2113
  injectToAST,
2079
2114
  isMatchAST,
2080
2115
  postConstructAST,