@whereby.com/browser-sdk 2.0.0-alpha5 → 2.0.0-alpha7
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/README.md +39 -2
- package/dist/lib.cjs.js +334 -91
- package/dist/lib.esm.js +333 -92
- package/dist/types.d.ts +167 -7
- package/dist/v2-alpha7.js +43 -0
- package/package.json +6 -5
- package/dist/v2-alpha5.js +0 -105
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import RtcManager from '@whereby/jslib-media/src/webrtc/RtcManager';
|
|
2
3
|
|
|
3
4
|
interface WherebyEmbedAttributes {
|
|
4
5
|
audio: string;
|
|
@@ -38,6 +39,82 @@ interface VideoViewSelfProps {
|
|
|
38
39
|
type VideoViewProps = VideoViewSelfProps & React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>;
|
|
39
40
|
declare const _default: ({ muted, stream, ...rest }: VideoViewProps) => JSX.Element;
|
|
40
41
|
|
|
42
|
+
type CameraEnabledEvent = {
|
|
43
|
+
enabled: boolean;
|
|
44
|
+
};
|
|
45
|
+
type MicrophoneEnabledEvent = {
|
|
46
|
+
enabled: boolean;
|
|
47
|
+
};
|
|
48
|
+
type DeviceListUpdatedEvent = {
|
|
49
|
+
cameraDevices: MediaDeviceInfo[];
|
|
50
|
+
microphoneDevices: MediaDeviceInfo[];
|
|
51
|
+
speakerDevices: MediaDeviceInfo[];
|
|
52
|
+
};
|
|
53
|
+
type DeviceListUpdateErrorEvent = {
|
|
54
|
+
error: unknown;
|
|
55
|
+
};
|
|
56
|
+
type StreamUpdatedEvent = {
|
|
57
|
+
stream: MediaStream;
|
|
58
|
+
};
|
|
59
|
+
interface LocalMediaEventsMap {
|
|
60
|
+
camera_enabled: CustomEvent<CameraEnabledEvent>;
|
|
61
|
+
device_list_updated: CustomEvent<DeviceListUpdatedEvent>;
|
|
62
|
+
device_list_update_error: CustomEvent<DeviceListUpdateErrorEvent>;
|
|
63
|
+
microphone_enabled: CustomEvent<MicrophoneEnabledEvent>;
|
|
64
|
+
stream_updated: CustomEvent<StreamUpdatedEvent>;
|
|
65
|
+
}
|
|
66
|
+
interface LocalMediaEventTarget extends EventTarget {
|
|
67
|
+
addEventListener<K extends keyof LocalMediaEventsMap>(type: K, listener: (ev: LocalMediaEventsMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
|
|
68
|
+
addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void;
|
|
69
|
+
}
|
|
70
|
+
declare const TypedLocalMediaEventTarget: new () => LocalMediaEventTarget;
|
|
71
|
+
declare class LocalMedia extends TypedLocalMediaEventTarget {
|
|
72
|
+
private _constraints;
|
|
73
|
+
_rtcManagers: RtcManager[];
|
|
74
|
+
stream: MediaStream;
|
|
75
|
+
constructor(constraints: MediaStreamConstraints);
|
|
76
|
+
addRtcManager(rtcManager: RtcManager): void;
|
|
77
|
+
removeRtcManager(rtcManager: RtcManager): void;
|
|
78
|
+
getCameraDeviceId(): string | undefined;
|
|
79
|
+
getMicrophoneDeviceId(): string | undefined;
|
|
80
|
+
isCameraEnabled(): boolean;
|
|
81
|
+
isMicrophoneEnabled(): boolean;
|
|
82
|
+
toggleCameraEnabled(enabled?: boolean): void;
|
|
83
|
+
toggleMichrophoneEnabled(enabled?: boolean): void;
|
|
84
|
+
setCameraDevice(deviceId: string): Promise<void>;
|
|
85
|
+
setMicrophoneDevice(deviceId: string): Promise<void>;
|
|
86
|
+
private _updateDeviceList;
|
|
87
|
+
start(): Promise<MediaStream>;
|
|
88
|
+
stop(): void;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface LocalMediaState {
|
|
92
|
+
currentCameraDeviceId?: string;
|
|
93
|
+
currentMicrophoneDeviceId?: string;
|
|
94
|
+
cameraDeviceError: unknown;
|
|
95
|
+
cameraDevices: MediaDeviceInfo[];
|
|
96
|
+
isSettingCameraDevice: boolean;
|
|
97
|
+
isSettingMicrophoneDevice: boolean;
|
|
98
|
+
isStarting: boolean;
|
|
99
|
+
localStream?: MediaStream;
|
|
100
|
+
microphoneDeviceError: unknown;
|
|
101
|
+
microphoneDevices: MediaDeviceInfo[];
|
|
102
|
+
speakerDevices: MediaDeviceInfo[];
|
|
103
|
+
startError: unknown;
|
|
104
|
+
}
|
|
105
|
+
interface LocalMediaActions {
|
|
106
|
+
setCameraDevice: InstanceType<typeof LocalMedia>["setCameraDevice"];
|
|
107
|
+
setMicrophoneDevice: InstanceType<typeof LocalMedia>["setMicrophoneDevice"];
|
|
108
|
+
toggleCameraEnabled: InstanceType<typeof LocalMedia>["toggleCameraEnabled"];
|
|
109
|
+
toggleMicrophoneEnabled: InstanceType<typeof LocalMedia>["toggleMichrophoneEnabled"];
|
|
110
|
+
}
|
|
111
|
+
type LocalMediaRef = {
|
|
112
|
+
state: LocalMediaState;
|
|
113
|
+
actions: LocalMediaActions;
|
|
114
|
+
_ref: LocalMedia;
|
|
115
|
+
};
|
|
116
|
+
declare function useLocalMedia(constraints?: MediaStreamConstraints): LocalMediaRef;
|
|
117
|
+
|
|
41
118
|
interface RoomParticipantData {
|
|
42
119
|
displayName: string;
|
|
43
120
|
id: string;
|
|
@@ -77,19 +154,96 @@ declare class LocalParticipant extends RoomParticipant {
|
|
|
77
154
|
type Logger = Pick<Console, "debug" | "error" | "log" | "warn">;
|
|
78
155
|
interface RoomConnectionOptions {
|
|
79
156
|
displayName?: string;
|
|
80
|
-
localStream?: MediaStream;
|
|
81
157
|
localMediaConstraints?: MediaStreamConstraints;
|
|
82
158
|
roomKey?: string;
|
|
83
159
|
logger?: Logger;
|
|
160
|
+
localMedia?: LocalMedia;
|
|
161
|
+
}
|
|
162
|
+
type RoomJoinedEvent = {
|
|
163
|
+
localParticipant: LocalParticipant;
|
|
164
|
+
remoteParticipants: RemoteParticipant[];
|
|
165
|
+
};
|
|
166
|
+
type ParticipantJoinedEvent = {
|
|
167
|
+
remoteParticipant: RemoteParticipant;
|
|
168
|
+
};
|
|
169
|
+
type ParticipantLeftEvent = {
|
|
170
|
+
participantId: string;
|
|
171
|
+
};
|
|
172
|
+
type ParticipantStreamAddedEvent = {
|
|
173
|
+
participantId: string;
|
|
174
|
+
stream: MediaStream;
|
|
175
|
+
};
|
|
176
|
+
type ParticipantAudioEnabledEvent = {
|
|
177
|
+
participantId: string;
|
|
178
|
+
isAudioEnabled: boolean;
|
|
179
|
+
};
|
|
180
|
+
type ParticipantVideoEnabledEvent = {
|
|
181
|
+
participantId: string;
|
|
182
|
+
isVideoEnabled: boolean;
|
|
183
|
+
};
|
|
184
|
+
type ParticipantMetadataChangedEvent = {
|
|
185
|
+
participantId: string;
|
|
186
|
+
displayName: string;
|
|
187
|
+
};
|
|
188
|
+
interface RoomEventsMap {
|
|
189
|
+
participant_audio_enabled: CustomEvent<ParticipantAudioEnabledEvent>;
|
|
190
|
+
participant_joined: CustomEvent<ParticipantJoinedEvent>;
|
|
191
|
+
participant_left: CustomEvent<ParticipantLeftEvent>;
|
|
192
|
+
participant_metadata_changed: CustomEvent<ParticipantMetadataChangedEvent>;
|
|
193
|
+
participant_stream_added: CustomEvent<ParticipantStreamAddedEvent>;
|
|
194
|
+
participant_video_enabled: CustomEvent<ParticipantVideoEnabledEvent>;
|
|
195
|
+
room_joined: CustomEvent<RoomJoinedEvent>;
|
|
196
|
+
}
|
|
197
|
+
interface RoomEventTarget extends EventTarget {
|
|
198
|
+
addEventListener<K extends keyof RoomEventsMap>(type: K, listener: (ev: RoomEventsMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
|
|
199
|
+
addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void;
|
|
200
|
+
}
|
|
201
|
+
declare const TypedEventTarget: new () => RoomEventTarget;
|
|
202
|
+
declare class RoomConnection extends TypedEventTarget {
|
|
203
|
+
localMedia: LocalMedia;
|
|
204
|
+
localParticipant: LocalParticipant | null;
|
|
205
|
+
roomUrl: URL;
|
|
206
|
+
remoteParticipants: RemoteParticipant[];
|
|
207
|
+
readonly localMediaConstraints?: MediaStreamConstraints;
|
|
208
|
+
private credentialsService;
|
|
209
|
+
private apiClient;
|
|
210
|
+
private organizationService;
|
|
211
|
+
private organizationServiceCache;
|
|
212
|
+
private organizationApiClient;
|
|
213
|
+
private roomService;
|
|
214
|
+
private signalSocket;
|
|
215
|
+
private rtcManagerDispatcher?;
|
|
216
|
+
private rtcManager?;
|
|
217
|
+
private roomConnectionState;
|
|
218
|
+
private logger;
|
|
219
|
+
private _ownsLocalMedia;
|
|
220
|
+
private displayName?;
|
|
221
|
+
constructor(roomUrl: string, { displayName, localMediaConstraints, logger, localMedia }: RoomConnectionOptions);
|
|
222
|
+
private _handleNewClient;
|
|
223
|
+
private _handleClientLeft;
|
|
224
|
+
private _handleClientAudioEnabled;
|
|
225
|
+
private _handleClientVideoEnabled;
|
|
226
|
+
private _handleClientMetadataReceived;
|
|
227
|
+
private _handleRtcEvent;
|
|
228
|
+
private _handleRtcManagerCreated;
|
|
229
|
+
private _handleAcceptStreams;
|
|
230
|
+
private _handleStreamAdded;
|
|
231
|
+
join(): Promise<void>;
|
|
232
|
+
leave(): Promise<void>;
|
|
233
|
+
setDisplayName(displayName: string): void;
|
|
84
234
|
}
|
|
85
235
|
|
|
86
236
|
type RemoteParticipantState = Omit<RemoteParticipant, "updateStreamState">;
|
|
87
|
-
interface
|
|
237
|
+
interface RoomConnectionState {
|
|
238
|
+
isJoining: boolean;
|
|
239
|
+
joinError: unknown;
|
|
88
240
|
localParticipant?: LocalParticipant;
|
|
89
241
|
roomConnectionStatus?: "connecting" | "connected" | "disconnected";
|
|
90
242
|
remoteParticipants: RemoteParticipantState[];
|
|
91
|
-
}
|
|
92
|
-
|
|
243
|
+
}
|
|
244
|
+
interface UseRoomConnectionOptions extends Omit<RoomConnectionOptions, "localMedia"> {
|
|
245
|
+
localMedia?: LocalMediaRef;
|
|
246
|
+
}
|
|
93
247
|
interface RoomConnectionActions {
|
|
94
248
|
toggleCamera(enabled?: boolean): void;
|
|
95
249
|
toggleMicrophone(enabled?: boolean): void;
|
|
@@ -98,8 +252,14 @@ interface RoomConnectionActions {
|
|
|
98
252
|
interface RoomConnectionComponents {
|
|
99
253
|
VideoView: typeof _default;
|
|
100
254
|
}
|
|
101
|
-
|
|
255
|
+
type RoomConnectionRef = {
|
|
256
|
+
state: RoomConnectionState;
|
|
257
|
+
actions: RoomConnectionActions;
|
|
258
|
+
components: RoomConnectionComponents;
|
|
259
|
+
_ref: RoomConnection;
|
|
260
|
+
};
|
|
261
|
+
declare function useRoomConnection(roomUrl: string, roomConnectionOptions: UseRoomConnectionOptions): RoomConnectionRef;
|
|
102
262
|
|
|
103
|
-
declare const sdkVersion = "2.0.0-
|
|
263
|
+
declare const sdkVersion = "2.0.0-alpha7";
|
|
104
264
|
|
|
105
|
-
export { sdkVersion, useRoomConnection };
|
|
265
|
+
export { _default as VideoView, sdkVersion, useLocalMedia, useRoomConnection };
|