react-router 7.18.0 → 8.0.0-pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/dist/development/dom-export.d.ts +6 -172
  2. package/dist/development/dom-export.js +12 -1009
  3. package/dist/development/index-react-server-client.d.ts +7 -4
  4. package/dist/development/index-react-server-client.js +8 -52
  5. package/dist/development/index-react-server.d.ts +1650 -1641
  6. package/dist/development/index-react-server.js +2882 -3664
  7. package/dist/development/index.d.ts +42 -1476
  8. package/dist/development/index.js +36 -2553
  9. package/dist/development/lib/actions.js +50 -0
  10. package/dist/development/lib/components.d.ts +1030 -0
  11. package/dist/development/lib/components.js +841 -0
  12. package/dist/development/lib/context.d.ts +83 -0
  13. package/dist/development/lib/context.js +41 -0
  14. package/dist/development/lib/dom/dom.d.ts +119 -0
  15. package/dist/development/lib/dom/dom.js +143 -0
  16. package/dist/development/lib/dom/lib.d.ts +2053 -0
  17. package/dist/development/lib/dom/lib.js +1271 -0
  18. package/dist/development/lib/dom/server.d.ts +138 -0
  19. package/dist/development/lib/dom/server.js +301 -0
  20. package/dist/development/lib/dom/ssr/components.d.ts +198 -0
  21. package/dist/development/lib/dom/ssr/components.js +589 -0
  22. package/dist/development/lib/dom/ssr/data.js +29 -0
  23. package/dist/development/lib/dom/ssr/entry.d.ts +60 -0
  24. package/dist/development/lib/dom/ssr/errorBoundaries.d.ts +27 -0
  25. package/dist/development/lib/dom/ssr/errorBoundaries.js +87 -0
  26. package/dist/development/lib/dom/ssr/fallback.js +33 -0
  27. package/dist/development/lib/dom/ssr/fog-of-war.d.ts +12 -0
  28. package/dist/development/lib/dom/ssr/fog-of-war.js +180 -0
  29. package/dist/development/lib/dom/ssr/hydration.d.ts +32 -0
  30. package/dist/development/lib/dom/ssr/hydration.js +29 -0
  31. package/dist/development/lib/dom/ssr/invariant.js +16 -0
  32. package/dist/development/lib/dom/ssr/links.js +170 -0
  33. package/dist/development/lib/dom/ssr/markup.js +24 -0
  34. package/dist/development/lib/dom/ssr/routeModules.d.ts +206 -0
  35. package/dist/development/lib/dom/ssr/routeModules.js +31 -0
  36. package/dist/development/lib/dom/ssr/routes-test-stub.d.ts +62 -0
  37. package/dist/development/lib/dom/ssr/routes-test-stub.js +108 -0
  38. package/dist/development/lib/dom/ssr/routes.d.ts +33 -0
  39. package/dist/development/lib/dom/ssr/routes.js +303 -0
  40. package/dist/development/lib/dom/ssr/server.d.ts +48 -0
  41. package/dist/development/lib/dom/ssr/server.js +69 -0
  42. package/dist/development/lib/dom/ssr/single-fetch.d.ts +14 -0
  43. package/dist/development/lib/dom/ssr/single-fetch.js +345 -0
  44. package/dist/development/lib/dom-export/dom-router-provider.d.ts +9 -0
  45. package/dist/development/lib/dom-export/dom-router-provider.js +22 -0
  46. package/dist/development/lib/dom-export/hydrated-router.d.ts +125 -0
  47. package/dist/development/lib/dom-export/hydrated-router.js +150 -0
  48. package/dist/development/lib/errors.js +29 -0
  49. package/dist/development/lib/hooks.d.ts +947 -0
  50. package/dist/development/lib/hooks.js +1388 -0
  51. package/dist/development/lib/href.d.ts +20 -0
  52. package/dist/development/lib/href.js +50 -0
  53. package/dist/development/lib/router/history.d.ts +258 -0
  54. package/dist/development/lib/router/history.js +372 -0
  55. package/dist/development/lib/router/instrumentation.d.ts +86 -0
  56. package/dist/development/lib/router/instrumentation.js +213 -0
  57. package/dist/development/lib/router/links.d.ts +114 -0
  58. package/dist/development/lib/router/router.d.ts +663 -0
  59. package/dist/development/lib/router/router.js +2988 -0
  60. package/dist/development/lib/router/url.js +18 -0
  61. package/dist/development/lib/router/utils.d.ts +948 -0
  62. package/dist/development/lib/router/utils.js +810 -0
  63. package/dist/development/lib/rsc/browser.d.ts +137 -0
  64. package/dist/development/lib/rsc/browser.js +603 -0
  65. package/dist/development/lib/rsc/errorBoundaries.d.ts +11 -0
  66. package/dist/development/lib/rsc/errorBoundaries.js +90 -0
  67. package/dist/development/lib/rsc/html-stream/browser.d.ts +48 -0
  68. package/dist/development/lib/rsc/html-stream/browser.js +74 -0
  69. package/dist/development/lib/rsc/html-stream/server.js +78 -0
  70. package/dist/development/lib/rsc/route-modules.js +27 -0
  71. package/dist/development/lib/rsc/server.rsc.d.ts +219 -0
  72. package/dist/development/lib/rsc/server.ssr.d.ts +129 -0
  73. package/dist/development/lib/rsc/server.ssr.js +404 -0
  74. package/dist/development/lib/server-runtime/build.d.ts +66 -0
  75. package/dist/development/lib/server-runtime/cookies.d.ts +66 -0
  76. package/dist/development/lib/server-runtime/cookies.js +139 -0
  77. package/dist/development/lib/server-runtime/crypto.js +43 -0
  78. package/dist/development/lib/server-runtime/data.d.ts +13 -0
  79. package/dist/development/lib/server-runtime/data.js +25 -0
  80. package/dist/development/lib/server-runtime/dev.d.ts +9 -0
  81. package/dist/development/lib/server-runtime/dev.js +26 -0
  82. package/dist/development/lib/server-runtime/entry.js +20 -0
  83. package/dist/development/lib/server-runtime/errors.js +75 -0
  84. package/dist/development/lib/server-runtime/headers.js +73 -0
  85. package/dist/development/lib/server-runtime/invariant.js +19 -0
  86. package/dist/development/lib/server-runtime/mode.d.ts +12 -0
  87. package/dist/development/lib/server-runtime/mode.js +25 -0
  88. package/dist/development/lib/server-runtime/routeMatching.js +28 -0
  89. package/dist/development/lib/server-runtime/routes.d.ts +13 -0
  90. package/dist/development/lib/server-runtime/routes.js +74 -0
  91. package/dist/development/lib/server-runtime/server.d.ts +10 -0
  92. package/dist/development/lib/server-runtime/server.js +345 -0
  93. package/dist/development/lib/server-runtime/serverHandoff.js +17 -0
  94. package/dist/development/lib/server-runtime/sessions/cookieStorage.d.ts +25 -0
  95. package/dist/development/lib/server-runtime/sessions/cookieStorage.js +45 -0
  96. package/dist/development/lib/server-runtime/sessions/memoryStorage.d.ts +23 -0
  97. package/dist/development/lib/server-runtime/sessions/memoryStorage.js +52 -0
  98. package/dist/development/lib/server-runtime/sessions.d.ts +145 -0
  99. package/dist/development/lib/server-runtime/sessions.js +98 -0
  100. package/dist/development/lib/server-runtime/single-fetch.d.ts +7 -0
  101. package/dist/development/lib/server-runtime/single-fetch.js +215 -0
  102. package/dist/development/lib/server-runtime/urls.js +28 -0
  103. package/dist/development/lib/server-runtime/warnings.js +20 -0
  104. package/dist/development/lib/types/future.d.ts +9 -0
  105. package/dist/development/lib/types/internal.d.ts +26 -177
  106. package/dist/development/lib/types/internal.js +3 -2
  107. package/dist/development/{register-roq_0qYo.d.ts → lib/types/register.d.ts} +9 -15
  108. package/dist/development/lib/types/route-data.d.ts +113 -0
  109. package/dist/development/lib/types/route-module-annotations.d.ts +149 -0
  110. package/dist/development/lib/types/route-module.d.ts +19 -0
  111. package/dist/development/lib/types/serializes-to.d.ts +13 -0
  112. package/dist/development/lib/types/utils.d.ts +11 -0
  113. package/dist/development/vendor/turbo-stream-v2/flatten.js +159 -0
  114. package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +179 -0
  115. package/dist/development/vendor/turbo-stream-v2/unflatten.js +199 -0
  116. package/dist/development/vendor/turbo-stream-v2/utils.js +39 -0
  117. package/dist/production/dom-export.d.ts +6 -172
  118. package/dist/production/dom-export.js +12 -1009
  119. package/dist/production/index-react-server-client.d.ts +7 -4
  120. package/dist/production/index-react-server-client.js +8 -52
  121. package/dist/production/index-react-server.d.ts +1650 -1641
  122. package/dist/production/index-react-server.js +2873 -3664
  123. package/dist/production/index.d.ts +42 -1476
  124. package/dist/production/index.js +36 -2553
  125. package/dist/production/lib/actions.js +50 -0
  126. package/dist/production/lib/components.d.ts +1030 -0
  127. package/dist/production/lib/components.js +841 -0
  128. package/dist/production/lib/context.d.ts +83 -0
  129. package/dist/production/lib/context.js +41 -0
  130. package/dist/production/lib/dom/dom.d.ts +119 -0
  131. package/dist/production/lib/dom/dom.js +143 -0
  132. package/dist/production/lib/dom/lib.d.ts +2053 -0
  133. package/dist/production/lib/dom/lib.js +1271 -0
  134. package/dist/production/lib/dom/server.d.ts +138 -0
  135. package/dist/production/lib/dom/server.js +301 -0
  136. package/dist/production/lib/dom/ssr/components.d.ts +198 -0
  137. package/dist/production/lib/dom/ssr/components.js +589 -0
  138. package/dist/production/lib/dom/ssr/data.js +29 -0
  139. package/dist/production/lib/dom/ssr/entry.d.ts +60 -0
  140. package/dist/production/lib/dom/ssr/errorBoundaries.d.ts +27 -0
  141. package/dist/production/lib/dom/ssr/errorBoundaries.js +87 -0
  142. package/dist/production/lib/dom/ssr/fallback.js +23 -0
  143. package/dist/production/lib/dom/ssr/fog-of-war.d.ts +12 -0
  144. package/dist/production/lib/dom/ssr/fog-of-war.js +180 -0
  145. package/dist/production/lib/dom/ssr/hydration.d.ts +32 -0
  146. package/dist/production/lib/dom/ssr/hydration.js +29 -0
  147. package/dist/production/lib/dom/ssr/invariant.js +16 -0
  148. package/dist/production/lib/dom/ssr/links.js +170 -0
  149. package/dist/production/lib/dom/ssr/markup.js +24 -0
  150. package/dist/production/lib/dom/ssr/routeModules.d.ts +206 -0
  151. package/dist/production/lib/dom/ssr/routeModules.js +31 -0
  152. package/dist/production/lib/dom/ssr/routes-test-stub.d.ts +62 -0
  153. package/dist/production/lib/dom/ssr/routes-test-stub.js +108 -0
  154. package/dist/production/lib/dom/ssr/routes.d.ts +33 -0
  155. package/dist/production/lib/dom/ssr/routes.js +303 -0
  156. package/dist/production/lib/dom/ssr/server.d.ts +48 -0
  157. package/dist/production/lib/dom/ssr/server.js +69 -0
  158. package/dist/production/lib/dom/ssr/single-fetch.d.ts +14 -0
  159. package/dist/production/lib/dom/ssr/single-fetch.js +345 -0
  160. package/dist/production/lib/dom-export/dom-router-provider.d.ts +9 -0
  161. package/dist/production/lib/dom-export/dom-router-provider.js +22 -0
  162. package/dist/production/lib/dom-export/hydrated-router.d.ts +125 -0
  163. package/dist/production/lib/dom-export/hydrated-router.js +150 -0
  164. package/dist/production/lib/errors.js +29 -0
  165. package/dist/production/lib/hooks.d.ts +947 -0
  166. package/dist/production/lib/hooks.js +1373 -0
  167. package/dist/production/lib/href.d.ts +20 -0
  168. package/dist/production/lib/href.js +50 -0
  169. package/dist/production/lib/router/history.d.ts +258 -0
  170. package/dist/production/lib/router/history.js +372 -0
  171. package/dist/production/lib/router/instrumentation.d.ts +86 -0
  172. package/dist/production/lib/router/instrumentation.js +213 -0
  173. package/dist/production/lib/router/links.d.ts +114 -0
  174. package/dist/production/lib/router/router.d.ts +663 -0
  175. package/dist/production/lib/router/router.js +2988 -0
  176. package/dist/production/lib/router/url.js +18 -0
  177. package/dist/production/lib/router/utils.d.ts +948 -0
  178. package/dist/production/lib/router/utils.js +801 -0
  179. package/dist/production/lib/rsc/browser.d.ts +137 -0
  180. package/dist/production/lib/rsc/browser.js +603 -0
  181. package/dist/production/lib/rsc/errorBoundaries.d.ts +11 -0
  182. package/dist/production/lib/rsc/errorBoundaries.js +90 -0
  183. package/dist/production/lib/rsc/html-stream/browser.d.ts +48 -0
  184. package/dist/production/lib/rsc/html-stream/browser.js +74 -0
  185. package/dist/production/lib/rsc/html-stream/server.js +78 -0
  186. package/dist/production/lib/rsc/route-modules.js +27 -0
  187. package/dist/production/lib/rsc/server.rsc.d.ts +219 -0
  188. package/dist/production/lib/rsc/server.ssr.d.ts +129 -0
  189. package/dist/production/lib/rsc/server.ssr.js +404 -0
  190. package/dist/production/lib/server-runtime/build.d.ts +66 -0
  191. package/dist/production/lib/server-runtime/cookies.d.ts +66 -0
  192. package/dist/production/lib/server-runtime/cookies.js +139 -0
  193. package/dist/production/lib/server-runtime/crypto.js +43 -0
  194. package/dist/production/lib/server-runtime/data.d.ts +13 -0
  195. package/dist/production/lib/server-runtime/data.js +25 -0
  196. package/dist/production/lib/server-runtime/dev.d.ts +9 -0
  197. package/dist/production/lib/server-runtime/dev.js +26 -0
  198. package/dist/production/lib/server-runtime/entry.js +20 -0
  199. package/dist/production/lib/server-runtime/errors.js +75 -0
  200. package/dist/production/lib/server-runtime/headers.js +73 -0
  201. package/dist/production/lib/server-runtime/invariant.js +19 -0
  202. package/dist/production/lib/server-runtime/mode.d.ts +12 -0
  203. package/dist/production/lib/server-runtime/mode.js +25 -0
  204. package/dist/production/lib/server-runtime/routeMatching.js +28 -0
  205. package/dist/production/lib/server-runtime/routes.d.ts +13 -0
  206. package/dist/production/lib/server-runtime/routes.js +74 -0
  207. package/dist/production/lib/server-runtime/server.d.ts +10 -0
  208. package/dist/production/lib/server-runtime/server.js +345 -0
  209. package/dist/production/lib/server-runtime/serverHandoff.js +17 -0
  210. package/dist/production/lib/server-runtime/sessions/cookieStorage.d.ts +25 -0
  211. package/dist/production/lib/server-runtime/sessions/cookieStorage.js +45 -0
  212. package/dist/production/lib/server-runtime/sessions/memoryStorage.d.ts +23 -0
  213. package/dist/production/lib/server-runtime/sessions/memoryStorage.js +52 -0
  214. package/dist/production/lib/server-runtime/sessions.d.ts +145 -0
  215. package/dist/production/lib/server-runtime/sessions.js +98 -0
  216. package/dist/production/lib/server-runtime/single-fetch.d.ts +7 -0
  217. package/dist/production/lib/server-runtime/single-fetch.js +215 -0
  218. package/dist/production/lib/server-runtime/urls.js +28 -0
  219. package/dist/production/lib/server-runtime/warnings.js +20 -0
  220. package/dist/production/lib/types/future.d.ts +9 -0
  221. package/dist/production/lib/types/internal.d.ts +26 -177
  222. package/dist/production/lib/types/internal.js +3 -2
  223. package/dist/production/{register-roq_0qYo.d.ts → lib/types/register.d.ts} +9 -15
  224. package/dist/production/lib/types/route-data.d.ts +113 -0
  225. package/dist/production/lib/types/route-module-annotations.d.ts +149 -0
  226. package/dist/production/lib/types/route-module.d.ts +19 -0
  227. package/dist/production/lib/types/serializes-to.d.ts +13 -0
  228. package/dist/production/lib/types/utils.d.ts +11 -0
  229. package/dist/production/vendor/turbo-stream-v2/flatten.js +159 -0
  230. package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +179 -0
  231. package/dist/production/vendor/turbo-stream-v2/unflatten.js +199 -0
  232. package/dist/production/vendor/turbo-stream-v2/utils.js +39 -0
  233. package/docs/explanation/code-splitting.md +16 -0
  234. package/docs/how-to/middleware.md +6 -41
  235. package/docs/how-to/react-server-components.md +1 -1
  236. package/docs/upgrading/future.md +0 -249
  237. package/package.json +43 -87
  238. package/dist/development/browser-B2PdsXXH.d.ts +0 -318
  239. package/dist/development/browser-DBmQ1yAR.d.mts +0 -318
  240. package/dist/development/chunk-4ZMWKKQ3.mjs +0 -11606
  241. package/dist/development/chunk-E4MTK73K.mjs +0 -2517
  242. package/dist/development/chunk-U7ORXROY.js +0 -10307
  243. package/dist/development/chunk-WW7PN6QI.js +0 -188
  244. package/dist/development/chunk-YL5M26XI.js +0 -1366
  245. package/dist/development/context-CeD5LmaF.d.mts +0 -1779
  246. package/dist/development/data-CjO11-hU.d.ts +0 -1740
  247. package/dist/development/data-DEjBmEfD.d.mts +0 -1740
  248. package/dist/development/dom-export.d.mts +0 -172
  249. package/dist/development/dom-export.mjs +0 -1010
  250. package/dist/development/index-react-server-client-3ykjivgQ.d.ts +0 -3677
  251. package/dist/development/index-react-server-client-CACgcj2J.d.mts +0 -2614
  252. package/dist/development/index-react-server-client.d.mts +0 -4
  253. package/dist/development/index-react-server-client.mjs +0 -59
  254. package/dist/development/index-react-server.d.mts +0 -2711
  255. package/dist/development/index-react-server.mjs +0 -3803
  256. package/dist/development/index.d.mts +0 -1479
  257. package/dist/development/index.mjs +0 -275
  258. package/dist/development/instrumentation-Dkmpzd13.d.ts +0 -715
  259. package/dist/development/lib/types/internal.d.mts +0 -184
  260. package/dist/development/lib/types/internal.mjs +0 -10
  261. package/dist/development/register-CmkRspdl.d.mts +0 -30
  262. package/dist/production/browser-B2PdsXXH.d.ts +0 -318
  263. package/dist/production/browser-DBmQ1yAR.d.mts +0 -318
  264. package/dist/production/chunk-3Z6WS2WZ.js +0 -188
  265. package/dist/production/chunk-BIP66BKV.js +0 -1366
  266. package/dist/production/chunk-EGOTSXNH.mjs +0 -2517
  267. package/dist/production/chunk-IUPBOWYO.js +0 -10307
  268. package/dist/production/chunk-M7NGGUU6.mjs +0 -11606
  269. package/dist/production/context-CeD5LmaF.d.mts +0 -1779
  270. package/dist/production/data-CjO11-hU.d.ts +0 -1740
  271. package/dist/production/data-DEjBmEfD.d.mts +0 -1740
  272. package/dist/production/dom-export.d.mts +0 -172
  273. package/dist/production/dom-export.mjs +0 -1010
  274. package/dist/production/index-react-server-client-3ykjivgQ.d.ts +0 -3677
  275. package/dist/production/index-react-server-client-CACgcj2J.d.mts +0 -2614
  276. package/dist/production/index-react-server-client.d.mts +0 -4
  277. package/dist/production/index-react-server-client.mjs +0 -59
  278. package/dist/production/index-react-server.d.mts +0 -2711
  279. package/dist/production/index-react-server.mjs +0 -3803
  280. package/dist/production/index.d.mts +0 -1479
  281. package/dist/production/index.mjs +0 -275
  282. package/dist/production/instrumentation-Dkmpzd13.d.ts +0 -715
  283. package/dist/production/lib/types/internal.d.mts +0 -184
  284. package/dist/production/lib/types/internal.mjs +0 -10
  285. package/dist/production/register-CmkRspdl.d.mts +0 -30
@@ -1,5 +1,5 @@
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 _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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.18.0
1
+ /**
2
+ * react-router v8.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -9,2554 +9,37 @@
9
9
  * @license MIT
10
10
  */
11
11
  "use client";
12
-
13
-
14
-
15
-
16
-
17
- var _chunk3Z6WS2WZjs = require('./chunk-3Z6WS2WZ.js');
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
- var _chunkBIP66BKVjs = require('./chunk-BIP66BKV.js');
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
-
157
- var _chunkIUPBOWYOjs = require('./chunk-IUPBOWYO.js');
158
-
159
- // lib/dom/ssr/server.tsx
160
- var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react); var React3 = _interopRequireWildcard(_react);
161
- function ServerRouter({
162
- context,
163
- url,
164
- nonce
165
- }) {
166
- if (typeof url === "string") {
167
- url = new URL(url);
168
- }
169
- let { manifest, routeModules, criticalCss, serverHandoffString } = context;
170
- let routes = _chunkIUPBOWYOjs.createServerRoutes.call(void 0,
171
- manifest.routes,
172
- routeModules,
173
- context.future,
174
- context.isSpaMode
175
- );
176
- context.staticHandlerContext.loaderData = {
177
- ...context.staticHandlerContext.loaderData
178
- };
179
- for (let match of context.staticHandlerContext.matches) {
180
- let routeId = match.route.id;
181
- let route = routeModules[routeId];
182
- let manifestRoute = context.manifest.routes[routeId];
183
- if (route && manifestRoute && _chunkIUPBOWYOjs.shouldHydrateRouteLoader.call(void 0,
184
- routeId,
185
- route.clientLoader,
186
- manifestRoute.hasLoader,
187
- context.isSpaMode
188
- ) && (route.HydrateFallback || !manifestRoute.hasLoader)) {
189
- delete context.staticHandlerContext.loaderData[routeId];
190
- }
191
- }
192
- let router = _chunkBIP66BKVjs.createStaticRouter.call(void 0, routes, context.staticHandlerContext, {
193
- branches: context.branches
194
- });
195
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
196
- _chunkIUPBOWYOjs.FrameworkContext.Provider,
197
- {
198
- value: {
199
- manifest,
200
- routeModules,
201
- criticalCss,
202
- serverHandoffString,
203
- future: context.future,
204
- ssr: context.ssr,
205
- isSpaMode: context.isSpaMode,
206
- routeDiscovery: context.routeDiscovery,
207
- nonce,
208
- serializeError: context.serializeError,
209
- renderMeta: context.renderMeta
210
- }
211
- },
212
- /* @__PURE__ */ React.createElement(_chunkIUPBOWYOjs.RemixErrorBoundary, { location: router.state.location }, /* @__PURE__ */ React.createElement(
213
- _chunkBIP66BKVjs.StaticRouterProvider,
214
- {
215
- router,
216
- context: context.staticHandlerContext,
217
- hydrate: false
218
- }
219
- ))
220
- ), context.serverHandoffStream ? /* @__PURE__ */ React.createElement(React.Suspense, null, /* @__PURE__ */ React.createElement(
221
- _chunkIUPBOWYOjs.StreamTransfer,
222
- {
223
- context,
224
- identifier: 0,
225
- reader: context.serverHandoffStream.getReader(),
226
- textDecoder: new TextDecoder(),
227
- nonce
228
- }
229
- )) : null);
230
- }
231
-
232
- // lib/dom/ssr/routes-test-stub.tsx
233
-
234
- function createRoutesStub(routes, _context) {
235
- return function RoutesTestStub({
236
- initialEntries,
237
- initialIndex,
238
- hydrationData,
239
- future
240
- }) {
241
- let routerRef = React2.useRef();
242
- let frameworkContextRef = React2.useRef();
243
- if (routerRef.current == null) {
244
- frameworkContextRef.current = {
245
- future: {
246
- v8_passThroughRequests: _optionalChain([future, 'optionalAccess', _2 => _2.v8_passThroughRequests]) === true,
247
- v8_middleware: _optionalChain([future, 'optionalAccess', _3 => _3.v8_middleware]) === true,
248
- v8_trailingSlashAwareDataRequests: _optionalChain([future, 'optionalAccess', _4 => _4.v8_trailingSlashAwareDataRequests]) === true
249
- },
250
- manifest: {
251
- routes: {},
252
- entry: { imports: [], module: "" },
253
- url: "",
254
- version: ""
255
- },
256
- routeModules: {},
257
- ssr: false,
258
- isSpaMode: false,
259
- routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" }
260
- };
261
- let patched = processRoutes(
262
- // @ts-expect-error `StubRouteObject` is stricter about `loader`/`action`
263
- // types compared to `RouteObject`
264
- _chunkIUPBOWYOjs.convertRoutesToDataRoutes.call(void 0, routes, (r) => r),
265
- _context !== void 0 ? _context : _optionalChain([future, 'optionalAccess', _5 => _5.v8_middleware]) ? new (0, _chunkIUPBOWYOjs.RouterContextProvider)() : {},
266
- frameworkContextRef.current.manifest,
267
- frameworkContextRef.current.routeModules
268
- );
269
- routerRef.current = _chunkIUPBOWYOjs.createMemoryRouter.call(void 0, patched, {
270
- initialEntries,
271
- initialIndex,
272
- hydrationData
273
- });
274
- }
275
- return /* @__PURE__ */ React2.createElement(_chunkIUPBOWYOjs.FrameworkContext.Provider, { value: frameworkContextRef.current }, /* @__PURE__ */ React2.createElement(_chunkIUPBOWYOjs.RouterProvider, { router: routerRef.current }));
276
- };
277
- }
278
- function processRoutes(routes, context, manifest, routeModules, parentId) {
279
- return routes.map((route) => {
280
- if (!route.id) {
281
- throw new Error(
282
- "Expected a route.id in react-router processRoutes() function"
283
- );
284
- }
285
- let newRoute = {
286
- id: route.id,
287
- path: route.path,
288
- index: route.index,
289
- Component: route.Component ? _chunkIUPBOWYOjs.withComponentProps.call(void 0, route.Component) : void 0,
290
- HydrateFallback: route.HydrateFallback ? _chunkIUPBOWYOjs.withHydrateFallbackProps.call(void 0, route.HydrateFallback) : void 0,
291
- ErrorBoundary: route.ErrorBoundary ? _chunkIUPBOWYOjs.withErrorBoundaryProps.call(void 0, route.ErrorBoundary) : void 0,
292
- action: route.action ? (args) => route.action({ ...args, context }) : void 0,
293
- loader: route.loader ? (args) => route.loader({ ...args, context }) : void 0,
294
- middleware: route.middleware ? route.middleware.map(
295
- (mw) => (...args) => mw(
296
- { ...args[0], context },
297
- args[1]
298
- )
299
- ) : void 0,
300
- handle: route.handle,
301
- shouldRevalidate: route.shouldRevalidate
302
- };
303
- let entryRoute = {
304
- id: route.id,
305
- path: route.path,
306
- index: route.index,
307
- parentId,
308
- hasAction: route.action != null,
309
- hasLoader: route.loader != null,
310
- // When testing routes, you should be stubbing loader/action/middleware,
311
- // not trying to re-implement the full loader/clientLoader/SSR/hydration
312
- // flow. That is better tested via E2E tests.
313
- hasClientAction: false,
314
- hasClientLoader: false,
315
- hasClientMiddleware: false,
316
- hasErrorBoundary: route.ErrorBoundary != null,
317
- // any need for these?
318
- module: "build/stub-path-to-module.js",
319
- clientActionModule: void 0,
320
- clientLoaderModule: void 0,
321
- clientMiddlewareModule: void 0,
322
- hydrateFallbackModule: void 0
323
- };
324
- manifest.routes[newRoute.id] = entryRoute;
325
- routeModules[route.id] = {
326
- default: newRoute.Component || _chunkIUPBOWYOjs.Outlet,
327
- ErrorBoundary: newRoute.ErrorBoundary || void 0,
328
- handle: route.handle,
329
- links: route.links,
330
- meta: route.meta,
331
- shouldRevalidate: route.shouldRevalidate
332
- };
333
- if (route.children) {
334
- newRoute.children = processRoutes(
335
- route.children,
336
- context,
337
- manifest,
338
- routeModules,
339
- newRoute.id
340
- );
341
- }
342
- return newRoute;
343
- });
344
- }
345
-
346
- // lib/server-runtime/cookies.ts
347
- var _cookie = require('cookie');
348
-
349
- // lib/server-runtime/crypto.ts
350
- var encoder = /* @__PURE__ */ new TextEncoder();
351
- var sign = async (value, secret) => {
352
- let data2 = encoder.encode(value);
353
- let key = await createKey(secret, ["sign"]);
354
- let signature = await crypto.subtle.sign("HMAC", key, data2);
355
- let hash = btoa(String.fromCharCode(...new Uint8Array(signature))).replace(
356
- /=+$/,
357
- ""
358
- );
359
- return value + "." + hash;
360
- };
361
- var unsign = async (cookie, secret) => {
362
- let index = cookie.lastIndexOf(".");
363
- let value = cookie.slice(0, index);
364
- let hash = cookie.slice(index + 1);
365
- let data2 = encoder.encode(value);
366
- let key = await createKey(secret, ["verify"]);
367
- try {
368
- let signature = byteStringToUint8Array(atob(hash));
369
- let valid = await crypto.subtle.verify("HMAC", key, signature, data2);
370
- return valid ? value : false;
371
- } catch (e) {
372
- return false;
373
- }
374
- };
375
- var createKey = async (secret, usages) => crypto.subtle.importKey(
376
- "raw",
377
- encoder.encode(secret),
378
- { name: "HMAC", hash: "SHA-256" },
379
- false,
380
- usages
381
- );
382
- function byteStringToUint8Array(byteString) {
383
- let array = new Uint8Array(byteString.length);
384
- for (let i = 0; i < byteString.length; i++) {
385
- array[i] = byteString.charCodeAt(i);
386
- }
387
- return array;
388
- }
389
-
390
- // lib/server-runtime/cookies.ts
391
- var createCookie = (name, cookieOptions = {}) => {
392
- let { secrets = [], ...options } = {
393
- path: "/",
394
- sameSite: "lax",
395
- ...cookieOptions
396
- };
397
- warnOnceAboutExpiresCookie(name, options.expires);
398
- return {
399
- get name() {
400
- return name;
401
- },
402
- get isSigned() {
403
- return secrets.length > 0;
404
- },
405
- get expires() {
406
- return typeof options.maxAge !== "undefined" ? new Date(Date.now() + options.maxAge * 1e3) : options.expires;
407
- },
408
- async parse(cookieHeader, parseOptions) {
409
- if (!cookieHeader) return null;
410
- let cookies = _cookie.parse.call(void 0, cookieHeader, { ...options, ...parseOptions });
411
- if (name in cookies) {
412
- let value = cookies[name];
413
- if (typeof value === "string" && value !== "") {
414
- let decoded = await decodeCookieValue(value, secrets);
415
- return decoded;
416
- } else {
417
- return "";
418
- }
419
- } else {
420
- return null;
421
- }
422
- },
423
- async serialize(value, serializeOptions) {
424
- return _cookie.serialize.call(void 0,
425
- name,
426
- value === "" ? "" : await encodeCookieValue(value, secrets),
427
- {
428
- ...options,
429
- ...serializeOptions
430
- }
431
- );
432
- }
433
- };
434
- };
435
- var isCookie = (object) => {
436
- return object != null && typeof object.name === "string" && typeof object.isSigned === "boolean" && typeof object.parse === "function" && typeof object.serialize === "function";
437
- };
438
- async function encodeCookieValue(value, secrets) {
439
- let encoded = encodeData(value);
440
- if (secrets.length > 0) {
441
- encoded = await sign(encoded, secrets[0]);
442
- }
443
- return encoded;
444
- }
445
- async function decodeCookieValue(value, secrets) {
446
- if (secrets.length > 0) {
447
- for (let secret of secrets) {
448
- let unsignedValue = await unsign(value, secret);
449
- if (unsignedValue !== false) {
450
- return decodeData(unsignedValue);
451
- }
452
- }
453
- return null;
454
- }
455
- return decodeData(value);
456
- }
457
- function encodeData(value) {
458
- return btoa(myUnescape(encodeURIComponent(JSON.stringify(value))));
459
- }
460
- function decodeData(value) {
461
- try {
462
- return JSON.parse(decodeURIComponent(myEscape(atob(value))));
463
- } catch (e) {
464
- return {};
465
- }
466
- }
467
- function myEscape(value) {
468
- let str = value.toString();
469
- let result = "";
470
- let index = 0;
471
- let chr, code;
472
- while (index < str.length) {
473
- chr = str.charAt(index++);
474
- if (/[\w*+\-./@]/.exec(chr)) {
475
- result += chr;
476
- } else {
477
- code = chr.charCodeAt(0);
478
- if (code < 256) {
479
- result += "%" + hex(code, 2);
480
- } else {
481
- result += "%u" + hex(code, 4).toUpperCase();
482
- }
483
- }
484
- }
485
- return result;
486
- }
487
- function hex(code, length) {
488
- let result = code.toString(16);
489
- while (result.length < length) result = "0" + result;
490
- return result;
491
- }
492
- function myUnescape(value) {
493
- let str = value.toString();
494
- let result = "";
495
- let index = 0;
496
- let chr, part;
497
- while (index < str.length) {
498
- chr = str.charAt(index++);
499
- if (chr === "%") {
500
- if (str.charAt(index) === "u") {
501
- part = str.slice(index + 1, index + 5);
502
- if (/^[\da-f]{4}$/i.exec(part)) {
503
- result += String.fromCharCode(parseInt(part, 16));
504
- index += 5;
505
- continue;
506
- }
507
- } else {
508
- part = str.slice(index, index + 2);
509
- if (/^[\da-f]{2}$/i.exec(part)) {
510
- result += String.fromCharCode(parseInt(part, 16));
511
- index += 2;
512
- continue;
513
- }
514
- }
515
- }
516
- result += chr;
517
- }
518
- return result;
519
- }
520
- function warnOnceAboutExpiresCookie(name, expires) {
521
- _chunkIUPBOWYOjs.warnOnce.call(void 0,
522
- !expires,
523
- `The "${name}" cookie has an "expires" property set. This will cause the expires value to not be updated when the session is committed. Instead, you should set the expires value when serializing the cookie. You can use \`commitSession(session, { expires })\` if using a session storage object, or \`cookie.serialize("value", { expires })\` if you're using the cookie directly.`
524
- );
525
- }
526
-
527
- // lib/server-runtime/entry.ts
528
- function createEntryRouteModules(manifest) {
529
- return Object.keys(manifest).reduce((memo, routeId) => {
530
- let route = manifest[routeId];
531
- if (route) {
532
- memo[routeId] = route.module;
533
- }
534
- return memo;
535
- }, {});
536
- }
537
-
538
- // lib/server-runtime/mode.ts
539
- var ServerMode = /* @__PURE__ */ ((ServerMode2) => {
540
- ServerMode2["Development"] = "development";
541
- ServerMode2["Production"] = "production";
542
- ServerMode2["Test"] = "test";
543
- return ServerMode2;
544
- })(ServerMode || {});
545
- function isServerMode(value) {
546
- return value === "development" /* Development */ || value === "production" /* Production */ || value === "test" /* Test */;
547
- }
548
-
549
- // lib/server-runtime/errors.ts
550
- function sanitizeError(error, serverMode) {
551
- if (error instanceof Error && serverMode !== "development" /* Development */) {
552
- let sanitized = new Error("Unexpected Server Error");
553
- sanitized.stack = void 0;
554
- return sanitized;
555
- }
556
- return error;
557
- }
558
- function sanitizeErrors(errors, serverMode) {
559
- return Object.entries(errors).reduce((acc, [routeId, error]) => {
560
- return Object.assign(acc, { [routeId]: sanitizeError(error, serverMode) });
561
- }, {});
562
- }
563
- function serializeError(error, serverMode) {
564
- let sanitized = sanitizeError(error, serverMode);
565
- return {
566
- message: sanitized.message,
567
- stack: sanitized.stack
568
- };
569
- }
570
-
571
- // lib/server-runtime/invariant.ts
572
- function invariant2(value, message) {
573
- if (value === false || value === null || typeof value === "undefined") {
574
- console.error(
575
- "The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"
576
- );
577
- throw new Error(message);
578
- }
579
- }
580
-
581
- // lib/server-runtime/routeMatching.ts
582
- function matchServerRoutes(manifest, dataRoutes, branches, pathname, basename) {
583
- let matches = _chunkIUPBOWYOjs.matchRoutesImpl.call(void 0,
584
- dataRoutes,
585
- pathname,
586
- _nullishCoalesce(basename, () => ( "/")),
587
- false,
588
- branches
589
- );
590
- if (!matches) return null;
591
- return matches.map((match) => {
592
- let route = manifest[match.route.id];
593
- invariant2(
594
- route,
595
- `Route with id "${match.route.id}" not found in manifest.`
596
- );
597
- return {
598
- params: match.params,
599
- pathname: match.pathname,
600
- route
601
- };
602
- });
603
- }
604
-
605
- // lib/server-runtime/data.ts
606
- async function callRouteHandler(handler, args, future) {
607
- let result = await handler({
608
- request: future.v8_passThroughRequests ? args.request : stripRoutesParam(stripIndexParam(args.request)),
609
- url: args.url,
610
- params: args.params,
611
- context: args.context,
612
- pattern: args.pattern
613
- });
614
- if (_chunkIUPBOWYOjs.isDataWithResponseInit.call(void 0, result) && result.init && result.init.status && _chunkIUPBOWYOjs.isRedirectStatusCode.call(void 0, result.init.status)) {
615
- throw new Response(null, result.init);
616
- }
617
- return result;
618
- }
619
- function stripIndexParam(request) {
620
- let url = new URL(request.url);
621
- let indexValues = url.searchParams.getAll("index");
622
- url.searchParams.delete("index");
623
- let indexValuesToKeep = [];
624
- for (let indexValue of indexValues) {
625
- if (indexValue) {
626
- indexValuesToKeep.push(indexValue);
627
- }
628
- }
629
- for (let toKeep of indexValuesToKeep) {
630
- url.searchParams.append("index", toKeep);
631
- }
632
- let init = {
633
- method: request.method,
634
- body: request.body,
635
- headers: request.headers,
636
- signal: request.signal
637
- };
638
- if (init.body) {
639
- init.duplex = "half";
640
- }
641
- return new Request(url.href, init);
642
- }
643
- function stripRoutesParam(request) {
644
- let url = new URL(request.url);
645
- url.searchParams.delete("_routes");
646
- let init = {
647
- method: request.method,
648
- body: request.body,
649
- headers: request.headers,
650
- signal: request.signal
651
- };
652
- if (init.body) {
653
- init.duplex = "half";
654
- }
655
- return new Request(url.href, init);
656
- }
657
-
658
- // lib/server-runtime/dev.ts
659
- var globalDevServerHooksKey = "__reactRouterDevServerHooks";
660
- function setDevServerHooks(devServerHooks) {
661
- globalThis[globalDevServerHooksKey] = devServerHooks;
662
- }
663
- function getDevServerHooks() {
664
- return globalThis[globalDevServerHooksKey];
665
- }
666
- function getBuildTimeHeader(request, headerName) {
667
- if (typeof process !== "undefined") {
668
- try {
669
- if (process.env.hasOwnProperty("IS_RR_BUILD_REQUEST") && process.env.IS_RR_BUILD_REQUEST === "yes") {
670
- return request.headers.get(headerName);
671
- }
672
- } catch (e) {
673
- }
674
- }
675
- return null;
676
- }
677
-
678
- // lib/server-runtime/routes.ts
679
- function groupRoutesByParentId(manifest) {
680
- let routes = {};
681
- Object.values(manifest).forEach((route) => {
682
- if (route) {
683
- let parentId = route.parentId || "";
684
- if (!routes[parentId]) {
685
- routes[parentId] = [];
686
- }
687
- routes[parentId].push(route);
688
- }
689
- });
690
- return routes;
691
- }
692
- function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesByParentId = groupRoutesByParentId(manifest)) {
693
- return (routesByParentId[parentId] || []).map((route) => {
694
- let commonRoute = {
695
- // Always include root due to default boundaries
696
- hasErrorBoundary: route.id === "root" || route.module.ErrorBoundary != null,
697
- id: route.id,
698
- path: route.path,
699
- middleware: route.module.middleware,
700
- // Need to use RR's version in the param typed here to permit the optional
701
- // context even though we know it'll always be provided in remix
702
- loader: route.module.loader ? async (args) => {
703
- let preRenderedData = getBuildTimeHeader(
704
- args.request,
705
- "X-React-Router-Prerender-Data"
706
- );
707
- if (preRenderedData != null) {
708
- let encoded = preRenderedData ? decodeURI(preRenderedData) : preRenderedData;
709
- invariant2(encoded, "Missing prerendered data for route");
710
- let uint8array = new TextEncoder().encode(encoded);
711
- let stream = new ReadableStream({
712
- start(controller) {
713
- controller.enqueue(uint8array);
714
- controller.close();
715
- }
716
- });
717
- let decoded = await _chunkIUPBOWYOjs.decodeViaTurboStream.call(void 0, stream, global);
718
- let data2 = decoded.value;
719
- if (data2 && _chunkIUPBOWYOjs.SingleFetchRedirectSymbol in data2) {
720
- let result = data2[_chunkIUPBOWYOjs.SingleFetchRedirectSymbol];
721
- let init = { status: result.status };
722
- if (result.reload) {
723
- throw _chunkIUPBOWYOjs.redirectDocument.call(void 0, result.redirect, init);
724
- } else if (result.replace) {
725
- throw _chunkIUPBOWYOjs.replace.call(void 0, result.redirect, init);
726
- } else {
727
- throw _chunkIUPBOWYOjs.redirect.call(void 0, result.redirect, init);
728
- }
729
- } else {
730
- invariant2(
731
- data2 && route.id in data2,
732
- "Unable to decode prerendered data"
733
- );
734
- let result = data2[route.id];
735
- invariant2(
736
- "data" in result,
737
- "Unable to process prerendered data"
738
- );
739
- return result.data;
740
- }
741
- }
742
- let val = await callRouteHandler(
743
- route.module.loader,
744
- args,
745
- future
746
- );
747
- return val;
748
- } : void 0,
749
- action: route.module.action ? (args) => callRouteHandler(route.module.action, args, future) : void 0,
750
- handle: route.module.handle
751
- };
752
- return route.index ? {
753
- index: true,
754
- ...commonRoute
755
- } : {
756
- caseSensitive: route.caseSensitive,
757
- children: createStaticHandlerDataRoutes(
758
- manifest,
759
- future,
760
- route.id,
761
- routesByParentId
762
- ),
763
- ...commonRoute
764
- };
765
- });
766
- }
767
-
768
- // lib/server-runtime/serverHandoff.ts
769
- function createServerHandoffString(serverHandoff) {
770
- return _chunkIUPBOWYOjs.escapeHtml.call(void 0, JSON.stringify(serverHandoff));
771
- }
772
-
773
- // lib/server-runtime/headers.ts
774
- var _setcookieparser = require('set-cookie-parser');
775
- function getDocumentHeaders(context, build) {
776
- return getDocumentHeadersImpl(context, (m) => {
777
- let route = build.routes[m.route.id];
778
- invariant2(route, `Route with id "${m.route.id}" not found in build`);
779
- return route.module.headers;
780
- });
781
- }
782
- function getDocumentHeadersImpl(context, getRouteHeadersFn, _defaultHeaders) {
783
- let boundaryIdx = context.errors ? context.matches.findIndex((m) => context.errors[m.route.id]) : -1;
784
- let matches = boundaryIdx >= 0 ? context.matches.slice(0, boundaryIdx + 1) : context.matches;
785
- let errorHeaders;
786
- if (boundaryIdx >= 0) {
787
- let { actionHeaders, actionData, loaderHeaders, loaderData } = context;
788
- context.matches.slice(boundaryIdx).some((match) => {
789
- let id = match.route.id;
790
- if (actionHeaders[id] && (!actionData || !actionData.hasOwnProperty(id))) {
791
- errorHeaders = actionHeaders[id];
792
- } else if (loaderHeaders[id] && !loaderData.hasOwnProperty(id)) {
793
- errorHeaders = loaderHeaders[id];
794
- }
795
- return errorHeaders != null;
796
- });
797
- }
798
- const defaultHeaders = new Headers(_defaultHeaders);
799
- return matches.reduce((parentHeaders, match, idx) => {
800
- let { id } = match.route;
801
- let loaderHeaders = context.loaderHeaders[id] || new Headers();
802
- let actionHeaders = context.actionHeaders[id] || new Headers();
803
- let includeErrorHeaders = errorHeaders != null && idx === matches.length - 1;
804
- let includeErrorCookies = includeErrorHeaders && errorHeaders !== loaderHeaders && errorHeaders !== actionHeaders;
805
- let headersFn = getRouteHeadersFn(match);
806
- if (headersFn == null) {
807
- let headers2 = new Headers(parentHeaders);
808
- if (includeErrorCookies) {
809
- prependCookies(errorHeaders, headers2);
810
- }
811
- prependCookies(actionHeaders, headers2);
812
- prependCookies(loaderHeaders, headers2);
813
- return headers2;
814
- }
815
- let headers = new Headers(
816
- typeof headersFn === "function" ? headersFn({
817
- loaderHeaders,
818
- parentHeaders,
819
- actionHeaders,
820
- errorHeaders: includeErrorHeaders ? errorHeaders : void 0
821
- }) : headersFn
822
- );
823
- if (includeErrorCookies) {
824
- prependCookies(errorHeaders, headers);
825
- }
826
- prependCookies(actionHeaders, headers);
827
- prependCookies(loaderHeaders, headers);
828
- prependCookies(parentHeaders, headers);
829
- return headers;
830
- }, new Headers(defaultHeaders));
831
- }
832
- function prependCookies(parentHeaders, childHeaders) {
833
- let parentSetCookieString = parentHeaders.get("Set-Cookie");
834
- if (parentSetCookieString) {
835
- let cookies = _setcookieparser.splitCookiesString.call(void 0, parentSetCookieString);
836
- let childCookies = new Set(childHeaders.getSetCookie());
837
- cookies.forEach((cookie) => {
838
- if (!childCookies.has(cookie)) {
839
- childHeaders.append("Set-Cookie", cookie);
840
- }
841
- });
842
- }
843
- }
844
-
845
- // lib/actions.ts
846
- function throwIfPotentialCSRFAttack(request, allowedActionOrigins) {
847
- let originHeader = request.headers.get("origin");
848
- let originDomain = null;
849
- try {
850
- originDomain = typeof originHeader === "string" && originHeader !== "null" ? new URL(originHeader).host : originHeader;
851
- } catch (e2) {
852
- throw new Error(
853
- `\`origin\` header is not a valid URL. Aborting the action.`
854
- );
855
- }
856
- let host = new URL(request.url).host;
857
- if (originDomain && originDomain !== host) {
858
- if (!isAllowedOrigin(originDomain, allowedActionOrigins)) {
859
- throw new Error(
860
- "The `request.url` host does not match `origin` header from a forwarded action request. Aborting the action."
861
- );
862
- }
863
- }
864
- }
865
- function matchWildcardDomain(domain, pattern) {
866
- const domainParts = domain.split(".");
867
- const patternParts = pattern.split(".");
868
- if (patternParts.length < 1) {
869
- return false;
870
- }
871
- if (domainParts.length < patternParts.length) {
872
- return false;
873
- }
874
- while (patternParts.length) {
875
- const patternPart = patternParts.pop();
876
- const domainPart = domainParts.pop();
877
- switch (patternPart) {
878
- case "": {
879
- return false;
880
- }
881
- case "*": {
882
- if (domainPart) {
883
- continue;
884
- } else {
885
- return false;
886
- }
887
- }
888
- case "**": {
889
- if (patternParts.length > 0) {
890
- return false;
891
- }
892
- return domainPart !== void 0;
893
- }
894
- case void 0:
895
- default: {
896
- if (domainPart !== patternPart) {
897
- return false;
898
- }
899
- }
900
- }
901
- }
902
- return domainParts.length === 0;
903
- }
904
- function isAllowedOrigin(originDomain, allowedActionOrigins = []) {
905
- return allowedActionOrigins.some(
906
- (allowedOrigin) => allowedOrigin && (allowedOrigin === originDomain || matchWildcardDomain(originDomain, allowedOrigin))
907
- );
908
- }
909
-
910
- // lib/server-runtime/urls.ts
911
- function getNormalizedPath(request, basename, future) {
912
- basename = basename || "/";
913
- let url = new URL(request.url);
914
- let pathname = url.pathname;
915
- if (_optionalChain([future, 'optionalAccess', _6 => _6.v8_trailingSlashAwareDataRequests])) {
916
- if (pathname.endsWith("/_.data")) {
917
- pathname = pathname.replace(/_\.data$/, "");
918
- } else {
919
- pathname = pathname.replace(/\.data$/, "");
920
- }
921
- } else {
922
- if (_chunkIUPBOWYOjs.stripBasename.call(void 0, pathname, basename) === "/_root.data") {
923
- pathname = basename;
924
- } else if (pathname.endsWith(".data")) {
925
- pathname = pathname.replace(/\.data$/, "");
926
- }
927
- if (_chunkIUPBOWYOjs.stripBasename.call(void 0, pathname, basename) !== "/" && pathname.endsWith("/")) {
928
- pathname = pathname.slice(0, -1);
929
- }
930
- }
931
- let searchParams = new URLSearchParams(url.search);
932
- searchParams.delete("_routes");
933
- let search = searchParams.toString();
934
- if (search) {
935
- search = `?${search}`;
936
- }
937
- return {
938
- pathname,
939
- search,
940
- // No hashes on the server
941
- hash: ""
942
- };
943
- }
944
-
945
- // lib/server-runtime/single-fetch.ts
946
- var SERVER_NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([
947
- ..._chunkIUPBOWYOjs.NO_BODY_STATUS_CODES,
948
- 304
949
- ]);
950
- async function singleFetchAction(build, serverMode, staticHandler, request, handlerUrl, loadContext, handleError) {
951
- try {
952
- try {
953
- throwIfPotentialCSRFAttack(
954
- request,
955
- Array.isArray(build.allowedActionOrigins) ? build.allowedActionOrigins : []
956
- );
957
- } catch (e) {
958
- return handleQueryError(new Error("Bad Request"), 400);
959
- }
960
- let handlerRequest = build.future.v8_passThroughRequests ? request : new Request(handlerUrl, {
961
- method: request.method,
962
- body: request.body,
963
- headers: request.headers,
964
- signal: request.signal,
965
- ...request.body ? { duplex: "half" } : void 0
966
- });
967
- let result = await staticHandler.query(handlerRequest, {
968
- requestContext: loadContext,
969
- skipLoaderErrorBubbling: true,
970
- skipRevalidation: true,
971
- generateMiddlewareResponse: build.future.v8_middleware ? async (query) => {
972
- try {
973
- let innerResult = await query(handlerRequest);
974
- return handleQueryResult(innerResult);
975
- } catch (error) {
976
- return handleQueryError(error);
977
- }
978
- } : void 0,
979
- normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
980
- });
981
- return handleQueryResult(result);
982
- } catch (error) {
983
- return handleQueryError(error);
984
- }
985
- function handleQueryResult(result) {
986
- return _chunkIUPBOWYOjs.isResponse.call(void 0, result) ? result : staticContextToResponse(result);
987
- }
988
- function handleQueryError(error, status = 500) {
989
- handleError(error);
990
- return generateSingleFetchResponse(request, build, serverMode, {
991
- result: { error },
992
- headers: new Headers(),
993
- status
994
- });
995
- }
996
- function staticContextToResponse(context) {
997
- let headers = getDocumentHeaders(context, build);
998
- if (_chunkIUPBOWYOjs.isRedirectStatusCode.call(void 0, context.statusCode) && headers.has("Location")) {
999
- return new Response(null, { status: context.statusCode, headers });
1000
- }
1001
- if (context.errors) {
1002
- Object.values(context.errors).forEach((err) => {
1003
- if (!_chunkIUPBOWYOjs.isRouteErrorResponse.call(void 0, err) || err.error) {
1004
- handleError(err);
1005
- }
1006
- });
1007
- context.errors = sanitizeErrors(context.errors, serverMode);
1008
- }
1009
- let singleFetchResult;
1010
- if (context.errors) {
1011
- singleFetchResult = { error: Object.values(context.errors)[0] };
1012
- } else {
1013
- singleFetchResult = {
1014
- data: Object.values(context.actionData || {})[0]
1015
- };
1016
- }
1017
- return generateSingleFetchResponse(request, build, serverMode, {
1018
- result: singleFetchResult,
1019
- headers,
1020
- status: context.statusCode
1021
- });
1022
- }
1023
- }
1024
- async function singleFetchLoaders(build, serverMode, staticHandler, request, handlerUrl, loadContext, handleError) {
1025
- let routesParam = new URL(request.url).searchParams.get("_routes");
1026
- let loadRouteIds = routesParam ? new Set(routesParam.split(",")) : null;
1027
- try {
1028
- let handlerRequest = build.future.v8_passThroughRequests ? request : new Request(handlerUrl, {
1029
- headers: request.headers,
1030
- signal: request.signal
1031
- });
1032
- let result = await staticHandler.query(handlerRequest, {
1033
- requestContext: loadContext,
1034
- filterMatchesToLoad: (m) => !loadRouteIds || loadRouteIds.has(m.route.id),
1035
- skipLoaderErrorBubbling: true,
1036
- generateMiddlewareResponse: build.future.v8_middleware ? async (query) => {
1037
- try {
1038
- let innerResult = await query(handlerRequest);
1039
- return handleQueryResult(innerResult);
1040
- } catch (error) {
1041
- return handleQueryError(error);
1042
- }
1043
- } : void 0,
1044
- normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
1045
- });
1046
- return handleQueryResult(result);
1047
- } catch (error) {
1048
- return handleQueryError(error);
1049
- }
1050
- function handleQueryResult(result) {
1051
- return _chunkIUPBOWYOjs.isResponse.call(void 0, result) ? result : staticContextToResponse(result);
1052
- }
1053
- function handleQueryError(error) {
1054
- handleError(error);
1055
- return generateSingleFetchResponse(request, build, serverMode, {
1056
- result: { error },
1057
- headers: new Headers(),
1058
- status: 500
1059
- });
1060
- }
1061
- function staticContextToResponse(context) {
1062
- let headers = getDocumentHeaders(context, build);
1063
- if (_chunkIUPBOWYOjs.isRedirectStatusCode.call(void 0, context.statusCode) && headers.has("Location")) {
1064
- return new Response(null, { status: context.statusCode, headers });
1065
- }
1066
- if (context.errors) {
1067
- Object.values(context.errors).forEach((err) => {
1068
- if (!_chunkIUPBOWYOjs.isRouteErrorResponse.call(void 0, err) || err.error) {
1069
- handleError(err);
1070
- }
1071
- });
1072
- context.errors = sanitizeErrors(context.errors, serverMode);
1073
- }
1074
- let results = {};
1075
- let loadedMatches = new Set(
1076
- context.matches.filter(
1077
- (m) => loadRouteIds ? loadRouteIds.has(m.route.id) : m.route.loader != null
1078
- ).map((m) => m.route.id)
1079
- );
1080
- if (context.errors) {
1081
- for (let [id, error] of Object.entries(context.errors)) {
1082
- results[id] = { error };
1083
- }
1084
- }
1085
- for (let [id, data2] of Object.entries(context.loaderData)) {
1086
- if (!(id in results) && loadedMatches.has(id)) {
1087
- results[id] = { data: data2 };
1088
- }
1089
- }
1090
- return generateSingleFetchResponse(request, build, serverMode, {
1091
- result: results,
1092
- headers,
1093
- status: context.statusCode
1094
- });
1095
- }
1096
- }
1097
- function generateSingleFetchResponse(request, build, serverMode, {
1098
- result,
1099
- headers,
1100
- status
1101
- }) {
1102
- let resultHeaders = new Headers(headers);
1103
- resultHeaders.set("X-Remix-Response", "yes");
1104
- if (SERVER_NO_BODY_STATUS_CODES.has(status)) {
1105
- return new Response(null, { status, headers: resultHeaders });
1106
- }
1107
- resultHeaders.set("Content-Type", "text/x-script");
1108
- resultHeaders.delete("Content-Length");
1109
- return new Response(
1110
- encodeViaTurboStream(
1111
- result,
1112
- request.signal,
1113
- build.entry.module.streamTimeout,
1114
- serverMode
1115
- ),
1116
- {
1117
- status: status || 200,
1118
- headers: resultHeaders
1119
- }
1120
- );
1121
- }
1122
- function generateSingleFetchRedirectResponse(redirectResponse, request, build, serverMode) {
1123
- let redirect2 = getSingleFetchRedirect(
1124
- redirectResponse.status,
1125
- redirectResponse.headers,
1126
- build.basename
1127
- );
1128
- let headers = new Headers(redirectResponse.headers);
1129
- headers.delete("Location");
1130
- headers.set("Content-Type", "text/x-script");
1131
- return generateSingleFetchResponse(request, build, serverMode, {
1132
- result: request.method === "GET" ? { [_chunkIUPBOWYOjs.SingleFetchRedirectSymbol]: redirect2 } : redirect2,
1133
- headers,
1134
- status: _chunkIUPBOWYOjs.SINGLE_FETCH_REDIRECT_STATUS
1135
- });
1136
- }
1137
- function getSingleFetchRedirect(status, headers, basename) {
1138
- let redirect2 = headers.get("Location");
1139
- if (basename) {
1140
- redirect2 = _chunkIUPBOWYOjs.stripBasename.call(void 0, redirect2, basename) || redirect2;
1141
- }
1142
- return {
1143
- redirect: redirect2,
1144
- status,
1145
- revalidate: (
1146
- // Technically X-Remix-Revalidate isn't needed here - that was an implementation
1147
- // detail of ?_data requests as our way to tell the front end to revalidate when
1148
- // we didn't have a response body to include that information in.
1149
- // With single fetch, we tell the front end via this revalidate boolean field.
1150
- // However, we're respecting it for now because it may be something folks have
1151
- // used in their own responses
1152
- // TODO(v3): Consider removing or making this official public API
1153
- headers.has("X-Remix-Revalidate") || headers.has("Set-Cookie")
1154
- ),
1155
- reload: headers.has("X-Remix-Reload-Document"),
1156
- replace: headers.has("X-Remix-Replace")
1157
- };
1158
- }
1159
- function encodeViaTurboStream(data2, requestSignal, streamTimeout, serverMode) {
1160
- let controller = new AbortController();
1161
- let timeoutId = setTimeout(
1162
- () => {
1163
- controller.abort(new Error("Server Timeout"));
1164
- cleanupCallbacks();
1165
- },
1166
- typeof streamTimeout === "number" ? streamTimeout : 4950
1167
- );
1168
- let abortControllerOnRequestAbort = () => {
1169
- controller.abort(requestSignal.reason);
1170
- cleanupCallbacks();
1171
- };
1172
- requestSignal.addEventListener("abort", abortControllerOnRequestAbort);
1173
- let cleanupCallbacks = () => {
1174
- clearTimeout(timeoutId);
1175
- requestSignal.removeEventListener("abort", abortControllerOnRequestAbort);
1176
- };
1177
- return _chunkIUPBOWYOjs.encode.call(void 0, data2, {
1178
- signal: controller.signal,
1179
- onComplete: cleanupCallbacks,
1180
- plugins: [
1181
- (value) => {
1182
- if (value instanceof Error) {
1183
- let { name, message, stack } = serverMode === "production" /* Production */ ? sanitizeError(value, serverMode) : value;
1184
- return ["SanitizedError", name, message, stack];
1185
- }
1186
- if (value instanceof _chunkIUPBOWYOjs.ErrorResponseImpl) {
1187
- let { data: data3, status, statusText } = value;
1188
- return ["ErrorResponse", data3, status, statusText];
1189
- }
1190
- if (value && typeof value === "object" && _chunkIUPBOWYOjs.SingleFetchRedirectSymbol in value) {
1191
- return ["SingleFetchRedirect", value[_chunkIUPBOWYOjs.SingleFetchRedirectSymbol]];
1192
- }
1193
- }
1194
- ],
1195
- postPlugins: [
1196
- (value) => {
1197
- if (!value) return;
1198
- if (typeof value !== "object") return;
1199
- return [
1200
- "SingleFetchClassInstance",
1201
- Object.fromEntries(Object.entries(value))
1202
- ];
1203
- },
1204
- () => ["SingleFetchFallback"]
1205
- ]
1206
- });
1207
- }
1208
-
1209
- // lib/server-runtime/server.ts
1210
- function derive(build, mode) {
1211
- let dataRoutes = createStaticHandlerDataRoutes(build.routes, build.future);
1212
- let serverMode = isServerMode(mode) ? mode : "production" /* Production */;
1213
- let staticHandler = _chunkIUPBOWYOjs.createStaticHandler.call(void 0, dataRoutes, {
1214
- basename: build.basename,
1215
- instrumentations: build.entry.module.instrumentations,
1216
- future: build.future
1217
- });
1218
- let errorHandler = build.entry.module.handleError || ((error, { request }) => {
1219
- if (serverMode !== "test" /* Test */ && !request.signal.aborted) {
1220
- console.error(
1221
- // @ts-expect-error This is "private" from users but intended for internal use
1222
- _chunkIUPBOWYOjs.isRouteErrorResponse.call(void 0, error) && error.error ? error.error : error
1223
- );
1224
- }
1225
- });
1226
- let requestHandler = async (request, initialContext) => {
1227
- let params = {};
1228
- let loadContext;
1229
- let handleError = (error) => {
1230
- if (mode === "development" /* Development */) {
1231
- _optionalChain([getDevServerHooks, 'call', _7 => _7(), 'optionalAccess', _8 => _8.processRequestError, 'optionalCall', _9 => _9(error)]);
1232
- }
1233
- errorHandler(error, {
1234
- context: loadContext,
1235
- params,
1236
- request
1237
- });
1238
- };
1239
- if (build.future.v8_middleware) {
1240
- if (initialContext && !(initialContext instanceof _chunkIUPBOWYOjs.RouterContextProvider)) {
1241
- let error = new Error(
1242
- "Invalid `context` value provided to `handleRequest`. When middleware is enabled you must return an instance of `RouterContextProvider` from your `getLoadContext` function."
1243
- );
1244
- handleError(error);
1245
- return returnLastResortErrorResponse(error, serverMode);
1246
- }
1247
- loadContext = initialContext || new (0, _chunkIUPBOWYOjs.RouterContextProvider)();
1248
- } else {
1249
- loadContext = initialContext || {};
1250
- }
1251
- let requestUrl = new URL(request.url);
1252
- let normalizedPathname = getNormalizedPath(
1253
- request,
1254
- build.basename,
1255
- build.future
1256
- ).pathname;
1257
- let isSpaMode = getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes";
1258
- if (!build.ssr) {
1259
- let decodedPath = decodeURI(normalizedPathname);
1260
- if (build.basename && build.basename !== "/") {
1261
- let strippedPath = _chunkIUPBOWYOjs.stripBasename.call(void 0, decodedPath, build.basename);
1262
- if (strippedPath == null) {
1263
- errorHandler(
1264
- new (0, _chunkIUPBOWYOjs.ErrorResponseImpl)(
1265
- 404,
1266
- "Not Found",
1267
- `Refusing to prerender the \`${decodedPath}\` path because it does not start with the basename \`${build.basename}\``
1268
- ),
1269
- {
1270
- context: loadContext,
1271
- params,
1272
- request
1273
- }
1274
- );
1275
- return new Response("Not Found", {
1276
- status: 404,
1277
- statusText: "Not Found"
1278
- });
1279
- }
1280
- decodedPath = strippedPath;
1281
- }
1282
- if (build.prerender.length === 0) {
1283
- isSpaMode = true;
1284
- } else if (!build.prerender.includes(decodedPath.replace(/\/$/, "")) && !build.prerender.includes(decodedPath.replace(/[^/]$/, "/"))) {
1285
- if (requestUrl.pathname.endsWith(".data")) {
1286
- errorHandler(
1287
- new (0, _chunkIUPBOWYOjs.ErrorResponseImpl)(
1288
- 404,
1289
- "Not Found",
1290
- `Refusing to SSR the path \`${decodedPath}\` because \`ssr:false\` is set and the path is not included in the \`prerender\` config, so in production the path will be a 404.`
1291
- ),
1292
- {
1293
- context: loadContext,
1294
- params,
1295
- request
1296
- }
1297
- );
1298
- return new Response("Not Found", {
1299
- status: 404,
1300
- statusText: "Not Found"
1301
- });
1302
- } else {
1303
- isSpaMode = true;
1304
- }
1305
- }
1306
- }
1307
- let manifestUrl = _chunkIUPBOWYOjs.getManifestPath.call(void 0,
1308
- build.routeDiscovery.manifestPath,
1309
- build.basename
1310
- );
1311
- if (build.routeDiscovery.mode === "lazy" && requestUrl.pathname === manifestUrl) {
1312
- try {
1313
- let res = await handleManifestRequest(
1314
- build,
1315
- staticHandler.dataRoutes,
1316
- staticHandler._internalRouteBranches,
1317
- requestUrl
1318
- );
1319
- return res;
1320
- } catch (e) {
1321
- handleError(e);
1322
- return new Response("Unknown Server Error", { status: 500 });
1323
- }
1324
- }
1325
- let matches = matchServerRoutes(
1326
- build.routes,
1327
- staticHandler.dataRoutes,
1328
- staticHandler._internalRouteBranches,
1329
- normalizedPathname,
1330
- build.basename
1331
- );
1332
- if (matches && matches.length > 0) {
1333
- Object.assign(params, matches[0].params);
1334
- }
1335
- let response;
1336
- if (requestUrl.pathname.endsWith(".data")) {
1337
- response = await handleSingleFetchRequest(
1338
- serverMode,
1339
- build,
1340
- staticHandler,
1341
- request,
1342
- normalizedPathname,
1343
- loadContext,
1344
- handleError
1345
- );
1346
- if (_chunkIUPBOWYOjs.isRedirectResponse.call(void 0, response)) {
1347
- response = generateSingleFetchRedirectResponse(
1348
- response,
1349
- request,
1350
- build,
1351
- serverMode
1352
- );
1353
- }
1354
- if (build.entry.module.handleDataRequest) {
1355
- response = await build.entry.module.handleDataRequest(response, {
1356
- context: loadContext,
1357
- params: matches ? matches[0].params : {},
1358
- request
1359
- });
1360
- if (_chunkIUPBOWYOjs.isRedirectResponse.call(void 0, response)) {
1361
- response = generateSingleFetchRedirectResponse(
1362
- response,
1363
- request,
1364
- build,
1365
- serverMode
1366
- );
1367
- }
1368
- }
1369
- } else if (!isSpaMode && matches && matches[matches.length - 1].route.module.default == null && matches[matches.length - 1].route.module.ErrorBoundary == null) {
1370
- response = await handleResourceRequest(
1371
- serverMode,
1372
- build,
1373
- staticHandler,
1374
- matches.slice(-1)[0].route.id,
1375
- request,
1376
- loadContext,
1377
- handleError
1378
- );
1379
- } else {
1380
- let { pathname } = requestUrl;
1381
- let criticalCss = void 0;
1382
- if (build.unstable_getCriticalCss) {
1383
- criticalCss = await build.unstable_getCriticalCss({ pathname });
1384
- } else if (mode === "development" /* Development */ && _optionalChain([getDevServerHooks, 'call', _10 => _10(), 'optionalAccess', _11 => _11.getCriticalCss])) {
1385
- criticalCss = await _optionalChain([getDevServerHooks, 'call', _12 => _12(), 'optionalAccess', _13 => _13.getCriticalCss, 'optionalCall', _14 => _14(pathname)]);
1386
- }
1387
- response = await handleDocumentRequest(
1388
- serverMode,
1389
- build,
1390
- staticHandler,
1391
- request,
1392
- loadContext,
1393
- handleError,
1394
- isSpaMode,
1395
- criticalCss
1396
- );
1397
- }
1398
- if (request.method === "HEAD") {
1399
- return new Response(null, {
1400
- headers: response.headers,
1401
- status: response.status,
1402
- statusText: response.statusText
1403
- });
1404
- }
1405
- return response;
1406
- };
1407
- if (build.entry.module.instrumentations) {
1408
- requestHandler = _chunkIUPBOWYOjs.instrumentHandler.call(void 0,
1409
- requestHandler,
1410
- build.entry.module.instrumentations.map((i) => i.handler).filter(Boolean)
1411
- );
1412
- }
1413
- return {
1414
- serverMode,
1415
- staticHandler,
1416
- errorHandler,
1417
- requestHandler
1418
- };
1419
- }
1420
- var createRequestHandler = (build, mode) => {
1421
- let _build;
1422
- let serverMode;
1423
- let staticHandler;
1424
- let errorHandler;
1425
- let _requestHandler;
1426
- return async function requestHandler(request, initialContext) {
1427
- _build = typeof build === "function" ? await build() : build;
1428
- if (typeof build === "function") {
1429
- let derived = derive(_build, mode);
1430
- serverMode = derived.serverMode;
1431
- staticHandler = derived.staticHandler;
1432
- errorHandler = derived.errorHandler;
1433
- _requestHandler = derived.requestHandler;
1434
- } else if (!serverMode || !staticHandler || !errorHandler || !_requestHandler) {
1435
- let derived = derive(_build, mode);
1436
- serverMode = derived.serverMode;
1437
- staticHandler = derived.staticHandler;
1438
- errorHandler = derived.errorHandler;
1439
- _requestHandler = derived.requestHandler;
1440
- }
1441
- return _requestHandler(request, initialContext);
1442
- };
1443
- };
1444
- async function handleManifestRequest(build, dataRoutes, branches, url) {
1445
- if (url.toString().length > _chunkIUPBOWYOjs.URL_LIMIT) {
1446
- return new Response(null, {
1447
- statusText: "Bad Request",
1448
- status: 400
1449
- });
1450
- }
1451
- if (build.assets.version !== url.searchParams.get("version")) {
1452
- return new Response(null, {
1453
- status: 204,
1454
- headers: {
1455
- "X-Remix-Reload-Document": "true"
1456
- }
1457
- });
1458
- }
1459
- let patches = {};
1460
- if (url.searchParams.has("paths")) {
1461
- let pathParam = url.searchParams.get("paths") || "";
1462
- let paths = new Set(pathParam.split(",").filter(Boolean));
1463
- for (let path of paths) {
1464
- if (!path.startsWith("/")) {
1465
- path = `/${path}`;
1466
- }
1467
- let matches = matchServerRoutes(
1468
- build.routes,
1469
- dataRoutes,
1470
- branches,
1471
- path,
1472
- build.basename
1473
- );
1474
- if (matches) {
1475
- for (let match of matches) {
1476
- let routeId = match.route.id;
1477
- let route = build.assets.routes[routeId];
1478
- if (route) {
1479
- patches[routeId] = route;
1480
- }
1481
- }
1482
- }
1483
- }
1484
- return Response.json(patches, {
1485
- headers: {
1486
- "Cache-Control": "public, max-age=31536000, immutable"
1487
- }
1488
- });
1489
- }
1490
- return new Response("Invalid Request", { status: 400 });
1491
- }
1492
- async function handleSingleFetchRequest(serverMode, build, staticHandler, request, normalizedPath, loadContext, handleError) {
1493
- let handlerUrl = new URL(request.url);
1494
- handlerUrl.pathname = normalizedPath;
1495
- let response = _chunkIUPBOWYOjs.isMutationMethod.call(void 0, request.method) ? await singleFetchAction(
1496
- build,
1497
- serverMode,
1498
- staticHandler,
1499
- request,
1500
- handlerUrl,
1501
- loadContext,
1502
- handleError
1503
- ) : await singleFetchLoaders(
1504
- build,
1505
- serverMode,
1506
- staticHandler,
1507
- request,
1508
- handlerUrl,
1509
- loadContext,
1510
- handleError
1511
- );
1512
- return response;
1513
- }
1514
- async function handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError, isSpaMode, criticalCss) {
1515
- try {
1516
- if (_chunkIUPBOWYOjs.isMutationMethod.call(void 0, request.method)) {
1517
- try {
1518
- throwIfPotentialCSRFAttack(
1519
- request,
1520
- Array.isArray(build.allowedActionOrigins) ? build.allowedActionOrigins : []
1521
- );
1522
- } catch (e) {
1523
- handleError(e);
1524
- return new Response("Bad Request", { status: 400 });
1525
- }
1526
- }
1527
- let result = await staticHandler.query(request, {
1528
- requestContext: loadContext,
1529
- generateMiddlewareResponse: build.future.v8_middleware ? async (query) => {
1530
- try {
1531
- let innerResult = await query(request);
1532
- if (!_chunkIUPBOWYOjs.isResponse.call(void 0, innerResult)) {
1533
- innerResult = await renderHtml(innerResult, isSpaMode);
1534
- }
1535
- return innerResult;
1536
- } catch (error) {
1537
- handleError(error);
1538
- return new Response(null, { status: 500 });
1539
- }
1540
- } : void 0,
1541
- normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
1542
- });
1543
- if (!_chunkIUPBOWYOjs.isResponse.call(void 0, result)) {
1544
- result = await renderHtml(result, isSpaMode);
1545
- }
1546
- return result;
1547
- } catch (error) {
1548
- handleError(error);
1549
- return new Response(null, { status: 500 });
1550
- }
1551
- async function renderHtml(context, isSpaMode2) {
1552
- let headers = getDocumentHeaders(context, build);
1553
- if (SERVER_NO_BODY_STATUS_CODES.has(context.statusCode)) {
1554
- return new Response(null, { status: context.statusCode, headers });
1555
- }
1556
- if (context.errors) {
1557
- Object.values(context.errors).forEach((err) => {
1558
- if (!_chunkIUPBOWYOjs.isRouteErrorResponse.call(void 0, err) || err.error) {
1559
- handleError(err);
1560
- }
1561
- });
1562
- context.errors = sanitizeErrors(context.errors, serverMode);
1563
- }
1564
- let state = {
1565
- loaderData: context.loaderData,
1566
- actionData: context.actionData,
1567
- errors: context.errors
1568
- };
1569
- let baseServerHandoff = {
1570
- basename: build.basename,
1571
- future: build.future,
1572
- routeDiscovery: build.routeDiscovery,
1573
- ssr: build.ssr,
1574
- isSpaMode: isSpaMode2
1575
- };
1576
- let entryContext = {
1577
- manifest: build.assets,
1578
- branches: staticHandler._internalRouteBranches,
1579
- routeModules: createEntryRouteModules(build.routes),
1580
- staticHandlerContext: context,
1581
- criticalCss,
1582
- serverHandoffString: createServerHandoffString({
1583
- ...baseServerHandoff,
1584
- criticalCss
1585
- }),
1586
- serverHandoffStream: encodeViaTurboStream(
1587
- state,
1588
- request.signal,
1589
- build.entry.module.streamTimeout,
1590
- serverMode
1591
- ),
1592
- renderMeta: {},
1593
- future: build.future,
1594
- ssr: build.ssr,
1595
- routeDiscovery: build.routeDiscovery,
1596
- isSpaMode: isSpaMode2,
1597
- serializeError: (err) => serializeError(err, serverMode)
1598
- };
1599
- let handleDocumentRequestFunction = build.entry.module.default;
1600
- try {
1601
- return await handleDocumentRequestFunction(
1602
- request,
1603
- context.statusCode,
1604
- headers,
1605
- entryContext,
1606
- loadContext
1607
- );
1608
- } catch (error) {
1609
- handleError(error);
1610
- let errorForSecondRender = error;
1611
- if (_chunkIUPBOWYOjs.isResponse.call(void 0, error)) {
1612
- try {
1613
- let data2 = await unwrapResponse(error);
1614
- errorForSecondRender = new (0, _chunkIUPBOWYOjs.ErrorResponseImpl)(
1615
- error.status,
1616
- error.statusText,
1617
- data2
1618
- );
1619
- } catch (e) {
1620
- }
1621
- }
1622
- context = _chunkIUPBOWYOjs.getStaticContextFromError.call(void 0,
1623
- staticHandler.dataRoutes,
1624
- context,
1625
- errorForSecondRender
1626
- );
1627
- if (context.errors) {
1628
- context.errors = sanitizeErrors(context.errors, serverMode);
1629
- }
1630
- let state2 = {
1631
- loaderData: context.loaderData,
1632
- actionData: context.actionData,
1633
- errors: context.errors
1634
- };
1635
- entryContext = {
1636
- ...entryContext,
1637
- staticHandlerContext: context,
1638
- serverHandoffString: createServerHandoffString(baseServerHandoff),
1639
- serverHandoffStream: encodeViaTurboStream(
1640
- state2,
1641
- request.signal,
1642
- build.entry.module.streamTimeout,
1643
- serverMode
1644
- ),
1645
- renderMeta: {}
1646
- };
1647
- try {
1648
- return await handleDocumentRequestFunction(
1649
- request,
1650
- context.statusCode,
1651
- headers,
1652
- entryContext,
1653
- loadContext
1654
- );
1655
- } catch (error2) {
1656
- handleError(error2);
1657
- return returnLastResortErrorResponse(error2, serverMode);
1658
- }
1659
- }
1660
- }
1661
- }
1662
- async function handleResourceRequest(serverMode, build, staticHandler, routeId, request, loadContext, handleError) {
1663
- try {
1664
- let result = await staticHandler.queryRoute(request, {
1665
- routeId,
1666
- requestContext: loadContext,
1667
- generateMiddlewareResponse: build.future.v8_middleware ? async (queryRoute) => {
1668
- try {
1669
- let innerResult = await queryRoute(request);
1670
- return handleQueryRouteResult(innerResult);
1671
- } catch (error) {
1672
- return handleQueryRouteError(error);
1673
- }
1674
- } : void 0,
1675
- normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
1676
- });
1677
- return handleQueryRouteResult(result);
1678
- } catch (error) {
1679
- return handleQueryRouteError(error);
1680
- }
1681
- function handleQueryRouteResult(result) {
1682
- if (_chunkIUPBOWYOjs.isResponse.call(void 0, result)) {
1683
- return result;
1684
- }
1685
- if (typeof result === "string") {
1686
- return new Response(result);
1687
- }
1688
- return Response.json(result);
1689
- }
1690
- function handleQueryRouteError(error) {
1691
- if (_chunkIUPBOWYOjs.isResponse.call(void 0, error)) {
1692
- return error;
1693
- }
1694
- if (_chunkIUPBOWYOjs.isRouteErrorResponse.call(void 0, error)) {
1695
- handleError(error);
1696
- return errorResponseToJson(error, serverMode);
1697
- }
1698
- if (error instanceof Error && error.message === "Expected a response from queryRoute") {
1699
- let newError = new Error(
1700
- "Expected a Response to be returned from resource route handler"
1701
- );
1702
- handleError(newError);
1703
- return returnLastResortErrorResponse(newError, serverMode);
1704
- }
1705
- handleError(error);
1706
- return returnLastResortErrorResponse(error, serverMode);
1707
- }
1708
- }
1709
- function errorResponseToJson(errorResponse, serverMode) {
1710
- return Response.json(
1711
- serializeError(
1712
- // @ts-expect-error This is "private" from users but intended for internal use
1713
- errorResponse.error || new Error("Unexpected Server Error"),
1714
- serverMode
1715
- ),
1716
- {
1717
- status: errorResponse.status,
1718
- statusText: errorResponse.statusText
1719
- }
1720
- );
1721
- }
1722
- function returnLastResortErrorResponse(error, serverMode) {
1723
- let message = "Unexpected Server Error";
1724
- if (serverMode !== "production" /* Production */) {
1725
- message += `
1726
-
1727
- ${String(error)}`;
1728
- }
1729
- return new Response(message, {
1730
- status: 500,
1731
- headers: {
1732
- "Content-Type": "text/plain"
1733
- }
1734
- });
1735
- }
1736
- function unwrapResponse(response) {
1737
- let contentType = response.headers.get("Content-Type");
1738
- return contentType && /\bapplication\/json\b/.test(contentType) ? response.body == null ? null : response.json() : response.text();
1739
- }
1740
-
1741
- // lib/server-runtime/sessions.ts
1742
- function flash(name) {
1743
- return `__flash_${name}__`;
1744
- }
1745
- var createSession = (initialData = {}, id = "") => {
1746
- let map = new Map(Object.entries(initialData));
1747
- return {
1748
- get id() {
1749
- return id;
1750
- },
1751
- get data() {
1752
- return Object.fromEntries(map);
1753
- },
1754
- has(name) {
1755
- return map.has(name) || map.has(flash(name));
1756
- },
1757
- get(name) {
1758
- if (map.has(name)) return map.get(name);
1759
- let flashName = flash(name);
1760
- if (map.has(flashName)) {
1761
- let value = map.get(flashName);
1762
- map.delete(flashName);
1763
- return value;
1764
- }
1765
- return void 0;
1766
- },
1767
- set(name, value) {
1768
- map.set(name, value);
1769
- },
1770
- flash(name, value) {
1771
- map.set(flash(name), value);
1772
- },
1773
- unset(name) {
1774
- map.delete(name);
1775
- }
1776
- };
1777
- };
1778
- var isSession = (object) => {
1779
- return object != null && typeof object.id === "string" && typeof object.data !== "undefined" && typeof object.has === "function" && typeof object.get === "function" && typeof object.set === "function" && typeof object.flash === "function" && typeof object.unset === "function";
1780
- };
1781
- function createSessionStorage({
1782
- cookie: cookieArg,
1783
- createData,
1784
- readData,
1785
- updateData,
1786
- deleteData
1787
- }) {
1788
- let cookie = isCookie(cookieArg) ? cookieArg : createCookie(_optionalChain([cookieArg, 'optionalAccess', _15 => _15.name]) || "__session", cookieArg);
1789
- warnOnceAboutSigningSessionCookie(cookie);
1790
- return {
1791
- async getSession(cookieHeader, options) {
1792
- let id = cookieHeader && await cookie.parse(cookieHeader, options);
1793
- let data2 = id && await readData(id);
1794
- return createSession(data2 || {}, id || "");
1795
- },
1796
- async commitSession(session, options) {
1797
- let { id, data: data2 } = session;
1798
- let expires = _optionalChain([options, 'optionalAccess', _16 => _16.maxAge]) != null ? new Date(Date.now() + options.maxAge * 1e3) : _optionalChain([options, 'optionalAccess', _17 => _17.expires]) != null ? options.expires : cookie.expires;
1799
- if (id) {
1800
- await updateData(id, data2, expires);
1801
- } else {
1802
- id = await createData(data2, expires);
1803
- }
1804
- return cookie.serialize(id, options);
1805
- },
1806
- async destroySession(session, options) {
1807
- await deleteData(session.id);
1808
- return cookie.serialize("", {
1809
- ...options,
1810
- maxAge: void 0,
1811
- expires: /* @__PURE__ */ new Date(0)
1812
- });
1813
- }
1814
- };
1815
- }
1816
- function warnOnceAboutSigningSessionCookie(cookie) {
1817
- _chunkIUPBOWYOjs.warnOnce.call(void 0,
1818
- cookie.isSigned,
1819
- `The "${cookie.name}" cookie is not signed, but session cookies should be signed to prevent tampering on the client before they are sent back to the server. See https://reactrouter.com/explanation/sessions-and-cookies#signing-cookies for more information.`
1820
- );
1821
- }
1822
-
1823
- // lib/server-runtime/sessions/cookieStorage.ts
1824
- function createCookieSessionStorage({ cookie: cookieArg } = {}) {
1825
- let cookie = isCookie(cookieArg) ? cookieArg : createCookie(_optionalChain([cookieArg, 'optionalAccess', _18 => _18.name]) || "__session", cookieArg);
1826
- warnOnceAboutSigningSessionCookie(cookie);
1827
- return {
1828
- async getSession(cookieHeader, options) {
1829
- return createSession(
1830
- cookieHeader && await cookie.parse(cookieHeader, options) || {}
1831
- );
1832
- },
1833
- async commitSession(session, options) {
1834
- let serializedCookie = await cookie.serialize(session.data, options);
1835
- if (serializedCookie.length > 4096) {
1836
- throw new Error(
1837
- "Cookie length will exceed browser maximum. Length: " + serializedCookie.length
1838
- );
1839
- }
1840
- return serializedCookie;
1841
- },
1842
- async destroySession(_session, options) {
1843
- return cookie.serialize("", {
1844
- ...options,
1845
- maxAge: void 0,
1846
- expires: /* @__PURE__ */ new Date(0)
1847
- });
1848
- }
1849
- };
1850
- }
1851
-
1852
- // lib/server-runtime/sessions/memoryStorage.ts
1853
- function createMemorySessionStorage({ cookie } = {}) {
1854
- let map = /* @__PURE__ */ new Map();
1855
- return createSessionStorage({
1856
- cookie,
1857
- async createData(data2, expires) {
1858
- let id = Math.random().toString(36).substring(2, 10);
1859
- map.set(id, { data: data2, expires });
1860
- return id;
1861
- },
1862
- async readData(id) {
1863
- if (map.has(id)) {
1864
- let { data: data2, expires } = map.get(id);
1865
- if (!expires || expires > /* @__PURE__ */ new Date()) {
1866
- return data2;
1867
- }
1868
- if (expires) map.delete(id);
1869
- }
1870
- return null;
1871
- },
1872
- async updateData(id, data2, expires) {
1873
- map.set(id, { data: data2, expires });
1874
- },
1875
- async deleteData(id) {
1876
- map.delete(id);
1877
- }
1878
- });
1879
- }
1880
-
1881
- // lib/href.ts
1882
- function href(path, ...args) {
1883
- let params = args[0];
1884
- let result = trimTrailingSplat(path).replace(
1885
- /\/:([\w-]+)(\?)?/g,
1886
- // same regex as in .\router\utils.ts: compilePath().
1887
- (_, param, questionMark) => {
1888
- const isRequired = questionMark === void 0;
1889
- const value = _optionalChain([params, 'optionalAccess', _19 => _19[param]]);
1890
- if (isRequired && value === void 0) {
1891
- throw new Error(
1892
- `Path '${path}' requires param '${param}' but it was not provided`
1893
- );
1894
- }
1895
- return value === void 0 ? "" : "/" + value;
1896
- }
1897
- );
1898
- if (path.endsWith("*")) {
1899
- const value = _optionalChain([params, 'optionalAccess', _20 => _20["*"]]);
1900
- if (value !== void 0) {
1901
- result += "/" + value;
1902
- }
1903
- }
1904
- return result || "/";
1905
- }
1906
- function trimTrailingSplat(path) {
1907
- let i = path.length - 1;
1908
- let char = path[i];
1909
- if (char !== "*" && char !== "/") return path;
1910
- i--;
1911
- for (; i >= 0; i--) {
1912
- if (path[i] !== "/") break;
1913
- }
1914
- return path.slice(0, i + 1);
1915
- }
1916
-
1917
- // lib/rsc/server.ssr.tsx
1918
-
1919
-
1920
- // lib/rsc/html-stream/server.ts
1921
- var encoder2 = new TextEncoder();
1922
- var trailer = "</body></html>";
1923
- function injectRSCPayload(rscStream) {
1924
- let decoder = new TextDecoder();
1925
- let resolveFlightDataPromise;
1926
- let flightDataPromise = new Promise(
1927
- (resolve) => resolveFlightDataPromise = resolve
1928
- );
1929
- let startedRSC = false;
1930
- let buffered = [];
1931
- let timeout = null;
1932
- function flushBufferedChunks(controller) {
1933
- for (let chunk of buffered) {
1934
- let buf = decoder.decode(chunk, { stream: true });
1935
- if (buf.endsWith(trailer)) {
1936
- buf = buf.slice(0, -trailer.length);
1937
- }
1938
- controller.enqueue(encoder2.encode(buf));
1939
- }
1940
- buffered.length = 0;
1941
- timeout = null;
1942
- }
1943
- return new TransformStream({
1944
- transform(chunk, controller) {
1945
- buffered.push(chunk);
1946
- if (timeout) {
1947
- return;
1948
- }
1949
- timeout = setTimeout(async () => {
1950
- flushBufferedChunks(controller);
1951
- if (!startedRSC) {
1952
- startedRSC = true;
1953
- writeRSCStream(rscStream, controller).catch((err) => controller.error(err)).then(resolveFlightDataPromise);
1954
- }
1955
- }, 0);
1956
- },
1957
- async flush(controller) {
1958
- await flightDataPromise;
1959
- if (timeout) {
1960
- clearTimeout(timeout);
1961
- flushBufferedChunks(controller);
1962
- }
1963
- controller.enqueue(encoder2.encode("</body></html>"));
1964
- }
1965
- });
1966
- }
1967
- async function writeRSCStream(rscStream, controller) {
1968
- let decoder = new TextDecoder("utf-8", { fatal: true });
1969
- const reader = rscStream.getReader();
1970
- try {
1971
- let read;
1972
- while ((read = await reader.read()) && !read.done) {
1973
- const chunk = read.value;
1974
- try {
1975
- writeChunk(
1976
- JSON.stringify(decoder.decode(chunk, { stream: true })),
1977
- controller
1978
- );
1979
- } catch (e) {
1980
- let base64 = JSON.stringify(btoa(String.fromCodePoint(...chunk)));
1981
- writeChunk(
1982
- `Uint8Array.from(atob(${base64}), m => m.codePointAt(0))`,
1983
- controller
1984
- );
1985
- }
1986
- }
1987
- } finally {
1988
- reader.releaseLock();
1989
- }
1990
- let remaining = decoder.decode();
1991
- if (remaining.length) {
1992
- writeChunk(JSON.stringify(remaining), controller);
1993
- }
1994
- }
1995
- function writeChunk(chunk, controller) {
1996
- controller.enqueue(
1997
- encoder2.encode(
1998
- `<script>${escapeScript(
1999
- `(self.__FLIGHT_DATA||=[]).push(${chunk})`
2000
- )}</script>`
2001
- )
2002
- );
2003
- }
2004
- function escapeScript(script) {
2005
- return script.replace(/<!--/g, "<\\!--").replace(/<\/(script)/gi, "</\\$1");
2006
- }
2007
-
2008
- // lib/rsc/server.ssr.tsx
2009
- var defaultManifestPath = "/__manifest";
2010
- var REACT_USE = "use";
2011
- var useImpl = React3[REACT_USE];
2012
- function useSafe(promise) {
2013
- if (useImpl) {
2014
- return useImpl(promise);
2015
- }
2016
- throw new Error("React Router v7 requires React 19+ for RSC features.");
2017
- }
2018
- async function routeRSCServerRequest({
2019
- request,
2020
- serverResponse,
2021
- createFromReadableStream,
2022
- renderHTML,
2023
- hydrate = true
2024
- }) {
2025
- const url = new URL(request.url);
2026
- const isDataRequest = isReactServerRequest(url);
2027
- const respondWithRSCPayload = isDataRequest || isManifestRequest(url) || request.headers.has("rsc-action-id");
2028
- if (respondWithRSCPayload || serverResponse.headers.get("React-Router-Resource") === "true") {
2029
- return serverResponse;
2030
- }
2031
- if (!serverResponse.body) {
2032
- throw new Error("Missing body in server response");
2033
- }
2034
- const detectRedirectResponse = serverResponse.clone();
2035
- let serverResponseB = null;
2036
- if (hydrate) {
2037
- serverResponseB = serverResponse.clone();
2038
- }
2039
- const body = serverResponse.body;
2040
- let buffer;
2041
- let streamControllers = [];
2042
- const createStream = () => {
2043
- if (!buffer) {
2044
- buffer = [];
2045
- return body.pipeThrough(
2046
- new TransformStream({
2047
- transform(chunk, controller) {
2048
- buffer.push(chunk);
2049
- controller.enqueue(chunk);
2050
- streamControllers.forEach((c) => c.enqueue(chunk));
2051
- },
2052
- flush() {
2053
- streamControllers.forEach((c) => c.close());
2054
- streamControllers = [];
2055
- }
2056
- })
2057
- );
2058
- }
2059
- return new ReadableStream({
2060
- start(controller) {
2061
- buffer.forEach((chunk) => controller.enqueue(chunk));
2062
- streamControllers.push(controller);
2063
- }
2064
- });
2065
- };
2066
- let deepestRenderedBoundaryId = null;
2067
- const getPayload = () => {
2068
- const payloadPromise = Promise.resolve(
2069
- createFromReadableStream(createStream())
2070
- );
2071
- return Object.defineProperties(payloadPromise, {
2072
- _deepestRenderedBoundaryId: {
2073
- get() {
2074
- return deepestRenderedBoundaryId;
2075
- },
2076
- set(boundaryId) {
2077
- deepestRenderedBoundaryId = boundaryId;
2078
- }
2079
- },
2080
- formState: {
2081
- get() {
2082
- return payloadPromise.then(
2083
- (payload) => payload.type === "render" ? payload.formState : void 0
2084
- );
2085
- }
2086
- }
2087
- });
2088
- };
2089
- let renderRedirect;
2090
- let renderError;
2091
- try {
2092
- if (!detectRedirectResponse.body) {
2093
- throw new Error("Failed to clone server response");
2094
- }
2095
- const payload = await createFromReadableStream(
2096
- detectRedirectResponse.body
2097
- );
2098
- if (serverResponse.status === _chunkIUPBOWYOjs.SINGLE_FETCH_REDIRECT_STATUS && payload.type === "redirect") {
2099
- if (_chunkIUPBOWYOjs.hasInvalidProtocol.call(void 0, payload.location)) {
2100
- throw new Error("Invalid redirect location");
2101
- }
2102
- const headers2 = new Headers(serverResponse.headers);
2103
- headers2.delete("Content-Encoding");
2104
- headers2.delete("Content-Length");
2105
- headers2.delete("Content-Type");
2106
- headers2.delete("X-Remix-Response");
2107
- headers2.set("Location", payload.location);
2108
- return new Response(_optionalChain([serverResponseB, 'optionalAccess', _21 => _21.body]) || "", {
2109
- headers: headers2,
2110
- status: payload.status,
2111
- statusText: serverResponse.statusText
2112
- });
2113
- }
2114
- let reactHeaders = new Headers();
2115
- let status = serverResponse.status;
2116
- let statusText = serverResponse.statusText;
2117
- let html = await renderHTML(getPayload, {
2118
- onError(error) {
2119
- if (typeof error === "object" && error && "digest" in error && typeof error.digest === "string") {
2120
- renderRedirect = _chunkIUPBOWYOjs.decodeRedirectErrorDigest.call(void 0, error.digest);
2121
- if (renderRedirect) {
2122
- return error.digest;
2123
- }
2124
- let routeErrorResponse = _chunkIUPBOWYOjs.decodeRouteErrorResponseDigest.call(void 0, error.digest);
2125
- if (routeErrorResponse) {
2126
- renderError = routeErrorResponse;
2127
- status = routeErrorResponse.status;
2128
- statusText = routeErrorResponse.statusText;
2129
- return error.digest;
2130
- }
2131
- }
2132
- },
2133
- onHeaders(headers2) {
2134
- for (const [key, value] of headers2) {
2135
- reactHeaders.append(key, value);
2136
- }
2137
- }
2138
- });
2139
- const headers = new Headers(reactHeaders);
2140
- for (const [key, value] of serverResponse.headers) {
2141
- headers.append(key, value);
2142
- }
2143
- headers.set("Content-Type", "text/html; charset=utf-8");
2144
- if (renderRedirect) {
2145
- if (_chunkIUPBOWYOjs.hasInvalidProtocol.call(void 0, renderRedirect.location)) {
2146
- throw new Error("Invalid redirect location");
2147
- }
2148
- headers.set("Location", renderRedirect.location);
2149
- return new Response(html, {
2150
- status: renderRedirect.status,
2151
- headers
2152
- });
2153
- }
2154
- const redirectTransform = new TransformStream({
2155
- flush(controller) {
2156
- if (renderRedirect) {
2157
- if (_chunkIUPBOWYOjs.hasInvalidProtocol.call(void 0, renderRedirect.location)) {
2158
- return;
2159
- }
2160
- controller.enqueue(
2161
- new TextEncoder().encode(
2162
- `<meta http-equiv="refresh" content="0;url=${_chunkIUPBOWYOjs.escapeHtml.call(void 0, renderRedirect.location)}"/>`
2163
- )
2164
- );
2165
- }
2166
- }
2167
- });
2168
- if (!hydrate) {
2169
- return new Response(html.pipeThrough(redirectTransform), {
2170
- status,
2171
- statusText,
2172
- headers
2173
- });
2174
- }
2175
- if (!_optionalChain([serverResponseB, 'optionalAccess', _22 => _22.body])) {
2176
- throw new Error("Failed to clone server response");
2177
- }
2178
- const body2 = html.pipeThrough(injectRSCPayload(serverResponseB.body)).pipeThrough(redirectTransform);
2179
- return new Response(body2, {
2180
- status,
2181
- statusText,
2182
- headers
2183
- });
2184
- } catch (error) {
2185
- if (error instanceof Response) {
2186
- return error;
2187
- }
2188
- if (renderRedirect) {
2189
- if (_chunkIUPBOWYOjs.hasInvalidProtocol.call(void 0, renderRedirect.location)) {
2190
- throw new Error("Invalid redirect location");
2191
- }
2192
- return new Response(`Redirect: ${renderRedirect.location}`, {
2193
- status: renderRedirect.status,
2194
- headers: {
2195
- Location: renderRedirect.location
2196
- }
2197
- });
2198
- }
2199
- try {
2200
- let normalizedError = _nullishCoalesce(renderError, () => ( error));
2201
- let [status, statusText] = _chunkIUPBOWYOjs.isRouteErrorResponse.call(void 0, normalizedError) ? [normalizedError.status, normalizedError.statusText] : [500, ""];
2202
- let retryRedirect;
2203
- let reactHeaders = new Headers();
2204
- const html = await renderHTML(
2205
- () => {
2206
- const decoded = Promise.resolve(
2207
- createFromReadableStream(createStream())
2208
- );
2209
- const payloadPromise = decoded.then(
2210
- (payload) => Object.assign(payload, {
2211
- status,
2212
- errors: deepestRenderedBoundaryId ? {
2213
- [deepestRenderedBoundaryId]: normalizedError
2214
- } : {}
2215
- })
2216
- );
2217
- return Object.defineProperties(payloadPromise, {
2218
- _deepestRenderedBoundaryId: {
2219
- get() {
2220
- return deepestRenderedBoundaryId;
2221
- },
2222
- set(boundaryId) {
2223
- deepestRenderedBoundaryId = boundaryId;
2224
- }
2225
- },
2226
- formState: {
2227
- get() {
2228
- return payloadPromise.then(
2229
- (payload) => payload.type === "render" ? payload.formState : void 0
2230
- );
2231
- }
2232
- }
2233
- });
2234
- },
2235
- {
2236
- onError(error2) {
2237
- if (typeof error2 === "object" && error2 && "digest" in error2 && typeof error2.digest === "string") {
2238
- retryRedirect = _chunkIUPBOWYOjs.decodeRedirectErrorDigest.call(void 0, error2.digest);
2239
- if (retryRedirect) {
2240
- return error2.digest;
2241
- }
2242
- let routeErrorResponse = _chunkIUPBOWYOjs.decodeRouteErrorResponseDigest.call(void 0,
2243
- error2.digest
2244
- );
2245
- if (routeErrorResponse) {
2246
- status = routeErrorResponse.status;
2247
- statusText = routeErrorResponse.statusText;
2248
- return error2.digest;
2249
- }
2250
- }
2251
- },
2252
- onHeaders(headers2) {
2253
- for (const [key, value] of headers2) {
2254
- reactHeaders.append(key, value);
2255
- }
2256
- }
2257
- }
2258
- );
2259
- const headers = new Headers(reactHeaders);
2260
- for (const [key, value] of serverResponse.headers) {
2261
- headers.append(key, value);
2262
- }
2263
- headers.set("Content-Type", "text/html; charset=utf-8");
2264
- if (retryRedirect) {
2265
- if (_chunkIUPBOWYOjs.hasInvalidProtocol.call(void 0, retryRedirect.location)) {
2266
- throw new Error("Invalid redirect location");
2267
- }
2268
- headers.set("Location", retryRedirect.location);
2269
- return new Response(html, {
2270
- status: retryRedirect.status,
2271
- headers
2272
- });
2273
- }
2274
- const retryRedirectTransform = new TransformStream({
2275
- flush(controller) {
2276
- if (retryRedirect) {
2277
- if (_chunkIUPBOWYOjs.hasInvalidProtocol.call(void 0, retryRedirect.location)) {
2278
- return;
2279
- }
2280
- controller.enqueue(
2281
- new TextEncoder().encode(
2282
- `<meta http-equiv="refresh" content="0;url=${_chunkIUPBOWYOjs.escapeHtml.call(void 0, retryRedirect.location)}"/>`
2283
- )
2284
- );
2285
- }
2286
- }
2287
- });
2288
- if (!hydrate) {
2289
- return new Response(html.pipeThrough(retryRedirectTransform), {
2290
- status,
2291
- statusText,
2292
- headers
2293
- });
2294
- }
2295
- if (!_optionalChain([serverResponseB, 'optionalAccess', _23 => _23.body])) {
2296
- throw new Error("Failed to clone server response");
2297
- }
2298
- const body2 = html.pipeThrough(injectRSCPayload(serverResponseB.body)).pipeThrough(retryRedirectTransform);
2299
- return new Response(body2, {
2300
- status,
2301
- statusText,
2302
- headers
2303
- });
2304
- } catch (error2) {
2305
- }
2306
- throw error;
2307
- }
2308
- }
2309
- function RSCStaticRouter({ getPayload }) {
2310
- const decoded = getPayload();
2311
- const payload = useSafe(decoded);
2312
- if (payload.type === "redirect") {
2313
- if (_chunkIUPBOWYOjs.hasInvalidProtocol.call(void 0, payload.location)) {
2314
- throw new Error("Invalid redirect location");
2315
- }
2316
- throw new Response(null, {
2317
- status: payload.status,
2318
- headers: {
2319
- Location: payload.location
2320
- }
2321
- });
2322
- }
2323
- if (payload.type !== "render") return null;
2324
- let patchedLoaderData = { ...payload.loaderData };
2325
- for (const match of payload.matches) {
2326
- if (_chunkIUPBOWYOjs.shouldHydrateRouteLoader.call(void 0,
2327
- match.id,
2328
- match.clientLoader,
2329
- match.hasLoader,
2330
- false
2331
- ) && (match.hydrateFallbackElement || !match.hasLoader)) {
2332
- delete patchedLoaderData[match.id];
2333
- }
2334
- }
2335
- const context = {
2336
- get _deepestRenderedBoundaryId() {
2337
- return _nullishCoalesce(decoded._deepestRenderedBoundaryId, () => ( null));
2338
- },
2339
- set _deepestRenderedBoundaryId(boundaryId) {
2340
- decoded._deepestRenderedBoundaryId = boundaryId;
2341
- },
2342
- actionData: payload.actionData,
2343
- actionHeaders: {},
2344
- basename: payload.basename,
2345
- errors: payload.errors,
2346
- loaderData: patchedLoaderData,
2347
- loaderHeaders: {},
2348
- location: payload.location,
2349
- statusCode: 200,
2350
- matches: payload.matches.map((match) => ({
2351
- params: match.params,
2352
- pathname: match.pathname,
2353
- pathnameBase: match.pathnameBase,
2354
- route: {
2355
- id: match.id,
2356
- action: match.hasAction || !!match.clientAction,
2357
- handle: match.handle,
2358
- hasErrorBoundary: match.hasErrorBoundary,
2359
- loader: match.hasLoader || !!match.clientLoader,
2360
- index: match.index,
2361
- path: match.path,
2362
- shouldRevalidate: match.shouldRevalidate
2363
- }
2364
- }))
2365
- };
2366
- const router = _chunkBIP66BKVjs.createStaticRouter.call(void 0,
2367
- payload.matches.reduceRight((previous, match) => {
2368
- const route = {
2369
- id: match.id,
2370
- action: match.hasAction || !!match.clientAction,
2371
- element: match.element,
2372
- errorElement: match.errorElement,
2373
- handle: match.handle,
2374
- hasErrorBoundary: !!match.errorElement,
2375
- hydrateFallbackElement: match.hydrateFallbackElement,
2376
- index: match.index,
2377
- loader: match.hasLoader || !!match.clientLoader,
2378
- path: match.path,
2379
- shouldRevalidate: match.shouldRevalidate
2380
- };
2381
- if (previous.length > 0) {
2382
- route.children = previous;
2383
- }
2384
- return [route];
2385
- }, []),
2386
- context
2387
- );
2388
- const frameworkContext = {
2389
- future: {
2390
- // These flags have no runtime impact so can always be false. If we add
2391
- // flags that drive runtime behavior they'll need to be proxied through.
2392
- v8_middleware: false,
2393
- v8_trailingSlashAwareDataRequests: true,
2394
- // always on for RSC
2395
- v8_passThroughRequests: true
2396
- // always on for RSC
2397
- },
2398
- isSpaMode: false,
2399
- ssr: true,
2400
- criticalCss: "",
2401
- manifest: {
2402
- routes: {},
2403
- version: "1",
2404
- url: "",
2405
- entry: {
2406
- module: "",
2407
- imports: []
2408
- }
2409
- },
2410
- routeDiscovery: payload.routeDiscovery.mode === "initial" ? { mode: "initial", manifestPath: defaultManifestPath } : {
2411
- mode: "lazy",
2412
- manifestPath: payload.routeDiscovery.manifestPath || defaultManifestPath
2413
- },
2414
- routeModules: _chunk3Z6WS2WZjs.createRSCRouteModules.call(void 0, payload)
2415
- };
2416
- return /* @__PURE__ */ React3.createElement(_chunkIUPBOWYOjs.RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React3.createElement(_chunk3Z6WS2WZjs.RSCRouterGlobalErrorBoundary, { location: payload.location }, /* @__PURE__ */ React3.createElement(_chunkIUPBOWYOjs.FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React3.createElement(
2417
- _chunkBIP66BKVjs.StaticRouterProvider,
2418
- {
2419
- context,
2420
- router,
2421
- hydrate: false,
2422
- nonce: payload.nonce
2423
- }
2424
- ))));
2425
- }
2426
- function isReactServerRequest(url) {
2427
- return url.pathname.endsWith(".rsc");
2428
- }
2429
- function isManifestRequest(url) {
2430
- return url.pathname.endsWith(".manifest");
2431
- }
2432
-
2433
-
2434
-
2435
-
2436
-
2437
-
2438
-
2439
-
2440
-
2441
-
2442
-
2443
-
2444
-
2445
-
2446
-
2447
-
2448
-
2449
-
2450
-
2451
-
2452
-
2453
-
2454
-
2455
-
2456
-
2457
-
2458
-
2459
-
2460
-
2461
-
2462
-
2463
-
2464
-
2465
-
2466
-
2467
-
2468
-
2469
-
2470
-
2471
-
2472
-
2473
-
2474
-
2475
-
2476
-
2477
-
2478
-
2479
-
2480
-
2481
-
2482
-
2483
-
2484
-
2485
-
2486
-
2487
-
2488
-
2489
-
2490
-
2491
-
2492
-
2493
-
2494
-
2495
-
2496
-
2497
-
2498
-
2499
-
2500
-
2501
-
2502
-
2503
-
2504
-
2505
-
2506
-
2507
-
2508
-
2509
-
2510
-
2511
-
2512
-
2513
-
2514
-
2515
-
2516
-
2517
-
2518
-
2519
-
2520
-
2521
-
2522
-
2523
-
2524
-
2525
-
2526
-
2527
-
2528
-
2529
-
2530
-
2531
-
2532
-
2533
-
2534
-
2535
-
2536
-
2537
-
2538
-
2539
-
2540
-
2541
-
2542
-
2543
-
2544
-
2545
-
2546
-
2547
-
2548
-
2549
-
2550
-
2551
-
2552
-
2553
-
2554
-
2555
-
2556
-
2557
-
2558
-
2559
-
2560
-
2561
-
2562
- exports.Await = _chunkIUPBOWYOjs.Await; exports.BrowserRouter = _chunkBIP66BKVjs.BrowserRouter; exports.Form = _chunkBIP66BKVjs.Form; exports.HashRouter = _chunkBIP66BKVjs.HashRouter; exports.IDLE_BLOCKER = _chunkIUPBOWYOjs.IDLE_BLOCKER; exports.IDLE_FETCHER = _chunkIUPBOWYOjs.IDLE_FETCHER; exports.IDLE_NAVIGATION = _chunkIUPBOWYOjs.IDLE_NAVIGATION; exports.Link = _chunkBIP66BKVjs.Link; exports.Links = _chunkIUPBOWYOjs.Links; exports.MemoryRouter = _chunkIUPBOWYOjs.MemoryRouter; exports.Meta = _chunkIUPBOWYOjs.Meta; exports.NavLink = _chunkBIP66BKVjs.NavLink; exports.Navigate = _chunkIUPBOWYOjs.Navigate; exports.NavigationType = _chunkIUPBOWYOjs.Action; exports.Outlet = _chunkIUPBOWYOjs.Outlet; exports.PrefetchPageLinks = _chunkIUPBOWYOjs.PrefetchPageLinks; exports.Route = _chunkIUPBOWYOjs.Route; exports.Router = _chunkIUPBOWYOjs.Router; exports.RouterContextProvider = _chunkIUPBOWYOjs.RouterContextProvider; exports.RouterProvider = _chunkIUPBOWYOjs.RouterProvider; exports.Routes = _chunkIUPBOWYOjs.Routes; exports.Scripts = _chunkIUPBOWYOjs.Scripts; exports.ScrollRestoration = _chunkBIP66BKVjs.ScrollRestoration; exports.ServerRouter = ServerRouter; exports.StaticRouter = _chunkBIP66BKVjs.StaticRouter; exports.StaticRouterProvider = _chunkBIP66BKVjs.StaticRouterProvider; exports.UNSAFE_AwaitContextProvider = _chunkIUPBOWYOjs.AwaitContextProvider; exports.UNSAFE_DataRouterContext = _chunkIUPBOWYOjs.DataRouterContext; exports.UNSAFE_DataRouterStateContext = _chunkIUPBOWYOjs.DataRouterStateContext; exports.UNSAFE_ErrorResponseImpl = _chunkIUPBOWYOjs.ErrorResponseImpl; exports.UNSAFE_FetchersContext = _chunkIUPBOWYOjs.FetchersContext; exports.UNSAFE_FrameworkContext = _chunkIUPBOWYOjs.FrameworkContext; exports.UNSAFE_LocationContext = _chunkIUPBOWYOjs.LocationContext; exports.UNSAFE_NavigationContext = _chunkIUPBOWYOjs.NavigationContext; exports.UNSAFE_RSCDefaultRootErrorBoundary = _chunk3Z6WS2WZjs.RSCDefaultRootErrorBoundary; exports.UNSAFE_RemixErrorBoundary = _chunkIUPBOWYOjs.RemixErrorBoundary; exports.UNSAFE_RouteContext = _chunkIUPBOWYOjs.RouteContext; exports.UNSAFE_ServerMode = ServerMode; exports.UNSAFE_SingleFetchRedirectSymbol = _chunkIUPBOWYOjs.SingleFetchRedirectSymbol; exports.UNSAFE_ViewTransitionContext = _chunkIUPBOWYOjs.ViewTransitionContext; exports.UNSAFE_WithComponentProps = _chunkIUPBOWYOjs.WithComponentProps; exports.UNSAFE_WithErrorBoundaryProps = _chunkIUPBOWYOjs.WithErrorBoundaryProps; exports.UNSAFE_WithHydrateFallbackProps = _chunkIUPBOWYOjs.WithHydrateFallbackProps; exports.UNSAFE_createBrowserHistory = _chunkIUPBOWYOjs.createBrowserHistory; exports.UNSAFE_createClientRoutes = _chunkIUPBOWYOjs.createClientRoutes; exports.UNSAFE_createClientRoutesWithHMRRevalidationOptOut = _chunkIUPBOWYOjs.createClientRoutesWithHMRRevalidationOptOut; exports.UNSAFE_createHashHistory = _chunkIUPBOWYOjs.createHashHistory; exports.UNSAFE_createMemoryHistory = _chunkIUPBOWYOjs.createMemoryHistory; exports.UNSAFE_createRouter = _chunkIUPBOWYOjs.createRouter; exports.UNSAFE_decodeViaTurboStream = _chunkIUPBOWYOjs.decodeViaTurboStream; exports.UNSAFE_getHydrationData = _chunk3Z6WS2WZjs.getHydrationData; exports.UNSAFE_getPatchRoutesOnNavigationFunction = _chunkIUPBOWYOjs.getPatchRoutesOnNavigationFunction; exports.UNSAFE_getTurboStreamSingleFetchDataStrategy = _chunkIUPBOWYOjs.getTurboStreamSingleFetchDataStrategy; exports.UNSAFE_hydrationRouteProperties = _chunkIUPBOWYOjs.hydrationRouteProperties; exports.UNSAFE_invariant = _chunkIUPBOWYOjs.invariant; exports.UNSAFE_mapRouteProperties = _chunkIUPBOWYOjs.mapRouteProperties; exports.UNSAFE_shouldHydrateRouteLoader = _chunkIUPBOWYOjs.shouldHydrateRouteLoader; exports.UNSAFE_useFogOFWarDiscovery = _chunkIUPBOWYOjs.useFogOFWarDiscovery; exports.UNSAFE_useScrollRestoration = _chunkBIP66BKVjs.useScrollRestoration; exports.UNSAFE_withComponentProps = _chunkIUPBOWYOjs.withComponentProps; exports.UNSAFE_withErrorBoundaryProps = _chunkIUPBOWYOjs.withErrorBoundaryProps; exports.UNSAFE_withHydrateFallbackProps = _chunkIUPBOWYOjs.withHydrateFallbackProps; exports.createBrowserRouter = _chunkBIP66BKVjs.createBrowserRouter; exports.createContext = _chunkIUPBOWYOjs.createContext; exports.createCookie = createCookie; exports.createCookieSessionStorage = createCookieSessionStorage; exports.createHashRouter = _chunkBIP66BKVjs.createHashRouter; exports.createMemoryRouter = _chunkIUPBOWYOjs.createMemoryRouter; exports.createMemorySessionStorage = createMemorySessionStorage; exports.createPath = _chunkIUPBOWYOjs.createPath; exports.createRequestHandler = createRequestHandler; exports.createRoutesFromChildren = _chunkIUPBOWYOjs.createRoutesFromChildren; exports.createRoutesFromElements = _chunkIUPBOWYOjs.createRoutesFromElements; exports.createRoutesStub = createRoutesStub; exports.createSearchParams = _chunkBIP66BKVjs.createSearchParams; exports.createSession = createSession; exports.createSessionStorage = createSessionStorage; exports.createStaticHandler = _chunkBIP66BKVjs.createStaticHandler; exports.createStaticRouter = _chunkBIP66BKVjs.createStaticRouter; exports.data = _chunkIUPBOWYOjs.data; exports.generatePath = _chunkIUPBOWYOjs.generatePath; exports.href = href; exports.isCookie = isCookie; exports.isRouteErrorResponse = _chunkIUPBOWYOjs.isRouteErrorResponse; exports.isSession = isSession; exports.matchPath = _chunkIUPBOWYOjs.matchPath; exports.matchRoutes = _chunkIUPBOWYOjs.matchRoutes; exports.parsePath = _chunkIUPBOWYOjs.parsePath; exports.redirect = _chunkIUPBOWYOjs.redirect; exports.redirectDocument = _chunkIUPBOWYOjs.redirectDocument; exports.renderMatches = _chunkIUPBOWYOjs.renderMatches; exports.replace = _chunkIUPBOWYOjs.replace; exports.resolvePath = _chunkIUPBOWYOjs.resolvePath; exports.unstable_HistoryRouter = _chunkBIP66BKVjs.HistoryRouter; exports.unstable_RSCStaticRouter = RSCStaticRouter; exports.unstable_routeRSCServerRequest = routeRSCServerRequest; exports.unstable_setDevServerHooks = setDevServerHooks; exports.unstable_usePrompt = _chunkBIP66BKVjs.usePrompt; exports.unstable_useRoute = _chunkIUPBOWYOjs.useRoute; exports.unstable_useRouterState = _chunkIUPBOWYOjs.useRouterState; exports.useActionData = _chunkIUPBOWYOjs.useActionData; exports.useAsyncError = _chunkIUPBOWYOjs.useAsyncError; exports.useAsyncValue = _chunkIUPBOWYOjs.useAsyncValue; exports.useBeforeUnload = _chunkBIP66BKVjs.useBeforeUnload; exports.useBlocker = _chunkIUPBOWYOjs.useBlocker; exports.useFetcher = _chunkBIP66BKVjs.useFetcher; exports.useFetchers = _chunkBIP66BKVjs.useFetchers; exports.useFormAction = _chunkBIP66BKVjs.useFormAction; exports.useHref = _chunkIUPBOWYOjs.useHref; exports.useInRouterContext = _chunkIUPBOWYOjs.useInRouterContext; exports.useLinkClickHandler = _chunkBIP66BKVjs.useLinkClickHandler; exports.useLoaderData = _chunkIUPBOWYOjs.useLoaderData; exports.useLocation = _chunkIUPBOWYOjs.useLocation; exports.useMatch = _chunkIUPBOWYOjs.useMatch; exports.useMatches = _chunkIUPBOWYOjs.useMatches; exports.useNavigate = _chunkIUPBOWYOjs.useNavigate; exports.useNavigation = _chunkIUPBOWYOjs.useNavigation; exports.useNavigationType = _chunkIUPBOWYOjs.useNavigationType; exports.useOutlet = _chunkIUPBOWYOjs.useOutlet; exports.useOutletContext = _chunkIUPBOWYOjs.useOutletContext; exports.useParams = _chunkIUPBOWYOjs.useParams; exports.useResolvedPath = _chunkIUPBOWYOjs.useResolvedPath; exports.useRevalidator = _chunkIUPBOWYOjs.useRevalidator; exports.useRouteError = _chunkIUPBOWYOjs.useRouteError; exports.useRouteLoaderData = _chunkIUPBOWYOjs.useRouteLoaderData; exports.useRoutes = _chunkIUPBOWYOjs.useRoutes; exports.useSearchParams = _chunkBIP66BKVjs.useSearchParams; exports.useSubmit = _chunkBIP66BKVjs.useSubmit; exports.useViewTransitionState = _chunkBIP66BKVjs.useViewTransitionState;
12
+ import { Action, createBrowserHistory, createHashHistory, createMemoryHistory, createPath, invariant, parsePath } from "./lib/router/history.js";
13
+ import { ErrorResponseImpl, RouterContextProvider, createContext, data, defaultMapRouteProperties, generatePath, isRouteErrorResponse, matchPath, matchRoutes, redirect, redirectDocument, replace, resolvePath } from "./lib/router/utils.js";
14
+ import { IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, createRouter, createStaticHandler } from "./lib/router/router.js";
15
+ import { AwaitContextProvider, DataRouterContext, DataRouterStateContext, FetchersContext, LocationContext, NavigationContext, RouteContext, ViewTransitionContext } from "./lib/context.js";
16
+ import { useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRoute, useRouteError, useRouteLoaderData, useRouterState, useRoutes } from "./lib/hooks.js";
17
+ import { Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, WithComponentProps, WithErrorBoundaryProps, WithHydrateFallbackProps, createMemoryRouter, createRoutesFromChildren, createRoutesFromElements, hydrationRouteProperties, renderMatches, withComponentProps, withErrorBoundaryProps, withHydrateFallbackProps } from "./lib/components.js";
18
+ import { createSearchParams } from "./lib/dom/dom.js";
19
+ import { SingleFetchRedirectSymbol, decodeViaTurboStream, getTurboStreamSingleFetchDataStrategy } from "./lib/dom/ssr/single-fetch.js";
20
+ import { RemixErrorBoundary } from "./lib/dom/ssr/errorBoundaries.js";
21
+ import { createClientRoutes, createClientRoutesWithHMRRevalidationOptOut, shouldHydrateRouteLoader } from "./lib/dom/ssr/routes.js";
22
+ import { getPatchRoutesOnNavigationFunction, useFogOFWarDiscovery } from "./lib/dom/ssr/fog-of-war.js";
23
+ import { FrameworkContext, Links, Meta, PrefetchPageLinks, Scripts } from "./lib/dom/ssr/components.js";
24
+ import { BrowserRouter, Form, HashRouter, HistoryRouter, Link, NavLink, ScrollRestoration, createBrowserRouter, createHashRouter, useBeforeUnload, useFetcher, useFetchers, useFormAction, useLinkClickHandler, usePrompt, useScrollRestoration, useSearchParams, useSubmit, useViewTransitionState } from "./lib/dom/lib.js";
25
+ import { StaticRouter, StaticRouterProvider, createStaticRouter } from "./lib/dom/server.js";
26
+ import { ServerRouter } from "./lib/dom/ssr/server.js";
27
+ import { createRoutesStub } from "./lib/dom/ssr/routes-test-stub.js";
28
+ import { createCookie, isCookie } from "./lib/server-runtime/cookies.js";
29
+ import { ServerMode } from "./lib/server-runtime/mode.js";
30
+ import { setDevServerHooks } from "./lib/server-runtime/dev.js";
31
+ import { createRequestHandler } from "./lib/server-runtime/server.js";
32
+ import { createSession, createSessionStorage, isSession } from "./lib/server-runtime/sessions.js";
33
+ import { createCookieSessionStorage } from "./lib/server-runtime/sessions/cookieStorage.js";
34
+ import { createMemorySessionStorage } from "./lib/server-runtime/sessions/memoryStorage.js";
35
+ import { href } from "./lib/href.js";
36
+ import { RSCDefaultRootErrorBoundary } from "./lib/rsc/errorBoundaries.js";
37
+ import { RSCStaticRouter, routeRSCServerRequest } from "./lib/rsc/server.ssr.js";
38
+ import { getHydrationData } from "./lib/dom/ssr/hydration.js";
39
+ //#region index.ts
40
+ /**
41
+ * @module index
42
+ * @mergeModuleWith react-router
43
+ */
44
+ //#endregion
45
+ export { Await, BrowserRouter, Form, HashRouter, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, Link, Links, MemoryRouter, Meta, NavLink, Navigate, Action as NavigationType, Outlet, PrefetchPageLinks, Route, Router, RouterContextProvider, RouterProvider, Routes, Scripts, ScrollRestoration, ServerRouter, StaticRouter, StaticRouterProvider, AwaitContextProvider as UNSAFE_AwaitContextProvider, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, FetchersContext as UNSAFE_FetchersContext, FrameworkContext as UNSAFE_FrameworkContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RSCDefaultRootErrorBoundary as UNSAFE_RSCDefaultRootErrorBoundary, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteContext as UNSAFE_RouteContext, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, ViewTransitionContext as UNSAFE_ViewTransitionContext, WithComponentProps as UNSAFE_WithComponentProps, WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps, WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps, createBrowserHistory as UNSAFE_createBrowserHistory, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, createHashHistory as UNSAFE_createHashHistory, createMemoryHistory as UNSAFE_createMemoryHistory, createRouter as UNSAFE_createRouter, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, defaultMapRouteProperties as UNSAFE_defaultMapRouteProperties, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, invariant as UNSAFE_invariant, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, withComponentProps as UNSAFE_withComponentProps, withErrorBoundaryProps as UNSAFE_withErrorBoundaryProps, withHydrateFallbackProps as UNSAFE_withHydrateFallbackProps, createBrowserRouter, createContext, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createPath, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, data, generatePath, href, isCookie, isRouteErrorResponse, isSession, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, replace, resolvePath, HistoryRouter as unstable_HistoryRouter, RSCStaticRouter as unstable_RSCStaticRouter, routeRSCServerRequest as unstable_routeRSCServerRequest, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useRoute as unstable_useRoute, useRouterState as unstable_useRouterState, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState };