@vindral/web-sdk 4.2.0 → 4.2.1

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/CuhQLT-7.js DELETED
@@ -1,254 +0,0 @@
1
- var C = Object.defineProperty, R = Object.defineProperties;
2
- var q = Object.getOwnPropertyDescriptors;
3
- var b = Object.getOwnPropertySymbols;
4
- var A = Object.prototype.hasOwnProperty, O = 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 (b)
9
- for (var n of b(t))
10
- O.call(t, n) && w(e, n, t[n]);
11
- return e;
12
- }, g = (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((r, s) => {
15
- var a = (o) => {
16
- try {
17
- i(n.next(o));
18
- } catch (h) {
19
- s(h);
20
- }
21
- }, c = (o) => {
22
- try {
23
- i(n.throw(o));
24
- } catch (h) {
25
- s(h);
26
- }
27
- }, i = (o) => o.done ? r(o.value) : Promise.resolve(o.value).then(a, c);
28
- i((n = n.apply(e, t)).next());
29
- });
30
- function f(e, t) {
31
- if (!e)
32
- throw new Error(t);
33
- }
34
- const P = (e) => {
35
- try {
36
- return JSON.parse(e);
37
- } catch (t) {
38
- return;
39
- }
40
- }, y = (e) => {
41
- switch (e) {
42
- case "h264":
43
- case "av1":
44
- return "video";
45
- case "aac":
46
- case "opus":
47
- case "mp3":
48
- return "audio";
49
- case "webvtt":
50
- return "text";
51
- default:
52
- throw new Error("Unknown codec");
53
- }
54
- };
55
- function U(e) {
56
- if (e.startsWith("opus"))
57
- return "opus";
58
- if (e.startsWith("mp4a"))
59
- return "aac";
60
- if (e.startsWith("avc1"))
61
- return "h264";
62
- if (e.startsWith("av01"))
63
- return "av1";
64
- if (e.startsWith("webvtt"))
65
- return "webvtt";
66
- }
67
- function J(e) {
68
- return !(typeof e.edges[0] == "string" || e.channels[0] && !("catalog" in e.channels[0]));
69
- }
70
- function j(e) {
71
- return e.tracks.filter((t) => !!t.codec).filter((t) => U(t.codec || "")).map((t, n) => {
72
- const r = t.codec, s = t.bitrate;
73
- f(r, "codec is required"), f(s !== void 0, "bitrate is required");
74
- const a = U(r);
75
- if (f(a, "codec is required"), y(a) === "audio") {
76
- const c = t.samplerate || 0, i = t.channelConfig === "stereo" ? 2 : 1;
77
- return {
78
- track: t,
79
- id: n,
80
- codec: a,
81
- codecString: r,
82
- bitRate: s,
83
- channels: i,
84
- sampleRate: c,
85
- language: t.language
86
- };
87
- }
88
- return y(a) === "text" ? {
89
- track: t,
90
- id: n,
91
- bitRate: 0,
92
- codec: a,
93
- kind: "subtitles",
94
- codecString: r,
95
- label: t.label,
96
- language: t.language
97
- } : (f(t.width, "width is required"), f(t.height, "width is required"), f(t.framerate, "framerate is required"), {
98
- track: t,
99
- id: n,
100
- codec: a,
101
- bitRate: s,
102
- codecString: r,
103
- width: t.width,
104
- height: t.height,
105
- frameRate: t.framerate
106
- });
107
- }).sort((t, n) => t.bitRate - n.bitRate);
108
- }
109
- const L = (e) => e ? {
110
- Authorization: `Bearer ${e}`
111
- } : void 0, G = (e, t) => {
112
- try {
113
- const n = e.ancestorOrigins;
114
- if (n && n.length > 0)
115
- return Array.from(n).join(",") || void 0;
116
- } catch (n) {
117
- }
118
- try {
119
- if (t.referrer)
120
- return new URL(t.referrer).origin || void 0;
121
- } catch (n) {
122
- }
123
- }, E = (e) => typeof e == "object" && e !== null && "message" in e;
124
- class H extends Error {
125
- constructor({ status: n, url: r, body: s }) {
126
- const a = P(s), c = E(a) ? a.message : `Url ${r.toString()}, Status code: ${n}, Body: ${s}`;
127
- super(c);
128
- d(this, "status");
129
- d(this, "body");
130
- d(this, "url");
131
- this.status = n, this.body = s, this.url = r, Object.setPrototypeOf(this, new.target.prototype);
132
- }
133
- }
134
- const M = (e) => typeof e.status == "number", S = () => {
135
- if (!(typeof window == "undefined" || typeof document == "undefined"))
136
- return G(window.location, document);
137
- }, T = (e) => {
138
- const t = S();
139
- if (!t || e.searchParams.has("parentOrigin"))
140
- return e;
141
- const n = new URL(e.toString());
142
- return n.searchParams.append("parentOrigin", t), n;
143
- }, $ = (e, t) => l(null, null, function* () {
144
- const n = T(e), r = yield fetch(n.toString(), u({ mode: "cors" }, t));
145
- if (!r.ok)
146
- throw new H({ status: r.status, url: n, body: yield r.text() });
147
- return r;
148
- }), m = (e, t) => l(null, null, function* () {
149
- return yield (yield $(e, u({}, t))).json();
150
- }), z = (e, t) => l(null, null, function* () {
151
- return $(e, u({ method: "POST" }, t));
152
- });
153
- function W(e) {
154
- var t;
155
- 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");
156
- }
157
- const I = {
158
- lbConnect: (e) => e.channelGroupId ? `connect?channelId=${e.channelId}&channelGroupId=${e.channelGroupId}` : `connect?channelId=${e.channelId}`,
159
- 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"
160
- };
161
- class N {
162
- constructor(t) {
163
- d(this, "baseUrl");
164
- d(this, "tokenFactory");
165
- this.baseUrl = new URL("/api/v4/", t.publicEndpoint).toString(), this.tokenFactory = t.tokenFactory;
166
- }
167
- /**
168
- * @ignore
169
- * Returns everything needed to setup the connection of Vindral instance.
170
- */
171
- connect(t) {
172
- return l(this, null, function* () {
173
- 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) });
174
- if (W(i)) {
175
- const o = i.channels.map((h) => {
176
- const p = this.toChannel(h, s), v = j(h.catalog);
177
- return g(u(u({}, h), p), { renditions: v });
178
- });
179
- return g(u({}, i), { channels: o });
180
- } else {
181
- const o = i.channels.map((h) => {
182
- const p = this.toChannel(h, s);
183
- return u(u({}, h), p);
184
- });
185
- return g(u({}, i), { channels: o });
186
- }
187
- });
188
- }
189
- /**
190
- * Fetches information regarding a single channel.
191
- *
192
- * @param channelId the channel to fetch
193
- * @returns a [[Channel]] containing information about the requested channel.
194
- */
195
- getChannel(t) {
196
- return l(this, null, function* () {
197
- const n = { channelId: t }, r = new URL(`channel/${t}`, this.baseUrl), s = this.getAuthToken(n), a = yield m(r, { headers: this.getHeaders(s) });
198
- return this.toChannel(a, n, s);
199
- });
200
- }
201
- /**
202
- * Fetches channels within a channel group
203
- *
204
- * Note: The returned list includes inactive channels - check isLive to filter out only active channels
205
- *
206
- * @param channelGroupId the channel group to fetch channels from
207
- * @returns an array of [[Channel]] that belong to the channel group
208
- */
209
- getChannels(t) {
210
- return l(this, null, function* () {
211
- const n = { channelGroupId: t }, r = new URL(`channels/${t}`, this.baseUrl), s = this.getAuthToken(n), a = yield m(r, {
212
- headers: this.getHeaders(s)
213
- }), c = Array.isArray(a) ? a : a.channels;
214
- return this.toChannels(c, n, s);
215
- });
216
- }
217
- getHeaders(t) {
218
- var r;
219
- return (r = L(t)) != null ? r : {};
220
- }
221
- getAuthToken(t) {
222
- return this.tokenFactory ? this.tokenFactory(t) : void 0;
223
- }
224
- toChannels(t, n, r) {
225
- return t.map((s) => this.toChannel(s, n, r));
226
- }
227
- toChannel(t, n, r) {
228
- const { baseUrl: s, sizes: a } = t.thumbnail, c = s || new URL(I.thumbnails(n, r), this.baseUrl), i = a.map((o) => new URL(
229
- `?channelId=${t.channelId}&width=${o.width}&height=${o.height}${F(
230
- n,
231
- r
232
- )}`,
233
- c
234
- ).toString());
235
- return {
236
- channelId: t.channelId,
237
- name: t.name,
238
- isLive: t.isLive,
239
- thumbnailUrls: i
240
- };
241
- }
242
- }
243
- const F = (e, t) => t ? e.channelGroupId ? `&channelGroupId=${e.channelGroupId}&auth.token=${t}&auth.type=jwt` : `&auth.token=${t}&auth.type=jwt` : "";
244
- export {
245
- N as A,
246
- f as a,
247
- j as b,
248
- U as c,
249
- M as d,
250
- y as e,
251
- J as i,
252
- z as p,
253
- P as t
254
- };