@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/index.d.mts CHANGED
@@ -133,9 +133,7 @@ declare class ScopeAvailableData {
133
133
  * Track Variable Change (Includes type update and children update) By KeyPath
134
134
  * @returns
135
135
  */
136
- trackByKeyPath(keyPath: string[] | undefined, cb: (variable?: BaseVariableField | undefined) => void, opts?: {
137
- triggerOnInit?: boolean;
138
- }): Disposable;
136
+ trackByKeyPath<Data = BaseVariableField | undefined>(keyPath: string[] | undefined, cb: (variable?: Data) => void, opts?: SubscribeConfig<BaseVariableField | undefined, Data>): Disposable;
139
137
  }
140
138
 
141
139
  /**
package/dist/index.d.ts CHANGED
@@ -133,9 +133,7 @@ declare class ScopeAvailableData {
133
133
  * Track Variable Change (Includes type update and children update) By KeyPath
134
134
  * @returns
135
135
  */
136
- trackByKeyPath(keyPath: string[] | undefined, cb: (variable?: BaseVariableField | undefined) => void, opts?: {
137
- triggerOnInit?: boolean;
138
- }): Disposable;
136
+ trackByKeyPath<Data = BaseVariableField | undefined>(keyPath: string[] | undefined, cb: (variable?: Data) => void, opts?: SubscribeConfig<BaseVariableField | undefined, Data>): Disposable;
139
137
  }
140
138
 
141
139
  /**
package/dist/index.js CHANGED
@@ -470,7 +470,6 @@ var ASTNode = class _ASTNode {
470
470
  this.opts = opts;
471
471
  this.key = key || (0, import_nanoid.nanoid)();
472
472
  this.fromJSON = this.withBatchUpdate(this.fromJSON.bind(this));
473
- this.dispatchGlobalEvent({ type: "NewAST" });
474
473
  }
475
474
  /**
476
475
  * AST 节点的类型
@@ -1545,6 +1544,7 @@ var ASTRegisters = class {
1545
1544
  node.changeLocked = true;
1546
1545
  node.fromJSON((0, import_lodash3.omit)(json, ["key", "kind"]));
1547
1546
  node.changeLocked = false;
1547
+ node.dispatchGlobalEvent({ type: "NewAST" });
1548
1548
  if (Reflect.hasMetadata(POST_CONSTRUCT_AST_SYMBOL, node)) {
1549
1549
  const postConstructKey = Reflect.getMetadata(POST_CONSTRUCT_AST_SYMBOL, node);
1550
1550
  node[postConstructKey]?.();
@@ -1855,16 +1855,25 @@ var ScopeAvailableData = class {
1855
1855
  * @returns
1856
1856
  */
1857
1857
  trackByKeyPath(keyPath = [], cb, opts) {
1858
- const { triggerOnInit = true } = opts || {};
1858
+ const { triggerOnInit = true, debounceAnimation, selector } = opts || {};
1859
1859
  return subsToDisposable(
1860
1860
  (0, import_rxjs4.merge)(this.anyVariableChange$, this.variables$).pipe(
1861
1861
  triggerOnInit ? (0, import_rxjs4.startWith)() : (0, import_rxjs4.tap)(() => null),
1862
1862
  (0, import_rxjs4.map)(() => {
1863
1863
  const v = this.getByKeyPath(keyPath);
1864
- return { v, hash: v?.hash };
1864
+ return selector ? selector(v) : v;
1865
1865
  }),
1866
- (0, import_rxjs4.distinctUntilKeyChanged)("hash"),
1867
- (0, import_rxjs4.map)(({ v }) => v)
1866
+ (0, import_rxjs4.distinctUntilChanged)(
1867
+ (a, b) => (0, import_fast_equals7.shallowEqual)(a, b),
1868
+ (value) => {
1869
+ if (value instanceof ASTNode) {
1870
+ return value.hash;
1871
+ }
1872
+ return value;
1873
+ }
1874
+ ),
1875
+ // 每个 animationFrame 内所有更新合并成一个
1876
+ debounceAnimation ? (0, import_rxjs4.debounceTime)(0, import_rxjs4.animationFrameScheduler) : (0, import_rxjs4.tap)(() => null)
1868
1877
  ).subscribe(cb)
1869
1878
  );
1870
1879
  }