@flight-framework/router 0.3.2 → 0.5.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/dist/index.d.ts +2 -2
- package/dist/index.js +34 -0
- package/dist/preact/index.d.ts +4 -4
- package/dist/preact/index.js +69 -2
- package/dist/{prefetch-COkjiZgH.d.ts → prefetch-C_RFFXW0.d.ts} +11 -1
- package/dist/react/index.d.ts +17 -5
- package/dist/react/index.js +65 -3
- package/dist/solid/index.d.ts +3 -3
- package/dist/solid/index.js +67 -0
- package/dist/svelte/index.d.ts +2 -2
- package/dist/svelte/index.js +34 -0
- package/dist/vue/index.d.ts +2 -2
- package/dist/vue/index.js +66 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LinkProps, R as RouteParams, S as SearchParams } from './prefetch-
|
|
2
|
-
export { g as LoaderContext, f as LoaderFunction, N as NavigateOptions, d as PrefetchOptions, k as PrefetchPageLinks, c as PrefetchPriority, P as PrefetchStrategy, e as RouteDefinition, h as RouteMatch, i as RouterContext, a as RouterContextValue, j as RouterProvider, b as RouterProviderProps, w as clearPrefetchCache, l as findRoute, o as generatePath, q as isActive, v as isPrefetched, m as matchRoute, n as navigate, x as observeForPrefetch, p as parseParams, s as prefetch, t as prefetchAll, z as prefetchPages, A as prefetchWhenIdle, r as redirect, y as setupIntentPrefetch, u as useRouter } from './prefetch-
|
|
1
|
+
import { L as LinkProps, R as RouteParams, S as SearchParams } from './prefetch-C_RFFXW0.js';
|
|
2
|
+
export { g as LoaderContext, f as LoaderFunction, N as NavigateOptions, d as PrefetchOptions, k as PrefetchPageLinks, c as PrefetchPriority, P as PrefetchStrategy, e as RouteDefinition, h as RouteMatch, i as RouterContext, a as RouterContextValue, j as RouterProvider, b as RouterProviderProps, w as clearPrefetchCache, l as findRoute, o as generatePath, q as isActive, v as isPrefetched, m as matchRoute, n as navigate, x as observeForPrefetch, p as parseParams, s as prefetch, t as prefetchAll, z as prefetchPages, A as prefetchWhenIdle, r as redirect, y as setupIntentPrefetch, u as useRouter } from './prefetch-C_RFFXW0.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @flight-framework/router - Link Component
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,40 @@
|
|
|
1
1
|
// src/context.ts
|
|
2
2
|
var isBrowser = typeof window !== "undefined";
|
|
3
|
+
function createSetSearchParams() {
|
|
4
|
+
return (nextInit, navigateOptions = {}) => {
|
|
5
|
+
if (!isBrowser) return;
|
|
6
|
+
const currentUrl = new URL(window.location.href);
|
|
7
|
+
let newSearchParams;
|
|
8
|
+
if (typeof nextInit === "function") {
|
|
9
|
+
newSearchParams = nextInit(new URLSearchParams(currentUrl.search));
|
|
10
|
+
} else if (nextInit instanceof URLSearchParams) {
|
|
11
|
+
newSearchParams = nextInit;
|
|
12
|
+
} else {
|
|
13
|
+
newSearchParams = new URLSearchParams();
|
|
14
|
+
for (const [key, value] of Object.entries(nextInit)) {
|
|
15
|
+
if (Array.isArray(value)) {
|
|
16
|
+
for (const v of value) {
|
|
17
|
+
newSearchParams.append(key, v);
|
|
18
|
+
}
|
|
19
|
+
} else {
|
|
20
|
+
newSearchParams.set(key, value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const newUrl = `${currentUrl.pathname}${newSearchParams.toString() ? `?${newSearchParams.toString()}` : ""}${currentUrl.hash}`;
|
|
25
|
+
if (navigateOptions.replace) {
|
|
26
|
+
window.history.replaceState(navigateOptions.state ?? null, "", newUrl);
|
|
27
|
+
} else {
|
|
28
|
+
window.history.pushState(navigateOptions.state ?? null, "", newUrl);
|
|
29
|
+
}
|
|
30
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
var globalSetSearchParams = createSetSearchParams();
|
|
3
34
|
var currentContext = {
|
|
4
35
|
path: "/",
|
|
5
36
|
searchParams: new URLSearchParams(),
|
|
37
|
+
setSearchParams: globalSetSearchParams,
|
|
6
38
|
navigate: () => {
|
|
7
39
|
},
|
|
8
40
|
back: () => {
|
|
@@ -56,6 +88,7 @@ function initRouter(options = {}) {
|
|
|
56
88
|
currentContext = {
|
|
57
89
|
path,
|
|
58
90
|
searchParams,
|
|
91
|
+
setSearchParams: globalSetSearchParams,
|
|
59
92
|
navigate: navigateTo,
|
|
60
93
|
back: () => isBrowser && window.history.back(),
|
|
61
94
|
forward: () => isBrowser && window.history.forward()
|
|
@@ -117,6 +150,7 @@ if (typeof globalThis !== "undefined") {
|
|
|
117
150
|
return {
|
|
118
151
|
path: basePath && path.startsWith(basePath) ? path.slice(basePath.length) || "/" : path,
|
|
119
152
|
searchParams,
|
|
153
|
+
setSearchParams: globalSetSearchParams,
|
|
120
154
|
navigate: navigateTo,
|
|
121
155
|
back: () => isBrowser && window.history.back(),
|
|
122
156
|
forward: () => isBrowser && window.history.forward()
|
package/dist/preact/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PrefetchStrategy, b as RouterProviderProps, a as RouterContextValue } from '../prefetch-
|
|
2
|
-
export { L as LinkProps, N as NavigateOptions, d as PrefetchOptions, c as PrefetchPriority, R as RouteParams, S as SearchParams, w as clearPrefetchCache, l as findRoute, o as generatePath,
|
|
1
|
+
import { P as PrefetchStrategy, b as RouterProviderProps, a as RouterContextValue, B as SetSearchParamsFunction } from '../prefetch-C_RFFXW0.js';
|
|
2
|
+
export { L as LinkProps, N as NavigateOptions, d as PrefetchOptions, c as PrefetchPriority, R as RouteParams, S as SearchParams, w as clearPrefetchCache, l as findRoute, o as generatePath, C as getRouterContext, E as initRouter, q as isActive, v as isPrefetched, m as matchRoute, n as navigate, x as observeForPrefetch, p as parseParams, s as prefetch, t as prefetchAll, z as prefetchPages, A as prefetchWhenIdle, r as redirect, y as setupIntentPrefetch, D as subscribe } from '../prefetch-C_RFFXW0.js';
|
|
3
3
|
import * as preact$1 from 'preact';
|
|
4
4
|
import { FunctionComponent, ComponentChildren } from 'preact';
|
|
5
5
|
|
|
@@ -46,9 +46,9 @@ declare function useRouter(): RouterContextValue;
|
|
|
46
46
|
*/
|
|
47
47
|
declare function usePathname(): string;
|
|
48
48
|
/**
|
|
49
|
-
* Hook to get current search params
|
|
49
|
+
* Hook to get and set current search params (React Router compatible)
|
|
50
50
|
*/
|
|
51
|
-
declare function useSearchParams(): URLSearchParams;
|
|
51
|
+
declare function useSearchParams(): [URLSearchParams, SetSearchParamsFunction];
|
|
52
52
|
/**
|
|
53
53
|
* Hook to get route params
|
|
54
54
|
*/
|
package/dist/preact/index.js
CHANGED
|
@@ -1,8 +1,40 @@
|
|
|
1
1
|
// src/context.ts
|
|
2
2
|
var isBrowser = typeof window !== "undefined";
|
|
3
|
+
function createSetSearchParams() {
|
|
4
|
+
return (nextInit, navigateOptions = {}) => {
|
|
5
|
+
if (!isBrowser) return;
|
|
6
|
+
const currentUrl = new URL(window.location.href);
|
|
7
|
+
let newSearchParams;
|
|
8
|
+
if (typeof nextInit === "function") {
|
|
9
|
+
newSearchParams = nextInit(new URLSearchParams(currentUrl.search));
|
|
10
|
+
} else if (nextInit instanceof URLSearchParams) {
|
|
11
|
+
newSearchParams = nextInit;
|
|
12
|
+
} else {
|
|
13
|
+
newSearchParams = new URLSearchParams();
|
|
14
|
+
for (const [key, value] of Object.entries(nextInit)) {
|
|
15
|
+
if (Array.isArray(value)) {
|
|
16
|
+
for (const v of value) {
|
|
17
|
+
newSearchParams.append(key, v);
|
|
18
|
+
}
|
|
19
|
+
} else {
|
|
20
|
+
newSearchParams.set(key, value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const newUrl = `${currentUrl.pathname}${newSearchParams.toString() ? `?${newSearchParams.toString()}` : ""}${currentUrl.hash}`;
|
|
25
|
+
if (navigateOptions.replace) {
|
|
26
|
+
window.history.replaceState(navigateOptions.state ?? null, "", newUrl);
|
|
27
|
+
} else {
|
|
28
|
+
window.history.pushState(navigateOptions.state ?? null, "", newUrl);
|
|
29
|
+
}
|
|
30
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
var globalSetSearchParams = createSetSearchParams();
|
|
3
34
|
var currentContext = {
|
|
4
35
|
path: "/",
|
|
5
36
|
searchParams: new URLSearchParams(),
|
|
37
|
+
setSearchParams: globalSetSearchParams,
|
|
6
38
|
navigate: () => {
|
|
7
39
|
},
|
|
8
40
|
back: () => {
|
|
@@ -56,6 +88,7 @@ function initRouter(options = {}) {
|
|
|
56
88
|
currentContext = {
|
|
57
89
|
path,
|
|
58
90
|
searchParams,
|
|
91
|
+
setSearchParams: globalSetSearchParams,
|
|
59
92
|
navigate: navigateTo,
|
|
60
93
|
back: () => isBrowser && window.history.back(),
|
|
61
94
|
forward: () => isBrowser && window.history.forward()
|
|
@@ -117,6 +150,7 @@ if (typeof globalThis !== "undefined") {
|
|
|
117
150
|
return {
|
|
118
151
|
path: basePath && path.startsWith(basePath) ? path.slice(basePath.length) || "/" : path,
|
|
119
152
|
searchParams,
|
|
153
|
+
setSearchParams: globalSetSearchParams,
|
|
120
154
|
navigate: navigateTo,
|
|
121
155
|
back: () => isBrowser && window.history.back(),
|
|
122
156
|
forward: () => isBrowser && window.history.forward()
|
|
@@ -551,9 +585,41 @@ function navigateTo2(to, options = {}) {
|
|
|
551
585
|
window.scrollTo({ top: 0, left: 0, behavior: "instant" });
|
|
552
586
|
}
|
|
553
587
|
}
|
|
588
|
+
function createSetSearchParams2() {
|
|
589
|
+
return (nextInit, navigateOptions = {}) => {
|
|
590
|
+
if (!isBrowser6) return;
|
|
591
|
+
const currentUrl = new URL(window.location.href);
|
|
592
|
+
let newSearchParams;
|
|
593
|
+
if (typeof nextInit === "function") {
|
|
594
|
+
newSearchParams = nextInit(new URLSearchParams(currentUrl.search));
|
|
595
|
+
} else if (nextInit instanceof URLSearchParams) {
|
|
596
|
+
newSearchParams = nextInit;
|
|
597
|
+
} else {
|
|
598
|
+
newSearchParams = new URLSearchParams();
|
|
599
|
+
for (const [key, value] of Object.entries(nextInit)) {
|
|
600
|
+
if (Array.isArray(value)) {
|
|
601
|
+
for (const v of value) {
|
|
602
|
+
newSearchParams.append(key, v);
|
|
603
|
+
}
|
|
604
|
+
} else {
|
|
605
|
+
newSearchParams.set(key, value);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
const newUrl = `${currentUrl.pathname}${newSearchParams.toString() ? `?${newSearchParams.toString()}` : ""}${currentUrl.hash}`;
|
|
610
|
+
if (navigateOptions.replace) {
|
|
611
|
+
window.history.replaceState(navigateOptions.state ?? null, "", newUrl);
|
|
612
|
+
} else {
|
|
613
|
+
window.history.pushState(navigateOptions.state ?? null, "", newUrl);
|
|
614
|
+
}
|
|
615
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
var globalSetSearchParams2 = createSetSearchParams2();
|
|
554
619
|
var defaultContext = {
|
|
555
620
|
path: "/",
|
|
556
621
|
searchParams: new URLSearchParams(),
|
|
622
|
+
setSearchParams: globalSetSearchParams2,
|
|
557
623
|
navigate: navigateTo2,
|
|
558
624
|
back: () => isBrowser6 && window.history.back(),
|
|
559
625
|
forward: () => isBrowser6 && window.history.forward()
|
|
@@ -567,8 +633,8 @@ function usePathname() {
|
|
|
567
633
|
return path;
|
|
568
634
|
}
|
|
569
635
|
function useSearchParams() {
|
|
570
|
-
const { searchParams } = useContext(RouterContext2);
|
|
571
|
-
return searchParams;
|
|
636
|
+
const { searchParams, setSearchParams } = useContext(RouterContext2);
|
|
637
|
+
return [searchParams, setSearchParams];
|
|
572
638
|
}
|
|
573
639
|
function useParams() {
|
|
574
640
|
return {};
|
|
@@ -588,6 +654,7 @@ var RouterProvider2 = ({
|
|
|
588
654
|
return {
|
|
589
655
|
path: normalizedPath,
|
|
590
656
|
searchParams,
|
|
657
|
+
setSearchParams: globalSetSearchParams2,
|
|
591
658
|
navigate: navigateTo2,
|
|
592
659
|
back: () => isBrowser6 && window.history.back(),
|
|
593
660
|
forward: () => isBrowser6 && window.history.forward()
|
|
@@ -9,6 +9,8 @@ interface RouterContextValue {
|
|
|
9
9
|
path: string;
|
|
10
10
|
/** URL search params as object */
|
|
11
11
|
searchParams: URLSearchParams;
|
|
12
|
+
/** Update URL search params (React Router compatible) */
|
|
13
|
+
setSearchParams: SetSearchParamsFunction;
|
|
12
14
|
/** Navigate to a new path */
|
|
13
15
|
navigate: (to: string, options?: NavigateOptions) => void;
|
|
14
16
|
/** Go back in history */
|
|
@@ -16,6 +18,14 @@ interface RouterContextValue {
|
|
|
16
18
|
/** Go forward in history */
|
|
17
19
|
forward: () => void;
|
|
18
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* SetSearchParams function type following React Router pattern.
|
|
23
|
+
* Accepts URLSearchParams, object, or callback function.
|
|
24
|
+
*/
|
|
25
|
+
type SetSearchParamsFunction = (nextInit: URLSearchParams | Record<string, string | string[]> | ((prev: URLSearchParams) => URLSearchParams), navigateOptions?: {
|
|
26
|
+
replace?: boolean;
|
|
27
|
+
state?: unknown;
|
|
28
|
+
}) => void;
|
|
19
29
|
/**
|
|
20
30
|
* Props for RouterProvider component
|
|
21
31
|
*/
|
|
@@ -370,4 +380,4 @@ declare function observeForPrefetch(element: Element, href: string): () => void;
|
|
|
370
380
|
*/
|
|
371
381
|
declare function setupIntentPrefetch(element: HTMLElement, href: string): () => void;
|
|
372
382
|
|
|
373
|
-
export { prefetchWhenIdle as A,
|
|
383
|
+
export { prefetchWhenIdle as A, type SetSearchParamsFunction as B, getRouterContext as C, subscribe as D, initRouter as E, type LinkProps as L, type NavigateOptions as N, type PrefetchStrategy as P, type RouteParams as R, type SearchParams as S, type RouterContextValue as a, type RouterProviderProps as b, type PrefetchPriority as c, type PrefetchOptions as d, type RouteDefinition as e, type LoaderFunction as f, type LoaderContext as g, type RouteMatch as h, RouterContext as i, RouterProvider as j, PrefetchPageLinks as k, findRoute as l, matchRoute as m, navigate as n, generatePath as o, parseParams as p, isActive as q, redirect as r, prefetch as s, prefetchAll as t, useRouter as u, isPrefetched as v, clearPrefetchCache as w, observeForPrefetch as x, setupIntentPrefetch as y, prefetchPages as z };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LinkProps, b as RouterProviderProps, a as RouterContextValue, R as RouteParams } from '../prefetch-
|
|
2
|
-
export { g as LoaderContext, f as LoaderFunction, N as NavigateOptions, d as PrefetchOptions, c as PrefetchPriority, P as PrefetchStrategy, e as RouteDefinition, h as RouteMatch, S as SearchParams, w as clearPrefetchCache, l as findRoute, o as generatePath,
|
|
1
|
+
import { L as LinkProps, b as RouterProviderProps, a as RouterContextValue, B as SetSearchParamsFunction, R as RouteParams } from '../prefetch-C_RFFXW0.js';
|
|
2
|
+
export { g as LoaderContext, f as LoaderFunction, N as NavigateOptions, d as PrefetchOptions, c as PrefetchPriority, P as PrefetchStrategy, e as RouteDefinition, h as RouteMatch, S as SearchParams, w as clearPrefetchCache, l as findRoute, o as generatePath, C as getRouterContext, E as initRouter, q as isActive, v as isPrefetched, m as matchRoute, n as navigate, x as observeForPrefetch, p as parseParams, s as prefetch, t as prefetchAll, z as prefetchPages, A as prefetchWhenIdle, r as redirect, y as setupIntentPrefetch, D as subscribe } from '../prefetch-C_RFFXW0.js';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -85,18 +85,30 @@ declare function RouterProvider({ children, initialPath, basePath }: RouterProvi
|
|
|
85
85
|
*/
|
|
86
86
|
declare function usePathname(): string;
|
|
87
87
|
/**
|
|
88
|
-
* Hook to get current search params
|
|
88
|
+
* Hook to get and set current search params
|
|
89
|
+
*
|
|
90
|
+
* Following React Router API pattern: returns [searchParams, setSearchParams] tuple.
|
|
89
91
|
*
|
|
90
92
|
* @example
|
|
91
93
|
* ```tsx
|
|
92
94
|
* function Component() {
|
|
93
|
-
* const searchParams = useSearchParams();
|
|
95
|
+
* const [searchParams, setSearchParams] = useSearchParams();
|
|
94
96
|
* const page = searchParams.get('page') || '1';
|
|
97
|
+
*
|
|
98
|
+
* // Update search params
|
|
99
|
+
* setSearchParams({ page: '2' });
|
|
100
|
+
*
|
|
101
|
+
* // Or with callback
|
|
102
|
+
* setSearchParams(prev => {
|
|
103
|
+
* prev.set('tab', '1');
|
|
104
|
+
* return prev;
|
|
105
|
+
* });
|
|
106
|
+
*
|
|
95
107
|
* return <div>Page: {page}</div>;
|
|
96
108
|
* }
|
|
97
109
|
* ```
|
|
98
110
|
*/
|
|
99
|
-
declare function useSearchParams(): URLSearchParams;
|
|
111
|
+
declare function useSearchParams(): [URLSearchParams, SetSearchParamsFunction];
|
|
100
112
|
/**
|
|
101
113
|
* Hook to get route params
|
|
102
114
|
*
|
package/dist/react/index.js
CHANGED
|
@@ -1,8 +1,40 @@
|
|
|
1
1
|
// src/context.ts
|
|
2
2
|
var isBrowser = typeof window !== "undefined";
|
|
3
|
+
function createSetSearchParams() {
|
|
4
|
+
return (nextInit, navigateOptions = {}) => {
|
|
5
|
+
if (!isBrowser) return;
|
|
6
|
+
const currentUrl = new URL(window.location.href);
|
|
7
|
+
let newSearchParams;
|
|
8
|
+
if (typeof nextInit === "function") {
|
|
9
|
+
newSearchParams = nextInit(new URLSearchParams(currentUrl.search));
|
|
10
|
+
} else if (nextInit instanceof URLSearchParams) {
|
|
11
|
+
newSearchParams = nextInit;
|
|
12
|
+
} else {
|
|
13
|
+
newSearchParams = new URLSearchParams();
|
|
14
|
+
for (const [key, value] of Object.entries(nextInit)) {
|
|
15
|
+
if (Array.isArray(value)) {
|
|
16
|
+
for (const v of value) {
|
|
17
|
+
newSearchParams.append(key, v);
|
|
18
|
+
}
|
|
19
|
+
} else {
|
|
20
|
+
newSearchParams.set(key, value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const newUrl = `${currentUrl.pathname}${newSearchParams.toString() ? `?${newSearchParams.toString()}` : ""}${currentUrl.hash}`;
|
|
25
|
+
if (navigateOptions.replace) {
|
|
26
|
+
window.history.replaceState(navigateOptions.state ?? null, "", newUrl);
|
|
27
|
+
} else {
|
|
28
|
+
window.history.pushState(navigateOptions.state ?? null, "", newUrl);
|
|
29
|
+
}
|
|
30
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
var globalSetSearchParams = createSetSearchParams();
|
|
3
34
|
var currentContext = {
|
|
4
35
|
path: "/",
|
|
5
36
|
searchParams: new URLSearchParams(),
|
|
37
|
+
setSearchParams: globalSetSearchParams,
|
|
6
38
|
navigate: () => {
|
|
7
39
|
},
|
|
8
40
|
back: () => {
|
|
@@ -56,6 +88,7 @@ function initRouter(options = {}) {
|
|
|
56
88
|
currentContext = {
|
|
57
89
|
path,
|
|
58
90
|
searchParams,
|
|
91
|
+
setSearchParams: globalSetSearchParams,
|
|
59
92
|
navigate: navigateTo,
|
|
60
93
|
back: () => isBrowser && window.history.back(),
|
|
61
94
|
forward: () => isBrowser && window.history.forward()
|
|
@@ -117,6 +150,7 @@ if (typeof globalThis !== "undefined") {
|
|
|
117
150
|
return {
|
|
118
151
|
path: basePath && path.startsWith(basePath) ? path.slice(basePath.length) || "/" : path,
|
|
119
152
|
searchParams,
|
|
153
|
+
setSearchParams: globalSetSearchParams,
|
|
120
154
|
navigate: navigateTo,
|
|
121
155
|
back: () => isBrowser && window.history.back(),
|
|
122
156
|
forward: () => isBrowser && window.history.forward()
|
|
@@ -556,7 +590,7 @@ function Link({
|
|
|
556
590
|
}
|
|
557
591
|
|
|
558
592
|
// src/react/RouterProvider.tsx
|
|
559
|
-
import { createContext, useContext, useState, useEffect as useEffect2 } from "react";
|
|
593
|
+
import { createContext, useContext, useState, useEffect as useEffect2, useCallback as useCallback2 } from "react";
|
|
560
594
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
561
595
|
var isBrowser6 = typeof window !== "undefined";
|
|
562
596
|
function navigateTo2(to, options = {}) {
|
|
@@ -571,9 +605,12 @@ function navigateTo2(to, options = {}) {
|
|
|
571
605
|
window.scrollTo({ top: 0, left: 0, behavior: "instant" });
|
|
572
606
|
}
|
|
573
607
|
}
|
|
608
|
+
var defaultSetSearchParams = () => {
|
|
609
|
+
};
|
|
574
610
|
var defaultContext = {
|
|
575
611
|
path: "/",
|
|
576
612
|
searchParams: new URLSearchParams(),
|
|
613
|
+
setSearchParams: defaultSetSearchParams,
|
|
577
614
|
navigate: navigateTo2,
|
|
578
615
|
back: () => isBrowser6 && window.history.back(),
|
|
579
616
|
forward: () => isBrowser6 && window.history.forward()
|
|
@@ -587,6 +624,30 @@ function RouterProvider2({
|
|
|
587
624
|
initialPath,
|
|
588
625
|
basePath = ""
|
|
589
626
|
}) {
|
|
627
|
+
const setSearchParamsCallback = useCallback2((nextInit, navigateOptions = {}) => {
|
|
628
|
+
if (!isBrowser6) return;
|
|
629
|
+
const currentUrl = new URL(window.location.href);
|
|
630
|
+
let newSearchParams;
|
|
631
|
+
if (typeof nextInit === "function") {
|
|
632
|
+
newSearchParams = nextInit(new URLSearchParams(currentUrl.search));
|
|
633
|
+
} else if (nextInit instanceof URLSearchParams) {
|
|
634
|
+
newSearchParams = nextInit;
|
|
635
|
+
} else {
|
|
636
|
+
newSearchParams = new URLSearchParams();
|
|
637
|
+
for (const [key, value] of Object.entries(nextInit)) {
|
|
638
|
+
if (Array.isArray(value)) {
|
|
639
|
+
for (const v of value) {
|
|
640
|
+
newSearchParams.append(key, v);
|
|
641
|
+
}
|
|
642
|
+
} else {
|
|
643
|
+
newSearchParams.set(key, value);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
const newUrl = `${currentUrl.pathname}${newSearchParams.toString() ? `?${newSearchParams.toString()}` : ""}${currentUrl.hash}`;
|
|
648
|
+
navigateTo2(newUrl, { replace: navigateOptions.replace ?? false, scroll: false, state: navigateOptions.state });
|
|
649
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
650
|
+
}, []);
|
|
590
651
|
const [routerState, setRouterState] = useState(() => {
|
|
591
652
|
const path = isBrowser6 ? window.location.pathname : initialPath || "/";
|
|
592
653
|
const searchParams = isBrowser6 ? new URLSearchParams(window.location.search) : new URLSearchParams();
|
|
@@ -597,6 +658,7 @@ function RouterProvider2({
|
|
|
597
658
|
return {
|
|
598
659
|
path: normalizedPath,
|
|
599
660
|
searchParams,
|
|
661
|
+
setSearchParams: setSearchParamsCallback,
|
|
600
662
|
navigate: navigateTo2,
|
|
601
663
|
back: () => isBrowser6 && window.history.back(),
|
|
602
664
|
forward: () => isBrowser6 && window.history.forward()
|
|
@@ -661,8 +723,8 @@ function usePathname() {
|
|
|
661
723
|
);
|
|
662
724
|
}
|
|
663
725
|
function useSearchParams() {
|
|
664
|
-
const { searchParams } = useContext2(RouterContext2);
|
|
665
|
-
return searchParams;
|
|
726
|
+
const { searchParams, setSearchParams } = useContext2(RouterContext2);
|
|
727
|
+
return [searchParams, setSearchParams];
|
|
666
728
|
}
|
|
667
729
|
function useParams() {
|
|
668
730
|
return {};
|
package/dist/solid/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PrefetchStrategy, b as RouterProviderProps, a as RouterContextValue } from '../prefetch-
|
|
2
|
-
export { L as LinkProps, N as NavigateOptions, d as PrefetchOptions, c as PrefetchPriority, R as RouteParams, S as SearchParams, w as clearPrefetchCache, l as findRoute, o as generatePath,
|
|
1
|
+
import { P as PrefetchStrategy, b as RouterProviderProps, a as RouterContextValue } from '../prefetch-C_RFFXW0.js';
|
|
2
|
+
export { L as LinkProps, N as NavigateOptions, d as PrefetchOptions, c as PrefetchPriority, R as RouteParams, S as SearchParams, w as clearPrefetchCache, l as findRoute, o as generatePath, C as getRouterContext, E as initRouter, q as isActive, v as isPrefetched, m as matchRoute, n as navigate, x as observeForPrefetch, p as parseParams, s as prefetch, t as prefetchAll, z as prefetchPages, A as prefetchWhenIdle, r as redirect, y as setupIntentPrefetch, D as subscribe } from '../prefetch-C_RFFXW0.js';
|
|
3
3
|
import * as solid_js from 'solid-js';
|
|
4
4
|
import { JSX, Accessor } from 'solid-js';
|
|
5
5
|
|
|
@@ -69,7 +69,7 @@ declare function useRouter(): RouterContextValue;
|
|
|
69
69
|
*/
|
|
70
70
|
declare function usePathname(): Accessor<string>;
|
|
71
71
|
/**
|
|
72
|
-
* Hook to get current search params
|
|
72
|
+
* Hook to get and set current search params
|
|
73
73
|
*/
|
|
74
74
|
declare function useSearchParams(): Accessor<URLSearchParams>;
|
|
75
75
|
/**
|
package/dist/solid/index.js
CHANGED
|
@@ -1,8 +1,40 @@
|
|
|
1
1
|
// src/context.ts
|
|
2
2
|
var isBrowser = typeof window !== "undefined";
|
|
3
|
+
function createSetSearchParams() {
|
|
4
|
+
return (nextInit, navigateOptions = {}) => {
|
|
5
|
+
if (!isBrowser) return;
|
|
6
|
+
const currentUrl = new URL(window.location.href);
|
|
7
|
+
let newSearchParams;
|
|
8
|
+
if (typeof nextInit === "function") {
|
|
9
|
+
newSearchParams = nextInit(new URLSearchParams(currentUrl.search));
|
|
10
|
+
} else if (nextInit instanceof URLSearchParams) {
|
|
11
|
+
newSearchParams = nextInit;
|
|
12
|
+
} else {
|
|
13
|
+
newSearchParams = new URLSearchParams();
|
|
14
|
+
for (const [key, value] of Object.entries(nextInit)) {
|
|
15
|
+
if (Array.isArray(value)) {
|
|
16
|
+
for (const v of value) {
|
|
17
|
+
newSearchParams.append(key, v);
|
|
18
|
+
}
|
|
19
|
+
} else {
|
|
20
|
+
newSearchParams.set(key, value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const newUrl = `${currentUrl.pathname}${newSearchParams.toString() ? `?${newSearchParams.toString()}` : ""}${currentUrl.hash}`;
|
|
25
|
+
if (navigateOptions.replace) {
|
|
26
|
+
window.history.replaceState(navigateOptions.state ?? null, "", newUrl);
|
|
27
|
+
} else {
|
|
28
|
+
window.history.pushState(navigateOptions.state ?? null, "", newUrl);
|
|
29
|
+
}
|
|
30
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
var globalSetSearchParams = createSetSearchParams();
|
|
3
34
|
var currentContext = {
|
|
4
35
|
path: "/",
|
|
5
36
|
searchParams: new URLSearchParams(),
|
|
37
|
+
setSearchParams: globalSetSearchParams,
|
|
6
38
|
navigate: () => {
|
|
7
39
|
},
|
|
8
40
|
back: () => {
|
|
@@ -56,6 +88,7 @@ function initRouter(options = {}) {
|
|
|
56
88
|
currentContext = {
|
|
57
89
|
path,
|
|
58
90
|
searchParams,
|
|
91
|
+
setSearchParams: globalSetSearchParams,
|
|
59
92
|
navigate: navigateTo,
|
|
60
93
|
back: () => isBrowser && window.history.back(),
|
|
61
94
|
forward: () => isBrowser && window.history.forward()
|
|
@@ -117,6 +150,7 @@ if (typeof globalThis !== "undefined") {
|
|
|
117
150
|
return {
|
|
118
151
|
path: basePath && path.startsWith(basePath) ? path.slice(basePath.length) || "/" : path,
|
|
119
152
|
searchParams,
|
|
153
|
+
setSearchParams: globalSetSearchParams,
|
|
120
154
|
navigate: navigateTo,
|
|
121
155
|
back: () => isBrowser && window.history.back(),
|
|
122
156
|
forward: () => isBrowser && window.history.forward()
|
|
@@ -539,9 +573,41 @@ function navigateTo2(to, options = {}) {
|
|
|
539
573
|
window.scrollTo({ top: 0, left: 0, behavior: "instant" });
|
|
540
574
|
}
|
|
541
575
|
}
|
|
576
|
+
function createSetSearchParams2() {
|
|
577
|
+
return (nextInit, navigateOptions = {}) => {
|
|
578
|
+
if (!isBrowser6) return;
|
|
579
|
+
const currentUrl = new URL(window.location.href);
|
|
580
|
+
let newSearchParams;
|
|
581
|
+
if (typeof nextInit === "function") {
|
|
582
|
+
newSearchParams = nextInit(new URLSearchParams(currentUrl.search));
|
|
583
|
+
} else if (nextInit instanceof URLSearchParams) {
|
|
584
|
+
newSearchParams = nextInit;
|
|
585
|
+
} else {
|
|
586
|
+
newSearchParams = new URLSearchParams();
|
|
587
|
+
for (const [key, value] of Object.entries(nextInit)) {
|
|
588
|
+
if (Array.isArray(value)) {
|
|
589
|
+
for (const v of value) {
|
|
590
|
+
newSearchParams.append(key, v);
|
|
591
|
+
}
|
|
592
|
+
} else {
|
|
593
|
+
newSearchParams.set(key, value);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
const newUrl = `${currentUrl.pathname}${newSearchParams.toString() ? `?${newSearchParams.toString()}` : ""}${currentUrl.hash}`;
|
|
598
|
+
if (navigateOptions.replace) {
|
|
599
|
+
window.history.replaceState(navigateOptions.state ?? null, "", newUrl);
|
|
600
|
+
} else {
|
|
601
|
+
window.history.pushState(navigateOptions.state ?? null, "", newUrl);
|
|
602
|
+
}
|
|
603
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
var globalSetSearchParams2 = createSetSearchParams2();
|
|
542
607
|
var defaultContext = {
|
|
543
608
|
path: "/",
|
|
544
609
|
searchParams: new URLSearchParams(),
|
|
610
|
+
setSearchParams: globalSetSearchParams2,
|
|
545
611
|
navigate: navigateTo2,
|
|
546
612
|
back: () => isBrowser6 && window.history.back(),
|
|
547
613
|
forward: () => isBrowser6 && window.history.forward()
|
|
@@ -572,6 +638,7 @@ function createRouterProvider(options = {}) {
|
|
|
572
638
|
const getRouterContext2 = () => ({
|
|
573
639
|
path: path(),
|
|
574
640
|
searchParams: searchParams(),
|
|
641
|
+
setSearchParams: globalSetSearchParams2,
|
|
575
642
|
navigate: navigateTo2,
|
|
576
643
|
back: () => isBrowser6 && window.history.back(),
|
|
577
644
|
forward: () => isBrowser6 && window.history.forward()
|
package/dist/svelte/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PrefetchStrategy, a as RouterContextValue } from '../prefetch-
|
|
2
|
-
export { L as LinkProps, N as NavigateOptions, d as PrefetchOptions, c as PrefetchPriority, R as RouteParams, b as RouterProviderProps, S as SearchParams, w as clearPrefetchCache, l as findRoute, o as generatePath,
|
|
1
|
+
import { P as PrefetchStrategy, a as RouterContextValue } from '../prefetch-C_RFFXW0.js';
|
|
2
|
+
export { L as LinkProps, N as NavigateOptions, d as PrefetchOptions, c as PrefetchPriority, R as RouteParams, b as RouterProviderProps, S as SearchParams, w as clearPrefetchCache, l as findRoute, o as generatePath, C as getRouterContext, E as initRouter, q as isActive, v as isPrefetched, m as matchRoute, n as navigate, x as observeForPrefetch, p as parseParams, s as prefetch, t as prefetchAll, z as prefetchPages, A as prefetchWhenIdle, r as redirect, y as setupIntentPrefetch, D as subscribe } from '../prefetch-C_RFFXW0.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Svelte Link Component
|
package/dist/svelte/index.js
CHANGED
|
@@ -1,8 +1,40 @@
|
|
|
1
1
|
// src/context.ts
|
|
2
2
|
var isBrowser = typeof window !== "undefined";
|
|
3
|
+
function createSetSearchParams() {
|
|
4
|
+
return (nextInit, navigateOptions = {}) => {
|
|
5
|
+
if (!isBrowser) return;
|
|
6
|
+
const currentUrl = new URL(window.location.href);
|
|
7
|
+
let newSearchParams;
|
|
8
|
+
if (typeof nextInit === "function") {
|
|
9
|
+
newSearchParams = nextInit(new URLSearchParams(currentUrl.search));
|
|
10
|
+
} else if (nextInit instanceof URLSearchParams) {
|
|
11
|
+
newSearchParams = nextInit;
|
|
12
|
+
} else {
|
|
13
|
+
newSearchParams = new URLSearchParams();
|
|
14
|
+
for (const [key, value] of Object.entries(nextInit)) {
|
|
15
|
+
if (Array.isArray(value)) {
|
|
16
|
+
for (const v of value) {
|
|
17
|
+
newSearchParams.append(key, v);
|
|
18
|
+
}
|
|
19
|
+
} else {
|
|
20
|
+
newSearchParams.set(key, value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const newUrl = `${currentUrl.pathname}${newSearchParams.toString() ? `?${newSearchParams.toString()}` : ""}${currentUrl.hash}`;
|
|
25
|
+
if (navigateOptions.replace) {
|
|
26
|
+
window.history.replaceState(navigateOptions.state ?? null, "", newUrl);
|
|
27
|
+
} else {
|
|
28
|
+
window.history.pushState(navigateOptions.state ?? null, "", newUrl);
|
|
29
|
+
}
|
|
30
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
var globalSetSearchParams = createSetSearchParams();
|
|
3
34
|
var currentContext = {
|
|
4
35
|
path: "/",
|
|
5
36
|
searchParams: new URLSearchParams(),
|
|
37
|
+
setSearchParams: globalSetSearchParams,
|
|
6
38
|
navigate: () => {
|
|
7
39
|
},
|
|
8
40
|
back: () => {
|
|
@@ -56,6 +88,7 @@ function initRouter(options = {}) {
|
|
|
56
88
|
currentContext = {
|
|
57
89
|
path,
|
|
58
90
|
searchParams,
|
|
91
|
+
setSearchParams: globalSetSearchParams,
|
|
59
92
|
navigate: navigateTo,
|
|
60
93
|
back: () => isBrowser && window.history.back(),
|
|
61
94
|
forward: () => isBrowser && window.history.forward()
|
|
@@ -117,6 +150,7 @@ if (typeof globalThis !== "undefined") {
|
|
|
117
150
|
return {
|
|
118
151
|
path: basePath && path.startsWith(basePath) ? path.slice(basePath.length) || "/" : path,
|
|
119
152
|
searchParams,
|
|
153
|
+
setSearchParams: globalSetSearchParams,
|
|
120
154
|
navigate: navigateTo,
|
|
121
155
|
back: () => isBrowser && window.history.back(),
|
|
122
156
|
forward: () => isBrowser && window.history.forward()
|
package/dist/vue/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PrefetchStrategy, b as RouterProviderProps, a as RouterContextValue } from '../prefetch-
|
|
2
|
-
export { L as LinkProps, N as NavigateOptions, d as PrefetchOptions, c as PrefetchPriority, R as RouteParams, S as SearchParams, w as clearPrefetchCache, l as findRoute, o as generatePath,
|
|
1
|
+
import { P as PrefetchStrategy, b as RouterProviderProps, a as RouterContextValue } from '../prefetch-C_RFFXW0.js';
|
|
2
|
+
export { L as LinkProps, N as NavigateOptions, d as PrefetchOptions, c as PrefetchPriority, R as RouteParams, S as SearchParams, w as clearPrefetchCache, l as findRoute, o as generatePath, C as getRouterContext, E as initRouter, q as isActive, v as isPrefetched, m as matchRoute, n as navigate, x as observeForPrefetch, p as parseParams, s as prefetch, t as prefetchAll, z as prefetchPages, A as prefetchWhenIdle, r as redirect, y as setupIntentPrefetch, D as subscribe } from '../prefetch-C_RFFXW0.js';
|
|
3
3
|
import * as vue from 'vue';
|
|
4
4
|
import { PropType, Ref } from 'vue';
|
|
5
5
|
|
package/dist/vue/index.js
CHANGED
|
@@ -1,8 +1,40 @@
|
|
|
1
1
|
// src/context.ts
|
|
2
2
|
var isBrowser = typeof window !== "undefined";
|
|
3
|
+
function createSetSearchParams() {
|
|
4
|
+
return (nextInit, navigateOptions = {}) => {
|
|
5
|
+
if (!isBrowser) return;
|
|
6
|
+
const currentUrl = new URL(window.location.href);
|
|
7
|
+
let newSearchParams;
|
|
8
|
+
if (typeof nextInit === "function") {
|
|
9
|
+
newSearchParams = nextInit(new URLSearchParams(currentUrl.search));
|
|
10
|
+
} else if (nextInit instanceof URLSearchParams) {
|
|
11
|
+
newSearchParams = nextInit;
|
|
12
|
+
} else {
|
|
13
|
+
newSearchParams = new URLSearchParams();
|
|
14
|
+
for (const [key, value] of Object.entries(nextInit)) {
|
|
15
|
+
if (Array.isArray(value)) {
|
|
16
|
+
for (const v of value) {
|
|
17
|
+
newSearchParams.append(key, v);
|
|
18
|
+
}
|
|
19
|
+
} else {
|
|
20
|
+
newSearchParams.set(key, value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const newUrl = `${currentUrl.pathname}${newSearchParams.toString() ? `?${newSearchParams.toString()}` : ""}${currentUrl.hash}`;
|
|
25
|
+
if (navigateOptions.replace) {
|
|
26
|
+
window.history.replaceState(navigateOptions.state ?? null, "", newUrl);
|
|
27
|
+
} else {
|
|
28
|
+
window.history.pushState(navigateOptions.state ?? null, "", newUrl);
|
|
29
|
+
}
|
|
30
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
var globalSetSearchParams = createSetSearchParams();
|
|
3
34
|
var currentContext = {
|
|
4
35
|
path: "/",
|
|
5
36
|
searchParams: new URLSearchParams(),
|
|
37
|
+
setSearchParams: globalSetSearchParams,
|
|
6
38
|
navigate: () => {
|
|
7
39
|
},
|
|
8
40
|
back: () => {
|
|
@@ -56,6 +88,7 @@ function initRouter(options = {}) {
|
|
|
56
88
|
currentContext = {
|
|
57
89
|
path,
|
|
58
90
|
searchParams,
|
|
91
|
+
setSearchParams: globalSetSearchParams,
|
|
59
92
|
navigate: navigateTo,
|
|
60
93
|
back: () => isBrowser && window.history.back(),
|
|
61
94
|
forward: () => isBrowser && window.history.forward()
|
|
@@ -117,6 +150,7 @@ if (typeof globalThis !== "undefined") {
|
|
|
117
150
|
return {
|
|
118
151
|
path: basePath && path.startsWith(basePath) ? path.slice(basePath.length) || "/" : path,
|
|
119
152
|
searchParams,
|
|
153
|
+
setSearchParams: globalSetSearchParams,
|
|
120
154
|
navigate: navigateTo,
|
|
121
155
|
back: () => isBrowser && window.history.back(),
|
|
122
156
|
forward: () => isBrowser && window.history.forward()
|
|
@@ -566,12 +600,44 @@ function navigateTo2(to, options = {}) {
|
|
|
566
600
|
window.scrollTo({ top: 0, left: 0, behavior: "instant" });
|
|
567
601
|
}
|
|
568
602
|
}
|
|
603
|
+
function createSetSearchParams2() {
|
|
604
|
+
return (nextInit, navigateOptions = {}) => {
|
|
605
|
+
if (!isBrowser6) return;
|
|
606
|
+
const currentUrl = new URL(window.location.href);
|
|
607
|
+
let newSearchParams;
|
|
608
|
+
if (typeof nextInit === "function") {
|
|
609
|
+
newSearchParams = nextInit(new URLSearchParams(currentUrl.search));
|
|
610
|
+
} else if (nextInit instanceof URLSearchParams) {
|
|
611
|
+
newSearchParams = nextInit;
|
|
612
|
+
} else {
|
|
613
|
+
newSearchParams = new URLSearchParams();
|
|
614
|
+
for (const [key, value] of Object.entries(nextInit)) {
|
|
615
|
+
if (Array.isArray(value)) {
|
|
616
|
+
for (const v of value) {
|
|
617
|
+
newSearchParams.append(key, v);
|
|
618
|
+
}
|
|
619
|
+
} else {
|
|
620
|
+
newSearchParams.set(key, value);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
const newUrl = `${currentUrl.pathname}${newSearchParams.toString() ? `?${newSearchParams.toString()}` : ""}${currentUrl.hash}`;
|
|
625
|
+
if (navigateOptions.replace) {
|
|
626
|
+
window.history.replaceState(navigateOptions.state ?? null, "", newUrl);
|
|
627
|
+
} else {
|
|
628
|
+
window.history.pushState(navigateOptions.state ?? null, "", newUrl);
|
|
629
|
+
}
|
|
630
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
var globalSetSearchParams2 = createSetSearchParams2();
|
|
569
634
|
function RouterProvider2(props, { slots }) {
|
|
570
635
|
const path = ref2(isBrowser6 ? window.location.pathname : props.initialPath || "/");
|
|
571
636
|
const searchParams = ref2(isBrowser6 ? new URLSearchParams(window.location.search) : new URLSearchParams());
|
|
572
637
|
const routerState = ref2({
|
|
573
638
|
path: path.value,
|
|
574
639
|
searchParams: searchParams.value,
|
|
640
|
+
setSearchParams: globalSetSearchParams2,
|
|
575
641
|
navigate: navigateTo2,
|
|
576
642
|
back: () => isBrowser6 && window.history.back(),
|
|
577
643
|
forward: () => isBrowser6 && window.history.forward()
|