@avvyr/storefront-sdk - v0.19.0
    Preparing search index...

    Interface SseReader

    Minimal Server-Sent Events reader for fetch responses.

    EventSource only does GET without custom headers, so streamed POST endpoints (the assistant's messages) are read straight off response.body. Works wherever fetch returns a WHATWG ReadableStream: every modern browser and Node 18+.

    Follows the parts of the SSE format the API uses: data: lines (several in one event are joined with a newline), events separated by a blank line, : comment lines ignored, and \n, \r\n or \r as line endings. A chunk may end anywhere, including mid-line or in the middle of a multi-byte character, so text is decoded in streaming mode and only complete lines are parsed. Whatever is left when the stream ends is flushed as a last event.

    interface SseReader {
        end(): void;
        push(text: string): void;
    }
    Index
    • The stream ended: dispatch a trailing event that had no blank line after it.

      Returns void

    • Feed a chunk of decoded text. Calls onData for every complete event.

      Parameters

      • text: string

      Returns void