vite-plugin-react-server
Version:
Vite plugin for React Server Components (RSC)
49 lines • 1.69 kB
TypeScript
/**
* renderPage.client.ts
*
* PURPOSE: Client-side static page rendering for React Server Components
*
* ARCHITECTURE OVERVIEW:
*
* CLIENT-SIDE vs SERVER-SIDE:
* - Server-side: RSC generation in main thread, HTML generation in worker
* - Client-side: RSC generation in worker, HTML generation in main thread
*
* FLOW:
* 1. RSC Worker generates RSC content with HTML wrapper
* 2. RSC content is buffered to allow dual consumption
* 3. Buffered RSC stream is consumed twice:
* - For RSC file writing (index.rsc)
* - For HTML transformation (index.html)
* 4. HTML transform processes RSC content in main thread
* 5. Both files are written to filesystem
*
* KEY INSIGHT: Node.js streams can only be consumed once, so we buffer the RSC
* content to allow it to be used for both RSC file generation and HTML transformation.
* This follows the pattern from collectRscContent.ts.
*
* HELPER FUNCTIONS:
* - createBufferedRscStream: Creates a buffered stream for dual consumption
* - createRscToHtmlStream: Transforms RSC content to HTML in main thread
*
* USAGE:
* ```typescript
* const result = await renderPage({
* route: "/",
* pagePath: "src/page/page.tsx",
* // ... other options
* });
*
* // result.html.pipe(htmlFileWriter);
* // result.rsc.pipe(rscFileWriter);
* ```
*/
import type { RenderPageFn } from "./types.js";
/**
* Client version of renderPage that uses the react-client pattern
* This works in REVERSE from the server plugin:
* - Server: Main thread (RSC) + HTML worker (HTML)
* - Client: RSC worker (RSC) + Main thread (HTML)
*/
export declare const renderPage: RenderPageFn;
//# sourceMappingURL=renderPage.client.d.ts.map