@real-router/svelte 0.15.14 → 0.15.16
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,43 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createSubscriber } from "svelte/reactivity";
|
|
1
|
+
import { createActiveSource } from "@real-router/sources";
|
|
3
2
|
import { createReactiveSource } from "../createReactiveSource.svelte";
|
|
4
3
|
import { useRouter } from "./useRouter.svelte";
|
|
5
4
|
export function useIsActiveRoute(routeName, params, strict, ignoreQueryParams, hash) {
|
|
6
5
|
const router = useRouter();
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
// `
|
|
12
|
-
//
|
|
13
|
-
|
|
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
|
-
}
|
|
36
|
-
// The `hash` argument (#532) participates in the cache key when defined.
|
|
37
|
-
// exactOptionalPropertyTypes forbids `{ hash: undefined }` literally — we
|
|
38
|
-
// conditionally include the key only when a value is provided.
|
|
39
|
-
const source = createActiveRouteSource(router, routeName, params, hash === undefined
|
|
40
|
-
? { strict, ignoreQueryParams }
|
|
41
|
-
: { strict, ignoreQueryParams, hash });
|
|
42
|
-
return createReactiveSource(source);
|
|
6
|
+
// The fast/slow decision — and the `routeName !== ""` guard that keeps
|
|
7
|
+
// `useIsActiveRoute("")` in sync with `router.isActiveRoute("")` (a misused
|
|
8
|
+
// empty name matches nothing, #1427) — lives in the shared `createActiveSource`
|
|
9
|
+
// builder (#1099 landed the fast path inline here; #1427 folded it into the
|
|
10
|
+
// shared builder). `createReactiveSource` bridges either path — the selector-
|
|
11
|
+
// backed fast source or the per-link slow source — to Svelte reactivity.
|
|
12
|
+
return createReactiveSource(createActiveSource(router, routeName, params, strict, ignoreQueryParams, hash));
|
|
43
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@real-router/svelte",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Svelte 5 integration for Real-Router",
|
|
6
6
|
"svelte": "./dist/index.js",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"license": "MIT",
|
|
49
49
|
"sideEffects": false,
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@real-router/core": "^0.
|
|
52
|
-
"@real-router/route-utils": "^0.2.
|
|
53
|
-
"@real-router/sources": "^0.11.
|
|
51
|
+
"@real-router/core": "^0.75.0",
|
|
52
|
+
"@real-router/route-utils": "^0.2.8",
|
|
53
|
+
"@real-router/sources": "^0.11.1"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@sveltejs/package": "2.5.8",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
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.18.
|
|
66
|
+
"@real-router/browser-plugin": "^0.18.18"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"svelte": ">=5.7.0"
|