@tanstack/solid-router 1.167.5 → 1.168.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/cjs/Match.cjs +244 -223
- package/dist/cjs/Match.cjs.map +1 -1
- package/dist/cjs/Match.d.cts +1 -3
- package/dist/cjs/Matches.cjs +32 -31
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/Scripts.cjs +10 -8
- package/dist/cjs/Scripts.cjs.map +1 -1
- package/dist/cjs/Scripts.d.cts +2 -1
- package/dist/cjs/Transitioner.cjs +26 -26
- package/dist/cjs/Transitioner.cjs.map +1 -1
- package/dist/cjs/headContentUtils.cjs +15 -15
- package/dist/cjs/headContentUtils.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.dev.cjs +1 -1
- package/dist/cjs/link.cjs +119 -84
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/matchContext.cjs +7 -5
- package/dist/cjs/matchContext.cjs.map +1 -1
- package/dist/cjs/matchContext.d.cts +8 -2
- package/dist/cjs/not-found.cjs +8 -4
- package/dist/cjs/not-found.cjs.map +1 -1
- package/dist/cjs/not-found.d.cts +1 -1
- package/dist/cjs/router.cjs +2 -1
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/routerStores.cjs +67 -0
- package/dist/cjs/routerStores.cjs.map +1 -0
- package/dist/cjs/routerStores.d.cts +10 -0
- package/dist/cjs/ssr/RouterClient.cjs +1 -1
- package/dist/cjs/ssr/RouterClient.cjs.map +1 -1
- package/dist/cjs/ssr/renderRouterToStream.cjs +1 -1
- package/dist/cjs/ssr/renderRouterToStream.cjs.map +1 -1
- package/dist/cjs/ssr/renderRouterToString.cjs +2 -2
- package/dist/cjs/ssr/renderRouterToString.cjs.map +1 -1
- package/dist/cjs/ssr/renderRouterToString.d.cts +1 -1
- package/dist/cjs/useCanGoBack.cjs +6 -2
- package/dist/cjs/useCanGoBack.cjs.map +1 -1
- package/dist/cjs/useCanGoBack.d.cts +2 -1
- package/dist/cjs/useLoaderDeps.cjs +2 -3
- package/dist/cjs/useLoaderDeps.cjs.map +1 -1
- package/dist/cjs/useLocation.cjs +13 -2
- package/dist/cjs/useLocation.cjs.map +1 -1
- package/dist/cjs/useMatch.cjs +17 -15
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/cjs/useParams.cjs +1 -1
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/cjs/useRouterState.cjs +12 -19
- package/dist/cjs/useRouterState.cjs.map +1 -1
- package/dist/cjs/useSearch.cjs +2 -1
- package/dist/cjs/useSearch.cjs.map +1 -1
- package/dist/cjs/utils.cjs +0 -14
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +0 -4
- package/dist/esm/Match.d.ts +1 -3
- package/dist/esm/Match.js +245 -224
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.js +34 -33
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/Scripts.d.ts +2 -1
- package/dist/esm/Scripts.js +8 -7
- package/dist/esm/Scripts.js.map +1 -1
- package/dist/esm/Transitioner.js +26 -26
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/headContentUtils.js +15 -15
- package/dist/esm/headContentUtils.js.map +1 -1
- package/dist/esm/index.dev.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/link.js +120 -85
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/matchContext.d.ts +8 -2
- package/dist/esm/matchContext.js +7 -4
- package/dist/esm/matchContext.js.map +1 -1
- package/dist/esm/not-found.d.ts +1 -1
- package/dist/esm/not-found.js +6 -3
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/router.js +2 -1
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerStores.d.ts +10 -0
- package/dist/esm/routerStores.js +65 -0
- package/dist/esm/routerStores.js.map +1 -0
- package/dist/esm/ssr/RouterClient.js +1 -1
- package/dist/esm/ssr/RouterClient.js.map +1 -1
- package/dist/esm/ssr/renderRouterToStream.js +1 -1
- package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
- package/dist/esm/ssr/renderRouterToString.d.ts +1 -1
- package/dist/esm/ssr/renderRouterToString.js +2 -2
- package/dist/esm/ssr/renderRouterToString.js.map +1 -1
- package/dist/esm/useCanGoBack.d.ts +2 -1
- package/dist/esm/useCanGoBack.js +4 -2
- package/dist/esm/useCanGoBack.js.map +1 -1
- package/dist/esm/useLoaderDeps.js +2 -3
- package/dist/esm/useLoaderDeps.js.map +1 -1
- package/dist/esm/useLocation.js +11 -2
- package/dist/esm/useLocation.js.map +1 -1
- package/dist/esm/useMatch.js +18 -16
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useParams.js +1 -1
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useRouterState.js +10 -18
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/esm/useSearch.js +2 -1
- package/dist/esm/useSearch.js.map +1 -1
- package/dist/esm/utils.d.ts +0 -4
- package/dist/esm/utils.js +1 -14
- package/dist/esm/utils.js.map +1 -1
- package/dist/source/Match.d.ts +1 -3
- package/dist/source/Match.jsx +246 -237
- package/dist/source/Match.jsx.map +1 -1
- package/dist/source/Matches.jsx +42 -44
- package/dist/source/Matches.jsx.map +1 -1
- package/dist/source/Scripts.d.ts +2 -1
- package/dist/source/Scripts.jsx +31 -36
- package/dist/source/Scripts.jsx.map +1 -1
- package/dist/source/Transitioner.jsx +26 -31
- package/dist/source/Transitioner.jsx.map +1 -1
- package/dist/source/headContentUtils.jsx +64 -72
- package/dist/source/headContentUtils.jsx.map +1 -1
- package/dist/source/link.jsx +136 -107
- package/dist/source/link.jsx.map +1 -1
- package/dist/source/matchContext.d.ts +8 -2
- package/dist/source/matchContext.jsx +7 -3
- package/dist/source/matchContext.jsx.map +1 -1
- package/dist/source/not-found.d.ts +1 -1
- package/dist/source/not-found.jsx +6 -5
- package/dist/source/not-found.jsx.map +1 -1
- package/dist/source/router.js +2 -1
- package/dist/source/router.js.map +1 -1
- package/dist/source/routerStores.d.ts +10 -0
- package/dist/source/routerStores.js +71 -0
- package/dist/source/routerStores.js.map +1 -0
- package/dist/source/ssr/RouterClient.jsx +1 -1
- package/dist/source/ssr/RouterClient.jsx.map +1 -1
- package/dist/source/ssr/renderRouterToStream.jsx +1 -1
- package/dist/source/ssr/renderRouterToStream.jsx.map +1 -1
- package/dist/source/ssr/renderRouterToString.d.ts +1 -1
- package/dist/source/ssr/renderRouterToString.jsx +2 -2
- package/dist/source/ssr/renderRouterToString.jsx.map +1 -1
- package/dist/source/useCanGoBack.d.ts +2 -1
- package/dist/source/useCanGoBack.js +4 -2
- package/dist/source/useCanGoBack.js.map +1 -1
- package/dist/source/useLoaderDeps.jsx +2 -3
- package/dist/source/useLoaderDeps.jsx.map +1 -1
- package/dist/source/useLocation.jsx +13 -3
- package/dist/source/useLocation.jsx.map +1 -1
- package/dist/source/useMatch.jsx +30 -27
- package/dist/source/useMatch.jsx.map +1 -1
- package/dist/source/useParams.jsx +1 -1
- package/dist/source/useParams.jsx.map +1 -1
- package/dist/source/useRouterState.jsx +12 -33
- package/dist/source/useRouterState.jsx.map +1 -1
- package/dist/source/useSearch.jsx +2 -1
- package/dist/source/useSearch.jsx.map +1 -1
- package/dist/source/utils.d.ts +0 -4
- package/dist/source/utils.js +0 -13
- package/dist/source/utils.js.map +1 -1
- package/package.json +2 -3
- package/skills/solid-router/SKILL.md +2 -0
- package/src/Match.tsx +351 -304
- package/src/Matches.tsx +49 -52
- package/src/Scripts.tsx +40 -41
- package/src/Transitioner.tsx +67 -66
- package/src/headContentUtils.tsx +89 -91
- package/src/link.tsx +179 -141
- package/src/matchContext.tsx +16 -7
- package/src/not-found.tsx +6 -6
- package/src/router.ts +2 -1
- package/src/routerStores.ts +107 -0
- package/src/ssr/RouterClient.tsx +1 -1
- package/src/ssr/renderRouterToStream.tsx +1 -1
- package/src/ssr/renderRouterToString.tsx +2 -2
- package/src/useCanGoBack.ts +6 -2
- package/src/useLoaderDeps.tsx +2 -3
- package/src/useLocation.tsx +18 -5
- package/src/useMatch.tsx +36 -43
- package/src/useParams.tsx +2 -3
- package/src/useRouterState.tsx +17 -41
- package/src/useSearch.tsx +2 -1
- package/src/utils.ts +0 -20
package/dist/esm/Match.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { CatchBoundary, ErrorComponent } from "./CatchBoundary.js";
|
|
2
2
|
import { useRouter } from "./useRouter.js";
|
|
3
|
-
import {
|
|
4
|
-
import { matchContext } from "./matchContext.js";
|
|
3
|
+
import { nearestMatchContext } from "./matchContext.js";
|
|
5
4
|
import { SafeFragment } from "./SafeFragment.js";
|
|
6
5
|
import { CatchNotFound } from "./not-found.js";
|
|
7
6
|
import { renderRouteNotFound } from "./renderRouteNotFound.js";
|
|
@@ -15,273 +14,297 @@ import invariant from "tiny-invariant";
|
|
|
15
14
|
//#region src/Match.tsx
|
|
16
15
|
var Match = (props) => {
|
|
17
16
|
const router = useRouter();
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
17
|
+
const match = Solid.createMemo(() => {
|
|
18
|
+
const id = props.matchId;
|
|
19
|
+
if (!id) return void 0;
|
|
20
|
+
return router.stores.activeMatchStoresById.get(id)?.state;
|
|
21
|
+
});
|
|
22
|
+
const rawMatchState = Solid.createMemo(() => {
|
|
23
|
+
const currentMatch = match();
|
|
24
|
+
if (!currentMatch) return null;
|
|
25
|
+
const routeId = currentMatch.routeId;
|
|
26
|
+
const parentRouteId = router.routesById[routeId]?.parentRoute?.id;
|
|
21
27
|
return {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
matchId: currentMatch.id,
|
|
29
|
+
routeId,
|
|
30
|
+
ssr: currentMatch.ssr,
|
|
31
|
+
_displayPending: currentMatch._displayPending,
|
|
32
|
+
parentRouteId
|
|
25
33
|
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
} });
|
|
54
|
-
},
|
|
34
|
+
});
|
|
35
|
+
const nearestMatch = {
|
|
36
|
+
matchId: () => rawMatchState()?.matchId,
|
|
37
|
+
routeId: () => rawMatchState()?.routeId,
|
|
38
|
+
match,
|
|
39
|
+
hasPending: Solid.createMemo(() => {
|
|
40
|
+
const currentRouteId = rawMatchState()?.routeId;
|
|
41
|
+
return currentRouteId ? Boolean(router.stores.pendingRouteIds.state[currentRouteId]) : false;
|
|
42
|
+
})
|
|
43
|
+
};
|
|
44
|
+
return createComponent(Solid.Show, {
|
|
45
|
+
get when() {
|
|
46
|
+
return rawMatchState();
|
|
47
|
+
},
|
|
48
|
+
children: (currentMatchState) => {
|
|
49
|
+
const route = () => router.routesById[currentMatchState().routeId];
|
|
50
|
+
const resolvePendingComponent = () => route().options.pendingComponent ?? router.options.defaultPendingComponent;
|
|
51
|
+
const routeErrorComponent = () => route().options.errorComponent ?? router.options.defaultErrorComponent;
|
|
52
|
+
const routeOnCatch = () => route().options.onCatch ?? router.options.defaultOnCatch;
|
|
53
|
+
const routeNotFoundComponent = () => route().isRoot ? route().options.notFoundComponent ?? router.options.notFoundRoute?.options.component : route().options.notFoundComponent;
|
|
54
|
+
const resolvedNoSsr = currentMatchState().ssr === false || currentMatchState().ssr === "data-only";
|
|
55
|
+
const ResolvedSuspenseBoundary = () => Solid.Suspense;
|
|
56
|
+
const ResolvedCatchBoundary = () => routeErrorComponent() ? CatchBoundary : SafeFragment;
|
|
57
|
+
const ResolvedNotFoundBoundary = () => routeNotFoundComponent() ? CatchNotFound : SafeFragment;
|
|
58
|
+
return createComponent(route().isRoot ? route().options.shellComponent ?? SafeFragment : SafeFragment, { get children() {
|
|
59
|
+
return [createComponent(nearestMatchContext.Provider, {
|
|
60
|
+
value: nearestMatch,
|
|
55
61
|
get children() {
|
|
56
62
|
return createComponent(Dynamic, {
|
|
57
63
|
get component() {
|
|
58
|
-
return
|
|
64
|
+
return ResolvedSuspenseBoundary();
|
|
59
65
|
},
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
onCatch: (error) => {
|
|
65
|
-
if (isNotFound(error)) throw error;
|
|
66
|
-
warning(false, `Error in route match: ${matchState().routeId}`);
|
|
67
|
-
routeOnCatch()?.(error);
|
|
66
|
+
get fallback() {
|
|
67
|
+
return memo(() => !!((isServer ?? router.isServer) && resolvedNoSsr))() ? void 0 : createComponent(Dynamic, { get component() {
|
|
68
|
+
return resolvePendingComponent();
|
|
69
|
+
} });
|
|
68
70
|
},
|
|
69
71
|
get children() {
|
|
70
72
|
return createComponent(Dynamic, {
|
|
71
73
|
get component() {
|
|
72
|
-
return
|
|
74
|
+
return ResolvedCatchBoundary();
|
|
75
|
+
},
|
|
76
|
+
getResetKey: () => router.stores.loadedAt.state,
|
|
77
|
+
get errorComponent() {
|
|
78
|
+
return routeErrorComponent() || ErrorComponent;
|
|
73
79
|
},
|
|
74
|
-
|
|
75
|
-
if (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
} }, error));
|
|
80
|
+
onCatch: (error) => {
|
|
81
|
+
if (isNotFound(error)) throw error;
|
|
82
|
+
warning(false, `Error in route match: ${currentMatchState().routeId}`);
|
|
83
|
+
routeOnCatch()?.(error);
|
|
79
84
|
},
|
|
80
85
|
get children() {
|
|
81
|
-
return createComponent(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
return createComponent(Dynamic, {
|
|
87
|
+
get component() {
|
|
88
|
+
return ResolvedNotFoundBoundary();
|
|
89
|
+
},
|
|
90
|
+
fallback: (error) => {
|
|
91
|
+
if (!routeNotFoundComponent() || error.routeId && error.routeId !== currentMatchState().routeId || !error.routeId && !route().isRoot) throw error;
|
|
92
|
+
return createComponent(Dynamic, mergeProps({ get component() {
|
|
93
|
+
return routeNotFoundComponent();
|
|
94
|
+
} }, error));
|
|
95
|
+
},
|
|
96
|
+
get children() {
|
|
97
|
+
return createComponent(Solid.Switch, { get children() {
|
|
98
|
+
return [createComponent(Solid.Match, {
|
|
99
|
+
when: resolvedNoSsr,
|
|
94
100
|
get children() {
|
|
95
|
-
return createComponent(
|
|
96
|
-
|
|
97
|
-
|
|
101
|
+
return createComponent(Solid.Show, {
|
|
102
|
+
get when() {
|
|
103
|
+
return !(isServer ?? router.isServer);
|
|
104
|
+
},
|
|
105
|
+
get fallback() {
|
|
106
|
+
return createComponent(Dynamic, { get component() {
|
|
107
|
+
return resolvePendingComponent();
|
|
108
|
+
} });
|
|
109
|
+
},
|
|
110
|
+
get children() {
|
|
111
|
+
return createComponent(MatchInner, {});
|
|
112
|
+
}
|
|
113
|
+
});
|
|
98
114
|
}
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
})];
|
|
109
|
-
} });
|
|
115
|
+
}), createComponent(Solid.Match, {
|
|
116
|
+
when: !resolvedNoSsr,
|
|
117
|
+
get children() {
|
|
118
|
+
return createComponent(MatchInner, {});
|
|
119
|
+
}
|
|
120
|
+
})];
|
|
121
|
+
} });
|
|
122
|
+
}
|
|
123
|
+
});
|
|
110
124
|
}
|
|
111
125
|
});
|
|
112
126
|
}
|
|
113
127
|
});
|
|
114
128
|
}
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
129
|
+
}), memo(() => memo(() => currentMatchState().parentRouteId === rootRouteId)() ? [createComponent(OnRendered, {}), createComponent(ScrollRestoration, {})] : null)];
|
|
130
|
+
} });
|
|
131
|
+
}
|
|
132
|
+
});
|
|
119
133
|
};
|
|
120
134
|
function OnRendered() {
|
|
121
135
|
const router = useRouter();
|
|
122
|
-
const location =
|
|
123
|
-
return s.resolvedLocation?.state.__TSR_key;
|
|
124
|
-
} });
|
|
136
|
+
const location = Solid.createMemo(() => router.stores.resolvedLocation.state?.state.__TSR_key);
|
|
125
137
|
Solid.createEffect(Solid.on([location], () => {
|
|
126
138
|
router.emit({
|
|
127
139
|
type: "onRendered",
|
|
128
|
-
...getLocationChangeInfo(router.state)
|
|
140
|
+
...getLocationChangeInfo(router.stores.location.state, router.stores.resolvedLocation.state)
|
|
129
141
|
});
|
|
130
142
|
}));
|
|
131
143
|
return null;
|
|
132
144
|
}
|
|
133
|
-
var MatchInner = (
|
|
145
|
+
var MatchInner = () => {
|
|
134
146
|
const router = useRouter();
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
147
|
+
const match = Solid.useContext(nearestMatchContext).match;
|
|
148
|
+
const rawMatchState = Solid.createMemo(() => {
|
|
149
|
+
const currentMatch = match();
|
|
150
|
+
if (!currentMatch) return null;
|
|
151
|
+
const routeId = currentMatch.routeId;
|
|
139
152
|
const remountDeps = (router.routesById[routeId].options.remountDeps ?? router.options.defaultRemountDeps)?.({
|
|
140
153
|
routeId,
|
|
141
|
-
loaderDeps:
|
|
142
|
-
params:
|
|
143
|
-
search:
|
|
154
|
+
loaderDeps: currentMatch.loaderDeps,
|
|
155
|
+
params: currentMatch._strictParams,
|
|
156
|
+
search: currentMatch._strictSearch
|
|
144
157
|
});
|
|
145
158
|
return {
|
|
146
159
|
key: remountDeps ? JSON.stringify(remountDeps) : void 0,
|
|
147
160
|
routeId,
|
|
148
161
|
match: {
|
|
149
|
-
id:
|
|
150
|
-
status:
|
|
151
|
-
error:
|
|
152
|
-
_forcePending:
|
|
153
|
-
_displayPending:
|
|
162
|
+
id: currentMatch.id,
|
|
163
|
+
status: currentMatch.status,
|
|
164
|
+
error: currentMatch.error,
|
|
165
|
+
_forcePending: currentMatch._forcePending ?? false,
|
|
166
|
+
_displayPending: currentMatch._displayPending ?? false
|
|
154
167
|
}
|
|
155
168
|
};
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const route = () => router.routesById[matchState().routeId];
|
|
159
|
-
const match = () => matchState().match;
|
|
160
|
-
const componentKey = () => matchState().key ?? matchState().match.id;
|
|
161
|
-
const out = () => {
|
|
162
|
-
const Comp = route().options.component ?? router.options.defaultComponent;
|
|
163
|
-
if (Comp) return createComponent(Comp, {});
|
|
164
|
-
return createComponent(Outlet, {});
|
|
165
|
-
};
|
|
166
|
-
const keyedOut = () => createComponent(Solid.Show, {
|
|
169
|
+
});
|
|
170
|
+
return createComponent(Solid.Show, {
|
|
167
171
|
get when() {
|
|
168
|
-
return
|
|
172
|
+
return rawMatchState();
|
|
169
173
|
},
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
children: (currentMatchState) => {
|
|
175
|
+
const route = () => router.routesById[currentMatchState().routeId];
|
|
176
|
+
const currentMatch = () => currentMatchState().match;
|
|
177
|
+
const componentKey = () => currentMatchState().key ?? currentMatchState().match.id;
|
|
178
|
+
const out = () => {
|
|
179
|
+
const Comp = route().options.component ?? router.options.defaultComponent;
|
|
180
|
+
if (Comp) return createComponent(Comp, {});
|
|
181
|
+
return createComponent(Outlet, {});
|
|
182
|
+
};
|
|
183
|
+
const keyedOut = () => createComponent(Solid.Show, {
|
|
176
184
|
get when() {
|
|
177
|
-
return
|
|
185
|
+
return componentKey();
|
|
178
186
|
},
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
187
|
+
keyed: true,
|
|
188
|
+
children: (_key) => out()
|
|
189
|
+
});
|
|
190
|
+
return createComponent(Solid.Switch, { get children() {
|
|
191
|
+
return [
|
|
192
|
+
createComponent(Solid.Match, {
|
|
193
|
+
get when() {
|
|
194
|
+
return currentMatch()._displayPending;
|
|
195
|
+
},
|
|
196
|
+
children: (_) => {
|
|
197
|
+
const [displayPendingResult] = Solid.createResource(() => router.getMatch(currentMatch().id)?._nonReactive.displayPendingPromise);
|
|
198
|
+
return memo(displayPendingResult);
|
|
199
|
+
}
|
|
200
|
+
}),
|
|
201
|
+
createComponent(Solid.Match, {
|
|
202
|
+
get when() {
|
|
203
|
+
return currentMatch()._forcePending;
|
|
204
|
+
},
|
|
205
|
+
children: (_) => {
|
|
206
|
+
const [minPendingResult] = Solid.createResource(() => router.getMatch(currentMatch().id)?._nonReactive.minPendingPromise);
|
|
207
|
+
return memo(minPendingResult);
|
|
208
|
+
}
|
|
209
|
+
}),
|
|
210
|
+
createComponent(Solid.Match, {
|
|
211
|
+
get when() {
|
|
212
|
+
return currentMatch().status === "pending";
|
|
213
|
+
},
|
|
214
|
+
children: (_) => {
|
|
215
|
+
const pendingMinMs = route().options.pendingMinMs ?? router.options.defaultPendingMinMs;
|
|
216
|
+
if (pendingMinMs) {
|
|
217
|
+
const routerMatch = router.getMatch(currentMatch().id);
|
|
218
|
+
if (routerMatch && !routerMatch._nonReactive.minPendingPromise) {
|
|
219
|
+
if (!(isServer ?? router.isServer)) {
|
|
220
|
+
const minPendingPromise = createControlledPromise();
|
|
221
|
+
routerMatch._nonReactive.minPendingPromise = minPendingPromise;
|
|
222
|
+
setTimeout(() => {
|
|
223
|
+
minPendingPromise.resolve();
|
|
224
|
+
routerMatch._nonReactive.minPendingPromise = void 0;
|
|
225
|
+
}, pendingMinMs);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
209
228
|
}
|
|
229
|
+
const [loaderResult] = Solid.createResource(async () => {
|
|
230
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
231
|
+
return router.getMatch(currentMatch().id)?._nonReactive.loadPromise;
|
|
232
|
+
});
|
|
233
|
+
const FallbackComponent = route().options.pendingComponent ?? router.options.defaultPendingComponent;
|
|
234
|
+
return [FallbackComponent && pendingMinMs > 0 ? createComponent(Dynamic, { component: FallbackComponent }) : null, memo(loaderResult)];
|
|
210
235
|
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
await new Promise((r) => setTimeout(r, 0));
|
|
214
|
-
return router.getMatch(match().id)?._nonReactive.loadPromise;
|
|
215
|
-
});
|
|
216
|
-
const FallbackComponent = route().options.pendingComponent ?? router.options.defaultPendingComponent;
|
|
217
|
-
return [FallbackComponent && pendingMinMs > 0 ? createComponent(Dynamic, { component: FallbackComponent }) : null, memo(loaderResult)];
|
|
218
|
-
}
|
|
219
|
-
}),
|
|
220
|
-
createComponent(Solid.Match, {
|
|
221
|
-
get when() {
|
|
222
|
-
return match().status === "notFound";
|
|
223
|
-
},
|
|
224
|
-
children: (_) => {
|
|
225
|
-
invariant(isNotFound(match().error), "Expected a notFound error");
|
|
226
|
-
return createComponent(Solid.Show, {
|
|
236
|
+
}),
|
|
237
|
+
createComponent(Solid.Match, {
|
|
227
238
|
get when() {
|
|
228
|
-
return
|
|
239
|
+
return currentMatch().status === "notFound";
|
|
229
240
|
},
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
241
|
+
children: (_) => {
|
|
242
|
+
invariant(isNotFound(currentMatch().error), "Expected a notFound error");
|
|
243
|
+
return createComponent(Solid.Show, {
|
|
244
|
+
get when() {
|
|
245
|
+
return currentMatchState().routeId;
|
|
246
|
+
},
|
|
247
|
+
keyed: true,
|
|
248
|
+
children: (_routeId) => renderRouteNotFound(router, route(), currentMatch().error)
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}),
|
|
252
|
+
createComponent(Solid.Match, {
|
|
253
|
+
get when() {
|
|
254
|
+
return currentMatch().status === "redirected";
|
|
255
|
+
},
|
|
256
|
+
children: (_) => {
|
|
257
|
+
invariant(isRedirect(currentMatch().error), "Expected a redirect error");
|
|
258
|
+
const [loaderResult] = Solid.createResource(async () => {
|
|
259
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
260
|
+
return router.getMatch(currentMatch().id)?._nonReactive.loadPromise;
|
|
261
|
+
});
|
|
262
|
+
return memo(loaderResult);
|
|
263
|
+
}
|
|
264
|
+
}),
|
|
265
|
+
createComponent(Solid.Match, {
|
|
266
|
+
get when() {
|
|
267
|
+
return currentMatch().status === "error";
|
|
268
|
+
},
|
|
269
|
+
children: (_) => {
|
|
270
|
+
if (isServer ?? router.isServer) return createComponent((route().options.errorComponent ?? router.options.defaultErrorComponent) || ErrorComponent, {
|
|
271
|
+
get error() {
|
|
272
|
+
return currentMatch().error;
|
|
273
|
+
},
|
|
274
|
+
info: { componentStack: "" }
|
|
275
|
+
});
|
|
276
|
+
throw currentMatch().error;
|
|
277
|
+
}
|
|
278
|
+
}),
|
|
279
|
+
createComponent(Solid.Match, {
|
|
280
|
+
get when() {
|
|
281
|
+
return currentMatch().status === "success";
|
|
282
|
+
},
|
|
283
|
+
get children() {
|
|
284
|
+
return keyedOut();
|
|
285
|
+
}
|
|
286
|
+
})
|
|
287
|
+
];
|
|
288
|
+
} });
|
|
289
|
+
}
|
|
290
|
+
});
|
|
266
291
|
};
|
|
267
292
|
var Outlet = () => {
|
|
268
293
|
const router = useRouter();
|
|
269
|
-
const
|
|
270
|
-
const
|
|
271
|
-
const
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
return matches[matches.findIndex((d) => d.id === matchId()) + 1]?.status;
|
|
284
|
-
} });
|
|
294
|
+
const nearestParentMatch = Solid.useContext(nearestMatchContext);
|
|
295
|
+
const parentMatch = nearestParentMatch.match;
|
|
296
|
+
const routeId = nearestParentMatch.routeId;
|
|
297
|
+
const route = Solid.createMemo(() => routeId() ? router.routesById[routeId()] : void 0);
|
|
298
|
+
const parentGlobalNotFound = Solid.createMemo(() => parentMatch()?.globalNotFound ?? false);
|
|
299
|
+
const childMatchId = Solid.createMemo(() => {
|
|
300
|
+
const currentRouteId = routeId();
|
|
301
|
+
return currentRouteId ? router.stores.childMatchIdByRouteId.state[currentRouteId] : void 0;
|
|
302
|
+
});
|
|
303
|
+
const childMatchStatus = Solid.createMemo(() => {
|
|
304
|
+
const id = childMatchId();
|
|
305
|
+
if (!id) return void 0;
|
|
306
|
+
return router.stores.activeMatchStoresById.get(id)?.state.status;
|
|
307
|
+
});
|
|
285
308
|
const shouldShowNotFound = () => childMatchStatus() !== "redirected" && parentGlobalNotFound();
|
|
286
309
|
return createComponent(Solid.Show, {
|
|
287
310
|
get when() {
|
|
@@ -290,15 +313,13 @@ var Outlet = () => {
|
|
|
290
313
|
get fallback() {
|
|
291
314
|
return createComponent(Solid.Show, {
|
|
292
315
|
get when() {
|
|
293
|
-
return shouldShowNotFound();
|
|
316
|
+
return memo(() => !!shouldShowNotFound())() && route();
|
|
294
317
|
},
|
|
295
|
-
|
|
296
|
-
return renderRouteNotFound(router, route(), void 0);
|
|
297
|
-
}
|
|
318
|
+
children: (resolvedRoute) => renderRouteNotFound(router, resolvedRoute(), void 0)
|
|
298
319
|
});
|
|
299
320
|
},
|
|
300
|
-
children: (
|
|
301
|
-
const currentMatchId = Solid.createMemo(() =>
|
|
321
|
+
children: (childMatchIdAccessor) => {
|
|
322
|
+
const currentMatchId = Solid.createMemo(() => childMatchIdAccessor());
|
|
302
323
|
return createComponent(Solid.Show, {
|
|
303
324
|
get when() {
|
|
304
325
|
return routeId() === rootRouteId;
|