@tanstack/vue-router 1.167.5 → 1.168.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/Match.js +55 -61
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.js +8 -15
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/Scripts.js +7 -6
- package/dist/esm/Scripts.js.map +1 -1
- package/dist/esm/Transitioner.js +18 -24
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/headContentUtils.js +13 -15
- package/dist/esm/headContentUtils.js.map +1 -1
- package/dist/esm/index.dev.js +6 -6
- package/dist/esm/index.js +6 -6
- package/dist/esm/link.js +242 -178
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/matchContext.d.ts +8 -14
- package/dist/esm/matchContext.js +11 -9
- package/dist/esm/matchContext.js.map +1 -1
- package/dist/esm/not-found.js +6 -3
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/router.js +2 -1
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerStores.d.ts +13 -0
- package/dist/esm/routerStores.js +33 -0
- package/dist/esm/routerStores.js.map +1 -0
- package/dist/esm/ssr/RouterClient.js +1 -1
- package/dist/esm/ssr/RouterClient.js.map +1 -1
- package/dist/esm/ssr/renderRouterToStream.js +2 -2
- package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
- package/dist/esm/ssr/renderRouterToString.js +1 -1
- package/dist/esm/ssr/renderRouterToString.js.map +1 -1
- package/dist/esm/useCanGoBack.d.ts +1 -1
- package/dist/esm/useCanGoBack.js +3 -2
- package/dist/esm/useCanGoBack.js.map +1 -1
- package/dist/esm/useLocation.js +3 -2
- package/dist/esm/useLocation.js.map +1 -1
- package/dist/esm/useMatch.js +29 -19
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useRouterState.js +4 -4
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/source/Match.jsx +121 -159
- package/dist/source/Match.jsx.map +1 -1
- package/dist/source/Matches.jsx +11 -28
- package/dist/source/Matches.jsx.map +1 -1
- package/dist/source/Scripts.jsx +32 -35
- package/dist/source/Scripts.jsx.map +1 -1
- package/dist/source/Transitioner.jsx +19 -21
- package/dist/source/Transitioner.jsx.map +1 -1
- package/dist/source/headContentUtils.jsx +51 -61
- package/dist/source/headContentUtils.jsx.map +1 -1
- package/dist/source/link.jsx +298 -249
- package/dist/source/link.jsx.map +1 -1
- package/dist/source/matchContext.d.ts +8 -14
- package/dist/source/matchContext.jsx +17 -23
- package/dist/source/matchContext.jsx.map +1 -1
- package/dist/source/not-found.jsx +6 -5
- package/dist/source/not-found.jsx.map +1 -1
- package/dist/source/router.js +2 -1
- package/dist/source/router.js.map +1 -1
- package/dist/source/routerStores.d.ts +13 -0
- package/dist/source/routerStores.js +37 -0
- package/dist/source/routerStores.js.map +1 -0
- package/dist/source/ssr/RouterClient.jsx +1 -1
- package/dist/source/ssr/RouterClient.jsx.map +1 -1
- package/dist/source/ssr/renderRouterToStream.jsx +2 -2
- package/dist/source/ssr/renderRouterToStream.jsx.map +1 -1
- package/dist/source/ssr/renderRouterToString.jsx +1 -1
- package/dist/source/ssr/renderRouterToString.jsx.map +1 -1
- package/dist/source/useCanGoBack.d.ts +1 -1
- package/dist/source/useCanGoBack.js +4 -2
- package/dist/source/useCanGoBack.js.map +1 -1
- package/dist/source/useLocation.jsx +4 -4
- package/dist/source/useLocation.jsx.map +1 -1
- package/dist/source/useMatch.jsx +60 -38
- package/dist/source/useMatch.jsx.map +1 -1
- package/dist/source/useRouterState.jsx +4 -4
- package/dist/source/useRouterState.jsx.map +1 -1
- package/package.json +2 -2
- package/skills/vue-router/SKILL.md +3 -0
- package/src/Match.tsx +168 -180
- package/src/Matches.tsx +18 -31
- package/src/Scripts.tsx +40 -40
- package/src/Transitioner.tsx +35 -23
- package/src/headContentUtils.tsx +101 -107
- package/src/link.tsx +445 -300
- package/src/matchContext.tsx +23 -25
- package/src/not-found.tsx +9 -5
- package/src/router.ts +2 -1
- package/src/routerStores.ts +54 -0
- package/src/ssr/RouterClient.tsx +1 -1
- package/src/ssr/renderRouterToStream.tsx +2 -2
- package/src/ssr/renderRouterToString.tsx +1 -1
- package/src/useCanGoBack.ts +7 -2
- package/src/useLocation.tsx +8 -5
- package/src/useMatch.tsx +95 -49
- package/src/useRouterState.tsx +6 -4
package/dist/esm/link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","names":["Vue","deepEqual","exactPathTest","isDangerousProtocol","preloadWarning","removeTrailingSlash","useRouterState","useRouter","useIntersectionObserver","useMatches","timeoutMap","WeakMap","useLinkProps","options","router","isTransitioning","ref","hasRenderFetched","console","warn","computed","type","URL","to","buildLocationKey","select","s","leaf","matches","length","search","hash","location","path","pathname","from","fullPath","_options","value","next","buildLocation","preload","reloadDocument","defaultPreload","preloadDelay","defaultPreloadDelay","isActive","activeOptions","exact","testExact","basepath","currentPathSplit","split","nextPathSplit","pathIsFuzzyEqual","every","d","i","includeSearch","searchTest","partial","ignoreUndefined","explicitUndefined","includeHash","doPreload","preloadRoute","catch","err","preloadViewportIoCallback","entry","isIntersecting","rootMargin","disabled","effect","getPropsSafeToSpread","result","optionRecord","key","includes","protocolAllowlist","process","env","NODE_ENV","safeProps","target","style","class","onClick","onBlur","onFocus","onMouseEnter","onMouseLeave","onMouseOver","onMouseOut","onTouchStart","Object","keys","forEach","undefined","externalProps","href","handleClick","e","elementTarget","currentTarget","getAttribute","effectiveTarget","isCtrlEvent","defaultPrevented","button","preventDefault","unsub","subscribe","navigate","replace","resetScroll","hashScrollIntoView","startTransition","viewTransition","ignoreBlocker","enqueueIntentPreload","eventTarget","has","set","setTimeout","delete","handleTouchStart","_","handleLeave","id","get","clearTimeout","composeEventHandlers","handlers","event","handler","resolvedActiveProps","activeProps","props","resolvedInactiveProps","inactiveProps","resolvedClassName","classes","filter","Boolean","join","resolvedStyle","assign","nextLocation","maskedLocation","publicHref","external","history","createHref","staticEventHandlers","onMouseenter","onMouseover","onMouseleave","onMouseout","onTouchstart","computedProps","role","activeP","inactiveP","createLink","Comp","defineComponent","name","inheritAttrs","setup","attrs","slots","h","LinkImpl","_asChild","allProps","linkPropsComputed","Component","linkProps","slotContent","default","svgLinkProps","children","Link","metaKey","altKey","ctrlKey","shiftKey","linkOptions"],"sources":["../../src/link.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport {\n deepEqual,\n exactPathTest,\n isDangerousProtocol,\n preloadWarning,\n removeTrailingSlash,\n} from '@tanstack/router-core'\n\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { useIntersectionObserver } from './utils'\nimport { useMatches } from './Matches'\n\nimport type {\n AnyRouter,\n Constrain,\n LinkOptions,\n RegisteredRouter,\n RoutePaths,\n} from '@tanstack/router-core'\nimport type { AnchorHTMLAttributes, ReservedProps } from '@vue/runtime-dom'\nimport type {\n ValidateLinkOptions,\n ValidateLinkOptionsArray,\n} from './typePrimitives'\n\ntype EventHandler<TEvent = Event> = (e: TEvent) => void\n\nconst timeoutMap = new WeakMap<EventTarget, ReturnType<typeof setTimeout>>()\n\ntype DataAttributes = {\n [K in `data-${string}`]?: unknown\n}\n\ntype LinkHTMLAttributes = AnchorHTMLAttributes &\n ReservedProps &\n DataAttributes & {\n // Vue's runtime-dom types use lowercase event names.\n // Also accept camelCase versions for external API compatibility.\n onMouseEnter?: EventHandler<MouseEvent>\n onMouseLeave?: EventHandler<MouseEvent>\n onMouseOver?: EventHandler<MouseEvent>\n onMouseOut?: EventHandler<MouseEvent>\n onTouchStart?: EventHandler<TouchEvent>\n\n // `disabled` is not a valid <a> attribute, but is useful when using `asChild`.\n disabled?: boolean\n }\n\ninterface StyledProps {\n class?: LinkHTMLAttributes['class']\n style?: LinkHTMLAttributes['style']\n [key: string]: unknown\n}\n\ntype PropsOfComponent<TComp> =\n // Functional components\n TComp extends (props: infer P, ...args: Array<unknown>) => any\n ? P\n : // Vue components (defineComponent, class components, etc)\n TComp extends Vue.Component<infer P>\n ? P\n : Record<string, unknown>\n\nexport function useLinkProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '',\n>(\n options: UseLinkPropsOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n): LinkHTMLAttributes {\n const router = useRouter()\n const isTransitioning = Vue.ref(false)\n let hasRenderFetched = false\n\n // Ensure router is defined before proceeding\n if (!router) {\n console.warn('useRouter must be used inside a <RouterProvider> component!')\n return Vue.computed(() => ({})) as unknown as LinkHTMLAttributes\n }\n\n // Determine if the link is external or internal\n const type = Vue.computed(() => {\n try {\n new URL(`${options.to}`)\n return 'external'\n } catch {\n return 'internal'\n }\n })\n\n const buildLocationKey = useRouterState({\n select: (s) => {\n const leaf = s.matches[s.matches.length - 1]\n return {\n search: leaf?.search,\n hash: s.location.hash,\n path: leaf?.pathname, // path + params\n }\n },\n })\n\n // when `from` is not supplied, use the leaf route of the current matches as the `from` location\n const from = useMatches({\n select: (matches) => options.from ?? matches[matches.length - 1]?.fullPath,\n })\n\n const _options = Vue.computed(() => ({\n ...options,\n from: from.value,\n }))\n\n const next = Vue.computed(() => {\n // Depend on search to rebuild when search changes\n buildLocationKey.value\n return router.buildLocation(_options.value as any)\n })\n\n const preload = Vue.computed(() => {\n if (_options.value.reloadDocument) {\n return false\n }\n return options.preload ?? router.options.defaultPreload\n })\n\n const preloadDelay = Vue.computed(\n () => options.preloadDelay ?? router.options.defaultPreloadDelay ?? 0,\n )\n\n const isActive = useRouterState({\n select: (s) => {\n const activeOptions = options.activeOptions\n if (activeOptions?.exact) {\n const testExact = exactPathTest(\n s.location.pathname,\n next.value.pathname,\n router.basepath,\n )\n if (!testExact) {\n return false\n }\n } else {\n const currentPathSplit = removeTrailingSlash(\n s.location.pathname,\n router.basepath,\n ).split('/')\n const nextPathSplit = removeTrailingSlash(\n next.value?.pathname,\n router.basepath,\n )?.split('/')\n\n const pathIsFuzzyEqual = nextPathSplit?.every(\n (d, i) => d === currentPathSplit[i],\n )\n if (!pathIsFuzzyEqual) {\n return false\n }\n }\n\n if (activeOptions?.includeSearch ?? true) {\n const searchTest = deepEqual(s.location.search, next.value.search, {\n partial: !activeOptions?.exact,\n ignoreUndefined: !activeOptions?.explicitUndefined,\n })\n if (!searchTest) {\n return false\n }\n }\n\n if (activeOptions?.includeHash) {\n return s.location.hash === next.value.hash\n }\n return true\n },\n })\n\n const doPreload = () =>\n router.preloadRoute(_options.value as any).catch((err: any) => {\n console.warn(err)\n console.warn(preloadWarning)\n })\n\n const preloadViewportIoCallback = (\n entry: IntersectionObserverEntry | undefined,\n ) => {\n if (entry?.isIntersecting) {\n doPreload()\n }\n }\n\n const ref = Vue.ref<Element | null>(null)\n\n useIntersectionObserver(\n ref,\n preloadViewportIoCallback,\n { rootMargin: '100px' },\n { disabled: () => !!options.disabled || !(preload.value === 'viewport') },\n )\n\n Vue.effect(() => {\n if (hasRenderFetched) {\n return\n }\n if (!options.disabled && preload.value === 'render') {\n doPreload()\n hasRenderFetched = true\n }\n })\n\n // Create safe props that can be spread\n const getPropsSafeToSpread = () => {\n const result: Record<string, any> = {}\n const optionRecord = options as unknown as Record<string, unknown>\n for (const key in options) {\n if (\n ![\n 'activeProps',\n 'inactiveProps',\n 'activeOptions',\n 'to',\n 'preload',\n 'preloadDelay',\n 'hashScrollIntoView',\n 'replace',\n 'startTransition',\n 'resetScroll',\n 'viewTransition',\n 'children',\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onBlur',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOver',\n 'onMouseOut',\n 'onTouchStart',\n 'ignoreBlocker',\n 'params',\n 'search',\n 'hash',\n 'state',\n 'mask',\n 'reloadDocument',\n '_asChild',\n 'from',\n 'additionalProps',\n ].includes(key)\n ) {\n result[key] = optionRecord[key]\n }\n }\n return result\n }\n\n if (type.value === 'external') {\n // Block dangerous protocols like javascript:, blob:, data:\n if (isDangerousProtocol(options.to as string, router.protocolAllowlist)) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Blocked Link with dangerous protocol: ${options.to}`)\n }\n // Return props without href to prevent navigation\n const safeProps: Record<string, unknown> = {\n ...getPropsSafeToSpread(),\n ref,\n // No href attribute - blocks the dangerous protocol\n target: options.target,\n disabled: options.disabled,\n style: options.style,\n class: options.class,\n onClick: options.onClick,\n onBlur: options.onBlur,\n onFocus: options.onFocus,\n onMouseEnter: options.onMouseEnter,\n onMouseLeave: options.onMouseLeave,\n onMouseOver: options.onMouseOver,\n onMouseOut: options.onMouseOut,\n onTouchStart: options.onTouchStart,\n }\n\n // Remove undefined values\n Object.keys(safeProps).forEach((key) => {\n if (safeProps[key] === undefined) {\n delete safeProps[key]\n }\n })\n\n return Vue.computed(\n () => safeProps as LinkHTMLAttributes,\n ) as unknown as LinkHTMLAttributes\n }\n\n // External links just have simple props\n const externalProps: Record<string, unknown> = {\n ...getPropsSafeToSpread(),\n ref,\n href: options.to,\n target: options.target,\n disabled: options.disabled,\n style: options.style,\n class: options.class,\n onClick: options.onClick,\n onBlur: options.onBlur,\n onFocus: options.onFocus,\n onMouseEnter: options.onMouseEnter,\n onMouseLeave: options.onMouseLeave,\n onMouseOver: options.onMouseOver,\n onMouseOut: options.onMouseOut,\n onTouchStart: options.onTouchStart,\n }\n\n // Remove undefined values\n Object.keys(externalProps).forEach((key) => {\n if (externalProps[key] === undefined) {\n delete externalProps[key]\n }\n })\n\n return Vue.computed(\n () => externalProps as LinkHTMLAttributes,\n ) as unknown as LinkHTMLAttributes\n }\n\n // The click handler\n const handleClick = (e: PointerEvent): void => {\n // Check actual element's target attribute as fallback\n const elementTarget = (\n e.currentTarget as HTMLAnchorElement | SVGAElement\n )?.getAttribute('target')\n const effectiveTarget =\n options.target !== undefined ? options.target : elementTarget\n\n if (\n !options.disabled &&\n !isCtrlEvent(e) &&\n !e.defaultPrevented &&\n (!effectiveTarget || effectiveTarget === '_self') &&\n e.button === 0\n ) {\n // Don't prevent default or handle navigation if reloadDocument is true\n if (_options.value.reloadDocument) {\n return\n }\n\n e.preventDefault()\n\n isTransitioning.value = true\n\n const unsub = router.subscribe('onResolved', () => {\n unsub()\n isTransitioning.value = false\n })\n\n // All is well? Navigate!\n router.navigate({\n ..._options.value,\n replace: options.replace,\n resetScroll: options.resetScroll,\n hashScrollIntoView: options.hashScrollIntoView,\n startTransition: options.startTransition,\n viewTransition: options.viewTransition,\n ignoreBlocker: options.ignoreBlocker,\n })\n }\n }\n\n const enqueueIntentPreload = (e: MouseEvent | FocusEvent) => {\n if (options.disabled || preload.value !== 'intent') return\n\n if (!preloadDelay.value) {\n doPreload()\n return\n }\n\n const eventTarget = e.currentTarget || e.target\n\n if (!eventTarget || timeoutMap.has(eventTarget)) return\n\n timeoutMap.set(\n eventTarget,\n setTimeout(() => {\n timeoutMap.delete(eventTarget)\n doPreload()\n }, preloadDelay.value),\n )\n }\n\n const handleTouchStart = (_: TouchEvent) => {\n if (options.disabled || preload.value !== 'intent') return\n doPreload()\n }\n\n const handleLeave = (e: MouseEvent | FocusEvent) => {\n if (options.disabled) return\n const eventTarget = e.currentTarget || e.target\n\n if (eventTarget) {\n const id = timeoutMap.get(eventTarget)\n clearTimeout(id)\n timeoutMap.delete(eventTarget)\n }\n }\n\n // Helper to compose event handlers - with explicit return type and better type handling\n function composeEventHandlers<T extends Event>(\n handlers: Array<EventHandler<T> | undefined>,\n ): (e: T) => void {\n return (event: T) => {\n for (const handler of handlers) {\n if (handler) {\n handler(event)\n }\n }\n }\n }\n\n // Get the active and inactive props\n const resolvedActiveProps = Vue.computed<StyledProps>(() => {\n const activeProps = options.activeProps || (() => ({ class: 'active' }))\n const props = isActive.value\n ? typeof activeProps === 'function'\n ? activeProps()\n : activeProps\n : {}\n\n return props || { class: undefined, style: undefined }\n })\n\n const resolvedInactiveProps = Vue.computed<StyledProps>(() => {\n const inactiveProps = options.inactiveProps || (() => ({}))\n const props = isActive.value\n ? {}\n : typeof inactiveProps === 'function'\n ? inactiveProps()\n : inactiveProps\n\n return props || { class: undefined, style: undefined }\n })\n\n const resolvedClassName = Vue.computed(() => {\n const classes = [\n options.class,\n resolvedActiveProps.value?.class,\n resolvedInactiveProps.value?.class,\n ].filter(Boolean)\n return classes.length ? classes.join(' ') : undefined\n })\n\n const resolvedStyle = Vue.computed(() => {\n const result: Record<string, string | number> = {}\n\n // Merge styles from all sources\n if (options.style) {\n Object.assign(result, options.style)\n }\n\n if (resolvedActiveProps.value?.style) {\n Object.assign(result, resolvedActiveProps.value.style)\n }\n\n if (resolvedInactiveProps.value?.style) {\n Object.assign(result, resolvedInactiveProps.value.style)\n }\n\n return Object.keys(result).length > 0 ? result : undefined\n })\n\n const href = Vue.computed(() => {\n if (options.disabled) {\n return undefined\n }\n const nextLocation = next.value\n const location = nextLocation?.maskedLocation ?? nextLocation\n\n // Use publicHref - it contains the correct href for display\n // When a rewrite changes the origin, publicHref is the full URL\n // Otherwise it's the origin-stripped path\n // This avoids constructing URL objects in the hot path\n const publicHref = location?.publicHref\n if (!publicHref) return undefined\n\n const external = location?.external\n if (external) return publicHref\n\n return router.history.createHref(publicHref) || '/'\n })\n\n // Create static event handlers that don't change between renders\n const staticEventHandlers = {\n onClick: composeEventHandlers<PointerEvent>([\n options.onClick,\n handleClick,\n ]) as any,\n onBlur: composeEventHandlers<FocusEvent>([\n options.onBlur,\n handleLeave,\n ]) as any,\n onFocus: composeEventHandlers<FocusEvent>([\n options.onFocus,\n enqueueIntentPreload,\n ]) as any,\n onMouseenter: composeEventHandlers<MouseEvent>([\n options.onMouseEnter,\n enqueueIntentPreload,\n ]) as any,\n onMouseover: composeEventHandlers<MouseEvent>([\n options.onMouseOver,\n enqueueIntentPreload,\n ]) as any,\n onMouseleave: composeEventHandlers<MouseEvent>([\n options.onMouseLeave,\n handleLeave,\n ]) as any,\n onMouseout: composeEventHandlers<MouseEvent>([\n options.onMouseOut,\n handleLeave,\n ]) as any,\n onTouchstart: composeEventHandlers<TouchEvent>([\n options.onTouchStart,\n handleTouchStart,\n ]) as any,\n }\n\n // Compute all props synchronously to avoid hydration mismatches\n // Using Vue.computed ensures props are calculated at render time, not after\n const computedProps = Vue.computed<LinkHTMLAttributes>(() => {\n const result: Record<string, unknown> = {\n ...getPropsSafeToSpread(),\n href: href.value,\n ref,\n ...staticEventHandlers,\n disabled: !!options.disabled,\n target: options.target,\n }\n\n // Add style if present\n if (resolvedStyle.value) {\n result.style = resolvedStyle.value\n }\n\n // Add class if present\n if (resolvedClassName.value) {\n result.class = resolvedClassName.value\n }\n\n // Add disabled props\n if (options.disabled) {\n result.role = 'link'\n result['aria-disabled'] = true\n }\n\n // Add active status\n if (isActive.value) {\n result['data-status'] = 'active'\n result['aria-current'] = 'page'\n }\n\n // Add transitioning status\n if (isTransitioning.value) {\n result['data-transitioning'] = 'transitioning'\n }\n\n // Merge active/inactive props (excluding class and style which are handled above)\n const activeP = resolvedActiveProps.value\n const inactiveP = resolvedInactiveProps.value\n\n for (const key of Object.keys(activeP)) {\n if (key !== 'class' && key !== 'style') {\n result[key] = (activeP as any)[key]\n }\n }\n for (const key of Object.keys(inactiveP)) {\n if (key !== 'class' && key !== 'style') {\n result[key] = (inactiveP as any)[key]\n }\n }\n\n return result\n })\n\n // Return the computed ref itself - callers should access .value\n return computedProps as unknown as LinkHTMLAttributes\n}\n\n// Type definitions\nexport type UseLinkPropsOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n LinkHTMLAttributes\n\nexport type ActiveLinkOptions<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n ActiveLinkOptionProps<TComp>\n\ntype ActiveLinkProps<TComp> = Partial<\n (TComp extends keyof HTMLElementTagNameMap\n ? LinkHTMLAttributes\n : PropsOfComponent<TComp>) & {\n [key: `data-${string}`]: unknown\n }\n>\n\nexport interface ActiveLinkOptionProps<TComp = 'a'> {\n /**\n * A function that returns additional props for the `active` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n activeProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n /**\n * A function that returns additional props for the `inactive` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n inactiveProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n}\n\nexport type LinkProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n LinkPropsChildren\n\nexport interface LinkPropsChildren {\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 | Vue.VNodeChild\n | ((state: {\n isActive: boolean\n isTransitioning: boolean\n }) => Vue.VNodeChild)\n}\n\ntype LinkComponentVueProps<TComp> = TComp extends keyof HTMLElementTagNameMap\n ? Omit<LinkHTMLAttributes, keyof CreateLinkProps>\n : Omit<PropsOfComponent<TComp>, keyof CreateLinkProps>\n\nexport type LinkComponentProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkComponentVueProps<TComp> &\n LinkProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>\n\nexport type CreateLinkProps = LinkProps<\n any,\n any,\n string,\n string,\n string,\n string\n>\n\nexport type LinkComponent<\n in out TComp,\n in out TDefaultFrom extends string = string,\n> = <\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = TDefaultFrom,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(\n props: LinkComponentProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n) => Vue.VNode\n\nexport interface LinkComponentRoute<\n in out TDefaultFrom extends string = string,\n> {\n defaultFrom: TDefaultFrom;\n <\n TRouter extends AnyRouter = RegisteredRouter,\n const TTo extends string | undefined = undefined,\n const TMaskTo extends string = '',\n >(\n props: LinkComponentProps<\n 'a',\n TRouter,\n this['defaultFrom'],\n TTo,\n this['defaultFrom'],\n TMaskTo\n >,\n ): Vue.VNode\n}\n\nexport function createLink<const TComp>(\n Comp: Constrain<TComp, any, (props: CreateLinkProps) => Vue.VNode>,\n): LinkComponent<TComp> {\n return Vue.defineComponent({\n name: 'CreatedLink',\n inheritAttrs: false,\n setup(_, { attrs, slots }) {\n return () => Vue.h(LinkImpl as any, { ...attrs, _asChild: Comp }, slots)\n },\n }) as any\n}\n\nconst LinkImpl = Vue.defineComponent({\n name: 'Link',\n inheritAttrs: false,\n props: [\n '_asChild',\n 'to',\n 'preload',\n 'preloadDelay',\n 'activeProps',\n 'inactiveProps',\n 'activeOptions',\n 'from',\n 'search',\n 'params',\n 'hash',\n 'state',\n 'mask',\n 'reloadDocument',\n 'disabled',\n 'additionalProps',\n 'viewTransition',\n 'resetScroll',\n 'startTransition',\n 'hashScrollIntoView',\n 'replace',\n 'ignoreBlocker',\n 'target',\n ],\n setup(props, { attrs, slots }) {\n // Call useLinkProps ONCE during setup with combined props and attrs\n // The returned object is a computed ref that updates reactively\n const allProps = { ...props, ...attrs }\n const linkPropsComputed = useLinkProps(\n allProps as any,\n ) as unknown as Vue.ComputedRef<LinkHTMLAttributes>\n\n return () => {\n const Component = props._asChild || 'a'\n\n // Access the computed value to get fresh props each render\n const linkProps = linkPropsComputed.value\n\n const isActive = linkProps['data-status'] === 'active'\n const isTransitioning =\n linkProps['data-transitioning'] === 'transitioning'\n\n // Create the slot content or empty array if no default slot\n const slotContent = slots.default\n ? slots.default({\n isActive,\n isTransitioning,\n })\n : []\n\n // Special handling for SVG links - wrap an <a> inside the SVG\n if (Component === 'svg') {\n // Create props without class for svg link\n const svgLinkProps = { ...linkProps }\n delete svgLinkProps.class\n return Vue.h('svg', {}, [Vue.h('a', svgLinkProps, slotContent)])\n }\n\n // For custom functional components (non-string), pass children as a prop\n // since they may expect children as a prop like in Solid\n if (typeof Component !== 'string') {\n return Vue.h(\n Component,\n { ...linkProps, children: slotContent },\n slotContent,\n )\n }\n\n // Return the component with props and children\n return Vue.h(Component, linkProps, slotContent)\n }\n },\n})\n\n/**\n * Link component with proper TypeScript generics support\n */\nexport const Link = LinkImpl as unknown as Vue.Component<unknown> &\n Vue.Component<CreateLinkProps> &\n LinkComponent<'a'>\n\nfunction isCtrlEvent(e: MouseEvent) {\n return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)\n}\n\nexport type LinkOptionsFnOptions<\n TOptions,\n TComp,\n TRouter extends AnyRouter = RegisteredRouter,\n> =\n TOptions extends ReadonlyArray<any>\n ? ValidateLinkOptionsArray<TRouter, TOptions, string, TComp>\n : ValidateLinkOptions<TRouter, TOptions, string, TComp>\n\nexport type LinkOptionsFn<TComp> = <\n const TOptions,\n TRouter extends AnyRouter = RegisteredRouter,\n>(\n options: LinkOptionsFnOptions<TOptions, TComp, TRouter>,\n) => TOptions\n\nexport const linkOptions: LinkOptionsFn<'a'> = (options) => {\n return options as any\n}\n"],"mappings":";;;;;;;AA6BA,IAAMU,6BAAa,IAAIC,SAAqD;AAoC5E,SAAgBC,aAOdC,SACoB;CACpB,MAAMC,SAASP,WAAW;CAC1B,MAAMQ,kBAAkBf,IAAIgB,IAAI,MAAM;CAC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GtC,MAAMC,cAAcR,MAAMS,UACtBT,MAAMS,QAAQ;IACZtI;IACA/B;IACD,CAAC,GACF,EAAE;AAGN,OAAIkK,cAAc,OAAO;IAEvB,MAAMI,eAAe,EAAE,GAAGH,WAAW;AACrC,WAAOG,aAAa/F;AACpB,WAAOtF,IAAI4K,EAAE,OAAO,EAAE,EAAE,CAAC5K,IAAI4K,EAAE,KAAKS,cAAcF,YAAY,CAAC,CAAC;;AAKlE,OAAI,OAAOF,cAAc,SACvB,QAAOjL,IAAI4K,EACTK,WACA;IAAE,GAAGC;IAAWI,UAAUH;IAAa,EACvCA,YACD;AAIH,UAAOnL,IAAI4K,EAAEK,WAAWC,WAAWC,YAAY;;;CAGpD,CAAC;;;;AAKF,IAAaI,OAAOV;AAIpB,SAASlE,YAAYL,GAAe;AAClC,QAAO,CAAC,EAAEA,EAAEkF,WAAWlF,EAAEmF,UAAUnF,EAAEoF,WAAWpF,EAAEqF;;AAmBpD,IAAaC,eAAmC/K,YAAY;AAC1D,QAAOA"}
|
|
1
|
+
{"version":3,"file":"link.js","names":["Vue","deepEqual","exactPathTest","isDangerousProtocol","preloadWarning","removeTrailingSlash","isServer","useStore","useRouter","useIntersectionObserver","timeoutMap","WeakMap","useLinkProps","options","router","isTransitioning","ref","hasRenderFetched","console","warn","computed","type","URL","to","eventHandlers","getLinkEventHandlers","value","protocolAllowlist","process","env","NODE_ENV","safeProps","getPropsSafeToSpread","target","disabled","style","class","onClick","onBlur","onFocus","onMouseenter","onMouseleave","onMouseover","onMouseout","onTouchstart","Object","keys","forEach","key","undefined","externalProps","href","next","buildLocation","getHref","nextLocation","isActive","getIsActive","loc","stores","location","state","nextLoc","activeOptions","resolvedActiveProps","resolvedInactiveProps","resolvedClassName","resolvedStyle","resolveStyleProps","result","combineResultProps","currentLocation","l","equal","prev","opts","_fromLocation","preload","reloadDocument","defaultPreload","preloadDelay","defaultPreloadDelay","doPreload","preloadRoute","_builtLocation","catch","err","preloadViewportIoCallback","entry","isIntersecting","rootMargin","effect","handleClick","e","elementTarget","currentTarget","getAttribute","effectiveTarget","isCtrlEvent","defaultPrevented","button","preventDefault","unsub","subscribe","navigate","replace","resetScroll","hashScrollIntoView","startTransition","viewTransition","ignoreBlocker","enqueueIntentPreload","eventTarget","has","set","setTimeout","delete","handleTouchStart","_","handleLeave","id","get","clearTimeout","composeEventHandlers","handlers","event","handler","resolvedStyleProps","staticEventHandlers","computedProps","activeProps","inactiveProps","classes","filter","Boolean","length","join","assign","role","onMouseEnter","onMouseLeave","onMouseOver","onMouseOut","onTouchStart","propsUnsafeToSpread","Set","exact","testExact","pathname","basepath","currentPath","nextPath","pathIsFuzzyEqual","startsWith","includeSearch","searchTest","search","partial","ignoreUndefined","explicitUndefined","includeHash","hash","maskedLocation","publicHref","external","history","createHref","createLink","Comp","defineComponent","name","inheritAttrs","setup","attrs","slots","h","LinkImpl","_asChild","props","allProps","linkPropsSource","Component","linkProps","unref","slotContent","default","svgLinkProps","children","Link","metaKey","altKey","ctrlKey","shiftKey","linkOptions"],"sources":["../../src/link.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport {\n deepEqual,\n exactPathTest,\n isDangerousProtocol,\n preloadWarning,\n removeTrailingSlash,\n} from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\n\nimport { useStore } from '@tanstack/vue-store'\nimport { useRouter } from './useRouter'\nimport { useIntersectionObserver } from './utils'\n\nimport type {\n AnyRouter,\n Constrain,\n LinkOptions,\n ParsedLocation,\n RegisteredRouter,\n RoutePaths,\n} from '@tanstack/router-core'\nimport type { AnchorHTMLAttributes, ReservedProps } from '@vue/runtime-dom'\nimport type {\n ValidateLinkOptions,\n ValidateLinkOptionsArray,\n} from './typePrimitives'\n\ntype EventHandler<TEvent = Event> = (e: TEvent) => void\n\nconst timeoutMap = new WeakMap<EventTarget, ReturnType<typeof setTimeout>>()\n\ntype DataAttributes = {\n [K in `data-${string}`]?: unknown\n}\n\ntype LinkHTMLAttributes = AnchorHTMLAttributes &\n ReservedProps &\n DataAttributes & {\n // Vue's runtime-dom types use lowercase event names.\n // Also accept camelCase versions for external API compatibility.\n onMouseEnter?: EventHandler<MouseEvent>\n onMouseLeave?: EventHandler<MouseEvent>\n onMouseOver?: EventHandler<MouseEvent>\n onMouseOut?: EventHandler<MouseEvent>\n onTouchStart?: EventHandler<TouchEvent>\n\n // `disabled` is not a valid <a> attribute, but is useful when using `asChild`.\n disabled?: boolean\n }\n\ntype VueStyleLinkEventHandlers = {\n onMouseenter?: EventHandler<MouseEvent>\n onMouseleave?: EventHandler<MouseEvent>\n onMouseover?: EventHandler<MouseEvent>\n onMouseout?: EventHandler<MouseEvent>\n onTouchstart?: EventHandler<TouchEvent>\n}\n\ninterface StyledProps {\n class?: LinkHTMLAttributes['class']\n style?: LinkHTMLAttributes['style']\n [key: string]: unknown\n}\n\ntype PropsOfComponent<TComp> =\n // Functional components\n TComp extends (props: infer P, ...args: Array<unknown>) => any\n ? P\n : // Vue components (defineComponent, class components, etc)\n TComp extends Vue.Component<infer P>\n ? P\n : Record<string, unknown>\n\ntype AnyLinkPropsOptions = UseLinkPropsOptions<any, any, any, any, any>\ntype LinkEventOptions = AnyLinkPropsOptions & Partial<VueStyleLinkEventHandlers>\n\nexport function useLinkProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '',\n>(\n options: UseLinkPropsOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n): LinkHTMLAttributes {\n const router = useRouter()\n const isTransitioning = Vue.ref(false)\n let hasRenderFetched = false\n\n // Ensure router is defined before proceeding\n if (!router) {\n console.warn('useRouter must be used inside a <RouterProvider> component!')\n return Vue.computed(() => ({})) as unknown as LinkHTMLAttributes\n }\n\n // Determine if the link is external or internal\n const type = Vue.computed(() => {\n try {\n new URL(`${options.to}`)\n return 'external'\n } catch {\n return 'internal'\n }\n })\n\n const ref = Vue.ref<Element | null>(null)\n const eventHandlers = getLinkEventHandlers(options as LinkEventOptions)\n\n if (type.value === 'external') {\n // Block dangerous protocols like javascript:, blob:, data:\n if (isDangerousProtocol(options.to as string, router.protocolAllowlist)) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Blocked Link with dangerous protocol: ${options.to}`)\n }\n // Return props without href to prevent navigation\n const safeProps: Record<string, unknown> = {\n ...getPropsSafeToSpread(options as AnyLinkPropsOptions),\n ref,\n // No href attribute - blocks the dangerous protocol\n target: options.target,\n disabled: options.disabled,\n style: options.style,\n class: options.class,\n onClick: options.onClick,\n onBlur: options.onBlur,\n onFocus: options.onFocus,\n onMouseenter: eventHandlers.onMouseenter,\n onMouseleave: eventHandlers.onMouseleave,\n onMouseover: eventHandlers.onMouseover,\n onMouseout: eventHandlers.onMouseout,\n onTouchstart: eventHandlers.onTouchstart,\n }\n\n // Remove undefined values\n Object.keys(safeProps).forEach((key) => {\n if (safeProps[key] === undefined) {\n delete safeProps[key]\n }\n })\n\n return Vue.computed(\n () => safeProps as LinkHTMLAttributes,\n ) as unknown as LinkHTMLAttributes\n }\n\n // External links just have simple props\n const externalProps: Record<string, unknown> = {\n ...getPropsSafeToSpread(options as AnyLinkPropsOptions),\n ref,\n href: options.to,\n target: options.target,\n disabled: options.disabled,\n style: options.style,\n class: options.class,\n onClick: options.onClick,\n onBlur: options.onBlur,\n onFocus: options.onFocus,\n onMouseenter: eventHandlers.onMouseenter,\n onMouseleave: eventHandlers.onMouseleave,\n onMouseover: eventHandlers.onMouseover,\n onMouseout: eventHandlers.onMouseout,\n onTouchstart: eventHandlers.onTouchstart,\n }\n\n // Remove undefined values\n Object.keys(externalProps).forEach((key) => {\n if (externalProps[key] === undefined) {\n delete externalProps[key]\n }\n })\n\n return Vue.computed(\n () => externalProps as LinkHTMLAttributes,\n ) as unknown as LinkHTMLAttributes\n }\n\n // During SSR we render exactly once and do not need reactivity.\n // Avoid store subscriptions, effects and observers on the server.\n if (isServer ?? router.isServer) {\n const next = router.buildLocation(options as any)\n const href = getHref({\n options: options as AnyLinkPropsOptions,\n router,\n nextLocation: next,\n })\n\n const isActive = getIsActive({\n loc: router.stores.location.state,\n nextLoc: next,\n activeOptions: options.activeOptions,\n router,\n })\n\n const {\n resolvedActiveProps,\n resolvedInactiveProps,\n resolvedClassName,\n resolvedStyle,\n } = resolveStyleProps({\n options: options as AnyLinkPropsOptions,\n isActive,\n })\n\n const result = combineResultProps({\n href,\n options: options as AnyLinkPropsOptions,\n isActive,\n isTransitioning: false,\n resolvedActiveProps,\n resolvedInactiveProps,\n resolvedClassName,\n resolvedStyle,\n })\n\n return Vue.ref(\n result as LinkHTMLAttributes,\n ) as unknown as LinkHTMLAttributes\n }\n\n const currentLocation = useStore(router.stores.location, (l) => l, {\n equal: (prev, next) => prev.href === next.href,\n })\n\n const next = Vue.computed(() => {\n // Rebuild when inherited search/hash or the current route context changes.\n\n const opts = { _fromLocation: currentLocation.value, ...options }\n return router.buildLocation(opts as any)\n })\n\n const preload = Vue.computed(() => {\n if (options.reloadDocument) {\n return false\n }\n return options.preload ?? router.options.defaultPreload\n })\n\n const preloadDelay = Vue.computed(\n () => options.preloadDelay ?? router.options.defaultPreloadDelay ?? 0,\n )\n\n const isActive = Vue.computed(() =>\n getIsActive({\n activeOptions: options.activeOptions,\n loc: currentLocation.value,\n nextLoc: next.value,\n router,\n }),\n )\n\n const doPreload = () =>\n router\n .preloadRoute({ ...options, _builtLocation: next.value } as any)\n .catch((err: any) => {\n console.warn(err)\n console.warn(preloadWarning)\n })\n\n const preloadViewportIoCallback = (\n entry: IntersectionObserverEntry | undefined,\n ) => {\n if (entry?.isIntersecting) {\n doPreload()\n }\n }\n\n useIntersectionObserver(\n ref,\n preloadViewportIoCallback,\n { rootMargin: '100px' },\n { disabled: () => !!options.disabled || !(preload.value === 'viewport') },\n )\n\n Vue.effect(() => {\n if (hasRenderFetched) {\n return\n }\n if (!options.disabled && preload.value === 'render') {\n doPreload()\n hasRenderFetched = true\n }\n })\n\n // The click handler\n const handleClick = (e: PointerEvent): void => {\n // Check actual element's target attribute as fallback\n const elementTarget = (\n e.currentTarget as HTMLAnchorElement | SVGAElement\n )?.getAttribute('target')\n const effectiveTarget =\n options.target !== undefined ? options.target : elementTarget\n\n if (\n !options.disabled &&\n !isCtrlEvent(e) &&\n !e.defaultPrevented &&\n (!effectiveTarget || effectiveTarget === '_self') &&\n e.button === 0\n ) {\n // Don't prevent default or handle navigation if reloadDocument is true\n if (options.reloadDocument) {\n return\n }\n\n e.preventDefault()\n\n isTransitioning.value = true\n\n const unsub = router.subscribe('onResolved', () => {\n unsub()\n isTransitioning.value = false\n })\n\n // All is well? Navigate!\n router.navigate({\n ...options,\n replace: options.replace,\n resetScroll: options.resetScroll,\n hashScrollIntoView: options.hashScrollIntoView,\n startTransition: options.startTransition,\n viewTransition: options.viewTransition,\n ignoreBlocker: options.ignoreBlocker,\n })\n }\n }\n\n const enqueueIntentPreload = (e: MouseEvent | FocusEvent) => {\n if (options.disabled || preload.value !== 'intent') return\n\n if (!preloadDelay.value) {\n doPreload()\n return\n }\n\n const eventTarget = e.currentTarget || e.target\n\n if (!eventTarget || timeoutMap.has(eventTarget)) return\n\n timeoutMap.set(\n eventTarget,\n setTimeout(() => {\n timeoutMap.delete(eventTarget)\n doPreload()\n }, preloadDelay.value),\n )\n }\n\n const handleTouchStart = (_: TouchEvent) => {\n if (options.disabled || preload.value !== 'intent') return\n doPreload()\n }\n\n const handleLeave = (e: MouseEvent | FocusEvent) => {\n if (options.disabled) return\n const eventTarget = e.currentTarget || e.target\n\n if (eventTarget) {\n const id = timeoutMap.get(eventTarget)\n clearTimeout(id)\n timeoutMap.delete(eventTarget)\n }\n }\n\n // Helper to compose event handlers - with explicit return type and better type handling\n function composeEventHandlers<T extends Event>(\n handlers: Array<EventHandler<T> | undefined>,\n ): (e: T) => void {\n return (event: T) => {\n for (const handler of handlers) {\n if (handler) {\n handler(event)\n }\n }\n }\n }\n\n // Get the active and inactive props\n const resolvedStyleProps = Vue.computed(() =>\n resolveStyleProps({\n options: options as AnyLinkPropsOptions,\n isActive: isActive.value,\n }),\n )\n\n const href = Vue.computed(() =>\n getHref({\n options: options as AnyLinkPropsOptions,\n router,\n nextLocation: next.value,\n }),\n )\n\n // Create static event handlers that don't change between renders\n const staticEventHandlers = {\n onClick: composeEventHandlers<PointerEvent>([\n options.onClick,\n handleClick,\n ]) as any,\n onBlur: composeEventHandlers<FocusEvent>([\n options.onBlur,\n handleLeave,\n ]) as any,\n onFocus: composeEventHandlers<FocusEvent>([\n options.onFocus,\n enqueueIntentPreload,\n ]) as any,\n onMouseenter: composeEventHandlers<MouseEvent>([\n eventHandlers.onMouseenter,\n enqueueIntentPreload,\n ]) as any,\n onMouseover: composeEventHandlers<MouseEvent>([\n eventHandlers.onMouseover,\n enqueueIntentPreload,\n ]) as any,\n onMouseleave: composeEventHandlers<MouseEvent>([\n eventHandlers.onMouseleave,\n handleLeave,\n ]) as any,\n onMouseout: composeEventHandlers<MouseEvent>([\n eventHandlers.onMouseout,\n handleLeave,\n ]) as any,\n onTouchstart: composeEventHandlers<TouchEvent>([\n eventHandlers.onTouchstart,\n handleTouchStart,\n ]) as any,\n }\n\n // Compute all props synchronously to avoid hydration mismatches\n // Using Vue.computed ensures props are calculated at render time, not after\n const computedProps = Vue.computed<LinkHTMLAttributes>(() => {\n const {\n resolvedActiveProps,\n resolvedInactiveProps,\n resolvedClassName,\n resolvedStyle,\n } = resolvedStyleProps.value\n return combineResultProps({\n href: href.value,\n options: options as AnyLinkPropsOptions,\n ref,\n staticEventHandlers,\n isActive: isActive.value,\n isTransitioning: isTransitioning.value,\n resolvedActiveProps,\n resolvedInactiveProps,\n resolvedClassName,\n resolvedStyle,\n })\n })\n\n // Return the computed ref itself - callers should access .value\n return computedProps as unknown as LinkHTMLAttributes\n}\n\nfunction resolveStyleProps({\n options,\n isActive,\n}: {\n options: AnyLinkPropsOptions\n isActive: boolean\n}) {\n const activeProps = options.activeProps || (() => ({ class: 'active' }))\n const resolvedActiveProps: StyledProps = (isActive\n ? typeof activeProps === 'function'\n ? activeProps()\n : activeProps\n : {}) || { class: undefined, style: undefined }\n\n const inactiveProps = options.inactiveProps || (() => ({}))\n\n const resolvedInactiveProps: StyledProps = (isActive\n ? {}\n : typeof inactiveProps === 'function'\n ? inactiveProps()\n : inactiveProps) || { class: undefined, style: undefined }\n\n const classes = [\n options.class,\n resolvedActiveProps?.class,\n resolvedInactiveProps?.class,\n ].filter(Boolean)\n const resolvedClassName = classes.length ? classes.join(' ') : undefined\n\n const result: Record<string, string | number> = {}\n\n // Merge styles from all sources\n if (options.style) {\n Object.assign(result, options.style)\n }\n\n if (resolvedActiveProps?.style) {\n Object.assign(result, resolvedActiveProps.style)\n }\n\n if (resolvedInactiveProps?.style) {\n Object.assign(result, resolvedInactiveProps.style)\n }\n\n const resolvedStyle = Object.keys(result).length > 0 ? result : undefined\n return {\n resolvedActiveProps,\n resolvedInactiveProps,\n resolvedClassName,\n resolvedStyle,\n }\n}\n\nfunction combineResultProps({\n href,\n options,\n isActive,\n isTransitioning,\n resolvedActiveProps,\n resolvedInactiveProps,\n resolvedClassName,\n resolvedStyle,\n ref,\n staticEventHandlers,\n}: {\n initial?: LinkHTMLAttributes\n href: string | undefined\n options: AnyLinkPropsOptions\n isActive: boolean\n isTransitioning: boolean\n resolvedActiveProps: StyledProps\n resolvedInactiveProps: StyledProps\n resolvedClassName?: string\n resolvedStyle?: Record<string, string | number>\n ref?: Vue.VNodeRef | undefined\n staticEventHandlers?: {\n onClick: any\n onBlur: any\n onFocus: any\n onMouseenter: any\n onMouseover: any\n onMouseleave: any\n onMouseout: any\n onTouchstart: any\n }\n}) {\n const result: Record<string, unknown> = {\n ...getPropsSafeToSpread(options),\n ref,\n ...staticEventHandlers,\n href,\n disabled: !!options.disabled,\n target: options.target,\n }\n\n if (resolvedStyle) {\n result.style = resolvedStyle\n }\n\n if (resolvedClassName) {\n result.class = resolvedClassName\n }\n\n if (options.disabled) {\n result.role = 'link'\n result['aria-disabled'] = true\n }\n\n if (isActive) {\n result['data-status'] = 'active'\n result['aria-current'] = 'page'\n }\n\n if (isTransitioning) {\n result['data-transitioning'] = 'transitioning'\n }\n\n for (const key of Object.keys(resolvedActiveProps)) {\n if (key !== 'class' && key !== 'style') {\n result[key] = resolvedActiveProps[key]\n }\n }\n\n for (const key of Object.keys(resolvedInactiveProps)) {\n if (key !== 'class' && key !== 'style') {\n result[key] = resolvedInactiveProps[key]\n }\n }\n return result\n}\n\nfunction getLinkEventHandlers(\n options: LinkEventOptions,\n): VueStyleLinkEventHandlers {\n return {\n onMouseenter: options.onMouseEnter ?? options.onMouseenter,\n onMouseleave: options.onMouseLeave ?? options.onMouseleave,\n onMouseover: options.onMouseOver ?? options.onMouseover,\n onMouseout: options.onMouseOut ?? options.onMouseout,\n onTouchstart: options.onTouchStart ?? options.onTouchstart,\n }\n}\n\nconst propsUnsafeToSpread = new Set([\n 'activeProps',\n 'inactiveProps',\n 'activeOptions',\n 'to',\n 'preload',\n 'preloadDelay',\n 'hashScrollIntoView',\n 'replace',\n 'startTransition',\n 'resetScroll',\n 'viewTransition',\n 'children',\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onBlur',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseenter',\n 'onMouseLeave',\n 'onMouseleave',\n 'onMouseOver',\n 'onMouseover',\n 'onMouseOut',\n 'onMouseout',\n 'onTouchStart',\n 'onTouchstart',\n 'ignoreBlocker',\n 'params',\n 'search',\n 'hash',\n 'state',\n 'mask',\n 'reloadDocument',\n '_asChild',\n 'from',\n 'additionalProps',\n])\n\n// Create safe props that can be spread\nconst getPropsSafeToSpread = (options: AnyLinkPropsOptions) => {\n const result: Record<string, unknown> = {}\n for (const key in options) {\n if (!propsUnsafeToSpread.has(key)) {\n result[key] = (options as Record<string, unknown>)[key]\n }\n }\n\n return result\n}\n\nfunction getIsActive({\n activeOptions,\n loc,\n nextLoc,\n router,\n}: {\n activeOptions: LinkOptions['activeOptions']\n loc: {\n pathname: string\n search: any\n hash: string\n }\n nextLoc: {\n pathname: string\n search: any\n hash: string\n }\n router: AnyRouter\n}) {\n if (activeOptions?.exact) {\n const testExact = exactPathTest(\n loc.pathname,\n nextLoc.pathname,\n router.basepath,\n )\n if (!testExact) {\n return false\n }\n } else {\n const currentPath = removeTrailingSlash(loc.pathname, router.basepath)\n const nextPath = removeTrailingSlash(nextLoc.pathname, router.basepath)\n\n const pathIsFuzzyEqual =\n currentPath.startsWith(nextPath) &&\n (currentPath.length === nextPath.length ||\n currentPath[nextPath.length] === '/')\n if (!pathIsFuzzyEqual) {\n return false\n }\n }\n\n if (activeOptions?.includeSearch ?? true) {\n const searchTest = deepEqual(loc.search, nextLoc.search, {\n partial: !activeOptions?.exact,\n ignoreUndefined: !activeOptions?.explicitUndefined,\n })\n if (!searchTest) {\n return false\n }\n }\n\n if (activeOptions?.includeHash) {\n return loc.hash === nextLoc.hash\n }\n return true\n}\n\nfunction getHref({\n options,\n router,\n nextLocation,\n}: {\n options: AnyLinkPropsOptions\n router: AnyRouter\n nextLocation?: ParsedLocation\n}) {\n if (options.disabled) {\n return undefined\n }\n const location = nextLocation?.maskedLocation ?? nextLocation\n\n // Use publicHref - it contains the correct href for display\n // When a rewrite changes the origin, publicHref is the full URL\n // Otherwise it's the origin-stripped path\n // This avoids constructing URL objects in the hot path\n const publicHref = location?.publicHref\n if (!publicHref) return undefined\n\n const external = location?.external\n if (external) return publicHref\n\n return router.history.createHref(publicHref) || '/'\n}\n\n// Type definitions\nexport type UseLinkPropsOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n LinkHTMLAttributes\n\nexport type ActiveLinkOptions<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n ActiveLinkOptionProps<TComp>\n\ntype ActiveLinkProps<TComp> = Partial<\n (TComp extends keyof HTMLElementTagNameMap\n ? LinkHTMLAttributes\n : PropsOfComponent<TComp>) & {\n [key: `data-${string}`]: unknown\n }\n>\n\nexport interface ActiveLinkOptionProps<TComp = 'a'> {\n /**\n * A function that returns additional props for the `active` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n activeProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n /**\n * A function that returns additional props for the `inactive` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n inactiveProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n}\n\nexport type LinkProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n LinkPropsChildren\n\nexport interface LinkPropsChildren {\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 | Vue.VNodeChild\n | ((state: {\n isActive: boolean\n isTransitioning: boolean\n }) => Vue.VNodeChild)\n}\n\ntype LinkComponentVueProps<TComp> = TComp extends keyof HTMLElementTagNameMap\n ? Omit<LinkHTMLAttributes, keyof CreateLinkProps>\n : Omit<PropsOfComponent<TComp>, keyof CreateLinkProps>\n\nexport type LinkComponentProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkComponentVueProps<TComp> &\n LinkProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>\n\nexport type CreateLinkProps = LinkProps<\n any,\n any,\n string,\n string,\n string,\n string\n>\n\nexport type LinkComponent<\n in out TComp,\n in out TDefaultFrom extends string = string,\n> = <\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = TDefaultFrom,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(\n props: LinkComponentProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n) => Vue.VNode\n\nexport interface LinkComponentRoute<\n in out TDefaultFrom extends string = string,\n> {\n defaultFrom: TDefaultFrom;\n <\n TRouter extends AnyRouter = RegisteredRouter,\n const TTo extends string | undefined = undefined,\n const TMaskTo extends string = '',\n >(\n props: LinkComponentProps<\n 'a',\n TRouter,\n this['defaultFrom'],\n TTo,\n this['defaultFrom'],\n TMaskTo\n >,\n ): Vue.VNode\n}\n\nexport function createLink<const TComp>(\n Comp: Constrain<TComp, any, (props: CreateLinkProps) => Vue.VNode>,\n): LinkComponent<TComp> {\n return Vue.defineComponent({\n name: 'CreatedLink',\n inheritAttrs: false,\n setup(_, { attrs, slots }) {\n return () => Vue.h(LinkImpl as any, { ...attrs, _asChild: Comp }, slots)\n },\n }) as any\n}\n\nconst LinkImpl = Vue.defineComponent({\n name: 'Link',\n inheritAttrs: false,\n props: [\n '_asChild',\n 'to',\n 'preload',\n 'preloadDelay',\n 'activeProps',\n 'inactiveProps',\n 'activeOptions',\n 'from',\n 'search',\n 'params',\n 'hash',\n 'state',\n 'mask',\n 'reloadDocument',\n 'disabled',\n 'additionalProps',\n 'viewTransition',\n 'resetScroll',\n 'startTransition',\n 'hashScrollIntoView',\n 'replace',\n 'ignoreBlocker',\n 'target',\n ],\n setup(props, { attrs, slots }) {\n // Call useLinkProps ONCE during setup with combined props and attrs\n const allProps = { ...props, ...attrs }\n const linkPropsSource = useLinkProps(allProps as any) as\n | LinkHTMLAttributes\n | Vue.ComputedRef<LinkHTMLAttributes>\n\n return () => {\n const Component = props._asChild || 'a'\n\n const linkProps = Vue.unref(linkPropsSource)\n\n const isActive = linkProps['data-status'] === 'active'\n const isTransitioning =\n linkProps['data-transitioning'] === 'transitioning'\n\n // Create the slot content or empty array if no default slot\n const slotContent = slots.default\n ? slots.default({\n isActive,\n isTransitioning,\n })\n : []\n\n // Special handling for SVG links - wrap an <a> inside the SVG\n if (Component === 'svg') {\n // Create props without class for svg link\n const svgLinkProps = { ...linkProps }\n delete svgLinkProps.class\n return Vue.h('svg', {}, [Vue.h('a', svgLinkProps, slotContent)])\n }\n\n // For custom functional components (non-string), pass children as a prop\n // since they may expect children as a prop like in Solid\n if (typeof Component !== 'string') {\n return Vue.h(\n Component,\n { ...linkProps, children: slotContent },\n slotContent,\n )\n }\n\n // Return the component with props and children\n return Vue.h(Component, linkProps, slotContent)\n }\n },\n})\n\n/**\n * Link component with proper TypeScript generics support\n */\nexport const Link = LinkImpl as unknown as Vue.Component<unknown> &\n Vue.Component<CreateLinkProps> &\n LinkComponent<'a'>\n\nfunction isCtrlEvent(e: MouseEvent) {\n return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)\n}\n\nexport type LinkOptionsFnOptions<\n TOptions,\n TComp,\n TRouter extends AnyRouter = RegisteredRouter,\n> =\n TOptions extends ReadonlyArray<any>\n ? ValidateLinkOptionsArray<TRouter, TOptions, string, TComp>\n : ValidateLinkOptions<TRouter, TOptions, string, TComp>\n\nexport type LinkOptionsFn<TComp> = <\n const TOptions,\n TRouter extends AnyRouter = RegisteredRouter,\n>(\n options: LinkOptionsFnOptions<TOptions, TComp, TRouter>,\n) => TOptions\n\nexport const linkOptions: LinkOptionsFn<'a'> = (options) => {\n return options as any\n}\n"],"mappings":";;;;;;;AA8BA,IAAMU,6BAAa,IAAIC,SAAqD;AA+C5E,SAAgBC,aAOdC,SACoB;CACpB,MAAMC,SAASN,WAAW;CAC1B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E,CAAC/K,IAAI+K,EAAE,KAAKW,cAAcF,YAAY,CAAC,CAAC;;AAKlE,OAAI,OAAOH,cAAc,SACvB,QAAOrL,IAAI+K,EACTM,WACA;IAAE,GAAGC;IAAWK,UAAUH;IAAa,EACvCA,YACD;AAIH,UAAOxL,IAAI+K,EAAEM,WAAWC,WAAWE,YAAY;;;CAGpD,CAAC;;;;AAKF,IAAaI,OAAOZ;AAIpB,SAAS9E,YAAYL,GAAe;AAClC,QAAO,CAAC,EAAEA,EAAEgG,WAAWhG,EAAEiG,UAAUjG,EAAEkG,WAAWlG,EAAEmG;;AAmBpD,IAAaC,eAAmCpL,YAAY;AAC1D,QAAOA"}
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import * as Vue from 'vue';
|
|
2
2
|
export declare const matchContext: Vue.InjectionKey<Vue.Ref<string | undefined>>;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const pendingMatchContext: Vue.InjectionKey<Vue.Ref<boolean>>;
|
|
4
|
+
export declare const dummyPendingMatchContext: Vue.InjectionKey<Vue.Ref<boolean>>;
|
|
5
|
+
export declare const routeIdContext: Vue.InjectionKey<string>;
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
7
|
+
* Retrieves nearest pending-match state from the component tree
|
|
6
8
|
*/
|
|
7
|
-
export declare function
|
|
9
|
+
export declare function injectPendingMatch(): Vue.Ref<boolean>;
|
|
8
10
|
/**
|
|
9
|
-
* Retrieves
|
|
11
|
+
* Retrieves dummy pending-match state from the component tree
|
|
12
|
+
* This only exists so we can conditionally inject a value when we are not interested in the nearest pending match
|
|
10
13
|
*/
|
|
11
|
-
export declare function
|
|
12
|
-
/**
|
|
13
|
-
* Provides a dummy match ID to child components
|
|
14
|
-
*/
|
|
15
|
-
export declare function provideDummyMatch(matchId: string | undefined): void;
|
|
16
|
-
/**
|
|
17
|
-
* Retrieves the dummy match ID from the component tree
|
|
18
|
-
* This only exists so we can conditionally inject a value when we are not interested in the nearest match
|
|
19
|
-
*/
|
|
20
|
-
export declare function injectDummyMatch(): Vue.Ref<string | undefined>;
|
|
14
|
+
export declare function injectDummyPendingMatch(): Vue.Ref<boolean>;
|
package/dist/esm/matchContext.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import * as Vue from "vue";
|
|
2
2
|
//#region src/matchContext.tsx
|
|
3
3
|
var matchContext = Symbol("TanStackRouterMatch");
|
|
4
|
-
var
|
|
4
|
+
var pendingMatchContext = Symbol("TanStackRouterPendingMatch");
|
|
5
|
+
var dummyPendingMatchContext = Symbol("TanStackRouterDummyPendingMatch");
|
|
6
|
+
var routeIdContext = Symbol("TanStackRouterRouteId");
|
|
5
7
|
/**
|
|
6
|
-
* Retrieves
|
|
8
|
+
* Retrieves nearest pending-match state from the component tree
|
|
7
9
|
*/
|
|
8
|
-
function
|
|
9
|
-
return Vue.inject(
|
|
10
|
+
function injectPendingMatch() {
|
|
11
|
+
return Vue.inject(pendingMatchContext, Vue.ref(false));
|
|
10
12
|
}
|
|
11
13
|
/**
|
|
12
|
-
* Retrieves
|
|
13
|
-
* This only exists so we can conditionally inject a value when we are not interested in the nearest match
|
|
14
|
+
* Retrieves dummy pending-match state from the component tree
|
|
15
|
+
* This only exists so we can conditionally inject a value when we are not interested in the nearest pending match
|
|
14
16
|
*/
|
|
15
|
-
function
|
|
16
|
-
return Vue.inject(
|
|
17
|
+
function injectDummyPendingMatch() {
|
|
18
|
+
return Vue.inject(dummyPendingMatchContext, Vue.ref(false));
|
|
17
19
|
}
|
|
18
20
|
//#endregion
|
|
19
|
-
export {
|
|
21
|
+
export { injectDummyPendingMatch, injectPendingMatch, matchContext, pendingMatchContext, routeIdContext };
|
|
20
22
|
|
|
21
23
|
//# sourceMappingURL=matchContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchContext.js","names":["Vue","matchContext","Symbol","
|
|
1
|
+
{"version":3,"file":"matchContext.js","names":["Vue","matchContext","Symbol","pendingMatchContext","dummyPendingMatchContext","routeIdContext","injectPendingMatch","inject","ref","injectDummyPendingMatch"],"sources":["../../src/matchContext.tsx"],"sourcesContent":["import * as Vue from 'vue'\n\n// Reactive nearest-match context used by hooks that work relative to the\n// current match in the tree.\nexport const matchContext = Symbol('TanStackRouterMatch') as Vue.InjectionKey<\n Vue.Ref<string | undefined>\n>\n\n// Pending match context for nearest-match lookups\nexport const pendingMatchContext = Symbol(\n 'TanStackRouterPendingMatch',\n) as Vue.InjectionKey<Vue.Ref<boolean>>\n\n// Dummy pending context when nearest pending state is not needed\nexport const dummyPendingMatchContext = Symbol(\n 'TanStackRouterDummyPendingMatch',\n) as Vue.InjectionKey<Vue.Ref<boolean>>\n\n// Stable routeId context — a plain string (not reactive) that identifies\n// which route this component belongs to. Provided by Match, consumed by\n// MatchInner, Outlet, and useMatch for routeId-based store lookups.\nexport const routeIdContext = Symbol(\n 'TanStackRouterRouteId',\n) as Vue.InjectionKey<string>\n\n/**\n * Retrieves nearest pending-match state from the component tree\n */\nexport function injectPendingMatch(): Vue.Ref<boolean> {\n return Vue.inject(pendingMatchContext, Vue.ref(false))\n}\n\n/**\n * Retrieves dummy pending-match state from the component tree\n * This only exists so we can conditionally inject a value when we are not interested in the nearest pending match\n */\nexport function injectDummyPendingMatch(): Vue.Ref<boolean> {\n return Vue.inject(dummyPendingMatchContext, Vue.ref(false))\n}\n"],"mappings":";;AAIA,IAAaC,eAAeC,OAAO,sBAElC;AAGD,IAAaC,sBAAsBD,OACjC,6BACqC;AAGvC,IAAaE,2BAA2BF,OACtC,kCACqC;AAKvC,IAAaG,iBAAiBH,OAC5B,wBAC2B;;;;AAK7B,SAAgBI,qBAAuC;AACrD,QAAON,IAAIO,OAAOJ,qBAAqBH,IAAIQ,IAAI,MAAM,CAAC;;;;;;AAOxD,SAAgBC,0BAA4C;AAC1D,QAAOT,IAAIO,OAAOH,0BAA0BJ,IAAIQ,IAAI,MAAM,CAAC"}
|
package/dist/esm/not-found.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { CatchBoundary } from "./CatchBoundary.js";
|
|
2
|
-
import {
|
|
2
|
+
import { useRouter } from "./useRouter.js";
|
|
3
3
|
import { isNotFound } from "@tanstack/router-core";
|
|
4
4
|
import * as Vue from "vue";
|
|
5
|
+
import { useStore } from "@tanstack/vue-store";
|
|
5
6
|
//#region src/not-found.tsx
|
|
6
7
|
function CatchNotFound(props) {
|
|
7
|
-
const
|
|
8
|
+
const router = useRouter();
|
|
9
|
+
const pathname = useStore(router.stores.location, (location) => location.pathname);
|
|
10
|
+
const status = useStore(router.stores.status, (value) => value);
|
|
8
11
|
const errorComponentFn = (componentProps) => {
|
|
9
12
|
const error = componentProps.error;
|
|
10
13
|
if (isNotFound(error)) {
|
|
@@ -13,7 +16,7 @@ function CatchNotFound(props) {
|
|
|
13
16
|
} else throw error;
|
|
14
17
|
};
|
|
15
18
|
return Vue.h(CatchBoundary, {
|
|
16
|
-
getResetKey: () =>
|
|
19
|
+
getResetKey: () => `not-found-${pathname.value}-${status.value}`,
|
|
17
20
|
onCatch: (error) => {
|
|
18
21
|
if (isNotFound(error)) {
|
|
19
22
|
if (props.onCatch) props.onCatch(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not-found.js","names":["Vue","isNotFound","CatchBoundary","
|
|
1
|
+
{"version":3,"file":"not-found.js","names":["Vue","isNotFound","useStore","CatchBoundary","useRouter","CatchNotFound","props","router","pathname","stores","location","status","value","errorComponentFn","componentProps","error","fallback","h","getResetKey","onCatch","errorComponent","children","DefaultGlobalNotFound","defineComponent","name","setup"],"sources":["../../src/not-found.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport { isNotFound } from '@tanstack/router-core'\nimport { useStore } from '@tanstack/vue-store'\nimport { CatchBoundary } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport type { ErrorComponentProps, NotFoundError } from '@tanstack/router-core'\n\nexport function CatchNotFound(props: {\n fallback?: (error: NotFoundError) => Vue.VNode\n onCatch?: (error: Error) => void\n children: Vue.VNode\n}) {\n const router = useRouter()\n // TODO: Some way for the user to programmatically reset the not-found boundary?\n const pathname = useStore(\n router.stores.location,\n (location) => location.pathname,\n )\n const status = useStore(router.stores.status, (value) => value)\n\n // Create a function that returns a VNode to match the SyncRouteComponent signature\n const errorComponentFn = (componentProps: ErrorComponentProps) => {\n const error = componentProps.error\n\n if (isNotFound(error)) {\n // If a fallback is provided, use it\n if (props.fallback) {\n return props.fallback(error)\n }\n // Otherwise return a default not found message\n return Vue.h('p', null, 'Not Found')\n } else {\n // Re-throw non-NotFound errors\n throw error\n }\n }\n\n return Vue.h(CatchBoundary, {\n getResetKey: () => `not-found-${pathname.value}-${status.value}`,\n onCatch: (error: Error) => {\n if (isNotFound(error)) {\n if (props.onCatch) {\n props.onCatch(error)\n }\n } else {\n throw error\n }\n },\n errorComponent: errorComponentFn,\n children: props.children,\n })\n}\n\nexport const DefaultGlobalNotFound = Vue.defineComponent({\n name: 'DefaultGlobalNotFound',\n setup() {\n return () => Vue.h('p', null, 'Not Found')\n },\n})\n"],"mappings":";;;;;;AAOA,SAAgBK,cAAcC,OAI3B;CACD,MAAMC,SAASH,WAAW;CAE1B,MAAMI,WAAWN,SACfK,OAAOE,OAAOC,WACbA,aAAaA,SAASF,SACxB;CACD,MAAMG,SAAST,SAASK,OAAOE,OAAOE,SAASC,UAAUA,MAAM;CAG/D,MAAMC,oBAAoBC,mBAAwC;EAChE,MAAMC,QAAQD,eAAeC;AAE7B,MAAId,WAAWc,MAAM,EAAE;AAErB,OAAIT,MAAMU,SACR,QAAOV,MAAMU,SAASD,MAAM;AAG9B,UAAOf,IAAIiB,EAAE,KAAK,MAAM,YAAY;QAGpC,OAAMF;;AAIV,QAAOf,IAAIiB,EAAEd,eAAe;EAC1Be,mBAAmB,aAAaV,SAASI,MAAK,GAAID,OAAOC;EACzDO,UAAUJ,UAAiB;AACzB,OAAId,WAAWc,MAAM;QACfT,MAAMa,QACRb,OAAMa,QAAQJ,MAAM;SAGtB,OAAMA;;EAGVK,gBAAgBP;EAChBQ,UAAUf,MAAMe;EACjB,CAAC;;AAGJ,IAAaC,wBAAwBtB,IAAIuB,gBAAgB;CACvDC,MAAM;CACNC,QAAQ;AACN,eAAazB,IAAIiB,EAAE,KAAK,MAAM,YAAY;;CAE7C,CAAC"}
|
package/dist/esm/router.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getStoreFactory } from "./routerStores.js";
|
|
1
2
|
import { RouterCore } from "@tanstack/router-core";
|
|
2
3
|
//#region src/router.ts
|
|
3
4
|
var createRouter = (options) => {
|
|
@@ -5,7 +6,7 @@ var createRouter = (options) => {
|
|
|
5
6
|
};
|
|
6
7
|
var Router = class extends RouterCore {
|
|
7
8
|
constructor(options) {
|
|
8
|
-
super(options);
|
|
9
|
+
super(options, getStoreFactory);
|
|
9
10
|
}
|
|
10
11
|
};
|
|
11
12
|
//#endregion
|
package/dist/esm/router.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","names":[],"sources":["../../src/router.ts"],"sourcesContent":["import { RouterCore } from '@tanstack/router-core'\nimport type { RouterHistory } from '@tanstack/history'\nimport type {\n AnyRoute,\n CreateRouterFn,\n RouterConstructorOptions,\n TrailingSlashOption,\n} from '@tanstack/router-core'\nimport type {\n ErrorRouteComponent,\n NotFoundRouteComponent,\n RouteComponent,\n} from './route'\nimport type { VNode } from 'vue'\n\ndeclare module '@tanstack/router-core' {\n export interface RouterOptionsExtensions {\n /**\n * The default `component` a route should use if no component is provided.\n *\n * @default Outlet\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultcomponent-property)\n */\n defaultComponent?: RouteComponent\n /**\n * The default `errorComponent` a route should use if no error component is provided.\n *\n * @default ErrorComponent\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaulterrorcomponent-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)\n */\n defaultErrorComponent?: ErrorRouteComponent\n /**\n * The default `pendingComponent` a route should use if no pending component is provided.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultpendingcomponent-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/data-loading#showing-a-pending-component)\n */\n defaultPendingComponent?: RouteComponent\n /**\n * The default `notFoundComponent` a route should use if no notFound component is provided.\n *\n * @default NotFound\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultnotfoundcomponent-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/not-found-errors#default-router-wide-not-found-handling)\n */\n defaultNotFoundComponent?: NotFoundRouteComponent\n /**\n * A component that will be used to wrap the entire router.\n *\n * This is useful for providing a context to the entire router.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#wrap-property)\n */\n Wrap?: (props: { children: any }) => VNode\n /**\n * A component that will be used to wrap the inner contents of the router.\n *\n * This is useful for providing a context to the inner contents of the router where you also need access to the router context and hooks.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#innerwrap-property)\n */\n InnerWrap?: (props: { children: any }) => VNode\n\n /**\n * The default `onCatch` handler for errors caught by the Router ErrorBoundary\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultoncatch-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionsoncatch)\n */\n defaultOnCatch?: (error: Error) => void\n }\n}\n\nexport const createRouter: CreateRouterFn = (options) => {\n return new Router(options)\n}\n\nexport class Router<\n in out TRouteTree extends AnyRoute,\n in out TTrailingSlashOption extends TrailingSlashOption = 'never',\n in out TDefaultStructuralSharingOption extends boolean = false,\n in out TRouterHistory extends RouterHistory = RouterHistory,\n in out TDehydrated extends Record<string, any> = Record<string, any>,\n> extends RouterCore<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n> {\n constructor(\n options: RouterConstructorOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n >,\n ) {\n super(options)\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"router.js","names":[],"sources":["../../src/router.ts"],"sourcesContent":["import { RouterCore } from '@tanstack/router-core'\nimport { getStoreFactory } from './routerStores'\nimport type { RouterHistory } from '@tanstack/history'\nimport type {\n AnyRoute,\n CreateRouterFn,\n RouterConstructorOptions,\n TrailingSlashOption,\n} from '@tanstack/router-core'\nimport type {\n ErrorRouteComponent,\n NotFoundRouteComponent,\n RouteComponent,\n} from './route'\nimport type { VNode } from 'vue'\n\ndeclare module '@tanstack/router-core' {\n export interface RouterOptionsExtensions {\n /**\n * The default `component` a route should use if no component is provided.\n *\n * @default Outlet\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultcomponent-property)\n */\n defaultComponent?: RouteComponent\n /**\n * The default `errorComponent` a route should use if no error component is provided.\n *\n * @default ErrorComponent\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaulterrorcomponent-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)\n */\n defaultErrorComponent?: ErrorRouteComponent\n /**\n * The default `pendingComponent` a route should use if no pending component is provided.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultpendingcomponent-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/data-loading#showing-a-pending-component)\n */\n defaultPendingComponent?: RouteComponent\n /**\n * The default `notFoundComponent` a route should use if no notFound component is provided.\n *\n * @default NotFound\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultnotfoundcomponent-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/not-found-errors#default-router-wide-not-found-handling)\n */\n defaultNotFoundComponent?: NotFoundRouteComponent\n /**\n * A component that will be used to wrap the entire router.\n *\n * This is useful for providing a context to the entire router.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#wrap-property)\n */\n Wrap?: (props: { children: any }) => VNode\n /**\n * A component that will be used to wrap the inner contents of the router.\n *\n * This is useful for providing a context to the inner contents of the router where you also need access to the router context and hooks.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#innerwrap-property)\n */\n InnerWrap?: (props: { children: any }) => VNode\n\n /**\n * The default `onCatch` handler for errors caught by the Router ErrorBoundary\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultoncatch-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionsoncatch)\n */\n defaultOnCatch?: (error: Error) => void\n }\n}\n\nexport const createRouter: CreateRouterFn = (options) => {\n return new Router(options)\n}\n\nexport class Router<\n in out TRouteTree extends AnyRoute,\n in out TTrailingSlashOption extends TrailingSlashOption = 'never',\n in out TDefaultStructuralSharingOption extends boolean = false,\n in out TRouterHistory extends RouterHistory = RouterHistory,\n in out TDehydrated extends Record<string, any> = Record<string, any>,\n> extends RouterCore<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n> {\n constructor(\n options: RouterConstructorOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n >,\n ) {\n super(options, getStoreFactory)\n }\n}\n"],"mappings":";;;AA2EA,IAAa,gBAAgC,YAAY;AACvD,QAAO,IAAI,OAAO,QAAQ;;AAG5B,IAAa,SAAb,cAMU,WAMR;CACA,YACE,SAOA;AACA,QAAM,SAAS,gBAAgB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AnyRoute, GetStoreConfig } from '@tanstack/router-core';
|
|
2
|
+
import { Readable } from '@tanstack/vue-store';
|
|
3
|
+
declare module '@tanstack/router-core' {
|
|
4
|
+
interface RouterReadableStore<TValue> extends Readable<TValue> {
|
|
5
|
+
}
|
|
6
|
+
interface RouterStores<in out TRouteTree extends AnyRoute> {
|
|
7
|
+
/** Maps each active routeId to the matchId of its child in the match tree. */
|
|
8
|
+
childMatchIdByRouteId: RouterReadableStore<Record<string, string>>;
|
|
9
|
+
/** Maps each pending routeId to true for quick lookup. */
|
|
10
|
+
pendingRouteIds: RouterReadableStore<Record<string, boolean>>;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export declare const getStoreFactory: GetStoreConfig;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { batch, createStore } from "@tanstack/vue-store";
|
|
2
|
+
//#region src/routerStores.ts
|
|
3
|
+
var getStoreFactory = (_opts) => {
|
|
4
|
+
return {
|
|
5
|
+
createMutableStore: createStore,
|
|
6
|
+
createReadonlyStore: createStore,
|
|
7
|
+
batch,
|
|
8
|
+
init: (stores) => {
|
|
9
|
+
stores.childMatchIdByRouteId = createStore(() => {
|
|
10
|
+
const ids = stores.matchesId.state;
|
|
11
|
+
const obj = {};
|
|
12
|
+
for (let i = 0; i < ids.length - 1; i++) {
|
|
13
|
+
const parentStore = stores.activeMatchStoresById.get(ids[i]);
|
|
14
|
+
if (parentStore?.routeId) obj[parentStore.routeId] = ids[i + 1];
|
|
15
|
+
}
|
|
16
|
+
return obj;
|
|
17
|
+
});
|
|
18
|
+
stores.pendingRouteIds = createStore(() => {
|
|
19
|
+
const ids = stores.pendingMatchesId.state;
|
|
20
|
+
const obj = {};
|
|
21
|
+
for (const id of ids) {
|
|
22
|
+
const store = stores.pendingMatchStoresById.get(id);
|
|
23
|
+
if (store?.routeId) obj[store.routeId] = true;
|
|
24
|
+
}
|
|
25
|
+
return obj;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
export { getStoreFactory };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=routerStores.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routerStores.js","names":[],"sources":["../../src/routerStores.ts"],"sourcesContent":["import { batch, createStore } from '@tanstack/vue-store'\nimport type {\n AnyRoute,\n GetStoreConfig,\n RouterStores,\n} from '@tanstack/router-core'\nimport type { Readable } from '@tanstack/vue-store'\n\ndeclare module '@tanstack/router-core' {\n export interface RouterReadableStore<TValue> extends Readable<TValue> {}\n export interface RouterStores<in out TRouteTree extends AnyRoute> {\n /** Maps each active routeId to the matchId of its child in the match tree. */\n childMatchIdByRouteId: RouterReadableStore<Record<string, string>>\n /** Maps each pending routeId to true for quick lookup. */\n pendingRouteIds: RouterReadableStore<Record<string, boolean>>\n }\n}\n\nexport const getStoreFactory: GetStoreConfig = (_opts) => {\n return {\n createMutableStore: createStore,\n createReadonlyStore: createStore,\n batch,\n init: (stores: RouterStores<AnyRoute>) => {\n // Single derived store: one reactive node that maps every active\n // routeId to its child's matchId. Depends only on matchesId +\n // the pool's routeId tags (which are set during reconciliation).\n // Outlet reads the map and then does a direct pool lookup.\n stores.childMatchIdByRouteId = createStore(() => {\n const ids = stores.matchesId.state\n const obj: Record<string, string> = {}\n for (let i = 0; i < ids.length - 1; i++) {\n const parentStore = stores.activeMatchStoresById.get(ids[i]!)\n if (parentStore?.routeId) {\n obj[parentStore.routeId] = ids[i + 1]!\n }\n }\n return obj\n })\n\n stores.pendingRouteIds = createStore(() => {\n const ids = stores.pendingMatchesId.state\n const obj: Record<string, boolean> = {}\n for (const id of ids) {\n const store = stores.pendingMatchStoresById.get(id)\n if (store?.routeId) {\n obj[store.routeId] = true\n }\n }\n return obj\n })\n },\n }\n}\n"],"mappings":";;AAkBA,IAAa,mBAAmC,UAAU;AACxD,QAAO;EACL,oBAAoB;EACpB,qBAAqB;EACrB;EACA,OAAO,WAAmC;AAKxC,UAAO,wBAAwB,kBAAkB;IAC/C,MAAM,MAAM,OAAO,UAAU;IAC7B,MAAM,MAA8B,EAAE;AACtC,SAAK,IAAI,IAAI,GAAG,IAAI,IAAI,SAAS,GAAG,KAAK;KACvC,MAAM,cAAc,OAAO,sBAAsB,IAAI,IAAI,GAAI;AAC7D,SAAI,aAAa,QACf,KAAI,YAAY,WAAW,IAAI,IAAI;;AAGvC,WAAO;KACP;AAEF,UAAO,kBAAkB,kBAAkB;IACzC,MAAM,MAAM,OAAO,iBAAiB;IACpC,MAAM,MAA+B,EAAE;AACvC,SAAK,MAAM,MAAM,KAAK;KACpB,MAAM,QAAQ,OAAO,uBAAuB,IAAI,GAAG;AACnD,SAAI,OAAO,QACT,KAAI,MAAM,WAAW;;AAGzB,WAAO;KACP;;EAEL"}
|
|
@@ -12,7 +12,7 @@ var RouterClient = Vue.defineComponent({
|
|
|
12
12
|
} },
|
|
13
13
|
setup(props) {
|
|
14
14
|
const isHydrated = Vue.ref(false);
|
|
15
|
-
if (!hydrationPromise) if (!props.router.state.
|
|
15
|
+
if (!hydrationPromise) if (!props.router.stores.matchesId.state.length) hydrationPromise = hydrate(props.router);
|
|
16
16
|
else hydrationPromise = Promise.resolve();
|
|
17
17
|
Vue.onMounted(() => {
|
|
18
18
|
hydrationPromise.then(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouterClient.js","names":["Vue","hydrate","HeadContent","RouterProvider","hydrationPromise","RouterClient","defineComponent","name","props","router","type","Object","required","setup","isHydrated","ref","
|
|
1
|
+
{"version":3,"file":"RouterClient.js","names":["Vue","hydrate","HeadContent","RouterProvider","hydrationPromise","RouterClient","defineComponent","name","props","router","type","Object","required","setup","isHydrated","ref","stores","matchesId","state","length","Promise","resolve","onMounted","then","value","window","h","innerWrap","innerProps","children"],"sources":["../../../src/ssr/RouterClient.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport { hydrate } from '@tanstack/router-core/ssr/client'\nimport { HeadContent } from '../HeadContent'\nimport { RouterProvider } from '../RouterProvider'\nimport type { AnyRouter } from '@tanstack/router-core'\n\nlet hydrationPromise: Promise<void | Array<Array<void>>> | undefined\n\nexport const RouterClient = Vue.defineComponent({\n name: 'RouterClient',\n props: {\n router: {\n type: Object as () => AnyRouter,\n required: true,\n },\n },\n setup(props) {\n const isHydrated = Vue.ref(false)\n\n if (!hydrationPromise) {\n if (!props.router.stores.matchesId.state.length) {\n hydrationPromise = hydrate(props.router)\n } else {\n hydrationPromise = Promise.resolve()\n }\n }\n\n Vue.onMounted(() => {\n hydrationPromise!.then(() => {\n isHydrated.value = true\n })\n })\n\n // For SSR, we're already hydrated\n if (typeof window === 'undefined') {\n isHydrated.value = true\n }\n\n return () => {\n if (!isHydrated.value) {\n return null\n }\n\n return Vue.h(\n RouterProvider,\n {\n router: props.router,\n },\n {\n innerWrap: (innerProps: { children: any }) => [\n Vue.h(HeadContent),\n innerProps.children,\n ],\n },\n )\n }\n },\n})\n"],"mappings":";;;;;AAMA,IAAII;AAEJ,IAAaC,eAAeL,IAAIM,gBAAgB;CAC9CC,MAAM;CACNC,OAAO,EACLC,QAAQ;EACNC,MAAMC;EACNC,UAAU;EACZ,EACD;CACDC,MAAML,OAAO;EACX,MAAMM,aAAad,IAAIe,IAAI,MAAM;AAEjC,MAAI,CAACX,iBACH,KAAI,CAACI,MAAMC,OAAOO,OAAOC,UAAUC,MAAMC,OACvCf,oBAAmBH,QAAQO,MAAMC,OAAO;MAExCL,oBAAmBgB,QAAQC,SAAS;AAIxCrB,MAAIsB,gBAAgB;AAClBlB,oBAAkBmB,WAAW;AAC3BT,eAAWU,QAAQ;KACnB;IACF;AAGF,MAAI,OAAOC,WAAW,YACpBX,YAAWU,QAAQ;AAGrB,eAAa;AACX,OAAI,CAACV,WAAWU,MACd,QAAO;AAGT,UAAOxB,IAAI0B,EACTvB,gBACA,EACEM,QAAQD,MAAMC,QACf,EACD,EACEkB,YAAYC,eAAkC,CAC5C5B,IAAI0B,EAAExB,YAAY,EAClB0B,WAAWC,SAAQ,EAGzB,CAAC;;;CAGN,CAAC"}
|
|
@@ -34,7 +34,7 @@ var renderRouterToStream = async ({ request, router, responseHeaders, App }) =>
|
|
|
34
34
|
if (htmlOpenIndex !== -1 && htmlCloseIndex !== -1) fullHtml = fullHtml.slice(htmlOpenIndex, htmlCloseIndex + 7);
|
|
35
35
|
else if (htmlOpenIndex !== -1) fullHtml = fullHtml.slice(htmlOpenIndex);
|
|
36
36
|
return new Response(`<!DOCTYPE html>${fullHtml}`, {
|
|
37
|
-
status: router.
|
|
37
|
+
status: router.stores.statusCode.state,
|
|
38
38
|
headers: responseHeaders
|
|
39
39
|
});
|
|
40
40
|
}
|
|
@@ -42,7 +42,7 @@ var renderRouterToStream = async ({ request, router, responseHeaders, App }) =>
|
|
|
42
42
|
pipeToWebWritable(app, {}, writable);
|
|
43
43
|
const responseStream = transformReadableStreamWithRouter(router, prependDoctype(readable));
|
|
44
44
|
return new Response(responseStream, {
|
|
45
|
-
status: router.
|
|
45
|
+
status: router.stores.statusCode.state,
|
|
46
46
|
headers: responseHeaders
|
|
47
47
|
});
|
|
48
48
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderRouterToStream.js","names":["ReadableStream","NodeReadableStream","Vue","pipeToWebWritable","renderToString","isbot","transformReadableStreamWithRouter","prependDoctype","readable","encoder","TextEncoder","sentDoctype","start","controller","reader","getReader","pump","done","value","read","close","enqueue","encode","catch","err","error","renderRouterToStream","request","router","responseHeaders","App","app","createSSRApp","headers","get","fullHtml","htmlOpenIndex","indexOf","htmlCloseIndex","slice","Response","status","
|
|
1
|
+
{"version":3,"file":"renderRouterToStream.js","names":["ReadableStream","NodeReadableStream","Vue","pipeToWebWritable","renderToString","isbot","transformReadableStreamWithRouter","prependDoctype","readable","encoder","TextEncoder","sentDoctype","start","controller","reader","getReader","pump","done","value","read","close","enqueue","encode","catch","err","error","renderRouterToStream","request","router","responseHeaders","App","app","createSSRApp","headers","get","fullHtml","htmlOpenIndex","indexOf","htmlCloseIndex","slice","Response","status","stores","statusCode","state","writable","TransformStream","doctypedStream","responseStream"],"sources":["../../../src/ssr/renderRouterToStream.tsx"],"sourcesContent":["import { ReadableStream as NodeReadableStream } from 'node:stream/web'\nimport * as Vue from 'vue'\nimport { pipeToWebWritable, renderToString } from 'vue/server-renderer'\nimport { isbot } from 'isbot'\nimport { transformReadableStreamWithRouter } from '@tanstack/router-core/ssr/server'\nimport type { AnyRouter } from '@tanstack/router-core'\nimport type { Component } from 'vue'\n\nfunction prependDoctype(\n readable: globalThis.ReadableStream,\n): NodeReadableStream<Uint8Array> {\n const encoder = new TextEncoder()\n let sentDoctype = false\n\n return new NodeReadableStream<Uint8Array>({\n start(controller) {\n const reader = readable.getReader()\n\n async function pump(): Promise<void> {\n const { done, value } = await reader.read()\n if (done) {\n controller.close()\n return\n }\n\n if (!sentDoctype) {\n sentDoctype = true\n controller.enqueue(encoder.encode('<!DOCTYPE html>'))\n }\n controller.enqueue(value)\n return pump()\n }\n\n pump().catch((err) => controller.error(err))\n },\n })\n}\n\nexport const renderRouterToStream = async ({\n request,\n router,\n responseHeaders,\n App,\n}: {\n request: Request\n router: AnyRouter\n responseHeaders: Headers\n App: Component\n}) => {\n const app = Vue.createSSRApp(App, { router })\n\n if (isbot(request.headers.get('User-Agent'))) {\n let fullHtml = await renderToString(app)\n\n const htmlOpenIndex = fullHtml.indexOf('<html')\n const htmlCloseIndex = fullHtml.indexOf('</html>')\n\n if (htmlOpenIndex !== -1 && htmlCloseIndex !== -1) {\n fullHtml = fullHtml.slice(htmlOpenIndex, htmlCloseIndex + 7)\n } else if (htmlOpenIndex !== -1) {\n fullHtml = fullHtml.slice(htmlOpenIndex)\n }\n\n return new Response(`<!DOCTYPE html>${fullHtml}`, {\n status: router.stores.statusCode.state,\n headers: responseHeaders,\n })\n }\n\n const { writable, readable } = new TransformStream()\n\n pipeToWebWritable(app, {}, writable)\n\n const doctypedStream = prependDoctype(readable)\n const responseStream = transformReadableStreamWithRouter(\n router,\n doctypedStream,\n )\n\n return new Response(responseStream as any, {\n status: router.stores.statusCode.state,\n headers: responseHeaders,\n })\n}\n"],"mappings":";;;;;;AAQA,SAASO,eACPC,UACgC;CAChC,MAAMC,UAAU,IAAIC,aAAa;CACjC,IAAIC,cAAc;AAElB,QAAO,IAAIV,eAA+B,EACxCW,MAAMC,YAAY;EAChB,MAAMC,SAASN,SAASO,WAAW;EAEnC,eAAeC,OAAsB;GACnC,MAAM,EAAEC,MAAMC,UAAU,MAAMJ,OAAOK,MAAM;AAC3C,OAAIF,MAAM;AACRJ,eAAWO,OAAO;AAClB;;AAGF,OAAI,CAACT,aAAa;AAChBA,kBAAc;AACdE,eAAWQ,QAAQZ,QAAQa,OAAO,kBAAkB,CAAC;;AAEvDT,cAAWQ,QAAQH,MAAM;AACzB,UAAOF,MAAM;;AAGfA,QAAM,CAACO,OAAOC,QAAQX,WAAWY,MAAMD,IAAI,CAAC;IAE/C,CAAC;;AAGJ,IAAaE,uBAAuB,OAAO,EACzCC,SACAC,QACAC,iBACAC,UAMI;CACJ,MAAMC,MAAM7B,IAAI8B,aAAaF,KAAK,EAAEF,QAAQ,CAAC;AAE7C,KAAIvB,MAAMsB,QAAQM,QAAQC,IAAI,aAAa,CAAC,EAAE;EAC5C,IAAIC,WAAW,MAAM/B,eAAe2B,IAAI;EAExC,MAAMK,gBAAgBD,SAASE,QAAQ,QAAQ;EAC/C,MAAMC,iBAAiBH,SAASE,QAAQ,UAAU;AAElD,MAAID,kBAAkB,MAAME,mBAAmB,GAC7CH,YAAWA,SAASI,MAAMH,eAAeE,iBAAiB,EAAE;WACnDF,kBAAkB,GAC3BD,YAAWA,SAASI,MAAMH,cAAc;AAG1C,SAAO,IAAII,SAAS,kBAAkBL,YAAY;GAChDM,QAAQb,OAAOc,OAAOC,WAAWC;GACjCX,SAASJ;GACV,CAAC;;CAGJ,MAAM,EAAEgB,UAAUrC,aAAa,IAAIsC,iBAAiB;AAEpD3C,mBAAkB4B,KAAK,EAAE,EAAEc,SAAS;CAGpC,MAAMG,iBAAiB1C,kCACrBsB,QAFqBrB,eAAeC,SAAS,CAI9C;AAED,QAAO,IAAIgC,SAASQ,gBAAuB;EACzCP,QAAQb,OAAOc,OAAOC,WAAWC;EACjCX,SAASJ;EACV,CAAC"}
|
|
@@ -8,7 +8,7 @@ var renderRouterToString = async ({ router, responseHeaders, App }) => {
|
|
|
8
8
|
const injectedHtml = router.serverSsr.takeBufferedHtml();
|
|
9
9
|
if (injectedHtml) html = html.replace(`</body>`, () => `${injectedHtml}</body>`);
|
|
10
10
|
return new Response(`<!DOCTYPE html>${html}`, {
|
|
11
|
-
status: router.
|
|
11
|
+
status: router.stores.statusCode.state,
|
|
12
12
|
headers: responseHeaders
|
|
13
13
|
});
|
|
14
14
|
} catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderRouterToString.js","names":["Vue","renderToString","vueRenderToString","renderRouterToString","router","responseHeaders","App","app","createSSRApp","html","serverSsr","setRenderFinished","injectedHtml","takeBufferedHtml","replace","Response","status","
|
|
1
|
+
{"version":3,"file":"renderRouterToString.js","names":["Vue","renderToString","vueRenderToString","renderRouterToString","router","responseHeaders","App","app","createSSRApp","html","serverSsr","setRenderFinished","injectedHtml","takeBufferedHtml","replace","Response","status","stores","statusCode","state","headers","error","console","cleanup"],"sources":["../../../src/ssr/renderRouterToString.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport { renderToString as vueRenderToString } from 'vue/server-renderer'\nimport type { AnyRouter } from '@tanstack/router-core'\nimport type { Component } from 'vue'\n\nexport const renderRouterToString = async ({\n router,\n responseHeaders,\n App,\n}: {\n router: AnyRouter\n responseHeaders: Headers\n App: Component\n}) => {\n try {\n const app = Vue.createSSRApp(App, { router })\n\n let html = await vueRenderToString(app)\n router.serverSsr!.setRenderFinished()\n\n const injectedHtml = router.serverSsr!.takeBufferedHtml()\n if (injectedHtml) {\n html = html.replace(`</body>`, () => `${injectedHtml}</body>`)\n }\n\n return new Response(`<!DOCTYPE html>${html}`, {\n status: router.stores.statusCode.state,\n headers: responseHeaders,\n })\n } catch (error) {\n console.error('Render to string error:', error)\n return new Response('Internal Server Error', {\n status: 500,\n headers: responseHeaders,\n })\n } finally {\n router.serverSsr?.cleanup()\n }\n}\n"],"mappings":";;;AAKA,IAAaG,uBAAuB,OAAO,EACzCC,QACAC,iBACAC,UAKI;AACJ,KAAI;EAGF,IAAIG,OAAO,MAAMP,eAFLF,IAAIQ,aAAaF,KAAK,EAAEF,QAAQ,CAAC,CAEN;AACvCA,SAAOM,UAAWC,mBAAmB;EAErC,MAAMC,eAAeR,OAAOM,UAAWG,kBAAkB;AACzD,MAAID,aACFH,QAAOA,KAAKK,QAAQ,iBAAiB,GAAGF,aAAY,SAAU;AAGhE,SAAO,IAAIG,SAAS,kBAAkBN,QAAQ;GAC5CO,QAAQZ,OAAOa,OAAOC,WAAWC;GACjCC,SAASf;GACV,CAAC;UACKgB,OAAO;AACdC,UAAQD,MAAM,2BAA2BA,MAAM;AAC/C,SAAO,IAAIN,SAAS,yBAAyB;GAC3CC,QAAQ;GACRI,SAASf;GACV,CAAC;WACM;AACRD,SAAOM,WAAWa,SAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useCanGoBack(): import('vue').Ref<boolean, boolean
|
|
1
|
+
export declare function useCanGoBack(): Readonly<import('vue').Ref<boolean, boolean>>;
|
package/dist/esm/useCanGoBack.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useRouter } from "./useRouter.js";
|
|
2
|
+
import { useStore } from "@tanstack/vue-store";
|
|
2
3
|
//#region src/useCanGoBack.ts
|
|
3
4
|
function useCanGoBack() {
|
|
4
|
-
return
|
|
5
|
+
return useStore(useRouter().stores.location, (location) => location.state.__TSR_index !== 0);
|
|
5
6
|
}
|
|
6
7
|
//#endregion
|
|
7
8
|
export { useCanGoBack };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCanGoBack.js","names":[],"sources":["../../src/useCanGoBack.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useCanGoBack.js","names":[],"sources":["../../src/useCanGoBack.ts"],"sourcesContent":["import { useStore } from '@tanstack/vue-store'\nimport { useRouter } from './useRouter'\n\nexport function useCanGoBack() {\n const router = useRouter()\n return useStore(\n router.stores.location,\n (location) => location.state.__TSR_index !== 0,\n )\n}\n"],"mappings":";;;AAGA,SAAgB,eAAe;AAE7B,QAAO,SADQ,WAAW,CAEjB,OAAO,WACb,aAAa,SAAS,MAAM,gBAAgB,EAC9C"}
|
package/dist/esm/useLocation.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useRouter } from "./useRouter.js";
|
|
2
|
+
import { useStore } from "@tanstack/vue-store";
|
|
2
3
|
//#region src/useLocation.tsx
|
|
3
4
|
function useLocation(opts) {
|
|
4
|
-
return
|
|
5
|
+
return useStore(useRouter().stores.location, (location) => opts?.select ? opts.select(location) : location);
|
|
5
6
|
}
|
|
6
7
|
//#endregion
|
|
7
8
|
export { useLocation };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocation.js","names":["
|
|
1
|
+
{"version":3,"file":"useLocation.js","names":["useStore","useRouter","useLocation","opts","router","stores","location","select"],"sources":["../../src/useLocation.tsx"],"sourcesContent":["import { useStore } from '@tanstack/vue-store'\nimport { useRouter } from './useRouter'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterState,\n} from '@tanstack/router-core'\nimport type * as Vue from 'vue'\n\nexport interface UseLocationBaseOptions<TRouter extends AnyRouter, TSelected> {\n select?: (state: RouterState<TRouter['routeTree']>['location']) => TSelected\n}\n\nexport type UseLocationResult<\n TRouter extends AnyRouter,\n TSelected,\n> = unknown extends TSelected\n ? RouterState<TRouter['routeTree']>['location']\n : TSelected\n\nexport function useLocation<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseLocationBaseOptions<TRouter, TSelected>,\n): Vue.Ref<UseLocationResult<TRouter, TSelected>> {\n const router = useRouter<TRouter>()\n return useStore(\n router.stores.location,\n (location) =>\n (opts?.select ? opts.select(location as any) : location) as any,\n ) as Vue.Ref<UseLocationResult<TRouter, TSelected>>\n}\n"],"mappings":";;;AAoBA,SAAgBE,YAIdC,MACgD;AAEhD,QAAOH,SADQC,WAAoB,CAE1BI,OAAOC,WACbA,aACEH,MAAMI,SAASJ,KAAKI,OAAOD,SAAgB,GAAGA,SAClD"}
|