vinext 0.0.35 → 0.0.36

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":"navigation.js","names":["React"],"sources":["../../src/shims/navigation.ts"],"sourcesContent":["/**\n * next/navigation shim\n *\n * App Router navigation hooks. These work on both server (RSC) and client.\n * Server-side: reads from a request context set by the RSC handler.\n * Client-side: reads from browser Location API and provides navigation.\n */\n\n// Use namespace import for RSC safety: the react-server condition doesn't export\n// createContext/useContext/useSyncExternalStore as named exports, and strict ESM\n// would throw at link time for missing bindings. With `import * as React`, the\n// bindings are just `undefined` on the namespace object and we can guard at runtime.\nimport * as React from \"react\";\nimport { toBrowserNavigationHref, toSameOriginAppPath } from \"./url-utils.js\";\nimport { stripBasePath } from \"../utils/base-path.js\";\nimport { ReadonlyURLSearchParams } from \"./readonly-url-search-params.js\";\n\n// ─── Layout segment context ───────────────────────────────────────────────────\n// Stores the child segments below the current layout. Each layout wraps its\n// children with a provider whose value is the remaining route tree segments\n// (including route groups, with dynamic params resolved to actual values).\n// Created lazily because `React.createContext` is NOT available in the\n// react-server condition of React. In the RSC environment, this remains null.\n// The shared context lives behind a global singleton so provider/hook pairs\n// still line up if Vite loads this shim through multiple resolved module IDs.\nconst _LAYOUT_SEGMENT_CTX_KEY = Symbol.for(\"vinext.layoutSegmentContext\");\nconst _SERVER_INSERTED_HTML_CTX_KEY = Symbol.for(\"vinext.serverInsertedHTMLContext\");\ntype _LayoutSegmentGlobal = typeof globalThis & {\n [_LAYOUT_SEGMENT_CTX_KEY]?: React.Context<string[]> | null;\n [_SERVER_INSERTED_HTML_CTX_KEY]?: React.Context<\n ((callback: () => unknown) => void) | null\n > | null;\n};\n\n// ─── ServerInsertedHTML context ────────────────────────────────────────────────\n// Used by CSS-in-JS libraries (Apollo Client, styled-components, emotion) to\n// register HTML injection callbacks during SSR via useContext().\n// The SSR entry wraps the rendered tree with a Provider whose value is a\n// callback registration function (useServerInsertedHTML).\n//\n// In Next.js, ServerInsertedHTMLContext holds a function:\n// (callback: () => React.ReactNode) => void\n// Libraries call useContext(ServerInsertedHTMLContext) to get this function,\n// then call it to register callbacks that inject HTML during SSR.\n//\n// Created eagerly at module load time. In the RSC environment (react-server\n// condition), createContext isn't available so this will be null.\n\nfunction getServerInsertedHTMLContext(): React.Context<\n ((callback: () => unknown) => void) | null\n> | null {\n if (typeof React.createContext !== \"function\") return null;\n\n const globalState = globalThis as _LayoutSegmentGlobal;\n if (!globalState[_SERVER_INSERTED_HTML_CTX_KEY]) {\n globalState[_SERVER_INSERTED_HTML_CTX_KEY] = React.createContext<\n ((callback: () => unknown) => void) | null\n >(null);\n }\n\n return globalState[_SERVER_INSERTED_HTML_CTX_KEY] ?? null;\n}\n\nexport const ServerInsertedHTMLContext: React.Context<\n ((callback: () => unknown) => void) | null\n> | null = getServerInsertedHTMLContext();\n\n/**\n * Get or create the layout segment context.\n * Returns null in the RSC environment (createContext unavailable).\n */\nexport function getLayoutSegmentContext(): React.Context<string[]> | null {\n if (typeof React.createContext !== \"function\") return null;\n\n const globalState = globalThis as _LayoutSegmentGlobal;\n if (!globalState[_LAYOUT_SEGMENT_CTX_KEY]) {\n globalState[_LAYOUT_SEGMENT_CTX_KEY] = React.createContext<string[]>([]);\n }\n\n return globalState[_LAYOUT_SEGMENT_CTX_KEY] ?? null;\n}\n\n/**\n * Read the child segments below the current layout from context.\n * Returns [] if no context is available (RSC environment, outside React tree).\n */\nfunction useChildSegments(): string[] {\n const ctx = getLayoutSegmentContext();\n if (!ctx) return [];\n // useContext is safe here because if createContext exists, useContext does too.\n // This branch is only taken in SSR/Browser, never in RSC.\n // Try/catch for unit tests that call this hook outside a React render tree.\n try {\n return React.useContext(ctx);\n } catch {\n return [];\n }\n}\n\n// ---------------------------------------------------------------------------\n// Server-side request context (set by the RSC entry before rendering)\n// ---------------------------------------------------------------------------\n\nexport interface NavigationContext {\n pathname: string;\n searchParams: URLSearchParams;\n params: Record<string, string | string[]>;\n}\n\nconst _READONLY_SEARCH_PARAMS = Symbol(\"vinext.navigation.readonlySearchParams\");\nconst _READONLY_SEARCH_PARAMS_SOURCE = Symbol(\"vinext.navigation.readonlySearchParamsSource\");\n\ntype NavigationContextWithReadonlyCache = NavigationContext & {\n [_READONLY_SEARCH_PARAMS]?: ReadonlyURLSearchParams;\n [_READONLY_SEARCH_PARAMS_SOURCE]?: URLSearchParams;\n};\n\n// ---------------------------------------------------------------------------\n// Server-side navigation state lives in a separate server-only module\n// (navigation-state.ts) that uses AsyncLocalStorage for request isolation.\n// This module is bundled for the browser, so it can't import node:async_hooks.\n//\n// On the server: state functions are set by navigation-state.ts at import time.\n// On the client: _serverContext falls back to null (hooks use window instead).\n// ---------------------------------------------------------------------------\n\nlet _serverContext: NavigationContext | null = null;\nlet _serverInsertedHTMLCallbacks: Array<() => unknown> = [];\n\n// These are overridden by navigation-state.ts on the server to use ALS.\nlet _getServerContext = (): NavigationContext | null => _serverContext;\nlet _setServerContext = (ctx: NavigationContext | null): void => {\n _serverContext = ctx;\n};\nlet _getInsertedHTMLCallbacks = (): Array<() => unknown> => _serverInsertedHTMLCallbacks;\nlet _clearInsertedHTMLCallbacks = (): void => {\n _serverInsertedHTMLCallbacks = [];\n};\n\n/**\n * Register ALS-backed state accessors. Called by navigation-state.ts on import.\n * @internal\n */\nexport function _registerStateAccessors(accessors: {\n getServerContext: () => NavigationContext | null;\n setServerContext: (ctx: NavigationContext | null) => void;\n getInsertedHTMLCallbacks: () => Array<() => unknown>;\n clearInsertedHTMLCallbacks: () => void;\n}): void {\n _getServerContext = accessors.getServerContext;\n _setServerContext = accessors.setServerContext;\n _getInsertedHTMLCallbacks = accessors.getInsertedHTMLCallbacks;\n _clearInsertedHTMLCallbacks = accessors.clearInsertedHTMLCallbacks;\n}\n\n/**\n * Get the navigation context for the current SSR/RSC render.\n * Reads from AsyncLocalStorage when available (concurrent-safe),\n * otherwise falls back to module-level state.\n */\nexport function getNavigationContext(): NavigationContext | null {\n return _getServerContext();\n}\n\n/**\n * Set the navigation context for the current SSR/RSC render.\n * Called by the framework entry before rendering each request.\n */\nexport function setNavigationContext(ctx: NavigationContext | null): void {\n _setServerContext(ctx);\n}\n\n// ---------------------------------------------------------------------------\n// Client-side state\n// ---------------------------------------------------------------------------\n\nconst isServer = typeof window === \"undefined\";\n\n/** basePath from next.config.js, injected by the plugin at build time */\nconst __basePath: string = process.env.__NEXT_ROUTER_BASEPATH ?? \"\";\n\n// ---------------------------------------------------------------------------\n// RSC prefetch cache utilities (shared between link.tsx and browser entry)\n// ---------------------------------------------------------------------------\n\n/** Maximum number of entries in the RSC prefetch cache. */\nexport const MAX_PREFETCH_CACHE_SIZE = 50;\n\n/** TTL for prefetch cache entries in ms (matches Next.js static prefetch TTL). */\nexport const PREFETCH_CACHE_TTL = 30_000;\n\nexport interface PrefetchCacheEntry {\n response: Response;\n timestamp: number;\n}\n\n/**\n * Convert a pathname (with optional query/hash) to its .rsc URL.\n * Strips trailing slashes before appending `.rsc` so that cache keys\n * are consistent regardless of the `trailingSlash` config setting.\n */\nexport function toRscUrl(href: string): string {\n const [beforeHash] = href.split(\"#\");\n const qIdx = beforeHash.indexOf(\"?\");\n const pathname = qIdx === -1 ? beforeHash : beforeHash.slice(0, qIdx);\n const query = qIdx === -1 ? \"\" : beforeHash.slice(qIdx);\n // Strip trailing slash (but preserve \"/\" root) for consistent cache keys\n const normalizedPath =\n pathname.length > 1 && pathname.endsWith(\"/\") ? pathname.slice(0, -1) : pathname;\n return normalizedPath + \".rsc\" + query;\n}\n\n/** Get or create the shared in-memory RSC prefetch cache on window. */\nexport function getPrefetchCache(): Map<string, PrefetchCacheEntry> {\n if (isServer) return new Map();\n if (!window.__VINEXT_RSC_PREFETCH_CACHE__) {\n window.__VINEXT_RSC_PREFETCH_CACHE__ = new Map<string, PrefetchCacheEntry>();\n }\n return window.__VINEXT_RSC_PREFETCH_CACHE__;\n}\n\n/**\n * Get or create the shared set of already-prefetched RSC URLs on window.\n * Keyed by rscUrl so that the browser entry can clear entries when consumed.\n */\nexport function getPrefetchedUrls(): Set<string> {\n if (isServer) return new Set();\n if (!window.__VINEXT_RSC_PREFETCHED_URLS__) {\n window.__VINEXT_RSC_PREFETCHED_URLS__ = new Set<string>();\n }\n return window.__VINEXT_RSC_PREFETCHED_URLS__;\n}\n\n/**\n * Store a prefetched RSC response in the cache.\n * Enforces a maximum cache size to prevent unbounded memory growth on\n * link-heavy pages.\n */\nexport function storePrefetchResponse(rscUrl: string, response: Response): void {\n const cache = getPrefetchCache();\n const now = Date.now();\n\n // Sweep expired entries before resorting to FIFO eviction\n if (cache.size >= MAX_PREFETCH_CACHE_SIZE) {\n const prefetched = getPrefetchedUrls();\n for (const [key, entry] of cache) {\n if (now - entry.timestamp >= PREFETCH_CACHE_TTL) {\n cache.delete(key);\n prefetched.delete(key);\n }\n }\n }\n\n // FIFO fallback if still at capacity after sweep\n if (cache.size >= MAX_PREFETCH_CACHE_SIZE) {\n const oldest = cache.keys().next().value;\n if (oldest !== undefined) {\n cache.delete(oldest);\n getPrefetchedUrls().delete(oldest);\n }\n }\n\n cache.set(rscUrl, { response, timestamp: now });\n}\n\n// Client navigation listeners\ntype NavigationListener = () => void;\nconst _listeners: Set<NavigationListener> = new Set();\n\nfunction notifyListeners(): void {\n for (const fn of _listeners) fn();\n}\n\n// Cached URLSearchParams, pathname, etc. for referential stability\n// useSyncExternalStore compares snapshots with Object.is — avoid creating\n// new instances on every render (infinite re-renders).\nlet _cachedSearch = !isServer ? window.location.search : \"\";\nlet _cachedReadonlySearchParams = new ReadonlyURLSearchParams(_cachedSearch);\nlet _cachedEmptyServerSearchParams: ReadonlyURLSearchParams | null = null;\nlet _cachedPathname = !isServer ? stripBasePath(window.location.pathname, __basePath) : \"/\";\n\nfunction getPathnameSnapshot(): string {\n const current = stripBasePath(window.location.pathname, __basePath);\n if (current !== _cachedPathname) {\n _cachedPathname = current;\n }\n return _cachedPathname;\n}\n\nfunction getSearchParamsSnapshot(): ReadonlyURLSearchParams {\n const current = window.location.search;\n if (current !== _cachedSearch) {\n _cachedSearch = current;\n _cachedReadonlySearchParams = new ReadonlyURLSearchParams(current);\n }\n return _cachedReadonlySearchParams;\n}\n\nfunction getServerSearchParamsSnapshot(): ReadonlyURLSearchParams {\n const ctx = _getServerContext() as NavigationContextWithReadonlyCache | null;\n if (ctx != null) {\n const searchParams = ctx.searchParams;\n if (ctx[_READONLY_SEARCH_PARAMS_SOURCE] !== searchParams) {\n ctx[_READONLY_SEARCH_PARAMS_SOURCE] = searchParams;\n ctx[_READONLY_SEARCH_PARAMS] = new ReadonlyURLSearchParams(searchParams);\n }\n return ctx[_READONLY_SEARCH_PARAMS]!;\n }\n if (_cachedEmptyServerSearchParams === null) {\n _cachedEmptyServerSearchParams = new ReadonlyURLSearchParams();\n }\n return _cachedEmptyServerSearchParams;\n}\n\n// Track client-side params (set during RSC hydration/navigation)\n// We cache the params object for referential stability — only create a new\n// object when the params actually change (shallow key/value comparison).\nconst _EMPTY_PARAMS: Record<string, string | string[]> = {};\nlet _clientParams: Record<string, string | string[]> = _EMPTY_PARAMS;\nlet _clientParamsJson = \"{}\";\n\nexport function setClientParams(params: Record<string, string | string[]>): void {\n const json = JSON.stringify(params);\n if (json !== _clientParamsJson) {\n _clientParams = params;\n _clientParamsJson = json;\n // Notify useSyncExternalStore subscribers so useParams() re-renders.\n notifyListeners();\n }\n}\n\n/** Get the current client params (for testing referential stability). */\nexport function getClientParams(): Record<string, string | string[]> {\n return _clientParams;\n}\n\nfunction getClientParamsSnapshot(): Record<string, string | string[]> {\n return _clientParams;\n}\n\nfunction getServerParamsSnapshot(): Record<string, string | string[]> {\n return _getServerContext()?.params ?? _EMPTY_PARAMS;\n}\n\nfunction subscribeToNavigation(cb: () => void): () => void {\n _listeners.add(cb);\n return () => {\n _listeners.delete(cb);\n };\n}\n\n// ---------------------------------------------------------------------------\n// Hooks\n// ---------------------------------------------------------------------------\n\n/**\n * Returns the current pathname.\n * Server: from request context. Client: from window.location.\n */\nexport function usePathname(): string {\n if (isServer) {\n // During SSR of \"use client\" components, the navigation context may not be set.\n // Return a safe fallback — the client will hydrate with the real value.\n return _getServerContext()?.pathname ?? \"/\";\n }\n // Client-side: use the hook system for reactivity\n return React.useSyncExternalStore(\n subscribeToNavigation,\n getPathnameSnapshot,\n () => _getServerContext()?.pathname ?? \"/\",\n );\n}\n\n/**\n * Returns the current search params as a read-only URLSearchParams.\n */\nexport function useSearchParams(): ReadonlyURLSearchParams {\n if (isServer) {\n // During SSR of \"use client\" components, the navigation context may not be set.\n // Return a safe fallback — the client will hydrate with the real value.\n return getServerSearchParamsSnapshot();\n }\n return React.useSyncExternalStore(\n subscribeToNavigation,\n getSearchParamsSnapshot,\n getServerSearchParamsSnapshot,\n );\n}\n\n/**\n * Returns the dynamic params for the current route.\n */\nexport function useParams<\n T extends Record<string, string | string[]> = Record<string, string | string[]>,\n>(): T {\n if (isServer) {\n // During SSR of \"use client\" components, the navigation context may not be set.\n return (_getServerContext()?.params ?? _EMPTY_PARAMS) as T;\n }\n return React.useSyncExternalStore(\n subscribeToNavigation,\n getClientParamsSnapshot as () => T,\n getServerParamsSnapshot as () => T,\n );\n}\n\n/**\n * Check if a href is an external URL (any URL scheme per RFC 3986, or protocol-relative).\n */\nfunction isExternalUrl(href: string): boolean {\n return /^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith(\"//\");\n}\n\n/**\n * Check if a href is only a hash change relative to the current URL.\n */\nfunction isHashOnlyChange(href: string): boolean {\n if (typeof window === \"undefined\") return false;\n if (href.startsWith(\"#\")) return true;\n try {\n const current = new URL(window.location.href);\n const next = new URL(href, window.location.href);\n return current.pathname === next.pathname && current.search === next.search && next.hash !== \"\";\n } catch {\n return false;\n }\n}\n\n/**\n * Scroll to a hash target element, or to the top if no hash.\n */\nfunction scrollToHash(hash: string): void {\n if (!hash || hash === \"#\") {\n window.scrollTo(0, 0);\n return;\n }\n const id = hash.slice(1);\n const element = document.getElementById(id);\n if (element) {\n element.scrollIntoView({ behavior: \"auto\" });\n }\n}\n\n/**\n * Reference to the native history.replaceState before patching.\n * Used internally to avoid triggering the interception for internal operations\n * (e.g. saving scroll position shouldn't cause re-renders).\n * Captured before the history method patching at the bottom of this module.\n */\nconst _nativeReplaceState: typeof window.history.replaceState | null = !isServer\n ? window.history.replaceState.bind(window.history)\n : null;\n\n/**\n * Save the current scroll position into the current history state.\n * Called before every navigation to enable scroll restoration on back/forward.\n *\n * Uses _nativeReplaceState to avoid triggering the history.replaceState\n * interception (which would cause spurious re-renders from notifyListeners).\n */\nfunction saveScrollPosition(): void {\n if (!_nativeReplaceState) return;\n const state = window.history.state ?? {};\n _nativeReplaceState.call(\n window.history,\n { ...state, __vinext_scrollX: window.scrollX, __vinext_scrollY: window.scrollY },\n \"\",\n );\n}\n\n/**\n * Restore scroll position from a history state object (used on popstate).\n *\n * When an RSC navigation is in flight (back/forward triggers both this\n * handler and the browser entry's popstate handler which calls\n * __VINEXT_RSC_NAVIGATE__), we must wait for the new content to render\n * before scrolling. Otherwise the user sees old content flash at the\n * restored scroll position.\n *\n * This handler fires before the browser entry's popstate handler (because\n * navigation.ts is loaded before hydration completes), so we defer via a\n * microtask to give the browser entry handler a chance to set\n * __VINEXT_RSC_PENDING__ first.\n */\nfunction restoreScrollPosition(state: unknown): void {\n if (state && typeof state === \"object\" && \"__vinext_scrollY\" in state) {\n const { __vinext_scrollX: x, __vinext_scrollY: y } = state as {\n __vinext_scrollX: number;\n __vinext_scrollY: number;\n };\n\n // Defer to allow other popstate listeners (browser entry) to run first\n // and set __VINEXT_RSC_PENDING__. Promise.resolve() schedules a microtask\n // that runs after all synchronous event listeners have completed.\n void Promise.resolve().then(() => {\n const pending: Promise<void> | null = window.__VINEXT_RSC_PENDING__ ?? null;\n\n if (pending) {\n // Wait for the RSC navigation to finish rendering, then scroll.\n void pending.then(() => {\n requestAnimationFrame(() => {\n window.scrollTo(x, y);\n });\n });\n } else {\n // No RSC navigation in flight (Pages Router or already settled).\n requestAnimationFrame(() => {\n window.scrollTo(x, y);\n });\n }\n });\n }\n}\n\n/**\n * Navigate to a URL, handling external URLs, hash-only changes, and RSC navigation.\n */\nasync function navigateImpl(\n href: string,\n mode: \"push\" | \"replace\",\n scroll: boolean,\n): Promise<void> {\n // Normalize same-origin absolute URLs to local paths for SPA navigation\n let normalizedHref = href;\n if (isExternalUrl(href)) {\n const localPath = toSameOriginAppPath(href, __basePath);\n if (localPath == null) {\n // Truly external: use full page navigation\n if (mode === \"replace\") {\n window.location.replace(href);\n } else {\n window.location.assign(href);\n }\n return;\n }\n normalizedHref = localPath;\n }\n\n const fullHref = toBrowserNavigationHref(normalizedHref, window.location.href, __basePath);\n\n // Save scroll position before navigating (for back/forward restoration)\n if (mode === \"push\") {\n saveScrollPosition();\n }\n\n // Hash-only change: update URL and scroll to target, skip RSC fetch\n if (isHashOnlyChange(fullHref)) {\n const hash = fullHref.includes(\"#\") ? fullHref.slice(fullHref.indexOf(\"#\")) : \"\";\n if (mode === \"replace\") {\n window.history.replaceState(null, \"\", fullHref);\n } else {\n window.history.pushState(null, \"\", fullHref);\n }\n notifyListeners();\n if (scroll) {\n scrollToHash(hash);\n }\n return;\n }\n\n // Extract hash for post-navigation scrolling\n const hashIdx = fullHref.indexOf(\"#\");\n const hash = hashIdx !== -1 ? fullHref.slice(hashIdx) : \"\";\n\n if (mode === \"replace\") {\n window.history.replaceState(null, \"\", fullHref);\n } else {\n window.history.pushState(null, \"\", fullHref);\n }\n notifyListeners();\n\n // Trigger RSC re-fetch if available, and wait for the new content to render\n // before scrolling. This prevents the old page from visibly jumping to the\n // top before the new content paints.\n if (typeof window.__VINEXT_RSC_NAVIGATE__ === \"function\") {\n await window.__VINEXT_RSC_NAVIGATE__(fullHref);\n }\n\n if (scroll) {\n if (hash) {\n scrollToHash(hash);\n } else {\n window.scrollTo(0, 0);\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// App Router router singleton\n//\n// All methods close over module-level state (navigateImpl, withBasePath, etc.)\n// and carry no per-render data, so the object can be created once and reused.\n// Next.js returns the same router reference on every call to useRouter(), which\n// matters for components that rely on referential equality (e.g. useMemo /\n// useEffect dependency arrays, React.memo bailouts).\n// ---------------------------------------------------------------------------\n\nconst _appRouter = {\n push(href: string, options?: { scroll?: boolean }): void {\n if (isServer) return;\n void navigateImpl(href, \"push\", options?.scroll !== false);\n },\n replace(href: string, options?: { scroll?: boolean }): void {\n if (isServer) return;\n void navigateImpl(href, \"replace\", options?.scroll !== false);\n },\n back(): void {\n if (isServer) return;\n window.history.back();\n },\n forward(): void {\n if (isServer) return;\n window.history.forward();\n },\n refresh(): void {\n if (isServer) return;\n // Re-fetch the current page's RSC stream\n if (typeof window.__VINEXT_RSC_NAVIGATE__ === \"function\") {\n void window.__VINEXT_RSC_NAVIGATE__(window.location.href);\n }\n },\n prefetch(href: string): void {\n if (isServer) return;\n // Prefetch the RSC payload for the target route and store in cache\n const fullHref = toBrowserNavigationHref(href, window.location.href, __basePath);\n const rscUrl = toRscUrl(fullHref);\n const prefetched = getPrefetchedUrls();\n if (prefetched.has(rscUrl)) return;\n prefetched.add(rscUrl);\n fetch(rscUrl, {\n headers: { Accept: \"text/x-component\" },\n credentials: \"include\",\n priority: \"low\" as RequestInit[\"priority\"],\n })\n .then((response) => {\n if (response.ok) {\n storePrefetchResponse(rscUrl, response);\n } else {\n // Non-ok response: allow retry on next prefetch() call\n prefetched.delete(rscUrl);\n }\n })\n .catch(() => {\n // Network error: allow retry on next prefetch() call\n prefetched.delete(rscUrl);\n });\n },\n};\n\n/**\n * App Router's useRouter — returns push/replace/back/forward/refresh.\n * Different from Pages Router's useRouter (next/router).\n *\n * Returns a stable singleton: the same object reference on every call,\n * matching Next.js behavior so components using referential equality\n * (e.g. useMemo / useEffect deps, React.memo) don't re-render unnecessarily.\n */\nexport function useRouter() {\n return _appRouter;\n}\n\n/**\n * Returns the active child segment one level below the layout where it's called.\n *\n * Returns the first segment from the route tree below this layout, including\n * route groups (e.g., \"(marketing)\") and resolved dynamic params. Returns null\n * if at the leaf (no child segments).\n *\n * @param parallelRoutesKey - Which parallel route to read (default: \"children\")\n */\nexport function useSelectedLayoutSegment(\n // parallelRoutesKey is accepted for API compat but not yet supported —\n // vinext doesn't implement parallel routes with separate segment tracking.\n _parallelRoutesKey?: string,\n): string | null {\n const segments = useSelectedLayoutSegments(_parallelRoutesKey);\n return segments.length > 0 ? segments[0] : null;\n}\n\n/**\n * Returns all active segments below the layout where it's called.\n *\n * Each layout in the App Router tree wraps its children with a\n * LayoutSegmentProvider whose value is the remaining route tree segments\n * (including route groups, with dynamic params resolved to actual values\n * and catch-all segments joined with \"/\"). This hook reads those segments\n * directly from context.\n *\n * @param parallelRoutesKey - Which parallel route to read (default: \"children\")\n */\nexport function useSelectedLayoutSegments(\n // parallelRoutesKey is accepted for API compat but not yet supported —\n // vinext doesn't implement parallel routes with separate segment tracking.\n _parallelRoutesKey?: string,\n): string[] {\n return useChildSegments();\n}\n\nexport { ReadonlyURLSearchParams };\n\n/**\n * useServerInsertedHTML — inject HTML during SSR from client components.\n *\n * Used by CSS-in-JS libraries (styled-components, emotion, StyleX) to inject\n * <style> tags during SSR so styles appear in the initial HTML (no FOUC).\n *\n * The callback is called once after each SSR render pass. The returned JSX/HTML\n * is serialized and injected into the HTML stream.\n *\n * Usage (in a \"use client\" component wrapping children):\n * useServerInsertedHTML(() => {\n * const styles = sheet.getStyleElement();\n * sheet.instance.clearTag();\n * return <>{styles}</>;\n * });\n */\n\nexport function useServerInsertedHTML(callback: () => unknown): void {\n if (typeof document !== \"undefined\") {\n // Client-side: no-op (styles are already in the DOM)\n return;\n }\n _getInsertedHTMLCallbacks().push(callback);\n}\n\n/**\n * Flush all collected useServerInsertedHTML callbacks.\n * Returns an array of results (React elements or strings).\n * Clears the callback list so the next render starts fresh.\n *\n * Called by the SSR entry after renderToReadableStream completes.\n */\nexport function flushServerInsertedHTML(): unknown[] {\n const callbacks = _getInsertedHTMLCallbacks();\n const results: unknown[] = [];\n for (const cb of callbacks) {\n try {\n const result = cb();\n if (result != null) results.push(result);\n } catch {\n // Ignore errors from individual callbacks\n }\n }\n callbacks.length = 0;\n return results;\n}\n\n/**\n * Clear all collected useServerInsertedHTML callbacks without flushing.\n * Used for cleanup between requests.\n */\nexport function clearServerInsertedHTML(): void {\n _clearInsertedHTMLCallbacks();\n}\n\n// ---------------------------------------------------------------------------\n// Non-hook utilities (can be called from Server Components)\n// ---------------------------------------------------------------------------\n\n/**\n * HTTP Access Fallback error code — shared prefix for notFound/forbidden/unauthorized.\n * Matches Next.js 16's unified error handling approach.\n */\nexport const HTTP_ERROR_FALLBACK_ERROR_CODE = \"NEXT_HTTP_ERROR_FALLBACK\";\n\n/**\n * Check if an error is an HTTP Access Fallback error (notFound, forbidden, unauthorized).\n */\nexport function isHTTPAccessFallbackError(error: unknown): boolean {\n if (error && typeof error === \"object\" && \"digest\" in error) {\n const digest = String((error as { digest: unknown }).digest);\n return (\n digest === \"NEXT_NOT_FOUND\" || // legacy compat\n digest.startsWith(`${HTTP_ERROR_FALLBACK_ERROR_CODE};`)\n );\n }\n return false;\n}\n\n/**\n * Extract the HTTP status code from an HTTP Access Fallback error.\n * Returns 404 for legacy NEXT_NOT_FOUND errors.\n */\nexport function getAccessFallbackHTTPStatus(error: unknown): number {\n if (error && typeof error === \"object\" && \"digest\" in error) {\n const digest = String((error as { digest: unknown }).digest);\n if (digest === \"NEXT_NOT_FOUND\") return 404;\n if (digest.startsWith(`${HTTP_ERROR_FALLBACK_ERROR_CODE};`)) {\n return parseInt(digest.split(\";\")[1], 10);\n }\n }\n return 404;\n}\n\n/**\n * Enum matching Next.js RedirectType for type-safe redirect calls.\n */\nexport enum RedirectType {\n push = \"push\",\n replace = \"replace\",\n}\n\n/**\n * Internal error class used by redirect/notFound/forbidden/unauthorized.\n * The `digest` field is the serialised control-flow signal read by the\n * framework's error boundary and server-side request handlers.\n */\nclass VinextNavigationError extends Error {\n readonly digest: string;\n constructor(message: string, digest: string) {\n super(message);\n this.digest = digest;\n }\n}\n\n/**\n * Throw a redirect. Caught by the framework to send a redirect response.\n */\nexport function redirect(url: string, type?: \"replace\" | \"push\" | RedirectType): never {\n throw new VinextNavigationError(\n `NEXT_REDIRECT:${url}`,\n `NEXT_REDIRECT;${type ?? \"replace\"};${encodeURIComponent(url)}`,\n );\n}\n\n/**\n * Trigger a permanent redirect (308).\n */\nexport function permanentRedirect(url: string): never {\n throw new VinextNavigationError(\n `NEXT_REDIRECT:${url}`,\n `NEXT_REDIRECT;replace;${encodeURIComponent(url)};308`,\n );\n}\n\n/**\n * Trigger a not-found response (404). Caught by the framework.\n */\nexport function notFound(): never {\n throw new VinextNavigationError(\"NEXT_NOT_FOUND\", `${HTTP_ERROR_FALLBACK_ERROR_CODE};404`);\n}\n\n/**\n * Trigger a forbidden response (403). Caught by the framework.\n * In Next.js, this is gated behind experimental.authInterrupts — we\n * support it unconditionally for maximum compatibility.\n */\nexport function forbidden(): never {\n throw new VinextNavigationError(\"NEXT_FORBIDDEN\", `${HTTP_ERROR_FALLBACK_ERROR_CODE};403`);\n}\n\n/**\n * Trigger an unauthorized response (401). Caught by the framework.\n * In Next.js, this is gated behind experimental.authInterrupts — we\n * support it unconditionally for maximum compatibility.\n */\nexport function unauthorized(): never {\n throw new VinextNavigationError(\"NEXT_UNAUTHORIZED\", `${HTTP_ERROR_FALLBACK_ERROR_CODE};401`);\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n// React hooks are imported at the top level via ESM.\n\n// Listen for popstate on the client\nif (!isServer) {\n window.addEventListener(\"popstate\", (event) => {\n notifyListeners();\n // Restore scroll position for back/forward navigation\n restoreScrollPosition(event.state);\n });\n\n // ---------------------------------------------------------------------------\n // history.pushState / replaceState interception (shallow routing)\n //\n // Next.js intercepts these native methods so that when user code calls\n // `window.history.pushState(null, '', '/new-path?filter=abc')` directly,\n // React hooks like usePathname() and useSearchParams() re-render with\n // the new URL. This is the foundation for shallow routing patterns\n // (filter UIs, tabs, URL search param state, etc.).\n //\n // We wrap the original methods, call through to the native implementation,\n // then notify our listener system so useSyncExternalStore picks up the\n // URL change.\n // ---------------------------------------------------------------------------\n const originalPushState = window.history.pushState.bind(window.history);\n const originalReplaceState = window.history.replaceState.bind(window.history);\n\n window.history.pushState = function patchedPushState(\n data: unknown,\n unused: string,\n url?: string | URL | null,\n ): void {\n originalPushState(data, unused, url);\n notifyListeners();\n };\n\n window.history.replaceState = function patchedReplaceState(\n data: unknown,\n unused: string,\n url?: string | URL | null,\n ): void {\n originalReplaceState(data, unused, url);\n notifyListeners();\n };\n}\n"],"mappings":";;;;;;;;;;;;AAyBA,MAAM,0BAA0B,OAAO,IAAI,8BAA8B;AACzE,MAAM,gCAAgC,OAAO,IAAI,mCAAmC;AAsBpF,SAAS,+BAEA;AACP,KAAI,OAAOA,QAAM,kBAAkB,WAAY,QAAO;CAEtD,MAAM,cAAc;AACpB,KAAI,CAAC,YAAY,+BACf,aAAY,iCAAiCA,QAAM,cAEjD,KAAK;AAGT,QAAO,YAAY,kCAAkC;;AAGvD,MAAa,4BAEF,8BAA8B;;;;;AAMzC,SAAgB,0BAA0D;AACxE,KAAI,OAAOA,QAAM,kBAAkB,WAAY,QAAO;CAEtD,MAAM,cAAc;AACpB,KAAI,CAAC,YAAY,yBACf,aAAY,2BAA2BA,QAAM,cAAwB,EAAE,CAAC;AAG1E,QAAO,YAAY,4BAA4B;;;;;;AAOjD,SAAS,mBAA6B;CACpC,MAAM,MAAM,yBAAyB;AACrC,KAAI,CAAC,IAAK,QAAO,EAAE;AAInB,KAAI;AACF,SAAOA,QAAM,WAAW,IAAI;SACtB;AACN,SAAO,EAAE;;;AAcb,MAAM,0BAA0B,OAAO,yCAAyC;AAChF,MAAM,iCAAiC,OAAO,+CAA+C;AAgB7F,IAAI,iBAA2C;AAC/C,IAAI,+BAAqD,EAAE;AAG3D,IAAI,0BAAoD;AACxD,IAAI,qBAAqB,QAAwC;AAC/D,kBAAiB;;AAE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C,MAAM;CACxC;CACA,YAAY,SAAiB,QAAgB;AAC3C,QAAM,QAAQ;AACd,OAAK,SAAS;;;;;;AAOlB,SAAgB,SAAS,KAAa,MAAiD;AACrF,OAAM,IAAI,sBACR,iBAAiB,OACjB,iBAAiB,QAAQ,UAAU,GAAG,mBAAmB,IAAI,GAC9D;;;;;AAMH,SAAgB,kBAAkB,KAAoB;AACpD,OAAM,IAAI,sBACR,iBAAiB,OACjB,yBAAyB,mBAAmB,IAAI,CAAC,MAClD;;;;;AAMH,SAAgB,WAAkB;AAChC,OAAM,IAAI,sBAAsB,kBAAkB,GAAG,+BAA+B,MAAM;;;;;;;AAQ5F,SAAgB,YAAmB;AACjC,OAAM,IAAI,sBAAsB,kBAAkB,GAAG,+BAA+B,MAAM;;;;;;;AAQ5F,SAAgB,eAAsB;AACpC,OAAM,IAAI,sBAAsB,qBAAqB,GAAG,+BAA+B,MAAM;;AAU/F,IAAI,CAAC,UAAU;AACb,QAAO,iBAAiB,aAAa,UAAU;AAC7C,mBAAiB;AAEjB,wBAAsB,MAAM,MAAM;GAClC;CAeF,MAAM,oBAAoB,OAAO,QAAQ,UAAU,KAAK,OAAO,QAAQ;CACvE,MAAM,uBAAuB,OAAO,QAAQ,aAAa,KAAK,OAAO,QAAQ;AAE7E,QAAO,QAAQ,YAAY,SAAS,iBAClC,MACA,QACA,KACM;AACN,oBAAkB,MAAM,QAAQ,IAAI;AACpC,mBAAiB;;AAGnB,QAAO,QAAQ,eAAe,SAAS,oBACrC,MACA,QACA,KACM;AACN,uBAAqB,MAAM,QAAQ,IAAI;AACvC,mBAAiB"}
1
+ {"version":3,"file":"navigation.js","names":["React"],"sources":["../../src/shims/navigation.ts"],"sourcesContent":["/**\n * next/navigation shim\n *\n * App Router navigation hooks. These work on both server (RSC) and client.\n * Server-side: reads from a request context set by the RSC handler.\n * Client-side: reads from browser Location API and provides navigation.\n */\n\n// Use namespace import for RSC safety: the react-server condition doesn't export\n// createContext/useContext/useSyncExternalStore as named exports, and strict ESM\n// would throw at link time for missing bindings. With `import * as React`, the\n// bindings are just `undefined` on the namespace object and we can guard at runtime.\nimport * as React from \"react\";\nimport { toBrowserNavigationHref, toSameOriginAppPath } from \"./url-utils.js\";\nimport { stripBasePath } from \"../utils/base-path.js\";\nimport { ReadonlyURLSearchParams } from \"./readonly-url-search-params.js\";\n\n// ─── Layout segment context ───────────────────────────────────────────────────\n// Stores the child segments below the current layout. Each layout wraps its\n// children with a provider whose value is the remaining route tree segments\n// (including route groups, with dynamic params resolved to actual values).\n// Created lazily because `React.createContext` is NOT available in the\n// react-server condition of React. In the RSC environment, this remains null.\n// The shared context lives behind a global singleton so provider/hook pairs\n// still line up if Vite loads this shim through multiple resolved module IDs.\nconst _LAYOUT_SEGMENT_CTX_KEY = Symbol.for(\"vinext.layoutSegmentContext\");\nconst _SERVER_INSERTED_HTML_CTX_KEY = Symbol.for(\"vinext.serverInsertedHTMLContext\");\ntype _LayoutSegmentGlobal = typeof globalThis & {\n [_LAYOUT_SEGMENT_CTX_KEY]?: React.Context<string[]> | null;\n [_SERVER_INSERTED_HTML_CTX_KEY]?: React.Context<\n ((callback: () => unknown) => void) | null\n > | null;\n};\n\n// ─── ServerInsertedHTML context ────────────────────────────────────────────────\n// Used by CSS-in-JS libraries (Apollo Client, styled-components, emotion) to\n// register HTML injection callbacks during SSR via useContext().\n// The SSR entry wraps the rendered tree with a Provider whose value is a\n// callback registration function (useServerInsertedHTML).\n//\n// In Next.js, ServerInsertedHTMLContext holds a function:\n// (callback: () => React.ReactNode) => void\n// Libraries call useContext(ServerInsertedHTMLContext) to get this function,\n// then call it to register callbacks that inject HTML during SSR.\n//\n// Created eagerly at module load time. In the RSC environment (react-server\n// condition), createContext isn't available so this will be null.\n\nfunction getServerInsertedHTMLContext(): React.Context<\n ((callback: () => unknown) => void) | null\n> | null {\n if (typeof React.createContext !== \"function\") return null;\n\n const globalState = globalThis as _LayoutSegmentGlobal;\n if (!globalState[_SERVER_INSERTED_HTML_CTX_KEY]) {\n globalState[_SERVER_INSERTED_HTML_CTX_KEY] = React.createContext<\n ((callback: () => unknown) => void) | null\n >(null);\n }\n\n return globalState[_SERVER_INSERTED_HTML_CTX_KEY] ?? null;\n}\n\nexport const ServerInsertedHTMLContext: React.Context<\n ((callback: () => unknown) => void) | null\n> | null = getServerInsertedHTMLContext();\n\n/**\n * Get or create the layout segment context.\n * Returns null in the RSC environment (createContext unavailable).\n */\nexport function getLayoutSegmentContext(): React.Context<string[]> | null {\n if (typeof React.createContext !== \"function\") return null;\n\n const globalState = globalThis as _LayoutSegmentGlobal;\n if (!globalState[_LAYOUT_SEGMENT_CTX_KEY]) {\n globalState[_LAYOUT_SEGMENT_CTX_KEY] = React.createContext<string[]>([]);\n }\n\n return globalState[_LAYOUT_SEGMENT_CTX_KEY] ?? null;\n}\n\n/**\n * Read the child segments below the current layout from context.\n * Returns [] if no context is available (RSC environment, outside React tree).\n */\nfunction useChildSegments(): string[] {\n const ctx = getLayoutSegmentContext();\n if (!ctx) return [];\n // useContext is safe here because if createContext exists, useContext does too.\n // This branch is only taken in SSR/Browser, never in RSC.\n // Try/catch for unit tests that call this hook outside a React render tree.\n try {\n return React.useContext(ctx);\n } catch {\n return [];\n }\n}\n\n// ---------------------------------------------------------------------------\n// Server-side request context (set by the RSC entry before rendering)\n// ---------------------------------------------------------------------------\n\nexport interface NavigationContext {\n pathname: string;\n searchParams: URLSearchParams;\n params: Record<string, string | string[]>;\n}\n\nconst _READONLY_SEARCH_PARAMS = Symbol(\"vinext.navigation.readonlySearchParams\");\nconst _READONLY_SEARCH_PARAMS_SOURCE = Symbol(\"vinext.navigation.readonlySearchParamsSource\");\n\ntype NavigationContextWithReadonlyCache = NavigationContext & {\n [_READONLY_SEARCH_PARAMS]?: ReadonlyURLSearchParams;\n [_READONLY_SEARCH_PARAMS_SOURCE]?: URLSearchParams;\n};\n\n// ---------------------------------------------------------------------------\n// Server-side navigation state lives in a separate server-only module\n// (navigation-state.ts) that uses AsyncLocalStorage for request isolation.\n// This module is bundled for the browser, so it can't import node:async_hooks.\n//\n// On the server: state functions are set by navigation-state.ts at import time.\n// On the client: _serverContext falls back to null (hooks use window instead).\n//\n// Global accessor pattern (issue #688):\n// Vite's multi-environment dev mode can create separate module instances of\n// this file for the SSR entry vs \"use client\" components. When that happens,\n// _registerStateAccessors only updates the SSR entry's instance, leaving the\n// \"use client\" instance with the default (null) fallbacks.\n//\n// To fix this, navigation-state.ts also stores the accessors on globalThis\n// via Symbol.for, and the defaults here check for that global before falling\n// back to module-level state. This ensures all module instances can reach the\n// ALS-backed state regardless of which instance was registered.\n// ---------------------------------------------------------------------------\n\ninterface _StateAccessors {\n getServerContext: () => NavigationContext | null;\n setServerContext: (ctx: NavigationContext | null) => void;\n getInsertedHTMLCallbacks: () => Array<() => unknown>;\n clearInsertedHTMLCallbacks: () => void;\n}\n\nexport const GLOBAL_ACCESSORS_KEY = Symbol.for(\"vinext.navigation.globalAccessors\");\nconst _GLOBAL_ACCESSORS_KEY = GLOBAL_ACCESSORS_KEY;\ntype _GlobalWithAccessors = typeof globalThis & { [_GLOBAL_ACCESSORS_KEY]?: _StateAccessors };\n\nfunction _getGlobalAccessors(): _StateAccessors | undefined {\n return (globalThis as _GlobalWithAccessors)[_GLOBAL_ACCESSORS_KEY];\n}\n\nlet _serverContext: NavigationContext | null = null;\nlet _serverInsertedHTMLCallbacks: Array<() => unknown> = [];\n\n// These are overridden by navigation-state.ts on the server to use ALS.\n// The defaults check globalThis for cross-module-instance access (issue #688).\nlet _getServerContext = (): NavigationContext | null => {\n const g = _getGlobalAccessors();\n return g ? g.getServerContext() : _serverContext;\n};\nlet _setServerContext = (ctx: NavigationContext | null): void => {\n const g = _getGlobalAccessors();\n if (g) {\n g.setServerContext(ctx);\n } else {\n _serverContext = ctx;\n }\n};\nlet _getInsertedHTMLCallbacks = (): Array<() => unknown> => {\n const g = _getGlobalAccessors();\n return g ? g.getInsertedHTMLCallbacks() : _serverInsertedHTMLCallbacks;\n};\nlet _clearInsertedHTMLCallbacks = (): void => {\n const g = _getGlobalAccessors();\n if (g) {\n g.clearInsertedHTMLCallbacks();\n } else {\n _serverInsertedHTMLCallbacks = [];\n }\n};\n\n/**\n * Register ALS-backed state accessors. Called by navigation-state.ts on import.\n * @internal\n */\nexport function _registerStateAccessors(accessors: _StateAccessors): void {\n _getServerContext = accessors.getServerContext;\n _setServerContext = accessors.setServerContext;\n _getInsertedHTMLCallbacks = accessors.getInsertedHTMLCallbacks;\n _clearInsertedHTMLCallbacks = accessors.clearInsertedHTMLCallbacks;\n}\n\n/**\n * Get the navigation context for the current SSR/RSC render.\n * Reads from AsyncLocalStorage when available (concurrent-safe),\n * otherwise falls back to module-level state.\n */\nexport function getNavigationContext(): NavigationContext | null {\n return _getServerContext();\n}\n\n/**\n * Set the navigation context for the current SSR/RSC render.\n * Called by the framework entry before rendering each request.\n */\nexport function setNavigationContext(ctx: NavigationContext | null): void {\n _setServerContext(ctx);\n}\n\n// ---------------------------------------------------------------------------\n// Client-side state\n// ---------------------------------------------------------------------------\n\nconst isServer = typeof window === \"undefined\";\n\n/** basePath from next.config.js, injected by the plugin at build time */\nconst __basePath: string = process.env.__NEXT_ROUTER_BASEPATH ?? \"\";\n\n// ---------------------------------------------------------------------------\n// RSC prefetch cache utilities (shared between link.tsx and browser entry)\n// ---------------------------------------------------------------------------\n\n/** Maximum number of entries in the RSC prefetch cache. */\nexport const MAX_PREFETCH_CACHE_SIZE = 50;\n\n/** TTL for prefetch cache entries in ms (matches Next.js static prefetch TTL). */\nexport const PREFETCH_CACHE_TTL = 30_000;\n\nexport interface PrefetchCacheEntry {\n response: Response;\n timestamp: number;\n}\n\n/**\n * Convert a pathname (with optional query/hash) to its .rsc URL.\n * Strips trailing slashes before appending `.rsc` so that cache keys\n * are consistent regardless of the `trailingSlash` config setting.\n */\nexport function toRscUrl(href: string): string {\n const [beforeHash] = href.split(\"#\");\n const qIdx = beforeHash.indexOf(\"?\");\n const pathname = qIdx === -1 ? beforeHash : beforeHash.slice(0, qIdx);\n const query = qIdx === -1 ? \"\" : beforeHash.slice(qIdx);\n // Strip trailing slash (but preserve \"/\" root) for consistent cache keys\n const normalizedPath =\n pathname.length > 1 && pathname.endsWith(\"/\") ? pathname.slice(0, -1) : pathname;\n return normalizedPath + \".rsc\" + query;\n}\n\n/** Get or create the shared in-memory RSC prefetch cache on window. */\nexport function getPrefetchCache(): Map<string, PrefetchCacheEntry> {\n if (isServer) return new Map();\n if (!window.__VINEXT_RSC_PREFETCH_CACHE__) {\n window.__VINEXT_RSC_PREFETCH_CACHE__ = new Map<string, PrefetchCacheEntry>();\n }\n return window.__VINEXT_RSC_PREFETCH_CACHE__;\n}\n\n/**\n * Get or create the shared set of already-prefetched RSC URLs on window.\n * Keyed by rscUrl so that the browser entry can clear entries when consumed.\n */\nexport function getPrefetchedUrls(): Set<string> {\n if (isServer) return new Set();\n if (!window.__VINEXT_RSC_PREFETCHED_URLS__) {\n window.__VINEXT_RSC_PREFETCHED_URLS__ = new Set<string>();\n }\n return window.__VINEXT_RSC_PREFETCHED_URLS__;\n}\n\n/**\n * Store a prefetched RSC response in the cache.\n * Enforces a maximum cache size to prevent unbounded memory growth on\n * link-heavy pages.\n */\nexport function storePrefetchResponse(rscUrl: string, response: Response): void {\n const cache = getPrefetchCache();\n const now = Date.now();\n\n // Sweep expired entries before resorting to FIFO eviction\n if (cache.size >= MAX_PREFETCH_CACHE_SIZE) {\n const prefetched = getPrefetchedUrls();\n for (const [key, entry] of cache) {\n if (now - entry.timestamp >= PREFETCH_CACHE_TTL) {\n cache.delete(key);\n prefetched.delete(key);\n }\n }\n }\n\n // FIFO fallback if still at capacity after sweep\n if (cache.size >= MAX_PREFETCH_CACHE_SIZE) {\n const oldest = cache.keys().next().value;\n if (oldest !== undefined) {\n cache.delete(oldest);\n getPrefetchedUrls().delete(oldest);\n }\n }\n\n cache.set(rscUrl, { response, timestamp: now });\n}\n\n// Client navigation listeners\ntype NavigationListener = () => void;\nconst _listeners: Set<NavigationListener> = new Set();\n\nfunction notifyListeners(): void {\n for (const fn of _listeners) fn();\n}\n\n// Cached URLSearchParams, pathname, etc. for referential stability\n// useSyncExternalStore compares snapshots with Object.is — avoid creating\n// new instances on every render (infinite re-renders).\nlet _cachedSearch = !isServer ? window.location.search : \"\";\nlet _cachedReadonlySearchParams = new ReadonlyURLSearchParams(_cachedSearch);\nlet _cachedEmptyServerSearchParams: ReadonlyURLSearchParams | null = null;\nlet _cachedPathname = !isServer ? stripBasePath(window.location.pathname, __basePath) : \"/\";\n\nfunction getPathnameSnapshot(): string {\n const current = stripBasePath(window.location.pathname, __basePath);\n if (current !== _cachedPathname) {\n _cachedPathname = current;\n }\n return _cachedPathname;\n}\n\nfunction getSearchParamsSnapshot(): ReadonlyURLSearchParams {\n const current = window.location.search;\n if (current !== _cachedSearch) {\n _cachedSearch = current;\n _cachedReadonlySearchParams = new ReadonlyURLSearchParams(current);\n }\n return _cachedReadonlySearchParams;\n}\n\nfunction getServerSearchParamsSnapshot(): ReadonlyURLSearchParams {\n const ctx = _getServerContext() as NavigationContextWithReadonlyCache | null;\n if (ctx != null) {\n const searchParams = ctx.searchParams;\n if (ctx[_READONLY_SEARCH_PARAMS_SOURCE] !== searchParams) {\n ctx[_READONLY_SEARCH_PARAMS_SOURCE] = searchParams;\n ctx[_READONLY_SEARCH_PARAMS] = new ReadonlyURLSearchParams(searchParams);\n }\n return ctx[_READONLY_SEARCH_PARAMS]!;\n }\n if (_cachedEmptyServerSearchParams === null) {\n _cachedEmptyServerSearchParams = new ReadonlyURLSearchParams();\n }\n return _cachedEmptyServerSearchParams;\n}\n\n// Track client-side params (set during RSC hydration/navigation)\n// We cache the params object for referential stability — only create a new\n// object when the params actually change (shallow key/value comparison).\nconst _EMPTY_PARAMS: Record<string, string | string[]> = {};\nlet _clientParams: Record<string, string | string[]> = _EMPTY_PARAMS;\nlet _clientParamsJson = \"{}\";\n\nexport function setClientParams(params: Record<string, string | string[]>): void {\n const json = JSON.stringify(params);\n if (json !== _clientParamsJson) {\n _clientParams = params;\n _clientParamsJson = json;\n // Notify useSyncExternalStore subscribers so useParams() re-renders.\n notifyListeners();\n }\n}\n\n/** Get the current client params (for testing referential stability). */\nexport function getClientParams(): Record<string, string | string[]> {\n return _clientParams;\n}\n\nfunction getClientParamsSnapshot(): Record<string, string | string[]> {\n return _clientParams;\n}\n\nfunction getServerParamsSnapshot(): Record<string, string | string[]> {\n return _getServerContext()?.params ?? _EMPTY_PARAMS;\n}\n\nfunction subscribeToNavigation(cb: () => void): () => void {\n _listeners.add(cb);\n return () => {\n _listeners.delete(cb);\n };\n}\n\n// ---------------------------------------------------------------------------\n// Hooks\n// ---------------------------------------------------------------------------\n\n/**\n * Returns the current pathname.\n * Server: from request context. Client: from window.location.\n */\nexport function usePathname(): string {\n if (isServer) {\n // During SSR of \"use client\" components, the navigation context may not be set.\n // Return a safe fallback — the client will hydrate with the real value.\n return _getServerContext()?.pathname ?? \"/\";\n }\n // Client-side: use the hook system for reactivity\n return React.useSyncExternalStore(\n subscribeToNavigation,\n getPathnameSnapshot,\n () => _getServerContext()?.pathname ?? \"/\",\n );\n}\n\n/**\n * Returns the current search params as a read-only URLSearchParams.\n */\nexport function useSearchParams(): ReadonlyURLSearchParams {\n if (isServer) {\n // During SSR of \"use client\" components, the navigation context may not be set.\n // Return a safe fallback — the client will hydrate with the real value.\n return getServerSearchParamsSnapshot();\n }\n return React.useSyncExternalStore(\n subscribeToNavigation,\n getSearchParamsSnapshot,\n getServerSearchParamsSnapshot,\n );\n}\n\n/**\n * Returns the dynamic params for the current route.\n */\nexport function useParams<\n T extends Record<string, string | string[]> = Record<string, string | string[]>,\n>(): T {\n if (isServer) {\n // During SSR of \"use client\" components, the navigation context may not be set.\n return (_getServerContext()?.params ?? _EMPTY_PARAMS) as T;\n }\n return React.useSyncExternalStore(\n subscribeToNavigation,\n getClientParamsSnapshot as () => T,\n getServerParamsSnapshot as () => T,\n );\n}\n\n/**\n * Check if a href is an external URL (any URL scheme per RFC 3986, or protocol-relative).\n */\nfunction isExternalUrl(href: string): boolean {\n return /^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith(\"//\");\n}\n\n/**\n * Check if a href is only a hash change relative to the current URL.\n */\nfunction isHashOnlyChange(href: string): boolean {\n if (typeof window === \"undefined\") return false;\n if (href.startsWith(\"#\")) return true;\n try {\n const current = new URL(window.location.href);\n const next = new URL(href, window.location.href);\n return current.pathname === next.pathname && current.search === next.search && next.hash !== \"\";\n } catch {\n return false;\n }\n}\n\n/**\n * Scroll to a hash target element, or to the top if no hash.\n */\nfunction scrollToHash(hash: string): void {\n if (!hash || hash === \"#\") {\n window.scrollTo(0, 0);\n return;\n }\n const id = hash.slice(1);\n const element = document.getElementById(id);\n if (element) {\n element.scrollIntoView({ behavior: \"auto\" });\n }\n}\n\n/**\n * Reference to the native history.replaceState before patching.\n * Used internally to avoid triggering the interception for internal operations\n * (e.g. saving scroll position shouldn't cause re-renders).\n * Captured before the history method patching at the bottom of this module.\n */\nconst _nativeReplaceState: typeof window.history.replaceState | null = !isServer\n ? window.history.replaceState.bind(window.history)\n : null;\n\n/**\n * Save the current scroll position into the current history state.\n * Called before every navigation to enable scroll restoration on back/forward.\n *\n * Uses _nativeReplaceState to avoid triggering the history.replaceState\n * interception (which would cause spurious re-renders from notifyListeners).\n */\nfunction saveScrollPosition(): void {\n if (!_nativeReplaceState) return;\n const state = window.history.state ?? {};\n _nativeReplaceState.call(\n window.history,\n { ...state, __vinext_scrollX: window.scrollX, __vinext_scrollY: window.scrollY },\n \"\",\n );\n}\n\n/**\n * Restore scroll position from a history state object (used on popstate).\n *\n * When an RSC navigation is in flight (back/forward triggers both this\n * handler and the browser entry's popstate handler which calls\n * __VINEXT_RSC_NAVIGATE__), we must wait for the new content to render\n * before scrolling. Otherwise the user sees old content flash at the\n * restored scroll position.\n *\n * This handler fires before the browser entry's popstate handler (because\n * navigation.ts is loaded before hydration completes), so we defer via a\n * microtask to give the browser entry handler a chance to set\n * __VINEXT_RSC_PENDING__ first.\n */\nfunction restoreScrollPosition(state: unknown): void {\n if (state && typeof state === \"object\" && \"__vinext_scrollY\" in state) {\n const { __vinext_scrollX: x, __vinext_scrollY: y } = state as {\n __vinext_scrollX: number;\n __vinext_scrollY: number;\n };\n\n // Defer to allow other popstate listeners (browser entry) to run first\n // and set __VINEXT_RSC_PENDING__. Promise.resolve() schedules a microtask\n // that runs after all synchronous event listeners have completed.\n void Promise.resolve().then(() => {\n const pending: Promise<void> | null = window.__VINEXT_RSC_PENDING__ ?? null;\n\n if (pending) {\n // Wait for the RSC navigation to finish rendering, then scroll.\n void pending.then(() => {\n requestAnimationFrame(() => {\n window.scrollTo(x, y);\n });\n });\n } else {\n // No RSC navigation in flight (Pages Router or already settled).\n requestAnimationFrame(() => {\n window.scrollTo(x, y);\n });\n }\n });\n }\n}\n\n/**\n * Navigate to a URL, handling external URLs, hash-only changes, and RSC navigation.\n */\nasync function navigateImpl(\n href: string,\n mode: \"push\" | \"replace\",\n scroll: boolean,\n): Promise<void> {\n // Normalize same-origin absolute URLs to local paths for SPA navigation\n let normalizedHref = href;\n if (isExternalUrl(href)) {\n const localPath = toSameOriginAppPath(href, __basePath);\n if (localPath == null) {\n // Truly external: use full page navigation\n if (mode === \"replace\") {\n window.location.replace(href);\n } else {\n window.location.assign(href);\n }\n return;\n }\n normalizedHref = localPath;\n }\n\n const fullHref = toBrowserNavigationHref(normalizedHref, window.location.href, __basePath);\n\n // Save scroll position before navigating (for back/forward restoration)\n if (mode === \"push\") {\n saveScrollPosition();\n }\n\n // Hash-only change: update URL and scroll to target, skip RSC fetch\n if (isHashOnlyChange(fullHref)) {\n const hash = fullHref.includes(\"#\") ? fullHref.slice(fullHref.indexOf(\"#\")) : \"\";\n if (mode === \"replace\") {\n window.history.replaceState(null, \"\", fullHref);\n } else {\n window.history.pushState(null, \"\", fullHref);\n }\n notifyListeners();\n if (scroll) {\n scrollToHash(hash);\n }\n return;\n }\n\n // Extract hash for post-navigation scrolling\n const hashIdx = fullHref.indexOf(\"#\");\n const hash = hashIdx !== -1 ? fullHref.slice(hashIdx) : \"\";\n\n if (mode === \"replace\") {\n window.history.replaceState(null, \"\", fullHref);\n } else {\n window.history.pushState(null, \"\", fullHref);\n }\n notifyListeners();\n\n // Trigger RSC re-fetch if available, and wait for the new content to render\n // before scrolling. This prevents the old page from visibly jumping to the\n // top before the new content paints.\n if (typeof window.__VINEXT_RSC_NAVIGATE__ === \"function\") {\n await window.__VINEXT_RSC_NAVIGATE__(fullHref);\n }\n\n if (scroll) {\n if (hash) {\n scrollToHash(hash);\n } else {\n window.scrollTo(0, 0);\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// App Router router singleton\n//\n// All methods close over module-level state (navigateImpl, withBasePath, etc.)\n// and carry no per-render data, so the object can be created once and reused.\n// Next.js returns the same router reference on every call to useRouter(), which\n// matters for components that rely on referential equality (e.g. useMemo /\n// useEffect dependency arrays, React.memo bailouts).\n// ---------------------------------------------------------------------------\n\nconst _appRouter = {\n push(href: string, options?: { scroll?: boolean }): void {\n if (isServer) return;\n void navigateImpl(href, \"push\", options?.scroll !== false);\n },\n replace(href: string, options?: { scroll?: boolean }): void {\n if (isServer) return;\n void navigateImpl(href, \"replace\", options?.scroll !== false);\n },\n back(): void {\n if (isServer) return;\n window.history.back();\n },\n forward(): void {\n if (isServer) return;\n window.history.forward();\n },\n refresh(): void {\n if (isServer) return;\n // Re-fetch the current page's RSC stream\n if (typeof window.__VINEXT_RSC_NAVIGATE__ === \"function\") {\n void window.__VINEXT_RSC_NAVIGATE__(window.location.href);\n }\n },\n prefetch(href: string): void {\n if (isServer) return;\n // Prefetch the RSC payload for the target route and store in cache\n const fullHref = toBrowserNavigationHref(href, window.location.href, __basePath);\n const rscUrl = toRscUrl(fullHref);\n const prefetched = getPrefetchedUrls();\n if (prefetched.has(rscUrl)) return;\n prefetched.add(rscUrl);\n fetch(rscUrl, {\n headers: { Accept: \"text/x-component\" },\n credentials: \"include\",\n priority: \"low\" as RequestInit[\"priority\"],\n })\n .then((response) => {\n if (response.ok) {\n storePrefetchResponse(rscUrl, response);\n } else {\n // Non-ok response: allow retry on next prefetch() call\n prefetched.delete(rscUrl);\n }\n })\n .catch(() => {\n // Network error: allow retry on next prefetch() call\n prefetched.delete(rscUrl);\n });\n },\n};\n\n/**\n * App Router's useRouter — returns push/replace/back/forward/refresh.\n * Different from Pages Router's useRouter (next/router).\n *\n * Returns a stable singleton: the same object reference on every call,\n * matching Next.js behavior so components using referential equality\n * (e.g. useMemo / useEffect deps, React.memo) don't re-render unnecessarily.\n */\nexport function useRouter() {\n return _appRouter;\n}\n\n/**\n * Returns the active child segment one level below the layout where it's called.\n *\n * Returns the first segment from the route tree below this layout, including\n * route groups (e.g., \"(marketing)\") and resolved dynamic params. Returns null\n * if at the leaf (no child segments).\n *\n * @param parallelRoutesKey - Which parallel route to read (default: \"children\")\n */\nexport function useSelectedLayoutSegment(\n // parallelRoutesKey is accepted for API compat but not yet supported —\n // vinext doesn't implement parallel routes with separate segment tracking.\n _parallelRoutesKey?: string,\n): string | null {\n const segments = useSelectedLayoutSegments(_parallelRoutesKey);\n return segments.length > 0 ? segments[0] : null;\n}\n\n/**\n * Returns all active segments below the layout where it's called.\n *\n * Each layout in the App Router tree wraps its children with a\n * LayoutSegmentProvider whose value is the remaining route tree segments\n * (including route groups, with dynamic params resolved to actual values\n * and catch-all segments joined with \"/\"). This hook reads those segments\n * directly from context.\n *\n * @param parallelRoutesKey - Which parallel route to read (default: \"children\")\n */\nexport function useSelectedLayoutSegments(\n // parallelRoutesKey is accepted for API compat but not yet supported —\n // vinext doesn't implement parallel routes with separate segment tracking.\n _parallelRoutesKey?: string,\n): string[] {\n return useChildSegments();\n}\n\nexport { ReadonlyURLSearchParams };\n\n/**\n * useServerInsertedHTML — inject HTML during SSR from client components.\n *\n * Used by CSS-in-JS libraries (styled-components, emotion, StyleX) to inject\n * <style> tags during SSR so styles appear in the initial HTML (no FOUC).\n *\n * The callback is called once after each SSR render pass. The returned JSX/HTML\n * is serialized and injected into the HTML stream.\n *\n * Usage (in a \"use client\" component wrapping children):\n * useServerInsertedHTML(() => {\n * const styles = sheet.getStyleElement();\n * sheet.instance.clearTag();\n * return <>{styles}</>;\n * });\n */\n\nexport function useServerInsertedHTML(callback: () => unknown): void {\n if (typeof document !== \"undefined\") {\n // Client-side: no-op (styles are already in the DOM)\n return;\n }\n _getInsertedHTMLCallbacks().push(callback);\n}\n\n/**\n * Flush all collected useServerInsertedHTML callbacks.\n * Returns an array of results (React elements or strings).\n * Clears the callback list so the next render starts fresh.\n *\n * Called by the SSR entry after renderToReadableStream completes.\n */\nexport function flushServerInsertedHTML(): unknown[] {\n const callbacks = _getInsertedHTMLCallbacks();\n const results: unknown[] = [];\n for (const cb of callbacks) {\n try {\n const result = cb();\n if (result != null) results.push(result);\n } catch {\n // Ignore errors from individual callbacks\n }\n }\n callbacks.length = 0;\n return results;\n}\n\n/**\n * Clear all collected useServerInsertedHTML callbacks without flushing.\n * Used for cleanup between requests.\n */\nexport function clearServerInsertedHTML(): void {\n _clearInsertedHTMLCallbacks();\n}\n\n// ---------------------------------------------------------------------------\n// Non-hook utilities (can be called from Server Components)\n// ---------------------------------------------------------------------------\n\n/**\n * HTTP Access Fallback error code — shared prefix for notFound/forbidden/unauthorized.\n * Matches Next.js 16's unified error handling approach.\n */\nexport const HTTP_ERROR_FALLBACK_ERROR_CODE = \"NEXT_HTTP_ERROR_FALLBACK\";\n\n/**\n * Check if an error is an HTTP Access Fallback error (notFound, forbidden, unauthorized).\n */\nexport function isHTTPAccessFallbackError(error: unknown): boolean {\n if (error && typeof error === \"object\" && \"digest\" in error) {\n const digest = String((error as { digest: unknown }).digest);\n return (\n digest === \"NEXT_NOT_FOUND\" || // legacy compat\n digest.startsWith(`${HTTP_ERROR_FALLBACK_ERROR_CODE};`)\n );\n }\n return false;\n}\n\n/**\n * Extract the HTTP status code from an HTTP Access Fallback error.\n * Returns 404 for legacy NEXT_NOT_FOUND errors.\n */\nexport function getAccessFallbackHTTPStatus(error: unknown): number {\n if (error && typeof error === \"object\" && \"digest\" in error) {\n const digest = String((error as { digest: unknown }).digest);\n if (digest === \"NEXT_NOT_FOUND\") return 404;\n if (digest.startsWith(`${HTTP_ERROR_FALLBACK_ERROR_CODE};`)) {\n return parseInt(digest.split(\";\")[1], 10);\n }\n }\n return 404;\n}\n\n/**\n * Enum matching Next.js RedirectType for type-safe redirect calls.\n */\nexport enum RedirectType {\n push = \"push\",\n replace = \"replace\",\n}\n\n/**\n * Internal error class used by redirect/notFound/forbidden/unauthorized.\n * The `digest` field is the serialised control-flow signal read by the\n * framework's error boundary and server-side request handlers.\n */\nclass VinextNavigationError extends Error {\n readonly digest: string;\n constructor(message: string, digest: string) {\n super(message);\n this.digest = digest;\n }\n}\n\n/**\n * Throw a redirect. Caught by the framework to send a redirect response.\n */\nexport function redirect(url: string, type?: \"replace\" | \"push\" | RedirectType): never {\n throw new VinextNavigationError(\n `NEXT_REDIRECT:${url}`,\n `NEXT_REDIRECT;${type ?? \"replace\"};${encodeURIComponent(url)}`,\n );\n}\n\n/**\n * Trigger a permanent redirect (308).\n */\nexport function permanentRedirect(url: string): never {\n throw new VinextNavigationError(\n `NEXT_REDIRECT:${url}`,\n `NEXT_REDIRECT;replace;${encodeURIComponent(url)};308`,\n );\n}\n\n/**\n * Trigger a not-found response (404). Caught by the framework.\n */\nexport function notFound(): never {\n throw new VinextNavigationError(\"NEXT_NOT_FOUND\", `${HTTP_ERROR_FALLBACK_ERROR_CODE};404`);\n}\n\n/**\n * Trigger a forbidden response (403). Caught by the framework.\n * In Next.js, this is gated behind experimental.authInterrupts — we\n * support it unconditionally for maximum compatibility.\n */\nexport function forbidden(): never {\n throw new VinextNavigationError(\"NEXT_FORBIDDEN\", `${HTTP_ERROR_FALLBACK_ERROR_CODE};403`);\n}\n\n/**\n * Trigger an unauthorized response (401). Caught by the framework.\n * In Next.js, this is gated behind experimental.authInterrupts — we\n * support it unconditionally for maximum compatibility.\n */\nexport function unauthorized(): never {\n throw new VinextNavigationError(\"NEXT_UNAUTHORIZED\", `${HTTP_ERROR_FALLBACK_ERROR_CODE};401`);\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n// React hooks are imported at the top level via ESM.\n\n// Listen for popstate on the client\nif (!isServer) {\n window.addEventListener(\"popstate\", (event) => {\n notifyListeners();\n // Restore scroll position for back/forward navigation\n restoreScrollPosition(event.state);\n });\n\n // ---------------------------------------------------------------------------\n // history.pushState / replaceState interception (shallow routing)\n //\n // Next.js intercepts these native methods so that when user code calls\n // `window.history.pushState(null, '', '/new-path?filter=abc')` directly,\n // React hooks like usePathname() and useSearchParams() re-render with\n // the new URL. This is the foundation for shallow routing patterns\n // (filter UIs, tabs, URL search param state, etc.).\n //\n // We wrap the original methods, call through to the native implementation,\n // then notify our listener system so useSyncExternalStore picks up the\n // URL change.\n // ---------------------------------------------------------------------------\n const originalPushState = window.history.pushState.bind(window.history);\n const originalReplaceState = window.history.replaceState.bind(window.history);\n\n window.history.pushState = function patchedPushState(\n data: unknown,\n unused: string,\n url?: string | URL | null,\n ): void {\n originalPushState(data, unused, url);\n notifyListeners();\n };\n\n window.history.replaceState = function patchedReplaceState(\n data: unknown,\n unused: string,\n url?: string | URL | null,\n ): void {\n originalReplaceState(data, unused, url);\n notifyListeners();\n };\n}\n"],"mappings":";;;;;;;;;;;;AAyBA,MAAM,0BAA0B,OAAO,IAAI,8BAA8B;AACzE,MAAM,gCAAgC,OAAO,IAAI,mCAAmC;AAsBpF,SAAS,+BAEA;AACP,KAAI,OAAOA,QAAM,kBAAkB,WAAY,QAAO;CAEtD,MAAM,cAAc;AACpB,KAAI,CAAC,YAAY,+BACf,aAAY,iCAAiCA,QAAM,cAEjD,KAAK;AAGT,QAAO,YAAY,kCAAkC;;AAGvD,MAAa,4BAEF,8BAA8B;;;;;AAMzC,SAAgB,0BAA0D;AACxE,KAAI,OAAOA,QAAM,kBAAkB,WAAY,QAAO;CAEtD,MAAM,cA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AgB,YAAmB;AACjC,OAAM,IAAI,sBAAsB,kBAAkB,GAAG,+BAA+B,MAAM;;;;;;;AAQ5F,SAAgB,eAAsB;AACpC,OAAM,IAAI,sBAAsB,qBAAqB,GAAG,+BAA+B,MAAM;;AAU/F,IAAI,CAAC,UAAU;AACb,QAAO,iBAAiB,aAAa,UAAU;AAC7C,mBAAiB;AAEjB,wBAAsB,MAAM,MAAM;GAClC;CAeF,MAAM,oBAAoB,OAAO,QAAQ,UAAU,KAAK,OAAO,QAAQ;CACvE,MAAM,uBAAuB,OAAO,QAAQ,aAAa,KAAK,OAAO,QAAQ;AAE7E,QAAO,QAAQ,YAAY,SAAS,iBAClC,MACA,QACA,KACM;AACN,oBAAkB,MAAM,QAAQ,IAAI;AACpC,mBAAiB;;AAGnB,QAAO,QAAQ,eAAe,SAAS,oBACrC,MACA,QACA,KACM;AACN,uBAAqB,MAAM,QAAQ,IAAI;AACvC,mBAAiB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vinext",
3
- "version": "0.0.35",
3
+ "version": "0.0.36",
4
4
  "description": "Run Next.js apps on Vite. Drop-in replacement for the next CLI.",
5
5
  "license": "MIT",
6
6
  "repository": {