@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.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Match.js","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"],"names":["Match","Vue","defineComponent","name","props","matchId","type","String","required","setup","router","useRouter","lastKnownRouteId","matchData","useRouterState","select","s","match","matches","find","d","id","matchIndex","findIndex","routeId","parentRouteId","loadedAt","ssr","_displayPending","invariant","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","matchContext","actualMatchId","resolvedNoSsr","shouldClientOnly","renderMatchContent","matchInner","MatchInner","content","ClientOnly","fallback","default","CatchNotFound","error","children","CatchBoundary","getResetKey","ErrorComponent","isNotFound","warning","withScrollRestoration","rootRouteId","scrollRestoration","Fragment","OnRendered","ScrollRestoration","filter","Boolean","length","location","resolvedLocation","state","key","watchEffect","emit","getLocationChangeInfo","combinedState","sameRouteMatch","remountFn","remountDeps","defaultRemountDeps","remountKey","loaderDeps","params","_strictParams","search","_strictSearch","JSON","stringify","status","_forcePending","renderRouteNotFound","isRedirect","getMatch","_nonReactive","loadPromise","RouteErrorComponent","reset","invalidate","info","componentStack","pendingMinMs","defaultPendingMinMs","routerMatch","minPendingPromise","isServer","createControlledPromise","setTimeout","resolve","Comp","defaultComponent","Outlet","inject","safeMatchId","parentGlobalNotFound","parentMatch","globalNotFound","childMatchData","index","child","paramsKey","nextMatch","Suspense"],"mappings":";;;;;;;;;;;;;MAsBaA,QAAQC,IAAIC,gBAAgB;AAAA,EACvCC,MAAM;AAAA,EACNC,OAAO;AAAA,IACLC,SAAS;AAAA,MACPC,MAAMC;AAAAA,MACNC,UAAU;AAAA,IACZ;AAAA;EAEFC,MAAML,OAAO;AACX,UAAMM,SAASC,UAAS;AAGxB,QAAIC,mBAAkC;AAItC,UAAMC,YAAYC,eAAe;AAAA,MAC/BC,QAASC,OAAM;AAEb,YAAIC,QAAQD,EAAEE,QAAQC,KAAMC,OAAMA,EAAEC,OAAOjB,MAAMC,OAAO;AACxD,YAAIiB,aAAaL,QACbD,EAAEE,QAAQK,UAAWH,OAAMA,EAAEC,OAAOjB,MAAMC,OAAO,IACjD;AAGJ,YAAIY,OAAO;AACTL,6BAAmBK,MAAMO;AAAAA,QAC3B,WAAWZ,kBAAkB;AAG3BK,kBAAQD,EAAEE,QAAQC,KAAMC,OAAMA,EAAEI,YAAYZ,gBAAgB;AAC5DU,uBAAaL,QACTD,EAAEE,QAAQK,UAAWH,OAAMA,EAAEI,YAAYZ,gBAAgB,IACzD;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AAI,CAACC,MAAO,QAAO;AACnB,eAAO;AAAA,UACLvH,IAAIuH,MAAMvH;AAAAA;AAAAA;AAAAA;AAAAA,UAIVwH,WAAWD,MAAMpH,UAAUoF,KAAKC,UAAU+B,MAAMnC,aAAa;AAAA;MAEjE;AAAA,IACF,CAAC;AAED,WAAO,MAAoB;AACzB,UAAI8B,qBAAqBzG,OAAO;AAC9B,eAAOkF,oBAAoBtG,QAAQqB,MAAMD,OAAOU,MAAS;AAAA,MAC3D;AAEA,UAAI,CAACkG,eAAe5G,OAAO;AACzB,eAAO;AAAA,MACT;AAEA,YAAMgH,YAAY7I,IAAIsC,EAAEvC,OAAO;AAAA,QAC7BK,SAASqI,eAAe5G,MAAMT;AAAAA,QAC9BwE,KAAK6C,eAAe5G,MAAM+G;AAAAA,MAC5B,CAAC;AAED,UAAIP,YAAYxG,UAAUoD,aAAa;AACrC,eAAOjF,IAAIsC,EACTtC,IAAI8I,UACJ;AAAA,UACExE,UAAU7D,OAAOyB,QAAQE,0BACrBpC,IAAIsC,EAAE7B,OAAOyB,QAAQE,uBAAuB,IAC5C;AAAA,QACN,GACA;AAAA,UACEmC,SAASA,MAAMsE;AAAAA,QACjB,CACF;AAAA,MACF;AAEA,aAAOA;AAAAA,IACT;AAAA,EACF;AACF,CAAC;"}
|
|
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,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;AAInE,OAAI,CAAC4F,YACH,QAAO;AAGT,UAAOA,YAAYC;KAEtB,CAAC;EAEF,MAAMC,iBAAiB9H,eAAe,EACpCkB,SAASC,MAAM;GACb,MAAME,UAAUF,EAAEE;GAElB,MAAM2G,QAAQ3G,QADAA,QAAQK,WAAWH,MAAMA,EAAEC,OAAOkG,YAAY1F,MAAM,GACpC;AAC9B,OAAI,CAACgG,MAAO,QAAO;AACnB,UAAO;IACLxG,IAAIwG,MAAMxG;IAIVyG,WAAWD,MAAMrG,UAAUyE,KAAKC,UAAU2B,MAAM/B,cAAa;IAC9D;KAEJ,CAAC;AAEF,eAA2B;AACzB,OAAI0B,qBAAqB3F,MACvB,QAAO5B,oBAAoBW,QAAQkB,MAAMD,OAAOU,KAAAA,EAAU;AAG5D,OAAI,CAACoF,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"}
|
package/dist/esm/Matches.js
CHANGED
|
@@ -1,188 +1,145 @@
|
|
|
1
|
-
import * as Vue from "vue";
|
|
2
|
-
import warning from "tiny-warning";
|
|
3
|
-
import { isServer } from "@tanstack/router-core/isServer";
|
|
4
1
|
import { CatchBoundary } from "./CatchBoundary.js";
|
|
5
|
-
import { useRouterState } from "./useRouterState.js";
|
|
6
2
|
import { useRouter } from "./useRouter.js";
|
|
3
|
+
import { useRouterState } from "./useRouterState.js";
|
|
7
4
|
import { useTransitionerSetup } from "./Transitioner.js";
|
|
8
5
|
import { matchContext } from "./matchContext.js";
|
|
9
6
|
import { Match } from "./Match.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
import * as Vue from "vue";
|
|
8
|
+
import warning from "tiny-warning";
|
|
9
|
+
import { isServer } from "@tanstack/router-core/isServer";
|
|
10
|
+
//#region src/Matches.tsx
|
|
11
|
+
var MatchesContent = Vue.defineComponent({
|
|
12
|
+
name: "MatchesContent",
|
|
13
|
+
setup() {
|
|
14
|
+
useTransitionerSetup();
|
|
15
|
+
return () => Vue.h(MatchesInner);
|
|
16
|
+
}
|
|
16
17
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
return router?.options?.InnerWrap ? Vue.h(router.options.InnerWrap, null, {
|
|
29
|
-
default: () => inner
|
|
30
|
-
}) : inner;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
18
|
+
var Matches = Vue.defineComponent({
|
|
19
|
+
name: "Matches",
|
|
20
|
+
setup() {
|
|
21
|
+
const router = useRouter();
|
|
22
|
+
return () => {
|
|
23
|
+
const pendingElement = router?.options?.defaultPendingComponent ? Vue.h(router.options.defaultPendingComponent) : null;
|
|
24
|
+
const inner = (isServer ?? router?.isServer ?? false) || typeof document !== "undefined" && router?.ssr ? Vue.h(MatchesContent) : Vue.h(Vue.Suspense, { fallback: pendingElement }, { default: () => Vue.h(MatchesContent) });
|
|
25
|
+
return router?.options?.InnerWrap ? Vue.h(router.options.InnerWrap, null, { default: () => inner }) : inner;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
33
28
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
var errorComponentFn = (props) => {
|
|
30
|
+
return Vue.h("div", { class: "error" }, [
|
|
31
|
+
Vue.h("h1", null, "Error"),
|
|
32
|
+
Vue.h("p", null, props.error.message || String(props.error)),
|
|
33
|
+
Vue.h("button", { onClick: props.reset }, "Try Again")
|
|
34
|
+
]);
|
|
40
35
|
};
|
|
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
|
-
onCatch: process.env.NODE_ENV !== "production" ? (error) => {
|
|
66
|
-
warning(false, `The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`);
|
|
67
|
-
warning(false, error.message || error.toString());
|
|
68
|
-
} : void 0,
|
|
69
|
-
children: childElement
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
}
|
|
36
|
+
var MatchesInner = Vue.defineComponent({
|
|
37
|
+
name: "MatchesInner",
|
|
38
|
+
setup() {
|
|
39
|
+
const router = useRouter();
|
|
40
|
+
const matchId = useRouterState({ select: (s) => {
|
|
41
|
+
return s.matches[0]?.id;
|
|
42
|
+
} });
|
|
43
|
+
const resetKey = useRouterState({ select: (s) => s.loadedAt });
|
|
44
|
+
const matchIdRef = Vue.computed(() => matchId.value);
|
|
45
|
+
Vue.provide(matchContext, matchIdRef);
|
|
46
|
+
return () => {
|
|
47
|
+
const childElement = matchId.value ? Vue.h(Match, { matchId: matchId.value }) : Vue.h("div");
|
|
48
|
+
if (router.options.disableGlobalCatchBoundary) return childElement;
|
|
49
|
+
return Vue.h(CatchBoundary, {
|
|
50
|
+
getResetKey: () => resetKey.value,
|
|
51
|
+
errorComponent: errorComponentFn,
|
|
52
|
+
onCatch: process.env.NODE_ENV !== "production" ? (error) => {
|
|
53
|
+
warning(false, `The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`);
|
|
54
|
+
warning(false, error.message || error.toString());
|
|
55
|
+
} : void 0,
|
|
56
|
+
children: childElement
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
}
|
|
73
60
|
});
|
|
74
61
|
function useMatchRoute() {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return router.matchRoute(rest, {
|
|
94
|
-
pending,
|
|
95
|
-
caseSensitive,
|
|
96
|
-
fuzzy,
|
|
97
|
-
includeSearch
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
return matchRoute;
|
|
101
|
-
};
|
|
62
|
+
const router = useRouter();
|
|
63
|
+
const routerState = useRouterState({ select: (s) => ({
|
|
64
|
+
locationHref: s.location.href,
|
|
65
|
+
resolvedLocationHref: s.resolvedLocation?.href,
|
|
66
|
+
status: s.status
|
|
67
|
+
}) });
|
|
68
|
+
return (opts) => {
|
|
69
|
+
const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts;
|
|
70
|
+
return Vue.computed(() => {
|
|
71
|
+
routerState.value;
|
|
72
|
+
return router.matchRoute(rest, {
|
|
73
|
+
pending,
|
|
74
|
+
caseSensitive,
|
|
75
|
+
fuzzy,
|
|
76
|
+
includeSearch
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
};
|
|
102
80
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const params = matchRoute(props).value;
|
|
142
|
-
if (!params || !slots.default) {
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
if (typeof slots.default === "function") {
|
|
146
|
-
return Vue.h(Vue.Fragment, null, slots.default(params));
|
|
147
|
-
}
|
|
148
|
-
return Vue.h(Vue.Fragment, null, slots.default);
|
|
149
|
-
};
|
|
150
|
-
}
|
|
81
|
+
var MatchRoute = Vue.defineComponent({
|
|
82
|
+
name: "MatchRoute",
|
|
83
|
+
props: {
|
|
84
|
+
from: {
|
|
85
|
+
type: String,
|
|
86
|
+
required: false
|
|
87
|
+
},
|
|
88
|
+
to: {
|
|
89
|
+
type: String,
|
|
90
|
+
required: false
|
|
91
|
+
},
|
|
92
|
+
fuzzy: {
|
|
93
|
+
type: Boolean,
|
|
94
|
+
required: false
|
|
95
|
+
},
|
|
96
|
+
caseSensitive: {
|
|
97
|
+
type: Boolean,
|
|
98
|
+
required: false
|
|
99
|
+
},
|
|
100
|
+
includeSearch: {
|
|
101
|
+
type: Boolean,
|
|
102
|
+
required: false
|
|
103
|
+
},
|
|
104
|
+
pending: {
|
|
105
|
+
type: Boolean,
|
|
106
|
+
required: false
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
setup(props, { slots }) {
|
|
110
|
+
const status = useRouterState({ select: (s) => s.status });
|
|
111
|
+
return () => {
|
|
112
|
+
if (!status.value) return null;
|
|
113
|
+
const params = useMatchRoute()(props).value;
|
|
114
|
+
if (!params || !slots.default) return null;
|
|
115
|
+
if (typeof slots.default === "function") return Vue.h(Vue.Fragment, null, slots.default(params));
|
|
116
|
+
return Vue.h(Vue.Fragment, null, slots.default);
|
|
117
|
+
};
|
|
118
|
+
}
|
|
151
119
|
});
|
|
152
120
|
function useMatches(opts) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
});
|
|
121
|
+
return useRouterState({ select: (state) => {
|
|
122
|
+
const matches = state?.matches || [];
|
|
123
|
+
return opts?.select ? opts.select(matches) : matches;
|
|
124
|
+
} });
|
|
159
125
|
}
|
|
160
126
|
function useParentMatches(opts) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
});
|
|
127
|
+
const contextMatchId = Vue.inject(matchContext);
|
|
128
|
+
const safeMatchId = Vue.computed(() => contextMatchId?.value || "");
|
|
129
|
+
return useMatches({ select: (matches) => {
|
|
130
|
+
matches = matches.slice(0, matches.findIndex((d) => d.id === safeMatchId.value));
|
|
131
|
+
return opts?.select ? opts.select(matches) : matches;
|
|
132
|
+
} });
|
|
169
133
|
}
|
|
170
134
|
function useChildMatches(opts) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
});
|
|
135
|
+
const contextMatchId = Vue.inject(matchContext);
|
|
136
|
+
const safeMatchId = Vue.computed(() => contextMatchId?.value || "");
|
|
137
|
+
return useMatches({ select: (matches) => {
|
|
138
|
+
matches = matches.slice(matches.findIndex((d) => d.id === safeMatchId.value) + 1);
|
|
139
|
+
return opts?.select ? opts.select(matches) : matches;
|
|
140
|
+
} });
|
|
179
141
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
useMatchRoute,
|
|
185
|
-
useMatches,
|
|
186
|
-
useParentMatches
|
|
187
|
-
};
|
|
188
|
-
//# sourceMappingURL=Matches.js.map
|
|
142
|
+
//#endregion
|
|
143
|
+
export { MatchRoute, Matches, useChildMatches, useMatchRoute, useMatches, useParentMatches };
|
|
144
|
+
|
|
145
|
+
//# sourceMappingURL=Matches.js.map
|
package/dist/esm/Matches.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Matches.js","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"],"names":["MatchesContent","Vue","defineComponent","name","setup","useTransitionerSetup","h","MatchesInner","Matches","router","useRouter","pendingElement","options","defaultPendingComponent","inner","isServer","document","ssr","Suspense","fallback","default","InnerWrap","errorComponentFn","props","class","error","message","String","onClick","reset","matchId","useRouterState","select","s","matches","id","resetKey","loadedAt","matchIdRef","computed","value","provide","matchContext","childElement","Match","disableGlobalCatchBoundary","CatchBoundary","getResetKey","errorComponent","onCatch","process","env","NODE_ENV","warning","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"],"mappings":";;;;;;;;;AA0CA,MAAMA,iBAAiBC,IAAIC,gBAAgB;AAAA,EACzCC,MAAM;AAAA,EACNC,QAAQ;AAUNC,yBAAoB;AAEpB,WAAO,MAAMJ,IAAIK,EAAEC,YAAY;AAAA,EACjC;AACF,CAAC;MAEYC,UAAUP,IAAIC,gBAAgB;AAAA,EACzCC,MAAM;AAAA,EACNC,QAAQ;AACN,UAAMK,SAASC,UAAS;AAExB,WAAO,MAAM;AACX,YAAMC,iBAAiBF,QAAQG,SAASC,0BACpCZ,IAAIK,EAAEG,OAAOG,QAAQC,uBAAuB,IAC5C;AAGJ,YAAMC,SACHC,YAAYN,QAAQM,YAAY,UAChC,OAAOC,aAAa,eAAeP,QAAQQ,MACxChB,IAAIK,EAAEN,cAAc,IACpBC,IAAIK,EACFL,IAAIiB,UACJ;AAAA,QAAEC,UAAUR;AAAAA,MAAe,GAC3B;AAAA,QACES,SAASA,MAAMnB,IAAIK,EAAEN,cAAc;AAAA,MACrC,CACF;AAEN,aAAOS,QAAQG,SAASS,YACpBpB,IAAIK,EAAEG,OAAOG,QAAQS,WAAW,MAAM;AAAA,QAAED,SAASA,MAAMN;AAAAA,OAAO,IAC9DA;AAAAA,IACN;AAAA,EACF;AACF,CAAC;AAGD,MAAMQ,mBACJC,WACG;AACH,SAAOtB,IAAIK,EAAE,OAAO;AAAA,IAAEkB,OAAO;AAAA,EAAQ,GAAG,CACtCvB,IAAIK,EAAE,MAAM,MAAM,OAAO,GACzBL,IAAIK,EAAE,KAAK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|
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;GAGJ,MAAMC,SACHlB,YAAYc,QAAQd,YAAY,UAChC,OAAOmB,aAAa,eAAeL,QAAQM,MACxCtB,IAAIa,EAAEJ,eAAe,GACrBT,IAAIa,EACFb,IAAIuB,UACJ,EAAEC,UAAUP,gBAAgB,EAC5B,EACEQ,eAAezB,IAAIa,EAAEJ,eAAc,EAEvC,CAAC;AAEP,UAAOO,QAAQE,SAASQ,YACpB1B,IAAIa,EAAEG,OAAOE,QAAQQ,WAAW,MAAM,EAAED,eAAeL,OAAO,CAAC,GAC/DA;;;CAGT,CAAC;AAGF,IAAMO,oBACJC,UACG;AACH,QAAO5B,IAAIa,EAAE,OAAO,EAAEgB,OAAO,SAAS,EAAE;EACtC7B,IAAIa,EAAE,MAAM,MAAM,QAAQ;EAC1Bb,IAAIa,EAAE,KAAK,MAAMe,MAAME,MAAMC,WAAWC,OAAOJ,MAAME,MAAM,CAAC;EAC5D9B,IAAIa,EAAE,UAAU,EAAEoB,SAASL,MAAMM,OAAO,EAAE,YAAY;EACvD,CAAC;;AAGJ,IAAMpB,eAAed,IAAIU,gBAAgB;CACvCC,MAAM;CACNC,QAAQ;EACN,MAAMI,SAASX,WAAW;EAE1B,MAAM8B,UAAU/B,eAAe,EAC7BgC,SAASC,MAAM;AACb,UAAOA,EAAEC,QAAQ,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