@jsenv/navi 0.29.499 → 0.29.500
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/jsenv_navi.js +37 -2
- package/dist/dev/jsenv_navi.js.map +4 -4
- package/dist/jsenv_navi.js +37 -2
- package/dist/jsenv_navi.js.map +4 -4
- package/package.json +1 -1
package/dist/dev/jsenv_navi.js
CHANGED
|
@@ -14962,7 +14962,21 @@ const setupBrowserIntegrationViaHistory = ({
|
|
|
14962
14962
|
// asked for it (see navBack's `landOn`). Read by the popstate listener,
|
|
14963
14963
|
// which is the one place the landing is applied.
|
|
14964
14964
|
let landOnPending = null;
|
|
14965
|
-
|
|
14965
|
+
// The back navBack asked for, from history.back() to the "popstate" that
|
|
14966
|
+
// answers it. Meanwhile the document still reads the entry being left (see
|
|
14967
|
+
// whenBackLanded).
|
|
14968
|
+
let backInFlight = null;
|
|
14969
|
+
const whenBackLanded = (callback) => {
|
|
14970
|
+
if (backInFlight) {
|
|
14971
|
+
return backInFlight.then(callback);
|
|
14972
|
+
}
|
|
14973
|
+
return callback();
|
|
14974
|
+
};
|
|
14975
|
+
// A second back asked before the first one landed (two popups closed in the
|
|
14976
|
+
// same handler) waits for it: the browser would queue both, but the landing
|
|
14977
|
+
// has one slot, and its `landOn` was read on the entry the first back leaves.
|
|
14978
|
+
const navBack = (options) => whenBackLanded(() => navBackNow(options));
|
|
14979
|
+
const navBackNow = ({ fallback, landOn } = {}) => {
|
|
14966
14980
|
if (canNavBackSignal.peek()) {
|
|
14967
14981
|
// Resolved once the back has landed: the "popstate" it is answered with
|
|
14968
14982
|
// reaches the routing listener first (registered at setup, before this
|
|
@@ -14974,10 +14988,12 @@ const setupBrowserIntegrationViaHistory = ({
|
|
|
14974
14988
|
return;
|
|
14975
14989
|
}
|
|
14976
14990
|
window.removeEventListener("popstate", onPopstate);
|
|
14991
|
+
backInFlight = null;
|
|
14977
14992
|
resolve(true);
|
|
14978
14993
|
};
|
|
14979
14994
|
window.addEventListener("popstate", onPopstate);
|
|
14980
14995
|
});
|
|
14996
|
+
backInFlight = landedPromise;
|
|
14981
14997
|
landOnPending = landOn || null;
|
|
14982
14998
|
window.history.back();
|
|
14983
14999
|
return landedPromise;
|
|
@@ -15021,6 +15037,7 @@ const setupBrowserIntegrationViaHistory = ({
|
|
|
15021
15037
|
stop,
|
|
15022
15038
|
reload,
|
|
15023
15039
|
navBack,
|
|
15040
|
+
whenBackLanded,
|
|
15024
15041
|
navForward,
|
|
15025
15042
|
getDocumentState,
|
|
15026
15043
|
carryByLinkNavigation,
|
|
@@ -15367,6 +15384,10 @@ const reload = browserIntegration.reload;
|
|
|
15367
15384
|
* current entry's place.
|
|
15368
15385
|
*/
|
|
15369
15386
|
const navBack = browserIntegration.navBack;
|
|
15387
|
+
// Runs `callback` once the back navBack started has landed, at once when there
|
|
15388
|
+
// is none: until then the document reads the entry that back is leaving, and
|
|
15389
|
+
// a write made there is gone with it.
|
|
15390
|
+
const whenBackLanded = browserIntegration.whenBackLanded;
|
|
15370
15391
|
const navForward = browserIntegration.navForward;
|
|
15371
15392
|
const isVisited = browserIntegration.isVisited;
|
|
15372
15393
|
const visitedUrlsSignal = browserIntegration.visitedUrlsSignal;
|
|
@@ -15617,7 +15638,14 @@ const useNavStateBasic = (
|
|
|
15617
15638
|
}
|
|
15618
15639
|
leaveEntry({ isBack, discard });
|
|
15619
15640
|
};
|
|
15641
|
+
// Read and written on the entry the document lands on: a leave asked while
|
|
15642
|
+
// another one's back is in flight (a popup closed with the one under it)
|
|
15643
|
+
// would otherwise carry that entry's url and state — the other key
|
|
15644
|
+
// included — onto the wrong one.
|
|
15620
15645
|
const leaveEntry = ({ isBack, discard }) => {
|
|
15646
|
+
whenBackLanded(() => leaveLandedEntry({ isBack, discard }));
|
|
15647
|
+
};
|
|
15648
|
+
const leaveLandedEntry = ({ isBack, discard }) => {
|
|
15621
15649
|
if (!Object.hasOwn(browserIntegration.getDocumentState() || {}, id)) {
|
|
15622
15650
|
return;
|
|
15623
15651
|
}
|
|
@@ -18921,7 +18949,14 @@ const writeInSignal = (signal, value, { history }) => {
|
|
|
18921
18949
|
// `discard` empties what belongs to the popup alone (its `ownSignals`): before
|
|
18922
18950
|
// a keep-close reads the url it lands on, and once a back has landed — the
|
|
18923
18951
|
// entry behind may hold them too, written by an `onOpen` before the push.
|
|
18924
|
-
|
|
18952
|
+
//
|
|
18953
|
+
// Read and written on the entry the document lands on: a close asked while
|
|
18954
|
+
// another popup's back is in flight (a popup closed with the one under it)
|
|
18955
|
+
// would otherwise read the url that back is leaving, and write onto it.
|
|
18956
|
+
const writeOpenedInSignal = (...args) => {
|
|
18957
|
+
whenBackLanded(() => writeOpenedInLandedSignal(...args));
|
|
18958
|
+
};
|
|
18959
|
+
const writeOpenedInLandedSignal = (
|
|
18925
18960
|
signal,
|
|
18926
18961
|
opened,
|
|
18927
18962
|
event,
|