@rsc-kit/core 0.16.2 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/appAssets.d.ts +4 -1
  2. package/dist/appAssets.js +55 -19
  3. package/dist/appAssets.js.map +1 -1
  4. package/dist/buildReport.d.ts +6 -1
  5. package/dist/buildReport.js +16 -18
  6. package/dist/buildReport.js.map +1 -1
  7. package/dist/cache.js +8 -4
  8. package/dist/cache.js.map +1 -1
  9. package/dist/clientEntries.d.ts +32 -0
  10. package/dist/clientEntries.js +107 -0
  11. package/dist/clientEntries.js.map +1 -0
  12. package/dist/clientImports.d.ts +36 -0
  13. package/dist/clientImports.js +36 -0
  14. package/dist/clientImports.js.map +1 -0
  15. package/dist/devReload.d.ts +19 -0
  16. package/dist/devReload.js +32 -0
  17. package/dist/devReload.js.map +1 -0
  18. package/dist/js/Form.js +54 -6
  19. package/dist/js/Form.js.map +1 -1
  20. package/dist/js/Link.d.ts +0 -3
  21. package/dist/js/Link.js +3 -6
  22. package/dist/js/Link.js.map +1 -1
  23. package/dist/js/SegmentBoundary.d.ts +38 -2
  24. package/dist/js/SegmentBoundary.js +51 -13
  25. package/dist/js/SegmentBoundary.js.map +1 -1
  26. package/dist/js/createViteRscApp.js +72 -11
  27. package/dist/js/createViteRscApp.js.map +1 -1
  28. package/dist/js/devNotice.d.ts +13 -0
  29. package/dist/js/devNotice.js +55 -0
  30. package/dist/js/devNotice.js.map +1 -0
  31. package/dist/js/fallbackReport.d.ts +2 -0
  32. package/dist/js/fallbackReport.js +51 -0
  33. package/dist/js/fallbackReport.js.map +1 -0
  34. package/dist/js/navigate.d.ts +1 -1
  35. package/dist/js/navigate.js +55 -23
  36. package/dist/js/navigate.js.map +1 -1
  37. package/dist/js/segmentStore.d.ts +2 -0
  38. package/dist/js/segmentStore.js +21 -1
  39. package/dist/js/segmentStore.js.map +1 -1
  40. package/dist/js/staleAssets.d.ts +17 -0
  41. package/dist/js/staleAssets.js +48 -0
  42. package/dist/js/staleAssets.js.map +1 -0
  43. package/dist/js/standardSchema.d.ts +6 -0
  44. package/dist/js/standardSchema.js +19 -1
  45. package/dist/js/standardSchema.js.map +1 -1
  46. package/dist/js/useLinkStatus.d.ts +14 -1
  47. package/dist/js/useLinkStatus.js +15 -1
  48. package/dist/js/useLinkStatus.js.map +1 -1
  49. package/dist/js/useSearchParams.d.ts +6 -0
  50. package/dist/js/useSearchParams.js +16 -3
  51. package/dist/js/useSearchParams.js.map +1 -1
  52. package/dist/metadata.d.ts +94 -15
  53. package/dist/metadata.js.map +1 -1
  54. package/dist/metadataRoutes.d.ts +41 -0
  55. package/dist/metadataRoutes.js +138 -0
  56. package/dist/metadataRoutes.js.map +1 -0
  57. package/dist/prerender.js +43 -10
  58. package/dist/prerender.js.map +1 -1
  59. package/dist/reactCache.d.ts +1 -0
  60. package/dist/reactCache.js +52 -0
  61. package/dist/reactCache.js.map +1 -0
  62. package/dist/request.d.ts +18 -1
  63. package/dist/request.js +91 -5
  64. package/dist/request.js.map +1 -1
  65. package/dist/useSsr.d.ts +19 -0
  66. package/dist/useSsr.js +104 -0
  67. package/dist/useSsr.js.map +1 -0
  68. package/dist/vite.d.ts +48 -11
  69. package/dist/vite.js +526 -26
  70. package/dist/vite.js.map +1 -1
  71. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"navigate.js","sourceRoot":"","sources":["../../src/js/navigate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAClD,6EAA6E;AAC7E,qDAAqD;AACrD,OAAO,EAAE,UAAU,EAAE,YAAY,IAAI,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAwCtF,IAAI,OAAO,G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C,MAAM,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,IAAI,aAAa,CAAC,GAAG,CAAC;QAAE,OAAO;IAE/B,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IAC1C,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IACrD,MAAM,UAAU,GAAG,mBAAmB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAErD,IAAI,CAAC,UAAU;QAAE,OAAO;IAExB,mBAAmB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACrC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACvB,UAAU,CAAC,KAAK,EAAE,CAAC;AACrB,CAAC","sourcesContent":["/**\n * Core SPA navigation engine for RSC.\n *\n * Uses module-level state (singleton in the browser bundle).\n * The Flight deserializer is injected by createViteRscApp to avoid\n * duplicate bundling of react-server-dom-webpack.\n */\n\nimport { isSafeRedirect } from '../safeUrl.js'\nimport type { Href } from '../routes.js'\nimport { reportReachable } from \"./onlineStore\";\nimport { clearSlots, setSlot } from \"./slotStore\";\n// Shared with the host: it stores a page under this key and the client looks\n// under it, so the format cannot live in two places.\nimport { matchRoute, retentionKey as retentionKeyFor, sharedDepth } from \"../routing\";\nimport type { ManifestRoute } from \"../manifest\";\n\ntype ReactNode = unknown;\ntype Deserializer = (stream: ReadableStream, options: Record<string, unknown>) => Promise<ReactNode>;\ntype CallServerFn = (id: string, args: unknown[]) => Promise<unknown>;\n\ninterface CacheEntry {\n tree: Promise<ReactNode>;\n expiresAt: number;\n /**\n * What the server said about the payload. A prefetch is a real request, so\n * it comes back partial like any other — losing that and treating it as a\n * whole document replaces the root with a page that has no layouts.\n */\n segmentDepth: number;\n layouts: string[] | null;\n /**\n * The slot this payload fills, when it is one region rather than a segment.\n *\n * A prefetch is a real request and comes back as whatever the host answers.\n * An interception answers with the interceptor alone, and an entry that\n * forgets that is applied as a whole document — so a hovered modal link\n * renders the modal *as* the page, with nothing around it. Only after a\n * hover, which is why a scripted click never finds it.\n */\n slot: string | null;\n /**\n * The chain held when this was prefetched. A partial payload is only valid\n * against the chain it was rendered for; navigate somewhere else first and\n * it no longer composes.\n */\n heldWhenFetched: string;\n}\n\ninterface InterceptEntry {\n urlPattern: string;\n slot: string;\n}\n\nlet version = \"\";\nlet onNavigate: ((tree: ReactNode, key: string, segmentDepth: number) => void) | null = null;\nlet onRestore: ((key: string, maxAge?: number) => boolean) | null = null;\n\n/**\n * How stale a held page may be and still be revealed by a link.\n *\n * The back button ignores this: it names a moment, and the page from that\n * moment is the right answer however old. A link says \"go here\", so there is a\n * point past which answering with what you saw before is stale data presented\n * as fresh. Thirty seconds covers leaving a form to check something and coming\n * straight back, which is the case this exists for.\n */\nlet revealWithin = 30_000;\n\nexport function setRevealWindow(ms: number): void {\n revealWithin = ms;\n}\nlet flightDeserializer: Deserializer | null = null;\nlet callServerFn: CallServerFn | null = null;\nlet activeController: AbortController | null = null;\nconst cache = new Map<string, CacheEntry>();\n/** In-flight prefetches, so one the pointer moved away from can be dropped. */\nconst prefetchControllers = new Map<string, AbortController>();\nlet interceptManifest: InterceptEntry[] = [];\n\n// The layout chain currently mounted, outermost first. Sent so the server can\n// skip re-rendering the layouts still on screen.\nlet heldLayouts: string[] = [];\n\n/**\n * The boundary depth an interception was rendered at, while one is showing.\n *\n * An interceptor replaces a slot on the layout that declares it, so leaving the\n * intercepted view has to re-render that layout for the slot to go back to its\n * default. Left to itself the next navigation shares the whole chain, replaces\n * only the page below it, and the modal stays open over the new one.\n */\nlet interceptedAtDepth: number | null = null;\n\n/**\n * The url showing underneath an open interception.\n *\n * An interception puts something in a slot on a page that stays where it is,\n * so closing it is not a navigation at all — the page beneath was never\n * replaced. Remembering which url that is means going back to it costs\n * nothing, rather than fetching and rebuilding a page that is already on\n * screen with everything the user typed into it.\n */\nlet interceptedOver: string | null = null;\n\nconst DEFAULT_PREFETCH_TTL = 30_000;\n\n/**\n * How many prefetched payloads are kept. Entries carry a TTL but were only\n * dropped when read again, so a long session hovering its way through a big\n * nav held every payload it had ever fetched. On insert, anything expired\n * goes, and past the cap the oldest goes - insertion order is age.\n */\nconst MAX_CACHED = 50;\n\nfunction makeRoom(): void {\n const now = Date.now();\n\n for (const [key, entry] of cache) {\n if (entry.expiresAt <= now && !prefetchControllers.has(key)) cache.delete(key);\n }\n\n while (cache.size >= MAX_CACHED) {\n const oldest = cache.keys().next().value as string | undefined;\n\n if (oldest === undefined) break;\n\n prefetchControllers.get(oldest)?.abort();\n prefetchControllers.delete(oldest);\n cache.delete(oldest);\n }\n}\n\n/**\n * Where a payload lives when there is no server to negotiate with.\n *\n * Normally the payload and the page share a url and are told apart by the\n * X-RSC header. A static host cannot vary by header — it serves one file per\n * url — so an exported build gives payloads their own addresses and the client\n * asks for those instead.\n */\nlet staticPayloadSuffix: string | null = null;\n\n/**\n * The route table, on a static host only.\n *\n * A server works out how much of the page to send by comparing the chain the\n * client sent with the route's own, and says so in a header. A file server\n * does neither — so on an exported site the client has to know the target's\n * layout chain before it asks, or every navigation takes the whole document\n * and replaces the root, which unmounts everything retained behind it.\n *\n * Inlined into the browser entry by the build, so it costs no request.\n */\nlet staticRoutes: ManifestRoute[] | null = null;\n\nexport function setStaticRoutes(routes: ManifestRoute[]): void {\n staticRoutes = routes;\n}\n\n/**\n * The layout chain of the page loaded from a file, since no header said.\n *\n * Without this the client believes it holds nothing, every navigation asks\n * for a whole document, and the depth variants sitting beside it are never\n * requested — the export looks correct and retention silently never happens.\n */\nexport function seedStaticChain(url: string): boolean {\n const segments = staticSegments(url);\n\n if (!segments) return false;\n\n heldLayouts = segments.chain;\n\n return true;\n}\n\n/**\n * The depth an exported payload should be asked for, and the chain it leaves\n * mounted — the two things a header would otherwise have carried.\n */\nfunction staticSegments(\n url: string,\n held: string[] = heldLayouts,\n): { depth: number; chain: string[] } | null {\n if (staticRoutes === null) return null;\n\n const path = new URL(url, window.location.origin).pathname;\n const match = matchRoute({ routes: staticRoutes } as never, path);\n\n if (!match) return null;\n\n return {\n // Against the chain the request is made with, never against whatever is\n // mounted by the time the answer arrives. A prefetch is fetched against\n // one chain and applied later, and reading live state here labels its\n // payload with a depth it was not rendered for.\n depth: sharedDepth(held.join(\",\"), match.route.layouts),\n // Copied: this is the build's table, and the caller assigns it to the\n // chain it holds — handing out the array itself makes the two the same\n // object.\n chain: [...match.route.layouts],\n };\n}\n\nexport function setStaticPayloads(suffix: string | null): void {\n staticPayloadSuffix = suffix;\n}\n\n/** The url to request a payload from, which is the page's own unless exported. */\nexport function payloadUrl(url: string, held: string[] = heldLayouts): string {\n if (staticPayloadSuffix === null) return url;\n\n const parsed = new URL(url, window.location.origin);\n const path = parsed.pathname.replace(/\\/+$/, \"\");\n const segments = staticSegments(url, held);\n\n // The variant for exactly the depth this client shares. Asking for the whole\n // document when a segment would do is not merely wasteful: it replaces the\n // root, and replacing the root throws away every page retained behind it.\n const name =\n segments && segments.depth > 0\n ? staticPayloadSuffix.replace(/^index\\./, `index.seg${segments.depth}.`)\n : staticPayloadSuffix;\n\n return `${path}/${name}${parsed.search}`;\n}\n\n/**\n * What a static payload was fetched as, recorded against its own response.\n *\n * The depth asked for and the depth applied have to be the same number. Worked\n * out separately at the two call sites they can disagree — and a payload\n * rendered whole but applied as a segment nests a boundary inside itself,\n * which does not error, it recurses until the renderer stops responding.\n */\nconst staticFetches = new WeakMap<Response, { depth: number; chain: string[] }>();\n\nexport function setVersion(v: string): void {\n version = v;\n}\n\n/**\n * The layout chain the client is holding.\n *\n * Seeded from the initial page's response and updated on every navigation, so\n * the next request can say what is already mounted.\n */\nexport function setHeldLayouts(chain: string[]): void {\n heldLayouts = chain;\n}\n\nexport function getHeldLayouts(): string[] {\n return heldLayouts;\n}\n\nexport function setNavigateHandler(fn: (tree: ReactNode, key: string, segmentDepth: number) => void): void {\n onNavigate = fn;\n}\n\n/**\n * How the router reveals a page that is still mounted behind the current one.\n *\n * Returning true means the page was restored with its client state intact and\n * no request was made.\n */\nexport function setRestoreHandler(fn: (key: string, maxAge?: number) => boolean): void {\n onRestore = fn;\n}\n\nexport function setDeserializer(fn: Deserializer): void {\n flightDeserializer = fn;\n}\n\nexport function setCallServer(fn: CallServerFn): void {\n callServerFn = fn;\n}\n\nexport function setInterceptManifest(entries: InterceptEntry[]): void {\n interceptManifest = entries;\n}\n\n/**\n * Check if a URL matches any intercept pattern.\n * Returns the matching slot name, or null if no match.\n */\nfunction matchIntercept(url: string): string | null {\n if (interceptManifest.length === 0) return null;\n\n let pathname: string;\n try {\n pathname = new URL(url, window.location.origin).pathname;\n } catch {\n pathname = url.split(\"?\")[0];\n }\n\n for (const entry of interceptManifest) {\n // urlPattern already has a leading slash (e.g. \"/docs/item/[id]\")\n const regex = new RegExp(\n \"^\" +\n entry.urlPattern\n .replace(/\\[\\.\\.\\.(\\w+)\\]/g, \"(.+)\")\n .replace(/\\[(\\w+)\\]/g, \"([^/]+)\") +\n \"$\"\n );\n\n if (regex.test(pathname)) {\n return entry.slot;\n }\n }\n\n return null;\n}\n\nexport function renderTree(tree: ReactNode): void {\n onNavigate?.(tree, retentionKey(window.location.href, null), 0);\n}\n\n/**\n * Identity of a page for retention purposes.\n *\n * Path and query only: a hash is a position within the same page, and an\n * intercepted route is a different rendering of the same URL, so it retains\n * separately from the full page.\n */\nexport function retentionKey(url: string, interceptSlot: string | null): string {\n let path: string;\n\n try {\n const parsed = new URL(url, window.location.origin);\n path = parsed.pathname + parsed.search;\n } catch {\n path = url.split(\"#\")[0];\n }\n\n return retentionKeyFor(path, interceptSlot);\n}\n\nexport function getCallServer(): CallServerFn {\n if (!callServerFn) {\n throw new Error(\"callServer not initialized. Ensure createViteRscApp() has been called.\");\n }\n return callServerFn;\n}\n\nfunction fetchRscPayload(\n url: string,\n signal?: AbortSignal,\n interceptSlot?: string,\n refererUrl?: string,\n chain: string[] = heldLayouts,\n // A prefetch is speculative and a navigation is not, but on the wire they\n // were identical — so a click could queue behind several prefetches the user\n // had already moved past. Over HTTP/1.1 a browser opens ~6 connections per\n // origin, which a sweep across a nav bar fills on its own.\n priority: \"high\" | \"low\" = \"high\",\n): Promise<Response> {\n const headers: Record<string, string> = {\n \"X-RSC\": \"true\",\n \"X-RSC-Version\": version,\n };\n\n if (chain.length) {\n headers[\"X-RSC-Segments\"] = chain.join(\",\");\n }\n\n if (interceptSlot) {\n headers[\"X-RSC-Intercept\"] = interceptSlot;\n }\n\n if (refererUrl) {\n headers[\"X-RSC-Referer\"] = refererUrl;\n }\n\n // `priority` is not in every lib.dom yet; browsers without it ignore it.\n const asked = staticSegments(url, chain);\n const request = fetch(payloadUrl(url, chain), { headers, signal, priority } as RequestInit).catch((err: unknown) => {\n // Nothing answered at all. An abort is our own doing, not the network's —\n // leaving a link cancels its prefetch, and that must not read as offline.\n if (!(err instanceof DOMException && err.name === \"AbortError\")) {\n reportReachable(false);\n }\n\n throw err;\n });\n\n return request.then(async (response) => {\n // What this payload was asked for, so the apply side cannot work out a\n // different answer from state that has moved on since.\n if (asked) staticFetches.set(response, asked);\n\n // Something answered, whatever it said. A 500 is a reachable server.\n reportReachable(true);\n // Adopt the server's build version from the first response that carries\n // one. Until we know it we send an empty version, which the middleware\n // treats as \"no opinion\"; afterwards a redeploy mid-session answers 409.\n const served = response.headers.get(\"X-RSC-Version\");\n\n if (served && version === \"\") {\n version = served;\n }\n\n if (response.status === 409) {\n const location = response.headers.get(\"X-RSC-Location\");\n // Server-chosen, so checked again here: the engine refuses these at the\n // source, but a host in front of it can put anything on the header.\n window.location.href = isSafeRedirect(location ?? url) ? (location ?? url) : url;\n throw new Error(\"Version mismatch — full reload triggered\");\n }\n\n return response;\n });\n}\n\n/**\n * Deserialize a Flight response into a React tree.\n *\n * Client modules, CSS <link>s and <title>/<meta> all travel inside the Flight\n * payload — @vitejs/plugin-rsc emits stylesheet links as tree elements and\n * resolves client references through its own browser runtime, and React 19\n * hoists document metadata into <head>. Nothing needs injecting from headers.\n */\nfunction deserializeResponse(response: Response): Promise<ReactNode> {\n return flightDeserializer!(response.body!, {\n callServer: callServerFn ?? (async () => {\n throw new Error(\"Server actions not initialized\");\n }),\n });\n}\n\nfunction isExternalUrl(url: string): boolean {\n try {\n return new URL(url, window.location.origin).origin !== window.location.origin;\n } catch {\n return false;\n }\n}\n\n/**\n * Whether a cached payload can be used for a navigation claiming this chain.\n *\n * A partial payload only composes against the chain it was rendered for, so\n * the chain it was fetched against has to be the one the navigation is about\n * to claim — not whatever happens to be mounted.\n */\nfunction isUsable(cached: CacheEntry | undefined, chain: string[]): boolean {\n return (\n cached !== undefined &&\n cached.expiresAt > Date.now() &&\n cached.heldWhenFetched === chain.join(\",\")\n );\n}\n\n/**\n * Whether a navigation to this url would be served from the prefetch cache.\n *\n * Lets a caller decide whether showing an already-fetched page is free. A form\n * uses it to put its target route's shell on screen while the real query runs:\n * worth doing when the shell is in hand, never worth an extra request.\n */\nexport function isPrefetched(url: string): boolean {\n if (isExternalUrl(url)) return false;\n\n const interceptSlot = matchIntercept(url);\n const cacheKey = retentionKeyFor(url, interceptSlot);\n\n return isUsable(cache.get(cacheKey), claimedChain(interceptSlot));\n}\n\n/**\n * The layout chain a navigation to a url will claim.\n *\n * Leaving an interception claims fewer layouts than are held, which is what\n * forces the layout owning the slot to render again so the slot can empty.\n * Both sides have to agree on it: a prefetch recorded against a different\n * chain can never be used, so the close of every modal refetched a payload it\n * had already fetched.\n */\nfunction claimedChain(interceptSlot: string | null): string[] {\n return !interceptSlot && interceptedAtDepth !== null\n ? heldLayouts.slice(0, interceptedAtDepth)\n : heldLayouts;\n}\n\n/**\n * How many redirects a single navigation will follow before giving up.\n *\n * A page that redirects to itself is a mistake someone will make, and without\n * a ceiling it is an unbounded loop of requests rather than an error. The\n * browser's own limit for HTTP redirects is 20; this is smaller because these\n * are full renders, not header exchanges.\n */\nconst MAX_REDIRECTS = 8;\n\n/**\n * Go to a url, the way a Link does.\n *\n * `url` is typed to the routes the build found; cast with `as Href` when the\n * destination is computed rather than written.\n */\nexport async function navigate(\n url: Href,\n opts?: {\n replace?: boolean;\n preserveScroll?: boolean;\n restore?: boolean;\n /** Internal: how many redirects led here. */\n redirectsFollowed?: number;\n }\n): Promise<void> {\n const redirectsFollowed = opts?.redirectsFollowed ?? 0;\n\n if (redirectsFollowed > MAX_REDIRECTS) {\n throw new Error(\n `Too many redirects following a navigation (${MAX_REDIRECTS}); last was ${url}`,\n );\n }\n\n // External URLs can't be fetched (CORS) — go directly to full page navigation\n if (isExternalUrl(url)) {\n window.location.href = url;\n return;\n }\n\n // Hash-only URLs — let the browser handle scrolling natively\n if (url.startsWith(\"#\")) {\n window.location.hash = url;\n return;\n }\n\n // Abort any in-flight navigation\n activeController?.abort();\n\n // If the initial HTML stream is still loading (Suspense completions streaming),\n // stop it so the single-threaded PHP server can handle the new request.\n if (document.readyState === \"loading\") {\n window.stop();\n }\n\n const controller = new AbortController();\n activeController = controller;\n\n // Check if this URL matches an intercept pattern.\n // If so, send the intercept slot + current URL as referer so the server\n // renders the full tree with the interceptor in the right slot.\n const interceptSlot = matchIntercept(url);\n const currentUrl = interceptSlot\n ? window.location.pathname + window.location.search\n : undefined;\n\n const activityKey = retentionKey(url, interceptSlot);\n\n // A page still being held is revealed rather than refetched, whichever\n // gesture asked for it — the back button or a link. Both mean \"the page I\n // was just on\", and having the form you were filling in survive one and not\n // the other is a distinction nobody makes while using the app.\n //\n // The cost is honest: what comes back is the tree from when you left, so its\n // data is from then. Retention is four pages deep, so this reaches only\n // somewhere you were moments ago, and `revalidate()` is how a page says its\n // data has moved on.\n // Closing an interception. The page underneath was never replaced, so this\n // is a matter of emptying the slot — no request, and nothing rebuilt. The\n // form behind the modal is still the one the user was filling in.\n if (\n !interceptSlot &&\n interceptedOver !== null &&\n retentionKey(url, null) === retentionKey(interceptedOver, null)\n ) {\n clearSlots();\n interceptedOver = null;\n interceptedAtDepth = null;\n\n if (opts?.replace) {\n history.replaceState({ rscUrl: url }, \"\", url);\n } else {\n history.pushState({ rscUrl: url }, \"\", url);\n }\n\n window.dispatchEvent(new CustomEvent(\"rsc-navigate\", { detail: url }));\n\n return;\n }\n\n // Not when the target is the page already showing: asking for this page\n // again means asking the server again, and revealing what is already there\n // would make refresh a no-op. Not while an interception is opening or\n // closing either — those rebuild the chain deliberately.\n const askingForThisPage = retentionKey(window.location.href, null) === retentionKey(url, null)\n //\n // And not while an interception is on screen. Leaving a modal has to\n // re-render the layout that owns the slot, because that is what empties it;\n // revealing the page underneath instead leaves the modal sitting over a page\n // whose url has already changed.\n const mayReveal =\n opts?.restore === true ||\n (!askingForThisPage && !interceptSlot && interceptedOver === null && interceptedAtDepth === null)\n\n // Unbounded for the back button, bounded for a link.\n if (mayReveal && onRestore?.(activityKey, opts?.restore ? undefined : revealWithin)) {\n // A restored tree carries its own slot contents, so the flag only has to\n // reflect whether what is now showing is an intercepted view.\n if (!interceptSlot) interceptedAtDepth = null;\n\n // opts?.replace, not opts.replace: this branch used to be reachable only\n // with opts.restore set, so opts was always there. A link reaches it now\n // with nothing passed at all.\n if (opts?.replace) {\n history.replaceState({ rscUrl: url }, \"\", url);\n } else {\n history.pushState({ rscUrl: url }, \"\", url);\n }\n\n window.dispatchEvent(new CustomEvent(\"rsc-navigate\", { detail: url }));\n\n return;\n }\n\n // A prefetched payload was rendered against the chain held at prefetch time.\n let segmentDepth = 0;\n let nextLayouts: string[] | null = null;\n /** The slot this answer fills, when it is one region rather than a segment. */\n let slotPayload: string | null = null;\n /** The cache entry this navigation is using, whose metadata settles with it. */\n let reused: CacheEntry | null = null;\n const previousUrl = window.location.pathname + window.location.search;\n\n try {\n const cacheKey = retentionKeyFor(url, interceptSlot);\n const cached = cache.get(cacheKey);\n let treePromise: Promise<ReactNode>;\n\n const chain = claimedChain(interceptSlot);\n\n // A partial payload only composes against the chain it was rendered for —\n // the one this navigation is about to claim, not whatever is mounted.\n // Hovering a link inside a modal prefetches it against the full chain, so\n // reusing that here would skip the layout holding the modal and leave it\n // open over the page behind it.\n const usable = isUsable(cached, chain);\n\n if (usable) {\n treePromise = cached!.tree;\n // Read after the tree resolves, not now. A prefetch fills these in when\n // its response lands, and a click can land first — hover a modal link\n // and click it quickly and the entry still says depth 0, so the\n // interceptor is applied as a whole document and the modal renders *as*\n // the page. The fields are set before the tree promise resolves, so\n // waiting for it is what makes them true.\n reused = cached!;\n cache.delete(cacheKey);\n } else {\n cache.delete(cacheKey);\n\n const response = await fetchRscPayload(url, controller.signal, interceptSlot ?? undefined, currentUrl, chain);\n\n // The check is for a host that answered the page instead of the\n // payload, which is what a server does when it does not recognise the\n // header. An exported build asks a url that only ever holds a payload,\n // and a file server labels it by extension — commonly\n // application/octet-stream — so the check would reject every navigation\n // and send the browser on a full page load instead.\n // The render asked to go somewhere else, and said so before writing\n // anything — so this is still a navigation, not a page load. A redirect\n // decided later than that cannot travel here; it arrives in the payload\n // as an error digest and RedirectBoundary performs it.\n const redirectTo = response.headers.get(\"X-RSC-Redirect\");\n\n if (redirectTo) {\n // replace: the url that redirected never became a page the user was\n // on, so Back must not return to it and redirect again.\n // Chosen by the server, not written here.\n await navigate(redirectTo as Href, { replace: true, redirectsFollowed: redirectsFollowed + 1 });\n\n return;\n }\n\n const contentType = response.headers.get(\"Content-Type\") ?? \"\";\n\n if (staticPayloadSuffix === null && !contentType.includes(\"text/x-component\")) {\n window.location.href = url;\n return;\n }\n\n // Headers on a server; worked out locally on a static host, where there\n // is nothing to send them.\n const served = staticFetches.get(response) ?? null;\n\n segmentDepth = Number(response.headers.get(\"X-RSC-Segment-Depth\") ?? served?.depth ?? 0) || 0;\n\n // Named region rather than a segment — see the apply below.\n slotPayload = response.headers.get(\"X-RSC-Revalidate\");\n\n const servedLayouts = response.headers.get(\"X-RSC-Layouts\");\n\n if (servedLayouts !== null) {\n nextLayouts = servedLayouts === \"\" ? [] : servedLayouts.split(\",\");\n } else if (served) {\n nextLayouts = served.chain;\n }\n\n treePromise = deserializeResponse(response);\n }\n\n const tree = await treePromise;\n\n if (reused) {\n segmentDepth = reused.segmentDepth;\n nextLayouts = reused.layouts;\n slotPayload = reused.slot;\n }\n\n if (controller.signal.aborted) return;\n\n if (opts?.replace) {\n history.replaceState({ rscUrl: url }, \"\", url);\n } else {\n history.pushState({ rscUrl: url }, \"\", url);\n }\n\n if (nextLayouts !== null) heldLayouts = nextLayouts;\n\n // The answer is one region, not a piece of the page: the host rendered\n // only the interceptor because the page underneath is already mounted and\n // still correct. Putting it in the slot leaves that page — and everything\n // typed into it — exactly as it was.\n if (slotPayload !== null) {\n setSlot(slotPayload, tree as ReactNode);\n interceptedOver = interceptedOver ?? previousUrl;\n interceptedAtDepth = null;\n\n return;\n }\n\n // A slot rendered for the page being left has no claim on the one being\n // arrived at.\n clearSlots();\n\n interceptedOver = null;\n interceptedAtDepth = interceptSlot ? segmentDepth : null;\n\n onNavigate?.(tree, activityKey, segmentDepth);\n\n if (!opts?.preserveScroll && !interceptSlot) {\n // Wait for React to commit the DOM update before scrolling.\n // Intercepted navigations preserve scroll (e.g. modal over current page).\n requestAnimationFrame(() => {\n window.scrollTo(0, 0);\n });\n }\n\n window.dispatchEvent(new CustomEvent(\"rsc-navigate\", { detail: url }));\n } catch (err) {\n if (err instanceof DOMException && err.name === \"AbortError\") return;\n\n // Without this a navigation that fails does nothing observable: the click\n // clears its own pending state and the page stays as it was, with no\n // error, no fallback and nothing for an app to react to. Dispatched before\n // rethrowing, so a programmatic caller still sees the failure.\n window.dispatchEvent(\n new CustomEvent(\"rsc-navigate-error\", { detail: { url, error: err } })\n );\n\n throw err;\n } finally {\n if (activeController === controller) {\n activeController = null;\n }\n }\n}\n\n/**\n * Put something the server re-rendered on screen.\n *\n * The trees arrive with an action's answer rather than being fetched, so this\n * is the same apply path a navigation uses — without a request, a url change\n * or a history entry.\n */\nexport function applyRevalidated(target: string, tree: ReactNode): void {\n const url = window.location.pathname + window.location.search;\n const key = retentionKey(url, null);\n\n if (target === 'all') {\n // Depth 0 replaces the root, which is what re-rendering the layouts means.\n onNavigate?.(tree, key, 0);\n\n return;\n }\n\n if (target === 'page') {\n onNavigate?.(tree, key, heldLayouts.length);\n\n return;\n }\n\n setSlot(target, tree);\n}\n\n/**\n * Ask the server for part of this page again.\n *\n * refresh() the page, leaving the layouts mounted\n * refresh('all') the whole document, layouts included\n * refresh('orders') one parallel slot, by the name its directory gave it\n *\n * The same words an action uses, so a thing can be invalidated from either\n * side. This is the path for a refresh nobody mutated anything to earn — a\n * button, a poll, a message saying that table has moved; what an action\n * invalidated travels back inside the action's own answer instead.\n *\n * A slot is the only region smaller than a page the server can name, so two\n * tables refresh apart from each other only if they are two slots. The page\n * form leaves the layouts alone, which is what makes it cheap and also why a\n * count living in a layout will not move until you ask for 'all'.\n */\nexport async function refresh(target = 'page'): Promise<void> {\n const url = window.location.pathname + window.location.search;\n\n if (target !== 'page' && target !== 'all') {\n const response = await fetch(payloadUrl(url), {\n headers: { \"X-RSC\": \"true\", \"X-RSC-Version\": version, \"X-RSC-Revalidate\": target },\n });\n\n if (!response.ok) {\n throw new Error(`Could not revalidate ${target}: the server answered ${response.status}`);\n }\n\n setSlot(target, await deserializeResponse(response));\n\n return;\n }\n\n const interceptSlot = matchIntercept(url);\n const cacheKey = retentionKeyFor(url, interceptSlot);\n\n // Never from the cache: refreshing asks what the server says now, not what\n // it said a moment ago.\n cache.delete(cacheKey);\n\n if (target === 'all') {\n heldLayouts = [];\n }\n\n // A refresh is not a navigation: the same page stays under the reader, so\n // where they were reading has to survive the tree being replaced.\n //\n // `preserveScroll` is not enough on its own. It stops navigate() scrolling\n // to the top deliberately, and says nothing about the scroll positions\n // *inside* the page. Refreshing everything replaces the root, so every\n // element that scrolls is a new node and starts at zero — a sidebar,\n // a code block, any pane with its own overflow. The window survives because\n // the document element is not the thing being replaced, which is why this\n // looks fine until a page has a second scroller in it.\n const positions = scrollPositions();\n\n await navigate(url as Href, { replace: true, preserveScroll: true });\n\n restoreScroll(positions);\n}\n\ninterface ScrollPosition {\n tag: string;\n top: number;\n left: number;\n}\n\n/** Every element that can scroll, whether or not it currently is. */\nfunction scrollables(): HTMLElement[] {\n return [...document.querySelectorAll<HTMLElement>('*')].filter(\n (el) => el.scrollHeight > el.clientHeight || el.scrollWidth > el.clientWidth,\n );\n}\n\n/**\n * Where everything on the page is scrolled to, in document order.\n *\n * Identified by position in the list rather than by a selector: a refresh\n * re-renders the same page, so the nth scrollable element is the same one, and\n * a selector would have to survive whatever classes the markup happens to use.\n * The tag is carried only to notice when that assumption has broken.\n *\n * Everything that *can* scroll, not everything that *is* scrolled — the two\n * lists have to be built the same way or they do not line up. Recording only\n * the scrolled ones and restoring over the scrollable ones puts a sidebar's\n * position onto whatever element happens to come first, which on any page long\n * enough to scroll is <html>.\n */\nfunction scrollPositions(): ScrollPosition[] {\n return [\n { tag: 'window', top: window.scrollY, left: window.scrollX },\n ...scrollables().map((el) => ({ tag: el.tagName, top: el.scrollTop, left: el.scrollLeft })),\n ];\n}\n\n/**\n * Put the page back where it was, once React has finished replacing it.\n *\n * Applied over several ticks rather than once, because `root.render()`\n * schedules the update instead of performing it: a single pass writes the\n * position onto the nodes that are about to be thrown away, and the ones that\n * replace them start at zero. There is nothing to await — the navigation\n * resolves when the tree is handed to React, not when React has committed it.\n *\n * `setTimeout`, not `requestAnimationFrame`. A hidden tab never runs an\n * animation frame, so a refresh in a background tab — an HMR update, a poll —\n * would leave the scroll state wrong the moment it came back into view. It\n * also makes this untestable in an automated browser, where the tab under test\n * is usually not the visible one.\n */\nconst RESTORE_ATTEMPTS = 5;\n\nfunction restoreScroll(positions: ScrollPosition[]): void {\n const [win, ...inner] = positions;\n\n const apply = (attempt: number) => {\n if (window.scrollY !== win.top || window.scrollX !== win.left) {\n window.scrollTo(win.left, win.top);\n }\n\n const now = scrollables();\n\n for (let i = 0; i < inner.length && i < now.length; i++) {\n // A different element here means the page came back a different shape,\n // and guessing further would scroll something nobody touched.\n if (now[i].tagName !== inner[i].tag) break;\n\n if (inner[i].top !== 0 && now[i].scrollTop !== inner[i].top) now[i].scrollTop = inner[i].top;\n if (inner[i].left !== 0 && now[i].scrollLeft !== inner[i].left) now[i].scrollLeft = inner[i].left;\n }\n\n if (attempt < RESTORE_ATTEMPTS) setTimeout(() => apply(attempt + 1), 16);\n };\n\n apply(1);\n}\n\nexport function prefetch(url: string, cacheForMs?: number): void {\n if (isExternalUrl(url)) return;\n\n const ttl = cacheForMs ?? DEFAULT_PREFETCH_TTL;\n const interceptSlot = matchIntercept(url);\n\n if (interceptSlot) {\n // Intercepted route — only prefetch the intercepted variant\n const currentUrl = window.location.pathname + window.location.search;\n const cacheKey = retentionKeyFor(url, interceptSlot);\n prefetchUrl(cacheKey, url, ttl, interceptSlot, currentUrl);\n } else {\n prefetchUrl(url, url, ttl);\n }\n}\n\nfunction prefetchUrl(\n cacheKey: string,\n url: string,\n ttl: number,\n interceptSlot?: string,\n refererUrl?: string\n): void {\n const chain = claimedChain(interceptSlot ?? null);\n const existing = cache.get(cacheKey);\n\n if (existing && existing.expiresAt > Date.now()) {\n return;\n }\n\n cache.delete(cacheKey);\n makeRoom();\n\n const controller = new AbortController();\n prefetchControllers.set(cacheKey, controller);\n\n const entry: CacheEntry = {\n tree: Promise.resolve(null),\n expiresAt: Date.now() + ttl,\n segmentDepth: 0,\n layouts: null,\n slot: null,\n heldWhenFetched: chain.join(\",\"),\n };\n\n // Low priority: the browser then lets a real navigation overtake a queue of\n // speculative requests instead of serving them in the order they were made.\n entry.tree = fetchRscPayload(url, controller.signal, interceptSlot, refererUrl, chain, \"low\")\n .then((response) => {\n // On a static host there are no headers to read, and dropping the depth\n // is not a small loss: the entry then claims a segment is a whole\n // document, and rendering a layout-less page as the document root does\n // not warn — it hangs the renderer.\n // A prefetch that lands on a redirect is not cached. Following it would\n // navigate on hover, and storing it would hand the click a 204 with no\n // body to deserialize. The click re-requests and redirects properly.\n if (response.headers.get(\"X-RSC-Redirect\")) {\n cache.delete(cacheKey);\n\n return null;\n }\n\n entry.slot = response.headers.get(\"X-RSC-Revalidate\");\n\n const local = staticFetches.get(response) ?? null;\n\n entry.segmentDepth = Number(response.headers.get(\"X-RSC-Segment-Depth\") ?? local?.depth ?? 0) || 0;\n\n const served = response.headers.get(\"X-RSC-Layouts\");\n\n if (served !== null) {\n entry.layouts = served === \"\" ? [] : served.split(\",\");\n } else if (local) {\n entry.layouts = local.chain;\n }\n\n return deserializeResponse(response);\n })\n .catch(() => {\n cache.delete(cacheKey);\n return null;\n })\n .finally(() => {\n // Settled, so there is nothing left to abort. A completed prefetch stays\n // in the cache — only an in-flight one is ever dropped.\n if (prefetchControllers.get(cacheKey) === controller) {\n prefetchControllers.delete(cacheKey);\n }\n });\n\n cache.set(cacheKey, entry);\n}\n\n/**\n * Drop a prefetch that is still in flight — the pointer left the link.\n *\n * The cache entry goes synchronously rather than in the abort's catch: the\n * rejection lands a tick later, and a click in between would find an entry\n * whose tree resolves to null and navigate to a blank page. A prefetch that\n * has already completed is kept; there is no request left to cancel and the\n * payload is still good.\n */\nexport function cancelPrefetch(url: string): void {\n if (isExternalUrl(url)) return;\n\n const interceptSlot = matchIntercept(url);\n const cacheKey = retentionKeyFor(url, interceptSlot);\n const controller = prefetchControllers.get(cacheKey);\n\n if (!controller) return;\n\n prefetchControllers.delete(cacheKey);\n cache.delete(cacheKey);\n controller.abort();\n}\n"]}
1
+ {"version":3,"file":"navigate.js","sourceRoot":"","sources":["../../src/js/navigate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAClD,6EAA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,KAAK,CAAC,GAAG,EAAE;QACV,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;SACD,OAAO,CAAC,GAAG,EAAE;QACZ,yEAAyE;QACzE,wDAAwD;QACxD,IAAI,mBAAmB,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,UAAU,EAAE,CAAC;YACrD,mBAAmB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,IAAI,aAAa,CAAC,GAAG,CAAC;QAAE,OAAO;IAE/B,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IAC1C,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IACrD,MAAM,UAAU,GAAG,mBAAmB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAErD,IAAI,CAAC,UAAU;QAAE,OAAO;IAExB,mBAAmB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACrC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACvB,UAAU,CAAC,KAAK,EAAE,CAAC;AACrB,CAAC","sourcesContent":["/**\n * Core SPA navigation engine for RSC.\n *\n * Uses module-level state (singleton in the browser bundle).\n * The Flight deserializer is injected by createViteRscApp to avoid\n * duplicate bundling of react-server-dom-webpack.\n */\n\nimport { isStaleAssetError } from \"./staleAssets\";\nimport { isSafeRedirect } from \"../safeUrl.js\";\nimport type { Href } from \"../routes.js\";\nimport { reportReachable } from \"./onlineStore\";\nimport { clearSlots, setSlot } from \"./slotStore\";\n// Shared with the host: it stores a page under this key and the client looks\n// under it, so the format cannot live in two places.\nimport {\n matchRoute,\n retentionKey as retentionKeyFor,\n sharedDepth,\n} from \"../routing\";\nimport type { ManifestRoute } from \"../manifest\";\n\ntype ReactNode = unknown;\ntype Deserializer = (\n stream: ReadableStream,\n options: Record<string, unknown>,\n) => Promise<ReactNode>;\ntype CallServerFn = (id: string, args: unknown[]) => Promise<unknown>;\n\ninterface CacheEntry {\n tree: Promise<ReactNode>;\n expiresAt: number;\n /**\n * What the server said about the payload. A prefetch is a real request, so\n * it comes back partial like any other — losing that and treating it as a\n * whole document replaces the root with a page that has no layouts.\n */\n segmentDepth: number;\n layouts: string[] | null;\n /**\n * The slot this payload fills, when it is one region rather than a segment.\n *\n * A prefetch is a real request and comes back as whatever the host answers.\n * An interception answers with the interceptor alone, and an entry that\n * forgets that is applied as a whole document — so a hovered modal link\n * renders the modal *as* the page, with nothing around it. Only after a\n * hover, which is why a scripted click never finds it.\n */\n slot: string | null;\n /**\n * The chain held when this was prefetched. A partial payload is only valid\n * against the chain it was rendered for; navigate somewhere else first and\n * it no longer composes.\n */\n heldWhenFetched: string;\n}\n\ninterface InterceptEntry {\n urlPattern: string;\n slot: string;\n}\n\nlet version = \"\";\nlet onNavigate:\n ((tree: ReactNode, key: string, segmentDepth: number) => void) | null = null;\nlet onRestore: ((key: string, maxAge?: number) => boolean) | null = null;\n\n/**\n * How stale a held page may be and still be revealed by a link.\n *\n * The back button ignores this: it names a moment, and the page from that\n * moment is the right answer however old. A link says \"go here\", so there is a\n * point past which answering with what you saw before is stale data presented\n * as fresh. Thirty seconds covers leaving a form to check something and coming\n * straight back, which is the case this exists for.\n */\nlet revealWithin = 30_000;\n\nexport function setRevealWindow(ms: number): void {\n revealWithin = ms;\n}\nlet flightDeserializer: Deserializer | null = null;\nlet callServerFn: CallServerFn | null = null;\nlet activeController: AbortController | null = null;\nconst cache = new Map<string, CacheEntry>();\n/** In-flight prefetches, so one the pointer moved away from can be dropped. */\nconst prefetchControllers = new Map<string, AbortController>();\nlet interceptManifest: InterceptEntry[] = [];\n\n// The layout chain currently mounted, outermost first. Sent so the server can\n// skip re-rendering the layouts still on screen.\nlet heldLayouts: string[] = [];\n\n/**\n * The boundary depth an interception was rendered at, while one is showing.\n *\n * An interceptor replaces a slot on the layout that declares it, so leaving the\n * intercepted view has to re-render that layout for the slot to go back to its\n * default. Left to itself the next navigation shares the whole chain, replaces\n * only the page below it, and the modal stays open over the new one.\n */\nlet interceptedAtDepth: number | null = null;\n\n/**\n * The url showing underneath an open interception.\n *\n * An interception puts something in a slot on a page that stays where it is,\n * so closing it is not a navigation at all — the page beneath was never\n * replaced. Remembering which url that is means going back to it costs\n * nothing, rather than fetching and rebuilding a page that is already on\n * screen with everything the user typed into it.\n */\nlet interceptedOver: string | null = null;\n\nconst DEFAULT_PREFETCH_TTL = 30_000;\n\n/**\n * How many prefetched payloads are kept. Entries carry a TTL but were only\n * dropped when read again, so a long session hovering its way through a big\n * nav held every payload it had ever fetched. On insert, anything expired\n * goes, and past the cap the oldest goes - insertion order is age.\n */\nconst MAX_CACHED = 50;\n\nfunction makeRoom(): void {\n const now = Date.now();\n\n for (const [key, entry] of cache) {\n if (entry.expiresAt <= now && !prefetchControllers.has(key))\n cache.delete(key);\n }\n\n while (cache.size >= MAX_CACHED) {\n const oldest = cache.keys().next().value as string | undefined;\n\n if (oldest === undefined) break;\n\n prefetchControllers.get(oldest)?.abort();\n prefetchControllers.delete(oldest);\n cache.delete(oldest);\n }\n}\n\n/**\n * Where a payload lives when there is no server to negotiate with.\n *\n * Normally the payload and the page share a url and are told apart by the\n * X-RSC header. A static host cannot vary by header — it serves one file per\n * url — so an exported build gives payloads their own addresses and the client\n * asks for those instead.\n */\nlet staticPayloadSuffix: string | null = null;\n\n/**\n * The route table, on a static host only.\n *\n * A server works out how much of the page to send by comparing the chain the\n * client sent with the route's own, and says so in a header. A file server\n * does neither — so on an exported site the client has to know the target's\n * layout chain before it asks, or every navigation takes the whole document\n * and replaces the root, which unmounts everything retained behind it.\n *\n * Inlined into the browser entry by the build, so it costs no request.\n */\nlet staticRoutes: ManifestRoute[] | null = null;\n\nexport function setStaticRoutes(routes: ManifestRoute[]): void {\n staticRoutes = routes;\n}\n\n/**\n * The layout chain of the page loaded from a file, since no header said.\n *\n * Without this the client believes it holds nothing, every navigation asks\n * for a whole document, and the depth variants sitting beside it are never\n * requested — the export looks correct and retention silently never happens.\n */\nexport function seedStaticChain(url: string): boolean {\n const segments = staticSegments(url);\n\n if (!segments) return false;\n\n heldLayouts = segments.chain;\n\n return true;\n}\n\n/**\n * The depth an exported payload should be asked for, and the chain it leaves\n * mounted — the two things a header would otherwise have carried.\n */\nfunction staticSegments(\n url: string,\n held: string[] = heldLayouts,\n): { depth: number; chain: string[] } | null {\n if (staticRoutes === null) return null;\n\n const path = new URL(url, window.location.origin).pathname;\n const match = matchRoute({ routes: staticRoutes } as never, path);\n\n if (!match) return null;\n\n return {\n // Against the chain the request is made with, never against whatever is\n // mounted by the time the answer arrives. A prefetch is fetched against\n // one chain and applied later, and reading live state here labels its\n // payload with a depth it was not rendered for.\n depth: sharedDepth(held.join(\",\"), match.route.layouts),\n // Copied: this is the build's table, and the caller assigns it to the\n // chain it holds — handing out the array itself makes the two the same\n // object.\n chain: [...match.route.layouts],\n };\n}\n\nexport function setStaticPayloads(suffix: string | null): void {\n staticPayloadSuffix = suffix;\n}\n\n/** The url to request a payload from, which is the page's own unless exported. */\nexport function payloadUrl(url: string, held: string[] = heldLayouts): string {\n if (staticPayloadSuffix === null) return url;\n\n const parsed = new URL(url, window.location.origin);\n const path = parsed.pathname.replace(/\\/+$/, \"\");\n const segments = staticSegments(url, held);\n\n // The variant for exactly the depth this client shares. Asking for the whole\n // document when a segment would do is not merely wasteful: it replaces the\n // root, and replacing the root throws away every page retained behind it.\n const name =\n segments && segments.depth > 0\n ? staticPayloadSuffix.replace(/^index\\./, `index.seg${segments.depth}.`)\n : staticPayloadSuffix;\n\n return `${path}/${name}${parsed.search}`;\n}\n\n/**\n * What a static payload was fetched as, recorded against its own response.\n *\n * The depth asked for and the depth applied have to be the same number. Worked\n * out separately at the two call sites they can disagree — and a payload\n * rendered whole but applied as a segment nests a boundary inside itself,\n * which does not error, it recurses until the renderer stops responding.\n */\nconst staticFetches = new WeakMap<\n Response,\n { depth: number; chain: string[] }\n>();\n\nexport function setVersion(v: string): void {\n version = v;\n}\n\n/**\n * The layout chain the client is holding.\n *\n * Seeded from the initial page's response and updated on every navigation, so\n * the next request can say what is already mounted.\n */\nexport function setHeldLayouts(chain: string[]): void {\n heldLayouts = chain;\n}\n\nexport function getHeldLayouts(): string[] {\n return heldLayouts;\n}\n\nexport function setNavigateHandler(\n fn: (tree: ReactNode, key: string, segmentDepth: number) => void,\n): void {\n onNavigate = fn;\n}\n\n/**\n * How the router reveals a page that is still mounted behind the current one.\n *\n * Returning true means the page was restored with its client state intact and\n * no request was made.\n */\nexport function setRestoreHandler(\n fn: (key: string, maxAge?: number) => boolean,\n): void {\n onRestore = fn;\n}\n\nexport function setDeserializer(fn: Deserializer): void {\n flightDeserializer = fn;\n}\n\nexport function setCallServer(fn: CallServerFn): void {\n callServerFn = fn;\n}\n\nexport function setInterceptManifest(entries: InterceptEntry[]): void {\n interceptManifest = entries;\n}\n\n/**\n * Check if a URL matches any intercept pattern.\n * Returns the matching slot name, or null if no match.\n */\nfunction matchIntercept(url: string): string | null {\n if (interceptManifest.length === 0) return null;\n\n let pathname: string;\n try {\n pathname = new URL(url, window.location.origin).pathname;\n } catch {\n pathname = url.split(\"?\")[0];\n }\n\n for (const entry of interceptManifest) {\n // urlPattern already has a leading slash (e.g. \"/docs/item/[id]\")\n const regex = new RegExp(\n \"^\" +\n entry.urlPattern\n .replace(/\\[\\.\\.\\.(\\w+)\\]/g, \"(.+)\")\n .replace(/\\[(\\w+)\\]/g, \"([^/]+)\") +\n \"$\",\n );\n\n if (regex.test(pathname)) {\n return entry.slot;\n }\n }\n\n return null;\n}\n\nexport function renderTree(tree: ReactNode): void {\n onNavigate?.(tree, retentionKey(window.location.href, null), 0);\n}\n\n/**\n * Identity of a page for retention purposes.\n *\n * Path and query only: a hash is a position within the same page, and an\n * intercepted route is a different rendering of the same URL, so it retains\n * separately from the full page.\n */\nexport function retentionKey(\n url: string,\n interceptSlot: string | null,\n): string {\n let path: string;\n\n try {\n const parsed = new URL(url, window.location.origin);\n path = parsed.pathname + parsed.search;\n } catch {\n path = url.split(\"#\")[0];\n }\n\n return retentionKeyFor(path, interceptSlot);\n}\n\nexport function getCallServer(): CallServerFn {\n if (!callServerFn) {\n throw new Error(\n \"callServer not initialized. Ensure createViteRscApp() has been called.\",\n );\n }\n return callServerFn;\n}\n\nfunction fetchRscPayload(\n url: string,\n signal?: AbortSignal,\n interceptSlot?: string,\n refererUrl?: string,\n chain: string[] = heldLayouts,\n // A prefetch is speculative and a navigation is not, but on the wire they\n // were identical — so a click could queue behind several prefetches the user\n // had already moved past. Over HTTP/1.1 a browser opens ~6 connections per\n // origin, which a sweep across a nav bar fills on its own.\n priority: \"high\" | \"low\" = \"high\",\n): Promise<Response> {\n const headers: Record<string, string> = {\n \"X-RSC\": \"true\",\n \"X-RSC-Version\": version,\n };\n\n if (chain.length) {\n headers[\"X-RSC-Segments\"] = chain.join(\",\");\n }\n\n if (interceptSlot) {\n headers[\"X-RSC-Intercept\"] = interceptSlot;\n }\n\n if (refererUrl) {\n headers[\"X-RSC-Referer\"] = refererUrl;\n }\n\n // `priority` is not in every lib.dom yet; browsers without it ignore it.\n const asked = staticSegments(url, chain);\n const request = fetch(payloadUrl(url, chain), {\n headers,\n signal,\n priority,\n } as RequestInit).catch((err: unknown) => {\n // Nothing answered at all. An abort is our own doing, not the network's —\n // leaving a link cancels its prefetch, and that must not read as offline.\n if (!(err instanceof DOMException && err.name === \"AbortError\")) {\n reportReachable(false);\n }\n\n throw err;\n });\n\n return request.then(async (response) => {\n // What this payload was asked for, so the apply side cannot work out a\n // different answer from state that has moved on since.\n if (asked) staticFetches.set(response, asked);\n\n // Something answered, whatever it said. A 500 is a reachable server.\n reportReachable(true);\n // Adopt the server's build version from the first response that carries\n // one. Until we know it we send an empty version, which the middleware\n // treats as \"no opinion\"; afterwards a redeploy mid-session answers 409.\n const served = response.headers.get(\"X-RSC-Version\");\n\n if (served && version === \"\") {\n version = served;\n }\n\n if (response.status === 409) {\n const location = response.headers.get(\"X-RSC-Location\");\n // Server-chosen, so checked again here: the engine refuses these at the\n // source, but a host in front of it can put anything on the header.\n window.location.href = isSafeRedirect(location ?? url)\n ? (location ?? url)\n : url;\n throw new Error(\"Version mismatch — full reload triggered\");\n }\n\n return response;\n });\n}\n\n/**\n * Deserialize a Flight response into a React tree.\n *\n * Client modules, CSS <link>s and <title>/<meta> all travel inside the Flight\n * payload — @vitejs/plugin-rsc emits stylesheet links as tree elements and\n * resolves client references through its own browser runtime, and React 19\n * hoists document metadata into <head>. Nothing needs injecting from headers.\n */\nfunction deserializeResponse(response: Response): Promise<ReactNode> {\n return flightDeserializer!(response.body!, {\n callServer:\n callServerFn ??\n (async () => {\n throw new Error(\"Server actions not initialized\");\n }),\n });\n}\n\nfunction isExternalUrl(url: string): boolean {\n try {\n return (\n new URL(url, window.location.origin).origin !== window.location.origin\n );\n } catch {\n return false;\n }\n}\n\n/**\n * Whether a cached payload can be used for a navigation claiming this chain.\n *\n * A partial payload only composes against the chain it was rendered for, so\n * the chain it was fetched against has to be the one the navigation is about\n * to claim — not whatever happens to be mounted.\n */\nfunction isUsable(cached: CacheEntry | undefined, chain: string[]): boolean {\n return (\n cached !== undefined &&\n cached.expiresAt > Date.now() &&\n cached.heldWhenFetched === chain.join(\",\")\n );\n}\n\n/**\n * Whether a navigation to this url would be served from the prefetch cache.\n *\n * Lets a caller decide whether showing an already-fetched page is free. A form\n * uses it to put its target route's shell on screen while the real query runs:\n * worth doing when the shell is in hand, never worth an extra request.\n */\nexport function isPrefetched(url: string): boolean {\n if (isExternalUrl(url)) return false;\n\n const interceptSlot = matchIntercept(url);\n const cacheKey = retentionKeyFor(url, interceptSlot);\n\n return isUsable(cache.get(cacheKey), claimedChain(interceptSlot));\n}\n\n/**\n * The layout chain a navigation to a url will claim.\n *\n * Leaving an interception claims fewer layouts than are held, which is what\n * forces the layout owning the slot to render again so the slot can empty.\n * Both sides have to agree on it: a prefetch recorded against a different\n * chain can never be used, so the close of every modal refetched a payload it\n * had already fetched.\n */\nfunction claimedChain(interceptSlot: string | null): string[] {\n return !interceptSlot && interceptedAtDepth !== null\n ? heldLayouts.slice(0, interceptedAtDepth)\n : heldLayouts;\n}\n\n/**\n * How many redirects a single navigation will follow before giving up.\n *\n * A page that redirects to itself is a mistake someone will make, and without\n * a ceiling it is an unbounded loop of requests rather than an error. The\n * browser's own limit for HTTP redirects is 20; this is smaller because these\n * are full renders, not header exchanges.\n */\nconst MAX_REDIRECTS = 8;\n\n/**\n * Go to a url, the way a Link does.\n *\n * `url` is typed to the routes the build found; cast with `as Href` when the\n * destination is computed rather than written.\n */\nexport async function navigate(\n url: Href,\n opts?: {\n replace?: boolean;\n preserveScroll?: boolean;\n restore?: boolean;\n /** Internal: how many redirects led here. */\n redirectsFollowed?: number;\n },\n): Promise<void> {\n const redirectsFollowed = opts?.redirectsFollowed ?? 0;\n\n if (redirectsFollowed > MAX_REDIRECTS) {\n throw new Error(\n `Too many redirects following a navigation (${MAX_REDIRECTS}); last was ${url}`,\n );\n }\n\n // External URLs can't be fetched (CORS) — go directly to full page navigation\n if (isExternalUrl(url)) {\n window.location.href = url;\n return;\n }\n\n // Hash-only URLs — let the browser handle scrolling natively\n if (url.startsWith(\"#\")) {\n window.location.hash = url;\n return;\n }\n\n // Abort any in-flight navigation\n activeController?.abort();\n\n // If the initial HTML stream is still loading (Suspense completions streaming),\n // stop it so the single-threaded PHP server can handle the new request.\n if (document.readyState === \"loading\") {\n window.stop();\n }\n\n const controller = new AbortController();\n activeController = controller;\n\n // Check if this URL matches an intercept pattern.\n // If so, send the intercept slot + current URL as referer so the server\n // renders the full tree with the interceptor in the right slot.\n const interceptSlot = matchIntercept(url);\n const currentUrl = interceptSlot\n ? window.location.pathname + window.location.search\n : undefined;\n\n const activityKey = retentionKey(url, interceptSlot);\n\n // A page still being held is revealed rather than refetched, whichever\n // gesture asked for it — the back button or a link. Both mean \"the page I\n // was just on\", and having the form you were filling in survive one and not\n // the other is a distinction nobody makes while using the app.\n //\n // The cost is honest: what comes back is the tree from when you left, so its\n // data is from then. Retention is four pages deep, so this reaches only\n // somewhere you were moments ago, and `revalidate()` is how a page says its\n // data has moved on.\n // Closing an interception. The page underneath was never replaced, so this\n // is a matter of emptying the slot — no request, and nothing rebuilt. The\n // form behind the modal is still the one the user was filling in.\n if (\n !interceptSlot &&\n interceptedOver !== null &&\n retentionKey(url, null) === retentionKey(interceptedOver, null)\n ) {\n clearSlots();\n interceptedOver = null;\n interceptedAtDepth = null;\n\n if (opts?.replace) {\n history.replaceState({ rscUrl: url }, \"\", url);\n } else {\n history.pushState({ rscUrl: url }, \"\", url);\n }\n\n window.dispatchEvent(new CustomEvent(\"rsc-navigate\", { detail: url }));\n\n return;\n }\n\n // Not when the target is the page already showing: asking for this page\n // again means asking the server again, and revealing what is already there\n // would make refresh a no-op. Not while an interception is opening or\n // closing either — those rebuild the chain deliberately.\n const askingForThisPage =\n retentionKey(window.location.href, null) === retentionKey(url, null);\n //\n // And not while an interception is on screen. Leaving a modal has to\n // re-render the layout that owns the slot, because that is what empties it;\n // revealing the page underneath instead leaves the modal sitting over a page\n // whose url has already changed.\n const mayReveal =\n opts?.restore === true ||\n (!askingForThisPage &&\n !interceptSlot &&\n interceptedOver === null &&\n interceptedAtDepth === null);\n\n // Unbounded for the back button, bounded for a link.\n if (\n mayReveal &&\n onRestore?.(activityKey, opts?.restore ? undefined : revealWithin)\n ) {\n // A restored tree carries its own slot contents, so the flag only has to\n // reflect whether what is now showing is an intercepted view.\n if (!interceptSlot) interceptedAtDepth = null;\n\n // opts?.replace, not opts.replace: this branch used to be reachable only\n // with opts.restore set, so opts was always there. A link reaches it now\n // with nothing passed at all.\n if (opts?.replace) {\n history.replaceState({ rscUrl: url }, \"\", url);\n } else {\n history.pushState({ rscUrl: url }, \"\", url);\n }\n\n window.dispatchEvent(new CustomEvent(\"rsc-navigate\", { detail: url }));\n\n return;\n }\n\n // A prefetched payload was rendered against the chain held at prefetch time.\n let segmentDepth = 0;\n let nextLayouts: string[] | null = null;\n /** The slot this answer fills, when it is one region rather than a segment. */\n let slotPayload: string | null = null;\n /** The cache entry this navigation is using, whose metadata settles with it. */\n let reused: CacheEntry | null = null;\n const previousUrl = window.location.pathname + window.location.search;\n\n try {\n const cacheKey = retentionKeyFor(url, interceptSlot);\n const cached = cache.get(cacheKey);\n let treePromise: Promise<ReactNode>;\n\n const chain = claimedChain(interceptSlot);\n\n // A partial payload only composes against the chain it was rendered for —\n // the one this navigation is about to claim, not whatever is mounted.\n // Hovering a link inside a modal prefetches it against the full chain, so\n // reusing that here would skip the layout holding the modal and leave it\n // open over the page behind it.\n const usable = isUsable(cached, chain);\n\n if (usable) {\n treePromise = cached!.tree;\n // Read after the tree resolves, not now. A prefetch fills these in when\n // its response lands, and a click can land first — hover a modal link\n // and click it quickly and the entry still says depth 0, so the\n // interceptor is applied as a whole document and the modal renders *as*\n // the page. The fields are set before the tree promise resolves, so\n // waiting for it is what makes them true.\n reused = cached!;\n cache.delete(cacheKey);\n } else {\n cache.delete(cacheKey);\n\n const response = await fetchRscPayload(\n url,\n controller.signal,\n interceptSlot ?? undefined,\n currentUrl,\n chain,\n );\n\n // The check is for a host that answered the page instead of the\n // payload, which is what a server does when it does not recognise the\n // header. An exported build asks a url that only ever holds a payload,\n // and a file server labels it by extension — commonly\n // application/octet-stream — so the check would reject every navigation\n // and send the browser on a full page load instead.\n // The render asked to go somewhere else, and said so before writing\n // anything — so this is still a navigation, not a page load. A redirect\n // decided later than that cannot travel here; it arrives in the payload\n // as an error digest and RedirectBoundary performs it.\n const redirectTo = response.headers.get(\"X-RSC-Redirect\");\n\n if (redirectTo) {\n // replace: the url that redirected never became a page the user was\n // on, so Back must not return to it and redirect again.\n // Chosen by the server, not written here.\n await navigate(redirectTo as Href, {\n replace: true,\n redirectsFollowed: redirectsFollowed + 1,\n });\n\n return;\n }\n\n const contentType = response.headers.get(\"Content-Type\") ?? \"\";\n\n if (\n staticPayloadSuffix === null &&\n !contentType.includes(\"text/x-component\")\n ) {\n window.location.href = url;\n return;\n }\n\n // Headers on a server; worked out locally on a static host, where there\n // is nothing to send them.\n const served = staticFetches.get(response) ?? null;\n\n segmentDepth =\n Number(\n response.headers.get(\"X-RSC-Segment-Depth\") ?? served?.depth ?? 0,\n ) || 0;\n\n // Named region rather than a segment — see the apply below.\n slotPayload = response.headers.get(\"X-RSC-Revalidate\");\n\n const servedLayouts = response.headers.get(\"X-RSC-Layouts\");\n\n if (servedLayouts !== null) {\n nextLayouts = servedLayouts === \"\" ? [] : servedLayouts.split(\",\");\n } else if (served) {\n nextLayouts = served.chain;\n }\n\n treePromise = deserializeResponse(response);\n }\n\n const tree = await treePromise;\n\n if (reused) {\n segmentDepth = reused.segmentDepth;\n nextLayouts = reused.layouts;\n slotPayload = reused.slot;\n }\n\n if (controller.signal.aborted) return;\n\n if (opts?.replace) {\n history.replaceState({ rscUrl: url }, \"\", url);\n } else {\n history.pushState({ rscUrl: url }, \"\", url);\n }\n\n if (nextLayouts !== null) heldLayouts = nextLayouts;\n\n // The answer is one region, not a piece of the page: the host rendered\n // only the interceptor because the page underneath is already mounted and\n // still correct. Putting it in the slot leaves that page — and everything\n // typed into it — exactly as it was.\n if (slotPayload !== null) {\n setSlot(slotPayload, tree as ReactNode);\n interceptedOver = interceptedOver ?? previousUrl;\n interceptedAtDepth = null;\n\n return;\n }\n\n // A slot rendered for the page being left has no claim on the one being\n // arrived at.\n clearSlots();\n\n interceptedOver = null;\n interceptedAtDepth = interceptSlot ? segmentDepth : null;\n\n onNavigate?.(tree, activityKey, segmentDepth);\n\n if (!opts?.preserveScroll && !interceptSlot) {\n // Wait for React to commit the DOM update before scrolling.\n // Intercepted navigations preserve scroll (e.g. modal over current page).\n requestAnimationFrame(() => {\n window.scrollTo(0, 0);\n });\n }\n\n window.dispatchEvent(new CustomEvent(\"rsc-navigate\", { detail: url }));\n } catch (err) {\n if (err instanceof DOMException && err.name === \"AbortError\") return;\n\n // A chunk the deploy no longer serves: the browser would have loaded the\n // document, and the new names with it. Do what it would have done.\n if (isStaleAssetError(err)) {\n window.location.href = url;\n\n return;\n }\n\n // Without this a navigation that fails does nothing observable: the click\n // clears its own pending state and the page stays as it was, with no\n // error, no fallback and nothing for an app to react to. Dispatched before\n // rethrowing, so a programmatic caller still sees the failure.\n window.dispatchEvent(\n new CustomEvent(\"rsc-navigate-error\", { detail: { url, error: err } }),\n );\n\n throw err;\n } finally {\n if (activeController === controller) {\n activeController = null;\n }\n }\n}\n\n/**\n * Put something the server re-rendered on screen.\n *\n * The trees arrive with an action's answer rather than being fetched, so this\n * is the same apply path a navigation uses — without a request, a url change\n * or a history entry.\n */\nexport function applyRevalidated(target: string, tree: ReactNode): void {\n const url = window.location.pathname + window.location.search;\n const key = retentionKey(url, null);\n\n if (target === \"all\") {\n // Depth 0 replaces the root, which is what re-rendering the layouts means.\n onNavigate?.(tree, key, 0);\n\n return;\n }\n\n if (target === \"page\") {\n onNavigate?.(tree, key, heldLayouts.length);\n\n return;\n }\n\n setSlot(target, tree);\n}\n\n/**\n * Ask the server for part of this page again.\n *\n * refresh() the page, leaving the layouts mounted\n * refresh('all') the whole document, layouts included\n * refresh('orders') one parallel slot, by the name its directory gave it\n *\n * The same words an action uses, so a thing can be invalidated from either\n * side. This is the path for a refresh nobody mutated anything to earn — a\n * button, a poll, a message saying that table has moved; what an action\n * invalidated travels back inside the action's own answer instead.\n *\n * A slot is the only region smaller than a page the server can name, so two\n * tables refresh apart from each other only if they are two slots. The page\n * form leaves the layouts alone, which is what makes it cheap and also why a\n * count living in a layout will not move until you ask for 'all'.\n */\nexport async function refresh(target = \"page\"): Promise<void> {\n const url = window.location.pathname + window.location.search;\n\n if (target !== \"page\" && target !== \"all\") {\n const response = await fetch(payloadUrl(url), {\n headers: {\n \"X-RSC\": \"true\",\n \"X-RSC-Version\": version,\n \"X-RSC-Revalidate\": target,\n },\n });\n\n if (!response.ok) {\n throw new Error(\n `Could not revalidate ${target}: the server answered ${response.status}`,\n );\n }\n\n setSlot(target, await deserializeResponse(response));\n\n return;\n }\n\n const interceptSlot = matchIntercept(url);\n const cacheKey = retentionKeyFor(url, interceptSlot);\n\n // Never from the cache: refreshing asks what the server says now, not what\n // it said a moment ago.\n cache.delete(cacheKey);\n\n if (target === \"all\") {\n heldLayouts = [];\n }\n\n // A refresh is not a navigation: the same page stays under the reader, so\n // where they were reading has to survive the tree being replaced.\n //\n // `preserveScroll` is not enough on its own. It stops navigate() scrolling\n // to the top deliberately, and says nothing about the scroll positions\n // *inside* the page. Refreshing everything replaces the root, so every\n // element that scrolls is a new node and starts at zero — a sidebar,\n // a code block, any pane with its own overflow. The window survives because\n // the document element is not the thing being replaced, which is why this\n // looks fine until a page has a second scroller in it.\n const positions = scrollPositions();\n\n await navigate(url as Href, { replace: true, preserveScroll: true });\n\n restoreScroll(positions);\n}\n\ninterface ScrollPosition {\n tag: string;\n top: number;\n left: number;\n}\n\n/** Every element that can scroll, whether or not it currently is. */\nfunction scrollables(): HTMLElement[] {\n return [...document.querySelectorAll<HTMLElement>(\"*\")].filter(\n (el) =>\n el.scrollHeight > el.clientHeight || el.scrollWidth > el.clientWidth,\n );\n}\n\n/**\n * Where everything on the page is scrolled to, in document order.\n *\n * Identified by position in the list rather than by a selector: a refresh\n * re-renders the same page, so the nth scrollable element is the same one, and\n * a selector would have to survive whatever classes the markup happens to use.\n * The tag is carried only to notice when that assumption has broken.\n *\n * Everything that *can* scroll, not everything that *is* scrolled — the two\n * lists have to be built the same way or they do not line up. Recording only\n * the scrolled ones and restoring over the scrollable ones puts a sidebar's\n * position onto whatever element happens to come first, which on any page long\n * enough to scroll is <html>.\n */\nfunction scrollPositions(): ScrollPosition[] {\n return [\n { tag: \"window\", top: window.scrollY, left: window.scrollX },\n ...scrollables().map((el) => ({\n tag: el.tagName,\n top: el.scrollTop,\n left: el.scrollLeft,\n })),\n ];\n}\n\n/**\n * Put the page back where it was, once React has finished replacing it.\n *\n * Applied over several ticks rather than once, because `root.render()`\n * schedules the update instead of performing it: a single pass writes the\n * position onto the nodes that are about to be thrown away, and the ones that\n * replace them start at zero. There is nothing to await — the navigation\n * resolves when the tree is handed to React, not when React has committed it.\n *\n * `setTimeout`, not `requestAnimationFrame`. A hidden tab never runs an\n * animation frame, so a refresh in a background tab — an HMR update, a poll —\n * would leave the scroll state wrong the moment it came back into view. It\n * also makes this untestable in an automated browser, where the tab under test\n * is usually not the visible one.\n */\nconst RESTORE_ATTEMPTS = 5;\n\nfunction restoreScroll(positions: ScrollPosition[]): void {\n const [win, ...inner] = positions;\n\n const apply = (attempt: number) => {\n if (window.scrollY !== win.top || window.scrollX !== win.left) {\n window.scrollTo(win.left, win.top);\n }\n\n const now = scrollables();\n\n for (let i = 0; i < inner.length && i < now.length; i++) {\n // A different element here means the page came back a different shape,\n // and guessing further would scroll something nobody touched.\n if (now[i].tagName !== inner[i].tag) break;\n\n if (inner[i].top !== 0 && now[i].scrollTop !== inner[i].top)\n now[i].scrollTop = inner[i].top;\n if (inner[i].left !== 0 && now[i].scrollLeft !== inner[i].left)\n now[i].scrollLeft = inner[i].left;\n }\n\n if (attempt < RESTORE_ATTEMPTS) setTimeout(() => apply(attempt + 1), 16);\n };\n\n apply(1);\n}\n\nexport function prefetch(url: string, cacheForMs?: number): void {\n if (isExternalUrl(url)) return;\n\n const ttl = cacheForMs ?? DEFAULT_PREFETCH_TTL;\n const interceptSlot = matchIntercept(url);\n\n if (interceptSlot) {\n // Intercepted route — only prefetch the intercepted variant\n const currentUrl = window.location.pathname + window.location.search;\n const cacheKey = retentionKeyFor(url, interceptSlot);\n prefetchUrl(cacheKey, url, ttl, interceptSlot, currentUrl);\n } else {\n prefetchUrl(url, url, ttl);\n }\n}\n\nfunction prefetchUrl(\n cacheKey: string,\n url: string,\n ttl: number,\n interceptSlot?: string,\n refererUrl?: string,\n): void {\n const chain = claimedChain(interceptSlot ?? null);\n const existing = cache.get(cacheKey);\n\n if (existing && existing.expiresAt > Date.now()) {\n return;\n }\n\n cache.delete(cacheKey);\n makeRoom();\n\n const controller = new AbortController();\n prefetchControllers.set(cacheKey, controller);\n\n const entry: CacheEntry = {\n tree: Promise.resolve(null),\n expiresAt: Date.now() + ttl,\n segmentDepth: 0,\n layouts: null,\n slot: null,\n heldWhenFetched: chain.join(\",\"),\n };\n\n // Low priority: the browser then lets a real navigation overtake a queue of\n // speculative requests instead of serving them in the order they were made.\n entry.tree = fetchRscPayload(\n url,\n controller.signal,\n interceptSlot,\n refererUrl,\n chain,\n \"low\",\n )\n .then((response) => {\n // On a static host there are no headers to read, and dropping the depth\n // is not a small loss: the entry then claims a segment is a whole\n // document, and rendering a layout-less page as the document root does\n // not warn — it hangs the renderer.\n // A prefetch that lands on a redirect is not cached. Following it would\n // navigate on hover, and storing it would hand the click a 204 with no\n // body to deserialize. The click re-requests and redirects properly.\n if (response.headers.get(\"X-RSC-Redirect\")) {\n cache.delete(cacheKey);\n\n return null;\n }\n\n entry.slot = response.headers.get(\"X-RSC-Revalidate\");\n\n const local = staticFetches.get(response) ?? null;\n\n entry.segmentDepth =\n Number(\n response.headers.get(\"X-RSC-Segment-Depth\") ?? local?.depth ?? 0,\n ) || 0;\n\n const served = response.headers.get(\"X-RSC-Layouts\");\n\n if (served !== null) {\n entry.layouts = served === \"\" ? [] : served.split(\",\");\n } else if (local) {\n entry.layouts = local.chain;\n }\n\n return deserializeResponse(response);\n })\n .catch(() => {\n cache.delete(cacheKey);\n return null;\n })\n .finally(() => {\n // Settled, so there is nothing left to abort. A completed prefetch stays\n // in the cache — only an in-flight one is ever dropped.\n if (prefetchControllers.get(cacheKey) === controller) {\n prefetchControllers.delete(cacheKey);\n }\n });\n\n cache.set(cacheKey, entry);\n}\n\n/**\n * Drop a prefetch that is still in flight — the pointer left the link.\n *\n * The cache entry goes synchronously rather than in the abort's catch: the\n * rejection lands a tick later, and a click in between would find an entry\n * whose tree resolves to null and navigate to a blank page. A prefetch that\n * has already completed is kept; there is no request left to cancel and the\n * payload is still good.\n */\nexport function cancelPrefetch(url: string): void {\n if (isExternalUrl(url)) return;\n\n const interceptSlot = matchIntercept(url);\n const cacheKey = retentionKeyFor(url, interceptSlot);\n const controller = prefetchControllers.get(cacheKey);\n\n if (!controller) return;\n\n prefetchControllers.delete(cacheKey);\n cache.delete(cacheKey);\n controller.abort();\n}\n"]}
@@ -105,4 +105,6 @@ export declare function restoreSegments(key: string, maxAge?: number): boolean;
105
105
  * claim on being correct for this one.
106
106
  */
107
107
  export declare function clearSegments(): void;
108
+ export declare function noteNavigation(): void;
109
+ export declare function navigatedOnce(): boolean;
108
110
  export {};
@@ -138,7 +138,10 @@ export function restoreSegments(key, maxAge) {
138
138
  if (holding.length === 0)
139
139
  return false;
140
140
  if (maxAge !== undefined) {
141
- const ages = holding.flatMap((d) => depths.get(d).entries.filter((entry) => entry.key === key).map((entry) => entry.at));
141
+ const ages = holding.flatMap((d) => depths
142
+ .get(d)
143
+ .entries.filter((entry) => entry.key === key)
144
+ .map((entry) => entry.at));
142
145
  // The oldest layer decides: revealing a fresh page under a stale layout
143
146
  // would be a chain nobody rendered together.
144
147
  // >= rather than >, so a window of 0 means never rather than "only within
@@ -170,4 +173,21 @@ export function clearSegments() {
170
173
  for (const depth of all)
171
174
  notify(depth);
172
175
  }
176
+ /**
177
+ * Whether a navigation has happened in this document.
178
+ *
179
+ * The first commit after hydration is the boundary taking over its
180
+ * server-rendered children - the same page, re-keyed for retention. A view
181
+ * transition for that commit fades the page into itself: the blank-then-
182
+ * content a first load or a reload showed. Inertia transitions on visits and
183
+ * never on load; so does this. The router notes the first navigation before
184
+ * it updates a segment, and the boundary animates from then on.
185
+ */
186
+ let navigated = false;
187
+ export function noteNavigation() {
188
+ navigated = true;
189
+ }
190
+ export function navigatedOnce() {
191
+ return navigated;
192
+ }
173
193
  //# sourceMapp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AC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;QACzF,MAAM,CAAC,CAAC,CAAC,CAAA;IACX,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;IAC9B,MAAM,CAAC,KAAK,EAAE,CAAA;IACd,KAAK,MAAM,KAAK,IAAI,GAAG;QAAE,MAAM,CAAC,KAAK,CAAC,CAAA;AACxC,CAAC","sourcesContent":["/**\n * What each segment boundary is showing, and what it is keeping alive behind it.\n *\n * A navigation replaces one segment. Keeping the previous one mounted — hidden,\n * not unmounted — is what lets going back restore it with its client state:\n * the half-typed form, the open disclosure, the scrolled list. Unmounting\n * throws all of that away, which is what replacing the root used to do.\n *\n * Entries are keyed by page (the URL, or its intercept variant), so a boundary\n * can hold several and reveal one. Empty is meaningful: a boundary with nothing\n * stored renders the children the server gave it.\n *\n * A store rather than state, and not a preference — three things rule state out.\n * A boundary is inserted between every layout level, so there are several and a\n * navigation targets one by depth; they are separated by server components, so\n * no setter can be threaded down to them, because a function does not cross\n * that boundary; and navigate.ts is a plain module with no component instance\n * to call one on. Addressing a component you hold no reference to is what an\n * external store is for.\n *\n * Underneath it is the wire protocol. A partial navigation sends only the\n * segment that changed — see the X-RSC-Segments headers — so there is nothing\n * for a root to re-render with even if it held the state. Next.js keeps its\n * router in useState and derives every segment from it; that is the same trade\n * in the other direction.\n *\n * What it costs: React pins an external store's updates to synchronous\n * priority, because a store cannot be safely time-sliced. Synchronous is never\n * a transition, and anything that only runs for one — React's <ViewTransition>\n * among them — never ran for a navigation.\n *\n * Which is why SegmentBoundary does not read this with useSyncExternalStore\n * any more. The store still does the addressing, which is the part only it can\n * do; the boundary copies into state, so the render is a transition. See the\n * view transitions guide.\n */\n\ntype Tree = unknown\ntype Listener = () => void\n\ninterface Entry {\n key: string\n tree: Tree\n /**\n * When this tree arrived, so a link can decide whether it is still worth\n * revealing. The back button never asks — it means \"the page I was on\",\n * however long ago that was.\n */\n at: number\n}\n\n/**\n * Immutable: useSyncExternalStore compares snapshots by identity, so a new\n * object per read reads as \"changed every render\" and loops forever. Every\n * mutation replaces this wholesale; nothing edits one in place.\n */\ninterface DepthState {\n readonly entries: readonly Entry[]\n readonly activeKey: string\n /** Most recently shown last; eviction takes from the front. */\n readonly order: readonly string[]\n}\n\n/** Pages kept alive per boundary. Four covers ordinary back-and-forth. */\nexport const RETENTION = 4\n\nconst depths = new Map<number, DepthState>()\nconst listeners = new Map<number, Set<Listener>>()\n\nfunction notify(depth: number): void {\n for (const listener of listeners.get(depth) ?? []) listener()\n}\n\nexport function subscribeToSegment(depth: number, listener: Listener): () => void {\n let set = listeners.get(depth)\n\n if (!set) {\n set = new Set()\n listeners.set(depth, set)\n }\n\n set.add(listener)\n\n return () => {\n set!.delete(listener)\n if (set!.size === 0) listeners.delete(depth)\n }\n}\n\n/** Everything a boundary at this depth needs to render, or null for \"use children\". */\nexport function getSegmentState(depth: number): DepthState | null {\n return depths.get(depth) ?? null\n}\n\n/** Apply the retention window to a candidate state. */\nfunction retain(entries: readonly Entry[], order: readonly string[], activeKey: string): DepthState {\n const kept = order.slice(-RETENTION)\n\n return {\n entries: entries.filter((entry) => kept.includes(entry.key)),\n order: kept,\n activeKey,\n }\n}\n\nfunction put(depth: number, key: string, tree: Tree): void {\n const state = depths.get(depth)\n const entries = [\n ...(state?.entries ?? []).filter((entry) => entry.key !== key),\n { key, tree, at: Date.now() },\n ]\n const order = [...(state?.order ?? []).filter((k) => k !== key), key]\n\n depths.set(depth, retain(entries, order, key))\n}\n\n/**\n * Show `tree` at `depth` for `key`, retaining what was there.\n *\n * Deeper segments belonged to the page being replaced; leaving them would\n * render the previous page inside the new one.\n */\nexport function setSegment(depth: number, key: string, tree: Tree): void {\n put(depth, key, tree)\n\n const stale = [...depths.keys()].filter((d) => d > depth)\n for (const d of stale) depths.delete(d)\n\n notify(depth)\n for (const d of stale) notify(d)\n}\n\n/**\n * Record the children the server rendered, so the page you arrived on can be\n * returned to later. Never changes what is showing.\n */\nexport function seedSegment(depth: number, key: string, tree: Tree): void {\n const state = depths.get(depth)\n\n if (state?.entries.some((entry) => entry.key === key)) return\n\n if (!state) {\n put(depth, key, tree)\n notify(depth)\n\n return\n }\n\n\n // Older than whatever is showing, so it goes to the front of the eviction\n // order — and crucially does not become the active page.\n depths.set(\n depth,\n retain(\n [...state.entries, { key, tree, at: Date.now() }],\n [key, ...state.order.filter((k) => k !== key)],\n state.activeKey,\n ),\n )\n\n notify(depth)\n}\n\n/**\n * Reveal a page the boundaries are still holding, without asking the server.\n *\n * Restoring is anchored on the deepest boundary that can show the page. Deeper\n * ones than that belonged to the page being left — a section with its own\n * layout adds a boundary the page you are going back to never had — so they\n * are dropped, exactly as setSegment drops them. Requiring every boundary to\n * hold the key instead made any such page refuse to restore.\n *\n * Shallower boundaries need no key of their own: their trees contain the\n * deeper boundary, so they delegate to whatever it is showing. One that does\n * hold the key is switched to it, since that is a real change at its level.\n */\n/**\n * Reveal a page still being held, if it is worth revealing.\n *\n * `maxAge` is what a link passes and the back button does not. Going back is\n * unambiguous — it names a moment, and the page from that moment is the right\n * answer however old. A link says \"go here\", and answering it with a tree from\n * twenty minutes ago is stale data presented as fresh, which is the objection\n * this design started with. Recent enough, and it is the same page you were\n * just on, with the form you were filling in still filled in.\n */\nexport function restoreSegments(key: string, maxAge?: number): boolean {\n const holding = [...depths.keys()].filter((d) =>\n depths.get(d)!.entries.some((entry) => entry.key === key),\n )\n\n if (holding.length === 0) return false\n\n if (maxAge !== undefined) {\n const ages = holding.flatMap((d) =>\n depths.get(d)!.entries.filter((entry) => entry.key === key).map((entry) => entry.at),\n )\n\n // The oldest layer decides: revealing a fresh page under a stale layout\n // would be a chain nobody rendered together.\n // >= rather than >, so a window of 0 means never rather than \"only within\n // the same millisecond\".\n if (Date.now() - Math.min(...ages) >= maxAge) return false\n }\n\n const anchor = Math.max(...holding)\n\n for (const d of [...depths.keys()].filter((d) => d > anchor)) {\n depths.delete(d)\n notify(d)\n }\n\n for (const d of holding) {\n const state = depths.get(d)!\n\n depths.set(d, retain(state.entries, [...state.order.filter((k) => k !== key), key], key))\n notify(d)\n }\n\n return true\n}\n\n/**\n * Drop everything, so boundaries fall back to their server-given children.\n *\n * A deployment invalidates them all: a segment from the previous build has no\n * claim on being correct for this one.\n */\nexport function clearSegments(): void {\n const all = [...depths.keys()]\n depths.clear()\n for (const depth of all) notify(depth)\n}\n"]}
1
+ {"version":3,"file":"segmentStore.js","sourceRoot":"","sources":["../../src/js/segmentStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AA4BH,0EAA0E;AAC1E,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC;AAE3B,MAAM,MAAM,GAAG,IAAI,GAAG,EAAsB,CAAC;AAC7C,MAAM,SAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;AAEnD,SAAS,MAAM,CAAC,KAAa;IAC3B,KAAK,MAAM,QAAQ,IAAI,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,KAAa,EACb,QAAkB;IAElB,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAE/B,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;QAChB,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAElB,OAAO,GAAG,EAAE;QACV,GAAI,CAAC,MAAM,CAAC,QA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AAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC;QAC7D,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACjB,MAAM,CAAC,CAAC,CAAC,CAAC;IACZ,CAAC;IAED,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAE,CAAC;QAE7B,MAAM,CAAC,GAAG,CACR,CAAC,EACD,MAAM,CACJ,KAAK,CAAC,OAAO,EACb,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,EAAE,GAAG,CAAC,EAC9C,GAAG,CACJ,CACF,CAAC;QACF,MAAM,CAAC,CAAC,CAAC,CAAC;IACZ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/B,MAAM,CAAC,KAAK,EAAE,CAAC;IACf,KAAK,MAAM,KAAK,IAAI,GAAG;QAAE,MAAM,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;;;GASG;AACH,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB,MAAM,UAAU,cAAc;IAC5B,SAAS,GAAG,IAAI,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["/**\n * What each segment boundary is showing, and what it is keeping alive behind it.\n *\n * A navigation replaces one segment. Keeping the previous one mounted — hidden,\n * not unmounted — is what lets going back restore it with its client state:\n * the half-typed form, the open disclosure, the scrolled list. Unmounting\n * throws all of that away, which is what replacing the root used to do.\n *\n * Entries are keyed by page (the URL, or its intercept variant), so a boundary\n * can hold several and reveal one. Empty is meaningful: a boundary with nothing\n * stored renders the children the server gave it.\n *\n * A store rather than state, and not a preference — three things rule state out.\n * A boundary is inserted between every layout level, so there are several and a\n * navigation targets one by depth; they are separated by server components, so\n * no setter can be threaded down to them, because a function does not cross\n * that boundary; and navigate.ts is a plain module with no component instance\n * to call one on. Addressing a component you hold no reference to is what an\n * external store is for.\n *\n * Underneath it is the wire protocol. A partial navigation sends only the\n * segment that changed — see the X-RSC-Segments headers — so there is nothing\n * for a root to re-render with even if it held the state. Next.js keeps its\n * router in useState and derives every segment from it; that is the same trade\n * in the other direction.\n *\n * What it costs: React pins an external store's updates to synchronous\n * priority, because a store cannot be safely time-sliced. Synchronous is never\n * a transition, and anything that only runs for one — React's <ViewTransition>\n * among them — never ran for a navigation.\n *\n * Which is why SegmentBoundary does not read this with useSyncExternalStore\n * any more. The store still does the addressing, which is the part only it can\n * do; the boundary copies into state, so the render is a transition. See the\n * view transitions guide.\n */\n\ntype Tree = unknown;\ntype Listener = () => void;\n\ninterface Entry {\n key: string;\n tree: Tree;\n /**\n * When this tree arrived, so a link can decide whether it is still worth\n * revealing. The back button never asks — it means \"the page I was on\",\n * however long ago that was.\n */\n at: number;\n}\n\n/**\n * Immutable: useSyncExternalStore compares snapshots by identity, so a new\n * object per read reads as \"changed every render\" and loops forever. Every\n * mutation replaces this wholesale; nothing edits one in place.\n */\ninterface DepthState {\n readonly entries: readonly Entry[];\n readonly activeKey: string;\n /** Most recently shown last; eviction takes from the front. */\n readonly order: readonly string[];\n}\n\n/** Pages kept alive per boundary. Four covers ordinary back-and-forth. */\nexport const RETENTION = 4;\n\nconst depths = new Map<number, DepthState>();\nconst listeners = new Map<number, Set<Listener>>();\n\nfunction notify(depth: number): void {\n for (const listener of listeners.get(depth) ?? []) listener();\n}\n\nexport function subscribeToSegment(\n depth: number,\n listener: Listener,\n): () => void {\n let set = listeners.get(depth);\n\n if (!set) {\n set = new Set();\n listeners.set(depth, set);\n }\n\n set.add(listener);\n\n return () => {\n set!.delete(listener);\n if (set!.size === 0) listeners.delete(depth);\n };\n}\n\n/** Everything a boundary at this depth needs to render, or null for \"use children\". */\nexport function getSegmentState(depth: number): DepthState | null {\n return depths.get(depth) ?? null;\n}\n\n/** Apply the retention window to a candidate state. */\nfunction retain(\n entries: readonly Entry[],\n order: readonly string[],\n activeKey: string,\n): DepthState {\n const kept = order.slice(-RETENTION);\n\n return {\n entries: entries.filter((entry) => kept.includes(entry.key)),\n order: kept,\n activeKey,\n };\n}\n\nfunction put(depth: number, key: string, tree: Tree): void {\n const state = depths.get(depth);\n const entries = [\n ...(state?.entries ?? []).filter((entry) => entry.key !== key),\n { key, tree, at: Date.now() },\n ];\n const order = [...(state?.order ?? []).filter((k) => k !== key), key];\n\n depths.set(depth, retain(entries, order, key));\n}\n\n/**\n * Show `tree` at `depth` for `key`, retaining what was there.\n *\n * Deeper segments belonged to the page being replaced; leaving them would\n * render the previous page inside the new one.\n */\nexport function setSegment(depth: number, key: string, tree: Tree): void {\n put(depth, key, tree);\n\n const stale = [...depths.keys()].filter((d) => d > depth);\n for (const d of stale) depths.delete(d);\n\n notify(depth);\n for (const d of stale) notify(d);\n}\n\n/**\n * Record the children the server rendered, so the page you arrived on can be\n * returned to later. Never changes what is showing.\n */\nexport function seedSegment(depth: number, key: string, tree: Tree): void {\n const state = depths.get(depth);\n\n if (state?.entries.some((entry) => entry.key === key)) return;\n\n if (!state) {\n put(depth, key, tree);\n notify(depth);\n\n return;\n }\n\n // Older than whatever is showing, so it goes to the front of the eviction\n // order — and crucially does not become the active page.\n depths.set(\n depth,\n retain(\n [...state.entries, { key, tree, at: Date.now() }],\n [key, ...state.order.filter((k) => k !== key)],\n state.activeKey,\n ),\n );\n\n notify(depth);\n}\n\n/**\n * Reveal a page the boundaries are still holding, without asking the server.\n *\n * Restoring is anchored on the deepest boundary that can show the page. Deeper\n * ones than that belonged to the page being left — a section with its own\n * layout adds a boundary the page you are going back to never had — so they\n * are dropped, exactly as setSegment drops them. Requiring every boundary to\n * hold the key instead made any such page refuse to restore.\n *\n * Shallower boundaries need no key of their own: their trees contain the\n * deeper boundary, so they delegate to whatever it is showing. One that does\n * hold the key is switched to it, since that is a real change at its level.\n */\n/**\n * Reveal a page still being held, if it is worth revealing.\n *\n * `maxAge` is what a link passes and the back button does not. Going back is\n * unambiguous — it names a moment, and the page from that moment is the right\n * answer however old. A link says \"go here\", and answering it with a tree from\n * twenty minutes ago is stale data presented as fresh, which is the objection\n * this design started with. Recent enough, and it is the same page you were\n * just on, with the form you were filling in still filled in.\n */\nexport function restoreSegments(key: string, maxAge?: number): boolean {\n const holding = [...depths.keys()].filter((d) =>\n depths.get(d)!.entries.some((entry) => entry.key === key),\n );\n\n if (holding.length === 0) return false;\n\n if (maxAge !== undefined) {\n const ages = holding.flatMap((d) =>\n depths\n .get(d)!\n .entries.filter((entry) => entry.key === key)\n .map((entry) => entry.at),\n );\n\n // The oldest layer decides: revealing a fresh page under a stale layout\n // would be a chain nobody rendered together.\n // >= rather than >, so a window of 0 means never rather than \"only within\n // the same millisecond\".\n if (Date.now() - Math.min(...ages) >= maxAge) return false;\n }\n\n const anchor = Math.max(...holding);\n\n for (const d of [...depths.keys()].filter((d) => d > anchor)) {\n depths.delete(d);\n notify(d);\n }\n\n for (const d of holding) {\n const state = depths.get(d)!;\n\n depths.set(\n d,\n retain(\n state.entries,\n [...state.order.filter((k) => k !== key), key],\n key,\n ),\n );\n notify(d);\n }\n\n return true;\n}\n\n/**\n * Drop everything, so boundaries fall back to their server-given children.\n *\n * A deployment invalidates them all: a segment from the previous build has no\n * claim on being correct for this one.\n */\nexport function clearSegments(): void {\n const all = [...depths.keys()];\n depths.clear();\n for (const depth of all) notify(depth);\n}\n\n/**\n * Whether a navigation has happened in this document.\n *\n * The first commit after hydration is the boundary taking over its\n * server-rendered children - the same page, re-keyed for retention. A view\n * transition for that commit fades the page into itself: the blank-then-\n * content a first load or a reload showed. Inertia transitions on visits and\n * never on load; so does this. The router notes the first navigation before\n * it updates a segment, and the boundary animates from then on.\n */\nlet navigated = false;\n\nexport function noteNavigation(): void {\n navigated = true;\n}\n\nexport function navigatedOnce(): boolean {\n return navigated;\n}\n"]}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * A navigation that lands on a chunk that is no longer there.
3
+ *
4
+ * After a deploy the open tab still holds the old page, and its next
5
+ * navigation asks for client components by the old hashed names, which the
6
+ * new deploy does not serve. The dev server does the same when it
7
+ * re-optimises dependencies and answers the old names with 504. Either way
8
+ * the payload arrives and React fails to load the module it names, on a
9
+ * page that was working a click ago.
10
+ *
11
+ * The fix is the one the browser would have applied: load the document again.
12
+ * Once — a second failure on the same url within a few seconds means the
13
+ * deploy is broken, not stale, and reloading forever would hide that.
14
+ */
15
+ export declare function isStaleAssetError(error: unknown): boolean;
16
+ /** True when the page is being reloaded for it; false when the error is something else, or reloading already failed. */
17
+ export declare function recoverFromStaleAssets(error: unknown): boolean;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * A navigation that lands on a chunk that is no longer there.
3
+ *
4
+ * After a deploy the open tab still holds the old page, and its next
5
+ * navigation asks for client components by the old hashed names, which the
6
+ * new deploy does not serve. The dev server does the same when it
7
+ * re-optimises dependencies and answers the old names with 504. Either way
8
+ * the payload arrives and React fails to load the module it names, on a
9
+ * page that was working a click ago.
10
+ *
11
+ * The fix is the one the browser would have applied: load the document again.
12
+ * Once — a second failure on the same url within a few seconds means the
13
+ * deploy is broken, not stale, and reloading forever would hide that.
14
+ */
15
+ const STALE_MODULE = /Failed to fetch dynamically imported module|Importing a module script failed|error loading dynamically imported module|Outdated Optimize Dep|Loading (?:CSS )?chunk/i;
16
+ const RELOADED = "rsc-kit:reloaded";
17
+ const WINDOW_MS = 10_000;
18
+ /**
19
+ * Development only: the shape a page takes when Vite re-optimised the
20
+ * browser's dependencies underneath it. Modules already loaded hold the old
21
+ * React, freshly loaded ones the new; a hook then reads a null dispatcher.
22
+ * The page is over either way; loading it again is what Vite would do next.
23
+ */
24
+ const MIXED_REACT = /Invalid hook call|Cannot read properties of null \(reading 'use[A-Z]\w*'\)/;
25
+ export function isStaleAssetError(error) {
26
+ const message = String(error?.message ?? error);
27
+ if (STALE_MODULE.test(message))
28
+ return true;
29
+ return !!import.meta.env?.DEV && MIXED_REACT.test(message);
30
+ }
31
+ /** True when the page is being reloaded for it; false when the error is something else, or reloading already failed. */
32
+ export function recoverFromStaleAssets(error) {
33
+ if (!isStaleAssetError(error) || typeof window === "undefined")
34
+ return false;
35
+ const mark = `${RELOADED}:${window.location.href}`;
36
+ try {
37
+ const last = Number(sessionStorage.getItem(mark) ?? 0);
38
+ if (Date.now() - last < WINDOW_MS)
39
+ return false;
40
+ sessionStorage.setItem(mark, String(Date.now()));
41
+ }
42
+ catch {
43
+ // No storage: reload anyway, once is the best that can be promised.
44
+ }
45
+ window.location.reload();
46
+ return true;
47
+ }
48
+ //# sourceMappingURL=staleAssets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staleAssets.js","sourceRoot":"","sources":["../../src/js/staleAssets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,YAAY,GAChB,sKAAsK,CAAC;AAEzK,MAAM,QAAQ,GAAG,kBAAkB,CAAC;AACpC,MAAM,SAAS,GAAG,MAAM,CAAC;AAEzB;;;;;GAKG;AACH,MAAM,WAAW,GAAG,4EAA4E,CAAC;AAEjG,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,MAAM,OAAO,GAAG,MAAM,CAAE,KAAqC,EAAE,OAAO,IAAI,KAAK,CAAC,CAAC;IAEjF,IAAI,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IAE5C,OAAO,CAAC,CAAC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC7D,CAAC;AAED,wHAAwH;AACxH,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACnD,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,KAAK,CAAC;IAE7E,MAAM,IAAI,GAAG,GAAG,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IAEnD,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAEvD,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,SAAS;YAAE,OAAO,KAAK,CAAC;QAEhD,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACnD,CAAC;IAAC,MAAM,CAAC;QACP,oEAAoE;IACtE,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAEzB,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["/**\n * A navigation that lands on a chunk that is no longer there.\n *\n * After a deploy the open tab still holds the old page, and its next\n * navigation asks for client components by the old hashed names, which the\n * new deploy does not serve. The dev server does the same when it\n * re-optimises dependencies and answers the old names with 504. Either way\n * the payload arrives and React fails to load the module it names, on a\n * page that was working a click ago.\n *\n * The fix is the one the browser would have applied: load the document again.\n * Once — a second failure on the same url within a few seconds means the\n * deploy is broken, not stale, and reloading forever would hide that.\n */\n\nconst STALE_MODULE =\n /Failed to fetch dynamically imported module|Importing a module script failed|error loading dynamically imported module|Outdated Optimize Dep|Loading (?:CSS )?chunk/i;\n\nconst RELOADED = \"rsc-kit:reloaded\";\nconst WINDOW_MS = 10_000;\n\n/**\n * Development only: the shape a page takes when Vite re-optimised the\n * browser's dependencies underneath it. Modules already loaded hold the old\n * React, freshly loaded ones the new; a hook then reads a null dispatcher.\n * The page is over either way; loading it again is what Vite would do next.\n */\nconst MIXED_REACT = /Invalid hook call|Cannot read properties of null \\(reading 'use[A-Z]\\w*'\\)/;\n\nexport function isStaleAssetError(error: unknown): boolean {\n const message = String((error as { message?: string } | null)?.message ?? error);\n\n if (STALE_MODULE.test(message)) return true;\n\n return !!import.meta.env?.DEV && MIXED_REACT.test(message);\n}\n\n/** True when the page is being reloaded for it; false when the error is something else, or reloading already failed. */\nexport function recoverFromStaleAssets(error: unknown): boolean {\n if (!isStaleAssetError(error) || typeof window === \"undefined\") return false;\n\n const mark = `${RELOADED}:${window.location.href}`;\n\n try {\n const last = Number(sessionStorage.getItem(mark) ?? 0);\n\n if (Date.now() - last < WINDOW_MS) return false;\n\n sessionStorage.setItem(mark, String(Date.now()));\n } catch {\n // No storage: reload anyway, once is the best that can be promised.\n }\n\n window.location.reload();\n\n return true;\n}\n"]}
@@ -1,6 +1,12 @@
1
1
  /**
2
2
  * Validating a form before it is submitted, with whatever library you use.
3
3
  *
4
+ * Not a client module, though a client component is its first caller: the
5
+ * action pipeline validates with it on the server too, and a "use client"
6
+ * directive here turned that call into a client-reference stub - "client
7
+ * reference export 'validateWith' is called on server", on every action
8
+ * with a schema. Pure functions, no React; importable from either side.
9
+ *
4
10
  * Not with an adapter per library: Standard Schema is the contract Zod,
5
11
  * Valibot, ArkType and others already implement, so this speaks to the schema
6
12
  * itself and never imports one. The types below are the spec, restated here
@@ -1,4 +1,22 @@
1
- "use client";
1
+ /**
2
+ * Validating a form before it is submitted, with whatever library you use.
3
+ *
4
+ * Not a client module, though a client component is its first caller: the
5
+ * action pipeline validates with it on the server too, and a "use client"
6
+ * directive here turned that call into a client-reference stub - "client
7
+ * reference export 'validateWith' is called on server", on every action
8
+ * with a schema. Pure functions, no React; importable from either side.
9
+ *
10
+ * Not with an adapter per library: Standard Schema is the contract Zod,
11
+ * Valibot, ArkType and others already implement, so this speaks to the schema
12
+ * itself and never imports one. The types below are the spec, restated here
13
+ * rather than depended on — it is an interface, and a package for it would be
14
+ * a dependency that ships nothing.
15
+ *
16
+ * Validation on the client is a courtesy, never a control. The server still
17
+ * has to check: a form is one way to reach an action, and the action is a
18
+ * public endpoint reachable without it.
19
+ */
2
20
  /**
3
21
  * The field an issue belongs to.
4
22
  *
@@ -1 +1 @@
1
- {"version":3,"file":"standardSchema.js","sourceRoot":"","sources":["../../src/js/standardSchema.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAmCb;;;;;;;GAOG;AACH,SAAS,OAAO,CAAC,IAA8I;IAC7J,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IAEzC,OAAO,IAAI;SACR,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;SAC3F,IAAI,CAAC,GAAG,CAAC,CAAA;AACd,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,cAAc,CAC5B,MAA4D;IAE5D,MAAM,MAAM,GAA6B,EAAE,CAAA;IAE3C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAEhC;QAAA,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAC7C,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAoC,EACpC,KAAc;IAEd,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAA;IAExB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IAExD,OAAO,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AACzF,CAAC","sourcesContent":["\"use client\";\n\n/**\n * Validating a form before it is submitted, with whatever library you use.\n *\n * Not with an adapter per library: Standard Schema is the contract Zod,\n * Valibot, ArkType and others already implement, so this speaks to the schema\n * itself and never imports one. The types below are the spec, restated here\n * rather than depended on — it is an interface, and a package for it would be\n * a dependency that ships nothing.\n *\n * Validation on the client is a courtesy, never a control. The server still\n * has to check: a form is one way to reach an action, and the action is a\n * public endpoint reachable without it.\n */\n\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n readonly '~standard': {\n readonly version: 1\n readonly vendor: string\n readonly validate: (\n value: unknown,\n ) => StandardSchemaResult<Output> | Promise<StandardSchemaResult<Output>>\n readonly types?: { readonly input: Input; readonly output: Output }\n }\n}\n\ninterface StandardSchemaResult<Output> {\n readonly value?: Output\n readonly issues?: ReadonlyArray<{\n readonly message: string\n readonly path?: ReadonlyArray<PropertyKey | { readonly key: PropertyKey }>\n }>\n}\n\n/**\n * The field an issue belongs to.\n *\n * Segments are joined with dots so a nested field reads the way it was named —\n * `address.city`, not `address`. An issue with no path is about the form\n * rather than any field, and goes under the empty string, which is where a\n * component that wants to render it can look.\n */\nfunction fieldOf(path: StandardSchemaResult<unknown>['issues'] extends undefined ? never : NonNullable<StandardSchemaResult<unknown>['issues']>[number]['path']): string {\n if (!path || path.length === 0) return ''\n\n return path\n .map((segment) => (typeof segment === 'object' && segment !== null ? segment.key : segment))\n .join('.')\n}\n\n/** Issues grouped by field, in the shape the form already reports. */\nexport function issuesToErrors(\n issues: NonNullable<StandardSchemaResult<unknown>['issues']>,\n): Record<string, string[]> {\n const errors: Record<string, string[]> = {}\n\n for (const issue of issues) {\n const field = fieldOf(issue.path)\n\n ;(errors[field] ??= []).push(issue.message)\n }\n\n return errors\n}\n\n/**\n * Run a schema, or nothing if there is not one.\n *\n * Returns the errors to show, or null when the value is acceptable. The parsed\n * value is deliberately discarded: what gets submitted is the FormData the\n * browser built, and quietly sending something else — a coerced number, a\n * trimmed string — would mean the action receives what the schema decided\n * rather than what the field said.\n */\nexport async function validateWith(\n schema: StandardSchemaV1 | undefined,\n value: unknown,\n): Promise<Record<string, string[]> | null> {\n if (!schema) return null\n\n const result = await schema['~standard'].validate(value)\n\n return result.issues && result.issues.length > 0 ? issuesToErrors(result.issues) : null\n}\n"]}
1
+ {"version":3,"file":"standardSchema.js","sourceRoot":"","sources":["../../src/js/standardSchema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAqBH;;;;;;;GAOG;AACH,SAAS,OAAO,CAAC,IAA8I;IAC7J,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IAEzC,OAAO,IAAI;SACR,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;SAC3F,IAAI,CAAC,GAAG,CAAC,CAAA;AACd,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,cAAc,CAC5B,MAA4D;IAE5D,MAAM,MAAM,GAA6B,EAAE,CAAA;IAE3C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAEhC;QAAA,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAC7C,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAoC,EACpC,KAAc;IAEd,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAA;IAExB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IAExD,OAAO,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AACzF,CAAC","sourcesContent":["/**\n * Validating a form before it is submitted, with whatever library you use.\n *\n * Not a client module, though a client component is its first caller: the\n * action pipeline validates with it on the server too, and a \"use client\"\n * directive here turned that call into a client-reference stub - \"client\n * reference export 'validateWith' is called on server\", on every action\n * with a schema. Pure functions, no React; importable from either side.\n *\n * Not with an adapter per library: Standard Schema is the contract Zod,\n * Valibot, ArkType and others already implement, so this speaks to the schema\n * itself and never imports one. The types below are the spec, restated here\n * rather than depended on — it is an interface, and a package for it would be\n * a dependency that ships nothing.\n *\n * Validation on the client is a courtesy, never a control. The server still\n * has to check: a form is one way to reach an action, and the action is a\n * public endpoint reachable without it.\n */\n\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n readonly '~standard': {\n readonly version: 1\n readonly vendor: string\n readonly validate: (\n value: unknown,\n ) => StandardSchemaResult<Output> | Promise<StandardSchemaResult<Output>>\n readonly types?: { readonly input: Input; readonly output: Output }\n }\n}\n\ninterface StandardSchemaResult<Output> {\n readonly value?: Output\n readonly issues?: ReadonlyArray<{\n readonly message: string\n readonly path?: ReadonlyArray<PropertyKey | { readonly key: PropertyKey }>\n }>\n}\n\n/**\n * The field an issue belongs to.\n *\n * Segments are joined with dots so a nested field reads the way it was named —\n * `address.city`, not `address`. An issue with no path is about the form\n * rather than any field, and goes under the empty string, which is where a\n * component that wants to render it can look.\n */\nfunction fieldOf(path: StandardSchemaResult<unknown>['issues'] extends undefined ? never : NonNullable<StandardSchemaResult<unknown>['issues']>[number]['path']): string {\n if (!path || path.length === 0) return ''\n\n return path\n .map((segment) => (typeof segment === 'object' && segment !== null ? segment.key : segment))\n .join('.')\n}\n\n/** Issues grouped by field, in the shape the form already reports. */\nexport function issuesToErrors(\n issues: NonNullable<StandardSchemaResult<unknown>['issues']>,\n): Record<string, string[]> {\n const errors: Record<string, string[]> = {}\n\n for (const issue of issues) {\n const field = fieldOf(issue.path)\n\n ;(errors[field] ??= []).push(issue.message)\n }\n\n return errors\n}\n\n/**\n * Run a schema, or nothing if there is not one.\n *\n * Returns the errors to show, or null when the value is acceptable. The parsed\n * value is deliberately discarded: what gets submitted is the FormData the\n * browser built, and quietly sending something else — a coerced number, a\n * trimmed string — would mean the action receives what the schema decided\n * rather than what the field said.\n */\nexport async function validateWith(\n schema: StandardSchemaV1 | undefined,\n value: unknown,\n): Promise<Record<string, string[]> | null> {\n if (!schema) return null\n\n const result = await schema['~standard'].validate(value)\n\n return result.issues && result.issues.length > 0 ? issuesToErrors(result.issues) : null\n}\n"]}
@@ -1 +1,14 @@
1
- export { useLinkStatus } from "./Link";
1
+ /**
2
+ * Whether the enclosing <Link> is mid-navigation, for the thing inside it
3
+ * that wants to show as much.
4
+ *
5
+ * In its own module rather than beside Link: a module that exports a
6
+ * component and a hook cannot be fast-refreshed, and every change to Link
7
+ * became a full page reload in development for whoever had it open.
8
+ */
9
+ export declare const LinkStatusContext: import("react").Context<{
10
+ pending: boolean;
11
+ }>;
12
+ export declare function useLinkStatus(): {
13
+ pending: boolean;
14
+ };
@@ -1,3 +1,17 @@
1
1
  "use client";
2
- export { useLinkStatus } from "./Link";
2
+ import { createContext, useContext } from "react";
3
+ /**
4
+ * Whether the enclosing <Link> is mid-navigation, for the thing inside it
5
+ * that wants to show as much.
6
+ *
7
+ * In its own module rather than beside Link: a module that exports a
8
+ * component and a hook cannot be fast-refreshed, and every change to Link
9
+ * became a full page reload in development for whoever had it open.
10
+ */
11
+ export const LinkStatusContext = createContext({
12
+ pending: false,
13
+ });
14
+ export function useLinkStatus() {
15
+ return useContext(LinkStatusContext);
16
+ }
3
17
  //# sourceMappingURL=useLinkStatus.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLinkStatus.js","sourceRoot":"","sources":["../../src/js/useLinkStatus.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC","sourcesContent":["\"use client\";\n\nexport { useLinkStatus } from \"./Link\";\n"]}
1
+ {"version":3,"file":"useLinkStatus.js","sourceRoot":"","sources":["../../src/js/useLinkStatus.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAuB;IACnE,OAAO,EAAE,KAAK;CACf,CAAC,CAAC;AAEH,MAAM,UAAU,aAAa;IAC3B,OAAO,UAAU,CAAC,iBAAiB,CAAC,CAAC;AACvC,CAAC","sourcesContent":["\"use client\";\n\nimport { createContext, useContext } from \"react\";\n\n/**\n * Whether the enclosing <Link> is mid-navigation, for the thing inside it\n * that wants to show as much.\n *\n * In its own module rather than beside Link: a module that exports a\n * component and a hook cannot be fast-refreshed, and every change to Link\n * became a full page reload in development for whoever had it open.\n */\nexport const LinkStatusContext = createContext<{ pending: boolean }>({\n pending: false,\n});\n\nexport function useLinkStatus(): { pending: boolean } {\n return useContext(LinkStatusContext);\n}\n"]}
@@ -1 +1,7 @@
1
+ /**
2
+ * The digest a stored page carries where the query was read under the
3
+ * boundary that caught it. The client recognises it on hydration and does
4
+ * not report the fallback as an error, because it is the designed path.
5
+ */
6
+ export declare const SEARCH_PARAMS_FALLBACK = "rsc-kit:search-params-fallback";
1
7
  export declare function useSearchParams(): URLSearchParams;