react-router 0.0.0-experimental-4cf5bd08c → 0.0.0-experimental-fbc98d36c

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 (33) hide show
  1. package/dist/development/{chunk-S26THQOM.js → chunk-3CA7XI72.js} +19 -13
  2. package/dist/development/{chunk-JGV7YEW2.mjs → chunk-7GSUB5NN.mjs} +20 -14
  3. package/dist/development/{chunk-LRHWL6QF.mjs → chunk-M62UTJYV.mjs} +87 -8
  4. package/dist/{production/chunk-2Y2ZW6ZH.js → development/chunk-QKLHOJUD.js} +131 -131
  5. package/dist/development/dom-export.js +3 -3
  6. package/dist/development/dom-export.mjs +3 -3
  7. package/dist/development/index-react-server-client.js +4 -4
  8. package/dist/development/index-react-server-client.mjs +2 -2
  9. package/dist/development/index-react-server.js +3 -3
  10. package/dist/development/index-react-server.mjs +3 -3
  11. package/dist/development/index.d.mts +10 -6
  12. package/dist/development/index.d.ts +10 -6
  13. package/dist/development/index.js +183 -104
  14. package/dist/development/index.mjs +3 -3
  15. package/dist/development/lib/types/internal.js +1 -1
  16. package/dist/development/lib/types/internal.mjs +1 -1
  17. package/dist/production/{chunk-3OEOUICR.mjs → chunk-DLFE4QXK.mjs} +20 -14
  18. package/dist/{development/chunk-TW7D4RFJ.js → production/chunk-JO4THVNU.js} +131 -131
  19. package/dist/production/{chunk-ZPOX44CY.mjs → chunk-QHYDKGKP.mjs} +87 -8
  20. package/dist/production/{chunk-GWTF4PDT.js → chunk-ZYB7Y7FF.js} +19 -13
  21. package/dist/production/dom-export.js +3 -3
  22. package/dist/production/dom-export.mjs +3 -3
  23. package/dist/production/index-react-server-client.js +4 -4
  24. package/dist/production/index-react-server-client.mjs +2 -2
  25. package/dist/production/index-react-server.js +3 -3
  26. package/dist/production/index-react-server.mjs +3 -3
  27. package/dist/production/index.d.mts +10 -6
  28. package/dist/production/index.d.ts +10 -6
  29. package/dist/production/index.js +183 -104
  30. package/dist/production/index.mjs +3 -3
  31. package/dist/production/lib/types/internal.js +1 -1
  32. package/dist/production/lib/types/internal.mjs +1 -1
  33. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
2
- * react-router v0.0.0-experimental-4cf5bd08c
2
+ * react-router v0.0.0-experimental-fbc98d36c
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -6239,10 +6239,10 @@ function useOutletContext() {
6239
6239
  }
6240
6240
  function useOutlet(context) {
6241
6241
  let outlet = React3.useContext(RouteContext).outlet;
6242
- if (outlet) {
6243
- return /* @__PURE__ */ React3.createElement(OutletContext.Provider, { value: context }, outlet);
6244
- }
6245
- return outlet;
6242
+ return React3.useMemo(
6243
+ () => outlet && /* @__PURE__ */ React3.createElement(OutletContext.Provider, { value: context }, outlet),
6244
+ [outlet, context]
6245
+ );
6246
6246
  }
6247
6247
  function useParams() {
6248
6248
  let { matches } = React3.useContext(RouteContext);
@@ -7514,7 +7514,7 @@ function getManifestPath(_manifestPath, basename) {
7514
7514
  var MANIFEST_VERSION_STORAGE_KEY = "react-router-manifest-version";
7515
7515
  async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, manifestPath, patchRoutes, signal) {
7516
7516
  const searchParams = new URLSearchParams();
7517
- paths.sort().forEach((path) => searchParams.append("p", path));
7517
+ searchParams.set("paths", paths.sort().join(","));
7518
7518
  searchParams.set("version", manifest.version);
7519
7519
  let url = new URL(
7520
7520
  getManifestPath(manifestPath, basename),
@@ -7537,13 +7537,16 @@ async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, ro
7537
7537
  );
7538
7538
  return;
7539
7539
  }
7540
- if (sessionStorage.getItem(MANIFEST_VERSION_STORAGE_KEY) === manifest.version) {
7541
- console.error(
7542
- "Unable to discover routes due to manifest version mismatch."
7543
- );
7544
- return;
7540
+ try {
7541
+ if (sessionStorage.getItem(MANIFEST_VERSION_STORAGE_KEY) === manifest.version) {
7542
+ console.error(
7543
+ "Unable to discover routes due to manifest version mismatch."
7544
+ );
7545
+ return;
7546
+ }
7547
+ sessionStorage.setItem(MANIFEST_VERSION_STORAGE_KEY, manifest.version);
7548
+ } catch (e2) {
7545
7549
  }
7546
- sessionStorage.setItem(MANIFEST_VERSION_STORAGE_KEY, manifest.version);
7547
7550
  window.location.href = errorReloadPath;
7548
7551
  console.warn("Detected manifest version mismatch, reloading...");
7549
7552
  await new Promise(() => {
@@ -7551,7 +7554,10 @@ async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, ro
7551
7554
  } else if (res.status >= 400) {
7552
7555
  throw new Error(await res.text());
7553
7556
  }
7554
- sessionStorage.removeItem(MANIFEST_VERSION_STORAGE_KEY);
7557
+ try {
7558
+ sessionStorage.removeItem(MANIFEST_VERSION_STORAGE_KEY);
7559
+ } catch (e3) {
7560
+ }
7555
7561
  serverPatches = await res.json();
7556
7562
  } catch (e) {
7557
7563
  if (_optionalChain([signal, 'optionalAccess', _97 => _97.aborted])) return;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-4cf5bd08c
2
+ * react-router v0.0.0-experimental-fbc98d36c
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -5061,10 +5061,10 @@ function useOutletContext() {
5061
5061
  }
5062
5062
  function useOutlet(context) {
5063
5063
  let outlet = React2.useContext(RouteContext).outlet;
5064
- if (outlet) {
5065
- return /* @__PURE__ */ React2.createElement(OutletContext.Provider, { value: context }, outlet);
5066
- }
5067
- return outlet;
5064
+ return React2.useMemo(
5065
+ () => outlet && /* @__PURE__ */ React2.createElement(OutletContext.Provider, { value: context }, outlet),
5066
+ [outlet, context]
5067
+ );
5068
5068
  }
5069
5069
  function useParams() {
5070
5070
  let { matches } = React2.useContext(RouteContext);
@@ -8277,7 +8277,7 @@ function getManifestPath(_manifestPath, basename) {
8277
8277
  var MANIFEST_VERSION_STORAGE_KEY = "react-router-manifest-version";
8278
8278
  async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, manifestPath, patchRoutes, signal) {
8279
8279
  const searchParams = new URLSearchParams();
8280
- paths.sort().forEach((path) => searchParams.append("p", path));
8280
+ searchParams.set("paths", paths.sort().join(","));
8281
8281
  searchParams.set("version", manifest.version);
8282
8282
  let url = new URL(
8283
8283
  getManifestPath(manifestPath, basename),
@@ -8300,13 +8300,16 @@ async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, ro
8300
8300
  );
8301
8301
  return;
8302
8302
  }
8303
- if (sessionStorage.getItem(MANIFEST_VERSION_STORAGE_KEY) === manifest.version) {
8304
- console.error(
8305
- "Unable to discover routes due to manifest version mismatch."
8306
- );
8307
- return;
8303
+ try {
8304
+ if (sessionStorage.getItem(MANIFEST_VERSION_STORAGE_KEY) === manifest.version) {
8305
+ console.error(
8306
+ "Unable to discover routes due to manifest version mismatch."
8307
+ );
8308
+ return;
8309
+ }
8310
+ sessionStorage.setItem(MANIFEST_VERSION_STORAGE_KEY, manifest.version);
8311
+ } catch {
8308
8312
  }
8309
- sessionStorage.setItem(MANIFEST_VERSION_STORAGE_KEY, manifest.version);
8310
8313
  window.location.href = errorReloadPath;
8311
8314
  console.warn("Detected manifest version mismatch, reloading...");
8312
8315
  await new Promise(() => {
@@ -8314,7 +8317,10 @@ async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, ro
8314
8317
  } else if (res.status >= 400) {
8315
8318
  throw new Error(await res.text());
8316
8319
  }
8317
- sessionStorage.removeItem(MANIFEST_VERSION_STORAGE_KEY);
8320
+ try {
8321
+ sessionStorage.removeItem(MANIFEST_VERSION_STORAGE_KEY);
8322
+ } catch {
8323
+ }
8318
8324
  serverPatches = await res.json();
8319
8325
  } catch (e) {
8320
8326
  if (signal?.aborted) return;
@@ -8979,7 +8985,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
8979
8985
  try {
8980
8986
  if (isBrowser) {
8981
8987
  window.__reactRouterVersion = // @ts-expect-error
8982
- "0.0.0-experimental-4cf5bd08c";
8988
+ "0.0.0-experimental-fbc98d36c";
8983
8989
  }
8984
8990
  } catch (e) {
8985
8991
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-4cf5bd08c
2
+ * react-router v0.0.0-experimental-fbc98d36c
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -59,7 +59,7 @@ import {
59
59
  withComponentProps,
60
60
  withErrorBoundaryProps,
61
61
  withHydrateFallbackProps
62
- } from "./chunk-JGV7YEW2.mjs";
62
+ } from "./chunk-7GSUB5NN.mjs";
63
63
 
64
64
  // lib/dom/ssr/server.tsx
65
65
  import * as React from "react";
@@ -1234,9 +1234,11 @@ async function handleManifestRequest(build, routes, url) {
1234
1234
  });
1235
1235
  }
1236
1236
  let patches = {};
1237
- if (url.searchParams.has("p")) {
1237
+ if (url.searchParams.has("paths")) {
1238
1238
  let paths = /* @__PURE__ */ new Set();
1239
- url.searchParams.getAll("p").forEach((path) => {
1239
+ let pathParam = url.searchParams.get("paths") || "";
1240
+ let requestedPaths = pathParam.split(",").filter(Boolean);
1241
+ requestedPaths.forEach((path) => {
1240
1242
  if (!path.startsWith("/")) {
1241
1243
  path = `/${path}`;
1242
1244
  }
@@ -2407,7 +2409,7 @@ function getManifestUrl(paths) {
2407
2409
  ""
2408
2410
  );
2409
2411
  let url = new URL(`${basename}/.manifest`, window.location.origin);
2410
- paths.sort().forEach((path) => url.searchParams.append("p", path));
2412
+ url.searchParams.set("paths", paths.sort().join(","));
2411
2413
  return url;
2412
2414
  }
2413
2415
  async function fetchAndApplyManifestPatches(paths, createFromReadableStream, fetchImplementation, signal) {
@@ -2601,8 +2603,28 @@ async function routeRSCServerRequest({
2601
2603
  }
2602
2604
  });
2603
2605
  };
2604
- const getPayload = async () => {
2605
- return createFromReadableStream(createStream());
2606
+ let deepestRenderedBoundaryId = null;
2607
+ const getPayload = () => {
2608
+ const payloadPromise = Promise.resolve(
2609
+ createFromReadableStream(createStream())
2610
+ );
2611
+ return Object.defineProperties(payloadPromise, {
2612
+ _deepestRenderedBoundaryId: {
2613
+ get() {
2614
+ return deepestRenderedBoundaryId;
2615
+ },
2616
+ set(boundaryId) {
2617
+ deepestRenderedBoundaryId = boundaryId;
2618
+ }
2619
+ },
2620
+ formState: {
2621
+ get() {
2622
+ return payloadPromise.then(
2623
+ (payload) => payload.type === "render" ? payload.formState : void 0
2624
+ );
2625
+ }
2626
+ }
2627
+ });
2606
2628
  };
2607
2629
  try {
2608
2630
  if (!detectRedirectResponse.body) {
@@ -2645,11 +2667,62 @@ async function routeRSCServerRequest({
2645
2667
  if (reason instanceof Response) {
2646
2668
  return reason;
2647
2669
  }
2670
+ try {
2671
+ const status = isRouteErrorResponse(reason) ? reason.status : 500;
2672
+ const html = await renderHTML(() => {
2673
+ const decoded = Promise.resolve(
2674
+ createFromReadableStream(createStream())
2675
+ );
2676
+ const payloadPromise = decoded.then(
2677
+ (payload) => Object.assign(payload, {
2678
+ status,
2679
+ errors: deepestRenderedBoundaryId ? {
2680
+ [deepestRenderedBoundaryId]: reason
2681
+ } : {}
2682
+ })
2683
+ );
2684
+ return Object.defineProperties(payloadPromise, {
2685
+ _deepestRenderedBoundaryId: {
2686
+ get() {
2687
+ return deepestRenderedBoundaryId;
2688
+ },
2689
+ set(boundaryId) {
2690
+ deepestRenderedBoundaryId = boundaryId;
2691
+ }
2692
+ },
2693
+ formState: {
2694
+ get() {
2695
+ return payloadPromise.then(
2696
+ (payload) => payload.type === "render" ? payload.formState : void 0
2697
+ );
2698
+ }
2699
+ }
2700
+ });
2701
+ });
2702
+ const headers = new Headers(serverResponse.headers);
2703
+ headers.set("Content-Type", "text/html");
2704
+ if (!hydrate) {
2705
+ return new Response(html, {
2706
+ status,
2707
+ headers
2708
+ });
2709
+ }
2710
+ if (!serverResponseB?.body) {
2711
+ throw new Error("Failed to clone server response");
2712
+ }
2713
+ const body2 = html.pipeThrough(injectRSCPayload(serverResponseB.body));
2714
+ return new Response(body2, {
2715
+ status,
2716
+ headers
2717
+ });
2718
+ } catch {
2719
+ }
2648
2720
  throw reason;
2649
2721
  }
2650
2722
  }
2651
2723
  function RSCStaticRouter({ getPayload }) {
2652
- const payload = useSafe(getPayload());
2724
+ const decoded = getPayload();
2725
+ const payload = useSafe(decoded);
2653
2726
  if (payload.type === "redirect") {
2654
2727
  throw new Response(null, {
2655
2728
  status: payload.status,
@@ -2671,6 +2744,12 @@ function RSCStaticRouter({ getPayload }) {
2671
2744
  }
2672
2745
  }
2673
2746
  const context = {
2747
+ get _deepestRenderedBoundaryId() {
2748
+ return decoded._deepestRenderedBoundaryId ?? null;
2749
+ },
2750
+ set _deepestRenderedBoundaryId(boundaryId) {
2751
+ decoded._deepestRenderedBoundaryId = boundaryId;
2752
+ },
2674
2753
  actionData: payload.actionData,
2675
2754
  actionHeaders: {},
2676
2755
  basename: payload.basename,