@voicemaster/react 1.0.3 → 1.0.5

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.d.mts CHANGED
@@ -1,18 +1,20 @@
1
- import { VoiceClientConfig, VoiceClient } from '@voicemaster/core';
2
-
3
- interface UseVoiceOptions extends VoiceClientConfig {
1
+ interface UseVoiceOptions {
2
+ signalingUrl: string;
3
+ roomId: string;
4
+ userId: string;
5
+ iceServers?: any[];
4
6
  autoConnect?: boolean;
5
7
  }
6
8
  declare function useVoice(options: UseVoiceOptions): {
7
9
  isConnected: boolean;
8
10
  isMuted: boolean;
9
- remoteStream: MediaStream | null;
11
+ remoteStream: any;
10
12
  peers: string[];
11
13
  speakingUsers: Set<string>;
12
14
  connect: () => void;
13
15
  disconnect: () => void;
14
16
  toggleMute: () => void;
15
- client: VoiceClient | null;
17
+ client: any;
16
18
  };
17
19
 
18
20
  export { useVoice };
package/dist/index.d.ts CHANGED
@@ -1,18 +1,20 @@
1
- import { VoiceClientConfig, VoiceClient } from '@voicemaster/core';
2
-
3
- interface UseVoiceOptions extends VoiceClientConfig {
1
+ interface UseVoiceOptions {
2
+ signalingUrl: string;
3
+ roomId: string;
4
+ userId: string;
5
+ iceServers?: any[];
4
6
  autoConnect?: boolean;
5
7
  }
6
8
  declare function useVoice(options: UseVoiceOptions): {
7
9
  isConnected: boolean;
8
10
  isMuted: boolean;
9
- remoteStream: MediaStream | null;
11
+ remoteStream: any;
10
12
  peers: string[];
11
13
  speakingUsers: Set<string>;
12
14
  connect: () => void;
13
15
  disconnect: () => void;
14
16
  toggleMute: () => void;
15
- client: VoiceClient | null;
17
+ client: any;
16
18
  };
17
19
 
18
20
  export { useVoice };
package/dist/index.js CHANGED
@@ -49,7 +49,6 @@ function useVoice(options) {
49
49
  setIsConnected(false);
50
50
  setPeers([]);
51
51
  setRemoteStream(null);
52
- setSpeakingUsers(/* @__PURE__ */ new Set());
53
52
  });
54
53
  client.on("remoteStream", (stream) => {
55
54
  setRemoteStream(stream);
package/dist/index.mjs CHANGED
@@ -23,7 +23,6 @@ function useVoice(options) {
23
23
  setIsConnected(false);
24
24
  setPeers([]);
25
25
  setRemoteStream(null);
26
- setSpeakingUsers(/* @__PURE__ */ new Set());
27
26
  });
28
27
  client.on("remoteStream", (stream) => {
29
28
  setRemoteStream(stream);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voicemaster/react",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "React hooks for VoiceMaster voice communication",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -31,6 +31,7 @@
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/react": "^18.0.0",
34
+ "@types/simple-peer": "^9.11.9",
34
35
  "tsup": "^8.0.0",
35
36
  "typescript": "^5.3.0"
36
37
  }
package/src/useVoice.ts CHANGED
@@ -1,18 +1,21 @@
1
1
  import { useEffect, useState, useRef, useCallback } from 'react';
2
2
  import { VoiceClient } from '@voicemaster/core';
3
- import type { VoiceClientConfig } from '@voicemaster/core';
4
3
 
5
- interface UseVoiceOptions extends VoiceClientConfig {
4
+ interface UseVoiceOptions {
5
+ signalingUrl: string;
6
+ roomId: string;
7
+ userId: string;
8
+ iceServers?: any[];
6
9
  autoConnect?: boolean;
7
10
  }
8
11
 
9
12
  export function useVoice(options: UseVoiceOptions) {
10
13
  const [isConnected, setIsConnected] = useState(false);
11
14
  const [isMuted, setIsMuted] = useState(false);
12
- const [remoteStream, setRemoteStream] = useState<MediaStream | null>(null);
15
+ const [remoteStream, setRemoteStream] = useState<any>(null);
13
16
  const [speakingUsers, setSpeakingUsers] = useState<Set<string>>(new Set());
14
17
  const [peers, setPeers] = useState<string[]>([]);
15
- const clientRef = useRef<VoiceClient | null>(null);
18
+ const clientRef = useRef<any>(null);
16
19
 
17
20
  useEffect(() => {
18
21
  const client = new VoiceClient({
@@ -31,18 +34,17 @@ export function useVoice(options: UseVoiceOptions) {
31
34
  setIsConnected(false);
32
35
  setPeers([]);
33
36
  setRemoteStream(null);
34
- setSpeakingUsers(new Set());
35
37
  });
36
38
 
37
- client.on('remoteStream', (stream) => {
39
+ client.on('remoteStream', (stream: any) => {
38
40
  setRemoteStream(stream);
39
41
  });
40
42
 
41
- client.on('userJoined', (userId) => {
43
+ client.on('userJoined', (userId: string) => {
42
44
  setPeers(prev => [...prev, userId]);
43
45
  });
44
46
 
45
- client.on('userLeft', (userId) => {
47
+ client.on('userLeft', (userId: string) => {
46
48
  setPeers(prev => prev.filter(id => id !== userId));
47
49
  setSpeakingUsers(prev => {
48
50
  const newSet = new Set(prev);
@@ -51,11 +53,11 @@ export function useVoice(options: UseVoiceOptions) {
51
53
  });
52
54
  });
53
55
 
54
- client.on('speaking', (userId) => {
56
+ client.on('speaking', (userId: string) => {
55
57
  setSpeakingUsers(prev => new Set(prev).add(userId));
56
58
  });
57
59
 
58
- client.on('stoppedSpeaking', (userId) => {
60
+ client.on('stoppedSpeaking', (userId: string) => {
59
61
  setSpeakingUsers(prev => {
60
62
  const newSet = new Set(prev);
61
63
  newSet.delete(userId);
@@ -63,7 +65,7 @@ export function useVoice(options: UseVoiceOptions) {
63
65
  });
64
66
  });
65
67
 
66
- client.on('error', (error) => {
68
+ client.on('error', (error: Error) => {
67
69
  console.error('Voice client error:', error);
68
70
  });
69
71
 
@@ -89,7 +91,6 @@ export function useVoice(options: UseVoiceOptions) {
89
91
  const toggleMute = useCallback(() => {
90
92
  if (clientRef.current) {
91
93
  clientRef.current.toggleMute();
92
- // Добавляем обновление isMuted
93
94
  setIsMuted(prev => !prev);
94
95
  }
95
96
  }, []);