@whereby.com/browser-sdk 2.0.0-beta2 → 2.0.0-beta4

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 (84) hide show
  1. package/README.md +1 -19
  2. package/dist/embed/index.d.ts +21 -4
  3. package/dist/embed/index.esm.js +156 -0
  4. package/dist/react/index.d.ts +829 -6
  5. package/dist/react/index.esm.js +8806 -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-beta4.js +16 -0
  9. package/package.json +26 -12
  10. package/dist/LocalMedia.d.ts +0 -70
  11. package/dist/LocalMedia.js +0 -208
  12. package/dist/RoomConnection.d.ts +0 -190
  13. package/dist/RoomConnection.js +0 -646
  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 -61
  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 -52
  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 -28
  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/embed/index.js +0 -124
  69. package/dist/react/VideoView.d.ts +0 -15
  70. package/dist/react/VideoView.js +0 -37
  71. package/dist/react/index.js +0 -4
  72. package/dist/react/useLocalMedia.d.ts +0 -29
  73. package/dist/react/useLocalMedia.js +0 -109
  74. package/dist/react/useRoomConnection.d.ts +0 -57
  75. package/dist/react/useRoomConnection.js +0 -340
  76. package/dist/utils/debounce.d.ts +0 -9
  77. package/dist/utils/debounce.js +0 -18
  78. package/dist/utils/fakeAudioStream.d.ts +0 -1
  79. package/dist/utils/fakeAudioStream.js +0 -18
  80. package/dist/utils/fakeWebcamFrame.d.ts +0 -1
  81. package/dist/utils/index.js +0 -2
  82. package/dist/v2-beta2.js +0 -2000
  83. package/dist/version.d.ts +0 -1
  84. package/dist/version.js +0 -1
package/README.md CHANGED
@@ -1,10 +1,5 @@
1
1
  # `@whereby.com/browser-sdk`
2
2
 
3
- > [!WARNING]
4
- > This is a pre-release of the v2 version of this library, adding support for
5
- > more custom integration using React hooks and plain JavaScript classes in
6
- > addition to the web component for embedding.
7
-
8
3
  Whereby browser SDK is a library for seamless integration of Whereby
9
4
  (https://whereby.com) video calls into your web application.
10
5
 
@@ -23,6 +18,7 @@ yarn add @whereby.com/browser-sdk
23
18
  ```
24
19
 
25
20
  ## Usage
21
+
26
22
  > [!IMPORTANT]
27
23
  > In order to make use of this functionality, you must have a Whereby account
28
24
  > from which you can create room urls, either [manually or through our
@@ -102,20 +98,6 @@ function MyCallUX( { roomUrl, localStream }) {
102
98
 
103
99
  ```
104
100
 
105
- #### Usage with Vite development environment
106
-
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`.
108
- This can be solved in `vite.config.js` with the following line:
109
-
110
- ``` javascript
111
- export default defineConfig({
112
- ...rest,
113
- define: {
114
- 'process.env': {}
115
- },
116
- });
117
- ```
118
-
119
101
  #### Usage with Next.js
120
102
 
121
103
  If you are integrating these React hooks with Next.js, you need to ensure your
@@ -1,27 +1,39 @@
1
- export { sdkVersion } from "../version";
2
1
  interface WherebyEmbedAttributes {
3
2
  audio: string;
4
3
  avatarUrl: string;
5
4
  background: string;
5
+ breakout: string;
6
6
  cameraAccess: string;
7
7
  chat: string;
8
8
  displayName: string;
9
9
  emptyRoomInvitation: string;
10
10
  externalId: string;
11
11
  floatSelf: string;
12
+ groups: string;
12
13
  help: string;
14
+ lang: string;
13
15
  leaveButton: string;
16
+ locking: string;
14
17
  logo: string;
18
+ lowData: string;
19
+ metadata: string;
20
+ minimal: string;
21
+ moreButton: string;
22
+ participantCount: string;
15
23
  people: string;
24
+ pipButton: string;
16
25
  precallReview: string;
17
26
  recording: string;
18
- screenshare: string;
19
- video: string;
20
- virtualBackgroundUrl: string;
21
27
  room: string;
28
+ settingsButton: string;
29
+ screenshare: string;
22
30
  style: {
23
31
  [key: string]: string;
24
32
  };
33
+ subgridLabels: string;
34
+ title: string;
35
+ video: string;
36
+ virtualBackgroundUrl: string;
25
37
  }
26
38
  declare global {
27
39
  namespace JSX {
@@ -30,3 +42,8 @@ declare global {
30
42
  }
31
43
  }
32
44
  }
45
+ declare const _default: {
46
+ sdkVersion: string;
47
+ };
48
+
49
+ export { _default as default };
@@ -0,0 +1,156 @@
1
+ import { define, ref } from 'heresy';
2
+
3
+ function parseRoomUrlAndSubdomain(roomAttribute, subdomainAttribute) {
4
+ if (!roomAttribute) {
5
+ throw new Error("Missing room attribute");
6
+ }
7
+ // Get subdomain from room URL, or use it specified
8
+ const m = /https:\/\/([^.]+)(\.whereby\.com|-ip-\d+-\d+-\d+-\d+.hereby.dev:4443)\/.+/.exec(roomAttribute);
9
+ const subdomain = (m && m[1]) || subdomainAttribute;
10
+ if (!subdomain) {
11
+ throw new Error("Missing subdomain attribute");
12
+ }
13
+ if (!m) {
14
+ throw new Error("Could not parse room URL");
15
+ }
16
+ const roomUrl = new URL(roomAttribute);
17
+ return {
18
+ subdomain,
19
+ roomUrl,
20
+ };
21
+ }
22
+
23
+ const sdkVersion = "2.0.0-beta4";
24
+
25
+ const boolAttrs = [
26
+ "audio",
27
+ "background",
28
+ "cameraAccess",
29
+ "chat",
30
+ "people",
31
+ "embed",
32
+ "emptyRoomInvitation",
33
+ "help",
34
+ "leaveButton",
35
+ "precallReview",
36
+ "screenshare",
37
+ "video",
38
+ "floatSelf",
39
+ "recording",
40
+ "logo",
41
+ "locking",
42
+ "participantCount",
43
+ "settingsButton",
44
+ "pipButton",
45
+ "moreButton",
46
+ "personality",
47
+ "subgridLabels",
48
+ "lowData",
49
+ "breakout",
50
+ ];
51
+ define("WherebyEmbed", {
52
+ oninit() {
53
+ this.iframe = ref();
54
+ },
55
+ onconnected() {
56
+ window.addEventListener("message", this.onmessage.bind(this));
57
+ },
58
+ ondisconnected() {
59
+ window.removeEventListener("message", this.onmessage.bind(this));
60
+ },
61
+ observedAttributes: [
62
+ "displayName",
63
+ "minimal",
64
+ "room",
65
+ "subdomain",
66
+ "lang",
67
+ "metadata",
68
+ "groups",
69
+ "virtualBackgroundUrl",
70
+ "avatarUrl",
71
+ "externalId",
72
+ "title",
73
+ ...boolAttrs,
74
+ ].map((a) => a.toLowerCase()),
75
+ onattributechanged({ attributeName, oldValue }) {
76
+ if (["room", "subdomain"].includes(attributeName) && oldValue == null)
77
+ return;
78
+ this.render();
79
+ },
80
+ style(self) {
81
+ return `
82
+ ${self} {
83
+ display: block;
84
+ }
85
+ ${self} iframe {
86
+ border: none;
87
+ height: 100%;
88
+ width: 100%;
89
+ }
90
+ `;
91
+ },
92
+ // Commands
93
+ _postCommand(command, args = []) {
94
+ if (this.iframe.current) {
95
+ this.iframe.current.contentWindow.postMessage({ command, args }, this.roomUrl.origin);
96
+ }
97
+ },
98
+ startRecording() {
99
+ this._postCommand("start_recording");
100
+ },
101
+ stopRecording() {
102
+ this._postCommand("stop_recording");
103
+ },
104
+ startStreaming() {
105
+ this._postCommand("start_streaming");
106
+ },
107
+ stopStreaming() {
108
+ this._postCommand("stop_streaming");
109
+ },
110
+ toggleCamera(enabled) {
111
+ this._postCommand("toggle_camera", [enabled]);
112
+ },
113
+ toggleMicrophone(enabled) {
114
+ this._postCommand("toggle_microphone", [enabled]);
115
+ },
116
+ toggleScreenshare(enabled) {
117
+ this._postCommand("toggle_screenshare", [enabled]);
118
+ },
119
+ toggleChat(enabled) {
120
+ this._postCommand("toggle_chat", [enabled]);
121
+ },
122
+ onmessage({ origin, data }) {
123
+ if (!this.roomUrl || origin !== this.roomUrl.origin)
124
+ return;
125
+ const { type, payload: detail } = data;
126
+ this.dispatchEvent(new CustomEvent(type, { detail }));
127
+ },
128
+ render() {
129
+ const { avatarurl: avatarUrl, displayname: displayName, lang, metadata, externalid: externalId, minimal, room, groups, virtualbackgroundurl: virtualBackgroundUrl, title, } = this;
130
+ let roomUrl, subdomain;
131
+ try {
132
+ ({ roomUrl, subdomain } = parseRoomUrlAndSubdomain(room, this.subdomain));
133
+ }
134
+ catch (error) {
135
+ return this.html `Whereby: ${error instanceof Error ? error.message : "unknown error"}`;
136
+ }
137
+ this.roomUrl = roomUrl;
138
+ Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: sdkVersion, iframeSource: subdomain }, (displayName && { displayName })), (lang && { lang: lang })), (metadata && { metadata: metadata })), (externalId && { externalId })), (groups && { groups: groups })), (virtualBackgroundUrl && { virtualBackgroundUrl: virtualBackgroundUrl })), (avatarUrl && { avatarUrl: avatarUrl })), (minimal != null && { embed: minimal })), boolAttrs.reduce(
139
+ // add to URL if set in any way
140
+ (o, v) => (this[v.toLowerCase()] != null ? Object.assign(Object.assign({}, o), { [v]: this[v.toLowerCase()] }) : o), {}))).forEach(([k, v]) => {
141
+ if (!this.roomUrl.searchParams.has(k)) {
142
+ this.roomUrl.searchParams.set(k, v);
143
+ }
144
+ });
145
+ this.html `
146
+ <iframe
147
+ title=${title || "Video calling component"}
148
+ ref=${this.iframe}
149
+ src=${this.roomUrl}
150
+ allow="autoplay; camera; microphone; fullscreen; speaker; display-capture" />
151
+ `;
152
+ },
153
+ });
154
+ var index = { sdkVersion: sdkVersion };
155
+
156
+ export { index as default };