@flowgram.ai/variable-core 0.1.31 → 0.2.1

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
@@ -217,7 +217,7 @@ var ASTKind = /* @__PURE__ */ ((ASTKind2) => {
217
217
  ASTKind2["VariableDeclarationList"] = "VariableDeclarationList";
218
218
  ASTKind2["KeyPathExpression"] = "KeyPathExpression";
219
219
  ASTKind2["EnumerateExpression"] = "EnumerateExpression";
220
- ASTKind2["ExpressionList"] = "ExpressionList";
220
+ ASTKind2["WrapArrayExpression"] = "WrapArrayExpression";
221
221
  ASTKind2["ListNode"] = "ListNode";
222
222
  ASTKind2["DataNode"] = "DataNode";
223
223
  ASTKind2["MapNode"] = "MapNode";
@@ -559,7 +559,7 @@ var BaseType = class extends ASTNode {
559
559
  this.flags = 8 /* BasicType */;
560
560
  }
561
561
  /**
562
- * 类型是否一致,节点有额外信息判断,请参考 extraTypeInfoEqual
562
+ * 类型是否一致
563
563
  * @param targetTypeJSON
564
564
  */
565
565
  isTypeEqual(targetTypeJSONOrKind) {
@@ -578,6 +578,10 @@ var BaseType = class extends ASTNode {
578
578
  getByKeyPath(keyPath = []) {
579
579
  throw new Error(`Get By Key Path is not implemented for Type: ${this.kind}`);
580
580
  }
581
+ /**
582
+ * Get AST JSON for current base type
583
+ * @returns
584
+ */
581
585
  toJSON() {
582
586
  return {
583
587
  kind: this.kind
@@ -913,29 +917,6 @@ var BaseExpression = class extends ASTNode {
913
917
  }
914
918
  };
915
919
 
916
- // src/ast/expression/expression-list.ts
917
- var ExpressionList = class extends ASTNode {
918
- fromJSON({ expressions }) {
919
- this.expressions = expressions.map((_expression, idx) => {
920
- const prevExpression = this.expressions[idx];
921
- if (prevExpression.kind !== _expression.kind) {
922
- prevExpression.dispose();
923
- this.fireChange();
924
- return this.createChildNode(_expression);
925
- }
926
- prevExpression.fromJSON(_expression);
927
- return prevExpression;
928
- });
929
- }
930
- toJSON() {
931
- return {
932
- kind: "ExpressionList" /* ExpressionList */,
933
- properties: this.expressions.map((_expression) => _expression.toJSON())
934
- };
935
- }
936
- };
937
- ExpressionList.kind = "ExpressionList" /* ExpressionList */;
938
-
939
920
  // src/ast/expression/keypath-expression.ts
940
921
  import { shallowEqual as shallowEqual3 } from "fast-equals";
941
922
  var KeyPathExpression = class extends BaseExpression {
@@ -1117,6 +1098,46 @@ var KeyPathExpressionV2 = class extends BaseExpression {
1117
1098
  };
1118
1099
  KeyPathExpressionV2.kind = "KeyPathExpression" /* KeyPathExpression */;
1119
1100
 
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);
1140
+
1120
1141
  // src/ast/declaration/base-variable-field.ts
1121
1142
  import { shallowEqual as shallowEqual5 } from "fast-equals";
1122
1143
  var BaseVariableField = class extends ASTNode {
@@ -1423,7 +1444,7 @@ var ASTRegisters = class {
1423
1444
  this.registerAST(VariableDeclarationList);
1424
1445
  this.registerAST(KeyPathExpression);
1425
1446
  this.registerAST(EnumerateExpression);
1426
- this.registerAST(ExpressionList);
1447
+ this.registerAST(WrapArrayExpression);
1427
1448
  this.registerAST(MapNode);
1428
1449
  this.registerAST(DataNode);
1429
1450
  }
@@ -1526,6 +1547,10 @@ var ASTFactory;
1526
1547
  kind: "KeyPathExpression" /* KeyPathExpression */,
1527
1548
  ...json
1528
1549
  });
1550
+ ASTFactory2.createWrapArrayExpression = (json) => ({
1551
+ kind: "WrapArrayExpression" /* WrapArrayExpression */,
1552
+ ...json
1553
+ });
1529
1554
  ASTFactory2.create = (targetType, json) => ({ kind: targetType.kind, ...json });
1530
1555
  })(ASTFactory || (ASTFactory = {}));
1531
1556
 
@@ -2064,7 +2089,6 @@ export {
2064
2089
  CustomType,
2065
2090
  DataNode,
2066
2091
  EnumerateExpression,
2067
- ExpressionList,
2068
2092
  IntegerType,
2069
2093
  KeyPathExpression,
2070
2094
  KeyPathExpressionV2,
@@ -2085,6 +2109,7 @@ export {
2085
2109
  VariableEngine,
2086
2110
  VariableEngineProvider,
2087
2111
  VariableFieldKeyRenameService,
2112
+ WrapArrayExpression,
2088
2113
  injectToAST,
2089
2114
  isMatchAST,
2090
2115
  postConstructAST,