@flowgram.ai/variable-core 0.3.2 → 0.3.4
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 +43 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +41 -6
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -32,6 +32,7 @@ declare class ScopeOutputData {
|
|
|
32
32
|
};
|
|
33
33
|
get variableEngine(): VariableEngine;
|
|
34
34
|
get globalVariableTable(): IVariableTable;
|
|
35
|
+
get version(): number;
|
|
35
36
|
/**
|
|
36
37
|
* @deprecated use onListOrAnyVarChange instead
|
|
37
38
|
*/
|
|
@@ -77,8 +78,11 @@ declare class ScopeAvailableData {
|
|
|
77
78
|
clear: (key?: string | symbol) => void;
|
|
78
79
|
};
|
|
79
80
|
get globalVariableTable(): IVariableTable;
|
|
81
|
+
protected _version: number;
|
|
80
82
|
protected refresh$: Subject<void>;
|
|
81
83
|
protected _variables: VariableDeclaration[];
|
|
84
|
+
get version(): number;
|
|
85
|
+
protected bumpVersion(): void;
|
|
82
86
|
refresh(): void;
|
|
83
87
|
/**
|
|
84
88
|
* 监听
|
|
@@ -133,9 +137,7 @@ declare class ScopeAvailableData {
|
|
|
133
137
|
* Track Variable Change (Includes type update and children update) By KeyPath
|
|
134
138
|
* @returns
|
|
135
139
|
*/
|
|
136
|
-
trackByKeyPath(keyPath: string[] | undefined, cb: (variable?:
|
|
137
|
-
triggerOnInit?: boolean;
|
|
138
|
-
}): Disposable;
|
|
140
|
+
trackByKeyPath<Data = BaseVariableField | undefined>(keyPath: string[] | undefined, cb: (variable?: Data) => void, opts?: SubscribeConfig<BaseVariableField | undefined, Data>): Disposable;
|
|
139
141
|
}
|
|
140
142
|
|
|
141
143
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ declare class ScopeOutputData {
|
|
|
32
32
|
};
|
|
33
33
|
get variableEngine(): VariableEngine;
|
|
34
34
|
get globalVariableTable(): IVariableTable;
|
|
35
|
+
get version(): number;
|
|
35
36
|
/**
|
|
36
37
|
* @deprecated use onListOrAnyVarChange instead
|
|
37
38
|
*/
|
|
@@ -77,8 +78,11 @@ declare class ScopeAvailableData {
|
|
|
77
78
|
clear: (key?: string | symbol) => void;
|
|
78
79
|
};
|
|
79
80
|
get globalVariableTable(): IVariableTable;
|
|
81
|
+
protected _version: number;
|
|
80
82
|
protected refresh$: Subject<void>;
|
|
81
83
|
protected _variables: VariableDeclaration[];
|
|
84
|
+
get version(): number;
|
|
85
|
+
protected bumpVersion(): void;
|
|
82
86
|
refresh(): void;
|
|
83
87
|
/**
|
|
84
88
|
* 监听
|
|
@@ -133,9 +137,7 @@ declare class ScopeAvailableData {
|
|
|
133
137
|
* Track Variable Change (Includes type update and children update) By KeyPath
|
|
134
138
|
* @returns
|
|
135
139
|
*/
|
|
136
|
-
trackByKeyPath(keyPath: string[] | undefined, cb: (variable?:
|
|
137
|
-
triggerOnInit?: boolean;
|
|
138
|
-
}): Disposable;
|
|
140
|
+
trackByKeyPath<Data = BaseVariableField | undefined>(keyPath: string[] | undefined, cb: (variable?: Data) => void, opts?: SubscribeConfig<BaseVariableField | undefined, Data>): Disposable;
|
|
139
141
|
}
|
|
140
142
|
|
|
141
143
|
/**
|
package/dist/index.js
CHANGED
|
@@ -119,6 +119,9 @@ var VariableTable = class {
|
|
|
119
119
|
this.parentTable = parentTable;
|
|
120
120
|
this.table = /* @__PURE__ */ new Map();
|
|
121
121
|
this.toDispose = new import_utils2.DisposableCollection();
|
|
122
|
+
/**
|
|
123
|
+
* @deprecated
|
|
124
|
+
*/
|
|
122
125
|
this.onDataChangeEmitter = new import_utils2.Emitter();
|
|
123
126
|
this.variables$ = new import_rxjs.Subject();
|
|
124
127
|
// 监听变量列表中的单个变量变化
|
|
@@ -143,7 +146,9 @@ var VariableTable = class {
|
|
|
143
146
|
this.toDispose.pushAll([
|
|
144
147
|
this.onDataChangeEmitter,
|
|
145
148
|
// active share()
|
|
146
|
-
this.onAnyVariableChange(() =>
|
|
149
|
+
this.onAnyVariableChange(() => {
|
|
150
|
+
this.bumpVersion();
|
|
151
|
+
})
|
|
147
152
|
]);
|
|
148
153
|
}
|
|
149
154
|
/**
|
|
@@ -172,7 +177,7 @@ var VariableTable = class {
|
|
|
172
177
|
return disposables;
|
|
173
178
|
}
|
|
174
179
|
fireChange() {
|
|
175
|
-
this.
|
|
180
|
+
this.bumpVersion();
|
|
176
181
|
this.onDataChangeEmitter.fire();
|
|
177
182
|
this.variables$.next(this.variables);
|
|
178
183
|
this.parentTable?.fireChange();
|
|
@@ -180,6 +185,12 @@ var VariableTable = class {
|
|
|
180
185
|
get version() {
|
|
181
186
|
return this._version;
|
|
182
187
|
}
|
|
188
|
+
bumpVersion() {
|
|
189
|
+
this._version = this._version + 1;
|
|
190
|
+
if (this._version === Number.MAX_SAFE_INTEGER) {
|
|
191
|
+
this._version = 0;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
183
194
|
get variables() {
|
|
184
195
|
return Array.from(this.table.values());
|
|
185
196
|
}
|
|
@@ -1668,6 +1679,9 @@ var ScopeOutputData = class {
|
|
|
1668
1679
|
get globalVariableTable() {
|
|
1669
1680
|
return this.scope.variableEngine.globalVariableTable;
|
|
1670
1681
|
}
|
|
1682
|
+
get version() {
|
|
1683
|
+
return this.variableTable.version;
|
|
1684
|
+
}
|
|
1671
1685
|
/**
|
|
1672
1686
|
* @deprecated use onListOrAnyVarChange instead
|
|
1673
1687
|
*/
|
|
@@ -1739,6 +1753,7 @@ var ScopeAvailableData = class {
|
|
|
1739
1753
|
constructor(scope) {
|
|
1740
1754
|
this.scope = scope;
|
|
1741
1755
|
this.memo = createMemo();
|
|
1756
|
+
this._version = 0;
|
|
1742
1757
|
this.refresh$ = new import_rxjs4.Subject();
|
|
1743
1758
|
this._variables = [];
|
|
1744
1759
|
/**
|
|
@@ -1783,10 +1798,12 @@ var ScopeAvailableData = class {
|
|
|
1783
1798
|
this._variables = _variables;
|
|
1784
1799
|
this.memo.clear();
|
|
1785
1800
|
this.onDataChangeEmitter.fire(this._variables);
|
|
1801
|
+
this.bumpVersion();
|
|
1786
1802
|
this.onListOrAnyVarChangeEmitter.fire(this._variables);
|
|
1787
1803
|
}),
|
|
1788
1804
|
this.onAnyVariableChange(() => {
|
|
1789
1805
|
this.onDataChangeEmitter.fire(this._variables);
|
|
1806
|
+
this.bumpVersion();
|
|
1790
1807
|
this.onListOrAnyVarChangeEmitter.fire(this._variables);
|
|
1791
1808
|
}),
|
|
1792
1809
|
import_utils5.Disposable.create(() => {
|
|
@@ -1798,6 +1815,15 @@ var ScopeAvailableData = class {
|
|
|
1798
1815
|
get globalVariableTable() {
|
|
1799
1816
|
return this.scope.variableEngine.globalVariableTable;
|
|
1800
1817
|
}
|
|
1818
|
+
get version() {
|
|
1819
|
+
return this._version;
|
|
1820
|
+
}
|
|
1821
|
+
bumpVersion() {
|
|
1822
|
+
this._version = this._version + 1;
|
|
1823
|
+
if (this._version === Number.MAX_SAFE_INTEGER) {
|
|
1824
|
+
this._version = 0;
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1801
1827
|
// 刷新可访问变量列表
|
|
1802
1828
|
refresh() {
|
|
1803
1829
|
if (this.scope.disposed) {
|
|
@@ -1855,16 +1881,25 @@ var ScopeAvailableData = class {
|
|
|
1855
1881
|
* @returns
|
|
1856
1882
|
*/
|
|
1857
1883
|
trackByKeyPath(keyPath = [], cb, opts) {
|
|
1858
|
-
const { triggerOnInit = true } = opts || {};
|
|
1884
|
+
const { triggerOnInit = true, debounceAnimation, selector } = opts || {};
|
|
1859
1885
|
return subsToDisposable(
|
|
1860
1886
|
(0, import_rxjs4.merge)(this.anyVariableChange$, this.variables$).pipe(
|
|
1861
1887
|
triggerOnInit ? (0, import_rxjs4.startWith)() : (0, import_rxjs4.tap)(() => null),
|
|
1862
1888
|
(0, import_rxjs4.map)(() => {
|
|
1863
1889
|
const v = this.getByKeyPath(keyPath);
|
|
1864
|
-
return
|
|
1890
|
+
return selector ? selector(v) : v;
|
|
1865
1891
|
}),
|
|
1866
|
-
(0, import_rxjs4.
|
|
1867
|
-
|
|
1892
|
+
(0, import_rxjs4.distinctUntilChanged)(
|
|
1893
|
+
(a, b) => (0, import_fast_equals7.shallowEqual)(a, b),
|
|
1894
|
+
(value) => {
|
|
1895
|
+
if (value instanceof ASTNode) {
|
|
1896
|
+
return value.hash;
|
|
1897
|
+
}
|
|
1898
|
+
return value;
|
|
1899
|
+
}
|
|
1900
|
+
),
|
|
1901
|
+
// 每个 animationFrame 内所有更新合并成一个
|
|
1902
|
+
debounceAnimation ? (0, import_rxjs4.debounceTime)(0, import_rxjs4.animationFrameScheduler) : (0, import_rxjs4.tap)(() => null)
|
|
1868
1903
|
).subscribe(cb)
|
|
1869
1904
|
);
|
|
1870
1905
|
}
|