@informedai/react 0.4.5 → 0.4.6

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
@@ -33,6 +33,7 @@ var import_react2 = require("react");
33
33
 
34
34
  // src/context/InformedAIContext.tsx
35
35
  var import_react = require("react");
36
+ var import_react_dom = require("react-dom");
36
37
 
37
38
  // src/utils/api-client.ts
38
39
  var DEFAULT_API_URL = "https://api.informedassistant.ai/api/v1";
@@ -518,12 +519,16 @@ function InformedAIProvider({ config, children }) {
518
519
  setStreamingContent((prev) => prev + event.content);
519
520
  }
520
521
  if (event.type === "done" || event.type === "session_update") {
522
+ (0, import_react_dom.flushSync)(() => {
523
+ if (event.session) {
524
+ setSession(event.session);
525
+ }
526
+ setStreamingContent("");
527
+ setIsStreaming(false);
528
+ });
521
529
  if (event.session) {
522
- setSession(event.session);
523
530
  config.onSessionChange?.(event.session);
524
531
  }
525
- setStreamingContent("");
526
- setIsStreaming(false);
527
532
  }
528
533
  if (event.type === "error") {
529
534
  const error2 = new Error(event.error || "Stream error");
package/dist/index.mjs CHANGED
@@ -3,6 +3,7 @@ import { useState as useState2, useRef as useRef2, useEffect as useEffect2 } fro
3
3
 
4
4
  // src/context/InformedAIContext.tsx
5
5
  import { createContext, useContext, useEffect, useState, useCallback, useRef } from "react";
6
+ import { flushSync } from "react-dom";
6
7
 
7
8
  // src/utils/api-client.ts
8
9
  var DEFAULT_API_URL = "https://api.informedassistant.ai/api/v1";
@@ -488,12 +489,16 @@ function InformedAIProvider({ config, children }) {
488
489
  setStreamingContent((prev) => prev + event.content);
489
490
  }
490
491
  if (event.type === "done" || event.type === "session_update") {
492
+ flushSync(() => {
493
+ if (event.session) {
494
+ setSession(event.session);
495
+ }
496
+ setStreamingContent("");
497
+ setIsStreaming(false);
498
+ });
491
499
  if (event.session) {
492
- setSession(event.session);
493
500
  config.onSessionChange?.(event.session);
494
501
  }
495
- setStreamingContent("");
496
- setIsStreaming(false);
497
502
  }
498
503
  if (event.type === "error") {
499
504
  const error2 = new Error(event.error || "Stream error");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@informedai/react",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
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",