@jsenv/navi 0.29.498 → 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 +61 -27
- package/dist/dev/jsenv_navi.js.map +5 -5
- package/dist/jsenv_navi.js +61 -27
- package/dist/jsenv_navi.js.map +5 -5
- package/docs/navigation.md +8 -7
- package/package.json +1 -1
package/dist/dev/jsenv_navi.js
CHANGED
|
@@ -10276,15 +10276,16 @@ const [publishRouteRender, observeRouteRender] = createPubSub();
|
|
|
10276
10276
|
*
|
|
10277
10277
|
* A page whose height depends on something still loading is not there at the
|
|
10278
10278
|
* moment it is put back, and a position beyond what has arrived is clamped.
|
|
10279
|
-
*
|
|
10280
|
-
*
|
|
10281
|
-
*
|
|
10282
|
-
*
|
|
10283
|
-
*
|
|
10284
|
-
*
|
|
10285
|
-
* (
|
|
10286
|
-
*
|
|
10287
|
-
*
|
|
10279
|
+
* So it is written into what is there, as far as that goes, and written again
|
|
10280
|
+
* once the page is whole (see putBackMeanwhile). What navi knows a first render
|
|
10281
|
+
* left out, it waits for: a `<Box mount="after-paint">` is built before the
|
|
10282
|
+
* offset that shows it is written (see mount_after_paint.jsx), and a reload or
|
|
10283
|
+
* a return waits for the route actions the page has nothing to draw for — its
|
|
10284
|
+
* code among them — including one whose `when` lets it ask after the position
|
|
10285
|
+
* is written (see stayForLateAsks). Anything else only the page knows, and it
|
|
10286
|
+
* says so (useHoldScrollRestoration). A wait can be long, so the reader
|
|
10287
|
+
* reaching for the page during it cancels the position: moved afterwards, they
|
|
10288
|
+
* would lose whatever they had started on.
|
|
10288
10289
|
*
|
|
10289
10290
|
* WHEN a page is arrived at is not decided here either. A document navigation
|
|
10290
10291
|
* lands where its kind says (see via_history.js), and one scrollport can be
|
|
@@ -10429,8 +10430,8 @@ const suspendScrollRecording = () => {
|
|
|
10429
10430
|
// the reader reaching for the page: where they are is theirs (see
|
|
10430
10431
|
// installScrollRestoration).
|
|
10431
10432
|
let pendingRestoration = null;
|
|
10432
|
-
const startRestoration = (position
|
|
10433
|
-
const restoration = { position, due: false
|
|
10433
|
+
const startRestoration = (position) => {
|
|
10434
|
+
const restoration = { position, due: false };
|
|
10434
10435
|
pendingRestoration = restoration;
|
|
10435
10436
|
return restoration;
|
|
10436
10437
|
};
|
|
@@ -10490,15 +10491,13 @@ const isDocumentHeld = () => {
|
|
|
10490
10491
|
return false;
|
|
10491
10492
|
};
|
|
10492
10493
|
|
|
10493
|
-
// A
|
|
10494
|
-
//
|
|
10495
|
-
//
|
|
10496
|
-
// what is there meanwhile, as far as that goes
|
|
10497
|
-
// and again once the page is whole, when what
|
|
10494
|
+
// A position waiting for the page to be whole is written after the reader has
|
|
10495
|
+
// seen the page at its top, and seen as a jump — after the movement, when a
|
|
10496
|
+
// route transition photographs the page as soon as it renders, stand-ins and
|
|
10497
|
+
// all. So it is also written into what is there meanwhile, as far as that goes
|
|
10498
|
+
// (the browser clamps the rest), and again once the page is whole, when what
|
|
10499
|
+
// it stands on has grown or shrunk.
|
|
10498
10500
|
const putBackMeanwhile = (restoration) => {
|
|
10499
|
-
if (!restoration.meanwhile) {
|
|
10500
|
-
return;
|
|
10501
|
-
}
|
|
10502
10501
|
// Out of whatever commit or effect is asking: see scrollTo.
|
|
10503
10502
|
queueMicrotask(() => {
|
|
10504
10503
|
if (pendingRestoration !== restoration || isDocumentHeld()) {
|
|
@@ -10535,11 +10534,11 @@ const holdScrollRestoration = () => {
|
|
|
10535
10534
|
};
|
|
10536
10535
|
|
|
10537
10536
|
/**
|
|
10538
|
-
*
|
|
10539
|
-
*
|
|
10540
|
-
*
|
|
10541
|
-
*
|
|
10542
|
-
*
|
|
10537
|
+
* Says the page is not whole yet to the scroll position a reload or a
|
|
10538
|
+
* back/forward gives it: written into what the page shows meanwhile, it is
|
|
10539
|
+
* clamped to that height. Put back again after the commit in which `held`
|
|
10540
|
+
* turns false — unless the reader has reached for the page in the meantime (a
|
|
10541
|
+
* finger, a click, a wheel, a key), or gone elsewhere.
|
|
10543
10542
|
*
|
|
10544
10543
|
* The page's route actions are waited for without this — its code, a read
|
|
10545
10544
|
* with no answer yet, one whose `when` holds later. This is for
|
|
@@ -10789,7 +10788,7 @@ const restoreScrollPositionOnReturn = (url) => {
|
|
|
10789
10788
|
if (!position) {
|
|
10790
10789
|
return;
|
|
10791
10790
|
}
|
|
10792
|
-
const restoration = startRestoration(position
|
|
10791
|
+
const restoration = startRestoration(position);
|
|
10793
10792
|
whenPageRendered(() => {
|
|
10794
10793
|
putBackOnceAnswered(restoration);
|
|
10795
10794
|
});
|
|
@@ -14963,7 +14962,21 @@ const setupBrowserIntegrationViaHistory = ({
|
|
|
14963
14962
|
// asked for it (see navBack's `landOn`). Read by the popstate listener,
|
|
14964
14963
|
// which is the one place the landing is applied.
|
|
14965
14964
|
let landOnPending = null;
|
|
14966
|
-
|
|
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 } = {}) => {
|
|
14967
14980
|
if (canNavBackSignal.peek()) {
|
|
14968
14981
|
// Resolved once the back has landed: the "popstate" it is answered with
|
|
14969
14982
|
// reaches the routing listener first (registered at setup, before this
|
|
@@ -14975,10 +14988,12 @@ const setupBrowserIntegrationViaHistory = ({
|
|
|
14975
14988
|
return;
|
|
14976
14989
|
}
|
|
14977
14990
|
window.removeEventListener("popstate", onPopstate);
|
|
14991
|
+
backInFlight = null;
|
|
14978
14992
|
resolve(true);
|
|
14979
14993
|
};
|
|
14980
14994
|
window.addEventListener("popstate", onPopstate);
|
|
14981
14995
|
});
|
|
14996
|
+
backInFlight = landedPromise;
|
|
14982
14997
|
landOnPending = landOn || null;
|
|
14983
14998
|
window.history.back();
|
|
14984
14999
|
return landedPromise;
|
|
@@ -15022,6 +15037,7 @@ const setupBrowserIntegrationViaHistory = ({
|
|
|
15022
15037
|
stop,
|
|
15023
15038
|
reload,
|
|
15024
15039
|
navBack,
|
|
15040
|
+
whenBackLanded,
|
|
15025
15041
|
navForward,
|
|
15026
15042
|
getDocumentState,
|
|
15027
15043
|
carryByLinkNavigation,
|
|
@@ -15368,6 +15384,10 @@ const reload = browserIntegration.reload;
|
|
|
15368
15384
|
* current entry's place.
|
|
15369
15385
|
*/
|
|
15370
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;
|
|
15371
15391
|
const navForward = browserIntegration.navForward;
|
|
15372
15392
|
const isVisited = browserIntegration.isVisited;
|
|
15373
15393
|
const visitedUrlsSignal = browserIntegration.visitedUrlsSignal;
|
|
@@ -15618,7 +15638,14 @@ const useNavStateBasic = (
|
|
|
15618
15638
|
}
|
|
15619
15639
|
leaveEntry({ isBack, discard });
|
|
15620
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.
|
|
15621
15645
|
const leaveEntry = ({ isBack, discard }) => {
|
|
15646
|
+
whenBackLanded(() => leaveLandedEntry({ isBack, discard }));
|
|
15647
|
+
};
|
|
15648
|
+
const leaveLandedEntry = ({ isBack, discard }) => {
|
|
15622
15649
|
if (!Object.hasOwn(browserIntegration.getDocumentState() || {}, id)) {
|
|
15623
15650
|
return;
|
|
15624
15651
|
}
|
|
@@ -18922,7 +18949,14 @@ const writeInSignal = (signal, value, { history }) => {
|
|
|
18922
18949
|
// `discard` empties what belongs to the popup alone (its `ownSignals`): before
|
|
18923
18950
|
// a keep-close reads the url it lands on, and once a back has landed — the
|
|
18924
18951
|
// entry behind may hold them too, written by an `onOpen` before the push.
|
|
18925
|
-
|
|
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 = (
|
|
18926
18960
|
signal,
|
|
18927
18961
|
opened,
|
|
18928
18962
|
event,
|