react-router 7.7.0-pre.1 → 7.7.0-pre.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 (58) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/development/{browser-BSrXyLft.d.mts → browser-CcxeZJcQ.d.mts} +3 -30
  3. package/dist/development/{chunk-Z7T4GLA7.js → chunk-3JI27NJZ.js} +1 -1
  4. package/dist/{production/chunk-KZZC37RO.mjs → development/chunk-NMPYIXDO.mjs} +31 -26
  5. package/dist/development/{chunk-YNUF36W5.mjs → chunk-XPO7SIPX.mjs} +52 -22
  6. package/dist/development/{chunk-6ZHKKNZG.js → chunk-XUCF2MWW.js} +170 -140
  7. package/dist/development/components-DzqPLVI1.d.mts +464 -0
  8. package/dist/development/dom-export.d.mts +3 -3
  9. package/dist/development/dom-export.js +3 -3
  10. package/dist/development/dom-export.mjs +3 -3
  11. package/dist/{production/index-react-server-client-DOK8MfYF.d.mts → development/index-react-server-client-CUidsuu_.d.mts} +2 -2
  12. package/dist/development/{index-react-server-client-LrDNRnlX.d.ts → index-react-server-client-kY8DvDF3.d.ts} +177 -529
  13. package/dist/development/index-react-server-client.d.mts +3 -3
  14. package/dist/development/index-react-server-client.d.ts +2 -2
  15. package/dist/development/index-react-server-client.js +10 -4
  16. package/dist/development/index-react-server-client.mjs +9 -3
  17. package/dist/development/index-react-server.js +20 -6
  18. package/dist/development/index-react-server.mjs +21 -6
  19. package/dist/development/index.d.mts +396 -9
  20. package/dist/development/index.d.ts +372 -12
  21. package/dist/development/index.js +131 -120
  22. package/dist/development/index.mjs +9 -3
  23. package/dist/development/lib/types/internal.d.mts +1 -1
  24. package/dist/development/lib/types/internal.d.ts +1 -1
  25. package/dist/development/lib/types/internal.js +1 -1
  26. package/dist/development/lib/types/internal.mjs +1 -1
  27. package/dist/{production/route-data-DAw7Esur.d.mts → development/route-data-DjzmHYNR.d.mts} +1 -1
  28. package/dist/{production/route-data-7aXBQ4I3.d.ts → development/routeModules-g5PTiDfO.d.ts} +156 -156
  29. package/dist/production/{browser-BSrXyLft.d.mts → browser-CcxeZJcQ.d.mts} +3 -30
  30. package/dist/production/{chunk-W77PDD2Y.js → chunk-CLUOEFXR.js} +170 -140
  31. package/dist/production/{chunk-SH44XSL4.js → chunk-LW7Q6L7E.js} +1 -1
  32. package/dist/{development/chunk-YP7CIEHK.mjs → production/chunk-RXNLZWLS.mjs} +31 -26
  33. package/dist/production/{chunk-4FKAWASN.mjs → chunk-V7D4RPWA.mjs} +52 -22
  34. package/dist/production/components-DzqPLVI1.d.mts +464 -0
  35. package/dist/production/dom-export.d.mts +3 -3
  36. package/dist/production/dom-export.js +3 -3
  37. package/dist/production/dom-export.mjs +3 -3
  38. package/dist/{development/index-react-server-client-DOK8MfYF.d.mts → production/index-react-server-client-CUidsuu_.d.mts} +2 -2
  39. package/dist/production/{index-react-server-client-LrDNRnlX.d.ts → index-react-server-client-kY8DvDF3.d.ts} +177 -529
  40. package/dist/production/index-react-server-client.d.mts +3 -3
  41. package/dist/production/index-react-server-client.d.ts +2 -2
  42. package/dist/production/index-react-server-client.js +10 -4
  43. package/dist/production/index-react-server-client.mjs +9 -3
  44. package/dist/production/index-react-server.js +20 -6
  45. package/dist/production/index-react-server.mjs +21 -6
  46. package/dist/production/index.d.mts +396 -9
  47. package/dist/production/index.d.ts +372 -12
  48. package/dist/production/index.js +131 -120
  49. package/dist/production/index.mjs +9 -3
  50. package/dist/production/lib/types/internal.d.mts +1 -1
  51. package/dist/production/lib/types/internal.d.ts +1 -1
  52. package/dist/production/lib/types/internal.js +1 -1
  53. package/dist/production/lib/types/internal.mjs +1 -1
  54. package/dist/{development/route-data-DAw7Esur.d.mts → production/route-data-DjzmHYNR.d.mts} +1 -1
  55. package/dist/{development/route-data-7aXBQ4I3.d.ts → production/routeModules-g5PTiDfO.d.ts} +156 -156
  56. package/package.json +1 -1
  57. package/dist/development/components-IaVqGBuO.d.mts +0 -816
  58. package/dist/production/components-IaVqGBuO.d.mts +0 -816
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # `react-router`
2
2
 
3
+ ## 7.7.0-pre.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [REMOVE] Inject client route component props during RSC render ([#14007](https://github.com/remix-run/react-router/pull/14007))
8
+
3
9
  ## 7.7.0-pre.1
4
10
 
5
11
  ### Patch Changes
@@ -1,6 +1,6 @@
1
- import * as React from 'react';
2
- import { u as unstable_RouterContextProvider, p as ActionFunction, C as ClientActionFunction, q as ClientLoaderFunction, r as HeadersFunction, s as LinksFunction, t as LoaderFunction, M as MetaFunction, v as ShouldRevalidateFunction, L as Location, g as Params, h as Router, R as RouterInit } from './route-data-DAw7Esur.mjs';
3
1
  import { AsyncLocalStorage } from 'node:async_hooks';
2
+ import * as React from 'react';
3
+ import { u as unstable_RouterContextProvider, i as ActionFunction, C as ClientActionFunction, j as ClientLoaderFunction, k as HeadersFunction, l as LinksFunction, m as LoaderFunction, M as MetaFunction, S as ShouldRevalidateFunction, c as Location, h as Params } from './route-data-DjzmHYNR.mjs';
4
4
 
5
5
  type ServerContext = {
6
6
  redirect?: Response;
@@ -120,33 +120,6 @@ declare function matchRSCServerRequest({ createTemporaryReferenceSet, basename,
120
120
  }) => Response;
121
121
  }): Promise<Response>;
122
122
 
123
- type BrowserCreateFromReadableStreamFunction = (body: ReadableStream<Uint8Array>, { temporaryReferences, }: {
124
- temporaryReferences: unknown;
125
- }) => Promise<unknown>;
126
- type EncodeReplyFunction = (args: unknown[], options: {
127
- temporaryReferences: unknown;
128
- }) => Promise<BodyInit>;
129
- declare global {
130
- interface Window {
131
- __router: Router;
132
- __routerInitialized: boolean;
133
- __routerActionID: number;
134
- }
135
- }
136
- declare function createCallServer({ createFromReadableStream, createTemporaryReferenceSet, encodeReply, fetch: fetchImplementation, }: {
137
- createFromReadableStream: BrowserCreateFromReadableStreamFunction;
138
- createTemporaryReferenceSet: () => unknown;
139
- encodeReply: EncodeReplyFunction;
140
- fetch?: (request: Request) => Promise<Response>;
141
- }): (id: string, args: unknown[]) => Promise<unknown>;
142
- declare function RSCHydratedRouter({ createFromReadableStream, fetch: fetchImplementation, payload, routeDiscovery, unstable_getContext, }: {
143
- createFromReadableStream: BrowserCreateFromReadableStreamFunction;
144
- fetch?: (request: Request) => Promise<Response>;
145
- payload: RSCPayload;
146
- routeDiscovery?: "eager" | "lazy";
147
- unstable_getContext?: RouterInit["unstable_getContext"];
148
- }): React.JSX.Element;
149
-
150
123
  declare global {
151
124
  interface Window {
152
125
  __FLIGHT_DATA: any[];
@@ -154,4 +127,4 @@ declare global {
154
127
  }
155
128
  declare function getRSCStream(): ReadableStream<any>;
156
129
 
157
- export { type BrowserCreateFromReadableStreamFunction as B, type DecodeActionFunction as D, type EncodeReplyFunction as E, type LoadServerActionFunction as L, type RSCPayload as R, RSCHydratedRouter as a, type DecodeFormStateFunction as b, createCallServer as c, type DecodeReplyFunction as d, type RSCManifestPayload as e, type RSCMatch as f, getRSCStream as g, type RSCRenderPayload as h, type RSCRouteManifest as i, type RSCRouteMatch as j, type RSCRouteConfigEntry as k, type RSCRouteConfig as l, matchRSCServerRequest as m };
130
+ export { type DecodeActionFunction as D, type LoadServerActionFunction as L, type RSCPayload as R, type DecodeFormStateFunction as a, type DecodeReplyFunction as b, type RSCManifestPayload as c, type RSCMatch as d, type RSCRenderPayload as e, type RSCRouteManifest as f, getRSCStream as g, type RSCRouteMatch as h, type RSCRouteConfigEntry as i, type RSCRouteConfig as j, matchRSCServerRequest as m };
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
2
- * react-router v7.7.0-pre.1
2
+ * react-router v7.7.0-pre.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.7.0-pre.1
2
+ * react-router v7.7.0-pre.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -57,7 +57,7 @@ import {
57
57
  withComponentProps,
58
58
  withErrorBoundaryProps,
59
59
  withHydrateFallbackProps
60
- } from "./chunk-4FKAWASN.mjs";
60
+ } from "./chunk-XPO7SIPX.mjs";
61
61
 
62
62
  // lib/dom/ssr/server.tsx
63
63
  import * as React from "react";
@@ -1805,9 +1805,10 @@ function createCallServer({
1805
1805
  encodeReply,
1806
1806
  fetch: fetchImplementation = fetch
1807
1807
  }) {
1808
+ const globalVar = window;
1808
1809
  let landedActionId = 0;
1809
1810
  return async (id, args) => {
1810
- let actionId = window.__routerActionID = (window.__routerActionID ?? (window.__routerActionID = 0)) + 1;
1811
+ let actionId = globalVar.__routerActionID = (globalVar.__routerActionID ?? (globalVar.__routerActionID = 0)) + 1;
1811
1812
  const temporaryReferences = createTemporaryReferenceSet();
1812
1813
  const response = await fetchImplementation(
1813
1814
  new Request(location.href, {
@@ -1830,7 +1831,7 @@ function createCallServer({
1830
1831
  window.location.href = payload.location;
1831
1832
  return;
1832
1833
  }
1833
- window.__router.navigate(payload.location, {
1834
+ globalVar.__router.navigate(payload.location, {
1834
1835
  replace: payload.replace
1835
1836
  });
1836
1837
  return payload.actionResult;
@@ -1844,21 +1845,21 @@ function createCallServer({
1844
1845
  async () => {
1845
1846
  const rerender = await payload.rerender;
1846
1847
  if (!rerender) return;
1847
- if (landedActionId < actionId && window.__routerActionID <= actionId) {
1848
+ if (landedActionId < actionId && globalVar.__routerActionID <= actionId) {
1848
1849
  landedActionId = actionId;
1849
1850
  if (rerender.type === "redirect") {
1850
1851
  if (rerender.reload) {
1851
1852
  window.location.href = rerender.location;
1852
1853
  return;
1853
1854
  }
1854
- window.__router.navigate(rerender.location, {
1855
+ globalVar.__router.navigate(rerender.location, {
1855
1856
  replace: rerender.replace
1856
1857
  });
1857
1858
  return;
1858
1859
  }
1859
1860
  let lastMatch;
1860
1861
  for (const match of rerender.matches) {
1861
- window.__router.patchRoutes(
1862
+ globalVar.__router.patchRoutes(
1862
1863
  lastMatch?.id ?? null,
1863
1864
  [createRouteFromServerManifest(match)],
1864
1865
  true
@@ -1870,12 +1871,12 @@ function createCallServer({
1870
1871
  window.__router._internalSetStateDoNotUseOrYouWillBreakYourApp({
1871
1872
  loaderData: Object.assign(
1872
1873
  {},
1873
- window.__router.state.loaderData,
1874
+ globalVar.__router.state.loaderData,
1874
1875
  rerender.loaderData
1875
1876
  ),
1876
1877
  errors: rerender.errors ? Object.assign(
1877
1878
  {},
1878
- window.__router.state.errors,
1879
+ globalVar.__router.state.errors,
1879
1880
  rerender.errors
1880
1881
  ) : null
1881
1882
  });
@@ -1893,7 +1894,8 @@ function createRouterFromPayload({
1893
1894
  unstable_getContext,
1894
1895
  payload
1895
1896
  }) {
1896
- if (window.__router) return window.__router;
1897
+ const globalVar = window;
1898
+ if (globalVar.__router) return globalVar.__router;
1897
1899
  if (payload.type !== "render") throw new Error("Invalid payload type");
1898
1900
  let patches = /* @__PURE__ */ new Map();
1899
1901
  payload.patches?.forEach((patch) => {
@@ -1919,7 +1921,7 @@ function createRouterFromPayload({
1919
1921
  }
1920
1922
  return [route];
1921
1923
  }, []);
1922
- window.__router = createRouter({
1924
+ globalVar.__router = createRouter({
1923
1925
  routes,
1924
1926
  unstable_getContext,
1925
1927
  basename: payload.basename,
@@ -1957,26 +1959,26 @@ function createRouterFromPayload({
1957
1959
  },
1958
1960
  // FIXME: Pass `build.ssr` into this function
1959
1961
  dataStrategy: getRSCSingleFetchDataStrategy(
1960
- () => window.__router,
1962
+ () => globalVar.__router,
1961
1963
  true,
1962
1964
  payload.basename,
1963
1965
  createFromReadableStream,
1964
1966
  fetchImplementation
1965
1967
  )
1966
1968
  });
1967
- if (window.__router.state.initialized) {
1968
- window.__routerInitialized = true;
1969
- window.__router.initialize();
1969
+ if (globalVar.__router.state.initialized) {
1970
+ globalVar.__routerInitialized = true;
1971
+ globalVar.__router.initialize();
1970
1972
  } else {
1971
- window.__routerInitialized = false;
1973
+ globalVar.__routerInitialized = false;
1972
1974
  }
1973
1975
  let lastLoaderData = void 0;
1974
- window.__router.subscribe(({ loaderData, actionData }) => {
1976
+ globalVar.__router.subscribe(({ loaderData, actionData }) => {
1975
1977
  if (lastLoaderData !== loaderData) {
1976
- window.__routerActionID = (window.__routerActionID ?? (window.__routerActionID = 0)) + 1;
1978
+ globalVar.__routerActionID = (globalVar.__routerActionID ?? (globalVar.__routerActionID = 0)) + 1;
1977
1979
  }
1978
1980
  });
1979
- return window.__router;
1981
+ return globalVar.__router;
1980
1982
  }
1981
1983
  var renderedRoutesContext = unstable_createContext();
1982
1984
  function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, createFromReadableStream, fetchImplementation) {
@@ -2109,9 +2111,10 @@ function RSCHydratedRouter({
2109
2111
  ]
2110
2112
  );
2111
2113
  React4.useLayoutEffect(() => {
2112
- if (!window.__routerInitialized) {
2113
- window.__routerInitialized = true;
2114
- window.__router.initialize();
2114
+ const globalVar = window;
2115
+ if (!globalVar.__routerInitialized) {
2116
+ globalVar.__routerInitialized = true;
2117
+ globalVar.__router.initialize();
2115
2118
  }
2116
2119
  }, []);
2117
2120
  let [location2, setLocation] = React4.useState(router.state.location);
@@ -2297,7 +2300,8 @@ function getManifestUrl(paths) {
2297
2300
  if (paths.length === 1) {
2298
2301
  return new URL(`${paths[0]}.manifest`, window.location.origin);
2299
2302
  }
2300
- let basename = (window.__router.basename ?? "").replace(/^\/|\/$/g, "");
2303
+ const globalVar = window;
2304
+ let basename = (globalVar.__router.basename ?? "").replace(/^\/|\/$/g, "");
2301
2305
  let url = new URL(`${basename}/.manifest`, window.location.origin);
2302
2306
  paths.sort().forEach((path) => url.searchParams.append("p", path));
2303
2307
  return url;
@@ -2323,9 +2327,10 @@ async function fetchAndApplyManifestPatches(paths, createFromReadableStream, fet
2323
2327
  }
2324
2328
  paths.forEach((p) => addToFifoQueue(p, discoveredPaths));
2325
2329
  payload.patches.forEach((p) => {
2326
- window.__router.patchRoutes(p.parentId ?? null, [
2327
- createRouteFromServerManifest(p)
2328
- ]);
2330
+ window.__router.patchRoutes(
2331
+ p.parentId ?? null,
2332
+ [createRouteFromServerManifest(p)]
2333
+ );
2329
2334
  });
2330
2335
  }
2331
2336
  function addToFifoQueue(path, queue) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.7.0-pre.1
2
+ * react-router v7.7.0-pre.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -5993,35 +5993,62 @@ var createRoutesFromElements = createRoutesFromChildren;
5993
5993
  function renderMatches(matches) {
5994
5994
  return _renderMatches(matches);
5995
5995
  }
5996
+ function useRouteComponentProps() {
5997
+ return {
5998
+ params: useParams(),
5999
+ loaderData: useLoaderData(),
6000
+ actionData: useActionData(),
6001
+ matches: useMatches()
6002
+ };
6003
+ }
6004
+ function WithComponentProps({
6005
+ children
6006
+ }) {
6007
+ const props = useRouteComponentProps();
6008
+ return React3.cloneElement(children, props);
6009
+ }
5996
6010
  function withComponentProps(Component4) {
5997
- return function WithComponentProps() {
5998
- const props = {
5999
- params: useParams(),
6000
- loaderData: useLoaderData(),
6001
- actionData: useActionData(),
6002
- matches: useMatches()
6003
- };
6011
+ return function WithComponentProps2() {
6012
+ const props = useRouteComponentProps();
6004
6013
  return React3.createElement(Component4, props);
6005
6014
  };
6006
6015
  }
6016
+ function useHydrateFallbackProps() {
6017
+ return {
6018
+ params: useParams(),
6019
+ loaderData: useLoaderData(),
6020
+ actionData: useActionData()
6021
+ };
6022
+ }
6023
+ function WithHydrateFallbackProps({
6024
+ children
6025
+ }) {
6026
+ const props = useHydrateFallbackProps();
6027
+ return React3.cloneElement(children, props);
6028
+ }
6007
6029
  function withHydrateFallbackProps(HydrateFallback) {
6008
- return function WithHydrateFallbackProps() {
6009
- const props = {
6010
- params: useParams(),
6011
- loaderData: useLoaderData(),
6012
- actionData: useActionData()
6013
- };
6030
+ return function WithHydrateFallbackProps2() {
6031
+ const props = useHydrateFallbackProps();
6014
6032
  return React3.createElement(HydrateFallback, props);
6015
6033
  };
6016
6034
  }
6035
+ function useErrorBoundaryProps() {
6036
+ return {
6037
+ params: useParams(),
6038
+ loaderData: useLoaderData(),
6039
+ actionData: useActionData(),
6040
+ error: useRouteError()
6041
+ };
6042
+ }
6043
+ function WithErrorBoundaryProps({
6044
+ children
6045
+ }) {
6046
+ const props = useErrorBoundaryProps();
6047
+ return React3.cloneElement(children, props);
6048
+ }
6017
6049
  function withErrorBoundaryProps(ErrorBoundary) {
6018
- return function WithErrorBoundaryProps() {
6019
- const props = {
6020
- params: useParams(),
6021
- loaderData: useLoaderData(),
6022
- actionData: useActionData(),
6023
- error: useRouteError()
6024
- };
6050
+ return function WithErrorBoundaryProps2() {
6051
+ const props = useErrorBoundaryProps();
6025
6052
  return React3.createElement(ErrorBoundary, props);
6026
6053
  };
6027
6054
  }
@@ -8815,7 +8842,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
8815
8842
  try {
8816
8843
  if (isBrowser) {
8817
8844
  window.__reactRouterVersion = // @ts-expect-error
8818
- "7.7.0-pre.1";
8845
+ "7.7.0-pre.2";
8819
8846
  }
8820
8847
  } catch (e) {
8821
8848
  }
@@ -9982,8 +10009,11 @@ export {
9982
10009
  createRoutesFromChildren,
9983
10010
  createRoutesFromElements,
9984
10011
  renderMatches,
10012
+ WithComponentProps,
9985
10013
  withComponentProps,
10014
+ WithHydrateFallbackProps,
9986
10015
  withHydrateFallbackProps,
10016
+ WithErrorBoundaryProps,
9987
10017
  withErrorBoundaryProps,
9988
10018
  createSearchParams,
9989
10019
  encode,