@solidjs/router 0.17.0-next.1 → 0.17.0-next.3
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/query.js +2 -2
- package/dist/index.js +28 -34
- package/dist/routers/components.jsx +1 -1
- package/dist/routers/createRouter.js +9 -10
- package/dist/routing.d.ts +1 -1
- package/dist/routing.js +12 -23
- package/package.json +7 -7
package/dist/data/query.js
CHANGED
|
@@ -113,7 +113,7 @@ export function query(fn, name) {
|
|
|
113
113
|
!isServer && intent === "navigate" && cached[4][1](cached[0]); // update version
|
|
114
114
|
}
|
|
115
115
|
else {
|
|
116
|
-
cache.set(key, (cached = [now, res, , intent, createSignal(now)]));
|
|
116
|
+
cache.set(key, (cached = [now, res, , intent, createSignal(now, { ownedWrite: true })]));
|
|
117
117
|
cached[4].count = 0;
|
|
118
118
|
}
|
|
119
119
|
if (tracking) {
|
|
@@ -193,7 +193,7 @@ query.set = (key, value) => {
|
|
|
193
193
|
cached[3] = "preload";
|
|
194
194
|
}
|
|
195
195
|
else {
|
|
196
|
-
cache.set(key, (cached = [now, Promise.resolve(value), value, "preload", createSignal(now)]));
|
|
196
|
+
cache.set(key, (cached = [now, Promise.resolve(value), value, "preload", createSignal(now, { ownedWrite: true })]));
|
|
197
197
|
cached[4].count = 0;
|
|
198
198
|
}
|
|
199
199
|
};
|
package/dist/index.js
CHANGED
|
@@ -380,7 +380,7 @@ const useCurrentMatches = () => useRouter().matches;
|
|
|
380
380
|
* const params = useParams();
|
|
381
381
|
*
|
|
382
382
|
* // fetch user based on the id path parameter
|
|
383
|
-
* const
|
|
383
|
+
* const getUser = query(() => fetchUser(params.id), "user");
|
|
384
384
|
* ```
|
|
385
385
|
*/
|
|
386
386
|
const useParams = () => useRouter().params;
|
|
@@ -551,7 +551,7 @@ function getRouteMatches(branches, location) {
|
|
|
551
551
|
}
|
|
552
552
|
function createLocation(path, state, queryWrapper) {
|
|
553
553
|
const origin = new URL(mockBase);
|
|
554
|
-
const url = createMemo(prev => {
|
|
554
|
+
const url = createMemo((prev = origin) => {
|
|
555
555
|
const path_ = path();
|
|
556
556
|
try {
|
|
557
557
|
return new URL(path_, origin);
|
|
@@ -559,11 +559,11 @@ function createLocation(path, state, queryWrapper) {
|
|
|
559
559
|
console.error(`Invalid path ${path_}`);
|
|
560
560
|
return prev;
|
|
561
561
|
}
|
|
562
|
-
},
|
|
562
|
+
}, {
|
|
563
563
|
equals: (a, b) => a.href === b.href
|
|
564
564
|
});
|
|
565
565
|
const pathname = createMemo(() => url().pathname);
|
|
566
|
-
const search = createMemo(() => url().search
|
|
566
|
+
const search = createMemo(() => url().search);
|
|
567
567
|
const hash = createMemo(() => url().hash);
|
|
568
568
|
const key = () => "";
|
|
569
569
|
const queryFn = createMemo(() => extractSearchParams(url()));
|
|
@@ -617,12 +617,12 @@ function createRouterContext(integration, branches, getContext, options = {}) {
|
|
|
617
617
|
});
|
|
618
618
|
}
|
|
619
619
|
const [isRouting, setIsRouting] = createSignal(false, {
|
|
620
|
-
|
|
620
|
+
ownedWrite: true
|
|
621
621
|
});
|
|
622
622
|
|
|
623
623
|
// Navigate override written from event handlers.
|
|
624
624
|
const [navigateTarget, setNavigateTarget] = createSignal(undefined, {
|
|
625
|
-
|
|
625
|
+
ownedWrite: true
|
|
626
626
|
});
|
|
627
627
|
|
|
628
628
|
// Keep track of last target, so that last call to navigate wins
|
|
@@ -630,20 +630,11 @@ function createRouterContext(integration, branches, getContext, options = {}) {
|
|
|
630
630
|
|
|
631
631
|
// source() remains canonical for native history changes; navigateTarget()
|
|
632
632
|
// temporarily overrides it for in-flight programmatic navigation.
|
|
633
|
-
const
|
|
634
|
-
|
|
635
|
-
if (nav !== undefined) return nav.value;
|
|
636
|
-
return source().value;
|
|
637
|
-
});
|
|
638
|
-
const state = createMemo(() => {
|
|
639
|
-
const nav = navigateTarget();
|
|
640
|
-
if (nav !== undefined) return nav.state;
|
|
641
|
-
return source().state;
|
|
642
|
-
});
|
|
643
|
-
const location = createLocation(reference, state, utils.queryWrapper);
|
|
633
|
+
const effective = createMemo(() => navigateTarget() ?? source());
|
|
634
|
+
const location = createLocation(() => effective().value, () => effective().state, utils.queryWrapper);
|
|
644
635
|
const referrers = [];
|
|
645
636
|
const submissions = createSignal(isServer ? initFromFlash() : [], {
|
|
646
|
-
|
|
637
|
+
ownedWrite: true
|
|
647
638
|
});
|
|
648
639
|
const matches = createMemo(() => {
|
|
649
640
|
if (typeof options.transformUrl === "function") {
|
|
@@ -711,8 +702,8 @@ function createRouterContext(integration, branches, getContext, options = {}) {
|
|
|
711
702
|
} else if (referrers.length >= MAX_REDIRECTS) {
|
|
712
703
|
throw new Error("Too many redirects");
|
|
713
704
|
}
|
|
714
|
-
const current =
|
|
715
|
-
if (resolvedTo !== current || nextState !== state
|
|
705
|
+
const current = effective();
|
|
706
|
+
if (resolvedTo !== current.value || nextState !== current.state) {
|
|
716
707
|
if (isServer) {
|
|
717
708
|
const e = getRequestEvent();
|
|
718
709
|
e && (e.response = {
|
|
@@ -729,10 +720,10 @@ function createRouterContext(integration, branches, getContext, options = {}) {
|
|
|
729
720
|
});
|
|
730
721
|
} else if (beforeLeave.confirm(resolvedTo, options)) {
|
|
731
722
|
referrers.push({
|
|
732
|
-
value: current,
|
|
723
|
+
value: current.value,
|
|
733
724
|
replace,
|
|
734
725
|
scroll,
|
|
735
|
-
state: state
|
|
726
|
+
state: current.state
|
|
736
727
|
});
|
|
737
728
|
const newTarget = {
|
|
738
729
|
value: resolvedTo,
|
|
@@ -981,7 +972,7 @@ function Routes(props) {
|
|
|
981
972
|
root = next[0];
|
|
982
973
|
prevMatches = nextMatches;
|
|
983
974
|
return next;
|
|
984
|
-
}
|
|
975
|
+
});
|
|
985
976
|
const outlet = createOutlet(() => routeStates() && root);
|
|
986
977
|
return memo(outlet);
|
|
987
978
|
}
|
|
@@ -1027,21 +1018,20 @@ function dataOnly(event, routerState, branches) {
|
|
|
1027
1018
|
}
|
|
1028
1019
|
}
|
|
1029
1020
|
|
|
1030
|
-
function intercept([value, setValue], get, set) {
|
|
1031
|
-
return [value, set ? v => setValue(set(v)) : setValue];
|
|
1032
|
-
}
|
|
1033
1021
|
function createRouter(config) {
|
|
1034
1022
|
let ignore = false;
|
|
1035
1023
|
const wrap = value => typeof value === "string" ? {
|
|
1036
1024
|
value
|
|
1037
1025
|
} : value;
|
|
1038
|
-
const
|
|
1039
|
-
equals: (a, b) => a.value === b.value && a.state === b.state
|
|
1040
|
-
|
|
1026
|
+
const [read, write] = createSignal(wrap(config.get()), {
|
|
1027
|
+
equals: (a, b) => a.value === b.value && a.state === b.state,
|
|
1028
|
+
ownedWrite: true
|
|
1029
|
+
});
|
|
1030
|
+
const signal = [read, next => {
|
|
1041
1031
|
!ignore && config.set(next);
|
|
1042
1032
|
if (sharedConfig.registry && !sharedConfig.done) sharedConfig.done = true;
|
|
1043
|
-
|
|
1044
|
-
}
|
|
1033
|
+
write(next);
|
|
1034
|
+
}];
|
|
1045
1035
|
config.init && onCleanup(config.init((value = config.get()) => {
|
|
1046
1036
|
ignore = true;
|
|
1047
1037
|
signal[1](wrap(value));
|
|
@@ -1178,7 +1168,9 @@ function query(fn, name) {
|
|
|
1178
1168
|
cached[3] = intent;
|
|
1179
1169
|
!isServer && intent === "navigate" && cached[4][1](cached[0]); // update version
|
|
1180
1170
|
} else {
|
|
1181
|
-
cache.set(key, cached = [now, res,, intent, createSignal(now
|
|
1171
|
+
cache.set(key, cached = [now, res,, intent, createSignal(now, {
|
|
1172
|
+
ownedWrite: true
|
|
1173
|
+
})]);
|
|
1182
1174
|
cached[4].count = 0;
|
|
1183
1175
|
}
|
|
1184
1176
|
if (tracking) {
|
|
@@ -1242,7 +1234,9 @@ query.set = (key, value) => {
|
|
|
1242
1234
|
cached[2] = value;
|
|
1243
1235
|
cached[3] = "preload";
|
|
1244
1236
|
} else {
|
|
1245
|
-
cache.set(key, cached = [now, Promise.resolve(value), value, "preload", createSignal(now
|
|
1237
|
+
cache.set(key, cached = [now, Promise.resolve(value), value, "preload", createSignal(now, {
|
|
1238
|
+
ownedWrite: true
|
|
1239
|
+
})]);
|
|
1246
1240
|
cached[4].count = 0;
|
|
1247
1241
|
}
|
|
1248
1242
|
};
|
|
@@ -1762,7 +1756,7 @@ function A(props) {
|
|
|
1762
1756
|
get ["aria-current"]() {
|
|
1763
1757
|
return isActive()[1] ? "page" : undefined;
|
|
1764
1758
|
}
|
|
1765
|
-
}), false
|
|
1759
|
+
}), false);
|
|
1766
1760
|
return _el$;
|
|
1767
1761
|
})();
|
|
1768
1762
|
}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { createSignal, onCleanup, sharedConfig } from "solid-js";
|
|
2
2
|
import { createRouterComponent } from "./components.jsx";
|
|
3
|
-
function intercept([value, setValue], get, set) {
|
|
4
|
-
return [get ? () => get(value()) : value, set ? (v) => setValue(set(v)) : setValue];
|
|
5
|
-
}
|
|
6
3
|
export function createRouter(config) {
|
|
7
4
|
let ignore = false;
|
|
8
5
|
const wrap = (value) => (typeof value === "string" ? { value } : value);
|
|
9
|
-
const
|
|
10
|
-
equals: (a, b) => a.value === b.value && a.state === b.state
|
|
11
|
-
|
|
12
|
-
!ignore && config.set(next);
|
|
13
|
-
if (sharedConfig.registry && !sharedConfig.done)
|
|
14
|
-
sharedConfig.done = true;
|
|
15
|
-
return next;
|
|
6
|
+
const [read, write] = createSignal(wrap(config.get()), {
|
|
7
|
+
equals: (a, b) => a.value === b.value && a.state === b.state,
|
|
8
|
+
ownedWrite: true
|
|
16
9
|
});
|
|
10
|
+
const signal = [read, (next) => {
|
|
11
|
+
!ignore && config.set(next);
|
|
12
|
+
if (sharedConfig.registry && !sharedConfig.done)
|
|
13
|
+
sharedConfig.done = true;
|
|
14
|
+
write(next);
|
|
15
|
+
}];
|
|
17
16
|
config.init &&
|
|
18
17
|
onCleanup(config.init((value = config.get()) => {
|
|
19
18
|
ignore = true;
|
package/dist/routing.d.ts
CHANGED
|
@@ -100,7 +100,7 @@ export declare const useCurrentMatches: () => () => RouteMatch[];
|
|
|
100
100
|
* const params = useParams();
|
|
101
101
|
*
|
|
102
102
|
* // fetch user based on the id path parameter
|
|
103
|
-
* const
|
|
103
|
+
* const getUser = query(() => fetchUser(params.id), "user");
|
|
104
104
|
* ```
|
|
105
105
|
*/
|
|
106
106
|
export declare const useParams: <T extends Params>() => T;
|
package/dist/routing.js
CHANGED
|
@@ -133,7 +133,7 @@ export const useCurrentMatches = () => useRouter().matches;
|
|
|
133
133
|
* const params = useParams();
|
|
134
134
|
*
|
|
135
135
|
* // fetch user based on the id path parameter
|
|
136
|
-
* const
|
|
136
|
+
* const getUser = query(() => fetchUser(params.id), "user");
|
|
137
137
|
* ```
|
|
138
138
|
*/
|
|
139
139
|
export const useParams = () => useRouter().params;
|
|
@@ -301,7 +301,7 @@ export function getRouteMatches(branches, location) {
|
|
|
301
301
|
}
|
|
302
302
|
function createLocation(path, state, queryWrapper) {
|
|
303
303
|
const origin = new URL(mockBase);
|
|
304
|
-
const url = createMemo(prev => {
|
|
304
|
+
const url = createMemo((prev = origin) => {
|
|
305
305
|
const path_ = path();
|
|
306
306
|
try {
|
|
307
307
|
return new URL(path_, origin);
|
|
@@ -310,11 +310,11 @@ function createLocation(path, state, queryWrapper) {
|
|
|
310
310
|
console.error(`Invalid path ${path_}`);
|
|
311
311
|
return prev;
|
|
312
312
|
}
|
|
313
|
-
},
|
|
313
|
+
}, {
|
|
314
314
|
equals: (a, b) => a.href === b.href
|
|
315
315
|
});
|
|
316
316
|
const pathname = createMemo(() => url().pathname);
|
|
317
|
-
const search = createMemo(() => url().search
|
|
317
|
+
const search = createMemo(() => url().search);
|
|
318
318
|
const hash = createMemo(() => url().hash);
|
|
319
319
|
const key = () => "";
|
|
320
320
|
const queryFn = createMemo(() => extractSearchParams(url()));
|
|
@@ -361,31 +361,20 @@ export function createRouterContext(integration, branches, getContext, options =
|
|
|
361
361
|
else if (basePath && !initialSource.value) {
|
|
362
362
|
setSource({ value: basePath, replace: true, scroll: false });
|
|
363
363
|
}
|
|
364
|
-
const [isRouting, setIsRouting] = createSignal(false, {
|
|
364
|
+
const [isRouting, setIsRouting] = createSignal(false, { ownedWrite: true });
|
|
365
365
|
// Navigate override written from event handlers.
|
|
366
366
|
const [navigateTarget, setNavigateTarget] = createSignal(undefined, {
|
|
367
|
-
|
|
367
|
+
ownedWrite: true
|
|
368
368
|
});
|
|
369
369
|
// Keep track of last target, so that last call to navigate wins
|
|
370
370
|
let lastTransitionTarget;
|
|
371
371
|
// source() remains canonical for native history changes; navigateTarget()
|
|
372
372
|
// temporarily overrides it for in-flight programmatic navigation.
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
if (nav !== undefined)
|
|
376
|
-
return nav.value;
|
|
377
|
-
return source().value;
|
|
378
|
-
});
|
|
379
|
-
const state = createMemo(() => {
|
|
380
|
-
const nav = navigateTarget();
|
|
381
|
-
if (nav !== undefined)
|
|
382
|
-
return nav.state;
|
|
383
|
-
return source().state;
|
|
384
|
-
});
|
|
385
|
-
const location = createLocation(reference, state, utils.queryWrapper);
|
|
373
|
+
const effective = createMemo(() => navigateTarget() ?? source());
|
|
374
|
+
const location = createLocation(() => effective().value, () => effective().state, utils.queryWrapper);
|
|
386
375
|
const referrers = [];
|
|
387
376
|
const submissions = createSignal(isServer ? initFromFlash() : [], {
|
|
388
|
-
|
|
377
|
+
ownedWrite: true
|
|
389
378
|
});
|
|
390
379
|
const matches = createMemo(() => {
|
|
391
380
|
if (typeof options.transformUrl === "function") {
|
|
@@ -457,15 +446,15 @@ export function createRouterContext(integration, branches, getContext, options =
|
|
|
457
446
|
else if (referrers.length >= MAX_REDIRECTS) {
|
|
458
447
|
throw new Error("Too many redirects");
|
|
459
448
|
}
|
|
460
|
-
const current =
|
|
461
|
-
if (resolvedTo !== current || nextState !== state
|
|
449
|
+
const current = effective();
|
|
450
|
+
if (resolvedTo !== current.value || nextState !== current.state) {
|
|
462
451
|
if (isServer) {
|
|
463
452
|
const e = getRequestEvent();
|
|
464
453
|
e && (e.response = { status: 302, headers: new Headers({ Location: resolvedTo }) });
|
|
465
454
|
setSource({ value: resolvedTo, replace, scroll, state: nextState });
|
|
466
455
|
}
|
|
467
456
|
else if (beforeLeave.confirm(resolvedTo, options)) {
|
|
468
|
-
referrers.push({ value: current, replace, scroll, state: state
|
|
457
|
+
referrers.push({ value: current.value, replace, scroll, state: current.state });
|
|
469
458
|
const newTarget = {
|
|
470
459
|
value: resolvedTo,
|
|
471
460
|
state: nextState
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"Ryan Turnquist"
|
|
7
7
|
],
|
|
8
8
|
"license": "MIT",
|
|
9
|
-
"version": "0.17.0-next.
|
|
9
|
+
"version": "0.17.0-next.3",
|
|
10
10
|
"homepage": "https://github.com/solidjs/solid-router#readme",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"sideEffects": false,
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@solidjs/web": "2.0.0-beta.
|
|
32
|
+
"@solidjs/web": "2.0.0-beta.7",
|
|
33
33
|
"@babel/core": "^7.26.0",
|
|
34
34
|
"@babel/preset-typescript": "^7.26.0",
|
|
35
35
|
"@changesets/cli": "^2.27.10",
|
|
@@ -38,19 +38,19 @@
|
|
|
38
38
|
"@rollup/plugin-terser": "0.4.4",
|
|
39
39
|
"@types/jest": "^29.5.14",
|
|
40
40
|
"@types/node": "^22.10.0",
|
|
41
|
-
"babel-preset-solid": "2.0.0-beta.
|
|
41
|
+
"babel-preset-solid": "2.0.0-beta.7",
|
|
42
42
|
"jsdom": "^25.0.1",
|
|
43
43
|
"prettier": "^3.4.1",
|
|
44
44
|
"rollup": "^4.27.4",
|
|
45
|
-
"solid-js": "2.0.0-beta.
|
|
45
|
+
"solid-js": "2.0.0-beta.7",
|
|
46
46
|
"typescript": "^5.7.2",
|
|
47
47
|
"vite": "^6.0.0",
|
|
48
|
-
"vite-plugin-solid": "3.0.0-next.
|
|
48
|
+
"vite-plugin-solid": "3.0.0-next.4",
|
|
49
49
|
"vitest": "^2.1.6"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@solidjs/web": "
|
|
53
|
-
"solid-js": "
|
|
52
|
+
"@solidjs/web": ">=2.0.0-beta.7 <2.0.0-experimental.0",
|
|
53
|
+
"solid-js": ">=2.0.0-beta.7 <2.0.0-experimental.0"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "rm -rf dist && tsc && rollup -c",
|