@rshono/core 1.0.0-rc.12 → 1.0.0-rc.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/rshono.mjs +3 -4
- package/dist/builder/env-shadow-loader.cjs +5 -5
- package/dist/builder/page-files.js +5 -5
- package/dist/builder/page-files.js.map +1 -1
- package/dist/builder/public-env.d.ts +5 -4
- package/dist/builder/public-env.d.ts.map +1 -1
- package/dist/builder/public-env.js +5 -4
- package/dist/builder/public-env.js.map +1 -1
- package/dist/builder/rspack-config.d.ts +5 -11
- package/dist/builder/rspack-config.d.ts.map +1 -1
- package/dist/builder/rspack-config.js +28 -50
- package/dist/builder/rspack-config.js.map +1 -1
- package/dist/cli/build.js +2 -2
- package/dist/cli/build.js.map +1 -1
- package/dist/cli/dev.d.ts.map +1 -1
- package/dist/cli/dev.js +30 -40
- package/dist/cli/dev.js.map +1 -1
- package/dist/cli/index.js +4 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/start.d.ts.map +1 -1
- package/dist/cli/start.js +2 -3
- package/dist/cli/start.js.map +1 -1
- package/dist/config.d.ts +28 -31
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -2
- package/dist/config.js.map +1 -1
- package/dist/deploy/aws-lambda/runtime.d.ts +4 -6
- package/dist/deploy/aws-lambda/runtime.d.ts.map +1 -1
- package/dist/deploy/aws-lambda/runtime.js +5 -8
- package/dist/deploy/aws-lambda/runtime.js.map +1 -1
- package/dist/deploy/build-marker.d.ts +3 -5
- package/dist/deploy/build-marker.d.ts.map +1 -1
- package/dist/deploy/build-marker.js +3 -5
- package/dist/deploy/build-marker.js.map +1 -1
- package/dist/deploy/cloudflare/build.d.ts.map +1 -1
- package/dist/deploy/cloudflare/build.js +6 -10
- package/dist/deploy/cloudflare/build.js.map +1 -1
- package/dist/deploy/cloudflare/runtime.d.ts +2 -5
- package/dist/deploy/cloudflare/runtime.d.ts.map +1 -1
- package/dist/deploy/cloudflare/runtime.js +19 -32
- package/dist/deploy/cloudflare/runtime.js.map +1 -1
- package/dist/deploy/contract.d.ts +25 -42
- package/dist/deploy/contract.d.ts.map +1 -1
- package/dist/deploy/contract.js.map +1 -1
- package/dist/deploy/filesystem.d.ts +3 -5
- package/dist/deploy/filesystem.d.ts.map +1 -1
- package/dist/deploy/filesystem.js +7 -11
- package/dist/deploy/filesystem.js.map +1 -1
- package/dist/deploy/node/runtime.d.ts +4 -5
- package/dist/deploy/node/runtime.d.ts.map +1 -1
- package/dist/deploy/node/runtime.js +9 -15
- package/dist/deploy/node/runtime.js.map +1 -1
- package/dist/deploy/presets.d.ts +19 -29
- package/dist/deploy/presets.d.ts.map +1 -1
- package/dist/deploy/presets.js +18 -25
- package/dist/deploy/presets.js.map +1 -1
- package/dist/deploy/vercel/build.d.ts.map +1 -1
- package/dist/deploy/vercel/build.js +9 -12
- package/dist/deploy/vercel/build.js.map +1 -1
- package/dist/deploy/vercel/runtime.d.ts +4 -7
- package/dist/deploy/vercel/runtime.d.ts.map +1 -1
- package/dist/deploy/vercel/runtime.js +4 -7
- package/dist/deploy/vercel/runtime.js.map +1 -1
- package/dist/index.d.ts +13 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -12
- package/dist/index.js.map +1 -1
- package/dist/router.d.ts +65 -93
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +2 -5
- package/dist/router.js.map +1 -1
- package/dist/runtime/boundaries.d.ts +24 -30
- package/dist/runtime/boundaries.d.ts.map +1 -1
- package/dist/runtime/boundaries.js +15 -22
- package/dist/runtime/boundaries.js.map +1 -1
- package/dist/runtime/client.d.ts +16 -7
- package/dist/runtime/client.d.ts.map +1 -1
- package/dist/runtime/client.js +16 -7
- package/dist/runtime/client.js.map +1 -1
- package/dist/runtime/context.d.ts +89 -118
- package/dist/runtime/context.d.ts.map +1 -1
- package/dist/runtime/context.js +107 -167
- package/dist/runtime/context.js.map +1 -1
- package/dist/runtime/control.js +3 -3
- package/dist/runtime/control.js.map +1 -1
- package/dist/runtime/dev-protocol.d.ts +4 -8
- package/dist/runtime/dev-protocol.d.ts.map +1 -1
- package/dist/runtime/dev-protocol.js.map +1 -1
- package/dist/runtime/entry.client.js +69 -105
- package/dist/runtime/entry.client.js.map +1 -1
- package/dist/runtime/entry.rsc.d.ts +5 -6
- package/dist/runtime/entry.rsc.d.ts.map +1 -1
- package/dist/runtime/entry.rsc.js +67 -122
- package/dist/runtime/entry.rsc.js.map +1 -1
- package/dist/runtime/entry.ssr.d.ts +7 -12
- package/dist/runtime/entry.ssr.d.ts.map +1 -1
- package/dist/runtime/entry.ssr.js +13 -24
- package/dist/runtime/entry.ssr.js.map +1 -1
- package/dist/runtime/flight-inject.d.ts +10 -17
- package/dist/runtime/flight-inject.d.ts.map +1 -1
- package/dist/runtime/flight-inject.js +35 -53
- package/dist/runtime/flight-inject.js.map +1 -1
- package/dist/runtime/hot-update.d.ts +20 -27
- package/dist/runtime/hot-update.d.ts.map +1 -1
- package/dist/runtime/hot-update.js +17 -23
- package/dist/runtime/hot-update.js.map +1 -1
- package/dist/runtime/navigation.d.ts +14 -19
- package/dist/runtime/navigation.d.ts.map +1 -1
- package/dist/runtime/navigation.js +9 -13
- package/dist/runtime/navigation.js.map +1 -1
- package/dist/runtime/request.d.ts +4 -6
- package/dist/runtime/request.d.ts.map +1 -1
- package/dist/runtime/request.js +2 -3
- package/dist/runtime/request.js.map +1 -1
- package/dist/runtime/server.d.ts +18 -10
- package/dist/runtime/server.d.ts.map +1 -1
- package/dist/runtime/server.js +21 -19
- package/dist/runtime/server.js.map +1 -1
- package/dist/server/headers.d.ts +8 -15
- package/dist/server/headers.d.ts.map +1 -1
- package/dist/server/headers.js +8 -15
- package/dist/server/headers.js.map +1 -1
- package/dist/server/load-config.d.ts +2 -2
- package/dist/server/load-config.d.ts.map +1 -1
- package/dist/server/load-config.js +6 -9
- package/dist/server/load-config.js.map +1 -1
- package/dist/server/prerendered.d.ts +30 -43
- package/dist/server/prerendered.d.ts.map +1 -1
- package/dist/server/prerendered.js +20 -29
- package/dist/server/prerendered.js.map +1 -1
- package/dist/server/server-config.d.ts +13 -28
- package/dist/server/server-config.d.ts.map +1 -1
- package/dist/server/server-config.js +5 -10
- package/dist/server/server-config.js.map +1 -1
- package/dist/server/shutdown.d.ts +2 -3
- package/dist/server/shutdown.d.ts.map +1 -1
- package/dist/server/shutdown.js +2 -3
- package/dist/server/shutdown.js.map +1 -1
- package/dist/server/ssg.d.ts +3 -6
- package/dist/server/ssg.d.ts.map +1 -1
- package/dist/server/ssg.js +11 -20
- package/dist/server/ssg.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.rsc.js","sourceRoot":"","sources":["../../src/runtime/entry.rsc.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAQpD,0FAA0F;AAC1F,qGAAqG;AACrG,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,8FAA8F;AAC9F,oGAAoG;AACpG,mDAAmD;AACnD,OAAO,EACL,2BAA2B,EAC3B,YAAY,EACZ,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,sBAAsB,GAGvB,MAAM,gCAAgC,CAAC;AACxC,iGAAiG;AACjG,gFAAgF;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,mFAAmF;AACnF,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACtD,sGAAsG;AACtG,OAAO,KAAK,eAAe,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,WAAW,EAA2G,MAAM,cAAc,CAAC;AACpJ,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,SAAS,EAAE,U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AAE,CAAC,eAAe,CAAC,CAAC,EAAE,MAAM,aAAa,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;YAC3H,CAAC;YAAC,OAAO,WAAW,EAAE,CAAC;gBACrB,iBAAiB,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,2CAA2C,EAAE,CAAC,CAAC;YAClI,CAAC;QACH,CAAC;QACD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7G,OAAO,CAAC,CAAC,IAAI,CAAC,wBAAwB,MAAM,EAAE,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,CAAC,MAAM,GAAG,GAAG,QAAQ,EAAE,CAAC;AAE9B;;;;;;;GAOG;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, and imported for its side effect on the *type* level: the module augments Hono's\n// `ContextVariableMap` with `secureHeadersNonce`, which is how a nonce set by `secureHeaders()` in\n// src/server.ts is read back below. Nothing from it is used at runtime.\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// The JSX factory, by name: the page element is created with this directly rather than as\n// `<Page {...props} />`, because a spread would drop the non-enumerable `ctx` prop. See `pageProps`.\nimport { jsx } from 'react/jsx-runtime';\n// The bare specifier, not `/server.node`: the package ships a build per runtime behind export\n// conditions, and the RSC layer's `conditionNames` picks one — so a non-Node deploy target gets its\n// own build rather than Node's by hard-coded path.\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// Resolved by the '@rshono/deploy' alias to the selected preset's runtime module — the one place\n// this file knows anything about where it is running. See `deploy/contract.ts`.\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, type RouteConfig } 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 { acceptsRsc, isActionRequest, parseRenderRequest, requestWantsRsc, wantsRsc } from './request.js';\n\nconst serverApp = ((serverAppModule as { default?: unknown }).default ?? null) as Hono | null;\n\n// Framework settings resolved from rshono.config.ts and compiled into the bundle at build time (see\n// builder/rspack-config.ts). There is no runtime env-var interface for these — env is for secrets.\n// `isDev` among them: the build mode is decided by which command produced the bundle, and not every\n// runtime this deploys to has a `process.env.NODE_ENV` to read.\nconst { isDev } = __RSHONO_CONFIG__;\n\n/** How long a prerendered page may be reused before revalidating. Also what `public/` files get. */\nconst SSG_CACHE_CONTROL = 'public, max-age=300';\n\n/**\n * The two content types a page can be served as. Both come back from the *same* URL depending on\n * the `Accept` header, which is what makes `Vary` non-optional here.\n */\nconst PAGE_CONTENT_TYPE = /^(?:text\\/html|text\\/x-component)\\b/;\n\n// Called here rather than at the top of the deploy runtime's own module so the timing is unchanged:\n// `.env` is loaded once every import above has been evaluated, exactly as before.\nruntime.loadEnv();\n\nconst routeConfig = userRoutes as RouteConfig;\nexport const routes: readonly Route[] = routeConfig.routes;\n\n/** The result of a server action, as a discriminated union (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 per-request CSP nonce, if the app asked for one.\n *\n * The framework does not mint this. `secureHeaders()` from `hono/secure-headers` does, when its\n * policy contains the `NONCE` placeholder, and it stores it here — so an app opts into a\n * nonce-based CSP by registering that middleware in `src/server.ts` and the framework's only job is\n * to stamp the value into the render.\n *\n * Readable from a route handler because `secureHeaders` resolves its directives *before* calling\n * `next()`; the header itself is written on the way back out. Absent when the app registered no CSP,\n * or one with no nonce in it — a fixed policy needs nothing from the render.\n */\nfunction cspNonce(c: Context): string | undefined {\n return c.get('secureHeadersNonce');\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. Shared for the `Vary`: this is still one of the answers a page URL gives depending on\n * `Accept`, and a cache not told so can hand a plain-text 404 to a browser asking for a document.\n */\nfunction plainNotFound(c: Context): Response {\n return c.text('Not Found', 404, { vary: 'Accept' });\n}\n\n/** A lazy once-cell: runs `load` at most once and caches the promise, 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 // Only clear if we're still holding the rejected promise (a later successful load may have already replaced it).\n if (promise === pending) promise = undefined;\n });\n }\n return promise;\n };\n}\n\n/**\n * Passes `stream` through untouched, calling `done` once it ends — however it ends.\n *\n * Used on the flight-only response path, which has no transform of its own to hang a completion hook\n * off (the document path has {@link injectFlightPayload}). `done` must be idempotent: a cancelled\n * response can reach both `cancel` and the abort forwarder.\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\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 * `url` and `params` match `useNavigation()` field for field, so a read can move between a page and a\n * `'use client'` component unchanged. The `URL` is this page's own, so mutating it cannot disturb\n * anything else on the request.\n *\n * `ctx` is *defined* rather than assigned, and both halves of how carry their weight:\n *\n * - **A getter**, so nothing is built for the pages that never read it, and so a `render: 'static'`\n * page that does read it gets {@link getRequestContext}'s \"no per-request context while\n * prerendering\" error rather than a bare `undefined`.\n * - **Non-enumerable**, so React's *development-only* serialization of a server component's props\n * (the debug channel behind component stacks and the performance track) skips it. That walks own\n * enumerable properties, and `ctx.hono` is the Hono {@link Context} — whose `env` holds the\n * runtime's bindings. An enumerable `ctx` would ship every one of them, secrets included, to the\n * browser in dev, and add well over 10 kB to a small page's flight payload.\n *\n * The cost is that the element has to be created by handing this object to `jsx()` *by reference*: a\n * `<Page {...props} />` spread copies enumerable properties only, and would drop `ctx` silently.\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 // A client going away aborts the render — but React's renderers must never be handed\n // `c.req.raw.signal` to watch for it. Both add an `abort` listener and only remove it if the abort\n // fires, so on the happy path that listener stays on a request-lifetime signal and through it pins\n // the flight request, the Fizz request and the whole rendered tree (~169 kB per `/ssr` request,\n // never reclaimed by a major GC).\n //\n // So the render gets a controller of its own and the request signal only forwards into it: the\n // forwarder is `once`, so an abort removes it, and `release` removes it on the normal path. Not\n // `AbortSignal.any()` — a signal it produced is *composite*, and Node holds every composite signal\n // carrying an `abort` listener in a process-lifetime set until it aborts or loses its last listener.\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 /** Detaches the forwarder once the response has been written, so nothing survives the request. */\n const release = () => requestSignal.removeEventListener('abort', forwardAbort);\n\n // Documents only: the nonce goes on the bootstrap scripts and the `<meta>` React hydrates from,\n // and a flight payload has neither. Leaving it off there is also what keeps a prerendered flight\n // payload servable from disk 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` itself: 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 it is true, so the flight payload of an ordinary page doesn't carry the key.\n const rscPayload: RscPayload = { root, formState: opts.formState, returnValue: opts.returnValue, ...(opts.notFound ? { notFound: true } : null) };\n\n // Past this line the response head belongs to the framework, so `ctx.setHeader()` and\n // `ctx.cookies.set()` start throwing rather than writing somewhere nothing will read. It has to be\n // the last thing before the render: a server action ran earlier in `renderPage` and legitimately\n // writes to the response, and so does any middleware that wrapped this handler.\n beginPageRender(c);\n\n let controlSignal: ControlSignal | undefined;\n const rscStream = renderToReadableStream(rscPayload, {\n temporaryReferences: opts.temporaryReferences,\n signal,\n onError(error) {\n if (isControlSignal(error)) {\n controlSignal = error;\n return error.digest;\n }\n if (!signal.aborted) reportServerError(error, { source: 'render', request: c.req.raw, 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', request: c.req.raw, message: '[rshono] SSR shell error:' }),\n onError: (error) => reportServerError(error, { source: 'ssr', request: c.req.raw, message: '[rshono] SSR error:' }),\n });\n } catch (error) {\n release();\n if (controlSignal) throw controlSignal;\n throw error;\n }\n if (controlSignal) {\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 // Checked before the body is decoded, so an unknown id costs nothing to reject — and\n // `loadServerAction` would otherwise fault on the missing manifest entry, turning a bad\n // request into an unhandled 500. `hasOwn` so `__proto__` doesn't 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.apply(null, args) };\n } catch (error) {\n if (isControlSignal(error)) throw error;\n // React sends a thrown action error to the client as an opaque marker in production — no\n // message, no digest — so without this the failure would be invisible on both ends.\n reportServerError(error, { source: 'action', request, message: '[rshono] server action error:' });\n returnValue = { ok: false, error };\n actionStatus = 500;\n }\n } else {\n const formData = await request.formData();\n const decodedAction = await decodeAction(formData, __rspack_rsc_manifest__.serverManifest);\n if (decodedAction) {\n const result = await decodedAction();\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 // Baseline security headers: stop content-type sniffing, keep the full URL out of cross-origin\n // referrers, and refuse to be framed by another origin. A floor, not a policy — an app that wants\n // the full set registers `secureHeaders()` from `hono/secure-headers` in src/server.ts, and\n // because this is registered first it unwinds *last* and the \"only if unset\" checks stand aside\n // for whatever that set. Kept in the framework rather than left to the app because it is\n // registered ahead of `mountStaticAssets`, which is a terminal handler the sub-app never sees:\n // without this, `/_static/*` would carry no security headers at all.\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 any CSP an app\n // would sensibly write for production. Widened here rather than asked of the app, so one policy\n // in src/server.ts serves both and nobody debugs a blocked HMR socket. Only ever in dev, and\n // only when the app has a `script-src` to widen.\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: one URL answers with either an HTML document or a flight\n // payload depending on `Accept`, and the default page is request-specific.\n if (!PAGE_CONTENT_TYPE.test(headers.get('content-type') ?? '')) return;\n appendVary(headers, 'Accept');\n // Without this a page carries no cache directives at all, and a shared cache — a CDN, a corporate\n // proxy — is free to store a logged-in user's page and hand it to someone else. `private` forbids\n // that; `no-cache` makes the browser revalidate rather than re-show a stale personalised page.\n // Neither blocks bfcache, which `no-store` would. A prerendered page already has its own value.\n if (!headers.has('cache-control')) headers.set('cache-control', 'private, no-cache');\n });\n\n runtime.mountStaticAssets(app);\n\n // Mounted ahead of the page routes so the sub-app's middleware (auth, logging, trailing-slash,\n // and the security middleware the framework no longer owns — `csrf()`, `bodyLimit()`,\n // `secureHeaders()`) wraps page requests too. The flip side: a *terminal* handler in\n // src/server.ts at the same path as a page route wins over the page.\n if (serverApp) {\n app.route('/', serverApp);\n }\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`, deliberately — see `renderComponent`. This payload is two fields and no\n // component tree, so there is nothing worth aborting and nothing worth a listener.\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 return renderComponent(c, await loadNotFoundPage(), { status: 404, isRsc, notFound: true });\n }\n return plainNotFound(c);\n };\n\n for (const route of routes) {\n if (isPageRoute(route)) {\n // Both are fixed for the life of the process, so resolve them once here instead of per request.\n const servesPrerendered = !isDev && route.render === 'static';\n const loadPage = once(() => loadPageModule(route.component, `\"${route.path}\"`));\n\n const handler: Handler = async (c) => {\n try {\n if (servesPrerendered && c.req.method === 'GET') {\n const isRsc = acceptsRsc(c.req.raw);\n // A prerendered file is one fixed set of bytes, so it cannot carry a per-request nonce:\n // where the app's CSP has one, the *document* has to be rendered per request. The flight\n // payload never carries a nonce, so it stays servable from the build either way.\n //\n // Decided per request rather than per build, which is what moving the CSP to\n // `secureHeaders()` buys: an app whose policy carries no `NONCE` keeps its prerendered\n // documents, where the old build-time `csp: true` flag gave every one of them up.\n const mustRenderForNonce = !isRsc && cspNonce(c) !== undefined;\n if (!mustRenderForNonce) {\n const page = await runtime.readPrerendered(c, isRsc ? 'flight' : 'html');\n // A prerendered page is request-independent by construction, so it is safe to cache\n // publicly; the short max-age matches what `public/` files get, and the ETag turns the\n // revalidation that follows into a 304 rather than the page all over again.\n //\n // Answered outside `runWithContext`: no app code runs on this path, so there is no\n // `getRequestContext()` to serve and no reason to pay for the AsyncLocalStorage scope.\n if (page !== null) {\n const headers = {\n 'cache-control': SSG_CACHE_CONTROL,\n etag: page.etag,\n vary: 'Accept',\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 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 return endpointHandler(c, next);\n };\n const method = route.method ?? 'all';\n if (method === 'all') app.all(route.path, handler);\n else app.on(method.toUpperCase(), route.path, handler);\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 return runWithContext(c, async () => renderComponent(c, await loadNotFoundPage(), { status: 404, isRsc }));\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` at all replaces Hono's default handler, which is what would otherwise\n // turn an `HTTPException` into the response it carries. Without this every middleware that\n // rejects a request by throwing one — `csrf()` with a 403, `bodyLimit()` with a 413, an app's own\n // `throw new HTTPException(401)` — would surface as a 500 error page instead of its own status.\n // Rebuilt through `c` rather than returned as-is, exactly as Hono's own default does, so headers\n // already prepared on the context (`c.header(…)` from middleware that ran first) survive.\n if (error instanceof HTTPException) {\n const res = error.getResponse();\n return c.newResponse(res.body, res);\n }\n reportServerError(error, { source: 'request', request: c.req.raw, 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 () => renderComponent(c, await loadErrorPage(), { status: 500, isRsc, errorInfo }));\n } catch (renderError) {\n reportServerError(renderError, { source: 'request', request: c.req.raw, 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 return c.text(`Internal Server Error${detail}`, 500, { vary: 'Accept' });\n });\n\n return app;\n}\n\nexport const app = buildApp();\n\n/**\n * The app, handed to whatever is hosting it.\n *\n * On a platform where rshono owns the process this binds a port and the default export is nothing;\n * where the host owns it, this *is* the export the platform looks for — so the same entry serves\n * both without a per-platform entry file. `app` and `routes` stay named exports either way, because\n * `rshono build` imports them to prerender `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,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAMpD,qGAAqG;AACrG,yBAAyB;AACzB,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,mGAAmG;AACnG,oCAA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CAAC,CAAC,EAAE,MAAM,aAAa,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;YAC3H,CAAC;YAAC,OAAO,WAAW,EAAE,CAAC;gBACrB,iBAAiB,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,2CAA2C,EAAE,CAAC,CAAC;YAClI,CAAC;QACH,CAAC;QACD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7G,OAAO,CAAC,CAAC,IAAI,CAAC,wBAAwB,MAAM,EAAE,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC3E,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, type RouteConfig } 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 { acceptsRsc, isActionRequest, parseRenderRequest, requestWantsRsc, wantsRsc } from './request.js';\n\nconst serverApp = ((serverAppModule as { default?: unknown }).default ?? null) as Hono | null;\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/** How long a prerendered page may be reused before revalidating. Also what `public/` files get. */\nconst SSG_CACHE_CONTROL = 'public, max-age=300';\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\nconst routeConfig = userRoutes as RouteConfig;\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 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\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 `Accept`.\n */\nfunction plainNotFound(c: Context): Response {\n return c.text('Not Found', 404, { vary: 'Accept' });\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\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 const rscStream = renderToReadableStream(rscPayload, {\n temporaryReferences: opts.temporaryReferences,\n signal,\n onError(error) {\n if (isControlSignal(error)) {\n controlSignal = error;\n return error.digest;\n }\n if (!signal.aborted) reportServerError(error, { source: 'render', request: c.req.raw, 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', request: c.req.raw, message: '[rshono] SSR shell error:' }),\n onError: (error) => reportServerError(error, { source: 'ssr', request: c.req.raw, message: '[rshono] SSR error:' }),\n });\n } catch (error) {\n release();\n if (controlSignal) throw controlSignal;\n throw error;\n }\n if (controlSignal) {\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', request, message: '[rshono] server action error:' });\n returnValue = { ok: false, error };\n actionStatus = 500;\n }\n } else {\n const formData = await request.formData();\n const decodedAction = await decodeAction(formData, __rspack_rsc_manifest__.serverManifest);\n if (decodedAction) {\n const result = await decodedAction();\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 because it also has to cover `mountStaticAssets` — a terminal handler the\n // app's own middleware never sees.\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, 'Accept');\n // Without a default a shared cache is free to store a logged-in user's page and hand it to someone\n // else. `private, no-cache` forbids that without blocking bfcache, which `no-store` would.\n if (!headers.has('cache-control')) headers.set('cache-control', 'private, no-cache');\n });\n\n runtime.mountStaticAssets(app);\n\n // Ahead of the page routes, so the app's own middleware (`csrf()`, `bodyLimit()`, auth, logging) wraps\n // page requests too. The flip side: a *terminal* handler in src/server.ts shadows a page at the same path.\n if (serverApp) {\n app.route('/', serverApp);\n }\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 return renderComponent(c, await loadNotFoundPage(), { status: 404, isRsc, notFound: true });\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 const handler: Handler = async (c) => {\n try {\n if (servesPrerendered && c.req.method === 'GET') {\n const isRsc = acceptsRsc(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: 'Accept',\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 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 const method = route.method ?? 'all';\n if (method === 'all') app.all(route.path, handler);\n else app.on(method.toUpperCase(), route.path, handler);\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 return runWithContext(c, async () => renderComponent(c, await loadNotFoundPage(), { status: 404, isRsc }));\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', request: c.req.raw, 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 () => renderComponent(c, await loadErrorPage(), { status: 500, isRsc, errorInfo }));\n } catch (renderError) {\n reportServerError(renderError, { source: 'request', request: c.req.raw, 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 return c.text(`Internal Server Error${detail}`, 500, { vary: 'Accept' });\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"]}
|
|
@@ -5,24 +5,19 @@ export interface RenderHTMLOptions {
|
|
|
5
5
|
signal?: AbortSignal;
|
|
6
6
|
nonce?: string;
|
|
7
7
|
/**
|
|
8
|
-
* Called when SSR fails before the shell is sent. Reporting is the RSC layer's job
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Called when SSR fails before the shell is sent. Reporting is the RSC layer's job: this module is
|
|
9
|
+
* compiled into the SSR layer, which gets its own instance of every module it imports, so a handler
|
|
10
|
+
* registered through `@rshono/core/server` is not reachable from here.
|
|
11
11
|
*/
|
|
12
12
|
onShellError?: (error: unknown) => void;
|
|
13
13
|
/**
|
|
14
|
-
* Called for an error that
|
|
15
|
-
*
|
|
16
|
-
* shell down with it. See {@link renderHTML} for why the ones that didn't originate here are
|
|
17
|
-
* dropped instead.
|
|
14
|
+
* Called for an error that *originated* in SSR — a client component that threw while rendering on the
|
|
15
|
+
* server. See {@link renderHTML} for why the others are dropped.
|
|
18
16
|
*/
|
|
19
17
|
onError?: (error: unknown) => void;
|
|
20
18
|
/**
|
|
21
|
-
* Called once the response stream has ended, however it ended.
|
|
22
|
-
*
|
|
23
|
-
* The RSC layer uses it to detach the listener forwarding client-disconnect aborts into this render —
|
|
24
|
-
* see `renderComponent`. Without a hook here that listener outlives the request and retains the whole
|
|
25
|
-
* rendered tree, so this is load-bearing rather than a convenience.
|
|
19
|
+
* Called once the response stream has ended, however it ended. Load-bearing: the RSC layer uses it to
|
|
20
|
+
* detach the abort forwarder that would otherwise retain the whole rendered tree.
|
|
26
21
|
*/
|
|
27
22
|
onDone?: () => void;
|
|
28
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.ssr.d.ts","sourceRoot":"","sources":["../../src/runtime/entry.ssr.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAOvD,MAAM,WAAW,iBAAiB;IAChC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC
|
|
1
|
+
{"version":3,"file":"entry.ssr.d.ts","sourceRoot":"","sources":["../../src/runtime/entry.ssr.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAOvD,MAAM,WAAW,iBAAiB;IAChC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AA+CD,wBAAsB,UAAU,CAAC,SAAS,EAAE,cAAc,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,iBAAiB;;;GA4CjG"}
|
|
@@ -4,27 +4,21 @@ import { renderToReadableStream } from 'react-dom/server';
|
|
|
4
4
|
import { createFromReadableStream } from 'react-server-dom-rspack/client';
|
|
5
5
|
import { isControlDigest } from './control.js';
|
|
6
6
|
import { injectFlightPayload } from './flight-inject.js';
|
|
7
|
-
//
|
|
8
|
-
// target need not have a `process` at all.
|
|
7
|
+
// The baked config, not `process.env.NODE_ENV`: a deploy target need not have a `process`.
|
|
9
8
|
const isDev = __RSHONO_CONFIG__.isDev;
|
|
10
9
|
/** Escapes text going into HTML body content — a stack trace is untrusted input. */
|
|
11
10
|
function escapeHtml(text) {
|
|
12
11
|
return text.replace(/[&<>]/g, (char) => (char === '&' ? '&' : char === '<' ? '<' : '>'));
|
|
13
12
|
}
|
|
14
13
|
/**
|
|
15
|
-
* The last-resort 500 document, for when SSR fails before a
|
|
14
|
+
* The last-resort 500 document, for when SSR fails before a byte of the real shell was sent.
|
|
16
15
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
16
|
+
* Plain HTML with no client runtime and no stylesheet links: both came from the render that just failed,
|
|
17
|
+
* and hydrating a mismatched payload would tear the page down over this very message. A string rather than
|
|
18
|
+
* a component for the same reason — React is what failed. It must end with the document trailer, which
|
|
19
|
+
* `injectFlightPayload` holds back and re-emits.
|
|
21
20
|
*
|
|
22
|
-
*
|
|
23
|
-
* this through it again is a dependency the fallback does not need. It must end with the document
|
|
24
|
-
* trailer, which is what `injectFlightPayload` holds back and re-emits.
|
|
25
|
-
*
|
|
26
|
-
* The detail is dev-only. In production this stays a generic message, matching how the `error` page
|
|
27
|
-
* from routes.ts redacts.
|
|
21
|
+
* The detail is dev-only, matching how the app's `error` page redacts.
|
|
28
22
|
*/
|
|
29
23
|
function failureDocument(error) {
|
|
30
24
|
const detail = isDev ? (error instanceof Error ? (error.stack ?? `${error.name}: ${error.message}`) : String(error)) : null;
|
|
@@ -59,13 +53,10 @@ export async function renderHTML(rscStream, options) {
|
|
|
59
53
|
payload ??= createFromReadableStream(rscForSsr, options.nonce ? { nonce: options.nonce } : undefined);
|
|
60
54
|
return React.use(payload).root;
|
|
61
55
|
}
|
|
62
|
-
// React hands `onError` every error it meets while streaming,
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
// prints an alarming, detail-free duplicate for a request a boundary handled perfectly well. Only
|
|
67
|
-
// an error carrying no digest started life in this render — a client component that threw during
|
|
68
|
-
// SSR — and that one nothing else will report.
|
|
56
|
+
// React hands `onError` every error it meets while streaming, contained ones included. Almost all arrive
|
|
57
|
+
// out of the flight payload as its redacted stand-in — a `digest` and no message — and the RSC layer has
|
|
58
|
+
// already reported those in full. Only an error carrying no digest started life in this render, and that
|
|
59
|
+
// one nothing else will report.
|
|
69
60
|
let reported;
|
|
70
61
|
const onError = (error) => {
|
|
71
62
|
if (typeof error?.digest === 'string')
|
|
@@ -83,16 +74,14 @@ export async function renderHTML(rscStream, options) {
|
|
|
83
74
|
formState: options.formState,
|
|
84
75
|
signal: options.signal,
|
|
85
76
|
nonce: options.nonce,
|
|
86
|
-
//
|
|
87
|
-
// stays exactly what it was before a handler was installed here.
|
|
77
|
+
// Returns nothing, so the digest React gives the client's `onRecoverableError` is unchanged.
|
|
88
78
|
onError,
|
|
89
79
|
});
|
|
90
80
|
}
|
|
91
81
|
catch (error) {
|
|
92
82
|
if (isControlDigest(error?.digest))
|
|
93
83
|
throw error;
|
|
94
|
-
// `onError` runs first for the failure that aborts the shell, so this reports only what it let
|
|
95
|
-
// through: an error out of the flight payload, whose detail the RSC layer alone has.
|
|
84
|
+
// `onError` runs first for the failure that aborts the shell, so this reports only what it let through.
|
|
96
85
|
if (!options.signal?.aborted && error !== reported)
|
|
97
86
|
options.onShellError?.(error);
|
|
98
87
|
status = 500;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.ssr.js","sourceRoot":"","sources":["../../src/runtime/entry.ssr.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC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,KAAK,CAAC;QACjB,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC,CAAC;IAEF,IAAI,UAAsC,CAAC;IAC3C,IAAI,MAA0B,CAAC;IAC/B,IAAI,CAAC;QACH,UAAU,GAAG,MAAM,sBAAsB,CAAC,KAAC,OAAO,KAAG,EAAE;YACrD,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;YAC1C,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,6FAA6F;YAC7F,OAAO;SACR,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,eAAe,CAAE,KAAqC,EAAE,MAAM,CAAC;YAAE,MAAM,KAAK,CAAC;QACjF,wGAAwG;QACxG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,IAAI,KAAK,KAAK,QAAQ;YAAE,OAAO,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC,CAAC;QAClF,MAAM,GAAG,GAAG,CAAC;QACb,UAAU,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,cAAc,GAAG,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAEnI,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC;AAC5C,CAAC","sourcesContent":["import React from 'react';\nimport type { ReactFormState } from 'react-dom/client';\nimport { renderToReadableStream } from 'react-dom/server';\nimport { createFromReadableStream } from 'react-server-dom-rspack/client';\nimport { isControlDigest } from './control.js';\nimport { injectFlightPayload } from './flight-inject.js';\nimport type { RscPayload } from './entry.rsc.js';\n\nexport interface RenderHTMLOptions {\n bootstrapScripts?: string[];\n formState?: ReactFormState;\n signal?: AbortSignal;\n nonce?: string;\n /**\n * Called when SSR fails before the shell is sent. Reporting is the RSC layer's job: this module is\n * compiled into the SSR layer, which gets its own instance of every module it imports, so a handler\n * registered through `@rshono/core/server` is not reachable from here.\n */\n onShellError?: (error: unknown) => void;\n /**\n * Called for an error that *originated* in SSR — a client component that threw while rendering on the\n * server. See {@link renderHTML} for why the others are dropped.\n */\n onError?: (error: unknown) => void;\n /**\n * Called once the response stream has ended, however it ended. Load-bearing: the RSC layer uses it to\n * detach the abort forwarder that would otherwise retain the whole rendered tree.\n */\n onDone?: () => void;\n}\n\n// The baked config, not `process.env.NODE_ENV`: a deploy target need not have a `process`.\nconst isDev = __RSHONO_CONFIG__.isDev;\n\n/** Escapes text going into HTML body content — a stack trace is untrusted input. */\nfunction escapeHtml(text: string): string {\n return text.replace(/[&<>]/g, (char) => (char === '&' ? '&' : char === '<' ? '<' : '>'));\n}\n\n/**\n * The last-resort 500 document, for when SSR fails before a byte of the real shell was sent.\n *\n * Plain HTML with no client runtime and no stylesheet links: both came from the render that just failed,\n * and hydrating a mismatched payload would tear the page down over this very message. A string rather than\n * a component for the same reason — React is what failed. It must end with the document trailer, which\n * `injectFlightPayload` holds back and re-emits.\n *\n * The detail is dev-only, matching how the app's `error` page redacts.\n */\nfunction failureDocument(error: unknown): ReadableStream<Uint8Array> {\n const detail = isDev ? (error instanceof Error ? (error.stack ?? `${error.name}: ${error.message}`) : String(error)) : null;\n const html =\n '<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"utf-8\">' +\n '<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">' +\n '<title>500 — Internal Server Error</title></head>' +\n '<body style=\"margin:0;padding:2rem;font:16px/1.6 system-ui,-apple-system,sans-serif;color:#18181b\">' +\n '<h1 style=\"margin:0 0 .5rem;font-size:1.25rem\">500 — Internal Server Error</h1>' +\n '<p style=\"margin:0 0 1.5rem;color:#52525b\">' +\n (isDev\n ? 'Server-side rendering failed before the page shell could be sent, so the app’s error page could not be reached either.'\n : 'Something went wrong while rendering this page. Please try again.') +\n '</p>' +\n (detail\n ? '<pre style=\"margin:0;padding:1rem;overflow:auto;background:#f4f4f5;border-left:3px solid #ef4444;' +\n `font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;word-break:break-word\">${escapeHtml(detail)}</pre>`\n : '') +\n '</body></html>';\n const bytes = new TextEncoder().encode(html);\n return new ReadableStream<Uint8Array>({\n start(controller) {\n controller.enqueue(bytes);\n controller.close();\n },\n });\n}\n\nexport async function renderHTML(rscStream: ReadableStream<Uint8Array>, options: RenderHTMLOptions) {\n // One copy is rendered to HTML here; the other rides along in that HTML for the client to hydrate from.\n const [rscForSsr, rscForClient] = rscStream.tee();\n\n let payload: Promise<RscPayload>;\n function SsrRoot() {\n payload ??= createFromReadableStream<RscPayload>(rscForSsr, options.nonce ? { nonce: options.nonce } : undefined);\n return React.use(payload).root;\n }\n\n // React hands `onError` every error it meets while streaming, contained ones included. Almost all arrive\n // out of the flight payload as its redacted stand-in — a `digest` and no message — and the RSC layer has\n // already reported those in full. Only an error carrying no digest started life in this render, and that\n // one nothing else will report.\n let reported: unknown;\n const onError = (error: unknown): void => {\n if (typeof (error as { digest?: unknown } | null)?.digest === 'string') return;\n if (options.signal?.aborted) return; // an abort is the client leaving, not a fault\n reported = error;\n options.onError?.(error);\n };\n\n let htmlStream: ReadableStream<Uint8Array>;\n let status: number | undefined;\n try {\n htmlStream = await renderToReadableStream(<SsrRoot />, {\n bootstrapScripts: options.bootstrapScripts,\n formState: options.formState,\n signal: options.signal,\n nonce: options.nonce,\n // Returns nothing, so the digest React gives the client's `onRecoverableError` is unchanged.\n onError,\n });\n } catch (error) {\n if (isControlDigest((error as { digest?: unknown } | null)?.digest)) throw error;\n // `onError` runs first for the failure that aborts the shell, so this reports only what it let through.\n if (!options.signal?.aborted && error !== reported) options.onShellError?.(error);\n status = 500;\n htmlStream = failureDocument(error);\n }\n\n const responseStream = htmlStream.pipeThrough(injectFlightPayload(rscForClient, { nonce: options.nonce, onDone: options.onDone }));\n\n return { stream: responseStream, status };\n}\n"]}
|
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Carrying the flight payload inside the HTML document, so the browser hydrates from bytes it
|
|
3
|
-
*
|
|
2
|
+
* Carrying the flight payload inside the HTML document, so the browser hydrates from bytes it already has
|
|
3
|
+
* rather than fetching the page twice. The reader is `readFlightPayload` in `entry.client.tsx`.
|
|
4
4
|
*
|
|
5
|
-
* The wire format is `rsc-html-stream`'s — a run of
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* that straddles one, so `</body></html>` can arrive as two chunks; upstream then fails to hold it
|
|
10
|
-
* back, and the document ends up with two trailers and the payload script after the first of them.
|
|
11
|
-
* A page's byte layout is deterministic, so that is not an intermittent fault — an unlucky page is
|
|
12
|
-
* malformed on every request. `test/unit.test.mjs` pins the split-trailer cases.
|
|
13
|
-
*
|
|
14
|
-
* The reader for this format is `readFlightPayload` in `entry.client.tsx`.
|
|
5
|
+
* The wire format is `rsc-html-stream`'s — a run of `<script>(self.__FLIGHT_DATA||=[]).push("…")</script>`
|
|
6
|
+
* tags — but the implementation is first-party, because that package tests each HTML chunk for the
|
|
7
|
+
* document trailer with `endsWith`: React's byte writer splits any write straddling its 2 kB views, so
|
|
8
|
+
* `</body></html>` can arrive as two chunks and the document ends up with two trailers.
|
|
15
9
|
*/
|
|
16
10
|
/**
|
|
17
|
-
* {@link Transformer} plus the `cancel` hook the Streams standard added for a cancelled readable side
|
|
11
|
+
* {@link Transformer} plus the `cancel` hook the Streams standard added for a cancelled readable side —
|
|
12
|
+
* declared here because the bundled lib types have not caught up with what Node calls.
|
|
18
13
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* that a response ended *without* finishing, and both users of it release a listener that would
|
|
22
|
-
* otherwise outlive the request.
|
|
14
|
+
* It matters because `cancel` is the only notification that a response ended *without* finishing, and both
|
|
15
|
+
* users of it release a listener that would otherwise outlive the request.
|
|
23
16
|
*/
|
|
24
17
|
export type CancellableTransformer<I, O> = Transformer<I, O> & {
|
|
25
18
|
cancel?: (reason?: unknown) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flight-inject.d.ts","sourceRoot":"","sources":["../../src/runtime/flight-inject.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"flight-inject.d.ts","sourceRoot":"","sources":["../../src/runtime/flight-inject.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,sBAAsB,CAAC,CAAC,EAAE,CAAC,IAAI,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;CAAE,CAAC;AAkDvG,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,cAAc,CAAC,UAAU,CAAC,EACrC,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;CAAO,GACpD,eAAe,CAAC,UAAU,EAAE,UAAU,CAAC,CAiJzC"}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Carrying the flight payload inside the HTML document, so the browser hydrates from bytes it
|
|
3
|
-
*
|
|
2
|
+
* Carrying the flight payload inside the HTML document, so the browser hydrates from bytes it already has
|
|
3
|
+
* rather than fetching the page twice. The reader is `readFlightPayload` in `entry.client.tsx`.
|
|
4
4
|
*
|
|
5
|
-
* The wire format is `rsc-html-stream`'s — a run of
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* that straddles one, so `</body></html>` can arrive as two chunks; upstream then fails to hold it
|
|
10
|
-
* back, and the document ends up with two trailers and the payload script after the first of them.
|
|
11
|
-
* A page's byte layout is deterministic, so that is not an intermittent fault — an unlucky page is
|
|
12
|
-
* malformed on every request. `test/unit.test.mjs` pins the split-trailer cases.
|
|
13
|
-
*
|
|
14
|
-
* The reader for this format is `readFlightPayload` in `entry.client.tsx`.
|
|
5
|
+
* The wire format is `rsc-html-stream`'s — a run of `<script>(self.__FLIGHT_DATA||=[]).push("…")</script>`
|
|
6
|
+
* tags — but the implementation is first-party, because that package tests each HTML chunk for the
|
|
7
|
+
* document trailer with `endsWith`: React's byte writer splits any write straddling its 2 kB views, so
|
|
8
|
+
* `</body></html>` can arrive as two chunks and the document ends up with two trailers.
|
|
15
9
|
*/
|
|
16
10
|
const encoder = new TextEncoder();
|
|
17
11
|
/** What React closes an `<html>` document with, and what this module re-emits after the last payload script. */
|
|
@@ -26,21 +20,16 @@ const unschedule = (handle) => {
|
|
|
26
20
|
clearTimeout(handle);
|
|
27
21
|
};
|
|
28
22
|
/**
|
|
29
|
-
* Escapes the two sequences that would end a `<script>` element early.
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* scan is far cheaper than two regex passes over 30 kB. `</script` becomes `</\script` rather than
|
|
33
|
-
* `<\/script`, which would break the valid JS `0</script/` (a regexp literal).
|
|
23
|
+
* Escapes the two sequences that would end a `<script>` element early. Guarded by `includes('<')`, which is
|
|
24
|
+
* far cheaper than two regex passes over 30 kB of payload that usually has no `<` in it. `</script` becomes
|
|
25
|
+
* `</\script`, not `<\/script`, which would break the valid JS `0</script/`.
|
|
34
26
|
*/
|
|
35
27
|
function escapeScript(script) {
|
|
36
28
|
return script.includes('<') ? script.replace(/<!--/g, '<\\!--').replace(/<\/(script)/gi, '</\\$1') : script;
|
|
37
29
|
}
|
|
38
30
|
/**
|
|
39
|
-
* The bytes of `chunk` as a latin1 string, which is the form `btoa` takes.
|
|
40
|
-
*
|
|
41
|
-
* Sliced rather than `String.fromCharCode(...chunk)`, which passes one argument per byte and
|
|
42
|
-
* overflows the call stack on a chunk of any size. The slice width is a stack-safety choice, not a
|
|
43
|
-
* tuned one — this is only reached for a chunk that split a multi-byte character.
|
|
31
|
+
* The bytes of `chunk` as a latin1 string, which is the form `btoa` takes. Sliced because
|
|
32
|
+
* `String.fromCharCode(...chunk)` passes one argument per byte and overflows the stack.
|
|
44
33
|
*/
|
|
45
34
|
function latin1(chunk) {
|
|
46
35
|
let out = '';
|
|
@@ -68,13 +57,11 @@ export function injectFlightPayload(rscStream, options = {}) {
|
|
|
68
57
|
const batch = [];
|
|
69
58
|
let boundary = null;
|
|
70
59
|
/**
|
|
71
|
-
* Set once the consumer has gone away, so nothing
|
|
72
|
-
* can no longer take it.
|
|
60
|
+
* Set once the consumer has gone away, so nothing tries to enqueue into a readable that cannot take it.
|
|
73
61
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* precisely that window. So a failed enqueue is also treated as the signal, wherever one happens.
|
|
62
|
+
* The `cancel` hook alone cannot set this: per the Streams standard, cancelling the readable after the
|
|
63
|
+
* close algorithm has started skips the transformer's `cancel` entirely — and `flush` awaiting the whole
|
|
64
|
+
* payload is precisely that window. So a failed enqueue counts as the signal too.
|
|
78
65
|
*/
|
|
79
66
|
let cancelled = false;
|
|
80
67
|
/** Held so {@link cancelled} can release the teed RSC branch rather than leaving it to be pumped. */
|
|
@@ -83,10 +70,9 @@ export function injectFlightPayload(rscStream, options = {}) {
|
|
|
83
70
|
* Emits the HTML buffered since the last boundary, holding back the document trailer for
|
|
84
71
|
* {@link TransformStream.flush} to re-emit after the payload scripts.
|
|
85
72
|
*
|
|
86
|
-
* The batch is joined before the trailer is looked for, so
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* batch; a trailer split *across* batches is not a shape React produces.
|
|
73
|
+
* The batch is joined before the trailer is looked for, so one React split across two views is still
|
|
74
|
+
* found. React writes its final flush in one synchronous run, so a trailer split across *batches* is not
|
|
75
|
+
* a shape it produces.
|
|
90
76
|
*/
|
|
91
77
|
function emitBatch(controller) {
|
|
92
78
|
boundary = null;
|
|
@@ -110,8 +96,8 @@ export function injectFlightPayload(rscStream, options = {}) {
|
|
|
110
96
|
}
|
|
111
97
|
async function writeFlight(controller) {
|
|
112
98
|
const reader = (flightReader = rscStream.getReader());
|
|
113
|
-
// `fatal`, so a chunk that split a multi-byte character throws
|
|
114
|
-
//
|
|
99
|
+
// `fatal`, so a chunk that split a multi-byte character throws instead of emitting U+FFFD; the catch
|
|
100
|
+
// below falls back to a byte-exact encoding for it.
|
|
115
101
|
const decoder = new TextDecoder('utf-8', { fatal: true });
|
|
116
102
|
const push = (literal) => controller.enqueue(encoder.encode(scriptOpen + literal + scriptClose));
|
|
117
103
|
for (;;) {
|
|
@@ -120,9 +106,8 @@ export function injectFlightPayload(rscStream, options = {}) {
|
|
|
120
106
|
const { done, value } = await reader.read();
|
|
121
107
|
if (done)
|
|
122
108
|
break;
|
|
123
|
-
// Only the
|
|
124
|
-
//
|
|
125
|
-
// re-encoding the chunk and enqueueing it again — which throws in turn, out of the catch.
|
|
109
|
+
// Only the decode is guarded: a `push` inside the same `try` would answer a dead controller by
|
|
110
|
+
// re-encoding the chunk and enqueueing it again.
|
|
126
111
|
let literal;
|
|
127
112
|
try {
|
|
128
113
|
literal = escapeScript(JSON.stringify(decoder.decode(value, { stream: true })));
|
|
@@ -132,8 +117,8 @@ export function injectFlightPayload(rscStream, options = {}) {
|
|
|
132
117
|
}
|
|
133
118
|
if (cancelled)
|
|
134
119
|
return;
|
|
135
|
-
// A failed enqueue means the consumer is gone
|
|
136
|
-
//
|
|
120
|
+
// A failed enqueue means the consumer is gone: release the RSC branch so `flush` unparks now rather
|
|
121
|
+
// than whenever the payload would have ended on its own.
|
|
137
122
|
try {
|
|
138
123
|
push(literal);
|
|
139
124
|
}
|
|
@@ -154,10 +139,8 @@ export function injectFlightPayload(rscStream, options = {}) {
|
|
|
154
139
|
batch.push(chunk);
|
|
155
140
|
if (boundary)
|
|
156
141
|
return;
|
|
157
|
-
// A macrotask, not a microtask: React writes a whole flush
|
|
158
|
-
//
|
|
159
|
-
// boundary guarantees the flush has arrived in full — a script injected between two of its
|
|
160
|
-
// chunks would land inside a tag.
|
|
142
|
+
// A macrotask, not a microtask: React writes a whole flush in one synchronous run but `pipeThrough`
|
|
143
|
+
// delivers it one microtask at a time, and a script injected between two chunks lands inside a tag.
|
|
161
144
|
boundary = schedule(() => {
|
|
162
145
|
try {
|
|
163
146
|
emitBatch(controller);
|
|
@@ -169,7 +152,9 @@ export function injectFlightPayload(rscStream, options = {}) {
|
|
|
169
152
|
}
|
|
170
153
|
if (!startedFlight) {
|
|
171
154
|
startedFlight = true;
|
|
172
|
-
|
|
155
|
+
// Deliberately not awaited: this runs inside a scheduled callback with nothing to return to, and
|
|
156
|
+
// the chain already routes a write failure to `controller.error` before settling `flightDone`.
|
|
157
|
+
void writeFlight(controller)
|
|
173
158
|
.catch((error) => controller.error(error))
|
|
174
159
|
.then(flightDone);
|
|
175
160
|
}
|
|
@@ -177,11 +162,9 @@ export function injectFlightPayload(rscStream, options = {}) {
|
|
|
177
162
|
},
|
|
178
163
|
async flush(controller) {
|
|
179
164
|
await flightWritten;
|
|
180
|
-
// That await spans the
|
|
181
|
-
//
|
|
182
|
-
//
|
|
183
|
-
// signal. Unguarded it rejects `flush`, and nothing owns that rejection: it surfaces as an
|
|
184
|
-
// unhandled one and, where the host does not swallow it, takes the process down.
|
|
165
|
+
// That await spans the whole payload, and the consumer can go away inside it — with `cancel` skipped
|
|
166
|
+
// (see `cancelled`), a throwing enqueue is the only signal. Unguarded it rejects `flush`, which
|
|
167
|
+
// nothing owns and which surfaces as an unhandled rejection.
|
|
185
168
|
try {
|
|
186
169
|
if (boundary) {
|
|
187
170
|
unschedule(boundary);
|
|
@@ -196,8 +179,7 @@ export function injectFlightPayload(rscStream, options = {}) {
|
|
|
196
179
|
flightReader?.cancel().catch(() => { });
|
|
197
180
|
}
|
|
198
181
|
finally {
|
|
199
|
-
//
|
|
200
|
-
// forwarder in `renderComponent`, so it has to run however the response ended.
|
|
182
|
+
// A `finally` because `onDone` releases the abort forwarder in `renderComponent`, however this ended.
|
|
201
183
|
onDone?.();
|
|
202
184
|
}
|
|
203
185
|
},
|
|
@@ -208,8 +190,8 @@ export function injectFlightPayload(rscStream, options = {}) {
|
|
|
208
190
|
boundary = null;
|
|
209
191
|
}
|
|
210
192
|
batch.length = 0;
|
|
211
|
-
//
|
|
212
|
-
//
|
|
193
|
+
// Otherwise the teed RSC branch keeps being pumped for a response nobody will read, and the tee's
|
|
194
|
+
// other half buffers every chunk waiting for this one to catch up.
|
|
213
195
|
flightReader?.cancel(reason).catch(() => { });
|
|
214
196
|
// Unparks `flush` if it is waiting on a payload that will now never arrive.
|
|
215
197
|
flightDone();
|