@snapcall/stream-ui 1.2.0 → 1.3.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/dist/types.d.ts CHANGED
@@ -33,13 +33,24 @@ interface JoinOptions {
33
33
  email?: string;
34
34
  displayName?: string;
35
35
  }
36
+ interface PeerState {
37
+ peerId: string;
38
+ displayName: string | undefined;
39
+ deviceState: DevicesState;
40
+ }
41
+ interface StreamerState extends PeerState {
42
+ roomId: string;
43
+ callId: number | undefined;
44
+ peers: Array<PeerState>;
45
+ }
36
46
  interface ProducerData {
37
47
  producerId: string;
38
48
  deviceType: DeviceType;
39
49
  paused: boolean;
40
50
  }
41
51
  interface PeerInfo {
42
- id: PeerId;
52
+ id?: PeerId;
53
+ peerId: PeerId;
43
54
  displayName: string;
44
55
  producersData: Array<ProducerData>;
45
56
  }
@@ -97,6 +108,15 @@ declare class AudioLevel {
97
108
  release(): void;
98
109
  static isAPIAvailable(): boolean;
99
110
  }
111
+ declare class AudioRenderer {
112
+ constructor({ consumerId }: {
113
+ consumerId: string;
114
+ });
115
+ destroy(): void;
116
+ setSource(srcObject: MediaStream): void;
117
+ setSink(sinkId: string): Promise<void>;
118
+ play(): Promise<void>;
119
+ }
100
120
  interface DeviceRequest {
101
121
  requestId: string;
102
122
  deviceType: DeviceType;
@@ -113,7 +133,105 @@ interface CustomMessage {
113
133
  }>;
114
134
  totalChunks: number;
115
135
  }
116
- declare class StreamerClient implements AudioLevelListener {
136
+ declare global {
137
+ export namespace SnapCall {
138
+ type SnapcallEvent<T> = CustomEvent<T>;
139
+ type PeersInfoEvent = SnapcallEvent<{
140
+ peerId: string;
141
+ peers: {
142
+ peerId: string;
143
+ displayName: string;
144
+ }[];
145
+ }>;
146
+ type PeerInfoEvent = SnapcallEvent<{
147
+ peerId: string;
148
+ displayName: string;
149
+ }>;
150
+ type RequestDeviceEvent = SnapcallEvent<{
151
+ peerId: string;
152
+ deviceType: DeviceType;
153
+ }>;
154
+ type RequestDeviceResultEvent = SnapcallEvent<{
155
+ result: {
156
+ peerId: string;
157
+ result: boolean;
158
+ };
159
+ }>;
160
+ type BaseEvent = SnapcallEvent<{}>;
161
+ type StreamEvent = SnapcallEvent<{
162
+ peerId: string;
163
+ }>;
164
+ type RequestResultEvent = SnapcallEvent<{
165
+ success: Boolean;
166
+ }>;
167
+ type ConsumerEvent = SnapcallEvent<{
168
+ peerId: string;
169
+ consumerId: string;
170
+ deviceType: DeviceType;
171
+ paused: boolean;
172
+ }>;
173
+ type AudioDeviceEvent = SnapcallEvent<MediaDeviceInfo>;
174
+ type ProducerEvent = SnapcallEvent<{
175
+ peerId: string;
176
+ producerId: string;
177
+ deviceType: DeviceType;
178
+ }>;
179
+ type WebcamUpdateEvent = SnapcallEvent<{
180
+ numberOfAvailableWebcams: number;
181
+ }>;
182
+ type CriticalErrorEvent = SnapcallEvent<{
183
+ code: string;
184
+ }>;
185
+ type CustomMessageEvent = SnapcallEvent<{
186
+ peerId: string;
187
+ event: {
188
+ type: string;
189
+ } & Record<string, any>;
190
+ }>;
191
+ }
192
+ }
193
+ interface StreamerEventMap {
194
+ leaveRoom: SnapCall.BaseEvent;
195
+ terminateRoom: SnapCall.BaseEvent;
196
+ invalidRoom: SnapCall.BaseEvent;
197
+ localVideoUnavailable: SnapCall.BaseEvent;
198
+ localVideoAvailable: SnapCall.BaseEvent;
199
+ microphoneEnabled: SnapCall.BaseEvent;
200
+ agentIdentity: SnapCall.RequestResultEvent;
201
+ peerClosed: SnapCall.StreamEvent;
202
+ newPeer: SnapCall.PeerInfoEvent;
203
+ selfDisplayName: SnapCall.PeerInfoEvent;
204
+ webcamsUpdate: SnapCall.WebcamUpdateEvent;
205
+ customMessage: SnapCall.CustomMessageEvent;
206
+ newConsumer: SnapCall.ConsumerEvent;
207
+ consumerClose: SnapCall.ConsumerEvent;
208
+ producerPaused: SnapCall.ProducerEvent;
209
+ producerResumed: SnapCall.ProducerEvent;
210
+ microphoneMute: SnapCall.BaseEvent;
211
+ microphoneUnmute: SnapCall.BaseEvent;
212
+ defaultAudioDeviceChange: SnapCall.AudioDeviceEvent;
213
+ screenshareEnabled: SnapCall.BaseEvent;
214
+ screenshareDisabled: SnapCall.BaseEvent;
215
+ localVideoRotate: SnapCall.BaseEvent;
216
+ enterRoom: SnapCall.PeersInfoEvent;
217
+ displayName: SnapCall.PeerInfoEvent;
218
+ peerStartSpeak: SnapCall.StreamEvent;
219
+ peerStopSpeak: SnapCall.StreamEvent;
220
+ criticalError: SnapCall.CriticalErrorEvent;
221
+ requestDevice: SnapCall.RequestDeviceEvent;
222
+ requestDeviceResult: SnapCall.RequestDeviceResultEvent;
223
+ }
224
+ interface StreamerEventTarget extends EventTarget {
225
+ addEventListener<T extends keyof StreamerEventMap>(type: T, listener: (event: StreamerEventMap[T]) => void, options?: boolean | AddEventListenerOptions): void;
226
+ addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void;
227
+ removeEventListener<T extends keyof StreamerEventMap>(type: T, listener: (event: StreamerEventMap[T]) => void): void;
228
+ removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null): void;
229
+ }
230
+ declare const StreamerEventTargetType: {
231
+ new (): StreamerEventTarget;
232
+ prototype: StreamerEventTarget;
233
+ };
234
+ declare class StreamerClient extends StreamerEventTargetType implements AudioLevelListener {
117
235
  iceServers: Array<RTCIceServer>;
118
236
  peers: Map<PeerId, PeerInfo>;
119
237
  consumers: Map<ConsumerId, ConsumerData>;
@@ -149,7 +267,9 @@ declare class StreamerClient implements AudioLevelListener {
149
267
  audioInputDefaultDevice?: MediaDeviceInfo;
150
268
  devicesList: Array<MediaDeviceInfo>;
151
269
  customMessages: Map<string, CustomMessage>;
270
+ audioRenderers: Record<string, AudioRenderer>;
152
271
  constructor();
272
+ getState(): StreamerState;
153
273
  onStartSpeak(): void;
154
274
  onStopSpeak(): void;
155
275
  generateToken(bid: string): Promise<string>;
@@ -164,13 +284,22 @@ declare class StreamerClient implements AudioLevelListener {
164
284
  toggleMute(): Promise<{
165
285
  muted: boolean;
166
286
  }>;
287
+ release(): void;
167
288
  endCall(): void;
168
289
  terminateRoom(): void;
169
290
  updateWebcams(): Promise<void>;
170
291
  isVideoZoomAvailable(): boolean;
171
292
  handleGetUserMediaError(deviceType: DeviceType, getUserMediaPromise: Promise<MediaStream>): Promise<MediaStream>;
172
293
  restartIce(transport: Transport): Promise<void>;
173
- enableVideo(): Promise<void>;
294
+ switchWebcam({ device, resolution, rotate, }: {
295
+ device?: MediaDeviceInfo;
296
+ resolution?: VideoResolution;
297
+ rotate?: boolean;
298
+ }): Promise<void>;
299
+ enableVideo(config?: {
300
+ device?: MediaDeviceInfo;
301
+ resolution?: VideoResolution;
302
+ }): Promise<void>;
174
303
  rotateVideo(): Promise<void>;
175
304
  zoomVideo(): Promise<void>;
176
305
  unzoomVideo(): Promise<void>;
@@ -180,10 +309,6 @@ declare class StreamerClient implements AudioLevelListener {
180
309
  onConsumerClose({ consumerId }: {
181
310
  consumerId: ConsumerId;
182
311
  }): void;
183
- requestVoice({ consumerId, element }: {
184
- consumerId: string;
185
- element: HTMLAudioElement;
186
- }): void;
187
312
  requestVideo({ consumerId, element }: {
188
313
  consumerId: string;
189
314
  element: HTMLVideoElement;
@@ -211,6 +336,21 @@ declare class StreamerClient implements AudioLevelListener {
211
336
  getDevicesState(): DevicesState;
212
337
  sendCustomMessageToAll(event: any): Promise<void>;
213
338
  sendCustomMessage(peerId: string, event: any): Promise<void>;
339
+ listAudioDevices(): Promise<MediaDeviceInfo[]>;
340
+ listVideoDevices(): Promise<MediaDeviceInfo[]>;
341
+ isListDevicesSupported(): boolean;
342
+ getCurrentWebcam(): {
343
+ device: MediaDeviceInfo | null;
344
+ resolution: VideoResolution;
345
+ };
346
+ getWebcamsList(): Map<string, MediaDeviceInfo>;
347
+ setWebcamResolution(resolution: VideoResolution): Promise<void>;
348
+ createAudioRenderer(consumerId: string): AudioRenderer;
349
+ deleteAudioRenderer(consumerId: string): void;
350
+ playAudioRenderer(consumerId: string): Promise<void>;
351
+ setAudioSink(sinkId: string): Promise<void>;
352
+ dispatchEvent(event: Event): boolean;
353
+ getShareLinkData(url: string): Promise<any>;
214
354
  }
215
355
  declare const streamerClient: StreamerClient;
216
356
  interface NotificationOptions {
@@ -220,6 +360,7 @@ interface NotificationOptions {
220
360
  icon?: JSX.Element | string;
221
361
  text: string;
222
362
  action: () => void;
363
+ style?: CSSProperties;
223
364
  };
224
365
  status?: {
225
366
  icon?: JSX.Element | string;
@@ -250,6 +391,9 @@ interface StreamUIMethods {
250
391
  leaveRoom: typeof streamerClient.endCall;
251
392
  terminateRoom: typeof streamerClient.terminateRoom;
252
393
  generateToken: typeof streamerClient.generateToken;
394
+ addEventListener: typeof streamerClient.addEventListener;
395
+ dispatchEvent: typeof streamerClient.dispatchEvent;
396
+ getState: typeof streamerClient.getState;
253
397
  }
254
398
  interface ControlSettings {
255
399
  available?: boolean;
@@ -290,31 +434,11 @@ declare global {
290
434
  setMicrophoneActive?: (active: boolean) => void;
291
435
  setCameraActive?: (active: boolean) => void;
292
436
  }
437
+ interface HTMLAudioElement {
438
+ setSinkId?: (sinkId: string) => Promise<undefined>;
439
+ }
293
440
  interface WindowEventMap {
294
441
  streamUISetExtraSettingsOptions: CustomEvent;
295
- enterRoom: CustomEvent;
296
- newPeer: CustomEvent;
297
- peerClosed: CustomEvent;
298
- newConsumer: CustomEvent;
299
- consumerClose: CustomEvent;
300
- screenshareEnabled: CustomEvent;
301
- screenshareDisabled: CustomEvent;
302
- producerPaused: CustomEvent;
303
- producerResumed: CustomEvent;
304
- displayName: CustomEvent;
305
- selfDisplayName: CustomEvent;
306
- requestDevice: CustomEvent;
307
- requestDeviceResult: CustomEvent;
308
- webcamsUpdate: CustomEvent;
309
- microphoneEnabled: CustomEvent;
310
- microphoneMute: CustomEvent;
311
- microphoneUnmute: CustomEvent;
312
- defaultAudioDeviceChange: CustomEvent;
313
- peerStartSpeak: CustomEvent;
314
- peerStopSpeak: CustomEvent;
315
- agentIdentity: CustomEvent;
316
- criticalError: CustomEvent;
317
- customMessage: CustomEvent;
318
442
  }
319
443
  }
320
444
  declare global {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snapcall/stream-ui",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "",
5
5
  "source": "src/index.tsx",
6
6
  "main": "dist/stream-ui.js",
@@ -49,8 +49,8 @@
49
49
  "styled-components": "^5.3.3"
50
50
  },
51
51
  "devDependencies": {
52
- "@parcel/packager-ts": "^2.6.0",
53
- "@parcel/transformer-typescript-types": "^2.6.0",
52
+ "@parcel/packager-ts": "^2.6.2",
53
+ "@parcel/transformer-typescript-types": "^2.6.2",
54
54
  "@types/protoo-client": "^4.0.1",
55
55
  "@types/qrcode": "^1.4.2",
56
56
  "@types/react": "^17.0.43",
@@ -60,14 +60,14 @@
60
60
  "eslint": "^8.16.0",
61
61
  "eslint-config-prettier": "^8.5.0",
62
62
  "eslint-config-react-app": "^7.0.1",
63
- "parcel": "^2.6.0",
63
+ "parcel": "^2.6.2",
64
64
  "prettier": "2.7.1",
65
65
  "process": "^0.11.10",
66
66
  "typescript": "^4.7.2"
67
67
  },
68
68
  "dependencies": {
69
69
  "@sentry/browser": "^7.0.0",
70
- "@types/youtube": "^0.0.46",
70
+ "@types/youtube": "^0.0.47",
71
71
  "bowser": "^2.11.0",
72
72
  "inobounce": "^0.2.1",
73
73
  "mediasoup-client": "^3.6.52",