react-router 0.0.0-experimental-63fd291ad → 0.0.0-experimental-d07149147

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 (87) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/development/{browser-D3uq9sI1.d.ts → browser-B2PdsXXH.d.ts} +2 -2
  3. package/dist/development/{browser-nIQ4Nsyi.d.mts → browser-DBmQ1yAR.d.mts} +2 -2
  4. package/dist/development/{chunk-RMKXU7MN.mjs → chunk-2LN5XYLV.mjs} +36 -86
  5. package/dist/{production/chunk-C3WYAS5Q.js → development/chunk-FXH6PCLA.js} +7 -7
  6. package/dist/development/{chunk-FSPJVI5E.js → chunk-INNQPBPI.js} +111 -108
  7. package/dist/development/{chunk-7LB5FDW6.js → chunk-NPZCI77A.js} +113 -35
  8. package/dist/development/{chunk-HDSKGGQN.mjs → chunk-YXISIC3F.mjs} +115 -38
  9. package/dist/{production/context-m8rizgnE.d.mts → development/context-CeD5LmaF.d.mts} +13 -5
  10. package/dist/{production/data-D4xhSy90.d.ts → development/data-CjO11-hU.d.ts} +9 -1
  11. package/dist/development/{data-U8FS-wNn.d.mts → data-DEjBmEfD.d.mts} +9 -1
  12. package/dist/development/dom-export.d.mts +4 -4
  13. package/dist/development/dom-export.d.ts +4 -4
  14. package/dist/development/dom-export.js +46 -44
  15. package/dist/development/dom-export.mjs +23 -21
  16. package/dist/{production/index-react-server-client-BLiUx67a.d.ts → development/index-react-server-client-3ykjivgQ.d.ts} +30 -8
  17. package/dist/development/{index-react-server-client-CdKROblb.d.mts → index-react-server-client-CACgcj2J.d.mts} +19 -5
  18. package/dist/development/index-react-server-client.d.mts +3 -3
  19. package/dist/development/index-react-server-client.d.ts +3 -3
  20. package/dist/development/index-react-server-client.js +4 -4
  21. package/dist/development/index-react-server-client.mjs +2 -2
  22. package/dist/development/index-react-server.d.mts +9 -1
  23. package/dist/development/index-react-server.d.ts +9 -1
  24. package/dist/development/index-react-server.js +136 -95
  25. package/dist/development/index-react-server.mjs +135 -94
  26. package/dist/development/index.d.mts +15 -14
  27. package/dist/development/index.d.ts +15 -14
  28. package/dist/development/index.js +116 -166
  29. package/dist/development/index.mjs +3 -5
  30. package/dist/{production/instrumentation-1q4YhLGP.d.ts → development/instrumentation-Dkmpzd13.d.ts} +2 -2
  31. package/dist/development/lib/types/internal.d.mts +2 -2
  32. package/dist/development/lib/types/internal.d.ts +2 -2
  33. package/dist/development/lib/types/internal.js +1 -1
  34. package/dist/development/lib/types/internal.mjs +1 -1
  35. package/dist/development/{register-CqK96Zfk.d.mts → register-CmkRspdl.d.mts} +1 -1
  36. package/dist/development/{register-CNAx3TXj.d.ts → register-roq_0qYo.d.ts} +1 -1
  37. package/dist/production/{browser-D3uq9sI1.d.ts → browser-B2PdsXXH.d.ts} +2 -2
  38. package/dist/production/{browser-nIQ4Nsyi.d.mts → browser-DBmQ1yAR.d.mts} +2 -2
  39. package/dist/production/{chunk-R6IYOE2I.mjs → chunk-CTPMZNY4.mjs} +36 -86
  40. package/dist/production/{chunk-7WCS65FW.js → chunk-EGIXHPKG.js} +113 -35
  41. package/dist/production/{chunk-ENJ3YRWR.js → chunk-L4O4PVIV.js} +111 -108
  42. package/dist/{development/chunk-EYULJJW2.js → production/chunk-OINPVNTA.js} +7 -7
  43. package/dist/production/{chunk-LNDORJHC.mjs → chunk-TPWBPI22.mjs} +115 -38
  44. package/dist/{development/context-m8rizgnE.d.mts → production/context-CeD5LmaF.d.mts} +13 -5
  45. package/dist/{development/data-D4xhSy90.d.ts → production/data-CjO11-hU.d.ts} +9 -1
  46. package/dist/production/{data-U8FS-wNn.d.mts → data-DEjBmEfD.d.mts} +9 -1
  47. package/dist/production/dom-export.d.mts +4 -4
  48. package/dist/production/dom-export.d.ts +4 -4
  49. package/dist/production/dom-export.js +46 -44
  50. package/dist/production/dom-export.mjs +23 -21
  51. package/dist/{development/index-react-server-client-BLiUx67a.d.ts → production/index-react-server-client-3ykjivgQ.d.ts} +30 -8
  52. package/dist/production/{index-react-server-client-CdKROblb.d.mts → index-react-server-client-CACgcj2J.d.mts} +19 -5
  53. package/dist/production/index-react-server-client.d.mts +3 -3
  54. package/dist/production/index-react-server-client.d.ts +3 -3
  55. package/dist/production/index-react-server-client.js +4 -4
  56. package/dist/production/index-react-server-client.mjs +2 -2
  57. package/dist/production/index-react-server.d.mts +9 -1
  58. package/dist/production/index-react-server.d.ts +9 -1
  59. package/dist/production/index-react-server.js +136 -95
  60. package/dist/production/index-react-server.mjs +135 -94
  61. package/dist/production/index.d.mts +15 -14
  62. package/dist/production/index.d.ts +15 -14
  63. package/dist/production/index.js +116 -166
  64. package/dist/production/index.mjs +3 -5
  65. package/dist/{development/instrumentation-1q4YhLGP.d.ts → production/instrumentation-Dkmpzd13.d.ts} +2 -2
  66. package/dist/production/lib/types/internal.d.mts +2 -2
  67. package/dist/production/lib/types/internal.d.ts +2 -2
  68. package/dist/production/lib/types/internal.js +1 -1
  69. package/dist/production/lib/types/internal.mjs +1 -1
  70. package/dist/production/{register-CqK96Zfk.d.mts → register-CmkRspdl.d.mts} +1 -1
  71. package/dist/production/{register-CNAx3TXj.d.ts → register-roq_0qYo.d.ts} +1 -1
  72. package/docs/explanation/code-splitting.md +1 -1
  73. package/docs/explanation/index-query-param.md +2 -2
  74. package/docs/explanation/type-safety.md +1 -1
  75. package/docs/how-to/data-strategy.md +5 -5
  76. package/docs/how-to/error-reporting.md +10 -2
  77. package/docs/how-to/headers.md +2 -1
  78. package/docs/how-to/security.md +9 -7
  79. package/docs/start/data/installation.md +4 -0
  80. package/docs/start/data/route-object.md +20 -0
  81. package/docs/start/framework/actions.md +0 -1
  82. package/docs/start/framework/data-loading.md +1 -1
  83. package/docs/start/framework/deploying.md +4 -0
  84. package/docs/start/framework/installation.md +0 -1
  85. package/docs/upgrading/future.md +34 -2
  86. package/docs/upgrading/v6.md +3 -0
  87. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # `react-router`
2
2
 
3
+ ## v7.17.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Ship a subset of the official documentation inside the `react-router` package ([#15121](https://github.com/remix-run/react-router/pull/15121))
8
+ - Markdown docs are now available in `node_modules/react-router/docs`, letting AI coding agents and the React Router agent skills read official docs locally
9
+ - Excludes auto-generated API docs (`api/`), `community/` content, and tutorials (`tutorials/`)
10
+
3
11
  ## v7.16.0
4
12
 
5
13
  ### Minor Changes
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { R as RouterInit } from './instrumentation-1q4YhLGP.js';
3
- import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction } from './data-D4xhSy90.js';
2
+ import { R as RouterInit } from './instrumentation-Dkmpzd13.js';
3
+ import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction } from './data-CjO11-hU.js';
4
4
 
5
5
  declare function getRequest(): Request;
6
6
  type RSCRouteConfigEntryBase = {
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { R as RouterInit } from './context-m8rizgnE.mjs';
3
- import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction } from './data-U8FS-wNn.mjs';
2
+ import { R as RouterInit } from './context-CeD5LmaF.mjs';
3
+ import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction } from './data-DEjBmEfD.mjs';
4
4
 
5
5
  declare function getRequest(): Request;
6
6
  type RSCRouteConfigEntryBase = {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-63fd291ad
2
+ * react-router v0.0.0-experimental-d07149147
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -35,6 +35,7 @@ import {
35
35
  escapeHtml,
36
36
  getManifestPath,
37
37
  getStaticContextFromError,
38
+ hasInvalidProtocol,
38
39
  instrumentHandler,
39
40
  isDataWithResponseInit,
40
41
  isMutationMethod,
@@ -54,7 +55,7 @@ import {
54
55
  withComponentProps,
55
56
  withErrorBoundaryProps,
56
57
  withHydrateFallbackProps
57
- } from "./chunk-HDSKGGQN.mjs";
58
+ } from "./chunk-YXISIC3F.mjs";
58
59
 
59
60
  // lib/dom/ssr/server.tsx
60
61
  import * as React from "react";
@@ -104,6 +105,7 @@ function ServerRouter({
104
105
  ssr: context.ssr,
105
106
  isSpaMode: context.isSpaMode,
106
107
  routeDiscovery: context.routeDiscovery,
108
+ nonce,
107
109
  serializeError: context.serializeError,
108
110
  renderMeta: context.renderMeta
109
111
  }
@@ -466,33 +468,6 @@ function serializeError(error, serverMode) {
466
468
  stack: sanitized.stack
467
469
  };
468
470
  }
469
- function serializeErrors(errors, serverMode) {
470
- if (!errors) return null;
471
- let entries = Object.entries(errors);
472
- let serialized = {};
473
- for (let [key, val] of entries) {
474
- if (isRouteErrorResponse(val)) {
475
- serialized[key] = { ...val, __type: "RouteErrorResponse" };
476
- } else if (val instanceof Error) {
477
- let sanitized = sanitizeError(val, serverMode);
478
- serialized[key] = {
479
- message: sanitized.message,
480
- stack: sanitized.stack,
481
- __type: "Error",
482
- // If this is a subclass (i.e., ReferenceError), send up the type so we
483
- // can re-create the same type during hydration. This will only apply
484
- // in dev mode since all production errors are sanitized to normal
485
- // Error instances
486
- ...sanitized.name !== "Error" ? {
487
- __subType: sanitized.name
488
- } : {}
489
- };
490
- } else {
491
- serialized[key] = val;
492
- }
493
- }
494
- return serialized;
495
- }
496
471
 
497
472
  // lib/server-runtime/invariant.ts
498
473
  function invariant(value, message) {
@@ -1225,7 +1200,7 @@ function derive(build, mode) {
1225
1200
  }
1226
1201
  if (build.prerender.length === 0) {
1227
1202
  isSpaMode = true;
1228
- } else if (!build.prerender.includes(decodedPath) && !build.prerender.includes(decodedPath + "/")) {
1203
+ } else if (!build.prerender.includes(decodedPath.replace(/\/$/, "")) && !build.prerender.includes(decodedPath.replace(/[^/]$/, "/"))) {
1229
1204
  if (requestUrl.pathname.endsWith(".data")) {
1230
1205
  errorHandler(
1231
1206
  new ErrorResponseImpl(
@@ -1386,6 +1361,12 @@ var createRequestHandler = (build, mode) => {
1386
1361
  };
1387
1362
  };
1388
1363
  async function handleManifestRequest(build, dataRoutes, branches, url) {
1364
+ if (url.toString().length > URL_LIMIT) {
1365
+ return new Response(null, {
1366
+ statusText: "Bad Request",
1367
+ status: 400
1368
+ });
1369
+ }
1389
1370
  if (build.assets.version !== url.searchParams.get("version")) {
1390
1371
  return new Response(null, {
1391
1372
  status: 204,
@@ -1394,28 +1375,14 @@ async function handleManifestRequest(build, dataRoutes, branches, url) {
1394
1375
  }
1395
1376
  });
1396
1377
  }
1397
- if (url.toString().length > URL_LIMIT) {
1398
- return new Response(null, {
1399
- statusText: "Bad Request",
1400
- status: 400
1401
- });
1402
- }
1403
1378
  let patches = {};
1404
1379
  if (url.searchParams.has("paths")) {
1405
- let paths = /* @__PURE__ */ new Set();
1406
1380
  let pathParam = url.searchParams.get("paths") || "";
1407
- let requestedPaths = pathParam.split(",").filter(Boolean);
1408
- requestedPaths.forEach((path) => {
1381
+ let paths = new Set(pathParam.split(",").filter(Boolean));
1382
+ for (let path of paths) {
1409
1383
  if (!path.startsWith("/")) {
1410
1384
  path = `/${path}`;
1411
1385
  }
1412
- let segments = path.split("/").slice(1);
1413
- segments.forEach((_, i) => {
1414
- let partialPath = segments.slice(0, i + 1).join("/");
1415
- paths.add(`/${partialPath}`);
1416
- });
1417
- });
1418
- for (let path of paths) {
1419
1386
  let matches = matchServerRoutes(
1420
1387
  build.routes,
1421
1388
  dataRoutes,
@@ -1516,7 +1483,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
1516
1483
  let state = {
1517
1484
  loaderData: context.loaderData,
1518
1485
  actionData: context.actionData,
1519
- errors: serializeErrors(context.errors, serverMode)
1486
+ errors: context.errors
1520
1487
  };
1521
1488
  let baseServerHandoff = {
1522
1489
  basename: build.basename,
@@ -1582,7 +1549,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
1582
1549
  let state2 = {
1583
1550
  loaderData: context.loaderData,
1584
1551
  actionData: context.actionData,
1585
- errors: serializeErrors(context.errors, serverMode)
1552
+ errors: context.errors
1586
1553
  };
1587
1554
  entryContext = {
1588
1555
  ...entryContext,
@@ -2178,6 +2145,9 @@ async function routeRSCServerRequest({
2178
2145
  detectRedirectResponse.body
2179
2146
  );
2180
2147
  if (serverResponse.status === SINGLE_FETCH_REDIRECT_STATUS && payload.type === "redirect") {
2148
+ if (hasInvalidProtocol(payload.location)) {
2149
+ throw new Error("Invalid redirect location");
2150
+ }
2181
2151
  const headers2 = new Headers(serverResponse.headers);
2182
2152
  headers2.delete("Content-Encoding");
2183
2153
  headers2.delete("Content-Length");
@@ -2221,6 +2191,9 @@ async function routeRSCServerRequest({
2221
2191
  }
2222
2192
  headers.set("Content-Type", "text/html; charset=utf-8");
2223
2193
  if (renderRedirect) {
2194
+ if (hasInvalidProtocol(renderRedirect.location)) {
2195
+ throw new Error("Invalid redirect location");
2196
+ }
2224
2197
  headers.set("Location", renderRedirect.location);
2225
2198
  return new Response(html, {
2226
2199
  status: renderRedirect.status,
@@ -2230,6 +2203,9 @@ async function routeRSCServerRequest({
2230
2203
  const redirectTransform = new TransformStream({
2231
2204
  flush(controller) {
2232
2205
  if (renderRedirect) {
2206
+ if (hasInvalidProtocol(renderRedirect.location)) {
2207
+ return;
2208
+ }
2233
2209
  controller.enqueue(
2234
2210
  new TextEncoder().encode(
2235
2211
  `<meta http-equiv="refresh" content="0;url=${escapeHtml(renderRedirect.location)}"/>`
@@ -2259,6 +2235,9 @@ async function routeRSCServerRequest({
2259
2235
  return error;
2260
2236
  }
2261
2237
  if (renderRedirect) {
2238
+ if (hasInvalidProtocol(renderRedirect.location)) {
2239
+ throw new Error("Invalid redirect location");
2240
+ }
2262
2241
  return new Response(`Redirect: ${renderRedirect.location}`, {
2263
2242
  status: renderRedirect.status,
2264
2243
  headers: {
@@ -2332,6 +2311,9 @@ async function routeRSCServerRequest({
2332
2311
  }
2333
2312
  headers.set("Content-Type", "text/html; charset=utf-8");
2334
2313
  if (retryRedirect) {
2314
+ if (hasInvalidProtocol(retryRedirect.location)) {
2315
+ throw new Error("Invalid redirect location");
2316
+ }
2335
2317
  headers.set("Location", retryRedirect.location);
2336
2318
  return new Response(html, {
2337
2319
  status: retryRedirect.status,
@@ -2341,6 +2323,9 @@ async function routeRSCServerRequest({
2341
2323
  const retryRedirectTransform = new TransformStream({
2342
2324
  flush(controller) {
2343
2325
  if (retryRedirect) {
2326
+ if (hasInvalidProtocol(retryRedirect.location)) {
2327
+ return;
2328
+ }
2344
2329
  controller.enqueue(
2345
2330
  new TextEncoder().encode(
2346
2331
  `<meta http-equiv="refresh" content="0;url=${escapeHtml(retryRedirect.location)}"/>`
@@ -2374,6 +2359,9 @@ function RSCStaticRouter({ getPayload }) {
2374
2359
  const decoded = getPayload();
2375
2360
  const payload = useSafe(decoded);
2376
2361
  if (payload.type === "redirect") {
2362
+ if (hasInvalidProtocol(payload.location)) {
2363
+ throw new Error("Invalid redirect location");
2364
+ }
2377
2365
  throw new Response(null, {
2378
2366
  status: payload.status,
2379
2367
  headers: {
@@ -2491,43 +2479,6 @@ function isManifestRequest(url) {
2491
2479
  return url.pathname.endsWith(".manifest");
2492
2480
  }
2493
2481
 
2494
- // lib/dom/ssr/errors.ts
2495
- function deserializeErrors(errors) {
2496
- if (!errors) return null;
2497
- let entries = Object.entries(errors);
2498
- let serialized = {};
2499
- for (let [key, val] of entries) {
2500
- if (val && val.__type === "RouteErrorResponse") {
2501
- serialized[key] = new ErrorResponseImpl(
2502
- val.status,
2503
- val.statusText,
2504
- val.data,
2505
- val.internal === true
2506
- );
2507
- } else if (val && val.__type === "Error") {
2508
- if (val.__subType) {
2509
- let ErrorConstructor = window[val.__subType];
2510
- if (typeof ErrorConstructor === "function") {
2511
- try {
2512
- let error = new ErrorConstructor(val.message);
2513
- error.stack = val.stack;
2514
- serialized[key] = error;
2515
- } catch (e) {
2516
- }
2517
- }
2518
- }
2519
- if (serialized[key] == null) {
2520
- let error = new Error(val.message);
2521
- error.stack = val.stack;
2522
- serialized[key] = error;
2523
- }
2524
- } else {
2525
- serialized[key] = val;
2526
- }
2527
- }
2528
- return serialized;
2529
- }
2530
-
2531
2482
  // lib/dom/ssr/hydration.tsx
2532
2483
  function getHydrationData({
2533
2484
  state,
@@ -2580,6 +2531,5 @@ export {
2580
2531
  populateRSCRouteModules,
2581
2532
  routeRSCServerRequest,
2582
2533
  RSCStaticRouter,
2583
- deserializeErrors,
2584
2534
  getHydrationData
2585
2535
  };
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }/**
2
- * react-router v0.0.0-experimental-63fd291ad
2
+ * react-router v0.0.0-experimental-d07149147
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -14,7 +14,7 @@
14
14
 
15
15
 
16
16
 
17
- var _chunk7WCS65FWjs = require('./chunk-7WCS65FW.js');
17
+ var _chunkNPZCI77Ajs = require('./chunk-NPZCI77A.js');
18
18
 
19
19
  // lib/dom/ssr/hydration.tsx
20
20
  function getHydrationData({
@@ -29,12 +29,12 @@ function getHydrationData({
29
29
  ...state,
30
30
  loaderData: { ...state.loaderData }
31
31
  };
32
- let initialMatches = _chunk7WCS65FWjs.matchRoutes.call(void 0, routes, location, basename);
32
+ let initialMatches = _chunkNPZCI77Ajs.matchRoutes.call(void 0, routes, location, basename);
33
33
  if (initialMatches) {
34
34
  for (let match of initialMatches) {
35
35
  let routeId = match.route.id;
36
36
  let routeInfo = getRouteInfo(routeId);
37
- if (_chunk7WCS65FWjs.shouldHydrateRouteLoader.call(void 0,
37
+ if (_chunkNPZCI77Ajs.shouldHydrateRouteLoader.call(void 0,
38
38
  routeId,
39
39
  routeInfo.clientLoader,
40
40
  routeInfo.hasLoader,
@@ -112,7 +112,7 @@ function RSCDefaultRootErrorBoundaryImpl({
112
112
  }
113
113
  }
114
114
  );
115
- if (_chunk7WCS65FWjs.isRouteErrorResponse.call(void 0, error)) {
115
+ if (_chunkNPZCI77Ajs.isRouteErrorResponse.call(void 0, error)) {
116
116
  return /* @__PURE__ */ _react2.default.createElement(
117
117
  ErrorWrapper,
118
118
  {
@@ -120,7 +120,7 @@ function RSCDefaultRootErrorBoundaryImpl({
120
120
  title: "Unhandled Thrown Response!"
121
121
  },
122
122
  /* @__PURE__ */ _react2.default.createElement("h1", { style: { fontSize: "24px" } }, error.status, " ", error.statusText),
123
- _chunk7WCS65FWjs.ENABLE_DEV_WARNINGS ? heyDeveloper : null
123
+ _chunkNPZCI77Ajs.ENABLE_DEV_WARNINGS ? heyDeveloper : null
124
124
  );
125
125
  }
126
126
  let errorInstance;
@@ -146,7 +146,7 @@ function RSCDefaultRootErrorBoundaryImpl({
146
146
  function RSCDefaultRootErrorBoundary({
147
147
  hasRootLayout
148
148
  }) {
149
- let error = _chunk7WCS65FWjs.useRouteError.call(void 0, );
149
+ let error = _chunkNPZCI77Ajs.useRouteError.call(void 0, );
150
150
  if (hasRootLayout === void 0) {
151
151
  throw new Error("Missing 'hasRootLayout' prop");
152
152
  }