@tanstack/solid-router 2.0.0-alpha.2 → 2.0.0-alpha.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/cjs/Asset.cjs +124 -167
- package/dist/cjs/Asset.cjs.map +1 -1
- package/dist/cjs/CatchBoundary.cjs +52 -68
- package/dist/cjs/CatchBoundary.cjs.map +1 -1
- package/dist/cjs/ClientOnly.cjs +61 -39
- package/dist/cjs/ClientOnly.cjs.map +1 -1
- package/dist/cjs/HeadContent.cjs +35 -27
- package/dist/cjs/HeadContent.cjs.map +1 -1
- package/dist/cjs/HeadContent.dev.cjs +48 -41
- package/dist/cjs/HeadContent.dev.cjs.map +1 -1
- package/dist/cjs/Match.cjs +367 -442
- package/dist/cjs/Match.cjs.map +1 -1
- package/dist/cjs/Matches.cjs +114 -158
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/RouterProvider.cjs +29 -41
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/SafeFragment.cjs +7 -5
- package/dist/cjs/SafeFragment.cjs.map +1 -1
- package/dist/cjs/ScriptOnce.cjs +20 -22
- package/dist/cjs/ScriptOnce.cjs.map +1 -1
- package/dist/cjs/Scripts.cjs +43 -58
- package/dist/cjs/Scripts.cjs.map +1 -1
- package/dist/cjs/ScrollRestoration.cjs +26 -28
- package/dist/cjs/ScrollRestoration.cjs.map +1 -1
- package/dist/cjs/Transitioner.cjs +91 -124
- package/dist/cjs/Transitioner.cjs.map +1 -1
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/cjs/awaited.cjs +31 -53
- package/dist/cjs/awaited.cjs.map +1 -1
- package/dist/cjs/fileRoute.cjs +96 -91
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +2 -2
- package/dist/cjs/headContentUtils.cjs +132 -170
- package/dist/cjs/headContentUtils.cjs.map +1 -1
- package/dist/cjs/index.cjs +245 -176
- package/dist/cjs/index.dev.cjs +245 -176
- package/dist/cjs/lazyRouteComponent.cjs +48 -54
- package/dist/cjs/lazyRouteComponent.cjs.map +1 -1
- package/dist/cjs/link.cjs +310 -345
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/matchContext.cjs +9 -23
- package/dist/cjs/matchContext.cjs.map +1 -1
- package/dist/cjs/not-found.cjs +26 -34
- package/dist/cjs/not-found.cjs.map +1 -1
- package/dist/cjs/renderRouteNotFound.cjs +23 -16
- package/dist/cjs/renderRouteNotFound.cjs.map +1 -1
- package/dist/cjs/route.cjs +200 -215
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/router.cjs +18 -16
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/routerContext.cjs +8 -22
- package/dist/cjs/routerContext.cjs.map +1 -1
- package/dist/cjs/scroll-restoration.cjs +25 -35
- package/dist/cjs/scroll-restoration.cjs.map +1 -1
- package/dist/cjs/ssr/RouterClient.cjs +18 -23
- package/dist/cjs/ssr/RouterClient.cjs.map +1 -1
- package/dist/cjs/ssr/RouterServer.cjs +10 -10
- package/dist/cjs/ssr/RouterServer.cjs.map +1 -1
- package/dist/cjs/ssr/client.cjs +2 -4
- package/dist/cjs/ssr/defaultRenderHandler.cjs +12 -16
- package/dist/cjs/ssr/defaultRenderHandler.cjs.map +1 -1
- package/dist/cjs/ssr/defaultStreamHandler.cjs +13 -18
- package/dist/cjs/ssr/defaultStreamHandler.cjs.map +1 -1
- package/dist/cjs/ssr/renderRouterToStream.cjs +26 -54
- package/dist/cjs/ssr/renderRouterToStream.cjs.map +1 -1
- package/dist/cjs/ssr/renderRouterToString.cjs +33 -57
- package/dist/cjs/ssr/renderRouterToString.cjs.map +1 -1
- package/dist/cjs/ssr/server.cjs +18 -18
- package/dist/cjs/useBlocker.cjs +140 -177
- package/dist/cjs/useBlocker.cjs.map +1 -1
- package/dist/cjs/useBlocker.d.cts +8 -5
- package/dist/cjs/useCanGoBack.cjs +6 -5
- package/dist/cjs/useCanGoBack.cjs.map +1 -1
- package/dist/cjs/useLoaderData.cjs +12 -11
- package/dist/cjs/useLoaderData.cjs.map +1 -1
- package/dist/cjs/useLoaderDeps.cjs +12 -14
- package/dist/cjs/useLoaderDeps.cjs.map +1 -1
- package/dist/cjs/useLocation.cjs +6 -7
- package/dist/cjs/useLocation.cjs.map +1 -1
- package/dist/cjs/useMatch.cjs +25 -46
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/cjs/useNavigate.cjs +20 -38
- package/dist/cjs/useNavigate.cjs.map +1 -1
- package/dist/cjs/useParams.cjs +14 -13
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/cjs/useRouteContext.cjs +9 -8
- package/dist/cjs/useRouteContext.cjs.map +1 -1
- package/dist/cjs/useRouter.cjs +13 -26
- package/dist/cjs/useRouter.cjs.map +1 -1
- package/dist/cjs/useRouterState.cjs +38 -45
- package/dist/cjs/useRouterState.cjs.map +1 -1
- package/dist/cjs/useSearch.cjs +13 -12
- package/dist/cjs/useSearch.cjs.map +1 -1
- package/dist/cjs/utils.cjs +57 -49
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/esm/Asset.js +122 -166
- package/dist/esm/Asset.js.map +1 -1
- package/dist/esm/CatchBoundary.js +48 -50
- package/dist/esm/CatchBoundary.js.map +1 -1
- package/dist/esm/ClientOnly.js +58 -22
- package/dist/esm/ClientOnly.js.map +1 -1
- package/dist/esm/HeadContent.dev.js +46 -40
- package/dist/esm/HeadContent.dev.js.map +1 -1
- package/dist/esm/HeadContent.js +33 -26
- package/dist/esm/HeadContent.js.map +1 -1
- package/dist/esm/Match.js +359 -422
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.js +107 -142
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.js +26 -40
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/SafeFragment.js +6 -5
- package/dist/esm/SafeFragment.js.map +1 -1
- package/dist/esm/ScriptOnce.js +18 -21
- package/dist/esm/ScriptOnce.js.map +1 -1
- package/dist/esm/Scripts.js +42 -58
- package/dist/esm/Scripts.js.map +1 -1
- package/dist/esm/ScrollRestoration.js +25 -29
- package/dist/esm/ScrollRestoration.js.map +1 -1
- package/dist/esm/Transitioner.js +87 -105
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/awaited.js +28 -36
- package/dist/esm/awaited.js.map +1 -1
- package/dist/esm/fileRoute.d.ts +2 -2
- package/dist/esm/fileRoute.js +90 -92
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/headContentUtils.js +129 -152
- package/dist/esm/headContentUtils.js.map +1 -1
- package/dist/esm/index.dev.js +15 -115
- package/dist/esm/index.js +17 -116
- package/dist/esm/lazyRouteComponent.js +46 -53
- package/dist/esm/lazyRouteComponent.js.map +1 -1
- package/dist/esm/link.js +306 -329
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/matchContext.js +7 -7
- package/dist/esm/matchContext.js.map +1 -1
- package/dist/esm/not-found.js +23 -33
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/renderRouteNotFound.js +20 -15
- package/dist/esm/renderRouteNotFound.js.map +1 -1
- package/dist/esm/route.js +193 -218
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.js +17 -17
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerContext.js +6 -5
- package/dist/esm/routerContext.js.map +1 -1
- package/dist/esm/scroll-restoration.js +23 -34
- package/dist/esm/scroll-restoration.js.map +1 -1
- package/dist/esm/ssr/RouterClient.js +16 -22
- package/dist/esm/ssr/RouterClient.js.map +1 -1
- package/dist/esm/ssr/RouterServer.js +9 -10
- package/dist/esm/ssr/RouterServer.js.map +1 -1
- package/dist/esm/ssr/client.js +1 -4
- package/dist/esm/ssr/defaultRenderHandler.js +11 -15
- package/dist/esm/ssr/defaultRenderHandler.js.map +1 -1
- package/dist/esm/ssr/defaultStreamHandler.js +12 -17
- package/dist/esm/ssr/defaultStreamHandler.js.map +1 -1
- package/dist/esm/ssr/renderRouterToStream.js +23 -36
- package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
- package/dist/esm/ssr/renderRouterToString.js +31 -40
- package/dist/esm/ssr/renderRouterToString.js.map +1 -1
- package/dist/esm/ssr/server.js +3 -10
- package/dist/esm/useBlocker.d.ts +8 -5
- package/dist/esm/useBlocker.js +136 -159
- package/dist/esm/useBlocker.js.map +1 -1
- package/dist/esm/useCanGoBack.js +6 -5
- package/dist/esm/useCanGoBack.js.map +1 -1
- package/dist/esm/useLoaderData.js +12 -11
- package/dist/esm/useLoaderData.js.map +1 -1
- package/dist/esm/useLoaderDeps.js +12 -14
- package/dist/esm/useLoaderDeps.js.map +1 -1
- package/dist/esm/useLocation.js +6 -7
- package/dist/esm/useLocation.js.map +1 -1
- package/dist/esm/useMatch.js +21 -28
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useNavigate.js +18 -22
- package/dist/esm/useNavigate.js.map +1 -1
- package/dist/esm/useParams.js +14 -13
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useRouteContext.js +9 -8
- package/dist/esm/useRouteContext.js.map +1 -1
- package/dist/esm/useRouter.js +9 -8
- package/dist/esm/useRouter.js.map +1 -1
- package/dist/esm/useRouterState.js +36 -44
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/esm/useSearch.js +13 -12
- package/dist/esm/useSearch.js.map +1 -1
- package/dist/esm/utils.js +55 -33
- package/dist/esm/utils.js.map +1 -1
- package/dist/source/fileRoute.d.ts +2 -2
- package/dist/source/useBlocker.d.ts +8 -5
- package/dist/source/useBlocker.jsx +2 -2
- package/dist/source/useBlocker.jsx.map +1 -1
- package/package.json +3 -3
- package/src/fileRoute.ts +2 -2
- package/src/useBlocker.tsx +15 -10
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/index.dev.cjs.map +0 -1
- package/dist/cjs/ssr/client.cjs.map +0 -1
- package/dist/cjs/ssr/server.cjs.map +0 -1
- package/dist/esm/index.dev.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/ssr/client.js.map +0 -1
- package/dist/esm/ssr/server.js.map +0 -1
package/dist/esm/Match.js
CHANGED
|
@@ -1,432 +1,369 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as Solid from "solid-js";
|
|
3
|
-
import invariant from "tiny-invariant";
|
|
4
|
-
import warning from "tiny-warning";
|
|
5
|
-
import { isNotFound, rootRouteId, createControlledPromise, isRedirect, getLocationChangeInfo } from "@tanstack/router-core";
|
|
6
|
-
import { isServer } from "@tanstack/router-core/isServer";
|
|
7
|
-
import { ErrorComponent, CatchBoundary } from "./CatchBoundary.js";
|
|
8
|
-
import { useRouterState } from "./useRouterState.js";
|
|
1
|
+
import { CatchBoundary, ErrorComponent } from "./CatchBoundary.js";
|
|
9
2
|
import { useRouter } from "./useRouter.js";
|
|
10
|
-
import {
|
|
3
|
+
import { useRouterState } from "./useRouterState.js";
|
|
11
4
|
import { matchContext } from "./matchContext.js";
|
|
12
5
|
import { SafeFragment } from "./SafeFragment.js";
|
|
6
|
+
import { CatchNotFound } from "./not-found.js";
|
|
13
7
|
import { renderRouteNotFound } from "./renderRouteNotFound.js";
|
|
14
8
|
import { ScrollRestoration } from "./scroll-restoration.js";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return createComponent(MatchInner, {
|
|
137
|
-
get matchId() {
|
|
138
|
-
return props.matchId;
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
})];
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
}), memo(() => memo(() => parentRouteId() === rootRouteId)() ? [createComponent(OnRendered, {}), createComponent(ScrollRestoration, {})] : null)];
|
|
153
|
-
}
|
|
154
|
-
});
|
|
9
|
+
import { createControlledPromise, getLocationChangeInfo, isNotFound, isRedirect, rootRouteId } from "@tanstack/router-core";
|
|
10
|
+
import { Dynamic, createComponent, memo, mergeProps } from "@solidjs/web";
|
|
11
|
+
import * as Solid from "solid-js";
|
|
12
|
+
import warning from "tiny-warning";
|
|
13
|
+
import { isServer } from "@tanstack/router-core/isServer";
|
|
14
|
+
import invariant from "tiny-invariant";
|
|
15
|
+
//#region src/Match.tsx
|
|
16
|
+
var MatchContext = matchContext;
|
|
17
|
+
var Match = (props) => {
|
|
18
|
+
const router = useRouter();
|
|
19
|
+
const matchState = useRouterState({ select: (s) => {
|
|
20
|
+
const match = s.matches.find((d) => d.id === props.matchId);
|
|
21
|
+
if (!match) return null;
|
|
22
|
+
return {
|
|
23
|
+
routeId: match.routeId,
|
|
24
|
+
ssr: match.ssr,
|
|
25
|
+
_displayPending: match._displayPending
|
|
26
|
+
};
|
|
27
|
+
} });
|
|
28
|
+
if (!Solid.untrack(matchState)) return null;
|
|
29
|
+
const route = () => router.routesById[matchState().routeId];
|
|
30
|
+
const resolvePendingComponent = () => route().options.pendingComponent ?? router.options.defaultPendingComponent;
|
|
31
|
+
const routeErrorComponent = () => route().options.errorComponent ?? router.options.defaultErrorComponent;
|
|
32
|
+
const routeOnCatch = () => route().options.onCatch ?? router.options.defaultOnCatch;
|
|
33
|
+
const routeNotFoundComponent = () => route().isRoot ? route().options.notFoundComponent ?? router.options.notFoundRoute?.options.component : route().options.notFoundComponent;
|
|
34
|
+
const resolvedNoSsr = Solid.createMemo(() => matchState().ssr === false || matchState().ssr === "data-only");
|
|
35
|
+
const ResolvedSuspenseBoundary = () => resolvedNoSsr() ? SafeFragment : Solid.Loading;
|
|
36
|
+
const ResolvedCatchBoundary = () => routeErrorComponent() ? CatchBoundary : SafeFragment;
|
|
37
|
+
const ResolvedNotFoundBoundary = () => routeNotFoundComponent() ? CatchNotFound : SafeFragment;
|
|
38
|
+
const resetKey = useRouterState({ select: (s) => s.loadedAt });
|
|
39
|
+
const parentRouteId = useRouterState({ select: (s) => {
|
|
40
|
+
const index = s.matches.findIndex((d) => d.id === props.matchId);
|
|
41
|
+
return s.matches[index - 1]?.routeId;
|
|
42
|
+
} });
|
|
43
|
+
const ShellComponent = Solid.createMemo(() => route().isRoot ? route().options.shellComponent ?? SafeFragment : SafeFragment);
|
|
44
|
+
return createComponent(Dynamic, {
|
|
45
|
+
get component() {
|
|
46
|
+
return ShellComponent();
|
|
47
|
+
},
|
|
48
|
+
get children() {
|
|
49
|
+
return [createComponent(MatchContext, {
|
|
50
|
+
value: () => props.matchId,
|
|
51
|
+
get children() {
|
|
52
|
+
return createComponent(Dynamic, {
|
|
53
|
+
get component() {
|
|
54
|
+
return ResolvedSuspenseBoundary();
|
|
55
|
+
},
|
|
56
|
+
get fallback() {
|
|
57
|
+
return memo(() => !!((isServer ?? router.isServer) || resolvedNoSsr()))() ? void 0 : createComponent(Dynamic, { get component() {
|
|
58
|
+
return resolvePendingComponent();
|
|
59
|
+
} });
|
|
60
|
+
},
|
|
61
|
+
get children() {
|
|
62
|
+
return createComponent(Dynamic, {
|
|
63
|
+
get component() {
|
|
64
|
+
return ResolvedCatchBoundary();
|
|
65
|
+
},
|
|
66
|
+
getResetKey: () => resetKey(),
|
|
67
|
+
get errorComponent() {
|
|
68
|
+
return routeErrorComponent() || ErrorComponent;
|
|
69
|
+
},
|
|
70
|
+
onCatch: (error) => {
|
|
71
|
+
if (isNotFound(error)) throw error;
|
|
72
|
+
warning(false, `Error in route match: ${Solid.untrack(matchState).routeId}`);
|
|
73
|
+
routeOnCatch()?.(error);
|
|
74
|
+
},
|
|
75
|
+
get children() {
|
|
76
|
+
return createComponent(Dynamic, {
|
|
77
|
+
get component() {
|
|
78
|
+
return ResolvedNotFoundBoundary();
|
|
79
|
+
},
|
|
80
|
+
fallback: (error) => {
|
|
81
|
+
if (!routeNotFoundComponent() || error.routeId && error.routeId !== matchState().routeId || !error.routeId && !route().isRoot) throw error;
|
|
82
|
+
return createComponent(Dynamic, mergeProps({ get component() {
|
|
83
|
+
return routeNotFoundComponent();
|
|
84
|
+
} }, error));
|
|
85
|
+
},
|
|
86
|
+
get children() {
|
|
87
|
+
return createComponent(Solid.Switch, { get children() {
|
|
88
|
+
return [createComponent(Solid.Match, {
|
|
89
|
+
get when() {
|
|
90
|
+
return resolvedNoSsr();
|
|
91
|
+
},
|
|
92
|
+
get children() {
|
|
93
|
+
return createComponent(Solid.Show, {
|
|
94
|
+
get when() {
|
|
95
|
+
return !(isServer ?? router.isServer);
|
|
96
|
+
},
|
|
97
|
+
get fallback() {
|
|
98
|
+
return createComponent(Dynamic, { get component() {
|
|
99
|
+
return resolvePendingComponent();
|
|
100
|
+
} });
|
|
101
|
+
},
|
|
102
|
+
get children() {
|
|
103
|
+
return createComponent(MatchInner, { get matchId() {
|
|
104
|
+
return props.matchId;
|
|
105
|
+
} });
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}), createComponent(Solid.Match, {
|
|
110
|
+
get when() {
|
|
111
|
+
return !resolvedNoSsr();
|
|
112
|
+
},
|
|
113
|
+
get children() {
|
|
114
|
+
return createComponent(MatchInner, { get matchId() {
|
|
115
|
+
return props.matchId;
|
|
116
|
+
} });
|
|
117
|
+
}
|
|
118
|
+
})];
|
|
119
|
+
} });
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}), memo(() => memo(() => parentRouteId() === rootRouteId)() ? [createComponent(OnRendered, {}), createComponent(ScrollRestoration, {})] : null)];
|
|
128
|
+
}
|
|
129
|
+
});
|
|
155
130
|
};
|
|
156
|
-
|
|
131
|
+
var lastOnRenderedKey = /* @__PURE__ */ new WeakMap();
|
|
157
132
|
function OnRendered() {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
});
|
|
173
|
-
return null;
|
|
133
|
+
const router = useRouter();
|
|
134
|
+
const location = useRouterState({ select: (s) => {
|
|
135
|
+
return s.resolvedLocation?.state.__TSR_key;
|
|
136
|
+
} });
|
|
137
|
+
Solid.createEffect(() => [location()], ([location]) => {
|
|
138
|
+
if (!location) return;
|
|
139
|
+
if (lastOnRenderedKey.get(router) === location) return;
|
|
140
|
+
lastOnRenderedKey.set(router, location);
|
|
141
|
+
router.emit({
|
|
142
|
+
type: "onRendered",
|
|
143
|
+
...getLocationChangeInfo(router.state)
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
return null;
|
|
174
147
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
}
|
|
321
|
-
}), createComponent(Solid.Match, {
|
|
322
|
-
get when() {
|
|
323
|
-
return match().status === "success";
|
|
324
|
-
},
|
|
325
|
-
get children() {
|
|
326
|
-
return keyedOut();
|
|
327
|
-
}
|
|
328
|
-
})];
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
};
|
|
332
|
-
const Outlet = () => {
|
|
333
|
-
const router = useRouter();
|
|
334
|
-
const matchId = Solid.useContext(matchContext);
|
|
335
|
-
const routeId = useRouterState({
|
|
336
|
-
select: (s) => s.matches.find((d) => d.id === matchId())?.routeId
|
|
337
|
-
});
|
|
338
|
-
const route = () => router.routesById[routeId()];
|
|
339
|
-
const parentGlobalNotFound = useRouterState({
|
|
340
|
-
select: (s) => {
|
|
341
|
-
const matches = s.matches;
|
|
342
|
-
const parentMatch = matches.find((d) => d.id === matchId());
|
|
343
|
-
if (!parentMatch) {
|
|
344
|
-
return false;
|
|
345
|
-
}
|
|
346
|
-
return parentMatch.globalNotFound;
|
|
347
|
-
}
|
|
348
|
-
});
|
|
349
|
-
const childMatchId = useRouterState({
|
|
350
|
-
select: (s) => {
|
|
351
|
-
const matches = s.matches;
|
|
352
|
-
const index = matches.findIndex((d) => d.id === matchId());
|
|
353
|
-
const v = matches[index + 1]?.id;
|
|
354
|
-
return v;
|
|
355
|
-
}
|
|
356
|
-
});
|
|
357
|
-
const childRouteId = useRouterState({
|
|
358
|
-
select: (s) => {
|
|
359
|
-
const matches = s.matches;
|
|
360
|
-
const index = matches.findIndex((d) => d.id === matchId());
|
|
361
|
-
return matches[index + 1]?.routeId;
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
const childMatchStatus = useRouterState({
|
|
365
|
-
select: (s) => {
|
|
366
|
-
const matches = s.matches;
|
|
367
|
-
const index = matches.findIndex((d) => d.id === matchId());
|
|
368
|
-
return matches[index + 1]?.status;
|
|
369
|
-
}
|
|
370
|
-
});
|
|
371
|
-
const shouldShowNotFound = () => childMatchStatus() !== "redirected" && parentGlobalNotFound();
|
|
372
|
-
return createComponent(Solid.Show, {
|
|
373
|
-
get when() {
|
|
374
|
-
return memo(() => !!!shouldShowNotFound())() && childMatchId();
|
|
375
|
-
},
|
|
376
|
-
get fallback() {
|
|
377
|
-
return createComponent(Solid.Show, {
|
|
378
|
-
get when() {
|
|
379
|
-
return shouldShowNotFound();
|
|
380
|
-
},
|
|
381
|
-
get children() {
|
|
382
|
-
return renderRouteNotFound(router, route(), void 0);
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
|
-
},
|
|
386
|
-
children: (matchIdAccessor) => {
|
|
387
|
-
const currentMatchId = Solid.createMemo(() => matchIdAccessor());
|
|
388
|
-
return createComponent(Solid.Show, {
|
|
389
|
-
get when() {
|
|
390
|
-
return routeId() === rootRouteId;
|
|
391
|
-
},
|
|
392
|
-
get fallback() {
|
|
393
|
-
return createComponent(Match, {
|
|
394
|
-
get matchId() {
|
|
395
|
-
return currentMatchId();
|
|
396
|
-
}
|
|
397
|
-
});
|
|
398
|
-
},
|
|
399
|
-
get children() {
|
|
400
|
-
return createComponent(Solid.Show, {
|
|
401
|
-
get when() {
|
|
402
|
-
return childRouteId();
|
|
403
|
-
},
|
|
404
|
-
keyed: true,
|
|
405
|
-
children: (_routeId) => createComponent(Solid.Loading, {
|
|
406
|
-
get fallback() {
|
|
407
|
-
return createComponent(Dynamic, {
|
|
408
|
-
get component() {
|
|
409
|
-
return router.options.defaultPendingComponent;
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
},
|
|
413
|
-
get children() {
|
|
414
|
-
return createComponent(Match, {
|
|
415
|
-
get matchId() {
|
|
416
|
-
return currentMatchId();
|
|
417
|
-
}
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
})
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
});
|
|
148
|
+
var MatchInner = (props) => {
|
|
149
|
+
const router = useRouter();
|
|
150
|
+
const matchState = useRouterState({ select: (s) => {
|
|
151
|
+
const match = s.matches.find((d) => d.id === props.matchId);
|
|
152
|
+
if (!match) return null;
|
|
153
|
+
const routeId = match.routeId;
|
|
154
|
+
const remountDeps = (router.routesById[routeId].options.remountDeps ?? router.options.defaultRemountDeps)?.({
|
|
155
|
+
routeId,
|
|
156
|
+
loaderDeps: match.loaderDeps,
|
|
157
|
+
params: match._strictParams,
|
|
158
|
+
search: match._strictSearch
|
|
159
|
+
});
|
|
160
|
+
return {
|
|
161
|
+
key: remountDeps ? JSON.stringify(remountDeps) : void 0,
|
|
162
|
+
routeId,
|
|
163
|
+
match: {
|
|
164
|
+
id: match.id,
|
|
165
|
+
status: match.status,
|
|
166
|
+
error: match.error,
|
|
167
|
+
_forcePending: match._forcePending,
|
|
168
|
+
_displayPending: match._displayPending
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
} });
|
|
172
|
+
if (!Solid.untrack(matchState)) return null;
|
|
173
|
+
const route = () => router.routesById[matchState().routeId];
|
|
174
|
+
const match = () => matchState().match;
|
|
175
|
+
const componentKey = () => matchState().key ?? matchState().match.id;
|
|
176
|
+
const out = () => {
|
|
177
|
+
const Comp = Solid.untrack(route).options.component ?? router.options.defaultComponent;
|
|
178
|
+
if (Comp) return createComponent(Comp, {});
|
|
179
|
+
return createComponent(Outlet, {});
|
|
180
|
+
};
|
|
181
|
+
const keyedOut = () => createComponent(Solid.Show, {
|
|
182
|
+
get when() {
|
|
183
|
+
return componentKey();
|
|
184
|
+
},
|
|
185
|
+
keyed: true,
|
|
186
|
+
children: (_key) => out()
|
|
187
|
+
});
|
|
188
|
+
return createComponent(Solid.Switch, { get children() {
|
|
189
|
+
return [
|
|
190
|
+
createComponent(Solid.Match, {
|
|
191
|
+
get when() {
|
|
192
|
+
return match()._displayPending;
|
|
193
|
+
},
|
|
194
|
+
children: (_) => {
|
|
195
|
+
const matchId = Solid.untrack(() => match().id);
|
|
196
|
+
return memo(Solid.createMemo(() => router.getMatch(matchId)?._nonReactive.displayPendingPromise));
|
|
197
|
+
}
|
|
198
|
+
}),
|
|
199
|
+
createComponent(Solid.Match, {
|
|
200
|
+
get when() {
|
|
201
|
+
return match()._forcePending;
|
|
202
|
+
},
|
|
203
|
+
children: (_) => {
|
|
204
|
+
const matchId = Solid.untrack(() => match().id);
|
|
205
|
+
return memo(Solid.createMemo(() => router.getMatch(matchId)?._nonReactive.minPendingPromise));
|
|
206
|
+
}
|
|
207
|
+
}),
|
|
208
|
+
createComponent(Solid.Match, {
|
|
209
|
+
get when() {
|
|
210
|
+
return match().status === "pending";
|
|
211
|
+
},
|
|
212
|
+
children: (_) => {
|
|
213
|
+
const currentMatch = Solid.untrack(match);
|
|
214
|
+
const currentRoute = Solid.untrack(route);
|
|
215
|
+
const pendingMinMs = currentRoute.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
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const loaderResult = Solid.createMemo(async () => {
|
|
230
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
231
|
+
return router.getMatch(currentMatch.id)?._nonReactive.loadPromise;
|
|
232
|
+
});
|
|
233
|
+
const FallbackComponent = currentRoute.options.pendingComponent ?? router.options.defaultPendingComponent;
|
|
234
|
+
return [FallbackComponent && pendingMinMs > 0 ? createComponent(Dynamic, { component: FallbackComponent }) : null, memo(loaderResult)];
|
|
235
|
+
}
|
|
236
|
+
}),
|
|
237
|
+
createComponent(Solid.Match, {
|
|
238
|
+
get when() {
|
|
239
|
+
return match().status === "notFound";
|
|
240
|
+
},
|
|
241
|
+
children: (_) => {
|
|
242
|
+
const currentMatch = Solid.untrack(match);
|
|
243
|
+
const currentRoute = Solid.untrack(route);
|
|
244
|
+
const currentRouteId = Solid.untrack(() => matchState().routeId);
|
|
245
|
+
invariant(isNotFound(currentMatch.error), "Expected a notFound error");
|
|
246
|
+
return createComponent(Solid.Show, {
|
|
247
|
+
when: currentRouteId,
|
|
248
|
+
keyed: true,
|
|
249
|
+
children: (_routeId) => renderRouteNotFound(router, currentRoute, currentMatch.error)
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
}),
|
|
253
|
+
createComponent(Solid.Match, {
|
|
254
|
+
get when() {
|
|
255
|
+
return match().status === "redirected";
|
|
256
|
+
},
|
|
257
|
+
children: (_) => {
|
|
258
|
+
const matchId = Solid.untrack(() => match().id);
|
|
259
|
+
invariant(isRedirect(Solid.untrack(match).error), "Expected a redirect error");
|
|
260
|
+
return memo(Solid.createMemo(async () => {
|
|
261
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
262
|
+
return router.getMatch(matchId)?._nonReactive.loadPromise;
|
|
263
|
+
}));
|
|
264
|
+
}
|
|
265
|
+
}),
|
|
266
|
+
createComponent(Solid.Match, {
|
|
267
|
+
get when() {
|
|
268
|
+
return match().status === "error";
|
|
269
|
+
},
|
|
270
|
+
children: (_) => {
|
|
271
|
+
if (isServer ?? router.isServer) {
|
|
272
|
+
const currentMatch = Solid.untrack(match);
|
|
273
|
+
return createComponent((Solid.untrack(route).options.errorComponent ?? router.options.defaultErrorComponent) || ErrorComponent, {
|
|
274
|
+
get error() {
|
|
275
|
+
return currentMatch.error;
|
|
276
|
+
},
|
|
277
|
+
info: { componentStack: "" }
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
throw Solid.untrack(match).error;
|
|
281
|
+
}
|
|
282
|
+
}),
|
|
283
|
+
createComponent(Solid.Match, {
|
|
284
|
+
get when() {
|
|
285
|
+
return match().status === "success";
|
|
286
|
+
},
|
|
287
|
+
get children() {
|
|
288
|
+
return keyedOut();
|
|
289
|
+
}
|
|
290
|
+
})
|
|
291
|
+
];
|
|
292
|
+
} });
|
|
426
293
|
};
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
294
|
+
var Outlet = () => {
|
|
295
|
+
const router = useRouter();
|
|
296
|
+
const matchId = Solid.useContext(matchContext);
|
|
297
|
+
const routeId = useRouterState({ select: (s) => s.matches.find((d) => d.id === matchId())?.routeId });
|
|
298
|
+
const route = () => router.routesById[routeId()];
|
|
299
|
+
const parentGlobalNotFound = useRouterState({ select: (s) => {
|
|
300
|
+
const parentMatch = s.matches.find((d) => d.id === matchId());
|
|
301
|
+
if (!parentMatch) return false;
|
|
302
|
+
return parentMatch.globalNotFound;
|
|
303
|
+
} });
|
|
304
|
+
const childMatchId = useRouterState({ select: (s) => {
|
|
305
|
+
const matches = s.matches;
|
|
306
|
+
return matches[matches.findIndex((d) => d.id === matchId()) + 1]?.id;
|
|
307
|
+
} });
|
|
308
|
+
const childRouteId = useRouterState({ select: (s) => {
|
|
309
|
+
const matches = s.matches;
|
|
310
|
+
return matches[matches.findIndex((d) => d.id === matchId()) + 1]?.routeId;
|
|
311
|
+
} });
|
|
312
|
+
const childMatchStatus = useRouterState({ select: (s) => {
|
|
313
|
+
const matches = s.matches;
|
|
314
|
+
return matches[matches.findIndex((d) => d.id === matchId()) + 1]?.status;
|
|
315
|
+
} });
|
|
316
|
+
const shouldShowNotFound = () => childMatchStatus() !== "redirected" && parentGlobalNotFound();
|
|
317
|
+
return createComponent(Solid.Show, {
|
|
318
|
+
get when() {
|
|
319
|
+
return memo(() => !!!shouldShowNotFound())() && childMatchId();
|
|
320
|
+
},
|
|
321
|
+
get fallback() {
|
|
322
|
+
return createComponent(Solid.Show, {
|
|
323
|
+
get when() {
|
|
324
|
+
return shouldShowNotFound();
|
|
325
|
+
},
|
|
326
|
+
get children() {
|
|
327
|
+
return renderRouteNotFound(router, route(), void 0);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
},
|
|
331
|
+
children: (matchIdAccessor) => {
|
|
332
|
+
const currentMatchId = Solid.createMemo(() => matchIdAccessor());
|
|
333
|
+
return createComponent(Solid.Show, {
|
|
334
|
+
get when() {
|
|
335
|
+
return routeId() === rootRouteId;
|
|
336
|
+
},
|
|
337
|
+
get fallback() {
|
|
338
|
+
return createComponent(Match, { get matchId() {
|
|
339
|
+
return currentMatchId();
|
|
340
|
+
} });
|
|
341
|
+
},
|
|
342
|
+
get children() {
|
|
343
|
+
return createComponent(Solid.Show, {
|
|
344
|
+
get when() {
|
|
345
|
+
return childRouteId();
|
|
346
|
+
},
|
|
347
|
+
keyed: true,
|
|
348
|
+
children: (_routeId) => createComponent(Solid.Loading, {
|
|
349
|
+
get fallback() {
|
|
350
|
+
return createComponent(Dynamic, { get component() {
|
|
351
|
+
return router.options.defaultPendingComponent;
|
|
352
|
+
} });
|
|
353
|
+
},
|
|
354
|
+
get children() {
|
|
355
|
+
return createComponent(Match, { get matchId() {
|
|
356
|
+
return currentMatchId();
|
|
357
|
+
} });
|
|
358
|
+
}
|
|
359
|
+
})
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
});
|
|
431
365
|
};
|
|
432
|
-
//#
|
|
366
|
+
//#endregion
|
|
367
|
+
export { Match, Outlet };
|
|
368
|
+
|
|
369
|
+
//# sourceMappingURL=Match.js.map
|