@solidjs/router 0.14.2 → 0.14.4
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/data/createAsync.js +2 -2
- package/dist/index.js +10 -9
- package/dist/routers/Router.js +3 -2
- package/dist/routers/StaticRouter.js +1 -2
- package/dist/routing.js +7 -3
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/data/createAsync.js
CHANGED
|
@@ -33,13 +33,13 @@ export function createAsyncStore(fn, options = {}) {
|
|
|
33
33
|
}
|
|
34
34
|
function createDeepSignal(value, options) {
|
|
35
35
|
const [store, setStore] = createStore({
|
|
36
|
-
value
|
|
36
|
+
value: structuredClone(value)
|
|
37
37
|
});
|
|
38
38
|
return [
|
|
39
39
|
() => store.value,
|
|
40
40
|
(v) => {
|
|
41
41
|
typeof v === "function" && (v = v());
|
|
42
|
-
setStore("value", reconcile(v, options));
|
|
42
|
+
setStore("value", reconcile(structuredClone(v), options));
|
|
43
43
|
return store.value;
|
|
44
44
|
}
|
|
45
45
|
];
|
package/dist/index.js
CHANGED
|
@@ -263,7 +263,7 @@ const useSearchParams = () => {
|
|
|
263
263
|
const location = useLocation();
|
|
264
264
|
const navigate = useNavigate();
|
|
265
265
|
const setSearchParams = (params, options) => {
|
|
266
|
-
const searchString = untrack(() =>
|
|
266
|
+
const searchString = untrack(() => mergeSearchString(location.search, params) + location.hash);
|
|
267
267
|
navigate(searchString, {
|
|
268
268
|
scroll: false,
|
|
269
269
|
resolve: false,
|
|
@@ -520,6 +520,7 @@ function createRouterContext(integration, branches, getContext, options = {}) {
|
|
|
520
520
|
}
|
|
521
521
|
return;
|
|
522
522
|
}
|
|
523
|
+
const queryOnly = !to || to[0] === "?";
|
|
523
524
|
const {
|
|
524
525
|
replace,
|
|
525
526
|
resolve,
|
|
@@ -527,11 +528,11 @@ function createRouterContext(integration, branches, getContext, options = {}) {
|
|
|
527
528
|
state: nextState
|
|
528
529
|
} = {
|
|
529
530
|
replace: false,
|
|
530
|
-
resolve:
|
|
531
|
+
resolve: !queryOnly,
|
|
531
532
|
scroll: true,
|
|
532
533
|
...options
|
|
533
534
|
};
|
|
534
|
-
const resolvedTo = resolve ? route.resolvePath(to) : resolvePath("", to);
|
|
535
|
+
const resolvedTo = resolve ? route.resolvePath(to) : resolvePath(queryOnly && location.pathname || "", to);
|
|
535
536
|
if (resolvedTo === undefined) {
|
|
536
537
|
throw new Error(`Path '${to}' is not a routable path`);
|
|
537
538
|
} else if (referrers.length >= MAX_REDIRECTS) {
|
|
@@ -873,9 +874,8 @@ function getPath(url) {
|
|
|
873
874
|
}
|
|
874
875
|
function StaticRouter(props) {
|
|
875
876
|
let e;
|
|
876
|
-
const url = props.url || (e = getRequestEvent()) && getPath(e.request.url) || "";
|
|
877
877
|
const obj = {
|
|
878
|
-
value: props.
|
|
878
|
+
value: props.url || (e = getRequestEvent()) && getPath(e.request.url) || ""
|
|
879
879
|
};
|
|
880
880
|
return createRouterComponent({
|
|
881
881
|
signal: [() => obj, next => Object.assign(obj, next)]
|
|
@@ -1315,9 +1315,10 @@ function Router(props) {
|
|
|
1315
1315
|
if (isServer) return StaticRouter(props);
|
|
1316
1316
|
const getSource = () => {
|
|
1317
1317
|
const url = window.location.pathname.replace(/^\/+/, "/") + window.location.search;
|
|
1318
|
+
const state = window.history.state && window.history.state._depth && Object.keys(window.history.state).length === 1 ? undefined : window.history.state;
|
|
1318
1319
|
return {
|
|
1319
|
-
value:
|
|
1320
|
-
state
|
|
1320
|
+
value: url + window.location.hash,
|
|
1321
|
+
state
|
|
1321
1322
|
};
|
|
1322
1323
|
};
|
|
1323
1324
|
const beforeLeave = createBeforeLeave();
|
|
@@ -1558,11 +1559,11 @@ function createAsyncStore(fn, options = {}) {
|
|
|
1558
1559
|
}
|
|
1559
1560
|
function createDeepSignal(value, options) {
|
|
1560
1561
|
const [store, setStore] = createStore({
|
|
1561
|
-
value
|
|
1562
|
+
value: structuredClone(value)
|
|
1562
1563
|
});
|
|
1563
1564
|
return [() => store.value, v => {
|
|
1564
1565
|
typeof v === "function" && (v = v());
|
|
1565
|
-
setStore("value", reconcile(v, options));
|
|
1566
|
+
setStore("value", reconcile(structuredClone(v), options));
|
|
1566
1567
|
return store.value;
|
|
1567
1568
|
}];
|
|
1568
1569
|
}
|
package/dist/routers/Router.js
CHANGED
|
@@ -8,9 +8,10 @@ export function Router(props) {
|
|
|
8
8
|
return StaticRouter(props);
|
|
9
9
|
const getSource = () => {
|
|
10
10
|
const url = window.location.pathname.replace(/^\/+/, "/") + window.location.search;
|
|
11
|
+
const state = window.history.state && window.history.state._depth && Object.keys(window.history.state).length === 1 ? undefined : window.history.state;
|
|
11
12
|
return {
|
|
12
|
-
value:
|
|
13
|
-
state
|
|
13
|
+
value: url + window.location.hash,
|
|
14
|
+
state
|
|
14
15
|
};
|
|
15
16
|
};
|
|
16
17
|
const beforeLeave = createBeforeLeave();
|
|
@@ -6,9 +6,8 @@ function getPath(url) {
|
|
|
6
6
|
}
|
|
7
7
|
export function StaticRouter(props) {
|
|
8
8
|
let e;
|
|
9
|
-
const url = props.url || ((e = getRequestEvent()) && getPath(e.request.url)) || "";
|
|
10
9
|
const obj = {
|
|
11
|
-
value: props.
|
|
10
|
+
value: props.url || ((e = getRequestEvent()) && getPath(e.request.url)) || "",
|
|
12
11
|
};
|
|
13
12
|
return createRouterComponent({
|
|
14
13
|
signal: [() => obj, next => Object.assign(obj, next)]
|
package/dist/routing.js
CHANGED
|
@@ -41,7 +41,7 @@ export const useSearchParams = () => {
|
|
|
41
41
|
const location = useLocation();
|
|
42
42
|
const navigate = useNavigate();
|
|
43
43
|
const setSearchParams = (params, options) => {
|
|
44
|
-
const searchString = untrack(() =>
|
|
44
|
+
const searchString = untrack(() => mergeSearchString(location.search, params) + location.hash);
|
|
45
45
|
navigate(searchString, {
|
|
46
46
|
scroll: false,
|
|
47
47
|
resolve: false,
|
|
@@ -295,13 +295,17 @@ export function createRouterContext(integration, branches, getContext, options =
|
|
|
295
295
|
}
|
|
296
296
|
return;
|
|
297
297
|
}
|
|
298
|
+
const queryOnly = !to || to[0] === "?";
|
|
298
299
|
const { replace, resolve, scroll, state: nextState } = {
|
|
299
300
|
replace: false,
|
|
300
|
-
resolve:
|
|
301
|
+
resolve: !queryOnly,
|
|
301
302
|
scroll: true,
|
|
302
303
|
...options
|
|
303
304
|
};
|
|
304
|
-
|
|
305
|
+
let s;
|
|
306
|
+
const resolvedTo = resolve
|
|
307
|
+
? route.resolvePath(to)
|
|
308
|
+
: resolvePath((queryOnly && location.pathname) || "", to);
|
|
305
309
|
if (resolvedTo === undefined) {
|
|
306
310
|
throw new Error(`Path '${to}' is not a routable path`);
|
|
307
311
|
}
|
package/dist/types.d.ts
CHANGED