@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.
Files changed (82) hide show
  1. package/README.md +13 -11
  2. package/dist/embed/index.d.ts +5 -1
  3. package/dist/embed/{index.js → index.esm.js} +117 -108
  4. package/dist/react/index.d.ts +397 -3
  5. package/dist/react/index.esm.js +7850 -0
  6. package/dist/utils/index.d.ts +5 -0
  7. package/dist/utils/{fakeWebcamFrame.js → index.esm.js} +68 -47
  8. package/dist/v2-alpha27.js +15 -0
  9. package/package.json +56 -30
  10. package/dist/LocalMedia.d.ts +0 -53
  11. package/dist/LocalMedia.js +0 -154
  12. package/dist/RoomConnection.d.ts +0 -174
  13. package/dist/RoomConnection.js +0 -608
  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 -30
  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 -90
  30. package/dist/api/deviceService/index.d.ts +0 -9
  31. package/dist/api/deviceService/index.js +0 -25
  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 -159
  58. package/dist/api/organizationServiceCache/index.d.ts +0 -13
  59. package/dist/api/organizationServiceCache/index.js +0 -20
  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 -5
  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/index.d.ts +0 -5
  69. package/dist/index.js +0 -5
  70. package/dist/react/VideoView.d.ts +0 -14
  71. package/dist/react/VideoView.js +0 -37
  72. package/dist/react/index.js +0 -3
  73. package/dist/react/useLocalMedia.d.ts +0 -28
  74. package/dist/react/useLocalMedia.js +0 -109
  75. package/dist/react/useRoomConnection.d.ts +0 -47
  76. package/dist/react/useRoomConnection.js +0 -283
  77. package/dist/utils/debounce.d.ts +0 -9
  78. package/dist/utils/debounce.js +0 -20
  79. package/dist/utils/fakeAudioStream.d.ts +0 -1
  80. package/dist/utils/fakeAudioStream.js +0 -18
  81. package/dist/utils/fakeWebcamFrame.d.ts +0 -1
  82. 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
- ### Usage with Vite development environment
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
- **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.
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.
@@ -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
- export {};
34
+
35
+ export { sdkVersion };
@@ -1,58 +1,62 @@
1
- import { define, ref } from "heresy";
2
- const boolAttrs = [
3
- "audio",
4
- "background",
5
- "cameraaccess",
6
- "chat",
7
- "people",
8
- "embed",
9
- "emptyRoomInvitation",
10
- "help",
11
- "leaveButton",
12
- "precallReview",
13
- "screenshare",
14
- "video",
15
- "floatSelf",
16
- "recording",
17
- "logo",
18
- "locking",
19
- "participantCount",
20
- "settingsButton",
21
- "pipButton",
22
- "moreButton",
23
- "personality",
24
- "subgridLabels",
25
- "lowData",
26
- "breakout",
27
- ];
28
- define("WherebyEmbed", {
29
- oninit() {
30
- this.iframe = ref();
31
- },
32
- onconnected() {
33
- window.addEventListener("message", this.onmessage);
34
- },
35
- ondisconnected() {
36
- window.removeEventListener("message", this.onmessage);
37
- },
38
- observedAttributes: [
39
- "displayName",
40
- "minimal",
41
- "room",
42
- "subdomain",
43
- "lang",
44
- "metadata",
45
- "groups",
46
- "virtualBackgroundUrl",
47
- "avatarUrl",
48
- ...boolAttrs,
49
- ].map((a) => a.toLowerCase()),
50
- onattributechanged({ attributeName, oldValue }) {
51
- if (["room", "subdomain"].includes(attributeName) && oldValue == null)
52
- return;
53
- this.render();
54
- },
55
- style(self) {
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
- _postCommand(command, args = []) {
68
- if (this.iframe.current) {
69
- this.iframe.current.contentWindow.postMessage({ command, args }, this.url.origin);
70
- }
71
- },
72
- startRecording() {
73
- this._postCommand("start_recording");
74
- },
75
- stopRecording() {
76
- this._postCommand("stop_recording");
77
- },
78
- toggleCamera(enabled) {
79
- this._postCommand("toggle_camera", [enabled]);
80
- },
81
- toggleMicrophone(enabled) {
82
- this._postCommand("toggle_microphone", [enabled]);
83
- },
84
- toggleScreenshare(enabled) {
85
- this._postCommand("toggle_screenshare", [enabled]);
86
- },
87
- onmessage({ origin, data }) {
88
- var _a;
89
- if (origin !== ((_a = this.url) === null || _a === void 0 ? void 0 : _a.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
- const m = /https:\/\/([^.]+)(\.whereby.com|-ip-\d+-\d+-\d+-\d+.hereby.dev:4443)\/.+/.exec(room);
99
- const subdomain = (m && m[1]) || this.subdomain;
100
- if (!subdomain)
101
- return this.html `Whereby: Missing subdomain attr.`;
102
- if (!m) {
103
- return this.html `could not parse URL.`;
104
- }
105
- const baseURL = m[2] || `.whereby.com`;
106
- this.url = new URL(room, `https://${subdomain}${baseURL}`);
107
- const roomUrl = new URL(room);
108
- if (roomUrl.searchParams.get("roomKey")) {
109
- this.url.searchParams.append("roomKey", roomUrl.searchParams.get("roomKey"));
110
- }
111
- Object.entries(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 })), (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]) => {
112
- if (!this.url.searchParams.has(k) && typeof v === "string") {
113
- this.url.searchParams.set(k, v);
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 };