react-router 0.0.0-experimental-d4ee0faac → 0.0.0-experimental-80dc2f07b

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 (70) hide show
  1. package/CHANGELOG.md +13 -29
  2. package/dist/development/browser-DO9ukXOW.d.mts +226 -0
  3. package/dist/development/{chunk-AXZ7XWJM.mjs → chunk-FRVKHHSP.mjs} +138 -104
  4. package/dist/development/{chunk-TYXIL3CH.js → chunk-KW2YDZG2.js} +172 -142
  5. package/dist/development/{chunk-BYMLG5RB.js → chunk-QIEB5IKV.js} +84 -80
  6. package/dist/{production/chunk-SSVNUOFF.mjs → development/chunk-ZDIHB6MN.mjs} +32 -29
  7. package/dist/development/components-kfi-pq4A.d.mts +802 -0
  8. package/dist/development/dom-export.d.mts +13 -6
  9. package/dist/development/dom-export.d.ts +10 -3
  10. package/dist/development/dom-export.js +3 -3
  11. package/dist/development/dom-export.mjs +3 -3
  12. package/dist/development/index-react-server-client-C4nRtAah.d.ts +3178 -0
  13. package/dist/development/index-react-server-client-DWt5PSS7.d.mts +2381 -0
  14. package/dist/development/index-react-server-client.d.mts +3 -3
  15. package/dist/development/index-react-server-client.d.ts +2 -2
  16. package/dist/development/index-react-server-client.js +10 -4
  17. package/dist/development/index-react-server-client.mjs +9 -3
  18. package/dist/development/index-react-server.d.mts +115 -2
  19. package/dist/development/index-react-server.d.ts +115 -2
  20. package/dist/development/index-react-server.js +44 -22
  21. package/dist/development/index-react-server.mjs +45 -22
  22. package/dist/development/index.d.mts +1033 -15
  23. package/dist/development/index.d.ts +1107 -20
  24. package/dist/development/index.js +132 -123
  25. package/dist/development/index.mjs +9 -3
  26. package/dist/development/lib/types/internal.d.mts +1 -1
  27. package/dist/development/lib/types/internal.d.ts +1 -1
  28. package/dist/development/lib/types/internal.js +1 -1
  29. package/dist/development/lib/types/internal.mjs +1 -1
  30. package/dist/{production/route-data-DAw7Esur.d.mts → development/route-data-Dccdkjzt.d.mts} +55 -3
  31. package/dist/development/{route-data-7aXBQ4I3.d.ts → routeModules-ePxkpnOJ.d.ts} +210 -158
  32. package/dist/production/browser-DO9ukXOW.d.mts +226 -0
  33. package/dist/production/{chunk-XHN2I73S.js → chunk-BJQSOW5M.js} +84 -80
  34. package/dist/production/{chunk-EATVYSE3.js → chunk-IMCXOMKU.js} +172 -142
  35. package/dist/{development/chunk-ECP3BYMQ.mjs → production/chunk-NUPZJCEO.mjs} +32 -29
  36. package/dist/production/{chunk-RB7EVRHX.mjs → chunk-VQ4KM56U.mjs} +138 -104
  37. package/dist/production/components-kfi-pq4A.d.mts +802 -0
  38. package/dist/production/dom-export.d.mts +13 -6
  39. package/dist/production/dom-export.d.ts +10 -3
  40. package/dist/production/dom-export.js +3 -3
  41. package/dist/production/dom-export.mjs +3 -3
  42. package/dist/production/index-react-server-client-C4nRtAah.d.ts +3178 -0
  43. package/dist/production/index-react-server-client-DWt5PSS7.d.mts +2381 -0
  44. package/dist/production/index-react-server-client.d.mts +3 -3
  45. package/dist/production/index-react-server-client.d.ts +2 -2
  46. package/dist/production/index-react-server-client.js +10 -4
  47. package/dist/production/index-react-server-client.mjs +9 -3
  48. package/dist/production/index-react-server.d.mts +115 -2
  49. package/dist/production/index-react-server.d.ts +115 -2
  50. package/dist/production/index-react-server.js +44 -22
  51. package/dist/production/index-react-server.mjs +45 -22
  52. package/dist/production/index.d.mts +1033 -15
  53. package/dist/production/index.d.ts +1107 -20
  54. package/dist/production/index.js +132 -123
  55. package/dist/production/index.mjs +9 -3
  56. package/dist/production/lib/types/internal.d.mts +1 -1
  57. package/dist/production/lib/types/internal.d.ts +1 -1
  58. package/dist/production/lib/types/internal.js +1 -1
  59. package/dist/production/lib/types/internal.mjs +1 -1
  60. package/dist/{development/route-data-DAw7Esur.d.mts → production/route-data-Dccdkjzt.d.mts} +55 -3
  61. package/dist/production/{route-data-7aXBQ4I3.d.ts → routeModules-ePxkpnOJ.d.ts} +210 -158
  62. package/package.json +1 -1
  63. package/dist/development/browser-BSrXyLft.d.mts +0 -157
  64. package/dist/development/components-IaVqGBuO.d.mts +0 -816
  65. package/dist/development/index-react-server-client-DOK8MfYF.d.mts +0 -1360
  66. package/dist/development/index-react-server-client-LrDNRnlX.d.ts +0 -2171
  67. package/dist/production/browser-BSrXyLft.d.mts +0 -157
  68. package/dist/production/components-IaVqGBuO.d.mts +0 -816
  69. package/dist/production/index-react-server-client-DOK8MfYF.d.mts +0 -1360
  70. package/dist/production/index-react-server-client-LrDNRnlX.d.ts +0 -2171
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-d4ee0faac
2
+ * react-router v0.0.0-experimental-80dc2f07b
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -2305,9 +2305,7 @@ function createRouter(init) {
2305
2305
  )
2306
2306
  };
2307
2307
  } else {
2308
- dataResults[routeId] = await convertDataStrategyResultToDataResult(
2309
- result
2310
- );
2308
+ dataResults[routeId] = await convertDataStrategyResultToDataResult(result);
2311
2309
  }
2312
2310
  }
2313
2311
  return dataResults;
@@ -4163,7 +4161,10 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
4163
4161
  });
4164
4162
  try {
4165
4163
  await Promise.all(
4166
- matches.flatMap((m) => [m._lazyPromises?.handler, m._lazyPromises?.route])
4164
+ matches.flatMap((m) => [
4165
+ m._lazyPromises?.handler,
4166
+ m._lazyPromises?.route
4167
+ ])
4167
4168
  );
4168
4169
  } catch (e) {
4169
4170
  }
@@ -5233,68 +5234,71 @@ function _renderMatches(matches, parentMatches = [], dataRouterState = null, fut
5233
5234
  }
5234
5235
  }
5235
5236
  }
5236
- return renderedMatches.reduceRight((outlet, match, index) => {
5237
- let error;
5238
- let shouldRenderHydrateFallback = false;
5239
- let errorElement = null;
5240
- let hydrateFallbackElement = null;
5241
- if (dataRouterState) {
5242
- error = errors && match.route.id ? errors[match.route.id] : void 0;
5243
- errorElement = match.route.errorElement || defaultErrorElement;
5244
- if (renderFallback) {
5245
- if (fallbackIndex < 0 && index === 0) {
5246
- warningOnce(
5247
- "route-fallback",
5248
- false,
5249
- "No `HydrateFallback` element provided to render during initial hydration"
5250
- );
5251
- shouldRenderHydrateFallback = true;
5252
- hydrateFallbackElement = null;
5253
- } else if (fallbackIndex === index) {
5254
- shouldRenderHydrateFallback = true;
5255
- hydrateFallbackElement = match.route.hydrateFallbackElement || null;
5237
+ return renderedMatches.reduceRight(
5238
+ (outlet, match, index) => {
5239
+ let error;
5240
+ let shouldRenderHydrateFallback = false;
5241
+ let errorElement = null;
5242
+ let hydrateFallbackElement = null;
5243
+ if (dataRouterState) {
5244
+ error = errors && match.route.id ? errors[match.route.id] : void 0;
5245
+ errorElement = match.route.errorElement || defaultErrorElement;
5246
+ if (renderFallback) {
5247
+ if (fallbackIndex < 0 && index === 0) {
5248
+ warningOnce(
5249
+ "route-fallback",
5250
+ false,
5251
+ "No `HydrateFallback` element provided to render during initial hydration"
5252
+ );
5253
+ shouldRenderHydrateFallback = true;
5254
+ hydrateFallbackElement = null;
5255
+ } else if (fallbackIndex === index) {
5256
+ shouldRenderHydrateFallback = true;
5257
+ hydrateFallbackElement = match.route.hydrateFallbackElement || null;
5258
+ }
5256
5259
  }
5257
5260
  }
5258
- }
5259
- let matches2 = parentMatches.concat(renderedMatches.slice(0, index + 1));
5260
- let getChildren = () => {
5261
- let children;
5262
- if (error) {
5263
- children = errorElement;
5264
- } else if (shouldRenderHydrateFallback) {
5265
- children = hydrateFallbackElement;
5266
- } else if (match.route.Component) {
5267
- children = /* @__PURE__ */ React2.createElement(match.route.Component, null);
5268
- } else if (match.route.element) {
5269
- children = match.route.element;
5270
- } else {
5271
- children = outlet;
5272
- }
5273
- return /* @__PURE__ */ React2.createElement(
5274
- RenderedRoute,
5261
+ let matches2 = parentMatches.concat(renderedMatches.slice(0, index + 1));
5262
+ let getChildren = () => {
5263
+ let children;
5264
+ if (error) {
5265
+ children = errorElement;
5266
+ } else if (shouldRenderHydrateFallback) {
5267
+ children = hydrateFallbackElement;
5268
+ } else if (match.route.Component) {
5269
+ children = /* @__PURE__ */ React2.createElement(match.route.Component, null);
5270
+ } else if (match.route.element) {
5271
+ children = match.route.element;
5272
+ } else {
5273
+ children = outlet;
5274
+ }
5275
+ return /* @__PURE__ */ React2.createElement(
5276
+ RenderedRoute,
5277
+ {
5278
+ match,
5279
+ routeContext: {
5280
+ outlet,
5281
+ matches: matches2,
5282
+ isDataRoute: dataRouterState != null
5283
+ },
5284
+ children
5285
+ }
5286
+ );
5287
+ };
5288
+ return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /* @__PURE__ */ React2.createElement(
5289
+ RenderErrorBoundary,
5275
5290
  {
5276
- match,
5277
- routeContext: {
5278
- outlet,
5279
- matches: matches2,
5280
- isDataRoute: dataRouterState != null
5281
- },
5282
- children
5291
+ location: dataRouterState.location,
5292
+ revalidation: dataRouterState.revalidation,
5293
+ component: errorElement,
5294
+ error,
5295
+ children: getChildren(),
5296
+ routeContext: { outlet: null, matches: matches2, isDataRoute: true }
5283
5297
  }
5284
- );
5285
- };
5286
- return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /* @__PURE__ */ React2.createElement(
5287
- RenderErrorBoundary,
5288
- {
5289
- location: dataRouterState.location,
5290
- revalidation: dataRouterState.revalidation,
5291
- component: errorElement,
5292
- error,
5293
- children: getChildren(),
5294
- routeContext: { outlet: null, matches: matches2, isDataRoute: true }
5295
- }
5296
- ) : getChildren();
5297
- }, null);
5298
+ ) : getChildren();
5299
+ },
5300
+ null
5301
+ );
5298
5302
  }
5299
5303
  function getDataRouterConsoleError(hookName) {
5300
5304
  return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
@@ -5802,7 +5806,7 @@ function Navigate({
5802
5806
  function Outlet(props) {
5803
5807
  return useOutlet(props.context);
5804
5808
  }
5805
- function Route(_props) {
5809
+ function Route(props) {
5806
5810
  invariant(
5807
5811
  false,
5808
5812
  `A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`
@@ -5993,35 +5997,62 @@ var createRoutesFromElements = createRoutesFromChildren;
5993
5997
  function renderMatches(matches) {
5994
5998
  return _renderMatches(matches);
5995
5999
  }
6000
+ function useRouteComponentProps() {
6001
+ return {
6002
+ params: useParams(),
6003
+ loaderData: useLoaderData(),
6004
+ actionData: useActionData(),
6005
+ matches: useMatches()
6006
+ };
6007
+ }
6008
+ function WithComponentProps({
6009
+ children
6010
+ }) {
6011
+ const props = useRouteComponentProps();
6012
+ return React3.cloneElement(children, props);
6013
+ }
5996
6014
  function withComponentProps(Component4) {
5997
- return function WithComponentProps() {
5998
- const props = {
5999
- params: useParams(),
6000
- loaderData: useLoaderData(),
6001
- actionData: useActionData(),
6002
- matches: useMatches()
6003
- };
6015
+ return function WithComponentProps2() {
6016
+ const props = useRouteComponentProps();
6004
6017
  return React3.createElement(Component4, props);
6005
6018
  };
6006
6019
  }
6020
+ function useHydrateFallbackProps() {
6021
+ return {
6022
+ params: useParams(),
6023
+ loaderData: useLoaderData(),
6024
+ actionData: useActionData()
6025
+ };
6026
+ }
6027
+ function WithHydrateFallbackProps({
6028
+ children
6029
+ }) {
6030
+ const props = useHydrateFallbackProps();
6031
+ return React3.cloneElement(children, props);
6032
+ }
6007
6033
  function withHydrateFallbackProps(HydrateFallback) {
6008
- return function WithHydrateFallbackProps() {
6009
- const props = {
6010
- params: useParams(),
6011
- loaderData: useLoaderData(),
6012
- actionData: useActionData()
6013
- };
6034
+ return function WithHydrateFallbackProps2() {
6035
+ const props = useHydrateFallbackProps();
6014
6036
  return React3.createElement(HydrateFallback, props);
6015
6037
  };
6016
6038
  }
6039
+ function useErrorBoundaryProps() {
6040
+ return {
6041
+ params: useParams(),
6042
+ loaderData: useLoaderData(),
6043
+ actionData: useActionData(),
6044
+ error: useRouteError()
6045
+ };
6046
+ }
6047
+ function WithErrorBoundaryProps({
6048
+ children
6049
+ }) {
6050
+ const props = useErrorBoundaryProps();
6051
+ return React3.cloneElement(children, props);
6052
+ }
6017
6053
  function withErrorBoundaryProps(ErrorBoundary) {
6018
- return function WithErrorBoundaryProps() {
6019
- const props = {
6020
- params: useParams(),
6021
- loaderData: useLoaderData(),
6022
- actionData: useActionData(),
6023
- error: useRouteError()
6024
- };
6054
+ return function WithErrorBoundaryProps2() {
6055
+ const props = useErrorBoundaryProps();
6025
6056
  return React3.createElement(ErrorBoundary, props);
6026
6057
  };
6027
6058
  }
@@ -6791,8 +6822,10 @@ function encode(input, options) {
6791
6822
  lastSentIndex++;
6792
6823
  } else if (id2 < 0) {
6793
6824
  controller.enqueue(
6794
- textEncoder.encode(`${TYPE_ERROR}${deferredId}:${id2}
6795
- `)
6825
+ textEncoder.encode(
6826
+ `${TYPE_ERROR}${deferredId}:${id2}
6827
+ `
6828
+ )
6796
6829
  );
6797
6830
  } else {
6798
6831
  const values = encoder.stringified.slice(lastSentIndex + 1).join(",");
@@ -8300,7 +8333,7 @@ function getActiveMatches(matches, errors, isSpaMode) {
8300
8333
  return matches;
8301
8334
  }
8302
8335
  var CRITICAL_CSS_DATA_ATTRIBUTE = "data-react-router-critical-css";
8303
- function Links() {
8336
+ function Links({ nonce }) {
8304
8337
  let { isSpaMode, manifest, routeModules, criticalCss } = useFrameworkContext();
8305
8338
  let { errors, matches: routerMatches } = useDataRouterStateContext();
8306
8339
  let matches = getActiveMatches(routerMatches, errors, isSpaMode);
@@ -8319,16 +8352,14 @@ function Links() {
8319
8352
  {
8320
8353
  ...{ [CRITICAL_CSS_DATA_ATTRIBUTE]: "" },
8321
8354
  rel: "stylesheet",
8322
- href: criticalCss.href
8355
+ href: criticalCss.href,
8356
+ nonce
8323
8357
  }
8324
8358
  ) : null, keyedLinks.map(
8325
- ({ key, link }) => isPageLinkDescriptor(link) ? /* @__PURE__ */ React8.createElement(PrefetchPageLinks, { key, ...link }) : /* @__PURE__ */ React8.createElement("link", { key, ...link })
8359
+ ({ key, link }) => isPageLinkDescriptor(link) ? /* @__PURE__ */ React8.createElement(PrefetchPageLinks, { key, nonce, ...link }) : /* @__PURE__ */ React8.createElement("link", { key, nonce, ...link })
8326
8360
  ));
8327
8361
  }
8328
- function PrefetchPageLinks({
8329
- page,
8330
- ...dataLinkProps
8331
- }) {
8362
+ function PrefetchPageLinks({ page, ...linkProps }) {
8332
8363
  let { router } = useDataRouterContext2();
8333
8364
  let matches = React8.useMemo(
8334
8365
  () => matchRoutes(router.routes, page, router.basename),
@@ -8337,7 +8368,7 @@ function PrefetchPageLinks({
8337
8368
  if (!matches) {
8338
8369
  return null;
8339
8370
  }
8340
- return /* @__PURE__ */ React8.createElement(PrefetchPageLinksImpl, { page, matches, ...dataLinkProps });
8371
+ return /* @__PURE__ */ React8.createElement(PrefetchPageLinksImpl, { page, matches, ...linkProps });
8341
8372
  }
8342
8373
  function useKeyedPrefetchLinks(matches) {
8343
8374
  let { manifest, routeModules } = useFrameworkContext();
@@ -8436,7 +8467,7 @@ function PrefetchPageLinksImpl({
8436
8467
  return /* @__PURE__ */ React8.createElement(React8.Fragment, null, dataHrefs.map((href) => /* @__PURE__ */ React8.createElement("link", { key: href, rel: "prefetch", as: "fetch", href, ...linkProps })), moduleHrefs.map((href) => /* @__PURE__ */ React8.createElement("link", { key: href, rel: "modulepreload", href, ...linkProps })), keyedPrefetchLinks.map(({ key, link }) => (
8437
8468
  // these don't spread `linkProps` because they are full link descriptors
8438
8469
  // already with their own props
8439
- /* @__PURE__ */ React8.createElement("link", { key, ...link })
8470
+ /* @__PURE__ */ React8.createElement("link", { key, nonce: linkProps.nonce, ...link })
8440
8471
  )));
8441
8472
  }
8442
8473
  function Meta() {
@@ -8541,7 +8572,7 @@ function isValidMetaTag(tagName) {
8541
8572
  return typeof tagName === "string" && /^(meta|link)$/.test(tagName);
8542
8573
  }
8543
8574
  var isHydrated = false;
8544
- function Scripts(props) {
8575
+ function Scripts(scriptProps) {
8545
8576
  let {
8546
8577
  manifest,
8547
8578
  serverHandoffString,
@@ -8627,7 +8658,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
8627
8658
  return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(
8628
8659
  "script",
8629
8660
  {
8630
- ...props,
8661
+ ...scriptProps,
8631
8662
  suppressHydrationWarning: true,
8632
8663
  dangerouslySetInnerHTML: createHtml(contextScript),
8633
8664
  type: void 0
@@ -8635,7 +8666,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
8635
8666
  ), /* @__PURE__ */ React8.createElement(
8636
8667
  "script",
8637
8668
  {
8638
- ...props,
8669
+ ...scriptProps,
8639
8670
  suppressHydrationWarning: true,
8640
8671
  dangerouslySetInnerHTML: createHtml(routeModulesScript),
8641
8672
  type: "module",
@@ -8672,7 +8703,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
8672
8703
  {
8673
8704
  rel: "modulepreload",
8674
8705
  href: manifest.url,
8675
- crossOrigin: props.crossOrigin,
8706
+ crossOrigin: scriptProps.crossOrigin,
8676
8707
  integrity: sri[manifest.url],
8677
8708
  suppressHydrationWarning: true
8678
8709
  }
@@ -8681,7 +8712,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
8681
8712
  {
8682
8713
  rel: "modulepreload",
8683
8714
  href: manifest.entry.module,
8684
- crossOrigin: props.crossOrigin,
8715
+ crossOrigin: scriptProps.crossOrigin,
8685
8716
  integrity: sri[manifest.entry.module],
8686
8717
  suppressHydrationWarning: true
8687
8718
  }
@@ -8691,7 +8722,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
8691
8722
  key: path,
8692
8723
  rel: "modulepreload",
8693
8724
  href: path,
8694
- crossOrigin: props.crossOrigin,
8725
+ crossOrigin: scriptProps.crossOrigin,
8695
8726
  integrity: sri[path],
8696
8727
  suppressHydrationWarning: true
8697
8728
  }
@@ -8815,7 +8846,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
8815
8846
  try {
8816
8847
  if (isBrowser) {
8817
8848
  window.__reactRouterVersion = // @ts-expect-error
8818
- "0.0.0-experimental-d4ee0faac";
8849
+ "0.0.0-experimental-80dc2f07b";
8819
8850
  }
8820
8851
  } catch (e) {
8821
8852
  }
@@ -9613,7 +9644,7 @@ function usePrompt({
9613
9644
  }
9614
9645
  }, [blocker, when]);
9615
9646
  }
9616
- function useViewTransitionState(to, opts = {}) {
9647
+ function useViewTransitionState(to, { relative } = {}) {
9617
9648
  let vtContext = React10.useContext(ViewTransitionContext);
9618
9649
  invariant(
9619
9650
  vtContext != null,
@@ -9622,7 +9653,7 @@ function useViewTransitionState(to, opts = {}) {
9622
9653
  let { basename } = useDataRouterContext3(
9623
9654
  "useViewTransitionState" /* useViewTransitionState */
9624
9655
  );
9625
- let path = useResolvedPath(to, { relative: opts.relative });
9656
+ let path = useResolvedPath(to, { relative });
9626
9657
  if (!vtContext.isTransitioning) {
9627
9658
  return false;
9628
9659
  }
@@ -9982,8 +10013,11 @@ export {
9982
10013
  createRoutesFromChildren,
9983
10014
  createRoutesFromElements,
9984
10015
  renderMatches,
10016
+ WithComponentProps,
9985
10017
  withComponentProps,
10018
+ WithHydrateFallbackProps,
9986
10019
  withHydrateFallbackProps,
10020
+ WithErrorBoundaryProps,
9987
10021
  withErrorBoundaryProps,
9988
10022
  createSearchParams,
9989
10023
  encode,