@whereby.com/browser-sdk 2.0.0-beta1 → 2.0.0-beta3
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 +12 -24
- package/dist/embed/index.d.ts +4 -1
- package/dist/embed/{index.js → index.esm.js} +117 -110
- package/dist/react/index.d.ts +397 -6
- package/dist/react/index.esm.js +8245 -0
- package/dist/utils/index.d.ts +5 -2
- package/dist/utils/{fakeWebcamFrame.js → index.esm.js} +68 -47
- package/dist/v2-beta3.js +15 -0
- package/package.json +50 -27
- package/dist/LocalMedia.d.ts +0 -63
- package/dist/LocalMedia.js +0 -211
- package/dist/RoomConnection.d.ts +0 -184
- package/dist/RoomConnection.js +0 -627
- package/dist/RoomParticipant.d.ts +0 -50
- package/dist/RoomParticipant.js +0 -48
- package/dist/api/ApiClient.d.ts +0 -26
- package/dist/api/ApiClient.js +0 -63
- package/dist/api/Credentials.d.ts +0 -17
- package/dist/api/Credentials.js +0 -16
- package/dist/api/HttpClient.d.ts +0 -16
- package/dist/api/HttpClient.js +0 -53
- package/dist/api/MultipartHttpClient.d.ts +0 -10
- package/dist/api/MultipartHttpClient.js +0 -25
- package/dist/api/OrganizationApiClient.d.ts +0 -16
- package/dist/api/OrganizationApiClient.js +0 -29
- package/dist/api/Response.d.ts +0 -29
- package/dist/api/Response.js +0 -9
- package/dist/api/credentialsService/index.d.ts +0 -27
- package/dist/api/credentialsService/index.js +0 -89
- package/dist/api/deviceService/index.d.ts +0 -9
- package/dist/api/deviceService/index.js +0 -23
- package/dist/api/extractUtils.d.ts +0 -16
- package/dist/api/extractUtils.js +0 -51
- package/dist/api/index.d.ts +0 -7
- package/dist/api/index.js +0 -7
- package/dist/api/localStorageWrapper/index.d.ts +0 -2
- package/dist/api/localStorageWrapper/index.js +0 -15
- package/dist/api/models/Account.d.ts +0 -20
- package/dist/api/models/Account.js +0 -24
- package/dist/api/models/Meeting.d.ts +0 -12
- package/dist/api/models/Meeting.js +0 -29
- package/dist/api/models/Organization.d.ts +0 -102
- package/dist/api/models/Organization.js +0 -81
- package/dist/api/models/Room.d.ts +0 -4
- package/dist/api/models/Room.js +0 -38
- package/dist/api/models/account/EmbeddedFreeTierStatus.d.ts +0 -13
- package/dist/api/models/account/EmbeddedFreeTierStatus.js +0 -17
- package/dist/api/modules/AbstractStore.d.ts +0 -5
- package/dist/api/modules/AbstractStore.js +0 -1
- package/dist/api/modules/ChromeStorageStore.d.ts +0 -10
- package/dist/api/modules/ChromeStorageStore.js +0 -21
- package/dist/api/modules/LocalStorageStore.d.ts +0 -9
- package/dist/api/modules/LocalStorageStore.js +0 -35
- package/dist/api/modules/tests/__mocks__/storage.d.ts +0 -10
- package/dist/api/modules/tests/__mocks__/storage.js +0 -19
- package/dist/api/organizationService/index.d.ts +0 -46
- package/dist/api/organizationService/index.js +0 -158
- package/dist/api/organizationServiceCache/index.d.ts +0 -13
- package/dist/api/organizationServiceCache/index.js +0 -16
- package/dist/api/parameterAssertUtils.d.ts +0 -13
- package/dist/api/parameterAssertUtils.js +0 -64
- package/dist/api/roomService/index.d.ts +0 -54
- package/dist/api/roomService/index.js +0 -160
- package/dist/api/test/helpers.d.ts +0 -7
- package/dist/api/test/helpers.js +0 -32
- package/dist/api/types.d.ts +0 -5
- package/dist/api/types.js +0 -1
- package/dist/react/VideoView.d.ts +0 -15
- package/dist/react/VideoView.js +0 -37
- package/dist/react/index.js +0 -4
- package/dist/react/useLocalMedia.d.ts +0 -28
- package/dist/react/useLocalMedia.js +0 -109
- package/dist/react/useRoomConnection.d.ts +0 -55
- package/dist/react/useRoomConnection.js +0 -315
- package/dist/utils/debounce.d.ts +0 -9
- package/dist/utils/debounce.js +0 -20
- package/dist/utils/fakeAudioStream.d.ts +0 -1
- package/dist/utils/fakeAudioStream.js +0 -18
- package/dist/utils/fakeWebcamFrame.d.ts +0 -1
- package/dist/utils/index.js +0 -2
- package/dist/v2-beta1.js +0 -2001
- package/dist/version.d.ts +0 -1
- package/dist/version.js +0 -1
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export default class OrganizationServiceCache {
|
|
2
|
-
constructor({ organizationService, subdomain }) {
|
|
3
|
-
this._organizationService = organizationService;
|
|
4
|
-
this._subdomain = subdomain;
|
|
5
|
-
this._organizationPromise = null;
|
|
6
|
-
}
|
|
7
|
-
initOrganization() {
|
|
8
|
-
return this.fetchOrganization().then(() => undefined);
|
|
9
|
-
}
|
|
10
|
-
fetchOrganization() {
|
|
11
|
-
if (!this._organizationPromise) {
|
|
12
|
-
this._organizationPromise = this._organizationService.getOrganizationBySubdomain(this._subdomain);
|
|
13
|
-
}
|
|
14
|
-
return this._organizationPromise;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare function assertTruthy(value: unknown, parameterName: string): unknown;
|
|
2
|
-
export declare function assertBoolean(value: unknown, parameterName: string): boolean;
|
|
3
|
-
export declare function assertNumber(value: unknown, parameterName: string): number;
|
|
4
|
-
export declare function assertString(value: unknown, parameterName: string): string;
|
|
5
|
-
export declare function assertInstanceOf<T>(value: unknown, type: new (any: unknown) => T, parameterName?: string): T;
|
|
6
|
-
export declare function assertRoomName(roomName: unknown, parameterName?: string): string;
|
|
7
|
-
export declare function assertArray(array: unknown, parameterName: string): Array<unknown>;
|
|
8
|
-
export declare function assertOneOf<T>(value: T, allowedValues: Array<unknown>, parameterName: string): T;
|
|
9
|
-
export declare function assertType(ref: unknown, type: string, name: string, message?: string): void;
|
|
10
|
-
export declare function assertRecord(ref: unknown, name: string): Record<string, unknown>;
|
|
11
|
-
export declare function assertNullOrType(ref: unknown, type: string, name: string, message?: string): void;
|
|
12
|
-
export declare function assertNullOrBoolean(ref: unknown, name: string, message?: string): void;
|
|
13
|
-
export declare function assertNullOrString(ref: unknown, name: string, message?: string): void;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import assert from "assert";
|
|
2
|
-
export function assertTruthy(value, parameterName) {
|
|
3
|
-
assert.ok(value, `${parameterName} is required`);
|
|
4
|
-
return value;
|
|
5
|
-
}
|
|
6
|
-
export function assertBoolean(value, parameterName) {
|
|
7
|
-
assert.ok(typeof value === "boolean", `${parameterName}<boolean> is required`);
|
|
8
|
-
return value;
|
|
9
|
-
}
|
|
10
|
-
export function assertNumber(value, parameterName) {
|
|
11
|
-
assert.ok(typeof value === "number", `${parameterName}<number> is required`);
|
|
12
|
-
return value;
|
|
13
|
-
}
|
|
14
|
-
export function assertString(value, parameterName) {
|
|
15
|
-
assert.ok(typeof value === "string", `${parameterName}<string> is required`);
|
|
16
|
-
return value;
|
|
17
|
-
}
|
|
18
|
-
export function assertInstanceOf(value, type, parameterName) {
|
|
19
|
-
const resolvedParameterName = parameterName || type.name[0].toLowerCase() + type.name.substring(1);
|
|
20
|
-
assert.ok(value instanceof type, `${resolvedParameterName}<${type.name}> is required`);
|
|
21
|
-
return value;
|
|
22
|
-
}
|
|
23
|
-
export function assertRoomName(roomName, parameterName = "roomName") {
|
|
24
|
-
assertString(roomName, parameterName);
|
|
25
|
-
assert.equal(typeof roomName === "string" && roomName[0], "/", `${parameterName} must begin with a '/'`);
|
|
26
|
-
return roomName;
|
|
27
|
-
}
|
|
28
|
-
export function assertArray(array, parameterName) {
|
|
29
|
-
assert.ok(Array.isArray(array), `${parameterName}<array> is required`);
|
|
30
|
-
return array;
|
|
31
|
-
}
|
|
32
|
-
export function assertOneOf(value, allowedValues, parameterName) {
|
|
33
|
-
assertTruthy(value, "value");
|
|
34
|
-
assertArray(allowedValues, "allowedValues");
|
|
35
|
-
const isAllowed = allowedValues.includes(value);
|
|
36
|
-
if (!isAllowed) {
|
|
37
|
-
throw new Error(`${parameterName}<string> must be one of the following: ${allowedValues.join(", ")}`);
|
|
38
|
-
}
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
export function assertType(ref, type, name, message) {
|
|
42
|
-
assert.ok(typeof name === "string", "name must be of type string");
|
|
43
|
-
const errorMessage = message || `${name} must be of type ${type}`;
|
|
44
|
-
assert.ok(ref !== null && typeof ref === type, errorMessage);
|
|
45
|
-
}
|
|
46
|
-
export function assertRecord(ref, name) {
|
|
47
|
-
if (ref === null || ref === undefined || typeof ref !== "object" || Array.isArray(ref)) {
|
|
48
|
-
throw new Error(`${name} must be a record. ${JSON.stringify(ref)}`);
|
|
49
|
-
}
|
|
50
|
-
return ref;
|
|
51
|
-
}
|
|
52
|
-
export function assertNullOrType(ref, type, name, message) {
|
|
53
|
-
assertString(name, "name");
|
|
54
|
-
const errorMessage = message || `${name} must be null or of type ${type}`;
|
|
55
|
-
assert.ok(ref === null || typeof ref === type, errorMessage);
|
|
56
|
-
}
|
|
57
|
-
export function assertNullOrBoolean(ref, name, message) {
|
|
58
|
-
assertString(name, "name");
|
|
59
|
-
assertNullOrType(ref, "boolean", name, message);
|
|
60
|
-
}
|
|
61
|
-
export function assertNullOrString(ref, name, message) {
|
|
62
|
-
assertString(name, "name");
|
|
63
|
-
assertNullOrType(ref, "string", name, message);
|
|
64
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import Room from "../models/Room";
|
|
2
|
-
export default class RoomService {
|
|
3
|
-
constructor({ organizationApiClient }: {
|
|
4
|
-
organizationApiClient: any;
|
|
5
|
-
});
|
|
6
|
-
getRooms({ types, fields }?: {
|
|
7
|
-
types: any;
|
|
8
|
-
fields?: never[] | undefined;
|
|
9
|
-
}): any;
|
|
10
|
-
getRoom({ roomName, fields }: {
|
|
11
|
-
roomName: string;
|
|
12
|
-
fields?: Array<string>;
|
|
13
|
-
}): Promise<Room>;
|
|
14
|
-
claimRoom({ roomName, type, mode, isLocked }: {
|
|
15
|
-
roomName: any;
|
|
16
|
-
type: any;
|
|
17
|
-
mode: any;
|
|
18
|
-
isLocked: any;
|
|
19
|
-
}): any;
|
|
20
|
-
unclaimRoom(roomName: any): any;
|
|
21
|
-
renameRoom({ roomName, newRoomName }: {
|
|
22
|
-
roomName: any;
|
|
23
|
-
newRoomName: any;
|
|
24
|
-
}): any;
|
|
25
|
-
changeMode({ roomName, mode }: {
|
|
26
|
-
roomName: any;
|
|
27
|
-
mode: any;
|
|
28
|
-
}): any;
|
|
29
|
-
updatePreferences({ roomName, preferences }: {
|
|
30
|
-
roomName: any;
|
|
31
|
-
preferences: any;
|
|
32
|
-
}): any;
|
|
33
|
-
updateProtectedPreferences({ roomName, preferences }: {
|
|
34
|
-
roomName: any;
|
|
35
|
-
preferences: any;
|
|
36
|
-
}): any;
|
|
37
|
-
getRoomPermissions(roomName: any, { roomKey }?: {
|
|
38
|
-
roomKey: any;
|
|
39
|
-
}): any;
|
|
40
|
-
getRoomMetrics({ roomName, metrics, from, to }: {
|
|
41
|
-
roomName: any;
|
|
42
|
-
metrics: any;
|
|
43
|
-
from: any;
|
|
44
|
-
to: any;
|
|
45
|
-
}): any;
|
|
46
|
-
changeType({ roomName, type }: {
|
|
47
|
-
roomName: any;
|
|
48
|
-
type: any;
|
|
49
|
-
}): any;
|
|
50
|
-
getForestSocialImage({ roomName, count }: {
|
|
51
|
-
roomName: any;
|
|
52
|
-
count: any;
|
|
53
|
-
}): any;
|
|
54
|
-
}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import Room from "../models/Room";
|
|
2
|
-
import { assertInstanceOf, assertRoomName, assertString, assertArray, assertOneOf, assertNumber, } from "../parameterAssertUtils";
|
|
3
|
-
import OrganizationApiClient from "../OrganizationApiClient";
|
|
4
|
-
import Meeting from "../models/Meeting";
|
|
5
|
-
function createRoomUrl(roomName, path = "") {
|
|
6
|
-
const encodedDisplayName = encodeURIComponent(roomName.substring(1));
|
|
7
|
-
return `/room/${encodedDisplayName}${path}`;
|
|
8
|
-
}
|
|
9
|
-
export default class RoomService {
|
|
10
|
-
constructor({ organizationApiClient }) {
|
|
11
|
-
this._organizationApiClient = assertInstanceOf(organizationApiClient, OrganizationApiClient);
|
|
12
|
-
}
|
|
13
|
-
getRooms({ types, fields = [] } = {}) {
|
|
14
|
-
assertArray(types, "types");
|
|
15
|
-
assertArray(fields, "fields");
|
|
16
|
-
return this._organizationApiClient
|
|
17
|
-
.request("/room", {
|
|
18
|
-
method: "GET",
|
|
19
|
-
params: { types: types.join(","), fields: fields.join(","), includeOnlyLegacyRoomType: "false" },
|
|
20
|
-
})
|
|
21
|
-
.then(({ data }) => data.rooms.map((room) => new Room(room)));
|
|
22
|
-
}
|
|
23
|
-
getRoom({ roomName, fields }) {
|
|
24
|
-
assertRoomName(roomName);
|
|
25
|
-
const encodedDisplayName = encodeURIComponent(roomName.substring(1));
|
|
26
|
-
return this._organizationApiClient
|
|
27
|
-
.request(`/rooms/${encodedDisplayName}`, {
|
|
28
|
-
method: "GET",
|
|
29
|
-
params: Object.assign({ includeOnlyLegacyRoomType: "false" }, (fields && { fields: fields.join(",") })),
|
|
30
|
-
})
|
|
31
|
-
.then(({ data }) => new Room(Object.assign({}, data, Object.assign({ roomName }, (data.meeting && { meeting: Meeting.fromJson(data.meeting) })))))
|
|
32
|
-
.catch((response) => {
|
|
33
|
-
if (response.status === 404) {
|
|
34
|
-
return new Room({
|
|
35
|
-
roomName,
|
|
36
|
-
isClaimed: false,
|
|
37
|
-
mode: "normal",
|
|
38
|
-
product: {
|
|
39
|
-
categoryName: "personal_free",
|
|
40
|
-
},
|
|
41
|
-
type: "personal",
|
|
42
|
-
legacyRoomType: "free",
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
if (response.status === 400 && response.data.error === "Banned room") {
|
|
46
|
-
return new Room({ roomName, isBanned: true });
|
|
47
|
-
}
|
|
48
|
-
throw new Error(response.data ? response.data.error : "Could not fetch room information");
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
claimRoom({ roomName, type, mode, isLocked }) {
|
|
52
|
-
assertRoomName(roomName);
|
|
53
|
-
assertString(type, "type");
|
|
54
|
-
return this._organizationApiClient
|
|
55
|
-
.request("/room/claim", {
|
|
56
|
-
method: "POST",
|
|
57
|
-
data: Object.assign(Object.assign({ roomName,
|
|
58
|
-
type }, (typeof mode === "string" && { mode })), (typeof isLocked === "boolean" && { isLocked })),
|
|
59
|
-
})
|
|
60
|
-
.then(() => undefined)
|
|
61
|
-
.catch((response) => {
|
|
62
|
-
throw new Error(response.data.error || "Failed to claim room");
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
unclaimRoom(roomName) {
|
|
66
|
-
assertRoomName(roomName);
|
|
67
|
-
const encodedDisplayName = encodeURIComponent(roomName.substring(1));
|
|
68
|
-
return this._organizationApiClient
|
|
69
|
-
.request(`/room/${encodedDisplayName}`, {
|
|
70
|
-
method: "DELETE",
|
|
71
|
-
})
|
|
72
|
-
.then(() => undefined);
|
|
73
|
-
}
|
|
74
|
-
renameRoom({ roomName, newRoomName }) {
|
|
75
|
-
assertRoomName(roomName);
|
|
76
|
-
assertString(newRoomName, "newRoomName");
|
|
77
|
-
const encodedRoomName = encodeURIComponent(roomName.substring(1));
|
|
78
|
-
return this._organizationApiClient
|
|
79
|
-
.request(`/room/${encodedRoomName}/roomName`, {
|
|
80
|
-
method: "PUT",
|
|
81
|
-
data: { newRoomName },
|
|
82
|
-
})
|
|
83
|
-
.then(() => undefined);
|
|
84
|
-
}
|
|
85
|
-
changeMode({ roomName, mode }) {
|
|
86
|
-
assertRoomName(roomName);
|
|
87
|
-
assertString(mode, "mode");
|
|
88
|
-
const encodedDisplayName = encodeURIComponent(roomName.substring(1));
|
|
89
|
-
return this._organizationApiClient
|
|
90
|
-
.request(`/room/${encodedDisplayName}/mode`, {
|
|
91
|
-
method: "PUT",
|
|
92
|
-
data: { mode },
|
|
93
|
-
})
|
|
94
|
-
.then(() => undefined);
|
|
95
|
-
}
|
|
96
|
-
updatePreferences({ roomName, preferences }) {
|
|
97
|
-
assertRoomName(roomName);
|
|
98
|
-
assertInstanceOf(preferences, Object, "preferences");
|
|
99
|
-
const encodedDisplayName = encodeURIComponent(roomName.substring(1));
|
|
100
|
-
return this._organizationApiClient
|
|
101
|
-
.request(`/room/${encodedDisplayName}/preferences`, {
|
|
102
|
-
method: "PATCH",
|
|
103
|
-
data: preferences,
|
|
104
|
-
})
|
|
105
|
-
.then(() => undefined);
|
|
106
|
-
}
|
|
107
|
-
updateProtectedPreferences({ roomName, preferences }) {
|
|
108
|
-
assertRoomName(roomName);
|
|
109
|
-
assertInstanceOf(preferences, Object, "preferences");
|
|
110
|
-
const encodedDisplayName = encodeURIComponent(roomName.substring(1));
|
|
111
|
-
return this._organizationApiClient
|
|
112
|
-
.request(`/room/${encodedDisplayName}/protected-preferences`, {
|
|
113
|
-
method: "PATCH",
|
|
114
|
-
data: preferences,
|
|
115
|
-
})
|
|
116
|
-
.then(() => undefined);
|
|
117
|
-
}
|
|
118
|
-
getRoomPermissions(roomName, { roomKey } = {}) {
|
|
119
|
-
assertRoomName(roomName);
|
|
120
|
-
return this._organizationApiClient
|
|
121
|
-
.request(createRoomUrl(roomName, "/permissions"), Object.assign({ method: "GET" }, (roomKey && { headers: { "X-Whereby-Room-Key": roomKey } })))
|
|
122
|
-
.then((response) => {
|
|
123
|
-
const { permissions, limits } = response.data;
|
|
124
|
-
return {
|
|
125
|
-
permissions,
|
|
126
|
-
limits,
|
|
127
|
-
};
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
getRoomMetrics({ roomName, metrics, from, to }) {
|
|
131
|
-
assertRoomName(roomName);
|
|
132
|
-
assertString(metrics, "metrics");
|
|
133
|
-
return this._organizationApiClient
|
|
134
|
-
.request(createRoomUrl(roomName, "/metrics"), {
|
|
135
|
-
method: "GET",
|
|
136
|
-
params: { metrics, from, to },
|
|
137
|
-
})
|
|
138
|
-
.then((response) => response.data);
|
|
139
|
-
}
|
|
140
|
-
changeType({ roomName, type }) {
|
|
141
|
-
assertRoomName(roomName);
|
|
142
|
-
assertOneOf(type, ["personal", "personal_xl"], "type");
|
|
143
|
-
const encodedDisplayName = encodeURIComponent(roomName.substring(1));
|
|
144
|
-
return this._organizationApiClient
|
|
145
|
-
.request(`/room/${encodedDisplayName}/type`, {
|
|
146
|
-
method: "PUT",
|
|
147
|
-
data: { type },
|
|
148
|
-
})
|
|
149
|
-
.then(() => undefined);
|
|
150
|
-
}
|
|
151
|
-
getForestSocialImage({ roomName, count }) {
|
|
152
|
-
assertRoomName(roomName);
|
|
153
|
-
assertNumber(count, "count");
|
|
154
|
-
return this._organizationApiClient
|
|
155
|
-
.request(createRoomUrl(roomName, `/forest-social-image/${count}`), {
|
|
156
|
-
method: "GET",
|
|
157
|
-
})
|
|
158
|
-
.then((response) => response.data.imageUrl);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
|
-
import ApiClient from "../ApiClient";
|
|
3
|
-
import { Json } from "../Response";
|
|
4
|
-
export declare const itShouldThrowIfInvalid: (missingPropertyName: string, func: () => void, regexMatcher?: RegExp) => void;
|
|
5
|
-
export declare const itShouldRejectIfApiClientRejects: (getApiClient: () => jest.Mocked<ApiClient>, func: () => void) => void;
|
|
6
|
-
export declare const itShouldRejectIfMultipartRequestRejects: (getApiClient: () => jest.Mocked<ApiClient>, func: () => void) => void;
|
|
7
|
-
export declare function toJson(value: unknown): Json;
|
package/dist/api/test/helpers.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
export const itShouldThrowIfInvalid = (missingPropertyName, func, regexMatcher) => {
|
|
3
|
-
const testingNoArguments = !missingPropertyName;
|
|
4
|
-
const isOrAre = missingPropertyName[missingPropertyName.length - 1] === "s" ? "are" : "is";
|
|
5
|
-
const scenario = testingNoArguments ? "arguments are missing" : `${missingPropertyName} ${isOrAre} invalid`;
|
|
6
|
-
const expectedException = testingNoArguments
|
|
7
|
-
? undefined
|
|
8
|
-
: regexMatcher || new RegExp(`${missingPropertyName}(<[\\w|]+>)? (is|are) required`);
|
|
9
|
-
it(`should throw if ${scenario}`, () => {
|
|
10
|
-
expect(() => {
|
|
11
|
-
func();
|
|
12
|
-
}).toThrowError(expectedException);
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
export const itShouldRejectIfApiClientRejects = (getApiClient, func) => {
|
|
16
|
-
it("should fail if the request failed", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
-
const error = new Error("some error");
|
|
18
|
-
getApiClient().request.mockRejectedValue(error);
|
|
19
|
-
yield expect(func()).rejects.toThrow(error);
|
|
20
|
-
}));
|
|
21
|
-
};
|
|
22
|
-
export const itShouldRejectIfMultipartRequestRejects = (getApiClient, func) => {
|
|
23
|
-
it("should fail if the requestMultipart failed", () => {
|
|
24
|
-
const error = new Error("some error");
|
|
25
|
-
getApiClient().requestMultipart.rejects(error);
|
|
26
|
-
const promise = func();
|
|
27
|
-
return expect(promise).to.eventually.be.rejected().toBe(error);
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
export function toJson(value) {
|
|
31
|
-
return JSON.parse(JSON.stringify(value));
|
|
32
|
-
}
|
package/dist/api/types.d.ts
DELETED
package/dist/api/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
interface VideoViewSelfProps {
|
|
3
|
-
stream: MediaStream;
|
|
4
|
-
muted?: boolean;
|
|
5
|
-
mirror?: boolean;
|
|
6
|
-
style?: React.CSSProperties;
|
|
7
|
-
onResize?: ({ width, height, stream }: {
|
|
8
|
-
width: number;
|
|
9
|
-
height: number;
|
|
10
|
-
stream: MediaStream;
|
|
11
|
-
}) => void;
|
|
12
|
-
}
|
|
13
|
-
type VideoViewProps = VideoViewSelfProps & React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>;
|
|
14
|
-
declare const _default: ({ muted, mirror, stream, onResize, ...rest }: VideoViewProps) => JSX.Element;
|
|
15
|
-
export default _default;
|
package/dist/react/VideoView.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { __rest } from "tslib";
|
|
2
|
-
import React, { useEffect, useRef } from "react";
|
|
3
|
-
import debounce from "../utils/debounce";
|
|
4
|
-
export default (_a) => {
|
|
5
|
-
var { muted, mirror = false, stream, onResize } = _a, rest = __rest(_a, ["muted", "mirror", "stream", "onResize"]);
|
|
6
|
-
const videoEl = useRef(null);
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
if (!videoEl.current || !onResize) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
const resizeObserver = new ResizeObserver(debounce(() => {
|
|
12
|
-
if (videoEl.current && (stream === null || stream === void 0 ? void 0 : stream.id)) {
|
|
13
|
-
onResize({
|
|
14
|
-
width: videoEl.current.clientWidth,
|
|
15
|
-
height: videoEl.current.clientHeight,
|
|
16
|
-
stream,
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}, { delay: 1000, edges: true }));
|
|
20
|
-
resizeObserver.observe(videoEl.current);
|
|
21
|
-
return () => {
|
|
22
|
-
resizeObserver.disconnect();
|
|
23
|
-
};
|
|
24
|
-
}, [stream]);
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
if (!videoEl.current) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (videoEl.current.srcObject !== stream) {
|
|
30
|
-
videoEl.current.srcObject = stream;
|
|
31
|
-
}
|
|
32
|
-
if (videoEl.current.muted !== muted) {
|
|
33
|
-
videoEl.current.muted = Boolean(muted);
|
|
34
|
-
}
|
|
35
|
-
}, [muted, stream, videoEl]);
|
|
36
|
-
return (React.createElement("video", Object.assign({ ref: videoEl, autoPlay: true, playsInline: true }, rest, { style: Object.assign({ transform: mirror ? "scaleX(-1)" : "none" }, rest.style) })));
|
|
37
|
-
};
|
package/dist/react/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import LocalMedia from "../LocalMedia";
|
|
2
|
-
interface LocalMediaState {
|
|
3
|
-
currentCameraDeviceId?: string;
|
|
4
|
-
currentMicrophoneDeviceId?: string;
|
|
5
|
-
cameraDeviceError: unknown;
|
|
6
|
-
cameraDevices: MediaDeviceInfo[];
|
|
7
|
-
isSettingCameraDevice: boolean;
|
|
8
|
-
isSettingMicrophoneDevice: boolean;
|
|
9
|
-
isStarting: boolean;
|
|
10
|
-
localStream?: MediaStream;
|
|
11
|
-
microphoneDeviceError: unknown;
|
|
12
|
-
microphoneDevices: MediaDeviceInfo[];
|
|
13
|
-
speakerDevices: MediaDeviceInfo[];
|
|
14
|
-
startError: unknown;
|
|
15
|
-
}
|
|
16
|
-
interface LocalMediaActions {
|
|
17
|
-
setCameraDevice: InstanceType<typeof LocalMedia>["setCameraDevice"];
|
|
18
|
-
setMicrophoneDevice: InstanceType<typeof LocalMedia>["setMicrophoneDevice"];
|
|
19
|
-
toggleCameraEnabled: InstanceType<typeof LocalMedia>["toggleCameraEnabled"];
|
|
20
|
-
toggleMicrophoneEnabled: InstanceType<typeof LocalMedia>["toggleMichrophoneEnabled"];
|
|
21
|
-
}
|
|
22
|
-
export type LocalMediaRef = {
|
|
23
|
-
state: LocalMediaState;
|
|
24
|
-
actions: LocalMediaActions;
|
|
25
|
-
_ref: LocalMedia;
|
|
26
|
-
};
|
|
27
|
-
export default function useLocalMedia(constraintsOrStream?: MediaStreamConstraints | MediaStream): LocalMediaRef;
|
|
28
|
-
export {};
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import { useEffect, useReducer, useState } from "react";
|
|
3
|
-
import LocalMedia from "../LocalMedia";
|
|
4
|
-
const initialState = {
|
|
5
|
-
cameraDeviceError: null,
|
|
6
|
-
cameraDevices: [],
|
|
7
|
-
isSettingCameraDevice: false,
|
|
8
|
-
isSettingMicrophoneDevice: false,
|
|
9
|
-
isStarting: false,
|
|
10
|
-
microphoneDeviceError: null,
|
|
11
|
-
microphoneDevices: [],
|
|
12
|
-
speakerDevices: [],
|
|
13
|
-
startError: null,
|
|
14
|
-
};
|
|
15
|
-
function reducer(state, action) {
|
|
16
|
-
switch (action.type) {
|
|
17
|
-
case "DEVICE_LIST_UPDATED":
|
|
18
|
-
return Object.assign(Object.assign({}, state), action.payload);
|
|
19
|
-
case "LOCAL_STREAM_UPDATED":
|
|
20
|
-
return Object.assign(Object.assign({}, state), { currentCameraDeviceId: action.payload.currentCameraDeviceId, currentMicrophoneDeviceId: action.payload.currentMicrophoneDeviceId, localStream: action.payload.stream });
|
|
21
|
-
case "SET_CAMERA_DEVICE":
|
|
22
|
-
return Object.assign(Object.assign({}, state), { cameraDeviceError: null, isSettingCameraDevice: true });
|
|
23
|
-
case "SET_CAMERA_DEVICE_COMPLETE":
|
|
24
|
-
return Object.assign(Object.assign({}, state), { isSettingCameraDevice: false });
|
|
25
|
-
case "SET_CAMERA_DEVICE_ERROR":
|
|
26
|
-
return Object.assign(Object.assign({}, state), { cameraDeviceError: action.payload, isSettingCameraDevice: false });
|
|
27
|
-
case "SET_MICROPHONE_DEVICE":
|
|
28
|
-
return Object.assign(Object.assign({}, state), { isSettingMicrophoneDevice: true, microphoneDeviceError: null });
|
|
29
|
-
case "SET_MICROPHONE_DEVICE_COMPLETE":
|
|
30
|
-
return Object.assign(Object.assign({}, state), { isSettingMicrophoneDevice: false });
|
|
31
|
-
case "SET_MICROPHONE_DEVICE_ERROR":
|
|
32
|
-
return Object.assign(Object.assign({}, state), { isSettingMicrophoneDevice: false, microphoneDeviceError: action.payload });
|
|
33
|
-
case "START":
|
|
34
|
-
return Object.assign(Object.assign({}, state), { isStarting: true, startError: null });
|
|
35
|
-
case "START_COMPLETE":
|
|
36
|
-
return Object.assign(Object.assign({}, state), { isStarting: false });
|
|
37
|
-
case "START_ERROR":
|
|
38
|
-
return Object.assign(Object.assign({}, state), { isStarting: false, startError: action.payload });
|
|
39
|
-
default:
|
|
40
|
-
return state;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
export default function useLocalMedia(constraintsOrStream = { audio: true, video: true }) {
|
|
44
|
-
const [localMedia] = useState(() => new LocalMedia(constraintsOrStream));
|
|
45
|
-
const [state, dispatch] = useReducer(reducer, initialState);
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
localMedia.addEventListener("device_list_updated", (e) => {
|
|
48
|
-
const { cameraDevices, microphoneDevices, speakerDevices } = e.detail;
|
|
49
|
-
dispatch({ type: "DEVICE_LIST_UPDATED", payload: { cameraDevices, microphoneDevices, speakerDevices } });
|
|
50
|
-
});
|
|
51
|
-
localMedia.addEventListener("stream_updated", (e) => {
|
|
52
|
-
const { stream } = e.detail;
|
|
53
|
-
dispatch({
|
|
54
|
-
type: "LOCAL_STREAM_UPDATED",
|
|
55
|
-
payload: {
|
|
56
|
-
stream,
|
|
57
|
-
currentCameraDeviceId: localMedia.getCameraDeviceId(),
|
|
58
|
-
currentMicrophoneDeviceId: localMedia.getMicrophoneDeviceId(),
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
const start = () => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
dispatch({ type: "START" });
|
|
64
|
-
try {
|
|
65
|
-
yield localMedia.start();
|
|
66
|
-
dispatch({ type: "START_COMPLETE" });
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
dispatch({ type: "START_ERROR", payload: error });
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
start();
|
|
73
|
-
return () => {
|
|
74
|
-
localMedia.stop();
|
|
75
|
-
};
|
|
76
|
-
}, []);
|
|
77
|
-
return {
|
|
78
|
-
state,
|
|
79
|
-
actions: {
|
|
80
|
-
setCameraDevice: (...args) => __awaiter(this, void 0, void 0, function* () {
|
|
81
|
-
dispatch({ type: "SET_CAMERA_DEVICE" });
|
|
82
|
-
try {
|
|
83
|
-
yield localMedia.setCameraDevice(...args);
|
|
84
|
-
dispatch({ type: "SET_CAMERA_DEVICE_COMPLETE" });
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
87
|
-
dispatch({ type: "SET_CAMERA_DEVICE_ERROR", payload: error });
|
|
88
|
-
}
|
|
89
|
-
}),
|
|
90
|
-
setMicrophoneDevice: (...args) => __awaiter(this, void 0, void 0, function* () {
|
|
91
|
-
dispatch({ type: "SET_MICROPHONE_DEVICE" });
|
|
92
|
-
try {
|
|
93
|
-
yield localMedia.setMicrophoneDevice(...args);
|
|
94
|
-
dispatch({ type: "SET_MICROPHONE_DEVICE_COMPLETE" });
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
dispatch({ type: "SET_MICROPHONE_DEVICE_ERROR", payload: error });
|
|
98
|
-
}
|
|
99
|
-
}),
|
|
100
|
-
toggleCameraEnabled: (...args) => {
|
|
101
|
-
return localMedia.toggleCameraEnabled(...args);
|
|
102
|
-
},
|
|
103
|
-
toggleMicrophoneEnabled: (...args) => {
|
|
104
|
-
return localMedia.toggleMichrophoneEnabled(...args);
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
_ref: localMedia,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import VideoView from "./VideoView";
|
|
3
|
-
import { LocalMediaRef } from "./useLocalMedia";
|
|
4
|
-
import RoomConnection, { ChatMessage, CloudRecordingState, RoomConnectionOptions, ConnectionStatus, LiveStreamState } from "../RoomConnection";
|
|
5
|
-
import { LocalParticipant, RemoteParticipant, Screenshare } from "../RoomParticipant";
|
|
6
|
-
export type RemoteParticipantState = Omit<RemoteParticipant, "updateStreamState" | "newJoiner" | "streams" | "addStream" | "removeStream">;
|
|
7
|
-
export type LocalParticipantState = LocalParticipant;
|
|
8
|
-
export interface WaitingParticipantState {
|
|
9
|
-
id: string;
|
|
10
|
-
displayName: string | null;
|
|
11
|
-
}
|
|
12
|
-
export interface ChatMessageState {
|
|
13
|
-
senderId: string;
|
|
14
|
-
timestamp: string;
|
|
15
|
-
text: string;
|
|
16
|
-
}
|
|
17
|
-
export type ScreenshareState = Screenshare;
|
|
18
|
-
type LocalScreenshareStatus = "starting" | "active";
|
|
19
|
-
export interface RoomConnectionState {
|
|
20
|
-
chatMessages: ChatMessage[];
|
|
21
|
-
cloudRecording?: CloudRecordingState;
|
|
22
|
-
localScreenshareStatus?: LocalScreenshareStatus;
|
|
23
|
-
localParticipant?: LocalParticipantState;
|
|
24
|
-
remoteParticipants: RemoteParticipantState[];
|
|
25
|
-
screenshares: Screenshare[];
|
|
26
|
-
connectionStatus: ConnectionStatus;
|
|
27
|
-
liveStream?: LiveStreamState;
|
|
28
|
-
waitingParticipants: WaitingParticipantState[];
|
|
29
|
-
}
|
|
30
|
-
interface UseRoomConnectionOptions extends Omit<RoomConnectionOptions, "localMedia"> {
|
|
31
|
-
localMedia?: LocalMediaRef;
|
|
32
|
-
}
|
|
33
|
-
interface RoomConnectionActions {
|
|
34
|
-
sendChatMessage(text: string): void;
|
|
35
|
-
knock(): void;
|
|
36
|
-
setDisplayName(displayName: string): void;
|
|
37
|
-
toggleCamera(enabled?: boolean): void;
|
|
38
|
-
toggleMicrophone(enabled?: boolean): void;
|
|
39
|
-
acceptWaitingParticipant(participantId: string): void;
|
|
40
|
-
rejectWaitingParticipant(participantId: string): void;
|
|
41
|
-
startScreenshare(): void;
|
|
42
|
-
stopScreenshare(): void;
|
|
43
|
-
}
|
|
44
|
-
type VideoViewComponentProps = Omit<React.ComponentProps<typeof VideoView>, "onResize">;
|
|
45
|
-
interface RoomConnectionComponents {
|
|
46
|
-
VideoView: (props: VideoViewComponentProps) => ReturnType<typeof VideoView>;
|
|
47
|
-
}
|
|
48
|
-
export type RoomConnectionRef = {
|
|
49
|
-
state: RoomConnectionState;
|
|
50
|
-
actions: RoomConnectionActions;
|
|
51
|
-
components: RoomConnectionComponents;
|
|
52
|
-
_ref: RoomConnection;
|
|
53
|
-
};
|
|
54
|
-
export declare function useRoomConnection(roomUrl: string, roomConnectionOptions?: UseRoomConnectionOptions): RoomConnectionRef;
|
|
55
|
-
export {};
|