react-router 0.0.0-experimental-e87ed2fd4 → 0.0.0-experimental-e7eb25a7b

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 (40) hide show
  1. package/CHANGELOG.md +91 -2
  2. package/dist/development/{browser-C9OqCpRB.d.mts → browser-BM9EKN98.d.mts} +3 -3
  3. package/dist/development/{chunk-PVJCBITV.mjs → chunk-SHQJZRZ7.mjs} +127 -36
  4. package/dist/development/dom-export.d.mts +2 -2
  5. package/dist/development/dom-export.js +2 -1
  6. package/dist/development/dom-export.mjs +3 -2
  7. package/dist/development/index.d.mts +5 -5
  8. package/dist/development/index.d.ts +5 -5
  9. package/dist/development/index.js +137 -46
  10. package/dist/development/index.mjs +7 -7
  11. package/dist/development/lib/types/internal.d.mts +1 -1
  12. package/dist/development/lib/types/internal.d.ts +1 -1
  13. package/dist/development/lib/types/internal.js +1 -1
  14. package/dist/development/lib/types/internal.mjs +1 -1
  15. package/dist/{production/register-zy84znbA.d.ts → development/register-B0EYMBux.d.ts} +1 -1
  16. package/dist/{production/route-data-C-cmsWVs.d.mts → development/route-data-B3YkvRuy.d.mts} +1 -1
  17. package/dist/development/rsc-export.d.mts +1 -2
  18. package/dist/development/rsc-export.d.ts +1 -2
  19. package/dist/development/rsc-export.js +59 -37
  20. package/dist/development/rsc-export.mjs +60 -38
  21. package/dist/production/{browser-C9OqCpRB.d.mts → browser-BM9EKN98.d.mts} +3 -3
  22. package/dist/production/{chunk-FJS6IVQF.mjs → chunk-VMGK4BUZ.mjs} +127 -36
  23. package/dist/production/dom-export.d.mts +2 -2
  24. package/dist/production/dom-export.js +2 -1
  25. package/dist/production/dom-export.mjs +3 -2
  26. package/dist/production/index.d.mts +5 -5
  27. package/dist/production/index.d.ts +5 -5
  28. package/dist/production/index.js +137 -46
  29. package/dist/production/index.mjs +7 -7
  30. package/dist/production/lib/types/internal.d.mts +1 -1
  31. package/dist/production/lib/types/internal.d.ts +1 -1
  32. package/dist/production/lib/types/internal.js +1 -1
  33. package/dist/production/lib/types/internal.mjs +1 -1
  34. package/dist/{development/register-zy84znbA.d.ts → production/register-B0EYMBux.d.ts} +1 -1
  35. package/dist/{development/route-data-C-cmsWVs.d.mts → production/route-data-B3YkvRuy.d.mts} +1 -1
  36. package/dist/production/rsc-export.d.mts +1 -2
  37. package/dist/production/rsc-export.d.ts +1 -2
  38. package/dist/production/rsc-export.js +59 -37
  39. package/dist/production/rsc-export.mjs +60 -38
  40. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
- import { parse, serialize } from 'cookie';
1
+ import { serialize, parse } from 'cookie';
2
2
  import * as React from 'react';
3
3
  import { splitCookiesString } from 'set-cookie-parser';
4
4
 
5
5
  /**
6
- * react-router v0.0.0-experimental-e87ed2fd4
6
+ * react-router v0.0.0-experimental-e7eb25a7b
7
7
  *
8
8
  * Copyright (c) Remix Software Inc.
9
9
  *
@@ -39,7 +39,7 @@ function createKey() {
39
39
  }
40
40
  function createLocation(current, to, state = null, key) {
41
41
  let location = {
42
- pathname: typeof current === "string" ? current : current.pathname,
42
+ pathname: "string" === "string" ? current : current.pathname,
43
43
  search: "",
44
44
  hash: "",
45
45
  ...typeof to === "string" ? parsePath(to) : to,
@@ -1484,10 +1484,9 @@ async function runMiddlewarePipeline(args, propagateResult, handler, errorHandle
1484
1484
  middlewareState.middlewareError.error,
1485
1485
  middlewareState.middlewareError.routeId
1486
1486
  );
1487
- if (propagateResult || !middlewareState.handlerResult) {
1487
+ {
1488
1488
  return result;
1489
1489
  }
1490
- return Object.assign(middlewareState.handlerResult, result);
1491
1490
  }
1492
1491
  }
1493
1492
  async function callRouteMiddleware(args, middlewares, propagateResult, middlewareState, handler, idx = 0) {
@@ -1521,7 +1520,7 @@ async function callRouteMiddleware(args, middlewares, propagateResult, middlewar
1521
1520
  handler,
1522
1521
  idx + 1
1523
1522
  );
1524
- if (propagateResult) {
1523
+ {
1525
1524
  nextResult = result;
1526
1525
  return nextResult;
1527
1526
  }
@@ -2454,19 +2453,28 @@ async function matchRSCServerRequest({
2454
2453
  }
2455
2454
  async function generateManifestResponse(routes, request, generateResponse) {
2456
2455
  let url = new URL(request.url);
2457
- let matches = matchRoutes(routes, url.pathname.replace(/\.manifest$/, ""));
2456
+ let pathnameParams = url.searchParams.getAll("p");
2457
+ let pathnames = pathnameParams.length ? pathnameParams : [url.pathname.replace(/\.manifest$/, "")];
2458
+ let routeIds = /* @__PURE__ */ new Set();
2459
+ let matchedRoutes = pathnames.flatMap((pathname) => {
2460
+ let pathnameMatches = matchRoutes(routes, pathname);
2461
+ return pathnameMatches?.map((m, i) => ({
2462
+ ...m.route,
2463
+ parentId: pathnameMatches[i - 1]?.route.id
2464
+ })) ?? [];
2465
+ }).filter((route) => {
2466
+ if (!routeIds.has(route.id)) {
2467
+ routeIds.add(route.id);
2468
+ return true;
2469
+ }
2470
+ return false;
2471
+ });
2458
2472
  let payload = {
2459
2473
  type: "manifest",
2460
- matches: await Promise.all(
2461
- matches?.map(
2462
- (m, i) => getManifestRoute(m.route, matches[i - 1]?.route.id)
2463
- ) ?? []
2464
- ),
2465
- patches: await getAdditionalRoutePatches(
2466
- url.pathname,
2467
- routes,
2468
- matches?.map((m) => m.route.id) ?? []
2469
- )
2474
+ patches: (await Promise.all([
2475
+ ...matchedRoutes.map((route) => getManifestRoute(route)),
2476
+ getAdditionalRoutePatches(pathnames, routes, Array.from(routeIds))
2477
+ ])).flat(1)
2470
2478
  };
2471
2479
  return generateResponse({
2472
2480
  statusCode: 200,
@@ -2533,7 +2541,11 @@ async function generateRenderResponse(request, routes, decodeCallServer, decodeF
2533
2541
  if (matches) {
2534
2542
  await Promise.all(matches.map((m) => explodeLazyRoute(m.route)));
2535
2543
  }
2536
- const handler = createStaticHandler(routes);
2544
+ const handler = createStaticHandler(routes, {
2545
+ mapRouteProperties: (r) => ({
2546
+ hasErrorBoundary: r.ErrorBoundary != null
2547
+ })
2548
+ });
2537
2549
  const result = await handler.query(request, {
2538
2550
  skipLoaderErrorBubbling: isDataRequest,
2539
2551
  skipRevalidation: isSubmission,
@@ -2671,7 +2683,7 @@ async function getRenderPayload(baseRenderPayload, routes, routeIdsToLoad, isDat
2671
2683
  })
2672
2684
  );
2673
2685
  let patchesPromise = !isDataRequest ? getAdditionalRoutePatches(
2674
- staticContext.location.pathname,
2686
+ [staticContext.location.pathname],
2675
2687
  routes,
2676
2688
  staticContext.matches.map((m) => m.route.id)
2677
2689
  ) : void 0;
@@ -2767,7 +2779,7 @@ async function getServerRouteMatch(staticContext, match, shouldRenderComponent,
2767
2779
  shouldRevalidate: match.route.shouldRevalidate
2768
2780
  };
2769
2781
  }
2770
- async function getManifestRoute(route, parentId) {
2782
+ async function getManifestRoute(route) {
2771
2783
  await explodeLazyRoute(route);
2772
2784
  const Layout = route.Layout || React.Fragment;
2773
2785
  const errorElement = route.ErrorBoundary ? React.createElement(
@@ -2784,7 +2796,7 @@ async function getManifestRoute(route, parentId) {
2784
2796
  errorElement,
2785
2797
  hasLoader: !!route.loader,
2786
2798
  id: route.id,
2787
- parentId,
2799
+ parentId: route.parentId,
2788
2800
  path: route.path,
2789
2801
  index: "index" in route ? route.index : void 0,
2790
2802
  links: route.links,
@@ -2800,26 +2812,36 @@ async function explodeLazyRoute(route) {
2800
2812
  route.lazy = void 0;
2801
2813
  }
2802
2814
  }
2803
- async function getAdditionalRoutePatches(pathname, routes, matchedRouteIds) {
2815
+ async function getAdditionalRoutePatches(pathnames, routes, matchedRouteIds) {
2804
2816
  let patchRouteMatches = /* @__PURE__ */ new Map();
2805
- let segments = pathname.split("/").filter(Boolean);
2806
- let paths = ["/"];
2807
- segments.pop();
2808
- while (segments.length > 0) {
2809
- paths.push(`/${segments.join("/")}`);
2817
+ let matchedPaths = /* @__PURE__ */ new Set();
2818
+ for (const pathname of pathnames) {
2819
+ let segments = pathname.split("/").filter(Boolean);
2820
+ let paths = ["/"];
2810
2821
  segments.pop();
2822
+ while (segments.length > 0) {
2823
+ paths.push(`/${segments.join("/")}`);
2824
+ segments.pop();
2825
+ }
2826
+ paths.forEach((path) => {
2827
+ if (matchedPaths.has(path)) {
2828
+ return;
2829
+ }
2830
+ matchedPaths.add(path);
2831
+ let matches = matchRoutes(routes, path) || [];
2832
+ matches.forEach((m, i) => {
2833
+ if (patchRouteMatches.get(m.route.id)) {
2834
+ return;
2835
+ }
2836
+ patchRouteMatches.set(m.route.id, {
2837
+ ...m.route,
2838
+ parentId: matches[i - 1]?.route.id
2839
+ });
2840
+ });
2841
+ });
2811
2842
  }
2812
- paths.forEach((path) => {
2813
- let matches = matchRoutes(routes, path) || [];
2814
- matches.forEach(
2815
- (m, i) => patchRouteMatches.set(m.route.id, {
2816
- ...m.route,
2817
- parentId: matches[i - 1]?.route.id
2818
- })
2819
- );
2820
- });
2821
2843
  let patches = await Promise.all(
2822
- [...patchRouteMatches.values()].filter((route) => !matchedRouteIds.some((id) => id === route.id)).map((route) => getManifestRoute(route, route.parentId))
2844
+ [...patchRouteMatches.values()].filter((route) => !matchedRouteIds.some((id) => id === route.id)).map((route) => getManifestRoute(route))
2823
2845
  );
2824
2846
  return patches;
2825
2847
  }
@@ -2831,4 +2853,4 @@ function canDecodeWithFormData(contentType) {
2831
2853
  return contentType.match(/\bapplication\/x-www-form-urlencoded\b/) || contentType.match(/\bmultipart\/form-data\b/);
2832
2854
  }
2833
2855
 
2834
- export { createCookie, createCookieSessionStorage, createMemorySessionStorage, createSession, createSessionStorage, createStaticHandler, data, isCookie, isSession, matchRSCServerRequest, matchRoutes, redirect, redirectDocument, replace, unstable_createContext };
2856
+ export { createCookie, createCookieSessionStorage, createMemorySessionStorage, createSession, createSessionStorage, createStaticHandler, data, isCookie, isSession, matchRoutes, redirect, redirectDocument, replace, unstable_createContext, matchRSCServerRequest as unstable_matchRSCServerRequest };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-router",
3
- "version": "0.0.0-experimental-e87ed2fd4",
3
+ "version": "0.0.0-experimental-e7eb25a7b",
4
4
  "description": "Declarative routing for React",
5
5
  "keywords": [
6
6
  "react",