react-router 7.14.2 → 7.15.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 (72) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/dist/development/{browser-I6n6wVSO.d.mts → browser-CRsXgNrY.d.mts} +2 -2
  3. package/dist/{production/browser-I6n6wVSO.d.mts → development/browser-wDl1FZEL.d.ts} +2 -2
  4. package/dist/{production/chunk-PQL4HLVQ.js → development/chunk-2D5H3HU3.js} +7 -7
  5. package/dist/development/{chunk-EVOBXE3Y.mjs → chunk-5KNZJZUH.mjs} +341 -208
  6. package/dist/development/{chunk-ZZNWZ5Q3.js → chunk-AM3XM4LS.js} +331 -205
  7. package/dist/development/{chunk-YQSHRJWW.mjs → chunk-RMD3H4O3.mjs} +80 -61
  8. package/dist/development/{chunk-YZKCRDTN.js → chunk-Z5YQYACE.js} +146 -139
  9. package/dist/{production/context-DGGUoDIu.d.mts → development/context-BQs41HrG.d.mts} +94 -42
  10. package/dist/development/{routeModules-7rtk67cd.d.ts → data-BVUf681J.d.mts} +64 -46
  11. package/dist/development/{routeModules-BW4a8k3I.d.mts → data-BqZ2x964.d.ts} +64 -46
  12. package/dist/development/dom-export.d.mts +8 -8
  13. package/dist/development/dom-export.d.ts +8 -8
  14. package/dist/development/dom-export.js +37 -40
  15. package/dist/development/dom-export.mjs +12 -15
  16. package/dist/development/{index-react-server-client-BBd0A0TL.d.ts → index-react-server-client-CSv-KZBk.d.ts} +123 -121
  17. package/dist/{production/index-react-server-client-BjhKIe3u.d.mts → development/index-react-server-client-Ck_yZ1qL.d.mts} +102 -100
  18. package/dist/development/index-react-server-client.d.mts +3 -3
  19. package/dist/development/index-react-server-client.d.ts +3 -3
  20. package/dist/development/index-react-server-client.js +4 -4
  21. package/dist/development/index-react-server-client.mjs +2 -2
  22. package/dist/development/index-react-server.d.mts +107 -36
  23. package/dist/development/index-react-server.d.ts +107 -36
  24. package/dist/development/index-react-server.js +60 -33
  25. package/dist/development/index-react-server.mjs +60 -33
  26. package/dist/development/index.d.mts +10 -10
  27. package/dist/development/index.d.ts +10 -10
  28. package/dist/development/index.js +173 -154
  29. package/dist/development/index.mjs +3 -3
  30. package/dist/{production/instrumentation-g0dG8UL0.d.ts → development/instrumentation-DlJ2QV7d.d.ts} +73 -21
  31. package/dist/development/lib/types/internal.d.mts +2 -2
  32. package/dist/development/lib/types/internal.d.ts +2 -2
  33. package/dist/development/lib/types/internal.js +1 -1
  34. package/dist/development/lib/types/internal.mjs +1 -1
  35. package/dist/development/{register-DcBltf5q.d.ts → register-Bsscfj79.d.ts} +1 -1
  36. package/dist/{production/register-DcBltf5q.d.ts → development/register-Df8okEea.d.mts} +1 -1
  37. package/dist/production/{browser-C-UvoYvi.d.ts → browser-CRsXgNrY.d.mts} +2 -2
  38. package/dist/{development/browser-C-UvoYvi.d.ts → production/browser-wDl1FZEL.d.ts} +2 -2
  39. package/dist/production/{chunk-2WLZNCK5.mjs → chunk-23ZOHYE5.mjs} +80 -61
  40. package/dist/{development/chunk-PZFPF4X7.js → production/chunk-7YXKJMLN.js} +7 -7
  41. package/dist/production/{chunk-LK6U7ULH.mjs → chunk-GM3PW4GX.mjs} +341 -208
  42. package/dist/production/{chunk-X5SKXJ4A.js → chunk-LCJTIOKZ.js} +331 -205
  43. package/dist/production/{chunk-UJQ4OJF4.js → chunk-YBQJ3ABE.js} +146 -139
  44. package/dist/{development/context-DGGUoDIu.d.mts → production/context-BQs41HrG.d.mts} +94 -42
  45. package/dist/production/{routeModules-7rtk67cd.d.ts → data-BVUf681J.d.mts} +64 -46
  46. package/dist/production/{routeModules-BW4a8k3I.d.mts → data-BqZ2x964.d.ts} +64 -46
  47. package/dist/production/dom-export.d.mts +8 -8
  48. package/dist/production/dom-export.d.ts +8 -8
  49. package/dist/production/dom-export.js +37 -40
  50. package/dist/production/dom-export.mjs +12 -15
  51. package/dist/production/{index-react-server-client-BBd0A0TL.d.ts → index-react-server-client-CSv-KZBk.d.ts} +123 -121
  52. package/dist/{development/index-react-server-client-BjhKIe3u.d.mts → production/index-react-server-client-Ck_yZ1qL.d.mts} +102 -100
  53. package/dist/production/index-react-server-client.d.mts +3 -3
  54. package/dist/production/index-react-server-client.d.ts +3 -3
  55. package/dist/production/index-react-server-client.js +4 -4
  56. package/dist/production/index-react-server-client.mjs +2 -2
  57. package/dist/production/index-react-server.d.mts +107 -36
  58. package/dist/production/index-react-server.d.ts +107 -36
  59. package/dist/production/index-react-server.js +60 -33
  60. package/dist/production/index-react-server.mjs +60 -33
  61. package/dist/production/index.d.mts +10 -10
  62. package/dist/production/index.d.ts +10 -10
  63. package/dist/production/index.js +173 -154
  64. package/dist/production/index.mjs +3 -3
  65. package/dist/{development/instrumentation-g0dG8UL0.d.ts → production/instrumentation-DlJ2QV7d.d.ts} +73 -21
  66. package/dist/production/lib/types/internal.d.mts +2 -2
  67. package/dist/production/lib/types/internal.d.ts +2 -2
  68. package/dist/production/lib/types/internal.js +1 -1
  69. package/dist/production/lib/types/internal.mjs +1 -1
  70. package/dist/{development/register-D9d2sMQ7.d.mts → production/register-Bsscfj79.d.ts} +1 -1
  71. package/dist/production/{register-D9d2sMQ7.d.mts → register-Df8okEea.d.mts} +1 -1
  72. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.14.2
2
+ * react-router v7.15.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -22,6 +22,7 @@ import {
22
22
  SingleFetchRedirectSymbol,
23
23
  StaticRouterProvider,
24
24
  StreamTransfer,
25
+ URL_LIMIT,
25
26
  convertRoutesToDataRoutes,
26
27
  createMemoryRouter,
27
28
  createServerRoutes,
@@ -41,6 +42,7 @@ import {
41
42
  isResponse,
42
43
  isRouteErrorResponse,
43
44
  matchRoutes,
45
+ matchRoutesImpl,
44
46
  redirect,
45
47
  redirectDocument,
46
48
  replace,
@@ -51,7 +53,7 @@ import {
51
53
  withComponentProps,
52
54
  withErrorBoundaryProps,
53
55
  withHydrateFallbackProps
54
- } from "./chunk-EVOBXE3Y.mjs";
56
+ } from "./chunk-5KNZJZUH.mjs";
55
57
 
56
58
  // lib/dom/ssr/server.tsx
57
59
  import * as React from "react";
@@ -86,7 +88,9 @@ function ServerRouter({
86
88
  delete context.staticHandlerContext.loaderData[routeId];
87
89
  }
88
90
  }
89
- let router = createStaticRouter(routes, context.staticHandlerContext);
91
+ let router = createStaticRouter(routes, context.staticHandlerContext, {
92
+ branches: context.branches
93
+ });
90
94
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
91
95
  FrameworkContext.Provider,
92
96
  {
@@ -137,8 +141,7 @@ function createRoutesStub(routes, _context) {
137
141
  if (routerRef.current == null) {
138
142
  frameworkContextRef.current = {
139
143
  future: {
140
- unstable_passThroughRequests: future?.unstable_passThroughRequests === true,
141
- unstable_subResourceIntegrity: future?.unstable_subResourceIntegrity === true,
144
+ v8_passThroughRequests: future?.v8_passThroughRequests === true,
142
145
  v8_middleware: future?.v8_middleware === true,
143
146
  unstable_trailingSlashAwareDataRequests: future?.unstable_trailingSlashAwareDataRequests === true
144
147
  },
@@ -490,29 +493,48 @@ function serializeErrors(errors, serverMode) {
490
493
  return serialized;
491
494
  }
492
495
 
496
+ // lib/server-runtime/invariant.ts
497
+ function invariant(value, message) {
498
+ if (value === false || value === null || typeof value === "undefined") {
499
+ console.error(
500
+ "The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"
501
+ );
502
+ throw new Error(message);
503
+ }
504
+ }
505
+
493
506
  // lib/server-runtime/routeMatching.ts
494
- function matchServerRoutes(routes, pathname, basename) {
495
- let matches = matchRoutes(
496
- routes,
507
+ function matchServerRoutes(manifest, dataRoutes, branches, pathname, basename) {
508
+ let matches = matchRoutesImpl(
509
+ dataRoutes,
497
510
  pathname,
498
- basename
511
+ basename ?? "/",
512
+ false,
513
+ branches
499
514
  );
500
515
  if (!matches) return null;
501
- return matches.map((match) => ({
502
- params: match.params,
503
- pathname: match.pathname,
504
- route: match.route
505
- }));
516
+ return matches.map((match) => {
517
+ let route = manifest[match.route.id];
518
+ invariant(
519
+ route,
520
+ `Route with id "${match.route.id}" not found in manifest.`
521
+ );
522
+ return {
523
+ params: match.params,
524
+ pathname: match.pathname,
525
+ route
526
+ };
527
+ });
506
528
  }
507
529
 
508
530
  // lib/server-runtime/data.ts
509
531
  async function callRouteHandler(handler, args, future) {
510
532
  let result = await handler({
511
- request: future.unstable_passThroughRequests ? args.request : stripRoutesParam(stripIndexParam(args.request)),
512
- unstable_url: args.unstable_url,
533
+ request: future.v8_passThroughRequests ? args.request : stripRoutesParam(stripIndexParam(args.request)),
534
+ url: args.url,
513
535
  params: args.params,
514
536
  context: args.context,
515
- unstable_pattern: args.unstable_pattern
537
+ pattern: args.pattern
516
538
  });
517
539
  if (isDataWithResponseInit(result) && result.init && result.init.status && isRedirectStatusCode(result.init.status)) {
518
540
  throw new Response(null, result.init);
@@ -558,16 +580,6 @@ function stripRoutesParam(request) {
558
580
  return new Request(url.href, init);
559
581
  }
560
582
 
561
- // lib/server-runtime/invariant.ts
562
- function invariant(value, message) {
563
- if (value === false || value === null || typeof value === "undefined") {
564
- console.error(
565
- "The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"
566
- );
567
- throw new Error(message);
568
- }
569
- }
570
-
571
583
  // lib/server-runtime/dev.ts
572
584
  var globalDevServerHooksKey = "__reactRouterDevServerHooks";
573
585
  function setDevServerHooks(devServerHooks) {
@@ -602,12 +614,6 @@ function groupRoutesByParentId(manifest) {
602
614
  });
603
615
  return routes;
604
616
  }
605
- function createRoutes(manifest, parentId = "", routesByParentId = groupRoutesByParentId(manifest)) {
606
- return (routesByParentId[parentId] || []).map((route) => ({
607
- ...route,
608
- children: createRoutes(manifest, route.id, routesByParentId)
609
- }));
610
- }
611
617
  function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesByParentId = groupRoutesByParentId(manifest)) {
612
618
  return (routesByParentId[parentId] || []).map((route) => {
613
619
  let commonRoute = {
@@ -894,7 +900,7 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
894
900
  } catch (e) {
895
901
  return handleQueryError(new Error("Bad Request"), 400);
896
902
  }
897
- let handlerRequest = build.future.unstable_passThroughRequests ? request : new Request(handlerUrl, {
903
+ let handlerRequest = build.future.v8_passThroughRequests ? request : new Request(handlerUrl, {
898
904
  method: request.method,
899
905
  body: request.body,
900
906
  headers: request.headers,
@@ -913,7 +919,7 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
913
919
  return handleQueryError(error);
914
920
  }
915
921
  } : void 0,
916
- unstable_normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
922
+ normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
917
923
  });
918
924
  return handleQueryResult(result);
919
925
  } catch (error) {
@@ -962,7 +968,7 @@ async function singleFetchLoaders(build, serverMode, staticHandler, request, han
962
968
  let routesParam = new URL(request.url).searchParams.get("_routes");
963
969
  let loadRouteIds = routesParam ? new Set(routesParam.split(",")) : null;
964
970
  try {
965
- let handlerRequest = build.future.unstable_passThroughRequests ? request : new Request(handlerUrl, {
971
+ let handlerRequest = build.future.v8_passThroughRequests ? request : new Request(handlerUrl, {
966
972
  headers: request.headers,
967
973
  signal: request.signal
968
974
  });
@@ -978,7 +984,7 @@ async function singleFetchLoaders(build, serverMode, staticHandler, request, han
978
984
  return handleQueryError(error);
979
985
  }
980
986
  } : void 0,
981
- unstable_normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
987
+ normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
982
988
  });
983
989
  return handleQueryResult(result);
984
990
  } catch (error) {
@@ -1145,12 +1151,12 @@ function encodeViaTurboStream(data2, requestSignal, streamTimeout, serverMode) {
1145
1151
 
1146
1152
  // lib/server-runtime/server.ts
1147
1153
  function derive(build, mode) {
1148
- let routes = createRoutes(build.routes);
1149
1154
  let dataRoutes = createStaticHandlerDataRoutes(build.routes, build.future);
1150
1155
  let serverMode = isServerMode(mode) ? mode : "production" /* Production */;
1151
1156
  let staticHandler = createStaticHandler(dataRoutes, {
1152
1157
  basename: build.basename,
1153
- unstable_instrumentations: build.entry.module.unstable_instrumentations
1158
+ instrumentations: build.entry.module.instrumentations,
1159
+ future: build.future
1154
1160
  });
1155
1161
  let errorHandler = build.entry.module.handleError || ((error, { request }) => {
1156
1162
  if (serverMode !== "test" /* Test */ && !request.signal.aborted) {
@@ -1247,24 +1253,30 @@ function derive(build, mode) {
1247
1253
  );
1248
1254
  if (requestUrl.pathname === manifestUrl) {
1249
1255
  try {
1250
- let res = await handleManifestRequest(build, routes, requestUrl);
1256
+ let res = await handleManifestRequest(
1257
+ build,
1258
+ staticHandler.dataRoutes,
1259
+ staticHandler._internalRouteBranches,
1260
+ requestUrl
1261
+ );
1251
1262
  return res;
1252
1263
  } catch (e) {
1253
1264
  handleError(e);
1254
1265
  return new Response("Unknown Server Error", { status: 500 });
1255
1266
  }
1256
1267
  }
1257
- let matches = matchServerRoutes(routes, normalizedPathname, build.basename);
1268
+ let matches = matchServerRoutes(
1269
+ build.routes,
1270
+ staticHandler.dataRoutes,
1271
+ staticHandler._internalRouteBranches,
1272
+ normalizedPathname,
1273
+ build.basename
1274
+ );
1258
1275
  if (matches && matches.length > 0) {
1259
1276
  Object.assign(params, matches[0].params);
1260
1277
  }
1261
1278
  let response;
1262
1279
  if (requestUrl.pathname.endsWith(".data")) {
1263
- let singleFetchMatches = matchServerRoutes(
1264
- routes,
1265
- normalizedPathname,
1266
- build.basename
1267
- );
1268
1280
  response = await handleSingleFetchRequest(
1269
1281
  serverMode,
1270
1282
  build,
@@ -1285,7 +1297,7 @@ function derive(build, mode) {
1285
1297
  if (build.entry.module.handleDataRequest) {
1286
1298
  response = await build.entry.module.handleDataRequest(response, {
1287
1299
  context: loadContext,
1288
- params: singleFetchMatches ? singleFetchMatches[0].params : {},
1300
+ params: matches ? matches[0].params : {},
1289
1301
  request
1290
1302
  });
1291
1303
  if (isRedirectResponse(response)) {
@@ -1335,15 +1347,13 @@ function derive(build, mode) {
1335
1347
  }
1336
1348
  return response;
1337
1349
  };
1338
- if (build.entry.module.unstable_instrumentations) {
1350
+ if (build.entry.module.instrumentations) {
1339
1351
  requestHandler = instrumentHandler(
1340
1352
  requestHandler,
1341
- build.entry.module.unstable_instrumentations.map((i) => i.handler).filter(Boolean)
1353
+ build.entry.module.instrumentations.map((i) => i.handler).filter(Boolean)
1342
1354
  );
1343
1355
  }
1344
1356
  return {
1345
- routes,
1346
- dataRoutes,
1347
1357
  serverMode,
1348
1358
  staticHandler,
1349
1359
  errorHandler,
@@ -1352,7 +1362,6 @@ function derive(build, mode) {
1352
1362
  }
1353
1363
  var createRequestHandler = (build, mode) => {
1354
1364
  let _build;
1355
- let routes;
1356
1365
  let serverMode;
1357
1366
  let staticHandler;
1358
1367
  let errorHandler;
@@ -1361,14 +1370,12 @@ var createRequestHandler = (build, mode) => {
1361
1370
  _build = typeof build === "function" ? await build() : build;
1362
1371
  if (typeof build === "function") {
1363
1372
  let derived = derive(_build, mode);
1364
- routes = derived.routes;
1365
1373
  serverMode = derived.serverMode;
1366
1374
  staticHandler = derived.staticHandler;
1367
1375
  errorHandler = derived.errorHandler;
1368
1376
  _requestHandler = derived.requestHandler;
1369
- } else if (!routes || !serverMode || !staticHandler || !errorHandler || !_requestHandler) {
1377
+ } else if (!serverMode || !staticHandler || !errorHandler || !_requestHandler) {
1370
1378
  let derived = derive(_build, mode);
1371
- routes = derived.routes;
1372
1379
  serverMode = derived.serverMode;
1373
1380
  staticHandler = derived.staticHandler;
1374
1381
  errorHandler = derived.errorHandler;
@@ -1377,7 +1384,7 @@ var createRequestHandler = (build, mode) => {
1377
1384
  return _requestHandler(request, initialContext);
1378
1385
  };
1379
1386
  };
1380
- async function handleManifestRequest(build, routes, url) {
1387
+ async function handleManifestRequest(build, dataRoutes, branches, url) {
1381
1388
  if (build.assets.version !== url.searchParams.get("version")) {
1382
1389
  return new Response(null, {
1383
1390
  status: 204,
@@ -1386,6 +1393,12 @@ async function handleManifestRequest(build, routes, url) {
1386
1393
  }
1387
1394
  });
1388
1395
  }
1396
+ if (url.toString().length > URL_LIMIT) {
1397
+ return new Response(null, {
1398
+ statusText: "Bad Request",
1399
+ status: 400
1400
+ });
1401
+ }
1389
1402
  let patches = {};
1390
1403
  if (url.searchParams.has("paths")) {
1391
1404
  let paths = /* @__PURE__ */ new Set();
@@ -1402,7 +1415,13 @@ async function handleManifestRequest(build, routes, url) {
1402
1415
  });
1403
1416
  });
1404
1417
  for (let path of paths) {
1405
- let matches = matchServerRoutes(routes, path, build.basename);
1418
+ let matches = matchServerRoutes(
1419
+ build.routes,
1420
+ dataRoutes,
1421
+ branches,
1422
+ path,
1423
+ build.basename
1424
+ );
1406
1425
  if (matches) {
1407
1426
  for (let match of matches) {
1408
1427
  let routeId = match.route.id;
@@ -1470,7 +1489,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
1470
1489
  return new Response(null, { status: 500 });
1471
1490
  }
1472
1491
  } : void 0,
1473
- unstable_normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
1492
+ normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
1474
1493
  });
1475
1494
  if (!isResponse(result)) {
1476
1495
  result = await renderHtml(result, isSpaMode);
@@ -1507,6 +1526,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
1507
1526
  };
1508
1527
  let entryContext = {
1509
1528
  manifest: build.assets,
1529
+ branches: staticHandler._internalRouteBranches,
1510
1530
  routeModules: createEntryRouteModules(build.routes),
1511
1531
  staticHandlerContext: context,
1512
1532
  criticalCss,
@@ -1603,7 +1623,7 @@ async function handleResourceRequest(serverMode, build, staticHandler, routeId,
1603
1623
  return handleQueryRouteError(error);
1604
1624
  }
1605
1625
  } : void 0,
1606
- unstable_normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
1626
+ normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
1607
1627
  });
1608
1628
  return handleQueryRouteResult(result);
1609
1629
  } catch (error) {
@@ -2430,10 +2450,9 @@ function RSCStaticRouter({ getPayload }) {
2430
2450
  // These flags have no runtime impact so can always be false. If we add
2431
2451
  // flags that drive runtime behavior they'll need to be proxied through.
2432
2452
  v8_middleware: false,
2433
- unstable_subResourceIntegrity: false,
2434
2453
  unstable_trailingSlashAwareDataRequests: true,
2435
2454
  // always on for RSC
2436
- unstable_passThroughRequests: true
2455
+ v8_passThroughRequests: true
2437
2456
  // always on for RSC
2438
2457
  },
2439
2458
  isSpaMode: false,