@rsc-kit/core 0.20.10 → 0.20.11

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/dist/host.d.ts CHANGED
@@ -60,7 +60,16 @@ export interface RscEngine {
60
60
  handleRscResume?(component: string, props?: Record<string, unknown>, layouts?: {
61
61
  component: string;
62
62
  props: Record<string, unknown>;
63
- }[], loadings?: string[], parallelSlots?: Record<string, string>, slotOverrides?: Record<string, unknown>, postponed?: unknown, nonce?: string, pageKey?: string, pathname?: string | null): Promise<{
63
+ }[], loadings?: string[], parallelSlots?: Record<string, string>, slotOverrides?: Record<string, unknown>, postponed?: unknown, nonce?: string, pageKey?: string, pathname?: string | null,
64
+ /**
65
+ * The real params, for the holes.
66
+ *
67
+ * Separate from `props`, which is the shape the shell was frozen with.
68
+ * A pattern shell is rendered with a placeholder per param, and the
69
+ * resume has to render the same tree above the holes or React cannot
70
+ * line them up; the values the holes need travel here.
71
+ */
72
+ params?: Record<string, string>): Promise<{
64
73
  htmlStream: ReadableStream;
65
74
  }>;
66
75
  handleRscRevalidate?(target: string, page: unknown): Promise<{
package/dist/host.js CHANGED
@@ -14,7 +14,7 @@
14
14
  // const rsc = createRscHandler({ engine, manifest, assets })
15
15
  // Bun.serve({ fetch: (req) => rsc(req).then((r) => r ?? new Response('', { status: 404 })) })
16
16
  import { allowFor, matchApiRoute, matchIntercept, matchRoute, retentionKey, sharedDepth, } from "./routing.js";
17
- import { pathKey, patternKey } from "./prerender.js";
17
+ import { PARAM_PLACEHOLDER, pathKey, patternKey } from "./prerender.js";
18
18
  import { apiKey } from "./apiPrerender.js";
19
19
  import { hostPath, hostSegment, routableHost } from "./hostRouting.js";
20
20
  import { withRevalidation } from "./revalidate.js";
@@ -1034,7 +1034,19 @@ export function createRscHandler(options) {
1034
1034
  // good. Fall through and render the page now instead.
1035
1035
  if (state === null || !engine.handleRscResume || !route)
1036
1036
  return null;
1037
- const { htmlStream } = await engine.handleRscResume(route.route.component, route.params,
1037
+ // A shell stored for the pattern was frozen with a placeholder for
1038
+ // every param - the build had no url to render for - and the tree
1039
+ // above its holes was shaped by those. Handing the real ones back
1040
+ // here renders a different tree wherever anything branches on a
1041
+ // param above a boundary, and React refuses to line the slots up:
1042
+ // "Expected the resume to render <X> in this slot but instead it
1043
+ // rendered <Y>", every hole client-rendered, a production page that
1044
+ // arrives inert. So the resume gets the shape the shell had, and the
1045
+ // values go to the holes through `params`.
1046
+ const forShape = shellKey === key
1047
+ ? route.params
1048
+ : Object.fromEntries(Object.keys(route.params).map((name) => [name, PARAM_PLACEHOLDER]));
1049
+ const { htmlStream } = await engine.handleRscResume(route.route.component, forShape,
1038
1050
  // Empty props, because that is what the build passed. Resuming replays
1039
1051
  // the tree against the slots the shell left, and React matches those by
1040
1052
  // key — so an argument that differs from the frozen render at all is a
@@ -1046,7 +1058,7 @@ export function createRscHandler(options) {
1046
1058
  // key the tree differently from the one being resumed.
1047
1059
  shellKey === key ? url.pathname : "",
1048
1060
  // But the url itself, for the hooks: the holes are rendered for it.
1049
- url.pathname);
1061
+ url.pathname, route.params);
1050
1062
  // A shell stored for the pattern was built without a url, so its title
1051
1063
  // is the layouts' - the page's generateMetadata reads the params and
1052
1064
  // was left out. This request has the params.