@afosecure/meetingsdk 1.3.8 → 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.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 AFOLABI MUBARAK
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AFOLABI MUBARAK
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,253 +1,253 @@
1
- # 📹 @afosecure/meetingsdk — React Video Meeting SDK
2
-
3
- A modern, lightweight React SDK for building peer-to-peer video communication applications using WebRTC. Designed with a clean, composable API and reactive state management.
4
-
5
- ---
6
-
7
- ## Features
8
-
9
- - WebRTC peer-to-peer video (no central media server required)
10
- - React Hooks API for seamless integration
11
- - Reactive state system for participants & streams
12
- - Lightweight core optimized for performance
13
- - Flexible WebSocket signaling backend support
14
- - Full TypeScript support
15
-
16
- ---
17
-
18
- ## 📦 Installation
19
-
20
- ```bash
21
- npm install @afosecure/meetingsdk
22
- # or
23
- yarn add @afosecure/meetingsdk
24
- # or
25
- pnpm add @afosecure/meetingsdk
26
- ```
27
-
28
- ---
29
-
30
- ## Quick Start
31
-
32
- ### 1. Initialize SDK
33
-
34
- ```tsx
35
- import { useState } from "react";
36
- import {
37
- MeetingProvider,
38
- MeetingState,
39
- VideoSDKCore,
40
- } from "@afosecure/meetingsdk";
41
-
42
- function App() {
43
- const [core] = useState(
44
- () =>
45
- new VideoSDKCore({
46
- onTrack: (_, peerId) => {
47
- console.log("📹 Received stream from:", peerId);
48
- },
49
- onUserJoined: (participant) => {
50
- console.log("👤 User joined:", participant.name);
51
- },
52
- onUserLeft: (userId) => {
53
- console.log("👤 User left:", userId);
54
- },
55
- }),
56
- );
57
-
58
- return (
59
- <MeetingProvider core={core}>
60
- <VideoCall />
61
- </MeetingProvider>
62
- );
63
- }
64
-
65
- export default App;
66
- ```
67
-
68
- ---
69
-
70
- ### 2. Basic Video Call
71
-
72
- ```tsx
73
- import { useRef, useState } from "react";
74
- import { useMeeting, useParticipants } from "@afosecure/meetingsdk";
75
-
76
- function VideoCall() {
77
- const { join, startLocalStream, leave, localParticipant } = useMeeting();
78
- const participants = useParticipants();
79
- const localVideoRef = useRef<HTMLVideoElement>(null);
80
-
81
- const [roomId, setRoomId] = useState("");
82
- const [name, setName] = useState("");
83
-
84
- const handleJoin = async () => {
85
- if (!localVideoRef.current) return;
86
-
87
- await startLocalStream(localVideoRef.current, name);
88
- await join(roomId, name);
89
- };
90
-
91
- return (
92
- <div>
93
- {!localParticipant ? (
94
- <>
95
- <input value={name} onChange={(e) => setName(e.target.value)} />
96
- <input value={roomId} onChange={(e) => setRoomId(e.target.value)} />
97
- <button onClick={handleJoin}>Join Meeting</button>
98
- </>
99
- ) : (
100
- <>
101
- <video ref={localVideoRef} autoPlay muted />
102
- <button onClick={leave}>Leave</button>
103
-
104
- {participants.map((p) => (
105
- <div key={p.id}>{p.name}</div>
106
- ))}
107
- </>
108
- )}
109
- </div>
110
- );
111
- }
112
- ```
113
-
114
- ---
115
-
116
- ## Core Concepts
117
-
118
- ### MeetingState
119
-
120
- ```ts
121
- const state = new MeetingState();
122
-
123
- state.getParticipants();
124
-
125
- state.subscribe(() => {
126
- console.log("updated");
127
- });
128
- ```
129
-
130
- ---
131
-
132
- ### VideoSDKCore
133
-
134
- ```ts
135
- const core = new VideoSDKCore(state, {
136
- onTrack: (stream, peerId) => {},
137
- onUserJoined: (p) => {},
138
- onUserLeft: (id) => {},
139
- });
140
- ```
141
-
142
- ---
143
-
144
- ## Hooks API
145
-
146
- ### useMeeting()
147
-
148
- ```ts
149
- const { join, startLocalStream, leave, localParticipant, meetingId } =
150
- useMeeting();
151
- ```
152
-
153
- ---
154
-
155
- ### useParticipants()
156
-
157
- ```ts
158
- const participants = useParticipants();
159
- ```
160
-
161
- ---
162
-
163
- ### useRemoteVideo()
164
-
165
- ```tsx
166
- const ref = useRemoteVideo(participantId);
167
-
168
- return <video ref={ref} autoPlay />;
169
- ```
170
-
171
- ---
172
-
173
- ### useLocalStream()
174
-
175
- ```ts
176
- const stream = useLocalStream();
177
- ```
178
-
179
- ---
180
-
181
- ### useStreams()
182
-
183
- ```ts
184
- const streams = useStreams();
185
- ```
186
-
187
- ---
188
-
189
- ## Complete Example
190
-
191
- ```tsx
192
- export default function App() {
193
- const [state] = useState(() => new MeetingState());
194
-
195
- const [core] = useState(
196
- () =>
197
- new VideoSDKCore(state, {
198
- onTrack: () => {},
199
- onUserJoined: () => {},
200
- onUserLeft: () => {},
201
- }),
202
- );
203
-
204
- return (
205
- <MeetingProvider core={core}>
206
- <VideoCallContent />
207
- </MeetingProvider>
208
- );
209
- }
210
- ```
211
-
212
- ---
213
-
214
- ## Server Requirements
215
-
216
- Your WebSocket server must support:
217
-
218
- ### Client → Server
219
-
220
- - JOIN
221
- - OFFER
222
- - ANSWER
223
- - ICE
224
-
225
- ### Server → Client
226
-
227
- - EXISTING_USERS
228
- - USER_JOINED
229
- - USER_LEFT
230
-
231
- ---
232
-
233
- ## Performance Tips
234
-
235
- - Stop media tracks on leave
236
- - Memoize participant components
237
- - Use multiple STUN servers
238
- - Avoid re-rendering video elements
239
-
240
- ---
241
-
242
- ## Browser Support
243
-
244
- - Chrome 54+
245
- - Firefox 55+
246
- - Safari 11+
247
- - Edge 79+
248
-
249
- ---
250
-
251
- ## 📄 License
252
-
253
- MIT
1
+ # 📹 @afosecure/meetingsdk — React Video Meeting SDK
2
+
3
+ A modern, lightweight React SDK for building peer-to-peer video communication applications using WebRTC. Designed with a clean, composable API and reactive state management.
4
+
5
+ ---
6
+
7
+ ## Features
8
+
9
+ - WebRTC peer-to-peer video (no central media server required)
10
+ - React Hooks API for seamless integration
11
+ - Reactive state system for participants & streams
12
+ - Lightweight core optimized for performance
13
+ - Flexible WebSocket signaling backend support
14
+ - Full TypeScript support
15
+
16
+ ---
17
+
18
+ ## 📦 Installation
19
+
20
+ ```bash
21
+ npm install @afosecure/meetingsdk
22
+ # or
23
+ yarn add @afosecure/meetingsdk
24
+ # or
25
+ pnpm add @afosecure/meetingsdk
26
+ ```
27
+
28
+ ---
29
+
30
+ ## Quick Start
31
+
32
+ ### 1. Initialize SDK
33
+
34
+ ```tsx
35
+ import { useState } from "react";
36
+ import {
37
+ MeetingProvider,
38
+ MeetingState,
39
+ VideoSDKCore,
40
+ } from "@afosecure/meetingsdk";
41
+
42
+ function App() {
43
+ const [core] = useState(
44
+ () =>
45
+ new VideoSDKCore({
46
+ onTrack: (_, peerId) => {
47
+ console.log("📹 Received stream from:", peerId);
48
+ },
49
+ onUserJoined: (participant) => {
50
+ console.log("👤 User joined:", participant.name);
51
+ },
52
+ onUserLeft: (userId) => {
53
+ console.log("👤 User left:", userId);
54
+ },
55
+ }),
56
+ );
57
+
58
+ return (
59
+ <MeetingProvider core={core}>
60
+ <VideoCall />
61
+ </MeetingProvider>
62
+ );
63
+ }
64
+
65
+ export default App;
66
+ ```
67
+
68
+ ---
69
+
70
+ ### 2. Basic Video Call
71
+
72
+ ```tsx
73
+ import { useRef, useState } from "react";
74
+ import { useMeeting, useParticipants } from "@afosecure/meetingsdk";
75
+
76
+ function VideoCall() {
77
+ const { join, startLocalStream, leave, localParticipant } = useMeeting();
78
+ const participants = useParticipants();
79
+ const localVideoRef = useRef<HTMLVideoElement>(null);
80
+
81
+ const [roomId, setRoomId] = useState("");
82
+ const [name, setName] = useState("");
83
+
84
+ const handleJoin = async () => {
85
+ if (!localVideoRef.current) return;
86
+
87
+ await startLocalStream(localVideoRef.current, name);
88
+ await join(roomId, name);
89
+ };
90
+
91
+ return (
92
+ <div>
93
+ {!localParticipant ? (
94
+ <>
95
+ <input value={name} onChange={(e) => setName(e.target.value)} />
96
+ <input value={roomId} onChange={(e) => setRoomId(e.target.value)} />
97
+ <button onClick={handleJoin}>Join Meeting</button>
98
+ </>
99
+ ) : (
100
+ <>
101
+ <video ref={localVideoRef} autoPlay muted />
102
+ <button onClick={leave}>Leave</button>
103
+
104
+ {participants.map((p) => (
105
+ <div key={p.id}>{p.name}</div>
106
+ ))}
107
+ </>
108
+ )}
109
+ </div>
110
+ );
111
+ }
112
+ ```
113
+
114
+ ---
115
+
116
+ ## Core Concepts
117
+
118
+ ### MeetingState
119
+
120
+ ```ts
121
+ const state = new MeetingState();
122
+
123
+ state.getParticipants();
124
+
125
+ state.subscribe(() => {
126
+ console.log("updated");
127
+ });
128
+ ```
129
+
130
+ ---
131
+
132
+ ### VideoSDKCore
133
+
134
+ ```ts
135
+ const core = new VideoSDKCore(state, {
136
+ onTrack: (stream, peerId) => {},
137
+ onUserJoined: (p) => {},
138
+ onUserLeft: (id) => {},
139
+ });
140
+ ```
141
+
142
+ ---
143
+
144
+ ## Hooks API
145
+
146
+ ### useMeeting()
147
+
148
+ ```ts
149
+ const { join, startLocalStream, leave, localParticipant, meetingId } =
150
+ useMeeting();
151
+ ```
152
+
153
+ ---
154
+
155
+ ### useParticipants()
156
+
157
+ ```ts
158
+ const participants = useParticipants();
159
+ ```
160
+
161
+ ---
162
+
163
+ ### useRemoteVideo()
164
+
165
+ ```tsx
166
+ const ref = useRemoteVideo(participantId);
167
+
168
+ return <video ref={ref} autoPlay />;
169
+ ```
170
+
171
+ ---
172
+
173
+ ### useLocalStream()
174
+
175
+ ```ts
176
+ const stream = useLocalStream();
177
+ ```
178
+
179
+ ---
180
+
181
+ ### useStreams()
182
+
183
+ ```ts
184
+ const streams = useStreams();
185
+ ```
186
+
187
+ ---
188
+
189
+ ## Complete Example
190
+
191
+ ```tsx
192
+ export default function App() {
193
+ const [state] = useState(() => new MeetingState());
194
+
195
+ const [core] = useState(
196
+ () =>
197
+ new VideoSDKCore(state, {
198
+ onTrack: () => {},
199
+ onUserJoined: () => {},
200
+ onUserLeft: () => {},
201
+ }),
202
+ );
203
+
204
+ return (
205
+ <MeetingProvider core={core}>
206
+ <VideoCallContent />
207
+ </MeetingProvider>
208
+ );
209
+ }
210
+ ```
211
+
212
+ ---
213
+
214
+ ## Server Requirements
215
+
216
+ Your WebSocket server must support:
217
+
218
+ ### Client → Server
219
+
220
+ - JOIN
221
+ - OFFER
222
+ - ANSWER
223
+ - ICE
224
+
225
+ ### Server → Client
226
+
227
+ - EXISTING_USERS
228
+ - USER_JOINED
229
+ - USER_LEFT
230
+
231
+ ---
232
+
233
+ ## Performance Tips
234
+
235
+ - Stop media tracks on leave
236
+ - Memoize participant components
237
+ - Use multiple STUN servers
238
+ - Avoid re-rendering video elements
239
+
240
+ ---
241
+
242
+ ## Browser Support
243
+
244
+ - Chrome 54+
245
+ - Firefox 55+
246
+ - Safari 11+
247
+ - Edge 79+
248
+
249
+ ---
250
+
251
+ ## 📄 License
252
+
253
+ MIT
package/dist/index.d.mts CHANGED
@@ -144,8 +144,6 @@ declare class VideoSDKCore {
144
144
  readonly state: MeetingState;
145
145
  private joinResolver?;
146
146
  private joinRejecter?;
147
- private initialAudioMuted;
148
- private initialVideoMuted;
149
147
  private isWaitingForApproval;
150
148
  private pendingRequestId;
151
149
  private iceTransportPolicy;
package/dist/index.d.ts CHANGED
@@ -144,8 +144,6 @@ declare class VideoSDKCore {
144
144
  readonly state: MeetingState;
145
145
  private joinResolver?;
146
146
  private joinRejecter?;
147
- private initialAudioMuted;
148
- private initialVideoMuted;
149
147
  private isWaitingForApproval;
150
148
  private pendingRequestId;
151
149
  private iceTransportPolicy;
package/dist/index.js CHANGED
@@ -39,7 +39,8 @@ var import_react2 = require("react");
39
39
 
40
40
  // src/config/ws.ts
41
41
  var SDK_CONFIG = {
42
- wsUrl: "wss://rust-video-server-sfyf.onrender.com/ws"
42
+ wsUrl: "wss://rust-video-server-sfyf.onrender.com/ws",
43
+ baseUrl: "https://rust-video-server-sfyf.onrender.com"
43
44
  };
44
45
 
45
46
  // src/core/MeetingState.ts
@@ -214,8 +215,6 @@ var VideoSDKCore = class {
214
215
  this.pendingOffers = {};
215
216
  this.reconnectAttempts = 0;
216
217
  this.participantName = "";
217
- this.initialAudioMuted = false;
218
- this.initialVideoMuted = false;
219
218
  // Track if we're in the waiting room (pending approval)
220
219
  this.isWaitingForApproval = false;
221
220
  this.pendingRequestId = null;
@@ -293,8 +292,8 @@ var VideoSDKCore = class {
293
292
  user_id: this.myId,
294
293
  sender_name: name,
295
294
  camera_stream_id: this.localStream?.id.replace(/[{}]/g, ""),
296
- audio_muted: this.initialAudioMuted,
297
- video_muted: this.initialVideoMuted
295
+ audio_muted: this.state.localParticipant?.media?.micEnabled,
296
+ video_muted: this.state.localParticipant?.media?.camEnabled
298
297
  });
299
298
  };
300
299
  this.ws.onerror = (err) => {
@@ -328,8 +327,6 @@ var VideoSDKCore = class {
328
327
  if (!roomId || !name) {
329
328
  throw new Error("roomId and name are required to join meeting");
330
329
  }
331
- this.initialAudioMuted = audioMuted;
332
- this.initialVideoMuted = videoMuted;
333
330
  this.participantName = name;
334
331
  if (!this.localStream) {
335
332
  this.localStream = await navigator.mediaDevices.getUserMedia({
@@ -578,18 +575,17 @@ var VideoSDKCore = class {
578
575
  }
579
576
  this.pendingOffers = {};
580
577
  }
581
- if (this.initialAudioMuted) {
578
+ const media = this.state.localParticipant?.media;
579
+ if (media) {
582
580
  this.send({
583
581
  type: "MEDIA_STATE",
584
582
  kind: "audio",
585
- enabled: false
583
+ enabled: !!media.micEnabled
586
584
  });
587
- }
588
- if (this.initialVideoMuted) {
589
585
  this.send({
590
586
  type: "MEDIA_STATE",
591
587
  kind: "video",
592
- enabled: false
588
+ enabled: !!media.camEnabled
593
589
  });
594
590
  }
595
591
  this.startHeartbeat();