/** * @link https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#fields */ export type SSEFields = 'data' | 'event' | 'id' | 'retry'; /** * @example * const sseObject = { * event: 'delta', * data: '{ key: "world!" }', * }; */ export type SSEOutput = Partial>; export interface JSONOutPut extends Partial> { success: boolean; message?: string; name?: string; } export interface XStreamOptions { /** * @description Readable stream of binary data * @link https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream */ readableStream: ReadableStream; /** * @description Support customizable transformStream to transform streams * @default sseTransformStream * @link https://developer.mozilla.org/en-US/docs/Web/API/TransformStream */ transformStream?: TransformStream; /** * @description Separator for stream data parsing */ streamSeparator?: string; /** * @description Separator for different parts within the stream */ partSeparator?: string; /** * @description Separator for key-value pairs in the stream data */ kvSeparator?: string; } export type XReadableStream = ReadableStream & AsyncGenerator; /** * @description Transform Uint8Array binary stream to {@link SSEOutput} by default * @warning The `XStream` only support the `utf-8` encoding. More encoding support maybe in the future. */ declare function XStream(options: XStreamOptions): XReadableStream; export default XStream;