@vindral/web-sdk 4.3.0-7-ga7804427 → 4.3.0-9-g13d8cb8f

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.
@@ -7740,45 +7740,35 @@ function Eg() {
7740
7740
  var Dg = (e, t) => {
7741
7741
  var n, r;
7742
7742
  let i = new URL("/subscribe", e);
7743
- return i.searchParams.append("channelId", t.channelId), i.searchParams.append("sessionId", t.sessionId), i.searchParams.append("clientId", t.clientId), (n = t.audio) != null && n.codec && (i.searchParams.append("audio.bitRate", Math.round(t.audio.bitRate).toString()), i.searchParams.append("audio.codec", t.audio.codec), t.audio.language && i.searchParams.append("audio.language", t.audio.language)), (r = t.video) != null && r.codec && (i.searchParams.append("video.width", t.video.width.toString()), i.searchParams.append("video.height", t.video.height.toString()), i.searchParams.append("video.bitRate", Math.round(t.video.bitRate).toString()), i.searchParams.append("video.codec", t.video.codec)), t.expectAdditionalConnection && i.searchParams.append("expectAdditionalConnection", t.expectAdditionalConnection.toString()), t.burstMs && i.searchParams.append("burstMs", t.burstMs.toString()), t.channelGroupId && i.searchParams.append("channelGroupId", t.channelGroupId), t.authToken && (i.searchParams.append("auth.token", t.authToken), i.searchParams.append("auth.type", "jwt")), i.toString();
7743
+ return i.searchParams.append("channelId", t.channelId), i.searchParams.append("sessionId", t.sessionId), i.searchParams.append("clientId", t.clientId), (n = t.audio) != null && n.codec && (i.searchParams.append("audio.bitRate", Math.round(t.audio.bitRate).toString()), i.searchParams.append("audio.codec", t.audio.codec), t.audio.language && i.searchParams.append("audio.language", t.audio.language)), (r = t.video) != null && r.codec && (i.searchParams.append("video.width", t.video.width.toString()), i.searchParams.append("video.height", t.video.height.toString()), i.searchParams.append("video.bitRate", Math.round(t.video.bitRate).toString()), i.searchParams.append("video.codec", t.video.codec)), t.burstMs && i.searchParams.append("burstMs", t.burstMs.toString()), t.channelGroupId && i.searchParams.append("channelGroupId", t.channelGroupId), t.authToken && (i.searchParams.append("auth.token", t.authToken), i.searchParams.append("auth.type", "jwt")), i.toString();
7744
7744
  }, Og = /* @__PURE__ */ function(e) {
7745
7745
  return e[e.AuthenticationFailed = 4e3] = "AuthenticationFailed", e[e.AuthenticationRefreshFailed = 4001] = "AuthenticationRefreshFailed", e[e.AuthenticationExpired = 4002] = "AuthenticationExpired", e[e.ChannelNotFound = 4003] = "ChannelNotFound", e[e.Inactivity = 4010] = "Inactivity", e;
7746
7746
  }({}), kg = class extends ge {
7747
7747
  constructor(n, r) {
7748
7748
  var i;
7749
- super(), i = this, e(this, "options", void 0), e(this, "websockets", []), e(this, "logger", void 0), e(this, "reconnectState", { reconnectRetries: 0 }), e(this, "isSuspended", !1), e(this, "_connectionAttemptCount", 0), e(this, "connectStartTime", 0), e(this, "_connectTime", void 0), e(this, "connectTimeout", void 0), e(this, "shouldContinueConnecting", !1), e(this, "_isConnectInProgress", !1), e(this, "readyState", () => {
7750
- if (this.websockets.length === 0) return WebSocket.CLOSED;
7751
- let e = this.websockets.map((e) => e.readyState);
7752
- for (let t of e) switch (t) {
7753
- case WebSocket.OPEN: continue;
7754
- default: return t;
7755
- }
7756
- return WebSocket.OPEN;
7749
+ super(), i = this, e(this, "options", void 0), e(this, "websocket", void 0), e(this, "logger", void 0), e(this, "reconnectState", { reconnectRetries: 0 }), e(this, "isSuspended", !1), e(this, "_connectionAttemptCount", 0), e(this, "connectStartTime", 0), e(this, "_connectTime", void 0), e(this, "connectTimeout", void 0), e(this, "shouldContinueConnecting", !1), e(this, "_isConnectInProgress", !1), e(this, "readyState", () => {
7750
+ var e, t;
7751
+ return (e = (t = this.websocket) == null ? void 0 : t.readyState) == null ? WebSocket.CLOSED : e;
7757
7752
  }), e(this, "url", () => {
7758
7753
  var e;
7759
- return (e = this.websockets[0]) == null ? void 0 : e.url;
7754
+ return (e = this.websocket) == null ? void 0 : e.url;
7760
7755
  }), e(this, "send", (e) => {
7761
- if (this.websockets.length) {
7762
- var t;
7763
- (t = this.websockets[0]) == null || t.send(e);
7764
- }
7765
- }), e(this, "closeSockets", (e, t) => {
7766
- let n = !1;
7767
- return e.forEach((e) => {
7768
- e.onmessage = o, e.removeEventListener("error", this.onError), e.removeEventListener("close", this.onClose), e.removeEventListener("open", this.onOpen), e.close(1e3, t), n = !0;
7769
- }), n;
7756
+ var t;
7757
+ (t = this.websocket) == null || t.send(e);
7758
+ }), e(this, "closeSocket", (e, t) => {
7759
+ e.onmessage = o, e.removeEventListener("error", this.onError), e.removeEventListener("close", this.onClose), e.removeEventListener("open", this.onOpen), e.close(1e3, t);
7770
7760
  }), e(this, "close", (e) => {
7771
7761
  this.clearConnectTimeout();
7772
- let t = this.closeSockets(this.websockets, e);
7773
- return this.websockets = [], this.shouldContinueConnecting = !1, this._isConnectInProgress = !1, this.logger.info("Closed websocket", { reason: e }), t;
7762
+ let t = this.websocket;
7763
+ return t && this.closeSocket(t, e), this.websocket = void 0, this.shouldContinueConnecting = !1, this._isConnectInProgress = !1, this.logger.info("Closed websocket", { reason: e }), !!t;
7774
7764
  }), e(this, "suspend", () => {
7775
7765
  this.isSuspended = !0;
7776
7766
  }), e(this, "unsuspend", () => {
7777
7767
  this.isSuspended = !1, this.readyState() !== WebSocket.OPEN && !this.isConnectInProgress && this.connect();
7778
- }), e(this, "onMessage", (e, t) => {
7779
- this.websockets.length !== 0 && this.options.onMessage(e, t.data);
7768
+ }), e(this, "onMessage", (e) => {
7769
+ this.options.onMessage(e.data);
7780
7770
  }), e(this, "onError", () => {
7781
- this.logger.warn("On error", w({}, this.options)), this.close("one websocket had an error"), this.emit("error", new g("WebSocket error", {
7771
+ this.logger.warn("On error", w({}, this.options)), this.close("websocket had an error"), this.emit("error", new g("WebSocket error", {
7782
7772
  code: "websocket_error",
7783
7773
  isFatal: !1
7784
7774
  }));
@@ -7788,7 +7778,7 @@ var Dg = (e, t) => {
7788
7778
  reason: e.reason,
7789
7779
  code: e.code,
7790
7780
  isSuspended: this.isSuspended
7791
- })), this.close("one websocket was closed");
7781
+ })), this.close("websocket was closed");
7792
7782
  let n;
7793
7783
  switch (e.code) {
7794
7784
  case Og.AuthenticationFailed:
@@ -7826,20 +7816,17 @@ var Dg = (e, t) => {
7826
7816
  if (i.reconnectState.reconnectRetries++, !e) return i._isConnectInProgress = !1, i.emit("error", s()), !1;
7827
7817
  }
7828
7818
  i._connectionAttemptCount++;
7829
- let t = [];
7819
+ let t;
7830
7820
  try {
7831
7821
  if (!i.shouldContinueConnecting) return i._isConnectInProgress = !1, i.logger.info("Connection aborted"), !1;
7832
- let { url: e, connectionCount: n } = yield i.options.connectHandler();
7822
+ let e = yield i.options.connectHandler();
7833
7823
  if (i.connectStartTime = Date.now(), !i.shouldContinueConnecting) return i._isConnectInProgress = !1, i.logger.info("Connection aborted"), !1;
7834
- i.logger.info("Connecting websockets", w(w({}, i.options), {}, { url: e }));
7835
- for (let r = 0; r < n; r++) {
7836
- let n = new WebSocket(e);
7837
- n.binaryType = "arraybuffer", n.onmessage = (e) => i.onMessage(r, e), n.addEventListener("error", i.onError), n.addEventListener("close", i.onClose), n.addEventListener("open", i.onOpen), t.push(n);
7838
- }
7839
- return i.websockets = t, i.startConnectTimeout(), !0;
7824
+ i.logger.info("Connecting websocket", w(w({}, i.options), {}, { url: e }));
7825
+ let n = new WebSocket(e);
7826
+ return t = n, n.binaryType = "arraybuffer", n.onmessage = i.onMessage, n.addEventListener("error", i.onError), n.addEventListener("close", i.onClose), n.addEventListener("open", i.onOpen), i.websocket = n, i.startConnectTimeout(), !0;
7840
7827
  } catch (e) {
7841
7828
  let n = i.shouldContinueConnecting;
7842
- return i.clearConnectTimeout(), i.closeSockets(t.length > 0 ? t : i.websockets, "failed to create websocket"), i.websockets = [], i.shouldContinueConnecting = !1, i._isConnectInProgress = !1, e instanceof g && (i.logger.error("Failed to connect", e.toStringifiable()), e.isFatal()) ? !1 : n ? (i.logger.info("Connection aborted", { error: e }), i.emit("error", new g("Failed to connect", {
7829
+ return i.clearConnectTimeout(), t && i.closeSocket(t, "failed to create websocket"), i.websocket = void 0, i.shouldContinueConnecting = !1, i._isConnectInProgress = !1, e instanceof g && (i.logger.error("Failed to connect", e.toStringifiable()), e.isFatal()) ? !1 : n ? (i.logger.info("Connection aborted", { error: e }), i.emit("error", new g("Failed to connect", {
7843
7830
  code: "failed_to_connect",
7844
7831
  isFatal: !1,
7845
7832
  source: e,
@@ -7851,9 +7838,6 @@ var Dg = (e, t) => {
7851
7838
  get isConnectInProgress() {
7852
7839
  return this._isConnectInProgress;
7853
7840
  }
7854
- get connectionCount() {
7855
- return this.websockets.length;
7856
- }
7857
7841
  get connectionAttemptCount() {
7858
7842
  return this._connectionAttemptCount;
7859
7843
  }
@@ -7866,7 +7850,7 @@ var Dg = (e, t) => {
7866
7850
  }, Fg = class n {
7867
7851
  constructor(r, i, a, s) {
7868
7852
  var c = this;
7869
- e(this, "emitter", void 0), e(this, "transport", void 0), e(this, "logger", void 0), e(this, "config", void 0), e(this, "rtts", void 0), e(this, "lastPingSentTime", Date.now()), e(this, "isPingInFlight", !1), e(this, "connectCount", 0), e(this, "missedPings", 0), e(this, "contextSwitchesInProgress", /* @__PURE__ */ new Set()), e(this, "contextSwitchesCompleted", /* @__PURE__ */ new Set()), e(this, "buffer", []), e(this, "disconnected", new T()), e(this, "unload", () => {
7853
+ e(this, "emitter", void 0), e(this, "transport", void 0), e(this, "logger", void 0), e(this, "config", void 0), e(this, "rtts", void 0), e(this, "lastPingSentTime", Date.now()), e(this, "isPingInFlight", !1), e(this, "connectCount", 0), e(this, "missedPings", 0), e(this, "isContextSwitchInProgress", !1), e(this, "signalBuffer", []), e(this, "dataBuffer", []), e(this, "disconnected", new T()), e(this, "unload", () => {
7870
7854
  this.logger.debug("Unloading module..."), this.close("Unloading"), this.emitter.off("send signal", this.sendSignal), this.emitter.off("disconnect", this.close), this.emitter.off("reconnect", this.reconnect), this.logger.debug("Unloaded module");
7871
7855
  }), e(this, "suspend", () => {
7872
7856
  this.resetPingState(), this.transport.suspend();
@@ -7884,36 +7868,33 @@ var Dg = (e, t) => {
7884
7868
  return;
7885
7869
  }
7886
7870
  this.transport.send(JSON.stringify(e));
7887
- }), e(this, "getStatistics", () => {
7888
- var e;
7889
- return {
7890
- edgeUrl: (e = this.transport) == null ? void 0 : e.url(),
7891
- connectionProtocol: "vindral_ws",
7892
- transportSelectionReason: void 0
7893
- };
7894
- }), e(this, "onMessage", (e, t) => {
7895
- var n;
7896
- if (this.pingCooldownExpired() && this.sendPing(), this.contextSwitchesCompleted.size === ((n = this.transport) == null ? void 0 : n.connectionCount)) {
7897
- this.logger.info("Completing context switch"), this.contextSwitchesInProgress.clear(), this.contextSwitchesCompleted.clear();
7898
- let e = this.buffer.filter(([e, t]) => !(t instanceof ArrayBuffer)), t = this.buffer.filter(([e, t]) => t instanceof ArrayBuffer);
7899
- e.map((e) => this.handleMessage(e[0], e[1])), t.map((e) => this.handleMessage(e[0], e[1])), this.buffer = [];
7900
- }
7901
- if (this.contextSwitchesInProgress.has(e)) {
7902
- if (!(t instanceof ArrayBuffer)) {
7903
- let n = JSON.parse(t);
7904
- if (Sn(n) && n.type === "context switch complete") {
7905
- this.logger.info("context switch completed", { socketId: e }), this.emitter.emit("context switch complete"), this.contextSwitchesCompleted.add(e);
7871
+ }), e(this, "getStatistics", () => ({
7872
+ edgeUrl: this.transport.url(),
7873
+ connectionProtocol: "vindral_ws",
7874
+ transportSelectionReason: void 0
7875
+ })), e(this, "onMessage", (e) => {
7876
+ if (this.pingCooldownExpired() && this.sendPing(), this.isContextSwitchInProgress) {
7877
+ if (e instanceof ArrayBuffer) {
7878
+ this.dataBuffer.push(e);
7879
+ return;
7880
+ }
7881
+ let t = JSON.parse(e);
7882
+ if (Sn(t)) {
7883
+ if (t.type === "pong") {
7884
+ this.handleMessage(e);
7885
+ return;
7886
+ }
7887
+ if (t.type === "context switch complete") {
7888
+ this.logger.info("context switch completed"), this.emitter.emit("context switch complete"), this.isContextSwitchInProgress = !1, this.flushContextSwitchBuffer();
7906
7889
  return;
7907
7890
  }
7908
7891
  }
7909
- this.buffer.push([e, t]);
7892
+ this.signalBuffer.push(e);
7910
7893
  return;
7911
7894
  }
7912
- this.handleMessage(e, t);
7895
+ this.handleMessage(e);
7913
7896
  }), e(this, "resolveEdgeUrl", t(function* () {
7914
- let e = c.config.connectInfo, t = yield c.config.onConnectInfo(e), n = c.config.options.getOverride("separateVideoSocketEnabled", t.channelId), r = c.config.options.get("media") === "audio+video", i = 1;
7915
- r && (i = n === !1 ? 1 : 2);
7916
- let a = Dg(c.config.edgeUrl, {
7897
+ let e = c.config.connectInfo, t = yield c.config.onConnectInfo(e), n = Dg(c.config.edgeUrl, {
7917
7898
  video: t.video,
7918
7899
  audio: t.audio,
7919
7900
  burstMs: t.burstMs,
@@ -7921,27 +7902,31 @@ var Dg = (e, t) => {
7921
7902
  clientId: t.clientId,
7922
7903
  channelId: t.channelId,
7923
7904
  channelGroupId: t.channelGroupId,
7924
- expectAdditionalConnection: i > 1,
7925
7905
  authToken: c.config.options.get("authenticationToken")
7926
7906
  });
7927
- return c.logger.debug("Resolved edge url", { edgeUrl: a }), {
7928
- url: a,
7929
- connectionCount: i
7930
- };
7931
- })), e(this, "handleMessage", (e, t) => {
7932
- if (t instanceof ArrayBuffer) this.emitter.emit("received data", t);
7907
+ return c.logger.debug("Resolved edge url", { edgeUrl: n }), n;
7908
+ })), e(this, "flushContextSwitchBuffer", () => {
7909
+ this.logger.info("Flushing context switch buffer");
7910
+ let e = this.signalBuffer, t = this.dataBuffer;
7911
+ this.signalBuffer = [], this.dataBuffer = [], e.forEach((e) => {
7912
+ this.handleMessage(e);
7913
+ }), t.forEach((e) => {
7914
+ this.handleMessage(e);
7915
+ });
7916
+ }), e(this, "handleMessage", (e) => {
7917
+ if (e instanceof ArrayBuffer) this.emitter.emit("received data", e);
7933
7918
  else {
7934
- let n = JSON.parse(t);
7935
- if (!Sn(n)) return;
7936
- switch (n.type) {
7919
+ let t = JSON.parse(e);
7920
+ if (!Sn(t)) return;
7921
+ switch (t.type) {
7937
7922
  case "pong":
7938
7923
  this.lastPingSentTime && (this.rtts.push(Date.now() - this.lastPingSentTime), this.isPingInFlight = !1, this.emitter.emit("rtt", Ot(this.rtts.items())));
7939
7924
  break;
7940
7925
  case "context switch":
7941
- this.logger.info("Starting context switch", { socketId: e }), this.emitter.emit("context switch started"), this.contextSwitchesInProgress.add(e);
7926
+ this.logger.info("Starting context switch"), this.emitter.emit("context switch started"), this.isContextSwitchInProgress = !0;
7942
7927
  break;
7943
7928
  default:
7944
- this.emitter.emit("received signal", n);
7929
+ this.emitter.emit("received signal", t);
7945
7930
  break;
7946
7931
  }
7947
7932
  }
@@ -7954,16 +7939,14 @@ var Dg = (e, t) => {
7954
7939
  }, this.logger.createContext("Transport"));
7955
7940
  return e.on("open", this.onTransportChange), e.on("close", this.onTransportChange), e.on("error", (e) => this.disconnected.reject(e)), e.connect(), e;
7956
7941
  }), e(this, "close", (e = "Disconnect Requested") => {
7957
- var t;
7958
- this.contextSwitchesCompleted.clear(), this.contextSwitchesInProgress.clear(), this.buffer = [], this.resetPingState(), this.disconnected.resolve(), (t = this.transport) == null || t.close(e);
7942
+ this.isContextSwitchInProgress = !1, this.signalBuffer = [], this.dataBuffer = [], this.resetPingState(), this.disconnected.resolve(), this.transport.close(e);
7959
7943
  }), e(this, "onTransportChange", () => {
7960
7944
  switch (this.getState()) {
7961
7945
  case "connected":
7962
- var e;
7963
- (e = this.transport) != null && e.connectTime && (this.rtts.push(this.transport.connectTime / n.TLS_ROUNDTRIPS / (this.transport.connectionCount || 1)), this.emitter.emit("rtt", Ot(this.rtts.items()))), this.connectCount++, this.resetPingState();
7946
+ this.transport.connectTime && (this.rtts.push(this.transport.connectTime / n.TLS_ROUNDTRIPS), this.emitter.emit("rtt", Ot(this.rtts.items()))), this.connectCount++, this.resetPingState();
7964
7947
  break;
7965
7948
  default:
7966
- this.contextSwitchesCompleted.clear(), this.contextSwitchesInProgress.clear(), this.buffer = [], this.resetPingState(), this.disconnected.resolve();
7949
+ this.isContextSwitchInProgress = !1, this.signalBuffer = [], this.dataBuffer = [], this.resetPingState(), this.disconnected.resolve();
7967
7950
  break;
7968
7951
  }
7969
7952
  this.emitter.emit("connection state", this.getState());
@@ -10562,7 +10545,6 @@ var Vv = [
10562
10545
  "maxBufferTime",
10563
10546
  "burstEnabled",
10564
10547
  "sizeBasedResolutionCapEnabled",
10565
- "separateVideoSocketEnabled",
10566
10548
  "webcodecsHardwareAcceleration",
10567
10549
  "offscreenCanvasEnabled",
10568
10550
  "videoCodecs"
@@ -11026,7 +11008,7 @@ var Uv = class {
11026
11008
  let e = this.modules.canvasModule instanceof J_ ? !0 : void 0;
11027
11009
  return w({
11028
11010
  uptime: Date.now() - this.createdAt,
11029
- version: "4.3.0-7-ga7804427",
11011
+ version: "4.3.0-9-g13d8cb8f",
11030
11012
  clientId: this.clientId,
11031
11013
  sessionId: this.sessionId,
11032
11014
  channelId: this.channelId,
@@ -1,5 +1,5 @@
1
1
  import { n as e, t } from "./BsfwXDui.js";
2
- import { _ as n, a as r, c as i, d as a, f as o, g as s, h as c, i as ee, l, m as te, n as u, o as ne, p as re, r as ie, s as ae, t as oe, u as se, v as ce } from "./CH6V1aJ7.js";
2
+ import { _ as n, a as r, c as i, d as a, f as o, g as s, h as c, i as ee, l, m as te, n as u, o as ne, p as re, r as ie, s as ae, t as oe, u as se, v as ce } from "./BWe37SYR.js";
3
3
  import { M as le } from "./C01DcfYu.js";
4
4
  import { a as d, i as f, n as p, r as m, t as h } from "./B7hT-BKr.js";
5
5
  import { n as ue, t as de } from "./DeYmk5AL.js";
package/api-client.d.ts CHANGED
@@ -38,7 +38,6 @@ interface ClientOverrides {
38
38
  maxBufferTime?: number;
39
39
  burstEnabled?: boolean;
40
40
  sizeBasedResolutionCapEnabled?: boolean;
41
- separateVideoSocketEnabled?: boolean;
42
41
  webcodecsHardwareAcceleration?: WebCodecsHardwareAccelerationPreference;
43
42
  offscreenCanvasEnabled?: boolean;
44
43
  videoCodecs?: string[];
package/core.d.ts CHANGED
@@ -449,7 +449,6 @@ interface ClientOverrides {
449
449
  maxBufferTime?: number;
450
450
  burstEnabled?: boolean;
451
451
  sizeBasedResolutionCapEnabled?: boolean;
452
- separateVideoSocketEnabled?: boolean;
453
452
  webcodecsHardwareAcceleration?: WebCodecsHardwareAccelerationPreference;
454
453
  offscreenCanvasEnabled?: boolean;
455
454
  videoCodecs?: string[];
package/core.js CHANGED
@@ -1,3 +1,3 @@
1
- import { t as e } from "./CH6V1aJ7.js";
1
+ import { t as e } from "./BWe37SYR.js";
2
2
  import { a as t, c as n, i as r, l as i, n as a, o, r as s, s as c, u as l } from "./C01DcfYu.js";
3
3
  export { a as AUTHENTICATION_EXPIRED_CODE, s as AUTHENTICATION_FAILED_CODE, r as CHANNEL_NOT_FOUND_CODE, t as CONNECTION_FAILED_AFTER_RETRIES_CODE, o as CONNECTION_FAILED_CODE, c as DISCONNECTED_BY_EDGE, n as INACTIVITY_CODE, i as NO_INCOMING_DATA, e as Vindral, l as VindralError };
package/legacy.d.ts CHANGED
@@ -452,7 +452,6 @@ interface ClientOverrides {
452
452
  maxBufferTime?: number;
453
453
  burstEnabled?: boolean;
454
454
  sizeBasedResolutionCapEnabled?: boolean;
455
- separateVideoSocketEnabled?: boolean;
456
455
  webcodecsHardwareAcceleration?: WebCodecsHardwareAccelerationPreference;
457
456
  offscreenCanvasEnabled?: boolean;
458
457
  videoCodecs?: string[];
package/legacy.es.js CHANGED
@@ -8650,7 +8650,7 @@ function Vv() {
8650
8650
  var Hv = (e, t) => {
8651
8651
  var n, r;
8652
8652
  let i = new URL("/subscribe", e);
8653
- return i.searchParams.append("channelId", t.channelId), i.searchParams.append("sessionId", t.sessionId), i.searchParams.append("clientId", t.clientId), (n = t.audio) != null && n.codec && (i.searchParams.append("audio.bitRate", Math.round(t.audio.bitRate).toString()), i.searchParams.append("audio.codec", t.audio.codec), t.audio.language && i.searchParams.append("audio.language", t.audio.language)), (r = t.video) != null && r.codec && (i.searchParams.append("video.width", t.video.width.toString()), i.searchParams.append("video.height", t.video.height.toString()), i.searchParams.append("video.bitRate", Math.round(t.video.bitRate).toString()), i.searchParams.append("video.codec", t.video.codec)), t.expectAdditionalConnection && i.searchParams.append("expectAdditionalConnection", t.expectAdditionalConnection.toString()), t.burstMs && i.searchParams.append("burstMs", t.burstMs.toString()), t.channelGroupId && i.searchParams.append("channelGroupId", t.channelGroupId), t.authToken && (i.searchParams.append("auth.token", t.authToken), i.searchParams.append("auth.type", "jwt")), i.toString();
8653
+ return i.searchParams.append("channelId", t.channelId), i.searchParams.append("sessionId", t.sessionId), i.searchParams.append("clientId", t.clientId), (n = t.audio) != null && n.codec && (i.searchParams.append("audio.bitRate", Math.round(t.audio.bitRate).toString()), i.searchParams.append("audio.codec", t.audio.codec), t.audio.language && i.searchParams.append("audio.language", t.audio.language)), (r = t.video) != null && r.codec && (i.searchParams.append("video.width", t.video.width.toString()), i.searchParams.append("video.height", t.video.height.toString()), i.searchParams.append("video.bitRate", Math.round(t.video.bitRate).toString()), i.searchParams.append("video.codec", t.video.codec)), t.burstMs && i.searchParams.append("burstMs", t.burstMs.toString()), t.channelGroupId && i.searchParams.append("channelGroupId", t.channelGroupId), t.authToken && (i.searchParams.append("auth.token", t.authToken), i.searchParams.append("auth.type", "jwt")), i.toString();
8654
8654
  };
8655
8655
  Ei(), V(), m(), z(), N();
8656
8656
  var Uv = /* @__PURE__ */ function(e) {
@@ -8658,39 +8658,29 @@ var Uv = /* @__PURE__ */ function(e) {
8658
8658
  }({}), Wv = class extends Ut {
8659
8659
  constructor(e, t) {
8660
8660
  var n;
8661
- super(), n = this, p(this, "options", void 0), p(this, "websockets", []), p(this, "logger", void 0), p(this, "reconnectState", { reconnectRetries: 0 }), p(this, "isSuspended", !1), p(this, "_connectionAttemptCount", 0), p(this, "connectStartTime", 0), p(this, "_connectTime", void 0), p(this, "connectTimeout", void 0), p(this, "shouldContinueConnecting", !1), p(this, "_isConnectInProgress", !1), p(this, "readyState", () => {
8662
- if (this.websockets.length === 0) return WebSocket.CLOSED;
8663
- let e = this.websockets.map((e) => e.readyState);
8664
- for (let t of e) switch (t) {
8665
- case WebSocket.OPEN: continue;
8666
- default: return t;
8667
- }
8668
- return WebSocket.OPEN;
8661
+ super(), n = this, p(this, "options", void 0), p(this, "websocket", void 0), p(this, "logger", void 0), p(this, "reconnectState", { reconnectRetries: 0 }), p(this, "isSuspended", !1), p(this, "_connectionAttemptCount", 0), p(this, "connectStartTime", 0), p(this, "_connectTime", void 0), p(this, "connectTimeout", void 0), p(this, "shouldContinueConnecting", !1), p(this, "_isConnectInProgress", !1), p(this, "readyState", () => {
8662
+ var e, t;
8663
+ return (e = (t = this.websocket) == null ? void 0 : t.readyState) == null ? WebSocket.CLOSED : e;
8669
8664
  }), p(this, "url", () => {
8670
8665
  var e;
8671
- return (e = this.websockets[0]) == null ? void 0 : e.url;
8666
+ return (e = this.websocket) == null ? void 0 : e.url;
8672
8667
  }), p(this, "send", (e) => {
8673
- if (this.websockets.length) {
8674
- var t;
8675
- (t = this.websockets[0]) == null || t.send(e);
8676
- }
8677
- }), p(this, "closeSockets", (e, t) => {
8678
- let n = !1;
8679
- return e.forEach((e) => {
8680
- e.onmessage = x, e.removeEventListener("error", this.onError), e.removeEventListener("close", this.onClose), e.removeEventListener("open", this.onOpen), e.close(1e3, t), n = !0;
8681
- }), n;
8668
+ var t;
8669
+ (t = this.websocket) == null || t.send(e);
8670
+ }), p(this, "closeSocket", (e, t) => {
8671
+ e.onmessage = x, e.removeEventListener("error", this.onError), e.removeEventListener("close", this.onClose), e.removeEventListener("open", this.onOpen), e.close(1e3, t);
8682
8672
  }), p(this, "close", (e) => {
8683
8673
  this.clearConnectTimeout();
8684
- let t = this.closeSockets(this.websockets, e);
8685
- return this.websockets = [], this.shouldContinueConnecting = !1, this._isConnectInProgress = !1, this.logger.info("Closed websocket", { reason: e }), t;
8674
+ let t = this.websocket;
8675
+ return t && this.closeSocket(t, e), this.websocket = void 0, this.shouldContinueConnecting = !1, this._isConnectInProgress = !1, this.logger.info("Closed websocket", { reason: e }), !!t;
8686
8676
  }), p(this, "suspend", () => {
8687
8677
  this.isSuspended = !0;
8688
8678
  }), p(this, "unsuspend", () => {
8689
8679
  this.isSuspended = !1, this.readyState() !== WebSocket.OPEN && !this.isConnectInProgress && this.connect();
8690
- }), p(this, "onMessage", (e, t) => {
8691
- this.websockets.length !== 0 && this.options.onMessage(e, t.data);
8680
+ }), p(this, "onMessage", (e) => {
8681
+ this.options.onMessage(e.data);
8692
8682
  }), p(this, "onError", () => {
8693
- this.logger.warn("On error", R({}, this.options)), this.close("one websocket had an error"), this.emit("error", new H("WebSocket error", {
8683
+ this.logger.warn("On error", R({}, this.options)), this.close("websocket had an error"), this.emit("error", new H("WebSocket error", {
8694
8684
  code: "websocket_error",
8695
8685
  isFatal: !1
8696
8686
  }));
@@ -8700,7 +8690,7 @@ var Uv = /* @__PURE__ */ function(e) {
8700
8690
  reason: e.reason,
8701
8691
  code: e.code,
8702
8692
  isSuspended: this.isSuspended
8703
- })), this.close("one websocket was closed");
8693
+ })), this.close("websocket was closed");
8704
8694
  let n;
8705
8695
  switch (e.code) {
8706
8696
  case Uv.AuthenticationFailed:
@@ -8738,20 +8728,17 @@ var Uv = /* @__PURE__ */ function(e) {
8738
8728
  if (n.reconnectState.reconnectRetries++, !e) return n._isConnectInProgress = !1, n.emit("error", xi()), !1;
8739
8729
  }
8740
8730
  n._connectionAttemptCount++;
8741
- let t = [];
8731
+ let t;
8742
8732
  try {
8743
8733
  if (!n.shouldContinueConnecting) return n._isConnectInProgress = !1, n.logger.info("Connection aborted"), !1;
8744
- let { url: e, connectionCount: r } = yield n.options.connectHandler();
8734
+ let e = yield n.options.connectHandler();
8745
8735
  if (n.connectStartTime = Date.now(), !n.shouldContinueConnecting) return n._isConnectInProgress = !1, n.logger.info("Connection aborted"), !1;
8746
- n.logger.info("Connecting websockets", R(R({}, n.options), {}, { url: e }));
8747
- for (let i = 0; i < r; i++) {
8748
- let r = new WebSocket(e);
8749
- r.binaryType = "arraybuffer", r.onmessage = (e) => n.onMessage(i, e), r.addEventListener("error", n.onError), r.addEventListener("close", n.onClose), r.addEventListener("open", n.onOpen), t.push(r);
8750
- }
8751
- return n.websockets = t, n.startConnectTimeout(), !0;
8736
+ n.logger.info("Connecting websocket", R(R({}, n.options), {}, { url: e }));
8737
+ let r = new WebSocket(e);
8738
+ return t = r, r.binaryType = "arraybuffer", r.onmessage = n.onMessage, r.addEventListener("error", n.onError), r.addEventListener("close", n.onClose), r.addEventListener("open", n.onOpen), n.websocket = r, n.startConnectTimeout(), !0;
8752
8739
  } catch (e) {
8753
8740
  let r = n.shouldContinueConnecting;
8754
- return n.clearConnectTimeout(), n.closeSockets(t.length > 0 ? t : n.websockets, "failed to create websocket"), n.websockets = [], n.shouldContinueConnecting = !1, n._isConnectInProgress = !1, e instanceof H && (n.logger.error("Failed to connect", e.toStringifiable()), e.isFatal()) ? !1 : r ? (n.logger.info("Connection aborted", { error: e }), n.emit("error", new H("Failed to connect", {
8741
+ return n.clearConnectTimeout(), t && n.closeSocket(t, "failed to create websocket"), n.websocket = void 0, n.shouldContinueConnecting = !1, n._isConnectInProgress = !1, e instanceof H && (n.logger.error("Failed to connect", e.toStringifiable()), e.isFatal()) ? !1 : r ? (n.logger.info("Connection aborted", { error: e }), n.emit("error", new H("Failed to connect", {
8755
8742
  code: "failed_to_connect",
8756
8743
  isFatal: !1,
8757
8744
  source: e,
@@ -8763,9 +8750,6 @@ var Uv = /* @__PURE__ */ function(e) {
8763
8750
  get isConnectInProgress() {
8764
8751
  return this._isConnectInProgress;
8765
8752
  }
8766
- get connectionCount() {
8767
- return this.websockets.length;
8768
- }
8769
8753
  get connectionAttemptCount() {
8770
8754
  return this._connectionAttemptCount;
8771
8755
  }
@@ -8780,7 +8764,7 @@ var Gv, Kv = 65536 * 8, qv = .9, Jv = 40, Yv = (e) => {
8780
8764
  }, Xv = class e {
8781
8765
  constructor(t, n, r, i) {
8782
8766
  var a = this;
8783
- p(this, "emitter", void 0), p(this, "transport", void 0), p(this, "logger", void 0), p(this, "config", void 0), p(this, "rtts", void 0), p(this, "lastPingSentTime", Date.now()), p(this, "isPingInFlight", !1), p(this, "connectCount", 0), p(this, "missedPings", 0), p(this, "contextSwitchesInProgress", /* @__PURE__ */ new Set()), p(this, "contextSwitchesCompleted", /* @__PURE__ */ new Set()), p(this, "buffer", []), p(this, "disconnected", new S()), p(this, "unload", () => {
8767
+ p(this, "emitter", void 0), p(this, "transport", void 0), p(this, "logger", void 0), p(this, "config", void 0), p(this, "rtts", void 0), p(this, "lastPingSentTime", Date.now()), p(this, "isPingInFlight", !1), p(this, "connectCount", 0), p(this, "missedPings", 0), p(this, "isContextSwitchInProgress", !1), p(this, "signalBuffer", []), p(this, "dataBuffer", []), p(this, "disconnected", new S()), p(this, "unload", () => {
8784
8768
  this.logger.debug("Unloading module..."), this.close("Unloading"), this.emitter.off("send signal", this.sendSignal), this.emitter.off("disconnect", this.close), this.emitter.off("reconnect", this.reconnect), this.logger.debug("Unloaded module");
8785
8769
  }), p(this, "suspend", () => {
8786
8770
  this.resetPingState(), this.transport.suspend();
@@ -8798,36 +8782,33 @@ var Gv, Kv = 65536 * 8, qv = .9, Jv = 40, Yv = (e) => {
8798
8782
  return;
8799
8783
  }
8800
8784
  this.transport.send(JSON.stringify(e));
8801
- }), p(this, "getStatistics", () => {
8802
- var e;
8803
- return {
8804
- edgeUrl: (e = this.transport) == null ? void 0 : e.url(),
8805
- connectionProtocol: "vindral_ws",
8806
- transportSelectionReason: void 0
8807
- };
8808
- }), p(this, "onMessage", (e, t) => {
8809
- var n;
8810
- if (this.pingCooldownExpired() && this.sendPing(), this.contextSwitchesCompleted.size === ((n = this.transport) == null ? void 0 : n.connectionCount)) {
8811
- this.logger.info("Completing context switch"), this.contextSwitchesInProgress.clear(), this.contextSwitchesCompleted.clear();
8812
- let e = this.buffer.filter(([e, t]) => !(t instanceof ArrayBuffer)), t = this.buffer.filter(([e, t]) => t instanceof ArrayBuffer);
8813
- e.map((e) => this.handleMessage(e[0], e[1])), t.map((e) => this.handleMessage(e[0], e[1])), this.buffer = [];
8814
- }
8815
- if (this.contextSwitchesInProgress.has(e)) {
8816
- if (!(t instanceof ArrayBuffer)) {
8817
- let n = JSON.parse(t);
8818
- if (vr(n) && n.type === "context switch complete") {
8819
- this.logger.info("context switch completed", { socketId: e }), this.emitter.emit("context switch complete"), this.contextSwitchesCompleted.add(e);
8785
+ }), p(this, "getStatistics", () => ({
8786
+ edgeUrl: this.transport.url(),
8787
+ connectionProtocol: "vindral_ws",
8788
+ transportSelectionReason: void 0
8789
+ })), p(this, "onMessage", (e) => {
8790
+ if (this.pingCooldownExpired() && this.sendPing(), this.isContextSwitchInProgress) {
8791
+ if (e instanceof ArrayBuffer) {
8792
+ this.dataBuffer.push(e);
8793
+ return;
8794
+ }
8795
+ let t = JSON.parse(e);
8796
+ if (vr(t)) {
8797
+ if (t.type === "pong") {
8798
+ this.handleMessage(e);
8799
+ return;
8800
+ }
8801
+ if (t.type === "context switch complete") {
8802
+ this.logger.info("context switch completed"), this.emitter.emit("context switch complete"), this.isContextSwitchInProgress = !1, this.flushContextSwitchBuffer();
8820
8803
  return;
8821
8804
  }
8822
8805
  }
8823
- this.buffer.push([e, t]);
8806
+ this.signalBuffer.push(e);
8824
8807
  return;
8825
8808
  }
8826
- this.handleMessage(e, t);
8809
+ this.handleMessage(e);
8827
8810
  }), p(this, "resolveEdgeUrl", M(function* () {
8828
- let e = a.config.connectInfo, t = yield a.config.onConnectInfo(e), n = a.config.options.getOverride("separateVideoSocketEnabled", t.channelId), r = a.config.options.get("media") === "audio+video", i = 1;
8829
- r && (i = n === !1 ? 1 : 2);
8830
- let o = Hv(a.config.edgeUrl, {
8811
+ let e = a.config.connectInfo, t = yield a.config.onConnectInfo(e), n = Hv(a.config.edgeUrl, {
8831
8812
  video: t.video,
8832
8813
  audio: t.audio,
8833
8814
  burstMs: t.burstMs,
@@ -8835,27 +8816,31 @@ var Gv, Kv = 65536 * 8, qv = .9, Jv = 40, Yv = (e) => {
8835
8816
  clientId: t.clientId,
8836
8817
  channelId: t.channelId,
8837
8818
  channelGroupId: t.channelGroupId,
8838
- expectAdditionalConnection: i > 1,
8839
8819
  authToken: a.config.options.get("authenticationToken")
8840
8820
  });
8841
- return a.logger.debug("Resolved edge url", { edgeUrl: o }), {
8842
- url: o,
8843
- connectionCount: i
8844
- };
8845
- })), p(this, "handleMessage", (e, t) => {
8846
- if (t instanceof ArrayBuffer) this.emitter.emit("received data", t);
8821
+ return a.logger.debug("Resolved edge url", { edgeUrl: n }), n;
8822
+ })), p(this, "flushContextSwitchBuffer", () => {
8823
+ this.logger.info("Flushing context switch buffer");
8824
+ let e = this.signalBuffer, t = this.dataBuffer;
8825
+ this.signalBuffer = [], this.dataBuffer = [], e.forEach((e) => {
8826
+ this.handleMessage(e);
8827
+ }), t.forEach((e) => {
8828
+ this.handleMessage(e);
8829
+ });
8830
+ }), p(this, "handleMessage", (e) => {
8831
+ if (e instanceof ArrayBuffer) this.emitter.emit("received data", e);
8847
8832
  else {
8848
- let n = JSON.parse(t);
8849
- if (!vr(n)) return;
8850
- switch (n.type) {
8833
+ let t = JSON.parse(e);
8834
+ if (!vr(t)) return;
8835
+ switch (t.type) {
8851
8836
  case "pong":
8852
8837
  this.lastPingSentTime && (this.rtts.push(Date.now() - this.lastPingSentTime), this.isPingInFlight = !1, this.emitter.emit("rtt", At(this.rtts.items())));
8853
8838
  break;
8854
8839
  case "context switch":
8855
- this.logger.info("Starting context switch", { socketId: e }), this.emitter.emit("context switch started"), this.contextSwitchesInProgress.add(e);
8840
+ this.logger.info("Starting context switch"), this.emitter.emit("context switch started"), this.isContextSwitchInProgress = !0;
8856
8841
  break;
8857
8842
  default:
8858
- this.emitter.emit("received signal", n);
8843
+ this.emitter.emit("received signal", t);
8859
8844
  break;
8860
8845
  }
8861
8846
  }
@@ -8868,16 +8853,14 @@ var Gv, Kv = 65536 * 8, qv = .9, Jv = 40, Yv = (e) => {
8868
8853
  }, this.logger.createContext("Transport"));
8869
8854
  return e.on("open", this.onTransportChange), e.on("close", this.onTransportChange), e.on("error", (e) => this.disconnected.reject(e)), e.connect(), e;
8870
8855
  }), p(this, "close", (e = "Disconnect Requested") => {
8871
- var t;
8872
- this.contextSwitchesCompleted.clear(), this.contextSwitchesInProgress.clear(), this.buffer = [], this.resetPingState(), this.disconnected.resolve(), (t = this.transport) == null || t.close(e);
8856
+ this.isContextSwitchInProgress = !1, this.signalBuffer = [], this.dataBuffer = [], this.resetPingState(), this.disconnected.resolve(), this.transport.close(e);
8873
8857
  }), p(this, "onTransportChange", () => {
8874
8858
  switch (this.getState()) {
8875
8859
  case "connected":
8876
- var t;
8877
- (t = this.transport) != null && t.connectTime && (this.rtts.push(this.transport.connectTime / e.TLS_ROUNDTRIPS / (this.transport.connectionCount || 1)), this.emitter.emit("rtt", At(this.rtts.items()))), this.connectCount++, this.resetPingState();
8860
+ this.transport.connectTime && (this.rtts.push(this.transport.connectTime / e.TLS_ROUNDTRIPS), this.emitter.emit("rtt", At(this.rtts.items()))), this.connectCount++, this.resetPingState();
8878
8861
  break;
8879
8862
  default:
8880
- this.contextSwitchesCompleted.clear(), this.contextSwitchesInProgress.clear(), this.buffer = [], this.resetPingState(), this.disconnected.resolve();
8863
+ this.isContextSwitchInProgress = !1, this.signalBuffer = [], this.dataBuffer = [], this.resetPingState(), this.disconnected.resolve();
8881
8864
  break;
8882
8865
  }
8883
8866
  this.emitter.emit("connection state", this.getState());
@@ -12043,7 +12026,6 @@ var Ax = [
12043
12026
  "maxBufferTime",
12044
12027
  "burstEnabled",
12045
12028
  "sizeBasedResolutionCapEnabled",
12046
- "separateVideoSocketEnabled",
12047
12029
  "webcodecsHardwareAcceleration",
12048
12030
  "offscreenCanvasEnabled",
12049
12031
  "videoCodecs"
@@ -12521,7 +12503,7 @@ var Gx = /* @__PURE__ */ new WeakMap(), Kx = /* @__PURE__ */ new WeakMap(), qx =
12521
12503
  let e = this.modules.canvasModule instanceof Lb ? !0 : void 0;
12522
12504
  return R({
12523
12505
  uptime: Date.now() - this.createdAt,
12524
- version: "4.3.0-7-ga7804427",
12506
+ version: "4.3.0-9-g13d8cb8f",
12525
12507
  clientId: this.clientId,
12526
12508
  sessionId: this.sessionId,
12527
12509
  channelId: this.channelId,