@flowgram.ai/variable-core 0.1.0-alpha.10 → 0.1.0-alpha.12
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 +23 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +51 -48
- package/dist/index.d.ts +51 -48
- package/dist/index.js +21 -6
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/esm/index.js
CHANGED
|
@@ -54,6 +54,7 @@ var VariableTable = class {
|
|
|
54
54
|
constructor(parentTable) {
|
|
55
55
|
this.parentTable = parentTable;
|
|
56
56
|
this.table = /* @__PURE__ */ new Map();
|
|
57
|
+
this.toDispose = new DisposableCollection();
|
|
57
58
|
this.onDataChangeEmitter = new Emitter();
|
|
58
59
|
this.variables$ = new Subject();
|
|
59
60
|
// 监听变量列表中的单个变量变化
|
|
@@ -75,6 +76,11 @@ var VariableTable = class {
|
|
|
75
76
|
*/
|
|
76
77
|
this.onDataChange = this.onDataChangeEmitter.event;
|
|
77
78
|
this._version = 0;
|
|
79
|
+
this.toDispose.pushAll([
|
|
80
|
+
this.onDataChangeEmitter,
|
|
81
|
+
// active share()
|
|
82
|
+
this.onAnyVariableChange(() => null)
|
|
83
|
+
]);
|
|
78
84
|
}
|
|
79
85
|
/**
|
|
80
86
|
* listen to any variable update in list
|
|
@@ -164,7 +170,7 @@ var VariableTable = class {
|
|
|
164
170
|
this.parentTable?.fireChange();
|
|
165
171
|
this.variables$.complete();
|
|
166
172
|
this.variables$.unsubscribe();
|
|
167
|
-
this.
|
|
173
|
+
this.toDispose.dispose();
|
|
168
174
|
}
|
|
169
175
|
};
|
|
170
176
|
|
|
@@ -408,7 +414,6 @@ var ASTNode = class _ASTNode {
|
|
|
408
414
|
this.opts = opts;
|
|
409
415
|
this.key = key || nanoid();
|
|
410
416
|
this.fromJSON = this.withBatchUpdate(this.fromJSON.bind(this));
|
|
411
|
-
this.dispatchGlobalEvent({ type: "NewAST" });
|
|
412
417
|
}
|
|
413
418
|
/**
|
|
414
419
|
* AST 节点的类型
|
|
@@ -1491,6 +1496,7 @@ var ASTRegisters = class {
|
|
|
1491
1496
|
node.changeLocked = true;
|
|
1492
1497
|
node.fromJSON(omit(json, ["key", "kind"]));
|
|
1493
1498
|
node.changeLocked = false;
|
|
1499
|
+
node.dispatchGlobalEvent({ type: "NewAST" });
|
|
1494
1500
|
if (Reflect.hasMetadata(POST_CONSTRUCT_AST_SYMBOL, node)) {
|
|
1495
1501
|
const postConstructKey = Reflect.getMetadata(POST_CONSTRUCT_AST_SYMBOL, node);
|
|
1496
1502
|
node[postConstructKey]?.();
|
|
@@ -1678,8 +1684,9 @@ var ScopeOutputData = class {
|
|
|
1678
1684
|
// src/scope/datas/scope-available-data.ts
|
|
1679
1685
|
import {
|
|
1680
1686
|
Subject as Subject3,
|
|
1687
|
+
animationFrameScheduler as animationFrameScheduler2,
|
|
1688
|
+
debounceTime as debounceTime2,
|
|
1681
1689
|
distinctUntilChanged as distinctUntilChanged3,
|
|
1682
|
-
distinctUntilKeyChanged,
|
|
1683
1690
|
map as map3,
|
|
1684
1691
|
merge as merge2,
|
|
1685
1692
|
share as share3,
|
|
@@ -1812,16 +1819,25 @@ var ScopeAvailableData = class {
|
|
|
1812
1819
|
* @returns
|
|
1813
1820
|
*/
|
|
1814
1821
|
trackByKeyPath(keyPath = [], cb, opts) {
|
|
1815
|
-
const { triggerOnInit = true } = opts || {};
|
|
1822
|
+
const { triggerOnInit = true, debounceAnimation, selector } = opts || {};
|
|
1816
1823
|
return subsToDisposable(
|
|
1817
1824
|
merge2(this.anyVariableChange$, this.variables$).pipe(
|
|
1818
1825
|
triggerOnInit ? startWith() : tap2(() => null),
|
|
1819
1826
|
map3(() => {
|
|
1820
1827
|
const v = this.getByKeyPath(keyPath);
|
|
1821
|
-
return
|
|
1828
|
+
return selector ? selector(v) : v;
|
|
1822
1829
|
}),
|
|
1823
|
-
|
|
1824
|
-
|
|
1830
|
+
distinctUntilChanged3(
|
|
1831
|
+
(a, b) => shallowEqual7(a, b),
|
|
1832
|
+
(value) => {
|
|
1833
|
+
if (value instanceof ASTNode) {
|
|
1834
|
+
return value.hash;
|
|
1835
|
+
}
|
|
1836
|
+
return value;
|
|
1837
|
+
}
|
|
1838
|
+
),
|
|
1839
|
+
// 每个 animationFrame 内所有更新合并成一个
|
|
1840
|
+
debounceAnimation ? debounceTime2(0, animationFrameScheduler2) : tap2(() => null)
|
|
1825
1841
|
).subscribe(cb)
|
|
1826
1842
|
);
|
|
1827
1843
|
}
|