@legendapp/state 3.0.0-beta.38 → 3.0.0-beta.39
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/index.js +47 -38
- package/index.mjs +47 -38
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -291,6 +291,14 @@ var ObservableHint = {
|
|
|
291
291
|
}
|
|
292
292
|
};
|
|
293
293
|
|
|
294
|
+
// src/checkPlain.ts
|
|
295
|
+
function checkPlain(node, value) {
|
|
296
|
+
var _a;
|
|
297
|
+
if (!node.isPlain && (((_a = node.parent) == null ? void 0 : _a.isPlain) || isHintPlain(value))) {
|
|
298
|
+
node.isPlain = true;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
294
302
|
// src/helpers.ts
|
|
295
303
|
function computeSelector(selector, getOptions, e, retainObservable) {
|
|
296
304
|
let c = selector;
|
|
@@ -617,37 +625,39 @@ function computeChangesAtNode(changesInBatch, node, isFromPersist, isFromSync, v
|
|
|
617
625
|
}
|
|
618
626
|
}
|
|
619
627
|
function computeChangesRecursive(changesInBatch, node, loading, remote, value, path, pathTypes, valueAtPath, prevAtPath, immediate, level, whenOptimizedOnlyIf) {
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
const
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
628
|
+
if (node.numListenersRecursive > 0) {
|
|
629
|
+
computeChangesAtNode(
|
|
630
|
+
changesInBatch,
|
|
631
|
+
node,
|
|
632
|
+
loading,
|
|
633
|
+
remote,
|
|
634
|
+
value,
|
|
635
|
+
path,
|
|
636
|
+
pathTypes,
|
|
637
|
+
valueAtPath,
|
|
638
|
+
prevAtPath,
|
|
639
|
+
immediate,
|
|
640
|
+
level,
|
|
641
|
+
whenOptimizedOnlyIf
|
|
642
|
+
);
|
|
643
|
+
if (node.linkedFromNodes) {
|
|
644
|
+
for (const linkedFromNode of node.linkedFromNodes) {
|
|
645
|
+
const childNode = getNodeAtPath(linkedFromNode, path);
|
|
646
|
+
computeChangesRecursive(
|
|
647
|
+
changesInBatch,
|
|
648
|
+
childNode,
|
|
649
|
+
loading,
|
|
650
|
+
remote,
|
|
651
|
+
valueAtPath,
|
|
652
|
+
[],
|
|
653
|
+
[],
|
|
654
|
+
valueAtPath,
|
|
655
|
+
prevAtPath,
|
|
656
|
+
immediate,
|
|
657
|
+
0,
|
|
658
|
+
whenOptimizedOnlyIf
|
|
659
|
+
);
|
|
660
|
+
}
|
|
651
661
|
}
|
|
652
662
|
}
|
|
653
663
|
if (node.parent) {
|
|
@@ -1712,6 +1722,7 @@ function setKey(node, key, newValue, level) {
|
|
|
1712
1722
|
}
|
|
1713
1723
|
}
|
|
1714
1724
|
const isRoot = !node.parent && key === "_";
|
|
1725
|
+
checkPlain(node, newValue);
|
|
1715
1726
|
if (node.parent && !getNodeValue(node) && !isFunction(newValue)) {
|
|
1716
1727
|
set(node, { [key]: newValue });
|
|
1717
1728
|
}
|
|
@@ -1729,8 +1740,8 @@ function setKey(node, key, newValue, level) {
|
|
|
1729
1740
|
} while (parent = parent.parent);
|
|
1730
1741
|
}
|
|
1731
1742
|
const notify2 = !equals(savedValue, prevValue);
|
|
1732
|
-
const forceNotify = !notify2 && childNode.isComputing && !isPrim;
|
|
1733
|
-
if (notify2 || forceNotify) {
|
|
1743
|
+
const forceNotify = !notify2 && childNode.isComputing && !isPrim && !childNode.isPlain;
|
|
1744
|
+
if ((notify2 || forceNotify) && !(childNode.isComputing && childNode.isPlain && node.numListenersRecursive === 0)) {
|
|
1734
1745
|
updateNodesAndNotify(
|
|
1735
1746
|
node,
|
|
1736
1747
|
savedValue,
|
|
@@ -1946,7 +1957,7 @@ function peek(node) {
|
|
|
1946
1957
|
}
|
|
1947
1958
|
var isFlushing = false;
|
|
1948
1959
|
function peekInternal(node, activateRecursive) {
|
|
1949
|
-
var _a
|
|
1960
|
+
var _a;
|
|
1950
1961
|
isFlushing = true;
|
|
1951
1962
|
if (activateRecursive && ((_a = node.dirtyChildren) == null ? void 0 : _a.size)) {
|
|
1952
1963
|
const dirty = Array.from(node.dirtyChildren);
|
|
@@ -1961,9 +1972,6 @@ function peekInternal(node, activateRecursive) {
|
|
|
1961
1972
|
}
|
|
1962
1973
|
isFlushing = false;
|
|
1963
1974
|
let value = getNodeValue(node);
|
|
1964
|
-
if (((_b = node.parent) == null ? void 0 : _b.isPlain) || isHintPlain(value)) {
|
|
1965
|
-
node.isPlain = true;
|
|
1966
|
-
}
|
|
1967
1975
|
if (!node.root.isLoadingLocal && !node.isPlain) {
|
|
1968
1976
|
value = checkLazy(node, value, !!activateRecursive);
|
|
1969
1977
|
}
|
|
@@ -1995,7 +2003,8 @@ function checkLazy(node, value, activateRecursive) {
|
|
|
1995
2003
|
value = extractFunctionOrComputed(node.parent, node.key, value);
|
|
1996
2004
|
}
|
|
1997
2005
|
}
|
|
1998
|
-
|
|
2006
|
+
checkPlain(node, value);
|
|
2007
|
+
if ((lazy || node.needsExtract) && !node.isPlain && !isObservable(value) && !isPrimitive(value)) {
|
|
1999
2008
|
if (activateRecursive) {
|
|
2000
2009
|
recursivelyAutoActivate(value, node);
|
|
2001
2010
|
}
|
package/index.mjs
CHANGED
|
@@ -289,6 +289,14 @@ var ObservableHint = {
|
|
|
289
289
|
}
|
|
290
290
|
};
|
|
291
291
|
|
|
292
|
+
// src/checkPlain.ts
|
|
293
|
+
function checkPlain(node, value) {
|
|
294
|
+
var _a;
|
|
295
|
+
if (!node.isPlain && (((_a = node.parent) == null ? void 0 : _a.isPlain) || isHintPlain(value))) {
|
|
296
|
+
node.isPlain = true;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
292
300
|
// src/helpers.ts
|
|
293
301
|
function computeSelector(selector, getOptions, e, retainObservable) {
|
|
294
302
|
let c = selector;
|
|
@@ -615,37 +623,39 @@ function computeChangesAtNode(changesInBatch, node, isFromPersist, isFromSync, v
|
|
|
615
623
|
}
|
|
616
624
|
}
|
|
617
625
|
function computeChangesRecursive(changesInBatch, node, loading, remote, value, path, pathTypes, valueAtPath, prevAtPath, immediate, level, whenOptimizedOnlyIf) {
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
const
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
626
|
+
if (node.numListenersRecursive > 0) {
|
|
627
|
+
computeChangesAtNode(
|
|
628
|
+
changesInBatch,
|
|
629
|
+
node,
|
|
630
|
+
loading,
|
|
631
|
+
remote,
|
|
632
|
+
value,
|
|
633
|
+
path,
|
|
634
|
+
pathTypes,
|
|
635
|
+
valueAtPath,
|
|
636
|
+
prevAtPath,
|
|
637
|
+
immediate,
|
|
638
|
+
level,
|
|
639
|
+
whenOptimizedOnlyIf
|
|
640
|
+
);
|
|
641
|
+
if (node.linkedFromNodes) {
|
|
642
|
+
for (const linkedFromNode of node.linkedFromNodes) {
|
|
643
|
+
const childNode = getNodeAtPath(linkedFromNode, path);
|
|
644
|
+
computeChangesRecursive(
|
|
645
|
+
changesInBatch,
|
|
646
|
+
childNode,
|
|
647
|
+
loading,
|
|
648
|
+
remote,
|
|
649
|
+
valueAtPath,
|
|
650
|
+
[],
|
|
651
|
+
[],
|
|
652
|
+
valueAtPath,
|
|
653
|
+
prevAtPath,
|
|
654
|
+
immediate,
|
|
655
|
+
0,
|
|
656
|
+
whenOptimizedOnlyIf
|
|
657
|
+
);
|
|
658
|
+
}
|
|
649
659
|
}
|
|
650
660
|
}
|
|
651
661
|
if (node.parent) {
|
|
@@ -1710,6 +1720,7 @@ function setKey(node, key, newValue, level) {
|
|
|
1710
1720
|
}
|
|
1711
1721
|
}
|
|
1712
1722
|
const isRoot = !node.parent && key === "_";
|
|
1723
|
+
checkPlain(node, newValue);
|
|
1713
1724
|
if (node.parent && !getNodeValue(node) && !isFunction(newValue)) {
|
|
1714
1725
|
set(node, { [key]: newValue });
|
|
1715
1726
|
}
|
|
@@ -1727,8 +1738,8 @@ function setKey(node, key, newValue, level) {
|
|
|
1727
1738
|
} while (parent = parent.parent);
|
|
1728
1739
|
}
|
|
1729
1740
|
const notify2 = !equals(savedValue, prevValue);
|
|
1730
|
-
const forceNotify = !notify2 && childNode.isComputing && !isPrim;
|
|
1731
|
-
if (notify2 || forceNotify) {
|
|
1741
|
+
const forceNotify = !notify2 && childNode.isComputing && !isPrim && !childNode.isPlain;
|
|
1742
|
+
if ((notify2 || forceNotify) && !(childNode.isComputing && childNode.isPlain && node.numListenersRecursive === 0)) {
|
|
1732
1743
|
updateNodesAndNotify(
|
|
1733
1744
|
node,
|
|
1734
1745
|
savedValue,
|
|
@@ -1944,7 +1955,7 @@ function peek(node) {
|
|
|
1944
1955
|
}
|
|
1945
1956
|
var isFlushing = false;
|
|
1946
1957
|
function peekInternal(node, activateRecursive) {
|
|
1947
|
-
var _a
|
|
1958
|
+
var _a;
|
|
1948
1959
|
isFlushing = true;
|
|
1949
1960
|
if (activateRecursive && ((_a = node.dirtyChildren) == null ? void 0 : _a.size)) {
|
|
1950
1961
|
const dirty = Array.from(node.dirtyChildren);
|
|
@@ -1959,9 +1970,6 @@ function peekInternal(node, activateRecursive) {
|
|
|
1959
1970
|
}
|
|
1960
1971
|
isFlushing = false;
|
|
1961
1972
|
let value = getNodeValue(node);
|
|
1962
|
-
if (((_b = node.parent) == null ? void 0 : _b.isPlain) || isHintPlain(value)) {
|
|
1963
|
-
node.isPlain = true;
|
|
1964
|
-
}
|
|
1965
1973
|
if (!node.root.isLoadingLocal && !node.isPlain) {
|
|
1966
1974
|
value = checkLazy(node, value, !!activateRecursive);
|
|
1967
1975
|
}
|
|
@@ -1993,7 +2001,8 @@ function checkLazy(node, value, activateRecursive) {
|
|
|
1993
2001
|
value = extractFunctionOrComputed(node.parent, node.key, value);
|
|
1994
2002
|
}
|
|
1995
2003
|
}
|
|
1996
|
-
|
|
2004
|
+
checkPlain(node, value);
|
|
2005
|
+
if ((lazy || node.needsExtract) && !node.isPlain && !isObservable(value) && !isPrimitive(value)) {
|
|
1997
2006
|
if (activateRecursive) {
|
|
1998
2007
|
recursivelyAutoActivate(value, node);
|
|
1999
2008
|
}
|