@rshono/core 1.0.0-rc.11 → 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/README.md +2 -1
- 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 +10 -0
- package/dist/builder/rspack-config.d.ts.map +1 -1
- package/dist/builder/rspack-config.js +38 -40
- package/dist/builder/rspack-config.js.map +1 -1
- package/dist/cli/build.js +4 -4
- package/dist/cli/build.js.map +1 -1
- package/dist/cli/dev.d.ts.map +1 -1
- package/dist/cli/dev.js +50 -37
- 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 +12 -15
- 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.d.ts.map +1 -1
- package/dist/runtime/entry.client.js +92 -120
- 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 +45 -0
- package/dist/runtime/hot-update.d.ts.map +1 -0
- package/dist/runtime/hot-update.js +44 -0
- package/dist/runtime/hot-update.js.map +1 -0
- 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 +18 -25
- package/dist/server/server-config.d.ts.map +1 -1
- package/dist/server/server-config.js +7 -11
- 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,15 +1,13 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Hono } from 'hono';
|
|
3
3
|
import { HTTPException } from 'hono/http-exception';
|
|
4
|
-
//
|
|
5
|
-
//
|
|
4
|
+
// Called directly rather than as `<Page {...props} />`: a spread would drop the non-enumerable `ctx`
|
|
5
|
+
// prop. See `pageProps`.
|
|
6
6
|
import { jsx } from 'react/jsx-runtime';
|
|
7
|
-
// The bare specifier, not `/server.node`: the
|
|
8
|
-
//
|
|
9
|
-
// own build rather than Node's by hard-coded path.
|
|
7
|
+
// The bare specifier, not `/server.node`: the RSC layer's `conditionNames` picks the build for the
|
|
8
|
+
// deploy target being compiled for.
|
|
10
9
|
import { createTemporaryReferenceSet, decodeAction, decodeFormState, decodeReply, loadServerAction, renderToReadableStream, } from 'react-server-dom-rspack/server';
|
|
11
|
-
//
|
|
12
|
-
// this file knows anything about where it is running. See `deploy/contract.ts`.
|
|
10
|
+
// Aliased at build time to the selected preset's runtime — the one place this file knows where it runs.
|
|
13
11
|
import { runtime } from '@rshono/deploy';
|
|
14
12
|
// @ts-expect-error — resolved by the '@rshono/routes' alias to the app's routes.ts
|
|
15
13
|
import { routes as userRoutes } from '@rshono/routes';
|
|
@@ -23,34 +21,21 @@ import { renderHTML } from './entry.ssr.js';
|
|
|
23
21
|
import { RouterProvider } from './navigation.js';
|
|
24
22
|
import { acceptsRsc, isActionRequest, parseRenderRequest, requestWantsRsc, wantsRsc } from './request.js';
|
|
25
23
|
const serverApp = (serverAppModule.default ?? null);
|
|
26
|
-
//
|
|
27
|
-
// builder/rspack-config.ts). There is no runtime env-var interface for these — env is for secrets.
|
|
28
|
-
// `isDev` among them: the build mode is decided by which command produced the bundle, and not every
|
|
29
|
-
// runtime this deploys to has a `process.env.NODE_ENV` to read.
|
|
24
|
+
// Compiled into the bundle from rshono.config.ts by DefinePlugin; there is no runtime env-var interface.
|
|
30
25
|
const { isDev } = __RSHONO_CONFIG__;
|
|
31
26
|
/** How long a prerendered page may be reused before revalidating. Also what `public/` files get. */
|
|
32
27
|
const SSG_CACHE_CONTROL = 'public, max-age=300';
|
|
33
|
-
/**
|
|
34
|
-
* The two content types a page can be served as. Both come back from the *same* URL depending on
|
|
35
|
-
* the `Accept` header, which is what makes `Vary` non-optional here.
|
|
36
|
-
*/
|
|
28
|
+
/** The two content types a page can be served as, from the same URL — which is what makes `Vary` non-optional. */
|
|
37
29
|
const PAGE_CONTENT_TYPE = /^(?:text\/html|text\/x-component)\b/;
|
|
38
|
-
// Called here rather than at the top of the deploy runtime's own module so the timing is unchanged:
|
|
39
|
-
// `.env` is loaded once every import above has been evaluated, exactly as before.
|
|
40
30
|
runtime.loadEnv();
|
|
41
31
|
const routeConfig = userRoutes;
|
|
42
32
|
export const routes = routeConfig.routes;
|
|
43
33
|
/**
|
|
44
34
|
* The per-request CSP nonce, if the app asked for one.
|
|
45
35
|
*
|
|
46
|
-
* The framework
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* to stamp the value into the render.
|
|
50
|
-
*
|
|
51
|
-
* Readable from a route handler because `secureHeaders` resolves its directives *before* calling
|
|
52
|
-
* `next()`; the header itself is written on the way back out. Absent when the app registered no CSP,
|
|
53
|
-
* or one with no nonce in it — a fixed policy needs nothing from the render.
|
|
36
|
+
* The framework never mints it: `secureHeaders()` does, when its policy contains the `NONCE`
|
|
37
|
+
* placeholder, and stores it here — so all the framework does is stamp the value into the render. It is
|
|
38
|
+
* readable from a route handler because `secureHeaders` resolves its directives before `next()`.
|
|
54
39
|
*/
|
|
55
40
|
function cspNonce(c) {
|
|
56
41
|
return c.get('secureHeadersNonce');
|
|
@@ -75,20 +60,18 @@ function acceptsHtml(c) {
|
|
|
75
60
|
}
|
|
76
61
|
/**
|
|
77
62
|
* The 404 for an app with no `notFound` page, and for a client that wanted neither HTML nor a flight
|
|
78
|
-
* payload.
|
|
79
|
-
* `Accept`, and a cache not told so can hand a plain-text 404 to a browser asking for a document.
|
|
63
|
+
* payload. It carries the `Vary` too: this is one of the answers a page URL gives depending on `Accept`.
|
|
80
64
|
*/
|
|
81
65
|
function plainNotFound(c) {
|
|
82
66
|
return c.text('Not Found', 404, { vary: 'Accept' });
|
|
83
67
|
}
|
|
84
|
-
/** A lazy once-cell: runs `load` at most once
|
|
68
|
+
/** A lazy once-cell: runs `load` at most once, but clears a rejection so a later call can retry. */
|
|
85
69
|
function once(load) {
|
|
86
70
|
let promise;
|
|
87
71
|
return () => {
|
|
88
72
|
if (!promise) {
|
|
89
73
|
const pending = (promise = load());
|
|
90
74
|
pending.catch(() => {
|
|
91
|
-
// Only clear if we're still holding the rejected promise (a later successful load may have already replaced it).
|
|
92
75
|
if (promise === pending)
|
|
93
76
|
promise = undefined;
|
|
94
77
|
});
|
|
@@ -97,11 +80,8 @@ function once(load) {
|
|
|
97
80
|
};
|
|
98
81
|
}
|
|
99
82
|
/**
|
|
100
|
-
* Passes `stream` through untouched, calling `done`
|
|
101
|
-
*
|
|
102
|
-
* Used on the flight-only response path, which has no transform of its own to hang a completion hook
|
|
103
|
-
* off (the document path has {@link injectFlightPayload}). `done` must be idempotent: a cancelled
|
|
104
|
-
* response can reach both `cancel` and the abort forwarder.
|
|
83
|
+
* Passes `stream` through untouched, calling `done` however it ends — for the flight-only response
|
|
84
|
+
* path, which has no transform of its own to hang a completion hook off. `done` must be idempotent.
|
|
105
85
|
*/
|
|
106
86
|
function releaseWhenDone(stream, done) {
|
|
107
87
|
return stream.pipeThrough(new TransformStream({
|
|
@@ -115,23 +95,16 @@ function releaseWhenDone(stream, done) {
|
|
|
115
95
|
/**
|
|
116
96
|
* Builds the props a page component is called with.
|
|
117
97
|
*
|
|
118
|
-
* `
|
|
119
|
-
* `'use client'` component unchanged. The `URL` is this page's own, so mutating it cannot disturb
|
|
120
|
-
* anything else on the request.
|
|
121
|
-
*
|
|
122
|
-
* `ctx` is *defined* rather than assigned, and both halves of how carry their weight:
|
|
98
|
+
* `ctx` is *defined* rather than assigned, and both halves are load-bearing:
|
|
123
99
|
*
|
|
124
|
-
* - **A getter**, so nothing is built for the pages that never read it, and
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* enumerable properties, and `ctx.hono` is the Hono {@link Context} — whose `env` holds the
|
|
130
|
-
* runtime's bindings. An enumerable `ctx` would ship every one of them, secrets included, to the
|
|
131
|
-
* browser in dev, and add well over 10 kB to a small page's flight payload.
|
|
100
|
+
* - **A getter**, so nothing is built for the pages that never read it, and a `render: 'static'` page
|
|
101
|
+
* that does gets {@link getRequestContext}'s prerendering error rather than a bare `undefined`.
|
|
102
|
+
* - **Non-enumerable**, so React's dev-only serialization of a server component's props skips it. That
|
|
103
|
+
* walks own enumerable properties, and `ctx.hono.env` holds the runtime's bindings — an enumerable
|
|
104
|
+
* `ctx` would ship every secret to the browser in dev.
|
|
132
105
|
*
|
|
133
|
-
* The cost
|
|
134
|
-
* `<Page {...props} />` spread
|
|
106
|
+
* The cost: the element is created by handing this object to `jsx()` by reference, since a
|
|
107
|
+
* `<Page {...props} />` spread would silently drop `ctx`.
|
|
135
108
|
*/
|
|
136
109
|
function pageProps(c, errorInfo) {
|
|
137
110
|
const props = { url: publicUrl(c), params: readParams(c), ...(errorInfo ? { error: errorInfo } : null) };
|
|
@@ -139,16 +112,11 @@ function pageProps(c, errorInfo) {
|
|
|
139
112
|
return props;
|
|
140
113
|
}
|
|
141
114
|
async function renderComponent(c, Page, opts) {
|
|
142
|
-
//
|
|
143
|
-
//
|
|
144
|
-
//
|
|
145
|
-
//
|
|
146
|
-
//
|
|
147
|
-
//
|
|
148
|
-
// So the render gets a controller of its own and the request signal only forwards into it: the
|
|
149
|
-
// forwarder is `once`, so an abort removes it, and `release` removes it on the normal path. Not
|
|
150
|
-
// `AbortSignal.any()` — a signal it produced is *composite*, and Node holds every composite signal
|
|
151
|
-
// carrying an `abort` listener in a process-lifetime set until it aborts or loses its last listener.
|
|
115
|
+
// React's renderers must never be handed `c.req.raw.signal`: they add an `abort` listener and only
|
|
116
|
+
// remove it if the abort fires, so on the happy path it stays on a request-lifetime signal and pins the
|
|
117
|
+
// whole rendered tree. The render gets its own controller and the request signal forwards into it —
|
|
118
|
+
// `release` detaches on the normal path. Not `AbortSignal.any()`, whose composite signals Node holds in
|
|
119
|
+
// a process-lifetime set until they abort.
|
|
152
120
|
const requestSignal = c.req.raw.signal;
|
|
153
121
|
const renderAbort = new AbortController();
|
|
154
122
|
const signal = renderAbort.signal;
|
|
@@ -157,20 +125,16 @@ async function renderComponent(c, Page, opts) {
|
|
|
157
125
|
renderAbort.abort(requestSignal.reason);
|
|
158
126
|
else
|
|
159
127
|
requestSignal.addEventListener('abort', forwardAbort, { once: true });
|
|
160
|
-
/** Detaches the forwarder once the response has been written, so nothing survives the request. */
|
|
161
128
|
const release = () => requestSignal.removeEventListener('abort', forwardAbort);
|
|
162
|
-
// Documents only: the nonce goes on the bootstrap scripts and the `<meta>` React hydrates from,
|
|
163
|
-
//
|
|
164
|
-
// payload servable from disk under a nonce-based CSP.
|
|
129
|
+
// Documents only: the nonce goes on the bootstrap scripts and the `<meta>` React hydrates from, and a
|
|
130
|
+
// flight payload has neither — which is what keeps a prerendered one servable under a nonce-based CSP.
|
|
165
131
|
const nonce = opts.isRsc ? undefined : cspNonce(c);
|
|
166
132
|
const props = pageProps(c, opts.errorInfo);
|
|
167
133
|
const root = (_jsxs(_Fragment, { children: [nonce && _jsx("meta", { property: "csp-nonce", nonce: nonce }), Page.entryCssFiles?.map((href) => (_jsx("link", { rel: "stylesheet", href: href, precedence: "default" }, href))), _jsx(RouterProvider, { href: props.url.href, params: props.params, children: jsx(Page, props) })] }));
|
|
168
|
-
// `notFound` only when
|
|
134
|
+
// `notFound` only when true, so an ordinary page's payload doesn't carry the key.
|
|
169
135
|
const rscPayload = { root, formState: opts.formState, returnValue: opts.returnValue, ...(opts.notFound ? { notFound: true } : null) };
|
|
170
|
-
//
|
|
171
|
-
//
|
|
172
|
-
// the last thing before the render: a server action ran earlier in `renderPage` and legitimately
|
|
173
|
-
// writes to the response, and so does any middleware that wrapped this handler.
|
|
136
|
+
// The last thing before the render: past here the response head is the framework's, so `ctx.setHeader()`
|
|
137
|
+
// starts throwing — while the action `renderPage` just ran, and the middleware around it, legitimately wrote.
|
|
174
138
|
beginPageRender(c);
|
|
175
139
|
let controlSignal;
|
|
176
140
|
const rscStream = renderToReadableStream(rscPayload, {
|
|
@@ -225,9 +189,8 @@ async function renderPage(c, loadPage) {
|
|
|
225
189
|
let actionStatus;
|
|
226
190
|
if (isActionRequest(renderRequest)) {
|
|
227
191
|
if (renderRequest.kind === 'rsc-action') {
|
|
228
|
-
//
|
|
229
|
-
//
|
|
230
|
-
// request into an unhandled 500. `hasOwn` so `__proto__` doesn't resolve to a manifest entry.
|
|
192
|
+
// Before the body is decoded, so an unknown id costs nothing to reject. `hasOwn` so `__proto__`
|
|
193
|
+
// does not resolve to a manifest entry.
|
|
231
194
|
if (!Object.hasOwn(__rspack_rsc_manifest__.serverManifest, renderRequest.actionId)) {
|
|
232
195
|
return c.text('Bad Request: unknown server action', 400);
|
|
233
196
|
}
|
|
@@ -237,13 +200,13 @@ async function renderPage(c, loadPage) {
|
|
|
237
200
|
const args = await decodeReply(body, { temporaryReferences });
|
|
238
201
|
const action = loadServerAction(renderRequest.actionId);
|
|
239
202
|
try {
|
|
240
|
-
returnValue = { ok: true, value: await action
|
|
203
|
+
returnValue = { ok: true, value: await action(...args) };
|
|
241
204
|
}
|
|
242
205
|
catch (error) {
|
|
243
206
|
if (isControlSignal(error))
|
|
244
207
|
throw error;
|
|
245
|
-
// React sends a thrown action error to the client as an opaque marker
|
|
246
|
-
//
|
|
208
|
+
// In production React sends a thrown action error to the client as an opaque marker, so this is
|
|
209
|
+
// the only place the real one is visible.
|
|
247
210
|
reportServerError(error, { source: 'action', request, message: '[rshono] server action error:' });
|
|
248
211
|
returnValue = { ok: false, error };
|
|
249
212
|
actionStatus = 500;
|
|
@@ -269,13 +232,10 @@ async function renderPage(c, loadPage) {
|
|
|
269
232
|
}
|
|
270
233
|
function buildApp() {
|
|
271
234
|
const app = new Hono();
|
|
272
|
-
//
|
|
273
|
-
//
|
|
274
|
-
// the
|
|
275
|
-
//
|
|
276
|
-
// for whatever that set. Kept in the framework rather than left to the app because it is
|
|
277
|
-
// registered ahead of `mountStaticAssets`, which is a terminal handler the sub-app never sees:
|
|
278
|
-
// without this, `/_static/*` would carry no security headers at all.
|
|
235
|
+
// A floor, not a policy: an app wanting the full set registers `secureHeaders()` in src/server.ts, and
|
|
236
|
+
// because this is registered first it unwinds last, so the "only if unset" checks stand aside for it.
|
|
237
|
+
// Owned by the framework because it also has to cover `mountStaticAssets` — a terminal handler the
|
|
238
|
+
// app's own middleware never sees.
|
|
279
239
|
app.use(async (c, next) => {
|
|
280
240
|
await next();
|
|
281
241
|
const headers = c.res.headers;
|
|
@@ -285,33 +245,26 @@ function buildApp() {
|
|
|
285
245
|
headers.set('referrer-policy', 'strict-origin-when-cross-origin');
|
|
286
246
|
if (!headers.has('x-frame-options'))
|
|
287
247
|
headers.set('x-frame-options', 'SAMEORIGIN');
|
|
288
|
-
// React Refresh compiles updates with `eval`, so a dev build cannot run under
|
|
289
|
-
//
|
|
290
|
-
// in src/server.ts serves both and nobody debugs a blocked HMR socket. Only ever in dev, and
|
|
291
|
-
// only when the app has a `script-src` to widen.
|
|
248
|
+
// React Refresh compiles updates with `eval`, so a dev build cannot run under a production CSP.
|
|
249
|
+
// Widened here so one policy in src/server.ts serves both.
|
|
292
250
|
if (isDev) {
|
|
293
251
|
const csp = headers.get('content-security-policy');
|
|
294
252
|
if (csp?.includes('script-src ')) {
|
|
295
253
|
headers.set('content-security-policy', csp.replace('script-src ', "script-src 'unsafe-eval' "));
|
|
296
254
|
}
|
|
297
255
|
}
|
|
298
|
-
// Page responses only
|
|
299
|
-
// payload depending on `Accept`, and the default page is request-specific.
|
|
256
|
+
// Page responses only from here down.
|
|
300
257
|
if (!PAGE_CONTENT_TYPE.test(headers.get('content-type') ?? ''))
|
|
301
258
|
return;
|
|
302
259
|
appendVary(headers, 'Accept');
|
|
303
|
-
// Without
|
|
304
|
-
//
|
|
305
|
-
// that; `no-cache` makes the browser revalidate rather than re-show a stale personalised page.
|
|
306
|
-
// Neither blocks bfcache, which `no-store` would. A prerendered page already has its own value.
|
|
260
|
+
// Without a default a shared cache is free to store a logged-in user's page and hand it to someone
|
|
261
|
+
// else. `private, no-cache` forbids that without blocking bfcache, which `no-store` would.
|
|
307
262
|
if (!headers.has('cache-control'))
|
|
308
263
|
headers.set('cache-control', 'private, no-cache');
|
|
309
264
|
});
|
|
310
265
|
runtime.mountStaticAssets(app);
|
|
311
|
-
//
|
|
312
|
-
//
|
|
313
|
-
// `secureHeaders()`) wraps page requests too. The flip side: a *terminal* handler in
|
|
314
|
-
// src/server.ts at the same path as a page route wins over the page.
|
|
266
|
+
// Ahead of the page routes, so the app's own middleware (`csrf()`, `bodyLimit()`, auth, logging) wraps
|
|
267
|
+
// page requests too. The flip side: a *terminal* handler in src/server.ts shadows a page at the same path.
|
|
315
268
|
if (serverApp) {
|
|
316
269
|
app.route('/', serverApp);
|
|
317
270
|
}
|
|
@@ -322,8 +275,7 @@ function buildApp() {
|
|
|
322
275
|
const isRsc = requestWantsRsc(c.req.raw);
|
|
323
276
|
if (signal instanceof RedirectSignal) {
|
|
324
277
|
if (isRsc) {
|
|
325
|
-
// No `signal
|
|
326
|
-
// component tree, so there is nothing worth aborting and nothing worth a listener.
|
|
278
|
+
// No `signal`: two fields and no component tree, so there is nothing worth aborting.
|
|
327
279
|
return c.body(renderToReadableStream({ root: null, redirect: signal.location }), 200, {
|
|
328
280
|
'content-type': 'text/x-component;charset=utf-8',
|
|
329
281
|
});
|
|
@@ -337,29 +289,22 @@ function buildApp() {
|
|
|
337
289
|
};
|
|
338
290
|
for (const route of routes) {
|
|
339
291
|
if (isPageRoute(route)) {
|
|
340
|
-
// Both
|
|
292
|
+
// Both fixed for the life of the process, so resolved once rather than per request.
|
|
341
293
|
const servesPrerendered = !isDev && route.render === 'static';
|
|
342
294
|
const loadPage = once(() => loadPageModule(route.component, `"${route.path}"`));
|
|
343
295
|
const handler = async (c) => {
|
|
344
296
|
try {
|
|
345
297
|
if (servesPrerendered && c.req.method === 'GET') {
|
|
346
298
|
const isRsc = acceptsRsc(c.req.raw);
|
|
347
|
-
//
|
|
348
|
-
// where the app's CSP has one
|
|
349
|
-
//
|
|
350
|
-
//
|
|
351
|
-
// Decided per request rather than per build, which is what moving the CSP to
|
|
352
|
-
// `secureHeaders()` buys: an app whose policy carries no `NONCE` keeps its prerendered
|
|
353
|
-
// documents, where the old build-time `csp: true` flag gave every one of them up.
|
|
299
|
+
// One fixed set of bytes cannot carry a per-request nonce, so a document has to be rendered
|
|
300
|
+
// where the app's CSP has one. Decided per request, so an app whose policy carries no `NONCE`
|
|
301
|
+
// keeps its prerendered documents. A flight payload never carries a nonce either way.
|
|
354
302
|
const mustRenderForNonce = !isRsc && cspNonce(c) !== undefined;
|
|
355
303
|
if (!mustRenderForNonce) {
|
|
356
304
|
const page = await runtime.readPrerendered(c, isRsc ? 'flight' : 'html');
|
|
357
|
-
//
|
|
358
|
-
//
|
|
359
|
-
//
|
|
360
|
-
//
|
|
361
|
-
// Answered outside `runWithContext`: no app code runs on this path, so there is no
|
|
362
|
-
// `getRequestContext()` to serve and no reason to pay for the AsyncLocalStorage scope.
|
|
305
|
+
// Request-independent by construction, so it is safe to cache publicly; the ETag turns the
|
|
306
|
+
// revalidation that follows into a 304. Answered outside `runWithContext` — no app code runs
|
|
307
|
+
// on this path, so there is no `getRequestContext()` to serve.
|
|
363
308
|
if (page !== null) {
|
|
364
309
|
const headers = {
|
|
365
310
|
'cache-control': SSG_CACHE_CONTROL,
|
|
@@ -387,6 +332,9 @@ function buildApp() {
|
|
|
387
332
|
const loadEndpoint = once(() => route.server());
|
|
388
333
|
const handler = async (c, next) => {
|
|
389
334
|
const { handler: endpointHandler } = await loadEndpoint();
|
|
335
|
+
// Hono's `Handler` leaves its return parameter defaulted to `any`, so this hands back exactly what
|
|
336
|
+
// the app's own handler is declared to return — there is nothing narrower to assert here.
|
|
337
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
390
338
|
return endpointHandler(c, next);
|
|
391
339
|
};
|
|
392
340
|
const method = route.method ?? 'all';
|
|
@@ -408,12 +356,10 @@ function buildApp() {
|
|
|
408
356
|
app.onError(async (error, c) => {
|
|
409
357
|
if (isControlSignal(error))
|
|
410
358
|
return runWithContext(c, () => respondToControlSignal(c, error));
|
|
411
|
-
// Registering an `onError`
|
|
412
|
-
//
|
|
413
|
-
//
|
|
414
|
-
//
|
|
415
|
-
// Rebuilt through `c` rather than returned as-is, exactly as Hono's own default does, so headers
|
|
416
|
-
// already prepared on the context (`c.header(…)` from middleware that ran first) survive.
|
|
359
|
+
// Registering an `onError` replaces Hono's default handler, which is what turns an `HTTPException`
|
|
360
|
+
// into the response it carries — without this, `csrf()`'s 403 and `bodyLimit()`'s 413 would both
|
|
361
|
+
// surface as a 500 error page. Rebuilt through `c`, as Hono's default does, so headers middleware
|
|
362
|
+
// already prepared survive.
|
|
417
363
|
if (error instanceof HTTPException) {
|
|
418
364
|
const res = error.getResponse();
|
|
419
365
|
return c.newResponse(res.body, res);
|
|
@@ -441,12 +387,11 @@ function buildApp() {
|
|
|
441
387
|
}
|
|
442
388
|
export const app = buildApp();
|
|
443
389
|
/**
|
|
444
|
-
* The app, handed to whatever is hosting it
|
|
390
|
+
* The app, handed to whatever is hosting it: this binds a port and exports nothing where rshono owns the
|
|
391
|
+
* process, and *is* the export the platform looks for where the host owns it — so one entry serves both.
|
|
445
392
|
*
|
|
446
|
-
*
|
|
447
|
-
*
|
|
448
|
-
* both without a per-platform entry file. `app` and `routes` stay named exports either way, because
|
|
449
|
-
* `rshono build` imports them to prerender `render: 'static'` routes.
|
|
393
|
+
* `app` and `routes` stay named exports either way, because `rshono build` imports them to prerender
|
|
394
|
+
* `render: 'static'` routes.
|
|
450
395
|
*/
|
|
451
396
|
export default runtime.serveApp(app);
|
|
452
397
|
//# sourceMappingURL=entry.rsc.js.map
|
|
@@ -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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CAAC,CAAC,CAAC,SAAS;iBACxD;gBACH,CAAC,CAAC,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC;YACzC,IAAI,CAAC;gBACH,OAAO,MAAM,cAAc,CAAC,CAAC,EAAE,KAAK,IAAI,EAAE,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,CA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,SAAS;iBACxD;gBACH,CAAC,CAAC,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC;YACzC,IAAI,CAAC;gBACH,OAAO,MAAM,cAAc,CAAC,CAAC,EAAE,KAAK,IAAI,EAAE,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;;;;;;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"}
|