aoye 0.0.11 → 0.0.13
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/aoye.cjs.js +66 -49
- package/dist/aoye.cjs.js.map +1 -1
- package/dist/aoye.esm.js +65 -50
- package/dist/aoye.esm.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.umd.js +66 -49
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -4
package/dist/aoye.cjs.js
CHANGED
|
@@ -641,6 +641,12 @@ function runWithPulling(fn, signal) {
|
|
|
641
641
|
G.PullingSignal = prevPulling;
|
|
642
642
|
return res;
|
|
643
643
|
}
|
|
644
|
+
function getPulling() {
|
|
645
|
+
return G.PullingSignal;
|
|
646
|
+
}
|
|
647
|
+
function setPulling(pulling) {
|
|
648
|
+
G.PullingSignal = pulling;
|
|
649
|
+
}
|
|
644
650
|
|
|
645
651
|
class Batch {
|
|
646
652
|
constructor() {
|
|
@@ -763,21 +769,19 @@ const _Signal = class _Signal {
|
|
|
763
769
|
pullRecurse(shouldLink = true) {
|
|
764
770
|
var _a, _b;
|
|
765
771
|
G.PullingRecurseDeep++;
|
|
766
|
-
|
|
772
|
+
const downstream = G.PullingSignal;
|
|
767
773
|
const isScope = this.state & State.IsScope;
|
|
768
|
-
if (
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
!(downstream.state & State.LinkScopeOnly && !isScope)
|
|
773
|
-
) {
|
|
774
|
+
if (this !== downstream && // 1. 外部支持 link
|
|
775
|
+
shouldLink && // 2. 有下游
|
|
776
|
+
downstream && // 3. 下游是 watcher,不链接非 scope
|
|
777
|
+
(!(downstream.state & State.LinkScopeOnly) || isScope)) {
|
|
774
778
|
Line.link(this, downstream);
|
|
775
779
|
}
|
|
776
780
|
try {
|
|
777
781
|
if (this.version === G.version) {
|
|
778
782
|
return this.value;
|
|
779
783
|
}
|
|
780
|
-
this.recEnd = null;
|
|
784
|
+
if (this.pull !== this.DEFAULT_PULL) this.recEnd = null;
|
|
781
785
|
this.state |= State.Pulling;
|
|
782
786
|
G.PullingSignal = this;
|
|
783
787
|
(_a = this.clean) == null ? void 0 : _a.call(this);
|
|
@@ -788,7 +792,6 @@ const _Signal = class _Signal {
|
|
|
788
792
|
this.clean = () => runWithPulling(fn, null);
|
|
789
793
|
v = this.value;
|
|
790
794
|
}
|
|
791
|
-
this.pull = this.customPull || this.DEFAULT_PULL;
|
|
792
795
|
this.value = v;
|
|
793
796
|
this.version = G.version;
|
|
794
797
|
return this.value;
|
|
@@ -796,6 +799,7 @@ const _Signal = class _Signal {
|
|
|
796
799
|
console.error("\u8BA1\u7B97\u5C5E\u6027\u62A5\u9519\u8FD9\u6B21\u4E0D\u89E6\u53D1\uFF0C\u540E\u7EED\u72B6\u6001\u53EF\u80FD\u51FA\u9519", error);
|
|
797
800
|
return this.value;
|
|
798
801
|
} finally {
|
|
802
|
+
this.pull = this.customPull || this.DEFAULT_PULL;
|
|
799
803
|
pullingPostprocess(this);
|
|
800
804
|
const toDel = (_b = this.recEnd) == null ? void 0 : _b.nextRecLine;
|
|
801
805
|
unlinkRecWithScope(toDel);
|
|
@@ -805,54 +809,64 @@ const _Signal = class _Signal {
|
|
|
805
809
|
}
|
|
806
810
|
pullDeep() {
|
|
807
811
|
const signal = this;
|
|
808
|
-
if (
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
}
|
|
817
|
-
node
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
node.
|
|
828
|
-
return;
|
|
829
|
-
} else {
|
|
830
|
-
const prevPulling = G.PullingSignal;
|
|
831
|
-
G.PullingSignal = downstream;
|
|
832
|
-
const prevValue = node.value;
|
|
833
|
-
node.pullRecurse(false);
|
|
834
|
-
if (prevValue !== node.value) {
|
|
812
|
+
if (signal.state & DirtyState) {
|
|
813
|
+
dfs(signal, {
|
|
814
|
+
isUp: true,
|
|
815
|
+
begin: ({ node }) => {
|
|
816
|
+
if (node.state & (State.Pulling | State.Dirty) || !(node.state & DirtyState) || node.isDisabled()) {
|
|
817
|
+
return true;
|
|
818
|
+
}
|
|
819
|
+
node.state |= State.Pulling;
|
|
820
|
+
},
|
|
821
|
+
complete: ({ node, notGoDeep: cleanOrDirty, walkedLine }) => {
|
|
822
|
+
const isDirty = node.state & State.Dirty;
|
|
823
|
+
let currentClean = cleanOrDirty && !isDirty;
|
|
824
|
+
if (cleanOrDirty && node.state & State.Pulling) {
|
|
825
|
+
currentClean = true;
|
|
826
|
+
}
|
|
827
|
+
let noGoSibling = false;
|
|
828
|
+
const last = walkedLine[walkedLine.length - 1];
|
|
829
|
+
const downstream2 = last == null ? void 0 : last.downstream;
|
|
830
|
+
if (currentClean) ; else if (isDirty) {
|
|
831
|
+
if (node.pull === node.DEFAULT_PULL && node.value !== node.nextValue) {
|
|
835
832
|
node.markDownStreamsDirty();
|
|
833
|
+
node.state &= ~State.Dirty;
|
|
834
|
+
node.state &= ~State.Pulling;
|
|
835
|
+
return;
|
|
836
|
+
} else {
|
|
837
|
+
const prevPulling = G.PullingSignal;
|
|
838
|
+
G.PullingSignal = downstream2;
|
|
839
|
+
const prevValue = node.value;
|
|
840
|
+
node.pullRecurse(false);
|
|
841
|
+
if (prevValue !== node.value) {
|
|
842
|
+
node.markDownStreamsDirty();
|
|
843
|
+
}
|
|
844
|
+
node.state &= ~State.Dirty;
|
|
845
|
+
G.PullingSignal = prevPulling;
|
|
846
|
+
noGoSibling = true;
|
|
836
847
|
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
noGoSibling = true;
|
|
848
|
+
} else if (node.state & State.Unknown) {
|
|
849
|
+
node.state &= ~State.Unknown;
|
|
840
850
|
}
|
|
841
|
-
|
|
842
|
-
node
|
|
851
|
+
node.version = G.version;
|
|
852
|
+
pullingPostprocess(node);
|
|
853
|
+
return noGoSibling;
|
|
843
854
|
}
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
const downstream = G.PullingSignal;
|
|
858
|
+
if (this !== downstream && // 2. 有下游
|
|
859
|
+
downstream && // 3. 下游是 watcher 不是 watch,或 是watcher 但 当前是 scope
|
|
860
|
+
(!(downstream.state & State.LinkScopeOnly) || this.state & State.IsScope)) {
|
|
861
|
+
Line.link(this, downstream);
|
|
862
|
+
}
|
|
849
863
|
return this.value;
|
|
850
864
|
}
|
|
851
865
|
get v() {
|
|
852
866
|
if (this.isDisabled()) {
|
|
853
867
|
return this.value;
|
|
854
868
|
}
|
|
855
|
-
if (!this.recStart) {
|
|
869
|
+
if (!this.recStart || this.pull === this.DEFAULT_PULL) {
|
|
856
870
|
return this.pullRecurse(true);
|
|
857
871
|
}
|
|
858
872
|
return this.pullDeep();
|
|
@@ -936,6 +950,7 @@ const deepSignal = (target, scope, deep = true) => {
|
|
|
936
950
|
case Keys.Meta:
|
|
937
951
|
return meta;
|
|
938
952
|
}
|
|
953
|
+
if (prop === Symbol.unscopables) return Reflect.get(obj, prop, receiver);
|
|
939
954
|
if (targetIsStore && isIgnoreKey(obj.constructor[StoreIgnoreKeys], prop)) {
|
|
940
955
|
return Reflect.get(obj, prop, receiver);
|
|
941
956
|
}
|
|
@@ -966,7 +981,7 @@ const deepSignal = (target, scope, deep = true) => {
|
|
|
966
981
|
return s.v;
|
|
967
982
|
},
|
|
968
983
|
set(obj, prop, value, receiver) {
|
|
969
|
-
if (targetIsStore && isIgnoreKey(obj.constructor[StoreIgnoreKeys], prop)) {
|
|
984
|
+
if (targetIsStore && isIgnoreKey(obj.constructor[StoreIgnoreKeys], prop) || typeof value === "function") {
|
|
970
985
|
return Reflect.set(obj, prop, value, receiver);
|
|
971
986
|
}
|
|
972
987
|
batch.start();
|
|
@@ -985,7 +1000,7 @@ const deepSignal = (target, scope, deep = true) => {
|
|
|
985
1000
|
},
|
|
986
1001
|
// 【核心修改】拦截 delete 操作
|
|
987
1002
|
deleteProperty(obj, prop) {
|
|
988
|
-
if (targetIsStore && isIgnoreKey(obj.constructor[StoreIgnoreKeys], prop)) {
|
|
1003
|
+
if (targetIsStore && isIgnoreKey(obj.constructor[StoreIgnoreKeys], prop) || typeof obj[prop] === "function") {
|
|
989
1004
|
return Reflect.deleteProperty(obj, prop);
|
|
990
1005
|
}
|
|
991
1006
|
if (cells.has(prop)) {
|
|
@@ -1526,10 +1541,12 @@ exports.batch = batch;
|
|
|
1526
1541
|
exports.clean = clean;
|
|
1527
1542
|
exports.customEffect = customEffect;
|
|
1528
1543
|
exports.effect = effect;
|
|
1544
|
+
exports.getPulling = getPulling;
|
|
1529
1545
|
exports.isScope = isScope;
|
|
1530
1546
|
exports.isSignal = isSignal;
|
|
1531
1547
|
exports.registerScheduler = registerScheduler;
|
|
1532
1548
|
exports.runWithPulling = runWithPulling;
|
|
1533
1549
|
exports.scope = scope;
|
|
1550
|
+
exports.setPulling = setPulling;
|
|
1534
1551
|
exports.shareSignal = shareSignal;
|
|
1535
1552
|
//# sourceMappingURL=aoye.cjs.js.map
|