@rshono/core 1.0.0-rc.18 → 1.0.0-rc.19

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 (53) hide show
  1. package/README.md +13 -3
  2. package/dist/builder/rspack-config.d.ts.map +1 -1
  3. package/dist/builder/rspack-config.js +5 -1
  4. package/dist/builder/rspack-config.js.map +1 -1
  5. package/dist/builder/server-only-imports.d.ts +33 -0
  6. package/dist/builder/server-only-imports.d.ts.map +1 -0
  7. package/dist/builder/server-only-imports.js +51 -0
  8. package/dist/builder/server-only-imports.js.map +1 -0
  9. package/dist/cli/build.d.ts.map +1 -1
  10. package/dist/cli/build.js +18 -9
  11. package/dist/cli/build.js.map +1 -1
  12. package/dist/cli/dev.d.ts.map +1 -1
  13. package/dist/cli/dev.js +45 -0
  14. package/dist/cli/dev.js.map +1 -1
  15. package/dist/deploy/presets.d.ts +8 -0
  16. package/dist/deploy/presets.d.ts.map +1 -1
  17. package/dist/deploy/presets.js +1 -0
  18. package/dist/deploy/presets.js.map +1 -1
  19. package/dist/router.d.ts +33 -18
  20. package/dist/router.d.ts.map +1 -1
  21. package/dist/router.js.map +1 -1
  22. package/dist/runtime/boundaries.d.ts +11 -4
  23. package/dist/runtime/boundaries.d.ts.map +1 -1
  24. package/dist/runtime/boundaries.js.map +1 -1
  25. package/dist/runtime/context.d.ts +9 -2
  26. package/dist/runtime/context.d.ts.map +1 -1
  27. package/dist/runtime/context.js +12 -3
  28. package/dist/runtime/context.js.map +1 -1
  29. package/dist/runtime/entry.client.js +124 -19
  30. package/dist/runtime/entry.client.js.map +1 -1
  31. package/dist/runtime/entry.rsc.d.ts +7 -0
  32. package/dist/runtime/entry.rsc.d.ts.map +1 -1
  33. package/dist/runtime/entry.rsc.js +17 -20
  34. package/dist/runtime/entry.rsc.js.map +1 -1
  35. package/dist/runtime/validate-entries.d.ts +49 -4
  36. package/dist/runtime/validate-entries.d.ts.map +1 -1
  37. package/dist/runtime/validate-entries.js +118 -2
  38. package/dist/runtime/validate-entries.js.map +1 -1
  39. package/dist/server/prerendered.d.ts +0 -5
  40. package/dist/server/prerendered.d.ts.map +1 -1
  41. package/dist/server/prerendered.js +1 -1
  42. package/dist/server/prerendered.js.map +1 -1
  43. package/dist/server/server-config.d.ts +8 -1
  44. package/dist/server/server-config.d.ts.map +1 -1
  45. package/dist/server/server-config.js +2 -1
  46. package/dist/server/server-config.js.map +1 -1
  47. package/dist/server/ssg.d.ts.map +1 -1
  48. package/dist/server/ssg.js +24 -7
  49. package/dist/server/ssg.js.map +1 -1
  50. package/dist/server/static.d.ts.map +1 -1
  51. package/dist/server/static.js +5 -1
  52. package/dist/server/static.js.map +1 -1
  53. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"entry.client.js","sourceRoot":"","sources":["../../src/runtime/entry.client.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,2BAA2B,EAC3B,WAAW,EACX,iBAAiB,GAClB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGpE,sGAAsG;AACtG,6CAA6C;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAyB,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC;AAOrD,0GAA0G;AAC1G,SAAS,iBAAiB;IACxB,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAClC,wFAAwF;IACxF,IAAI,UAAwD,CAAC;IAC7D,MAAM,MAAM,GAAG,IAAI,cAAc,CAAa;QAC5C,K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KAAK,CAAC,CAAC;IACrE,SAAS,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { hydrateRoot } from 'react-dom/client';\nimport {\n createFromFetch,\n createFromReadableStream,\n createTemporaryReferenceSet,\n encodeReply,\n setServerCallback,\n} from 'react-server-dom-rspack/client.browser';\nimport { isControlDigest, parseRedirectDigest } from './control.js';\nimport type { DevMessage } from './dev-protocol.js';\nimport type { RscPayload } from './entry.rsc.js';\n// Dev-only: its one caller sits behind `import.meta.webpackHot`, which a production build compiles to\n// `false` — so this module is dropped there.\nimport { walkHotUpdates } from './hot-update.js';\nimport { RouterContext, type NavigationRouter } from './navigation.js';\nimport { createRscRequest } from './request.js';\n\nconst isDev = process.env.NODE_ENV === 'development';\n\ndeclare global {\n /** The array the payload `<script>` tags `flight-inject.ts` emits push their chunks into. */\n var __FLIGHT_DATA: Array<string | Uint8Array> | undefined;\n}\n\n/** The flight payload the document carried, read back out of `__FLIGHT_DATA` — see `flight-inject.ts`. */\nfunction readFlightPayload(): ReadableStream<Uint8Array> {\n const encoder = new TextEncoder();\n // Assigned synchronously by `start`, which `new ReadableStream` runs before it returns.\n let controller!: ReadableStreamDefaultController<Uint8Array>;\n const stream = new ReadableStream<Uint8Array>({\n start: (c) => void (controller = c),\n });\n const enqueue = (chunk: string | Uint8Array) => controller.enqueue(typeof chunk === 'string' ? encoder.encode(chunk) : chunk);\n\n // Payload scripts interleave with the document: the ones that already ran are in the array, the rest\n // arrive through `push`.\n const data = (self.__FLIGHT_DATA ??= []);\n for (const chunk of data) enqueue(chunk);\n data.push = enqueue as typeof data.push;\n\n // The last payload script lands before parsing finishes, so that is what closes the stream.\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', () => controller.close(), { once: true });\n } else {\n controller.close();\n }\n return stream;\n}\n\n/** Created at module evaluation, not inside `main()`, so no chunk can be pushed before it is watching. */\nconst flightStream = readFlightPayload();\n\n/**\n * The part of the location a payload is rendered for — the document, without the fragment, which the server\n * never sees. Two URLs that differ only by `#hash` describe the same payload.\n */\nconst documentUrl = (): string => location.pathname + location.search;\n\n/** Guarantees somewhere to attach the fatal overlay: the root container is `document`, so a teardown can take `<body>` with it. */\nfunction overlayHost(): HTMLElement {\n if (!document.documentElement) document.appendChild(document.createElement('html'));\n if (!document.body) document.documentElement.appendChild(document.createElement('body'));\n return document.body;\n}\n\n/**\n * Paints the reason for an uncaught render error over the blank page it leaves behind — the full stack in\n * dev, a generic notice and a reload button in production.\n *\n * DOM calls rather than React (the renderer is what just failed), and `textContent` rather than\n * `innerHTML` (an error message is untrusted input).\n */\nfunction showFatal(error: unknown, componentStack?: string | null): void {\n // Queued: React's teardown runs after this callback returns and would remove a node appended inline.\n setTimeout(() => {\n const host = overlayHost();\n host.querySelector('[data-rshono-fatal]')?.remove();\n\n const box = document.createElement('div');\n box.setAttribute('data-rshono-fatal', '');\n box.setAttribute('role', 'alert');\n box.style.cssText =\n 'position:fixed;inset:0;z-index:2147483647;overflow:auto;padding:1.5rem;background:#18181b;color:#f4f4f5;' +\n 'font:14px/1.6 ui-monospace,SFMono-Regular,Menlo,monospace;text-align:left';\n\n const title = document.createElement('div');\n title.textContent = isDev ? 'Unhandled error' : 'Something went wrong';\n title.style.cssText = 'font-size:1.0625rem;font-weight:700;color:#f87171;margin:0 0 0.75rem';\n box.appendChild(title);\n\n if (isDev) {\n const detail = document.createElement('pre');\n detail.style.cssText = 'margin:0;white-space:pre-wrap;word-break:break-word';\n detail.textContent =\n (error instanceof Error ? (error.stack ?? `${error.name}: ${error.message}`) : String(error)) +\n (componentStack ? `\\n\\nComponent stack:${componentStack}` : '');\n box.appendChild(detail);\n } else {\n const message = document.createElement('p');\n message.textContent = 'This page hit an unexpected error and can’t continue.';\n message.style.cssText = 'margin:0 0 1rem;color:#d4d4d8';\n box.appendChild(message);\n }\n\n const reload = document.createElement('button');\n reload.textContent = 'Reload page';\n reload.style.cssText =\n 'margin-top:1.25rem;padding:0.5rem 1rem;font:inherit;color:#18181b;background:#f4f4f5;border:0;border-radius:4px;cursor:pointer';\n reload.addEventListener('click', () => window.location.reload());\n box.appendChild(reload);\n\n host.appendChild(box);\n }, 0);\n}\n\n/** What every flight response is typed as. The charset and any other parameters follow it. */\nconst FLIGHT_CONTENT_TYPE = 'text/x-component';\n\n/**\n * Fetches a payload, refusing a response that is not one.\n *\n * The status cannot be the gate: a payload legitimately arrives as a 404 from the `notFound` page and as a\n * 500 from an action that threw, and both carry a real payload the caller has to see. The content type is.\n *\n * What this catches is the response that is not a payload at all — a `bodyLimit()` 413, a proxy's error page,\n * a 502 mid-deploy. Handed to the flight parser those all surface as `Error: Connection closed.`, with the\n * status and the body nowhere in sight; here they become an error that says what arrived.\n */\nasync function payloadResponse(request: Request): Promise<Response> {\n const response = await fetch(request);\n const contentType = response.headers.get('content-type');\n if (contentType?.startsWith(FLIGHT_CONTENT_TYPE)) return response;\n // Read for the message: a plain-text refusal says what it refused only in its body, and HTTP/2 has no\n // `statusText` at all. Bounded, because this is an error path and the body is not ours to trust.\n const body = await response.text().then(\n (text) => text.trim().slice(0, 200),\n () => '',\n );\n const status = `${response.status}${response.statusText ? ` ${response.statusText}` : ''}`;\n throw new Error(`[rshono] the server answered ${status} (${contentType ?? 'no content type'}) instead of a payload${body ? `: ${body}` : ''}`);\n}\n\n/**\n * Asks a URL for its flight payload. Deliberately uncached — a payload can never be staler than the click\n * that wanted it, and the browser's own HTTP cache is what makes a repeat visit cheap.\n */\nfunction requestPayload(href: string, signal?: AbortSignal): Promise<RscPayload> {\n return createFromFetch<RscPayload>(payloadResponse(createRscRequest(new URL(href, location.href).href, undefined, signal)));\n}\n\n/**\n * Whether the browser hands us its navigations. Gated on `sourceElement` rather than on `navigation` itself:\n * Chrome shipped the event in 102 and that property only in 135, and without it a `data-native` link cannot\n * be told from any other — so the older window would soft-navigate the very links that asked not to be.\n *\n * Where this is false there is no interception at all and every navigation is a real browser load, which a\n * server-rendered app answers correctly on its own. Only the soft part is missing.\n *\n * Both globals are tested, and neither is touched before: this runs at module scope, where a ReferenceError\n * would take the whole client runtime down with it rather than degrading anything.\n */\nconst canSoftNavigate = typeof navigation !== 'undefined' && typeof NavigateEvent !== 'undefined' && 'sourceElement' in NavigateEvent.prototype;\n\n/**\n * Drops a navigation's result promises. Both reject when a navigation is superseded or cancelled — routine\n * here, since a second click is meant to abandon the first — and unhandled they would be reported as faults.\n */\nfunction settle(result: NavigationResult): void {\n const ignore = () => {};\n void result.committed?.catch(ignore);\n void result.finished?.catch(ignore);\n}\n\n// The imperative actions behind `useNavigation().router`. Each one only *asks*: the browser turns it into a\n// `navigate` event, which is where `listenNavigation` answers it — so a `router.push` and a link click reach\n// the same code by the same route, and inherit the same fetch, scroll and `pending` flag.\nfunction push(href: string): void {\n if (canSoftNavigate) settle(navigation.navigate(href, { history: 'push' }));\n else window.location.assign(href);\n}\n\nfunction replace(href: string): void {\n if (canSoftNavigate) settle(navigation.navigate(href, { history: 'replace' }));\n else window.location.replace(href);\n}\n\n// A traversal is the browser's to perform either way — `navigation` only hands it back as an interceptable\n// event first. Nothing to go back to is a rejection there and a no-op here; both amount to the same thing.\nfunction back(): void {\n if (canSoftNavigate) settle(navigation.back());\n else window.history.back();\n}\n\nfunction forward(): void {\n if (canSoftNavigate) settle(navigation.forward());\n else window.history.forward();\n}\n\n// A refresh keeps the URL, and is still a navigation: it arrives as `navigationType: 'reload'`, which is what\n// tells the listener to leave scroll and focus where the user left them.\nfunction refresh(): void {\n if (canSoftNavigate) settle(navigation.reload());\n else window.location.reload();\n}\n\n/**\n * Turns a control-signal digest — how `redirect()` / `notFound()` reach the browser — into a real\n * navigation. Returns false for anything else, so callers fall through to their own handling.\n *\n * `hard` forces a full document load, for signals that surfaced *through React*: it unmounts the root on\n * an uncaught error, leaving no live tree to soft-navigate with.\n */\nfunction handleControlDigest(error: unknown, { hard = false }: { hard?: boolean } = {}): boolean {\n const digest = (error as { digest?: unknown } | null)?.digest;\n if (!isControlDigest(digest)) return false;\n const redirect = parseRedirectDigest(digest);\n if (!redirect) {\n window.location.reload();\n } else if (hard) {\n window.location.assign(new URL(redirect.location, window.location.href).href);\n } else {\n push(redirect.location);\n }\n return true;\n}\n\n/**\n * Puts a payload on screen, resolving once React has committed it. Replaced by `BrowserRoot`'s own on mount;\n * the default covers the window before hydration, where `setServerCallback` is already registered but there\n * is no root to update — a reload is the honest answer, and nothing after it needs to run.\n */\nlet setPayload: (payload: RscPayload) => Promise<void> = () => {\n window.location.reload();\n return new Promise<void>(() => {});\n};\n\n/** Runs work inside the nav transition so `useNavigation().pending` stays true across the round-trip. */\nlet startNav: (run: () => void | Promise<void>) => void = (run) => {\n void run();\n};\n\n/**\n * Fetches the payload for `url` and puts it on screen.\n *\n * Resolves once React has **committed** it rather than when the fetch lands: an intercepted navigation\n * scrolls and moves focus when this promise settles, and a `#hash` target does not exist until the new tree\n * does. Rejects only on a genuine failure — being superseded is not one, and resolves quietly, because the\n * navigation that replaced this one owns the screen from then on.\n */\nfunction loadPayload(url: string, signal?: AbortSignal): Promise<void> {\n // Deliberately not awaited inside the transition: the scope ends once the payload is handed to React, and\n // React holds `pending` until the update it scheduled commits. Awaiting the commit *inside* the scope would\n // work too, but only because React happens not to gate a commit on its async scope settling — an internal\n // this has no reason to depend on across the whole `^19.1.0` peer range.\n let committed: Promise<void> | undefined;\n\n const run = async () => {\n const payload = await requestPayload(url, signal);\n // The browser aborts a navigation the moment a newer one starts. Checked again after the await because\n // the fetch may already have resolved by then, and applying it would repaint a page the user has left.\n if (signal?.aborted) return;\n if (payload.redirect) {\n push(payload.redirect);\n return;\n }\n committed = setPayload(payload);\n };\n\n // `startTransition` runs the work but hands nothing back, so the promise carrying a failure is caught here\n // instead. Assigned synchronously: React invokes the callback before `startNav` returns.\n let work!: Promise<void>;\n startNav(() => (work = run()));\n\n return work.then(\n // Undefined whenever nothing was applied — an abort, or a redirect — and there is then nothing to wait for.\n () => committed,\n (error: unknown) => {\n // Checked before the error is read: an abort is this navigation being replaced, and the one that\n // replaced it owns the outcome.\n if (signal?.aborted || handleControlDigest(error)) return;\n throw error;\n },\n );\n}\n\n/**\n * Navigations the browser can hand over but shouldn't:\n *\n * - a fragment jump, which is same-document already and needs no payload — the browser's own jump is the one\n * that honours `scroll-padding-top`, and re-rendering would pull the target out from under it;\n * - a download, which is not a navigation of this page at all;\n * - a `POST` form, which is a submission and the server's to answer (a `GET` form carries its fields in the\n * URL, has no `formData`, and soft-navigates like any other link);\n * - a link marked `data-native`, the documented opt-out.\n */\nfunction leaveToBrowser(event: NavigateEvent): boolean {\n return event.hashChange || event.downloadRequest !== null || event.formData !== null || event.sourceElement?.hasAttribute('data-native') === true;\n}\n\n/**\n * The whole router, in one listener.\n *\n * Every navigation the page can make arrives as a `navigate` event — a link click, a `GET` form, a\n * `history.pushState`, the back button, `navigation.reload()` — already filtered by the browser: it does not\n * fire for a middle-click, a modified click or a new tab, and reports `canIntercept: false` for anything\n * cross-origin, or for a traversal that leaves the app. Those need no handling here; they are left alone, and\n * the browser performs them as it always would.\n */\nfunction listenNavigation(): () => void {\n if (!canSoftNavigate) return () => {};\n\n const onNavigate = (event: NavigateEvent) => {\n if (!event.canIntercept || leaveToBrowser(event)) return;\n\n // A push or a traversal lands on a new page, so the browser resets the scroll offset — or restores the\n // one it remembers — and moves focus, which is what makes a soft navigation announce itself to a screen\n // reader. A replace or a refresh stays where it is, so neither should move. Both wait on the handler,\n // which is the point of resolving it at commit rather than at fetch.\n const inPlace = event.navigationType === 'replace' || event.navigationType === 'reload';\n\n event.intercept({\n scroll: inPlace ? 'manual' : 'after-transition',\n focusReset: inPlace ? 'manual' : 'after-transition',\n // The URL commits before the handler runs, so a failure leaves the address bar describing a page the\n // document is not showing. A real load is the only way back to agreement.\n handler: () => loadPayload(event.destination.url, event.signal).catch(() => window.location.reload()),\n });\n };\n\n navigation.addEventListener('navigate', onNavigate);\n return () => navigation.removeEventListener('navigate', onNavigate);\n}\n\nasync function main() {\n // The assertion is load-bearing under the compiler that builds this: TypeScript 7 declares `nonce` on\n // HTMLElement, 6 declares it on Element. ESLint runs the older lib — where the narrowing is redundant —\n // so it reports an assertion that `tsc` requires. Believe `typecheck`, not the rule.\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const cspMeta = document.querySelector('meta[property=\"csp-nonce\"]') as HTMLMetaElement | null;\n if (cspMeta?.nonce) __webpack_nonce__ = cspMeta.nonce;\n\n const initialPayload = await createFromReadableStream<RscPayload>(flightStream);\n\n function BrowserRoot() {\n const [payload, setPayloadState] = React.useState(initialPayload);\n const [pending, startTransition] = React.useTransition();\n // The resolver the payload on screen still owes — see {@link loadPayload}.\n const pendingCommit = React.useRef<(() => void) | null>(null);\n\n React.useEffect(() => {\n setPayload = (next) =>\n new Promise<void>((resolve) => {\n // A payload replaced before it ever painted still has a navigation waiting on it. React commits\n // only the newest, so the effect below never runs for the one it skipped: release it here.\n pendingCommit.current?.();\n pendingCommit.current = resolve;\n setPayloadState(next);\n });\n startNav = (run) => startTransition(run);\n }, [startTransition]);\n\n /**\n * Releases the navigation waiting on this payload, which is what lets the browser scroll and move focus\n * now that their target exists. A layout effect, so the pre-scroll position is never painted.\n */\n React.useLayoutEffect(() => {\n const commit = pendingCommit.current;\n pendingCommit.current = null;\n commit?.();\n }, [payload]);\n\n React.useEffect(() => listenNavigation(), []);\n\n const router = React.useMemo<NavigationRouter>(() => ({ push, replace, back, forward, refresh, pending }), [pending]);\n\n return <RouterContext.Provider value={router}>{payload.root}</RouterContext.Provider>;\n }\n\n setServerCallback(async (id, args) => {\n const temporaryReferences = createTemporaryReferenceSet();\n // The document the action is being called from. Every action response carries a fresh payload for that\n // page, so if a navigation has moved on by the time it arrives the payload describes a page the user has\n // left — the return value is still theirs, but painting it is not. Compared without the fragment, which\n // the server never saw.\n const calledFrom = documentUrl();\n const request = createRscRequest(window.location.href, {\n id,\n body: await encodeReply(args, { temporaryReferences }),\n });\n let payload: RscPayload;\n try {\n payload = await createFromFetch<RscPayload>(payloadResponse(request), { temporaryReferences });\n } catch (error) {\n if (handleControlDigest(error)) return undefined;\n throw error;\n }\n if (payload.redirect) {\n push(payload.redirect);\n return undefined;\n }\n if (documentUrl() === calledFrom) React.startTransition(() => void setPayload(payload));\n if (payload.notFound) return undefined;\n const result = payload.returnValue;\n if (!result) {\n // A payload that is not this action's own reply: the server rendered a page in its place. An action\n // that had already run has its result carried across (see `actionResults` in entry.rsc.tsx), so\n // reaching here means the request failed before it ran at all — an undecodable body, most likely.\n // Reading `.ok` off it used to hand the caller `Cannot read properties of undefined`.\n throw new Error('[rshono] the server action produced no result — the request failed around it and the server answered with a page instead. Its log has the error.');\n }\n if (!result.ok) throw result.error;\n return result.value;\n });\n\n // A `redirect()` / `notFound()` from a component below the page root reaches us through React: it rides the\n // flight payload as an error, and boundaries re-throw it so it lands here rather than in a fallback.\n //\n // Installing these hooks opts out of React's own defaults, so everything that isn't a control signal has to\n // be put back by hand — `reportError` rather than a bare log, so error-reporting tools still see it.\n hydrateRoot(document, <BrowserRoot />, {\n formState: initialPayload.formState,\n onCaughtError: (error, errorInfo) => {\n if (handleControlDigest(error, { hard: true })) return;\n // A boundary handled it and the tree is intact, so no overlay over the app's own fallback.\n console.error(error, errorInfo.componentStack ?? '');\n },\n onUncaughtError: (error, errorInfo) => {\n if (handleControlDigest(error, { hard: true })) return;\n // Nothing caught it, so React tears the root down — and the root is `document`.\n globalThis.reportError(error);\n showFatal(error, errorInfo.componentStack);\n },\n });\n\n if (import.meta.webpackHot) {\n initDevRefresh();\n }\n}\n\n/**\n * Dev-only refresh client, listening to the CLI's SSE endpoint:\n *\n * client-built → hot-apply the waiting updates; anything the page can't be patched up to reloads.\n * rsc-update → server component code changed: re-fetch the flight payload, state preserved.\n * hello → sent on (re)connect with the latest build hash; a mismatch means a missed event.\n */\nfunction initDevRefresh() {\n const hot = import.meta.webpackHot!;\n let connectedOnce = false;\n /** The newest build the dev server has announced — what {@link applyClientUpdate} walks towards. */\n let targetHash: string | undefined;\n\n function reload(reason: string, error?: unknown): void {\n console.warn(`[rshono] ${reason} — reloading`, ...(error === undefined ? [] : [error]));\n window.location.reload();\n }\n\n async function applyClientUpdate(): Promise<void> {\n const giveUp = await walkHotUpdates(\n hot,\n () => __webpack_hash__,\n () => targetHash,\n );\n if (giveUp) reload(giveUp.reason, giveUp.error);\n }\n\n async function handle(message: DevMessage): Promise<void> {\n switch (message.type) {\n case 'hello':\n targetHash = message.hash ?? targetHash;\n if (connectedOnce) {\n await applyClientUpdate();\n await loadPayload(window.location.href).catch(() => window.location.reload());\n }\n connectedOnce = true;\n break;\n case 'client-built':\n targetHash = message.hash;\n await applyClientUpdate();\n break;\n case 'rsc-update':\n console.log('[rshono] server components updated');\n await loadPayload(window.location.href).catch(() => window.location.reload());\n break;\n }\n }\n\n const source = new EventSource('/_rshono/hmr');\n // Chained rather than handled as they arrive: `hot.check` may only run from `idle`, and a burst of saves\n // puts several frames on the wire inside the time one takes. Queueing drops nothing, because `targetHash`\n // is shared — whichever handler runs next walks to the newest build.\n let queue: Promise<void> = Promise.resolve();\n source.onmessage = (event: MessageEvent<string>) => {\n const message = JSON.parse(event.data) as DevMessage;\n queue = queue.then(() => handle(message)).catch((error) => reload('the dev client failed', error));\n };\n}\n\n// A bootstrap failure — a truncated initial payload, most likely — would otherwise be an unhandled\n// rejection: nothing hydrates, nothing is reported, and the page just sits there.\nmain().catch((error) => {\n console.error('[rshono] the client runtime failed to start:', error);\n showFatal(error);\n});\n"]}
1
+ {"version":3,"file":"entry.client.js","sourceRoot":"","sources":["../../src/runtime/entry.client.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,2BAA2B,EAC3B,WAAW,EACX,iBAAiB,GAClB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,cAAc,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E,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,8CAA8C,EAAE,KAAK,CAAC,CAAC;IACrE,SAAS,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { hydrateRoot } from 'react-dom/client';\nimport {\n createFromFetch,\n createFromReadableStream,\n createTemporaryReferenceSet,\n encodeReply,\n setServerCallback,\n} from 'react-server-dom-rspack/client.browser';\nimport { isControlDigest, parseRedirectDigest } from './control.js';\nimport type { DevMessage } from './dev-protocol.js';\nimport type { RscPayload } from './entry.rsc.js';\n// Dev-only: its one caller sits behind `import.meta.webpackHot`, which a production build compiles to\n// `false` — so this module is dropped there.\nimport { walkHotUpdates } from './hot-update.js';\nimport { RouterContext, type NavigationRouter } from './navigation.js';\nimport { createRscRequest } from './request.js';\n\nconst isDev = process.env.NODE_ENV === 'development';\n\ndeclare global {\n /** The array the payload `<script>` tags `flight-inject.ts` emits push their chunks into. */\n var __FLIGHT_DATA: Array<string | Uint8Array> | undefined;\n}\n\n/** The flight payload the document carried, read back out of `__FLIGHT_DATA` — see `flight-inject.ts`. */\nfunction readFlightPayload(): ReadableStream<Uint8Array> {\n const encoder = new TextEncoder();\n // Assigned synchronously by `start`, which `new ReadableStream` runs before it returns.\n let controller!: ReadableStreamDefaultController<Uint8Array>;\n const stream = new ReadableStream<Uint8Array>({\n start: (c) => void (controller = c),\n });\n const enqueue = (chunk: string | Uint8Array) => controller.enqueue(typeof chunk === 'string' ? encoder.encode(chunk) : chunk);\n\n // Payload scripts interleave with the document: the ones that already ran are in the array, the rest\n // arrive through `push`.\n const data = (self.__FLIGHT_DATA ??= []);\n for (const chunk of data) enqueue(chunk);\n data.push = enqueue as typeof data.push;\n\n // The last payload script lands before parsing finishes, so that is what closes the stream.\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', () => controller.close(), { once: true });\n } else {\n controller.close();\n }\n return stream;\n}\n\n/** Created at module evaluation, not inside `main()`, so no chunk can be pushed before it is watching. */\nconst flightStream = readFlightPayload();\n\n/**\n * The part of the location a payload is rendered for — the document, without the fragment, which the server\n * never sees. Two URLs that differ only by `#hash` describe the same payload.\n */\nconst documentUrl = (): string => location.pathname + location.search;\n\n/** Guarantees somewhere to attach the fatal overlay: the root container is `document`, so a teardown can take `<body>` with it. */\nfunction overlayHost(): HTMLElement {\n if (!document.documentElement) document.appendChild(document.createElement('html'));\n if (!document.body) document.documentElement.appendChild(document.createElement('body'));\n return document.body;\n}\n\n/**\n * Paints a full-viewport panel over whatever is on screen, and returns the box for the caller to fill.\n *\n * DOM calls rather than React (one caller runs because the renderer just failed), and `textContent` rather\n * than `innerHTML` (an error message is untrusted input). Queued on a macrotask: React's teardown runs after\n * the callback that reaches here returns, and would remove a node appended inline.\n */\nfunction paintOverlay(fill: (box: HTMLElement) => void): void {\n setTimeout(() => {\n const host = overlayHost();\n host.querySelector('[data-rshono-fatal]')?.remove();\n\n const box = document.createElement('div');\n box.setAttribute('data-rshono-fatal', '');\n box.setAttribute('role', 'alert');\n box.style.cssText =\n 'position:fixed;inset:0;z-index:2147483647;overflow:auto;padding:1.5rem;background:#18181b;color:#f4f4f5;' +\n 'font:14px/1.6 ui-monospace,SFMono-Regular,Menlo,monospace;text-align:left';\n\n fill(box);\n host.appendChild(box);\n }, 0);\n}\n\n/** The overlay's heading. */\nfunction overlayTitle(text: string): HTMLElement {\n const title = document.createElement('div');\n title.textContent = text;\n title.style.cssText = 'font-size:1.0625rem;font-weight:700;color:#f87171;margin:0 0 0.75rem';\n return title;\n}\n\n/**\n * Paints the reason for an uncaught render error over the blank page it leaves behind — the full stack in\n * dev, a generic notice and a reload button in production.\n */\nfunction showFatal(error: unknown, componentStack?: string | null): void {\n paintOverlay((box) => {\n box.appendChild(overlayTitle(isDev ? 'Unhandled error' : 'Something went wrong'));\n\n if (isDev) {\n const detail = document.createElement('pre');\n detail.style.cssText = 'margin:0;white-space:pre-wrap;word-break:break-word';\n detail.textContent =\n (error instanceof Error ? (error.stack ?? `${error.name}: ${error.message}`) : String(error)) +\n (componentStack ? `\\n\\nComponent stack:${componentStack}` : '');\n box.appendChild(detail);\n } else {\n const message = document.createElement('p');\n message.textContent = 'This page hit an unexpected error and can’t continue.';\n message.style.cssText = 'margin:0 0 1rem;color:#d4d4d8';\n box.appendChild(message);\n }\n\n const reload = document.createElement('button');\n reload.textContent = 'Reload page';\n reload.style.cssText =\n 'margin-top:1.25rem;padding:0.5rem 1rem;font:inherit;color:#18181b;background:#f4f4f5;border:0;border-radius:4px;cursor:pointer';\n reload.addEventListener('click', () => loadOutsideRouter(() => window.location.reload()));\n box.appendChild(reload);\n });\n}\n\n/**\n * The end of the line for a `notFound()` that arrived too late to be a 404 and did not survive a reload.\n *\n * No reload button, unlike {@link showFatal}: the reload has already been spent, and the second identical\n * response is what brought us here. \"Page not found\" is what the server was trying to say, so it is what the\n * visitor is told; the reason it could not say it properly is a message for whoever wrote the page, and dev is\n * where they are.\n */\nfunction showLateNotFound(): void {\n paintOverlay((box) => {\n box.appendChild(overlayTitle('Page not found'));\n\n const message = document.createElement('p');\n message.textContent = isDev\n ? 'notFound() was raised from a boundary that resolved after the page shell had been sent, so the response ' +\n 'could not be a 404 — and reloading rendered the same page again. Decide before the render starts ' +\n 'streaming: in Hono middleware, or in the page component body above the boundary.'\n : 'This page is not available.';\n message.style.cssText = 'margin:0;color:#d4d4d8';\n box.appendChild(message);\n });\n}\n/** What every flight response is typed as. The charset and any other parameters follow it. */\nconst FLIGHT_CONTENT_TYPE = 'text/x-component';\n\n/**\n * Fetches a payload, refusing a response that is not one.\n *\n * The status cannot be the gate: a payload legitimately arrives as a 404 from the `notFound` page and as a\n * 500 from an action that threw, and both carry a real payload the caller has to see. The content type is.\n *\n * What this catches is the response that is not a payload at all — a `bodyLimit()` 413, a proxy's error page,\n * a 502 mid-deploy. Handed to the flight parser those all surface as `Error: Connection closed.`, with the\n * status and the body nowhere in sight; here they become an error that says what arrived.\n */\nasync function payloadResponse(request: Request): Promise<Response> {\n const response = await fetch(request);\n const contentType = response.headers.get('content-type');\n if (contentType?.startsWith(FLIGHT_CONTENT_TYPE)) return response;\n // Read for the message: a plain-text refusal says what it refused only in its body, and HTTP/2 has no\n // `statusText` at all. Bounded, because this is an error path and the body is not ours to trust.\n const body = await response.text().then(\n (text) => text.trim().slice(0, 200),\n () => '',\n );\n const status = `${response.status}${response.statusText ? ` ${response.statusText}` : ''}`;\n throw new Error(`[rshono] the server answered ${status} (${contentType ?? 'no content type'}) instead of a payload${body ? `: ${body}` : ''}`);\n}\n\n/**\n * Asks a URL for its flight payload. Deliberately uncached — a payload can never be staler than the click\n * that wanted it, and the browser's own HTTP cache is what makes a repeat visit cheap.\n */\nfunction requestPayload(href: string, signal?: AbortSignal): Promise<RscPayload> {\n return createFromFetch<RscPayload>(payloadResponse(createRscRequest(new URL(href, location.href).href, undefined, signal)));\n}\n\n/**\n * Whether the browser hands us its navigations. Gated on `sourceElement` rather than on `navigation` itself:\n * Chrome shipped the event in 102 and that property only in 135, and without it a `data-native` link cannot\n * be told from any other — so the older window would soft-navigate the very links that asked not to be.\n *\n * Where this is false there is no interception at all and every navigation is a real browser load, which a\n * server-rendered app answers correctly on its own. Only the soft part is missing.\n *\n * Both globals are tested, and neither is touched before: this runs at module scope, where a ReferenceError\n * would take the whole client runtime down with it rather than degrading anything.\n */\nconst canSoftNavigate = typeof navigation !== 'undefined' && typeof NavigateEvent !== 'undefined' && 'sourceElement' in NavigateEvent.prototype;\n\n/**\n * Drops a navigation's result promises. Both reject when a navigation is superseded or cancelled — routine\n * here, since a second click is meant to abandon the first — and unhandled they would be reported as faults.\n */\nfunction settle(result: NavigationResult): void {\n const ignore = () => {};\n void result.committed?.catch(ignore);\n void result.finished?.catch(ignore);\n}\n\n/** Set by {@link loadOutsideRouter}, read and cleared by the `navigate` listener. */\nlet bypassRouter = false;\n\n/**\n * Performs a navigation the router below must **not** intercept, and returns having asked for it.\n *\n * `location.reload()` and `location.assign()` fire a `navigate` event like any other navigation, and\n * `listenNavigation` intercepts a `reload` on purpose — that is what `router.refresh()` is. Every caller here\n * is reaching for a *new document* precisely because the current one cannot be repaired: the React root a\n * soft load would render into is the thing that just failed, or is about to be torn down. Intercepted, the\n * escape hatch becomes a payload fetch that lands nowhere — which is how a late `notFound()` left the tab on\n * its Suspense fallback with no second document ever arriving, and how a late `redirect()` moved the address\n * bar to a page it then failed to render.\n *\n * One-shot: the listener clears the flag on the next event it sees. If that event never comes — a navigation\n * the browser refuses — the cost is that the *next* navigation is a full load rather than a soft one, on a\n * document that was on its way out anyway.\n */\nfunction loadOutsideRouter(navigate: () => void): void {\n bypassRouter = true;\n navigate();\n}\n\n// The imperative actions behind `useNavigation().router`. Each one only *asks*: the browser turns it into a\n// `navigate` event, which is where `listenNavigation` answers it — so a `router.push` and a link click reach\n// the same code by the same route, and inherit the same fetch, scroll and `pending` flag.\nfunction push(href: string): void {\n if (canSoftNavigate) settle(navigation.navigate(href, { history: 'push' }));\n else window.location.assign(href);\n}\n\nfunction replace(href: string): void {\n if (canSoftNavigate) settle(navigation.navigate(href, { history: 'replace' }));\n else window.location.replace(href);\n}\n\n// A traversal is the browser's to perform either way — `navigation` only hands it back as an interceptable\n// event first. Nothing to go back to is a rejection there and a no-op here; both amount to the same thing.\nfunction back(): void {\n if (canSoftNavigate) settle(navigation.back());\n else window.history.back();\n}\n\nfunction forward(): void {\n if (canSoftNavigate) settle(navigation.forward());\n else window.history.forward();\n}\n\n// A refresh keeps the URL, and is still a navigation: it arrives as `navigationType: 'reload'`, which is what\n// tells the listener to leave scroll and focus where the user left them.\nfunction refresh(): void {\n if (canSoftNavigate) settle(navigation.reload());\n else window.location.reload();\n}\n\n/** How long the recovery reload is given to replace this document before the panel is painted instead. */\nconst RELOAD_GRACE_MS = 2000;\n\n/**\n * Spends the one reload a late `notFound()` gets, or paints if it has already been spent for this URL.\n *\n * `redirect()` is terminal on the client — there is somewhere to navigate to — and `notFound()` is not: the\n * response is already committed as a 200, so the only recovery left is asking for the page again and hoping\n * the signal comes early enough this time to be a real 404. That works where the lateness was incidental, a\n * boundary that happened to resolve after the shell on a slow request. Where it is structural — a page that\n * always signals from a late boundary — the reload gets a byte-identical response and reloads again, and the\n * tab spins until the visitor leaves. In production nothing is logged, because the warning that explains this\n * is `isDev`-only.\n *\n * So it is bounded: one reload per URL per tab, then {@link showLateNotFound}. `sessionStorage` because the\n * value has to outlive the document it is written in and must not outlive the tab, and keyed by URL so a\n * second page's late signal still gets its own attempt.\n */\nfunction reloadOnceForLateNotFound(): void {\n const key = `rshono:late-not-found:${documentUrl()}`;\n let spent: boolean;\n try {\n spent = sessionStorage.getItem(key) !== null;\n if (!spent) sessionStorage.setItem(key, '1');\n } catch {\n // Storage can throw outright where site data is blocked, and a page that cannot count its reloads has\n // to pick a side. It picks the terminating one: a message on a page that might have recovered is a\n // worse outcome than a reload loop only by a lot less.\n spent = true;\n }\n if (spent) {\n showLateNotFound();\n return;\n }\n\n loadOutsideRouter(() => window.location.reload());\n\n // The reload wins this race whenever it happens at all: the document goes away and takes the timer with\n // it. What this covers is a reload that does not happen — swallowed by an interceptor, refused by the\n // browser, held by a `beforeunload` — which used to leave the visitor on a Suspense fallback with nothing\n // coming and nothing said. The panel is the honest answer in that case too.\n setTimeout(() => {\n if (!document.querySelector('[data-rshono-fatal]')) showLateNotFound();\n }, RELOAD_GRACE_MS);\n}\n\n/**\n * Turns a control-signal digest — how `redirect()` / `notFound()` reach the browser — into a real\n * navigation. Returns false for anything else, so callers fall through to their own handling.\n *\n * `hard` forces a full document load, for signals that surfaced *through React*: it unmounts the root on\n * an uncaught error, leaving no live tree to soft-navigate with.\n */\nfunction handleControlDigest(error: unknown, { hard = false }: { hard?: boolean } = {}): boolean {\n const digest = (error as { digest?: unknown } | null)?.digest;\n if (!isControlDigest(digest)) return false;\n const redirect = parseRedirectDigest(digest);\n if (!redirect) {\n reloadOnceForLateNotFound();\n } else if (hard) {\n loadOutsideRouter(() => window.location.assign(new URL(redirect.location, window.location.href).href));\n } else {\n push(redirect.location);\n }\n return true;\n}\n\n/**\n * Puts a payload on screen, resolving once React has committed it. Replaced by `BrowserRoot`'s own on mount;\n * the default covers the window before hydration, where `setServerCallback` is already registered but there\n * is no root to update — a reload is the honest answer, and nothing after it needs to run.\n */\nlet setPayload: (payload: RscPayload) => Promise<void> = () => {\n window.location.reload();\n return new Promise<void>(() => {});\n};\n\n/** Runs work inside the nav transition so `useNavigation().pending` stays true across the round-trip. */\nlet startNav: (run: () => void | Promise<void>) => void = (run) => {\n void run();\n};\n\n/**\n * Fetches the payload for `url` and puts it on screen.\n *\n * Resolves once React has **committed** it rather than when the fetch lands: an intercepted navigation\n * scrolls and moves focus when this promise settles, and a `#hash` target does not exist until the new tree\n * does. Rejects only on a genuine failure — being superseded is not one, and resolves quietly, because the\n * navigation that replaced this one owns the screen from then on.\n */\nfunction loadPayload(url: string, signal?: AbortSignal): Promise<void> {\n // Deliberately not awaited inside the transition: the scope ends once the payload is handed to React, and\n // React holds `pending` until the update it scheduled commits. Awaiting the commit *inside* the scope would\n // work too, but only because React happens not to gate a commit on its async scope settling — an internal\n // this has no reason to depend on across the whole `^19.1.0` peer range.\n let committed: Promise<void> | undefined;\n\n const run = async () => {\n const payload = await requestPayload(url, signal);\n // The browser aborts a navigation the moment a newer one starts. Checked again after the await because\n // the fetch may already have resolved by then, and applying it would repaint a page the user has left.\n if (signal?.aborted) return;\n if (payload.redirect) {\n push(payload.redirect);\n return;\n }\n committed = setPayload(payload);\n };\n\n // `startTransition` runs the work but hands nothing back, so the promise carrying a failure is caught here\n // instead. Assigned synchronously: React invokes the callback before `startNav` returns.\n let work!: Promise<void>;\n startNav(() => (work = run()));\n\n return work.then(\n // Undefined whenever nothing was applied — an abort, or a redirect — and there is then nothing to wait for.\n () => committed,\n (error: unknown) => {\n // Checked before the error is read: an abort is this navigation being replaced, and the one that\n // replaced it owns the outcome.\n if (signal?.aborted || handleControlDigest(error)) return;\n throw error;\n },\n );\n}\n\n/**\n * Navigations the browser can hand over but shouldn't:\n *\n * - a fragment jump, which is same-document already and needs no payload — the browser's own jump is the one\n * that honours `scroll-padding-top`, and re-rendering would pull the target out from under it;\n * - a download, which is not a navigation of this page at all;\n * - a `POST` form, which is a submission and the server's to answer (a `GET` form carries its fields in the\n * URL, has no `formData`, and soft-navigates like any other link);\n * - a link marked `data-native`, the documented opt-out.\n */\nfunction leaveToBrowser(event: NavigateEvent): boolean {\n return event.hashChange || event.downloadRequest !== null || event.formData !== null || event.sourceElement?.hasAttribute('data-native') === true;\n}\n\n/**\n * The whole router, in one listener.\n *\n * Every navigation the page can make arrives as a `navigate` event — a link click, a `GET` form, a\n * `history.pushState`, the back button, `navigation.reload()` — already filtered by the browser: it does not\n * fire for a middle-click, a modified click or a new tab, and reports `canIntercept: false` for anything\n * cross-origin, or for a traversal that leaves the app. Those need no handling here; they are left alone, and\n * the browser performs them as it always would.\n */\nfunction listenNavigation(): () => void {\n if (!canSoftNavigate) return () => {};\n\n const onNavigate = (event: NavigateEvent) => {\n // Cleared as it is consumed, whatever this event turns out to be: the flag names one navigation, and the\n // one it named is the one that just arrived.\n if (bypassRouter) {\n bypassRouter = false;\n return;\n }\n if (!event.canIntercept || leaveToBrowser(event)) return;\n\n // A push or a traversal lands on a new page, so the browser resets the scroll offset — or restores the\n // one it remembers — and moves focus, which is what makes a soft navigation announce itself to a screen\n // reader. A replace or a refresh stays where it is, so neither should move. Both wait on the handler,\n // which is the point of resolving it at commit rather than at fetch.\n const inPlace = event.navigationType === 'replace' || event.navigationType === 'reload';\n\n event.intercept({\n scroll: inPlace ? 'manual' : 'after-transition',\n focusReset: inPlace ? 'manual' : 'after-transition',\n // The URL commits before the handler runs, so a failure leaves the address bar describing a page the\n // document is not showing. A real load is the only way back to agreement.\n handler: () => loadPayload(event.destination.url, event.signal).catch(() => loadOutsideRouter(() => window.location.reload())),\n });\n };\n\n navigation.addEventListener('navigate', onNavigate);\n return () => navigation.removeEventListener('navigate', onNavigate);\n}\n\nasync function main() {\n // The assertion is load-bearing under the compiler that builds this: TypeScript 7 declares `nonce` on\n // HTMLElement, 6 declares it on Element. ESLint runs the older lib — where the narrowing is redundant —\n // so it reports an assertion that `tsc` requires. Believe `typecheck`, not the rule.\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const cspMeta = document.querySelector('meta[property=\"csp-nonce\"]') as HTMLMetaElement | null;\n if (cspMeta?.nonce) __webpack_nonce__ = cspMeta.nonce;\n\n const initialPayload = await createFromReadableStream<RscPayload>(flightStream);\n\n function BrowserRoot() {\n const [payload, setPayloadState] = React.useState(initialPayload);\n const [pending, startTransition] = React.useTransition();\n // The resolver the payload on screen still owes — see {@link loadPayload}.\n const pendingCommit = React.useRef<(() => void) | null>(null);\n\n React.useEffect(() => {\n setPayload = (next) =>\n new Promise<void>((resolve) => {\n // A payload replaced before it ever painted still has a navigation waiting on it. React commits\n // only the newest, so the effect below never runs for the one it skipped: release it here.\n pendingCommit.current?.();\n pendingCommit.current = resolve;\n setPayloadState(next);\n });\n startNav = (run) => startTransition(run);\n }, [startTransition]);\n\n /**\n * Releases the navigation waiting on this payload, which is what lets the browser scroll and move focus\n * now that their target exists. A layout effect, so the pre-scroll position is never painted.\n */\n React.useLayoutEffect(() => {\n const commit = pendingCommit.current;\n pendingCommit.current = null;\n commit?.();\n }, [payload]);\n\n React.useEffect(() => listenNavigation(), []);\n\n const router = React.useMemo<NavigationRouter>(() => ({ push, replace, back, forward, refresh, pending }), [pending]);\n\n return <RouterContext.Provider value={router}>{payload.root}</RouterContext.Provider>;\n }\n\n setServerCallback(async (id, args) => {\n const temporaryReferences = createTemporaryReferenceSet();\n // The document the action is being called from. Every action response carries a fresh payload for that\n // page, so if a navigation has moved on by the time it arrives the payload describes a page the user has\n // left — the return value is still theirs, but painting it is not. Compared without the fragment, which\n // the server never saw.\n const calledFrom = documentUrl();\n const request = createRscRequest(window.location.href, {\n id,\n body: await encodeReply(args, { temporaryReferences }),\n });\n let payload: RscPayload;\n try {\n payload = await createFromFetch<RscPayload>(payloadResponse(request), { temporaryReferences });\n } catch (error) {\n if (handleControlDigest(error)) return undefined;\n throw error;\n }\n if (payload.redirect) {\n push(payload.redirect);\n return undefined;\n }\n if (documentUrl() === calledFrom) React.startTransition(() => void setPayload(payload));\n if (payload.notFound) return undefined;\n const result = payload.returnValue;\n if (!result) {\n // A payload that is not this action's own reply: the server rendered a page in its place. An action\n // that had already run has its result carried across (see `actionResults` in entry.rsc.tsx), so\n // reaching here means the request failed before it ran at all — an undecodable body, most likely.\n // Reading `.ok` off it used to hand the caller `Cannot read properties of undefined`.\n throw new Error('[rshono] the server action produced no result — the request failed around it and the server answered with a page instead. Its log has the error.');\n }\n if (!result.ok) throw result.error;\n return result.value;\n });\n\n // A `redirect()` / `notFound()` from a component below the page root reaches us through React: it rides the\n // flight payload as an error, and boundaries re-throw it so it lands here rather than in a fallback.\n //\n // Installing these hooks opts out of React's own defaults, so everything that isn't a control signal has to\n // be put back by hand — `reportError` rather than a bare log, so error-reporting tools still see it.\n hydrateRoot(document, <BrowserRoot />, {\n formState: initialPayload.formState,\n onCaughtError: (error, errorInfo) => {\n if (handleControlDigest(error, { hard: true })) return;\n // A boundary handled it and the tree is intact, so no overlay over the app's own fallback.\n console.error(error, errorInfo.componentStack ?? '');\n },\n onUncaughtError: (error, errorInfo) => {\n if (handleControlDigest(error, { hard: true })) return;\n // Nothing caught it, so React tears the root down — and the root is `document`.\n globalThis.reportError(error);\n showFatal(error, errorInfo.componentStack);\n },\n });\n\n if (import.meta.webpackHot) {\n initDevRefresh();\n }\n}\n\n/**\n * Dev-only refresh client, listening to the CLI's SSE endpoint:\n *\n * client-built → hot-apply the waiting updates; anything the page can't be patched up to reloads.\n * rsc-update → server component code changed: re-fetch the flight payload, state preserved.\n * hello → sent on (re)connect with the latest build hash; a mismatch means a missed event.\n */\nfunction initDevRefresh() {\n const hot = import.meta.webpackHot!;\n let connectedOnce = false;\n /** The newest build the dev server has announced — what {@link applyClientUpdate} walks towards. */\n let targetHash: string | undefined;\n\n function reload(reason: string, error?: unknown): void {\n console.warn(`[rshono] ${reason} — reloading`, ...(error === undefined ? [] : [error]));\n loadOutsideRouter(() => window.location.reload());\n }\n\n async function applyClientUpdate(): Promise<void> {\n const giveUp = await walkHotUpdates(\n hot,\n () => __webpack_hash__,\n () => targetHash,\n );\n if (giveUp) reload(giveUp.reason, giveUp.error);\n }\n\n async function handle(message: DevMessage): Promise<void> {\n switch (message.type) {\n case 'hello':\n targetHash = message.hash ?? targetHash;\n if (connectedOnce) {\n await applyClientUpdate();\n await loadPayload(window.location.href).catch(() => loadOutsideRouter(() => window.location.reload()));\n }\n connectedOnce = true;\n break;\n case 'client-built':\n targetHash = message.hash;\n await applyClientUpdate();\n break;\n case 'rsc-update':\n console.log('[rshono] server components updated');\n await loadPayload(window.location.href).catch(() => loadOutsideRouter(() => window.location.reload()));\n break;\n }\n }\n\n const source = new EventSource('/_rshono/hmr');\n // Chained rather than handled as they arrive: `hot.check` may only run from `idle`, and a burst of saves\n // puts several frames on the wire inside the time one takes. Queueing drops nothing, because `targetHash`\n // is shared — whichever handler runs next walks to the newest build.\n let queue: Promise<void> = Promise.resolve();\n source.onmessage = (event: MessageEvent<string>) => {\n const message = JSON.parse(event.data) as DevMessage;\n queue = queue.then(() => handle(message)).catch((error) => reload('the dev client failed', error));\n };\n}\n\n// A bootstrap failure — a truncated initial payload, most likely — would otherwise be an unhandled\n// rejection: nothing hydrates, nothing is reported, and the page just sits there.\nmain().catch((error) => {\n console.error('[rshono] the client runtime failed to start:', error);\n showFatal(error);\n});\n"]}
@@ -18,6 +18,13 @@ export type RscPayload = {
18
18
  redirect?: string;
19
19
  notFound?: boolean;
20
20
  };
21
+ /**
22
+ * Resolves and checks every route's own module — page and endpoint alike, `notFound` and `error` included.
23
+ * Called by `rshono build` once this bundle is imported for the prerender pass, so a route that could never
24
+ * serve a request fails the build rather than answering 500 in production. Exported from here rather than
25
+ * driven from the CLI because the fallback pages are on `routeConfig`, which does not leave this module.
26
+ */
27
+ export declare const checkRouteModules: () => Promise<void>;
21
28
  export declare const app: Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
22
29
  /**
23
30
  * The app, handed to whatever is hosting it: this binds a port and exports nothing where rshono owns the
@@ -1 +1 @@
1
- {"version":3,"file":"entry.rsc.d.ts","sourceRoot":"","sources":["../../src/runtime/entry.rsc.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAK5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAsBvD,OAAO,EAA0F,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAmDlI,eAAO,MAAM,MAAM,EAAE,SAAS,KAAK,EAAuB,CAAC;AAE3D,kGAAkG;AAClG,MAAM,MAAM,YAAY,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAExF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AA+kBF,eAAO,MAAM,GAAG,4EAAa,CAAC;AAE9B;;;;;;GAMG"}
1
+ {"version":3,"file":"entry.rsc.d.ts","sourceRoot":"","sources":["../../src/runtime/entry.rsc.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAK5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAsBvD,OAAO,EAA0F,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAmDlI,eAAO,MAAM,MAAM,EAAE,SAAS,KAAK,EAAuB,CAAC;AAE3D,kGAAkG;AAClG,MAAM,MAAM,YAAY,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAExF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAkkBF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,QAAO,OAAO,CAAC,IAAI,CAAoC,CAAC;AAEtF,eAAO,MAAM,GAAG,4EAAa,CAAC;AAE9B;;;;;;GAMG"}
@@ -20,7 +20,7 @@ import { isControlSignal, RedirectSignal } from './control.js';
20
20
  import { renderHTML } from './entry.ssr.js';
21
21
  import { RouterProvider } from './navigation.js';
22
22
  import { asksForRsc, isActionRequest, parseRenderRequest, requestWantsRsc, RSC_VARY_HEADER, wantsRsc } from './request.js';
23
- import { validateRoutesModule, validateServerApp } from './validate-entries.js';
23
+ import { assertEndpointModule, assertPageModule, assertRouteModules, validateRoutesModule, validateServerApp } from './validate-entries.js';
24
24
  const serverApp = validateServerApp(serverAppModule);
25
25
  // Compiled into the bundle from rshono.config.ts by DefinePlugin; there is no runtime env-var interface.
26
26
  const { isDev } = __RSHONO_CONFIG__;
@@ -121,20 +121,6 @@ function refusesCrossSiteForm(c) {
121
121
  return false;
122
122
  return c.req.header('origin') !== publicUrl(c).origin;
123
123
  }
124
- async function loadPageModule(load, label) {
125
- const mod = await load();
126
- const Page = mod.default;
127
- if (typeof Page !== 'function') {
128
- throw new Error(`[rshono] The page module for ${label} must default-export a server component.`);
129
- }
130
- if (!Page.entryJsFiles) {
131
- throw new Error(`[rshono] The page component for ${label} is missing its client-asset info ('use server-entry'). ` +
132
- "The directive is added automatically for inline `component: () => import('…')` thunks in routes.ts. " +
133
- "If this page is wired up another way, put 'use server-entry' on the first line of the page module yourself — " +
134
- "and make sure the page is a server component (a 'use client' page must be wrapped by a server component instead).");
135
- }
136
- return Page;
137
- }
138
124
  /** A browser navigation or a crawler, as opposed to a fetch that would rather have plain text. */
139
125
  function acceptsHtml(c) {
140
126
  return c.req.header('accept')?.includes('text/html') ?? false;
@@ -200,7 +186,9 @@ function warnLateControlSignal(c, signal) {
200
186
  console.warn(`[rshono] ${isRedirect ? `redirect(${JSON.stringify(signal.location)})` : 'notFound()'} was called from a boundary that ` +
201
187
  `resolved after the page shell had already been sent (${c.req.method} ${c.req.path}), so it cannot become a real ` +
202
188
  `${isRedirect ? '3xx' : '404'}: the response is committed as 200 text/html. A browser with JavaScript follows the ` +
203
- `digest that rides the payload; one without stays on the Suspense fallback, and a crawler indexes the 200.${isRedirect ? '' : ' A JavaScript client recovers by reloading, which renders this same page again.'}` +
189
+ `digest that rides the payload; one without stays on the Suspense fallback, and a crawler indexes the 200.${isRedirect
190
+ ? ''
191
+ : ' A JavaScript client asks for the page once more, in case the signal comes early enough that time to be a real 404 — and shows a plain "Page not found" panel when it does not, rather than reloading into the same response forever.'}` +
204
192
  ' Decide before the render starts streaming — in Hono middleware, or in the page component body above the boundary.');
205
193
  }
206
194
  /**
@@ -441,7 +429,7 @@ function buildApp() {
441
429
  app.route('/', serverApp);
442
430
  }
443
431
  runtime.mountStaticAssets(app);
444
- const memoizePage = (page, label) => once(() => loadPageModule(page.component, label));
432
+ const memoizePage = (page, label) => once(async () => assertPageModule(await page.component(), label));
445
433
  const loadNotFoundPage = routeConfig.notFound ? memoizePage(routeConfig.notFound, 'the notFound page') : null;
446
434
  /** Turns a thrown `redirect()` / `notFound()` into the response it stands for. */
447
435
  const respondToControlSignal = async (c, signal) => {
@@ -480,7 +468,7 @@ function buildApp() {
480
468
  if (isPageRoute(route)) {
481
469
  // Both fixed for the life of the process, so resolved once rather than per request.
482
470
  const servesPrerendered = !isDev && route.render === 'static';
483
- const loadPage = once(() => loadPageModule(route.component, `"${route.path}"`));
471
+ const loadPage = once(async () => assertPageModule(await route.component(), `"${route.path}"`));
484
472
  /** Everything the route answers, before a HEAD has its body taken off it. */
485
473
  const respond = async (c) => {
486
474
  try {
@@ -535,9 +523,11 @@ function buildApp() {
535
523
  app.on(['GET', 'POST'], route.path, handler);
536
524
  }
537
525
  else {
538
- const loadEndpoint = once(() => route.server());
526
+ // Checked on the way out of the thunk rather than at the call site, so `once`'s cache holds a handler
527
+ // that has already been proven to be one — and a rejection clears, so the message repeats per request.
528
+ const loadEndpoint = once(async () => assertEndpointModule(await route.server(), `"${route.path}"`));
539
529
  const handler = async (c, next) => {
540
- const { handler: endpointHandler } = await loadEndpoint();
530
+ const endpointHandler = await loadEndpoint();
541
531
  // Hono's `Handler` leaves its return parameter defaulted to `any`, so this hands back exactly what
542
532
  // the app's own handler is declared to return — there is nothing narrower to assert here.
543
533
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
@@ -599,6 +589,13 @@ function buildApp() {
599
589
  });
600
590
  return app;
601
591
  }
592
+ /**
593
+ * Resolves and checks every route's own module — page and endpoint alike, `notFound` and `error` included.
594
+ * Called by `rshono build` once this bundle is imported for the prerender pass, so a route that could never
595
+ * serve a request fails the build rather than answering 500 in production. Exported from here rather than
596
+ * driven from the CLI because the fallback pages are on `routeConfig`, which does not leave this module.
597
+ */
598
+ export const checkRouteModules = () => assertRouteModules(routeConfig);
602
599
  export const app = buildApp();
603
600
  /**
604
601
  * The app, handed to whatever is hosting it: this binds a port and exports nothing where rshono owns the
@@ -1 +1 @@
1
- {"version":3,"file":"entry.rsc.js","sourceRoot":"","sources":["../../src/runtime/entry.rsc.tsx"],"names":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AK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7G,wGAAwG;QACxG,qGAAqG;QACrG,OAAO,CAAC,CAAC,IAAI,CAAC,wBAAwB,MAAM,EAAE,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,kBAAkB,EAAE,CAAC,CAAC;IACvH,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,CAAC,MAAM,GAAG,GAAG,QAAQ,EAAE,CAAC;AAE9B;;;;;;GAMG;AACH,eAAe,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC","sourcesContent":["import type { Context, Handler } from 'hono';\nimport { Hono } from 'hono';\nimport { HTTPException } from 'hono/http-exception';\n// Type-only side effect: augments Hono's `ContextVariableMap` with `secureHeadersNonce`, read in `cspNonce`.\nimport type {} from 'hono/secure-headers';\nimport type { ContentfulStatusCode, RedirectStatusCode } from 'hono/utils/http-status';\nimport type React from 'react';\nimport type { ReactFormState } from 'react-dom/client';\n// Called directly rather than as `<Page {...props} />`: a spread would drop the non-enumerable `ctx`\n// prop. See `pageProps`.\nimport { jsx } from 'react/jsx-runtime';\n// The bare specifier, not `/server.node`: the RSC layer's `conditionNames` picks the build for the\n// deploy target being compiled for.\nimport {\n createTemporaryReferenceSet,\n decodeAction,\n decodeFormState,\n decodeReply,\n loadServerAction,\n renderToReadableStream,\n type ServerEntry,\n type TemporaryReferenceSet,\n} from 'react-server-dom-rspack/server';\n// Aliased at build time to the selected preset's runtime — the one place this file knows where it runs.\nimport { runtime } from '@rshono/deploy';\n// @ts-expect-error — resolved by the '@rshono/routes' alias to the app's routes.ts\nimport { routes as userRoutes } from '@rshono/routes';\n// @ts-expect-error — resolved by the '@rshono/server-app' alias (src/server.ts or the empty fallback)\nimport * as serverAppModule from '@rshono/server-app';\nimport { isPageRoute, type ErrorPageInfo, type FallbackPage, type PageComponent, type PageProps, type Route } from '../router.js';\nimport { appendVary, etagMatches } from '../server/headers.js';\nimport { beginPageRender, getRequestContext, publicUrl, readParams, reportServerError, runWithContext } from './context.js';\nimport { isControlSignal, RedirectSignal, type ControlSignal } from './control.js';\nimport { renderHTML } from './entry.ssr.js';\n// Type-only, so it is erased — the RSC layer does not take its own instance of the SSR layer's module.\nimport type { CancellableTransformer } from './flight-inject.js';\nimport { RouterProvider } from './navigation.js';\nimport { asksForRsc, isActionRequest, parseRenderRequest, requestWantsRsc, RSC_VARY_HEADER, wantsRsc } from './request.js';\nimport { validateRoutesModule, validateServerApp } from './validate-entries.js';\n\nconst serverApp = validateServerApp(serverAppModule);\n\n// Compiled into the bundle from rshono.config.ts by DefinePlugin; there is no runtime env-var interface.\nconst { isDev } = __RSHONO_CONFIG__;\n\n/**\n * How long a prerendered page may be reused before revalidating. Also what `public/` files get.\n *\n * Not a config field, deliberately: it is a per-response header, and `rshono.config.ts` is compiled into the\n * bundle — a cache policy you cannot change without a rebuild is the wrong shape. An app that wants a longer\n * `max-age`, or a `stale-while-revalidate`, sets it from middleware **after `await next()`**:\n *\n * ```ts\n * server.use('/docs/*', async (c, next) => {\n * await next();\n * c.res.headers.set('cache-control', 'public, max-age=86400, stale-while-revalidate=604800');\n * });\n * ```\n *\n * After, because the response below is built with `cache-control` in the bag it hands `c.body(...)`, and\n * that replaces a header prepared with `c.header(...)` before the handler ran. The `ETag` is untouched\n * either way, so revalidation still costs a 304 rather than the page.\n */\nconst SSG_CACHE_CONTROL = 'public, max-age=300';\n\n/**\n * What a page response gets when nothing else set one: without it a shared cache is free to store a logged-in\n * user's page and hand it to someone else. `private, no-cache` forbids that without blocking bfcache, which\n * `no-store` would.\n */\nconst PAGE_CACHE_CONTROL = 'private, no-cache';\n\n/** The two content types a page can be served as, from the same URL — which is what makes `Vary` non-optional. */\nconst PAGE_CONTENT_TYPE = /^(?:text\\/html|text\\/x-component)\\b/;\n\nruntime.loadEnv();\n\n// Checked rather than cast: these two modules are the app's, and a mistake in either used to surface as a\n// `TypeError` from somewhere else entirely — or, for a duplicated path, as nothing at all.\nconst routeConfig = validateRoutesModule(userRoutes);\nexport const routes: readonly Route[] = routeConfig.routes;\n\n/** The result of a server action, as a `Result<T, E>` rather than an `ok` flag over one field. */\nexport type ActionResult = { ok: true; value: unknown } | { ok: false; error: unknown };\n\nexport type RscPayload = {\n root: React.ReactNode;\n returnValue?: ActionResult;\n formState?: ReactFormState;\n redirect?: string;\n notFound?: boolean;\n};\n\n/**\n * The result of an action that has already run, for the request whose *render* then failed.\n *\n * The action and the page it answers with are one response: an action returns its value through the payload\n * of the page rendered after it. So when that render throws — a page module that will not load, most\n * plausibly a chunk that went away mid-deploy — `onError` renders the `error` page in its place, and without\n * this the reply carries no `returnValue` at all. The caller of an action that ran, and may well have\n * written something, would be told only that a field was missing.\n *\n * Keyed on the Hono context the way `beginPageRender` keys its own marker, and weakly, so nothing outlives\n * the request it belongs to.\n */\nconst actionResults = new WeakMap<Context, ActionResult>();\n\n/**\n * The per-request CSP nonce, if the app asked for one.\n *\n * The framework never mints it: `secureHeaders()` does, when its policy contains the `NONCE`\n * placeholder, and stores it here — so all the framework does is stamp the value into the render. It is\n * readable from a route handler because `secureHeaders` resolves its directives before `next()`.\n */\nfunction cspNonce(c: Context): string | undefined {\n return c.get('secureHeadersNonce');\n}\n\n/**\n * Whether a `<form action={serverAction}>` post came from another site, and so must not be allowed to run one.\n *\n * This is not CSRF policy — that is `csrf()` from Hono, registered in `src/server.ts`, which runs ahead of\n * every page route and covers far more than this. It is the framework declining to run *its own* action\n * mechanism for a request that mechanism cannot legitimately produce, in the one place the two action shapes\n * are not equally exposed:\n *\n * - A client-initiated action carries `x-rsc-action`, which is not a CORS-simple header. A cross-origin caller\n * needs a preflight it will not be given, so that shape cannot be forged from a browser at all.\n * - A form post is `multipart/form-data` or `application/x-www-form-urlencoded` with no header of its own —\n * the content types that need no preflight. It is forgeable, and an app with no `src/server.ts` has nothing\n * standing in front of it.\n *\n * Both halves are required, because either alone refuses something real:\n *\n * - `Sec-Fetch-Site` is the browser's own statement of provenance, unforgeable by page script, and every\n * browser that can post a form to a server action sends it. `cross-site` and `same-site` are the two labels\n * that mean \"not from this origin\" — `same-site` is what a *sibling subdomain* gets, which is a user-content\n * host, a stale CNAME or a subdomain takeover, so leaving it to `csrf()` meant an app without one could have\n * any `'use server'` export driven from next door. An absent header means a non-browser client, which cannot\n * be a CSRF victim. `same-origin` and `none` settle it on their own, and are what a genuine post carries\n * however many proxies rewrote `Host` on the way in.\n * - An `Origin` that is the app's own contradicts either label — a browser calls a post from the app's own pages\n * `same-origin` — so the pair is a shape no browser produces, and refusing it would only catch a proxy or a\n * test client setting the label by hand while posting from the app itself. Nothing else clears the label:\n * an `Origin` of `null` (a sandboxed iframe, a `data:` URL, `Referrer-Policy: no-referrer`) and no `Origin`\n * at all are both refused. A browser attaches one to every non-GET request, so neither is a shape it\n * produces — but a security predicate that says \"not proven foreign\" rather than \"proven local\" fails open\n * the day something does produce it.\n *\n * `publicUrl(c)` rather than `c.req.url`, so it honours `trustProxy` and compares against the origin the\n * browser actually used — which behind a proxy, `rshono dev`'s included, is not the one the server was reached\n * on. The cost is that an app deliberately accepting *form* posts to an action from another origin of its own\n * cannot, `csrf()`'s allowlist included; that is what an `{ type: 'endpoint' }` route is for.\n */\nfunction refusesCrossSiteForm(c: Context): boolean {\n const site = c.req.header('sec-fetch-site');\n if (site !== 'cross-site' && site !== 'same-site') return false;\n return c.req.header('origin') !== publicUrl(c).origin;\n}\n\nasync function loadPageModule(load: () => Promise<{ default: PageComponent }>, label: string): Promise<ServerEntry<PageComponent>> {\n const mod = await load();\n const Page = mod.default as ServerEntry<PageComponent> | undefined;\n if (typeof Page !== 'function') {\n throw new Error(`[rshono] The page module for ${label} must default-export a server component.`);\n }\n if (!Page.entryJsFiles) {\n throw new Error(\n `[rshono] The page component for ${label} is missing its client-asset info ('use server-entry'). ` +\n \"The directive is added automatically for inline `component: () => import('…')` thunks in routes.ts. \" +\n \"If this page is wired up another way, put 'use server-entry' on the first line of the page module yourself — \" +\n \"and make sure the page is a server component (a 'use client' page must be wrapped by a server component instead).\",\n );\n }\n return Page;\n}\n\n/** A browser navigation or a crawler, as opposed to a fetch that would rather have plain text. */\nfunction acceptsHtml(c: Context): boolean {\n return c.req.header('accept')?.includes('text/html') ?? false;\n}\n\n/**\n * The 404 for an app with no `notFound` page, and for a client that wanted neither HTML nor a flight\n * payload. It carries the `Vary` too: this is one of the answers a page URL gives depending on the `RSC` request header.\n */\nfunction plainNotFound(c: Context): Response {\n // `cache-control` explicitly, because the default above is applied to page *content types* and this is\n // `text/plain`. A 404 is heuristically cacheable under RFC 9111, so without it a shared cache may store\n // this one — while the rendered HTML 404 next to it, the same answer to the same request from a client\n // that asked for HTML, is correctly private.\n return c.text('Not Found', 404, { vary: RSC_VARY_HEADER, 'cache-control': PAGE_CACHE_CONTROL });\n}\n\n/** A lazy once-cell: runs `load` at most once, but clears a rejection so a later call can retry. */\nfunction once<T>(load: () => Promise<T>): () => Promise<T> {\n let promise: Promise<T> | undefined;\n return () => {\n if (!promise) {\n const pending = (promise = load());\n pending.catch(() => {\n if (promise === pending) promise = undefined;\n });\n }\n return promise;\n };\n}\n\n/**\n * Passes `stream` through untouched, calling `done` however it ends — for the flight-only response\n * path, which has no transform of its own to hang a completion hook off. `done` must be idempotent.\n */\nfunction releaseWhenDone(stream: ReadableStream<Uint8Array>, done: () => void): ReadableStream<Uint8Array> {\n return stream.pipeThrough(\n new TransformStream<Uint8Array, Uint8Array>({\n transform(chunk, controller) {\n controller.enqueue(chunk);\n },\n flush: done,\n cancel: done,\n } as CancellableTransformer<Uint8Array, Uint8Array>),\n );\n}\n\n/**\n * A macrotask boundary: `setImmediate` where there is one — the current turn's check phase rather than a\n * timer — and `setTimeout` as the portable fallback, for a runtime without it. `flight-inject.ts` has the\n * same two lines and the same reason; they are not shared because that module belongs to the SSR layer, and\n * importing it here would give the RSC layer its own instance of it.\n */\nconst deferTask: (run: () => void) => void =\n typeof setImmediate === 'function'\n ? setImmediate\n : (run) => {\n setTimeout(run, 0);\n };\n\n/**\n * Dev-only: says that a control signal arrived too late to be one.\n *\n * The root fix is in app code, so authoring time is where this has to be said, and a docs paragraph is not\n * where anyone reads it. `isDev` is the baked build flag, so a production server pays one boolean check on a\n * path that has already gone wrong — and says nothing.\n */\nfunction warnLateControlSignal(c: Context, signal: ControlSignal): void {\n const isRedirect = signal instanceof RedirectSignal;\n console.warn(\n `[rshono] ${isRedirect ? `redirect(${JSON.stringify(signal.location)})` : 'notFound()'} was called from a boundary that ` +\n `resolved after the page shell had already been sent (${c.req.method} ${c.req.path}), so it cannot become a real ` +\n `${isRedirect ? '3xx' : '404'}: the response is committed as 200 text/html. A browser with JavaScript follows the ` +\n `digest that rides the payload; one without stays on the Suspense fallback, and a crawler indexes the 200.${\n isRedirect ? '' : ' A JavaScript client recovers by reloading, which renders this same page again.'\n }` +\n ' Decide before the render starts streaming — in Hono middleware, or in the page component body above the boundary.',\n );\n}\n\ninterface ComponentRenderOptions {\n status?: number;\n isRsc: boolean;\n formState?: ReactFormState;\n returnValue?: RscPayload['returnValue'];\n temporaryReferences?: TemporaryReferenceSet;\n /** Passed when the page being rendered is the `error` page, which takes it as an extra prop. */\n errorInfo?: ErrorPageInfo;\n /** Marks the payload as the not-found page, so a soft navigation can tell it apart from the page it asked for. */\n notFound?: boolean;\n}\n\n/**\n * Builds the props a page component is called with.\n *\n * `ctx` is *defined* rather than assigned, and both halves are load-bearing:\n *\n * - **A getter**, so nothing is built for the pages that never read it, and a `render: 'static'` page\n * that does gets {@link getRequestContext}'s prerendering error rather than a bare `undefined`.\n * - **Non-enumerable**, so React's dev-only serialization of a server component's props skips it. That\n * walks own enumerable properties, and `ctx.hono.env` holds the runtime's bindings — an enumerable\n * `ctx` would ship every secret to the browser in dev.\n *\n * The cost: the element is created by handing this object to `jsx()` by reference, since a\n * `<Page {...props} />` spread would silently drop `ctx`.\n */\nfunction pageProps(c: Context, errorInfo: ErrorPageInfo | undefined): PageProps & { error?: ErrorPageInfo } {\n const props = { url: publicUrl(c), params: readParams(c), ...(errorInfo ? { error: errorInfo } : null) };\n Object.defineProperty(props, 'ctx', { get: getRequestContext, enumerable: false, configurable: true });\n return props as PageProps & { error?: ErrorPageInfo };\n}\n\nasync function renderComponent(c: Context, Page: ServerEntry<PageComponent>, opts: ComponentRenderOptions): Promise<Response> {\n // React's renderers must never be handed `c.req.raw.signal`: they add an `abort` listener and only\n // remove it if the abort fires, so on the happy path it stays on a request-lifetime signal and pins the\n // whole rendered tree. The render gets its own controller and the request signal forwards into it —\n // `release` detaches on the normal path. Not `AbortSignal.any()`, whose composite signals Node holds in\n // a process-lifetime set until they abort.\n const requestSignal = c.req.raw.signal;\n const renderAbort = new AbortController();\n const signal = renderAbort.signal;\n const forwardAbort = () => renderAbort.abort(requestSignal.reason);\n if (requestSignal.aborted) renderAbort.abort(requestSignal.reason);\n else requestSignal.addEventListener('abort', forwardAbort, { once: true });\n const release = () => requestSignal.removeEventListener('abort', forwardAbort);\n\n // Documents only: the nonce goes on the bootstrap scripts and the `<meta>` React hydrates from, and a\n // flight payload has neither — which is what keeps a prerendered one servable under a nonce-based CSP.\n const nonce = opts.isRsc ? undefined : cspNonce(c);\n const props = pageProps(c, opts.errorInfo);\n const root = (\n <>\n {nonce && <meta property=\"csp-nonce\" nonce={nonce} />}\n {Page.entryCssFiles?.map((href) => (\n <link key={href} rel=\"stylesheet\" href={href} precedence=\"default\" />\n ))}\n {/* `href`, not the `URL`: these props cross into a client component, so they have to be serializable. */}\n <RouterProvider href={props.url.href} params={props.params}>\n {jsx(Page, props)}\n </RouterProvider>\n </>\n );\n\n // `notFound` only when true, so an ordinary page's payload doesn't carry the key.\n const rscPayload: RscPayload = { root, formState: opts.formState, returnValue: opts.returnValue, ...(opts.notFound ? { notFound: true } : null) };\n\n // The last thing before the render: past here the response head is the framework's, so `ctx.setHeader()`\n // starts throwing — while the action `renderPage` just ran, and the middleware around it, legitimately wrote.\n beginPageRender(c);\n\n let controlSignal: ControlSignal | undefined;\n /** Set once `renderHTML` has returned, which is where the response head stops being changeable. */\n let shellFlushed = false;\n const rscStream = renderToReadableStream(rscPayload, {\n temporaryReferences: opts.temporaryReferences,\n signal,\n onError(error) {\n if (isControlSignal(error)) {\n controlSignal = error;\n if (shellFlushed) {\n if (isDev) warnLateControlSignal(c, error);\n // Past the shell the status line, the headers and the first bytes are on the wire, so the digest\n // React writes into the payload is the only path left — and everything still rendering is for a\n // page the browser is about to navigate away from. Winding it down stops those boundaries, runs\n // `flight-inject`'s cancel/flush, and fires the `release()` above now rather than whenever the\n // doomed render happens to finish.\n //\n // One macrotask later rather than from inside `onError`, where React is still handling the error\n // that produced the digest — the row carrying it is the only recovery the client has, and an abort\n // that re-entered React there could cut the render off before it is written. Measured to survive\n // either way on react-server-dom-rspack 0.1.0; deferred anyway, because that ordering is an\n // internal the `^19.1.0` peer range does not promise, and the cost is one macrotask on a render\n // that is already doomed. The reason is the signal itself, so every boundary the abort errors\n // carries the digest rather than a bare AbortError the client would paint as a fault.\n if (!signal.aborted) deferTask(() => renderAbort.abort(error));\n }\n return error.digest;\n }\n if (!signal.aborted) reportServerError(error, { source: 'render', hono: c, message: '[rshono] render error:' });\n },\n });\n\n if (opts.isRsc) {\n return c.body(releaseWhenDone(rscStream, release), (opts.status ?? 200) as ContentfulStatusCode, {\n 'content-type': 'text/x-component;charset=utf-8',\n });\n }\n\n let ssrResult: Awaited<ReturnType<typeof renderHTML>>;\n try {\n ssrResult = await renderHTML(rscStream, {\n bootstrapScripts: Page.entryJsFiles,\n formState: opts.formState,\n signal,\n nonce,\n onDone: release,\n onShellError: (error) => reportServerError(error, { source: 'ssr', hono: c, message: '[rshono] SSR shell error:' }),\n onError: (error) => reportServerError(error, { source: 'ssr', hono: c, message: '[rshono] SSR error:' }),\n });\n } catch (error) {\n release();\n if (controlSignal) throw controlSignal;\n throw error;\n }\n // `renderHTML` returns at *shell ready*, so from here the response is the one that ships. Set before the\n // check below rather than after it, so nothing lands in the window between the two: a signal that arrives\n // in it is handled there *and* schedules an abort, and aborting an aborted controller is a no-op.\n shellFlushed = true;\n if (controlSignal) {\n // The shell resolved, so this response is live: React is being pumped into the payload-injecting\n // transform, and a `redirect()` that surfaced from a boundary settling just before the shell was ready\n // lands here. Nothing will read that stream now — the signal becomes a redirect instead — so it is stopped\n // rather than left to render to completion for a response that was replaced.\n //\n // Both calls, because they stop different halves. `abort` reaches the two renders through the signal they\n // were handed; cancelling the response readable propagates back through the transform to release the teed\n // flight branch it holds a reader on, which `abort` alone does not.\n renderAbort.abort();\n void ssrResult.stream.cancel().catch(() => {\n // Already errored or locked — there is nothing left to release either way.\n });\n release();\n throw controlSignal;\n }\n return c.body(ssrResult.stream, (ssrResult.status ?? opts.status ?? 200) as ContentfulStatusCode, {\n 'content-type': 'text/html;charset=utf-8',\n });\n}\n\nasync function renderPage(c: Context, loadPage: () => Promise<ServerEntry<PageComponent>>): Promise<Response> {\n const request = c.req.raw;\n const renderRequest = parseRenderRequest(request);\n\n let returnValue: ActionResult | undefined;\n let formState: ReactFormState | undefined;\n let temporaryReferences: TemporaryReferenceSet | undefined;\n let actionStatus: number | undefined;\n if (isActionRequest(renderRequest)) {\n if (renderRequest.kind === 'rsc-action') {\n // Before the body is decoded, so an unknown id costs nothing to reject. `hasOwn` so `__proto__`\n // does not resolve to a manifest entry.\n if (!Object.hasOwn(__rspack_rsc_manifest__.serverManifest, renderRequest.actionId)) {\n return c.text('Bad Request: unknown server action', 400);\n }\n const contentType = request.headers.get('content-type');\n const body = contentType?.startsWith('multipart/form-data') ? await request.formData() : await request.text();\n temporaryReferences = createTemporaryReferenceSet();\n const args = await decodeReply<unknown[]>(body, { temporaryReferences });\n const action = loadServerAction(renderRequest.actionId);\n try {\n returnValue = { ok: true, value: await action(...args) };\n } catch (error) {\n if (isControlSignal(error)) throw error;\n // In production React sends a thrown action error to the client as an opaque marker, so this is\n // the only place the real one is visible.\n reportServerError(error, { source: 'action', hono: c, message: '[rshono] server action error:' });\n returnValue = { ok: false, error };\n actionStatus = 500;\n }\n // The action is done and its result is the caller's, whatever becomes of the render below. See\n // {@link actionResults}.\n actionResults.set(c, returnValue);\n } else {\n // A `<form action={serverAction}>` post, which is the path that runs before hydration and with\n // JavaScript off. Unlike the client-initiated one it carries no custom header, so it is also the only\n // action shape a browser can be made to send from another site: see `refusesCrossSiteForm`.\n if (refusesCrossSiteForm(c)) {\n return c.text('Forbidden: cross-site form post to a server action', 403, { vary: RSC_VARY_HEADER });\n }\n const formData = await request.formData();\n const decodedAction = await decodeAction(formData, __rspack_rsc_manifest__.serverManifest);\n if (decodedAction) {\n let result: unknown;\n try {\n result = await decodedAction();\n } catch (error) {\n if (isControlSignal(error)) throw error;\n // Reported here so a no-JS form post is attributed to the action that threw, exactly as the\n // client-initiated path is — the top-level handler would call it a `request`. Then re-thrown,\n // because this path has no client boundary and no `useActionState` to hand the error to, so the\n // app's `error` page is the honest answer. `reportServerError` de-duplicates, so the re-throw\n // reaching `onError` does not report it a second time.\n reportServerError(error, { source: 'action', hono: c, message: '[rshono] server action error:' });\n throw error;\n }\n formState = (await decodeFormState(result, formData, __rspack_rsc_manifest__.serverManifest)) ?? undefined;\n }\n }\n }\n\n const Page = await loadPage();\n return renderComponent(c, Page, {\n status: actionStatus,\n isRsc: wantsRsc(renderRequest),\n formState,\n returnValue,\n temporaryReferences,\n });\n}\n\nfunction buildApp(): Hono {\n const app = new Hono();\n\n // A floor, not a policy: an app wanting the full set registers `secureHeaders()` in src/server.ts, and\n // because this is registered first it unwinds last, so the \"only if unset\" checks stand aside for it.\n // Owned by the framework so that an app with no src/server.ts at all still gets it.\n app.use(async (c, next) => {\n await next();\n const headers = c.res.headers;\n if (!headers.has('x-content-type-options')) headers.set('x-content-type-options', 'nosniff');\n if (!headers.has('referrer-policy')) headers.set('referrer-policy', 'strict-origin-when-cross-origin');\n if (!headers.has('x-frame-options')) headers.set('x-frame-options', 'SAMEORIGIN');\n\n // React Refresh compiles updates with `eval`, so a dev build cannot run under a production CSP.\n // Widened here so one policy in src/server.ts serves both.\n if (isDev) {\n const csp = headers.get('content-security-policy');\n if (csp?.includes('script-src ')) {\n headers.set('content-security-policy', csp.replace('script-src ', \"script-src 'unsafe-eval' \"));\n }\n }\n\n // Page responses only from here down.\n if (!PAGE_CONTENT_TYPE.test(headers.get('content-type') ?? '')) return;\n appendVary(headers, RSC_VARY_HEADER);\n if (!headers.has('cache-control')) headers.set('cache-control', PAGE_CACHE_CONTROL);\n });\n\n // First, so the app's own middleware (`csrf()`, `bodyLimit()`, auth, logging) wraps everything registered\n // below: the page routes, and the asset handlers too. Assets used to be mounted ahead of this, which left\n // `/_static/*` answered by a terminal handler nothing of the app's ever saw — no `secureHeaders()`, and so\n // no HSTS on exactly the requests a downgrade attack lands on. The flip side is the same one it always had,\n // one path wider: a *terminal* handler in src/server.ts shadows a page at the same path, and unscoped\n // middleware now also runs for `/_static`, which is a reserved prefix an app should not be matching on\n // purpose anyway.\n if (serverApp) {\n app.route('/', serverApp);\n }\n\n runtime.mountStaticAssets(app);\n\n const memoizePage = (page: FallbackPage, label: string) => once(() => loadPageModule(page.component, label));\n const loadNotFoundPage = routeConfig.notFound ? memoizePage(routeConfig.notFound, 'the notFound page') : null;\n\n /** Turns a thrown `redirect()` / `notFound()` into the response it stands for. */\n const respondToControlSignal = async (c: Context, signal: ControlSignal): Promise<Response> => {\n const isRsc = requestWantsRsc(c.req.raw);\n if (signal instanceof RedirectSignal) {\n if (isRsc) {\n // No `signal`: two fields and no component tree, so there is nothing worth aborting.\n return c.body(renderToReadableStream({ root: null, redirect: signal.location } satisfies RscPayload), 200, {\n 'content-type': 'text/x-component;charset=utf-8',\n });\n }\n return c.redirect(signal.location, signal.status as RedirectStatusCode);\n }\n if (loadNotFoundPage) {\n try {\n return await renderComponent(c, await loadNotFoundPage(), { status: 404, isRsc, notFound: true });\n } catch (error) {\n // The `notFound` page is already the answer to a request that went wrong, so a failure here has\n // nowhere to escalate to: this runs from `onError` as well as from the page handler, and Hono calls\n // `onError` inside its own catch — a throw from there rejects `app.fetch`, which\n // `@hono/node-server` turns into a bodiless 500 with nothing in the log. So it is answered here, the\n // way a failing `error` page is answered below.\n //\n // A `redirect()` from the page is the exception: nothing is committed yet, the branch above cannot\n // fail, and this is what the same page does when `app.notFound` renders it — so it is honoured, and\n // recurses exactly once.\n if (error instanceof RedirectSignal) return respondToControlSignal(c, error);\n reportServerError(error, { source: 'render', hono: c, message: '[rshono] the notFound page failed to render:' });\n }\n }\n return plainNotFound(c);\n };\n\n for (const route of routes) {\n if (isPageRoute(route)) {\n // Both fixed for the life of the process, so resolved once rather than per request.\n const servesPrerendered = !isDev && route.render === 'static';\n const loadPage = once(() => loadPageModule(route.component, `\"${route.path}\"`));\n\n /** Everything the route answers, before a HEAD has its body taken off it. */\n const respond = async (c: Context): Promise<Response> => {\n try {\n // A HEAD takes the GET path, prerendered bytes included: the headers it promises are the ones a\n // GET would send, `etag` and `content-length` among them.\n if (servesPrerendered && (c.req.method === 'GET' || c.req.method === 'HEAD')) {\n const isRsc = asksForRsc(c.req.raw);\n // One fixed set of bytes cannot carry a per-request nonce, so a document has to be rendered\n // where the app's CSP has one. Decided per request, so an app whose policy carries no `NONCE`\n // keeps its prerendered documents. A flight payload never carries a nonce either way.\n const mustRenderForNonce = !isRsc && cspNonce(c) !== undefined;\n if (!mustRenderForNonce) {\n const page = await runtime.readPrerendered(c, isRsc ? 'flight' : 'html');\n // Request-independent by construction, so it is safe to cache publicly; the ETag turns the\n // revalidation that follows into a 304. Answered outside `runWithContext` — no app code runs\n // on this path, so there is no `getRequestContext()` to serve.\n if (page !== null) {\n const headers = {\n 'cache-control': SSG_CACHE_CONTROL,\n etag: page.etag,\n vary: RSC_VARY_HEADER,\n 'content-type': isRsc ? 'text/x-component;charset=utf-8' : 'text/html;charset=utf-8',\n };\n if (etagMatches(c.req.header('if-none-match'), page.etag)) return c.body(null, 304, headers);\n return c.body(page.body, 200, { ...headers, 'content-length': page.contentLength });\n }\n }\n }\n return await runWithContext(c, () => renderPage(c, loadPage));\n } catch (error) {\n if (isControlSignal(error)) return runWithContext(c, () => respondToControlSignal(c, error));\n throw error;\n }\n };\n\n const handler: Handler = async (c) => {\n const response = await respond(c);\n // Hono dispatches a HEAD to the GET route and then rebuilds the response as `new Response(null, res)`,\n // which drops the body without reading it — so for a rendered page nothing ever consumes the stream:\n // `flight-inject`'s `cancel` never runs, and neither does the `release()` that detaches the abort\n // forwarder from the request signal. Cancelling here is what ends the render nobody asked to read.\n if (c.req.method === 'HEAD' && response.body !== null) {\n void response.body.cancel().catch(() => {\n // Already errored or locked, and there is nothing left to release either way.\n });\n return new Response(null, response);\n }\n return response;\n };\n app.on(['GET', 'POST'], route.path, handler);\n } else {\n const loadEndpoint = once(() => route.server());\n const handler: Handler = async (c, next) => {\n const { handler: endpointHandler } = await loadEndpoint();\n // Hono's `Handler` leaves its return parameter defaulted to `any`, so this hands back exactly what\n // the app's own handler is declared to return — there is nothing narrower to assert here.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return endpointHandler(c, next);\n };\n // De-duplicated, because `app.on(['GET', 'GET'], …)` registers the path twice. Validation refuses\n // `'all'` inside a list, so a list that reaches here is concrete methods only.\n const methods = [...new Set([route.method ?? 'all'].flat())];\n if (methods.includes('all')) app.all(route.path, handler);\n else {\n app.on(\n methods.map((method) => method.toUpperCase()),\n route.path,\n handler,\n );\n }\n }\n }\n\n runtime.mountPublicFallback(app);\n\n app.notFound(async (c) => {\n const isRsc = requestWantsRsc(c.req.raw);\n if (loadNotFoundPage && (isRsc || acceptsHtml(c))) {\n // `notFound: true` here as well as on the signal path: the two produce the same page for the same\n // status, and a payload that says so from one route and not the other is a wire contract with a hole\n // in it. The client reads it to tell \"this is the 404 page\" from \"this is the page you asked for\".\n return runWithContext(c, async () => renderComponent(c, await loadNotFoundPage(), { status: 404, isRsc, notFound: true }));\n }\n return plainNotFound(c);\n });\n\n const loadErrorPage = routeConfig.error ? memoizePage(routeConfig.error, 'the error page') : null;\n app.onError(async (error, c) => {\n if (isControlSignal(error)) return runWithContext(c, () => respondToControlSignal(c, error));\n // Registering an `onError` replaces Hono's default handler, which is what turns an `HTTPException`\n // into the response it carries — without this, `csrf()`'s 403 and `bodyLimit()`'s 413 would both\n // surface as a 500 error page. Rebuilt through `c`, as Hono's default does, so headers middleware\n // already prepared survive.\n if (error instanceof HTTPException) {\n const res = error.getResponse();\n return c.newResponse(res.body, res);\n }\n reportServerError(error, { source: 'request', hono: c, message: '[rshono] request error:' });\n const isRsc = requestWantsRsc(c.req.raw);\n if (loadErrorPage && (isRsc || acceptsHtml(c))) {\n const errorInfo: ErrorPageInfo = isDev\n ? {\n message: error instanceof Error ? error.message : String(error),\n stack: error instanceof Error ? error.stack : undefined,\n }\n : { message: 'Internal Server Error' };\n try {\n return await runWithContext(c, async () =>\n renderComponent(c, await loadErrorPage(), { status: 500, isRsc, errorInfo, returnValue: actionResults.get(c) }),\n );\n } catch (renderError) {\n reportServerError(renderError, { source: 'request', hono: c, message: '[rshono] the error page failed to render:' });\n }\n }\n const detail = isDev ? `\\n\\n${error instanceof Error ? (error.stack ?? error.message) : String(error)}` : '';\n // Same reason as `plainNotFound`, minus the urgency: a 500 is not heuristically cacheable, so this half\n // is consistency — the framework's own answers should not differ in what they promise about caching.\n return c.text(`Internal Server Error${detail}`, 500, { vary: RSC_VARY_HEADER, 'cache-control': PAGE_CACHE_CONTROL });\n });\n\n return app;\n}\n\nexport const app = buildApp();\n\n/**\n * The app, handed to whatever is hosting it: this binds a port and exports nothing where rshono owns the\n * process, and *is* the export the platform looks for where the host owns it — so one entry serves both.\n *\n * `app` and `routes` stay named exports either way, because `rshono build` imports them to prerender\n * `render: 'static'` routes.\n */\nexport default runtime.serveApp(app);\n"]}
1
+ {"version":3,"file":"entry.rsc.js","sourceRoot":"","sources":["../../src/runtime/entry.rsc.tsx"],"names":[],"mappings":";AACA,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AACb,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAkB,EAAE,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;AAEtF,MAAM,CAAC,MAAM,GAAG,GAAG,QAAQ,EAAE,CAAC;AAE9B;;;;;;GAMG;AACH,eAAe,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC","sourcesContent":["import type { Context, Handler } from 'hono';\nimport { Hono } from 'hono';\nimport { HTTPException } from 'hono/http-exception';\n// Type-only side effect: augments Hono's `ContextVariableMap` with `secureHeadersNonce`, read in `cspNonce`.\nimport type {} from 'hono/secure-headers';\nimport type { ContentfulStatusCode, RedirectStatusCode } from 'hono/utils/http-status';\nimport type React from 'react';\nimport type { ReactFormState } from 'react-dom/client';\n// Called directly rather than as `<Page {...props} />`: a spread would drop the non-enumerable `ctx`\n// prop. See `pageProps`.\nimport { jsx } from 'react/jsx-runtime';\n// The bare specifier, not `/server.node`: the RSC layer's `conditionNames` picks the build for the\n// deploy target being compiled for.\nimport {\n createTemporaryReferenceSet,\n decodeAction,\n decodeFormState,\n decodeReply,\n loadServerAction,\n renderToReadableStream,\n type ServerEntry,\n type TemporaryReferenceSet,\n} from 'react-server-dom-rspack/server';\n// Aliased at build time to the selected preset's runtime — the one place this file knows where it runs.\nimport { runtime } from '@rshono/deploy';\n// @ts-expect-error — resolved by the '@rshono/routes' alias to the app's routes.ts\nimport { routes as userRoutes } from '@rshono/routes';\n// @ts-expect-error — resolved by the '@rshono/server-app' alias (src/server.ts or the empty fallback)\nimport * as serverAppModule from '@rshono/server-app';\nimport { isPageRoute, type ErrorPageInfo, type FallbackPage, type PageComponent, type PageProps, type Route } from '../router.js';\nimport { appendVary, etagMatches } from '../server/headers.js';\nimport { beginPageRender, getRequestContext, publicUrl, readParams, reportServerError, runWithContext } from './context.js';\nimport { isControlSignal, RedirectSignal, type ControlSignal } from './control.js';\nimport { renderHTML } from './entry.ssr.js';\n// Type-only, so it is erased — the RSC layer does not take its own instance of the SSR layer's module.\nimport type { CancellableTransformer } from './flight-inject.js';\nimport { RouterProvider } from './navigation.js';\nimport { asksForRsc, isActionRequest, parseRenderRequest, requestWantsRsc, RSC_VARY_HEADER, wantsRsc } from './request.js';\nimport { assertEndpointModule, assertPageModule, assertRouteModules, validateRoutesModule, validateServerApp } from './validate-entries.js';\n\nconst serverApp = validateServerApp(serverAppModule);\n\n// Compiled into the bundle from rshono.config.ts by DefinePlugin; there is no runtime env-var interface.\nconst { isDev } = __RSHONO_CONFIG__;\n\n/**\n * How long a prerendered page may be reused before revalidating. Also what `public/` files get.\n *\n * Not a config field, deliberately: it is a per-response header, and `rshono.config.ts` is compiled into the\n * bundle — a cache policy you cannot change without a rebuild is the wrong shape. An app that wants a longer\n * `max-age`, or a `stale-while-revalidate`, sets it from middleware **after `await next()`**:\n *\n * ```ts\n * server.use('/docs/*', async (c, next) => {\n * await next();\n * c.res.headers.set('cache-control', 'public, max-age=86400, stale-while-revalidate=604800');\n * });\n * ```\n *\n * After, because the response below is built with `cache-control` in the bag it hands `c.body(...)`, and\n * that replaces a header prepared with `c.header(...)` before the handler ran. The `ETag` is untouched\n * either way, so revalidation still costs a 304 rather than the page.\n */\nconst SSG_CACHE_CONTROL = 'public, max-age=300';\n\n/**\n * What a page response gets when nothing else set one: without it a shared cache is free to store a logged-in\n * user's page and hand it to someone else. `private, no-cache` forbids that without blocking bfcache, which\n * `no-store` would.\n */\nconst PAGE_CACHE_CONTROL = 'private, no-cache';\n\n/** The two content types a page can be served as, from the same URL — which is what makes `Vary` non-optional. */\nconst PAGE_CONTENT_TYPE = /^(?:text\\/html|text\\/x-component)\\b/;\n\nruntime.loadEnv();\n\n// Checked rather than cast: these two modules are the app's, and a mistake in either used to surface as a\n// `TypeError` from somewhere else entirely — or, for a duplicated path, as nothing at all.\nconst routeConfig = validateRoutesModule(userRoutes);\nexport const routes: readonly Route[] = routeConfig.routes;\n\n/** The result of a server action, as a `Result<T, E>` rather than an `ok` flag over one field. */\nexport type ActionResult = { ok: true; value: unknown } | { ok: false; error: unknown };\n\nexport type RscPayload = {\n root: React.ReactNode;\n returnValue?: ActionResult;\n formState?: ReactFormState;\n redirect?: string;\n notFound?: boolean;\n};\n\n/**\n * The result of an action that has already run, for the request whose *render* then failed.\n *\n * The action and the page it answers with are one response: an action returns its value through the payload\n * of the page rendered after it. So when that render throws — a page module that will not load, most\n * plausibly a chunk that went away mid-deploy — `onError` renders the `error` page in its place, and without\n * this the reply carries no `returnValue` at all. The caller of an action that ran, and may well have\n * written something, would be told only that a field was missing.\n *\n * Keyed on the Hono context the way `beginPageRender` keys its own marker, and weakly, so nothing outlives\n * the request it belongs to.\n */\nconst actionResults = new WeakMap<Context, ActionResult>();\n\n/**\n * The per-request CSP nonce, if the app asked for one.\n *\n * The framework never mints it: `secureHeaders()` does, when its policy contains the `NONCE`\n * placeholder, and stores it here — so all the framework does is stamp the value into the render. It is\n * readable from a route handler because `secureHeaders` resolves its directives before `next()`.\n */\nfunction cspNonce(c: Context): string | undefined {\n return c.get('secureHeadersNonce');\n}\n\n/**\n * Whether a `<form action={serverAction}>` post came from another site, and so must not be allowed to run one.\n *\n * This is not CSRF policy — that is `csrf()` from Hono, registered in `src/server.ts`, which runs ahead of\n * every page route and covers far more than this. It is the framework declining to run *its own* action\n * mechanism for a request that mechanism cannot legitimately produce, in the one place the two action shapes\n * are not equally exposed:\n *\n * - A client-initiated action carries `x-rsc-action`, which is not a CORS-simple header. A cross-origin caller\n * needs a preflight it will not be given, so that shape cannot be forged from a browser at all.\n * - A form post is `multipart/form-data` or `application/x-www-form-urlencoded` with no header of its own —\n * the content types that need no preflight. It is forgeable, and an app with no `src/server.ts` has nothing\n * standing in front of it.\n *\n * Both halves are required, because either alone refuses something real:\n *\n * - `Sec-Fetch-Site` is the browser's own statement of provenance, unforgeable by page script, and every\n * browser that can post a form to a server action sends it. `cross-site` and `same-site` are the two labels\n * that mean \"not from this origin\" — `same-site` is what a *sibling subdomain* gets, which is a user-content\n * host, a stale CNAME or a subdomain takeover, so leaving it to `csrf()` meant an app without one could have\n * any `'use server'` export driven from next door. An absent header means a non-browser client, which cannot\n * be a CSRF victim. `same-origin` and `none` settle it on their own, and are what a genuine post carries\n * however many proxies rewrote `Host` on the way in.\n * - An `Origin` that is the app's own contradicts either label — a browser calls a post from the app's own pages\n * `same-origin` — so the pair is a shape no browser produces, and refusing it would only catch a proxy or a\n * test client setting the label by hand while posting from the app itself. Nothing else clears the label:\n * an `Origin` of `null` (a sandboxed iframe, a `data:` URL, `Referrer-Policy: no-referrer`) and no `Origin`\n * at all are both refused. A browser attaches one to every non-GET request, so neither is a shape it\n * produces — but a security predicate that says \"not proven foreign\" rather than \"proven local\" fails open\n * the day something does produce it.\n *\n * `publicUrl(c)` rather than `c.req.url`, so it honours `trustProxy` and compares against the origin the\n * browser actually used — which behind a proxy, `rshono dev`'s included, is not the one the server was reached\n * on. The cost is that an app deliberately accepting *form* posts to an action from another origin of its own\n * cannot, `csrf()`'s allowlist included; that is what an `{ type: 'endpoint' }` route is for.\n */\nfunction refusesCrossSiteForm(c: Context): boolean {\n const site = c.req.header('sec-fetch-site');\n if (site !== 'cross-site' && site !== 'same-site') return false;\n return c.req.header('origin') !== publicUrl(c).origin;\n}\n\n/** A browser navigation or a crawler, as opposed to a fetch that would rather have plain text. */\nfunction acceptsHtml(c: Context): boolean {\n return c.req.header('accept')?.includes('text/html') ?? false;\n}\n\n/**\n * The 404 for an app with no `notFound` page, and for a client that wanted neither HTML nor a flight\n * payload. It carries the `Vary` too: this is one of the answers a page URL gives depending on the `RSC` request header.\n */\nfunction plainNotFound(c: Context): Response {\n // `cache-control` explicitly, because the default above is applied to page *content types* and this is\n // `text/plain`. A 404 is heuristically cacheable under RFC 9111, so without it a shared cache may store\n // this one — while the rendered HTML 404 next to it, the same answer to the same request from a client\n // that asked for HTML, is correctly private.\n return c.text('Not Found', 404, { vary: RSC_VARY_HEADER, 'cache-control': PAGE_CACHE_CONTROL });\n}\n\n/** A lazy once-cell: runs `load` at most once, but clears a rejection so a later call can retry. */\nfunction once<T>(load: () => Promise<T>): () => Promise<T> {\n let promise: Promise<T> | undefined;\n return () => {\n if (!promise) {\n const pending = (promise = load());\n pending.catch(() => {\n if (promise === pending) promise = undefined;\n });\n }\n return promise;\n };\n}\n\n/**\n * Passes `stream` through untouched, calling `done` however it ends — for the flight-only response\n * path, which has no transform of its own to hang a completion hook off. `done` must be idempotent.\n */\nfunction releaseWhenDone(stream: ReadableStream<Uint8Array>, done: () => void): ReadableStream<Uint8Array> {\n return stream.pipeThrough(\n new TransformStream<Uint8Array, Uint8Array>({\n transform(chunk, controller) {\n controller.enqueue(chunk);\n },\n flush: done,\n cancel: done,\n } as CancellableTransformer<Uint8Array, Uint8Array>),\n );\n}\n\n/**\n * A macrotask boundary: `setImmediate` where there is one — the current turn's check phase rather than a\n * timer — and `setTimeout` as the portable fallback, for a runtime without it. `flight-inject.ts` has the\n * same two lines and the same reason; they are not shared because that module belongs to the SSR layer, and\n * importing it here would give the RSC layer its own instance of it.\n */\nconst deferTask: (run: () => void) => void =\n typeof setImmediate === 'function'\n ? setImmediate\n : (run) => {\n setTimeout(run, 0);\n };\n\n/**\n * Dev-only: says that a control signal arrived too late to be one.\n *\n * The root fix is in app code, so authoring time is where this has to be said, and a docs paragraph is not\n * where anyone reads it. `isDev` is the baked build flag, so a production server pays one boolean check on a\n * path that has already gone wrong — and says nothing.\n */\nfunction warnLateControlSignal(c: Context, signal: ControlSignal): void {\n const isRedirect = signal instanceof RedirectSignal;\n console.warn(\n `[rshono] ${isRedirect ? `redirect(${JSON.stringify(signal.location)})` : 'notFound()'} was called from a boundary that ` +\n `resolved after the page shell had already been sent (${c.req.method} ${c.req.path}), so it cannot become a real ` +\n `${isRedirect ? '3xx' : '404'}: the response is committed as 200 text/html. A browser with JavaScript follows the ` +\n `digest that rides the payload; one without stays on the Suspense fallback, and a crawler indexes the 200.${\n isRedirect\n ? ''\n : ' A JavaScript client asks for the page once more, in case the signal comes early enough that time to be a real 404 — and shows a plain \"Page not found\" panel when it does not, rather than reloading into the same response forever.'\n }` +\n ' Decide before the render starts streaming — in Hono middleware, or in the page component body above the boundary.',\n );\n}\n\ninterface ComponentRenderOptions {\n status?: number;\n isRsc: boolean;\n formState?: ReactFormState;\n returnValue?: RscPayload['returnValue'];\n temporaryReferences?: TemporaryReferenceSet;\n /** Passed when the page being rendered is the `error` page, which takes it as an extra prop. */\n errorInfo?: ErrorPageInfo;\n /** Marks the payload as the not-found page, so a soft navigation can tell it apart from the page it asked for. */\n notFound?: boolean;\n}\n\n/**\n * Builds the props a page component is called with.\n *\n * `ctx` is *defined* rather than assigned, and both halves are load-bearing:\n *\n * - **A getter**, so nothing is built for the pages that never read it, and a `render: 'static'` page\n * that does gets {@link getRequestContext}'s prerendering error rather than a bare `undefined`.\n * - **Non-enumerable**, so React's dev-only serialization of a server component's props skips it. That\n * walks own enumerable properties, and `ctx.hono.env` holds the runtime's bindings — an enumerable\n * `ctx` would ship every secret to the browser in dev.\n *\n * The cost: the element is created by handing this object to `jsx()` by reference, since a\n * `<Page {...props} />` spread would silently drop `ctx`.\n */\nfunction pageProps(c: Context, errorInfo: ErrorPageInfo | undefined): PageProps & { error?: ErrorPageInfo } {\n const props = { url: publicUrl(c), params: readParams(c), ...(errorInfo ? { error: errorInfo } : null) };\n Object.defineProperty(props, 'ctx', { get: getRequestContext, enumerable: false, configurable: true });\n return props as PageProps & { error?: ErrorPageInfo };\n}\n\nasync function renderComponent(c: Context, Page: ServerEntry<PageComponent>, opts: ComponentRenderOptions): Promise<Response> {\n // React's renderers must never be handed `c.req.raw.signal`: they add an `abort` listener and only\n // remove it if the abort fires, so on the happy path it stays on a request-lifetime signal and pins the\n // whole rendered tree. The render gets its own controller and the request signal forwards into it —\n // `release` detaches on the normal path. Not `AbortSignal.any()`, whose composite signals Node holds in\n // a process-lifetime set until they abort.\n const requestSignal = c.req.raw.signal;\n const renderAbort = new AbortController();\n const signal = renderAbort.signal;\n const forwardAbort = () => renderAbort.abort(requestSignal.reason);\n if (requestSignal.aborted) renderAbort.abort(requestSignal.reason);\n else requestSignal.addEventListener('abort', forwardAbort, { once: true });\n const release = () => requestSignal.removeEventListener('abort', forwardAbort);\n\n // Documents only: the nonce goes on the bootstrap scripts and the `<meta>` React hydrates from, and a\n // flight payload has neither — which is what keeps a prerendered one servable under a nonce-based CSP.\n const nonce = opts.isRsc ? undefined : cspNonce(c);\n const props = pageProps(c, opts.errorInfo);\n const root = (\n <>\n {nonce && <meta property=\"csp-nonce\" nonce={nonce} />}\n {Page.entryCssFiles?.map((href) => (\n <link key={href} rel=\"stylesheet\" href={href} precedence=\"default\" />\n ))}\n {/* `href`, not the `URL`: these props cross into a client component, so they have to be serializable. */}\n <RouterProvider href={props.url.href} params={props.params}>\n {jsx(Page, props)}\n </RouterProvider>\n </>\n );\n\n // `notFound` only when true, so an ordinary page's payload doesn't carry the key.\n const rscPayload: RscPayload = { root, formState: opts.formState, returnValue: opts.returnValue, ...(opts.notFound ? { notFound: true } : null) };\n\n // The last thing before the render: past here the response head is the framework's, so `ctx.setHeader()`\n // starts throwing — while the action `renderPage` just ran, and the middleware around it, legitimately wrote.\n beginPageRender(c);\n\n let controlSignal: ControlSignal | undefined;\n /** Set once `renderHTML` has returned, which is where the response head stops being changeable. */\n let shellFlushed = false;\n const rscStream = renderToReadableStream(rscPayload, {\n temporaryReferences: opts.temporaryReferences,\n signal,\n onError(error) {\n if (isControlSignal(error)) {\n controlSignal = error;\n if (shellFlushed) {\n if (isDev) warnLateControlSignal(c, error);\n // Past the shell the status line, the headers and the first bytes are on the wire, so the digest\n // React writes into the payload is the only path left — and everything still rendering is for a\n // page the browser is about to navigate away from. Winding it down stops those boundaries, runs\n // `flight-inject`'s cancel/flush, and fires the `release()` above now rather than whenever the\n // doomed render happens to finish.\n //\n // One macrotask later rather than from inside `onError`, where React is still handling the error\n // that produced the digest — the row carrying it is the only recovery the client has, and an abort\n // that re-entered React there could cut the render off before it is written. Measured to survive\n // either way on react-server-dom-rspack 0.1.0; deferred anyway, because that ordering is an\n // internal the `^19.1.0` peer range does not promise, and the cost is one macrotask on a render\n // that is already doomed. The reason is the signal itself, so every boundary the abort errors\n // carries the digest rather than a bare AbortError the client would paint as a fault.\n if (!signal.aborted) deferTask(() => renderAbort.abort(error));\n }\n return error.digest;\n }\n if (!signal.aborted) reportServerError(error, { source: 'render', hono: c, message: '[rshono] render error:' });\n },\n });\n\n if (opts.isRsc) {\n return c.body(releaseWhenDone(rscStream, release), (opts.status ?? 200) as ContentfulStatusCode, {\n 'content-type': 'text/x-component;charset=utf-8',\n });\n }\n\n let ssrResult: Awaited<ReturnType<typeof renderHTML>>;\n try {\n ssrResult = await renderHTML(rscStream, {\n bootstrapScripts: Page.entryJsFiles,\n formState: opts.formState,\n signal,\n nonce,\n onDone: release,\n onShellError: (error) => reportServerError(error, { source: 'ssr', hono: c, message: '[rshono] SSR shell error:' }),\n onError: (error) => reportServerError(error, { source: 'ssr', hono: c, message: '[rshono] SSR error:' }),\n });\n } catch (error) {\n release();\n if (controlSignal) throw controlSignal;\n throw error;\n }\n // `renderHTML` returns at *shell ready*, so from here the response is the one that ships. Set before the\n // check below rather than after it, so nothing lands in the window between the two: a signal that arrives\n // in it is handled there *and* schedules an abort, and aborting an aborted controller is a no-op.\n shellFlushed = true;\n if (controlSignal) {\n // The shell resolved, so this response is live: React is being pumped into the payload-injecting\n // transform, and a `redirect()` that surfaced from a boundary settling just before the shell was ready\n // lands here. Nothing will read that stream now — the signal becomes a redirect instead — so it is stopped\n // rather than left to render to completion for a response that was replaced.\n //\n // Both calls, because they stop different halves. `abort` reaches the two renders through the signal they\n // were handed; cancelling the response readable propagates back through the transform to release the teed\n // flight branch it holds a reader on, which `abort` alone does not.\n renderAbort.abort();\n void ssrResult.stream.cancel().catch(() => {\n // Already errored or locked — there is nothing left to release either way.\n });\n release();\n throw controlSignal;\n }\n return c.body(ssrResult.stream, (ssrResult.status ?? opts.status ?? 200) as ContentfulStatusCode, {\n 'content-type': 'text/html;charset=utf-8',\n });\n}\n\nasync function renderPage(c: Context, loadPage: () => Promise<ServerEntry<PageComponent>>): Promise<Response> {\n const request = c.req.raw;\n const renderRequest = parseRenderRequest(request);\n\n let returnValue: ActionResult | undefined;\n let formState: ReactFormState | undefined;\n let temporaryReferences: TemporaryReferenceSet | undefined;\n let actionStatus: number | undefined;\n if (isActionRequest(renderRequest)) {\n if (renderRequest.kind === 'rsc-action') {\n // Before the body is decoded, so an unknown id costs nothing to reject. `hasOwn` so `__proto__`\n // does not resolve to a manifest entry.\n if (!Object.hasOwn(__rspack_rsc_manifest__.serverManifest, renderRequest.actionId)) {\n return c.text('Bad Request: unknown server action', 400);\n }\n const contentType = request.headers.get('content-type');\n const body = contentType?.startsWith('multipart/form-data') ? await request.formData() : await request.text();\n temporaryReferences = createTemporaryReferenceSet();\n const args = await decodeReply<unknown[]>(body, { temporaryReferences });\n const action = loadServerAction(renderRequest.actionId);\n try {\n returnValue = { ok: true, value: await action(...args) };\n } catch (error) {\n if (isControlSignal(error)) throw error;\n // In production React sends a thrown action error to the client as an opaque marker, so this is\n // the only place the real one is visible.\n reportServerError(error, { source: 'action', hono: c, message: '[rshono] server action error:' });\n returnValue = { ok: false, error };\n actionStatus = 500;\n }\n // The action is done and its result is the caller's, whatever becomes of the render below. See\n // {@link actionResults}.\n actionResults.set(c, returnValue);\n } else {\n // A `<form action={serverAction}>` post, which is the path that runs before hydration and with\n // JavaScript off. Unlike the client-initiated one it carries no custom header, so it is also the only\n // action shape a browser can be made to send from another site: see `refusesCrossSiteForm`.\n if (refusesCrossSiteForm(c)) {\n return c.text('Forbidden: cross-site form post to a server action', 403, { vary: RSC_VARY_HEADER });\n }\n const formData = await request.formData();\n const decodedAction = await decodeAction(formData, __rspack_rsc_manifest__.serverManifest);\n if (decodedAction) {\n let result: unknown;\n try {\n result = await decodedAction();\n } catch (error) {\n if (isControlSignal(error)) throw error;\n // Reported here so a no-JS form post is attributed to the action that threw, exactly as the\n // client-initiated path is — the top-level handler would call it a `request`. Then re-thrown,\n // because this path has no client boundary and no `useActionState` to hand the error to, so the\n // app's `error` page is the honest answer. `reportServerError` de-duplicates, so the re-throw\n // reaching `onError` does not report it a second time.\n reportServerError(error, { source: 'action', hono: c, message: '[rshono] server action error:' });\n throw error;\n }\n formState = (await decodeFormState(result, formData, __rspack_rsc_manifest__.serverManifest)) ?? undefined;\n }\n }\n }\n\n const Page = await loadPage();\n return renderComponent(c, Page, {\n status: actionStatus,\n isRsc: wantsRsc(renderRequest),\n formState,\n returnValue,\n temporaryReferences,\n });\n}\n\nfunction buildApp(): Hono {\n const app = new Hono();\n\n // A floor, not a policy: an app wanting the full set registers `secureHeaders()` in src/server.ts, and\n // because this is registered first it unwinds last, so the \"only if unset\" checks stand aside for it.\n // Owned by the framework so that an app with no src/server.ts at all still gets it.\n app.use(async (c, next) => {\n await next();\n const headers = c.res.headers;\n if (!headers.has('x-content-type-options')) headers.set('x-content-type-options', 'nosniff');\n if (!headers.has('referrer-policy')) headers.set('referrer-policy', 'strict-origin-when-cross-origin');\n if (!headers.has('x-frame-options')) headers.set('x-frame-options', 'SAMEORIGIN');\n\n // React Refresh compiles updates with `eval`, so a dev build cannot run under a production CSP.\n // Widened here so one policy in src/server.ts serves both.\n if (isDev) {\n const csp = headers.get('content-security-policy');\n if (csp?.includes('script-src ')) {\n headers.set('content-security-policy', csp.replace('script-src ', \"script-src 'unsafe-eval' \"));\n }\n }\n\n // Page responses only from here down.\n if (!PAGE_CONTENT_TYPE.test(headers.get('content-type') ?? '')) return;\n appendVary(headers, RSC_VARY_HEADER);\n if (!headers.has('cache-control')) headers.set('cache-control', PAGE_CACHE_CONTROL);\n });\n\n // First, so the app's own middleware (`csrf()`, `bodyLimit()`, auth, logging) wraps everything registered\n // below: the page routes, and the asset handlers too. Assets used to be mounted ahead of this, which left\n // `/_static/*` answered by a terminal handler nothing of the app's ever saw — no `secureHeaders()`, and so\n // no HSTS on exactly the requests a downgrade attack lands on. The flip side is the same one it always had,\n // one path wider: a *terminal* handler in src/server.ts shadows a page at the same path, and unscoped\n // middleware now also runs for `/_static`, which is a reserved prefix an app should not be matching on\n // purpose anyway.\n if (serverApp) {\n app.route('/', serverApp);\n }\n\n runtime.mountStaticAssets(app);\n\n const memoizePage = (page: FallbackPage, label: string) => once(async () => assertPageModule(await page.component(), label));\n const loadNotFoundPage = routeConfig.notFound ? memoizePage(routeConfig.notFound, 'the notFound page') : null;\n\n /** Turns a thrown `redirect()` / `notFound()` into the response it stands for. */\n const respondToControlSignal = async (c: Context, signal: ControlSignal): Promise<Response> => {\n const isRsc = requestWantsRsc(c.req.raw);\n if (signal instanceof RedirectSignal) {\n if (isRsc) {\n // No `signal`: two fields and no component tree, so there is nothing worth aborting.\n return c.body(renderToReadableStream({ root: null, redirect: signal.location } satisfies RscPayload), 200, {\n 'content-type': 'text/x-component;charset=utf-8',\n });\n }\n return c.redirect(signal.location, signal.status as RedirectStatusCode);\n }\n if (loadNotFoundPage) {\n try {\n return await renderComponent(c, await loadNotFoundPage(), { status: 404, isRsc, notFound: true });\n } catch (error) {\n // The `notFound` page is already the answer to a request that went wrong, so a failure here has\n // nowhere to escalate to: this runs from `onError` as well as from the page handler, and Hono calls\n // `onError` inside its own catch — a throw from there rejects `app.fetch`, which\n // `@hono/node-server` turns into a bodiless 500 with nothing in the log. So it is answered here, the\n // way a failing `error` page is answered below.\n //\n // A `redirect()` from the page is the exception: nothing is committed yet, the branch above cannot\n // fail, and this is what the same page does when `app.notFound` renders it — so it is honoured, and\n // recurses exactly once.\n if (error instanceof RedirectSignal) return respondToControlSignal(c, error);\n reportServerError(error, { source: 'render', hono: c, message: '[rshono] the notFound page failed to render:' });\n }\n }\n return plainNotFound(c);\n };\n\n for (const route of routes) {\n if (isPageRoute(route)) {\n // Both fixed for the life of the process, so resolved once rather than per request.\n const servesPrerendered = !isDev && route.render === 'static';\n const loadPage = once(async () => assertPageModule(await route.component(), `\"${route.path}\"`));\n\n /** Everything the route answers, before a HEAD has its body taken off it. */\n const respond = async (c: Context): Promise<Response> => {\n try {\n // A HEAD takes the GET path, prerendered bytes included: the headers it promises are the ones a\n // GET would send, `etag` and `content-length` among them.\n if (servesPrerendered && (c.req.method === 'GET' || c.req.method === 'HEAD')) {\n const isRsc = asksForRsc(c.req.raw);\n // One fixed set of bytes cannot carry a per-request nonce, so a document has to be rendered\n // where the app's CSP has one. Decided per request, so an app whose policy carries no `NONCE`\n // keeps its prerendered documents. A flight payload never carries a nonce either way.\n const mustRenderForNonce = !isRsc && cspNonce(c) !== undefined;\n if (!mustRenderForNonce) {\n const page = await runtime.readPrerendered(c, isRsc ? 'flight' : 'html');\n // Request-independent by construction, so it is safe to cache publicly; the ETag turns the\n // revalidation that follows into a 304. Answered outside `runWithContext` — no app code runs\n // on this path, so there is no `getRequestContext()` to serve.\n if (page !== null) {\n const headers = {\n 'cache-control': SSG_CACHE_CONTROL,\n etag: page.etag,\n vary: RSC_VARY_HEADER,\n 'content-type': isRsc ? 'text/x-component;charset=utf-8' : 'text/html;charset=utf-8',\n };\n if (etagMatches(c.req.header('if-none-match'), page.etag)) return c.body(null, 304, headers);\n return c.body(page.body, 200, { ...headers, 'content-length': page.contentLength });\n }\n }\n }\n return await runWithContext(c, () => renderPage(c, loadPage));\n } catch (error) {\n if (isControlSignal(error)) return runWithContext(c, () => respondToControlSignal(c, error));\n throw error;\n }\n };\n\n const handler: Handler = async (c) => {\n const response = await respond(c);\n // Hono dispatches a HEAD to the GET route and then rebuilds the response as `new Response(null, res)`,\n // which drops the body without reading it — so for a rendered page nothing ever consumes the stream:\n // `flight-inject`'s `cancel` never runs, and neither does the `release()` that detaches the abort\n // forwarder from the request signal. Cancelling here is what ends the render nobody asked to read.\n if (c.req.method === 'HEAD' && response.body !== null) {\n void response.body.cancel().catch(() => {\n // Already errored or locked, and there is nothing left to release either way.\n });\n return new Response(null, response);\n }\n return response;\n };\n app.on(['GET', 'POST'], route.path, handler);\n } else {\n // Checked on the way out of the thunk rather than at the call site, so `once`'s cache holds a handler\n // that has already been proven to be one — and a rejection clears, so the message repeats per request.\n const loadEndpoint = once(async () => assertEndpointModule(await route.server(), `\"${route.path}\"`));\n const handler: Handler = async (c, next) => {\n const endpointHandler = await loadEndpoint();\n // Hono's `Handler` leaves its return parameter defaulted to `any`, so this hands back exactly what\n // the app's own handler is declared to return — there is nothing narrower to assert here.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return endpointHandler(c, next);\n };\n // De-duplicated, because `app.on(['GET', 'GET'], …)` registers the path twice. Validation refuses\n // `'all'` inside a list, so a list that reaches here is concrete methods only.\n const methods = [...new Set([route.method ?? 'all'].flat())];\n if (methods.includes('all')) app.all(route.path, handler);\n else {\n app.on(\n methods.map((method) => method.toUpperCase()),\n route.path,\n handler,\n );\n }\n }\n }\n\n runtime.mountPublicFallback(app);\n\n app.notFound(async (c) => {\n const isRsc = requestWantsRsc(c.req.raw);\n if (loadNotFoundPage && (isRsc || acceptsHtml(c))) {\n // `notFound: true` here as well as on the signal path: the two produce the same page for the same\n // status, and a payload that says so from one route and not the other is a wire contract with a hole\n // in it. The client reads it to tell \"this is the 404 page\" from \"this is the page you asked for\".\n return runWithContext(c, async () => renderComponent(c, await loadNotFoundPage(), { status: 404, isRsc, notFound: true }));\n }\n return plainNotFound(c);\n });\n\n const loadErrorPage = routeConfig.error ? memoizePage(routeConfig.error, 'the error page') : null;\n app.onError(async (error, c) => {\n if (isControlSignal(error)) return runWithContext(c, () => respondToControlSignal(c, error));\n // Registering an `onError` replaces Hono's default handler, which is what turns an `HTTPException`\n // into the response it carries — without this, `csrf()`'s 403 and `bodyLimit()`'s 413 would both\n // surface as a 500 error page. Rebuilt through `c`, as Hono's default does, so headers middleware\n // already prepared survive.\n if (error instanceof HTTPException) {\n const res = error.getResponse();\n return c.newResponse(res.body, res);\n }\n reportServerError(error, { source: 'request', hono: c, message: '[rshono] request error:' });\n const isRsc = requestWantsRsc(c.req.raw);\n if (loadErrorPage && (isRsc || acceptsHtml(c))) {\n const errorInfo: ErrorPageInfo = isDev\n ? {\n message: error instanceof Error ? error.message : String(error),\n stack: error instanceof Error ? error.stack : undefined,\n }\n : { message: 'Internal Server Error' };\n try {\n return await runWithContext(c, async () =>\n renderComponent(c, await loadErrorPage(), { status: 500, isRsc, errorInfo, returnValue: actionResults.get(c) }),\n );\n } catch (renderError) {\n reportServerError(renderError, { source: 'request', hono: c, message: '[rshono] the error page failed to render:' });\n }\n }\n const detail = isDev ? `\\n\\n${error instanceof Error ? (error.stack ?? error.message) : String(error)}` : '';\n // Same reason as `plainNotFound`, minus the urgency: a 500 is not heuristically cacheable, so this half\n // is consistency — the framework's own answers should not differ in what they promise about caching.\n return c.text(`Internal Server Error${detail}`, 500, { vary: RSC_VARY_HEADER, 'cache-control': PAGE_CACHE_CONTROL });\n });\n\n return app;\n}\n\n/**\n * Resolves and checks every route's own module — page and endpoint alike, `notFound` and `error` included.\n * Called by `rshono build` once this bundle is imported for the prerender pass, so a route that could never\n * serve a request fails the build rather than answering 500 in production. Exported from here rather than\n * driven from the CLI because the fallback pages are on `routeConfig`, which does not leave this module.\n */\nexport const checkRouteModules = (): Promise<void> => assertRouteModules(routeConfig);\n\nexport const app = buildApp();\n\n/**\n * The app, handed to whatever is hosting it: this binds a port and exports nothing where rshono owns the\n * process, and *is* the export the platform looks for where the host owns it — so one entry serves both.\n *\n * `app` and `routes` stay named exports either way, because `rshono build` imports them to prerender\n * `render: 'static'` routes.\n */\nexport default runtime.serveApp(app);\n"]}