react-router 7.13.1-pre.0 → 7.13.2-pre.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 (76) hide show
  1. package/CHANGELOG.md +55 -2
  2. package/dist/{production/browser-DzsJABDQ.d.mts → development/browser-Bfn3xw9E.d.ts} +2 -1
  3. package/dist/development/{browser-DzsJABDQ.d.mts → browser-Di6-vSl-.d.mts} +2 -1
  4. package/dist/{production/chunk-I63A6YSE.js → development/chunk-FXJW44AE.js} +7 -7
  5. package/dist/{production/chunk-ROHSFSEU.mjs → development/chunk-JEVMZMTG.mjs} +83 -49
  6. package/dist/development/{chunk-WQZSGSJA.mjs → chunk-WM3TIFYP.mjs} +124 -44
  7. package/dist/development/{chunk-LF5SS6XE.js → chunk-WO3PXTPV.js} +190 -111
  8. package/dist/development/{chunk-TC44ITIJ.js → chunk-ZHBHDHL3.js} +100 -99
  9. package/dist/development/context-phCt_zmH.d.mts +1713 -0
  10. package/dist/development/dom-export.d.mts +3 -2
  11. package/dist/development/dom-export.d.ts +3 -2
  12. package/dist/development/dom-export.js +45 -29
  13. package/dist/development/dom-export.mjs +21 -5
  14. package/dist/development/{index-react-server-client-C4tCIird.d.ts → index-react-server-client-BcrVT7Dd.d.mts} +4 -2
  15. package/dist/{production/index-react-server-client-C4tCIird.d.ts → development/index-react-server-client-CCwMoQIT.d.ts} +1067 -10
  16. package/dist/development/index-react-server-client.d.mts +3 -2
  17. package/dist/development/index-react-server-client.d.ts +3 -2
  18. package/dist/development/index-react-server-client.js +4 -4
  19. package/dist/development/index-react-server-client.mjs +2 -2
  20. package/dist/development/index-react-server.d.mts +293 -246
  21. package/dist/development/index-react-server.d.ts +293 -246
  22. package/dist/development/index-react-server.js +121 -43
  23. package/dist/development/index-react-server.mjs +121 -43
  24. package/dist/development/index.d.mts +15 -13
  25. package/dist/development/index.d.ts +15 -13
  26. package/dist/development/index.js +176 -142
  27. package/dist/development/index.mjs +3 -3
  28. package/dist/development/instrumentation-BYr6ff5D.d.ts +657 -0
  29. package/dist/development/lib/types/internal.d.mts +2 -2
  30. package/dist/development/lib/types/internal.d.ts +2 -2
  31. package/dist/development/lib/types/internal.js +1 -1
  32. package/dist/development/lib/types/internal.mjs +1 -1
  33. package/dist/development/{register-CBoanF80.d.ts → register-CTxsJBKQ.d.mts} +1 -1
  34. package/dist/development/{register-cRYJ3CjG.d.mts → register-CkcGwv27.d.ts} +1 -1
  35. package/dist/development/routeModules-BRrCYrSL.d.mts +1693 -0
  36. package/dist/development/routeModules-CA7kSxJJ.d.ts +1693 -0
  37. package/dist/production/{browser-sPQ7eaK4.d.ts → browser-Bfn3xw9E.d.ts} +2 -1
  38. package/dist/{development/browser-sPQ7eaK4.d.ts → production/browser-Di6-vSl-.d.mts} +2 -1
  39. package/dist/production/{chunk-XCKC4VBJ.js → chunk-6A7E6W56.js} +190 -111
  40. package/dist/production/{chunk-ZXYVKLN7.js → chunk-C3CA6GXO.js} +100 -99
  41. package/dist/production/{chunk-2K4LVAAG.mjs → chunk-GCYIH3UC.mjs} +124 -44
  42. package/dist/{development/chunk-CGPAOPIJ.js → production/chunk-R7LC5VXK.js} +7 -7
  43. package/dist/{development/chunk-BPFEYQ6M.mjs → production/chunk-ZLBCNRMB.mjs} +83 -49
  44. package/dist/production/context-phCt_zmH.d.mts +1713 -0
  45. package/dist/production/dom-export.d.mts +3 -2
  46. package/dist/production/dom-export.d.ts +3 -2
  47. package/dist/production/dom-export.js +45 -29
  48. package/dist/production/dom-export.mjs +21 -5
  49. package/dist/{development/index-react-server-client-EzWJGpN_.d.mts → production/index-react-server-client-BcrVT7Dd.d.mts} +4 -2
  50. package/dist/production/{index-react-server-client-EzWJGpN_.d.mts → index-react-server-client-CCwMoQIT.d.ts} +1067 -10
  51. package/dist/production/index-react-server-client.d.mts +3 -2
  52. package/dist/production/index-react-server-client.d.ts +3 -2
  53. package/dist/production/index-react-server-client.js +4 -4
  54. package/dist/production/index-react-server-client.mjs +2 -2
  55. package/dist/production/index-react-server.d.mts +293 -246
  56. package/dist/production/index-react-server.d.ts +293 -246
  57. package/dist/production/index-react-server.js +121 -43
  58. package/dist/production/index-react-server.mjs +121 -43
  59. package/dist/production/index.d.mts +15 -13
  60. package/dist/production/index.d.ts +15 -13
  61. package/dist/production/index.js +176 -142
  62. package/dist/production/index.mjs +3 -3
  63. package/dist/production/instrumentation-BYr6ff5D.d.ts +657 -0
  64. package/dist/production/lib/types/internal.d.mts +2 -2
  65. package/dist/production/lib/types/internal.d.ts +2 -2
  66. package/dist/production/lib/types/internal.js +1 -1
  67. package/dist/production/lib/types/internal.mjs +1 -1
  68. package/dist/production/{register-CBoanF80.d.ts → register-CTxsJBKQ.d.mts} +1 -1
  69. package/dist/production/{register-cRYJ3CjG.d.mts → register-CkcGwv27.d.ts} +1 -1
  70. package/dist/production/routeModules-BRrCYrSL.d.mts +1693 -0
  71. package/dist/production/routeModules-CA7kSxJJ.d.ts +1693 -0
  72. package/package.json +1 -1
  73. package/dist/development/instrumentation--6Pioq_G.d.ts +0 -3344
  74. package/dist/development/router-cLsU7kHk.d.mts +0 -3344
  75. package/dist/production/instrumentation--6Pioq_G.d.ts +0 -3344
  76. package/dist/production/router-cLsU7kHk.d.mts +0 -3344
package/CHANGELOG.md CHANGED
@@ -1,19 +1,71 @@
1
1
  # `react-router`
2
2
 
3
- ## 7.13.1-pre.0
3
+ ## 7.13.2-pre.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix clientLoader.hydrate when an ancestor route is also hydrating a clientLoader ([#14835](https://github.com/remix-run/react-router/pull/14835))
8
+ - Fix type error when passing Framework Mode route components using `Route.ComponentProps` to `createRoutesStub` ([#14892](https://github.com/remix-run/react-router/pull/14892))
9
+ - Fix percent encoding in relative path navigation ([#14786](https://github.com/remix-run/react-router/pull/14786))
10
+ - Add `future.unstable_passThroughRequests` flag ([#14775](https://github.com/remix-run/react-router/pull/14775))
11
+
12
+ By default, React Router normalizes the `request.url` passed to your `loader`, `action`, and `middleware` functions by removing React Router's internal implementation details (`.data` suffixes, `index` + `_routes` query params).
13
+
14
+ Enabling this flag removes that normalization and passes the raw HTTP `request` instance to your handlers. This provides a few benefits:
15
+ - Reduces server-side overhead by eliminating multiple `new Request()` calls on the critical path
16
+ - Allows you to distinguish document from data requests in your handlers base don the presence of a `.data` suffix (useful for observability purposes)
17
+
18
+ If you were previously relying on the normalization of `request.url`, you can switch to use the new sibling `unstable_url` parameter which contains a `URL` instance representing the normalized location:
19
+
20
+ ```tsx
21
+ // ❌ Before: you could assume there was no `.data` suffix in `request.url`
22
+ export async function loader({ request }: Route.LoaderArgs) {
23
+ let url = new URL(request.url);
24
+ if (url.pathname === "/path") {
25
+ // This check will fail with the flag enabled because the `.data` suffix will
26
+ // exist on data requests
27
+ }
28
+ }
29
+
30
+ // ✅ After: use `unstable_url` for normalized routing logic and `request.url`
31
+ // for raw routing logic
32
+ export async function loader({ request, unstable_url }: Route.LoaderArgs) {
33
+ if (unstable_url.pathname === "/path") {
34
+ // This will always have the `.data` suffix stripped
35
+ }
36
+
37
+ // And now you can distinguish between document versus data requests
38
+ let isDataRequest = new URL(request.url).pathname.endsWith(".data");
39
+ }
40
+ ```
41
+
42
+ - Internal refactor to consolidate framework-agnostic/React-specific route type layers - no public API changes ([#14765](https://github.com/remix-run/react-router/pull/14765))
43
+ - Sync protocol validation to rsc flows ([#14882](https://github.com/remix-run/react-router/pull/14882))
44
+ - Add a new `unstable_url: URL` parameter to route handler methods (`loader`, `action`, `middleware`, etc.) representing the normalized URL the application is navigating to or fetching, with React Router implementation details removed (`.data`suffix, `index`/`_routes` query params) ([#14775](https://github.com/remix-run/react-router/pull/14775))
45
+
46
+ This is being added alongside the new `future.unstable_passthroughRequests` future flag so that users still have a way to access the normalized URL when that flag is enabled and non-normalized `request`'s are being passed to your handlers. When adopting this flag, you will only need to start leveraging this new parameter if you are relying on the normalization of `request.url` in your application code.
47
+
48
+ If you don't have the flag enabled, then `unstable_url` will match `request.url`.
49
+
50
+ ## 7.13.1
4
51
 
5
52
  ### Patch Changes
6
53
 
7
54
  - fix null reference exception in bad codepath leading to invalid route tree comparisons ([#14780](https://github.com/remix-run/react-router/pull/14780))
55
+
8
56
  - fix: clear timeout when turbo-stream encoding completes ([#14810](https://github.com/remix-run/react-router/pull/14810))
57
+
9
58
  - Improve error message when Origin header is invalid ([#14743](https://github.com/remix-run/react-router/pull/14743))
59
+
10
60
  - Fix matchPath optional params matching without a "/" separator. ([#14689](https://github.com/remix-run/react-router/pull/14689))
11
61
  - matchPath("/users/:id?", "/usersblah") now returns null.
12
62
  - matchPath("/test_route/:part?", "/test_route_more") now returns null.
13
63
 
14
64
  - add RSC unstable_getRequest ([#14758](https://github.com/remix-run/react-router/pull/14758))
65
+
15
66
  - Fix `HydrateFallback` rendering during initial lazy route discovery with matching splat route ([#14740](https://github.com/remix-run/react-router/pull/14740))
16
- - [UNSTABLE] Add support for `<Link unstable_mask>` in Data Mode which allows users to navigate to a URL in the router but "mask" the URL displayed in the browser. This is useful for contextual routing usages such as displaying an image in a model on top of a gallery, but displaying a browser URL directly to the image that can be shared and loaded without the contextual gallery in the background. ([#14716](https://github.com/remix-run/react-router/pull/14716))
67
+
68
+ - \[UNSTABLE] Add support for `<Link unstable_mask>` in Data Mode which allows users to navigate to a URL in the router but "mask" the URL displayed in the browser. This is useful for contextual routing usages such as displaying an image in a model on top of a gallery, but displaying a browser URL directly to the image that can be shared and loaded without the contextual gallery in the background. ([#14716](https://github.com/remix-run/react-router/pull/14716))
17
69
 
18
70
  ```tsx
19
71
  // routes/gallery.tsx
@@ -60,6 +112,7 @@
60
112
  - This provides a first-class API to mask URLs in Data Mode to achieve the same behavior you could do in Declarative Mode via [manual `backgroundLocation` management](https://github.com/remix-run/react-router/tree/main/examples/modal).
61
113
 
62
114
  - RSC: Update failed origin checks to return a 400 status and appropriate UI instead of a generic 500 ([#14755](https://github.com/remix-run/react-router/pull/14755))
115
+
63
116
  - Preserve query parameters and hash on manifest version mismatch reload ([#14813](https://github.com/remix-run/react-router/pull/14813))
64
117
 
65
118
  ## 7.13.0
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
- import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction, e as RouterInit } from './router-cLsU7kHk.mjs';
2
+ import { R as RouterInit } from './instrumentation-BYr6ff5D.js';
3
+ import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction } from './routeModules-CA7kSxJJ.js';
3
4
 
4
5
  declare function getRequest(): Request;
5
6
  type RSCRouteConfigEntryBase = {
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
- import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction, e as RouterInit } from './router-cLsU7kHk.mjs';
2
+ import { R as RouterInit } from './context-phCt_zmH.mjs';
3
+ import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction } from './routeModules-BRrCYrSL.mjs';
3
4
 
4
5
  declare function getRequest(): Request;
5
6
  type RSCRouteConfigEntryBase = {
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }/**
2
- * react-router v7.13.1-pre.0
2
+ * react-router v7.13.2-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -14,7 +14,7 @@
14
14
 
15
15
 
16
16
 
17
- var _chunkXCKC4VBJjs = require('./chunk-XCKC4VBJ.js');
17
+ var _chunkWO3PXTPVjs = require('./chunk-WO3PXTPV.js');
18
18
 
19
19
  // lib/dom/ssr/hydration.tsx
20
20
  function getHydrationData({
@@ -29,12 +29,12 @@ function getHydrationData({
29
29
  ...state,
30
30
  loaderData: { ...state.loaderData }
31
31
  };
32
- let initialMatches = _chunkXCKC4VBJjs.matchRoutes.call(void 0, routes, location, basename);
32
+ let initialMatches = _chunkWO3PXTPVjs.matchRoutes.call(void 0, routes, location, basename);
33
33
  if (initialMatches) {
34
34
  for (let match of initialMatches) {
35
35
  let routeId = match.route.id;
36
36
  let routeInfo = getRouteInfo(routeId);
37
- if (_chunkXCKC4VBJjs.shouldHydrateRouteLoader.call(void 0,
37
+ if (_chunkWO3PXTPVjs.shouldHydrateRouteLoader.call(void 0,
38
38
  routeId,
39
39
  routeInfo.clientLoader,
40
40
  routeInfo.hasLoader,
@@ -112,7 +112,7 @@ function RSCDefaultRootErrorBoundaryImpl({
112
112
  }
113
113
  }
114
114
  );
115
- if (_chunkXCKC4VBJjs.isRouteErrorResponse.call(void 0, error)) {
115
+ if (_chunkWO3PXTPVjs.isRouteErrorResponse.call(void 0, error)) {
116
116
  return /* @__PURE__ */ _react2.default.createElement(
117
117
  ErrorWrapper,
118
118
  {
@@ -120,7 +120,7 @@ function RSCDefaultRootErrorBoundaryImpl({
120
120
  title: "Unhandled Thrown Response!"
121
121
  },
122
122
  /* @__PURE__ */ _react2.default.createElement("h1", { style: { fontSize: "24px" } }, error.status, " ", error.statusText),
123
- _chunkXCKC4VBJjs.ENABLE_DEV_WARNINGS ? heyDeveloper : null
123
+ _chunkWO3PXTPVjs.ENABLE_DEV_WARNINGS ? heyDeveloper : null
124
124
  );
125
125
  }
126
126
  let errorInstance;
@@ -146,7 +146,7 @@ function RSCDefaultRootErrorBoundaryImpl({
146
146
  function RSCDefaultRootErrorBoundary({
147
147
  hasRootLayout
148
148
  }) {
149
- let error = _chunkXCKC4VBJjs.useRouteError.call(void 0, );
149
+ let error = _chunkWO3PXTPVjs.useRouteError.call(void 0, );
150
150
  if (hasRootLayout === void 0) {
151
151
  throw new Error("Missing 'hasRootLayout' prop");
152
152
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.13.1-pre.0
2
+ * react-router v7.13.2-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -51,7 +51,7 @@ import {
51
51
  withComponentProps,
52
52
  withErrorBoundaryProps,
53
53
  withHydrateFallbackProps
54
- } from "./chunk-2K4LVAAG.mjs";
54
+ } from "./chunk-WM3TIFYP.mjs";
55
55
 
56
56
  // lib/dom/ssr/server.tsx
57
57
  import * as React from "react";
@@ -137,6 +137,7 @@ function createRoutesStub(routes, _context) {
137
137
  if (routerRef.current == null) {
138
138
  frameworkContextRef.current = {
139
139
  future: {
140
+ unstable_passThroughRequests: future?.unstable_passThroughRequests === true,
140
141
  unstable_subResourceIntegrity: future?.unstable_subResourceIntegrity === true,
141
142
  v8_middleware: future?.v8_middleware === true,
142
143
  unstable_trailingSlashAwareDataRequests: future?.unstable_trailingSlashAwareDataRequests === true
@@ -154,7 +155,7 @@ function createRoutesStub(routes, _context) {
154
155
  };
155
156
  let patched = processRoutes(
156
157
  // @ts-expect-error `StubRouteObject` is stricter about `loader`/`action`
157
- // types compared to `AgnosticRouteObject`
158
+ // types compared to `RouteObject`
158
159
  convertRoutesToDataRoutes(routes, (r) => r),
159
160
  _context !== void 0 ? _context : future?.v8_middleware ? new RouterContextProvider() : {},
160
161
  frameworkContextRef.current.manifest,
@@ -505,9 +506,10 @@ function matchServerRoutes(routes, pathname, basename) {
505
506
  }
506
507
 
507
508
  // lib/server-runtime/data.ts
508
- async function callRouteHandler(handler, args) {
509
+ async function callRouteHandler(handler, args, future) {
509
510
  let result = await handler({
510
- request: stripRoutesParam(stripIndexParam(args.request)),
511
+ request: future.unstable_passThroughRequests ? args.request : stripRoutesParam(stripIndexParam(args.request)),
512
+ unstable_url: args.unstable_url,
511
513
  params: args.params,
512
514
  context: args.context,
513
515
  unstable_pattern: args.unstable_pattern
@@ -656,10 +658,14 @@ function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesBy
656
658
  return result.data;
657
659
  }
658
660
  }
659
- let val = await callRouteHandler(route.module.loader, args);
661
+ let val = await callRouteHandler(
662
+ route.module.loader,
663
+ args,
664
+ future
665
+ );
660
666
  return val;
661
667
  } : void 0,
662
- action: route.module.action ? (args) => callRouteHandler(route.module.action, args) : void 0,
668
+ action: route.module.action ? (args) => callRouteHandler(route.module.action, args, future) : void 0,
663
669
  handle: route.module.handle
664
670
  };
665
671
  return route.index ? {
@@ -838,6 +844,41 @@ function parseHostHeader(headers) {
838
844
  } : void 0;
839
845
  }
840
846
 
847
+ // lib/server-runtime/urls.ts
848
+ function getNormalizedPath(request, basename, future) {
849
+ basename = basename || "/";
850
+ let url = new URL(request.url);
851
+ let pathname = url.pathname;
852
+ if (future?.unstable_trailingSlashAwareDataRequests) {
853
+ if (pathname.endsWith("/_.data")) {
854
+ pathname = pathname.replace(/_\.data$/, "");
855
+ } else {
856
+ pathname = pathname.replace(/\.data$/, "");
857
+ }
858
+ } else {
859
+ if (stripBasename(pathname, basename) === "/_root.data") {
860
+ pathname = basename;
861
+ } else if (pathname.endsWith(".data")) {
862
+ pathname = pathname.replace(/\.data$/, "");
863
+ }
864
+ if (stripBasename(pathname, basename) !== "/" && pathname.endsWith("/")) {
865
+ pathname = pathname.slice(0, -1);
866
+ }
867
+ }
868
+ let searchParams = new URLSearchParams(url.search);
869
+ searchParams.delete("_routes");
870
+ let search = searchParams.toString();
871
+ if (search) {
872
+ search = `?${search}`;
873
+ }
874
+ return {
875
+ pathname,
876
+ search,
877
+ // No hashes on the server
878
+ hash: ""
879
+ };
880
+ }
881
+
841
882
  // lib/server-runtime/single-fetch.ts
842
883
  var SERVER_NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([
843
884
  ...NO_BODY_STATUS_CODES,
@@ -853,7 +894,7 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
853
894
  } catch (e) {
854
895
  return handleQueryError(new Error("Bad Request"), 400);
855
896
  }
856
- let handlerRequest = new Request(handlerUrl, {
897
+ let handlerRequest = build.future.unstable_passThroughRequests ? request : new Request(handlerUrl, {
857
898
  method: request.method,
858
899
  body: request.body,
859
900
  headers: request.headers,
@@ -871,7 +912,8 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
871
912
  } catch (error) {
872
913
  return handleQueryError(error);
873
914
  }
874
- } : void 0
915
+ } : void 0,
916
+ unstable_normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
875
917
  });
876
918
  return handleQueryResult(result);
877
919
  } catch (error) {
@@ -920,7 +962,7 @@ async function singleFetchLoaders(build, serverMode, staticHandler, request, han
920
962
  let routesParam = new URL(request.url).searchParams.get("_routes");
921
963
  let loadRouteIds = routesParam ? new Set(routesParam.split(",")) : null;
922
964
  try {
923
- let handlerRequest = new Request(handlerUrl, {
965
+ let handlerRequest = build.future.unstable_passThroughRequests ? request : new Request(handlerUrl, {
924
966
  headers: request.headers,
925
967
  signal: request.signal
926
968
  });
@@ -935,7 +977,8 @@ async function singleFetchLoaders(build, serverMode, staticHandler, request, han
935
977
  } catch (error) {
936
978
  return handleQueryError(error);
937
979
  }
938
- } : void 0
980
+ } : void 0,
981
+ unstable_normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
939
982
  });
940
983
  return handleQueryResult(result);
941
984
  } catch (error) {
@@ -1132,36 +1175,23 @@ function derive(build, mode) {
1132
1175
  } else {
1133
1176
  loadContext = initialContext || {};
1134
1177
  }
1135
- let url = new URL(request.url);
1136
- let normalizedBasename = build.basename || "/";
1137
- let normalizedPath = url.pathname;
1138
- if (build.future.unstable_trailingSlashAwareDataRequests) {
1139
- if (normalizedPath.endsWith("/_.data")) {
1140
- normalizedPath = normalizedPath.replace(/_.data$/, "");
1141
- } else {
1142
- normalizedPath = normalizedPath.replace(/\.data$/, "");
1143
- }
1144
- } else {
1145
- if (stripBasename(normalizedPath, normalizedBasename) === "/_root.data") {
1146
- normalizedPath = normalizedBasename;
1147
- } else if (normalizedPath.endsWith(".data")) {
1148
- normalizedPath = normalizedPath.replace(/\.data$/, "");
1149
- }
1150
- if (stripBasename(normalizedPath, normalizedBasename) !== "/" && normalizedPath.endsWith("/")) {
1151
- normalizedPath = normalizedPath.slice(0, -1);
1152
- }
1153
- }
1178
+ let requestUrl = new URL(request.url);
1179
+ let normalizedPathname = getNormalizedPath(
1180
+ request,
1181
+ build.basename,
1182
+ build.future
1183
+ ).pathname;
1154
1184
  let isSpaMode = getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes";
1155
1185
  if (!build.ssr) {
1156
- let decodedPath = decodeURI(normalizedPath);
1157
- if (normalizedBasename !== "/") {
1158
- let strippedPath = stripBasename(decodedPath, normalizedBasename);
1186
+ let decodedPath = decodeURI(normalizedPathname);
1187
+ if (build.basename && build.basename !== "/") {
1188
+ let strippedPath = stripBasename(decodedPath, build.basename);
1159
1189
  if (strippedPath == null) {
1160
1190
  errorHandler(
1161
1191
  new ErrorResponseImpl(
1162
1192
  404,
1163
1193
  "Not Found",
1164
- `Refusing to prerender the \`${decodedPath}\` path because it does not start with the basename \`${normalizedBasename}\``
1194
+ `Refusing to prerender the \`${decodedPath}\` path because it does not start with the basename \`${build.basename}\``
1165
1195
  ),
1166
1196
  {
1167
1197
  context: loadContext,
@@ -1179,7 +1209,7 @@ function derive(build, mode) {
1179
1209
  if (build.prerender.length === 0) {
1180
1210
  isSpaMode = true;
1181
1211
  } else if (!build.prerender.includes(decodedPath) && !build.prerender.includes(decodedPath + "/")) {
1182
- if (url.pathname.endsWith(".data")) {
1212
+ if (requestUrl.pathname.endsWith(".data")) {
1183
1213
  errorHandler(
1184
1214
  new ErrorResponseImpl(
1185
1215
  404,
@@ -1203,28 +1233,26 @@ function derive(build, mode) {
1203
1233
  }
1204
1234
  let manifestUrl = getManifestPath(
1205
1235
  build.routeDiscovery.manifestPath,
1206
- normalizedBasename
1236
+ build.basename
1207
1237
  );
1208
- if (url.pathname === manifestUrl) {
1238
+ if (requestUrl.pathname === manifestUrl) {
1209
1239
  try {
1210
- let res = await handleManifestRequest(build, routes, url);
1240
+ let res = await handleManifestRequest(build, routes, requestUrl);
1211
1241
  return res;
1212
1242
  } catch (e) {
1213
1243
  handleError(e);
1214
1244
  return new Response("Unknown Server Error", { status: 500 });
1215
1245
  }
1216
1246
  }
1217
- let matches = matchServerRoutes(routes, normalizedPath, build.basename);
1247
+ let matches = matchServerRoutes(routes, normalizedPathname, build.basename);
1218
1248
  if (matches && matches.length > 0) {
1219
1249
  Object.assign(params, matches[0].params);
1220
1250
  }
1221
1251
  let response;
1222
- if (url.pathname.endsWith(".data")) {
1223
- let handlerUrl = new URL(request.url);
1224
- handlerUrl.pathname = normalizedPath;
1252
+ if (requestUrl.pathname.endsWith(".data")) {
1225
1253
  let singleFetchMatches = matchServerRoutes(
1226
1254
  routes,
1227
- handlerUrl.pathname,
1255
+ normalizedPathname,
1228
1256
  build.basename
1229
1257
  );
1230
1258
  response = await handleSingleFetchRequest(
@@ -1232,7 +1260,7 @@ function derive(build, mode) {
1232
1260
  build,
1233
1261
  staticHandler,
1234
1262
  request,
1235
- handlerUrl,
1263
+ normalizedPathname,
1236
1264
  loadContext,
1237
1265
  handleError
1238
1266
  );
@@ -1270,7 +1298,7 @@ function derive(build, mode) {
1270
1298
  handleError
1271
1299
  );
1272
1300
  } else {
1273
- let { pathname } = url;
1301
+ let { pathname } = requestUrl;
1274
1302
  let criticalCss = void 0;
1275
1303
  if (build.unstable_getCriticalCss) {
1276
1304
  criticalCss = await build.unstable_getCriticalCss({ pathname });
@@ -1383,7 +1411,9 @@ async function handleManifestRequest(build, routes, url) {
1383
1411
  }
1384
1412
  return new Response("Invalid Request", { status: 400 });
1385
1413
  }
1386
- async function handleSingleFetchRequest(serverMode, build, staticHandler, request, handlerUrl, loadContext, handleError) {
1414
+ async function handleSingleFetchRequest(serverMode, build, staticHandler, request, normalizedPath, loadContext, handleError) {
1415
+ let handlerUrl = new URL(request.url);
1416
+ handlerUrl.pathname = normalizedPath;
1387
1417
  let response = request.method !== "GET" ? await singleFetchAction(
1388
1418
  build,
1389
1419
  serverMode,
@@ -1429,7 +1459,8 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
1429
1459
  handleError(error);
1430
1460
  return new Response(null, { status: 500 });
1431
1461
  }
1432
- } : void 0
1462
+ } : void 0,
1463
+ unstable_normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
1433
1464
  });
1434
1465
  if (!isResponse(result)) {
1435
1466
  result = await renderHtml(result, isSpaMode);
@@ -1561,7 +1592,8 @@ async function handleResourceRequest(serverMode, build, staticHandler, routeId,
1561
1592
  } catch (error) {
1562
1593
  return handleQueryRouteError(error);
1563
1594
  }
1564
- } : void 0
1595
+ } : void 0,
1596
+ unstable_normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
1565
1597
  });
1566
1598
  return handleQueryRouteResult(result);
1567
1599
  } catch (error) {
@@ -2388,7 +2420,9 @@ function RSCStaticRouter({ getPayload }) {
2388
2420
  // flags that drive runtime behavior they'll need to be proxied through.
2389
2421
  v8_middleware: false,
2390
2422
  unstable_subResourceIntegrity: false,
2391
- unstable_trailingSlashAwareDataRequests: true
2423
+ unstable_trailingSlashAwareDataRequests: true,
2424
+ // always on for RSC
2425
+ unstable_passThroughRequests: true
2392
2426
  // always on for RSC
2393
2427
  },
2394
2428
  isSpaMode: false,