import type { HttpContext } from '@adonisjs/core/http'; /** * Writes `this.stream()` chunks straight to the raw HTTP response as they * happen, instead of buffering them until the action finishes — matching * PHP Livewire's `ob_flush()`-per-call behavior instead of this port's * previous "collect everything, send it all in one blob at the end" * approach (see architecture-overview memory / git history for why that * wasn't actually progressive). * * One instance per `/livewire/update` request (see `getStreamWriter()`), * shared across every component processed in that request — multiple * components streaming in the same batch interleave correctly because * `livewire.update()` is awaited sequentially per component, so writes * naturally happen in the order each component's action calls `stream()`. * * Headers are only sent on the FIRST actual `write()` call — a request * that never calls `this.stream()` looks exactly like it did before this * feature existed, no streaming headers, no behavior change. */ export declare class StreamWriter { #private; /** True once at least one chunk has been written. */ used: boolean; constructor(ctx: HttpContext); /** * Write one `this.stream()` call as an NDJSON-style frame. Matches the * client's `extractStreamObjects()` regex: * `{"stream":true,...,"endStream":true}`. * * Fire-and-forget: doesn't wait for Node's `drain` event on backpressure. * Acceptable for the small, infrequent text chunks this feature is for — * a component streaming megabytes per call would need real backpressure * handling, which isn't done here. */ write(body: Record): void; /** * Write the final (normal) Livewire response as the last NDJSON line and * end the response. Only meaningful if `write()` was called at least * once — callers should check `.used` first and fall back to a normal * `return result` otherwise. */ finish(result: unknown): void; } /** * Get (or lazily create) the single `StreamWriter` for this request's * `HttpContext`. Safe to call repeatedly — every `this.stream()` call and * the provider's final response-assembly step share the same instance. */ export declare function getStreamWriter(ctx: HttpContext): StreamWriter;