@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.
Files changed (83) hide show
  1. package/README.md +12 -24
  2. package/dist/embed/index.d.ts +4 -1
  3. package/dist/embed/{index.js → index.esm.js} +117 -110
  4. package/dist/react/index.d.ts +397 -6
  5. package/dist/react/index.esm.js +8245 -0
  6. package/dist/utils/index.d.ts +5 -2
  7. package/dist/utils/{fakeWebcamFrame.js → index.esm.js} +68 -47
  8. package/dist/v2-beta3.js +15 -0
  9. package/package.json +50 -27
  10. package/dist/LocalMedia.d.ts +0 -63
  11. package/dist/LocalMedia.js +0 -211
  12. package/dist/RoomConnection.d.ts +0 -184
  13. package/dist/RoomConnection.js +0 -627
  14. package/dist/RoomParticipant.d.ts +0 -50
  15. package/dist/RoomParticipant.js +0 -48
  16. package/dist/api/ApiClient.d.ts +0 -26
  17. package/dist/api/ApiClient.js +0 -63
  18. package/dist/api/Credentials.d.ts +0 -17
  19. package/dist/api/Credentials.js +0 -16
  20. package/dist/api/HttpClient.d.ts +0 -16
  21. package/dist/api/HttpClient.js +0 -53
  22. package/dist/api/MultipartHttpClient.d.ts +0 -10
  23. package/dist/api/MultipartHttpClient.js +0 -25
  24. package/dist/api/OrganizationApiClient.d.ts +0 -16
  25. package/dist/api/OrganizationApiClient.js +0 -29
  26. package/dist/api/Response.d.ts +0 -29
  27. package/dist/api/Response.js +0 -9
  28. package/dist/api/credentialsService/index.d.ts +0 -27
  29. package/dist/api/credentialsService/index.js +0 -89
  30. package/dist/api/deviceService/index.d.ts +0 -9
  31. package/dist/api/deviceService/index.js +0 -23
  32. package/dist/api/extractUtils.d.ts +0 -16
  33. package/dist/api/extractUtils.js +0 -51
  34. package/dist/api/index.d.ts +0 -7
  35. package/dist/api/index.js +0 -7
  36. package/dist/api/localStorageWrapper/index.d.ts +0 -2
  37. package/dist/api/localStorageWrapper/index.js +0 -15
  38. package/dist/api/models/Account.d.ts +0 -20
  39. package/dist/api/models/Account.js +0 -24
  40. package/dist/api/models/Meeting.d.ts +0 -12
  41. package/dist/api/models/Meeting.js +0 -29
  42. package/dist/api/models/Organization.d.ts +0 -102
  43. package/dist/api/models/Organization.js +0 -81
  44. package/dist/api/models/Room.d.ts +0 -4
  45. package/dist/api/models/Room.js +0 -38
  46. package/dist/api/models/account/EmbeddedFreeTierStatus.d.ts +0 -13
  47. package/dist/api/models/account/EmbeddedFreeTierStatus.js +0 -17
  48. package/dist/api/modules/AbstractStore.d.ts +0 -5
  49. package/dist/api/modules/AbstractStore.js +0 -1
  50. package/dist/api/modules/ChromeStorageStore.d.ts +0 -10
  51. package/dist/api/modules/ChromeStorageStore.js +0 -21
  52. package/dist/api/modules/LocalStorageStore.d.ts +0 -9
  53. package/dist/api/modules/LocalStorageStore.js +0 -35
  54. package/dist/api/modules/tests/__mocks__/storage.d.ts +0 -10
  55. package/dist/api/modules/tests/__mocks__/storage.js +0 -19
  56. package/dist/api/organizationService/index.d.ts +0 -46
  57. package/dist/api/organizationService/index.js +0 -158
  58. package/dist/api/organizationServiceCache/index.d.ts +0 -13
  59. package/dist/api/organizationServiceCache/index.js +0 -16
  60. package/dist/api/parameterAssertUtils.d.ts +0 -13
  61. package/dist/api/parameterAssertUtils.js +0 -64
  62. package/dist/api/roomService/index.d.ts +0 -54
  63. package/dist/api/roomService/index.js +0 -160
  64. package/dist/api/test/helpers.d.ts +0 -7
  65. package/dist/api/test/helpers.js +0 -32
  66. package/dist/api/types.d.ts +0 -5
  67. package/dist/api/types.js +0 -1
  68. package/dist/react/VideoView.d.ts +0 -15
  69. package/dist/react/VideoView.js +0 -37
  70. package/dist/react/index.js +0 -4
  71. package/dist/react/useLocalMedia.d.ts +0 -28
  72. package/dist/react/useLocalMedia.js +0 -109
  73. package/dist/react/useRoomConnection.d.ts +0 -55
  74. package/dist/react/useRoomConnection.js +0 -315
  75. package/dist/utils/debounce.d.ts +0 -9
  76. package/dist/utils/debounce.js +0 -20
  77. package/dist/utils/fakeAudioStream.d.ts +0 -1
  78. package/dist/utils/fakeAudioStream.js +0 -18
  79. package/dist/utils/fakeWebcamFrame.d.ts +0 -1
  80. package/dist/utils/index.js +0 -2
  81. package/dist/v2-beta1.js +0 -2001
  82. package/dist/version.d.ts +0 -1
  83. 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
- **Note**
173
-
174
- Although we have just higlighted two combinations of how to load and use the
175
- web component, it should be possible to use this library with all the major
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.
@@ -1,4 +1,5 @@
1
- export { sdkVersion } from "../version";
1
+ declare const sdkVersion = "__SDK_VERSION__";
2
+
2
3
  interface WherebyEmbedAttributes {
3
4
  audio: string;
4
5
  avatarUrl: string;
@@ -30,3 +31,5 @@ declare global {
30
31
  }
31
32
  }
32
33
  }
34
+
35
+ export { sdkVersion };
@@ -1,60 +1,62 @@
1
- import { define, ref } from "heresy";
2
- export { sdkVersion } from "../version";
3
- const boolAttrs = [
4
- "audio",
5
- "background",
6
- "cameraaccess",
7
- "chat",
8
- "people",
9
- "embed",
10
- "emptyRoomInvitation",
11
- "help",
12
- "leaveButton",
13
- "precallReview",
14
- "screenshare",
15
- "video",
16
- "floatSelf",
17
- "recording",
18
- "logo",
19
- "locking",
20
- "participantCount",
21
- "settingsButton",
22
- "pipButton",
23
- "moreButton",
24
- "personality",
25
- "subgridLabels",
26
- "lowData",
27
- "breakout",
28
- ];
29
- define("WherebyEmbed", {
30
- oninit() {
31
- this.iframe = ref();
32
- },
33
- onconnected() {
34
- window.addEventListener("message", this.onmessage);
35
- },
36
- ondisconnected() {
37
- window.removeEventListener("message", this.onmessage);
38
- },
39
- observedAttributes: [
40
- "displayName",
41
- "minimal",
42
- "room",
43
- "subdomain",
44
- "lang",
45
- "metadata",
46
- "groups",
47
- "virtualBackgroundUrl",
48
- "avatarUrl",
49
- "externalId",
50
- ...boolAttrs,
51
- ].map((a) => a.toLowerCase()),
52
- onattributechanged({ attributeName, oldValue }) {
53
- if (["room", "subdomain"].includes(attributeName) && oldValue == null)
54
- return;
55
- this.render();
56
- },
57
- style(self) {
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
- _postCommand(command, args = []) {
70
- if (this.iframe.current) {
71
- this.iframe.current.contentWindow.postMessage({ command, args }, this.url.origin);
72
- }
73
- },
74
- startRecording() {
75
- this._postCommand("start_recording");
76
- },
77
- stopRecording() {
78
- this._postCommand("stop_recording");
79
- },
80
- toggleCamera(enabled) {
81
- this._postCommand("toggle_camera", [enabled]);
82
- },
83
- toggleMicrophone(enabled) {
84
- this._postCommand("toggle_microphone", [enabled]);
85
- },
86
- toggleScreenshare(enabled) {
87
- this._postCommand("toggle_screenshare", [enabled]);
88
- },
89
- onmessage({ origin, data }) {
90
- var _a;
91
- if (origin !== ((_a = this.url) === null || _a === void 0 ? void 0 : _a.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
- const m = /https:\/\/([^.]+)(\.whereby.com|-ip-\d+-\d+-\d+-\d+.hereby.dev:4443)\/.+/.exec(room);
101
- const subdomain = (m && m[1]) || this.subdomain;
102
- if (!subdomain)
103
- return this.html `Whereby: Missing subdomain attr.`;
104
- if (!m) {
105
- return this.html `could not parse URL.`;
106
- }
107
- const baseURL = m[2] || `.whereby.com`;
108
- this.url = new URL(room, `https://${subdomain}${baseURL}`);
109
- const roomUrl = new URL(room);
110
- if (roomUrl.searchParams.get("roomKey")) {
111
- this.url.searchParams.append("roomKey", roomUrl.searchParams.get("roomKey"));
112
- }
113
- Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: "__SDK_VERSION__", iframeSource: subdomain }, (displayName && { displayName })), (lang && { lang })), (metadata && { metadata })), (externalId && { externalId })), (groups && { groups })), (virtualBackgroundUrl && { virtualBackgroundUrl })), (avatarUrl && { avatarUrl })), (minimal != null && { embed: minimal })), boolAttrs.reduce((o, v) => (this[v.toLowerCase()] != null ? Object.assign(Object.assign({}, o), { [v]: this[v.toLowerCase()] }) : o), {}))).forEach(([k, v]) => {
114
- if (!this.url.searchParams.has(k) && typeof v === "string") {
115
- this.url.searchParams.set(k, v);
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 };