@whereby.com/browser-sdk 2.0.0-alpha25 → 2.0.0-alpha27
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 +13 -11
- package/dist/embed/index.d.ts +5 -1
- package/dist/embed/{index.js → index.esm.js} +117 -108
- package/dist/react/index.d.ts +397 -3
- package/dist/react/index.esm.js +7850 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/{fakeWebcamFrame.js → index.esm.js} +68 -47
- package/dist/v2-alpha27.js +15 -0
- package/package.json +56 -30
- package/dist/LocalMedia.d.ts +0 -53
- package/dist/LocalMedia.js +0 -154
- package/dist/RoomConnection.d.ts +0 -174
- package/dist/RoomConnection.js +0 -608
- 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 -30
- 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 -90
- package/dist/api/deviceService/index.d.ts +0 -9
- package/dist/api/deviceService/index.js +0 -25
- 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 -159
- package/dist/api/organizationServiceCache/index.d.ts +0 -13
- package/dist/api/organizationServiceCache/index.js +0 -20
- 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 -5
- 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/index.d.ts +0 -5
- package/dist/index.js +0 -5
- package/dist/react/VideoView.d.ts +0 -14
- package/dist/react/VideoView.js +0 -37
- package/dist/react/index.js +0 -3
- package/dist/react/useLocalMedia.d.ts +0 -28
- package/dist/react/useLocalMedia.js +0 -109
- package/dist/react/useRoomConnection.d.ts +0 -47
- package/dist/react/useRoomConnection.js +0 -283
- 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/v2-alpha25.js +0 -1993
package/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# `@whereby.com/browser-sdk`
|
|
2
2
|
|
|
3
|
+
> [!WARNING]
|
|
3
4
|
> This is a pre-release of the v2 version of this library, adding support for
|
|
4
5
|
> more custom integration using React hooks and plain JavaScript classes in
|
|
5
6
|
> addition to the web component for embedding.
|
|
@@ -7,6 +8,8 @@
|
|
|
7
8
|
Whereby browser SDK is a library for seamless integration of Whereby
|
|
8
9
|
(https://whereby.com) video calls into your web application.
|
|
9
10
|
|
|
11
|
+
**For a more detailed set of instructions, including the building of a [simple telehealth app](https://docs.whereby.com/whereby-101/create-your-video-experience/in-a-web-page/using-whereby-react-hooks-build-a-telehealth-app), please see our [documentation](https://docs.whereby.com/reference/react-hooks-reference).**
|
|
12
|
+
|
|
10
13
|
## Installation
|
|
11
14
|
|
|
12
15
|
```shell
|
|
@@ -20,7 +23,7 @@ yarn add @whereby.com/browser-sdk
|
|
|
20
23
|
```
|
|
21
24
|
|
|
22
25
|
## Usage
|
|
23
|
-
|
|
26
|
+
> [!IMPORTANT]
|
|
24
27
|
> In order to make use of this functionality, you must have a Whereby account
|
|
25
28
|
> from which you can create room urls, either [manually or through our
|
|
26
29
|
> API](https://docs.whereby.com/creating-and-deleting-rooms).
|
|
@@ -36,7 +39,7 @@ their device selection up-front. This hook works seamlessly with the
|
|
|
36
39
|
`useRoomConnection` hook described below.
|
|
37
40
|
|
|
38
41
|
```js
|
|
39
|
-
import { useLocalMedia, VideoView } from "@whereby.com/browser-sdk";
|
|
42
|
+
import { useLocalMedia, VideoView } from "@whereby.com/browser-sdk/react";
|
|
40
43
|
|
|
41
44
|
function MyPreCallUX() {
|
|
42
45
|
const localMedia = useLocalMedia({ audio: false, video: true });
|
|
@@ -71,7 +74,7 @@ room, subscribe to state updates, and perform actions on the connection, like
|
|
|
71
74
|
toggling camera or microphone.
|
|
72
75
|
|
|
73
76
|
```js
|
|
74
|
-
import { useRoomConnection } from "@whereby.com/browser-sdk";
|
|
77
|
+
import { useRoomConnection } from "@whereby.com/browser-sdk/react";
|
|
75
78
|
|
|
76
79
|
function MyCallUX( { roomUrl, localStream }) {
|
|
77
80
|
const { state, actions, components } = useRoomConnection(
|
|
@@ -99,7 +102,7 @@ function MyCallUX( { roomUrl, localStream }) {
|
|
|
99
102
|
|
|
100
103
|
```
|
|
101
104
|
|
|
102
|
-
|
|
105
|
+
#### Usage with Vite development environment
|
|
103
106
|
|
|
104
107
|
There is a [known Vite issue](https://github.com/vitejs/vite/issues/1973) where modules trying to access `process.env` throw `Uncaught ReferenceError: process is not defined`.
|
|
105
108
|
This can be solved in `vite.config.js` with the following line:
|
|
@@ -123,7 +126,7 @@ client";` to the top of component, like in the following example:
|
|
|
123
126
|
```js
|
|
124
127
|
"use client";
|
|
125
128
|
|
|
126
|
-
import { VideoView, useLocalMedia } from "@whereby.com/browser-sdk";
|
|
129
|
+
import { VideoView, useLocalMedia } from "@whereby.com/browser-sdk/react";
|
|
127
130
|
|
|
128
131
|
export default function MyNextVideoExperience() {
|
|
129
132
|
const { state, actions } = useLocalMedia({ audio: false, video: true });
|
|
@@ -145,7 +148,7 @@ to learn which attributes are supported.
|
|
|
145
148
|
#### React
|
|
146
149
|
|
|
147
150
|
```js
|
|
148
|
-
import "@whereby.com/browser-sdk";
|
|
151
|
+
import "@whereby.com/browser-sdk/embed";
|
|
149
152
|
|
|
150
153
|
const MyComponent = ({ roomUrl }) => {
|
|
151
154
|
return <whereby-embed chat="off" room={roomUrl} />;
|
|
@@ -169,8 +172,7 @@ export default MyComponent;
|
|
|
169
172
|
</html>
|
|
170
173
|
```
|
|
171
174
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
frontend frameworks.
|
|
175
|
+
> [!NOTE]
|
|
176
|
+
> Although we have just higlighted two combinations of how to load and use the
|
|
177
|
+
> web component, it should be possible to use this library with all the major
|
|
178
|
+
> frontend frameworks.
|
package/dist/embed/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
declare const sdkVersion = "__SDK_VERSION__";
|
|
2
|
+
|
|
1
3
|
interface WherebyEmbedAttributes {
|
|
2
4
|
audio: string;
|
|
3
5
|
avatarUrl: string;
|
|
@@ -6,6 +8,7 @@ interface WherebyEmbedAttributes {
|
|
|
6
8
|
chat: string;
|
|
7
9
|
displayName: string;
|
|
8
10
|
emptyRoomInvitation: string;
|
|
11
|
+
externalId: string;
|
|
9
12
|
floatSelf: string;
|
|
10
13
|
help: string;
|
|
11
14
|
leaveButton: string;
|
|
@@ -28,4 +31,5 @@ declare global {
|
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
|
-
|
|
34
|
+
|
|
35
|
+
export { sdkVersion };
|
|
@@ -1,58 +1,62 @@
|
|
|
1
|
-
import { define, ref } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
window.
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
1
|
+
import { define, ref } from 'heresy';
|
|
2
|
+
|
|
3
|
+
const sdkVersion = "2.0.0-alpha27";
|
|
4
|
+
|
|
5
|
+
const boolAttrs = [
|
|
6
|
+
"audio",
|
|
7
|
+
"background",
|
|
8
|
+
"cameraaccess",
|
|
9
|
+
"chat",
|
|
10
|
+
"people",
|
|
11
|
+
"embed",
|
|
12
|
+
"emptyRoomInvitation",
|
|
13
|
+
"help",
|
|
14
|
+
"leaveButton",
|
|
15
|
+
"precallReview",
|
|
16
|
+
"screenshare",
|
|
17
|
+
"video",
|
|
18
|
+
"floatSelf",
|
|
19
|
+
"recording",
|
|
20
|
+
"logo",
|
|
21
|
+
"locking",
|
|
22
|
+
"participantCount",
|
|
23
|
+
"settingsButton",
|
|
24
|
+
"pipButton",
|
|
25
|
+
"moreButton",
|
|
26
|
+
"personality",
|
|
27
|
+
"subgridLabels",
|
|
28
|
+
"lowData",
|
|
29
|
+
"breakout",
|
|
30
|
+
];
|
|
31
|
+
define("WherebyEmbed", {
|
|
32
|
+
oninit() {
|
|
33
|
+
this.iframe = ref();
|
|
34
|
+
},
|
|
35
|
+
onconnected() {
|
|
36
|
+
window.addEventListener("message", this.onmessage.bind(this));
|
|
37
|
+
},
|
|
38
|
+
ondisconnected() {
|
|
39
|
+
window.removeEventListener("message", this.onmessage.bind(this));
|
|
40
|
+
},
|
|
41
|
+
observedAttributes: [
|
|
42
|
+
"displayName",
|
|
43
|
+
"minimal",
|
|
44
|
+
"room",
|
|
45
|
+
"subdomain",
|
|
46
|
+
"lang",
|
|
47
|
+
"metadata",
|
|
48
|
+
"groups",
|
|
49
|
+
"virtualBackgroundUrl",
|
|
50
|
+
"avatarUrl",
|
|
51
|
+
"externalId",
|
|
52
|
+
...boolAttrs,
|
|
53
|
+
].map((a) => a.toLowerCase()),
|
|
54
|
+
onattributechanged({ attributeName, oldValue }) {
|
|
55
|
+
if (["room", "subdomain"].includes(attributeName) && oldValue == null)
|
|
56
|
+
return;
|
|
57
|
+
this.render();
|
|
58
|
+
},
|
|
59
|
+
style(self) {
|
|
56
60
|
return `
|
|
57
61
|
${self} {
|
|
58
62
|
display: block;
|
|
@@ -62,62 +66,67 @@ define("WherebyEmbed", {
|
|
|
62
66
|
height: 100%;
|
|
63
67
|
width: 100%;
|
|
64
68
|
}
|
|
65
|
-
`;
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (origin !==
|
|
90
|
-
return;
|
|
91
|
-
const { type, payload: detail } = data;
|
|
92
|
-
this.dispatchEvent(new CustomEvent(type, { detail }));
|
|
93
|
-
},
|
|
94
|
-
render() {
|
|
95
|
-
const { avatarurl: avatarUrl, displayname: displayName, lang, metadata, minimal, room, groups, virtualbackgroundurl: virtualBackgroundUrl, } = this;
|
|
96
|
-
if (!room)
|
|
97
|
-
return this.html `Whereby: Missing room attribute.`;
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
69
|
+
`;
|
|
70
|
+
},
|
|
71
|
+
// Commands
|
|
72
|
+
_postCommand(command, args = []) {
|
|
73
|
+
if (this.iframe.current) {
|
|
74
|
+
this.iframe.current.contentWindow.postMessage({ command, args }, this.url.origin);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
startRecording() {
|
|
78
|
+
this._postCommand("start_recording");
|
|
79
|
+
},
|
|
80
|
+
stopRecording() {
|
|
81
|
+
this._postCommand("stop_recording");
|
|
82
|
+
},
|
|
83
|
+
toggleCamera(enabled) {
|
|
84
|
+
this._postCommand("toggle_camera", [enabled]);
|
|
85
|
+
},
|
|
86
|
+
toggleMicrophone(enabled) {
|
|
87
|
+
this._postCommand("toggle_microphone", [enabled]);
|
|
88
|
+
},
|
|
89
|
+
toggleScreenshare(enabled) {
|
|
90
|
+
this._postCommand("toggle_screenshare", [enabled]);
|
|
91
|
+
},
|
|
92
|
+
onmessage({ origin, data }) {
|
|
93
|
+
if (origin !== this.url.origin)
|
|
94
|
+
return;
|
|
95
|
+
const { type, payload: detail } = data;
|
|
96
|
+
this.dispatchEvent(new CustomEvent(type, { detail }));
|
|
97
|
+
},
|
|
98
|
+
render() {
|
|
99
|
+
const { avatarurl: avatarUrl, displayname: displayName, externalId: externalId, lang, metadata, minimal, room, groups, virtualbackgroundurl: virtualBackgroundUrl, } = this;
|
|
100
|
+
if (!room)
|
|
101
|
+
return this.html `Whereby: Missing room attribute.`;
|
|
102
|
+
// Get subdomain from room URL, or use it specified
|
|
103
|
+
const m = /https:\/\/([^.]+)(\.whereby.com|-ip-\d+-\d+-\d+-\d+.hereby.dev:4443)\/.+/.exec(room);
|
|
104
|
+
const subdomain = (m && m[1]) || this.subdomain;
|
|
105
|
+
if (!subdomain)
|
|
106
|
+
return this.html `Whereby: Missing subdomain attr.`;
|
|
107
|
+
if (!m) {
|
|
108
|
+
return this.html `could not parse URL.`;
|
|
109
|
+
}
|
|
110
|
+
const baseURL = m[2] || `.whereby.com`;
|
|
111
|
+
this.url = new URL(room, `https://${subdomain}${baseURL}`);
|
|
112
|
+
const roomUrl = new URL(room);
|
|
113
|
+
if (roomUrl.searchParams.get("roomKey")) {
|
|
114
|
+
this.url.searchParams.append("roomKey", roomUrl.searchParams.get("roomKey"));
|
|
115
|
+
}
|
|
116
|
+
Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: "2.0.0-alpha27", iframeSource: subdomain }, (displayName && { displayName })), (lang && { lang })), (metadata && { metadata })), (externalId && { externalId })), (groups && { groups })), (virtualBackgroundUrl && { virtualBackgroundUrl })), (avatarUrl && { avatarUrl })), (minimal != null && { embed: minimal })), boolAttrs.reduce(
|
|
117
|
+
// add to URL if set in any way
|
|
118
|
+
(o, v) => (this[v.toLowerCase()] != null ? Object.assign(Object.assign({}, o), { [v]: this[v.toLowerCase()] }) : o), {}))).forEach(([k, v]) => {
|
|
119
|
+
if (!this.url.searchParams.has(k) && typeof v === "string") {
|
|
120
|
+
this.url.searchParams.set(k, v);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
116
123
|
return this.html `
|
|
117
124
|
<iframe
|
|
118
125
|
ref=${this.iframe}
|
|
119
126
|
src=${this.url}
|
|
120
127
|
allow="autoplay; camera; microphone; fullscreen; speaker; display-capture" />
|
|
121
|
-
`;
|
|
122
|
-
},
|
|
128
|
+
`;
|
|
129
|
+
},
|
|
123
130
|
});
|
|
131
|
+
|
|
132
|
+
export { sdkVersion };
|