@oddin-gg/havik-player 1.13.0 → 1.15.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/havik-player.global.js +3 -3
- package/dist/havik-player.global.js.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +30 -21
- package/dist/index.js.map +1 -1
- package/embed/index.html +1 -1
- package/examples/vanilla.html +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -164,6 +164,16 @@ export declare interface CreatePlayerOptions {
|
|
|
164
164
|
* differs from that convention.
|
|
165
165
|
*/
|
|
166
166
|
eventsBaseUrl?: string;
|
|
167
|
+
/**
|
|
168
|
+
* Extra headers attached to every request the SDK makes to {@link baseUrl}
|
|
169
|
+
* (playback resolution, live-status polling) — and ONLY there: never to
|
|
170
|
+
* CDN manifest/segment hosts, DRM license endpoints, the SSE events host,
|
|
171
|
+
* or the beacons endpoint. For integrations whose API front door wants
|
|
172
|
+
* its own auth signal on top of the publishable key — an operator console
|
|
173
|
+
* proving a session to its reverse proxy, or a customer gateway in front
|
|
174
|
+
* of the streams API. `x-api-key` cannot be overridden through this map.
|
|
175
|
+
*/
|
|
176
|
+
apiHeaders?: Record<string, string>;
|
|
167
177
|
/**
|
|
168
178
|
* QoE beacons + CMCD session attribution. Active only when the playback
|
|
169
179
|
* response carries an analytics sid (the server-side flag) — without one
|
|
@@ -295,6 +305,11 @@ export declare interface FetchCatalogOptions {
|
|
|
295
305
|
etag?: string;
|
|
296
306
|
status?: MatchLiveStatus | MatchLiveStatus[];
|
|
297
307
|
sport?: string;
|
|
308
|
+
/**
|
|
309
|
+
* Extra headers attached to every request to {@link baseUrl} — and only
|
|
310
|
+
* there: never to CDN or license hosts. `x-api-key` cannot be overridden.
|
|
311
|
+
*/
|
|
312
|
+
apiHeaders?: Record<string, string>;
|
|
298
313
|
}
|
|
299
314
|
|
|
300
315
|
/**
|
|
@@ -315,6 +330,11 @@ export declare interface FetchTournamentOptions {
|
|
|
315
330
|
signal?: AbortSignal;
|
|
316
331
|
/** Prior ETag for a conditional GET (304 when unchanged) — only effective once havik-streams ETags `/v1/tournaments/{urn}` (parity with `/v1/matches/{urn}`). */
|
|
317
332
|
etag?: string;
|
|
333
|
+
/**
|
|
334
|
+
* Extra headers attached to every request to {@link baseUrl} — and only
|
|
335
|
+
* there: never to CDN or license hosts. `x-api-key` cannot be overridden.
|
|
336
|
+
*/
|
|
337
|
+
apiHeaders?: Record<string, string>;
|
|
318
338
|
}
|
|
319
339
|
|
|
320
340
|
/** Flatten a Catalog to a single match list (handy for grids). */
|
|
@@ -687,6 +707,14 @@ export declare interface ResolveOptions {
|
|
|
687
707
|
*/
|
|
688
708
|
waitForLive?: WaitForLive;
|
|
689
709
|
signal?: AbortSignal;
|
|
710
|
+
/**
|
|
711
|
+
* Extra headers attached to every request this call makes to {@link baseUrl}
|
|
712
|
+
* — and ONLY there: never to CDN manifest/segment hosts or DRM license
|
|
713
|
+
* endpoints. For integrations whose API front door wants its own auth
|
|
714
|
+
* signal on top of the publishable key (gateways, operator consoles).
|
|
715
|
+
* `x-api-key` cannot be overridden.
|
|
716
|
+
*/
|
|
717
|
+
apiHeaders?: Record<string, string>;
|
|
690
718
|
}
|
|
691
719
|
|
|
692
720
|
/**
|
|
@@ -870,6 +898,11 @@ export declare interface WatchStatusOptions {
|
|
|
870
898
|
onError?: (err: PlaybackError) => void;
|
|
871
899
|
/** Poll interval in ms. Floored at 2000. Default: 10000 (catalog max-age). */
|
|
872
900
|
intervalMs?: number;
|
|
901
|
+
/**
|
|
902
|
+
* Extra headers attached to every request to {@link baseUrl} — and only
|
|
903
|
+
* there: never to CDN or license hosts. `x-api-key` cannot be overridden.
|
|
904
|
+
*/
|
|
905
|
+
apiHeaders?: Record<string, string>;
|
|
873
906
|
}
|
|
874
907
|
|
|
875
908
|
export declare interface WidevineInfo {
|
package/dist/index.d.ts
CHANGED
|
@@ -164,6 +164,16 @@ export declare interface CreatePlayerOptions {
|
|
|
164
164
|
* differs from that convention.
|
|
165
165
|
*/
|
|
166
166
|
eventsBaseUrl?: string;
|
|
167
|
+
/**
|
|
168
|
+
* Extra headers attached to every request the SDK makes to {@link baseUrl}
|
|
169
|
+
* (playback resolution, live-status polling) — and ONLY there: never to
|
|
170
|
+
* CDN manifest/segment hosts, DRM license endpoints, the SSE events host,
|
|
171
|
+
* or the beacons endpoint. For integrations whose API front door wants
|
|
172
|
+
* its own auth signal on top of the publishable key — an operator console
|
|
173
|
+
* proving a session to its reverse proxy, or a customer gateway in front
|
|
174
|
+
* of the streams API. `x-api-key` cannot be overridden through this map.
|
|
175
|
+
*/
|
|
176
|
+
apiHeaders?: Record<string, string>;
|
|
167
177
|
/**
|
|
168
178
|
* QoE beacons + CMCD session attribution. Active only when the playback
|
|
169
179
|
* response carries an analytics sid (the server-side flag) — without one
|
|
@@ -295,6 +305,11 @@ export declare interface FetchCatalogOptions {
|
|
|
295
305
|
etag?: string;
|
|
296
306
|
status?: MatchLiveStatus | MatchLiveStatus[];
|
|
297
307
|
sport?: string;
|
|
308
|
+
/**
|
|
309
|
+
* Extra headers attached to every request to {@link baseUrl} — and only
|
|
310
|
+
* there: never to CDN or license hosts. `x-api-key` cannot be overridden.
|
|
311
|
+
*/
|
|
312
|
+
apiHeaders?: Record<string, string>;
|
|
298
313
|
}
|
|
299
314
|
|
|
300
315
|
/**
|
|
@@ -315,6 +330,11 @@ export declare interface FetchTournamentOptions {
|
|
|
315
330
|
signal?: AbortSignal;
|
|
316
331
|
/** Prior ETag for a conditional GET (304 when unchanged) — only effective once havik-streams ETags `/v1/tournaments/{urn}` (parity with `/v1/matches/{urn}`). */
|
|
317
332
|
etag?: string;
|
|
333
|
+
/**
|
|
334
|
+
* Extra headers attached to every request to {@link baseUrl} — and only
|
|
335
|
+
* there: never to CDN or license hosts. `x-api-key` cannot be overridden.
|
|
336
|
+
*/
|
|
337
|
+
apiHeaders?: Record<string, string>;
|
|
318
338
|
}
|
|
319
339
|
|
|
320
340
|
/** Flatten a Catalog to a single match list (handy for grids). */
|
|
@@ -687,6 +707,14 @@ export declare interface ResolveOptions {
|
|
|
687
707
|
*/
|
|
688
708
|
waitForLive?: WaitForLive;
|
|
689
709
|
signal?: AbortSignal;
|
|
710
|
+
/**
|
|
711
|
+
* Extra headers attached to every request this call makes to {@link baseUrl}
|
|
712
|
+
* — and ONLY there: never to CDN manifest/segment hosts or DRM license
|
|
713
|
+
* endpoints. For integrations whose API front door wants its own auth
|
|
714
|
+
* signal on top of the publishable key (gateways, operator consoles).
|
|
715
|
+
* `x-api-key` cannot be overridden.
|
|
716
|
+
*/
|
|
717
|
+
apiHeaders?: Record<string, string>;
|
|
690
718
|
}
|
|
691
719
|
|
|
692
720
|
/**
|
|
@@ -870,6 +898,11 @@ export declare interface WatchStatusOptions {
|
|
|
870
898
|
onError?: (err: PlaybackError) => void;
|
|
871
899
|
/** Poll interval in ms. Floored at 2000. Default: 10000 (catalog max-age). */
|
|
872
900
|
intervalMs?: number;
|
|
901
|
+
/**
|
|
902
|
+
* Extra headers attached to every request to {@link baseUrl} — and only
|
|
903
|
+
* there: never to CDN or license hosts. `x-api-key` cannot be overridden.
|
|
904
|
+
*/
|
|
905
|
+
apiHeaders?: Record<string, string>;
|
|
873
906
|
}
|
|
874
907
|
|
|
875
908
|
export declare interface WidevineInfo {
|
package/dist/index.js
CHANGED
|
@@ -64,6 +64,7 @@ function c(e) {
|
|
|
64
64
|
}
|
|
65
65
|
async function l(e, n) {
|
|
66
66
|
let r = await o(n.credential), i = n.headers ?? new Headers();
|
|
67
|
+
if (n.apiHeaders) for (let [e, t] of Object.entries(n.apiHeaders)) i.has(e) || i.set(e, t);
|
|
67
68
|
i.set("x-api-key", r.apiKey);
|
|
68
69
|
try {
|
|
69
70
|
return await fetch(e, {
|
|
@@ -171,7 +172,8 @@ async function y(e) {
|
|
|
171
172
|
if (!e.matchUrn || typeof e.matchUrn != "string") throw new t("INVALID_URN", 0, "resolveStream: a non-empty matchUrn is required");
|
|
172
173
|
let n = await l(s(e.baseUrl, `/v1/playback/${encodeURIComponent(e.matchUrn)}`), {
|
|
173
174
|
credential: e.credential,
|
|
174
|
-
signal: e.signal
|
|
175
|
+
signal: e.signal,
|
|
176
|
+
apiHeaders: e.apiHeaders
|
|
175
177
|
});
|
|
176
178
|
if (!n.ok) throw await ae(n);
|
|
177
179
|
return S(await n.json(), e.matchUrn);
|
|
@@ -247,7 +249,8 @@ async function C(e) {
|
|
|
247
249
|
let c = await l(a, {
|
|
248
250
|
credential: e.credential,
|
|
249
251
|
signal: e.signal,
|
|
250
|
-
headers: o
|
|
252
|
+
headers: o,
|
|
253
|
+
apiHeaders: e.apiHeaders
|
|
251
254
|
});
|
|
252
255
|
if (c.status === 304) return {
|
|
253
256
|
tournaments: [],
|
|
@@ -287,7 +290,8 @@ async function ce(e) {
|
|
|
287
290
|
let a = await l(r, {
|
|
288
291
|
credential: e.credential,
|
|
289
292
|
signal: e.signal,
|
|
290
|
-
headers: i
|
|
293
|
+
headers: i,
|
|
294
|
+
apiHeaders: e.apiHeaders
|
|
291
295
|
});
|
|
292
296
|
if (a.status === 304) return {
|
|
293
297
|
etag: e.etag,
|
|
@@ -339,7 +343,8 @@ function de(e) {
|
|
|
339
343
|
let u = await l(r, {
|
|
340
344
|
credential: e.credential,
|
|
341
345
|
signal: i.signal,
|
|
342
|
-
headers: a
|
|
346
|
+
headers: a,
|
|
347
|
+
apiHeaders: e.apiHeaders
|
|
343
348
|
});
|
|
344
349
|
if (u.status !== 304) {
|
|
345
350
|
if (!u.ok) throw new t(n(u.status), u.status, `match status request failed (HTTP ${u.status})`);
|
|
@@ -1307,14 +1312,16 @@ var ze = class {
|
|
|
1307
1312
|
if (e && e(this.url, t)) return;
|
|
1308
1313
|
}
|
|
1309
1314
|
let n = this.opts.fetchFn ?? (typeof fetch < "u" ? fetch : void 0);
|
|
1310
|
-
|
|
1315
|
+
if (!n) return;
|
|
1316
|
+
let r = { "content-type": "application/json" };
|
|
1317
|
+
this.opts.apiKey && (r["x-api-key"] = this.opts.apiKey), n(this.url, {
|
|
1311
1318
|
method: "POST",
|
|
1312
|
-
headers:
|
|
1319
|
+
headers: r,
|
|
1313
1320
|
body: t,
|
|
1314
1321
|
keepalive: !0
|
|
1315
1322
|
}).catch(() => {});
|
|
1316
1323
|
}
|
|
1317
|
-
}, Be = "1.
|
|
1324
|
+
}, Be = "1.15.0", W = {
|
|
1318
1325
|
accent: "#E1B600",
|
|
1319
1326
|
accentText: "#1B1C23",
|
|
1320
1327
|
background: "#0e0f13",
|
|
@@ -1790,7 +1797,8 @@ var tt = class {
|
|
|
1790
1797
|
baseUrl: this.opts.baseUrl,
|
|
1791
1798
|
matchUrn: this.opts.matchUrn,
|
|
1792
1799
|
credential: this.opts.credential,
|
|
1793
|
-
signal: this.abort.signal
|
|
1800
|
+
signal: this.abort.signal,
|
|
1801
|
+
apiHeaders: this.opts.apiHeaders
|
|
1794
1802
|
};
|
|
1795
1803
|
}
|
|
1796
1804
|
beginArming(e, t) {
|
|
@@ -1888,32 +1896,33 @@ var tt = class {
|
|
|
1888
1896
|
i(), r.destroy();
|
|
1889
1897
|
return;
|
|
1890
1898
|
}
|
|
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);
|
|
1899
|
+
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
1900
|
}
|
|
1893
|
-
startAnalytics(e, t) {
|
|
1901
|
+
startAnalytics(e, t, n) {
|
|
1894
1902
|
if (this.analyticsSession?.noteDestroyed(), this.analyticsSession = null, this.detachSeekListener?.(), this.opts.analytics === !1) return;
|
|
1895
|
-
let
|
|
1896
|
-
if (!n) return;
|
|
1897
|
-
let r = (typeof this.opts.analytics == "object" ? this.opts.analytics.endpoint : void 0) ?? Re(this.opts.baseUrl);
|
|
1903
|
+
let r = e.analytics?.sid;
|
|
1898
1904
|
if (!r) return;
|
|
1899
|
-
let i = this.opts.
|
|
1900
|
-
|
|
1901
|
-
|
|
1905
|
+
let i = (typeof this.opts.analytics == "object" ? this.opts.analytics.endpoint : void 0) ?? Re(this.opts.baseUrl);
|
|
1906
|
+
if (!i) return;
|
|
1907
|
+
let a = this.opts.video, o = new ze({
|
|
1908
|
+
endpoint: i,
|
|
1909
|
+
sid: r,
|
|
1910
|
+
apiKey: n,
|
|
1902
1911
|
player: t.name === "native" ? "PLAYER_SAFARI_NATIVE" : "PLAYER_HLSJS",
|
|
1903
1912
|
sdkVersion: Be,
|
|
1904
1913
|
sample: () => {
|
|
1905
|
-
let e = this.engine?.getStats() ?? F, t =
|
|
1914
|
+
let e = this.engine?.getStats() ?? F, t = a.buffered.length ? Math.max(0, a.buffered.end(a.buffered.length - 1) - a.currentTime) : 0;
|
|
1906
1915
|
return {
|
|
1907
1916
|
...e,
|
|
1908
1917
|
bufferedMs: Math.round(t * 1e3),
|
|
1909
1918
|
state: this._state,
|
|
1910
|
-
positionMs: Math.round(
|
|
1919
|
+
positionMs: Math.round(a.currentTime * 1e3)
|
|
1911
1920
|
};
|
|
1912
1921
|
}
|
|
1913
1922
|
});
|
|
1914
|
-
this.analyticsSession =
|
|
1915
|
-
let
|
|
1916
|
-
|
|
1923
|
+
this.analyticsSession = o;
|
|
1924
|
+
let s = () => o.noteSeek();
|
|
1925
|
+
a.addEventListener("seeking", s), this.detachSeekListener = () => a.removeEventListener("seeking", s), o.start();
|
|
1917
1926
|
}
|
|
1918
1927
|
createEngine(e, n) {
|
|
1919
1928
|
let r = { ...this.opts.hlsConfig };
|