react-router 7.16.0 → 8.0.0-pre.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (369) hide show
  1. package/CHANGELOG.md +0 -1
  2. package/dist/development/dom-export.d.ts +6 -172
  3. package/dist/development/dom-export.js +12 -1007
  4. package/dist/development/index-react-server-client.d.ts +7 -4
  5. package/dist/development/index-react-server-client.js +8 -52
  6. package/dist/development/index-react-server.d.ts +1645 -1635
  7. package/dist/development/index-react-server.js +2880 -3642
  8. package/dist/development/index.d.ts +43 -1475
  9. package/dist/development/index.js +37 -2621
  10. package/dist/development/lib/actions.js +62 -0
  11. package/dist/development/lib/components.d.ts +1022 -0
  12. package/dist/development/lib/components.js +835 -0
  13. package/dist/development/lib/context.d.ts +83 -0
  14. package/dist/development/lib/context.js +41 -0
  15. package/dist/development/lib/dom/dom.d.ts +119 -0
  16. package/dist/development/lib/dom/dom.js +143 -0
  17. package/dist/development/lib/dom/lib.d.ts +2042 -0
  18. package/dist/development/lib/dom/lib.js +1259 -0
  19. package/dist/development/lib/dom/server.d.ts +138 -0
  20. package/dist/development/lib/dom/server.js +301 -0
  21. package/dist/development/lib/dom/ssr/components.d.ts +196 -0
  22. package/dist/development/lib/dom/ssr/components.js +579 -0
  23. package/dist/development/lib/dom/ssr/data.js +29 -0
  24. package/dist/development/lib/dom/ssr/entry.d.ts +59 -0
  25. package/dist/development/lib/dom/ssr/errorBoundaries.d.ts +27 -0
  26. package/dist/development/lib/dom/ssr/errorBoundaries.js +83 -0
  27. package/dist/development/lib/dom/ssr/errors.d.ts +7 -0
  28. package/dist/development/lib/dom/ssr/errors.js +36 -0
  29. package/dist/development/lib/dom/ssr/fallback.js +28 -0
  30. package/dist/development/lib/dom/ssr/fog-of-war.d.ts +12 -0
  31. package/dist/development/lib/dom/ssr/fog-of-war.js +170 -0
  32. package/dist/development/lib/dom/ssr/hydration.d.ts +32 -0
  33. package/dist/development/lib/dom/ssr/hydration.js +29 -0
  34. package/dist/development/lib/dom/ssr/invariant.js +16 -0
  35. package/dist/development/lib/dom/ssr/links.js +170 -0
  36. package/dist/development/lib/dom/ssr/markup.js +24 -0
  37. package/dist/development/lib/dom/ssr/routeModules.d.ts +206 -0
  38. package/dist/development/lib/dom/ssr/routeModules.js +31 -0
  39. package/dist/development/lib/dom/ssr/routes-test-stub.d.ts +62 -0
  40. package/dist/development/lib/dom/ssr/routes-test-stub.js +108 -0
  41. package/dist/development/lib/dom/ssr/routes.d.ts +33 -0
  42. package/dist/development/lib/dom/ssr/routes.js +303 -0
  43. package/dist/development/lib/dom/ssr/server.d.ts +45 -0
  44. package/dist/development/lib/dom/ssr/server.js +68 -0
  45. package/dist/development/lib/dom/ssr/single-fetch.d.ts +14 -0
  46. package/dist/development/lib/dom/ssr/single-fetch.js +346 -0
  47. package/dist/development/lib/dom-export/dom-router-provider.d.ts +9 -0
  48. package/dist/development/lib/dom-export/dom-router-provider.js +22 -0
  49. package/dist/development/lib/dom-export/hydrated-router.d.ts +125 -0
  50. package/dist/development/lib/dom-export/hydrated-router.js +153 -0
  51. package/dist/development/lib/errors.js +29 -0
  52. package/dist/development/lib/hooks.d.ts +947 -0
  53. package/dist/development/lib/hooks.js +1386 -0
  54. package/dist/development/lib/href.d.ts +20 -0
  55. package/dist/development/lib/href.js +50 -0
  56. package/dist/development/lib/router/history.d.ts +258 -0
  57. package/dist/development/lib/router/history.js +371 -0
  58. package/dist/development/lib/router/instrumentation.d.ts +86 -0
  59. package/dist/development/lib/router/instrumentation.js +213 -0
  60. package/dist/development/lib/router/links.d.ts +113 -0
  61. package/dist/development/lib/router/router.d.ts +663 -0
  62. package/dist/development/lib/router/router.js +2981 -0
  63. package/dist/development/lib/router/utils.d.ts +942 -0
  64. package/dist/development/lib/router/utils.js +791 -0
  65. package/dist/development/lib/rsc/browser.d.ts +137 -0
  66. package/dist/development/lib/rsc/browser.js +599 -0
  67. package/dist/development/lib/rsc/errorBoundaries.d.ts +11 -0
  68. package/dist/development/lib/rsc/errorBoundaries.js +90 -0
  69. package/dist/development/lib/rsc/html-stream/browser.d.ts +48 -0
  70. package/dist/development/lib/rsc/html-stream/browser.js +74 -0
  71. package/dist/development/lib/rsc/html-stream/server.js +78 -0
  72. package/dist/development/lib/rsc/route-modules.js +27 -0
  73. package/dist/development/lib/rsc/server.rsc.d.ts +219 -0
  74. package/dist/development/lib/rsc/server.ssr.d.ts +129 -0
  75. package/dist/development/lib/rsc/server.ssr.js +388 -0
  76. package/dist/development/lib/server-runtime/build.d.ts +66 -0
  77. package/dist/development/lib/server-runtime/cookies.d.ts +66 -0
  78. package/dist/development/lib/server-runtime/cookies.js +139 -0
  79. package/dist/development/lib/server-runtime/crypto.js +43 -0
  80. package/dist/development/lib/server-runtime/data.d.ts +13 -0
  81. package/dist/development/lib/server-runtime/data.js +25 -0
  82. package/dist/development/lib/server-runtime/dev.d.ts +9 -0
  83. package/dist/development/lib/server-runtime/dev.js +26 -0
  84. package/dist/development/lib/server-runtime/entry.js +20 -0
  85. package/dist/development/lib/server-runtime/errors.js +95 -0
  86. package/dist/development/lib/server-runtime/headers.js +73 -0
  87. package/dist/development/lib/server-runtime/invariant.js +19 -0
  88. package/dist/development/lib/server-runtime/mode.d.ts +12 -0
  89. package/dist/development/lib/server-runtime/mode.js +25 -0
  90. package/dist/development/lib/server-runtime/routeMatching.js +28 -0
  91. package/dist/development/lib/server-runtime/routes.d.ts +13 -0
  92. package/dist/development/lib/server-runtime/routes.js +74 -0
  93. package/dist/development/lib/server-runtime/server.d.ts +10 -0
  94. package/dist/development/lib/server-runtime/server.js +351 -0
  95. package/dist/development/lib/server-runtime/serverHandoff.js +17 -0
  96. package/dist/development/lib/server-runtime/sessions/cookieStorage.d.ts +25 -0
  97. package/dist/development/lib/server-runtime/sessions/cookieStorage.js +45 -0
  98. package/dist/development/lib/server-runtime/sessions/memoryStorage.d.ts +23 -0
  99. package/dist/development/lib/server-runtime/sessions/memoryStorage.js +52 -0
  100. package/dist/development/lib/server-runtime/sessions.d.ts +145 -0
  101. package/dist/development/lib/server-runtime/sessions.js +98 -0
  102. package/dist/development/lib/server-runtime/single-fetch.d.ts +7 -0
  103. package/dist/development/lib/server-runtime/single-fetch.js +215 -0
  104. package/dist/development/lib/server-runtime/urls.js +31 -0
  105. package/dist/development/lib/server-runtime/warnings.js +20 -0
  106. package/dist/development/lib/types/future.d.ts +9 -0
  107. package/dist/development/lib/types/internal.d.ts +26 -177
  108. package/dist/development/lib/types/internal.js +3 -2
  109. package/dist/{production/register-CNAx3TXj.d.ts → development/lib/types/register.d.ts} +9 -15
  110. package/dist/development/lib/types/route-data.d.ts +113 -0
  111. package/dist/development/lib/types/route-module-annotations.d.ts +149 -0
  112. package/dist/development/lib/types/route-module.d.ts +19 -0
  113. package/dist/development/lib/types/serializes-to.d.ts +13 -0
  114. package/dist/development/lib/types/utils.d.ts +11 -0
  115. package/dist/development/vendor/turbo-stream-v2/flatten.js +159 -0
  116. package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +178 -0
  117. package/dist/development/vendor/turbo-stream-v2/unflatten.js +198 -0
  118. package/dist/development/vendor/turbo-stream-v2/utils.js +47 -0
  119. package/dist/production/dom-export.d.ts +6 -172
  120. package/dist/production/dom-export.js +12 -1007
  121. package/dist/production/index-react-server-client.d.ts +7 -4
  122. package/dist/production/index-react-server-client.js +8 -52
  123. package/dist/production/index-react-server.d.ts +1645 -1635
  124. package/dist/production/index-react-server.js +2871 -3642
  125. package/dist/production/index.d.ts +43 -1475
  126. package/dist/production/index.js +37 -2621
  127. package/dist/production/lib/actions.js +62 -0
  128. package/dist/production/lib/components.d.ts +1022 -0
  129. package/dist/production/lib/components.js +835 -0
  130. package/dist/production/lib/context.d.ts +83 -0
  131. package/dist/production/lib/context.js +41 -0
  132. package/dist/production/lib/dom/dom.d.ts +119 -0
  133. package/dist/production/lib/dom/dom.js +143 -0
  134. package/dist/production/lib/dom/lib.d.ts +2042 -0
  135. package/dist/production/lib/dom/lib.js +1259 -0
  136. package/dist/production/lib/dom/server.d.ts +138 -0
  137. package/dist/production/lib/dom/server.js +301 -0
  138. package/dist/production/lib/dom/ssr/components.d.ts +196 -0
  139. package/dist/production/lib/dom/ssr/components.js +579 -0
  140. package/dist/production/lib/dom/ssr/data.js +29 -0
  141. package/dist/production/lib/dom/ssr/entry.d.ts +59 -0
  142. package/dist/production/lib/dom/ssr/errorBoundaries.d.ts +27 -0
  143. package/dist/production/lib/dom/ssr/errorBoundaries.js +83 -0
  144. package/dist/production/lib/dom/ssr/errors.d.ts +7 -0
  145. package/dist/production/lib/dom/ssr/errors.js +36 -0
  146. package/dist/production/lib/dom/ssr/fallback.js +21 -0
  147. package/dist/production/lib/dom/ssr/fog-of-war.d.ts +12 -0
  148. package/dist/production/lib/dom/ssr/fog-of-war.js +170 -0
  149. package/dist/production/lib/dom/ssr/hydration.d.ts +32 -0
  150. package/dist/production/lib/dom/ssr/hydration.js +29 -0
  151. package/dist/production/lib/dom/ssr/invariant.js +16 -0
  152. package/dist/production/lib/dom/ssr/links.js +170 -0
  153. package/dist/production/lib/dom/ssr/markup.js +24 -0
  154. package/dist/production/lib/dom/ssr/routeModules.d.ts +206 -0
  155. package/dist/production/lib/dom/ssr/routeModules.js +31 -0
  156. package/dist/production/lib/dom/ssr/routes-test-stub.d.ts +62 -0
  157. package/dist/production/lib/dom/ssr/routes-test-stub.js +108 -0
  158. package/dist/production/lib/dom/ssr/routes.d.ts +33 -0
  159. package/dist/production/lib/dom/ssr/routes.js +303 -0
  160. package/dist/production/lib/dom/ssr/server.d.ts +45 -0
  161. package/dist/production/lib/dom/ssr/server.js +68 -0
  162. package/dist/production/lib/dom/ssr/single-fetch.d.ts +14 -0
  163. package/dist/production/lib/dom/ssr/single-fetch.js +346 -0
  164. package/dist/production/lib/dom-export/dom-router-provider.d.ts +9 -0
  165. package/dist/production/lib/dom-export/dom-router-provider.js +22 -0
  166. package/dist/production/lib/dom-export/hydrated-router.d.ts +125 -0
  167. package/dist/production/lib/dom-export/hydrated-router.js +153 -0
  168. package/dist/production/lib/errors.js +29 -0
  169. package/dist/production/lib/hooks.d.ts +947 -0
  170. package/dist/production/lib/hooks.js +1371 -0
  171. package/dist/production/lib/href.d.ts +20 -0
  172. package/dist/production/lib/href.js +50 -0
  173. package/dist/production/lib/router/history.d.ts +258 -0
  174. package/dist/production/lib/router/history.js +371 -0
  175. package/dist/production/lib/router/instrumentation.d.ts +86 -0
  176. package/dist/production/lib/router/instrumentation.js +213 -0
  177. package/dist/production/lib/router/links.d.ts +113 -0
  178. package/dist/production/lib/router/router.d.ts +663 -0
  179. package/dist/production/lib/router/router.js +2981 -0
  180. package/dist/production/lib/router/utils.d.ts +942 -0
  181. package/dist/production/lib/router/utils.js +782 -0
  182. package/dist/production/lib/rsc/browser.d.ts +137 -0
  183. package/dist/production/lib/rsc/browser.js +599 -0
  184. package/dist/production/lib/rsc/errorBoundaries.d.ts +11 -0
  185. package/dist/production/lib/rsc/errorBoundaries.js +90 -0
  186. package/dist/production/lib/rsc/html-stream/browser.d.ts +48 -0
  187. package/dist/production/lib/rsc/html-stream/browser.js +74 -0
  188. package/dist/production/lib/rsc/html-stream/server.js +78 -0
  189. package/dist/production/lib/rsc/route-modules.js +27 -0
  190. package/dist/production/lib/rsc/server.rsc.d.ts +219 -0
  191. package/dist/production/lib/rsc/server.ssr.d.ts +129 -0
  192. package/dist/production/lib/rsc/server.ssr.js +388 -0
  193. package/dist/production/lib/server-runtime/build.d.ts +66 -0
  194. package/dist/production/lib/server-runtime/cookies.d.ts +66 -0
  195. package/dist/production/lib/server-runtime/cookies.js +139 -0
  196. package/dist/production/lib/server-runtime/crypto.js +43 -0
  197. package/dist/production/lib/server-runtime/data.d.ts +13 -0
  198. package/dist/production/lib/server-runtime/data.js +25 -0
  199. package/dist/production/lib/server-runtime/dev.d.ts +9 -0
  200. package/dist/production/lib/server-runtime/dev.js +26 -0
  201. package/dist/production/lib/server-runtime/entry.js +20 -0
  202. package/dist/production/lib/server-runtime/errors.js +95 -0
  203. package/dist/production/lib/server-runtime/headers.js +73 -0
  204. package/dist/production/lib/server-runtime/invariant.js +19 -0
  205. package/dist/production/lib/server-runtime/mode.d.ts +12 -0
  206. package/dist/production/lib/server-runtime/mode.js +25 -0
  207. package/dist/production/lib/server-runtime/routeMatching.js +28 -0
  208. package/dist/production/lib/server-runtime/routes.d.ts +13 -0
  209. package/dist/production/lib/server-runtime/routes.js +74 -0
  210. package/dist/production/lib/server-runtime/server.d.ts +10 -0
  211. package/dist/production/lib/server-runtime/server.js +351 -0
  212. package/dist/production/lib/server-runtime/serverHandoff.js +17 -0
  213. package/dist/production/lib/server-runtime/sessions/cookieStorage.d.ts +25 -0
  214. package/dist/production/lib/server-runtime/sessions/cookieStorage.js +45 -0
  215. package/dist/production/lib/server-runtime/sessions/memoryStorage.d.ts +23 -0
  216. package/dist/production/lib/server-runtime/sessions/memoryStorage.js +52 -0
  217. package/dist/production/lib/server-runtime/sessions.d.ts +145 -0
  218. package/dist/production/lib/server-runtime/sessions.js +98 -0
  219. package/dist/production/lib/server-runtime/single-fetch.d.ts +7 -0
  220. package/dist/production/lib/server-runtime/single-fetch.js +215 -0
  221. package/dist/production/lib/server-runtime/urls.js +31 -0
  222. package/dist/production/lib/server-runtime/warnings.js +20 -0
  223. package/dist/production/lib/types/future.d.ts +9 -0
  224. package/dist/production/lib/types/internal.d.ts +26 -177
  225. package/dist/production/lib/types/internal.js +3 -2
  226. package/dist/{development/register-CNAx3TXj.d.ts → production/lib/types/register.d.ts} +9 -15
  227. package/dist/production/lib/types/route-data.d.ts +113 -0
  228. package/dist/production/lib/types/route-module-annotations.d.ts +149 -0
  229. package/dist/production/lib/types/route-module.d.ts +19 -0
  230. package/dist/production/lib/types/serializes-to.d.ts +13 -0
  231. package/dist/production/lib/types/utils.d.ts +11 -0
  232. package/dist/production/vendor/turbo-stream-v2/flatten.js +159 -0
  233. package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +178 -0
  234. package/dist/production/vendor/turbo-stream-v2/unflatten.js +198 -0
  235. package/dist/production/vendor/turbo-stream-v2/utils.js +47 -0
  236. package/docs/explanation/backend-for-frontend.md +50 -0
  237. package/docs/explanation/code-splitting.md +77 -0
  238. package/docs/explanation/concurrency.md +135 -0
  239. package/docs/explanation/form-vs-fetcher.md +292 -0
  240. package/docs/explanation/hot-module-replacement.md +137 -0
  241. package/docs/explanation/hydration.md +14 -0
  242. package/docs/explanation/index-query-param.md +86 -0
  243. package/docs/explanation/index.md +4 -0
  244. package/docs/explanation/lazy-route-discovery.md +78 -0
  245. package/docs/explanation/location.md +6 -0
  246. package/docs/explanation/progressive-enhancement.md +150 -0
  247. package/docs/explanation/race-conditions.md +88 -0
  248. package/docs/explanation/react-transitions.md +160 -0
  249. package/docs/explanation/route-matching.md +7 -0
  250. package/docs/explanation/server-client-execution.md +4 -0
  251. package/docs/explanation/sessions-and-cookies.md +465 -0
  252. package/docs/explanation/special-files.md +16 -0
  253. package/docs/explanation/state-management.md +524 -0
  254. package/docs/explanation/styling.md +87 -0
  255. package/docs/explanation/type-safety.md +82 -0
  256. package/docs/how-to/accessibility.md +44 -0
  257. package/docs/how-to/client-data.md +199 -0
  258. package/docs/how-to/data-strategy.md +317 -0
  259. package/docs/how-to/error-boundary.md +231 -0
  260. package/docs/how-to/error-reporting.md +134 -0
  261. package/docs/how-to/fetchers.md +307 -0
  262. package/docs/how-to/file-route-conventions.md +410 -0
  263. package/docs/how-to/file-uploads.md +217 -0
  264. package/docs/how-to/form-validation.md +120 -0
  265. package/docs/how-to/headers.md +164 -0
  266. package/docs/how-to/index.md +4 -0
  267. package/docs/how-to/instrumentation.md +556 -0
  268. package/docs/how-to/meta.md +40 -0
  269. package/docs/how-to/middleware.md +728 -0
  270. package/docs/how-to/navigation-blocking.md +233 -0
  271. package/docs/how-to/optimize-revalidation.md +12 -0
  272. package/docs/how-to/pre-rendering.md +225 -0
  273. package/docs/how-to/presets.md +103 -0
  274. package/docs/how-to/react-server-components.md +899 -0
  275. package/docs/how-to/resource-routes.md +126 -0
  276. package/docs/how-to/route-module-type-safety.md +100 -0
  277. package/docs/how-to/search-params.md +4 -0
  278. package/docs/how-to/security.md +30 -0
  279. package/docs/how-to/server-bundles.md +66 -0
  280. package/docs/how-to/spa.md +120 -0
  281. package/docs/how-to/status.md +63 -0
  282. package/docs/how-to/suspense.md +132 -0
  283. package/docs/how-to/using-handle.md +117 -0
  284. package/docs/how-to/view-transitions.md +237 -0
  285. package/docs/how-to/webhook.md +50 -0
  286. package/docs/index.md +39 -0
  287. package/docs/start/data/actions.md +138 -0
  288. package/docs/start/data/custom.md +198 -0
  289. package/docs/start/data/data-loading.md +44 -0
  290. package/docs/start/data/index.md +4 -0
  291. package/docs/start/data/installation.md +52 -0
  292. package/docs/start/data/navigating.md +12 -0
  293. package/docs/start/data/pending-ui.md +12 -0
  294. package/docs/start/data/route-object.md +248 -0
  295. package/docs/start/data/routing.md +281 -0
  296. package/docs/start/data/testing.md +8 -0
  297. package/docs/start/declarative/index.md +4 -0
  298. package/docs/start/declarative/installation.md +43 -0
  299. package/docs/start/declarative/navigating.md +133 -0
  300. package/docs/start/declarative/routing.md +237 -0
  301. package/docs/start/declarative/url-values.md +65 -0
  302. package/docs/start/framework/actions.md +175 -0
  303. package/docs/start/framework/data-loading.md +201 -0
  304. package/docs/start/framework/deploying.md +96 -0
  305. package/docs/start/framework/index.md +4 -0
  306. package/docs/start/framework/installation.md +42 -0
  307. package/docs/start/framework/navigating.md +182 -0
  308. package/docs/start/framework/pending-ui.md +142 -0
  309. package/docs/start/framework/rendering.md +59 -0
  310. package/docs/start/framework/route-module.md +527 -0
  311. package/docs/start/framework/routing.md +362 -0
  312. package/docs/start/framework/testing.md +133 -0
  313. package/docs/start/index.md +4 -0
  314. package/docs/start/modes.md +201 -0
  315. package/docs/upgrading/component-routes.md +363 -0
  316. package/docs/upgrading/future.md +31 -0
  317. package/docs/upgrading/index.md +4 -0
  318. package/docs/upgrading/remix.md +403 -0
  319. package/docs/upgrading/router-provider.md +442 -0
  320. package/docs/upgrading/v6.md +379 -0
  321. package/package.json +44 -87
  322. package/dist/development/browser-D3uq9sI1.d.ts +0 -318
  323. package/dist/development/browser-nIQ4Nsyi.d.mts +0 -318
  324. package/dist/development/chunk-IBI7OMNB.js +0 -1363
  325. package/dist/development/chunk-QUQL4437.mjs +0 -11529
  326. package/dist/development/chunk-S54KXAEJ.mjs +0 -2585
  327. package/dist/development/chunk-SRID2YZ2.js +0 -10229
  328. package/dist/development/chunk-XEJDWL2B.js +0 -188
  329. package/dist/development/context-m8rizgnE.d.mts +0 -1771
  330. package/dist/development/data-D4xhSy90.d.ts +0 -1732
  331. package/dist/development/data-U8FS-wNn.d.mts +0 -1732
  332. package/dist/development/dom-export.d.mts +0 -172
  333. package/dist/development/dom-export.mjs +0 -1008
  334. package/dist/development/index-react-server-client-BLiUx67a.d.ts +0 -3655
  335. package/dist/development/index-react-server-client-CdKROblb.d.mts +0 -2600
  336. package/dist/development/index-react-server-client.d.mts +0 -4
  337. package/dist/development/index-react-server-client.mjs +0 -59
  338. package/dist/development/index-react-server.d.mts +0 -2703
  339. package/dist/development/index-react-server.mjs +0 -3780
  340. package/dist/development/index.d.mts +0 -1478
  341. package/dist/development/index.mjs +0 -277
  342. package/dist/development/instrumentation-1q4YhLGP.d.ts +0 -715
  343. package/dist/development/lib/types/internal.d.mts +0 -184
  344. package/dist/development/lib/types/internal.mjs +0 -10
  345. package/dist/development/register-CqK96Zfk.d.mts +0 -30
  346. package/dist/production/browser-D3uq9sI1.d.ts +0 -318
  347. package/dist/production/browser-nIQ4Nsyi.d.mts +0 -318
  348. package/dist/production/chunk-EAQNHM3N.js +0 -188
  349. package/dist/production/chunk-NALGHHKE.mjs +0 -2585
  350. package/dist/production/chunk-Q65P7S7Y.mjs +0 -11529
  351. package/dist/production/chunk-SKEDDLRM.js +0 -1363
  352. package/dist/production/chunk-Y7DNFQZP.js +0 -10229
  353. package/dist/production/context-m8rizgnE.d.mts +0 -1771
  354. package/dist/production/data-D4xhSy90.d.ts +0 -1732
  355. package/dist/production/data-U8FS-wNn.d.mts +0 -1732
  356. package/dist/production/dom-export.d.mts +0 -172
  357. package/dist/production/dom-export.mjs +0 -1008
  358. package/dist/production/index-react-server-client-BLiUx67a.d.ts +0 -3655
  359. package/dist/production/index-react-server-client-CdKROblb.d.mts +0 -2600
  360. package/dist/production/index-react-server-client.d.mts +0 -4
  361. package/dist/production/index-react-server-client.mjs +0 -59
  362. package/dist/production/index-react-server.d.mts +0 -2703
  363. package/dist/production/index-react-server.mjs +0 -3780
  364. package/dist/production/index.d.mts +0 -1478
  365. package/dist/production/index.mjs +0 -277
  366. package/dist/production/instrumentation-1q4YhLGP.d.ts +0 -715
  367. package/dist/production/lib/types/internal.d.mts +0 -184
  368. package/dist/production/lib/types/internal.mjs +0 -10
  369. package/dist/production/register-CqK96Zfk.d.mts +0 -30
@@ -0,0 +1,346 @@
1
+ /**
2
+ * react-router v8.0.0-pre.0
3
+ *
4
+ * Copyright (c) Remix Software Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ import { ErrorResponseImpl, data, isRouteErrorResponse, redirect } from "../../router/utils.js";
12
+ import { isDataWithResponseInit, isResponse } from "../../router/router.js";
13
+ import invariant from "./invariant.js";
14
+ import { escapeHtml } from "./markup.js";
15
+ import { SUPPORTED_ERROR_TYPES } from "../../../vendor/turbo-stream-v2/utils.js";
16
+ import { decode } from "../../../vendor/turbo-stream-v2/turbo-stream.js";
17
+ import { createRequestInit } from "./data.js";
18
+ import * as React$1 from "react";
19
+ //#region lib/dom/ssr/single-fetch.tsx
20
+ const SingleFetchRedirectSymbol = Symbol("SingleFetchRedirect");
21
+ var SingleFetchNoResultError = class extends Error {};
22
+ const NO_BODY_STATUS_CODES = new Set([
23
+ 100,
24
+ 101,
25
+ 204,
26
+ 205
27
+ ]);
28
+ function StreamTransfer({ context, identifier, reader, textDecoder, nonce }) {
29
+ if (!context.renderMeta || !context.renderMeta.didRenderScripts) return null;
30
+ if (!context.renderMeta.streamCache) context.renderMeta.streamCache = {};
31
+ let { streamCache } = context.renderMeta;
32
+ let promise = streamCache[identifier];
33
+ if (!promise) promise = streamCache[identifier] = reader.read().then((result) => {
34
+ streamCache[identifier].result = {
35
+ done: result.done,
36
+ value: textDecoder.decode(result.value, { stream: true })
37
+ };
38
+ }).catch((e) => {
39
+ streamCache[identifier].error = e;
40
+ });
41
+ if (promise.error) throw promise.error;
42
+ if (promise.result === void 0) throw promise;
43
+ let { done, value } = promise.result;
44
+ let scriptTag = value ? /* @__PURE__ */ React$1.createElement("script", {
45
+ nonce,
46
+ dangerouslySetInnerHTML: { __html: `window.__reactRouterContext.streamController.enqueue(${escapeHtml(JSON.stringify(value))});` }
47
+ }) : null;
48
+ if (done) return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, scriptTag, /* @__PURE__ */ React$1.createElement("script", {
49
+ nonce,
50
+ dangerouslySetInnerHTML: { __html: `window.__reactRouterContext.streamController.close();` }
51
+ }));
52
+ else return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, scriptTag, /* @__PURE__ */ React$1.createElement(React$1.Suspense, null, /* @__PURE__ */ React$1.createElement(StreamTransfer, {
53
+ context,
54
+ identifier: identifier + 1,
55
+ reader,
56
+ textDecoder,
57
+ nonce
58
+ })));
59
+ }
60
+ function getTurboStreamSingleFetchDataStrategy(getRouter, manifest, routeModules, ssr) {
61
+ let dataStrategy = getSingleFetchDataStrategyImpl(getRouter, (match) => {
62
+ let manifestRoute = manifest.routes[match.route.id];
63
+ invariant(manifestRoute, "Route not found in manifest");
64
+ return {
65
+ hasLoader: manifestRoute.hasLoader,
66
+ hasClientLoader: manifestRoute.hasClientLoader
67
+ };
68
+ }, fetchAndDecodeViaTurboStream, ssr);
69
+ return async (args) => args.runClientMiddleware(dataStrategy);
70
+ }
71
+ function getSingleFetchDataStrategyImpl(getRouter, getRouteInfo, fetchAndDecode, ssr, shouldAllowOptOut = () => true) {
72
+ return async (args) => {
73
+ let { request, matches, fetcherKey } = args;
74
+ let router = getRouter();
75
+ if (request.method !== "GET") return singleFetchActionStrategy(args, fetchAndDecode);
76
+ let foundRevalidatingServerLoader = matches.some((m) => {
77
+ let { hasLoader, hasClientLoader } = getRouteInfo(m);
78
+ return m.shouldCallHandler() && hasLoader && !hasClientLoader;
79
+ });
80
+ if (!ssr && !foundRevalidatingServerLoader) return nonSsrStrategy(args, getRouteInfo, fetchAndDecode);
81
+ if (fetcherKey) return singleFetchLoaderFetcherStrategy(args, fetchAndDecode);
82
+ return singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, fetchAndDecode, ssr, shouldAllowOptOut);
83
+ };
84
+ }
85
+ async function singleFetchActionStrategy(args, fetchAndDecode) {
86
+ let actionMatch = args.matches.find((m) => m.shouldCallHandler());
87
+ invariant(actionMatch, "No action match found");
88
+ let actionStatus = void 0;
89
+ let result = await actionMatch.resolve(async (handler) => {
90
+ return await handler(async () => {
91
+ let { data, status } = await fetchAndDecode(args, [actionMatch.route.id]);
92
+ actionStatus = status;
93
+ return unwrapSingleFetchResult(data, actionMatch.route.id);
94
+ });
95
+ });
96
+ if (isResponse(result.result) || isRouteErrorResponse(result.result) || isDataWithResponseInit(result.result)) return { [actionMatch.route.id]: result };
97
+ return { [actionMatch.route.id]: {
98
+ type: result.type,
99
+ result: data(result.result, actionStatus)
100
+ } };
101
+ }
102
+ async function nonSsrStrategy(args, getRouteInfo, fetchAndDecode) {
103
+ let matchesToLoad = args.matches.filter((m) => m.shouldCallHandler());
104
+ let results = {};
105
+ await Promise.all(matchesToLoad.map((m) => m.resolve(async (handler) => {
106
+ try {
107
+ let { hasClientLoader } = getRouteInfo(m);
108
+ let routeId = m.route.id;
109
+ let result = hasClientLoader ? await handler(async () => {
110
+ let { data } = await fetchAndDecode(args, [routeId]);
111
+ return unwrapSingleFetchResult(data, routeId);
112
+ }) : await handler();
113
+ results[m.route.id] = {
114
+ type: "data",
115
+ result
116
+ };
117
+ } catch (e) {
118
+ results[m.route.id] = {
119
+ type: "error",
120
+ result: e
121
+ };
122
+ }
123
+ })));
124
+ return results;
125
+ }
126
+ async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, fetchAndDecode, ssr, shouldAllowOptOut = () => true) {
127
+ let routesParams = /* @__PURE__ */ new Set();
128
+ let foundOptOutRoute = false;
129
+ let routeDfds = args.matches.map(() => createDeferred());
130
+ let singleFetchDfd = createDeferred();
131
+ let results = {};
132
+ let resolvePromise = Promise.all(args.matches.map(async (m, i) => m.resolve(async (handler) => {
133
+ routeDfds[i].resolve();
134
+ let routeId = m.route.id;
135
+ let { hasLoader, hasClientLoader } = getRouteInfo(m);
136
+ let defaultShouldRevalidate = !m.shouldRevalidateArgs || m.shouldRevalidateArgs.actionStatus == null || m.shouldRevalidateArgs.actionStatus < 400;
137
+ if (!m.shouldCallHandler(defaultShouldRevalidate)) {
138
+ foundOptOutRoute ||= m.shouldRevalidateArgs != null && hasLoader;
139
+ return;
140
+ }
141
+ if (shouldAllowOptOut(m) && hasClientLoader) {
142
+ if (hasLoader) foundOptOutRoute = true;
143
+ try {
144
+ results[routeId] = {
145
+ type: "data",
146
+ result: await handler(async () => {
147
+ let { data } = await fetchAndDecode(args, [routeId]);
148
+ return unwrapSingleFetchResult(data, routeId);
149
+ })
150
+ };
151
+ } catch (e) {
152
+ results[routeId] = {
153
+ type: "error",
154
+ result: e
155
+ };
156
+ }
157
+ return;
158
+ }
159
+ if (hasLoader) routesParams.add(routeId);
160
+ try {
161
+ results[routeId] = {
162
+ type: "data",
163
+ result: await handler(async () => {
164
+ return unwrapSingleFetchResult(await singleFetchDfd.promise, routeId);
165
+ })
166
+ };
167
+ } catch (e) {
168
+ results[routeId] = {
169
+ type: "error",
170
+ result: e
171
+ };
172
+ }
173
+ })));
174
+ await Promise.all(routeDfds.map((d) => d.promise));
175
+ if ((!router.state.initialized && router.state.navigation.state === "idle" || routesParams.size === 0) && !window.__reactRouterHdrActive) singleFetchDfd.resolve({ routes: {} });
176
+ else {
177
+ let targetRoutes = ssr && foundOptOutRoute && routesParams.size > 0 ? [...routesParams.keys()] : void 0;
178
+ try {
179
+ let data = await fetchAndDecode(args, targetRoutes);
180
+ singleFetchDfd.resolve(data.data);
181
+ } catch (e) {
182
+ singleFetchDfd.reject(e);
183
+ }
184
+ }
185
+ await resolvePromise;
186
+ await bubbleMiddlewareErrors(singleFetchDfd.promise, args.matches, routesParams, results);
187
+ return results;
188
+ }
189
+ async function bubbleMiddlewareErrors(singleFetchPromise, matches, routesParams, results) {
190
+ try {
191
+ let middlewareError;
192
+ let fetchedData = await singleFetchPromise;
193
+ if ("routes" in fetchedData) {
194
+ for (let match of matches) if (match.route.id in fetchedData.routes) {
195
+ let routeResult = fetchedData.routes[match.route.id];
196
+ if ("error" in routeResult) {
197
+ middlewareError = routeResult.error;
198
+ if (results[match.route.id]?.result == null) results[match.route.id] = {
199
+ type: "error",
200
+ result: middlewareError
201
+ };
202
+ break;
203
+ }
204
+ }
205
+ }
206
+ if (middlewareError !== void 0) Array.from(routesParams.values()).forEach((routeId) => {
207
+ if (results[routeId].result instanceof SingleFetchNoResultError) results[routeId].result = middlewareError;
208
+ });
209
+ } catch (e) {}
210
+ }
211
+ async function singleFetchLoaderFetcherStrategy(args, fetchAndDecode) {
212
+ let fetcherMatch = args.matches.find((m) => m.shouldCallHandler());
213
+ invariant(fetcherMatch, "No fetcher match found");
214
+ let routeId = fetcherMatch.route.id;
215
+ let result = await fetcherMatch.resolve(async (handler) => handler(async () => {
216
+ let { data } = await fetchAndDecode(args, [routeId]);
217
+ return unwrapSingleFetchResult(data, routeId);
218
+ }));
219
+ return { [fetcherMatch.route.id]: result };
220
+ }
221
+ function stripIndexParam(url) {
222
+ let indexValues = url.searchParams.getAll("index");
223
+ url.searchParams.delete("index");
224
+ let indexValuesToKeep = [];
225
+ for (let indexValue of indexValues) if (indexValue) indexValuesToKeep.push(indexValue);
226
+ for (let toKeep of indexValuesToKeep) url.searchParams.append("index", toKeep);
227
+ return url;
228
+ }
229
+ function singleFetchUrl(reqUrl, extension) {
230
+ let url = typeof reqUrl === "string" ? new URL(reqUrl, typeof window === "undefined" ? "server://singlefetch/" : window.location.origin) : reqUrl;
231
+ if (url.pathname.endsWith("/")) url.pathname = `${url.pathname}_.${extension}`;
232
+ else url.pathname = `${url.pathname}.${extension}`;
233
+ return url;
234
+ }
235
+ async function fetchAndDecodeViaTurboStream(args, targetRoutes) {
236
+ let { request } = args;
237
+ let url = singleFetchUrl(request.url, "data");
238
+ if (request.method === "GET") {
239
+ url = stripIndexParam(url);
240
+ if (targetRoutes) url.searchParams.set("_routes", targetRoutes.join(","));
241
+ }
242
+ let res = await fetch(url, await createRequestInit(request));
243
+ if (res.status >= 400 && !res.headers.has("X-Remix-Response")) throw new ErrorResponseImpl(res.status, res.statusText, await res.text());
244
+ if (res.status === 204 && res.headers.has("X-Remix-Redirect")) return {
245
+ status: 202,
246
+ data: { redirect: {
247
+ redirect: res.headers.get("X-Remix-Redirect"),
248
+ status: Number(res.headers.get("X-Remix-Status") || "302"),
249
+ revalidate: res.headers.get("X-Remix-Revalidate") === "true",
250
+ reload: res.headers.get("X-Remix-Reload-Document") === "true",
251
+ replace: res.headers.get("X-Remix-Replace") === "true"
252
+ } }
253
+ };
254
+ if (NO_BODY_STATUS_CODES.has(res.status)) {
255
+ let routes = {};
256
+ if (targetRoutes && request.method !== "GET") routes[targetRoutes[0]] = { data: void 0 };
257
+ return {
258
+ status: res.status,
259
+ data: { routes }
260
+ };
261
+ }
262
+ invariant(res.body, "No response body to decode");
263
+ try {
264
+ let decoded = await decodeViaTurboStream(res.body, window);
265
+ let data;
266
+ if (request.method === "GET") {
267
+ let typed = decoded.value;
268
+ if (SingleFetchRedirectSymbol in typed) data = { redirect: typed[SingleFetchRedirectSymbol] };
269
+ else data = { routes: typed };
270
+ } else {
271
+ let typed = decoded.value;
272
+ let routeId = targetRoutes?.[0];
273
+ invariant(routeId, "No routeId found for single fetch call decoding");
274
+ if ("redirect" in typed) data = { redirect: typed };
275
+ else data = { routes: { [routeId]: typed } };
276
+ }
277
+ return {
278
+ status: res.status,
279
+ data
280
+ };
281
+ } catch (e) {
282
+ throw new Error("Unable to decode turbo-stream response");
283
+ }
284
+ }
285
+ function decodeViaTurboStream(body, global) {
286
+ return decode(body, { plugins: [(type, ...rest) => {
287
+ if (type === "SanitizedError") {
288
+ let [name, message, stack] = rest;
289
+ let Constructor = Error;
290
+ if (name && SUPPORTED_ERROR_TYPES.includes(name) && name in global && typeof global[name] === "function") Constructor = global[name];
291
+ let error = new Constructor(message);
292
+ error.stack = stack;
293
+ return { value: error };
294
+ }
295
+ if (type === "ErrorResponse") {
296
+ let [data, status, statusText] = rest;
297
+ return { value: new ErrorResponseImpl(status, statusText, data) };
298
+ }
299
+ if (type === "SingleFetchRedirect") return { value: { [SingleFetchRedirectSymbol]: rest[0] } };
300
+ if (type === "SingleFetchClassInstance") return { value: rest[0] };
301
+ if (type === "SingleFetchFallback") return { value: void 0 };
302
+ }] });
303
+ }
304
+ function unwrapSingleFetchResult(result, routeId) {
305
+ if ("redirect" in result) {
306
+ let { redirect: location, revalidate, reload, replace, status } = result.redirect;
307
+ throw redirect(location, {
308
+ status,
309
+ headers: {
310
+ ...revalidate ? { "X-Remix-Revalidate": "yes" } : null,
311
+ ...reload ? { "X-Remix-Reload-Document": "yes" } : null,
312
+ ...replace ? { "X-Remix-Replace": "yes" } : null
313
+ }
314
+ });
315
+ }
316
+ let routeResult = result.routes[routeId];
317
+ if (routeResult == null) throw new SingleFetchNoResultError(`No result found for routeId "${routeId}"`);
318
+ else if ("error" in routeResult) throw routeResult.error;
319
+ else if ("data" in routeResult) return routeResult.data;
320
+ else throw new Error(`Invalid response found for routeId "${routeId}"`);
321
+ }
322
+ function createDeferred() {
323
+ let resolve;
324
+ let reject;
325
+ let promise = new Promise((res, rej) => {
326
+ resolve = async (val) => {
327
+ res(val);
328
+ try {
329
+ await promise;
330
+ } catch (e) {}
331
+ };
332
+ reject = async (error) => {
333
+ rej(error);
334
+ try {
335
+ await promise;
336
+ } catch (e) {}
337
+ };
338
+ });
339
+ return {
340
+ promise,
341
+ resolve,
342
+ reject
343
+ };
344
+ }
345
+ //#endregion
346
+ export { NO_BODY_STATUS_CODES, SingleFetchRedirectSymbol, StreamTransfer, decodeViaTurboStream, getSingleFetchDataStrategyImpl, getTurboStreamSingleFetchDataStrategy, singleFetchUrl, stripIndexParam };
@@ -0,0 +1,9 @@
1
+
2
+ import * as React$1 from "react";
3
+ import { RouterProviderProps } from "react-router";
4
+
5
+ //#region lib/dom-export/dom-router-provider.d.ts
6
+ type RouterProviderProps$1 = Omit<RouterProviderProps, "flushSync">;
7
+ declare function RouterProvider$1(props: RouterProviderProps$1): React$1.JSX.Element;
8
+ //#endregion
9
+ export { RouterProvider$1 as RouterProvider, RouterProviderProps$1 as RouterProviderProps };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * react-router v8.0.0-pre.0
3
+ *
4
+ * Copyright (c) Remix Software Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ import * as React$1 from "react";
12
+ import * as ReactDOM from "react-dom";
13
+ import { RouterProvider } from "react-router";
14
+ //#region lib/dom-export/dom-router-provider.tsx
15
+ function RouterProvider$1(props) {
16
+ return /* @__PURE__ */ React$1.createElement(RouterProvider, {
17
+ flushSync: ReactDOM.flushSync,
18
+ ...props
19
+ });
20
+ }
21
+ //#endregion
22
+ export { RouterProvider$1 as RouterProvider };
@@ -0,0 +1,125 @@
1
+
2
+ import { ClientInstrumentation } from "../router/instrumentation.js";
3
+ import * as React$1 from "react";
4
+ import { ClientOnErrorFunction, RouterInit } from "react-router";
5
+
6
+ //#region lib/dom-export/hydrated-router.d.ts
7
+ /**
8
+ * Props for the {@link dom.HydratedRouter} component.
9
+ *
10
+ * @category Types
11
+ */
12
+ interface HydratedRouterProps {
13
+ /**
14
+ * Context factory function to be passed through to {@link createBrowserRouter}.
15
+ * This function will be called to create a fresh `context` instance on each
16
+ * navigation/fetch and made available to
17
+ * [`clientAction`](../../start/framework/route-module#clientAction)/[`clientLoader`](../../start/framework/route-module#clientLoader)
18
+ * functions.
19
+ */
20
+ getContext?: RouterInit["getContext"];
21
+ /**
22
+ * Array of instrumentation objects allowing you to instrument the router and
23
+ * individual routes prior to router initialization (and on any subsequently
24
+ * added routes via `route.lazy` or `patchRoutesOnNavigation`). This is
25
+ * mostly useful for observability such as wrapping navigations, fetches,
26
+ * as well as route loaders/actions/middlewares with logging and/or performance
27
+ * tracing. See the [docs](../../how-to/instrumentation) for more information.
28
+ *
29
+ * ```tsx
30
+ * const logging = {
31
+ * router({ instrument }) {
32
+ * instrument({
33
+ * navigate: (impl, { to }) => logExecution(`navigate ${to}`, impl),
34
+ * fetch: (impl, { to }) => logExecution(`fetch ${to}`, impl)
35
+ * });
36
+ * },
37
+ * route({ instrument, id }) {
38
+ * instrument({
39
+ * middleware: (impl, { request }) => logExecution(
40
+ * `middleware ${request.url} (route ${id})`,
41
+ * impl
42
+ * ),
43
+ * loader: (impl, { request }) => logExecution(
44
+ * `loader ${request.url} (route ${id})`,
45
+ * impl
46
+ * ),
47
+ * action: (impl, { request }) => logExecution(
48
+ * `action ${request.url} (route ${id})`,
49
+ * impl
50
+ * ),
51
+ * })
52
+ * }
53
+ * };
54
+ *
55
+ * async function logExecution(label: string, impl: () => Promise<void>) {
56
+ * let start = performance.now();
57
+ * console.log(`start ${label}`);
58
+ * await impl();
59
+ * let duration = Math.round(performance.now() - start);
60
+ * console.log(`end ${label} (${duration}ms)`);
61
+ * }
62
+ *
63
+ * startTransition(() => {
64
+ * hydrateRoot(
65
+ * document,
66
+ * <HydratedRouter instrumentations={[logging]} />
67
+ * );
68
+ * });
69
+ * ```
70
+ */
71
+ instrumentations?: ClientInstrumentation[];
72
+ /**
73
+ * An error handler function that will be called for any middleware, loader, action,
74
+ * or render errors that are encountered in your application. This is useful for
75
+ * logging or reporting errors instead of in the {@link ErrorBoundary} because it's not
76
+ * subject to re-rendering and will only run one time per error.
77
+ *
78
+ * The `errorInfo` parameter is passed along from
79
+ * [`componentDidCatch`](https://react.dev/reference/react/Component#componentdidcatch)
80
+ * and is only present for render errors.
81
+ *
82
+ * ```tsx
83
+ * <HydratedRouter onError=(error, info) => {
84
+ * let { location, params, pattern, errorInfo } = info;
85
+ * console.error(error, location, errorInfo);
86
+ * reportToErrorService(error, location, errorInfo);
87
+ * }} />
88
+ * ```
89
+ */
90
+ onError?: ClientOnErrorFunction;
91
+ /**
92
+ * Control whether router state updates are internally wrapped in
93
+ * [`React.startTransition`](https://react.dev/reference/react/startTransition).
94
+ *
95
+ * - When left `undefined`, all state updates are wrapped in
96
+ * `React.startTransition`
97
+ * - This can lead to buggy behaviors if you are wrapping your own
98
+ * navigations/fetchers in `startTransition`.
99
+ * - When set to `true`, {@link Link} and {@link Form} navigations will be wrapped
100
+ * in `React.startTransition` and router state changes will be wrapped in
101
+ * `React.startTransition` and also sent through
102
+ * [`useOptimistic`](https://react.dev/reference/react/useOptimistic) to
103
+ * surface mid-navigation router state changes to the UI.
104
+ * - When set to `false`, the router will not leverage `React.startTransition` or
105
+ * `React.useOptimistic` on any navigations or state changes.
106
+ *
107
+ * For more information, please see the [docs](../../explanation/react-transitions).
108
+ */
109
+ useTransitions?: boolean;
110
+ }
111
+ /**
112
+ * Framework-mode router component to be used to hydrate a router from a
113
+ * {@link ServerRouter}. See [`entry.client.tsx`](../framework-conventions/entry.client.tsx).
114
+ *
115
+ * @public
116
+ * @category Framework Routers
117
+ * @mode framework
118
+ * @param props Props
119
+ * @param {dom.HydratedRouterProps.getContext} props.getContext n/a
120
+ * @param {dom.HydratedRouterProps.onError} props.onError n/a
121
+ * @returns A React element that represents the hydrated application.
122
+ */
123
+ declare function HydratedRouter(props: HydratedRouterProps): React$1.JSX.Element;
124
+ //#endregion
125
+ export { HydratedRouter, HydratedRouterProps };
@@ -0,0 +1,153 @@
1
+ /**
2
+ * react-router v8.0.0-pre.0
3
+ *
4
+ * Copyright (c) Remix Software Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ import { CRITICAL_CSS_DATA_ATTRIBUTE } from "../dom/ssr/components.js";
12
+ import { RouterProvider as RouterProvider$1 } from "./dom-router-provider.js";
13
+ import * as React$1 from "react";
14
+ import { UNSAFE_FrameworkContext, UNSAFE_RemixErrorBoundary, UNSAFE_createBrowserHistory, UNSAFE_createClientRoutes, UNSAFE_createClientRoutesWithHMRRevalidationOptOut, UNSAFE_createRouter, UNSAFE_decodeViaTurboStream, UNSAFE_defaultMapRouteProperties, UNSAFE_deserializeErrors, UNSAFE_getHydrationData, UNSAFE_getPatchRoutesOnNavigationFunction, UNSAFE_getTurboStreamSingleFetchDataStrategy, UNSAFE_hydrationRouteProperties, UNSAFE_invariant, UNSAFE_useFogOFWarDiscovery } from "react-router";
15
+ //#region lib/dom-export/hydrated-router.tsx
16
+ let ssrInfo = null;
17
+ let router = null;
18
+ function initSsrInfo() {
19
+ if (!ssrInfo && window.__reactRouterContext && window.__reactRouterManifest && window.__reactRouterRouteModules) {
20
+ if (window.__reactRouterManifest.sri === true) {
21
+ const importMap = document.querySelector("script[rr-importmap]");
22
+ if (importMap?.textContent) try {
23
+ window.__reactRouterManifest.sri = JSON.parse(importMap.textContent).integrity;
24
+ } catch (err) {
25
+ console.error("Failed to parse import map", err);
26
+ }
27
+ }
28
+ ssrInfo = {
29
+ context: window.__reactRouterContext,
30
+ manifest: window.__reactRouterManifest,
31
+ routeModules: window.__reactRouterRouteModules,
32
+ stateDecodingPromise: void 0,
33
+ router: void 0,
34
+ routerInitialized: false
35
+ };
36
+ }
37
+ }
38
+ function createHydratedRouter({ getContext, instrumentations }) {
39
+ initSsrInfo();
40
+ if (!ssrInfo) throw new Error("You must be using the SSR features of React Router in order to skip passing a `router` prop to `<RouterProvider>`");
41
+ let localSsrInfo = ssrInfo;
42
+ if (!ssrInfo.stateDecodingPromise) {
43
+ let stream = ssrInfo.context.stream;
44
+ UNSAFE_invariant(stream, "No stream found for single fetch decoding");
45
+ ssrInfo.context.stream = void 0;
46
+ ssrInfo.stateDecodingPromise = UNSAFE_decodeViaTurboStream(stream, window).then((value) => {
47
+ ssrInfo.context.state = value.value;
48
+ localSsrInfo.stateDecodingPromise.value = true;
49
+ }).catch((e) => {
50
+ localSsrInfo.stateDecodingPromise.error = e;
51
+ });
52
+ }
53
+ if (ssrInfo.stateDecodingPromise.error) throw ssrInfo.stateDecodingPromise.error;
54
+ if (!ssrInfo.stateDecodingPromise.value) throw ssrInfo.stateDecodingPromise;
55
+ let routes = UNSAFE_createClientRoutes(ssrInfo.manifest.routes, ssrInfo.routeModules, ssrInfo.context.state, ssrInfo.context.ssr, ssrInfo.context.isSpaMode);
56
+ let hydrationData = void 0;
57
+ if (ssrInfo.context.isSpaMode) {
58
+ let { loaderData } = ssrInfo.context.state;
59
+ if (ssrInfo.manifest.routes.root?.hasLoader && loaderData && "root" in loaderData) hydrationData = { loaderData: { root: loaderData.root } };
60
+ } else {
61
+ hydrationData = UNSAFE_getHydrationData({
62
+ state: ssrInfo.context.state,
63
+ routes,
64
+ getRouteInfo: (routeId) => ({
65
+ clientLoader: ssrInfo.routeModules[routeId]?.clientLoader,
66
+ hasLoader: ssrInfo.manifest.routes[routeId]?.hasLoader === true,
67
+ hasHydrateFallback: ssrInfo.routeModules[routeId]?.HydrateFallback != null
68
+ }),
69
+ location: window.location,
70
+ basename: window.__reactRouterContext?.basename,
71
+ isSpaMode: ssrInfo.context.isSpaMode
72
+ });
73
+ if (hydrationData && hydrationData.errors) hydrationData.errors = UNSAFE_deserializeErrors(hydrationData.errors);
74
+ }
75
+ if (window.history.state && window.history.state.masked) window.history.replaceState({
76
+ ...window.history.state,
77
+ masked: void 0
78
+ }, "");
79
+ let router = UNSAFE_createRouter({
80
+ routes,
81
+ history: UNSAFE_createBrowserHistory(),
82
+ basename: ssrInfo.context.basename,
83
+ getContext,
84
+ hydrationData,
85
+ mapRouteProperties: UNSAFE_defaultMapRouteProperties,
86
+ hydrationRouteProperties: UNSAFE_hydrationRouteProperties,
87
+ instrumentations,
88
+ dataStrategy: UNSAFE_getTurboStreamSingleFetchDataStrategy(() => router, ssrInfo.manifest, ssrInfo.routeModules, ssrInfo.context.ssr),
89
+ patchRoutesOnNavigation: UNSAFE_getPatchRoutesOnNavigationFunction(() => router, ssrInfo.manifest, ssrInfo.routeModules, ssrInfo.context.ssr, ssrInfo.context.routeDiscovery, ssrInfo.context.isSpaMode, ssrInfo.context.basename)
90
+ });
91
+ ssrInfo.router = router;
92
+ if (router.state.initialized) {
93
+ ssrInfo.routerInitialized = true;
94
+ router.initialize();
95
+ }
96
+ router.createRoutesForHMR = UNSAFE_createClientRoutesWithHMRRevalidationOptOut;
97
+ window.__reactRouterDataRouter = router;
98
+ return router;
99
+ }
100
+ /**
101
+ * Framework-mode router component to be used to hydrate a router from a
102
+ * {@link ServerRouter}. See [`entry.client.tsx`](../framework-conventions/entry.client.tsx).
103
+ *
104
+ * @public
105
+ * @category Framework Routers
106
+ * @mode framework
107
+ * @param props Props
108
+ * @param {dom.HydratedRouterProps.getContext} props.getContext n/a
109
+ * @param {dom.HydratedRouterProps.onError} props.onError n/a
110
+ * @returns A React element that represents the hydrated application.
111
+ */
112
+ function HydratedRouter(props) {
113
+ if (!router) router = createHydratedRouter({
114
+ getContext: props.getContext,
115
+ instrumentations: props.instrumentations
116
+ });
117
+ let [criticalCss, setCriticalCss] = React$1.useState(process.env.NODE_ENV === "development" ? ssrInfo?.context.criticalCss : void 0);
118
+ React$1.useEffect(() => {
119
+ if (process.env.NODE_ENV === "development") setCriticalCss(void 0);
120
+ }, []);
121
+ React$1.useEffect(() => {
122
+ if (process.env.NODE_ENV === "development" && criticalCss === void 0) document.querySelectorAll(`[${CRITICAL_CSS_DATA_ATTRIBUTE}]`).forEach((element) => element.remove());
123
+ }, [criticalCss]);
124
+ let [location, setLocation] = React$1.useState(router.state.location);
125
+ React$1.useLayoutEffect(() => {
126
+ if (ssrInfo && ssrInfo.router && !ssrInfo.routerInitialized) {
127
+ ssrInfo.routerInitialized = true;
128
+ ssrInfo.router.initialize();
129
+ }
130
+ }, []);
131
+ React$1.useLayoutEffect(() => {
132
+ if (ssrInfo && ssrInfo.router) return ssrInfo.router.subscribe((newState) => {
133
+ if (newState.location !== location) setLocation(newState.location);
134
+ });
135
+ }, [location]);
136
+ UNSAFE_invariant(ssrInfo, "ssrInfo unavailable for HydratedRouter");
137
+ UNSAFE_useFogOFWarDiscovery(router, ssrInfo.manifest, ssrInfo.routeModules, ssrInfo.context.ssr, ssrInfo.context.routeDiscovery, ssrInfo.context.isSpaMode);
138
+ return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, /* @__PURE__ */ React$1.createElement(UNSAFE_FrameworkContext.Provider, { value: {
139
+ manifest: ssrInfo.manifest,
140
+ routeModules: ssrInfo.routeModules,
141
+ future: ssrInfo.context.future,
142
+ criticalCss,
143
+ ssr: ssrInfo.context.ssr,
144
+ isSpaMode: ssrInfo.context.isSpaMode,
145
+ routeDiscovery: ssrInfo.context.routeDiscovery
146
+ } }, /* @__PURE__ */ React$1.createElement(UNSAFE_RemixErrorBoundary, { location }, /* @__PURE__ */ React$1.createElement(RouterProvider$1, {
147
+ router,
148
+ useTransitions: props.useTransitions,
149
+ onError: props.onError
150
+ }))), /* @__PURE__ */ React$1.createElement(React$1.Fragment, null));
151
+ }
152
+ //#endregion
153
+ export { HydratedRouter };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * react-router v8.0.0-pre.0
3
+ *
4
+ * Copyright (c) Remix Software Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ import { ErrorResponseImpl } from "./router/utils.js";
12
+ //#region lib/errors.ts
13
+ const ERROR_DIGEST_BASE = "REACT_ROUTER_ERROR";
14
+ const ERROR_DIGEST_REDIRECT = "REDIRECT";
15
+ const ERROR_DIGEST_ROUTE_ERROR_RESPONSE = "ROUTE_ERROR_RESPONSE";
16
+ function decodeRedirectErrorDigest(digest) {
17
+ if (digest.startsWith(`${ERROR_DIGEST_BASE}:${ERROR_DIGEST_REDIRECT}:{`)) try {
18
+ let parsed = JSON.parse(digest.slice(28));
19
+ if (typeof parsed === "object" && parsed && typeof parsed.status === "number" && typeof parsed.statusText === "string" && typeof parsed.location === "string" && typeof parsed.reloadDocument === "boolean" && typeof parsed.replace === "boolean") return parsed;
20
+ } catch {}
21
+ }
22
+ function decodeRouteErrorResponseDigest(digest) {
23
+ if (digest.startsWith(`${ERROR_DIGEST_BASE}:${ERROR_DIGEST_ROUTE_ERROR_RESPONSE}:{`)) try {
24
+ let parsed = JSON.parse(digest.slice(40));
25
+ if (typeof parsed === "object" && parsed && typeof parsed.status === "number" && typeof parsed.statusText === "string") return new ErrorResponseImpl(parsed.status, parsed.statusText, parsed.data);
26
+ } catch {}
27
+ }
28
+ //#endregion
29
+ export { decodeRedirectErrorDigest, decodeRouteErrorResponseDigest };