@real-router/svelte 0.24.2 → 0.24.3
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.
|
@@ -32,7 +32,8 @@ export function createDirectionTracker(router) {
|
|
|
32
32
|
}
|
|
33
33
|
let popstateFlag = false;
|
|
34
34
|
document.documentElement.dataset.navDirection = "forward";
|
|
35
|
-
|
|
35
|
+
// The `toState` the transition in flight was announced with.
|
|
36
|
+
let inFlight;
|
|
36
37
|
let armedMidTransition = false;
|
|
37
38
|
// ⚑ The flag is SPENT by the transition it belongs to, whether or not that
|
|
38
39
|
// transition reaches a leave phase (#1924). It is armed by any `popstate` on
|
|
@@ -76,7 +77,7 @@ export function createDirectionTracker(router) {
|
|
|
76
77
|
popstateFlag = true;
|
|
77
78
|
// A deferred event belongs to the replay, not to the transition running
|
|
78
79
|
// now, so that transition's terminal event must not spend it.
|
|
79
|
-
armedMidTransition =
|
|
80
|
+
armedMidTransition = inFlight !== undefined;
|
|
80
81
|
};
|
|
81
82
|
// IMPORTANT — listener-ordering: `popstate` fires on `window`, which
|
|
82
83
|
// has no DOM descendants, so capture phase is moot. Listeners are
|
|
@@ -88,19 +89,37 @@ export function createDirectionTracker(router) {
|
|
|
88
89
|
globalThis.addEventListener("popstate", onPopstate);
|
|
89
90
|
const api = getPluginApi(router);
|
|
90
91
|
const onSettled = () => {
|
|
91
|
-
|
|
92
|
+
inFlight = undefined;
|
|
92
93
|
if (armedMidTransition) {
|
|
93
94
|
armedMidTransition = false;
|
|
94
95
|
return;
|
|
95
96
|
}
|
|
96
97
|
popstateFlag = false;
|
|
97
98
|
};
|
|
99
|
+
// Core also reports a refusal that starts no transition on
|
|
100
|
+
// `TRANSITION_ERROR`, and may do so while another transition runs. A
|
|
101
|
+
// transition's own error carries a `toState` with that transition's
|
|
102
|
+
// `context`, so another one does not settle it (#2779). With nothing in
|
|
103
|
+
// flight every error settles: the `SAME_STATES` arc above spends the flag
|
|
104
|
+
// that way.
|
|
105
|
+
const onError = (toState) => {
|
|
106
|
+
if (inFlight === undefined || toState?.context === inFlight.context) {
|
|
107
|
+
onSettled();
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
// A popstate armed while the transition runs may be the one this
|
|
111
|
+
// refusal answers: a URL plugin handles a popstate that arrives during a
|
|
112
|
+
// programmatic transition on the spot. So that transition's terminal
|
|
113
|
+
// spends the flag instead of keeping it for a replay.
|
|
114
|
+
armedMidTransition = false;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
98
117
|
const unsubs = [
|
|
99
|
-
api.addEventListener(events.TRANSITION_START, () => {
|
|
100
|
-
|
|
118
|
+
api.addEventListener(events.TRANSITION_START, (toState) => {
|
|
119
|
+
inFlight = toState;
|
|
101
120
|
}),
|
|
102
121
|
api.addEventListener(events.TRANSITION_SUCCESS, onSettled),
|
|
103
|
-
api.addEventListener(events.TRANSITION_ERROR,
|
|
122
|
+
api.addEventListener(events.TRANSITION_ERROR, onError),
|
|
104
123
|
api.addEventListener(events.TRANSITION_CANCEL, onSettled),
|
|
105
124
|
router.subscribeLeave(() => {
|
|
106
125
|
document.documentElement.dataset.navDirection = popstateFlag
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@real-router/svelte",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Svelte 5 integration for Real-Router",
|
|
6
6
|
"svelte": "./dist/index.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"sideEffects": false,
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@real-router/route-utils": "^0.4.0",
|
|
54
|
-
"@real-router/sources": "^0.15.
|
|
54
|
+
"@real-router/sources": "^0.15.1"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@real-router/browser-plugin": "^0.26.2",
|