@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/jsenv_navi.js
CHANGED
|
@@ -14356,7 +14356,21 @@ const setupBrowserIntegrationViaHistory = ({
|
|
|
14356
14356
|
// asked for it (see navBack's `landOn`). Read by the popstate listener,
|
|
14357
14357
|
// which is the one place the landing is applied.
|
|
14358
14358
|
let landOnPending = null;
|
|
14359
|
-
|
|
14359
|
+
// The back navBack asked for, from history.back() to the "popstate" that
|
|
14360
|
+
// answers it. Meanwhile the document still reads the entry being left (see
|
|
14361
|
+
// whenBackLanded).
|
|
14362
|
+
let backInFlight = null;
|
|
14363
|
+
const whenBackLanded = (callback) => {
|
|
14364
|
+
if (backInFlight) {
|
|
14365
|
+
return backInFlight.then(callback);
|
|
14366
|
+
}
|
|
14367
|
+
return callback();
|
|
14368
|
+
};
|
|
14369
|
+
// A second back asked before the first one landed (two popups closed in the
|
|
14370
|
+
// same handler) waits for it: the browser would queue both, but the landing
|
|
14371
|
+
// has one slot, and its `landOn` was read on the entry the first back leaves.
|
|
14372
|
+
const navBack = (options) => whenBackLanded(() => navBackNow(options));
|
|
14373
|
+
const navBackNow = ({ fallback, landOn } = {}) => {
|
|
14360
14374
|
if (canNavBackSignal.peek()) {
|
|
14361
14375
|
// Resolved once the back has landed: the "popstate" it is answered with
|
|
14362
14376
|
// reaches the routing listener first (registered at setup, before this
|
|
@@ -14368,10 +14382,12 @@ const setupBrowserIntegrationViaHistory = ({
|
|
|
14368
14382
|
return;
|
|
14369
14383
|
}
|
|
14370
14384
|
window.removeEventListener("popstate", onPopstate);
|
|
14385
|
+
backInFlight = null;
|
|
14371
14386
|
resolve(true);
|
|
14372
14387
|
};
|
|
14373
14388
|
window.addEventListener("popstate", onPopstate);
|
|
14374
14389
|
});
|
|
14390
|
+
backInFlight = landedPromise;
|
|
14375
14391
|
landOnPending = landOn || null;
|
|
14376
14392
|
window.history.back();
|
|
14377
14393
|
return landedPromise;
|
|
@@ -14415,6 +14431,7 @@ const setupBrowserIntegrationViaHistory = ({
|
|
|
14415
14431
|
stop,
|
|
14416
14432
|
reload,
|
|
14417
14433
|
navBack,
|
|
14434
|
+
whenBackLanded,
|
|
14418
14435
|
navForward,
|
|
14419
14436
|
getDocumentState,
|
|
14420
14437
|
carryByLinkNavigation,
|
|
@@ -14708,6 +14725,10 @@ const reload = browserIntegration.reload;
|
|
|
14708
14725
|
* current entry's place.
|
|
14709
14726
|
*/
|
|
14710
14727
|
const navBack = browserIntegration.navBack;
|
|
14728
|
+
// Runs `callback` once the back navBack started has landed, at once when there
|
|
14729
|
+
// is none: until then the document reads the entry that back is leaving, and
|
|
14730
|
+
// a write made there is gone with it.
|
|
14731
|
+
const whenBackLanded = browserIntegration.whenBackLanded;
|
|
14711
14732
|
const navForward = browserIntegration.navForward;
|
|
14712
14733
|
const isVisited = browserIntegration.isVisited;
|
|
14713
14734
|
const visitedUrlsSignal = browserIntegration.visitedUrlsSignal;
|
|
@@ -14873,7 +14894,14 @@ const useNavStateBasic = (
|
|
|
14873
14894
|
}
|
|
14874
14895
|
leaveEntry({ isBack, discard });
|
|
14875
14896
|
};
|
|
14897
|
+
// Read and written on the entry the document lands on: a leave asked while
|
|
14898
|
+
// another one's back is in flight (a popup closed with the one under it)
|
|
14899
|
+
// would otherwise carry that entry's url and state — the other key
|
|
14900
|
+
// included — onto the wrong one.
|
|
14876
14901
|
const leaveEntry = ({ isBack, discard }) => {
|
|
14902
|
+
whenBackLanded(() => leaveLandedEntry({ isBack, discard }));
|
|
14903
|
+
};
|
|
14904
|
+
const leaveLandedEntry = ({ isBack, discard }) => {
|
|
14877
14905
|
if (!Object.hasOwn(browserIntegration.getDocumentState() || {}, id)) {
|
|
14878
14906
|
return;
|
|
14879
14907
|
}
|
|
@@ -18143,7 +18171,14 @@ const writeInSignal = (signal, value, { history }) => {
|
|
|
18143
18171
|
// `discard` empties what belongs to the popup alone (its `ownSignals`): before
|
|
18144
18172
|
// a keep-close reads the url it lands on, and once a back has landed — the
|
|
18145
18173
|
// entry behind may hold them too, written by an `onOpen` before the push.
|
|
18146
|
-
|
|
18174
|
+
//
|
|
18175
|
+
// Read and written on the entry the document lands on: a close asked while
|
|
18176
|
+
// another popup's back is in flight (a popup closed with the one under it)
|
|
18177
|
+
// would otherwise read the url that back is leaving, and write onto it.
|
|
18178
|
+
const writeOpenedInSignal = (...args) => {
|
|
18179
|
+
whenBackLanded(() => writeOpenedInLandedSignal(...args));
|
|
18180
|
+
};
|
|
18181
|
+
const writeOpenedInLandedSignal = (
|
|
18147
18182
|
signal,
|
|
18148
18183
|
opened,
|
|
18149
18184
|
event,
|