@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
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,20 +102,6 @@ function MyCallUX( { roomUrl, localStream }) {
|
|
|
99
102
|
|
|
100
103
|
```
|
|
101
104
|
|
|
102
|
-
### Usage with Vite development environment
|
|
103
|
-
|
|
104
|
-
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
|
-
This can be solved in `vite.config.js` with the following line:
|
|
106
|
-
|
|
107
|
-
``` javascript
|
|
108
|
-
export default defineConfig({
|
|
109
|
-
...rest,
|
|
110
|
-
define: {
|
|
111
|
-
'process.env': {}
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
```
|
|
115
|
-
|
|
116
105
|
#### Usage with Next.js
|
|
117
106
|
|
|
118
107
|
If you are integrating these React hooks with Next.js, you need to ensure your
|
|
@@ -123,7 +112,7 @@ client";` to the top of component, like in the following example:
|
|
|
123
112
|
```js
|
|
124
113
|
"use client";
|
|
125
114
|
|
|
126
|
-
import { VideoView, useLocalMedia } from "@whereby.com/browser-sdk";
|
|
115
|
+
import { VideoView, useLocalMedia } from "@whereby.com/browser-sdk/react";
|
|
127
116
|
|
|
128
117
|
export default function MyNextVideoExperience() {
|
|
129
118
|
const { state, actions } = useLocalMedia({ audio: false, video: true });
|
|
@@ -145,7 +134,7 @@ to learn which attributes are supported.
|
|
|
145
134
|
#### React
|
|
146
135
|
|
|
147
136
|
```js
|
|
148
|
-
import "@whereby.com/browser-sdk";
|
|
137
|
+
import "@whereby.com/browser-sdk/embed";
|
|
149
138
|
|
|
150
139
|
const MyComponent = ({ roomUrl }) => {
|
|
151
140
|
return <whereby-embed chat="off" room={roomUrl} />;
|
|
@@ -169,8 +158,7 @@ export default MyComponent;
|
|
|
169
158
|
</html>
|
|
170
159
|
```
|
|
171
160
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
frontend frameworks.
|
|
161
|
+
> [!NOTE]
|
|
162
|
+
> Although we have just higlighted two combinations of how to load and use the
|
|
163
|
+
> web component, it should be possible to use this library with all the major
|
|
164
|
+
> frontend frameworks.
|
package/dist/embed/index.d.ts
CHANGED
|
@@ -1,60 +1,62 @@
|
|
|
1
|
-
import { define, ref } from
|
|
2
|
-
|
|
3
|
-
const
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
1
|
+
import { define, ref } from 'heresy';
|
|
2
|
+
|
|
3
|
+
const sdkVersion = "2.0.0-beta3";
|
|
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) {
|
|
58
60
|
return `
|
|
59
61
|
${self} {
|
|
60
62
|
display: block;
|
|
@@ -64,62 +66,67 @@ define("WherebyEmbed", {
|
|
|
64
66
|
height: 100%;
|
|
65
67
|
width: 100%;
|
|
66
68
|
}
|
|
67
|
-
`;
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (origin !==
|
|
92
|
-
return;
|
|
93
|
-
const { type, payload: detail } = data;
|
|
94
|
-
this.dispatchEvent(new CustomEvent(type, { detail }));
|
|
95
|
-
},
|
|
96
|
-
render() {
|
|
97
|
-
const { avatarurl: avatarUrl, displayname: displayName, externalId: externalId, lang, metadata, minimal, room, groups, virtualbackgroundurl: virtualBackgroundUrl, } = this;
|
|
98
|
-
if (!room)
|
|
99
|
-
return this.html `Whereby: Missing room attribute.`;
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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-beta3", 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
|
+
});
|
|
118
123
|
return this.html `
|
|
119
124
|
<iframe
|
|
120
125
|
ref=${this.iframe}
|
|
121
126
|
src=${this.url}
|
|
122
127
|
allow="autoplay; camera; microphone; fullscreen; speaker; display-capture" />
|
|
123
|
-
`;
|
|
124
|
-
},
|
|
128
|
+
`;
|
|
129
|
+
},
|
|
125
130
|
});
|
|
131
|
+
|
|
132
|
+
export { sdkVersion };
|