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
@@ -1,1362 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
2
- * react-router v7.15.1
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
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
- var _chunkHUBUW7R3js = require('./chunk-HUBUW7R3.js');
55
-
56
- // lib/dom/dom.ts
57
- var defaultMethod = "get";
58
- var defaultEncType = "application/x-www-form-urlencoded";
59
- function isHtmlElement(object) {
60
- return typeof HTMLElement !== "undefined" && object instanceof HTMLElement;
61
- }
62
- function isButtonElement(object) {
63
- return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
64
- }
65
- function isFormElement(object) {
66
- return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
67
- }
68
- function isInputElement(object) {
69
- return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
70
- }
71
- function isModifiedEvent(event) {
72
- return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
73
- }
74
- function shouldProcessLinkClick(event, target) {
75
- return event.button === 0 && // Ignore everything but left clicks
76
- (!target || target === "_self") && // Let browser handle "target=_blank" etc.
77
- !isModifiedEvent(event);
78
- }
79
- function createSearchParams(init = "") {
80
- return new URLSearchParams(
81
- typeof init === "string" || Array.isArray(init) || init instanceof URLSearchParams ? init : Object.keys(init).reduce((memo, key) => {
82
- let value = init[key];
83
- return memo.concat(
84
- Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]]
85
- );
86
- }, [])
87
- );
88
- }
89
- function getSearchParamsForLocation(locationSearch, defaultSearchParams) {
90
- let searchParams = createSearchParams(locationSearch);
91
- if (defaultSearchParams) {
92
- defaultSearchParams.forEach((_, key) => {
93
- if (!searchParams.has(key)) {
94
- defaultSearchParams.getAll(key).forEach((value) => {
95
- searchParams.append(key, value);
96
- });
97
- }
98
- });
99
- }
100
- return searchParams;
101
- }
102
- var _formDataSupportsSubmitter = null;
103
- function isFormDataSubmitterSupported() {
104
- if (_formDataSupportsSubmitter === null) {
105
- try {
106
- new FormData(
107
- document.createElement("form"),
108
- // @ts-expect-error if FormData supports the submitter parameter, this will throw
109
- 0
110
- );
111
- _formDataSupportsSubmitter = false;
112
- } catch (e) {
113
- _formDataSupportsSubmitter = true;
114
- }
115
- }
116
- return _formDataSupportsSubmitter;
117
- }
118
- var supportedFormEncTypes = /* @__PURE__ */ new Set([
119
- "application/x-www-form-urlencoded",
120
- "multipart/form-data",
121
- "text/plain"
122
- ]);
123
- function getFormEncType(encType) {
124
- if (encType != null && !supportedFormEncTypes.has(encType)) {
125
- _chunkHUBUW7R3js.warning.call(void 0,
126
- false,
127
- `"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`
128
- );
129
- return null;
130
- }
131
- return encType;
132
- }
133
- function getFormSubmissionInfo(target, basename) {
134
- let method;
135
- let action;
136
- let encType;
137
- let formData;
138
- let body;
139
- if (isFormElement(target)) {
140
- let attr = target.getAttribute("action");
141
- action = attr ? _chunkHUBUW7R3js.stripBasename.call(void 0, attr, basename) : null;
142
- method = target.getAttribute("method") || defaultMethod;
143
- encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
144
- formData = new FormData(target);
145
- } else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
146
- let form = target.form;
147
- if (form == null) {
148
- throw new Error(
149
- `Cannot submit a <button> or <input type="submit"> without a <form>`
150
- );
151
- }
152
- let attr = target.getAttribute("formaction") || form.getAttribute("action");
153
- action = attr ? _chunkHUBUW7R3js.stripBasename.call(void 0, attr, basename) : null;
154
- method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
155
- encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
156
- formData = new FormData(form, target);
157
- if (!isFormDataSubmitterSupported()) {
158
- let { name, type, value } = target;
159
- if (type === "image") {
160
- let prefix = name ? `${name}.` : "";
161
- formData.append(`${prefix}x`, "0");
162
- formData.append(`${prefix}y`, "0");
163
- } else if (name) {
164
- formData.append(name, value);
165
- }
166
- }
167
- } else if (isHtmlElement(target)) {
168
- throw new Error(
169
- `Cannot submit element that is not <form>, <button>, or <input type="submit|image">`
170
- );
171
- } else {
172
- method = defaultMethod;
173
- action = null;
174
- encType = defaultEncType;
175
- body = target;
176
- }
177
- if (formData && encType === "text/plain") {
178
- body = formData;
179
- formData = void 0;
180
- }
181
- return { action, method: method.toLowerCase(), encType, formData, body };
182
- }
183
-
184
- // lib/dom/lib.tsx
185
- var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react);
186
- var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
187
- try {
188
- if (isBrowser) {
189
- window.__reactRouterVersion = // @ts-expect-error
190
- "7.15.1";
191
- }
192
- } catch (e) {
193
- }
194
- function createBrowserRouter(routes, opts) {
195
- return _chunkHUBUW7R3js.createRouter.call(void 0, {
196
- basename: _optionalChain([opts, 'optionalAccess', _2 => _2.basename]),
197
- getContext: _optionalChain([opts, 'optionalAccess', _3 => _3.getContext]),
198
- future: _optionalChain([opts, 'optionalAccess', _4 => _4.future]),
199
- history: _chunkHUBUW7R3js.createBrowserHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _5 => _5.window]) }),
200
- hydrationData: _optionalChain([opts, 'optionalAccess', _6 => _6.hydrationData]) || parseHydrationData(),
201
- routes,
202
- mapRouteProperties: _chunkHUBUW7R3js.mapRouteProperties,
203
- hydrationRouteProperties: _chunkHUBUW7R3js.hydrationRouteProperties,
204
- dataStrategy: _optionalChain([opts, 'optionalAccess', _7 => _7.dataStrategy]),
205
- patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _8 => _8.patchRoutesOnNavigation]),
206
- window: _optionalChain([opts, 'optionalAccess', _9 => _9.window]),
207
- instrumentations: _optionalChain([opts, 'optionalAccess', _10 => _10.instrumentations])
208
- }).initialize();
209
- }
210
- function createHashRouter(routes, opts) {
211
- return _chunkHUBUW7R3js.createRouter.call(void 0, {
212
- basename: _optionalChain([opts, 'optionalAccess', _11 => _11.basename]),
213
- getContext: _optionalChain([opts, 'optionalAccess', _12 => _12.getContext]),
214
- future: _optionalChain([opts, 'optionalAccess', _13 => _13.future]),
215
- history: _chunkHUBUW7R3js.createHashHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _14 => _14.window]) }),
216
- hydrationData: _optionalChain([opts, 'optionalAccess', _15 => _15.hydrationData]) || parseHydrationData(),
217
- routes,
218
- mapRouteProperties: _chunkHUBUW7R3js.mapRouteProperties,
219
- hydrationRouteProperties: _chunkHUBUW7R3js.hydrationRouteProperties,
220
- dataStrategy: _optionalChain([opts, 'optionalAccess', _16 => _16.dataStrategy]),
221
- patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _17 => _17.patchRoutesOnNavigation]),
222
- window: _optionalChain([opts, 'optionalAccess', _18 => _18.window]),
223
- instrumentations: _optionalChain([opts, 'optionalAccess', _19 => _19.instrumentations])
224
- }).initialize();
225
- }
226
- function parseHydrationData() {
227
- let state = _optionalChain([window, 'optionalAccess', _20 => _20.__staticRouterHydrationData]);
228
- if (state && state.errors) {
229
- state = {
230
- ...state,
231
- errors: deserializeErrors(state.errors)
232
- };
233
- }
234
- return state;
235
- }
236
- function deserializeErrors(errors) {
237
- if (!errors) return null;
238
- let entries = Object.entries(errors);
239
- let serialized = {};
240
- for (let [key, val] of entries) {
241
- if (val && val.__type === "RouteErrorResponse") {
242
- serialized[key] = new (0, _chunkHUBUW7R3js.ErrorResponseImpl)(
243
- val.status,
244
- val.statusText,
245
- val.data,
246
- val.internal === true
247
- );
248
- } else if (val && val.__type === "Error") {
249
- if (val.__subType) {
250
- let ErrorConstructor = window[val.__subType];
251
- if (typeof ErrorConstructor === "function") {
252
- try {
253
- let error = new ErrorConstructor(val.message);
254
- error.stack = "";
255
- serialized[key] = error;
256
- } catch (e) {
257
- }
258
- }
259
- }
260
- if (serialized[key] == null) {
261
- let error = new Error(val.message);
262
- error.stack = "";
263
- serialized[key] = error;
264
- }
265
- } else {
266
- serialized[key] = val;
267
- }
268
- }
269
- return serialized;
270
- }
271
- function BrowserRouter({
272
- basename,
273
- children,
274
- useTransitions,
275
- window: window2
276
- }) {
277
- let historyRef = React.useRef();
278
- if (historyRef.current == null) {
279
- historyRef.current = _chunkHUBUW7R3js.createBrowserHistory.call(void 0, { window: window2, v5Compat: true });
280
- }
281
- let history = historyRef.current;
282
- let [state, setStateImpl] = React.useState({
283
- action: history.action,
284
- location: history.location
285
- });
286
- let setState = React.useCallback(
287
- (newState) => {
288
- if (useTransitions === false) {
289
- setStateImpl(newState);
290
- } else {
291
- React.startTransition(() => setStateImpl(newState));
292
- }
293
- },
294
- [useTransitions]
295
- );
296
- React.useLayoutEffect(() => history.listen(setState), [history, setState]);
297
- return /* @__PURE__ */ React.createElement(
298
- _chunkHUBUW7R3js.Router,
299
- {
300
- basename,
301
- children,
302
- location: state.location,
303
- navigationType: state.action,
304
- navigator: history,
305
- useTransitions
306
- }
307
- );
308
- }
309
- function HashRouter({
310
- basename,
311
- children,
312
- useTransitions,
313
- window: window2
314
- }) {
315
- let historyRef = React.useRef();
316
- if (historyRef.current == null) {
317
- historyRef.current = _chunkHUBUW7R3js.createHashHistory.call(void 0, { window: window2, v5Compat: true });
318
- }
319
- let history = historyRef.current;
320
- let [state, setStateImpl] = React.useState({
321
- action: history.action,
322
- location: history.location
323
- });
324
- let setState = React.useCallback(
325
- (newState) => {
326
- if (useTransitions === false) {
327
- setStateImpl(newState);
328
- } else {
329
- React.startTransition(() => setStateImpl(newState));
330
- }
331
- },
332
- [useTransitions]
333
- );
334
- React.useLayoutEffect(() => history.listen(setState), [history, setState]);
335
- return /* @__PURE__ */ React.createElement(
336
- _chunkHUBUW7R3js.Router,
337
- {
338
- basename,
339
- children,
340
- location: state.location,
341
- navigationType: state.action,
342
- navigator: history,
343
- useTransitions
344
- }
345
- );
346
- }
347
- function HistoryRouter({
348
- basename,
349
- children,
350
- history,
351
- useTransitions
352
- }) {
353
- let [state, setStateImpl] = React.useState({
354
- action: history.action,
355
- location: history.location
356
- });
357
- let setState = React.useCallback(
358
- (newState) => {
359
- if (useTransitions === false) {
360
- setStateImpl(newState);
361
- } else {
362
- React.startTransition(() => setStateImpl(newState));
363
- }
364
- },
365
- [useTransitions]
366
- );
367
- React.useLayoutEffect(() => history.listen(setState), [history, setState]);
368
- return /* @__PURE__ */ React.createElement(
369
- _chunkHUBUW7R3js.Router,
370
- {
371
- basename,
372
- children,
373
- location: state.location,
374
- navigationType: state.action,
375
- navigator: history,
376
- useTransitions
377
- }
378
- );
379
- }
380
- HistoryRouter.displayName = "unstable_HistoryRouter";
381
- var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
382
- var Link = React.forwardRef(
383
- function LinkWithRef({
384
- onClick,
385
- discover = "render",
386
- prefetch = "none",
387
- relative,
388
- reloadDocument,
389
- replace,
390
- mask,
391
- state,
392
- target,
393
- to,
394
- preventScrollReset,
395
- viewTransition,
396
- defaultShouldRevalidate,
397
- ...rest
398
- }, forwardedRef) {
399
- let { basename, navigator, useTransitions } = React.useContext(_chunkHUBUW7R3js.NavigationContext);
400
- let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX.test(to);
401
- let parsed = _chunkHUBUW7R3js.parseToInfo.call(void 0, to, basename);
402
- to = parsed.to;
403
- let href = _chunkHUBUW7R3js.useHref.call(void 0, to, { relative });
404
- let location = _chunkHUBUW7R3js.useLocation.call(void 0, );
405
- let maskedHref = null;
406
- if (mask) {
407
- let resolved = _chunkHUBUW7R3js.resolveTo.call(void 0,
408
- mask,
409
- [],
410
- location.mask ? location.mask.pathname : "/",
411
- true
412
- );
413
- if (basename !== "/") {
414
- resolved.pathname = resolved.pathname === "/" ? basename : _chunkHUBUW7R3js.joinPaths.call(void 0, [basename, resolved.pathname]);
415
- }
416
- maskedHref = navigator.createHref(resolved);
417
- }
418
- let [shouldPrefetch, prefetchRef, prefetchHandlers] = _chunkHUBUW7R3js.usePrefetchBehavior.call(void 0,
419
- prefetch,
420
- rest
421
- );
422
- let internalOnClick = useLinkClickHandler(to, {
423
- replace,
424
- mask,
425
- state,
426
- target,
427
- preventScrollReset,
428
- relative,
429
- viewTransition,
430
- defaultShouldRevalidate,
431
- useTransitions
432
- });
433
- function handleClick(event) {
434
- if (onClick) onClick(event);
435
- if (!event.defaultPrevented) {
436
- internalOnClick(event);
437
- }
438
- }
439
- let isSpaLink = !(parsed.isExternal || reloadDocument);
440
- let link = (
441
- // eslint-disable-next-line jsx-a11y/anchor-has-content
442
- /* @__PURE__ */ React.createElement(
443
- "a",
444
- {
445
- ...rest,
446
- ...prefetchHandlers,
447
- href: (isSpaLink ? maskedHref : void 0) || parsed.absoluteURL || href,
448
- onClick: isSpaLink ? handleClick : onClick,
449
- ref: _chunkHUBUW7R3js.mergeRefs.call(void 0, forwardedRef, prefetchRef),
450
- target,
451
- "data-discover": !isAbsolute && discover === "render" ? "true" : void 0
452
- }
453
- )
454
- );
455
- return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React.createElement(React.Fragment, null, link, /* @__PURE__ */ React.createElement(_chunkHUBUW7R3js.PrefetchPageLinks, { page: href })) : link;
456
- }
457
- );
458
- Link.displayName = "Link";
459
- var NavLink = React.forwardRef(
460
- function NavLinkWithRef({
461
- "aria-current": ariaCurrentProp = "page",
462
- caseSensitive = false,
463
- className: classNameProp = "",
464
- end = false,
465
- style: styleProp,
466
- to,
467
- viewTransition,
468
- children,
469
- ...rest
470
- }, ref) {
471
- let path = _chunkHUBUW7R3js.useResolvedPath.call(void 0, to, { relative: rest.relative });
472
- let location = _chunkHUBUW7R3js.useLocation.call(void 0, );
473
- let routerState = React.useContext(_chunkHUBUW7R3js.DataRouterStateContext);
474
- let { navigator, basename } = React.useContext(_chunkHUBUW7R3js.NavigationContext);
475
- let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
476
- // eslint-disable-next-line react-hooks/rules-of-hooks
477
- useViewTransitionState(path) && viewTransition === true;
478
- let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
479
- let locationPathname = location.pathname;
480
- let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
481
- if (!caseSensitive) {
482
- locationPathname = locationPathname.toLowerCase();
483
- nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
484
- toPathname = toPathname.toLowerCase();
485
- }
486
- if (nextLocationPathname && basename) {
487
- nextLocationPathname = _chunkHUBUW7R3js.stripBasename.call(void 0, nextLocationPathname, basename) || nextLocationPathname;
488
- }
489
- const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
490
- let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
491
- let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
492
- let renderProps = {
493
- isActive,
494
- isPending,
495
- isTransitioning
496
- };
497
- let ariaCurrent = isActive ? ariaCurrentProp : void 0;
498
- let className;
499
- if (typeof classNameProp === "function") {
500
- className = classNameProp(renderProps);
501
- } else {
502
- className = [
503
- classNameProp,
504
- isActive ? "active" : null,
505
- isPending ? "pending" : null,
506
- isTransitioning ? "transitioning" : null
507
- ].filter(Boolean).join(" ");
508
- }
509
- let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
510
- return /* @__PURE__ */ React.createElement(
511
- Link,
512
- {
513
- ...rest,
514
- "aria-current": ariaCurrent,
515
- className,
516
- ref,
517
- style,
518
- to,
519
- viewTransition
520
- },
521
- typeof children === "function" ? children(renderProps) : children
522
- );
523
- }
524
- );
525
- NavLink.displayName = "NavLink";
526
- var Form = React.forwardRef(
527
- ({
528
- discover = "render",
529
- fetcherKey,
530
- navigate,
531
- reloadDocument,
532
- replace,
533
- state,
534
- method = defaultMethod,
535
- action,
536
- onSubmit,
537
- relative,
538
- preventScrollReset,
539
- viewTransition,
540
- defaultShouldRevalidate,
541
- ...props
542
- }, forwardedRef) => {
543
- let { useTransitions } = React.useContext(_chunkHUBUW7R3js.NavigationContext);
544
- let submit = useSubmit();
545
- let formAction = useFormAction(action, { relative });
546
- let formMethod = method.toLowerCase() === "get" ? "get" : "post";
547
- let isAbsolute = typeof action === "string" && ABSOLUTE_URL_REGEX.test(action);
548
- let submitHandler = (event) => {
549
- onSubmit && onSubmit(event);
550
- if (event.defaultPrevented) return;
551
- event.preventDefault();
552
- let submitter = event.nativeEvent.submitter;
553
- let submitMethod = _optionalChain([submitter, 'optionalAccess', _21 => _21.getAttribute, 'call', _22 => _22("formmethod")]) || method;
554
- let doSubmit = () => submit(submitter || event.currentTarget, {
555
- fetcherKey,
556
- method: submitMethod,
557
- navigate,
558
- replace,
559
- state,
560
- relative,
561
- preventScrollReset,
562
- viewTransition,
563
- defaultShouldRevalidate
564
- });
565
- if (useTransitions && navigate !== false) {
566
- React.startTransition(() => doSubmit());
567
- } else {
568
- doSubmit();
569
- }
570
- };
571
- return /* @__PURE__ */ React.createElement(
572
- "form",
573
- {
574
- ref: forwardedRef,
575
- method: formMethod,
576
- action: formAction,
577
- onSubmit: reloadDocument ? onSubmit : submitHandler,
578
- ...props,
579
- "data-discover": !isAbsolute && discover === "render" ? "true" : void 0
580
- }
581
- );
582
- }
583
- );
584
- Form.displayName = "Form";
585
- function ScrollRestoration({
586
- getKey,
587
- storageKey,
588
- ...props
589
- }) {
590
- let remixContext = React.useContext(_chunkHUBUW7R3js.FrameworkContext);
591
- let { basename } = React.useContext(_chunkHUBUW7R3js.NavigationContext);
592
- let location = _chunkHUBUW7R3js.useLocation.call(void 0, );
593
- let matches = _chunkHUBUW7R3js.useMatches.call(void 0, );
594
- useScrollRestoration({ getKey, storageKey });
595
- let ssrKey = React.useMemo(
596
- () => {
597
- if (!remixContext || !getKey) return null;
598
- let userKey = getScrollRestorationKey(
599
- location,
600
- matches,
601
- basename,
602
- getKey
603
- );
604
- return userKey !== location.key ? userKey : null;
605
- },
606
- // Nah, we only need this the first time for the SSR render
607
- // eslint-disable-next-line react-hooks/exhaustive-deps
608
- []
609
- );
610
- if (!remixContext || remixContext.isSpaMode) {
611
- return null;
612
- }
613
- let restoreScroll = ((storageKey2, restoreKey) => {
614
- if (!window.history.state || !window.history.state.key) {
615
- let key = Math.random().toString(32).slice(2);
616
- window.history.replaceState({ key }, "");
617
- }
618
- try {
619
- let positions = JSON.parse(sessionStorage.getItem(storageKey2) || "{}");
620
- let storedY = positions[restoreKey || window.history.state.key];
621
- if (typeof storedY === "number") {
622
- window.scrollTo(0, storedY);
623
- }
624
- } catch (error) {
625
- console.error(error);
626
- sessionStorage.removeItem(storageKey2);
627
- }
628
- }).toString();
629
- return /* @__PURE__ */ React.createElement(
630
- "script",
631
- {
632
- ...props,
633
- suppressHydrationWarning: true,
634
- dangerouslySetInnerHTML: {
635
- __html: `(${restoreScroll})(${_chunkHUBUW7R3js.escapeHtml.call(void 0,
636
- JSON.stringify(storageKey || SCROLL_RESTORATION_STORAGE_KEY)
637
- )}, ${_chunkHUBUW7R3js.escapeHtml.call(void 0, JSON.stringify(ssrKey))})`
638
- }
639
- }
640
- );
641
- }
642
- ScrollRestoration.displayName = "ScrollRestoration";
643
- function getDataRouterConsoleError(hookName) {
644
- return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
645
- }
646
- function useDataRouterContext(hookName) {
647
- let ctx = React.useContext(_chunkHUBUW7R3js.DataRouterContext);
648
- _chunkHUBUW7R3js.invariant.call(void 0, ctx, getDataRouterConsoleError(hookName));
649
- return ctx;
650
- }
651
- function useDataRouterState(hookName) {
652
- let state = React.useContext(_chunkHUBUW7R3js.DataRouterStateContext);
653
- _chunkHUBUW7R3js.invariant.call(void 0, state, getDataRouterConsoleError(hookName));
654
- return state;
655
- }
656
- function useLinkClickHandler(to, {
657
- target,
658
- replace: replaceProp,
659
- mask,
660
- state,
661
- preventScrollReset,
662
- relative,
663
- viewTransition,
664
- defaultShouldRevalidate,
665
- useTransitions
666
- } = {}) {
667
- let navigate = _chunkHUBUW7R3js.useNavigate.call(void 0, );
668
- let location = _chunkHUBUW7R3js.useLocation.call(void 0, );
669
- let path = _chunkHUBUW7R3js.useResolvedPath.call(void 0, to, { relative });
670
- return React.useCallback(
671
- (event) => {
672
- if (shouldProcessLinkClick(event, target)) {
673
- event.preventDefault();
674
- let replace = replaceProp !== void 0 ? replaceProp : _chunkHUBUW7R3js.createPath.call(void 0, location) === _chunkHUBUW7R3js.createPath.call(void 0, path);
675
- let doNavigate = () => navigate(to, {
676
- replace,
677
- mask,
678
- state,
679
- preventScrollReset,
680
- relative,
681
- viewTransition,
682
- defaultShouldRevalidate
683
- });
684
- if (useTransitions) {
685
- React.startTransition(() => doNavigate());
686
- } else {
687
- doNavigate();
688
- }
689
- }
690
- },
691
- [
692
- location,
693
- navigate,
694
- path,
695
- replaceProp,
696
- mask,
697
- state,
698
- target,
699
- to,
700
- preventScrollReset,
701
- relative,
702
- viewTransition,
703
- defaultShouldRevalidate,
704
- useTransitions
705
- ]
706
- );
707
- }
708
- function useSearchParams(defaultInit) {
709
- _chunkHUBUW7R3js.warning.call(void 0,
710
- typeof URLSearchParams !== "undefined",
711
- `You cannot use the \`useSearchParams\` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.`
712
- );
713
- let defaultSearchParamsRef = React.useRef(createSearchParams(defaultInit));
714
- let hasSetSearchParamsRef = React.useRef(false);
715
- let location = _chunkHUBUW7R3js.useLocation.call(void 0, );
716
- let searchParams = React.useMemo(
717
- () => (
718
- // Only merge in the defaults if we haven't yet called setSearchParams.
719
- // Once we call that we want those to take precedence, otherwise you can't
720
- // remove a param with setSearchParams({}) if it has an initial value
721
- getSearchParamsForLocation(
722
- location.search,
723
- hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current
724
- )
725
- ),
726
- [location.search]
727
- );
728
- let navigate = _chunkHUBUW7R3js.useNavigate.call(void 0, );
729
- let setSearchParams = React.useCallback(
730
- (nextInit, navigateOptions) => {
731
- const newSearchParams = createSearchParams(
732
- typeof nextInit === "function" ? nextInit(new URLSearchParams(searchParams)) : nextInit
733
- );
734
- hasSetSearchParamsRef.current = true;
735
- navigate("?" + newSearchParams, navigateOptions);
736
- },
737
- [navigate, searchParams]
738
- );
739
- return [searchParams, setSearchParams];
740
- }
741
- var fetcherId = 0;
742
- var getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
743
- function useSubmit() {
744
- let { router } = useDataRouterContext("useSubmit" /* UseSubmit */);
745
- let { basename } = React.useContext(_chunkHUBUW7R3js.NavigationContext);
746
- let currentRouteId = _chunkHUBUW7R3js.useRouteId.call(void 0, );
747
- let routerFetch = router.fetch;
748
- let routerNavigate = router.navigate;
749
- return React.useCallback(
750
- async (target, options = {}) => {
751
- let { action, method, encType, formData, body } = getFormSubmissionInfo(
752
- target,
753
- basename
754
- );
755
- if (options.navigate === false) {
756
- let key = options.fetcherKey || getUniqueFetcherId();
757
- await routerFetch(key, currentRouteId, options.action || action, {
758
- defaultShouldRevalidate: options.defaultShouldRevalidate,
759
- preventScrollReset: options.preventScrollReset,
760
- formData,
761
- body,
762
- formMethod: options.method || method,
763
- formEncType: options.encType || encType,
764
- flushSync: options.flushSync
765
- });
766
- } else {
767
- await routerNavigate(options.action || action, {
768
- defaultShouldRevalidate: options.defaultShouldRevalidate,
769
- preventScrollReset: options.preventScrollReset,
770
- formData,
771
- body,
772
- formMethod: options.method || method,
773
- formEncType: options.encType || encType,
774
- replace: options.replace,
775
- state: options.state,
776
- fromRouteId: currentRouteId,
777
- flushSync: options.flushSync,
778
- viewTransition: options.viewTransition
779
- });
780
- }
781
- },
782
- [routerFetch, routerNavigate, basename, currentRouteId]
783
- );
784
- }
785
- function useFormAction(action, { relative } = {}) {
786
- let { basename } = React.useContext(_chunkHUBUW7R3js.NavigationContext);
787
- let routeContext = React.useContext(_chunkHUBUW7R3js.RouteContext);
788
- _chunkHUBUW7R3js.invariant.call(void 0, routeContext, "useFormAction must be used inside a RouteContext");
789
- let [match] = routeContext.matches.slice(-1);
790
- let path = { ..._chunkHUBUW7R3js.useResolvedPath.call(void 0, action ? action : ".", { relative }) };
791
- let location = _chunkHUBUW7R3js.useLocation.call(void 0, );
792
- if (action == null) {
793
- path.search = location.search;
794
- let params = new URLSearchParams(path.search);
795
- let indexValues = params.getAll("index");
796
- let hasNakedIndexParam = indexValues.some((v) => v === "");
797
- if (hasNakedIndexParam) {
798
- params.delete("index");
799
- indexValues.filter((v) => v).forEach((v) => params.append("index", v));
800
- let qs = params.toString();
801
- path.search = qs ? `?${qs}` : "";
802
- }
803
- }
804
- if ((!action || action === ".") && match.route.index) {
805
- path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
806
- }
807
- if (basename !== "/") {
808
- path.pathname = path.pathname === "/" ? basename : _chunkHUBUW7R3js.joinPaths.call(void 0, [basename, path.pathname]);
809
- }
810
- return _chunkHUBUW7R3js.createPath.call(void 0, path);
811
- }
812
- function useFetcher({
813
- key
814
- } = {}) {
815
- let { router } = useDataRouterContext("useFetcher" /* UseFetcher */);
816
- let state = useDataRouterState("useFetcher" /* UseFetcher */);
817
- let fetcherData = React.useContext(_chunkHUBUW7R3js.FetchersContext);
818
- let route = React.useContext(_chunkHUBUW7R3js.RouteContext);
819
- let routeId = _optionalChain([route, 'access', _23 => _23.matches, 'access', _24 => _24[route.matches.length - 1], 'optionalAccess', _25 => _25.route, 'access', _26 => _26.id]);
820
- _chunkHUBUW7R3js.invariant.call(void 0, fetcherData, `useFetcher must be used inside a FetchersContext`);
821
- _chunkHUBUW7R3js.invariant.call(void 0, route, `useFetcher must be used inside a RouteContext`);
822
- _chunkHUBUW7R3js.invariant.call(void 0,
823
- routeId != null,
824
- `useFetcher can only be used on routes that contain a unique "id"`
825
- );
826
- let defaultKey = React.useId();
827
- let [fetcherKey, setFetcherKey] = React.useState(key || defaultKey);
828
- if (key && key !== fetcherKey) {
829
- setFetcherKey(key);
830
- }
831
- let { deleteFetcher, getFetcher, resetFetcher, fetch: routerFetch } = router;
832
- React.useEffect(() => {
833
- getFetcher(fetcherKey);
834
- return () => deleteFetcher(fetcherKey);
835
- }, [deleteFetcher, getFetcher, fetcherKey]);
836
- let load = React.useCallback(
837
- async (href, opts) => {
838
- _chunkHUBUW7R3js.invariant.call(void 0, routeId, "No routeId available for fetcher.load()");
839
- await routerFetch(fetcherKey, routeId, href, opts);
840
- },
841
- [fetcherKey, routeId, routerFetch]
842
- );
843
- let submitImpl = useSubmit();
844
- let submit = React.useCallback(
845
- async (target, opts) => {
846
- await submitImpl(target, {
847
- ...opts,
848
- navigate: false,
849
- fetcherKey
850
- });
851
- },
852
- [fetcherKey, submitImpl]
853
- );
854
- let reset = React.useCallback(
855
- (opts) => resetFetcher(fetcherKey, opts),
856
- [resetFetcher, fetcherKey]
857
- );
858
- let FetcherForm = React.useMemo(() => {
859
- let FetcherForm2 = React.forwardRef(
860
- (props, ref) => {
861
- return /* @__PURE__ */ React.createElement(Form, { ...props, navigate: false, fetcherKey, ref });
862
- }
863
- );
864
- FetcherForm2.displayName = "fetcher.Form";
865
- return FetcherForm2;
866
- }, [fetcherKey]);
867
- let fetcher = state.fetchers.get(fetcherKey) || _chunkHUBUW7R3js.IDLE_FETCHER;
868
- let data = fetcherData.get(fetcherKey);
869
- let fetcherWithComponents = React.useMemo(
870
- () => ({
871
- Form: FetcherForm,
872
- submit,
873
- load,
874
- reset,
875
- ...fetcher,
876
- data
877
- }),
878
- [FetcherForm, submit, load, reset, fetcher, data]
879
- );
880
- return fetcherWithComponents;
881
- }
882
- function useFetchers() {
883
- let state = useDataRouterState("useFetchers" /* UseFetchers */);
884
- return React.useMemo(
885
- () => Array.from(state.fetchers.entries()).map(([key, fetcher]) => ({
886
- ...fetcher,
887
- key
888
- })),
889
- [state.fetchers]
890
- );
891
- }
892
- var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
893
- var savedScrollPositions = {};
894
- function getScrollRestorationKey(location, matches, basename, getKey) {
895
- let key = null;
896
- if (getKey) {
897
- if (basename !== "/") {
898
- key = getKey(
899
- {
900
- ...location,
901
- pathname: _chunkHUBUW7R3js.stripBasename.call(void 0, location.pathname, basename) || location.pathname
902
- },
903
- matches
904
- );
905
- } else {
906
- key = getKey(location, matches);
907
- }
908
- }
909
- if (key == null) {
910
- key = location.key;
911
- }
912
- return key;
913
- }
914
- function useScrollRestoration({
915
- getKey,
916
- storageKey
917
- } = {}) {
918
- let { router } = useDataRouterContext("useScrollRestoration" /* UseScrollRestoration */);
919
- let { restoreScrollPosition, preventScrollReset } = useDataRouterState(
920
- "useScrollRestoration" /* UseScrollRestoration */
921
- );
922
- let { basename } = React.useContext(_chunkHUBUW7R3js.NavigationContext);
923
- let location = _chunkHUBUW7R3js.useLocation.call(void 0, );
924
- let matches = _chunkHUBUW7R3js.useMatches.call(void 0, );
925
- let navigation = _chunkHUBUW7R3js.useNavigation.call(void 0, );
926
- React.useEffect(() => {
927
- window.history.scrollRestoration = "manual";
928
- return () => {
929
- window.history.scrollRestoration = "auto";
930
- };
931
- }, []);
932
- usePageHide(
933
- React.useCallback(() => {
934
- if (navigation.state === "idle") {
935
- let key = getScrollRestorationKey(location, matches, basename, getKey);
936
- savedScrollPositions[key] = window.scrollY;
937
- }
938
- try {
939
- sessionStorage.setItem(
940
- storageKey || SCROLL_RESTORATION_STORAGE_KEY,
941
- JSON.stringify(savedScrollPositions)
942
- );
943
- } catch (error) {
944
- _chunkHUBUW7R3js.warning.call(void 0,
945
- false,
946
- `Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${error}).`
947
- );
948
- }
949
- window.history.scrollRestoration = "auto";
950
- }, [navigation.state, getKey, basename, location, matches, storageKey])
951
- );
952
- if (typeof document !== "undefined") {
953
- React.useLayoutEffect(() => {
954
- try {
955
- let sessionPositions = sessionStorage.getItem(
956
- storageKey || SCROLL_RESTORATION_STORAGE_KEY
957
- );
958
- if (sessionPositions) {
959
- savedScrollPositions = JSON.parse(sessionPositions);
960
- }
961
- } catch (e) {
962
- }
963
- }, [storageKey]);
964
- React.useLayoutEffect(() => {
965
- let disableScrollRestoration = _optionalChain([router, 'optionalAccess', _27 => _27.enableScrollRestoration, 'call', _28 => _28(
966
- savedScrollPositions,
967
- () => window.scrollY,
968
- getKey ? (location2, matches2) => getScrollRestorationKey(location2, matches2, basename, getKey) : void 0
969
- )]);
970
- return () => disableScrollRestoration && disableScrollRestoration();
971
- }, [router, basename, getKey]);
972
- React.useLayoutEffect(() => {
973
- if (restoreScrollPosition === false) {
974
- return;
975
- }
976
- if (typeof restoreScrollPosition === "number") {
977
- window.scrollTo(0, restoreScrollPosition);
978
- return;
979
- }
980
- try {
981
- if (location.hash) {
982
- let el = document.getElementById(
983
- decodeURIComponent(location.hash.slice(1))
984
- );
985
- if (el) {
986
- el.scrollIntoView();
987
- return;
988
- }
989
- }
990
- } catch (e2) {
991
- _chunkHUBUW7R3js.warning.call(void 0,
992
- false,
993
- `"${location.hash.slice(
994
- 1
995
- )}" is not a decodable element ID. The view will not scroll to it.`
996
- );
997
- }
998
- if (preventScrollReset === true) {
999
- return;
1000
- }
1001
- window.scrollTo(0, 0);
1002
- }, [location, restoreScrollPosition, preventScrollReset]);
1003
- }
1004
- }
1005
- function useBeforeUnload(callback, options) {
1006
- let { capture } = options || {};
1007
- React.useEffect(() => {
1008
- let opts = capture != null ? { capture } : void 0;
1009
- window.addEventListener("beforeunload", callback, opts);
1010
- return () => {
1011
- window.removeEventListener("beforeunload", callback, opts);
1012
- };
1013
- }, [callback, capture]);
1014
- }
1015
- function usePageHide(callback, options) {
1016
- let { capture } = options || {};
1017
- React.useEffect(() => {
1018
- let opts = capture != null ? { capture } : void 0;
1019
- window.addEventListener("pagehide", callback, opts);
1020
- return () => {
1021
- window.removeEventListener("pagehide", callback, opts);
1022
- };
1023
- }, [callback, capture]);
1024
- }
1025
- function usePrompt({
1026
- when,
1027
- message
1028
- }) {
1029
- let blocker = _chunkHUBUW7R3js.useBlocker.call(void 0, when);
1030
- React.useEffect(() => {
1031
- if (blocker.state === "blocked") {
1032
- let proceed = window.confirm(message);
1033
- if (proceed) {
1034
- setTimeout(blocker.proceed, 0);
1035
- } else {
1036
- blocker.reset();
1037
- }
1038
- }
1039
- }, [blocker, message]);
1040
- React.useEffect(() => {
1041
- if (blocker.state === "blocked" && !when) {
1042
- blocker.reset();
1043
- }
1044
- }, [blocker, when]);
1045
- }
1046
- function useViewTransitionState(to, { relative } = {}) {
1047
- let vtContext = React.useContext(_chunkHUBUW7R3js.ViewTransitionContext);
1048
- _chunkHUBUW7R3js.invariant.call(void 0,
1049
- vtContext != null,
1050
- "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"
1051
- );
1052
- let { basename } = useDataRouterContext(
1053
- "useViewTransitionState" /* useViewTransitionState */
1054
- );
1055
- let path = _chunkHUBUW7R3js.useResolvedPath.call(void 0, to, { relative });
1056
- if (!vtContext.isTransitioning) {
1057
- return false;
1058
- }
1059
- let currentPath = _chunkHUBUW7R3js.stripBasename.call(void 0, vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
1060
- let nextPath = _chunkHUBUW7R3js.stripBasename.call(void 0, vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
1061
- return _chunkHUBUW7R3js.matchPath.call(void 0, path.pathname, nextPath) != null || _chunkHUBUW7R3js.matchPath.call(void 0, path.pathname, currentPath) != null;
1062
- }
1063
-
1064
- // lib/dom/server.tsx
1065
-
1066
- function StaticRouter({
1067
- basename,
1068
- children,
1069
- location: locationProp = "/"
1070
- }) {
1071
- if (typeof locationProp === "string") {
1072
- locationProp = _chunkHUBUW7R3js.parsePath.call(void 0, locationProp);
1073
- }
1074
- let action = "POP" /* Pop */;
1075
- let location = {
1076
- pathname: locationProp.pathname || "/",
1077
- search: locationProp.search || "",
1078
- hash: locationProp.hash || "",
1079
- state: locationProp.state != null ? locationProp.state : null,
1080
- key: locationProp.key || "default",
1081
- mask: void 0
1082
- };
1083
- let staticNavigator = getStatelessNavigator();
1084
- return /* @__PURE__ */ React2.createElement(
1085
- _chunkHUBUW7R3js.Router,
1086
- {
1087
- basename,
1088
- children,
1089
- location,
1090
- navigationType: action,
1091
- navigator: staticNavigator,
1092
- static: true,
1093
- useTransitions: false
1094
- }
1095
- );
1096
- }
1097
- function StaticRouterProvider({
1098
- context,
1099
- router,
1100
- hydrate = true,
1101
- nonce
1102
- }) {
1103
- _chunkHUBUW7R3js.invariant.call(void 0,
1104
- router && context,
1105
- "You must provide `router` and `context` to <StaticRouterProvider>"
1106
- );
1107
- let dataRouterContext = {
1108
- router,
1109
- navigator: getStatelessNavigator(),
1110
- static: true,
1111
- staticContext: context,
1112
- basename: context.basename || "/"
1113
- };
1114
- let fetchersContext = /* @__PURE__ */ new Map();
1115
- let hydrateScript = "";
1116
- if (hydrate !== false) {
1117
- let data = {
1118
- loaderData: context.loaderData,
1119
- actionData: context.actionData,
1120
- errors: serializeErrors(context.errors)
1121
- };
1122
- let json = _chunkHUBUW7R3js.escapeHtml.call(void 0, JSON.stringify(JSON.stringify(data)));
1123
- hydrateScript = `window.__staticRouterHydrationData = JSON.parse(${json});`;
1124
- }
1125
- let { state } = dataRouterContext.router;
1126
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(_chunkHUBUW7R3js.DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React2.createElement(_chunkHUBUW7R3js.DataRouterStateContext.Provider, { value: state }, /* @__PURE__ */ React2.createElement(_chunkHUBUW7R3js.FetchersContext.Provider, { value: fetchersContext }, /* @__PURE__ */ React2.createElement(_chunkHUBUW7R3js.ViewTransitionContext.Provider, { value: { isTransitioning: false } }, /* @__PURE__ */ React2.createElement(
1127
- _chunkHUBUW7R3js.Router,
1128
- {
1129
- basename: dataRouterContext.basename,
1130
- location: state.location,
1131
- navigationType: state.historyAction,
1132
- navigator: dataRouterContext.navigator,
1133
- static: dataRouterContext.static,
1134
- useTransitions: false
1135
- },
1136
- /* @__PURE__ */ React2.createElement(
1137
- _chunkHUBUW7R3js.DataRoutes,
1138
- {
1139
- manifest: router.manifest,
1140
- routes: router.routes,
1141
- future: router.future,
1142
- state,
1143
- isStatic: true
1144
- }
1145
- )
1146
- ))))), hydrateScript ? /* @__PURE__ */ React2.createElement(
1147
- "script",
1148
- {
1149
- suppressHydrationWarning: true,
1150
- nonce,
1151
- dangerouslySetInnerHTML: { __html: hydrateScript }
1152
- }
1153
- ) : null);
1154
- }
1155
- function serializeErrors(errors) {
1156
- if (!errors) return null;
1157
- let entries = Object.entries(errors);
1158
- let serialized = {};
1159
- for (let [key, val] of entries) {
1160
- if (_chunkHUBUW7R3js.isRouteErrorResponse.call(void 0, val)) {
1161
- serialized[key] = { ...val, __type: "RouteErrorResponse" };
1162
- } else if (val instanceof Error) {
1163
- serialized[key] = {
1164
- message: val.message,
1165
- __type: "Error",
1166
- // If this is a subclass (i.e., ReferenceError), send up the type so we
1167
- // can re-create the same type during hydration.
1168
- ...val.name !== "Error" ? {
1169
- __subType: val.name
1170
- } : {}
1171
- };
1172
- } else {
1173
- serialized[key] = val;
1174
- }
1175
- }
1176
- return serialized;
1177
- }
1178
- function getStatelessNavigator() {
1179
- return {
1180
- createHref,
1181
- encodeLocation,
1182
- push(to) {
1183
- throw new Error(
1184
- `You cannot use navigator.push() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${JSON.stringify(to)})\` somewhere in your app.`
1185
- );
1186
- },
1187
- replace(to) {
1188
- throw new Error(
1189
- `You cannot use navigator.replace() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${JSON.stringify(to)}, { replace: true })\` somewhere in your app.`
1190
- );
1191
- },
1192
- go(delta) {
1193
- throw new Error(
1194
- `You cannot use navigator.go() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${delta})\` somewhere in your app.`
1195
- );
1196
- },
1197
- back() {
1198
- throw new Error(
1199
- `You cannot use navigator.back() on the server because it is a stateless environment.`
1200
- );
1201
- },
1202
- forward() {
1203
- throw new Error(
1204
- `You cannot use navigator.forward() on the server because it is a stateless environment.`
1205
- );
1206
- }
1207
- };
1208
- }
1209
- function createStaticHandler2(routes, opts) {
1210
- return _chunkHUBUW7R3js.createStaticHandler.call(void 0, routes, {
1211
- ...opts,
1212
- mapRouteProperties: _chunkHUBUW7R3js.mapRouteProperties
1213
- });
1214
- }
1215
- function createStaticRouter(routes, context, opts = {}) {
1216
- let manifest = {};
1217
- let dataRoutes = _chunkHUBUW7R3js.convertRoutesToDataRoutes.call(void 0,
1218
- routes,
1219
- _chunkHUBUW7R3js.mapRouteProperties,
1220
- void 0,
1221
- manifest
1222
- );
1223
- let matches = context.matches.map((match) => {
1224
- let route = manifest[match.route.id] || match.route;
1225
- return {
1226
- ...match,
1227
- route
1228
- };
1229
- });
1230
- let msg = (method) => `You cannot use router.${method}() on the server because it is a stateless environment`;
1231
- return {
1232
- get basename() {
1233
- return context.basename;
1234
- },
1235
- get future() {
1236
- return {
1237
- v8_middleware: false,
1238
- v8_passThroughRequests: false,
1239
- ..._optionalChain([opts, 'optionalAccess', _29 => _29.future])
1240
- };
1241
- },
1242
- get state() {
1243
- return {
1244
- historyAction: "POP" /* Pop */,
1245
- location: context.location,
1246
- matches,
1247
- loaderData: context.loaderData,
1248
- actionData: context.actionData,
1249
- errors: context.errors,
1250
- initialized: true,
1251
- renderFallback: false,
1252
- navigation: _chunkHUBUW7R3js.IDLE_NAVIGATION,
1253
- restoreScrollPosition: null,
1254
- preventScrollReset: false,
1255
- revalidation: "idle",
1256
- fetchers: /* @__PURE__ */ new Map(),
1257
- blockers: /* @__PURE__ */ new Map()
1258
- };
1259
- },
1260
- get routes() {
1261
- return dataRoutes;
1262
- },
1263
- get branches() {
1264
- return opts.branches;
1265
- },
1266
- get manifest() {
1267
- return manifest;
1268
- },
1269
- get window() {
1270
- return void 0;
1271
- },
1272
- initialize() {
1273
- throw msg("initialize");
1274
- },
1275
- subscribe() {
1276
- throw msg("subscribe");
1277
- },
1278
- enableScrollRestoration() {
1279
- throw msg("enableScrollRestoration");
1280
- },
1281
- navigate() {
1282
- throw msg("navigate");
1283
- },
1284
- fetch() {
1285
- throw msg("fetch");
1286
- },
1287
- revalidate() {
1288
- throw msg("revalidate");
1289
- },
1290
- createHref,
1291
- encodeLocation,
1292
- getFetcher() {
1293
- return _chunkHUBUW7R3js.IDLE_FETCHER;
1294
- },
1295
- deleteFetcher() {
1296
- throw msg("deleteFetcher");
1297
- },
1298
- resetFetcher() {
1299
- throw msg("resetFetcher");
1300
- },
1301
- dispose() {
1302
- throw msg("dispose");
1303
- },
1304
- getBlocker() {
1305
- return _chunkHUBUW7R3js.IDLE_BLOCKER;
1306
- },
1307
- deleteBlocker() {
1308
- throw msg("deleteBlocker");
1309
- },
1310
- patchRoutes() {
1311
- throw msg("patchRoutes");
1312
- },
1313
- _internalFetchControllers: /* @__PURE__ */ new Map(),
1314
- _internalSetRoutes() {
1315
- throw msg("_internalSetRoutes");
1316
- },
1317
- _internalSetStateDoNotUseOrYouWillBreakYourApp() {
1318
- throw msg("_internalSetStateDoNotUseOrYouWillBreakYourApp");
1319
- }
1320
- };
1321
- }
1322
- function createHref(to) {
1323
- return typeof to === "string" ? to : _chunkHUBUW7R3js.createPath.call(void 0, to);
1324
- }
1325
- function encodeLocation(to) {
1326
- let href = typeof to === "string" ? to : _chunkHUBUW7R3js.createPath.call(void 0, to);
1327
- href = href.replace(/ $/, "%20");
1328
- let encoded = ABSOLUTE_URL_REGEX2.test(href) ? new URL(href) : new URL(href, "http://localhost");
1329
- return {
1330
- pathname: encoded.pathname,
1331
- search: encoded.search,
1332
- hash: encoded.hash
1333
- };
1334
- }
1335
- var ABSOLUTE_URL_REGEX2 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
1336
-
1337
-
1338
-
1339
-
1340
-
1341
-
1342
-
1343
-
1344
-
1345
-
1346
-
1347
-
1348
-
1349
-
1350
-
1351
-
1352
-
1353
-
1354
-
1355
-
1356
-
1357
-
1358
-
1359
-
1360
-
1361
-
1362
- exports.createSearchParams = createSearchParams; exports.createBrowserRouter = createBrowserRouter; exports.createHashRouter = createHashRouter; exports.BrowserRouter = BrowserRouter; exports.HashRouter = HashRouter; exports.HistoryRouter = HistoryRouter; exports.Link = Link; exports.NavLink = NavLink; exports.Form = Form; exports.ScrollRestoration = ScrollRestoration; exports.useLinkClickHandler = useLinkClickHandler; exports.useSearchParams = useSearchParams; exports.useSubmit = useSubmit; exports.useFormAction = useFormAction; exports.useFetcher = useFetcher; exports.useFetchers = useFetchers; exports.useScrollRestoration = useScrollRestoration; exports.useBeforeUnload = useBeforeUnload; exports.usePrompt = usePrompt; exports.useViewTransitionState = useViewTransitionState; exports.StaticRouter = StaticRouter; exports.StaticRouterProvider = StaticRouterProvider; exports.createStaticHandler = createStaticHandler2; exports.createStaticRouter = createStaticRouter;