@real-router/svelte 0.13.13 → 0.13.14
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.
|
@@ -1,8 +1,38 @@
|
|
|
1
|
-
import { createActiveRouteSource } from "@real-router/sources";
|
|
1
|
+
import { createActiveNameSelector, createActiveRouteSource, } from "@real-router/sources";
|
|
2
|
+
import { createSubscriber } from "svelte/reactivity";
|
|
2
3
|
import { createReactiveSource } from "../createReactiveSource.svelte";
|
|
3
4
|
import { useRouter } from "./useRouter.svelte";
|
|
4
5
|
export function useIsActiveRoute(routeName, params, strict, ignoreQueryParams, hash) {
|
|
5
6
|
const router = useRouter();
|
|
7
|
+
// Fast path (#1099) — the default-options `<Link>`: non-strict matching,
|
|
8
|
+
// query params ignored, no custom `params`, no `hash`. Use the per-router
|
|
9
|
+
// shared `ActiveNameSelector`: ONE `router.subscribe` handle serves any
|
|
10
|
+
// number of distinct-`routeName` links, instead of a per-link
|
|
11
|
+
// `createActiveRouteSource` (which allocates a `BaseSource` AND opens its own
|
|
12
|
+
// router subscription for every link). This mirrors the Solid adapter's
|
|
13
|
+
// `routeSelector` fast path and removes ~4 ms / 1000 links from the
|
|
14
|
+
// link-build mount — the per-link source setup was the bulk of the Svelte
|
|
15
|
+
// `<Link>`'s extra cost over the Solid adapter.
|
|
16
|
+
//
|
|
17
|
+
// Equivalence: the selector's `isActive` is exactly non-strict,
|
|
18
|
+
// query-ignoring, name-only matching — identical to
|
|
19
|
+
// `createActiveRouteSource(router, name, undefined, { strict: false,
|
|
20
|
+
// ignoreQueryParams: true })`. Any deviation from these defaults falls to the
|
|
21
|
+
// slow path below, whose cache handles the full argument surface (custom
|
|
22
|
+
// params, strict, `ignoreQueryParams: false`, hash-aware #532).
|
|
23
|
+
if (params === undefined &&
|
|
24
|
+
!strict &&
|
|
25
|
+
ignoreQueryParams &&
|
|
26
|
+
hash === undefined) {
|
|
27
|
+
const selector = createActiveNameSelector(router);
|
|
28
|
+
const subscribe = createSubscriber((update) => selector.subscribe(routeName, update));
|
|
29
|
+
return {
|
|
30
|
+
get current() {
|
|
31
|
+
subscribe();
|
|
32
|
+
return selector.isActive(routeName);
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
6
36
|
// The `hash` argument (#532) participates in the cache key when defined.
|
|
7
37
|
// exactOptionalPropertyTypes forbids `{ hash: undefined }` literally — we
|
|
8
38
|
// conditionally include the key only when a value is provided.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@real-router/svelte",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Svelte 5 integration for Real-Router",
|
|
6
6
|
"svelte": "./dist/index.js",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"license": "MIT",
|
|
49
49
|
"sideEffects": false,
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@real-router/core": "^0.62.2",
|
|
52
51
|
"@real-router/route-utils": "^0.2.5",
|
|
52
|
+
"@real-router/core": "^0.62.3",
|
|
53
53
|
"@real-router/sources": "^0.10.1"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"@testing-library/user-event": "14.6.1",
|
|
61
61
|
"eslint-plugin-svelte": "3.19.0",
|
|
62
62
|
"rimraf": "6.1.3",
|
|
63
|
-
"svelte": "5.56.
|
|
63
|
+
"svelte": "5.56.4",
|
|
64
64
|
"svelte-check": "4.6.0",
|
|
65
65
|
"svelte-eslint-parser": "1.8.0",
|
|
66
|
-
"@real-router/browser-plugin": "^0.
|
|
66
|
+
"@real-router/browser-plugin": "^0.18.1"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"svelte": ">=5.7.0"
|