@whereby.com/media 1.14.1 → 1.14.2

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/index.cjs CHANGED
@@ -1421,10 +1421,6 @@ class VegaConnection extends EventEmitter.EventEmitter {
1421
1421
  var _a;
1422
1422
  (_a = this.socket) === null || _a === void 0 ? void 0 : _a.close();
1423
1423
  }
1424
- isConnected() {
1425
- var _a, _b;
1426
- return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === WebSocket.OPEN || ((_b = this.socket) === null || _b === void 0 ? void 0 : _b.readyState) === WebSocket.CONNECTING;
1427
- }
1428
1424
  _onOpen() {
1429
1425
  logger$9.info("Connected");
1430
1426
  this.emit("open");
@@ -5080,6 +5076,7 @@ class VegaRtcManager {
5080
5076
  this._socketListenerDeregisterFunctions = [];
5081
5077
  this._reconnect = true;
5082
5078
  this._reconnectTimeOut = null;
5079
+ this._hasVegaConnection = false;
5083
5080
  this._qualityMonitor = new VegaMediaQualityMonitor();
5084
5081
  this._qualityMonitor.on(PROTOCOL_EVENTS.MEDIA_QUALITY_CHANGED, (payload) => {
5085
5082
  this._emitToPWA(PROTOCOL_EVENTS.MEDIA_QUALITY_CHANGED, payload);
@@ -5114,7 +5111,7 @@ class VegaRtcManager {
5114
5111
  }), this._serverSocket.on(PROTOCOL_RESPONSES.ROOM_JOINED, () => {
5115
5112
  if (this._screenVideoTrack)
5116
5113
  this._emitScreenshareStarted();
5117
- if (this._features.sfuReconnectV2On && !this._vegaConnection.isConnected() && this._reconnect) {
5114
+ if (this._features.sfuReconnectV2On && !this._hasVegaConnection && this._reconnect) {
5118
5115
  this._connect();
5119
5116
  }
5120
5117
  }));
@@ -5128,6 +5125,8 @@ class VegaRtcManager {
5128
5125
  }
5129
5126
  _connect() {
5130
5127
  if (this._features.sfuReconnectV2On) {
5128
+ if (this._hasVegaConnection)
5129
+ return;
5131
5130
  if (!this._serverSocket.isConnected()) {
5132
5131
  const reconnectThresholdInMs = this._serverSocket.getReconnectThreshold();
5133
5132
  if (!reconnectThresholdInMs)
@@ -5145,6 +5144,7 @@ class VegaRtcManager {
5145
5144
  const queryString = searchParams.toString();
5146
5145
  const wsUrl = `wss://${host}?${queryString}`;
5147
5146
  this._vegaConnection = new VegaConnection(wsUrl);
5147
+ this._hasVegaConnection = true;
5148
5148
  this._vegaConnection.on("open", () => this._join());
5149
5149
  this._vegaConnection.on("close", () => this._onClose());
5150
5150
  this._vegaConnection.on("message", (message) => this._onMessage(message));
@@ -5152,6 +5152,7 @@ class VegaRtcManager {
5152
5152
  _onClose() {
5153
5153
  var _a, _b;
5154
5154
  logger$1.info("_onClose()");
5155
+ this._hasVegaConnection = false;
5155
5156
  (_a = this._sendTransport) === null || _a === void 0 ? void 0 : _a.close();
5156
5157
  (_b = this._receiveTransport) === null || _b === void 0 ? void 0 : _b.close();
5157
5158
  this._sendTransport = null;
@@ -5848,7 +5849,7 @@ class VegaRtcManager {
5848
5849
  if (!videoTrack.effectTrack) {
5849
5850
  this._monitorVideoTrack(videoTrack);
5850
5851
  }
5851
- const beforeEffectTrack = beforeEffectTracks.find(t => t.kind === "video");
5852
+ const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "video");
5852
5853
  if (beforeEffectTrack) {
5853
5854
  this._monitorVideoTrack(beforeEffectTrack);
5854
5855
  }
@@ -5859,7 +5860,7 @@ class VegaRtcManager {
5859
5860
  if (!audioTrack.effectTrack) {
5860
5861
  this._monitorAudioTrack(audioTrack);
5861
5862
  }
5862
- const beforeEffectTrack = beforeEffectTracks.find(t => t.kind === "audio");
5863
+ const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "audio");
5863
5864
  if (beforeEffectTrack) {
5864
5865
  this._monitorAudioTrack(beforeEffectTrack);
5865
5866
  }
@@ -5930,7 +5931,9 @@ class VegaRtcManager {
5930
5931
  }
5931
5932
  if (!enable) {
5932
5933
  clearTimeout(this._stopCameraTimeout);
5933
- const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended" ? 0 : 5000;
5934
+ const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended"
5935
+ ? 0
5936
+ : 5000;
5934
5937
  this._stopCameraTimeout = setTimeout(() => {
5935
5938
  localStream.getVideoTracks().forEach((track) => {
5936
5939
  if (track.enabled === false) {
package/dist/index.d.cts CHANGED
@@ -1090,7 +1090,6 @@ declare class VegaConnection extends EventEmitter$1 {
1090
1090
  _setupSocket(): void;
1091
1091
  _tearDown(): void;
1092
1092
  close(): void;
1093
- isConnected(): boolean;
1094
1093
  _onOpen(): void;
1095
1094
  _onMessage(event: MessageEvent): void;
1096
1095
  _onClose(): void;
@@ -1218,6 +1217,7 @@ declare class VegaRtcManager implements RtcManager {
1218
1217
  _mediaserverConfigTtlSeconds: any;
1219
1218
  _videoTrackBeingMonitored?: CustomMediaStreamTrack;
1220
1219
  _audioTrackBeingMonitored?: CustomMediaStreamTrack;
1220
+ _hasVegaConnection: boolean;
1221
1221
  constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, eventClaim, deviceHandlerFactory, }: {
1222
1222
  selfId: any;
1223
1223
  room: any;
package/dist/index.d.mts CHANGED
@@ -1090,7 +1090,6 @@ declare class VegaConnection extends EventEmitter$1 {
1090
1090
  _setupSocket(): void;
1091
1091
  _tearDown(): void;
1092
1092
  close(): void;
1093
- isConnected(): boolean;
1094
1093
  _onOpen(): void;
1095
1094
  _onMessage(event: MessageEvent): void;
1096
1095
  _onClose(): void;
@@ -1218,6 +1217,7 @@ declare class VegaRtcManager implements RtcManager {
1218
1217
  _mediaserverConfigTtlSeconds: any;
1219
1218
  _videoTrackBeingMonitored?: CustomMediaStreamTrack;
1220
1219
  _audioTrackBeingMonitored?: CustomMediaStreamTrack;
1220
+ _hasVegaConnection: boolean;
1221
1221
  constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, eventClaim, deviceHandlerFactory, }: {
1222
1222
  selfId: any;
1223
1223
  room: any;
package/dist/index.d.ts CHANGED
@@ -1090,7 +1090,6 @@ declare class VegaConnection extends EventEmitter$1 {
1090
1090
  _setupSocket(): void;
1091
1091
  _tearDown(): void;
1092
1092
  close(): void;
1093
- isConnected(): boolean;
1094
1093
  _onOpen(): void;
1095
1094
  _onMessage(event: MessageEvent): void;
1096
1095
  _onClose(): void;
@@ -1218,6 +1217,7 @@ declare class VegaRtcManager implements RtcManager {
1218
1217
  _mediaserverConfigTtlSeconds: any;
1219
1218
  _videoTrackBeingMonitored?: CustomMediaStreamTrack;
1220
1219
  _audioTrackBeingMonitored?: CustomMediaStreamTrack;
1220
+ _hasVegaConnection: boolean;
1221
1221
  constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, eventClaim, deviceHandlerFactory, }: {
1222
1222
  selfId: any;
1223
1223
  room: any;
package/dist/index.mjs CHANGED
@@ -1400,10 +1400,6 @@ class VegaConnection extends EventEmitter {
1400
1400
  var _a;
1401
1401
  (_a = this.socket) === null || _a === void 0 ? void 0 : _a.close();
1402
1402
  }
1403
- isConnected() {
1404
- var _a, _b;
1405
- return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === WebSocket.OPEN || ((_b = this.socket) === null || _b === void 0 ? void 0 : _b.readyState) === WebSocket.CONNECTING;
1406
- }
1407
1403
  _onOpen() {
1408
1404
  logger$9.info("Connected");
1409
1405
  this.emit("open");
@@ -5059,6 +5055,7 @@ class VegaRtcManager {
5059
5055
  this._socketListenerDeregisterFunctions = [];
5060
5056
  this._reconnect = true;
5061
5057
  this._reconnectTimeOut = null;
5058
+ this._hasVegaConnection = false;
5062
5059
  this._qualityMonitor = new VegaMediaQualityMonitor();
5063
5060
  this._qualityMonitor.on(PROTOCOL_EVENTS.MEDIA_QUALITY_CHANGED, (payload) => {
5064
5061
  this._emitToPWA(PROTOCOL_EVENTS.MEDIA_QUALITY_CHANGED, payload);
@@ -5093,7 +5090,7 @@ class VegaRtcManager {
5093
5090
  }), this._serverSocket.on(PROTOCOL_RESPONSES.ROOM_JOINED, () => {
5094
5091
  if (this._screenVideoTrack)
5095
5092
  this._emitScreenshareStarted();
5096
- if (this._features.sfuReconnectV2On && !this._vegaConnection.isConnected() && this._reconnect) {
5093
+ if (this._features.sfuReconnectV2On && !this._hasVegaConnection && this._reconnect) {
5097
5094
  this._connect();
5098
5095
  }
5099
5096
  }));
@@ -5107,6 +5104,8 @@ class VegaRtcManager {
5107
5104
  }
5108
5105
  _connect() {
5109
5106
  if (this._features.sfuReconnectV2On) {
5107
+ if (this._hasVegaConnection)
5108
+ return;
5110
5109
  if (!this._serverSocket.isConnected()) {
5111
5110
  const reconnectThresholdInMs = this._serverSocket.getReconnectThreshold();
5112
5111
  if (!reconnectThresholdInMs)
@@ -5124,6 +5123,7 @@ class VegaRtcManager {
5124
5123
  const queryString = searchParams.toString();
5125
5124
  const wsUrl = `wss://${host}?${queryString}`;
5126
5125
  this._vegaConnection = new VegaConnection(wsUrl);
5126
+ this._hasVegaConnection = true;
5127
5127
  this._vegaConnection.on("open", () => this._join());
5128
5128
  this._vegaConnection.on("close", () => this._onClose());
5129
5129
  this._vegaConnection.on("message", (message) => this._onMessage(message));
@@ -5131,6 +5131,7 @@ class VegaRtcManager {
5131
5131
  _onClose() {
5132
5132
  var _a, _b;
5133
5133
  logger$1.info("_onClose()");
5134
+ this._hasVegaConnection = false;
5134
5135
  (_a = this._sendTransport) === null || _a === void 0 ? void 0 : _a.close();
5135
5136
  (_b = this._receiveTransport) === null || _b === void 0 ? void 0 : _b.close();
5136
5137
  this._sendTransport = null;
@@ -5827,7 +5828,7 @@ class VegaRtcManager {
5827
5828
  if (!videoTrack.effectTrack) {
5828
5829
  this._monitorVideoTrack(videoTrack);
5829
5830
  }
5830
- const beforeEffectTrack = beforeEffectTracks.find(t => t.kind === "video");
5831
+ const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "video");
5831
5832
  if (beforeEffectTrack) {
5832
5833
  this._monitorVideoTrack(beforeEffectTrack);
5833
5834
  }
@@ -5838,7 +5839,7 @@ class VegaRtcManager {
5838
5839
  if (!audioTrack.effectTrack) {
5839
5840
  this._monitorAudioTrack(audioTrack);
5840
5841
  }
5841
- const beforeEffectTrack = beforeEffectTracks.find(t => t.kind === "audio");
5842
+ const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "audio");
5842
5843
  if (beforeEffectTrack) {
5843
5844
  this._monitorAudioTrack(beforeEffectTrack);
5844
5845
  }
@@ -5909,7 +5910,9 @@ class VegaRtcManager {
5909
5910
  }
5910
5911
  if (!enable) {
5911
5912
  clearTimeout(this._stopCameraTimeout);
5912
- const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended" ? 0 : 5000;
5913
+ const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended"
5914
+ ? 0
5915
+ : 5000;
5913
5916
  this._stopCameraTimeout = setTimeout(() => {
5914
5917
  localStream.getVideoTracks().forEach((track) => {
5915
5918
  if (track.enabled === false) {
@@ -1400,10 +1400,6 @@ class VegaConnection extends EventEmitter {
1400
1400
  var _a;
1401
1401
  (_a = this.socket) === null || _a === void 0 ? void 0 : _a.close();
1402
1402
  }
1403
- isConnected() {
1404
- var _a, _b;
1405
- return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === WebSocket.OPEN || ((_b = this.socket) === null || _b === void 0 ? void 0 : _b.readyState) === WebSocket.CONNECTING;
1406
- }
1407
1403
  _onOpen() {
1408
1404
  logger$9.info("Connected");
1409
1405
  this.emit("open");
@@ -5059,6 +5055,7 @@ class VegaRtcManager {
5059
5055
  this._socketListenerDeregisterFunctions = [];
5060
5056
  this._reconnect = true;
5061
5057
  this._reconnectTimeOut = null;
5058
+ this._hasVegaConnection = false;
5062
5059
  this._qualityMonitor = new VegaMediaQualityMonitor();
5063
5060
  this._qualityMonitor.on(PROTOCOL_EVENTS.MEDIA_QUALITY_CHANGED, (payload) => {
5064
5061
  this._emitToPWA(PROTOCOL_EVENTS.MEDIA_QUALITY_CHANGED, payload);
@@ -5093,7 +5090,7 @@ class VegaRtcManager {
5093
5090
  }), this._serverSocket.on(PROTOCOL_RESPONSES.ROOM_JOINED, () => {
5094
5091
  if (this._screenVideoTrack)
5095
5092
  this._emitScreenshareStarted();
5096
- if (this._features.sfuReconnectV2On && !this._vegaConnection.isConnected() && this._reconnect) {
5093
+ if (this._features.sfuReconnectV2On && !this._hasVegaConnection && this._reconnect) {
5097
5094
  this._connect();
5098
5095
  }
5099
5096
  }));
@@ -5107,6 +5104,8 @@ class VegaRtcManager {
5107
5104
  }
5108
5105
  _connect() {
5109
5106
  if (this._features.sfuReconnectV2On) {
5107
+ if (this._hasVegaConnection)
5108
+ return;
5110
5109
  if (!this._serverSocket.isConnected()) {
5111
5110
  const reconnectThresholdInMs = this._serverSocket.getReconnectThreshold();
5112
5111
  if (!reconnectThresholdInMs)
@@ -5124,6 +5123,7 @@ class VegaRtcManager {
5124
5123
  const queryString = searchParams.toString();
5125
5124
  const wsUrl = `wss://${host}?${queryString}`;
5126
5125
  this._vegaConnection = new VegaConnection(wsUrl);
5126
+ this._hasVegaConnection = true;
5127
5127
  this._vegaConnection.on("open", () => this._join());
5128
5128
  this._vegaConnection.on("close", () => this._onClose());
5129
5129
  this._vegaConnection.on("message", (message) => this._onMessage(message));
@@ -5131,6 +5131,7 @@ class VegaRtcManager {
5131
5131
  _onClose() {
5132
5132
  var _a, _b;
5133
5133
  logger$1.info("_onClose()");
5134
+ this._hasVegaConnection = false;
5134
5135
  (_a = this._sendTransport) === null || _a === void 0 ? void 0 : _a.close();
5135
5136
  (_b = this._receiveTransport) === null || _b === void 0 ? void 0 : _b.close();
5136
5137
  this._sendTransport = null;
@@ -5827,7 +5828,7 @@ class VegaRtcManager {
5827
5828
  if (!videoTrack.effectTrack) {
5828
5829
  this._monitorVideoTrack(videoTrack);
5829
5830
  }
5830
- const beforeEffectTrack = beforeEffectTracks.find(t => t.kind === "video");
5831
+ const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "video");
5831
5832
  if (beforeEffectTrack) {
5832
5833
  this._monitorVideoTrack(beforeEffectTrack);
5833
5834
  }
@@ -5838,7 +5839,7 @@ class VegaRtcManager {
5838
5839
  if (!audioTrack.effectTrack) {
5839
5840
  this._monitorAudioTrack(audioTrack);
5840
5841
  }
5841
- const beforeEffectTrack = beforeEffectTracks.find(t => t.kind === "audio");
5842
+ const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "audio");
5842
5843
  if (beforeEffectTrack) {
5843
5844
  this._monitorAudioTrack(beforeEffectTrack);
5844
5845
  }
@@ -5909,7 +5910,9 @@ class VegaRtcManager {
5909
5910
  }
5910
5911
  if (!enable) {
5911
5912
  clearTimeout(this._stopCameraTimeout);
5912
- const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended" ? 0 : 5000;
5913
+ const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended"
5914
+ ? 0
5915
+ : 5000;
5913
5916
  this._stopCameraTimeout = setTimeout(() => {
5914
5917
  localStream.getVideoTracks().forEach((track) => {
5915
5918
  if (track.enabled === false) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@whereby.com/media",
3
3
  "description": "Media library for Whereby",
4
- "version": "1.14.1",
4
+ "version": "1.14.2",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/whereby/sdk",
7
7
  "repository": {