/** * This is a utility function to make scheduling sequential tasks that run back to back easier. * We schedule on the same queue (setImmediate) at the same time to ensure no other events can sneak in between. */ export declare function prerenderAndAbortInSequentialTasks(prerender: () => Promise, abort: () => void): Promise; export declare function prerenderServerWithPhases(signal: AbortSignal, render: () => ReadableStream, finalPhase: () => void): Promise; export declare function prerenderServerWithPhases(signal: AbortSignal, render: () => ReadableStream, secondPhase: () => void, finalPhase: () => void): Promise; export declare function prerenderServerWithPhases(signal: AbortSignal, render: () => ReadableStream, secondPhase: () => void, thirdPhase: () => void, ...remainingPhases: Array<() => void>): Promise; export declare class ServerPrerenderStreamResult { private currentChunks; private chunksByPhase; private trailingChunks; private status; private reason; constructor(stream: ReadableStream); markPhase(): void; markComplete(): void; markInterrupted(): void; /** * Returns a stream which only releases chunks when `releasePhase` is called. This stream will never "complete" because * we rely upon the stream remaining open when prerendering to avoid triggering errors for incomplete chunks in the client. * * asPhasedStream is expected to be called once per result however it is safe to call multiple times as long as we have not * transferred the underlying data. Generally this will only happen when streaming to a response */ asPhasedStream(): PhasedStream>; /** * Returns a stream which will release all chunks immediately. This stream will "complete" synchronously. It should be used outside * of render use cases like loading client chunks ahead of SSR or writing the streamed content to disk. */ asStream(): ReadableStream; } declare class PhasedStream extends ReadableStream { private nextPhase; private chunksByPhase; private destination; constructor(chunksByPhase: Array>); releasePhase(): void; assertExhausted(): void; } export declare function prerenderClientWithPhases(render: () => Promise, finalPhase: () => void): Promise; export declare function prerenderClientWithPhases(render: () => Promise, secondPhase: () => void, finalPhase: () => void): Promise; export declare function prerenderClientWithPhases(render: () => Promise, secondPhase: () => void, thirdPhase: () => void, ...remainingPhases: Array<() => void>): Promise; export declare class ReactServerResult { private _stream; constructor(stream: ReadableStream); tee(): ReadableStream>; consume(): ReadableStream>; } export type ReactServerPrerenderResolveToType = { prelude: ReadableStream; }; export declare function createReactServerPrerenderResult(underlying: Promise): Promise; export declare function createReactServerPrerenderResultFromRender(underlying: ReadableStream): Promise; export declare class ReactServerPrerenderResult { private _chunks; private assertChunks; private consumeChunks; consume(): void; constructor(chunks: Array); asUnclosingStream(): ReadableStream; consumeAsUnclosingStream(): ReadableStream; asStream(): ReadableStream; consumeAsStream(): ReadableStream; } export {};