react-router 0.0.0-experimental-ae6d61df4 → 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-2ZZVVNV4.mjs → chunk-JGV7YEW2.mjs} +33 -15
  3. package/dist/{production/chunk-RDSEQDXA.mjs → development/chunk-LRHWL6QF.mjs} +6 -20
  4. package/dist/development/{chunk-IRJNXLFF.js → chunk-S26THQOM.js} +73 -60
  5. package/dist/development/{chunk-Y3HHG2TB.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 +3 -3
  9. package/dist/development/dom-export.mjs +3 -3
  10. package/dist/{production/index-react-server-client-1cWMpKk4.d.mts → development/index-react-server-client-BK28HOyz.d.mts} +40 -24
  11. package/dist/{production/index-react-server-client-CMC2eQAY.d.ts → development/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 +11 -1
  17. package/dist/development/index-react-server.d.ts +11 -1
  18. package/dist/development/index-react-server.js +3 -3
  19. package/dist/development/index-react-server.mjs +3 -3
  20. package/dist/development/index.d.mts +6 -6
  21. package/dist/development/index.d.ts +4 -4
  22. package/dist/development/index.js +100 -114
  23. package/dist/development/index.mjs +3 -3
  24. package/dist/development/lib/types/internal.d.mts +2 -2
  25. package/dist/development/lib/types/internal.d.ts +1 -1
  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/{production/routeModules-DSKAn01V.d.ts → development/routeModules-b8-a2L4o.d.ts} +11 -1
  30. package/dist/production/{chunk-TUJHIUWZ.js → chunk-2Y2ZW6ZH.js} +137 -132
  31. package/dist/production/{chunk-SBKYKNWV.mjs → chunk-3OEOUICR.mjs} +33 -15
  32. package/dist/production/{chunk-UKH567WH.js → chunk-GWTF4PDT.js} +73 -60
  33. package/dist/{development/chunk-RID2P5US.mjs → production/chunk-ZPOX44CY.mjs} +6 -20
  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 +3 -3
  37. package/dist/production/dom-export.mjs +3 -3
  38. package/dist/{development/index-react-server-client-1cWMpKk4.d.mts → production/index-react-server-client-BK28HOyz.d.mts} +40 -24
  39. package/dist/{development/index-react-server-client-CMC2eQAY.d.ts → production/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 +11 -1
  45. package/dist/production/index-react-server.d.ts +11 -1
  46. package/dist/production/index-react-server.js +3 -3
  47. package/dist/production/index-react-server.mjs +3 -3
  48. package/dist/production/index.d.mts +6 -6
  49. package/dist/production/index.d.ts +4 -4
  50. package/dist/production/index.js +100 -114
  51. package/dist/production/index.mjs +3 -3
  52. package/dist/production/lib/types/internal.d.mts +2 -2
  53. package/dist/production/lib/types/internal.d.ts +1 -1
  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/{development/routeModules-DSKAn01V.d.ts → production/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-ae6d61df4
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,
@@ -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) {
@@ -8265,7 +8277,7 @@ function getManifestPath(_manifestPath, basename) {
8265
8277
  var MANIFEST_VERSION_STORAGE_KEY = "react-router-manifest-version";
8266
8278
  async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, manifestPath, patchRoutes, signal) {
8267
8279
  const searchParams = new URLSearchParams();
8268
- searchParams.set("paths", paths.sort().join(","));
8280
+ paths.sort().forEach((path) => searchParams.append("p", path));
8269
8281
  searchParams.set("version", manifest.version);
8270
8282
  let url = new URL(
8271
8283
  getManifestPath(manifestPath, basename),
@@ -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-ae6d61df4";
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-ae6d61df4
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-SBKYKNWV.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));
@@ -1246,11 +1234,9 @@ async function handleManifestRequest(build, routes, url) {
1246
1234
  });
1247
1235
  }
1248
1236
  let patches = {};
1249
- if (url.searchParams.has("paths")) {
1237
+ if (url.searchParams.has("p")) {
1250
1238
  let paths = /* @__PURE__ */ new Set();
1251
- let pathParam = url.searchParams.get("paths") || "";
1252
- let requestedPaths = pathParam.split(",").filter(Boolean);
1253
- requestedPaths.forEach((path) => {
1239
+ url.searchParams.getAll("p").forEach((path) => {
1254
1240
  if (!path.startsWith("/")) {
1255
1241
  path = `/${path}`;
1256
1242
  }
@@ -2421,7 +2407,7 @@ function getManifestUrl(paths) {
2421
2407
  ""
2422
2408
  );
2423
2409
  let url = new URL(`${basename}/.manifest`, window.location.origin);
2424
- url.searchParams.set("paths", paths.sort().join(","));
2410
+ paths.sort().forEach((path) => url.searchParams.append("p", path));
2425
2411
  return url;
2426
2412
  }
2427
2413
  async function fetchAndApplyManifestPatches(paths, createFromReadableStream, fetchImplementation, signal) {