vinext 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/config-matchers.d.ts +3 -2
- package/dist/config/config-matchers.d.ts.map +1 -1
- package/dist/config/config-matchers.js +4 -3
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -3
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +3 -2
- package/dist/init.js.map +1 -1
- package/dist/server/app-dev-server.d.ts.map +1 -1
- package/dist/server/app-dev-server.js +21 -5
- package/dist/server/app-dev-server.js.map +1 -1
- package/dist/server/app-router-entry.d.ts.map +1 -1
- package/dist/server/app-router-entry.js +8 -1
- package/dist/server/app-router-entry.js.map +1 -1
- package/dist/server/dev-server.d.ts.map +1 -1
- package/dist/server/dev-server.js +4 -3
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/middleware.d.ts.map +1 -1
- package/dist/server/middleware.js +9 -1
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/prod-server.d.ts.map +1 -1
- package/dist/server/prod-server.js +20 -2
- package/dist/server/prod-server.js.map +1 -1
- package/dist/shims/fetch-cache.d.ts.map +1 -1
- package/dist/shims/fetch-cache.js +153 -61
- package/dist/shims/fetch-cache.js.map +1 -1
- package/dist/shims/navigation.js +2 -2
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/router.d.ts +1 -1
- package/dist/shims/router.d.ts.map +1 -1
- package/dist/shims/router.js +2 -2
- package/dist/shims/router.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-cache.js","sourceRoot":"","sources":["../../src/shims/fetch-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EACL,eAAe,GAEhB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,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IAAwC,CAAC;IAC1E,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACzD,CAAC;AAED,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E,8EAA8E;AAC9E,kDAAkD;AAClD,sEAAsE;AACtE,mEAAmE;AACnE,6EAA6E;AAC7E,8EAA8E;AAE9E,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;AAElE,SAAS,qBAAqB;IAC5B,IAAI,EAAE,CAAC,UAAU,CAAC;QAAE,OAAO;IAC3B,EAAE,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IACtB,UAAU,CAAC,KAAK,GAAG,kBAAkB,EAAE,CAAC;AAC1C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc;IAC5B,qBAAqB,EAAE,CAAC;IACxB,mBAAmB,EAAE,CAAC;IAEtB,OAAO,GAAG,EAAE;QACV,mBAAmB,EAAE,CAAC;IACxB,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAI,EAAoB;IAC7D,qBAAqB,EAAE,CAAC;IACxB,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,kBAAkB,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["/**\n * Extended fetch() with Next.js caching semantics.\n *\n * Patches `globalThis.fetch` during server rendering to support:\n *\n * fetch(url, { next: { revalidate: 60, tags: ['posts'] } })\n * fetch(url, { cache: 'force-cache' })\n * fetch(url, { cache: 'no-store' })\n *\n * Cached responses are stored via the pluggable CacheHandler, so\n * revalidateTag() and revalidatePath() invalidate fetch-level caches.\n *\n * Usage (in server entry):\n * import { withFetchCache, cleanupFetchCache } from './fetch-cache';\n * const cleanup = withFetchCache();\n * try { ... render ... } finally { cleanup(); }\n *\n * Or use the async helper:\n * await runWithFetchCache(async () => { ... render ... });\n */\n\nimport {\n getCacheHandler,\n type CachedFetchValue,\n} from \"./cache.js\";\nimport { AsyncLocalStorage } from \"node:async_hooks\";\n\n// ---------------------------------------------------------------------------\n// Cache key generation\n// ---------------------------------------------------------------------------\n\n/**\n * Headers that carry per-user identity. When any of these are present in a\n * fetch request, they MUST be included in the cache key to prevent one user's\n * authenticated response from being served to another user.\n *\n * Checked case-insensitively to match HTTP header semantics.\n *\n * SECURITY NOTE: Only these three headers are keyed. If your application uses\n * custom authentication headers (e.g. \"X-Session-Token\", \"X-Auth-Token\"),\n * responses may be incorrectly shared across users. In such cases, use\n * `cache: 'no-store'` on authenticated fetches or add the header to the URL\n * as a query parameter to ensure unique cache keys.\n */\nconst AUTH_HEADERS = [\"authorization\", \"cookie\", \"x-api-key\"];\n\n/**\n * Check whether a fetch request includes any per-user authentication headers.\n * Returns the normalized header values (sorted by name) for cache key inclusion,\n * or null if no auth headers are present.\n */\nfunction extractAuthHeaders(input: string | URL | Request, init?: RequestInit): string | null {\n const collected: [string, string][] = [];\n\n // Gather headers from the init object\n if (init?.headers) {\n const headers = init.headers instanceof Headers\n ? init.headers\n : new Headers(init.headers as HeadersInit);\n for (const name of AUTH_HEADERS) {\n const value = headers.get(name);\n if (value) collected.push([name, value]);\n }\n }\n\n // Also check headers from the Request object (if input is a Request)\n if (input instanceof Request && input.headers) {\n for (const name of AUTH_HEADERS) {\n // Don't duplicate if already found in init\n if (collected.some(([n]) => n === name)) continue;\n const value = input.headers.get(name);\n if (value) collected.push([name, value]);\n }\n }\n\n if (collected.length === 0) return null;\n\n // Sort for deterministic key ordering\n collected.sort((a, b) => a[0].localeCompare(b[0]));\n return collected.map(([k, v]) => `${k}=${v}`).join(\"&\");\n}\n\n/**\n * Check whether a fetch request carries any per-user auth headers.\n */\nfunction hasAuthHeaders(input: string | URL | Request, init?: RequestInit): boolean {\n return extractAuthHeaders(input, init) !== null;\n}\n\n/**\n * Generate a deterministic cache key from a fetch request.\n *\n * Key = \"fetch:\" + method + \":\" + URL [+ \"|\" + body] [+ \"|auth:\" + auth_headers].\n *\n * When per-user headers (Authorization, Cookie, X-API-Key) are present,\n * they are included in the cache key so different users get separate cache\n * entries. This prevents authenticated responses from leaking across users.\n */\nfunction buildFetchCacheKey(input: string | URL | Request, init?: RequestInit & { next?: NextFetchOptions }): string {\n let url: string;\n let method = \"GET\";\n let body: string | undefined;\n\n if (typeof input === \"string\") {\n url = input;\n } else if (input instanceof URL) {\n url = input.toString();\n } else {\n // Request object\n url = input.url;\n method = input.method || \"GET\";\n }\n\n if (init?.method) method = init.method;\n if (init?.body && typeof init.body === \"string\") body = init.body;\n\n // Build a stable key from URL + method + body + auth headers\n const parts = [`fetch:${method}:${url}`];\n if (body) parts.push(body);\n\n // Include per-user auth headers in the key to prevent cross-user leakage\n const authPart = extractAuthHeaders(input, init);\n if (authPart) parts.push(`auth:${authPart}`);\n\n return parts.join(\"|\");\n}\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\ninterface NextFetchOptions {\n revalidate?: number | false;\n tags?: string[];\n}\n\n// Extend the standard RequestInit to include `next`\ndeclare global {\n interface RequestInit {\n next?: NextFetchOptions;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Patching\n// ---------------------------------------------------------------------------\n\n// Capture the real (unpatched) fetch once, shared across Vite's\n// multi-environment module instances via Symbol.for().\nconst _ORIG_FETCH_KEY = Symbol.for(\"vinext.fetchCache.originalFetch\");\nconst _gFetch = globalThis as unknown as Record<PropertyKey, unknown>;\nconst originalFetch: typeof globalThis.fetch = (_gFetch[_ORIG_FETCH_KEY] ??= globalThis.fetch) as typeof globalThis.fetch;\n\n// ---------------------------------------------------------------------------\n// AsyncLocalStorage for request-scoped fetch cache state.\n// Uses Symbol.for() on globalThis so the storage is shared across Vite's\n// multi-environment module instances.\n// ---------------------------------------------------------------------------\ninterface FetchCacheState {\n currentRequestTags: string[];\n}\n\nconst _ALS_KEY = Symbol.for(\"vinext.fetchCache.als\");\nconst _FALLBACK_KEY = Symbol.for(\"vinext.fetchCache.fallback\");\nconst _g = globalThis as unknown as Record<PropertyKey, unknown>;\nconst _als = (_g[_ALS_KEY] ??= new AsyncLocalStorage<FetchCacheState>()) as AsyncLocalStorage<FetchCacheState>;\n\nconst _fallbackState = (_g[_FALLBACK_KEY] ??= {\n currentRequestTags: [],\n} satisfies FetchCacheState) as FetchCacheState;\n\nfunction _getState(): FetchCacheState {\n return _als.getStore() ?? _fallbackState;\n}\n\n/**\n * Reset the fallback state for a new request. Used by `withFetchCache()`\n * in single-threaded contexts where ALS.run() isn't used.\n */\nfunction _resetFallbackState(): void {\n _fallbackState.currentRequestTags = [];\n}\n\n/**\n * Get tags collected during the current render pass.\n * Useful for associating page-level cache entries with all the\n * fetch tags used during rendering.\n */\nexport function getCollectedFetchTags(): string[] {\n return [..._getState().currentRequestTags];\n}\n\n/**\n * Create a patched fetch function with Next.js caching semantics.\n *\n * The patched fetch:\n * 1. Checks `cache` and `next` options to determine caching behavior\n * 2. On cache hit, returns the cached response without hitting the network\n * 3. On cache miss, fetches from network, stores in cache, returns response\n * 4. Respects `next.revalidate` for TTL-based revalidation\n * 5. Respects `next.tags` for tag-based invalidation via revalidateTag()\n */\nfunction createPatchedFetch(): typeof globalThis.fetch {\n return async function patchedFetch(\n input: string | URL | Request,\n init?: RequestInit,\n ): Promise<Response> {\n const nextOpts = init?.next as NextFetchOptions | undefined;\n const cacheDirective = init?.cache;\n\n // Determine caching behavior:\n // - cache: 'no-store' → skip cache entirely\n // - cache: 'force-cache' → cache indefinitely (revalidate = Infinity)\n // - next.revalidate: false → same as 'no-store'\n // - next.revalidate: 0 → same as 'no-store'\n // - next.revalidate: N → cache for N seconds\n // - No cache/next options → default behavior (no caching, pass-through)\n\n // If no caching options at all, just pass through to original fetch\n if (!nextOpts && !cacheDirective) {\n return originalFetch(input, init);\n }\n\n // Explicit no-store or no-cache — bypass cache entirely\n if (cacheDirective === \"no-store\" || cacheDirective === \"no-cache\" || nextOpts?.revalidate === false || nextOpts?.revalidate === 0) {\n // Strip the `next` property before passing to real fetch\n const cleanInit = stripNextFromInit(init);\n return originalFetch(input, cleanInit);\n }\n\n // Safety: when per-user auth headers are present and the developer hasn't\n // explicitly opted into caching with `cache: 'force-cache'` or an explicit\n // `next.revalidate`, skip caching to prevent accidental cross-user data\n // leakage. Developers who understand the implications can still force\n // caching by using `cache: 'force-cache'` or `next: { revalidate: N }`.\n const hasExplicitCacheOpt =\n cacheDirective === \"force-cache\" ||\n (typeof nextOpts?.revalidate === \"number\" && nextOpts.revalidate > 0);\n if (!hasExplicitCacheOpt && hasAuthHeaders(input, init)) {\n const cleanInit = stripNextFromInit(init);\n return originalFetch(input, cleanInit);\n }\n\n // Determine revalidation period\n let revalidateSeconds: number;\n if (cacheDirective === \"force-cache\") {\n // force-cache means cache indefinitely (we use a very large number)\n revalidateSeconds = nextOpts?.revalidate && typeof nextOpts.revalidate === \"number\"\n ? nextOpts.revalidate\n : 31536000; // 1 year\n } else if (typeof nextOpts?.revalidate === \"number\" && nextOpts.revalidate > 0) {\n revalidateSeconds = nextOpts.revalidate;\n } else {\n // Has `next` options but no explicit revalidate — Next.js defaults to\n // caching when `next` is present (force-cache behavior).\n // If only tags are specified, cache indefinitely.\n if (nextOpts?.tags && nextOpts.tags.length > 0) {\n revalidateSeconds = 31536000;\n } else {\n // next: {} with no revalidate or tags — pass through\n const cleanInit = stripNextFromInit(init);\n return originalFetch(input, cleanInit);\n }\n }\n\n const tags = nextOpts?.tags ?? [];\n const cacheKey = buildFetchCacheKey(input, init);\n const handler = getCacheHandler();\n\n // Collect tags for this render pass\n const reqTags = _getState().currentRequestTags;\n if (tags.length > 0) {\n for (const tag of tags) {\n if (!reqTags.includes(tag)) {\n reqTags.push(tag);\n }\n }\n }\n\n // Try cache first\n try {\n const cached = await handler.get(cacheKey, { kind: \"FETCH\", tags });\n if (cached?.value && cached.value.kind === \"FETCH\" && cached.cacheState !== \"stale\") {\n const cachedData = cached.value.data;\n // Reconstruct a Response from the cached data\n return new Response(cachedData.body, {\n status: cachedData.status ?? 200,\n headers: cachedData.headers,\n });\n }\n\n // Stale entry — we could do stale-while-revalidate here, but for fetch()\n // the simpler approach is to just re-fetch (the page-level ISR handles SWR).\n // However, if we have a stale entry, return it and trigger background refetch.\n if (cached?.value && cached.value.kind === \"FETCH\" && cached.cacheState === \"stale\") {\n const staleData = cached.value.data;\n\n // Background refetch\n const cleanInit = stripNextFromInit(init);\n originalFetch(input, cleanInit).then(async (freshResp) => {\n const freshBody = await freshResp.text();\n const freshHeaders: Record<string, string> = {};\n freshResp.headers.forEach((v, k) => { freshHeaders[k] = v; });\n\n const freshValue: CachedFetchValue = {\n kind: \"FETCH\",\n data: {\n headers: freshHeaders,\n body: freshBody,\n url: typeof input === \"string\" ? input : input instanceof URL ? input.toString() : input.url,\n status: freshResp.status,\n },\n tags,\n revalidate: revalidateSeconds,\n };\n await handler.set(cacheKey, freshValue, {\n fetchCache: true,\n tags,\n revalidate: revalidateSeconds,\n });\n }).catch((err) => {\n console.error(\"[vinext] fetch cache background revalidation failed:\", err);\n });\n\n // Return stale data immediately\n return new Response(staleData.body, {\n status: staleData.status ?? 200,\n headers: staleData.headers,\n });\n }\n } catch (cacheErr) {\n // Cache read failed — fall through to network\n console.error(\"[vinext] fetch cache read error:\", cacheErr);\n }\n\n // Cache miss — fetch from network\n const cleanInit = stripNextFromInit(init);\n const response = await originalFetch(input, cleanInit);\n\n // Only cache successful responses (2xx)\n if (response.ok) {\n // Clone before reading body\n const cloned = response.clone();\n const body = await cloned.text();\n const headers: Record<string, string> = {};\n cloned.headers.forEach((v, k) => { headers[k] = v; });\n\n const cacheValue: CachedFetchValue = {\n kind: \"FETCH\",\n data: {\n headers,\n body,\n url: typeof input === \"string\" ? input : input instanceof URL ? input.toString() : input.url,\n status: cloned.status,\n },\n tags,\n revalidate: revalidateSeconds,\n };\n\n // Store in cache (fire-and-forget)\n handler.set(cacheKey, cacheValue, {\n fetchCache: true,\n tags,\n revalidate: revalidateSeconds,\n }).catch((err) => {\n console.error(\"[vinext] fetch cache write error:\", err);\n });\n }\n\n return response;\n } as typeof globalThis.fetch;\n}\n\n/**\n * Strip the `next` property from RequestInit before passing to real fetch.\n * The `next` property is not a standard fetch option and would cause warnings\n * in some environments.\n */\nfunction stripNextFromInit(init?: RequestInit): RequestInit | undefined {\n if (!init) return init;\n if (!(\"next\" in init)) return init;\n const { next: _next, ...rest } = init as RequestInit & { next?: unknown };\n return Object.keys(rest).length > 0 ? rest : undefined;\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n// ---------------------------------------------------------------------------\n// Fetch patching — install once, not per-request.\n// The patched fetch uses _getState() internally, which reads from ALS\n// (concurrent) or _fallbackState (single-threaded), so per-request\n// isolation is handled at the state level, not by swapping globalThis.fetch.\n// ---------------------------------------------------------------------------\n\nconst _PATCH_KEY = Symbol.for(\"vinext.fetchCache.patchInstalled\");\n\nfunction _ensurePatchInstalled(): void {\n if (_g[_PATCH_KEY]) return;\n _g[_PATCH_KEY] = true;\n globalThis.fetch = createPatchedFetch();\n}\n\n/**\n * Install the patched fetch and reset per-request tag state.\n * Returns a cleanup function that clears tags.\n *\n * @deprecated Prefer `runWithFetchCache()` which uses `AsyncLocalStorage.run()`\n * for proper per-request isolation in concurrent environments.\n *\n * Usage:\n * const cleanup = withFetchCache();\n * try { await render(); } finally { cleanup(); }\n */\nexport function withFetchCache(): () => void {\n _ensurePatchInstalled();\n _resetFallbackState();\n\n return () => {\n _resetFallbackState();\n };\n}\n\n/**\n * Run an async function with patched fetch caching enabled.\n * Uses `AsyncLocalStorage.run()` for proper per-request isolation\n * of collected fetch tags in concurrent server environments.\n */\nexport async function runWithFetchCache<T>(fn: () => Promise<T>): Promise<T> {\n _ensurePatchInstalled();\n return _als.run({ currentRequestTags: [] }, fn);\n}\n\n/**\n * Get the original (unpatched) fetch function.\n * Useful for internal code that should bypass caching.\n */\nexport function getOriginalFetch(): typeof globalThis.fetch {\n return originalFetch;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fetch-cache.js","sourceRoot":"","sources":["../../src/shims/fetch-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EACL,eAAe,GAEhB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,8EAA8E;AAC9E,uBAAuB;AACvB,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;AAEvD,8EAA8E;AAC9E,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAE9B;;;;GAIG;AACH,SAAS,cAAc,CAAC,KAA6B,EAAE,IAAkB;IACvE,MAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,kDAAkD;IAClD,IAAI,KAAK,YAAY,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAC9C,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,yEAAyE;IACzE,IAAI,IAAI,EAAE,OAAO,EAAE,CAAC;QAClB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,YAAY,OAAO;YAC7C,CAAC,CAAC,IAAI,CAAC,OAAO;YACd,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,OAAsB,CAAC,CAAC;QAC7C,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CA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;AAC1C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc;IAC5B,qBAAqB,EAAE,CAAC;IACxB,mBAAmB,EAAE,CAAC;IAEtB,OAAO,GAAG,EAAE;QACV,mBAAmB,EAAE,CAAC;IACxB,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAI,EAAoB;IAC7D,qBAAqB,EAAE,CAAC;IACxB,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,kBAAkB,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["/**\n * Extended fetch() with Next.js caching semantics.\n *\n * Patches `globalThis.fetch` during server rendering to support:\n *\n * fetch(url, { next: { revalidate: 60, tags: ['posts'] } })\n * fetch(url, { cache: 'force-cache' })\n * fetch(url, { cache: 'no-store' })\n *\n * Cached responses are stored via the pluggable CacheHandler, so\n * revalidateTag() and revalidatePath() invalidate fetch-level caches.\n *\n * Usage (in server entry):\n * import { withFetchCache, cleanupFetchCache } from './fetch-cache';\n * const cleanup = withFetchCache();\n * try { ... render ... } finally { cleanup(); }\n *\n * Or use the async helper:\n * await runWithFetchCache(async () => { ... render ... });\n */\n\nimport {\n getCacheHandler,\n type CachedFetchValue,\n} from \"./cache.js\";\nimport { AsyncLocalStorage } from \"node:async_hooks\";\n\n// ---------------------------------------------------------------------------\n// Cache key generation\n// ---------------------------------------------------------------------------\n\n/**\n * Headers excluded from the cache key. These are W3C trace context headers\n * that can break request caching and deduplication.\n * All other headers ARE included in the cache key, matching Next.js behavior.\n */\nconst HEADER_BLOCKLIST = [\"traceparent\", \"tracestate\"];\n\n// Cache key version — bump when changing the key format to bust stale entries\nconst CACHE_KEY_PREFIX = \"v1\";\n\n/**\n * Collect all headers from the request, excluding the blocklist.\n * Merges headers from both the Request object and the init object,\n * with init taking precedence (matching fetch() spec behavior).\n */\nfunction collectHeaders(input: string | URL | Request, init?: RequestInit): Record<string, string> {\n const merged: Record<string, string> = {};\n\n // Start with headers from Request object (if any)\n if (input instanceof Request && input.headers) {\n input.headers.forEach((v, k) => { merged[k] = v; });\n }\n\n // Override with headers from init (init takes precedence per fetch spec)\n if (init?.headers) {\n const headers = init.headers instanceof Headers\n ? init.headers\n : new Headers(init.headers as HeadersInit);\n headers.forEach((v, k) => { merged[k] = v; });\n }\n\n // Remove blocklisted headers\n for (const blocked of HEADER_BLOCKLIST) {\n delete merged[blocked];\n }\n\n return merged;\n}\n\n/**\n * Check whether a fetch request carries any per-user auth headers.\n * Used for the safety bypass (skip caching when auth headers are present\n * without an explicit cache opt-in).\n */\nconst AUTH_HEADERS = [\"authorization\", \"cookie\", \"x-api-key\"];\n\nfunction hasAuthHeaders(input: string | URL | Request, init?: RequestInit): boolean {\n const headers = collectHeaders(input, init);\n return AUTH_HEADERS.some((name) => name in headers);\n}\n\n/**\n * Serialize request body into string chunks for cache key inclusion.\n * Handles all body types: string, Uint8Array, ReadableStream, FormData, Blob.\n * Returns the serialized body chunks and optionally stashes the original body\n * on init as `_ogBody` so it can still be used after stream consumption.\n */\nasync function serializeBody(init?: RequestInit): Promise<string[]> {\n if (!init?.body) return [];\n\n const bodyChunks: string[] = [];\n const encoder = new TextEncoder();\n const decoder = new TextDecoder();\n\n if (init.body instanceof Uint8Array) {\n bodyChunks.push(decoder.decode(init.body));\n (init as any)._ogBody = init.body;\n } else if (typeof (init.body as any).getReader === \"function\") {\n // ReadableStream\n const readableBody = init.body as ReadableStream<Uint8Array | string>;\n const chunks: Uint8Array[] = [];\n\n try {\n await readableBody.pipeTo(\n new WritableStream({\n write(chunk) {\n if (typeof chunk === \"string\") {\n chunks.push(encoder.encode(chunk));\n bodyChunks.push(chunk);\n } else {\n chunks.push(chunk);\n bodyChunks.push(decoder.decode(chunk, { stream: true }));\n }\n },\n })\n );\n // Flush the decoder\n bodyChunks.push(decoder.decode());\n\n // Reconstruct the body so it can still be sent\n const length = chunks.reduce((total, arr) => total + arr.length, 0);\n const arrayBuffer = new Uint8Array(length);\n let offset = 0;\n for (const chunk of chunks) {\n arrayBuffer.set(chunk, offset);\n offset += chunk.length;\n }\n (init as any)._ogBody = arrayBuffer;\n } catch (err) {\n console.error(\"[vinext] Problem reading body for cache key\", err);\n // Still reconstruct what we have so originalFetch doesn't get a spent stream\n if (chunks.length > 0) {\n const length = chunks.reduce((total, arr) => total + arr.length, 0);\n const partial = new Uint8Array(length);\n let offset = 0;\n for (const chunk of chunks) {\n partial.set(chunk, offset);\n offset += chunk.length;\n }\n (init as any)._ogBody = partial;\n }\n }\n } else if (init.body instanceof URLSearchParams) {\n // URLSearchParams — .toString() gives a stable serialization\n (init as any)._ogBody = init.body;\n bodyChunks.push(init.body.toString());\n } else if (typeof (init.body as any).keys === \"function\") {\n // FormData\n const formData = init.body as FormData;\n (init as any)._ogBody = init.body;\n for (const key of new Set(formData.keys())) {\n const values = formData.getAll(key);\n bodyChunks.push(\n `${key}=${(\n await Promise.all(\n values.map(async (val) => {\n if (typeof val === \"string\") return val;\n // Note: File name/type/lastModified are not included — only content.\n // Two Files with identical content but different names produce the same key.\n return await val.text();\n })\n )\n ).join(\",\")}`\n );\n }\n } else if (typeof (init.body as any).arrayBuffer === \"function\") {\n // Blob\n const blob = init.body as Blob;\n bodyChunks.push(await blob.text());\n const arrayBuffer = await blob.arrayBuffer();\n (init as any)._ogBody = new Blob([arrayBuffer], { type: blob.type });\n } else if (typeof init.body === \"string\") {\n bodyChunks.push(init.body);\n (init as any)._ogBody = init.body;\n }\n\n return bodyChunks;\n}\n\n/**\n * Generate a deterministic cache key from a fetch request.\n *\n * Matches Next.js behavior: the key is a SHA-256 hash of a JSON array\n * containing URL, method, all headers (minus blocklist), all RequestInit\n * options, and the serialized body.\n */\nasync function buildFetchCacheKey(input: string | URL | Request, init?: RequestInit & { next?: NextFetchOptions }): Promise<string> {\n let url: string;\n let method = \"GET\";\n\n if (typeof input === \"string\") {\n url = input;\n } else if (input instanceof URL) {\n url = input.toString();\n } else {\n // Request object\n url = input.url;\n method = input.method || \"GET\";\n }\n\n if (init?.method) method = init.method;\n\n const headers = collectHeaders(input, init);\n const bodyChunks = await serializeBody(init);\n\n const cacheString = JSON.stringify([\n CACHE_KEY_PREFIX,\n url,\n method,\n headers,\n init?.mode,\n init?.redirect,\n init?.credentials,\n init?.referrer,\n init?.referrerPolicy,\n init?.integrity,\n init?.cache,\n bodyChunks,\n ]);\n\n const encoder = new TextEncoder();\n const buffer = encoder.encode(cacheString);\n const hashBuffer = await crypto.subtle.digest(\"SHA-256\", buffer);\n return Array.prototype.map\n .call(new Uint8Array(hashBuffer), (b: number) => b.toString(16).padStart(2, \"0\"))\n .join(\"\");\n}\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\ninterface NextFetchOptions {\n revalidate?: number | false;\n tags?: string[];\n}\n\n// Extend the standard RequestInit to include `next`\ndeclare global {\n interface RequestInit {\n next?: NextFetchOptions;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Patching\n// ---------------------------------------------------------------------------\n\n// Capture the real (unpatched) fetch once, shared across Vite's\n// multi-environment module instances via Symbol.for().\nconst _ORIG_FETCH_KEY = Symbol.for(\"vinext.fetchCache.originalFetch\");\nconst _gFetch = globalThis as unknown as Record<PropertyKey, unknown>;\nconst originalFetch: typeof globalThis.fetch = (_gFetch[_ORIG_FETCH_KEY] ??= globalThis.fetch) as typeof globalThis.fetch;\n\n// ---------------------------------------------------------------------------\n// AsyncLocalStorage for request-scoped fetch cache state.\n// Uses Symbol.for() on globalThis so the storage is shared across Vite's\n// multi-environment module instances.\n// ---------------------------------------------------------------------------\ninterface FetchCacheState {\n currentRequestTags: string[];\n}\n\nconst _ALS_KEY = Symbol.for(\"vinext.fetchCache.als\");\nconst _FALLBACK_KEY = Symbol.for(\"vinext.fetchCache.fallback\");\nconst _g = globalThis as unknown as Record<PropertyKey, unknown>;\nconst _als = (_g[_ALS_KEY] ??= new AsyncLocalStorage<FetchCacheState>()) as AsyncLocalStorage<FetchCacheState>;\n\nconst _fallbackState = (_g[_FALLBACK_KEY] ??= {\n currentRequestTags: [],\n} satisfies FetchCacheState) as FetchCacheState;\n\nfunction _getState(): FetchCacheState {\n return _als.getStore() ?? _fallbackState;\n}\n\n/**\n * Reset the fallback state for a new request. Used by `withFetchCache()`\n * in single-threaded contexts where ALS.run() isn't used.\n */\nfunction _resetFallbackState(): void {\n _fallbackState.currentRequestTags = [];\n}\n\n/**\n * Get tags collected during the current render pass.\n * Useful for associating page-level cache entries with all the\n * fetch tags used during rendering.\n */\nexport function getCollectedFetchTags(): string[] {\n return [..._getState().currentRequestTags];\n}\n\n/**\n * Create a patched fetch function with Next.js caching semantics.\n *\n * The patched fetch:\n * 1. Checks `cache` and `next` options to determine caching behavior\n * 2. On cache hit, returns the cached response without hitting the network\n * 3. On cache miss, fetches from network, stores in cache, returns response\n * 4. Respects `next.revalidate` for TTL-based revalidation\n * 5. Respects `next.tags` for tag-based invalidation via revalidateTag()\n */\nfunction createPatchedFetch(): typeof globalThis.fetch {\n return async function patchedFetch(\n input: string | URL | Request,\n init?: RequestInit,\n ): Promise<Response> {\n const nextOpts = init?.next as NextFetchOptions | undefined;\n const cacheDirective = init?.cache;\n\n // Determine caching behavior:\n // - cache: 'no-store' → skip cache entirely\n // - cache: 'force-cache' → cache indefinitely (revalidate = Infinity)\n // - next.revalidate: false → same as 'no-store'\n // - next.revalidate: 0 → same as 'no-store'\n // - next.revalidate: N → cache for N seconds\n // - No cache/next options → default behavior (no caching, pass-through)\n\n // If no caching options at all, just pass through to original fetch\n if (!nextOpts && !cacheDirective) {\n return originalFetch(input, init);\n }\n\n // Explicit no-store or no-cache — bypass cache entirely\n if (cacheDirective === \"no-store\" || cacheDirective === \"no-cache\" || nextOpts?.revalidate === false || nextOpts?.revalidate === 0) {\n // Strip the `next` property before passing to real fetch\n const cleanInit = stripNextFromInit(init);\n return originalFetch(input, cleanInit);\n }\n\n // Safety: when per-user auth headers are present and the developer hasn't\n // explicitly opted into caching with `cache: 'force-cache'` or an explicit\n // `next.revalidate`, skip caching to prevent accidental cross-user data\n // leakage. Developers who understand the implications can still force\n // caching by using `cache: 'force-cache'` or `next: { revalidate: N }`.\n const hasExplicitCacheOpt =\n cacheDirective === \"force-cache\" ||\n (typeof nextOpts?.revalidate === \"number\" && nextOpts.revalidate > 0);\n if (!hasExplicitCacheOpt && hasAuthHeaders(input, init)) {\n const cleanInit = stripNextFromInit(init);\n return originalFetch(input, cleanInit);\n }\n\n // Determine revalidation period\n let revalidateSeconds: number;\n if (cacheDirective === \"force-cache\") {\n // force-cache means cache indefinitely (we use a very large number)\n revalidateSeconds = nextOpts?.revalidate && typeof nextOpts.revalidate === \"number\"\n ? nextOpts.revalidate\n : 31536000; // 1 year\n } else if (typeof nextOpts?.revalidate === \"number\" && nextOpts.revalidate > 0) {\n revalidateSeconds = nextOpts.revalidate;\n } else {\n // Has `next` options but no explicit revalidate — Next.js defaults to\n // caching when `next` is present (force-cache behavior).\n // If only tags are specified, cache indefinitely.\n if (nextOpts?.tags && nextOpts.tags.length > 0) {\n revalidateSeconds = 31536000;\n } else {\n // next: {} with no revalidate or tags — pass through\n const cleanInit = stripNextFromInit(init);\n return originalFetch(input, cleanInit);\n }\n }\n\n const tags = nextOpts?.tags ?? [];\n const cacheKey = await buildFetchCacheKey(input, init);\n const handler = getCacheHandler();\n\n // Collect tags for this render pass\n const reqTags = _getState().currentRequestTags;\n if (tags.length > 0) {\n for (const tag of tags) {\n if (!reqTags.includes(tag)) {\n reqTags.push(tag);\n }\n }\n }\n\n // Try cache first\n try {\n const cached = await handler.get(cacheKey, { kind: \"FETCH\", tags });\n if (cached?.value && cached.value.kind === \"FETCH\" && cached.cacheState !== \"stale\") {\n const cachedData = cached.value.data;\n // Reconstruct a Response from the cached data\n return new Response(cachedData.body, {\n status: cachedData.status ?? 200,\n headers: cachedData.headers,\n });\n }\n\n // Stale entry — we could do stale-while-revalidate here, but for fetch()\n // the simpler approach is to just re-fetch (the page-level ISR handles SWR).\n // However, if we have a stale entry, return it and trigger background refetch.\n if (cached?.value && cached.value.kind === \"FETCH\" && cached.cacheState === \"stale\") {\n const staleData = cached.value.data;\n\n // Background refetch\n const cleanInit = stripNextFromInit(init);\n originalFetch(input, cleanInit).then(async (freshResp) => {\n const freshBody = await freshResp.text();\n const freshHeaders: Record<string, string> = {};\n freshResp.headers.forEach((v, k) => { freshHeaders[k] = v; });\n\n const freshValue: CachedFetchValue = {\n kind: \"FETCH\",\n data: {\n headers: freshHeaders,\n body: freshBody,\n url: typeof input === \"string\" ? input : input instanceof URL ? input.toString() : input.url,\n status: freshResp.status,\n },\n tags,\n revalidate: revalidateSeconds,\n };\n await handler.set(cacheKey, freshValue, {\n fetchCache: true,\n tags,\n revalidate: revalidateSeconds,\n });\n }).catch((err) => {\n console.error(\"[vinext] fetch cache background revalidation failed:\", err);\n });\n\n // Return stale data immediately\n return new Response(staleData.body, {\n status: staleData.status ?? 200,\n headers: staleData.headers,\n });\n }\n } catch (cacheErr) {\n // Cache read failed — fall through to network\n console.error(\"[vinext] fetch cache read error:\", cacheErr);\n }\n\n // Cache miss — fetch from network\n const cleanInit = stripNextFromInit(init);\n const response = await originalFetch(input, cleanInit);\n\n // Only cache successful responses (2xx)\n if (response.ok) {\n // Clone before reading body\n const cloned = response.clone();\n const body = await cloned.text();\n const headers: Record<string, string> = {};\n cloned.headers.forEach((v, k) => { headers[k] = v; });\n\n const cacheValue: CachedFetchValue = {\n kind: \"FETCH\",\n data: {\n headers,\n body,\n url: typeof input === \"string\" ? input : input instanceof URL ? input.toString() : input.url,\n status: cloned.status,\n },\n tags,\n revalidate: revalidateSeconds,\n };\n\n // Store in cache (fire-and-forget)\n handler.set(cacheKey, cacheValue, {\n fetchCache: true,\n tags,\n revalidate: revalidateSeconds,\n }).catch((err) => {\n console.error(\"[vinext] fetch cache write error:\", err);\n });\n }\n\n return response;\n } as typeof globalThis.fetch;\n}\n\n/**\n * Strip the `next` property from RequestInit before passing to real fetch.\n * The `next` property is not a standard fetch option and would cause warnings\n * in some environments.\n */\nfunction stripNextFromInit(init?: RequestInit): RequestInit | undefined {\n if (!init) return init;\n const castInit = init as RequestInit & { next?: unknown; _ogBody?: BodyInit };\n const { next: _next, _ogBody, ...rest } = castInit;\n // Restore the original body if it was stashed by serializeBody (e.g. after\n // consuming a ReadableStream for cache key generation).\n if (_ogBody !== undefined) {\n rest.body = _ogBody;\n }\n return Object.keys(rest).length > 0 ? rest : undefined;\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n// ---------------------------------------------------------------------------\n// Fetch patching — install once, not per-request.\n// The patched fetch uses _getState() internally, which reads from ALS\n// (concurrent) or _fallbackState (single-threaded), so per-request\n// isolation is handled at the state level, not by swapping globalThis.fetch.\n// ---------------------------------------------------------------------------\n\nconst _PATCH_KEY = Symbol.for(\"vinext.fetchCache.patchInstalled\");\n\nfunction _ensurePatchInstalled(): void {\n if (_g[_PATCH_KEY]) return;\n _g[_PATCH_KEY] = true;\n globalThis.fetch = createPatchedFetch();\n}\n\n/**\n * Install the patched fetch and reset per-request tag state.\n * Returns a cleanup function that clears tags.\n *\n * @deprecated Prefer `runWithFetchCache()` which uses `AsyncLocalStorage.run()`\n * for proper per-request isolation in concurrent environments.\n *\n * Usage:\n * const cleanup = withFetchCache();\n * try { await render(); } finally { cleanup(); }\n */\nexport function withFetchCache(): () => void {\n _ensurePatchInstalled();\n _resetFallbackState();\n\n return () => {\n _resetFallbackState();\n };\n}\n\n/**\n * Run an async function with patched fetch caching enabled.\n * Uses `AsyncLocalStorage.run()` for proper per-request isolation\n * of collected fetch tags in concurrent server environments.\n */\nexport async function runWithFetchCache<T>(fn: () => Promise<T>): Promise<T> {\n _ensurePatchInstalled();\n return _als.run({ currentRequestTags: [] }, fn);\n}\n\n/**\n * Get the original (unpatched) fetch function.\n * Useful for internal code that should bypass caching.\n */\nexport function getOriginalFetch(): typeof globalThis.fetch {\n return originalFetch;\n}\n"]}
|
package/dist/shims/navigation.js
CHANGED
|
@@ -247,10 +247,10 @@ export function useParams() {
|
|
|
247
247
|
return _clientParams;
|
|
248
248
|
}
|
|
249
249
|
/**
|
|
250
|
-
* Check if a href is an external URL.
|
|
250
|
+
* Check if a href is an external URL (any URL scheme per RFC 3986, or protocol-relative).
|
|
251
251
|
*/
|
|
252
252
|
function isExternalUrl(href) {
|
|
253
|
-
return
|
|
253
|
+
return /^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith("//");
|
|
254
254
|
}
|
|
255
255
|
/**
|
|
256
256
|
* Check if a href is only a hash change relative to the current URL.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.js","sourceRoot":"","sources":["../../src/shims/navigation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,iFAAiF;AACjF,iFAAiF;AACjF,+EAA+E;AAC/E,qFAAqF;AACrF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,iFAAiF;AACjF,wEAAwE;AACxE,kFAAkF;AAClF,4EAA4E;AAC5E,oEAAoE;AACpE,6EAA6E;AAE7E,IAAI,iBAAiB,GAAiC,IAAI,CAAC;AAE3D;;;GAGG;AACH,MAAM,UAAU,uBAAuB;IACrC,IAAI,iBAAiB,KAAK,IAAI,IAAI,OAAO,KAAK,CAAC,aAAa,KAAK,UAAU,EAAE,CAAC;QAC5E,iBAAiB,GAAG,KAAK,CAAC,aAAa,CAAS,CAAC,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED;;;GAGG;AACH,SAAS,qBAAqB;IAC5B,MAAM,GAAG,GAAG,uBAAuB,EAAE,CAAC;IACtC,IAAI,CAAC,GAAG;QAAE,OAAO,CAAC,CAAC;IACnB,gFAAgF;IAChF,0DAA0D;IAC1D,4EAA4E;IAC5E,IAAI,CAAC;QACH,OA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CAAC;IACpB,CAAC,CAAC;AACJ,CAAC","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\";\n\n// ─── Layout segment depth context ─────────────────────────────────────────────\n// Used by useSelectedLayoutSegments() to know which layout it's inside.\n// The context is created lazily because `React.createContext` is NOT available in\n// the react-server condition of React. In the RSC environment, this remains\n// null and the hooks fall back to returning all segments (depth 0).\n// In SSR and browser environments, the context is created and used normally.\n\nlet _LayoutSegmentCtx: React.Context<number> | null = null;\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<number> | null {\n if (_LayoutSegmentCtx === null && typeof React.createContext === \"function\") {\n _LayoutSegmentCtx = React.createContext<number>(0);\n }\n return _LayoutSegmentCtx;\n}\n\n/**\n * Read the layout segment depth from context. Returns 0 if no context\n * is available (RSC environment, outside React tree, or root level).\n */\nfunction useLayoutSegmentDepth(): number {\n const ctx = getLayoutSegmentContext();\n if (!ctx) return 0;\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 0;\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\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 => { _serverContext = ctx; };\nlet _getInsertedHTMLCallbacks = (): Array<() => unknown> => _serverInsertedHTMLCallbacks;\nlet _clearInsertedHTMLCallbacks = (): void => { _serverInsertedHTMLCallbacks = []; };\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/** Strip basePath prefix from a browser pathname */\nfunction stripBasePath(p: string): string {\n if (!__basePath) return p;\n if (p.startsWith(__basePath)) return p.slice(__basePath.length) || \"/\";\n return p;\n}\n\n/** Prepend basePath to a path for browser URLs / fetches */\nfunction withBasePath(p: string): string {\n if (!__basePath) return p;\n return __basePath + p;\n}\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. */\nconst 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 = pathname.length > 1 && pathname.endsWith(\"/\")\n ? pathname.slice(0, -1)\n : 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 const win = window as any;\n if (!win.__VINEXT_RSC_PREFETCH_CACHE__) {\n win.__VINEXT_RSC_PREFETCH_CACHE__ = new Map<string, PrefetchCacheEntry>();\n }\n return win.__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 const win = window as any;\n if (!win.__VINEXT_RSC_PREFETCHED_URLS__) {\n win.__VINEXT_RSC_PREFETCHED_URLS__ = new Set<string>();\n }\n return win.__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 // Evict oldest entry if at capacity (Map iterates in insertion order)\n if (cache.size >= MAX_PREFETCH_CACHE_SIZE) {\n const oldest = cache.keys().next().value;\n if (oldest !== undefined) cache.delete(oldest);\n }\n cache.set(rscUrl, { response, timestamp: Date.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 for referential stability (useSyncExternalStore\n// compares snapshots with Object.is — new URLSearchParams instances are\n// never equal, which would cause infinite re-renders).\nlet _cachedSearch = !isServer ? window.location.search : \"\";\nlet _cachedSearchParams: URLSearchParams = new URLSearchParams(_cachedSearch);\n\nfunction getSearchParamsSnapshot(): URLSearchParams {\n const current = window.location.search;\n if (current !== _cachedSearch) {\n _cachedSearch = current;\n _cachedSearchParams = new URLSearchParams(current);\n }\n return _cachedSearchParams;\n}\n\n// Same for pathname — cache the string for referential stability\nlet _cachedPathname = !isServer ? stripBasePath(window.location.pathname) : \"/\";\n\nfunction getPathnameSnapshot(): string {\n const current = stripBasePath(window.location.pathname);\n if (current !== _cachedPathname) {\n _cachedPathname = current;\n }\n return _cachedPathname;\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).\nlet _clientParams: Record<string, string | string[]> = {};\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 }\n}\n\n/** Get the current client params (for testing referential stability). */\nexport function getClientParams(): Record<string, string | string[]> {\n return _clientParams;\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 (cb: () => void) => { _listeners.add(cb); return () => { _listeners.delete(cb); }; },\n getPathnameSnapshot,\n () => _getServerContext()?.pathname ?? \"/\",\n );\n}\n\n/**\n * Returns the current search params as a read-only URLSearchParams.\n */\nexport function useSearchParams(): URLSearchParams {\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()?.searchParams ?? new URLSearchParams();\n }\n return React.useSyncExternalStore(\n (cb: () => void) => { _listeners.add(cb); return () => { _listeners.delete(cb); }; },\n getSearchParamsSnapshot,\n () => _getServerContext()?.searchParams ?? new URLSearchParams(),\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 ?? {}) as T;\n }\n return _clientParams as T;\n}\n\n/**\n * Check if a href is an external URL.\n */\nfunction isExternalUrl(href: string): boolean {\n return href.startsWith(\"http://\") || href.startsWith(\"https://\") || 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 = !isServer\n ? window.history.replaceState.bind(window.history)\n : (null as unknown as typeof window.history.replaceState);\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 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 Promise.resolve().then(() => {\n const pending: Promise<void> | null = (window as any).__VINEXT_RSC_PENDING__ ?? null;\n\n if (pending) {\n // Wait for the RSC navigation to finish rendering, then scroll.\n 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 // External URLs: use full page navigation\n if (isExternalUrl(href)) {\n if (mode === \"replace\") {\n window.location.replace(href);\n } else {\n window.location.assign(href);\n }\n return;\n }\n\n const fullHref = withBasePath(href);\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 as any).__VINEXT_RSC_NAVIGATE__ === \"function\") {\n await (window as any).__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's useRouter — returns push/replace/back/forward/refresh.\n * Different from Pages Router's useRouter (next/router).\n */\nexport function useRouter() {\n const router = {\n push(href: string, options?: { scroll?: boolean }): void {\n if (isServer) return;\n navigateImpl(href, \"push\", options?.scroll !== false);\n },\n replace(href: string, options?: { scroll?: boolean }): void {\n if (isServer) return;\n 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 as any).__VINEXT_RSC_NAVIGATE__ === \"function\") {\n (window as any).__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 = withBasePath(href);\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 priority: \"low\" as RequestInit[\"priority\"],\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 }).catch(() => {\n // Network error: allow retry on next prefetch() call\n prefetched.delete(rscUrl);\n });\n },\n };\n return router;\n}\n\n/**\n * Returns the active child segment one level below the layout where it's called.\n *\n * In Next.js, this is layout-aware: it returns the segment relative to the\n * nearest parent layout. In our implementation, we approximate by returning\n * the first segment after a specified parallel route key, or the first segment\n * of the pathname. Returns null if at the leaf (no child segments).\n *\n * @param parallelRoutesKey - Which parallel route to read (default: \"children\")\n */\nexport function useSelectedLayoutSegment(\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 * In Next.js, this returns the full array of segments from the current\n * layout down to the leaf page. Each layout in the tree wraps its children\n * with a LayoutSegmentProvider that records the URL segment depth at that\n * level. This hook reads that depth from context and slices the pathname\n * segments accordingly.\n *\n * @param parallelRoutesKey - Which parallel route to read (default: \"children\")\n */\nexport function useSelectedLayoutSegments(\n _parallelRoutesKey?: string,\n): string[] {\n const pathname = usePathname();\n const depth = useLayoutSegmentDepth();\n const segments = pathname.split(\"/\").filter(Boolean);\n return segments.slice(depth);\n}\n\n/**\n * ReadonlyURLSearchParams — type alias matching Next.js.\n * In Next.js this prevents mutation, but since URLSearchParams is the underlying\n * type in our implementation, we export it as-is for type compatibility.\n */\nexport type ReadonlyURLSearchParams = URLSearchParams;\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 any).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 any).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 * Throw a redirect. Caught by the framework to send a redirect response.\n */\nexport function redirect(url: string, type?: \"replace\" | \"push\" | RedirectType): never {\n const error = new Error(`NEXT_REDIRECT:${url}`);\n (error as any).digest = `NEXT_REDIRECT;${type ?? \"replace\"};${encodeURIComponent(url)}`;\n throw error;\n}\n\n/**\n * Trigger a permanent redirect (308).\n */\nexport function permanentRedirect(url: string): never {\n const error = new Error(`NEXT_REDIRECT:${url}`);\n (error as any).digest = `NEXT_REDIRECT;replace;${encodeURIComponent(url)};308`;\n throw error;\n}\n\n/**\n * Trigger a not-found response (404). Caught by the framework.\n */\nexport function notFound(): never {\n const error = new Error(\"NEXT_NOT_FOUND\");\n (error as any).digest = `${HTTP_ERROR_FALLBACK_ERROR_CODE};404`;\n throw error;\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 const error = new Error(\"NEXT_FORBIDDEN\");\n (error as any).digest = `${HTTP_ERROR_FALLBACK_ERROR_CODE};403`;\n throw error;\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 const error = new Error(\"NEXT_UNAUTHORIZED\");\n (error as any).digest = `${HTTP_ERROR_FALLBACK_ERROR_CODE};401`;\n throw error;\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"]}
|
|
1
|
+
{"version":3,"file":"navigation.js","sourceRoot":"","sources":["../../src/shims/navigation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,iFAAiF;AAC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AuE;IACvE,cAAc;IACd,8EAA8E;IAC9E,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACxE,MAAM,oBAAoB,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE9E,MAAM,CAAC,OAAO,CAAC,SAAS,GAAG,SAAS,gBAAgB,CAClD,IAAa,EACb,MAAc,EACd,GAAyB;QAEzB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QACrC,eAAe,EAAE,CAAC;IACpB,CAAC,CAAC;IAEF,MAAM,CAAC,OAAO,CAAC,YAAY,GAAG,SAAS,mBAAmB,CACxD,IAAa,EACb,MAAc,EACd,GAAyB;QAEzB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QACxC,eAAe,EAAE,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC","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\";\n\n// ─── Layout segment depth context ─────────────────────────────────────────────\n// Used by useSelectedLayoutSegments() to know which layout it's inside.\n// The context is created lazily because `React.createContext` is NOT available in\n// the react-server condition of React. In the RSC environment, this remains\n// null and the hooks fall back to returning all segments (depth 0).\n// In SSR and browser environments, the context is created and used normally.\n\nlet _LayoutSegmentCtx: React.Context<number> | null = null;\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<number> | null {\n if (_LayoutSegmentCtx === null && typeof React.createContext === \"function\") {\n _LayoutSegmentCtx = React.createContext<number>(0);\n }\n return _LayoutSegmentCtx;\n}\n\n/**\n * Read the layout segment depth from context. Returns 0 if no context\n * is available (RSC environment, outside React tree, or root level).\n */\nfunction useLayoutSegmentDepth(): number {\n const ctx = getLayoutSegmentContext();\n if (!ctx) return 0;\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 0;\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\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 => { _serverContext = ctx; };\nlet _getInsertedHTMLCallbacks = (): Array<() => unknown> => _serverInsertedHTMLCallbacks;\nlet _clearInsertedHTMLCallbacks = (): void => { _serverInsertedHTMLCallbacks = []; };\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/** Strip basePath prefix from a browser pathname */\nfunction stripBasePath(p: string): string {\n if (!__basePath) return p;\n if (p.startsWith(__basePath)) return p.slice(__basePath.length) || \"/\";\n return p;\n}\n\n/** Prepend basePath to a path for browser URLs / fetches */\nfunction withBasePath(p: string): string {\n if (!__basePath) return p;\n return __basePath + p;\n}\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. */\nconst 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 = pathname.length > 1 && pathname.endsWith(\"/\")\n ? pathname.slice(0, -1)\n : 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 const win = window as any;\n if (!win.__VINEXT_RSC_PREFETCH_CACHE__) {\n win.__VINEXT_RSC_PREFETCH_CACHE__ = new Map<string, PrefetchCacheEntry>();\n }\n return win.__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 const win = window as any;\n if (!win.__VINEXT_RSC_PREFETCHED_URLS__) {\n win.__VINEXT_RSC_PREFETCHED_URLS__ = new Set<string>();\n }\n return win.__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 // Evict oldest entry if at capacity (Map iterates in insertion order)\n if (cache.size >= MAX_PREFETCH_CACHE_SIZE) {\n const oldest = cache.keys().next().value;\n if (oldest !== undefined) cache.delete(oldest);\n }\n cache.set(rscUrl, { response, timestamp: Date.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 for referential stability (useSyncExternalStore\n// compares snapshots with Object.is — new URLSearchParams instances are\n// never equal, which would cause infinite re-renders).\nlet _cachedSearch = !isServer ? window.location.search : \"\";\nlet _cachedSearchParams: URLSearchParams = new URLSearchParams(_cachedSearch);\n\nfunction getSearchParamsSnapshot(): URLSearchParams {\n const current = window.location.search;\n if (current !== _cachedSearch) {\n _cachedSearch = current;\n _cachedSearchParams = new URLSearchParams(current);\n }\n return _cachedSearchParams;\n}\n\n// Same for pathname — cache the string for referential stability\nlet _cachedPathname = !isServer ? stripBasePath(window.location.pathname) : \"/\";\n\nfunction getPathnameSnapshot(): string {\n const current = stripBasePath(window.location.pathname);\n if (current !== _cachedPathname) {\n _cachedPathname = current;\n }\n return _cachedPathname;\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).\nlet _clientParams: Record<string, string | string[]> = {};\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 }\n}\n\n/** Get the current client params (for testing referential stability). */\nexport function getClientParams(): Record<string, string | string[]> {\n return _clientParams;\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 (cb: () => void) => { _listeners.add(cb); return () => { _listeners.delete(cb); }; },\n getPathnameSnapshot,\n () => _getServerContext()?.pathname ?? \"/\",\n );\n}\n\n/**\n * Returns the current search params as a read-only URLSearchParams.\n */\nexport function useSearchParams(): URLSearchParams {\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()?.searchParams ?? new URLSearchParams();\n }\n return React.useSyncExternalStore(\n (cb: () => void) => { _listeners.add(cb); return () => { _listeners.delete(cb); }; },\n getSearchParamsSnapshot,\n () => _getServerContext()?.searchParams ?? new URLSearchParams(),\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 ?? {}) as T;\n }\n return _clientParams as T;\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 = !isServer\n ? window.history.replaceState.bind(window.history)\n : (null as unknown as typeof window.history.replaceState);\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 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 Promise.resolve().then(() => {\n const pending: Promise<void> | null = (window as any).__VINEXT_RSC_PENDING__ ?? null;\n\n if (pending) {\n // Wait for the RSC navigation to finish rendering, then scroll.\n 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 // External URLs: use full page navigation\n if (isExternalUrl(href)) {\n if (mode === \"replace\") {\n window.location.replace(href);\n } else {\n window.location.assign(href);\n }\n return;\n }\n\n const fullHref = withBasePath(href);\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 as any).__VINEXT_RSC_NAVIGATE__ === \"function\") {\n await (window as any).__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's useRouter — returns push/replace/back/forward/refresh.\n * Different from Pages Router's useRouter (next/router).\n */\nexport function useRouter() {\n const router = {\n push(href: string, options?: { scroll?: boolean }): void {\n if (isServer) return;\n navigateImpl(href, \"push\", options?.scroll !== false);\n },\n replace(href: string, options?: { scroll?: boolean }): void {\n if (isServer) return;\n 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 as any).__VINEXT_RSC_NAVIGATE__ === \"function\") {\n (window as any).__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 = withBasePath(href);\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 priority: \"low\" as RequestInit[\"priority\"],\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 }).catch(() => {\n // Network error: allow retry on next prefetch() call\n prefetched.delete(rscUrl);\n });\n },\n };\n return router;\n}\n\n/**\n * Returns the active child segment one level below the layout where it's called.\n *\n * In Next.js, this is layout-aware: it returns the segment relative to the\n * nearest parent layout. In our implementation, we approximate by returning\n * the first segment after a specified parallel route key, or the first segment\n * of the pathname. Returns null if at the leaf (no child segments).\n *\n * @param parallelRoutesKey - Which parallel route to read (default: \"children\")\n */\nexport function useSelectedLayoutSegment(\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 * In Next.js, this returns the full array of segments from the current\n * layout down to the leaf page. Each layout in the tree wraps its children\n * with a LayoutSegmentProvider that records the URL segment depth at that\n * level. This hook reads that depth from context and slices the pathname\n * segments accordingly.\n *\n * @param parallelRoutesKey - Which parallel route to read (default: \"children\")\n */\nexport function useSelectedLayoutSegments(\n _parallelRoutesKey?: string,\n): string[] {\n const pathname = usePathname();\n const depth = useLayoutSegmentDepth();\n const segments = pathname.split(\"/\").filter(Boolean);\n return segments.slice(depth);\n}\n\n/**\n * ReadonlyURLSearchParams — type alias matching Next.js.\n * In Next.js this prevents mutation, but since URLSearchParams is the underlying\n * type in our implementation, we export it as-is for type compatibility.\n */\nexport type ReadonlyURLSearchParams = URLSearchParams;\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 any).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 any).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 * Throw a redirect. Caught by the framework to send a redirect response.\n */\nexport function redirect(url: string, type?: \"replace\" | \"push\" | RedirectType): never {\n const error = new Error(`NEXT_REDIRECT:${url}`);\n (error as any).digest = `NEXT_REDIRECT;${type ?? \"replace\"};${encodeURIComponent(url)}`;\n throw error;\n}\n\n/**\n * Trigger a permanent redirect (308).\n */\nexport function permanentRedirect(url: string): never {\n const error = new Error(`NEXT_REDIRECT:${url}`);\n (error as any).digest = `NEXT_REDIRECT;replace;${encodeURIComponent(url)};308`;\n throw error;\n}\n\n/**\n * Trigger a not-found response (404). Caught by the framework.\n */\nexport function notFound(): never {\n const error = new Error(\"NEXT_NOT_FOUND\");\n (error as any).digest = `${HTTP_ERROR_FALLBACK_ERROR_CODE};404`;\n throw error;\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 const error = new Error(\"NEXT_FORBIDDEN\");\n (error as any).digest = `${HTTP_ERROR_FALLBACK_ERROR_CODE};403`;\n throw error;\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 const error = new Error(\"NEXT_UNAUTHORIZED\");\n (error as any).digest = `${HTTP_ERROR_FALLBACK_ERROR_CODE};401`;\n throw error;\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"]}
|
package/dist/shims/router.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ interface RouterEvents {
|
|
|
62
62
|
* Same logic as Link's applyLocaleToHref but reads from window globals.
|
|
63
63
|
*/
|
|
64
64
|
export declare function applyNavigationLocale(url: string, locale?: string): string;
|
|
65
|
-
/** Check if a URL is external */
|
|
65
|
+
/** Check if a URL is external (any URL scheme per RFC 3986, or protocol-relative) */
|
|
66
66
|
export declare function isExternalUrl(url: string): boolean;
|
|
67
67
|
/** Check if a href is only a hash change relative to the current URL */
|
|
68
68
|
export declare function isHashOnlyChange(href: string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/shims/router.ts"],"names":[],"mappings":"AA0BA,KAAK,sBAAsB,GAAG,CAAC,KAAK,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAA;CAAE,KAAK,OAAO,CAAC;AAE7G,UAAU,UAAU;IAClB,uBAAuB;IACvB,QAAQ,EAAE,M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iBAAiB;mBAoC1D,MAAM,GAAG,SAAS,QAAQ,MAAM,YAAY,iBAAiB;;;oBAqC5D,MAAM;yBASP,sBAAsB;;CAI5C,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/shims/router.js
CHANGED
|
@@ -67,9 +67,9 @@ export function applyNavigationLocale(url, locale) {
|
|
|
67
67
|
return url;
|
|
68
68
|
return `/${locale}${url.startsWith("/") ? url : `/${url}`}`;
|
|
69
69
|
}
|
|
70
|
-
/** Check if a URL is external */
|
|
70
|
+
/** Check if a URL is external (any URL scheme per RFC 3986, or protocol-relative) */
|
|
71
71
|
export function isExternalUrl(url) {
|
|
72
|
-
return
|
|
72
|
+
return /^[a-z][a-z0-9+.-]*:/i.test(url) || url.startsWith("//");
|
|
73
73
|
}
|
|
74
74
|
/** Check if a href is only a hash change relative to the current URL */
|
|
75
75
|
export function isHashOnlyChange(href) {
|