react-router 7.15.1 → 8.0.0-pre.0

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 (369) hide show
  1. package/CHANGELOG.md +18 -2
  2. package/dist/development/dom-export.d.ts +6 -172
  3. package/dist/development/dom-export.js +12 -1007
  4. package/dist/development/index-react-server-client.d.ts +7 -4
  5. package/dist/development/index-react-server-client.js +8 -52
  6. package/dist/development/index-react-server.d.ts +1645 -1635
  7. package/dist/development/index-react-server.js +2880 -3642
  8. package/dist/development/index.d.ts +43 -1469
  9. package/dist/development/index.js +37 -2621
  10. package/dist/development/lib/actions.js +62 -0
  11. package/dist/development/lib/components.d.ts +1022 -0
  12. package/dist/development/lib/components.js +835 -0
  13. package/dist/development/lib/context.d.ts +83 -0
  14. package/dist/development/lib/context.js +41 -0
  15. package/dist/development/lib/dom/dom.d.ts +119 -0
  16. package/dist/development/lib/dom/dom.js +143 -0
  17. package/dist/development/lib/dom/lib.d.ts +2042 -0
  18. package/dist/development/lib/dom/lib.js +1259 -0
  19. package/dist/development/lib/dom/server.d.ts +138 -0
  20. package/dist/development/lib/dom/server.js +301 -0
  21. package/dist/development/lib/dom/ssr/components.d.ts +196 -0
  22. package/dist/development/lib/dom/ssr/components.js +579 -0
  23. package/dist/development/lib/dom/ssr/data.js +29 -0
  24. package/dist/development/lib/dom/ssr/entry.d.ts +59 -0
  25. package/dist/development/lib/dom/ssr/errorBoundaries.d.ts +27 -0
  26. package/dist/development/lib/dom/ssr/errorBoundaries.js +83 -0
  27. package/dist/development/lib/dom/ssr/errors.d.ts +7 -0
  28. package/dist/development/lib/dom/ssr/errors.js +36 -0
  29. package/dist/development/lib/dom/ssr/fallback.js +28 -0
  30. package/dist/development/lib/dom/ssr/fog-of-war.d.ts +12 -0
  31. package/dist/development/lib/dom/ssr/fog-of-war.js +170 -0
  32. package/dist/development/lib/dom/ssr/hydration.d.ts +32 -0
  33. package/dist/development/lib/dom/ssr/hydration.js +29 -0
  34. package/dist/development/lib/dom/ssr/invariant.js +16 -0
  35. package/dist/development/lib/dom/ssr/links.js +170 -0
  36. package/dist/development/lib/dom/ssr/markup.js +24 -0
  37. package/dist/development/lib/dom/ssr/routeModules.d.ts +206 -0
  38. package/dist/development/lib/dom/ssr/routeModules.js +31 -0
  39. package/dist/development/lib/dom/ssr/routes-test-stub.d.ts +62 -0
  40. package/dist/development/lib/dom/ssr/routes-test-stub.js +108 -0
  41. package/dist/development/lib/dom/ssr/routes.d.ts +33 -0
  42. package/dist/development/lib/dom/ssr/routes.js +303 -0
  43. package/dist/development/lib/dom/ssr/server.d.ts +45 -0
  44. package/dist/development/lib/dom/ssr/server.js +68 -0
  45. package/dist/development/lib/dom/ssr/single-fetch.d.ts +14 -0
  46. package/dist/development/lib/dom/ssr/single-fetch.js +346 -0
  47. package/dist/development/lib/dom-export/dom-router-provider.d.ts +9 -0
  48. package/dist/development/lib/dom-export/dom-router-provider.js +22 -0
  49. package/dist/development/lib/dom-export/hydrated-router.d.ts +125 -0
  50. package/dist/development/lib/dom-export/hydrated-router.js +153 -0
  51. package/dist/development/lib/errors.js +29 -0
  52. package/dist/development/lib/hooks.d.ts +947 -0
  53. package/dist/development/lib/hooks.js +1386 -0
  54. package/dist/development/lib/href.d.ts +20 -0
  55. package/dist/development/lib/href.js +50 -0
  56. package/dist/development/lib/router/history.d.ts +258 -0
  57. package/dist/development/lib/router/history.js +371 -0
  58. package/dist/development/lib/router/instrumentation.d.ts +86 -0
  59. package/dist/development/lib/router/instrumentation.js +213 -0
  60. package/dist/development/lib/router/links.d.ts +113 -0
  61. package/dist/development/lib/router/router.d.ts +663 -0
  62. package/dist/development/lib/router/router.js +2981 -0
  63. package/dist/development/lib/router/utils.d.ts +942 -0
  64. package/dist/development/lib/router/utils.js +791 -0
  65. package/dist/development/lib/rsc/browser.d.ts +137 -0
  66. package/dist/development/lib/rsc/browser.js +599 -0
  67. package/dist/development/lib/rsc/errorBoundaries.d.ts +11 -0
  68. package/dist/development/lib/rsc/errorBoundaries.js +90 -0
  69. package/dist/development/lib/rsc/html-stream/browser.d.ts +48 -0
  70. package/dist/development/lib/rsc/html-stream/browser.js +74 -0
  71. package/dist/development/lib/rsc/html-stream/server.js +78 -0
  72. package/dist/development/lib/rsc/route-modules.js +27 -0
  73. package/dist/development/lib/rsc/server.rsc.d.ts +219 -0
  74. package/dist/development/lib/rsc/server.ssr.d.ts +129 -0
  75. package/dist/development/lib/rsc/server.ssr.js +388 -0
  76. package/dist/development/lib/server-runtime/build.d.ts +66 -0
  77. package/dist/development/lib/server-runtime/cookies.d.ts +66 -0
  78. package/dist/development/lib/server-runtime/cookies.js +139 -0
  79. package/dist/development/lib/server-runtime/crypto.js +43 -0
  80. package/dist/development/lib/server-runtime/data.d.ts +13 -0
  81. package/dist/development/lib/server-runtime/data.js +25 -0
  82. package/dist/development/lib/server-runtime/dev.d.ts +9 -0
  83. package/dist/development/lib/server-runtime/dev.js +26 -0
  84. package/dist/development/lib/server-runtime/entry.js +20 -0
  85. package/dist/development/lib/server-runtime/errors.js +95 -0
  86. package/dist/development/lib/server-runtime/headers.js +73 -0
  87. package/dist/development/lib/server-runtime/invariant.js +19 -0
  88. package/dist/development/lib/server-runtime/mode.d.ts +12 -0
  89. package/dist/development/lib/server-runtime/mode.js +25 -0
  90. package/dist/development/lib/server-runtime/routeMatching.js +28 -0
  91. package/dist/development/lib/server-runtime/routes.d.ts +13 -0
  92. package/dist/development/lib/server-runtime/routes.js +74 -0
  93. package/dist/development/lib/server-runtime/server.d.ts +10 -0
  94. package/dist/development/lib/server-runtime/server.js +351 -0
  95. package/dist/development/lib/server-runtime/serverHandoff.js +17 -0
  96. package/dist/development/lib/server-runtime/sessions/cookieStorage.d.ts +25 -0
  97. package/dist/development/lib/server-runtime/sessions/cookieStorage.js +45 -0
  98. package/dist/development/lib/server-runtime/sessions/memoryStorage.d.ts +23 -0
  99. package/dist/development/lib/server-runtime/sessions/memoryStorage.js +52 -0
  100. package/dist/development/lib/server-runtime/sessions.d.ts +145 -0
  101. package/dist/development/lib/server-runtime/sessions.js +98 -0
  102. package/dist/development/lib/server-runtime/single-fetch.d.ts +7 -0
  103. package/dist/development/lib/server-runtime/single-fetch.js +215 -0
  104. package/dist/development/lib/server-runtime/urls.js +31 -0
  105. package/dist/development/lib/server-runtime/warnings.js +20 -0
  106. package/dist/development/lib/types/future.d.ts +9 -0
  107. package/dist/development/lib/types/internal.d.ts +26 -177
  108. package/dist/development/lib/types/internal.js +3 -2
  109. package/dist/{production/register-Bsscfj79.d.ts → development/lib/types/register.d.ts} +9 -15
  110. package/dist/development/lib/types/route-data.d.ts +113 -0
  111. package/dist/development/lib/types/route-module-annotations.d.ts +149 -0
  112. package/dist/development/lib/types/route-module.d.ts +19 -0
  113. package/dist/development/lib/types/serializes-to.d.ts +13 -0
  114. package/dist/development/lib/types/utils.d.ts +11 -0
  115. package/dist/development/vendor/turbo-stream-v2/flatten.js +159 -0
  116. package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +178 -0
  117. package/dist/development/vendor/turbo-stream-v2/unflatten.js +198 -0
  118. package/dist/development/vendor/turbo-stream-v2/utils.js +47 -0
  119. package/dist/production/dom-export.d.ts +6 -172
  120. package/dist/production/dom-export.js +12 -1007
  121. package/dist/production/index-react-server-client.d.ts +7 -4
  122. package/dist/production/index-react-server-client.js +8 -52
  123. package/dist/production/index-react-server.d.ts +1645 -1635
  124. package/dist/production/index-react-server.js +2871 -3642
  125. package/dist/production/index.d.ts +43 -1469
  126. package/dist/production/index.js +37 -2621
  127. package/dist/production/lib/actions.js +62 -0
  128. package/dist/production/lib/components.d.ts +1022 -0
  129. package/dist/production/lib/components.js +835 -0
  130. package/dist/production/lib/context.d.ts +83 -0
  131. package/dist/production/lib/context.js +41 -0
  132. package/dist/production/lib/dom/dom.d.ts +119 -0
  133. package/dist/production/lib/dom/dom.js +143 -0
  134. package/dist/production/lib/dom/lib.d.ts +2042 -0
  135. package/dist/production/lib/dom/lib.js +1259 -0
  136. package/dist/production/lib/dom/server.d.ts +138 -0
  137. package/dist/production/lib/dom/server.js +301 -0
  138. package/dist/production/lib/dom/ssr/components.d.ts +196 -0
  139. package/dist/production/lib/dom/ssr/components.js +579 -0
  140. package/dist/production/lib/dom/ssr/data.js +29 -0
  141. package/dist/production/lib/dom/ssr/entry.d.ts +59 -0
  142. package/dist/production/lib/dom/ssr/errorBoundaries.d.ts +27 -0
  143. package/dist/production/lib/dom/ssr/errorBoundaries.js +83 -0
  144. package/dist/production/lib/dom/ssr/errors.d.ts +7 -0
  145. package/dist/production/lib/dom/ssr/errors.js +36 -0
  146. package/dist/production/lib/dom/ssr/fallback.js +21 -0
  147. package/dist/production/lib/dom/ssr/fog-of-war.d.ts +12 -0
  148. package/dist/production/lib/dom/ssr/fog-of-war.js +170 -0
  149. package/dist/production/lib/dom/ssr/hydration.d.ts +32 -0
  150. package/dist/production/lib/dom/ssr/hydration.js +29 -0
  151. package/dist/production/lib/dom/ssr/invariant.js +16 -0
  152. package/dist/production/lib/dom/ssr/links.js +170 -0
  153. package/dist/production/lib/dom/ssr/markup.js +24 -0
  154. package/dist/production/lib/dom/ssr/routeModules.d.ts +206 -0
  155. package/dist/production/lib/dom/ssr/routeModules.js +31 -0
  156. package/dist/production/lib/dom/ssr/routes-test-stub.d.ts +62 -0
  157. package/dist/production/lib/dom/ssr/routes-test-stub.js +108 -0
  158. package/dist/production/lib/dom/ssr/routes.d.ts +33 -0
  159. package/dist/production/lib/dom/ssr/routes.js +303 -0
  160. package/dist/production/lib/dom/ssr/server.d.ts +45 -0
  161. package/dist/production/lib/dom/ssr/server.js +68 -0
  162. package/dist/production/lib/dom/ssr/single-fetch.d.ts +14 -0
  163. package/dist/production/lib/dom/ssr/single-fetch.js +346 -0
  164. package/dist/production/lib/dom-export/dom-router-provider.d.ts +9 -0
  165. package/dist/production/lib/dom-export/dom-router-provider.js +22 -0
  166. package/dist/production/lib/dom-export/hydrated-router.d.ts +125 -0
  167. package/dist/production/lib/dom-export/hydrated-router.js +153 -0
  168. package/dist/production/lib/errors.js +29 -0
  169. package/dist/production/lib/hooks.d.ts +947 -0
  170. package/dist/production/lib/hooks.js +1371 -0
  171. package/dist/production/lib/href.d.ts +20 -0
  172. package/dist/production/lib/href.js +50 -0
  173. package/dist/production/lib/router/history.d.ts +258 -0
  174. package/dist/production/lib/router/history.js +371 -0
  175. package/dist/production/lib/router/instrumentation.d.ts +86 -0
  176. package/dist/production/lib/router/instrumentation.js +213 -0
  177. package/dist/production/lib/router/links.d.ts +113 -0
  178. package/dist/production/lib/router/router.d.ts +663 -0
  179. package/dist/production/lib/router/router.js +2981 -0
  180. package/dist/production/lib/router/utils.d.ts +942 -0
  181. package/dist/production/lib/router/utils.js +782 -0
  182. package/dist/production/lib/rsc/browser.d.ts +137 -0
  183. package/dist/production/lib/rsc/browser.js +599 -0
  184. package/dist/production/lib/rsc/errorBoundaries.d.ts +11 -0
  185. package/dist/production/lib/rsc/errorBoundaries.js +90 -0
  186. package/dist/production/lib/rsc/html-stream/browser.d.ts +48 -0
  187. package/dist/production/lib/rsc/html-stream/browser.js +74 -0
  188. package/dist/production/lib/rsc/html-stream/server.js +78 -0
  189. package/dist/production/lib/rsc/route-modules.js +27 -0
  190. package/dist/production/lib/rsc/server.rsc.d.ts +219 -0
  191. package/dist/production/lib/rsc/server.ssr.d.ts +129 -0
  192. package/dist/production/lib/rsc/server.ssr.js +388 -0
  193. package/dist/production/lib/server-runtime/build.d.ts +66 -0
  194. package/dist/production/lib/server-runtime/cookies.d.ts +66 -0
  195. package/dist/production/lib/server-runtime/cookies.js +139 -0
  196. package/dist/production/lib/server-runtime/crypto.js +43 -0
  197. package/dist/production/lib/server-runtime/data.d.ts +13 -0
  198. package/dist/production/lib/server-runtime/data.js +25 -0
  199. package/dist/production/lib/server-runtime/dev.d.ts +9 -0
  200. package/dist/production/lib/server-runtime/dev.js +26 -0
  201. package/dist/production/lib/server-runtime/entry.js +20 -0
  202. package/dist/production/lib/server-runtime/errors.js +95 -0
  203. package/dist/production/lib/server-runtime/headers.js +73 -0
  204. package/dist/production/lib/server-runtime/invariant.js +19 -0
  205. package/dist/production/lib/server-runtime/mode.d.ts +12 -0
  206. package/dist/production/lib/server-runtime/mode.js +25 -0
  207. package/dist/production/lib/server-runtime/routeMatching.js +28 -0
  208. package/dist/production/lib/server-runtime/routes.d.ts +13 -0
  209. package/dist/production/lib/server-runtime/routes.js +74 -0
  210. package/dist/production/lib/server-runtime/server.d.ts +10 -0
  211. package/dist/production/lib/server-runtime/server.js +351 -0
  212. package/dist/production/lib/server-runtime/serverHandoff.js +17 -0
  213. package/dist/production/lib/server-runtime/sessions/cookieStorage.d.ts +25 -0
  214. package/dist/production/lib/server-runtime/sessions/cookieStorage.js +45 -0
  215. package/dist/production/lib/server-runtime/sessions/memoryStorage.d.ts +23 -0
  216. package/dist/production/lib/server-runtime/sessions/memoryStorage.js +52 -0
  217. package/dist/production/lib/server-runtime/sessions.d.ts +145 -0
  218. package/dist/production/lib/server-runtime/sessions.js +98 -0
  219. package/dist/production/lib/server-runtime/single-fetch.d.ts +7 -0
  220. package/dist/production/lib/server-runtime/single-fetch.js +215 -0
  221. package/dist/production/lib/server-runtime/urls.js +31 -0
  222. package/dist/production/lib/server-runtime/warnings.js +20 -0
  223. package/dist/production/lib/types/future.d.ts +9 -0
  224. package/dist/production/lib/types/internal.d.ts +26 -177
  225. package/dist/production/lib/types/internal.js +3 -2
  226. package/dist/{development/register-Bsscfj79.d.ts → production/lib/types/register.d.ts} +9 -15
  227. package/dist/production/lib/types/route-data.d.ts +113 -0
  228. package/dist/production/lib/types/route-module-annotations.d.ts +149 -0
  229. package/dist/production/lib/types/route-module.d.ts +19 -0
  230. package/dist/production/lib/types/serializes-to.d.ts +13 -0
  231. package/dist/production/lib/types/utils.d.ts +11 -0
  232. package/dist/production/vendor/turbo-stream-v2/flatten.js +159 -0
  233. package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +178 -0
  234. package/dist/production/vendor/turbo-stream-v2/unflatten.js +198 -0
  235. package/dist/production/vendor/turbo-stream-v2/utils.js +47 -0
  236. package/docs/explanation/backend-for-frontend.md +50 -0
  237. package/docs/explanation/code-splitting.md +77 -0
  238. package/docs/explanation/concurrency.md +135 -0
  239. package/docs/explanation/form-vs-fetcher.md +292 -0
  240. package/docs/explanation/hot-module-replacement.md +137 -0
  241. package/docs/explanation/hydration.md +14 -0
  242. package/docs/explanation/index-query-param.md +86 -0
  243. package/docs/explanation/index.md +4 -0
  244. package/docs/explanation/lazy-route-discovery.md +78 -0
  245. package/docs/explanation/location.md +6 -0
  246. package/docs/explanation/progressive-enhancement.md +150 -0
  247. package/docs/explanation/race-conditions.md +88 -0
  248. package/docs/explanation/react-transitions.md +160 -0
  249. package/docs/explanation/route-matching.md +7 -0
  250. package/docs/explanation/server-client-execution.md +4 -0
  251. package/docs/explanation/sessions-and-cookies.md +465 -0
  252. package/docs/explanation/special-files.md +16 -0
  253. package/docs/explanation/state-management.md +524 -0
  254. package/docs/explanation/styling.md +87 -0
  255. package/docs/explanation/type-safety.md +82 -0
  256. package/docs/how-to/accessibility.md +44 -0
  257. package/docs/how-to/client-data.md +199 -0
  258. package/docs/how-to/data-strategy.md +317 -0
  259. package/docs/how-to/error-boundary.md +231 -0
  260. package/docs/how-to/error-reporting.md +134 -0
  261. package/docs/how-to/fetchers.md +307 -0
  262. package/docs/how-to/file-route-conventions.md +410 -0
  263. package/docs/how-to/file-uploads.md +217 -0
  264. package/docs/how-to/form-validation.md +120 -0
  265. package/docs/how-to/headers.md +164 -0
  266. package/docs/how-to/index.md +4 -0
  267. package/docs/how-to/instrumentation.md +556 -0
  268. package/docs/how-to/meta.md +40 -0
  269. package/docs/how-to/middleware.md +728 -0
  270. package/docs/how-to/navigation-blocking.md +233 -0
  271. package/docs/how-to/optimize-revalidation.md +12 -0
  272. package/docs/how-to/pre-rendering.md +225 -0
  273. package/docs/how-to/presets.md +103 -0
  274. package/docs/how-to/react-server-components.md +899 -0
  275. package/docs/how-to/resource-routes.md +126 -0
  276. package/docs/how-to/route-module-type-safety.md +100 -0
  277. package/docs/how-to/search-params.md +4 -0
  278. package/docs/how-to/security.md +30 -0
  279. package/docs/how-to/server-bundles.md +66 -0
  280. package/docs/how-to/spa.md +120 -0
  281. package/docs/how-to/status.md +63 -0
  282. package/docs/how-to/suspense.md +132 -0
  283. package/docs/how-to/using-handle.md +117 -0
  284. package/docs/how-to/view-transitions.md +237 -0
  285. package/docs/how-to/webhook.md +50 -0
  286. package/docs/index.md +39 -0
  287. package/docs/start/data/actions.md +138 -0
  288. package/docs/start/data/custom.md +198 -0
  289. package/docs/start/data/data-loading.md +44 -0
  290. package/docs/start/data/index.md +4 -0
  291. package/docs/start/data/installation.md +52 -0
  292. package/docs/start/data/navigating.md +12 -0
  293. package/docs/start/data/pending-ui.md +12 -0
  294. package/docs/start/data/route-object.md +248 -0
  295. package/docs/start/data/routing.md +281 -0
  296. package/docs/start/data/testing.md +8 -0
  297. package/docs/start/declarative/index.md +4 -0
  298. package/docs/start/declarative/installation.md +43 -0
  299. package/docs/start/declarative/navigating.md +133 -0
  300. package/docs/start/declarative/routing.md +237 -0
  301. package/docs/start/declarative/url-values.md +65 -0
  302. package/docs/start/framework/actions.md +175 -0
  303. package/docs/start/framework/data-loading.md +201 -0
  304. package/docs/start/framework/deploying.md +96 -0
  305. package/docs/start/framework/index.md +4 -0
  306. package/docs/start/framework/installation.md +42 -0
  307. package/docs/start/framework/navigating.md +182 -0
  308. package/docs/start/framework/pending-ui.md +142 -0
  309. package/docs/start/framework/rendering.md +59 -0
  310. package/docs/start/framework/route-module.md +527 -0
  311. package/docs/start/framework/routing.md +362 -0
  312. package/docs/start/framework/testing.md +133 -0
  313. package/docs/start/index.md +4 -0
  314. package/docs/start/modes.md +201 -0
  315. package/docs/upgrading/component-routes.md +363 -0
  316. package/docs/upgrading/future.md +31 -0
  317. package/docs/upgrading/index.md +4 -0
  318. package/docs/upgrading/remix.md +403 -0
  319. package/docs/upgrading/router-provider.md +442 -0
  320. package/docs/upgrading/v6.md +379 -0
  321. package/package.json +44 -87
  322. package/dist/development/browser-3AnU12UI.d.mts +0 -318
  323. package/dist/development/browser-BOdXz9dK.d.ts +0 -318
  324. package/dist/development/chunk-4N6VE7H7.mjs +0 -11528
  325. package/dist/development/chunk-4YRVXM2U.js +0 -188
  326. package/dist/development/chunk-66UKHEGQ.js +0 -1362
  327. package/dist/development/chunk-D6LUOGOQ.js +0 -10229
  328. package/dist/development/chunk-RJYABSBD.mjs +0 -2585
  329. package/dist/development/context-ByvtofY2.d.mts +0 -1771
  330. package/dist/development/data-BVUf681J.d.mts +0 -1732
  331. package/dist/development/data-BqZ2x964.d.ts +0 -1732
  332. package/dist/development/dom-export.d.mts +0 -172
  333. package/dist/development/dom-export.mjs +0 -1008
  334. package/dist/development/index-react-server-client-BS5F89FR.d.ts +0 -3655
  335. package/dist/development/index-react-server-client-DY04-103.d.mts +0 -2600
  336. package/dist/development/index-react-server-client.d.mts +0 -4
  337. package/dist/development/index-react-server-client.mjs +0 -59
  338. package/dist/development/index-react-server.d.mts +0 -2703
  339. package/dist/development/index-react-server.mjs +0 -3780
  340. package/dist/development/index.d.mts +0 -1472
  341. package/dist/development/index.mjs +0 -277
  342. package/dist/development/instrumentation-cRWWLfsU.d.ts +0 -715
  343. package/dist/development/lib/types/internal.d.mts +0 -184
  344. package/dist/development/lib/types/internal.mjs +0 -10
  345. package/dist/development/register-Df8okEea.d.mts +0 -30
  346. package/dist/production/browser-3AnU12UI.d.mts +0 -318
  347. package/dist/production/browser-BOdXz9dK.d.ts +0 -318
  348. package/dist/production/chunk-6S4627ZB.mjs +0 -2585
  349. package/dist/production/chunk-HUBUW7R3.js +0 -10229
  350. package/dist/production/chunk-JAKZPQZC.mjs +0 -11528
  351. package/dist/production/chunk-PNZCCTKT.js +0 -1362
  352. package/dist/production/chunk-Y6IFXO7V.js +0 -188
  353. package/dist/production/context-ByvtofY2.d.mts +0 -1771
  354. package/dist/production/data-BVUf681J.d.mts +0 -1732
  355. package/dist/production/data-BqZ2x964.d.ts +0 -1732
  356. package/dist/production/dom-export.d.mts +0 -172
  357. package/dist/production/dom-export.mjs +0 -1008
  358. package/dist/production/index-react-server-client-BS5F89FR.d.ts +0 -3655
  359. package/dist/production/index-react-server-client-DY04-103.d.mts +0 -2600
  360. package/dist/production/index-react-server-client.d.mts +0 -4
  361. package/dist/production/index-react-server-client.mjs +0 -59
  362. package/dist/production/index-react-server.d.mts +0 -2703
  363. package/dist/production/index-react-server.mjs +0 -3780
  364. package/dist/production/index.d.mts +0 -1472
  365. package/dist/production/index.mjs +0 -277
  366. package/dist/production/instrumentation-cRWWLfsU.d.ts +0 -715
  367. package/dist/production/lib/types/internal.d.mts +0 -184
  368. package/dist/production/lib/types/internal.mjs +0 -10
  369. package/dist/production/register-Df8okEea.d.mts +0 -30
@@ -0,0 +1,835 @@
1
+ /**
2
+ * react-router v8.0.0-pre.0
3
+ *
4
+ * Copyright (c) Remix Software Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ import { createMemoryHistory, invariant, parsePath, warning } from "./router/history.js";
12
+ import { defaultMapRouteProperties, getResolveToMatches, getRoutePattern, resolveTo, stripBasename } from "./router/utils.js";
13
+ import { createRouter } from "./router/router.js";
14
+ import { AwaitContext, DataRouterContext, DataRouterStateContext, FetchersContext, LocationContext, NavigationContext, RouteContext, ViewTransitionContext, useIsRSCRouterContext } from "./context.js";
15
+ import { _renderMatches, useActionData, useAsyncValue, useInRouterContext, useLoaderData, useLocation, useMatches, useNavigate, useOutlet, useParams, useRouteError, useRoutes, useRoutesImpl } from "./hooks.js";
16
+ import { warnOnce } from "./server-runtime/warnings.js";
17
+ import * as React$1 from "react";
18
+ import { useOptimistic } from "react";
19
+ //#region lib/components.tsx
20
+ const hydrationRouteProperties = ["HydrateFallback", "hydrateFallbackElement"];
21
+ /**
22
+ * Create a new {@link DataRouter} that manages the application path using an
23
+ * in-memory [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
24
+ * stack. Useful for non-browser environments without a DOM API.
25
+ *
26
+ * @public
27
+ * @category Data Routers
28
+ * @mode data
29
+ * @param routes Application routes
30
+ * @param opts Options
31
+ * @param {MemoryRouterOpts.basename} opts.basename n/a
32
+ * @param {MemoryRouterOpts.dataStrategy} opts.dataStrategy n/a
33
+ * @param {MemoryRouterOpts.future} opts.future n/a
34
+ * @param {MemoryRouterOpts.getContext} opts.getContext n/a
35
+ * @param {MemoryRouterOpts.hydrationData} opts.hydrationData n/a
36
+ * @param {MemoryRouterOpts.initialEntries} opts.initialEntries n/a
37
+ * @param {MemoryRouterOpts.initialIndex} opts.initialIndex n/a
38
+ * @param {MemoryRouterOpts.instrumentations} opts.instrumentations n/a
39
+ * @param {MemoryRouterOpts.patchRoutesOnNavigation} opts.patchRoutesOnNavigation n/a
40
+ * @returns An initialized {@link DataRouter} to pass to {@link RouterProvider | `<RouterProvider>`}
41
+ */
42
+ function createMemoryRouter(routes, opts) {
43
+ return createRouter({
44
+ basename: opts?.basename,
45
+ getContext: opts?.getContext,
46
+ future: opts?.future,
47
+ history: createMemoryHistory({
48
+ initialEntries: opts?.initialEntries,
49
+ initialIndex: opts?.initialIndex
50
+ }),
51
+ hydrationData: opts?.hydrationData,
52
+ routes,
53
+ mapRouteProperties: defaultMapRouteProperties,
54
+ hydrationRouteProperties,
55
+ dataStrategy: opts?.dataStrategy,
56
+ patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
57
+ instrumentations: opts?.instrumentations
58
+ }).initialize();
59
+ }
60
+ var Deferred = class {
61
+ status = "pending";
62
+ promise;
63
+ resolve;
64
+ reject;
65
+ constructor() {
66
+ this.promise = new Promise((resolve, reject) => {
67
+ this.resolve = (value) => {
68
+ if (this.status === "pending") {
69
+ this.status = "resolved";
70
+ resolve(value);
71
+ }
72
+ };
73
+ this.reject = (reason) => {
74
+ if (this.status === "pending") {
75
+ this.status = "rejected";
76
+ reject(reason);
77
+ }
78
+ };
79
+ });
80
+ }
81
+ };
82
+ /**
83
+ * Render the UI for the given {@link DataRouter}. This component should
84
+ * typically be at the top of an app's element tree.
85
+ *
86
+ * ```tsx
87
+ * import { createBrowserRouter } from "react-router";
88
+ * import { RouterProvider } from "react-router/dom";
89
+ * import { createRoot } from "react-dom/client";
90
+ *
91
+ * const router = createBrowserRouter(routes);
92
+ * createRoot(document.getElementById("root")).render(
93
+ * <RouterProvider router={router} />
94
+ * );
95
+ * ```
96
+ *
97
+ * <docs-info>Please note that this component is exported both from
98
+ * `react-router` and `react-router/dom` with the only difference being that the
99
+ * latter automatically wires up `react-dom`'s [`flushSync`](https://react.dev/reference/react-dom/flushSync)
100
+ * implementation. You _almost always_ want to use the version from
101
+ * `react-router/dom` unless you're running in a non-DOM environment.</docs-info>
102
+ *
103
+ *
104
+ * @public
105
+ * @category Data Routers
106
+ * @mode data
107
+ * @param props Props
108
+ * @param {RouterProviderProps.flushSync} props.flushSync n/a
109
+ * @param {RouterProviderProps.onError} props.onError n/a
110
+ * @param {RouterProviderProps.router} props.router n/a
111
+ * @param {RouterProviderProps.useTransitions} props.useTransitions n/a
112
+ * @returns React element for the rendered router
113
+ */
114
+ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, useTransitions }) {
115
+ useTransitions = useIsRSCRouterContext() || useTransitions;
116
+ let [_state, setStateImpl] = React$1.useState(router.state);
117
+ let [state, setOptimisticState] = useOptimistic(_state);
118
+ let [pendingState, setPendingState] = React$1.useState();
119
+ let [vtContext, setVtContext] = React$1.useState({ isTransitioning: false });
120
+ let [renderDfd, setRenderDfd] = React$1.useState();
121
+ let [transition, setTransition] = React$1.useState();
122
+ let [interruption, setInterruption] = React$1.useState();
123
+ let fetcherData = React$1.useRef(/* @__PURE__ */ new Map());
124
+ let setState = React$1.useCallback((newState, { deletedFetchers, newErrors, flushSync, viewTransitionOpts }) => {
125
+ if (newErrors && onError) Object.values(newErrors).forEach((error) => onError(error, {
126
+ location: newState.location,
127
+ params: newState.matches[0]?.params ?? {},
128
+ pattern: getRoutePattern(newState.matches)
129
+ }));
130
+ newState.fetchers.forEach((fetcher, key) => {
131
+ if (fetcher.data !== void 0) fetcherData.current.set(key, fetcher.data);
132
+ });
133
+ deletedFetchers.forEach((key) => fetcherData.current.delete(key));
134
+ warnOnce(flushSync === false || reactDomFlushSyncImpl != null, "You provided the `flushSync` option to a router update, but you are not using the `<RouterProvider>` from `react-router/dom` so `ReactDOM.flushSync()` is unavailable. Please update your app to `import { RouterProvider } from \"react-router/dom\"` and ensure you have `react-dom` installed as a dependency to use the `flushSync` option.");
135
+ let isViewTransitionAvailable = router.window != null && router.window.document != null && typeof router.window.document.startViewTransition === "function";
136
+ warnOnce(viewTransitionOpts == null || isViewTransitionAvailable, "You provided the `viewTransition` option to a router update, but you do not appear to be running in a DOM environment as `window.startViewTransition` is not available.");
137
+ if (!viewTransitionOpts || !isViewTransitionAvailable) {
138
+ if (reactDomFlushSyncImpl && flushSync) reactDomFlushSyncImpl(() => setStateImpl(newState));
139
+ else if (useTransitions === false) setStateImpl(newState);
140
+ else React$1.startTransition(() => {
141
+ if (useTransitions === true) setOptimisticState((s) => getOptimisticRouterState(s, newState));
142
+ setStateImpl(newState);
143
+ });
144
+ return;
145
+ }
146
+ if (reactDomFlushSyncImpl && flushSync) {
147
+ reactDomFlushSyncImpl(() => {
148
+ if (transition) {
149
+ renderDfd?.resolve();
150
+ transition.skipTransition();
151
+ }
152
+ setVtContext({
153
+ isTransitioning: true,
154
+ flushSync: true,
155
+ currentLocation: viewTransitionOpts.currentLocation,
156
+ nextLocation: viewTransitionOpts.nextLocation
157
+ });
158
+ });
159
+ let t = router.window.document.startViewTransition(() => {
160
+ reactDomFlushSyncImpl(() => setStateImpl(newState));
161
+ });
162
+ t.finished.finally(() => {
163
+ reactDomFlushSyncImpl(() => {
164
+ setRenderDfd(void 0);
165
+ setTransition(void 0);
166
+ setPendingState(void 0);
167
+ setVtContext({ isTransitioning: false });
168
+ });
169
+ });
170
+ reactDomFlushSyncImpl(() => setTransition(t));
171
+ return;
172
+ }
173
+ if (transition) {
174
+ renderDfd?.resolve();
175
+ transition.skipTransition();
176
+ setInterruption({
177
+ state: newState,
178
+ currentLocation: viewTransitionOpts.currentLocation,
179
+ nextLocation: viewTransitionOpts.nextLocation
180
+ });
181
+ } else {
182
+ setPendingState(newState);
183
+ setVtContext({
184
+ isTransitioning: true,
185
+ flushSync: false,
186
+ currentLocation: viewTransitionOpts.currentLocation,
187
+ nextLocation: viewTransitionOpts.nextLocation
188
+ });
189
+ }
190
+ }, [
191
+ router.window,
192
+ reactDomFlushSyncImpl,
193
+ transition,
194
+ renderDfd,
195
+ useTransitions,
196
+ setOptimisticState,
197
+ onError
198
+ ]);
199
+ React$1.useLayoutEffect(() => router.subscribe(setState), [router, setState]);
200
+ React$1.useEffect(() => {
201
+ if (vtContext.isTransitioning && !vtContext.flushSync) setRenderDfd(new Deferred());
202
+ }, [vtContext]);
203
+ React$1.useEffect(() => {
204
+ if (renderDfd && pendingState && router.window) {
205
+ let newState = pendingState;
206
+ let renderPromise = renderDfd.promise;
207
+ let transition = router.window.document.startViewTransition(async () => {
208
+ if (useTransitions === false) setStateImpl(newState);
209
+ else React$1.startTransition(() => {
210
+ if (useTransitions === true) setOptimisticState((s) => getOptimisticRouterState(s, newState));
211
+ setStateImpl(newState);
212
+ });
213
+ await renderPromise;
214
+ });
215
+ transition.finished.finally(() => {
216
+ setRenderDfd(void 0);
217
+ setTransition(void 0);
218
+ setPendingState(void 0);
219
+ setVtContext({ isTransitioning: false });
220
+ });
221
+ setTransition(transition);
222
+ }
223
+ }, [
224
+ pendingState,
225
+ renderDfd,
226
+ router.window,
227
+ useTransitions,
228
+ setOptimisticState
229
+ ]);
230
+ React$1.useEffect(() => {
231
+ if (renderDfd && pendingState && state.location.key === pendingState.location.key) renderDfd.resolve();
232
+ }, [
233
+ renderDfd,
234
+ transition,
235
+ state.location,
236
+ pendingState
237
+ ]);
238
+ React$1.useEffect(() => {
239
+ if (!vtContext.isTransitioning && interruption) {
240
+ setPendingState(interruption.state);
241
+ setVtContext({
242
+ isTransitioning: true,
243
+ flushSync: false,
244
+ currentLocation: interruption.currentLocation,
245
+ nextLocation: interruption.nextLocation
246
+ });
247
+ setInterruption(void 0);
248
+ }
249
+ }, [vtContext.isTransitioning, interruption]);
250
+ let navigator = React$1.useMemo(() => {
251
+ return {
252
+ createHref: router.createHref,
253
+ encodeLocation: router.encodeLocation,
254
+ go: (n) => router.navigate(n),
255
+ push: (to, state, opts) => router.navigate(to, {
256
+ state,
257
+ preventScrollReset: opts?.preventScrollReset
258
+ }),
259
+ replace: (to, state, opts) => router.navigate(to, {
260
+ replace: true,
261
+ state,
262
+ preventScrollReset: opts?.preventScrollReset
263
+ })
264
+ };
265
+ }, [router]);
266
+ let basename = router.basename || "/";
267
+ let dataRouterContext = React$1.useMemo(() => ({
268
+ router,
269
+ navigator,
270
+ static: false,
271
+ basename,
272
+ onError
273
+ }), [
274
+ router,
275
+ navigator,
276
+ basename,
277
+ onError
278
+ ]);
279
+ return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, /* @__PURE__ */ React$1.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React$1.createElement(DataRouterStateContext.Provider, { value: state }, /* @__PURE__ */ React$1.createElement(FetchersContext.Provider, { value: fetcherData.current }, /* @__PURE__ */ React$1.createElement(ViewTransitionContext.Provider, { value: vtContext }, /* @__PURE__ */ React$1.createElement(Router, {
280
+ basename,
281
+ location: state.location,
282
+ navigationType: state.historyAction,
283
+ navigator,
284
+ useTransitions
285
+ }, /* @__PURE__ */ React$1.createElement(MemoizedDataRoutes, {
286
+ routes: router.routes,
287
+ manifest: router.manifest,
288
+ future: router.future,
289
+ state,
290
+ isStatic: false,
291
+ onError
292
+ })))))), null);
293
+ }
294
+ function getOptimisticRouterState(currentState, newState) {
295
+ return {
296
+ ...currentState,
297
+ navigation: newState.navigation.state !== "idle" ? newState.navigation : currentState.navigation,
298
+ revalidation: newState.revalidation !== "idle" ? newState.revalidation : currentState.revalidation,
299
+ actionData: newState.navigation.state !== "submitting" ? newState.actionData : currentState.actionData,
300
+ fetchers: newState.fetchers
301
+ };
302
+ }
303
+ const MemoizedDataRoutes = React$1.memo(DataRoutes);
304
+ function DataRoutes({ routes, manifest, future, state, isStatic, onError }) {
305
+ return useRoutesImpl(routes, void 0, {
306
+ manifest,
307
+ state,
308
+ isStatic,
309
+ onError,
310
+ future
311
+ });
312
+ }
313
+ /**
314
+ * A declarative {@link Router | `<Router>`} that stores all entries in memory.
315
+ *
316
+ * @public
317
+ * @category Declarative Routers
318
+ * @mode declarative
319
+ * @param props Props
320
+ * @param {MemoryRouterProps.basename} props.basename n/a
321
+ * @param {MemoryRouterProps.children} props.children n/a
322
+ * @param {MemoryRouterProps.initialEntries} props.initialEntries n/a
323
+ * @param {MemoryRouterProps.initialIndex} props.initialIndex n/a
324
+ * @param {MemoryRouterProps.useTransitions} props.useTransitions n/a
325
+ * @returns A declarative in-memory {@link Router | `<Router>`} for client-side
326
+ * routing.
327
+ */
328
+ function MemoryRouter({ basename, children, initialEntries, initialIndex, useTransitions }) {
329
+ let historyRef = React$1.useRef(null);
330
+ if (historyRef.current == null) historyRef.current = createMemoryHistory({
331
+ initialEntries,
332
+ initialIndex,
333
+ v5Compat: true
334
+ });
335
+ let history = historyRef.current;
336
+ let [state, setStateImpl] = React$1.useState({
337
+ action: history.action,
338
+ location: history.location
339
+ });
340
+ let setState = React$1.useCallback((newState) => {
341
+ if (useTransitions === false) setStateImpl(newState);
342
+ else React$1.startTransition(() => setStateImpl(newState));
343
+ }, [useTransitions]);
344
+ React$1.useLayoutEffect(() => history.listen(setState), [history, setState]);
345
+ return /* @__PURE__ */ React$1.createElement(Router, {
346
+ basename,
347
+ children,
348
+ location: state.location,
349
+ navigationType: state.action,
350
+ navigator: history,
351
+ useTransitions
352
+ });
353
+ }
354
+ /**
355
+ * A component-based version of {@link useNavigate} to use in a
356
+ * [`React.Component` class](https://react.dev/reference/react/Component) where
357
+ * hooks cannot be used.
358
+ *
359
+ * It's recommended to avoid using this component in favor of {@link useNavigate}.
360
+ *
361
+ * @example
362
+ * <Navigate to="/tasks" />
363
+ *
364
+ * @public
365
+ * @category Components
366
+ * @param props Props
367
+ * @param {NavigateProps.relative} props.relative n/a
368
+ * @param {NavigateProps.replace} props.replace n/a
369
+ * @param {NavigateProps.state} props.state n/a
370
+ * @param {NavigateProps.to} props.to n/a
371
+ * @returns {void}
372
+ *
373
+ */
374
+ function Navigate({ to, replace, state, relative }) {
375
+ invariant(useInRouterContext(), `<Navigate> may be used only in the context of a <Router> component.`);
376
+ let { static: isStatic } = React$1.useContext(NavigationContext);
377
+ warning(!isStatic, "<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");
378
+ let { matches } = React$1.useContext(RouteContext);
379
+ let { pathname: locationPathname } = useLocation();
380
+ let navigate = useNavigate();
381
+ let path = resolveTo(to, getResolveToMatches(matches), locationPathname, relative === "path");
382
+ let jsonPath = JSON.stringify(path);
383
+ React$1.useEffect(() => {
384
+ navigate(JSON.parse(jsonPath), {
385
+ replace,
386
+ state,
387
+ relative
388
+ });
389
+ }, [
390
+ navigate,
391
+ jsonPath,
392
+ relative,
393
+ replace,
394
+ state
395
+ ]);
396
+ return null;
397
+ }
398
+ /**
399
+ * Renders the matching child route of a parent route or nothing if no child
400
+ * route matches.
401
+ *
402
+ * @example
403
+ * import { Outlet } from "react-router";
404
+ *
405
+ * export default function SomeParent() {
406
+ * return (
407
+ * <div>
408
+ * <h1>Parent Content</h1>
409
+ * <Outlet />
410
+ * </div>
411
+ * );
412
+ * }
413
+ *
414
+ * @public
415
+ * @category Components
416
+ * @param props Props
417
+ * @param {OutletProps.context} props.context n/a
418
+ * @returns React element for the rendered outlet or `null` if no child route matches.
419
+ */
420
+ function Outlet(props) {
421
+ return useOutlet(props.context);
422
+ }
423
+ /**
424
+ * Configures an element to render when a pattern matches the current location.
425
+ * It must be rendered within a {@link Routes} element. Note that these routes
426
+ * do not participate in data loading, actions, code splitting, or any other
427
+ * route module features.
428
+ *
429
+ * @example
430
+ * // Usually used in a declarative router
431
+ * function App() {
432
+ * return (
433
+ * <BrowserRouter>
434
+ * <Routes>
435
+ * <Route index element={<StepOne />} />
436
+ * <Route path="step-2" element={<StepTwo />} />
437
+ * <Route path="step-3" element={<StepThree />} />
438
+ * </Routes>
439
+ * </BrowserRouter>
440
+ * );
441
+ * }
442
+ *
443
+ * // But can be used with a data router as well if you prefer the JSX notation
444
+ * const routes = createRoutesFromElements(
445
+ * <>
446
+ * <Route index loader={step1Loader} Component={StepOne} />
447
+ * <Route path="step-2" loader={step2Loader} Component={StepTwo} />
448
+ * <Route path="step-3" loader={step3Loader} Component={StepThree} />
449
+ * </>
450
+ * );
451
+ *
452
+ * const router = createBrowserRouter(routes);
453
+ *
454
+ * function App() {
455
+ * return <RouterProvider router={router} />;
456
+ * }
457
+ *
458
+ * @public
459
+ * @category Components
460
+ * @param props Props
461
+ * @param {PathRouteProps.action} props.action n/a
462
+ * @param {PathRouteProps.caseSensitive} props.caseSensitive n/a
463
+ * @param {PathRouteProps.Component} props.Component n/a
464
+ * @param {PathRouteProps.children} props.children n/a
465
+ * @param {PathRouteProps.element} props.element n/a
466
+ * @param {PathRouteProps.ErrorBoundary} props.ErrorBoundary n/a
467
+ * @param {PathRouteProps.errorElement} props.errorElement n/a
468
+ * @param {PathRouteProps.handle} props.handle n/a
469
+ * @param {PathRouteProps.HydrateFallback} props.HydrateFallback n/a
470
+ * @param {PathRouteProps.hydrateFallbackElement} props.hydrateFallbackElement n/a
471
+ * @param {PathRouteProps.id} props.id n/a
472
+ * @param {PathRouteProps.index} props.index n/a
473
+ * @param {PathRouteProps.lazy} props.lazy n/a
474
+ * @param {PathRouteProps.loader} props.loader n/a
475
+ * @param {PathRouteProps.path} props.path n/a
476
+ * @param {PathRouteProps.shouldRevalidate} props.shouldRevalidate n/a
477
+ * @returns {void}
478
+ */
479
+ function Route(props) {
480
+ invariant(false, "A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.");
481
+ }
482
+ /**
483
+ * Provides location context for the rest of the app.
484
+ *
485
+ * Note: You usually won't render a `<Router>` directly. Instead, you'll render a
486
+ * router that is more specific to your environment such as a {@link BrowserRouter}
487
+ * in web browsers or a {@link ServerRouter} for server rendering.
488
+ *
489
+ * @public
490
+ * @category Declarative Routers
491
+ * @mode declarative
492
+ * @param props Props
493
+ * @param {RouterProps.basename} props.basename n/a
494
+ * @param {RouterProps.children} props.children n/a
495
+ * @param {RouterProps.location} props.location n/a
496
+ * @param {RouterProps.navigationType} props.navigationType n/a
497
+ * @param {RouterProps.navigator} props.navigator n/a
498
+ * @param {RouterProps.static} props.static n/a
499
+ * @param {RouterProps.useTransitions} props.useTransitions n/a
500
+ * @returns React element for the rendered router or `null` if the location does
501
+ * not match the {@link props.basename}
502
+ */
503
+ function Router({ basename: basenameProp = "/", children = null, location: locationProp, navigationType = "POP", navigator, static: staticProp = false, useTransitions }) {
504
+ invariant(!useInRouterContext(), "You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");
505
+ let basename = basenameProp.replace(/^\/*/, "/");
506
+ let navigationContext = React$1.useMemo(() => ({
507
+ basename,
508
+ navigator,
509
+ static: staticProp,
510
+ useTransitions,
511
+ future: {}
512
+ }), [
513
+ basename,
514
+ navigator,
515
+ staticProp,
516
+ useTransitions
517
+ ]);
518
+ if (typeof locationProp === "string") locationProp = parsePath(locationProp);
519
+ let { pathname = "/", search = "", hash = "", state = null, key = "default", mask } = locationProp;
520
+ let locationContext = React$1.useMemo(() => {
521
+ let trailingPathname = stripBasename(pathname, basename);
522
+ if (trailingPathname == null) return null;
523
+ return {
524
+ location: {
525
+ pathname: trailingPathname,
526
+ search,
527
+ hash,
528
+ state,
529
+ key,
530
+ mask
531
+ },
532
+ navigationType
533
+ };
534
+ }, [
535
+ basename,
536
+ pathname,
537
+ search,
538
+ hash,
539
+ state,
540
+ key,
541
+ navigationType,
542
+ mask
543
+ ]);
544
+ warning(locationContext != null, `<Router basename="${basename}"> is not able to match the URL "${pathname}${search}${hash}" because it does not start with the basename, so the <Router> won't render anything.`);
545
+ if (locationContext == null) return null;
546
+ return /* @__PURE__ */ React$1.createElement(NavigationContext.Provider, { value: navigationContext }, /* @__PURE__ */ React$1.createElement(LocationContext.Provider, {
547
+ children,
548
+ value: locationContext
549
+ }));
550
+ }
551
+ /**
552
+ * Renders a branch of {@link Route | `<Route>`s} that best matches the current
553
+ * location. Note that these routes do not participate in [data loading](../../start/framework/route-module#loader),
554
+ * [`action`](../../start/framework/route-module#action), code splitting, or
555
+ * any other [route module](../../start/framework/route-module) features.
556
+ *
557
+ * @example
558
+ * import { Route, Routes } from "react-router";
559
+ *
560
+ * <Routes>
561
+ * <Route index element={<StepOne />} />
562
+ * <Route path="step-2" element={<StepTwo />} />
563
+ * <Route path="step-3" element={<StepThree />} />
564
+ * </Routes>
565
+ *
566
+ * @public
567
+ * @category Components
568
+ * @param props Props
569
+ * @param {RoutesProps.children} props.children n/a
570
+ * @param {RoutesProps.location} props.location n/a
571
+ * @returns React element for the rendered routes or `null` if no route matches
572
+ */
573
+ function Routes({ children, location }) {
574
+ return useRoutes(createRoutesFromChildren(children), location);
575
+ }
576
+ /**
577
+ * Used to render promise values with automatic error handling.
578
+ *
579
+ * **Note:** `<Await>` expects to be rendered inside a [`<React.Suspense>`](https://react.dev/reference/react/Suspense)
580
+ *
581
+ * @example
582
+ * import { Await, useLoaderData } from "react-router";
583
+ *
584
+ * export async function loader() {
585
+ * // not awaited
586
+ * const reviews = getReviews();
587
+ * // awaited (blocks the transition)
588
+ * const book = await fetch("/api/book").then((res) => res.json());
589
+ * return { book, reviews };
590
+ * }
591
+ *
592
+ * function Book() {
593
+ * const { book, reviews } = useLoaderData();
594
+ * return (
595
+ * <div>
596
+ * <h1>{book.title}</h1>
597
+ * <p>{book.description}</p>
598
+ * <React.Suspense fallback={<ReviewsSkeleton />}>
599
+ * <Await
600
+ * resolve={reviews}
601
+ * errorElement={
602
+ * <div>Could not load reviews 😬</div>
603
+ * }
604
+ * children={(resolvedReviews) => (
605
+ * <Reviews items={resolvedReviews} />
606
+ * )}
607
+ * />
608
+ * </React.Suspense>
609
+ * </div>
610
+ * );
611
+ * }
612
+ *
613
+ * @public
614
+ * @category Components
615
+ * @mode framework
616
+ * @mode data
617
+ * @param props Props
618
+ * @param {AwaitProps.children} props.children n/a
619
+ * @param {AwaitProps.errorElement} props.errorElement n/a
620
+ * @param {AwaitProps.resolve} props.resolve n/a
621
+ * @returns React element for the rendered awaited value
622
+ */
623
+ function Await({ children, errorElement, resolve }) {
624
+ let dataRouterContext = React$1.useContext(DataRouterContext);
625
+ let dataRouterStateContext = React$1.useContext(DataRouterStateContext);
626
+ let onError = React$1.useCallback((error, errorInfo) => {
627
+ if (dataRouterContext && dataRouterContext.onError && dataRouterStateContext) dataRouterContext.onError(error, {
628
+ location: dataRouterStateContext.location,
629
+ params: dataRouterStateContext.matches[0]?.params || {},
630
+ pattern: getRoutePattern(dataRouterStateContext.matches),
631
+ errorInfo
632
+ });
633
+ }, [dataRouterContext, dataRouterStateContext]);
634
+ return /* @__PURE__ */ React$1.createElement(AwaitErrorBoundary, {
635
+ resolve,
636
+ errorElement,
637
+ onError
638
+ }, /* @__PURE__ */ React$1.createElement(ResolveAwait, null, children));
639
+ }
640
+ var AwaitErrorBoundary = class extends React$1.Component {
641
+ constructor(props) {
642
+ super(props);
643
+ this.state = { error: null };
644
+ }
645
+ static getDerivedStateFromError(error) {
646
+ return { error };
647
+ }
648
+ componentDidCatch(error, errorInfo) {
649
+ if (this.props.onError) this.props.onError(error, errorInfo);
650
+ else console.error("<Await> caught the following error during render", error, errorInfo);
651
+ }
652
+ render() {
653
+ let { children, errorElement, resolve } = this.props;
654
+ let promise = null;
655
+ let status = 0;
656
+ if (!(resolve instanceof Promise)) {
657
+ status = 1;
658
+ promise = Promise.resolve();
659
+ Object.defineProperty(promise, "_tracked", { get: () => true });
660
+ Object.defineProperty(promise, "_data", { get: () => resolve });
661
+ } else if (this.state.error) {
662
+ status = 2;
663
+ let renderError = this.state.error;
664
+ promise = Promise.reject().catch(() => {});
665
+ Object.defineProperty(promise, "_tracked", { get: () => true });
666
+ Object.defineProperty(promise, "_error", { get: () => renderError });
667
+ } else if (resolve._tracked) {
668
+ promise = resolve;
669
+ status = "_error" in promise ? 2 : "_data" in promise ? 1 : 0;
670
+ } else {
671
+ status = 0;
672
+ Object.defineProperty(resolve, "_tracked", { get: () => true });
673
+ promise = resolve.then((data) => Object.defineProperty(resolve, "_data", { get: () => data }), (error) => {
674
+ this.props.onError?.(error);
675
+ Object.defineProperty(resolve, "_error", { get: () => error });
676
+ });
677
+ }
678
+ if (status === 2 && !errorElement) throw promise._error;
679
+ if (status === 2) return /* @__PURE__ */ React$1.createElement(AwaitContext.Provider, {
680
+ value: promise,
681
+ children: errorElement
682
+ });
683
+ if (status === 1) return /* @__PURE__ */ React$1.createElement(AwaitContext.Provider, {
684
+ value: promise,
685
+ children
686
+ });
687
+ throw promise;
688
+ }
689
+ };
690
+ function ResolveAwait({ children }) {
691
+ let data = useAsyncValue();
692
+ let toRender = typeof children === "function" ? children(data) : children;
693
+ return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, toRender);
694
+ }
695
+ /**
696
+ * Creates a route config from a React "children" object, which is usually
697
+ * either a `<Route>` element or an array of them. Used internally by
698
+ * `<Routes>` to create a route config from its children.
699
+ *
700
+ * @category Utils
701
+ * @mode data
702
+ * @param children The React children to convert into a route config
703
+ * @param parentPath The path of the parent route, used to generate unique IDs.
704
+ * @returns An array of {@link RouteObject}s that can be used with a {@link DataRouter}
705
+ */
706
+ function createRoutesFromChildren(children, parentPath = []) {
707
+ let routes = [];
708
+ React$1.Children.forEach(children, (element, index) => {
709
+ if (!React$1.isValidElement(element)) return;
710
+ let treePath = [...parentPath, index];
711
+ if (element.type === React$1.Fragment) {
712
+ routes.push.apply(routes, createRoutesFromChildren(element.props.children, treePath));
713
+ return;
714
+ }
715
+ invariant(element.type === Route, `[${typeof element.type === "string" ? element.type : element.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`);
716
+ let props = element.props;
717
+ invariant(!props.index || !props.children, "An index route cannot have child routes.");
718
+ let route = {
719
+ id: props.id || treePath.join("-"),
720
+ caseSensitive: props.caseSensitive,
721
+ element: props.element,
722
+ Component: props.Component,
723
+ index: props.index,
724
+ path: props.path,
725
+ middleware: props.middleware,
726
+ loader: props.loader,
727
+ action: props.action,
728
+ hydrateFallbackElement: props.hydrateFallbackElement,
729
+ HydrateFallback: props.HydrateFallback,
730
+ errorElement: props.errorElement,
731
+ ErrorBoundary: props.ErrorBoundary,
732
+ shouldRevalidate: props.shouldRevalidate,
733
+ handle: props.handle,
734
+ lazy: props.lazy
735
+ };
736
+ if (props.children) route.children = createRoutesFromChildren(props.children, treePath);
737
+ routes.push(route);
738
+ });
739
+ return routes;
740
+ }
741
+ /**
742
+ * Create route objects from JSX elements instead of arrays of objects.
743
+ *
744
+ * @example
745
+ * const routes = createRoutesFromElements(
746
+ * <>
747
+ * <Route index loader={step1Loader} Component={StepOne} />
748
+ * <Route path="step-2" loader={step2Loader} Component={StepTwo} />
749
+ * <Route path="step-3" loader={step3Loader} Component={StepThree} />
750
+ * </>
751
+ * );
752
+ *
753
+ * const router = createBrowserRouter(routes);
754
+ *
755
+ * function App() {
756
+ * return <RouterProvider router={router} />;
757
+ * }
758
+ *
759
+ * @name createRoutesFromElements
760
+ * @public
761
+ * @category Utils
762
+ * @mode data
763
+ * @param children The React children to convert into a route config
764
+ * @param parentPath The path of the parent route, used to generate unique IDs.
765
+ * This is used for internal recursion and is not intended to be used by the
766
+ * application developer.
767
+ * @returns An array of {@link RouteObject}s that can be used with a {@link DataRouter}
768
+ */
769
+ const createRoutesFromElements = createRoutesFromChildren;
770
+ /**
771
+ * Renders the result of {@link matchRoutes} into a React element.
772
+ *
773
+ * @public
774
+ * @category Utils
775
+ * @param matches The array of {@link RouteMatch | route matches} to render
776
+ * @returns A React element that renders the matched routes or `null` if no matches
777
+ */
778
+ function renderMatches(matches) {
779
+ return _renderMatches(matches);
780
+ }
781
+ function useRouteComponentProps() {
782
+ return {
783
+ params: useParams(),
784
+ loaderData: useLoaderData(),
785
+ actionData: useActionData(),
786
+ matches: useMatches()
787
+ };
788
+ }
789
+ function WithComponentProps({ children }) {
790
+ const props = useRouteComponentProps();
791
+ return React$1.cloneElement(children, props);
792
+ }
793
+ function withComponentProps(Component) {
794
+ return function WithComponentProps() {
795
+ const props = useRouteComponentProps();
796
+ return React$1.createElement(Component, props);
797
+ };
798
+ }
799
+ function useHydrateFallbackProps() {
800
+ return {
801
+ params: useParams(),
802
+ loaderData: useLoaderData(),
803
+ actionData: useActionData()
804
+ };
805
+ }
806
+ function WithHydrateFallbackProps({ children }) {
807
+ const props = useHydrateFallbackProps();
808
+ return React$1.cloneElement(children, props);
809
+ }
810
+ function withHydrateFallbackProps(HydrateFallback) {
811
+ return function WithHydrateFallbackProps() {
812
+ const props = useHydrateFallbackProps();
813
+ return React$1.createElement(HydrateFallback, props);
814
+ };
815
+ }
816
+ function useErrorBoundaryProps() {
817
+ return {
818
+ params: useParams(),
819
+ loaderData: useLoaderData(),
820
+ actionData: useActionData(),
821
+ error: useRouteError()
822
+ };
823
+ }
824
+ function WithErrorBoundaryProps({ children }) {
825
+ const props = useErrorBoundaryProps();
826
+ return React$1.cloneElement(children, props);
827
+ }
828
+ function withErrorBoundaryProps(ErrorBoundary) {
829
+ return function WithErrorBoundaryProps() {
830
+ const props = useErrorBoundaryProps();
831
+ return React$1.createElement(ErrorBoundary, props);
832
+ };
833
+ }
834
+ //#endregion
835
+ export { Await, DataRoutes, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, WithComponentProps, WithErrorBoundaryProps, WithHydrateFallbackProps, createMemoryRouter, createRoutesFromChildren, createRoutesFromElements, hydrationRouteProperties, renderMatches, withComponentProps, withErrorBoundaryProps, withHydrateFallbackProps };