import { DatastarEventOptions, EventType, StreamOptions, Jsonifiable } from "../types.js"; import { ServerSentEventGenerator as AbstractSSEGenerator } from "../abstractServerSentEventGenerator.js"; /** * ServerSentEventGenerator class, responsible for initializing and handling * server-sent events (SSE) as well as reading signals sent by the client. * Cannot be instantiated directly, you must use the stream static method. */ export declare class ServerSentEventGenerator extends AbstractSSEGenerator { protected controller: ReadableStreamDefaultController; protected constructor(controller: ReadableStreamDefaultController); /** * Initializes the server-sent event generator and executes the onStart callback. * * @param onStart - A function that will be passed the initialized ServerSentEventGenerator class as it's first parameter. * @param options? - An object that can contain options for the Response constructor onError and onCancel callbacks and a keepalive boolean. * The onAbort callback will be called whenever the request is aborted or the stream is cancelled * * The onError callback will be called whenever an error is met. If provided, the onAbort callback will also be executed. * If an onError callback is not provided, then the stream will be ended and the error will be thrown up. * * If responseInit is provided, then it will be passed to the Response constructor along with the default headers. * * The stream is always closed after the onStart callback ends. * If onStart is non blocking, but you still need the stream to stay open after it is called, * then the keepalive option will maintain it open until the request is aborted by the client. * * @returns an HTTP Response */ static stream(onStart: (stream: ServerSentEventGenerator) => Promise | void, options?: StreamOptions): Response; protected send(event: EventType, dataLines: string[], options: DatastarEventOptions): string[]; /** * Closes the server-sent event stream. * * Closes the ReadableStream controller. */ close(): void; /** * Reads client sent signals based on HTTP methods * * @params request - The HTTP Request object. * * @returns An object containing a success boolean and either the client's signals or an error message. */ static readSignals(request: Request): Promise<{ success: true; signals: Record; } | { success: false; error: string; }>; } //# sourceMappingURL=serverSentEventGenerator.d.ts.map