react-router 7.18.0 → 8.0.0-pre.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 (285) hide show
  1. package/dist/development/dom-export.d.ts +6 -172
  2. package/dist/development/dom-export.js +12 -1009
  3. package/dist/development/index-react-server-client.d.ts +7 -4
  4. package/dist/development/index-react-server-client.js +8 -52
  5. package/dist/development/index-react-server.d.ts +1650 -1641
  6. package/dist/development/index-react-server.js +2882 -3664
  7. package/dist/development/index.d.ts +42 -1476
  8. package/dist/development/index.js +36 -2553
  9. package/dist/development/lib/actions.js +50 -0
  10. package/dist/development/lib/components.d.ts +1030 -0
  11. package/dist/development/lib/components.js +841 -0
  12. package/dist/development/lib/context.d.ts +83 -0
  13. package/dist/development/lib/context.js +41 -0
  14. package/dist/development/lib/dom/dom.d.ts +119 -0
  15. package/dist/development/lib/dom/dom.js +143 -0
  16. package/dist/development/lib/dom/lib.d.ts +2053 -0
  17. package/dist/development/lib/dom/lib.js +1271 -0
  18. package/dist/development/lib/dom/server.d.ts +138 -0
  19. package/dist/development/lib/dom/server.js +301 -0
  20. package/dist/development/lib/dom/ssr/components.d.ts +198 -0
  21. package/dist/development/lib/dom/ssr/components.js +589 -0
  22. package/dist/development/lib/dom/ssr/data.js +29 -0
  23. package/dist/development/lib/dom/ssr/entry.d.ts +60 -0
  24. package/dist/development/lib/dom/ssr/errorBoundaries.d.ts +27 -0
  25. package/dist/development/lib/dom/ssr/errorBoundaries.js +87 -0
  26. package/dist/development/lib/dom/ssr/fallback.js +33 -0
  27. package/dist/development/lib/dom/ssr/fog-of-war.d.ts +12 -0
  28. package/dist/development/lib/dom/ssr/fog-of-war.js +180 -0
  29. package/dist/development/lib/dom/ssr/hydration.d.ts +32 -0
  30. package/dist/development/lib/dom/ssr/hydration.js +29 -0
  31. package/dist/development/lib/dom/ssr/invariant.js +16 -0
  32. package/dist/development/lib/dom/ssr/links.js +170 -0
  33. package/dist/development/lib/dom/ssr/markup.js +24 -0
  34. package/dist/development/lib/dom/ssr/routeModules.d.ts +206 -0
  35. package/dist/development/lib/dom/ssr/routeModules.js +31 -0
  36. package/dist/development/lib/dom/ssr/routes-test-stub.d.ts +62 -0
  37. package/dist/development/lib/dom/ssr/routes-test-stub.js +108 -0
  38. package/dist/development/lib/dom/ssr/routes.d.ts +33 -0
  39. package/dist/development/lib/dom/ssr/routes.js +303 -0
  40. package/dist/development/lib/dom/ssr/server.d.ts +48 -0
  41. package/dist/development/lib/dom/ssr/server.js +69 -0
  42. package/dist/development/lib/dom/ssr/single-fetch.d.ts +14 -0
  43. package/dist/development/lib/dom/ssr/single-fetch.js +345 -0
  44. package/dist/development/lib/dom-export/dom-router-provider.d.ts +9 -0
  45. package/dist/development/lib/dom-export/dom-router-provider.js +22 -0
  46. package/dist/development/lib/dom-export/hydrated-router.d.ts +125 -0
  47. package/dist/development/lib/dom-export/hydrated-router.js +150 -0
  48. package/dist/development/lib/errors.js +29 -0
  49. package/dist/development/lib/hooks.d.ts +947 -0
  50. package/dist/development/lib/hooks.js +1388 -0
  51. package/dist/development/lib/href.d.ts +20 -0
  52. package/dist/development/lib/href.js +50 -0
  53. package/dist/development/lib/router/history.d.ts +258 -0
  54. package/dist/development/lib/router/history.js +372 -0
  55. package/dist/development/lib/router/instrumentation.d.ts +86 -0
  56. package/dist/development/lib/router/instrumentation.js +213 -0
  57. package/dist/development/lib/router/links.d.ts +114 -0
  58. package/dist/development/lib/router/router.d.ts +663 -0
  59. package/dist/development/lib/router/router.js +2988 -0
  60. package/dist/development/lib/router/url.js +18 -0
  61. package/dist/development/lib/router/utils.d.ts +948 -0
  62. package/dist/development/lib/router/utils.js +810 -0
  63. package/dist/development/lib/rsc/browser.d.ts +137 -0
  64. package/dist/development/lib/rsc/browser.js +603 -0
  65. package/dist/development/lib/rsc/errorBoundaries.d.ts +11 -0
  66. package/dist/development/lib/rsc/errorBoundaries.js +90 -0
  67. package/dist/development/lib/rsc/html-stream/browser.d.ts +48 -0
  68. package/dist/development/lib/rsc/html-stream/browser.js +74 -0
  69. package/dist/development/lib/rsc/html-stream/server.js +78 -0
  70. package/dist/development/lib/rsc/route-modules.js +27 -0
  71. package/dist/development/lib/rsc/server.rsc.d.ts +219 -0
  72. package/dist/development/lib/rsc/server.ssr.d.ts +129 -0
  73. package/dist/development/lib/rsc/server.ssr.js +404 -0
  74. package/dist/development/lib/server-runtime/build.d.ts +66 -0
  75. package/dist/development/lib/server-runtime/cookies.d.ts +66 -0
  76. package/dist/development/lib/server-runtime/cookies.js +139 -0
  77. package/dist/development/lib/server-runtime/crypto.js +43 -0
  78. package/dist/development/lib/server-runtime/data.d.ts +13 -0
  79. package/dist/development/lib/server-runtime/data.js +25 -0
  80. package/dist/development/lib/server-runtime/dev.d.ts +9 -0
  81. package/dist/development/lib/server-runtime/dev.js +26 -0
  82. package/dist/development/lib/server-runtime/entry.js +20 -0
  83. package/dist/development/lib/server-runtime/errors.js +75 -0
  84. package/dist/development/lib/server-runtime/headers.js +73 -0
  85. package/dist/development/lib/server-runtime/invariant.js +19 -0
  86. package/dist/development/lib/server-runtime/mode.d.ts +12 -0
  87. package/dist/development/lib/server-runtime/mode.js +25 -0
  88. package/dist/development/lib/server-runtime/routeMatching.js +28 -0
  89. package/dist/development/lib/server-runtime/routes.d.ts +13 -0
  90. package/dist/development/lib/server-runtime/routes.js +74 -0
  91. package/dist/development/lib/server-runtime/server.d.ts +10 -0
  92. package/dist/development/lib/server-runtime/server.js +345 -0
  93. package/dist/development/lib/server-runtime/serverHandoff.js +17 -0
  94. package/dist/development/lib/server-runtime/sessions/cookieStorage.d.ts +25 -0
  95. package/dist/development/lib/server-runtime/sessions/cookieStorage.js +45 -0
  96. package/dist/development/lib/server-runtime/sessions/memoryStorage.d.ts +23 -0
  97. package/dist/development/lib/server-runtime/sessions/memoryStorage.js +52 -0
  98. package/dist/development/lib/server-runtime/sessions.d.ts +145 -0
  99. package/dist/development/lib/server-runtime/sessions.js +98 -0
  100. package/dist/development/lib/server-runtime/single-fetch.d.ts +7 -0
  101. package/dist/development/lib/server-runtime/single-fetch.js +215 -0
  102. package/dist/development/lib/server-runtime/urls.js +28 -0
  103. package/dist/development/lib/server-runtime/warnings.js +20 -0
  104. package/dist/development/lib/types/future.d.ts +9 -0
  105. package/dist/development/lib/types/internal.d.ts +26 -177
  106. package/dist/development/lib/types/internal.js +3 -2
  107. package/dist/development/{register-roq_0qYo.d.ts → lib/types/register.d.ts} +9 -15
  108. package/dist/development/lib/types/route-data.d.ts +113 -0
  109. package/dist/development/lib/types/route-module-annotations.d.ts +149 -0
  110. package/dist/development/lib/types/route-module.d.ts +19 -0
  111. package/dist/development/lib/types/serializes-to.d.ts +13 -0
  112. package/dist/development/lib/types/utils.d.ts +11 -0
  113. package/dist/development/vendor/turbo-stream-v2/flatten.js +159 -0
  114. package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +179 -0
  115. package/dist/development/vendor/turbo-stream-v2/unflatten.js +199 -0
  116. package/dist/development/vendor/turbo-stream-v2/utils.js +39 -0
  117. package/dist/production/dom-export.d.ts +6 -172
  118. package/dist/production/dom-export.js +12 -1009
  119. package/dist/production/index-react-server-client.d.ts +7 -4
  120. package/dist/production/index-react-server-client.js +8 -52
  121. package/dist/production/index-react-server.d.ts +1650 -1641
  122. package/dist/production/index-react-server.js +2873 -3664
  123. package/dist/production/index.d.ts +42 -1476
  124. package/dist/production/index.js +36 -2553
  125. package/dist/production/lib/actions.js +50 -0
  126. package/dist/production/lib/components.d.ts +1030 -0
  127. package/dist/production/lib/components.js +841 -0
  128. package/dist/production/lib/context.d.ts +83 -0
  129. package/dist/production/lib/context.js +41 -0
  130. package/dist/production/lib/dom/dom.d.ts +119 -0
  131. package/dist/production/lib/dom/dom.js +143 -0
  132. package/dist/production/lib/dom/lib.d.ts +2053 -0
  133. package/dist/production/lib/dom/lib.js +1271 -0
  134. package/dist/production/lib/dom/server.d.ts +138 -0
  135. package/dist/production/lib/dom/server.js +301 -0
  136. package/dist/production/lib/dom/ssr/components.d.ts +198 -0
  137. package/dist/production/lib/dom/ssr/components.js +589 -0
  138. package/dist/production/lib/dom/ssr/data.js +29 -0
  139. package/dist/production/lib/dom/ssr/entry.d.ts +60 -0
  140. package/dist/production/lib/dom/ssr/errorBoundaries.d.ts +27 -0
  141. package/dist/production/lib/dom/ssr/errorBoundaries.js +87 -0
  142. package/dist/production/lib/dom/ssr/fallback.js +23 -0
  143. package/dist/production/lib/dom/ssr/fog-of-war.d.ts +12 -0
  144. package/dist/production/lib/dom/ssr/fog-of-war.js +180 -0
  145. package/dist/production/lib/dom/ssr/hydration.d.ts +32 -0
  146. package/dist/production/lib/dom/ssr/hydration.js +29 -0
  147. package/dist/production/lib/dom/ssr/invariant.js +16 -0
  148. package/dist/production/lib/dom/ssr/links.js +170 -0
  149. package/dist/production/lib/dom/ssr/markup.js +24 -0
  150. package/dist/production/lib/dom/ssr/routeModules.d.ts +206 -0
  151. package/dist/production/lib/dom/ssr/routeModules.js +31 -0
  152. package/dist/production/lib/dom/ssr/routes-test-stub.d.ts +62 -0
  153. package/dist/production/lib/dom/ssr/routes-test-stub.js +108 -0
  154. package/dist/production/lib/dom/ssr/routes.d.ts +33 -0
  155. package/dist/production/lib/dom/ssr/routes.js +303 -0
  156. package/dist/production/lib/dom/ssr/server.d.ts +48 -0
  157. package/dist/production/lib/dom/ssr/server.js +69 -0
  158. package/dist/production/lib/dom/ssr/single-fetch.d.ts +14 -0
  159. package/dist/production/lib/dom/ssr/single-fetch.js +345 -0
  160. package/dist/production/lib/dom-export/dom-router-provider.d.ts +9 -0
  161. package/dist/production/lib/dom-export/dom-router-provider.js +22 -0
  162. package/dist/production/lib/dom-export/hydrated-router.d.ts +125 -0
  163. package/dist/production/lib/dom-export/hydrated-router.js +150 -0
  164. package/dist/production/lib/errors.js +29 -0
  165. package/dist/production/lib/hooks.d.ts +947 -0
  166. package/dist/production/lib/hooks.js +1373 -0
  167. package/dist/production/lib/href.d.ts +20 -0
  168. package/dist/production/lib/href.js +50 -0
  169. package/dist/production/lib/router/history.d.ts +258 -0
  170. package/dist/production/lib/router/history.js +372 -0
  171. package/dist/production/lib/router/instrumentation.d.ts +86 -0
  172. package/dist/production/lib/router/instrumentation.js +213 -0
  173. package/dist/production/lib/router/links.d.ts +114 -0
  174. package/dist/production/lib/router/router.d.ts +663 -0
  175. package/dist/production/lib/router/router.js +2988 -0
  176. package/dist/production/lib/router/url.js +18 -0
  177. package/dist/production/lib/router/utils.d.ts +948 -0
  178. package/dist/production/lib/router/utils.js +801 -0
  179. package/dist/production/lib/rsc/browser.d.ts +137 -0
  180. package/dist/production/lib/rsc/browser.js +603 -0
  181. package/dist/production/lib/rsc/errorBoundaries.d.ts +11 -0
  182. package/dist/production/lib/rsc/errorBoundaries.js +90 -0
  183. package/dist/production/lib/rsc/html-stream/browser.d.ts +48 -0
  184. package/dist/production/lib/rsc/html-stream/browser.js +74 -0
  185. package/dist/production/lib/rsc/html-stream/server.js +78 -0
  186. package/dist/production/lib/rsc/route-modules.js +27 -0
  187. package/dist/production/lib/rsc/server.rsc.d.ts +219 -0
  188. package/dist/production/lib/rsc/server.ssr.d.ts +129 -0
  189. package/dist/production/lib/rsc/server.ssr.js +404 -0
  190. package/dist/production/lib/server-runtime/build.d.ts +66 -0
  191. package/dist/production/lib/server-runtime/cookies.d.ts +66 -0
  192. package/dist/production/lib/server-runtime/cookies.js +139 -0
  193. package/dist/production/lib/server-runtime/crypto.js +43 -0
  194. package/dist/production/lib/server-runtime/data.d.ts +13 -0
  195. package/dist/production/lib/server-runtime/data.js +25 -0
  196. package/dist/production/lib/server-runtime/dev.d.ts +9 -0
  197. package/dist/production/lib/server-runtime/dev.js +26 -0
  198. package/dist/production/lib/server-runtime/entry.js +20 -0
  199. package/dist/production/lib/server-runtime/errors.js +75 -0
  200. package/dist/production/lib/server-runtime/headers.js +73 -0
  201. package/dist/production/lib/server-runtime/invariant.js +19 -0
  202. package/dist/production/lib/server-runtime/mode.d.ts +12 -0
  203. package/dist/production/lib/server-runtime/mode.js +25 -0
  204. package/dist/production/lib/server-runtime/routeMatching.js +28 -0
  205. package/dist/production/lib/server-runtime/routes.d.ts +13 -0
  206. package/dist/production/lib/server-runtime/routes.js +74 -0
  207. package/dist/production/lib/server-runtime/server.d.ts +10 -0
  208. package/dist/production/lib/server-runtime/server.js +345 -0
  209. package/dist/production/lib/server-runtime/serverHandoff.js +17 -0
  210. package/dist/production/lib/server-runtime/sessions/cookieStorage.d.ts +25 -0
  211. package/dist/production/lib/server-runtime/sessions/cookieStorage.js +45 -0
  212. package/dist/production/lib/server-runtime/sessions/memoryStorage.d.ts +23 -0
  213. package/dist/production/lib/server-runtime/sessions/memoryStorage.js +52 -0
  214. package/dist/production/lib/server-runtime/sessions.d.ts +145 -0
  215. package/dist/production/lib/server-runtime/sessions.js +98 -0
  216. package/dist/production/lib/server-runtime/single-fetch.d.ts +7 -0
  217. package/dist/production/lib/server-runtime/single-fetch.js +215 -0
  218. package/dist/production/lib/server-runtime/urls.js +28 -0
  219. package/dist/production/lib/server-runtime/warnings.js +20 -0
  220. package/dist/production/lib/types/future.d.ts +9 -0
  221. package/dist/production/lib/types/internal.d.ts +26 -177
  222. package/dist/production/lib/types/internal.js +3 -2
  223. package/dist/production/{register-roq_0qYo.d.ts → lib/types/register.d.ts} +9 -15
  224. package/dist/production/lib/types/route-data.d.ts +113 -0
  225. package/dist/production/lib/types/route-module-annotations.d.ts +149 -0
  226. package/dist/production/lib/types/route-module.d.ts +19 -0
  227. package/dist/production/lib/types/serializes-to.d.ts +13 -0
  228. package/dist/production/lib/types/utils.d.ts +11 -0
  229. package/dist/production/vendor/turbo-stream-v2/flatten.js +159 -0
  230. package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +179 -0
  231. package/dist/production/vendor/turbo-stream-v2/unflatten.js +199 -0
  232. package/dist/production/vendor/turbo-stream-v2/utils.js +39 -0
  233. package/docs/explanation/code-splitting.md +16 -0
  234. package/docs/how-to/middleware.md +6 -41
  235. package/docs/how-to/react-server-components.md +1 -1
  236. package/docs/upgrading/future.md +0 -249
  237. package/package.json +43 -87
  238. package/dist/development/browser-B2PdsXXH.d.ts +0 -318
  239. package/dist/development/browser-DBmQ1yAR.d.mts +0 -318
  240. package/dist/development/chunk-4ZMWKKQ3.mjs +0 -11606
  241. package/dist/development/chunk-E4MTK73K.mjs +0 -2517
  242. package/dist/development/chunk-U7ORXROY.js +0 -10307
  243. package/dist/development/chunk-WW7PN6QI.js +0 -188
  244. package/dist/development/chunk-YL5M26XI.js +0 -1366
  245. package/dist/development/context-CeD5LmaF.d.mts +0 -1779
  246. package/dist/development/data-CjO11-hU.d.ts +0 -1740
  247. package/dist/development/data-DEjBmEfD.d.mts +0 -1740
  248. package/dist/development/dom-export.d.mts +0 -172
  249. package/dist/development/dom-export.mjs +0 -1010
  250. package/dist/development/index-react-server-client-3ykjivgQ.d.ts +0 -3677
  251. package/dist/development/index-react-server-client-CACgcj2J.d.mts +0 -2614
  252. package/dist/development/index-react-server-client.d.mts +0 -4
  253. package/dist/development/index-react-server-client.mjs +0 -59
  254. package/dist/development/index-react-server.d.mts +0 -2711
  255. package/dist/development/index-react-server.mjs +0 -3803
  256. package/dist/development/index.d.mts +0 -1479
  257. package/dist/development/index.mjs +0 -275
  258. package/dist/development/instrumentation-Dkmpzd13.d.ts +0 -715
  259. package/dist/development/lib/types/internal.d.mts +0 -184
  260. package/dist/development/lib/types/internal.mjs +0 -10
  261. package/dist/development/register-CmkRspdl.d.mts +0 -30
  262. package/dist/production/browser-B2PdsXXH.d.ts +0 -318
  263. package/dist/production/browser-DBmQ1yAR.d.mts +0 -318
  264. package/dist/production/chunk-3Z6WS2WZ.js +0 -188
  265. package/dist/production/chunk-BIP66BKV.js +0 -1366
  266. package/dist/production/chunk-EGOTSXNH.mjs +0 -2517
  267. package/dist/production/chunk-IUPBOWYO.js +0 -10307
  268. package/dist/production/chunk-M7NGGUU6.mjs +0 -11606
  269. package/dist/production/context-CeD5LmaF.d.mts +0 -1779
  270. package/dist/production/data-CjO11-hU.d.ts +0 -1740
  271. package/dist/production/data-DEjBmEfD.d.mts +0 -1740
  272. package/dist/production/dom-export.d.mts +0 -172
  273. package/dist/production/dom-export.mjs +0 -1010
  274. package/dist/production/index-react-server-client-3ykjivgQ.d.ts +0 -3677
  275. package/dist/production/index-react-server-client-CACgcj2J.d.mts +0 -2614
  276. package/dist/production/index-react-server-client.d.mts +0 -4
  277. package/dist/production/index-react-server-client.mjs +0 -59
  278. package/dist/production/index-react-server.d.mts +0 -2711
  279. package/dist/production/index-react-server.mjs +0 -3803
  280. package/dist/production/index.d.mts +0 -1479
  281. package/dist/production/index.mjs +0 -275
  282. package/dist/production/instrumentation-Dkmpzd13.d.ts +0 -715
  283. package/dist/production/lib/types/internal.d.mts +0 -184
  284. package/dist/production/lib/types/internal.mjs +0 -10
  285. package/dist/production/register-CmkRspdl.d.mts +0 -30
@@ -1,93 +1,94 @@
1
- import * as React from 'react';
2
- export { BrowserRouter, Form, HashRouter, Link, Links, MemoryRouter, Meta, NavLink, Navigate, Outlet, Route, Router, RouterProvider, Routes, ScrollRestoration, StaticRouter, StaticRouterProvider, unstable_HistoryRouter } from 'react-router/internal/react-server-client';
3
- import { ParseOptions, SerializeOptions } from 'cookie';
4
- export { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions } from 'cookie';
5
1
 
2
+ import * as React from "react";
3
+ import { CookieParseOptions, CookieParseOptions as CookieParseOptions$1, CookieSerializeOptions, CookieSerializeOptions as CookieSerializeOptions$1 } from "cookie-es";
4
+ import { BrowserRouter, Form, HashRouter, Link, Links, MemoryRouter, Meta, NavLink, Navigate, Outlet, Route, Router, RouterProvider, Routes, ScrollRestoration, StaticRouter, StaticRouterProvider, unstable_HistoryRouter } from "react-router/internal/react-server-client";
5
+
6
+ //#region lib/router/history.d.ts
6
7
  /**
7
8
  * Actions represent the type of change to a location value.
8
9
  */
9
10
  declare enum Action {
10
- /**
11
- * A POP indicates a change to an arbitrary index in the history stack, such
12
- * as a back or forward navigation. It does not describe the direction of the
13
- * navigation, only that the current index changed.
14
- *
15
- * Note: This is the default action for newly created history objects.
16
- */
17
- Pop = "POP",
18
- /**
19
- * A PUSH indicates a new entry being added to the history stack, such as when
20
- * a link is clicked and a new page loads. When this happens, all subsequent
21
- * entries in the stack are lost.
22
- */
23
- Push = "PUSH",
24
- /**
25
- * A REPLACE indicates the entry at the current index in the history stack
26
- * being replaced by a new one.
27
- */
28
- Replace = "REPLACE"
11
+ /**
12
+ * A POP indicates a change to an arbitrary index in the history stack, such
13
+ * as a back or forward navigation. It does not describe the direction of the
14
+ * navigation, only that the current index changed.
15
+ *
16
+ * Note: This is the default action for newly created history objects.
17
+ */
18
+ Pop = "POP",
19
+ /**
20
+ * A PUSH indicates a new entry being added to the history stack, such as when
21
+ * a link is clicked and a new page loads. When this happens, all subsequent
22
+ * entries in the stack are lost.
23
+ */
24
+ Push = "PUSH",
25
+ /**
26
+ * A REPLACE indicates the entry at the current index in the history stack
27
+ * being replaced by a new one.
28
+ */
29
+ Replace = "REPLACE"
29
30
  }
30
31
  /**
31
32
  * The pathname, search, and hash values of a URL.
32
33
  */
33
34
  interface Path {
34
- /**
35
- * A URL pathname, beginning with a /.
36
- */
37
- pathname: string;
38
- /**
39
- * A URL search string, beginning with a ?.
40
- */
41
- search: string;
42
- /**
43
- * A URL fragment identifier, beginning with a #.
44
- */
45
- hash: string;
35
+ /**
36
+ * A URL pathname, beginning with a /.
37
+ */
38
+ pathname: string;
39
+ /**
40
+ * A URL search string, beginning with a ?.
41
+ */
42
+ search: string;
43
+ /**
44
+ * A URL fragment identifier, beginning with a #.
45
+ */
46
+ hash: string;
46
47
  }
47
48
  /**
48
49
  * An entry in a history stack. A location contains information about the
49
50
  * URL path, as well as possibly some arbitrary state and a key.
50
51
  */
51
52
  interface Location<State = any> extends Path {
52
- /**
53
- * A value of arbitrary data associated with this location.
54
- */
55
- state: State;
56
- /**
57
- * A unique string associated with this location. May be used to safely store
58
- * and retrieve data in some other storage API, like `localStorage`.
59
- *
60
- * Note: This value is always "default" on the initial location.
61
- */
62
- key: string;
63
- /**
64
- * The masked location displayed in the URL bar, which differs from the URL the
65
- * router is operating on
66
- */
67
- mask?: Path;
53
+ /**
54
+ * A value of arbitrary data associated with this location.
55
+ */
56
+ state: State;
57
+ /**
58
+ * A unique string associated with this location. May be used to safely store
59
+ * and retrieve data in some other storage API, like `localStorage`.
60
+ *
61
+ * Note: This value is always "default" on the initial location.
62
+ */
63
+ key: string;
64
+ /**
65
+ * The masked location displayed in the URL bar, which differs from the URL the
66
+ * router is operating on
67
+ */
68
+ mask?: Path;
68
69
  }
69
70
  /**
70
71
  * A change to the current location.
71
72
  */
72
73
  interface Update {
73
- /**
74
- * The action that triggered the change.
75
- */
76
- action: Action;
77
- /**
78
- * The new location.
79
- */
80
- location: Location;
81
- /**
82
- * The delta between this location and the former location in the history stack
83
- */
84
- delta: number | null;
74
+ /**
75
+ * The action that triggered the change.
76
+ */
77
+ action: Action;
78
+ /**
79
+ * The new location.
80
+ */
81
+ location: Location;
82
+ /**
83
+ * The delta between this location and the former location in the history stack
84
+ */
85
+ delta: number | null;
85
86
  }
86
87
  /**
87
88
  * A function that receives notifications about location changes.
88
89
  */
89
90
  interface Listener {
90
- (update: Update): void;
91
+ (update: Update): void;
91
92
  }
92
93
  /**
93
94
  * Describes a location that is the destination of some navigation used in
@@ -103,86 +104,77 @@ type To = string | Partial<Path>;
103
104
  * focused API.
104
105
  */
105
106
  interface History {
106
- /**
107
- * The last action that modified the current location. This will always be
108
- * Action.Pop when a history instance is first created. This value is mutable.
109
- */
110
- readonly action: Action;
111
- /**
112
- * The current location. This value is mutable.
113
- */
114
- readonly location: Location;
115
- /**
116
- * Returns a valid href for the given `to` value that may be used as
117
- * the value of an <a href> attribute.
118
- *
119
- * @param to - The destination URL
120
- */
121
- createHref(to: To): string;
122
- /**
123
- * Returns a URL for the given `to` value
124
- *
125
- * @param to - The destination URL
126
- */
127
- createURL(to: To): URL;
128
- /**
129
- * Encode a location the same way window.history would do (no-op for memory
130
- * history) so we ensure our PUSH/REPLACE navigations for data routers
131
- * behave the same as POP
132
- *
133
- * @param to Unencoded path
134
- */
135
- encodeLocation(to: To): Path;
136
- /**
137
- * Pushes a new location onto the history stack, increasing its length by one.
138
- * If there were any entries in the stack after the current one, they are
139
- * lost.
140
- *
141
- * @param to - The new URL
142
- * @param state - Data to associate with the new location
143
- */
144
- push(to: To, state?: any): void;
145
- /**
146
- * Replaces the current location in the history stack with a new one. The
147
- * location that was replaced will no longer be available.
148
- *
149
- * @param to - The new URL
150
- * @param state - Data to associate with the new location
151
- */
152
- replace(to: To, state?: any): void;
153
- /**
154
- * Navigates `n` entries backward/forward in the history stack relative to the
155
- * current index. For example, a "back" navigation would use go(-1).
156
- *
157
- * @param delta - The delta in the stack index
158
- */
159
- go(delta: number): void;
160
- /**
161
- * Sets up a listener that will be called whenever the current location
162
- * changes.
163
- *
164
- * @param listener - A function that will be called when the location changes
165
- * @returns unlisten - A function that may be used to stop listening
166
- */
167
- listen(listener: Listener): () => void;
107
+ /**
108
+ * The last action that modified the current location. This will always be
109
+ * Action.Pop when a history instance is first created. This value is mutable.
110
+ */
111
+ readonly action: Action;
112
+ /**
113
+ * The current location. This value is mutable.
114
+ */
115
+ readonly location: Location;
116
+ /**
117
+ * Returns a valid href for the given `to` value that may be used as
118
+ * the value of an <a href> attribute.
119
+ *
120
+ * @param to - The destination URL
121
+ */
122
+ createHref(to: To): string;
123
+ /**
124
+ * Returns a URL for the given `to` value
125
+ *
126
+ * @param to - The destination URL
127
+ */
128
+ createURL(to: To): URL;
129
+ /**
130
+ * Encode a location the same way window.history would do (no-op for memory
131
+ * history) so we ensure our PUSH/REPLACE navigations for data routers
132
+ * behave the same as POP
133
+ *
134
+ * @param to Unencoded path
135
+ */
136
+ encodeLocation(to: To): Path;
137
+ /**
138
+ * Pushes a new location onto the history stack, increasing its length by one.
139
+ * If there were any entries in the stack after the current one, they are
140
+ * lost.
141
+ *
142
+ * @param to - The new URL
143
+ * @param state - Data to associate with the new location
144
+ */
145
+ push(to: To, state?: any): void;
146
+ /**
147
+ * Replaces the current location in the history stack with a new one. The
148
+ * location that was replaced will no longer be available.
149
+ *
150
+ * @param to - The new URL
151
+ * @param state - Data to associate with the new location
152
+ */
153
+ replace(to: To, state?: any): void;
154
+ /**
155
+ * Navigates `n` entries backward/forward in the history stack relative to the
156
+ * current index. For example, a "back" navigation would use go(-1).
157
+ *
158
+ * @param delta - The delta in the stack index
159
+ */
160
+ go(delta: number): void;
161
+ /**
162
+ * Sets up a listener that will be called whenever the current location
163
+ * changes.
164
+ *
165
+ * @param listener - A function that will be called when the location changes
166
+ * @returns unlisten - A function that may be used to stop listening
167
+ */
168
+ listen(listener: Listener): () => void;
168
169
  }
169
-
170
- /**
171
- * An augmentable interface users can modify in their app-code to opt into
172
- * future-flag-specific types
173
- */
174
- interface Future {
175
- }
176
- type MiddlewareEnabled = Future extends {
177
- v8_middleware: infer T extends boolean;
178
- } ? T : false;
179
-
170
+ //#endregion
171
+ //#region lib/router/utils.d.ts
180
172
  type MaybePromise<T> = T | Promise<T>;
181
173
  /**
182
174
  * Map of routeId -> data returned from a loader/action/error
183
175
  */
184
176
  interface RouteData {
185
- [routeId: string]: any;
177
+ [routeId: string]: any;
186
178
  }
187
179
  type LowerCaseFormMethod = "get" | "post" | "put" | "patch" | "delete";
188
180
  type UpperCaseFormMethod = Uppercase<LowerCaseFormMethod>;
@@ -197,11 +189,7 @@ type HTMLFormMethod = LowerCaseFormMethod | UpperCaseFormMethod;
197
189
  */
198
190
  type FormMethod = UpperCaseFormMethod;
199
191
  type FormEncType = "application/x-www-form-urlencoded" | "multipart/form-data" | "application/json" | "text/plain";
200
- type JsonObject = {
201
- [Key in string]: JsonValue;
202
- } & {
203
- [Key in string]?: JsonValue | undefined;
204
- };
192
+ type JsonObject = { [Key in string]: JsonValue } & { [Key in string]?: JsonValue | undefined };
205
193
  type JsonArray = JsonValue[] | readonly JsonValue[];
206
194
  type JsonPrimitive = string | number | boolean | null;
207
195
  type JsonValue = JsonPrimitive | JsonObject | JsonArray;
@@ -211,26 +199,26 @@ type JsonValue = JsonPrimitive | JsonObject | JsonArray;
211
199
  * external consumption
212
200
  */
213
201
  type Submission = {
214
- formMethod: FormMethod;
215
- formAction: string;
216
- formEncType: FormEncType;
217
- formData: FormData;
218
- json: undefined;
219
- text: undefined;
202
+ formMethod: FormMethod;
203
+ formAction: string;
204
+ formEncType: FormEncType;
205
+ formData: FormData;
206
+ json: undefined;
207
+ text: undefined;
220
208
  } | {
221
- formMethod: FormMethod;
222
- formAction: string;
223
- formEncType: FormEncType;
224
- formData: undefined;
225
- json: JsonValue;
226
- text: undefined;
209
+ formMethod: FormMethod;
210
+ formAction: string;
211
+ formEncType: FormEncType;
212
+ formData: undefined;
213
+ json: JsonValue;
214
+ text: undefined;
227
215
  } | {
228
- formMethod: FormMethod;
229
- formAction: string;
230
- formEncType: FormEncType;
231
- formData: undefined;
232
- json: undefined;
233
- text: string;
216
+ formMethod: FormMethod;
217
+ formAction: string;
218
+ formEncType: FormEncType;
219
+ formData: undefined;
220
+ json: undefined;
221
+ text: string;
234
222
  };
235
223
  /**
236
224
  * A context instance used as the key for the `get`/`set` methods of a
@@ -238,7 +226,7 @@ type Submission = {
238
226
  * value to be returned if no value has been set.
239
227
  */
240
228
  interface RouterContext<T = unknown> {
241
- defaultValue?: T;
229
+ defaultValue?: T;
242
230
  }
243
231
  /**
244
232
  * Creates a type-safe {@link RouterContext} object that can be used to
@@ -322,82 +310,82 @@ declare function createContext<T>(defaultValue?: T): RouterContext<T>;
322
310
  * @mode data
323
311
  */
324
312
  declare class RouterContextProvider {
325
- #private;
326
- /**
327
- * Create a new `RouterContextProvider` instance
328
- * @param init An optional initial context map to populate the provider with
329
- */
330
- constructor(init?: Map<RouterContext, unknown>);
331
- /**
332
- * Access a value from the context. If no value has been set for the context,
333
- * it will return the context's `defaultValue` if provided, or throw an error
334
- * if no `defaultValue` was set.
335
- * @param context The context to get the value for
336
- * @returns The value for the context, or the context's `defaultValue` if no
337
- * value was set
338
- */
339
- get<T>(context: RouterContext<T>): T;
340
- /**
341
- * Set a value for the context. If the context already has a value set, this
342
- * will overwrite it.
343
- *
344
- * @param context The context to set the value for
345
- * @param value The value to set for the context
346
- * @returns {void}
347
- */
348
- set<C extends RouterContext>(context: C, value: C extends RouterContext<infer T> ? T : never): void;
313
+ #private;
314
+ /**
315
+ * Create a new `RouterContextProvider` instance
316
+ * @param init An optional initial context map to populate the provider with
317
+ */
318
+ constructor(init?: Map<RouterContext, unknown>);
319
+ /**
320
+ * Access a value from the context. If no value has been set for the context,
321
+ * it will return the context's `defaultValue` if provided, or throw an error
322
+ * if no `defaultValue` was set.
323
+ * @param context The context to get the value for
324
+ * @returns The value for the context, or the context's `defaultValue` if no
325
+ * value was set
326
+ */
327
+ get<T>(context: RouterContext<T>): T;
328
+ /**
329
+ * Set a value for the context. If the context already has a value set, this
330
+ * will overwrite it.
331
+ *
332
+ * @param context The context to set the value for
333
+ * @param value The value to set for the context
334
+ * @returns {void}
335
+ */
336
+ set<C extends RouterContext>(context: C, value: C extends RouterContext<infer T> ? T : never): void;
349
337
  }
350
- type DefaultContext = MiddlewareEnabled extends true ? Readonly<RouterContextProvider> : any;
338
+ type DefaultContext = Readonly<RouterContextProvider>;
351
339
  /**
352
340
  * @private
353
341
  * Arguments passed to route loader/action functions. Same for now but we keep
354
342
  * this as a private implementation detail in case they diverge in the future.
355
343
  */
356
344
  interface DataFunctionArgs<Context> {
357
- /** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read headers (like cookies, and {@link https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams URLSearchParams} from the request. */
358
- request: Request;
359
- /**
360
- * A URL instance representing the application location being navigated to or
361
- * fetched. By default, this matches `request.url`.
362
- *
363
- * In Framework mode with `future.v8_passThroughRequests` enabled, this is a
364
- * normalized URL with React-Router-specific implementation details removed
365
- * (`.data` suffixes, `index`/`_routes` search params).
366
- */
367
- url: URL;
368
- /**
369
- * Matched un-interpolated route pattern for the current path (i.e., /blog/:slug).
370
- * Mostly useful as a identifier to aggregate on for logging/tracing/etc.
371
- */
372
- pattern: string;
373
- /**
374
- * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
375
- * @example
376
- * // app/routes.ts
377
- * route("teams/:teamId", "./team.tsx"),
378
- *
379
- * // app/team.tsx
380
- * export function loader({
381
- * params,
382
- * }: Route.LoaderArgs) {
383
- * params.teamId;
384
- * // ^ string
385
- * }
386
- */
387
- params: Params;
388
- /**
389
- * This is the context passed in to your server adapter's getLoadContext() function.
390
- * It's a way to bridge the gap between the adapter's request/response API with your React Router app.
391
- * It is only applicable if you are using a custom server adapter.
392
- */
393
- context: Context;
345
+ /** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read headers (like cookies, and {@link https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams URLSearchParams} from the request. */
346
+ request: Request;
347
+ /**
348
+ * A URL instance representing the application location being navigated to or
349
+ * fetched.
350
+ *
351
+ * In Framework mode, this is a normalized URL with React-Router-specific
352
+ * implementation details removed (`.data` suffixes, `index`/`_routes` search
353
+ * params). For the raw incoming URL, use `request.url`.
354
+ */
355
+ url: URL;
356
+ /**
357
+ * Matched un-interpolated route pattern for the current path (i.e., /blog/:slug).
358
+ * Mostly useful as a identifier to aggregate on for logging/tracing/etc.
359
+ */
360
+ pattern: string;
361
+ /**
362
+ * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
363
+ * @example
364
+ * // app/routes.ts
365
+ * route("teams/:teamId", "./team.tsx"),
366
+ *
367
+ * // app/team.tsx
368
+ * export function loader({
369
+ * params,
370
+ * }: Route.LoaderArgs) {
371
+ * params.teamId;
372
+ * // ^ string
373
+ * }
374
+ */
375
+ params: Params;
376
+ /**
377
+ * This is the context passed in to your server adapter's getLoadContext() function.
378
+ * It's a way to bridge the gap between the adapter's request/response API with your React Router app.
379
+ * It is only applicable if you are using a custom server adapter.
380
+ */
381
+ context: Context;
394
382
  }
395
383
  /**
396
384
  * Route middleware `next` function to call downstream handlers and then complete
397
385
  * middlewares from the bottom-up
398
386
  */
399
387
  interface MiddlewareNextFunction<Result = unknown> {
400
- (): Promise<Result>;
388
+ (): Promise<Result>;
401
389
  }
402
390
  /**
403
391
  * Route middleware function signature. Receives the same "data" arguments as a
@@ -409,13 +397,11 @@ type MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<Readonly<Rou
409
397
  /**
410
398
  * Arguments passed to loader functions
411
399
  */
412
- interface LoaderFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
413
- }
400
+ interface LoaderFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {}
414
401
  /**
415
402
  * Arguments passed to action functions
416
403
  */
417
- interface ActionFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
418
- }
404
+ interface ActionFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {}
419
405
  /**
420
406
  * Loaders and actions can return anything
421
407
  */
@@ -425,71 +411,71 @@ type DataFunctionReturnValue = MaybePromise<DataFunctionValue>;
425
411
  * Route loader function signature
426
412
  */
427
413
  type LoaderFunction<Context = DefaultContext> = {
428
- (args: LoaderFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
414
+ (args: LoaderFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
429
415
  } & {
430
- hydrate?: boolean;
416
+ hydrate?: boolean;
431
417
  };
432
418
  /**
433
419
  * Route action function signature
434
420
  */
435
421
  interface ActionFunction<Context = DefaultContext> {
436
- (args: ActionFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
422
+ (args: ActionFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
437
423
  }
438
424
  /**
439
425
  * Arguments passed to shouldRevalidate function
440
426
  */
441
427
  interface ShouldRevalidateFunctionArgs {
442
- /** This is the url the navigation started from. You can compare it with `nextUrl` to decide if you need to revalidate this route's data. */
443
- currentUrl: URL;
444
- /** These are the {@link https://reactrouter.com/start/framework/routing#dynamic-segments dynamic route params} from the URL that can be compared to the `nextParams` to decide if you need to reload or not. Perhaps you're using only a partial piece of the param for data loading, you don't need to revalidate if a superfluous part of the param changed. */
445
- currentParams: DataRouteMatch["params"];
446
- /** In the case of navigation, this the URL the user is requesting. Some revalidations are not navigation, so it will simply be the same as currentUrl. */
447
- nextUrl: URL;
448
- /** In the case of navigation, these are the {@link https://reactrouter.com/start/framework/routing#dynamic-segments dynamic route params} from the next location the user is requesting. Some revalidations are not navigation, so it will simply be the same as currentParams. */
449
- nextParams: DataRouteMatch["params"];
450
- /** The method (probably `"GET"` or `"POST"`) used in the form submission that triggered the revalidation. */
451
- formMethod?: Submission["formMethod"];
452
- /** The form action (`<Form action="/somewhere">`) that triggered the revalidation. */
453
- formAction?: Submission["formAction"];
454
- /** The form encType (`<Form encType="application/x-www-form-urlencoded">) used in the form submission that triggered the revalidation*/
455
- formEncType?: Submission["formEncType"];
456
- /** The form submission data when the form's encType is `text/plain` */
457
- text?: Submission["text"];
458
- /** The form submission data when the form's encType is `application/x-www-form-urlencoded` or `multipart/form-data` */
459
- formData?: Submission["formData"];
460
- /** The form submission data when the form's encType is `application/json` */
461
- json?: Submission["json"];
462
- /** The status code of the action response */
463
- actionStatus?: number;
464
- /**
465
- * When a submission causes the revalidation this will be the result of the action—either action data or an error if the action failed. It's common to include some information in the action result to instruct shouldRevalidate to revalidate or not.
466
- *
467
- * @example
468
- * export async function action() {
469
- * await saveSomeStuff();
470
- * return { ok: true };
471
- * }
472
- *
473
- * export function shouldRevalidate({
474
- * actionResult,
475
- * }) {
476
- * if (actionResult?.ok) {
477
- * return false;
478
- * }
479
- * return true;
480
- * }
481
- */
482
- actionResult?: any;
483
- /**
484
- * By default, React Router doesn't call every loader all the time. There are reliable optimizations it can make by default. For example, only loaders with changing params are called. Consider navigating from the following URL to the one below it:
485
- *
486
- * /projects/123/tasks/abc
487
- * /projects/123/tasks/def
488
- * React Router will only call the loader for tasks/def because the param for projects/123 didn't change.
489
- *
490
- * It's safest to always return defaultShouldRevalidate after you've done your specific optimizations that return false, otherwise your UI might get out of sync with your data on the server.
491
- */
492
- defaultShouldRevalidate: boolean;
428
+ /** This is the url the navigation started from. You can compare it with `nextUrl` to decide if you need to revalidate this route's data. */
429
+ currentUrl: URL;
430
+ /** These are the {@link https://reactrouter.com/start/framework/routing#dynamic-segments dynamic route params} from the URL that can be compared to the `nextParams` to decide if you need to reload or not. Perhaps you're using only a partial piece of the param for data loading, you don't need to revalidate if a superfluous part of the param changed. */
431
+ currentParams: DataRouteMatch["params"];
432
+ /** In the case of navigation, this the URL the user is requesting. Some revalidations are not navigation, so it will simply be the same as currentUrl. */
433
+ nextUrl: URL;
434
+ /** In the case of navigation, these are the {@link https://reactrouter.com/start/framework/routing#dynamic-segments dynamic route params} from the next location the user is requesting. Some revalidations are not navigation, so it will simply be the same as currentParams. */
435
+ nextParams: DataRouteMatch["params"];
436
+ /** The method (probably `"GET"` or `"POST"`) used in the form submission that triggered the revalidation. */
437
+ formMethod?: Submission["formMethod"];
438
+ /** The form action (`<Form action="/somewhere">`) that triggered the revalidation. */
439
+ formAction?: Submission["formAction"];
440
+ /** The form encType (`<Form encType="application/x-www-form-urlencoded">) used in the form submission that triggered the revalidation*/
441
+ formEncType?: Submission["formEncType"];
442
+ /** The form submission data when the form's encType is `text/plain` */
443
+ text?: Submission["text"];
444
+ /** The form submission data when the form's encType is `application/x-www-form-urlencoded` or `multipart/form-data` */
445
+ formData?: Submission["formData"];
446
+ /** The form submission data when the form's encType is `application/json` */
447
+ json?: Submission["json"];
448
+ /** The status code of the action response */
449
+ actionStatus?: number;
450
+ /**
451
+ * When a submission causes the revalidation this will be the result of the action—either action data or an error if the action failed. It's common to include some information in the action result to instruct shouldRevalidate to revalidate or not.
452
+ *
453
+ * @example
454
+ * export async function action() {
455
+ * await saveSomeStuff();
456
+ * return { ok: true };
457
+ * }
458
+ *
459
+ * export function shouldRevalidate({
460
+ * actionResult,
461
+ * }) {
462
+ * if (actionResult?.ok) {
463
+ * return false;
464
+ * }
465
+ * return true;
466
+ * }
467
+ */
468
+ actionResult?: any;
469
+ /**
470
+ * By default, React Router doesn't call every loader all the time. There are reliable optimizations it can make by default. For example, only loaders with changing params are called. Consider navigating from the following URL to the one below it:
471
+ *
472
+ * /projects/123/tasks/abc
473
+ * /projects/123/tasks/def
474
+ * React Router will only call the loader for tasks/def because the param for projects/123 didn't change.
475
+ *
476
+ * It's safest to always return defaultShouldRevalidate after you've done your specific optimizations that return false, otherwise your UI might get out of sync with your data on the server.
477
+ */
478
+ defaultShouldRevalidate: boolean;
493
479
  }
494
480
  /**
495
481
  * Route shouldRevalidate function signature. This runs after any submission
@@ -499,113 +485,111 @@ interface ShouldRevalidateFunctionArgs {
499
485
  * have to re-run based on the data models that were potentially mutated.
500
486
  */
501
487
  interface ShouldRevalidateFunction {
502
- (args: ShouldRevalidateFunctionArgs): boolean;
488
+ (args: ShouldRevalidateFunctionArgs): boolean;
503
489
  }
504
490
  interface DataStrategyMatch extends RouteMatch<string, DataRouteObject> {
505
- /**
506
- * @private
507
- */
508
- _lazyPromises?: {
509
- middleware: Promise<void> | undefined;
510
- handler: Promise<void> | undefined;
511
- route: Promise<void> | undefined;
512
- };
513
- /**
514
- * @deprecated Deprecated in favor of `shouldCallHandler`
515
- *
516
- * A boolean value indicating whether this route handler should be called in
517
- * this pass.
518
- *
519
- * The `matches` array always includes _all_ matched routes even when only
520
- * _some_ route handlers need to be called so that things like middleware can
521
- * be implemented.
522
- *
523
- * `shouldLoad` is usually only interesting if you are skipping the route
524
- * handler entirely and implementing custom handler logic - since it lets you
525
- * determine if that custom logic should run for this route or not.
526
- *
527
- * For example:
528
- * - If you are on `/parent/child/a` and you navigate to `/parent/child/b` -
529
- * you'll get an array of three matches (`[parent, child, b]`), but only `b`
530
- * will have `shouldLoad=true` because the data for `parent` and `child` is
531
- * already loaded
532
- * - If you are on `/parent/child/a` and you submit to `a`'s [`action`](https://reactrouter.com/docs/start/data/route-object#action),
533
- * then only `a` will have `shouldLoad=true` for the action execution of
534
- * `dataStrategy`
535
- * - After the [`action`](https://reactrouter.com/docs/start/data/route-object#action),
536
- * `dataStrategy` will be called again for the [`loader`](https://reactrouter.com/docs/start/data/route-object#loader)
537
- * revalidation, and all matches will have `shouldLoad=true` (assuming no
538
- * custom `shouldRevalidate` implementations)
539
- */
540
- shouldLoad: boolean;
541
- /**
542
- * Arguments passed to the `shouldRevalidate` function for this `loader` execution.
543
- * Will be `null` if this is not a revalidating loader {@link DataStrategyMatch}.
544
- */
545
- shouldRevalidateArgs: ShouldRevalidateFunctionArgs | null;
546
- /**
547
- * Determine if this route's handler should be called during this `dataStrategy`
548
- * execution. Calling it with no arguments will leverage the default revalidation
549
- * behavior. You can pass your own `defaultShouldRevalidate` value if you wish
550
- * to change the default revalidation behavior with your `dataStrategy`.
551
- *
552
- * @param defaultShouldRevalidate `defaultShouldRevalidate` override value (optional)
553
- */
554
- shouldCallHandler(defaultShouldRevalidate?: boolean): boolean;
555
- /**
556
- * An async function that will resolve any `route.lazy` implementations and
557
- * execute the route's handler (if necessary), returning a {@link DataStrategyResult}
558
- *
559
- * - Calling `match.resolve` does not mean you're calling the
560
- * [`action`](https://reactrouter.com/docs/start/data/route-object#action)/[`loader`](https://reactrouter.com/docs/start/data/route-object#loader)
561
- * (the "handler") - `resolve` will only call the `handler` internally if
562
- * needed _and_ if you don't pass your own `handlerOverride` function parameter
563
- * - It is safe to call `match.resolve` for all matches, even if they have
564
- * `shouldLoad=false`, and it will no-op if no loading is required
565
- * - You should generally always call `match.resolve()` for `shouldLoad:true`
566
- * routes to ensure that any `route.lazy` implementations are processed
567
- * - See the examples below for how to implement custom handler execution via
568
- * `match.resolve`
569
- */
570
- resolve: (handlerOverride?: (handler: (ctx?: unknown) => DataFunctionReturnValue) => DataFunctionReturnValue) => Promise<DataStrategyResult>;
491
+ /**
492
+ * @private
493
+ */
494
+ _lazyPromises?: {
495
+ middleware: Promise<void> | undefined;
496
+ handler: Promise<void> | undefined;
497
+ route: Promise<void> | undefined;
498
+ };
499
+ /**
500
+ * @deprecated Deprecated in favor of `shouldCallHandler`
501
+ *
502
+ * A boolean value indicating whether this route handler should be called in
503
+ * this pass.
504
+ *
505
+ * The `matches` array always includes _all_ matched routes even when only
506
+ * _some_ route handlers need to be called so that things like middleware can
507
+ * be implemented.
508
+ *
509
+ * `shouldLoad` is usually only interesting if you are skipping the route
510
+ * handler entirely and implementing custom handler logic - since it lets you
511
+ * determine if that custom logic should run for this route or not.
512
+ *
513
+ * For example:
514
+ * - If you are on `/parent/child/a` and you navigate to `/parent/child/b` -
515
+ * you'll get an array of three matches (`[parent, child, b]`), but only `b`
516
+ * will have `shouldLoad=true` because the data for `parent` and `child` is
517
+ * already loaded
518
+ * - If you are on `/parent/child/a` and you submit to `a`'s [`action`](https://reactrouter.com/docs/start/data/route-object#action),
519
+ * then only `a` will have `shouldLoad=true` for the action execution of
520
+ * `dataStrategy`
521
+ * - After the [`action`](https://reactrouter.com/docs/start/data/route-object#action),
522
+ * `dataStrategy` will be called again for the [`loader`](https://reactrouter.com/docs/start/data/route-object#loader)
523
+ * revalidation, and all matches will have `shouldLoad=true` (assuming no
524
+ * custom `shouldRevalidate` implementations)
525
+ */
526
+ shouldLoad: boolean;
527
+ /**
528
+ * Arguments passed to the `shouldRevalidate` function for this `loader` execution.
529
+ * Will be `null` if this is not a revalidating loader {@link DataStrategyMatch}.
530
+ */
531
+ shouldRevalidateArgs: ShouldRevalidateFunctionArgs | null;
532
+ /**
533
+ * Determine if this route's handler should be called during this `dataStrategy`
534
+ * execution. Calling it with no arguments will leverage the default revalidation
535
+ * behavior. You can pass your own `defaultShouldRevalidate` value if you wish
536
+ * to change the default revalidation behavior with your `dataStrategy`.
537
+ *
538
+ * @param defaultShouldRevalidate `defaultShouldRevalidate` override value (optional)
539
+ */
540
+ shouldCallHandler(defaultShouldRevalidate?: boolean): boolean;
541
+ /**
542
+ * An async function that will resolve any `route.lazy` implementations and
543
+ * execute the route's handler (if necessary), returning a {@link DataStrategyResult}
544
+ *
545
+ * - Calling `match.resolve` does not mean you're calling the
546
+ * [`action`](https://reactrouter.com/docs/start/data/route-object#action)/[`loader`](https://reactrouter.com/docs/start/data/route-object#loader)
547
+ * (the "handler") - `resolve` will only call the `handler` internally if
548
+ * needed _and_ if you don't pass your own `handlerOverride` function parameter
549
+ * - It is safe to call `match.resolve` for all matches, even if they have
550
+ * `shouldLoad=false`, and it will no-op if no loading is required
551
+ * - You should generally always call `match.resolve()` for `shouldLoad:true`
552
+ * routes to ensure that any `route.lazy` implementations are processed
553
+ * - See the examples below for how to implement custom handler execution via
554
+ * `match.resolve`
555
+ */
556
+ resolve: (handlerOverride?: (handler: (ctx?: unknown) => DataFunctionReturnValue) => DataFunctionReturnValue) => Promise<DataStrategyResult>;
571
557
  }
572
558
  interface DataStrategyFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
573
- /**
574
- * Matches for this route extended with Data strategy APIs
575
- */
576
- matches: DataStrategyMatch[];
577
- runClientMiddleware: (cb: DataStrategyFunction<Context>) => Promise<Record<string, DataStrategyResult>>;
578
- /**
579
- * The key of the fetcher we are calling `dataStrategy` for, otherwise `null`
580
- * for navigational executions
581
- */
582
- fetcherKey: string | null;
559
+ /**
560
+ * Matches for this route extended with Data strategy APIs
561
+ */
562
+ matches: DataStrategyMatch[];
563
+ runClientMiddleware: (cb: DataStrategyFunction<Context>) => Promise<Record<string, DataStrategyResult>>;
564
+ /**
565
+ * The key of the fetcher we are calling `dataStrategy` for, otherwise `null`
566
+ * for navigational executions
567
+ */
568
+ fetcherKey: string | null;
583
569
  }
584
570
  /**
585
571
  * Result from a loader or action called via dataStrategy
586
572
  */
587
573
  interface DataStrategyResult {
588
- type: "data" | "error";
589
- result: unknown;
574
+ type: "data" | "error";
575
+ result: unknown;
590
576
  }
591
577
  interface DataStrategyFunction<Context = DefaultContext> {
592
- (args: DataStrategyFunctionArgs<Context>): Promise<Record<string, DataStrategyResult>>;
578
+ (args: DataStrategyFunctionArgs<Context>): Promise<Record<string, DataStrategyResult>>;
593
579
  }
594
580
  type PatchRoutesOnNavigationFunctionArgs = {
595
- signal: AbortSignal;
596
- path: string;
597
- matches: RouteMatch[];
598
- fetcherKey: string | undefined;
599
- patch: (routeId: string | null, children: RouteObject[]) => void;
581
+ signal: AbortSignal;
582
+ path: string;
583
+ matches: RouteMatch[];
584
+ fetcherKey: string | undefined;
585
+ patch: (routeId: string | null, children: RouteObject[]) => void;
600
586
  };
601
587
  type PatchRoutesOnNavigationFunction = (opts: PatchRoutesOnNavigationFunctionArgs) => MaybePromise<void>;
602
588
  /**
603
589
  * Function provided to set route-specific properties from route objects
604
590
  */
605
591
  interface MapRoutePropertiesFunction {
606
- (route: DataRouteObject): {
607
- hasErrorBoundary: boolean;
608
- } & Record<string, any>;
592
+ (route: DataRouteObject): Partial<DataRouteObject>;
609
593
  }
610
594
  /**
611
595
  * Keys we cannot change from within a lazy object. We spread all other keys
@@ -623,15 +607,13 @@ type UnsupportedLazyRouteFunctionKey = UnsupportedLazyRouteObjectKey | "middlewa
623
607
  * lazy object to load route properties, which can add non-matching
624
608
  * related properties to a route
625
609
  */
626
- type LazyRouteObject<R extends RouteObject> = {
627
- [K in keyof R as K extends UnsupportedLazyRouteObjectKey ? never : K]?: () => Promise<R[K] | null | undefined>;
628
- };
610
+ type LazyRouteObject<R extends RouteObject> = { [K in keyof R as K extends UnsupportedLazyRouteObjectKey ? never : K]?: () => Promise<R[K] | null | undefined> };
629
611
  /**
630
612
  * lazy() function to load a route definition, which can add non-matching
631
613
  * related properties to a route
632
614
  */
633
615
  interface LazyRouteFunction<R extends RouteObject> {
634
- (): Promise<Omit<R, UnsupportedLazyRouteFunctionKey> & Partial<Record<UnsupportedLazyRouteFunctionKey, never>>>;
616
+ (): Promise<Omit<R, UnsupportedLazyRouteFunctionKey> & Partial<Record<UnsupportedLazyRouteFunctionKey, never>>>;
635
617
  }
636
618
  type LazyRouteDefinition<R extends RouteObject> = LazyRouteObject<R> | LazyRouteFunction<R>;
637
619
  /**
@@ -639,106 +621,105 @@ type LazyRouteDefinition<R extends RouteObject> = LazyRouteObject<R> | LazyRoute
639
621
  * @internal
640
622
  */
641
623
  type BaseRouteObject = {
642
- /**
643
- * Whether the path should be case-sensitive. Defaults to `false`.
644
- */
645
- caseSensitive?: boolean;
646
- /**
647
- * The path pattern to match. If unspecified or empty, then this becomes a
648
- * layout route.
649
- */
650
- path?: string;
651
- /**
652
- * The unique identifier for this route (for use with {@link DataRouter}s)
653
- */
654
- id?: string;
655
- /**
656
- * The route middleware.
657
- * See [`middleware`](../../start/data/route-object#middleware).
658
- */
659
- middleware?: MiddlewareFunction[];
660
- /**
661
- * The route loader.
662
- * See [`loader`](../../start/data/route-object#loader).
663
- */
664
- loader?: LoaderFunction | boolean;
665
- /**
666
- * The route action.
667
- * See [`action`](../../start/data/route-object#action).
668
- */
669
- action?: ActionFunction | boolean;
670
- hasErrorBoundary?: boolean;
671
- /**
672
- * The route shouldRevalidate function.
673
- * See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
674
- */
675
- shouldRevalidate?: ShouldRevalidateFunction;
676
- /**
677
- * The route handle.
678
- */
679
- handle?: any;
680
- /**
681
- * A function that returns a promise that resolves to the route object.
682
- * Used for code-splitting routes.
683
- * See [`lazy`](../../start/data/route-object#lazy).
684
- */
685
- lazy?: LazyRouteDefinition<BaseRouteObject>;
686
- /**
687
- * The React Component to render when this route matches.
688
- * Mutually exclusive with `element`.
689
- */
690
- Component?: React.ComponentType | null;
691
- /**
692
- * The React element to render when this Route matches.
693
- * Mutually exclusive with `Component`.
694
- */
695
- element?: React.ReactNode | null;
696
- /**
697
- * The React Component to render at this route if an error occurs.
698
- * Mutually exclusive with `errorElement`.
699
- */
700
- ErrorBoundary?: React.ComponentType | null;
701
- /**
702
- * The React element to render at this route if an error occurs.
703
- * Mutually exclusive with `ErrorBoundary`.
704
- */
705
- errorElement?: React.ReactNode | null;
706
- /**
707
- * The React Component to render while this router is loading data.
708
- * Mutually exclusive with `hydrateFallbackElement`.
709
- */
710
- HydrateFallback?: React.ComponentType | null;
711
- /**
712
- * The React element to render while this router is loading data.
713
- * Mutually exclusive with `HydrateFallback`.
714
- */
715
- hydrateFallbackElement?: React.ReactNode | null;
624
+ /**
625
+ * Whether the path should be case-sensitive. Defaults to `false`.
626
+ */
627
+ caseSensitive?: boolean;
628
+ /**
629
+ * The path pattern to match. If unspecified or empty, then this becomes a
630
+ * layout route.
631
+ */
632
+ path?: string;
633
+ /**
634
+ * The unique identifier for this route (for use with {@link DataRouter}s)
635
+ */
636
+ id?: string;
637
+ /**
638
+ * The route middleware.
639
+ * See [`middleware`](../../start/data/route-object#middleware).
640
+ */
641
+ middleware?: MiddlewareFunction[];
642
+ /**
643
+ * The route loader.
644
+ * See [`loader`](../../start/data/route-object#loader).
645
+ */
646
+ loader?: LoaderFunction | boolean;
647
+ /**
648
+ * The route action.
649
+ * See [`action`](../../start/data/route-object#action).
650
+ */
651
+ action?: ActionFunction | boolean;
652
+ /**
653
+ * The route shouldRevalidate function.
654
+ * See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
655
+ */
656
+ shouldRevalidate?: ShouldRevalidateFunction;
657
+ /**
658
+ * The route handle.
659
+ */
660
+ handle?: any;
661
+ /**
662
+ * A function that returns a promise that resolves to the route object.
663
+ * Used for code-splitting routes.
664
+ * See [`lazy`](../../start/data/route-object#lazy).
665
+ */
666
+ lazy?: LazyRouteDefinition<BaseRouteObject>;
667
+ /**
668
+ * The React Component to render when this route matches.
669
+ * Mutually exclusive with `element`.
670
+ */
671
+ Component?: React.ComponentType | null;
672
+ /**
673
+ * The React element to render when this Route matches.
674
+ * Mutually exclusive with `Component`.
675
+ */
676
+ element?: React.ReactNode | null;
677
+ /**
678
+ * The React Component to render at this route if an error occurs.
679
+ * Mutually exclusive with `errorElement`.
680
+ */
681
+ ErrorBoundary?: React.ComponentType | null;
682
+ /**
683
+ * The React element to render at this route if an error occurs.
684
+ * Mutually exclusive with `ErrorBoundary`.
685
+ */
686
+ errorElement?: React.ReactNode | null;
687
+ /**
688
+ * The React Component to render while this router is loading data.
689
+ * Mutually exclusive with `hydrateFallbackElement`.
690
+ */
691
+ HydrateFallback?: React.ComponentType | null;
692
+ /**
693
+ * The React element to render while this router is loading data.
694
+ * Mutually exclusive with `HydrateFallback`.
695
+ */
696
+ hydrateFallbackElement?: React.ReactNode | null;
716
697
  };
717
698
  /**
718
699
  * Index routes must not have children
719
700
  */
720
701
  type IndexRouteObject = BaseRouteObject & {
721
- /**
722
- * Child Route objects - not valid on index routes.
723
- */
724
- children?: undefined;
725
- /**
726
- * Whether this is an index route.
727
- */
728
- index: true;
702
+ /**
703
+ * Child Route objects - not valid on index routes.
704
+ */
705
+ children?: undefined;
706
+ /**
707
+ * Whether this is an index route.
708
+ */
709
+ index: true;
729
710
  };
730
711
  /**
731
712
  * Non-index routes may have children, but cannot have `index` set to `true`.
732
713
  */
733
714
  type NonIndexRouteObject = BaseRouteObject & {
734
- /**
735
- * Child Route objects.
736
- */
737
- children?: RouteObject[];
738
- /**
739
- * Whether this is an index route - must be `false` or undefined on non-index routes.
740
- */
741
- index?: false;
715
+ /**
716
+ * Child Route objects.
717
+ */
718
+ children?: RouteObject[];
719
+ /**
720
+ * Whether this is an index route - must be `false` or undefined on non-index routes.
721
+ */
722
+ index?: false;
742
723
  };
743
724
  /**
744
725
  * A route object represents a logical route, with (optionally) its child
@@ -746,11 +727,11 @@ type NonIndexRouteObject = BaseRouteObject & {
746
727
  */
747
728
  type RouteObject = IndexRouteObject | NonIndexRouteObject;
748
729
  type DataIndexRouteObject = IndexRouteObject & {
749
- id: string;
730
+ id: string;
750
731
  };
751
732
  type DataNonIndexRouteObject = NonIndexRouteObject & {
752
- children?: DataRouteObject[];
753
- id: string;
733
+ children?: DataRouteObject[];
734
+ id: string;
754
735
  };
755
736
  /**
756
737
  * A data route object, which is just a RouteObject with a required unique ID
@@ -760,32 +741,29 @@ type RouteManifest<R = DataRouteObject> = Record<string, R | undefined>;
760
741
  /**
761
742
  * The parameters that were parsed from the URL path.
762
743
  */
763
- type Params<Key extends string = string> = {
764
- readonly [key in Key]: string | undefined;
765
- };
744
+ type Params<Key extends string = string> = { readonly [key in Key]: string | undefined };
766
745
  /**
767
746
  * A RouteMatch contains info about how a route matched a URL.
768
747
  */
769
748
  interface RouteMatch<ParamKey extends string = string, RouteObjectType extends RouteObject = RouteObject> {
770
- /**
771
- * The names and values of dynamic parameters in the URL.
772
- */
773
- params: Params<ParamKey>;
774
- /**
775
- * The portion of the URL pathname that was matched.
776
- */
777
- pathname: string;
778
- /**
779
- * The portion of the URL pathname that was matched before child routes.
780
- */
781
- pathnameBase: string;
782
- /**
783
- * The route object that was used to match.
784
- */
785
- route: RouteObjectType;
786
- }
787
- interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {
749
+ /**
750
+ * The names and values of dynamic parameters in the URL.
751
+ */
752
+ params: Params<ParamKey>;
753
+ /**
754
+ * The portion of the URL pathname that was matched.
755
+ */
756
+ pathname: string;
757
+ /**
758
+ * The portion of the URL pathname that was matched before child routes.
759
+ */
760
+ pathnameBase: string;
761
+ /**
762
+ * The route object that was used to match.
763
+ */
764
+ route: RouteObjectType;
788
765
  }
766
+ interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {}
789
767
  /**
790
768
  * Matches the given routes to a location and returns the match data.
791
769
  *
@@ -814,39 +792,31 @@ interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {
814
792
  */
815
793
  declare function matchRoutes<RouteObjectType extends RouteObject = RouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename?: string): RouteMatch<string, RouteObjectType>[] | null;
816
794
  interface UIMatch<Data = unknown, Handle = unknown> {
817
- id: string;
818
- pathname: string;
819
- /**
820
- * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the matched route.
821
- */
822
- params: RouteMatch["params"];
823
- /**
824
- * The return value from the matched route's loader or clientLoader. This might
825
- * be `undefined` if this route's `loader` (or a deeper route's `loader`) threw
826
- * an error and we're currently displaying an `ErrorBoundary`.
827
- *
828
- * @deprecated Use `UIMatch.loaderData` instead
829
- */
830
- data: Data | undefined;
831
- /**
832
- * The return value from the matched route's loader or clientLoader. This might
833
- * be `undefined` if this route's `loader` (or a deeper route's `loader`) threw
834
- * an error and we're currently displaying an `ErrorBoundary`.
835
- */
836
- loaderData: Data | undefined;
837
- /**
838
- * The {@link https://reactrouter.com/start/framework/route-module#handle handle object}
839
- * exported from the matched route module
840
- */
841
- handle: Handle;
795
+ id: string;
796
+ pathname: string;
797
+ /**
798
+ * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the matched route.
799
+ */
800
+ params: RouteMatch["params"];
801
+ /**
802
+ * The return value from the matched route's loader or clientLoader. This might
803
+ * be `undefined` if this route's `loader` (or a deeper route's `loader`) threw
804
+ * an error and we're currently displaying an `ErrorBoundary`.
805
+ */
806
+ loaderData: Data | undefined;
807
+ /**
808
+ * The {@link https://reactrouter.com/start/framework/route-module#handle handle object}
809
+ * exported from the matched route module
810
+ */
811
+ handle: Handle;
842
812
  }
843
813
  interface RouteMeta<RouteObjectType extends RouteObject = RouteObject> {
844
- relativePath: string;
845
- caseSensitive: boolean;
846
- childrenIndex: number;
847
- route: RouteObjectType;
848
- matcher?: RegExp;
849
- compiledParams?: CompiledPathParam[];
814
+ relativePath: string;
815
+ caseSensitive: boolean;
816
+ childrenIndex: number;
817
+ route: RouteObjectType;
818
+ matcher?: RegExp;
819
+ compiledParams?: CompiledPathParam[];
850
820
  }
851
821
  /**
852
822
  * @private
@@ -856,19 +826,19 @@ interface RouteMeta<RouteObjectType extends RouteObject = RouteObject> {
856
826
  * This is an internal interface not intended for direct external usage.
857
827
  */
858
828
  interface RouteBranch<RouteObjectType extends RouteObject = RouteObject> {
859
- path: string;
860
- score: number;
861
- routesMeta: RouteMeta<RouteObjectType>[];
829
+ path: string;
830
+ score: number;
831
+ routesMeta: RouteMeta<RouteObjectType>[];
862
832
  }
863
833
  type CompiledPathParam = {
864
- paramName: string;
865
- isOptional?: boolean;
834
+ paramName: string;
835
+ isOptional?: boolean;
866
836
  };
867
837
  declare class DataWithResponseInit<D> {
868
- type: string;
869
- data: D;
870
- init: ResponseInit | null;
871
- constructor(data: D, init?: ResponseInit);
838
+ type: string;
839
+ data: D;
840
+ init: ResponseInit | null;
841
+ constructor(data: D, init?: ResponseInit);
872
842
  }
873
843
  /**
874
844
  * Create "responses" that contain `headers`/`status` without forcing
@@ -988,11 +958,11 @@ declare const redirectDocument$1: RedirectFunction;
988
958
  * object with the redirect status and [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
989
959
  * header.
990
960
  */
991
- declare const replace$1: RedirectFunction;
961
+ declare const replace$2: RedirectFunction;
992
962
  type ErrorResponse = {
993
- status: number;
994
- statusText: string;
995
- data: any;
963
+ status: number;
964
+ statusText: string;
965
+ data: any;
996
966
  };
997
967
  /**
998
968
  * Check if the given error is an {@link ErrorResponse} generated from a 4xx/5xx
@@ -1026,383 +996,375 @@ type ErrorResponse = {
1026
996
  * @returns `true` if the error is an {@link ErrorResponse}, `false` otherwise.
1027
997
  */
1028
998
  declare function isRouteErrorResponse(error: any): error is ErrorResponse;
1029
-
1030
- /**
1031
- * An object of unknown type for route loaders and actions provided by the
1032
- * server's `getLoadContext()` function. This is defined as an empty interface
1033
- * specifically so apps can leverage declaration merging to augment this type
1034
- * globally: https://www.typescriptlang.org/docs/handbook/declaration-merging.html
1035
- */
1036
- interface AppLoadContext {
1037
- [key: string]: unknown;
1038
- }
1039
-
999
+ //#endregion
1000
+ //#region lib/router/instrumentation.d.ts
1040
1001
  type ServerInstrumentation = {
1041
- handler?: InstrumentRequestHandlerFunction;
1042
- route?: InstrumentRouteFunction;
1002
+ handler?: InstrumentRequestHandlerFunction;
1003
+ route?: InstrumentRouteFunction;
1043
1004
  };
1044
1005
  type ClientInstrumentation = {
1045
- router?: InstrumentRouterFunction;
1046
- route?: InstrumentRouteFunction;
1006
+ router?: InstrumentRouterFunction;
1007
+ route?: InstrumentRouteFunction;
1047
1008
  };
1048
1009
  type InstrumentRequestHandlerFunction = (handler: InstrumentableRequestHandler) => void;
1049
1010
  type InstrumentRouterFunction = (router: InstrumentableRouter) => void;
1050
1011
  type InstrumentRouteFunction = (route: InstrumentableRoute) => void;
1051
1012
  type InstrumentationHandlerResult = {
1052
- status: "success";
1053
- error: undefined;
1013
+ status: "success";
1014
+ error: undefined;
1054
1015
  } | {
1055
- status: "error";
1056
- error: Error;
1016
+ status: "error";
1017
+ error: Error;
1057
1018
  };
1058
1019
  type InstrumentFunction<T> = (handler: () => Promise<InstrumentationHandlerResult>, info: T) => Promise<void>;
1059
1020
  type ReadonlyRequest = {
1060
- method: string;
1061
- url: string;
1062
- headers: Pick<Headers, "get">;
1021
+ method: string;
1022
+ url: string;
1023
+ headers: Pick<Headers, "get">;
1063
1024
  };
1064
- type ReadonlyContext = MiddlewareEnabled extends true ? Pick<RouterContextProvider, "get"> : Readonly<AppLoadContext>;
1025
+ type ReadonlyContext = Pick<RouterContextProvider, "get">;
1065
1026
  type InstrumentableRoute = {
1066
- id: string;
1067
- index: boolean | undefined;
1068
- path: string | undefined;
1069
- instrument(instrumentations: RouteInstrumentations): void;
1027
+ id: string;
1028
+ index: boolean | undefined;
1029
+ path: string | undefined;
1030
+ instrument(instrumentations: RouteInstrumentations): void;
1070
1031
  };
1071
1032
  type RouteInstrumentations = {
1072
- lazy?: InstrumentFunction<RouteLazyInstrumentationInfo>;
1073
- "lazy.loader"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
1074
- "lazy.action"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
1075
- "lazy.middleware"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
1076
- middleware?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
1077
- loader?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
1078
- action?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
1033
+ lazy?: InstrumentFunction<RouteLazyInstrumentationInfo>;
1034
+ "lazy.loader"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
1035
+ "lazy.action"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
1036
+ "lazy.middleware"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
1037
+ middleware?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
1038
+ loader?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
1039
+ action?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
1079
1040
  };
1080
1041
  type RouteLazyInstrumentationInfo = undefined;
1081
1042
  type RouteHandlerInstrumentationInfo = Readonly<{
1082
- request: ReadonlyRequest;
1083
- params: LoaderFunctionArgs["params"];
1084
- pattern: string;
1085
- context: ReadonlyContext;
1043
+ request: ReadonlyRequest;
1044
+ params: LoaderFunctionArgs["params"];
1045
+ pattern: string;
1046
+ context: ReadonlyContext;
1086
1047
  }>;
1087
1048
  type InstrumentableRouter = {
1088
- instrument(instrumentations: RouterInstrumentations): void;
1049
+ instrument(instrumentations: RouterInstrumentations): void;
1089
1050
  };
1090
1051
  type RouterInstrumentations = {
1091
- navigate?: InstrumentFunction<RouterNavigationInstrumentationInfo>;
1092
- fetch?: InstrumentFunction<RouterFetchInstrumentationInfo>;
1052
+ navigate?: InstrumentFunction<RouterNavigationInstrumentationInfo>;
1053
+ fetch?: InstrumentFunction<RouterFetchInstrumentationInfo>;
1093
1054
  };
1094
1055
  type RouterNavigationInstrumentationInfo = Readonly<{
1095
- to: string | number;
1096
- currentUrl: string;
1097
- formMethod?: HTMLFormMethod;
1098
- formEncType?: FormEncType;
1099
- formData?: FormData;
1100
- body?: any;
1056
+ to: string | number;
1057
+ currentUrl: string;
1058
+ formMethod?: HTMLFormMethod;
1059
+ formEncType?: FormEncType;
1060
+ formData?: FormData;
1061
+ body?: any;
1101
1062
  }>;
1102
1063
  type RouterFetchInstrumentationInfo = Readonly<{
1103
- href: string;
1104
- currentUrl: string;
1105
- fetcherKey: string;
1106
- formMethod?: HTMLFormMethod;
1107
- formEncType?: FormEncType;
1108
- formData?: FormData;
1109
- body?: any;
1064
+ href: string;
1065
+ currentUrl: string;
1066
+ fetcherKey: string;
1067
+ formMethod?: HTMLFormMethod;
1068
+ formEncType?: FormEncType;
1069
+ formData?: FormData;
1070
+ body?: any;
1110
1071
  }>;
1111
1072
  type InstrumentableRequestHandler = {
1112
- instrument(instrumentations: RequestHandlerInstrumentations): void;
1073
+ instrument(instrumentations: RequestHandlerInstrumentations): void;
1113
1074
  };
1114
1075
  type RequestHandlerInstrumentations = {
1115
- request?: InstrumentFunction<RequestHandlerInstrumentationInfo>;
1076
+ request?: InstrumentFunction<RequestHandlerInstrumentationInfo>;
1116
1077
  };
1117
1078
  type RequestHandlerInstrumentationInfo = Readonly<{
1118
- request: ReadonlyRequest;
1119
- context: ReadonlyContext | undefined;
1079
+ request: ReadonlyRequest;
1080
+ context: ReadonlyContext | undefined;
1120
1081
  }>;
1121
-
1082
+ //#endregion
1083
+ //#region lib/router/router.d.ts
1122
1084
  /**
1123
1085
  * A Router instance manages all navigation and data loading/mutations
1124
1086
  */
1125
- interface Router {
1126
- /**
1127
- * @private
1128
- * PRIVATE - DO NOT USE
1129
- *
1130
- * Return the basename for the router
1131
- */
1132
- get basename(): RouterInit["basename"];
1133
- /**
1134
- * @private
1135
- * PRIVATE - DO NOT USE
1136
- *
1137
- * Return the future config for the router
1138
- */
1139
- get future(): FutureConfig;
1140
- /**
1141
- * @private
1142
- * PRIVATE - DO NOT USE
1143
- *
1144
- * Return the current state of the router
1145
- */
1146
- get state(): RouterState;
1147
- /**
1148
- * @private
1149
- * PRIVATE - DO NOT USE
1150
- *
1151
- * Return the routes for this router instance
1152
- */
1153
- get routes(): DataRouteObject[];
1154
- /**
1155
- * @private
1156
- * PRIVATE - DO NOT USE
1157
- *
1158
- * Return the route branches for this router instance
1159
- */
1160
- get branches(): RouteBranch<DataRouteObject>[] | undefined;
1161
- /**
1162
- * @private
1163
- * PRIVATE - DO NOT USE
1164
- *
1165
- * Return the manifest for this router instance
1166
- */
1167
- get manifest(): RouteManifest;
1168
- /**
1169
- * @private
1170
- * PRIVATE - DO NOT USE
1171
- *
1172
- * Return the window associated with the router
1173
- */
1174
- get window(): RouterInit["window"];
1175
- /**
1176
- * @private
1177
- * PRIVATE - DO NOT USE
1178
- *
1179
- * Initialize the router, including adding history listeners and kicking off
1180
- * initial data fetches. Returns a function to cleanup listeners and abort
1181
- * any in-progress loads
1182
- */
1183
- initialize(): Router;
1184
- /**
1185
- * @private
1186
- * PRIVATE - DO NOT USE
1187
- *
1188
- * Subscribe to router.state updates
1189
- *
1190
- * @param fn function to call with the new state
1191
- */
1192
- subscribe(fn: RouterSubscriber): () => void;
1193
- /**
1194
- * @private
1195
- * PRIVATE - DO NOT USE
1196
- *
1197
- * Enable scroll restoration behavior in the router
1198
- *
1199
- * @param savedScrollPositions Object that will manage positions, in case
1200
- * it's being restored from sessionStorage
1201
- * @param getScrollPosition Function to get the active Y scroll position
1202
- * @param getKey Function to get the key to use for restoration
1203
- */
1204
- enableScrollRestoration(savedScrollPositions: Record<string, number>, getScrollPosition: GetScrollPositionFunction, getKey?: GetScrollRestorationKeyFunction): () => void;
1205
- /**
1206
- * @private
1207
- * PRIVATE - DO NOT USE
1208
- *
1209
- * Navigate forward/backward in the history stack
1210
- * @param to Delta to move in the history stack
1211
- */
1212
- navigate(to: number): Promise<void>;
1213
- /**
1214
- * Navigate to the given path
1215
- * @param to Path to navigate to
1216
- * @param opts Navigation options (method, submission, etc.)
1217
- */
1218
- navigate(to: To | null, opts?: RouterNavigateOptions): Promise<void>;
1219
- /**
1220
- * @private
1221
- * PRIVATE - DO NOT USE
1222
- *
1223
- * Trigger a fetcher load/submission
1224
- *
1225
- * @param key Fetcher key
1226
- * @param routeId Route that owns the fetcher
1227
- * @param href href to fetch
1228
- * @param opts Fetcher options, (method, submission, etc.)
1229
- */
1230
- fetch(key: string, routeId: string, href: string | null, opts?: RouterFetchOptions): Promise<void>;
1231
- /**
1232
- * @private
1233
- * PRIVATE - DO NOT USE
1234
- *
1235
- * Trigger a revalidation of all current route loaders and fetcher loads
1236
- */
1237
- revalidate(): Promise<void>;
1238
- /**
1239
- * @private
1240
- * PRIVATE - DO NOT USE
1241
- *
1242
- * Utility function to create an href for the given location
1243
- * @param location
1244
- */
1245
- createHref(location: Location | URL): string;
1246
- /**
1247
- * @private
1248
- * PRIVATE - DO NOT USE
1249
- *
1250
- * Utility function to URL encode a destination path according to the internal
1251
- * history implementation
1252
- * @param to
1253
- */
1254
- encodeLocation(to: To): Path;
1255
- /**
1256
- * @private
1257
- * PRIVATE - DO NOT USE
1258
- *
1259
- * Get/create a fetcher for the given key
1260
- * @param key
1261
- */
1262
- getFetcher<TData = any>(key: string): Fetcher<TData>;
1263
- /**
1264
- * @internal
1265
- * PRIVATE - DO NOT USE
1266
- *
1267
- * Reset the fetcher for a given key
1268
- * @param key
1269
- */
1270
- resetFetcher(key: string, opts?: {
1271
- reason?: unknown;
1272
- }): void;
1273
- /**
1274
- * @private
1275
- * PRIVATE - DO NOT USE
1276
- *
1277
- * Delete the fetcher for a given key
1278
- * @param key
1279
- */
1280
- deleteFetcher(key: string): void;
1281
- /**
1282
- * @private
1283
- * PRIVATE - DO NOT USE
1284
- *
1285
- * Cleanup listeners and abort any in-progress loads
1286
- */
1287
- dispose(): void;
1288
- /**
1289
- * @private
1290
- * PRIVATE - DO NOT USE
1291
- *
1292
- * Get a navigation blocker
1293
- * @param key The identifier for the blocker
1294
- * @param fn The blocker function implementation
1295
- */
1296
- getBlocker(key: string, fn: BlockerFunction): Blocker;
1297
- /**
1298
- * @private
1299
- * PRIVATE - DO NOT USE
1300
- *
1301
- * Delete a navigation blocker
1302
- * @param key The identifier for the blocker
1303
- */
1304
- deleteBlocker(key: string): void;
1305
- /**
1306
- * @private
1307
- * PRIVATE DO NOT USE
1308
- *
1309
- * Patch additional children routes into an existing parent route
1310
- * @param routeId The parent route id or a callback function accepting `patch`
1311
- * to perform batch patching
1312
- * @param children The additional children routes
1313
- * @param unstable_allowElementMutations Allow mutation or route elements on
1314
- * existing routes. Intended for RSC-usage
1315
- * only.
1316
- */
1317
- patchRoutes(routeId: string | null, children: RouteObject[], unstable_allowElementMutations?: boolean): void;
1318
- /**
1319
- * @private
1320
- * PRIVATE - DO NOT USE
1321
- *
1322
- * HMR needs to pass in-flight route updates to React Router
1323
- * TODO: Replace this with granular route update APIs (addRoute, updateRoute, deleteRoute)
1324
- */
1325
- _internalSetRoutes(routes: RouteObject[]): void;
1326
- /**
1327
- * @private
1328
- * PRIVATE - DO NOT USE
1329
- *
1330
- * Cause subscribers to re-render. This is used to force a re-render.
1331
- */
1332
- _internalSetStateDoNotUseOrYouWillBreakYourApp(state: Partial<RouterState>): void;
1333
- /**
1334
- * @private
1335
- * PRIVATE - DO NOT USE
1336
- *
1337
- * Internal fetch AbortControllers accessed by unit tests
1338
- */
1339
- _internalFetchControllers: Map<string, AbortController>;
1087
+ interface Router$1 {
1088
+ /**
1089
+ * @private
1090
+ * PRIVATE - DO NOT USE
1091
+ *
1092
+ * Return the basename for the router
1093
+ */
1094
+ get basename(): RouterInit["basename"];
1095
+ /**
1096
+ * @private
1097
+ * PRIVATE - DO NOT USE
1098
+ *
1099
+ * Return the future config for the router
1100
+ */
1101
+ get future(): FutureConfig;
1102
+ /**
1103
+ * @private
1104
+ * PRIVATE - DO NOT USE
1105
+ *
1106
+ * Return the current state of the router
1107
+ */
1108
+ get state(): RouterState;
1109
+ /**
1110
+ * @private
1111
+ * PRIVATE - DO NOT USE
1112
+ *
1113
+ * Return the routes for this router instance
1114
+ */
1115
+ get routes(): DataRouteObject[];
1116
+ /**
1117
+ * @private
1118
+ * PRIVATE - DO NOT USE
1119
+ *
1120
+ * Return the route branches for this router instance
1121
+ */
1122
+ get branches(): RouteBranch<DataRouteObject>[] | undefined;
1123
+ /**
1124
+ * @private
1125
+ * PRIVATE - DO NOT USE
1126
+ *
1127
+ * Return the manifest for this router instance
1128
+ */
1129
+ get manifest(): RouteManifest;
1130
+ /**
1131
+ * @private
1132
+ * PRIVATE - DO NOT USE
1133
+ *
1134
+ * Return the window associated with the router
1135
+ */
1136
+ get window(): RouterInit["window"];
1137
+ /**
1138
+ * @private
1139
+ * PRIVATE - DO NOT USE
1140
+ *
1141
+ * Initialize the router, including adding history listeners and kicking off
1142
+ * initial data fetches. Returns a function to cleanup listeners and abort
1143
+ * any in-progress loads
1144
+ */
1145
+ initialize(): Router$1;
1146
+ /**
1147
+ * @private
1148
+ * PRIVATE - DO NOT USE
1149
+ *
1150
+ * Subscribe to router.state updates
1151
+ *
1152
+ * @param fn function to call with the new state
1153
+ */
1154
+ subscribe(fn: RouterSubscriber): () => void;
1155
+ /**
1156
+ * @private
1157
+ * PRIVATE - DO NOT USE
1158
+ *
1159
+ * Enable scroll restoration behavior in the router
1160
+ *
1161
+ * @param savedScrollPositions Object that will manage positions, in case
1162
+ * it's being restored from sessionStorage
1163
+ * @param getScrollPosition Function to get the active Y scroll position
1164
+ * @param getKey Function to get the key to use for restoration
1165
+ */
1166
+ enableScrollRestoration(savedScrollPositions: Record<string, number>, getScrollPosition: GetScrollPositionFunction, getKey?: GetScrollRestorationKeyFunction): () => void;
1167
+ /**
1168
+ * @private
1169
+ * PRIVATE - DO NOT USE
1170
+ *
1171
+ * Navigate forward/backward in the history stack
1172
+ * @param to Delta to move in the history stack
1173
+ */
1174
+ navigate(to: number): Promise<void>;
1175
+ /**
1176
+ * Navigate to the given path
1177
+ * @param to Path to navigate to
1178
+ * @param opts Navigation options (method, submission, etc.)
1179
+ */
1180
+ navigate(to: To | null, opts?: RouterNavigateOptions): Promise<void>;
1181
+ /**
1182
+ * @private
1183
+ * PRIVATE - DO NOT USE
1184
+ *
1185
+ * Trigger a fetcher load/submission
1186
+ *
1187
+ * @param key Fetcher key
1188
+ * @param routeId Route that owns the fetcher
1189
+ * @param href href to fetch
1190
+ * @param opts Fetcher options, (method, submission, etc.)
1191
+ */
1192
+ fetch(key: string, routeId: string, href: string | null, opts?: RouterFetchOptions): Promise<void>;
1193
+ /**
1194
+ * @private
1195
+ * PRIVATE - DO NOT USE
1196
+ *
1197
+ * Trigger a revalidation of all current route loaders and fetcher loads
1198
+ */
1199
+ revalidate(): Promise<void>;
1200
+ /**
1201
+ * @private
1202
+ * PRIVATE - DO NOT USE
1203
+ *
1204
+ * Utility function to create an href for the given location
1205
+ * @param location
1206
+ */
1207
+ createHref(location: Location | URL): string;
1208
+ /**
1209
+ * @private
1210
+ * PRIVATE - DO NOT USE
1211
+ *
1212
+ * Utility function to URL encode a destination path according to the internal
1213
+ * history implementation
1214
+ * @param to
1215
+ */
1216
+ encodeLocation(to: To): Path;
1217
+ /**
1218
+ * @private
1219
+ * PRIVATE - DO NOT USE
1220
+ *
1221
+ * Get/create a fetcher for the given key
1222
+ * @param key
1223
+ */
1224
+ getFetcher<TData = any>(key: string): Fetcher<TData>;
1225
+ /**
1226
+ * @internal
1227
+ * PRIVATE - DO NOT USE
1228
+ *
1229
+ * Reset the fetcher for a given key
1230
+ * @param key
1231
+ */
1232
+ resetFetcher(key: string, opts?: {
1233
+ reason?: unknown;
1234
+ }): void;
1235
+ /**
1236
+ * @private
1237
+ * PRIVATE - DO NOT USE
1238
+ *
1239
+ * Delete the fetcher for a given key
1240
+ * @param key
1241
+ */
1242
+ deleteFetcher(key: string): void;
1243
+ /**
1244
+ * @private
1245
+ * PRIVATE - DO NOT USE
1246
+ *
1247
+ * Cleanup listeners and abort any in-progress loads
1248
+ */
1249
+ dispose(): void;
1250
+ /**
1251
+ * @private
1252
+ * PRIVATE - DO NOT USE
1253
+ *
1254
+ * Get a navigation blocker
1255
+ * @param key The identifier for the blocker
1256
+ * @param fn The blocker function implementation
1257
+ */
1258
+ getBlocker(key: string, fn: BlockerFunction): Blocker;
1259
+ /**
1260
+ * @private
1261
+ * PRIVATE - DO NOT USE
1262
+ *
1263
+ * Delete a navigation blocker
1264
+ * @param key The identifier for the blocker
1265
+ */
1266
+ deleteBlocker(key: string): void;
1267
+ /**
1268
+ * @private
1269
+ * PRIVATE DO NOT USE
1270
+ *
1271
+ * Patch additional children routes into an existing parent route
1272
+ * @param routeId The parent route id or a callback function accepting `patch`
1273
+ * to perform batch patching
1274
+ * @param children The additional children routes
1275
+ * @param unstable_allowElementMutations Allow mutation or route elements on
1276
+ * existing routes. Intended for RSC-usage
1277
+ * only.
1278
+ */
1279
+ patchRoutes(routeId: string | null, children: RouteObject[], unstable_allowElementMutations?: boolean): void;
1280
+ /**
1281
+ * @private
1282
+ * PRIVATE - DO NOT USE
1283
+ *
1284
+ * HMR needs to pass in-flight route updates to React Router
1285
+ * TODO: Replace this with granular route update APIs (addRoute, updateRoute, deleteRoute)
1286
+ */
1287
+ _internalSetRoutes(routes: RouteObject[]): void;
1288
+ /**
1289
+ * @private
1290
+ * PRIVATE - DO NOT USE
1291
+ *
1292
+ * Cause subscribers to re-render. This is used to force a re-render.
1293
+ */
1294
+ _internalSetStateDoNotUseOrYouWillBreakYourApp(state: Partial<RouterState>): void;
1295
+ /**
1296
+ * @private
1297
+ * PRIVATE - DO NOT USE
1298
+ *
1299
+ * Internal fetch AbortControllers accessed by unit tests
1300
+ */
1301
+ _internalFetchControllers: Map<string, AbortController>;
1340
1302
  }
1341
1303
  /**
1342
1304
  * State maintained internally by the router. During a navigation, all states
1343
1305
  * reflect the "old" location unless otherwise noted.
1344
1306
  */
1345
1307
  interface RouterState {
1346
- /**
1347
- * The action of the most recent navigation
1348
- */
1349
- historyAction: Action;
1350
- /**
1351
- * The current location reflected by the router
1352
- */
1353
- location: Location;
1354
- /**
1355
- * The current set of route matches
1356
- */
1357
- matches: DataRouteMatch[];
1358
- /**
1359
- * Tracks whether we've completed our initial data load
1360
- */
1361
- initialized: boolean;
1362
- /**
1363
- * Tracks whether we should be rendering a HydrateFallback during hydration
1364
- */
1365
- renderFallback: boolean;
1366
- /**
1367
- * Current scroll position we should start at for a new view
1368
- * - number -> scroll position to restore to
1369
- * - false -> do not restore scroll at all (used during submissions/revalidations)
1370
- * - null -> don't have a saved position, scroll to hash or top of page
1371
- */
1372
- restoreScrollPosition: number | false | null;
1373
- /**
1374
- * Indicate whether this navigation should skip resetting the scroll position
1375
- * if we are unable to restore the scroll position
1376
- */
1377
- preventScrollReset: boolean;
1378
- /**
1379
- * Tracks the state of the current navigation
1380
- */
1381
- navigation: Navigation;
1382
- /**
1383
- * Tracks any in-progress revalidations
1384
- */
1385
- revalidation: RevalidationState;
1386
- /**
1387
- * Data from the loaders for the current matches
1388
- */
1389
- loaderData: RouteData;
1390
- /**
1391
- * Data from the action for the current matches
1392
- */
1393
- actionData: RouteData | null;
1394
- /**
1395
- * Errors caught from loaders for the current matches
1396
- */
1397
- errors: RouteData | null;
1398
- /**
1399
- * Map of current fetchers
1400
- */
1401
- fetchers: Map<string, Fetcher>;
1402
- /**
1403
- * Map of current blockers
1404
- */
1405
- blockers: Map<string, Blocker>;
1308
+ /**
1309
+ * The action of the most recent navigation
1310
+ */
1311
+ historyAction: Action;
1312
+ /**
1313
+ * The current location reflected by the router
1314
+ */
1315
+ location: Location;
1316
+ /**
1317
+ * The current set of route matches
1318
+ */
1319
+ matches: DataRouteMatch[];
1320
+ /**
1321
+ * Tracks whether we've completed our initial data load
1322
+ */
1323
+ initialized: boolean;
1324
+ /**
1325
+ * Tracks whether we should be rendering a HydrateFallback during hydration
1326
+ */
1327
+ renderFallback: boolean;
1328
+ /**
1329
+ * Current scroll position we should start at for a new view
1330
+ * - number -> scroll position to restore to
1331
+ * - false -> do not restore scroll at all (used during submissions/revalidations)
1332
+ * - null -> don't have a saved position, scroll to hash or top of page
1333
+ */
1334
+ restoreScrollPosition: number | false | null;
1335
+ /**
1336
+ * Indicate whether this navigation should skip resetting the scroll position
1337
+ * if we are unable to restore the scroll position
1338
+ */
1339
+ preventScrollReset: boolean;
1340
+ /**
1341
+ * Tracks the state of the current navigation
1342
+ */
1343
+ navigation: Navigation;
1344
+ /**
1345
+ * Tracks any in-progress revalidations
1346
+ */
1347
+ revalidation: RevalidationState;
1348
+ /**
1349
+ * Data from the loaders for the current matches
1350
+ */
1351
+ loaderData: RouteData;
1352
+ /**
1353
+ * Data from the action for the current matches
1354
+ */
1355
+ actionData: RouteData | null;
1356
+ /**
1357
+ * Errors caught from loaders for the current matches
1358
+ */
1359
+ errors: RouteData | null;
1360
+ /**
1361
+ * Map of current fetchers
1362
+ */
1363
+ fetchers: Map<string, Fetcher>;
1364
+ /**
1365
+ * Map of current blockers
1366
+ */
1367
+ blockers: Map<string, Blocker>;
1406
1368
  }
1407
1369
  /**
1408
1370
  * Data that can be passed into hydrate a Router from SSR
@@ -1411,130 +1373,128 @@ type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "e
1411
1373
  /**
1412
1374
  * Future flags to toggle new feature behavior
1413
1375
  */
1414
- interface FutureConfig {
1415
- }
1376
+ interface FutureConfig {}
1416
1377
  /**
1417
1378
  * Initialization options for createRouter
1418
1379
  */
1419
1380
  interface RouterInit {
1420
- routes: RouteObject[];
1421
- history: History;
1422
- basename?: string;
1423
- getContext?: () => MaybePromise<RouterContextProvider>;
1424
- instrumentations?: ClientInstrumentation[];
1425
- mapRouteProperties?: MapRoutePropertiesFunction;
1426
- future?: Partial<FutureConfig>;
1427
- hydrationRouteProperties?: string[];
1428
- hydrationData?: HydrationState;
1429
- window?: Window;
1430
- dataStrategy?: DataStrategyFunction;
1431
- patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
1381
+ routes: RouteObject[];
1382
+ history: History;
1383
+ basename?: string;
1384
+ getContext?: () => MaybePromise<RouterContextProvider>;
1385
+ instrumentations?: ClientInstrumentation[];
1386
+ mapRouteProperties?: MapRoutePropertiesFunction;
1387
+ future?: Partial<FutureConfig>;
1388
+ hydrationRouteProperties?: string[];
1389
+ hydrationData?: HydrationState;
1390
+ window?: Window;
1391
+ dataStrategy?: DataStrategyFunction;
1392
+ patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
1432
1393
  }
1433
1394
  /**
1434
1395
  * State returned from a server-side query() call
1435
1396
  */
1436
1397
  interface StaticHandlerContext {
1437
- basename: Router["basename"];
1438
- location: RouterState["location"];
1439
- matches: RouterState["matches"];
1440
- loaderData: RouterState["loaderData"];
1441
- actionData: RouterState["actionData"];
1442
- errors: RouterState["errors"];
1443
- statusCode: number;
1444
- loaderHeaders: Record<string, Headers>;
1445
- actionHeaders: Record<string, Headers>;
1446
- _deepestRenderedBoundaryId?: string | null;
1398
+ basename: Router$1["basename"];
1399
+ location: RouterState["location"];
1400
+ matches: RouterState["matches"];
1401
+ loaderData: RouterState["loaderData"];
1402
+ actionData: RouterState["actionData"];
1403
+ errors: RouterState["errors"];
1404
+ statusCode: number;
1405
+ loaderHeaders: Record<string, Headers>;
1406
+ actionHeaders: Record<string, Headers>;
1407
+ _deepestRenderedBoundaryId?: string | null;
1447
1408
  }
1448
1409
  /**
1449
1410
  * A StaticHandler instance manages a singular SSR navigation/fetch event
1450
1411
  */
1451
1412
  interface StaticHandler {
1452
- /**
1453
- * The set of data routes managed by this handler
1454
- */
1455
- dataRoutes: DataRouteObject[];
1456
- /**
1457
- * @private
1458
- * PRIVATE - DO NOT USE
1459
- *
1460
- * The route branches derived from the data routes, used for internal route
1461
- * matching in Framework Mode
1462
- */
1463
- _internalRouteBranches: RouteBranch<DataRouteObject>[];
1464
- /**
1465
- * Perform a query for a given request - executing all matched route
1466
- * loaders/actions. Used for document requests.
1467
- *
1468
- * @param request The request to query
1469
- * @param opts Optional query options
1470
- * @param opts.dataStrategy Alternate dataStrategy implementation
1471
- * @param opts.filterMatchesToLoad Predicate function to filter which matches should be loaded
1472
- * @param opts.generateMiddlewareResponse To enable middleware, provide a function
1473
- * to generate a response to bubble back up the middleware chain
1474
- * @param opts.requestContext Context object to pass to loaders/actions
1475
- * @param opts.skipLoaderErrorBubbling Skip loader error bubbling
1476
- * @param opts.skipRevalidation Skip revalidation after action submission
1477
- * @param opts.normalizePath Normalize the request path
1478
- */
1479
- query(request: Request, opts?: {
1480
- requestContext?: unknown;
1481
- filterMatchesToLoad?: (match: DataRouteMatch) => boolean;
1482
- skipLoaderErrorBubbling?: boolean;
1483
- skipRevalidation?: boolean;
1484
- dataStrategy?: DataStrategyFunction<unknown>;
1485
- generateMiddlewareResponse?: (query: (r: Request, args?: {
1486
- filterMatchesToLoad?: (match: DataRouteMatch) => boolean;
1487
- }) => Promise<StaticHandlerContext | Response>) => MaybePromise<Response>;
1488
- normalizePath?: (request: Request) => Path;
1489
- }): Promise<StaticHandlerContext | Response>;
1490
- /**
1491
- * Perform a query for a specific route. Used for resource requests.
1492
- *
1493
- * @param request The request to query
1494
- * @param opts Optional queryRoute options
1495
- * @param opts.dataStrategy Alternate dataStrategy implementation
1496
- * @param opts.generateMiddlewareResponse To enable middleware, provide a function
1497
- * to generate a response to bubble back up the middleware chain
1498
- * @param opts.requestContext Context object to pass to loaders/actions
1499
- * @param opts.routeId The ID of the route to query
1500
- * @param opts.normalizePath Normalize the request path
1501
-
1502
- */
1503
- queryRoute(request: Request, opts?: {
1504
- routeId?: string;
1505
- requestContext?: unknown;
1506
- dataStrategy?: DataStrategyFunction<unknown>;
1507
- generateMiddlewareResponse?: (queryRoute: (r: Request) => Promise<Response>) => MaybePromise<Response>;
1508
- normalizePath?: (request: Request) => Path;
1509
- }): Promise<any>;
1413
+ /**
1414
+ * The set of data routes managed by this handler
1415
+ */
1416
+ dataRoutes: DataRouteObject[];
1417
+ /**
1418
+ * @private
1419
+ * PRIVATE - DO NOT USE
1420
+ *
1421
+ * The route branches derived from the data routes, used for internal route
1422
+ * matching in Framework Mode
1423
+ */
1424
+ _internalRouteBranches: RouteBranch<DataRouteObject>[];
1425
+ /**
1426
+ * Perform a query for a given request - executing all matched route
1427
+ * loaders/actions. Used for document requests.
1428
+ *
1429
+ * @param request The request to query
1430
+ * @param opts Optional query options
1431
+ * @param opts.dataStrategy Alternate dataStrategy implementation
1432
+ * @param opts.filterMatchesToLoad Predicate function to filter which matches should be loaded
1433
+ * @param opts.generateMiddlewareResponse To enable middleware, provide a function
1434
+ * to generate a response to bubble back up the middleware chain
1435
+ * @param opts.requestContext Context object to pass to loaders/actions
1436
+ * @param opts.skipLoaderErrorBubbling Skip loader error bubbling
1437
+ * @param opts.skipRevalidation Skip revalidation after action submission
1438
+ * @param opts.normalizePath Normalize the request path
1439
+ */
1440
+ query(request: Request, opts?: {
1441
+ requestContext?: unknown;
1442
+ filterMatchesToLoad?: (match: DataRouteMatch) => boolean;
1443
+ skipLoaderErrorBubbling?: boolean;
1444
+ skipRevalidation?: boolean;
1445
+ dataStrategy?: DataStrategyFunction<unknown>;
1446
+ generateMiddlewareResponse?: (query: (r: Request, args?: {
1447
+ filterMatchesToLoad?: (match: DataRouteMatch) => boolean;
1448
+ }) => Promise<StaticHandlerContext | Response>) => MaybePromise<Response>;
1449
+ normalizePath?: (request: Request) => Path;
1450
+ }): Promise<StaticHandlerContext | Response>;
1451
+ /**
1452
+ * Perform a query for a specific route. Used for resource requests.
1453
+ *
1454
+ * @param request The request to query
1455
+ * @param opts Optional queryRoute options
1456
+ * @param opts.dataStrategy Alternate dataStrategy implementation
1457
+ * @param opts.generateMiddlewareResponse To enable middleware, provide a function
1458
+ * to generate a response to bubble back up the middleware chain
1459
+ * @param opts.requestContext Context object to pass to loaders/actions
1460
+ * @param opts.routeId The ID of the route to query
1461
+ * @param opts.normalizePath Normalize the request path
1462
+ */
1463
+ queryRoute(request: Request, opts?: {
1464
+ routeId?: string;
1465
+ requestContext?: unknown;
1466
+ dataStrategy?: DataStrategyFunction<unknown>;
1467
+ generateMiddlewareResponse?: (queryRoute: (r: Request) => Promise<Response>) => MaybePromise<Response>;
1468
+ normalizePath?: (request: Request) => Path;
1469
+ }): Promise<any>;
1510
1470
  }
1511
1471
  type ViewTransitionOpts = {
1512
- currentLocation: Location;
1513
- nextLocation: Location;
1472
+ currentLocation: Location;
1473
+ nextLocation: Location;
1514
1474
  };
1515
1475
  /**
1516
1476
  * Subscriber function signature for changes to router state
1517
1477
  */
1518
1478
  interface RouterSubscriber {
1519
- (state: RouterState, opts: {
1520
- deletedFetchers: string[];
1521
- newErrors: RouteData | null;
1522
- viewTransitionOpts?: ViewTransitionOpts;
1523
- flushSync: boolean;
1524
- }): void;
1479
+ (state: RouterState, opts: {
1480
+ deletedFetchers: string[];
1481
+ newErrors: RouteData | null;
1482
+ viewTransitionOpts?: ViewTransitionOpts;
1483
+ flushSync: boolean;
1484
+ }): void;
1525
1485
  }
1526
1486
  /**
1527
1487
  * Function signature for determining the key to be used in scroll restoration
1528
1488
  * for a given location
1529
1489
  */
1530
1490
  interface GetScrollRestorationKeyFunction {
1531
- (location: Location, matches: UIMatch[]): string | null;
1491
+ (location: Location, matches: UIMatch[]): string | null;
1532
1492
  }
1533
1493
  /**
1534
1494
  * Function signature for determining the current scroll position
1535
1495
  */
1536
1496
  interface GetScrollPositionFunction {
1537
- (): number;
1497
+ (): number;
1538
1498
  }
1539
1499
  /**
1540
1500
  * - "route": relative to the route hierarchy so `..` means remove all segments
@@ -1546,27 +1506,27 @@ interface GetScrollPositionFunction {
1546
1506
  */
1547
1507
  type RelativeRoutingType = "route" | "path";
1548
1508
  type BaseNavigateOrFetchOptions = {
1549
- preventScrollReset?: boolean;
1550
- relative?: RelativeRoutingType;
1551
- flushSync?: boolean;
1552
- defaultShouldRevalidate?: boolean;
1509
+ preventScrollReset?: boolean;
1510
+ relative?: RelativeRoutingType;
1511
+ flushSync?: boolean;
1512
+ defaultShouldRevalidate?: boolean;
1553
1513
  };
1554
1514
  type BaseNavigateOptions = BaseNavigateOrFetchOptions & {
1555
- replace?: boolean;
1556
- state?: any;
1557
- fromRouteId?: string;
1558
- viewTransition?: boolean;
1559
- mask?: To;
1515
+ replace?: boolean;
1516
+ state?: any;
1517
+ fromRouteId?: string;
1518
+ viewTransition?: boolean;
1519
+ mask?: To;
1560
1520
  };
1561
1521
  type BaseSubmissionOptions = {
1562
- formMethod?: HTMLFormMethod;
1563
- formEncType?: FormEncType;
1522
+ formMethod?: HTMLFormMethod;
1523
+ formEncType?: FormEncType;
1564
1524
  } & ({
1565
- formData: FormData;
1566
- body?: undefined;
1525
+ formData: FormData;
1526
+ body?: undefined;
1567
1527
  } | {
1568
- formData?: undefined;
1569
- body: any;
1528
+ formData?: undefined;
1529
+ body: any;
1570
1530
  });
1571
1531
  /**
1572
1532
  * Options for a navigate() call for a normal (non-submission) navigation
@@ -1596,42 +1556,42 @@ type RouterFetchOptions = LoadFetchOptions | SubmitFetchOptions;
1596
1556
  * Potential states for state.navigation
1597
1557
  */
1598
1558
  type NavigationStates = {
1599
- Idle: {
1600
- state: "idle";
1601
- location: undefined;
1602
- matches: undefined;
1603
- historyAction: undefined;
1604
- formMethod: undefined;
1605
- formAction: undefined;
1606
- formEncType: undefined;
1607
- formData: undefined;
1608
- json: undefined;
1609
- text: undefined;
1610
- };
1611
- Loading: {
1612
- state: "loading";
1613
- location: Location;
1614
- matches: DataRouteMatch[];
1615
- historyAction: Action;
1616
- formMethod: Submission["formMethod"] | undefined;
1617
- formAction: Submission["formAction"] | undefined;
1618
- formEncType: Submission["formEncType"] | undefined;
1619
- formData: Submission["formData"] | undefined;
1620
- json: Submission["json"] | undefined;
1621
- text: Submission["text"] | undefined;
1622
- };
1623
- Submitting: {
1624
- state: "submitting";
1625
- location: Location;
1626
- matches: DataRouteMatch[];
1627
- historyAction: Action;
1628
- formMethod: Submission["formMethod"];
1629
- formAction: Submission["formAction"];
1630
- formEncType: Submission["formEncType"];
1631
- formData: Submission["formData"];
1632
- json: Submission["json"];
1633
- text: Submission["text"];
1634
- };
1559
+ Idle: {
1560
+ state: "idle";
1561
+ location: undefined;
1562
+ matches: undefined;
1563
+ historyAction: undefined;
1564
+ formMethod: undefined;
1565
+ formAction: undefined;
1566
+ formEncType: undefined;
1567
+ formData: undefined;
1568
+ json: undefined;
1569
+ text: undefined;
1570
+ };
1571
+ Loading: {
1572
+ state: "loading";
1573
+ location: Location;
1574
+ matches: DataRouteMatch[];
1575
+ historyAction: Action;
1576
+ formMethod: Submission["formMethod"] | undefined;
1577
+ formAction: Submission["formAction"] | undefined;
1578
+ formEncType: Submission["formEncType"] | undefined;
1579
+ formData: Submission["formData"] | undefined;
1580
+ json: Submission["json"] | undefined;
1581
+ text: Submission["text"] | undefined;
1582
+ };
1583
+ Submitting: {
1584
+ state: "submitting";
1585
+ location: Location;
1586
+ matches: DataRouteMatch[];
1587
+ historyAction: Action;
1588
+ formMethod: Submission["formMethod"];
1589
+ formAction: Submission["formAction"];
1590
+ formEncType: Submission["formEncType"];
1591
+ formData: Submission["formData"];
1592
+ json: Submission["json"];
1593
+ text: Submission["text"];
1594
+ };
1635
1595
  };
1636
1596
  type Navigation = NavigationStates[keyof NavigationStates];
1637
1597
  type RevalidationState = "idle" | "loading";
@@ -1639,197 +1599,225 @@ type RevalidationState = "idle" | "loading";
1639
1599
  * Potential states for fetchers
1640
1600
  */
1641
1601
  type FetcherStates<TData = any> = {
1602
+ /**
1603
+ * The fetcher is not calling a loader or action
1604
+ *
1605
+ * ```tsx
1606
+ * fetcher.state === "idle"
1607
+ * ```
1608
+ */
1609
+ Idle: {
1610
+ state: "idle";
1611
+ formMethod: undefined;
1612
+ formAction: undefined;
1613
+ formEncType: undefined;
1614
+ text: undefined;
1615
+ formData: undefined;
1616
+ json: undefined;
1642
1617
  /**
1643
- * The fetcher is not calling a loader or action
1644
- *
1645
- * ```tsx
1646
- * fetcher.state === "idle"
1647
- * ```
1648
- */
1649
- Idle: {
1650
- state: "idle";
1651
- formMethod: undefined;
1652
- formAction: undefined;
1653
- formEncType: undefined;
1654
- text: undefined;
1655
- formData: undefined;
1656
- json: undefined;
1657
- /**
1658
- * If the fetcher has never been called, this will be undefined.
1659
- */
1660
- data: TData | undefined;
1661
- };
1662
- /**
1663
- * The fetcher is loading data from a {@link LoaderFunction | loader} from a
1664
- * call to {@link FetcherWithComponents.load | `fetcher.load`}.
1665
- *
1666
- * ```tsx
1667
- * // somewhere
1668
- * <button onClick={() => fetcher.load("/some/route") }>Load</button>
1669
- *
1670
- * // the state will update
1671
- * fetcher.state === "loading"
1672
- * ```
1673
- */
1674
- Loading: {
1675
- state: "loading";
1676
- formMethod: Submission["formMethod"] | undefined;
1677
- formAction: Submission["formAction"] | undefined;
1678
- formEncType: Submission["formEncType"] | undefined;
1679
- text: Submission["text"] | undefined;
1680
- formData: Submission["formData"] | undefined;
1681
- json: Submission["json"] | undefined;
1682
- data: TData | undefined;
1683
- };
1684
- /**
1685
- The fetcher is submitting to a {@link LoaderFunction} (GET) or {@link ActionFunction} (POST) from a {@link FetcherWithComponents.Form | `fetcher.Form`} or {@link FetcherWithComponents.submit | `fetcher.submit`}.
1686
-
1687
- ```tsx
1688
- // somewhere
1689
- <input
1690
- onChange={e => {
1691
- fetcher.submit(event.currentTarget.form, { method: "post" });
1692
- }}
1693
- />
1694
-
1695
- // the state will update
1696
- fetcher.state === "submitting"
1697
-
1698
- // and formData will be available
1699
- fetcher.formData
1700
- ```
1701
- */
1702
- Submitting: {
1703
- state: "submitting";
1704
- formMethod: Submission["formMethod"];
1705
- formAction: Submission["formAction"];
1706
- formEncType: Submission["formEncType"];
1707
- text: Submission["text"];
1708
- formData: Submission["formData"];
1709
- json: Submission["json"];
1710
- data: TData | undefined;
1711
- };
1618
+ * If the fetcher has never been called, this will be undefined.
1619
+ */
1620
+ data: TData | undefined;
1621
+ };
1622
+ /**
1623
+ * The fetcher is loading data from a {@link LoaderFunction | loader} from a
1624
+ * call to {@link FetcherWithComponents.load | `fetcher.load`}.
1625
+ *
1626
+ * ```tsx
1627
+ * // somewhere
1628
+ * <button onClick={() => fetcher.load("/some/route") }>Load</button>
1629
+ *
1630
+ * // the state will update
1631
+ * fetcher.state === "loading"
1632
+ * ```
1633
+ */
1634
+ Loading: {
1635
+ state: "loading";
1636
+ formMethod: Submission["formMethod"] | undefined;
1637
+ formAction: Submission["formAction"] | undefined;
1638
+ formEncType: Submission["formEncType"] | undefined;
1639
+ text: Submission["text"] | undefined;
1640
+ formData: Submission["formData"] | undefined;
1641
+ json: Submission["json"] | undefined;
1642
+ data: TData | undefined;
1643
+ };
1644
+ /**
1645
+ The fetcher is submitting to a {@link LoaderFunction} (GET) or {@link ActionFunction} (POST) from a {@link FetcherWithComponents.Form | `fetcher.Form`} or {@link FetcherWithComponents.submit | `fetcher.submit`}.
1646
+ ```tsx
1647
+ // somewhere
1648
+ <input
1649
+ onChange={e => {
1650
+ fetcher.submit(event.currentTarget.form, { method: "post" });
1651
+ }}
1652
+ />
1653
+ // the state will update
1654
+ fetcher.state === "submitting"
1655
+ // and formData will be available
1656
+ fetcher.formData
1657
+ ```
1658
+ */
1659
+ Submitting: {
1660
+ state: "submitting";
1661
+ formMethod: Submission["formMethod"];
1662
+ formAction: Submission["formAction"];
1663
+ formEncType: Submission["formEncType"];
1664
+ text: Submission["text"];
1665
+ formData: Submission["formData"];
1666
+ json: Submission["json"];
1667
+ data: TData | undefined;
1668
+ };
1712
1669
  };
1713
1670
  type Fetcher<TData = any> = FetcherStates<TData>[keyof FetcherStates<TData>];
1714
1671
  interface BlockerBlocked {
1715
- state: "blocked";
1716
- reset: () => void;
1717
- proceed: () => void;
1718
- location: Location;
1672
+ state: "blocked";
1673
+ reset: () => void;
1674
+ proceed: () => void;
1675
+ location: Location;
1719
1676
  }
1720
1677
  interface BlockerUnblocked {
1721
- state: "unblocked";
1722
- reset: undefined;
1723
- proceed: undefined;
1724
- location: undefined;
1678
+ state: "unblocked";
1679
+ reset: undefined;
1680
+ proceed: undefined;
1681
+ location: undefined;
1725
1682
  }
1726
1683
  interface BlockerProceeding {
1727
- state: "proceeding";
1728
- reset: undefined;
1729
- proceed: undefined;
1730
- location: Location;
1684
+ state: "proceeding";
1685
+ reset: undefined;
1686
+ proceed: undefined;
1687
+ location: Location;
1731
1688
  }
1732
1689
  type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
1733
1690
  type BlockerFunction = (args: {
1734
- currentLocation: Location;
1735
- nextLocation: Location;
1736
- historyAction: Action;
1691
+ currentLocation: Location;
1692
+ nextLocation: Location;
1693
+ historyAction: Action;
1737
1694
  }) => boolean;
1738
1695
  interface CreateStaticHandlerOptions {
1739
- basename?: string;
1740
- mapRouteProperties?: MapRoutePropertiesFunction;
1741
- instrumentations?: Pick<ServerInstrumentation, "route">[];
1742
- future?: Partial<FutureConfig>;
1696
+ basename?: string;
1697
+ mapRouteProperties?: MapRoutePropertiesFunction;
1698
+ instrumentations?: Pick<ServerInstrumentation, "route">[];
1699
+ future?: Partial<FutureConfig>;
1743
1700
  }
1701
+ /**
1702
+ * Create a static handler to perform server-side data loading
1703
+ *
1704
+ * @example
1705
+ * export async function handleRequest(request: Request) {
1706
+ * let { query, dataRoutes } = createStaticHandler(routes);
1707
+ * let context = await query(request);
1708
+ *
1709
+ * if (context instanceof Response) {
1710
+ * return context;
1711
+ * }
1712
+ *
1713
+ * let router = createStaticRouter(dataRoutes, context);
1714
+ * return new Response(
1715
+ * ReactDOMServer.renderToString(<StaticRouterProvider ... />),
1716
+ * { headers: { "Content-Type": "text/html" } }
1717
+ * );
1718
+ * }
1719
+ *
1720
+ * @public
1721
+ * @category Data Routers
1722
+ * @mode data
1723
+ * @param routes The {@link RouteObject | route objects} to create a static
1724
+ * handler for
1725
+ * @param opts Options
1726
+ * @param opts.basename The base URL for the static handler (default: `/`)
1727
+ * @param opts.future Future flags for the static handler
1728
+ * @returns A static handler that can be used to query data for the provided
1729
+ * routes
1730
+ */
1744
1731
  declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticHandlerOptions): StaticHandler;
1745
-
1732
+ //#endregion
1733
+ //#region lib/router/links.d.ts
1746
1734
  type Primitive = null | undefined | string | number | boolean | symbol | bigint;
1747
1735
  type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
1748
1736
  interface HtmlLinkProps {
1749
- /**
1750
- * Address of the hyperlink
1751
- */
1752
- href?: string;
1753
- /**
1754
- * How the element handles crossorigin requests
1755
- */
1756
- crossOrigin?: "anonymous" | "use-credentials";
1757
- /**
1758
- * Relationship between the document containing the hyperlink and the destination resource
1759
- */
1760
- rel: LiteralUnion<"alternate" | "dns-prefetch" | "icon" | "manifest" | "modulepreload" | "next" | "pingback" | "preconnect" | "prefetch" | "preload" | "prerender" | "search" | "stylesheet", string>;
1761
- /**
1762
- * Applicable media: "screen", "print", "(max-width: 764px)"
1763
- */
1764
- media?: string;
1765
- /**
1766
- * Integrity metadata used in Subresource Integrity checks
1767
- */
1768
- integrity?: string;
1769
- /**
1770
- * Language of the linked resource
1771
- */
1772
- hrefLang?: string;
1773
- /**
1774
- * Hint for the type of the referenced resource
1775
- */
1776
- type?: string;
1777
- /**
1778
- * Referrer policy for fetches initiated by the element
1779
- */
1780
- referrerPolicy?: "" | "no-referrer" | "no-referrer-when-downgrade" | "same-origin" | "origin" | "strict-origin" | "origin-when-cross-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
1781
- /**
1782
- * Sizes of the icons (for rel="icon")
1783
- */
1784
- sizes?: string;
1785
- /**
1786
- * Potential destination for a preload request (for rel="preload" and rel="modulepreload")
1787
- */
1788
- as?: LiteralUnion<"audio" | "audioworklet" | "document" | "embed" | "fetch" | "font" | "frame" | "iframe" | "image" | "manifest" | "object" | "paintworklet" | "report" | "script" | "serviceworker" | "sharedworker" | "style" | "track" | "video" | "worker" | "xslt", string>;
1789
- /**
1790
- * Color to use when customizing a site's icon (for rel="mask-icon")
1791
- */
1792
- color?: string;
1793
- /**
1794
- * Whether the link is disabled
1795
- */
1796
- disabled?: boolean;
1797
- /**
1798
- * The title attribute has special semantics on this element: Title of the link; CSS style sheet set name.
1799
- */
1800
- title?: string;
1801
- /**
1802
- * Images to use in different situations, e.g., high-resolution displays,
1803
- * small monitors, etc. (for rel="preload")
1804
- */
1805
- imageSrcSet?: string;
1806
- /**
1807
- * Image sizes for different page layouts (for rel="preload")
1808
- */
1809
- imageSizes?: string;
1737
+ /**
1738
+ * Address of the hyperlink
1739
+ */
1740
+ href?: string;
1741
+ /**
1742
+ * How the element handles crossorigin requests
1743
+ */
1744
+ crossOrigin?: "anonymous" | "use-credentials";
1745
+ /**
1746
+ * Relationship between the document containing the hyperlink and the destination resource
1747
+ */
1748
+ rel: LiteralUnion<"alternate" | "dns-prefetch" | "icon" | "manifest" | "modulepreload" | "next" | "pingback" | "preconnect" | "prefetch" | "preload" | "prerender" | "search" | "stylesheet", string>;
1749
+ /**
1750
+ * Applicable media: "screen", "print", "(max-width: 764px)"
1751
+ */
1752
+ media?: string;
1753
+ /**
1754
+ * Integrity metadata used in Subresource Integrity checks
1755
+ */
1756
+ integrity?: string;
1757
+ /**
1758
+ * Language of the linked resource
1759
+ */
1760
+ hrefLang?: string;
1761
+ /**
1762
+ * Hint for the type of the referenced resource
1763
+ */
1764
+ type?: string;
1765
+ /**
1766
+ * Referrer policy for fetches initiated by the element
1767
+ */
1768
+ referrerPolicy?: "" | "no-referrer" | "no-referrer-when-downgrade" | "same-origin" | "origin" | "strict-origin" | "origin-when-cross-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
1769
+ /**
1770
+ * Sizes of the icons (for rel="icon")
1771
+ */
1772
+ sizes?: string;
1773
+ /**
1774
+ * Potential destination for a preload request (for rel="preload" and rel="modulepreload")
1775
+ */
1776
+ as?: LiteralUnion<"audio" | "audioworklet" | "document" | "embed" | "fetch" | "font" | "frame" | "iframe" | "image" | "manifest" | "object" | "paintworklet" | "report" | "script" | "serviceworker" | "sharedworker" | "style" | "track" | "video" | "worker" | "xslt", string>;
1777
+ /**
1778
+ * Color to use when customizing a site's icon (for rel="mask-icon")
1779
+ */
1780
+ color?: string;
1781
+ /**
1782
+ * Whether the link is disabled
1783
+ */
1784
+ disabled?: boolean;
1785
+ /**
1786
+ * The title attribute has special semantics on this element: Title of the link; CSS style sheet set name.
1787
+ */
1788
+ title?: string;
1789
+ /**
1790
+ * Images to use in different situations, e.g., high-resolution displays,
1791
+ * small monitors, etc. (for rel="preload")
1792
+ */
1793
+ imageSrcSet?: string;
1794
+ /**
1795
+ * Image sizes for different page layouts (for rel="preload")
1796
+ */
1797
+ imageSizes?: string;
1810
1798
  }
1811
1799
  interface HtmlLinkPreloadImage extends HtmlLinkProps {
1812
- /**
1813
- * Relationship between the document containing the hyperlink and the destination resource
1814
- */
1815
- rel: "preload";
1816
- /**
1817
- * Potential destination for a preload request (for rel="preload" and rel="modulepreload")
1818
- */
1819
- as: "image";
1820
- /**
1821
- * Address of the hyperlink
1822
- */
1823
- href?: string;
1824
- /**
1825
- * Images to use in different situations, e.g., high-resolution displays,
1826
- * small monitors, etc. (for rel="preload")
1827
- */
1828
- imageSrcSet: string;
1829
- /**
1830
- * Image sizes for different page layouts (for rel="preload")
1831
- */
1832
- imageSizes?: string;
1800
+ /**
1801
+ * Relationship between the document containing the hyperlink and the destination resource
1802
+ */
1803
+ rel: "preload";
1804
+ /**
1805
+ * Potential destination for a preload request (for rel="preload" and rel="modulepreload")
1806
+ */
1807
+ as: "image";
1808
+ /**
1809
+ * Address of the hyperlink
1810
+ */
1811
+ href?: string;
1812
+ /**
1813
+ * Images to use in different situations, e.g., high-resolution displays,
1814
+ * small monitors, etc. (for rel="preload")
1815
+ */
1816
+ imageSrcSet: string;
1817
+ /**
1818
+ * Image sizes for different page layouts (for rel="preload")
1819
+ */
1820
+ imageSizes?: string;
1833
1821
  }
1834
1822
  /**
1835
1823
  * Represents a `<link>` element.
@@ -1837,32 +1825,34 @@ interface HtmlLinkPreloadImage extends HtmlLinkProps {
1837
1825
  * WHATWG Specification: https://html.spec.whatwg.org/multipage/semantics.html#the-link-element
1838
1826
  */
1839
1827
  type HtmlLinkDescriptor = (HtmlLinkProps & Pick<Required<HtmlLinkProps>, "href">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "imageSizes">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "href"> & {
1840
- imageSizes?: never;
1828
+ imageSizes?: never;
1841
1829
  });
1842
1830
  interface PageLinkDescriptor extends Omit<HtmlLinkDescriptor, "href" | "rel" | "type" | "sizes" | "imageSrcSet" | "imageSizes" | "as" | "color" | "title"> {
1843
- /**
1844
- * A [`nonce`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/nonce)
1845
- * attribute to render on the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
1846
- * element. If not provided in Framework Mode, it will default to any
1847
- * {@link ServerRouter | `<ServerRouter nonce>`} prop.
1848
-
1849
- */
1850
- nonce?: string | undefined;
1851
- /**
1852
- * The absolute path of the page to prefetch, e.g. `/absolute/path`.
1853
- */
1854
- page: string;
1831
+ /**
1832
+ * A [`nonce`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/nonce)
1833
+ * attribute to render on the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
1834
+ * element. If not provided in Framework Mode, it will default to any
1835
+ * {@link ServerRouter | `<ServerRouter nonce>`} prop.
1836
+ */
1837
+ nonce?: string | undefined;
1838
+ /**
1839
+ * The absolute path of the page to prefetch, e.g. `/absolute/path`.
1840
+ */
1841
+ page: string;
1855
1842
  }
1856
1843
  type LinkDescriptor = HtmlLinkDescriptor | PageLinkDescriptor;
1857
-
1844
+ //#endregion
1845
+ //#region lib/server-runtime/single-fetch.d.ts
1858
1846
  type Serializable = undefined | null | boolean | string | symbol | number | Array<Serializable> | {
1859
- [key: PropertyKey]: Serializable;
1847
+ [key: PropertyKey]: Serializable;
1860
1848
  } | bigint | Date | URL | RegExp | Error | Map<Serializable, Serializable> | Set<Serializable> | Promise<Serializable>;
1861
-
1849
+ //#endregion
1850
+ //#region lib/types/utils.d.ts
1862
1851
  type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
1863
1852
  type IsAny<T> = 0 extends 1 & T ? true : false;
1864
1853
  type Func = (...args: any[]) => unknown;
1865
-
1854
+ //#endregion
1855
+ //#region lib/types/serializes-to.d.ts
1866
1856
  /**
1867
1857
  * A brand that can be applied to a type to indicate that it will serialize
1868
1858
  * to a specific type when transported to the client from a loader.
@@ -1870,12 +1860,11 @@ type Func = (...args: any[]) => unknown;
1870
1860
  * in your application.
1871
1861
  */
1872
1862
  type unstable_SerializesTo<T> = {
1873
- unstable__ReactRouter_SerializesTo: [T];
1863
+ unstable__ReactRouter_SerializesTo: [T];
1874
1864
  };
1875
-
1876
- type Serialize<T> = T extends unstable_SerializesTo<infer To> ? To : T extends Serializable ? T : T extends (...args: any[]) => unknown ? undefined : T extends Promise<infer U> ? Promise<Serialize<U>> : T extends Map<infer K, infer V> ? Map<Serialize<K>, Serialize<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<Serialize<K>, Serialize<V>> : T extends Set<infer U> ? Set<Serialize<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<Serialize<U>> : T extends [] ? [] : T extends readonly [infer F, ...infer R] ? [Serialize<F>, ...Serialize<R>] : T extends Array<infer U> ? Array<Serialize<U>> : T extends readonly unknown[] ? readonly Serialize<T[number]>[] : T extends Record<any, any> ? {
1877
- [K in keyof T]: Serialize<T[K]>;
1878
- } : undefined;
1865
+ //#endregion
1866
+ //#region lib/types/route-data.d.ts
1867
+ type Serialize<T> = T extends unstable_SerializesTo<infer To> ? To : T extends Serializable ? T : T extends ((...args: any[]) => unknown) ? undefined : T extends Promise<infer U> ? Promise<Serialize<U>> : T extends Map<infer K, infer V> ? Map<Serialize<K>, Serialize<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<Serialize<K>, Serialize<V>> : T extends Set<infer U> ? Set<Serialize<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<Serialize<U>> : T extends [] ? [] : T extends readonly [infer F, ...infer R] ? [Serialize<F>, ...Serialize<R>] : T extends Array<infer U> ? Array<Serialize<U>> : T extends readonly unknown[] ? readonly Serialize<T[number]>[] : T extends Record<any, any> ? { [K in keyof T]: Serialize<T[K]> } : undefined;
1879
1868
  type VoidToUndefined<T> = Equal<T, void> extends true ? undefined : T;
1880
1869
  type DataFrom<T> = IsAny<T> extends true ? undefined : T extends Func ? VoidToUndefined<Awaited<ReturnType<T>>> : undefined;
1881
1870
  type ClientData<T> = T extends Response ? never : T extends DataWithResponseInit<infer U> ? U : T;
@@ -1883,55 +1872,51 @@ type ServerData<T> = T extends Response ? never : T extends DataWithResponseInit
1883
1872
  type ServerDataFrom<T> = ServerData<DataFrom<T>>;
1884
1873
  type ClientDataFrom<T> = ClientData<DataFrom<T>>;
1885
1874
  type ClientDataFunctionArgs<Params> = {
1886
- /**
1887
- * A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the URL, the method, the "content-type" header, and the request body from the request.
1888
- *
1889
- * @note Because client data functions are called before a network request is made, the Request object does not include the headers which the browser automatically adds. React Router infers the "content-type" header from the enc-type of the form that performed the submission.
1890
- **/
1891
- request: Request;
1892
- /**
1893
- * A URL instance representing the application location being navigated to or
1894
- * fetched. By default, this matches `request.url`.
1895
- *
1896
- * In Framework mode with `future.v8_passThroughRequests` enabled, this is a
1897
- * normalized URL with React-Router-specific implementation details removed
1898
- * (`.data` suffixes, `index`/`_routes` search params).
1899
- */
1900
- url: URL;
1901
- /**
1902
- * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
1903
- * @example
1904
- * // app/routes.ts
1905
- * route("teams/:teamId", "./team.tsx"),
1906
- *
1907
- * // app/team.tsx
1908
- * export function clientLoader({
1909
- * params,
1910
- * }: Route.ClientLoaderArgs) {
1911
- * params.teamId;
1912
- * // ^ string
1913
- * }
1914
- **/
1915
- params: Params;
1916
- /**
1917
- * Matched un-interpolated route pattern for the current path (i.e., /blog/:slug).
1918
- * Mostly useful as a identifier to aggregate on for logging/tracing/etc.
1919
- */
1920
- pattern: string;
1921
- /**
1922
- * When `future.v8_middleware` is not enabled, this is undefined.
1923
- *
1924
- * When `future.v8_middleware` is enabled, this is an instance of
1925
- * `RouterContextProvider` and can be used to access context values
1926
- * from your route middlewares. You may pass in initial context values in your
1927
- * `<HydratedRouter getContext>` prop
1928
- */
1929
- context: Readonly<RouterContextProvider>;
1875
+ /**
1876
+ * A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the URL, the method, the "content-type" header, and the request body from the request.
1877
+ *
1878
+ * @note Because client data functions are called before a network request is made, the Request object does not include the headers which the browser automatically adds. React Router infers the "content-type" header from the enc-type of the form that performed the submission.
1879
+ **/
1880
+ request: Request;
1881
+ /**
1882
+ * A URL instance representing the application location being navigated to or
1883
+ * fetched.
1884
+ *
1885
+ * In Framework mode, this is a normalized URL with React-Router-specific
1886
+ * implementation details removed (`.data` suffixes, `index`/`_routes` search
1887
+ * params). For the raw incoming URL, use `request.url`.
1888
+ */
1889
+ url: URL;
1890
+ /**
1891
+ * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
1892
+ * @example
1893
+ * // app/routes.ts
1894
+ * route("teams/:teamId", "./team.tsx"),
1895
+ *
1896
+ * // app/team.tsx
1897
+ * export function clientLoader({
1898
+ * params,
1899
+ * }: Route.ClientLoaderArgs) {
1900
+ * params.teamId;
1901
+ * // ^ string
1902
+ * }
1903
+ **/
1904
+ params: Params;
1905
+ /**
1906
+ * Matched un-interpolated route pattern for the current path (i.e., /blog/:slug).
1907
+ * Mostly useful as a identifier to aggregate on for logging/tracing/etc.
1908
+ */
1909
+ pattern: string;
1910
+ /**
1911
+ * An instance of `RouterContextProvider` that can be used to access context
1912
+ * values from your route middlewares. You may pass in initial context values
1913
+ * in your `<HydratedRouter getContext>` prop.
1914
+ */
1915
+ context: Readonly<RouterContextProvider>;
1930
1916
  };
1931
- type SerializeFrom<T> = T extends (...args: infer Args) => unknown ? Args extends [
1932
- ClientLoaderFunctionArgs | ClientActionFunctionArgs | ClientDataFunctionArgs<unknown>
1933
- ] ? ClientDataFrom<T> : ServerDataFrom<T> : T;
1934
-
1917
+ type SerializeFrom<T> = T extends ((...args: infer Args) => unknown) ? Args extends [ClientLoaderFunctionArgs | ClientActionFunctionArgs | ClientDataFunctionArgs<unknown>] ? ClientDataFrom<T> : ServerDataFrom<T> : T;
1918
+ //#endregion
1919
+ //#region lib/dom/ssr/routeModules.d.ts
1935
1920
  /**
1936
1921
  * A function that handles data mutations for a route on the client
1937
1922
  */
@@ -1940,32 +1925,32 @@ type ClientActionFunction = (args: ClientActionFunctionArgs) => ReturnType<Actio
1940
1925
  * Arguments passed to a route `clientAction` function
1941
1926
  */
1942
1927
  type ClientActionFunctionArgs = ActionFunctionArgs & {
1943
- serverAction: <T = unknown>() => Promise<SerializeFrom<T>>;
1928
+ serverAction: <T = unknown>() => Promise<SerializeFrom<T>>;
1944
1929
  };
1945
1930
  /**
1946
1931
  * A function that loads data for a route on the client
1947
1932
  */
1948
1933
  type ClientLoaderFunction = ((args: ClientLoaderFunctionArgs) => ReturnType<LoaderFunction>) & {
1949
- hydrate?: boolean;
1934
+ hydrate?: boolean;
1950
1935
  };
1951
1936
  /**
1952
1937
  * Arguments passed to a route `clientLoader` function
1953
1938
  */
1954
1939
  type ClientLoaderFunctionArgs = LoaderFunctionArgs & {
1955
- serverLoader: <T = unknown>() => Promise<SerializeFrom<T>>;
1940
+ serverLoader: <T = unknown>() => Promise<SerializeFrom<T>>;
1956
1941
  };
1957
1942
  type HeadersArgs = {
1958
- loaderHeaders: Headers;
1959
- parentHeaders: Headers;
1960
- actionHeaders: Headers;
1961
- errorHeaders: Headers | undefined;
1943
+ loaderHeaders: Headers;
1944
+ parentHeaders: Headers;
1945
+ actionHeaders: Headers;
1946
+ errorHeaders: Headers | undefined;
1962
1947
  };
1963
1948
  /**
1964
1949
  * A function that returns HTTP headers to be used for a route. These headers
1965
1950
  * will be merged with (and take precedence over) headers from parent routes.
1966
1951
  */
1967
1952
  interface HeadersFunction {
1968
- (args: HeadersArgs): Headers | HeadersInit;
1953
+ (args: HeadersArgs): Headers | HeadersInit;
1969
1954
  }
1970
1955
  /**
1971
1956
  * A function that defines `<link>` tags to be inserted into the `<head>` of
@@ -1974,30 +1959,24 @@ interface HeadersFunction {
1974
1959
  * @see https://reactrouter.com/start/framework/route-module#meta
1975
1960
  */
1976
1961
  interface LinksFunction {
1977
- (): LinkDescriptor[];
1962
+ (): LinkDescriptor[];
1978
1963
  }
1979
1964
  interface MetaMatch<RouteId extends string = string, Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown> {
1980
- id: RouteId;
1981
- pathname: DataRouteMatch["pathname"];
1982
- /** @deprecated Use `MetaMatch.loaderData` instead */
1983
- data: Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown;
1984
- loaderData: Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown;
1985
- handle?: RouteHandle;
1986
- params: DataRouteMatch["params"];
1987
- meta: MetaDescriptor[];
1988
- error?: unknown;
1965
+ id: RouteId;
1966
+ pathname: DataRouteMatch["pathname"];
1967
+ loaderData: Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown;
1968
+ handle?: RouteHandle;
1969
+ params: DataRouteMatch["params"];
1970
+ meta: MetaDescriptor[];
1971
+ error?: unknown;
1989
1972
  }
1990
- type MetaMatches<MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> = Array<{
1991
- [K in keyof MatchLoaders]: MetaMatch<Exclude<K, number | symbol>, MatchLoaders[K]>;
1992
- }[keyof MatchLoaders]>;
1973
+ type MetaMatches<MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> = Array<{ [K in keyof MatchLoaders]: MetaMatch<Exclude<K, number | symbol>, MatchLoaders[K]> }[keyof MatchLoaders]>;
1993
1974
  interface MetaArgs<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
1994
- /** @deprecated Use `MetaArgs.loaderData` instead */
1995
- data: (Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown) | undefined;
1996
- loaderData: (Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown) | undefined;
1997
- params: Params;
1998
- location: Location;
1999
- matches: MetaMatches<MatchLoaders>;
2000
- error?: unknown;
1975
+ loaderData: (Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown) | undefined;
1976
+ params: Params;
1977
+ location: Location;
1978
+ matches: MetaMatches<MatchLoaders>;
1979
+ error?: unknown;
2001
1980
  }
2002
1981
  /**
2003
1982
  * A function that returns an array of data objects to use for rendering
@@ -2037,164 +2016,164 @@ interface MetaArgs<Loader extends LoaderFunction | ClientLoaderFunction | unknow
2037
2016
  * "root": RootLoader,
2038
2017
  * "routes/sales": SalesLoader,
2039
2018
  * "routes/sales/customers": CustomersLoader,
2040
- * }> = ({ data, matches }) => {
2041
- * const { name } = data
2019
+ * }> = ({ loaderData, matches }) => {
2020
+ * const { name } = loaderData
2042
2021
  * // ^? string
2043
- * const { customerCount } = matches.find((match) => match.id === "routes/sales/customers").data
2022
+ * const { customerCount } = matches.find((match) => match.id === "routes/sales/customers").loaderData
2044
2023
  * // ^? number
2045
- * const { salesCount } = matches.find((match) => match.id === "routes/sales").data
2024
+ * const { salesCount } = matches.find((match) => match.id === "routes/sales").loaderData
2046
2025
  * // ^? number
2047
- * const { hello } = matches.find((match) => match.id === "root").data
2026
+ * const { hello } = matches.find((match) => match.id === "root").loaderData
2048
2027
  * // ^? "world"
2049
2028
  * }
2050
2029
  * ```
2051
2030
  */
2052
2031
  interface MetaFunction<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
2053
- (args: MetaArgs<Loader, MatchLoaders>): MetaDescriptor[] | undefined;
2032
+ (args: MetaArgs<Loader, MatchLoaders>): MetaDescriptor[] | undefined;
2054
2033
  }
2055
2034
  type MetaDescriptor = {
2056
- charSet: "utf-8";
2035
+ charSet: "utf-8";
2057
2036
  } | {
2058
- title: string;
2037
+ title: string;
2059
2038
  } | {
2060
- name: string;
2061
- content: string;
2039
+ name: string;
2040
+ content: string;
2062
2041
  } | {
2063
- property: string;
2064
- content: string;
2042
+ property: string;
2043
+ content: string;
2065
2044
  } | {
2066
- httpEquiv: string;
2067
- content: string;
2045
+ httpEquiv: string;
2046
+ content: string;
2068
2047
  } | {
2069
- "script:ld+json": LdJsonObject | LdJsonObject[];
2048
+ "script:ld+json": LdJsonObject | LdJsonObject[];
2070
2049
  } | {
2071
- tagName: "meta" | "link";
2072
- [name: string]: string;
2050
+ tagName: "meta" | "link";
2051
+ [name: string]: string;
2073
2052
  } | {
2074
- [name: string]: unknown;
2075
- };
2076
- type LdJsonObject = {
2077
- [Key in string]: LdJsonValue;
2078
- } & {
2079
- [Key in string]?: LdJsonValue | undefined;
2053
+ [name: string]: unknown;
2080
2054
  };
2055
+ type LdJsonObject = { [Key in string]: LdJsonValue } & { [Key in string]?: LdJsonValue | undefined };
2081
2056
  type LdJsonArray = LdJsonValue[] | readonly LdJsonValue[];
2082
2057
  type LdJsonPrimitive = string | number | boolean | null;
2083
2058
  type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray;
2059
+ /**
2060
+ * A React component that is rendered for a route.
2061
+ */
2084
2062
  /**
2085
2063
  * An arbitrary object that is associated with a route.
2086
2064
  *
2087
2065
  * @see https://reactrouter.com/how-to/using-handle
2088
2066
  */
2089
2067
  type RouteHandle = unknown;
2090
-
2068
+ //#endregion
2069
+ //#region lib/components.d.ts
2091
2070
  interface AwaitResolveRenderFunction<Resolve = any> {
2092
- (data: Awaited<Resolve>): React.ReactNode;
2071
+ (data: Awaited<Resolve>): React.ReactNode;
2093
2072
  }
2094
2073
  /**
2095
2074
  * @category Types
2096
2075
  */
2097
2076
  interface AwaitProps<Resolve> {
2098
- /**
2099
- * When using a function, the resolved value is provided as the parameter.
2100
- *
2101
- * ```tsx [2]
2102
- * <Await resolve={reviewsPromise}>
2103
- * {(resolvedReviews) => <Reviews items={resolvedReviews} />}
2104
- * </Await>
2105
- * ```
2106
- *
2107
- * When using React elements, {@link useAsyncValue} will provide the
2108
- * resolved value:
2109
- *
2110
- * ```tsx [2]
2111
- * <Await resolve={reviewsPromise}>
2112
- * <Reviews />
2113
- * </Await>
2114
- *
2115
- * function Reviews() {
2116
- * const resolvedReviews = useAsyncValue();
2117
- * return <div>...</div>;
2118
- * }
2119
- * ```
2120
- */
2121
- children: React.ReactNode | AwaitResolveRenderFunction<Resolve>;
2122
- /**
2123
- * The error element renders instead of the `children` when the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
2124
- * rejects.
2125
- *
2126
- * ```tsx
2127
- * <Await
2128
- * errorElement={<div>Oops</div>}
2129
- * resolve={reviewsPromise}
2130
- * >
2131
- * <Reviews />
2132
- * </Await>
2133
- * ```
2134
- *
2135
- * To provide a more contextual error, you can use the {@link useAsyncError} in a
2136
- * child component
2137
- *
2138
- * ```tsx
2139
- * <Await
2140
- * errorElement={<ReviewsError />}
2141
- * resolve={reviewsPromise}
2142
- * >
2143
- * <Reviews />
2144
- * </Await>
2145
- *
2146
- * function ReviewsError() {
2147
- * const error = useAsyncError();
2148
- * return <div>Error loading reviews: {error.message}</div>;
2149
- * }
2150
- * ```
2151
- *
2152
- * If you do not provide an `errorElement`, the rejected value will bubble up
2153
- * to the nearest route-level [`ErrorBoundary`](../../start/framework/route-module#errorboundary)
2154
- * and be accessible via the {@link useRouteError} hook.
2155
- */
2156
- errorElement?: React.ReactNode;
2157
- /**
2158
- * Takes a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
2159
- * returned from a [`loader`](../../start/framework/route-module#loader) to be
2160
- * resolved and rendered.
2161
- *
2162
- * ```tsx
2163
- * import { Await, useLoaderData } from "react-router";
2164
- *
2165
- * export async function loader() {
2166
- * let reviews = getReviews(); // not awaited
2167
- * let book = await getBook();
2168
- * return {
2169
- * book,
2170
- * reviews, // this is a promise
2171
- * };
2172
- * }
2173
- *
2174
- * export default function Book() {
2175
- * const {
2176
- * book,
2177
- * reviews, // this is the same promise
2178
- * } = useLoaderData();
2179
- *
2180
- * return (
2181
- * <div>
2182
- * <h1>{book.title}</h1>
2183
- * <p>{book.description}</p>
2184
- * <React.Suspense fallback={<ReviewsSkeleton />}>
2185
- * <Await
2186
- * // and is the promise we pass to Await
2187
- * resolve={reviews}
2188
- * >
2189
- * <Reviews />
2190
- * </Await>
2191
- * </React.Suspense>
2192
- * </div>
2193
- * );
2194
- * }
2195
- * ```
2196
- */
2197
- resolve: Resolve;
2077
+ /**
2078
+ * When using a function, the resolved value is provided as the parameter.
2079
+ *
2080
+ * ```tsx [2]
2081
+ * <Await resolve={reviewsPromise}>
2082
+ * {(resolvedReviews) => <Reviews items={resolvedReviews} />}
2083
+ * </Await>
2084
+ * ```
2085
+ *
2086
+ * When using React elements, {@link useAsyncValue} will provide the
2087
+ * resolved value:
2088
+ *
2089
+ * ```tsx [2]
2090
+ * <Await resolve={reviewsPromise}>
2091
+ * <Reviews />
2092
+ * </Await>
2093
+ *
2094
+ * function Reviews() {
2095
+ * const resolvedReviews = useAsyncValue();
2096
+ * return <div>...</div>;
2097
+ * }
2098
+ * ```
2099
+ */
2100
+ children: React.ReactNode | AwaitResolveRenderFunction<Resolve>;
2101
+ /**
2102
+ * The error element renders instead of the `children` when the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
2103
+ * rejects.
2104
+ *
2105
+ * ```tsx
2106
+ * <Await
2107
+ * errorElement={<div>Oops</div>}
2108
+ * resolve={reviewsPromise}
2109
+ * >
2110
+ * <Reviews />
2111
+ * </Await>
2112
+ * ```
2113
+ *
2114
+ * To provide a more contextual error, you can use the {@link useAsyncError} in a
2115
+ * child component
2116
+ *
2117
+ * ```tsx
2118
+ * <Await
2119
+ * errorElement={<ReviewsError />}
2120
+ * resolve={reviewsPromise}
2121
+ * >
2122
+ * <Reviews />
2123
+ * </Await>
2124
+ *
2125
+ * function ReviewsError() {
2126
+ * const error = useAsyncError();
2127
+ * return <div>Error loading reviews: {error.message}</div>;
2128
+ * }
2129
+ * ```
2130
+ *
2131
+ * If you do not provide an `errorElement`, the rejected value will bubble up
2132
+ * to the nearest route-level [`ErrorBoundary`](../../start/framework/route-module#errorboundary)
2133
+ * and be accessible via the {@link useRouteError} hook.
2134
+ */
2135
+ errorElement?: React.ReactNode;
2136
+ /**
2137
+ * Takes a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
2138
+ * returned from a [`loader`](../../start/framework/route-module#loader) to be
2139
+ * resolved and rendered.
2140
+ *
2141
+ * ```tsx
2142
+ * import { Await, useLoaderData } from "react-router";
2143
+ *
2144
+ * export async function loader() {
2145
+ * let reviews = getReviews(); // not awaited
2146
+ * let book = await getBook();
2147
+ * return {
2148
+ * book,
2149
+ * reviews, // this is a promise
2150
+ * };
2151
+ * }
2152
+ *
2153
+ * export default function Book() {
2154
+ * const {
2155
+ * book,
2156
+ * reviews, // this is the same promise
2157
+ * } = useLoaderData();
2158
+ *
2159
+ * return (
2160
+ * <div>
2161
+ * <h1>{book.title}</h1>
2162
+ * <p>{book.description}</p>
2163
+ * <React.Suspense fallback={<ReviewsSkeleton />}>
2164
+ * <Await
2165
+ * // and is the promise we pass to Await
2166
+ * resolve={reviews}
2167
+ * >
2168
+ * <Reviews />
2169
+ * </Await>
2170
+ * </React.Suspense>
2171
+ * </div>
2172
+ * );
2173
+ * }
2174
+ * ```
2175
+ */
2176
+ resolve: Resolve;
2198
2177
  }
2199
2178
  /**
2200
2179
  * Used to render promise values with automatic error handling.
@@ -2243,115 +2222,119 @@ interface AwaitProps<Resolve> {
2243
2222
  * @param {AwaitProps.resolve} props.resolve n/a
2244
2223
  * @returns React element for the rendered awaited value
2245
2224
  */
2246
- declare function Await$1<Resolve>({ children, errorElement, resolve, }: AwaitProps<Resolve>): React.JSX.Element;
2247
-
2225
+ declare function Await$1<Resolve>({
2226
+ children,
2227
+ errorElement,
2228
+ resolve
2229
+ }: AwaitProps<Resolve>): React.JSX.Element;
2230
+ //#endregion
2231
+ //#region lib/rsc/server.rsc.d.ts
2248
2232
  declare function getRequest(): Request;
2249
2233
  declare const redirect: typeof redirect$1;
2250
2234
  declare const redirectDocument: typeof redirectDocument$1;
2251
- declare const replace: typeof replace$1;
2235
+ declare const replace$1: typeof replace$2;
2252
2236
  declare const Await: typeof Await$1;
2253
2237
  type RSCRouteConfigEntryBase = {
2254
- action?: ActionFunction;
2255
- clientAction?: ClientActionFunction;
2256
- clientLoader?: ClientLoaderFunction;
2257
- ErrorBoundary?: React.ComponentType<any>;
2258
- handle?: any;
2259
- headers?: HeadersFunction;
2260
- HydrateFallback?: React.ComponentType<any>;
2261
- Layout?: React.ComponentType<any>;
2262
- links?: LinksFunction;
2263
- loader?: LoaderFunction;
2264
- meta?: MetaFunction;
2265
- shouldRevalidate?: ShouldRevalidateFunction;
2238
+ action?: ActionFunction;
2239
+ clientAction?: ClientActionFunction;
2240
+ clientLoader?: ClientLoaderFunction;
2241
+ ErrorBoundary?: React.ComponentType<any>;
2242
+ handle?: any;
2243
+ headers?: HeadersFunction;
2244
+ HydrateFallback?: React.ComponentType<any>;
2245
+ Layout?: React.ComponentType<any>;
2246
+ links?: LinksFunction;
2247
+ loader?: LoaderFunction;
2248
+ meta?: MetaFunction;
2249
+ shouldRevalidate?: ShouldRevalidateFunction;
2266
2250
  };
2267
2251
  type RSCRouteConfigEntry = RSCRouteConfigEntryBase & {
2268
- id: string;
2269
- path?: string;
2252
+ id: string;
2253
+ path?: string;
2254
+ Component?: React.ComponentType<any>;
2255
+ lazy?: () => Promise<RSCRouteConfigEntryBase & ({
2256
+ default?: React.ComponentType<any>;
2257
+ Component?: never;
2258
+ } | {
2259
+ default?: never;
2270
2260
  Component?: React.ComponentType<any>;
2271
- lazy?: () => Promise<RSCRouteConfigEntryBase & ({
2272
- default?: React.ComponentType<any>;
2273
- Component?: never;
2274
- } | {
2275
- default?: never;
2276
- Component?: React.ComponentType<any>;
2277
- })>;
2261
+ })>;
2278
2262
  } & ({
2279
- index: true;
2263
+ index: true;
2280
2264
  } | {
2281
- children?: RSCRouteConfigEntry[];
2265
+ children?: RSCRouteConfigEntry[];
2282
2266
  });
2283
2267
  type RSCRouteConfig = Array<RSCRouteConfigEntry>;
2284
2268
  type RSCRouteManifest = {
2285
- clientAction?: ClientActionFunction;
2286
- clientLoader?: ClientLoaderFunction;
2287
- element?: React.ReactElement | false;
2288
- errorElement?: React.ReactElement;
2289
- handle?: any;
2290
- hasAction: boolean;
2291
- hasComponent: boolean;
2292
- hasErrorBoundary: boolean;
2293
- hasLoader: boolean;
2294
- hydrateFallbackElement?: React.ReactElement;
2295
- id: string;
2296
- index?: boolean;
2297
- links?: LinksFunction;
2298
- meta?: MetaFunction;
2299
- parentId?: string;
2300
- path?: string;
2301
- shouldRevalidate?: ShouldRevalidateFunction;
2269
+ clientAction?: ClientActionFunction;
2270
+ clientLoader?: ClientLoaderFunction;
2271
+ element?: React.ReactElement | false;
2272
+ errorElement?: React.ReactElement;
2273
+ handle?: any;
2274
+ hasAction: boolean;
2275
+ hasComponent: boolean;
2276
+ hasLoader: boolean;
2277
+ hydrateFallbackElement?: React.ReactElement;
2278
+ id: string;
2279
+ index?: boolean;
2280
+ links?: LinksFunction;
2281
+ meta?: MetaFunction;
2282
+ parentId?: string;
2283
+ path?: string;
2284
+ shouldRevalidate?: ShouldRevalidateFunction;
2302
2285
  };
2303
2286
  type RSCRouteMatch = RSCRouteManifest & {
2304
- params: Params;
2305
- pathname: string;
2306
- pathnameBase: string;
2287
+ params: Params;
2288
+ pathname: string;
2289
+ pathnameBase: string;
2307
2290
  };
2308
2291
  type RSCRenderPayload = {
2309
- type: "render";
2310
- actionData: Record<string, any> | null;
2311
- basename: string | undefined;
2312
- errors: Record<string, any> | null;
2313
- loaderData: Record<string, any>;
2314
- location: Location;
2315
- routeDiscovery: RouteDiscovery;
2316
- matches: RSCRouteMatch[];
2317
- patches?: Promise<RSCRouteManifest[]>;
2318
- nonce?: string;
2319
- formState?: unknown;
2292
+ type: "render";
2293
+ actionData: Record<string, any> | null;
2294
+ basename: string | undefined;
2295
+ errors: Record<string, any> | null;
2296
+ loaderData: Record<string, any>;
2297
+ location: Location;
2298
+ routeDiscovery: RouteDiscovery;
2299
+ matches: RSCRouteMatch[];
2300
+ patches?: Promise<RSCRouteManifest[]>;
2301
+ nonce?: string;
2302
+ formState?: unknown;
2320
2303
  };
2321
2304
  type RSCManifestPayload = {
2322
- type: "manifest";
2323
- patches: Promise<RSCRouteManifest[]>;
2305
+ type: "manifest";
2306
+ patches: Promise<RSCRouteManifest[]>;
2324
2307
  };
2325
2308
  type RSCActionPayload = {
2326
- type: "action";
2327
- actionResult: Promise<unknown>;
2328
- rerender?: Promise<RSCRenderPayload | RSCRedirectPayload>;
2309
+ type: "action";
2310
+ actionResult: Promise<unknown>;
2311
+ rerender?: Promise<RSCRenderPayload | RSCRedirectPayload>;
2329
2312
  };
2330
2313
  type RSCRedirectPayload = {
2331
- type: "redirect";
2332
- status: number;
2333
- location: string;
2334
- replace: boolean;
2335
- reload: boolean;
2336
- actionResult?: Promise<unknown>;
2314
+ type: "redirect";
2315
+ status: number;
2316
+ location: string;
2317
+ replace: boolean;
2318
+ reload: boolean;
2319
+ actionResult?: Promise<unknown>;
2337
2320
  };
2338
2321
  type RSCPayload = RSCRenderPayload | RSCManifestPayload | RSCActionPayload | RSCRedirectPayload;
2339
2322
  type RSCMatch = {
2340
- statusCode: number;
2341
- headers: Headers;
2342
- payload: RSCPayload;
2323
+ statusCode: number;
2324
+ headers: Headers;
2325
+ payload: RSCPayload;
2343
2326
  };
2344
2327
  type DecodeActionFunction = (formData: FormData) => Promise<() => Promise<unknown>>;
2345
2328
  type DecodeFormStateFunction = (result: unknown, formData: FormData) => unknown;
2346
2329
  type DecodeReplyFunction = (reply: FormData | string, options: {
2347
- temporaryReferences: unknown;
2330
+ temporaryReferences: unknown;
2348
2331
  }) => Promise<unknown[]>;
2349
2332
  type LoadServerActionFunction = (id: string) => Promise<Function>;
2350
2333
  type RouteDiscovery = {
2351
- mode: "lazy";
2352
- manifestPath?: string | undefined;
2334
+ mode: "lazy";
2335
+ manifestPath?: string | undefined;
2353
2336
  } | {
2354
- mode: "initial";
2337
+ mode: "initial";
2355
2338
  };
2356
2339
  /**
2357
2340
  * Matches the given routes to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
@@ -2425,47 +2408,61 @@ type RouteDiscovery = {
2425
2408
  * that contains the [RSC](https://react.dev/reference/rsc/server-components)
2426
2409
  * data for hydration.
2427
2410
  */
2428
- declare function matchRSCServerRequest({ allowedActionOrigins, createTemporaryReferenceSet, basename, decodeReply, requestContext, routeDiscovery, loadServerAction, decodeAction, decodeFormState, onError, request, routes, generateResponse, }: {
2429
- allowedActionOrigins?: string[];
2430
- createTemporaryReferenceSet: () => unknown;
2431
- basename?: string;
2432
- decodeReply?: DecodeReplyFunction;
2433
- decodeAction?: DecodeActionFunction;
2434
- decodeFormState?: DecodeFormStateFunction;
2435
- requestContext?: RouterContextProvider;
2436
- loadServerAction?: LoadServerActionFunction;
2437
- onError?: (error: unknown) => void;
2438
- request: Request;
2439
- routes: RSCRouteConfigEntry[];
2440
- routeDiscovery?: RouteDiscovery;
2441
- generateResponse: (match: RSCMatch, { onError, temporaryReferences, }: {
2442
- onError(error: unknown): string | undefined;
2443
- temporaryReferences: unknown;
2444
- }) => Response;
2411
+ declare function matchRSCServerRequest({
2412
+ allowedActionOrigins,
2413
+ createTemporaryReferenceSet,
2414
+ basename,
2415
+ decodeReply,
2416
+ requestContext,
2417
+ routeDiscovery,
2418
+ loadServerAction,
2419
+ decodeAction,
2420
+ decodeFormState,
2421
+ onError,
2422
+ request,
2423
+ routes,
2424
+ generateResponse
2425
+ }: {
2426
+ allowedActionOrigins?: string[];
2427
+ createTemporaryReferenceSet: () => unknown;
2428
+ basename?: string;
2429
+ decodeReply?: DecodeReplyFunction;
2430
+ decodeAction?: DecodeActionFunction;
2431
+ decodeFormState?: DecodeFormStateFunction;
2432
+ requestContext?: RouterContextProvider;
2433
+ loadServerAction?: LoadServerActionFunction;
2434
+ onError?: (error: unknown) => void;
2435
+ request: Request;
2436
+ routes: RSCRouteConfigEntry[];
2437
+ routeDiscovery?: RouteDiscovery;
2438
+ generateResponse: (match: RSCMatch, {
2439
+ onError,
2440
+ temporaryReferences
2441
+ }: {
2442
+ onError(error: unknown): string | undefined;
2443
+ temporaryReferences: unknown;
2444
+ }) => Response;
2445
2445
  }): Promise<Response>;
2446
-
2446
+ //#endregion
2447
+ //#region lib/types/register.d.ts
2447
2448
  /**
2448
2449
  * Apps can use this interface to "register" app-wide types for React Router via interface declaration merging and module augmentation.
2449
2450
  * React Router should handle this for you via type generation.
2450
2451
  *
2451
2452
  * For more on declaration merging and module augmentation, see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation .
2452
2453
  */
2453
- interface Register {
2454
- }
2454
+ interface Register {}
2455
2455
  type AnyParams = Record<string, string | undefined>;
2456
2456
  type AnyPages = Record<string, {
2457
- params: AnyParams;
2457
+ params: AnyParams;
2458
2458
  }>;
2459
2459
  type Pages = Register extends {
2460
- pages: infer Registered extends AnyPages;
2460
+ pages: infer Registered extends AnyPages;
2461
2461
  } ? Registered : AnyPages;
2462
-
2463
- type Args = {
2464
- [K in keyof Pages]: ToArgs<Pages[K]["params"]>;
2465
- };
2466
- type ToArgs<Params extends Record<string, string | undefined>> = Equal<Params, {}> extends true ? [] : Partial<Params> extends Params ? [Params] | [] : [
2467
- Params
2468
- ];
2462
+ //#endregion
2463
+ //#region lib/href.d.ts
2464
+ type Args = { [K in keyof Pages]: ToArgs<Pages[K]["params"]> };
2465
+ type ToArgs<Params extends Record<string, string | undefined>> = Equal<Params, {}> extends true ? [] : Partial<Params> extends Params ? [Params] | [] : [Params];
2469
2466
  /**
2470
2467
  Returns a resolved URL path for the specified route.
2471
2468
 
@@ -2477,19 +2474,20 @@ type ToArgs<Params extends Record<string, string | undefined>> = Equal<Params, {
2477
2474
  ```
2478
2475
  */
2479
2476
  declare function href<Path extends keyof Args>(path: Path, ...args: Args[Path]): string;
2480
-
2477
+ //#endregion
2478
+ //#region lib/server-runtime/cookies.d.ts
2481
2479
  interface CookieSignatureOptions {
2482
- /**
2483
- * An array of secrets that may be used to sign/unsign the value of a cookie.
2484
- *
2485
- * The array makes it easy to rotate secrets. New secrets should be added to
2486
- * the beginning of the array. `cookie.serialize()` will always use the first
2487
- * value in the array, but `cookie.parse()` may use any of them so that
2488
- * cookies that were signed with older secrets still work.
2489
- */
2490
- secrets?: string[];
2480
+ /**
2481
+ * An array of secrets that may be used to sign/unsign the value of a cookie.
2482
+ *
2483
+ * The array makes it easy to rotate secrets. New secrets should be added to
2484
+ * the beginning of the array. `cookie.serialize()` will always use the first
2485
+ * value in the array, but `cookie.parse()` may use any of them so that
2486
+ * cookies that were signed with older secrets still work.
2487
+ */
2488
+ secrets?: string[];
2491
2489
  }
2492
- type CookieOptions = ParseOptions & SerializeOptions & CookieSignatureOptions;
2490
+ type CookieOptions = CookieParseOptions & CookieSerializeOptions & CookieSignatureOptions;
2493
2491
  /**
2494
2492
  * A HTTP cookie.
2495
2493
  *
@@ -2501,31 +2499,31 @@ type CookieOptions = ParseOptions & SerializeOptions & CookieSignatureOptions;
2501
2499
  * @see https://remix.run/utils/cookies#cookie-api
2502
2500
  */
2503
2501
  interface Cookie {
2504
- /**
2505
- * The name of the cookie, used in the `Cookie` and `Set-Cookie` headers.
2506
- */
2507
- readonly name: string;
2508
- /**
2509
- * True if this cookie uses one or more secrets for verification.
2510
- */
2511
- readonly isSigned: boolean;
2512
- /**
2513
- * The Date this cookie expires.
2514
- *
2515
- * Note: This is calculated at access time using `maxAge` when no `expires`
2516
- * option is provided to `createCookie()`.
2517
- */
2518
- readonly expires?: Date;
2519
- /**
2520
- * Parses a raw `Cookie` header and returns the value of this cookie or
2521
- * `null` if it's not present.
2522
- */
2523
- parse(cookieHeader: string | null, options?: ParseOptions): Promise<any>;
2524
- /**
2525
- * Serializes the given value to a string and returns the `Set-Cookie`
2526
- * header.
2527
- */
2528
- serialize(value: any, options?: SerializeOptions): Promise<string>;
2502
+ /**
2503
+ * The name of the cookie, used in the `Cookie` and `Set-Cookie` headers.
2504
+ */
2505
+ readonly name: string;
2506
+ /**
2507
+ * True if this cookie uses one or more secrets for verification.
2508
+ */
2509
+ readonly isSigned: boolean;
2510
+ /**
2511
+ * The Date this cookie expires.
2512
+ *
2513
+ * Note: This is calculated at access time using `maxAge` when no `expires`
2514
+ * option is provided to `createCookie()`.
2515
+ */
2516
+ readonly expires?: Date;
2517
+ /**
2518
+ * Parses a raw `Cookie` header and returns the value of this cookie or
2519
+ * `null` if it's not present.
2520
+ */
2521
+ parse(cookieHeader: string | null, options?: CookieParseOptions): Promise<any>;
2522
+ /**
2523
+ * Serializes the given value to a string and returns the `Set-Cookie`
2524
+ * header.
2525
+ */
2526
+ serialize(value: any, options?: CookieSerializeOptions): Promise<string>;
2529
2527
  }
2530
2528
  /**
2531
2529
  * Creates a logical container for managing a browser cookie from the server.
@@ -2538,12 +2536,13 @@ type IsCookieFunction = (object: any) => object is Cookie;
2538
2536
  * @see https://remix.run/utils/cookies#iscookie
2539
2537
  */
2540
2538
  declare const isCookie: IsCookieFunction;
2541
-
2539
+ //#endregion
2540
+ //#region lib/server-runtime/sessions.d.ts
2542
2541
  /**
2543
2542
  * An object of name/value pairs to be used in the session.
2544
2543
  */
2545
2544
  interface SessionData {
2546
- [name: string]: any;
2545
+ [name: string]: any;
2547
2546
  }
2548
2547
  /**
2549
2548
  * Session persists data across HTTP requests.
@@ -2551,46 +2550,44 @@ interface SessionData {
2551
2550
  * @see https://reactrouter.com/explanation/sessions-and-cookies#sessions
2552
2551
  */
2553
2552
  interface Session<Data = SessionData, FlashData = Data> {
2554
- /**
2555
- * A unique identifier for this session.
2556
- *
2557
- * Note: This will be the empty string for newly created sessions and
2558
- * sessions that are not backed by a database (i.e. cookie-based sessions).
2559
- */
2560
- readonly id: string;
2561
- /**
2562
- * The raw data contained in this session.
2563
- *
2564
- * This is useful mostly for SessionStorage internally to access the raw
2565
- * session data to persist.
2566
- */
2567
- readonly data: FlashSessionData<Data, FlashData>;
2568
- /**
2569
- * Returns `true` if the session has a value for the given `name`, `false`
2570
- * otherwise.
2571
- */
2572
- has(name: (keyof Data | keyof FlashData) & string): boolean;
2573
- /**
2574
- * Returns the value for the given `name` in this session.
2575
- */
2576
- get<Key extends (keyof Data | keyof FlashData) & string>(name: Key): (Key extends keyof Data ? Data[Key] : undefined) | (Key extends keyof FlashData ? FlashData[Key] : undefined) | undefined;
2577
- /**
2578
- * Sets a value in the session for the given `name`.
2579
- */
2580
- set<Key extends keyof Data & string>(name: Key, value: Data[Key]): void;
2581
- /**
2582
- * Sets a value in the session that is only valid until the next `get()`.
2583
- * This can be useful for temporary values, like error messages.
2584
- */
2585
- flash<Key extends keyof FlashData & string>(name: Key, value: FlashData[Key]): void;
2586
- /**
2587
- * Removes a value from the session.
2588
- */
2589
- unset(name: keyof Data & string): void;
2553
+ /**
2554
+ * A unique identifier for this session.
2555
+ *
2556
+ * Note: This will be the empty string for newly created sessions and
2557
+ * sessions that are not backed by a database (i.e. cookie-based sessions).
2558
+ */
2559
+ readonly id: string;
2560
+ /**
2561
+ * The raw data contained in this session.
2562
+ *
2563
+ * This is useful mostly for SessionStorage internally to access the raw
2564
+ * session data to persist.
2565
+ */
2566
+ readonly data: FlashSessionData<Data, FlashData>;
2567
+ /**
2568
+ * Returns `true` if the session has a value for the given `name`, `false`
2569
+ * otherwise.
2570
+ */
2571
+ has(name: (keyof Data | keyof FlashData) & string): boolean;
2572
+ /**
2573
+ * Returns the value for the given `name` in this session.
2574
+ */
2575
+ get<Key extends (keyof Data | keyof FlashData) & string>(name: Key): (Key extends keyof Data ? Data[Key] : undefined) | (Key extends keyof FlashData ? FlashData[Key] : undefined) | undefined;
2576
+ /**
2577
+ * Sets a value in the session for the given `name`.
2578
+ */
2579
+ set<Key extends keyof Data & string>(name: Key, value: Data[Key]): void;
2580
+ /**
2581
+ * Sets a value in the session that is only valid until the next `get()`.
2582
+ * This can be useful for temporary values, like error messages.
2583
+ */
2584
+ flash<Key extends keyof FlashData & string>(name: Key, value: FlashData[Key]): void;
2585
+ /**
2586
+ * Removes a value from the session.
2587
+ */
2588
+ unset(name: keyof Data & string): void;
2590
2589
  }
2591
- type FlashSessionData<Data, FlashData> = Partial<Data & {
2592
- [Key in keyof FlashData as FlashDataKey<Key & string>]: FlashData[Key];
2593
- }>;
2590
+ type FlashSessionData<Data, FlashData> = Partial<Data & { [Key in keyof FlashData as FlashDataKey<Key & string>]: FlashData[Key] }>;
2594
2591
  type FlashDataKey<Key extends string> = `__flash_${Key}__`;
2595
2592
  type CreateSessionFunction = <Data = SessionData, FlashData = Data>(initialData?: Data, id?: string) => Session<Data, FlashData>;
2596
2593
  /**
@@ -2615,22 +2612,22 @@ declare const isSession: IsSessionFunction;
2615
2612
  * Then, later it generates the `Set-Cookie` header to be used in the response.
2616
2613
  */
2617
2614
  interface SessionStorage<Data = SessionData, FlashData = Data> {
2618
- /**
2619
- * Parses a Cookie header from a HTTP request and returns the associated
2620
- * Session. If there is no session associated with the cookie, this will
2621
- * return a new Session with no data.
2622
- */
2623
- getSession: (cookieHeader?: string | null, options?: ParseOptions) => Promise<Session<Data, FlashData>>;
2624
- /**
2625
- * Stores all data in the Session and returns the Set-Cookie header to be
2626
- * used in the HTTP response.
2627
- */
2628
- commitSession: (session: Session<Data, FlashData>, options?: SerializeOptions) => Promise<string>;
2629
- /**
2630
- * Deletes all data associated with the Session and returns the Set-Cookie
2631
- * header to be used in the HTTP response.
2632
- */
2633
- destroySession: (session: Session<Data, FlashData>, options?: SerializeOptions) => Promise<string>;
2615
+ /**
2616
+ * Parses a Cookie header from a HTTP request and returns the associated
2617
+ * Session. If there is no session associated with the cookie, this will
2618
+ * return a new Session with no data.
2619
+ */
2620
+ getSession: (cookieHeader?: string | null, options?: CookieParseOptions$1) => Promise<Session<Data, FlashData>>;
2621
+ /**
2622
+ * Stores all data in the Session and returns the Set-Cookie header to be
2623
+ * used in the HTTP response.
2624
+ */
2625
+ commitSession: (session: Session<Data, FlashData>, options?: CookieSerializeOptions$1) => Promise<string>;
2626
+ /**
2627
+ * Deletes all data associated with the Session and returns the Set-Cookie
2628
+ * header to be used in the HTTP response.
2629
+ */
2630
+ destroySession: (session: Session<Data, FlashData>, options?: CookieSerializeOptions$1) => Promise<string>;
2634
2631
  }
2635
2632
  /**
2636
2633
  * SessionIdStorageStrategy is designed to allow anyone to easily build their
@@ -2642,29 +2639,29 @@ interface SessionStorage<Data = SessionData, FlashData = Data> {
2642
2639
  * are provided for managing the session data.
2643
2640
  */
2644
2641
  interface SessionIdStorageStrategy<Data = SessionData, FlashData = Data> {
2645
- /**
2646
- * The Cookie used to store the session id, or options used to automatically
2647
- * create one.
2648
- */
2649
- cookie?: Cookie | (CookieOptions & {
2650
- name?: string;
2651
- });
2652
- /**
2653
- * Creates a new record with the given data and returns the session id.
2654
- */
2655
- createData: (data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<string>;
2656
- /**
2657
- * Returns data for a given session id, or `null` if there isn't any.
2658
- */
2659
- readData: (id: string) => Promise<FlashSessionData<Data, FlashData> | null>;
2660
- /**
2661
- * Updates data for the given session id.
2662
- */
2663
- updateData: (id: string, data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<void>;
2664
- /**
2665
- * Deletes data for a given session id from the data store.
2666
- */
2667
- deleteData: (id: string) => Promise<void>;
2642
+ /**
2643
+ * The Cookie used to store the session id, or options used to automatically
2644
+ * create one.
2645
+ */
2646
+ cookie?: Cookie | (CookieOptions & {
2647
+ name?: string;
2648
+ });
2649
+ /**
2650
+ * Creates a new record with the given data and returns the session id.
2651
+ */
2652
+ createData: (data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<string>;
2653
+ /**
2654
+ * Returns data for a given session id, or `null` if there isn't any.
2655
+ */
2656
+ readData: (id: string) => Promise<FlashSessionData<Data, FlashData> | null>;
2657
+ /**
2658
+ * Updates data for the given session id.
2659
+ */
2660
+ updateData: (id: string, data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<void>;
2661
+ /**
2662
+ * Deletes data for a given session id from the data store.
2663
+ */
2664
+ deleteData: (id: string) => Promise<void>;
2668
2665
  }
2669
2666
  /**
2670
2667
  * Creates a SessionStorage object using a SessionIdStorageStrategy.
@@ -2672,14 +2669,21 @@ interface SessionIdStorageStrategy<Data = SessionData, FlashData = Data> {
2672
2669
  * Note: This is a low-level API that should only be used if none of the
2673
2670
  * existing session storage options meet your requirements.
2674
2671
  */
2675
- declare function createSessionStorage<Data = SessionData, FlashData = Data>({ cookie: cookieArg, createData, readData, updateData, deleteData, }: SessionIdStorageStrategy<Data, FlashData>): SessionStorage<Data, FlashData>;
2676
-
2672
+ declare function createSessionStorage<Data = SessionData, FlashData = Data>({
2673
+ cookie: cookieArg,
2674
+ createData,
2675
+ readData,
2676
+ updateData,
2677
+ deleteData
2678
+ }: SessionIdStorageStrategy<Data, FlashData>): SessionStorage<Data, FlashData>;
2679
+ //#endregion
2680
+ //#region lib/server-runtime/sessions/cookieStorage.d.ts
2677
2681
  interface CookieSessionStorageOptions {
2678
- /**
2679
- * The Cookie used to store the session data on the client, or options used
2680
- * to automatically create one.
2681
- */
2682
- cookie?: SessionIdStorageStrategy["cookie"];
2682
+ /**
2683
+ * The Cookie used to store the session data on the client, or options used
2684
+ * to automatically create one.
2685
+ */
2686
+ cookie?: SessionIdStorageStrategy["cookie"];
2683
2687
  }
2684
2688
  /**
2685
2689
  * Creates and returns a SessionStorage object that stores all session data
@@ -2690,14 +2694,17 @@ interface CookieSessionStorageOptions {
2690
2694
  * also has the limitation that serialized session data may not exceed the
2691
2695
  * browser's maximum cookie size. Trade-offs!
2692
2696
  */
2693
- declare function createCookieSessionStorage<Data = SessionData, FlashData = Data>({ cookie: cookieArg }?: CookieSessionStorageOptions): SessionStorage<Data, FlashData>;
2694
-
2697
+ declare function createCookieSessionStorage<Data = SessionData, FlashData = Data>({
2698
+ cookie: cookieArg
2699
+ }?: CookieSessionStorageOptions): SessionStorage<Data, FlashData>;
2700
+ //#endregion
2701
+ //#region lib/server-runtime/sessions/memoryStorage.d.ts
2695
2702
  interface MemorySessionStorageOptions {
2696
- /**
2697
- * The Cookie used to store the session id on the client, or options used
2698
- * to automatically create one.
2699
- */
2700
- cookie?: SessionIdStorageStrategy["cookie"];
2703
+ /**
2704
+ * The Cookie used to store the session id on the client, or options used
2705
+ * to automatically create one.
2706
+ */
2707
+ cookie?: SessionIdStorageStrategy["cookie"];
2701
2708
  }
2702
2709
  /**
2703
2710
  * Creates and returns a simple in-memory SessionStorage object, mostly useful
@@ -2706,6 +2713,8 @@ interface MemorySessionStorageOptions {
2706
2713
  * Note: This storage does not scale beyond a single process, so it is not
2707
2714
  * suitable for most production scenarios.
2708
2715
  */
2709
- declare function createMemorySessionStorage<Data = SessionData, FlashData = Data>({ cookie }?: MemorySessionStorageOptions): SessionStorage<Data, FlashData>;
2710
-
2711
- export { Await, type Cookie, type CookieOptions, type CookieSignatureOptions, type FlashSessionData, type IsCookieFunction, type IsSessionFunction, type MiddlewareFunction, type MiddlewareNextFunction, type RouterContext, RouterContextProvider, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, createContext, createCookie, createCookieSessionStorage, createMemorySessionStorage, createSession, createSessionStorage, createStaticHandler, data, href, isCookie, isRouteErrorResponse, isSession, matchRoutes, redirect, redirectDocument, replace, type DecodeActionFunction as unstable_DecodeActionFunction, type DecodeFormStateFunction as unstable_DecodeFormStateFunction, type DecodeReplyFunction as unstable_DecodeReplyFunction, type LoadServerActionFunction as unstable_LoadServerActionFunction, type RSCManifestPayload as unstable_RSCManifestPayload, type RSCMatch as unstable_RSCMatch, type RSCPayload as unstable_RSCPayload, type RSCRenderPayload as unstable_RSCRenderPayload, type RSCRouteConfig as unstable_RSCRouteConfig, type RSCRouteConfigEntry as unstable_RSCRouteConfigEntry, type RSCRouteManifest as unstable_RSCRouteManifest, type RSCRouteMatch as unstable_RSCRouteMatch, getRequest as unstable_getRequest, matchRSCServerRequest as unstable_matchRSCServerRequest };
2716
+ declare function createMemorySessionStorage<Data = SessionData, FlashData = Data>({
2717
+ cookie
2718
+ }?: MemorySessionStorageOptions): SessionStorage<Data, FlashData>;
2719
+ //#endregion
2720
+ export { Await, BrowserRouter, type Cookie, type CookieOptions, type CookieParseOptions, type CookieSerializeOptions, type CookieSignatureOptions, type FlashSessionData, Form, HashRouter, type IsCookieFunction, type IsSessionFunction, Link, Links, MemoryRouter, Meta, type MiddlewareFunction, type MiddlewareNextFunction, NavLink, Navigate, Outlet, Route, Router, type RouterContext, RouterContextProvider, RouterProvider, Routes, ScrollRestoration, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, StaticRouter, StaticRouterProvider, createContext, createCookie, createCookieSessionStorage, createMemorySessionStorage, createSession, createSessionStorage, createStaticHandler, data, href, isCookie, isRouteErrorResponse, isSession, matchRoutes, redirect, redirectDocument, replace$1 as replace, type DecodeActionFunction as unstable_DecodeActionFunction, type DecodeFormStateFunction as unstable_DecodeFormStateFunction, type DecodeReplyFunction as unstable_DecodeReplyFunction, unstable_HistoryRouter, type LoadServerActionFunction as unstable_LoadServerActionFunction, type RSCManifestPayload as unstable_RSCManifestPayload, type RSCMatch as unstable_RSCMatch, type RSCPayload as unstable_RSCPayload, type RSCRenderPayload as unstable_RSCRenderPayload, type RSCRouteConfig as unstable_RSCRouteConfig, type RSCRouteConfigEntry as unstable_RSCRouteConfigEntry, type RSCRouteManifest as unstable_RSCRouteManifest, type RSCRouteMatch as unstable_RSCRouteMatch, getRequest as unstable_getRequest, matchRSCServerRequest as unstable_matchRSCServerRequest };