@flowgram.ai/variable-core 0.1.0-alpha.11 → 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 CHANGED
@@ -414,7 +414,6 @@ var ASTNode = class _ASTNode {
414
414
  this.opts = opts;
415
415
  this.key = key || nanoid();
416
416
  this.fromJSON = this.withBatchUpdate(this.fromJSON.bind(this));
417
- this.dispatchGlobalEvent({ type: "NewAST" });
418
417
  }
419
418
  /**
420
419
  * AST 节点的类型
@@ -1497,6 +1496,7 @@ var ASTRegisters = class {
1497
1496
  node.changeLocked = true;
1498
1497
  node.fromJSON(omit(json, ["key", "kind"]));
1499
1498
  node.changeLocked = false;
1499
+ node.dispatchGlobalEvent({ type: "NewAST" });
1500
1500
  if (Reflect.hasMetadata(POST_CONSTRUCT_AST_SYMBOL, node)) {
1501
1501
  const postConstructKey = Reflect.getMetadata(POST_CONSTRUCT_AST_SYMBOL, node);
1502
1502
  node[postConstructKey]?.();
@@ -1684,8 +1684,9 @@ var ScopeOutputData = class {
1684
1684
  // src/scope/datas/scope-available-data.ts
1685
1685
  import {
1686
1686
  Subject as Subject3,
1687
+ animationFrameScheduler as animationFrameScheduler2,
1688
+ debounceTime as debounceTime2,
1687
1689
  distinctUntilChanged as distinctUntilChanged3,
1688
- distinctUntilKeyChanged,
1689
1690
  map as map3,
1690
1691
  merge as merge2,
1691
1692
  share as share3,
@@ -1818,16 +1819,25 @@ var ScopeAvailableData = class {
1818
1819
  * @returns
1819
1820
  */
1820
1821
  trackByKeyPath(keyPath = [], cb, opts) {
1821
- const { triggerOnInit = true } = opts || {};
1822
+ const { triggerOnInit = true, debounceAnimation, selector } = opts || {};
1822
1823
  return subsToDisposable(
1823
1824
  merge2(this.anyVariableChange$, this.variables$).pipe(
1824
1825
  triggerOnInit ? startWith() : tap2(() => null),
1825
1826
  map3(() => {
1826
1827
  const v = this.getByKeyPath(keyPath);
1827
- return { v, hash: v?.hash };
1828
+ return selector ? selector(v) : v;
1828
1829
  }),
1829
- distinctUntilKeyChanged("hash"),
1830
- map3(({ v }) => v)
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)
1831
1841
  ).subscribe(cb)
1832
1842
  );
1833
1843
  }