@oddin-gg/havik-player 1.13.0 → 1.14.0

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.js CHANGED
@@ -1307,14 +1307,16 @@ var ze = class {
1307
1307
  if (e && e(this.url, t)) return;
1308
1308
  }
1309
1309
  let n = this.opts.fetchFn ?? (typeof fetch < "u" ? fetch : void 0);
1310
- n && n(this.url, {
1310
+ if (!n) return;
1311
+ let r = { "content-type": "application/json" };
1312
+ this.opts.apiKey && (r["x-api-key"] = this.opts.apiKey), n(this.url, {
1311
1313
  method: "POST",
1312
- headers: { "content-type": "application/json" },
1314
+ headers: r,
1313
1315
  body: t,
1314
1316
  keepalive: !0
1315
1317
  }).catch(() => {});
1316
1318
  }
1317
- }, Be = "1.13.0", W = {
1319
+ }, Be = "1.14.0", W = {
1318
1320
  accent: "#E1B600",
1319
1321
  accentText: "#1B1C23",
1320
1322
  background: "#0e0f13",
@@ -1888,32 +1890,33 @@ var tt = class {
1888
1890
  i(), r.destroy();
1889
1891
  return;
1890
1892
  }
1891
- this.engine = r, this.detachMedia = i, this.opts.maxBitrate != null && r.setMaxBitrate(this.opts.maxBitrate), this.startStats(), this.scheduleLicenseRefresh(), this.startLiveState(t), this.startAnalytics(e, r);
1893
+ this.engine = r, this.detachMedia = i, this.opts.maxBitrate != null && r.setMaxBitrate(this.opts.maxBitrate), this.startStats(), this.scheduleLicenseRefresh(), this.startLiveState(t), this.startAnalytics(e, r, n.apiKey);
1892
1894
  }
1893
- startAnalytics(e, t) {
1895
+ startAnalytics(e, t, n) {
1894
1896
  if (this.analyticsSession?.noteDestroyed(), this.analyticsSession = null, this.detachSeekListener?.(), this.opts.analytics === !1) return;
1895
- let n = e.analytics?.sid;
1896
- if (!n) return;
1897
- let r = (typeof this.opts.analytics == "object" ? this.opts.analytics.endpoint : void 0) ?? Re(this.opts.baseUrl);
1897
+ let r = e.analytics?.sid;
1898
1898
  if (!r) return;
1899
- let i = this.opts.video, a = new ze({
1900
- endpoint: r,
1901
- sid: n,
1899
+ let i = (typeof this.opts.analytics == "object" ? this.opts.analytics.endpoint : void 0) ?? Re(this.opts.baseUrl);
1900
+ if (!i) return;
1901
+ let a = this.opts.video, o = new ze({
1902
+ endpoint: i,
1903
+ sid: r,
1904
+ apiKey: n,
1902
1905
  player: t.name === "native" ? "PLAYER_SAFARI_NATIVE" : "PLAYER_HLSJS",
1903
1906
  sdkVersion: Be,
1904
1907
  sample: () => {
1905
- let e = this.engine?.getStats() ?? F, t = i.buffered.length ? Math.max(0, i.buffered.end(i.buffered.length - 1) - i.currentTime) : 0;
1908
+ let e = this.engine?.getStats() ?? F, t = a.buffered.length ? Math.max(0, a.buffered.end(a.buffered.length - 1) - a.currentTime) : 0;
1906
1909
  return {
1907
1910
  ...e,
1908
1911
  bufferedMs: Math.round(t * 1e3),
1909
1912
  state: this._state,
1910
- positionMs: Math.round(i.currentTime * 1e3)
1913
+ positionMs: Math.round(a.currentTime * 1e3)
1911
1914
  };
1912
1915
  }
1913
1916
  });
1914
- this.analyticsSession = a;
1915
- let o = () => a.noteSeek();
1916
- i.addEventListener("seeking", o), this.detachSeekListener = () => i.removeEventListener("seeking", o), a.start();
1917
+ this.analyticsSession = o;
1918
+ let s = () => o.noteSeek();
1919
+ a.addEventListener("seeking", s), this.detachSeekListener = () => a.removeEventListener("seeking", s), o.start();
1917
1920
  }
1918
1921
  createEngine(e, n) {
1919
1922
  let r = { ...this.opts.hlsConfig };