@tanstack/vue-router 1.167.5 → 1.168.1
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/Match.js +55 -61
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.js +8 -15
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/Scripts.js +7 -6
- package/dist/esm/Scripts.js.map +1 -1
- package/dist/esm/Transitioner.js +18 -24
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/headContentUtils.js +13 -15
- package/dist/esm/headContentUtils.js.map +1 -1
- package/dist/esm/index.dev.js +6 -6
- package/dist/esm/index.js +6 -6
- package/dist/esm/link.js +242 -178
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/matchContext.d.ts +8 -14
- package/dist/esm/matchContext.js +11 -9
- package/dist/esm/matchContext.js.map +1 -1
- package/dist/esm/not-found.js +6 -3
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/router.js +2 -1
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerStores.d.ts +13 -0
- package/dist/esm/routerStores.js +33 -0
- package/dist/esm/routerStores.js.map +1 -0
- package/dist/esm/ssr/RouterClient.js +1 -1
- package/dist/esm/ssr/RouterClient.js.map +1 -1
- package/dist/esm/ssr/renderRouterToStream.js +2 -2
- package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
- package/dist/esm/ssr/renderRouterToString.js +1 -1
- package/dist/esm/ssr/renderRouterToString.js.map +1 -1
- package/dist/esm/useCanGoBack.d.ts +1 -1
- package/dist/esm/useCanGoBack.js +3 -2
- package/dist/esm/useCanGoBack.js.map +1 -1
- package/dist/esm/useLocation.js +3 -2
- package/dist/esm/useLocation.js.map +1 -1
- package/dist/esm/useMatch.js +29 -19
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useRouterState.js +4 -4
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/source/Match.jsx +121 -159
- package/dist/source/Match.jsx.map +1 -1
- package/dist/source/Matches.jsx +11 -28
- package/dist/source/Matches.jsx.map +1 -1
- package/dist/source/Scripts.jsx +32 -35
- package/dist/source/Scripts.jsx.map +1 -1
- package/dist/source/Transitioner.jsx +19 -21
- package/dist/source/Transitioner.jsx.map +1 -1
- package/dist/source/headContentUtils.jsx +51 -61
- package/dist/source/headContentUtils.jsx.map +1 -1
- package/dist/source/link.jsx +298 -249
- package/dist/source/link.jsx.map +1 -1
- package/dist/source/matchContext.d.ts +8 -14
- package/dist/source/matchContext.jsx +17 -23
- package/dist/source/matchContext.jsx.map +1 -1
- package/dist/source/not-found.jsx +6 -5
- package/dist/source/not-found.jsx.map +1 -1
- package/dist/source/router.js +2 -1
- package/dist/source/router.js.map +1 -1
- package/dist/source/routerStores.d.ts +13 -0
- package/dist/source/routerStores.js +37 -0
- package/dist/source/routerStores.js.map +1 -0
- package/dist/source/ssr/RouterClient.jsx +1 -1
- package/dist/source/ssr/RouterClient.jsx.map +1 -1
- package/dist/source/ssr/renderRouterToStream.jsx +2 -2
- package/dist/source/ssr/renderRouterToStream.jsx.map +1 -1
- package/dist/source/ssr/renderRouterToString.jsx +1 -1
- package/dist/source/ssr/renderRouterToString.jsx.map +1 -1
- package/dist/source/useCanGoBack.d.ts +1 -1
- package/dist/source/useCanGoBack.js +4 -2
- package/dist/source/useCanGoBack.js.map +1 -1
- package/dist/source/useLocation.jsx +4 -4
- package/dist/source/useLocation.jsx.map +1 -1
- package/dist/source/useMatch.jsx +60 -38
- package/dist/source/useMatch.jsx.map +1 -1
- package/dist/source/useRouterState.jsx +4 -4
- package/dist/source/useRouterState.jsx.map +1 -1
- package/package.json +4 -4
- package/skills/vue-router/SKILL.md +3 -0
- package/src/Match.tsx +168 -180
- package/src/Matches.tsx +18 -31
- package/src/Scripts.tsx +40 -40
- package/src/Transitioner.tsx +35 -23
- package/src/headContentUtils.tsx +101 -107
- package/src/link.tsx +445 -300
- package/src/matchContext.tsx +23 -25
- package/src/not-found.tsx +9 -5
- package/src/router.ts +2 -1
- package/src/routerStores.ts +54 -0
- package/src/ssr/RouterClient.tsx +1 -1
- package/src/ssr/renderRouterToStream.tsx +2 -2
- package/src/ssr/renderRouterToString.tsx +1 -1
- package/src/useCanGoBack.ts +7 -2
- package/src/useLocation.tsx +8 -5
- package/src/useMatch.tsx +95 -49
- package/src/useRouterState.tsx +6 -4
package/dist/esm/Match.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { CatchBoundary, ErrorComponent } from "./CatchBoundary.js";
|
|
2
2
|
import { useRouter } from "./useRouter.js";
|
|
3
|
-
import {
|
|
4
|
-
import { matchContext } from "./matchContext.js";
|
|
3
|
+
import { matchContext, pendingMatchContext, routeIdContext } from "./matchContext.js";
|
|
5
4
|
import { ClientOnly } from "./ClientOnly.js";
|
|
6
5
|
import { CatchNotFound } from "./not-found.js";
|
|
7
6
|
import { renderRouteNotFound } from "./renderRouteNotFound.js";
|
|
@@ -10,6 +9,7 @@ import { createControlledPromise, getLocationChangeInfo, isNotFound, isRedirect,
|
|
|
10
9
|
import * as Vue from "vue";
|
|
11
10
|
import warning from "tiny-warning";
|
|
12
11
|
import { isServer } from "@tanstack/router-core/isServer";
|
|
12
|
+
import { useStore } from "@tanstack/vue-store";
|
|
13
13
|
import invariant from "tiny-invariant";
|
|
14
14
|
//#region src/Match.tsx
|
|
15
15
|
var Match = Vue.defineComponent({
|
|
@@ -20,28 +20,23 @@ var Match = Vue.defineComponent({
|
|
|
20
20
|
} },
|
|
21
21
|
setup(props) {
|
|
22
22
|
const router = useRouter();
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
23
|
+
const routeId = router.stores.activeMatchStoresById.get(props.matchId)?.routeId;
|
|
24
|
+
invariant(routeId, `Could not find routeId for matchId "${props.matchId}". Please file an issue!`);
|
|
25
|
+
const isChildOfRoot = router.routesById[routeId]?.parentRoute?.id === rootRouteId;
|
|
26
|
+
const activeMatch = useStore(router.stores.getMatchStoreByRouteId(routeId), (value) => value);
|
|
27
|
+
const isPendingMatchRef = useStore(router.stores.pendingRouteIds, (pendingRouteIds) => Boolean(pendingRouteIds[routeId]), { equal: Object.is });
|
|
28
|
+
const loadedAt = useStore(router.stores.loadedAt, (value) => value);
|
|
29
|
+
const matchData = Vue.computed(() => {
|
|
30
|
+
const match = activeMatch.value;
|
|
32
31
|
if (!match) return null;
|
|
33
|
-
const routeId = match.routeId;
|
|
34
|
-
const parentRouteId = matchIndex > 0 ? s.matches[matchIndex - 1]?.routeId : null;
|
|
35
32
|
return {
|
|
36
33
|
matchId: match.id,
|
|
37
34
|
routeId,
|
|
38
|
-
|
|
39
|
-
loadedAt: s.loadedAt,
|
|
35
|
+
loadedAt: loadedAt.value,
|
|
40
36
|
ssr: match.ssr,
|
|
41
37
|
_displayPending: match._displayPending
|
|
42
38
|
};
|
|
43
|
-
}
|
|
44
|
-
invariant(matchData.value, `Could not find routeId for matchId "${props.matchId}". Please file an issue!`);
|
|
39
|
+
});
|
|
45
40
|
const route = Vue.computed(() => matchData.value ? router.routesById[matchData.value.routeId] : null);
|
|
46
41
|
const PendingComponent = Vue.computed(() => route.value?.options?.pendingComponent ?? router?.options?.defaultPendingComponent);
|
|
47
42
|
const pendingElement = Vue.computed(() => PendingComponent.value ? Vue.h(PendingComponent.value) : void 0);
|
|
@@ -53,11 +48,10 @@ var Match = Vue.defineComponent({
|
|
|
53
48
|
return !!route.value.options.shellComponent;
|
|
54
49
|
});
|
|
55
50
|
const ShellComponent = Vue.computed(() => hasShellComponent.value ? route.value.options.shellComponent : null);
|
|
56
|
-
|
|
57
|
-
Vue.
|
|
58
|
-
matchIdRef.value = dataMatchId ?? propsMatchId;
|
|
59
|
-
}, { immediate: true });
|
|
51
|
+
Vue.provide(routeIdContext, routeId);
|
|
52
|
+
const matchIdRef = Vue.computed(() => activeMatch.value?.id ?? props.matchId);
|
|
60
53
|
Vue.provide(matchContext, matchIdRef);
|
|
54
|
+
Vue.provide(pendingMatchContext, isPendingMatchRef);
|
|
61
55
|
return () => {
|
|
62
56
|
const actualMatchId = matchData.value?.matchId ?? props.matchId;
|
|
63
57
|
const shouldClientOnly = matchData.value?.ssr === false || matchData.value?.ssr === "data-only" || !!matchData.value?._displayPending;
|
|
@@ -81,7 +75,7 @@ var Match = Vue.defineComponent({
|
|
|
81
75
|
},
|
|
82
76
|
children: content
|
|
83
77
|
});
|
|
84
|
-
const withScrollRestoration = [content,
|
|
78
|
+
const withScrollRestoration = [content, isChildOfRoot && router.options.scrollRestoration ? Vue.h(Vue.Fragment, null, [Vue.h(OnRendered), Vue.h(ScrollRestoration)]) : null].filter(Boolean);
|
|
85
79
|
if (withScrollRestoration.length === 1) return withScrollRestoration[0];
|
|
86
80
|
return Vue.h(Vue.Fragment, null, withScrollRestoration);
|
|
87
81
|
};
|
|
@@ -94,15 +88,20 @@ var OnRendered = Vue.defineComponent({
|
|
|
94
88
|
name: "OnRendered",
|
|
95
89
|
setup() {
|
|
96
90
|
const router = useRouter();
|
|
97
|
-
const location =
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
91
|
+
const location = useStore(router.stores.resolvedLocation, (resolvedLocation) => resolvedLocation?.state.__TSR_key);
|
|
92
|
+
let prevHref;
|
|
93
|
+
Vue.watch(location, () => {
|
|
94
|
+
if (location.value) {
|
|
95
|
+
const currentHref = router.latestLocation.href;
|
|
96
|
+
if (prevHref === void 0 || prevHref !== currentHref) {
|
|
97
|
+
router.emit({
|
|
98
|
+
type: "onRendered",
|
|
99
|
+
...getLocationChangeInfo(router.stores.location.state, router.stores.resolvedLocation.state)
|
|
100
|
+
});
|
|
101
|
+
prevHref = currentHref;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}, { immediate: true });
|
|
106
105
|
return () => null;
|
|
107
106
|
}
|
|
108
107
|
});
|
|
@@ -114,21 +113,17 @@ var MatchInner = Vue.defineComponent({
|
|
|
114
113
|
} },
|
|
115
114
|
setup(props) {
|
|
116
115
|
const router = useRouter();
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
else if (lastKnownRouteId) {
|
|
122
|
-
const sameRouteMatch = s.matches.find((d) => d.routeId === lastKnownRouteId);
|
|
123
|
-
if (sameRouteMatch) match = sameRouteMatch;
|
|
124
|
-
}
|
|
116
|
+
const routeId = Vue.inject(routeIdContext);
|
|
117
|
+
const activeMatch = useStore(router.stores.getMatchStoreByRouteId(routeId), (value) => value);
|
|
118
|
+
const combinedState = Vue.computed(() => {
|
|
119
|
+
const match = activeMatch.value;
|
|
125
120
|
if (!match) return null;
|
|
126
|
-
const
|
|
127
|
-
const remountFn = router.routesById[
|
|
121
|
+
const matchRouteId = match.routeId;
|
|
122
|
+
const remountFn = router.routesById[matchRouteId].options.remountDeps ?? router.options.defaultRemountDeps;
|
|
128
123
|
let remountKey;
|
|
129
124
|
if (remountFn) {
|
|
130
125
|
const remountDeps = remountFn({
|
|
131
|
-
routeId,
|
|
126
|
+
routeId: matchRouteId,
|
|
132
127
|
loaderDeps: match.loaderDeps,
|
|
133
128
|
params: match._strictParams,
|
|
134
129
|
search: match._strictSearch
|
|
@@ -136,7 +131,7 @@ var MatchInner = Vue.defineComponent({
|
|
|
136
131
|
remountKey = remountDeps ? JSON.stringify(remountDeps) : void 0;
|
|
137
132
|
}
|
|
138
133
|
return {
|
|
139
|
-
routeId,
|
|
134
|
+
routeId: matchRouteId,
|
|
140
135
|
match: {
|
|
141
136
|
id: match.id,
|
|
142
137
|
status: match.status,
|
|
@@ -147,7 +142,7 @@ var MatchInner = Vue.defineComponent({
|
|
|
147
142
|
},
|
|
148
143
|
remountKey
|
|
149
144
|
};
|
|
150
|
-
}
|
|
145
|
+
});
|
|
151
146
|
const route = Vue.computed(() => {
|
|
152
147
|
if (!combinedState.value) return null;
|
|
153
148
|
return router.routesById[combinedState.value.routeId];
|
|
@@ -211,33 +206,32 @@ var Outlet = Vue.defineComponent({
|
|
|
211
206
|
name: "Outlet",
|
|
212
207
|
setup() {
|
|
213
208
|
const router = useRouter();
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
const
|
|
217
|
-
const route = Vue.computed(() => router.routesById[
|
|
218
|
-
const parentGlobalNotFound =
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
const matches = s.matches;
|
|
225
|
-
const child = matches[matches.findIndex((d) => d.id === safeMatchId.value) + 1];
|
|
209
|
+
const parentRouteId = Vue.inject(routeIdContext);
|
|
210
|
+
if (!parentRouteId) return () => null;
|
|
211
|
+
const parentMatch = useStore(router.stores.getMatchStoreByRouteId(parentRouteId), (v) => v);
|
|
212
|
+
const route = Vue.computed(() => parentMatch.value ? router.routesById[parentMatch.value.routeId] : void 0);
|
|
213
|
+
const parentGlobalNotFound = Vue.computed(() => parentMatch.value?.globalNotFound ?? false);
|
|
214
|
+
const childMatchIdMap = useStore(router.stores.childMatchIdByRouteId, (v) => v);
|
|
215
|
+
const childMatchData = Vue.computed(() => {
|
|
216
|
+
const childId = childMatchIdMap.value[parentRouteId];
|
|
217
|
+
if (!childId) return null;
|
|
218
|
+
const child = router.stores.activeMatchStoresById.get(childId)?.state;
|
|
226
219
|
if (!child) return null;
|
|
227
220
|
return {
|
|
228
221
|
id: child.id,
|
|
229
222
|
paramsKey: child.routeId + JSON.stringify(child._strictParams)
|
|
230
223
|
};
|
|
231
|
-
}
|
|
224
|
+
});
|
|
232
225
|
return () => {
|
|
233
|
-
if (parentGlobalNotFound.value)
|
|
226
|
+
if (parentGlobalNotFound.value) {
|
|
227
|
+
if (!route.value) return null;
|
|
228
|
+
return renderRouteNotFound(router, route.value, void 0);
|
|
229
|
+
}
|
|
234
230
|
if (!childMatchData.value) return null;
|
|
235
|
-
|
|
231
|
+
return Vue.h(Match, {
|
|
236
232
|
matchId: childMatchData.value.id,
|
|
237
233
|
key: childMatchData.value.paramsKey
|
|
238
234
|
});
|
|
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
235
|
};
|
|
242
236
|
}
|
|
243
237
|
});
|
package/dist/esm/Match.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Match.js","names":["Vue","invariant","warning","createControlledPromise","getLocationChangeInfo","isNotFound","isRedirect","rootRouteId","isServer","CatchBoundary","ErrorComponent","ClientOnly","useRouterState","useRouter","CatchNotFound","matchContext","renderRouteNotFound","ScrollRestoration","Match","defineComponent","name","props","matchId","type","String","required","setup","router","lastKnownRouteId","matchData","select","s","match","matches","find","d","id","matchIndex","findIndex","routeId","parentRouteId","loadedAt","ssr","_displayPending","value","route","computed","routesById","PendingComponent","options","pendingComponent","defaultPendingComponent","pendingElement","h","undefined","routeErrorComponent","errorComponent","defaultErrorComponent","routeOnCatch","onCatch","defaultOnCatch","routeNotFoundComponent","isRoot","notFoundComponent","notFoundRoute","component","hasShellComponent","shellComponent","ShellComponent","matchIdRef","ref","watch","propsMatchId","dataMatchId","immediate","provide","actualMatchId","resolvedNoSsr","shouldClientOnly","renderMatchContent","matchInner","MatchInner","content","fallback","default","error","children","getResetKey","withScrollRestoration","scrollRestoration","Fragment","OnRendered","filter","Boolean","length","location","resolvedLocation","state","key","watchEffect","emit","combinedState","sameRouteMatch","remountFn","remountDeps","defaultRemountDeps","remountKey","loaderDeps","params","_strictParams","search","_strictSearch","JSON","stringify","status","_forcePending","getMatch","_nonReactive","loadPromise","RouteErrorComponent","reset","invalidate","info","componentStack","pendingMinMs","defaultPendingMinMs","routerMatch","minPendingPromise","setTimeout","resolve","Comp","defaultComponent","Outlet","inject","safeMatchId","parentGlobalNotFound","parentMatch","globalNotFound","childMatchData","index","child","paramsKey","nextMatch","Suspense"],"sources":["../../src/Match.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport {\n createControlledPromise,\n getLocationChangeInfo,\n isNotFound,\n isRedirect,\n rootRouteId,\n} from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { ClientOnly } from './ClientOnly'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { CatchNotFound } from './not-found'\nimport { matchContext } from './matchContext'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { ScrollRestoration } from './scroll-restoration'\nimport type { VNode } from 'vue'\nimport type { AnyRoute, RootRouteOptions } from '@tanstack/router-core'\n\nexport const Match = Vue.defineComponent({\n name: 'Match',\n props: {\n matchId: {\n type: String,\n required: true,\n },\n },\n setup(props) {\n const router = useRouter()\n\n // Track the last known routeId to handle stale props during same-route transitions\n let lastKnownRouteId: string | null = null\n\n // Combined selector that returns all needed data including the actual matchId\n // This handles stale props.matchId during same-route transitions\n const matchData = useRouterState({\n select: (s) => {\n // First try to find match by props.matchId\n let match = s.matches.find((d) => d.id === props.matchId)\n let matchIndex = match\n ? s.matches.findIndex((d) => d.id === props.matchId)\n : -1\n\n // If match found, update lastKnownRouteId\n if (match) {\n lastKnownRouteId = match.routeId as string\n } else if (lastKnownRouteId) {\n // Match not found - props.matchId might be stale during a same-route transition\n // Try to find the NEW match by routeId\n match = s.matches.find((d) => d.routeId === lastKnownRouteId)\n matchIndex = match\n ? s.matches.findIndex((d) => d.routeId === lastKnownRouteId)\n : -1\n }\n\n if (!match) {\n return null\n }\n\n const routeId = match.routeId as string\n const parentRouteId =\n matchIndex > 0 ? (s.matches[matchIndex - 1]?.routeId as string) : null\n\n return {\n matchId: match.id, // Return the actual matchId (may differ from props.matchId)\n routeId,\n parentRouteId,\n loadedAt: s.loadedAt,\n ssr: match.ssr,\n _displayPending: match._displayPending,\n }\n },\n })\n\n invariant(\n matchData.value,\n `Could not find routeId for matchId \"${props.matchId}\". Please file an issue!`,\n )\n\n const route = Vue.computed(() =>\n matchData.value ? router.routesById[matchData.value.routeId] : null,\n )\n\n const PendingComponent = Vue.computed(\n () =>\n route.value?.options?.pendingComponent ??\n router?.options?.defaultPendingComponent,\n )\n\n const pendingElement = Vue.computed(() =>\n PendingComponent.value ? Vue.h(PendingComponent.value) : undefined,\n )\n\n const routeErrorComponent = Vue.computed(\n () =>\n route.value?.options?.errorComponent ??\n router?.options?.defaultErrorComponent,\n )\n\n const routeOnCatch = Vue.computed(\n () => route.value?.options?.onCatch ?? router?.options?.defaultOnCatch,\n )\n\n const routeNotFoundComponent = Vue.computed(() =>\n route.value?.isRoot\n ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n (route.value?.options?.notFoundComponent ??\n router?.options?.notFoundRoute?.options?.component)\n : route.value?.options?.notFoundComponent,\n )\n\n const hasShellComponent = Vue.computed(() => {\n if (!route.value?.isRoot) return false\n return !!(route.value.options as RootRouteOptions).shellComponent\n })\n\n const ShellComponent = Vue.computed(() =>\n hasShellComponent.value\n ? ((route.value!.options as RootRouteOptions).shellComponent as any)\n : null,\n )\n\n // Create a ref for the current matchId that we provide to child components\n // This ref is updated to the ACTUAL matchId found (which may differ from props during transitions)\n const matchIdRef = Vue.ref(matchData.value?.matchId ?? props.matchId)\n\n // Watch both props.matchId and matchData to keep matchIdRef in sync\n // This ensures Outlet gets the correct matchId even during transitions\n Vue.watch(\n [() => props.matchId, () => matchData.value?.matchId],\n ([propsMatchId, dataMatchId]) => {\n // Prefer the matchId from matchData (which handles fallback)\n // Fall back to props.matchId if matchData is null\n matchIdRef.value = dataMatchId ?? propsMatchId\n },\n { immediate: true },\n )\n\n // Provide the matchId to child components\n Vue.provide(matchContext, matchIdRef)\n\n return (): VNode => {\n // Use the actual matchId from matchData, not props (which may be stale)\n const actualMatchId = matchData.value?.matchId ?? props.matchId\n\n const resolvedNoSsr =\n matchData.value?.ssr === false || matchData.value?.ssr === 'data-only'\n const shouldClientOnly =\n resolvedNoSsr || !!matchData.value?._displayPending\n\n const renderMatchContent = (): VNode => {\n const matchInner = Vue.h(MatchInner, { matchId: actualMatchId })\n\n let content: VNode = shouldClientOnly\n ? Vue.h(\n ClientOnly,\n {\n fallback: pendingElement.value,\n },\n {\n default: () => matchInner,\n },\n )\n : matchInner\n\n // Wrap in NotFound boundary if needed\n if (routeNotFoundComponent.value) {\n content = Vue.h(CatchNotFound, {\n fallback: (error: any) => {\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.value ||\n (error.routeId && error.routeId !== matchData.value?.routeId) ||\n (!error.routeId && route.value && !route.value.isRoot)\n )\n throw error\n\n return Vue.h(routeNotFoundComponent.value, error)\n },\n children: content,\n })\n }\n\n // Wrap in error boundary if needed\n if (routeErrorComponent.value) {\n content = CatchBoundary({\n getResetKey: () => matchData.value?.loadedAt ?? 0,\n errorComponent: routeErrorComponent.value || ErrorComponent,\n onCatch: (error: Error) => {\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: ${actualMatchId}`)\n routeOnCatch.value?.(error)\n },\n children: content,\n })\n }\n\n // Add scroll restoration if needed\n const withScrollRestoration: Array<VNode> = [\n content,\n matchData.value?.parentRouteId === rootRouteId &&\n router.options.scrollRestoration\n ? Vue.h(Vue.Fragment, null, [\n Vue.h(OnRendered),\n Vue.h(ScrollRestoration),\n ])\n : null,\n ].filter(Boolean) as Array<VNode>\n\n // Return single child directly to avoid Fragment wrapper that causes hydration mismatch\n if (withScrollRestoration.length === 1) {\n return withScrollRestoration[0]!\n }\n\n return Vue.h(Vue.Fragment, null, withScrollRestoration)\n }\n\n if (!hasShellComponent.value) {\n return renderMatchContent()\n }\n\n return Vue.h(ShellComponent.value, null, {\n // Important: return a fresh VNode on each slot invocation so that shell\n // components can re-render without reusing a cached VNode instance.\n default: () => renderMatchContent(),\n })\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).\nconst OnRendered = Vue.defineComponent({\n name: 'OnRendered',\n setup() {\n const router = useRouter()\n\n const location = useRouterState({\n select: (s) => {\n return s.resolvedLocation?.state.key\n },\n })\n\n Vue.watchEffect(() => {\n if (location.value) {\n router.emit({\n type: 'onRendered',\n ...getLocationChangeInfo(router.state),\n })\n }\n })\n\n return () => null\n },\n})\n\nexport const MatchInner = Vue.defineComponent({\n name: 'MatchInner',\n props: {\n matchId: {\n type: String,\n required: true,\n },\n },\n setup(props) {\n const router = useRouter()\n\n // Track the last known routeId to handle stale props during same-route transitions\n // This is stored outside the selector so it persists across selector calls\n let lastKnownRouteId: string | null = null\n\n // Combined selector for match state AND remount key\n // This ensures both are computed in the same selector call with consistent data\n const combinedState = useRouterState({\n select: (s) => {\n // First try to find match by props.matchId\n let match = s.matches.find((d) => d.id === props.matchId)\n\n // If match found, update lastKnownRouteId\n if (match) {\n lastKnownRouteId = match.routeId as string\n } else if (lastKnownRouteId) {\n // Match not found - props.matchId might be stale during a same-route transition\n // (matchId changed due to loaderDepsHash but props haven't updated yet)\n // Try to find the NEW match by routeId and use that instead\n const sameRouteMatch = s.matches.find(\n (d) => d.routeId === lastKnownRouteId,\n )\n if (sameRouteMatch) {\n match = sameRouteMatch\n }\n }\n\n if (!match) {\n // Route no longer exists - truly navigating away\n return null\n }\n\n const routeId = match.routeId as string\n\n // Compute remount key\n const remountFn =\n (router.routesById[routeId] as AnyRoute).options.remountDeps ??\n router.options.defaultRemountDeps\n\n let remountKey: string | undefined\n if (remountFn) {\n const remountDeps = remountFn({\n routeId,\n loaderDeps: match.loaderDeps,\n params: match._strictParams,\n search: match._strictSearch,\n })\n remountKey = remountDeps ? JSON.stringify(remountDeps) : undefined\n }\n\n return {\n routeId,\n match: {\n id: match.id,\n status: match.status,\n error: match.error,\n ssr: match.ssr,\n _forcePending: match._forcePending,\n _displayPending: match._displayPending,\n },\n remountKey,\n }\n },\n })\n\n const route = Vue.computed(() => {\n if (!combinedState.value) return null\n return router.routesById[combinedState.value.routeId]!\n })\n\n const match = Vue.computed(() => combinedState.value?.match)\n const remountKey = Vue.computed(() => combinedState.value?.remountKey)\n\n return (): VNode | null => {\n // If match doesn't exist, return null (component is being unmounted or not ready)\n if (!combinedState.value || !match.value || !route.value) return null\n\n // Handle different match statuses\n if (match.value._displayPending) {\n const PendingComponent =\n route.value.options.pendingComponent ??\n router.options.defaultPendingComponent\n\n return PendingComponent ? Vue.h(PendingComponent) : null\n }\n\n if (match.value._forcePending) {\n const PendingComponent =\n route.value.options.pendingComponent ??\n router.options.defaultPendingComponent\n\n return PendingComponent ? Vue.h(PendingComponent) : null\n }\n\n if (match.value.status === 'notFound') {\n invariant(isNotFound(match.value.error), 'Expected a notFound error')\n return renderRouteNotFound(router, route.value, match.value.error)\n }\n\n if (match.value.status === 'redirected') {\n invariant(isRedirect(match.value.error), 'Expected a redirect error')\n throw router.getMatch(match.value.id)?._nonReactive.loadPromise\n }\n\n if (match.value.status === 'error') {\n // Check if this route or any parent has an error component\n const RouteErrorComponent =\n route.value.options.errorComponent ??\n router.options.defaultErrorComponent\n\n // If this route has an error component, render it directly\n // This is more reliable than relying on Vue's error boundary\n if (RouteErrorComponent) {\n return Vue.h(RouteErrorComponent, {\n error: match.value.error,\n reset: () => {\n router.invalidate()\n },\n info: {\n componentStack: '',\n },\n })\n }\n\n // If there's no error component for this route, throw the error\n // so it can bubble up to the nearest parent with an error component\n throw match.value.error\n }\n\n if (match.value.status === 'pending') {\n const pendingMinMs =\n route.value.options.pendingMinMs ?? router.options.defaultPendingMinMs\n\n const routerMatch = router.getMatch(match.value.id)\n if (\n pendingMinMs &&\n routerMatch &&\n !routerMatch._nonReactive.minPendingPromise\n ) {\n // Create a promise that will resolve after the minPendingMs\n if (!(isServer ?? router.isServer)) {\n const minPendingPromise = createControlledPromise<void>()\n\n routerMatch._nonReactive.minPendingPromise = minPendingPromise\n\n setTimeout(() => {\n minPendingPromise.resolve()\n // We've handled the minPendingPromise, so we can delete it\n routerMatch._nonReactive.minPendingPromise = undefined\n }, pendingMinMs)\n }\n }\n\n // In Vue, we render the pending component directly instead of throwing a promise\n // because Vue's Suspense doesn't catch thrown promises like React does\n const PendingComponent =\n route.value.options.pendingComponent ??\n router.options.defaultPendingComponent\n\n if (PendingComponent) {\n return Vue.h(PendingComponent)\n }\n\n // If no pending component, return null while loading\n return null\n }\n\n // Success status - render the component with remount key\n const Comp =\n route.value.options.component ?? router.options.defaultComponent\n const key = remountKey.value\n\n if (Comp) {\n // Pass key as a prop - Vue.h properly handles 'key' as a special prop\n return Vue.h(Comp, key !== undefined ? { key } : undefined)\n }\n\n return Vue.h(Outlet, key !== undefined ? { key } : undefined)\n }\n },\n})\n\nexport const Outlet = Vue.defineComponent({\n name: 'Outlet',\n setup() {\n const router = useRouter()\n const matchId = Vue.inject(matchContext)\n const safeMatchId = Vue.computed(() => matchId?.value || '')\n\n const routeId = useRouterState({\n select: (s) =>\n s.matches.find((d) => d.id === safeMatchId.value)?.routeId as string,\n })\n\n const route = Vue.computed(() => router.routesById[routeId.value]!)\n\n const parentGlobalNotFound = useRouterState({\n select: (s) => {\n const matches = s.matches\n const parentMatch = matches.find((d) => d.id === safeMatchId.value)\n\n // During navigation transitions, parent match can be temporarily removed\n // Return false to avoid errors - the component will handle this gracefully\n if (!parentMatch) {\n return false\n }\n\n return parentMatch.globalNotFound\n },\n })\n\n const childMatchData = useRouterState({\n select: (s) => {\n const matches = s.matches\n const index = matches.findIndex((d) => d.id === safeMatchId.value)\n const child = matches[index + 1]\n if (!child) return null\n return {\n id: child.id,\n // Key based on routeId + params only (not loaderDeps)\n // This ensures component recreates when params change,\n // but NOT when only loaderDeps change\n paramsKey: child.routeId + JSON.stringify(child._strictParams),\n }\n },\n })\n\n return (): VNode | null => {\n if (parentGlobalNotFound.value) {\n return renderRouteNotFound(router, route.value, undefined)\n }\n\n if (!childMatchData.value) {\n return null\n }\n\n const nextMatch = Vue.h(Match, {\n matchId: childMatchData.value.id,\n key: childMatchData.value.paramsKey,\n })\n\n if (safeMatchId.value === rootRouteId) {\n return Vue.h(\n Vue.Suspense,\n {\n fallback: router.options.defaultPendingComponent\n ? Vue.h(router.options.defaultPendingComponent)\n : null,\n },\n {\n default: () => nextMatch,\n },\n )\n }\n\n return nextMatch\n }\n },\n})\n"],"mappings":";;;;;;;;;;;;;;AAsBA,IAAakB,QAAQlB,IAAImB,gBAAgB;CACvCC,MAAM;CACNC,OAAO,EACLC,SAAS;EACPC,MAAMC;EACNC,UAAU;EACZ,EACD;CACDC,MAAML,OAAO;EACX,MAAMM,SAASd,WAAW;EAG1B,IAAIe,mBAAkC;EAItC,MAAMC,YAAYjB,eAAe,EAC/BkB,SAASC,MAAM;GAEb,IAAIC,QAAQD,EAAEE,QAAQC,MAAMC,MAAMA,EAAEC,OAAOf,MAAMC,QAAQ;GACzD,IAAIe,aAAaL,QACbD,EAAEE,QAAQK,WAAWH,MAAMA,EAAEC,OAAOf,MAAMC,QAAQ,GAClD;AAGJ,OAAIU,MACFJ,oBAAmBI,MAAMO;YAChBX,kBAAkB;AAG3BI,YAAQD,EAAEE,QAAQC,MAAMC,MAAMA,EAAEI,YAAYX,iBAAiB;AAC7DS,iBAAaL,QACTD,EAAEE,QAAQK,WAAWH,MAAMA,EAAEI,YAAYX,iBAAiB,GAC1D;;AAGN,OAAI,CAACI,MACH,QAAO;GAGT,MAAMO,UAAUP,MAAMO;GACtB,MAAMC,gBACJH,aAAa,IAAKN,EAAEE,QAAQI,aAAa,IAAIE,UAAqB;AAEpE,UAAO;IACLjB,SAASU,MAAMI;IACfG;IACAC;IACAC,UAAUV,EAAEU;IACZC,KAAKV,MAAMU;IACXC,iB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AACoF,eAAe9F,MAClB,QAAO;GAGT,MAAMkG,YAAY9I,IAAIqD,EAAEnC,OAAO;IAC7BI,SAASoH,eAAe9F,MAAMR;IAC9B8D,KAAKwC,eAAe9F,MAAMiG;IAC3B,CAAC;AAEF,OAAIP,YAAY1F,UAAUrC,YACxB,QAAOP,IAAIqD,EACTrD,IAAI+I,UACJ,EACE5D,UAAUxD,OAAOsB,QAAQE,0BACrBnD,IAAIqD,EAAE1B,OAAOsB,QAAQE,wBAAwB,GAC7C,MACL,EACD,EACEiC,eAAe0D,WAEnB,CAAC;AAGH,UAAOA;;;CAGZ,CAAC"}
|
|
1
|
+
{"version":3,"file":"Match.js","names":["Vue","invariant","warning","createControlledPromise","getLocationChangeInfo","isNotFound","isRedirect","rootRouteId","isServer","useStore","CatchBoundary","ErrorComponent","ClientOnly","useRouter","CatchNotFound","matchContext","pendingMatchContext","routeIdContext","renderRouteNotFound","ScrollRestoration","Match","defineComponent","name","props","matchId","type","String","required","setup","router","routeId","stores","activeMatchStoresById","get","isChildOfRoot","routesById","parentRoute","id","activeMatch","getMatchStoreByRouteId","value","isPendingMatchRef","pendingRouteIds","Boolean","equal","Object","is","loadedAt","matchData","computed","match","ssr","_displayPending","route","PendingComponent","options","pendingComponent","defaultPendingComponent","pendingElement","h","undefined","routeErrorComponent","errorComponent","defaultErrorComponent","routeOnCatch","onCatch","defaultOnCatch","routeNotFoundComponent","isRoot","notFoundComponent","notFoundRoute","component","hasShellComponent","shellComponent","ShellComponent","provide","matchIdRef","actualMatchId","resolvedNoSsr","shouldClientOnly","renderMatchContent","matchInner","MatchInner","content","fallback","default","error","children","getResetKey","withScrollRestoration","scrollRestoration","Fragment","OnRendered","filter","length","location","resolvedLocation","state","__TSR_key","prevHref","watch","currentHref","latestLocation","href","emit","immediate","inject","combinedState","matchRouteId","remountFn","remountDeps","defaultRemountDeps","remountKey","loaderDeps","params","_strictParams","search","_strictSearch","JSON","stringify","status","_forcePending","getMatch","_nonReactive","loadPromise","RouteErrorComponent","reset","invalidate","info","componentStack","pendingMinMs","defaultPendingMinMs","routerMatch","minPendingPromise","setTimeout","resolve","Comp","defaultComponent","key","Outlet","parentRouteId","parentMatch","v","parentGlobalNotFound","globalNotFound","childMatchIdMap","childMatchIdByRouteId","childMatchData","childId","child","paramsKey","nextMatch"],"sources":["../../src/Match.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport {\n createControlledPromise,\n getLocationChangeInfo,\n isNotFound,\n isRedirect,\n rootRouteId,\n} from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { useStore } from '@tanstack/vue-store'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { ClientOnly } from './ClientOnly'\nimport { useRouter } from './useRouter'\nimport { CatchNotFound } from './not-found'\nimport {\n matchContext,\n pendingMatchContext,\n routeIdContext,\n} from './matchContext'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { ScrollRestoration } from './scroll-restoration'\nimport type { VNode } from 'vue'\nimport type { AnyRoute, RootRouteOptions } from '@tanstack/router-core'\n\nexport const Match = Vue.defineComponent({\n name: 'Match',\n props: {\n matchId: {\n type: String,\n required: true,\n },\n },\n setup(props) {\n const router = useRouter()\n\n // Derive routeId from initial props.matchId — stable for this component's\n // lifetime. The routeId never changes for a given route position in the\n // tree, even when matchId changes (loaderDepsHash, etc).\n const routeId = router.stores.activeMatchStoresById.get(\n props.matchId,\n )?.routeId\n\n invariant(\n routeId,\n `Could not find routeId for matchId \"${props.matchId}\". Please file an issue!`,\n )\n\n // Static route-tree check: is this route a direct child of the root?\n // parentRoute is set at build time, so no reactive tracking needed.\n const isChildOfRoot =\n (router.routesById[routeId] as AnyRoute)?.parentRoute?.id === rootRouteId\n\n // Single stable store subscription — getMatchStoreByRouteId returns a\n // cached computed store that resolves routeId → current match state\n // through the signal graph. No bridge needed.\n const activeMatch = useStore(\n router.stores.getMatchStoreByRouteId(routeId),\n (value) => value,\n )\n const isPendingMatchRef = useStore(\n router.stores.pendingRouteIds,\n (pendingRouteIds) => Boolean(pendingRouteIds[routeId]),\n { equal: Object.is },\n )\n const loadedAt = useStore(router.stores.loadedAt, (value) => value)\n\n const matchData = Vue.computed(() => {\n const match = activeMatch.value\n if (!match) {\n return null\n }\n\n return {\n matchId: match.id,\n routeId,\n loadedAt: loadedAt.value,\n ssr: match.ssr,\n _displayPending: match._displayPending,\n }\n })\n\n const route = Vue.computed(() =>\n matchData.value ? router.routesById[matchData.value.routeId] : null,\n )\n\n const PendingComponent = Vue.computed(\n () =>\n route.value?.options?.pendingComponent ??\n router?.options?.defaultPendingComponent,\n )\n\n const pendingElement = Vue.computed(() =>\n PendingComponent.value ? Vue.h(PendingComponent.value) : undefined,\n )\n\n const routeErrorComponent = Vue.computed(\n () =>\n route.value?.options?.errorComponent ??\n router?.options?.defaultErrorComponent,\n )\n\n const routeOnCatch = Vue.computed(\n () => route.value?.options?.onCatch ?? router?.options?.defaultOnCatch,\n )\n\n const routeNotFoundComponent = Vue.computed(() =>\n route.value?.isRoot\n ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n (route.value?.options?.notFoundComponent ??\n router?.options?.notFoundRoute?.options?.component)\n : route.value?.options?.notFoundComponent,\n )\n\n const hasShellComponent = Vue.computed(() => {\n if (!route.value?.isRoot) return false\n return !!(route.value.options as RootRouteOptions).shellComponent\n })\n\n const ShellComponent = Vue.computed(() =>\n hasShellComponent.value\n ? ((route.value!.options as RootRouteOptions).shellComponent as any)\n : null,\n )\n\n // Provide routeId context (stable string) for children.\n // MatchInner, Outlet, and useMatch all consume this.\n Vue.provide(routeIdContext, routeId)\n\n // Provide reactive nearest-match context for hooks that slice the active\n // matches array relative to the current match.\n const matchIdRef = Vue.computed(\n () => activeMatch.value?.id ?? props.matchId,\n )\n Vue.provide(matchContext, matchIdRef)\n\n Vue.provide(pendingMatchContext, isPendingMatchRef)\n\n return (): VNode => {\n const actualMatchId = matchData.value?.matchId ?? props.matchId\n\n const resolvedNoSsr =\n matchData.value?.ssr === false || matchData.value?.ssr === 'data-only'\n const shouldClientOnly =\n resolvedNoSsr || !!matchData.value?._displayPending\n\n const renderMatchContent = (): VNode => {\n const matchInner = Vue.h(MatchInner, { matchId: actualMatchId })\n\n let content: VNode = shouldClientOnly\n ? Vue.h(\n ClientOnly,\n {\n fallback: pendingElement.value,\n },\n {\n default: () => matchInner,\n },\n )\n : matchInner\n\n // Wrap in NotFound boundary if needed\n if (routeNotFoundComponent.value) {\n content = Vue.h(CatchNotFound, {\n fallback: (error: any) => {\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.value ||\n (error.routeId && error.routeId !== matchData.value?.routeId) ||\n (!error.routeId && route.value && !route.value.isRoot)\n )\n throw error\n\n return Vue.h(routeNotFoundComponent.value, error)\n },\n children: content,\n })\n }\n\n // Wrap in error boundary if needed\n if (routeErrorComponent.value) {\n content = CatchBoundary({\n getResetKey: () => matchData.value?.loadedAt ?? 0,\n errorComponent: routeErrorComponent.value || ErrorComponent,\n onCatch: (error: Error) => {\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: ${actualMatchId}`)\n routeOnCatch.value?.(error)\n },\n children: content,\n })\n }\n\n // Add scroll restoration if needed\n const withScrollRestoration: Array<VNode> = [\n content,\n isChildOfRoot && router.options.scrollRestoration\n ? Vue.h(Vue.Fragment, null, [\n Vue.h(OnRendered),\n Vue.h(ScrollRestoration),\n ])\n : null,\n ].filter(Boolean) as Array<VNode>\n\n // Return single child directly to avoid Fragment wrapper that causes hydration mismatch\n if (withScrollRestoration.length === 1) {\n return withScrollRestoration[0]!\n }\n\n return Vue.h(Vue.Fragment, null, withScrollRestoration)\n }\n\n if (!hasShellComponent.value) {\n return renderMatchContent()\n }\n\n return Vue.h(ShellComponent.value, null, {\n // Important: return a fresh VNode on each slot invocation so that shell\n // components can re-render without reusing a cached VNode instance.\n default: () => renderMatchContent(),\n })\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.__TSR_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).\nconst OnRendered = Vue.defineComponent({\n name: 'OnRendered',\n setup() {\n const router = useRouter()\n\n const location = useStore(\n router.stores.resolvedLocation,\n (resolvedLocation) => resolvedLocation?.state.__TSR_key,\n )\n\n let prevHref: string | undefined\n\n Vue.watch(\n location,\n () => {\n if (location.value) {\n const currentHref = router.latestLocation.href\n if (prevHref === undefined || prevHref !== currentHref) {\n router.emit({\n type: 'onRendered',\n ...getLocationChangeInfo(\n router.stores.location.state,\n router.stores.resolvedLocation.state,\n ),\n })\n prevHref = currentHref\n }\n }\n },\n { immediate: true },\n )\n\n return () => null\n },\n})\n\nexport const MatchInner = Vue.defineComponent({\n name: 'MatchInner',\n props: {\n matchId: {\n type: String,\n required: true,\n },\n },\n setup(props) {\n const router = useRouter()\n\n // Use routeId from context (provided by parent Match) — stable string.\n const routeId = Vue.inject(routeIdContext)!\n const activeMatch = useStore(\n router.stores.getMatchStoreByRouteId(routeId),\n (value) => value,\n )\n\n // Combined selector for match state AND remount key\n // This ensures both are computed in the same selector call with consistent data\n const combinedState = Vue.computed(() => {\n const match = activeMatch.value\n if (!match) {\n // Route no longer exists - truly navigating away\n return null\n }\n\n const matchRouteId = match.routeId as string\n\n // Compute remount key\n const remountFn =\n (router.routesById[matchRouteId] as AnyRoute).options.remountDeps ??\n router.options.defaultRemountDeps\n\n let remountKey: string | undefined\n if (remountFn) {\n const remountDeps = remountFn({\n routeId: matchRouteId,\n loaderDeps: match.loaderDeps,\n params: match._strictParams,\n search: match._strictSearch,\n })\n remountKey = remountDeps ? JSON.stringify(remountDeps) : undefined\n }\n\n return {\n routeId: matchRouteId,\n match: {\n id: match.id,\n status: match.status,\n error: match.error,\n ssr: match.ssr,\n _forcePending: match._forcePending,\n _displayPending: match._displayPending,\n },\n remountKey,\n }\n })\n\n const route = Vue.computed(() => {\n if (!combinedState.value) return null\n return router.routesById[combinedState.value.routeId]!\n })\n\n const match = Vue.computed(() => combinedState.value?.match)\n const remountKey = Vue.computed(() => combinedState.value?.remountKey)\n\n return (): VNode | null => {\n // If match doesn't exist, return null (component is being unmounted or not ready)\n if (!combinedState.value || !match.value || !route.value) return null\n\n // Handle different match statuses\n if (match.value._displayPending) {\n const PendingComponent =\n route.value.options.pendingComponent ??\n router.options.defaultPendingComponent\n\n return PendingComponent ? Vue.h(PendingComponent) : null\n }\n\n if (match.value._forcePending) {\n const PendingComponent =\n route.value.options.pendingComponent ??\n router.options.defaultPendingComponent\n\n return PendingComponent ? Vue.h(PendingComponent) : null\n }\n\n if (match.value.status === 'notFound') {\n invariant(isNotFound(match.value.error), 'Expected a notFound error')\n return renderRouteNotFound(router, route.value, match.value.error)\n }\n\n if (match.value.status === 'redirected') {\n invariant(isRedirect(match.value.error), 'Expected a redirect error')\n throw router.getMatch(match.value.id)?._nonReactive.loadPromise\n }\n\n if (match.value.status === 'error') {\n // Check if this route or any parent has an error component\n const RouteErrorComponent =\n route.value.options.errorComponent ??\n router.options.defaultErrorComponent\n\n // If this route has an error component, render it directly\n // This is more reliable than relying on Vue's error boundary\n if (RouteErrorComponent) {\n return Vue.h(RouteErrorComponent, {\n error: match.value.error,\n reset: () => {\n router.invalidate()\n },\n info: {\n componentStack: '',\n },\n })\n }\n\n // If there's no error component for this route, throw the error\n // so it can bubble up to the nearest parent with an error component\n throw match.value.error\n }\n\n if (match.value.status === 'pending') {\n const pendingMinMs =\n route.value.options.pendingMinMs ?? router.options.defaultPendingMinMs\n\n const routerMatch = router.getMatch(match.value.id)\n if (\n pendingMinMs &&\n routerMatch &&\n !routerMatch._nonReactive.minPendingPromise\n ) {\n // Create a promise that will resolve after the minPendingMs\n if (!(isServer ?? router.isServer)) {\n const minPendingPromise = createControlledPromise<void>()\n\n routerMatch._nonReactive.minPendingPromise = minPendingPromise\n\n setTimeout(() => {\n minPendingPromise.resolve()\n // We've handled the minPendingPromise, so we can delete it\n routerMatch._nonReactive.minPendingPromise = undefined\n }, pendingMinMs)\n }\n }\n\n // In Vue, we render the pending component directly instead of throwing a promise\n // because Vue's Suspense doesn't catch thrown promises like React does\n const PendingComponent =\n route.value.options.pendingComponent ??\n router.options.defaultPendingComponent\n\n if (PendingComponent) {\n return Vue.h(PendingComponent)\n }\n\n // If no pending component, return null while loading\n return null\n }\n\n // Success status - render the component with remount key\n const Comp =\n route.value.options.component ?? router.options.defaultComponent\n const key = remountKey.value\n\n if (Comp) {\n // Pass key as a prop - Vue.h properly handles 'key' as a special prop\n return Vue.h(Comp, key !== undefined ? { key } : undefined)\n }\n\n return Vue.h(Outlet, key !== undefined ? { key } : undefined)\n }\n },\n})\n\nexport const Outlet = Vue.defineComponent({\n name: 'Outlet',\n setup() {\n const router = useRouter()\n const parentRouteId = Vue.inject(routeIdContext)\n\n if (!parentRouteId) {\n return (): VNode | null => null\n }\n\n // Parent state via stable routeId store — single subscription\n const parentMatch = useStore(\n router.stores.getMatchStoreByRouteId(parentRouteId),\n (v) => v,\n )\n\n const route = Vue.computed(() =>\n parentMatch.value\n ? router.routesById[parentMatch.value.routeId as string]!\n : undefined,\n )\n\n const parentGlobalNotFound = Vue.computed(\n () => parentMatch.value?.globalNotFound ?? false,\n )\n\n // Child match lookup: read the child matchId from the shared derived\n // map (one reactive node for the whole tree), then grab match state\n // directly from the pool.\n const childMatchIdMap = useStore(\n router.stores.childMatchIdByRouteId,\n (v) => v,\n )\n\n const childMatchData = Vue.computed(() => {\n const childId = childMatchIdMap.value[parentRouteId]\n if (!childId) return null\n const child = router.stores.activeMatchStoresById.get(childId)?.state\n if (!child) return null\n\n return {\n id: child.id,\n // Key based on routeId + params only (not loaderDeps)\n // This ensures component recreates when params change,\n // but NOT when only loaderDeps change\n paramsKey: child.routeId + JSON.stringify(child._strictParams),\n }\n })\n\n return (): VNode | null => {\n if (parentGlobalNotFound.value) {\n if (!route.value) {\n return null\n }\n return renderRouteNotFound(router, route.value, undefined)\n }\n\n if (!childMatchData.value) {\n return null\n }\n\n const nextMatch = Vue.h(Match, {\n matchId: childMatchData.value.id,\n key: childMatchData.value.paramsKey,\n })\n\n // Note: We intentionally do NOT wrap in Suspense here.\n // The top-level Suspense in Matches already covers the root.\n // The old code compared matchId (e.g. \"__root__/\") with rootRouteId (\"__root__\")\n // which never matched, so this Suspense was effectively dead code.\n // With routeId-based lookup, parentRouteId === rootRouteId would match,\n // causing a double-Suspense that corrupts Vue's DOM during updates.\n return nextMatch\n }\n },\n})\n"],"mappings":";;;;;;;;;;;;;;AA0BA,IAAaoB,QAAQpB,IAAIqB,gBAAgB;CACvCC,MAAM;CACNC,OAAO,EACLC,SAAS;EACPC,MAAMC;EACNC,UAAU;EACZ,EACD;CACDC,MAAML,OAAO;EACX,MAAMM,SAAShB,WAAW;EAK1B,MAAMiB,UAAUD,OAAOE,OAAOC,sBAAsBC,IAClDV,MAAMC,QACP,EAAEM;AAEH7B,YACE6B,SACA,uCAAuCP,MAAMC,QAAO,0BACrD;EAID,MAAMU,gBACHL,OAAOM,WAAWL,UAAuBM,aAAaC,OAAO9B;EAKhE,MAAM+B,cAAc7B,SAClBoB,OAAOE,OAAOQ,uBAAuBT,QAAQ,GAC5CU,UAAUA,MACZ;EACD,MAAMC,oBAAoBhC,SACxBoB,OAAOE,OAAOW,kBACbA,oBAAoBC,QAAQD,gBAAgBZ,SAAS,EACtD,EAAEc,OAAOC,OAAOC,IAClB,CAAC;EACD,MAAMC,WAAWtC,SAASoB,OAAOE,OAAOgB,WAAWP,UAAUA,MAAM;EAEnE,MAAMQ,YAAYhD,IAAIiD,eAAe;GACnC,MAAMC,QAAQZ,YAAYE;AAC1B,OAAI,CAACU,MACH,QAAO;AAGT,UAAO;IACL1B,SAAS0B,MAAMb;IACfP;IACAiB,UAAUA,SAASP;IACnB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Ae3G,MAAMH;IAC9BqG,KAAKS,eAAe3G,MAAM8G;IAC3B,CAAC;;;CAWP,CAAC"}
|
package/dist/esm/Matches.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CatchBoundary } from "./CatchBoundary.js";
|
|
2
2
|
import { useRouter } from "./useRouter.js";
|
|
3
|
-
import { useRouterState } from "./useRouterState.js";
|
|
4
|
-
import { useTransitionerSetup } from "./Transitioner.js";
|
|
5
3
|
import { matchContext } from "./matchContext.js";
|
|
6
4
|
import { Match } from "./Match.js";
|
|
5
|
+
import { useTransitionerSetup } from "./Transitioner.js";
|
|
7
6
|
import * as Vue from "vue";
|
|
8
7
|
import warning from "tiny-warning";
|
|
9
8
|
import { isServer } from "@tanstack/router-core/isServer";
|
|
9
|
+
import { useStore } from "@tanstack/vue-store";
|
|
10
10
|
//#region src/Matches.tsx
|
|
11
11
|
var MatchesContent = Vue.defineComponent({
|
|
12
12
|
name: "MatchesContent",
|
|
@@ -37,10 +37,8 @@ var MatchesInner = Vue.defineComponent({
|
|
|
37
37
|
name: "MatchesInner",
|
|
38
38
|
setup() {
|
|
39
39
|
const router = useRouter();
|
|
40
|
-
const matchId =
|
|
41
|
-
|
|
42
|
-
} });
|
|
43
|
-
const resetKey = useRouterState({ select: (s) => s.loadedAt });
|
|
40
|
+
const matchId = useStore(router.stores.firstMatchId, (id) => id);
|
|
41
|
+
const resetKey = useStore(router.stores.loadedAt, (loadedAt) => loadedAt);
|
|
44
42
|
const matchIdRef = Vue.computed(() => matchId.value);
|
|
45
43
|
Vue.provide(matchContext, matchIdRef);
|
|
46
44
|
return () => {
|
|
@@ -60,11 +58,7 @@ var MatchesInner = Vue.defineComponent({
|
|
|
60
58
|
});
|
|
61
59
|
function useMatchRoute() {
|
|
62
60
|
const router = useRouter();
|
|
63
|
-
const routerState =
|
|
64
|
-
locationHref: s.location.href,
|
|
65
|
-
resolvedLocationHref: s.resolvedLocation?.href,
|
|
66
|
-
status: s.status
|
|
67
|
-
}) });
|
|
61
|
+
const routerState = useStore(router.stores.matchRouteReactivity, (value) => value);
|
|
68
62
|
return (opts) => {
|
|
69
63
|
const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts;
|
|
70
64
|
return Vue.computed(() => {
|
|
@@ -107,7 +101,7 @@ var MatchRoute = Vue.defineComponent({
|
|
|
107
101
|
}
|
|
108
102
|
},
|
|
109
103
|
setup(props, { slots }) {
|
|
110
|
-
const status =
|
|
104
|
+
const status = useStore(useRouter().stores.matchRouteReactivity, (value) => value.status);
|
|
111
105
|
return () => {
|
|
112
106
|
if (!status.value) return null;
|
|
113
107
|
const params = useMatchRoute()(props).value;
|
|
@@ -118,10 +112,9 @@ var MatchRoute = Vue.defineComponent({
|
|
|
118
112
|
}
|
|
119
113
|
});
|
|
120
114
|
function useMatches(opts) {
|
|
121
|
-
return
|
|
122
|
-
const matches = state?.matches || [];
|
|
115
|
+
return useStore(useRouter().stores.activeMatchesSnapshot, (matches) => {
|
|
123
116
|
return opts?.select ? opts.select(matches) : matches;
|
|
124
|
-
}
|
|
117
|
+
});
|
|
125
118
|
}
|
|
126
119
|
function useParentMatches(opts) {
|
|
127
120
|
const contextMatchId = Vue.inject(matchContext);
|
package/dist/esm/Matches.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Matches.js","names":["Vue","warning","isServer","CatchBoundary","useRouterState","useRouter","useTransitionerSetup","matchContext","Match","MatchesContent","defineComponent","name","setup","h","MatchesInner","Matches","router","pendingElement","options","defaultPendingComponent","inner","document","ssr","Suspense","fallback","default","InnerWrap","errorComponentFn","props","class","error","message","String","onClick","reset","matchId","select","s","matches","id","resetKey","loadedAt","matchIdRef","computed","value","provide","childElement","disableGlobalCatchBoundary","getResetKey","errorComponent","onCatch","process","env","NODE_ENV","toString","undefined","children","useMatchRoute","routerState","locationHref","location","href","resolvedLocationHref","resolvedLocation","status","opts","pending","caseSensitive","fuzzy","includeSearch","rest","matchRoute","MatchRoute","from","type","required","to","Boolean","slots","params","Fragment","useMatches","state","useParentMatches","contextMatchId","inject","safeMatchId","slice","findIndex","d","useChildMatches"],"sources":["../../src/Matches.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport warning from 'tiny-warning'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { CatchBoundary } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { useTransitionerSetup } from './Transitioner'\nimport { matchContext } from './matchContext'\nimport { Match } from './Match'\nimport type {\n AnyRouter,\n DeepPartial,\n ErrorComponentProps,\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\n// Define a type for the error component function\ntype ErrorRouteComponentType = (props: ErrorComponentProps) => Vue.VNode\n\ndeclare module '@tanstack/router-core' {\n export interface RouteMatchExtensions {\n meta?: Array<Vue.ComponentOptions['meta'] | undefined>\n links?: Array<Vue.ComponentOptions['link'] | undefined>\n scripts?: Array<Vue.ComponentOptions['script'] | undefined>\n headScripts?: Array<Vue.ComponentOptions['script'] | undefined>\n }\n}\n\n// Create a component that renders MatchesInner with Transitioner's setup logic inlined.\n// This is critical for proper hydration - we call useTransitionerSetup() as a composable\n// rather than rendering it as a component, which avoids Fragment/element mismatches.\nconst MatchesContent = Vue.defineComponent({\n name: 'MatchesContent',\n setup() {\n // IMPORTANT: We need to ensure Transitioner's setup() runs.\n // Transitioner sets up critical functionality:\n // - router.startTransition\n // - History subscription via router.history.subscribe(router.load)\n // - Watchers for router events\n //\n // We inline Transitioner's setup logic here. Since Transitioner returns null,\n // we can call its setup function directly without affecting the render tree.\n // This is done by importing and calling useTransitionerSetup.\n useTransitionerSetup()\n\n return () => Vue.h(MatchesInner)\n },\n})\n\nexport const Matches = Vue.defineComponent({\n name: 'Matches',\n setup() {\n const router = useRouter()\n\n return () => {\n const pendingElement = router?.options?.defaultPendingComponent\n ? Vue.h(router.options.defaultPendingComponent)\n : null\n\n // Do not render a root Suspense during SSR or hydrating from SSR\n const inner =\n (isServer ?? router?.isServer ?? false) ||\n (typeof document !== 'undefined' && router?.ssr)\n ? Vue.h(MatchesContent)\n : Vue.h(\n Vue.Suspense,\n { fallback: pendingElement },\n {\n default: () => Vue.h(MatchesContent),\n },\n )\n\n return router?.options?.InnerWrap\n ? Vue.h(router.options.InnerWrap, null, { default: () => inner })\n : inner\n }\n },\n})\n\n// Create a simple error component function that matches ErrorRouteComponent\nconst errorComponentFn: ErrorRouteComponentType = (\n props: ErrorComponentProps,\n) => {\n return Vue.h('div', { class: 'error' }, [\n Vue.h('h1', null, 'Error'),\n Vue.h('p', null, props.error.message || String(props.error)),\n Vue.h('button', { onClick: props.reset }, 'Try Again'),\n ])\n}\n\nconst MatchesInner = Vue.defineComponent({\n name: 'MatchesInner',\n setup() {\n const router = useRouter()\n\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 // Create a ref for the match id to provide\n const matchIdRef = Vue.computed(() => matchId.value)\n\n // Provide the matchId for child components using the InjectionKey\n Vue.provide(matchContext, matchIdRef)\n\n return () => {\n // Generate a placeholder element if matchId.value is not present\n const childElement = matchId.value\n ? Vue.h(Match, { matchId: matchId.value })\n : Vue.h('div')\n\n // If disableGlobalCatchBoundary is true, don't wrap in CatchBoundary\n if (router.options.disableGlobalCatchBoundary) {\n return childElement\n }\n\n return Vue.h(CatchBoundary, {\n getResetKey: () => resetKey.value,\n errorComponent: errorComponentFn,\n onCatch:\n process.env.NODE_ENV !== 'production'\n ? (error: 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 : undefined,\n children: childElement,\n })\n }\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 // Track state changes to trigger re-computation\n // Use multiple state values like React does for complete reactivity\n const routerState = useRouterState({\n select: (s) => ({\n locationHref: s.location.href,\n resolvedLocationHref: s.resolvedLocation?.href,\n status: s.status,\n }),\n })\n\n return <\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 ): Vue.Ref<\n false | ResolveRoute<TRouter, TFrom, TTo>['types']['allParams']\n > => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n const matchRoute = Vue.computed(() => {\n // Access routerState to establish dependency\n\n routerState.value\n return router.matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n })\n\n return matchRoute\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 ) => Vue.VNode)\n | Vue.VNode\n}\n\n// Create a type for the MatchRoute component that includes the generics\nexport interface MatchRouteComponentType {\n <\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n >(\n props: MakeMatchRouteOptions<TRouter, TFrom, TTo>,\n ): Vue.VNode\n new (): {\n $props: {\n from?: string\n to?: string\n fuzzy?: boolean\n caseSensitive?: boolean\n includeSearch?: boolean\n pending?: boolean\n }\n }\n}\n\nexport const MatchRoute = Vue.defineComponent({\n name: 'MatchRoute',\n props: {\n // Define props to match MakeMatchRouteOptions\n from: {\n type: String,\n required: false,\n },\n to: {\n type: String,\n required: false,\n },\n fuzzy: {\n type: Boolean,\n required: false,\n },\n caseSensitive: {\n type: Boolean,\n required: false,\n },\n includeSearch: {\n type: Boolean,\n required: false,\n },\n pending: {\n type: Boolean,\n required: false,\n },\n },\n setup(props, { slots }) {\n const status = useRouterState({\n select: (s) => s.status,\n })\n\n return () => {\n if (!status.value) return null\n\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any).value as boolean\n\n // Create a component that renders the slot in a reactive manner\n if (!params || !slots.default) {\n return null\n }\n\n // For function slots, pass the params\n if (typeof slots.default === 'function') {\n // Use h to create a wrapper component that will call the slot function\n return Vue.h(Vue.Fragment, null, slots.default(params))\n }\n\n // For normal slots, just render them\n return Vue.h(Vue.Fragment, null, slots.default)\n }\n },\n}) as unknown as MatchRouteComponentType\n\nexport interface UseMatchesBaseOptions<TRouter extends AnyRouter, TSelected> {\n select?: (matches: Array<MakeRouteMatchUnion<TRouter>>) => TSelected\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>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Vue.Ref<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 } as any) as Vue.Ref<UseMatchesResult<TRouter, TSelected>>\n}\n\nexport function useParentMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Vue.Ref<UseMatchesResult<TRouter, TSelected>> {\n // Use matchContext with proper type\n const contextMatchId = Vue.inject<Vue.Ref<string | undefined>>(matchContext)\n const safeMatchId = Vue.computed(() => contextMatchId?.value || '')\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n 0,\n matches.findIndex((d) => d.id === safeMatchId.value),\n )\n return opts?.select ? opts.select(matches) : matches\n },\n } as any)\n}\n\nexport function useChildMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Vue.Ref<UseMatchesResult<TRouter, TSelected>> {\n // Use matchContext with proper type\n const contextMatchId = Vue.inject<Vue.Ref<string | undefined>>(matchContext)\n const safeMatchId = Vue.computed(() => contextMatchId?.value || '')\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n matches.findIndex((d) => d.id === safeMatchId.value) + 1,\n )\n return opts?.select ? opts.select(matches) : matches\n },\n } as any)\n}\n"],"mappings":";;;;;;;;;;AA0CA,IAAMS,iBAAiBT,IAAIU,gBAAgB;CACzCC,MAAM;CACNC,QAAQ;AAUNN,wBAAsB;AAEtB,eAAaN,IAAIa,EAAEC,aAAa;;CAEnC,CAAC;AAEF,IAAaC,UAAUf,IAAIU,gBAAgB;CACzCC,MAAM;CACNC,QAAQ;EACN,MAAMI,SAASX,WAAW;AAE1B,eAAa;GACX,MAAMY,iBAAiBD,QAAQE,SAASC,0BACpCnB,IAAIa,EAAEG,OAAOE,QAAQC,wBAAwB,GAC7C;GAG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,QAAOzB,IAAIa,EAAEb,IAAIgF,UAAU,MAAMF,MAAMrD,QAAQsD,OAAO,CAAC;AAIzD,UAAO/E,IAAIa,EAAEb,IAAIgF,UAAU,MAAMF,MAAMrD,QAAQ;;;CAGpD,CAAuC;AAWxC,SAAgBwD,WAIdhB,MAC+C;AAC/C,QAAO7D,eAAe,EACpBgC,SAAS8C,UAA6C;EACpD,MAAM5C,UAAU4C,OAAO5C,WAAW,EAAE;AACpC,SAAO2B,MAAM7B,SACT6B,KAAK7B,OAAOE,QAA+C,GAC3DA;IAEA,CAAC;;AAGX,SAAgB6C,iBAIdlB,MAC+C;CAE/C,MAAMmB,iBAAiBpF,IAAIqF,OAAoC9E,aAAa;CAC5E,MAAM+E,cAActF,IAAI2C,eAAeyC,gBAAgBxC,SAAS,GAAG;AAEnE,QAAOqC,WAAW,EAChB7C,SAASE,YAAiD;AACxDA,YAAUA,QAAQiD,MAChB,GACAjD,QAAQkD,WAAWC,MAAMA,EAAElD,OAAO+C,YAAY1C,MAChD,CAAC;AACD,SAAOqB,MAAM7B,SAAS6B,KAAK7B,OAAOE,QAAQ,GAAGA;IAEzC,CAAC;;AAGX,SAAgBoD,gBAIdzB,MAC+C;CAE/C,MAAMmB,iBAAiBpF,IAAIqF,OAAoC9E,aAAa;CAC5E,MAAM+E,cAActF,IAAI2C,eAAeyC,gBAAgBxC,SAAS,GAAG;AAEnE,QAAOqC,WAAW,EAChB7C,SAASE,YAAiD;AACxDA,YAAUA,QAAQiD,MAChBjD,QAAQkD,WAAWC,MAAMA,EAAElD,OAAO+C,YAAY1C,MAAM,GAAG,EACxD;AACD,SAAOqB,MAAM7B,SAAS6B,KAAK7B,OAAOE,QAAQ,GAAGA;IAEzC,CAAC"}
|
|
1
|
+
{"version":3,"file":"Matches.js","names":["Vue","warning","isServer","useStore","CatchBoundary","useRouter","useTransitionerSetup","matchContext","Match","MatchesContent","defineComponent","name","setup","h","MatchesInner","Matches","router","pendingElement","options","defaultPendingComponent","inner","document","ssr","Suspense","fallback","default","InnerWrap","errorComponentFn","props","class","error","message","String","onClick","reset","matchId","stores","firstMatchId","id","resetKey","loadedAt","matchIdRef","computed","value","provide","childElement","disableGlobalCatchBoundary","getResetKey","errorComponent","onCatch","process","env","NODE_ENV","toString","undefined","children","useMatchRoute","routerState","matchRouteReactivity","opts","pending","caseSensitive","fuzzy","includeSearch","rest","matchRoute","MatchRoute","from","type","required","to","Boolean","slots","status","params","Fragment","useMatches","activeMatchesSnapshot","matches","select","useParentMatches","contextMatchId","inject","safeMatchId","slice","findIndex","d","useChildMatches"],"sources":["../../src/Matches.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport warning from 'tiny-warning'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { useStore } from '@tanstack/vue-store'\nimport { CatchBoundary } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport { useTransitionerSetup } from './Transitioner'\nimport { matchContext } from './matchContext'\nimport { Match } from './Match'\nimport type {\n AnyRouter,\n DeepPartial,\n ErrorComponentProps,\n MakeOptionalPathParams,\n MakeOptionalSearchParams,\n MakeRouteMatchUnion,\n MaskOptions,\n MatchRouteOptions,\n NoInfer,\n RegisteredRouter,\n ResolveRelativePath,\n ResolveRoute,\n RouteByPath,\n ToSubOptionsProps,\n} from '@tanstack/router-core'\n\n// Define a type for the error component function\ntype ErrorRouteComponentType = (props: ErrorComponentProps) => Vue.VNode\n\ndeclare module '@tanstack/router-core' {\n export interface RouteMatchExtensions {\n meta?: Array<Vue.ComponentOptions['meta'] | undefined>\n links?: Array<Vue.ComponentOptions['link'] | undefined>\n scripts?: Array<Vue.ComponentOptions['script'] | undefined>\n headScripts?: Array<Vue.ComponentOptions['script'] | undefined>\n }\n}\n\n// Create a component that renders MatchesInner with Transitioner's setup logic inlined.\n// This is critical for proper hydration - we call useTransitionerSetup() as a composable\n// rather than rendering it as a component, which avoids Fragment/element mismatches.\nconst MatchesContent = Vue.defineComponent({\n name: 'MatchesContent',\n setup() {\n // IMPORTANT: We need to ensure Transitioner's setup() runs.\n // Transitioner sets up critical functionality:\n // - router.startTransition\n // - History subscription via router.history.subscribe(router.load)\n // - Watchers for router events\n //\n // We inline Transitioner's setup logic here. Since Transitioner returns null,\n // we can call its setup function directly without affecting the render tree.\n // This is done by importing and calling useTransitionerSetup.\n useTransitionerSetup()\n\n return () => Vue.h(MatchesInner)\n },\n})\n\nexport const Matches = Vue.defineComponent({\n name: 'Matches',\n setup() {\n const router = useRouter()\n\n return () => {\n const pendingElement = router?.options?.defaultPendingComponent\n ? Vue.h(router.options.defaultPendingComponent)\n : null\n\n // Do not render a root Suspense during SSR or hydrating from SSR\n const inner =\n (isServer ?? router?.isServer ?? false) ||\n (typeof document !== 'undefined' && router?.ssr)\n ? Vue.h(MatchesContent)\n : Vue.h(\n Vue.Suspense,\n { fallback: pendingElement },\n {\n default: () => Vue.h(MatchesContent),\n },\n )\n\n return router?.options?.InnerWrap\n ? Vue.h(router.options.InnerWrap, null, { default: () => inner })\n : inner\n }\n },\n})\n\n// Create a simple error component function that matches ErrorRouteComponent\nconst errorComponentFn: ErrorRouteComponentType = (\n props: ErrorComponentProps,\n) => {\n return Vue.h('div', { class: 'error' }, [\n Vue.h('h1', null, 'Error'),\n Vue.h('p', null, props.error.message || String(props.error)),\n Vue.h('button', { onClick: props.reset }, 'Try Again'),\n ])\n}\n\nconst MatchesInner = Vue.defineComponent({\n name: 'MatchesInner',\n setup() {\n const router = useRouter()\n\n const matchId = useStore(router.stores.firstMatchId, (id) => id)\n const resetKey = useStore(router.stores.loadedAt, (loadedAt) => loadedAt)\n\n // Create a ref for the match id to provide\n const matchIdRef = Vue.computed(() => matchId.value)\n\n // Provide the matchId for child components using the InjectionKey\n Vue.provide(matchContext, matchIdRef)\n\n return () => {\n // Generate a placeholder element if matchId.value is not present\n const childElement = matchId.value\n ? Vue.h(Match, { matchId: matchId.value })\n : Vue.h('div')\n\n // If disableGlobalCatchBoundary is true, don't wrap in CatchBoundary\n if (router.options.disableGlobalCatchBoundary) {\n return childElement\n }\n\n return Vue.h(CatchBoundary, {\n getResetKey: () => resetKey.value,\n errorComponent: errorComponentFn,\n onCatch:\n process.env.NODE_ENV !== 'production'\n ? (error: 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 : undefined,\n children: childElement,\n })\n }\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 const routerState = useStore(\n router.stores.matchRouteReactivity,\n (value) => value,\n )\n\n return <\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 ): Vue.Ref<\n false | ResolveRoute<TRouter, TFrom, TTo>['types']['allParams']\n > => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n const matchRoute = Vue.computed(() => {\n // Access routerState to establish dependency\n\n routerState.value\n return router.matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n })\n\n return matchRoute\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 ) => Vue.VNode)\n | Vue.VNode\n}\n\n// Create a type for the MatchRoute component that includes the generics\nexport interface MatchRouteComponentType {\n <\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n >(\n props: MakeMatchRouteOptions<TRouter, TFrom, TTo>,\n ): Vue.VNode\n new (): {\n $props: {\n from?: string\n to?: string\n fuzzy?: boolean\n caseSensitive?: boolean\n includeSearch?: boolean\n pending?: boolean\n }\n }\n}\n\nexport const MatchRoute = Vue.defineComponent({\n name: 'MatchRoute',\n props: {\n // Define props to match MakeMatchRouteOptions\n from: {\n type: String,\n required: false,\n },\n to: {\n type: String,\n required: false,\n },\n fuzzy: {\n type: Boolean,\n required: false,\n },\n caseSensitive: {\n type: Boolean,\n required: false,\n },\n includeSearch: {\n type: Boolean,\n required: false,\n },\n pending: {\n type: Boolean,\n required: false,\n },\n },\n setup(props, { slots }) {\n const router = useRouter()\n const status = useStore(\n router.stores.matchRouteReactivity,\n (value) => value.status,\n )\n\n return () => {\n if (!status.value) return null\n\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any).value as boolean\n\n // Create a component that renders the slot in a reactive manner\n if (!params || !slots.default) {\n return null\n }\n\n // For function slots, pass the params\n if (typeof slots.default === 'function') {\n // Use h to create a wrapper component that will call the slot function\n return Vue.h(Vue.Fragment, null, slots.default(params))\n }\n\n // For normal slots, just render them\n return Vue.h(Vue.Fragment, null, slots.default)\n }\n },\n}) as unknown as MatchRouteComponentType\n\nexport interface UseMatchesBaseOptions<TRouter extends AnyRouter, TSelected> {\n select?: (matches: Array<MakeRouteMatchUnion<TRouter>>) => TSelected\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>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Vue.Ref<UseMatchesResult<TRouter, TSelected>> {\n const router = useRouter<TRouter>()\n return useStore(router.stores.activeMatchesSnapshot, (matches) => {\n return opts?.select\n ? opts.select(matches as Array<MakeRouteMatchUnion<TRouter>>)\n : (matches as any)\n })\n}\n\nexport function useParentMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Vue.Ref<UseMatchesResult<TRouter, TSelected>> {\n // Use matchContext with proper type\n const contextMatchId = Vue.inject<Vue.Ref<string | undefined>>(matchContext)\n const safeMatchId = Vue.computed(() => contextMatchId?.value || '')\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n 0,\n matches.findIndex((d) => d.id === safeMatchId.value),\n )\n return opts?.select ? opts.select(matches) : matches\n },\n } as any)\n}\n\nexport function useChildMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Vue.Ref<UseMatchesResult<TRouter, TSelected>> {\n // Use matchContext with proper type\n const contextMatchId = Vue.inject<Vue.Ref<string | undefined>>(matchContext)\n const safeMatchId = Vue.computed(() => contextMatchId?.value || '')\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n matches.findIndex((d) => d.id === safeMatchId.value) + 1,\n )\n return opts?.select ? opts.select(matches) : matches\n },\n } as any)\n}\n"],"mappings":";;;;;;;;;;AAyCA,IAAMS,iBAAiBT,IAAIU,gBAAgB;CACzCC,MAAM;CACNC,QAAQ;AAUNN,wBAAsB;AAEtB,eAAaN,IAAIa,EAAEC,aAAa;;CAEnC,CAAC;AAEF,IAAaC,UAAUf,IAAIU,gBAAgB;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IT,OAAI,OAAO+C,MAAM/C,YAAY,WAE3B,QAAOzB,IAAIa,EAAEb,IAAI2E,UAAU,MAAMH,MAAM/C,QAAQiD,OAAO,CAAC;AAIzD,UAAO1E,IAAIa,EAAEb,IAAI2E,UAAU,MAAMH,MAAM/C,QAAQ;;;CAGpD,CAAuC;AAWxC,SAAgBmD,WAIdjB,MAC+C;AAE/C,QAAOxD,SADQE,WAAoB,CACZ+B,OAAOyC,wBAAwBC,YAAY;AAChE,SAAOnB,MAAMoB,SACTpB,KAAKoB,OAAOD,QAA+C,GAC1DA;GACL;;AAGJ,SAAgBE,iBAIdrB,MAC+C;CAE/C,MAAMsB,iBAAiBjF,IAAIkF,OAAoC3E,aAAa;CAC5E,MAAM4E,cAAcnF,IAAI0C,eAAeuC,gBAAgBtC,SAAS,GAAG;AAEnE,QAAOiC,WAAW,EAChBG,SAASD,YAAiD;AACxDA,YAAUA,QAAQM,MAChB,GACAN,QAAQO,WAAWC,MAAMA,EAAEhD,OAAO6C,YAAYxC,MAChD,CAAC;AACD,SAAOgB,MAAMoB,SAASpB,KAAKoB,OAAOD,QAAQ,GAAGA;IAEzC,CAAC;;AAGX,SAAgBS,gBAId5B,MAC+C;CAE/C,MAAMsB,iBAAiBjF,IAAIkF,OAAoC3E,aAAa;CAC5E,MAAM4E,cAAcnF,IAAI0C,eAAeuC,gBAAgBtC,SAAS,GAAG;AAEnE,QAAOiC,WAAW,EAChBG,SAASD,YAAiD;AACxDA,YAAUA,QAAQM,MAChBN,QAAQO,WAAWC,MAAMA,EAAEhD,OAAO6C,YAAYxC,MAAM,GAAG,EACxD;AACD,SAAOgB,MAAMoB,SAASpB,KAAKoB,OAAOD,QAAQ,GAAGA;IAEzC,CAAC"}
|
package/dist/esm/Scripts.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { useRouter } from "./useRouter.js";
|
|
2
|
-
import { useRouterState } from "./useRouterState.js";
|
|
3
2
|
import { Asset } from "./Asset.js";
|
|
4
3
|
import * as Vue from "vue";
|
|
5
4
|
import { Fragment, createVNode, mergeProps } from "vue";
|
|
5
|
+
import { useStore } from "@tanstack/vue-store";
|
|
6
6
|
//#region src/Scripts.tsx
|
|
7
7
|
var Scripts = Vue.defineComponent({
|
|
8
8
|
name: "Scripts",
|
|
9
9
|
setup() {
|
|
10
10
|
const router = useRouter();
|
|
11
11
|
const nonce = router.options.ssr?.nonce;
|
|
12
|
-
const
|
|
12
|
+
const matches = useStore(router.stores.activeMatchesSnapshot, (value) => value);
|
|
13
|
+
const assetScripts = Vue.computed(() => {
|
|
13
14
|
const assetScripts = [];
|
|
14
15
|
const manifest = router.ssr?.manifest;
|
|
15
16
|
if (!manifest) return [];
|
|
16
|
-
|
|
17
|
+
matches.value.map((match) => router.looseRoutesById[match.routeId]).forEach((route) => manifest.routes[route.id]?.assets?.filter((d) => d.tag === "script").forEach((asset) => {
|
|
17
18
|
assetScripts.push({
|
|
18
19
|
tag: "script",
|
|
19
20
|
attrs: {
|
|
@@ -24,15 +25,15 @@ var Scripts = Vue.defineComponent({
|
|
|
24
25
|
});
|
|
25
26
|
}));
|
|
26
27
|
return assetScripts;
|
|
27
|
-
}
|
|
28
|
-
const scripts =
|
|
28
|
+
});
|
|
29
|
+
const scripts = Vue.computed(() => ({ scripts: matches.value.map((match) => match.scripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
|
|
29
30
|
tag: "script",
|
|
30
31
|
attrs: {
|
|
31
32
|
...script,
|
|
32
33
|
nonce
|
|
33
34
|
},
|
|
34
35
|
children
|
|
35
|
-
})) })
|
|
36
|
+
})) }));
|
|
36
37
|
const mounted = Vue.ref(false);
|
|
37
38
|
Vue.onMounted(() => {
|
|
38
39
|
mounted.value = true;
|
package/dist/esm/Scripts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scripts.js","names":["Vue","
|
|
1
|
+
{"version":3,"file":"Scripts.js","names":["Vue","useStore","Asset","useRouter","Scripts","defineComponent","name","setup","router","nonce","options","ssr","matches","stores","activeMatchesSnapshot","value","assetScripts","computed","manifest","map","match","looseRoutesById","routeId","forEach","route","routes","id","assets","filter","d","tag","asset","push","attrs","children","scripts","flat","Boolean","script","mounted","ref","onMounted","allScripts","serverSsr","serverBufferedScript","takeBufferedScripts","_createVNode","_Fragment","i","_mergeProps"],"sources":["../../src/Scripts.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport { useStore } from '@tanstack/vue-store'\nimport { Asset } from './Asset'\nimport { useRouter } from './useRouter'\nimport type { RouterManagedTag } from '@tanstack/router-core'\n\nexport const Scripts = Vue.defineComponent({\n name: 'Scripts',\n setup() {\n const router = useRouter()\n const nonce = router.options.ssr?.nonce\n const matches = useStore(\n router.stores.activeMatchesSnapshot,\n (value) => value,\n )\n\n const assetScripts = Vue.computed<Array<RouterManagedTag>>(() => {\n const assetScripts: Array<RouterManagedTag> = []\n const manifest = router.ssr?.manifest\n\n if (!manifest) {\n return []\n }\n\n matches.value\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, nonce },\n children: asset.children,\n } as RouterManagedTag)\n }),\n )\n\n return assetScripts\n })\n\n const scripts = Vue.computed(() => ({\n scripts: (\n matches.value\n .map((match) => match.scripts!)\n .flat(1)\n .filter(Boolean) as Array<RouterManagedTag>\n ).map(({ children, ...script }) => ({\n tag: 'script' as const,\n attrs: {\n ...script,\n nonce,\n },\n children,\n })),\n }))\n\n const mounted = Vue.ref(false)\n Vue.onMounted(() => {\n mounted.value = true\n })\n\n return () => {\n const allScripts: Array<RouterManagedTag> = []\n\n if (router.serverSsr) {\n const serverBufferedScript = router.serverSsr.takeBufferedScripts()\n if (serverBufferedScript) {\n allScripts.push(serverBufferedScript)\n }\n } else if (router.ssr && !mounted.value) {\n allScripts.push({\n tag: 'script',\n attrs: { nonce, 'data-allow-mismatch': true },\n children: '',\n } as RouterManagedTag)\n\n allScripts.push({\n tag: 'script',\n attrs: {\n nonce,\n id: '$tsr-stream-barrier',\n 'data-allow-mismatch': true,\n },\n children: '',\n } as RouterManagedTag)\n\n for (const asset of assetScripts.value) {\n allScripts.push({\n tag: 'script',\n attrs: {\n ...asset.attrs,\n 'data-allow-mismatch': true,\n },\n children: '',\n } as RouterManagedTag)\n }\n }\n\n for (const script of scripts.value.scripts) {\n allScripts.push(script as RouterManagedTag)\n }\n\n if (mounted.value || router.serverSsr) {\n for (const asset of assetScripts.value) {\n allScripts.push(asset)\n }\n }\n\n return (\n <>\n {allScripts.map((asset, i) => (\n <Asset {...asset} key={`tsr-scripts-${asset.tag}-${i}`} />\n ))}\n </>\n )\n }\n },\n})\n"],"mappings":";;;;;;AAMA,IAAaI,UAAUJ,IAAIK,gBAAgB;CACzCC,MAAM;CACNC,QAAQ;EACN,MAAMC,SAASL,WAAW;EAC1B,MAAMM,QAAQD,OAAOE,QAAQC,KAAKF;EAClC,MAAMG,UAAUX,SACdO,OAAOK,OAAOC,wBACbC,UAAUA,MACZ;EAED,MAAMC,eAAehB,IAAIiB,eAAwC;GAC/D,MAAMD,eAAwC,EAAE;GAChD,MAAME,WAAWV,OAAOG,KAAKO;AAE7B,OAAI,CAACA,SACH,QAAO,EAAE;AAGXN,WAAQG,MACLI,KAAKC,UAAUZ,OAAOa,gBAAgBD,MAAME,SAAU,CACtDC,SAASC,UACRN,SAASO,OAAOD,MAAME,KAAKC,QACvBC,QAAQC,MAAMA,EAAEC,QAAQ,SAAS,CAClCP,SAASQ,UAAU;AAClBf,iBAAagB,KAAK;KAChBF,KAAK;KACLG,OAAO;MAAE,GAAGF,MAAME;MAAOxB;MAAO;KAChCyB,UAAUH,MAAMG;KACG,CAAC;KAE5B,CAAC;AAEH,UAAOlB;IACP;EAEF,MAAMmB,UAAUnC,IAAIiB,gBAAgB,EAClCkB,SACEvB,QAAQG,MACLI,KAAKC,UAAUA,MAAMe,QA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