react-router 7.8.1-pre.0 → 7.8.1

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 (30) hide show
  1. package/CHANGELOG.md +5 -4
  2. package/dist/development/{chunk-V2P3SFSY.mjs → chunk-IFMMFE4R.mjs} +2 -2
  3. package/dist/development/{chunk-3JLHOGU7.js → chunk-IIA3TUI2.js} +130 -130
  4. package/dist/development/{chunk-CXAO7FY7.js → chunk-TGXCWGPT.js} +29 -37
  5. package/dist/development/{chunk-WKLBIS42.mjs → chunk-UH6JLGW7.mjs} +30 -38
  6. package/dist/development/dom-export.js +3 -3
  7. package/dist/development/dom-export.mjs +3 -3
  8. package/dist/development/index-react-server-client.js +4 -4
  9. package/dist/development/index-react-server-client.mjs +2 -2
  10. package/dist/development/index-react-server.js +29 -37
  11. package/dist/development/index-react-server.mjs +29 -37
  12. package/dist/development/index.js +102 -102
  13. package/dist/development/index.mjs +3 -3
  14. package/dist/development/lib/types/internal.js +1 -1
  15. package/dist/development/lib/types/internal.mjs +1 -1
  16. package/dist/production/{chunk-ZKLGVTLT.mjs → chunk-5Y7ELDIJ.mjs} +2 -2
  17. package/dist/production/{chunk-ZFXTWIWH.js → chunk-KHPQXKYM.js} +29 -37
  18. package/dist/production/{chunk-GIJZ6O2U.mjs → chunk-PFDCNQUK.mjs} +30 -38
  19. package/dist/production/{chunk-6K5ETUFZ.js → chunk-YMYXECPK.js} +130 -130
  20. package/dist/production/dom-export.js +3 -3
  21. package/dist/production/dom-export.mjs +3 -3
  22. package/dist/production/index-react-server-client.js +4 -4
  23. package/dist/production/index-react-server-client.mjs +2 -2
  24. package/dist/production/index-react-server.js +29 -37
  25. package/dist/production/index-react-server.mjs +29 -37
  26. package/dist/production/index.js +102 -102
  27. package/dist/production/index.mjs +3 -3
  28. package/dist/production/lib/types/internal.js +1 -1
  29. package/dist/production/lib/types/internal.mjs +1 -1
  30. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.8.1-pre.0
2
+ * react-router v7.8.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -31,7 +31,7 @@ import {
31
31
  isSession,
32
32
  routeRSCServerRequest,
33
33
  setDevServerHooks
34
- } from "./chunk-V2P3SFSY.mjs";
34
+ } from "./chunk-IFMMFE4R.mjs";
35
35
  import {
36
36
  Action,
37
37
  Await,
@@ -140,7 +140,7 @@ import {
140
140
  withComponentProps,
141
141
  withErrorBoundaryProps,
142
142
  withHydrateFallbackProps
143
- } from "./chunk-WKLBIS42.mjs";
143
+ } from "./chunk-UH6JLGW7.mjs";
144
144
  export {
145
145
  Await,
146
146
  BrowserRouter,
@@ -1,5 +1,5 @@
1
1
  "use strict";/**
2
- * react-router v7.8.1-pre.0
2
+ * react-router v7.8.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.8.1-pre.0
2
+ * react-router v7.8.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.8.1-pre.0
2
+ * react-router v7.8.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -58,7 +58,7 @@ import {
58
58
  withComponentProps,
59
59
  withErrorBoundaryProps,
60
60
  withHydrateFallbackProps
61
- } from "./chunk-GIJZ6O2U.mjs";
61
+ } from "./chunk-PFDCNQUK.mjs";
62
62
 
63
63
  // lib/dom/ssr/server.tsx
64
64
  import * as React from "react";
@@ -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.8.1-pre.0
2
+ * react-router v7.8.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -2823,9 +2823,23 @@ function createStaticHandler(routes, opts) {
2823
2823
  return res;
2824
2824
  },
2825
2825
  async (error, routeId) => {
2826
- if (isResponse(error)) {
2826
+ if (isRedirectResponse(error)) {
2827
2827
  return error;
2828
2828
  }
2829
+ if (isResponse(error)) {
2830
+ try {
2831
+ error = new ErrorResponseImpl(
2832
+ error.status,
2833
+ error.statusText,
2834
+ await parseResponseBody(error)
2835
+ );
2836
+ } catch (e) {
2837
+ error = e;
2838
+ }
2839
+ }
2840
+ if (isDataWithResponseInit(error)) {
2841
+ error = dataWithResponseInitToErrorResponse(error);
2842
+ }
2829
2843
  if (renderedStaticContext) {
2830
2844
  if (routeId in renderedStaticContext.loaderData) {
2831
2845
  renderedStaticContext.loaderData[routeId] = void 0;
@@ -2951,8 +2965,8 @@ function createStaticHandler(routes, opts) {
2951
2965
  return res;
2952
2966
  },
2953
2967
  (error) => {
2954
- if (isRouteErrorResponse(error)) {
2955
- return Promise.resolve(errorResponseToResponse(error));
2968
+ if (isDataWithResponseInit(error)) {
2969
+ return Promise.resolve(dataWithResponseInitToResponse(error));
2956
2970
  }
2957
2971
  if (isResponse(error)) {
2958
2972
  return Promise.resolve(error);
@@ -4022,11 +4036,7 @@ async function callServerRouteMiddleware(args, middlewares, handler, errorHandle
4022
4036
  nextResult = result;
4023
4037
  return nextResult;
4024
4038
  } catch (e) {
4025
- nextResult = await errorHandler(
4026
- // Convert thrown data() values to ErrorResponses
4027
- isDataWithResponseInit(e) ? dataWithResponseInitToErrorResponse(e) : e,
4028
- routeId
4029
- );
4039
+ nextResult = await errorHandler(e, routeId);
4030
4040
  return nextResult;
4031
4041
  }
4032
4042
  };
@@ -4051,11 +4061,7 @@ async function callServerRouteMiddleware(args, middlewares, handler, errorHandle
4051
4061
  return nextResult;
4052
4062
  }
4053
4063
  } catch (e) {
4054
- let response = await errorHandler(
4055
- // Convert thrown data() values to ErrorResponses
4056
- isDataWithResponseInit(e) ? dataWithResponseInitToErrorResponse(e) : e,
4057
- routeId
4058
- );
4064
+ let response = await errorHandler(e, routeId);
4059
4065
  return response;
4060
4066
  }
4061
4067
  }
@@ -4381,21 +4387,19 @@ async function callLoaderOrAction({
4381
4387
  }
4382
4388
  return result;
4383
4389
  }
4390
+ async function parseResponseBody(response) {
4391
+ let contentType = response.headers.get("Content-Type");
4392
+ if (contentType && /\bapplication\/json\b/.test(contentType)) {
4393
+ return response.body == null ? null : response.json();
4394
+ }
4395
+ return response.text();
4396
+ }
4384
4397
  async function convertDataStrategyResultToDataResult(dataStrategyResult) {
4385
4398
  let { result, type } = dataStrategyResult;
4386
4399
  if (isResponse(result)) {
4387
4400
  let data2;
4388
4401
  try {
4389
- let contentType = result.headers.get("Content-Type");
4390
- if (contentType && /\bapplication\/json\b/.test(contentType)) {
4391
- if (result.body == null) {
4392
- data2 = null;
4393
- } else {
4394
- data2 = await result.json();
4395
- }
4396
- } else {
4397
- data2 = await result.text();
4398
- }
4402
+ data2 = await parseResponseBody(result);
4399
4403
  } catch (e) {
4400
4404
  return { type: "error" /* error */, error: e };
4401
4405
  }
@@ -4725,10 +4729,7 @@ function isHashChangeOnly(a, b) {
4725
4729
  return false;
4726
4730
  }
4727
4731
  function dataWithResponseInitToResponse(data2) {
4728
- return new Response(
4729
- typeof data2.data === "string" ? data2.data : JSON.stringify(data2.data),
4730
- data2.init || void 0
4731
- );
4732
+ return Response.json(data2.data, _nullishCoalesce(data2.init, () => ( void 0)));
4732
4733
  }
4733
4734
  function dataWithResponseInitToErrorResponse(data2) {
4734
4735
  return new ErrorResponseImpl(
@@ -4737,15 +4738,6 @@ function dataWithResponseInitToErrorResponse(data2) {
4737
4738
  data2.data
4738
4739
  );
4739
4740
  }
4740
- function errorResponseToResponse(error) {
4741
- return new Response(
4742
- typeof error.data === "string" ? error.data : JSON.stringify(error.data),
4743
- {
4744
- status: error.status,
4745
- statusText: error.statusText
4746
- }
4747
- );
4748
- }
4749
4741
  function isDataStrategyResult(result) {
4750
4742
  return result != null && typeof result === "object" && "type" in result && "result" in result && (result.type === "data" /* data */ || result.type === "error" /* error */);
4751
4743
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.8.1-pre.0
2
+ * react-router v7.8.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -2823,9 +2823,23 @@ function createStaticHandler(routes, opts) {
2823
2823
  return res;
2824
2824
  },
2825
2825
  async (error, routeId) => {
2826
- if (isResponse(error)) {
2826
+ if (isRedirectResponse(error)) {
2827
2827
  return error;
2828
2828
  }
2829
+ if (isResponse(error)) {
2830
+ try {
2831
+ error = new ErrorResponseImpl(
2832
+ error.status,
2833
+ error.statusText,
2834
+ await parseResponseBody(error)
2835
+ );
2836
+ } catch (e) {
2837
+ error = e;
2838
+ }
2839
+ }
2840
+ if (isDataWithResponseInit(error)) {
2841
+ error = dataWithResponseInitToErrorResponse(error);
2842
+ }
2829
2843
  if (renderedStaticContext) {
2830
2844
  if (routeId in renderedStaticContext.loaderData) {
2831
2845
  renderedStaticContext.loaderData[routeId] = void 0;
@@ -2951,8 +2965,8 @@ function createStaticHandler(routes, opts) {
2951
2965
  return res;
2952
2966
  },
2953
2967
  (error) => {
2954
- if (isRouteErrorResponse(error)) {
2955
- return Promise.resolve(errorResponseToResponse(error));
2968
+ if (isDataWithResponseInit(error)) {
2969
+ return Promise.resolve(dataWithResponseInitToResponse(error));
2956
2970
  }
2957
2971
  if (isResponse(error)) {
2958
2972
  return Promise.resolve(error);
@@ -4022,11 +4036,7 @@ async function callServerRouteMiddleware(args, middlewares, handler, errorHandle
4022
4036
  nextResult = result;
4023
4037
  return nextResult;
4024
4038
  } catch (e) {
4025
- nextResult = await errorHandler(
4026
- // Convert thrown data() values to ErrorResponses
4027
- isDataWithResponseInit(e) ? dataWithResponseInitToErrorResponse(e) : e,
4028
- routeId
4029
- );
4039
+ nextResult = await errorHandler(e, routeId);
4030
4040
  return nextResult;
4031
4041
  }
4032
4042
  };
@@ -4051,11 +4061,7 @@ async function callServerRouteMiddleware(args, middlewares, handler, errorHandle
4051
4061
  return nextResult;
4052
4062
  }
4053
4063
  } catch (e) {
4054
- let response = await errorHandler(
4055
- // Convert thrown data() values to ErrorResponses
4056
- isDataWithResponseInit(e) ? dataWithResponseInitToErrorResponse(e) : e,
4057
- routeId
4058
- );
4064
+ let response = await errorHandler(e, routeId);
4059
4065
  return response;
4060
4066
  }
4061
4067
  }
@@ -4381,21 +4387,19 @@ async function callLoaderOrAction({
4381
4387
  }
4382
4388
  return result;
4383
4389
  }
4390
+ async function parseResponseBody(response) {
4391
+ let contentType = response.headers.get("Content-Type");
4392
+ if (contentType && /\bapplication\/json\b/.test(contentType)) {
4393
+ return response.body == null ? null : response.json();
4394
+ }
4395
+ return response.text();
4396
+ }
4384
4397
  async function convertDataStrategyResultToDataResult(dataStrategyResult) {
4385
4398
  let { result, type } = dataStrategyResult;
4386
4399
  if (isResponse(result)) {
4387
4400
  let data2;
4388
4401
  try {
4389
- let contentType = result.headers.get("Content-Type");
4390
- if (contentType && /\bapplication\/json\b/.test(contentType)) {
4391
- if (result.body == null) {
4392
- data2 = null;
4393
- } else {
4394
- data2 = await result.json();
4395
- }
4396
- } else {
4397
- data2 = await result.text();
4398
- }
4402
+ data2 = await parseResponseBody(result);
4399
4403
  } catch (e) {
4400
4404
  return { type: "error" /* error */, error: e };
4401
4405
  }
@@ -4725,10 +4729,7 @@ function isHashChangeOnly(a, b) {
4725
4729
  return false;
4726
4730
  }
4727
4731
  function dataWithResponseInitToResponse(data2) {
4728
- return new Response(
4729
- typeof data2.data === "string" ? data2.data : JSON.stringify(data2.data),
4730
- data2.init || void 0
4731
- );
4732
+ return Response.json(data2.data, data2.init ?? void 0);
4732
4733
  }
4733
4734
  function dataWithResponseInitToErrorResponse(data2) {
4734
4735
  return new ErrorResponseImpl(
@@ -4737,15 +4738,6 @@ function dataWithResponseInitToErrorResponse(data2) {
4737
4738
  data2.data
4738
4739
  );
4739
4740
  }
4740
- function errorResponseToResponse(error) {
4741
- return new Response(
4742
- typeof error.data === "string" ? error.data : JSON.stringify(error.data),
4743
- {
4744
- status: error.status,
4745
- statusText: error.statusText
4746
- }
4747
- );
4748
- }
4749
4741
  function isDataStrategyResult(result) {
4750
4742
  return result != null && typeof result === "object" && "type" in result && "result" in result && (result.type === "data" /* data */ || result.type === "error" /* error */);
4751
4743
  }
@@ -8994,7 +8986,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
8994
8986
  try {
8995
8987
  if (isBrowser) {
8996
8988
  window.__reactRouterVersion = // @ts-expect-error
8997
- "7.8.1-pre.0";
8989
+ "7.8.1";
8998
8990
  }
8999
8991
  } catch (e) {
9000
8992
  }