@rshono/core 1.0.0-rc.20 → 1.0.0-rc.22
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 +5 -2
- package/dist/runtime/entry.client.js +330 -46
- package/dist/runtime/entry.client.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -322,8 +322,11 @@ Every target streams, which is the bar a new one has to clear.
|
|
|
322
322
|
- **Soft navigation needs the [Navigation API](https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API)**
|
|
323
323
|
— Chrome/Edge 135, Firefox 147, Safari 26.2, [Baseline](https://web.dev/blog/baseline-navigation-api) since
|
|
324
324
|
January 2026. Where it is missing there is no interception at all and every link is a real browser load,
|
|
325
|
-
which a server-rendered app answers correctly; only the soft part is gone.
|
|
326
|
-
|
|
325
|
+
which a server-rendered app answers correctly; only the soft part is gone. On a soft navigation the runtime
|
|
326
|
+
owns the scroll: a push reaches the top or its fragment, a traversal returns to where the entry was left,
|
|
327
|
+
and focus resets — `history.scrollRestoration` is `manual` for the document and positions are kept per
|
|
328
|
+
entry, in `sessionStorage` too, so a reload lands where the last document was left. A same-page fragment
|
|
329
|
+
stays the browser's, since it never changes the payload.
|
|
327
330
|
- **`redirect()` and `notFound()` must be reached before the page shell is sent.** A page streams: the status
|
|
328
331
|
line and the first bytes go out as soon as the shell is ready, and HTTP has no take-backs after that. Called
|
|
329
332
|
from a `<Suspense>` boundary that resolves later, the signal can no longer be a 3xx or a 404 — the response
|
|
@@ -40,6 +40,12 @@ const flightStream = readFlightPayload();
|
|
|
40
40
|
* never sees. Two URLs that differ only by `#hash` describe the same payload.
|
|
41
41
|
*/
|
|
42
42
|
const documentUrl = () => location.pathname + location.search;
|
|
43
|
+
/**
|
|
44
|
+
* The document URL the payload on screen was rendered for — see {@link documentUrl}. A fragment-only
|
|
45
|
+
* traversal leaves it unchanged, which is how the `popstate` listener knows there is nothing to fetch.
|
|
46
|
+
* Updated in the layout effect that commits a payload.
|
|
47
|
+
*/
|
|
48
|
+
let renderedUrl = documentUrl();
|
|
43
49
|
/** Guarantees somewhere to attach the fatal overlay: the root container is `document`, so a teardown can take `<body>` with it. */
|
|
44
50
|
function overlayHost() {
|
|
45
51
|
if (!document.documentElement)
|
|
@@ -101,7 +107,7 @@ function showFatal(error, componentStack) {
|
|
|
101
107
|
reload.textContent = 'Reload page';
|
|
102
108
|
reload.style.cssText =
|
|
103
109
|
'margin-top:1.25rem;padding:0.5rem 1rem;font:inherit;color:#18181b;background:#f4f4f5;border:0;border-radius:4px;cursor:pointer';
|
|
104
|
-
reload.addEventListener('click', () =>
|
|
110
|
+
reload.addEventListener('click', () => loadDocument());
|
|
105
111
|
box.appendChild(reload);
|
|
106
112
|
});
|
|
107
113
|
}
|
|
@@ -168,6 +174,101 @@ function requestPayload(href, signal) {
|
|
|
168
174
|
* would take the whole client runtime down with it rather than degrading anything.
|
|
169
175
|
*/
|
|
170
176
|
const canSoftNavigate = typeof navigation !== 'undefined' && typeof NavigateEvent !== 'undefined' && 'sourceElement' in NavigateEvent.prototype;
|
|
177
|
+
/**
|
|
178
|
+
* The runtime owns a soft navigation's scroll, so the browser's own restoration has to be off: left on, a
|
|
179
|
+
* traversal restores the destination's offset against the outgoing tree before the payload for that entry
|
|
180
|
+
* has even been asked for, and the incoming tree overwrites it. `manual` only concerns the entries this
|
|
181
|
+
* document creates — a navigation to another document creates its own entry `auto` — and it also turns the
|
|
182
|
+
* browser's reload restoration off, which {@link readStoredScrollPositions} and the first layout effect put
|
|
183
|
+
* back.
|
|
184
|
+
*
|
|
185
|
+
* Gated on the soft router: below the Navigation API floor every navigation is a real document load, which
|
|
186
|
+
* a server-rendered app answers correctly and the browser restores correctly, and taking that over without
|
|
187
|
+
* a router to repaint the entry would strand the visitor at the top.
|
|
188
|
+
*/
|
|
189
|
+
if (canSoftNavigate) {
|
|
190
|
+
try {
|
|
191
|
+
history.scrollRestoration = 'manual';
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
// A preference, not a requirement: where it cannot be set, the browser's restoration and the runtime's
|
|
195
|
+
// own can race on a traversal, and the runtime's runs at commit, after.
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Where each history entry of this document was left, keyed by its Navigation API key. In memory for the
|
|
200
|
+
* document's life; {@link persistScrollPositions} also writes it to `sessionStorage` so a reload — which
|
|
201
|
+
* the `manual` mode above stops the browser restoring — lands where the last document was left.
|
|
202
|
+
*/
|
|
203
|
+
const scrollPositions = new Map();
|
|
204
|
+
/** The `sessionStorage` key holding {@link scrollPositions}. */
|
|
205
|
+
const SCROLL_STORAGE_KEY = 'rshono:scroll';
|
|
206
|
+
/** How many entries are kept in that snapshot; the oldest falls out first — `Map` iteration order. */
|
|
207
|
+
const SCROLL_STORAGE_LIMIT = 50;
|
|
208
|
+
/** The key of the history entry being shown, or `undefined` where the soft router does not exist. */
|
|
209
|
+
function currentEntryKey() {
|
|
210
|
+
return canSoftNavigate ? navigation.currentEntry?.key : undefined;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Records where the outgoing entry is being left. Read at `navigate` time — before the browser commits the
|
|
214
|
+
* new entry — and at `pagehide`, so whatever the navigation turns out to be, the entry it leaves has a
|
|
215
|
+
* position to come back to.
|
|
216
|
+
*/
|
|
217
|
+
function rememberCurrentScroll() {
|
|
218
|
+
const key = currentEntryKey();
|
|
219
|
+
if (key)
|
|
220
|
+
scrollPositions.set(key, { x: window.scrollX, y: window.scrollY });
|
|
221
|
+
}
|
|
222
|
+
/** The position `key` was left at, or `undefined` when this document never saw it. */
|
|
223
|
+
function scrollPointFor(key) {
|
|
224
|
+
return key === undefined ? undefined : scrollPositions.get(key);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Reads the last document's snapshot back into {@link scrollPositions}. Called once, on startup, before the
|
|
228
|
+
* first payload commits: the in-memory map alone would lose every entry the moment the document is replaced.
|
|
229
|
+
*/
|
|
230
|
+
function readStoredScrollPositions() {
|
|
231
|
+
try {
|
|
232
|
+
const raw = sessionStorage.getItem(SCROLL_STORAGE_KEY);
|
|
233
|
+
if (!raw)
|
|
234
|
+
return;
|
|
235
|
+
for (const [key, point] of Object.entries(JSON.parse(raw))) {
|
|
236
|
+
if (Number.isFinite(point?.x) && Number.isFinite(point?.y))
|
|
237
|
+
scrollPositions.set(key, point);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
catch {
|
|
241
|
+
// Blocked site data, or a snapshot written by a different version. Either way there is nothing to restore,
|
|
242
|
+
// and the page is still correct without it.
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
/** Writes {@link scrollPositions} out, oldest first, bounded — see {@link SCROLL_STORAGE_LIMIT}. */
|
|
246
|
+
function persistScrollPositions() {
|
|
247
|
+
try {
|
|
248
|
+
while (scrollPositions.size > SCROLL_STORAGE_LIMIT) {
|
|
249
|
+
const oldest = scrollPositions.keys().next().value;
|
|
250
|
+
if (oldest === undefined)
|
|
251
|
+
break;
|
|
252
|
+
scrollPositions.delete(oldest);
|
|
253
|
+
}
|
|
254
|
+
sessionStorage.setItem(SCROLL_STORAGE_KEY, JSON.stringify(Object.fromEntries(scrollPositions)));
|
|
255
|
+
}
|
|
256
|
+
catch {
|
|
257
|
+
// Blocked site data: the in-memory map still carries this document's navigations.
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* The snapshot starts with the document, not with hydration: the page is visible and clickable while the
|
|
262
|
+
* initial payload streams, and a reload or a navigation away in that window would otherwise lose the offset
|
|
263
|
+
* now that `manual` has stopped the browser restoring it. Nothing here depends on the router being mounted,
|
|
264
|
+
* so it does not wait for {@link listenNavigation}.
|
|
265
|
+
*/
|
|
266
|
+
if (canSoftNavigate) {
|
|
267
|
+
window.addEventListener('pagehide', () => {
|
|
268
|
+
rememberCurrentScroll();
|
|
269
|
+
persistScrollPositions();
|
|
270
|
+
});
|
|
271
|
+
}
|
|
171
272
|
/**
|
|
172
273
|
* Drops a navigation's result promises. Both reject when a navigation is superseded or cancelled — routine
|
|
173
274
|
* here, since a second click is meant to abandon the first — and unhandled they would be reported as faults.
|
|
@@ -177,26 +278,36 @@ function settle(result) {
|
|
|
177
278
|
void result.committed?.catch(ignore);
|
|
178
279
|
void result.finished?.catch(ignore);
|
|
179
280
|
}
|
|
180
|
-
/**
|
|
181
|
-
|
|
281
|
+
/**
|
|
282
|
+
* The mark {@link loadDocument} puts on its navigations, so the `navigate` listener below recognizes them as
|
|
283
|
+
* the runtime's own. A symbol because the identity has to survive the trip through the browser intact:
|
|
284
|
+
* `NavigateEvent.info` hands the value back by reference, so only the navigation that was given it matches.
|
|
285
|
+
*/
|
|
286
|
+
const documentNavigation = Symbol('rshono:document-navigation');
|
|
182
287
|
/**
|
|
183
288
|
* Performs a navigation the router below must **not** intercept, and returns having asked for it.
|
|
184
289
|
*
|
|
185
|
-
* `
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
* soft load would render into is the thing that just failed, or is about to be torn down. Intercepted, the
|
|
290
|
+
* `listenNavigation` intercepts a `reload` on purpose — that is what `router.refresh()` is — and every caller
|
|
291
|
+
* here is reaching for a *new document* precisely because the current one cannot be repaired: the React root
|
|
292
|
+
* a soft load would render into is the thing that just failed, or is about to be torn down. Intercepted, the
|
|
189
293
|
* escape hatch becomes a payload fetch that lands nowhere — which is how a late `notFound()` left the tab on
|
|
190
294
|
* its Suspense fallback with no second document ever arriving, and how a late `redirect()` moved the address
|
|
191
295
|
* bar to a page it then failed to render.
|
|
192
296
|
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
297
|
+
* The mark rides the navigation itself, through `info`, so the listener recognizes the event that owns it
|
|
298
|
+
* instead of consuming a flag set in advance. There is no state to clear and none to leak: a navigation the
|
|
299
|
+
* browser refuses cannot make the next one a full load. Below the Navigation API there is no interception to
|
|
300
|
+
* opt out of, and `location.*` is already a document load.
|
|
196
301
|
*/
|
|
197
|
-
function
|
|
198
|
-
|
|
199
|
-
|
|
302
|
+
function loadDocument(href) {
|
|
303
|
+
if (!canSoftNavigate) {
|
|
304
|
+
if (href === undefined)
|
|
305
|
+
window.location.reload();
|
|
306
|
+
else
|
|
307
|
+
window.location.assign(href);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
settle(href === undefined ? navigation.reload({ info: documentNavigation }) : navigation.navigate(href, { info: documentNavigation }));
|
|
200
311
|
}
|
|
201
312
|
// The imperative actions behind `useNavigation().router`. Each one only *asks*: the browser turns it into a
|
|
202
313
|
// `navigate` event, which is where `listenNavigation` answers it — so a `router.push` and a link click reach
|
|
@@ -272,7 +383,7 @@ function reloadOnceForLateNotFound() {
|
|
|
272
383
|
showLateNotFound();
|
|
273
384
|
return;
|
|
274
385
|
}
|
|
275
|
-
|
|
386
|
+
loadDocument();
|
|
276
387
|
// The reload wins this race whenever it happens at all: the document goes away and takes the timer with
|
|
277
388
|
// it. What this covers is a reload that does not happen — swallowed by an interceptor, refused by the
|
|
278
389
|
// browser, held by a `beforeunload` — which used to leave the visitor on a Suspense fallback with nothing
|
|
@@ -298,17 +409,79 @@ function handleControlDigest(error, { hard = false } = {}) {
|
|
|
298
409
|
reloadOnceForLateNotFound();
|
|
299
410
|
}
|
|
300
411
|
else if (hard) {
|
|
301
|
-
|
|
412
|
+
// The URL is resolved first: a malformed location then throws here, before any navigation is asked for.
|
|
413
|
+
loadDocument(new URL(redirect.location, window.location.href).href);
|
|
302
414
|
}
|
|
303
415
|
else {
|
|
304
416
|
push(redirect.location);
|
|
305
417
|
}
|
|
306
418
|
return true;
|
|
307
419
|
}
|
|
420
|
+
/**
|
|
421
|
+
* Scrolls the document to its start.
|
|
422
|
+
*
|
|
423
|
+
* The options form rather than `scrollTo(0, 0)`: the two-argument call is `auto`, which follows a
|
|
424
|
+
* `scroll-behavior` the app may have set on `html`, and a soft navigation that animates its own reset reads
|
|
425
|
+
* as a glitch rather than a page change.
|
|
426
|
+
*/
|
|
427
|
+
function scrollToTop() {
|
|
428
|
+
window.scrollTo({ top: 0, left: 0, behavior: 'instant' });
|
|
429
|
+
}
|
|
430
|
+
/** Puts a saved offset back. Instant for the same reason {@link scrollToTop} passes it. */
|
|
431
|
+
function scrollToPoint(point) {
|
|
432
|
+
window.scrollTo({ top: point.y, left: point.x, behavior: 'instant' });
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Scrolls to a fragment's target the way the browser's own fragment jump does.
|
|
436
|
+
*
|
|
437
|
+
* `scrollIntoView` is the algorithm that honours `scroll-padding-top` on the scrolling box and
|
|
438
|
+
* `scroll-margin-top` on the target, which `window.scrollTo` does not. The lookup follows the browser's
|
|
439
|
+
* "find a potential indicated element": the id first, then the name. A malformed percent-escape falls back
|
|
440
|
+
* to the literal fragment, and a fragment nothing matches gets the top of the document — what a browser
|
|
441
|
+
* gives a missing anchor on a real load.
|
|
442
|
+
*/
|
|
443
|
+
function jumpToAnchor(hash) {
|
|
444
|
+
const raw = hash.startsWith('#') ? hash.slice(1) : hash;
|
|
445
|
+
// No special case for `#top`: the browser only treats it as the top of the document when no element
|
|
446
|
+
// matches, and the fallback below is that top.
|
|
447
|
+
if (raw === '') {
|
|
448
|
+
scrollToTop();
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
let id = raw;
|
|
452
|
+
try {
|
|
453
|
+
id = decodeURIComponent(raw);
|
|
454
|
+
}
|
|
455
|
+
catch {
|
|
456
|
+
// Malformed escape — the literal fragment is the better guess at the id than nothing.
|
|
457
|
+
}
|
|
458
|
+
const target = document.getElementById(id) ?? document.getElementsByName(id)[0];
|
|
459
|
+
if (target)
|
|
460
|
+
target.scrollIntoView();
|
|
461
|
+
else
|
|
462
|
+
scrollToTop();
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Moves focus the way the browser's `focusReset: 'after-transition'` does: the first `autofocus` element,
|
|
466
|
+
* else the document body. A traversal is no longer intercepted, so the browser performs no focus reset for
|
|
467
|
+
* it; without this, Back would leave focus on the link that was clicked on the page being left, and the next
|
|
468
|
+
* Tab would resume there. `preventScroll` because the traversal's own offset has just been restored.
|
|
469
|
+
*/
|
|
470
|
+
function resetFocus() {
|
|
471
|
+
const autofocus = document.querySelector('[autofocus]');
|
|
472
|
+
if (autofocus)
|
|
473
|
+
autofocus.focus({ preventScroll: true });
|
|
474
|
+
else
|
|
475
|
+
document.body.focus({ preventScroll: true });
|
|
476
|
+
}
|
|
308
477
|
/**
|
|
309
478
|
* Puts a payload on screen, resolving once React has committed it. Replaced by `BrowserRoot`'s own on mount;
|
|
310
479
|
* the default covers the window before hydration, where `setServerCallback` is already registered but there
|
|
311
480
|
* is no root to update — a reload is the honest answer, and nothing after it needs to run.
|
|
481
|
+
*
|
|
482
|
+
* `afterCommit`, when given, runs in the same layout effect that releases the commit: after the new tree is
|
|
483
|
+
* in the DOM and before the browser paints, which is the only moment a `#hash` target exists and the
|
|
484
|
+
* pre-scroll position has not been shown.
|
|
312
485
|
*/
|
|
313
486
|
let setPayload = () => {
|
|
314
487
|
window.location.reload();
|
|
@@ -318,31 +491,48 @@ let setPayload = () => {
|
|
|
318
491
|
let startNav = (run) => {
|
|
319
492
|
void run();
|
|
320
493
|
};
|
|
494
|
+
/**
|
|
495
|
+
* The navigation whose payload is allowed to settle the screen. React runs async work concurrently, so two
|
|
496
|
+
* navigations are two live fetches with no ordering between them; without this a slow first response landing
|
|
497
|
+
* after a fast second one repaints the page the user already left. The Navigation API aborts an intercepted
|
|
498
|
+
* navigation when a newer one starts, but a traversal has no `event.signal` to watch — `popstate` arrives
|
|
499
|
+
* after the browser has already committed it — so ordering is the runtime's own for those.
|
|
500
|
+
*/
|
|
501
|
+
let currentNavigation = 0;
|
|
502
|
+
/** The in-flight navigation's fetch, so a newer one can stop paying for it. */
|
|
503
|
+
let navigationFetch = null;
|
|
321
504
|
/**
|
|
322
505
|
* Fetches the payload for `url` and puts it on screen.
|
|
323
506
|
*
|
|
324
|
-
* Resolves once React has **committed** it rather than when the fetch lands:
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
507
|
+
* Resolves once React has **committed** it rather than when the fetch lands: `afterCommit` runs at that
|
|
508
|
+
* point, and a `#hash` target does not exist until the new tree does. Rejects only on a genuine failure —
|
|
509
|
+
* being superseded is not one, and resolves quietly, because the navigation that replaced this one owns the
|
|
510
|
+
* screen from then on.
|
|
328
511
|
*/
|
|
329
|
-
function loadPayload(url, signal) {
|
|
512
|
+
function loadPayload(url, signal, afterCommit) {
|
|
513
|
+
// This navigation's place in the queue, and its own abort switch: a fetch is abandoned by whichever comes
|
|
514
|
+
// first, the browser superseding it (an intercepted navigation carries `event.signal`) or a newer runtime
|
|
515
|
+
// fetch starting (a traversal, an action, a dev refresh).
|
|
516
|
+
const navigation = ++currentNavigation;
|
|
517
|
+
navigationFetch?.abort();
|
|
518
|
+
const controller = (navigationFetch = new AbortController());
|
|
519
|
+
const abort = signal ? AbortSignal.any([signal, controller.signal]) : controller.signal;
|
|
330
520
|
// Deliberately not awaited inside the transition: the scope ends once the payload is handed to React, and
|
|
331
521
|
// React holds `pending` until the update it scheduled commits. Awaiting the commit *inside* the scope would
|
|
332
522
|
// work too, but only because React happens not to gate a commit on its async scope settling — an internal
|
|
333
523
|
// this has no reason to depend on across the whole `^19.1.0` peer range.
|
|
334
524
|
let committed;
|
|
335
525
|
const run = async () => {
|
|
336
|
-
const payload = await requestPayload(url,
|
|
337
|
-
//
|
|
338
|
-
//
|
|
339
|
-
if (
|
|
526
|
+
const payload = await requestPayload(url, abort);
|
|
527
|
+
// Checked again after the await because the fetch may already have resolved by then, and applying it
|
|
528
|
+
// would repaint a page the user has left.
|
|
529
|
+
if (abort.aborted || navigation !== currentNavigation)
|
|
340
530
|
return;
|
|
341
531
|
if (payload.redirect) {
|
|
342
532
|
push(payload.redirect);
|
|
343
533
|
return;
|
|
344
534
|
}
|
|
345
|
-
committed = setPayload(payload);
|
|
535
|
+
committed = setPayload(payload, afterCommit);
|
|
346
536
|
};
|
|
347
537
|
// `startTransition` runs the work but hands nothing back, so the promise carrying a failure is caught here
|
|
348
538
|
// instead. Assigned synchronously: React invokes the callback before `startNav` returns.
|
|
@@ -353,11 +543,28 @@ function loadPayload(url, signal) {
|
|
|
353
543
|
() => committed, (error) => {
|
|
354
544
|
// Checked before the error is read: an abort is this navigation being replaced, and the one that
|
|
355
545
|
// replaced it owns the outcome.
|
|
356
|
-
if (
|
|
546
|
+
if (abort.aborted || navigation !== currentNavigation || handleControlDigest(error))
|
|
357
547
|
return;
|
|
358
548
|
throw error;
|
|
359
549
|
});
|
|
360
550
|
}
|
|
551
|
+
/**
|
|
552
|
+
* Whether a destination names a file rather than a page. `public/`, `/_static` and an endpoint route that
|
|
553
|
+
* serves a document (`/llms.txt`, `/sitemap.xml`) answer an RSC fetch with the file itself, not a flight
|
|
554
|
+
* payload — so intercepting one buys nothing: the payload never arrives, and the only recovery left is the
|
|
555
|
+
* document load the browser would have made directly. Handing it that navigation up front also gives the
|
|
556
|
+
* entry the file loads into the browser's own history, so Back is an ordinary cross-document traversal. An
|
|
557
|
+
* intercepted entry is same-document by construction, and traversing one with nothing to repaint it changes
|
|
558
|
+
* the URL and nothing else — which is what a Back press out of an opened file was doing.
|
|
559
|
+
*
|
|
560
|
+
* A dot in the last path segment rather than a list of extensions: a list is never complete, and every miss
|
|
561
|
+
* is the failed round trip above. A page route whose last segment carries a dot (`/release-1.0`) therefore
|
|
562
|
+
* costs a document load — the direction to err in, and what a `data-native` link already asks for by hand.
|
|
563
|
+
*/
|
|
564
|
+
function namesAFile(href) {
|
|
565
|
+
const lastSegment = new URL(href).pathname.split('/').pop() ?? '';
|
|
566
|
+
return lastSegment.includes('.');
|
|
567
|
+
}
|
|
361
568
|
/**
|
|
362
569
|
* Navigations the browser can hand over but shouldn't:
|
|
363
570
|
*
|
|
@@ -366,10 +573,15 @@ function loadPayload(url, signal) {
|
|
|
366
573
|
* - a download, which is not a navigation of this page at all;
|
|
367
574
|
* - a `POST` form, which is a submission and the server's to answer (a `GET` form carries its fields in the
|
|
368
575
|
* URL, has no `formData`, and soft-navigates like any other link);
|
|
369
|
-
* - a link marked `data-native`, the documented opt-out
|
|
576
|
+
* - a link marked `data-native`, the documented opt-out;
|
|
577
|
+
* - a destination that names a file — see {@link namesAFile}.
|
|
370
578
|
*/
|
|
371
579
|
function leaveToBrowser(event) {
|
|
372
|
-
return event.hashChange ||
|
|
580
|
+
return (event.hashChange ||
|
|
581
|
+
event.downloadRequest !== null ||
|
|
582
|
+
event.formData !== null ||
|
|
583
|
+
event.sourceElement?.hasAttribute('data-native') === true ||
|
|
584
|
+
namesAFile(event.destination.url));
|
|
373
585
|
}
|
|
374
586
|
/**
|
|
375
587
|
* The whole router, in one listener.
|
|
@@ -384,29 +596,81 @@ function listenNavigation() {
|
|
|
384
596
|
if (!canSoftNavigate)
|
|
385
597
|
return () => { };
|
|
386
598
|
const onNavigate = (event) => {
|
|
387
|
-
//
|
|
388
|
-
//
|
|
389
|
-
|
|
390
|
-
|
|
599
|
+
// A document navigation the runtime asked for itself, marked through `info`. Checked before the scroll
|
|
600
|
+
// snapshot: the document is going away, so where its entry was left does not matter, and an unrelated
|
|
601
|
+
// later navigation can never be mistaken for this one.
|
|
602
|
+
if (event.info === documentNavigation)
|
|
391
603
|
return;
|
|
392
|
-
|
|
604
|
+
// Whatever the browser is about to do with this navigation, the entry it is leaving is about to lose the
|
|
605
|
+
// offset it was at, and nothing else in this document will put it back. Saved before the branches below
|
|
606
|
+
// return, so a fragment the browser performs itself is covered too.
|
|
607
|
+
rememberCurrentScroll();
|
|
393
608
|
if (!event.canIntercept || leaveToBrowser(event))
|
|
394
609
|
return;
|
|
395
|
-
// A
|
|
396
|
-
//
|
|
397
|
-
//
|
|
398
|
-
//
|
|
610
|
+
// A traversal is repainted by the `popstate` listener below, not intercepted. `intercept`ing one is what
|
|
611
|
+
// makes WebKit stall the rendered viewport for about three seconds on a back swipe
|
|
612
|
+
// (bugs.webkit.org/319414): the view gesture's snapshot is only removed once the navigation finishes, and
|
|
613
|
+
// React's root attaches the wheel listener the bug also needs. Letting the traversal through means the
|
|
614
|
+
// browser commits the entry straight away, and the runtime puts the payload on screen when it arrives.
|
|
615
|
+
if (event.navigationType === 'traverse')
|
|
616
|
+
return;
|
|
617
|
+
// A replace or a refresh stays where it is, so neither should move. A push starts at the top of the
|
|
618
|
+
// page, or at its fragment — and that scroll is the runtime's own now: WebKit performs no
|
|
619
|
+
// `after-transition` reset at all for an intercepted push (bugs.webkit.org/304593). Chromium skips it
|
|
620
|
+
// too, and a fragment jump rides the same code path. Passing `manual` here makes the browser hand the
|
|
621
|
+
// handler over without scrolling; the `afterCommit` callback reaches the target once the new tree is on
|
|
622
|
+
// screen. Focus stays the browser's, reset after the transition.
|
|
399
623
|
const inPlace = event.navigationType === 'replace' || event.navigationType === 'reload';
|
|
624
|
+
let afterCommit;
|
|
625
|
+
if (event.navigationType === 'push') {
|
|
626
|
+
const { hash } = new URL(event.destination.url);
|
|
627
|
+
afterCommit = hash === '' ? scrollToTop : () => jumpToAnchor(hash);
|
|
628
|
+
}
|
|
400
629
|
event.intercept({
|
|
401
|
-
scroll:
|
|
630
|
+
scroll: 'manual',
|
|
402
631
|
focusReset: inPlace ? 'manual' : 'after-transition',
|
|
403
632
|
// The URL commits before the handler runs, so a failure leaves the address bar describing a page the
|
|
404
633
|
// document is not showing. A real load is the only way back to agreement.
|
|
405
|
-
handler: () => loadPayload(event.destination.url, event.signal).catch(() =>
|
|
634
|
+
handler: () => loadPayload(event.destination.url, event.signal, afterCommit).catch(() => loadDocument()),
|
|
406
635
|
});
|
|
407
636
|
};
|
|
637
|
+
/**
|
|
638
|
+
* Repaints a traversal the listener above deliberately left to the browser, and moves the viewport back
|
|
639
|
+
* where the entry was left. `popstate` fires after the browser has committed the entry, so the destination
|
|
640
|
+
* is `navigation.currentEntry` and its saved offset is in {@link scrollPositions}.
|
|
641
|
+
*/
|
|
642
|
+
const onPopState = () => {
|
|
643
|
+
const stored = scrollPointFor(currentEntryKey());
|
|
644
|
+
const hash = location.hash;
|
|
645
|
+
const apply = () => {
|
|
646
|
+
if (stored)
|
|
647
|
+
scrollToPoint(stored);
|
|
648
|
+
else if (hash !== '')
|
|
649
|
+
jumpToAnchor(hash);
|
|
650
|
+
else
|
|
651
|
+
scrollToTop();
|
|
652
|
+
};
|
|
653
|
+
// A fragment-only traversal never changed the payload: the address bar is back at an anchor of the page
|
|
654
|
+
// already on screen, so there is nothing to fetch and nothing to wait for. The browser's own restoration
|
|
655
|
+
// is off, so the offset comes from what `onNavigate` saved when the anchor was followed; no focus reset,
|
|
656
|
+
// which is what leaving those navigations to the browser has always meant.
|
|
657
|
+
if (documentUrl() === renderedUrl) {
|
|
658
|
+
apply();
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
void loadPayload(location.href, undefined, () => {
|
|
662
|
+
apply();
|
|
663
|
+
// The browser performs this for an intercepted navigation; a traversal is no longer intercepted, so
|
|
664
|
+
// without it Back would leave focus on the link that was clicked on the page being left.
|
|
665
|
+
resetFocus();
|
|
666
|
+
}).catch(() => loadDocument());
|
|
667
|
+
};
|
|
408
668
|
navigation.addEventListener('navigate', onNavigate);
|
|
409
|
-
|
|
669
|
+
window.addEventListener('popstate', onPopState);
|
|
670
|
+
return () => {
|
|
671
|
+
navigation.removeEventListener('navigate', onNavigate);
|
|
672
|
+
window.removeEventListener('popstate', onPopState);
|
|
673
|
+
};
|
|
410
674
|
}
|
|
411
675
|
async function main() {
|
|
412
676
|
// The assertion is load-bearing under the compiler that builds this: TypeScript 7 declares `nonce` on
|
|
@@ -433,26 +697,46 @@ async function main() {
|
|
|
433
697
|
// Blocked site data. `reloadOnceForLateNotFound` already treats that as the terminating case.
|
|
434
698
|
}
|
|
435
699
|
}
|
|
700
|
+
// Everything the last document saved, read before any payload commits: the in-memory map alone would not
|
|
701
|
+
// survive the reload that `history.scrollRestoration = 'manual'` just stopped the browser restoring. The
|
|
702
|
+
// entry's key is stable across a reload, and the offset is applied by `BrowserRoot`'s first layout effect,
|
|
703
|
+
// before the first paint of the new tree.
|
|
704
|
+
if (canSoftNavigate)
|
|
705
|
+
readStoredScrollPositions();
|
|
706
|
+
const restored = scrollPointFor(currentEntryKey());
|
|
436
707
|
function BrowserRoot() {
|
|
437
708
|
const [payload, setPayloadState] = React.useState(initialPayload);
|
|
438
709
|
const [pending, startTransition] = React.useTransition();
|
|
439
710
|
// The resolver the payload on screen still owes — see {@link loadPayload}.
|
|
440
711
|
const pendingCommit = React.useRef(null);
|
|
712
|
+
// The scroll the payload about to commit owes, set with it so a payload that supersedes another takes
|
|
713
|
+
// its predecessor's scroll out of the queue along with its commit. Initialised with the reload's offset:
|
|
714
|
+
// the first layout effect below applies it with the first payload, before the new tree is painted.
|
|
715
|
+
const pendingScroll = React.useRef(restored ? () => scrollToPoint(restored) : null);
|
|
441
716
|
React.useEffect(() => {
|
|
442
|
-
setPayload = (next) => new Promise((resolve) => {
|
|
717
|
+
setPayload = (next, afterCommit) => new Promise((resolve) => {
|
|
443
718
|
// A payload replaced before it ever painted still has a navigation waiting on it. React commits
|
|
444
719
|
// only the newest, so the effect below never runs for the one it skipped: release it here.
|
|
445
720
|
pendingCommit.current?.();
|
|
446
721
|
pendingCommit.current = resolve;
|
|
722
|
+
// Replaced rather than kept: a server action's payload carries no `afterCommit`, and the
|
|
723
|
+
// navigation it superseded must not scroll the page the action is about to replace it with.
|
|
724
|
+
pendingScroll.current = afterCommit ?? null;
|
|
447
725
|
setPayloadState(next);
|
|
448
726
|
});
|
|
449
727
|
startNav = (run) => startTransition(run);
|
|
450
728
|
}, [startTransition]);
|
|
451
729
|
/**
|
|
452
|
-
*
|
|
453
|
-
*
|
|
730
|
+
* Performs the pending scroll and releases the navigation waiting on this payload. A layout effect, so
|
|
731
|
+
* the new tree is in the DOM and the pre-scroll position is never painted.
|
|
454
732
|
*/
|
|
455
733
|
React.useLayoutEffect(() => {
|
|
734
|
+
const scroll = pendingScroll.current;
|
|
735
|
+
pendingScroll.current = null;
|
|
736
|
+
scroll?.();
|
|
737
|
+
// What the payload that just committed was rendered for — see {@link renderedUrl}. A redirect never
|
|
738
|
+
// reaches here, and an action or a dev refresh keeps the URL it was fetched for.
|
|
739
|
+
renderedUrl = documentUrl();
|
|
456
740
|
const commit = pendingCommit.current;
|
|
457
741
|
pendingCommit.current = null;
|
|
458
742
|
commit?.();
|
|
@@ -549,7 +833,7 @@ function initDevRefresh() {
|
|
|
549
833
|
let targetHash;
|
|
550
834
|
function reload(reason, error) {
|
|
551
835
|
console.warn(`[rshono] ${reason} — reloading`, ...(error === undefined ? [] : [error]));
|
|
552
|
-
|
|
836
|
+
loadDocument();
|
|
553
837
|
}
|
|
554
838
|
async function applyClientUpdate() {
|
|
555
839
|
const giveUp = await walkHotUpdates(hot, () => __webpack_hash__, () => targetHash);
|
|
@@ -562,7 +846,7 @@ function initDevRefresh() {
|
|
|
562
846
|
targetHash = message.hash ?? targetHash;
|
|
563
847
|
if (connectedOnce) {
|
|
564
848
|
await applyClientUpdate();
|
|
565
|
-
await loadPayload(window.location.href).catch(() =>
|
|
849
|
+
await loadPayload(window.location.href).catch(() => loadDocument());
|
|
566
850
|
}
|
|
567
851
|
connectedOnce = true;
|
|
568
852
|
break;
|
|
@@ -572,7 +856,7 @@ function initDevRefresh() {
|
|
|
572
856
|
break;
|
|
573
857
|
case 'rsc-update':
|
|
574
858
|
console.log('[rshono] server components updated');
|
|
575
|
-
await loadPayload(window.location.href).catch(() =>
|
|
859
|
+
await loadPayload(window.location.href).catch(() => loadDocument());
|
|
576
860
|
break;
|
|
577
861
|
}
|
|
578
862
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.client.js","sourceRoot":"","sources":["../../src/runtime/entry.client.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,eAAe,EACf,w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AC;gBACvG,MAAM;QACV,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,cAAc,CAAC,CAAC;IAC/C,yGAAyG;IACzG,0GAA0G;IAC1G,qEAAqE;IACrE,IAAI,KAAK,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7C,MAAM,CAAC,SAAS,GAAG,CAAC,KAA2B,EAAE,EAAE;QACjD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAe,CAAC;QACrD,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC,CAAC;IACrG,CAAC,CAAC;AACJ,CAAC;AAED,mGAAmG;AACnG,kFAAkF;AAClF,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,8CAA8C,EAAE,KAAK,CAAC,CAAC;IACrE,SAAS,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { hydrateRoot } from 'react-dom/client';\nimport {\n createFromFetch,\n createFromReadableStream,\n createTemporaryReferenceSet,\n encodeReply,\n setServerCallback,\n} from 'react-server-dom-rspack/client.browser';\nimport { isControlDigest, parseRedirectDigest } from './control.js';\nimport type { DevMessage } from './dev-protocol.js';\nimport type { RscPayload } from './entry.rsc.js';\n// Dev-only: its one caller sits behind `import.meta.webpackHot`, which a production build compiles to\n// `false` — so this module is dropped there.\nimport { walkHotUpdates } from './hot-update.js';\nimport { RouterContext, type NavigationRouter } from './navigation.js';\nimport { createRscRequest } from './request.js';\n\nconst isDev = process.env.NODE_ENV === 'development';\n\ndeclare global {\n /** The array the payload `<script>` tags `flight-inject.ts` emits push their chunks into. */\n var __FLIGHT_DATA: Array<string | Uint8Array> | undefined;\n}\n\n/** The flight payload the document carried, read back out of `__FLIGHT_DATA` — see `flight-inject.ts`. */\nfunction readFlightPayload(): ReadableStream<Uint8Array> {\n const encoder = new TextEncoder();\n // Assigned synchronously by `start`, which `new ReadableStream` runs before it returns.\n let controller!: ReadableStreamDefaultController<Uint8Array>;\n const stream = new ReadableStream<Uint8Array>({\n start: (c) => void (controller = c),\n });\n const enqueue = (chunk: string | Uint8Array) => controller.enqueue(typeof chunk === 'string' ? encoder.encode(chunk) : chunk);\n\n // Payload scripts interleave with the document: the ones that already ran are in the array, the rest\n // arrive through `push`.\n const data = (self.__FLIGHT_DATA ??= []);\n for (const chunk of data) enqueue(chunk);\n data.push = enqueue as typeof data.push;\n\n // The last payload script lands before parsing finishes, so that is what closes the stream.\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', () => controller.close(), { once: true });\n } else {\n controller.close();\n }\n return stream;\n}\n\n/** Created at module evaluation, not inside `main()`, so no chunk can be pushed before it is watching. */\nconst flightStream = readFlightPayload();\n\n/**\n * The part of the location a payload is rendered for — the document, without the fragment, which the server\n * never sees. Two URLs that differ only by `#hash` describe the same payload.\n */\nconst documentUrl = (): string => location.pathname + location.search;\n\n/** Guarantees somewhere to attach the fatal overlay: the root container is `document`, so a teardown can take `<body>` with it. */\nfunction overlayHost(): HTMLElement {\n if (!document.documentElement) document.appendChild(document.createElement('html'));\n if (!document.body) document.documentElement.appendChild(document.createElement('body'));\n return document.body;\n}\n\n/**\n * Paints a full-viewport panel over whatever is on screen, and returns the box for the caller to fill.\n *\n * DOM calls rather than React (one caller runs because the renderer just failed), and `textContent` rather\n * than `innerHTML` (an error message is untrusted input). Queued on a macrotask: React's teardown runs after\n * the callback that reaches here returns, and would remove a node appended inline.\n */\nfunction paintOverlay(fill: (box: HTMLElement) => void): void {\n setTimeout(() => {\n const host = overlayHost();\n host.querySelector('[data-rshono-fatal]')?.remove();\n\n const box = document.createElement('div');\n box.setAttribute('data-rshono-fatal', '');\n box.setAttribute('role', 'alert');\n box.style.cssText =\n 'position:fixed;inset:0;z-index:2147483647;overflow:auto;padding:1.5rem;background:#18181b;color:#f4f4f5;' +\n 'font:14px/1.6 ui-monospace,SFMono-Regular,Menlo,monospace;text-align:left';\n\n fill(box);\n host.appendChild(box);\n }, 0);\n}\n\n/** The overlay's heading. */\nfunction overlayTitle(text: string): HTMLElement {\n const title = document.createElement('div');\n title.textContent = text;\n title.style.cssText = 'font-size:1.0625rem;font-weight:700;color:#f87171;margin:0 0 0.75rem';\n return title;\n}\n\n/**\n * Paints the reason for an uncaught render error over the blank page it leaves behind — the full stack in\n * dev, a generic notice and a reload button in production.\n */\nfunction showFatal(error: unknown, componentStack?: string | null): void {\n paintOverlay((box) => {\n box.appendChild(overlayTitle(isDev ? 'Unhandled error' : 'Something went wrong'));\n\n if (isDev) {\n const detail = document.createElement('pre');\n detail.style.cssText = 'margin:0;white-space:pre-wrap;word-break:break-word';\n detail.textContent =\n (error instanceof Error ? (error.stack ?? `${error.name}: ${error.message}`) : String(error)) +\n (componentStack ? `\\n\\nComponent stack:${componentStack}` : '');\n box.appendChild(detail);\n } else {\n const message = document.createElement('p');\n message.textContent = 'This page hit an unexpected error and can’t continue.';\n message.style.cssText = 'margin:0 0 1rem;color:#d4d4d8';\n box.appendChild(message);\n }\n\n const reload = document.createElement('button');\n reload.textContent = 'Reload page';\n reload.style.cssText =\n 'margin-top:1.25rem;padding:0.5rem 1rem;font:inherit;color:#18181b;background:#f4f4f5;border:0;border-radius:4px;cursor:pointer';\n reload.addEventListener('click', () => loadOutsideRouter(() => window.location.reload()));\n box.appendChild(reload);\n });\n}\n\n/**\n * The end of the line for a `notFound()` that arrived too late to be a 404 and did not survive a reload.\n *\n * No reload button, unlike {@link showFatal}: the reload has already been spent, and the second identical\n * response is what brought us here. \"Page not found\" is what the server was trying to say, so it is what the\n * visitor is told; the reason it could not say it properly is a message for whoever wrote the page, and dev is\n * where they are.\n */\nfunction showLateNotFound(): void {\n paintOverlay((box) => {\n box.appendChild(overlayTitle('Page not found'));\n\n const message = document.createElement('p');\n message.textContent = isDev\n ? 'notFound() was raised from a boundary that resolved after the page shell had been sent, so the response ' +\n 'could not be a 404 — and reloading rendered the same page again. Decide before the render starts ' +\n 'streaming: in Hono middleware, or in the page component body above the boundary.'\n : 'This page is not available.';\n message.style.cssText = 'margin:0;color:#d4d4d8';\n box.appendChild(message);\n });\n}\n/** What every flight response is typed as. The charset and any other parameters follow it. */\nconst FLIGHT_CONTENT_TYPE = 'text/x-component';\n\n/**\n * Fetches a payload, refusing a response that is not one.\n *\n * The status cannot be the gate: a payload legitimately arrives as a 404 from the `notFound` page and as a\n * 500 from an action that threw, and both carry a real payload the caller has to see. The content type is.\n *\n * What this catches is the response that is not a payload at all — a `bodyLimit()` 413, a proxy's error page,\n * a 502 mid-deploy. Handed to the flight parser those all surface as `Error: Connection closed.`, with the\n * status and the body nowhere in sight; here they become an error that says what arrived.\n */\nasync function payloadResponse(request: Request): Promise<Response> {\n const response = await fetch(request);\n const contentType = response.headers.get('content-type');\n if (contentType?.startsWith(FLIGHT_CONTENT_TYPE)) return response;\n // Read for the message: a plain-text refusal says what it refused only in its body, and HTTP/2 has no\n // `statusText` at all. Bounded, because this is an error path and the body is not ours to trust.\n const body = await response.text().then(\n (text) => text.trim().slice(0, 200),\n () => '',\n );\n const status = `${response.status}${response.statusText ? ` ${response.statusText}` : ''}`;\n throw new Error(`[rshono] the server answered ${status} (${contentType ?? 'no content type'}) instead of a payload${body ? `: ${body}` : ''}`);\n}\n\n/**\n * Asks a URL for its flight payload. Deliberately uncached — a payload can never be staler than the click\n * that wanted it, and the browser's own HTTP cache is what makes a repeat visit cheap.\n */\nfunction requestPayload(href: string, signal?: AbortSignal): Promise<RscPayload> {\n return createFromFetch<RscPayload>(payloadResponse(createRscRequest(new URL(href, location.href).href, undefined, signal)));\n}\n\n/**\n * Whether the browser hands us its navigations. Gated on `sourceElement` rather than on `navigation` itself:\n * Chrome shipped the event in 102 and that property only in 135, and without it a `data-native` link cannot\n * be told from any other — so the older window would soft-navigate the very links that asked not to be.\n *\n * Where this is false there is no interception at all and every navigation is a real browser load, which a\n * server-rendered app answers correctly on its own. Only the soft part is missing.\n *\n * Both globals are tested, and neither is touched before: this runs at module scope, where a ReferenceError\n * would take the whole client runtime down with it rather than degrading anything.\n */\nconst canSoftNavigate = typeof navigation !== 'undefined' && typeof NavigateEvent !== 'undefined' && 'sourceElement' in NavigateEvent.prototype;\n\n/**\n * Drops a navigation's result promises. Both reject when a navigation is superseded or cancelled — routine\n * here, since a second click is meant to abandon the first — and unhandled they would be reported as faults.\n */\nfunction settle(result: NavigationResult): void {\n const ignore = () => {};\n void result.committed?.catch(ignore);\n void result.finished?.catch(ignore);\n}\n\n/** Set by {@link loadOutsideRouter}, read and cleared by the `navigate` listener. */\nlet bypassRouter = false;\n\n/**\n * Performs a navigation the router below must **not** intercept, and returns having asked for it.\n *\n * `location.reload()` and `location.assign()` fire a `navigate` event like any other navigation, and\n * `listenNavigation` intercepts a `reload` on purpose — that is what `router.refresh()` is. Every caller here\n * is reaching for a *new document* precisely because the current one cannot be repaired: the React root a\n * soft load would render into is the thing that just failed, or is about to be torn down. Intercepted, the\n * escape hatch becomes a payload fetch that lands nowhere — which is how a late `notFound()` left the tab on\n * its Suspense fallback with no second document ever arriving, and how a late `redirect()` moved the address\n * bar to a page it then failed to render.\n *\n * One-shot: the listener clears the flag on the next event it sees. If that event never comes — a navigation\n * the browser refuses — the cost is that the *next* navigation is a full load rather than a soft one, on a\n * document that was on its way out anyway.\n */\nfunction loadOutsideRouter(navigate: () => void): void {\n bypassRouter = true;\n navigate();\n}\n\n// The imperative actions behind `useNavigation().router`. Each one only *asks*: the browser turns it into a\n// `navigate` event, which is where `listenNavigation` answers it — so a `router.push` and a link click reach\n// the same code by the same route, and inherit the same fetch, scroll and `pending` flag.\nfunction push(href: string): void {\n if (canSoftNavigate) settle(navigation.navigate(href, { history: 'push' }));\n else window.location.assign(href);\n}\n\nfunction replace(href: string): void {\n if (canSoftNavigate) settle(navigation.navigate(href, { history: 'replace' }));\n else window.location.replace(href);\n}\n\n// A traversal is the browser's to perform either way — `navigation` only hands it back as an interceptable\n// event first. Nothing to go back to is a rejection there and a no-op here; both amount to the same thing.\nfunction back(): void {\n if (canSoftNavigate) settle(navigation.back());\n else window.history.back();\n}\n\nfunction forward(): void {\n if (canSoftNavigate) settle(navigation.forward());\n else window.history.forward();\n}\n\n// A refresh keeps the URL, and is still a navigation: it arrives as `navigationType: 'reload'`, which is what\n// tells the listener to leave scroll and focus where the user left them.\nfunction refresh(): void {\n if (canSoftNavigate) settle(navigation.reload());\n else window.location.reload();\n}\n\n/** How long the recovery reload is given to replace this document before the panel is painted instead. */\nconst RELOAD_GRACE_MS = 2000;\n\n/** The `sessionStorage` key bounding the recovery reload for one URL. Spent here, released in {@link main}. */\nconst lateNotFoundKey = (): string => `rshono:late-not-found:${documentUrl()}`;\n\n/**\n * Spends the one reload a late `notFound()` gets, or paints if it has already been spent for this URL.\n *\n * `redirect()` is terminal on the client — there is somewhere to navigate to — and `notFound()` is not: the\n * response is already committed as a 200, so the only recovery left is asking for the page again and hoping\n * the signal comes early enough this time to be a real 404. That works where the lateness was incidental, a\n * boundary that happened to resolve after the shell on a slow request. Where it is structural — a page that\n * always signals from a late boundary — the reload gets a byte-identical response and reloads again, and the\n * tab spins until the visitor leaves. In production nothing is logged, because the warning that explains this\n * is `isDev`-only.\n *\n * So it is bounded: one reload per URL per tab, then {@link showLateNotFound}. `sessionStorage` because the\n * value has to outlive the document it is written in and must not outlive the tab, and keyed by URL so a\n * second page's late signal still gets its own attempt.\n */\nfunction reloadOnceForLateNotFound(): void {\n const key = lateNotFoundKey();\n let spent: boolean;\n try {\n spent = sessionStorage.getItem(key) !== null;\n if (!spent) sessionStorage.setItem(key, '1');\n } catch {\n // Storage can throw outright where site data is blocked, and a page that cannot count its reloads has\n // to pick a side. It picks the terminating one: a message on a page that might have recovered is a\n // worse outcome than a reload loop only by a lot less.\n spent = true;\n }\n if (spent) {\n showLateNotFound();\n return;\n }\n\n loadOutsideRouter(() => window.location.reload());\n\n // The reload wins this race whenever it happens at all: the document goes away and takes the timer with\n // it. What this covers is a reload that does not happen — swallowed by an interceptor, refused by the\n // browser, held by a `beforeunload` — which used to leave the visitor on a Suspense fallback with nothing\n // coming and nothing said. The panel is the honest answer in that case too.\n setTimeout(() => {\n if (!document.querySelector('[data-rshono-fatal]')) showLateNotFound();\n }, RELOAD_GRACE_MS);\n}\n\n/**\n * Turns a control-signal digest — how `redirect()` / `notFound()` reach the browser — into a real\n * navigation. Returns false for anything else, so callers fall through to their own handling.\n *\n * `hard` forces a full document load, for signals that surfaced *through React*: it unmounts the root on\n * an uncaught error, leaving no live tree to soft-navigate with.\n */\nfunction handleControlDigest(error: unknown, { hard = false }: { hard?: boolean } = {}): boolean {\n const digest = (error as { digest?: unknown } | null)?.digest;\n if (!isControlDigest(digest)) return false;\n const redirect = parseRedirectDigest(digest);\n if (!redirect) {\n reloadOnceForLateNotFound();\n } else if (hard) {\n loadOutsideRouter(() => window.location.assign(new URL(redirect.location, window.location.href).href));\n } else {\n push(redirect.location);\n }\n return true;\n}\n\n/**\n * Puts a payload on screen, resolving once React has committed it. Replaced by `BrowserRoot`'s own on mount;\n * the default covers the window before hydration, where `setServerCallback` is already registered but there\n * is no root to update — a reload is the honest answer, and nothing after it needs to run.\n */\nlet setPayload: (payload: RscPayload) => Promise<void> = () => {\n window.location.reload();\n return new Promise<void>(() => {});\n};\n\n/** Runs work inside the nav transition so `useNavigation().pending` stays true across the round-trip. */\nlet startNav: (run: () => void | Promise<void>) => void = (run) => {\n void run();\n};\n\n/**\n * Fetches the payload for `url` and puts it on screen.\n *\n * Resolves once React has **committed** it rather than when the fetch lands: an intercepted navigation\n * scrolls and moves focus when this promise settles, and a `#hash` target does not exist until the new tree\n * does. Rejects only on a genuine failure — being superseded is not one, and resolves quietly, because the\n * navigation that replaced this one owns the screen from then on.\n */\nfunction loadPayload(url: string, signal?: AbortSignal): Promise<void> {\n // Deliberately not awaited inside the transition: the scope ends once the payload is handed to React, and\n // React holds `pending` until the update it scheduled commits. Awaiting the commit *inside* the scope would\n // work too, but only because React happens not to gate a commit on its async scope settling — an internal\n // this has no reason to depend on across the whole `^19.1.0` peer range.\n let committed: Promise<void> | undefined;\n\n const run = async () => {\n const payload = await requestPayload(url, signal);\n // The browser aborts a navigation the moment a newer one starts. Checked again after the await because\n // the fetch may already have resolved by then, and applying it would repaint a page the user has left.\n if (signal?.aborted) return;\n if (payload.redirect) {\n push(payload.redirect);\n return;\n }\n committed = setPayload(payload);\n };\n\n // `startTransition` runs the work but hands nothing back, so the promise carrying a failure is caught here\n // instead. Assigned synchronously: React invokes the callback before `startNav` returns.\n let work!: Promise<void>;\n startNav(() => (work = run()));\n\n return work.then(\n // Undefined whenever nothing was applied — an abort, or a redirect — and there is then nothing to wait for.\n () => committed,\n (error: unknown) => {\n // Checked before the error is read: an abort is this navigation being replaced, and the one that\n // replaced it owns the outcome.\n if (signal?.aborted || handleControlDigest(error)) return;\n throw error;\n },\n );\n}\n\n/**\n * Navigations the browser can hand over but shouldn't:\n *\n * - a fragment jump, which is same-document already and needs no payload — the browser's own jump is the one\n * that honours `scroll-padding-top`, and re-rendering would pull the target out from under it;\n * - a download, which is not a navigation of this page at all;\n * - a `POST` form, which is a submission and the server's to answer (a `GET` form carries its fields in the\n * URL, has no `formData`, and soft-navigates like any other link);\n * - a link marked `data-native`, the documented opt-out.\n */\nfunction leaveToBrowser(event: NavigateEvent): boolean {\n return event.hashChange || event.downloadRequest !== null || event.formData !== null || event.sourceElement?.hasAttribute('data-native') === true;\n}\n\n/**\n * The whole router, in one listener.\n *\n * Every navigation the page can make arrives as a `navigate` event — a link click, a `GET` form, a\n * `history.pushState`, the back button, `navigation.reload()` — already filtered by the browser: it does not\n * fire for a middle-click, a modified click or a new tab, and reports `canIntercept: false` for anything\n * cross-origin, or for a traversal that leaves the app. Those need no handling here; they are left alone, and\n * the browser performs them as it always would.\n */\nfunction listenNavigation(): () => void {\n if (!canSoftNavigate) return () => {};\n\n const onNavigate = (event: NavigateEvent) => {\n // Cleared as it is consumed, whatever this event turns out to be: the flag names one navigation, and the\n // one it named is the one that just arrived.\n if (bypassRouter) {\n bypassRouter = false;\n return;\n }\n if (!event.canIntercept || leaveToBrowser(event)) return;\n\n // A push or a traversal lands on a new page, so the browser resets the scroll offset — or restores the\n // one it remembers — and moves focus, which is what makes a soft navigation announce itself to a screen\n // reader. A replace or a refresh stays where it is, so neither should move. Both wait on the handler,\n // which is the point of resolving it at commit rather than at fetch.\n const inPlace = event.navigationType === 'replace' || event.navigationType === 'reload';\n\n event.intercept({\n scroll: inPlace ? 'manual' : 'after-transition',\n focusReset: inPlace ? 'manual' : 'after-transition',\n // The URL commits before the handler runs, so a failure leaves the address bar describing a page the\n // document is not showing. A real load is the only way back to agreement.\n handler: () => loadPayload(event.destination.url, event.signal).catch(() => loadOutsideRouter(() => window.location.reload())),\n });\n };\n\n navigation.addEventListener('navigate', onNavigate);\n return () => navigation.removeEventListener('navigate', onNavigate);\n}\n\nasync function main() {\n // The assertion is load-bearing under the compiler that builds this: TypeScript 7 declares `nonce` on\n // HTMLElement, 6 declares it on Element. ESLint runs the older lib — where the narrowing is redundant —\n // so it reports an assertion that `tsc` requires. Believe `typecheck`, not the rule.\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const cspMeta = document.querySelector('meta[property=\"csp-nonce\"]') as HTMLMetaElement | null;\n if (cspMeta?.nonce) __webpack_nonce__ = cspMeta.nonce;\n\n const initialPayload = await createFromReadableStream<RscPayload>(flightStream);\n\n // The recovery reload landed: this document *is* the `notFound` page, so the signal that could only be a\n // digest on the `RSC: 1` request became a real 404 on the document request. The one-reload bound was spent\n // on a recovery that worked and has to be released — otherwise the *next* soft navigation to this URL sees a\n // spent key and paints {@link showLateNotFound} over a page the app can still render.\n //\n // This is the discriminator the bound was missing. A structurally late `notFound()` commits its 200 before\n // it signals, so its reloaded document is the page itself and carries no `notFound`: the key survives and\n // that loop stays bounded at one reload, which is the whole reason the bound exists.\n if (initialPayload.notFound) {\n try {\n sessionStorage.removeItem(lateNotFoundKey());\n } catch {\n // Blocked site data. `reloadOnceForLateNotFound` already treats that as the terminating case.\n }\n }\n\n function BrowserRoot() {\n const [payload, setPayloadState] = React.useState(initialPayload);\n const [pending, startTransition] = React.useTransition();\n // The resolver the payload on screen still owes — see {@link loadPayload}.\n const pendingCommit = React.useRef<(() => void) | null>(null);\n\n React.useEffect(() => {\n setPayload = (next) =>\n new Promise<void>((resolve) => {\n // A payload replaced before it ever painted still has a navigation waiting on it. React commits\n // only the newest, so the effect below never runs for the one it skipped: release it here.\n pendingCommit.current?.();\n pendingCommit.current = resolve;\n setPayloadState(next);\n });\n startNav = (run) => startTransition(run);\n }, [startTransition]);\n\n /**\n * Releases the navigation waiting on this payload, which is what lets the browser scroll and move focus\n * now that their target exists. A layout effect, so the pre-scroll position is never painted.\n */\n React.useLayoutEffect(() => {\n const commit = pendingCommit.current;\n pendingCommit.current = null;\n commit?.();\n }, [payload]);\n\n React.useEffect(() => listenNavigation(), []);\n\n const router = React.useMemo<NavigationRouter>(() => ({ push, replace, back, forward, refresh, pending }), [pending]);\n\n return <RouterContext.Provider value={router}>{payload.root}</RouterContext.Provider>;\n }\n\n setServerCallback(async (id, args) => {\n const temporaryReferences = createTemporaryReferenceSet();\n // The document the action is being called from. Every action response carries a fresh payload for that\n // page, so if a navigation has moved on by the time it arrives the payload describes a page the user has\n // left — the return value is still theirs, but painting it is not. Compared without the fragment, which\n // the server never saw.\n const calledFrom = documentUrl();\n const request = createRscRequest(window.location.href, {\n id,\n body: await encodeReply(args, { temporaryReferences }),\n });\n let payload: RscPayload;\n try {\n payload = await createFromFetch<RscPayload>(payloadResponse(request), { temporaryReferences });\n } catch (error) {\n if (handleControlDigest(error)) return undefined;\n throw error;\n }\n if (payload.redirect) {\n push(payload.redirect);\n return undefined;\n }\n if (documentUrl() === calledFrom) React.startTransition(() => void setPayload(payload));\n if (payload.notFound) return undefined;\n const result = payload.returnValue;\n if (!result) {\n // A payload that is not this action's own reply: the server rendered a page in its place. An action\n // that had already run has its result carried across (see `actionResults` in entry.rsc.tsx), and the\n // ways a *caller* can get a request wrong are refused ahead of any render — an unknown id or an\n // undecodable body is a `text/plain` 400, which `payloadResponse` turns into an error of its own\n // before this.\n //\n // What is left is the server failing before the action ran, which is answered with the `error` page —\n // a flight payload, so it arrives here rather than at `payloadResponse`, with no `returnValue` in it.\n // A module the deployment no longer holds is the reachable case: `loadServerAction` throws, the\n // framework reports it and 500s, and this is what the caller has to go on. Hence the message: the\n // failure is on the server and its log is where the error is. Below that it is still the defensive\n // floor for a payload shaped by another deployment or replaced by a proxy — reading `.ok` off it used\n // to hand the caller `Cannot read properties of undefined`.\n throw new Error(\n '[rshono] the server action produced no result — the request failed around it and the server answered with a page instead. Its log has the error.',\n );\n }\n if (!result.ok) throw result.error;\n return result.value;\n });\n\n // A `redirect()` / `notFound()` from a component below the page root reaches us through React: it rides the\n // flight payload as an error, and boundaries re-throw it so it lands here rather than in a fallback.\n //\n // Installing these hooks opts out of React's own defaults, so everything that isn't a control signal has to\n // be put back by hand — `reportError` rather than a bare log, so error-reporting tools still see it.\n hydrateRoot(document, <BrowserRoot />, {\n formState: initialPayload.formState,\n onCaughtError: (error, errorInfo) => {\n if (handleControlDigest(error, { hard: true })) return;\n // A boundary handled it and the tree is intact, so no overlay over the app's own fallback.\n console.error(error, errorInfo.componentStack ?? '');\n },\n onUncaughtError: (error, errorInfo) => {\n if (handleControlDigest(error, { hard: true })) return;\n // Nothing caught it, so React tears the root down — and the root is `document`.\n globalThis.reportError(error);\n showFatal(error, errorInfo.componentStack);\n },\n });\n\n if (import.meta.webpackHot) {\n initDevRefresh();\n }\n}\n\n/**\n * Dev-only refresh client, listening to the CLI's SSE endpoint:\n *\n * client-built → hot-apply the waiting updates; anything the page can't be patched up to reloads.\n * rsc-update → server component code changed: re-fetch the flight payload, state preserved.\n * hello → sent on (re)connect with the latest build hash; a mismatch means a missed event.\n */\nfunction initDevRefresh() {\n const hot = import.meta.webpackHot!;\n let connectedOnce = false;\n /** The newest build the dev server has announced — what {@link applyClientUpdate} walks towards. */\n let targetHash: string | undefined;\n\n function reload(reason: string, error?: unknown): void {\n console.warn(`[rshono] ${reason} — reloading`, ...(error === undefined ? [] : [error]));\n loadOutsideRouter(() => window.location.reload());\n }\n\n async function applyClientUpdate(): Promise<void> {\n const giveUp = await walkHotUpdates(\n hot,\n () => __webpack_hash__,\n () => targetHash,\n );\n if (giveUp) reload(giveUp.reason, giveUp.error);\n }\n\n async function handle(message: DevMessage): Promise<void> {\n switch (message.type) {\n case 'hello':\n targetHash = message.hash ?? targetHash;\n if (connectedOnce) {\n await applyClientUpdate();\n await loadPayload(window.location.href).catch(() => loadOutsideRouter(() => window.location.reload()));\n }\n connectedOnce = true;\n break;\n case 'client-built':\n targetHash = message.hash;\n await applyClientUpdate();\n break;\n case 'rsc-update':\n console.log('[rshono] server components updated');\n await loadPayload(window.location.href).catch(() => loadOutsideRouter(() => window.location.reload()));\n break;\n }\n }\n\n const source = new EventSource('/_rshono/hmr');\n // Chained rather than handled as they arrive: `hot.check` may only run from `idle`, and a burst of saves\n // puts several frames on the wire inside the time one takes. Queueing drops nothing, because `targetHash`\n // is shared — whichever handler runs next walks to the newest build.\n let queue: Promise<void> = Promise.resolve();\n source.onmessage = (event: MessageEvent<string>) => {\n const message = JSON.parse(event.data) as DevMessage;\n queue = queue.then(() => handle(message)).catch((error) => reload('the dev client failed', error));\n };\n}\n\n// A bootstrap failure — a truncated initial payload, most likely — would otherwise be an unhandled\n// rejection: nothing hydrates, nothing is reported, and the page just sits there.\nmain().catch((error) => {\n console.error('[rshono] the client runtime failed to start:', error);\n showFatal(error);\n});\n"]}
|
|
1
|
+
{"version":3,"file":"entry.client.js","sourceRoot":"","sources":["../../src/runtime/entry.client.tsx"],"names":[],"mappings":";AAAA,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,\n createFromReadableStream,\n createTemporaryReferenceSet,\n encodeReply,\n setServerCallback,\n} from 'react-server-dom-rspack/client.browser';\nimport { isControlDigest, parseRedirectDigest } from './control.js';\nimport type { DevMessage } from './dev-protocol.js';\nimport type { RscPayload } from './entry.rsc.js';\n// Dev-only: its one caller sits behind `import.meta.webpackHot`, which a production build compiles to\n// `false` — so this module is dropped there.\nimport { walkHotUpdates } from './hot-update.js';\nimport { RouterContext, type NavigationRouter } from './navigation.js';\nimport { createRscRequest } from './request.js';\n\nconst isDev = process.env.NODE_ENV === 'development';\n\ndeclare global {\n /** The array the payload `<script>` tags `flight-inject.ts` emits push their chunks into. */\n var __FLIGHT_DATA: Array<string | Uint8Array> | undefined;\n}\n\n/** The flight payload the document carried, read back out of `__FLIGHT_DATA` — see `flight-inject.ts`. */\nfunction readFlightPayload(): ReadableStream<Uint8Array> {\n const encoder = new TextEncoder();\n // Assigned synchronously by `start`, which `new ReadableStream` runs before it returns.\n let controller!: ReadableStreamDefaultController<Uint8Array>;\n const stream = new ReadableStream<Uint8Array>({\n start: (c) => void (controller = c),\n });\n const enqueue = (chunk: string | Uint8Array) => controller.enqueue(typeof chunk === 'string' ? encoder.encode(chunk) : chunk);\n\n // Payload scripts interleave with the document: the ones that already ran are in the array, the rest\n // arrive through `push`.\n const data = (self.__FLIGHT_DATA ??= []);\n for (const chunk of data) enqueue(chunk);\n data.push = enqueue as typeof data.push;\n\n // The last payload script lands before parsing finishes, so that is what closes the stream.\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', () => controller.close(), { once: true });\n } else {\n controller.close();\n }\n return stream;\n}\n\n/** Created at module evaluation, not inside `main()`, so no chunk can be pushed before it is watching. */\nconst flightStream = readFlightPayload();\n\n/**\n * The part of the location a payload is rendered for — the document, without the fragment, which the server\n * never sees. Two URLs that differ only by `#hash` describe the same payload.\n */\nconst documentUrl = (): string => location.pathname + location.search;\n\n/**\n * The document URL the payload on screen was rendered for — see {@link documentUrl}. A fragment-only\n * traversal leaves it unchanged, which is how the `popstate` listener knows there is nothing to fetch.\n * Updated in the layout effect that commits a payload.\n */\nlet renderedUrl = documentUrl();\n\n/** Guarantees somewhere to attach the fatal overlay: the root container is `document`, so a teardown can take `<body>` with it. */\nfunction overlayHost(): HTMLElement {\n if (!document.documentElement) document.appendChild(document.createElement('html'));\n if (!document.body) document.documentElement.appendChild(document.createElement('body'));\n return document.body;\n}\n\n/**\n * Paints a full-viewport panel over whatever is on screen, and returns the box for the caller to fill.\n *\n * DOM calls rather than React (one caller runs because the renderer just failed), and `textContent` rather\n * than `innerHTML` (an error message is untrusted input). Queued on a macrotask: React's teardown runs after\n * the callback that reaches here returns, and would remove a node appended inline.\n */\nfunction paintOverlay(fill: (box: HTMLElement) => void): void {\n setTimeout(() => {\n const host = overlayHost();\n host.querySelector('[data-rshono-fatal]')?.remove();\n\n const box = document.createElement('div');\n box.setAttribute('data-rshono-fatal', '');\n box.setAttribute('role', 'alert');\n box.style.cssText =\n 'position:fixed;inset:0;z-index:2147483647;overflow:auto;padding:1.5rem;background:#18181b;color:#f4f4f5;' +\n 'font:14px/1.6 ui-monospace,SFMono-Regular,Menlo,monospace;text-align:left';\n\n fill(box);\n host.appendChild(box);\n }, 0);\n}\n\n/** The overlay's heading. */\nfunction overlayTitle(text: string): HTMLElement {\n const title = document.createElement('div');\n title.textContent = text;\n title.style.cssText = 'font-size:1.0625rem;font-weight:700;color:#f87171;margin:0 0 0.75rem';\n return title;\n}\n\n/**\n * Paints the reason for an uncaught render error over the blank page it leaves behind — the full stack in\n * dev, a generic notice and a reload button in production.\n */\nfunction showFatal(error: unknown, componentStack?: string | null): void {\n paintOverlay((box) => {\n box.appendChild(overlayTitle(isDev ? 'Unhandled error' : 'Something went wrong'));\n\n if (isDev) {\n const detail = document.createElement('pre');\n detail.style.cssText = 'margin:0;white-space:pre-wrap;word-break:break-word';\n detail.textContent =\n (error instanceof Error ? (error.stack ?? `${error.name}: ${error.message}`) : String(error)) +\n (componentStack ? `\\n\\nComponent stack:${componentStack}` : '');\n box.appendChild(detail);\n } else {\n const message = document.createElement('p');\n message.textContent = 'This page hit an unexpected error and can’t continue.';\n message.style.cssText = 'margin:0 0 1rem;color:#d4d4d8';\n box.appendChild(message);\n }\n\n const reload = document.createElement('button');\n reload.textContent = 'Reload page';\n reload.style.cssText =\n 'margin-top:1.25rem;padding:0.5rem 1rem;font:inherit;color:#18181b;background:#f4f4f5;border:0;border-radius:4px;cursor:pointer';\n reload.addEventListener('click', () => loadDocument());\n box.appendChild(reload);\n });\n}\n\n/**\n * The end of the line for a `notFound()` that arrived too late to be a 404 and did not survive a reload.\n *\n * No reload button, unlike {@link showFatal}: the reload has already been spent, and the second identical\n * response is what brought us here. \"Page not found\" is what the server was trying to say, so it is what the\n * visitor is told; the reason it could not say it properly is a message for whoever wrote the page, and dev is\n * where they are.\n */\nfunction showLateNotFound(): void {\n paintOverlay((box) => {\n box.appendChild(overlayTitle('Page not found'));\n\n const message = document.createElement('p');\n message.textContent = isDev\n ? 'notFound() was raised from a boundary that resolved after the page shell had been sent, so the response ' +\n 'could not be a 404 — and reloading rendered the same page again. Decide before the render starts ' +\n 'streaming: in Hono middleware, or in the page component body above the boundary.'\n : 'This page is not available.';\n message.style.cssText = 'margin:0;color:#d4d4d8';\n box.appendChild(message);\n });\n}\n/** What every flight response is typed as. The charset and any other parameters follow it. */\nconst FLIGHT_CONTENT_TYPE = 'text/x-component';\n\n/**\n * Fetches a payload, refusing a response that is not one.\n *\n * The status cannot be the gate: a payload legitimately arrives as a 404 from the `notFound` page and as a\n * 500 from an action that threw, and both carry a real payload the caller has to see. The content type is.\n *\n * What this catches is the response that is not a payload at all — a `bodyLimit()` 413, a proxy's error page,\n * a 502 mid-deploy. Handed to the flight parser those all surface as `Error: Connection closed.`, with the\n * status and the body nowhere in sight; here they become an error that says what arrived.\n */\nasync function payloadResponse(request: Request): Promise<Response> {\n const response = await fetch(request);\n const contentType = response.headers.get('content-type');\n if (contentType?.startsWith(FLIGHT_CONTENT_TYPE)) return response;\n // Read for the message: a plain-text refusal says what it refused only in its body, and HTTP/2 has no\n // `statusText` at all. Bounded, because this is an error path and the body is not ours to trust.\n const body = await response.text().then(\n (text) => text.trim().slice(0, 200),\n () => '',\n );\n const status = `${response.status}${response.statusText ? ` ${response.statusText}` : ''}`;\n throw new Error(`[rshono] the server answered ${status} (${contentType ?? 'no content type'}) instead of a payload${body ? `: ${body}` : ''}`);\n}\n\n/**\n * Asks a URL for its flight payload. Deliberately uncached — a payload can never be staler than the click\n * that wanted it, and the browser's own HTTP cache is what makes a repeat visit cheap.\n */\nfunction requestPayload(href: string, signal?: AbortSignal): Promise<RscPayload> {\n return createFromFetch<RscPayload>(payloadResponse(createRscRequest(new URL(href, location.href).href, undefined, signal)));\n}\n\n/**\n * Whether the browser hands us its navigations. Gated on `sourceElement` rather than on `navigation` itself:\n * Chrome shipped the event in 102 and that property only in 135, and without it a `data-native` link cannot\n * be told from any other — so the older window would soft-navigate the very links that asked not to be.\n *\n * Where this is false there is no interception at all and every navigation is a real browser load, which a\n * server-rendered app answers correctly on its own. Only the soft part is missing.\n *\n * Both globals are tested, and neither is touched before: this runs at module scope, where a ReferenceError\n * would take the whole client runtime down with it rather than degrading anything.\n */\nconst canSoftNavigate = typeof navigation !== 'undefined' && typeof NavigateEvent !== 'undefined' && 'sourceElement' in NavigateEvent.prototype;\n\n/**\n * The runtime owns a soft navigation's scroll, so the browser's own restoration has to be off: left on, a\n * traversal restores the destination's offset against the outgoing tree before the payload for that entry\n * has even been asked for, and the incoming tree overwrites it. `manual` only concerns the entries this\n * document creates — a navigation to another document creates its own entry `auto` — and it also turns the\n * browser's reload restoration off, which {@link readStoredScrollPositions} and the first layout effect put\n * back.\n *\n * Gated on the soft router: below the Navigation API floor every navigation is a real document load, which\n * a server-rendered app answers correctly and the browser restores correctly, and taking that over without\n * a router to repaint the entry would strand the visitor at the top.\n */\nif (canSoftNavigate) {\n try {\n history.scrollRestoration = 'manual';\n } catch {\n // A preference, not a requirement: where it cannot be set, the browser's restoration and the runtime's\n // own can race on a traversal, and the runtime's runs at commit, after.\n }\n}\n\n/** A scroll offset, in the coordinates `window.scrollTo` takes and `window.scrollX`/`window.scrollY` return. */\ntype ScrollPoint = { x: number; y: number };\n\n/**\n * Where each history entry of this document was left, keyed by its Navigation API key. In memory for the\n * document's life; {@link persistScrollPositions} also writes it to `sessionStorage` so a reload — which\n * the `manual` mode above stops the browser restoring — lands where the last document was left.\n */\nconst scrollPositions = new Map<string, ScrollPoint>();\n\n/** The `sessionStorage` key holding {@link scrollPositions}. */\nconst SCROLL_STORAGE_KEY = 'rshono:scroll';\n\n/** How many entries are kept in that snapshot; the oldest falls out first — `Map` iteration order. */\nconst SCROLL_STORAGE_LIMIT = 50;\n\n/** The key of the history entry being shown, or `undefined` where the soft router does not exist. */\nfunction currentEntryKey(): string | undefined {\n return canSoftNavigate ? navigation.currentEntry?.key : undefined;\n}\n\n/**\n * Records where the outgoing entry is being left. Read at `navigate` time — before the browser commits the\n * new entry — and at `pagehide`, so whatever the navigation turns out to be, the entry it leaves has a\n * position to come back to.\n */\nfunction rememberCurrentScroll(): void {\n const key = currentEntryKey();\n if (key) scrollPositions.set(key, { x: window.scrollX, y: window.scrollY });\n}\n\n/** The position `key` was left at, or `undefined` when this document never saw it. */\nfunction scrollPointFor(key: string | undefined): ScrollPoint | undefined {\n return key === undefined ? undefined : scrollPositions.get(key);\n}\n\n/**\n * Reads the last document's snapshot back into {@link scrollPositions}. Called once, on startup, before the\n * first payload commits: the in-memory map alone would lose every entry the moment the document is replaced.\n */\nfunction readStoredScrollPositions(): void {\n try {\n const raw = sessionStorage.getItem(SCROLL_STORAGE_KEY);\n if (!raw) return;\n for (const [key, point] of Object.entries(JSON.parse(raw) as Record<string, ScrollPoint>)) {\n if (Number.isFinite(point?.x) && Number.isFinite(point?.y)) scrollPositions.set(key, point);\n }\n } catch {\n // Blocked site data, or a snapshot written by a different version. Either way there is nothing to restore,\n // and the page is still correct without it.\n }\n}\n\n/** Writes {@link scrollPositions} out, oldest first, bounded — see {@link SCROLL_STORAGE_LIMIT}. */\nfunction persistScrollPositions(): void {\n try {\n while (scrollPositions.size > SCROLL_STORAGE_LIMIT) {\n const oldest = scrollPositions.keys().next().value;\n if (oldest === undefined) break;\n scrollPositions.delete(oldest);\n }\n sessionStorage.setItem(SCROLL_STORAGE_KEY, JSON.stringify(Object.fromEntries(scrollPositions)));\n } catch {\n // Blocked site data: the in-memory map still carries this document's navigations.\n }\n}\n\n/**\n * The snapshot starts with the document, not with hydration: the page is visible and clickable while the\n * initial payload streams, and a reload or a navigation away in that window would otherwise lose the offset\n * now that `manual` has stopped the browser restoring it. Nothing here depends on the router being mounted,\n * so it does not wait for {@link listenNavigation}.\n */\nif (canSoftNavigate) {\n window.addEventListener('pagehide', () => {\n rememberCurrentScroll();\n persistScrollPositions();\n });\n}\n\n/**\n * Drops a navigation's result promises. Both reject when a navigation is superseded or cancelled — routine\n * here, since a second click is meant to abandon the first — and unhandled they would be reported as faults.\n */\nfunction settle(result: NavigationResult): void {\n const ignore = () => {};\n void result.committed?.catch(ignore);\n void result.finished?.catch(ignore);\n}\n\n/**\n * The mark {@link loadDocument} puts on its navigations, so the `navigate` listener below recognizes them as\n * the runtime's own. A symbol because the identity has to survive the trip through the browser intact:\n * `NavigateEvent.info` hands the value back by reference, so only the navigation that was given it matches.\n */\nconst documentNavigation = Symbol('rshono:document-navigation');\n\n/**\n * Performs a navigation the router below must **not** intercept, and returns having asked for it.\n *\n * `listenNavigation` intercepts a `reload` on purpose — that is what `router.refresh()` is — and every caller\n * here is reaching for a *new document* precisely because the current one cannot be repaired: the React root\n * a soft load would render into is the thing that just failed, or is about to be torn down. Intercepted, the\n * escape hatch becomes a payload fetch that lands nowhere — which is how a late `notFound()` left the tab on\n * its Suspense fallback with no second document ever arriving, and how a late `redirect()` moved the address\n * bar to a page it then failed to render.\n *\n * The mark rides the navigation itself, through `info`, so the listener recognizes the event that owns it\n * instead of consuming a flag set in advance. There is no state to clear and none to leak: a navigation the\n * browser refuses cannot make the next one a full load. Below the Navigation API there is no interception to\n * opt out of, and `location.*` is already a document load.\n */\nfunction loadDocument(href?: string): void {\n if (!canSoftNavigate) {\n if (href === undefined) window.location.reload();\n else window.location.assign(href);\n return;\n }\n\n settle(href === undefined ? navigation.reload({ info: documentNavigation }) : navigation.navigate(href, { info: documentNavigation }));\n}\n\n// The imperative actions behind `useNavigation().router`. Each one only *asks*: the browser turns it into a\n// `navigate` event, which is where `listenNavigation` answers it — so a `router.push` and a link click reach\n// the same code by the same route, and inherit the same fetch, scroll and `pending` flag.\nfunction push(href: string): void {\n if (canSoftNavigate) settle(navigation.navigate(href, { history: 'push' }));\n else window.location.assign(href);\n}\n\nfunction replace(href: string): void {\n if (canSoftNavigate) settle(navigation.navigate(href, { history: 'replace' }));\n else window.location.replace(href);\n}\n\n// A traversal is the browser's to perform either way — `navigation` only hands it back as an interceptable\n// event first. Nothing to go back to is a rejection there and a no-op here; both amount to the same thing.\nfunction back(): void {\n if (canSoftNavigate) settle(navigation.back());\n else window.history.back();\n}\n\nfunction forward(): void {\n if (canSoftNavigate) settle(navigation.forward());\n else window.history.forward();\n}\n\n// A refresh keeps the URL, and is still a navigation: it arrives as `navigationType: 'reload'`, which is what\n// tells the listener to leave scroll and focus where the user left them.\nfunction refresh(): void {\n if (canSoftNavigate) settle(navigation.reload());\n else window.location.reload();\n}\n\n/** How long the recovery reload is given to replace this document before the panel is painted instead. */\nconst RELOAD_GRACE_MS = 2000;\n\n/** The `sessionStorage` key bounding the recovery reload for one URL. Spent here, released in {@link main}. */\nconst lateNotFoundKey = (): string => `rshono:late-not-found:${documentUrl()}`;\n\n/**\n * Spends the one reload a late `notFound()` gets, or paints if it has already been spent for this URL.\n *\n * `redirect()` is terminal on the client — there is somewhere to navigate to — and `notFound()` is not: the\n * response is already committed as a 200, so the only recovery left is asking for the page again and hoping\n * the signal comes early enough this time to be a real 404. That works where the lateness was incidental, a\n * boundary that happened to resolve after the shell on a slow request. Where it is structural — a page that\n * always signals from a late boundary — the reload gets a byte-identical response and reloads again, and the\n * tab spins until the visitor leaves. In production nothing is logged, because the warning that explains this\n * is `isDev`-only.\n *\n * So it is bounded: one reload per URL per tab, then {@link showLateNotFound}. `sessionStorage` because the\n * value has to outlive the document it is written in and must not outlive the tab, and keyed by URL so a\n * second page's late signal still gets its own attempt.\n */\nfunction reloadOnceForLateNotFound(): void {\n const key = lateNotFoundKey();\n let spent: boolean;\n try {\n spent = sessionStorage.getItem(key) !== null;\n if (!spent) sessionStorage.setItem(key, '1');\n } catch {\n // Storage can throw outright where site data is blocked, and a page that cannot count its reloads has\n // to pick a side. It picks the terminating one: a message on a page that might have recovered is a\n // worse outcome than a reload loop only by a lot less.\n spent = true;\n }\n if (spent) {\n showLateNotFound();\n return;\n }\n\n loadDocument();\n\n // The reload wins this race whenever it happens at all: the document goes away and takes the timer with\n // it. What this covers is a reload that does not happen — swallowed by an interceptor, refused by the\n // browser, held by a `beforeunload` — which used to leave the visitor on a Suspense fallback with nothing\n // coming and nothing said. The panel is the honest answer in that case too.\n setTimeout(() => {\n if (!document.querySelector('[data-rshono-fatal]')) showLateNotFound();\n }, RELOAD_GRACE_MS);\n}\n\n/**\n * Turns a control-signal digest — how `redirect()` / `notFound()` reach the browser — into a real\n * navigation. Returns false for anything else, so callers fall through to their own handling.\n *\n * `hard` forces a full document load, for signals that surfaced *through React*: it unmounts the root on\n * an uncaught error, leaving no live tree to soft-navigate with.\n */\nfunction handleControlDigest(error: unknown, { hard = false }: { hard?: boolean } = {}): boolean {\n const digest = (error as { digest?: unknown } | null)?.digest;\n if (!isControlDigest(digest)) return false;\n const redirect = parseRedirectDigest(digest);\n if (!redirect) {\n reloadOnceForLateNotFound();\n } else if (hard) {\n // The URL is resolved first: a malformed location then throws here, before any navigation is asked for.\n loadDocument(new URL(redirect.location, window.location.href).href);\n } else {\n push(redirect.location);\n }\n return true;\n}\n\n/**\n * Scrolls the document to its start.\n *\n * The options form rather than `scrollTo(0, 0)`: the two-argument call is `auto`, which follows a\n * `scroll-behavior` the app may have set on `html`, and a soft navigation that animates its own reset reads\n * as a glitch rather than a page change.\n */\nfunction scrollToTop(): void {\n window.scrollTo({ top: 0, left: 0, behavior: 'instant' });\n}\n\n/** Puts a saved offset back. Instant for the same reason {@link scrollToTop} passes it. */\nfunction scrollToPoint(point: ScrollPoint): void {\n window.scrollTo({ top: point.y, left: point.x, behavior: 'instant' });\n}\n\n/**\n * Scrolls to a fragment's target the way the browser's own fragment jump does.\n *\n * `scrollIntoView` is the algorithm that honours `scroll-padding-top` on the scrolling box and\n * `scroll-margin-top` on the target, which `window.scrollTo` does not. The lookup follows the browser's\n * \"find a potential indicated element\": the id first, then the name. A malformed percent-escape falls back\n * to the literal fragment, and a fragment nothing matches gets the top of the document — what a browser\n * gives a missing anchor on a real load.\n */\nfunction jumpToAnchor(hash: string): void {\n const raw = hash.startsWith('#') ? hash.slice(1) : hash;\n // No special case for `#top`: the browser only treats it as the top of the document when no element\n // matches, and the fallback below is that top.\n if (raw === '') {\n scrollToTop();\n return;\n }\n let id = raw;\n try {\n id = decodeURIComponent(raw);\n } catch {\n // Malformed escape — the literal fragment is the better guess at the id than nothing.\n }\n const target = document.getElementById(id) ?? document.getElementsByName(id)[0];\n if (target) target.scrollIntoView();\n else scrollToTop();\n}\n\n/**\n * Moves focus the way the browser's `focusReset: 'after-transition'` does: the first `autofocus` element,\n * else the document body. A traversal is no longer intercepted, so the browser performs no focus reset for\n * it; without this, Back would leave focus on the link that was clicked on the page being left, and the next\n * Tab would resume there. `preventScroll` because the traversal's own offset has just been restored.\n */\nfunction resetFocus(): void {\n const autofocus = document.querySelector<HTMLElement>('[autofocus]');\n if (autofocus) autofocus.focus({ preventScroll: true });\n else document.body.focus({ preventScroll: true });\n}\n\n/**\n * Puts a payload on screen, resolving once React has committed it. Replaced by `BrowserRoot`'s own on mount;\n * the default covers the window before hydration, where `setServerCallback` is already registered but there\n * is no root to update — a reload is the honest answer, and nothing after it needs to run.\n *\n * `afterCommit`, when given, runs in the same layout effect that releases the commit: after the new tree is\n * in the DOM and before the browser paints, which is the only moment a `#hash` target exists and the\n * pre-scroll position has not been shown.\n */\nlet setPayload: (payload: RscPayload, afterCommit?: () => void) => Promise<void> = () => {\n window.location.reload();\n return new Promise<void>(() => {});\n};\n\n/** Runs work inside the nav transition so `useNavigation().pending` stays true across the round-trip. */\nlet startNav: (run: () => void | Promise<void>) => void = (run) => {\n void run();\n};\n\n/**\n * The navigation whose payload is allowed to settle the screen. React runs async work concurrently, so two\n * navigations are two live fetches with no ordering between them; without this a slow first response landing\n * after a fast second one repaints the page the user already left. The Navigation API aborts an intercepted\n * navigation when a newer one starts, but a traversal has no `event.signal` to watch — `popstate` arrives\n * after the browser has already committed it — so ordering is the runtime's own for those.\n */\nlet currentNavigation = 0;\n\n/** The in-flight navigation's fetch, so a newer one can stop paying for it. */\nlet navigationFetch: AbortController | null = null;\n\n/**\n * Fetches the payload for `url` and puts it on screen.\n *\n * Resolves once React has **committed** it rather than when the fetch lands: `afterCommit` runs at that\n * point, and a `#hash` target does not exist until the new tree does. Rejects only on a genuine failure —\n * being superseded is not one, and resolves quietly, because the navigation that replaced this one owns the\n * screen from then on.\n */\nfunction loadPayload(url: string, signal?: AbortSignal, afterCommit?: () => void): Promise<void> {\n // This navigation's place in the queue, and its own abort switch: a fetch is abandoned by whichever comes\n // first, the browser superseding it (an intercepted navigation carries `event.signal`) or a newer runtime\n // fetch starting (a traversal, an action, a dev refresh).\n const navigation = ++currentNavigation;\n navigationFetch?.abort();\n const controller = (navigationFetch = new AbortController());\n const abort = signal ? AbortSignal.any([signal, controller.signal]) : controller.signal;\n\n // Deliberately not awaited inside the transition: the scope ends once the payload is handed to React, and\n // React holds `pending` until the update it scheduled commits. Awaiting the commit *inside* the scope would\n // work too, but only because React happens not to gate a commit on its async scope settling — an internal\n // this has no reason to depend on across the whole `^19.1.0` peer range.\n let committed: Promise<void> | undefined;\n\n const run = async () => {\n const payload = await requestPayload(url, abort);\n // Checked again after the await because the fetch may already have resolved by then, and applying it\n // would repaint a page the user has left.\n if (abort.aborted || navigation !== currentNavigation) return;\n if (payload.redirect) {\n push(payload.redirect);\n return;\n }\n committed = setPayload(payload, afterCommit);\n };\n\n // `startTransition` runs the work but hands nothing back, so the promise carrying a failure is caught here\n // instead. Assigned synchronously: React invokes the callback before `startNav` returns.\n let work!: Promise<void>;\n startNav(() => (work = run()));\n\n return work.then(\n // Undefined whenever nothing was applied — an abort, or a redirect — and there is then nothing to wait for.\n () => committed,\n (error: unknown) => {\n // Checked before the error is read: an abort is this navigation being replaced, and the one that\n // replaced it owns the outcome.\n if (abort.aborted || navigation !== currentNavigation || handleControlDigest(error)) return;\n throw error;\n },\n );\n}\n\n/**\n * Whether a destination names a file rather than a page. `public/`, `/_static` and an endpoint route that\n * serves a document (`/llms.txt`, `/sitemap.xml`) answer an RSC fetch with the file itself, not a flight\n * payload — so intercepting one buys nothing: the payload never arrives, and the only recovery left is the\n * document load the browser would have made directly. Handing it that navigation up front also gives the\n * entry the file loads into the browser's own history, so Back is an ordinary cross-document traversal. An\n * intercepted entry is same-document by construction, and traversing one with nothing to repaint it changes\n * the URL and nothing else — which is what a Back press out of an opened file was doing.\n *\n * A dot in the last path segment rather than a list of extensions: a list is never complete, and every miss\n * is the failed round trip above. A page route whose last segment carries a dot (`/release-1.0`) therefore\n * costs a document load — the direction to err in, and what a `data-native` link already asks for by hand.\n */\nfunction namesAFile(href: string): boolean {\n const lastSegment = new URL(href).pathname.split('/').pop() ?? '';\n return lastSegment.includes('.');\n}\n\n/**\n * Navigations the browser can hand over but shouldn't:\n *\n * - a fragment jump, which is same-document already and needs no payload — the browser's own jump is the one\n * that honours `scroll-padding-top`, and re-rendering would pull the target out from under it;\n * - a download, which is not a navigation of this page at all;\n * - a `POST` form, which is a submission and the server's to answer (a `GET` form carries its fields in the\n * URL, has no `formData`, and soft-navigates like any other link);\n * - a link marked `data-native`, the documented opt-out;\n * - a destination that names a file — see {@link namesAFile}.\n */\nfunction leaveToBrowser(event: NavigateEvent): boolean {\n return (\n event.hashChange ||\n event.downloadRequest !== null ||\n event.formData !== null ||\n event.sourceElement?.hasAttribute('data-native') === true ||\n namesAFile(event.destination.url)\n );\n}\n\n/**\n * The whole router, in one listener.\n *\n * Every navigation the page can make arrives as a `navigate` event — a link click, a `GET` form, a\n * `history.pushState`, the back button, `navigation.reload()` — already filtered by the browser: it does not\n * fire for a middle-click, a modified click or a new tab, and reports `canIntercept: false` for anything\n * cross-origin, or for a traversal that leaves the app. Those need no handling here; they are left alone, and\n * the browser performs them as it always would.\n */\nfunction listenNavigation(): () => void {\n if (!canSoftNavigate) return () => {};\n\n const onNavigate = (event: NavigateEvent) => {\n // A document navigation the runtime asked for itself, marked through `info`. Checked before the scroll\n // snapshot: the document is going away, so where its entry was left does not matter, and an unrelated\n // later navigation can never be mistaken for this one.\n if (event.info === documentNavigation) return;\n\n // Whatever the browser is about to do with this navigation, the entry it is leaving is about to lose the\n // offset it was at, and nothing else in this document will put it back. Saved before the branches below\n // return, so a fragment the browser performs itself is covered too.\n rememberCurrentScroll();\n\n if (!event.canIntercept || leaveToBrowser(event)) return;\n\n // A traversal is repainted by the `popstate` listener below, not intercepted. `intercept`ing one is what\n // makes WebKit stall the rendered viewport for about three seconds on a back swipe\n // (bugs.webkit.org/319414): the view gesture's snapshot is only removed once the navigation finishes, and\n // React's root attaches the wheel listener the bug also needs. Letting the traversal through means the\n // browser commits the entry straight away, and the runtime puts the payload on screen when it arrives.\n if (event.navigationType === 'traverse') return;\n\n // A replace or a refresh stays where it is, so neither should move. A push starts at the top of the\n // page, or at its fragment — and that scroll is the runtime's own now: WebKit performs no\n // `after-transition` reset at all for an intercepted push (bugs.webkit.org/304593). Chromium skips it\n // too, and a fragment jump rides the same code path. Passing `manual` here makes the browser hand the\n // handler over without scrolling; the `afterCommit` callback reaches the target once the new tree is on\n // screen. Focus stays the browser's, reset after the transition.\n const inPlace = event.navigationType === 'replace' || event.navigationType === 'reload';\n let afterCommit: (() => void) | undefined;\n if (event.navigationType === 'push') {\n const { hash } = new URL(event.destination.url);\n afterCommit = hash === '' ? scrollToTop : () => jumpToAnchor(hash);\n }\n\n event.intercept({\n scroll: 'manual',\n focusReset: inPlace ? 'manual' : 'after-transition',\n // The URL commits before the handler runs, so a failure leaves the address bar describing a page the\n // document is not showing. A real load is the only way back to agreement.\n handler: () => loadPayload(event.destination.url, event.signal, afterCommit).catch(() => loadDocument()),\n });\n };\n\n /**\n * Repaints a traversal the listener above deliberately left to the browser, and moves the viewport back\n * where the entry was left. `popstate` fires after the browser has committed the entry, so the destination\n * is `navigation.currentEntry` and its saved offset is in {@link scrollPositions}.\n */\n const onPopState = () => {\n const stored = scrollPointFor(currentEntryKey());\n const hash = location.hash;\n const apply = () => {\n if (stored) scrollToPoint(stored);\n else if (hash !== '') jumpToAnchor(hash);\n else scrollToTop();\n };\n\n // A fragment-only traversal never changed the payload: the address bar is back at an anchor of the page\n // already on screen, so there is nothing to fetch and nothing to wait for. The browser's own restoration\n // is off, so the offset comes from what `onNavigate` saved when the anchor was followed; no focus reset,\n // which is what leaving those navigations to the browser has always meant.\n if (documentUrl() === renderedUrl) {\n apply();\n return;\n }\n\n void loadPayload(location.href, undefined, () => {\n apply();\n // The browser performs this for an intercepted navigation; a traversal is no longer intercepted, so\n // without it Back would leave focus on the link that was clicked on the page being left.\n resetFocus();\n }).catch(() => loadDocument());\n };\n\n navigation.addEventListener('navigate', onNavigate);\n window.addEventListener('popstate', onPopState);\n return () => {\n navigation.removeEventListener('navigate', onNavigate);\n window.removeEventListener('popstate', onPopState);\n };\n}\n\nasync function main() {\n // The assertion is load-bearing under the compiler that builds this: TypeScript 7 declares `nonce` on\n // HTMLElement, 6 declares it on Element. ESLint runs the older lib — where the narrowing is redundant —\n // so it reports an assertion that `tsc` requires. Believe `typecheck`, not the rule.\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const cspMeta = document.querySelector('meta[property=\"csp-nonce\"]') as HTMLMetaElement | null;\n if (cspMeta?.nonce) __webpack_nonce__ = cspMeta.nonce;\n\n const initialPayload = await createFromReadableStream<RscPayload>(flightStream);\n\n // The recovery reload landed: this document *is* the `notFound` page, so the signal that could only be a\n // digest on the `RSC: 1` request became a real 404 on the document request. The one-reload bound was spent\n // on a recovery that worked and has to be released — otherwise the *next* soft navigation to this URL sees a\n // spent key and paints {@link showLateNotFound} over a page the app can still render.\n //\n // This is the discriminator the bound was missing. A structurally late `notFound()` commits its 200 before\n // it signals, so its reloaded document is the page itself and carries no `notFound`: the key survives and\n // that loop stays bounded at one reload, which is the whole reason the bound exists.\n if (initialPayload.notFound) {\n try {\n sessionStorage.removeItem(lateNotFoundKey());\n } catch {\n // Blocked site data. `reloadOnceForLateNotFound` already treats that as the terminating case.\n }\n }\n\n // Everything the last document saved, read before any payload commits: the in-memory map alone would not\n // survive the reload that `history.scrollRestoration = 'manual'` just stopped the browser restoring. The\n // entry's key is stable across a reload, and the offset is applied by `BrowserRoot`'s first layout effect,\n // before the first paint of the new tree.\n if (canSoftNavigate) readStoredScrollPositions();\n const restored = scrollPointFor(currentEntryKey());\n\n function BrowserRoot() {\n const [payload, setPayloadState] = React.useState(initialPayload);\n const [pending, startTransition] = React.useTransition();\n // The resolver the payload on screen still owes — see {@link loadPayload}.\n const pendingCommit = React.useRef<(() => void) | null>(null);\n // The scroll the payload about to commit owes, set with it so a payload that supersedes another takes\n // its predecessor's scroll out of the queue along with its commit. Initialised with the reload's offset:\n // the first layout effect below applies it with the first payload, before the new tree is painted.\n const pendingScroll = React.useRef<(() => void) | null>(restored ? () => scrollToPoint(restored) : null);\n\n React.useEffect(() => {\n setPayload = (next, afterCommit) =>\n new Promise<void>((resolve) => {\n // A payload replaced before it ever painted still has a navigation waiting on it. React commits\n // only the newest, so the effect below never runs for the one it skipped: release it here.\n pendingCommit.current?.();\n pendingCommit.current = resolve;\n // Replaced rather than kept: a server action's payload carries no `afterCommit`, and the\n // navigation it superseded must not scroll the page the action is about to replace it with.\n pendingScroll.current = afterCommit ?? null;\n setPayloadState(next);\n });\n startNav = (run) => startTransition(run);\n }, [startTransition]);\n\n /**\n * Performs the pending scroll and releases the navigation waiting on this payload. A layout effect, so\n * the new tree is in the DOM and the pre-scroll position is never painted.\n */\n React.useLayoutEffect(() => {\n const scroll = pendingScroll.current;\n pendingScroll.current = null;\n scroll?.();\n // What the payload that just committed was rendered for — see {@link renderedUrl}. A redirect never\n // reaches here, and an action or a dev refresh keeps the URL it was fetched for.\n renderedUrl = documentUrl();\n const commit = pendingCommit.current;\n pendingCommit.current = null;\n commit?.();\n }, [payload]);\n\n React.useEffect(() => listenNavigation(), []);\n\n const router = React.useMemo<NavigationRouter>(() => ({ push, replace, back, forward, refresh, pending }), [pending]);\n\n return <RouterContext.Provider value={router}>{payload.root}</RouterContext.Provider>;\n }\n\n setServerCallback(async (id, args) => {\n const temporaryReferences = createTemporaryReferenceSet();\n // The document the action is being called from. Every action response carries a fresh payload for that\n // page, so if a navigation has moved on by the time it arrives the payload describes a page the user has\n // left — the return value is still theirs, but painting it is not. Compared without the fragment, which\n // the server never saw.\n const calledFrom = documentUrl();\n const request = createRscRequest(window.location.href, {\n id,\n body: await encodeReply(args, { temporaryReferences }),\n });\n let payload: RscPayload;\n try {\n payload = await createFromFetch<RscPayload>(payloadResponse(request), { temporaryReferences });\n } catch (error) {\n if (handleControlDigest(error)) return undefined;\n throw error;\n }\n if (payload.redirect) {\n push(payload.redirect);\n return undefined;\n }\n if (documentUrl() === calledFrom) React.startTransition(() => void setPayload(payload));\n if (payload.notFound) return undefined;\n const result = payload.returnValue;\n if (!result) {\n // A payload that is not this action's own reply: the server rendered a page in its place. An action\n // that had already run has its result carried across (see `actionResults` in entry.rsc.tsx), and the\n // ways a *caller* can get a request wrong are refused ahead of any render — an unknown id or an\n // undecodable body is a `text/plain` 400, which `payloadResponse` turns into an error of its own\n // before this.\n //\n // What is left is the server failing before the action ran, which is answered with the `error` page —\n // a flight payload, so it arrives here rather than at `payloadResponse`, with no `returnValue` in it.\n // A module the deployment no longer holds is the reachable case: `loadServerAction` throws, the\n // framework reports it and 500s, and this is what the caller has to go on. Hence the message: the\n // failure is on the server and its log is where the error is. Below that it is still the defensive\n // floor for a payload shaped by another deployment or replaced by a proxy — reading `.ok` off it used\n // to hand the caller `Cannot read properties of undefined`.\n throw new Error(\n '[rshono] the server action produced no result — the request failed around it and the server answered with a page instead. Its log has the error.',\n );\n }\n if (!result.ok) throw result.error;\n return result.value;\n });\n\n // A `redirect()` / `notFound()` from a component below the page root reaches us through React: it rides the\n // flight payload as an error, and boundaries re-throw it so it lands here rather than in a fallback.\n //\n // Installing these hooks opts out of React's own defaults, so everything that isn't a control signal has to\n // be put back by hand — `reportError` rather than a bare log, so error-reporting tools still see it.\n hydrateRoot(document, <BrowserRoot />, {\n formState: initialPayload.formState,\n onCaughtError: (error, errorInfo) => {\n if (handleControlDigest(error, { hard: true })) return;\n // A boundary handled it and the tree is intact, so no overlay over the app's own fallback.\n console.error(error, errorInfo.componentStack ?? '');\n },\n onUncaughtError: (error, errorInfo) => {\n if (handleControlDigest(error, { hard: true })) return;\n // Nothing caught it, so React tears the root down — and the root is `document`.\n globalThis.reportError(error);\n showFatal(error, errorInfo.componentStack);\n },\n });\n\n if (import.meta.webpackHot) {\n initDevRefresh();\n }\n}\n\n/**\n * Dev-only refresh client, listening to the CLI's SSE endpoint:\n *\n * client-built → hot-apply the waiting updates; anything the page can't be patched up to reloads.\n * rsc-update → server component code changed: re-fetch the flight payload, state preserved.\n * hello → sent on (re)connect with the latest build hash; a mismatch means a missed event.\n */\nfunction initDevRefresh() {\n const hot = import.meta.webpackHot!;\n let connectedOnce = false;\n /** The newest build the dev server has announced — what {@link applyClientUpdate} walks towards. */\n let targetHash: string | undefined;\n\n function reload(reason: string, error?: unknown): void {\n console.warn(`[rshono] ${reason} — reloading`, ...(error === undefined ? [] : [error]));\n loadDocument();\n }\n\n async function applyClientUpdate(): Promise<void> {\n const giveUp = await walkHotUpdates(\n hot,\n () => __webpack_hash__,\n () => targetHash,\n );\n if (giveUp) reload(giveUp.reason, giveUp.error);\n }\n\n async function handle(message: DevMessage): Promise<void> {\n switch (message.type) {\n case 'hello':\n targetHash = message.hash ?? targetHash;\n if (connectedOnce) {\n await applyClientUpdate();\n await loadPayload(window.location.href).catch(() => loadDocument());\n }\n connectedOnce = true;\n break;\n case 'client-built':\n targetHash = message.hash;\n await applyClientUpdate();\n break;\n case 'rsc-update':\n console.log('[rshono] server components updated');\n await loadPayload(window.location.href).catch(() => loadDocument());\n break;\n }\n }\n\n const source = new EventSource('/_rshono/hmr');\n // Chained rather than handled as they arrive: `hot.check` may only run from `idle`, and a burst of saves\n // puts several frames on the wire inside the time one takes. Queueing drops nothing, because `targetHash`\n // is shared — whichever handler runs next walks to the newest build.\n let queue: Promise<void> = Promise.resolve();\n source.onmessage = (event: MessageEvent<string>) => {\n const message = JSON.parse(event.data) as DevMessage;\n queue = queue.then(() => handle(message)).catch((error) => reload('the dev client failed', error));\n };\n}\n\n// A bootstrap failure — a truncated initial payload, most likely — would otherwise be an unhandled\n// rejection: nothing hydrates, nothing is reported, and the page just sits there.\nmain().catch((error) => {\n console.error('[rshono] the client runtime failed to start:', error);\n showFatal(error);\n});\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rshono/core",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.22",
|
|
4
4
|
"description": "Minimalist web framework — Hono + Rspack + React Server Components",
|
|
5
5
|
"author": "Lasse <lasse@lassetange.com> (https://www.lassetange.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,17 +52,17 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@hono/node-server": "^2.1.1",
|
|
55
|
-
"@rspack/core": "2.2.
|
|
55
|
+
"@rspack/core": "2.2.6",
|
|
56
56
|
"@rspack/plugin-react-refresh": "2.0.2",
|
|
57
57
|
"react-refresh": "0.18.0",
|
|
58
58
|
"react-server-dom-rspack": "0.1.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@playwright/test": "^1.
|
|
62
|
-
"@types/node": "^26.
|
|
61
|
+
"@playwright/test": "^1.63.0",
|
|
62
|
+
"@types/node": "^26.5.1",
|
|
63
63
|
"@types/react": "^19.2.18",
|
|
64
64
|
"@types/react-dom": "^19.2.5",
|
|
65
|
-
"hono": "^4.13.
|
|
65
|
+
"hono": "^4.13.7",
|
|
66
66
|
"react": "19.2.8",
|
|
67
67
|
"react-dom": "19.2.8",
|
|
68
68
|
"typescript": "^7.0.2"
|