@vindral/web-sdk 4.8.0-2-g31d0f7c0 → 4.8.0-4-gb24dc167

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.
@@ -1,5 +1,5 @@
1
1
  import { n as e, t } from "./BsfwXDui.js";
2
- import { C as n, D as r, E as i, O as a, S as o, T as s, _ as c, b as l, g as u, h as d, k as f, m as ee, p as te, t as ne, v as re, w as ie, x as ae, y as oe } from "./C9eQS1Qa.js";
2
+ import { C as n, D as r, E as i, O as a, S as o, T as s, _ as c, b as l, g as u, h as d, k as f, m as ee, p as te, t as ne, v as re, w as ie, x as ae, y as oe } from "./Dz6tIxPq.js";
3
3
  import { t as se } from "./CuYn2z5X.js";
4
4
  import { i as p, n as m, r as h, t as g } from "./DSw1XhvD.js";
5
5
  import { c as ce, n as le, t as ue } from "./D40eQS8l.js";
@@ -8999,7 +8999,7 @@ var ab = /* @__PURE__ */ function(e) {
8999
8999
  }, fb = class r {
9000
9000
  constructor(i, a, o, s) {
9001
9001
  var c = this;
9002
- 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", performance.now()), e(this, "isPingInFlight", !1), e(this, "connectCount", 0), e(this, "missedPings", 0), e(this, "closedForBacklog", !1), e(this, "isContextSwitchInProgress", !1), e(this, "signalBuffer", []), e(this, "dataBuffer", []), e(this, "disconnected", new w()), e(this, "linkQueue", new gy()), e(this, "clockCorrection", 0), e(this, "backlogBreaker", new Jv(this.linkQueue, () => this.getState() === "connected", (e) => {
9002
+ 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", performance.now()), e(this, "isPingInFlight", !1), e(this, "lastSignalSentTime", performance.now()), e(this, "connectCount", 0), e(this, "missedPings", 0), e(this, "closedForBacklog", !1), e(this, "isContextSwitchInProgress", !1), e(this, "signalBuffer", []), e(this, "dataBuffer", []), e(this, "disconnected", new w()), e(this, "linkQueue", new gy()), e(this, "clockCorrection", 0), e(this, "backlogBreaker", new Jv(this.linkQueue, () => this.getState() === "connected", (e) => {
9003
9003
  this.logger.info("Link queue over the breaker, reconnecting", { levelMs: Math.round(e) }), this.closeForBacklog("link queue over the breaker");
9004
9004
  })), e(this, "unload", () => {
9005
9005
  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");
@@ -9018,7 +9018,7 @@ var ab = /* @__PURE__ */ function(e) {
9018
9018
  this.logger.debug("transport is closed");
9019
9019
  return;
9020
9020
  }
9021
- this.transport.send(JSON.stringify(e));
9021
+ this.transport.send(JSON.stringify(e)), this.lastSignalSentTime = performance.now();
9022
9022
  }), e(this, "getStatistics", () => ({
9023
9023
  edgeUrl: Pv(this.config.edgeUrl),
9024
9024
  connectionProtocol: "vindral_ws",
@@ -9075,7 +9075,10 @@ var ab = /* @__PURE__ */ function(e) {
9075
9075
  if (!hn(t)) return;
9076
9076
  switch (t.type) {
9077
9077
  case "pong":
9078
- this.lastPingSentTime && (this.rtts.push(performance.now() - this.lastPingSentTime), this.isPingInFlight = !1, this.emitter.emit("rtt", gt(this.rtts.items())));
9078
+ if (this.lastPingSentTime) {
9079
+ let e = performance.now() - this.lastPingSentTime;
9080
+ this.isPingInFlight = !1, e < r.PING_INTERVAL && (this.rtts.push(e), this.emitter.emit("rtt", gt(this.rtts.items())));
9081
+ }
9079
9082
  break;
9080
9083
  case "context switch":
9081
9084
  this.logger.info("Starting context switch"), this.emitter.emit("context switch started"), this.isContextSwitchInProgress = !0;
@@ -9124,8 +9127,15 @@ var ab = /* @__PURE__ */ function(e) {
9124
9127
  this.missedPings = 0, this.isPingInFlight = !1;
9125
9128
  }), e(this, "pingCooldownExpired", () => performance.now() - this.lastPingSentTime > r.PING_INTERVAL), e(this, "sendPing", () => {
9126
9129
  if (this.isPingInFlight) {
9127
- this.missedPings++, this.missedPings > r.MAX_MISSED_PINGS && this.linkQueue.level() === void 0 && this.closeForBacklog("missed pings");
9128
- return;
9130
+ if (this.missedPings++, this.linkQueue.level() === void 0) {
9131
+ this.missedPings > r.MAX_MISSED_PINGS && this.closeForBacklog("missed pings");
9132
+ return;
9133
+ }
9134
+ let e = performance.now();
9135
+ if (e - this.lastPingSentTime < r.PING_TIMEOUT) {
9136
+ e - this.lastSignalSentTime > r.PING_INTERVAL && this.sendSignal({ type: "keepalive" });
9137
+ return;
9138
+ }
9129
9139
  }
9130
9140
  this.isPingInFlight = !0, this.lastPingSentTime = performance.now(), this.missedPings = 0, this.sendSignal({ type: "ping" });
9131
9141
  }), this.logger = a, this.emitter = i, this.config = o, this.rtts = s, this.emitter.on("send signal", this.sendSignal), this.emitter.on("disconnect", this.close), this.emitter.on("reconnect", this.reconnect), this.disconnected.promise.catch(n), this.transport = this.connectWebSocketTransport();
@@ -9134,7 +9144,7 @@ var ab = /* @__PURE__ */ function(e) {
9134
9144
  return this.disconnected.promise;
9135
9145
  }
9136
9146
  };
9137
- sb = fb, e(fb, "PING_INTERVAL", 5e3), e(fb, "MAX_MISSED_PINGS", 4), e(fb, "TLS_ROUNDTRIPS", 3), e(fb, "start", (e, t, n, r) => new Promise((i, a) => {
9147
+ sb = fb, e(fb, "PING_INTERVAL", 5e3), e(fb, "PING_TIMEOUT", 15e3), e(fb, "MAX_MISSED_PINGS", 4), e(fb, "TLS_ROUNDTRIPS", 3), e(fb, "start", (e, t, n, r) => new Promise((i, a) => {
9138
9148
  let o = new sb(e, t, n, r);
9139
9149
  o.transport.once("error", (e) => a(e)), o.transport.once("open", () => {
9140
9150
  var e;
@@ -12771,7 +12781,7 @@ var GS = class {
12771
12781
  let e = this.modules.canvasModule instanceof qx ? !0 : void 0;
12772
12782
  return x({
12773
12783
  uptime: this.uptime,
12774
- version: "4.8.0-2-g31d0f7c0",
12784
+ version: "4.8.0-4-gb24dc167",
12775
12785
  clientId: this.clientId,
12776
12786
  sessionId: this.sessionId,
12777
12787
  channelId: this.channelId,
package/core.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as e, c as t, d as n, f as r, i, l as a, o, r as s, s as c, t as l, u } from "./C9eQS1Qa.js";
1
+ import { a as e, c as t, d as n, f as r, i, l as a, o, r as s, s as c, t as l, u } from "./Dz6tIxPq.js";
2
2
  export { s as AUTHENTICATION_EXPIRED_CODE, i as AUTHENTICATION_FAILED_CODE, e as CHANNEL_NOT_FOUND_CODE, o as CHANNEL_NOT_LIVE_CODE, c as CONNECTION_FAILED_AFTER_RETRIES_CODE, t as CONNECTION_FAILED_CODE, a as DISCONNECTED_BY_EDGE, u as INACTIVITY_CODE, n as NO_INCOMING_DATA, l as Vindral, r as VindralError };
package/legacy.es.js CHANGED
@@ -9972,7 +9972,7 @@ var SS, CS = 65536 * 8, wS = .9, TS = 40, ES = (e) => {
9972
9972
  }, DS = class e {
9973
9973
  constructor(t, n, r, i) {
9974
9974
  var a = this;
9975
- 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", performance.now()), p(this, "isPingInFlight", !1), p(this, "connectCount", 0), p(this, "missedPings", 0), p(this, "closedForBacklog", !1), p(this, "isContextSwitchInProgress", !1), p(this, "signalBuffer", []), p(this, "dataBuffer", []), p(this, "disconnected", new C()), p(this, "linkQueue", new Ox()), p(this, "clockCorrection", 0), p(this, "backlogBreaker", new ox(this.linkQueue, () => this.getState() === "connected", (e) => {
9975
+ 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", performance.now()), p(this, "isPingInFlight", !1), p(this, "lastSignalSentTime", performance.now()), p(this, "connectCount", 0), p(this, "missedPings", 0), p(this, "closedForBacklog", !1), p(this, "isContextSwitchInProgress", !1), p(this, "signalBuffer", []), p(this, "dataBuffer", []), p(this, "disconnected", new C()), p(this, "linkQueue", new Ox()), p(this, "clockCorrection", 0), p(this, "backlogBreaker", new ox(this.linkQueue, () => this.getState() === "connected", (e) => {
9976
9976
  this.logger.info("Link queue over the breaker, reconnecting", { levelMs: Math.round(e) }), this.closeForBacklog("link queue over the breaker");
9977
9977
  })), p(this, "unload", () => {
9978
9978
  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");
@@ -9991,7 +9991,7 @@ var SS, CS = 65536 * 8, wS = .9, TS = 40, ES = (e) => {
9991
9991
  this.logger.debug("transport is closed");
9992
9992
  return;
9993
9993
  }
9994
- this.transport.send(JSON.stringify(e));
9994
+ this.transport.send(JSON.stringify(e)), this.lastSignalSentTime = performance.now();
9995
9995
  }), p(this, "getStatistics", () => ({
9996
9996
  edgeUrl: Kb(this.config.edgeUrl),
9997
9997
  connectionProtocol: "vindral_ws",
@@ -10041,20 +10041,23 @@ var SS, CS = 65536 * 8, wS = .9, TS = 40, ES = (e) => {
10041
10041
  }), t.forEach((e) => {
10042
10042
  this.handleMessage(e);
10043
10043
  });
10044
- }), p(this, "handleMessage", (e) => {
10045
- if (e instanceof ArrayBuffer) this.emitter.emit("received data", e);
10044
+ }), p(this, "handleMessage", (t) => {
10045
+ if (t instanceof ArrayBuffer) this.emitter.emit("received data", t);
10046
10046
  else {
10047
- let t = JSON.parse(e);
10048
- if (!Wr(t)) return;
10049
- switch (t.type) {
10047
+ let n = JSON.parse(t);
10048
+ if (!Wr(n)) return;
10049
+ switch (n.type) {
10050
10050
  case "pong":
10051
- this.lastPingSentTime && (this.rtts.push(performance.now() - this.lastPingSentTime), this.isPingInFlight = !1, this.emitter.emit("rtt", Vt(this.rtts.items())));
10051
+ if (this.lastPingSentTime) {
10052
+ let t = performance.now() - this.lastPingSentTime;
10053
+ this.isPingInFlight = !1, t < e.PING_INTERVAL && (this.rtts.push(t), this.emitter.emit("rtt", Vt(this.rtts.items())));
10054
+ }
10052
10055
  break;
10053
10056
  case "context switch":
10054
10057
  this.logger.info("Starting context switch"), this.emitter.emit("context switch started"), this.isContextSwitchInProgress = !0;
10055
10058
  break;
10056
10059
  default:
10057
- this.emitter.emit("received signal", t);
10060
+ this.emitter.emit("received signal", n);
10058
10061
  break;
10059
10062
  }
10060
10063
  }
@@ -10097,8 +10100,15 @@ var SS, CS = 65536 * 8, wS = .9, TS = 40, ES = (e) => {
10097
10100
  this.missedPings = 0, this.isPingInFlight = !1;
10098
10101
  }), p(this, "pingCooldownExpired", () => performance.now() - this.lastPingSentTime > e.PING_INTERVAL), p(this, "sendPing", () => {
10099
10102
  if (this.isPingInFlight) {
10100
- this.missedPings++, this.missedPings > e.MAX_MISSED_PINGS && this.linkQueue.level() === void 0 && this.closeForBacklog("missed pings");
10101
- return;
10103
+ if (this.missedPings++, this.linkQueue.level() === void 0) {
10104
+ this.missedPings > e.MAX_MISSED_PINGS && this.closeForBacklog("missed pings");
10105
+ return;
10106
+ }
10107
+ let t = performance.now();
10108
+ if (t - this.lastPingSentTime < e.PING_TIMEOUT) {
10109
+ t - this.lastSignalSentTime > e.PING_INTERVAL && this.sendSignal({ type: "keepalive" });
10110
+ return;
10111
+ }
10102
10112
  }
10103
10113
  this.isPingInFlight = !0, this.lastPingSentTime = performance.now(), this.missedPings = 0, this.sendSignal({ type: "ping" });
10104
10114
  }), this.logger = n, this.emitter = t, this.config = r, this.rtts = i, this.emitter.on("send signal", this.sendSignal), this.emitter.on("disconnect", this.close), this.emitter.on("reconnect", this.reconnect), this.disconnected.promise.catch(S), this.transport = this.connectWebSocketTransport();
@@ -10107,7 +10117,7 @@ var SS, CS = 65536 * 8, wS = .9, TS = 40, ES = (e) => {
10107
10117
  return this.disconnected.promise;
10108
10118
  }
10109
10119
  };
10110
- SS = DS, p(DS, "PING_INTERVAL", 5e3), p(DS, "MAX_MISSED_PINGS", 4), p(DS, "TLS_ROUNDTRIPS", 3), p(DS, "start", (e, t, n, r) => new Promise((i, a) => {
10120
+ SS = DS, p(DS, "PING_INTERVAL", 5e3), p(DS, "PING_TIMEOUT", 15e3), p(DS, "MAX_MISSED_PINGS", 4), p(DS, "TLS_ROUNDTRIPS", 3), p(DS, "start", (e, t, n, r) => new Promise((i, a) => {
10111
10121
  let o = new SS(e, t, n, r);
10112
10122
  o.transport.once("error", (e) => a(e)), o.transport.once("open", () => {
10113
10123
  var e;
@@ -14359,7 +14369,7 @@ var QT = 1e4, $T = 300, eE = 3e3, tE = 1e4, nE = 1280 * 720, rE = /* @__PURE__ *
14359
14369
  let e = this.modules.canvasModule instanceof Iw ? !0 : void 0;
14360
14370
  return L({
14361
14371
  uptime: this.uptime,
14362
- version: "4.8.0-2-g31d0f7c0",
14372
+ version: "4.8.0-4-gb24dc167",
14363
14373
  clientId: this.clientId,
14364
14374
  sessionId: this.sessionId,
14365
14375
  channelId: this.channelId,