@real-router/vue 0.10.1 → 0.12.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["NOOP_INSTANCE"],"sources":["../../src/components/RouteView/components.ts","../../src/components/RouteView/helpers.ts","../../src/useRefFromSource.ts","../../src/context.ts","../../src/composables/useRouter.ts","../../src/composables/useRouteNode.ts","../../src/components/RouteView/RouteView.ts","../../src/constants.ts","../../../../shared/dom-utils/route-announcer.ts","../../../../shared/dom-utils/scroll-restore.ts","../../../../shared/dom-utils/view-transitions.ts","../../../../shared/dom-utils/link-utils.ts","../../src/components/Link.ts","../../src/components/RouterErrorBoundary.ts","../../src/directives/vLink.ts","../../src/composables/useNavigator.ts","../../src/composables/useRouteUtils.ts","../../src/composables/useRoute.ts","../../src/composables/useRouterTransition.ts","../../src/composables/useRouteExit.ts","../../src/composables/useRouteEnter.ts","../../src/setupRouteProvision.ts","../../src/createRouterPlugin.ts","../../src/RouterProvider.ts"],"sourcesContent":["import { defineComponent } from \"vue\";\n\nimport type { SelfProps } from \"./types\";\nimport type { FunctionalComponent, PropType, VNode } from \"vue\";\n\nfunction renderNull() {\n return null;\n}\n\nexport const Match = defineComponent({\n name: \"RouteView.Match\",\n props: {\n segment: {\n type: String as PropType<string>,\n required: true,\n },\n exact: {\n type: Boolean,\n default: false,\n },\n fallback: {\n type: [Object, Function] as PropType<VNode | (() => VNode)>,\n default: undefined,\n },\n keepAlive: {\n type: Boolean,\n default: false,\n },\n },\n render: renderNull,\n});\n\n// Type Self via FunctionalComponent<SelfProps> so the SelfProps interface\n// is anchored to the component contract — knip otherwise flags SelfProps\n// as unused even though it's re-exported as RouteViewSelfProps for\n// consumers wrapping Self in custom HOCs.\nconst SelfImpl = defineComponent({\n name: \"RouteView.Self\",\n props: {\n fallback: {\n type: [Object, Function] as PropType<VNode | (() => VNode)>,\n default: undefined,\n },\n },\n render: renderNull,\n});\n\nexport const Self = SelfImpl as unknown as FunctionalComponent<SelfProps>;\n\nexport const NotFound = defineComponent({\n name: \"RouteView.NotFound\",\n render: renderNull,\n});\n","import { UNKNOWN_ROUTE } from \"@real-router/core\";\nimport { startsWithSegment } from \"@real-router/route-utils\";\nimport { Fragment, isVNode } from \"vue\";\n\nimport { Match, NotFound, Self } from \"./components\";\n\nimport type { VNode } from \"vue\";\n\ntype FallbackType = VNode | (() => VNode) | undefined;\n\ninterface FallbackSlots {\n selfVNode: VNode | null;\n selfFallback: FallbackType;\n notFoundChildren: unknown;\n}\n\nfunction isSegmentMatch(\n routeName: string,\n fullSegmentName: string,\n exact: boolean,\n): boolean {\n if (exact) {\n return routeName === fullSegmentName;\n }\n\n return startsWithSegment(routeName, fullSegmentName);\n}\n\nfunction normalizeChildren(children: unknown): VNode[] {\n if (Array.isArray(children)) {\n const result: VNode[] = [];\n\n for (const child of children) {\n if (Array.isArray(child)) {\n result.push(...normalizeChildren(child));\n } else if (isVNode(child)) {\n result.push(child);\n }\n }\n\n return result;\n }\n\n if (isVNode(children)) {\n return [children];\n }\n\n return [];\n}\n\nexport function collectElements(children: unknown, result: VNode[]): void {\n const vnodes = normalizeChildren(children);\n\n for (const child of vnodes) {\n if (\n child.type === Match ||\n child.type === Self ||\n child.type === NotFound\n ) {\n result.push(child);\n } else if (child.type === Fragment) {\n collectElements(child.children, result);\n }\n }\n}\n\nfunction recordFallback(child: VNode, slots: FallbackSlots): boolean {\n if (child.type === NotFound) {\n slots.notFoundChildren = child.children;\n\n return true;\n }\n\n if (child.type === Self) {\n if (slots.selfVNode === null) {\n slots.selfVNode = child;\n const props = child.props as { fallback?: FallbackType } | null;\n\n slots.selfFallback = props?.fallback;\n }\n\n return true;\n }\n\n return false;\n}\n\nfunction evaluateMatch(\n child: VNode,\n routeName: string,\n nodeName: string,\n): { isActive: boolean; fallback: FallbackType } {\n const props = child.props as {\n segment: string;\n exact?: boolean;\n fallback?: FallbackType;\n } | null;\n const segment = props?.segment ?? \"\";\n const exact = props?.exact ?? false;\n const fullSegmentName = nodeName ? `${nodeName}.${segment}` : segment;\n const isActive = isSegmentMatch(routeName, fullSegmentName, exact);\n\n return { isActive, fallback: props?.fallback };\n}\n\nfunction appendFallback(\n rendered: VNode[],\n routeName: string,\n nodeName: string,\n slots: FallbackSlots,\n elements: VNode[],\n): FallbackType {\n if (slots.selfVNode !== null && routeName === nodeName) {\n rendered.push(slots.selfVNode);\n\n return slots.selfFallback;\n }\n\n if (routeName === UNKNOWN_ROUTE && slots.notFoundChildren !== null) {\n const nfElements = elements.filter((element) => element.type === NotFound);\n /* v8 ignore next 3 */\n const lastNf = nfElements.at(-1);\n\n if (lastNf) {\n rendered.push(lastNf);\n }\n }\n\n return undefined;\n}\n\nexport function buildRenderList(\n elements: VNode[],\n routeName: string,\n nodeName: string,\n): {\n rendered: VNode[];\n activeMatchFound: boolean;\n fallback?: FallbackType;\n} {\n const slots: FallbackSlots = {\n selfVNode: null,\n selfFallback: undefined,\n notFoundChildren: null,\n };\n let activeMatchFound = false;\n let fallback: FallbackType = undefined;\n const rendered: VNode[] = [];\n\n for (const child of elements) {\n if (recordFallback(child, slots)) {\n continue;\n }\n\n if (activeMatchFound) {\n continue;\n }\n\n const result = evaluateMatch(child, routeName, nodeName);\n\n if (result.isActive) {\n activeMatchFound = true;\n fallback = result.fallback;\n rendered.push(child);\n }\n }\n\n if (!activeMatchFound) {\n fallback = appendFallback(rendered, routeName, nodeName, slots, elements);\n }\n\n return { rendered, activeMatchFound, fallback };\n}\n","import { shallowRef, onScopeDispose } from \"vue\";\n\nimport type { RouterSource } from \"@real-router/sources\";\nimport type { ShallowRef } from \"vue\";\n\nexport function useRefFromSource<T>(source: RouterSource<T>): ShallowRef<T> {\n const ref = shallowRef(source.getSnapshot());\n\n const unsub = source.subscribe(() => {\n ref.value = source.getSnapshot();\n });\n\n onScopeDispose(unsub);\n\n return ref;\n}\n","import type { RouteContext as RouteContextType } from \"./types\";\nimport type { Router, Navigator } from \"@real-router/core\";\nimport type { InjectionKey } from \"vue\";\n\nexport const RouterKey: InjectionKey<Router> = Symbol(\"RouterKey\");\n\nexport const NavigatorKey: InjectionKey<Navigator> = Symbol(\"NavigatorKey\");\n\nexport const RouteKey: InjectionKey<RouteContextType> = Symbol(\"RouteKey\");\n","import { inject } from \"vue\";\n\nimport { RouterKey } from \"../context\";\n\nimport type { Router } from \"@real-router/core\";\n\nexport const useRouter = (): Router => {\n const router = inject(RouterKey);\n\n if (!router) {\n throw new Error(\"useRouter must be used within a RouterProvider\");\n }\n\n return router;\n};\n","import { getNavigator } from \"@real-router/core\";\nimport { createRouteNodeSource } from \"@real-router/sources\";\nimport { computed } from \"vue\";\n\nimport { useRefFromSource } from \"../useRefFromSource\";\nimport { useRouter } from \"./useRouter\";\n\nimport type { RouteContext } from \"../types\";\n\nexport function useRouteNode(nodeName: string): RouteContext {\n const router = useRouter();\n\n const source = createRouteNodeSource(router, nodeName);\n const snapshot = useRefFromSource(source);\n\n // getNavigator is WeakMap-cached in core; no useMemo equivalent needed.\n const navigator = getNavigator(router);\n\n // Derive route/previousRoute via computed instead of mirroring with a sync\n // watch into two extra shallowRefs. computed shares snapshot's identity so\n // when the underlying source emits the same reference (idempotent or\n // out-of-node nav), consumers don't see a new ref.\n const route = computed(() => snapshot.value.route);\n const previousRoute = computed(() => snapshot.value.previousRoute);\n\n return {\n navigator,\n route,\n previousRoute,\n };\n}\n","import {\n Fragment,\n defineComponent,\n h,\n KeepAlive,\n markRaw,\n Suspense,\n} from \"vue\";\n\nimport { Match, NotFound, Self } from \"./components\";\nimport { buildRenderList, collectElements } from \"./helpers\";\nimport { useRouteNode } from \"../../composables/useRouteNode\";\n\nimport type { Component, VNode } from \"vue\";\n\ntype SlotChildren = Record<string, (() => VNode[]) | undefined> | null;\n\nfunction getSlotContent(vnode: VNode): VNode[] | null {\n const slots = vnode.children as SlotChildren;\n\n return slots?.default?.() ?? null;\n}\n\nfunction getOrCreateWrapper(\n cache: Map<string, Component>,\n segment: string,\n): Component {\n const existing = cache.get(segment);\n\n if (existing) {\n return existing;\n }\n\n const wrapper = markRaw(\n defineComponent({\n name: `KeepAlive-${segment}`,\n setup(_wrapperProps, wrapperCtx) {\n return () => wrapperCtx.slots.default?.();\n },\n }),\n );\n\n cache.set(segment, wrapper);\n\n return wrapper;\n}\n\nfunction wrapWithSuspense(content: VNode, fallback: unknown): VNode {\n if (fallback === undefined) {\n return content;\n }\n\n const fallbackContent =\n typeof fallback === \"function\" ? (fallback as () => VNode)() : fallback;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment\n const suspenseComponent = Suspense as any;\n\n return h(\n suspenseComponent,\n {},\n {\n default: () => content,\n fallback: () => fallbackContent,\n },\n );\n}\n\nconst emptyKeepAlivePlaceholder = markRaw(\n defineComponent({\n name: \"KeepAlive-placeholder\",\n render() {\n return null;\n },\n }),\n);\n\nfunction renderWithRootKA(\n activeChild: VNode,\n wrapperCache: Map<string, Component>,\n fallback: unknown,\n): VNode {\n const activeProps = activeChild.props as { segment?: string } | null;\n const segment = activeProps?.segment ?? \"__not-found__\";\n const WrapperComponent = getOrCreateWrapper(wrapperCache, segment);\n const slotContent = getSlotContent(activeChild) ?? [];\n const keepAliveContent = h(KeepAlive, null, {\n default: () =>\n h(WrapperComponent, { key: segment }, { default: () => slotContent }),\n });\n\n return wrapWithSuspense(keepAliveContent, fallback);\n}\n\n// Vue compiles boolean-shorthand template attributes (`<Match keepAlive>`) to\n// an empty string instead of `true`, and converts them to `true` only when the\n// receiving component's prop is declared with `type: Boolean`. `Match` is a\n// marker component (`render: null`) — its props are inspected on the VNode\n// without ever going through Vue's prop-casting pipeline, so the raw `\"\"` (or\n// the hyphenated attribute name) reaches us here. Accept the same trio Vue's\n// runtime does.\nfunction isKeepAliveEnabled(value: unknown): boolean {\n return value === true || value === \"\" || value === \"keep-alive\";\n}\n\nfunction renderWithPerMatchKA(\n activeChild: VNode,\n wrapperCache: Map<string, Component>,\n fallback: unknown,\n): VNode | null {\n const matchProps = activeChild.props as {\n segment?: string;\n keepAlive?: unknown;\n } | null;\n\n if (isKeepAliveEnabled(matchProps?.keepAlive) && activeChild.type === Match) {\n /* v8 ignore start */\n const segment = matchProps?.segment ?? \"__not-found__\";\n /* v8 ignore stop */\n const WrapperComponent = getOrCreateWrapper(wrapperCache, segment);\n const slotContent = getSlotContent(activeChild) ?? [];\n\n return h(Fragment, [\n h(KeepAlive, null, {\n default: () =>\n h(WrapperComponent, { key: segment }, { default: () => slotContent }),\n }),\n ]);\n }\n\n const content = getSlotContent(activeChild);\n\n /* v8 ignore start */\n if (!content) {\n return null;\n }\n /* v8 ignore stop */\n\n return h(Fragment, [\n h(KeepAlive, null, { default: () => h(emptyKeepAlivePlaceholder) }),\n wrapWithSuspense(h(Fragment, content), fallback),\n ]);\n}\n\nconst RouteViewComponent = defineComponent({\n name: \"RouteView\",\n props: {\n nodeName: {\n type: String,\n required: true,\n },\n keepAlive: {\n type: Boolean,\n default: false,\n },\n },\n setup(props, { slots }) {\n const routeContext = useRouteNode(props.nodeName);\n const wrapperCache = new Map<string, Component>();\n\n // Cache per-Match `keepAlive` detection by slot output identity. Slot\n // contents change reference only when the parent re-renders with new\n // children, so steady-state navigations skip the O(n) `.some(...)` scan.\n let lastSlotOutput: unknown = null;\n let lastHasPerMatchKA = false;\n\n function detectPerMatchKA(elements: VNode[], slotOutput: unknown): boolean {\n /* v8 ignore next 3 -- @preserve: Vue's compiled slot wrapper allocates a\n new array per render call in JSDOM tests; identity-cache hits in\n production where parent compiled templates share slot output, but\n is unobservable through TestBed-style assertions. */\n if (slotOutput === lastSlotOutput) {\n return lastHasPerMatchKA;\n }\n\n lastSlotOutput = slotOutput;\n lastHasPerMatchKA = elements.some(\n (element) =>\n element.type === Match &&\n isKeepAliveEnabled(\n (element.props as { keepAlive?: unknown } | null)?.keepAlive,\n ),\n );\n\n return lastHasPerMatchKA;\n }\n\n return (): VNode | null => {\n const route = routeContext.route.value;\n\n if (!route) {\n return null;\n }\n\n const slotOutput = slots.default?.();\n const elements: VNode[] = [];\n\n collectElements(slotOutput, elements);\n\n const { rendered, fallback } = buildRenderList(\n elements,\n route.name,\n props.nodeName,\n );\n\n if (rendered.length === 0) {\n return null;\n }\n\n const activeChild = rendered[0];\n\n if (props.keepAlive) {\n return renderWithRootKA(activeChild, wrapperCache, fallback);\n }\n\n /* v8 ignore start */\n if (\n activeChild.type !== Match &&\n activeChild.type !== Self &&\n activeChild.type !== NotFound\n ) {\n return null;\n }\n /* v8 ignore stop */\n\n const hasPerMatchKA = detectPerMatchKA(elements, slotOutput);\n\n if (hasPerMatchKA) {\n return renderWithPerMatchKA(activeChild, wrapperCache, fallback);\n }\n\n const content = getSlotContent(activeChild);\n\n if (!content) {\n return null;\n }\n\n return wrapWithSuspense(h(Fragment, content), fallback);\n };\n },\n});\n\nexport const RouteView = Object.assign(RouteViewComponent, {\n Match,\n Self,\n NotFound,\n});\n\nexport type {\n RouteViewProps,\n MatchProps as RouteViewMatchProps,\n SelfProps as RouteViewSelfProps,\n NotFoundProps as RouteViewNotFoundProps,\n} from \"./types\";\n","/**\n * Stable empty object for default params\n */\nexport const EMPTY_PARAMS = Object.freeze({});\n\n/**\n * Stable empty options object\n */\nexport const EMPTY_OPTIONS = Object.freeze({});\n","import type { Router, State } from \"@real-router/core\";\n\nconst CLEAR_DELAY = 7000;\nconst SAFARI_READY_DELAY = 100;\nconst ANNOUNCER_ATTR = \"data-real-router-announcer\";\nconst INTERNAL_ROUTE_PREFIX = \"@@\";\nconst VISUALLY_HIDDEN =\n \"position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);clip-path:inset(50%);white-space:nowrap;border:0\";\n\nexport interface RouteAnnouncerOptions {\n prefix?: string;\n getAnnouncementText?: (route: State) => string;\n}\n\nexport function createRouteAnnouncer(\n router: Router,\n options?: RouteAnnouncerOptions,\n): { destroy: () => void } {\n const prefix = options?.prefix ?? \"Navigated to \";\n const getCustomText = options?.getAnnouncementText;\n\n let isInitialNavigation = true;\n let isReady = false;\n let isDestroyed = false;\n let lastAnnouncedText = \"\";\n let pendingText: string | null = null;\n let clearTimeoutId: ReturnType<typeof setTimeout> | undefined;\n\n const announcer = getOrCreateAnnouncer();\n\n const doAnnounce = (text: string, h1: HTMLElement | null): void => {\n lastAnnouncedText = text;\n clearTimeout(clearTimeoutId);\n announcer.textContent = text;\n clearTimeoutId = setTimeout(() => {\n announcer.textContent = \"\";\n lastAnnouncedText = \"\";\n }, CLEAR_DELAY);\n\n manageFocus(h1);\n };\n\n // Safari-ready delay: announcing before VoiceOver wires up the aria-live region\n // causes the first announcement to be silently dropped. Wait SAFARI_READY_DELAY ms\n // before marking the announcer \"ready\" — any navigation during that window is\n // buffered in pendingText and flushed once the delay expires.\n const safariTimeoutId = setTimeout(() => {\n isReady = true;\n\n if (pendingText !== null && !isDestroyed) {\n const text = pendingText;\n\n pendingText = null;\n doAnnounce(text, document.querySelector<HTMLElement>(\"h1\"));\n }\n }, SAFARI_READY_DELAY);\n\n const unsubscribe = router.subscribe(({ route }) => {\n if (isInitialNavigation) {\n isInitialNavigation = false;\n\n return;\n }\n\n // Double rAF: waits for two paint frames so the incoming route's DOM\n // (including the new <h1>) is fully rendered before resolveText reads it.\n // Single rAF fires before the new route's template has been attached,\n // which would cause resolveText to pick up the OLD h1 or fall back to\n // document.title / route.name prematurely.\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n if (isDestroyed) {\n return;\n }\n\n const h1 = document.querySelector<HTMLElement>(\"h1\");\n const text = resolveText(route, prefix, getCustomText, h1);\n\n if (!text || text === lastAnnouncedText) {\n return;\n }\n\n if (!isReady) {\n // Defer announcement until Safari-ready window elapses (see safariTimeoutId).\n pendingText = text;\n\n return;\n }\n\n doAnnounce(text, h1);\n });\n });\n });\n\n return {\n destroy() {\n isDestroyed = true;\n unsubscribe();\n clearTimeout(clearTimeoutId);\n clearTimeout(safariTimeoutId);\n removeAnnouncer();\n },\n };\n}\n\nfunction getOrCreateAnnouncer(): HTMLElement {\n const existing = document.querySelector<HTMLElement>(`[${ANNOUNCER_ATTR}]`);\n\n if (existing) {\n return existing;\n }\n\n const element = document.createElement(\"div\");\n\n element.setAttribute(\"style\", VISUALLY_HIDDEN);\n element.setAttribute(\"aria-live\", \"assertive\");\n element.setAttribute(\"aria-atomic\", \"true\");\n element.setAttribute(ANNOUNCER_ATTR, \"\");\n\n document.body.prepend(element);\n\n return element;\n}\n\nfunction removeAnnouncer(): void {\n document.querySelector(`[${ANNOUNCER_ATTR}]`)?.remove();\n}\n\nfunction resolveText(\n route: State,\n prefix: string,\n getCustomText: ((route: State) => string) | undefined,\n h1: HTMLElement | null,\n): string {\n if (getCustomText) {\n return getCustomText(route);\n }\n\n const h1Text = (h1?.textContent ?? \"\").trim();\n const routeName = route.name.startsWith(INTERNAL_ROUTE_PREFIX)\n ? \"\"\n : route.name;\n const rawText =\n h1Text || document.title || routeName || globalThis.location.pathname;\n\n return `${prefix}${rawText}`;\n}\n\nfunction manageFocus(h1: HTMLElement | null): void {\n if (!h1) {\n return;\n }\n\n if (!h1.hasAttribute(\"tabindex\")) {\n h1.setAttribute(\"tabindex\", \"-1\");\n }\n\n h1.focus({ preventScroll: true });\n}\n","import type { Router, State } from \"@real-router/core\";\n\nconst STORAGE_KEY = \"real-router:scroll\";\n\nconst NOOP_INSTANCE: { destroy: () => void } = Object.freeze({\n destroy: () => {\n /* no-op */\n },\n});\n\nexport type ScrollRestorationMode = \"restore\" | \"top\" | \"manual\";\n\nexport interface ScrollRestorationOptions {\n mode?: ScrollRestorationMode | undefined;\n anchorScrolling?: boolean | undefined;\n scrollContainer?: (() => HTMLElement | null) | undefined;\n}\n\ninterface NavigationContext {\n direction?: \"forward\" | \"back\" | \"unknown\";\n navigationType?: \"push\" | \"replace\" | \"traverse\" | \"reload\";\n}\n\nexport function createScrollRestoration(\n router: Router,\n options?: ScrollRestorationOptions,\n): { destroy: () => void } {\n if (typeof globalThis.window === \"undefined\") {\n return NOOP_INSTANCE;\n }\n\n const mode = options?.mode ?? \"restore\";\n\n // mode \"manual\" = utility does nothing. Don't flip history.scrollRestoration,\n // don't subscribe, don't register pagehide — leave the browser's native\n // auto-restore intact for the app to override if it wants to.\n if (mode === \"manual\") {\n return NOOP_INSTANCE;\n }\n\n const anchorEnabled = options?.anchorScrolling ?? true;\n const getContainer = options?.scrollContainer;\n\n const prevScrollRestoration = history.scrollRestoration;\n\n try {\n history.scrollRestoration = \"manual\";\n } catch {\n // Ignore — some embedded contexts may reject the assignment.\n }\n\n // Resolve the container lazily on every event so containers mounted AFTER\n // the provider still get correct scroll handling. Falls back to window when\n // the getter is absent or returns null (pre-mount).\n const readPos = (): number => {\n const element = getContainer?.();\n\n return element ? element.scrollTop : globalThis.scrollY;\n };\n\n const writePos = (top: number): void => {\n const element = getContainer?.();\n\n if (element) {\n element.scrollTop = top;\n } else {\n globalThis.scrollTo(0, top);\n }\n };\n\n const scrollToHashOrTop = (): void => {\n const hash = globalThis.location.hash;\n\n if (anchorEnabled && hash.length > 1) {\n // location.hash is percent-encoded; ids in the DOM are the raw string.\n // Decode for the match. Fall back to the raw slice if the hash contains\n // a malformed escape sequence (decodeURIComponent throws on those).\n let id: string;\n\n try {\n id = decodeURIComponent(hash.slice(1));\n } catch {\n id = hash.slice(1);\n }\n\n // eslint-disable-next-line unicorn/prefer-query-selector -- ids may contain CSS-unsafe chars\n const element = document.getElementById(id);\n\n if (element) {\n element.scrollIntoView();\n\n return;\n }\n }\n\n writePos(0);\n };\n\n let destroyed = false;\n\n const unsubscribe = router.subscribe(({ route, previousRoute }) => {\n const nav = (route.context as { navigation?: NavigationContext })\n .navigation;\n\n // Browsers dispatch reload as the initial navigation after refresh, so\n // previousRoute is undefined and capture is naturally skipped. The\n // pre-refresh position was already persisted via pagehide.\n if (previousRoute) {\n putPos(keyOf(previousRoute), readPos());\n }\n\n // Single rAF so DOM is committed before we read anchors / write scroll.\n // Guard against destroy() racing with the callback.\n requestAnimationFrame(() => {\n if (destroyed) {\n return;\n }\n\n if (mode === \"top\" || !nav) {\n scrollToHashOrTop();\n\n return;\n }\n\n if (nav.navigationType === \"replace\") {\n return;\n }\n\n if (\n nav.direction === \"back\" ||\n nav.navigationType === \"traverse\" ||\n nav.navigationType === \"reload\"\n ) {\n writePos(loadStore()[keyOf(route)] ?? 0);\n\n return;\n }\n\n scrollToHashOrTop();\n });\n });\n\n const onPageHide = (): void => {\n const current = router.getState();\n\n if (current) {\n putPos(keyOf(current), readPos());\n }\n };\n\n globalThis.addEventListener(\"pagehide\", onPageHide);\n\n return {\n destroy: () => {\n if (destroyed) {\n return;\n }\n\n destroyed = true;\n unsubscribe();\n globalThis.removeEventListener(\"pagehide\", onPageHide);\n\n try {\n history.scrollRestoration = prevScrollRestoration;\n } catch {\n // Ignore.\n }\n },\n };\n}\n\nfunction keyOf(state: State): string {\n return `${state.name}:${canonicalJson(state.params)}`;\n}\n\nfunction loadStore(): Record<string, number> {\n try {\n const raw = sessionStorage.getItem(STORAGE_KEY);\n\n return raw ? (JSON.parse(raw) as Record<string, number>) : {};\n } catch {\n return {};\n }\n}\n\nfunction putPos(key: string, pos: number): void {\n try {\n const store = loadStore();\n\n store[key] = pos;\n sessionStorage.setItem(STORAGE_KEY, JSON.stringify(store));\n } catch {\n // Ignore quota / security errors.\n }\n}\n\nfunction canonicalJson(value: unknown): string {\n return JSON.stringify(value, canonicalReplacer);\n}\n\nfunction canonicalReplacer(_key: string, val: unknown): unknown {\n if (val !== null && typeof val === \"object\" && !Array.isArray(val)) {\n const sorted: Record<string, unknown> = {};\n // eslint-disable-next-line unicorn/no-array-sort -- ng-packagr uses pre-ES2023 lib; toSorted unavailable\n const keys = Object.keys(val as Record<string, unknown>).sort(\n (left: string, right: string) => left.localeCompare(right),\n );\n\n for (const key of keys) {\n sorted[key] = (val as Record<string, unknown>)[key];\n }\n\n return sorted;\n }\n\n return val;\n}\n","import type { Router } from \"@real-router/core\";\n\nexport interface ViewTransitions {\n destroy: () => void;\n}\n\nconst NOOP_INSTANCE: ViewTransitions = Object.freeze({\n destroy: () => {\n /* no-op */\n },\n});\n\nexport function createViewTransitions(router: Router): ViewTransitions {\n if (\n typeof document === \"undefined\" ||\n typeof document.startViewTransition !== \"function\"\n ) {\n return NOOP_INSTANCE;\n }\n\n let closeVT: (() => void) | null = null;\n let currentVT: { skipTransition?: () => void } | null = null;\n // Tracks whether TRANSITION_SUCCESS fired for the current leave. Used to\n // distinguish \"benign cleanup abort\" (router's async path aborts its own\n // controller in a finally block after successful navigation) from \"real\n // cancellation\" (concurrent navigate, guard rejection, dispose).\n let successFired = false;\n\n const resolveAndClear = (): void => {\n closeVT?.();\n closeVT = null;\n };\n\n const offLeave = router.subscribeLeave(({ signal }) => {\n // Reentrant abort: signal already aborted when we're called. Open no VT\n // — router will fall through to TRANSITION_CANCELLED via isCurrentNav()\n // after leave resolves. addEventListener(\"abort\", ...) does not re-fire\n // for past events, so skipping startViewTransition is the safe path.\n if (signal.aborted) {\n return;\n }\n\n successFired = false;\n resolveAndClear();\n\n // Return a Promise so the router awaits until the browser invokes\n // updateCallback. This ensures old DOM snapshot is captured BEFORE the\n // router commits the new state — giving correct exit→state→entry\n // ordering (vs fire-and-forget, where URL changes before VT captures).\n return new Promise<void>((resolveLeave) => {\n // Capture the resolver synchronously BEFORE startViewTransition() is\n // called. The browser invokes updateCallback in a later task, but\n // router.subscribe (TRANSITION_SUCCESS) can fire before that. If we\n // captured `resolve` inside the callback, subscribe would see closeVT\n // still null and skip resolving — the deferred would hang for 4s\n // until the VT API aborts with TimeoutError.\n const deferred = new Promise<void>((resolve) => {\n closeVT = resolve;\n });\n\n signal.addEventListener(\n \"abort\",\n () => {\n if (successFired) {\n // Router's async path (#finishAsyncNavigation) aborts its own\n // controller in a finally block AFTER completeTransition (and\n // thus AFTER subscribe fired). This is cleanup, not\n // cancellation — VT is progressing normally, do nothing.\n return;\n }\n\n // Real cancellation (concurrent navigate, dispose). Resolve the\n // deferred so updateCallback can complete, skip the VT so no\n // stale animation leaks, and unblock the router if the abort\n // fires before updateCallback was invoked.\n resolveAndClear();\n currentVT?.skipTransition?.();\n resolveLeave();\n },\n { once: true },\n );\n\n try {\n currentVT = document.startViewTransition(() => {\n // Resolving here unblocks the router at the moment the browser\n // enters updateCallback — by spec, old DOM snapshot is captured\n // before this callback runs. Router now proceeds through\n // activation guards and setState; the VT animation waits on\n // `deferred`, which is resolved from router.subscribe after a\n // task-queue tick (see NOTE on setTimeout below).\n resolveLeave();\n\n return deferred;\n });\n } catch {\n // Defensive: spec says startViewTransition doesn't throw under\n // normal conditions, but Chromium has had edge cases (detached\n // document, extension interference). Clean up and unblock router.\n resolveAndClear();\n resolveLeave();\n }\n });\n });\n\n const offSuccess = router.subscribe(() => {\n const resolver = closeVT;\n\n successFired = true;\n closeVT = null;\n\n if (resolver === null) {\n currentVT = null;\n } else {\n // CRITICAL: CANNOT use requestAnimationFrame here. When the router\n // takes the async path (leave returned a Promise), subscribe fires\n // AFTER the browser has already transitioned VT into the\n // \"update-callback-called\" phase. In that phase Chromium sets\n // rendering suppression to true, which ALSO blocks rAF callbacks.\n // rAF would never fire → deferred never resolves → browser aborts\n // vt.ready with TimeoutError after 4s (observed in Chromium).\n //\n // setTimeout runs on the task queue independent of the rendering\n // pipeline, so it fires regardless of suppression. React's scheduler\n // uses MessageChannel tasks, which are queued before our setTimeout,\n // so the new DOM is committed by the time our callback runs.\n setTimeout(() => {\n resolver();\n currentVT = null;\n }, 0);\n }\n });\n\n return {\n destroy: () => {\n offLeave();\n offSuccess();\n currentVT?.skipTransition?.();\n currentVT = null;\n resolveAndClear();\n },\n };\n}\n","import type { Router, Params } from \"@real-router/core\";\n\nexport function shouldNavigate(evt: MouseEvent): boolean {\n return (\n evt.button === 0 &&\n !evt.metaKey &&\n !evt.altKey &&\n !evt.ctrlKey &&\n !evt.shiftKey\n );\n}\n\ntype BuildUrlFn = (name: string, params: Params) => string | undefined;\n\nexport function buildHref(\n router: Router,\n routeName: string,\n routeParams: Params,\n): string | undefined {\n try {\n const buildUrl = router.buildUrl as BuildUrlFn | undefined;\n\n if (buildUrl) {\n const url = buildUrl(routeName, routeParams);\n\n if (url !== undefined) {\n return url;\n }\n }\n\n return router.buildPath(routeName, routeParams);\n } catch {\n console.error(\n `[real-router] Route \"${routeName}\" is not defined. The element will render without an href attribute.`,\n );\n\n return undefined;\n }\n}\n\nfunction parseTokens(value: string | undefined): string[] {\n return value ? (value.match(/\\S+/g) ?? []) : [];\n}\n\nexport function buildActiveClassName(\n isActive: boolean,\n activeClassName: string | undefined,\n baseClassName: string | undefined,\n): string | undefined {\n if (isActive && activeClassName) {\n const activeTokens = parseTokens(activeClassName);\n\n if (activeTokens.length === 0) {\n return baseClassName ?? undefined;\n }\n if (!baseClassName) {\n return activeTokens.join(\" \");\n }\n\n const baseTokens = parseTokens(baseClassName);\n const seen = new Set(baseTokens);\n\n for (const token of activeTokens) {\n if (!seen.has(token)) {\n seen.add(token);\n baseTokens.push(token);\n }\n }\n\n return baseTokens.join(\" \");\n }\n\n return baseClassName ?? undefined;\n}\n\nexport function shallowEqual(\n prev: object | undefined,\n next: object | undefined,\n): boolean {\n if (Object.is(prev, next)) {\n return true;\n }\n if (!prev || !next) {\n return false;\n }\n\n const prevKeys = Object.keys(prev);\n\n if (prevKeys.length !== Object.keys(next).length) {\n return false;\n }\n\n const prevRecord = prev as Record<string, unknown>;\n const nextRecord = next as Record<string, unknown>;\n\n for (const key of prevKeys) {\n if (!Object.is(prevRecord[key], nextRecord[key])) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function applyLinkA11y(element: HTMLElement | null | undefined): void {\n if (!element) {\n return;\n }\n if (\n element instanceof HTMLAnchorElement ||\n element instanceof HTMLButtonElement\n ) {\n return;\n }\n if (!element.hasAttribute(\"role\")) {\n element.setAttribute(\"role\", \"link\");\n }\n if (!element.hasAttribute(\"tabindex\")) {\n element.setAttribute(\"tabindex\", \"0\");\n }\n}\n","import { createActiveRouteSource } from \"@real-router/sources\";\nimport { defineComponent, h, computed, shallowRef, watch } from \"vue\";\n\nimport { useRouter } from \"../composables/useRouter\";\nimport { EMPTY_PARAMS, EMPTY_OPTIONS } from \"../constants\";\nimport { shouldNavigate, buildHref, buildActiveClassName } from \"../dom-utils\";\n\nimport type { Params, NavigationOptions } from \"@real-router/core\";\nimport type { PropType } from \"vue\";\n\ntype OnClickHandler = (evt: MouseEvent) => void;\n\n/**\n * Vue's compiled template binds multiple `@click` handlers as an array.\n * Single render-function `onClick` is a function. Both must be invoked.\n */\nfunction invokeAttributesOnClick(value: unknown, evt: MouseEvent): void {\n if (typeof value === \"function\") {\n (value as OnClickHandler)(evt);\n\n return;\n }\n if (Array.isArray(value)) {\n const handlers = value as OnClickHandler[];\n\n for (const fn of handlers) {\n if (typeof fn === \"function\") {\n fn(evt);\n\n if (evt.defaultPrevented) {\n return;\n }\n }\n }\n }\n}\n\nexport const Link = defineComponent({\n name: \"Link\",\n // Disable Vue's automatic attribute fallthrough. Without this, attrs.onClick\n // (function OR array) is auto-attached as a native click listener AND our\n // explicit onClick fires too — user handlers are double-invoked. We invoke\n // attrs.onClick manually inside handleClick to preserve preventDefault.\n inheritAttrs: false,\n props: {\n routeName: {\n type: String,\n required: true,\n },\n routeParams: {\n type: Object as PropType<Params>,\n default: () => EMPTY_PARAMS,\n },\n routeOptions: {\n type: Object as PropType<NavigationOptions>,\n default: () => EMPTY_OPTIONS,\n },\n class: {\n type: String,\n default: undefined,\n },\n activeClassName: {\n type: String,\n default: \"active\",\n },\n activeStrict: {\n type: Boolean,\n default: false,\n },\n ignoreQueryParams: {\n type: Boolean,\n default: true,\n },\n target: {\n type: String,\n default: undefined,\n },\n },\n setup(props, { slots, attrs }) {\n const router = useRouter();\n\n const isActive = shallowRef(false);\n\n // watch with an explicit dep getter recreates the source ONLY when\n // routeName/routeParams/strict/ignoreQueryParams change — not on every\n // reactive read inside the source factory (the watchEffect alternative\n // would also re-subscribe whenever isActive itself changed).\n watch(\n () =>\n [\n props.routeName,\n props.routeParams,\n props.activeStrict,\n props.ignoreQueryParams,\n ] as const,\n (\n [routeName, routeParams, activeStrict, ignoreQueryParams],\n _prev,\n onCleanup,\n ) => {\n const source = createActiveRouteSource(router, routeName, routeParams, {\n strict: activeStrict,\n ignoreQueryParams,\n });\n\n isActive.value = source.getSnapshot();\n\n const unsub = source.subscribe(() => {\n isActive.value = source.getSnapshot();\n });\n\n onCleanup(unsub);\n },\n { immediate: true, flush: \"sync\" },\n );\n\n const href = computed(() =>\n buildHref(router, props.routeName, props.routeParams),\n );\n\n const finalClassName = computed(() =>\n buildActiveClassName(isActive.value, props.activeClassName, props.class),\n );\n\n const handleClick = (evt: MouseEvent) => {\n // Vue allows attrs.onClick to be a function or an array of functions\n // (compiled templates with multiple @click bindings produce arrays).\n // Both must be invoked; treating arrays as \"no handler\" silently drops\n // user code.\n if (attrs.onClick !== undefined && attrs.onClick !== null) {\n invokeAttributesOnClick(attrs.onClick, evt);\n\n if (evt.defaultPrevented) {\n return;\n }\n }\n\n if (!shouldNavigate(evt) || props.target === \"_blank\") {\n return;\n }\n\n evt.preventDefault();\n router\n .navigate(props.routeName, props.routeParams, props.routeOptions)\n .catch(() => {});\n };\n\n return () => {\n // Build forwarded attrs without `onClick`. Vue's runtime auto-attaches\n // attrs.onClick (function OR array) as a native DOM listener, which would\n // double-invoke user handlers when combined with our explicit `onClick`.\n // We invoke the original attrs.onClick manually inside handleClick so the\n // preventDefault contract is preserved.\n const restAttributes: Record<string, unknown> = {};\n\n for (const key of Object.keys(attrs)) {\n if (key !== \"onClick\") {\n restAttributes[key] = (attrs as Record<string, unknown>)[key];\n }\n }\n\n return h(\n \"a\",\n {\n ...restAttributes,\n href: href.value,\n class: finalClassName.value,\n target: props.target,\n onClick: handleClick,\n },\n slots.default?.(),\n );\n };\n },\n});\n","import { createDismissableError } from \"@real-router/sources\";\nimport { defineComponent, h, watch, Fragment } from \"vue\";\n\nimport { useRouter } from \"../composables/useRouter\";\nimport { useRefFromSource } from \"../useRefFromSource\";\n\nimport type { RouterError, State } from \"@real-router/core\";\nimport type { VNode, PropType } from \"vue\";\n\nexport const RouterErrorBoundary = defineComponent({\n name: \"RouterErrorBoundary\",\n props: {\n fallback: {\n type: Function as PropType<\n (error: RouterError, resetError: () => void) => VNode\n >,\n required: true,\n },\n onError: {\n type: Function as PropType<\n (\n error: RouterError,\n toRoute: State | null,\n fromRoute: State | null,\n ) => void\n >,\n default: undefined,\n },\n },\n setup(props, { slots }) {\n const router = useRouter();\n const snapshot = useRefFromSource(createDismissableError(router));\n\n watch(\n () => snapshot.value.version,\n () => {\n if (snapshot.value.error) {\n props.onError?.(\n snapshot.value.error,\n snapshot.value.toRoute,\n snapshot.value.fromRoute,\n );\n }\n },\n { immediate: true },\n );\n\n return () => {\n const children = slots.default?.() ?? [];\n const errorVNode = snapshot.value.error\n ? props.fallback(snapshot.value.error, snapshot.value.resetError)\n : null;\n\n return h(Fragment, null, [...children, errorVNode]);\n };\n },\n});\n\nexport type RouterErrorBoundaryProps = InstanceType<\n typeof RouterErrorBoundary\n>[\"$props\"];\n","import { shouldNavigate, applyLinkA11y } from \"../dom-utils\";\n\nimport type { Router, NavigationOptions, Params } from \"@real-router/core\";\nimport type { Directive } from \"vue\";\n\nexport interface LinkDirectiveValue {\n name: string;\n params?: Params;\n options?: NavigationOptions;\n}\n\n/**\n * Router stack for nested RouterProviders. The active router is the top of\n * the stack. RouterProvider pushes its router on mount and pops it on unmount,\n * which preserves the parent context when an inner provider tears down.\n *\n * Without the stack, an unmounted child provider would leave the directive\n * pointing at a disposed router, and v-link in the still-mounted parent would\n * navigate via the wrong (or torn-down) instance.\n */\nconst routerStack: Router[] = [];\n\n/**\n * Pushes a router onto the active stack. Returns a release function that\n * removes that exact router from the stack regardless of position — safe\n * across out-of-order provider unmount sequences.\n *\n * @internal Used by RouterProvider during setup/teardown.\n */\nexport function pushDirectiveRouter(router: Router): () => void {\n routerStack.push(router);\n\n return () => {\n const idx = routerStack.lastIndexOf(router);\n\n if (idx !== -1) {\n routerStack.splice(idx, 1);\n }\n };\n}\n\n/**\n * Backwards-compatible alias. Replaces the active router unconditionally and\n * does NOT participate in the stack — use {@link pushDirectiveRouter} from\n * provider code instead. Kept for tests and direct callers.\n */\nexport function setDirectiveRouter(router: Router | null): void {\n if (router === null) {\n routerStack.length = 0;\n\n return;\n }\n if (routerStack.length === 0) {\n routerStack.push(router);\n\n return;\n }\n\n routerStack[routerStack.length - 1] = router;\n}\n\nexport function getDirectiveRouter(): Router {\n const top = routerStack.at(-1);\n\n if (!top) {\n throw new Error(\n \"v-link directive requires a RouterProvider ancestor. Make sure RouterProvider is mounted.\",\n );\n }\n\n return top;\n}\n\ninterface Handlers {\n click: (evt: MouseEvent) => void;\n keydown: (evt: KeyboardEvent) => void;\n}\n\n// Single WeakMap halves per-element bookkeeping vs two parallel maps.\nconst handlers = new WeakMap<HTMLElement, Handlers>();\n\n/**\n * Validates a directive binding value before attaching handlers.\n * Returns false (and warns once per call) when the value is missing or\n * has no `name` — silently doing nothing is preferable to a runtime crash\n * inside a click handler.\n */\nfunction isValidBinding(value: unknown): value is LinkDirectiveValue {\n if (value === null || value === undefined) {\n console.error(\n \"[real-router] v-link directive received null/undefined value. The element will not be wired for navigation.\",\n );\n\n return false;\n }\n if (typeof (value as { name?: unknown }).name !== \"string\") {\n console.error(\n \"[real-router] v-link directive value is missing a string `name` field. The element will not be wired for navigation.\",\n );\n\n return false;\n }\n\n return true;\n}\n\nfunction createClickHandler(\n router: Router,\n value: LinkDirectiveValue,\n): (evt: MouseEvent) => void {\n return (evt: MouseEvent) => {\n if (!shouldNavigate(evt)) {\n return;\n }\n\n evt.preventDefault();\n router\n .navigate(value.name, value.params ?? {}, value.options ?? {})\n .catch(() => {});\n };\n}\n\nfunction createKeydownHandler(\n router: Router,\n value: LinkDirectiveValue,\n element: HTMLElement,\n): (evt: KeyboardEvent) => void {\n return (evt: KeyboardEvent) => {\n if (evt.key === \"Enter\" && !(element instanceof HTMLButtonElement)) {\n router\n .navigate(value.name, value.params ?? {}, value.options ?? {})\n .catch(() => {});\n }\n };\n}\n\nfunction attachHandlers(\n element: HTMLElement,\n router: Router,\n value: LinkDirectiveValue,\n): void {\n const click = createClickHandler(router, value);\n const keydown = createKeydownHandler(router, value, element);\n\n element.addEventListener(\"click\", click);\n element.addEventListener(\"keydown\", keydown);\n\n handlers.set(element, { click, keydown });\n}\n\nfunction detachHandlers(element: HTMLElement): void {\n const entry = handlers.get(element);\n\n if (entry) {\n element.removeEventListener(\"click\", entry.click);\n element.removeEventListener(\"keydown\", entry.keydown);\n handlers.delete(element);\n }\n}\n\nexport const vLink: Directive<HTMLElement, LinkDirectiveValue> = {\n mounted(element, binding) {\n const router = getDirectiveRouter();\n\n applyLinkA11y(element);\n\n element.style.cursor = \"pointer\";\n\n if (!isValidBinding(binding.value)) {\n return;\n }\n\n attachHandlers(element, router, binding.value);\n },\n\n updated(element, binding) {\n const router = getDirectiveRouter();\n\n detachHandlers(element);\n\n if (!isValidBinding(binding.value)) {\n return;\n }\n\n attachHandlers(element, router, binding.value);\n },\n\n beforeUnmount(element) {\n detachHandlers(element);\n },\n};\n","import { inject } from \"vue\";\n\nimport { NavigatorKey } from \"../context\";\n\nimport type { Navigator } from \"@real-router/core\";\n\nexport const useNavigator = (): Navigator => {\n const navigator = inject(NavigatorKey);\n\n if (!navigator) {\n throw new Error(\"useNavigator must be used within a RouterProvider\");\n }\n\n return navigator;\n};\n","import { getPluginApi } from \"@real-router/core/api\";\nimport { getRouteUtils } from \"@real-router/route-utils\";\n\nimport { useRouter } from \"./useRouter\";\n\nimport type { RouteUtils } from \"@real-router/route-utils\";\n\nexport const useRouteUtils = (): RouteUtils => {\n const router = useRouter();\n\n return getRouteUtils(getPluginApi(router).getTree());\n};\n","import { inject } from \"vue\";\n\nimport { RouteKey } from \"../context\";\n\nimport type { RouteContext } from \"../types\";\nimport type { Params, State } from \"@real-router/core\";\nimport type { Ref } from \"vue\";\n\nexport const useRoute = <P extends Params = Params>(): Omit<\n RouteContext<P>,\n \"route\"\n> & { route: Readonly<Ref<State<P>>> } => {\n const routeContext = inject(RouteKey);\n\n if (!routeContext) {\n throw new Error(\"useRoute must be used within a RouterProvider\");\n }\n\n if (!routeContext.route.value) {\n throw new Error(\n \"useRoute called with no active route. Did you forget to await router.start() before rendering, or is the router stopped/disposed?\",\n );\n }\n\n return routeContext as Omit<RouteContext<P>, \"route\"> & {\n route: Readonly<Ref<State<P>>>;\n };\n};\n","import { getTransitionSource } from \"@real-router/sources\";\n\nimport { useRefFromSource } from \"../useRefFromSource\";\nimport { useRouter } from \"./useRouter\";\n\nimport type { RouterTransitionSnapshot } from \"@real-router/sources\";\nimport type { ShallowRef } from \"vue\";\n\nexport function useRouterTransition(): ShallowRef<RouterTransitionSnapshot> {\n const router = useRouter();\n const source = getTransitionSource(router);\n\n return useRefFromSource(source);\n}\n","import { onScopeDispose } from \"vue\";\n\nimport { useRouter } from \"./useRouter\";\n\nimport type { State } from \"@real-router/core\";\n\nexport interface RouteExitContext {\n /** The route being left. */\n route: State;\n /** The route being navigated to. */\n nextRoute: State;\n /**\n * AbortSignal that fires when this navigation is superseded by a later\n * one (rapid clicks). Already filtered: when the handler runs,\n * `signal.aborted` is guaranteed to be `false`. Use\n * `signal.addEventListener(\"abort\", cleanup, { once: true })` for\n * cleanup that must run on cancellation.\n */\n signal: AbortSignal;\n}\n\nexport interface UseRouteExitOptions {\n /**\n * Skip the handler when `route.name === nextRoute.name`\n * (sort/filter/query-only navigations on the same route). Default:\n * `true`.\n */\n skipSameRoute?: boolean;\n}\n\nexport type RouteExitHandler = (\n context: RouteExitContext,\n) => void | Promise<void>;\n\n/**\n * Subscribe to the router's leave-window with the universal guards baked\n * in. Wraps `router.subscribeLeave` so consumers don't repeat the same\n * boilerplate every time:\n *\n * - **Reentrant abort pre-check**: if `signal.aborted` is already `true`\n * when the handler would run (rapid navigation superseded a slower\n * one), the handler is skipped entirely.\n * - **Same-route skip**: by default, `route.name === nextRoute.name`\n * short-circuits the handler — query-only navigations skip the work.\n * Opt out with `skipSameRoute: false`.\n *\n * Cleanup is bound to the component's effect scope via `onScopeDispose`.\n *\n * If the handler returns a Promise, the router blocks on it. If the\n * Promise resolves, navigation proceeds. If it rejects, the router emits\n * `TRANSITION_CANCELLED`.\n *\n * **Handler reactivity (Vue):** Vue composables run **once** during\n * `setup()`; `handler` is captured in closure at the call site. To vary\n * behavior over time, read refs/computeds inside the handler body — do\n * not rely on swapping the handler reference.\n *\n * @example Animation\n * ```ts\n * const ref = useTemplateRef<HTMLDivElement>(\"box\");\n *\n * useRouteExit(async ({ signal }) => {\n * const el = ref.value;\n * if (!el) return;\n * el.classList.add(\"fade-out\");\n * const cleanup = () => el.classList.remove(\"fade-out\");\n * signal.addEventListener(\"abort\", cleanup, { once: true });\n * try {\n * el.getBoundingClientRect();\n * await Promise.allSettled(el.getAnimations().map((a) => a.finished));\n * } finally {\n * cleanup();\n * }\n * });\n * ```\n *\n * @example Auto-save form draft\n * ```ts\n * useRouteExit(async ({ signal }) => {\n * if (formState.value.dirty) {\n * await api.saveDraft(formState.value, { signal });\n * }\n * });\n * ```\n *\n * @example Reading rich transition metadata via `nextRoute.transition`\n * ```ts\n * useRouteExit(({ route, nextRoute }) => {\n * if (nextRoute.transition.segments.deactivated.includes(\"products\")) {\n * productCache.clear();\n * }\n * if (nextRoute.transition.redirected) return;\n * });\n * ```\n */\nexport function useRouteExit(\n handler: RouteExitHandler,\n options?: UseRouteExitOptions,\n): void {\n const router = useRouter();\n const skipSameRoute = options?.skipSameRoute ?? true;\n\n const off = router.subscribeLeave(({ route, nextRoute, signal }) => {\n if (skipSameRoute && route.name === nextRoute.name) {\n return;\n }\n\n if (signal.aborted) {\n return;\n }\n\n return handler({ route, nextRoute, signal });\n });\n\n onScopeDispose(off);\n}\n","import { watch } from \"vue\";\n\nimport { useRoute } from \"./useRoute\";\n\nimport type { State } from \"@real-router/core\";\n\nexport interface RouteEnterContext {\n /** The route that was just activated. */\n route: State;\n /** The route that was active immediately before this navigation. */\n previousRoute: State;\n}\n\nexport type RouteEnterHandler = (context: RouteEnterContext) => void;\n\nexport interface UseRouteEnterOptions {\n /**\n * Skip the handler when `route.name === previousRoute.name`\n * (sort/filter/query-only navigations on the same route). Default:\n * `true`. Symmetric with `useRouteExit`'s same-name option.\n */\n skipSameRoute?: boolean;\n}\n\n/**\n * Fire `handler` once when the component mounts as a result of a\n * navigation. Mirror of `useRouteExit` for the entry side.\n *\n * What this composable covers that an ad-hoc `watch` + `useRoute()`\n * doesn't:\n *\n * - **Skip-initial**: `watch` (with default `immediate: false`) plus the\n * explicit `route.transition.from` guard ensures the handler doesn't\n * fire on the very first state committed by `router.start()`.\n * - **Same-route skip** (default): handler is skipped when\n * `route.transition.from === route.name`. Sort/filter/query-only\n * navigations re-trigger the watcher, but they are not \"entries\" in\n * the animation / analytics sense. Opt out with\n * `skipSameRoute: false`.\n * - **Mount-time `route` / `previousRoute` snapshot**: handler receives\n * the values that were live at the moment of the new state, not the\n * latest ones (which may have moved on if the user navigated again\n * before the watcher drained).\n *\n * **Handler reactivity (Vue):** Vue composables run **once** during\n * `setup()`; `handler` is captured in closure at the call site. To vary\n * behavior over time, read refs/computeds inside the handler body.\n *\n * @example Direction-aware entry animation\n * ```ts\n * useRouteEnter(({ route }) => {\n * const direction = route.context.browser?.direction;\n * ref.value?.classList.add(\n * direction === \"back\" ? \"slide-from-left\" : \"slide-from-right\",\n * );\n * });\n * ```\n *\n * @example Analytics page-enter event (skip-initial built-in)\n * ```ts\n * useRouteEnter(({ route, previousRoute }) => {\n * analytics.track(\"page_enter\", {\n * route: route.name,\n * from: previousRoute.name,\n * });\n * });\n * ```\n *\n * @example Reading rich transition metadata via `route.transition`\n * ```ts\n * useRouteEnter(({ route }) => {\n * if (route.transition.redirected) {\n * showToast(`Redirected from ${route.transition.from}`);\n * }\n * });\n * ```\n */\nexport function useRouteEnter(\n handler: RouteEnterHandler,\n options?: UseRouteEnterOptions,\n): void {\n const { route, previousRoute } = useRoute();\n const skipSameRoute = options?.skipSameRoute ?? true;\n let lastHandledRoute: State | null = null;\n\n watch(route, (newRoute) => {\n const prev = previousRoute.value;\n\n // Early-exit guards, top-down:\n //\n // - **Skip-initial**: `!transition.from` catches the first commit\n // from `router.start()`. Vue's `watch` (default `immediate: false`)\n // does not fire on the initial state — kept for parity with\n // React/Preact and v8-ignored.\n // - **Skip-same-route**: query-only navigations have\n // `transition.from === route.name`. Opt-out via\n // `skipSameRoute: false`.\n // - **Defensive dedupe + missing `previousRoute`**: same `route`\n // ref between watcher activations is unexpected on Vue (driven\n // off ref identity); `!prev` is unreachable once\n // `transition.from` is set (core populates them together). Both\n // kept for parity with React; v8-ignored.\n /* v8 ignore start */\n if (!newRoute.transition.from) {\n return;\n }\n /* v8 ignore stop */\n if (skipSameRoute && newRoute.transition.from === newRoute.name) {\n return;\n }\n /* v8 ignore start */\n if (lastHandledRoute === newRoute || !prev) {\n return;\n }\n /* v8 ignore stop */\n\n lastHandledRoute = newRoute;\n handler({ route: newRoute, previousRoute: prev });\n });\n}\n","// packages/vue/src/setupRouteProvision.ts\n\nimport { getNavigator } from \"@real-router/core\";\nimport { createRouteSource } from \"@real-router/sources\";\nimport { shallowRef } from \"vue\";\n\nimport type { Router, Navigator, State } from \"@real-router/core\";\nimport type { ShallowRef } from \"vue\";\n\n/**\n * Shared setup for `RouterProvider` (component-scoped) and\n * `createRouterPlugin` (app-scoped). Builds the reactive route refs +\n * subscription bookkeeping in one place; callers wire the result into their\n * provide/inject mechanism and own teardown lifecycle.\n *\n * @internal\n */\nexport interface RouteProvision {\n navigator: Navigator;\n route: ShallowRef<State | undefined>;\n previousRoute: ShallowRef<State | undefined>;\n /** Call when the owning scope tears down to release the router subscription. */\n unsubscribe: () => void;\n}\n\nexport function setupRouteProvision(router: Router): RouteProvision {\n const navigator = getNavigator(router);\n const source = createRouteSource(router);\n const initial = source.getSnapshot();\n\n const route = shallowRef<State | undefined>(initial.route);\n const previousRoute = shallowRef<State | undefined>(initial.previousRoute);\n\n const unsubscribe = source.subscribe(() => {\n const snapshot = source.getSnapshot();\n\n route.value = snapshot.route;\n previousRoute.value = snapshot.previousRoute;\n });\n\n return { navigator, route, previousRoute, unsubscribe };\n}\n","import { NavigatorKey, RouteKey, RouterKey } from \"./context\";\nimport { pushDirectiveRouter } from \"./directives/vLink\";\nimport { setupRouteProvision } from \"./setupRouteProvision\";\n\nimport type { Router } from \"@real-router/core\";\nimport type { App, Plugin } from \"vue\";\n\nexport function createRouterPlugin(router: Router): Plugin<[]> {\n return {\n install(app): void {\n const releaseDirective = pushDirectiveRouter(router);\n\n const { navigator, route, previousRoute, unsubscribe } =\n setupRouteProvision(router);\n\n // Vue 3.5+ exposes app.onUnmount for plugin cleanup.\n // On older versions (3.3–3.4), the subscription is cleaned up\n // when the router is garbage-collected (same as vue-router).\n if (\"onUnmount\" in app) {\n (app as App & { onUnmount: (fn: () => void) => void }).onUnmount(() => {\n releaseDirective();\n unsubscribe();\n });\n }\n\n app.provide(RouterKey, router);\n app.provide(NavigatorKey, navigator);\n app.provide(RouteKey, { navigator, route, previousRoute });\n },\n };\n}\n","import { defineComponent, onScopeDispose, provide, watch } from \"vue\";\n\nimport { NavigatorKey, RouteKey, RouterKey } from \"./context\";\nimport { pushDirectiveRouter } from \"./directives/vLink\";\nimport {\n createRouteAnnouncer,\n createScrollRestoration,\n createViewTransitions,\n} from \"./dom-utils\";\nimport { setupRouteProvision } from \"./setupRouteProvision\";\n\nimport type { ScrollRestorationOptions } from \"./dom-utils\";\nimport type { Router } from \"@real-router/core\";\nimport type { PropType } from \"vue\";\n\nexport const RouterProvider = defineComponent({\n name: \"RouterProvider\",\n props: {\n router: {\n type: Object as PropType<Router>,\n required: true,\n },\n announceNavigation: {\n type: Boolean,\n default: false,\n },\n scrollRestoration: {\n type: Object as PropType<ScrollRestorationOptions>,\n },\n viewTransitions: {\n type: Boolean,\n default: false,\n },\n },\n setup(props, { slots }) {\n // Reactive announceNavigation: setting prop true/false at runtime now\n // creates/destroys the announcer accordingly. Prior implementation read\n // the prop only inside onMounted, so toggling it post-mount silently no-op'd.\n watch(\n () => [props.router, props.announceNavigation] as const,\n ([router, enabled], _prev, onCleanup) => {\n if (!enabled) {\n return;\n }\n\n const announcer = createRouteAnnouncer(router);\n\n onCleanup(() => {\n announcer.destroy();\n });\n },\n { immediate: true },\n );\n\n // Watch by primitives so inline `{ mode: \"restore\" }` doesn't thrash.\n // scrollContainer is a getter invoked lazily on every event inside the\n // utility — swapping its reference doesn't change the resolved element,\n // so we intentionally omit it from watched sources.\n watch(\n () =>\n [\n props.router,\n props.scrollRestoration !== undefined,\n props.scrollRestoration?.mode,\n props.scrollRestoration?.anchorScrolling,\n ] as const,\n ([router, enabled, mode, anchorScrolling], _prev, onCleanup) => {\n if (!enabled) {\n return;\n }\n\n const sr = createScrollRestoration(router, {\n mode,\n anchorScrolling,\n scrollContainer: props.scrollRestoration?.scrollContainer,\n });\n\n onCleanup(() => {\n sr.destroy();\n });\n },\n { immediate: true },\n );\n\n // Reactive viewTransitions: toggling prop creates/destroys the utility.\n watch(\n () => [props.router, props.viewTransitions] as const,\n ([router, enabled], _prev, onCleanup) => {\n if (!enabled) {\n return;\n }\n\n const vt = createViewTransitions(router);\n\n onCleanup(() => {\n vt.destroy();\n });\n },\n { immediate: true },\n );\n\n // Push this provider's router on the v-link directive stack so nested\n // RouterProviders behave like nested DI scopes (LIFO). Release on unmount\n // restores the outer router for any v-link still mounted in the parent.\n const releaseDirective = pushDirectiveRouter(props.router);\n\n const { navigator, route, previousRoute, unsubscribe } =\n setupRouteProvision(props.router);\n\n onScopeDispose(() => {\n releaseDirective();\n unsubscribe();\n });\n\n provide(RouterKey, props.router);\n provide(NavigatorKey, navigator);\n provide(RouteKey, { navigator, route, previousRoute });\n\n return () => slots.default?.();\n },\n});\n"],"mappings":"+jBAKA,SAAS,GAAa,CACpB,OAAO,KAGT,MAAa,EAAQ,EAAgB,CACnC,KAAM,kBACN,MAAO,CACL,Q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ACH,OAGF,IAAM,EAAK,GAAsB,EAAO,CAExC,MAAgB,CACd,EAAG,SAAS,EACZ,EAEJ,CAAE,UAAW,GAAM,CACpB,CAKD,IAAM,EAAmB,EAAoB,EAAM,OAAO,CAEpD,CAAE,YAAW,QAAO,gBAAe,eACvC,EAAoB,EAAM,OAAO,CAWnC,OATA,MAAqB,CACnB,GAAkB,CAClB,GAAa,EACb,CAEF,EAAQ,EAAW,EAAM,OAAO,CAChC,EAAQ,EAAc,EAAU,CAChC,EAAQ,EAAU,CAAE,YAAW,QAAO,gBAAe,CAAC,KAEzC,EAAM,WAAW,EAEjC,CAAC"}
1
+ {"version":3,"file":"index.mjs","names":["NOOP_INSTANCE"],"sources":["../../src/components/RouteView/components.ts","../../src/components/RouteView/helpers.ts","../../src/useRefFromSource.ts","../../src/context.ts","../../src/composables/useRouter.ts","../../src/composables/useRouteNode.ts","../../src/components/RouteView/RouteView.ts","../../src/constants.ts","../../../../shared/dom-utils/route-announcer.ts","../../../../shared/dom-utils/scroll-restore.ts","../../../../shared/dom-utils/view-transitions.ts","../../../../shared/dom-utils/link-utils.ts","../../src/components/Link.ts","../../src/components/RouterErrorBoundary.ts","../../src/directives/vLink.ts","../../src/composables/useNavigator.ts","../../src/composables/useRouteUtils.ts","../../src/composables/useRoute.ts","../../src/composables/useRouterTransition.ts","../../src/composables/useRouteExit.ts","../../src/composables/useRouteEnter.ts","../../src/setupRouteProvision.ts","../../src/createRouterPlugin.ts","../../src/RouterProvider.ts"],"sourcesContent":["import { defineComponent } from \"vue\";\n\nimport type { SelfProps } from \"./types\";\nimport type { FunctionalComponent, PropType, VNode } from \"vue\";\n\nfunction renderNull() {\n return null;\n}\n\nexport const Match = defineComponent({\n name: \"RouteView.Match\",\n props: {\n segment: {\n type: String as PropType<string>,\n required: true,\n },\n exact: {\n type: Boolean,\n default: false,\n },\n fallback: {\n type: [Object, Function] as PropType<VNode | (() => VNode)>,\n default: undefined,\n },\n keepAlive: {\n type: Boolean,\n default: false,\n },\n },\n render: renderNull,\n});\n\n// Type Self via FunctionalComponent<SelfProps> so the SelfProps interface\n// is anchored to the component contract — knip otherwise flags SelfProps\n// as unused even though it's re-exported as RouteViewSelfProps for\n// consumers wrapping Self in custom HOCs.\nconst SelfImpl = defineComponent({\n name: \"RouteView.Self\",\n props: {\n fallback: {\n type: [Object, Function] as PropType<VNode | (() => VNode)>,\n default: undefined,\n },\n },\n render: renderNull,\n});\n\nexport const Self = SelfImpl as unknown as FunctionalComponent<SelfProps>;\n\nexport const NotFound = defineComponent({\n name: \"RouteView.NotFound\",\n render: renderNull,\n});\n","import { UNKNOWN_ROUTE } from \"@real-router/core\";\nimport { startsWithSegment } from \"@real-router/route-utils\";\nimport { Fragment, isVNode } from \"vue\";\n\nimport { Match, NotFound, Self } from \"./components\";\n\nimport type { VNode } from \"vue\";\n\ntype FallbackType = VNode | (() => VNode) | undefined;\n\ninterface FallbackSlots {\n selfVNode: VNode | null;\n selfFallback: FallbackType;\n notFoundChildren: unknown;\n}\n\nfunction isSegmentMatch(\n routeName: string,\n fullSegmentName: string,\n exact: boolean,\n): boolean {\n if (exact) {\n return routeName === fullSegmentName;\n }\n\n return startsWithSegment(routeName, fullSegmentName);\n}\n\nfunction normalizeChildren(children: unknown): VNode[] {\n if (Array.isArray(children)) {\n const result: VNode[] = [];\n\n for (const child of children) {\n if (Array.isArray(child)) {\n result.push(...normalizeChildren(child));\n } else if (isVNode(child)) {\n result.push(child);\n }\n }\n\n return result;\n }\n\n if (isVNode(children)) {\n return [children];\n }\n\n return [];\n}\n\nexport function collectElements(children: unknown, result: VNode[]): void {\n const vnodes = normalizeChildren(children);\n\n for (const child of vnodes) {\n if (\n child.type === Match ||\n child.type === Self ||\n child.type === NotFound\n ) {\n result.push(child);\n } else if (child.type === Fragment) {\n collectElements(child.children, result);\n }\n }\n}\n\nfunction recordFallback(child: VNode, slots: FallbackSlots): boolean {\n if (child.type === NotFound) {\n slots.notFoundChildren = child.children;\n\n return true;\n }\n\n if (child.type === Self) {\n if (slots.selfVNode === null) {\n slots.selfVNode = child;\n const props = child.props as { fallback?: FallbackType } | null;\n\n slots.selfFallback = props?.fallback;\n }\n\n return true;\n }\n\n return false;\n}\n\nfunction evaluateMatch(\n child: VNode,\n routeName: string,\n nodeName: string,\n): { isActive: boolean; fallback: FallbackType } {\n const props = child.props as {\n segment: string;\n exact?: boolean;\n fallback?: FallbackType;\n } | null;\n const segment = props?.segment ?? \"\";\n const exact = props?.exact ?? false;\n const fullSegmentName = nodeName ? `${nodeName}.${segment}` : segment;\n const isActive = isSegmentMatch(routeName, fullSegmentName, exact);\n\n return { isActive, fallback: props?.fallback };\n}\n\nfunction appendFallback(\n rendered: VNode[],\n routeName: string,\n nodeName: string,\n slots: FallbackSlots,\n elements: VNode[],\n): FallbackType {\n if (slots.selfVNode !== null && routeName === nodeName) {\n rendered.push(slots.selfVNode);\n\n return slots.selfFallback;\n }\n\n if (routeName === UNKNOWN_ROUTE && slots.notFoundChildren !== null) {\n const nfElements = elements.filter((element) => element.type === NotFound);\n /* v8 ignore next 3 */\n const lastNf = nfElements.at(-1);\n\n if (lastNf) {\n rendered.push(lastNf);\n }\n }\n\n return undefined;\n}\n\nexport function buildRenderList(\n elements: VNode[],\n routeName: string,\n nodeName: string,\n): {\n rendered: VNode[];\n activeMatchFound: boolean;\n fallback?: FallbackType;\n} {\n const slots: FallbackSlots = {\n selfVNode: null,\n selfFallback: undefined,\n notFoundChildren: null,\n };\n let activeMatchFound = false;\n let fallback: FallbackType = undefined;\n const rendered: VNode[] = [];\n\n for (const child of elements) {\n if (recordFallback(child, slots)) {\n continue;\n }\n\n if (activeMatchFound) {\n continue;\n }\n\n const result = evaluateMatch(child, routeName, nodeName);\n\n if (result.isActive) {\n activeMatchFound = true;\n fallback = result.fallback;\n rendered.push(child);\n }\n }\n\n if (!activeMatchFound) {\n fallback = appendFallback(rendered, routeName, nodeName, slots, elements);\n }\n\n return { rendered, activeMatchFound, fallback };\n}\n","import { shallowRef, onScopeDispose } from \"vue\";\n\nimport type { RouterSource } from \"@real-router/sources\";\nimport type { ShallowRef } from \"vue\";\n\nexport function useRefFromSource<T>(source: RouterSource<T>): ShallowRef<T> {\n const ref = shallowRef(source.getSnapshot());\n\n const unsub = source.subscribe(() => {\n ref.value = source.getSnapshot();\n });\n\n onScopeDispose(unsub);\n\n return ref;\n}\n","import type { RouteContext as RouteContextType } from \"./types\";\nimport type { Router, Navigator } from \"@real-router/core\";\nimport type { InjectionKey } from \"vue\";\n\nexport const RouterKey: InjectionKey<Router> = Symbol(\"RouterKey\");\n\nexport const NavigatorKey: InjectionKey<Navigator> = Symbol(\"NavigatorKey\");\n\nexport const RouteKey: InjectionKey<RouteContextType> = Symbol(\"RouteKey\");\n","import { inject } from \"vue\";\n\nimport { RouterKey } from \"../context\";\n\nimport type { Router } from \"@real-router/core\";\n\nexport const useRouter = (): Router => {\n const router = inject(RouterKey);\n\n if (!router) {\n throw new Error(\"useRouter must be used within a RouterProvider\");\n }\n\n return router;\n};\n","import { getNavigator } from \"@real-router/core\";\nimport { createRouteNodeSource } from \"@real-router/sources\";\nimport { computed } from \"vue\";\n\nimport { useRefFromSource } from \"../useRefFromSource\";\nimport { useRouter } from \"./useRouter\";\n\nimport type { RouteContext } from \"../types\";\n\nexport function useRouteNode(nodeName: string): RouteContext {\n const router = useRouter();\n\n const source = createRouteNodeSource(router, nodeName);\n const snapshot = useRefFromSource(source);\n\n // getNavigator is WeakMap-cached in core; no useMemo equivalent needed.\n const navigator = getNavigator(router);\n\n // Derive route/previousRoute via computed instead of mirroring with a sync\n // watch into two extra shallowRefs. computed shares snapshot's identity so\n // when the underlying source emits the same reference (idempotent or\n // out-of-node nav), consumers don't see a new ref.\n const route = computed(() => snapshot.value.route);\n const previousRoute = computed(() => snapshot.value.previousRoute);\n\n return {\n navigator,\n route,\n previousRoute,\n };\n}\n","import {\n Fragment,\n defineComponent,\n h,\n KeepAlive,\n markRaw,\n Suspense,\n} from \"vue\";\n\nimport { Match, NotFound, Self } from \"./components\";\nimport { buildRenderList, collectElements } from \"./helpers\";\nimport { useRouteNode } from \"../../composables/useRouteNode\";\n\nimport type { Component, VNode } from \"vue\";\n\ntype SlotChildren = Record<string, (() => VNode[]) | undefined> | null;\n\nfunction getSlotContent(vnode: VNode): VNode[] | null {\n const slots = vnode.children as SlotChildren;\n\n return slots?.default?.() ?? null;\n}\n\nfunction getOrCreateWrapper(\n cache: Map<string, Component>,\n segment: string,\n): Component {\n const existing = cache.get(segment);\n\n if (existing) {\n return existing;\n }\n\n const wrapper = markRaw(\n defineComponent({\n name: `KeepAlive-${segment}`,\n setup(_wrapperProps, wrapperCtx) {\n return () => wrapperCtx.slots.default?.();\n },\n }),\n );\n\n cache.set(segment, wrapper);\n\n return wrapper;\n}\n\nfunction wrapWithSuspense(content: VNode, fallback: unknown): VNode {\n if (fallback === undefined) {\n return content;\n }\n\n const fallbackContent =\n typeof fallback === \"function\" ? (fallback as () => VNode)() : fallback;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment\n const suspenseComponent = Suspense as any;\n\n return h(\n suspenseComponent,\n {},\n {\n default: () => content,\n fallback: () => fallbackContent,\n },\n );\n}\n\nconst emptyKeepAlivePlaceholder = markRaw(\n defineComponent({\n name: \"KeepAlive-placeholder\",\n render() {\n return null;\n },\n }),\n);\n\nfunction renderWithRootKA(\n activeChild: VNode,\n wrapperCache: Map<string, Component>,\n fallback: unknown,\n): VNode {\n const activeProps = activeChild.props as { segment?: string } | null;\n const segment = activeProps?.segment ?? \"__not-found__\";\n const WrapperComponent = getOrCreateWrapper(wrapperCache, segment);\n const slotContent = getSlotContent(activeChild) ?? [];\n const keepAliveContent = h(KeepAlive, null, {\n default: () =>\n h(WrapperComponent, { key: segment }, { default: () => slotContent }),\n });\n\n return wrapWithSuspense(keepAliveContent, fallback);\n}\n\n// Vue compiles boolean-shorthand template attributes (`<Match keepAlive>`) to\n// an empty string instead of `true`, and converts them to `true` only when the\n// receiving component's prop is declared with `type: Boolean`. `Match` is a\n// marker component (`render: null`) — its props are inspected on the VNode\n// without ever going through Vue's prop-casting pipeline, so the raw `\"\"` (or\n// the hyphenated attribute name) reaches us here. Accept the same trio Vue's\n// runtime does.\nfunction isKeepAliveEnabled(value: unknown): boolean {\n return value === true || value === \"\" || value === \"keep-alive\";\n}\n\nfunction renderWithPerMatchKA(\n activeChild: VNode,\n wrapperCache: Map<string, Component>,\n fallback: unknown,\n): VNode | null {\n const matchProps = activeChild.props as {\n segment?: string;\n keepAlive?: unknown;\n } | null;\n\n if (isKeepAliveEnabled(matchProps?.keepAlive) && activeChild.type === Match) {\n /* v8 ignore start */\n const segment = matchProps?.segment ?? \"__not-found__\";\n /* v8 ignore stop */\n const WrapperComponent = getOrCreateWrapper(wrapperCache, segment);\n const slotContent = getSlotContent(activeChild) ?? [];\n\n return h(Fragment, [\n h(KeepAlive, null, {\n default: () =>\n h(WrapperComponent, { key: segment }, { default: () => slotContent }),\n }),\n ]);\n }\n\n const content = getSlotContent(activeChild);\n\n /* v8 ignore start */\n if (!content) {\n return null;\n }\n /* v8 ignore stop */\n\n return h(Fragment, [\n h(KeepAlive, null, { default: () => h(emptyKeepAlivePlaceholder) }),\n wrapWithSuspense(h(Fragment, content), fallback),\n ]);\n}\n\nconst RouteViewComponent = defineComponent({\n name: \"RouteView\",\n props: {\n nodeName: {\n type: String,\n required: true,\n },\n keepAlive: {\n type: Boolean,\n default: false,\n },\n },\n setup(props, { slots }) {\n const routeContext = useRouteNode(props.nodeName);\n const wrapperCache = new Map<string, Component>();\n\n // Cache per-Match `keepAlive` detection by slot output identity. Slot\n // contents change reference only when the parent re-renders with new\n // children, so steady-state navigations skip the O(n) `.some(...)` scan.\n let lastSlotOutput: unknown = null;\n let lastHasPerMatchKA = false;\n\n function detectPerMatchKA(elements: VNode[], slotOutput: unknown): boolean {\n /* v8 ignore next 3 -- @preserve: Vue's compiled slot wrapper allocates a\n new array per render call in JSDOM tests; identity-cache hits in\n production where parent compiled templates share slot output, but\n is unobservable through TestBed-style assertions. */\n if (slotOutput === lastSlotOutput) {\n return lastHasPerMatchKA;\n }\n\n lastSlotOutput = slotOutput;\n lastHasPerMatchKA = elements.some(\n (element) =>\n element.type === Match &&\n isKeepAliveEnabled(\n (element.props as { keepAlive?: unknown } | null)?.keepAlive,\n ),\n );\n\n return lastHasPerMatchKA;\n }\n\n return (): VNode | null => {\n const route = routeContext.route.value;\n\n if (!route) {\n return null;\n }\n\n const slotOutput = slots.default?.();\n const elements: VNode[] = [];\n\n collectElements(slotOutput, elements);\n\n const { rendered, fallback } = buildRenderList(\n elements,\n route.name,\n props.nodeName,\n );\n\n if (rendered.length === 0) {\n return null;\n }\n\n const activeChild = rendered[0];\n\n if (props.keepAlive) {\n return renderWithRootKA(activeChild, wrapperCache, fallback);\n }\n\n /* v8 ignore start */\n if (\n activeChild.type !== Match &&\n activeChild.type !== Self &&\n activeChild.type !== NotFound\n ) {\n return null;\n }\n /* v8 ignore stop */\n\n const hasPerMatchKA = detectPerMatchKA(elements, slotOutput);\n\n if (hasPerMatchKA) {\n return renderWithPerMatchKA(activeChild, wrapperCache, fallback);\n }\n\n const content = getSlotContent(activeChild);\n\n if (!content) {\n return null;\n }\n\n return wrapWithSuspense(h(Fragment, content), fallback);\n };\n },\n});\n\nexport const RouteView = Object.assign(RouteViewComponent, {\n Match,\n Self,\n NotFound,\n});\n\nexport type {\n RouteViewProps,\n MatchProps as RouteViewMatchProps,\n SelfProps as RouteViewSelfProps,\n NotFoundProps as RouteViewNotFoundProps,\n} from \"./types\";\n","/**\n * Stable empty object for default params\n */\nexport const EMPTY_PARAMS = Object.freeze({});\n\n/**\n * Stable empty options object\n */\nexport const EMPTY_OPTIONS = Object.freeze({});\n","import type { Router, State } from \"@real-router/core\";\n\nconst CLEAR_DELAY = 7000;\nconst SAFARI_READY_DELAY = 100;\nconst ANNOUNCER_ATTR = \"data-real-router-announcer\";\nconst INTERNAL_ROUTE_PREFIX = \"@@\";\nconst VISUALLY_HIDDEN =\n \"position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);clip-path:inset(50%);white-space:nowrap;border:0\";\n\nexport interface RouteAnnouncerOptions {\n prefix?: string;\n getAnnouncementText?: (route: State) => string;\n}\n\nexport function createRouteAnnouncer(\n router: Router,\n options?: RouteAnnouncerOptions,\n): { destroy: () => void } {\n const prefix = options?.prefix ?? \"Navigated to \";\n const getCustomText = options?.getAnnouncementText;\n\n let isInitialNavigation = true;\n let isReady = false;\n let isDestroyed = false;\n let lastAnnouncedText = \"\";\n let pendingText: string | null = null;\n let clearTimeoutId: ReturnType<typeof setTimeout> | undefined;\n\n const announcer = getOrCreateAnnouncer();\n\n const doAnnounce = (text: string, h1: HTMLElement | null): void => {\n lastAnnouncedText = text;\n clearTimeout(clearTimeoutId);\n announcer.textContent = text;\n clearTimeoutId = setTimeout(() => {\n announcer.textContent = \"\";\n lastAnnouncedText = \"\";\n }, CLEAR_DELAY);\n\n manageFocus(h1);\n };\n\n // Safari-ready delay: announcing before VoiceOver wires up the aria-live region\n // causes the first announcement to be silently dropped. Wait SAFARI_READY_DELAY ms\n // before marking the announcer \"ready\" — any navigation during that window is\n // buffered in pendingText and flushed once the delay expires.\n const safariTimeoutId = setTimeout(() => {\n isReady = true;\n\n if (pendingText !== null && !isDestroyed) {\n const text = pendingText;\n\n pendingText = null;\n doAnnounce(text, document.querySelector<HTMLElement>(\"h1\"));\n }\n }, SAFARI_READY_DELAY);\n\n const unsubscribe = router.subscribe(({ route }) => {\n if (isInitialNavigation) {\n isInitialNavigation = false;\n\n return;\n }\n\n // Double rAF: waits for two paint frames so the incoming route's DOM\n // (including the new <h1>) is fully rendered before resolveText reads it.\n // Single rAF fires before the new route's template has been attached,\n // which would cause resolveText to pick up the OLD h1 or fall back to\n // document.title / route.name prematurely.\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n if (isDestroyed) {\n return;\n }\n\n const h1 = document.querySelector<HTMLElement>(\"h1\");\n const text = resolveText(route, prefix, getCustomText, h1);\n\n if (!text || text === lastAnnouncedText) {\n return;\n }\n\n if (!isReady) {\n // Defer announcement until Safari-ready window elapses (see safariTimeoutId).\n pendingText = text;\n\n return;\n }\n\n doAnnounce(text, h1);\n });\n });\n });\n\n return {\n destroy() {\n isDestroyed = true;\n unsubscribe();\n clearTimeout(clearTimeoutId);\n clearTimeout(safariTimeoutId);\n removeAnnouncer();\n },\n };\n}\n\nfunction getOrCreateAnnouncer(): HTMLElement {\n const existing = document.querySelector<HTMLElement>(`[${ANNOUNCER_ATTR}]`);\n\n if (existing) {\n return existing;\n }\n\n const element = document.createElement(\"div\");\n\n element.setAttribute(\"style\", VISUALLY_HIDDEN);\n element.setAttribute(\"aria-live\", \"assertive\");\n element.setAttribute(\"aria-atomic\", \"true\");\n element.setAttribute(ANNOUNCER_ATTR, \"\");\n\n document.body.prepend(element);\n\n return element;\n}\n\nfunction removeAnnouncer(): void {\n document.querySelector(`[${ANNOUNCER_ATTR}]`)?.remove();\n}\n\nfunction resolveText(\n route: State,\n prefix: string,\n getCustomText: ((route: State) => string) | undefined,\n h1: HTMLElement | null,\n): string {\n if (getCustomText) {\n return getCustomText(route);\n }\n\n const h1Text = (h1?.textContent ?? \"\").trim();\n const routeName = route.name.startsWith(INTERNAL_ROUTE_PREFIX)\n ? \"\"\n : route.name;\n const rawText =\n h1Text || document.title || routeName || globalThis.location.pathname;\n\n return `${prefix}${rawText}`;\n}\n\nfunction manageFocus(h1: HTMLElement | null): void {\n if (!h1) {\n return;\n }\n\n if (!h1.hasAttribute(\"tabindex\")) {\n h1.setAttribute(\"tabindex\", \"-1\");\n }\n\n h1.focus({ preventScroll: true });\n}\n","import type { Router, State } from \"@real-router/core\";\n\nconst DEFAULT_STORAGE_KEY = \"real-router:scroll\";\n\nconst NOOP_INSTANCE: { destroy: () => void } = Object.freeze({\n destroy: () => {\n /* no-op */\n },\n});\n\nexport type ScrollRestorationMode = \"restore\" | \"top\" | \"native\";\n\nexport interface ScrollRestorationOptions {\n mode?: ScrollRestorationMode | undefined;\n anchorScrolling?: boolean | undefined;\n scrollContainer?: (() => HTMLElement | null) | undefined;\n /**\n * Scroll behavior passed to `scrollTo({ behavior })` and\n * `scrollIntoView({ behavior })`.\n *\n * - `\"auto\"` (default) — browser-defined, usually instant.\n * - `\"instant\"` — explicit instant jump (no animation).\n * - `\"smooth\"` — animated transition. Note: smooth restore on back/traverse\n * can feel disorienting if the user expects to land at the saved position\n * immediately. Recommended for `mode: \"top\"` or anchor scroll only.\n *\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/ScrollToOptions/behavior).\n */\n behavior?: ScrollBehavior | undefined;\n /**\n * sessionStorage key used to persist saved scroll positions. Default:\n * `\"real-router:scroll\"`. Override only when multiple independent\n * `RouterProvider` instances share the same document and you need to\n * isolate their scroll stores (e.g. micro-frontends, embedded widgets,\n * or testing). For a single app with one provider the default is fine.\n */\n storageKey?: string | undefined;\n}\n\ninterface NavigationContext {\n direction?: \"forward\" | \"back\" | \"unknown\";\n navigationType?: \"push\" | \"replace\" | \"traverse\" | \"reload\";\n}\n\nexport function createScrollRestoration(\n router: Router,\n options?: ScrollRestorationOptions,\n): { destroy: () => void } {\n if (typeof globalThis.window === \"undefined\") {\n return NOOP_INSTANCE;\n }\n\n const mode = options?.mode ?? \"restore\";\n\n // mode \"native\" = utility does nothing. Don't flip history.scrollRestoration,\n // don't subscribe, don't register pagehide — `history.scrollRestoration`\n // stays at the browser default (\"auto\") so the browser handles scroll\n // restore natively. (Note: this is the OPPOSITE of `history.scrollRestoration\n // === \"manual\"` — utility's \"native\" leaves the DOM property at \"auto\" so\n // the browser is in charge.)\n if (mode === \"native\") {\n return NOOP_INSTANCE;\n }\n\n const anchorEnabled = options?.anchorScrolling ?? true;\n const getContainer = options?.scrollContainer;\n const behavior: ScrollBehavior = options?.behavior ?? \"auto\";\n const storageKey = options?.storageKey ?? DEFAULT_STORAGE_KEY;\n\n const loadStore = (): Record<string, number> => {\n try {\n const raw = sessionStorage.getItem(storageKey);\n\n return raw ? (JSON.parse(raw) as Record<string, number>) : {};\n } catch {\n return {};\n }\n };\n\n const putPos = (key: string, pos: number): void => {\n try {\n const store = loadStore();\n\n store[key] = pos;\n sessionStorage.setItem(storageKey, JSON.stringify(store));\n } catch {\n // Ignore quota / security errors.\n }\n };\n\n const prevScrollRestoration = history.scrollRestoration;\n\n try {\n history.scrollRestoration = \"manual\";\n } catch {\n // Ignore — some embedded contexts may reject the assignment.\n }\n\n // Resolve the container lazily on every event so containers mounted AFTER\n // the provider still get correct scroll handling. Falls back to window when\n // the getter is absent or returns null (pre-mount).\n const readPos = (): number => {\n const element = getContainer?.();\n\n return element ? element.scrollTop : globalThis.scrollY;\n };\n\n const writePos = (top: number): void => {\n const element = getContainer?.();\n\n if (element) {\n element.scrollTo({ top, left: 0, behavior });\n } else {\n globalThis.scrollTo({ top, left: 0, behavior });\n }\n };\n\n const scrollToHashOrTop = (route: State): void => {\n // URL plugin path (#532): `state.context.url.hash` is the source of truth\n // when one of the URL plugins (browser-plugin / navigation-plugin) is\n // installed. The value is already DECODED — feeding it through\n // `decodeURIComponent` again would throw on a bare `%`.\n const ctxHash = (route.context as { url?: { hash?: string } } | undefined)\n ?.url?.hash;\n\n if (ctxHash !== undefined) {\n if (anchorEnabled && ctxHash.length > 0) {\n // eslint-disable-next-line unicorn/prefer-query-selector -- ids may contain CSS-unsafe chars\n const element = document.getElementById(ctxHash);\n\n if (element) {\n element.scrollIntoView({ behavior });\n\n return;\n }\n }\n\n writePos(0);\n\n return;\n }\n\n // Fallback path: no URL plugin, read the DOM. `location.hash` is\n // percent-encoded; ids in the DOM are the raw string, so decode for the\n // match. Fall back to the raw slice if the hash contains a malformed\n // escape sequence (decodeURIComponent throws on those).\n const hash = globalThis.location.hash;\n\n if (anchorEnabled && hash.length > 1) {\n let id: string;\n\n try {\n id = decodeURIComponent(hash.slice(1));\n } catch {\n id = hash.slice(1);\n }\n\n // eslint-disable-next-line unicorn/prefer-query-selector -- ids may contain CSS-unsafe chars\n const element = document.getElementById(id);\n\n if (element) {\n element.scrollIntoView({ behavior });\n\n return;\n }\n }\n\n writePos(0);\n };\n\n let destroyed = false;\n\n const unsubscribe = router.subscribe(({ route, previousRoute }) => {\n const nav = (route.context as { navigation?: NavigationContext })\n .navigation;\n\n // Browsers dispatch reload as the initial navigation after refresh, so\n // previousRoute is undefined and capture is naturally skipped. The\n // pre-refresh position was already persisted via pagehide.\n if (previousRoute) {\n putPos(keyOf(previousRoute), readPos());\n }\n\n // Single rAF so DOM is committed before we read anchors / write scroll.\n // Guard against destroy() racing with the callback.\n requestAnimationFrame(() => {\n if (destroyed) {\n return;\n }\n\n if (mode === \"top\" || !nav) {\n scrollToHashOrTop(route);\n\n return;\n }\n\n if (nav.navigationType === \"replace\") {\n return;\n }\n\n if (\n nav.direction === \"back\" ||\n nav.navigationType === \"traverse\" ||\n nav.navigationType === \"reload\"\n ) {\n writePos(loadStore()[keyOf(route)] ?? 0);\n\n return;\n }\n\n scrollToHashOrTop(route);\n });\n });\n\n const onPageHide = (): void => {\n const current = router.getState();\n\n if (current) {\n putPos(keyOf(current), readPos());\n }\n };\n\n globalThis.addEventListener(\"pagehide\", onPageHide);\n\n return {\n destroy: () => {\n if (destroyed) {\n return;\n }\n\n destroyed = true;\n unsubscribe();\n globalThis.removeEventListener(\"pagehide\", onPageHide);\n\n try {\n history.scrollRestoration = prevScrollRestoration;\n } catch {\n // Ignore.\n }\n },\n };\n}\n\nfunction keyOf(state: State): string {\n return `${state.name}:${canonicalJson(state.params)}`;\n}\n\nfunction canonicalJson(value: unknown): string {\n return JSON.stringify(value, canonicalReplacer);\n}\n\nfunction canonicalReplacer(_key: string, val: unknown): unknown {\n if (val !== null && typeof val === \"object\" && !Array.isArray(val)) {\n const sorted: Record<string, unknown> = {};\n // eslint-disable-next-line unicorn/no-array-sort -- ng-packagr uses pre-ES2023 lib; toSorted unavailable\n const keys = Object.keys(val as Record<string, unknown>).sort(\n (left: string, right: string) => left.localeCompare(right),\n );\n\n for (const key of keys) {\n sorted[key] = (val as Record<string, unknown>)[key];\n }\n\n return sorted;\n }\n\n return val;\n}\n","import type { Router } from \"@real-router/core\";\n\nexport interface ViewTransitions {\n destroy: () => void;\n}\n\nconst NOOP_INSTANCE: ViewTransitions = Object.freeze({\n destroy: () => {\n /* no-op */\n },\n});\n\nexport function createViewTransitions(router: Router): ViewTransitions {\n if (\n typeof document === \"undefined\" ||\n typeof document.startViewTransition !== \"function\"\n ) {\n return NOOP_INSTANCE;\n }\n\n let closeVT: (() => void) | null = null;\n let currentVT: { skipTransition?: () => void } | null = null;\n // Tracks whether TRANSITION_SUCCESS fired for the current leave. Used to\n // distinguish \"benign cleanup abort\" (router's async path aborts its own\n // controller in a finally block after successful navigation) from \"real\n // cancellation\" (concurrent navigate, guard rejection, dispose).\n let successFired = false;\n\n const resolveAndClear = (): void => {\n closeVT?.();\n closeVT = null;\n };\n\n const offLeave = router.subscribeLeave(({ signal }) => {\n // Reentrant abort: signal already aborted when we're called. Open no VT\n // — router will fall through to TRANSITION_CANCELLED via isCurrentNav()\n // after leave resolves. addEventListener(\"abort\", ...) does not re-fire\n // for past events, so skipping startViewTransition is the safe path.\n if (signal.aborted) {\n return;\n }\n\n successFired = false;\n resolveAndClear();\n\n // Return a Promise so the router awaits until the browser invokes\n // updateCallback. This ensures old DOM snapshot is captured BEFORE the\n // router commits the new state — giving correct exit→state→entry\n // ordering (vs fire-and-forget, where URL changes before VT captures).\n return new Promise<void>((resolveLeave) => {\n // Capture the resolver synchronously BEFORE startViewTransition() is\n // called. The browser invokes updateCallback in a later task, but\n // router.subscribe (TRANSITION_SUCCESS) can fire before that. If we\n // captured `resolve` inside the callback, subscribe would see closeVT\n // still null and skip resolving — the deferred would hang for 4s\n // until the VT API aborts with TimeoutError.\n const deferred = new Promise<void>((resolve) => {\n closeVT = resolve;\n });\n\n signal.addEventListener(\n \"abort\",\n () => {\n if (successFired) {\n // Router's async path (#finishAsyncNavigation) aborts its own\n // controller in a finally block AFTER completeTransition (and\n // thus AFTER subscribe fired). This is cleanup, not\n // cancellation — VT is progressing normally, do nothing.\n return;\n }\n\n // Real cancellation (concurrent navigate, dispose). Resolve the\n // deferred so updateCallback can complete, skip the VT so no\n // stale animation leaks, and unblock the router if the abort\n // fires before updateCallback was invoked.\n resolveAndClear();\n currentVT?.skipTransition?.();\n resolveLeave();\n },\n { once: true },\n );\n\n try {\n currentVT = document.startViewTransition(() => {\n // Resolving here unblocks the router at the moment the browser\n // enters updateCallback — by spec, old DOM snapshot is captured\n // before this callback runs. Router now proceeds through\n // activation guards and setState; the VT animation waits on\n // `deferred`, which is resolved from router.subscribe after a\n // task-queue tick (see NOTE on setTimeout below).\n resolveLeave();\n\n return deferred;\n });\n } catch {\n // Defensive: spec says startViewTransition doesn't throw under\n // normal conditions, but Chromium has had edge cases (detached\n // document, extension interference). Clean up and unblock router.\n resolveAndClear();\n resolveLeave();\n }\n });\n });\n\n const offSuccess = router.subscribe(() => {\n const resolver = closeVT;\n\n successFired = true;\n closeVT = null;\n\n if (resolver === null) {\n currentVT = null;\n } else {\n // CRITICAL: CANNOT use requestAnimationFrame here. When the router\n // takes the async path (leave returned a Promise), subscribe fires\n // AFTER the browser has already transitioned VT into the\n // \"update-callback-called\" phase. In that phase Chromium sets\n // rendering suppression to true, which ALSO blocks rAF callbacks.\n // rAF would never fire → deferred never resolves → browser aborts\n // vt.ready with TimeoutError after 4s (observed in Chromium).\n //\n // setTimeout runs on the task queue independent of the rendering\n // pipeline, so it fires regardless of suppression. React's scheduler\n // uses MessageChannel tasks, which are queued before our setTimeout,\n // so the new DOM is committed by the time our callback runs.\n setTimeout(() => {\n resolver();\n currentVT = null;\n }, 0);\n }\n });\n\n return {\n destroy: () => {\n offLeave();\n offSuccess();\n currentVT?.skipTransition?.();\n currentVT = null;\n resolveAndClear();\n },\n };\n}\n","import type {\n NavigationOptions,\n Params,\n Router,\n State,\n} from \"@real-router/core\";\n\nexport function shouldNavigate(evt: MouseEvent): boolean {\n return (\n evt.button === 0 &&\n !evt.metaKey &&\n !evt.altKey &&\n !evt.ctrlKey &&\n !evt.shiftKey\n );\n}\n\n/**\n * RFC 3986 fragment encoding: preserve sub-delims (`&`, `=`, `?`, `:`),\n * encode space, `%`, control chars, non-ASCII via encodeURI; defensively\n * escape `#` (encodeURI does not). Mirrors `encodeHashFragment` in\n * `shared/browser-env/url-context.ts` — duplicated here because the\n * shared/dom-utils symlink graph does not reach shared/browser-env.\n */\nfunction encodeFragmentInline(decoded: string): string {\n return encodeURI(decoded).replaceAll(\"#\", \"%23\");\n}\n\ntype BuildUrlFn = (\n name: string,\n params: Params,\n options?: { hash?: string },\n) => string | undefined;\n\n/**\n * Builds an href for a `<Link>` element.\n *\n * - Prefers the URL plugin's `buildUrl` (browser-plugin, navigation-plugin,\n * hash-plugin) when present.\n * - Falls back to `router.buildPath` for runtimes without a URL plugin\n * (memory-plugin, console UIs, NativeScript). In that fallback the hash\n * is appended manually so the rendered href is still correct.\n * - The optional 4th argument is an options object so the contract stays\n * extensible. The `hash` option is a decoded fragment without leading \"#\";\n * `<Link hash=\"#section\">` is accepted defensively (leading \"#\" stripped).\n * Frozen API: previous 3-arg call sites continue to work unchanged.\n */\nexport function buildHref(\n router: Router,\n routeName: string,\n routeParams: Params,\n options?: { hash?: string },\n): string | undefined {\n try {\n const rawHash = options?.hash;\n let normHash: string | undefined;\n\n if (rawHash !== undefined) {\n normHash = rawHash.startsWith(\"#\") ? rawHash.slice(1) : rawHash;\n }\n\n const buildUrl = router.buildUrl as BuildUrlFn | undefined;\n\n if (buildUrl) {\n const url = buildUrl(\n routeName,\n routeParams,\n normHash === undefined ? undefined : { hash: normHash },\n );\n\n if (url !== undefined) {\n return url;\n }\n }\n\n const path = router.buildPath(routeName, routeParams);\n\n return normHash ? `${path}#${encodeFragmentInline(normHash)}` : path;\n } catch {\n console.error(\n `[real-router] Route \"${routeName}\" is not defined. The element will render without an href attribute.`,\n );\n\n return undefined;\n }\n}\n\n/**\n * `<Link>` click-handler navigation helper (#532).\n *\n * Wraps `router.navigate(name, params, opts)` with same-route different-hash\n * detection: when the consumer clicks a hash-bearing Link that targets the\n * current route with the same params but a different fragment, core's\n * SAME_STATES check would otherwise reject the navigation. The helper adds\n * `force: true` and `hashChange: true` automatically — subscribers can then\n * disambiguate via `state.context.url.hashChanged`.\n *\n * For pure programmatic same-route hash-only navigation, callers are\n * documented to pass `{ force: true }` themselves; the auto-bypass here is\n * a UX convenience for `<Link hash>` that all 6 framework adapters share.\n */\n/**\n * Local extended-options type. Adapters that depend only on `@real-router/core`\n * (without a URL plugin) do not see the `NavigationOptions` augmentation that\n * declares `hash` / `hashChange`. Casting to this widened type inside the\n * helper keeps shared/dom-utils self-contained — adapters do not need to\n * augment NavigationOptions themselves to consume `<Link hash>`.\n */\ntype HashAwareNavigationOptions = NavigationOptions & {\n hash?: string;\n hashChange?: boolean;\n};\n\nexport function navigateWithHash(\n router: Router,\n routeName: string,\n routeParams: Params,\n hash: string | undefined,\n extraOptions?: NavigationOptions,\n): Promise<State> {\n const opts: HashAwareNavigationOptions = { ...extraOptions };\n\n if (hash !== undefined) {\n opts.hash = hash;\n }\n\n const current = router.getState();\n\n if (\n current?.name === routeName &&\n shallowEqual(current.params, routeParams)\n ) {\n const currentHash =\n (current.context as { url?: { hash?: string } } | undefined)?.url?.hash ??\n \"\";\n const newHash = hash ?? currentHash;\n\n if (currentHash !== newHash) {\n opts.force = true;\n opts.hashChange = true;\n }\n }\n\n return router.navigate(routeName, routeParams, opts);\n}\n\nfunction parseTokens(value: string | undefined): string[] {\n return value ? (value.match(/\\S+/g) ?? []) : [];\n}\n\nexport function buildActiveClassName(\n isActive: boolean,\n activeClassName: string | undefined,\n baseClassName: string | undefined,\n): string | undefined {\n if (isActive && activeClassName) {\n const activeTokens = parseTokens(activeClassName);\n\n if (activeTokens.length === 0) {\n return baseClassName ?? undefined;\n }\n if (!baseClassName) {\n return activeTokens.join(\" \");\n }\n\n const baseTokens = parseTokens(baseClassName);\n const seen = new Set(baseTokens);\n\n for (const token of activeTokens) {\n if (!seen.has(token)) {\n seen.add(token);\n baseTokens.push(token);\n }\n }\n\n return baseTokens.join(\" \");\n }\n\n return baseClassName ?? undefined;\n}\n\nexport function shallowEqual(\n prev: object | undefined,\n next: object | undefined,\n): boolean {\n if (Object.is(prev, next)) {\n return true;\n }\n if (!prev || !next) {\n return false;\n }\n\n const prevKeys = Object.keys(prev);\n\n if (prevKeys.length !== Object.keys(next).length) {\n return false;\n }\n\n const prevRecord = prev as Record<string, unknown>;\n const nextRecord = next as Record<string, unknown>;\n\n for (const key of prevKeys) {\n if (!Object.is(prevRecord[key], nextRecord[key])) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function applyLinkA11y(element: HTMLElement | null | undefined): void {\n if (!element) {\n return;\n }\n if (\n element instanceof HTMLAnchorElement ||\n element instanceof HTMLButtonElement\n ) {\n return;\n }\n if (!element.hasAttribute(\"role\")) {\n element.setAttribute(\"role\", \"link\");\n }\n if (!element.hasAttribute(\"tabindex\")) {\n element.setAttribute(\"tabindex\", \"0\");\n }\n}\n","import { createActiveRouteSource } from \"@real-router/sources\";\nimport { defineComponent, h, computed, shallowRef, watch } from \"vue\";\n\nimport { useRouter } from \"../composables/useRouter\";\nimport { EMPTY_PARAMS, EMPTY_OPTIONS } from \"../constants\";\nimport {\n shouldNavigate,\n buildHref,\n buildActiveClassName,\n navigateWithHash,\n} from \"../dom-utils\";\n\nimport type { Params, NavigationOptions } from \"@real-router/core\";\nimport type { PropType } from \"vue\";\n\ntype OnClickHandler = (evt: MouseEvent) => void;\n\n/**\n * Vue's compiled template binds multiple `@click` handlers as an array.\n * Single render-function `onClick` is a function. Both must be invoked.\n */\nfunction invokeAttributesOnClick(value: unknown, evt: MouseEvent): void {\n if (typeof value === \"function\") {\n (value as OnClickHandler)(evt);\n\n return;\n }\n if (Array.isArray(value)) {\n const handlers = value as OnClickHandler[];\n\n for (const fn of handlers) {\n if (typeof fn === \"function\") {\n fn(evt);\n\n if (evt.defaultPrevented) {\n return;\n }\n }\n }\n }\n}\n\nexport const Link = defineComponent({\n name: \"Link\",\n // Disable Vue's automatic attribute fallthrough. Without this, attrs.onClick\n // (function OR array) is auto-attached as a native click listener AND our\n // explicit onClick fires too — user handlers are double-invoked. We invoke\n // attrs.onClick manually inside handleClick to preserve preventDefault.\n inheritAttrs: false,\n props: {\n routeName: {\n type: String,\n required: true,\n },\n routeParams: {\n type: Object as PropType<Params>,\n default: () => EMPTY_PARAMS,\n },\n routeOptions: {\n type: Object as PropType<NavigationOptions>,\n default: () => EMPTY_OPTIONS,\n },\n class: {\n type: String,\n default: undefined,\n },\n activeClassName: {\n type: String,\n default: \"active\",\n },\n activeStrict: {\n type: Boolean,\n default: false,\n },\n ignoreQueryParams: {\n type: Boolean,\n default: true,\n },\n target: {\n type: String,\n default: undefined,\n },\n /**\n * URL fragment (decoded form, no leading \"#\") (#532).\n * - omitted/`undefined` → preserve current fragment on same-route navigation\n * - `\"\"` → clear fragment\n * - non-empty → set fragment\n */\n hash: {\n type: String,\n default: undefined,\n },\n },\n setup(props, { slots, attrs }) {\n const router = useRouter();\n\n const isActive = shallowRef(false);\n\n // watch with an explicit dep getter recreates the source ONLY when\n // routeName/routeParams/strict/ignoreQueryParams change — not on every\n // reactive read inside the source factory (the watchEffect alternative\n // would also re-subscribe whenever isActive itself changed).\n watch(\n () =>\n [\n props.routeName,\n props.routeParams,\n props.activeStrict,\n props.ignoreQueryParams,\n props.hash,\n ] as const,\n (\n [routeName, routeParams, activeStrict, ignoreQueryParams, hash],\n _prev,\n onCleanup,\n ) => {\n // Hash-aware active (#532): pass hash through so tab links with the\n // same routeName but different `hash` props don't all light up.\n const source = createActiveRouteSource(\n router,\n routeName,\n routeParams,\n hash === undefined\n ? { strict: activeStrict, ignoreQueryParams }\n : { strict: activeStrict, ignoreQueryParams, hash },\n );\n\n isActive.value = source.getSnapshot();\n\n const unsub = source.subscribe(() => {\n isActive.value = source.getSnapshot();\n });\n\n onCleanup(unsub);\n },\n { immediate: true, flush: \"sync\" },\n );\n\n const href = computed(() =>\n buildHref(\n router,\n props.routeName,\n props.routeParams,\n props.hash === undefined ? undefined : { hash: props.hash },\n ),\n );\n\n const finalClassName = computed(() =>\n buildActiveClassName(isActive.value, props.activeClassName, props.class),\n );\n\n const handleClick = (evt: MouseEvent) => {\n // Vue allows attrs.onClick to be a function or an array of functions\n // (compiled templates with multiple @click bindings produce arrays).\n // Both must be invoked; treating arrays as \"no handler\" silently drops\n // user code.\n if (attrs.onClick !== undefined && attrs.onClick !== null) {\n invokeAttributesOnClick(attrs.onClick, evt);\n\n if (evt.defaultPrevented) {\n return;\n }\n }\n\n if (!shouldNavigate(evt) || props.target === \"_blank\") {\n return;\n }\n\n evt.preventDefault();\n navigateWithHash(\n router,\n props.routeName,\n props.routeParams,\n props.hash,\n props.routeOptions,\n ).catch(() => {});\n };\n\n return () => {\n // Build forwarded attrs without `onClick`. Vue's runtime auto-attaches\n // attrs.onClick (function OR array) as a native DOM listener, which would\n // double-invoke user handlers when combined with our explicit `onClick`.\n // We invoke the original attrs.onClick manually inside handleClick so the\n // preventDefault contract is preserved.\n const restAttributes: Record<string, unknown> = {};\n\n for (const key of Object.keys(attrs)) {\n if (key !== \"onClick\") {\n restAttributes[key] = (attrs as Record<string, unknown>)[key];\n }\n }\n\n return h(\n \"a\",\n {\n ...restAttributes,\n href: href.value,\n class: finalClassName.value,\n target: props.target,\n onClick: handleClick,\n },\n slots.default?.(),\n );\n };\n },\n});\n","import { createDismissableError } from \"@real-router/sources\";\nimport { defineComponent, h, watch, Fragment } from \"vue\";\n\nimport { useRouter } from \"../composables/useRouter\";\nimport { useRefFromSource } from \"../useRefFromSource\";\n\nimport type { RouterError, State } from \"@real-router/core\";\nimport type { VNode, PropType } from \"vue\";\n\nexport const RouterErrorBoundary = defineComponent({\n name: \"RouterErrorBoundary\",\n props: {\n fallback: {\n type: Function as PropType<\n (error: RouterError, resetError: () => void) => VNode\n >,\n required: true,\n },\n onError: {\n type: Function as PropType<\n (\n error: RouterError,\n toRoute: State | null,\n fromRoute: State | null,\n ) => void\n >,\n default: undefined,\n },\n },\n setup(props, { slots }) {\n const router = useRouter();\n const snapshot = useRefFromSource(createDismissableError(router));\n\n watch(\n () => snapshot.value.version,\n () => {\n if (snapshot.value.error) {\n props.onError?.(\n snapshot.value.error,\n snapshot.value.toRoute,\n snapshot.value.fromRoute,\n );\n }\n },\n { immediate: true },\n );\n\n return () => {\n const children = slots.default?.() ?? [];\n const errorVNode = snapshot.value.error\n ? props.fallback(snapshot.value.error, snapshot.value.resetError)\n : null;\n\n return h(Fragment, null, [...children, errorVNode]);\n };\n },\n});\n\nexport type RouterErrorBoundaryProps = InstanceType<\n typeof RouterErrorBoundary\n>[\"$props\"];\n","import { shouldNavigate, applyLinkA11y } from \"../dom-utils\";\n\nimport type { Router, NavigationOptions, Params } from \"@real-router/core\";\nimport type { Directive } from \"vue\";\n\nexport interface LinkDirectiveValue {\n name: string;\n params?: Params;\n options?: NavigationOptions;\n}\n\n/**\n * Router stack for nested RouterProviders. The active router is the top of\n * the stack. RouterProvider pushes its router on mount and pops it on unmount,\n * which preserves the parent context when an inner provider tears down.\n *\n * Without the stack, an unmounted child provider would leave the directive\n * pointing at a disposed router, and v-link in the still-mounted parent would\n * navigate via the wrong (or torn-down) instance.\n */\nconst routerStack: Router[] = [];\n\n/**\n * Pushes a router onto the active stack. Returns a release function that\n * removes that exact router from the stack regardless of position — safe\n * across out-of-order provider unmount sequences.\n *\n * @internal Used by RouterProvider during setup/teardown.\n */\nexport function pushDirectiveRouter(router: Router): () => void {\n routerStack.push(router);\n\n return () => {\n const idx = routerStack.lastIndexOf(router);\n\n if (idx !== -1) {\n routerStack.splice(idx, 1);\n }\n };\n}\n\n/**\n * Backwards-compatible alias. Replaces the active router unconditionally and\n * does NOT participate in the stack — use {@link pushDirectiveRouter} from\n * provider code instead. Kept for tests and direct callers.\n */\nexport function setDirectiveRouter(router: Router | null): void {\n if (router === null) {\n routerStack.length = 0;\n\n return;\n }\n if (routerStack.length === 0) {\n routerStack.push(router);\n\n return;\n }\n\n routerStack[routerStack.length - 1] = router;\n}\n\nexport function getDirectiveRouter(): Router {\n const top = routerStack.at(-1);\n\n if (!top) {\n throw new Error(\n \"v-link directive requires a RouterProvider ancestor. Make sure RouterProvider is mounted.\",\n );\n }\n\n return top;\n}\n\ninterface Handlers {\n click: (evt: MouseEvent) => void;\n keydown: (evt: KeyboardEvent) => void;\n}\n\n// Single WeakMap halves per-element bookkeeping vs two parallel maps.\nconst handlers = new WeakMap<HTMLElement, Handlers>();\n\n/**\n * Validates a directive binding value before attaching handlers.\n * Returns false (and warns once per call) when the value is missing or\n * has no `name` — silently doing nothing is preferable to a runtime crash\n * inside a click handler.\n */\nfunction isValidBinding(value: unknown): value is LinkDirectiveValue {\n if (value === null || value === undefined) {\n console.error(\n \"[real-router] v-link directive received null/undefined value. The element will not be wired for navigation.\",\n );\n\n return false;\n }\n if (typeof (value as { name?: unknown }).name !== \"string\") {\n console.error(\n \"[real-router] v-link directive value is missing a string `name` field. The element will not be wired for navigation.\",\n );\n\n return false;\n }\n\n return true;\n}\n\nfunction createClickHandler(\n router: Router,\n value: LinkDirectiveValue,\n): (evt: MouseEvent) => void {\n return (evt: MouseEvent) => {\n if (!shouldNavigate(evt)) {\n return;\n }\n\n evt.preventDefault();\n router\n .navigate(value.name, value.params ?? {}, value.options ?? {})\n .catch(() => {});\n };\n}\n\nfunction createKeydownHandler(\n router: Router,\n value: LinkDirectiveValue,\n element: HTMLElement,\n): (evt: KeyboardEvent) => void {\n return (evt: KeyboardEvent) => {\n if (evt.key === \"Enter\" && !(element instanceof HTMLButtonElement)) {\n router\n .navigate(value.name, value.params ?? {}, value.options ?? {})\n .catch(() => {});\n }\n };\n}\n\nfunction attachHandlers(\n element: HTMLElement,\n router: Router,\n value: LinkDirectiveValue,\n): void {\n const click = createClickHandler(router, value);\n const keydown = createKeydownHandler(router, value, element);\n\n element.addEventListener(\"click\", click);\n element.addEventListener(\"keydown\", keydown);\n\n handlers.set(element, { click, keydown });\n}\n\nfunction detachHandlers(element: HTMLElement): void {\n const entry = handlers.get(element);\n\n if (entry) {\n element.removeEventListener(\"click\", entry.click);\n element.removeEventListener(\"keydown\", entry.keydown);\n handlers.delete(element);\n }\n}\n\nexport const vLink: Directive<HTMLElement, LinkDirectiveValue> = {\n mounted(element, binding) {\n const router = getDirectiveRouter();\n\n applyLinkA11y(element);\n\n element.style.cursor = \"pointer\";\n\n if (!isValidBinding(binding.value)) {\n return;\n }\n\n attachHandlers(element, router, binding.value);\n },\n\n updated(element, binding) {\n const router = getDirectiveRouter();\n\n detachHandlers(element);\n\n if (!isValidBinding(binding.value)) {\n return;\n }\n\n attachHandlers(element, router, binding.value);\n },\n\n beforeUnmount(element) {\n detachHandlers(element);\n },\n};\n","import { inject } from \"vue\";\n\nimport { NavigatorKey } from \"../context\";\n\nimport type { Navigator } from \"@real-router/core\";\n\nexport const useNavigator = (): Navigator => {\n const navigator = inject(NavigatorKey);\n\n if (!navigator) {\n throw new Error(\"useNavigator must be used within a RouterProvider\");\n }\n\n return navigator;\n};\n","import { getPluginApi } from \"@real-router/core/api\";\nimport { getRouteUtils } from \"@real-router/route-utils\";\n\nimport { useRouter } from \"./useRouter\";\n\nimport type { RouteUtils } from \"@real-router/route-utils\";\n\nexport const useRouteUtils = (): RouteUtils => {\n const router = useRouter();\n\n return getRouteUtils(getPluginApi(router).getTree());\n};\n","import { inject } from \"vue\";\n\nimport { RouteKey } from \"../context\";\n\nimport type { RouteContext } from \"../types\";\nimport type { Params, State } from \"@real-router/core\";\nimport type { Ref } from \"vue\";\n\nexport const useRoute = <P extends Params = Params>(): Omit<\n RouteContext<P>,\n \"route\"\n> & { route: Readonly<Ref<State<P>>> } => {\n const routeContext = inject(RouteKey);\n\n if (!routeContext) {\n throw new Error(\"useRoute must be used within a RouterProvider\");\n }\n\n if (!routeContext.route.value) {\n throw new Error(\n \"useRoute called with no active route. Did you forget to await router.start() before rendering, or is the router stopped/disposed?\",\n );\n }\n\n return routeContext as Omit<RouteContext<P>, \"route\"> & {\n route: Readonly<Ref<State<P>>>;\n };\n};\n","import { getTransitionSource } from \"@real-router/sources\";\n\nimport { useRefFromSource } from \"../useRefFromSource\";\nimport { useRouter } from \"./useRouter\";\n\nimport type { RouterTransitionSnapshot } from \"@real-router/sources\";\nimport type { ShallowRef } from \"vue\";\n\nexport function useRouterTransition(): ShallowRef<RouterTransitionSnapshot> {\n const router = useRouter();\n const source = getTransitionSource(router);\n\n return useRefFromSource(source);\n}\n","import { onScopeDispose } from \"vue\";\n\nimport { useRouter } from \"./useRouter\";\n\nimport type { State } from \"@real-router/core\";\n\nexport interface RouteExitContext {\n /** The route being left. */\n route: State;\n /** The route being navigated to. */\n nextRoute: State;\n /**\n * AbortSignal that fires when this navigation is superseded by a later\n * one (rapid clicks). Already filtered: when the handler runs,\n * `signal.aborted` is guaranteed to be `false`. Use\n * `signal.addEventListener(\"abort\", cleanup, { once: true })` for\n * cleanup that must run on cancellation.\n */\n signal: AbortSignal;\n}\n\nexport interface UseRouteExitOptions {\n /**\n * Skip the handler when `route.name === nextRoute.name`\n * (sort/filter/query-only navigations on the same route). Default:\n * `true`.\n */\n skipSameRoute?: boolean;\n}\n\nexport type RouteExitHandler = (\n context: RouteExitContext,\n) => void | Promise<void>;\n\n/**\n * Subscribe to the router's leave-window with the universal guards baked\n * in. Wraps `router.subscribeLeave` so consumers don't repeat the same\n * boilerplate every time:\n *\n * - **Reentrant abort pre-check**: if `signal.aborted` is already `true`\n * when the handler would run (rapid navigation superseded a slower\n * one), the handler is skipped entirely.\n * - **Same-route skip**: by default, `route.name === nextRoute.name`\n * short-circuits the handler — query-only navigations skip the work.\n * Opt out with `skipSameRoute: false`.\n *\n * Cleanup is bound to the component's effect scope via `onScopeDispose`.\n *\n * If the handler returns a Promise, the router blocks on it. If the\n * Promise resolves, navigation proceeds. If it rejects, the router emits\n * `TRANSITION_CANCELLED`.\n *\n * **Handler reactivity (Vue):** Vue composables run **once** during\n * `setup()`; `handler` is captured in closure at the call site. To vary\n * behavior over time, read refs/computeds inside the handler body — do\n * not rely on swapping the handler reference.\n *\n * @example Animation\n * ```ts\n * const ref = useTemplateRef<HTMLDivElement>(\"box\");\n *\n * useRouteExit(async ({ signal }) => {\n * const el = ref.value;\n * if (!el) return;\n * el.classList.add(\"fade-out\");\n * const cleanup = () => el.classList.remove(\"fade-out\");\n * signal.addEventListener(\"abort\", cleanup, { once: true });\n * try {\n * el.getBoundingClientRect();\n * await Promise.allSettled(el.getAnimations().map((a) => a.finished));\n * } finally {\n * cleanup();\n * }\n * });\n * ```\n *\n * @example Auto-save form draft\n * ```ts\n * useRouteExit(async ({ signal }) => {\n * if (formState.value.dirty) {\n * await api.saveDraft(formState.value, { signal });\n * }\n * });\n * ```\n *\n * @example Reading rich transition metadata via `nextRoute.transition`\n * ```ts\n * useRouteExit(({ route, nextRoute }) => {\n * if (nextRoute.transition.segments.deactivated.includes(\"products\")) {\n * productCache.clear();\n * }\n * if (nextRoute.transition.redirected) return;\n * });\n * ```\n */\nexport function useRouteExit(\n handler: RouteExitHandler,\n options?: UseRouteExitOptions,\n): void {\n const router = useRouter();\n const skipSameRoute = options?.skipSameRoute ?? true;\n\n const off = router.subscribeLeave(({ route, nextRoute, signal }) => {\n if (skipSameRoute && route.name === nextRoute.name) {\n return;\n }\n\n if (signal.aborted) {\n return;\n }\n\n return handler({ route, nextRoute, signal });\n });\n\n onScopeDispose(off);\n}\n","import { watch } from \"vue\";\n\nimport { useRoute } from \"./useRoute\";\n\nimport type { State } from \"@real-router/core\";\n\nexport interface RouteEnterContext {\n /** The route that was just activated. */\n route: State;\n /** The route that was active immediately before this navigation. */\n previousRoute: State;\n}\n\nexport type RouteEnterHandler = (context: RouteEnterContext) => void;\n\nexport interface UseRouteEnterOptions {\n /**\n * Skip the handler when `route.name === previousRoute.name`\n * (sort/filter/query-only navigations on the same route). Default:\n * `true`. Symmetric with `useRouteExit`'s same-name option.\n */\n skipSameRoute?: boolean;\n}\n\n/**\n * Fire `handler` once when the component mounts as a result of a\n * navigation. Mirror of `useRouteExit` for the entry side.\n *\n * What this composable covers that an ad-hoc `watch` + `useRoute()`\n * doesn't:\n *\n * - **Skip-initial**: `watch` (with default `immediate: false`) plus the\n * explicit `route.transition.from` guard ensures the handler doesn't\n * fire on the very first state committed by `router.start()`.\n * - **Same-route skip** (default): handler is skipped when\n * `route.transition.from === route.name`. Sort/filter/query-only\n * navigations re-trigger the watcher, but they are not \"entries\" in\n * the animation / analytics sense. Opt out with\n * `skipSameRoute: false`.\n * - **Mount-time `route` / `previousRoute` snapshot**: handler receives\n * the values that were live at the moment of the new state, not the\n * latest ones (which may have moved on if the user navigated again\n * before the watcher drained).\n *\n * **Handler reactivity (Vue):** Vue composables run **once** during\n * `setup()`; `handler` is captured in closure at the call site. To vary\n * behavior over time, read refs/computeds inside the handler body.\n *\n * @example Direction-aware entry animation\n * ```ts\n * useRouteEnter(({ route }) => {\n * const direction = route.context.browser?.direction;\n * ref.value?.classList.add(\n * direction === \"back\" ? \"slide-from-left\" : \"slide-from-right\",\n * );\n * });\n * ```\n *\n * @example Analytics page-enter event (skip-initial built-in)\n * ```ts\n * useRouteEnter(({ route, previousRoute }) => {\n * analytics.track(\"page_enter\", {\n * route: route.name,\n * from: previousRoute.name,\n * });\n * });\n * ```\n *\n * @example Reading rich transition metadata via `route.transition`\n * ```ts\n * useRouteEnter(({ route }) => {\n * if (route.transition.redirected) {\n * showToast(`Redirected from ${route.transition.from}`);\n * }\n * });\n * ```\n */\nexport function useRouteEnter(\n handler: RouteEnterHandler,\n options?: UseRouteEnterOptions,\n): void {\n const { route, previousRoute } = useRoute();\n const skipSameRoute = options?.skipSameRoute ?? true;\n let lastHandledRoute: State | null = null;\n\n watch(route, (newRoute) => {\n const prev = previousRoute.value;\n\n // Early-exit guards, top-down:\n //\n // - **Skip-initial**: `!transition.from` catches the first commit\n // from `router.start()`. Vue's `watch` (default `immediate: false`)\n // does not fire on the initial state — kept for parity with\n // React/Preact and v8-ignored.\n // - **Skip-same-route**: query-only navigations have\n // `transition.from === route.name`. Opt-out via\n // `skipSameRoute: false`.\n // - **Defensive dedupe + missing `previousRoute`**: same `route`\n // ref between watcher activations is unexpected on Vue (driven\n // off ref identity); `!prev` is unreachable once\n // `transition.from` is set (core populates them together). Both\n // kept for parity with React; v8-ignored.\n /* v8 ignore start */\n if (!newRoute.transition.from) {\n return;\n }\n /* v8 ignore stop */\n if (skipSameRoute && newRoute.transition.from === newRoute.name) {\n return;\n }\n /* v8 ignore start */\n if (lastHandledRoute === newRoute || !prev) {\n return;\n }\n /* v8 ignore stop */\n\n lastHandledRoute = newRoute;\n handler({ route: newRoute, previousRoute: prev });\n });\n}\n","// packages/vue/src/setupRouteProvision.ts\n\nimport { getNavigator } from \"@real-router/core\";\nimport { createRouteSource } from \"@real-router/sources\";\nimport { shallowRef } from \"vue\";\n\nimport type { Router, Navigator, State } from \"@real-router/core\";\nimport type { ShallowRef } from \"vue\";\n\n/**\n * Shared setup for `RouterProvider` (component-scoped) and\n * `createRouterPlugin` (app-scoped). Builds the reactive route refs +\n * subscription bookkeeping in one place; callers wire the result into their\n * provide/inject mechanism and own teardown lifecycle.\n *\n * @internal\n */\nexport interface RouteProvision {\n navigator: Navigator;\n route: ShallowRef<State | undefined>;\n previousRoute: ShallowRef<State | undefined>;\n /** Call when the owning scope tears down to release the router subscription. */\n unsubscribe: () => void;\n}\n\nexport function setupRouteProvision(router: Router): RouteProvision {\n const navigator = getNavigator(router);\n const source = createRouteSource(router);\n const initial = source.getSnapshot();\n\n const route = shallowRef<State | undefined>(initial.route);\n const previousRoute = shallowRef<State | undefined>(initial.previousRoute);\n\n const unsubscribe = source.subscribe(() => {\n const snapshot = source.getSnapshot();\n\n route.value = snapshot.route;\n previousRoute.value = snapshot.previousRoute;\n });\n\n return { navigator, route, previousRoute, unsubscribe };\n}\n","import { NavigatorKey, RouteKey, RouterKey } from \"./context\";\nimport { pushDirectiveRouter } from \"./directives/vLink\";\nimport { setupRouteProvision } from \"./setupRouteProvision\";\n\nimport type { Router } from \"@real-router/core\";\nimport type { App, Plugin } from \"vue\";\n\nexport function createRouterPlugin(router: Router): Plugin<[]> {\n return {\n install(app): void {\n const releaseDirective = pushDirectiveRouter(router);\n\n const { navigator, route, previousRoute, unsubscribe } =\n setupRouteProvision(router);\n\n // Vue 3.5+ exposes app.onUnmount for plugin cleanup.\n // On older versions (3.3–3.4), the subscription is cleaned up\n // when the router is garbage-collected (same as vue-router).\n if (\"onUnmount\" in app) {\n (app as App & { onUnmount: (fn: () => void) => void }).onUnmount(() => {\n releaseDirective();\n unsubscribe();\n });\n }\n\n app.provide(RouterKey, router);\n app.provide(NavigatorKey, navigator);\n app.provide(RouteKey, { navigator, route, previousRoute });\n },\n };\n}\n","import { defineComponent, onScopeDispose, provide, watch } from \"vue\";\n\nimport { NavigatorKey, RouteKey, RouterKey } from \"./context\";\nimport { pushDirectiveRouter } from \"./directives/vLink\";\nimport {\n createRouteAnnouncer,\n createScrollRestoration,\n createViewTransitions,\n} from \"./dom-utils\";\nimport { setupRouteProvision } from \"./setupRouteProvision\";\n\nimport type { ScrollRestorationOptions } from \"./dom-utils\";\nimport type { Router } from \"@real-router/core\";\nimport type { PropType } from \"vue\";\n\nexport const RouterProvider = defineComponent({\n name: \"RouterProvider\",\n props: {\n router: {\n type: Object as PropType<Router>,\n required: true,\n },\n announceNavigation: {\n type: Boolean,\n default: false,\n },\n scrollRestoration: {\n type: Object as PropType<ScrollRestorationOptions>,\n },\n viewTransitions: {\n type: Boolean,\n default: false,\n },\n },\n setup(props, { slots }) {\n // Reactive announceNavigation: setting prop true/false at runtime now\n // creates/destroys the announcer accordingly. Prior implementation read\n // the prop only inside onMounted, so toggling it post-mount silently no-op'd.\n watch(\n () => [props.router, props.announceNavigation] as const,\n ([router, enabled], _prev, onCleanup) => {\n if (!enabled) {\n return;\n }\n\n const announcer = createRouteAnnouncer(router);\n\n onCleanup(() => {\n announcer.destroy();\n });\n },\n { immediate: true },\n );\n\n // Watch by primitives so inline `{ mode: \"restore\" }` doesn't thrash.\n // scrollContainer is a getter invoked lazily on every event inside the\n // utility — swapping its reference doesn't change the resolved element,\n // so we intentionally omit it from watched sources.\n watch(\n () =>\n [\n props.router,\n props.scrollRestoration !== undefined,\n props.scrollRestoration?.mode,\n props.scrollRestoration?.anchorScrolling,\n props.scrollRestoration?.behavior,\n props.scrollRestoration?.storageKey,\n ] as const,\n (\n [router, enabled, mode, anchorScrolling, behavior, storageKey],\n _prev,\n onCleanup,\n ) => {\n if (!enabled) {\n return;\n }\n\n const sr = createScrollRestoration(router, {\n mode,\n anchorScrolling,\n behavior,\n storageKey,\n scrollContainer: props.scrollRestoration?.scrollContainer,\n });\n\n onCleanup(() => {\n sr.destroy();\n });\n },\n { immediate: true },\n );\n\n // Reactive viewTransitions: toggling prop creates/destroys the utility.\n watch(\n () => [props.router, props.viewTransitions] as const,\n ([router, enabled], _prev, onCleanup) => {\n if (!enabled) {\n return;\n }\n\n const vt = createViewTransitions(router);\n\n onCleanup(() => {\n vt.destroy();\n });\n },\n { immediate: true },\n );\n\n // Push this provider's router on the v-link directive stack so nested\n // RouterProviders behave like nested DI scopes (LIFO). Release on unmount\n // restores the outer router for any v-link still mounted in the parent.\n const releaseDirective = pushDirectiveRouter(props.router);\n\n const { navigator, route, previousRoute, unsubscribe } =\n setupRouteProvision(props.router);\n\n onScopeDispose(() => {\n releaseDirective();\n unsubscribe();\n });\n\n provide(RouterKey, props.router);\n provide(NavigatorKey, navigator);\n provide(RouteKey, { navigator, route, previousRoute });\n\n return () => slots.default?.();\n },\n});\n"],"mappings":"8jBAKA,SAAS,GAAa,CACpB,OAAO,KAGT,MAAa,EAAQ,EAAgB,CACnC,KAAM,kBACN,MAAO,CACL,QAAS,CACP,KAAM,OACN,SAAU,GACX,CACD,MAAO,CACL,KAAM,QACN,QAAS,GACV,CACD,SAAU,CACR,KAAM,CAAC,OAAQ,S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IAAM,EAAK,GAAwB,EAAQ,CACzC,OACA,kBACA,WACA,aACA,gBAAiB,EAAM,mBAAmB,gBAC3C,CAAC,CAEF,MAAgB,CACd,EAAG,SAAS,EACZ,EAEJ,CAAE,UAAW,GAAM,CACpB,CAGD,MACQ,CAAC,EAAM,OAAQ,EAAM,gBAAgB,EAC1C,CAAC,EAAQ,GAAU,EAAO,IAAc,CACvC,GAAI,CAAC,EACH,OAGF,IAAM,EAAK,GAAsB,EAAO,CAExC,MAAgB,CACd,EAAG,SAAS,EACZ,EAEJ,CAAE,UAAW,GAAM,CACpB,CAKD,IAAM,EAAmB,EAAoB,EAAM,OAAO,CAEpD,CAAE,YAAW,QAAO,gBAAe,eACvC,EAAoB,EAAM,OAAO,CAWnC,OATA,MAAqB,CACnB,GAAkB,CAClB,GAAa,EACb,CAEF,EAAQ,EAAW,EAAM,OAAO,CAChC,EAAQ,EAAc,EAAU,CAChC,EAAQ,EAAU,CAAE,YAAW,QAAO,gBAAe,CAAC,KAEzC,EAAM,WAAW,EAEjC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@real-router/vue",
3
- "version": "0.10.1",
3
+ "version": "0.12.0",
4
4
  "type": "commonjs",
5
5
  "description": "Vue 3 integration for Real-Router",
6
6
  "main": "./dist/cjs/index.js",
@@ -52,13 +52,13 @@
52
52
  "dependencies": {
53
53
  "@real-router/core": "^0.51.0",
54
54
  "@real-router/route-utils": "^0.2.2",
55
- "@real-router/sources": "^0.7.3"
55
+ "@real-router/sources": "^0.8.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@testing-library/jest-dom": "6.9.1",
59
59
  "@vue/test-utils": "2.4.6",
60
60
  "vue": "3.5.13",
61
- "@real-router/browser-plugin": "^0.16.1"
61
+ "@real-router/browser-plugin": "^0.17.0"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "vue": ">=3.3.0"
@@ -63,8 +63,14 @@ export const RouterProvider = defineComponent({
63
63
  props.scrollRestoration !== undefined,
64
64
  props.scrollRestoration?.mode,
65
65
  props.scrollRestoration?.anchorScrolling,
66
+ props.scrollRestoration?.behavior,
67
+ props.scrollRestoration?.storageKey,
66
68
  ] as const,
67
- ([router, enabled, mode, anchorScrolling], _prev, onCleanup) => {
69
+ (
70
+ [router, enabled, mode, anchorScrolling, behavior, storageKey],
71
+ _prev,
72
+ onCleanup,
73
+ ) => {
68
74
  if (!enabled) {
69
75
  return;
70
76
  }
@@ -72,6 +78,8 @@ export const RouterProvider = defineComponent({
72
78
  const sr = createScrollRestoration(router, {
73
79
  mode,
74
80
  anchorScrolling,
81
+ behavior,
82
+ storageKey,
75
83
  scrollContainer: props.scrollRestoration?.scrollContainer,
76
84
  });
77
85
 
@@ -3,7 +3,12 @@ import { defineComponent, h, computed, shallowRef, watch } from "vue";
3
3
 
4
4
  import { useRouter } from "../composables/useRouter";
5
5
  import { EMPTY_PARAMS, EMPTY_OPTIONS } from "../constants";
6
- import { shouldNavigate, buildHref, buildActiveClassName } from "../dom-utils";
6
+ import {
7
+ shouldNavigate,
8
+ buildHref,
9
+ buildActiveClassName,
10
+ navigateWithHash,
11
+ } from "../dom-utils";
7
12
 
8
13
  import type { Params, NavigationOptions } from "@real-router/core";
9
14
  import type { PropType } from "vue";
@@ -75,6 +80,16 @@ export const Link = defineComponent({
75
80
  type: String,
76
81
  default: undefined,
77
82
  },
83
+ /**
84
+ * URL fragment (decoded form, no leading "#") (#532).
85
+ * - omitted/`undefined` → preserve current fragment on same-route navigation
86
+ * - `""` → clear fragment
87
+ * - non-empty → set fragment
88
+ */
89
+ hash: {
90
+ type: String,
91
+ default: undefined,
92
+ },
78
93
  },
79
94
  setup(props, { slots, attrs }) {
80
95
  const router = useRouter();
@@ -92,16 +107,23 @@ export const Link = defineComponent({
92
107
  props.routeParams,
93
108
  props.activeStrict,
94
109
  props.ignoreQueryParams,
110
+ props.hash,
95
111
  ] as const,
96
112
  (
97
- [routeName, routeParams, activeStrict, ignoreQueryParams],
113
+ [routeName, routeParams, activeStrict, ignoreQueryParams, hash],
98
114
  _prev,
99
115
  onCleanup,
100
116
  ) => {
101
- const source = createActiveRouteSource(router, routeName, routeParams, {
102
- strict: activeStrict,
103
- ignoreQueryParams,
104
- });
117
+ // Hash-aware active (#532): pass hash through so tab links with the
118
+ // same routeName but different `hash` props don't all light up.
119
+ const source = createActiveRouteSource(
120
+ router,
121
+ routeName,
122
+ routeParams,
123
+ hash === undefined
124
+ ? { strict: activeStrict, ignoreQueryParams }
125
+ : { strict: activeStrict, ignoreQueryParams, hash },
126
+ );
105
127
 
106
128
  isActive.value = source.getSnapshot();
107
129
 
@@ -115,7 +137,12 @@ export const Link = defineComponent({
115
137
  );
116
138
 
117
139
  const href = computed(() =>
118
- buildHref(router, props.routeName, props.routeParams),
140
+ buildHref(
141
+ router,
142
+ props.routeName,
143
+ props.routeParams,
144
+ props.hash === undefined ? undefined : { hash: props.hash },
145
+ ),
119
146
  );
120
147
 
121
148
  const finalClassName = computed(() =>
@@ -140,9 +167,13 @@ export const Link = defineComponent({
140
167
  }
141
168
 
142
169
  evt.preventDefault();
143
- router
144
- .navigate(props.routeName, props.routeParams, props.routeOptions)
145
- .catch(() => {});
170
+ navigateWithHash(
171
+ router,
172
+ props.routeName,
173
+ props.routeParams,
174
+ props.hash,
175
+ props.routeOptions,
176
+ ).catch(() => {});
146
177
  };
147
178
 
148
179
  return () => {
@@ -11,13 +11,21 @@ export function useIsActiveRoute(
11
11
  params?: Params,
12
12
  strict = false,
13
13
  ignoreQueryParams = true,
14
+ hash?: string,
14
15
  ): ShallowRef<boolean> {
15
16
  const router = useRouter();
16
17
 
17
- const source = createActiveRouteSource(router, routeName, params, {
18
- strict,
19
- ignoreQueryParams,
20
- });
18
+ // The `hash` argument (#532) participates in the cache key when defined.
19
+ // exactOptionalPropertyTypes forbids `{ hash: undefined }` literally — we
20
+ // conditionally include the key only when a value is provided.
21
+ const source = createActiveRouteSource(
22
+ router,
23
+ routeName,
24
+ params,
25
+ hash === undefined
26
+ ? { strict, ignoreQueryParams }
27
+ : { strict, ignoreQueryParams, hash },
28
+ );
21
29
 
22
30
  return useRefFromSource(source);
23
31
  }