@whereby.com/browser-sdk 2.0.0-alpha21 → 2.0.0-alpha23

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/dist/lib.cjs CHANGED
@@ -136,7 +136,7 @@ heresy.define("WherebyEmbed", {
136
136
  if (roomUrl.searchParams.get("roomKey")) {
137
137
  this.url.searchParams.append("roomKey", roomUrl.searchParams.get("roomKey"));
138
138
  }
139
- Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: "2.0.0-alpha21", iframeSource: subdomain }, (displayName && { displayName })), (lang && { lang })), (metadata && { metadata })), (groups && { groups })), (virtualBackgroundUrl && { virtualBackgroundUrl })), (avatarUrl && { avatarUrl })), (minimal != null && { embed: minimal })), boolAttrs.reduce(
139
+ Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: "2.0.0-alpha23", iframeSource: subdomain }, (displayName && { displayName })), (lang && { lang })), (metadata && { metadata })), (groups && { groups })), (virtualBackgroundUrl && { virtualBackgroundUrl })), (avatarUrl && { avatarUrl })), (minimal != null && { embed: minimal })), boolAttrs.reduce(
140
140
  // add to URL if set in any way
141
141
  (o, v) => (this[v.toLowerCase()] != null ? Object.assign(Object.assign({}, o), { [v]: this[v.toLowerCase()] }) : o), {}))).forEach(([k, v]) => {
142
142
  if (!this.url.searchParams.has(k) && typeof v === "string") {
@@ -5326,6 +5326,25 @@ function createSocket() {
5326
5326
  };
5327
5327
  return new ServerSocket(SOCKET_HOST, socketConf);
5328
5328
  }
5329
+ function handleStreamAdded(remoteParticipants, { clientId, stream, streamId, streamType }) {
5330
+ if (!streamId) {
5331
+ streamId = stream.id;
5332
+ }
5333
+ const remoteParticipant = remoteParticipants.find((p) => p.id === clientId);
5334
+ if (!remoteParticipant) {
5335
+ return;
5336
+ }
5337
+ const remoteParticipantStream = remoteParticipant.streams.find((s) => s.id === streamId) || remoteParticipant.streams[0];
5338
+ if ((remoteParticipant.stream && remoteParticipant.stream.id === streamId) ||
5339
+ (!remoteParticipant.stream && streamType === "webcam") ||
5340
+ (!remoteParticipant.stream && !streamType && remoteParticipant.streams.indexOf(remoteParticipantStream) < 1)) {
5341
+ return new CustomEvent("participant_stream_added", { detail: { participantId: clientId, stream, streamId } });
5342
+ }
5343
+ // screenshare
5344
+ return new CustomEvent("screenshare_started", {
5345
+ detail: { participantId: clientId, stream, id: streamId, isLocal: false },
5346
+ });
5347
+ }
5329
5348
  const noop = () => {
5330
5349
  return;
5331
5350
  };
@@ -5722,26 +5741,11 @@ class RoomConnection extends TypedEventTarget {
5722
5741
  });
5723
5742
  });
5724
5743
  }
5725
- _handleStreamAdded({ clientId, stream, streamId, streamType }) {
5726
- const remoteParticipant = this.remoteParticipants.find((p) => p.id === clientId);
5727
- if (!remoteParticipant) {
5728
- this.logger.log("WARN: Could not find participant for incoming stream");
5729
- return;
5730
- }
5731
- const remoteParticipantStream = remoteParticipant.streams.find((s) => s.id === streamId);
5732
- if ((remoteParticipant.stream && remoteParticipant.stream.id === streamId) ||
5733
- (!remoteParticipant.stream && streamType === "webcam") ||
5734
- (!remoteParticipant.stream &&
5735
- !streamType &&
5736
- remoteParticipantStream &&
5737
- remoteParticipant.streams.indexOf(remoteParticipantStream) < 1)) {
5738
- this.dispatchEvent(new CustomEvent("participant_stream_added", { detail: { participantId: clientId, stream, streamId } }));
5739
- return;
5744
+ _handleStreamAdded(args) {
5745
+ const streamAddedEvent = handleStreamAdded(this.remoteParticipants, args);
5746
+ if (streamAddedEvent) {
5747
+ this.dispatchEvent(streamAddedEvent);
5740
5748
  }
5741
- // screenshare
5742
- this.dispatchEvent(new CustomEvent("screenshare_started", {
5743
- detail: { participantId: clientId, stream, id: streamId, isLocal: false },
5744
- }));
5745
5749
  }
5746
5750
  _joinRoom() {
5747
5751
  this.signalSocket.emit("join_room", {
@@ -6115,6 +6119,13 @@ function useRoomConnection(roomUrl, roomConnectionOptions) {
6115
6119
  payload: { participantId, displayName },
6116
6120
  });
6117
6121
  }),
6122
+ createEventListener("waiting_participant_left", (e) => {
6123
+ const { participantId } = e.detail;
6124
+ dispatch({
6125
+ type: "WAITING_PARTICIPANT_LEFT",
6126
+ payload: { participantId },
6127
+ });
6128
+ }),
6118
6129
  ], []);
6119
6130
  React.useEffect(() => {
6120
6131
  eventListeners.forEach(({ eventName, listener }) => {
@@ -6181,7 +6192,7 @@ function useRoomConnection(roomUrl, roomConnectionOptions) {
6181
6192
  };
6182
6193
  }
6183
6194
 
6184
- const sdkVersion = "2.0.0-alpha21";
6195
+ const sdkVersion = "2.0.0-alpha23";
6185
6196
 
6186
6197
  exports.VideoView = VideoView;
6187
6198
  exports.sdkVersion = sdkVersion;
package/dist/lib.esm.js CHANGED
@@ -121,7 +121,7 @@ define("WherebyEmbed", {
121
121
  if (roomUrl.searchParams.get("roomKey")) {
122
122
  this.url.searchParams.append("roomKey", roomUrl.searchParams.get("roomKey"));
123
123
  }
124
- Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: "2.0.0-alpha21", iframeSource: subdomain }, (displayName && { displayName })), (lang && { lang })), (metadata && { metadata })), (groups && { groups })), (virtualBackgroundUrl && { virtualBackgroundUrl })), (avatarUrl && { avatarUrl })), (minimal != null && { embed: minimal })), boolAttrs.reduce(
124
+ Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: "2.0.0-alpha23", iframeSource: subdomain }, (displayName && { displayName })), (lang && { lang })), (metadata && { metadata })), (groups && { groups })), (virtualBackgroundUrl && { virtualBackgroundUrl })), (avatarUrl && { avatarUrl })), (minimal != null && { embed: minimal })), boolAttrs.reduce(
125
125
  // add to URL if set in any way
126
126
  (o, v) => (this[v.toLowerCase()] != null ? Object.assign(Object.assign({}, o), { [v]: this[v.toLowerCase()] }) : o), {}))).forEach(([k, v]) => {
127
127
  if (!this.url.searchParams.has(k) && typeof v === "string") {
@@ -5311,6 +5311,25 @@ function createSocket() {
5311
5311
  };
5312
5312
  return new ServerSocket(SOCKET_HOST, socketConf);
5313
5313
  }
5314
+ function handleStreamAdded(remoteParticipants, { clientId, stream, streamId, streamType }) {
5315
+ if (!streamId) {
5316
+ streamId = stream.id;
5317
+ }
5318
+ const remoteParticipant = remoteParticipants.find((p) => p.id === clientId);
5319
+ if (!remoteParticipant) {
5320
+ return;
5321
+ }
5322
+ const remoteParticipantStream = remoteParticipant.streams.find((s) => s.id === streamId) || remoteParticipant.streams[0];
5323
+ if ((remoteParticipant.stream && remoteParticipant.stream.id === streamId) ||
5324
+ (!remoteParticipant.stream && streamType === "webcam") ||
5325
+ (!remoteParticipant.stream && !streamType && remoteParticipant.streams.indexOf(remoteParticipantStream) < 1)) {
5326
+ return new CustomEvent("participant_stream_added", { detail: { participantId: clientId, stream, streamId } });
5327
+ }
5328
+ // screenshare
5329
+ return new CustomEvent("screenshare_started", {
5330
+ detail: { participantId: clientId, stream, id: streamId, isLocal: false },
5331
+ });
5332
+ }
5314
5333
  const noop = () => {
5315
5334
  return;
5316
5335
  };
@@ -5707,26 +5726,11 @@ class RoomConnection extends TypedEventTarget {
5707
5726
  });
5708
5727
  });
5709
5728
  }
5710
- _handleStreamAdded({ clientId, stream, streamId, streamType }) {
5711
- const remoteParticipant = this.remoteParticipants.find((p) => p.id === clientId);
5712
- if (!remoteParticipant) {
5713
- this.logger.log("WARN: Could not find participant for incoming stream");
5714
- return;
5715
- }
5716
- const remoteParticipantStream = remoteParticipant.streams.find((s) => s.id === streamId);
5717
- if ((remoteParticipant.stream && remoteParticipant.stream.id === streamId) ||
5718
- (!remoteParticipant.stream && streamType === "webcam") ||
5719
- (!remoteParticipant.stream &&
5720
- !streamType &&
5721
- remoteParticipantStream &&
5722
- remoteParticipant.streams.indexOf(remoteParticipantStream) < 1)) {
5723
- this.dispatchEvent(new CustomEvent("participant_stream_added", { detail: { participantId: clientId, stream, streamId } }));
5724
- return;
5729
+ _handleStreamAdded(args) {
5730
+ const streamAddedEvent = handleStreamAdded(this.remoteParticipants, args);
5731
+ if (streamAddedEvent) {
5732
+ this.dispatchEvent(streamAddedEvent);
5725
5733
  }
5726
- // screenshare
5727
- this.dispatchEvent(new CustomEvent("screenshare_started", {
5728
- detail: { participantId: clientId, stream, id: streamId, isLocal: false },
5729
- }));
5730
5734
  }
5731
5735
  _joinRoom() {
5732
5736
  this.signalSocket.emit("join_room", {
@@ -6100,6 +6104,13 @@ function useRoomConnection(roomUrl, roomConnectionOptions) {
6100
6104
  payload: { participantId, displayName },
6101
6105
  });
6102
6106
  }),
6107
+ createEventListener("waiting_participant_left", (e) => {
6108
+ const { participantId } = e.detail;
6109
+ dispatch({
6110
+ type: "WAITING_PARTICIPANT_LEFT",
6111
+ payload: { participantId },
6112
+ });
6113
+ }),
6103
6114
  ], []);
6104
6115
  useEffect(() => {
6105
6116
  eventListeners.forEach(({ eventName, listener }) => {
@@ -6166,6 +6177,6 @@ function useRoomConnection(roomUrl, roomConnectionOptions) {
6166
6177
  };
6167
6178
  }
6168
6179
 
6169
- const sdkVersion = "2.0.0-alpha21";
6180
+ const sdkVersion = "2.0.0-alpha23";
6170
6181
 
6171
6182
  export { VideoView, sdkVersion, useLocalMedia, useRoomConnection };
package/dist/types.d.ts CHANGED
@@ -377,6 +377,6 @@ type RoomConnectionRef = {
377
377
  };
378
378
  declare function useRoomConnection(roomUrl: string, roomConnectionOptions: UseRoomConnectionOptions): RoomConnectionRef;
379
379
 
380
- declare const sdkVersion = "2.0.0-alpha21";
380
+ declare const sdkVersion = "2.0.0-alpha23";
381
381
 
382
382
  export { _default as VideoView, sdkVersion, useLocalMedia, useRoomConnection };