@solidjs/router 2.0.0-next.37 → 2.0.0-next.38
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 +74 -34
- package/dist/claims.d.ts +1 -1
- package/dist/claims.js +12 -3
- package/dist/data/events.d.ts +11 -4
- package/dist/data/events.js +37 -41
- package/dist/index.d.ts +4 -2
- package/dist/index.js +381 -155
- package/dist/index.jsx +3 -1
- package/dist/pending.js +2 -2
- package/dist/preload.d.ts +53 -0
- package/dist/preload.js +175 -0
- package/dist/preloadRoute.d.ts +23 -0
- package/dist/preloadRoute.js +92 -0
- package/dist/routers/factory.d.ts +13 -3
- package/dist/routers/factory.jsx +5 -2
- package/dist/routing.d.ts +1 -15
- package/dist/routing.js +11 -89
- package/dist/types.d.ts +19 -1
- package/dist/utils.d.ts +6 -5
- package/dist/utils.js +18 -14
- package/package.json +1 -1
package/dist/utils.d.ts
CHANGED
|
@@ -15,19 +15,20 @@ export declare const comparablePath: (path: string) => string;
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function isUnderBase(pathname: string, base: string): boolean;
|
|
17
17
|
/**
|
|
18
|
-
* The link-state rule shared by claimed anchors and `useLinkState`,
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* The link-state rule shared by claimed anchors and `useLinkState`, bound to
|
|
19
|
+
* a location so links matched against the same one share its parse. The
|
|
20
|
+
* returned matcher takes a link's already-resolved target (path, optional
|
|
21
|
+
* query and hash):
|
|
21
22
|
*
|
|
22
23
|
* - `current` — same pathname and same query (parameter order and hash aside)
|
|
23
24
|
* - `active` — same pathname or one under it; the router's root (`base`, or
|
|
24
25
|
* `/` without one) only matches exactly, since it is a prefix of every
|
|
25
26
|
* page. `end` makes every link exact-only.
|
|
26
27
|
*/
|
|
27
|
-
export declare function
|
|
28
|
+
export declare function linkMatcher({ pathname, search }: {
|
|
28
29
|
pathname: string;
|
|
29
30
|
search: string;
|
|
30
|
-
},
|
|
31
|
+
}, base: string, end?: boolean): (target: string | undefined) => {
|
|
31
32
|
active: boolean;
|
|
32
33
|
current: boolean;
|
|
33
34
|
};
|
package/dist/utils.js
CHANGED
|
@@ -32,26 +32,30 @@ const comparableQuery = (search) => {
|
|
|
32
32
|
return params.toString();
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
35
|
-
* The link-state rule shared by claimed anchors and `useLinkState`,
|
|
36
|
-
*
|
|
37
|
-
*
|
|
35
|
+
* The link-state rule shared by claimed anchors and `useLinkState`, bound to
|
|
36
|
+
* a location so links matched against the same one share its parse. The
|
|
37
|
+
* returned matcher takes a link's already-resolved target (path, optional
|
|
38
|
+
* query and hash):
|
|
38
39
|
*
|
|
39
40
|
* - `current` — same pathname and same query (parameter order and hash aside)
|
|
40
41
|
* - `active` — same pathname or one under it; the router's root (`base`, or
|
|
41
42
|
* `/` without one) only matches exactly, since it is a prefix of every
|
|
42
43
|
* page. `end` makes every link exact-only.
|
|
43
44
|
*/
|
|
44
|
-
export function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
export function linkMatcher({ pathname, search }, base, end) {
|
|
46
|
+
const loc = comparablePath(pathname);
|
|
47
|
+
const root = comparablePath(base);
|
|
48
|
+
return (target) => {
|
|
49
|
+
if (target === undefined)
|
|
50
|
+
return { active: false, current: false };
|
|
51
|
+
const path = comparablePath(target);
|
|
52
|
+
const exact = loc === path;
|
|
53
|
+
const hashless = target.split("#", 1)[0];
|
|
54
|
+
const q = hashless.indexOf("?");
|
|
55
|
+
return {
|
|
56
|
+
active: exact || (!end && path !== "" && path !== root && loc.startsWith(path + "/")),
|
|
57
|
+
current: exact && comparableQuery(search) === comparableQuery(q < 0 ? "" : hashless.slice(q))
|
|
58
|
+
};
|
|
55
59
|
};
|
|
56
60
|
}
|
|
57
61
|
export function resolvePath(base, path, from) {
|