fully-react
Version:
React Server for Vite
66 lines (63 loc) • 3.3 kB
TypeScript
import react__default, { Thenable } from 'react';
import { E as Env } from '../env-94f3ad21.js';
import 'vite';
import 'react-server-dom-webpack/server.edge';
import 'react-dom/server';
type FlightResponseRef = {
current: null | Thenable<JSX.Element>;
};
/**
* Render Flight stream.
* This is only used for renderToHTML, the Flight response does not need additional wrappers.
*/
declare function useServerElement(serverElementStream: ReadableStream<Uint8Array>, flightResponseRef: FlightResponseRef, writable?: WritableStream<Uint8Array>, onChunk?: (chunk: Uint8Array) => void): react__default.Thenable<JSX.Element>;
/**
* Create a component that renders the Flight stream.
* This is only used for renderToHTML, the Flight response does not need additional wrappers.
*/
declare function createServerComponentRenderer<Props extends any = any>(src: string, { dataStream: writable, ...env }: {
dataStream: WritableStream;
} & Env): (props: Props) => JSX.Element;
/**
* Renders a React element to a ReadableStream of HTML. It first renders the
* element to a ReadableStream of RSC, and then uses the RSC stream to render
* the HTML stream. It then inlines the RSC stream as data in script tags at
* the end of the HTML stream.
*
* When the RSC stream is rendered to HTML, it also renders the Client
* components which were skipped during the RSC render.
*
* @param element React element to render, should be server component
* @param renderOptions
* @returns ReadableStream of HTML
*/
declare function renderToHTMLStream(component: string, props: any, renderOptions: Env & {
dataStream: WritableStream;
}): Promise<ReadableStream<Uint8Array>>;
declare function createHTMLResponse(component: string, props: any, renderOptions: Env, responseInit?: ResponseInit): Promise<Response>;
/**
* Creates a TransformStream that inlines the initial RSC stream that is used * produce the HTML stream, as data in script tags at the end of the HTML
* stream. Note that the RSC stream should be teed before being passed to this
* function, so that the HTML stream can be read from the first tee, and the
* RSC stream can be read from the second tee for inlining.
*
* It inlines it right before the closing body tag, so that the RSC stream
* doesn't have to be parsed/processed by the browser until after the HTML
* stream has been parsed.
*
* The API it exposes on the client is:
* - window.init_rsc: a ReadableStream that is the initial RSC stream,
* should be used for hydration
* - window.rsc_chunk(chunk): a function that can be used to write chunks to
* the RSC stream, which will be inlined in the HTML stream
* @param serverElementStream
* @returns TransformStream
*/
declare function inlineInitialServerComponent(serverElementStream: ReadableStream<Uint8Array>): ReadableWritablePair<Uint8Array, Uint8Array>;
/**
* Creates a TransformStream that buffers the text in the stream, and then
* flushes it all at once at the end of the stream.
* @returns TransformStream
*/
declare function bufferedTransformStream(): ReadableWritablePair<Uint8Array, Uint8Array>;
export { FlightResponseRef, bufferedTransformStream, createHTMLResponse, createServerComponentRenderer, inlineInitialServerComponent, renderToHTMLStream, useServerElement };