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