@real-router/svelte 0.22.1 → 0.23.0
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 +23 -0
- package/dist/dom-utils/index.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +4 -6
package/README.md
CHANGED
|
@@ -535,6 +535,29 @@ Opt-in animated route transitions via the browser's [View Transitions API](https
|
|
|
535
535
|
|
|
536
536
|
Reactive via `$effect` — toggling the prop creates/destroys the utility. No-op on unsupported browsers (Firefox as of 2026-04, SSR). Customization is pure CSS via `::view-transition-*` pseudo-elements and `view-transition-name` for hero morphs. See [View Transitions guide](https://github.com/greydragon888/real-router/wiki/View-Transitions) for patterns.
|
|
537
537
|
|
|
538
|
+
## Navigation Direction
|
|
539
|
+
|
|
540
|
+
`createDirectionTracker(router)` writes `data-nav-direction="forward" | "back"` on `<html>` on every leave, so exit and entry animations can key off the direction. Install it **before** `router.usePlugin(browserPluginFactory())`: both listen to `popstate`, and the tracker has to see the event first.
|
|
541
|
+
|
|
542
|
+
```ts
|
|
543
|
+
import { browserPluginFactory } from "@real-router/browser-plugin";
|
|
544
|
+
import { createRouter } from "@real-router/core";
|
|
545
|
+
import { createDirectionTracker } from "@real-router/svelte";
|
|
546
|
+
|
|
547
|
+
const router = createRouter(routes);
|
|
548
|
+
|
|
549
|
+
createDirectionTracker(router); // before usePlugin
|
|
550
|
+
router.usePlugin(browserPluginFactory());
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
```css
|
|
554
|
+
html[data-nav-direction="back"] .page {
|
|
555
|
+
animation-name: slide-in-from-left;
|
|
556
|
+
}
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
`destroy()` removes the listener and the attribute. Without a `document` (SSR) it returns a no-op instance. The argument must be a live `Router`: the tracker follows its transitions through `getPluginApi`. The API is unstable — it may change in a minor release. Live demo: [`examples/web/svelte/animation-examples/route-animations/`](../../examples/web/svelte/animation-examples/route-animations/). Recipes: [Routing Animations guide](https://github.com/greydragon888/real-router/wiki/Routing-Animations).
|
|
560
|
+
|
|
538
561
|
## Documentation
|
|
539
562
|
|
|
540
563
|
Full documentation: [Wiki](https://github.com/greydragon888/real-router/wiki)
|
|
@@ -4,6 +4,7 @@ export { createScrollRestoration } from "./scroll-restore.js";
|
|
|
4
4
|
export { createScrollSpy } from "./scroll-spy.js";
|
|
5
5
|
export { createViewTransitions } from "./view-transitions.js";
|
|
6
6
|
export { shouldNavigate, targetsAnotherContext, anchorTargetsAnotherContext, buildHref, buildActiveClassName, navigateWithHash, resolveLinkTarget, shallowEqual, applyLinkA11y, } from "./link-utils.js";
|
|
7
|
+
export type { DirectionTracker } from "./direction-tracker.js";
|
|
7
8
|
export type { RouteAnnouncerOptions } from "./route-announcer.js";
|
|
8
9
|
export type { ScrollRestorationOptions } from "./scroll-restore.js";
|
|
9
10
|
export type { ScrollSpy, ScrollSpyOptions } from "./scroll-spy.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,9 @@ export { createLinkAction } from "./actions/link.svelte";
|
|
|
15
15
|
export type { LinkActionParams } from "./actions/link.svelte";
|
|
16
16
|
export { default as RouterProvider } from "./RouterProvider.svelte";
|
|
17
17
|
export { ROUTER_KEY, NAVIGATOR_KEY, ROUTE_KEY } from "./context";
|
|
18
|
+
export { createDirectionTracker } from "./dom-utils";
|
|
18
19
|
export type { LinkProps, RouteContext } from "./types";
|
|
20
|
+
export type { DirectionTracker } from "./dom-utils";
|
|
19
21
|
export type { RouteExitContext, RouteExitHandler, UseRouteExitOptions, } from "./composables/useRouteExit.svelte";
|
|
20
22
|
export type { RouteEnterContext, RouteEnterHandler, UseRouteEnterOptions, } from "./composables/useRouteEnter.svelte";
|
|
21
23
|
export type { Navigator } from "@real-router/core";
|
package/dist/index.js
CHANGED
|
@@ -19,3 +19,5 @@ export { createLinkAction } from "./actions/link.svelte";
|
|
|
19
19
|
// Context
|
|
20
20
|
export { default as RouterProvider } from "./RouterProvider.svelte";
|
|
21
21
|
export { ROUTER_KEY, NAVIGATOR_KEY, ROUTE_KEY } from "./context";
|
|
22
|
+
// DOM utilities
|
|
23
|
+
export { createDirectionTracker } from "./dom-utils";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@real-router/svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Svelte 5 integration for Real-Router",
|
|
6
6
|
"svelte": "./dist/index.js",
|
|
@@ -55,20 +55,18 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@real-router/browser-plugin": "^0.25.0",
|
|
58
|
-
"@real-router/core": "^0.
|
|
58
|
+
"@real-router/core": "^0.148.0",
|
|
59
59
|
"@sveltejs/package": "2.5.8",
|
|
60
60
|
"@sveltejs/vite-plugin-svelte": "7.3.0",
|
|
61
61
|
"@testing-library/jest-dom": "~7.0.1",
|
|
62
62
|
"@testing-library/svelte": "~5.4.2",
|
|
63
63
|
"@testing-library/user-event": "~14.6.1",
|
|
64
|
-
"eslint-plugin-svelte": "3.23.0",
|
|
65
64
|
"rimraf": "6.1.3",
|
|
66
65
|
"svelte": "~5.57.0",
|
|
67
|
-
"svelte-check": "4.7.6"
|
|
68
|
-
"svelte-eslint-parser": "1.8.1"
|
|
66
|
+
"svelte-check": "4.7.6"
|
|
69
67
|
},
|
|
70
68
|
"peerDependencies": {
|
|
71
|
-
"@real-router/core": ">=0.
|
|
69
|
+
"@real-router/core": ">=0.148.0",
|
|
72
70
|
"svelte": ">=5.7.0"
|
|
73
71
|
},
|
|
74
72
|
"scripts": {
|