@umituz/web-ai 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,6 +33,16 @@ type ParsedSseEvent<TToolCall = unknown> = {
33
33
  };
34
34
  declare function parseSseEvent<TToolCall = unknown>(rawEvent: string): ParsedSseEvent<TToolCall> | null;
35
35
  declare function readSseResponse<TToolCall = unknown>(response: Response, callbacks: StreamCallbacks<TToolCall>): Promise<void>;
36
+ /** Yield each SSE event's data payload from a Response (or its raw body).
37
+ * A payload split across network chunks reassembles before it yields;
38
+ * frames without data never surface. The reader is always released AND
39
+ * the body cancelled — including when the consumer breaks out of the
40
+ * loop early, throws inside it, or the stream errors mid-read. */
41
+ declare function iterateSseData(source: Response | ReadableStream<Uint8Array>): AsyncGenerator<string>;
42
+ /** iterateSseData + JSON.parse: yields T per frame and skips frames that
43
+ * don't parse — one malformed frame never kills the stream; the next
44
+ * frame boundary resyncs it. */
45
+ declare function iterateSseJson<T>(source: Response | ReadableStream<Uint8Array>): AsyncGenerator<T>;
36
46
 
37
47
  /** Body the backend chat endpoint expects. Kept generic on purpose —
38
48
  * `settings` is whatever the app's API contract defines. */
@@ -67,4 +77,4 @@ interface RemoteChatClient {
67
77
  }
68
78
  declare function createRemoteChatClient(options: RemoteChatClientOptions): RemoteChatClient;
69
79
 
70
- export { type ParsedSseEvent as P, type RemoteChatClient as R, type StreamCallbacks as S, type RemoteChatClientOptions as a, type RemoteChatStreamBody as b, type RemoteChatUrls as c, type RemoteStreamHandle as d, createRemoteChatClient as e, parseSseEvent as p, readSseResponse as r };
80
+ export { type ParsedSseEvent as P, type RemoteChatClient as R, type StreamCallbacks as S, type RemoteChatClientOptions as a, type RemoteChatStreamBody as b, type RemoteChatUrls as c, type RemoteStreamHandle as d, createRemoteChatClient as e, iterateSseJson as f, iterateSseData as i, parseSseEvent as p, readSseResponse as r };
@@ -33,6 +33,16 @@ type ParsedSseEvent<TToolCall = unknown> = {
33
33
  };
34
34
  declare function parseSseEvent<TToolCall = unknown>(rawEvent: string): ParsedSseEvent<TToolCall> | null;
35
35
  declare function readSseResponse<TToolCall = unknown>(response: Response, callbacks: StreamCallbacks<TToolCall>): Promise<void>;
36
+ /** Yield each SSE event's data payload from a Response (or its raw body).
37
+ * A payload split across network chunks reassembles before it yields;
38
+ * frames without data never surface. The reader is always released AND
39
+ * the body cancelled — including when the consumer breaks out of the
40
+ * loop early, throws inside it, or the stream errors mid-read. */
41
+ declare function iterateSseData(source: Response | ReadableStream<Uint8Array>): AsyncGenerator<string>;
42
+ /** iterateSseData + JSON.parse: yields T per frame and skips frames that
43
+ * don't parse — one malformed frame never kills the stream; the next
44
+ * frame boundary resyncs it. */
45
+ declare function iterateSseJson<T>(source: Response | ReadableStream<Uint8Array>): AsyncGenerator<T>;
36
46
 
37
47
  /** Body the backend chat endpoint expects. Kept generic on purpose —
38
48
  * `settings` is whatever the app's API contract defines. */
@@ -67,4 +77,4 @@ interface RemoteChatClient {
67
77
  }
68
78
  declare function createRemoteChatClient(options: RemoteChatClientOptions): RemoteChatClient;
69
79
 
70
- export { type ParsedSseEvent as P, type RemoteChatClient as R, type StreamCallbacks as S, type RemoteChatClientOptions as a, type RemoteChatStreamBody as b, type RemoteChatUrls as c, type RemoteStreamHandle as d, createRemoteChatClient as e, parseSseEvent as p, readSseResponse as r };
80
+ export { type ParsedSseEvent as P, type RemoteChatClient as R, type StreamCallbacks as S, type RemoteChatClientOptions as a, type RemoteChatStreamBody as b, type RemoteChatUrls as c, type RemoteStreamHandle as d, createRemoteChatClient as e, iterateSseJson as f, iterateSseData as i, parseSseEvent as p, readSseResponse as r };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/web-ai",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "Provider-agnostic AI engine for web and edge — text, chat, structured output and streaming over swappable providers (Anthropic, Groq, Gemini, fal, Pruna), plus a content generation suite",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",