@real-router/svelte 0.24.4 → 0.24.5
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/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
npm install @real-router/svelte @real-router/core @real-router/browser-plugin
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
**Peer
|
|
13
|
+
**Peer dependencies:** `@real-router/core`, `svelte` >= 5.7.0
|
|
14
14
|
|
|
15
15
|
## Quick Start
|
|
16
16
|
|
|
@@ -497,7 +497,7 @@ Emits a forced same-route transition with `{ hash, replace: true, force: true, h
|
|
|
497
497
|
|
|
498
498
|
Options: `{ selector: string, rootMargin?: string, scrollContainer?: () => HTMLElement | null }`. Reactive via `$effect` — primitive fields (`selector`, `rootMargin`) wrapped in `$derived`, so inline objects with the same values don't thrash; `scrollContainer` getter pulled via `untrack` (identity changes don't retrigger). Empty `selector` / `undefined` = off. SSR / browsers without `IntersectionObserver` = NOOP. Requires `browser-plugin` or `navigation-plugin` (hash-plugin / memory-plugin → warn-once + NOOP).
|
|
499
499
|
|
|
500
|
-
Behaviour is identical to the React adapter — see the [React Scroll Spy demo](../../examples/web/react/hash-examples/scroll-spy/) (12 sections, TOC sidebar,
|
|
500
|
+
Behaviour is identical to the React adapter — see the [React Scroll Spy demo](../../examples/web/react/hash-examples/scroll-spy/) (12 sections, TOC sidebar, Playwright-tested) and the [Scroll Spy guide](https://github.com/greydragon888/real-router/wiki/Scroll-Spy).
|
|
501
501
|
|
|
502
502
|
## View Transitions
|
|
503
503
|
|
|
@@ -553,12 +553,12 @@ Full documentation: [Wiki](https://github.com/greydragon888/real-router/wiki)
|
|
|
553
553
|
|
|
554
554
|
## Related Packages
|
|
555
555
|
|
|
556
|
-
| Package | Description
|
|
557
|
-
| ---------------------------------------------------------------------------------------- |
|
|
558
|
-
| [@real-router/core](https://www.npmjs.com/package/@real-router/core) | Core router (required dependency)
|
|
559
|
-
| [@real-router/browser-plugin](https://www.npmjs.com/package/@real-router/browser-plugin) | Browser History API integration
|
|
560
|
-
| [@real-router/sources](https://www.npmjs.com/package/@real-router/sources) | Subscription layer (used internally)
|
|
561
|
-
| [@real-router/route-utils](https://www.npmjs.com/package/@real-router/route-utils) | Route tree queries (`useRouteUtils`)
|
|
556
|
+
| Package | Description |
|
|
557
|
+
| ---------------------------------------------------------------------------------------- | -------------------------------------- |
|
|
558
|
+
| [@real-router/core](https://www.npmjs.com/package/@real-router/core) | Core router (required peer dependency) |
|
|
559
|
+
| [@real-router/browser-plugin](https://www.npmjs.com/package/@real-router/browser-plugin) | Browser History API integration |
|
|
560
|
+
| [@real-router/sources](https://www.npmjs.com/package/@real-router/sources) | Subscription layer (used internally) |
|
|
561
|
+
| [@real-router/route-utils](https://www.npmjs.com/package/@real-router/route-utils) | Route tree queries (`useRouteUtils`) |
|
|
562
562
|
|
|
563
563
|
## Contributing
|
|
564
564
|
|
|
@@ -45,7 +45,9 @@ export type RouteExitHandler = (context: RouteExitContext) => void | Promise<voi
|
|
|
45
45
|
* navigation's `signal` aborts). A handler that rejects with a
|
|
46
46
|
* `RouterError(TRANSITION_CANCELLED)` itself cancels the navigation quietly:
|
|
47
47
|
* `navigate()` rejects with that error and the router emits
|
|
48
|
-
* `TRANSITION_CANCEL` instead (#2787).
|
|
48
|
+
* `TRANSITION_CANCEL` instead (#2787). A handler that rejects with the
|
|
49
|
+
* error the router ended ANOTHER navigation with — it awaited that
|
|
50
|
+
* navigation's work — fails this one with `CANNOT_DEACTIVATE` (#2786).
|
|
49
51
|
*
|
|
50
52
|
* **Handler reactivity (Svelte):** Svelte composables run **once** at
|
|
51
53
|
* component init; `handler` is captured in closure at the call site. To
|
|
@@ -24,7 +24,9 @@ import { useRouter } from "./useRouter.svelte";
|
|
|
24
24
|
* navigation's `signal` aborts). A handler that rejects with a
|
|
25
25
|
* `RouterError(TRANSITION_CANCELLED)` itself cancels the navigation quietly:
|
|
26
26
|
* `navigate()` rejects with that error and the router emits
|
|
27
|
-
* `TRANSITION_CANCEL` instead (#2787).
|
|
27
|
+
* `TRANSITION_CANCEL` instead (#2787). A handler that rejects with the
|
|
28
|
+
* error the router ended ANOTHER navigation with — it awaited that
|
|
29
|
+
* navigation's work — fails this one with `CANNOT_DEACTIVATE` (#2786).
|
|
28
30
|
*
|
|
29
31
|
* **Handler reactivity (Svelte):** Svelte composables run **once** at
|
|
30
32
|
* component init; `handler` is captured in closure at the call site. To
|
|
@@ -41,6 +41,8 @@ export function createDirectionTracker(router) {
|
|
|
41
41
|
// A URL plugin starts its traversal after that transition, so its flag is
|
|
42
42
|
// kept apart from the one the transition in flight may own.
|
|
43
43
|
let replay;
|
|
44
|
+
// The last transition passed the flag on.
|
|
45
|
+
let passedOn = false;
|
|
44
46
|
// ⚑ The flag is SPENT by the transition it belongs to, whether or not that
|
|
45
47
|
// transition reaches a leave phase (#1924). It is armed by any `popstate` on
|
|
46
48
|
// `globalThis`, not only one the router consumes, so `history.back()` onto an
|
|
@@ -113,6 +115,7 @@ export function createDirectionTracker(router) {
|
|
|
113
115
|
const onSettled = () => {
|
|
114
116
|
inFlight = undefined;
|
|
115
117
|
popstateFlag = replay !== undefined;
|
|
118
|
+
passedOn = popstateFlag;
|
|
116
119
|
replay = undefined;
|
|
117
120
|
};
|
|
118
121
|
// Core also reports a refusal that starts no transition on
|
|
@@ -138,6 +141,15 @@ export function createDirectionTracker(router) {
|
|
|
138
141
|
const unsubs = [
|
|
139
142
|
api.addEventListener(events.TRANSITION_START, (toState) => {
|
|
140
143
|
inFlight = toState;
|
|
144
|
+
// A flag armed between transitions that finds the router's address is a
|
|
145
|
+
// return's: it landed before the write of a navigation committed on its
|
|
146
|
+
// way, so its popstate read another address (#2879). A History plugin
|
|
147
|
+
// starts a traversal within its popstate, at the address that popstate
|
|
148
|
+
// read. A flag passed on is left alone: the plugin can write the router's
|
|
149
|
+
// URL over the entry its replay reached.
|
|
150
|
+
if (popstateFlag && !passedOn && landsOnRouterState()) {
|
|
151
|
+
popstateFlag = false;
|
|
152
|
+
}
|
|
141
153
|
}),
|
|
142
154
|
api.addEventListener(events.TRANSITION_SUCCESS, onSettled),
|
|
143
155
|
api.addEventListener(events.TRANSITION_ERROR, onError),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@real-router/svelte",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Svelte 5 integration for Real-Router",
|
|
6
6
|
"svelte": "./dist/index.js",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"@real-router/sources": "^0.15.1"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@real-router/browser-plugin": "^0.
|
|
58
|
-
"@real-router/core": "^0.
|
|
57
|
+
"@real-router/browser-plugin": "^0.27.0",
|
|
58
|
+
"@real-router/core": "^0.154.0",
|
|
59
59
|
"@sveltejs/package": "2.5.8",
|
|
60
60
|
"@sveltejs/vite-plugin-svelte": "7.3.1",
|
|
61
61
|
"@testing-library/jest-dom": "~7.0.1",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"svelte-check": "4.7.6"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@real-router/core": ">=0.
|
|
69
|
+
"@real-router/core": ">=0.154.0",
|
|
70
70
|
"svelte": ">=5.7.0"
|
|
71
71
|
},
|
|
72
72
|
"scripts": {
|