@overmap-ai/core 1.0.53-fix-outbox.3 → 1.0.53-fix-outbox.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/overmap-core.js +43 -19
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +43 -19
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/store/store.d.ts +2 -1
- package/package.json +1 -1
|
@@ -4534,6 +4534,8 @@ var __publicField = (obj, key, value) => {
|
|
|
4534
4534
|
function getClientStore() {
|
|
4535
4535
|
return clientStore;
|
|
4536
4536
|
}
|
|
4537
|
+
const useAppDispatch = () => reactRedux.useDispatch();
|
|
4538
|
+
const useAppSelector = reactRedux.useSelector;
|
|
4537
4539
|
const VERSION_REDUCER_KEY = "versioning";
|
|
4538
4540
|
const overmapReducers = {
|
|
4539
4541
|
// TODO: attachmentReducer,
|
|
@@ -4630,21 +4632,38 @@ var __publicField = (obj, key, value) => {
|
|
|
4630
4632
|
}
|
|
4631
4633
|
return overmapReducer(mutatedState, action);
|
|
4632
4634
|
};
|
|
4633
|
-
let
|
|
4634
|
-
|
|
4635
|
-
|
|
4635
|
+
let __resolveOutboxCoordinator = null;
|
|
4636
|
+
let __outboxCoordinator = null;
|
|
4637
|
+
const __OUTBOX_COORDINATOR_PROMISE = new Promise((resolve) => {
|
|
4638
|
+
__resolveOutboxCoordinator = resolve;
|
|
4639
|
+
}).then((coordinator) => {
|
|
4640
|
+
__outboxCoordinator = coordinator;
|
|
4641
|
+
return coordinator;
|
|
4642
|
+
});
|
|
4643
|
+
async function getOutboxCoordinator() {
|
|
4644
|
+
return await __OUTBOX_COORDINATOR_PROMISE;
|
|
4645
|
+
}
|
|
4646
|
+
const useOutboxCoordinator = () => {
|
|
4647
|
+
const [coordinator, setCoordinator] = React.useState(null);
|
|
4648
|
+
const rehydrated = useAppSelector(selectRehydrated);
|
|
4649
|
+
React.useEffect(() => {
|
|
4650
|
+
if (!rehydrated) {
|
|
4651
|
+
return;
|
|
4652
|
+
}
|
|
4636
4653
|
const clientStore2 = getClientStore();
|
|
4637
4654
|
if (!clientStore2) {
|
|
4638
|
-
|
|
4639
|
-
"Cannot reload outbox because there is no client store yet. If there is an outbox, it will be broken."
|
|
4640
|
-
);
|
|
4641
|
-
return new OutboxCoordinator();
|
|
4655
|
+
throw new Error("Client store not set");
|
|
4642
4656
|
}
|
|
4643
4657
|
const outbox = clientStore2.getState().offline.outbox;
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4658
|
+
const coordinator2 = OutboxCoordinator._fromOutbox(outbox);
|
|
4659
|
+
setCoordinator(coordinator2);
|
|
4660
|
+
if (!__resolveOutboxCoordinator) {
|
|
4661
|
+
throw new Error("Outbox coordinator promise resolver not set");
|
|
4662
|
+
}
|
|
4663
|
+
__resolveOutboxCoordinator(coordinator2);
|
|
4664
|
+
}, [rehydrated]);
|
|
4665
|
+
return coordinator;
|
|
4666
|
+
};
|
|
4648
4667
|
const persistCallback = (err) => {
|
|
4649
4668
|
if (err)
|
|
4650
4669
|
throw err;
|
|
@@ -4656,12 +4675,18 @@ var __publicField = (obj, key, value) => {
|
|
|
4656
4675
|
}
|
|
4657
4676
|
};
|
|
4658
4677
|
const enqueue = (_array, item, _context) => {
|
|
4659
|
-
const coordinator =
|
|
4678
|
+
const coordinator = __outboxCoordinator;
|
|
4679
|
+
if (!coordinator) {
|
|
4680
|
+
throw new Error("Outbox coordinator not set");
|
|
4681
|
+
}
|
|
4660
4682
|
coordinator.addRequest(item);
|
|
4661
4683
|
return coordinator.getQueue();
|
|
4662
4684
|
};
|
|
4663
4685
|
const dequeue = (_array, item, _context) => {
|
|
4664
|
-
const coordinator =
|
|
4686
|
+
const coordinator = __outboxCoordinator;
|
|
4687
|
+
if (!coordinator) {
|
|
4688
|
+
throw new Error("Outbox coordinator not set");
|
|
4689
|
+
}
|
|
4665
4690
|
const meta = item.meta;
|
|
4666
4691
|
const uuid2 = meta.offlineAction.payload.uuid;
|
|
4667
4692
|
coordinator.remove(uuid2);
|
|
@@ -4953,7 +4978,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4953
4978
|
const uuid2 = action.payload.uuid;
|
|
4954
4979
|
function rollbackAndThrow() {
|
|
4955
4980
|
clientStore2.dispatch(markAsDeleted(uuid2));
|
|
4956
|
-
|
|
4981
|
+
__outboxCoordinator.remove(action.payload.uuid);
|
|
4957
4982
|
const rollbackAction = action.meta.offline.rollback;
|
|
4958
4983
|
if (rollbackAction) {
|
|
4959
4984
|
console.warn("Rolling back request due to SDK error:", action);
|
|
@@ -4984,24 +5009,22 @@ var __publicField = (obj, key, value) => {
|
|
|
4984
5009
|
console.error(`Could not display toast for status ${status} because there is no toast handle.`);
|
|
4985
5010
|
}
|
|
4986
5011
|
}
|
|
4987
|
-
|
|
5012
|
+
__outboxCoordinator.remove(action.payload.uuid);
|
|
4988
5013
|
reason.options.discard = true;
|
|
4989
5014
|
rollbackAndThrow();
|
|
4990
5015
|
}
|
|
4991
5016
|
}
|
|
4992
5017
|
console.debug("Registering a retry for request:", action.payload.uuid);
|
|
4993
|
-
|
|
5018
|
+
__outboxCoordinator.registerRetry(action.payload.uuid);
|
|
4994
5019
|
return false;
|
|
4995
5020
|
}
|
|
4996
5021
|
function peek(_array, _item, _context) {
|
|
4997
|
-
return
|
|
5022
|
+
return __outboxCoordinator.peek();
|
|
4998
5023
|
}
|
|
4999
5024
|
function retry(_action, _retries) {
|
|
5000
5025
|
getClientStore().dispatch(_setLatestRetryTime((/* @__PURE__ */ new Date()).getTime()));
|
|
5001
5026
|
return OUTBOX_RETRY_DELAY;
|
|
5002
5027
|
}
|
|
5003
|
-
const useAppDispatch = () => reactRedux.useDispatch();
|
|
5004
|
-
const useAppSelector = reactRedux.useSelector;
|
|
5005
5028
|
const EXPIRING_SOON_THRESHOLD = 1800;
|
|
5006
5029
|
function parseTokens(response) {
|
|
5007
5030
|
if (!response.access)
|
|
@@ -17324,6 +17347,7 @@ var __publicField = (obj, key, value) => {
|
|
|
17324
17347
|
exports2.useFileViewer = useFileViewer;
|
|
17325
17348
|
exports2.useFormikInput = useFormikInput;
|
|
17326
17349
|
exports2.useMemoCompare = useMemoCompare;
|
|
17350
|
+
exports2.useOutboxCoordinator = useOutboxCoordinator;
|
|
17327
17351
|
exports2.useSDK = useSDK;
|
|
17328
17352
|
exports2.userReducer = userReducer;
|
|
17329
17353
|
exports2.userSlice = userSlice;
|