import { DatastarEventOptions, EventType, PatchElementsOptions, PatchSignalsOptions } from "./types.js"; /** * Abstract ServerSentEventGenerator class, responsible for initializing and handling * server-sent events (SSE) as well as reading signals sent by the client. * * The concrete implementation must override the send and constructor methods as well * as implement readSignals and stream static methods. */ export declare abstract class ServerSentEventGenerator { protected constructor(); /** * Validates that the provided mode is a valid ElementPatchMode. * @param mode - The mode to validate * @throws {Error} If the mode is invalid */ private validateElementPatchMode; /** * Validates that the provided namespace is a valid NamespaceType. * @param namespace - The namespace to validate * @throws {Error} If the namespace is invalid */ private validateNamespace; /** * Validates required parameters are not empty or undefined. * @param value - The value to validate * @param paramName - The parameter name for error messages * @throws {Error} If the value is empty or undefined */ private validateRequired; /** * Sends a server-sent event (SSE) to the client. * * Runtimes should override this method by calling the parent function * with `super.send(event, dataLines, options)`. That will return all the * datalines as an array of strings that should be streamed to the client. * * @param eventType - The type of the event. * @param dataLines - Lines of data to send. * @param [sendOptions] - Additional options for sending events. */ protected send(event: EventType, dataLines: string[], options: DatastarEventOptions): T | string[]; /** * Closes the server-sent event stream. * * Use this method to manually close the stream when `keepalive: true` is set. * This is required when you want to close the stream before the client disconnects. * * Concrete implementations must override this method to close the underlying stream. */ abstract close(): void; private eachNewlineIsADataLine; private eachOptionIsADataLine; private hasDefaultValue; /** * Patches HTML elements into the DOM. * * Use this to insert, update, or remove elements in the client DOM. Supports various patch modes and options. * * Examples: * ``` * // Insert new element inside #container * patchElements('
Hello
', { selector: '#container', mode: 'append' }); * * // Replace element by ID * patchElements('
Replaced
'); * * // Remove by selector, note that you can also use removeElements * patchElements('', { selector: '#toRemove', mode: 'remove' }); * * // Remove by elements with IDs, note that you can also use removeElements * patchElements('
', { mode: 'remove' }); * ``` * * @param elements - HTML string of elements to patch (must have IDs unless using selector). * @param options - Patch options: selector, mode, namespace, useViewTransition, eventId, retryDuration. * @returns The SSE lines to send. */ patchElements(elements: string, options?: PatchElementsOptions): ReturnType; /** * Patches signals into the signal store. * * Use this to update client-side signals using RFC 7386 JSON Merge Patch semantics. * * Examples: * ``` * // Patch a single signal * patchSignals('{"show": true}'); * * // Patch multiple signals with onlyIfMissing option * patchSignals('{"output": "Test", "user": {"name": "Alice"}}', { onlyIfMissing: true }); * ``` * * @param signals - JSON string containing signal data to patch. * @param options - Patch options: onlyIfMissing, eventId, retryDuration. * @returns The SSE lines to send. */ patchSignals(signals: string, options?: PatchSignalsOptions): ReturnType; /** * Executes a script on the client by sending a