@jsenv/navi 0.29.458 → 0.29.459
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 +19 -13
- package/dist/dev/jsenv_navi.js.map +4 -4
- package/dist/jsenv_navi.js +19 -13
- package/dist/jsenv_navi.js.map +4 -4
- package/docs/navigation.md +4 -2
- package/docs/popup_open.md +17 -0
- package/package.json +1 -1
package/dist/dev/jsenv_navi.js
CHANGED
|
@@ -11310,27 +11310,29 @@ const updateDocumentState = (value) => {
|
|
|
11310
11310
|
* `state`:
|
|
11311
11311
|
* - `undefined` — a neutral navigation: a link click, a `replaceUrl` writing a
|
|
11312
11312
|
* search param. A **replace** stays on the entry the document is already on,
|
|
11313
|
-
* so what that entry holds stays with it. A **push** opens a NEW entry
|
|
11314
|
-
*
|
|
11315
|
-
*
|
|
11316
|
-
*
|
|
11317
|
-
*
|
|
11313
|
+
* so what that entry holds stays with it. A **push** opens a NEW entry. One
|
|
11314
|
+
* arriving at another page (`isArrival`, see scroll_restoration.js) starts
|
|
11315
|
+
* empty: what was written for the entry being left — an open dialog, an
|
|
11316
|
+
* expanded picker (see `useNavState`) — describes that entry alone, and
|
|
11317
|
+
* carried forward it would reopen on the next screen, and on the one after
|
|
11318
|
+
* that, until something mounting the same id opens out of nowhere. A push
|
|
11319
|
+
* that keeps the page (a layer bound to a search param, opened over it)
|
|
11320
|
+
* carries the state: whatever holds it is still mounted under the new
|
|
11321
|
+
* address, and an empty entry would close it there — an expanded row
|
|
11322
|
+
* collapsing under the layer, expanding again when the back takes it away.
|
|
11318
11323
|
* - `null` — an explicit reset.
|
|
11319
11324
|
* - an object — built by the caller (`enter()`/`leave()` copy the current state
|
|
11320
11325
|
* themselves), taken as given.
|
|
11321
11326
|
*
|
|
11322
|
-
* `
|
|
11323
|
-
*
|
|
11324
|
-
* The push/replace split is the Navigation API's own rule for a `navigate()`
|
|
11325
|
-
* carrying no state — which is why via_navigation.js gets it from the browser
|
|
11326
|
-
* and via_history.js has to spell it out to say the same thing.
|
|
11327
|
+
* `currentState` is what the entry being left holds. `sharedState` always
|
|
11328
|
+
* wins: it describes the document, not the entry.
|
|
11327
11329
|
*/
|
|
11328
11330
|
const resolveEffectiveDocumentState = (
|
|
11329
11331
|
state,
|
|
11330
|
-
{ navigationType, currentState, sharedState },
|
|
11332
|
+
{ navigationType, isArrival, currentState, sharedState },
|
|
11331
11333
|
) => {
|
|
11332
11334
|
if (state === undefined) {
|
|
11333
|
-
if (navigationType === "push") {
|
|
11335
|
+
if (navigationType === "push" && isArrival) {
|
|
11334
11336
|
return sharedState;
|
|
11335
11337
|
}
|
|
11336
11338
|
return { ...(currentState || {}), ...sharedState };
|
|
@@ -11874,6 +11876,8 @@ const startAtTop = (url, { from } = {}) => {
|
|
|
11874
11876
|
positionByUrl.set(href, { x: 0, y: 0 });
|
|
11875
11877
|
window.scrollTo({ top: 0, left: 0, behavior: "instant" });
|
|
11876
11878
|
};
|
|
11879
|
+
// Also what decides whether a push carries the state of the page it keeps
|
|
11880
|
+
// (see resolveEffectiveDocumentState).
|
|
11877
11881
|
const isArrival = (url, { from }) => {
|
|
11878
11882
|
if (
|
|
11879
11883
|
from !== undefined &&
|
|
@@ -12309,7 +12313,8 @@ const setupBrowserIntegrationViaHistory = ({
|
|
|
12309
12313
|
|
|
12310
12314
|
const applyRoutingTask = (url, options) => {
|
|
12311
12315
|
// Read before the history is written: the url the reader is being taken
|
|
12312
|
-
// away from, which is what decides where a push lands (see startAtTop)
|
|
12316
|
+
// away from, which is what decides where a push lands (see startAtTop) and
|
|
12317
|
+
// whether it carries the state (see resolveEffectiveDocumentState).
|
|
12313
12318
|
const urlLeft = readAddress();
|
|
12314
12319
|
const {
|
|
12315
12320
|
reason,
|
|
@@ -12329,6 +12334,7 @@ const setupBrowserIntegrationViaHistory = ({
|
|
|
12329
12334
|
markUrlAsVisited(url);
|
|
12330
12335
|
const effectiveState = resolveEffectiveDocumentState(state, {
|
|
12331
12336
|
navigationType,
|
|
12337
|
+
isArrival: isArrival(url, { from: urlLeft }),
|
|
12332
12338
|
currentState: getDocumentState(),
|
|
12333
12339
|
sharedState: {
|
|
12334
12340
|
jsenv_visited_urls: Array.from(visitedUrlSet),
|