@solidjs/router 0.17.0-next.0 → 0.17.0-next.1
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.js +25 -15
- package/dist/routers/components.jsx +16 -8
- package/dist/routing.js +2 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -606,9 +606,10 @@ function createRouterContext(integration, branches, getContext, options = {}) {
|
|
|
606
606
|
const renderPath = utils.renderPath || (p => p);
|
|
607
607
|
const beforeLeave = utils.beforeLeave || createBeforeLeave();
|
|
608
608
|
const basePath = resolvePath("", options.base || "");
|
|
609
|
+
const initialSource = untrack(source);
|
|
609
610
|
if (basePath === undefined) {
|
|
610
611
|
throw new Error(`${basePath} is not a valid base path`);
|
|
611
|
-
} else if (basePath && !
|
|
612
|
+
} else if (basePath && !initialSource.value) {
|
|
612
613
|
setSource({
|
|
613
614
|
value: basePath,
|
|
614
615
|
replace: true,
|
|
@@ -855,17 +856,29 @@ function createRouteContext(router, parent, outlet, match) {
|
|
|
855
856
|
return route;
|
|
856
857
|
}
|
|
857
858
|
|
|
858
|
-
const createRouterComponent = router => props
|
|
859
|
+
const createRouterComponent = router => function IntegratedRouter(props) {
|
|
859
860
|
const {
|
|
860
|
-
base
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
861
|
+
base,
|
|
862
|
+
singleFlight,
|
|
863
|
+
transformUrl,
|
|
864
|
+
root,
|
|
865
|
+
rootPreload,
|
|
866
|
+
routeChildren
|
|
867
|
+
} = untrack(() => ({
|
|
868
|
+
base: props.base,
|
|
869
|
+
singleFlight: props.singleFlight,
|
|
870
|
+
transformUrl: props.transformUrl,
|
|
871
|
+
root: props.root,
|
|
872
|
+
rootPreload: props.rootPreload,
|
|
873
|
+
routeChildren: props.children
|
|
874
|
+
}));
|
|
875
|
+
const routeDefs = children(() => routeChildren);
|
|
876
|
+
const branches = createMemo(() => createBranches(routeDefs(), base || ""));
|
|
864
877
|
let context;
|
|
865
878
|
const routerState = createRouterContext(router, branches, () => context, {
|
|
866
879
|
base,
|
|
867
|
-
singleFlight
|
|
868
|
-
transformUrl
|
|
880
|
+
singleFlight,
|
|
881
|
+
transformUrl
|
|
869
882
|
});
|
|
870
883
|
router.create && router.create(routerState);
|
|
871
884
|
return createComponent$1(RouterContextObj, {
|
|
@@ -873,12 +886,8 @@ const createRouterComponent = router => props => {
|
|
|
873
886
|
get children() {
|
|
874
887
|
return createComponent$1(Root, {
|
|
875
888
|
routerState: routerState,
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
},
|
|
879
|
-
get preload() {
|
|
880
|
-
return props.rootPreload;
|
|
881
|
-
},
|
|
889
|
+
root: root,
|
|
890
|
+
preload: rootPreload,
|
|
882
891
|
get children() {
|
|
883
892
|
return [memo(() => (context = getOwner()) && null), createComponent$1(Routes, {
|
|
884
893
|
routerState: routerState,
|
|
@@ -973,7 +982,8 @@ function Routes(props) {
|
|
|
973
982
|
prevMatches = nextMatches;
|
|
974
983
|
return next;
|
|
975
984
|
}, undefined);
|
|
976
|
-
|
|
985
|
+
const outlet = createOutlet(() => routeStates() && root);
|
|
986
|
+
return memo(outlet);
|
|
977
987
|
}
|
|
978
988
|
const createOutlet = child => {
|
|
979
989
|
return () => {
|
|
@@ -2,19 +2,26 @@
|
|
|
2
2
|
import { children, createMemo, createRoot, getOwner, merge, untrack } from "solid-js";
|
|
3
3
|
import { getRequestEvent, isServer } from "@solidjs/web";
|
|
4
4
|
import { createBranches, createRouteContext, createRouterContext, getIntent, getRouteMatches, RouteContextObj, RouterContextObj, setInPreloadFn } from "../routing.js";
|
|
5
|
-
export const createRouterComponent = (router) => (props)
|
|
6
|
-
const { base } =
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export const createRouterComponent = (router) => function IntegratedRouter(props) {
|
|
6
|
+
const { base, singleFlight, transformUrl, root, rootPreload, routeChildren } = untrack(() => ({
|
|
7
|
+
base: props.base,
|
|
8
|
+
singleFlight: props.singleFlight,
|
|
9
|
+
transformUrl: props.transformUrl,
|
|
10
|
+
root: props.root,
|
|
11
|
+
rootPreload: props.rootPreload,
|
|
12
|
+
routeChildren: props.children
|
|
13
|
+
}));
|
|
14
|
+
const routeDefs = children(() => routeChildren);
|
|
15
|
+
const branches = createMemo(() => createBranches(routeDefs(), base || ""));
|
|
9
16
|
let context;
|
|
10
17
|
const routerState = createRouterContext(router, branches, () => context, {
|
|
11
18
|
base,
|
|
12
|
-
singleFlight
|
|
13
|
-
transformUrl
|
|
19
|
+
singleFlight,
|
|
20
|
+
transformUrl,
|
|
14
21
|
});
|
|
15
22
|
router.create && router.create(routerState);
|
|
16
23
|
return (<RouterContextObj value={routerState}>
|
|
17
|
-
<Root routerState={routerState} root={
|
|
24
|
+
<Root routerState={routerState} root={root} preload={rootPreload}>
|
|
18
25
|
{(context = getOwner()) && null}
|
|
19
26
|
<Routes routerState={routerState} branches={branches()}/>
|
|
20
27
|
</Root>
|
|
@@ -91,7 +98,8 @@ function Routes(props) {
|
|
|
91
98
|
prevMatches = nextMatches;
|
|
92
99
|
return next;
|
|
93
100
|
}, undefined);
|
|
94
|
-
|
|
101
|
+
const outlet = createOutlet(() => routeStates() && root);
|
|
102
|
+
return <>{outlet()}</>;
|
|
95
103
|
}
|
|
96
104
|
const createOutlet = (child) => {
|
|
97
105
|
return () => {
|
package/dist/routing.js
CHANGED
|
@@ -354,10 +354,11 @@ export function createRouterContext(integration, branches, getContext, options =
|
|
|
354
354
|
const renderPath = utils.renderPath || (p => p);
|
|
355
355
|
const beforeLeave = utils.beforeLeave || createBeforeLeave();
|
|
356
356
|
const basePath = resolvePath("", options.base || "");
|
|
357
|
+
const initialSource = untrack(source);
|
|
357
358
|
if (basePath === undefined) {
|
|
358
359
|
throw new Error(`${basePath} is not a valid base path`);
|
|
359
360
|
}
|
|
360
|
-
else if (basePath && !
|
|
361
|
+
else if (basePath && !initialSource.value) {
|
|
361
362
|
setSource({ value: basePath, replace: true, scroll: false });
|
|
362
363
|
}
|
|
363
364
|
const [isRouting, setIsRouting] = createSignal(false, { pureWrite: true });
|