@informedai/react 0.4.7 → 0.4.8

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.
package/dist/index.js CHANGED
@@ -207,6 +207,7 @@ var InformedAIClient = class {
207
207
  }
208
208
  const decoder = new TextDecoder();
209
209
  let buffer = "";
210
+ let currentEventType = null;
210
211
  try {
211
212
  while (true) {
212
213
  const { done, value } = await reader.read();
@@ -215,20 +216,40 @@ var InformedAIClient = class {
215
216
  const lines = buffer.split("\n");
216
217
  buffer = lines.pop() || "";
217
218
  for (const line of lines) {
218
- if (line.startsWith("data: ")) {
219
+ if (line.startsWith("event: ")) {
220
+ currentEventType = line.slice(7).trim();
221
+ } else if (line.startsWith("data: ")) {
219
222
  try {
220
223
  const data = JSON.parse(line.slice(6));
221
- onEvent(data);
224
+ const sseEvent = {
225
+ type: currentEventType || "content",
226
+ content: data.text,
227
+ // Backend sends 'text', SDK expects 'content'
228
+ session: data.session,
229
+ error: data.error
230
+ };
231
+ onEvent(sseEvent);
232
+ currentEventType = null;
222
233
  } catch {
223
234
  }
224
235
  }
225
236
  }
226
237
  }
227
- if (buffer.startsWith("data: ")) {
228
- try {
229
- const data = JSON.parse(buffer.slice(6));
230
- onEvent(data);
231
- } catch {
238
+ for (const line of buffer.split("\n")) {
239
+ if (line.startsWith("event: ")) {
240
+ currentEventType = line.slice(7).trim();
241
+ } else if (line.startsWith("data: ")) {
242
+ try {
243
+ const data = JSON.parse(line.slice(6));
244
+ const sseEvent = {
245
+ type: currentEventType || "content",
246
+ content: data.text,
247
+ session: data.session,
248
+ error: data.error
249
+ };
250
+ onEvent(sseEvent);
251
+ } catch {
252
+ }
232
253
  }
233
254
  }
234
255
  } finally {
package/dist/index.mjs CHANGED
@@ -177,6 +177,7 @@ var InformedAIClient = class {
177
177
  }
178
178
  const decoder = new TextDecoder();
179
179
  let buffer = "";
180
+ let currentEventType = null;
180
181
  try {
181
182
  while (true) {
182
183
  const { done, value } = await reader.read();
@@ -185,20 +186,40 @@ var InformedAIClient = class {
185
186
  const lines = buffer.split("\n");
186
187
  buffer = lines.pop() || "";
187
188
  for (const line of lines) {
188
- if (line.startsWith("data: ")) {
189
+ if (line.startsWith("event: ")) {
190
+ currentEventType = line.slice(7).trim();
191
+ } else if (line.startsWith("data: ")) {
189
192
  try {
190
193
  const data = JSON.parse(line.slice(6));
191
- onEvent(data);
194
+ const sseEvent = {
195
+ type: currentEventType || "content",
196
+ content: data.text,
197
+ // Backend sends 'text', SDK expects 'content'
198
+ session: data.session,
199
+ error: data.error
200
+ };
201
+ onEvent(sseEvent);
202
+ currentEventType = null;
192
203
  } catch {
193
204
  }
194
205
  }
195
206
  }
196
207
  }
197
- if (buffer.startsWith("data: ")) {
198
- try {
199
- const data = JSON.parse(buffer.slice(6));
200
- onEvent(data);
201
- } catch {
208
+ for (const line of buffer.split("\n")) {
209
+ if (line.startsWith("event: ")) {
210
+ currentEventType = line.slice(7).trim();
211
+ } else if (line.startsWith("data: ")) {
212
+ try {
213
+ const data = JSON.parse(line.slice(6));
214
+ const sseEvent = {
215
+ type: currentEventType || "content",
216
+ content: data.text,
217
+ session: data.session,
218
+ error: data.error
219
+ };
220
+ onEvent(sseEvent);
221
+ } catch {
222
+ }
202
223
  }
203
224
  }
204
225
  } finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@informedai/react",
3
- "version": "0.4.7",
3
+ "version": "0.4.8",
4
4
  "description": "React SDK for InformedAI Assistant - AI-powered content creation widget",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",