@legendapp/state 3.0.0-beta.47 → 3.0.0-beta.48
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/README.md +2 -1
- package/config/enableReactNativeComponents.js +2 -4
- package/config/enableReactNativeComponents.mjs +3 -5
- package/helpers/undoRedo.js +1 -2
- package/helpers/undoRedo.mjs +1 -2
- package/index.d.mts +2 -0
- package/index.d.ts +2 -0
- package/index.js +42 -10
- package/index.mjs +42 -10
- package/package.json +1 -1
- package/react-hooks/createObservableHook.js +15 -4
- package/react-hooks/createObservableHook.mjs +15 -4
- package/react-native.js +2 -4
- package/react-native.mjs +3 -5
- package/react-reactive/Components.js +2 -4
- package/react-reactive/Components.mjs +3 -5
- package/react-reactive/enableReactNativeComponents.js +2 -5
- package/react-reactive/enableReactNativeComponents.mjs +2 -5
- package/react-reactive/enableReactive.native.js +2 -5
- package/react-reactive/enableReactive.native.mjs +2 -5
- package/react-reactive/enableReactive.web.js +2 -5
- package/react-reactive/enableReactive.web.mjs +2 -5
- package/react.js +102 -60
- package/react.mjs +103 -61
- package/sync-plugins/crud.js +32 -5
- package/sync-plugins/crud.mjs +32 -5
- package/sync.js +17 -4
- package/sync.mjs +17 -4
- package/.DS_Store +0 -0
package/sync.js
CHANGED
|
@@ -249,6 +249,12 @@ function createRevertChanges(obs$, changes) {
|
|
|
249
249
|
};
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
+
// src/onChange.ts
|
|
253
|
+
function markNodeAsSynced(node) {
|
|
254
|
+
const activationState = node.activationState || (node.activationState = {});
|
|
255
|
+
activationState.synced = true;
|
|
256
|
+
}
|
|
257
|
+
|
|
252
258
|
// src/sync/syncObservable.ts
|
|
253
259
|
var {
|
|
254
260
|
clone: clone2,
|
|
@@ -715,11 +721,12 @@ async function doChangeRemote(changeInfo) {
|
|
|
715
721
|
onError: onSetError,
|
|
716
722
|
update: (params) => {
|
|
717
723
|
if (updateResult) {
|
|
718
|
-
const { value: value2, mode, changes } = params;
|
|
724
|
+
const { value: value2, mode, changes, failedChanges } = params;
|
|
719
725
|
updateResult = {
|
|
720
726
|
value: deepMerge(updateResult.value, value2),
|
|
721
727
|
mode,
|
|
722
|
-
changes: changes ? [...updateResult.changes || [], ...changes] : updateResult.changes
|
|
728
|
+
changes: changes ? [...updateResult.changes || [], ...changes] : updateResult.changes,
|
|
729
|
+
failedChanges: failedChanges ? [...updateResult.failedChanges || [], ...failedChanges] : updateResult.failedChanges
|
|
723
730
|
};
|
|
724
731
|
} else {
|
|
725
732
|
updateResult = params;
|
|
@@ -742,7 +749,11 @@ async function doChangeRemote(changeInfo) {
|
|
|
742
749
|
});
|
|
743
750
|
}
|
|
744
751
|
if (!didError || (updateResult == null ? void 0 : updateResult.changes)) {
|
|
745
|
-
const {
|
|
752
|
+
const {
|
|
753
|
+
value: updateValue,
|
|
754
|
+
changes: updateChanges = changesRemote,
|
|
755
|
+
failedChanges = []
|
|
756
|
+
} = updateResult || {};
|
|
746
757
|
const changesWithPath = updateChanges;
|
|
747
758
|
const pathStrs = Array.from(new Set(changesWithPath.map((change) => change.pathStr)));
|
|
748
759
|
if (pathStrs.length > 0) {
|
|
@@ -750,6 +761,7 @@ async function doChangeRemote(changeInfo) {
|
|
|
750
761
|
const metadata = {};
|
|
751
762
|
const pending = localState.pendingChanges;
|
|
752
763
|
const pendingToKeep = /* @__PURE__ */ new Set();
|
|
764
|
+
const failedPathStrs = new Set(failedChanges.map((change) => change.pathStr));
|
|
753
765
|
if (pending) {
|
|
754
766
|
const changesByPath = /* @__PURE__ */ new Map();
|
|
755
767
|
for (let i = 0; i < changesWithPath.length; i++) {
|
|
@@ -762,7 +774,7 @@ async function doChangeRemote(changeInfo) {
|
|
|
762
774
|
continue;
|
|
763
775
|
}
|
|
764
776
|
const change = changesByPath.get(key);
|
|
765
|
-
if (!change || !deepEqual(pendingEntry.v, change.valueAtPath)) {
|
|
777
|
+
if (failedPathStrs.has(key) || !change || !deepEqual(pendingEntry.v, change.valueAtPath)) {
|
|
766
778
|
pendingToKeep.add(key);
|
|
767
779
|
}
|
|
768
780
|
}
|
|
@@ -996,6 +1008,7 @@ function syncObservable(obs$, syncOptionsOrSynced) {
|
|
|
996
1008
|
if ((process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test") && (!obs$ || !node)) {
|
|
997
1009
|
throw new Error("[legend-state] syncObservable called with undefined observable");
|
|
998
1010
|
}
|
|
1011
|
+
markNodeAsSynced(node);
|
|
999
1012
|
syncOptions = deepMerge(
|
|
1000
1013
|
{
|
|
1001
1014
|
syncMode: "auto"
|
package/sync.mjs
CHANGED
|
@@ -247,6 +247,12 @@ function createRevertChanges(obs$, changes) {
|
|
|
247
247
|
};
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
+
// src/onChange.ts
|
|
251
|
+
function markNodeAsSynced(node) {
|
|
252
|
+
const activationState = node.activationState || (node.activationState = {});
|
|
253
|
+
activationState.synced = true;
|
|
254
|
+
}
|
|
255
|
+
|
|
250
256
|
// src/sync/syncObservable.ts
|
|
251
257
|
var {
|
|
252
258
|
clone: clone2,
|
|
@@ -713,11 +719,12 @@ async function doChangeRemote(changeInfo) {
|
|
|
713
719
|
onError: onSetError,
|
|
714
720
|
update: (params) => {
|
|
715
721
|
if (updateResult) {
|
|
716
|
-
const { value: value2, mode, changes } = params;
|
|
722
|
+
const { value: value2, mode, changes, failedChanges } = params;
|
|
717
723
|
updateResult = {
|
|
718
724
|
value: deepMerge(updateResult.value, value2),
|
|
719
725
|
mode,
|
|
720
|
-
changes: changes ? [...updateResult.changes || [], ...changes] : updateResult.changes
|
|
726
|
+
changes: changes ? [...updateResult.changes || [], ...changes] : updateResult.changes,
|
|
727
|
+
failedChanges: failedChanges ? [...updateResult.failedChanges || [], ...failedChanges] : updateResult.failedChanges
|
|
721
728
|
};
|
|
722
729
|
} else {
|
|
723
730
|
updateResult = params;
|
|
@@ -740,7 +747,11 @@ async function doChangeRemote(changeInfo) {
|
|
|
740
747
|
});
|
|
741
748
|
}
|
|
742
749
|
if (!didError || (updateResult == null ? void 0 : updateResult.changes)) {
|
|
743
|
-
const {
|
|
750
|
+
const {
|
|
751
|
+
value: updateValue,
|
|
752
|
+
changes: updateChanges = changesRemote,
|
|
753
|
+
failedChanges = []
|
|
754
|
+
} = updateResult || {};
|
|
744
755
|
const changesWithPath = updateChanges;
|
|
745
756
|
const pathStrs = Array.from(new Set(changesWithPath.map((change) => change.pathStr)));
|
|
746
757
|
if (pathStrs.length > 0) {
|
|
@@ -748,6 +759,7 @@ async function doChangeRemote(changeInfo) {
|
|
|
748
759
|
const metadata = {};
|
|
749
760
|
const pending = localState.pendingChanges;
|
|
750
761
|
const pendingToKeep = /* @__PURE__ */ new Set();
|
|
762
|
+
const failedPathStrs = new Set(failedChanges.map((change) => change.pathStr));
|
|
751
763
|
if (pending) {
|
|
752
764
|
const changesByPath = /* @__PURE__ */ new Map();
|
|
753
765
|
for (let i = 0; i < changesWithPath.length; i++) {
|
|
@@ -760,7 +772,7 @@ async function doChangeRemote(changeInfo) {
|
|
|
760
772
|
continue;
|
|
761
773
|
}
|
|
762
774
|
const change = changesByPath.get(key);
|
|
763
|
-
if (!change || !deepEqual(pendingEntry.v, change.valueAtPath)) {
|
|
775
|
+
if (failedPathStrs.has(key) || !change || !deepEqual(pendingEntry.v, change.valueAtPath)) {
|
|
764
776
|
pendingToKeep.add(key);
|
|
765
777
|
}
|
|
766
778
|
}
|
|
@@ -994,6 +1006,7 @@ function syncObservable(obs$, syncOptionsOrSynced) {
|
|
|
994
1006
|
if ((process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test") && (!obs$ || !node)) {
|
|
995
1007
|
throw new Error("[legend-state] syncObservable called with undefined observable");
|
|
996
1008
|
}
|
|
1009
|
+
markNodeAsSynced(node);
|
|
997
1010
|
syncOptions = deepMerge(
|
|
998
1011
|
{
|
|
999
1012
|
syncMode: "auto"
|
package/.DS_Store
DELETED
|
Binary file
|