react-router 7.13.2 → 7.14.0

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 (60) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/development/{browser-Bfn3xw9E.d.ts → browser-C9Ar1yxG.d.ts} +13 -10
  3. package/dist/development/{browser-Di6-vSl-.d.mts → browser-vtIR1Kpe.d.mts} +13 -10
  4. package/dist/development/{chunk-UALY5CBT.mjs → chunk-2UH5WJXA.mjs} +21 -7
  5. package/dist/development/{chunk-GO74ODU3.js → chunk-IK6APEEG.js} +191 -118
  6. package/dist/development/{chunk-HPFFRPKK.js → chunk-NXTEWSJO.js} +99 -99
  7. package/dist/development/{chunk-UVKPFVEO.mjs → chunk-QFMPRPBF.mjs} +192 -119
  8. package/dist/development/{chunk-LLP6DRWX.js → chunk-WAVMRYR2.js} +7 -7
  9. package/dist/development/dom-export.d.mts +1 -1
  10. package/dist/development/dom-export.d.ts +1 -1
  11. package/dist/development/dom-export.js +65 -54
  12. package/dist/development/dom-export.mjs +34 -23
  13. package/dist/{production/index-react-server-client-BcrVT7Dd.d.mts → development/index-react-server-client-BwWaHAr3.d.mts} +7 -5
  14. package/dist/development/{index-react-server-client-CCwMoQIT.d.ts → index-react-server-client-luDbagNU.d.ts} +7 -5
  15. package/dist/development/index-react-server-client.d.mts +1 -1
  16. package/dist/development/index-react-server-client.d.ts +1 -1
  17. package/dist/development/index-react-server-client.js +4 -4
  18. package/dist/development/index-react-server-client.mjs +2 -2
  19. package/dist/development/index-react-server.d.mts +12 -3
  20. package/dist/development/index-react-server.d.ts +12 -3
  21. package/dist/development/index-react-server.js +58 -18
  22. package/dist/development/index-react-server.mjs +58 -18
  23. package/dist/development/index.d.mts +4 -4
  24. package/dist/development/index.d.ts +4 -4
  25. package/dist/development/index.js +101 -87
  26. package/dist/development/index.mjs +3 -3
  27. package/dist/development/lib/types/internal.d.mts +10 -10
  28. package/dist/development/lib/types/internal.d.ts +10 -10
  29. package/dist/development/lib/types/internal.js +1 -1
  30. package/dist/development/lib/types/internal.mjs +1 -1
  31. package/dist/production/{browser-Bfn3xw9E.d.ts → browser-C9Ar1yxG.d.ts} +13 -10
  32. package/dist/production/{browser-Di6-vSl-.d.mts → browser-vtIR1Kpe.d.mts} +13 -10
  33. package/dist/production/{chunk-CAFVLUDY.js → chunk-355DUZMC.js} +7 -7
  34. package/dist/production/{chunk-LKUVSIBA.js → chunk-4TJ7T2OQ.js} +191 -118
  35. package/dist/production/{chunk-XAAX7KIK.js → chunk-FPT5DLVJ.js} +99 -99
  36. package/dist/production/{chunk-2BDJPJTA.mjs → chunk-HZQGQD2X.mjs} +192 -119
  37. package/dist/production/{chunk-PY35PE22.mjs → chunk-X5LK27NZ.mjs} +21 -7
  38. package/dist/production/dom-export.d.mts +1 -1
  39. package/dist/production/dom-export.d.ts +1 -1
  40. package/dist/production/dom-export.js +65 -54
  41. package/dist/production/dom-export.mjs +34 -23
  42. package/dist/{development/index-react-server-client-BcrVT7Dd.d.mts → production/index-react-server-client-BwWaHAr3.d.mts} +7 -5
  43. package/dist/production/{index-react-server-client-CCwMoQIT.d.ts → index-react-server-client-luDbagNU.d.ts} +7 -5
  44. package/dist/production/index-react-server-client.d.mts +1 -1
  45. package/dist/production/index-react-server-client.d.ts +1 -1
  46. package/dist/production/index-react-server-client.js +4 -4
  47. package/dist/production/index-react-server-client.mjs +2 -2
  48. package/dist/production/index-react-server.d.mts +12 -3
  49. package/dist/production/index-react-server.d.ts +12 -3
  50. package/dist/production/index-react-server.js +58 -18
  51. package/dist/production/index-react-server.mjs +58 -18
  52. package/dist/production/index.d.mts +4 -4
  53. package/dist/production/index.d.ts +4 -4
  54. package/dist/production/index.js +101 -87
  55. package/dist/production/index.mjs +3 -3
  56. package/dist/production/lib/types/internal.d.mts +10 -10
  57. package/dist/production/lib/types/internal.d.ts +10 -10
  58. package/dist/production/lib/types/internal.js +1 -1
  59. package/dist/production/lib/types/internal.mjs +1 -1
  60. package/package.json +1 -1
@@ -2221,14 +2221,15 @@ type RSCRenderPayload = {
2221
2221
  errors: Record<string, any> | null;
2222
2222
  loaderData: Record<string, any>;
2223
2223
  location: Location;
2224
+ routeDiscovery: RouteDiscovery;
2224
2225
  matches: RSCRouteMatch[];
2225
- patches?: RSCRouteManifest[];
2226
+ patches?: Promise<RSCRouteManifest[]>;
2226
2227
  nonce?: string;
2227
2228
  formState?: unknown;
2228
2229
  };
2229
2230
  type RSCManifestPayload = {
2230
2231
  type: "manifest";
2231
- patches: RSCRouteManifest[];
2232
+ patches: Promise<RSCRouteManifest[]>;
2232
2233
  };
2233
2234
  type RSCActionPayload = {
2234
2235
  type: "action";
@@ -2255,6 +2256,12 @@ type DecodeReplyFunction = (reply: FormData | string, options: {
2255
2256
  temporaryReferences: unknown;
2256
2257
  }) => Promise<unknown[]>;
2257
2258
  type LoadServerActionFunction = (id: string) => Promise<Function>;
2259
+ type RouteDiscovery = {
2260
+ mode: "lazy";
2261
+ manifestPath?: string | undefined;
2262
+ } | {
2263
+ mode: "initial";
2264
+ };
2258
2265
  /**
2259
2266
  * Matches the given routes to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
2260
2267
  * and returns an [RSC](https://react.dev/reference/rsc/server-components)
@@ -2321,12 +2328,13 @@ type LoadServerActionFunction = (id: string) => Promise<Function>;
2321
2328
  * @param opts.requestContext An instance of {@link RouterContextProvider}
2322
2329
  * that should be created per request, to be passed to [`action`](../../start/data/route-object#action)s,
2323
2330
  * [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
2331
+ * @param opts.routeDiscovery The route discovery configuration, used to determine how the router should discover new routes during navigations.
2324
2332
  * @param opts.routes Your {@link unstable_RSCRouteConfigEntry | route definitions}.
2325
2333
  * @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
2326
2334
  * that contains the [RSC](https://react.dev/reference/rsc/server-components)
2327
2335
  * data for hydration.
2328
2336
  */
2329
- declare function matchRSCServerRequest({ allowedActionOrigins, createTemporaryReferenceSet, basename, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, request, routes, generateResponse, }: {
2337
+ declare function matchRSCServerRequest({ allowedActionOrigins, createTemporaryReferenceSet, basename, decodeReply, requestContext, routeDiscovery, loadServerAction, decodeAction, decodeFormState, onError, request, routes, generateResponse, }: {
2330
2338
  allowedActionOrigins?: string[];
2331
2339
  createTemporaryReferenceSet: () => unknown;
2332
2340
  basename?: string;
@@ -2338,6 +2346,7 @@ declare function matchRSCServerRequest({ allowedActionOrigins, createTemporaryRe
2338
2346
  onError?: (error: unknown) => void;
2339
2347
  request: Request;
2340
2348
  routes: RSCRouteConfigEntry[];
2349
+ routeDiscovery?: RouteDiscovery;
2341
2350
  generateResponse: (match: RSCMatch, { onError, temporaryReferences, }: {
2342
2351
  onError(error: unknown): string | undefined;
2343
2352
  temporaryReferences: unknown;
@@ -27,7 +27,7 @@ function _interopNamespace(e) {
27
27
  var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
28
28
 
29
29
  /**
30
- * react-router v7.13.2
30
+ * react-router v7.14.0
31
31
  *
32
32
  * Copyright (c) Remix Software Inc.
33
33
  *
@@ -2659,6 +2659,7 @@ async function matchRSCServerRequest({
2659
2659
  basename,
2660
2660
  decodeReply,
2661
2661
  requestContext,
2662
+ routeDiscovery,
2662
2663
  loadServerAction,
2663
2664
  decodeAction,
2664
2665
  decodeFormState,
@@ -2695,7 +2696,8 @@ async function matchRSCServerRequest({
2695
2696
  basename,
2696
2697
  request,
2697
2698
  generateResponse,
2698
- temporaryReferences
2699
+ temporaryReferences,
2700
+ routeDiscovery
2699
2701
  );
2700
2702
  return response2;
2701
2703
  }
@@ -2728,12 +2730,30 @@ async function matchRSCServerRequest({
2728
2730
  onError,
2729
2731
  generateResponse,
2730
2732
  temporaryReferences,
2731
- allowedActionOrigins
2733
+ allowedActionOrigins,
2734
+ routeDiscovery
2732
2735
  );
2733
2736
  response.headers.set("X-Remix-Response", "yes");
2734
2737
  return response;
2735
2738
  }
2736
- async function generateManifestResponse(routes, basename, request, generateResponse, temporaryReferences) {
2739
+ async function generateManifestResponse(routes, basename, request, generateResponse, temporaryReferences, routeDiscovery) {
2740
+ if (routeDiscovery?.mode === "initial") {
2741
+ let payload2 = {
2742
+ type: "manifest",
2743
+ patches: getAllRoutePatches(routes)
2744
+ };
2745
+ return generateResponse(
2746
+ {
2747
+ statusCode: 200,
2748
+ headers: new Headers({
2749
+ "Content-Type": "text/x-component",
2750
+ Vary: "Content-Type"
2751
+ }),
2752
+ payload: payload2
2753
+ },
2754
+ { temporaryReferences, onError: defaultOnError }
2755
+ );
2756
+ }
2737
2757
  let url = new URL(request.url);
2738
2758
  let pathParam = url.searchParams.get("paths");
2739
2759
  let pathnames = pathParam ? pathParam.split(",").filter(Boolean) : [url.pathname.replace(/\.manifest$/, "")];
@@ -2753,7 +2773,7 @@ async function generateManifestResponse(routes, basename, request, generateRespo
2753
2773
  });
2754
2774
  let payload = {
2755
2775
  type: "manifest",
2756
- patches: (await Promise.all([
2776
+ patches: Promise.all([
2757
2777
  ...matchedRoutes.map((route) => getManifestRoute(route)),
2758
2778
  getAdditionalRoutePatches(
2759
2779
  pathnames,
@@ -2761,14 +2781,13 @@ async function generateManifestResponse(routes, basename, request, generateRespo
2761
2781
  basename,
2762
2782
  Array.from(routeIds)
2763
2783
  )
2764
- ])).flat(1)
2784
+ ]).then((r) => r.flat(1))
2765
2785
  };
2766
2786
  return generateResponse(
2767
2787
  {
2768
2788
  statusCode: 200,
2769
2789
  headers: new Headers({
2770
- "Content-Type": "text/x-component",
2771
- Vary: "Content-Type"
2790
+ "Content-Type": "text/x-component"
2772
2791
  }),
2773
2792
  payload
2774
2793
  },
@@ -2908,7 +2927,7 @@ async function generateResourceResponse(request, routes, basename, routeId, requ
2908
2927
  });
2909
2928
  }
2910
2929
  }
2911
- async function generateRenderResponse(request, routes, basename, isDataRequest, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, generateResponse, temporaryReferences, allowedActionOrigins) {
2930
+ async function generateRenderResponse(request, routes, basename, isDataRequest, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, generateResponse, temporaryReferences, allowedActionOrigins, routeDiscovery) {
2912
2931
  let statusCode = 200;
2913
2932
  let url = new URL(request.url);
2914
2933
  let isSubmission = isMutationMethod(request.method);
@@ -3017,7 +3036,8 @@ async function generateRenderResponse(request, routes, basename, isDataRequest,
3017
3036
  staticContext,
3018
3037
  temporaryReferences,
3019
3038
  skipRevalidation,
3020
- ctx.redirect?.headers
3039
+ ctx.redirect?.headers,
3040
+ routeDiscovery
3021
3041
  );
3022
3042
  }
3023
3043
  })
@@ -3058,7 +3078,6 @@ function generateRedirectResponse(response, actionResult, basename, isDataReques
3058
3078
  headers.delete("X-Remix-Replace");
3059
3079
  headers.delete("Content-Length");
3060
3080
  headers.set("Content-Type", "text/x-component");
3061
- headers.set("Vary", "Content-Type");
3062
3081
  return generateResponse(
3063
3082
  {
3064
3083
  statusCode: SINGLE_FETCH_REDIRECT_STATUS,
@@ -3068,7 +3087,7 @@ function generateRedirectResponse(response, actionResult, basename, isDataReques
3068
3087
  { temporaryReferences, onError: defaultOnError }
3069
3088
  );
3070
3089
  }
3071
- async function generateStaticContextResponse(routes, basename, generateResponse, statusCode, routeIdsToLoad, isDataRequest, isSubmission, actionResult, formState, staticContext, temporaryReferences, skipRevalidation, sideEffectRedirectHeaders) {
3090
+ async function generateStaticContextResponse(routes, basename, generateResponse, statusCode, routeIdsToLoad, isDataRequest, isSubmission, actionResult, formState, staticContext, temporaryReferences, skipRevalidation, sideEffectRedirectHeaders, routeDiscovery) {
3072
3091
  statusCode = staticContext.statusCode ?? statusCode;
3073
3092
  if (staticContext.errors) {
3074
3093
  staticContext.errors = Object.fromEntries(
@@ -3096,6 +3115,7 @@ async function generateStaticContextResponse(routes, basename, generateResponse,
3096
3115
  const baseRenderPayload = {
3097
3116
  type: "render",
3098
3117
  basename: staticContext.basename,
3118
+ routeDiscovery: routeDiscovery ?? { mode: "lazy" },
3099
3119
  actionData: staticContext.actionData,
3100
3120
  errors: staticContext.errors,
3101
3121
  loaderData: staticContext.loaderData,
@@ -3108,7 +3128,8 @@ async function generateStaticContextResponse(routes, basename, generateResponse,
3108
3128
  basename,
3109
3129
  routeIdsToLoad,
3110
3130
  isDataRequest,
3111
- staticContext
3131
+ staticContext,
3132
+ routeDiscovery
3112
3133
  );
3113
3134
  let payload;
3114
3135
  if (actionResult) {
@@ -3121,7 +3142,7 @@ async function generateStaticContextResponse(routes, basename, generateResponse,
3121
3142
  payload = {
3122
3143
  ...baseRenderPayload,
3123
3144
  matches: [],
3124
- patches: []
3145
+ patches: Promise.resolve([])
3125
3146
  };
3126
3147
  } else {
3127
3148
  payload = await renderPayloadPromise();
@@ -3135,7 +3156,7 @@ async function generateStaticContextResponse(routes, basename, generateResponse,
3135
3156
  { temporaryReferences, onError: defaultOnError }
3136
3157
  );
3137
3158
  }
3138
- async function getRenderPayload(baseRenderPayload, routes, basename, routeIdsToLoad, isDataRequest, staticContext) {
3159
+ async function getRenderPayload(baseRenderPayload, routes, basename, routeIdsToLoad, isDataRequest, staticContext, routeDiscovery) {
3139
3160
  let deepestRenderedRouteIdx = staticContext.matches.length - 1;
3140
3161
  let parentIds = {};
3141
3162
  staticContext.matches.forEach((m, i) => {
@@ -3159,16 +3180,19 @@ async function getRenderPayload(baseRenderPayload, routes, basename, routeIdsToL
3159
3180
  });
3160
3181
  })
3161
3182
  );
3162
- let patchesPromise = getAdditionalRoutePatches(
3183
+ let patches = routeDiscovery?.mode === "initial" && !isDataRequest ? getAllRoutePatches(routes).then(
3184
+ (patches2) => patches2.filter(
3185
+ (patch) => !staticContext.matches.some((m) => m.route.id === patch.id)
3186
+ )
3187
+ ) : getAdditionalRoutePatches(
3163
3188
  [staticContext.location.pathname],
3164
3189
  routes,
3165
3190
  basename,
3166
3191
  staticContext.matches.map((m) => m.route.id)
3167
3192
  );
3168
- let [matches, patches] = await Promise.all([matchesPromise, patchesPromise]);
3169
3193
  return {
3170
3194
  ...baseRenderPayload,
3171
- matches,
3195
+ matches: await matchesPromise,
3172
3196
  patches
3173
3197
  };
3174
3198
  }
@@ -3306,6 +3330,22 @@ async function explodeLazyRoute(route) {
3306
3330
  route.lazy = void 0;
3307
3331
  }
3308
3332
  }
3333
+ async function getAllRoutePatches(routes, basename) {
3334
+ let patches = [];
3335
+ async function traverse(route, parentId) {
3336
+ let manifestRoute = await getManifestRoute({ ...route, parentId });
3337
+ patches.push(manifestRoute);
3338
+ if ("children" in route && route.children?.length) {
3339
+ for (let child of route.children) {
3340
+ await traverse(child, route.id);
3341
+ }
3342
+ }
3343
+ }
3344
+ for (let route of routes) {
3345
+ await traverse(route, void 0);
3346
+ }
3347
+ return patches.filter((p) => !!p.parentId);
3348
+ }
3309
3349
  async function getAdditionalRoutePatches(pathnames, routes, basename, matchedRouteIds) {
3310
3350
  let patchRouteMatches = /* @__PURE__ */ new Map();
3311
3351
  let matchedPaths = /* @__PURE__ */ new Set();
@@ -6,7 +6,7 @@ export { BrowserRouter, Form, HashRouter, Link, Links, MemoryRouter, Meta, NavLi
6
6
  import { serialize, parse } from 'cookie';
7
7
 
8
8
  /**
9
- * react-router v7.13.2
9
+ * react-router v7.14.0
10
10
  *
11
11
  * Copyright (c) Remix Software Inc.
12
12
  *
@@ -2638,6 +2638,7 @@ async function matchRSCServerRequest({
2638
2638
  basename,
2639
2639
  decodeReply,
2640
2640
  requestContext,
2641
+ routeDiscovery,
2641
2642
  loadServerAction,
2642
2643
  decodeAction,
2643
2644
  decodeFormState,
@@ -2674,7 +2675,8 @@ async function matchRSCServerRequest({
2674
2675
  basename,
2675
2676
  request,
2676
2677
  generateResponse,
2677
- temporaryReferences
2678
+ temporaryReferences,
2679
+ routeDiscovery
2678
2680
  );
2679
2681
  return response2;
2680
2682
  }
@@ -2707,12 +2709,30 @@ async function matchRSCServerRequest({
2707
2709
  onError,
2708
2710
  generateResponse,
2709
2711
  temporaryReferences,
2710
- allowedActionOrigins
2712
+ allowedActionOrigins,
2713
+ routeDiscovery
2711
2714
  );
2712
2715
  response.headers.set("X-Remix-Response", "yes");
2713
2716
  return response;
2714
2717
  }
2715
- async function generateManifestResponse(routes, basename, request, generateResponse, temporaryReferences) {
2718
+ async function generateManifestResponse(routes, basename, request, generateResponse, temporaryReferences, routeDiscovery) {
2719
+ if (routeDiscovery?.mode === "initial") {
2720
+ let payload2 = {
2721
+ type: "manifest",
2722
+ patches: getAllRoutePatches(routes)
2723
+ };
2724
+ return generateResponse(
2725
+ {
2726
+ statusCode: 200,
2727
+ headers: new Headers({
2728
+ "Content-Type": "text/x-component",
2729
+ Vary: "Content-Type"
2730
+ }),
2731
+ payload: payload2
2732
+ },
2733
+ { temporaryReferences, onError: defaultOnError }
2734
+ );
2735
+ }
2716
2736
  let url = new URL(request.url);
2717
2737
  let pathParam = url.searchParams.get("paths");
2718
2738
  let pathnames = pathParam ? pathParam.split(",").filter(Boolean) : [url.pathname.replace(/\.manifest$/, "")];
@@ -2732,7 +2752,7 @@ async function generateManifestResponse(routes, basename, request, generateRespo
2732
2752
  });
2733
2753
  let payload = {
2734
2754
  type: "manifest",
2735
- patches: (await Promise.all([
2755
+ patches: Promise.all([
2736
2756
  ...matchedRoutes.map((route) => getManifestRoute(route)),
2737
2757
  getAdditionalRoutePatches(
2738
2758
  pathnames,
@@ -2740,14 +2760,13 @@ async function generateManifestResponse(routes, basename, request, generateRespo
2740
2760
  basename,
2741
2761
  Array.from(routeIds)
2742
2762
  )
2743
- ])).flat(1)
2763
+ ]).then((r) => r.flat(1))
2744
2764
  };
2745
2765
  return generateResponse(
2746
2766
  {
2747
2767
  statusCode: 200,
2748
2768
  headers: new Headers({
2749
- "Content-Type": "text/x-component",
2750
- Vary: "Content-Type"
2769
+ "Content-Type": "text/x-component"
2751
2770
  }),
2752
2771
  payload
2753
2772
  },
@@ -2887,7 +2906,7 @@ async function generateResourceResponse(request, routes, basename, routeId, requ
2887
2906
  });
2888
2907
  }
2889
2908
  }
2890
- async function generateRenderResponse(request, routes, basename, isDataRequest, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, generateResponse, temporaryReferences, allowedActionOrigins) {
2909
+ async function generateRenderResponse(request, routes, basename, isDataRequest, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, generateResponse, temporaryReferences, allowedActionOrigins, routeDiscovery) {
2891
2910
  let statusCode = 200;
2892
2911
  let url = new URL(request.url);
2893
2912
  let isSubmission = isMutationMethod(request.method);
@@ -2996,7 +3015,8 @@ async function generateRenderResponse(request, routes, basename, isDataRequest,
2996
3015
  staticContext,
2997
3016
  temporaryReferences,
2998
3017
  skipRevalidation,
2999
- ctx.redirect?.headers
3018
+ ctx.redirect?.headers,
3019
+ routeDiscovery
3000
3020
  );
3001
3021
  }
3002
3022
  })
@@ -3037,7 +3057,6 @@ function generateRedirectResponse(response, actionResult, basename, isDataReques
3037
3057
  headers.delete("X-Remix-Replace");
3038
3058
  headers.delete("Content-Length");
3039
3059
  headers.set("Content-Type", "text/x-component");
3040
- headers.set("Vary", "Content-Type");
3041
3060
  return generateResponse(
3042
3061
  {
3043
3062
  statusCode: SINGLE_FETCH_REDIRECT_STATUS,
@@ -3047,7 +3066,7 @@ function generateRedirectResponse(response, actionResult, basename, isDataReques
3047
3066
  { temporaryReferences, onError: defaultOnError }
3048
3067
  );
3049
3068
  }
3050
- async function generateStaticContextResponse(routes, basename, generateResponse, statusCode, routeIdsToLoad, isDataRequest, isSubmission, actionResult, formState, staticContext, temporaryReferences, skipRevalidation, sideEffectRedirectHeaders) {
3069
+ async function generateStaticContextResponse(routes, basename, generateResponse, statusCode, routeIdsToLoad, isDataRequest, isSubmission, actionResult, formState, staticContext, temporaryReferences, skipRevalidation, sideEffectRedirectHeaders, routeDiscovery) {
3051
3070
  statusCode = staticContext.statusCode ?? statusCode;
3052
3071
  if (staticContext.errors) {
3053
3072
  staticContext.errors = Object.fromEntries(
@@ -3075,6 +3094,7 @@ async function generateStaticContextResponse(routes, basename, generateResponse,
3075
3094
  const baseRenderPayload = {
3076
3095
  type: "render",
3077
3096
  basename: staticContext.basename,
3097
+ routeDiscovery: routeDiscovery ?? { mode: "lazy" },
3078
3098
  actionData: staticContext.actionData,
3079
3099
  errors: staticContext.errors,
3080
3100
  loaderData: staticContext.loaderData,
@@ -3087,7 +3107,8 @@ async function generateStaticContextResponse(routes, basename, generateResponse,
3087
3107
  basename,
3088
3108
  routeIdsToLoad,
3089
3109
  isDataRequest,
3090
- staticContext
3110
+ staticContext,
3111
+ routeDiscovery
3091
3112
  );
3092
3113
  let payload;
3093
3114
  if (actionResult) {
@@ -3100,7 +3121,7 @@ async function generateStaticContextResponse(routes, basename, generateResponse,
3100
3121
  payload = {
3101
3122
  ...baseRenderPayload,
3102
3123
  matches: [],
3103
- patches: []
3124
+ patches: Promise.resolve([])
3104
3125
  };
3105
3126
  } else {
3106
3127
  payload = await renderPayloadPromise();
@@ -3114,7 +3135,7 @@ async function generateStaticContextResponse(routes, basename, generateResponse,
3114
3135
  { temporaryReferences, onError: defaultOnError }
3115
3136
  );
3116
3137
  }
3117
- async function getRenderPayload(baseRenderPayload, routes, basename, routeIdsToLoad, isDataRequest, staticContext) {
3138
+ async function getRenderPayload(baseRenderPayload, routes, basename, routeIdsToLoad, isDataRequest, staticContext, routeDiscovery) {
3118
3139
  let deepestRenderedRouteIdx = staticContext.matches.length - 1;
3119
3140
  let parentIds = {};
3120
3141
  staticContext.matches.forEach((m, i) => {
@@ -3138,16 +3159,19 @@ async function getRenderPayload(baseRenderPayload, routes, basename, routeIdsToL
3138
3159
  });
3139
3160
  })
3140
3161
  );
3141
- let patchesPromise = getAdditionalRoutePatches(
3162
+ let patches = routeDiscovery?.mode === "initial" && !isDataRequest ? getAllRoutePatches(routes).then(
3163
+ (patches2) => patches2.filter(
3164
+ (patch) => !staticContext.matches.some((m) => m.route.id === patch.id)
3165
+ )
3166
+ ) : getAdditionalRoutePatches(
3142
3167
  [staticContext.location.pathname],
3143
3168
  routes,
3144
3169
  basename,
3145
3170
  staticContext.matches.map((m) => m.route.id)
3146
3171
  );
3147
- let [matches, patches] = await Promise.all([matchesPromise, patchesPromise]);
3148
3172
  return {
3149
3173
  ...baseRenderPayload,
3150
- matches,
3174
+ matches: await matchesPromise,
3151
3175
  patches
3152
3176
  };
3153
3177
  }
@@ -3285,6 +3309,22 @@ async function explodeLazyRoute(route) {
3285
3309
  route.lazy = void 0;
3286
3310
  }
3287
3311
  }
3312
+ async function getAllRoutePatches(routes, basename) {
3313
+ let patches = [];
3314
+ async function traverse(route, parentId) {
3315
+ let manifestRoute = await getManifestRoute({ ...route, parentId });
3316
+ patches.push(manifestRoute);
3317
+ if ("children" in route && route.children?.length) {
3318
+ for (let child of route.children) {
3319
+ await traverse(child, route.id);
3320
+ }
3321
+ }
3322
+ }
3323
+ for (let route of routes) {
3324
+ await traverse(route, void 0);
3325
+ }
3326
+ return patches.filter((p) => !!p.parentId);
3327
+ }
3288
3328
  async function getAdditionalRoutePatches(pathnames, routes, basename, matchedRouteIds) {
3289
3329
  let patchRouteMatches = /* @__PURE__ */ new Map();
3290
3330
  let matchedPaths = /* @__PURE__ */ new Set();
@@ -6,12 +6,12 @@ import * as React from 'react';
6
6
  import React__default, { ReactElement } from 'react';
7
7
  import { a as RouteModules$1, P as Pages } from './register-CTxsJBKQ.mjs';
8
8
  export { b as Register } from './register-CTxsJBKQ.mjs';
9
- import { A as AssetsManifest, S as ServerBuild, E as EntryContext, F as FutureConfig } from './index-react-server-client-BcrVT7Dd.mjs';
10
- export { l as BrowserRouter, B as BrowserRouterProps, D as DOMRouterOpts, a1 as DiscoverBehavior, c as FetcherFormProps, h as FetcherSubmitFunction, G as FetcherSubmitOptions, i as FetcherWithComponents, q as Form, d as FormProps, a2 as HandleDataRequestFunction, a3 as HandleDocumentRequestFunction, a4 as HandleErrorFunction, m as HashRouter, H as HashRouterProps, a as HistoryRouterProps, n as Link, L as LinkProps, X as Links, _ as LinksProps, W as Meta, p as NavLink, N as NavLinkProps, b as NavLinkRenderProps, P as ParamKeyValuePair, a0 as PrefetchBehavior, Z as PrefetchPageLinks, Y as Scripts, $ as ScriptsProps, r as ScrollRestoration, e as ScrollRestorationProps, a5 as ServerEntryModule, f as SetURLSearchParams, T as StaticRouter, M as StaticRouterProps, V as StaticRouterProvider, O as StaticRouterProviderProps, g as SubmitFunction, I as SubmitOptions, J as SubmitTarget, a6 as UNSAFE_FrameworkContext, a7 as UNSAFE_createClientRoutes, a8 as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, a9 as UNSAFE_shouldHydrateRouteLoader, aa as UNSAFE_useScrollRestoration, U as URLSearchParamsInit, j as createBrowserRouter, k as createHashRouter, K as createSearchParams, Q as createStaticHandler, R as createStaticRouter, o as unstable_HistoryRouter, z as unstable_usePrompt, y as useBeforeUnload, w as useFetcher, x as useFetchers, v as useFormAction, u as useLinkClickHandler, s as useSearchParams, t as useSubmit, C as useViewTransitionState } from './index-react-server-client-BcrVT7Dd.mjs';
9
+ import { A as AssetsManifest, S as ServerBuild, E as EntryContext, F as FutureConfig } from './index-react-server-client-BwWaHAr3.mjs';
10
+ export { l as BrowserRouter, B as BrowserRouterProps, D as DOMRouterOpts, a1 as DiscoverBehavior, c as FetcherFormProps, h as FetcherSubmitFunction, G as FetcherSubmitOptions, i as FetcherWithComponents, q as Form, d as FormProps, a2 as HandleDataRequestFunction, a3 as HandleDocumentRequestFunction, a4 as HandleErrorFunction, m as HashRouter, H as HashRouterProps, a as HistoryRouterProps, n as Link, L as LinkProps, X as Links, _ as LinksProps, W as Meta, p as NavLink, N as NavLinkProps, b as NavLinkRenderProps, P as ParamKeyValuePair, a0 as PrefetchBehavior, Z as PrefetchPageLinks, Y as Scripts, $ as ScriptsProps, r as ScrollRestoration, e as ScrollRestorationProps, a5 as ServerEntryModule, f as SetURLSearchParams, T as StaticRouter, M as StaticRouterProps, V as StaticRouterProvider, O as StaticRouterProviderProps, g as SubmitFunction, I as SubmitOptions, J as SubmitTarget, a6 as UNSAFE_FrameworkContext, a7 as UNSAFE_createClientRoutes, a8 as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, a9 as UNSAFE_shouldHydrateRouteLoader, aa as UNSAFE_useScrollRestoration, U as URLSearchParamsInit, j as createBrowserRouter, k as createHashRouter, K as createSearchParams, Q as createStaticHandler, R as createStaticRouter, o as unstable_HistoryRouter, z as unstable_usePrompt, y as useBeforeUnload, w as useFetcher, x as useFetchers, v as useFormAction, u as useLinkClickHandler, s as useSearchParams, t as useSubmit, C as useViewTransitionState } from './index-react-server-client-BwWaHAr3.mjs';
11
11
  import { ParseOptions, SerializeOptions } from 'cookie';
12
12
  export { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions } from 'cookie';
13
- import { e as RSCPayload, g as getRequest, m as matchRSCServerRequest } from './browser-Di6-vSl-.mjs';
14
- export { B as unstable_BrowserCreateFromReadableStreamFunction, D as unstable_DecodeActionFunction, a as unstable_DecodeFormStateFunction, b as unstable_DecodeReplyFunction, E as unstable_EncodeReplyFunction, L as unstable_LoadServerActionFunction, h as unstable_RSCHydratedRouterProps, d as unstable_RSCManifestPayload, i as unstable_RSCMatch, f as unstable_RSCRenderPayload, n as unstable_RSCRouteConfig, l as unstable_RSCRouteConfigEntry, j as unstable_RSCRouteManifest, k as unstable_RSCRouteMatch } from './browser-Di6-vSl-.mjs';
13
+ import { e as RSCPayload, g as getRequest, m as matchRSCServerRequest } from './browser-vtIR1Kpe.mjs';
14
+ export { B as unstable_BrowserCreateFromReadableStreamFunction, D as unstable_DecodeActionFunction, a as unstable_DecodeFormStateFunction, b as unstable_DecodeReplyFunction, E as unstable_EncodeReplyFunction, L as unstable_LoadServerActionFunction, h as unstable_RSCHydratedRouterProps, d as unstable_RSCManifestPayload, i as unstable_RSCMatch, f as unstable_RSCRenderPayload, n as unstable_RSCRouteConfig, l as unstable_RSCRouteConfigEntry, j as unstable_RSCRouteManifest, k as unstable_RSCRouteMatch } from './browser-vtIR1Kpe.mjs';
15
15
 
16
16
  declare const SingleFetchRedirectSymbol: unique symbol;
17
17
  declare function getTurboStreamSingleFetchDataStrategy(getRouter: () => Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, basename: string | undefined, trailingSlashAware: boolean): DataStrategyFunction;
@@ -2,16 +2,16 @@ import { J as RouteModules, l as DataStrategyFunction, r as MiddlewareEnabled, c
2
2
  export { _ as ActionFunctionArgs, $ as BaseRouteObject, C as ClientActionFunction, ap as ClientActionFunctionArgs, aq as ClientLoaderFunctionArgs, D as DataRouteMatch, a0 as DataStrategyFunctionArgs, a1 as DataStrategyMatch, B as DataStrategyResult, a3 as ErrorResponse, F as FormEncType, a4 as FormMethod, av as Future, o as HTMLFormMethod, ar as HeadersArgs, H as HeadersFunction, au as HtmlLinkDescriptor, a5 as LazyRouteFunction, t as LinkDescriptor, q as LoaderFunctionArgs, as as MetaArgs, w as MetaDescriptor, a6 as MiddlewareFunction, at as PageLinkDescriptor, a7 as PatchRoutesOnNavigationFunctionArgs, a8 as PathParam, a9 as RedirectFunction, aa as RouteMatch, ab as RouterContext, S as ShouldRevalidateFunction, ac as ShouldRevalidateFunctionArgs, a2 as UNSAFE_DataWithResponseInit, aB as UNSAFE_ErrorResponseImpl, ay as UNSAFE_createBrowserHistory, az as UNSAFE_createHashHistory, ax as UNSAFE_createMemoryHistory, aA as UNSAFE_invariant, ad as createContext, ae as createPath, ag as data, ah as generatePath, ai as isRouteErrorResponse, aj as matchPath, ak as matchRoutes, af as parsePath, al as redirect, am as redirectDocument, an as replace, ao as resolvePath, aw as unstable_SerializesTo } from './routeModules-CA7kSxJJ.js';
3
3
  import { a as Router, B as BlockerFunction, b as Blocker, c as RelativeRoutingType, N as Navigation, H as HydrationState, d as RouterState } from './instrumentation-BYr6ff5D.js';
4
4
  export { F as Fetcher, G as GetScrollPositionFunction, e as GetScrollRestorationKeyFunction, r as IDLE_BLOCKER, q as IDLE_FETCHER, I as IDLE_NAVIGATION, g as NavigationStates, k as RevalidationState, j as RouterFetchOptions, R as RouterInit, i as RouterNavigateOptions, h as RouterSubscriber, S as StaticHandler, f as StaticHandlerContext, s as UNSAFE_createRouter, u as unstable_ClientInstrumentation, m as unstable_InstrumentRequestHandlerFunction, o as unstable_InstrumentRouteFunction, n as unstable_InstrumentRouterFunction, p as unstable_InstrumentationHandlerResult, l as unstable_ServerInstrumentation } from './instrumentation-BYr6ff5D.js';
5
- import { A as AssetsManifest, S as ServerBuild, N as NavigateOptions, E as EntryContext, F as FutureConfig } from './index-react-server-client-CCwMoQIT.js';
6
- export { i as Await, c as AwaitProps, W as BrowserRouter, B as BrowserRouterProps, C as ClientOnErrorFunction, D as DOMRouterOpts, at as DiscoverBehavior, y as FetcherFormProps, Q as FetcherSubmitFunction, aa as FetcherSubmitOptions, T as FetcherWithComponents, $ as Form, z as FormProps, au as HandleDataRequestFunction, av as HandleDocumentRequestFunction, aw as HandleErrorFunction, X as HashRouter, H as HashRouterProps, u as HistoryRouterProps, I as IndexRouteProps, L as LayoutRouteProps, Y as Link, v as LinkProps, an as Links, aq as LinksProps, j as MemoryRouter, M as MemoryRouterOpts, d as MemoryRouterProps, am as Meta, _ as NavLink, w as NavLinkProps, x as NavLinkRenderProps, k as Navigate, e as NavigateProps, a as Navigator, l as Outlet, O as OutletProps, ab as ParamKeyValuePair, P as PathRouteProps, as as PrefetchBehavior, ap as PrefetchPageLinks, m as Route, R as RouteProps, n as Router, f as RouterProps, o as RouterProvider, g as RouterProviderProps, p as Routes, h as RoutesProps, ao as Scripts, ar as ScriptsProps, a0 as ScrollRestoration, G as ScrollRestorationProps, ax as ServerEntryModule, J as SetURLSearchParams, ak as StaticRouter, ag as StaticRouterProps, al as StaticRouterProvider, ah as StaticRouterProviderProps, K as SubmitFunction, ac as SubmitOptions, ae as SubmitTarget, b as UNSAFE_AwaitContextProvider, ay as UNSAFE_DataRouterContext, az as UNSAFE_DataRouterStateContext, aA as UNSAFE_FetchersContext, aN as UNSAFE_FrameworkContext, aB as UNSAFE_LocationContext, aC as UNSAFE_NavigationContext, aD as UNSAFE_RouteContext, aE as UNSAFE_ViewTransitionContext, aH as UNSAFE_WithComponentProps, aL as UNSAFE_WithErrorBoundaryProps, aJ as UNSAFE_WithHydrateFallbackProps, aO as UNSAFE_createClientRoutes, aP as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, aF as UNSAFE_hydrationRouteProperties, aG as UNSAFE_mapRouteProperties, aQ as UNSAFE_shouldHydrateRouteLoader, aR as UNSAFE_useScrollRestoration, aI as UNSAFE_withComponentProps, aM as UNSAFE_withErrorBoundaryProps, aK as UNSAFE_withHydrateFallbackProps, ad as URLSearchParamsInit, U as createBrowserRouter, V as createHashRouter, q as createMemoryRouter, r as createRoutesFromChildren, s as createRoutesFromElements, af as createSearchParams, ai as createStaticHandler, aj as createStaticRouter, t as renderMatches, Z as unstable_HistoryRouter, a8 as unstable_usePrompt, a7 as useBeforeUnload, a5 as useFetcher, a6 as useFetchers, a4 as useFormAction, a1 as useLinkClickHandler, a2 as useSearchParams, a3 as useSubmit, a9 as useViewTransitionState } from './index-react-server-client-CCwMoQIT.js';
5
+ import { A as AssetsManifest, S as ServerBuild, N as NavigateOptions, E as EntryContext, F as FutureConfig } from './index-react-server-client-luDbagNU.js';
6
+ export { i as Await, c as AwaitProps, W as BrowserRouter, B as BrowserRouterProps, C as ClientOnErrorFunction, D as DOMRouterOpts, at as DiscoverBehavior, y as FetcherFormProps, Q as FetcherSubmitFunction, aa as FetcherSubmitOptions, T as FetcherWithComponents, $ as Form, z as FormProps, au as HandleDataRequestFunction, av as HandleDocumentRequestFunction, aw as HandleErrorFunction, X as HashRouter, H as HashRouterProps, u as HistoryRouterProps, I as IndexRouteProps, L as LayoutRouteProps, Y as Link, v as LinkProps, an as Links, aq as LinksProps, j as MemoryRouter, M as MemoryRouterOpts, d as MemoryRouterProps, am as Meta, _ as NavLink, w as NavLinkProps, x as NavLinkRenderProps, k as Navigate, e as NavigateProps, a as Navigator, l as Outlet, O as OutletProps, ab as ParamKeyValuePair, P as PathRouteProps, as as PrefetchBehavior, ap as PrefetchPageLinks, m as Route, R as RouteProps, n as Router, f as RouterProps, o as RouterProvider, g as RouterProviderProps, p as Routes, h as RoutesProps, ao as Scripts, ar as ScriptsProps, a0 as ScrollRestoration, G as ScrollRestorationProps, ax as ServerEntryModule, J as SetURLSearchParams, ak as StaticRouter, ag as StaticRouterProps, al as StaticRouterProvider, ah as StaticRouterProviderProps, K as SubmitFunction, ac as SubmitOptions, ae as SubmitTarget, b as UNSAFE_AwaitContextProvider, ay as UNSAFE_DataRouterContext, az as UNSAFE_DataRouterStateContext, aA as UNSAFE_FetchersContext, aN as UNSAFE_FrameworkContext, aB as UNSAFE_LocationContext, aC as UNSAFE_NavigationContext, aD as UNSAFE_RouteContext, aE as UNSAFE_ViewTransitionContext, aH as UNSAFE_WithComponentProps, aL as UNSAFE_WithErrorBoundaryProps, aJ as UNSAFE_WithHydrateFallbackProps, aO as UNSAFE_createClientRoutes, aP as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, aF as UNSAFE_hydrationRouteProperties, aG as UNSAFE_mapRouteProperties, aQ as UNSAFE_shouldHydrateRouteLoader, aR as UNSAFE_useScrollRestoration, aI as UNSAFE_withComponentProps, aM as UNSAFE_withErrorBoundaryProps, aK as UNSAFE_withHydrateFallbackProps, ad as URLSearchParamsInit, U as createBrowserRouter, V as createHashRouter, q as createMemoryRouter, r as createRoutesFromChildren, s as createRoutesFromElements, af as createSearchParams, ai as createStaticHandler, aj as createStaticRouter, t as renderMatches, Z as unstable_HistoryRouter, a8 as unstable_usePrompt, a7 as useBeforeUnload, a5 as useFetcher, a6 as useFetchers, a4 as useFormAction, a1 as useLinkClickHandler, a2 as useSearchParams, a3 as useSubmit, a9 as useViewTransitionState } from './index-react-server-client-luDbagNU.js';
7
7
  import * as React from 'react';
8
8
  import React__default, { ReactElement } from 'react';
9
9
  import { a as RouteModules$1, P as Pages } from './register-CkcGwv27.js';
10
10
  export { b as Register } from './register-CkcGwv27.js';
11
11
  import { ParseOptions, SerializeOptions } from 'cookie';
12
12
  export { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions } from 'cookie';
13
- import { e as RSCPayload, g as getRequest, m as matchRSCServerRequest } from './browser-Bfn3xw9E.js';
14
- export { B as unstable_BrowserCreateFromReadableStreamFunction, D as unstable_DecodeActionFunction, a as unstable_DecodeFormStateFunction, b as unstable_DecodeReplyFunction, E as unstable_EncodeReplyFunction, L as unstable_LoadServerActionFunction, h as unstable_RSCHydratedRouterProps, d as unstable_RSCManifestPayload, i as unstable_RSCMatch, f as unstable_RSCRenderPayload, n as unstable_RSCRouteConfig, l as unstable_RSCRouteConfigEntry, j as unstable_RSCRouteManifest, k as unstable_RSCRouteMatch } from './browser-Bfn3xw9E.js';
13
+ import { e as RSCPayload, g as getRequest, m as matchRSCServerRequest } from './browser-C9Ar1yxG.js';
14
+ export { B as unstable_BrowserCreateFromReadableStreamFunction, D as unstable_DecodeActionFunction, a as unstable_DecodeFormStateFunction, b as unstable_DecodeReplyFunction, E as unstable_EncodeReplyFunction, L as unstable_LoadServerActionFunction, h as unstable_RSCHydratedRouterProps, d as unstable_RSCManifestPayload, i as unstable_RSCMatch, f as unstable_RSCRenderPayload, n as unstable_RSCRouteConfig, l as unstable_RSCRouteConfigEntry, j as unstable_RSCRouteManifest, k as unstable_RSCRouteMatch } from './browser-C9Ar1yxG.js';
15
15
 
16
16
  declare const SingleFetchRedirectSymbol: unique symbol;
17
17
  declare function getTurboStreamSingleFetchDataStrategy(getRouter: () => Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, basename: string | undefined, trailingSlashAware: boolean): DataStrategyFunction;