@rshono/core 1.0.0-rc.2 → 1.0.0-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/README.md +45 -29
  2. package/dist/builder/rspack-config.d.ts +3 -3
  3. package/dist/builder/rspack-config.js +3 -3
  4. package/dist/builder/rspack-config.js.map +1 -1
  5. package/dist/cli/build.d.ts +2 -2
  6. package/dist/cli/build.js.map +1 -1
  7. package/dist/cli/dev.d.ts +2 -2
  8. package/dist/cli/dev.js.map +1 -1
  9. package/dist/cli/index.js +11 -10
  10. package/dist/cli/index.js.map +1 -1
  11. package/dist/config.d.ts +4 -17
  12. package/dist/config.d.ts.map +1 -1
  13. package/dist/config.js.map +1 -1
  14. package/dist/deploy/cloudflare/build.js +1 -1
  15. package/dist/deploy/cloudflare/build.js.map +1 -1
  16. package/dist/deploy/cloudflare/runtime.d.ts.map +1 -1
  17. package/dist/deploy/cloudflare/runtime.js +7 -37
  18. package/dist/deploy/cloudflare/runtime.js.map +1 -1
  19. package/dist/deploy/contract.d.ts +14 -13
  20. package/dist/deploy/contract.d.ts.map +1 -1
  21. package/dist/deploy/contract.js.map +1 -1
  22. package/dist/deploy/filesystem.d.ts +1 -1
  23. package/dist/deploy/filesystem.d.ts.map +1 -1
  24. package/dist/deploy/filesystem.js +1 -3
  25. package/dist/deploy/filesystem.js.map +1 -1
  26. package/dist/deploy/node/runtime.d.ts +6 -2
  27. package/dist/deploy/node/runtime.d.ts.map +1 -1
  28. package/dist/deploy/node/runtime.js +30 -5
  29. package/dist/deploy/node/runtime.js.map +1 -1
  30. package/dist/deploy/presets.d.ts +5 -1
  31. package/dist/deploy/presets.d.ts.map +1 -1
  32. package/dist/deploy/presets.js +15 -28
  33. package/dist/deploy/presets.js.map +1 -1
  34. package/dist/deploy/vercel/runtime.d.ts.map +1 -1
  35. package/dist/deploy/vercel/runtime.js +0 -3
  36. package/dist/deploy/vercel/runtime.js.map +1 -1
  37. package/dist/index.d.ts +4 -9
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +6 -3
  40. package/dist/index.js.map +1 -1
  41. package/dist/router.d.ts +14 -15
  42. package/dist/router.d.ts.map +1 -1
  43. package/dist/router.js +5 -6
  44. package/dist/router.js.map +1 -1
  45. package/dist/runtime/client.d.ts +5 -6
  46. package/dist/runtime/client.d.ts.map +1 -1
  47. package/dist/runtime/client.js +5 -6
  48. package/dist/runtime/client.js.map +1 -1
  49. package/dist/runtime/context.d.ts +36 -40
  50. package/dist/runtime/context.d.ts.map +1 -1
  51. package/dist/runtime/context.js +41 -53
  52. package/dist/runtime/context.js.map +1 -1
  53. package/dist/runtime/entry.client.d.ts +4 -0
  54. package/dist/runtime/entry.client.d.ts.map +1 -1
  55. package/dist/runtime/entry.client.js +161 -147
  56. package/dist/runtime/entry.client.js.map +1 -1
  57. package/dist/runtime/entry.rsc.d.ts.map +1 -1
  58. package/dist/runtime/entry.rsc.js +80 -63
  59. package/dist/runtime/entry.rsc.js.map +1 -1
  60. package/dist/runtime/entry.ssr.d.ts +9 -1
  61. package/dist/runtime/entry.ssr.d.ts.map +1 -1
  62. package/dist/runtime/entry.ssr.js +36 -18
  63. package/dist/runtime/entry.ssr.js.map +1 -1
  64. package/dist/runtime/flight-inject.d.ts +31 -0
  65. package/dist/runtime/flight-inject.d.ts.map +1 -0
  66. package/dist/runtime/flight-inject.js +221 -0
  67. package/dist/runtime/flight-inject.js.map +1 -0
  68. package/dist/runtime/navigation.d.ts +10 -39
  69. package/dist/runtime/navigation.d.ts.map +1 -1
  70. package/dist/runtime/navigation.js +7 -53
  71. package/dist/runtime/navigation.js.map +1 -1
  72. package/dist/runtime/request.d.ts +6 -0
  73. package/dist/runtime/request.d.ts.map +1 -1
  74. package/dist/runtime/request.js +8 -0
  75. package/dist/runtime/request.js.map +1 -1
  76. package/dist/runtime/server.d.ts +2 -2
  77. package/dist/runtime/server.d.ts.map +1 -1
  78. package/dist/runtime/server.js +2 -2
  79. package/dist/runtime/server.js.map +1 -1
  80. package/dist/server/headers.d.ts +9 -9
  81. package/dist/server/headers.js +9 -9
  82. package/dist/server/headers.js.map +1 -1
  83. package/dist/server/load-config.d.ts +2 -2
  84. package/dist/server/load-config.d.ts.map +1 -1
  85. package/dist/server/load-config.js +22 -11
  86. package/dist/server/load-config.js.map +1 -1
  87. package/dist/server/prerendered.d.ts +52 -9
  88. package/dist/server/prerendered.d.ts.map +1 -1
  89. package/dist/server/prerendered.js +57 -0
  90. package/dist/server/prerendered.js.map +1 -1
  91. package/dist/server/server-config.d.ts +11 -18
  92. package/dist/server/server-config.d.ts.map +1 -1
  93. package/dist/server/server-config.js +9 -12
  94. package/dist/server/server-config.js.map +1 -1
  95. package/dist/server/ssg.d.ts +2 -2
  96. package/dist/server/ssg.d.ts.map +1 -1
  97. package/dist/server/ssg.js +11 -23
  98. package/dist/server/ssg.js.map +1 -1
  99. package/package.json +13 -16
  100. package/dist/deploy/bun/runtime.d.ts +0 -11
  101. package/dist/deploy/bun/runtime.d.ts.map +0 -1
  102. package/dist/deploy/bun/runtime.js +0 -22
  103. package/dist/deploy/bun/runtime.js.map +0 -1
  104. package/dist/deploy/deno/runtime.d.ts +0 -11
  105. package/dist/deploy/deno/runtime.d.ts.map +0 -1
  106. package/dist/deploy/deno/runtime.js +0 -16
  107. package/dist/deploy/deno/runtime.js.map +0 -1
  108. package/dist/deploy/listen.d.ts +0 -20
  109. package/dist/deploy/listen.d.ts.map +0 -1
  110. package/dist/deploy/listen.js +0 -24
  111. package/dist/deploy/listen.js.map +0 -1
  112. package/dist/deploy/netlify/build.d.ts +0 -8
  113. package/dist/deploy/netlify/build.d.ts.map +0 -1
  114. package/dist/deploy/netlify/build.js +0 -52
  115. package/dist/deploy/netlify/build.js.map +0 -1
  116. package/dist/deploy/netlify/runtime.d.ts +0 -13
  117. package/dist/deploy/netlify/runtime.d.ts.map +0 -1
  118. package/dist/deploy/netlify/runtime.js +0 -24
  119. package/dist/deploy/netlify/runtime.js.map +0 -1
  120. package/dist/server/compress.d.ts +0 -15
  121. package/dist/server/compress.d.ts.map +0 -1
  122. package/dist/server/compress.js +0 -76
  123. package/dist/server/compress.js.map +0 -1
@@ -2,11 +2,44 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import React from 'react';
3
3
  import { hydrateRoot } from 'react-dom/client';
4
4
  import { createFromFetch, createFromReadableStream, createTemporaryReferenceSet, encodeReply, setServerCallback, } from 'react-server-dom-rspack/client.browser';
5
- import { rscStream } from 'rsc-html-stream/client';
6
5
  import { isControlDigest, parseRedirectDigest } from './control.js';
7
6
  import { RouterContext } from './navigation.js';
8
7
  import { createRscRequest } from './request.js';
9
8
  const isDev = process.env.NODE_ENV === 'development';
9
+ /**
10
+ * The flight payload the document carried, read back out of `__FLIGHT_DATA`.
11
+ *
12
+ * The reader for the format `flight-inject.ts` writes — 14 lines, which is the whole reason neither
13
+ * half of `rsc-html-stream` is a dependency: its server half mishandles a split document trailer
14
+ * (see `flight-inject.ts`), and once that one is first-party, keeping the package for this one is a
15
+ * dependency for a `for` loop.
16
+ */
17
+ function readFlightPayload() {
18
+ const encoder = new TextEncoder();
19
+ // Assigned synchronously by `start`, which `new ReadableStream` runs before it returns.
20
+ let controller;
21
+ const stream = new ReadableStream({
22
+ start: (c) => void (controller = c),
23
+ });
24
+ const enqueue = (chunk) => controller.enqueue(typeof chunk === 'string' ? encoder.encode(chunk) : chunk);
25
+ // Payload scripts interleave with the document, so some have already run by the time this module
26
+ // is evaluated — those are in the array — and the rest run after it, arriving through `push`.
27
+ const data = (self.__FLIGHT_DATA ??= []);
28
+ for (const chunk of data)
29
+ enqueue(chunk);
30
+ data.push = enqueue;
31
+ // The last payload script lands before the document finishes parsing, so that is what says there
32
+ // is no more of it to come.
33
+ if (document.readyState === 'loading') {
34
+ document.addEventListener('DOMContentLoaded', () => controller.close(), { once: true });
35
+ }
36
+ else {
37
+ controller.close();
38
+ }
39
+ return stream;
40
+ }
41
+ /** Created at module evaluation, not inside `main()`, so no chunk can be pushed before it is watching. */
42
+ const flightStream = readFlightPayload();
10
43
  /**
11
44
  * Guarantees somewhere to attach the fatal overlay. React's root container is the whole `document`,
12
45
  * so by the time an uncaught error has torn the tree down, `<body>` — or even `<html>` — may be gone.
@@ -68,48 +101,18 @@ function showFatal(error, componentStack) {
68
101
  host.appendChild(box);
69
102
  }, 0);
70
103
  }
71
- // In-memory flight-payload cache keyed by same-origin path+search. `data-prefetch`
72
- // links warm it on hover/focus; a navigation to a warmed URL resolves instantly and
73
- // clears the entry (a prefetch is used at most once, so re-visits always re-fetch).
74
- const payloadCache = new Map();
75
- // Bounded so a long session over a link-dense app can't grow it without limit. Insertion-ordered,
76
- // so the first key is the least recently warmed.
77
- const MAX_WARMED_PAYLOADS = 8;
78
- function cacheKey(href) {
79
- const url = new URL(href, location.href);
80
- if (url.origin !== location.origin)
81
- return null;
82
- return url.pathname + url.search;
83
- }
104
+ /**
105
+ * Asks a URL for its flight payload.
106
+ *
107
+ * There is no cache in front of this any more. A `data-prefetch` attribute used to warm one on
108
+ * hover/focus, keyed by same-origin path+search and bounded to 8 entries worth knowing about if you
109
+ * are wondering where the speculative fetching went. Every navigation is now a fetch at the moment it
110
+ * is asked for, so a payload can never be staler than the click that wanted it, and the browser's own
111
+ * HTTP cache is what makes a repeat visit cheap.
112
+ */
84
113
  function requestPayload(href) {
85
114
  return createFromFetch(fetch(createRscRequest(new URL(href, location.href).href)));
86
115
  }
87
- function warmPayload(href) {
88
- const key = cacheKey(href);
89
- if (!key || key === cacheKey(location.href) || payloadCache.has(key))
90
- return;
91
- const promise = requestPayload(href);
92
- payloadCache.set(key, promise);
93
- // One entry in means at most one out, and the first key is the oldest.
94
- if (payloadCache.size > MAX_WARMED_PAYLOADS)
95
- payloadCache.delete(payloadCache.keys().next().value);
96
- // Don't cache failures, and swallow the rejection until (or unless) a nav awaits it.
97
- promise.catch(() => {
98
- if (payloadCache.get(key) === promise)
99
- payloadCache.delete(key);
100
- });
101
- }
102
- function takePayload(href) {
103
- const key = cacheKey(href);
104
- if (key) {
105
- const cached = payloadCache.get(key);
106
- if (cached) {
107
- payloadCache.delete(key);
108
- return cached;
109
- }
110
- }
111
- return requestPayload(href);
112
- }
113
116
  async function main() {
114
117
  const cspMeta = document.querySelector('meta[property="csp-nonce"]');
115
118
  if (cspMeta?.nonce)
@@ -124,7 +127,7 @@ async function main() {
124
127
  let startNav = (run) => {
125
128
  void run();
126
129
  };
127
- const initialPayload = await createFromReadableStream(rscStream);
130
+ const initialPayload = await createFromReadableStream(flightStream);
128
131
  function push(href) {
129
132
  const target = new URL(href, window.location.href);
130
133
  if (target.origin !== window.location.origin) {
@@ -141,12 +144,11 @@ async function main() {
141
144
  }
142
145
  window.history.replaceState(null, '', target.href);
143
146
  }
144
- const back = () => window.history.back();
145
- const forward = () => window.history.forward();
146
- // A refresh keeps the URL, so it can't ride the history patch like push/replace — it drives the flight re-fetch directly (bypassing any warmed cache to get fresh data).
147
+ // A refresh keeps the URL, so it can't ride the history patch like push/replace — it drives the
148
+ // flight re-fetch directly.
147
149
  const refresh = () => startNav(async () => {
148
150
  try {
149
- await fetchRscPayload(true);
151
+ await fetchRscPayload();
150
152
  }
151
153
  catch {
152
154
  window.location.reload();
@@ -177,10 +179,10 @@ async function main() {
177
179
  }
178
180
  return true;
179
181
  }
180
- async function fetchRscPayload(force = false) {
182
+ async function fetchRscPayload() {
181
183
  let payload;
182
184
  try {
183
- payload = await (force ? requestPayload(window.location.href) : takePayload(window.location.href));
185
+ payload = await requestPayload(window.location.href);
184
186
  }
185
187
  catch (error) {
186
188
  if (handleControlDigest(error))
@@ -198,16 +200,23 @@ async function main() {
198
200
  setPayload = (v) => setPayloadState(v);
199
201
  startNav = (run) => startTransition(run);
200
202
  }, [startTransition]);
201
- React.useEffect(() => listenNavigation((restoreScroll) => startNav(async () => {
202
- try {
203
- await fetchRscPayload();
204
- restoreScroll();
205
- }
206
- catch {
207
- window.location.reload();
208
- }
209
- }), warmPayload), []);
210
- const router = React.useMemo(() => ({ push, replace, back, forward, refresh, pending }), [pending]);
203
+ React.useEffect(() => {
204
+ const stopNavigating = listenNavigation((afterRender) => startNav(async () => {
205
+ try {
206
+ await fetchRscPayload();
207
+ afterRender();
208
+ }
209
+ catch {
210
+ window.location.reload();
211
+ }
212
+ }));
213
+ const stopUpgradingLinks = listenLinks();
214
+ return () => {
215
+ stopUpgradingLinks();
216
+ stopNavigating();
217
+ };
218
+ }, []);
219
+ const router = React.useMemo(() => ({ push, replace, refresh, pending }), [pending]);
211
220
  return _jsx(RouterContext.Provider, { value: router, children: payload.root });
212
221
  }
213
222
  setServerCallback(async (id, args) => {
@@ -216,9 +225,6 @@ async function main() {
216
225
  id,
217
226
  body: await encodeReply(args, { temporaryReferences }),
218
227
  });
219
- // The action is about to mutate who-knows-what, so anything warmed up to now is pre-mutation
220
- // data. Cleared before the round-trip so it happens even if the action throws.
221
- payloadCache.clear();
222
228
  let payload;
223
229
  try {
224
230
  payload = await createFromFetch(fetch(request), { temporaryReferences });
@@ -267,15 +273,20 @@ async function main() {
267
273
  },
268
274
  });
269
275
  if (import.meta.webpackHot) {
270
- // Server code may have changed, so drop any warmed payloads and re-fetch fresh.
271
- initDevRefresh(() => {
272
- payloadCache.clear();
273
- return fetchRscPayload(true);
274
- });
276
+ initDevRefresh(fetchRscPayload);
275
277
  }
276
278
  }
277
- /** Hover/focus dwell time before a `data-prefetch` link warms its payload. */
278
- const PREFETCH_DELAY_MS = 120;
279
+ /**
280
+ * Runs teardown in reverse and empties the list, so a second call is a no-op.
281
+ *
282
+ * Collecting these as setup goes keeps each undo next to the thing it undoes: a listener added
283
+ * without one is visible on the spot, rather than as a leak found later against a teardown block
284
+ * that drifted out of sync.
285
+ */
286
+ function disposeAll(undo) {
287
+ for (const dispose of undo.splice(0).reverse())
288
+ dispose();
289
+ }
279
290
  // An `<a>` we intercept for soft navigation: same-origin, same tab, not a download,
280
291
  // and not explicitly opted out with `data-native` (which forces a full browser navigation).
281
292
  function isRouterLink(link) {
@@ -285,61 +296,15 @@ function isRouterLink(link) {
285
296
  !link.hasAttribute('download') &&
286
297
  !link.hasAttribute('data-native'));
287
298
  }
288
- function listenNavigation(onNavigation, prefetch) {
289
- // Scroll restoration. We tag each history entry with a stable numeric key in its
290
- // `history.state` and remember scrollY per key, so back/forward restores the exact
291
- // position while push scrolls to the top. `manual` hands restoration to us.
292
- const scrollByKey = new Map();
293
- let seq = 0;
294
- const prevRestoration = window.history.scrollRestoration;
295
- try {
296
- window.history.scrollRestoration = 'manual';
297
- }
298
- catch { }
299
- const keyOf = () => {
300
- const state = window.history.state;
301
- return state && typeof state.__rshonoScroll === 'number' ? state.__rshonoScroll : null;
302
- };
303
- const tag = (state, key) => ({ ...state, __rshonoScroll: key });
304
- if (keyOf() === null) {
305
- window.history.replaceState(tag(window.history.state, seq++), '');
306
- }
307
- let scrollRaf = 0;
308
- const onScroll = () => {
309
- if (scrollRaf)
310
- return;
311
- scrollRaf = requestAnimationFrame(() => {
312
- scrollRaf = 0;
313
- const key = keyOf();
314
- if (key !== null)
315
- scrollByKey.set(key, window.scrollY);
316
- });
317
- };
318
- window.addEventListener('scroll', onScroll, { passive: true });
319
- const restoreScrollFor = (type) => () => {
320
- if (type === 'replace')
321
- return;
322
- const key = keyOf();
323
- requestAnimationFrame(() => {
324
- const y = type === 'pop' && key !== null ? (scrollByKey.get(key) ?? 0) : 0;
325
- window.scrollTo(0, y);
326
- });
327
- };
328
- const notify = (type) => onNavigation(restoreScrollFor(type));
329
- const onPopState = () => notify('pop');
330
- window.addEventListener('popstate', onPopState);
331
- const oldPushState = window.history.pushState;
332
- window.history.pushState = function (state, unused, url) {
333
- const res = oldPushState.call(this, tag(state, seq++), unused, url);
334
- notify('push');
335
- return res;
336
- };
337
- const oldReplaceState = window.history.replaceState;
338
- window.history.replaceState = function (state, unused, url) {
339
- const res = oldReplaceState.call(this, tag(state, keyOf() ?? seq++), unused, url);
340
- notify('replace');
341
- return res;
342
- };
299
+ /**
300
+ * Upgrades the app's anchors: a plain left-click becomes a soft navigation.
301
+ *
302
+ * Kept apart from `listenNavigation` because the two share no state. A click here only calls
303
+ * `history.pushState` which is where that function picks the navigation up — so the whole contract
304
+ * between them is one global the browser already provides.
305
+ */
306
+ function listenLinks() {
307
+ const undo = [];
343
308
  function onClick(e) {
344
309
  const link = e.target.closest('a');
345
310
  if (link &&
@@ -358,37 +323,86 @@ function listenNavigation(onNavigation, prefetch) {
358
323
  }
359
324
  }
360
325
  document.addEventListener('click', onClick);
361
- // A prefetch is a full server render, so it waits out a short dwell time on one shared timer:
362
- // sweeping the cursor across a list of prefetch links costs one request (for the link the pointer
363
- // settled on), not one per link.
364
- let prefetchTimer;
365
- function onPrefetch(e) {
366
- const target = e.target;
367
- if (!(target instanceof Element))
368
- return;
369
- const link = target.closest('a[data-prefetch]');
370
- if (!(link instanceof HTMLAnchorElement) || !isRouterLink(link))
371
- return;
372
- const { href } = link;
373
- clearTimeout(prefetchTimer);
374
- prefetchTimer = setTimeout(() => prefetch(href), PREFETCH_DELAY_MS);
326
+ undo.push(() => document.removeEventListener('click', onClick));
327
+ return () => disposeAll(undo);
328
+ }
329
+ function listenNavigation(onNavigation) {
330
+ const undo = [];
331
+ // Scroll restoration is the browser's. It used to be ours: each history entry was tagged with a key
332
+ // in `history.state`, `scrollY` was remembered per key, and `manual` handed restoration over — about
333
+ // 130 lines to restore a traversal exactly and to chase a `#hash` target across the frames before
334
+ // React had committed the new payload. `auto` is set explicitly rather than left at the default,
335
+ // because it is a statement: the browser remembers a traversal's offset for us.
336
+ const prevRestoration = window.history.scrollRestoration;
337
+ try {
338
+ window.history.scrollRestoration = 'auto';
375
339
  }
376
- document.addEventListener('pointerover', onPrefetch);
377
- document.addEventListener('focusin', onPrefetch);
378
- return () => {
379
- clearTimeout(prefetchTimer);
380
- document.removeEventListener('click', onClick);
381
- document.removeEventListener('pointerover', onPrefetch);
382
- document.removeEventListener('focusin', onPrefetch);
383
- window.removeEventListener('popstate', onPopState);
384
- window.removeEventListener('scroll', onScroll);
385
- window.history.pushState = oldPushState;
386
- window.history.replaceState = oldReplaceState;
340
+ catch { }
341
+ undo.push(() => {
387
342
  try {
388
343
  window.history.scrollRestoration = prevRestoration;
389
344
  }
390
345
  catch { }
346
+ });
347
+ /**
348
+ * A push is not a real navigation as far as the browser is concerned, so nothing resets the scroll
349
+ * offset — a click through to a new page would otherwise land wherever the last one was scrolled to.
350
+ * `replace` keeps its position deliberately, and a traversal is the browser's to restore.
351
+ *
352
+ * Deferred a frame because the payload is *set* before React commits it, so the layout being scrolled
353
+ * is still the outgoing one until one has passed.
354
+ *
355
+ * A `#hash` on a cross-page link is no longer chased: the target does not exist until the new payload
356
+ * commits, and following it was the other half of what came out with the scroll memory.
357
+ */
358
+ const afterRenderFor = (type) => () => {
359
+ if (type !== 'push')
360
+ return;
361
+ requestAnimationFrame(() => window.scrollTo(0, 0));
391
362
  };
363
+ const documentUrl = () => location.pathname + location.search;
364
+ // What the payload on screen was rendered for. Only the document part: the server never sees the
365
+ // fragment, so two URLs differing by one render identically.
366
+ let renderedUrl = documentUrl();
367
+ /**
368
+ * A navigation that moves only the fragment — `#a` → `#b`, or back out of a same-page anchor —
369
+ * leaves the document unchanged, so the payload already on screen is the right one. Fetching
370
+ * another would be a wasted round-trip that re-renders the page out from under the jump.
371
+ *
372
+ * `router.refresh()` is unaffected: it drives the re-fetch directly rather than through here, and
373
+ * remains the way to ask for fresh data at an unchanged URL.
374
+ */
375
+ const notify = (type) => {
376
+ const afterRender = afterRenderFor(type);
377
+ if (documentUrl() === renderedUrl) {
378
+ afterRender();
379
+ return;
380
+ }
381
+ renderedUrl = documentUrl();
382
+ onNavigation(afterRender);
383
+ };
384
+ const onPopState = () => notify('pop');
385
+ window.addEventListener('popstate', onPopState);
386
+ undo.push(() => window.removeEventListener('popstate', onPopState));
387
+ const oldPushState = window.history.pushState;
388
+ window.history.pushState = function (state, unused, url) {
389
+ const res = oldPushState.call(this, state, unused, url);
390
+ notify('push');
391
+ return res;
392
+ };
393
+ undo.push(() => {
394
+ window.history.pushState = oldPushState;
395
+ });
396
+ const oldReplaceState = window.history.replaceState;
397
+ window.history.replaceState = function (state, unused, url) {
398
+ const res = oldReplaceState.call(this, state, unused, url);
399
+ notify('replace');
400
+ return res;
401
+ };
402
+ undo.push(() => {
403
+ window.history.replaceState = oldReplaceState;
404
+ });
405
+ return () => disposeAll(undo);
392
406
  }
393
407
  /**
394
408
  * Dev-only refresh client (stripped from prod bundles: the whole call is
@@ -1 +1 @@
1
- {"version":3,"file":"entry.client.js","sourceRoot":"","sources":["../../src/runtime/entry.client.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,2BAA2B,EAC3B,WAAW,EACX,iBAAiB,GAClB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGpE,OAAO,EAAE,aAAa,EAAe,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC;AAErD;;;GAGG;AACH,SAAS,WAAW;IAClB,IAAI,CAAC,QAAQ,CAAC,eAAe;QAAE,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IACpF,IAAI,CAAC,QAAQ,CAAC,IAAI;QAAE,QAAQ,CAAC,eAAe,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IACzF,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC;AAED;;;;;;;;;;GAUG;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AO;gBACV,IAAI,aAAa,EAAE,CAAC;oBAClB,IAAI,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,KAAK,gBAAgB;wBAAE,MAAM,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;oBAC7F,MAAM,eAAe,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;gBAChE,CAAC;gBACD,aAAa,GAAG,IAAI,CAAC;gBACrB,MAAM;YACR,KAAK,cAAc;gBACjB,IAAI,OAAO,CAAC,IAAI;oBAAE,MAAM,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACxD,MAAM;YACR,KAAK,YAAY;gBACf,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;gBAClD,MAAM,eAAe,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;gBAC9D,MAAM;QACV,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,oGAAoG;AACpG,kGAAkG;AAClG,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 { rscStream } from 'rsc-html-stream/client';\nimport { isControlDigest, parseRedirectDigest } from './control.js';\nimport type { DevMessage } from './dev-protocol.js';\nimport type { RscPayload } from './entry.rsc.js';\nimport { RouterContext, type Router } from './navigation.js';\nimport { createRscRequest } from './request.js';\n\nconst isDev = process.env.NODE_ENV === 'development';\n\n/**\n * Guarantees somewhere to attach the fatal overlay. React's root container is the whole `document`,\n * so by the time an uncaught error has torn the tree down, `<body>` — or even `<html>` — may be gone.\n */\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 * Replaces the white screen of death with something readable.\n *\n * Because the root container is `document`, an uncaught render error leaves a genuinely blank page\n * with the reason only in the console — so this paints the reason over it instead. In development\n * that's the full stack; in production it's a generic notice plus a reload button, since the tree is\n * unrecoverable and reloading is the only way forward.\n *\n * Written with DOM calls rather than React (the renderer is what just failed) and `textContent`\n * rather than `innerHTML` (an error message is untrusted input).\n */\nfunction showFatal(error: unknown, componentStack?: string | null): void {\n // Queued rather than run inline: React's teardown happens after this callback returns, and would\n // remove a node appended synchronously along with the rest of the tree.\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'); // the page is gone; announce it rather than leaving silence\n box.style.cssText =\n 'position:fixed;inset:0;z-index:2147483647;overflow:auto;padding:1.5rem;background:#18181b;color:#f4f4f5;' +\n 'font:14px/1.6 ui-monospace,SFMono-Regular,Menlo,monospace;text-align:left';\n\n const title = document.createElement('div');\n title.textContent = isDev ? 'Unhandled error' : 'Something went wrong';\n title.style.cssText = 'font-size:1.0625rem;font-weight:700;color:#f87171;margin:0 0 0.75rem';\n box.appendChild(title);\n\n if (isDev) {\n const detail = document.createElement('pre');\n detail.style.cssText = 'margin:0;white-space:pre-wrap;word-break:break-word';\n detail.textContent =\n (error instanceof Error ? (error.stack ?? `${error.name}: ${error.message}`) : String(error)) +\n (componentStack ? `\\n\\nComponent stack:${componentStack}` : '');\n box.appendChild(detail);\n } else {\n const message = document.createElement('p');\n message.textContent = 'This page hit an unexpected error and can’t continue.';\n message.style.cssText = 'margin:0 0 1rem;color:#d4d4d8';\n box.appendChild(message);\n }\n\n const reload = document.createElement('button');\n reload.textContent = 'Reload page';\n reload.style.cssText =\n 'margin-top:1.25rem;padding:0.5rem 1rem;font:inherit;color:#18181b;background:#f4f4f5;border:0;border-radius:4px;cursor:pointer';\n reload.addEventListener('click', () => window.location.reload());\n box.appendChild(reload);\n\n host.appendChild(box);\n }, 0);\n}\n\n// In-memory flight-payload cache keyed by same-origin path+search. `data-prefetch`\n// links warm it on hover/focus; a navigation to a warmed URL resolves instantly and\n// clears the entry (a prefetch is used at most once, so re-visits always re-fetch).\nconst payloadCache = new Map<string, Promise<RscPayload>>();\n\n// Bounded so a long session over a link-dense app can't grow it without limit. Insertion-ordered,\n// so the first key is the least recently warmed.\nconst MAX_WARMED_PAYLOADS = 8;\n\nfunction cacheKey(href: string): string | null {\n const url = new URL(href, location.href);\n if (url.origin !== location.origin) return null;\n return url.pathname + url.search;\n}\n\nfunction requestPayload(href: string): Promise<RscPayload> {\n return createFromFetch<RscPayload>(fetch(createRscRequest(new URL(href, location.href).href)));\n}\n\nfunction warmPayload(href: string): void {\n const key = cacheKey(href);\n if (!key || key === cacheKey(location.href) || payloadCache.has(key)) return;\n const promise = requestPayload(href);\n payloadCache.set(key, promise);\n // One entry in means at most one out, and the first key is the oldest.\n if (payloadCache.size > MAX_WARMED_PAYLOADS) payloadCache.delete(payloadCache.keys().next().value!);\n // Don't cache failures, and swallow the rejection until (or unless) a nav awaits it.\n promise.catch(() => {\n if (payloadCache.get(key) === promise) payloadCache.delete(key);\n });\n}\n\nfunction takePayload(href: string): Promise<RscPayload> {\n const key = cacheKey(href);\n if (key) {\n const cached = payloadCache.get(key);\n if (cached) {\n payloadCache.delete(key);\n return cached;\n }\n }\n return requestPayload(href);\n}\n\nasync function main() {\n const cspMeta = document.querySelector('meta[property=\"csp-nonce\"]') as HTMLMetaElement | null;\n if (cspMeta?.nonce) __webpack_nonce__ = cspMeta.nonce;\n\n // Both are replaced by BrowserRoot's own on mount. The defaults matter: `setServerCallback` is\n // registered before hydration, so an action or refresh firing in that window would otherwise call\n // an unassigned binding. Until there's a root to update, a full reload is the honest fallback.\n let setPayload: (v: RscPayload) => void = () => {\n window.location.reload();\n };\n // Runs work inside the nav transition so useNavigation().pending stays true across the round-trip.\n let startNav: (run: () => void | Promise<void>) => void = (run) => {\n void run();\n };\n\n const initialPayload = await createFromReadableStream<RscPayload>(rscStream);\n\n function push(href: string) {\n const target = new URL(href, window.location.href);\n if (target.origin !== window.location.origin) {\n window.location.assign(target.href);\n return;\n }\n window.history.pushState(null, '', target.href);\n }\n\n function replace(href: string) {\n const target = new URL(href, window.location.href);\n if (target.origin !== window.location.origin) {\n window.location.replace(target.href);\n return;\n }\n window.history.replaceState(null, '', target.href);\n }\n\n const back = () => window.history.back();\n const forward = () => window.history.forward();\n // A refresh keeps the URL, so it can't ride the history patch like push/replace — it drives the flight re-fetch directly (bypassing any warmed cache to get fresh data).\n const refresh = () =>\n startNav(async () => {\n try {\n await fetchRscPayload(true);\n } catch {\n window.location.reload();\n }\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 can fall through to their own handling.\n *\n * `hard` forces a full document load, for signals that surfaced *through React* (a nested\n * component's redirect, reported via the root error handlers). React unmounts the root on an\n * uncaught error, so there is no live tree left to soft-navigate with. A signal caught earlier —\n * a top-level payload rejection — still swaps the payload in place.\n */\n function handleControlDigest(error: unknown, { hard = false }: { hard?: boolean } = {}): boolean {\n const digest = (error as { digest?: unknown } | null)?.digest;\n if (!isControlDigest(digest)) return false;\n const redirect = parseRedirectDigest(digest);\n if (!redirect) {\n window.location.reload();\n } else if (hard) {\n window.location.assign(new URL(redirect.location, window.location.href).href);\n } else {\n push(redirect.location);\n }\n return true;\n }\n\n async function fetchRscPayload(force = false) {\n let payload: RscPayload;\n try {\n payload = await (force ? requestPayload(window.location.href) : takePayload(window.location.href));\n } catch (error) {\n if (handleControlDigest(error)) return;\n throw error;\n }\n if (payload.redirect) return push(payload.redirect);\n setPayload(payload);\n }\n\n function BrowserRoot() {\n const [payload, setPayloadState] = React.useState(initialPayload);\n const [pending, startTransition] = React.useTransition();\n\n React.useEffect(() => {\n setPayload = (v) => setPayloadState(v);\n startNav = (run) => startTransition(run);\n }, [startTransition]);\n\n React.useEffect(\n () =>\n listenNavigation(\n (restoreScroll) =>\n startNav(async () => {\n try {\n await fetchRscPayload();\n restoreScroll();\n } catch {\n window.location.reload();\n }\n }),\n warmPayload,\n ),\n [],\n );\n\n const router = React.useMemo<Router>(() => ({ 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 const request = createRscRequest(window.location.href, {\n id,\n body: await encodeReply(args, { temporaryReferences }),\n });\n // The action is about to mutate who-knows-what, so anything warmed up to now is pre-mutation\n // data. Cleared before the round-trip so it happens even if the action throws.\n payloadCache.clear();\n let payload: RscPayload;\n try {\n payload = await createFromFetch<RscPayload>(fetch(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 React.startTransition(() => setPayload(payload));\n if (payload.notFound) return undefined;\n const result = payload.returnValue!;\n if (!result.ok) throw result.error;\n return result.value;\n });\n\n // A `redirect()` / `notFound()` from a component *below* the page root can only reach us through\n // React: it rides the flight payload as an error at that component's position, and boundaries\n // re-throw it (see boundaries.tsx) so it lands here rather than rendering an error fallback.\n //\n // Anything that isn't a control signal falls back to what React would have done on its own —\n // console for a caught error, `reportError` (i.e. window.onerror, so error-reporting tools still\n // see it) for an uncaught one. Overriding these hooks means opting out of that default, so it has\n // to be put back by hand.\n hydrateRoot(document, <BrowserRoot />, {\n formState: initialPayload.formState,\n onCaughtError: (error, errorInfo) => {\n if (handleControlDigest(error, { hard: true })) return;\n // A boundary handled this and the tree is intact, so no overlay: whatever fallback the app\n // chose is the right thing to have on screen.\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`. This is the\n // white screen; paint the reason over it.\n globalThis.reportError(error);\n showFatal(error, errorInfo.componentStack);\n },\n });\n\n if (import.meta.webpackHot) {\n // Server code may have changed, so drop any warmed payloads and re-fetch fresh.\n initDevRefresh(() => {\n payloadCache.clear();\n return fetchRscPayload(true);\n });\n }\n}\n\ntype NavigationType = 'push' | 'replace' | 'pop';\n\n/** Hover/focus dwell time before a `data-prefetch` link warms its payload. */\nconst PREFETCH_DELAY_MS = 120;\n\n// An `<a>` we intercept for soft navigation: same-origin, same tab, not a download,\n// and not explicitly opted out with `data-native` (which forces a full browser navigation).\nfunction isRouterLink(link: HTMLAnchorElement): boolean {\n return (\n !!link.href &&\n (!link.target || link.target === '_self') &&\n link.origin === location.origin &&\n !link.hasAttribute('download') &&\n !link.hasAttribute('data-native')\n );\n}\n\nfunction listenNavigation(onNavigation: (restoreScroll: () => void) => void, prefetch: (href: string) => void): () => void {\n // Scroll restoration. We tag each history entry with a stable numeric key in its\n // `history.state` and remember scrollY per key, so back/forward restores the exact\n // position while push scrolls to the top. `manual` hands restoration to us.\n const scrollByKey = new Map<number, number>();\n let seq = 0;\n const prevRestoration = window.history.scrollRestoration;\n try {\n window.history.scrollRestoration = 'manual';\n } catch {}\n\n const keyOf = (): number | null => {\n const state = window.history.state as { __rshonoScroll?: unknown } | null;\n return state && typeof state.__rshonoScroll === 'number' ? state.__rshonoScroll : null;\n };\n const tag = (state: unknown, key: number) => ({ ...(state as object | null), __rshonoScroll: key });\n\n if (keyOf() === null) {\n window.history.replaceState(tag(window.history.state, seq++), '');\n }\n\n let scrollRaf = 0;\n const onScroll = () => {\n if (scrollRaf) return;\n scrollRaf = requestAnimationFrame(() => {\n scrollRaf = 0;\n const key = keyOf();\n if (key !== null) scrollByKey.set(key, window.scrollY);\n });\n };\n window.addEventListener('scroll', onScroll, { passive: true });\n\n const restoreScrollFor = (type: NavigationType) => () => {\n if (type === 'replace') return;\n const key = keyOf();\n requestAnimationFrame(() => {\n const y = type === 'pop' && key !== null ? (scrollByKey.get(key) ?? 0) : 0;\n window.scrollTo(0, y);\n });\n };\n const notify = (type: NavigationType) => onNavigation(restoreScrollFor(type));\n\n const onPopState = () => notify('pop');\n window.addEventListener('popstate', onPopState);\n\n const oldPushState = window.history.pushState;\n window.history.pushState = function (state, unused, url) {\n const res = oldPushState.call(this, tag(state, seq++), unused, url as string);\n notify('push');\n return res;\n };\n\n const oldReplaceState = window.history.replaceState;\n window.history.replaceState = function (state, unused, url) {\n const res = oldReplaceState.call(this, tag(state, keyOf() ?? seq++), unused, url as string);\n notify('replace');\n return res;\n };\n\n function onClick(e: MouseEvent) {\n const link = (e.target as Element).closest('a');\n if (\n link &&\n link instanceof HTMLAnchorElement &&\n isRouterLink(link) &&\n e.button === 0 &&\n !e.metaKey &&\n !e.ctrlKey &&\n !e.altKey &&\n !e.shiftKey &&\n !e.defaultPrevented\n ) {\n if (link.hash && link.pathname === location.pathname && link.search === location.search) return;\n e.preventDefault();\n history.pushState(null, '', link.href);\n }\n }\n document.addEventListener('click', onClick);\n\n // A prefetch is a full server render, so it waits out a short dwell time on one shared timer:\n // sweeping the cursor across a list of prefetch links costs one request (for the link the pointer\n // settled on), not one per link.\n let prefetchTimer: ReturnType<typeof setTimeout> | undefined;\n function onPrefetch(e: Event) {\n const target = e.target;\n if (!(target instanceof Element)) return;\n const link = target.closest('a[data-prefetch]');\n if (!(link instanceof HTMLAnchorElement) || !isRouterLink(link)) return;\n const { href } = link;\n clearTimeout(prefetchTimer);\n prefetchTimer = setTimeout(() => prefetch(href), PREFETCH_DELAY_MS);\n }\n document.addEventListener('pointerover', onPrefetch);\n document.addEventListener('focusin', onPrefetch);\n\n return () => {\n clearTimeout(prefetchTimer);\n document.removeEventListener('click', onClick);\n document.removeEventListener('pointerover', onPrefetch);\n document.removeEventListener('focusin', onPrefetch);\n window.removeEventListener('popstate', onPopState);\n window.removeEventListener('scroll', onScroll);\n window.history.pushState = oldPushState;\n window.history.replaceState = oldReplaceState;\n try {\n window.history.scrollRestoration = prevRestoration;\n } catch {}\n };\n}\n\n/**\n * Dev-only refresh client (stripped from prod bundles: the whole call is\n * guarded by import.meta.webpackHot). Listens to the CLI's SSE endpoint:\n *\n * client-built → hot-apply the waiting updates (react-refresh keeps\n * component state); any failure falls back to reload.\n * rsc-update → server component code changed: re-fetch the flight\n * payload for the current URL, state preserved.\n * hello → sent on (re)connect with the latest build hash; a\n * mismatch means events were missed — resync.\n */\nfunction initDevRefresh(fetchRscPayload: () => Promise<void>) {\n let connectedOnce = false;\n\n async function applyClientUpdate(hash: string) {\n const hot = import.meta.webpackHot!;\n if (hash === __webpack_hash__) return;\n if (hot.status() !== 'idle') {\n window.location.reload();\n return;\n }\n try {\n await hot.check(true);\n if (hash !== __webpack_hash__) await applyClientUpdate(hash);\n } catch (error) {\n console.warn('[rshono] hot update failed, reloading:', error);\n window.location.reload();\n }\n }\n\n const source = new EventSource('/_rshono/hmr');\n source.onmessage = async (event) => {\n const message = JSON.parse(event.data) as DevMessage;\n switch (message.type) {\n case 'hello':\n if (connectedOnce) {\n if (message.hash && message.hash !== __webpack_hash__) await applyClientUpdate(message.hash);\n await fetchRscPayload().catch(() => window.location.reload());\n }\n connectedOnce = true;\n break;\n case 'client-built':\n if (message.hash) await applyClientUpdate(message.hash);\n break;\n case 'rsc-update':\n console.log('[rshono] server components updated');\n await fetchRscPayload().catch(() => window.location.reload());\n break;\n }\n };\n}\n\n// Bootstrap failures (a truncated or malformed initial flight payload, most likely) would otherwise\n// be an unhandled 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":";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,CAAC,IAAI,KAAK,gBAAgB;wBAAE,MAAM,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;oBAC7F,MAAM,eAAe,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;gBAChE,CAAC;gBACD,aAAa,GAAG,IAAI,CAAC;gBACrB,MAAM;YACR,KAAK,cAAc;gBACjB,IAAI,OAAO,CAAC,IAAI;oBAAE,MAAM,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACxD,MAAM;YACR,KAAK,YAAY;gBACf,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;gBAClD,MAAM,eAAe,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;gBAC9D,MAAM;QACV,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,oGAAoG;AACpG,kGAAkG;AAClG,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';\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/**\n * The flight payload the document carried, read back out of `__FLIGHT_DATA`.\n *\n * The reader for the format `flight-inject.ts` writes — 14 lines, which is the whole reason neither\n * half of `rsc-html-stream` is a dependency: its server half mishandles a split document trailer\n * (see `flight-inject.ts`), and once that one is first-party, keeping the package for this one is a\n * dependency for a `for` loop.\n */\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, so some have already run by the time this module\n // is evaluated — those are in the array — and the rest run after it, arriving 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 the document finishes parsing, so that is what says there\n // is no more of it to come.\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 * Guarantees somewhere to attach the fatal overlay. React's root container is the whole `document`,\n * so by the time an uncaught error has torn the tree down, `<body>` — or even `<html>` — may be gone.\n */\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 * Replaces the white screen of death with something readable.\n *\n * Because the root container is `document`, an uncaught render error leaves a genuinely blank page\n * with the reason only in the console — so this paints the reason over it instead. In development\n * that's the full stack; in production it's a generic notice plus a reload button, since the tree is\n * unrecoverable and reloading is the only way forward.\n *\n * Written with DOM calls rather than React (the renderer is what just failed) and `textContent`\n * rather than `innerHTML` (an error message is untrusted input).\n */\nfunction showFatal(error: unknown, componentStack?: string | null): void {\n // Queued rather than run inline: React's teardown happens after this callback returns, and would\n // remove a node appended synchronously along with the rest of the tree.\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'); // the page is gone; announce it rather than leaving silence\n box.style.cssText =\n 'position:fixed;inset:0;z-index:2147483647;overflow:auto;padding:1.5rem;background:#18181b;color:#f4f4f5;' +\n 'font:14px/1.6 ui-monospace,SFMono-Regular,Menlo,monospace;text-align:left';\n\n const title = document.createElement('div');\n title.textContent = isDev ? 'Unhandled error' : 'Something went wrong';\n title.style.cssText = 'font-size:1.0625rem;font-weight:700;color:#f87171;margin:0 0 0.75rem';\n box.appendChild(title);\n\n if (isDev) {\n const detail = document.createElement('pre');\n detail.style.cssText = 'margin:0;white-space:pre-wrap;word-break:break-word';\n detail.textContent =\n (error instanceof Error ? (error.stack ?? `${error.name}: ${error.message}`) : String(error)) +\n (componentStack ? `\\n\\nComponent stack:${componentStack}` : '');\n box.appendChild(detail);\n } else {\n const message = document.createElement('p');\n message.textContent = 'This page hit an unexpected error and can’t continue.';\n message.style.cssText = 'margin:0 0 1rem;color:#d4d4d8';\n box.appendChild(message);\n }\n\n const reload = document.createElement('button');\n reload.textContent = 'Reload page';\n reload.style.cssText =\n 'margin-top:1.25rem;padding:0.5rem 1rem;font:inherit;color:#18181b;background:#f4f4f5;border:0;border-radius:4px;cursor:pointer';\n reload.addEventListener('click', () => window.location.reload());\n box.appendChild(reload);\n\n host.appendChild(box);\n }, 0);\n}\n\n/**\n * Asks a URL for its flight payload.\n *\n * There is no cache in front of this any more. A `data-prefetch` attribute used to warm one on\n * hover/focus, keyed by same-origin path+search and bounded to 8 entries — worth knowing about if you\n * are wondering where the speculative fetching went. Every navigation is now a fetch at the moment it\n * is asked for, so a payload can never be staler than the click that wanted it, and the browser's own\n * HTTP cache is what makes a repeat visit cheap.\n */\nfunction requestPayload(href: string): Promise<RscPayload> {\n return createFromFetch<RscPayload>(fetch(createRscRequest(new URL(href, location.href).href)));\n}\n\nasync function main() {\n const cspMeta = document.querySelector('meta[property=\"csp-nonce\"]') as HTMLMetaElement | null;\n if (cspMeta?.nonce) __webpack_nonce__ = cspMeta.nonce;\n\n // Both are replaced by BrowserRoot's own on mount. The defaults matter: `setServerCallback` is\n // registered before hydration, so an action or refresh firing in that window would otherwise call\n // an unassigned binding. Until there's a root to update, a full reload is the honest fallback.\n let setPayload: (v: RscPayload) => void = () => {\n window.location.reload();\n };\n // Runs work inside the nav transition so useNavigation().pending stays true across the round-trip.\n let startNav: (run: () => void | Promise<void>) => void = (run) => {\n void run();\n };\n\n const initialPayload = await createFromReadableStream<RscPayload>(flightStream);\n\n function push(href: string) {\n const target = new URL(href, window.location.href);\n if (target.origin !== window.location.origin) {\n window.location.assign(target.href);\n return;\n }\n window.history.pushState(null, '', target.href);\n }\n\n function replace(href: string) {\n const target = new URL(href, window.location.href);\n if (target.origin !== window.location.origin) {\n window.location.replace(target.href);\n return;\n }\n window.history.replaceState(null, '', target.href);\n }\n\n // A refresh keeps the URL, so it can't ride the history patch like push/replace — it drives the\n // flight re-fetch directly.\n const refresh = () =>\n startNav(async () => {\n try {\n await fetchRscPayload();\n } catch {\n window.location.reload();\n }\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 can fall through to their own handling.\n *\n * `hard` forces a full document load, for signals that surfaced *through React* (a nested\n * component's redirect, reported via the root error handlers). React unmounts the root on an\n * uncaught error, so there is no live tree left to soft-navigate with. A signal caught earlier —\n * a top-level payload rejection — still swaps the payload in place.\n */\n function handleControlDigest(error: unknown, { hard = false }: { hard?: boolean } = {}): boolean {\n const digest = (error as { digest?: unknown } | null)?.digest;\n if (!isControlDigest(digest)) return false;\n const redirect = parseRedirectDigest(digest);\n if (!redirect) {\n window.location.reload();\n } else if (hard) {\n window.location.assign(new URL(redirect.location, window.location.href).href);\n } else {\n push(redirect.location);\n }\n return true;\n }\n\n async function fetchRscPayload() {\n let payload: RscPayload;\n try {\n payload = await requestPayload(window.location.href);\n } catch (error) {\n if (handleControlDigest(error)) return;\n throw error;\n }\n if (payload.redirect) return push(payload.redirect);\n setPayload(payload);\n }\n\n function BrowserRoot() {\n const [payload, setPayloadState] = React.useState(initialPayload);\n const [pending, startTransition] = React.useTransition();\n\n React.useEffect(() => {\n setPayload = (v) => setPayloadState(v);\n startNav = (run) => startTransition(run);\n }, [startTransition]);\n\n React.useEffect(() => {\n const stopNavigating = listenNavigation((afterRender) =>\n startNav(async () => {\n try {\n await fetchRscPayload();\n afterRender();\n } catch {\n window.location.reload();\n }\n }),\n );\n const stopUpgradingLinks = listenLinks();\n return () => {\n stopUpgradingLinks();\n stopNavigating();\n };\n }, []);\n\n const router = React.useMemo<NavigationRouter>(() => ({ push, replace, 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 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>(fetch(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 React.startTransition(() => setPayload(payload));\n if (payload.notFound) return undefined;\n const result = payload.returnValue!;\n if (!result.ok) throw result.error;\n return result.value;\n });\n\n // A `redirect()` / `notFound()` from a component *below* the page root can only reach us through\n // React: it rides the flight payload as an error at that component's position, and boundaries\n // re-throw it (see boundaries.tsx) so it lands here rather than rendering an error fallback.\n //\n // Anything that isn't a control signal falls back to what React would have done on its own —\n // console for a caught error, `reportError` (i.e. window.onerror, so error-reporting tools still\n // see it) for an uncaught one. Overriding these hooks means opting out of that default, so it has\n // to be put back by hand.\n hydrateRoot(document, <BrowserRoot />, {\n formState: initialPayload.formState,\n onCaughtError: (error, errorInfo) => {\n if (handleControlDigest(error, { hard: true })) return;\n // A boundary handled this and the tree is intact, so no overlay: whatever fallback the app\n // chose is the right thing to have on screen.\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`. This is the\n // white screen; paint the reason over it.\n globalThis.reportError(error);\n showFatal(error, errorInfo.componentStack);\n },\n });\n\n if (import.meta.webpackHot) {\n initDevRefresh(fetchRscPayload);\n }\n}\n\ntype NavigationType = 'push' | 'replace' | 'pop';\n\n/**\n * Runs teardown in reverse and empties the list, so a second call is a no-op.\n *\n * Collecting these as setup goes keeps each undo next to the thing it undoes: a listener added\n * without one is visible on the spot, rather than as a leak found later against a teardown block\n * that drifted out of sync.\n */\nfunction disposeAll(undo: Array<() => void>): void {\n for (const dispose of undo.splice(0).reverse()) dispose();\n}\n\n// An `<a>` we intercept for soft navigation: same-origin, same tab, not a download,\n// and not explicitly opted out with `data-native` (which forces a full browser navigation).\nfunction isRouterLink(link: HTMLAnchorElement): boolean {\n return (\n !!link.href &&\n (!link.target || link.target === '_self') &&\n link.origin === location.origin &&\n !link.hasAttribute('download') &&\n !link.hasAttribute('data-native')\n );\n}\n\n/**\n * Upgrades the app's anchors: a plain left-click becomes a soft navigation.\n *\n * Kept apart from `listenNavigation` because the two share no state. A click here only calls\n * `history.pushState` — which is where that function picks the navigation up — so the whole contract\n * between them is one global the browser already provides.\n */\nfunction listenLinks(): () => void {\n const undo: Array<() => void> = [];\n\n function onClick(e: MouseEvent) {\n const link = (e.target as Element).closest('a');\n if (\n link &&\n link instanceof HTMLAnchorElement &&\n isRouterLink(link) &&\n e.button === 0 &&\n !e.metaKey &&\n !e.ctrlKey &&\n !e.altKey &&\n !e.shiftKey &&\n !e.defaultPrevented\n ) {\n if (link.hash && link.pathname === location.pathname && link.search === location.search) return;\n e.preventDefault();\n history.pushState(null, '', link.href);\n }\n }\n document.addEventListener('click', onClick);\n undo.push(() => document.removeEventListener('click', onClick));\n\n return () => disposeAll(undo);\n}\n\nfunction listenNavigation(onNavigation: (afterRender: () => void) => void): () => void {\n const undo: Array<() => void> = [];\n\n // Scroll restoration is the browser's. It used to be ours: each history entry was tagged with a key\n // in `history.state`, `scrollY` was remembered per key, and `manual` handed restoration over — about\n // 130 lines to restore a traversal exactly and to chase a `#hash` target across the frames before\n // React had committed the new payload. `auto` is set explicitly rather than left at the default,\n // because it is a statement: the browser remembers a traversal's offset for us.\n const prevRestoration = window.history.scrollRestoration;\n try {\n window.history.scrollRestoration = 'auto';\n } catch {}\n undo.push(() => {\n try {\n window.history.scrollRestoration = prevRestoration;\n } catch {}\n });\n\n /**\n * A push is not a real navigation as far as the browser is concerned, so nothing resets the scroll\n * offset — a click through to a new page would otherwise land wherever the last one was scrolled to.\n * `replace` keeps its position deliberately, and a traversal is the browser's to restore.\n *\n * Deferred a frame because the payload is *set* before React commits it, so the layout being scrolled\n * is still the outgoing one until one has passed.\n *\n * A `#hash` on a cross-page link is no longer chased: the target does not exist until the new payload\n * commits, and following it was the other half of what came out with the scroll memory.\n */\n const afterRenderFor = (type: NavigationType) => () => {\n if (type !== 'push') return;\n requestAnimationFrame(() => window.scrollTo(0, 0));\n };\n\n const documentUrl = () => location.pathname + location.search;\n\n // What the payload on screen was rendered for. Only the document part: the server never sees the\n // fragment, so two URLs differing by one render identically.\n let renderedUrl = documentUrl();\n\n /**\n * A navigation that moves only the fragment — `#a` → `#b`, or back out of a same-page anchor —\n * leaves the document unchanged, so the payload already on screen is the right one. Fetching\n * another would be a wasted round-trip that re-renders the page out from under the jump.\n *\n * `router.refresh()` is unaffected: it drives the re-fetch directly rather than through here, and\n * remains the way to ask for fresh data at an unchanged URL.\n */\n const notify = (type: NavigationType) => {\n const afterRender = afterRenderFor(type);\n if (documentUrl() === renderedUrl) {\n afterRender();\n return;\n }\n renderedUrl = documentUrl();\n onNavigation(afterRender);\n };\n\n const onPopState = () => notify('pop');\n window.addEventListener('popstate', onPopState);\n undo.push(() => window.removeEventListener('popstate', onPopState));\n\n const oldPushState = window.history.pushState;\n window.history.pushState = function (state, unused, url) {\n const res = oldPushState.call(this, state, unused, url as string);\n notify('push');\n return res;\n };\n undo.push(() => {\n window.history.pushState = oldPushState;\n });\n\n const oldReplaceState = window.history.replaceState;\n window.history.replaceState = function (state, unused, url) {\n const res = oldReplaceState.call(this, state, unused, url as string);\n notify('replace');\n return res;\n };\n undo.push(() => {\n window.history.replaceState = oldReplaceState;\n });\n\n return () => disposeAll(undo);\n}\n\n/**\n * Dev-only refresh client (stripped from prod bundles: the whole call is\n * guarded by import.meta.webpackHot). Listens to the CLI's SSE endpoint:\n *\n * client-built → hot-apply the waiting updates (react-refresh keeps\n * component state); any failure falls back to reload.\n * rsc-update → server component code changed: re-fetch the flight\n * payload for the current URL, state preserved.\n * hello → sent on (re)connect with the latest build hash; a\n * mismatch means events were missed — resync.\n */\nfunction initDevRefresh(fetchRscPayload: () => Promise<void>) {\n let connectedOnce = false;\n\n async function applyClientUpdate(hash: string) {\n const hot = import.meta.webpackHot!;\n if (hash === __webpack_hash__) return;\n if (hot.status() !== 'idle') {\n window.location.reload();\n return;\n }\n try {\n await hot.check(true);\n if (hash !== __webpack_hash__) await applyClientUpdate(hash);\n } catch (error) {\n console.warn('[rshono] hot update failed, reloading:', error);\n window.location.reload();\n }\n }\n\n const source = new EventSource('/_rshono/hmr');\n source.onmessage = async (event) => {\n const message = JSON.parse(event.data) as DevMessage;\n switch (message.type) {\n case 'hello':\n if (connectedOnce) {\n if (message.hash && message.hash !== __webpack_hash__) await applyClientUpdate(message.hash);\n await fetchRscPayload().catch(() => window.location.reload());\n }\n connectedOnce = true;\n break;\n case 'client-built':\n if (message.hash) await applyClientUpdate(message.hash);\n break;\n case 'rsc-update':\n console.log('[rshono] server components updated');\n await fetchRscPayload().catch(() => window.location.reload());\n break;\n }\n };\n}\n\n// Bootstrap failures (a truncated or malformed initial flight payload, most likely) would otherwise\n// be an unhandled 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 +1 @@
1
- {"version":3,"file":"entry.rsc.d.ts","sourceRoot":"","sources":["../../src/runtime/entry.rsc.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAwBvD,OAAO,EAAsF,KAAK,KAAK,EAAoB,MAAM,cAAc,CAAC;AAyChJ,eAAO,MAAM,MAAM,EAAE,SAAS,KAAK,EAAuB,CAAC;AAE3D,0HAA0H;AAC1H,MAAM,MAAM,YAAY,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAExF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAycF,eAAO,MAAM,GAAG,4EAAa,CAAC;AAE9B;;;;;;;GAOG"}
1
+ {"version":3,"file":"entry.rsc.d.ts","sourceRoot":"","sources":["../../src/runtime/entry.rsc.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBA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