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
@@ -0,0 +1,345 @@
1
+ /**
2
+ * react-router v8.0.0-pre.1
3
+ *
4
+ * Copyright (c) Remix Software Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ import { ErrorResponseImpl, RouterContextProvider, defaultMapRouteProperties, isRouteErrorResponse, removeTrailingSlash, stripBasename } from "../router/utils.js";
12
+ import { instrumentHandler } from "../router/instrumentation.js";
13
+ import { createStaticHandler, getStaticContextFromError, isMutationMethod, isRedirectResponse, isResponse } from "../router/router.js";
14
+ import { getManifestPath } from "../dom/ssr/fog-of-war.js";
15
+ import { createEntryRouteModules } from "./entry.js";
16
+ import { isServerMode } from "./mode.js";
17
+ import { sanitizeErrors, serializeError } from "./errors.js";
18
+ import { matchServerRoutes } from "./routeMatching.js";
19
+ import { getBuildTimeHeader, getDevServerHooks } from "./dev.js";
20
+ import { createStaticHandlerDataRoutes } from "./routes.js";
21
+ import { createServerHandoffString } from "./serverHandoff.js";
22
+ import { getDocumentHeaders } from "./headers.js";
23
+ import { throwIfPotentialCSRFAttack } from "../actions.js";
24
+ import { getNormalizedPath } from "./urls.js";
25
+ import { SERVER_NO_BODY_STATUS_CODES, encodeViaTurboStream, generateSingleFetchRedirectResponse, singleFetchAction, singleFetchLoaders } from "./single-fetch.js";
26
+ //#region lib/server-runtime/server.ts
27
+ function derive(build, mode) {
28
+ let dataRoutes = createStaticHandlerDataRoutes(build.routes);
29
+ let serverMode = isServerMode(mode) ? mode : "production";
30
+ let staticHandler = createStaticHandler(dataRoutes, {
31
+ basename: build.basename,
32
+ mapRouteProperties: defaultMapRouteProperties,
33
+ instrumentations: build.entry.module.instrumentations,
34
+ future: build.future
35
+ });
36
+ let errorHandler = build.entry.module.handleError || ((error, { request }) => {
37
+ if (serverMode !== "test" && !request.signal.aborted) console.error(isRouteErrorResponse(error) && error.error ? error.error : error);
38
+ });
39
+ let requestHandler = async (request, initialContext) => {
40
+ let params = {};
41
+ let loadContext;
42
+ let handleError = (error) => {
43
+ if (mode === "development") getDevServerHooks()?.processRequestError?.(error);
44
+ errorHandler(error, {
45
+ context: loadContext,
46
+ params,
47
+ request
48
+ });
49
+ };
50
+ if (initialContext && !(initialContext instanceof RouterContextProvider)) {
51
+ let error = /* @__PURE__ */ new Error("Invalid `context` value provided to `handleRequest`. You must return an instance of `RouterContextProvider` from your `getLoadContext` function.");
52
+ handleError(error);
53
+ return returnLastResortErrorResponse(error, serverMode);
54
+ }
55
+ loadContext = initialContext || new RouterContextProvider();
56
+ let requestUrl = new URL(request.url);
57
+ let normalizedPathname = getNormalizedPath(request).pathname;
58
+ let isSpaMode = getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes";
59
+ if (!build.ssr) {
60
+ let decodedPath = decodeURI(normalizedPathname);
61
+ if (build.basename && build.basename !== "/") {
62
+ let strippedPath = stripBasename(decodedPath, build.basename);
63
+ if (strippedPath == null) {
64
+ errorHandler(new ErrorResponseImpl(404, "Not Found", `Refusing to prerender the \`${decodedPath}\` path because it does not start with the basename \`${build.basename}\``), {
65
+ context: loadContext,
66
+ params,
67
+ request
68
+ });
69
+ return new Response("Not Found", {
70
+ status: 404,
71
+ statusText: "Not Found"
72
+ });
73
+ }
74
+ decodedPath = strippedPath;
75
+ }
76
+ if (build.prerender.length === 0) isSpaMode = true;
77
+ else if (!build.prerender.some((p) => removeTrailingSlash(p) === removeTrailingSlash(decodedPath))) if (requestUrl.pathname.endsWith(".data")) {
78
+ errorHandler(new ErrorResponseImpl(404, "Not Found", `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.`), {
79
+ context: loadContext,
80
+ params,
81
+ request
82
+ });
83
+ return new Response("Not Found", {
84
+ status: 404,
85
+ statusText: "Not Found"
86
+ });
87
+ } else isSpaMode = true;
88
+ }
89
+ let manifestUrl = getManifestPath(build.routeDiscovery.manifestPath, build.basename);
90
+ if (build.routeDiscovery.mode === "lazy" && requestUrl.pathname === manifestUrl) try {
91
+ return await handleManifestRequest(build, staticHandler.dataRoutes, staticHandler._internalRouteBranches, requestUrl);
92
+ } catch (e) {
93
+ handleError(e);
94
+ return new Response("Unknown Server Error", { status: 500 });
95
+ }
96
+ let matches = matchServerRoutes(build.routes, staticHandler.dataRoutes, staticHandler._internalRouteBranches, normalizedPathname, build.basename);
97
+ if (matches && matches.length > 0) Object.assign(params, matches[0].params);
98
+ let response;
99
+ if (requestUrl.pathname.endsWith(".data")) {
100
+ response = await handleSingleFetchRequest(serverMode, build, staticHandler, request, loadContext, handleError);
101
+ if (isRedirectResponse(response)) response = generateSingleFetchRedirectResponse(response, request, build, serverMode);
102
+ if (build.entry.module.handleDataRequest) {
103
+ response = await build.entry.module.handleDataRequest(response, {
104
+ context: loadContext,
105
+ params: matches ? matches[0].params : {},
106
+ request
107
+ });
108
+ if (isRedirectResponse(response)) response = generateSingleFetchRedirectResponse(response, request, build, serverMode);
109
+ }
110
+ } else if (!isSpaMode && matches && matches[matches.length - 1].route.module.default == null && matches[matches.length - 1].route.module.ErrorBoundary == null) response = await handleResourceRequest(serverMode, build, staticHandler, matches.slice(-1)[0].route.id, request, loadContext, handleError);
111
+ else {
112
+ let { pathname } = requestUrl;
113
+ let criticalCss = void 0;
114
+ if (build.unstable_getCriticalCss) criticalCss = await build.unstable_getCriticalCss({ pathname });
115
+ else if (mode === "development" && getDevServerHooks()?.getCriticalCss) criticalCss = await getDevServerHooks()?.getCriticalCss?.(pathname);
116
+ response = await handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError, isSpaMode, criticalCss);
117
+ }
118
+ if (request.method === "HEAD") return new Response(null, {
119
+ headers: response.headers,
120
+ status: response.status,
121
+ statusText: response.statusText
122
+ });
123
+ return response;
124
+ };
125
+ if (build.entry.module.instrumentations) requestHandler = instrumentHandler(requestHandler, build.entry.module.instrumentations.map((i) => i.handler).filter(Boolean));
126
+ return {
127
+ serverMode,
128
+ staticHandler,
129
+ errorHandler,
130
+ requestHandler
131
+ };
132
+ }
133
+ const createRequestHandler = (build, mode) => {
134
+ let _build;
135
+ let serverMode;
136
+ let staticHandler;
137
+ let errorHandler;
138
+ let _requestHandler;
139
+ return async function requestHandler(request, initialContext) {
140
+ _build = typeof build === "function" ? await build() : build;
141
+ if (typeof build === "function") {
142
+ let derived = derive(_build, mode);
143
+ serverMode = derived.serverMode;
144
+ staticHandler = derived.staticHandler;
145
+ errorHandler = derived.errorHandler;
146
+ _requestHandler = derived.requestHandler;
147
+ } else if (!serverMode || !staticHandler || !errorHandler || !_requestHandler) {
148
+ let derived = derive(_build, mode);
149
+ serverMode = derived.serverMode;
150
+ staticHandler = derived.staticHandler;
151
+ errorHandler = derived.errorHandler;
152
+ _requestHandler = derived.requestHandler;
153
+ }
154
+ return _requestHandler(request, initialContext);
155
+ };
156
+ };
157
+ async function handleManifestRequest(build, dataRoutes, branches, url) {
158
+ if (url.toString().length > 7680) return new Response(null, {
159
+ statusText: "Bad Request",
160
+ status: 400
161
+ });
162
+ if (build.assets.version !== url.searchParams.get("version")) return new Response(null, {
163
+ status: 204,
164
+ headers: { "X-Remix-Reload-Document": "true" }
165
+ });
166
+ let patches = {};
167
+ if (url.searchParams.has("paths")) {
168
+ let pathParam = url.searchParams.get("paths") || "";
169
+ let paths = new Set(pathParam.split(",").filter(Boolean));
170
+ for (let path of paths) {
171
+ if (!path.startsWith("/")) path = `/${path}`;
172
+ let matches = matchServerRoutes(build.routes, dataRoutes, branches, path, build.basename);
173
+ if (matches) for (let match of matches) {
174
+ let routeId = match.route.id;
175
+ let route = build.assets.routes[routeId];
176
+ if (route) patches[routeId] = route;
177
+ }
178
+ }
179
+ return Response.json(patches, { headers: { "Cache-Control": "public, max-age=31536000, immutable" } });
180
+ }
181
+ return new Response("Invalid Request", { status: 400 });
182
+ }
183
+ async function handleSingleFetchRequest(serverMode, build, staticHandler, request, loadContext, handleError) {
184
+ return isMutationMethod(request.method) ? await singleFetchAction(build, serverMode, staticHandler, request, loadContext, handleError) : await singleFetchLoaders(build, serverMode, staticHandler, request, loadContext, handleError);
185
+ }
186
+ async function handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError, isSpaMode, criticalCss) {
187
+ try {
188
+ if (isMutationMethod(request.method)) try {
189
+ throwIfPotentialCSRFAttack(request, Array.isArray(build.allowedActionOrigins) ? build.allowedActionOrigins : []);
190
+ } catch (e) {
191
+ handleError(e);
192
+ return new Response("Bad Request", { status: 400 });
193
+ }
194
+ let result = await staticHandler.query(request, {
195
+ requestContext: loadContext,
196
+ generateMiddlewareResponse: async (query) => {
197
+ try {
198
+ let innerResult = await query(request);
199
+ if (!isResponse(innerResult)) innerResult = await renderHtml(innerResult, isSpaMode);
200
+ return innerResult;
201
+ } catch (error) {
202
+ handleError(error);
203
+ return new Response(null, { status: 500 });
204
+ }
205
+ },
206
+ normalizePath: (r) => getNormalizedPath(r)
207
+ });
208
+ if (!isResponse(result)) result = await renderHtml(result, isSpaMode);
209
+ return result;
210
+ } catch (error) {
211
+ handleError(error);
212
+ return new Response(null, { status: 500 });
213
+ }
214
+ async function renderHtml(context, isSpaMode) {
215
+ let headers = getDocumentHeaders(context, build);
216
+ if (SERVER_NO_BODY_STATUS_CODES.has(context.statusCode)) return new Response(null, {
217
+ status: context.statusCode,
218
+ headers
219
+ });
220
+ if (context.errors) {
221
+ Object.values(context.errors).forEach((err) => {
222
+ if (!isRouteErrorResponse(err) || err.error) handleError(err);
223
+ });
224
+ context.errors = sanitizeErrors(context.errors, serverMode);
225
+ }
226
+ let state = {
227
+ loaderData: context.loaderData,
228
+ actionData: context.actionData,
229
+ errors: context.errors
230
+ };
231
+ let baseServerHandoff = {
232
+ basename: build.basename,
233
+ future: build.future,
234
+ routeDiscovery: build.routeDiscovery,
235
+ ssr: build.ssr,
236
+ isSpaMode
237
+ };
238
+ let entryContext = {
239
+ manifest: build.assets,
240
+ branches: staticHandler._internalRouteBranches,
241
+ routeModules: createEntryRouteModules(build.routes),
242
+ staticHandlerContext: context,
243
+ criticalCss,
244
+ serverHandoffString: createServerHandoffString({
245
+ ...baseServerHandoff,
246
+ criticalCss
247
+ }),
248
+ serverHandoffStream: encodeViaTurboStream(state, request.signal, build.entry.module.streamTimeout, serverMode),
249
+ renderMeta: {},
250
+ future: build.future,
251
+ ssr: build.ssr,
252
+ routeDiscovery: build.routeDiscovery,
253
+ isSpaMode,
254
+ serializeError: (err) => serializeError(err, serverMode)
255
+ };
256
+ let handleDocumentRequestFunction = build.entry.module.default;
257
+ try {
258
+ return await handleDocumentRequestFunction(request, context.statusCode, headers, entryContext, loadContext);
259
+ } catch (error) {
260
+ handleError(error);
261
+ let errorForSecondRender = error;
262
+ if (isResponse(error)) try {
263
+ let data = await unwrapResponse(error);
264
+ errorForSecondRender = new ErrorResponseImpl(error.status, error.statusText, data);
265
+ } catch (e) {}
266
+ context = getStaticContextFromError(staticHandler.dataRoutes, context, errorForSecondRender);
267
+ if (context.errors) context.errors = sanitizeErrors(context.errors, serverMode);
268
+ let state = {
269
+ loaderData: context.loaderData,
270
+ actionData: context.actionData,
271
+ errors: context.errors
272
+ };
273
+ entryContext = {
274
+ ...entryContext,
275
+ staticHandlerContext: context,
276
+ serverHandoffString: createServerHandoffString(baseServerHandoff),
277
+ serverHandoffStream: encodeViaTurboStream(state, request.signal, build.entry.module.streamTimeout, serverMode),
278
+ renderMeta: {}
279
+ };
280
+ try {
281
+ return await handleDocumentRequestFunction(request, context.statusCode, headers, entryContext, loadContext);
282
+ } catch (error) {
283
+ handleError(error);
284
+ return returnLastResortErrorResponse(error, serverMode);
285
+ }
286
+ }
287
+ }
288
+ }
289
+ async function handleResourceRequest(serverMode, build, staticHandler, routeId, request, loadContext, handleError) {
290
+ try {
291
+ return handleQueryRouteResult(await staticHandler.queryRoute(request, {
292
+ routeId,
293
+ requestContext: loadContext,
294
+ generateMiddlewareResponse: async (queryRoute) => {
295
+ try {
296
+ return handleQueryRouteResult(await queryRoute(request));
297
+ } catch (error) {
298
+ return handleQueryRouteError(error);
299
+ }
300
+ },
301
+ normalizePath: (r) => getNormalizedPath(r)
302
+ }));
303
+ } catch (error) {
304
+ return handleQueryRouteError(error);
305
+ }
306
+ function handleQueryRouteResult(result) {
307
+ if (isResponse(result)) return result;
308
+ if (typeof result === "string") return new Response(result);
309
+ return Response.json(result);
310
+ }
311
+ function handleQueryRouteError(error) {
312
+ if (isResponse(error)) return error;
313
+ if (isRouteErrorResponse(error)) {
314
+ handleError(error);
315
+ return errorResponseToJson(error, serverMode);
316
+ }
317
+ if (error instanceof Error && error.message === "Expected a response from queryRoute") {
318
+ let newError = /* @__PURE__ */ new Error("Expected a Response to be returned from resource route handler");
319
+ handleError(newError);
320
+ return returnLastResortErrorResponse(newError, serverMode);
321
+ }
322
+ handleError(error);
323
+ return returnLastResortErrorResponse(error, serverMode);
324
+ }
325
+ }
326
+ function errorResponseToJson(errorResponse, serverMode) {
327
+ return Response.json(serializeError(errorResponse.error || /* @__PURE__ */ new Error("Unexpected Server Error"), serverMode), {
328
+ status: errorResponse.status,
329
+ statusText: errorResponse.statusText
330
+ });
331
+ }
332
+ function returnLastResortErrorResponse(error, serverMode) {
333
+ let message = "Unexpected Server Error";
334
+ if (serverMode !== "production") message += `\n\n${String(error)}`;
335
+ return new Response(message, {
336
+ status: 500,
337
+ headers: { "Content-Type": "text/plain" }
338
+ });
339
+ }
340
+ function unwrapResponse(response) {
341
+ let contentType = response.headers.get("Content-Type");
342
+ return contentType && /\bapplication\/json\b/.test(contentType) ? response.body == null ? null : response.json() : response.text();
343
+ }
344
+ //#endregion
345
+ export { createRequestHandler };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * react-router v8.0.0-pre.1
3
+ *
4
+ * Copyright (c) Remix Software Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ import { escapeHtml } from "../dom/ssr/markup.js";
12
+ //#region lib/server-runtime/serverHandoff.ts
13
+ function createServerHandoffString(serverHandoff) {
14
+ return escapeHtml(JSON.stringify(serverHandoff));
15
+ }
16
+ //#endregion
17
+ export { createServerHandoffString };
@@ -0,0 +1,25 @@
1
+
2
+ import { SessionData, SessionIdStorageStrategy, SessionStorage } from "../sessions.js";
3
+
4
+ //#region lib/server-runtime/sessions/cookieStorage.d.ts
5
+ interface CookieSessionStorageOptions {
6
+ /**
7
+ * The Cookie used to store the session data on the client, or options used
8
+ * to automatically create one.
9
+ */
10
+ cookie?: SessionIdStorageStrategy["cookie"];
11
+ }
12
+ /**
13
+ * Creates and returns a SessionStorage object that stores all session data
14
+ * directly in the session cookie itself.
15
+ *
16
+ * This has the advantage that no database or other backend services are
17
+ * needed, and can help to simplify some load-balanced scenarios. However, it
18
+ * also has the limitation that serialized session data may not exceed the
19
+ * browser's maximum cookie size. Trade-offs!
20
+ */
21
+ declare function createCookieSessionStorage<Data = SessionData, FlashData = Data>({
22
+ cookie: cookieArg
23
+ }?: CookieSessionStorageOptions): SessionStorage<Data, FlashData>;
24
+ //#endregion
25
+ export { createCookieSessionStorage };
@@ -0,0 +1,45 @@
1
+ /**
2
+ * react-router v8.0.0-pre.1
3
+ *
4
+ * Copyright (c) Remix Software Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ import { createCookie, isCookie } from "../cookies.js";
12
+ import { createSession, warnOnceAboutSigningSessionCookie } from "../sessions.js";
13
+ //#region lib/server-runtime/sessions/cookieStorage.ts
14
+ /**
15
+ * Creates and returns a SessionStorage object that stores all session data
16
+ * directly in the session cookie itself.
17
+ *
18
+ * This has the advantage that no database or other backend services are
19
+ * needed, and can help to simplify some load-balanced scenarios. However, it
20
+ * also has the limitation that serialized session data may not exceed the
21
+ * browser's maximum cookie size. Trade-offs!
22
+ */
23
+ function createCookieSessionStorage({ cookie: cookieArg } = {}) {
24
+ let cookie = isCookie(cookieArg) ? cookieArg : createCookie(cookieArg?.name || "__session", cookieArg);
25
+ warnOnceAboutSigningSessionCookie(cookie);
26
+ return {
27
+ async getSession(cookieHeader, options) {
28
+ return createSession(cookieHeader && await cookie.parse(cookieHeader, options) || {});
29
+ },
30
+ async commitSession(session, options) {
31
+ let serializedCookie = await cookie.serialize(session.data, options);
32
+ if (serializedCookie.length > 4096) throw new Error("Cookie length will exceed browser maximum. Length: " + serializedCookie.length);
33
+ return serializedCookie;
34
+ },
35
+ async destroySession(_session, options) {
36
+ return cookie.serialize("", {
37
+ ...options,
38
+ maxAge: void 0,
39
+ expires: /* @__PURE__ */ new Date(0)
40
+ });
41
+ }
42
+ };
43
+ }
44
+ //#endregion
45
+ export { createCookieSessionStorage };
@@ -0,0 +1,23 @@
1
+
2
+ import { SessionData, SessionIdStorageStrategy, SessionStorage } from "../sessions.js";
3
+
4
+ //#region lib/server-runtime/sessions/memoryStorage.d.ts
5
+ interface MemorySessionStorageOptions {
6
+ /**
7
+ * The Cookie used to store the session id on the client, or options used
8
+ * to automatically create one.
9
+ */
10
+ cookie?: SessionIdStorageStrategy["cookie"];
11
+ }
12
+ /**
13
+ * Creates and returns a simple in-memory SessionStorage object, mostly useful
14
+ * for testing and as a reference implementation.
15
+ *
16
+ * Note: This storage does not scale beyond a single process, so it is not
17
+ * suitable for most production scenarios.
18
+ */
19
+ declare function createMemorySessionStorage<Data = SessionData, FlashData = Data>({
20
+ cookie
21
+ }?: MemorySessionStorageOptions): SessionStorage<Data, FlashData>;
22
+ //#endregion
23
+ export { createMemorySessionStorage };
@@ -0,0 +1,52 @@
1
+ /**
2
+ * react-router v8.0.0-pre.1
3
+ *
4
+ * Copyright (c) Remix Software Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ import { createSessionStorage } from "../sessions.js";
12
+ //#region lib/server-runtime/sessions/memoryStorage.ts
13
+ /**
14
+ * Creates and returns a simple in-memory SessionStorage object, mostly useful
15
+ * for testing and as a reference implementation.
16
+ *
17
+ * Note: This storage does not scale beyond a single process, so it is not
18
+ * suitable for most production scenarios.
19
+ */
20
+ function createMemorySessionStorage({ cookie } = {}) {
21
+ let map = /* @__PURE__ */ new Map();
22
+ return createSessionStorage({
23
+ cookie,
24
+ async createData(data, expires) {
25
+ let id = Math.random().toString(36).substring(2, 10);
26
+ map.set(id, {
27
+ data,
28
+ expires
29
+ });
30
+ return id;
31
+ },
32
+ async readData(id) {
33
+ if (map.has(id)) {
34
+ let { data, expires } = map.get(id);
35
+ if (!expires || expires > /* @__PURE__ */ new Date()) return data;
36
+ if (expires) map.delete(id);
37
+ }
38
+ return null;
39
+ },
40
+ async updateData(id, data, expires) {
41
+ map.set(id, {
42
+ data,
43
+ expires
44
+ });
45
+ },
46
+ async deleteData(id) {
47
+ map.delete(id);
48
+ }
49
+ });
50
+ }
51
+ //#endregion
52
+ export { createMemorySessionStorage };
@@ -0,0 +1,145 @@
1
+
2
+ import { Cookie, CookieOptions } from "./cookies.js";
3
+ import { CookieParseOptions, CookieSerializeOptions } from "cookie-es";
4
+
5
+ //#region lib/server-runtime/sessions.d.ts
6
+ /**
7
+ * An object of name/value pairs to be used in the session.
8
+ */
9
+ interface SessionData {
10
+ [name: string]: any;
11
+ }
12
+ /**
13
+ * Session persists data across HTTP requests.
14
+ *
15
+ * @see https://reactrouter.com/explanation/sessions-and-cookies#sessions
16
+ */
17
+ interface Session<Data = SessionData, FlashData = Data> {
18
+ /**
19
+ * A unique identifier for this session.
20
+ *
21
+ * Note: This will be the empty string for newly created sessions and
22
+ * sessions that are not backed by a database (i.e. cookie-based sessions).
23
+ */
24
+ readonly id: string;
25
+ /**
26
+ * The raw data contained in this session.
27
+ *
28
+ * This is useful mostly for SessionStorage internally to access the raw
29
+ * session data to persist.
30
+ */
31
+ readonly data: FlashSessionData<Data, FlashData>;
32
+ /**
33
+ * Returns `true` if the session has a value for the given `name`, `false`
34
+ * otherwise.
35
+ */
36
+ has(name: (keyof Data | keyof FlashData) & string): boolean;
37
+ /**
38
+ * Returns the value for the given `name` in this session.
39
+ */
40
+ get<Key extends (keyof Data | keyof FlashData) & string>(name: Key): (Key extends keyof Data ? Data[Key] : undefined) | (Key extends keyof FlashData ? FlashData[Key] : undefined) | undefined;
41
+ /**
42
+ * Sets a value in the session for the given `name`.
43
+ */
44
+ set<Key extends keyof Data & string>(name: Key, value: Data[Key]): void;
45
+ /**
46
+ * Sets a value in the session that is only valid until the next `get()`.
47
+ * This can be useful for temporary values, like error messages.
48
+ */
49
+ flash<Key extends keyof FlashData & string>(name: Key, value: FlashData[Key]): void;
50
+ /**
51
+ * Removes a value from the session.
52
+ */
53
+ unset(name: keyof Data & string): void;
54
+ }
55
+ type FlashSessionData<Data, FlashData> = Partial<Data & { [Key in keyof FlashData as FlashDataKey<Key & string>]: FlashData[Key] }>;
56
+ type FlashDataKey<Key extends string> = `__flash_${Key}__`;
57
+ type CreateSessionFunction = <Data = SessionData, FlashData = Data>(initialData?: Data, id?: string) => Session<Data, FlashData>;
58
+ /**
59
+ * Creates a new Session object.
60
+ *
61
+ * Note: This function is typically not invoked directly by application code.
62
+ * Instead, use a `SessionStorage` object's `getSession` method.
63
+ */
64
+ declare const createSession: CreateSessionFunction;
65
+ type IsSessionFunction = (object: any) => object is Session;
66
+ /**
67
+ * Returns true if an object is a React Router session.
68
+ *
69
+ * @see https://reactrouter.com/api/utils/isSession
70
+ */
71
+ declare const isSession: IsSessionFunction;
72
+ /**
73
+ * SessionStorage stores session data between HTTP requests and knows how to
74
+ * parse and create cookies.
75
+ *
76
+ * A SessionStorage creates Session objects using a `Cookie` header as input.
77
+ * Then, later it generates the `Set-Cookie` header to be used in the response.
78
+ */
79
+ interface SessionStorage<Data = SessionData, FlashData = Data> {
80
+ /**
81
+ * Parses a Cookie header from a HTTP request and returns the associated
82
+ * Session. If there is no session associated with the cookie, this will
83
+ * return a new Session with no data.
84
+ */
85
+ getSession: (cookieHeader?: string | null, options?: CookieParseOptions) => Promise<Session<Data, FlashData>>;
86
+ /**
87
+ * Stores all data in the Session and returns the Set-Cookie header to be
88
+ * used in the HTTP response.
89
+ */
90
+ commitSession: (session: Session<Data, FlashData>, options?: CookieSerializeOptions) => Promise<string>;
91
+ /**
92
+ * Deletes all data associated with the Session and returns the Set-Cookie
93
+ * header to be used in the HTTP response.
94
+ */
95
+ destroySession: (session: Session<Data, FlashData>, options?: CookieSerializeOptions) => Promise<string>;
96
+ }
97
+ /**
98
+ * SessionIdStorageStrategy is designed to allow anyone to easily build their
99
+ * own SessionStorage using `createSessionStorage(strategy)`.
100
+ *
101
+ * This strategy describes a common scenario where the session id is stored in
102
+ * a cookie but the actual session data is stored elsewhere, usually in a
103
+ * database or on disk. A set of create, read, update, and delete operations
104
+ * are provided for managing the session data.
105
+ */
106
+ interface SessionIdStorageStrategy<Data = SessionData, FlashData = Data> {
107
+ /**
108
+ * The Cookie used to store the session id, or options used to automatically
109
+ * create one.
110
+ */
111
+ cookie?: Cookie | (CookieOptions & {
112
+ name?: string;
113
+ });
114
+ /**
115
+ * Creates a new record with the given data and returns the session id.
116
+ */
117
+ createData: (data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<string>;
118
+ /**
119
+ * Returns data for a given session id, or `null` if there isn't any.
120
+ */
121
+ readData: (id: string) => Promise<FlashSessionData<Data, FlashData> | null>;
122
+ /**
123
+ * Updates data for the given session id.
124
+ */
125
+ updateData: (id: string, data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<void>;
126
+ /**
127
+ * Deletes data for a given session id from the data store.
128
+ */
129
+ deleteData: (id: string) => Promise<void>;
130
+ }
131
+ /**
132
+ * Creates a SessionStorage object using a SessionIdStorageStrategy.
133
+ *
134
+ * Note: This is a low-level API that should only be used if none of the
135
+ * existing session storage options meet your requirements.
136
+ */
137
+ declare function createSessionStorage<Data = SessionData, FlashData = Data>({
138
+ cookie: cookieArg,
139
+ createData,
140
+ readData,
141
+ updateData,
142
+ deleteData
143
+ }: SessionIdStorageStrategy<Data, FlashData>): SessionStorage<Data, FlashData>;
144
+ //#endregion
145
+ export { FlashSessionData, IsSessionFunction, Session, SessionData, SessionIdStorageStrategy, SessionStorage, createSession, createSessionStorage, isSession };