@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.
- package/dist/esm/Asset.js +107 -151
- package/dist/esm/Asset.js.map +1 -1
- package/dist/esm/Body.js +15 -24
- package/dist/esm/Body.js.map +1 -1
- package/dist/esm/CatchBoundary.js +112 -130
- package/dist/esm/CatchBoundary.js.map +1 -1
- package/dist/esm/ClientOnly.js +59 -29
- package/dist/esm/ClientOnly.js.map +1 -1
- package/dist/esm/HeadContent.dev.js +29 -23
- package/dist/esm/HeadContent.dev.js.map +1 -1
- package/dist/esm/HeadContent.js +21 -16
- package/dist/esm/HeadContent.js.map +1 -1
- package/dist/esm/Html.js +42 -61
- package/dist/esm/Html.js.map +1 -1
- package/dist/esm/Match.js +238 -319
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.js +127 -170
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.js +50 -65
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/ScriptOnce.js +31 -36
- package/dist/esm/ScriptOnce.js.map +1 -1
- package/dist/esm/Scripts.js +79 -101
- package/dist/esm/Scripts.js.map +1 -1
- package/dist/esm/ScrollRestoration.js +25 -29
- package/dist/esm/ScrollRestoration.js.map +1 -1
- package/dist/esm/Transitioner.js +146 -164
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/awaited.js +27 -34
- package/dist/esm/awaited.js.map +1 -1
- package/dist/esm/fileRoute.js +90 -92
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/headContentUtils.js +92 -123
- package/dist/esm/headContentUtils.js.map +1 -1
- package/dist/esm/index.dev.js +16 -118
- package/dist/esm/index.js +18 -119
- package/dist/esm/lazyRouteComponent.js +69 -82
- package/dist/esm/lazyRouteComponent.js.map +1 -1
- package/dist/esm/link.js +364 -385
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/matchContext.js +16 -11
- package/dist/esm/matchContext.js.map +1 -1
- package/dist/esm/not-found.js +30 -40
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/renderRouteNotFound.js +20 -15
- package/dist/esm/renderRouteNotFound.js.map +1 -1
- package/dist/esm/route.js +196 -174
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.js +11 -11
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerContext.js +10 -7
- package/dist/esm/routerContext.js.map +1 -1
- package/dist/esm/scroll-restoration.js +39 -50
- package/dist/esm/scroll-restoration.js.map +1 -1
- package/dist/esm/ssr/RouterClient.js +29 -43
- package/dist/esm/ssr/RouterClient.js.map +1 -1
- package/dist/esm/ssr/RouterServer.js +29 -32
- package/dist/esm/ssr/RouterServer.js.map +1 -1
- package/dist/esm/ssr/client.js +1 -4
- package/dist/esm/ssr/defaultRenderHandler.js +11 -13
- package/dist/esm/ssr/defaultRenderHandler.js.map +1 -1
- package/dist/esm/ssr/defaultStreamHandler.js +12 -15
- package/dist/esm/ssr/defaultStreamHandler.js.map +1 -1
- package/dist/esm/ssr/renderRouterToStream.js +47 -65
- package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
- package/dist/esm/ssr/renderRouterToString.js +24 -32
- package/dist/esm/ssr/renderRouterToString.js.map +1 -1
- package/dist/esm/ssr/server.js +3 -10
- package/dist/esm/useBlocker.js +243 -287
- package/dist/esm/useBlocker.js.map +1 -1
- package/dist/esm/useCanGoBack.js +6 -5
- package/dist/esm/useCanGoBack.js.map +1 -1
- package/dist/esm/useLoaderData.js +12 -11
- package/dist/esm/useLoaderData.js.map +1 -1
- package/dist/esm/useLoaderDeps.js +12 -14
- package/dist/esm/useLoaderDeps.js.map +1 -1
- package/dist/esm/useLocation.js +6 -7
- package/dist/esm/useLocation.js.map +1 -1
- package/dist/esm/useMatch.js +27 -35
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useNavigate.js +18 -24
- package/dist/esm/useNavigate.js.map +1 -1
- package/dist/esm/useParams.js +13 -12
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useRouteContext.js +9 -8
- package/dist/esm/useRouteContext.js.map +1 -1
- package/dist/esm/useRouter.js +9 -8
- package/dist/esm/useRouter.js.map +1 -1
- package/dist/esm/useRouterState.js +18 -22
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/esm/useSearch.js +13 -12
- package/dist/esm/useSearch.js.map +1 -1
- package/dist/esm/utils.js +59 -38
- package/dist/esm/utils.js.map +1 -1
- package/package.json +3 -3
- package/dist/esm/index.dev.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/ssr/client.js.map +0 -1
- package/dist/esm/ssr/server.js.map +0 -1
package/dist/esm/Match.js
CHANGED
|
@@ -1,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 {
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}, 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
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
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
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
};
|
|
328
|
-
//# sourceMappingURL=Match.js.map
|
|
244
|
+
//#endregion
|
|
245
|
+
export { Match, Outlet };
|
|
246
|
+
|
|
247
|
+
//# sourceMappingURL=Match.js.map
|