react-router 0.0.0-experimental-795b50c5b → 0.0.0-experimental-4cf5bd08c

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 +29 -0
  2. package/dist/development/{chunk-7T5JZQAV.mjs → chunk-JGV7YEW2.mjs} +33 -15
  3. package/dist/development/{chunk-KHKNSFUT.mjs → chunk-LRHWL6QF.mjs} +18 -23
  4. package/dist/development/{chunk-VNH3JIG2.js → chunk-S26THQOM.js} +73 -60
  5. package/dist/development/{chunk-F3UYON6A.js → chunk-TW7D4RFJ.js} +137 -132
  6. package/dist/development/{context-BH6Jwdoy.d.mts → context-DxpDNUkt.d.mts} +11 -1
  7. package/dist/development/dom-export.d.mts +1 -1
  8. package/dist/development/dom-export.js +10 -10
  9. package/dist/development/dom-export.mjs +10 -10
  10. package/dist/{production/index-react-server-client-1cWMpKk4.d.mts → development/index-react-server-client-BK28HOyz.d.mts} +40 -24
  11. package/dist/development/{index-react-server-client-CMC2eQAY.d.ts → index-react-server-client-DTamczhY.d.ts} +39 -23
  12. package/dist/development/index-react-server-client.d.mts +3 -3
  13. package/dist/development/index-react-server-client.d.ts +2 -2
  14. package/dist/development/index-react-server-client.js +4 -4
  15. package/dist/development/index-react-server-client.mjs +2 -2
  16. package/dist/development/index-react-server.d.mts +46 -2
  17. package/dist/development/index-react-server.d.ts +46 -2
  18. package/dist/development/index-react-server.js +29 -2
  19. package/dist/development/index-react-server.mjs +29 -3
  20. package/dist/development/index.d.mts +22 -15
  21. package/dist/development/index.d.ts +20 -13
  22. package/dist/development/index.js +112 -117
  23. package/dist/development/index.mjs +3 -3
  24. package/dist/development/lib/types/internal.d.mts +39 -14
  25. package/dist/development/lib/types/internal.d.ts +38 -13
  26. package/dist/development/lib/types/internal.js +1 -1
  27. package/dist/development/lib/types/internal.mjs +1 -1
  28. package/dist/development/{route-data-BQkq8Erj.d.mts → route-data-AeZHuDjE.d.mts} +1 -1
  29. package/dist/development/{routeModules-DSKAn01V.d.ts → routeModules-b8-a2L4o.d.ts} +11 -1
  30. package/dist/production/{chunk-LWO6LYIZ.js → chunk-2Y2ZW6ZH.js} +137 -132
  31. package/dist/production/{chunk-RNMWSLFV.mjs → chunk-3OEOUICR.mjs} +33 -15
  32. package/dist/production/{chunk-GBRGDNKH.js → chunk-GWTF4PDT.js} +73 -60
  33. package/dist/production/{chunk-XHECLLLG.mjs → chunk-ZPOX44CY.mjs} +18 -23
  34. package/dist/production/{context-BH6Jwdoy.d.mts → context-DxpDNUkt.d.mts} +11 -1
  35. package/dist/production/dom-export.d.mts +1 -1
  36. package/dist/production/dom-export.js +10 -10
  37. package/dist/production/dom-export.mjs +10 -10
  38. package/dist/{development/index-react-server-client-1cWMpKk4.d.mts → production/index-react-server-client-BK28HOyz.d.mts} +40 -24
  39. package/dist/production/{index-react-server-client-CMC2eQAY.d.ts → index-react-server-client-DTamczhY.d.ts} +39 -23
  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 +4 -4
  43. package/dist/production/index-react-server-client.mjs +2 -2
  44. package/dist/production/index-react-server.d.mts +46 -2
  45. package/dist/production/index-react-server.d.ts +46 -2
  46. package/dist/production/index-react-server.js +29 -2
  47. package/dist/production/index-react-server.mjs +29 -3
  48. package/dist/production/index.d.mts +22 -15
  49. package/dist/production/index.d.ts +20 -13
  50. package/dist/production/index.js +112 -117
  51. package/dist/production/index.mjs +3 -3
  52. package/dist/production/lib/types/internal.d.mts +39 -14
  53. package/dist/production/lib/types/internal.d.ts +38 -13
  54. package/dist/production/lib/types/internal.js +1 -1
  55. package/dist/production/lib/types/internal.mjs +1 -1
  56. package/dist/production/{route-data-BQkq8Erj.d.mts → route-data-AeZHuDjE.d.mts} +1 -1
  57. package/dist/production/{routeModules-DSKAn01V.d.ts → routeModules-b8-a2L4o.d.ts} +11 -1
  58. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # `react-router`
2
2
 
3
+ ## 7.9.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix internal `Future` interface naming from `middleware` -> `v8_middleware` ([#14327](https://github.com/remix-run/react-router/pull/14327))
8
+
9
+ ## 7.9.0
10
+
11
+ ### Minor Changes
12
+
13
+ - Stabilize middleware and context APIs. ([#14215](https://github.com/remix-run/react-router/pull/14215))
14
+
15
+ We have removed the `unstable_` prefix from the following APIs and they are now considered stable and ready for production use:
16
+ - [`RouterContextProvider`](https://reactrouter.com/api/utils/RouterContextProvider)
17
+ - [`createContext`](https://reactrouter.com/api/utils/createContext)
18
+ - `createBrowserRouter` [`getContext`](https://reactrouter.com/api/data-routers/createBrowserRouter#optsgetcontext) option
19
+ - `<HydratedRouter>` [`getContext`](https://reactrouter.com/api/framework-routers/HydratedRouter#getcontext) prop
20
+
21
+ Please see the [Middleware Docs](https://reactrouter.com/how-to/middleware), the [Middleware RFC](https://github.com/remix-run/remix/discussions/7642), and the [Client-side Context RFC](https://github.com/remix-run/react-router/discussions/9856) for more information.
22
+
23
+ ### Patch Changes
24
+
25
+ - Escape HTML in `meta()` JSON-LD content ([#14316](https://github.com/remix-run/react-router/pull/14316))
26
+ - Add react-server Await component implementation ([#14261](https://github.com/remix-run/react-router/pull/14261))
27
+ - In RSC Data Mode when using a custom basename, fix hydration errors for routes that only have client loaders ([#14264](https://github.com/remix-run/react-router/pull/14264))
28
+ - Make `href` function available in a react-server context ([#14262](https://github.com/remix-run/react-router/pull/14262))
29
+ - decode each time `getPayload()` is called to allow for "in-context" decoding and hoisting of contextual assets ([#14248](https://github.com/remix-run/react-router/pull/14248))
30
+ - `href()` now correctly processes routes that have an extension after the parameter or are a single optional parameter. ([#13797](https://github.com/remix-run/react-router/pull/13797))
31
+
3
32
  ## 7.8.2
4
33
 
5
34
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-795b50c5b
2
+ * react-router v0.0.0-experimental-4cf5bd08c
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -2437,6 +2437,10 @@ function createRouter(init) {
2437
2437
  }
2438
2438
  return state.fetchers.get(key) || IDLE_FETCHER;
2439
2439
  }
2440
+ function resetFetcher(key, opts) {
2441
+ abortFetcher(key, opts?.reason);
2442
+ updateFetcherState(key, getDoneFetcher(null));
2443
+ }
2440
2444
  function deleteFetcher(key) {
2441
2445
  let fetcher = state.fetchers.get(key);
2442
2446
  if (fetchControllers.has(key) && !(fetcher && fetcher.state === "loading" && fetchReloadIds.has(key))) {
@@ -2459,10 +2463,10 @@ function createRouter(init) {
2459
2463
  }
2460
2464
  updateState({ fetchers: new Map(state.fetchers) });
2461
2465
  }
2462
- function abortFetcher(key) {
2466
+ function abortFetcher(key, reason) {
2463
2467
  let controller = fetchControllers.get(key);
2464
2468
  if (controller) {
2465
- controller.abort();
2469
+ controller.abort(reason);
2466
2470
  fetchControllers.delete(key);
2467
2471
  }
2468
2472
  }
@@ -2726,6 +2730,7 @@ function createRouter(init) {
2726
2730
  createHref: (to) => init.history.createHref(to),
2727
2731
  encodeLocation: (to) => init.history.encodeLocation(to),
2728
2732
  getFetcher,
2733
+ resetFetcher,
2729
2734
  deleteFetcher: queueFetcherForDeletion,
2730
2735
  dispose,
2731
2736
  getBlocker,
@@ -2835,7 +2840,7 @@ function createStaticHandler(routes, opts) {
2835
2840
  dataStrategy || null,
2836
2841
  skipLoaderErrorBubbling === true,
2837
2842
  null,
2838
- "filterMatchesToLoad" in opts2 ? opts2.filterMatchesToLoad ?? null : null,
2843
+ "filterMatchesToLoad" in opts2 ? opts2.filterMatchesToLoad ?? null : filterMatchesToLoad ?? null,
2839
2844
  skipRevalidation === true
2840
2845
  );
2841
2846
  if (isResponse(result2)) {
@@ -5143,13 +5148,23 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
5143
5148
  params: Object.assign({}, parentParams, match.params),
5144
5149
  pathname: joinPaths([
5145
5150
  parentPathnameBase,
5146
- // Re-encode pathnames that were decoded inside matchRoutes
5147
- navigator.encodeLocation ? navigator.encodeLocation(match.pathname).pathname : match.pathname
5151
+ // Re-encode pathnames that were decoded inside matchRoutes.
5152
+ // Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
5153
+ // `new URL()` internally and we need to prevent it from treating
5154
+ // them as separators
5155
+ navigator.encodeLocation ? navigator.encodeLocation(
5156
+ match.pathname.replace(/\?/g, "%3F").replace(/#/g, "%23")
5157
+ ).pathname : match.pathname
5148
5158
  ]),
5149
5159
  pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
5150
5160
  parentPathnameBase,
5151
5161
  // Re-encode pathnames that were decoded inside matchRoutes
5152
- navigator.encodeLocation ? navigator.encodeLocation(match.pathnameBase).pathname : match.pathnameBase
5162
+ // Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
5163
+ // `new URL()` internally and we need to prevent it from treating
5164
+ // them as separators
5165
+ navigator.encodeLocation ? navigator.encodeLocation(
5166
+ match.pathnameBase.replace(/\?/g, "%3F").replace(/#/g, "%23")
5167
+ ).pathname : match.pathnameBase
5153
5168
  ])
5154
5169
  })
5155
5170
  ),
@@ -6998,9 +7013,6 @@ var ESCAPE_REGEX = /[&><\u2028\u2029]/g;
6998
7013
  function escapeHtml(html) {
6999
7014
  return html.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]);
7000
7015
  }
7001
- function createHtml(html) {
7002
- return { __html: html };
7003
- }
7004
7016
 
7005
7017
  // lib/dom/ssr/invariant.ts
7006
7018
  function invariant2(value, message) {
@@ -8676,7 +8688,7 @@ function Meta() {
8676
8688
  {
8677
8689
  key: `script:ld+json:${json}`,
8678
8690
  type: "application/ld+json",
8679
- dangerouslySetInnerHTML: { __html: json }
8691
+ dangerouslySetInnerHTML: { __html: escapeHtml(json) }
8680
8692
  }
8681
8693
  );
8682
8694
  } catch (err) {
@@ -8781,7 +8793,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
8781
8793
  {
8782
8794
  ...scriptProps,
8783
8795
  suppressHydrationWarning: true,
8784
- dangerouslySetInnerHTML: createHtml(contextScript),
8796
+ dangerouslySetInnerHTML: { __html: contextScript },
8785
8797
  type: void 0
8786
8798
  }
8787
8799
  ), /* @__PURE__ */ React8.createElement(
@@ -8789,7 +8801,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
8789
8801
  {
8790
8802
  ...scriptProps,
8791
8803
  suppressHydrationWarning: true,
8792
- dangerouslySetInnerHTML: createHtml(routeModulesScript),
8804
+ dangerouslySetInnerHTML: { __html: routeModulesScript },
8793
8805
  type: "module",
8794
8806
  async: true
8795
8807
  }
@@ -8967,7 +8979,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
8967
8979
  try {
8968
8980
  if (isBrowser) {
8969
8981
  window.__reactRouterVersion = // @ts-expect-error
8970
- "0.0.0-experimental-795b50c5b";
8982
+ "0.0.0-experimental-4cf5bd08c";
8971
8983
  }
8972
8984
  } catch (e) {
8973
8985
  }
@@ -9581,6 +9593,7 @@ function useFetcher({
9581
9593
  },
9582
9594
  [fetcherKey, submitImpl]
9583
9595
  );
9596
+ let unstable_reset = React10.useCallback((opts) => router.resetFetcher(fetcherKey, opts), [router, fetcherKey]);
9584
9597
  let FetcherForm = React10.useMemo(() => {
9585
9598
  let FetcherForm2 = React10.forwardRef(
9586
9599
  (props, ref) => {
@@ -9597,10 +9610,11 @@ function useFetcher({
9597
9610
  Form: FetcherForm,
9598
9611
  submit,
9599
9612
  load,
9613
+ unstable_reset,
9600
9614
  ...fetcher,
9601
9615
  data: data2
9602
9616
  }),
9603
- [FetcherForm, submit, load, fetcher, data2]
9617
+ [FetcherForm, submit, load, unstable_reset, fetcher, data2]
9604
9618
  );
9605
9619
  return fetcherWithComponents;
9606
9620
  }
@@ -10011,6 +10025,9 @@ function createStaticRouter(routes, context, opts = {}) {
10011
10025
  deleteFetcher() {
10012
10026
  throw msg("deleteFetcher");
10013
10027
  },
10028
+ resetFetcher() {
10029
+ throw msg("resetFetcher");
10030
+ },
10014
10031
  dispose() {
10015
10032
  throw msg("dispose");
10016
10033
  },
@@ -10142,6 +10159,7 @@ export {
10142
10159
  WithErrorBoundaryProps,
10143
10160
  withErrorBoundaryProps,
10144
10161
  createSearchParams,
10162
+ escapeHtml,
10145
10163
  encode,
10146
10164
  createRequestInit,
10147
10165
  SingleFetchRedirectSymbol,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-795b50c5b
2
+ * react-router v0.0.0-experimental-4cf5bd08c
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -33,6 +33,7 @@ import {
33
33
  createStaticRouter,
34
34
  decodeViaTurboStream,
35
35
  encode,
36
+ escapeHtml,
36
37
  getManifestPath,
37
38
  getSingleFetchDataStrategyImpl,
38
39
  getStaticContextFromError,
@@ -58,7 +59,7 @@ import {
58
59
  withComponentProps,
59
60
  withErrorBoundaryProps,
60
61
  withHydrateFallbackProps
61
- } from "./chunk-7T5JZQAV.mjs";
62
+ } from "./chunk-JGV7YEW2.mjs";
62
63
 
63
64
  // lib/dom/ssr/server.tsx
64
65
  import * as React from "react";
@@ -677,19 +678,6 @@ function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesBy
677
678
  });
678
679
  }
679
680
 
680
- // lib/server-runtime/markup.ts
681
- var ESCAPE_LOOKUP = {
682
- "&": "\\u0026",
683
- ">": "\\u003e",
684
- "<": "\\u003c",
685
- "\u2028": "\\u2028",
686
- "\u2029": "\\u2029"
687
- };
688
- var ESCAPE_REGEX = /[&><\u2028\u2029]/g;
689
- function escapeHtml(html) {
690
- return html.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]);
691
- }
692
-
693
681
  // lib/server-runtime/serverHandoff.ts
694
682
  function createServerHandoffString(serverHandoff) {
695
683
  return escapeHtml(JSON.stringify(serverHandoff));
@@ -1686,7 +1674,14 @@ import * as React4 from "react";
1686
1674
  import * as ReactDOM from "react-dom";
1687
1675
 
1688
1676
  // lib/dom/ssr/hydration.tsx
1689
- function getHydrationData(state, routes, getRouteInfo, location2, basename, isSpaMode) {
1677
+ function getHydrationData({
1678
+ state,
1679
+ routes,
1680
+ getRouteInfo,
1681
+ location: location2,
1682
+ basename,
1683
+ isSpaMode
1684
+ }) {
1690
1685
  let hydrationData = {
1691
1686
  ...state,
1692
1687
  loaderData: { ...state.loaderData }
@@ -1979,14 +1974,14 @@ function createRouterFromPayload({
1979
1974
  getContext,
1980
1975
  basename: payload.basename,
1981
1976
  history: createBrowserHistory(),
1982
- hydrationData: getHydrationData(
1983
- {
1977
+ hydrationData: getHydrationData({
1978
+ state: {
1984
1979
  loaderData: payload.loaderData,
1985
1980
  actionData: payload.actionData,
1986
1981
  errors: payload.errors
1987
1982
  },
1988
1983
  routes,
1989
- (routeId) => {
1984
+ getRouteInfo: (routeId) => {
1990
1985
  let match = payload.matches.find((m) => m.id === routeId);
1991
1986
  invariant(match, "Route not found in payload");
1992
1987
  return {
@@ -1995,10 +1990,10 @@ function createRouterFromPayload({
1995
1990
  hasHydrateFallback: match.hydrateFallbackElement != null
1996
1991
  };
1997
1992
  },
1998
- payload.location,
1999
- void 0,
2000
- false
2001
- ),
1993
+ location: payload.location,
1994
+ basename: payload.basename,
1995
+ isSpaMode: false
1996
+ }),
2002
1997
  async patchRoutesOnNavigation({ path, signal }) {
2003
1998
  if (discoveredPaths.has(path)) {
2004
1999
  return;