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