@vindral/web-sdk 4.0.0 → 4.1.0-1-g31205a30
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/BojTkNPM.js +11797 -0
- package/{BTxJOjm9.js → Bx7s5QdT.js} +3 -0
- package/{BzSm3HsC.js → Cxs0dJcY.js} +1 -1
- package/api-client.d.ts +121 -42
- package/api-client.js +1 -1
- package/cast-sender.d.ts +34 -6
- package/cast-sender.js +1 -1
- package/core.d.ts +489 -345
- package/core.js +4 -5
- package/{C291RiDK.js → ez5LtZtE.js} +1 -1
- package/hRzek83o.js +234 -0
- package/legacy.d.ts +499 -355
- package/legacy.es.js +10199 -4366
- package/legacy.umd.js +9 -8
- package/package.json +5 -1
- package/player.d.ts +596 -354
- package/player.js +2078 -1421
- package/react.d.ts +1855 -0
- package/react.js +1 -0
- package/style.css +1 -1
- package/B7jz034g.js +0 -147
- package/DwDXQwR0.js +0 -6037
package/hRzek83o.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 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
|
+
for (var n in t || (t = {}))
|
|
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]);
|
|
11
|
+
return e;
|
|
12
|
+
}, p = (e, t) => R(e, q(t));
|
|
13
|
+
var d = (e, t, n) => w(e, typeof t != "symbol" ? t + "" : t, n);
|
|
14
|
+
var l = (e, t, n) => new Promise((s, r) => {
|
|
15
|
+
var a = (o) => {
|
|
16
|
+
try {
|
|
17
|
+
i(n.next(o));
|
|
18
|
+
} catch (h) {
|
|
19
|
+
r(h);
|
|
20
|
+
}
|
|
21
|
+
}, c = (o) => {
|
|
22
|
+
try {
|
|
23
|
+
i(n.throw(o));
|
|
24
|
+
} catch (h) {
|
|
25
|
+
r(h);
|
|
26
|
+
}
|
|
27
|
+
}, i = (o) => o.done ? s(o.value) : Promise.resolve(o.value).then(a, c);
|
|
28
|
+
i((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 S(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 c = t.samplerate || 0, i = t.channelConfig === "stereo" ? 2 : 1;
|
|
66
|
+
return {
|
|
67
|
+
track: t,
|
|
68
|
+
id: n,
|
|
69
|
+
codec: a,
|
|
70
|
+
codecString: s,
|
|
71
|
+
bitRate: r,
|
|
72
|
+
channels: i,
|
|
73
|
+
sampleRate: c,
|
|
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), c = H(a) ? a.message : `Url ${s.toString()}, Status code: ${n}, Body: ${r}`;
|
|
116
|
+
super(c);
|
|
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 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* () {
|
|
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
|
+
this.baseUrl = new URL("/api/v4/", t.publicEndpoint).toString(), this.tokenFactory = t.tokenFactory;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* @ignore
|
|
149
|
+
* Returns everything needed to setup the connection of Vindral instance.
|
|
150
|
+
*/
|
|
151
|
+
connect(t) {
|
|
152
|
+
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) });
|
|
154
|
+
if (W(i)) {
|
|
155
|
+
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 });
|
|
158
|
+
});
|
|
159
|
+
return p(u({}, i), { channels: o });
|
|
160
|
+
} else {
|
|
161
|
+
const o = i.channels.map((h) => {
|
|
162
|
+
const f = this.toChannel(h, r);
|
|
163
|
+
return u(u({}, h), f);
|
|
164
|
+
});
|
|
165
|
+
return p(u({}, i), { channels: o });
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Fetches information regarding a single channel.
|
|
171
|
+
*
|
|
172
|
+
* @param channelId the channel to fetch
|
|
173
|
+
* @returns a [[Channel]] containing information about the requested channel.
|
|
174
|
+
*/
|
|
175
|
+
getChannel(t) {
|
|
176
|
+
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);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Fetches channels within a channel group
|
|
183
|
+
*
|
|
184
|
+
* Note: The returned list includes inactive channels - check isLive to filter out only active channels
|
|
185
|
+
*
|
|
186
|
+
* @param channelGroupId the channel group to fetch channels from
|
|
187
|
+
* @returns an array of [[Channel]] that belong to the channel group
|
|
188
|
+
*/
|
|
189
|
+
getChannels(t) {
|
|
190
|
+
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)
|
|
193
|
+
}), c = Array.isArray(a) ? a : a.channels;
|
|
194
|
+
return this.toChannels(c, n, r);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
getHeaders(t) {
|
|
198
|
+
var s;
|
|
199
|
+
return (s = E(t)) != null ? s : {};
|
|
200
|
+
}
|
|
201
|
+
getAuthToken(t) {
|
|
202
|
+
return this.tokenFactory ? this.tokenFactory(t) : void 0;
|
|
203
|
+
}
|
|
204
|
+
toChannels(t, n, s) {
|
|
205
|
+
return t.map((r) => this.toChannel(r, n, s));
|
|
206
|
+
}
|
|
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(
|
|
209
|
+
`?channelId=${t.channelId}&width=${o.width}&height=${o.height}${F(
|
|
210
|
+
n,
|
|
211
|
+
s
|
|
212
|
+
)}`,
|
|
213
|
+
c
|
|
214
|
+
).toString());
|
|
215
|
+
return {
|
|
216
|
+
channelId: t.channelId,
|
|
217
|
+
name: t.name,
|
|
218
|
+
isLive: t.isLive,
|
|
219
|
+
thumbnailUrls: i
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
const F = (e, t) => t ? e.channelGroupId ? `&channelGroupId=${e.channelGroupId}&auth.token=${t}&auth.type=jwt` : `&auth.token=${t}&auth.type=jwt` : "";
|
|
224
|
+
export {
|
|
225
|
+
J as A,
|
|
226
|
+
g as a,
|
|
227
|
+
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
|
|
234
|
+
};
|