@tanstack/vue-router 1.140.1 → 1.141.0
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 +122 -8
- package/dist/esm/Asset.js.map +1 -1
- package/dist/esm/Body.d.ts +4 -0
- package/dist/esm/Body.js +26 -0
- package/dist/esm/Body.js.map +1 -0
- package/dist/esm/CatchBoundary.d.ts +1 -1
- package/dist/esm/CatchBoundary.js +8 -8
- package/dist/esm/CatchBoundary.js.map +1 -1
- package/dist/esm/Html.d.ts +4 -0
- package/dist/esm/Html.js +63 -0
- package/dist/esm/Html.js.map +1 -0
- package/dist/esm/Match.js +87 -49
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.js +3 -2
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.js +3 -0
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/ScriptOnce.d.ts +12 -5
- package/dist/esm/ScriptOnce.js +35 -15
- package/dist/esm/ScriptOnce.js.map +1 -1
- package/dist/esm/Scripts.d.ts +2 -1
- package/dist/esm/Scripts.js +101 -35
- package/dist/esm/Scripts.js.map +1 -1
- package/dist/esm/Transitioner.d.ts +16 -0
- package/dist/esm/Transitioner.js +136 -133
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/awaited.d.ts +20 -5
- package/dist/esm/awaited.js +17 -20
- package/dist/esm/awaited.js.map +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lazyRouteComponent.js +2 -2
- package/dist/esm/lazyRouteComponent.js.map +1 -1
- package/dist/esm/link.js +27 -35
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/scroll-restoration.d.ts +8 -1
- package/dist/esm/scroll-restoration.js +44 -12
- package/dist/esm/scroll-restoration.js.map +1 -1
- package/dist/esm/ssr/RouterClient.d.ts +15 -0
- package/dist/esm/ssr/RouterClient.js +46 -0
- package/dist/esm/ssr/RouterClient.js.map +1 -0
- package/dist/esm/ssr/RouterServer.d.ts +15 -0
- package/dist/esm/ssr/RouterServer.js +37 -0
- package/dist/esm/ssr/RouterServer.js.map +1 -0
- package/dist/esm/ssr/client.d.ts +1 -0
- package/dist/esm/ssr/client.js +5 -0
- package/dist/esm/ssr/client.js.map +1 -0
- package/dist/esm/ssr/defaultRenderHandler.d.ts +1 -0
- package/dist/esm/ssr/defaultRenderHandler.js +15 -0
- package/dist/esm/ssr/defaultRenderHandler.js.map +1 -0
- package/dist/esm/ssr/defaultStreamHandler.d.ts +1 -0
- package/dist/esm/ssr/defaultStreamHandler.js +17 -0
- package/dist/esm/ssr/defaultStreamHandler.js.map +1 -0
- package/dist/esm/ssr/renderRouterToStream.d.ts +8 -0
- package/dist/esm/ssr/renderRouterToStream.js +70 -0
- package/dist/esm/ssr/renderRouterToStream.js.map +1 -0
- package/dist/esm/ssr/renderRouterToString.d.ts +7 -0
- package/dist/esm/ssr/renderRouterToString.js +33 -0
- package/dist/esm/ssr/renderRouterToString.js.map +1 -0
- package/dist/esm/ssr/server.d.ts +6 -0
- package/dist/esm/ssr/server.js +14 -0
- package/dist/esm/ssr/server.js.map +1 -0
- package/dist/source/Asset.jsx +119 -7
- package/dist/source/Asset.jsx.map +1 -1
- package/dist/source/Body.d.ts +4 -0
- package/dist/source/Body.jsx +15 -0
- package/dist/source/Body.jsx.map +1 -0
- package/dist/source/CatchBoundary.d.ts +1 -1
- package/dist/source/CatchBoundary.jsx +10 -23
- package/dist/source/CatchBoundary.jsx.map +1 -1
- package/dist/source/Html.d.ts +4 -0
- package/dist/source/Html.jsx +56 -0
- package/dist/source/Html.jsx.map +1 -0
- package/dist/source/Match.jsx +119 -54
- package/dist/source/Match.jsx.map +1 -1
- package/dist/source/Matches.jsx +15 -3
- package/dist/source/Matches.jsx.map +1 -1
- package/dist/source/RouterProvider.jsx +5 -0
- package/dist/source/RouterProvider.jsx.map +1 -1
- package/dist/source/ScriptOnce.d.ts +12 -5
- package/dist/source/ScriptOnce.jsx +27 -16
- package/dist/source/ScriptOnce.jsx.map +1 -1
- package/dist/source/Scripts.d.ts +2 -1
- package/dist/source/Scripts.jsx +100 -42
- package/dist/source/Scripts.jsx.map +1 -1
- package/dist/source/Transitioner.d.ts +16 -0
- package/dist/source/Transitioner.jsx +180 -160
- package/dist/source/Transitioner.jsx.map +1 -1
- package/dist/source/awaited.d.ts +20 -5
- package/dist/source/awaited.jsx +18 -25
- package/dist/source/awaited.jsx.map +1 -1
- package/dist/source/index.d.ts +2 -0
- package/dist/source/index.jsx +2 -0
- package/dist/source/index.jsx.map +1 -1
- package/dist/source/lazyRouteComponent.jsx +4 -2
- package/dist/source/lazyRouteComponent.jsx.map +1 -1
- package/dist/source/link.jsx +37 -51
- package/dist/source/link.jsx.map +1 -1
- package/dist/source/scroll-restoration.d.ts +8 -1
- package/dist/source/scroll-restoration.jsx +55 -12
- package/dist/source/scroll-restoration.jsx.map +1 -1
- package/dist/source/ssr/RouterClient.d.ts +15 -0
- package/dist/source/ssr/RouterClient.jsx +48 -0
- package/dist/source/ssr/RouterClient.jsx.map +1 -0
- package/dist/source/ssr/RouterServer.d.ts +15 -0
- package/dist/source/ssr/RouterServer.jsx +40 -0
- package/dist/source/ssr/RouterServer.jsx.map +1 -0
- package/dist/source/ssr/client.d.ts +1 -0
- package/dist/source/ssr/client.js +2 -0
- package/dist/source/ssr/client.js.map +1 -0
- package/dist/source/ssr/defaultRenderHandler.d.ts +1 -0
- package/dist/source/ssr/defaultRenderHandler.jsx +9 -0
- package/dist/source/ssr/defaultRenderHandler.jsx.map +1 -0
- package/dist/source/ssr/defaultStreamHandler.d.ts +1 -0
- package/dist/source/ssr/defaultStreamHandler.jsx +10 -0
- package/dist/source/ssr/defaultStreamHandler.jsx.map +1 -0
- package/dist/source/ssr/renderRouterToStream.d.ts +8 -0
- package/dist/source/ssr/renderRouterToStream.jsx +55 -0
- package/dist/source/ssr/renderRouterToStream.jsx.map +1 -0
- package/dist/source/ssr/renderRouterToString.d.ts +7 -0
- package/dist/source/ssr/renderRouterToString.jsx +26 -0
- package/dist/source/ssr/renderRouterToString.jsx.map +1 -0
- package/dist/source/ssr/server.d.ts +6 -0
- package/dist/source/ssr/server.js +7 -0
- package/dist/source/ssr/server.js.map +1 -0
- package/package.json +16 -3
- package/src/Asset.tsx +157 -7
- package/src/Body.tsx +26 -0
- package/src/CatchBoundary.tsx +11 -25
- package/src/Html.tsx +65 -0
- package/src/Match.tsx +135 -58
- package/src/Matches.tsx +16 -4
- package/src/RouterProvider.tsx +6 -0
- package/src/ScriptOnce.tsx +43 -28
- package/src/Scripts.tsx +121 -56
- package/src/Transitioner.tsx +197 -176
- package/src/awaited.tsx +17 -28
- package/src/index.tsx +2 -0
- package/src/lazyRouteComponent.tsx +4 -2
- package/src/link.tsx +42 -47
- package/src/scroll-restoration.tsx +69 -21
- package/src/ssr/RouterClient.tsx +58 -0
- package/src/ssr/RouterServer.tsx +51 -0
- package/src/ssr/client.ts +1 -0
- package/src/ssr/defaultRenderHandler.tsx +12 -0
- package/src/ssr/defaultStreamHandler.tsx +13 -0
- package/src/ssr/renderRouterToStream.tsx +85 -0
- package/src/ssr/renderRouterToString.tsx +37 -0
- package/src/ssr/server.ts +6 -0
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 { CatchBoundary, ErrorComponent } from './CatchBoundary'\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 } 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 const routeId = useRouterState({\n select: (s) => {\n return s.matches.find((d) => d.id === props.matchId)?.routeId as string\n },\n })\n\n invariant(\n routeId.value,\n `Could not find routeId for matchId \"${props.matchId}\". Please file an issue!`,\n )\n\n const route = Vue.computed(() => router.routesById[routeId.value])\n\n const PendingComponent = Vue.computed(\n () =>\n route.value?.options?.pendingComponent ??\n router?.options?.defaultPendingComponent,\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 resetKey = useRouterState({\n select: (s) => s.loadedAt,\n })\n\n const parentRouteId = useRouterState({\n select: (s) => {\n const index = s.matches.findIndex((d) => d.id === props.matchId)\n return s.matches[index - 1]?.routeId as string\n },\n })\n\n // Create a ref for the current matchId that we can provide to child components\n const matchIdRef = Vue.ref(props.matchId)\n\n // When props.matchId changes, update the ref\n Vue.watch(\n () => props.matchId,\n (newMatchId) => {\n matchIdRef.value = newMatchId\n },\n { immediate: true },\n )\n\n // Provide the matchId to child components\n Vue.provide(matchContext, matchIdRef)\n\n return (): VNode => {\n // Determine which components to render\n let content: VNode = Vue.h(MatchInner, { matchId: props.matchId })\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 !== routeId.value) ||\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: () => resetKey.value,\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: ${props.matchId}`)\n routeOnCatch.value?.(error)\n },\n children: content,\n })\n }\n\n // Wrap in suspense if needed\n // Root routes should also wrap in Suspense if they have a pendingComponent\n const needsSuspense =\n route.value &&\n (route.value?.options?.wrapInSuspense ??\n PendingComponent.value ??\n false)\n\n if (needsSuspense) {\n content = Vue.h(\n Vue.Suspense,\n {\n fallback: PendingComponent.value\n ? Vue.h(PendingComponent.value)\n : null,\n },\n {\n default: () => content,\n },\n )\n }\n\n // Add scroll restoration if needed\n const withScrollRestoration: Array<VNode> = [\n content,\n parentRouteId.value === rootRouteId && 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 Vue.h(Vue.Fragment, null, withScrollRestoration)\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 // { match, key, routeId } =\n const matchState = useRouterState({\n select: (s) => {\n const match = s.matches.find((d) => d.id === props.matchId)\n\n // During navigation transitions, matches can be temporarily removed\n if (!match) {\n return null\n }\n\n const routeId = match.routeId as string\n\n const remountFn =\n (router.routesById[routeId] as AnyRoute).options.remountDeps ??\n router.options.defaultRemountDeps\n const remountDeps = remountFn?.({\n routeId,\n loaderDeps: match.loaderDeps,\n params: match._strictParams,\n search: match._strictSearch,\n })\n const key = remountDeps ? JSON.stringify(remountDeps) : undefined\n\n return {\n key,\n routeId,\n match: {\n id: match.id,\n status: match.status,\n error: match.error,\n },\n }\n },\n })\n\n const route = Vue.computed(() => {\n if (!matchState.value) return null\n return router.routesById[matchState.value.routeId]!\n })\n\n const match = Vue.computed(() => matchState.value?.match)\n\n const out = Vue.computed((): VNode | null => {\n if (!route.value) return null\n const Comp =\n route.value.options.component ?? router.options.defaultComponent\n if (Comp) {\n return Vue.h(Comp)\n }\n return Vue.h(Outlet)\n })\n\n return (): VNode | null => {\n // If match doesn't exist, return null (component is being unmounted or not ready)\n if (!matchState.value || !match.value || !route.value) {\n return null\n }\n\n // Handle different match statuses\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 (!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\n return out.value\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 childMatchId = useRouterState({\n select: (s) => {\n const matches = s.matches\n const index = matches.findIndex((d) => d.id === safeMatchId.value)\n return matches[index + 1]?.id\n },\n })\n\n return (): VNode | null => {\n if (parentGlobalNotFound.value) {\n return renderRouteNotFound(router, route.value, undefined)\n }\n\n if (!childMatchId.value) {\n return null\n }\n\n const nextMatch = Vue.h(Match, { matchId: childMatchId.value })\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","routeId","useRouterState","select","s","matches","find","d","id","invariant","value","route","computed","routesById","PendingComponent","options","pendingComponent","defaultPendingComponent","routeErrorComponent","errorComponent","defaultErrorComponent","routeOnCatch","onCatch","defaultOnCatch","routeNotFoundComponent","isRoot","notFoundComponent","notFoundRoute","component","resetKey","loadedAt","parentRouteId","index","findIndex","matchIdRef","ref","watch","newMatchId","immediate","provide","matchContext","content","h","MatchInner","CatchNotFound","fallback","error","children","CatchBoundary","getResetKey","ErrorComponent","isNotFound","warning","needsSuspense","wrapInSuspense","Suspense","default","withScrollRestoration","rootRouteId","scrollRestoration","Fragment","OnRendered","ScrollRestoration","filter","Boolean","location","resolvedLocation","state","key","watchEffect","emit","getLocationChangeInfo","matchState","match","remountFn","remountDeps","defaultRemountDeps","loaderDeps","params","_strictParams","search","_strictSearch","JSON","stringify","undefined","status","out","Comp","defaultComponent","Outlet","renderRouteNotFound","isRedirect","getMatch","_nonReactive","loadPromise","RouteErrorComponent","reset","invalidate","info","componentStack","pendingMinMs","defaultPendingMinMs","routerMatch","minPendingPromise","isServer","createControlledPromise","setTimeout","resolve","inject","safeMatchId","parentGlobalNotFound","parentMatch","globalNotFound","childMatchId","nextMatch"],"mappings":";;;;;;;;;;;MAoBaA,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;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;AACrC,eAAOpE,IAAIoD,EACTpD,IAAIiE,UACJ;AAAA,UACEV,UAAU9C,OAAOgB,QAAQE,0BACrB3B,IAAIoD,EAAE3C,OAAOgB,QAAQE,uBAAuB,IAC5C;AAAA,QACN,GACA;AAAA,UACEuC,SAASA,MAAM0D;AAAAA,QACjB,CACF;AAAA,MACF;AAEA,aAAOA;AAAAA,IACT;AAAA,EACF;AACF,CAAC;"}
|
|
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 { CatchBoundary, ErrorComponent } from './CatchBoundary'\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 } 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 }\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 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 // 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 // Determine which components to render\n let content: VNode = Vue.h(MatchInner, { matchId: actualMatchId })\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 // Wrap in suspense if needed\n // Root routes should also wrap in Suspense if they have a pendingComponent\n const needsSuspense =\n route.value &&\n (route.value?.options?.wrapInSuspense ??\n PendingComponent.value ??\n false)\n\n if (needsSuspense) {\n content = Vue.h(\n Vue.Suspense,\n {\n fallback: PendingComponent.value\n ? Vue.h(PendingComponent.value)\n : null,\n },\n {\n default: () => content,\n },\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 return Vue.h(Vue.Fragment, null, withScrollRestoration)\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 },\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) {\n return null\n }\n\n // Handle different match statuses\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 (!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","invariant","value","route","computed","routesById","PendingComponent","options","pendingComponent","defaultPendingComponent","routeErrorComponent","errorComponent","defaultErrorComponent","routeOnCatch","onCatch","defaultOnCatch","routeNotFoundComponent","isRoot","notFoundComponent","notFoundRoute","component","matchIdRef","ref","watch","propsMatchId","dataMatchId","immediate","provide","matchContext","actualMatchId","content","h","MatchInner","CatchNotFound","fallback","error","children","CatchBoundary","getResetKey","ErrorComponent","isNotFound","warning","needsSuspense","wrapInSuspense","Suspense","default","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","undefined","status","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"],"mappings":";;;;;;;;;;;MAoBaA,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,Y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
3
3
|
import { CatchBoundary } from "./CatchBoundary.js";
|
|
4
4
|
import { useRouterState } from "./useRouterState.js";
|
|
5
5
|
import { useRouter } from "./useRouter.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useTransitionerSetup } from "./Transitioner.js";
|
|
7
7
|
import { matchContext } from "./matchContext.js";
|
|
8
8
|
import { Match } from "./Match.js";
|
|
9
9
|
const MatchesContent = Vue.defineComponent({
|
|
10
10
|
name: "MatchesContent",
|
|
11
11
|
setup() {
|
|
12
|
-
|
|
12
|
+
useTransitionerSetup();
|
|
13
|
+
return () => Vue.h(MatchesInner);
|
|
13
14
|
}
|
|
14
15
|
});
|
|
15
16
|
const Matches = Vue.defineComponent({
|
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 { CatchBoundary } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { Transitioner } 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 both the Transitioner and MatchesInner\nconst MatchesContent = Vue.defineComponent({\n name: 'MatchesContent',\n setup() {\n return () =>\n Vue.h(Vue.Fragment, null, [Vue.h(Transitioner), 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 router?.isServer || (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: (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 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","h","Fragment","Transitioner","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","warning","toString","children","useMatchRoute","routerState","locationHref","location","href","resolvedLocationHref","resolvedLocation","status","opts","pending","caseSensitive","fuzzy","includeSearch","rest","matchRoute","MatchRoute","from","type","required","to","Boolean","slots","params","useMatches","state","useParentMatches","contextMatchId","inject","safeMatchId","slice","findIndex","d","useChildMatches"],"mappings":";;;;;;;;AAuCA,MAAMA,iBAAiBC,IAAIC,gBAAgB;AAAA,EACzCC,MAAM;AAAA,EACNC,QAAQ;AACN,WAAO,MACLH,IAAII,EAAEJ,IAAIK,UAAU,MAAM,CAACL,IAAII,EAAEE,YAAY,GAAGN,IAAII,EAAEG,YAAY,CAAC,CAAC;AAAA,EACxE;AACF,CAAC;MAEYC,UAAUR,IAAIC,gBAAgB;AAAA,EACzCC,MAAM;AAAA,EACNC,QAAQ;AACN,UAAMM,SAASC,UAAS;AAExB,WAAO,MAAM;AACX,YAAMC,iBAAiBF,QAAQG,SAASC,0BACpCb,IAAII,EAAEK,OAAOG,QAAQC,uBAAuB,IAC5C;AAGJ,YAAMC,QACJL,QAAQM,YAAa,OAAOC,aAAa,eAAeP,QAAQQ,MAC5DjB,IAAII,EAAEL,cAAc,IACpBC,IAAII,EACFJ,IAAIkB,UACJ;AAAA,QAAEC,UAAUR;AAAAA,MAAe,GAC3B;AAAA,QACES,SAASA,MAAMpB,IAAII,EAAEL,cAAc;AAAA,MACrC,CACF;AAEN,aAAOU,QAAQG,SAASS,YACpBrB,IAAII,EAAEK,OAAOG,QAAQS,WAAW,MAAM;AAAA,QAAED,SAASA,MAAMN;AAAAA,OAAO,IAC9DA;AAAAA,IACN;AAAA,EACF;AACF,CAAC;AAGD,MAAMQ,mBACJC,WACG;AACH,SAAOvB,IAAII,EAAE,OAAO;AAAA,IAAEoB,OAAO;AAAA,EAAQ,GAAG,CACtCxB,IAAII,EAAE,MAAM,MAAM,OAAO,GACzBJ,IAAII,EAAE,KAAK,MAAMmB,MAAME,MAAMC,WAAWC,OAAOJ,MAAME,KAAK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,QAAQuD,MAAM,CAAC;AAAA,MACxD;AAGA,aAAO3E,IAAII,EAAEJ,IAAIK,UAAU,MAAMqE,MAAMtD,OAAO;AAAA,IAChD;AAAA,EACF;AACF,CAAC;AAWM,SAASwD,WAIdf,MAC+C;AAC/C,SAAO9B,eAAe;AAAA,IACpBC,QAAS6C,WAA6C;AACpD,YAAM3C,UAAU2C,OAAO3C,WAAW,CAAA;AAClC,aAAO2B,MAAM7B,SACT6B,KAAK7B,OAAOE,OAA8C,IAC1DA;AAAAA,IACN;AAAA,EACF,CAAQ;AACV;AAEO,SAAS4C,iBAIdjB,MAC+C;AAE/C,QAAMkB,iBAAiB/E,IAAIgF,OAAoCtC,YAAY;AAC3E,QAAMuC,cAAcjF,IAAIuC,SAAS,MAAMwC,gBAAgBvC,SAAS,EAAE;AAElE,SAAOoC,WAAW;AAAA,IAChB5C,QAASE,aAAiD;AACxDA,gBAAUA,QAAQgD,MAChB,GACAhD,QAAQiD,UAAWC,OAAMA,EAAEjD,OAAO8C,YAAYzC,KAAK,CACrD;AACA,aAAOqB,MAAM7B,SAAS6B,KAAK7B,OAAOE,OAAO,IAAIA;AAAAA,IAC/C;AAAA,EACF,CAAQ;AACV;AAEO,SAASmD,gBAIdxB,MAC+C;AAE/C,QAAMkB,iBAAiB/E,IAAIgF,OAAoCtC,YAAY;AAC3E,QAAMuC,cAAcjF,IAAIuC,SAAS,MAAMwC,gBAAgBvC,SAAS,EAAE;AAElE,SAAOoC,WAAW;AAAA,IAChB5C,QAASE,aAAiD;AACxDA,gBAAUA,QAAQgD,MAChBhD,QAAQiD,UAAWC,OAAMA,EAAEjD,OAAO8C,YAAYzC,KAAK,IAAI,CACzD;AACA,aAAOqB,MAAM7B,SAAS6B,KAAK7B,OAAOE,OAAO,IAAIA;AAAAA,IAC/C;AAAA,EACF,CAAQ;AACV;"}
|
|
1
|
+
{"version":3,"file":"Matches.js","sources":["../../src/Matches.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport warning from 'tiny-warning'\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 router?.isServer || (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: (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 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","warning","toString","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":";;;;;;;;AAyCA,MAAMA,iBAAiBC,IAAIC,gBAAgB;AAAA,EACzCC,MAAM;AAAA,EACNC,QAAQ;AAUNC,y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O,SAAS6C,iBAIdlB,MAC+C;AAE/C,QAAMmB,iBAAiB/E,IAAIgF,OAAoCvC,YAAY;AAC3E,QAAMwC,cAAcjF,IAAIsC,SAAS,MAAMyC,gBAAgBxC,SAAS,EAAE;AAElE,SAAOqC,WAAW;AAAA,IAChB7C,QAASE,aAAiD;AACxDA,gBAAUA,QAAQiD,MAChB,GACAjD,QAAQkD,UAAWC,OAAMA,EAAElD,OAAO+C,YAAY1C,KAAK,CACrD;AACA,aAAOqB,MAAM7B,SAAS6B,KAAK7B,OAAOE,OAAO,IAAIA;AAAAA,IAC/C;AAAA,EACF,CAAQ;AACV;AAEO,SAASoD,gBAIdzB,MAC+C;AAE/C,QAAMmB,iBAAiB/E,IAAIgF,OAAoCvC,YAAY;AAC3E,QAAMwC,cAAcjF,IAAIsC,SAAS,MAAMyC,gBAAgBxC,SAAS,EAAE;AAElE,SAAOqC,WAAW;AAAA,IAChB7C,QAASE,aAAiD;AACxDA,gBAAUA,QAAQiD,MAChBjD,QAAQkD,UAAWC,OAAMA,EAAElD,OAAO+C,YAAY1C,KAAK,IAAI,CACzD;AACA,aAAOqB,MAAM7B,SAAS6B,KAAK7B,OAAOE,OAAO,IAAIA;AAAAA,IAC/C;AAAA,EACF,CAAQ;AACV;"}
|
|
@@ -31,6 +31,9 @@ const RouterContextProvider = Vue.defineComponent({
|
|
|
31
31
|
const WrapComponent = router.options.Wrap;
|
|
32
32
|
return Vue.h(WrapComponent, null, () => childContent);
|
|
33
33
|
}
|
|
34
|
+
if (Array.isArray(childContent) && childContent.length === 1) {
|
|
35
|
+
return childContent[0];
|
|
36
|
+
}
|
|
34
37
|
return childContent;
|
|
35
38
|
};
|
|
36
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouterProvider.js","sources":["../../src/RouterProvider.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport { Matches } from './Matches'\nimport { provideRouter } from './routerContext'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterOptions,\n} from '@tanstack/router-core'\n\n// Component that provides router context and renders children\nexport const RouterContextProvider = Vue.defineComponent({\n name: 'RouterContextProvider',\n props: {\n router: {\n type: Object,\n required: true,\n },\n // Rest of router options will be passed as attrs\n },\n setup(props, { attrs, slots }) {\n const router = props.router as AnyRouter\n const restAttrs = attrs as Record<string, any>\n\n // Allow the router to update options on the router instance\n router.update({\n ...router.options,\n ...restAttrs,\n context: {\n ...router.options.context,\n ...((restAttrs.context as Record<string, any>) || {}),\n },\n } as any)\n\n // Provide router to all child components\n provideRouter(router)\n\n return () => {\n // Get child content\n const childContent = slots.default?.()\n\n // If a Wrap component is specified in router options, use it\n if (router.options.Wrap) {\n const WrapComponent = router.options.Wrap\n return Vue.h(WrapComponent, null, () => childContent)\n }\n\n // Otherwise just return the child content\n return childContent\n }\n },\n})\n\n// The main router provider component that includes matches\nexport const RouterProvider = Vue.defineComponent({\n name: 'RouterProvider',\n props: {\n router: {\n type: Object,\n required: true,\n },\n // Rest of router options will be passed as attrs\n },\n setup(props, { attrs }) {\n const restAttrs = attrs as Record<string, any>\n\n return () => {\n return Vue.h(\n RouterContextProvider,\n {\n router: props.router,\n ...restAttrs,\n },\n {\n default: () => Vue.h(Matches),\n },\n )\n }\n },\n}) as unknown as {\n <TRouter extends AnyRouter = RegisteredRouter>(\n props: {\n router: TRouter\n routeTree?: TRouter['routeTree']\n } & Record<string, any>,\n ): Vue.VNode\n new (): {\n $props: {\n router: AnyRouter\n routeTree?: AnyRouter['routeTree']\n }\n }\n}\n\nexport type RouterProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n> = Omit<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n false,\n TRouter['history'],\n TDehydrated\n >,\n 'context'\n> & {\n router: TRouter\n context?: Partial<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n false,\n TRouter['history'],\n TDehydrated\n >['context']\n >\n}\n"],"names":["RouterContextProvider","Vue","defineComponent","name","props","router","type","Object","required","setup","attrs","slots","restAttrs","update","options","context","provideRouter","childContent","default","Wrap","WrapComponent","h","RouterProvider","Matches"],"mappings":";;;MAUaA,wBAAwBC,IAAIC,gBAAgB;AAAA,EACvDC,MAAM;AAAA,EACNC,OAAO;AAAA,IACLC,QAAQ;AAAA,MACNC,MAAMC;AAAAA,MACNC,UAAU;AAAA,IACZ;AAAA;AAAA;EAGFC,MAAML,OAAO;AAAA,IAAEM;AAAAA,IAAOC;AAAAA,EAAM,GAAG;AAC7B,UAAMN,SAASD,MAAMC;AACrB,UAAMO,YAAYF;AAGlBL,WAAOQ,OAAO;AAAA,MACZ,GAAGR,OAAOS;AAAAA,MACV,GAAGF;AAAAA,MACHG,SAAS;AAAA,QACP,GAAGV,OAAOS,QAAQC;AAAAA,QAClB,GAAKH,UAAUG,WAAmC,CAAA;AAAA,MACpD;AAAA,IACF,CAAQ;AAGRC,kBAAcX,MAAM;AAEpB,WAAO,MAAM;AAEX,YAAMY,eAAeN,MAAMO,UAAO;AAGlC,UAAIb,OAAOS,QAAQK,MAAM;AACvB,cAAMC,gBAAgBf,OAAOS,QAAQK;AACrC,eAAOlB,IAAIoB,EAAED,eAAe,MAAM,MAAMH,YAAY;AAAA,MACtD;AAGA,aAAOA;AAAAA,IACT;AAAA,EACF;AACF,CAAC;
|
|
1
|
+
{"version":3,"file":"RouterProvider.js","sources":["../../src/RouterProvider.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport { Matches } from './Matches'\nimport { provideRouter } from './routerContext'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterOptions,\n} from '@tanstack/router-core'\n\n// Component that provides router context and renders children\nexport const RouterContextProvider = Vue.defineComponent({\n name: 'RouterContextProvider',\n props: {\n router: {\n type: Object,\n required: true,\n },\n // Rest of router options will be passed as attrs\n },\n setup(props, { attrs, slots }) {\n const router = props.router as AnyRouter\n const restAttrs = attrs as Record<string, any>\n\n // Allow the router to update options on the router instance\n router.update({\n ...router.options,\n ...restAttrs,\n context: {\n ...router.options.context,\n ...((restAttrs.context as Record<string, any>) || {}),\n },\n } as any)\n\n // Provide router to all child components\n provideRouter(router)\n\n return () => {\n // Get child content\n const childContent = slots.default?.()\n\n // If a Wrap component is specified in router options, use it\n if (router.options.Wrap) {\n const WrapComponent = router.options.Wrap\n return Vue.h(WrapComponent, null, () => childContent)\n }\n\n // Unwrap single-element arrays to avoid implicit Fragment\n // that would cause hydration mismatch\n if (Array.isArray(childContent) && childContent.length === 1) {\n return childContent[0]\n }\n\n // Otherwise just return the child content\n return childContent\n }\n },\n})\n\n// The main router provider component that includes matches\nexport const RouterProvider = Vue.defineComponent({\n name: 'RouterProvider',\n props: {\n router: {\n type: Object,\n required: true,\n },\n // Rest of router options will be passed as attrs\n },\n setup(props, { attrs }) {\n const restAttrs = attrs as Record<string, any>\n\n return () => {\n return Vue.h(\n RouterContextProvider,\n {\n router: props.router,\n ...restAttrs,\n },\n {\n default: () => Vue.h(Matches),\n },\n )\n }\n },\n}) as unknown as {\n <TRouter extends AnyRouter = RegisteredRouter>(\n props: {\n router: TRouter\n routeTree?: TRouter['routeTree']\n } & Record<string, any>,\n ): Vue.VNode\n new (): {\n $props: {\n router: AnyRouter\n routeTree?: AnyRouter['routeTree']\n }\n }\n}\n\nexport type RouterProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n> = Omit<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n false,\n TRouter['history'],\n TDehydrated\n >,\n 'context'\n> & {\n router: TRouter\n context?: Partial<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n false,\n TRouter['history'],\n TDehydrated\n >['context']\n >\n}\n"],"names":["RouterContextProvider","Vue","defineComponent","name","props","router","type","Object","required","setup","attrs","slots","restAttrs","update","options","context","provideRouter","childContent","default","Wrap","WrapComponent","h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,OAAO;AAAA,MAC9B,CACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;"}
|
package/dist/esm/ScriptOnce.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import * as Vue from 'vue';
|
|
2
|
+
export declare const ScriptOnce: Vue.DefineComponent<Vue.ExtractPropTypes<{
|
|
3
|
+
children: {
|
|
4
|
+
type: StringConstructor;
|
|
5
|
+
required: true;
|
|
6
|
+
};
|
|
7
|
+
}>, () => import("vue/jsx-runtime").JSX.Element | null, {}, {}, {}, Vue.ComponentOptionsMixin, Vue.ComponentOptionsMixin, {}, string, Vue.PublicProps, Readonly<Vue.ExtractPropTypes<{
|
|
8
|
+
children: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
required: true;
|
|
11
|
+
};
|
|
12
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, Vue.ComponentProvideOptions, true, {}, any>;
|
package/dist/esm/ScriptOnce.js
CHANGED
|
@@ -1,20 +1,40 @@
|
|
|
1
|
+
import * as Vue from "vue";
|
|
1
2
|
import { createVNode } from "vue";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import { useRouter } from "./useRouter.js";
|
|
4
|
+
const ScriptOnce = Vue.defineComponent({
|
|
5
|
+
name: "ScriptOnce",
|
|
6
|
+
props: {
|
|
7
|
+
children: {
|
|
8
|
+
type: String,
|
|
9
|
+
required: true
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
setup(props) {
|
|
13
|
+
const router = useRouter();
|
|
14
|
+
if (router.isServer) {
|
|
15
|
+
return () => createVNode("script", {
|
|
16
|
+
"nonce": router.options.ssr?.nonce,
|
|
17
|
+
"class": "$tsr",
|
|
18
|
+
"innerHTML": props.children
|
|
19
|
+
}, null);
|
|
20
|
+
}
|
|
21
|
+
const mounted = Vue.ref(false);
|
|
22
|
+
Vue.onMounted(() => {
|
|
23
|
+
mounted.value = true;
|
|
24
|
+
});
|
|
25
|
+
return () => {
|
|
26
|
+
if (mounted.value) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return createVNode("script", {
|
|
30
|
+
"nonce": router.options.ssr?.nonce,
|
|
31
|
+
"class": "$tsr",
|
|
32
|
+
"data-allow-mismatch": true,
|
|
33
|
+
"innerHTML": ""
|
|
34
|
+
}, null);
|
|
35
|
+
};
|
|
9
36
|
}
|
|
10
|
-
|
|
11
|
-
"class": "tsr-once",
|
|
12
|
-
"innerHTML": [children, (log ?? true) && process.env.NODE_ENV === "development" ? `console.info(\`Injected From Server:
|
|
13
|
-
${jsesc(children.toString(), {
|
|
14
|
-
quotes: "backtick"
|
|
15
|
-
})}\`)` : "", 'if (typeof __TSR_SSR__ !== "undefined") __TSR_SSR__.cleanScripts()'].filter(Boolean).join("\n")
|
|
16
|
-
}, null);
|
|
17
|
-
}
|
|
37
|
+
});
|
|
18
38
|
export {
|
|
19
39
|
ScriptOnce
|
|
20
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScriptOnce.js","sources":["../../src/ScriptOnce.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"ScriptOnce.js","sources":["../../src/ScriptOnce.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport { useRouter } from './useRouter'\n\nexport const ScriptOnce = Vue.defineComponent({\n name: 'ScriptOnce',\n props: {\n children: {\n type: String,\n required: true,\n },\n },\n setup(props) {\n const router = useRouter()\n\n if (router.isServer) {\n return () => (\n <script\n nonce={router.options.ssr?.nonce}\n class=\"$tsr\"\n innerHTML={props.children}\n />\n )\n }\n\n const mounted = Vue.ref(false)\n Vue.onMounted(() => {\n mounted.value = true\n })\n\n return () => {\n if (mounted.value) {\n return null\n }\n\n return (\n <script\n nonce={router.options.ssr?.nonce}\n class=\"$tsr\"\n data-allow-mismatch\n innerHTML=\"\"\n />\n )\n }\n },\n})\n"],"names":["ScriptOnce","Vue","defineComponent","name","props","children","type","String","required","setup","router","useRouter","isServer","_createVNode","options","ssr","nonce","mounted","ref","onMounted","value"],"mappings":";;;MAGaA,aAAaC,IAAIC,gBAAgB;AAAA,EAC5CC,MAAM;AAAA,EACNC,OAAO;AAAA,IACLC,UAAU;AAAA,MACRC,MAAMC;AAAAA,MACNC,UAAU;AAAA,IACZ;AAAA;EAEFC,MAAML,OAAO;AACX,UAAMM,SAASC,UAAS;AAExB,QAAID,OAAOE,UAAU;AACnB,aAAO,MAAAC,YAAA,UAAA;AAAA,QAAA,SAEIH,OAAOI,QAAQC,KAAKC;AAAAA,QAAK,SAAA;AAAA,QAAA,aAErBZ,MAAMC;AAAAA,SAAQ,IAAA;AAAA,IAG/B;AAEA,UAAMY,UAAUhB,IAAIiB,IAAI,KAAK;AAC7BjB,QAAIkB,UAAU,MAAM;AAClBF,cAAQG,QAAQ;AAAA,IAClB,CAAC;AAED,WAAO,MAAM;AACX,UAAIH,QAAQG,OAAO;AACjB,eAAO;AAAA,MACT;AAEA,aAAAP,YAAA,UAAA;AAAA,QAAA,SAEWH,OAAOI,QAAQC,KAAKC;AAAAA,QAAK,SAAA;AAAA,QAAA,uBAAA;AAAA,QAAA,aAAA;AAAA,MAAA,GAAA,IAAA;AAAA,IAMtC;AAAA,EACF;AACF,CAAC;"}
|
package/dist/esm/Scripts.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import * as Vue from 'vue';
|
|
2
|
+
export declare const Scripts: Vue.DefineComponent<{}, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, Vue.ComponentOptionsMixin, Vue.ComponentOptionsMixin, {}, string, Vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, Vue.ComponentProvideOptions, true, {}, any>;
|
package/dist/esm/Scripts.js
CHANGED
|
@@ -1,45 +1,111 @@
|
|
|
1
|
+
import * as Vue from "vue";
|
|
1
2
|
import { createVNode, Fragment, mergeProps } from "vue";
|
|
2
3
|
import { Asset } from "./Asset.js";
|
|
3
4
|
import { useRouterState } from "./useRouterState.js";
|
|
4
5
|
import { useRouter } from "./useRouter.js";
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
const VUE_DEFER_SCRIPT = "self.$_TSR_DEFER=true";
|
|
7
|
+
const Scripts = Vue.defineComponent({
|
|
8
|
+
name: "Scripts",
|
|
9
|
+
setup() {
|
|
10
|
+
const router = useRouter();
|
|
11
|
+
const nonce = router.options.ssr?.nonce;
|
|
12
|
+
const assetScripts = useRouterState({
|
|
13
|
+
select: (state) => {
|
|
14
|
+
const assetScripts2 = [];
|
|
15
|
+
const manifest = router.ssr?.manifest;
|
|
16
|
+
if (!manifest) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
state.matches.map((match) => router.looseRoutesById[match.routeId]).forEach((route) => manifest.routes[route.id]?.assets?.filter((d) => d.tag === "script").forEach((asset) => {
|
|
20
|
+
assetScripts2.push({
|
|
21
|
+
tag: "script",
|
|
22
|
+
attrs: {
|
|
23
|
+
...asset.attrs,
|
|
24
|
+
nonce
|
|
25
|
+
},
|
|
26
|
+
children: asset.children
|
|
27
|
+
});
|
|
28
|
+
}));
|
|
29
|
+
return assetScripts2;
|
|
13
30
|
}
|
|
14
|
-
|
|
15
|
-
|
|
31
|
+
});
|
|
32
|
+
const scripts = useRouterState({
|
|
33
|
+
select: (state) => ({
|
|
34
|
+
scripts: state.matches.map((match) => match.scripts).flat(1).filter(Boolean).map(({
|
|
35
|
+
children,
|
|
36
|
+
...script
|
|
37
|
+
}) => ({
|
|
38
|
+
tag: "script",
|
|
39
|
+
attrs: {
|
|
40
|
+
...script,
|
|
41
|
+
nonce
|
|
42
|
+
},
|
|
43
|
+
children
|
|
44
|
+
}))
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
const mounted = Vue.ref(false);
|
|
48
|
+
Vue.onMounted(() => {
|
|
49
|
+
mounted.value = true;
|
|
50
|
+
});
|
|
51
|
+
return () => {
|
|
52
|
+
const allScripts = [];
|
|
53
|
+
if (router.serverSsr) {
|
|
54
|
+
allScripts.push({
|
|
16
55
|
tag: "script",
|
|
17
|
-
attrs:
|
|
18
|
-
|
|
56
|
+
attrs: {
|
|
57
|
+
nonce
|
|
58
|
+
},
|
|
59
|
+
children: VUE_DEFER_SCRIPT
|
|
19
60
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
61
|
+
const serverBufferedScript = router.serverSsr.takeBufferedScripts();
|
|
62
|
+
if (serverBufferedScript) {
|
|
63
|
+
allScripts.push(serverBufferedScript);
|
|
64
|
+
}
|
|
65
|
+
} else if (router.ssr && !mounted.value) {
|
|
66
|
+
allScripts.push({
|
|
67
|
+
tag: "script",
|
|
68
|
+
attrs: {
|
|
69
|
+
nonce,
|
|
70
|
+
"data-allow-mismatch": true
|
|
71
|
+
},
|
|
72
|
+
children: ""
|
|
73
|
+
});
|
|
74
|
+
allScripts.push({
|
|
75
|
+
tag: "script",
|
|
76
|
+
attrs: {
|
|
77
|
+
nonce,
|
|
78
|
+
class: "$tsr",
|
|
79
|
+
id: "$tsr-stream-barrier",
|
|
80
|
+
"data-allow-mismatch": true
|
|
81
|
+
},
|
|
82
|
+
children: ""
|
|
83
|
+
});
|
|
84
|
+
for (const asset of assetScripts.value) {
|
|
85
|
+
allScripts.push({
|
|
86
|
+
tag: "script",
|
|
87
|
+
attrs: {
|
|
88
|
+
...asset.attrs,
|
|
89
|
+
"data-allow-mismatch": true
|
|
90
|
+
},
|
|
91
|
+
children: ""
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
for (const script of scripts.value.scripts) {
|
|
96
|
+
allScripts.push(script);
|
|
97
|
+
}
|
|
98
|
+
if (mounted.value || router.serverSsr) {
|
|
99
|
+
for (const asset of assetScripts.value) {
|
|
100
|
+
allScripts.push(asset);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return createVNode(Fragment, null, [allScripts.map((asset, i) => createVNode(Asset, mergeProps(asset, {
|
|
104
|
+
"key": `tsr-scripts-${asset.tag}-${i}`
|
|
105
|
+
}), null))]);
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
});
|
|
43
109
|
export {
|
|
44
110
|
Scripts
|
|
45
111
|
};
|
package/dist/esm/Scripts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scripts.js","sources":["../../src/Scripts.tsx"],"sourcesContent":["import { Asset } from './Asset'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport type { RouterManagedTag } from '@tanstack/router-core'\n\nexport const Scripts = ()
|
|
1
|
+
{"version":3,"file":"Scripts.js","sources":["../../src/Scripts.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport { Asset } from './Asset'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport type { RouterManagedTag } from '@tanstack/router-core'\n\n// Script that sets the defer flag for Vue - must run BEFORE TSR bootstrap script\n// This prevents $_TSR.c() from removing scripts until Vue hydration is complete\nconst VUE_DEFER_SCRIPT = 'self.$_TSR_DEFER=true'\n\nexport const Scripts = Vue.defineComponent({\n name: 'Scripts',\n setup() {\n const router = useRouter()\n const nonce = router.options.ssr?.nonce\n\n const assetScripts = useRouterState({\n select: (state) => {\n const assetScripts: Array<RouterManagedTag> = []\n const manifest = router.ssr?.manifest\n\n if (!manifest) {\n return []\n }\n\n state.matches\n .map((match) => router.looseRoutesById[match.routeId]!)\n .forEach((route) =>\n manifest.routes[route.id]?.assets\n ?.filter((d) => d.tag === 'script')\n .forEach((asset) => {\n assetScripts.push({\n tag: 'script',\n attrs: { ...asset.attrs, nonce },\n children: asset.children,\n } as RouterManagedTag)\n }),\n )\n\n return assetScripts\n },\n })\n\n const scripts = useRouterState({\n select: (state) => ({\n scripts: (\n state.matches\n .map((match) => match.scripts!)\n .flat(1)\n .filter(Boolean) as Array<RouterManagedTag>\n ).map(({ children, ...script }) => ({\n tag: 'script' as const,\n attrs: {\n ...script,\n nonce,\n },\n children,\n })),\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 allScripts.push({\n tag: 'script',\n attrs: { nonce },\n children: VUE_DEFER_SCRIPT,\n } as RouterManagedTag)\n\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 class: '$tsr',\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"],"names":["VUE_DEFER_SCRIPT","Scripts","Vue","defineComponent","name","setup","router","useRouter","nonce","options","ssr","assetScripts","useRouterState","select","state","manifest","matches","map","match","looseRoutesById","routeId","forEach","route","routes","id","assets","filter","d","tag","asset","push","attrs","children","scripts","flat","Boolean","script","mounted","ref","onMounted","value","allScripts","serverSsr","serverBufferedScript","takeBufferedScripts","class","_createVNode","_Fragment","i","Asset","_mergeProps"],"mappings":";;;;;AAQA,MAAMA,mBAAmB;MAEZC,UAAUC,IAAIC,gBAAgB;AAAA,EACzCC,MAAM;AAAA,EACNC,QAAQ;AACN,UAAMC,SAASC,UAAS;AACxB,UAAMC,QAAQF,OAAOG,QAAQC,KAAKF;AAElC,UAAMG,eAAeC,eAAe;AAAA,MAClCC,QAASC,WAAU;AACjB,cAAMH,gBAAwC,CAAA;AAC9C,cAAMI,WAAWT,OAAOI,KAAKK;AAE7B,YAAI,CAACA,UAAU;AACb,iBAAO,CAAA;AAAA,QACT;AAEAD,cAAME,QACHC,IAAKC,WAAUZ,OAAOa,gBAAgBD,MAAME,OAAO,CAAE,EACrDC,QAASC,WACRP,SAASQ,OAAOD,MAAME,EAAE,GAAGC,QACvBC,OAAQC,OAAMA,EAAEC,QAAQ,QAAQ,EACjCP,QAASQ,WAAU;AAClBlB,UAAAA,cAAamB,KAAK;AAAA,YAChBF,KAAK;AAAA,YACLG,OAAO;AAAA,cAAE,GAAGF,MAAME;AAAAA,cAAOvB;AAAAA;YACzBwB,UAAUH,MAAMG;AAAAA,UAClB,CAAqB;AAAA,QACvB,CAAC,CACL;AAEF,eAAOrB;AAAAA,MACT;AAAA,IACF,CAAC;AAED,UAAMsB,UAAUrB,eAAe;AAAA,MAC7BC,QAASC,YAAW;AAAA,QAClBmB,SACEnB,MAAME,QACHC,IAAKC,WAAUA,MAAMe,OAAQ,EAC7BC,KAAK,CAAC,EACNR,OAAOS,OAAO,EACjBlB,IAAI,CAAC;AAAA,UAAEe;AAAAA,UAAU,GAAGI;A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C,WAAW;AACrC,mBAAWb,SAASlB,aAAa6B,OAAO;AACtCC,qBAAWX,KAAKD,KAAK;AAAA,QACvB;AAAA,MACF;AAEA,aAAAiB,YAAAC,iBAEKN,WAAWxB,IAAI,CAACY,OAAOmB,MAACF,YAAAG,OAAAC,WACZrB,OAAK;AAAA,QAAA,OAAO,eAAeA,MAAMD,GAAG,IAAIoB,CAAC;AAAA,MAAE,CAAA,GAAA,IAAA,CACvD,CAAC,CAAA;AAAA,IAGR;AAAA,EACF;AACF,CAAC;"}
|
|
@@ -1,2 +1,18 @@
|
|
|
1
1
|
import * as Vue from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Composable that sets up router transition logic.
|
|
4
|
+
* This is called from MatchesContent to set up:
|
|
5
|
+
* - router.startTransition
|
|
6
|
+
* - router.startViewTransition
|
|
7
|
+
* - History subscription
|
|
8
|
+
* - Router event watchers
|
|
9
|
+
*
|
|
10
|
+
* Must be called during component setup phase.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useTransitionerSetup(): void;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use useTransitionerSetup() composable instead.
|
|
15
|
+
* This component is kept for backwards compatibility but the setup logic
|
|
16
|
+
* has been moved to useTransitionerSetup() for better SSR hydration.
|
|
17
|
+
*/
|
|
2
18
|
export declare const Transitioner: Vue.DefineComponent<{}, () => null, {}, {}, {}, Vue.ComponentOptionsMixin, Vue.ComponentOptionsMixin, {}, string, Vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, Vue.ComponentProvideOptions, true, {}, any>;
|