Files
med-notes/.pnpm-store/v10/files/a6/90a27ea88d7bc0acf0ee4663ea691425d673e7c016d251430940ec6c66533b9ab2a17d5c0c0e957cdc48154dfdea3e98c247648caba52aeaf19eb1eeec16e9
2025-05-09 05:30:08 +02:00

115 lines
4.0 KiB
Plaintext

// forward declarations
declare global {
namespace NodeJS {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface ReadableStream {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface WritableStream {}
}
/**
* Stub for https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
*/
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface AbortSignal {}
/**
* Stub for https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream
*/
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface ReadableStream {}
}
import { ReactNode } from "react";
import { ErrorInfo } from "./client";
export type BootstrapScriptDescriptor = {
src: string;
integrity?: string | undefined;
crossOrigin?: string | undefined;
};
export interface RenderToPipeableStreamOptions {
identifierPrefix?: string;
namespaceURI?: string;
nonce?: string;
bootstrapScriptContent?: string;
bootstrapScripts?: Array<string | BootstrapScriptDescriptor>;
bootstrapModules?: Array<string | BootstrapScriptDescriptor>;
progressiveChunkSize?: number;
onShellReady?: () => void;
onShellError?: (error: unknown) => void;
onAllReady?: () => void;
onError?: (error: unknown, errorInfo: ErrorInfo) => string | void;
}
export interface PipeableStream {
abort: (reason?: unknown) => void;
pipe: <Writable extends NodeJS.WritableStream>(destination: Writable) => Writable;
}
export interface ServerOptions {
identifierPrefix?: string;
}
/**
* Only available in the environments with [Node.js Streams](https://nodejs.dev/learn/nodejs-streams).
*
* @see [API](https://reactjs.org/docs/react-dom-server.html#rendertopipeablestream)
*
* @param children
* @param options
*/
export function renderToPipeableStream(children: ReactNode, options?: RenderToPipeableStreamOptions): PipeableStream;
/**
* Render a React element to its initial HTML. This should only be used on the server.
* React will return an HTML string. You can use this method to generate HTML on the server
* and send the markup down on the initial request for faster page loads and to allow search
* engines to crawl your pages for SEO purposes.
*
* If you call `ReactDOMClient.hydrateRoot()` on a node that already has this server-rendered markup,
* React will preserve it and only attach event handlers, allowing you
* to have a very performant first-load experience.
*/
export function renderToString(element: ReactNode, options?: ServerOptions): string;
/**
* Similar to `renderToString`, except this doesn't create extra DOM attributes
* such as `data-reactid`, that React uses internally. This is useful if you want
* to use React as a simple static page generator, as stripping away the extra
* attributes can save lots of bytes.
*/
export function renderToStaticMarkup(element: ReactNode, options?: ServerOptions): string;
export interface RenderToReadableStreamOptions {
identifierPrefix?: string;
namespaceURI?: string;
nonce?: string;
bootstrapScriptContent?: string;
bootstrapScripts?: Array<string | BootstrapScriptDescriptor>;
bootstrapModules?: Array<string | BootstrapScriptDescriptor>;
progressiveChunkSize?: number;
signal?: AbortSignal;
onError?: (error: unknown, errorInfo: ErrorInfo) => string | void;
}
export interface ReactDOMServerReadableStream extends ReadableStream {
allReady: Promise<void>;
}
/**
* Only available in the environments with [Web Streams](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API) (this includes browsers, Deno, and some modern edge runtimes).
*
* @see [API](https://reactjs.org/docs/react-dom-server.html#rendertoreadablestream)
*/
export function renderToReadableStream(
children: ReactNode,
options?: RenderToReadableStreamOptions,
): Promise<ReactDOMServerReadableStream>;
export const version: string;
export as namespace ReactDOMServer;