@vindral/web-sdk 4.1.2 → 4.1.3-2-g8484afe9

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,33 +1,33 @@
1
1
  var C = Object.defineProperty, R = Object.defineProperties;
2
2
  var q = Object.getOwnPropertyDescriptors;
3
- var y = Object.getOwnPropertySymbols;
4
- var A = Object.prototype.hasOwnProperty, G = Object.prototype.propertyIsEnumerable;
3
+ var b = Object.getOwnPropertySymbols;
4
+ var A = Object.prototype.hasOwnProperty, O = Object.prototype.propertyIsEnumerable;
5
5
  var w = (e, t, n) => t in e ? C(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, u = (e, t) => {
6
6
  for (var n in t || (t = {}))
7
7
  A.call(t, n) && w(e, n, t[n]);
8
- if (y)
9
- for (var n of y(t))
10
- G.call(t, n) && w(e, n, t[n]);
8
+ if (b)
9
+ for (var n of b(t))
10
+ O.call(t, n) && w(e, n, t[n]);
11
11
  return e;
12
- }, p = (e, t) => R(e, q(t));
12
+ }, g = (e, t) => R(e, q(t));
13
13
  var d = (e, t, n) => w(e, typeof t != "symbol" ? t + "" : t, n);
14
- var l = (e, t, n) => new Promise((s, r) => {
14
+ var l = (e, t, n) => new Promise((r, s) => {
15
15
  var a = (o) => {
16
16
  try {
17
17
  i(n.next(o));
18
18
  } catch (h) {
19
- r(h);
19
+ s(h);
20
20
  }
21
21
  }, c = (o) => {
22
22
  try {
23
23
  i(n.throw(o));
24
24
  } catch (h) {
25
- r(h);
25
+ s(h);
26
26
  }
27
- }, i = (o) => o.done ? s(o.value) : Promise.resolve(o.value).then(a, c);
27
+ }, i = (o) => o.done ? r(o.value) : Promise.resolve(o.value).then(a, c);
28
28
  i((n = n.apply(e, t)).next());
29
29
  });
30
- const m = (e) => {
30
+ const y = (e) => {
31
31
  switch (e) {
32
32
  case "h264":
33
33
  case "av1":
@@ -42,60 +42,60 @@ const m = (e) => {
42
42
  throw new Error("Unknown codec");
43
43
  }
44
44
  };
45
- function g(e, t) {
45
+ function f(e, t) {
46
46
  if (!e)
47
47
  throw new Error(t);
48
48
  }
49
- const L = (e) => {
49
+ const P = (e) => {
50
50
  try {
51
51
  return JSON.parse(e);
52
52
  } catch (t) {
53
53
  return;
54
54
  }
55
55
  };
56
- function S(e) {
56
+ function J(e) {
57
57
  return !(typeof e.edges[0] == "string" || e.channels[0] && !("catalog" in e.channels[0]));
58
58
  }
59
59
  function j(e) {
60
- return e.tracks.filter((t) => !!t.codec).filter((t) => I(t.codec || "")).map((t, n) => {
61
- const s = t.codec, r = t.bitrate;
62
- g(s, "codec is required"), g(r != null, "bitrate is required");
63
- const a = I(s);
64
- if (g(a, "codec is required"), m(a) === "audio") {
60
+ return e.tracks.filter((t) => !!t.codec).filter((t) => U(t.codec || "")).map((t, n) => {
61
+ const r = t.codec, s = t.bitrate;
62
+ f(r, "codec is required"), f(s != null, "bitrate is required");
63
+ const a = U(r);
64
+ if (f(a, "codec is required"), y(a) === "audio") {
65
65
  const c = t.samplerate || 0, i = t.channelConfig === "stereo" ? 2 : 1;
66
66
  return {
67
67
  track: t,
68
68
  id: n,
69
69
  codec: a,
70
- codecString: s,
71
- bitRate: r,
70
+ codecString: r,
71
+ bitRate: s,
72
72
  channels: i,
73
73
  sampleRate: c,
74
74
  language: t.language
75
75
  };
76
76
  }
77
- return m(a) === "text" ? {
77
+ return y(a) === "text" ? {
78
78
  track: t,
79
79
  id: n,
80
80
  bitRate: 0,
81
81
  codec: a,
82
82
  kind: "subtitles",
83
- codecString: s,
83
+ codecString: r,
84
84
  label: t.label,
85
85
  language: t.language
86
- } : (g(t.width, "width is required"), g(t.height, "width is required"), g(t.framerate, "framerate is required"), {
86
+ } : (f(t.width, "width is required"), f(t.height, "width is required"), f(t.framerate, "framerate is required"), {
87
87
  track: t,
88
88
  id: n,
89
89
  codec: a,
90
- bitRate: r,
91
- codecString: s,
90
+ bitRate: s,
91
+ codecString: r,
92
92
  width: t.width,
93
93
  height: t.height,
94
94
  frameRate: t.framerate
95
95
  });
96
96
  }).sort((t, n) => t.bitRate - n.bitRate);
97
97
  }
98
- function I(e) {
98
+ function U(e) {
99
99
  if (e.startsWith("opus"))
100
100
  return "opus";
101
101
  if (e.startsWith("mp4a"))
@@ -107,38 +107,59 @@ function I(e) {
107
107
  if (e.startsWith("webvtt"))
108
108
  return "webvtt";
109
109
  }
110
- const E = (e) => e ? {
110
+ const L = (e) => e ? {
111
111
  Authorization: `Bearer ${e}`
112
- } : void 0, H = (e) => typeof e == "object" && e !== null && "message" in e;
113
- class T extends Error {
114
- constructor({ status: n, url: s, body: r }) {
115
- const a = L(r), c = H(a) ? a.message : `Url ${s.toString()}, Status code: ${n}, Body: ${r}`;
112
+ } : void 0, G = (e, t) => {
113
+ try {
114
+ const n = e.ancestorOrigins;
115
+ if (n && n.length > 0)
116
+ return Array.from(n).join(",") || void 0;
117
+ } catch (n) {
118
+ }
119
+ try {
120
+ if (t.referrer)
121
+ return new URL(t.referrer).origin || void 0;
122
+ } catch (n) {
123
+ }
124
+ }, E = (e) => typeof e == "object" && e !== null && "message" in e;
125
+ class H extends Error {
126
+ constructor({ status: n, url: r, body: s }) {
127
+ const a = P(s), c = E(a) ? a.message : `Url ${r.toString()}, Status code: ${n}, Body: ${s}`;
116
128
  super(c);
117
129
  d(this, "status");
118
130
  d(this, "body");
119
131
  d(this, "url");
120
- this.status = n, this.body = r, this.url = s, Object.setPrototypeOf(this, new.target.prototype);
132
+ this.status = n, this.body = s, this.url = r, Object.setPrototypeOf(this, new.target.prototype);
121
133
  }
122
134
  }
123
- const P = (e) => typeof e.status == "number", $ = (e, t) => l(void 0, null, function* () {
124
- const n = yield fetch(e.toString(), u({ mode: "cors" }, t));
125
- if (!n.ok)
126
- throw new T({ status: n.status, url: e, body: yield n.text() });
127
- return n;
128
- }), b = (e, t) => l(void 0, null, function* () {
135
+ const M = (e) => typeof e.status == "number", S = () => {
136
+ if (!(typeof window == "undefined" || typeof document == "undefined"))
137
+ return G(window.location, document);
138
+ }, T = (e) => {
139
+ const t = S();
140
+ if (!t || e.searchParams.has("parentOrigin"))
141
+ return e;
142
+ const n = new URL(e.toString());
143
+ return n.searchParams.append("parentOrigin", t), n;
144
+ }, $ = (e, t) => l(null, null, function* () {
145
+ const n = T(e), r = yield fetch(n.toString(), u({ mode: "cors" }, t));
146
+ if (!r.ok)
147
+ throw new H({ status: r.status, url: n, body: yield r.text() });
148
+ return r;
149
+ }), m = (e, t) => l(null, null, function* () {
129
150
  return yield (yield $(e, u({}, t))).json();
130
- }), B = (e, t) => l(void 0, null, function* () {
151
+ }), z = (e, t) => l(null, null, function* () {
131
152
  return $(e, u({ method: "POST" }, t));
132
153
  });
133
154
  function W(e) {
134
155
  var t;
135
156
  return !(typeof e.edges[0] == "string" || e.channels[0] && "catalog" in e.channels[0] && typeof ((t = e.channels[0]) == null ? void 0 : t.catalog) == "undefined");
136
157
  }
137
- const U = {
158
+ const I = {
138
159
  lbConnect: (e) => e.channelGroupId ? `connect?channelId=${e.channelId}&channelGroupId=${e.channelGroupId}` : `connect?channelId=${e.channelId}`,
139
160
  thumbnails: (e, t) => t ? e.channelGroupId ? `thumbnail/?channelGroupId=${e.channelGroupId}&auth.token=${t}&auth.type=jwt` : e.channelId ? `thumbnail/?channelId=${e.channelId}&auth.token=${t}&auth.type=jwt` : "thumbnail" : "thumbnail"
140
161
  };
141
- class J {
162
+ class N {
142
163
  constructor(t) {
143
164
  d(this, "baseUrl");
144
165
  d(this, "tokenFactory");
@@ -150,19 +171,19 @@ class J {
150
171
  */
151
172
  connect(t) {
152
173
  return l(this, null, function* () {
153
- const { channelId: n, channelGroupId: s } = t, r = { channelId: n, channelGroupId: s }, a = new URL(U.lbConnect(t), this.baseUrl), c = this.getAuthToken(r), i = yield b(a, { headers: this.getHeaders(c) });
174
+ const { channelId: n, channelGroupId: r } = t, s = { channelId: n, channelGroupId: r }, a = new URL(I.lbConnect(t), this.baseUrl), c = this.getAuthToken(s), i = yield m(a, { headers: this.getHeaders(c) });
154
175
  if (W(i)) {
155
176
  const o = i.channels.map((h) => {
156
- const f = this.toChannel(h, r), v = j(h.catalog);
157
- return p(u(u({}, h), f), { renditions: v });
177
+ const p = this.toChannel(h, s), v = j(h.catalog);
178
+ return g(u(u({}, h), p), { renditions: v });
158
179
  });
159
- return p(u({}, i), { channels: o });
180
+ return g(u({}, i), { channels: o });
160
181
  } else {
161
182
  const o = i.channels.map((h) => {
162
- const f = this.toChannel(h, r);
163
- return u(u({}, h), f);
183
+ const p = this.toChannel(h, s);
184
+ return u(u({}, h), p);
164
185
  });
165
- return p(u({}, i), { channels: o });
186
+ return g(u({}, i), { channels: o });
166
187
  }
167
188
  });
168
189
  }
@@ -174,8 +195,8 @@ class J {
174
195
  */
175
196
  getChannel(t) {
176
197
  return l(this, null, function* () {
177
- const n = { channelId: t }, s = new URL(`channel/${t}`, this.baseUrl), r = this.getAuthToken(n), a = yield b(s, { headers: this.getHeaders(r) });
178
- return this.toChannel(a, n, r);
198
+ const n = { channelId: t }, r = new URL(`channel/${t}`, this.baseUrl), s = this.getAuthToken(n), a = yield m(r, { headers: this.getHeaders(s) });
199
+ return this.toChannel(a, n, s);
179
200
  });
180
201
  }
181
202
  /**
@@ -188,27 +209,27 @@ class J {
188
209
  */
189
210
  getChannels(t) {
190
211
  return l(this, null, function* () {
191
- const n = { channelGroupId: t }, s = new URL(`channels/${t}`, this.baseUrl), r = this.getAuthToken(n), a = yield b(s, {
192
- headers: this.getHeaders(r)
212
+ const n = { channelGroupId: t }, r = new URL(`channels/${t}`, this.baseUrl), s = this.getAuthToken(n), a = yield m(r, {
213
+ headers: this.getHeaders(s)
193
214
  }), c = Array.isArray(a) ? a : a.channels;
194
- return this.toChannels(c, n, r);
215
+ return this.toChannels(c, n, s);
195
216
  });
196
217
  }
197
218
  getHeaders(t) {
198
- var s;
199
- return (s = E(t)) != null ? s : {};
219
+ var r;
220
+ return (r = L(t)) != null ? r : {};
200
221
  }
201
222
  getAuthToken(t) {
202
223
  return this.tokenFactory ? this.tokenFactory(t) : void 0;
203
224
  }
204
- toChannels(t, n, s) {
205
- return t.map((r) => this.toChannel(r, n, s));
225
+ toChannels(t, n, r) {
226
+ return t.map((s) => this.toChannel(s, n, r));
206
227
  }
207
- toChannel(t, n, s) {
208
- const { baseUrl: r, sizes: a } = t.thumbnail, c = r || new URL(U.thumbnails(n, s), this.baseUrl), i = a.map((o) => new URL(
228
+ toChannel(t, n, r) {
229
+ const { baseUrl: s, sizes: a } = t.thumbnail, c = s || new URL(I.thumbnails(n, r), this.baseUrl), i = a.map((o) => new URL(
209
230
  `?channelId=${t.channelId}&width=${o.width}&height=${o.height}${F(
210
231
  n,
211
- s
232
+ r
212
233
  )}`,
213
234
  c
214
235
  ).toString());
@@ -222,13 +243,13 @@ class J {
222
243
  }
223
244
  const F = (e, t) => t ? e.channelGroupId ? `&channelGroupId=${e.channelGroupId}&auth.token=${t}&auth.type=jwt` : `&auth.token=${t}&auth.type=jwt` : "";
224
245
  export {
225
- J as A,
226
- g as a,
246
+ N as A,
247
+ f as a,
227
248
  j as b,
228
- I as c,
229
- P as d,
230
- m as e,
231
- S as i,
232
- B as p,
233
- L as t
249
+ U as c,
250
+ M as d,
251
+ y as e,
252
+ J as i,
253
+ z as p,
254
+ P as t
234
255
  };
@@ -27,10 +27,10 @@ var X = (B, g, A) => new Promise((J, k) => {
27
27
  }, o = (h) => h.done ? J(h.value) : Promise.resolve(h.value).then(y, a);
28
28
  o((A = A.apply(B, g)).next());
29
29
  });
30
- import { F as RA, d as JA, n as kA } from "./ZD9OGvpf.js";
31
- var hA = function() {
30
+ import { F as RA, d as JA, n as kA } from "./mOp16Cow.js";
31
+ var hA = (function() {
32
32
  var B = typeof document != "undefined" && document.currentScript ? document.currentScript.src : void 0;
33
- return function(g) {
33
+ return (function(g) {
34
34
  g = g || {};
35
35
  var A;
36
36
  A || (A = typeof g != "undefined" ? g : {});
@@ -175,7 +175,7 @@ var hA = function() {
175
175
  } catch (Q) {
176
176
  return S("Module.instantiateWasm callback failed with error: " + Q), !1;
177
177
  }
178
- return function() {
178
+ return (function() {
179
179
  return L || typeof WebAssembly.instantiateStreaming != "function" || V(s) || typeof fetch != "function" ? i(C) : fetch(s, { credentials: "same-origin" }).then(function(Q) {
180
180
  return WebAssembly.instantiateStreaming(Q, G).then(
181
181
  C,
@@ -184,7 +184,7 @@ var hA = function() {
184
184
  }
185
185
  );
186
186
  });
187
- }().catch(k), {};
187
+ })().catch(k), {};
188
188
  })(), A.___wasm_call_ctors = function() {
189
189
  return (A.___wasm_call_ctors = A.asm.h).apply(null, arguments);
190
190
  }, A._opus_decoder_create = function() {
@@ -223,8 +223,8 @@ var hA = function() {
223
223
  }
224
224
  if (A.run = l, A.preInit) for (typeof A.preInit == "function" && (A.preInit = [A.preInit]); 0 < A.preInit.length; ) A.preInit.pop()();
225
225
  return l(), g.ready;
226
- };
227
- }(), QA = /* @__PURE__ */ ((B) => (B[B.OK = 0] = "OK", B[B["Bad argument"] = -1] = "Bad argument", B[B["Buffer too small"] = -2] = "Buffer too small", B[B["Internal error"] = -3] = "Internal error", B[B["Invalid packet"] = -4] = "Invalid packet", B[B.Unimplemented = -5] = "Unimplemented", B[B["Invalid state"] = -6] = "Invalid state", B[B["Memory allocation fail"] = -7] = "Memory allocation fail", B))(QA || {});
226
+ });
227
+ })(), QA = /* @__PURE__ */ ((B) => (B[B.OK = 0] = "OK", B[B["Bad argument"] = -1] = "Bad argument", B[B["Buffer too small"] = -2] = "Buffer too small", B[B["Internal error"] = -3] = "Internal error", B[B["Invalid packet"] = -4] = "Invalid packet", B[B.Unimplemented = -5] = "Unimplemented", B[B["Invalid state"] = -6] = "Invalid state", B[B["Memory allocation fail"] = -7] = "Memory allocation fail", B))(QA || {});
228
228
  const w = class w {
229
229
  constructor(g, A, J) {
230
230
  // = 120ms
@@ -265,7 +265,7 @@ const w = class w {
265
265
  );
266
266
  }
267
267
  };
268
- E(w, "MAX_OPUS_BUFFER", 1e3 * 1e3), E(w, "MAX_SAMPLES", 6 * 960), E(w, "create", (g, A) => X(w, null, function* () {
268
+ E(w, "MAX_OPUS_BUFFER", 1e3 * 1e3), E(w, "MAX_SAMPLES", 6 * 960), E(w, "create", (g, A) => X(null, null, function* () {
269
269
  return new w(yield hA(), g, A);
270
270
  }));
271
271
  let m = w;
@@ -303,7 +303,7 @@ const d = class d {
303
303
  return this.errors.pop();
304
304
  }
305
305
  };
306
- E(d, "create", (g, A) => X(d, null, function* () {
306
+ E(d, "create", (g, A) => X(null, null, function* () {
307
307
  return new d(yield m.create(g, A));
308
308
  }));
309
309
  let BA = d;
package/api-client.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as o } from "./hRzek83o.js";
1
+ import { A as o } from "./Bs3ZbgIy.js";
2
2
  export {
3
3
  o as ApiClient
4
4
  };
package/core.d.ts CHANGED
@@ -1103,11 +1103,20 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1103
1103
  */
1104
1104
  get channelCurrentTime(): number;
1105
1105
  /**
1106
- * The current target buffer time in milliseconds
1106
+ * The current target buffer time in milliseconds.
1107
+ *
1108
+ * Initially, this will always be equal to `minBufferTime`.
1109
+ * Only when using a separate `maxBufferTime`, the `targetBufferTime` will be able to vary between min and max.
1110
+ *
1107
1111
  */
1108
1112
  get targetBufferTime(): number;
1109
1113
  /**
1110
- * Set the current target buffer time in milliseconds
1114
+ * Set the current target buffer time in milliseconds.
1115
+ *
1116
+ * Note that setting this will not respect min/max buffer time values.
1117
+ * For instance with `{ minBufferTime: 500, maxBufferTime: 3000 }, you can still set `targetBufferTime` to 100 ms.`
1118
+ * The dynamic buffer will still work in respect to the originally set values when needed. Therefore we recommend
1119
+ * setting targetBufferTime within that range for consistancy if using both min/max.
1111
1120
  */
1112
1121
  set targetBufferTime(bufferTimeMs: number);
1113
1122
  /**
package/core.js CHANGED
@@ -1,4 +1,4 @@
1
- import { b as C, c as I, e as _, f as O, C as D, D as T, I as a, N as A, V as s, g as r } from "./ZD9OGvpf.js";
1
+ import { c as C, e as I, f as _, a as O, C as D, D as T, I as a, N as A, V as s, g as r } from "./mOp16Cow.js";
2
2
  export {
3
3
  C as AUTHENTICATION_EXPIRED_CODE,
4
4
  I as AUTHENTICATION_FAILED_CODE,
package/legacy.d.ts CHANGED
@@ -1118,11 +1118,20 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1118
1118
  */
1119
1119
  get channelCurrentTime(): number;
1120
1120
  /**
1121
- * The current target buffer time in milliseconds
1121
+ * The current target buffer time in milliseconds.
1122
+ *
1123
+ * Initially, this will always be equal to `minBufferTime`.
1124
+ * Only when using a separate `maxBufferTime`, the `targetBufferTime` will be able to vary between min and max.
1125
+ *
1122
1126
  */
1123
1127
  get targetBufferTime(): number;
1124
1128
  /**
1125
- * Set the current target buffer time in milliseconds
1129
+ * Set the current target buffer time in milliseconds.
1130
+ *
1131
+ * Note that setting this will not respect min/max buffer time values.
1132
+ * For instance with `{ minBufferTime: 500, maxBufferTime: 3000 }, you can still set `targetBufferTime` to 100 ms.`
1133
+ * The dynamic buffer will still work in respect to the originally set values when needed. Therefore we recommend
1134
+ * setting targetBufferTime within that range for consistancy if using both min/max.
1126
1135
  */
1127
1136
  set targetBufferTime(bufferTimeMs: number);
1128
1137
  /**
@@ -1818,10 +1827,11 @@ export interface PlayerOptions {
1818
1827
  * Represents a Vindral player
1819
1828
  *
1820
1829
  * ```typescript
1821
- * // minimal configuration of a Vindral web player
1830
+ * // example configuration of a Vindral web player
1822
1831
  * const instance = new Player({
1823
1832
  * url: "https://lb.cdn.vindral.com",
1824
1833
  * channelId: "vindral_demo1_ci_099ee1fa-80f3-455e-aa23-3d184e93e04f",
1834
+ * minBufferTime: 1000,
1825
1835
  * })
1826
1836
  * ```
1827
1837
  */