@real-router/svelte 0.22.1 → 0.24.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 +24 -25
- package/dist/dom-utils/index.d.ts +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -2
- package/package.json +4 -6
package/README.md
CHANGED
|
@@ -381,30 +381,6 @@ The action automatically adds `role="link"` + `tabindex="0"` to non-interactive
|
|
|
381
381
|
|
|
382
382
|
> **Hash asymmetry vs `<Link hash>`:** `createLinkAction` does **not** accept a `hash` parameter; `<Link hash="x">` does (#532). Use `<Link>` when a hash-aware variant is needed (tab-style UIs, same-route different-fragment navigation through `navigateWithHash`). For pure `use:link` callers, attach a click handler that calls `router.navigate(name, params, undefined, { force: true, hash: "x" })` manually if hash control is required.
|
|
383
383
|
|
|
384
|
-
## Reactive Primitives
|
|
385
|
-
|
|
386
|
-
### `createReactiveSource`
|
|
387
|
-
|
|
388
|
-
Public building block that bridges any `RouterSource<T>` to Svelte's reactivity system. Returns a `{ current: T }` getter object that lazily subscribes via `createSubscriber`.
|
|
389
|
-
|
|
390
|
-
```svelte
|
|
391
|
-
<script lang="ts">
|
|
392
|
-
import { createReactiveSource, useRouter } from "@real-router/svelte";
|
|
393
|
-
import { createActiveRouteSource } from "@real-router/sources";
|
|
394
|
-
|
|
395
|
-
const router = useRouter();
|
|
396
|
-
const isActive = createReactiveSource(
|
|
397
|
-
createActiveRouteSource(router, "users.profile", {})
|
|
398
|
-
);
|
|
399
|
-
</script>
|
|
400
|
-
|
|
401
|
-
{#if isActive.current}
|
|
402
|
-
<span class="badge">Active</span>
|
|
403
|
-
{/if}
|
|
404
|
-
```
|
|
405
|
-
|
|
406
|
-
Use cases: custom active route indicators, domain-specific composables, integration with other reactive primitives.
|
|
407
|
-
|
|
408
384
|
## Svelte-Specific Patterns
|
|
409
385
|
|
|
410
386
|
### Reading .current in Reactive Contexts
|
|
@@ -535,6 +511,29 @@ Opt-in animated route transitions via the browser's [View Transitions API](https
|
|
|
535
511
|
|
|
536
512
|
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
513
|
|
|
514
|
+
## Navigation Direction
|
|
515
|
+
|
|
516
|
+
`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.
|
|
517
|
+
|
|
518
|
+
```ts
|
|
519
|
+
import { browserPluginFactory } from "@real-router/browser-plugin";
|
|
520
|
+
import { createRouter } from "@real-router/core";
|
|
521
|
+
import { createDirectionTracker } from "@real-router/svelte";
|
|
522
|
+
|
|
523
|
+
const router = createRouter(routes);
|
|
524
|
+
|
|
525
|
+
createDirectionTracker(router); // before usePlugin
|
|
526
|
+
router.usePlugin(browserPluginFactory());
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
```css
|
|
530
|
+
html[data-nav-direction="back"] .page {
|
|
531
|
+
animation-name: slide-in-from-left;
|
|
532
|
+
}
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
`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).
|
|
536
|
+
|
|
538
537
|
## Documentation
|
|
539
538
|
|
|
540
539
|
Full documentation: [Wiki](https://github.com/greydragon888/real-router/wiki)
|
|
@@ -546,7 +545,7 @@ Full documentation: [Wiki](https://github.com/greydragon888/real-router/wiki)
|
|
|
546
545
|
|
|
547
546
|
24 runnable examples — each is a standalone Vite app. Run: `cd examples/web/svelte/basic && pnpm dev`
|
|
548
547
|
|
|
549
|
-
**Core:** [basic](../../examples/web/svelte/basic) · [nested-routes](../../examples/web/svelte/nested-routes) · [auth-guards](../../examples/web/svelte/auth-guards) · [data-loading](../../examples/web/svelte/data-loading) · [lazy-loading](../../examples/web/svelte/lazy-loading) · [async-guards](../../examples/web/svelte/async-guards) · [hash-routing](../../examples/web/svelte/hash-routing) · [persistent-params](../../examples/web/svelte/persistent-params) · [error-handling](../../examples/web/svelte/error-handling) · [dynamic-routes](../../examples/web/svelte/dynamic-routes) · [link-action](../../examples/web/svelte/link-action) · [lazy-loading-svelte](../../examples/web/svelte/lazy-loading-svelte) · [snippets-routing](../../examples/web/svelte/snippets-routing) · [
|
|
548
|
+
**Core:** [basic](../../examples/web/svelte/basic) · [nested-routes](../../examples/web/svelte/nested-routes) · [auth-guards](../../examples/web/svelte/auth-guards) · [data-loading](../../examples/web/svelte/data-loading) · [lazy-loading](../../examples/web/svelte/lazy-loading) · [async-guards](../../examples/web/svelte/async-guards) · [hash-routing](../../examples/web/svelte/hash-routing) · [persistent-params](../../examples/web/svelte/persistent-params) · [error-handling](../../examples/web/svelte/error-handling) · [dynamic-routes](../../examples/web/svelte/dynamic-routes) · [link-action](../../examples/web/svelte/link-action) · [lazy-loading-svelte](../../examples/web/svelte/lazy-loading-svelte) · [snippets-routing](../../examples/web/svelte/snippets-routing) · [search-schema](../../examples/web/svelte/search-schema) · [combined](../../examples/web/svelte/combined)
|
|
550
549
|
|
|
551
550
|
**Animations:** [motion-animations](../../examples/web/svelte/animation-examples/motion-animations) · [page-animations](../../examples/web/svelte/animation-examples/page-animations) · [route-animations](../../examples/web/svelte/animation-examples/route-animations) · [view-transitions](../../examples/web/svelte/animation-examples/view-transitions)
|
|
552
551
|
|
|
@@ -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
|
@@ -2,7 +2,6 @@ export { default as RouteView } from "./components/RouteView.svelte";
|
|
|
2
2
|
export { default as Link } from "./components/Link.svelte";
|
|
3
3
|
export { default as Lazy } from "./components/Lazy.svelte";
|
|
4
4
|
export { default as RouterErrorBoundary } from "./components/RouterErrorBoundary.svelte";
|
|
5
|
-
export { createReactiveSource } from "./createReactiveSource.svelte";
|
|
6
5
|
export { useRouter } from "./composables/useRouter.svelte";
|
|
7
6
|
export { useNavigator } from "./composables/useNavigator.svelte";
|
|
8
7
|
export { useRouteUtils } from "./composables/useRouteUtils.svelte";
|
|
@@ -15,7 +14,9 @@ export { createLinkAction } from "./actions/link.svelte";
|
|
|
15
14
|
export type { LinkActionParams } from "./actions/link.svelte";
|
|
16
15
|
export { default as RouterProvider } from "./RouterProvider.svelte";
|
|
17
16
|
export { ROUTER_KEY, NAVIGATOR_KEY, ROUTE_KEY } from "./context";
|
|
17
|
+
export { createDirectionTracker } from "./dom-utils";
|
|
18
18
|
export type { LinkProps, RouteContext } from "./types";
|
|
19
|
+
export type { DirectionTracker } from "./dom-utils";
|
|
19
20
|
export type { RouteExitContext, RouteExitHandler, UseRouteExitOptions, } from "./composables/useRouteExit.svelte";
|
|
20
21
|
export type { RouteEnterContext, RouteEnterHandler, UseRouteEnterOptions, } from "./composables/useRouteEnter.svelte";
|
|
21
22
|
export type { Navigator } from "@real-router/core";
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,6 @@ export { default as RouteView } from "./components/RouteView.svelte";
|
|
|
3
3
|
export { default as Link } from "./components/Link.svelte";
|
|
4
4
|
export { default as Lazy } from "./components/Lazy.svelte";
|
|
5
5
|
export { default as RouterErrorBoundary } from "./components/RouterErrorBoundary.svelte";
|
|
6
|
-
// Reactive Primitives
|
|
7
|
-
export { createReactiveSource } from "./createReactiveSource.svelte";
|
|
8
6
|
// Composables
|
|
9
7
|
export { useRouter } from "./composables/useRouter.svelte";
|
|
10
8
|
export { useNavigator } from "./composables/useNavigator.svelte";
|
|
@@ -19,3 +17,5 @@ export { createLinkAction } from "./actions/link.svelte";
|
|
|
19
17
|
// Context
|
|
20
18
|
export { default as RouterProvider } from "./RouterProvider.svelte";
|
|
21
19
|
export { ROUTER_KEY, NAVIGATOR_KEY, ROUTE_KEY } from "./context";
|
|
20
|
+
// DOM utilities
|
|
21
|
+
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.24.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": {
|