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