@tanstack/solid-router 1.167.1 → 1.167.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.
Files changed (200) hide show
  1. package/dist/cjs/Asset.cjs +84 -127
  2. package/dist/cjs/Asset.cjs.map +1 -1
  3. package/dist/cjs/CatchBoundary.cjs +50 -68
  4. package/dist/cjs/CatchBoundary.cjs.map +1 -1
  5. package/dist/cjs/ClientOnly.cjs +61 -39
  6. package/dist/cjs/ClientOnly.cjs.map +1 -1
  7. package/dist/cjs/HeadContent.cjs +25 -19
  8. package/dist/cjs/HeadContent.cjs.map +1 -1
  9. package/dist/cjs/HeadContent.dev.cjs +38 -33
  10. package/dist/cjs/HeadContent.dev.cjs.map +1 -1
  11. package/dist/cjs/Match.cjs +330 -398
  12. package/dist/cjs/Match.cjs.map +1 -1
  13. package/dist/cjs/Matches.cjs +109 -151
  14. package/dist/cjs/Matches.cjs.map +1 -1
  15. package/dist/cjs/RouterProvider.cjs +28 -40
  16. package/dist/cjs/RouterProvider.cjs.map +1 -1
  17. package/dist/cjs/SafeFragment.cjs +7 -5
  18. package/dist/cjs/SafeFragment.cjs.map +1 -1
  19. package/dist/cjs/ScriptOnce.cjs +18 -20
  20. package/dist/cjs/ScriptOnce.cjs.map +1 -1
  21. package/dist/cjs/Scripts.cjs +41 -54
  22. package/dist/cjs/Scripts.cjs.map +1 -1
  23. package/dist/cjs/ScrollRestoration.cjs +26 -28
  24. package/dist/cjs/ScrollRestoration.cjs.map +1 -1
  25. package/dist/cjs/Transitioner.cjs +94 -129
  26. package/dist/cjs/Transitioner.cjs.map +1 -1
  27. package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
  28. package/dist/cjs/awaited.cjs +24 -51
  29. package/dist/cjs/awaited.cjs.map +1 -1
  30. package/dist/cjs/fileRoute.cjs +96 -91
  31. package/dist/cjs/fileRoute.cjs.map +1 -1
  32. package/dist/cjs/headContentUtils.cjs +132 -170
  33. package/dist/cjs/headContentUtils.cjs.map +1 -1
  34. package/dist/cjs/index.cjs +245 -176
  35. package/dist/cjs/index.dev.cjs +245 -176
  36. package/dist/cjs/lazyRouteComponent.cjs +48 -54
  37. package/dist/cjs/lazyRouteComponent.cjs.map +1 -1
  38. package/dist/cjs/link.cjs +304 -331
  39. package/dist/cjs/link.cjs.map +1 -1
  40. package/dist/cjs/matchContext.cjs +9 -23
  41. package/dist/cjs/matchContext.cjs.map +1 -1
  42. package/dist/cjs/not-found.cjs +26 -34
  43. package/dist/cjs/not-found.cjs.map +1 -1
  44. package/dist/cjs/renderRouteNotFound.cjs +23 -16
  45. package/dist/cjs/renderRouteNotFound.cjs.map +1 -1
  46. package/dist/cjs/route.cjs +200 -215
  47. package/dist/cjs/route.cjs.map +1 -1
  48. package/dist/cjs/router.cjs +18 -16
  49. package/dist/cjs/router.cjs.map +1 -1
  50. package/dist/cjs/routerContext.cjs +8 -22
  51. package/dist/cjs/routerContext.cjs.map +1 -1
  52. package/dist/cjs/scroll-restoration.cjs +25 -35
  53. package/dist/cjs/scroll-restoration.cjs.map +1 -1
  54. package/dist/cjs/ssr/RouterClient.cjs +31 -42
  55. package/dist/cjs/ssr/RouterClient.cjs.map +1 -1
  56. package/dist/cjs/ssr/RouterServer.cjs +44 -51
  57. package/dist/cjs/ssr/RouterServer.cjs.map +1 -1
  58. package/dist/cjs/ssr/client.cjs +2 -4
  59. package/dist/cjs/ssr/defaultRenderHandler.cjs +12 -16
  60. package/dist/cjs/ssr/defaultRenderHandler.cjs.map +1 -1
  61. package/dist/cjs/ssr/defaultStreamHandler.cjs +13 -18
  62. package/dist/cjs/ssr/defaultStreamHandler.cjs.map +1 -1
  63. package/dist/cjs/ssr/renderRouterToStream.cjs +27 -55
  64. package/dist/cjs/ssr/renderRouterToStream.cjs.map +1 -1
  65. package/dist/cjs/ssr/renderRouterToString.cjs +33 -57
  66. package/dist/cjs/ssr/renderRouterToString.cjs.map +1 -1
  67. package/dist/cjs/ssr/server.cjs +18 -18
  68. package/dist/cjs/useBlocker.cjs +138 -173
  69. package/dist/cjs/useBlocker.cjs.map +1 -1
  70. package/dist/cjs/useBlocker.d.cts +8 -5
  71. package/dist/cjs/useCanGoBack.cjs +6 -5
  72. package/dist/cjs/useCanGoBack.cjs.map +1 -1
  73. package/dist/cjs/useLoaderData.cjs +12 -11
  74. package/dist/cjs/useLoaderData.cjs.map +1 -1
  75. package/dist/cjs/useLoaderDeps.cjs +12 -14
  76. package/dist/cjs/useLoaderDeps.cjs.map +1 -1
  77. package/dist/cjs/useLocation.cjs +6 -7
  78. package/dist/cjs/useLocation.cjs.map +1 -1
  79. package/dist/cjs/useMatch.cjs +27 -49
  80. package/dist/cjs/useMatch.cjs.map +1 -1
  81. package/dist/cjs/useNavigate.cjs +20 -38
  82. package/dist/cjs/useNavigate.cjs.map +1 -1
  83. package/dist/cjs/useParams.cjs +14 -13
  84. package/dist/cjs/useParams.cjs.map +1 -1
  85. package/dist/cjs/useRouteContext.cjs +9 -8
  86. package/dist/cjs/useRouteContext.cjs.map +1 -1
  87. package/dist/cjs/useRouter.cjs +13 -26
  88. package/dist/cjs/useRouter.cjs.map +1 -1
  89. package/dist/cjs/useRouterState.cjs +29 -37
  90. package/dist/cjs/useRouterState.cjs.map +1 -1
  91. package/dist/cjs/useSearch.cjs +13 -12
  92. package/dist/cjs/useSearch.cjs.map +1 -1
  93. package/dist/cjs/utils.cjs +58 -51
  94. package/dist/cjs/utils.cjs.map +1 -1
  95. package/dist/esm/Asset.js +82 -126
  96. package/dist/esm/Asset.js.map +1 -1
  97. package/dist/esm/CatchBoundary.js +46 -50
  98. package/dist/esm/CatchBoundary.js.map +1 -1
  99. package/dist/esm/ClientOnly.js +58 -22
  100. package/dist/esm/ClientOnly.js.map +1 -1
  101. package/dist/esm/HeadContent.dev.js +36 -32
  102. package/dist/esm/HeadContent.dev.js.map +1 -1
  103. package/dist/esm/HeadContent.js +23 -18
  104. package/dist/esm/HeadContent.js.map +1 -1
  105. package/dist/esm/Match.js +322 -378
  106. package/dist/esm/Match.js.map +1 -1
  107. package/dist/esm/Matches.js +102 -135
  108. package/dist/esm/Matches.js.map +1 -1
  109. package/dist/esm/RouterProvider.js +25 -39
  110. package/dist/esm/RouterProvider.js.map +1 -1
  111. package/dist/esm/SafeFragment.js +6 -5
  112. package/dist/esm/SafeFragment.js.map +1 -1
  113. package/dist/esm/ScriptOnce.js +16 -19
  114. package/dist/esm/ScriptOnce.js.map +1 -1
  115. package/dist/esm/Scripts.js +40 -54
  116. package/dist/esm/Scripts.js.map +1 -1
  117. package/dist/esm/ScrollRestoration.js +25 -29
  118. package/dist/esm/ScrollRestoration.js.map +1 -1
  119. package/dist/esm/Transitioner.js +90 -110
  120. package/dist/esm/Transitioner.js.map +1 -1
  121. package/dist/esm/awaited.js +21 -34
  122. package/dist/esm/awaited.js.map +1 -1
  123. package/dist/esm/fileRoute.js +90 -92
  124. package/dist/esm/fileRoute.js.map +1 -1
  125. package/dist/esm/headContentUtils.js +129 -152
  126. package/dist/esm/headContentUtils.js.map +1 -1
  127. package/dist/esm/index.dev.js +15 -115
  128. package/dist/esm/index.js +17 -116
  129. package/dist/esm/lazyRouteComponent.js +47 -54
  130. package/dist/esm/lazyRouteComponent.js.map +1 -1
  131. package/dist/esm/link.js +299 -314
  132. package/dist/esm/link.js.map +1 -1
  133. package/dist/esm/matchContext.js +7 -7
  134. package/dist/esm/matchContext.js.map +1 -1
  135. package/dist/esm/not-found.js +23 -33
  136. package/dist/esm/not-found.js.map +1 -1
  137. package/dist/esm/renderRouteNotFound.js +20 -15
  138. package/dist/esm/renderRouteNotFound.js.map +1 -1
  139. package/dist/esm/route.js +193 -218
  140. package/dist/esm/route.js.map +1 -1
  141. package/dist/esm/router.js +17 -17
  142. package/dist/esm/router.js.map +1 -1
  143. package/dist/esm/routerContext.js +6 -5
  144. package/dist/esm/routerContext.js.map +1 -1
  145. package/dist/esm/scroll-restoration.js +23 -34
  146. package/dist/esm/scroll-restoration.js.map +1 -1
  147. package/dist/esm/ssr/RouterClient.js +29 -41
  148. package/dist/esm/ssr/RouterClient.js.map +1 -1
  149. package/dist/esm/ssr/RouterServer.js +40 -48
  150. package/dist/esm/ssr/RouterServer.js.map +1 -1
  151. package/dist/esm/ssr/client.js +1 -4
  152. package/dist/esm/ssr/defaultRenderHandler.js +11 -15
  153. package/dist/esm/ssr/defaultRenderHandler.js.map +1 -1
  154. package/dist/esm/ssr/defaultStreamHandler.js +12 -17
  155. package/dist/esm/ssr/defaultStreamHandler.js.map +1 -1
  156. package/dist/esm/ssr/renderRouterToStream.js +24 -37
  157. package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
  158. package/dist/esm/ssr/renderRouterToString.js +31 -40
  159. package/dist/esm/ssr/renderRouterToString.js.map +1 -1
  160. package/dist/esm/ssr/server.js +3 -10
  161. package/dist/esm/useBlocker.d.ts +8 -5
  162. package/dist/esm/useBlocker.js +134 -155
  163. package/dist/esm/useBlocker.js.map +1 -1
  164. package/dist/esm/useCanGoBack.js +6 -5
  165. package/dist/esm/useCanGoBack.js.map +1 -1
  166. package/dist/esm/useLoaderData.js +12 -11
  167. package/dist/esm/useLoaderData.js.map +1 -1
  168. package/dist/esm/useLoaderDeps.js +12 -14
  169. package/dist/esm/useLoaderDeps.js.map +1 -1
  170. package/dist/esm/useLocation.js +6 -7
  171. package/dist/esm/useLocation.js.map +1 -1
  172. package/dist/esm/useMatch.js +23 -31
  173. package/dist/esm/useMatch.js.map +1 -1
  174. package/dist/esm/useNavigate.js +18 -22
  175. package/dist/esm/useNavigate.js.map +1 -1
  176. package/dist/esm/useParams.js +14 -13
  177. package/dist/esm/useParams.js.map +1 -1
  178. package/dist/esm/useRouteContext.js +9 -8
  179. package/dist/esm/useRouteContext.js.map +1 -1
  180. package/dist/esm/useRouter.js +9 -8
  181. package/dist/esm/useRouter.js.map +1 -1
  182. package/dist/esm/useRouterState.js +28 -37
  183. package/dist/esm/useRouterState.js.map +1 -1
  184. package/dist/esm/useSearch.js +13 -12
  185. package/dist/esm/useSearch.js.map +1 -1
  186. package/dist/esm/utils.js +56 -35
  187. package/dist/esm/utils.js.map +1 -1
  188. package/dist/source/useBlocker.d.ts +8 -5
  189. package/dist/source/useBlocker.jsx +2 -2
  190. package/dist/source/useBlocker.jsx.map +1 -1
  191. package/package.json +3 -3
  192. package/src/useBlocker.tsx +15 -10
  193. package/dist/cjs/index.cjs.map +0 -1
  194. package/dist/cjs/index.dev.cjs.map +0 -1
  195. package/dist/cjs/ssr/client.cjs.map +0 -1
  196. package/dist/cjs/ssr/server.cjs.map +0 -1
  197. package/dist/esm/index.dev.js.map +0 -1
  198. package/dist/esm/index.js.map +0 -1
  199. package/dist/esm/ssr/client.js.map +0 -1
  200. package/dist/esm/ssr/server.js.map +0 -1
package/dist/esm/Match.js CHANGED
@@ -1,388 +1,332 @@
1
- import { createComponent, memo, Dynamic, mergeProps } from "solid-js/web";
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 { CatchNotFound } from "./not-found.js";
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
- const Match = (props) => {
16
- const router = useRouter();
17
- const matchState = useRouterState({
18
- select: (s) => {
19
- const match = s.matches.find((d) => d.id === props.matchId);
20
- if (!match) {
21
- return null;
22
- }
23
- return {
24
- routeId: match.routeId,
25
- ssr: match.ssr,
26
- _displayPending: match._displayPending
27
- };
28
- }
29
- });
30
- if (!matchState()) return null;
31
- const route = () => router.routesById[matchState().routeId];
32
- const resolvePendingComponent = () => route().options.pendingComponent ?? router.options.defaultPendingComponent;
33
- const routeErrorComponent = () => route().options.errorComponent ?? router.options.defaultErrorComponent;
34
- const routeOnCatch = () => route().options.onCatch ?? router.options.defaultOnCatch;
35
- const routeNotFoundComponent = () => route().isRoot ? (
36
- // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component
37
- route().options.notFoundComponent ?? router.options.notFoundRoute?.options.component
38
- ) : route().options.notFoundComponent;
39
- const resolvedNoSsr = matchState().ssr === false || matchState().ssr === "data-only";
40
- const ResolvedSuspenseBoundary = () => Solid.Suspense;
41
- const ResolvedCatchBoundary = () => routeErrorComponent() ? CatchBoundary : SafeFragment;
42
- const ResolvedNotFoundBoundary = () => routeNotFoundComponent() ? CatchNotFound : SafeFragment;
43
- const resetKey = useRouterState({
44
- select: (s) => s.loadedAt
45
- });
46
- const parentRouteId = useRouterState({
47
- select: (s) => {
48
- const index = s.matches.findIndex((d) => d.id === props.matchId);
49
- return s.matches[index - 1]?.routeId;
50
- }
51
- });
52
- const ShellComponent = route().isRoot ? route().options.shellComponent ?? SafeFragment : SafeFragment;
53
- return createComponent(ShellComponent, {
54
- get children() {
55
- return [createComponent(matchContext.Provider, {
56
- value: () => props.matchId,
57
- get children() {
58
- return createComponent(Dynamic, {
59
- get component() {
60
- return ResolvedSuspenseBoundary();
61
- },
62
- get fallback() {
63
- return (
64
- // Don't show fallback on server when using no-ssr mode to avoid hydration mismatch
65
- memo(() => !!((isServer ?? router.isServer) || resolvedNoSsr))() ? void 0 : createComponent(Dynamic, {
66
- get component() {
67
- return resolvePendingComponent();
68
- }
69
- })
70
- );
71
- },
72
- get children() {
73
- return createComponent(Dynamic, {
74
- get component() {
75
- return ResolvedCatchBoundary();
76
- },
77
- getResetKey: () => resetKey(),
78
- get errorComponent() {
79
- return routeErrorComponent() || ErrorComponent;
80
- },
81
- onCatch: (error) => {
82
- if (isNotFound(error)) throw error;
83
- warning(false, `Error in route match: ${matchState().routeId}`);
84
- routeOnCatch()?.(error);
85
- },
86
- get children() {
87
- return createComponent(Dynamic, {
88
- get component() {
89
- return ResolvedNotFoundBoundary();
90
- },
91
- fallback: (error) => {
92
- if (!routeNotFoundComponent() || error.routeId && error.routeId !== matchState().routeId || !error.routeId && !route().isRoot) throw error;
93
- return createComponent(Dynamic, mergeProps({
94
- get component() {
95
- return routeNotFoundComponent();
96
- }
97
- }, error));
98
- },
99
- get children() {
100
- return createComponent(Solid.Switch, {
101
- get children() {
102
- return [createComponent(Solid.Match, {
103
- when: resolvedNoSsr,
104
- get children() {
105
- return createComponent(Solid.Show, {
106
- get when() {
107
- return !(isServer ?? router.isServer);
108
- },
109
- get fallback() {
110
- return createComponent(Dynamic, {
111
- get component() {
112
- return resolvePendingComponent();
113
- }
114
- });
115
- },
116
- get children() {
117
- return createComponent(MatchInner, {
118
- get matchId() {
119
- return props.matchId;
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
- const router = useRouter();
150
- const location = useRouterState({
151
- select: (s) => {
152
- return s.resolvedLocation?.state.__TSR_key;
153
- }
154
- });
155
- Solid.createEffect(Solid.on([location], () => {
156
- router.emit({
157
- type: "onRendered",
158
- ...getLocationChangeInfo(router.state)
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
- const MatchInner = (props) => {
164
- const router = useRouter();
165
- const matchState = useRouterState({
166
- select: (s) => {
167
- const match2 = s.matches.find((d) => d.id === props.matchId);
168
- if (!match2) {
169
- return null;
170
- }
171
- const routeId = match2.routeId;
172
- const remountFn = router.routesById[routeId].options.remountDeps ?? router.options.defaultRemountDeps;
173
- const remountDeps = remountFn?.({
174
- routeId,
175
- loaderDeps: match2.loaderDeps,
176
- params: match2._strictParams,
177
- search: match2._strictSearch
178
- });
179
- const key = remountDeps ? JSON.stringify(remountDeps) : void 0;
180
- return {
181
- key,
182
- routeId,
183
- match: {
184
- id: match2.id,
185
- status: match2.status,
186
- error: match2.error,
187
- _forcePending: match2._forcePending,
188
- _displayPending: match2._displayPending
189
- }
190
- };
191
- }
192
- });
193
- if (!matchState()) return null;
194
- const route = () => router.routesById[matchState().routeId];
195
- const match = () => matchState().match;
196
- const componentKey = () => matchState().key ?? matchState().match.id;
197
- const out = () => {
198
- const Comp = route().options.component ?? router.options.defaultComponent;
199
- if (Comp) {
200
- return createComponent(Comp, {});
201
- }
202
- return createComponent(Outlet, {});
203
- };
204
- const keyedOut = () => createComponent(Solid.Show, {
205
- get when() {
206
- return componentKey();
207
- },
208
- keyed: true,
209
- children: (_key) => out()
210
- });
211
- return createComponent(Solid.Switch, {
212
- get children() {
213
- return [createComponent(Solid.Match, {
214
- get when() {
215
- return match()._displayPending;
216
- },
217
- children: (_) => {
218
- const [displayPendingResult] = Solid.createResource(() => router.getMatch(match().id)?._nonReactive.displayPendingPromise);
219
- return memo(displayPendingResult);
220
- }
221
- }), createComponent(Solid.Match, {
222
- get when() {
223
- return match()._forcePending;
224
- },
225
- children: (_) => {
226
- const [minPendingResult] = Solid.createResource(() => router.getMatch(match().id)?._nonReactive.minPendingPromise);
227
- return memo(minPendingResult);
228
- }
229
- }), createComponent(Solid.Match, {
230
- get when() {
231
- return match().status === "pending";
232
- },
233
- children: (_) => {
234
- const pendingMinMs = route().options.pendingMinMs ?? router.options.defaultPendingMinMs;
235
- if (pendingMinMs) {
236
- const routerMatch = router.getMatch(match().id);
237
- if (routerMatch && !routerMatch._nonReactive.minPendingPromise) {
238
- if (!(isServer ?? router.isServer)) {
239
- const minPendingPromise = createControlledPromise();
240
- routerMatch._nonReactive.minPendingPromise = minPendingPromise;
241
- setTimeout(() => {
242
- minPendingPromise.resolve();
243
- routerMatch._nonReactive.minPendingPromise = void 0;
244
- }, pendingMinMs);
245
- }
246
- }
247
- }
248
- const [loaderResult] = Solid.createResource(async () => {
249
- await new Promise((r) => setTimeout(r, 0));
250
- return router.getMatch(match().id)?._nonReactive.loadPromise;
251
- });
252
- const FallbackComponent = route().options.pendingComponent ?? router.options.defaultPendingComponent;
253
- return [FallbackComponent && pendingMinMs > 0 ? createComponent(Dynamic, {
254
- component: FallbackComponent
255
- }) : null, memo(loaderResult)];
256
- }
257
- }), createComponent(Solid.Match, {
258
- get when() {
259
- return match().status === "notFound";
260
- },
261
- children: (_) => {
262
- invariant(isNotFound(match().error), "Expected a notFound error");
263
- return createComponent(Solid.Show, {
264
- get when() {
265
- return matchState().routeId;
266
- },
267
- keyed: true,
268
- children: (_routeId) => renderRouteNotFound(router, route(), match().error)
269
- });
270
- }
271
- }), createComponent(Solid.Match, {
272
- get when() {
273
- return match().status === "redirected";
274
- },
275
- children: (_) => {
276
- invariant(isRedirect(match().error), "Expected a redirect error");
277
- const [loaderResult] = Solid.createResource(async () => {
278
- await new Promise((r) => setTimeout(r, 0));
279
- return router.getMatch(match().id)?._nonReactive.loadPromise;
280
- });
281
- return memo(loaderResult);
282
- }
283
- }), createComponent(Solid.Match, {
284
- get when() {
285
- return match().status === "error";
286
- },
287
- children: (_) => {
288
- throw match().error;
289
- }
290
- }), createComponent(Solid.Match, {
291
- get when() {
292
- return match().status === "success";
293
- },
294
- get children() {
295
- return keyedOut();
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
- export {
384
- Match,
385
- MatchInner,
386
- Outlet
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
- //# sourceMappingURL=Match.js.map
329
+ //#endregion
330
+ export { Match, Outlet };
331
+
332
+ //# sourceMappingURL=Match.js.map