@rsc-kit/core 0.30.5 → 0.30.7

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.
@@ -16,12 +16,21 @@ interface Props {
16
16
  interface State {
17
17
  redirecting: boolean;
18
18
  wasActive: boolean;
19
+ /** A missing page that could not be answered with one: shown as the error it is. */
20
+ failed: unknown;
21
+ /** The children that said the page is missing, while not-found.tsx is being fetched. */
22
+ asked: ReactNode | null;
23
+ /** Whether not-found.tsx has been fetched and put where those children were. */
24
+ answered: boolean;
25
+ /** The children that are the answer, so a page replacing it is told from it. */
26
+ shown: ReactNode | null;
19
27
  }
20
28
  export declare class RedirectBoundary extends Component<Props, State> {
21
29
  state: State;
22
30
  static getDerivedStateFromError(error: unknown): Partial<State> | null;
23
31
  static getDerivedStateFromProps(props: Props, state: State): Partial<State> | null;
24
32
  componentDidCatch(error: unknown, _info: ErrorInfo): void;
33
+ private showNotFound;
25
34
  render(): ReactNode;
26
35
  }
27
36
  export {};
@@ -1,25 +1,50 @@
1
1
  "use client";
2
- import { Component } from "react";
2
+ import { Component, createElement } from "react";
3
3
  import { parseRedirectDigest } from "../redirectDigest.js";
4
+ import { isNotFoundDigest } from "../notFound.js";
4
5
  import { visit } from "./router";
6
+ import { DefaultRouteError } from "./DefaultRouteError";
5
7
  export class RedirectBoundary extends Component {
6
- state = { redirecting: false, wasActive: this.props.active !== false };
8
+ state = {
9
+ redirecting: false,
10
+ wasActive: this.props.active !== false,
11
+ failed: null,
12
+ asked: null,
13
+ answered: false,
14
+ shown: null,
15
+ };
7
16
  static getDerivedStateFromError(error) {
8
17
  // Reading `digest` rather than the message: React replaces a server
9
18
  // error's message in production and transmits the digest either way.
10
- return parseRedirectDigest(error?.digest)
11
- ? { redirecting: true }
12
- : null;
19
+ const digest = error?.digest;
20
+ return parseRedirectDigest(digest) || isNotFoundDigest(digest) ? { redirecting: true } : null;
13
21
  }
14
22
  static getDerivedStateFromProps(props, state) {
15
23
  const active = props.active !== false;
16
- if (active === state.wasActive)
17
- return null;
24
+ let next = {};
18
25
  // Revealed again: render the page, not the space left by its redirect.
19
- return { wasActive: active, redirecting: active ? false : state.redirecting };
26
+ if (active !== state.wasActive) {
27
+ next = { wasActive: active, redirecting: active ? false : state.redirecting };
28
+ }
29
+ // The tree that stands for a missing page has replaced the one that threw:
30
+ // render it. Not before the answer is in - a parent rendering again hands
31
+ // down new children that are the same page, and rendering those would
32
+ // throw again.
33
+ if (state.asked !== null && state.answered && props.children !== state.asked) {
34
+ next = { ...next, asked: null, shown: props.children, redirecting: false };
35
+ }
36
+ else if (state.shown !== null && props.children !== state.shown) {
37
+ // Something else took its place - the person came back to a page that
38
+ // exists now. The next missing page is a first one again.
39
+ next = { ...next, shown: null, answered: false };
40
+ }
41
+ return Object.keys(next).length ? next : null;
20
42
  }
21
43
  componentDidCatch(error, _info) {
22
- const target = parseRedirectDigest(error?.digest);
44
+ const digest = error?.digest;
45
+ if (isNotFoundDigest(digest))
46
+ return this.showNotFound(error);
47
+ const target = parseRedirectDigest(digest);
23
48
  if (!target)
24
49
  throw error;
25
50
  if (this.props.active === false)
@@ -34,7 +59,33 @@ export class RedirectBoundary extends Component {
34
59
  // The server chose this, so it is not one of the app's authored hrefs.
35
60
  void visit(target.location, { replace: true });
36
61
  }
62
+ showNotFound(error) {
63
+ if (this.props.active === false)
64
+ return;
65
+ // The answer itself said the page is missing: a not-found.tsx that calls
66
+ // notFound() would otherwise be answered with itself for ever. It is
67
+ // shown as the error it has become.
68
+ if (this.state.answered) {
69
+ this.setState({ failed: error });
70
+ return;
71
+ }
72
+ const here = window.location.pathname + window.location.search;
73
+ this.setState({ asked: this.props.children });
74
+ // replace: the url is the page's own, and nothing was pushed for it to
75
+ // leave behind. Not-found.tsx replaces the page in the history entry the
76
+ // person is already on.
77
+ visit(here, { replace: true, notFound: true }).then(() => this.setState({ answered: true }),
78
+ // Announced by the navigation as rsc-navigate-error. The person is left
79
+ // with the error the page would have shown, not an empty space.
80
+ () => this.setState({ failed: error }));
81
+ }
37
82
  render() {
83
+ if (this.state.failed) {
84
+ return createElement(DefaultRouteError, {
85
+ error: this.state.failed,
86
+ reset: () => this.setState({ failed: null, redirecting: false }),
87
+ });
88
+ }
38
89
  if (this.state.redirecting)
39
90
  return this.props.fallback ?? null;
40
91
  return this.props.children;
@@ -1 +1 @@
1
- {"version":3,"file":"RedirectBoundary.js","sourceRoot":"","sources":["../../src/js/RedirectBoundary.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAqBb,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAqBjC,MAAM,OAAO,gBAAiB,SAAQ,SAAuB;IAC3D,KAAK,GAAU,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;IAE9E,MAAM,CAAC,wBAAwB,CAAC,KAAc;QAC5C,oEAAoE;QACpE,qEAAqE;QACrE,OAAO,mBAAmB,CAAE,KAA8B,EAAE,MAAM,CAAC;YACjE,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE;YACvB,CAAC,CAAC,IAAI,CAAC;IACX,CAAC;IAED,MAAM,CAAC,wBAAwB,CAAC,KAAY,EAAE,KAAY;QACxD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC;QAEtC,IAAI,MAAM,KAAK,KAAK,CAAC,SAAS;YAAE,OAAO,IAAI,CAAC;QAE5C,uEAAuE;QACvE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;IAChF,CAAC;IAED,iBAAiB,CAAC,KAAc,EAAE,KAAgB;QAChD,MAAM,MAAM,GAAG,mBAAmB,CAAE,KAA8B,EAAE,MAAM,CAAC,CAAC;QAE5E,IAAI,CAAC,MAAM;YAAE,MAAM,KAAK,CAAC;QACzB,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,KAAK;YAAE,OAAO;QAExC,uEAAuE;QACvE,sEAAsE;QACtE,wEAAwE;QACxE,wDAAwD;QACxD,EAAE;QACF,uEAAuE;QACvE,uEAAuE;QACvE,uEAAuE;QACvE,KAAK,KAAK,CAAC,MAAM,CAAC,QAAiB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM;QACJ,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC;QAE/D,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,CAAC;CACF","sourcesContent":["\"use client\";\n\n/**\n * Performs a redirect that was decided too late to be a status code.\n *\n * A redirect thrown above every Suspense boundary is answered by the host\n * before anything is written — the browser never sees this page, and this\n * component is never involved. One thrown inside a boundary arrives after the\n * shell, as an error carrying the destination in its digest, and this is what\n * turns that back into a navigation.\n *\n * An error boundary rather than a hook because that is the only thing React\n * offers for \"a child threw\": the throw happens in a server component whose\n * error is serialised into the payload, and it surfaces here when the client\n * renders it.\n *\n * Anything that is not a redirect is rethrown untouched, so an app's own error\n * boundaries still see the errors they exist for.\n */\n\nimport type { Route } from \"../routes.js\";\nimport { Component } from \"react\";\nimport type { ErrorInfo, ReactNode } from \"react\";\nimport { parseRedirectDigest } from \"../redirectDigest.js\";\nimport { visit } from \"./router\";\n\ninterface Props {\n children: ReactNode;\n /** Shown while the navigation is in flight. Null keeps the space empty. */\n fallback?: ReactNode;\n /**\n * Whether what this boundary wraps is the page on screen. A segment keeps\n * pages alive behind the active one, each under its own boundary, and a\n * redirect caught on a page that is not showing is not performed — it was\n * already performed when it was. Shown again, the boundary renders the\n * page afresh, and a refusal that still stands redirects again.\n */\n active?: boolean;\n}\n\ninterface State {\n redirecting: boolean;\n wasActive: boolean;\n}\n\nexport class RedirectBoundary extends Component<Props, State> {\n state: State = { redirecting: false, wasActive: this.props.active !== false };\n\n static getDerivedStateFromError(error: unknown): Partial<State> | null {\n // Reading `digest` rather than the message: React replaces a server\n // error's message in production and transmits the digest either way.\n return parseRedirectDigest((error as { digest?: unknown })?.digest)\n ? { redirecting: true }\n : null;\n }\n\n static getDerivedStateFromProps(props: Props, state: State): Partial<State> | null {\n const active = props.active !== false;\n\n if (active === state.wasActive) return null;\n\n // Revealed again: render the page, not the space left by its redirect.\n return { wasActive: active, redirecting: active ? false : state.redirecting };\n }\n\n componentDidCatch(error: unknown, _info: ErrorInfo): void {\n const target = parseRedirectDigest((error as { digest?: unknown })?.digest);\n\n if (!target) throw error;\n if (this.props.active === false) return;\n\n // An SPA navigation, not a location assignment: the layouts above this\n // boundary are already mounted and correct, so replacing the document\n // would throw away state the user can see — including whatever they had\n // typed into a page that is only being redirected past.\n //\n // replace, because the url being left never became a page the user was\n // on; leaving a history entry for it means Back returns to a redirect.\n // The server chose this, so it is not one of the app's authored hrefs.\n void visit(target.location as Route, { replace: true });\n }\n\n render(): ReactNode {\n if (this.state.redirecting) return this.props.fallback ?? null;\n\n return this.props.children;\n }\n}\n"]}
1
+ {"version":3,"file":"RedirectBoundary.js","sourceRoot":"","sources":["../../src/js/RedirectBoundary.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AA4Bb,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AA6BxD,MAAM,OAAO,gBAAiB,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,QAAQ,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;QAE/D,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;QAE9C,uEAAuE;QACvE,yEAAyE;QACzE,wBAAwB;QACxB,KAAK,CAAC,IAAa,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAC1D,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QACvC,wEAAwE;QACxE,gEAAgE;QAChE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CACvC,CAAC;IACJ,CAAC;IAED,MAAM;QACJ,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YACtB,OAAO,aAAa,CAAC,iBAA0B,EAAE;gBAC/C,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;gBACxB,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;aACjE,CAAC,CAAC;QACL,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC;QAE/D,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,CAAC;CACF","sourcesContent":["\"use client\";\n\n/**\n * Performs a redirect, or shows a missing page, that was decided too late to\n * be a status code.\n *\n * A redirect thrown above every Suspense boundary is answered by the host\n * before anything is written — the browser never sees this page, and this\n * component is never involved. One thrown inside a boundary arrives after the\n * shell, as an error carrying the destination in its digest, and this is what\n * turns that back into a navigation.\n *\n * An error boundary rather than a hook because that is the only thing React\n * offers for \"a child threw\": the throw happens in a server component whose\n * error is serialised into the payload, and it surfaces here when the client\n * renders it.\n *\n * A page that said it does not exist, after its shell was sent, arrives the\n * same way and is answered the same way: the server is asked for not-found.tsx\n * for this url and it is rendered where the page was, with the layouts kept and\n * the url and its history entry as they are. The status is already 200 and the\n * document says noindex; this is what a person sees.\n *\n * Anything that is neither is rethrown untouched, so an app's own error\n * boundaries still see the errors they exist for.\n */\n\nimport type { Route } from \"../routes.js\";\nimport { Component, createElement } from \"react\";\nimport type { ErrorInfo, ReactNode } from \"react\";\nimport { parseRedirectDigest } from \"../redirectDigest.js\";\nimport { isNotFoundDigest } from \"../notFound.js\";\nimport { visit } from \"./router\";\nimport { DefaultRouteError } from \"./DefaultRouteError\";\n\ninterface Props {\n children: ReactNode;\n /** Shown while the navigation is in flight. Null keeps the space empty. */\n fallback?: ReactNode;\n /**\n * Whether what this boundary wraps is the page on screen. A segment keeps\n * pages alive behind the active one, each under its own boundary, and a\n * redirect caught on a page that is not showing is not performed — it was\n * already performed when it was. Shown again, the boundary renders the\n * page afresh, and a refusal that still stands redirects again.\n */\n active?: boolean;\n}\n\ninterface State {\n redirecting: boolean;\n wasActive: boolean;\n /** A missing page that could not be answered with one: shown as the error it is. */\n failed: unknown;\n /** The children that said the page is missing, while not-found.tsx is being fetched. */\n asked: ReactNode | null;\n /** Whether not-found.tsx has been fetched and put where those children were. */\n answered: boolean;\n /** The children that are the answer, so a page replacing it is told from it. */\n shown: ReactNode | null;\n}\n\nexport class RedirectBoundary extends Component<Props, State> {\n state: State = {\n redirecting: false,\n wasActive: this.props.active !== false,\n failed: null,\n asked: null,\n answered: false,\n shown: null,\n };\n\n static getDerivedStateFromError(error: unknown): Partial<State> | null {\n // Reading `digest` rather than the message: React replaces a server\n // error's message in production and transmits the digest either way.\n const digest = (error as { digest?: unknown })?.digest;\n\n return parseRedirectDigest(digest) || isNotFoundDigest(digest) ? { redirecting: true } : null;\n }\n\n static getDerivedStateFromProps(props: Props, state: State): Partial<State> | null {\n const active = props.active !== false;\n let next: Partial<State> = {};\n\n // Revealed again: render the page, not the space left by its redirect.\n if (active !== state.wasActive) {\n next = { wasActive: active, redirecting: active ? false : state.redirecting };\n }\n\n // The tree that stands for a missing page has replaced the one that threw:\n // render it. Not before the answer is in - a parent rendering again hands\n // down new children that are the same page, and rendering those would\n // throw again.\n if (state.asked !== null && state.answered && props.children !== state.asked) {\n next = { ...next, asked: null, shown: props.children, redirecting: false };\n } else if (state.shown !== null && props.children !== state.shown) {\n // Something else took its place - the person came back to a page that\n // exists now. The next missing page is a first one again.\n next = { ...next, shown: null, answered: false };\n }\n\n return Object.keys(next).length ? next : null;\n }\n\n componentDidCatch(error: unknown, _info: ErrorInfo): void {\n const digest = (error as { digest?: unknown })?.digest;\n\n if (isNotFoundDigest(digest)) return this.showNotFound(error);\n\n const target = parseRedirectDigest(digest);\n\n if (!target) throw error;\n if (this.props.active === false) return;\n\n // An SPA navigation, not a location assignment: the layouts above this\n // boundary are already mounted and correct, so replacing the document\n // would throw away state the user can see — including whatever they had\n // typed into a page that is only being redirected past.\n //\n // replace, because the url being left never became a page the user was\n // on; leaving a history entry for it means Back returns to a redirect.\n // The server chose this, so it is not one of the app's authored hrefs.\n void visit(target.location as Route, { replace: true });\n }\n\n private showNotFound(error: unknown): void {\n if (this.props.active === false) return;\n\n // The answer itself said the page is missing: a not-found.tsx that calls\n // notFound() would otherwise be answered with itself for ever. It is\n // shown as the error it has become.\n if (this.state.answered) {\n this.setState({ failed: error });\n\n return;\n }\n\n const here = window.location.pathname + window.location.search;\n\n this.setState({ asked: this.props.children });\n\n // replace: the url is the page's own, and nothing was pushed for it to\n // leave behind. Not-found.tsx replaces the page in the history entry the\n // person is already on.\n visit(here as Route, { replace: true, notFound: true }).then(\n () => this.setState({ answered: true }),\n // Announced by the navigation as rsc-navigate-error. The person is left\n // with the error the page would have shown, not an empty space.\n () => this.setState({ failed: error }),\n );\n }\n\n render(): ReactNode {\n if (this.state.failed) {\n return createElement(DefaultRouteError as never, {\n error: this.state.failed,\n reset: () => this.setState({ failed: null, redirecting: false }),\n });\n }\n\n if (this.state.redirecting) return this.props.fallback ?? null;\n\n return this.props.children;\n }\n}\n"]}
@@ -11,6 +11,7 @@
11
11
  // rule loading.tsx follows.
12
12
  import { Component, createElement } from 'react';
13
13
  import { parseRedirectDigest } from '../redirectDigest.js';
14
+ import { isNotFoundDigest } from '../notFound.js';
14
15
  export class RouteErrorBoundary extends Component {
15
16
  state = { error: null, from: '' };
16
17
  static getDerivedStateFromError(error) {
@@ -18,7 +19,7 @@ export class RouteErrorBoundary extends Component {
18
19
  // the destination in its digest. It is not a failure for an error.tsx to
19
20
  // show - it is the page's answer - and the boundary that performs it sits
20
21
  // above this one. Left alone here; componentDidCatch hands it up.
21
- if (parseRedirectDigest(error?.digest))
22
+ if (parseRedirectDigest(error?.digest) || isNotFoundDigest(error?.digest))
22
23
  return null;
23
24
  return { error };
24
25
  }
@@ -34,7 +35,10 @@ export class RouteErrorBoundary extends Component {
34
35
  }
35
36
  componentDidCatch(error) {
36
37
  // Rethrown so the RedirectBoundary above turns it back into a navigation.
37
- if (parseRedirectDigest(error?.digest))
38
+ // A missing page is the same: it is the page's answer, and the boundary
39
+ // above asks for not-found.tsx - an error.tsx showing "something went
40
+ // wrong" over a record that does not exist was the bug.
41
+ if (parseRedirectDigest(error?.digest) || isNotFoundDigest(error?.digest))
38
42
  throw error;
39
43
  // Reported as well as rendered. A boundary that swallows the error leaves
40
44
  // nothing in the console for whoever has to find the cause.
@@ -1 +1 @@
1
- {"version":3,"file":"RouteErrorBoundary.js","sourceRoot":"","sources":["../../src/js/RouteErrorBoundary.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,kDAAkD;AAClD,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,2EAA2E;AAC3E,SAAS;AACT,EAAE;AACF,4EAA4E;AAC5E,+EAA+E;AAC/E,4BAA4B;AAE5B,OAAO,EAAE,S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,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACxC,KAAK;YACL,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;SAC5C,CAAC,CAAA;IACJ,CAAC;CACF","sourcesContent":["'use client'\n\n// The boundary an `error.tsx` is rendered inside.\n//\n// A class, because catching a render error is the one thing React still has no\n// hook for. It is a CLIENT component and has to be: a server component cannot\n// catch what happens in the browser, and `reset` is a callback the browser\n// calls.\n//\n// One of these wraps each segment that has an error.tsx above it, innermost\n// first, so the nearest file to the failure is the one that answers — the same\n// rule loading.tsx follows.\n\nimport { Component, createElement, type ReactNode } from 'react'\nimport { parseRedirectDigest } from '../redirectDigest.js'\n\nexport interface RouteErrorProps {\n /** What was thrown. In production React replaces the message with a digest. */\n error: Error & { digest?: string }\n /** Render the segment again. For a failure that might not happen twice. */\n reset: () => void\n}\n\ninterface Props {\n fallback: (props: RouteErrorProps) => ReactNode\n children?: ReactNode\n /**\n * Changes when the route does.\n *\n * Without it a boundary that caught an error stays caught: navigating away\n * from a broken page would leave its error on screen over the new one, and\n * the only way out would be a reload.\n */\n resetKey: string\n}\n\ninterface State {\n error: (Error & { digest?: string }) | null\n /** The route the error belongs to, so a new one clears it. */\n from: string\n}\n\nexport class RouteErrorBoundary extends Component<Props, State> {\n state: State = { error: null, from: '' }\n\n static getDerivedStateFromError(error: Error & { digest?: string }): Partial<State> | null {\n // A redirect decided inside a Suspense boundary arrives as an error with\n // the destination in its digest. It is not a failure for an error.tsx to\n // show - it is the page's answer - and the boundary that performs it sits\n // above this one. Left alone here; componentDidCatch hands it up.\n if (parseRedirectDigest(error?.digest)) return null\n\n return { error }\n }\n\n static getDerivedStateFromProps(props: Props, state: State): Partial<State> | null {\n // A navigation clears it. Compared rather than keyed from outside, because\n // remounting the boundary on every navigation would throw away the subtree\n // it is wrapping along with the error.\n if (state.error && state.from !== props.resetKey) return { error: null, from: props.resetKey }\n if (state.from !== props.resetKey) return { from: props.resetKey }\n\n return null\n }\n\n componentDidCatch(error: Error & { digest?: string }): void {\n // Rethrown so the RedirectBoundary above turns it back into a navigation.\n if (parseRedirectDigest(error?.digest)) throw error\n\n // Reported as well as rendered. A boundary that swallows the error leaves\n // nothing in the console for whoever has to find the cause.\n console.error(error)\n }\n\n render(): ReactNode {\n const { error } = this.state\n\n if (!error) return this.props.children\n\n return createElement(this.props.fallback, {\n error,\n reset: () => this.setState({ error: null }),\n })\n }\n}\n"]}
1
+ {"version":3,"file":"RouteErrorBoundary.js","sourceRoot":"","sources":["../../src/js/RouteErrorBoundary.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,kDAAkD;AAClD,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,2EAA2E;AAC3E,SAAS;AACT,EAAE;AACF,4EAA4E;AAC5E,+EAA+E;AAC/E,4BAA4B;AAE5B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAA;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AA4BjD,MAAM,OAAO,kBAAmB,SAAQ,SAAuB;IAC7D,KAAK,GAAU,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAA;IAExC,MAAM,CAAC,wBAAwB,CAAC,KAAkC;QAChE,yEAAyE;QACzE,yEAAyE;QACzE,0EAA0E;QAC1E,kEAAkE;QAClE,IAAI,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC;YAAE,OAAO,IAAI,CAAA;QAEtF,OAAO,EAAE,KAAK,EAAE,CAAA;IAClB,CAAC;IAED,MAAM,CAAC,wBAAwB,CAAC,KAAY,EAAE,KAAY;QACxD,2EAA2E;QAC3E,2EAA2E;QAC3E,uCAAuC;QACvC,IAAI,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,QAAQ;YAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAA;QAC9F,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,QAAQ;YAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAA;QAElE,OAAO,IAAI,CAAA;IACb,CAAC;IAED,iBAAiB,CAAC,KAAkC;QAClD,0EAA0E;QAC1E,wEAAwE;QACxE,sEAAsE;QACtE,wDAAwD;QACxD,IAAI,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC;YAAE,MAAM,KAAK,CAAA;QAEtF,0EAA0E;QAC1E,4DAA4D;QAC5D,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACtB,CAAC;IAED,MAAM;QACJ,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QAE5B,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAA;QAEtC,OAAO,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACxC,KAAK;YACL,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;SAC5C,CAAC,CAAA;IACJ,CAAC;CACF","sourcesContent":["'use client'\n\n// The boundary an `error.tsx` is rendered inside.\n//\n// A class, because catching a render error is the one thing React still has no\n// hook for. It is a CLIENT component and has to be: a server component cannot\n// catch what happens in the browser, and `reset` is a callback the browser\n// calls.\n//\n// One of these wraps each segment that has an error.tsx above it, innermost\n// first, so the nearest file to the failure is the one that answers — the same\n// rule loading.tsx follows.\n\nimport { Component, createElement, type ReactNode } from 'react'\nimport { parseRedirectDigest } from '../redirectDigest.js'\nimport { isNotFoundDigest } from '../notFound.js'\n\nexport interface RouteErrorProps {\n /** What was thrown. In production React replaces the message with a digest. */\n error: Error & { digest?: string }\n /** Render the segment again. For a failure that might not happen twice. */\n reset: () => void\n}\n\ninterface Props {\n fallback: (props: RouteErrorProps) => ReactNode\n children?: ReactNode\n /**\n * Changes when the route does.\n *\n * Without it a boundary that caught an error stays caught: navigating away\n * from a broken page would leave its error on screen over the new one, and\n * the only way out would be a reload.\n */\n resetKey: string\n}\n\ninterface State {\n error: (Error & { digest?: string }) | null\n /** The route the error belongs to, so a new one clears it. */\n from: string\n}\n\nexport class RouteErrorBoundary extends Component<Props, State> {\n state: State = { error: null, from: '' }\n\n static getDerivedStateFromError(error: Error & { digest?: string }): Partial<State> | null {\n // A redirect decided inside a Suspense boundary arrives as an error with\n // the destination in its digest. It is not a failure for an error.tsx to\n // show - it is the page's answer - and the boundary that performs it sits\n // above this one. Left alone here; componentDidCatch hands it up.\n if (parseRedirectDigest(error?.digest) || isNotFoundDigest(error?.digest)) return null\n\n return { error }\n }\n\n static getDerivedStateFromProps(props: Props, state: State): Partial<State> | null {\n // A navigation clears it. Compared rather than keyed from outside, because\n // remounting the boundary on every navigation would throw away the subtree\n // it is wrapping along with the error.\n if (state.error && state.from !== props.resetKey) return { error: null, from: props.resetKey }\n if (state.from !== props.resetKey) return { from: props.resetKey }\n\n return null\n }\n\n componentDidCatch(error: Error & { digest?: string }): void {\n // Rethrown so the RedirectBoundary above turns it back into a navigation.\n // A missing page is the same: it is the page's answer, and the boundary\n // above asks for not-found.tsx - an error.tsx showing \"something went\n // wrong\" over a record that does not exist was the bug.\n if (parseRedirectDigest(error?.digest) || isNotFoundDigest(error?.digest)) throw error\n\n // Reported as well as rendered. A boundary that swallows the error leaves\n // nothing in the console for whoever has to find the cause.\n console.error(error)\n }\n\n render(): ReactNode {\n const { error } = this.state\n\n if (!error) return this.props.children\n\n return createElement(this.props.fallback, {\n error,\n reset: () => this.setState({ error: null }),\n })\n }\n}\n"]}
@@ -7,6 +7,7 @@ import { SEARCH_PARAMS_FALLBACK } from "./useSearchParams";
7
7
  import { recoverFromStaleAssets } from "./staleAssets";
8
8
  import { afterHydration, replayEarlyClicks } from "./earlyClicks";
9
9
  import { parseRedirectDigest } from "../redirectDigest.js";
10
+ import { isNotFoundDigest } from "../notFound.js";
10
11
  import { showDevNotice } from "./devNotice";
11
12
  import { caughtByLoading } from "./fallbackReport";
12
13
  import { noteNavigation } from "./segmentStore";
@@ -30,7 +31,12 @@ import { cancelPrefetch, forgetOtherPages, isPrefetched, navigate, setApiRoutes,
30
31
  function isRedirect(error) {
31
32
  const digest = error?.digest;
32
33
  const cause = error?.cause;
33
- return parseRedirectDigest(digest) !== null || parseRedirectDigest(cause?.digest) !== null;
34
+ return (parseRedirectDigest(digest) !== null ||
35
+ parseRedirectDigest(cause?.digest) !== null ||
36
+ // A missing page decided inside a boundary is answered the same way, by
37
+ // the same boundary, and is just as little a fault to report.
38
+ isNotFoundDigest(digest) ||
39
+ isNotFoundDigest(cause?.digest));
34
40
  }
35
41
  export async function createViteRscApp(container = document, interceptEntries = [], options = {}) {
36
42
  // The urls a route.ts answers: a link to one is an anchor, never a
@@ -1 +1 @@
1
- {"version":3,"file":"createViteRscApp.js","sourceRoot":"","sources":["../../src/js/createViteRscApp.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,qFAAqF;AACrF,8EAA8E;AAC9E,4EAA4E;AAC5E,qCAAqC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACn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AAC;IACzD,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,GAAG,EAAE;QACvC,yEAAyE;QACzE,gEAAgE;QAChE,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAa,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,YAAY,CAClB,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,EAChC,EAAE,EACF,MAAM,CAAC,QAAQ,CAAC,IAAI,CACrB,CAAC;IAEF,sEAAsE;IACtE,sEAAsE;IACtE,sEAAsE;IACtE,mEAAmE;IACnE,cAAc,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAY,CAAC,CAAC,CAAC,CAAC;AAC3E,CAAC","sourcesContent":["// Vite-engine client bootstrap. Uses @vitejs/plugin-rsc's browser runtime as\n// the Flight deserializer + action encoder, and drives the package's engine-agnostic\n// navigate.ts SPA engine (Link, prefetch, popstate) through it. This replaces\n// the bun engine's createRscApp + the hand-rolled webpack shim — the plugin\n// resolves client references itself.\nimport { SEARCH_PARAMS_FALLBACK } from \"./useSearchParams\";\nimport { recoverFromStaleAssets } from \"./staleAssets\";\nimport { afterHydration, replayEarlyClicks } from \"./earlyClicks\";\nimport { parseRedirectDigest } from \"../redirectDigest.js\";\nimport { showDevNotice } from \"./devNotice\";\nimport { caughtByLoading } from \"./fallbackReport\";\nimport { noteNavigation } from \"./segmentStore\";\nimport type { Route } from \"../routes.js\";\nimport { isSafeRedirect } from \"../safeUrl.js\";\nimport {\n createFromReadableStream,\n encodeReply,\n setServerCallback,\n} from \"@vitejs/plugin-rsc/browser\";\nimport { createElement, startTransition } from \"react\";\nimport { createRoot, hydrateRoot } from \"react-dom/client\";\nimport { activityMarkersIn } from \"./activityMarkers\";\nimport { ActivityRoot } from \"./ActivityRouter\";\nimport { ServerRedirectError, noteRedirected, throwForFailedAction } from \"./errors\";\nimport { fetchPagePayload } from \"./pagePayload\";\nimport { inlinePayload } from \"./inlinePayload\";\nimport { claimRead, setQueryCodec } from \"./queryClient\";\nimport { clearSegments, dropHidden, isHeld, prerenderSegment, restoreSegments, setSegment } from \"./segmentStore\";\nimport type { ReactNode } from \"react\";\nimport {\n cancelPrefetch,\n forgetOtherPages,\n isPrefetched,\n navigate,\n setApiRoutes,\n refresh,\n applyRevalidations,\n prefetch,\n retentionKey,\n setCallServer,\n setHeldLayouts,\n setStaticPayloads,\n setStaticRoutes,\n seedStaticChain,\n payloadUrl,\n setDeserializer,\n setInterceptManifest,\n getHeldLayouts,\n setNavigateHandler,\n setHeldHandlers,\n setPrerenderHandler,\n setReplaceRootHandler,\n setRestoreHandler,\n setVersion,\n} from \"./navigate\";\n\n\n/**\n * A redirect that travelled as an error: the digest of the error itself, or\n * of the cause React wraps it in when it reports client-rendering a boundary\n * the server had already failed.\n */\nfunction isRedirect(error: unknown): boolean {\n const digest = (error as { digest?: unknown } | null)?.digest;\n const cause = (error as { cause?: { digest?: unknown } } | null)?.cause;\n\n return parseRedirectDigest(digest) !== null || parseRedirectDigest(cause?.digest) !== null;\n}\n\nexport async function createViteRscApp(\n container: Document | Element = document,\n interceptEntries: { urlPattern: string; slot: string }[] = [],\n options: { staticPayloads?: string | null; routes?: unknown[] | null; apiRoutes?: string[] } = {},\n): Promise<void> {\n // The urls a route.ts answers: a link to one is an anchor, never a\n // prefetch, never a payload fetch.\n if (options.apiRoutes) setApiRoutes(options.apiRoutes);\n // An exported build has no server to negotiate with, so payloads live at\n // their own urls rather than behind a header on the page's url.\n setStaticPayloads(options.staticPayloads ?? null);\n // Only an exported build ships this: with no server to negotiate with, the\n // client works out for itself how much of a page it still holds.\n if (options.routes) setStaticRoutes(options.routes as never);\n // The router has to recognise an intercepted link before it asks the server,\n // so the patterns are baked into the generated browser entry. Without them\n // every intercepted route falls through to a full-page navigation.\n setInterceptManifest(interceptEntries);\n\n async function callServer(id: string, args: unknown[]): Promise<unknown> {\n // A read opened a slot before calling the reference, and this is the first\n // point at which the id exists on the client — React keeps it private and\n // hands it over only here. Claiming the slot enqueues the read for the\n // batched GET instead of posting it.\n const read = claimRead(id, args);\n\n if (read) return await read;\n\n const encoded = await encodeReply(args);\n\n // encodeReply returns FormData as soon as an argument contains a File.\n // Sending that as multipart would make PHP consume php://input while\n // parsing it, leaving the action with an empty body — so serialize it to\n // raw bytes under an opaque content-type and send the real one in\n // X-RSC-Content-Type for the worker to rebuild FormData from.\n let body: BodyInit;\n let realContentType: string;\n\n if (encoded instanceof FormData) {\n const serialized = new Response(encoded);\n body = await serialized.arrayBuffer();\n realContentType =\n serialized.headers.get(\"content-type\") ?? \"multipart/form-data\";\n } else {\n body = encoded as BodyInit;\n realContentType = \"text/plain;charset=UTF-8\";\n }\n\n // Where the action was invoked from. The host resolves it to the\n // components that render the page, so anything the action says it\n // invalidated can come back with the answer instead of being fetched\n // afterwards - and what comes back is for this page, not whichever is\n // showing when it lands.\n const from = window.location.pathname + window.location.search;\n\n const res = await fetch(\"/_rsc/action\", {\n method: \"POST\",\n headers: {\n \"X-RSC-Action\": id,\n \"X-RSC-Referer\": from,\n \"X-RSC-Content-Type\": realContentType,\n \"Content-Type\": \"application/octet-stream\",\n \"X-XSRF-TOKEN\": decodeURIComponent(\n document.cookie.match(/XSRF-TOKEN=([^;]+)/)?.[1] ?? \"\",\n ),\n },\n body,\n });\n\n // A failed action does not answer with a Flight stream, and the decoder\n // cannot tell — it reports its own parse failure instead of what the\n // server said.\n try {\n await throwForFailedAction(res);\n } catch (err) {\n // A redirect is an instruction, not something for a form to display:\n // an expired session answers this way, and the destination is the login\n // page rather than a message about one.\n if (err instanceof ServerRedirectError) {\n // The destination came off a response header, so it is checked here\n // too — the engine refuses these at the source, but a proxy or a host\n // in front of it can write whatever it likes. A navigation, not a\n // document load: the layouts stay mounted and the history entry the\n // form was on is replaced, the way a redirect after a POST should\n // be - Back does not return to the submitted form.\n //\n // Awaited, so the action is still pending when the destination's\n // tree is handed to React: the two are one transition, committed\n // together. Not awaited, the action ended first - its optimistic\n // state dropped, pending went false - and the page it redirected to\n // arrived a frame later. A new chat's first message vanished from\n // the thread and came back with its reply.\n //\n // Asked of the server, never revealed from what the router holds. The\n // action may have changed anything the destination reads - a cookie,\n // a membership, a row - and a page kept from before it, or prefetched\n // before it, shows the world as it was: a sign-in that redirected\n // back showed the page signed out until a reload. What a revalidating\n // action already drops, a redirecting one drops too.\n if (isSafeRedirect(err.location)) {\n forgetOtherPages();\n\n try {\n await navigate(err.location as Route, { replace: true });\n } catch {\n // Announced by the navigation itself, as rsc-navigate-error. The\n // action did redirect; that is still its answer.\n }\n }\n\n // Performed, so resolved - not thrown. The call's answer is \"you are\n // being taken somewhere\": an object saying so, the shape an action's\n // result already has, so a caller reading result.validationErrors\n // reads undefined rather than throwing. A caller that awaited the\n // action in a plain startTransition had no catch for a throw, the\n // rejection reached React, and the root unmounted to a white page\n // on every logout.\n noteRedirected(err.location);\n\n return { redirected: err.location };\n }\n\n throw err;\n }\n\n const answer = await createFromReadableStream(res.body!, { callServer });\n\n return unwrapRevalidated(answer, from);\n }\n\n /**\n * Put anything the action re-rendered on screen, and hand back its result.\n *\n * The trees travel with the answer rather than being fetched afterwards, so\n * the caller sees only what its action returned and never knows the page\n * was updated around it.\n */\n function unwrapRevalidated(answer: unknown, from: string): unknown {\n if (\n answer === null ||\n typeof answer !== \"object\" ||\n !(\"__rscRevalidated\" in answer)\n ) {\n return answer;\n }\n\n const envelope = answer as {\n __rscRevalidated: Record<string, unknown>;\n result: unknown;\n };\n\n applyRevalidations(from, envelope.__rscRevalidated as Record<string, ReactNode>);\n\n return envelope.result;\n }\n\n setDeserializer(createFromReadableStream as never);\n // The query transport speaks Flight too, and reaches the runtime through here\n // rather than importing it: a second import of the browser runtime from the\n // client-component graph is a second client-reference registry, and the\n // symptom is components that render as undefined with nothing logged.\n setQueryCodec({\n deserialize: (stream) =>\n createFromReadableStream(stream, { callServer }) as Promise<unknown>,\n encode: (args) => encodeReply(args) as Promise<string | FormData>,\n // The way back when a read cannot ride in a url. Re-entering callServer is\n // safe: the slot was cleared the moment the reference returned, so this\n // takes the ordinary POST path rather than claiming a read again.\n asAction: (id, args) => callServer(id, args),\n });\n setCallServer(callServer);\n // The plugin's own \"use server\" client stubs route through its registered\n // server callback — register the same transport there too.\n setServerCallback(callServer as never);\n\n // Link / Form / router live in a separate build graph and reach the SPA\n // engine through these globals.\n (window as unknown as { __rsc_navigate: typeof navigate }).__rsc_navigate =\n navigate;\n (window as unknown as { __rsc_prefetch: typeof prefetch }).__rsc_prefetch =\n prefetch;\n (\n window as unknown as { __rsc_cancel_prefetch: typeof cancelPrefetch }\n ).__rsc_cancel_prefetch = cancelPrefetch;\n (\n window as unknown as { __rsc_is_prefetched: typeof isPrefetched }\n ).__rsc_is_prefetched = isPrefetched;\n (window as unknown as { __rsc_refresh: typeof refresh }).__rsc_refresh =\n refresh;\n\n // Hydrate from the RSC endpoint (same url + X-RSC, no version header).\n //\n // Everything from here to the decode is failure handling, because this is\n // the one request with nothing watching it. A page whose shell is already\n // rendered looks fine while this fails, and its fallbacks stay on screen\n // indefinitely with nothing reported anywhere.\n // The payload the document streamed in for itself, when it did - one\n // render per visit, see inlinePayload.ts. A page the build wrote whole\n // fetches its stored payload, as it always did.\n const res = inlinePayload() ?? (await fetchPagePayload(payloadUrl(window.location.href)));\n\n // Seed the router with the build this DOCUMENT is, so a redeploy is caught\n // on the next navigation: the host answers 409 to a client of another\n // build, and the document is loaded again. From the document's own meta\n // first - a document a service worker served from its cache is the last\n // build's, while the payload just fetched is this one's, and seeding from\n // the payload would have the old client claim to be new. The header is\n // the fallback for a document with no meta.\n const documentBuild = document.querySelector('meta[name=\"rsc-kit:build\"]')?.getAttribute(\"content\");\n const servedVersion = documentBuild || res.headers.get(\"X-RSC-Version\");\n\n if (servedVersion) {\n setVersion(servedVersion);\n }\n\n // The chain this page is built from, so the next navigation can say what is\n // already mounted and be sent only what changed.\n // A server says what this page is built from; a file server says nothing,\n // so an exported build works it out from the table it was given.\n const servedLayouts = res.headers.get(\"X-RSC-Layouts\");\n\n if (servedLayouts !== null) {\n setHeldLayouts(servedLayouts.split(\",\"));\n } else if (!seedStaticChain(window.location.href)) {\n setHeldLayouts([]);\n }\n const tree = await createFromReadableStream(res.body!, { callServer });\n\n // Retaining the previous page behind <Activity> needs a wrapper above the\n // page, and React will not hydrate a *document* container through one: the\n // root child of a document has to be <html>, and wrapping it hangs the\n // renderer outright (React 19.2.7). An app whose root layout owns <html>\n // therefore hydrates the tree directly and navigations replace it, as before.\n //\n // Apps that hydrate into an element get retention. Giving it to document-\n // rooted apps means SPA navigation returning only the changed segment rather\n // than a whole document, which is an engine change, not a client one.\n const retains = container !== document;\n\n const shell = retains\n ? createElement(ActivityRoot, {\n initialKey: retentionKey(window.location.href, null),\n initialTree: tree as ReactNode,\n })\n : (tree as ReactNode);\n\n // A document that cannot be hydrated by this tree is client-rendered\n // instead - a repaint, not a freeze. React 19.2 does not recover from a\n // hydration mismatch at an <Activity>: it retries hydrating the boundary,\n // mismatches again, and never returns to the main thread. Every segment\n // boundary is an Activity, one per layout, so a document with none where\n // the page has layouts is that mismatch, guaranteed, before React starts.\n // What produced one: a parameterised route's PPR shell, rendered without\n // a page key and, by a build before this one, without the Activities too.\n // None rather than fewer: a boundary inside a Suspense hole the shell left\n // unfinished has no marker and is client-rendered by React on its own,\n // which is not a mismatch. The stale-asset reload does not apply - the\n // document would come back the same.\n const missing = retains && getHeldLayouts().length > 0 && activityMarkersIn(container) === 0;\n\n if (missing) {\n console.warn(\n \"[rsc-kit] The document has no <Activity> boundaries where the page has layouts, so it cannot be hydrated; rendering the page instead. A PPR shell built by an earlier release lacks them - rebuild.\",\n );\n }\n\n // The payload answered with an error status - the not-found page for a\n // url the shell was served for anyway. It is not the document on screen,\n // so it is rendered, not hydrated: a mismatch at an Activity is the loop\n // above, and this one is certain.\n const disagrees = !res.ok;\n\n const onRecoverableError = (error: unknown, errorInfo: unknown) => {\n // A client component whose chunk the server no longer has fails while\n // hydrating, and React reports that as recoverable: the page is loaded\n // again, with the current names.\n if (recoverFromStaleAssets(error)) return;\n\n // A redirect decided inside a boundary: the server's row carried it as\n // the digest, React client-renders the boundary and reports that it\n // did, and the RedirectBoundary is already performing it. Nothing to\n // read in the console about a page doing what it was told.\n if (isRedirect(error)) return;\n\n // A PPR shell is served with its Suspense boundaries deliberately\n // unfinished — the build aborts the render once the static part is out.\n // React reports that as #419 and client-renders the boundary from the\n // Flight payload, which is the intended path, not a fault to report.\n const message = String((error as { message?: string })?.message ?? error);\n\n if (\n message.includes(\"419\") ||\n message.includes(\"did not finish this Suspense boundary\")\n ) {\n return;\n }\n\n // A view transition the browser cancelled because the tab was not\n // visible. React reports it here; the update still landed, and a tab\n // in the background is not a fault in the page.\n if (message.includes(\"Transition was aborted\")) return;\n\n // A navigation another one overtook: its request was aborted, and a\n // row of its payload that a component was still reading rejects with\n // the abort. React recovers by rendering the root again synchronously\n // and reports the recovery here as #520, with the abort as the cause.\n // The page it recovered to is the one the second navigation asked for;\n // the abort was the design, not a fault.\n const cause = (error as { cause?: { name?: string; message?: string } } | null)?.cause;\n\n if (\n cause?.name === \"AbortError\" ||\n /\\baborted\\b/i.test(cause?.message ?? \"\") ||\n /\\baborted\\b/i.test(message)\n ) {\n return;\n }\n // A page whose query string was read under a boundary carries the\n // fallback there; React reports the recovery on hydration. Under a\n // boundary the developer wrote, that is the designed path and nothing\n // is said. With nothing closer than a loading.tsx, the whole segment\n // showed the fallback until the query arrived - said here, in the\n // page and the console, for whoever is looking at either. Production\n // has no stack to tell the two apart; the build's note on the route is\n // the record there.\n if (\n (error as { digest?: string })?.digest === SEARCH_PARAMS_FALLBACK ||\n message.includes(\"useSearchParams()\")\n ) {\n const stack = (errorInfo as { componentStack?: string } | null)\n ?.componentStack;\n\n if (!caughtByLoading(stack)) return;\n\n const hint =\n \"useSearchParams() was read on the server with nothing closer than a loading.tsx, so the \" +\n \"whole segment showed that fallback until the query arrived. A <Suspense> around the \" +\n \"component that reads keeps the rest of the page painted.\";\n\n showDevNotice(hint, stack);\n console.error(new Error(hint), errorInfo);\n\n return;\n }\n\n console.error(error, errorInfo);\n };\n\n const rootOptions = {\n onRecoverableError,\n // A chunk the deploy no longer serves is not a fault in the page; the\n // document is loaded again, and the new names come with it. Anything\n // else is reported the way React would have.\n onUncaughtError(error: unknown, errorInfo: unknown) {\n if (recoverFromStaleAssets(error)) return;\n\n console.error(error, errorInfo);\n },\n onCaughtError(error: unknown, errorInfo: unknown) {\n if (recoverFromStaleAssets(error)) return;\n // Caught by the RedirectBoundary, which is performing it.\n if (isRedirect(error)) return;\n\n console.error(error, errorInfo);\n },\n };\n\n const root = missing || disagrees\n ? (() => {\n const created = createRoot(container as Element, rootOptions);\n\n created.render(shell);\n\n return created;\n })()\n : hydrateRoot(container, shell, rootOptions);\n\n // Depth 0 is a whole document and replaces the root. Anything deeper is one\n // segment: handing it to the boundary at that depth leaves the layouts above\n // it mounted, which is the point of asking for a partial render at all.\n setNavigateHandler((tree: unknown, key: string, segmentDepth: number, inPlaceOf?: string | null) => {\n const newTree = tree as ReactNode;\n\n // From here on the boundary animates; the seed commit before this did not.\n noteNavigation();\n\n if (segmentDepth > 0) {\n setSegment(segmentDepth, key, newTree, inPlaceOf);\n\n return;\n }\n\n clearSegments();\n root.render(newTree);\n });\n\n // The whole document again, in place - revalidate(\"all\"). Not through the\n // handler above: that clears the boundaries and renders the tree as a new\n // page, and a boundary emptied re-keys its Activity to the current url and\n // remounts everything under it. A port's \"added to cart\" went with the\n // form's state that way, on every product reached by a link. Here the root\n // takes the tree in a transition and each boundary hands its page the new\n // children under the key it has - see replaceActive.\n setReplaceRootHandler((tree: unknown) => {\n startTransition(() => root.render(tree as ReactNode));\n });\n\n // Back and forward reveal a page the boundaries are still holding, with the\n // form you were filling in still filled in, and without asking the server.\n setRestoreHandler((key: string, maxAge?: number) =>\n restoreSegments(key, maxAge),\n );\n setHeldHandlers(isHeld, dropHidden);\n\n // A touch or a settled hover: the page is rendered hidden now, and the\n // click reveals it. See warm() in navigate.ts and prerenderSegment.\n setPrerenderHandler((tree: unknown, key: string, segmentDepth: number) => {\n prerenderSegment(segmentDepth, key, tree as ReactNode);\n });\n\n window.addEventListener(\"popstate\", () => {\n // restore: back and forward reveal the page you were on, with its state.\n // Wherever the browser just went; not a literal this app wrote.\n navigate(window.location.href as Route, { replace: true, restore: true });\n });\n\n history.replaceState(\n { rscUrl: window.location.href },\n \"\",\n window.location.href,\n );\n\n // A tap held by the bootstrap script, navigated to once hydration has\n // committed - not now: the runtime's script running is seconds before\n // React can dispatch a click on a phone still downloading chunks, and\n // a tap in that window would be the browser's. See earlyClicks.ts.\n afterHydration(() => replayEarlyClicks((url) => navigate(url as Route)));\n}\n\n"]}
1
+ {"version":3,"file":"createViteRscApp.js","sourceRoot":"","sources":["../../src/js/createViteRscApp.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,qFAAqF;AACrF,8EAA8E;AAC9E,4EAA4E;AAC5E,qCAAqC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,wBAAwB,EACx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D,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,GAAG,EAAE;QACvC,yEAAyE;QACzE,gEAAgE;QAChE,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAa,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,YAAY,CAClB,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,EAChC,EAAE,EACF,MAAM,CAAC,QAAQ,CAAC,IAAI,CACrB,CAAC;IAEF,sEAAsE;IACtE,sEAAsE;IACtE,sEAAsE;IACtE,mEAAmE;IACnE,cAAc,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAY,CAAC,CAAC,CAAC,CAAC;AAC3E,CAAC","sourcesContent":["// Vite-engine client bootstrap. Uses @vitejs/plugin-rsc's browser runtime as\n// the Flight deserializer + action encoder, and drives the package's engine-agnostic\n// navigate.ts SPA engine (Link, prefetch, popstate) through it. This replaces\n// the bun engine's createRscApp + the hand-rolled webpack shim — the plugin\n// resolves client references itself.\nimport { SEARCH_PARAMS_FALLBACK } from \"./useSearchParams\";\nimport { recoverFromStaleAssets } from \"./staleAssets\";\nimport { afterHydration, replayEarlyClicks } from \"./earlyClicks\";\nimport { parseRedirectDigest } from \"../redirectDigest.js\";\nimport { isNotFoundDigest } from \"../notFound.js\";\nimport { showDevNotice } from \"./devNotice\";\nimport { caughtByLoading } from \"./fallbackReport\";\nimport { noteNavigation } from \"./segmentStore\";\nimport type { Route } from \"../routes.js\";\nimport { isSafeRedirect } from \"../safeUrl.js\";\nimport {\n createFromReadableStream,\n encodeReply,\n setServerCallback,\n} from \"@vitejs/plugin-rsc/browser\";\nimport { createElement, startTransition } from \"react\";\nimport { createRoot, hydrateRoot } from \"react-dom/client\";\nimport { activityMarkersIn } from \"./activityMarkers\";\nimport { ActivityRoot } from \"./ActivityRouter\";\nimport { ServerRedirectError, noteRedirected, throwForFailedAction } from \"./errors\";\nimport { fetchPagePayload } from \"./pagePayload\";\nimport { inlinePayload } from \"./inlinePayload\";\nimport { claimRead, setQueryCodec } from \"./queryClient\";\nimport { clearSegments, dropHidden, isHeld, prerenderSegment, restoreSegments, setSegment } from \"./segmentStore\";\nimport type { ReactNode } from \"react\";\nimport {\n cancelPrefetch,\n forgetOtherPages,\n isPrefetched,\n navigate,\n setApiRoutes,\n refresh,\n applyRevalidations,\n prefetch,\n retentionKey,\n setCallServer,\n setHeldLayouts,\n setStaticPayloads,\n setStaticRoutes,\n seedStaticChain,\n payloadUrl,\n setDeserializer,\n setInterceptManifest,\n getHeldLayouts,\n setNavigateHandler,\n setHeldHandlers,\n setPrerenderHandler,\n setReplaceRootHandler,\n setRestoreHandler,\n setVersion,\n} from \"./navigate\";\n\n\n/**\n * A redirect that travelled as an error: the digest of the error itself, or\n * of the cause React wraps it in when it reports client-rendering a boundary\n * the server had already failed.\n */\nfunction isRedirect(error: unknown): boolean {\n const digest = (error as { digest?: unknown } | null)?.digest;\n const cause = (error as { cause?: { digest?: unknown } } | null)?.cause;\n\n return (\n parseRedirectDigest(digest) !== null ||\n parseRedirectDigest(cause?.digest) !== null ||\n // A missing page decided inside a boundary is answered the same way, by\n // the same boundary, and is just as little a fault to report.\n isNotFoundDigest(digest) ||\n isNotFoundDigest(cause?.digest)\n );\n}\n\nexport async function createViteRscApp(\n container: Document | Element = document,\n interceptEntries: { urlPattern: string; slot: string }[] = [],\n options: { staticPayloads?: string | null; routes?: unknown[] | null; apiRoutes?: string[] } = {},\n): Promise<void> {\n // The urls a route.ts answers: a link to one is an anchor, never a\n // prefetch, never a payload fetch.\n if (options.apiRoutes) setApiRoutes(options.apiRoutes);\n // An exported build has no server to negotiate with, so payloads live at\n // their own urls rather than behind a header on the page's url.\n setStaticPayloads(options.staticPayloads ?? null);\n // Only an exported build ships this: with no server to negotiate with, the\n // client works out for itself how much of a page it still holds.\n if (options.routes) setStaticRoutes(options.routes as never);\n // The router has to recognise an intercepted link before it asks the server,\n // so the patterns are baked into the generated browser entry. Without them\n // every intercepted route falls through to a full-page navigation.\n setInterceptManifest(interceptEntries);\n\n async function callServer(id: string, args: unknown[]): Promise<unknown> {\n // A read opened a slot before calling the reference, and this is the first\n // point at which the id exists on the client — React keeps it private and\n // hands it over only here. Claiming the slot enqueues the read for the\n // batched GET instead of posting it.\n const read = claimRead(id, args);\n\n if (read) return await read;\n\n const encoded = await encodeReply(args);\n\n // encodeReply returns FormData as soon as an argument contains a File.\n // Sending that as multipart would make PHP consume php://input while\n // parsing it, leaving the action with an empty body — so serialize it to\n // raw bytes under an opaque content-type and send the real one in\n // X-RSC-Content-Type for the worker to rebuild FormData from.\n let body: BodyInit;\n let realContentType: string;\n\n if (encoded instanceof FormData) {\n const serialized = new Response(encoded);\n body = await serialized.arrayBuffer();\n realContentType =\n serialized.headers.get(\"content-type\") ?? \"multipart/form-data\";\n } else {\n body = encoded as BodyInit;\n realContentType = \"text/plain;charset=UTF-8\";\n }\n\n // Where the action was invoked from. The host resolves it to the\n // components that render the page, so anything the action says it\n // invalidated can come back with the answer instead of being fetched\n // afterwards - and what comes back is for this page, not whichever is\n // showing when it lands.\n const from = window.location.pathname + window.location.search;\n\n const res = await fetch(\"/_rsc/action\", {\n method: \"POST\",\n headers: {\n \"X-RSC-Action\": id,\n \"X-RSC-Referer\": from,\n \"X-RSC-Content-Type\": realContentType,\n \"Content-Type\": \"application/octet-stream\",\n \"X-XSRF-TOKEN\": decodeURIComponent(\n document.cookie.match(/XSRF-TOKEN=([^;]+)/)?.[1] ?? \"\",\n ),\n },\n body,\n });\n\n // A failed action does not answer with a Flight stream, and the decoder\n // cannot tell — it reports its own parse failure instead of what the\n // server said.\n try {\n await throwForFailedAction(res);\n } catch (err) {\n // A redirect is an instruction, not something for a form to display:\n // an expired session answers this way, and the destination is the login\n // page rather than a message about one.\n if (err instanceof ServerRedirectError) {\n // The destination came off a response header, so it is checked here\n // too — the engine refuses these at the source, but a proxy or a host\n // in front of it can write whatever it likes. A navigation, not a\n // document load: the layouts stay mounted and the history entry the\n // form was on is replaced, the way a redirect after a POST should\n // be - Back does not return to the submitted form.\n //\n // Awaited, so the action is still pending when the destination's\n // tree is handed to React: the two are one transition, committed\n // together. Not awaited, the action ended first - its optimistic\n // state dropped, pending went false - and the page it redirected to\n // arrived a frame later. A new chat's first message vanished from\n // the thread and came back with its reply.\n //\n // Asked of the server, never revealed from what the router holds. The\n // action may have changed anything the destination reads - a cookie,\n // a membership, a row - and a page kept from before it, or prefetched\n // before it, shows the world as it was: a sign-in that redirected\n // back showed the page signed out until a reload. What a revalidating\n // action already drops, a redirecting one drops too.\n if (isSafeRedirect(err.location)) {\n forgetOtherPages();\n\n try {\n await navigate(err.location as Route, { replace: true });\n } catch {\n // Announced by the navigation itself, as rsc-navigate-error. The\n // action did redirect; that is still its answer.\n }\n }\n\n // Performed, so resolved - not thrown. The call's answer is \"you are\n // being taken somewhere\": an object saying so, the shape an action's\n // result already has, so a caller reading result.validationErrors\n // reads undefined rather than throwing. A caller that awaited the\n // action in a plain startTransition had no catch for a throw, the\n // rejection reached React, and the root unmounted to a white page\n // on every logout.\n noteRedirected(err.location);\n\n return { redirected: err.location };\n }\n\n throw err;\n }\n\n const answer = await createFromReadableStream(res.body!, { callServer });\n\n return unwrapRevalidated(answer, from);\n }\n\n /**\n * Put anything the action re-rendered on screen, and hand back its result.\n *\n * The trees travel with the answer rather than being fetched afterwards, so\n * the caller sees only what its action returned and never knows the page\n * was updated around it.\n */\n function unwrapRevalidated(answer: unknown, from: string): unknown {\n if (\n answer === null ||\n typeof answer !== \"object\" ||\n !(\"__rscRevalidated\" in answer)\n ) {\n return answer;\n }\n\n const envelope = answer as {\n __rscRevalidated: Record<string, unknown>;\n result: unknown;\n };\n\n applyRevalidations(from, envelope.__rscRevalidated as Record<string, ReactNode>);\n\n return envelope.result;\n }\n\n setDeserializer(createFromReadableStream as never);\n // The query transport speaks Flight too, and reaches the runtime through here\n // rather than importing it: a second import of the browser runtime from the\n // client-component graph is a second client-reference registry, and the\n // symptom is components that render as undefined with nothing logged.\n setQueryCodec({\n deserialize: (stream) =>\n createFromReadableStream(stream, { callServer }) as Promise<unknown>,\n encode: (args) => encodeReply(args) as Promise<string | FormData>,\n // The way back when a read cannot ride in a url. Re-entering callServer is\n // safe: the slot was cleared the moment the reference returned, so this\n // takes the ordinary POST path rather than claiming a read again.\n asAction: (id, args) => callServer(id, args),\n });\n setCallServer(callServer);\n // The plugin's own \"use server\" client stubs route through its registered\n // server callback — register the same transport there too.\n setServerCallback(callServer as never);\n\n // Link / Form / router live in a separate build graph and reach the SPA\n // engine through these globals.\n (window as unknown as { __rsc_navigate: typeof navigate }).__rsc_navigate =\n navigate;\n (window as unknown as { __rsc_prefetch: typeof prefetch }).__rsc_prefetch =\n prefetch;\n (\n window as unknown as { __rsc_cancel_prefetch: typeof cancelPrefetch }\n ).__rsc_cancel_prefetch = cancelPrefetch;\n (\n window as unknown as { __rsc_is_prefetched: typeof isPrefetched }\n ).__rsc_is_prefetched = isPrefetched;\n (window as unknown as { __rsc_refresh: typeof refresh }).__rsc_refresh =\n refresh;\n\n // Hydrate from the RSC endpoint (same url + X-RSC, no version header).\n //\n // Everything from here to the decode is failure handling, because this is\n // the one request with nothing watching it. A page whose shell is already\n // rendered looks fine while this fails, and its fallbacks stay on screen\n // indefinitely with nothing reported anywhere.\n // The payload the document streamed in for itself, when it did - one\n // render per visit, see inlinePayload.ts. A page the build wrote whole\n // fetches its stored payload, as it always did.\n const res = inlinePayload() ?? (await fetchPagePayload(payloadUrl(window.location.href)));\n\n // Seed the router with the build this DOCUMENT is, so a redeploy is caught\n // on the next navigation: the host answers 409 to a client of another\n // build, and the document is loaded again. From the document's own meta\n // first - a document a service worker served from its cache is the last\n // build's, while the payload just fetched is this one's, and seeding from\n // the payload would have the old client claim to be new. The header is\n // the fallback for a document with no meta.\n const documentBuild = document.querySelector('meta[name=\"rsc-kit:build\"]')?.getAttribute(\"content\");\n const servedVersion = documentBuild || res.headers.get(\"X-RSC-Version\");\n\n if (servedVersion) {\n setVersion(servedVersion);\n }\n\n // The chain this page is built from, so the next navigation can say what is\n // already mounted and be sent only what changed.\n // A server says what this page is built from; a file server says nothing,\n // so an exported build works it out from the table it was given.\n const servedLayouts = res.headers.get(\"X-RSC-Layouts\");\n\n if (servedLayouts !== null) {\n setHeldLayouts(servedLayouts.split(\",\"));\n } else if (!seedStaticChain(window.location.href)) {\n setHeldLayouts([]);\n }\n const tree = await createFromReadableStream(res.body!, { callServer });\n\n // Retaining the previous page behind <Activity> needs a wrapper above the\n // page, and React will not hydrate a *document* container through one: the\n // root child of a document has to be <html>, and wrapping it hangs the\n // renderer outright (React 19.2.7). An app whose root layout owns <html>\n // therefore hydrates the tree directly and navigations replace it, as before.\n //\n // Apps that hydrate into an element get retention. Giving it to document-\n // rooted apps means SPA navigation returning only the changed segment rather\n // than a whole document, which is an engine change, not a client one.\n const retains = container !== document;\n\n const shell = retains\n ? createElement(ActivityRoot, {\n initialKey: retentionKey(window.location.href, null),\n initialTree: tree as ReactNode,\n })\n : (tree as ReactNode);\n\n // A document that cannot be hydrated by this tree is client-rendered\n // instead - a repaint, not a freeze. React 19.2 does not recover from a\n // hydration mismatch at an <Activity>: it retries hydrating the boundary,\n // mismatches again, and never returns to the main thread. Every segment\n // boundary is an Activity, one per layout, so a document with none where\n // the page has layouts is that mismatch, guaranteed, before React starts.\n // What produced one: a parameterised route's PPR shell, rendered without\n // a page key and, by a build before this one, without the Activities too.\n // None rather than fewer: a boundary inside a Suspense hole the shell left\n // unfinished has no marker and is client-rendered by React on its own,\n // which is not a mismatch. The stale-asset reload does not apply - the\n // document would come back the same.\n const missing = retains && getHeldLayouts().length > 0 && activityMarkersIn(container) === 0;\n\n if (missing) {\n console.warn(\n \"[rsc-kit] The document has no <Activity> boundaries where the page has layouts, so it cannot be hydrated; rendering the page instead. A PPR shell built by an earlier release lacks them - rebuild.\",\n );\n }\n\n // The payload answered with an error status - the not-found page for a\n // url the shell was served for anyway. It is not the document on screen,\n // so it is rendered, not hydrated: a mismatch at an Activity is the loop\n // above, and this one is certain.\n const disagrees = !res.ok;\n\n const onRecoverableError = (error: unknown, errorInfo: unknown) => {\n // A client component whose chunk the server no longer has fails while\n // hydrating, and React reports that as recoverable: the page is loaded\n // again, with the current names.\n if (recoverFromStaleAssets(error)) return;\n\n // A redirect decided inside a boundary: the server's row carried it as\n // the digest, React client-renders the boundary and reports that it\n // did, and the RedirectBoundary is already performing it. Nothing to\n // read in the console about a page doing what it was told.\n if (isRedirect(error)) return;\n\n // A PPR shell is served with its Suspense boundaries deliberately\n // unfinished — the build aborts the render once the static part is out.\n // React reports that as #419 and client-renders the boundary from the\n // Flight payload, which is the intended path, not a fault to report.\n const message = String((error as { message?: string })?.message ?? error);\n\n if (\n message.includes(\"419\") ||\n message.includes(\"did not finish this Suspense boundary\")\n ) {\n return;\n }\n\n // A view transition the browser cancelled because the tab was not\n // visible. React reports it here; the update still landed, and a tab\n // in the background is not a fault in the page.\n if (message.includes(\"Transition was aborted\")) return;\n\n // A navigation another one overtook: its request was aborted, and a\n // row of its payload that a component was still reading rejects with\n // the abort. React recovers by rendering the root again synchronously\n // and reports the recovery here as #520, with the abort as the cause.\n // The page it recovered to is the one the second navigation asked for;\n // the abort was the design, not a fault.\n const cause = (error as { cause?: { name?: string; message?: string } } | null)?.cause;\n\n if (\n cause?.name === \"AbortError\" ||\n /\\baborted\\b/i.test(cause?.message ?? \"\") ||\n /\\baborted\\b/i.test(message)\n ) {\n return;\n }\n // A page whose query string was read under a boundary carries the\n // fallback there; React reports the recovery on hydration. Under a\n // boundary the developer wrote, that is the designed path and nothing\n // is said. With nothing closer than a loading.tsx, the whole segment\n // showed the fallback until the query arrived - said here, in the\n // page and the console, for whoever is looking at either. Production\n // has no stack to tell the two apart; the build's note on the route is\n // the record there.\n if (\n (error as { digest?: string })?.digest === SEARCH_PARAMS_FALLBACK ||\n message.includes(\"useSearchParams()\")\n ) {\n const stack = (errorInfo as { componentStack?: string } | null)\n ?.componentStack;\n\n if (!caughtByLoading(stack)) return;\n\n const hint =\n \"useSearchParams() was read on the server with nothing closer than a loading.tsx, so the \" +\n \"whole segment showed that fallback until the query arrived. A <Suspense> around the \" +\n \"component that reads keeps the rest of the page painted.\";\n\n showDevNotice(hint, stack);\n console.error(new Error(hint), errorInfo);\n\n return;\n }\n\n console.error(error, errorInfo);\n };\n\n const rootOptions = {\n onRecoverableError,\n // A chunk the deploy no longer serves is not a fault in the page; the\n // document is loaded again, and the new names come with it. Anything\n // else is reported the way React would have.\n onUncaughtError(error: unknown, errorInfo: unknown) {\n if (recoverFromStaleAssets(error)) return;\n\n console.error(error, errorInfo);\n },\n onCaughtError(error: unknown, errorInfo: unknown) {\n if (recoverFromStaleAssets(error)) return;\n // Caught by the RedirectBoundary, which is performing it.\n if (isRedirect(error)) return;\n\n console.error(error, errorInfo);\n },\n };\n\n const root = missing || disagrees\n ? (() => {\n const created = createRoot(container as Element, rootOptions);\n\n created.render(shell);\n\n return created;\n })()\n : hydrateRoot(container, shell, rootOptions);\n\n // Depth 0 is a whole document and replaces the root. Anything deeper is one\n // segment: handing it to the boundary at that depth leaves the layouts above\n // it mounted, which is the point of asking for a partial render at all.\n setNavigateHandler((tree: unknown, key: string, segmentDepth: number, inPlaceOf?: string | null) => {\n const newTree = tree as ReactNode;\n\n // From here on the boundary animates; the seed commit before this did not.\n noteNavigation();\n\n if (segmentDepth > 0) {\n setSegment(segmentDepth, key, newTree, inPlaceOf);\n\n return;\n }\n\n clearSegments();\n root.render(newTree);\n });\n\n // The whole document again, in place - revalidate(\"all\"). Not through the\n // handler above: that clears the boundaries and renders the tree as a new\n // page, and a boundary emptied re-keys its Activity to the current url and\n // remounts everything under it. A port's \"added to cart\" went with the\n // form's state that way, on every product reached by a link. Here the root\n // takes the tree in a transition and each boundary hands its page the new\n // children under the key it has - see replaceActive.\n setReplaceRootHandler((tree: unknown) => {\n startTransition(() => root.render(tree as ReactNode));\n });\n\n // Back and forward reveal a page the boundaries are still holding, with the\n // form you were filling in still filled in, and without asking the server.\n setRestoreHandler((key: string, maxAge?: number) =>\n restoreSegments(key, maxAge),\n );\n setHeldHandlers(isHeld, dropHidden);\n\n // A touch or a settled hover: the page is rendered hidden now, and the\n // click reveals it. See warm() in navigate.ts and prerenderSegment.\n setPrerenderHandler((tree: unknown, key: string, segmentDepth: number) => {\n prerenderSegment(segmentDepth, key, tree as ReactNode);\n });\n\n window.addEventListener(\"popstate\", () => {\n // restore: back and forward reveal the page you were on, with its state.\n // Wherever the browser just went; not a literal this app wrote.\n navigate(window.location.href as Route, { replace: true, restore: true });\n });\n\n history.replaceState(\n { rscUrl: window.location.href },\n \"\",\n window.location.href,\n );\n\n // A tap held by the bootstrap script, navigated to once hydration has\n // committed - not now: the runtime's script running is seconds before\n // React can dispatch a click on a phone still downloading chunks, and\n // a tap in that window would be the browser's. See earlyClicks.ts.\n afterHydration(() => replayEarlyClicks((url) => navigate(url as Route)));\n}\n\n"]}
@@ -94,6 +94,12 @@ export declare function navigate(url: Route, opts?: {
94
94
  restore?: boolean;
95
95
  /** Internal: how many redirects led here. */
96
96
  redirectsFollowed?: number;
97
+ /**
98
+ * This url's page decided it does not exist after the shell was sent:
99
+ * ask for the not-found page and render it where the page was. The url
100
+ * and the history entry stay; what a prefetch kept is not the answer.
101
+ */
102
+ notFound?: boolean;
97
103
  }): Promise<void>;
98
104
  /**
99
105
  * Put something the server re-rendered on screen.
@@ -417,11 +417,19 @@ priority = "high",
417
417
  * link did the same to a half-filled form. The session is marked stale
418
418
  * instead, so the next navigation the visitor makes is a document load.
419
419
  */
420
- speculative = false) {
420
+ speculative = false,
421
+ /**
422
+ * Ask for the not-found page in place of this url's page: its own render
423
+ * said, after the shell had gone out, that nothing is here.
424
+ */
425
+ notFound = false) {
421
426
  const headers = {
422
427
  "X-RSC": "true",
423
428
  "X-RSC-Version": version,
424
429
  };
430
+ if (notFound) {
431
+ headers["X-RSC-Not-Found"] = "1";
432
+ }
425
433
  if (chain.length) {
426
434
  headers["X-RSC-Segments"] = chain.join(",");
427
435
  }
@@ -695,7 +703,7 @@ export async function navigate(url, opts) {
695
703
  const previousUrl = window.location.pathname + window.location.search;
696
704
  try {
697
705
  const cacheKey = retentionKeyFor(url, interceptSlot);
698
- const cached = cache.get(cacheKey);
706
+ const cached = opts?.notFound ? undefined : cache.get(cacheKey);
699
707
  let treePromise;
700
708
  const chain = claimedChain(interceptSlot);
701
709
  // A partial payload only composes against the chain it was rendered for —
@@ -723,7 +731,7 @@ export async function navigate(url, opts) {
723
731
  navigating.add(cacheKey);
724
732
  let response;
725
733
  try {
726
- response = await fetchRscPayload(url, controller.signal, interceptSlot ?? undefined, currentUrl, chain);
734
+ response = await fetchRscPayload(url, controller.signal, interceptSlot ?? undefined, currentUrl, chain, "high", false, opts?.notFound === true);
727
735
  }
728
736
  finally {
729
737
  navigating.delete(cacheKey);