@flowgram.ai/variable-core 0.1.0-alpha.12 → 0.1.0-alpha.14

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
@@ -55,6 +55,9 @@ var VariableTable = class {
55
55
  this.parentTable = parentTable;
56
56
  this.table = /* @__PURE__ */ new Map();
57
57
  this.toDispose = new DisposableCollection();
58
+ /**
59
+ * @deprecated
60
+ */
58
61
  this.onDataChangeEmitter = new Emitter();
59
62
  this.variables$ = new Subject();
60
63
  // 监听变量列表中的单个变量变化
@@ -79,7 +82,9 @@ var VariableTable = class {
79
82
  this.toDispose.pushAll([
80
83
  this.onDataChangeEmitter,
81
84
  // active share()
82
- this.onAnyVariableChange(() => null)
85
+ this.onAnyVariableChange(() => {
86
+ this.bumpVersion();
87
+ })
83
88
  ]);
84
89
  }
85
90
  /**
@@ -108,7 +113,7 @@ var VariableTable = class {
108
113
  return disposables;
109
114
  }
110
115
  fireChange() {
111
- this._version++;
116
+ this.bumpVersion();
112
117
  this.onDataChangeEmitter.fire();
113
118
  this.variables$.next(this.variables);
114
119
  this.parentTable?.fireChange();
@@ -116,6 +121,12 @@ var VariableTable = class {
116
121
  get version() {
117
122
  return this._version;
118
123
  }
124
+ bumpVersion() {
125
+ this._version = this._version + 1;
126
+ if (this._version === Number.MAX_SAFE_INTEGER) {
127
+ this._version = 0;
128
+ }
129
+ }
119
130
  get variables() {
120
131
  return Array.from(this.table.values());
121
132
  }
@@ -244,7 +255,7 @@ var ASTKind = /* @__PURE__ */ ((ASTKind2) => {
244
255
  })(ASTKind || {});
245
256
 
246
257
  // src/ast/ast-registers.ts
247
- import { omit } from "lodash";
258
+ import { omit } from "lodash-es";
248
259
  import { injectable as injectable2 } from "inversify";
249
260
 
250
261
  // src/ast/utils/inversify.ts
@@ -662,7 +673,17 @@ var StringType = class extends BaseType {
662
673
  super(...arguments);
663
674
  this.flags = 8 /* BasicType */;
664
675
  }
665
- fromJSON() {
676
+ /**
677
+ * https://json-schema.org/understanding-json-schema/reference/type#format
678
+ */
679
+ get format() {
680
+ return this._format;
681
+ }
682
+ fromJSON(json) {
683
+ if (json?.format !== this._format) {
684
+ this._format = json?.format;
685
+ this.fireChange();
686
+ }
666
687
  }
667
688
  };
668
689
  StringType.kind = "String" /* String */;
@@ -740,7 +761,7 @@ var MapType = class extends BaseType {
740
761
  MapType.kind = "Map" /* Map */;
741
762
 
742
763
  // src/ast/type/object.ts
743
- import { xor } from "lodash";
764
+ import { xor } from "lodash-es";
744
765
  var ObjectType = class extends BaseType {
745
766
  constructor() {
746
767
  super(...arguments);
@@ -1024,7 +1045,7 @@ EnumerateExpression.kind = "EnumerateExpression" /* EnumerateExpression */;
1024
1045
  import { shallowEqual as shallowEqual4 } from "fast-equals";
1025
1046
 
1026
1047
  // src/ast/utils/expression.ts
1027
- import { intersection } from "lodash";
1048
+ import { intersection } from "lodash-es";
1028
1049
  function getAllRefs(ast) {
1029
1050
  return getAllChildren(ast).filter((_child) => _child.flags & 4 /* Expression */).map((_child) => _child.refs).flat().filter(Boolean);
1030
1051
  }
@@ -1530,7 +1551,10 @@ ASTRegisters = __decorateClass([
1530
1551
  // src/ast/factory.ts
1531
1552
  var ASTFactory;
1532
1553
  ((ASTFactory2) => {
1533
- ASTFactory2.createString = () => ({ kind: "String" /* String */ });
1554
+ ASTFactory2.createString = (json) => ({
1555
+ kind: "String" /* String */,
1556
+ ...json || {}
1557
+ });
1534
1558
  ASTFactory2.createNumber = () => ({ kind: "Number" /* Number */ });
1535
1559
  ASTFactory2.createBoolean = () => ({ kind: "Boolean" /* Boolean */ });
1536
1560
  ASTFactory2.createInteger = () => ({ kind: "Integer" /* Integer */ });
@@ -1620,6 +1644,9 @@ var ScopeOutputData = class {
1620
1644
  get globalVariableTable() {
1621
1645
  return this.scope.variableEngine.globalVariableTable;
1622
1646
  }
1647
+ get version() {
1648
+ return this.variableTable.version;
1649
+ }
1623
1650
  /**
1624
1651
  * @deprecated use onListOrAnyVarChange instead
1625
1652
  */
@@ -1695,7 +1722,7 @@ import {
1695
1722
  switchMap as switchMap3,
1696
1723
  tap as tap2
1697
1724
  } from "rxjs";
1698
- import { flatten } from "lodash";
1725
+ import { flatten } from "lodash-es";
1699
1726
  import { shallowEqual as shallowEqual7 } from "fast-equals";
1700
1727
  import { Disposable as Disposable3 } from "@flowgram.ai/utils";
1701
1728
  import { Emitter as Emitter2 } from "@flowgram.ai/utils";
@@ -1703,6 +1730,7 @@ var ScopeAvailableData = class {
1703
1730
  constructor(scope) {
1704
1731
  this.scope = scope;
1705
1732
  this.memo = createMemo();
1733
+ this._version = 0;
1706
1734
  this.refresh$ = new Subject3();
1707
1735
  this._variables = [];
1708
1736
  /**
@@ -1747,10 +1775,12 @@ var ScopeAvailableData = class {
1747
1775
  this._variables = _variables;
1748
1776
  this.memo.clear();
1749
1777
  this.onDataChangeEmitter.fire(this._variables);
1778
+ this.bumpVersion();
1750
1779
  this.onListOrAnyVarChangeEmitter.fire(this._variables);
1751
1780
  }),
1752
1781
  this.onAnyVariableChange(() => {
1753
1782
  this.onDataChangeEmitter.fire(this._variables);
1783
+ this.bumpVersion();
1754
1784
  this.onListOrAnyVarChangeEmitter.fire(this._variables);
1755
1785
  }),
1756
1786
  Disposable3.create(() => {
@@ -1762,6 +1792,15 @@ var ScopeAvailableData = class {
1762
1792
  get globalVariableTable() {
1763
1793
  return this.scope.variableEngine.globalVariableTable;
1764
1794
  }
1795
+ get version() {
1796
+ return this._version;
1797
+ }
1798
+ bumpVersion() {
1799
+ this._version = this._version + 1;
1800
+ if (this._version === Number.MAX_SAFE_INTEGER) {
1801
+ this._version = 0;
1802
+ }
1803
+ }
1765
1804
  // 刷新可访问变量列表
1766
1805
  refresh() {
1767
1806
  if (this.scope.disposed) {
@@ -2056,7 +2095,7 @@ VariableEngine = __decorateClass([
2056
2095
  ], VariableEngine);
2057
2096
 
2058
2097
  // src/services/variable-field-key-rename-service.ts
2059
- import { difference } from "lodash";
2098
+ import { difference } from "lodash-es";
2060
2099
  import { inject as inject3, injectable as injectable4, postConstruct, preDestroy as preDestroy2 } from "inversify";
2061
2100
  import { DisposableCollection as DisposableCollection6, Emitter as Emitter4 } from "@flowgram.ai/utils";
2062
2101
  var VariableFieldKeyRenameService = class {