aoye 0.0.12 → 0.0.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/index.umd.js CHANGED
@@ -771,21 +771,19 @@
771
771
  pullRecurse(shouldLink = true) {
772
772
  var _a, _b;
773
773
  G.PullingRecurseDeep++;
774
- let downstream = G.PullingSignal;
774
+ const downstream = G.PullingSignal;
775
775
  const isScope = this.state & State.IsScope;
776
- if (
777
- // 1. 外部支持 link
778
- shouldLink && // 2. 有下游
779
- downstream && // 3. 下游是 watcher,不链接非 scope
780
- !(downstream.state & State.LinkScopeOnly && !isScope)
781
- ) {
776
+ if (this !== downstream && // 1. 外部支持 link
777
+ shouldLink && // 2. 有下游
778
+ downstream && // 3. 下游是 watcher,不链接非 scope
779
+ (!(downstream.state & State.LinkScopeOnly) || isScope)) {
782
780
  Line.link(this, downstream);
783
781
  }
784
782
  try {
785
783
  if (this.version === G.version) {
786
784
  return this.value;
787
785
  }
788
- this.recEnd = null;
786
+ if (this.pull !== this.DEFAULT_PULL) this.recEnd = null;
789
787
  this.state |= State.Pulling;
790
788
  G.PullingSignal = this;
791
789
  (_a = this.clean) == null ? void 0 : _a.call(this);
@@ -796,7 +794,6 @@
796
794
  this.clean = () => runWithPulling(fn, null);
797
795
  v = this.value;
798
796
  }
799
- this.pull = this.customPull || this.DEFAULT_PULL;
800
797
  this.value = v;
801
798
  this.version = G.version;
802
799
  return this.value;
@@ -804,6 +801,7 @@
804
801
  console.error("\u8BA1\u7B97\u5C5E\u6027\u62A5\u9519\u8FD9\u6B21\u4E0D\u89E6\u53D1\uFF0C\u540E\u7EED\u72B6\u6001\u53EF\u80FD\u51FA\u9519", error);
805
802
  return this.value;
806
803
  } finally {
804
+ this.pull = this.customPull || this.DEFAULT_PULL;
807
805
  pullingPostprocess(this);
808
806
  const toDel = (_b = this.recEnd) == null ? void 0 : _b.nextRecLine;
809
807
  unlinkRecWithScope(toDel);
@@ -813,54 +811,64 @@
813
811
  }
814
812
  pullDeep() {
815
813
  const signal = this;
816
- if (!(signal.state & DirtyState)) {
817
- return this.value;
818
- }
819
- dfs(signal, {
820
- isUp: true,
821
- begin: ({ node }) => {
822
- if (node.state & State.Pulling || !(node.state & DirtyState) || node.isDisabled()) {
823
- return true;
824
- }
825
- node.state |= State.Pulling;
826
- },
827
- complete: ({ node, notGoDeep: currentClean, walkedLine }) => {
828
- let noGoSibling = false;
829
- const last = walkedLine[walkedLine.length - 1];
830
- const downstream = last == null ? void 0 : last.downstream;
831
- if (currentClean) ; else if (node.state & State.Dirty) {
832
- if (!node.recStart && node.value !== node.nextValue) {
833
- node.markDownStreamsDirty();
834
- node.state &= ~State.Dirty;
835
- node.state &= ~State.Pulling;
836
- return;
837
- } else {
838
- const prevPulling = G.PullingSignal;
839
- G.PullingSignal = downstream;
840
- const prevValue = node.value;
841
- node.pullRecurse(false);
842
- if (prevValue !== node.value) {
814
+ if (signal.state & DirtyState) {
815
+ dfs(signal, {
816
+ isUp: true,
817
+ begin: ({ node }) => {
818
+ if (node.state & (State.Pulling | State.Dirty) || !(node.state & DirtyState) || node.isDisabled()) {
819
+ return true;
820
+ }
821
+ node.state |= State.Pulling;
822
+ },
823
+ complete: ({ node, notGoDeep: cleanOrDirty, walkedLine }) => {
824
+ const isDirty = node.state & State.Dirty;
825
+ let currentClean = cleanOrDirty && !isDirty;
826
+ if (cleanOrDirty && node.state & State.Pulling) {
827
+ currentClean = true;
828
+ }
829
+ let noGoSibling = false;
830
+ const last = walkedLine[walkedLine.length - 1];
831
+ const downstream2 = last == null ? void 0 : last.downstream;
832
+ if (currentClean) ; else if (isDirty) {
833
+ if (node.pull === node.DEFAULT_PULL && node.value !== node.nextValue) {
843
834
  node.markDownStreamsDirty();
835
+ node.state &= ~State.Dirty;
836
+ node.state &= ~State.Pulling;
837
+ return;
838
+ } else {
839
+ const prevPulling = G.PullingSignal;
840
+ G.PullingSignal = downstream2;
841
+ const prevValue = node.value;
842
+ node.pullRecurse(false);
843
+ if (prevValue !== node.value) {
844
+ node.markDownStreamsDirty();
845
+ }
846
+ node.state &= ~State.Dirty;
847
+ G.PullingSignal = prevPulling;
848
+ noGoSibling = true;
844
849
  }
845
- node.state &= ~State.Dirty;
846
- G.PullingSignal = prevPulling;
847
- noGoSibling = true;
850
+ } else if (node.state & State.Unknown) {
851
+ node.state &= ~State.Unknown;
848
852
  }
849
- } else if (node.state & State.Unknown) {
850
- node.state &= ~State.Unknown;
853
+ node.version = G.version;
854
+ pullingPostprocess(node);
855
+ return noGoSibling;
851
856
  }
852
- node.version = G.version;
853
- pullingPostprocess(node);
854
- return noGoSibling;
855
- }
856
- });
857
+ });
858
+ }
859
+ const downstream = G.PullingSignal;
860
+ if (this !== downstream && // 2. 有下游
861
+ downstream && // 3. 下游是 watcher 不是 watch,或 是watcher 但 当前是 scope
862
+ (!(downstream.state & State.LinkScopeOnly) || this.state & State.IsScope)) {
863
+ Line.link(this, downstream);
864
+ }
857
865
  return this.value;
858
866
  }
859
867
  get v() {
860
868
  if (this.isDisabled()) {
861
869
  return this.value;
862
870
  }
863
- if (!this.recStart) {
871
+ if (!this.recStart || this.pull === this.DEFAULT_PULL) {
864
872
  return this.pullRecurse(true);
865
873
  }
866
874
  return this.pullDeep();
@@ -944,6 +952,7 @@
944
952
  case Keys.Meta:
945
953
  return meta;
946
954
  }
955
+ if (prop === Symbol.unscopables) return Reflect.get(obj, prop, receiver);
947
956
  if (targetIsStore && isIgnoreKey(obj.constructor[StoreIgnoreKeys], prop)) {
948
957
  return Reflect.get(obj, prop, receiver);
949
958
  }
@@ -974,7 +983,7 @@
974
983
  return s.v;
975
984
  },
976
985
  set(obj, prop, value, receiver) {
977
- if (targetIsStore && isIgnoreKey(obj.constructor[StoreIgnoreKeys], prop)) {
986
+ if (targetIsStore && isIgnoreKey(obj.constructor[StoreIgnoreKeys], prop) || typeof value === "function") {
978
987
  return Reflect.set(obj, prop, value, receiver);
979
988
  }
980
989
  batch.start();
@@ -993,7 +1002,7 @@
993
1002
  },
994
1003
  // 【核心修改】拦截 delete 操作
995
1004
  deleteProperty(obj, prop) {
996
- if (targetIsStore && isIgnoreKey(obj.constructor[StoreIgnoreKeys], prop)) {
1005
+ if (targetIsStore && isIgnoreKey(obj.constructor[StoreIgnoreKeys], prop) || typeof obj[prop] === "function") {
997
1006
  return Reflect.deleteProperty(obj, prop);
998
1007
  }
999
1008
  if (cells.has(prop)) {