@vindral/web-sdk 3.4.3 → 4.0.0-100-g47797f66
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/1-7ANhlY.js +312 -0
- package/BgHWk4Cd.js +127 -0
- package/Bozsjl6j.js +6867 -0
- package/Bx7s5QdT.js +35 -0
- package/C80BN8Qb.js +234 -0
- package/Cpe0b7AQ.js +4894 -0
- package/README.md +74 -30
- package/api-client.d.ts +229 -0
- package/api-client.js +4 -0
- package/cast-sender.d.ts +424 -0
- package/cast-sender.js +230 -0
- package/core.d.ts +1503 -0
- package/core.js +13 -0
- package/{index.d.ts → legacy.d.ts} +1007 -862
- package/legacy.es.js +13477 -0
- package/legacy.umd.js +60 -0
- package/package.json +25 -9
- package/player.d.ts +1720 -0
- package/player.js +3839 -0
- package/style.css +1 -1
- package/vindral-player-component.js +2 -0
- package/index.js +0 -7674
- package/index.umd.cjs +0 -59
package/Bx7s5QdT.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var f = Object.defineProperty;
|
|
2
|
+
var o = (n, s, e) => s in n ? f(n, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[s] = e;
|
|
3
|
+
var l = (n, s, e) => o(n, typeof s != "symbol" ? s + "" : s, e);
|
|
4
|
+
class c {
|
|
5
|
+
constructor() {
|
|
6
|
+
l(this, "listeners", {});
|
|
7
|
+
}
|
|
8
|
+
emit(s, e) {
|
|
9
|
+
const i = this.listeners[s];
|
|
10
|
+
i && (this.listeners[s] = i.filter((t) => !t.once), i.map((t) => t.fn(e)).map((t) => typeof t == "function" && (t == null ? void 0 : t())));
|
|
11
|
+
}
|
|
12
|
+
off(s, e) {
|
|
13
|
+
const i = this.listeners[s];
|
|
14
|
+
i && (this.listeners[s] = i.filter((r) => r.fn !== e));
|
|
15
|
+
}
|
|
16
|
+
on(s, e) {
|
|
17
|
+
this.add(s, e, !1);
|
|
18
|
+
}
|
|
19
|
+
once(s, e) {
|
|
20
|
+
this.add(s, e, !0);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Reset the event emitter
|
|
24
|
+
*/
|
|
25
|
+
reset() {
|
|
26
|
+
this.listeners = {};
|
|
27
|
+
}
|
|
28
|
+
add(s, e, i) {
|
|
29
|
+
const r = this.listeners[s], t = { fn: e, once: i };
|
|
30
|
+
r ? r.push(t) : this.listeners[s] = [t];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
c as E
|
|
35
|
+
};
|
package/C80BN8Qb.js
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
var C = Object.defineProperty, R = Object.defineProperties;
|
|
2
|
+
var q = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var y = Object.getOwnPropertySymbols;
|
|
4
|
+
var A = Object.prototype.hasOwnProperty, G = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var b = (e, t, n) => t in e ? C(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, u = (e, t) => {
|
|
6
|
+
for (var n in t || (t = {}))
|
|
7
|
+
A.call(t, n) && b(e, n, t[n]);
|
|
8
|
+
if (y)
|
|
9
|
+
for (var n of y(t))
|
|
10
|
+
G.call(t, n) && b(e, n, t[n]);
|
|
11
|
+
return e;
|
|
12
|
+
}, p = (e, t) => R(e, q(t));
|
|
13
|
+
var d = (e, t, n) => b(e, typeof t != "symbol" ? t + "" : t, n);
|
|
14
|
+
var l = (e, t, n) => new Promise((s, r) => {
|
|
15
|
+
var a = (o) => {
|
|
16
|
+
try {
|
|
17
|
+
c(n.next(o));
|
|
18
|
+
} catch (h) {
|
|
19
|
+
r(h);
|
|
20
|
+
}
|
|
21
|
+
}, i = (o) => {
|
|
22
|
+
try {
|
|
23
|
+
c(n.throw(o));
|
|
24
|
+
} catch (h) {
|
|
25
|
+
r(h);
|
|
26
|
+
}
|
|
27
|
+
}, c = (o) => o.done ? s(o.value) : Promise.resolve(o.value).then(a, i);
|
|
28
|
+
c((n = n.apply(e, t)).next());
|
|
29
|
+
});
|
|
30
|
+
const m = (e) => {
|
|
31
|
+
switch (e) {
|
|
32
|
+
case "h264":
|
|
33
|
+
case "av1":
|
|
34
|
+
return "video";
|
|
35
|
+
case "aac":
|
|
36
|
+
case "opus":
|
|
37
|
+
case "mp3":
|
|
38
|
+
return "audio";
|
|
39
|
+
case "webvtt":
|
|
40
|
+
return "text";
|
|
41
|
+
default:
|
|
42
|
+
throw new Error("Unknown codec");
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
function g(e, t) {
|
|
46
|
+
if (!e)
|
|
47
|
+
throw new Error(t);
|
|
48
|
+
}
|
|
49
|
+
const L = (e) => {
|
|
50
|
+
try {
|
|
51
|
+
return JSON.parse(e);
|
|
52
|
+
} catch (t) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
function P(e) {
|
|
57
|
+
return !(typeof e.edges[0] == "string" || e.channels[0] && !("catalog" in e.channels[0]));
|
|
58
|
+
}
|
|
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") {
|
|
65
|
+
const i = t.samplerate || 0, c = t.channelConfig === "stereo" ? 2 : 1;
|
|
66
|
+
return {
|
|
67
|
+
track: t,
|
|
68
|
+
id: n,
|
|
69
|
+
codec: a,
|
|
70
|
+
codecString: s,
|
|
71
|
+
bitRate: r,
|
|
72
|
+
channels: c,
|
|
73
|
+
sampleRate: i,
|
|
74
|
+
language: t.language
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return m(a) === "text" ? {
|
|
78
|
+
track: t,
|
|
79
|
+
id: n,
|
|
80
|
+
bitRate: 0,
|
|
81
|
+
codec: a,
|
|
82
|
+
kind: "subtitles",
|
|
83
|
+
codecString: s,
|
|
84
|
+
label: t.label,
|
|
85
|
+
language: t.language
|
|
86
|
+
} : (g(t.width, "width is required"), g(t.height, "width is required"), g(t.framerate, "framerate is required"), {
|
|
87
|
+
track: t,
|
|
88
|
+
id: n,
|
|
89
|
+
codec: a,
|
|
90
|
+
bitRate: r,
|
|
91
|
+
codecString: s,
|
|
92
|
+
width: t.width,
|
|
93
|
+
height: t.height,
|
|
94
|
+
frameRate: t.framerate
|
|
95
|
+
});
|
|
96
|
+
}).sort((t, n) => t.bitRate - n.bitRate);
|
|
97
|
+
}
|
|
98
|
+
function I(e) {
|
|
99
|
+
if (e.startsWith("opus"))
|
|
100
|
+
return "opus";
|
|
101
|
+
if (e.startsWith("mp4a"))
|
|
102
|
+
return "aac";
|
|
103
|
+
if (e.startsWith("avc1"))
|
|
104
|
+
return "h264";
|
|
105
|
+
if (e.startsWith("av01"))
|
|
106
|
+
return "av1";
|
|
107
|
+
if (e.startsWith("webvtt"))
|
|
108
|
+
return "webvtt";
|
|
109
|
+
}
|
|
110
|
+
const E = (e) => e ? {
|
|
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), i = H(a) ? a.message : `Url ${s.toString()}, Status code: ${n}, Body: ${r}`;
|
|
116
|
+
super(i);
|
|
117
|
+
d(this, "status");
|
|
118
|
+
d(this, "body");
|
|
119
|
+
d(this, "url");
|
|
120
|
+
this.status = n, this.body = r, this.url = s, Object.setPrototypeOf(this, new.target.prototype);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const S = (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
|
+
}), w = (e, t) => l(void 0, null, function* () {
|
|
129
|
+
return yield (yield $(e, u({}, t))).json();
|
|
130
|
+
}), B = (e, t) => l(void 0, null, function* () {
|
|
131
|
+
return $(e, u({ method: "POST" }, t));
|
|
132
|
+
});
|
|
133
|
+
function W(e) {
|
|
134
|
+
var t;
|
|
135
|
+
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
|
+
}
|
|
137
|
+
const U = {
|
|
138
|
+
lbConnect: (e) => e.channelGroupId ? `connect?channelId=${e.channelId}&channelGroupId=${e.channelGroupId}` : `connect?channelId=${e.channelId}`,
|
|
139
|
+
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
|
+
};
|
|
141
|
+
class J {
|
|
142
|
+
constructor(t) {
|
|
143
|
+
d(this, "baseUrl");
|
|
144
|
+
d(this, "tokenFactory");
|
|
145
|
+
const n = "/api/v4/";
|
|
146
|
+
this.baseUrl = new URL(n, t.publicEndpoint).toString(), this.tokenFactory = t.tokenFactory;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* @ignore
|
|
150
|
+
* Returns everything needed to setup the connection of Vindral instance.
|
|
151
|
+
*/
|
|
152
|
+
connect(t) {
|
|
153
|
+
return l(this, null, function* () {
|
|
154
|
+
const { channelId: n, channelGroupId: s } = t, r = { channelId: n, channelGroupId: s }, a = new URL(U.lbConnect(t), this.baseUrl), i = this.getAuthToken(r), c = yield w(a, { headers: this.getHeaders(i) });
|
|
155
|
+
if (W(c)) {
|
|
156
|
+
const o = c.channels.map((h) => {
|
|
157
|
+
const f = this.toChannel(h, r), v = j(h.catalog);
|
|
158
|
+
return p(u(u({}, h), f), { renditions: v });
|
|
159
|
+
});
|
|
160
|
+
return p(u({}, c), { channels: o });
|
|
161
|
+
} else {
|
|
162
|
+
const o = c.channels.map((h) => {
|
|
163
|
+
const f = this.toChannel(h, r);
|
|
164
|
+
return u(u({}, h), f);
|
|
165
|
+
});
|
|
166
|
+
return p(u({}, c), { channels: o });
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Fetches information regarding a single channel.
|
|
172
|
+
*
|
|
173
|
+
* @param channelId the channel to fetch
|
|
174
|
+
* @returns a [[Channel]] containing information about the requested channel.
|
|
175
|
+
*/
|
|
176
|
+
getChannel(t) {
|
|
177
|
+
return l(this, null, function* () {
|
|
178
|
+
const n = { channelId: t }, s = new URL(`channel/${t}`, this.baseUrl), r = this.getAuthToken(n), a = yield w(s, { headers: this.getHeaders(r) });
|
|
179
|
+
return this.toChannel(a, n, r);
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Fetches channels within a channel group
|
|
184
|
+
*
|
|
185
|
+
* Note: The returned list includes inactive channels - check isLive to filter out only active channels
|
|
186
|
+
*
|
|
187
|
+
* @param channelGroupId the channel group to fetch channels from
|
|
188
|
+
* @returns an array of [[Channel]] that belong to the channel group
|
|
189
|
+
*/
|
|
190
|
+
getChannels(t) {
|
|
191
|
+
return l(this, null, function* () {
|
|
192
|
+
const n = { channelGroupId: t }, s = new URL(`channels/${t}`, this.baseUrl), r = this.getAuthToken(n), a = yield w(s, {
|
|
193
|
+
headers: this.getHeaders(r)
|
|
194
|
+
}), i = Array.isArray(a) ? a : a.channels;
|
|
195
|
+
return this.toChannels(i, n, r);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
getHeaders(t) {
|
|
199
|
+
var s;
|
|
200
|
+
return (s = E(t)) != null ? s : {};
|
|
201
|
+
}
|
|
202
|
+
getAuthToken(t) {
|
|
203
|
+
return this.tokenFactory ? this.tokenFactory(t) : void 0;
|
|
204
|
+
}
|
|
205
|
+
toChannels(t, n, s) {
|
|
206
|
+
return t.map((r) => this.toChannel(r, n, s));
|
|
207
|
+
}
|
|
208
|
+
toChannel(t, n, s) {
|
|
209
|
+
const { baseUrl: r, sizes: a } = t.thumbnail, i = r || new URL(U.thumbnails(n, s), this.baseUrl), c = a.map((o) => new URL(
|
|
210
|
+
`?channelId=${t.channelId}&width=${o.width}&height=${o.height}${F(
|
|
211
|
+
n,
|
|
212
|
+
s
|
|
213
|
+
)}`,
|
|
214
|
+
i
|
|
215
|
+
).toString());
|
|
216
|
+
return {
|
|
217
|
+
channelId: t.channelId,
|
|
218
|
+
name: t.name,
|
|
219
|
+
isLive: t.isLive,
|
|
220
|
+
thumbnailUrls: c
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
const F = (e, t) => t ? e.channelGroupId ? `&channelGroupId=${e.channelGroupId}&auth.token=${t}&auth.type=jwt` : `&auth.token=${t}&auth.type=jwt` : "";
|
|
225
|
+
export {
|
|
226
|
+
J as A,
|
|
227
|
+
g as a,
|
|
228
|
+
S as b,
|
|
229
|
+
j as c,
|
|
230
|
+
m as d,
|
|
231
|
+
P as i,
|
|
232
|
+
B as p,
|
|
233
|
+
L as t
|
|
234
|
+
};
|