| 1 | import { |
| 2 | createTemporaryReferenceSet, |
| 3 | decodeAction, |
| 4 | decodeFormState, |
| 5 | decodeReply, |
| 6 | loadServerAction, |
| 7 | renderToReadableStream, |
| 8 | } from "@vitejs/plugin-rsc/rsc"; |
| 9 | import { unstable_matchRSCServerRequest as matchRSCServerRequest } from "react-router"; |
| 10 | import { routes } from "../app/routes"; |
| 11 | |
| 12 | export function fetchServer(request: Request) { |
| 13 | return matchRSCServerRequest({ |
| 14 | createTemporaryReferenceSet, |
| 15 | decodeAction, |
| 16 | decodeFormState, |
| 17 | decodeReply, |
| 18 | loadServerAction, |
| 19 | request, |
| 20 | routes, |
| 21 | generateResponse(match, options) { |
| 22 | return new Response(renderToReadableStream(match.payload, options), { |
| 23 | status: match.statusCode, |
| 24 | headers: match.headers, |
| 25 | }); |
| 26 | }, |
| 27 | }); |
| 28 | } |
| 29 | |
| 30 | if (import.meta.hot) { |
| 31 | import.meta.hot.accept(); |
| 32 | } |