@wq-hook/volcano-react 1.0.1 → 1.0.2

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
@@ -1343,6 +1343,7 @@ function useStreamTTS({
1343
1343
  const sourceRef = (0, import_react4.useRef)(null);
1344
1344
  const audioUrlRef = (0, import_react4.useRef)(null);
1345
1345
  const streamTextRef = (0, import_react4.useRef)("");
1346
+ const isConnectedRef = (0, import_react4.useRef)(false);
1346
1347
  const isSessionStartedRef = (0, import_react4.useRef)(false);
1347
1348
  const calledSessionStartedRef = (0, import_react4.useRef)(false);
1348
1349
  const splitterRef = (0, import_react4.useRef)(null);
@@ -1451,6 +1452,7 @@ function useStreamTTS({
1451
1452
  }
1452
1453
  cleanupAudio();
1453
1454
  setIsConnected(false);
1455
+ isConnectedRef.current = false;
1454
1456
  setIsSessionStarted(false);
1455
1457
  isSessionStartedRef.current = false;
1456
1458
  calledSessionStartedRef.current = false;
@@ -1565,6 +1567,7 @@ function useStreamTTS({
1565
1567
  // ===== 关键回调 =====
1566
1568
  onStart: () => {
1567
1569
  setIsConnected(true);
1570
+ isConnectedRef.current = true;
1568
1571
  console.log("[useStreamTTS] WebSocket connected, waiting for text...");
1569
1572
  },
1570
1573
  onSessionStarted: () => {
@@ -1653,13 +1656,13 @@ function useStreamTTS({
1653
1656
  if (!chunk) return;
1654
1657
  streamTextRef.current += chunk;
1655
1658
  setStreamText(streamTextRef.current);
1656
- if (!calledSessionStartedRef.current && !isSessionStartedRef.current && clientRef.current && isConnected) {
1659
+ if (!calledSessionStartedRef.current && !isSessionStartedRef.current && clientRef.current && isConnectedRef.current) {
1657
1660
  console.log("[useStreamTTS] First text received, starting session...");
1658
1661
  calledSessionStartedRef.current = true;
1659
1662
  clientRef.current.startSession();
1660
1663
  }
1661
1664
  splitterRef.current?.onChunk(chunk);
1662
- }, [isConnected]);
1665
+ }, []);
1663
1666
  const finishStream = (0, import_react4.useCallback)(async () => {
1664
1667
  isStreamFinishedRef.current = true;
1665
1668
  splitterRef.current?.complete();
package/dist/index.mjs CHANGED
@@ -1297,6 +1297,7 @@ function useStreamTTS({
1297
1297
  const sourceRef = useRef4(null);
1298
1298
  const audioUrlRef = useRef4(null);
1299
1299
  const streamTextRef = useRef4("");
1300
+ const isConnectedRef = useRef4(false);
1300
1301
  const isSessionStartedRef = useRef4(false);
1301
1302
  const calledSessionStartedRef = useRef4(false);
1302
1303
  const splitterRef = useRef4(null);
@@ -1405,6 +1406,7 @@ function useStreamTTS({
1405
1406
  }
1406
1407
  cleanupAudio();
1407
1408
  setIsConnected(false);
1409
+ isConnectedRef.current = false;
1408
1410
  setIsSessionStarted(false);
1409
1411
  isSessionStartedRef.current = false;
1410
1412
  calledSessionStartedRef.current = false;
@@ -1519,6 +1521,7 @@ function useStreamTTS({
1519
1521
  // ===== 关键回调 =====
1520
1522
  onStart: () => {
1521
1523
  setIsConnected(true);
1524
+ isConnectedRef.current = true;
1522
1525
  console.log("[useStreamTTS] WebSocket connected, waiting for text...");
1523
1526
  },
1524
1527
  onSessionStarted: () => {
@@ -1607,13 +1610,13 @@ function useStreamTTS({
1607
1610
  if (!chunk) return;
1608
1611
  streamTextRef.current += chunk;
1609
1612
  setStreamText(streamTextRef.current);
1610
- if (!calledSessionStartedRef.current && !isSessionStartedRef.current && clientRef.current && isConnected) {
1613
+ if (!calledSessionStartedRef.current && !isSessionStartedRef.current && clientRef.current && isConnectedRef.current) {
1611
1614
  console.log("[useStreamTTS] First text received, starting session...");
1612
1615
  calledSessionStartedRef.current = true;
1613
1616
  clientRef.current.startSession();
1614
1617
  }
1615
1618
  splitterRef.current?.onChunk(chunk);
1616
- }, [isConnected]);
1619
+ }, []);
1617
1620
  const finishStream = useCallback4(async () => {
1618
1621
  isStreamFinishedRef.current = true;
1619
1622
  splitterRef.current?.complete();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wq-hook/volcano-react",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Volcano Engine ASR & TTS React Hooks",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",