@flowgram.ai/variable-core 0.1.0-alpha.8 → 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/index.js CHANGED
@@ -155,10 +155,9 @@ var VariableTable = class {
155
155
  return disposables;
156
156
  }
157
157
  fireChange() {
158
- var _a;
159
158
  this._version++;
160
159
  this.onDataChangeEmitter.fire();
161
- (_a = this.parentTable) == null ? void 0 : _a.fireChange();
160
+ this.parentTable?.fireChange();
162
161
  }
163
162
  get version() {
164
163
  return this._version;
@@ -180,7 +179,7 @@ var VariableTable = class {
180
179
  return;
181
180
  }
182
181
  const variable = this.getVariableByKey(variableKey);
183
- return propertyKeys.length ? variable == null ? void 0 : variable.getByKeyPath(propertyKeys) : variable;
182
+ return propertyKeys.length ? variable?.getByKeyPath(propertyKeys) : variable;
184
183
  }
185
184
  /**
186
185
  * 根据 key 值找到相应的变量
@@ -214,10 +213,7 @@ var VariableTable = class {
214
213
  }
215
214
  dispose() {
216
215
  this.variableKeys.forEach(
217
- (_key) => {
218
- var _a;
219
- return (_a = this.parentTable) == null ? void 0 : _a.removeVariableFromTable(_key);
220
- }
216
+ (_key) => this.parentTable?.removeVariableFromTable(_key)
221
217
  );
222
218
  this.onDataChangeEmitter.dispose();
223
219
  }
@@ -327,21 +323,21 @@ var postConstructAST = () => (target, propertyKey) => {
327
323
  // src/ast/match.ts
328
324
  var ASTMatch;
329
325
  ((ASTMatch2) => {
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 */;
326
+ ASTMatch2.isString = (node) => node?.kind === "String" /* String */;
327
+ ASTMatch2.isNumber = (node) => node?.kind === "Number" /* Number */;
328
+ ASTMatch2.isBoolean = (node) => node?.kind === "Boolean" /* Boolean */;
329
+ ASTMatch2.isInteger = (node) => node?.kind === "Integer" /* Integer */;
330
+ ASTMatch2.isObject = (node) => node?.kind === "Object" /* Object */;
331
+ ASTMatch2.isArray = (node) => node?.kind === "Array" /* Array */;
332
+ ASTMatch2.isMap = (node) => node?.kind === "Map" /* Map */;
333
+ ASTMatch2.isCustomType = (node) => node?.kind === "CustomType" /* CustomType */;
334
+ ASTMatch2.isVariableDeclaration = (node) => node?.kind === "VariableDeclaration" /* VariableDeclaration */;
335
+ ASTMatch2.isProperty = (node) => node?.kind === "Property" /* Property */;
336
+ ASTMatch2.isVariableDeclarationList = (node) => node?.kind === "VariableDeclarationList" /* VariableDeclarationList */;
337
+ ASTMatch2.isEnumerateExpression = (node) => node?.kind === "EnumerateExpression" /* EnumerateExpression */;
338
+ ASTMatch2.isKeyPathExpression = (node) => node?.kind === "KeyPathExpression" /* KeyPathExpression */;
343
339
  function is(node, targetType) {
344
- return (node == null ? void 0 : node.kind) === (targetType == null ? void 0 : targetType.kind);
340
+ return node?.kind === targetType?.kind;
345
341
  }
346
342
  ASTMatch2.is = is;
347
343
  })(ASTMatch || (ASTMatch = {}));
@@ -354,8 +350,8 @@ function updateChildNodeHelper({
354
350
  nextJSON
355
351
  }) {
356
352
  const currNode = getChildNode();
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);
353
+ const isNewKind = currNode?.kind !== nextJSON?.kind;
354
+ const isNewKey = nextJSON?.key && nextJSON?.key !== currNode?.key;
359
355
  if (isNewKind || isNewKey) {
360
356
  if (currNode) {
361
357
  currNode.dispose();
@@ -370,7 +366,7 @@ function updateChildNodeHelper({
370
366
  this.fireChange();
371
367
  }
372
368
  } else if (nextJSON) {
373
- currNode == null ? void 0 : currNode.fromJSON(nextJSON);
369
+ currNode?.fromJSON(nextJSON);
374
370
  }
375
371
  return currNode;
376
372
  }
@@ -442,8 +438,7 @@ var ASTNode = class _ASTNode {
442
438
  */
443
439
  this.toDispose = new import_utils4.DisposableCollection(
444
440
  import_utils4.Disposable.create(() => {
445
- var _a;
446
- (_a = this.parent) == null ? void 0 : _a.fireChange();
441
+ this.parent?.fireChange();
447
442
  this.children.forEach((child) => child.dispose());
448
443
  })
449
444
  );
@@ -539,7 +534,6 @@ var ASTNode = class _ASTNode {
539
534
  * 触发当前节点更新
540
535
  */
541
536
  fireChange() {
542
- var _a;
543
537
  if (this.changeLocked || this.disposed) {
544
538
  return;
545
539
  }
@@ -550,7 +544,7 @@ var ASTNode = class _ASTNode {
550
544
  this._version++;
551
545
  this.value$.next(this);
552
546
  this.dispatchGlobalEvent({ type: "UpdateAST" });
553
- (_a = this.parent) == null ? void 0 : _a.fireChange();
547
+ this.parent?.fireChange();
554
548
  }
555
549
  /**
556
550
  * 节点的版本值
@@ -625,14 +619,13 @@ var BaseType = class extends ASTNode {
625
619
  * @param targetTypeJSON
626
620
  */
627
621
  isTypeEqual(targetTypeJSONOrKind) {
628
- var _a;
629
622
  const targetTypeJSON = parseTypeJsonOrKind(targetTypeJSONOrKind);
630
- if ((targetTypeJSON == null ? void 0 : targetTypeJSON.kind) === "Union" /* Union */) {
631
- return (_a = (targetTypeJSON == null ? void 0 : targetTypeJSON.types) || []) == null ? void 0 : _a.some(
623
+ if (targetTypeJSON?.kind === "Union" /* Union */) {
624
+ return (targetTypeJSON?.types || [])?.some(
632
625
  (_subType) => this.isTypeEqual(_subType)
633
626
  );
634
627
  }
635
- return this.kind === (targetTypeJSON == null ? void 0 : targetTypeJSON.kind);
628
+ return this.kind === targetTypeJSON?.kind;
636
629
  }
637
630
  /**
638
631
  * 可下钻类型需实现
@@ -663,8 +656,7 @@ var ArrayType = class extends BaseType {
663
656
  }
664
657
  // items 类型是否可下钻
665
658
  get canDrilldownItems() {
666
- var _a;
667
- return !!(((_a = this.items) == null ? void 0 : _a.flags) & 16 /* DrilldownType */);
659
+ return !!(this.items?.flags & 16 /* DrilldownType */);
668
660
  }
669
661
  getByKeyPath(keyPath) {
670
662
  const [curr, ...rest] = keyPath || [];
@@ -676,11 +668,11 @@ var ArrayType = class extends BaseType {
676
668
  isTypeEqual(targetTypeJSONOrKind) {
677
669
  const targetTypeJSON = parseTypeJsonOrKind(targetTypeJSONOrKind);
678
670
  const isSuperEqual = super.isTypeEqual(targetTypeJSONOrKind);
679
- if ((targetTypeJSON == null ? void 0 : targetTypeJSON.weak) || (targetTypeJSON == null ? void 0 : targetTypeJSON.kind) === "Union" /* Union */) {
671
+ if (targetTypeJSON?.weak || targetTypeJSON?.kind === "Union" /* Union */) {
680
672
  return isSuperEqual;
681
673
  }
682
674
  return targetTypeJSON && isSuperEqual && // 弱比较,只需要比较 Kind 即可
683
- ((targetTypeJSON == null ? void 0 : targetTypeJSON.weak) || this.customStrongEqual(targetTypeJSON));
675
+ (targetTypeJSON?.weak || this.customStrongEqual(targetTypeJSON));
684
676
  }
685
677
  /**
686
678
  * Array 强比较
@@ -688,17 +680,15 @@ var ArrayType = class extends BaseType {
688
680
  * @returns
689
681
  */
690
682
  customStrongEqual(targetTypeJSON) {
691
- var _a;
692
683
  if (!this.items) {
693
- return !(targetTypeJSON == null ? void 0 : targetTypeJSON.items);
684
+ return !targetTypeJSON?.items;
694
685
  }
695
- return (_a = this.items) == null ? void 0 : _a.isTypeEqual(targetTypeJSON.items);
686
+ return this.items?.isTypeEqual(targetTypeJSON.items);
696
687
  }
697
688
  toJSON() {
698
- var _a;
699
689
  return {
700
690
  kind: "Array" /* Array */,
701
- items: (_a = this.items) == null ? void 0 : _a.toJSON()
691
+ items: this.items?.toJSON()
702
692
  };
703
693
  }
704
694
  };
@@ -760,11 +750,11 @@ var MapType = class extends BaseType {
760
750
  isTypeEqual(targetTypeJSONOrKind) {
761
751
  const targetTypeJSON = parseTypeJsonOrKind(targetTypeJSONOrKind);
762
752
  const isSuperEqual = super.isTypeEqual(targetTypeJSONOrKind);
763
- if ((targetTypeJSON == null ? void 0 : targetTypeJSON.weak) || (targetTypeJSON == null ? void 0 : targetTypeJSON.kind) === "Union" /* Union */) {
753
+ if (targetTypeJSON?.weak || targetTypeJSON?.kind === "Union" /* Union */) {
764
754
  return isSuperEqual;
765
755
  }
766
756
  return targetTypeJSON && isSuperEqual && // 弱比较,只需要比较 Kind 即可
767
- ((targetTypeJSON == null ? void 0 : targetTypeJSON.weak) || this.customStrongEqual(targetTypeJSON));
757
+ (targetTypeJSON?.weak || this.customStrongEqual(targetTypeJSON));
768
758
  }
769
759
  /**
770
760
  * Map 强比较
@@ -772,17 +762,15 @@ var MapType = class extends BaseType {
772
762
  * @returns
773
763
  */
774
764
  customStrongEqual(targetTypeJSON) {
775
- var _a, _b;
776
765
  const { keyType = "String" /* String */, valueType } = targetTypeJSON;
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));
766
+ const isValueTypeEqual = !valueType && !this.valueType || this.valueType?.isTypeEqual(valueType);
767
+ return isValueTypeEqual && this.keyType?.isTypeEqual(keyType);
779
768
  }
780
769
  toJSON() {
781
- var _a, _b;
782
770
  return {
783
771
  kind: "Map" /* Map */,
784
- keyType: (_a = this.keyType) == null ? void 0 : _a.toJSON(),
785
- valueType: (_b = this.valueType) == null ? void 0 : _b.toJSON()
772
+ keyType: this.keyType?.toJSON(),
773
+ valueType: this.valueType?.toJSON()
786
774
  };
787
775
  }
788
776
  };
@@ -818,7 +806,7 @@ var ObjectType = class extends BaseType {
818
806
  });
819
807
  removedKeys.forEach((key) => {
820
808
  const property = this.propertyTable.get(key);
821
- property == null ? void 0 : property.dispose();
809
+ property?.dispose();
822
810
  this.propertyTable.delete(key);
823
811
  this.fireChange();
824
812
  });
@@ -842,13 +830,12 @@ var ObjectType = class extends BaseType {
842
830
  * @returns
843
831
  */
844
832
  getByKeyPath(keyPath) {
845
- var _a;
846
833
  const [curr, ...restKeyPath] = keyPath;
847
834
  const property = this.propertyTable.get(curr);
848
835
  if (!restKeyPath.length) {
849
836
  return property;
850
837
  }
851
- if ((property == null ? void 0 : property.type) && ((_a = property == null ? void 0 : property.type) == null ? void 0 : _a.flags) & 16 /* DrilldownType */) {
838
+ if (property?.type && property?.type?.flags & 16 /* DrilldownType */) {
852
839
  return property.type.getByKeyPath(restKeyPath);
853
840
  }
854
841
  return void 0;
@@ -856,11 +843,11 @@ var ObjectType = class extends BaseType {
856
843
  isTypeEqual(targetTypeJSONOrKind) {
857
844
  const targetTypeJSON = parseTypeJsonOrKind(targetTypeJSONOrKind);
858
845
  const isSuperEqual = super.isTypeEqual(targetTypeJSONOrKind);
859
- if ((targetTypeJSON == null ? void 0 : targetTypeJSON.weak) || (targetTypeJSON == null ? void 0 : targetTypeJSON.kind) === "Union" /* Union */) {
846
+ if (targetTypeJSON?.weak || targetTypeJSON?.kind === "Union" /* Union */) {
860
847
  return isSuperEqual;
861
848
  }
862
849
  return targetTypeJSON && isSuperEqual && // 弱比较,只需要比较 Kind 即可
863
- ((targetTypeJSON == null ? void 0 : targetTypeJSON.weak) || this.customStrongEqual(targetTypeJSON));
850
+ (targetTypeJSON?.weak || this.customStrongEqual(targetTypeJSON));
864
851
  }
865
852
  /**
866
853
  * Object 类型强比较
@@ -873,9 +860,8 @@ var ObjectType = class extends BaseType {
873
860
  const targetPropertyKeys = targetProperties.map((_target) => _target.key);
874
861
  const isKeyStrongEqual = !(0, import_lodash.xor)(sourcePropertyKeys, targetPropertyKeys).length;
875
862
  return isKeyStrongEqual && targetProperties.every((targetProperty) => {
876
- var _a;
877
863
  const sourceProperty = this.propertyTable.get(targetProperty.key);
878
- return sourceProperty && sourceProperty.key === targetProperty.key && ((_a = sourceProperty.type) == null ? void 0 : _a.isTypeEqual(targetProperty == null ? void 0 : targetProperty.type));
864
+ return sourceProperty && sourceProperty.key === targetProperty.key && sourceProperty.type?.isTypeEqual(targetProperty?.type);
879
865
  });
880
866
  }
881
867
  };
@@ -893,14 +879,13 @@ var CustomType = class extends BaseType {
893
879
  }
894
880
  }
895
881
  isTypeEqual(targetTypeJSONOrKind) {
896
- var _a;
897
882
  const targetTypeJSON = parseTypeJsonOrKind(targetTypeJSONOrKind);
898
- if ((targetTypeJSON == null ? void 0 : targetTypeJSON.kind) === "Union" /* Union */) {
899
- return (_a = (targetTypeJSON == null ? void 0 : targetTypeJSON.types) || []) == null ? void 0 : _a.some(
883
+ if (targetTypeJSON?.kind === "Union" /* Union */) {
884
+ return (targetTypeJSON?.types || [])?.some(
900
885
  (_subType) => this.isTypeEqual(_subType)
901
886
  );
902
887
  }
903
- return (targetTypeJSON == null ? void 0 : targetTypeJSON.kind) === this.kind && (targetTypeJSON == null ? void 0 : targetTypeJSON.typeName) === this.typeName;
888
+ return targetTypeJSON?.kind === this.kind && targetTypeJSON?.typeName === this.typeName;
904
889
  }
905
890
  };
906
891
  CustomType.kind = "CustomType" /* CustomType */;
@@ -940,7 +925,7 @@ var BaseExpression = class extends ASTNode {
940
925
  (0, import_rxjs3.map)(() => this.getRefFields()),
941
926
  (0, import_rxjs3.distinctUntilChanged)(import_fast_equals2.shallowEqual),
942
927
  (0, import_rxjs3.switchMap)(
943
- (refs) => !(refs == null ? void 0 : refs.length) ? (0, import_rxjs3.of)([]) : (0, import_rxjs3.combineLatest)(
928
+ (refs) => !refs?.length ? (0, import_rxjs3.of)([]) : (0, import_rxjs3.combineLatest)(
944
929
  refs.map(
945
930
  (ref) => ref ? ref.value$ : (0, import_rxjs3.of)(void 0)
946
931
  )
@@ -1044,9 +1029,8 @@ var EnumerateExpression = class extends BaseExpression {
1044
1029
  return this._enumerateFor;
1045
1030
  }
1046
1031
  get returnType() {
1047
- var _a;
1048
- const childReturnType = (_a = this.enumerateFor) == null ? void 0 : _a.returnType;
1049
- if ((childReturnType == null ? void 0 : childReturnType.kind) === "Array" /* Array */) {
1032
+ const childReturnType = this.enumerateFor?.returnType;
1033
+ if (childReturnType?.kind === "Array" /* Array */) {
1050
1034
  return childReturnType.items;
1051
1035
  }
1052
1036
  return void 0;
@@ -1058,10 +1042,9 @@ var EnumerateExpression = class extends BaseExpression {
1058
1042
  this.updateChildNodeByKey("_enumerateFor", expression);
1059
1043
  }
1060
1044
  toJSON() {
1061
- var _a;
1062
1045
  return {
1063
1046
  kind: "EnumerateExpression" /* EnumerateExpression */,
1064
- enumerateFor: (_a = this.enumerateFor) == null ? void 0 : _a.toJSON()
1047
+ enumerateFor: this.enumerateFor?.toJSON()
1065
1048
  };
1066
1049
  }
1067
1050
  };
@@ -1076,7 +1059,7 @@ function getAllRefs(ast) {
1076
1059
  return getAllChildren(ast).filter((_child) => _child.flags & 4 /* Expression */).map((_child) => _child.refs).flat().filter(Boolean);
1077
1060
  }
1078
1061
  function checkRefCycle(curr, refNodes) {
1079
- if ((0, import_lodash2.intersection)(curr.scope.coverScopes, refNodes.map((_ref) => _ref == null ? void 0 : _ref.scope).filter(Boolean)).length === 0) {
1062
+ if ((0, import_lodash2.intersection)(curr.scope.coverScopes, refNodes.map((_ref) => _ref?.scope).filter(Boolean)).length === 0) {
1080
1063
  return false;
1081
1064
  }
1082
1065
  const visited = /* @__PURE__ */ new Set();
@@ -1109,10 +1092,9 @@ var KeyPathExpressionV2 = class extends BaseExpression {
1109
1092
  }),
1110
1093
  subsToDisposable(
1111
1094
  this.refs$.subscribe((_type) => {
1112
- var _a, _b;
1113
1095
  const [ref] = this._refs;
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;
1096
+ if (this.prevRefTypeHash !== ref?.type?.hash) {
1097
+ this.prevRefTypeHash = ref?.type?.hash;
1116
1098
  this.updateChildNodeByKey("_returnType", this.getReturnTypeJSONByRef(ref));
1117
1099
  }
1118
1100
  })
@@ -1153,8 +1135,7 @@ var KeyPathExpressionV2 = class extends BaseExpression {
1153
1135
  }
1154
1136
  }
1155
1137
  getReturnTypeJSONByRef(_ref) {
1156
- var _a;
1157
- return (_a = _ref == null ? void 0 : _ref.type) == null ? void 0 : _a.toJSON();
1138
+ return _ref?.type?.toJSON();
1158
1139
  }
1159
1140
  toJSON() {
1160
1141
  return {
@@ -1174,8 +1155,7 @@ var WrapArrayExpression = class extends BaseExpression {
1174
1155
  return this._returnType;
1175
1156
  }
1176
1157
  refreshReturnType() {
1177
- var _a, _b;
1178
- const childReturnTypeJSON = (_b = (_a = this.wrapFor) == null ? void 0 : _a.returnType) == null ? void 0 : _b.toJSON();
1158
+ const childReturnTypeJSON = this.wrapFor?.returnType?.toJSON();
1179
1159
  this.updateChildNodeByKey("_returnType", {
1180
1160
  kind: "Array" /* Array */,
1181
1161
  items: childReturnTypeJSON
@@ -1188,19 +1168,15 @@ var WrapArrayExpression = class extends BaseExpression {
1188
1168
  this.updateChildNodeByKey("_wrapFor", expression);
1189
1169
  }
1190
1170
  toJSON() {
1191
- var _a;
1192
1171
  return {
1193
1172
  kind: "WrapArrayExpression" /* WrapArrayExpression */,
1194
- wrapFor: (_a = this.wrapFor) == null ? void 0 : _a.toJSON()
1173
+ wrapFor: this.wrapFor?.toJSON()
1195
1174
  };
1196
1175
  }
1197
1176
  init() {
1198
1177
  this.toDispose.push(
1199
1178
  this.subscribe(this.refreshReturnType, {
1200
- selector: (curr) => {
1201
- var _a;
1202
- return (_a = curr.wrapFor) == null ? void 0 : _a.returnType;
1203
- }
1179
+ selector: (curr) => curr.wrapFor?.returnType
1204
1180
  })
1205
1181
  );
1206
1182
  }
@@ -1228,8 +1204,7 @@ var BaseVariableField = class extends ASTNode {
1228
1204
  return this._meta;
1229
1205
  }
1230
1206
  get type() {
1231
- var _a;
1232
- return ((_a = this._initializer) == null ? void 0 : _a.returnType) || this._type;
1207
+ return this._initializer?.returnType || this._type;
1233
1208
  }
1234
1209
  get initializer() {
1235
1210
  return this._initializer;
@@ -1261,8 +1236,7 @@ var BaseVariableField = class extends ASTNode {
1261
1236
  * @returns
1262
1237
  */
1263
1238
  getByKeyPath(keyPath) {
1264
- var _a;
1265
- if (((_a = this.type) == null ? void 0 : _a.flags) & 16 /* DrilldownType */) {
1239
+ if (this.type?.flags & 16 /* DrilldownType */) {
1266
1240
  return this.type.getByKeyPath(keyPath);
1267
1241
  }
1268
1242
  return void 0;
@@ -1280,12 +1254,11 @@ var BaseVariableField = class extends ASTNode {
1280
1254
  * @returns
1281
1255
  */
1282
1256
  toJSON() {
1283
- var _a, _b;
1284
1257
  return {
1285
1258
  kind: this.kind,
1286
1259
  key: this.key,
1287
- type: (_a = this.type) == null ? void 0 : _a.toJSON(),
1288
- initializer: (_b = this.initializer) == null ? void 0 : _b.toJSON(),
1260
+ type: this.type?.toJSON(),
1261
+ initializer: this.initializer?.toJSON(),
1289
1262
  meta: this._meta
1290
1263
  };
1291
1264
  }
@@ -1334,9 +1307,8 @@ var VariableDeclarationList = class extends ASTNode {
1334
1307
  const prev = [...this.declarations || []];
1335
1308
  this.declarations = (declarations || []).map(
1336
1309
  (declaration, idx) => {
1337
- var _a, _b;
1338
1310
  const order = (startOrder || 0) + idx;
1339
- const declarationKey = declaration.key || ((_b = (_a = this.declarations) == null ? void 0 : _a[idx]) == null ? void 0 : _b.key);
1311
+ const declarationKey = declaration.key || this.declarations?.[idx]?.key;
1340
1312
  const existDeclaration = this.declarationTable.get(declarationKey);
1341
1313
  if (declarationKey) {
1342
1314
  removedKeys.delete(declarationKey);
@@ -1358,7 +1330,7 @@ var VariableDeclarationList = class extends ASTNode {
1358
1330
  );
1359
1331
  removedKeys.forEach((key) => {
1360
1332
  const declaration = this.declarationTable.get(key);
1361
- declaration == null ? void 0 : declaration.dispose();
1333
+ declaration?.dispose();
1362
1334
  this.declarationTable.delete(key);
1363
1335
  });
1364
1336
  this.dispatchGlobalEvent({
@@ -1484,8 +1456,7 @@ var MapNode = class extends ASTNode {
1484
1456
  * @param key
1485
1457
  */
1486
1458
  remove(key) {
1487
- var _a;
1488
- (_a = this.get(key)) == null ? void 0 : _a.dispose();
1459
+ this.get(key)?.dispose();
1489
1460
  this.map.delete(key);
1490
1461
  this.fireChange();
1491
1462
  }
@@ -1531,7 +1502,6 @@ var ASTRegisters = class {
1531
1502
  * @returns
1532
1503
  */
1533
1504
  createAST(json, { parent, scope }) {
1534
- var _a;
1535
1505
  const Registry = this.astMap.get(json.kind);
1536
1506
  if (!Registry) {
1537
1507
  throw Error(`ASTKind: ${String(json.kind)} can not find its ASTNode Registry`);
@@ -1543,14 +1513,14 @@ var ASTRegisters = class {
1543
1513
  scope,
1544
1514
  parent
1545
1515
  },
1546
- (injector == null ? void 0 : injector()) || {}
1516
+ injector?.() || {}
1547
1517
  );
1548
1518
  node.changeLocked = true;
1549
1519
  node.fromJSON((0, import_lodash3.omit)(json, ["key", "kind"]));
1550
1520
  node.changeLocked = false;
1551
1521
  if (Reflect.hasMetadata(POST_CONSTRUCT_AST_SYMBOL, node)) {
1552
1522
  const postConstructKey = Reflect.getMetadata(POST_CONSTRUCT_AST_SYMBOL, node);
1553
- (_a = node[postConstructKey]) == null ? void 0 : _a.call(node);
1523
+ node[postConstructKey]?.();
1554
1524
  }
1555
1525
  return node;
1556
1526
  }
@@ -1650,14 +1620,12 @@ var ScopeOutputData = class {
1650
1620
  }
1651
1621
  }),
1652
1622
  this.scope.event.on("DisposeAST", (_action) => {
1653
- var _a;
1654
- if (((_a = _action.ast) == null ? void 0 : _a.kind) === "VariableDeclaration" /* VariableDeclaration */) {
1623
+ if (_action.ast?.kind === "VariableDeclaration" /* VariableDeclaration */) {
1655
1624
  this.removeVariableFromTable(_action.ast.key);
1656
1625
  }
1657
1626
  }),
1658
1627
  this.scope.event.on("NewAST", (_action) => {
1659
- var _a;
1660
- if (((_a = _action.ast) == null ? void 0 : _a.kind) === "VariableDeclaration" /* VariableDeclaration */) {
1628
+ if (_action.ast?.kind === "VariableDeclaration" /* VariableDeclaration */) {
1661
1629
  this.addVariableToTable(_action.ast);
1662
1630
  }
1663
1631
  }),
@@ -1892,13 +1860,13 @@ var Scope = class {
1892
1860
  get depScopes() {
1893
1861
  return this.memo(
1894
1862
  "deps",
1895
- () => this.variableEngine.chain.getDeps(this).filter((_scope) => Boolean(_scope) && !(_scope == null ? void 0 : _scope.disposed))
1863
+ () => this.variableEngine.chain.getDeps(this).filter((_scope) => Boolean(_scope) && !_scope?.disposed)
1896
1864
  );
1897
1865
  }
1898
1866
  get coverScopes() {
1899
1867
  return this.memo(
1900
1868
  "covers",
1901
- () => this.variableEngine.chain.getCovers(this).filter((_scope) => Boolean(_scope) && !(_scope == null ? void 0 : _scope.disposed))
1869
+ () => this.variableEngine.chain.getCovers(this).filter((_scope) => Boolean(_scope) && !_scope?.disposed)
1902
1870
  );
1903
1871
  }
1904
1872
  dispose() {
@@ -1944,8 +1912,7 @@ var VariableEngine = class {
1944
1912
  }
1945
1913
  // 移除作用域
1946
1914
  removeScopeById(scopeId) {
1947
- var _a;
1948
- (_a = this.getScopeById(scopeId)) == null ? void 0 : _a.dispose();
1915
+ this.getScopeById(scopeId)?.dispose();
1949
1916
  }
1950
1917
  /**
1951
1918
  * Get Scope, if Scope exists and type is same, will use it directly
@@ -2029,8 +1996,7 @@ var VariableFieldKeyRenameService = class {
2029
1996
  this.onDisposeInList = this.disposeInListEmitter.event;
2030
1997
  }
2031
1998
  handleFieldListChange(ast, prev, next) {
2032
- var _a, _b;
2033
- if (!ast || !(prev == null ? void 0 : prev.length) || !(next == null ? void 0 : next.length)) {
1999
+ if (!ast || !prev?.length || !next?.length) {
2034
2000
  this.notifyFieldsDispose(prev, next);
2035
2001
  return;
2036
2002
  }
@@ -2048,7 +2014,7 @@ var VariableFieldKeyRenameService = class {
2048
2014
  return;
2049
2015
  }
2050
2016
  existFieldChanged = true;
2051
- if (((_a = prevField.type) == null ? void 0 : _a.kind) === ((_b = nextField.type) == null ? void 0 : _b.kind)) {
2017
+ if (prevField.type?.kind === nextField.type?.kind) {
2052
2018
  renameNodeInfo = { before: prevField, after: nextField };
2053
2019
  }
2054
2020
  }
@@ -2068,15 +2034,13 @@ var VariableFieldKeyRenameService = class {
2068
2034
  this.variableEngine.onGlobalEvent(
2069
2035
  "VariableListChange",
2070
2036
  (_action) => {
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);
2037
+ this.handleFieldListChange(_action.ast, _action.payload?.prev, _action.payload?.next);
2073
2038
  }
2074
2039
  ),
2075
2040
  this.variableEngine.onGlobalEvent(
2076
2041
  "ObjectPropertiesChange",
2077
2042
  (_action) => {
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);
2043
+ this.handleFieldListChange(_action.ast, _action.payload?.prev, _action.payload?.next);
2080
2044
  }
2081
2045
  )
2082
2046
  ]);
@@ -2112,10 +2076,7 @@ var import_react = require("react");
2112
2076
  var ScopeContext = (0, import_react.createContext)(null);
2113
2077
  var ScopeProvider = ScopeContext.Provider;
2114
2078
  var useScopeContext = () => (0, import_react.useContext)(ScopeContext);
2115
- var useCurrentScope = () => {
2116
- var _a;
2117
- return (_a = (0, import_react.useContext)(ScopeContext)) == null ? void 0 : _a.scope;
2118
- };
2079
+ var useCurrentScope = () => (0, import_react.useContext)(ScopeContext)?.scope;
2119
2080
 
2120
2081
  // src/react/hooks/useScopeAvailable.ts
2121
2082
  var import_react2 = require("react");