react-router 7.6.1-pre.2 → 7.6.2

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 (32) hide show
  1. package/CHANGELOG.md +12 -18
  2. package/dist/development/{chunk-H4Y5ODCL.mjs → chunk-NL6KNZEE.mjs} +48 -39
  3. package/dist/development/dom-export.d.mts +2 -2
  4. package/dist/development/dom-export.js +1 -1
  5. package/dist/development/dom-export.mjs +2 -2
  6. package/dist/development/index.d.mts +8 -389
  7. package/dist/development/index.d.ts +819 -799
  8. package/dist/development/index.js +51 -39
  9. package/dist/development/index.mjs +9 -3
  10. package/dist/development/lib/types/internal.d.mts +1 -1
  11. package/dist/development/lib/types/internal.d.ts +1 -1
  12. package/dist/development/lib/types/internal.js +1 -1
  13. package/dist/development/lib/types/internal.mjs +1 -1
  14. package/dist/{production/lib-B8x_tOvL.d.mts → development/lib-C1JSsICm.d.mts} +537 -136
  15. package/dist/{production/register-BkDIKxVz.d.ts → development/register-DCE0tH5m.d.ts} +1 -1
  16. package/dist/{production/route-data-WyrduLgj.d.mts → development/route-data-ByAYLHuM.d.mts} +1 -1
  17. package/dist/production/{chunk-WUZRT63N.mjs → chunk-JRQCFVZH.mjs} +48 -39
  18. package/dist/production/dom-export.d.mts +2 -2
  19. package/dist/production/dom-export.js +1 -1
  20. package/dist/production/dom-export.mjs +2 -2
  21. package/dist/production/index.d.mts +8 -389
  22. package/dist/production/index.d.ts +819 -799
  23. package/dist/production/index.js +51 -39
  24. package/dist/production/index.mjs +9 -3
  25. package/dist/production/lib/types/internal.d.mts +1 -1
  26. package/dist/production/lib/types/internal.d.ts +1 -1
  27. package/dist/production/lib/types/internal.js +1 -1
  28. package/dist/production/lib/types/internal.mjs +1 -1
  29. package/dist/{development/lib-B8x_tOvL.d.mts → production/lib-C1JSsICm.d.mts} +537 -136
  30. package/dist/{development/register-BkDIKxVz.d.ts → production/register-DCE0tH5m.d.ts} +1 -1
  31. package/dist/{development/route-data-WyrduLgj.d.mts → production/route-data-ByAYLHuM.d.mts} +1 -1
  32. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,18 +1,13 @@
1
1
  # `react-router`
2
2
 
3
- ## 7.6.1-pre.2
3
+ ## 7.6.2
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - [REMOVE] Revert tsup changes ([#13667](https://github.com/remix-run/react-router/pull/13667))
7
+ - Avoid additional `with-props` chunk in Framework Mode by moving route module component prop logic from the Vite plugin to `react-router` ([#13650](https://github.com/remix-run/react-router/pull/13650))
8
+ - \[INTERNAL] Slight refactor of internal `headers()` function processing for use with RSC ([#13639](https://github.com/remix-run/react-router/pull/13639))
8
9
 
9
- ## 7.6.1-pre.1
10
-
11
- ### Patch Changes
12
-
13
- - [REMOVE] test changeset to force prerelease ([`d79c4fcac`](https://github.com/remix-run/react-router/commit/d79c4fcac236fd3bd5041ba706b2c52370337915))
14
-
15
- ## 7.6.1-pre.0
10
+ ## 7.6.1
16
11
 
17
12
  ### Patch Changes
18
13
 
@@ -21,6 +16,7 @@
21
16
  This is primarily for cases where a route `loader` threw an error to it's own `ErrorBoundary`. but it also arises in the case of a 404 which renders the root `ErrorBoundary`/`meta` but the root loader did not run because not routes matched.
22
17
 
23
18
  - Partially revert optimization added in `7.1.4` to reduce calls to `matchRoutes` because it surfaced other issues ([#13562](https://github.com/remix-run/react-router/pull/13562))
19
+
24
20
  - Fix typegen when same route is used at multiple paths ([#13574](https://github.com/remix-run/react-router/pull/13574))
25
21
 
26
22
  For example, `routes/route.tsx` is used at 4 different paths here:
@@ -50,7 +46,7 @@
50
46
 
51
47
  export default [
52
48
  route("parent/:p", "routes/parent.tsx", [
53
- route("route/:r", "routes/route.tsx", [
49
+ route("layout/:l", "routes/layout.tsx", [
54
50
  route("child1/:c1a/:c1b", "routes/child1.tsx"),
55
51
  route("child2/:c2a/:c2b", "routes/child2.tsx"),
56
52
  ]),
@@ -58,9 +54,9 @@
58
54
  ] satisfies RouteConfig;
59
55
  ```
60
56
 
61
- Previously, `params` for `routes/route` were calculated as `{ p: string, r: string }`.
57
+ Previously, `params` for the `routes/layout.tsx` route were calculated as `{ p: string, l: string }`.
62
58
  This incorrectly ignores params that could come from child routes.
63
- If visiting `/parent/1/route/2/child1/3/4`, the actual params passed to `routes/route` will have a type of `{ p: string, r: string, c1a: string, c1b: string }`.
59
+ If visiting `/parent/1/layout/2/child1/3/4`, the actual params passed to `routes/layout.tsx` will have a type of `{ p: string, l: string, c1a: string, c1b: string }`.
64
60
 
65
61
  Now, `params` are aware of child routes and autocompletion will include child params as optionals:
66
62
 
@@ -68,21 +64,21 @@
68
64
  params.|
69
65
  // ^ cursor is here and you ask for autocompletion
70
66
  // p: string
71
- // r: string
67
+ // l: string
72
68
  // c1a?: string
73
69
  // c1b?: string
74
70
  // c2a?: string
75
71
  // c2b?: string
76
72
  ```
77
73
 
78
- You can also narrow the types for `params` as it is implemented as a normalized union of params for each page that includes `routes/route`:
74
+ You can also narrow the types for `params` as it is implemented as a normalized union of params for each page that includes `routes/layout.tsx`:
79
75
 
80
76
  ```ts
81
77
  if (typeof params.c1a === 'string') {
82
78
  params.|
83
79
  // ^ cursor is here and you ask for autocompletion
84
80
  // p: string
85
- // r: string
81
+ // l: string
86
82
  // c1a: string
87
83
  // c1b: string
88
84
  }
@@ -94,7 +90,7 @@
94
90
  UNSTABLE: removed `Info` export from generated `+types/*` files
95
91
 
96
92
  - Avoid initial fetcher execution 404 error when Lazy Route Discovery is interrupted by a navigation ([#13564](https://github.com/remix-run/react-router/pull/13564))
97
- - Remove hashes from files in `dist/` for easier usage with `patch-package` ([#13567](https://github.com/remix-run/react-router/pull/13567))
93
+
98
94
  - href replaces splats `*` ([#13593](https://github.com/remix-run/react-router/pull/13593))
99
95
 
100
96
  ```ts
@@ -508,8 +504,6 @@
508
504
 
509
505
  For library and framework authors using `unstable_SerializesTo`, you may need to add `as unknown` casts before casting to `unstable_SerializesTo`.
510
506
 
511
- - \[REMOVE] Remove middleware depth logic and always call middlware for all matches ([#13172](https://github.com/remix-run/react-router/pull/13172))
512
-
513
507
  - Fix single fetch `_root.data` requests when a `basename` is used ([#12898](https://github.com/remix-run/react-router/pull/12898))
514
508
 
515
509
  - Add `context` support to client side data routers (unstable) ([#12941](https://github.com/remix-run/react-router/pull/12941))
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.6.1-pre.2
2
+ * react-router v7.6.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -5920,6 +5920,38 @@ var createRoutesFromElements = createRoutesFromChildren;
5920
5920
  function renderMatches(matches) {
5921
5921
  return _renderMatches(matches);
5922
5922
  }
5923
+ function withComponentProps(Component4) {
5924
+ return function WithComponentProps() {
5925
+ const props = {
5926
+ params: useParams(),
5927
+ loaderData: useLoaderData(),
5928
+ actionData: useActionData(),
5929
+ matches: useMatches()
5930
+ };
5931
+ return React3.createElement(Component4, props);
5932
+ };
5933
+ }
5934
+ function withHydrateFallbackProps(HydrateFallback) {
5935
+ return function WithHydrateFallbackProps() {
5936
+ const props = {
5937
+ params: useParams(),
5938
+ loaderData: useLoaderData(),
5939
+ actionData: useActionData()
5940
+ };
5941
+ return React3.createElement(HydrateFallback, props);
5942
+ };
5943
+ }
5944
+ function withErrorBoundaryProps(ErrorBoundary) {
5945
+ return function WithErrorBoundaryProps() {
5946
+ const props = {
5947
+ params: useParams(),
5948
+ loaderData: useLoaderData(),
5949
+ actionData: useActionData(),
5950
+ error: useRouteError()
5951
+ };
5952
+ return React3.createElement(ErrorBoundary, props);
5953
+ };
5954
+ }
5923
5955
 
5924
5956
  // lib/dom/lib.tsx
5925
5957
  import * as React10 from "react";
@@ -8685,7 +8717,7 @@ function mergeRefs(...refs) {
8685
8717
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
8686
8718
  try {
8687
8719
  if (isBrowser) {
8688
- window.__reactRouterVersion = "7.6.1-pre.2";
8720
+ window.__reactRouterVersion = "7.6.2";
8689
8721
  }
8690
8722
  } catch (e) {
8691
8723
  }
@@ -9879,37 +9911,6 @@ function createRoutesStub(routes, unstable_getContext) {
9879
9911
  return /* @__PURE__ */ React13.createElement(FrameworkContext.Provider, { value: remixContextRef.current }, /* @__PURE__ */ React13.createElement(RouterProvider, { router: routerRef.current }));
9880
9912
  };
9881
9913
  }
9882
- function withComponentProps(Component4) {
9883
- return function Wrapped() {
9884
- return React13.createElement(Component4, {
9885
- params: useParams(),
9886
- loaderData: useLoaderData(),
9887
- actionData: useActionData(),
9888
- matches: useMatches()
9889
- });
9890
- };
9891
- }
9892
- function withHydrateFallbackProps(HydrateFallback) {
9893
- return function Wrapped() {
9894
- const props = {
9895
- params: useParams(),
9896
- loaderData: useLoaderData(),
9897
- actionData: useActionData()
9898
- };
9899
- return React13.createElement(HydrateFallback, props);
9900
- };
9901
- }
9902
- function withErrorBoundaryProps(ErrorBoundary) {
9903
- return function Wrapped() {
9904
- const props = {
9905
- params: useParams(),
9906
- loaderData: useLoaderData(),
9907
- actionData: useActionData(),
9908
- error: useRouteError()
9909
- };
9910
- return React13.createElement(ErrorBoundary, props);
9911
- };
9912
- }
9913
9914
  function processRoutes(routes, manifest, routeModules, parentId) {
9914
9915
  return routes.map((route) => {
9915
9916
  if (!route.id) {
@@ -10428,6 +10429,13 @@ function createServerHandoffString(serverHandoff) {
10428
10429
  // lib/server-runtime/headers.ts
10429
10430
  import { splitCookiesString } from "set-cookie-parser";
10430
10431
  function getDocumentHeaders(build, context) {
10432
+ return getDocumentHeadersImpl(context, (m) => {
10433
+ let route = build.routes[m.route.id];
10434
+ invariant3(route, `Route with id "${m.route.id}" not found in build`);
10435
+ return route.module.headers;
10436
+ });
10437
+ }
10438
+ function getDocumentHeadersImpl(context, getRouteHeadersFn) {
10431
10439
  let boundaryIdx = context.errors ? context.matches.findIndex((m) => context.errors[m.route.id]) : -1;
10432
10440
  let matches = boundaryIdx >= 0 ? context.matches.slice(0, boundaryIdx + 1) : context.matches;
10433
10441
  let errorHeaders;
@@ -10445,14 +10453,12 @@ function getDocumentHeaders(build, context) {
10445
10453
  }
10446
10454
  return matches.reduce((parentHeaders, match, idx) => {
10447
10455
  let { id } = match.route;
10448
- let route = build.routes[id];
10449
- invariant3(route, `Route with id "${id}" not found in build`);
10450
- let routeModule = route.module;
10451
10456
  let loaderHeaders = context.loaderHeaders[id] || new Headers();
10452
10457
  let actionHeaders = context.actionHeaders[id] || new Headers();
10453
10458
  let includeErrorHeaders = errorHeaders != null && idx === matches.length - 1;
10454
10459
  let includeErrorCookies = includeErrorHeaders && errorHeaders !== loaderHeaders && errorHeaders !== actionHeaders;
10455
- if (routeModule.headers == null) {
10460
+ let headersFn = getRouteHeadersFn(match);
10461
+ if (headersFn == null) {
10456
10462
  let headers2 = new Headers(parentHeaders);
10457
10463
  if (includeErrorCookies) {
10458
10464
  prependCookies(errorHeaders, headers2);
@@ -10462,12 +10468,12 @@ function getDocumentHeaders(build, context) {
10462
10468
  return headers2;
10463
10469
  }
10464
10470
  let headers = new Headers(
10465
- routeModule.headers ? typeof routeModule.headers === "function" ? routeModule.headers({
10471
+ typeof headersFn === "function" ? headersFn({
10466
10472
  loaderHeaders,
10467
10473
  parentHeaders,
10468
10474
  actionHeaders,
10469
10475
  errorHeaders: includeErrorHeaders ? errorHeaders : void 0
10470
- }) : routeModule.headers : void 0
10476
+ }) : headersFn
10471
10477
  );
10472
10478
  if (includeErrorCookies) {
10473
10479
  prependCookies(errorHeaders, headers);
@@ -11509,6 +11515,9 @@ export {
11509
11515
  createRoutesFromChildren,
11510
11516
  createRoutesFromElements,
11511
11517
  renderMatches,
11518
+ withComponentProps,
11519
+ withHydrateFallbackProps,
11520
+ withErrorBoundaryProps,
11512
11521
  createSearchParams,
11513
11522
  SingleFetchRedirectSymbol,
11514
11523
  getTurboStreamSingleFetchDataStrategy,
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { R as RouterProviderProps$1 } from './lib-B8x_tOvL.mjs';
3
- import { R as RouterInit } from './route-data-WyrduLgj.mjs';
2
+ import { R as RouterProviderProps$1 } from './lib-C1JSsICm.mjs';
3
+ import { R as RouterInit } from './route-data-ByAYLHuM.mjs';
4
4
 
5
5
  type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
6
6
  declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.6.1-pre.2
2
+ * react-router v7.6.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.6.1-pre.2
2
+ * react-router v7.6.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -25,7 +25,7 @@ import {
25
25
  invariant,
26
26
  mapRouteProperties,
27
27
  useFogOFWarDiscovery
28
- } from "./chunk-H4Y5ODCL.mjs";
28
+ } from "./chunk-NL6KNZEE.mjs";
29
29
 
30
30
  // lib/dom-export/dom-router-provider.tsx
31
31
  import * as React from "react";