@vindral/web-sdk 3.4.4 → 4.0.0-191-g9f7294ed
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/1PRs0vho.js +127 -0
- package/AXCpqROO.js +4311 -0
- package/B-HFfmiu.js +6783 -0
- package/BTxJOjm9.js +32 -0
- package/CayXch2-.js +312 -0
- package/F-U5JXpv.js +231 -0
- package/README.md +74 -30
- package/api-client.d.ts +217 -0
- package/api-client.js +4 -0
- package/cast-sender.d.ts +410 -0
- package/cast-sender.js +230 -0
- package/core.d.ts +1444 -0
- package/core.js +14 -0
- package/{index.d.ts → legacy.d.ts} +794 -716
- package/legacy.es.js +12805 -0
- package/legacy.umd.js +60 -0
- package/package.json +25 -9
- package/player.d.ts +1691 -0
- package/player.js +3784 -0
- package/vindral-player-component.js +2 -0
- package/index.js +0 -7716
- package/index.umd.cjs +0 -59
package/AXCpqROO.js
ADDED
|
@@ -0,0 +1,4311 @@
|
|
|
1
|
+
var ko = Object.create;
|
|
2
|
+
var ir = Object.defineProperty, Io = Object.defineProperties, So = Object.getOwnPropertyDescriptor, Uo = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var qi = Object.getOwnPropertySymbols;
|
|
4
|
+
var Yr = Object.prototype.hasOwnProperty, Jr = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var pt = (i, t) => (t = Symbol[i]) ? t : Symbol.for("Symbol." + i), Et = (i) => {
|
|
6
|
+
throw TypeError(i);
|
|
7
|
+
};
|
|
8
|
+
var _i = (i, t, e) => t in i ? ir(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, Yt = (i, t) => {
|
|
9
|
+
for (var e in t || (t = {}))
|
|
10
|
+
Yr.call(t, e) && _i(i, e, t[e]);
|
|
11
|
+
if (qi)
|
|
12
|
+
for (var e of qi(t))
|
|
13
|
+
Jr.call(t, e) && _i(i, e, t[e]);
|
|
14
|
+
return i;
|
|
15
|
+
}, nr = (i, t) => Io(i, Uo(t)), Zr = (i, t) => ir(i, "name", { value: t, configurable: !0 });
|
|
16
|
+
var Kr = (i, t) => {
|
|
17
|
+
var e = {};
|
|
18
|
+
for (var n in i)
|
|
19
|
+
Yr.call(i, n) && t.indexOf(n) < 0 && (e[n] = i[n]);
|
|
20
|
+
if (i != null && qi)
|
|
21
|
+
for (var n of qi(i))
|
|
22
|
+
t.indexOf(n) < 0 && Jr.call(i, n) && (e[n] = i[n]);
|
|
23
|
+
return e;
|
|
24
|
+
};
|
|
25
|
+
var Ve = (i) => {
|
|
26
|
+
var t;
|
|
27
|
+
return [, , , ko((t = i == null ? void 0 : i[pt("metadata")]) != null ? t : null)];
|
|
28
|
+
}, Qr = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], Ds = (i) => i !== void 0 && typeof i != "function" ? Et("Function expected") : i, To = (i, t, e, n, r) => ({ kind: Qr[i], name: t, metadata: n, addInitializer: (a) => e._ ? Et("Already initialized") : r.push(Ds(a || null)) }), Jt = (i, t) => _i(t, pt("metadata"), i[3]), Ce = (i, t, e, n) => {
|
|
29
|
+
for (var r = 0, a = i[t >> 1], c = a && a.length; r < c; r++) t & 1 ? a[r].call(e) : n = a[r].call(e, n);
|
|
30
|
+
return n;
|
|
31
|
+
}, X = (i, t, e, n, r, a) => {
|
|
32
|
+
var c, d, f, p, b, m = t & 7, I = !!(t & 8), y = !!(t & 16), E = m > 3 ? i.length + 1 : m ? I ? 1 : 2 : 0, P = Qr[m + 5], H = m > 3 && (i[E - 1] = []), T = i[E] || (i[E] = []), g = m && (!y && !I && (r = r.prototype), m < 5 && (m > 3 || !y) && So(m < 4 ? r : { get [e]() {
|
|
33
|
+
return s(this, a);
|
|
34
|
+
}, set [e](S) {
|
|
35
|
+
return u(this, a, S);
|
|
36
|
+
} }, e));
|
|
37
|
+
m ? y && m < 4 && Zr(a, (m > 2 ? "set " : m > 1 ? "get " : "") + e) : Zr(r, e);
|
|
38
|
+
for (var Y = n.length - 1; Y >= 0; Y--)
|
|
39
|
+
p = To(m, e, f = {}, i[3], T), m && (p.static = I, p.private = y, b = p.access = { has: y ? (S) => Eo(r, S) : (S) => e in S }, m ^ 3 && (b.get = y ? (S) => (m ^ 1 ? s : w)(S, r, m ^ 4 ? a : g.get) : (S) => S[e]), m > 2 && (b.set = y ? (S, Tt) => u(S, r, Tt, m ^ 4 ? a : g.set) : (S, Tt) => S[e] = Tt)), d = (0, n[Y])(m ? m < 4 ? y ? a : g[P] : m > 4 ? void 0 : { get: g.get, set: g.set } : r, p), f._ = 1, m ^ 4 || d === void 0 ? Ds(d) && (m > 4 ? H.unshift(d) : m ? y ? a = d : g[P] = d : r = d) : typeof d != "object" || d === null ? Et("Object expected") : (Ds(c = d.get) && (g.get = c), Ds(c = d.set) && (g.set = c), Ds(c = d.init) && H.unshift(c));
|
|
40
|
+
return m || Jt(i, r), g && ir(r, e, g), y ? m ^ 4 ? a : g : r;
|
|
41
|
+
}, l = (i, t, e) => _i(i, typeof t != "symbol" ? t + "" : t, e), rr = (i, t, e) => t.has(i) || Et("Cannot " + e), Eo = (i, t) => Object(t) !== t ? Et('Cannot use the "in" operator on this value') : i.has(t), s = (i, t, e) => (rr(i, t, "read from private field"), e ? e.call(i) : t.get(i)), o = (i, t, e) => t.has(i) ? Et("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(i) : t.set(i, e), u = (i, t, e, n) => (rr(i, t, "write to private field"), n ? n.call(i, e) : t.set(i, e), e), w = (i, t, e) => (rr(i, t, "access private method"), e);
|
|
42
|
+
var qr = (i, t, e, n) => ({
|
|
43
|
+
set _(r) {
|
|
44
|
+
u(i, t, r, e);
|
|
45
|
+
},
|
|
46
|
+
get _() {
|
|
47
|
+
return s(i, t, n);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
var h = (i, t, e) => new Promise((n, r) => {
|
|
51
|
+
var a = (f) => {
|
|
52
|
+
try {
|
|
53
|
+
d(e.next(f));
|
|
54
|
+
} catch (p) {
|
|
55
|
+
r(p);
|
|
56
|
+
}
|
|
57
|
+
}, c = (f) => {
|
|
58
|
+
try {
|
|
59
|
+
d(e.throw(f));
|
|
60
|
+
} catch (p) {
|
|
61
|
+
r(p);
|
|
62
|
+
}
|
|
63
|
+
}, d = (f) => f.done ? n(f.value) : Promise.resolve(f.value).then(a, c);
|
|
64
|
+
d((e = e.apply(i, t)).next());
|
|
65
|
+
}), A = function(i, t) {
|
|
66
|
+
this[0] = i, this[1] = t;
|
|
67
|
+
}, Dt = (i, t, e) => {
|
|
68
|
+
var n = (c, d, f, p) => {
|
|
69
|
+
try {
|
|
70
|
+
var b = e[c](d), m = (d = b.value) instanceof A, I = b.done;
|
|
71
|
+
Promise.resolve(m ? d[0] : d).then((y) => m ? n(c === "return" ? c : "next", d[1] ? { done: y.done, value: y.value } : y, f, p) : f({ value: y, done: I })).catch((y) => n("throw", y, f, p));
|
|
72
|
+
} catch (y) {
|
|
73
|
+
p(y);
|
|
74
|
+
}
|
|
75
|
+
}, r = (c) => a[c] = (d) => new Promise((f, p) => n(c, d, f, p)), a = {};
|
|
76
|
+
return e = e.apply(i, t), a[pt("asyncIterator")] = () => a, r("next"), r("throw"), r("return"), a;
|
|
77
|
+
}, ar = (i) => {
|
|
78
|
+
var t = i[pt("asyncIterator")], e = !1, n, r = {};
|
|
79
|
+
return t == null ? (t = i[pt("iterator")](), n = (a) => r[a] = (c) => t[a](c)) : (t = t.call(i), n = (a) => r[a] = (c) => {
|
|
80
|
+
if (e) {
|
|
81
|
+
if (e = !1, a === "throw") throw c;
|
|
82
|
+
return c;
|
|
83
|
+
}
|
|
84
|
+
return e = !0, {
|
|
85
|
+
done: !1,
|
|
86
|
+
value: new A(new Promise((d) => {
|
|
87
|
+
var f = t[a](c);
|
|
88
|
+
f instanceof Object || Et("Object expected"), d(f);
|
|
89
|
+
}), 1)
|
|
90
|
+
};
|
|
91
|
+
}), r[pt("iterator")] = () => r, n("next"), "throw" in t ? n("throw") : r.throw = (a) => {
|
|
92
|
+
throw a;
|
|
93
|
+
}, "return" in t && n("return"), r;
|
|
94
|
+
}, C = (i, t, e) => (t = i[pt("asyncIterator")]) ? t.call(i) : (i = i[pt("iterator")](), t = {}, e = (n, r) => (r = i[n]) && (t[n] = (a) => new Promise((c, d, f) => (a = r.call(i, a), f = a.done, Promise.resolve(a.value).then((p) => c({ value: p, done: f }), d)))), e("next"), e("return"), t);
|
|
95
|
+
var mt = (i, t, e) => {
|
|
96
|
+
if (t != null) {
|
|
97
|
+
typeof t != "object" && typeof t != "function" && Et("Object expected");
|
|
98
|
+
var n;
|
|
99
|
+
e && (n = t[pt("asyncDispose")]), n === void 0 && (n = t[pt("dispose")]), typeof n != "function" && Et("Object not disposable"), i.push([e, n, t]);
|
|
100
|
+
} else e && i.push([e]);
|
|
101
|
+
return t;
|
|
102
|
+
}, bt = (i, t, e) => {
|
|
103
|
+
var n = typeof SuppressedError == "function" ? SuppressedError : function(c, d, f, p) {
|
|
104
|
+
return p = Error(f), p.name = "SuppressedError", p.error = c, p.suppressed = d, p;
|
|
105
|
+
}, r = (c) => t = e ? new n(c, t, "An error was suppressed during disposal") : (e = !0, c), a = (c) => {
|
|
106
|
+
for (; c = i.pop(); )
|
|
107
|
+
try {
|
|
108
|
+
var d = c[1] && c[1].call(c[2]);
|
|
109
|
+
if (c[0]) return Promise.resolve(d).then(a, (f) => (r(f), a()));
|
|
110
|
+
} catch (f) {
|
|
111
|
+
r(f);
|
|
112
|
+
}
|
|
113
|
+
if (e) throw t;
|
|
114
|
+
};
|
|
115
|
+
return a();
|
|
116
|
+
};
|
|
117
|
+
import { D as x, F as xr, n as B, B as tr, b as Do, w as er, i as _, L as Xt, a as Ao, W as Oo, t as Vo, m as Co, c as Bo, e as xo } from "./B-HFfmiu.js";
|
|
118
|
+
import { a as Ia, p as Po, c as Ro } from "./F-U5JXpv.js";
|
|
119
|
+
function Pr(i) {
|
|
120
|
+
const t = new Rr(i);
|
|
121
|
+
return [t, t];
|
|
122
|
+
}
|
|
123
|
+
var jt, Fe, rt, ti;
|
|
124
|
+
class Rr {
|
|
125
|
+
constructor(t) {
|
|
126
|
+
/// The internal queue
|
|
127
|
+
o(this, jt);
|
|
128
|
+
/// Slows down push when the queue is full
|
|
129
|
+
o(this, Fe, new x());
|
|
130
|
+
/// Slows down pop when the queue is empty
|
|
131
|
+
o(this, rt);
|
|
132
|
+
/// The channel is closed
|
|
133
|
+
o(this, ti, !1);
|
|
134
|
+
u(this, jt, new xr(t));
|
|
135
|
+
}
|
|
136
|
+
close() {
|
|
137
|
+
var t;
|
|
138
|
+
(t = s(this, rt)) == null || t.resolve(), u(this, ti, !0);
|
|
139
|
+
}
|
|
140
|
+
abort(t) {
|
|
141
|
+
var e, n;
|
|
142
|
+
(e = s(this, rt)) == null || e.promise.catch(B), (n = s(this, rt)) == null || n.reject(t);
|
|
143
|
+
}
|
|
144
|
+
push(t) {
|
|
145
|
+
return h(this, null, function* () {
|
|
146
|
+
var e;
|
|
147
|
+
s(this, jt).isFull() && (yield s(this, Fe).promise), s(this, jt).push(t), (e = s(this, rt)) == null || e.resolve(), u(this, rt, new x());
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
pop() {
|
|
151
|
+
return h(this, null, function* () {
|
|
152
|
+
var t;
|
|
153
|
+
for (; !(s(this, ti) && s(this, jt).isEmpty()); ) {
|
|
154
|
+
const e = s(this, jt).pop();
|
|
155
|
+
if (e)
|
|
156
|
+
return s(this, Fe).resolve(), u(this, Fe, new x()), e;
|
|
157
|
+
s(this, rt) || u(this, rt, new x()), yield (t = s(this, rt)) == null ? void 0 : t.promise;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
start(t) {
|
|
162
|
+
}
|
|
163
|
+
pull(t) {
|
|
164
|
+
return h(this, null, function* () {
|
|
165
|
+
const e = yield this.pop();
|
|
166
|
+
e ? t.enqueue(e) : t.close();
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
cancel(t) {
|
|
170
|
+
this.abort(new Error(t));
|
|
171
|
+
}
|
|
172
|
+
next() {
|
|
173
|
+
return h(this, null, function* () {
|
|
174
|
+
const t = yield this.pop().catch(() => {
|
|
175
|
+
});
|
|
176
|
+
return t ? { done: !1, value: t } : { done: !0, value: void 0 };
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return() {
|
|
180
|
+
return this.close(), Promise.resolve({ done: !0, value: void 0 });
|
|
181
|
+
}
|
|
182
|
+
[Symbol.asyncIterator]() {
|
|
183
|
+
return this;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
jt = new WeakMap(), Fe = new WeakMap(), rt = new WeakMap(), ti = new WeakMap();
|
|
187
|
+
function k(i) {
|
|
188
|
+
return typeof BigInt == "function" ? BigInt(i) : i;
|
|
189
|
+
}
|
|
190
|
+
function Oe() {
|
|
191
|
+
return typeof Symbol.asyncDispose != "symbol" && Object.defineProperty(Symbol, "asyncDispose", { value: Symbol.for("asyncDispose") }), Symbol.asyncDispose;
|
|
192
|
+
}
|
|
193
|
+
function Sa() {
|
|
194
|
+
return typeof Symbol.dispose != "symbol" && Object.defineProperty(Symbol, "dispose", { value: Symbol.for("dispose") }), Symbol.dispose;
|
|
195
|
+
}
|
|
196
|
+
var ei, lr;
|
|
197
|
+
class Lo {
|
|
198
|
+
constructor(t, e) {
|
|
199
|
+
o(this, ei);
|
|
200
|
+
l(this, "value");
|
|
201
|
+
l(this, "unlocker");
|
|
202
|
+
this.value = t, this.unlocker = e;
|
|
203
|
+
}
|
|
204
|
+
unlocked() {
|
|
205
|
+
var t;
|
|
206
|
+
return (t = this.unlocker) == null ? void 0 : t.promise;
|
|
207
|
+
}
|
|
208
|
+
[Sa()]() {
|
|
209
|
+
w(this, ei, lr).call(this);
|
|
210
|
+
}
|
|
211
|
+
[Symbol.dispose]() {
|
|
212
|
+
w(this, ei, lr).call(this);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
ei = new WeakSet(), lr = function() {
|
|
216
|
+
this.unlocker.resolve(this.value);
|
|
217
|
+
};
|
|
218
|
+
var _t, te;
|
|
219
|
+
class jo {
|
|
220
|
+
constructor(t) {
|
|
221
|
+
o(this, _t);
|
|
222
|
+
o(this, te, new x());
|
|
223
|
+
u(this, _t, t), s(this, te).resolve(t);
|
|
224
|
+
}
|
|
225
|
+
unsafeValue() {
|
|
226
|
+
return s(this, _t);
|
|
227
|
+
}
|
|
228
|
+
isLocked() {
|
|
229
|
+
return s(this, te).pending;
|
|
230
|
+
}
|
|
231
|
+
lock() {
|
|
232
|
+
return h(this, null, function* () {
|
|
233
|
+
const t = new x();
|
|
234
|
+
t.promise.then((n) => {
|
|
235
|
+
u(this, _t, n);
|
|
236
|
+
}).catch(B);
|
|
237
|
+
const e = s(this, te).promise.then(() => t);
|
|
238
|
+
return u(this, te, t), yield e, new Lo(s(this, _t), t);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
_t = new WeakMap(), te = new WeakMap();
|
|
243
|
+
var et, at;
|
|
244
|
+
class ft {
|
|
245
|
+
constructor(t) {
|
|
246
|
+
o(this, et);
|
|
247
|
+
o(this, at);
|
|
248
|
+
u(this, et, t), u(this, at, new x());
|
|
249
|
+
}
|
|
250
|
+
isClosed() {
|
|
251
|
+
var t;
|
|
252
|
+
return !((t = s(this, at)) != null && t.pending);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Return only the current value
|
|
256
|
+
*/
|
|
257
|
+
current() {
|
|
258
|
+
return s(this, et);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Return the current value and a promise for the next value
|
|
262
|
+
*/
|
|
263
|
+
value() {
|
|
264
|
+
var t;
|
|
265
|
+
return [s(this, et), (t = s(this, at)) == null ? void 0 : t.promise];
|
|
266
|
+
}
|
|
267
|
+
update(t) {
|
|
268
|
+
var e;
|
|
269
|
+
if (!((e = s(this, at)) != null && e.pending))
|
|
270
|
+
throw new Error("ObservableValue is closed");
|
|
271
|
+
u(this, et, t instanceof Function ? t(s(this, et)) : t), s(this, at).resolve(s(this, et)), u(this, at, new x());
|
|
272
|
+
}
|
|
273
|
+
close() {
|
|
274
|
+
var t;
|
|
275
|
+
(t = s(this, at)) == null || t.resolve(s(this, et)), u(this, at, void 0);
|
|
276
|
+
}
|
|
277
|
+
waitFor(t) {
|
|
278
|
+
return h(this, null, function* () {
|
|
279
|
+
if (t(s(this, et)))
|
|
280
|
+
return s(this, et);
|
|
281
|
+
for (; ; ) {
|
|
282
|
+
const [e, n] = this.value();
|
|
283
|
+
if (!n)
|
|
284
|
+
return;
|
|
285
|
+
const r = yield n;
|
|
286
|
+
if (t(r))
|
|
287
|
+
return r;
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
[Symbol.asyncIterator]() {
|
|
292
|
+
return Dt(this, null, function* () {
|
|
293
|
+
for (; ; ) {
|
|
294
|
+
const [t, e] = this.value();
|
|
295
|
+
if (yield t, !e)
|
|
296
|
+
return;
|
|
297
|
+
yield new A(e);
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
et = new WeakMap(), at = new WeakMap();
|
|
303
|
+
function Ua(i) {
|
|
304
|
+
try {
|
|
305
|
+
return i();
|
|
306
|
+
} catch (t) {
|
|
307
|
+
return t;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
function Ta(i) {
|
|
311
|
+
let t = i.readUint32();
|
|
312
|
+
const e = [i.readUint8(), i.readUint8(), i.readUint8(), i.readUint8()], n = String.fromCharCode.apply(null, e);
|
|
313
|
+
return t === 1 && (t = i.readUint64() - 8), {
|
|
314
|
+
size: t - 8,
|
|
315
|
+
// Subtract header size
|
|
316
|
+
type: n
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function Go(i, t) {
|
|
320
|
+
const e = Ta(t), n = new tr(t.readBytes(e.size));
|
|
321
|
+
if (e.type !== i.type)
|
|
322
|
+
throw new Error(`invalid error type: ${e.type}, expected ${i.type}`);
|
|
323
|
+
const r = i.decodeData(n);
|
|
324
|
+
return n.readRemaining(), r;
|
|
325
|
+
}
|
|
326
|
+
function Zt(i) {
|
|
327
|
+
const t = i.readUint8(), e = i.readUint24();
|
|
328
|
+
return {
|
|
329
|
+
version: t,
|
|
330
|
+
flags: e
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
const xe = class xe {
|
|
334
|
+
constructor({
|
|
335
|
+
timescale: t,
|
|
336
|
+
presentationTime: e,
|
|
337
|
+
presentationTimeDelta: n,
|
|
338
|
+
schemeIdUri: r,
|
|
339
|
+
value: a,
|
|
340
|
+
eventDuration: c,
|
|
341
|
+
id: d,
|
|
342
|
+
data: f
|
|
343
|
+
}) {
|
|
344
|
+
l(this, "type", xe.type);
|
|
345
|
+
l(this, "timescale");
|
|
346
|
+
l(this, "presentationTime");
|
|
347
|
+
l(this, "presentationTimeDelta");
|
|
348
|
+
l(this, "schemeIdUri");
|
|
349
|
+
l(this, "value");
|
|
350
|
+
l(this, "eventDuration");
|
|
351
|
+
l(this, "id");
|
|
352
|
+
l(this, "data");
|
|
353
|
+
this.timescale = t, this.presentationTime = e, this.presentationTimeDelta = n, this.schemeIdUri = r, this.value = a, this.eventDuration = c, this.id = d, this.data = f;
|
|
354
|
+
}
|
|
355
|
+
static decodeData(t) {
|
|
356
|
+
const { version: e } = Zt(t);
|
|
357
|
+
switch (e) {
|
|
358
|
+
case 1: {
|
|
359
|
+
const n = t.readUint32(), r = t.readUint64(), a = t.readUint32(), c = t.readUint32(), d = t.readUtf8String(), f = t.readUtf8String(), p = t.remaining(), b = t.readBytes(p);
|
|
360
|
+
return new xe({
|
|
361
|
+
timescale: n,
|
|
362
|
+
presentationTime: r,
|
|
363
|
+
eventDuration: a,
|
|
364
|
+
id: c,
|
|
365
|
+
schemeIdUri: d,
|
|
366
|
+
value: f,
|
|
367
|
+
data: b
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
case 0: {
|
|
371
|
+
const n = t.readUtf8String(), r = t.readUtf8String(), a = t.readUint32(), c = t.readUint32(), d = t.readUint32(), f = t.readUint32(), p = t.remaining(), b = t.readBytes(p);
|
|
372
|
+
return new xe({ timescale: a, presentationTimeDelta: c, schemeIdUri: n, value: r, eventDuration: d, id: f, data: b });
|
|
373
|
+
}
|
|
374
|
+
default:
|
|
375
|
+
throw new Error(`unsupported version ${e}`);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
l(xe, "type", "emsg");
|
|
380
|
+
let hn = xe;
|
|
381
|
+
const Rs = class Rs {
|
|
382
|
+
constructor(t) {
|
|
383
|
+
l(this, "type", Rs.type);
|
|
384
|
+
l(this, "data");
|
|
385
|
+
this.data = t;
|
|
386
|
+
}
|
|
387
|
+
static decodeData(t) {
|
|
388
|
+
const e = t.readRemaining();
|
|
389
|
+
return new Rs(e);
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
l(Rs, "type", "mdat");
|
|
393
|
+
let ln = Rs;
|
|
394
|
+
const Ls = class Ls {
|
|
395
|
+
constructor(t, e, n) {
|
|
396
|
+
l(this, "type", Ls.type);
|
|
397
|
+
l(this, "extra");
|
|
398
|
+
/**
|
|
399
|
+
* The byte offset of the baseMediaDecodeTime field
|
|
400
|
+
*/
|
|
401
|
+
l(this, "byteOffset");
|
|
402
|
+
l(this, "baseMediaDecodeTime");
|
|
403
|
+
this.extra = t, this.byteOffset = e, this.baseMediaDecodeTime = n;
|
|
404
|
+
}
|
|
405
|
+
static decodeData(t) {
|
|
406
|
+
const e = Zt(t), n = t.byteOffset();
|
|
407
|
+
let r = 0;
|
|
408
|
+
return e.version === 1 ? r = t.readUint64() : r = t.readUint32(), new Ls(e, n, r);
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
l(Ls, "type", "tfdt");
|
|
412
|
+
let dn = Ls;
|
|
413
|
+
const O = class O {
|
|
414
|
+
constructor(t, e, n) {
|
|
415
|
+
l(this, "type", O.type);
|
|
416
|
+
l(this, "dataOffset");
|
|
417
|
+
l(this, "firstSampleFlags");
|
|
418
|
+
l(this, "samplesCount");
|
|
419
|
+
l(this, "sampleDurations", []);
|
|
420
|
+
l(this, "sampleSizes", []);
|
|
421
|
+
l(this, "sampleFlags", []);
|
|
422
|
+
l(this, "sampleCts", []);
|
|
423
|
+
this.dataOffset = e, this.firstSampleFlags = n, this.samplesCount = t;
|
|
424
|
+
}
|
|
425
|
+
is_sync_sample(t) {
|
|
426
|
+
const e = O.FLAG_SAMPLE_FLAG_IS_NON_SYNC | O.FLAG_SAMPLE_DEPENDS_YES, n = this.sampleFlags[t];
|
|
427
|
+
if (typeof n != "undefined")
|
|
428
|
+
return (n & e) === 0;
|
|
429
|
+
if (t === 0 && this.firstSampleFlags)
|
|
430
|
+
return (this.firstSampleFlags & e) === 0;
|
|
431
|
+
}
|
|
432
|
+
static decodeData(t) {
|
|
433
|
+
const { flags: e } = Zt(t), n = t.readUint32();
|
|
434
|
+
let r, a;
|
|
435
|
+
e & O.TRUN_DATA_OFFSET && (r = t.readUint32()), e & O.TRUN_FIRST_SAMPLE_FLAGS && (a = t.readUint32());
|
|
436
|
+
const c = new O(n, r, a);
|
|
437
|
+
for (let d = 0; d < n; d++)
|
|
438
|
+
e & O.SAMPLE_DURATION && c.sampleDurations.push(t.readUint32()), e & O.SAMPLE_SIZE && c.sampleSizes.push(t.readUint32()), e & O.SAMPLE_FLAGS && c.sampleFlags.push(t.readUint32()), e & O.SAMPLE_CTS && c.sampleCts.push(t.readUint32());
|
|
439
|
+
return c;
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
l(O, "TRUN_DATA_OFFSET", 1), l(O, "TRUN_FIRST_SAMPLE_FLAGS", 4), l(O, "SAMPLE_DURATION", 256), l(O, "SAMPLE_SIZE", 512), l(O, "SAMPLE_FLAGS", 1024), l(O, "SAMPLE_CTS", 2048), l(O, "FLAG_SAMPLE_FLAG_IS_NON_SYNC", 65536), l(O, "FLAG_SAMPLE_DEPENDS_NO", 33554432), l(O, "FLAG_SAMPLE_DEPENDS_YES", 16777216), l(O, "type", "trun");
|
|
443
|
+
let _s = O;
|
|
444
|
+
const js = class js {
|
|
445
|
+
constructor(t, e) {
|
|
446
|
+
l(this, "type", js.type);
|
|
447
|
+
l(this, "tfdt");
|
|
448
|
+
l(this, "trun");
|
|
449
|
+
this.tfdt = t, this.trun = e;
|
|
450
|
+
}
|
|
451
|
+
static decodeData(t) {
|
|
452
|
+
let e, n;
|
|
453
|
+
for (; t.remaining() > 0; ) {
|
|
454
|
+
const r = wt(t);
|
|
455
|
+
r instanceof dn && (e = r), r instanceof _s && (n = r);
|
|
456
|
+
}
|
|
457
|
+
return new js(e, n);
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
l(js, "type", "traf");
|
|
461
|
+
let fn = js;
|
|
462
|
+
const Gs = class Gs {
|
|
463
|
+
constructor(t) {
|
|
464
|
+
l(this, "type", Gs.type);
|
|
465
|
+
l(this, "traf");
|
|
466
|
+
this.traf = t;
|
|
467
|
+
}
|
|
468
|
+
static decodeData(t) {
|
|
469
|
+
let e;
|
|
470
|
+
for (; t.remaining() > 0; ) {
|
|
471
|
+
const n = wt(t);
|
|
472
|
+
n instanceof fn && (e = n);
|
|
473
|
+
}
|
|
474
|
+
if (!e)
|
|
475
|
+
throw new Error("No traf found");
|
|
476
|
+
return new Gs(e);
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
l(Gs, "type", "moof");
|
|
480
|
+
let wn = Gs;
|
|
481
|
+
const Ns = class Ns {
|
|
482
|
+
constructor() {
|
|
483
|
+
l(this, "type", Ns.type);
|
|
484
|
+
}
|
|
485
|
+
static decodeData(t) {
|
|
486
|
+
return new Ns();
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
l(Ns, "type", "mvhd");
|
|
490
|
+
let pn = Ns;
|
|
491
|
+
const Fs = class Fs {
|
|
492
|
+
constructor(t) {
|
|
493
|
+
l(this, "type", Fs.type);
|
|
494
|
+
l(this, "fourCC");
|
|
495
|
+
this.fourCC = t;
|
|
496
|
+
}
|
|
497
|
+
mediaType() {
|
|
498
|
+
switch (this.fourCC) {
|
|
499
|
+
case "vide":
|
|
500
|
+
return "video";
|
|
501
|
+
case "soun":
|
|
502
|
+
return "audio";
|
|
503
|
+
case "sbtl":
|
|
504
|
+
return "text";
|
|
505
|
+
default:
|
|
506
|
+
throw new Error("Unknown media type");
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
static decodeData(t) {
|
|
510
|
+
Zt(t), t.readUint32();
|
|
511
|
+
const e = String.fromCharCode(...t.readBytes(4));
|
|
512
|
+
return new Fs(e);
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
l(Fs, "type", "hdlr");
|
|
516
|
+
let mn = Fs;
|
|
517
|
+
const Pe = class Pe {
|
|
518
|
+
constructor(t, e, n, r) {
|
|
519
|
+
l(this, "type", Pe.type);
|
|
520
|
+
l(this, "creationTime");
|
|
521
|
+
l(this, "modificationTime");
|
|
522
|
+
l(this, "timescale");
|
|
523
|
+
l(this, "duration");
|
|
524
|
+
this.creationTime = t, this.modificationTime = e, this.timescale = n, this.duration = r;
|
|
525
|
+
}
|
|
526
|
+
static decodeData(t) {
|
|
527
|
+
const { version: e } = Zt(t);
|
|
528
|
+
if (e === 1) {
|
|
529
|
+
const d = t.readUint64(), f = t.readUint64(), p = t.readUint32(), b = t.readUint64();
|
|
530
|
+
return new Pe(d, f, p, b);
|
|
531
|
+
}
|
|
532
|
+
const n = t.readUint32(), r = t.readUint32(), a = t.readUint32(), c = t.readUint32();
|
|
533
|
+
return new Pe(n, r, a, c);
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
l(Pe, "type", "mdhd");
|
|
537
|
+
let bn = Pe;
|
|
538
|
+
const Ws = class Ws {
|
|
539
|
+
constructor(t, e, n, r) {
|
|
540
|
+
l(this, "type", Ws.type);
|
|
541
|
+
l(this, "av01");
|
|
542
|
+
l(this, "avc1");
|
|
543
|
+
l(this, "opus");
|
|
544
|
+
l(this, "codec");
|
|
545
|
+
this.avc1 = t, this.av01 = e, this.opus = n, this.codec = r;
|
|
546
|
+
}
|
|
547
|
+
mediaType() {
|
|
548
|
+
return this.avc1 || this.av01 ? "video" : "audio";
|
|
549
|
+
}
|
|
550
|
+
width() {
|
|
551
|
+
var t;
|
|
552
|
+
return (t = this.avc1) == null ? void 0 : t.width;
|
|
553
|
+
}
|
|
554
|
+
height() {
|
|
555
|
+
var t;
|
|
556
|
+
return (t = this.avc1) == null ? void 0 : t.height;
|
|
557
|
+
}
|
|
558
|
+
static decodeData(t) {
|
|
559
|
+
Zt(t);
|
|
560
|
+
const e = t.readUint32();
|
|
561
|
+
let n, r, a, c;
|
|
562
|
+
for (let d = 0; d < e; d++)
|
|
563
|
+
for (; t.remaining() > 0; ) {
|
|
564
|
+
const f = wt(t);
|
|
565
|
+
switch (f.type) {
|
|
566
|
+
case "avc1":
|
|
567
|
+
n = "h264", r = f;
|
|
568
|
+
break;
|
|
569
|
+
case "av01":
|
|
570
|
+
n = "av1", c = f;
|
|
571
|
+
break;
|
|
572
|
+
case "mp4a":
|
|
573
|
+
n = "aac";
|
|
574
|
+
break;
|
|
575
|
+
case "Opus":
|
|
576
|
+
n = "opus", a = f;
|
|
577
|
+
break;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
return new Ws(r, c, a, n);
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
l(Ws, "type", "stsd");
|
|
584
|
+
let yn = Ws;
|
|
585
|
+
const $s = class $s {
|
|
586
|
+
constructor(t) {
|
|
587
|
+
l(this, "type", $s.type);
|
|
588
|
+
l(this, "stsd");
|
|
589
|
+
this.stsd = t;
|
|
590
|
+
}
|
|
591
|
+
static decodeData(t) {
|
|
592
|
+
let e;
|
|
593
|
+
for (; t.remaining() > 0; ) {
|
|
594
|
+
const n = wt(t);
|
|
595
|
+
n instanceof yn && (e = n);
|
|
596
|
+
}
|
|
597
|
+
if (!e)
|
|
598
|
+
throw new Error("No stsd found");
|
|
599
|
+
return new $s(e);
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
l($s, "type", "stbl");
|
|
603
|
+
let gn = $s;
|
|
604
|
+
const zs = class zs {
|
|
605
|
+
constructor(t) {
|
|
606
|
+
l(this, "type", zs.type);
|
|
607
|
+
l(this, "stbl");
|
|
608
|
+
this.stbl = t;
|
|
609
|
+
}
|
|
610
|
+
static decodeData(t) {
|
|
611
|
+
let e;
|
|
612
|
+
for (; t.remaining() > 0; ) {
|
|
613
|
+
const n = wt(t);
|
|
614
|
+
n instanceof gn && (e = n);
|
|
615
|
+
}
|
|
616
|
+
if (!e)
|
|
617
|
+
throw new Error("No stbl found");
|
|
618
|
+
return new zs(e);
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
l(zs, "type", "minf");
|
|
622
|
+
let vn = zs;
|
|
623
|
+
const Ms = class Ms {
|
|
624
|
+
constructor(t, e, n) {
|
|
625
|
+
l(this, "type", Ms.type);
|
|
626
|
+
l(this, "hdlr");
|
|
627
|
+
l(this, "minf");
|
|
628
|
+
l(this, "mdhd");
|
|
629
|
+
this.hdlr = t, this.minf = e, this.mdhd = n;
|
|
630
|
+
}
|
|
631
|
+
static decodeData(t) {
|
|
632
|
+
let e, n, r;
|
|
633
|
+
for (; t.remaining() > 0; ) {
|
|
634
|
+
const a = wt(t);
|
|
635
|
+
a instanceof mn && (e = a), a instanceof vn && (n = a), a instanceof bn && (r = a);
|
|
636
|
+
}
|
|
637
|
+
if (!e)
|
|
638
|
+
throw new Error("No hdlr found");
|
|
639
|
+
if (!n)
|
|
640
|
+
throw new Error("No minf found");
|
|
641
|
+
if (!r)
|
|
642
|
+
throw new Error("No mdhd found");
|
|
643
|
+
return new Ms(e, n, r);
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
l(Ms, "type", "mdia");
|
|
647
|
+
let kn = Ms;
|
|
648
|
+
const Hs = class Hs {
|
|
649
|
+
constructor(t, e, n, r, a, c, d, f) {
|
|
650
|
+
l(this, "type", Hs.type);
|
|
651
|
+
l(this, "modificationTime");
|
|
652
|
+
l(this, "creationTime");
|
|
653
|
+
l(this, "trackId");
|
|
654
|
+
l(this, "duration");
|
|
655
|
+
l(this, "alternateGroup");
|
|
656
|
+
l(this, "volume");
|
|
657
|
+
l(this, "width");
|
|
658
|
+
l(this, "height");
|
|
659
|
+
this.modificationTime = t, this.creationTime = e, this.trackId = n, this.duration = r, this.alternateGroup = a, this.volume = c, this.width = d, this.height = f;
|
|
660
|
+
}
|
|
661
|
+
static decodeData(t) {
|
|
662
|
+
const e = Zt(t);
|
|
663
|
+
let n = 0, r = 0;
|
|
664
|
+
e.version === 1 ? (n = t.readUint64(), r = t.readUint64()) : (n = t.readUint32(), r = t.readUint32());
|
|
665
|
+
const a = t.readUint32();
|
|
666
|
+
t.readUint32();
|
|
667
|
+
const c = t.readUint32();
|
|
668
|
+
t.readUint32(), t.readUint32(), t.readUint16();
|
|
669
|
+
const d = t.readUint16(), f = t.readUint16();
|
|
670
|
+
t.readUint16(), new Array(9).fill(0).map(() => t.readUint32());
|
|
671
|
+
const p = t.readUint16();
|
|
672
|
+
t.readUint16();
|
|
673
|
+
const b = t.readUint16();
|
|
674
|
+
return t.readUint16(), new Hs(n, r, a, c, d, f, p, b);
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
l(Hs, "type", "tkhd");
|
|
678
|
+
let In = Hs;
|
|
679
|
+
const Xs = class Xs {
|
|
680
|
+
constructor(t, e) {
|
|
681
|
+
l(this, "type", Xs.type);
|
|
682
|
+
l(this, "tkhd");
|
|
683
|
+
l(this, "mdia");
|
|
684
|
+
this.tkhd = t, this.mdia = e;
|
|
685
|
+
}
|
|
686
|
+
static decodeData(t) {
|
|
687
|
+
let e, n;
|
|
688
|
+
for (; t.remaining() > 0; ) {
|
|
689
|
+
const r = wt(t);
|
|
690
|
+
r instanceof In && (e = r), r instanceof kn && (n = r);
|
|
691
|
+
}
|
|
692
|
+
if (!e)
|
|
693
|
+
throw new Error("No tkhd found");
|
|
694
|
+
if (!n)
|
|
695
|
+
throw new Error("No mdia found");
|
|
696
|
+
return new Xs(e, n);
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
l(Xs, "type", "trak");
|
|
700
|
+
let Sn = Xs;
|
|
701
|
+
const Zs = class Zs {
|
|
702
|
+
constructor(t, e) {
|
|
703
|
+
l(this, "type", Zs.type);
|
|
704
|
+
l(this, "mvhd");
|
|
705
|
+
l(this, "traks");
|
|
706
|
+
this.mvhd = t, this.traks = e;
|
|
707
|
+
}
|
|
708
|
+
static decodeData(t) {
|
|
709
|
+
let e;
|
|
710
|
+
const n = [];
|
|
711
|
+
for (; t.remaining() > 0; ) {
|
|
712
|
+
const r = wt(t);
|
|
713
|
+
r instanceof Sn && n.push(r), r instanceof pn && (e = r);
|
|
714
|
+
}
|
|
715
|
+
if (!e)
|
|
716
|
+
throw new Error("No mvhd found");
|
|
717
|
+
return new Zs(e, n);
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
l(Zs, "type", "moov");
|
|
721
|
+
let Un = Zs;
|
|
722
|
+
const Ys = class Ys {
|
|
723
|
+
constructor(t, e, n, r, a, c, d, f) {
|
|
724
|
+
l(this, "type", Ys.type);
|
|
725
|
+
l(this, "configurationVersion");
|
|
726
|
+
l(this, "avcProfileIndication");
|
|
727
|
+
l(this, "profileCompatibility");
|
|
728
|
+
l(this, "avcLevelIndication");
|
|
729
|
+
l(this, "lengthSizeMinusOne");
|
|
730
|
+
l(this, "sequenceParameterSets");
|
|
731
|
+
l(this, "pictureParameterSets");
|
|
732
|
+
l(this, "bytes");
|
|
733
|
+
this.configurationVersion = t, this.avcProfileIndication = e, this.profileCompatibility = n, this.avcLevelIndication = r, this.lengthSizeMinusOne = a, this.sequenceParameterSets = c, this.pictureParameterSets = d, this.bytes = f;
|
|
734
|
+
}
|
|
735
|
+
static decodeData(t) {
|
|
736
|
+
const e = t.buffer(), n = t.readUint8(), r = t.readUint8(), a = t.readUint8(), c = t.readUint8(), d = t.readUint8() & 3, f = t.readUint8() & 31, p = [];
|
|
737
|
+
for (let I = 0; I < f; I++) {
|
|
738
|
+
const y = t.readBytes(t.readUint16());
|
|
739
|
+
p.push(y);
|
|
740
|
+
}
|
|
741
|
+
const b = t.readUint8(), m = [];
|
|
742
|
+
for (let I = 0; I < b; I++) {
|
|
743
|
+
const y = t.readBytes(t.readUint16());
|
|
744
|
+
m.push(y);
|
|
745
|
+
}
|
|
746
|
+
return new Ys(
|
|
747
|
+
n,
|
|
748
|
+
r,
|
|
749
|
+
a,
|
|
750
|
+
c,
|
|
751
|
+
d,
|
|
752
|
+
p,
|
|
753
|
+
m,
|
|
754
|
+
e
|
|
755
|
+
);
|
|
756
|
+
}
|
|
757
|
+
};
|
|
758
|
+
l(Ys, "type", "avcC");
|
|
759
|
+
let dr = Ys;
|
|
760
|
+
const Js = class Js {
|
|
761
|
+
constructor(t, e, n, r, a) {
|
|
762
|
+
l(this, "type", Js.type);
|
|
763
|
+
l(this, "avcC");
|
|
764
|
+
l(this, "width");
|
|
765
|
+
l(this, "height");
|
|
766
|
+
l(this, "horizontalResolution");
|
|
767
|
+
l(this, "verticalResolution");
|
|
768
|
+
this.avcC = t, this.width = e, this.height = n, this.horizontalResolution = r, this.verticalResolution = a;
|
|
769
|
+
}
|
|
770
|
+
static decodeData(t) {
|
|
771
|
+
t.readUint32(), t.readUint16(), t.readUint16(), t.readUint32(), t.readUint64(), t.readUint32();
|
|
772
|
+
const e = t.readUint16(), n = t.readUint16(), r = t.readUint32(), a = t.readUint32();
|
|
773
|
+
t.readUint32(), t.readUint16(), t.readBytes(32), t.readUint16(), t.readUint16();
|
|
774
|
+
let c;
|
|
775
|
+
for (; t.remaining() > 0; ) {
|
|
776
|
+
const d = wt(t);
|
|
777
|
+
switch (d.type) {
|
|
778
|
+
case "avcC":
|
|
779
|
+
c = d;
|
|
780
|
+
break;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
if (!c)
|
|
784
|
+
throw new Error("no avcC");
|
|
785
|
+
return new Js(c, e, n, r, a);
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
l(Js, "type", "avc1");
|
|
789
|
+
let fr = Js;
|
|
790
|
+
const Ks = class Ks {
|
|
791
|
+
constructor() {
|
|
792
|
+
l(this, "type", Ks.type);
|
|
793
|
+
}
|
|
794
|
+
static decodeData(t) {
|
|
795
|
+
return new Ks();
|
|
796
|
+
}
|
|
797
|
+
};
|
|
798
|
+
l(Ks, "type", "dOps");
|
|
799
|
+
let wr = Ks;
|
|
800
|
+
const Qs = class Qs {
|
|
801
|
+
constructor(t, e, n) {
|
|
802
|
+
l(this, "type", Qs.type);
|
|
803
|
+
l(this, "dops");
|
|
804
|
+
l(this, "channelCount");
|
|
805
|
+
l(this, "sampleRate");
|
|
806
|
+
this.dops = t, this.channelCount = e, this.sampleRate = n;
|
|
807
|
+
}
|
|
808
|
+
static decodeData(t) {
|
|
809
|
+
t.readUint32(), t.readUint16(), t.readUint16();
|
|
810
|
+
const e = t.readUint16();
|
|
811
|
+
t.readUint16(), t.readUint32();
|
|
812
|
+
const n = t.readUint16();
|
|
813
|
+
t.readUint16(), t.readUint32();
|
|
814
|
+
const r = t.readUint16();
|
|
815
|
+
t.readUint16(), e === 1 && (t.readUint64(), t.readUint64());
|
|
816
|
+
const a = Go(wr, t);
|
|
817
|
+
return new Qs(a, n, r);
|
|
818
|
+
}
|
|
819
|
+
};
|
|
820
|
+
l(Qs, "type", "Opus");
|
|
821
|
+
let pr = Qs;
|
|
822
|
+
const Re = class Re {
|
|
823
|
+
constructor(t, e) {
|
|
824
|
+
l(this, "type", Re.type);
|
|
825
|
+
l(this, "ntpTimestamp");
|
|
826
|
+
l(this, "mediaTime");
|
|
827
|
+
this.ntpTimestamp = t, this.mediaTime = e;
|
|
828
|
+
}
|
|
829
|
+
static decodeData(t) {
|
|
830
|
+
const { version: e } = Zt(t);
|
|
831
|
+
t.readUint32();
|
|
832
|
+
const n = t.readUint32(), r = t.readUint32();
|
|
833
|
+
if (e === 1) {
|
|
834
|
+
const c = t.readUint64();
|
|
835
|
+
return new Re([n, r], c);
|
|
836
|
+
}
|
|
837
|
+
const a = t.readUint32();
|
|
838
|
+
return new Re([n, r], a);
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
l(Re, "type", "prft");
|
|
842
|
+
let Tn = Re;
|
|
843
|
+
var si, ii;
|
|
844
|
+
class No {
|
|
845
|
+
constructor(t, e) {
|
|
846
|
+
o(this, si);
|
|
847
|
+
o(this, ii);
|
|
848
|
+
u(this, si, t), u(this, ii, e.readBytes(t.size));
|
|
849
|
+
}
|
|
850
|
+
data() {
|
|
851
|
+
return s(this, ii);
|
|
852
|
+
}
|
|
853
|
+
get type() {
|
|
854
|
+
return s(this, si).type;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
si = new WeakMap(), ii = new WeakMap();
|
|
858
|
+
const Fo = {
|
|
859
|
+
moov: Un,
|
|
860
|
+
trak: Sn,
|
|
861
|
+
tkhd: In,
|
|
862
|
+
mvhd: pn,
|
|
863
|
+
moof: wn,
|
|
864
|
+
traf: fn,
|
|
865
|
+
tfdt: dn,
|
|
866
|
+
trun: _s,
|
|
867
|
+
mdat: ln,
|
|
868
|
+
mdia: kn,
|
|
869
|
+
hdlr: mn,
|
|
870
|
+
minf: vn,
|
|
871
|
+
stbl: gn,
|
|
872
|
+
mdhd: bn,
|
|
873
|
+
stsd: yn,
|
|
874
|
+
prft: Tn,
|
|
875
|
+
avc1: fr,
|
|
876
|
+
avcC: dr,
|
|
877
|
+
Opus: pr,
|
|
878
|
+
emsg: hn
|
|
879
|
+
};
|
|
880
|
+
function wt(i) {
|
|
881
|
+
const t = Ta(i), e = Fo[t.type], n = new tr(i.readBytes(t.size));
|
|
882
|
+
if (!e) {
|
|
883
|
+
const a = new No(t, n);
|
|
884
|
+
return n.readRemaining(), a;
|
|
885
|
+
}
|
|
886
|
+
const r = e.decodeData(n);
|
|
887
|
+
return n.readRemaining(), r;
|
|
888
|
+
}
|
|
889
|
+
function Wo(i) {
|
|
890
|
+
if (i.byteLength < 8)
|
|
891
|
+
throw new Error("Buffer too small");
|
|
892
|
+
const t = new tr(i), e = /* @__PURE__ */ new Map();
|
|
893
|
+
for (; t.remaining() > 0; ) {
|
|
894
|
+
const a = wt(t);
|
|
895
|
+
e.set(a.type, a);
|
|
896
|
+
}
|
|
897
|
+
const n = e.get("ftyp"), r = e.get("moov");
|
|
898
|
+
if (!n)
|
|
899
|
+
throw new Error("ftyp atom not found");
|
|
900
|
+
if (!r || !(r instanceof Un))
|
|
901
|
+
throw new Error("moov atom not found");
|
|
902
|
+
return {
|
|
903
|
+
ftyp: n,
|
|
904
|
+
moov: r
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
function $o(i) {
|
|
908
|
+
if (i.byteLength < 8)
|
|
909
|
+
throw new Error("Buffer too small");
|
|
910
|
+
const t = new tr(i), e = /* @__PURE__ */ new Map(), n = [];
|
|
911
|
+
for (; t.remaining() > 0; ) {
|
|
912
|
+
const d = wt(t);
|
|
913
|
+
d instanceof hn && n.push(d), e.set(d.type, d);
|
|
914
|
+
}
|
|
915
|
+
const r = e.get("moof"), a = e.get("mdat"), c = e.get("prft");
|
|
916
|
+
if (!r || !(r instanceof wn))
|
|
917
|
+
throw new Error("moof atom not found");
|
|
918
|
+
if (!a || !(a instanceof ln))
|
|
919
|
+
throw new Error("mdat atom not found");
|
|
920
|
+
if (c && !(c instanceof Tn))
|
|
921
|
+
throw new Error("invalid prft found");
|
|
922
|
+
return {
|
|
923
|
+
moof: r,
|
|
924
|
+
mdat: a,
|
|
925
|
+
prft: c,
|
|
926
|
+
emsgs: n
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
var ni, ri;
|
|
930
|
+
class zo {
|
|
931
|
+
constructor(t) {
|
|
932
|
+
o(this, ni);
|
|
933
|
+
o(this, ri);
|
|
934
|
+
u(this, ni, t), u(this, ri, Wo(t));
|
|
935
|
+
}
|
|
936
|
+
rawBytes() {
|
|
937
|
+
return s(this, ni);
|
|
938
|
+
}
|
|
939
|
+
init() {
|
|
940
|
+
return s(this, ri);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
ni = new WeakMap(), ri = new WeakMap();
|
|
944
|
+
var ot, J, D;
|
|
945
|
+
class Mo {
|
|
946
|
+
constructor(t, e) {
|
|
947
|
+
o(this, ot);
|
|
948
|
+
o(this, J);
|
|
949
|
+
o(this, D);
|
|
950
|
+
u(this, ot, e), u(this, J, t), u(this, D, $o(e));
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* Update the raw bytes of the fragment with the new baseMediaDecodeTime
|
|
954
|
+
* @param baseMediaDecodeTime
|
|
955
|
+
*/
|
|
956
|
+
updateBaseMediaDecodeTime(t) {
|
|
957
|
+
const e = new DataView(s(this, ot).buffer, s(this, ot).byteOffset, s(this, ot).byteLength);
|
|
958
|
+
if (s(this, D).moof.traf.tfdt)
|
|
959
|
+
if (s(this, D).moof.traf.tfdt.baseMediaDecodeTime = t, s(this, D).moof.traf.tfdt.extra.version === 1) {
|
|
960
|
+
const n = Math.floor(t / 4294967296), r = (t & 4294967295) >>> 0;
|
|
961
|
+
e.setUint32(s(this, D).moof.traf.tfdt.byteOffset - s(this, ot).byteOffset, n), e.setUint32(s(this, D).moof.traf.tfdt.byteOffset - s(this, ot).byteOffset + 4, r);
|
|
962
|
+
} else
|
|
963
|
+
e.setUint32(s(this, D).moof.traf.tfdt.byteOffset - s(this, ot).byteOffset, t);
|
|
964
|
+
}
|
|
965
|
+
producerReferenceTime() {
|
|
966
|
+
if (!s(this, D).prft)
|
|
967
|
+
return;
|
|
968
|
+
const [t, e] = s(this, D).prft.ntpTimestamp, n = t * 1e3 + e / 2 ** 32 * 1e3, r = new Date(Date.UTC(1900, 0, 1, 0, 0, 0));
|
|
969
|
+
return new Date(r.getTime() + n);
|
|
970
|
+
}
|
|
971
|
+
duration() {
|
|
972
|
+
var t;
|
|
973
|
+
return ((t = s(this, D).moof.traf.trun) == null ? void 0 : t.sampleDurations.reduce((e, n) => e + n, 0)) || 0;
|
|
974
|
+
}
|
|
975
|
+
baseMediaDecodeTime() {
|
|
976
|
+
var e;
|
|
977
|
+
const t = (e = s(this, D).moof.traf.tfdt) == null ? void 0 : e.baseMediaDecodeTime;
|
|
978
|
+
if (!t)
|
|
979
|
+
throw new Error("no baseMediaDecodeTime");
|
|
980
|
+
return t;
|
|
981
|
+
}
|
|
982
|
+
startsWithKeyframe() {
|
|
983
|
+
const t = s(this, D).moof.traf.trun, e = (t == null ? void 0 : t.firstSampleFlags) || (t == null ? void 0 : t.sampleFlags[0]);
|
|
984
|
+
return e ? (e & _s.FLAG_SAMPLE_DEPENDS_NO) !== 0 : !1;
|
|
985
|
+
}
|
|
986
|
+
timescale() {
|
|
987
|
+
const t = s(this, J).init().moov.traks[0];
|
|
988
|
+
if (!t)
|
|
989
|
+
throw new Error("no tracks");
|
|
990
|
+
return t.mdia.mdhd.timescale;
|
|
991
|
+
}
|
|
992
|
+
mediaType() {
|
|
993
|
+
var e;
|
|
994
|
+
const t = (e = s(this, J).init().moov.traks[0]) == null ? void 0 : e.mdia.hdlr.mediaType();
|
|
995
|
+
if (!t)
|
|
996
|
+
throw new Error("no media type");
|
|
997
|
+
return t;
|
|
998
|
+
}
|
|
999
|
+
header() {
|
|
1000
|
+
return s(this, J);
|
|
1001
|
+
}
|
|
1002
|
+
fragment() {
|
|
1003
|
+
return s(this, D);
|
|
1004
|
+
}
|
|
1005
|
+
samplesCount() {
|
|
1006
|
+
var t;
|
|
1007
|
+
return ((t = s(this, D).moof.traf.trun) == null ? void 0 : t.samplesCount) || 0;
|
|
1008
|
+
}
|
|
1009
|
+
sample(t) {
|
|
1010
|
+
var y, E, P, H, T, g, Y, S, Tt, Us, Ki, Qi, Mr, Hr, Xr;
|
|
1011
|
+
const e = (y = s(this, J).init().moov.traks[0]) == null ? void 0 : y.mdia.minf.stbl.stsd.codec, n = ((E = s(this, D).moof.traf.trun) == null ? void 0 : E.samplesCount) || 0, r = (P = s(this, D).moof.traf.tfdt) == null ? void 0 : P.baseMediaDecodeTime;
|
|
1012
|
+
if (t >= n || typeof r == "undefined" || !e)
|
|
1013
|
+
return;
|
|
1014
|
+
const a = ((H = s(this, D).moof.traf.trun) == null ? void 0 : H.sampleDurations[t]) || 0, c = ((T = s(this, D).moof.traf.trun) == null ? void 0 : T.sampleDurations.slice(0, t).reduce((Ts, Es) => Ts + Es, 0)) || 0, d = r + c, f = ((g = s(this, J).init().moov.traks[0]) == null ? void 0 : g.mdia.mdhd.timescale) || 1e3, p = ((Y = s(this, D).moof.traf.trun) == null ? void 0 : Y.sampleSizes[t]) || s(this, D).mdat.data.byteLength, b = ((S = s(this, D).moof.traf.trun) == null ? void 0 : S.sampleSizes.slice(0, t).reduce((Ts, Es) => Ts + Es, 0)) || 0, m = s(this, D).mdat.data.subarray(b, b + p), I = ((Tt = s(this, D).moof.traf.trun) == null ? void 0 : Tt.is_sync_sample(t)) || !1;
|
|
1015
|
+
if (this.mediaType() === "video") {
|
|
1016
|
+
const Ts = ((Us = s(this, J).init().moov.traks[0]) == null ? void 0 : Us.tkhd.width) || 0, Es = ((Ki = s(this, J).init().moov.traks[0]) == null ? void 0 : Ki.tkhd.height) || 0;
|
|
1017
|
+
return {
|
|
1018
|
+
type: "video",
|
|
1019
|
+
codec: e,
|
|
1020
|
+
width: Ts,
|
|
1021
|
+
height: Es,
|
|
1022
|
+
duration: a,
|
|
1023
|
+
isSync: I,
|
|
1024
|
+
timescale: f,
|
|
1025
|
+
timestamp: d,
|
|
1026
|
+
data: m
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
return {
|
|
1030
|
+
type: "audio",
|
|
1031
|
+
codec: e,
|
|
1032
|
+
channels: ((Mr = (Qi = s(this, J).init().moov.traks[0]) == null ? void 0 : Qi.mdia.minf.stbl.stsd.opus) == null ? void 0 : Mr.channelCount) || 0,
|
|
1033
|
+
sampleRate: ((Xr = (Hr = s(this, J).init().moov.traks[0]) == null ? void 0 : Hr.mdia.minf.stbl.stsd.opus) == null ? void 0 : Xr.sampleRate) || 0,
|
|
1034
|
+
duration: a,
|
|
1035
|
+
isSync: I,
|
|
1036
|
+
timestamp: d,
|
|
1037
|
+
data: m,
|
|
1038
|
+
timescale: f
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* @returns the raw bytes of the cmaf fragment
|
|
1043
|
+
*/
|
|
1044
|
+
rawBytes() {
|
|
1045
|
+
return s(this, ot);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
ot = new WeakMap(), J = new WeakMap(), D = new WeakMap();
|
|
1049
|
+
var We;
|
|
1050
|
+
class _r {
|
|
1051
|
+
constructor(t) {
|
|
1052
|
+
o(this, We);
|
|
1053
|
+
u(this, We, new zo(t));
|
|
1054
|
+
}
|
|
1055
|
+
header() {
|
|
1056
|
+
return s(this, We);
|
|
1057
|
+
}
|
|
1058
|
+
createFragment(t) {
|
|
1059
|
+
return new Mo(s(this, We), t);
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
We = new WeakMap();
|
|
1063
|
+
var Gt, ai;
|
|
1064
|
+
class Ho {
|
|
1065
|
+
constructor(t, e) {
|
|
1066
|
+
o(this, Gt);
|
|
1067
|
+
o(this, ai);
|
|
1068
|
+
u(this, Gt, t), u(this, ai, e);
|
|
1069
|
+
}
|
|
1070
|
+
start(t) {
|
|
1071
|
+
s(this, Gt).addEventListener("message", (e) => {
|
|
1072
|
+
if (typeof e.data == "object" && e.data instanceof ArrayBuffer) {
|
|
1073
|
+
const n = new Uint8Array(e.data);
|
|
1074
|
+
n[0] == s(this, ai) && t.enqueue(n.subarray(1));
|
|
1075
|
+
}
|
|
1076
|
+
}), s(this, Gt).addEventListener("error", (e) => t.error(e)), s(this, Gt).addEventListener("close", () => Ua(() => t.close()));
|
|
1077
|
+
}
|
|
1078
|
+
cancel(t) {
|
|
1079
|
+
s(this, Gt).close(void 0, t);
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
Gt = new WeakMap(), ai = new WeakMap();
|
|
1083
|
+
var yt, ee, se, ie;
|
|
1084
|
+
class Xo {
|
|
1085
|
+
constructor(t) {
|
|
1086
|
+
o(this, yt);
|
|
1087
|
+
o(this, ee, null);
|
|
1088
|
+
o(this, se, null);
|
|
1089
|
+
o(this, ie, null);
|
|
1090
|
+
u(this, yt, t);
|
|
1091
|
+
}
|
|
1092
|
+
start(t) {
|
|
1093
|
+
u(this, ee, (e) => {
|
|
1094
|
+
if (typeof e.data == "object" && e.data instanceof ArrayBuffer) {
|
|
1095
|
+
const n = new Uint8Array(e.data), r = n[0] || 0, a = r & 127, c = (r >> 7 & 1) > 0;
|
|
1096
|
+
if (a && a !== 0) {
|
|
1097
|
+
const d = n.subarray(1);
|
|
1098
|
+
t.enqueue([c, a, d]);
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
}), u(this, se, () => Ua(() => t.close())), u(this, ie, (e) => t.error(e)), s(this, yt).addEventListener("message", s(this, ee)), s(this, yt).addEventListener("error", s(this, ie)), s(this, yt).addEventListener("close", s(this, se));
|
|
1102
|
+
}
|
|
1103
|
+
cancel(t) {
|
|
1104
|
+
s(this, ee) && s(this, yt).removeEventListener("message", s(this, ee)), s(this, ie) && s(this, yt).removeEventListener("error", s(this, ie)), s(this, se) && s(this, yt).removeEventListener("close", s(this, se));
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
yt = new WeakMap(), ee = new WeakMap(), se = new WeakMap(), ie = new WeakMap();
|
|
1108
|
+
var gt, oi, $e, vt, xn, U, Vs, en, qt, sn, Lt;
|
|
1109
|
+
class En {
|
|
1110
|
+
constructor(t, e) {
|
|
1111
|
+
o(this, U);
|
|
1112
|
+
o(this, gt);
|
|
1113
|
+
o(this, oi);
|
|
1114
|
+
o(this, $e);
|
|
1115
|
+
o(this, vt, 0);
|
|
1116
|
+
o(this, xn, new TextDecoder());
|
|
1117
|
+
u(this, gt, t), u(this, oi, e), u(this, $e, e.getReader());
|
|
1118
|
+
}
|
|
1119
|
+
readUnsigned8() {
|
|
1120
|
+
return h(this, null, function* () {
|
|
1121
|
+
return yield w(this, U, qt).call(this, 1), w(this, U, Lt).call(this, 1)[0];
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
readString() {
|
|
1125
|
+
return h(this, null, function* () {
|
|
1126
|
+
const t = yield this.readVarInt(), e = yield this.read(t);
|
|
1127
|
+
return s(this, xn).decode(e);
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
readVarInt() {
|
|
1131
|
+
return h(this, null, function* () {
|
|
1132
|
+
const t = yield this.readBigVarInt();
|
|
1133
|
+
if (t > Number.MAX_SAFE_INTEGER)
|
|
1134
|
+
throw new Error("VarInt is too large");
|
|
1135
|
+
return Number(t);
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
readBigVarInt() {
|
|
1139
|
+
return h(this, null, function* () {
|
|
1140
|
+
yield w(this, U, qt).call(this, 1);
|
|
1141
|
+
const t = (w(this, U, sn).call(this, 1)[0] & 192) >> 6;
|
|
1142
|
+
switch (s(this, gt)[s(this, vt)] = w(this, U, sn).call(this, 1)[0] & 63, t) {
|
|
1143
|
+
case 0:
|
|
1144
|
+
return k(w(this, U, Lt).call(this, 1)[0]);
|
|
1145
|
+
case 1: {
|
|
1146
|
+
yield w(this, U, qt).call(this, 2);
|
|
1147
|
+
const e = w(this, U, Lt).call(this, 2), n = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
1148
|
+
return k(n.getUint16(0));
|
|
1149
|
+
}
|
|
1150
|
+
case 2: {
|
|
1151
|
+
yield w(this, U, qt).call(this, 4);
|
|
1152
|
+
const e = w(this, U, Lt).call(this, 4), n = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
1153
|
+
return k(n.getUint32(0));
|
|
1154
|
+
}
|
|
1155
|
+
case 3: {
|
|
1156
|
+
yield w(this, U, qt).call(this, 8);
|
|
1157
|
+
const e = w(this, U, Lt).call(this, 8), n = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
1158
|
+
if (typeof n.getBigUint64 != "undefined")
|
|
1159
|
+
return k(n.getBigUint64(0));
|
|
1160
|
+
const r = Do(e, 0, 7);
|
|
1161
|
+
return k(r);
|
|
1162
|
+
}
|
|
1163
|
+
default:
|
|
1164
|
+
throw new Error("Invalid VarInt size");
|
|
1165
|
+
}
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
read(t) {
|
|
1169
|
+
return h(this, null, function* () {
|
|
1170
|
+
return yield w(this, U, qt).call(this, t), w(this, U, Lt).call(this, t);
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
readAll() {
|
|
1174
|
+
return h(this, null, function* () {
|
|
1175
|
+
for (; yield w(this, U, en).call(this); )
|
|
1176
|
+
;
|
|
1177
|
+
return w(this, U, Lt).call(this, w(this, U, Vs).call(this));
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1180
|
+
isDone() {
|
|
1181
|
+
return h(this, null, function* () {
|
|
1182
|
+
return w(this, U, Vs).call(this) > 0 ? !1 : (yield w(this, U, en).call(this)) == 0;
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
close() {
|
|
1186
|
+
return h(this, null, function* () {
|
|
1187
|
+
return s(this, $e).releaseLock(), s(this, oi).cancel();
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
gt = new WeakMap(), oi = new WeakMap(), $e = new WeakMap(), vt = new WeakMap(), xn = new WeakMap(), U = new WeakSet(), Vs = function() {
|
|
1192
|
+
return s(this, gt).length - s(this, vt);
|
|
1193
|
+
}, en = function() {
|
|
1194
|
+
return h(this, null, function* () {
|
|
1195
|
+
const { value: t, done: e } = yield s(this, $e).read();
|
|
1196
|
+
if (e)
|
|
1197
|
+
return Promise.resolve(0);
|
|
1198
|
+
if (w(this, U, Vs).call(this) === 0)
|
|
1199
|
+
u(this, gt, t);
|
|
1200
|
+
else {
|
|
1201
|
+
const r = s(this, gt).subarray(s(this, vt)), a = new Uint8Array(r.length + t.length);
|
|
1202
|
+
a.set(r), a.set(t, r.byteLength), u(this, gt, a);
|
|
1203
|
+
}
|
|
1204
|
+
return u(this, vt, 0), Promise.resolve(t.length);
|
|
1205
|
+
});
|
|
1206
|
+
}, qt = function(t) {
|
|
1207
|
+
return h(this, null, function* () {
|
|
1208
|
+
for (; w(this, U, Vs).call(this) < t; )
|
|
1209
|
+
if ((yield w(this, U, en).call(this)) === 0)
|
|
1210
|
+
throw new Error("Read failed");
|
|
1211
|
+
});
|
|
1212
|
+
}, sn = function(t) {
|
|
1213
|
+
return s(this, gt).subarray(s(this, vt), s(this, vt) + t);
|
|
1214
|
+
}, Lt = function(t) {
|
|
1215
|
+
const e = w(this, U, sn).call(this, t);
|
|
1216
|
+
return u(this, vt, s(this, vt) + e.length), e;
|
|
1217
|
+
};
|
|
1218
|
+
var ze, Me, At, Pn;
|
|
1219
|
+
class Zo {
|
|
1220
|
+
constructor(t) {
|
|
1221
|
+
o(this, ze, new Uint8Array(8));
|
|
1222
|
+
o(this, Me);
|
|
1223
|
+
o(this, At);
|
|
1224
|
+
o(this, Pn, new TextEncoder());
|
|
1225
|
+
u(this, Me, t), u(this, At, s(this, Me).getWriter());
|
|
1226
|
+
}
|
|
1227
|
+
writeString(t) {
|
|
1228
|
+
return h(this, null, function* () {
|
|
1229
|
+
const e = s(this, Pn).encode(t);
|
|
1230
|
+
return yield this.writeVarInt(e.length), this.write(e);
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1233
|
+
write(t) {
|
|
1234
|
+
return s(this, At).write(t);
|
|
1235
|
+
}
|
|
1236
|
+
writeUnsigned8(t) {
|
|
1237
|
+
return s(this, At).write(sr(t, s(this, ze)));
|
|
1238
|
+
}
|
|
1239
|
+
writeVarInt(t) {
|
|
1240
|
+
return s(this, At).write(xa(t, s(this, ze)));
|
|
1241
|
+
}
|
|
1242
|
+
writeBigVarInt(t) {
|
|
1243
|
+
return s(this, At).write(Pa(t, s(this, ze)));
|
|
1244
|
+
}
|
|
1245
|
+
flush() {
|
|
1246
|
+
return h(this, null, function* () {
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1249
|
+
close() {
|
|
1250
|
+
return h(this, null, function* () {
|
|
1251
|
+
s(this, At).releaseLock(), yield s(this, Me).close();
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
ze = new WeakMap(), Me = new WeakMap(), At = new WeakMap(), Pn = new WeakMap();
|
|
1256
|
+
var Z, K, He, Rn;
|
|
1257
|
+
const qs = class qs {
|
|
1258
|
+
constructor(t) {
|
|
1259
|
+
o(this, Z, 0);
|
|
1260
|
+
o(this, K, new Uint8Array(qs.DEFAULT_BUFFER_SIZE));
|
|
1261
|
+
o(this, He);
|
|
1262
|
+
o(this, Rn, new TextEncoder());
|
|
1263
|
+
u(this, He, t);
|
|
1264
|
+
}
|
|
1265
|
+
writeString(t) {
|
|
1266
|
+
return h(this, null, function* () {
|
|
1267
|
+
const e = s(this, Rn).encode(t);
|
|
1268
|
+
return yield this.writeVarInt(e.length), this.write(e);
|
|
1269
|
+
});
|
|
1270
|
+
}
|
|
1271
|
+
ensureBufferSpace(t) {
|
|
1272
|
+
if (s(this, K).length - s(this, Z) >= t)
|
|
1273
|
+
return;
|
|
1274
|
+
const e = new Uint8Array(s(this, K).length * 2);
|
|
1275
|
+
e.set(s(this, K)), u(this, K, e);
|
|
1276
|
+
}
|
|
1277
|
+
write(t) {
|
|
1278
|
+
return this.ensureBufferSpace(t.length), s(this, K).set(t, s(this, Z)), u(this, Z, s(this, Z) + t.byteLength), Promise.resolve();
|
|
1279
|
+
}
|
|
1280
|
+
writeUnsigned8(t) {
|
|
1281
|
+
return this.ensureBufferSpace(1), sr(t, s(this, K).subarray(s(this, Z))), u(this, Z, s(this, Z) + 1), Promise.resolve();
|
|
1282
|
+
}
|
|
1283
|
+
writeVarInt(t) {
|
|
1284
|
+
if (t < 0)
|
|
1285
|
+
throw new Error(`VarInt can not be negative: ${t}`);
|
|
1286
|
+
return this.ensureBufferSpace(8), u(this, Z, s(this, Z) + xa(t, s(this, K).subarray(s(this, Z))).byteLength), Promise.resolve();
|
|
1287
|
+
}
|
|
1288
|
+
writeBigVarInt(t) {
|
|
1289
|
+
if (t < 0)
|
|
1290
|
+
throw new Error(`VarInt can not be negative: ${t}`);
|
|
1291
|
+
return this.ensureBufferSpace(8), u(this, Z, s(this, Z) + Pa(t, s(this, K).subarray(s(this, Z))).byteLength), Promise.resolve();
|
|
1292
|
+
}
|
|
1293
|
+
flush() {
|
|
1294
|
+
return s(this, He).send(s(this, K).subarray(0, s(this, Z))), u(this, Z, 0), u(this, K, new Uint8Array(qs.DEFAULT_BUFFER_SIZE)), Promise.resolve();
|
|
1295
|
+
}
|
|
1296
|
+
close() {
|
|
1297
|
+
return s(this, He).close(), Promise.resolve();
|
|
1298
|
+
}
|
|
1299
|
+
};
|
|
1300
|
+
Z = new WeakMap(), K = new WeakMap(), He = new WeakMap(), Rn = new WeakMap(), l(qs, "DEFAULT_BUFFER_SIZE", 1024);
|
|
1301
|
+
let Dn = qs;
|
|
1302
|
+
const Ea = Math.pow(2, 6) - 1, Da = Math.pow(2, 14) - 1, Aa = Math.pow(2, 30) - 1, Yo = Number.MAX_SAFE_INTEGER, Jo = typeof BigInt == "function" ? k(2) ** k(62) - k(1) : k(Number.MAX_SAFE_INTEGER);
|
|
1303
|
+
function sr(i, t) {
|
|
1304
|
+
return t[0] = i, t.subarray(0, 1);
|
|
1305
|
+
}
|
|
1306
|
+
function Oa(i, t) {
|
|
1307
|
+
const e = new DataView(t.buffer, t.byteOffset, 2);
|
|
1308
|
+
return e.setUint16(0, i), new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
1309
|
+
}
|
|
1310
|
+
function Va(i, t) {
|
|
1311
|
+
const e = new DataView(t.buffer, t.byteOffset, 4);
|
|
1312
|
+
return e.setUint32(0, i), new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
1313
|
+
}
|
|
1314
|
+
function Ca(i, t) {
|
|
1315
|
+
const e = new DataView(t.buffer, t.byteOffset, 8);
|
|
1316
|
+
return e.setBigUint64(0, i), new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
1317
|
+
}
|
|
1318
|
+
function Ba(i, t) {
|
|
1319
|
+
const e = new DataView(t.buffer, t.byteOffset, 8);
|
|
1320
|
+
return e.setUint32(0, i / 4294967296), e.setUint32(4, i & 4294967295), t.set([192], 0), new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
1321
|
+
}
|
|
1322
|
+
function xa(i, t) {
|
|
1323
|
+
if (i <= Ea)
|
|
1324
|
+
return sr(i, t);
|
|
1325
|
+
if (i <= Da)
|
|
1326
|
+
return Oa(i | 16384, t);
|
|
1327
|
+
if (i <= Aa)
|
|
1328
|
+
return Va(i | 2147483648, t);
|
|
1329
|
+
if (i <= Yo)
|
|
1330
|
+
return typeof BigInt == "function" ? Ca(BigInt(i) | BigInt(3221225472) << BigInt(32), t) : Ba(Number(i), t);
|
|
1331
|
+
throw new Error(`overflow, value larger than 53-bits: ${i}`);
|
|
1332
|
+
}
|
|
1333
|
+
function Pa(i, t) {
|
|
1334
|
+
if (i < Ea)
|
|
1335
|
+
return sr(Number(i), t);
|
|
1336
|
+
if (i < Da)
|
|
1337
|
+
return Oa(Number(i) | 16384, t);
|
|
1338
|
+
if (i <= Aa)
|
|
1339
|
+
return Va(Number(i) | 2147483648, t);
|
|
1340
|
+
if (i <= Jo)
|
|
1341
|
+
return typeof BigInt == "function" ? Ca(BigInt(i) | BigInt(3221225472) << BigInt(32), t) : Ba(Number(i), t);
|
|
1342
|
+
throw new Error(`overflow, value larger than 62-bits: ${i}`);
|
|
1343
|
+
}
|
|
1344
|
+
var v = /* @__PURE__ */ ((i) => (i[i.SubscribeUpdate = 2] = "SubscribeUpdate", i[i.Subscribe = 3] = "Subscribe", i[i.SubscribeOk = 4] = "SubscribeOk", i[i.SubscribeError = 5] = "SubscribeError", i[i.Announce = 6] = "Announce", i[i.AnnounceOk = 7] = "AnnounceOk", i[i.AnnounceError = 8] = "AnnounceError", i[i.Unannounce = 9] = "Unannounce", i[i.Unsubscribe = 10] = "Unsubscribe", i[i.SubscribeDone = 11] = "SubscribeDone", i[i.AnnounceCancel = 12] = "AnnounceCancel", i[i.TrackStatusRequest = 13] = "TrackStatusRequest", i[i.TrackStatus = 14] = "TrackStatus", i[i.Goaway = 16] = "Goaway", i[i.ClientSetup = 64] = "ClientSetup", i[i.ServerSetup = 65] = "ServerSetup", i[i.Unknown = 255] = "Unknown", i))(v || {});
|
|
1345
|
+
function Ra(i) {
|
|
1346
|
+
return h(this, null, function* () {
|
|
1347
|
+
const t = yield i.readVarInt();
|
|
1348
|
+
if (t < 1 || t > 32)
|
|
1349
|
+
throw new Error(`namespace must be between 1 and 32, got ${t}`);
|
|
1350
|
+
const e = [];
|
|
1351
|
+
for (let n = 0; n < t; n++)
|
|
1352
|
+
e.push(yield i.readString());
|
|
1353
|
+
return e;
|
|
1354
|
+
});
|
|
1355
|
+
}
|
|
1356
|
+
function La(i, t) {
|
|
1357
|
+
return h(this, null, function* () {
|
|
1358
|
+
yield i.writeVarInt(t.length);
|
|
1359
|
+
for (const e of t)
|
|
1360
|
+
yield i.writeString(e);
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
function Ko(i, t) {
|
|
1364
|
+
return h(this, null, function* () {
|
|
1365
|
+
yield La(i, t.namespace);
|
|
1366
|
+
});
|
|
1367
|
+
}
|
|
1368
|
+
const ta = k(2);
|
|
1369
|
+
function Yi(i) {
|
|
1370
|
+
return h(this, null, function* () {
|
|
1371
|
+
const t = yield i.readVarInt(), e = /* @__PURE__ */ new Map();
|
|
1372
|
+
for (let n = 0; n < t; n++) {
|
|
1373
|
+
const r = yield i.readBigVarInt(), a = yield i.read(yield i.readVarInt());
|
|
1374
|
+
e.set(r, { type: r, payload: a });
|
|
1375
|
+
}
|
|
1376
|
+
return e;
|
|
1377
|
+
});
|
|
1378
|
+
}
|
|
1379
|
+
function Ji(i, t) {
|
|
1380
|
+
return h(this, null, function* () {
|
|
1381
|
+
yield i.writeVarInt(t.size);
|
|
1382
|
+
for (const [e, n] of t)
|
|
1383
|
+
yield i.writeBigVarInt(e), yield i.writeVarInt(n.payload.length), yield i.write(n.payload);
|
|
1384
|
+
});
|
|
1385
|
+
}
|
|
1386
|
+
const ja = {
|
|
1387
|
+
Publisher: 0,
|
|
1388
|
+
Subscriber: 1,
|
|
1389
|
+
Both: 2
|
|
1390
|
+
}, An = {
|
|
1391
|
+
Role: k(0)
|
|
1392
|
+
}, Ga = {
|
|
1393
|
+
Draft07: 4278190087
|
|
1394
|
+
};
|
|
1395
|
+
function Na(i) {
|
|
1396
|
+
return h(this, null, function* () {
|
|
1397
|
+
const t = yield i.readVarInt();
|
|
1398
|
+
switch (t) {
|
|
1399
|
+
case Ga.Draft07:
|
|
1400
|
+
return { type: "known", value: t };
|
|
1401
|
+
default:
|
|
1402
|
+
return { type: "unknown", value: t };
|
|
1403
|
+
}
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1406
|
+
function Qo(i, t) {
|
|
1407
|
+
return h(this, null, function* () {
|
|
1408
|
+
yield i.writeVarInt(t.supportedVersions.length);
|
|
1409
|
+
for (const e of t.supportedVersions)
|
|
1410
|
+
yield i.writeVarInt(e.value);
|
|
1411
|
+
yield Ji(i, t.parameters);
|
|
1412
|
+
});
|
|
1413
|
+
}
|
|
1414
|
+
function qo(i) {
|
|
1415
|
+
return h(this, null, function* () {
|
|
1416
|
+
const t = [], e = yield i.readVarInt();
|
|
1417
|
+
for (let r = 0; r < e; r++)
|
|
1418
|
+
t.push(yield Na(i));
|
|
1419
|
+
const n = yield Yi(i);
|
|
1420
|
+
if (!n.has(An.Role))
|
|
1421
|
+
throw new Error("Role parameter is required");
|
|
1422
|
+
return {
|
|
1423
|
+
type: v.ClientSetup,
|
|
1424
|
+
supportedVersions: t,
|
|
1425
|
+
parameters: n
|
|
1426
|
+
};
|
|
1427
|
+
});
|
|
1428
|
+
}
|
|
1429
|
+
function _o(i, t) {
|
|
1430
|
+
return h(this, null, function* () {
|
|
1431
|
+
yield i.writeVarInt(t.selectedVersion.value), yield Ji(i, t.parameters);
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
function tc(i) {
|
|
1435
|
+
return h(this, null, function* () {
|
|
1436
|
+
const t = yield Na(i);
|
|
1437
|
+
if (t.type !== "known")
|
|
1438
|
+
throw new Error("Expected known version");
|
|
1439
|
+
const e = yield Yi(i);
|
|
1440
|
+
if (!e.has(An.Role))
|
|
1441
|
+
throw new Error("Role parameter is required");
|
|
1442
|
+
return {
|
|
1443
|
+
type: v.ServerSetup,
|
|
1444
|
+
selectedVersion: t,
|
|
1445
|
+
parameters: e
|
|
1446
|
+
};
|
|
1447
|
+
});
|
|
1448
|
+
}
|
|
1449
|
+
const ec = {
|
|
1450
|
+
"latest-group": 1,
|
|
1451
|
+
"latest-object": 2,
|
|
1452
|
+
"absolute-start": 3,
|
|
1453
|
+
"absolute-range": 4
|
|
1454
|
+
};
|
|
1455
|
+
function sc(i) {
|
|
1456
|
+
return h(this, null, function* () {
|
|
1457
|
+
const t = yield i.readVarInt();
|
|
1458
|
+
switch (t) {
|
|
1459
|
+
case 1:
|
|
1460
|
+
return { type: "latest-group" };
|
|
1461
|
+
case 2:
|
|
1462
|
+
return { type: "latest-object" };
|
|
1463
|
+
case 3:
|
|
1464
|
+
return {
|
|
1465
|
+
type: "absolute-start",
|
|
1466
|
+
start: {
|
|
1467
|
+
group: yield i.readBigVarInt(),
|
|
1468
|
+
object: yield i.readBigVarInt()
|
|
1469
|
+
}
|
|
1470
|
+
};
|
|
1471
|
+
case 4:
|
|
1472
|
+
return {
|
|
1473
|
+
type: "absolute-range",
|
|
1474
|
+
start: {
|
|
1475
|
+
group: yield i.readBigVarInt(),
|
|
1476
|
+
object: yield i.readBigVarInt()
|
|
1477
|
+
},
|
|
1478
|
+
end: {
|
|
1479
|
+
group: yield i.readBigVarInt(),
|
|
1480
|
+
object: yield i.readBigVarInt()
|
|
1481
|
+
}
|
|
1482
|
+
};
|
|
1483
|
+
default:
|
|
1484
|
+
throw new Error(`Invalid location type ${t}`);
|
|
1485
|
+
}
|
|
1486
|
+
});
|
|
1487
|
+
}
|
|
1488
|
+
function ic(i, t) {
|
|
1489
|
+
return h(this, null, function* () {
|
|
1490
|
+
const e = ec[t.type];
|
|
1491
|
+
switch (yield i.writeVarInt(e), t.type) {
|
|
1492
|
+
case "absolute-range":
|
|
1493
|
+
yield i.writeBigVarInt(t.start.group), yield i.writeBigVarInt(t.start.object), yield i.writeBigVarInt(t.end.group), yield i.writeBigVarInt(t.end.object);
|
|
1494
|
+
break;
|
|
1495
|
+
case "absolute-start":
|
|
1496
|
+
yield i.writeBigVarInt(t.start.group), yield i.writeBigVarInt(t.start.object);
|
|
1497
|
+
break;
|
|
1498
|
+
case "latest-object":
|
|
1499
|
+
case "latest-group":
|
|
1500
|
+
break;
|
|
1501
|
+
default:
|
|
1502
|
+
throw new Error(`Invalid location type ${e}`);
|
|
1503
|
+
}
|
|
1504
|
+
});
|
|
1505
|
+
}
|
|
1506
|
+
function Fa(i) {
|
|
1507
|
+
return h(this, null, function* () {
|
|
1508
|
+
const t = yield i.readUnsigned8();
|
|
1509
|
+
switch (t) {
|
|
1510
|
+
case 0:
|
|
1511
|
+
return "inherit-publisher";
|
|
1512
|
+
case 1:
|
|
1513
|
+
return "ascending";
|
|
1514
|
+
case 2:
|
|
1515
|
+
return "descending";
|
|
1516
|
+
default:
|
|
1517
|
+
throw new Error(`Invalid location type ${t}`);
|
|
1518
|
+
}
|
|
1519
|
+
});
|
|
1520
|
+
}
|
|
1521
|
+
function Wa(i, t) {
|
|
1522
|
+
return h(this, null, function* () {
|
|
1523
|
+
switch (t) {
|
|
1524
|
+
case "inherit-publisher":
|
|
1525
|
+
yield i.writeUnsigned8(0);
|
|
1526
|
+
break;
|
|
1527
|
+
case "ascending":
|
|
1528
|
+
yield i.writeUnsigned8(1);
|
|
1529
|
+
break;
|
|
1530
|
+
case "descending":
|
|
1531
|
+
yield i.writeUnsigned8(2);
|
|
1532
|
+
break;
|
|
1533
|
+
}
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1536
|
+
function nc(i) {
|
|
1537
|
+
return h(this, null, function* () {
|
|
1538
|
+
const t = yield i.readBigVarInt(), e = yield i.readBigVarInt(), n = yield Ra(i), r = yield i.readString(), a = yield i.readUnsigned8(), c = yield Fa(i), d = yield sc(i), f = yield Yi(i);
|
|
1539
|
+
if (d.type === "absolute-range") {
|
|
1540
|
+
const p = d.start.group > d.end.group, b = d.start.group === d.end.group && d.start.object > d.end.object;
|
|
1541
|
+
if (p || b)
|
|
1542
|
+
throw new Error("Invalid filter range");
|
|
1543
|
+
}
|
|
1544
|
+
return {
|
|
1545
|
+
type: v.Subscribe,
|
|
1546
|
+
id: t,
|
|
1547
|
+
trackAlias: e,
|
|
1548
|
+
namespace: n,
|
|
1549
|
+
name: r,
|
|
1550
|
+
subscriberPriority: a,
|
|
1551
|
+
groupOrder: c,
|
|
1552
|
+
filterType: d,
|
|
1553
|
+
params: f
|
|
1554
|
+
};
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
function rc(i, t) {
|
|
1558
|
+
return h(this, null, function* () {
|
|
1559
|
+
yield i.writeBigVarInt(t.id), yield i.writeBigVarInt(t.trackAlias), yield La(i, t.namespace), yield i.writeString(t.name), yield i.writeUnsigned8(t.subscriberPriority), yield Wa(i, t.groupOrder), yield ic(i, t.filterType), yield Ji(i, t.params);
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
const ac = {
|
|
1563
|
+
Unsubscribed: 0,
|
|
1564
|
+
InternalError: 1,
|
|
1565
|
+
Unauthorized: 2,
|
|
1566
|
+
TrackEnded: 3,
|
|
1567
|
+
SubscriptionEnded: 4,
|
|
1568
|
+
GoingAway: 5,
|
|
1569
|
+
Expired: 6
|
|
1570
|
+
};
|
|
1571
|
+
function oc(i) {
|
|
1572
|
+
return h(this, null, function* () {
|
|
1573
|
+
const t = yield i.readBigVarInt(), e = yield i.readVarInt(), n = yield i.readString(), r = (yield i.readUnsigned8()) == 1;
|
|
1574
|
+
let a;
|
|
1575
|
+
return r && (a = {
|
|
1576
|
+
group: yield i.readBigVarInt(),
|
|
1577
|
+
object: yield i.readBigVarInt()
|
|
1578
|
+
}), {
|
|
1579
|
+
type: v.SubscribeDone,
|
|
1580
|
+
id: t,
|
|
1581
|
+
errorCode: e,
|
|
1582
|
+
reason: n,
|
|
1583
|
+
finalInfo: a
|
|
1584
|
+
};
|
|
1585
|
+
});
|
|
1586
|
+
}
|
|
1587
|
+
function cc(i, t) {
|
|
1588
|
+
return h(this, null, function* () {
|
|
1589
|
+
yield i.writeBigVarInt(t.id), yield i.writeVarInt(t.errorCode), yield i.writeString(t.reason), yield i.writeUnsigned8(t.finalInfo ? 1 : 0), t.finalInfo && (yield i.writeBigVarInt(t.finalInfo.group), yield i.writeBigVarInt(t.finalInfo.object));
|
|
1590
|
+
});
|
|
1591
|
+
}
|
|
1592
|
+
function uc(i) {
|
|
1593
|
+
return h(this, null, function* () {
|
|
1594
|
+
const t = yield i.readBigVarInt(), e = yield i.readBigVarInt(), n = yield Fa(i), r = (yield i.readUnsigned8()) == 1;
|
|
1595
|
+
let a;
|
|
1596
|
+
if (n == "inherit-publisher")
|
|
1597
|
+
throw new Error("SusbcribeOk cannot have inherit publisher group order");
|
|
1598
|
+
r && (a = {
|
|
1599
|
+
group: yield i.readBigVarInt(),
|
|
1600
|
+
object: yield i.readBigVarInt()
|
|
1601
|
+
});
|
|
1602
|
+
const c = yield Yi(i);
|
|
1603
|
+
return {
|
|
1604
|
+
type: v.SubscribeOk,
|
|
1605
|
+
id: t,
|
|
1606
|
+
groupOrder: n,
|
|
1607
|
+
expires: e,
|
|
1608
|
+
largestInfo: a,
|
|
1609
|
+
params: c
|
|
1610
|
+
};
|
|
1611
|
+
});
|
|
1612
|
+
}
|
|
1613
|
+
function hc(i, t) {
|
|
1614
|
+
return h(this, null, function* () {
|
|
1615
|
+
yield i.writeBigVarInt(t.id), yield i.writeBigVarInt(t.expires), yield Wa(i, t.groupOrder), yield i.writeUnsigned8(t.largestInfo ? 1 : 0), t.largestInfo && (yield i.writeBigVarInt(t.largestInfo.group), yield i.writeBigVarInt(t.largestInfo.object)), yield Ji(i, t.params);
|
|
1616
|
+
});
|
|
1617
|
+
}
|
|
1618
|
+
function lc(i, t) {
|
|
1619
|
+
return h(this, null, function* () {
|
|
1620
|
+
yield i.writeBigVarInt(t.id), yield i.writeBigVarInt(t.start.group), yield i.writeBigVarInt(t.start.object), yield i.writeBigVarInt(t.end.group), yield i.writeBigVarInt(t.end.object), yield i.writeUnsigned8(t.subscriberPriority), yield Ji(i, t.params);
|
|
1621
|
+
});
|
|
1622
|
+
}
|
|
1623
|
+
function dc(i) {
|
|
1624
|
+
return h(this, null, function* () {
|
|
1625
|
+
return {
|
|
1626
|
+
type: v.Unsubscribe,
|
|
1627
|
+
id: yield i.readBigVarInt()
|
|
1628
|
+
};
|
|
1629
|
+
});
|
|
1630
|
+
}
|
|
1631
|
+
function fc(i, t) {
|
|
1632
|
+
return h(this, null, function* () {
|
|
1633
|
+
yield i.writeBigVarInt(t.id);
|
|
1634
|
+
});
|
|
1635
|
+
}
|
|
1636
|
+
var Ot, Xe, L, za, Ma, Ha, Xa, Za, Ya, Ja, Ka;
|
|
1637
|
+
class $a {
|
|
1638
|
+
constructor(t) {
|
|
1639
|
+
o(this, L);
|
|
1640
|
+
o(this, Ot);
|
|
1641
|
+
// Temporary buffer that holds the message before it is written to the stream
|
|
1642
|
+
// This way we can calculate the byte length of the message before writing it
|
|
1643
|
+
o(this, Xe, new Uint8Array());
|
|
1644
|
+
u(this, Ot, t);
|
|
1645
|
+
}
|
|
1646
|
+
write(t) {
|
|
1647
|
+
return h(this, null, function* () {
|
|
1648
|
+
yield s(this, Ot).writeVarInt(t.type);
|
|
1649
|
+
const e = new Dn({
|
|
1650
|
+
close: () => {
|
|
1651
|
+
},
|
|
1652
|
+
send: (n) => {
|
|
1653
|
+
u(this, Xe, new Uint8Array(n));
|
|
1654
|
+
}
|
|
1655
|
+
});
|
|
1656
|
+
switch (t.type) {
|
|
1657
|
+
case v.Subscribe:
|
|
1658
|
+
yield w(this, L, Ha).call(this, e, t);
|
|
1659
|
+
break;
|
|
1660
|
+
case v.SubscribeOk:
|
|
1661
|
+
yield w(this, L, Xa).call(this, e, t);
|
|
1662
|
+
break;
|
|
1663
|
+
case v.SubscribeUpdate:
|
|
1664
|
+
yield w(this, L, Za).call(this, e, t);
|
|
1665
|
+
break;
|
|
1666
|
+
case v.SubscribeDone:
|
|
1667
|
+
yield w(this, L, Ya).call(this, e, t);
|
|
1668
|
+
break;
|
|
1669
|
+
case v.Unsubscribe:
|
|
1670
|
+
yield w(this, L, Ja).call(this, e, t);
|
|
1671
|
+
break;
|
|
1672
|
+
case v.ClientSetup:
|
|
1673
|
+
yield w(this, L, za).call(this, e, t);
|
|
1674
|
+
break;
|
|
1675
|
+
case v.ServerSetup:
|
|
1676
|
+
yield w(this, L, Ma).call(this, e, t);
|
|
1677
|
+
break;
|
|
1678
|
+
case v.AnnounceOk:
|
|
1679
|
+
yield w(this, L, Ka).call(this, e, t);
|
|
1680
|
+
break;
|
|
1681
|
+
default:
|
|
1682
|
+
throw new Error(`Unknown message type: ${t.type}`);
|
|
1683
|
+
}
|
|
1684
|
+
yield e.flush(), yield s(this, Ot).writeVarInt(s(this, Xe).byteLength), yield s(this, Ot).write(s(this, Xe)), yield s(this, Ot).flush();
|
|
1685
|
+
});
|
|
1686
|
+
}
|
|
1687
|
+
close() {
|
|
1688
|
+
return h(this, null, function* () {
|
|
1689
|
+
return s(this, Ot).close();
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
Ot = new WeakMap(), Xe = new WeakMap(), L = new WeakSet(), za = function(t, e) {
|
|
1694
|
+
return h(this, null, function* () {
|
|
1695
|
+
yield Qo(t, e);
|
|
1696
|
+
});
|
|
1697
|
+
}, Ma = function(t, e) {
|
|
1698
|
+
return h(this, null, function* () {
|
|
1699
|
+
yield _o(t, e);
|
|
1700
|
+
});
|
|
1701
|
+
}, Ha = function(t, e) {
|
|
1702
|
+
return h(this, null, function* () {
|
|
1703
|
+
yield rc(t, e);
|
|
1704
|
+
});
|
|
1705
|
+
}, Xa = function(t, e) {
|
|
1706
|
+
return h(this, null, function* () {
|
|
1707
|
+
yield hc(t, e);
|
|
1708
|
+
});
|
|
1709
|
+
}, Za = function(t, e) {
|
|
1710
|
+
return h(this, null, function* () {
|
|
1711
|
+
yield lc(t, e);
|
|
1712
|
+
});
|
|
1713
|
+
}, Ya = function(t, e) {
|
|
1714
|
+
return h(this, null, function* () {
|
|
1715
|
+
yield cc(t, e);
|
|
1716
|
+
});
|
|
1717
|
+
}, Ja = function(t, e) {
|
|
1718
|
+
return h(this, null, function* () {
|
|
1719
|
+
yield fc(t, e);
|
|
1720
|
+
});
|
|
1721
|
+
}, Ka = function(t, e) {
|
|
1722
|
+
return h(this, null, function* () {
|
|
1723
|
+
yield Ko(t, e);
|
|
1724
|
+
});
|
|
1725
|
+
};
|
|
1726
|
+
var Ze, ci, ui;
|
|
1727
|
+
class wc {
|
|
1728
|
+
constructor(t, e) {
|
|
1729
|
+
o(this, Ze);
|
|
1730
|
+
o(this, ci);
|
|
1731
|
+
o(this, ui);
|
|
1732
|
+
u(this, Ze, t), u(this, ci, new $a(t)), u(this, ui, e);
|
|
1733
|
+
}
|
|
1734
|
+
write(t) {
|
|
1735
|
+
return h(this, null, function* () {
|
|
1736
|
+
yield s(this, Ze).write(s(this, ui)), yield s(this, ci).write(t);
|
|
1737
|
+
});
|
|
1738
|
+
}
|
|
1739
|
+
close() {
|
|
1740
|
+
return s(this, Ze).close();
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
Ze = new WeakMap(), ci = new WeakMap(), ui = new WeakMap();
|
|
1744
|
+
function pc(i) {
|
|
1745
|
+
return h(this, null, function* () {
|
|
1746
|
+
return {
|
|
1747
|
+
type: v.Announce,
|
|
1748
|
+
namespace: yield Ra(i),
|
|
1749
|
+
params: yield Yi(i)
|
|
1750
|
+
};
|
|
1751
|
+
});
|
|
1752
|
+
}
|
|
1753
|
+
function mc(i) {
|
|
1754
|
+
return h(this, null, function* () {
|
|
1755
|
+
return {
|
|
1756
|
+
type: v.SubscribeError,
|
|
1757
|
+
id: yield i.readBigVarInt(),
|
|
1758
|
+
errorCode: yield i.readBigVarInt(),
|
|
1759
|
+
reason: yield i.readString(),
|
|
1760
|
+
trackAlias: yield i.readBigVarInt()
|
|
1761
|
+
};
|
|
1762
|
+
});
|
|
1763
|
+
}
|
|
1764
|
+
function bc(i, t, e) {
|
|
1765
|
+
return h(this, null, function* () {
|
|
1766
|
+
return {
|
|
1767
|
+
type: v.Unknown,
|
|
1768
|
+
messageType: t,
|
|
1769
|
+
payload: yield i.read(e)
|
|
1770
|
+
};
|
|
1771
|
+
});
|
|
1772
|
+
}
|
|
1773
|
+
var W;
|
|
1774
|
+
class ea {
|
|
1775
|
+
constructor(t) {
|
|
1776
|
+
o(this, W);
|
|
1777
|
+
u(this, W, t);
|
|
1778
|
+
}
|
|
1779
|
+
cancel() {
|
|
1780
|
+
return s(this, W).close();
|
|
1781
|
+
}
|
|
1782
|
+
read() {
|
|
1783
|
+
return h(this, null, function* () {
|
|
1784
|
+
const t = yield s(this, W).readVarInt(), e = yield s(this, W).readVarInt();
|
|
1785
|
+
switch (t) {
|
|
1786
|
+
case v.ServerSetup:
|
|
1787
|
+
return tc(s(this, W));
|
|
1788
|
+
case v.ClientSetup:
|
|
1789
|
+
return qo(s(this, W));
|
|
1790
|
+
case v.Subscribe:
|
|
1791
|
+
return nc(s(this, W));
|
|
1792
|
+
case v.SubscribeOk:
|
|
1793
|
+
return uc(s(this, W));
|
|
1794
|
+
case v.SubscribeDone:
|
|
1795
|
+
return oc(s(this, W));
|
|
1796
|
+
case v.SubscribeError:
|
|
1797
|
+
return mc(s(this, W));
|
|
1798
|
+
case v.Unsubscribe:
|
|
1799
|
+
return dc(s(this, W));
|
|
1800
|
+
case v.Announce:
|
|
1801
|
+
return pc(s(this, W));
|
|
1802
|
+
}
|
|
1803
|
+
return bc(s(this, W), k(t), e);
|
|
1804
|
+
});
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
W = new WeakMap();
|
|
1808
|
+
var hi, Ye, Je, li, Ln, Qa, jn;
|
|
1809
|
+
const Le = class Le {
|
|
1810
|
+
constructor(t, e) {
|
|
1811
|
+
o(this, Ln);
|
|
1812
|
+
o(this, hi);
|
|
1813
|
+
o(this, Ye);
|
|
1814
|
+
o(this, Je, new x());
|
|
1815
|
+
o(this, li, new x());
|
|
1816
|
+
u(this, hi, t), u(this, Ye, e), s(this, Je).resolve();
|
|
1817
|
+
}
|
|
1818
|
+
write(t) {
|
|
1819
|
+
return h(this, null, function* () {
|
|
1820
|
+
const e = yield w(this, Ln, Qa).call(this);
|
|
1821
|
+
try {
|
|
1822
|
+
yield s(this, hi).write(t);
|
|
1823
|
+
} finally {
|
|
1824
|
+
e.resolve();
|
|
1825
|
+
}
|
|
1826
|
+
});
|
|
1827
|
+
}
|
|
1828
|
+
markPostHandshake() {
|
|
1829
|
+
s(this, li).resolve();
|
|
1830
|
+
}
|
|
1831
|
+
postHandshake() {
|
|
1832
|
+
return s(this, li).promise;
|
|
1833
|
+
}
|
|
1834
|
+
// Not "thread" safe (:
|
|
1835
|
+
read() {
|
|
1836
|
+
return h(this, null, function* () {
|
|
1837
|
+
return s(this, Ye).read();
|
|
1838
|
+
});
|
|
1839
|
+
}
|
|
1840
|
+
cancel() {
|
|
1841
|
+
return s(this, Ye).cancel();
|
|
1842
|
+
}
|
|
1843
|
+
static wrapWebsocket(t) {
|
|
1844
|
+
const e = new ReadableStream(new Ho(t, s(Le, jn))), n = new ea(new En(new Uint8Array([]), e)), r = new wc(new Dn(t), new Uint8Array([0]));
|
|
1845
|
+
return new Le(r, n);
|
|
1846
|
+
}
|
|
1847
|
+
static wrapWebTransport(t) {
|
|
1848
|
+
const e = t.writable, n = t.readable;
|
|
1849
|
+
return new Le(
|
|
1850
|
+
new $a(new Zo(e)),
|
|
1851
|
+
new ea(new En(new Uint8Array(), n))
|
|
1852
|
+
);
|
|
1853
|
+
}
|
|
1854
|
+
};
|
|
1855
|
+
hi = new WeakMap(), Ye = new WeakMap(), Je = new WeakMap(), li = new WeakMap(), Ln = new WeakSet(), Qa = function() {
|
|
1856
|
+
const t = new x(), e = s(this, Je).promise.then(() => t);
|
|
1857
|
+
return u(this, Je, t), e;
|
|
1858
|
+
}, jn = new WeakMap(), o(Le, jn, 0);
|
|
1859
|
+
let On = Le;
|
|
1860
|
+
function qa(i, t) {
|
|
1861
|
+
return h(this, null, function* () {
|
|
1862
|
+
yield i.write({
|
|
1863
|
+
type: v.ClientSetup,
|
|
1864
|
+
supportedVersions: [{ type: "known", value: Ga.Draft07 }],
|
|
1865
|
+
parameters: /* @__PURE__ */ new Map([[An.Role, { type: An.Role, payload: new Uint8Array([t]) }]])
|
|
1866
|
+
});
|
|
1867
|
+
const e = yield i.read();
|
|
1868
|
+
if (i.markPostHandshake(), e.type !== v.ServerSetup)
|
|
1869
|
+
throw new Error("Expected server setup message");
|
|
1870
|
+
if (e.selectedVersion.type !== "known")
|
|
1871
|
+
throw new Error("Expected known version");
|
|
1872
|
+
});
|
|
1873
|
+
}
|
|
1874
|
+
var Ke, Nt, di, Gn, ne, ct;
|
|
1875
|
+
const Nn = class Nn {
|
|
1876
|
+
constructor(t) {
|
|
1877
|
+
l(this, "subscribe");
|
|
1878
|
+
o(this, Ke, new x());
|
|
1879
|
+
o(this, Nt, new x());
|
|
1880
|
+
o(this, di, new x());
|
|
1881
|
+
o(this, Gn, Date.now());
|
|
1882
|
+
o(this, ne, new x());
|
|
1883
|
+
o(this, ct);
|
|
1884
|
+
switch (this.subscribe = t, t.filterType.type) {
|
|
1885
|
+
case "absolute-start":
|
|
1886
|
+
u(this, ct, { startGroup: t.filterType.start.group });
|
|
1887
|
+
break;
|
|
1888
|
+
case "absolute-range":
|
|
1889
|
+
u(this, ct, { startGroup: t.filterType.start.group, endGroup: t.filterType.end.group });
|
|
1890
|
+
break;
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
onUpdate(t) {
|
|
1894
|
+
u(this, ct, { startGroup: t.start.group }), t.end.group > k(0) && (s(this, ct).endGroup = t.end.group - k(1));
|
|
1895
|
+
}
|
|
1896
|
+
onError(t) {
|
|
1897
|
+
const e = new Error(t.reason);
|
|
1898
|
+
return s(this, Ke).reject(e), s(this, Nt).reject(e), e;
|
|
1899
|
+
}
|
|
1900
|
+
onDone(t) {
|
|
1901
|
+
t.finalInfo && (s(this, ct) || u(this, ct, { startGroup: k(0) }), s(this, ct).endGroup = t.finalInfo.group), s(this, Nt).resolve(t);
|
|
1902
|
+
}
|
|
1903
|
+
onUnsubscribe(t) {
|
|
1904
|
+
s(this, di).resolve(t);
|
|
1905
|
+
}
|
|
1906
|
+
onOk(t) {
|
|
1907
|
+
const e = Math.max(0, Date.now() - s(this, Gn)), n = Number(t.expires);
|
|
1908
|
+
if (n > 0) {
|
|
1909
|
+
const r = Math.min(n / 10, Nn.maxGraceTime);
|
|
1910
|
+
Promise.race([er(n - r - e), this.done().catch(B)]).then(() => s(this, ne).resolve(this.expiryState())).catch(B);
|
|
1911
|
+
}
|
|
1912
|
+
s(this, Ke).resolve(t);
|
|
1913
|
+
}
|
|
1914
|
+
done() {
|
|
1915
|
+
return s(this, Nt).promise;
|
|
1916
|
+
}
|
|
1917
|
+
ok() {
|
|
1918
|
+
return s(this, Ke).promise;
|
|
1919
|
+
}
|
|
1920
|
+
range() {
|
|
1921
|
+
return s(this, ct);
|
|
1922
|
+
}
|
|
1923
|
+
close() {
|
|
1924
|
+
s(this, ne).promise.catch(B), s(this, ne).reject(new Error("Subscription closed"));
|
|
1925
|
+
}
|
|
1926
|
+
// Returns whether the subscription is still active - i.e. hasn't received a done or unsubscribe
|
|
1927
|
+
expiryState() {
|
|
1928
|
+
return s(this, Nt).resolved && s(this, Nt).resolved.errorCode !== ac.Expired ? "done" : s(this, di).pending ? "active" : "unsubscribed";
|
|
1929
|
+
}
|
|
1930
|
+
/**
|
|
1931
|
+
* Returns a promise that resolves when the subscription is about to expire (15 seconds before expiry).
|
|
1932
|
+
|
|
1933
|
+
*/
|
|
1934
|
+
expiryNotification() {
|
|
1935
|
+
return s(this, ne).promise;
|
|
1936
|
+
}
|
|
1937
|
+
};
|
|
1938
|
+
Ke = new WeakMap(), Nt = new WeakMap(), di = new WeakMap(), Gn = new WeakMap(), ne = new WeakMap(), ct = new WeakMap(), l(Nn, "maxGraceTime", 15e3);
|
|
1939
|
+
let mr = Nn;
|
|
1940
|
+
function yc(i, t) {
|
|
1941
|
+
const e = new mr(t), [n, r] = Pr(100), a = new gc(e, n), c = new _a(i, e, r);
|
|
1942
|
+
return [a, c];
|
|
1943
|
+
}
|
|
1944
|
+
var re;
|
|
1945
|
+
class gc {
|
|
1946
|
+
constructor(t, e) {
|
|
1947
|
+
l(this, "state");
|
|
1948
|
+
o(this, re);
|
|
1949
|
+
this.state = t, u(this, re, e);
|
|
1950
|
+
}
|
|
1951
|
+
onDone(t) {
|
|
1952
|
+
this.state.onDone(t);
|
|
1953
|
+
}
|
|
1954
|
+
onData(t) {
|
|
1955
|
+
return s(this, re).push(t);
|
|
1956
|
+
}
|
|
1957
|
+
onError(t) {
|
|
1958
|
+
const e = this.state.onError(t);
|
|
1959
|
+
s(this, re).abort(e);
|
|
1960
|
+
}
|
|
1961
|
+
/**
|
|
1962
|
+
* Closes the subscription producer so that no more objects an be emitted
|
|
1963
|
+
*/
|
|
1964
|
+
close() {
|
|
1965
|
+
this.state.close(), s(this, re).close();
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
re = new WeakMap();
|
|
1969
|
+
var ca, Qe, j, qe, _e, ur, ts, Cs;
|
|
1970
|
+
class _a {
|
|
1971
|
+
constructor(t, e, n) {
|
|
1972
|
+
Ce(ur, 5, this);
|
|
1973
|
+
o(this, ts);
|
|
1974
|
+
o(this, Qe);
|
|
1975
|
+
o(this, j);
|
|
1976
|
+
o(this, qe);
|
|
1977
|
+
o(this, _e, new x());
|
|
1978
|
+
u(this, Qe, t), u(this, j, e), u(this, qe, n);
|
|
1979
|
+
}
|
|
1980
|
+
get id() {
|
|
1981
|
+
return s(this, j).subscribe.id;
|
|
1982
|
+
}
|
|
1983
|
+
get trackAlias() {
|
|
1984
|
+
return s(this, j).subscribe.trackAlias;
|
|
1985
|
+
}
|
|
1986
|
+
get name() {
|
|
1987
|
+
return s(this, j).subscribe.name;
|
|
1988
|
+
}
|
|
1989
|
+
range() {
|
|
1990
|
+
return s(this, j).range();
|
|
1991
|
+
}
|
|
1992
|
+
expiryNotification() {
|
|
1993
|
+
return s(this, j).expiryNotification();
|
|
1994
|
+
}
|
|
1995
|
+
/**
|
|
1996
|
+
* Update the subscription range
|
|
1997
|
+
* @param startGroup the start group to subscribe to
|
|
1998
|
+
* @param endGroup the end group to subscribe to
|
|
1999
|
+
*/
|
|
2000
|
+
update(t, e) {
|
|
2001
|
+
return h(this, null, function* () {
|
|
2002
|
+
const n = {
|
|
2003
|
+
type: v.SubscribeUpdate,
|
|
2004
|
+
id: s(this, j).subscribe.id,
|
|
2005
|
+
start: { group: t, object: k(0) },
|
|
2006
|
+
end: { group: e + k(1), object: k(0) },
|
|
2007
|
+
params: /* @__PURE__ */ new Map(),
|
|
2008
|
+
subscriberPriority: 0
|
|
2009
|
+
};
|
|
2010
|
+
s(this, j).onUpdate(n), yield s(this, Qe).push(n);
|
|
2011
|
+
});
|
|
2012
|
+
}
|
|
2013
|
+
unsubscribe() {
|
|
2014
|
+
return h(this, null, function* () {
|
|
2015
|
+
const t = { type: v.Unsubscribe, id: s(this, j).subscribe.id };
|
|
2016
|
+
s(this, j).onUnsubscribe(t), yield s(this, Qe).push(t);
|
|
2017
|
+
});
|
|
2018
|
+
}
|
|
2019
|
+
/// Closes the object reader so any pending readData calls are resolved
|
|
2020
|
+
close() {
|
|
2021
|
+
var t, e;
|
|
2022
|
+
return s(this, _e).resolve(), (e = (t = s(this, qe)).return) == null ? void 0 : e.call(t);
|
|
2023
|
+
}
|
|
2024
|
+
/// Closed is resolved when the subscription has been fully consumed which means no more objects will be available
|
|
2025
|
+
closed() {
|
|
2026
|
+
return s(this, _e).promise;
|
|
2027
|
+
}
|
|
2028
|
+
/// Await this subscription to become done
|
|
2029
|
+
/// Done does not mean that the subscription is closed,
|
|
2030
|
+
/// it means that the server has confirmed our unsubscribe request
|
|
2031
|
+
done() {
|
|
2032
|
+
return s(this, j).done();
|
|
2033
|
+
}
|
|
2034
|
+
expiryState() {
|
|
2035
|
+
return s(this, j).expiryState();
|
|
2036
|
+
}
|
|
2037
|
+
return() {
|
|
2038
|
+
return h(this, null, function* () {
|
|
2039
|
+
return s(this, _e).resolve(), yield this.unsubscribe(), { done: !0, value: void 0 };
|
|
2040
|
+
});
|
|
2041
|
+
}
|
|
2042
|
+
groups() {
|
|
2043
|
+
return Dt(this, null, function* () {
|
|
2044
|
+
var t, e;
|
|
2045
|
+
try {
|
|
2046
|
+
for (var y = C(s(this, qe)), E, P, H; E = !(P = yield new A(y.next())).done; E = !1) {
|
|
2047
|
+
var d = P.value;
|
|
2048
|
+
var f = [];
|
|
2049
|
+
try {
|
|
2050
|
+
const T = mt(f, d, !0);
|
|
2051
|
+
try {
|
|
2052
|
+
for (var n = C(T.groups()), r, a, c; r = !(a = yield new A(n.next())).done; r = !1) {
|
|
2053
|
+
const g = a.value;
|
|
2054
|
+
const Y = (t = s(this, j).range()) == null ? void 0 : t.startGroup, S = (e = s(this, j).range()) == null ? void 0 : e.endGroup;
|
|
2055
|
+
if (Y && g.groupId() < Y)
|
|
2056
|
+
return { done: !0, value: void 0 };
|
|
2057
|
+
if (S && g.groupId() > S)
|
|
2058
|
+
return { done: !0, value: void 0 };
|
|
2059
|
+
yield g;
|
|
2060
|
+
}
|
|
2061
|
+
} catch (a) {
|
|
2062
|
+
c = [a];
|
|
2063
|
+
} finally {
|
|
2064
|
+
try {
|
|
2065
|
+
r && (a = n.return) && (yield new A(a.call(n)));
|
|
2066
|
+
} finally {
|
|
2067
|
+
if (c)
|
|
2068
|
+
throw c[0];
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
} catch (p) {
|
|
2072
|
+
var b = p, m = !0;
|
|
2073
|
+
} finally {
|
|
2074
|
+
var I = bt(f, b, m);
|
|
2075
|
+
I && (yield new A(I));
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
} catch (P) {
|
|
2079
|
+
H = [P];
|
|
2080
|
+
} finally {
|
|
2081
|
+
try {
|
|
2082
|
+
E && (P = y.return) && (yield new A(P.call(y)));
|
|
2083
|
+
} finally {
|
|
2084
|
+
if (H)
|
|
2085
|
+
throw H[0];
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
});
|
|
2089
|
+
}
|
|
2090
|
+
[Symbol.asyncIterator]() {
|
|
2091
|
+
return this.groups();
|
|
2092
|
+
}
|
|
2093
|
+
/**
|
|
2094
|
+
* @returns the next object from the subscription
|
|
2095
|
+
*/
|
|
2096
|
+
objects() {
|
|
2097
|
+
return Dt(this, null, function* () {
|
|
2098
|
+
try {
|
|
2099
|
+
for (var a = C(this.groups()), c, d, f; c = !(d = yield new A(a.next())).done; c = !1) {
|
|
2100
|
+
const p = d.value;
|
|
2101
|
+
try {
|
|
2102
|
+
for (var t = C(p), e, n, r; e = !(n = yield new A(t.next())).done; e = !1) {
|
|
2103
|
+
const b = n.value;
|
|
2104
|
+
yield b;
|
|
2105
|
+
}
|
|
2106
|
+
} catch (n) {
|
|
2107
|
+
r = [n];
|
|
2108
|
+
} finally {
|
|
2109
|
+
try {
|
|
2110
|
+
e && (n = t.return) && (yield new A(n.call(t)));
|
|
2111
|
+
} finally {
|
|
2112
|
+
if (r)
|
|
2113
|
+
throw r[0];
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
} catch (d) {
|
|
2118
|
+
f = [d];
|
|
2119
|
+
} finally {
|
|
2120
|
+
try {
|
|
2121
|
+
c && (d = a.return) && (yield new A(d.call(a)));
|
|
2122
|
+
} finally {
|
|
2123
|
+
if (f)
|
|
2124
|
+
throw f[0];
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
});
|
|
2128
|
+
}
|
|
2129
|
+
[(ca = [_({ context: "SubscriptionConsumer", enter: "info" })], Oe())]() {
|
|
2130
|
+
return w(this, ts, Cs).call(this);
|
|
2131
|
+
}
|
|
2132
|
+
[Symbol.asyncDispose]() {
|
|
2133
|
+
return w(this, ts, Cs).call(this);
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
ur = Ve(null), Qe = new WeakMap(), j = new WeakMap(), qe = new WeakMap(), _e = new WeakMap(), ts = new WeakSet(), Cs = function() {
|
|
2137
|
+
return h(this, null, function* () {
|
|
2138
|
+
return yield this.close(), this.unsubscribe();
|
|
2139
|
+
});
|
|
2140
|
+
}, Cs = X(ur, 17, "#dispose", ca, ts, Cs), Jt(ur, _a);
|
|
2141
|
+
const vc = 2e3;
|
|
2142
|
+
var ua, ha, la, da, fa, wa, st, Q, ae, oe, Qt, R, nn, Bs, xs, Be;
|
|
2143
|
+
class br {
|
|
2144
|
+
constructor(t, e) {
|
|
2145
|
+
Ce(Qt, 5, this);
|
|
2146
|
+
o(this, R);
|
|
2147
|
+
// The owner session of the subscriber
|
|
2148
|
+
o(this, st);
|
|
2149
|
+
// The next subscribe id
|
|
2150
|
+
l(this, "nextSubscribeId", k(0));
|
|
2151
|
+
// The active subscriptions
|
|
2152
|
+
o(this, Q, new ft(/* @__PURE__ */ new Map()));
|
|
2153
|
+
o(this, ae);
|
|
2154
|
+
o(this, oe, Xt.get().createContext("Subscriber"));
|
|
2155
|
+
u(this, st, t), u(this, ae, e), w(this, R, nn).call(this).catch(B), s(this, st).closed().then(() => w(this, R, xs).call(this)).catch(B);
|
|
2156
|
+
}
|
|
2157
|
+
[(wa = [_({ context: "Session", return: "debug" })], fa = [_({ context: "Session", enter: "debug" })], Sa())]() {
|
|
2158
|
+
w(this, R, Bs).call(this);
|
|
2159
|
+
}
|
|
2160
|
+
[(da = Symbol.dispose, la = [_({ context: "Session", enter: "info", error: "error" })], ha = [_({ context: "Session", enter: "debug" })], ua = [_({ context: "Session", enter: "debug" })], da)]() {
|
|
2161
|
+
w(this, R, Bs).call(this);
|
|
2162
|
+
}
|
|
2163
|
+
subscribe(t, e) {
|
|
2164
|
+
return h(this, null, function* () {
|
|
2165
|
+
const n = this.nextSubscribeId++, r = /* @__PURE__ */ new Map(), a = s(this, st).authToken.current();
|
|
2166
|
+
a && r.set(ta, { type: ta, payload: new TextEncoder().encode(a) });
|
|
2167
|
+
const c = {
|
|
2168
|
+
type: v.Subscribe,
|
|
2169
|
+
namespace: t,
|
|
2170
|
+
name: e.name,
|
|
2171
|
+
id: n,
|
|
2172
|
+
trackAlias: n,
|
|
2173
|
+
groupOrder: e.groupOrder,
|
|
2174
|
+
subscriberPriority: e.priority,
|
|
2175
|
+
filterType: e.filterType,
|
|
2176
|
+
params: r
|
|
2177
|
+
}, [d, f] = yc(s(this, ae), c);
|
|
2178
|
+
if (s(this, Q).update((b) => b.set(n, d)), yield s(this, ae).push(c), !(yield Promise.race([d.state.ok(), s(this, st).closed()])))
|
|
2179
|
+
throw new Error("Session closed");
|
|
2180
|
+
return f.closed().then(() => Promise.race([er(vc), this.closed()])).then(() => w(this, R, Be).call(this, f.id)).catch(() => w(this, R, Be).call(this, f.id)), f;
|
|
2181
|
+
});
|
|
2182
|
+
}
|
|
2183
|
+
closed() {
|
|
2184
|
+
return s(this, st).closed();
|
|
2185
|
+
}
|
|
2186
|
+
close() {
|
|
2187
|
+
s(this, st).close();
|
|
2188
|
+
}
|
|
2189
|
+
updateAuthToken(t) {
|
|
2190
|
+
s(this, st).authToken.update(t);
|
|
2191
|
+
}
|
|
2192
|
+
transportType() {
|
|
2193
|
+
return s(this, st).transportType();
|
|
2194
|
+
}
|
|
2195
|
+
url() {
|
|
2196
|
+
return s(this, st).url();
|
|
2197
|
+
}
|
|
2198
|
+
onMessage(t) {
|
|
2199
|
+
return h(this, null, function* () {
|
|
2200
|
+
switch (t.type) {
|
|
2201
|
+
case v.Announce:
|
|
2202
|
+
yield s(this, ae).push({
|
|
2203
|
+
type: v.AnnounceOk,
|
|
2204
|
+
namespace: t.namespace
|
|
2205
|
+
});
|
|
2206
|
+
break;
|
|
2207
|
+
case v.SubscribeOk:
|
|
2208
|
+
{
|
|
2209
|
+
const e = s(this, Q).current().get(t.id);
|
|
2210
|
+
e && e.state.onOk(t);
|
|
2211
|
+
}
|
|
2212
|
+
break;
|
|
2213
|
+
case v.SubscribeError:
|
|
2214
|
+
{
|
|
2215
|
+
const e = s(this, Q).current().get(t.id);
|
|
2216
|
+
e || s(this, oe).debug("No subscription found", t), e == null || e.onError(t), w(this, R, Be).call(this, t.id);
|
|
2217
|
+
}
|
|
2218
|
+
break;
|
|
2219
|
+
case v.SubscribeDone:
|
|
2220
|
+
{
|
|
2221
|
+
const e = s(this, Q).current().get(t.id);
|
|
2222
|
+
e || s(this, oe).debug("No subscription found", t), e == null || e.onDone(t);
|
|
2223
|
+
}
|
|
2224
|
+
break;
|
|
2225
|
+
}
|
|
2226
|
+
});
|
|
2227
|
+
}
|
|
2228
|
+
onObjectReader(t) {
|
|
2229
|
+
return h(this, null, function* () {
|
|
2230
|
+
const e = s(this, Q).current().get(t.subscribeId());
|
|
2231
|
+
if (!e) {
|
|
2232
|
+
s(this, oe).warn("No subscription found", t.subscribeId());
|
|
2233
|
+
return;
|
|
2234
|
+
}
|
|
2235
|
+
yield e.onData(t);
|
|
2236
|
+
});
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
Qt = Ve(null), st = new WeakMap(), Q = new WeakMap(), ae = new WeakMap(), oe = new WeakMap(), R = new WeakSet(), nn = function() {
|
|
2240
|
+
return h(this, null, function* () {
|
|
2241
|
+
try {
|
|
2242
|
+
for (var t = C(s(this, Q)), e, n, r; e = !(n = yield t.next()).done; e = !1) {
|
|
2243
|
+
const a = n.value;
|
|
2244
|
+
const c = [...a.values()].map((d) => d.state.subscribe);
|
|
2245
|
+
s(this, oe).debug("current subscriptions", c);
|
|
2246
|
+
}
|
|
2247
|
+
} catch (n) {
|
|
2248
|
+
r = [n];
|
|
2249
|
+
} finally {
|
|
2250
|
+
try {
|
|
2251
|
+
e && (n = t.return) && (yield n.call(t));
|
|
2252
|
+
} finally {
|
|
2253
|
+
if (r)
|
|
2254
|
+
throw r[0];
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
});
|
|
2258
|
+
}, Bs = function() {
|
|
2259
|
+
w(this, R, xs).call(this);
|
|
2260
|
+
}, xs = function() {
|
|
2261
|
+
s(this, Q).current().forEach((t) => t.close()), s(this, Q).close();
|
|
2262
|
+
}, Be = function(t) {
|
|
2263
|
+
s(this, Q).isClosed() || s(this, Q).update((e) => (e.delete(t), e));
|
|
2264
|
+
}, nn = X(Qt, 17, "#observeChanges", wa, R, nn), Bs = X(Qt, 17, "#dispose", fa, R, Bs), X(Qt, 1, "subscribe", la, br), xs = X(Qt, 17, "#close", ha, R, xs), Be = X(Qt, 17, "#deleteSubscription", ua, R, Be), Jt(Qt, br);
|
|
2265
|
+
var pa, ma, ba, ut, fi, ce, es, ss, M, to, eo, As, rn, an, on;
|
|
2266
|
+
ba = [_({ context: "Session", return: "info", error: "error" })], ma = [_({ context: "Session", return: "info", error: "error" })], pa = [_({ context: "Session", return: "info", error: "error" })];
|
|
2267
|
+
const Fn = class Fn {
|
|
2268
|
+
constructor(t, e, n) {
|
|
2269
|
+
Ce(As, 5, this);
|
|
2270
|
+
o(this, M);
|
|
2271
|
+
// The underlying transport implementation
|
|
2272
|
+
o(this, ut);
|
|
2273
|
+
// The background "thread" running the background tasks
|
|
2274
|
+
o(this, fi);
|
|
2275
|
+
// Outgoing messages
|
|
2276
|
+
o(this, ce);
|
|
2277
|
+
// If the session has a subscriber role this is set - otherwise undefined
|
|
2278
|
+
o(this, es);
|
|
2279
|
+
o(this, ss, Xt.get().createContext("Subscriber"));
|
|
2280
|
+
l(this, "authToken");
|
|
2281
|
+
u(this, ut, t), u(this, ce, e), u(this, fi, w(this, M, eo).call(this)), this.authToken = new ft(n);
|
|
2282
|
+
}
|
|
2283
|
+
static subscriber(t, e) {
|
|
2284
|
+
const [n, r] = Pr(100), a = new Fn(t, r, e), c = new br(a, n);
|
|
2285
|
+
return u(a, es, c), c;
|
|
2286
|
+
}
|
|
2287
|
+
transportType() {
|
|
2288
|
+
return s(this, ut).transportType();
|
|
2289
|
+
}
|
|
2290
|
+
url() {
|
|
2291
|
+
return s(this, ut).url();
|
|
2292
|
+
}
|
|
2293
|
+
closed() {
|
|
2294
|
+
return s(this, fi);
|
|
2295
|
+
}
|
|
2296
|
+
close() {
|
|
2297
|
+
try {
|
|
2298
|
+
s(this, ce).cancel("closing"), s(this, ut).close();
|
|
2299
|
+
} catch (t) {
|
|
2300
|
+
s(this, ss).warn("Error closing session", t);
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
};
|
|
2304
|
+
As = Ve(null), ut = new WeakMap(), fi = new WeakMap(), ce = new WeakMap(), es = new WeakMap(), ss = new WeakMap(), M = new WeakSet(), to = function(t) {
|
|
2305
|
+
return h(this, null, function* () {
|
|
2306
|
+
var e;
|
|
2307
|
+
switch (s(this, ss).debug("received message", t), yield (e = s(this, es)) == null ? void 0 : e.onMessage(t), t.type) {
|
|
2308
|
+
case v.Goaway:
|
|
2309
|
+
break;
|
|
2310
|
+
}
|
|
2311
|
+
});
|
|
2312
|
+
}, eo = function() {
|
|
2313
|
+
return h(this, null, function* () {
|
|
2314
|
+
return (yield Promise.all([w(this, M, an).call(this), w(this, M, on).call(this), w(this, M, rn).call(this)])).find((e) => e instanceof Error);
|
|
2315
|
+
});
|
|
2316
|
+
}, rn = function() {
|
|
2317
|
+
return h(this, null, function* () {
|
|
2318
|
+
try {
|
|
2319
|
+
try {
|
|
2320
|
+
for (var t = C(s(this, ce)), e, n, r; e = !(n = yield t.next()).done; e = !1) {
|
|
2321
|
+
const a = n.value;
|
|
2322
|
+
s(this, ss).debug("sending message", a), yield s(this, ut).writeMessage(a);
|
|
2323
|
+
}
|
|
2324
|
+
} catch (n) {
|
|
2325
|
+
r = [n];
|
|
2326
|
+
} finally {
|
|
2327
|
+
try {
|
|
2328
|
+
e && (n = t.return) && (yield n.call(t));
|
|
2329
|
+
} finally {
|
|
2330
|
+
if (r)
|
|
2331
|
+
throw r[0];
|
|
2332
|
+
}
|
|
2333
|
+
}
|
|
2334
|
+
} catch (a) {
|
|
2335
|
+
return a;
|
|
2336
|
+
}
|
|
2337
|
+
});
|
|
2338
|
+
}, an = function() {
|
|
2339
|
+
return h(this, null, function* () {
|
|
2340
|
+
yield s(this, ut).afterHandshake();
|
|
2341
|
+
try {
|
|
2342
|
+
for (; ; ) {
|
|
2343
|
+
const t = yield s(this, ut).readMessage().catch(() => {
|
|
2344
|
+
});
|
|
2345
|
+
if (!t)
|
|
2346
|
+
break;
|
|
2347
|
+
yield w(this, M, to).call(this, t);
|
|
2348
|
+
}
|
|
2349
|
+
} catch (t) {
|
|
2350
|
+
return t;
|
|
2351
|
+
} finally {
|
|
2352
|
+
s(this, ce).cancel("closing");
|
|
2353
|
+
}
|
|
2354
|
+
});
|
|
2355
|
+
}, on = function() {
|
|
2356
|
+
return h(this, null, function* () {
|
|
2357
|
+
var t;
|
|
2358
|
+
try {
|
|
2359
|
+
for (; ; ) {
|
|
2360
|
+
const e = yield s(this, ut).objectStream();
|
|
2361
|
+
if (!e)
|
|
2362
|
+
break;
|
|
2363
|
+
yield (t = s(this, es)) == null ? void 0 : t.onObjectReader(e);
|
|
2364
|
+
}
|
|
2365
|
+
} catch (e) {
|
|
2366
|
+
return e;
|
|
2367
|
+
}
|
|
2368
|
+
});
|
|
2369
|
+
}, rn = X(As, 17, "#runOutgoingMessages", ba, M, rn), an = X(As, 17, "#runControl", ma, M, an), on = X(As, 17, "#runObjects", pa, M, on), Jt(As, Fn);
|
|
2370
|
+
let Vn = Fn;
|
|
2371
|
+
var yr = /* @__PURE__ */ ((i) => (i[i.StreamHeaderGroup = 4] = "StreamHeaderGroup", i[i.FetchHeader = 5] = "FetchHeader", i[i.StreamHeaderTrack = 60] = "StreamHeaderTrack", i))(yr || {});
|
|
2372
|
+
const $ = {
|
|
2373
|
+
Normal: 0,
|
|
2374
|
+
ObjectDoesNotExist: 1,
|
|
2375
|
+
GroupDoesNotExist: 2,
|
|
2376
|
+
EndOfGroup: 3,
|
|
2377
|
+
EndOfTrackAndGroup: 4
|
|
2378
|
+
};
|
|
2379
|
+
function so(i) {
|
|
2380
|
+
switch (i) {
|
|
2381
|
+
case $.Normal:
|
|
2382
|
+
case $.ObjectDoesNotExist:
|
|
2383
|
+
case $.GroupDoesNotExist:
|
|
2384
|
+
case $.EndOfGroup:
|
|
2385
|
+
case $.EndOfTrackAndGroup:
|
|
2386
|
+
return;
|
|
2387
|
+
}
|
|
2388
|
+
throw new Error("Unknown object status " + i);
|
|
2389
|
+
}
|
|
2390
|
+
var kt, is, ns, wi, pi, rs, mi;
|
|
2391
|
+
class kc {
|
|
2392
|
+
constructor(t, e, n, r, a) {
|
|
2393
|
+
o(this, kt);
|
|
2394
|
+
o(this, is);
|
|
2395
|
+
o(this, ns);
|
|
2396
|
+
o(this, wi);
|
|
2397
|
+
o(this, pi);
|
|
2398
|
+
o(this, rs, new x());
|
|
2399
|
+
o(this, mi, 0);
|
|
2400
|
+
u(this, kt, t), u(this, is, e), u(this, ns, n), u(this, wi, r), u(this, pi, a);
|
|
2401
|
+
}
|
|
2402
|
+
endStatus() {
|
|
2403
|
+
return s(this, rs).promise;
|
|
2404
|
+
}
|
|
2405
|
+
groupId() {
|
|
2406
|
+
return s(this, is);
|
|
2407
|
+
}
|
|
2408
|
+
subscribeId() {
|
|
2409
|
+
return s(this, ns);
|
|
2410
|
+
}
|
|
2411
|
+
next() {
|
|
2412
|
+
return h(this, null, function* () {
|
|
2413
|
+
if (!s(this, rs).pending)
|
|
2414
|
+
return { done: !0, value: void 0 };
|
|
2415
|
+
if (yield s(this, kt).isDone())
|
|
2416
|
+
return { done: !0, value: void 0 };
|
|
2417
|
+
const t = s(this, mi) === 0 ? s(this, is) : yield s(this, kt).readBigVarInt(), e = yield s(this, kt).readBigVarInt(), n = yield s(this, kt).readVarInt();
|
|
2418
|
+
let r = 0, a = new Uint8Array();
|
|
2419
|
+
return n > 0 ? a = yield s(this, kt).read(n) : r = yield s(this, kt).readVarInt(), so(r), (r === $.EndOfTrackAndGroup || r === $.EndOfGroup) && s(this, rs).resolve(r), qr(this, mi)._++, {
|
|
2420
|
+
done: !1,
|
|
2421
|
+
value: {
|
|
2422
|
+
subscribeId: s(this, ns),
|
|
2423
|
+
trackAlias: s(this, wi),
|
|
2424
|
+
groupId: t,
|
|
2425
|
+
subGroupId: k(0),
|
|
2426
|
+
objectId: e,
|
|
2427
|
+
subscriberPriority: s(this, pi),
|
|
2428
|
+
objectStatus: r,
|
|
2429
|
+
payload: a
|
|
2430
|
+
}
|
|
2431
|
+
};
|
|
2432
|
+
});
|
|
2433
|
+
}
|
|
2434
|
+
return() {
|
|
2435
|
+
return h(this, null, function* () {
|
|
2436
|
+
for (; !(yield this.next()).done; )
|
|
2437
|
+
;
|
|
2438
|
+
return { done: !0, value: void 0 };
|
|
2439
|
+
});
|
|
2440
|
+
}
|
|
2441
|
+
[Symbol.asyncIterator]() {
|
|
2442
|
+
return this;
|
|
2443
|
+
}
|
|
2444
|
+
[Oe()]() {
|
|
2445
|
+
return Promise.resolve();
|
|
2446
|
+
}
|
|
2447
|
+
[Symbol.asyncDispose]() {
|
|
2448
|
+
return Promise.resolve();
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
kt = new WeakMap(), is = new WeakMap(), ns = new WeakMap(), wi = new WeakMap(), pi = new WeakMap(), rs = new WeakMap(), mi = new WeakMap();
|
|
2452
|
+
var Vt, as, bi, yi, Ee, io, gr;
|
|
2453
|
+
class Ic {
|
|
2454
|
+
constructor(t, e, n, r) {
|
|
2455
|
+
o(this, Ee);
|
|
2456
|
+
o(this, Vt);
|
|
2457
|
+
o(this, as);
|
|
2458
|
+
o(this, bi);
|
|
2459
|
+
o(this, yi);
|
|
2460
|
+
u(this, Vt, t), u(this, as, e), u(this, bi, n), u(this, yi, r);
|
|
2461
|
+
}
|
|
2462
|
+
groups() {
|
|
2463
|
+
return w(this, Ee, io).call(this);
|
|
2464
|
+
}
|
|
2465
|
+
subscribeId() {
|
|
2466
|
+
return s(this, as);
|
|
2467
|
+
}
|
|
2468
|
+
return() {
|
|
2469
|
+
return h(this, null, function* () {
|
|
2470
|
+
return yield s(this, Vt).close(), { done: !0, value: void 0 };
|
|
2471
|
+
});
|
|
2472
|
+
}
|
|
2473
|
+
[Symbol.asyncIterator]() {
|
|
2474
|
+
return this;
|
|
2475
|
+
}
|
|
2476
|
+
[Oe()]() {
|
|
2477
|
+
return w(this, Ee, gr).call(this);
|
|
2478
|
+
}
|
|
2479
|
+
[Symbol.asyncDispose]() {
|
|
2480
|
+
return w(this, Ee, gr).call(this);
|
|
2481
|
+
}
|
|
2482
|
+
}
|
|
2483
|
+
Vt = new WeakMap(), as = new WeakMap(), bi = new WeakMap(), yi = new WeakMap(), Ee = new WeakSet(), io = function() {
|
|
2484
|
+
return Dt(this, null, function* () {
|
|
2485
|
+
for (; !(yield new A(s(this, Vt).isDone())); ) {
|
|
2486
|
+
const t = yield new A(s(this, Vt).readBigVarInt()), e = new kc(
|
|
2487
|
+
s(this, Vt),
|
|
2488
|
+
t,
|
|
2489
|
+
s(this, as),
|
|
2490
|
+
s(this, bi),
|
|
2491
|
+
s(this, yi)
|
|
2492
|
+
);
|
|
2493
|
+
if (yield e, (yield new A(e.endStatus())) === $.EndOfTrackAndGroup)
|
|
2494
|
+
return;
|
|
2495
|
+
}
|
|
2496
|
+
});
|
|
2497
|
+
}, gr = function() {
|
|
2498
|
+
return s(this, Vt).close().catch(() => {
|
|
2499
|
+
});
|
|
2500
|
+
};
|
|
2501
|
+
var ht, os, gi, cs, vi, ki, Ii, Wn, De, no, vr;
|
|
2502
|
+
class Sc {
|
|
2503
|
+
constructor(t, e, n, r, a, c) {
|
|
2504
|
+
o(this, De);
|
|
2505
|
+
o(this, ht);
|
|
2506
|
+
o(this, os);
|
|
2507
|
+
o(this, gi);
|
|
2508
|
+
o(this, cs);
|
|
2509
|
+
o(this, vi);
|
|
2510
|
+
o(this, ki);
|
|
2511
|
+
o(this, Ii, !1);
|
|
2512
|
+
o(this, Wn, Xt.get().createContext("GroupReader"));
|
|
2513
|
+
u(this, ht, t), u(this, os, e), u(this, gi, n), u(this, cs, r), u(this, vi, a), u(this, ki, c);
|
|
2514
|
+
}
|
|
2515
|
+
groupId() {
|
|
2516
|
+
return s(this, cs);
|
|
2517
|
+
}
|
|
2518
|
+
subscribeId() {
|
|
2519
|
+
return s(this, os);
|
|
2520
|
+
}
|
|
2521
|
+
next() {
|
|
2522
|
+
return h(this, null, function* () {
|
|
2523
|
+
try {
|
|
2524
|
+
if ((yield s(this, ht).isDone()) || s(this, Ii))
|
|
2525
|
+
return { done: !0, value: void 0 };
|
|
2526
|
+
const t = yield s(this, ht).readBigVarInt(), e = yield s(this, ht).readVarInt();
|
|
2527
|
+
let n = 0, r = new Uint8Array();
|
|
2528
|
+
return e > 0 ? r = yield s(this, ht).read(e) : n = yield s(this, ht).readVarInt(), so(n), n === $.EndOfGroup && u(this, Ii, !0), {
|
|
2529
|
+
done: !1,
|
|
2530
|
+
value: {
|
|
2531
|
+
subscribeId: s(this, os),
|
|
2532
|
+
trackAlias: s(this, gi),
|
|
2533
|
+
groupId: s(this, cs),
|
|
2534
|
+
subGroupId: s(this, vi),
|
|
2535
|
+
subscriberPriority: s(this, ki),
|
|
2536
|
+
objectId: t,
|
|
2537
|
+
objectStatus: n,
|
|
2538
|
+
payload: r
|
|
2539
|
+
}
|
|
2540
|
+
};
|
|
2541
|
+
} catch (t) {
|
|
2542
|
+
return s(this, Wn).info("Error reading object", { error: t }), { done: !0, value: void 0 };
|
|
2543
|
+
}
|
|
2544
|
+
});
|
|
2545
|
+
}
|
|
2546
|
+
return() {
|
|
2547
|
+
return h(this, null, function* () {
|
|
2548
|
+
return yield s(this, ht).close().catch(() => {
|
|
2549
|
+
}), { done: !0, value: void 0 };
|
|
2550
|
+
});
|
|
2551
|
+
}
|
|
2552
|
+
groups() {
|
|
2553
|
+
return w(this, De, no).call(this);
|
|
2554
|
+
}
|
|
2555
|
+
[Symbol.asyncIterator]() {
|
|
2556
|
+
return this;
|
|
2557
|
+
}
|
|
2558
|
+
[Oe()]() {
|
|
2559
|
+
return w(this, De, vr).call(this);
|
|
2560
|
+
}
|
|
2561
|
+
[Symbol.asyncDispose]() {
|
|
2562
|
+
return w(this, De, vr).call(this);
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
2565
|
+
ht = new WeakMap(), os = new WeakMap(), gi = new WeakMap(), cs = new WeakMap(), vi = new WeakMap(), ki = new WeakMap(), Ii = new WeakMap(), Wn = new WeakMap(), De = new WeakSet(), no = function() {
|
|
2566
|
+
return Dt(this, null, function* () {
|
|
2567
|
+
yield this;
|
|
2568
|
+
});
|
|
2569
|
+
}, vr = function() {
|
|
2570
|
+
return s(this, ht).close().catch(() => {
|
|
2571
|
+
});
|
|
2572
|
+
};
|
|
2573
|
+
function ro(i) {
|
|
2574
|
+
return h(this, null, function* () {
|
|
2575
|
+
const t = yield i.readVarInt();
|
|
2576
|
+
switch (t) {
|
|
2577
|
+
case yr.StreamHeaderGroup: {
|
|
2578
|
+
const e = yield i.readBigVarInt(), n = yield i.readBigVarInt(), r = yield i.readBigVarInt(), a = yield i.readBigVarInt(), c = yield i.readUnsigned8();
|
|
2579
|
+
return new Sc(i, e, n, r, a, c);
|
|
2580
|
+
}
|
|
2581
|
+
case yr.StreamHeaderTrack: {
|
|
2582
|
+
const e = yield i.readBigVarInt(), n = yield i.readBigVarInt(), r = yield i.readUnsigned8();
|
|
2583
|
+
return new Ic(i, e, n, r);
|
|
2584
|
+
}
|
|
2585
|
+
default:
|
|
2586
|
+
throw new Error("Unexpected message type " + t);
|
|
2587
|
+
}
|
|
2588
|
+
});
|
|
2589
|
+
}
|
|
2590
|
+
var ue, Ft, us, he, Ct;
|
|
2591
|
+
class Uc {
|
|
2592
|
+
constructor(t, e) {
|
|
2593
|
+
o(this, ue);
|
|
2594
|
+
o(this, Ft);
|
|
2595
|
+
o(this, us);
|
|
2596
|
+
o(this, he);
|
|
2597
|
+
o(this, Ct, /* @__PURE__ */ new Map());
|
|
2598
|
+
u(this, ue, t), u(this, Ft, e), u(this, us, new ReadableStream(new Xo(t))), s(this, ue).addEventListener("close", () => {
|
|
2599
|
+
s(this, Ct).forEach((n) => n.close());
|
|
2600
|
+
});
|
|
2601
|
+
}
|
|
2602
|
+
transportType() {
|
|
2603
|
+
return "websocket";
|
|
2604
|
+
}
|
|
2605
|
+
url() {
|
|
2606
|
+
return s(this, ue).url;
|
|
2607
|
+
}
|
|
2608
|
+
afterHandshake() {
|
|
2609
|
+
return s(this, Ft).postHandshake();
|
|
2610
|
+
}
|
|
2611
|
+
objectStream() {
|
|
2612
|
+
return h(this, null, function* () {
|
|
2613
|
+
var t;
|
|
2614
|
+
for (; ; ) {
|
|
2615
|
+
u(this, he, s(this, us).getReader());
|
|
2616
|
+
try {
|
|
2617
|
+
const { value: e, done: n } = yield s(this, he).read();
|
|
2618
|
+
if (n)
|
|
2619
|
+
return;
|
|
2620
|
+
const [r, a, c] = e;
|
|
2621
|
+
if (s(this, Ct).has(k(a))) {
|
|
2622
|
+
const d = s(this, Ct).get(k(a));
|
|
2623
|
+
if (!d)
|
|
2624
|
+
throw new Error("Stream not found");
|
|
2625
|
+
c.length > 0 && (yield d.push(c)), r || (d.close(), s(this, Ct).delete(k(a)));
|
|
2626
|
+
} else {
|
|
2627
|
+
let b;
|
|
2628
|
+
const [d, f] = Pr(100), p = new ReadableStream({
|
|
2629
|
+
pull(m) {
|
|
2630
|
+
return h(this, null, function* () {
|
|
2631
|
+
const I = yield f.pop();
|
|
2632
|
+
I ? m.enqueue(I) : m.close();
|
|
2633
|
+
});
|
|
2634
|
+
}
|
|
2635
|
+
});
|
|
2636
|
+
if (s(this, Ct).set(k(a), d), r || (yield p.cancel(), s(this, Ct).delete(k(a))), c.length > 0)
|
|
2637
|
+
return yield ro(new En(c, p));
|
|
2638
|
+
}
|
|
2639
|
+
} finally {
|
|
2640
|
+
(t = s(this, he)) == null || t.releaseLock();
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
});
|
|
2644
|
+
}
|
|
2645
|
+
close() {
|
|
2646
|
+
var t;
|
|
2647
|
+
return s(this, Ft).cancel().catch(B), s(this, us).cancel("closing").catch(B), (t = s(this, he)) == null || t.cancel("closing").catch(B), s(this, ue).close();
|
|
2648
|
+
}
|
|
2649
|
+
closed() {
|
|
2650
|
+
return Promise.resolve();
|
|
2651
|
+
}
|
|
2652
|
+
writeMessage(t) {
|
|
2653
|
+
return h(this, null, function* () {
|
|
2654
|
+
yield s(this, Ft).write(t);
|
|
2655
|
+
});
|
|
2656
|
+
}
|
|
2657
|
+
readMessage() {
|
|
2658
|
+
return h(this, null, function* () {
|
|
2659
|
+
return s(this, Ft).read();
|
|
2660
|
+
});
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2663
|
+
ue = new WeakMap(), Ft = new WeakMap(), us = new WeakMap(), he = new WeakMap(), Ct = new WeakMap();
|
|
2664
|
+
var le, de, fe, Si, $n, zn, ao;
|
|
2665
|
+
class Tc {
|
|
2666
|
+
constructor(t, e, n) {
|
|
2667
|
+
o(this, zn);
|
|
2668
|
+
o(this, le);
|
|
2669
|
+
o(this, de);
|
|
2670
|
+
o(this, fe, new Rr(100));
|
|
2671
|
+
o(this, Si);
|
|
2672
|
+
o(this, $n, Xt.get().createContext("WebTransportConnection"));
|
|
2673
|
+
u(this, Si, n), u(this, le, t), u(this, de, e), w(this, zn, ao).call(this).catch((r) => {
|
|
2674
|
+
s(this, $n).debug("Incoming streams handling ended with error", r), s(this, fe).close();
|
|
2675
|
+
});
|
|
2676
|
+
}
|
|
2677
|
+
transportType() {
|
|
2678
|
+
return "webtransport";
|
|
2679
|
+
}
|
|
2680
|
+
url() {
|
|
2681
|
+
return s(this, Si);
|
|
2682
|
+
}
|
|
2683
|
+
afterHandshake() {
|
|
2684
|
+
return s(this, de).postHandshake();
|
|
2685
|
+
}
|
|
2686
|
+
closed() {
|
|
2687
|
+
return h(this, null, function* () {
|
|
2688
|
+
yield s(this, le).closed;
|
|
2689
|
+
});
|
|
2690
|
+
}
|
|
2691
|
+
close() {
|
|
2692
|
+
s(this, le).close();
|
|
2693
|
+
}
|
|
2694
|
+
writeMessage(t) {
|
|
2695
|
+
return h(this, null, function* () {
|
|
2696
|
+
yield s(this, de).write(t);
|
|
2697
|
+
});
|
|
2698
|
+
}
|
|
2699
|
+
readMessage() {
|
|
2700
|
+
return h(this, null, function* () {
|
|
2701
|
+
return s(this, de).read();
|
|
2702
|
+
});
|
|
2703
|
+
}
|
|
2704
|
+
objectStream() {
|
|
2705
|
+
return h(this, null, function* () {
|
|
2706
|
+
return s(this, fe).pop();
|
|
2707
|
+
});
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
le = new WeakMap(), de = new WeakMap(), fe = new WeakMap(), Si = new WeakMap(), $n = new WeakMap(), zn = new WeakSet(), ao = function() {
|
|
2711
|
+
return h(this, null, function* () {
|
|
2712
|
+
const t = s(this, le).incomingUnidirectionalStreams.getReader();
|
|
2713
|
+
for (; ; ) {
|
|
2714
|
+
const { value: e, done: n } = yield t.read();
|
|
2715
|
+
if (n) {
|
|
2716
|
+
s(this, fe).close();
|
|
2717
|
+
return;
|
|
2718
|
+
}
|
|
2719
|
+
const r = new En(new Uint8Array(), e);
|
|
2720
|
+
yield s(this, fe).push(ro(r));
|
|
2721
|
+
}
|
|
2722
|
+
});
|
|
2723
|
+
};
|
|
2724
|
+
function or(i) {
|
|
2725
|
+
return h(this, null, function* () {
|
|
2726
|
+
const t = new WebSocket(i.url);
|
|
2727
|
+
t.binaryType = "arraybuffer", yield new Promise((a, c) => {
|
|
2728
|
+
t.addEventListener("error", c, { once: !0 }), t.addEventListener("open", a, { once: !0 });
|
|
2729
|
+
});
|
|
2730
|
+
const e = On.wrapWebsocket(t);
|
|
2731
|
+
qa(e, ja.Subscriber).catch(() => {
|
|
2732
|
+
t.close();
|
|
2733
|
+
});
|
|
2734
|
+
const n = new Uc(t, e);
|
|
2735
|
+
return Vn.subscriber(n, i.authToken);
|
|
2736
|
+
});
|
|
2737
|
+
}
|
|
2738
|
+
function sa(i) {
|
|
2739
|
+
return h(this, null, function* () {
|
|
2740
|
+
const t = "60b82e8021689e163c1041b4475ef9c86e7565bc45d1a0aa43f5148769f461c7", e = new Uint8Array(t.length / 2);
|
|
2741
|
+
for (let f = 0; f < e.length; f += 1)
|
|
2742
|
+
e[f] = parseInt(t.slice(2 * f, 2 * f + 2), 16);
|
|
2743
|
+
const n = new WebTransport(i.url, {
|
|
2744
|
+
congestionControl: "low-latency"
|
|
2745
|
+
// serverCertificateHashes: [{ algorithm: "sha-256", value: hexBytes }],
|
|
2746
|
+
});
|
|
2747
|
+
yield Promise.race([n.ready, n.closed.then(() => Promise.reject(new Error("WebTransport closed")))]);
|
|
2748
|
+
const r = yield n.createBidirectionalStream(), a = On.wrapWebTransport(r);
|
|
2749
|
+
qa(a, ja.Subscriber).catch(() => {
|
|
2750
|
+
n.close();
|
|
2751
|
+
});
|
|
2752
|
+
const c = new Tc(n, a, i.url.toString());
|
|
2753
|
+
return Vn.subscriber(c, i.authToken);
|
|
2754
|
+
});
|
|
2755
|
+
}
|
|
2756
|
+
function Ec(i) {
|
|
2757
|
+
return h(this, null, function* () {
|
|
2758
|
+
if (self.WebTransport && (i == null ? void 0 : i.preferredTransport) !== "websocket" && i.url.protocol.startsWith("https")) {
|
|
2759
|
+
if (!i.websocketFallbackTimeoutMs)
|
|
2760
|
+
return sa(i);
|
|
2761
|
+
const t = sa(i).catch(() => or(i)), e = yield Promise.race([t, er(i.websocketFallbackTimeoutMs)]);
|
|
2762
|
+
return e || or(i);
|
|
2763
|
+
}
|
|
2764
|
+
return or(i);
|
|
2765
|
+
});
|
|
2766
|
+
}
|
|
2767
|
+
var Bt;
|
|
2768
|
+
class Rt {
|
|
2769
|
+
constructor() {
|
|
2770
|
+
o(this, Bt, {
|
|
2771
|
+
name: "",
|
|
2772
|
+
priority: 0,
|
|
2773
|
+
groupOrder: "descending",
|
|
2774
|
+
filterType: { type: "latest-group" }
|
|
2775
|
+
});
|
|
2776
|
+
}
|
|
2777
|
+
name(t) {
|
|
2778
|
+
return s(this, Bt).name = t, this;
|
|
2779
|
+
}
|
|
2780
|
+
priority(t) {
|
|
2781
|
+
return s(this, Bt).priority = t, this;
|
|
2782
|
+
}
|
|
2783
|
+
groupOrder(t) {
|
|
2784
|
+
return s(this, Bt).groupOrder = t, this;
|
|
2785
|
+
}
|
|
2786
|
+
/**
|
|
2787
|
+
* @param startGroup the group to start the subscription at
|
|
2788
|
+
* @returns the builder
|
|
2789
|
+
*/
|
|
2790
|
+
startGroup(t) {
|
|
2791
|
+
return s(this, Bt).filterType = {
|
|
2792
|
+
type: "absolute-start",
|
|
2793
|
+
start: { group: t, object: k(0) }
|
|
2794
|
+
}, this;
|
|
2795
|
+
}
|
|
2796
|
+
range(t, e) {
|
|
2797
|
+
return s(this, Bt).filterType = {
|
|
2798
|
+
type: "absolute-range",
|
|
2799
|
+
start: { group: t, object: k(0) },
|
|
2800
|
+
end: { group: e, object: k(0) }
|
|
2801
|
+
}, this;
|
|
2802
|
+
}
|
|
2803
|
+
build() {
|
|
2804
|
+
return s(this, Bt);
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
Bt = new WeakMap();
|
|
2808
|
+
var hs, Ui;
|
|
2809
|
+
class oo {
|
|
2810
|
+
constructor(t, e) {
|
|
2811
|
+
o(this, hs);
|
|
2812
|
+
o(this, Ui);
|
|
2813
|
+
u(this, hs, t), u(this, Ui, e);
|
|
2814
|
+
}
|
|
2815
|
+
subscribe(t) {
|
|
2816
|
+
return s(this, hs).subscribe(this.namespace(), t);
|
|
2817
|
+
}
|
|
2818
|
+
closed() {
|
|
2819
|
+
return s(this, hs).closed();
|
|
2820
|
+
}
|
|
2821
|
+
namespace() {
|
|
2822
|
+
return s(this, Ui).namespace;
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
hs = new WeakMap(), Ui = new WeakMap();
|
|
2826
|
+
function Kt(i) {
|
|
2827
|
+
const t = i.at(1);
|
|
2828
|
+
if (!t)
|
|
2829
|
+
throw new Error("namespace must contain a channel ID");
|
|
2830
|
+
return t;
|
|
2831
|
+
}
|
|
2832
|
+
function Dc(i) {
|
|
2833
|
+
return "tracks" in i;
|
|
2834
|
+
}
|
|
2835
|
+
function Ac(i) {
|
|
2836
|
+
const t = new TextDecoder().decode(i);
|
|
2837
|
+
return JSON.parse(t);
|
|
2838
|
+
}
|
|
2839
|
+
var q, It, we, it, Ti, Mn, Ei, kr;
|
|
2840
|
+
const jr = class jr {
|
|
2841
|
+
constructor(t, e) {
|
|
2842
|
+
o(this, Ei);
|
|
2843
|
+
o(this, q);
|
|
2844
|
+
// The largest group id seen so far - used to switch seamlessly between tracks
|
|
2845
|
+
o(this, It);
|
|
2846
|
+
// We keep track of the most recent groups to ensure we haven't missed any due to re-ordering before we close subscriptions
|
|
2847
|
+
o(this, we, new xr(100));
|
|
2848
|
+
// This contains the unconsumed groups if this track has an absolute range
|
|
2849
|
+
o(this, it);
|
|
2850
|
+
o(this, Ti);
|
|
2851
|
+
o(this, Mn, (t) => h(this, null, function* () {
|
|
2852
|
+
if (!t)
|
|
2853
|
+
return s(this, q).close();
|
|
2854
|
+
if (s(this, it))
|
|
2855
|
+
return;
|
|
2856
|
+
const e = s(this, we).items().reduce((n, r) => n < r ? n : r, t);
|
|
2857
|
+
u(this, it, w(this, Ei, kr).call(this, e, t)), s(this, it).size === 0 && (yield s(this, q).close());
|
|
2858
|
+
}));
|
|
2859
|
+
u(this, q, t), u(this, It, e), t.done().then((n) => h(this, null, function* () {
|
|
2860
|
+
var r;
|
|
2861
|
+
return s(this, Mn).call(this, (r = n.finalInfo) == null ? void 0 : r.group);
|
|
2862
|
+
})).catch(B), u(this, Ti, t.groups());
|
|
2863
|
+
}
|
|
2864
|
+
static subscribe(t, e) {
|
|
2865
|
+
return h(this, null, function* () {
|
|
2866
|
+
const n = yield t.subscribe(e);
|
|
2867
|
+
return new jr(n, void 0);
|
|
2868
|
+
});
|
|
2869
|
+
}
|
|
2870
|
+
subscribeId() {
|
|
2871
|
+
return s(this, q).id;
|
|
2872
|
+
}
|
|
2873
|
+
name() {
|
|
2874
|
+
return s(this, q).name;
|
|
2875
|
+
}
|
|
2876
|
+
largestGroupId() {
|
|
2877
|
+
return s(this, It);
|
|
2878
|
+
}
|
|
2879
|
+
// The subscription needs renewal if it is still active and aren't finishing up the unconsumed group IDs.
|
|
2880
|
+
// If we are just finishing up the unconsumed group IDs we assume we'll finish up before the expiry.
|
|
2881
|
+
needsRenewal() {
|
|
2882
|
+
return s(this, q).expiryState() === "active" && s(this, it) === void 0;
|
|
2883
|
+
}
|
|
2884
|
+
/** Set the endGroup as the end of group.
|
|
2885
|
+
* This lets the subscription end when the endGroup is reached.
|
|
2886
|
+
*/
|
|
2887
|
+
endOfTrack(t) {
|
|
2888
|
+
const e = s(this, we).items().reduce((n, r) => n < r ? n : r, t);
|
|
2889
|
+
return this.update(e, t);
|
|
2890
|
+
}
|
|
2891
|
+
update(t, e) {
|
|
2892
|
+
return h(this, null, function* () {
|
|
2893
|
+
return u(this, it, w(this, Ei, kr).call(this, t, e)), s(this, it).size === 0 && (yield s(this, q).close()), s(this, q).update(t, e);
|
|
2894
|
+
});
|
|
2895
|
+
}
|
|
2896
|
+
unsubscribe() {
|
|
2897
|
+
return s(this, q).unsubscribe();
|
|
2898
|
+
}
|
|
2899
|
+
next() {
|
|
2900
|
+
return h(this, null, function* () {
|
|
2901
|
+
var n;
|
|
2902
|
+
if (s(this, it) && s(this, it).size === 0)
|
|
2903
|
+
return { done: !0, value: void 0 };
|
|
2904
|
+
const t = yield s(this, Ti).next();
|
|
2905
|
+
if (t.done)
|
|
2906
|
+
return t;
|
|
2907
|
+
const e = t.value.groupId();
|
|
2908
|
+
return (n = s(this, it)) == null || n.delete(e), s(this, we).push(e), s(this, It) || u(this, It, e), u(this, It, s(this, It) < e ? e : s(this, It)), t;
|
|
2909
|
+
});
|
|
2910
|
+
}
|
|
2911
|
+
return() {
|
|
2912
|
+
return s(this, q).return();
|
|
2913
|
+
}
|
|
2914
|
+
[Symbol.asyncIterator]() {
|
|
2915
|
+
return this;
|
|
2916
|
+
}
|
|
2917
|
+
};
|
|
2918
|
+
q = new WeakMap(), It = new WeakMap(), we = new WeakMap(), it = new WeakMap(), Ti = new WeakMap(), Mn = new WeakMap(), Ei = new WeakSet(), kr = function(t, e) {
|
|
2919
|
+
const n = /* @__PURE__ */ new Set();
|
|
2920
|
+
for (let r = t; r <= e; r++)
|
|
2921
|
+
n == null || n.add(r);
|
|
2922
|
+
return s(this, we).items().forEach((r) => {
|
|
2923
|
+
n == null || n.delete(r);
|
|
2924
|
+
}), n;
|
|
2925
|
+
};
|
|
2926
|
+
let Cn = jr;
|
|
2927
|
+
var St, pe, xt, Wt, Di;
|
|
2928
|
+
const Gr = class Gr {
|
|
2929
|
+
constructor(t) {
|
|
2930
|
+
// The current active subscription
|
|
2931
|
+
o(this, St);
|
|
2932
|
+
// The current group iterator - gets replaced by the next in #groups when it runs out
|
|
2933
|
+
o(this, pe);
|
|
2934
|
+
// The next group iterators to switch to when the current one runs out
|
|
2935
|
+
o(this, xt, new Rr(10));
|
|
2936
|
+
o(this, Wt);
|
|
2937
|
+
o(this, Di, (t, e) => h(this, null, function* () {
|
|
2938
|
+
var m = [];
|
|
2939
|
+
try {
|
|
2940
|
+
const n = mt(m, yield s(this, St).lock());
|
|
2941
|
+
const r = { subscribeId: n.value.subscribeId() };
|
|
2942
|
+
if (!n.value.needsRenewal()) {
|
|
2943
|
+
s(this, Wt).debug("Subscription does not need renewal", r);
|
|
2944
|
+
return;
|
|
2945
|
+
}
|
|
2946
|
+
const a = n.value.largestGroupId();
|
|
2947
|
+
const c = a !== void 0;
|
|
2948
|
+
const d = new Rt().name(e.name).priority(e.priority).groupOrder(e.groupOrder);
|
|
2949
|
+
r.largestGroupId = a;
|
|
2950
|
+
s(this, Wt).debug("Renewing subscription", r);
|
|
2951
|
+
switch (e.filterType.type) {
|
|
2952
|
+
case "absolute-range":
|
|
2953
|
+
s(this, Wt).debug("Absolute range is not renewed", r);
|
|
2954
|
+
return;
|
|
2955
|
+
case "absolute-start":
|
|
2956
|
+
case "latest-group":
|
|
2957
|
+
case "latest-object":
|
|
2958
|
+
c && d.startGroup(a + k(1));
|
|
2959
|
+
break;
|
|
2960
|
+
}
|
|
2961
|
+
const f = d.build();
|
|
2962
|
+
r.newTrack = f;
|
|
2963
|
+
const [p] = yield Promise.all([
|
|
2964
|
+
t.subscribe(f),
|
|
2965
|
+
c ? n.value.update(a, a) : n.value.unsubscribe()
|
|
2966
|
+
]);
|
|
2967
|
+
p.expiryNotification().then(() => s(this, Di).call(this, t, f)).catch(B);
|
|
2968
|
+
const b = new Cn(p, a);
|
|
2969
|
+
n.value = b;
|
|
2970
|
+
yield s(this, xt).push(b);
|
|
2971
|
+
s(this, Wt).info("Subscription renewed", r);
|
|
2972
|
+
} catch (I) {
|
|
2973
|
+
var y = I, E = !0;
|
|
2974
|
+
} finally {
|
|
2975
|
+
bt(m, y, E);
|
|
2976
|
+
}
|
|
2977
|
+
}));
|
|
2978
|
+
u(this, St, new jo(t)), u(this, pe, t), u(this, Wt, Xt.get().createContext(`Renewable '${t.name()}'`));
|
|
2979
|
+
}
|
|
2980
|
+
static subscribe(t, e, n) {
|
|
2981
|
+
return h(this, null, function* () {
|
|
2982
|
+
const r = yield t.subscribe(e), a = new Gr(new Cn(r, n));
|
|
2983
|
+
return r.expiryNotification().then(() => {
|
|
2984
|
+
var c;
|
|
2985
|
+
return s(c = a, Di).call(c, t, e);
|
|
2986
|
+
}).catch(B), a;
|
|
2987
|
+
});
|
|
2988
|
+
}
|
|
2989
|
+
largestGroupId() {
|
|
2990
|
+
return s(this, St).unsafeValue().largestGroupId();
|
|
2991
|
+
}
|
|
2992
|
+
update(t, e) {
|
|
2993
|
+
return h(this, null, function* () {
|
|
2994
|
+
var r = [];
|
|
2995
|
+
try {
|
|
2996
|
+
const n = mt(r, yield s(this, St).lock());
|
|
2997
|
+
s(this, xt).close();
|
|
2998
|
+
return n.value.update(t, e);
|
|
2999
|
+
} catch (a) {
|
|
3000
|
+
var c = a, d = !0;
|
|
3001
|
+
} finally {
|
|
3002
|
+
bt(r, c, d);
|
|
3003
|
+
}
|
|
3004
|
+
});
|
|
3005
|
+
}
|
|
3006
|
+
endOfTrack(t) {
|
|
3007
|
+
return h(this, null, function* () {
|
|
3008
|
+
var n = [];
|
|
3009
|
+
try {
|
|
3010
|
+
const e = mt(n, yield s(this, St).lock());
|
|
3011
|
+
s(this, xt).close();
|
|
3012
|
+
return e.value.endOfTrack(t);
|
|
3013
|
+
} catch (r) {
|
|
3014
|
+
var a = r, c = !0;
|
|
3015
|
+
} finally {
|
|
3016
|
+
bt(n, a, c);
|
|
3017
|
+
}
|
|
3018
|
+
});
|
|
3019
|
+
}
|
|
3020
|
+
unsubscribe() {
|
|
3021
|
+
return h(this, null, function* () {
|
|
3022
|
+
var e = [];
|
|
3023
|
+
try {
|
|
3024
|
+
const t = mt(e, yield s(this, St).lock());
|
|
3025
|
+
s(this, xt).close();
|
|
3026
|
+
return t.value.unsubscribe();
|
|
3027
|
+
} catch (n) {
|
|
3028
|
+
var r = n, a = !0;
|
|
3029
|
+
} finally {
|
|
3030
|
+
bt(e, r, a);
|
|
3031
|
+
}
|
|
3032
|
+
});
|
|
3033
|
+
}
|
|
3034
|
+
return() {
|
|
3035
|
+
return h(this, null, function* () {
|
|
3036
|
+
var e = [];
|
|
3037
|
+
try {
|
|
3038
|
+
const t = mt(e, yield s(this, St).lock());
|
|
3039
|
+
s(this, xt).close();
|
|
3040
|
+
return t.value.return();
|
|
3041
|
+
} catch (n) {
|
|
3042
|
+
var r = n, a = !0;
|
|
3043
|
+
} finally {
|
|
3044
|
+
bt(e, r, a);
|
|
3045
|
+
}
|
|
3046
|
+
});
|
|
3047
|
+
}
|
|
3048
|
+
next() {
|
|
3049
|
+
return h(this, null, function* () {
|
|
3050
|
+
var e, n;
|
|
3051
|
+
const t = yield s(this, pe).next();
|
|
3052
|
+
if (t.done) {
|
|
3053
|
+
yield (n = (e = s(this, pe)).return) == null ? void 0 : n.call(e);
|
|
3054
|
+
const r = yield s(this, xt).pop();
|
|
3055
|
+
if (r)
|
|
3056
|
+
return u(this, pe, r), this.next();
|
|
3057
|
+
}
|
|
3058
|
+
return t;
|
|
3059
|
+
});
|
|
3060
|
+
}
|
|
3061
|
+
[Symbol.asyncIterator]() {
|
|
3062
|
+
return this;
|
|
3063
|
+
}
|
|
3064
|
+
objects() {
|
|
3065
|
+
return Dt(this, null, function* () {
|
|
3066
|
+
try {
|
|
3067
|
+
for (var d = C(this), f, p, b; f = !(p = yield new A(d.next())).done; f = !1) {
|
|
3068
|
+
var t = p.value;
|
|
3069
|
+
var e = [];
|
|
3070
|
+
try {
|
|
3071
|
+
const m = mt(e, t, !0);
|
|
3072
|
+
yield* ar(m);
|
|
3073
|
+
} catch (n) {
|
|
3074
|
+
var r = n, a = !0;
|
|
3075
|
+
} finally {
|
|
3076
|
+
var c = bt(e, r, a);
|
|
3077
|
+
c && (yield new A(c));
|
|
3078
|
+
}
|
|
3079
|
+
}
|
|
3080
|
+
} catch (p) {
|
|
3081
|
+
b = [p];
|
|
3082
|
+
} finally {
|
|
3083
|
+
try {
|
|
3084
|
+
f && (p = d.return) && (yield new A(p.call(d)));
|
|
3085
|
+
} finally {
|
|
3086
|
+
if (b)
|
|
3087
|
+
throw b[0];
|
|
3088
|
+
}
|
|
3089
|
+
}
|
|
3090
|
+
});
|
|
3091
|
+
}
|
|
3092
|
+
};
|
|
3093
|
+
St = new WeakMap(), pe = new WeakMap(), xt = new WeakMap(), Wt = new WeakMap(), Di = new WeakMap();
|
|
3094
|
+
let Ht = Gr;
|
|
3095
|
+
const Oc = "catalog";
|
|
3096
|
+
function ia(i) {
|
|
3097
|
+
const t = Ac(i.payload);
|
|
3098
|
+
if (!Dc(t))
|
|
3099
|
+
throw new Error("unexpected catalog type");
|
|
3100
|
+
return t;
|
|
3101
|
+
}
|
|
3102
|
+
var me, Ai, Oi, Vi, Hn, co;
|
|
3103
|
+
const Xn = class Xn {
|
|
3104
|
+
constructor(t, e, n) {
|
|
3105
|
+
o(this, Hn);
|
|
3106
|
+
o(this, me);
|
|
3107
|
+
o(this, Ai);
|
|
3108
|
+
o(this, Oi);
|
|
3109
|
+
o(this, Vi);
|
|
3110
|
+
u(this, Ai, t), u(this, me, e), u(this, Oi, n), u(this, Vi, w(this, Hn, co).call(this));
|
|
3111
|
+
}
|
|
3112
|
+
catalog() {
|
|
3113
|
+
return s(this, me);
|
|
3114
|
+
}
|
|
3115
|
+
closed() {
|
|
3116
|
+
return s(this, Vi);
|
|
3117
|
+
}
|
|
3118
|
+
close() {
|
|
3119
|
+
return h(this, null, function* () {
|
|
3120
|
+
return s(this, me).close(), (yield s(this, Ai).promise).unsubscribe();
|
|
3121
|
+
});
|
|
3122
|
+
}
|
|
3123
|
+
static start(t, e) {
|
|
3124
|
+
return h(this, null, function* () {
|
|
3125
|
+
const n = x.fromPromise(
|
|
3126
|
+
Ht.subscribe(
|
|
3127
|
+
t,
|
|
3128
|
+
new Rt().name(e.catalogName || Oc).groupOrder("ascending").build()
|
|
3129
|
+
)
|
|
3130
|
+
), r = x.fromPromise(n.promise.then((f) => f.objects()));
|
|
3131
|
+
if (e.catalog)
|
|
3132
|
+
return new Xn(n, new ft(e.catalog), r);
|
|
3133
|
+
const c = yield (yield r.promise).next();
|
|
3134
|
+
if (!c.value)
|
|
3135
|
+
throw new Error("No catalog found");
|
|
3136
|
+
const d = ia(c.value);
|
|
3137
|
+
return new Xn(n, new ft(d), r);
|
|
3138
|
+
});
|
|
3139
|
+
}
|
|
3140
|
+
};
|
|
3141
|
+
me = new WeakMap(), Ai = new WeakMap(), Oi = new WeakMap(), Vi = new WeakMap(), Hn = new WeakSet(), co = function() {
|
|
3142
|
+
return h(this, null, function* () {
|
|
3143
|
+
const t = yield s(this, Oi).promise;
|
|
3144
|
+
try {
|
|
3145
|
+
for (var e = C(t), n, r, a; n = !(r = yield e.next()).done; n = !1) {
|
|
3146
|
+
const c = r.value;
|
|
3147
|
+
if (c.objectStatus !== $.Normal)
|
|
3148
|
+
continue;
|
|
3149
|
+
const d = ia(c);
|
|
3150
|
+
s(this, me).update(d);
|
|
3151
|
+
}
|
|
3152
|
+
} catch (r) {
|
|
3153
|
+
a = [r];
|
|
3154
|
+
} finally {
|
|
3155
|
+
try {
|
|
3156
|
+
n && (r = e.return) && (yield r.call(e));
|
|
3157
|
+
} finally {
|
|
3158
|
+
if (a)
|
|
3159
|
+
throw a[0];
|
|
3160
|
+
}
|
|
3161
|
+
}
|
|
3162
|
+
});
|
|
3163
|
+
};
|
|
3164
|
+
let Ir = Xn;
|
|
3165
|
+
function uo(i) {
|
|
3166
|
+
const t = atob(i), e = new Uint8Array(t.length);
|
|
3167
|
+
for (let n = 0; n < t.length; n++)
|
|
3168
|
+
e[n] = t.charCodeAt(n);
|
|
3169
|
+
return e.buffer;
|
|
3170
|
+
}
|
|
3171
|
+
var Ci, ls, Bi, ds, xi, Sr;
|
|
3172
|
+
class Vc {
|
|
3173
|
+
constructor(t, e, n, r) {
|
|
3174
|
+
o(this, xi);
|
|
3175
|
+
o(this, Ci);
|
|
3176
|
+
o(this, ls);
|
|
3177
|
+
o(this, Bi);
|
|
3178
|
+
l(this, "track");
|
|
3179
|
+
o(this, ds, Xt.get().createContext("CmafGroup"));
|
|
3180
|
+
this.track = r, u(this, Ci, n), u(this, ls, t), u(this, Bi, e);
|
|
3181
|
+
}
|
|
3182
|
+
[Symbol.asyncIterator]() {
|
|
3183
|
+
return Dt(this, null, function* () {
|
|
3184
|
+
const t = { name: this.track.trackObject.name, namespace: this.track.namespace };
|
|
3185
|
+
s(this, ds).debug("start", Yt({}, t));
|
|
3186
|
+
try {
|
|
3187
|
+
for (var e = C(s(this, ls)), n, r, a; n = !(r = yield new A(e.next())).done; n = !1) {
|
|
3188
|
+
const c = r.value;
|
|
3189
|
+
if (c.objectStatus === $.EndOfTrackAndGroup && (yield new A(this.track.endOfTrack(c.groupId))), c.objectStatus !== $.Normal)
|
|
3190
|
+
continue;
|
|
3191
|
+
const d = s(this, Bi).createFragment(c.payload), f = d.timescale(), p = d.baseMediaDecodeTime() / f * 1e3, b = d.duration() / f * 1e3, m = p + b, I = s(this, Ci) / 1e3 * f;
|
|
3192
|
+
d.updateBaseMediaDecodeTime(d.baseMediaDecodeTime() - I);
|
|
3193
|
+
const y = this.track.timestampRange();
|
|
3194
|
+
if (y && p >= y[1])
|
|
3195
|
+
break;
|
|
3196
|
+
s(this, ds).debug("fragment", nr(Yt({}, t), {
|
|
3197
|
+
startTime: p,
|
|
3198
|
+
endTime: m,
|
|
3199
|
+
subscribeId: c.subscribeId,
|
|
3200
|
+
groupId: c.groupId,
|
|
3201
|
+
objectId: c.objectId
|
|
3202
|
+
})), yield [c.groupId, d];
|
|
3203
|
+
}
|
|
3204
|
+
} catch (r) {
|
|
3205
|
+
a = [r];
|
|
3206
|
+
} finally {
|
|
3207
|
+
try {
|
|
3208
|
+
n && (r = e.return) && (yield new A(r.call(e)));
|
|
3209
|
+
} finally {
|
|
3210
|
+
if (a)
|
|
3211
|
+
throw a[0];
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
s(this, ds).debug("end", Yt({}, t));
|
|
3215
|
+
});
|
|
3216
|
+
}
|
|
3217
|
+
[Oe()]() {
|
|
3218
|
+
return w(this, xi, Sr).call(this);
|
|
3219
|
+
}
|
|
3220
|
+
[Symbol.asyncDispose]() {
|
|
3221
|
+
return w(this, xi, Sr).call(this);
|
|
3222
|
+
}
|
|
3223
|
+
}
|
|
3224
|
+
Ci = new WeakMap(), ls = new WeakMap(), Bi = new WeakMap(), ds = new WeakMap(), xi = new WeakSet(), Sr = function() {
|
|
3225
|
+
return h(this, null, function* () {
|
|
3226
|
+
var t, e;
|
|
3227
|
+
return yield (e = (t = s(this, ls)).return) == null ? void 0 : e.call(t), Promise.resolve();
|
|
3228
|
+
});
|
|
3229
|
+
};
|
|
3230
|
+
var Pi, Ut, Ri, Li, Zn, ho;
|
|
3231
|
+
const je = class je {
|
|
3232
|
+
constructor(t, e, n, r, a) {
|
|
3233
|
+
o(this, Pi);
|
|
3234
|
+
o(this, Ut);
|
|
3235
|
+
// A static offset that will be applied to all fragments
|
|
3236
|
+
o(this, Ri);
|
|
3237
|
+
// Stop consuming the track after we have passed thig timestamp
|
|
3238
|
+
o(this, Li);
|
|
3239
|
+
l(this, "trackObject");
|
|
3240
|
+
l(this, "namespace");
|
|
3241
|
+
this.trackObject = t, this.namespace = e, u(this, Ut, n), u(this, Pi, r), u(this, Ri, a);
|
|
3242
|
+
}
|
|
3243
|
+
static subscribe(t, e, n, r) {
|
|
3244
|
+
return h(this, null, function* () {
|
|
3245
|
+
var b;
|
|
3246
|
+
if (e.format !== "cmaf")
|
|
3247
|
+
throw new Error("format must be cmaf");
|
|
3248
|
+
const a = new Rt().name(e.name);
|
|
3249
|
+
r && a.startGroup(r);
|
|
3250
|
+
const c = a.build();
|
|
3251
|
+
if (e.initTrack) {
|
|
3252
|
+
const m = new Rt().name(e.initTrack).build(), [I, y] = yield Promise.all([
|
|
3253
|
+
w(b = je, Zn, ho).call(b, t, m),
|
|
3254
|
+
Ht.subscribe(t, c, r ? r - k(1) : void 0)
|
|
3255
|
+
]), E = new _r(I);
|
|
3256
|
+
return new je(e, t.namespace(), y, E, n);
|
|
3257
|
+
}
|
|
3258
|
+
Ia(e.initData, "no init data found on track");
|
|
3259
|
+
const d = uo(e.initData), f = new _r(new Uint8Array(d)), p = yield Ht.subscribe(t, c, r ? r - k(1) : void 0);
|
|
3260
|
+
return new je(e, t.namespace(), p, f, n);
|
|
3261
|
+
});
|
|
3262
|
+
}
|
|
3263
|
+
largestGroupId() {
|
|
3264
|
+
return s(this, Ut).largestGroupId();
|
|
3265
|
+
}
|
|
3266
|
+
stopAfterTimestampReached(t) {
|
|
3267
|
+
u(this, Li, [0, t]);
|
|
3268
|
+
}
|
|
3269
|
+
timestampRange() {
|
|
3270
|
+
return s(this, Li);
|
|
3271
|
+
}
|
|
3272
|
+
endOfTrack(t) {
|
|
3273
|
+
return s(this, Ut).endOfTrack(t);
|
|
3274
|
+
}
|
|
3275
|
+
update(t, e) {
|
|
3276
|
+
return s(this, Ut).update(t, e);
|
|
3277
|
+
}
|
|
3278
|
+
unsubscribe() {
|
|
3279
|
+
return h(this, null, function* () {
|
|
3280
|
+
return s(this, Ut).unsubscribe();
|
|
3281
|
+
});
|
|
3282
|
+
}
|
|
3283
|
+
next() {
|
|
3284
|
+
return h(this, null, function* () {
|
|
3285
|
+
const t = yield s(this, Ut).next();
|
|
3286
|
+
return t.done ? t : {
|
|
3287
|
+
done: !1,
|
|
3288
|
+
value: new Vc(t.value, s(this, Pi), s(this, Ri), this)
|
|
3289
|
+
};
|
|
3290
|
+
});
|
|
3291
|
+
}
|
|
3292
|
+
return() {
|
|
3293
|
+
return h(this, null, function* () {
|
|
3294
|
+
return yield s(this, Ut).return(), { done: !0, value: void 0 };
|
|
3295
|
+
});
|
|
3296
|
+
}
|
|
3297
|
+
[Symbol.asyncIterator]() {
|
|
3298
|
+
return this;
|
|
3299
|
+
}
|
|
3300
|
+
[Oe()]() {
|
|
3301
|
+
return this.unsubscribe();
|
|
3302
|
+
}
|
|
3303
|
+
[Symbol.asyncDispose]() {
|
|
3304
|
+
return h(this, null, function* () {
|
|
3305
|
+
return this.unsubscribe();
|
|
3306
|
+
});
|
|
3307
|
+
}
|
|
3308
|
+
};
|
|
3309
|
+
Pi = new WeakMap(), Ut = new WeakMap(), Ri = new WeakMap(), Li = new WeakMap(), Zn = new WeakSet(), ho = function(t, e) {
|
|
3310
|
+
return h(this, null, function* () {
|
|
3311
|
+
const n = yield t.subscribe(e), r = yield n.objects().next();
|
|
3312
|
+
if (r.done)
|
|
3313
|
+
throw new Error("No init object");
|
|
3314
|
+
return yield n.close(), r.value.payload;
|
|
3315
|
+
});
|
|
3316
|
+
}, o(je, Zn);
|
|
3317
|
+
let Ur = je;
|
|
3318
|
+
const na = 1e4, Cc = 3e4;
|
|
3319
|
+
var Yn, be, ye, ji, Gi, Ni, Ae, Er, lo;
|
|
3320
|
+
const Nr = class Nr {
|
|
3321
|
+
constructor(t, e, n) {
|
|
3322
|
+
o(this, Ae);
|
|
3323
|
+
o(this, Yn, Xt.get().createContext("Timeline"));
|
|
3324
|
+
o(this, be, new ft([]));
|
|
3325
|
+
o(this, ye);
|
|
3326
|
+
o(this, ji);
|
|
3327
|
+
o(this, Gi);
|
|
3328
|
+
o(this, Ni);
|
|
3329
|
+
u(this, ji, t), u(this, Gi, n), u(this, ye, e), u(this, Ni, w(this, Ae, Er).call(this, s(this, ye)));
|
|
3330
|
+
}
|
|
3331
|
+
closed() {
|
|
3332
|
+
return s(this, Ni);
|
|
3333
|
+
}
|
|
3334
|
+
close() {
|
|
3335
|
+
return h(this, null, function* () {
|
|
3336
|
+
return (yield s(this, ye).promise).unsubscribe();
|
|
3337
|
+
});
|
|
3338
|
+
}
|
|
3339
|
+
timeline() {
|
|
3340
|
+
const [t, e] = s(this, be).value();
|
|
3341
|
+
return t;
|
|
3342
|
+
}
|
|
3343
|
+
/**
|
|
3344
|
+
* Returns the offset between the wallclock time and media timestamps.
|
|
3345
|
+
* This is useful for time aligning two streams based on the common wallclock time
|
|
3346
|
+
*/
|
|
3347
|
+
timestampWallclockOffset() {
|
|
3348
|
+
return Ao(this.timeline().map((t) => t.mediaPts - t.wallclock));
|
|
3349
|
+
}
|
|
3350
|
+
static start(t, e) {
|
|
3351
|
+
const n = x.fromPromise(
|
|
3352
|
+
Ht.subscribe(t, new Rt().name(e).groupOrder("ascending").build())
|
|
3353
|
+
);
|
|
3354
|
+
return new Nr(t, n, e);
|
|
3355
|
+
}
|
|
3356
|
+
waitForWallclockTime(t) {
|
|
3357
|
+
return h(this, null, function* () {
|
|
3358
|
+
return yield s(this, be).waitFor((e) => !!e.find((n) => n.wallclock >= t)), this.timeline();
|
|
3359
|
+
});
|
|
3360
|
+
}
|
|
3361
|
+
waitForTimelineToHaveMinDuration() {
|
|
3362
|
+
return h(this, null, function* () {
|
|
3363
|
+
return yield s(this, be).waitFor((t) => {
|
|
3364
|
+
const e = t[0], n = t[t.length - 1];
|
|
3365
|
+
return !e || !n ? !1 : n.wallclock - e.wallclock > na;
|
|
3366
|
+
}), this.timeline();
|
|
3367
|
+
});
|
|
3368
|
+
}
|
|
3369
|
+
};
|
|
3370
|
+
Yn = new WeakMap(), be = new WeakMap(), ye = new WeakMap(), ji = new WeakMap(), Gi = new WeakMap(), Ni = new WeakMap(), Ae = new WeakSet(), Er = function(t) {
|
|
3371
|
+
return h(this, null, function* () {
|
|
3372
|
+
const e = yield t.promise;
|
|
3373
|
+
try {
|
|
3374
|
+
for (var y = C(e), E, P, H; E = !(P = yield y.next()).done; E = !1) {
|
|
3375
|
+
var d = P.value;
|
|
3376
|
+
var f = [];
|
|
3377
|
+
try {
|
|
3378
|
+
const T = mt(f, d, !0);
|
|
3379
|
+
try {
|
|
3380
|
+
for (var n = C(T), r, a, c; r = !(a = yield n.next()).done; r = !1) {
|
|
3381
|
+
const g = a.value;
|
|
3382
|
+
if (g.objectStatus !== $.Normal)
|
|
3383
|
+
continue;
|
|
3384
|
+
const Y = Bc(g.payload);
|
|
3385
|
+
s(this, be).update((S) => {
|
|
3386
|
+
var Tt, Us;
|
|
3387
|
+
for (S.push(...Y), S.sort((Ki, Qi) => Ki.wallclock - Qi.wallclock); S[0] && ((Us = (Tt = S[S.length - 1]) == null ? void 0 : Tt.wallclock) != null ? Us : 0) - S[0].wallclock > Cc; )
|
|
3388
|
+
S.shift();
|
|
3389
|
+
return S;
|
|
3390
|
+
}), e === s(this, ye).resolved && g.groupId > k(0) && g.objectId == k(0) && w(this, Ae, lo).call(this, g.groupId).catch((S) => {
|
|
3391
|
+
s(this, Yn).warn("backfill failed", S);
|
|
3392
|
+
});
|
|
3393
|
+
}
|
|
3394
|
+
} catch (a) {
|
|
3395
|
+
c = [a];
|
|
3396
|
+
} finally {
|
|
3397
|
+
try {
|
|
3398
|
+
r && (a = n.return) && (yield a.call(n));
|
|
3399
|
+
} finally {
|
|
3400
|
+
if (c)
|
|
3401
|
+
throw c[0];
|
|
3402
|
+
}
|
|
3403
|
+
}
|
|
3404
|
+
} catch (p) {
|
|
3405
|
+
var b = p, m = !0;
|
|
3406
|
+
} finally {
|
|
3407
|
+
var I = bt(f, b, m);
|
|
3408
|
+
I && (yield I);
|
|
3409
|
+
}
|
|
3410
|
+
}
|
|
3411
|
+
} catch (P) {
|
|
3412
|
+
H = [P];
|
|
3413
|
+
} finally {
|
|
3414
|
+
try {
|
|
3415
|
+
E && (P = y.return) && (yield P.call(y));
|
|
3416
|
+
} finally {
|
|
3417
|
+
if (H)
|
|
3418
|
+
throw H[0];
|
|
3419
|
+
}
|
|
3420
|
+
}
|
|
3421
|
+
});
|
|
3422
|
+
}, lo = function(t) {
|
|
3423
|
+
return h(this, null, function* () {
|
|
3424
|
+
const e = t - k(1), n = this.timeline(), r = n[0], a = n[n.length - 1];
|
|
3425
|
+
if (!r || !a || a.wallclock - r.wallclock > na)
|
|
3426
|
+
return;
|
|
3427
|
+
const c = x.fromPromise(
|
|
3428
|
+
Ht.subscribe(
|
|
3429
|
+
s(this, ji),
|
|
3430
|
+
new Rt().name(s(this, Gi)).groupOrder("ascending").range(e, e).build()
|
|
3431
|
+
)
|
|
3432
|
+
);
|
|
3433
|
+
return w(this, Ae, Er).call(this, c);
|
|
3434
|
+
});
|
|
3435
|
+
};
|
|
3436
|
+
let Tr = Nr;
|
|
3437
|
+
function Bc(i) {
|
|
3438
|
+
var e;
|
|
3439
|
+
const t = new TextDecoder("utf-8").decode(i).split(`
|
|
3440
|
+
`);
|
|
3441
|
+
return (e = t[0]) != null && e.startsWith("MEDIA_PTS") && t.shift(), t.filter((n) => n.length > 0).map((n) => {
|
|
3442
|
+
const [r, a, c, d, f] = n.split(",");
|
|
3443
|
+
if (!r || !d)
|
|
3444
|
+
throw new Error(`invalid timeline row: ${n}`);
|
|
3445
|
+
return {
|
|
3446
|
+
mediaPts: parseInt(r),
|
|
3447
|
+
groupId: a ? parseInt(a) : void 0,
|
|
3448
|
+
objectId: c ? parseInt(c) : void 0,
|
|
3449
|
+
wallclock: parseInt(d),
|
|
3450
|
+
metadata: f
|
|
3451
|
+
};
|
|
3452
|
+
});
|
|
3453
|
+
}
|
|
3454
|
+
function xc(i) {
|
|
3455
|
+
return typeof i.language == "string";
|
|
3456
|
+
}
|
|
3457
|
+
var Jn, Fi, $t, fs;
|
|
3458
|
+
const Fr = class Fr {
|
|
3459
|
+
constructor(t, e, n, r, a) {
|
|
3460
|
+
o(this, Jn, new Oo());
|
|
3461
|
+
o(this, Fi);
|
|
3462
|
+
o(this, $t);
|
|
3463
|
+
o(this, fs, 0);
|
|
3464
|
+
l(this, "trackObject");
|
|
3465
|
+
l(this, "namespace");
|
|
3466
|
+
u(this, $t, t), u(this, Fi, e), this.trackObject = n, this.namespace = r, u(this, fs, a);
|
|
3467
|
+
}
|
|
3468
|
+
static subscribe(t, e, n) {
|
|
3469
|
+
return h(this, null, function* () {
|
|
3470
|
+
if (!xc(e))
|
|
3471
|
+
throw new Error("track object language is required");
|
|
3472
|
+
const r = new Rt().name(e.name).build(), a = yield Ht.subscribe(t, r), c = a.objects();
|
|
3473
|
+
return new Fr(a, c, e, t.namespace(), n);
|
|
3474
|
+
});
|
|
3475
|
+
}
|
|
3476
|
+
largestGroupId() {
|
|
3477
|
+
return s(this, $t).largestGroupId();
|
|
3478
|
+
}
|
|
3479
|
+
update(t, e) {
|
|
3480
|
+
return s(this, $t).update(t, e);
|
|
3481
|
+
}
|
|
3482
|
+
unsubscribe() {
|
|
3483
|
+
return s(this, $t).unsubscribe();
|
|
3484
|
+
}
|
|
3485
|
+
next() {
|
|
3486
|
+
return h(this, null, function* () {
|
|
3487
|
+
for (; ; ) {
|
|
3488
|
+
const t = yield s(this, Fi).next();
|
|
3489
|
+
if (t.done)
|
|
3490
|
+
return t;
|
|
3491
|
+
if (t.value.objectStatus !== $.Normal)
|
|
3492
|
+
continue;
|
|
3493
|
+
const e = new TextDecoder().decode(t.value.payload), n = s(this, Jn).parse(e).map((a) => (a.startTime -= s(this, fs) / 1e3, a.endTime -= s(this, fs) / 1e3, a));
|
|
3494
|
+
return {
|
|
3495
|
+
done: !1,
|
|
3496
|
+
value: { language: this.trackObject.language, cues: n }
|
|
3497
|
+
};
|
|
3498
|
+
}
|
|
3499
|
+
});
|
|
3500
|
+
}
|
|
3501
|
+
return() {
|
|
3502
|
+
return h(this, null, function* () {
|
|
3503
|
+
return yield s(this, $t).return(), { done: !0, value: void 0 };
|
|
3504
|
+
});
|
|
3505
|
+
}
|
|
3506
|
+
[Symbol.asyncIterator]() {
|
|
3507
|
+
return this;
|
|
3508
|
+
}
|
|
3509
|
+
[Oe()]() {
|
|
3510
|
+
return this.unsubscribe();
|
|
3511
|
+
}
|
|
3512
|
+
[Symbol.asyncDispose]() {
|
|
3513
|
+
return this.unsubscribe();
|
|
3514
|
+
}
|
|
3515
|
+
};
|
|
3516
|
+
Jn = new WeakMap(), Fi = new WeakMap(), $t = new WeakMap(), fs = new WeakMap();
|
|
3517
|
+
let Dr = Fr;
|
|
3518
|
+
var ya, ge, ve, ws, zt, hr, ps, cn;
|
|
3519
|
+
ya = [_({ context: "Channel", enter: "info" })];
|
|
3520
|
+
const Ge = class Ge {
|
|
3521
|
+
constructor(t, e, n, r, a) {
|
|
3522
|
+
o(this, ps);
|
|
3523
|
+
l(this, "namespace");
|
|
3524
|
+
o(this, ge);
|
|
3525
|
+
o(this, ve);
|
|
3526
|
+
o(this, ws);
|
|
3527
|
+
o(this, zt);
|
|
3528
|
+
this.namespace = r, u(this, ge, t), u(this, ve, e), u(this, ws, n), u(this, zt, a);
|
|
3529
|
+
}
|
|
3530
|
+
static start(t, e) {
|
|
3531
|
+
return h(this, null, function* () {
|
|
3532
|
+
const n = new oo(t, { namespace: e.namespace }), [r, a] = yield Promise.all([
|
|
3533
|
+
Tr.start(n, "timeline"),
|
|
3534
|
+
Ir.start(n, { catalog: e.catalog, namespace: e.namespace })
|
|
3535
|
+
]);
|
|
3536
|
+
return new Ge(n, r, a, e.namespace, 0);
|
|
3537
|
+
});
|
|
3538
|
+
}
|
|
3539
|
+
catalog() {
|
|
3540
|
+
return s(this, ws).catalog();
|
|
3541
|
+
}
|
|
3542
|
+
timestampWallclockOffset() {
|
|
3543
|
+
return s(this, ve).timestampWallclockOffset();
|
|
3544
|
+
}
|
|
3545
|
+
timestampOffsetMs() {
|
|
3546
|
+
return s(this, zt);
|
|
3547
|
+
}
|
|
3548
|
+
setTimestampOffsetMs(t) {
|
|
3549
|
+
u(this, zt, t);
|
|
3550
|
+
}
|
|
3551
|
+
waitForWallclockTime(t) {
|
|
3552
|
+
return s(this, ve).waitForWallclockTime(t);
|
|
3553
|
+
}
|
|
3554
|
+
subscribeCmafTrack(t, e) {
|
|
3555
|
+
const r = this.catalog().current().tracks.find(
|
|
3556
|
+
(a) => a["com.vindral.variant_uid"] === t["com.vindral.variant_uid"]
|
|
3557
|
+
);
|
|
3558
|
+
return w(this, ps, cn).call(this, () => Ur.subscribe(s(this, ge), r != null ? r : t, s(this, zt), e));
|
|
3559
|
+
}
|
|
3560
|
+
subscribeWebVttTrack(t) {
|
|
3561
|
+
return w(this, ps, cn).call(this, () => Dr.subscribe(s(this, ge), t, s(this, zt)));
|
|
3562
|
+
}
|
|
3563
|
+
subscribeTrack(t) {
|
|
3564
|
+
return w(this, ps, cn).call(this, () => s(this, ge).subscribe(t));
|
|
3565
|
+
}
|
|
3566
|
+
/**
|
|
3567
|
+
* Closes the channel subscriptions
|
|
3568
|
+
*/
|
|
3569
|
+
close() {
|
|
3570
|
+
return Promise.all([s(this, ws).close(), s(this, ve).close()]);
|
|
3571
|
+
}
|
|
3572
|
+
};
|
|
3573
|
+
hr = Ve(null), ge = new WeakMap(), ve = new WeakMap(), ws = new WeakMap(), zt = new WeakMap(), ps = new WeakSet(), cn = function(t) {
|
|
3574
|
+
return h(this, null, function* () {
|
|
3575
|
+
const [e, n] = this.catalog().value();
|
|
3576
|
+
try {
|
|
3577
|
+
return yield t();
|
|
3578
|
+
} catch (r) {
|
|
3579
|
+
if (e === this.catalog().current() && n && (yield Promise.race([n, er(500)])), e !== this.catalog().current())
|
|
3580
|
+
return t();
|
|
3581
|
+
throw r;
|
|
3582
|
+
}
|
|
3583
|
+
});
|
|
3584
|
+
}, X(hr, 9, "start", ya, Ge), Jt(hr, Ge), Ce(hr, 3, Ge);
|
|
3585
|
+
let Bn = Ge;
|
|
3586
|
+
var ke, Wi, Kn, fo;
|
|
3587
|
+
const Wr = class Wr {
|
|
3588
|
+
constructor(t) {
|
|
3589
|
+
o(this, Kn);
|
|
3590
|
+
o(this, ke);
|
|
3591
|
+
o(this, Wi);
|
|
3592
|
+
const [e, n] = t.value.value();
|
|
3593
|
+
u(this, ke, {
|
|
3594
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
3595
|
+
wallclock: new Date(e.ntpTimestamp),
|
|
3596
|
+
rtt: e.rtt
|
|
3597
|
+
}), u(this, Wi, w(this, Kn, fo).call(this, t));
|
|
3598
|
+
}
|
|
3599
|
+
/**
|
|
3600
|
+
* @returns returns the current wallclock time in milliseconds based on the ntp timestamp of the stats track + the elapsed time since the last stats track.
|
|
3601
|
+
*/
|
|
3602
|
+
wallclock() {
|
|
3603
|
+
const e = Date.now() - s(this, ke).createdAt.getTime();
|
|
3604
|
+
return s(this, ke).wallclock.getTime() + e;
|
|
3605
|
+
}
|
|
3606
|
+
closed() {
|
|
3607
|
+
return s(this, Wi);
|
|
3608
|
+
}
|
|
3609
|
+
static start(t) {
|
|
3610
|
+
return new Wr(t);
|
|
3611
|
+
}
|
|
3612
|
+
};
|
|
3613
|
+
ke = new WeakMap(), Wi = new WeakMap(), Kn = new WeakSet(), fo = function(t) {
|
|
3614
|
+
return h(this, null, function* () {
|
|
3615
|
+
try {
|
|
3616
|
+
for (var e = C(t.value), n, r, a; n = !(r = yield e.next()).done; n = !1) {
|
|
3617
|
+
const c = r.value;
|
|
3618
|
+
u(this, ke, {
|
|
3619
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
3620
|
+
wallclock: new Date(c.ntpTimestamp),
|
|
3621
|
+
rtt: c.rtt
|
|
3622
|
+
});
|
|
3623
|
+
}
|
|
3624
|
+
} catch (r) {
|
|
3625
|
+
a = [r];
|
|
3626
|
+
} finally {
|
|
3627
|
+
try {
|
|
3628
|
+
n && (r = e.return) && (yield r.call(e));
|
|
3629
|
+
} finally {
|
|
3630
|
+
if (a)
|
|
3631
|
+
throw a[0];
|
|
3632
|
+
}
|
|
3633
|
+
}
|
|
3634
|
+
});
|
|
3635
|
+
};
|
|
3636
|
+
let Ar = Wr;
|
|
3637
|
+
function tn(i) {
|
|
3638
|
+
return typeof i == "string" || i === null || i === void 0;
|
|
3639
|
+
}
|
|
3640
|
+
function Pc(i) {
|
|
3641
|
+
return "provider" in i && typeof i.provider == "string" && (!("widevineLicenseUrl" in i) || tn(i.widevineLicenseUrl)) && (!("playreadyLicenseUrl" in i) || tn(i.playreadyLicenseUrl)) && (!("fairplayLicenseUrl" in i) || tn(i.fairplayLicenseUrl)) && (!("fairplayCertificate" in i) || tn(i.fairplayCertificate));
|
|
3642
|
+
}
|
|
3643
|
+
function Rc(i) {
|
|
3644
|
+
try {
|
|
3645
|
+
return uo(i);
|
|
3646
|
+
} catch (t) {
|
|
3647
|
+
throw new Error("Failed to convert fairplayCertificate");
|
|
3648
|
+
}
|
|
3649
|
+
}
|
|
3650
|
+
function Lc(i) {
|
|
3651
|
+
const t = new TextDecoder().decode(i), e = JSON.parse(t);
|
|
3652
|
+
if (!Pc(e))
|
|
3653
|
+
throw new Error("Invalid drm object");
|
|
3654
|
+
const a = e, { fairplayCertificate: n } = a, r = Kr(a, ["fairplayCertificate"]);
|
|
3655
|
+
return nr(Yt({}, r), {
|
|
3656
|
+
fairplayCertificate: n ? Rc(n) : void 0
|
|
3657
|
+
});
|
|
3658
|
+
}
|
|
3659
|
+
class Lr {
|
|
3660
|
+
constructor(t) {
|
|
3661
|
+
l(this, "value");
|
|
3662
|
+
this.value = t;
|
|
3663
|
+
}
|
|
3664
|
+
static create(t) {
|
|
3665
|
+
return h(this, null, function* () {
|
|
3666
|
+
var c = [];
|
|
3667
|
+
try {
|
|
3668
|
+
const e = mt(c, yield t.subscribeTrack(new Rt().name("drm").build()), !0);
|
|
3669
|
+
const n = e.objects();
|
|
3670
|
+
const r = yield n.next();
|
|
3671
|
+
if (r.done)
|
|
3672
|
+
throw new Error("No drm object received");
|
|
3673
|
+
const a = Lc(r.value.payload);
|
|
3674
|
+
return new Lr(a);
|
|
3675
|
+
} catch (d) {
|
|
3676
|
+
var f = d, p = !0;
|
|
3677
|
+
} finally {
|
|
3678
|
+
var b = bt(c, f, p);
|
|
3679
|
+
b && (yield b);
|
|
3680
|
+
}
|
|
3681
|
+
});
|
|
3682
|
+
}
|
|
3683
|
+
}
|
|
3684
|
+
function jc(i) {
|
|
3685
|
+
return "rtt" in i && typeof i.rtt == "number" && "ntpTimestamp" in i && typeof i.ntpTimestamp == "number" && "estimatedBandwidth" in i && typeof i.estimatedBandwidth == "number";
|
|
3686
|
+
}
|
|
3687
|
+
function ra(i) {
|
|
3688
|
+
const t = new TextDecoder().decode(i), e = JSON.parse(t);
|
|
3689
|
+
if (!jc(e))
|
|
3690
|
+
throw new Error("Invalid stats object");
|
|
3691
|
+
return e;
|
|
3692
|
+
}
|
|
3693
|
+
const Gc = 1e4;
|
|
3694
|
+
var $i, Qn, wo;
|
|
3695
|
+
const $r = class $r {
|
|
3696
|
+
constructor(t, e, n) {
|
|
3697
|
+
o(this, Qn);
|
|
3698
|
+
l(this, "ip");
|
|
3699
|
+
l(this, "value");
|
|
3700
|
+
o(this, $i);
|
|
3701
|
+
this.ip = n, this.value = new ft(e), u(this, $i, w(this, Qn, wo).call(this, t));
|
|
3702
|
+
}
|
|
3703
|
+
closed() {
|
|
3704
|
+
return s(this, $i);
|
|
3705
|
+
}
|
|
3706
|
+
idleTimeout() {
|
|
3707
|
+
return h(this, null, function* () {
|
|
3708
|
+
for (; ; ) {
|
|
3709
|
+
const [t, e] = this.value.value();
|
|
3710
|
+
try {
|
|
3711
|
+
yield Promise.race([Vo(Gc, new Error("Idle timeout")), e]);
|
|
3712
|
+
} catch (n) {
|
|
3713
|
+
return n;
|
|
3714
|
+
}
|
|
3715
|
+
}
|
|
3716
|
+
});
|
|
3717
|
+
}
|
|
3718
|
+
static start(t) {
|
|
3719
|
+
return h(this, null, function* () {
|
|
3720
|
+
const n = (yield t.subscribe(new Rt().name("stats").groupOrder("ascending").build())).objects(), r = yield n.next();
|
|
3721
|
+
if (r.done)
|
|
3722
|
+
throw new Error("No stats object received");
|
|
3723
|
+
const a = ra(r.value.payload);
|
|
3724
|
+
if (!a.ip)
|
|
3725
|
+
throw new Error("Expected IP in initial stats object");
|
|
3726
|
+
return new $r(n, a, a.ip);
|
|
3727
|
+
});
|
|
3728
|
+
}
|
|
3729
|
+
};
|
|
3730
|
+
$i = new WeakMap(), Qn = new WeakSet(), wo = function(t) {
|
|
3731
|
+
return h(this, null, function* () {
|
|
3732
|
+
try {
|
|
3733
|
+
for (var e = C(t), n, r, a; n = !(r = yield e.next()).done; n = !1) {
|
|
3734
|
+
const c = r.value;
|
|
3735
|
+
if (c.objectStatus !== $.Normal)
|
|
3736
|
+
continue;
|
|
3737
|
+
const d = ra(c.payload);
|
|
3738
|
+
this.value.update(d);
|
|
3739
|
+
}
|
|
3740
|
+
} catch (r) {
|
|
3741
|
+
a = [r];
|
|
3742
|
+
} finally {
|
|
3743
|
+
try {
|
|
3744
|
+
n && (r = e.return) && (yield r.call(e));
|
|
3745
|
+
} finally {
|
|
3746
|
+
if (a)
|
|
3747
|
+
throw a[0];
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3750
|
+
});
|
|
3751
|
+
};
|
|
3752
|
+
let Or = $r;
|
|
3753
|
+
var ms, zi, Mi;
|
|
3754
|
+
class cr {
|
|
3755
|
+
constructor(t, e) {
|
|
3756
|
+
o(this, ms, Xt.get().createContext("TracksIterator"));
|
|
3757
|
+
o(this, zi);
|
|
3758
|
+
o(this, Mi);
|
|
3759
|
+
u(this, zi, t), u(this, Mi, e);
|
|
3760
|
+
}
|
|
3761
|
+
[Symbol.asyncIterator]() {
|
|
3762
|
+
return Dt(this, null, function* () {
|
|
3763
|
+
const t = s(this, Mi);
|
|
3764
|
+
try {
|
|
3765
|
+
for (var e = C(s(this, zi)), n, r, a; n = !(r = yield new A(e.next())).done; n = !1) {
|
|
3766
|
+
const c = r.value;
|
|
3767
|
+
if (!c)
|
|
3768
|
+
continue;
|
|
3769
|
+
const d = {
|
|
3770
|
+
name: c.trackObject.name,
|
|
3771
|
+
namespace: c.namespace
|
|
3772
|
+
};
|
|
3773
|
+
s(this, ms).debug("track start", Yt({ mediaType: t }, d)), yield* ar(c), s(this, ms).debug("track end", Yt({ mediaType: t }, d));
|
|
3774
|
+
}
|
|
3775
|
+
} catch (r) {
|
|
3776
|
+
a = [r];
|
|
3777
|
+
} finally {
|
|
3778
|
+
try {
|
|
3779
|
+
n && (r = e.return) && (yield new A(r.call(e)));
|
|
3780
|
+
} finally {
|
|
3781
|
+
if (a)
|
|
3782
|
+
throw a[0];
|
|
3783
|
+
}
|
|
3784
|
+
}
|
|
3785
|
+
s(this, ms).debug("tracks ended", { mediaType: t });
|
|
3786
|
+
});
|
|
3787
|
+
}
|
|
3788
|
+
}
|
|
3789
|
+
ms = new WeakMap(), zi = new WeakMap(), Mi = new WeakMap();
|
|
3790
|
+
var ga, va, ka, bs, ys, Ie, G, lt, dt, Mt, Hi, Os, z, un, Ps, po, Cr;
|
|
3791
|
+
ka = [_({ context: "Player", enter: "info" })], va = [_({ context: "Player", enter: "info", return: "info" })], ga = [_({ context: "Player", enter: "info" })];
|
|
3792
|
+
const Ne = class Ne {
|
|
3793
|
+
constructor(t, e, n) {
|
|
3794
|
+
Ce(Os, 5, this);
|
|
3795
|
+
o(this, z);
|
|
3796
|
+
o(this, bs);
|
|
3797
|
+
o(this, ys);
|
|
3798
|
+
o(this, Ie);
|
|
3799
|
+
o(this, G);
|
|
3800
|
+
o(this, lt, new ft(void 0));
|
|
3801
|
+
o(this, dt, new ft(void 0));
|
|
3802
|
+
o(this, Mt, new ft(void 0));
|
|
3803
|
+
o(this, Hi);
|
|
3804
|
+
l(this, "subtitles", new cr(s(this, Mt), "subtitles"));
|
|
3805
|
+
l(this, "video", new cr(s(this, dt), "video"));
|
|
3806
|
+
l(this, "audio", new cr(s(this, lt), "audio"));
|
|
3807
|
+
u(this, bs, t), u(this, ys, Ar.start(n)), u(this, Ie, n), u(this, G, new ft(e)), u(this, Hi, Promise.race([n.idleTimeout(), w(this, z, po).call(this)])), s(this, bs).closed().then(() => this.close()).catch(B);
|
|
3808
|
+
}
|
|
3809
|
+
closed() {
|
|
3810
|
+
return s(this, Hi);
|
|
3811
|
+
}
|
|
3812
|
+
static start(t, e) {
|
|
3813
|
+
return h(this, null, function* () {
|
|
3814
|
+
const n = e.namespace, r = new oo(t, { namespace: n }), [[a, c, d], f] = yield Promise.all([
|
|
3815
|
+
Bn.start(t, e).then((b) => Promise.all([
|
|
3816
|
+
Promise.resolve(b),
|
|
3817
|
+
e.videoTrack ? b.subscribeCmafTrack(e.videoTrack) : void 0,
|
|
3818
|
+
e.audioTrack ? b.subscribeCmafTrack(e.audioTrack) : void 0
|
|
3819
|
+
])),
|
|
3820
|
+
Or.start(r)
|
|
3821
|
+
]), p = new Ne(t, a, f);
|
|
3822
|
+
return d && s(p, lt).update(d), c && s(p, dt).update(c), p;
|
|
3823
|
+
});
|
|
3824
|
+
}
|
|
3825
|
+
connectionInfo() {
|
|
3826
|
+
const t = s(this, Ie).value.current();
|
|
3827
|
+
return {
|
|
3828
|
+
ip: s(this, Ie).ip,
|
|
3829
|
+
rtt: t.rtt,
|
|
3830
|
+
estimatedBandwidth: t.estimatedBandwidth
|
|
3831
|
+
};
|
|
3832
|
+
}
|
|
3833
|
+
stats() {
|
|
3834
|
+
return s(this, Ie).value;
|
|
3835
|
+
}
|
|
3836
|
+
catalog() {
|
|
3837
|
+
return s(this, G).current().catalog();
|
|
3838
|
+
}
|
|
3839
|
+
namespace() {
|
|
3840
|
+
return s(this, G).current().namespace;
|
|
3841
|
+
}
|
|
3842
|
+
videoTrack() {
|
|
3843
|
+
var t;
|
|
3844
|
+
return (t = s(this, dt).current()) == null ? void 0 : t.trackObject;
|
|
3845
|
+
}
|
|
3846
|
+
audioTrack() {
|
|
3847
|
+
var t;
|
|
3848
|
+
return (t = s(this, lt).current()) == null ? void 0 : t.trackObject;
|
|
3849
|
+
}
|
|
3850
|
+
referenceClock() {
|
|
3851
|
+
return s(this, ys);
|
|
3852
|
+
}
|
|
3853
|
+
drm() {
|
|
3854
|
+
return h(this, null, function* () {
|
|
3855
|
+
return Lr.create(s(this, G).current()).catch(B);
|
|
3856
|
+
});
|
|
3857
|
+
}
|
|
3858
|
+
close() {
|
|
3859
|
+
return Promise.all([
|
|
3860
|
+
// Close the channel subscription
|
|
3861
|
+
s(this, G).current().close(),
|
|
3862
|
+
// Close the channel ObservableValue
|
|
3863
|
+
s(this, G).close(),
|
|
3864
|
+
// Close the consumers so that the iterators will stop
|
|
3865
|
+
w(this, z, un).call(this, s(this, lt)),
|
|
3866
|
+
w(this, z, un).call(this, s(this, dt)),
|
|
3867
|
+
w(this, z, un).call(this, s(this, Mt))
|
|
3868
|
+
]);
|
|
3869
|
+
}
|
|
3870
|
+
zap(t, e) {
|
|
3871
|
+
return h(this, null, function* () {
|
|
3872
|
+
var P, H;
|
|
3873
|
+
const n = yield Bn.start(s(this, bs), t), r = s(this, ys).wallclock() - e, a = s(this, G).current(), c = a.timestampWallclockOffset(), [d, f] = yield Promise.all([
|
|
3874
|
+
n.waitForWallclockTime(r),
|
|
3875
|
+
s(this, G).current().close()
|
|
3876
|
+
]), p = d.toReversed().find((T) => T.wallclock <= r), b = p != null && p.mediaPts ? p.mediaPts - a.timestampOffsetMs() : void 0, y = n.timestampWallclockOffset() - c + a.timestampOffsetMs();
|
|
3877
|
+
n.setTimestampOffsetMs(y);
|
|
3878
|
+
const E = p != null && p.groupId ? k(p.groupId) : void 0;
|
|
3879
|
+
b && ((P = s(this, dt).current()) == null || P.stopAfterTimestampReached(b), (H = s(this, lt).current()) == null || H.stopAfterTimestampReached(b)), s(this, G).update(n), yield Promise.all([
|
|
3880
|
+
t.videoTrack ? this.setVideoTrack(t.videoTrack, E) : void 0,
|
|
3881
|
+
t.audioTrack ? this.setAudioTrack(t.audioTrack, E) : void 0
|
|
3882
|
+
]);
|
|
3883
|
+
});
|
|
3884
|
+
}
|
|
3885
|
+
setSubtitleTrack(t) {
|
|
3886
|
+
return h(this, null, function* () {
|
|
3887
|
+
var n, r;
|
|
3888
|
+
if (!t) {
|
|
3889
|
+
yield (n = s(this, Mt).current()) == null ? void 0 : n.unsubscribe();
|
|
3890
|
+
return;
|
|
3891
|
+
}
|
|
3892
|
+
const [e] = yield Promise.all([
|
|
3893
|
+
s(this, G).current().subscribeWebVttTrack(t),
|
|
3894
|
+
(r = s(this, Mt).current()) == null ? void 0 : r.unsubscribe()
|
|
3895
|
+
]);
|
|
3896
|
+
s(this, Mt).update(e);
|
|
3897
|
+
});
|
|
3898
|
+
}
|
|
3899
|
+
setVideoTrack(t, e) {
|
|
3900
|
+
return h(this, null, function* () {
|
|
3901
|
+
const n = yield w(this, z, Ps).call(this, s(this, G).current(), t, s(this, dt).current(), e);
|
|
3902
|
+
s(this, dt).update(n);
|
|
3903
|
+
});
|
|
3904
|
+
}
|
|
3905
|
+
setAudioTrack(t, e) {
|
|
3906
|
+
return h(this, null, function* () {
|
|
3907
|
+
const n = yield w(this, z, Ps).call(this, s(this, G).current(), t, s(this, lt).current(), e);
|
|
3908
|
+
s(this, lt).update(n);
|
|
3909
|
+
});
|
|
3910
|
+
}
|
|
3911
|
+
};
|
|
3912
|
+
Os = Ve(null), bs = new WeakMap(), ys = new WeakMap(), Ie = new WeakMap(), G = new WeakMap(), lt = new WeakMap(), dt = new WeakMap(), Mt = new WeakMap(), Hi = new WeakMap(), z = new WeakSet(), un = function(t) {
|
|
3913
|
+
const e = t.current(), n = e == null ? void 0 : e.largestGroupId();
|
|
3914
|
+
return t.isClosed() || t.update(void 0), t.close(), n ? e == null ? void 0 : e.update(n, n) : e == null ? void 0 : e.unsubscribe();
|
|
3915
|
+
}, Ps = function(t, e, n, r) {
|
|
3916
|
+
return h(this, null, function* () {
|
|
3917
|
+
const a = n == null ? void 0 : n.largestGroupId(), [c, d] = yield Promise.all([
|
|
3918
|
+
t.subscribeCmafTrack(
|
|
3919
|
+
e,
|
|
3920
|
+
r || (a ? a + k(1) : void 0)
|
|
3921
|
+
),
|
|
3922
|
+
a ? n == null ? void 0 : n.update(a, a) : n == null ? void 0 : n.unsubscribe()
|
|
3923
|
+
]);
|
|
3924
|
+
return c;
|
|
3925
|
+
});
|
|
3926
|
+
}, po = function() {
|
|
3927
|
+
return h(this, null, function* () {
|
|
3928
|
+
try {
|
|
3929
|
+
for (var a = C(s(this, G)), c, d, f; c = !(d = yield a.next()).done; c = !1) {
|
|
3930
|
+
const p = d.value;
|
|
3931
|
+
try {
|
|
3932
|
+
for (var t = C(p.catalog()), e, n, r; e = !(n = yield t.next()).done; e = !1) {
|
|
3933
|
+
const b = n.value;
|
|
3934
|
+
yield Promise.all([
|
|
3935
|
+
w(this, z, Cr).call(this, b, s(this, dt)),
|
|
3936
|
+
w(this, z, Cr).call(this, b, s(this, lt))
|
|
3937
|
+
]);
|
|
3938
|
+
}
|
|
3939
|
+
} catch (n) {
|
|
3940
|
+
r = [n];
|
|
3941
|
+
} finally {
|
|
3942
|
+
try {
|
|
3943
|
+
e && (n = t.return) && (yield n.call(t));
|
|
3944
|
+
} finally {
|
|
3945
|
+
if (r)
|
|
3946
|
+
throw r[0];
|
|
3947
|
+
}
|
|
3948
|
+
}
|
|
3949
|
+
}
|
|
3950
|
+
} catch (d) {
|
|
3951
|
+
f = [d];
|
|
3952
|
+
} finally {
|
|
3953
|
+
try {
|
|
3954
|
+
c && (d = a.return) && (yield d.call(a));
|
|
3955
|
+
} finally {
|
|
3956
|
+
if (f)
|
|
3957
|
+
throw f[0];
|
|
3958
|
+
}
|
|
3959
|
+
}
|
|
3960
|
+
});
|
|
3961
|
+
}, Cr = function(t, e) {
|
|
3962
|
+
return h(this, null, function* () {
|
|
3963
|
+
const n = e.current();
|
|
3964
|
+
if (!n)
|
|
3965
|
+
return;
|
|
3966
|
+
const r = n.trackObject.name, a = n.trackObject["com.vindral.variant_uid"], c = t.tracks.find((f) => f.name === r), d = t.tracks.find((f) => f["com.vindral.variant_uid"] === a);
|
|
3967
|
+
if (!c) {
|
|
3968
|
+
if (!d) {
|
|
3969
|
+
e.update(void 0);
|
|
3970
|
+
return;
|
|
3971
|
+
}
|
|
3972
|
+
e.update(yield s(this, G).current().subscribeCmafTrack(d));
|
|
3973
|
+
}
|
|
3974
|
+
});
|
|
3975
|
+
}, X(Os, 1, "close", ka, Ne), X(Os, 1, "zap", va, Ne), Ps = X(Os, 17, "#replaceTrack", ga, z, Ps), Jt(Os, Ne);
|
|
3976
|
+
let Vr = Ne;
|
|
3977
|
+
function Nc(i, t, e) {
|
|
3978
|
+
const n = new URL("/voq/subscribe", typeof i == "string" ? i : i.moqUrl || i.moqWsUrl);
|
|
3979
|
+
return n.searchParams.set("sessionId", t.sessionId), n.searchParams.set("clientId", t.clientId), n.searchParams.set("channelId", t.channelId), e && n.searchParams.set("authToken", e), n;
|
|
3980
|
+
}
|
|
3981
|
+
var N, F, nt, Se, gs, vs, V, Ue, Xi, qn, ks, tt, mo, Is, Zi, Ss, bo, yo, go, Br;
|
|
3982
|
+
const zr = class zr {
|
|
3983
|
+
constructor(t, e, n, r, a) {
|
|
3984
|
+
o(this, tt);
|
|
3985
|
+
o(this, N);
|
|
3986
|
+
o(this, F);
|
|
3987
|
+
o(this, nt);
|
|
3988
|
+
o(this, Se, "disconnected");
|
|
3989
|
+
o(this, gs);
|
|
3990
|
+
o(this, vs);
|
|
3991
|
+
o(this, V);
|
|
3992
|
+
o(this, Ue, /* @__PURE__ */ new Map());
|
|
3993
|
+
o(this, Xi, new xr(10));
|
|
3994
|
+
o(this, qn, Number.MAX_SAFE_INTEGER);
|
|
3995
|
+
o(this, ks, /* @__PURE__ */ new Map());
|
|
3996
|
+
o(this, Is, (t) => {
|
|
3997
|
+
if (!t) {
|
|
3998
|
+
s(this, V).setSubtitleTrack(void 0).catch(B);
|
|
3999
|
+
return;
|
|
4000
|
+
}
|
|
4001
|
+
const e = s(this, Ue).get(Kt(s(this, V).namespace())), n = e == null ? void 0 : e.getTextTrack(t);
|
|
4002
|
+
n && s(this, V).setSubtitleTrack(n).catch(B);
|
|
4003
|
+
});
|
|
4004
|
+
o(this, Zi, (t) => {
|
|
4005
|
+
switch (t.type) {
|
|
4006
|
+
case "subscribe":
|
|
4007
|
+
{
|
|
4008
|
+
if (s(this, Ss)) {
|
|
4009
|
+
s(this, F).info("Ignoring - we are already switching");
|
|
4010
|
+
return;
|
|
4011
|
+
}
|
|
4012
|
+
u(this, Ss, !0), w(this, tt, bo).call(this, t.subscription).catch((e) => s(this, F).error("error handling subscription", e)).finally(() => u(this, Ss, !1));
|
|
4013
|
+
}
|
|
4014
|
+
break;
|
|
4015
|
+
case "telemetry":
|
|
4016
|
+
Po(new URL("/api/telemetry", s(this, nt).url().replace("wss://", "https://")), {
|
|
4017
|
+
body: t.body,
|
|
4018
|
+
headers: { "Content-Type": "text/plain" }
|
|
4019
|
+
}).catch(B);
|
|
4020
|
+
break;
|
|
4021
|
+
case "refresh auth":
|
|
4022
|
+
s(this, nt).updateAuthToken(t.token);
|
|
4023
|
+
break;
|
|
4024
|
+
}
|
|
4025
|
+
});
|
|
4026
|
+
o(this, Ss, !1);
|
|
4027
|
+
l(this, "disconnect", (t = "Disconnect Requested") => {
|
|
4028
|
+
s(this, F).info("Disconnecting", t), s(this, nt).close(), s(this, V).close().catch(B), u(this, ks, /* @__PURE__ */ new Map()), u(this, Se, "disconnected");
|
|
4029
|
+
});
|
|
4030
|
+
u(this, N, t), u(this, F, e), u(this, nt, n), u(this, V, r), u(this, Ue, a), s(this, N).on("send signal", s(this, Zi)), s(this, N).on("disconnect", this.disconnect), s(this, N).on("text track", s(this, Is)), w(this, tt, mo).call(this).catch(B), w(this, tt, yo).call(this).catch(B);
|
|
4031
|
+
}
|
|
4032
|
+
get estimatedBandwidth() {
|
|
4033
|
+
return s(this, qn);
|
|
4034
|
+
}
|
|
4035
|
+
get firstConnectionTime() {
|
|
4036
|
+
return s(this, gs);
|
|
4037
|
+
}
|
|
4038
|
+
get lastConnectionTime() {
|
|
4039
|
+
return s(this, vs);
|
|
4040
|
+
}
|
|
4041
|
+
unload() {
|
|
4042
|
+
s(this, N).off("send signal", s(this, Zi)), s(this, N).off("disconnect", this.disconnect), s(this, N).off("text track", s(this, Is)), this.disconnect();
|
|
4043
|
+
}
|
|
4044
|
+
suspend() {
|
|
4045
|
+
}
|
|
4046
|
+
unsuspend() {
|
|
4047
|
+
}
|
|
4048
|
+
getStatistics() {
|
|
4049
|
+
const e = s(this, V).connectionInfo().estimatedBandwidth;
|
|
4050
|
+
return {
|
|
4051
|
+
rtt: Co(s(this, Xi).items()),
|
|
4052
|
+
estimatedBandwidth: e,
|
|
4053
|
+
connectCount: 0,
|
|
4054
|
+
connectionAttemptCount: 0,
|
|
4055
|
+
edgeUrl: s(this, nt).url(),
|
|
4056
|
+
connectionProtocol: "moq"
|
|
4057
|
+
};
|
|
4058
|
+
}
|
|
4059
|
+
static start(t, e, n) {
|
|
4060
|
+
return h(this, null, function* () {
|
|
4061
|
+
var E, P, H, T;
|
|
4062
|
+
const r = new Map(
|
|
4063
|
+
n.connectInfo.channels.map((g) => [
|
|
4064
|
+
Kt(g.catalog.namespace),
|
|
4065
|
+
new oa(new ft(g.catalog))
|
|
4066
|
+
])
|
|
4067
|
+
), a = yield n.onConnectInfo(n.connectInfo), c = Nc(n.edgeUrl, a, n.options.options.authenticationToken), d = (E = n.connectInfo.channels.find((g) => g.channelId === a.channelId)) == null ? void 0 : E.catalog;
|
|
4068
|
+
e.debug("Resolved edge url", { edgeUrl: c }), Ia(d, "no catalog found");
|
|
4069
|
+
const f = (P = r.get(Kt(d.namespace))) == null ? void 0 : P.getVideoTrack(a.video), p = (H = r.get(Kt(d.namespace))) == null ? void 0 : H.getAudioTrack(a.audio), b = yield Ec({
|
|
4070
|
+
url: new URL(c),
|
|
4071
|
+
handshakePipelining: !0,
|
|
4072
|
+
authToken: n.options.get("authenticationToken")
|
|
4073
|
+
}), m = yield Vr.start(b, {
|
|
4074
|
+
namespace: d.namespace,
|
|
4075
|
+
catalog: d,
|
|
4076
|
+
videoTrack: f == null ? void 0 : f.track,
|
|
4077
|
+
audioTrack: p == null ? void 0 : p.track
|
|
4078
|
+
}), I = new oa(m.catalog());
|
|
4079
|
+
r.set(Kt(d.namespace), I), t.emit("received signal", {
|
|
4080
|
+
type: "client ip",
|
|
4081
|
+
ip: m.connectionInfo().ip
|
|
4082
|
+
}), m.drm().then((g) => {
|
|
4083
|
+
g && t.emit("received drm data", g.value);
|
|
4084
|
+
});
|
|
4085
|
+
const y = new zr(t, e, b, m, r);
|
|
4086
|
+
return a.textTrack && s(T = y, Is).call(T, a.textTrack), y;
|
|
4087
|
+
});
|
|
4088
|
+
}
|
|
4089
|
+
getState() {
|
|
4090
|
+
return s(this, Se);
|
|
4091
|
+
}
|
|
4092
|
+
get rtt() {
|
|
4093
|
+
var t;
|
|
4094
|
+
return (t = s(this, V)) == null ? void 0 : t.connectionInfo().rtt;
|
|
4095
|
+
}
|
|
4096
|
+
close() {
|
|
4097
|
+
var t;
|
|
4098
|
+
(t = s(this, nt)) == null || t.close();
|
|
4099
|
+
}
|
|
4100
|
+
closed() {
|
|
4101
|
+
var t;
|
|
4102
|
+
return (t = s(this, nt)) == null ? void 0 : t.closed();
|
|
4103
|
+
}
|
|
4104
|
+
};
|
|
4105
|
+
N = new WeakMap(), F = new WeakMap(), nt = new WeakMap(), Se = new WeakMap(), gs = new WeakMap(), vs = new WeakMap(), V = new WeakMap(), Ue = new WeakMap(), Xi = new WeakMap(), qn = new WeakMap(), ks = new WeakMap(), tt = new WeakSet(), mo = function() {
|
|
4106
|
+
return h(this, null, function* () {
|
|
4107
|
+
try {
|
|
4108
|
+
for (var t = C(s(this, V).stats()), e, n, r; e = !(n = yield t.next()).done; e = !1) {
|
|
4109
|
+
const { rtt: a } = n.value;
|
|
4110
|
+
s(this, Xi).push(a);
|
|
4111
|
+
}
|
|
4112
|
+
} catch (n) {
|
|
4113
|
+
r = [n];
|
|
4114
|
+
} finally {
|
|
4115
|
+
try {
|
|
4116
|
+
e && (n = t.return) && (yield n.call(t));
|
|
4117
|
+
} finally {
|
|
4118
|
+
if (r)
|
|
4119
|
+
throw r[0];
|
|
4120
|
+
}
|
|
4121
|
+
}
|
|
4122
|
+
});
|
|
4123
|
+
}, Is = new WeakMap(), Zi = new WeakMap(), Ss = new WeakMap(), bo = function(t) {
|
|
4124
|
+
return h(this, null, function* () {
|
|
4125
|
+
var d, f, p, b, m, I, y;
|
|
4126
|
+
s(this, F).info("handle subscription", t);
|
|
4127
|
+
const e = s(this, V), n = s(this, nt);
|
|
4128
|
+
if (!e) {
|
|
4129
|
+
s(this, F).info("no player");
|
|
4130
|
+
return;
|
|
4131
|
+
}
|
|
4132
|
+
if (!n) {
|
|
4133
|
+
s(this, F).info("no session");
|
|
4134
|
+
return;
|
|
4135
|
+
}
|
|
4136
|
+
const r = s(this, Ue).get(t.channelId);
|
|
4137
|
+
if (!r) {
|
|
4138
|
+
s(this, F).info("no catalog for ", t.channelId);
|
|
4139
|
+
return;
|
|
4140
|
+
}
|
|
4141
|
+
if (e.namespace().join("/") !== r.namespace().join("/")) {
|
|
4142
|
+
s(this, F).info("changing channel", t.channelId);
|
|
4143
|
+
const E = r.getVideoTrack(t.video), P = r.getAudioTrack(t.audio);
|
|
4144
|
+
yield e.zap(
|
|
4145
|
+
{
|
|
4146
|
+
namespace: r.namespace(),
|
|
4147
|
+
catalog: r.catalog(),
|
|
4148
|
+
videoTrack: E == null ? void 0 : E.track,
|
|
4149
|
+
audioTrack: P == null ? void 0 : P.track
|
|
4150
|
+
},
|
|
4151
|
+
500
|
|
4152
|
+
), s(this, F).info("switched channel", t.channelId), (d = s(this, Ue).get(Kt(e.namespace()))) == null || d.updateCatalog(e.catalog()), s(this, N).emit("received signal", {
|
|
4153
|
+
type: "subscription changed",
|
|
4154
|
+
subscription: t
|
|
4155
|
+
});
|
|
4156
|
+
return;
|
|
4157
|
+
}
|
|
4158
|
+
const a = r.getVideoTrack(t.video), c = r.getAudioTrack(t.audio);
|
|
4159
|
+
yield Promise.all([
|
|
4160
|
+
a && a.track.name !== ((p = (f = s(this, V)) == null ? void 0 : f.videoTrack()) == null ? void 0 : p.name) ? (b = s(this, V)) == null ? void 0 : b.setVideoTrack(a.track) : void 0,
|
|
4161
|
+
c && c.track.name !== ((I = (m = s(this, V)) == null ? void 0 : m.audioTrack()) == null ? void 0 : I.name) ? (y = s(this, V)) == null ? void 0 : y.setAudioTrack(c.track) : void 0
|
|
4162
|
+
]), s(this, N).emit("received signal", {
|
|
4163
|
+
type: "subscription changed",
|
|
4164
|
+
subscription: t
|
|
4165
|
+
});
|
|
4166
|
+
});
|
|
4167
|
+
}, yo = function() {
|
|
4168
|
+
return h(this, null, function* () {
|
|
4169
|
+
try {
|
|
4170
|
+
u(this, Se, "connecting"), s(this, F).info("Connecting..."), u(this, vs, Date.now()), s(this, gs) || u(this, gs, s(this, vs)), u(this, Se, "connected"), yield Promise.all([
|
|
4171
|
+
w(this, tt, Br).call(this, s(this, V).referenceClock(), s(this, V).audio),
|
|
4172
|
+
w(this, tt, Br).call(this, s(this, V).referenceClock(), s(this, V).video),
|
|
4173
|
+
w(this, tt, go).call(this, s(this, V).subtitles)
|
|
4174
|
+
]), yield s(this, V).closed(), s(this, nt).close(), s(this, F).info("Session closed");
|
|
4175
|
+
} catch (t) {
|
|
4176
|
+
s(this, F).warn("Session error", t);
|
|
4177
|
+
}
|
|
4178
|
+
});
|
|
4179
|
+
}, go = function(t) {
|
|
4180
|
+
return h(this, null, function* () {
|
|
4181
|
+
try {
|
|
4182
|
+
for (var e = C(t), n, r, a; n = !(r = yield e.next()).done; n = !1) {
|
|
4183
|
+
const c = r.value;
|
|
4184
|
+
s(this, N).emit("text track data", c);
|
|
4185
|
+
}
|
|
4186
|
+
} catch (r) {
|
|
4187
|
+
a = [r];
|
|
4188
|
+
} finally {
|
|
4189
|
+
try {
|
|
4190
|
+
n && (r = e.return) && (yield r.call(e));
|
|
4191
|
+
} finally {
|
|
4192
|
+
if (a)
|
|
4193
|
+
throw a[0];
|
|
4194
|
+
}
|
|
4195
|
+
}
|
|
4196
|
+
});
|
|
4197
|
+
}, Br = function(t, e) {
|
|
4198
|
+
return h(this, null, function* () {
|
|
4199
|
+
let n = "", r = "";
|
|
4200
|
+
try {
|
|
4201
|
+
for (var p = C(e), b, m, I; b = !(m = yield p.next()).done; b = !1) {
|
|
4202
|
+
const y = m.value;
|
|
4203
|
+
const E = Kt(y.track.namespace), P = y.track.trackObject.language;
|
|
4204
|
+
try {
|
|
4205
|
+
for (var a = C(y), c, d, f; c = !(d = yield a.next()).done; c = !1) {
|
|
4206
|
+
const [H, T] = d.value;
|
|
4207
|
+
n !== "" && n !== E && T.mediaType() === "video" && s(this, N).emit("add event", {
|
|
4208
|
+
type: "channel switch",
|
|
4209
|
+
channelId: E,
|
|
4210
|
+
timestamp: T.baseMediaDecodeTime() / T.timescale() * 1e3
|
|
4211
|
+
}), n = E, r !== "" && P && r !== P && T.mediaType() === "audio" && s(this, N).emit("add event", {
|
|
4212
|
+
type: "language switch",
|
|
4213
|
+
language: P,
|
|
4214
|
+
timestamp: T.baseMediaDecodeTime() / T.timescale() * 1e3
|
|
4215
|
+
}), r = P;
|
|
4216
|
+
const g = T.producerReferenceTime(), Y = s(this, ks).get(y.track.namespace) || 0;
|
|
4217
|
+
if (g && Date.now() - Y > 1e3) {
|
|
4218
|
+
s(this, ks).set(y.track.namespace, Date.now());
|
|
4219
|
+
const S = t.wallclock() - g.getTime();
|
|
4220
|
+
s(this, F).info("ti", {
|
|
4221
|
+
medaiType: T.mediaType(),
|
|
4222
|
+
referenceClock: t,
|
|
4223
|
+
delta: S,
|
|
4224
|
+
groupId: H,
|
|
4225
|
+
timestamp: T.baseMediaDecodeTime() / T.timescale() * 1e3 + S,
|
|
4226
|
+
wallclockTime: g.getTime()
|
|
4227
|
+
}), s(this, N).emit("received signal", {
|
|
4228
|
+
type: "timing info",
|
|
4229
|
+
timingInfo: {
|
|
4230
|
+
channelId: E,
|
|
4231
|
+
timestamp: T.baseMediaDecodeTime() / T.timescale() * 1e3 + S,
|
|
4232
|
+
wallclockTime: g.getTime()
|
|
4233
|
+
}
|
|
4234
|
+
});
|
|
4235
|
+
}
|
|
4236
|
+
s(this, N).emit("received moq data", {
|
|
4237
|
+
payload: T,
|
|
4238
|
+
channelId: E,
|
|
4239
|
+
groupId: H,
|
|
4240
|
+
// FIXME: We should replace this with something better than hashing the track name
|
|
4241
|
+
renditionId: Fc(y.track.trackObject.name)
|
|
4242
|
+
});
|
|
4243
|
+
}
|
|
4244
|
+
} catch (d) {
|
|
4245
|
+
f = [d];
|
|
4246
|
+
} finally {
|
|
4247
|
+
try {
|
|
4248
|
+
c && (d = a.return) && (yield d.call(a));
|
|
4249
|
+
} finally {
|
|
4250
|
+
if (f)
|
|
4251
|
+
throw f[0];
|
|
4252
|
+
}
|
|
4253
|
+
}
|
|
4254
|
+
}
|
|
4255
|
+
} catch (m) {
|
|
4256
|
+
I = [m];
|
|
4257
|
+
} finally {
|
|
4258
|
+
try {
|
|
4259
|
+
b && (m = p.return) && (yield m.call(p));
|
|
4260
|
+
} finally {
|
|
4261
|
+
if (I)
|
|
4262
|
+
throw I[0];
|
|
4263
|
+
}
|
|
4264
|
+
}
|
|
4265
|
+
});
|
|
4266
|
+
};
|
|
4267
|
+
let aa = zr;
|
|
4268
|
+
function Fc(i) {
|
|
4269
|
+
return i.split("").reduce(
|
|
4270
|
+
(e, n) => e = n.charCodeAt(0) + (e << 6) + (e << 16) - e,
|
|
4271
|
+
0
|
|
4272
|
+
);
|
|
4273
|
+
}
|
|
4274
|
+
var Pt, Te, _n, vo;
|
|
4275
|
+
class oa {
|
|
4276
|
+
constructor(t) {
|
|
4277
|
+
o(this, _n);
|
|
4278
|
+
o(this, Pt);
|
|
4279
|
+
o(this, Te);
|
|
4280
|
+
u(this, Pt, t), u(this, Te, w(this, _n, vo).call(this));
|
|
4281
|
+
}
|
|
4282
|
+
catalog() {
|
|
4283
|
+
return s(this, Pt).current();
|
|
4284
|
+
}
|
|
4285
|
+
namespace() {
|
|
4286
|
+
return s(this, Pt).current().namespace;
|
|
4287
|
+
}
|
|
4288
|
+
updateCatalog(t) {
|
|
4289
|
+
u(this, Pt, t);
|
|
4290
|
+
}
|
|
4291
|
+
getTextTrack(t) {
|
|
4292
|
+
return s(this, Pt).current().tracks.find((e) => e.label === t);
|
|
4293
|
+
}
|
|
4294
|
+
getAudioTrack(t) {
|
|
4295
|
+
return t.codec ? s(this, Te).filter((n) => !(!Bo(n) || n.bitRate > t.bitRate || t.codec && n.codec !== t.codec || t.language && n.language !== t.language)).at(-1) : void 0;
|
|
4296
|
+
}
|
|
4297
|
+
getVideoTrack(t) {
|
|
4298
|
+
return t.codec ? s(this, Te).filter((n) => !(!xo(n) || n.bitRate > t.bitRate || t.codec && n.codec !== t.codec)).at(-1) : void 0;
|
|
4299
|
+
}
|
|
4300
|
+
renditions() {
|
|
4301
|
+
return s(this, Te);
|
|
4302
|
+
}
|
|
4303
|
+
}
|
|
4304
|
+
Pt = new WeakMap(), Te = new WeakMap(), _n = new WeakSet(), vo = function() {
|
|
4305
|
+
const [t, e] = s(this, Pt).value();
|
|
4306
|
+
return Ro(t);
|
|
4307
|
+
};
|
|
4308
|
+
export {
|
|
4309
|
+
oa as CatalogObserver,
|
|
4310
|
+
aa as MoqConnectionAdapter
|
|
4311
|
+
};
|