@tanstack/vue-router 1.167.0 → 1.167.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/esm/Asset.js +107 -151
  2. package/dist/esm/Asset.js.map +1 -1
  3. package/dist/esm/Body.js +15 -24
  4. package/dist/esm/Body.js.map +1 -1
  5. package/dist/esm/CatchBoundary.js +112 -130
  6. package/dist/esm/CatchBoundary.js.map +1 -1
  7. package/dist/esm/ClientOnly.js +59 -29
  8. package/dist/esm/ClientOnly.js.map +1 -1
  9. package/dist/esm/HeadContent.dev.js +29 -23
  10. package/dist/esm/HeadContent.dev.js.map +1 -1
  11. package/dist/esm/HeadContent.js +21 -16
  12. package/dist/esm/HeadContent.js.map +1 -1
  13. package/dist/esm/Html.js +42 -61
  14. package/dist/esm/Html.js.map +1 -1
  15. package/dist/esm/Match.js +238 -319
  16. package/dist/esm/Match.js.map +1 -1
  17. package/dist/esm/Matches.js +127 -170
  18. package/dist/esm/Matches.js.map +1 -1
  19. package/dist/esm/RouterProvider.js +50 -65
  20. package/dist/esm/RouterProvider.js.map +1 -1
  21. package/dist/esm/ScriptOnce.js +31 -36
  22. package/dist/esm/ScriptOnce.js.map +1 -1
  23. package/dist/esm/Scripts.js +79 -101
  24. package/dist/esm/Scripts.js.map +1 -1
  25. package/dist/esm/ScrollRestoration.js +25 -29
  26. package/dist/esm/ScrollRestoration.js.map +1 -1
  27. package/dist/esm/Transitioner.js +146 -164
  28. package/dist/esm/Transitioner.js.map +1 -1
  29. package/dist/esm/awaited.js +27 -34
  30. package/dist/esm/awaited.js.map +1 -1
  31. package/dist/esm/fileRoute.js +90 -92
  32. package/dist/esm/fileRoute.js.map +1 -1
  33. package/dist/esm/headContentUtils.js +92 -123
  34. package/dist/esm/headContentUtils.js.map +1 -1
  35. package/dist/esm/index.dev.js +16 -118
  36. package/dist/esm/index.js +18 -119
  37. package/dist/esm/lazyRouteComponent.js +69 -82
  38. package/dist/esm/lazyRouteComponent.js.map +1 -1
  39. package/dist/esm/link.js +364 -385
  40. package/dist/esm/link.js.map +1 -1
  41. package/dist/esm/matchContext.js +16 -11
  42. package/dist/esm/matchContext.js.map +1 -1
  43. package/dist/esm/not-found.js +30 -40
  44. package/dist/esm/not-found.js.map +1 -1
  45. package/dist/esm/renderRouteNotFound.js +20 -15
  46. package/dist/esm/renderRouteNotFound.js.map +1 -1
  47. package/dist/esm/route.js +196 -174
  48. package/dist/esm/route.js.map +1 -1
  49. package/dist/esm/router.js +11 -11
  50. package/dist/esm/router.js.map +1 -1
  51. package/dist/esm/routerContext.js +10 -7
  52. package/dist/esm/routerContext.js.map +1 -1
  53. package/dist/esm/scroll-restoration.js +39 -50
  54. package/dist/esm/scroll-restoration.js.map +1 -1
  55. package/dist/esm/ssr/RouterClient.js +29 -43
  56. package/dist/esm/ssr/RouterClient.js.map +1 -1
  57. package/dist/esm/ssr/RouterServer.js +29 -32
  58. package/dist/esm/ssr/RouterServer.js.map +1 -1
  59. package/dist/esm/ssr/client.js +1 -4
  60. package/dist/esm/ssr/defaultRenderHandler.js +11 -13
  61. package/dist/esm/ssr/defaultRenderHandler.js.map +1 -1
  62. package/dist/esm/ssr/defaultStreamHandler.js +12 -15
  63. package/dist/esm/ssr/defaultStreamHandler.js.map +1 -1
  64. package/dist/esm/ssr/renderRouterToStream.js +47 -65
  65. package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
  66. package/dist/esm/ssr/renderRouterToString.js +24 -32
  67. package/dist/esm/ssr/renderRouterToString.js.map +1 -1
  68. package/dist/esm/ssr/server.js +3 -10
  69. package/dist/esm/useBlocker.js +243 -287
  70. package/dist/esm/useBlocker.js.map +1 -1
  71. package/dist/esm/useCanGoBack.js +6 -5
  72. package/dist/esm/useCanGoBack.js.map +1 -1
  73. package/dist/esm/useLoaderData.js +12 -11
  74. package/dist/esm/useLoaderData.js.map +1 -1
  75. package/dist/esm/useLoaderDeps.js +12 -14
  76. package/dist/esm/useLoaderDeps.js.map +1 -1
  77. package/dist/esm/useLocation.js +6 -7
  78. package/dist/esm/useLocation.js.map +1 -1
  79. package/dist/esm/useMatch.js +27 -35
  80. package/dist/esm/useMatch.js.map +1 -1
  81. package/dist/esm/useNavigate.js +18 -24
  82. package/dist/esm/useNavigate.js.map +1 -1
  83. package/dist/esm/useParams.js +13 -12
  84. package/dist/esm/useParams.js.map +1 -1
  85. package/dist/esm/useRouteContext.js +9 -8
  86. package/dist/esm/useRouteContext.js.map +1 -1
  87. package/dist/esm/useRouter.js +9 -8
  88. package/dist/esm/useRouter.js.map +1 -1
  89. package/dist/esm/useRouterState.js +18 -22
  90. package/dist/esm/useRouterState.js.map +1 -1
  91. package/dist/esm/useSearch.js +13 -12
  92. package/dist/esm/useSearch.js.map +1 -1
  93. package/dist/esm/utils.js +59 -38
  94. package/dist/esm/utils.js.map +1 -1
  95. package/package.json +3 -3
  96. package/dist/esm/index.dev.js.map +0 -1
  97. package/dist/esm/index.js.map +0 -1
  98. package/dist/esm/ssr/client.js.map +0 -1
  99. package/dist/esm/ssr/server.js.map +0 -1
package/dist/esm/Match.js CHANGED
@@ -1,328 +1,247 @@
1
- import * as Vue from "vue";
2
- import invariant from "tiny-invariant";
3
- import warning from "tiny-warning";
4
- import { rootRouteId, isNotFound, isRedirect, createControlledPromise, getLocationChangeInfo } from "@tanstack/router-core";
5
- import { isServer } from "@tanstack/router-core/isServer";
6
1
  import { CatchBoundary, ErrorComponent } from "./CatchBoundary.js";
7
- import { ClientOnly } from "./ClientOnly.js";
8
- import { useRouterState } from "./useRouterState.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";
5
+ import { ClientOnly } from "./ClientOnly.js";
6
+ import { CatchNotFound } from "./not-found.js";
12
7
  import { renderRouteNotFound } from "./renderRouteNotFound.js";
13
8
  import { ScrollRestoration } from "./scroll-restoration.js";
14
- const Match = Vue.defineComponent({
15
- name: "Match",
16
- props: {
17
- matchId: {
18
- type: String,
19
- required: true
20
- }
21
- },
22
- setup(props) {
23
- const router = useRouter();
24
- let lastKnownRouteId = null;
25
- const matchData = useRouterState({
26
- select: (s) => {
27
- let match = s.matches.find((d) => d.id === props.matchId);
28
- let matchIndex = match ? s.matches.findIndex((d) => d.id === props.matchId) : -1;
29
- if (match) {
30
- lastKnownRouteId = match.routeId;
31
- } else if (lastKnownRouteId) {
32
- match = s.matches.find((d) => d.routeId === lastKnownRouteId);
33
- matchIndex = match ? s.matches.findIndex((d) => d.routeId === lastKnownRouteId) : -1;
34
- }
35
- if (!match) {
36
- return null;
37
- }
38
- const routeId = match.routeId;
39
- const parentRouteId = matchIndex > 0 ? s.matches[matchIndex - 1]?.routeId : null;
40
- return {
41
- matchId: match.id,
42
- // Return the actual matchId (may differ from props.matchId)
43
- routeId,
44
- parentRouteId,
45
- loadedAt: s.loadedAt,
46
- ssr: match.ssr,
47
- _displayPending: match._displayPending
48
- };
49
- }
50
- });
51
- invariant(matchData.value, `Could not find routeId for matchId "${props.matchId}". Please file an issue!`);
52
- const route = Vue.computed(() => matchData.value ? router.routesById[matchData.value.routeId] : null);
53
- const PendingComponent = Vue.computed(() => route.value?.options?.pendingComponent ?? router?.options?.defaultPendingComponent);
54
- const pendingElement = Vue.computed(() => PendingComponent.value ? Vue.h(PendingComponent.value) : void 0);
55
- const routeErrorComponent = Vue.computed(() => route.value?.options?.errorComponent ?? router?.options?.defaultErrorComponent);
56
- const routeOnCatch = Vue.computed(() => route.value?.options?.onCatch ?? router?.options?.defaultOnCatch);
57
- const routeNotFoundComponent = Vue.computed(() => route.value?.isRoot ? (
58
- // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component
59
- route.value?.options?.notFoundComponent ?? router?.options?.notFoundRoute?.options?.component
60
- ) : route.value?.options?.notFoundComponent);
61
- const hasShellComponent = Vue.computed(() => {
62
- if (!route.value?.isRoot) return false;
63
- return !!route.value.options.shellComponent;
64
- });
65
- const ShellComponent = Vue.computed(() => hasShellComponent.value ? route.value.options.shellComponent : null);
66
- const matchIdRef = Vue.ref(matchData.value?.matchId ?? props.matchId);
67
- Vue.watch([() => props.matchId, () => matchData.value?.matchId], ([propsMatchId, dataMatchId]) => {
68
- matchIdRef.value = dataMatchId ?? propsMatchId;
69
- }, {
70
- immediate: true
71
- });
72
- Vue.provide(matchContext, matchIdRef);
73
- return () => {
74
- const actualMatchId = matchData.value?.matchId ?? props.matchId;
75
- const resolvedNoSsr = matchData.value?.ssr === false || matchData.value?.ssr === "data-only";
76
- const shouldClientOnly = resolvedNoSsr || !!matchData.value?._displayPending;
77
- const renderMatchContent = () => {
78
- const matchInner = Vue.h(MatchInner, {
79
- matchId: actualMatchId
80
- });
81
- let content = shouldClientOnly ? Vue.h(ClientOnly, {
82
- fallback: pendingElement.value
83
- }, {
84
- default: () => matchInner
85
- }) : matchInner;
86
- if (routeNotFoundComponent.value) {
87
- content = Vue.h(CatchNotFound, {
88
- fallback: (error) => {
89
- if (!routeNotFoundComponent.value || error.routeId && error.routeId !== matchData.value?.routeId || !error.routeId && route.value && !route.value.isRoot) throw error;
90
- return Vue.h(routeNotFoundComponent.value, error);
91
- },
92
- children: content
93
- });
94
- }
95
- if (routeErrorComponent.value) {
96
- content = CatchBoundary({
97
- getResetKey: () => matchData.value?.loadedAt ?? 0,
98
- errorComponent: routeErrorComponent.value || ErrorComponent,
99
- onCatch: (error) => {
100
- if (isNotFound(error)) throw error;
101
- warning(false, `Error in route match: ${actualMatchId}`);
102
- routeOnCatch.value?.(error);
103
- },
104
- children: content
105
- });
106
- }
107
- const withScrollRestoration = [content, matchData.value?.parentRouteId === rootRouteId && router.options.scrollRestoration ? Vue.h(Vue.Fragment, null, [Vue.h(OnRendered), Vue.h(ScrollRestoration)]) : null].filter(Boolean);
108
- if (withScrollRestoration.length === 1) {
109
- return withScrollRestoration[0];
110
- }
111
- return Vue.h(Vue.Fragment, null, withScrollRestoration);
112
- };
113
- if (!hasShellComponent.value) {
114
- return renderMatchContent();
115
- }
116
- return Vue.h(ShellComponent.value, null, {
117
- // Important: return a fresh VNode on each slot invocation so that shell
118
- // components can re-render without reusing a cached VNode instance.
119
- default: () => renderMatchContent()
120
- });
121
- };
122
- }
9
+ import { createControlledPromise, getLocationChangeInfo, isNotFound, isRedirect, rootRouteId } from "@tanstack/router-core";
10
+ import * as Vue from "vue";
11
+ import warning from "tiny-warning";
12
+ import { isServer } from "@tanstack/router-core/isServer";
13
+ import invariant from "tiny-invariant";
14
+ //#region src/Match.tsx
15
+ var Match = Vue.defineComponent({
16
+ name: "Match",
17
+ props: { matchId: {
18
+ type: String,
19
+ required: true
20
+ } },
21
+ setup(props) {
22
+ const router = useRouter();
23
+ let lastKnownRouteId = null;
24
+ const matchData = useRouterState({ select: (s) => {
25
+ let match = s.matches.find((d) => d.id === props.matchId);
26
+ let matchIndex = match ? s.matches.findIndex((d) => d.id === props.matchId) : -1;
27
+ if (match) lastKnownRouteId = match.routeId;
28
+ else if (lastKnownRouteId) {
29
+ match = s.matches.find((d) => d.routeId === lastKnownRouteId);
30
+ matchIndex = match ? s.matches.findIndex((d) => d.routeId === lastKnownRouteId) : -1;
31
+ }
32
+ if (!match) return null;
33
+ const routeId = match.routeId;
34
+ const parentRouteId = matchIndex > 0 ? s.matches[matchIndex - 1]?.routeId : null;
35
+ return {
36
+ matchId: match.id,
37
+ routeId,
38
+ parentRouteId,
39
+ loadedAt: s.loadedAt,
40
+ ssr: match.ssr,
41
+ _displayPending: match._displayPending
42
+ };
43
+ } });
44
+ invariant(matchData.value, `Could not find routeId for matchId "${props.matchId}". Please file an issue!`);
45
+ const route = Vue.computed(() => matchData.value ? router.routesById[matchData.value.routeId] : null);
46
+ const PendingComponent = Vue.computed(() => route.value?.options?.pendingComponent ?? router?.options?.defaultPendingComponent);
47
+ const pendingElement = Vue.computed(() => PendingComponent.value ? Vue.h(PendingComponent.value) : void 0);
48
+ const routeErrorComponent = Vue.computed(() => route.value?.options?.errorComponent ?? router?.options?.defaultErrorComponent);
49
+ const routeOnCatch = Vue.computed(() => route.value?.options?.onCatch ?? router?.options?.defaultOnCatch);
50
+ const routeNotFoundComponent = Vue.computed(() => route.value?.isRoot ? route.value?.options?.notFoundComponent ?? router?.options?.notFoundRoute?.options?.component : route.value?.options?.notFoundComponent);
51
+ const hasShellComponent = Vue.computed(() => {
52
+ if (!route.value?.isRoot) return false;
53
+ return !!route.value.options.shellComponent;
54
+ });
55
+ const ShellComponent = Vue.computed(() => hasShellComponent.value ? route.value.options.shellComponent : null);
56
+ const matchIdRef = Vue.ref(matchData.value?.matchId ?? props.matchId);
57
+ Vue.watch([() => props.matchId, () => matchData.value?.matchId], ([propsMatchId, dataMatchId]) => {
58
+ matchIdRef.value = dataMatchId ?? propsMatchId;
59
+ }, { immediate: true });
60
+ Vue.provide(matchContext, matchIdRef);
61
+ return () => {
62
+ const actualMatchId = matchData.value?.matchId ?? props.matchId;
63
+ const shouldClientOnly = matchData.value?.ssr === false || matchData.value?.ssr === "data-only" || !!matchData.value?._displayPending;
64
+ const renderMatchContent = () => {
65
+ const matchInner = Vue.h(MatchInner, { matchId: actualMatchId });
66
+ let content = shouldClientOnly ? Vue.h(ClientOnly, { fallback: pendingElement.value }, { default: () => matchInner }) : matchInner;
67
+ if (routeNotFoundComponent.value) content = Vue.h(CatchNotFound, {
68
+ fallback: (error) => {
69
+ if (!routeNotFoundComponent.value || error.routeId && error.routeId !== matchData.value?.routeId || !error.routeId && route.value && !route.value.isRoot) throw error;
70
+ return Vue.h(routeNotFoundComponent.value, error);
71
+ },
72
+ children: content
73
+ });
74
+ if (routeErrorComponent.value) content = CatchBoundary({
75
+ getResetKey: () => matchData.value?.loadedAt ?? 0,
76
+ errorComponent: routeErrorComponent.value || ErrorComponent,
77
+ onCatch: (error) => {
78
+ if (isNotFound(error)) throw error;
79
+ warning(false, `Error in route match: ${actualMatchId}`);
80
+ routeOnCatch.value?.(error);
81
+ },
82
+ children: content
83
+ });
84
+ const withScrollRestoration = [content, matchData.value?.parentRouteId === rootRouteId && router.options.scrollRestoration ? Vue.h(Vue.Fragment, null, [Vue.h(OnRendered), Vue.h(ScrollRestoration)]) : null].filter(Boolean);
85
+ if (withScrollRestoration.length === 1) return withScrollRestoration[0];
86
+ return Vue.h(Vue.Fragment, null, withScrollRestoration);
87
+ };
88
+ if (!hasShellComponent.value) return renderMatchContent();
89
+ return Vue.h(ShellComponent.value, null, { default: () => renderMatchContent() });
90
+ };
91
+ }
123
92
  });
124
- const OnRendered = Vue.defineComponent({
125
- name: "OnRendered",
126
- setup() {
127
- const router = useRouter();
128
- const location = useRouterState({
129
- select: (s) => {
130
- return s.resolvedLocation?.state.key;
131
- }
132
- });
133
- Vue.watchEffect(() => {
134
- if (location.value) {
135
- router.emit({
136
- type: "onRendered",
137
- ...getLocationChangeInfo(router.state)
138
- });
139
- }
140
- });
141
- return () => null;
142
- }
93
+ var OnRendered = Vue.defineComponent({
94
+ name: "OnRendered",
95
+ setup() {
96
+ const router = useRouter();
97
+ const location = useRouterState({ select: (s) => {
98
+ return s.resolvedLocation?.state.key;
99
+ } });
100
+ Vue.watchEffect(() => {
101
+ if (location.value) router.emit({
102
+ type: "onRendered",
103
+ ...getLocationChangeInfo(router.state)
104
+ });
105
+ });
106
+ return () => null;
107
+ }
143
108
  });
144
- const MatchInner = Vue.defineComponent({
145
- name: "MatchInner",
146
- props: {
147
- matchId: {
148
- type: String,
149
- required: true
150
- }
151
- },
152
- setup(props) {
153
- const router = useRouter();
154
- let lastKnownRouteId = null;
155
- const combinedState = useRouterState({
156
- select: (s) => {
157
- let match2 = s.matches.find((d) => d.id === props.matchId);
158
- if (match2) {
159
- lastKnownRouteId = match2.routeId;
160
- } else if (lastKnownRouteId) {
161
- const sameRouteMatch = s.matches.find((d) => d.routeId === lastKnownRouteId);
162
- if (sameRouteMatch) {
163
- match2 = sameRouteMatch;
164
- }
165
- }
166
- if (!match2) {
167
- return null;
168
- }
169
- const routeId = match2.routeId;
170
- const remountFn = router.routesById[routeId].options.remountDeps ?? router.options.defaultRemountDeps;
171
- let remountKey2;
172
- if (remountFn) {
173
- const remountDeps = remountFn({
174
- routeId,
175
- loaderDeps: match2.loaderDeps,
176
- params: match2._strictParams,
177
- search: match2._strictSearch
178
- });
179
- remountKey2 = remountDeps ? JSON.stringify(remountDeps) : void 0;
180
- }
181
- return {
182
- routeId,
183
- match: {
184
- id: match2.id,
185
- status: match2.status,
186
- error: match2.error,
187
- ssr: match2.ssr,
188
- _forcePending: match2._forcePending,
189
- _displayPending: match2._displayPending
190
- },
191
- remountKey: remountKey2
192
- };
193
- }
194
- });
195
- const route = Vue.computed(() => {
196
- if (!combinedState.value) return null;
197
- return router.routesById[combinedState.value.routeId];
198
- });
199
- const match = Vue.computed(() => combinedState.value?.match);
200
- const remountKey = Vue.computed(() => combinedState.value?.remountKey);
201
- return () => {
202
- if (!combinedState.value || !match.value || !route.value) return null;
203
- if (match.value._displayPending) {
204
- const PendingComponent = route.value.options.pendingComponent ?? router.options.defaultPendingComponent;
205
- return PendingComponent ? Vue.h(PendingComponent) : null;
206
- }
207
- if (match.value._forcePending) {
208
- const PendingComponent = route.value.options.pendingComponent ?? router.options.defaultPendingComponent;
209
- return PendingComponent ? Vue.h(PendingComponent) : null;
210
- }
211
- if (match.value.status === "notFound") {
212
- invariant(isNotFound(match.value.error), "Expected a notFound error");
213
- return renderRouteNotFound(router, route.value, match.value.error);
214
- }
215
- if (match.value.status === "redirected") {
216
- invariant(isRedirect(match.value.error), "Expected a redirect error");
217
- throw router.getMatch(match.value.id)?._nonReactive.loadPromise;
218
- }
219
- if (match.value.status === "error") {
220
- const RouteErrorComponent = route.value.options.errorComponent ?? router.options.defaultErrorComponent;
221
- if (RouteErrorComponent) {
222
- return Vue.h(RouteErrorComponent, {
223
- error: match.value.error,
224
- reset: () => {
225
- router.invalidate();
226
- },
227
- info: {
228
- componentStack: ""
229
- }
230
- });
231
- }
232
- throw match.value.error;
233
- }
234
- if (match.value.status === "pending") {
235
- const pendingMinMs = route.value.options.pendingMinMs ?? router.options.defaultPendingMinMs;
236
- const routerMatch = router.getMatch(match.value.id);
237
- if (pendingMinMs && 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
- const PendingComponent = route.value.options.pendingComponent ?? router.options.defaultPendingComponent;
248
- if (PendingComponent) {
249
- return Vue.h(PendingComponent);
250
- }
251
- return null;
252
- }
253
- const Comp = route.value.options.component ?? router.options.defaultComponent;
254
- const key = remountKey.value;
255
- if (Comp) {
256
- return Vue.h(Comp, key !== void 0 ? {
257
- key
258
- } : void 0);
259
- }
260
- return Vue.h(Outlet, key !== void 0 ? {
261
- key
262
- } : void 0);
263
- };
264
- }
109
+ var MatchInner = Vue.defineComponent({
110
+ name: "MatchInner",
111
+ props: { matchId: {
112
+ type: String,
113
+ required: true
114
+ } },
115
+ setup(props) {
116
+ const router = useRouter();
117
+ let lastKnownRouteId = null;
118
+ const combinedState = useRouterState({ select: (s) => {
119
+ let match = s.matches.find((d) => d.id === props.matchId);
120
+ if (match) lastKnownRouteId = match.routeId;
121
+ else if (lastKnownRouteId) {
122
+ const sameRouteMatch = s.matches.find((d) => d.routeId === lastKnownRouteId);
123
+ if (sameRouteMatch) match = sameRouteMatch;
124
+ }
125
+ if (!match) return null;
126
+ const routeId = match.routeId;
127
+ const remountFn = router.routesById[routeId].options.remountDeps ?? router.options.defaultRemountDeps;
128
+ let remountKey;
129
+ if (remountFn) {
130
+ const remountDeps = remountFn({
131
+ routeId,
132
+ loaderDeps: match.loaderDeps,
133
+ params: match._strictParams,
134
+ search: match._strictSearch
135
+ });
136
+ remountKey = remountDeps ? JSON.stringify(remountDeps) : void 0;
137
+ }
138
+ return {
139
+ routeId,
140
+ match: {
141
+ id: match.id,
142
+ status: match.status,
143
+ error: match.error,
144
+ ssr: match.ssr,
145
+ _forcePending: match._forcePending,
146
+ _displayPending: match._displayPending
147
+ },
148
+ remountKey
149
+ };
150
+ } });
151
+ const route = Vue.computed(() => {
152
+ if (!combinedState.value) return null;
153
+ return router.routesById[combinedState.value.routeId];
154
+ });
155
+ const match = Vue.computed(() => combinedState.value?.match);
156
+ const remountKey = Vue.computed(() => combinedState.value?.remountKey);
157
+ return () => {
158
+ if (!combinedState.value || !match.value || !route.value) return null;
159
+ if (match.value._displayPending) {
160
+ const PendingComponent = route.value.options.pendingComponent ?? router.options.defaultPendingComponent;
161
+ return PendingComponent ? Vue.h(PendingComponent) : null;
162
+ }
163
+ if (match.value._forcePending) {
164
+ const PendingComponent = route.value.options.pendingComponent ?? router.options.defaultPendingComponent;
165
+ return PendingComponent ? Vue.h(PendingComponent) : null;
166
+ }
167
+ if (match.value.status === "notFound") {
168
+ invariant(isNotFound(match.value.error), "Expected a notFound error");
169
+ return renderRouteNotFound(router, route.value, match.value.error);
170
+ }
171
+ if (match.value.status === "redirected") {
172
+ invariant(isRedirect(match.value.error), "Expected a redirect error");
173
+ throw router.getMatch(match.value.id)?._nonReactive.loadPromise;
174
+ }
175
+ if (match.value.status === "error") {
176
+ const RouteErrorComponent = route.value.options.errorComponent ?? router.options.defaultErrorComponent;
177
+ if (RouteErrorComponent) return Vue.h(RouteErrorComponent, {
178
+ error: match.value.error,
179
+ reset: () => {
180
+ router.invalidate();
181
+ },
182
+ info: { componentStack: "" }
183
+ });
184
+ throw match.value.error;
185
+ }
186
+ if (match.value.status === "pending") {
187
+ const pendingMinMs = route.value.options.pendingMinMs ?? router.options.defaultPendingMinMs;
188
+ const routerMatch = router.getMatch(match.value.id);
189
+ if (pendingMinMs && routerMatch && !routerMatch._nonReactive.minPendingPromise) {
190
+ if (!(isServer ?? router.isServer)) {
191
+ const minPendingPromise = createControlledPromise();
192
+ routerMatch._nonReactive.minPendingPromise = minPendingPromise;
193
+ setTimeout(() => {
194
+ minPendingPromise.resolve();
195
+ routerMatch._nonReactive.minPendingPromise = void 0;
196
+ }, pendingMinMs);
197
+ }
198
+ }
199
+ const PendingComponent = route.value.options.pendingComponent ?? router.options.defaultPendingComponent;
200
+ if (PendingComponent) return Vue.h(PendingComponent);
201
+ return null;
202
+ }
203
+ const Comp = route.value.options.component ?? router.options.defaultComponent;
204
+ const key = remountKey.value;
205
+ if (Comp) return Vue.h(Comp, key !== void 0 ? { key } : void 0);
206
+ return Vue.h(Outlet, key !== void 0 ? { key } : void 0);
207
+ };
208
+ }
265
209
  });
266
- const Outlet = Vue.defineComponent({
267
- name: "Outlet",
268
- setup() {
269
- const router = useRouter();
270
- const matchId = Vue.inject(matchContext);
271
- const safeMatchId = Vue.computed(() => matchId?.value || "");
272
- const routeId = useRouterState({
273
- select: (s) => s.matches.find((d) => d.id === safeMatchId.value)?.routeId
274
- });
275
- const route = Vue.computed(() => router.routesById[routeId.value]);
276
- const parentGlobalNotFound = useRouterState({
277
- select: (s) => {
278
- const matches = s.matches;
279
- const parentMatch = matches.find((d) => d.id === safeMatchId.value);
280
- if (!parentMatch) {
281
- return false;
282
- }
283
- return parentMatch.globalNotFound;
284
- }
285
- });
286
- const childMatchData = useRouterState({
287
- select: (s) => {
288
- const matches = s.matches;
289
- const index = matches.findIndex((d) => d.id === safeMatchId.value);
290
- const child = matches[index + 1];
291
- if (!child) return null;
292
- return {
293
- id: child.id,
294
- // Key based on routeId + params only (not loaderDeps)
295
- // This ensures component recreates when params change,
296
- // but NOT when only loaderDeps change
297
- paramsKey: child.routeId + JSON.stringify(child._strictParams)
298
- };
299
- }
300
- });
301
- return () => {
302
- if (parentGlobalNotFound.value) {
303
- return renderRouteNotFound(router, route.value, void 0);
304
- }
305
- if (!childMatchData.value) {
306
- return null;
307
- }
308
- const nextMatch = Vue.h(Match, {
309
- matchId: childMatchData.value.id,
310
- key: childMatchData.value.paramsKey
311
- });
312
- if (safeMatchId.value === rootRouteId) {
313
- return Vue.h(Vue.Suspense, {
314
- fallback: router.options.defaultPendingComponent ? Vue.h(router.options.defaultPendingComponent) : null
315
- }, {
316
- default: () => nextMatch
317
- });
318
- }
319
- return nextMatch;
320
- };
321
- }
210
+ var Outlet = Vue.defineComponent({
211
+ name: "Outlet",
212
+ setup() {
213
+ const router = useRouter();
214
+ const matchId = Vue.inject(matchContext);
215
+ const safeMatchId = Vue.computed(() => matchId?.value || "");
216
+ const routeId = useRouterState({ select: (s) => s.matches.find((d) => d.id === safeMatchId.value)?.routeId });
217
+ const route = Vue.computed(() => router.routesById[routeId.value]);
218
+ const parentGlobalNotFound = useRouterState({ select: (s) => {
219
+ const parentMatch = s.matches.find((d) => d.id === safeMatchId.value);
220
+ if (!parentMatch) return false;
221
+ return parentMatch.globalNotFound;
222
+ } });
223
+ const childMatchData = useRouterState({ select: (s) => {
224
+ const matches = s.matches;
225
+ const child = matches[matches.findIndex((d) => d.id === safeMatchId.value) + 1];
226
+ if (!child) return null;
227
+ return {
228
+ id: child.id,
229
+ paramsKey: child.routeId + JSON.stringify(child._strictParams)
230
+ };
231
+ } });
232
+ return () => {
233
+ if (parentGlobalNotFound.value) return renderRouteNotFound(router, route.value, void 0);
234
+ if (!childMatchData.value) return null;
235
+ const nextMatch = Vue.h(Match, {
236
+ matchId: childMatchData.value.id,
237
+ key: childMatchData.value.paramsKey
238
+ });
239
+ if (safeMatchId.value === rootRouteId) return Vue.h(Vue.Suspense, { fallback: router.options.defaultPendingComponent ? Vue.h(router.options.defaultPendingComponent) : null }, { default: () => nextMatch });
240
+ return nextMatch;
241
+ };
242
+ }
322
243
  });
323
- export {
324
- Match,
325
- MatchInner,
326
- Outlet
327
- };
328
- //# sourceMappingURL=Match.js.map
244
+ //#endregion
245
+ export { Match, Outlet };
246
+
247
+ //# sourceMappingURL=Match.js.map