@solidjs/signals 0.10.3 → 0.10.5
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/dev.js +157 -149
- package/dist/node.cjs +241 -234
- package/dist/prod.js +183 -176
- package/dist/types/core/core.d.ts +1 -6
- package/dist/types/core/index.d.ts +3 -1
- package/dist/types/core/owner.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/store/store.d.ts +4 -4
- package/package.json +1 -1
package/dist/dev.js
CHANGED
|
@@ -717,100 +717,67 @@ function notifyStatus(el, status, error, blockStatus, lane) {
|
|
|
717
717
|
}
|
|
718
718
|
}
|
|
719
719
|
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
const
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
lazy: true
|
|
720
|
+
function unlinkSubs(link) {
|
|
721
|
+
const dep = link._dep;
|
|
722
|
+
const nextDep = link._nextDep;
|
|
723
|
+
const nextSub = link._nextSub;
|
|
724
|
+
const prevSub = link._prevSub;
|
|
725
|
+
if (nextSub !== null) nextSub._prevSub = prevSub;
|
|
726
|
+
else dep._subsTail = prevSub;
|
|
727
|
+
if (prevSub !== null) prevSub._nextSub = nextSub;
|
|
728
|
+
else {
|
|
729
|
+
dep._subs = nextSub;
|
|
730
|
+
if (nextSub === null) {
|
|
731
|
+
dep._unobserved?.();
|
|
732
|
+
dep._fn && !dep._preventAutoDisposal && !(dep._flags & REACTIVE_ZOMBIE) && unobserved(dep);
|
|
734
733
|
}
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
node._effectFn = effect;
|
|
738
|
-
node._errorFn = error;
|
|
739
|
-
node._cleanup = undefined;
|
|
740
|
-
node._type = options?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
741
|
-
node._notifyStatus = (status, error) => {
|
|
742
|
-
const actualStatus = status !== undefined ? status : node._statusFlags;
|
|
743
|
-
const actualError = error !== undefined ? error : node._error;
|
|
744
|
-
if (actualStatus & STATUS_ERROR) {
|
|
745
|
-
let err = actualError;
|
|
746
|
-
node._queue.notify(node, STATUS_PENDING, 0);
|
|
747
|
-
if (node._type === EFFECT_USER) {
|
|
748
|
-
try {
|
|
749
|
-
return node._errorFn
|
|
750
|
-
? node._errorFn(err, () => {
|
|
751
|
-
node._cleanup?.();
|
|
752
|
-
node._cleanup = undefined;
|
|
753
|
-
})
|
|
754
|
-
: console.error(err);
|
|
755
|
-
} catch (e) {
|
|
756
|
-
err = e;
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
if (!node._queue.notify(node, STATUS_ERROR, STATUS_ERROR)) throw err;
|
|
760
|
-
} else if (node._type === EFFECT_RENDER)
|
|
761
|
-
node._queue.notify(node, STATUS_PENDING | STATUS_ERROR, actualStatus, actualError);
|
|
762
|
-
};
|
|
763
|
-
recompute(node, true);
|
|
764
|
-
!options?.defer &&
|
|
765
|
-
(node._type === EFFECT_USER
|
|
766
|
-
? node._queue.enqueue(node._type, runEffect.bind(node))
|
|
767
|
-
: runEffect.call(node));
|
|
768
|
-
initialized = true;
|
|
769
|
-
onCleanup(() => node._cleanup?.());
|
|
770
|
-
if (!node._parent)
|
|
771
|
-
console.warn("Effects created outside a reactive context will never be disposed");
|
|
734
|
+
}
|
|
735
|
+
return nextDep;
|
|
772
736
|
}
|
|
773
|
-
function
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
this._cleanup = this._effectFn(this._value, this._prevValue);
|
|
779
|
-
} catch (error) {
|
|
780
|
-
if (!this._queue.notify(this, STATUS_ERROR, STATUS_ERROR)) throw error;
|
|
781
|
-
} finally {
|
|
782
|
-
this._prevValue = this._value;
|
|
783
|
-
this._modified = false;
|
|
737
|
+
function unobserved(el) {
|
|
738
|
+
deleteFromHeap(el, el._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
739
|
+
let dep = el._deps;
|
|
740
|
+
while (dep !== null) {
|
|
741
|
+
dep = unlinkSubs(dep);
|
|
784
742
|
}
|
|
743
|
+
el._deps = null;
|
|
744
|
+
disposeChildren(el, true);
|
|
785
745
|
}
|
|
786
|
-
function
|
|
787
|
-
const
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
()
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
);
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
if (
|
|
813
|
-
|
|
746
|
+
function link(dep, sub) {
|
|
747
|
+
const prevDep = sub._depsTail;
|
|
748
|
+
if (prevDep !== null && prevDep._dep === dep) return;
|
|
749
|
+
let nextDep = null;
|
|
750
|
+
const isRecomputing = sub._flags & REACTIVE_RECOMPUTING_DEPS;
|
|
751
|
+
if (isRecomputing) {
|
|
752
|
+
nextDep = prevDep !== null ? prevDep._nextDep : sub._deps;
|
|
753
|
+
if (nextDep !== null && nextDep._dep === dep) {
|
|
754
|
+
sub._depsTail = nextDep;
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
const prevSub = dep._subsTail;
|
|
759
|
+
if (prevSub !== null && prevSub._sub === sub && (!isRecomputing || isValidLink(prevSub, sub)))
|
|
760
|
+
return;
|
|
761
|
+
const newLink =
|
|
762
|
+
(sub._depsTail =
|
|
763
|
+
dep._subsTail =
|
|
764
|
+
{ _dep: dep, _sub: sub, _nextDep: nextDep, _prevSub: prevSub, _nextSub: null });
|
|
765
|
+
if (prevDep !== null) prevDep._nextDep = newLink;
|
|
766
|
+
else sub._deps = newLink;
|
|
767
|
+
if (prevSub !== null) prevSub._nextSub = newLink;
|
|
768
|
+
else dep._subs = newLink;
|
|
769
|
+
}
|
|
770
|
+
function isValidLink(checkLink, sub) {
|
|
771
|
+
const depsTail = sub._depsTail;
|
|
772
|
+
if (depsTail !== null) {
|
|
773
|
+
let link = sub._deps;
|
|
774
|
+
do {
|
|
775
|
+
if (link === checkLink) return true;
|
|
776
|
+
if (link === depsTail) break;
|
|
777
|
+
link = link._nextDep;
|
|
778
|
+
} while (link !== null);
|
|
779
|
+
}
|
|
780
|
+
return false;
|
|
814
781
|
}
|
|
815
782
|
const PENDING_OWNER = {};
|
|
816
783
|
function markDisposal(el) {
|
|
@@ -875,12 +842,19 @@ function runDisposal(node, zombie) {
|
|
|
875
842
|
}
|
|
876
843
|
zombie ? (node._pendingDisposal = null) : (node._disposal = null);
|
|
877
844
|
}
|
|
878
|
-
function
|
|
845
|
+
function childId(owner, consume) {
|
|
879
846
|
let counter = owner;
|
|
880
847
|
while (counter._transparent && counter._parent) counter = counter._parent;
|
|
881
|
-
if (counter.id != null)
|
|
848
|
+
if (counter.id != null)
|
|
849
|
+
return formatId(counter.id, consume ? counter._childCount++ : counter._childCount);
|
|
882
850
|
throw new Error("Cannot get child id from owner without an id");
|
|
883
851
|
}
|
|
852
|
+
function getNextChildId(owner) {
|
|
853
|
+
return childId(owner, true);
|
|
854
|
+
}
|
|
855
|
+
function peekNextChildId(owner) {
|
|
856
|
+
return childId(owner, false);
|
|
857
|
+
}
|
|
884
858
|
function formatId(prefix, id) {
|
|
885
859
|
const num = id.toString(36),
|
|
886
860
|
len = num.length - 1;
|
|
@@ -941,67 +915,100 @@ function createRoot(init, options) {
|
|
|
941
915
|
const owner = createOwner(options);
|
|
942
916
|
return runWithOwner(owner, () => init(owner.dispose));
|
|
943
917
|
}
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
const
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
918
|
+
let leafEffectActive = false;
|
|
919
|
+
function effect(compute, effect, error, initialValue, options) {
|
|
920
|
+
let initialized = false;
|
|
921
|
+
const node = computed(
|
|
922
|
+
options?.render ? p => staleValues(() => compute(p)) : compute,
|
|
923
|
+
initialValue,
|
|
924
|
+
{
|
|
925
|
+
...options,
|
|
926
|
+
equals: () => {
|
|
927
|
+
node._modified = !node._error;
|
|
928
|
+
if (initialized) node._queue.enqueue(node._type, runEffect.bind(node));
|
|
929
|
+
return false;
|
|
930
|
+
},
|
|
931
|
+
lazy: true
|
|
957
932
|
}
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
933
|
+
);
|
|
934
|
+
node._prevValue = initialValue;
|
|
935
|
+
node._effectFn = effect;
|
|
936
|
+
node._errorFn = error;
|
|
937
|
+
node._cleanup = undefined;
|
|
938
|
+
node._type = options?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
939
|
+
node._notifyStatus = (status, error) => {
|
|
940
|
+
const actualStatus = status !== undefined ? status : node._statusFlags;
|
|
941
|
+
const actualError = error !== undefined ? error : node._error;
|
|
942
|
+
if (actualStatus & STATUS_ERROR) {
|
|
943
|
+
let err = actualError;
|
|
944
|
+
node._queue.notify(node, STATUS_PENDING, 0);
|
|
945
|
+
if (node._type === EFFECT_USER) {
|
|
946
|
+
try {
|
|
947
|
+
return node._errorFn
|
|
948
|
+
? node._errorFn(err, () => {
|
|
949
|
+
node._cleanup?.();
|
|
950
|
+
node._cleanup = undefined;
|
|
951
|
+
})
|
|
952
|
+
: console.error(err);
|
|
953
|
+
} catch (e) {
|
|
954
|
+
err = e;
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
if (!node._queue.notify(node, STATUS_ERROR, STATUS_ERROR)) throw err;
|
|
958
|
+
} else if (node._type === EFFECT_RENDER)
|
|
959
|
+
node._queue.notify(node, STATUS_PENDING | STATUS_ERROR, actualStatus, actualError);
|
|
960
|
+
};
|
|
961
|
+
recompute(node, true);
|
|
962
|
+
!options?.defer &&
|
|
963
|
+
(node._type === EFFECT_USER
|
|
964
|
+
? node._queue.enqueue(node._type, runEffect.bind(node))
|
|
965
|
+
: runEffect.call(node));
|
|
966
|
+
initialized = true;
|
|
967
|
+
onCleanup(() => node._cleanup?.());
|
|
968
|
+
if (!node._parent)
|
|
969
|
+
console.warn("Effects created outside a reactive context will never be disposed");
|
|
969
970
|
}
|
|
970
|
-
function
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
if (
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
971
|
+
function runEffect() {
|
|
972
|
+
if (!this._modified || this._flags & REACTIVE_DISPOSED) return;
|
|
973
|
+
this._cleanup?.();
|
|
974
|
+
this._cleanup = undefined;
|
|
975
|
+
try {
|
|
976
|
+
this._cleanup = this._effectFn(this._value, this._prevValue);
|
|
977
|
+
} catch (error) {
|
|
978
|
+
if (!this._queue.notify(this, STATUS_ERROR, STATUS_ERROR)) throw error;
|
|
979
|
+
} finally {
|
|
980
|
+
this._prevValue = this._value;
|
|
981
|
+
this._modified = false;
|
|
981
982
|
}
|
|
982
|
-
const prevSub = dep._subsTail;
|
|
983
|
-
if (prevSub !== null && prevSub._sub === sub && (!isRecomputing || isValidLink(prevSub, sub)))
|
|
984
|
-
return;
|
|
985
|
-
const newLink =
|
|
986
|
-
(sub._depsTail =
|
|
987
|
-
dep._subsTail =
|
|
988
|
-
{ _dep: dep, _sub: sub, _nextDep: nextDep, _prevSub: prevSub, _nextSub: null });
|
|
989
|
-
if (prevDep !== null) prevDep._nextDep = newLink;
|
|
990
|
-
else sub._deps = newLink;
|
|
991
|
-
if (prevSub !== null) prevSub._nextSub = newLink;
|
|
992
|
-
else dep._subs = newLink;
|
|
993
983
|
}
|
|
994
|
-
function
|
|
995
|
-
const
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
984
|
+
function trackedEffect(fn, options) {
|
|
985
|
+
const run = () => {
|
|
986
|
+
if (!node._modified || node._flags & REACTIVE_DISPOSED) return;
|
|
987
|
+
node._modified = false;
|
|
988
|
+
recompute(node);
|
|
989
|
+
};
|
|
990
|
+
const node = computed(
|
|
991
|
+
() => {
|
|
992
|
+
leafEffectActive = true;
|
|
993
|
+
try {
|
|
994
|
+
node._cleanup?.();
|
|
995
|
+
node._cleanup = undefined;
|
|
996
|
+
node._cleanup = staleValues(fn) || undefined;
|
|
997
|
+
} finally {
|
|
998
|
+
leafEffectActive = false;
|
|
999
|
+
}
|
|
1000
|
+
},
|
|
1001
|
+
undefined,
|
|
1002
|
+
{ ...options, lazy: true, pureWrite: true }
|
|
1003
|
+
);
|
|
1004
|
+
node._cleanup = undefined;
|
|
1005
|
+
node._modified = true;
|
|
1006
|
+
node._type = EFFECT_TRACKED;
|
|
1007
|
+
node._run = run;
|
|
1008
|
+
node._queue.enqueue(EFFECT_USER, run);
|
|
1009
|
+
onCleanup(() => node._cleanup?.());
|
|
1010
|
+
if (!node._parent)
|
|
1011
|
+
console.warn("Effects created outside a reactive context will never be disposed");
|
|
1005
1012
|
}
|
|
1006
1013
|
GlobalQueue._update = recompute;
|
|
1007
1014
|
GlobalQueue._dispose = disposeChildren;
|
|
@@ -2902,6 +2909,7 @@ export {
|
|
|
2902
2909
|
omit,
|
|
2903
2910
|
onCleanup,
|
|
2904
2911
|
onSettled,
|
|
2912
|
+
peekNextChildId,
|
|
2905
2913
|
pending,
|
|
2906
2914
|
reconcile,
|
|
2907
2915
|
refresh,
|