@tanstack/react-router 1.121.15 → 1.121.17

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 (241) hide show
  1. package/package.json +2 -2
  2. package/dist/cjs/Asset.cjs +0 -41
  3. package/dist/cjs/Asset.cjs.map +0 -1
  4. package/dist/cjs/Asset.d.cts +0 -2
  5. package/dist/cjs/CatchBoundary.cjs +0 -114
  6. package/dist/cjs/CatchBoundary.cjs.map +0 -1
  7. package/dist/cjs/CatchBoundary.d.cts +0 -12
  8. package/dist/cjs/ClientOnly.cjs +0 -20
  9. package/dist/cjs/ClientOnly.cjs.map +0 -1
  10. package/dist/cjs/ClientOnly.d.cts +0 -29
  11. package/dist/cjs/HeadContent.cjs +0 -155
  12. package/dist/cjs/HeadContent.cjs.map +0 -1
  13. package/dist/cjs/HeadContent.d.cts +0 -7
  14. package/dist/cjs/Match.cjs +0 -257
  15. package/dist/cjs/Match.cjs.map +0 -1
  16. package/dist/cjs/Match.d.cts +0 -8
  17. package/dist/cjs/Matches.cjs +0 -136
  18. package/dist/cjs/Matches.cjs.map +0 -1
  19. package/dist/cjs/Matches.d.cts +0 -26
  20. package/dist/cjs/RouterProvider.cjs +0 -33
  21. package/dist/cjs/RouterProvider.cjs.map +0 -1
  22. package/dist/cjs/RouterProvider.d.cts +0 -10
  23. package/dist/cjs/SafeFragment.cjs +0 -8
  24. package/dist/cjs/SafeFragment.cjs.map +0 -1
  25. package/dist/cjs/SafeFragment.d.cts +0 -1
  26. package/dist/cjs/ScriptOnce.cjs +0 -28
  27. package/dist/cjs/ScriptOnce.cjs.map +0 -1
  28. package/dist/cjs/ScriptOnce.d.cts +0 -5
  29. package/dist/cjs/Scripts.cjs +0 -51
  30. package/dist/cjs/Scripts.cjs.map +0 -1
  31. package/dist/cjs/Scripts.d.cts +0 -1
  32. package/dist/cjs/ScrollRestoration.cjs +0 -39
  33. package/dist/cjs/ScrollRestoration.cjs.map +0 -1
  34. package/dist/cjs/ScrollRestoration.d.cts +0 -14
  35. package/dist/cjs/Transitioner.cjs +0 -115
  36. package/dist/cjs/Transitioner.cjs.map +0 -1
  37. package/dist/cjs/Transitioner.d.cts +0 -1
  38. package/dist/cjs/awaited.cjs +0 -48
  39. package/dist/cjs/awaited.cjs.map +0 -1
  40. package/dist/cjs/awaited.d.cts +0 -10
  41. package/dist/cjs/fileRoute.cjs +0 -107
  42. package/dist/cjs/fileRoute.cjs.map +0 -1
  43. package/dist/cjs/fileRoute.d.cts +0 -54
  44. package/dist/cjs/history.d.cts +0 -8
  45. package/dist/cjs/index.cjs +0 -289
  46. package/dist/cjs/index.cjs.map +0 -1
  47. package/dist/cjs/index.d.cts +0 -55
  48. package/dist/cjs/lazyRouteComponent.cjs +0 -78
  49. package/dist/cjs/lazyRouteComponent.cjs.map +0 -1
  50. package/dist/cjs/lazyRouteComponent.d.cts +0 -2
  51. package/dist/cjs/link.cjs +0 -324
  52. package/dist/cjs/link.cjs.map +0 -1
  53. package/dist/cjs/link.d.cts +0 -48
  54. package/dist/cjs/matchContext.cjs +0 -27
  55. package/dist/cjs/matchContext.cjs.map +0 -1
  56. package/dist/cjs/matchContext.d.cts +0 -3
  57. package/dist/cjs/not-found.cjs +0 -40
  58. package/dist/cjs/not-found.cjs.map +0 -1
  59. package/dist/cjs/not-found.d.cts +0 -9
  60. package/dist/cjs/renderRouteNotFound.cjs +0 -22
  61. package/dist/cjs/renderRouteNotFound.cjs.map +0 -1
  62. package/dist/cjs/renderRouteNotFound.d.cts +0 -2
  63. package/dist/cjs/route.cjs +0 -205
  64. package/dist/cjs/route.cjs.map +0 -1
  65. package/dist/cjs/route.d.cts +0 -95
  66. package/dist/cjs/router.cjs +0 -22
  67. package/dist/cjs/router.cjs.map +0 -1
  68. package/dist/cjs/router.d.cts +0 -72
  69. package/dist/cjs/routerContext.cjs +0 -33
  70. package/dist/cjs/routerContext.cjs.map +0 -1
  71. package/dist/cjs/routerContext.d.cts +0 -8
  72. package/dist/cjs/scroll-restoration.cjs +0 -24
  73. package/dist/cjs/scroll-restoration.cjs.map +0 -1
  74. package/dist/cjs/scroll-restoration.d.cts +0 -1
  75. package/dist/cjs/serializer.d.cts +0 -6
  76. package/dist/cjs/structuralSharing.d.cts +0 -8
  77. package/dist/cjs/typePrimitives.d.cts +0 -16
  78. package/dist/cjs/useBlocker.cjs +0 -165
  79. package/dist/cjs/useBlocker.cjs.map +0 -1
  80. package/dist/cjs/useBlocker.d.cts +0 -66
  81. package/dist/cjs/useCanGoBack.cjs +0 -8
  82. package/dist/cjs/useCanGoBack.cjs.map +0 -1
  83. package/dist/cjs/useCanGoBack.d.cts +0 -1
  84. package/dist/cjs/useLoaderData.cjs +0 -15
  85. package/dist/cjs/useLoaderData.cjs.map +0 -1
  86. package/dist/cjs/useLoaderData.d.cts +0 -8
  87. package/dist/cjs/useLoaderDeps.cjs +0 -14
  88. package/dist/cjs/useLoaderDeps.cjs.map +0 -1
  89. package/dist/cjs/useLoaderDeps.d.cts +0 -8
  90. package/dist/cjs/useLocation.cjs +0 -10
  91. package/dist/cjs/useLocation.cjs.map +0 -1
  92. package/dist/cjs/useLocation.d.cts +0 -7
  93. package/dist/cjs/useMatch.cjs +0 -47
  94. package/dist/cjs/useMatch.cjs.map +0 -1
  95. package/dist/cjs/useMatch.d.cts +0 -10
  96. package/dist/cjs/useNavigate.cjs +0 -55
  97. package/dist/cjs/useNavigate.cjs.map +0 -1
  98. package/dist/cjs/useNavigate.d.cts +0 -5
  99. package/dist/cjs/useParams.cjs +0 -16
  100. package/dist/cjs/useParams.cjs.map +0 -1
  101. package/dist/cjs/useParams.d.cts +0 -9
  102. package/dist/cjs/useRouteContext.cjs +0 -11
  103. package/dist/cjs/useRouteContext.cjs.map +0 -1
  104. package/dist/cjs/useRouteContext.d.cts +0 -3
  105. package/dist/cjs/useRouter.cjs +0 -32
  106. package/dist/cjs/useRouter.cjs.map +0 -1
  107. package/dist/cjs/useRouter.d.cts +0 -4
  108. package/dist/cjs/useRouterState.cjs +0 -29
  109. package/dist/cjs/useRouterState.cjs.map +0 -1
  110. package/dist/cjs/useRouterState.d.cts +0 -8
  111. package/dist/cjs/useSearch.cjs +0 -16
  112. package/dist/cjs/useSearch.cjs.map +0 -1
  113. package/dist/cjs/useSearch.d.cts +0 -9
  114. package/dist/cjs/utils.cjs +0 -72
  115. package/dist/cjs/utils.cjs.map +0 -1
  116. package/dist/cjs/utils.d.cts +0 -49
  117. package/dist/esm/Asset.d.ts +0 -2
  118. package/dist/esm/Asset.js +0 -41
  119. package/dist/esm/Asset.js.map +0 -1
  120. package/dist/esm/CatchBoundary.d.ts +0 -12
  121. package/dist/esm/CatchBoundary.js +0 -97
  122. package/dist/esm/CatchBoundary.js.map +0 -1
  123. package/dist/esm/ClientOnly.d.ts +0 -29
  124. package/dist/esm/ClientOnly.js +0 -20
  125. package/dist/esm/ClientOnly.js.map +0 -1
  126. package/dist/esm/HeadContent.d.ts +0 -7
  127. package/dist/esm/HeadContent.js +0 -139
  128. package/dist/esm/HeadContent.js.map +0 -1
  129. package/dist/esm/Match.d.ts +0 -8
  130. package/dist/esm/Match.js +0 -240
  131. package/dist/esm/Match.js.map +0 -1
  132. package/dist/esm/Matches.d.ts +0 -26
  133. package/dist/esm/Matches.js +0 -119
  134. package/dist/esm/Matches.js.map +0 -1
  135. package/dist/esm/RouterProvider.d.ts +0 -10
  136. package/dist/esm/RouterProvider.js +0 -33
  137. package/dist/esm/RouterProvider.js.map +0 -1
  138. package/dist/esm/SafeFragment.d.ts +0 -1
  139. package/dist/esm/SafeFragment.js +0 -8
  140. package/dist/esm/SafeFragment.js.map +0 -1
  141. package/dist/esm/ScriptOnce.d.ts +0 -5
  142. package/dist/esm/ScriptOnce.js +0 -28
  143. package/dist/esm/ScriptOnce.js.map +0 -1
  144. package/dist/esm/Scripts.d.ts +0 -1
  145. package/dist/esm/Scripts.js +0 -51
  146. package/dist/esm/Scripts.js.map +0 -1
  147. package/dist/esm/ScrollRestoration.d.ts +0 -14
  148. package/dist/esm/ScrollRestoration.js +0 -39
  149. package/dist/esm/ScrollRestoration.js.map +0 -1
  150. package/dist/esm/Transitioner.d.ts +0 -1
  151. package/dist/esm/Transitioner.js +0 -98
  152. package/dist/esm/Transitioner.js.map +0 -1
  153. package/dist/esm/awaited.d.ts +0 -10
  154. package/dist/esm/awaited.js +0 -31
  155. package/dist/esm/awaited.js.map +0 -1
  156. package/dist/esm/fileRoute.d.ts +0 -54
  157. package/dist/esm/fileRoute.js +0 -107
  158. package/dist/esm/fileRoute.js.map +0 -1
  159. package/dist/esm/history.d.ts +0 -8
  160. package/dist/esm/index.d.ts +0 -55
  161. package/dist/esm/index.js +0 -151
  162. package/dist/esm/index.js.map +0 -1
  163. package/dist/esm/lazyRouteComponent.d.ts +0 -2
  164. package/dist/esm/lazyRouteComponent.js +0 -61
  165. package/dist/esm/lazyRouteComponent.js.map +0 -1
  166. package/dist/esm/link.d.ts +0 -48
  167. package/dist/esm/link.js +0 -307
  168. package/dist/esm/link.js.map +0 -1
  169. package/dist/esm/matchContext.d.ts +0 -3
  170. package/dist/esm/matchContext.js +0 -10
  171. package/dist/esm/matchContext.js.map +0 -1
  172. package/dist/esm/not-found.d.ts +0 -9
  173. package/dist/esm/not-found.js +0 -40
  174. package/dist/esm/not-found.js.map +0 -1
  175. package/dist/esm/renderRouteNotFound.d.ts +0 -2
  176. package/dist/esm/renderRouteNotFound.js +0 -22
  177. package/dist/esm/renderRouteNotFound.js.map +0 -1
  178. package/dist/esm/route.d.ts +0 -95
  179. package/dist/esm/route.js +0 -205
  180. package/dist/esm/route.js.map +0 -1
  181. package/dist/esm/router.d.ts +0 -72
  182. package/dist/esm/router.js +0 -22
  183. package/dist/esm/router.js.map +0 -1
  184. package/dist/esm/routerContext.d.ts +0 -8
  185. package/dist/esm/routerContext.js +0 -16
  186. package/dist/esm/routerContext.js.map +0 -1
  187. package/dist/esm/scroll-restoration.d.ts +0 -1
  188. package/dist/esm/scroll-restoration.js +0 -24
  189. package/dist/esm/scroll-restoration.js.map +0 -1
  190. package/dist/esm/serializer.d.ts +0 -6
  191. package/dist/esm/structuralSharing.d.ts +0 -8
  192. package/dist/esm/typePrimitives.d.ts +0 -16
  193. package/dist/esm/useBlocker.d.ts +0 -66
  194. package/dist/esm/useBlocker.js +0 -148
  195. package/dist/esm/useBlocker.js.map +0 -1
  196. package/dist/esm/useCanGoBack.d.ts +0 -1
  197. package/dist/esm/useCanGoBack.js +0 -8
  198. package/dist/esm/useCanGoBack.js.map +0 -1
  199. package/dist/esm/useLoaderData.d.ts +0 -8
  200. package/dist/esm/useLoaderData.js +0 -15
  201. package/dist/esm/useLoaderData.js.map +0 -1
  202. package/dist/esm/useLoaderDeps.d.ts +0 -8
  203. package/dist/esm/useLoaderDeps.js +0 -14
  204. package/dist/esm/useLoaderDeps.js.map +0 -1
  205. package/dist/esm/useLocation.d.ts +0 -7
  206. package/dist/esm/useLocation.js +0 -10
  207. package/dist/esm/useLocation.js.map +0 -1
  208. package/dist/esm/useMatch.d.ts +0 -10
  209. package/dist/esm/useMatch.js +0 -30
  210. package/dist/esm/useMatch.js.map +0 -1
  211. package/dist/esm/useNavigate.d.ts +0 -5
  212. package/dist/esm/useNavigate.js +0 -38
  213. package/dist/esm/useNavigate.js.map +0 -1
  214. package/dist/esm/useParams.d.ts +0 -9
  215. package/dist/esm/useParams.js +0 -16
  216. package/dist/esm/useParams.js.map +0 -1
  217. package/dist/esm/useRouteContext.d.ts +0 -3
  218. package/dist/esm/useRouteContext.js +0 -11
  219. package/dist/esm/useRouteContext.js.map +0 -1
  220. package/dist/esm/useRouter.d.ts +0 -4
  221. package/dist/esm/useRouter.js +0 -15
  222. package/dist/esm/useRouter.js.map +0 -1
  223. package/dist/esm/useRouterState.d.ts +0 -8
  224. package/dist/esm/useRouterState.js +0 -29
  225. package/dist/esm/useRouterState.js.map +0 -1
  226. package/dist/esm/useSearch.d.ts +0 -9
  227. package/dist/esm/useSearch.js +0 -16
  228. package/dist/esm/useSearch.js.map +0 -1
  229. package/dist/esm/utils.d.ts +0 -49
  230. package/dist/esm/utils.js +0 -55
  231. package/dist/esm/utils.js.map +0 -1
  232. package/dist/llms/index.d.ts +0 -3
  233. package/dist/llms/index.js +0 -35
  234. package/dist/llms/rules/api.d.ts +0 -2
  235. package/dist/llms/rules/api.js +0 -4241
  236. package/dist/llms/rules/guide.d.ts +0 -2
  237. package/dist/llms/rules/guide.js +0 -6225
  238. package/dist/llms/rules/routing.d.ts +0 -2
  239. package/dist/llms/rules/routing.js +0 -1946
  240. package/dist/llms/rules/setup-and-architecture.d.ts +0 -2
  241. package/dist/llms/rules/setup-and-architecture.js +0 -932
package/dist/esm/Match.js DELETED
@@ -1,240 +0,0 @@
1
- import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
- import * as React from "react";
3
- import invariant from "tiny-invariant";
4
- import warning from "tiny-warning";
5
- import { isNotFound, rootRouteId, pick, isRedirect, createControlledPromise, getLocationChangeInfo } from "@tanstack/router-core";
6
- import { CatchBoundary, ErrorComponent } from "./CatchBoundary.js";
7
- import { useRouterState } from "./useRouterState.js";
8
- import { useRouter } from "./useRouter.js";
9
- import { CatchNotFound } from "./not-found.js";
10
- import { matchContext } from "./matchContext.js";
11
- import { SafeFragment } from "./SafeFragment.js";
12
- import { renderRouteNotFound } from "./renderRouteNotFound.js";
13
- import { ScrollRestoration } from "./scroll-restoration.js";
14
- const Match = React.memo(function MatchImpl({
15
- matchId
16
- }) {
17
- var _a, _b;
18
- const router = useRouter();
19
- const routeId = useRouterState({
20
- select: (s) => {
21
- var _a2;
22
- return (_a2 = s.matches.find((d) => d.id === matchId)) == null ? void 0 : _a2.routeId;
23
- }
24
- });
25
- invariant(
26
- routeId,
27
- `Could not find routeId for matchId "${matchId}". Please file an issue!`
28
- );
29
- const route = router.routesById[routeId];
30
- const PendingComponent = route.options.pendingComponent ?? router.options.defaultPendingComponent;
31
- const pendingElement = PendingComponent ? /* @__PURE__ */ jsx(PendingComponent, {}) : null;
32
- const routeErrorComponent = route.options.errorComponent ?? router.options.defaultErrorComponent;
33
- const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch;
34
- const routeNotFoundComponent = route.isRoot ? (
35
- // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component
36
- route.options.notFoundComponent ?? ((_a = router.options.notFoundRoute) == null ? void 0 : _a.options.component)
37
- ) : route.options.notFoundComponent;
38
- const ResolvedSuspenseBoundary = (
39
- // If we're on the root route, allow forcefully wrapping in suspense
40
- (!route.isRoot || route.options.wrapInSuspense) && (route.options.wrapInSuspense ?? PendingComponent ?? ((_b = route.options.errorComponent) == null ? void 0 : _b.preload)) ? React.Suspense : SafeFragment
41
- );
42
- const ResolvedCatchBoundary = routeErrorComponent ? CatchBoundary : SafeFragment;
43
- const ResolvedNotFoundBoundary = routeNotFoundComponent ? CatchNotFound : SafeFragment;
44
- const resetKey = useRouterState({
45
- select: (s) => s.loadedAt
46
- });
47
- const parentRouteId = useRouterState({
48
- select: (s) => {
49
- var _a2;
50
- const index = s.matches.findIndex((d) => d.id === matchId);
51
- return (_a2 = s.matches[index - 1]) == null ? void 0 : _a2.routeId;
52
- }
53
- });
54
- return /* @__PURE__ */ jsxs(Fragment, { children: [
55
- /* @__PURE__ */ jsx(matchContext.Provider, { value: matchId, children: /* @__PURE__ */ jsx(ResolvedSuspenseBoundary, { fallback: pendingElement, children: /* @__PURE__ */ jsx(
56
- ResolvedCatchBoundary,
57
- {
58
- getResetKey: () => resetKey,
59
- errorComponent: routeErrorComponent || ErrorComponent,
60
- onCatch: (error, errorInfo) => {
61
- if (isNotFound(error)) throw error;
62
- warning(false, `Error in route match: ${matchId}`);
63
- routeOnCatch == null ? void 0 : routeOnCatch(error, errorInfo);
64
- },
65
- children: /* @__PURE__ */ jsx(
66
- ResolvedNotFoundBoundary,
67
- {
68
- fallback: (error) => {
69
- if (!routeNotFoundComponent || error.routeId && error.routeId !== routeId || !error.routeId && !route.isRoot)
70
- throw error;
71
- return React.createElement(routeNotFoundComponent, error);
72
- },
73
- children: /* @__PURE__ */ jsx(MatchInner, { matchId })
74
- }
75
- )
76
- }
77
- ) }) }),
78
- parentRouteId === rootRouteId && router.options.scrollRestoration ? /* @__PURE__ */ jsxs(Fragment, { children: [
79
- /* @__PURE__ */ jsx(OnRendered, {}),
80
- /* @__PURE__ */ jsx(ScrollRestoration, {})
81
- ] }) : null
82
- ] });
83
- });
84
- function OnRendered() {
85
- const router = useRouter();
86
- const prevLocationRef = React.useRef(
87
- void 0
88
- );
89
- return /* @__PURE__ */ jsx(
90
- "script",
91
- {
92
- suppressHydrationWarning: true,
93
- ref: (el) => {
94
- if (el && (prevLocationRef.current === void 0 || prevLocationRef.current.href !== router.latestLocation.href)) {
95
- router.emit({
96
- type: "onRendered",
97
- ...getLocationChangeInfo(router.state)
98
- });
99
- prevLocationRef.current = router.latestLocation;
100
- }
101
- }
102
- },
103
- router.latestLocation.state.key
104
- );
105
- }
106
- const MatchInner = React.memo(function MatchInnerImpl({
107
- matchId
108
- }) {
109
- var _a, _b, _c;
110
- const router = useRouter();
111
- const { match, key, routeId } = useRouterState({
112
- select: (s) => {
113
- const matchIndex = s.matches.findIndex((d) => d.id === matchId);
114
- const match2 = s.matches[matchIndex];
115
- const routeId2 = match2.routeId;
116
- const remountFn = router.routesById[routeId2].options.remountDeps ?? router.options.defaultRemountDeps;
117
- const remountDeps = remountFn == null ? void 0 : remountFn({
118
- routeId: routeId2,
119
- loaderDeps: match2.loaderDeps,
120
- params: match2._strictParams,
121
- search: match2._strictSearch
122
- });
123
- const key2 = remountDeps ? JSON.stringify(remountDeps) : void 0;
124
- return {
125
- key: key2,
126
- routeId: routeId2,
127
- match: pick(match2, ["id", "status", "error"])
128
- };
129
- },
130
- structuralSharing: true
131
- });
132
- const route = router.routesById[routeId];
133
- const out = React.useMemo(() => {
134
- const Comp = route.options.component ?? router.options.defaultComponent;
135
- if (Comp) {
136
- return /* @__PURE__ */ jsx(Comp, {}, key);
137
- }
138
- return /* @__PURE__ */ jsx(Outlet, {});
139
- }, [key, route.options.component, router.options.defaultComponent]);
140
- const RouteErrorComponent = (route.options.errorComponent ?? router.options.defaultErrorComponent) || ErrorComponent;
141
- if (match.status === "notFound") {
142
- invariant(isNotFound(match.error), "Expected a notFound error");
143
- return renderRouteNotFound(router, route, match.error);
144
- }
145
- if (match.status === "redirected") {
146
- invariant(isRedirect(match.error), "Expected a redirect error");
147
- throw (_a = router.getMatch(match.id)) == null ? void 0 : _a.loadPromise;
148
- }
149
- if (match.status === "error") {
150
- if (router.isServer) {
151
- return /* @__PURE__ */ jsx(
152
- RouteErrorComponent,
153
- {
154
- error: match.error,
155
- reset: void 0,
156
- info: {
157
- componentStack: ""
158
- }
159
- }
160
- );
161
- }
162
- throw match.error;
163
- }
164
- if (match.status === "pending") {
165
- const pendingMinMs = route.options.pendingMinMs ?? router.options.defaultPendingMinMs;
166
- if (pendingMinMs && !((_b = router.getMatch(match.id)) == null ? void 0 : _b.minPendingPromise)) {
167
- if (!router.isServer) {
168
- const minPendingPromise = createControlledPromise();
169
- Promise.resolve().then(() => {
170
- router.updateMatch(match.id, (prev) => ({
171
- ...prev,
172
- minPendingPromise
173
- }));
174
- });
175
- setTimeout(() => {
176
- minPendingPromise.resolve();
177
- router.updateMatch(match.id, (prev) => ({
178
- ...prev,
179
- minPendingPromise: void 0
180
- }));
181
- }, pendingMinMs);
182
- }
183
- }
184
- throw (_c = router.getMatch(match.id)) == null ? void 0 : _c.loadPromise;
185
- }
186
- return out;
187
- });
188
- const Outlet = React.memo(function OutletImpl() {
189
- const router = useRouter();
190
- const matchId = React.useContext(matchContext);
191
- const routeId = useRouterState({
192
- select: (s) => {
193
- var _a;
194
- return (_a = s.matches.find((d) => d.id === matchId)) == null ? void 0 : _a.routeId;
195
- }
196
- });
197
- const route = router.routesById[routeId];
198
- const parentGlobalNotFound = useRouterState({
199
- select: (s) => {
200
- const matches = s.matches;
201
- const parentMatch = matches.find((d) => d.id === matchId);
202
- invariant(
203
- parentMatch,
204
- `Could not find parent match for matchId "${matchId}"`
205
- );
206
- return parentMatch.globalNotFound;
207
- }
208
- });
209
- const childMatchId = useRouterState({
210
- select: (s) => {
211
- var _a;
212
- const matches = s.matches;
213
- const index = matches.findIndex((d) => d.id === matchId);
214
- return (_a = matches[index + 1]) == null ? void 0 : _a.id;
215
- }
216
- });
217
- const pendingElement = router.options.defaultPendingComponent ? /* @__PURE__ */ jsx(router.options.defaultPendingComponent, {}) : null;
218
- if (router.isShell)
219
- return /* @__PURE__ */ jsx(React.Suspense, { fallback: pendingElement, children: /* @__PURE__ */ jsx(ShellInner, {}) });
220
- if (parentGlobalNotFound) {
221
- return renderRouteNotFound(router, route, void 0);
222
- }
223
- if (!childMatchId) {
224
- return null;
225
- }
226
- const nextMatch = /* @__PURE__ */ jsx(Match, { matchId: childMatchId });
227
- if (matchId === rootRouteId) {
228
- return /* @__PURE__ */ jsx(React.Suspense, { fallback: pendingElement, children: nextMatch });
229
- }
230
- return nextMatch;
231
- });
232
- function ShellInner() {
233
- throw new Error("ShellBoundaryError");
234
- }
235
- export {
236
- Match,
237
- MatchInner,
238
- Outlet
239
- };
240
- //# sourceMappingURL=Match.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Match.js","sources":["../../src/Match.tsx"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport {\n createControlledPromise,\n getLocationChangeInfo,\n isNotFound,\n isRedirect,\n pick,\n rootRouteId,\n} from '@tanstack/router-core'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { CatchNotFound } from './not-found'\nimport { matchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { ScrollRestoration } from './scroll-restoration'\nimport type { AnyRoute, ParsedLocation } from '@tanstack/router-core'\n\nexport const Match = React.memo(function MatchImpl({\n matchId,\n}: {\n matchId: string\n}) {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n invariant(\n routeId,\n `Could not find routeId for matchId \"${matchId}\". Please file an issue!`,\n )\n\n const route: AnyRoute = router.routesById[routeId]\n\n const PendingComponent =\n route.options.pendingComponent ?? router.options.defaultPendingComponent\n\n const pendingElement = PendingComponent ? <PendingComponent /> : null\n\n const routeErrorComponent =\n route.options.errorComponent ?? router.options.defaultErrorComponent\n\n const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch\n\n const routeNotFoundComponent = route.isRoot\n ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n (route.options.notFoundComponent ??\n router.options.notFoundRoute?.options.component)\n : route.options.notFoundComponent\n\n const ResolvedSuspenseBoundary =\n // If we're on the root route, allow forcefully wrapping in suspense\n (!route.isRoot || route.options.wrapInSuspense) &&\n (route.options.wrapInSuspense ??\n PendingComponent ??\n (route.options.errorComponent as any)?.preload)\n ? React.Suspense\n : SafeFragment\n\n const ResolvedCatchBoundary = routeErrorComponent\n ? CatchBoundary\n : SafeFragment\n\n const ResolvedNotFoundBoundary = routeNotFoundComponent\n ? CatchNotFound\n : SafeFragment\n\n const resetKey = useRouterState({\n select: (s) => s.loadedAt,\n })\n\n const parentRouteId = useRouterState({\n select: (s) => {\n const index = s.matches.findIndex((d) => d.id === matchId)\n return s.matches[index - 1]?.routeId as string\n },\n })\n\n return (\n <>\n <matchContext.Provider value={matchId}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n getResetKey={() => resetKey}\n errorComponent={routeErrorComponent || ErrorComponent}\n onCatch={(error, errorInfo) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n warning(false, `Error in route match: ${matchId}`)\n routeOnCatch?.(error, errorInfo)\n }}\n >\n <ResolvedNotFoundBoundary\n fallback={(error) => {\n // If the current not found handler doesn't exist or it has a\n // route ID which doesn't match the current route, rethrow the error\n if (\n !routeNotFoundComponent ||\n (error.routeId && error.routeId !== routeId) ||\n (!error.routeId && !route.isRoot)\n )\n throw error\n\n return React.createElement(routeNotFoundComponent, error as any)\n }}\n >\n <MatchInner matchId={matchId} />\n </ResolvedNotFoundBoundary>\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchContext.Provider>\n {parentRouteId === rootRouteId && router.options.scrollRestoration ? (\n <>\n <OnRendered />\n <ScrollRestoration />\n </>\n ) : null}\n </>\n )\n})\n\n// On Rendered can't happen above the root layout because it actually\n// renders a dummy dom element to track the rendered state of the app.\n// We render a script tag with a key that changes based on the current\n// location state.key. Also, because it's below the root layout, it\n// allows us to fire onRendered events even after a hydration mismatch\n// error that occurred above the root layout (like bad head/link tags,\n// which is common).\nfunction OnRendered() {\n const router = useRouter()\n\n const prevLocationRef = React.useRef<undefined | ParsedLocation<{}>>(\n undefined,\n )\n\n return (\n <script\n key={router.latestLocation.state.key}\n suppressHydrationWarning\n ref={(el) => {\n if (\n el &&\n (prevLocationRef.current === undefined ||\n prevLocationRef.current.href !== router.latestLocation.href)\n ) {\n router.emit({\n type: 'onRendered',\n ...getLocationChangeInfo(router.state),\n })\n prevLocationRef.current = router.latestLocation\n }\n }}\n />\n )\n}\n\nexport const MatchInner = React.memo(function MatchInnerImpl({\n matchId,\n}: {\n matchId: string\n}): any {\n const router = useRouter()\n\n const { match, key, routeId } = useRouterState({\n select: (s) => {\n const matchIndex = s.matches.findIndex((d) => d.id === matchId)\n const match = s.matches[matchIndex]!\n const routeId = match.routeId as string\n\n const remountFn =\n (router.routesById[routeId] as AnyRoute).options.remountDeps ??\n router.options.defaultRemountDeps\n const remountDeps = remountFn?.({\n routeId,\n loaderDeps: match.loaderDeps,\n params: match._strictParams,\n search: match._strictSearch,\n })\n const key = remountDeps ? JSON.stringify(remountDeps) : undefined\n\n return {\n key,\n routeId,\n match: pick(match, ['id', 'status', 'error']),\n }\n },\n structuralSharing: true as any,\n })\n\n const route = router.routesById[routeId] as AnyRoute\n\n const out = React.useMemo(() => {\n const Comp = route.options.component ?? router.options.defaultComponent\n if (Comp) {\n return <Comp key={key} />\n }\n return <Outlet />\n }, [key, route.options.component, router.options.defaultComponent])\n\n const RouteErrorComponent =\n (route.options.errorComponent ?? router.options.defaultErrorComponent) ||\n ErrorComponent\n\n if (match.status === 'notFound') {\n invariant(isNotFound(match.error), 'Expected a notFound error')\n return renderRouteNotFound(router, route, match.error)\n }\n\n if (match.status === 'redirected') {\n // Redirects should be handled by the router transition. If we happen to\n // encounter a redirect here, it's a bug. Let's warn, but render nothing.\n invariant(isRedirect(match.error), 'Expected a redirect error')\n\n // warning(\n // false,\n // 'Tried to render a redirected route match! This is a weird circumstance, please file an issue!',\n // )\n throw router.getMatch(match.id)?.loadPromise\n }\n\n if (match.status === 'error') {\n // If we're on the server, we need to use React's new and super\n // wonky api for throwing errors from a server side render inside\n // of a suspense boundary. This is the only way to get\n // renderToPipeableStream to not hang indefinitely.\n // We'll serialize the error and rethrow it on the client.\n if (router.isServer) {\n return (\n <RouteErrorComponent\n error={match.error as any}\n reset={undefined as any}\n info={{\n componentStack: '',\n }}\n />\n )\n }\n\n throw match.error\n }\n\n if (match.status === 'pending') {\n // We're pending, and if we have a minPendingMs, we need to wait for it\n const pendingMinMs =\n route.options.pendingMinMs ?? router.options.defaultPendingMinMs\n\n if (pendingMinMs && !router.getMatch(match.id)?.minPendingPromise) {\n // Create a promise that will resolve after the minPendingMs\n if (!router.isServer) {\n const minPendingPromise = createControlledPromise<void>()\n\n Promise.resolve().then(() => {\n router.updateMatch(match.id, (prev) => ({\n ...prev,\n minPendingPromise,\n }))\n })\n\n setTimeout(() => {\n minPendingPromise.resolve()\n\n // We've handled the minPendingPromise, so we can delete it\n router.updateMatch(match.id, (prev) => ({\n ...prev,\n minPendingPromise: undefined,\n }))\n }, pendingMinMs)\n }\n }\n throw router.getMatch(match.id)?.loadPromise\n }\n\n return out\n})\n\nexport const Outlet = React.memo(function OutletImpl() {\n const router = useRouter()\n const matchId = React.useContext(matchContext)\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const parentGlobalNotFound = useRouterState({\n select: (s) => {\n const matches = s.matches\n const parentMatch = matches.find((d) => d.id === matchId)\n invariant(\n parentMatch,\n `Could not find parent match for matchId \"${matchId}\"`,\n )\n return parentMatch.globalNotFound\n },\n })\n\n const childMatchId = useRouterState({\n select: (s) => {\n const matches = s.matches\n const index = matches.findIndex((d) => d.id === matchId)\n return matches[index + 1]?.id\n },\n })\n\n const pendingElement = router.options.defaultPendingComponent ? (\n <router.options.defaultPendingComponent />\n ) : null\n\n if (router.isShell)\n return (\n <React.Suspense fallback={pendingElement}>\n <ShellInner />\n </React.Suspense>\n )\n\n if (parentGlobalNotFound) {\n return renderRouteNotFound(router, route, undefined)\n }\n\n if (!childMatchId) {\n return null\n }\n\n const nextMatch = <Match matchId={childMatchId} />\n\n if (matchId === rootRouteId) {\n return (\n <React.Suspense fallback={pendingElement}>{nextMatch}</React.Suspense>\n )\n }\n\n return nextMatch\n})\n\nfunction ShellInner(): React.ReactElement {\n throw new Error('ShellBoundaryError')\n}\n"],"names":["_a","match","routeId","key"],"mappings":";;;;;;;;;;;;;AAqBO,MAAM,QAAQ,MAAM,KAAK,SAAS,UAAU;AAAA,EACjD;AACF,GAEG;;AACD,QAAM,SAAS,UAAU;AACzB,QAAM,UAAU,eAAe;AAAA,IAC7B,QAAQ,CAAC;;AAAM,cAAAA,MAAA,EAAE,QAAQ,KAAK,CAAC,MAAM,EAAE,OAAO,OAAO,MAAtC,gBAAAA,IAAyC;AAAA;AAAA,EAAA,CACzD;AAED;AAAA,IACE;AAAA,IACA,uCAAuC,OAAO;AAAA,EAChD;AAEM,QAAA,QAAkB,OAAO,WAAW,OAAO;AAEjD,QAAM,mBACJ,MAAM,QAAQ,oBAAoB,OAAO,QAAQ;AAEnD,QAAM,iBAAiB,mBAAoB,oBAAA,kBAAA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MAAM;;AACb,YAAM,UAAU,EAAE;AAClB,YAAM,QAAQ,QAAQ,UAAU,CAAC,MAAM,EAAE,OAAO,OAAO;AAChD,cAAA,aAAQ,QAAQ,CAAC,MAAjB,mBAAoB;AAAA,IAAA;AAAA,EAC7B,CACD;AAEK,QAAA,iBAAiB,OAAO,QAAQ,8CACnC,OAAO,QAAQ,yBAAf,CAAuC,CAAA,IACtC;AAEJ,MAAI,OAAO;AAEP,WAAA,oBAAC,MAAM,UAAN,EAAe,UAAU,gBACxB,UAAA,oBAAC,cAAW,EACd,CAAA;AAGJ,MAAI,sBAAsB;AACjB,WAAA,oBAAoB,QAAQ,OAAO,MAAS;AAAA,EAAA;AAGrD,MAAI,CAAC,cAAc;AACV,WAAA;AAAA,EAAA;AAGT,QAAM,YAAY,oBAAC,OAAM,EAAA,SAAS,aAAc,CAAA;AAEhD,MAAI,YAAY,aAAa;AAC3B,+BACG,MAAM,UAAN,EAAe,UAAU,gBAAiB,UAAU,WAAA;AAAA,EAAA;AAIlD,SAAA;AACT,CAAC;AAED,SAAS,aAAiC;AAClC,QAAA,IAAI,MAAM,oBAAoB;AACtC;"}
@@ -1,26 +0,0 @@
1
- import { StructuralSharingOption, ValidateSelected } from './structuralSharing.js';
2
- import { ReactNode } from './route.js';
3
- import { AnyRouter, DeepPartial, Expand, MakeOptionalPathParams, MakeOptionalSearchParams, MakeRouteMatchUnion, MaskOptions, MatchRouteOptions, NoInfer, RegisteredRouter, ResolveRelativePath, ResolveRoute, RouteByPath, ToSubOptionsProps } from '@tanstack/router-core';
4
- import * as React from 'react';
5
- declare module '@tanstack/router-core' {
6
- interface RouteMatchExtensions {
7
- meta?: Array<React.JSX.IntrinsicElements['meta'] | undefined>;
8
- links?: Array<React.JSX.IntrinsicElements['link'] | undefined>;
9
- scripts?: Array<React.JSX.IntrinsicElements['script'] | undefined>;
10
- headScripts?: Array<React.JSX.IntrinsicElements['script'] | undefined>;
11
- }
12
- }
13
- export declare function Matches(): import("react/jsx-runtime").JSX.Element;
14
- export type UseMatchRouteOptions<TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = undefined, TMaskFrom extends string = TFrom, TMaskTo extends string = ''> = ToSubOptionsProps<TRouter, TFrom, TTo> & DeepPartial<MakeOptionalSearchParams<TRouter, TFrom, TTo>> & DeepPartial<MakeOptionalPathParams<TRouter, TFrom, TTo>> & MaskOptions<TRouter, TMaskFrom, TMaskTo> & MatchRouteOptions;
15
- export declare function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>(): <const TFrom extends string = string, const TTo extends string | undefined = undefined, const TMaskFrom extends string = TFrom, const TMaskTo extends string = "">(opts: UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>) => false | Expand<ResolveRoute<TRouter, TFrom, TTo>["types"]["allParams"]>;
16
- export type MakeMatchRouteOptions<TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = undefined, TMaskFrom extends string = TFrom, TMaskTo extends string = ''> = UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {
17
- children?: ((params?: RouteByPath<TRouter['routeTree'], ResolveRelativePath<TFrom, NoInfer<TTo>>>['types']['allParams']) => ReactNode) | React.ReactNode;
18
- };
19
- export declare function MatchRoute<TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string = string, const TTo extends string | undefined = undefined, const TMaskFrom extends string = TFrom, const TMaskTo extends string = ''>(props: MakeMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): any;
20
- export interface UseMatchesBaseOptions<TRouter extends AnyRouter, TSelected, TStructuralSharing> {
21
- select?: (matches: Array<MakeRouteMatchUnion<TRouter>>) => ValidateSelected<TRouter, TSelected, TStructuralSharing>;
22
- }
23
- export type UseMatchesResult<TRouter extends AnyRouter, TSelected> = unknown extends TSelected ? Array<MakeRouteMatchUnion<TRouter>> : TSelected;
24
- export declare function useMatches<TRouter extends AnyRouter = RegisteredRouter, TSelected = unknown, TStructuralSharing extends boolean = boolean>(opts?: UseMatchesBaseOptions<TRouter, TSelected, TStructuralSharing> & StructuralSharingOption<TRouter, TSelected, TStructuralSharing>): UseMatchesResult<TRouter, TSelected>;
25
- export declare function useParentMatches<TRouter extends AnyRouter = RegisteredRouter, TSelected = unknown, TStructuralSharing extends boolean = boolean>(opts?: UseMatchesBaseOptions<TRouter, TSelected, TStructuralSharing> & StructuralSharingOption<TRouter, TSelected, TStructuralSharing>): UseMatchesResult<TRouter, TSelected>;
26
- export declare function useChildMatches<TRouter extends AnyRouter = RegisteredRouter, TSelected = unknown, TStructuralSharing extends boolean = boolean>(opts?: UseMatchesBaseOptions<TRouter, TSelected, TStructuralSharing> & StructuralSharingOption<TRouter, TSelected, TStructuralSharing>): UseMatchesResult<TRouter, TSelected>;
@@ -1,119 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import * as React from "react";
3
- import warning from "tiny-warning";
4
- import { CatchBoundary, ErrorComponent } from "./CatchBoundary.js";
5
- import { useRouterState } from "./useRouterState.js";
6
- import { useRouter } from "./useRouter.js";
7
- import { Transitioner } from "./Transitioner.js";
8
- import { matchContext } from "./matchContext.js";
9
- import { Match } from "./Match.js";
10
- import { SafeFragment } from "./SafeFragment.js";
11
- function Matches() {
12
- const router = useRouter();
13
- const pendingElement = router.options.defaultPendingComponent ? /* @__PURE__ */ jsx(router.options.defaultPendingComponent, {}) : null;
14
- const ResolvedSuspense = router.isServer || typeof document !== "undefined" && router.clientSsr ? SafeFragment : React.Suspense;
15
- const inner = /* @__PURE__ */ jsxs(ResolvedSuspense, { fallback: pendingElement, children: [
16
- /* @__PURE__ */ jsx(Transitioner, {}),
17
- /* @__PURE__ */ jsx(MatchesInner, {})
18
- ] });
19
- return router.options.InnerWrap ? /* @__PURE__ */ jsx(router.options.InnerWrap, { children: inner }) : inner;
20
- }
21
- function MatchesInner() {
22
- const matchId = useRouterState({
23
- select: (s) => {
24
- var _a;
25
- return (_a = s.matches[0]) == null ? void 0 : _a.id;
26
- }
27
- });
28
- const resetKey = useRouterState({
29
- select: (s) => s.loadedAt
30
- });
31
- return /* @__PURE__ */ jsx(matchContext.Provider, { value: matchId, children: /* @__PURE__ */ jsx(
32
- CatchBoundary,
33
- {
34
- getResetKey: () => resetKey,
35
- errorComponent: ErrorComponent,
36
- onCatch: (error) => {
37
- warning(
38
- false,
39
- `The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`
40
- );
41
- warning(false, error.message || error.toString());
42
- },
43
- children: matchId ? /* @__PURE__ */ jsx(Match, { matchId }) : null
44
- }
45
- ) });
46
- }
47
- function useMatchRoute() {
48
- const router = useRouter();
49
- useRouterState({
50
- select: (s) => {
51
- var _a;
52
- return [s.location.href, (_a = s.resolvedLocation) == null ? void 0 : _a.href, s.status];
53
- },
54
- structuralSharing: true
55
- });
56
- return React.useCallback(
57
- (opts) => {
58
- const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts;
59
- return router.matchRoute(rest, {
60
- pending,
61
- caseSensitive,
62
- fuzzy,
63
- includeSearch
64
- });
65
- },
66
- [router]
67
- );
68
- }
69
- function MatchRoute(props) {
70
- const matchRoute = useMatchRoute();
71
- const params = matchRoute(props);
72
- if (typeof props.children === "function") {
73
- return props.children(params);
74
- }
75
- return params ? props.children : null;
76
- }
77
- function useMatches(opts) {
78
- return useRouterState({
79
- select: (state) => {
80
- const matches = state.matches;
81
- return (opts == null ? void 0 : opts.select) ? opts.select(matches) : matches;
82
- },
83
- structuralSharing: opts == null ? void 0 : opts.structuralSharing
84
- });
85
- }
86
- function useParentMatches(opts) {
87
- const contextMatchId = React.useContext(matchContext);
88
- return useMatches({
89
- select: (matches) => {
90
- matches = matches.slice(
91
- 0,
92
- matches.findIndex((d) => d.id === contextMatchId)
93
- );
94
- return (opts == null ? void 0 : opts.select) ? opts.select(matches) : matches;
95
- },
96
- structuralSharing: opts == null ? void 0 : opts.structuralSharing
97
- });
98
- }
99
- function useChildMatches(opts) {
100
- const contextMatchId = React.useContext(matchContext);
101
- return useMatches({
102
- select: (matches) => {
103
- matches = matches.slice(
104
- matches.findIndex((d) => d.id === contextMatchId) + 1
105
- );
106
- return (opts == null ? void 0 : opts.select) ? opts.select(matches) : matches;
107
- },
108
- structuralSharing: opts == null ? void 0 : opts.structuralSharing
109
- });
110
- }
111
- export {
112
- MatchRoute,
113
- Matches,
114
- useChildMatches,
115
- useMatchRoute,
116
- useMatches,
117
- useParentMatches
118
- };
119
- //# sourceMappingURL=Matches.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Matches.js","sources":["../../src/Matches.tsx"],"sourcesContent":["import * as React from 'react'\nimport warning from 'tiny-warning'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { Transitioner } from './Transitioner'\nimport { matchContext } from './matchContext'\nimport { Match } from './Match'\nimport { SafeFragment } from './SafeFragment'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type { ReactNode } from './route'\nimport type {\n AnyRouter,\n DeepPartial,\n Expand,\n MakeOptionalPathParams,\n MakeOptionalSearchParams,\n MakeRouteMatchUnion,\n MaskOptions,\n MatchRouteOptions,\n NoInfer,\n RegisteredRouter,\n ResolveRelativePath,\n ResolveRoute,\n RouteByPath,\n RouterState,\n ToSubOptionsProps,\n} from '@tanstack/router-core'\n\ndeclare module '@tanstack/router-core' {\n export interface RouteMatchExtensions {\n meta?: Array<React.JSX.IntrinsicElements['meta'] | undefined>\n links?: Array<React.JSX.IntrinsicElements['link'] | undefined>\n scripts?: Array<React.JSX.IntrinsicElements['script'] | undefined>\n headScripts?: Array<React.JSX.IntrinsicElements['script'] | undefined>\n }\n}\n\nexport function Matches() {\n const router = useRouter()\n\n const pendingElement = router.options.defaultPendingComponent ? (\n <router.options.defaultPendingComponent />\n ) : null\n\n // Do not render a root Suspense during SSR or hydrating from SSR\n const ResolvedSuspense =\n router.isServer || (typeof document !== 'undefined' && router.clientSsr)\n ? SafeFragment\n : React.Suspense\n\n const inner = (\n <ResolvedSuspense fallback={pendingElement}>\n <Transitioner />\n <MatchesInner />\n </ResolvedSuspense>\n )\n\n return router.options.InnerWrap ? (\n <router.options.InnerWrap>{inner}</router.options.InnerWrap>\n ) : (\n inner\n )\n}\n\nfunction MatchesInner() {\n const matchId = useRouterState({\n select: (s) => {\n return s.matches[0]?.id\n },\n })\n\n const resetKey = useRouterState({\n select: (s) => s.loadedAt,\n })\n\n return (\n <matchContext.Provider value={matchId}>\n <CatchBoundary\n getResetKey={() => resetKey}\n errorComponent={ErrorComponent}\n onCatch={(error) => {\n warning(\n false,\n `The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`,\n )\n warning(false, error.message || error.toString())\n }}\n >\n {matchId ? <Match matchId={matchId} /> : null}\n </CatchBoundary>\n </matchContext.Provider>\n )\n}\n\nexport type UseMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = ToSubOptionsProps<TRouter, TFrom, TTo> &\n DeepPartial<MakeOptionalSearchParams<TRouter, TFrom, TTo>> &\n DeepPartial<MakeOptionalPathParams<TRouter, TFrom, TTo>> &\n MaskOptions<TRouter, TMaskFrom, TMaskTo> &\n MatchRouteOptions\n\nexport function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>() {\n const router = useRouter()\n\n useRouterState({\n select: (s) => [s.location.href, s.resolvedLocation?.href, s.status],\n structuralSharing: true as any,\n })\n\n return React.useCallback(\n <\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n >(\n opts: UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n ):\n | false\n | Expand<ResolveRoute<TRouter, TFrom, TTo>['types']['allParams']> => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n return router.matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n },\n [router],\n )\n}\n\nexport type MakeMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | ((\n params?: RouteByPath<\n TRouter['routeTree'],\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => ReactNode)\n | React.ReactNode\n}\n\nexport function MatchRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(props: MakeMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): any {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any) as boolean\n\n if (typeof props.children === 'function') {\n return (props.children as any)(params)\n }\n\n return params ? props.children : null\n}\n\nexport interface UseMatchesBaseOptions<\n TRouter extends AnyRouter,\n TSelected,\n TStructuralSharing,\n> {\n select?: (\n matches: Array<MakeRouteMatchUnion<TRouter>>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n}\n\nexport type UseMatchesResult<\n TRouter extends AnyRouter,\n TSelected,\n> = unknown extends TSelected ? Array<MakeRouteMatchUnion<TRouter>> : TSelected\n\nexport function useMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected, TStructuralSharing> &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n): UseMatchesResult<TRouter, TSelected> {\n return useRouterState({\n select: (state: RouterState<TRouter['routeTree']>) => {\n const matches = state.matches\n return opts?.select\n ? opts.select(matches as Array<MakeRouteMatchUnion<TRouter>>)\n : matches\n },\n structuralSharing: opts?.structuralSharing,\n } as any) as UseMatchesResult<TRouter, TSelected>\n}\n\nexport function useParentMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected, TStructuralSharing> &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n): UseMatchesResult<TRouter, TSelected> {\n const contextMatchId = React.useContext(matchContext)\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n 0,\n matches.findIndex((d) => d.id === contextMatchId),\n )\n return opts?.select ? opts.select(matches) : matches\n },\n structuralSharing: opts?.structuralSharing,\n } as any)\n}\n\nexport function useChildMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected, TStructuralSharing> &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n): UseMatchesResult<TRouter, TSelected> {\n const contextMatchId = React.useContext(matchContext)\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n matches.findIndex((d) => d.id === contextMatchId) + 1,\n )\n return opts?.select ? opts.select(matches) : matches\n },\n structuralSharing: opts?.structuralSharing,\n } as any)\n}\n"],"names":[],"mappings":";;;;;;;;;;AAyCO,SAAS,UAAU;AACxB,QAAM,SAAS,UAAU;AAEnB,QAAA,iBAAiB,OAAO,QAAQ,8CACnC,OAAO,QAAQ,yBAAf,CAAuC,CAAA,IACtC;AAGE,QAAA,mBACJ,OAAO,YAAa,OAAO,aAAa,eAAe,OAAO,YAC1D,eACA,MAAM;AAEZ,QAAM,QACJ,qBAAC,kBAAiB,EAAA,UAAU,gBAC1B,UAAA;AAAA,IAAA,oBAAC,cAAa,EAAA;AAAA,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AAElC,MAAA,OAAO,MAAM,aAAa,YAAY;AAChC,WAAA,MAAM,SAAiB,MAAM;AAAA,EAAA;AAGhC,SAAA,SAAS,MAAM,WAAW;AACnC;AAiBO,SAAS,WAKd,MAEsC;AACtC,SAAO,eAAe;AAAA,IACpB,QAAQ,CAAC,UAA6C;AACpD,YAAM,UAAU,MAAM;AACtB,cAAO,6BAAM,UACT,KAAK,OAAO,OAA8C,IAC1D;AAAA,IACN;AAAA,IACA,mBAAmB,6BAAM;AAAA,EAAA,CACnB;AACV;AAEO,SAAS,iBAKd,MAEsC;AAChC,QAAA,iBAAiB,MAAM,WAAW,YAAY;AAEpD,SAAO,WAAW;AAAA,IAChB,QAAQ,CAAC,YAAiD;AACxD,gBAAU,QAAQ;AAAA,QAChB;AAAA,QACA,QAAQ,UAAU,CAAC,MAAM,EAAE,OAAO,cAAc;AAAA,MAClD;AACA,cAAO,6BAAM,UAAS,KAAK,OAAO,OAAO,IAAI;AAAA,IAC/C;AAAA,IACA,mBAAmB,6BAAM;AAAA,EAAA,CACnB;AACV;AAEO,SAAS,gBAKd,MAEsC;AAChC,QAAA,iBAAiB,MAAM,WAAW,YAAY;AAEpD,SAAO,WAAW;AAAA,IAChB,QAAQ,CAAC,YAAiD;AACxD,gBAAU,QAAQ;AAAA,QAChB,QAAQ,UAAU,CAAC,MAAM,EAAE,OAAO,cAAc,IAAI;AAAA,MACtD;AACA,cAAO,6BAAM,UAAS,KAAK,OAAO,OAAO,IAAI;AAAA,IAC/C;AAAA,IACA,mBAAmB,6BAAM;AAAA,EAAA,CACnB;AACV;"}
@@ -1,10 +0,0 @@
1
- import { AnyRouter, RegisteredRouter, RouterOptions } from '@tanstack/router-core';
2
- import * as React from 'react';
3
- export declare function RouterContextProvider<TRouter extends AnyRouter = RegisteredRouter, TDehydrated extends Record<string, any> = Record<string, any>>({ router, children, ...rest }: RouterProps<TRouter, TDehydrated> & {
4
- children: React.ReactNode;
5
- }): import("react/jsx-runtime").JSX.Element;
6
- export declare function RouterProvider<TRouter extends AnyRouter = RegisteredRouter, TDehydrated extends Record<string, any> = Record<string, any>>({ router, ...rest }: RouterProps<TRouter, TDehydrated>): import("react/jsx-runtime").JSX.Element;
7
- export type RouterProps<TRouter extends AnyRouter = RegisteredRouter, TDehydrated extends Record<string, any> = Record<string, any>> = Omit<RouterOptions<TRouter['routeTree'], NonNullable<TRouter['options']['trailingSlash']>, NonNullable<TRouter['options']['defaultStructuralSharing']>, TRouter['history'], TDehydrated>, 'context'> & {
8
- router: TRouter;
9
- context?: Partial<RouterOptions<TRouter['routeTree'], NonNullable<TRouter['options']['trailingSlash']>, NonNullable<TRouter['options']['defaultStructuralSharing']>, TRouter['history'], TDehydrated>['context']>;
10
- };
@@ -1,33 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { Matches } from "./Matches.js";
3
- import { getRouterContext } from "./routerContext.js";
4
- function RouterContextProvider({
5
- router,
6
- children,
7
- ...rest
8
- }) {
9
- if (Object.keys(rest).length > 0) {
10
- router.update({
11
- ...router.options,
12
- ...rest,
13
- context: {
14
- ...router.options.context,
15
- ...rest.context
16
- }
17
- });
18
- }
19
- const routerContext = getRouterContext();
20
- const provider = /* @__PURE__ */ jsx(routerContext.Provider, { value: router, children });
21
- if (router.options.Wrap) {
22
- return /* @__PURE__ */ jsx(router.options.Wrap, { children: provider });
23
- }
24
- return provider;
25
- }
26
- function RouterProvider({ router, ...rest }) {
27
- return /* @__PURE__ */ jsx(RouterContextProvider, { router, ...rest, children: /* @__PURE__ */ jsx(Matches, {}) });
28
- }
29
- export {
30
- RouterContextProvider,
31
- RouterProvider
32
- };
33
- //# sourceMappingURL=RouterProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RouterProvider.js","sources":["../../src/RouterProvider.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Matches } from './Matches'\nimport { getRouterContext } from './routerContext'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterOptions,\n} from '@tanstack/router-core'\n\nexport function RouterContextProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({\n router,\n children,\n ...rest\n}: RouterProps<TRouter, TDehydrated> & {\n children: React.ReactNode\n}) {\n if (Object.keys(rest).length > 0) {\n // Allow the router to update options on the router instance\n router.update({\n ...router.options,\n ...rest,\n context: {\n ...router.options.context,\n ...rest.context,\n },\n } as any)\n }\n\n const routerContext = getRouterContext()\n\n const provider = (\n <routerContext.Provider value={router as AnyRouter}>\n {children}\n </routerContext.Provider>\n )\n\n if (router.options.Wrap) {\n return <router.options.Wrap>{provider}</router.options.Wrap>\n }\n\n return provider\n}\n\nexport function RouterProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({ router, ...rest }: RouterProps<TRouter, TDehydrated>) {\n return (\n <RouterContextProvider router={router} {...rest}>\n <Matches />\n </RouterContextProvider>\n )\n}\n\nexport type RouterProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n> = Omit<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TRouter['history'],\n TDehydrated\n >,\n 'context'\n> & {\n router: TRouter\n context?: Partial<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TRouter['history'],\n TDehydrated\n >['context']\n >\n}\n"],"names":[],"mappings":";;;AASO,SAAS,sBAGd;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAEG;AACD,MAAI,OAAO,KAAK,IAAI,EAAE,SAAS,GAAG;AAEhC,WAAO,OAAO;AAAA,MACZ,GAAG,OAAO;AAAA,MACV,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAG,OAAO,QAAQ;AAAA,QAClB,GAAG,KAAK;AAAA,MAAA;AAAA,IACV,CACM;AAAA,EAAA;AAGV,QAAM,gBAAgB,iBAAiB;AAEvC,QAAM,WACH,oBAAA,cAAc,UAAd,EAAuB,OAAO,QAC5B,UACH;AAGE,MAAA,OAAO,QAAQ,MAAM;AACvB,WAAQ,oBAAA,OAAO,QAAQ,MAAf,EAAqB,UAAS,UAAA;AAAA,EAAA;AAGjC,SAAA;AACT;AAEO,SAAS,eAGd,EAAE,QAAQ,GAAG,QAA2C;AACxD,6BACG,uBAAsB,EAAA,QAAiB,GAAG,MACzC,UAAA,oBAAC,UAAQ,CAAA,GACX;AAEJ;"}
@@ -1 +0,0 @@
1
- export declare function SafeFragment(props: any): import("react/jsx-runtime").JSX.Element;
@@ -1,8 +0,0 @@
1
- import { jsx, Fragment } from "react/jsx-runtime";
2
- function SafeFragment(props) {
3
- return /* @__PURE__ */ jsx(Fragment, { children: props.children });
4
- }
5
- export {
6
- SafeFragment
7
- };
8
- //# sourceMappingURL=SafeFragment.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SafeFragment.js","sources":["../../src/SafeFragment.tsx"],"sourcesContent":["import * as React from 'react'\n\nexport function SafeFragment(props: any) {\n return <>{props.children}</>\n}\n"],"names":[],"mappings":";AAEO,SAAS,aAAa,OAAY;AAChC,SAAA,oBAAA,UAAA,EAAG,gBAAM,SAAS,CAAA;AAC3B;"}
@@ -1,5 +0,0 @@
1
- export declare function ScriptOnce({ children, log, }: {
2
- children: string;
3
- log?: boolean;
4
- sync?: boolean;
5
- }): import("react/jsx-runtime").JSX.Element | null;
@@ -1,28 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import jsesc from "jsesc";
3
- function ScriptOnce({
4
- children,
5
- log
6
- }) {
7
- if (typeof document !== "undefined") {
8
- return null;
9
- }
10
- return /* @__PURE__ */ jsx(
11
- "script",
12
- {
13
- className: "tsr-once",
14
- dangerouslySetInnerHTML: {
15
- __html: [
16
- children,
17
- (log ?? true) && process.env.NODE_ENV === "development" ? `console.info(\`Injected From Server:
18
- ${jsesc(children.toString(), { quotes: "backtick" })}\`)` : "",
19
- 'if (typeof __TSR_SSR__ !== "undefined") __TSR_SSR__.cleanScripts()'
20
- ].filter(Boolean).join("\n")
21
- }
22
- }
23
- );
24
- }
25
- export {
26
- ScriptOnce
27
- };
28
- //# sourceMappingURL=ScriptOnce.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ScriptOnce.js","sources":["../../src/ScriptOnce.tsx"],"sourcesContent":["import jsesc from 'jsesc'\n\nexport function ScriptOnce({\n children,\n log,\n}: {\n children: string\n log?: boolean\n sync?: boolean\n}) {\n if (typeof document !== 'undefined') {\n return null\n }\n\n return (\n <script\n className=\"tsr-once\"\n dangerouslySetInnerHTML={{\n __html: [\n children,\n (log ?? true) && process.env.NODE_ENV === 'development'\n ? `console.info(\\`Injected From Server:\n${jsesc(children.toString(), { quotes: 'backtick' })}\\`)`\n : '',\n 'if (typeof __TSR_SSR__ !== \"undefined\") __TSR_SSR__.cleanScripts()',\n ]\n .filter(Boolean)\n .join('\\n'),\n }}\n />\n )\n}\n"],"names":[],"mappings":";;AAEO,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AACF,GAIG;AACG,MAAA,OAAO,aAAa,aAAa;AAC5B,WAAA;AAAA,EAAA;AAIP,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACV,yBAAyB;AAAA,QACvB,QAAQ;AAAA,UACN;AAAA,WACC,OAAO,SAAS,QAAQ,IAAI,aAAa,gBACtC;AAAA,EACZ,MAAM,SAAS,YAAY,EAAE,QAAQ,WAAY,CAAA,CAAC,QACtC;AAAA,UACJ;AAAA,QAEC,EAAA,OAAO,OAAO,EACd,KAAK,IAAI;AAAA,MAAA;AAAA,IACd;AAAA,EACF;AAEJ;"}
@@ -1 +0,0 @@
1
- export declare const Scripts: () => import("react/jsx-runtime").JSX.Element;
@@ -1,51 +0,0 @@
1
- import { jsx, Fragment } from "react/jsx-runtime";
2
- import { createElement } from "react";
3
- import { Asset } from "./Asset.js";
4
- import { useRouterState } from "./useRouterState.js";
5
- import { useRouter } from "./useRouter.js";
6
- const Scripts = () => {
7
- const router = useRouter();
8
- const assetScripts = useRouterState({
9
- select: (state) => {
10
- var _a;
11
- const assetScripts2 = [];
12
- const manifest = (_a = router.ssr) == null ? void 0 : _a.manifest;
13
- if (!manifest) {
14
- return [];
15
- }
16
- state.matches.map((match) => router.looseRoutesById[match.routeId]).forEach(
17
- (route) => {
18
- var _a2, _b;
19
- return (_b = (_a2 = manifest.routes[route.id]) == null ? void 0 : _a2.assets) == null ? void 0 : _b.filter((d) => d.tag === "script").forEach((asset) => {
20
- assetScripts2.push({
21
- tag: "script",
22
- attrs: asset.attrs,
23
- children: asset.children
24
- });
25
- });
26
- }
27
- );
28
- return assetScripts2;
29
- },
30
- structuralSharing: true
31
- });
32
- const { scripts } = useRouterState({
33
- select: (state) => ({
34
- scripts: state.matches.map((match) => match.scripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
35
- tag: "script",
36
- attrs: {
37
- ...script,
38
- suppressHydrationWarning: true
39
- },
40
- children
41
- }))
42
- }),
43
- structuralSharing: true
44
- });
45
- const allScripts = [...scripts, ...assetScripts];
46
- return /* @__PURE__ */ jsx(Fragment, { children: allScripts.map((asset, i) => /* @__PURE__ */ createElement(Asset, { ...asset, key: `tsr-scripts-${asset.tag}-${i}` })) });
47
- };
48
- export {
49
- Scripts
50
- };
51
- //# sourceMappingURL=Scripts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Scripts.js","sources":["../../src/Scripts.tsx"],"sourcesContent":["import { Asset } from './Asset'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport type { RouterManagedTag } from '@tanstack/router-core'\n\nexport const Scripts = () => {\n const router = useRouter()\n\n const assetScripts = useRouterState({\n select: (state) => {\n const assetScripts: Array<RouterManagedTag> = []\n const manifest = router.ssr?.manifest\n\n if (!manifest) {\n return []\n }\n\n state.matches\n .map((match) => router.looseRoutesById[match.routeId]!)\n .forEach((route) =>\n manifest.routes[route.id]?.assets\n ?.filter((d) => d.tag === 'script')\n .forEach((asset) => {\n assetScripts.push({\n tag: 'script',\n attrs: asset.attrs,\n children: asset.children,\n } as any)\n }),\n )\n\n return assetScripts\n },\n structuralSharing: true as any,\n })\n\n const { scripts } = useRouterState({\n select: (state) => ({\n scripts: (\n state.matches\n .map((match) => match.scripts!)\n .flat(1)\n .filter(Boolean) as Array<RouterManagedTag>\n ).map(({ children, ...script }) => ({\n tag: 'script',\n attrs: {\n ...script,\n suppressHydrationWarning: true,\n },\n children,\n })),\n }),\n structuralSharing: true as any,\n })\n\n const allScripts = [...scripts, ...assetScripts] as Array<RouterManagedTag>\n\n return (\n <>\n {allScripts.map((asset, i) => (\n <Asset {...asset} key={`tsr-scripts-${asset.tag}-${i}`} />\n ))}\n </>\n )\n}\n"],"names":["assetScripts","_a"],"mappings":";;;;;AAKO,MAAM,UAAU,MAAM;AAC3B,QAAM,SAAS,UAAU;AAEzB,QAAM,eAAe,eAAe;AAAA,IAClC,QAAQ,CAAC,UAAU;;AACjB,YAAMA,gBAAwC,CAAC;AACzC,YAAA,YAAW,YAAO,QAAP,mBAAY;AAE7B,UAAI,CAAC,UAAU;AACb,eAAO,CAAC;AAAA,MAAA;AAGJ,YAAA,QACH,IAAI,CAAC,UAAU,OAAO,gBAAgB,MAAM,OAAO,CAAE,EACrD;AAAA,QAAQ,CAAC,UACR;;AAAA,wBAAAC,MAAA,SAAS,OAAO,MAAM,EAAE,MAAxB,gBAAAA,IAA2B,WAA3B,mBACI,OAAO,CAAC,MAAM,EAAE,QAAQ,UACzB,QAAQ,CAAC,UAAU;AAClBD,0BAAa,KAAK;AAAA,cAChB,KAAK;AAAA,cACL,OAAO,MAAM;AAAA,cACb,UAAU,MAAM;AAAA,YAAA,CACV;AAAA,UACT;AAAA;AAAA,MACL;AAEKA,aAAAA;AAAAA,IACT;AAAA,IACA,mBAAmB;AAAA,EAAA,CACpB;AAEK,QAAA,EAAE,QAAQ,IAAI,eAAe;AAAA,IACjC,QAAQ,CAAC,WAAW;AAAA,MAClB,SACE,MAAM,QACH,IAAI,CAAC,UAAU,MAAM,OAAQ,EAC7B,KAAK,CAAC,EACN,OAAO,OAAO,EACjB,IAAI,CAAC,EAAE,UAAU,GAAG,cAAc;AAAA,QAClC,KAAK;AAAA,QACL,OAAO;AAAA,UACL,GAAG;AAAA,UACH,0BAA0B;AAAA,QAC5B;AAAA,QACA;AAAA,MAAA,EACA;AAAA,IAAA;AAAA,IAEJ,mBAAmB;AAAA,EAAA,CACpB;AAED,QAAM,aAAa,CAAC,GAAG,SAAS,GAAG,YAAY;AAE/C,yCAEK,UAAW,WAAA,IAAI,CAAC,OAAO,oCACrB,OAAO,EAAA,GAAG,OAAO,KAAK,eAAe,MAAM,GAAG,IAAI,CAAC,IAAI,CACzD,GACH;AAEJ;"}
@@ -1,14 +0,0 @@
1
- import { ParsedLocation, ScrollRestorationEntry, ScrollRestorationOptions } from '@tanstack/router-core';
2
- /**
3
- * @deprecated use createRouter's `scrollRestoration` option instead
4
- */
5
- export declare function ScrollRestoration(_props: ScrollRestorationOptions): null;
6
- export declare function useElementScrollRestoration(options: ({
7
- id: string;
8
- getElement?: () => Window | Element | undefined | null;
9
- } | {
10
- id?: string;
11
- getElement: () => Window | Element | undefined | null;
12
- }) & {
13
- getKey?: (location: ParsedLocation) => string;
14
- }): ScrollRestorationEntry | undefined;