@real-router/svelte 0.5.0 → 0.6.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
CHANGED
|
@@ -384,9 +384,9 @@ Full documentation: [Wiki](https://github.com/greydragon888/real-router/wiki)
|
|
|
384
384
|
|
|
385
385
|
## Examples
|
|
386
386
|
|
|
387
|
-
16 runnable examples — each is a standalone Vite app. Run: `cd examples/svelte/basic && pnpm dev`
|
|
387
|
+
16 runnable examples — each is a standalone Vite app. Run: `cd examples/web/svelte/basic && pnpm dev`
|
|
388
388
|
|
|
389
|
-
[basic](../../examples/svelte/basic) · [nested-routes](../../examples/svelte/nested-routes) · [auth-guards](../../examples/svelte/auth-guards) · [data-loading](../../examples/svelte/data-loading) · [lazy-loading](../../examples/svelte/lazy-loading) · [async-guards](../../examples/svelte/async-guards) · [hash-routing](../../examples/svelte/hash-routing) · [persistent-params](../../examples/svelte/persistent-params) · [error-handling](../../examples/svelte/error-handling) · [dynamic-routes](../../examples/svelte/dynamic-routes) · [link-action](../../examples/svelte/link-action) · [lazy-loading-svelte](../../examples/svelte/lazy-loading-svelte) · [snippets-routing](../../examples/svelte/snippets-routing) · [reactive-source](../../examples/svelte/reactive-source) · [search-schema](../../examples/svelte/search-schema) · [combined](../../examples/svelte/combined)
|
|
389
|
+
[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) · [reactive-source](../../examples/web/svelte/reactive-source) · [search-schema](../../examples/web/svelte/search-schema) · [combined](../../examples/web/svelte/combined)
|
|
390
390
|
|
|
391
391
|
## Related Packages
|
|
392
392
|
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import { startsWithSegment } from "@real-router/route-utils";
|
|
3
3
|
|
|
4
|
+
// Snippet names reserved by RouteView for non-segment slots. Iteration in
|
|
5
|
+
// `getActiveSegment` skips these so they don't accidentally match a route.
|
|
6
|
+
const RESERVED_SLOT_NAMES = new Set(["self", "notFound"]);
|
|
7
|
+
|
|
4
8
|
export function getActiveSegment(
|
|
5
9
|
routeName: string,
|
|
6
10
|
node: string,
|
|
@@ -9,7 +13,7 @@
|
|
|
9
13
|
const prefix = node ? `${node}.` : "";
|
|
10
14
|
|
|
11
15
|
for (const segment in snippets) {
|
|
12
|
-
if (segment
|
|
16
|
+
if (RESERVED_SLOT_NAMES.has(segment)) continue;
|
|
13
17
|
if (startsWithSegment(routeName, prefix + segment)) {
|
|
14
18
|
return segment;
|
|
15
19
|
}
|
|
@@ -28,10 +32,12 @@
|
|
|
28
32
|
|
|
29
33
|
let {
|
|
30
34
|
nodeName,
|
|
35
|
+
self,
|
|
31
36
|
notFound,
|
|
32
37
|
...segmentSnippets
|
|
33
38
|
}: {
|
|
34
39
|
nodeName: string;
|
|
40
|
+
self?: Snippet;
|
|
35
41
|
notFound?: Snippet;
|
|
36
42
|
[key: string]: Snippet | string | undefined;
|
|
37
43
|
} = $props();
|
|
@@ -45,6 +51,8 @@
|
|
|
45
51
|
{#if segment}
|
|
46
52
|
{@const snippet = segmentSnippets[segment] as Snippet}
|
|
47
53
|
{@render snippet()}
|
|
54
|
+
{:else if self && route.name === nodeName}
|
|
55
|
+
{@render self()}
|
|
48
56
|
{:else if route.name === UNKNOWN_ROUTE && notFound}
|
|
49
57
|
{@render notFound()}
|
|
50
58
|
{/if}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@real-router/svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Svelte 5 integration for Real-Router",
|
|
6
6
|
"svelte": "./dist/index.js",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"license": "MIT",
|
|
45
45
|
"sideEffects": false,
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@real-router/core": "^0.50.
|
|
47
|
+
"@real-router/core": "^0.50.1",
|
|
48
48
|
"@real-router/route-utils": "^0.2.1",
|
|
49
49
|
"@real-router/sources": "^0.7.2"
|
|
50
50
|
},
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"svelte": "5.54.0",
|
|
59
59
|
"svelte-check": "4.4.5",
|
|
60
60
|
"svelte-eslint-parser": "1.6.0",
|
|
61
|
-
"@real-router/browser-plugin": "^0.
|
|
61
|
+
"@real-router/browser-plugin": "^0.15.1"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"svelte": ">=5.7.0"
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import { startsWithSegment } from "@real-router/route-utils";
|
|
3
3
|
|
|
4
|
+
// Snippet names reserved by RouteView for non-segment slots. Iteration in
|
|
5
|
+
// `getActiveSegment` skips these so they don't accidentally match a route.
|
|
6
|
+
const RESERVED_SLOT_NAMES = new Set(["self", "notFound"]);
|
|
7
|
+
|
|
4
8
|
export function getActiveSegment(
|
|
5
9
|
routeName: string,
|
|
6
10
|
node: string,
|
|
@@ -9,7 +13,7 @@
|
|
|
9
13
|
const prefix = node ? `${node}.` : "";
|
|
10
14
|
|
|
11
15
|
for (const segment in snippets) {
|
|
12
|
-
if (segment
|
|
16
|
+
if (RESERVED_SLOT_NAMES.has(segment)) continue;
|
|
13
17
|
if (startsWithSegment(routeName, prefix + segment)) {
|
|
14
18
|
return segment;
|
|
15
19
|
}
|
|
@@ -28,10 +32,12 @@
|
|
|
28
32
|
|
|
29
33
|
let {
|
|
30
34
|
nodeName,
|
|
35
|
+
self,
|
|
31
36
|
notFound,
|
|
32
37
|
...segmentSnippets
|
|
33
38
|
}: {
|
|
34
39
|
nodeName: string;
|
|
40
|
+
self?: Snippet;
|
|
35
41
|
notFound?: Snippet;
|
|
36
42
|
[key: string]: Snippet | string | undefined;
|
|
37
43
|
} = $props();
|
|
@@ -45,6 +51,8 @@
|
|
|
45
51
|
{#if segment}
|
|
46
52
|
{@const snippet = segmentSnippets[segment] as Snippet}
|
|
47
53
|
{@render snippet()}
|
|
54
|
+
{:else if self && route.name === nodeName}
|
|
55
|
+
{@render self()}
|
|
48
56
|
{:else if route.name === UNKNOWN_ROUTE && notFound}
|
|
49
57
|
{@render notFound()}
|
|
50
58
|
{/if}
|