react-router 7.15.1 → 8.3.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 (364) hide show
  1. package/CHANGELOG.md +181 -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 +1789 -1657
  7. package/dist/development/index-react-server.js +3074 -3674
  8. package/dist/development/index.d.ts +41 -1469
  9. package/dist/development/index.js +36 -2621
  10. package/dist/development/lib/actions.js +50 -0
  11. package/dist/development/lib/components.d.ts +1030 -0
  12. package/dist/development/lib/components.js +841 -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 +2054 -0
  18. package/dist/development/lib/dom/lib.js +1272 -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 +198 -0
  22. package/dist/development/lib/dom/ssr/components.js +589 -0
  23. package/dist/development/lib/dom/ssr/data.js +29 -0
  24. package/dist/development/lib/dom/ssr/entry.d.ts +60 -0
  25. package/dist/development/lib/dom/ssr/errorBoundaries.d.ts +27 -0
  26. package/dist/development/lib/dom/ssr/errorBoundaries.js +87 -0
  27. package/dist/development/lib/dom/ssr/fallback.js +33 -0
  28. package/dist/development/lib/dom/ssr/fog-of-war.d.ts +12 -0
  29. package/dist/development/lib/dom/ssr/fog-of-war.js +185 -0
  30. package/dist/development/lib/dom/ssr/hydration.d.ts +32 -0
  31. package/dist/development/lib/dom/ssr/hydration.js +29 -0
  32. package/dist/development/lib/dom/ssr/invariant.js +16 -0
  33. package/dist/development/lib/dom/ssr/links.js +170 -0
  34. package/dist/development/lib/dom/ssr/markup.js +24 -0
  35. package/dist/development/lib/dom/ssr/routeModules.d.ts +206 -0
  36. package/dist/development/lib/dom/ssr/routeModules.js +31 -0
  37. package/dist/development/lib/dom/ssr/routes-test-stub.d.ts +75 -0
  38. package/dist/development/lib/dom/ssr/routes-test-stub.js +121 -0
  39. package/dist/development/lib/dom/ssr/routes.d.ts +33 -0
  40. package/dist/development/lib/dom/ssr/routes.js +303 -0
  41. package/dist/development/lib/dom/ssr/server.d.ts +48 -0
  42. package/dist/development/lib/dom/ssr/server.js +69 -0
  43. package/dist/development/lib/dom/ssr/single-fetch.d.ts +14 -0
  44. package/dist/development/lib/dom/ssr/single-fetch.js +345 -0
  45. package/dist/development/lib/dom-export/dom-router-provider.d.ts +9 -0
  46. package/dist/development/lib/dom-export/dom-router-provider.js +22 -0
  47. package/dist/development/lib/dom-export/hydrated-router.d.ts +125 -0
  48. package/dist/development/lib/dom-export/hydrated-router.js +150 -0
  49. package/dist/development/lib/errors.js +29 -0
  50. package/dist/development/lib/hooks.d.ts +974 -0
  51. package/dist/development/lib/hooks.js +1415 -0
  52. package/dist/development/lib/href.d.ts +36 -0
  53. package/dist/development/lib/href.js +70 -0
  54. package/dist/development/lib/router/history.d.ts +264 -0
  55. package/dist/development/lib/router/history.js +378 -0
  56. package/dist/development/lib/router/instrumentation.d.ts +111 -0
  57. package/dist/development/lib/router/instrumentation.js +290 -0
  58. package/dist/development/lib/router/links.d.ts +114 -0
  59. package/dist/development/lib/router/router.d.ts +663 -0
  60. package/dist/development/lib/router/router.js +2988 -0
  61. package/dist/development/lib/router/url.js +18 -0
  62. package/dist/development/lib/router/utils.d.ts +960 -0
  63. package/dist/development/lib/router/utils.js +881 -0
  64. package/dist/development/lib/rsc/browser.d.ts +137 -0
  65. package/dist/development/lib/rsc/browser.js +612 -0
  66. package/dist/development/lib/rsc/errorBoundaries.d.ts +11 -0
  67. package/dist/development/lib/rsc/errorBoundaries.js +90 -0
  68. package/dist/development/lib/rsc/html-stream/browser.d.ts +48 -0
  69. package/dist/development/lib/rsc/html-stream/browser.js +74 -0
  70. package/dist/development/lib/rsc/html-stream/server.js +97 -0
  71. package/dist/development/lib/rsc/route-modules.js +27 -0
  72. package/dist/development/lib/rsc/server.rsc.d.ts +224 -0
  73. package/dist/development/lib/rsc/server.ssr.d.ts +152 -0
  74. package/dist/development/lib/rsc/server.ssr.js +419 -0
  75. package/dist/development/lib/server-runtime/build.d.ts +66 -0
  76. package/dist/development/lib/server-runtime/cookies.d.ts +92 -0
  77. package/dist/development/lib/server-runtime/cookies.js +153 -0
  78. package/dist/development/lib/server-runtime/crypto.js +43 -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 +22 -0
  92. package/dist/development/lib/server-runtime/server.js +364 -0
  93. package/dist/development/lib/server-runtime/serverHandoff.js +17 -0
  94. package/dist/development/lib/server-runtime/sessions/cookieStorage.d.ts +33 -0
  95. package/dist/development/lib/server-runtime/sessions/cookieStorage.js +53 -0
  96. package/dist/development/lib/server-runtime/sessions/memoryStorage.d.ts +29 -0
  97. package/dist/development/lib/server-runtime/sessions/memoryStorage.js +58 -0
  98. package/dist/development/lib/server-runtime/sessions.d.ts +174 -0
  99. package/dist/development/lib/server-runtime/sessions.js +115 -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/{production/register-Bsscfj79.d.ts → development/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 -1007
  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 +1789 -1657
  122. package/dist/production/index-react-server.js +3065 -3674
  123. package/dist/production/index.d.ts +41 -1469
  124. package/dist/production/index.js +36 -2621
  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 +2054 -0
  133. package/dist/production/lib/dom/lib.js +1272 -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 +185 -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 +75 -0
  153. package/dist/production/lib/dom/ssr/routes-test-stub.js +121 -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 +974 -0
  166. package/dist/production/lib/hooks.js +1400 -0
  167. package/dist/production/lib/href.d.ts +36 -0
  168. package/dist/production/lib/href.js +70 -0
  169. package/dist/production/lib/router/history.d.ts +264 -0
  170. package/dist/production/lib/router/history.js +378 -0
  171. package/dist/production/lib/router/instrumentation.d.ts +111 -0
  172. package/dist/production/lib/router/instrumentation.js +290 -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 +960 -0
  178. package/dist/production/lib/router/utils.js +872 -0
  179. package/dist/production/lib/rsc/browser.d.ts +137 -0
  180. package/dist/production/lib/rsc/browser.js +612 -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 +97 -0
  186. package/dist/production/lib/rsc/route-modules.js +27 -0
  187. package/dist/production/lib/rsc/server.rsc.d.ts +224 -0
  188. package/dist/production/lib/rsc/server.ssr.d.ts +152 -0
  189. package/dist/production/lib/rsc/server.ssr.js +419 -0
  190. package/dist/production/lib/server-runtime/build.d.ts +66 -0
  191. package/dist/production/lib/server-runtime/cookies.d.ts +92 -0
  192. package/dist/production/lib/server-runtime/cookies.js +153 -0
  193. package/dist/production/lib/server-runtime/crypto.js +43 -0
  194. package/dist/production/lib/server-runtime/data.js +25 -0
  195. package/dist/production/lib/server-runtime/dev.d.ts +9 -0
  196. package/dist/production/lib/server-runtime/dev.js +26 -0
  197. package/dist/production/lib/server-runtime/entry.js +20 -0
  198. package/dist/production/lib/server-runtime/errors.js +75 -0
  199. package/dist/production/lib/server-runtime/headers.js +73 -0
  200. package/dist/production/lib/server-runtime/invariant.js +19 -0
  201. package/dist/production/lib/server-runtime/mode.d.ts +12 -0
  202. package/dist/production/lib/server-runtime/mode.js +25 -0
  203. package/dist/production/lib/server-runtime/routeMatching.js +28 -0
  204. package/dist/production/lib/server-runtime/routes.d.ts +13 -0
  205. package/dist/production/lib/server-runtime/routes.js +74 -0
  206. package/dist/production/lib/server-runtime/server.d.ts +22 -0
  207. package/dist/production/lib/server-runtime/server.js +364 -0
  208. package/dist/production/lib/server-runtime/serverHandoff.js +17 -0
  209. package/dist/production/lib/server-runtime/sessions/cookieStorage.d.ts +33 -0
  210. package/dist/production/lib/server-runtime/sessions/cookieStorage.js +53 -0
  211. package/dist/production/lib/server-runtime/sessions/memoryStorage.d.ts +29 -0
  212. package/dist/production/lib/server-runtime/sessions/memoryStorage.js +58 -0
  213. package/dist/production/lib/server-runtime/sessions.d.ts +174 -0
  214. package/dist/production/lib/server-runtime/sessions.js +115 -0
  215. package/dist/production/lib/server-runtime/single-fetch.d.ts +7 -0
  216. package/dist/production/lib/server-runtime/single-fetch.js +215 -0
  217. package/dist/production/lib/server-runtime/urls.js +28 -0
  218. package/dist/production/lib/server-runtime/warnings.js +20 -0
  219. package/dist/production/lib/types/future.d.ts +9 -0
  220. package/dist/production/lib/types/internal.d.ts +26 -177
  221. package/dist/production/lib/types/internal.js +3 -2
  222. package/dist/{development/register-Bsscfj79.d.ts → production/lib/types/register.d.ts} +9 -15
  223. package/dist/production/lib/types/route-data.d.ts +113 -0
  224. package/dist/production/lib/types/route-module-annotations.d.ts +149 -0
  225. package/dist/production/lib/types/route-module.d.ts +19 -0
  226. package/dist/production/lib/types/serializes-to.d.ts +13 -0
  227. package/dist/production/lib/types/utils.d.ts +11 -0
  228. package/dist/production/vendor/turbo-stream-v2/flatten.js +159 -0
  229. package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +179 -0
  230. package/dist/production/vendor/turbo-stream-v2/unflatten.js +199 -0
  231. package/dist/production/vendor/turbo-stream-v2/utils.js +39 -0
  232. package/docs/explanation/backend-for-frontend.md +50 -0
  233. package/docs/explanation/code-splitting.md +77 -0
  234. package/docs/explanation/concurrency.md +135 -0
  235. package/docs/explanation/form-vs-fetcher.md +292 -0
  236. package/docs/explanation/hot-module-replacement.md +137 -0
  237. package/docs/explanation/hydration.md +14 -0
  238. package/docs/explanation/index-query-param.md +86 -0
  239. package/docs/explanation/index.md +4 -0
  240. package/docs/explanation/lazy-route-discovery.md +78 -0
  241. package/docs/explanation/location.md +6 -0
  242. package/docs/explanation/progressive-enhancement.md +150 -0
  243. package/docs/explanation/race-conditions.md +88 -0
  244. package/docs/explanation/react-transitions.md +160 -0
  245. package/docs/explanation/route-matching.md +7 -0
  246. package/docs/explanation/server-client-execution.md +4 -0
  247. package/docs/explanation/sessions-and-cookies.md +465 -0
  248. package/docs/explanation/special-files.md +16 -0
  249. package/docs/explanation/state-management.md +524 -0
  250. package/docs/explanation/styling.md +87 -0
  251. package/docs/explanation/type-safety.md +82 -0
  252. package/docs/how-to/accessibility.md +44 -0
  253. package/docs/how-to/client-data.md +199 -0
  254. package/docs/how-to/data-strategy.md +317 -0
  255. package/docs/how-to/error-boundary.md +231 -0
  256. package/docs/how-to/error-reporting.md +142 -0
  257. package/docs/how-to/fetchers.md +307 -0
  258. package/docs/how-to/file-route-conventions.md +410 -0
  259. package/docs/how-to/file-uploads.md +217 -0
  260. package/docs/how-to/form-validation.md +120 -0
  261. package/docs/how-to/headers.md +165 -0
  262. package/docs/how-to/index.md +4 -0
  263. package/docs/how-to/instrumentation.md +661 -0
  264. package/docs/how-to/meta.md +40 -0
  265. package/docs/how-to/middleware.md +647 -0
  266. package/docs/how-to/navigation-blocking.md +233 -0
  267. package/docs/how-to/optimize-revalidation.md +12 -0
  268. package/docs/how-to/pre-rendering.md +225 -0
  269. package/docs/how-to/presets.md +103 -0
  270. package/docs/how-to/react-server-components.md +951 -0
  271. package/docs/how-to/resource-routes.md +126 -0
  272. package/docs/how-to/route-module-type-safety.md +85 -0
  273. package/docs/how-to/search-params.md +4 -0
  274. package/docs/how-to/security.md +39 -0
  275. package/docs/how-to/server-bundles.md +66 -0
  276. package/docs/how-to/spa.md +120 -0
  277. package/docs/how-to/status.md +63 -0
  278. package/docs/how-to/suspense.md +132 -0
  279. package/docs/how-to/using-handle.md +117 -0
  280. package/docs/how-to/view-transitions.md +237 -0
  281. package/docs/how-to/webhook.md +50 -0
  282. package/docs/index.md +36 -0
  283. package/docs/start/data/actions.md +138 -0
  284. package/docs/start/data/custom.md +198 -0
  285. package/docs/start/data/data-loading.md +44 -0
  286. package/docs/start/data/index.md +4 -0
  287. package/docs/start/data/installation.md +56 -0
  288. package/docs/start/data/navigating.md +12 -0
  289. package/docs/start/data/pending-ui.md +12 -0
  290. package/docs/start/data/route-object.md +268 -0
  291. package/docs/start/data/routing.md +281 -0
  292. package/docs/start/data/testing.md +8 -0
  293. package/docs/start/declarative/index.md +4 -0
  294. package/docs/start/declarative/installation.md +43 -0
  295. package/docs/start/declarative/navigating.md +133 -0
  296. package/docs/start/declarative/routing.md +237 -0
  297. package/docs/start/declarative/url-values.md +65 -0
  298. package/docs/start/framework/actions.md +174 -0
  299. package/docs/start/framework/data-loading.md +201 -0
  300. package/docs/start/framework/deploying.md +104 -0
  301. package/docs/start/framework/index.md +4 -0
  302. package/docs/start/framework/installation.md +41 -0
  303. package/docs/start/framework/navigating.md +182 -0
  304. package/docs/start/framework/pending-ui.md +142 -0
  305. package/docs/start/framework/rendering.md +59 -0
  306. package/docs/start/framework/route-module.md +527 -0
  307. package/docs/start/framework/routing.md +362 -0
  308. package/docs/start/framework/testing.md +133 -0
  309. package/docs/start/index.md +4 -0
  310. package/docs/start/modes.md +200 -0
  311. package/docs/upgrading/component-routes.md +363 -0
  312. package/docs/upgrading/future.md +111 -0
  313. package/docs/upgrading/index.md +4 -0
  314. package/docs/upgrading/router-provider.md +445 -0
  315. package/docs/upgrading/v7.md +460 -0
  316. package/package.json +44 -87
  317. package/dist/development/browser-3AnU12UI.d.mts +0 -318
  318. package/dist/development/browser-BOdXz9dK.d.ts +0 -318
  319. package/dist/development/chunk-4N6VE7H7.mjs +0 -11528
  320. package/dist/development/chunk-4YRVXM2U.js +0 -188
  321. package/dist/development/chunk-66UKHEGQ.js +0 -1362
  322. package/dist/development/chunk-D6LUOGOQ.js +0 -10229
  323. package/dist/development/chunk-RJYABSBD.mjs +0 -2585
  324. package/dist/development/context-ByvtofY2.d.mts +0 -1771
  325. package/dist/development/data-BVUf681J.d.mts +0 -1732
  326. package/dist/development/data-BqZ2x964.d.ts +0 -1732
  327. package/dist/development/dom-export.d.mts +0 -172
  328. package/dist/development/dom-export.mjs +0 -1008
  329. package/dist/development/index-react-server-client-BS5F89FR.d.ts +0 -3655
  330. package/dist/development/index-react-server-client-DY04-103.d.mts +0 -2600
  331. package/dist/development/index-react-server-client.d.mts +0 -4
  332. package/dist/development/index-react-server-client.mjs +0 -59
  333. package/dist/development/index-react-server.d.mts +0 -2703
  334. package/dist/development/index-react-server.mjs +0 -3780
  335. package/dist/development/index.d.mts +0 -1472
  336. package/dist/development/index.mjs +0 -277
  337. package/dist/development/instrumentation-cRWWLfsU.d.ts +0 -715
  338. package/dist/development/lib/types/internal.d.mts +0 -184
  339. package/dist/development/lib/types/internal.mjs +0 -10
  340. package/dist/development/register-Df8okEea.d.mts +0 -30
  341. package/dist/production/browser-3AnU12UI.d.mts +0 -318
  342. package/dist/production/browser-BOdXz9dK.d.ts +0 -318
  343. package/dist/production/chunk-6S4627ZB.mjs +0 -2585
  344. package/dist/production/chunk-HUBUW7R3.js +0 -10229
  345. package/dist/production/chunk-JAKZPQZC.mjs +0 -11528
  346. package/dist/production/chunk-PNZCCTKT.js +0 -1362
  347. package/dist/production/chunk-Y6IFXO7V.js +0 -188
  348. package/dist/production/context-ByvtofY2.d.mts +0 -1771
  349. package/dist/production/data-BVUf681J.d.mts +0 -1732
  350. package/dist/production/data-BqZ2x964.d.ts +0 -1732
  351. package/dist/production/dom-export.d.mts +0 -172
  352. package/dist/production/dom-export.mjs +0 -1008
  353. package/dist/production/index-react-server-client-BS5F89FR.d.ts +0 -3655
  354. package/dist/production/index-react-server-client-DY04-103.d.mts +0 -2600
  355. package/dist/production/index-react-server-client.d.mts +0 -4
  356. package/dist/production/index-react-server-client.mjs +0 -59
  357. package/dist/production/index-react-server.d.mts +0 -2703
  358. package/dist/production/index-react-server.mjs +0 -3780
  359. package/dist/production/index.d.mts +0 -1472
  360. package/dist/production/index.mjs +0 -277
  361. package/dist/production/instrumentation-cRWWLfsU.d.ts +0 -715
  362. package/dist/production/lib/types/internal.d.mts +0 -184
  363. package/dist/production/lib/types/internal.mjs +0 -10
  364. package/dist/production/register-Df8okEea.d.mts +0 -30
@@ -0,0 +1,881 @@
1
+ /**
2
+ * react-router v8.3.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 { ABSOLUTE_URL_REGEX, PROTOCOL_RELATIVE_URL_REGEX, normalizeProtocolRelativeUrl } from "./url.js";
12
+ import { invariant, parsePath, warning } from "./history.js";
13
+ import * as React$1 from "react";
14
+ //#region lib/router/utils.ts
15
+ /**
16
+ * Creates a type-safe {@link RouterContext} object that can be used to
17
+ * store and retrieve arbitrary values in [`action`](../../start/framework/route-module#action)s,
18
+ * [`loader`](../../start/framework/route-module#loader)s, and [middleware](../../how-to/middleware).
19
+ * Similar to React's [`createContext`](https://react.dev/reference/react/createContext),
20
+ * but specifically designed for React Router's request/response lifecycle.
21
+ *
22
+ * If a `defaultValue` is provided, it will be returned from `context.get()`
23
+ * when no value has been set for the context. Otherwise, reading this context
24
+ * when no value has been set will throw an error.
25
+ *
26
+ * ```tsx filename=app/context.ts
27
+ * import { createContext } from "react-router";
28
+ *
29
+ * // Create a context for user data
30
+ * export const userContext =
31
+ * createContext<User | null>(null);
32
+ * ```
33
+ *
34
+ * ```tsx filename=app/middleware/auth.ts
35
+ * import { getUserFromSession } from "~/auth.server";
36
+ * import { userContext } from "~/context";
37
+ *
38
+ * export const authMiddleware = async ({
39
+ * context,
40
+ * request,
41
+ * }) => {
42
+ * const user = await getUserFromSession(request);
43
+ * context.set(userContext, user);
44
+ * };
45
+ * ```
46
+ *
47
+ * ```tsx filename=app/routes/profile.tsx
48
+ * import { userContext } from "~/context";
49
+ *
50
+ * export async function loader({
51
+ * context,
52
+ * }: Route.LoaderArgs) {
53
+ * const user = context.get(userContext);
54
+ *
55
+ * if (!user) {
56
+ * throw new Response("Unauthorized", { status: 401 });
57
+ * }
58
+ *
59
+ * return { user };
60
+ * }
61
+ * ```
62
+ *
63
+ * @public
64
+ * @category Utils
65
+ * @mode framework
66
+ * @mode data
67
+ * @param defaultValue An optional default value for the context. This value
68
+ * will be returned if no value has been set for this context.
69
+ * @returns A {@link RouterContext} object that can be used with
70
+ * `context.get()` and `context.set()` in [`action`](../../start/framework/route-module#action)s,
71
+ * [`loader`](../../start/framework/route-module#loader)s, and [middleware](../../how-to/middleware).
72
+ */
73
+ function createContext(defaultValue) {
74
+ return { defaultValue };
75
+ }
76
+ /**
77
+ * Provides methods for writing/reading values in application context in a
78
+ * type-safe way. Primarily for usage with [middleware](../../how-to/middleware).
79
+ *
80
+ * @example
81
+ * import {
82
+ * createContext,
83
+ * RouterContextProvider
84
+ * } from "react-router";
85
+ *
86
+ * const userContext = createContext<User | null>(null);
87
+ * const contextProvider = new RouterContextProvider();
88
+ * contextProvider.set(userContext, getUser());
89
+ * // ^ Type-safe
90
+ * const user = contextProvider.get(userContext);
91
+ * // ^ User
92
+ *
93
+ * @public
94
+ * @category Utils
95
+ * @mode framework
96
+ * @mode data
97
+ */
98
+ var RouterContextProvider = class {
99
+ #map = /* @__PURE__ */ new Map();
100
+ /**
101
+ * Create a new `RouterContextProvider` instance
102
+ * @param init An optional initial context map to populate the provider with
103
+ */
104
+ constructor(init) {
105
+ if (init) for (let [context, value] of init) this.set(context, value);
106
+ }
107
+ /**
108
+ * Access a value from the context. If no value has been set for the context,
109
+ * it will return the context's `defaultValue` if provided, or throw an error
110
+ * if no `defaultValue` was set.
111
+ * @param context The context to get the value for
112
+ * @returns The value for the context, or the context's `defaultValue` if no
113
+ * value was set
114
+ */
115
+ get(context) {
116
+ if (this.#map.has(context)) return this.#map.get(context);
117
+ if (context.defaultValue !== void 0) return context.defaultValue;
118
+ throw new Error("No value found for context");
119
+ }
120
+ /**
121
+ * Set a value for the context. If the context already has a value set, this
122
+ * will overwrite it.
123
+ *
124
+ * @param context The context to set the value for
125
+ * @param value The value to set for the context
126
+ * @returns {void}
127
+ */
128
+ set(context, value) {
129
+ this.#map.set(context, value);
130
+ }
131
+ };
132
+ const unsupportedLazyRouteObjectKeys = new Set([
133
+ "lazy",
134
+ "caseSensitive",
135
+ "path",
136
+ "id",
137
+ "index",
138
+ "children"
139
+ ]);
140
+ function isUnsupportedLazyRouteObjectKey(key) {
141
+ return unsupportedLazyRouteObjectKeys.has(key);
142
+ }
143
+ const unsupportedLazyRouteFunctionKeys = new Set([
144
+ "lazy",
145
+ "caseSensitive",
146
+ "path",
147
+ "id",
148
+ "index",
149
+ "middleware",
150
+ "children"
151
+ ]);
152
+ function isUnsupportedLazyRouteFunctionKey(key) {
153
+ return unsupportedLazyRouteFunctionKeys.has(key);
154
+ }
155
+ function isIndexRoute(route) {
156
+ return route.index === true;
157
+ }
158
+ function defaultMapRouteProperties(route) {
159
+ let updates = {};
160
+ if (route.Component) {
161
+ if (route.element) warning(false, "You should not include both `Component` and `element` on your route - `Component` will be used.");
162
+ Object.assign(updates, {
163
+ element: React$1.createElement(route.Component),
164
+ Component: void 0
165
+ });
166
+ }
167
+ if (route.HydrateFallback) {
168
+ if (route.hydrateFallbackElement) warning(false, "You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - `HydrateFallback` will be used.");
169
+ Object.assign(updates, {
170
+ hydrateFallbackElement: React$1.createElement(route.HydrateFallback),
171
+ HydrateFallback: void 0
172
+ });
173
+ }
174
+ if (route.ErrorBoundary) {
175
+ if (route.errorElement) warning(false, "You should not include both `ErrorBoundary` and `errorElement` on your route - `ErrorBoundary` will be used.");
176
+ Object.assign(updates, {
177
+ errorElement: React$1.createElement(route.ErrorBoundary),
178
+ ErrorBoundary: void 0
179
+ });
180
+ }
181
+ return updates;
182
+ }
183
+ function convertRoutesToDataRoutes(routes, mapRouteProperties = defaultMapRouteProperties, parentPath = [], manifest = {}, allowInPlaceMutations = false) {
184
+ return routes.map((route, index) => {
185
+ let treePath = [...parentPath, String(index)];
186
+ let id = typeof route.id === "string" ? route.id : treePath.join("-");
187
+ invariant(route.index !== true || !route.children, `Cannot specify children on an index route`);
188
+ invariant(allowInPlaceMutations || !manifest[id], `Found a route id collision on id "${id}". Route id's must be globally unique within Data Router usages`);
189
+ if (isIndexRoute(route)) {
190
+ let indexRoute = {
191
+ ...route,
192
+ id
193
+ };
194
+ manifest[id] = mergeRouteUpdates(indexRoute, mapRouteProperties(indexRoute));
195
+ return indexRoute;
196
+ } else {
197
+ let pathOrLayoutRoute = {
198
+ ...route,
199
+ id,
200
+ children: void 0
201
+ };
202
+ manifest[id] = mergeRouteUpdates(pathOrLayoutRoute, mapRouteProperties(pathOrLayoutRoute));
203
+ if (route.children) pathOrLayoutRoute.children = convertRoutesToDataRoutes(route.children, mapRouteProperties, treePath, manifest, allowInPlaceMutations);
204
+ return pathOrLayoutRoute;
205
+ }
206
+ });
207
+ }
208
+ function mergeRouteUpdates(route, updates) {
209
+ return Object.assign(route, {
210
+ ...updates,
211
+ ...typeof updates.lazy === "object" && updates.lazy != null ? { lazy: {
212
+ ...route.lazy,
213
+ ...updates.lazy
214
+ } } : {}
215
+ });
216
+ }
217
+ /**
218
+ * Matches the given routes to a location and returns the match data.
219
+ *
220
+ * @example
221
+ * import { matchRoutes } from "react-router";
222
+ *
223
+ * let routes = [{
224
+ * path: "/",
225
+ * Component: Root,
226
+ * children: [{
227
+ * path: "dashboard",
228
+ * Component: Dashboard,
229
+ * }]
230
+ * }];
231
+ *
232
+ * matchRoutes(routes, "/dashboard"); // [rootMatch, dashboardMatch]
233
+ *
234
+ * @public
235
+ * @category Utils
236
+ * @param routes The array of route objects to match against.
237
+ * @param locationArg The location to match against, either a string path or a
238
+ * partial {@link Location} object
239
+ * @param basename Optional base path to strip from the location before matching.
240
+ * Defaults to `/`.
241
+ * @returns An array of matched routes, or `null` if no matches were found.
242
+ */
243
+ function matchRoutes(routes, locationArg, basename = "/") {
244
+ return matchRoutesImpl(routes, locationArg, basename, false);
245
+ }
246
+ function matchRoutesImpl(routes, locationArg, basename, allowPartial, precomputedBranches) {
247
+ let pathname = stripBasename((typeof locationArg === "string" ? parsePath(locationArg) : locationArg).pathname || "/", basename);
248
+ if (pathname == null) return null;
249
+ let branches = precomputedBranches ?? flattenAndRankRoutes(routes);
250
+ let matches = null;
251
+ let decoded = decodePath(pathname);
252
+ for (let i = 0; matches == null && i < branches.length; ++i) matches = matchRouteBranch(branches[i], decoded, allowPartial);
253
+ return matches;
254
+ }
255
+ function convertRouteMatchToUiMatch(match, loaderData) {
256
+ let { route, pathname, params } = match;
257
+ return {
258
+ id: route.id,
259
+ pathname,
260
+ params,
261
+ loaderData: loaderData[route.id],
262
+ handle: route.handle
263
+ };
264
+ }
265
+ function flattenAndRankRoutes(routes) {
266
+ let branches = flattenRoutes(routes);
267
+ rankRouteBranches(branches);
268
+ return branches;
269
+ }
270
+ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
271
+ let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
272
+ let meta = {
273
+ relativePath: relativePath === void 0 ? route.path || "" : relativePath,
274
+ caseSensitive: route.caseSensitive === true,
275
+ childrenIndex: index,
276
+ route
277
+ };
278
+ if (meta.relativePath.startsWith("/")) {
279
+ if (!meta.relativePath.startsWith(parentPath) && hasParentOptionalSegments) return;
280
+ invariant(meta.relativePath.startsWith(parentPath), `Absolute route path "${meta.relativePath}" nested under path "${parentPath}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`);
281
+ meta.relativePath = meta.relativePath.slice(parentPath.length);
282
+ }
283
+ let path = joinPaths([parentPath, meta.relativePath]);
284
+ let routesMeta = parentsMeta.concat(meta);
285
+ if (route.children && route.children.length > 0) {
286
+ invariant(route.index !== true, `Index routes must not have child routes. Please remove all child routes from route path "${path}".`);
287
+ flattenRoutes(route.children, branches, routesMeta, path, hasParentOptionalSegments);
288
+ }
289
+ if (route.path == null && !route.index) return;
290
+ branches.push({
291
+ path,
292
+ score: computeScore(path, route.index),
293
+ routesMeta: routesMeta.map((meta, i) => {
294
+ let [matcher, params] = compilePath(meta.relativePath, meta.caseSensitive, i === routesMeta.length - 1);
295
+ return {
296
+ ...meta,
297
+ matcher,
298
+ compiledParams: params
299
+ };
300
+ })
301
+ });
302
+ };
303
+ routes.forEach((route, index) => {
304
+ if (route.path === "" || !route.path?.includes("?")) flattenRoute(route, index);
305
+ else for (let exploded of explodeOptionalSegments(route.path)) flattenRoute(route, index, true, exploded);
306
+ });
307
+ return branches;
308
+ }
309
+ function explodeOptionalSegments(path) {
310
+ let segments = path.split("/");
311
+ if (segments.length === 0) return [];
312
+ let [first, ...rest] = segments;
313
+ let isOptional = first.endsWith("?");
314
+ let required = first.replace(/\?$/, "");
315
+ if (rest.length === 0) return isOptional ? [required, ""] : [required];
316
+ let restExploded = explodeOptionalSegments(rest.join("/"));
317
+ let result = [];
318
+ result.push(...restExploded.map((subpath) => subpath === "" ? required : [required, subpath].join("/")));
319
+ if (isOptional) result.push(...restExploded);
320
+ return result.map((exploded) => path.startsWith("/") && exploded === "" ? "/" : exploded);
321
+ }
322
+ function rankRouteBranches(branches) {
323
+ branches.sort((a, b) => a.score !== b.score ? b.score - a.score : compareIndexes(a.routesMeta.map((meta) => meta.childrenIndex), b.routesMeta.map((meta) => meta.childrenIndex)));
324
+ }
325
+ const paramRe = /^:[\w-]+$/;
326
+ const partialParamRe = /^:[\w-]+/;
327
+ const partialDynamicSegmentValue = 3.5;
328
+ const dynamicSegmentValue = 3;
329
+ const indexRouteValue = 2;
330
+ const emptySegmentValue = 1;
331
+ const staticSegmentValue = 10;
332
+ const splatPenalty = -2;
333
+ const isSplat = (s) => s === "*";
334
+ function computeScore(path, index) {
335
+ let segments = path.split("/");
336
+ let initialScore = segments.length;
337
+ if (segments.some(isSplat)) initialScore += splatPenalty;
338
+ if (index) initialScore += indexRouteValue;
339
+ return segments.filter((s) => !isSplat(s)).reduce((score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : partialParamRe.test(segment) ? partialDynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue), initialScore);
340
+ }
341
+ function compareIndexes(a, b) {
342
+ return a.length === b.length && a.slice(0, -1).every((n, i) => n === b[i]) ? a[a.length - 1] - b[b.length - 1] : 0;
343
+ }
344
+ function matchRouteBranch(branch, pathname, allowPartial = false) {
345
+ let { routesMeta } = branch;
346
+ let matchedParams = {};
347
+ let matchedPathname = "/";
348
+ let matches = [];
349
+ for (let i = 0; i < routesMeta.length; ++i) {
350
+ let meta = routesMeta[i];
351
+ let end = i === routesMeta.length - 1;
352
+ let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
353
+ let pattern = {
354
+ path: meta.relativePath,
355
+ caseSensitive: meta.caseSensitive,
356
+ end
357
+ };
358
+ let match = meta.matcher && meta.compiledParams ? matchPathImpl(pattern, remainingPathname, meta.matcher, meta.compiledParams) : matchPath(pattern, remainingPathname);
359
+ let route = meta.route;
360
+ if (!match && end && allowPartial && !routesMeta[routesMeta.length - 1].route.index) match = matchPath({
361
+ path: meta.relativePath,
362
+ caseSensitive: meta.caseSensitive,
363
+ end: false
364
+ }, remainingPathname);
365
+ if (!match) return null;
366
+ Object.assign(matchedParams, match.params);
367
+ matches.push({
368
+ params: matchedParams,
369
+ pathname: joinPaths([matchedPathname, match.pathname]),
370
+ pathnameBase: normalizePathname(joinPaths([matchedPathname, match.pathnameBase])),
371
+ route
372
+ });
373
+ if (match.pathnameBase !== "/") matchedPathname = joinPaths([matchedPathname, match.pathnameBase]);
374
+ }
375
+ return matches;
376
+ }
377
+ /**
378
+ * Characters that `encodeURIComponent` escapes but that are valid literally in
379
+ * a URL path segment. Per RFC 3986 §3.3, a path segment is made of `pchar`:
380
+ *
381
+ * ```
382
+ * pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
383
+ * sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
384
+ * ```
385
+ *
386
+ * `encodeURIComponent` targets query-string values, where `$ & + , ; = : @`
387
+ * are delimiters and must be escaped — but in a path segment they carry no
388
+ * special meaning, and browsers keep them literal in `location.pathname`.
389
+ * (`! ' ( ) *` and the unreserved set are already left alone by
390
+ * `encodeURIComponent`, so they need no restoring.)
391
+ */
392
+ const PATH_PARAM_OVERESCAPED = {
393
+ "%24": "$",
394
+ "%26": "&",
395
+ "%2B": "+",
396
+ "%2C": ",",
397
+ "%3A": ":",
398
+ "%3B": ";",
399
+ "%3D": "=",
400
+ "%40": "@"
401
+ };
402
+ /**
403
+ * Encodes a param value for interpolation into a single URL path segment.
404
+ *
405
+ * Escapes characters that would break the path (`/ ? # %`, whitespace,
406
+ * non-ASCII, …) while leaving characters that RFC 3986 permits literally in a
407
+ * path segment untouched. Escaping those would needlessly rewrite URLs — e.g.
408
+ * a semver build param `1.0.0+1` would become `1.0.0%2B1` even though browsers
409
+ * display and match the `+` literally in `location.pathname`.
410
+ *
411
+ * See [RFC 3986 §3.3](https://datatracker.ietf.org/doc/html/rfc3986#section-3.3))
412
+ *
413
+ * @param value The param value to encode.
414
+ * @returns The encoded value, safe for use as a single path segment.
415
+ */
416
+ function encodePathParam(value) {
417
+ return encodeURIComponent(value).replace(/%(?:24|26|2B|2C|3A|3B|3D|40)/g, (match) => PATH_PARAM_OVERESCAPED[match]);
418
+ }
419
+ /**
420
+ * Returns a path with params interpolated.
421
+ *
422
+ * Param values are percent-encoded for use in a path segment: characters that
423
+ * would change the URL structure (`/`, `?`, `#`, `%`, whitespace, non-ASCII)
424
+ * are escaped, while characters that RFC 3986 allows literally in a path
425
+ * segment (`$ & + , ; = : @`) are kept as-is. Note this differs from query-string
426
+ * encoding (`encodeURIComponent`/`URLSearchParams`), where those characters are
427
+ * delimiters and must be escaped. Splat (`*`) values are encoded per segment,
428
+ * preserving `/` separators.
429
+ *
430
+ * See [RFC 3986 §3.3](https://datatracker.ietf.org/doc/html/rfc3986#section-3.3)
431
+ *
432
+ * @example
433
+ * import { generatePath } from "react-router";
434
+ *
435
+ * generatePath("/users/:id", { id: "123" }); // "/users/123"
436
+ * generatePath("/files/:name", { name: "a b" }); // "/files/a%20b"
437
+ * generatePath("/releases/:v", { v: "1.0.0+1" }); // "/releases/1.0.0+1"
438
+ *
439
+ * @public
440
+ * @category Utils
441
+ * @param originalPath The original path to generate.
442
+ * @param params The parameters to interpolate into the path.
443
+ * @returns The generated path with parameters interpolated.
444
+ */
445
+ function generatePath(originalPath, params = {}) {
446
+ let path = originalPath;
447
+ if (path.endsWith("*") && path !== "*" && !path.endsWith("/*")) {
448
+ warning(false, `Route path "${path}" will be treated as if it were "${path.replace(/\*$/, "/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${path.replace(/\*$/, "/*")}".`);
449
+ path = path.replace(/\*$/, "/*");
450
+ }
451
+ const prefix = path.startsWith("/") ? "/" : "";
452
+ const stringify = (p) => p == null ? "" : typeof p === "string" ? p : String(p);
453
+ return prefix + path.split(/\/+/).map((segment, index, array) => {
454
+ if (index === array.length - 1 && segment === "*") return stringify(params["*"]);
455
+ const keyMatch = segment.match(/^:([\w-]+)(\??)(.*)/);
456
+ if (keyMatch) {
457
+ const [, key, optional, suffix] = keyMatch;
458
+ let param = params[key];
459
+ invariant(optional === "?" || param != null, `Missing ":${key}" param`);
460
+ return encodePathParam(stringify(param)) + suffix;
461
+ }
462
+ return segment.replace(/\?$/g, "");
463
+ }).filter((segment) => !!segment).join("/");
464
+ }
465
+ /**
466
+ * Performs pattern matching on a URL pathname and returns information about
467
+ * the match.
468
+ *
469
+ * @public
470
+ * @category Utils
471
+ * @param pattern The pattern to match against the URL pathname. This can be a
472
+ * string or a {@link PathPattern} object. If a string is provided, it will be
473
+ * treated as a pattern with `caseSensitive` set to `false` and `end` set to
474
+ * `true`.
475
+ * @param pathname The URL pathname to match against the pattern.
476
+ * @returns A path match object if the pattern matches the pathname,
477
+ * or `null` if it does not match.
478
+ */
479
+ function matchPath(pattern, pathname) {
480
+ if (typeof pattern === "string") pattern = {
481
+ path: pattern,
482
+ caseSensitive: false,
483
+ end: true
484
+ };
485
+ let [matcher, compiledParams] = compilePath(pattern.path, pattern.caseSensitive, pattern.end);
486
+ return matchPathImpl(pattern, pathname, matcher, compiledParams);
487
+ }
488
+ function matchPathImpl(pattern, pathname, matcher, compiledParams) {
489
+ let match = pathname.match(matcher);
490
+ if (!match) return null;
491
+ let matchedPathname = match[0];
492
+ let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
493
+ let captureGroups = match.slice(1);
494
+ return {
495
+ params: compiledParams.reduce((memo, { paramName, isOptional }, index) => {
496
+ if (paramName === "*") {
497
+ let splatValue = captureGroups[index] || "";
498
+ pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
499
+ }
500
+ const value = captureGroups[index];
501
+ if (isOptional && !value) memo[paramName] = void 0;
502
+ else memo[paramName] = (value || "").replace(/%2F/g, "/");
503
+ return memo;
504
+ }, {}),
505
+ pathname: matchedPathname,
506
+ pathnameBase,
507
+ pattern
508
+ };
509
+ }
510
+ function compilePath(path, caseSensitive = false, end = true) {
511
+ warning(path === "*" || !path.endsWith("*") || path.endsWith("/*"), `Route path "${path}" will be treated as if it were "${path.replace(/\*$/, "/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${path.replace(/\*$/, "/*")}".`);
512
+ let params = [];
513
+ let regexpSource = "^" + path.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(/\/:([\w-]+)(\?)?/g, (match, paramName, isOptional, index, str) => {
514
+ params.push({
515
+ paramName,
516
+ isOptional: isOptional != null
517
+ });
518
+ if (isOptional) {
519
+ let nextChar = str.charAt(index + match.length);
520
+ if (nextChar && nextChar !== "/") return "/([^\\/]*)";
521
+ return "(?:/([^\\/]*))?";
522
+ }
523
+ return "/([^\\/]+)";
524
+ }).replace(/\/([\w-]+)\?(?=\/|$|\()/g, "(?:/$1)?");
525
+ if (path.endsWith("*")) {
526
+ params.push({ paramName: "*" });
527
+ regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
528
+ } else if (end) regexpSource += "\\/*$";
529
+ else if (path !== "" && path !== "/") regexpSource += "(?:(?=\\/|$))";
530
+ return [new RegExp(regexpSource, caseSensitive ? void 0 : "i"), params];
531
+ }
532
+ function decodePath(value) {
533
+ try {
534
+ return value.split("/").map((v) => decodeURIComponent(v).replace(/\//g, "%2F")).join("/");
535
+ } catch (error) {
536
+ warning(false, `The URL path "${value}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${error}).`);
537
+ return value;
538
+ }
539
+ }
540
+ function stripBasename(pathname, basename) {
541
+ if (basename === "/") return pathname;
542
+ if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) return null;
543
+ let startIndex = basename.endsWith("/") ? basename.length - 1 : basename.length;
544
+ let nextChar = pathname.charAt(startIndex);
545
+ if (nextChar && nextChar !== "/") return null;
546
+ return pathname.slice(startIndex) || "/";
547
+ }
548
+ function prependBasename({ basename, pathname }) {
549
+ return pathname === "/" ? basename : joinPaths([basename, pathname]);
550
+ }
551
+ const isAbsoluteUrl = (url) => ABSOLUTE_URL_REGEX.test(url);
552
+ /**
553
+ * Returns a resolved {@link Path} object relative to the given pathname.
554
+ *
555
+ * @public
556
+ * @category Utils
557
+ * @param to The path to resolve, either a string or a partial {@link Path}
558
+ * object.
559
+ * @param fromPathname The pathname to resolve the path from. Defaults to `/`.
560
+ * @returns A {@link Path} object with the resolved pathname, search, and hash.
561
+ */
562
+ function resolvePath(to, fromPathname = "/") {
563
+ let { pathname: toPathname, search = "", hash = "" } = typeof to === "string" ? parsePath(to) : to;
564
+ let pathname;
565
+ if (toPathname) {
566
+ toPathname = removeDoubleSlashes(toPathname);
567
+ if (toPathname.startsWith("/")) pathname = resolvePathname(toPathname.substring(1), "/");
568
+ else pathname = resolvePathname(toPathname, fromPathname);
569
+ } else pathname = fromPathname;
570
+ return {
571
+ pathname,
572
+ search: normalizeSearch(search),
573
+ hash: normalizeHash(hash)
574
+ };
575
+ }
576
+ function resolvePathname(relativePath, fromPathname) {
577
+ let segments = removeTrailingSlash(fromPathname).split("/");
578
+ relativePath.split("/").forEach((segment) => {
579
+ if (segment === "..") {
580
+ if (segments.length > 1) segments.pop();
581
+ } else if (segment !== ".") segments.push(segment);
582
+ });
583
+ return segments.length > 1 ? segments.join("/") : "/";
584
+ }
585
+ function getInvalidPathError(char, field, dest, path) {
586
+ return `Cannot include a '${char}' character in a manually specified \`to.${field}\` field [${JSON.stringify(path)}]. Please separate it out to the \`to.${dest}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`;
587
+ }
588
+ function getPathContributingMatches(matches) {
589
+ return matches.filter((match, index) => index === 0 || match.route.path && match.route.path.length > 0);
590
+ }
591
+ function getResolveToMatches(matches) {
592
+ let pathMatches = getPathContributingMatches(matches);
593
+ return pathMatches.map((match, idx) => idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase);
594
+ }
595
+ function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = false) {
596
+ let to;
597
+ if (typeof toArg === "string") to = parsePath(toArg);
598
+ else {
599
+ to = { ...toArg };
600
+ invariant(!to.pathname || !to.pathname.includes("?"), getInvalidPathError("?", "pathname", "search", to));
601
+ invariant(!to.pathname || !to.pathname.includes("#"), getInvalidPathError("#", "pathname", "hash", to));
602
+ invariant(!to.search || !to.search.includes("#"), getInvalidPathError("#", "search", "hash", to));
603
+ }
604
+ let isEmptyPath = toArg === "" || to.pathname === "";
605
+ let toPathname = isEmptyPath ? "/" : to.pathname;
606
+ let from;
607
+ if (toPathname == null) from = locationPathname;
608
+ else {
609
+ let routePathnameIndex = routePathnames.length - 1;
610
+ if (!isPathRelative && toPathname.startsWith("..")) {
611
+ let toSegments = toPathname.split("/");
612
+ while (toSegments[0] === "..") {
613
+ toSegments.shift();
614
+ routePathnameIndex -= 1;
615
+ }
616
+ to.pathname = toSegments.join("/");
617
+ }
618
+ from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/";
619
+ }
620
+ let path = resolvePath(to, from);
621
+ let hasExplicitTrailingSlash = toPathname && toPathname !== "/" && toPathname.endsWith("/");
622
+ let hasCurrentTrailingSlash = (isEmptyPath || toPathname === ".") && locationPathname.endsWith("/");
623
+ if (!path.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash)) path.pathname += "/";
624
+ return path;
625
+ }
626
+ const removeDoubleSlashes = (path) => path.replace(/[\\/]{2,}/g, "/");
627
+ const joinPaths = (paths) => removeDoubleSlashes(paths.join("/"));
628
+ const removeTrailingSlash = (path) => path.replace(/\/+$/, "");
629
+ const normalizePathname = (pathname) => removeTrailingSlash(pathname).replace(/^\/*/, "/");
630
+ const normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
631
+ const normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
632
+ var DataWithResponseInit = class {
633
+ type = "DataWithResponseInit";
634
+ data;
635
+ init;
636
+ constructor(data, init) {
637
+ this.data = data;
638
+ this.init = init || null;
639
+ }
640
+ };
641
+ /**
642
+ * Create "responses" that contain `headers`/`status` without forcing
643
+ * serialization into an actual [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
644
+ *
645
+ * @example
646
+ * import { data } from "react-router";
647
+ *
648
+ * export async function action({ request }: Route.ActionArgs) {
649
+ * let formData = await request.formData();
650
+ * let item = await createItem(formData);
651
+ * return data(item, {
652
+ * headers: { "X-Custom-Header": "value" }
653
+ * status: 201,
654
+ * });
655
+ * }
656
+ *
657
+ * @public
658
+ * @category Utils
659
+ * @mode framework
660
+ * @mode data
661
+ * @param data The data to be included in the response.
662
+ * @param init The status code or a `ResponseInit` object to be included in the
663
+ * response.
664
+ * @returns A {@link DataWithResponseInit} instance containing the data and
665
+ * response init.
666
+ */
667
+ function data(data, init) {
668
+ return new DataWithResponseInit(data, typeof init === "number" ? { status: init } : init);
669
+ }
670
+ /**
671
+ * A redirect [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response).
672
+ * Sets the status code and the [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
673
+ * header. Defaults to [`302 Found`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302).
674
+ *
675
+ * This utility accepts absolute URLs and can navigate to external domains, so
676
+ * the application should validate any user-supplied inputs to redirects.
677
+ *
678
+ * @example
679
+ * import { redirect } from "react-router";
680
+ *
681
+ * export async function loader({ request }: Route.LoaderArgs) {
682
+ * if (!isLoggedIn(request))
683
+ * throw redirect("/login");
684
+ * }
685
+ *
686
+ * // ...
687
+ * }
688
+ *
689
+ * @public
690
+ * @category Utils
691
+ * @mode framework
692
+ * @mode data
693
+ * @param url The URL to redirect to.
694
+ * @param init The status code or a `ResponseInit` object to be included in the
695
+ * response.
696
+ * @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
697
+ * object with the redirect status and [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
698
+ * header.
699
+ */
700
+ const redirect = (url, init = 302) => {
701
+ let responseInit = init;
702
+ if (typeof responseInit === "number") responseInit = { status: responseInit };
703
+ else if (typeof responseInit.status === "undefined") responseInit.status = 302;
704
+ let headers = new Headers(responseInit.headers);
705
+ headers.set("Location", url);
706
+ return new Response(null, {
707
+ ...responseInit,
708
+ headers
709
+ });
710
+ };
711
+ /**
712
+ * A redirect [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
713
+ * that will force a document reload to the new location. Sets the status code
714
+ * and the [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
715
+ * header. Defaults to [`302 Found`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302).
716
+ *
717
+ * This utility accepts absolute URLs and can navigate to external domains, so
718
+ * the application should validate any user-supplied inputs to redirects.
719
+ *
720
+ * ```tsx filename=routes/logout.tsx
721
+ * import { redirectDocument } from "react-router";
722
+ *
723
+ * import { destroySession } from "../sessions.server";
724
+ *
725
+ * export async function action({ request }: Route.ActionArgs) {
726
+ * let session = await getSession(request.headers.get("Cookie"));
727
+ * return redirectDocument("/", {
728
+ * headers: { "Set-Cookie": await destroySession(session) }
729
+ * });
730
+ * }
731
+ * ```
732
+ *
733
+ * @public
734
+ * @category Utils
735
+ * @mode framework
736
+ * @mode data
737
+ * @param url The URL to redirect to.
738
+ * @param init The status code or a `ResponseInit` object to be included in the
739
+ * response.
740
+ * @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
741
+ * object with the redirect status and [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
742
+ * header.
743
+ */
744
+ const redirectDocument = (url, init) => {
745
+ let response = redirect(url, init);
746
+ response.headers.set("X-Remix-Reload-Document", "true");
747
+ return response;
748
+ };
749
+ /**
750
+ * A redirect [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
751
+ * that will perform a [`history.replaceState`](https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState)
752
+ * instead of a [`history.pushState`](https://developer.mozilla.org/en-US/docs/Web/API/History/pushState)
753
+ * for client-side navigation redirects. Sets the status code and the [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
754
+ * header. Defaults to [`302 Found`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302).
755
+ *
756
+ * @example
757
+ * import { replace } from "react-router";
758
+ *
759
+ * export async function loader() {
760
+ * return replace("/new-location");
761
+ * }
762
+ *
763
+ * @public
764
+ * @category Utils
765
+ * @mode framework
766
+ * @mode data
767
+ * @param url The URL to redirect to.
768
+ * @param init The status code or a `ResponseInit` object to be included in the
769
+ * response.
770
+ * @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
771
+ * object with the redirect status and [`Location`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location)
772
+ * header.
773
+ */
774
+ const replace = (url, init) => {
775
+ let response = redirect(url, init);
776
+ response.headers.set("X-Remix-Replace", "true");
777
+ return response;
778
+ };
779
+ const SUPPORTED_ERROR_TYPES = [
780
+ "EvalError",
781
+ "RangeError",
782
+ "ReferenceError",
783
+ "SyntaxError",
784
+ "TypeError",
785
+ "URIError"
786
+ ];
787
+ var ErrorResponseImpl = class {
788
+ status;
789
+ statusText;
790
+ data;
791
+ error;
792
+ internal;
793
+ constructor(status, statusText, data, internal = false) {
794
+ this.status = status;
795
+ this.statusText = statusText || "";
796
+ this.internal = internal;
797
+ if (data instanceof Error) {
798
+ this.data = data.toString();
799
+ this.error = data;
800
+ } else this.data = data;
801
+ }
802
+ };
803
+ /**
804
+ * Check if the given error is an {@link ErrorResponse} generated from a 4xx/5xx
805
+ * [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
806
+ * thrown from an [`action`](../../start/framework/route-module#action) or
807
+ * [`loader`](../../start/framework/route-module#loader) function.
808
+ *
809
+ * @example
810
+ * import { isRouteErrorResponse } from "react-router";
811
+ *
812
+ * export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
813
+ * if (isRouteErrorResponse(error)) {
814
+ * return (
815
+ * <>
816
+ * <p>Error: `${error.status}: ${error.statusText}`</p>
817
+ * <p>{error.data}</p>
818
+ * </>
819
+ * );
820
+ * }
821
+ *
822
+ * return (
823
+ * <p>Error: {error instanceof Error ? error.message : "Unknown Error"}</p>
824
+ * );
825
+ * }
826
+ *
827
+ * @public
828
+ * @category Utils
829
+ * @mode framework
830
+ * @mode data
831
+ * @param error The error to check.
832
+ * @returns `true` if the error is an {@link ErrorResponse}, `false` otherwise.
833
+ */
834
+ function isRouteErrorResponse(error) {
835
+ return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
836
+ }
837
+ function getRoutePattern(matches) {
838
+ return joinPaths(matches.map((m) => m.route.path).filter(Boolean)) || "/";
839
+ }
840
+ function createDataFunctionUrl(request, path) {
841
+ let url = new URL(typeof request === "string" || request instanceof URL ? request : request.url);
842
+ let parsed = typeof path === "string" ? parsePath(path) : path;
843
+ url.pathname = parsed.pathname || "/";
844
+ if (parsed.search) {
845
+ let searchParams = new URLSearchParams(parsed.search);
846
+ let indexValues = searchParams.getAll("index");
847
+ searchParams.delete("index");
848
+ for (let value of indexValues.filter(Boolean)) searchParams.append("index", value);
849
+ let search = searchParams.toString();
850
+ url.search = search ? `?${search}` : "";
851
+ } else url.search = "";
852
+ url.hash = parsed.hash || "";
853
+ return url;
854
+ }
855
+ const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
856
+ function parseToInfo(_to, basename) {
857
+ let to = _to;
858
+ if (typeof to !== "string" || !ABSOLUTE_URL_REGEX.test(to)) return {
859
+ absoluteURL: void 0,
860
+ isExternal: false,
861
+ to
862
+ };
863
+ let absoluteURL = to;
864
+ let isExternal = false;
865
+ if (isBrowser) try {
866
+ let currentUrl = new URL(window.location.href);
867
+ let targetUrl = PROTOCOL_RELATIVE_URL_REGEX.test(to) ? new URL(normalizeProtocolRelativeUrl(to, currentUrl.protocol)) : new URL(to);
868
+ let path = stripBasename(targetUrl.pathname, basename);
869
+ if (targetUrl.origin === currentUrl.origin && path != null) to = path + targetUrl.search + targetUrl.hash;
870
+ else isExternal = true;
871
+ } catch (e) {
872
+ warning(false, `<Link to="${to}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`);
873
+ }
874
+ return {
875
+ absoluteURL,
876
+ isExternal,
877
+ to
878
+ };
879
+ }
880
+ //#endregion
881
+ export { ErrorResponseImpl, RouterContextProvider, SUPPORTED_ERROR_TYPES, compilePath, convertRouteMatchToUiMatch, convertRoutesToDataRoutes, createContext, createDataFunctionUrl, data, decodePath, defaultMapRouteProperties, encodePathParam, flattenAndRankRoutes, generatePath, getPathContributingMatches, getResolveToMatches, getRoutePattern, isAbsoluteUrl, isBrowser, isRouteErrorResponse, isUnsupportedLazyRouteFunctionKey, isUnsupportedLazyRouteObjectKey, joinPaths, matchPath, matchRoutes, matchRoutesImpl, parseToInfo, prependBasename, redirect, redirectDocument, removeDoubleSlashes, removeTrailingSlash, replace, resolvePath, resolveTo, stripBasename };