@moq/watch 0.2.4 → 0.2.5
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/audio/source.d.ts.map +1 -1
- package/backend.d.ts +5 -1
- package/backend.d.ts.map +1 -1
- package/{broadcast-b-IDmAB3.js → broadcast-CZkbruBC.js} +912 -854
- package/{broadcast-b-IDmAB3.js.map → broadcast-CZkbruBC.js.map} +1 -1
- package/element.d.ts +7 -3
- package/element.d.ts.map +1 -1
- package/element.js +67 -43
- package/element.js.map +1 -1
- package/index.js +2 -2
- package/package.json +3 -3
- package/sync.d.ts +8 -2
- package/sync.d.ts.map +1 -1
- package/ui/components/BufferControl.d.ts +1 -1
- package/ui/context.d.ts +3 -1
- package/ui/context.d.ts.map +1 -1
- package/ui/index.js +255 -254
- package/ui/index.js.map +1 -1
- package/video/renderer.d.ts +3 -0
- package/video/renderer.d.ts.map +1 -1
- package/video/source.d.ts.map +1 -1
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
import * as _ from "@moq/lite";
|
|
2
|
-
import { Time as
|
|
2
|
+
import { Time as p, Path as zn } from "@moq/lite";
|
|
3
3
|
import { Signal as h, Effect as T } from "@moq/signals";
|
|
4
4
|
function v(n, e, t) {
|
|
5
|
-
function s(
|
|
6
|
-
if (
|
|
5
|
+
function s(c, o) {
|
|
6
|
+
if (c._zod || Object.defineProperty(c, "_zod", {
|
|
7
7
|
value: {
|
|
8
|
-
def:
|
|
8
|
+
def: o,
|
|
9
9
|
constr: a,
|
|
10
10
|
traits: /* @__PURE__ */ new Set()
|
|
11
11
|
},
|
|
12
12
|
enumerable: !1
|
|
13
|
-
}),
|
|
13
|
+
}), c._zod.traits.has(n))
|
|
14
14
|
return;
|
|
15
|
-
|
|
15
|
+
c._zod.traits.add(n), e(c, o);
|
|
16
16
|
const u = a.prototype, d = Object.keys(u);
|
|
17
17
|
for (let l = 0; l < d.length; l++) {
|
|
18
18
|
const f = d[l];
|
|
19
|
-
f in
|
|
19
|
+
f in c || (c[f] = u[f].bind(c));
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
const r = t?.Parent ?? Object;
|
|
23
23
|
class i extends r {
|
|
24
24
|
}
|
|
25
25
|
Object.defineProperty(i, "name", { value: n });
|
|
26
|
-
function a(
|
|
27
|
-
var
|
|
26
|
+
function a(c) {
|
|
27
|
+
var o;
|
|
28
28
|
const u = t?.Parent ? new i() : this;
|
|
29
|
-
s(u,
|
|
29
|
+
s(u, c), (o = u._zod).deferred ?? (o.deferred = []);
|
|
30
30
|
for (const d of u._zod.deferred)
|
|
31
31
|
d();
|
|
32
32
|
return u;
|
|
33
33
|
}
|
|
34
34
|
return Object.defineProperty(a, "init", { value: s }), Object.defineProperty(a, Symbol.hasInstance, {
|
|
35
|
-
value: (
|
|
35
|
+
value: (c) => t?.Parent && c instanceof t.Parent ? !0 : c?._zod?.traits?.has(n)
|
|
36
36
|
}), Object.defineProperty(a, "name", { value: n }), a;
|
|
37
37
|
}
|
|
38
38
|
class H extends Error {
|
|
@@ -40,19 +40,19 @@ class H extends Error {
|
|
|
40
40
|
super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
class
|
|
43
|
+
class Nn extends Error {
|
|
44
44
|
constructor(e) {
|
|
45
45
|
super(`Encountered unidirectional transform during encode: ${e}`), this.name = "ZodEncodeError";
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
const
|
|
48
|
+
const qn = {};
|
|
49
49
|
function K(n) {
|
|
50
|
-
return
|
|
50
|
+
return qn;
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function Dn(n, e) {
|
|
53
53
|
return typeof e == "bigint" ? e.toString() : e;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function je(n) {
|
|
56
56
|
return {
|
|
57
57
|
get value() {
|
|
58
58
|
{
|
|
@@ -62,7 +62,7 @@ function $e(n) {
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function Ge(n) {
|
|
66
66
|
const e = n.startsWith("^") ? 1 : 0, t = n.endsWith("$") ? n.length - 1 : n.length;
|
|
67
67
|
return n.slice(e, t);
|
|
68
68
|
}
|
|
@@ -83,12 +83,12 @@ function I(n, e, t) {
|
|
|
83
83
|
configurable: !0
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
-
const
|
|
86
|
+
const Ze = "captureStackTrace" in Error ? Error.captureStackTrace : (...n) => {
|
|
87
87
|
};
|
|
88
88
|
function de(n) {
|
|
89
89
|
return typeof n == "object" && n !== null && !Array.isArray(n);
|
|
90
90
|
}
|
|
91
|
-
function
|
|
91
|
+
function Xe(n) {
|
|
92
92
|
if (de(n) === !1)
|
|
93
93
|
return !1;
|
|
94
94
|
const e = n.constructor;
|
|
@@ -97,23 +97,23 @@ function Ze(n) {
|
|
|
97
97
|
const t = e.prototype;
|
|
98
98
|
return !(de(t) === !1 || Object.prototype.hasOwnProperty.call(t, "isPrototypeOf") === !1);
|
|
99
99
|
}
|
|
100
|
-
function
|
|
101
|
-
return
|
|
100
|
+
function xn(n) {
|
|
101
|
+
return Xe(n) ? { ...n } : Array.isArray(n) ? [...n] : n;
|
|
102
102
|
}
|
|
103
103
|
function Ae(n) {
|
|
104
104
|
return n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function Cn(n, e, t) {
|
|
107
107
|
const s = new n._zod.constr(e ?? n._zod.def);
|
|
108
108
|
return (!e || t?.parent) && (s._zod.parent = n), s;
|
|
109
109
|
}
|
|
110
|
-
function
|
|
110
|
+
function P(n) {
|
|
111
111
|
return {};
|
|
112
112
|
}
|
|
113
|
-
function
|
|
113
|
+
function Fn(n) {
|
|
114
114
|
return Object.keys(n).filter((e) => n[e]._zod.optin === "optional" && n[e]._zod.optout === "optional");
|
|
115
115
|
}
|
|
116
|
-
const
|
|
116
|
+
const Vn = {
|
|
117
117
|
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
118
118
|
int32: [-2147483648, 2147483647],
|
|
119
119
|
uint32: [0, 4294967295],
|
|
@@ -145,62 +145,62 @@ function Y(n, e, t) {
|
|
|
145
145
|
}
|
|
146
146
|
return delete s.inst, delete s.continue, e?.reportInput || delete s.input, s;
|
|
147
147
|
}
|
|
148
|
-
const
|
|
148
|
+
const He = (n, e) => {
|
|
149
149
|
n.name = "$ZodError", Object.defineProperty(n, "_zod", {
|
|
150
150
|
value: n._zod,
|
|
151
151
|
enumerable: !1
|
|
152
152
|
}), Object.defineProperty(n, "issues", {
|
|
153
153
|
value: e,
|
|
154
154
|
enumerable: !1
|
|
155
|
-
}), n.message = JSON.stringify(e,
|
|
155
|
+
}), n.message = JSON.stringify(e, Dn, 2), Object.defineProperty(n, "toString", {
|
|
156
156
|
value: () => n.message,
|
|
157
157
|
enumerable: !1
|
|
158
158
|
});
|
|
159
|
-
},
|
|
159
|
+
}, Bn = v("$ZodError", He), fe = v("$ZodError", He, { Parent: Error }), Ln = (n) => (e, t, s, r) => {
|
|
160
160
|
const i = s ? Object.assign(s, { async: !1 }) : { async: !1 }, a = e._zod.run({ value: t, issues: [] }, i);
|
|
161
161
|
if (a instanceof Promise)
|
|
162
162
|
throw new H();
|
|
163
163
|
if (a.issues.length) {
|
|
164
|
-
const
|
|
165
|
-
throw
|
|
164
|
+
const c = new (r?.Err ?? n)(a.issues.map((o) => Y(o, i, K())));
|
|
165
|
+
throw Ze(c, r?.callee), c;
|
|
166
166
|
}
|
|
167
167
|
return a.value;
|
|
168
|
-
},
|
|
168
|
+
}, $n = /* @__PURE__ */ Ln(fe), jn = (n) => async (e, t, s, r) => {
|
|
169
169
|
const i = s ? Object.assign(s, { async: !0 }) : { async: !0 };
|
|
170
170
|
let a = e._zod.run({ value: t, issues: [] }, i);
|
|
171
171
|
if (a instanceof Promise && (a = await a), a.issues.length) {
|
|
172
|
-
const
|
|
173
|
-
throw
|
|
172
|
+
const c = new (r?.Err ?? n)(a.issues.map((o) => Y(o, i, K())));
|
|
173
|
+
throw Ze(c, r?.callee), c;
|
|
174
174
|
}
|
|
175
175
|
return a.value;
|
|
176
|
-
},
|
|
176
|
+
}, Gn = /* @__PURE__ */ jn(fe), Zn = (n) => (e, t, s) => {
|
|
177
177
|
const r = s ? { ...s, async: !1 } : { async: !1 }, i = e._zod.run({ value: t, issues: [] }, r);
|
|
178
178
|
if (i instanceof Promise)
|
|
179
179
|
throw new H();
|
|
180
180
|
return i.issues.length ? {
|
|
181
181
|
success: !1,
|
|
182
|
-
error: new (n ??
|
|
182
|
+
error: new (n ?? Bn)(i.issues.map((a) => Y(a, r, K())))
|
|
183
183
|
} : { success: !0, data: i.value };
|
|
184
|
-
},
|
|
184
|
+
}, We = /* @__PURE__ */ Zn(fe), Xn = (n) => async (e, t, s) => {
|
|
185
185
|
const r = s ? Object.assign(s, { async: !0 }) : { async: !0 };
|
|
186
186
|
let i = e._zod.run({ value: t, issues: [] }, r);
|
|
187
187
|
return i instanceof Promise && (i = await i), i.issues.length ? {
|
|
188
188
|
success: !1,
|
|
189
189
|
error: new n(i.issues.map((a) => Y(a, r, K())))
|
|
190
190
|
} : { success: !0, data: i.value };
|
|
191
|
-
},
|
|
191
|
+
}, Ke = /* @__PURE__ */ Xn(fe), Hn = (n) => {
|
|
192
192
|
const e = n ? `[\\s\\S]{${n?.minimum ?? 0},${n?.maximum ?? ""}}` : "[\\s\\S]*";
|
|
193
193
|
return new RegExp(`^${e}$`);
|
|
194
|
-
},
|
|
194
|
+
}, Wn = /^-?\d+$/, Ye = /^-?\d+(?:\.\d+)?$/, Kn = /^(?:true|false)$/i, be = /* @__PURE__ */ v("$ZodCheck", (n, e) => {
|
|
195
195
|
var t;
|
|
196
196
|
n._zod ?? (n._zod = {}), n._zod.def = e, (t = n._zod).onattach ?? (t.onattach = []);
|
|
197
|
-
}),
|
|
197
|
+
}), Je = {
|
|
198
198
|
number: "number",
|
|
199
199
|
bigint: "bigint",
|
|
200
200
|
object: "date"
|
|
201
|
-
},
|
|
201
|
+
}, Yn = /* @__PURE__ */ v("$ZodCheckLessThan", (n, e) => {
|
|
202
202
|
be.init(n, e);
|
|
203
|
-
const t =
|
|
203
|
+
const t = Je[typeof e.value];
|
|
204
204
|
n._zod.onattach.push((s) => {
|
|
205
205
|
const r = s._zod.bag, i = (e.inclusive ? r.maximum : r.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
206
206
|
e.value < i && (e.inclusive ? r.maximum = e.value : r.exclusiveMaximum = e.value);
|
|
@@ -215,9 +215,9 @@ const Xe = (n, e) => {
|
|
|
215
215
|
continue: !e.abort
|
|
216
216
|
});
|
|
217
217
|
};
|
|
218
|
-
}),
|
|
218
|
+
}), Jn = /* @__PURE__ */ v("$ZodCheckGreaterThan", (n, e) => {
|
|
219
219
|
be.init(n, e);
|
|
220
|
-
const t =
|
|
220
|
+
const t = Je[typeof e.value];
|
|
221
221
|
n._zod.onattach.push((s) => {
|
|
222
222
|
const r = s._zod.bag, i = (e.inclusive ? r.minimum : r.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
223
223
|
e.value > i && (e.inclusive ? r.minimum = e.value : r.exclusiveMinimum = e.value);
|
|
@@ -232,29 +232,29 @@ const Xe = (n, e) => {
|
|
|
232
232
|
continue: !e.abort
|
|
233
233
|
});
|
|
234
234
|
};
|
|
235
|
-
}),
|
|
235
|
+
}), Qn = /* @__PURE__ */ v("$ZodCheckNumberFormat", (n, e) => {
|
|
236
236
|
be.init(n, e), e.format = e.format || "float64";
|
|
237
|
-
const t = e.format?.includes("int"), s = t ? "int" : "number", [r, i] =
|
|
237
|
+
const t = e.format?.includes("int"), s = t ? "int" : "number", [r, i] = Vn[e.format];
|
|
238
238
|
n._zod.onattach.push((a) => {
|
|
239
|
-
const
|
|
240
|
-
|
|
239
|
+
const c = a._zod.bag;
|
|
240
|
+
c.format = e.format, c.minimum = r, c.maximum = i, t && (c.pattern = Wn);
|
|
241
241
|
}), n._zod.check = (a) => {
|
|
242
|
-
const
|
|
242
|
+
const c = a.value;
|
|
243
243
|
if (t) {
|
|
244
|
-
if (!Number.isInteger(
|
|
244
|
+
if (!Number.isInteger(c)) {
|
|
245
245
|
a.issues.push({
|
|
246
246
|
expected: s,
|
|
247
247
|
format: e.format,
|
|
248
248
|
code: "invalid_type",
|
|
249
249
|
continue: !1,
|
|
250
|
-
input:
|
|
250
|
+
input: c,
|
|
251
251
|
inst: n
|
|
252
252
|
});
|
|
253
253
|
return;
|
|
254
254
|
}
|
|
255
|
-
if (!Number.isSafeInteger(
|
|
256
|
-
|
|
257
|
-
input:
|
|
255
|
+
if (!Number.isSafeInteger(c)) {
|
|
256
|
+
c > 0 ? a.issues.push({
|
|
257
|
+
input: c,
|
|
258
258
|
code: "too_big",
|
|
259
259
|
maximum: Number.MAX_SAFE_INTEGER,
|
|
260
260
|
note: "Integers must be within the safe integer range.",
|
|
@@ -263,7 +263,7 @@ const Xe = (n, e) => {
|
|
|
263
263
|
inclusive: !0,
|
|
264
264
|
continue: !e.abort
|
|
265
265
|
}) : a.issues.push({
|
|
266
|
-
input:
|
|
266
|
+
input: c,
|
|
267
267
|
code: "too_small",
|
|
268
268
|
minimum: Number.MIN_SAFE_INTEGER,
|
|
269
269
|
note: "Integers must be within the safe integer range.",
|
|
@@ -275,17 +275,17 @@ const Xe = (n, e) => {
|
|
|
275
275
|
return;
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
|
-
|
|
278
|
+
c < r && a.issues.push({
|
|
279
279
|
origin: "number",
|
|
280
|
-
input:
|
|
280
|
+
input: c,
|
|
281
281
|
code: "too_small",
|
|
282
282
|
minimum: r,
|
|
283
283
|
inclusive: !0,
|
|
284
284
|
inst: n,
|
|
285
285
|
continue: !e.abort
|
|
286
|
-
}),
|
|
286
|
+
}), c > i && a.issues.push({
|
|
287
287
|
origin: "number",
|
|
288
|
-
input:
|
|
288
|
+
input: c,
|
|
289
289
|
code: "too_big",
|
|
290
290
|
maximum: i,
|
|
291
291
|
inclusive: !0,
|
|
@@ -293,13 +293,13 @@ const Xe = (n, e) => {
|
|
|
293
293
|
continue: !e.abort
|
|
294
294
|
});
|
|
295
295
|
};
|
|
296
|
-
}),
|
|
296
|
+
}), et = {
|
|
297
297
|
major: 4,
|
|
298
298
|
minor: 3,
|
|
299
299
|
patch: 6
|
|
300
300
|
}, U = /* @__PURE__ */ v("$ZodType", (n, e) => {
|
|
301
301
|
var t;
|
|
302
|
-
n ?? (n = {}), n._zod.def = e, n._zod.bag = n._zod.bag || {}, n._zod.version =
|
|
302
|
+
n ?? (n = {}), n._zod.def = e, n._zod.bag = n._zod.bag || {}, n._zod.version = et;
|
|
303
303
|
const s = [...n._zod.def.checks ?? []];
|
|
304
304
|
n._zod.traits.has("$ZodCheck") && s.unshift(n);
|
|
305
305
|
for (const r of s)
|
|
@@ -310,20 +310,20 @@ const Xe = (n, e) => {
|
|
|
310
310
|
n._zod.run = n._zod.parse;
|
|
311
311
|
});
|
|
312
312
|
else {
|
|
313
|
-
const r = (a,
|
|
313
|
+
const r = (a, c, o) => {
|
|
314
314
|
let u = ee(a), d;
|
|
315
|
-
for (const l of
|
|
315
|
+
for (const l of c) {
|
|
316
316
|
if (l._zod.def.when) {
|
|
317
317
|
if (!l._zod.def.when(a))
|
|
318
318
|
continue;
|
|
319
319
|
} else if (u)
|
|
320
320
|
continue;
|
|
321
|
-
const f = a.issues.length,
|
|
322
|
-
if (
|
|
321
|
+
const f = a.issues.length, w = l._zod.check(a);
|
|
322
|
+
if (w instanceof Promise && o?.async === !1)
|
|
323
323
|
throw new H();
|
|
324
|
-
if (d ||
|
|
324
|
+
if (d || w instanceof Promise)
|
|
325
325
|
d = (d ?? Promise.resolve()).then(async () => {
|
|
326
|
-
await
|
|
326
|
+
await w, a.issues.length !== f && (u || (u = ee(a, f)));
|
|
327
327
|
});
|
|
328
328
|
else {
|
|
329
329
|
if (a.issues.length === f)
|
|
@@ -332,47 +332,47 @@ const Xe = (n, e) => {
|
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
334
|
return d ? d.then(() => a) : a;
|
|
335
|
-
}, i = (a,
|
|
335
|
+
}, i = (a, c, o) => {
|
|
336
336
|
if (ee(a))
|
|
337
337
|
return a.aborted = !0, a;
|
|
338
|
-
const u = r(
|
|
338
|
+
const u = r(c, s, o);
|
|
339
339
|
if (u instanceof Promise) {
|
|
340
|
-
if (
|
|
340
|
+
if (o.async === !1)
|
|
341
341
|
throw new H();
|
|
342
|
-
return u.then((d) => n._zod.parse(d,
|
|
342
|
+
return u.then((d) => n._zod.parse(d, o));
|
|
343
343
|
}
|
|
344
|
-
return n._zod.parse(u,
|
|
344
|
+
return n._zod.parse(u, o);
|
|
345
345
|
};
|
|
346
|
-
n._zod.run = (a,
|
|
347
|
-
if (
|
|
348
|
-
return n._zod.parse(a,
|
|
349
|
-
if (
|
|
350
|
-
const u = n._zod.parse({ value: a.value, issues: [] }, { ...
|
|
351
|
-
return u instanceof Promise ? u.then((d) => i(d, a,
|
|
352
|
-
}
|
|
353
|
-
const
|
|
354
|
-
if (
|
|
355
|
-
if (
|
|
346
|
+
n._zod.run = (a, c) => {
|
|
347
|
+
if (c.skipChecks)
|
|
348
|
+
return n._zod.parse(a, c);
|
|
349
|
+
if (c.direction === "backward") {
|
|
350
|
+
const u = n._zod.parse({ value: a.value, issues: [] }, { ...c, skipChecks: !0 });
|
|
351
|
+
return u instanceof Promise ? u.then((d) => i(d, a, c)) : i(u, a, c);
|
|
352
|
+
}
|
|
353
|
+
const o = n._zod.parse(a, c);
|
|
354
|
+
if (o instanceof Promise) {
|
|
355
|
+
if (c.async === !1)
|
|
356
356
|
throw new H();
|
|
357
|
-
return
|
|
357
|
+
return o.then((u) => r(u, s, c));
|
|
358
358
|
}
|
|
359
|
-
return r(
|
|
359
|
+
return r(o, s, c);
|
|
360
360
|
};
|
|
361
361
|
}
|
|
362
362
|
I(n, "~standard", () => ({
|
|
363
363
|
validate: (r) => {
|
|
364
364
|
try {
|
|
365
|
-
const i =
|
|
365
|
+
const i = We(n, r);
|
|
366
366
|
return i.success ? { value: i.data } : { issues: i.error?.issues };
|
|
367
367
|
} catch {
|
|
368
|
-
return
|
|
368
|
+
return Ke(n, r).then((a) => a.success ? { value: a.data } : { issues: a.error?.issues });
|
|
369
369
|
}
|
|
370
370
|
},
|
|
371
371
|
vendor: "zod",
|
|
372
372
|
version: 1
|
|
373
373
|
}));
|
|
374
|
-
}),
|
|
375
|
-
U.init(n, e), n._zod.pattern = [...n?._zod.bag?.patterns ?? []].pop() ??
|
|
374
|
+
}), nt = /* @__PURE__ */ v("$ZodString", (n, e) => {
|
|
375
|
+
U.init(n, e), n._zod.pattern = [...n?._zod.bag?.patterns ?? []].pop() ?? Hn(n._zod.bag), n._zod.parse = (t, s) => {
|
|
376
376
|
if (e.coerce)
|
|
377
377
|
try {
|
|
378
378
|
t.value = String(t.value);
|
|
@@ -385,8 +385,8 @@ const Xe = (n, e) => {
|
|
|
385
385
|
inst: n
|
|
386
386
|
}), t;
|
|
387
387
|
};
|
|
388
|
-
}),
|
|
389
|
-
U.init(n, e), n._zod.pattern = n._zod.bag.pattern ??
|
|
388
|
+
}), Qe = /* @__PURE__ */ v("$ZodNumber", (n, e) => {
|
|
389
|
+
U.init(n, e), n._zod.pattern = n._zod.bag.pattern ?? Ye, n._zod.parse = (t, s) => {
|
|
390
390
|
if (e.coerce)
|
|
391
391
|
try {
|
|
392
392
|
t.value = Number(t.value);
|
|
@@ -404,10 +404,10 @@ const Xe = (n, e) => {
|
|
|
404
404
|
...i ? { received: i } : {}
|
|
405
405
|
}), t;
|
|
406
406
|
};
|
|
407
|
-
}),
|
|
408
|
-
|
|
409
|
-
}),
|
|
410
|
-
U.init(n, e), n._zod.pattern =
|
|
407
|
+
}), tt = /* @__PURE__ */ v("$ZodNumberFormat", (n, e) => {
|
|
408
|
+
Qn.init(n, e), Qe.init(n, e);
|
|
409
|
+
}), st = /* @__PURE__ */ v("$ZodBoolean", (n, e) => {
|
|
410
|
+
U.init(n, e), n._zod.pattern = Kn, n._zod.parse = (t, s) => {
|
|
411
411
|
if (e.coerce)
|
|
412
412
|
try {
|
|
413
413
|
t.value = !!t.value;
|
|
@@ -425,7 +425,7 @@ const Xe = (n, e) => {
|
|
|
425
425
|
function Ie(n, e, t) {
|
|
426
426
|
n.issues.length && e.issues.push(...Z(t, n.issues)), e.value[t] = n.value;
|
|
427
427
|
}
|
|
428
|
-
const
|
|
428
|
+
const rt = /* @__PURE__ */ v("$ZodArray", (n, e) => {
|
|
429
429
|
U.init(n, e), n._zod.parse = (t, s) => {
|
|
430
430
|
const r = t.value;
|
|
431
431
|
if (!Array.isArray(r))
|
|
@@ -438,11 +438,11 @@ const st = /* @__PURE__ */ v("$ZodArray", (n, e) => {
|
|
|
438
438
|
t.value = Array(r.length);
|
|
439
439
|
const i = [];
|
|
440
440
|
for (let a = 0; a < r.length; a++) {
|
|
441
|
-
const
|
|
442
|
-
value:
|
|
441
|
+
const c = r[a], o = e.element._zod.run({
|
|
442
|
+
value: c,
|
|
443
443
|
issues: []
|
|
444
444
|
}, s);
|
|
445
|
-
|
|
445
|
+
o instanceof Promise ? i.push(o.then((u) => Ie(u, t, a))) : Ie(o, t, a);
|
|
446
446
|
}
|
|
447
447
|
return i.length ? Promise.all(i).then(() => t) : t;
|
|
448
448
|
};
|
|
@@ -455,12 +455,12 @@ function le(n, e, t, s, r) {
|
|
|
455
455
|
}
|
|
456
456
|
n.value === void 0 ? t in s && (e.value[t] = void 0) : e.value[t] = n.value;
|
|
457
457
|
}
|
|
458
|
-
function
|
|
458
|
+
function it(n) {
|
|
459
459
|
const e = Object.keys(n.shape);
|
|
460
460
|
for (const s of e)
|
|
461
461
|
if (!n.shape?.[s]?._zod?.traits?.has("$ZodType"))
|
|
462
462
|
throw new Error(`Invalid element at key "${s}": expected a Zod schema`);
|
|
463
|
-
const t =
|
|
463
|
+
const t = Fn(n.shape);
|
|
464
464
|
return {
|
|
465
465
|
...n,
|
|
466
466
|
keys: e,
|
|
@@ -469,17 +469,17 @@ function rt(n) {
|
|
|
469
469
|
optionalKeys: new Set(t)
|
|
470
470
|
};
|
|
471
471
|
}
|
|
472
|
-
function
|
|
473
|
-
const a = [],
|
|
472
|
+
function at(n, e, t, s, r, i) {
|
|
473
|
+
const a = [], c = r.keySet, o = r.catchall._zod, u = o.def.type, d = o.optout === "optional";
|
|
474
474
|
for (const l in e) {
|
|
475
|
-
if (
|
|
475
|
+
if (c.has(l))
|
|
476
476
|
continue;
|
|
477
477
|
if (u === "never") {
|
|
478
478
|
a.push(l);
|
|
479
479
|
continue;
|
|
480
480
|
}
|
|
481
|
-
const f =
|
|
482
|
-
f instanceof Promise ? n.push(f.then((
|
|
481
|
+
const f = o.run({ value: e[l], issues: [] }, s);
|
|
482
|
+
f instanceof Promise ? n.push(f.then((w) => le(w, t, l, e, d))) : le(f, t, l, e, d);
|
|
483
483
|
}
|
|
484
484
|
return a.length && t.issues.push({
|
|
485
485
|
code: "unrecognized_keys",
|
|
@@ -488,50 +488,50 @@ function it(n, e, t, s, r, i) {
|
|
|
488
488
|
inst: i
|
|
489
489
|
}), n.length ? Promise.all(n).then(() => t) : t;
|
|
490
490
|
}
|
|
491
|
-
const
|
|
491
|
+
const ot = /* @__PURE__ */ v("$ZodObject", (n, e) => {
|
|
492
492
|
if (U.init(n, e), !Object.getOwnPropertyDescriptor(e, "shape")?.get) {
|
|
493
|
-
const
|
|
493
|
+
const c = e.shape;
|
|
494
494
|
Object.defineProperty(e, "shape", {
|
|
495
495
|
get: () => {
|
|
496
|
-
const
|
|
496
|
+
const o = { ...c };
|
|
497
497
|
return Object.defineProperty(e, "shape", {
|
|
498
|
-
value:
|
|
499
|
-
}),
|
|
498
|
+
value: o
|
|
499
|
+
}), o;
|
|
500
500
|
}
|
|
501
501
|
});
|
|
502
502
|
}
|
|
503
|
-
const s =
|
|
503
|
+
const s = je(() => it(e));
|
|
504
504
|
I(n._zod, "propValues", () => {
|
|
505
|
-
const
|
|
506
|
-
for (const u in
|
|
507
|
-
const d =
|
|
505
|
+
const c = e.shape, o = {};
|
|
506
|
+
for (const u in c) {
|
|
507
|
+
const d = c[u]._zod;
|
|
508
508
|
if (d.values) {
|
|
509
|
-
|
|
509
|
+
o[u] ?? (o[u] = /* @__PURE__ */ new Set());
|
|
510
510
|
for (const l of d.values)
|
|
511
|
-
|
|
511
|
+
o[u].add(l);
|
|
512
512
|
}
|
|
513
513
|
}
|
|
514
|
-
return
|
|
514
|
+
return o;
|
|
515
515
|
});
|
|
516
516
|
const r = de, i = e.catchall;
|
|
517
517
|
let a;
|
|
518
|
-
n._zod.parse = (
|
|
518
|
+
n._zod.parse = (c, o) => {
|
|
519
519
|
a ?? (a = s.value);
|
|
520
|
-
const u =
|
|
520
|
+
const u = c.value;
|
|
521
521
|
if (!r(u))
|
|
522
|
-
return
|
|
522
|
+
return c.issues.push({
|
|
523
523
|
expected: "object",
|
|
524
524
|
code: "invalid_type",
|
|
525
525
|
input: u,
|
|
526
526
|
inst: n
|
|
527
|
-
}),
|
|
528
|
-
|
|
527
|
+
}), c;
|
|
528
|
+
c.value = {};
|
|
529
529
|
const d = [], l = a.shape;
|
|
530
530
|
for (const f of a.keys) {
|
|
531
|
-
const
|
|
532
|
-
g instanceof Promise ? d.push(g.then((R) => le(R,
|
|
531
|
+
const w = l[f], b = w._zod.optout === "optional", g = w._zod.run({ value: u[f], issues: [] }, o);
|
|
532
|
+
g instanceof Promise ? d.push(g.then((R) => le(R, c, f, u, b))) : le(g, c, f, u, b);
|
|
533
533
|
}
|
|
534
|
-
return i ?
|
|
534
|
+
return i ? at(d, u, c, o, s.value, n) : d.length ? Promise.all(d).then(() => c) : c;
|
|
535
535
|
};
|
|
536
536
|
});
|
|
537
537
|
function Re(n, e, t, s) {
|
|
@@ -546,14 +546,14 @@ function Re(n, e, t, s) {
|
|
|
546
546
|
errors: n.map((i) => i.issues.map((a) => Y(a, s, K())))
|
|
547
547
|
}), e);
|
|
548
548
|
}
|
|
549
|
-
const
|
|
549
|
+
const en = /* @__PURE__ */ v("$ZodUnion", (n, e) => {
|
|
550
550
|
U.init(n, e), I(n._zod, "optin", () => e.options.some((r) => r._zod.optin === "optional") ? "optional" : void 0), I(n._zod, "optout", () => e.options.some((r) => r._zod.optout === "optional") ? "optional" : void 0), I(n._zod, "values", () => {
|
|
551
551
|
if (e.options.every((r) => r._zod.values))
|
|
552
552
|
return new Set(e.options.flatMap((r) => Array.from(r._zod.values)));
|
|
553
553
|
}), I(n._zod, "pattern", () => {
|
|
554
554
|
if (e.options.every((r) => r._zod.pattern)) {
|
|
555
555
|
const r = e.options.map((i) => i._zod.pattern);
|
|
556
|
-
return new RegExp(`^(${r.map((i) =>
|
|
556
|
+
return new RegExp(`^(${r.map((i) => Ge(i.source)).join("|")})$`);
|
|
557
557
|
}
|
|
558
558
|
});
|
|
559
559
|
const t = e.options.length === 1, s = e.options[0]._zod.run;
|
|
@@ -561,24 +561,24 @@ const Qe = /* @__PURE__ */ v("$ZodUnion", (n, e) => {
|
|
|
561
561
|
if (t)
|
|
562
562
|
return s(r, i);
|
|
563
563
|
let a = !1;
|
|
564
|
-
const
|
|
565
|
-
for (const
|
|
566
|
-
const u =
|
|
564
|
+
const c = [];
|
|
565
|
+
for (const o of e.options) {
|
|
566
|
+
const u = o._zod.run({
|
|
567
567
|
value: r.value,
|
|
568
568
|
issues: []
|
|
569
569
|
}, i);
|
|
570
570
|
if (u instanceof Promise)
|
|
571
|
-
|
|
571
|
+
c.push(u), a = !0;
|
|
572
572
|
else {
|
|
573
573
|
if (u.issues.length === 0)
|
|
574
574
|
return u;
|
|
575
|
-
|
|
575
|
+
c.push(u);
|
|
576
576
|
}
|
|
577
577
|
}
|
|
578
|
-
return a ? Promise.all(
|
|
578
|
+
return a ? Promise.all(c).then((o) => Re(o, r, n, i)) : Re(c, r, n, i);
|
|
579
579
|
};
|
|
580
|
-
}),
|
|
581
|
-
e.inclusive = !1,
|
|
580
|
+
}), ct = /* @__PURE__ */ v("$ZodDiscriminatedUnion", (n, e) => {
|
|
581
|
+
e.inclusive = !1, en.init(n, e);
|
|
582
582
|
const t = n._zod.parse;
|
|
583
583
|
I(n._zod, "propValues", () => {
|
|
584
584
|
const r = {};
|
|
@@ -586,24 +586,24 @@ const Qe = /* @__PURE__ */ v("$ZodUnion", (n, e) => {
|
|
|
586
586
|
const a = i._zod.propValues;
|
|
587
587
|
if (!a || Object.keys(a).length === 0)
|
|
588
588
|
throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);
|
|
589
|
-
for (const [
|
|
590
|
-
r[
|
|
591
|
-
for (const u of
|
|
592
|
-
r[
|
|
589
|
+
for (const [c, o] of Object.entries(a)) {
|
|
590
|
+
r[c] || (r[c] = /* @__PURE__ */ new Set());
|
|
591
|
+
for (const u of o)
|
|
592
|
+
r[c].add(u);
|
|
593
593
|
}
|
|
594
594
|
}
|
|
595
595
|
return r;
|
|
596
596
|
});
|
|
597
|
-
const s =
|
|
597
|
+
const s = je(() => {
|
|
598
598
|
const r = e.options, i = /* @__PURE__ */ new Map();
|
|
599
599
|
for (const a of r) {
|
|
600
|
-
const
|
|
601
|
-
if (!
|
|
600
|
+
const c = a._zod.propValues?.[e.discriminator];
|
|
601
|
+
if (!c || c.size === 0)
|
|
602
602
|
throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(a)}"`);
|
|
603
|
-
for (const
|
|
604
|
-
if (i.has(
|
|
605
|
-
throw new Error(`Duplicate discriminator value "${String(
|
|
606
|
-
i.set(
|
|
603
|
+
for (const o of c) {
|
|
604
|
+
if (i.has(o))
|
|
605
|
+
throw new Error(`Duplicate discriminator value "${String(o)}"`);
|
|
606
|
+
i.set(o, a);
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
609
|
return i;
|
|
@@ -617,8 +617,8 @@ const Qe = /* @__PURE__ */ v("$ZodUnion", (n, e) => {
|
|
|
617
617
|
input: a,
|
|
618
618
|
inst: n
|
|
619
619
|
}), r;
|
|
620
|
-
const
|
|
621
|
-
return
|
|
620
|
+
const c = s.value.get(a?.[e.discriminator]);
|
|
621
|
+
return c ? c._zod.run(r, i) : e.unionFallback ? t(r, i) : (r.issues.push({
|
|
622
622
|
code: "invalid_union",
|
|
623
623
|
errors: [],
|
|
624
624
|
note: "No matching discriminator",
|
|
@@ -628,10 +628,10 @@ const Qe = /* @__PURE__ */ v("$ZodUnion", (n, e) => {
|
|
|
628
628
|
inst: n
|
|
629
629
|
}), r);
|
|
630
630
|
};
|
|
631
|
-
}),
|
|
631
|
+
}), ut = /* @__PURE__ */ v("$ZodRecord", (n, e) => {
|
|
632
632
|
U.init(n, e), n._zod.parse = (t, s) => {
|
|
633
633
|
const r = t.value;
|
|
634
|
-
if (!
|
|
634
|
+
if (!Xe(r))
|
|
635
635
|
return t.issues.push({
|
|
636
636
|
expected: "record",
|
|
637
637
|
code: "invalid_type",
|
|
@@ -641,58 +641,58 @@ const Qe = /* @__PURE__ */ v("$ZodUnion", (n, e) => {
|
|
|
641
641
|
const i = [], a = e.keyType._zod.values;
|
|
642
642
|
if (a) {
|
|
643
643
|
t.value = {};
|
|
644
|
-
const
|
|
644
|
+
const c = /* @__PURE__ */ new Set();
|
|
645
645
|
for (const u of a)
|
|
646
646
|
if (typeof u == "string" || typeof u == "number" || typeof u == "symbol") {
|
|
647
|
-
|
|
647
|
+
c.add(typeof u == "number" ? u.toString() : u);
|
|
648
648
|
const d = e.valueType._zod.run({ value: r[u], issues: [] }, s);
|
|
649
649
|
d instanceof Promise ? i.push(d.then((l) => {
|
|
650
650
|
l.issues.length && t.issues.push(...Z(u, l.issues)), t.value[u] = l.value;
|
|
651
651
|
})) : (d.issues.length && t.issues.push(...Z(u, d.issues)), t.value[u] = d.value);
|
|
652
652
|
}
|
|
653
|
-
let
|
|
653
|
+
let o;
|
|
654
654
|
for (const u in r)
|
|
655
|
-
|
|
656
|
-
|
|
655
|
+
c.has(u) || (o = o ?? [], o.push(u));
|
|
656
|
+
o && o.length > 0 && t.issues.push({
|
|
657
657
|
code: "unrecognized_keys",
|
|
658
658
|
input: r,
|
|
659
659
|
inst: n,
|
|
660
|
-
keys:
|
|
660
|
+
keys: o
|
|
661
661
|
});
|
|
662
662
|
} else {
|
|
663
663
|
t.value = {};
|
|
664
|
-
for (const
|
|
665
|
-
if (
|
|
664
|
+
for (const c of Reflect.ownKeys(r)) {
|
|
665
|
+
if (c === "__proto__")
|
|
666
666
|
continue;
|
|
667
|
-
let
|
|
668
|
-
if (
|
|
667
|
+
let o = e.keyType._zod.run({ value: c, issues: [] }, s);
|
|
668
|
+
if (o instanceof Promise)
|
|
669
669
|
throw new Error("Async schemas not supported in object keys currently");
|
|
670
|
-
if (typeof
|
|
671
|
-
const l = e.keyType._zod.run({ value: Number(
|
|
670
|
+
if (typeof c == "string" && Ye.test(c) && o.issues.length) {
|
|
671
|
+
const l = e.keyType._zod.run({ value: Number(c), issues: [] }, s);
|
|
672
672
|
if (l instanceof Promise)
|
|
673
673
|
throw new Error("Async schemas not supported in object keys currently");
|
|
674
|
-
l.issues.length === 0 && (
|
|
674
|
+
l.issues.length === 0 && (o = l);
|
|
675
675
|
}
|
|
676
|
-
if (
|
|
677
|
-
e.mode === "loose" ? t.value[
|
|
676
|
+
if (o.issues.length) {
|
|
677
|
+
e.mode === "loose" ? t.value[c] = r[c] : t.issues.push({
|
|
678
678
|
code: "invalid_key",
|
|
679
679
|
origin: "record",
|
|
680
|
-
issues:
|
|
681
|
-
input:
|
|
682
|
-
path: [
|
|
680
|
+
issues: o.issues.map((l) => Y(l, s, K())),
|
|
681
|
+
input: c,
|
|
682
|
+
path: [c],
|
|
683
683
|
inst: n
|
|
684
684
|
});
|
|
685
685
|
continue;
|
|
686
686
|
}
|
|
687
|
-
const d = e.valueType._zod.run({ value: r[
|
|
687
|
+
const d = e.valueType._zod.run({ value: r[c], issues: [] }, s);
|
|
688
688
|
d instanceof Promise ? i.push(d.then((l) => {
|
|
689
|
-
l.issues.length && t.issues.push(...Z(
|
|
690
|
-
})) : (d.issues.length && t.issues.push(...Z(
|
|
689
|
+
l.issues.length && t.issues.push(...Z(c, l.issues)), t.value[o.value] = l.value;
|
|
690
|
+
})) : (d.issues.length && t.issues.push(...Z(c, d.issues)), t.value[o.value] = d.value);
|
|
691
691
|
}
|
|
692
692
|
}
|
|
693
693
|
return i.length ? Promise.all(i).then(() => t) : t;
|
|
694
694
|
};
|
|
695
|
-
}),
|
|
695
|
+
}), dt = /* @__PURE__ */ v("$ZodLiteral", (n, e) => {
|
|
696
696
|
if (U.init(n, e), e.values.length === 0)
|
|
697
697
|
throw new Error("Cannot create literal schema with no valid values");
|
|
698
698
|
const t = new Set(e.values);
|
|
@@ -705,10 +705,10 @@ const Qe = /* @__PURE__ */ v("$ZodUnion", (n, e) => {
|
|
|
705
705
|
inst: n
|
|
706
706
|
}), s;
|
|
707
707
|
};
|
|
708
|
-
}),
|
|
708
|
+
}), lt = /* @__PURE__ */ v("$ZodTransform", (n, e) => {
|
|
709
709
|
U.init(n, e), n._zod.parse = (t, s) => {
|
|
710
710
|
if (s.direction === "backward")
|
|
711
|
-
throw new
|
|
711
|
+
throw new Nn(n.constructor.name);
|
|
712
712
|
const r = e.transform(t.value, t);
|
|
713
713
|
if (s.async)
|
|
714
714
|
return (r instanceof Promise ? r : Promise.resolve(r)).then((a) => (t.value = a, t));
|
|
@@ -720,10 +720,10 @@ const Qe = /* @__PURE__ */ v("$ZodUnion", (n, e) => {
|
|
|
720
720
|
function Ee(n, e) {
|
|
721
721
|
return n.issues.length && e === void 0 ? { issues: [], value: void 0 } : n;
|
|
722
722
|
}
|
|
723
|
-
const
|
|
723
|
+
const ht = /* @__PURE__ */ v("$ZodOptional", (n, e) => {
|
|
724
724
|
U.init(n, e), n._zod.optin = "optional", n._zod.optout = "optional", I(n._zod, "values", () => e.innerType._zod.values ? /* @__PURE__ */ new Set([...e.innerType._zod.values, void 0]) : void 0), I(n._zod, "pattern", () => {
|
|
725
725
|
const t = e.innerType._zod.pattern;
|
|
726
|
-
return t ? new RegExp(`^(${
|
|
726
|
+
return t ? new RegExp(`^(${Ge(t.source)})?$`) : void 0;
|
|
727
727
|
}), n._zod.parse = (t, s) => {
|
|
728
728
|
if (e.innerType._zod.optin === "optional") {
|
|
729
729
|
const r = e.innerType._zod.run(t, s);
|
|
@@ -731,7 +731,7 @@ const lt = /* @__PURE__ */ v("$ZodOptional", (n, e) => {
|
|
|
731
731
|
}
|
|
732
732
|
return t.value === void 0 ? t : e.innerType._zod.run(t, s);
|
|
733
733
|
};
|
|
734
|
-
}),
|
|
734
|
+
}), ft = /* @__PURE__ */ v("$ZodDefault", (n, e) => {
|
|
735
735
|
U.init(n, e), n._zod.optin = "optional", I(n._zod, "values", () => e.innerType._zod.values), n._zod.parse = (t, s) => {
|
|
736
736
|
if (s.direction === "backward")
|
|
737
737
|
return e.innerType._zod.run(t, s);
|
|
@@ -744,7 +744,7 @@ const lt = /* @__PURE__ */ v("$ZodOptional", (n, e) => {
|
|
|
744
744
|
function Te(n, e) {
|
|
745
745
|
return n.value === void 0 && (n.value = e.defaultValue), n;
|
|
746
746
|
}
|
|
747
|
-
const
|
|
747
|
+
const mt = /* @__PURE__ */ v("$ZodPipe", (n, e) => {
|
|
748
748
|
U.init(n, e), I(n._zod, "values", () => e.in._zod.values), I(n._zod, "optin", () => e.in._zod.optin), I(n._zod, "optout", () => e.out._zod.optout), I(n._zod, "propValues", () => e.in._zod.propValues), n._zod.parse = (t, s) => {
|
|
749
749
|
if (s.direction === "backward") {
|
|
750
750
|
const i = e.out._zod.run(t, s);
|
|
@@ -758,7 +758,7 @@ function ue(n, e, t) {
|
|
|
758
758
|
return n.issues.length ? (n.aborted = !0, n) : e._zod.run({ value: n.value, issues: n.issues }, t);
|
|
759
759
|
}
|
|
760
760
|
var Ue;
|
|
761
|
-
class
|
|
761
|
+
class pt {
|
|
762
762
|
constructor() {
|
|
763
763
|
this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map();
|
|
764
764
|
}
|
|
@@ -787,223 +787,223 @@ class mt {
|
|
|
787
787
|
return this._map.has(e);
|
|
788
788
|
}
|
|
789
789
|
}
|
|
790
|
-
function
|
|
791
|
-
return new
|
|
790
|
+
function wt() {
|
|
791
|
+
return new pt();
|
|
792
792
|
}
|
|
793
|
-
(Ue = globalThis).__zod_globalRegistry ?? (Ue.__zod_globalRegistry =
|
|
793
|
+
(Ue = globalThis).__zod_globalRegistry ?? (Ue.__zod_globalRegistry = wt());
|
|
794
794
|
// @__NO_SIDE_EFFECTS__
|
|
795
|
-
function
|
|
795
|
+
function vt(n, e) {
|
|
796
796
|
return new n({
|
|
797
797
|
type: "string",
|
|
798
|
-
...
|
|
798
|
+
...P()
|
|
799
799
|
});
|
|
800
800
|
}
|
|
801
801
|
// @__NO_SIDE_EFFECTS__
|
|
802
|
-
function
|
|
802
|
+
function bt(n, e) {
|
|
803
803
|
return new n({
|
|
804
804
|
type: "number",
|
|
805
805
|
checks: [],
|
|
806
|
-
...
|
|
806
|
+
...P()
|
|
807
807
|
});
|
|
808
808
|
}
|
|
809
809
|
// @__NO_SIDE_EFFECTS__
|
|
810
|
-
function
|
|
810
|
+
function gt(n, e) {
|
|
811
811
|
return new n({
|
|
812
812
|
type: "number",
|
|
813
813
|
check: "number_format",
|
|
814
814
|
abort: !1,
|
|
815
815
|
format: "safeint",
|
|
816
|
-
...
|
|
816
|
+
...P()
|
|
817
817
|
});
|
|
818
818
|
}
|
|
819
819
|
// @__NO_SIDE_EFFECTS__
|
|
820
|
-
function
|
|
820
|
+
function yt(n, e) {
|
|
821
821
|
return new n({
|
|
822
822
|
type: "boolean",
|
|
823
|
-
...
|
|
823
|
+
...P()
|
|
824
824
|
});
|
|
825
825
|
}
|
|
826
826
|
// @__NO_SIDE_EFFECTS__
|
|
827
|
-
function
|
|
828
|
-
return new
|
|
827
|
+
function nn(n, e) {
|
|
828
|
+
return new Yn({
|
|
829
829
|
check: "less_than",
|
|
830
|
-
...
|
|
830
|
+
...P(),
|
|
831
831
|
value: n,
|
|
832
832
|
inclusive: !0
|
|
833
833
|
});
|
|
834
834
|
}
|
|
835
835
|
// @__NO_SIDE_EFFECTS__
|
|
836
|
-
function
|
|
837
|
-
return new
|
|
836
|
+
function _t(n, e) {
|
|
837
|
+
return new Jn({
|
|
838
838
|
check: "greater_than",
|
|
839
|
-
...
|
|
839
|
+
...P(),
|
|
840
840
|
value: n,
|
|
841
841
|
inclusive: !0
|
|
842
842
|
});
|
|
843
843
|
}
|
|
844
844
|
// @__NO_SIDE_EFFECTS__
|
|
845
|
-
function
|
|
846
|
-
return /* @__PURE__ */
|
|
845
|
+
function tn(n) {
|
|
846
|
+
return /* @__PURE__ */ _t(0);
|
|
847
847
|
}
|
|
848
|
-
const
|
|
848
|
+
const M = /* @__PURE__ */ v("ZodMiniType", (n, e) => {
|
|
849
849
|
if (!n._zod)
|
|
850
850
|
throw new Error("Uninitialized schema in ZodMiniType.");
|
|
851
|
-
U.init(n, e), n.def = e, n.type = e.type, n.parse = (t, s) =>
|
|
851
|
+
U.init(n, e), n.def = e, n.type = e.type, n.parse = (t, s) => $n(n, t, s, { callee: n.parse }), n.safeParse = (t, s) => We(n, t, s), n.parseAsync = async (t, s) => Gn(n, t, s, { callee: n.parseAsync }), n.safeParseAsync = async (t, s) => Ke(n, t, s), n.check = (...t) => n.clone({
|
|
852
852
|
...e,
|
|
853
853
|
checks: [
|
|
854
854
|
...e.checks ?? [],
|
|
855
855
|
...t.map((s) => typeof s == "function" ? { _zod: { check: s, def: { check: "custom" }, onattach: [] } } : s)
|
|
856
856
|
]
|
|
857
|
-
}, { parent: !0 }), n.with = n.check, n.clone = (t, s) =>
|
|
858
|
-
}),
|
|
859
|
-
|
|
857
|
+
}, { parent: !0 }), n.with = n.check, n.clone = (t, s) => Cn(n, t, s), n.brand = () => n, n.register = ((t, s) => (t.add(n, s), n)), n.apply = (t) => t(n);
|
|
858
|
+
}), St = /* @__PURE__ */ v("ZodMiniString", (n, e) => {
|
|
859
|
+
nt.init(n, e), M.init(n, e);
|
|
860
860
|
});
|
|
861
861
|
// @__NO_SIDE_EFFECTS__
|
|
862
862
|
function y(n) {
|
|
863
|
-
return /* @__PURE__ */
|
|
863
|
+
return /* @__PURE__ */ vt(St);
|
|
864
864
|
}
|
|
865
|
-
const
|
|
866
|
-
|
|
865
|
+
const sn = /* @__PURE__ */ v("ZodMiniNumber", (n, e) => {
|
|
866
|
+
Qe.init(n, e), M.init(n, e);
|
|
867
867
|
});
|
|
868
868
|
// @__NO_SIDE_EFFECTS__
|
|
869
869
|
function B(n) {
|
|
870
|
-
return /* @__PURE__ */
|
|
870
|
+
return /* @__PURE__ */ bt(sn);
|
|
871
871
|
}
|
|
872
|
-
const
|
|
873
|
-
|
|
872
|
+
const kt = /* @__PURE__ */ v("ZodMiniNumberFormat", (n, e) => {
|
|
873
|
+
tt.init(n, e), sn.init(n, e);
|
|
874
874
|
});
|
|
875
875
|
// @__NO_SIDE_EFFECTS__
|
|
876
|
-
function
|
|
877
|
-
return /* @__PURE__ */
|
|
876
|
+
function rn(n) {
|
|
877
|
+
return /* @__PURE__ */ gt(kt);
|
|
878
878
|
}
|
|
879
|
-
const
|
|
880
|
-
|
|
879
|
+
const At = /* @__PURE__ */ v("ZodMiniBoolean", (n, e) => {
|
|
880
|
+
st.init(n, e), M.init(n, e);
|
|
881
881
|
});
|
|
882
882
|
// @__NO_SIDE_EFFECTS__
|
|
883
|
-
function
|
|
884
|
-
return /* @__PURE__ */
|
|
883
|
+
function an(n) {
|
|
884
|
+
return /* @__PURE__ */ yt(At);
|
|
885
885
|
}
|
|
886
|
-
const
|
|
887
|
-
|
|
886
|
+
const It = /* @__PURE__ */ v("ZodMiniArray", (n, e) => {
|
|
887
|
+
rt.init(n, e), M.init(n, e);
|
|
888
888
|
});
|
|
889
889
|
// @__NO_SIDE_EFFECTS__
|
|
890
890
|
function j(n, e) {
|
|
891
|
-
return new
|
|
891
|
+
return new It({
|
|
892
892
|
type: "array",
|
|
893
893
|
element: n,
|
|
894
|
-
...
|
|
894
|
+
...P()
|
|
895
895
|
});
|
|
896
896
|
}
|
|
897
|
-
const
|
|
898
|
-
|
|
897
|
+
const Rt = /* @__PURE__ */ v("ZodMiniObject", (n, e) => {
|
|
898
|
+
ot.init(n, e), M.init(n, e), I(n, "shape", () => e.shape);
|
|
899
899
|
});
|
|
900
900
|
// @__NO_SIDE_EFFECTS__
|
|
901
901
|
function S(n, e) {
|
|
902
902
|
const t = {
|
|
903
903
|
type: "object",
|
|
904
904
|
shape: n ?? {},
|
|
905
|
-
...
|
|
905
|
+
...P()
|
|
906
906
|
};
|
|
907
|
-
return new
|
|
907
|
+
return new Rt(t);
|
|
908
908
|
}
|
|
909
|
-
const
|
|
910
|
-
|
|
909
|
+
const Et = /* @__PURE__ */ v("ZodMiniUnion", (n, e) => {
|
|
910
|
+
en.init(n, e), M.init(n, e);
|
|
911
911
|
});
|
|
912
912
|
// @__NO_SIDE_EFFECTS__
|
|
913
|
-
function
|
|
914
|
-
return new
|
|
913
|
+
function on(n, e) {
|
|
914
|
+
return new Et({
|
|
915
915
|
type: "union",
|
|
916
916
|
options: n,
|
|
917
|
-
...
|
|
917
|
+
...P()
|
|
918
918
|
});
|
|
919
919
|
}
|
|
920
|
-
const
|
|
921
|
-
|
|
920
|
+
const Tt = /* @__PURE__ */ v("ZodMiniDiscriminatedUnion", (n, e) => {
|
|
921
|
+
ct.init(n, e), M.init(n, e);
|
|
922
922
|
});
|
|
923
923
|
// @__NO_SIDE_EFFECTS__
|
|
924
|
-
function
|
|
925
|
-
return new
|
|
924
|
+
function Ut(n, e, t) {
|
|
925
|
+
return new Tt({
|
|
926
926
|
type: "union",
|
|
927
927
|
options: e,
|
|
928
928
|
discriminator: n,
|
|
929
|
-
...
|
|
929
|
+
...P()
|
|
930
930
|
});
|
|
931
931
|
}
|
|
932
|
-
const
|
|
933
|
-
|
|
932
|
+
const Mt = /* @__PURE__ */ v("ZodMiniRecord", (n, e) => {
|
|
933
|
+
ut.init(n, e), M.init(n, e);
|
|
934
934
|
});
|
|
935
935
|
// @__NO_SIDE_EFFECTS__
|
|
936
936
|
function ge(n, e, t) {
|
|
937
|
-
return new
|
|
937
|
+
return new Mt({
|
|
938
938
|
type: "record",
|
|
939
939
|
keyType: n,
|
|
940
940
|
valueType: e,
|
|
941
|
-
...
|
|
941
|
+
...P()
|
|
942
942
|
});
|
|
943
943
|
}
|
|
944
944
|
const Pt = /* @__PURE__ */ v("ZodMiniLiteral", (n, e) => {
|
|
945
|
-
|
|
945
|
+
dt.init(n, e), M.init(n, e);
|
|
946
946
|
});
|
|
947
947
|
// @__NO_SIDE_EFFECTS__
|
|
948
|
-
function
|
|
948
|
+
function Me(n, e) {
|
|
949
949
|
return new Pt({
|
|
950
950
|
type: "literal",
|
|
951
951
|
values: Array.isArray(n) ? n : [n],
|
|
952
|
-
...
|
|
952
|
+
...P()
|
|
953
953
|
});
|
|
954
954
|
}
|
|
955
|
-
const
|
|
956
|
-
|
|
955
|
+
const Ot = /* @__PURE__ */ v("ZodMiniTransform", (n, e) => {
|
|
956
|
+
lt.init(n, e), M.init(n, e);
|
|
957
957
|
});
|
|
958
958
|
// @__NO_SIDE_EFFECTS__
|
|
959
|
-
function
|
|
960
|
-
return new
|
|
959
|
+
function cn(n) {
|
|
960
|
+
return new Ot({
|
|
961
961
|
type: "transform",
|
|
962
962
|
transform: n
|
|
963
963
|
});
|
|
964
964
|
}
|
|
965
|
-
const
|
|
966
|
-
|
|
965
|
+
const zt = /* @__PURE__ */ v("ZodMiniOptional", (n, e) => {
|
|
966
|
+
ht.init(n, e), M.init(n, e);
|
|
967
967
|
});
|
|
968
968
|
// @__NO_SIDE_EFFECTS__
|
|
969
969
|
function m(n) {
|
|
970
|
-
return new
|
|
970
|
+
return new zt({
|
|
971
971
|
type: "optional",
|
|
972
972
|
innerType: n
|
|
973
973
|
});
|
|
974
974
|
}
|
|
975
|
-
const
|
|
976
|
-
|
|
975
|
+
const Nt = /* @__PURE__ */ v("ZodMiniDefault", (n, e) => {
|
|
976
|
+
ft.init(n, e), M.init(n, e);
|
|
977
977
|
});
|
|
978
978
|
// @__NO_SIDE_EFFECTS__
|
|
979
|
-
function
|
|
980
|
-
return new
|
|
979
|
+
function qt(n, e) {
|
|
980
|
+
return new Nt({
|
|
981
981
|
type: "default",
|
|
982
982
|
innerType: n,
|
|
983
983
|
get defaultValue() {
|
|
984
|
-
return typeof e == "function" ? e() :
|
|
984
|
+
return typeof e == "function" ? e() : xn(e);
|
|
985
985
|
}
|
|
986
986
|
});
|
|
987
987
|
}
|
|
988
|
-
const
|
|
989
|
-
|
|
988
|
+
const Dt = /* @__PURE__ */ v("ZodMiniPipe", (n, e) => {
|
|
989
|
+
mt.init(n, e), M.init(n, e);
|
|
990
990
|
});
|
|
991
991
|
// @__NO_SIDE_EFFECTS__
|
|
992
|
-
function
|
|
993
|
-
return new
|
|
992
|
+
function un(n, e) {
|
|
993
|
+
return new Dt({
|
|
994
994
|
type: "pipe",
|
|
995
995
|
in: n,
|
|
996
996
|
out: e
|
|
997
997
|
});
|
|
998
998
|
}
|
|
999
|
-
(/* @__PURE__ */ B()).check(/* @__PURE__ */
|
|
1000
|
-
const E = (/* @__PURE__ */ B()).check(/* @__PURE__ */
|
|
1001
|
-
/* @__PURE__ */
|
|
999
|
+
(/* @__PURE__ */ B()).check(/* @__PURE__ */ rn(), /* @__PURE__ */ tn(), /* @__PURE__ */ nn(255)).brand("u8");
|
|
1000
|
+
const E = (/* @__PURE__ */ B()).check(/* @__PURE__ */ rn(), /* @__PURE__ */ tn(), /* @__PURE__ */ nn(Number.MAX_SAFE_INTEGER)).brand("u53"), dn = /* @__PURE__ */ qt(
|
|
1001
|
+
/* @__PURE__ */ Ut("kind", [
|
|
1002
1002
|
// The default hang container
|
|
1003
|
-
/* @__PURE__ */ S({ kind: /* @__PURE__ */
|
|
1003
|
+
/* @__PURE__ */ S({ kind: /* @__PURE__ */ Me("legacy") }),
|
|
1004
1004
|
// CMAF container with timescale for timestamp conversion
|
|
1005
1005
|
/* @__PURE__ */ S({
|
|
1006
|
-
kind: /* @__PURE__ */
|
|
1006
|
+
kind: /* @__PURE__ */ Me("cmaf"),
|
|
1007
1007
|
// Time units per second
|
|
1008
1008
|
timescale: E,
|
|
1009
1009
|
// Track ID used in the moof/mdat fragments
|
|
@@ -1011,13 +1011,13 @@ const E = (/* @__PURE__ */ B()).check(/* @__PURE__ */ sn(), /* @__PURE__ */ nn()
|
|
|
1011
1011
|
})
|
|
1012
1012
|
]),
|
|
1013
1013
|
{ kind: "legacy" }
|
|
1014
|
-
),
|
|
1014
|
+
), xt = /* @__PURE__ */ S({
|
|
1015
1015
|
name: /* @__PURE__ */ y()
|
|
1016
|
-
}),
|
|
1016
|
+
}), Pe = /* @__PURE__ */ S({
|
|
1017
1017
|
// See: https://w3c.github.io/webcodecs/codec_registry.html
|
|
1018
1018
|
codec: /* @__PURE__ */ y(),
|
|
1019
1019
|
// The container format, used to decode the timestamp and more.
|
|
1020
|
-
container:
|
|
1020
|
+
container: dn,
|
|
1021
1021
|
// The description is used for some codecs.
|
|
1022
1022
|
// If provided, we can initialize the decoder based on the catalog alone.
|
|
1023
1023
|
// Otherwise, the initialization information is in-band.
|
|
@@ -1037,39 +1037,39 @@ const E = (/* @__PURE__ */ B()).check(/* @__PURE__ */ sn(), /* @__PURE__ */ nn()
|
|
|
1037
1037
|
// NOTE: The audio "frame" duration depends on the codec, sample rate, etc.
|
|
1038
1038
|
// ex: AAC often uses 1024 samples per frame, so at 44100Hz, this would be 1024/44100 = 23ms
|
|
1039
1039
|
jitter: /* @__PURE__ */ m(E)
|
|
1040
|
-
}),
|
|
1040
|
+
}), Ct = /* @__PURE__ */ on([
|
|
1041
1041
|
/* @__PURE__ */ S({
|
|
1042
1042
|
// A map of track name to rendition configuration.
|
|
1043
1043
|
// This is not an array so it will work with JSON Merge Patch.
|
|
1044
|
-
renditions: /* @__PURE__ */ ge(/* @__PURE__ */ y(),
|
|
1044
|
+
renditions: /* @__PURE__ */ ge(/* @__PURE__ */ y(), Pe)
|
|
1045
1045
|
}),
|
|
1046
1046
|
// Backwards compatibility: transform old {track, config} format to new object format
|
|
1047
|
-
/* @__PURE__ */
|
|
1047
|
+
/* @__PURE__ */ un(
|
|
1048
1048
|
/* @__PURE__ */ S({
|
|
1049
|
-
track:
|
|
1050
|
-
config:
|
|
1049
|
+
track: xt,
|
|
1050
|
+
config: Pe
|
|
1051
1051
|
}),
|
|
1052
|
-
/* @__PURE__ */
|
|
1052
|
+
/* @__PURE__ */ cn((n) => ({
|
|
1053
1053
|
renditions: { [n.track.name]: n.config }
|
|
1054
1054
|
}))
|
|
1055
1055
|
)
|
|
1056
|
-
]),
|
|
1056
|
+
]), Ft = /* @__PURE__ */ S({
|
|
1057
1057
|
hardware: /* @__PURE__ */ m(/* @__PURE__ */ j(/* @__PURE__ */ y())),
|
|
1058
1058
|
software: /* @__PURE__ */ m(/* @__PURE__ */ j(/* @__PURE__ */ y())),
|
|
1059
1059
|
unsupported: /* @__PURE__ */ m(/* @__PURE__ */ j(/* @__PURE__ */ y()))
|
|
1060
|
-
}),
|
|
1060
|
+
}), Vt = /* @__PURE__ */ S({
|
|
1061
1061
|
hardware: /* @__PURE__ */ m(/* @__PURE__ */ j(/* @__PURE__ */ y())),
|
|
1062
1062
|
software: /* @__PURE__ */ m(/* @__PURE__ */ j(/* @__PURE__ */ y())),
|
|
1063
1063
|
unsupported: /* @__PURE__ */ m(/* @__PURE__ */ j(/* @__PURE__ */ y()))
|
|
1064
|
-
}),
|
|
1065
|
-
video: /* @__PURE__ */ m(
|
|
1066
|
-
audio: /* @__PURE__ */ m(
|
|
1064
|
+
}), Bt = /* @__PURE__ */ S({
|
|
1065
|
+
video: /* @__PURE__ */ m(Ft),
|
|
1066
|
+
audio: /* @__PURE__ */ m(Vt)
|
|
1067
1067
|
}), re = /* @__PURE__ */ S({
|
|
1068
1068
|
name: /* @__PURE__ */ y()
|
|
1069
|
-
}),
|
|
1069
|
+
}), Lt = /* @__PURE__ */ S({
|
|
1070
1070
|
message: /* @__PURE__ */ m(re),
|
|
1071
1071
|
typing: /* @__PURE__ */ m(re)
|
|
1072
|
-
}),
|
|
1072
|
+
}), ln = /* @__PURE__ */ S({
|
|
1073
1073
|
// The relative X position of the broadcast, from -1 to +1.
|
|
1074
1074
|
// This should be used for audio panning but can also be used for video positioning.
|
|
1075
1075
|
x: /* @__PURE__ */ m(/* @__PURE__ */ B()),
|
|
@@ -1081,11 +1081,11 @@ const E = (/* @__PURE__ */ B()).check(/* @__PURE__ */ sn(), /* @__PURE__ */ nn()
|
|
|
1081
1081
|
z: /* @__PURE__ */ m(/* @__PURE__ */ B()),
|
|
1082
1082
|
// The scale of the broadcast, where 1 is 100%
|
|
1083
1083
|
s: /* @__PURE__ */ m(/* @__PURE__ */ B())
|
|
1084
|
-
}),
|
|
1084
|
+
}), $t = /* @__PURE__ */ S({
|
|
1085
1085
|
// The initial position of the broadcaster, from -1 to +1 in both dimensions.
|
|
1086
1086
|
// If not provided, then the broadcaster is assumed to be at (0,0)
|
|
1087
1087
|
// This should be used for audio panning but can also be used for video positioning.
|
|
1088
|
-
initial: /* @__PURE__ */ m(
|
|
1088
|
+
initial: /* @__PURE__ */ m(ln),
|
|
1089
1089
|
// If provided, then updates to the position are done via a separate Moq track.
|
|
1090
1090
|
// This is used to avoid a full catalog update every time we want to update a few bytes.
|
|
1091
1091
|
// TODO: These updates currently use JSON for simplicity, but we should use a binary format.
|
|
@@ -1096,7 +1096,7 @@ const E = (/* @__PURE__ */ B()).check(/* @__PURE__ */ sn(), /* @__PURE__ */ nn()
|
|
|
1096
1096
|
// If provided, this broadcaster is signaling the location of other peers.
|
|
1097
1097
|
// The payload is a JSON blob keyed by handle for each peer.
|
|
1098
1098
|
peers: /* @__PURE__ */ m(re)
|
|
1099
|
-
}),
|
|
1099
|
+
}), vr = /* @__PURE__ */ ge(/* @__PURE__ */ y(), ln), W = {
|
|
1100
1100
|
catalog: 100,
|
|
1101
1101
|
chat: 90,
|
|
1102
1102
|
audio: 80,
|
|
@@ -1104,19 +1104,19 @@ const E = (/* @__PURE__ */ B()).check(/* @__PURE__ */ sn(), /* @__PURE__ */ nn()
|
|
|
1104
1104
|
typing: 40,
|
|
1105
1105
|
location: 20,
|
|
1106
1106
|
preview: 10
|
|
1107
|
-
},
|
|
1107
|
+
}, jt = /* @__PURE__ */ S({
|
|
1108
1108
|
id: /* @__PURE__ */ m(/* @__PURE__ */ y()),
|
|
1109
1109
|
name: /* @__PURE__ */ m(/* @__PURE__ */ y()),
|
|
1110
1110
|
avatar: /* @__PURE__ */ m(/* @__PURE__ */ y()),
|
|
1111
1111
|
// TODO allow using a track instead of a URL?
|
|
1112
1112
|
color: /* @__PURE__ */ m(/* @__PURE__ */ y())
|
|
1113
|
-
}),
|
|
1113
|
+
}), Gt = /* @__PURE__ */ S({
|
|
1114
1114
|
name: /* @__PURE__ */ y()
|
|
1115
1115
|
}), Oe = /* @__PURE__ */ S({
|
|
1116
1116
|
// See: https://w3c.github.io/webcodecs/codec_registry.html
|
|
1117
1117
|
codec: /* @__PURE__ */ y(),
|
|
1118
1118
|
// The container format, used to decode the timestamp and more.
|
|
1119
|
-
container:
|
|
1119
|
+
container: dn,
|
|
1120
1120
|
// The description is used for some codecs.
|
|
1121
1121
|
// If provided, we can initialize the decoder based on the catalog alone.
|
|
1122
1122
|
// Otherwise, the initialization information is (repeated) before each key-frame.
|
|
@@ -1138,7 +1138,7 @@ const E = (/* @__PURE__ */ B()).check(/* @__PURE__ */ sn(), /* @__PURE__ */ nn()
|
|
|
1138
1138
|
bitrate: /* @__PURE__ */ m(E),
|
|
1139
1139
|
// If true, the decoder will optimize for latency.
|
|
1140
1140
|
// Default: true
|
|
1141
|
-
optimizeForLatency: /* @__PURE__ */ m(/* @__PURE__ */
|
|
1141
|
+
optimizeForLatency: /* @__PURE__ */ m(/* @__PURE__ */ an()),
|
|
1142
1142
|
// The maximum jitter before the next frame is emitted in milliseconds.
|
|
1143
1143
|
// The player's jitter buffer should be larger than this value.
|
|
1144
1144
|
// If not provided, the player should assume each frame is flushed immediately.
|
|
@@ -1148,7 +1148,7 @@ const E = (/* @__PURE__ */ B()).check(/* @__PURE__ */ sn(), /* @__PURE__ */ nn()
|
|
|
1148
1148
|
// - If there can be up to 3 b-frames in a row, this would be 3 * 1000/fps.
|
|
1149
1149
|
// - If frames are buffered into 2s segments, this would be 2s.
|
|
1150
1150
|
jitter: /* @__PURE__ */ m(E)
|
|
1151
|
-
}),
|
|
1151
|
+
}), Zt = /* @__PURE__ */ on([
|
|
1152
1152
|
/* @__PURE__ */ S({
|
|
1153
1153
|
// A map of track name to rendition configuration.
|
|
1154
1154
|
// This is not an array in order for it to work with JSON Merge Patch.
|
|
@@ -1166,17 +1166,17 @@ const E = (/* @__PURE__ */ B()).check(/* @__PURE__ */ sn(), /* @__PURE__ */ nn()
|
|
|
1166
1166
|
rotation: /* @__PURE__ */ m(/* @__PURE__ */ B()),
|
|
1167
1167
|
// If true, the decoder will flip the video horizontally
|
|
1168
1168
|
// Default: false
|
|
1169
|
-
flip: /* @__PURE__ */ m(/* @__PURE__ */
|
|
1169
|
+
flip: /* @__PURE__ */ m(/* @__PURE__ */ an())
|
|
1170
1170
|
}),
|
|
1171
1171
|
// Backwards compatibility: transform old array of {track, config} to new object format
|
|
1172
|
-
/* @__PURE__ */
|
|
1172
|
+
/* @__PURE__ */ un(
|
|
1173
1173
|
/* @__PURE__ */ j(
|
|
1174
1174
|
/* @__PURE__ */ S({
|
|
1175
|
-
track:
|
|
1175
|
+
track: Gt,
|
|
1176
1176
|
config: Oe
|
|
1177
1177
|
})
|
|
1178
1178
|
),
|
|
1179
|
-
/* @__PURE__ */
|
|
1179
|
+
/* @__PURE__ */ cn((n) => {
|
|
1180
1180
|
const e = n[0]?.config;
|
|
1181
1181
|
return {
|
|
1182
1182
|
renditions: Object.fromEntries(n.map((t) => [t.track.name, t.config])),
|
|
@@ -1186,36 +1186,36 @@ const E = (/* @__PURE__ */ B()).check(/* @__PURE__ */ sn(), /* @__PURE__ */ nn()
|
|
|
1186
1186
|
};
|
|
1187
1187
|
})
|
|
1188
1188
|
)
|
|
1189
|
-
]),
|
|
1190
|
-
video: /* @__PURE__ */ m(
|
|
1191
|
-
audio: /* @__PURE__ */ m(
|
|
1192
|
-
location: /* @__PURE__ */ m(
|
|
1193
|
-
user: /* @__PURE__ */ m(
|
|
1194
|
-
chat: /* @__PURE__ */ m(
|
|
1195
|
-
capabilities: /* @__PURE__ */ m(
|
|
1189
|
+
]), Xt = /* @__PURE__ */ S({
|
|
1190
|
+
video: /* @__PURE__ */ m(Zt),
|
|
1191
|
+
audio: /* @__PURE__ */ m(Ct),
|
|
1192
|
+
location: /* @__PURE__ */ m($t),
|
|
1193
|
+
user: /* @__PURE__ */ m(jt),
|
|
1194
|
+
chat: /* @__PURE__ */ m(Lt),
|
|
1195
|
+
capabilities: /* @__PURE__ */ m(Bt),
|
|
1196
1196
|
preview: /* @__PURE__ */ m(re)
|
|
1197
1197
|
});
|
|
1198
|
-
function
|
|
1198
|
+
function Ht(n) {
|
|
1199
1199
|
const t = new TextDecoder().decode(n);
|
|
1200
1200
|
try {
|
|
1201
1201
|
const s = JSON.parse(t);
|
|
1202
|
-
return
|
|
1202
|
+
return Xt.parse(s);
|
|
1203
1203
|
} catch (s) {
|
|
1204
1204
|
throw console.warn("invalid catalog", t), s;
|
|
1205
1205
|
}
|
|
1206
1206
|
}
|
|
1207
|
-
async function
|
|
1207
|
+
async function Wt(n) {
|
|
1208
1208
|
const e = await n.readFrame();
|
|
1209
1209
|
if (e)
|
|
1210
|
-
return
|
|
1210
|
+
return Ht(e);
|
|
1211
1211
|
}
|
|
1212
|
-
function
|
|
1212
|
+
function hn(n) {
|
|
1213
1213
|
return n instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && n instanceof SharedArrayBuffer;
|
|
1214
1214
|
}
|
|
1215
|
-
const
|
|
1216
|
-
function
|
|
1215
|
+
const Kt = "utf-16", pe = "utf-16be", ze = "utf-16le", te = "utf-8";
|
|
1216
|
+
function fn(n, e = {}) {
|
|
1217
1217
|
let t;
|
|
1218
|
-
|
|
1218
|
+
hn(n) ? t = new DataView(n) : t = new DataView(n.buffer, n.byteOffset, n.byteLength);
|
|
1219
1219
|
let s = 0, { encoding: r } = e;
|
|
1220
1220
|
if (!r) {
|
|
1221
1221
|
const u = t.getUint8(0), d = t.getUint8(1);
|
|
@@ -1223,42 +1223,42 @@ function hn(n, e = {}) {
|
|
|
1223
1223
|
}
|
|
1224
1224
|
if (typeof TextDecoder < "u") return new TextDecoder(r).decode(t);
|
|
1225
1225
|
const { byteLength: i } = t, a = r !== pe;
|
|
1226
|
-
let
|
|
1226
|
+
let c = "", o;
|
|
1227
1227
|
for (; s < i; ) {
|
|
1228
1228
|
switch (r) {
|
|
1229
1229
|
case te:
|
|
1230
|
-
if (
|
|
1231
|
-
else if (
|
|
1230
|
+
if (o = t.getUint8(s), o < 128) s++;
|
|
1231
|
+
else if (o >= 194 && o <= 223) if (s + 1 < i) {
|
|
1232
1232
|
const u = t.getUint8(s + 1);
|
|
1233
|
-
u >= 128 && u <= 191 ? (
|
|
1233
|
+
u >= 128 && u <= 191 ? (o = (o & 31) << 6 | u & 63, s += 2) : s++;
|
|
1234
1234
|
} else s++;
|
|
1235
|
-
else if (
|
|
1235
|
+
else if (o >= 224 && o <= 239) if (s + 2 <= i - 1) {
|
|
1236
1236
|
const u = t.getUint8(s + 1), d = t.getUint8(s + 2);
|
|
1237
|
-
u >= 128 && u <= 191 && d >= 128 && d <= 191 ? (
|
|
1237
|
+
u >= 128 && u <= 191 && d >= 128 && d <= 191 ? (o = (o & 15) << 12 | (u & 63) << 6 | d & 63, s += 3) : s++;
|
|
1238
1238
|
} else s++;
|
|
1239
|
-
else if (
|
|
1239
|
+
else if (o >= 240 && o <= 244) if (s + 3 <= i - 1) {
|
|
1240
1240
|
const u = t.getUint8(s + 1), d = t.getUint8(s + 2), l = t.getUint8(s + 3);
|
|
1241
|
-
u >= 128 && u <= 191 && d >= 128 && d <= 191 && l >= 128 && l <= 191 ? (
|
|
1241
|
+
u >= 128 && u <= 191 && d >= 128 && d <= 191 && l >= 128 && l <= 191 ? (o = (o & 7) << 18 | (u & 63) << 12 | (d & 63) << 6 | l & 63, s += 4) : s++;
|
|
1242
1242
|
} else s++;
|
|
1243
1243
|
else s++;
|
|
1244
1244
|
break;
|
|
1245
1245
|
case pe:
|
|
1246
|
-
case
|
|
1246
|
+
case Kt:
|
|
1247
1247
|
case ze:
|
|
1248
|
-
|
|
1248
|
+
o = t.getUint16(s, a), s += 2;
|
|
1249
1249
|
break;
|
|
1250
1250
|
}
|
|
1251
|
-
|
|
1251
|
+
c += String.fromCodePoint(o);
|
|
1252
1252
|
}
|
|
1253
|
-
return
|
|
1253
|
+
return c;
|
|
1254
1254
|
}
|
|
1255
|
-
function
|
|
1255
|
+
function Yt(n) {
|
|
1256
1256
|
return new TextEncoder().encode(n);
|
|
1257
1257
|
}
|
|
1258
|
-
function
|
|
1258
|
+
function Jt(n) {
|
|
1259
1259
|
return { writers: n?.writers ?? {} };
|
|
1260
1260
|
}
|
|
1261
|
-
const
|
|
1261
|
+
const Qt = [
|
|
1262
1262
|
"dinf",
|
|
1263
1263
|
"edts",
|
|
1264
1264
|
"grpl",
|
|
@@ -1279,8 +1279,8 @@ const Jt = [
|
|
|
1279
1279
|
"udta",
|
|
1280
1280
|
"vttc"
|
|
1281
1281
|
];
|
|
1282
|
-
function
|
|
1283
|
-
return "boxes" in n ||
|
|
1282
|
+
function mn(n) {
|
|
1283
|
+
return "boxes" in n || Qt.includes(n.type);
|
|
1284
1284
|
}
|
|
1285
1285
|
const Ne = "utf8", L = "uint", ie = "template", qe = "string", De = "int", xe = "data";
|
|
1286
1286
|
var A = class {
|
|
@@ -1300,16 +1300,16 @@ var A = class {
|
|
|
1300
1300
|
r.setUint16(i, t);
|
|
1301
1301
|
break;
|
|
1302
1302
|
case 3: {
|
|
1303
|
-
const a = (t & 16776960) >> 8,
|
|
1304
|
-
r.setUint16(i, a), r.setUint8(i + 2,
|
|
1303
|
+
const a = (t & 16776960) >> 8, c = t & 255;
|
|
1304
|
+
r.setUint16(i, a), r.setUint8(i + 2, c);
|
|
1305
1305
|
break;
|
|
1306
1306
|
}
|
|
1307
1307
|
case 4:
|
|
1308
1308
|
r.setUint32(i, t);
|
|
1309
1309
|
break;
|
|
1310
1310
|
case 8: {
|
|
1311
|
-
const a = Math.floor(t / Math.pow(2, 32)),
|
|
1312
|
-
r.setUint32(i, a), r.setUint32(i + 4,
|
|
1311
|
+
const a = Math.floor(t / Math.pow(2, 32)), c = t - a * Math.pow(2, 32);
|
|
1312
|
+
r.setUint32(i, a), r.setUint32(i + 4, c);
|
|
1313
1313
|
break;
|
|
1314
1314
|
}
|
|
1315
1315
|
}
|
|
@@ -1327,8 +1327,8 @@ var A = class {
|
|
|
1327
1327
|
r.setInt32(i, t);
|
|
1328
1328
|
break;
|
|
1329
1329
|
case 8:
|
|
1330
|
-
const a = Math.floor(t / Math.pow(2, 32)),
|
|
1331
|
-
r.setUint32(i, a), r.setUint32(i + 4,
|
|
1330
|
+
const a = Math.floor(t / Math.pow(2, 32)), c = t - a * Math.pow(2, 32);
|
|
1331
|
+
r.setUint32(i, a), r.setUint32(i + 4, c);
|
|
1332
1332
|
break;
|
|
1333
1333
|
}
|
|
1334
1334
|
this.cursor += s;
|
|
@@ -1340,7 +1340,7 @@ var A = class {
|
|
|
1340
1340
|
this.writeUint(0, 1);
|
|
1341
1341
|
}
|
|
1342
1342
|
}, this.writeUtf8TerminatedString = (t) => {
|
|
1343
|
-
const s =
|
|
1343
|
+
const s = Yt(t);
|
|
1344
1344
|
new Uint8Array(this.dataView.buffer).set(s, this.cursor), this.cursor += s.length, this.writeUint(0, 1);
|
|
1345
1345
|
}, this.writeBytes = (t) => {
|
|
1346
1346
|
Array.isArray(t) || (t = [t]);
|
|
@@ -1348,7 +1348,7 @@ var A = class {
|
|
|
1348
1348
|
new Uint8Array(this.dataView.buffer).set(s, this.cursor), this.cursor += s.length;
|
|
1349
1349
|
}, this.writeArray = (t, s, r, i) => {
|
|
1350
1350
|
const a = s === L ? this.writeUint : s === ie ? this.writeTemplate : this.writeInt;
|
|
1351
|
-
for (let
|
|
1351
|
+
for (let c = 0; c < i; c++) a(t[c] ?? 0, r);
|
|
1352
1352
|
}, this.writeTemplate = (t, s) => {
|
|
1353
1353
|
const i = Math.round(t * Math.pow(2, s === 4 ? 16 : 8));
|
|
1354
1354
|
this.writeUint(i, s);
|
|
@@ -1390,34 +1390,34 @@ var A = class {
|
|
|
1390
1390
|
this.writeUint(n, 1), this.writeUint(e, 3);
|
|
1391
1391
|
}
|
|
1392
1392
|
};
|
|
1393
|
-
function
|
|
1394
|
-
return Array.from(n, (t) =>
|
|
1393
|
+
function pn(n, e) {
|
|
1394
|
+
return Array.from(n, (t) => ns(t, e));
|
|
1395
1395
|
}
|
|
1396
1396
|
function ye(n, e) {
|
|
1397
|
-
const t =
|
|
1397
|
+
const t = pn(n, e);
|
|
1398
1398
|
return {
|
|
1399
1399
|
bytes: t,
|
|
1400
1400
|
size: t.reduce((s, r) => s + r.byteLength, 0)
|
|
1401
1401
|
};
|
|
1402
1402
|
}
|
|
1403
|
-
function
|
|
1403
|
+
function es(n, e) {
|
|
1404
1404
|
const { bytes: s, size: r } = ye(n.boxes, e), i = 8 + r, a = new A(n.type, i);
|
|
1405
1405
|
return a.writeBytes(s), a;
|
|
1406
1406
|
}
|
|
1407
|
-
function
|
|
1407
|
+
function ns(n, e) {
|
|
1408
1408
|
let t = null;
|
|
1409
1409
|
if ("type" in n) {
|
|
1410
1410
|
const { type: s } = n, r = e.writers?.[s];
|
|
1411
|
-
if (r ? t = r(n, e) :
|
|
1411
|
+
if (r ? t = r(n, e) : mn(n) ? t = es(n, e) : "view" in n && (t = n.view), !t) throw new Error(`No writer found for box type: ${s}`);
|
|
1412
1412
|
}
|
|
1413
1413
|
if ("buffer" in n && (t = n), !t) throw new Error("Invalid box");
|
|
1414
1414
|
return new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
|
|
1415
1415
|
}
|
|
1416
|
-
function
|
|
1416
|
+
function ts(n, e, t) {
|
|
1417
1417
|
const s = t > 0 ? t : n.byteLength - (e - n.byteOffset);
|
|
1418
1418
|
return new Uint8Array(n.buffer, e, Math.max(s, 0));
|
|
1419
1419
|
}
|
|
1420
|
-
function
|
|
1420
|
+
function ss(n, e, t) {
|
|
1421
1421
|
let s = NaN;
|
|
1422
1422
|
const r = e - n.byteOffset;
|
|
1423
1423
|
switch (t) {
|
|
@@ -1467,11 +1467,11 @@ function Ce(n, e, t) {
|
|
|
1467
1467
|
}
|
|
1468
1468
|
return s;
|
|
1469
1469
|
}
|
|
1470
|
-
function
|
|
1470
|
+
function rs(n, e, t) {
|
|
1471
1471
|
const s = t / 2;
|
|
1472
1472
|
return G(n, e, s) + G(n, e + s, s) / Math.pow(2, s);
|
|
1473
1473
|
}
|
|
1474
|
-
function
|
|
1474
|
+
function is(n, e) {
|
|
1475
1475
|
let t = "", s = e;
|
|
1476
1476
|
for (; s - n.byteOffset < n.byteLength; ) {
|
|
1477
1477
|
const r = G(n, s, 1);
|
|
@@ -1480,22 +1480,22 @@ function rs(n, e) {
|
|
|
1480
1480
|
}
|
|
1481
1481
|
return t;
|
|
1482
1482
|
}
|
|
1483
|
-
function
|
|
1483
|
+
function as(n, e) {
|
|
1484
1484
|
const t = n.byteLength - (e - n.byteOffset);
|
|
1485
|
-
return t > 0 ?
|
|
1485
|
+
return t > 0 ? fn(new DataView(n.buffer, e, t), { encoding: te }) : "";
|
|
1486
1486
|
}
|
|
1487
|
-
function
|
|
1487
|
+
function os(n, e) {
|
|
1488
1488
|
const t = n.byteLength - (e - n.byteOffset);
|
|
1489
1489
|
let s = "";
|
|
1490
1490
|
if (t > 0) {
|
|
1491
1491
|
const r = new DataView(n.buffer, e, t);
|
|
1492
1492
|
let i = 0;
|
|
1493
1493
|
for (; i < t && r.getUint8(i) !== 0; i++) ;
|
|
1494
|
-
s =
|
|
1494
|
+
s = fn(new DataView(n.buffer, e, i), { encoding: te });
|
|
1495
1495
|
}
|
|
1496
1496
|
return s;
|
|
1497
1497
|
}
|
|
1498
|
-
var
|
|
1498
|
+
var cs = class wn {
|
|
1499
1499
|
/**
|
|
1500
1500
|
* Creates a new IsoView instance. Similar to DataView, but with additional
|
|
1501
1501
|
* methods for reading ISO BMFF data. It implements the iterator protocol,
|
|
@@ -1506,55 +1506,55 @@ var os = class pn {
|
|
|
1506
1506
|
*/
|
|
1507
1507
|
constructor(e, t) {
|
|
1508
1508
|
this.truncated = !1, this.slice = (s, r) => {
|
|
1509
|
-
const i = new
|
|
1510
|
-
return this.offset +=
|
|
1509
|
+
const i = new wn(new DataView(this.dataView.buffer, s, r), this.config), a = this.offset - s, c = r - a;
|
|
1510
|
+
return this.offset += c, i.jump(a), i;
|
|
1511
1511
|
}, this.read = (s, r = 0) => {
|
|
1512
1512
|
const { dataView: i, offset: a } = this;
|
|
1513
|
-
let
|
|
1513
|
+
let c, o = r;
|
|
1514
1514
|
switch (s) {
|
|
1515
1515
|
case L:
|
|
1516
|
-
|
|
1516
|
+
c = G(i, a, r);
|
|
1517
1517
|
break;
|
|
1518
1518
|
case De:
|
|
1519
|
-
|
|
1519
|
+
c = ss(i, a, r);
|
|
1520
1520
|
break;
|
|
1521
1521
|
case ie:
|
|
1522
|
-
|
|
1522
|
+
c = rs(i, a, r);
|
|
1523
1523
|
break;
|
|
1524
1524
|
case qe:
|
|
1525
|
-
r === -1 ? (
|
|
1525
|
+
r === -1 ? (c = is(i, a), o = c.length + 1) : c = Ce(i, a, r);
|
|
1526
1526
|
break;
|
|
1527
1527
|
case xe:
|
|
1528
|
-
|
|
1528
|
+
c = ts(i, a, r), o = c.length;
|
|
1529
1529
|
break;
|
|
1530
1530
|
case Ne:
|
|
1531
|
-
r === -1 ? (
|
|
1531
|
+
r === -1 ? (c = os(i, a), o = c.length + 1) : c = as(i, a);
|
|
1532
1532
|
break;
|
|
1533
1533
|
default:
|
|
1534
|
-
|
|
1534
|
+
c = -1;
|
|
1535
1535
|
}
|
|
1536
|
-
return this.offset +=
|
|
1536
|
+
return this.offset += o, c;
|
|
1537
1537
|
}, this.readUint = (s) => this.read(L, s), this.readInt = (s) => this.read(De, s), this.readString = (s) => this.read(qe, s), this.readTemplate = (s) => this.read(ie, s), this.readData = (s) => this.read(xe, s), this.readUtf8 = (s) => this.read(Ne, s), this.readFullBox = () => ({
|
|
1538
1538
|
version: this.readUint(1),
|
|
1539
1539
|
flags: this.readUint(3)
|
|
1540
1540
|
}), this.readArray = (s, r, i) => {
|
|
1541
1541
|
const a = [];
|
|
1542
|
-
for (let
|
|
1542
|
+
for (let c = 0; c < i; c++) a.push(this.read(s, r));
|
|
1543
1543
|
return a;
|
|
1544
1544
|
}, this.jump = (s) => {
|
|
1545
1545
|
this.offset += s;
|
|
1546
1546
|
}, this.readBox = () => {
|
|
1547
1547
|
const { dataView: s, offset: r } = this;
|
|
1548
1548
|
let i = 0;
|
|
1549
|
-
const a = G(s, r, 4),
|
|
1549
|
+
const a = G(s, r, 4), c = Ce(s, r + 4, 4), o = {
|
|
1550
1550
|
size: a,
|
|
1551
|
-
type:
|
|
1551
|
+
type: c
|
|
1552
1552
|
};
|
|
1553
|
-
i += 8,
|
|
1554
|
-
const u =
|
|
1553
|
+
i += 8, o.size === 1 && (o.largesize = G(s, r + i, 8), i += 8);
|
|
1554
|
+
const u = o.size === 0 ? this.bytesRemaining : o.largesize ?? o.size;
|
|
1555
1555
|
if (this.cursor + u > s.byteLength)
|
|
1556
1556
|
throw this.truncated = !0, new Error("Truncated box");
|
|
1557
|
-
return this.jump(i),
|
|
1557
|
+
return this.jump(i), c === "uuid" && (o.usertype = this.readArray("uint", 1, 16)), o.view = this.slice(r, u), o;
|
|
1558
1558
|
}, this.readBoxes = (s = -1) => {
|
|
1559
1559
|
const r = [];
|
|
1560
1560
|
for (const i of this)
|
|
@@ -1564,7 +1564,7 @@ var os = class pn {
|
|
|
1564
1564
|
const i = [];
|
|
1565
1565
|
for (let a = 0; a < s; a++) i.push(r());
|
|
1566
1566
|
return i;
|
|
1567
|
-
}, this.dataView =
|
|
1567
|
+
}, this.dataView = hn(e) ? new DataView(e) : e instanceof DataView ? e : new DataView(e.buffer, e.byteOffset, e.byteLength), this.offset = this.dataView.byteOffset, this.config = t || {};
|
|
1568
1568
|
}
|
|
1569
1569
|
/**
|
|
1570
1570
|
* The buffer of the data view.
|
|
@@ -1611,9 +1611,9 @@ var os = class pn {
|
|
|
1611
1611
|
const { readers: e = {} } = this.config;
|
|
1612
1612
|
for (; !this.done; ) try {
|
|
1613
1613
|
const t = this.readBox(), { type: s, view: r } = t, i = e[s] || e[s.trim()];
|
|
1614
|
-
if (i && Object.assign(t, i(r, s)),
|
|
1614
|
+
if (i && Object.assign(t, i(r, s)), mn(t) && !t.boxes) {
|
|
1615
1615
|
const a = [];
|
|
1616
|
-
for (const
|
|
1616
|
+
for (const c of r) a.push(c);
|
|
1617
1617
|
t.boxes = a;
|
|
1618
1618
|
}
|
|
1619
1619
|
yield t;
|
|
@@ -1623,28 +1623,28 @@ var os = class pn {
|
|
|
1623
1623
|
}
|
|
1624
1624
|
}
|
|
1625
1625
|
};
|
|
1626
|
-
function
|
|
1626
|
+
function vn(n, e) {
|
|
1627
1627
|
const t = [];
|
|
1628
|
-
for (const s of new
|
|
1628
|
+
for (const s of new cs(n, e)) t.push(s);
|
|
1629
1629
|
return t;
|
|
1630
1630
|
}
|
|
1631
|
-
function
|
|
1632
|
-
return
|
|
1631
|
+
function us(n, e) {
|
|
1632
|
+
return pn(n, Jt(e));
|
|
1633
1633
|
}
|
|
1634
|
-
function
|
|
1634
|
+
function ds(n) {
|
|
1635
1635
|
return {
|
|
1636
1636
|
type: "mdat",
|
|
1637
1637
|
data: n.readData(-1)
|
|
1638
1638
|
};
|
|
1639
1639
|
}
|
|
1640
|
-
function
|
|
1640
|
+
function ls(n) {
|
|
1641
1641
|
return {
|
|
1642
1642
|
type: "mfhd",
|
|
1643
1643
|
...n.readFullBox(),
|
|
1644
1644
|
sequenceNumber: n.readUint(4)
|
|
1645
1645
|
};
|
|
1646
1646
|
}
|
|
1647
|
-
function
|
|
1647
|
+
function hs(n) {
|
|
1648
1648
|
const { version: e, flags: t } = n.readFullBox();
|
|
1649
1649
|
return {
|
|
1650
1650
|
type: "tfdt",
|
|
@@ -1653,7 +1653,7 @@ function ls(n) {
|
|
|
1653
1653
|
baseMediaDecodeTime: n.readUint(e == 1 ? 8 : 4)
|
|
1654
1654
|
};
|
|
1655
1655
|
}
|
|
1656
|
-
function
|
|
1656
|
+
function fs(n) {
|
|
1657
1657
|
const { version: e, flags: t } = n.readFullBox();
|
|
1658
1658
|
return {
|
|
1659
1659
|
type: "tfhd",
|
|
@@ -1667,13 +1667,13 @@ function hs(n) {
|
|
|
1667
1667
|
defaultSampleFlags: t & 32 ? n.readUint(4) : void 0
|
|
1668
1668
|
};
|
|
1669
1669
|
}
|
|
1670
|
-
function
|
|
1670
|
+
function ms(n) {
|
|
1671
1671
|
const { version: e, flags: t } = n.readFullBox(), s = n.readUint(4);
|
|
1672
1672
|
let r, i;
|
|
1673
1673
|
t & 1 && (r = n.readInt(4)), t & 4 && (i = n.readUint(4));
|
|
1674
1674
|
const a = n.readEntries(s, () => {
|
|
1675
|
-
const
|
|
1676
|
-
return t & 256 && (
|
|
1675
|
+
const c = {};
|
|
1676
|
+
return t & 256 && (c.sampleDuration = n.readUint(4)), t & 512 && (c.sampleSize = n.readUint(4)), t & 1024 && (c.sampleFlags = n.readUint(4)), t & 2048 && (c.sampleCompositionTimeOffset = e === 1 ? n.readInt(4) : n.readUint(4)), c;
|
|
1677
1677
|
});
|
|
1678
1678
|
return {
|
|
1679
1679
|
type: "trun",
|
|
@@ -1685,80 +1685,80 @@ function fs(n) {
|
|
|
1685
1685
|
samples: a
|
|
1686
1686
|
};
|
|
1687
1687
|
}
|
|
1688
|
-
function
|
|
1689
|
-
const i = n.entries.length, { bytes: a, size:
|
|
1690
|
-
return
|
|
1688
|
+
function ps(n, e) {
|
|
1689
|
+
const i = n.entries.length, { bytes: a, size: c } = ye(n.entries, e), o = new A("dref", 16 + c);
|
|
1690
|
+
return o.writeFullBox(n.version, n.flags), o.writeUint(i, 4), o.writeBytes(a), o;
|
|
1691
1691
|
}
|
|
1692
|
-
function
|
|
1692
|
+
function ws(n) {
|
|
1693
1693
|
const r = n.compatibleBrands.length * 4, i = new A("ftyp", 16 + r);
|
|
1694
1694
|
i.writeString(n.majorBrand), i.writeUint(n.minorVersion, 4);
|
|
1695
1695
|
for (const a of n.compatibleBrands) i.writeString(a);
|
|
1696
1696
|
return i;
|
|
1697
1697
|
}
|
|
1698
|
-
function ws(n) {
|
|
1699
|
-
const a = n.name.length + 1, o = new A("hdlr", 32 + a);
|
|
1700
|
-
return o.writeFullBox(n.version, n.flags), o.writeUint(n.preDefined, 4), o.writeString(n.handlerType), o.writeArray(n.reserved, L, 4, 3), o.writeTerminatedString(n.name), o;
|
|
1701
|
-
}
|
|
1702
1698
|
function vs(n) {
|
|
1699
|
+
const a = n.name.length + 1, c = new A("hdlr", 32 + a);
|
|
1700
|
+
return c.writeFullBox(n.version, n.flags), c.writeUint(n.preDefined, 4), c.writeString(n.handlerType), c.writeArray(n.reserved, L, 4, 3), c.writeTerminatedString(n.name), c;
|
|
1701
|
+
}
|
|
1702
|
+
function bs(n) {
|
|
1703
1703
|
const e = new A("mdat", 8 + n.data.length);
|
|
1704
1704
|
return e.writeBytes(n.data), e;
|
|
1705
1705
|
}
|
|
1706
|
-
function
|
|
1706
|
+
function gs(n) {
|
|
1707
1707
|
const e = n.version === 1 ? 8 : 4, t = 8, s = 4, r = e * 3, i = new A("mdhd", t + s + r + 4 + 2 + 2);
|
|
1708
1708
|
i.writeFullBox(n.version, n.flags), i.writeUint(n.creationTime, e), i.writeUint(n.modificationTime, e), i.writeUint(n.timescale, 4), i.writeUint(n.duration, e);
|
|
1709
1709
|
const a = n.language.length >= 3 ? (n.language.charCodeAt(0) - 96 & 31) << 10 | (n.language.charCodeAt(1) - 96 & 31) << 5 | n.language.charCodeAt(2) - 96 & 31 : 0;
|
|
1710
1710
|
return i.writeUint(a, 2), i.writeUint(n.preDefined, 2), i;
|
|
1711
1711
|
}
|
|
1712
|
-
function
|
|
1712
|
+
function ys(n) {
|
|
1713
1713
|
const e = new A("mfhd", 16);
|
|
1714
1714
|
return e.writeFullBox(n.version, n.flags), e.writeUint(n.sequenceNumber, 4), e;
|
|
1715
1715
|
}
|
|
1716
|
-
function
|
|
1716
|
+
function _s(n) {
|
|
1717
1717
|
const e = n.version === 1 ? 8 : 4, t = 8, s = 4, r = e * 3, i = new A("mvhd", t + s + r + 4 + 4 + 2 + 2 + 8 + 36 + 24 + 4);
|
|
1718
1718
|
return i.writeFullBox(n.version, n.flags), i.writeUint(n.creationTime, e), i.writeUint(n.modificationTime, e), i.writeUint(n.timescale, 4), i.writeUint(n.duration, e), i.writeTemplate(n.rate, 4), i.writeTemplate(n.volume, 2), i.writeUint(n.reserved1, 2), i.writeArray(n.reserved2, L, 4, 2), i.writeArray(n.matrix, ie, 4, 9), i.writeArray(n.preDefined, L, 4, 6), i.writeUint(n.nextTrackId, 4), i;
|
|
1719
1719
|
}
|
|
1720
|
-
function
|
|
1720
|
+
function Ss(n) {
|
|
1721
1721
|
const e = new A("smhd", 16);
|
|
1722
1722
|
return e.writeFullBox(n.version, n.flags), e.writeUint(n.balance, 2), e.writeUint(n.reserved, 2), e;
|
|
1723
1723
|
}
|
|
1724
|
-
function
|
|
1725
|
-
const i = n.entries.length, { bytes: a, size:
|
|
1726
|
-
return
|
|
1724
|
+
function ks(n, e) {
|
|
1725
|
+
const i = n.entries.length, { bytes: a, size: c } = ye(n.entries, e), o = new A("stsd", 16 + c);
|
|
1726
|
+
return o.writeFullBox(n.version, n.flags), o.writeUint(i, 4), o.writeBytes(a), o;
|
|
1727
1727
|
}
|
|
1728
|
-
function
|
|
1728
|
+
function As(n) {
|
|
1729
1729
|
const r = n.entryCount * 8, i = new A("stts", 16 + r);
|
|
1730
1730
|
i.writeFullBox(n.version, n.flags), i.writeUint(n.entryCount, 4);
|
|
1731
1731
|
for (const a of n.entries)
|
|
1732
1732
|
i.writeUint(a.sampleCount, 4), i.writeUint(a.sampleDelta, 4);
|
|
1733
1733
|
return i;
|
|
1734
1734
|
}
|
|
1735
|
-
function
|
|
1735
|
+
function Is(n) {
|
|
1736
1736
|
const e = n.version === 1 ? 8 : 4, t = 8, s = 4, r = e, i = new A("tfdt", t + s + r);
|
|
1737
1737
|
return i.writeFullBox(n.version, n.flags), i.writeUint(n.baseMediaDecodeTime, e), i;
|
|
1738
1738
|
}
|
|
1739
|
-
function
|
|
1740
|
-
const r = n.flags & 1 ? 8 : 0, i = n.flags & 2 ? 4 : 0, a = n.flags & 8 ? 4 : 0,
|
|
1739
|
+
function Rs(n) {
|
|
1740
|
+
const r = n.flags & 1 ? 8 : 0, i = n.flags & 2 ? 4 : 0, a = n.flags & 8 ? 4 : 0, c = n.flags & 16 ? 4 : 0, o = n.flags & 32 ? 4 : 0, u = new A("tfhd", 16 + r + i + a + c + o);
|
|
1741
1741
|
return u.writeFullBox(n.version, n.flags), u.writeUint(n.trackId, 4), n.flags & 1 && u.writeUint(n.baseDataOffset ?? 0, 8), n.flags & 2 && u.writeUint(n.sampleDescriptionIndex ?? 0, 4), n.flags & 8 && u.writeUint(n.defaultSampleDuration ?? 0, 4), n.flags & 16 && u.writeUint(n.defaultSampleSize ?? 0, 4), n.flags & 32 && u.writeUint(n.defaultSampleFlags ?? 0, 4), u;
|
|
1742
1742
|
}
|
|
1743
|
-
function
|
|
1743
|
+
function Es(n) {
|
|
1744
1744
|
const e = n.version === 1 ? 8 : 4, t = 8, s = 4, r = e * 3, i = new A("tkhd", t + s + r + 4 + 4 + 8 + 2 + 2 + 2 + 2 + 36 + 4 + 4);
|
|
1745
1745
|
return i.writeFullBox(n.version, n.flags), i.writeUint(n.creationTime, e), i.writeUint(n.modificationTime, e), i.writeUint(n.trackId, 4), i.writeUint(n.reserved1, 4), i.writeUint(n.duration, e), i.writeArray(n.reserved2, L, 4, 2), i.writeUint(n.layer, 2), i.writeUint(n.alternateGroup, 2), i.writeTemplate(n.volume, 2), i.writeUint(n.reserved3, 2), i.writeArray(n.matrix, ie, 4, 9), i.writeTemplate(n.width, 4), i.writeTemplate(n.height, 4), i;
|
|
1746
1746
|
}
|
|
1747
|
-
function
|
|
1747
|
+
function Ts(n) {
|
|
1748
1748
|
const e = new A("trex", 32);
|
|
1749
1749
|
return e.writeFullBox(n.version, n.flags), e.writeUint(n.trackId, 4), e.writeUint(n.defaultSampleDescriptionIndex, 4), e.writeUint(n.defaultSampleDuration, 4), e.writeUint(n.defaultSampleSize, 4), e.writeUint(n.defaultSampleFlags, 4), e;
|
|
1750
1750
|
}
|
|
1751
|
-
function
|
|
1751
|
+
function Us(n) {
|
|
1752
1752
|
const r = n.flags & 1 ? 4 : 0, i = n.flags & 4 ? 4 : 0;
|
|
1753
1753
|
let a = 0;
|
|
1754
1754
|
n.flags & 256 && (a += 4), n.flags & 512 && (a += 4), n.flags & 1024 && (a += 4), n.flags & 2048 && (a += 4);
|
|
1755
|
-
const
|
|
1756
|
-
|
|
1755
|
+
const c = a * n.sampleCount, o = new A("trun", 16 + r + i + c);
|
|
1756
|
+
o.writeFullBox(n.version, n.flags), o.writeUint(n.sampleCount, 4), n.flags & 1 && o.writeUint(n.dataOffset ?? 0, 4), n.flags & 4 && o.writeUint(n.firstSampleFlags ?? 0, 4);
|
|
1757
1757
|
for (const u of n.samples)
|
|
1758
|
-
n.flags & 256 &&
|
|
1759
|
-
return
|
|
1758
|
+
n.flags & 256 && o.writeUint(u.sampleDuration ?? 0, 4), n.flags & 512 && o.writeUint(u.sampleSize ?? 0, 4), n.flags & 1024 && o.writeUint(u.sampleFlags ?? 0, 4), n.flags & 2048 && o.writeUint(u.sampleCompositionTimeOffset ?? 0, 4);
|
|
1759
|
+
return o;
|
|
1760
1760
|
}
|
|
1761
|
-
function
|
|
1761
|
+
function Ms(n) {
|
|
1762
1762
|
const s = n.location.length + 1, r = new A("url ", 12 + s);
|
|
1763
1763
|
return r.writeFullBox(n.version, n.flags), r.writeTerminatedString(n.location), r;
|
|
1764
1764
|
}
|
|
@@ -1766,12 +1766,12 @@ function Ps(n) {
|
|
|
1766
1766
|
const e = new A("vmhd", 20);
|
|
1767
1767
|
return e.writeFullBox(n.version, n.flags), e.writeUint(n.graphicsmode, 2), e.writeArray(n.opcolor, L, 2, 3), e;
|
|
1768
1768
|
}
|
|
1769
|
-
const
|
|
1770
|
-
mfhd:
|
|
1771
|
-
tfhd:
|
|
1772
|
-
tfdt:
|
|
1773
|
-
trun:
|
|
1774
|
-
mdat:
|
|
1769
|
+
const bn = {
|
|
1770
|
+
mfhd: ls,
|
|
1771
|
+
tfhd: fs,
|
|
1772
|
+
tfdt: hs,
|
|
1773
|
+
trun: ms,
|
|
1774
|
+
mdat: ds
|
|
1775
1775
|
};
|
|
1776
1776
|
function X(n, e) {
|
|
1777
1777
|
for (const t of n) {
|
|
@@ -1784,19 +1784,19 @@ function X(n, e) {
|
|
|
1784
1784
|
}
|
|
1785
1785
|
}
|
|
1786
1786
|
}
|
|
1787
|
-
function
|
|
1787
|
+
function gn(n) {
|
|
1788
1788
|
const e = new ArrayBuffer(n.byteLength);
|
|
1789
1789
|
return new Uint8Array(e).set(n), e;
|
|
1790
1790
|
}
|
|
1791
1791
|
function ne(n) {
|
|
1792
1792
|
return (e) => e.type === n;
|
|
1793
1793
|
}
|
|
1794
|
-
function
|
|
1795
|
-
const t =
|
|
1794
|
+
function yn(n, e) {
|
|
1795
|
+
const t = vn(gn(n), { readers: bn });
|
|
1796
1796
|
return (X(t, ne("tfdt"))?.baseMediaDecodeTime ?? 0) * 1e6 / e;
|
|
1797
1797
|
}
|
|
1798
|
-
function
|
|
1799
|
-
const t =
|
|
1798
|
+
function _n(n, e) {
|
|
1799
|
+
const t = vn(gn(n), { readers: bn }), r = X(t, ne("tfdt"))?.baseMediaDecodeTime ?? 0, i = X(t, ne("tfhd")), a = i?.defaultSampleDuration ?? 0, c = i?.defaultSampleSize ?? 0, o = i?.defaultSampleFlags ?? 0, u = X(t, ne("trun"));
|
|
1800
1800
|
if (!u)
|
|
1801
1801
|
throw new Error("No trun box found in data segment");
|
|
1802
1802
|
const d = X(t, ne("mdat"));
|
|
@@ -1806,19 +1806,19 @@ function yn(n, e) {
|
|
|
1806
1806
|
if (!l)
|
|
1807
1807
|
throw new Error("No data in mdat box");
|
|
1808
1808
|
const f = [];
|
|
1809
|
-
let
|
|
1809
|
+
let w = 0, b = r;
|
|
1810
1810
|
for (let g = 0; g < u.sampleCount; g++) {
|
|
1811
|
-
const R = u.samples[g] ?? {}, O = R.sampleSize ??
|
|
1811
|
+
const R = u.samples[g] ?? {}, O = R.sampleSize ?? c, z = R.sampleDuration ?? a;
|
|
1812
1812
|
if (O <= 0)
|
|
1813
1813
|
throw new Error(`Invalid sample size ${O} for sample ${g} in trun`);
|
|
1814
1814
|
if (z <= 0)
|
|
1815
1815
|
throw new Error(`Invalid sample duration ${z} for sample ${g} in trun`);
|
|
1816
|
-
if (
|
|
1816
|
+
if (w + O > l.length)
|
|
1817
1817
|
throw new Error(
|
|
1818
|
-
`Sample ${g} would overflow mdat: offset=${
|
|
1818
|
+
`Sample ${g} would overflow mdat: offset=${w}, size=${O}, mdatLength=${l.length}`
|
|
1819
1819
|
);
|
|
1820
|
-
const $ = g === 0 && u.firstSampleFlags !== void 0 ? u.firstSampleFlags : R.sampleFlags ??
|
|
1821
|
-
|
|
1820
|
+
const $ = g === 0 && u.firstSampleFlags !== void 0 ? u.firstSampleFlags : R.sampleFlags ?? o, D = R.sampleCompositionTimeOffset ?? 0, x = new Uint8Array(l.slice(w, w + O));
|
|
1821
|
+
w += O;
|
|
1822
1822
|
const C = b + D, F = Math.round(C * 1e6 / e), k = $ === 0 || ($ & 65536) === 0;
|
|
1823
1823
|
f.push({
|
|
1824
1824
|
data: x,
|
|
@@ -1836,62 +1836,62 @@ function q(n) {
|
|
|
1836
1836
|
throw new Error("invalid hex string format");
|
|
1837
1837
|
return new Uint8Array(e.map((t) => parseInt(t, 16)));
|
|
1838
1838
|
}
|
|
1839
|
-
const he = [65536, 0, 0, 0, 65536, 0, 0, 0, 1073741824],
|
|
1839
|
+
const he = [65536, 0, 0, 0, 65536, 0, 0, 0, 1073741824], Os = {
|
|
1840
1840
|
// Init segment boxes
|
|
1841
|
-
ftyp:
|
|
1842
|
-
mvhd:
|
|
1843
|
-
tkhd:
|
|
1844
|
-
mdhd:
|
|
1845
|
-
hdlr:
|
|
1841
|
+
ftyp: ws,
|
|
1842
|
+
mvhd: _s,
|
|
1843
|
+
tkhd: Es,
|
|
1844
|
+
mdhd: gs,
|
|
1845
|
+
hdlr: vs,
|
|
1846
1846
|
vmhd: Ps,
|
|
1847
|
-
smhd:
|
|
1848
|
-
"url ":
|
|
1849
|
-
dref:
|
|
1850
|
-
stsd:
|
|
1851
|
-
stts:
|
|
1852
|
-
trex:
|
|
1847
|
+
smhd: Ss,
|
|
1848
|
+
"url ": Ms,
|
|
1849
|
+
dref: ps,
|
|
1850
|
+
stsd: ks,
|
|
1851
|
+
stts: As,
|
|
1852
|
+
trex: Ts,
|
|
1853
1853
|
// Data segment boxes
|
|
1854
|
-
mfhd:
|
|
1855
|
-
tfhd:
|
|
1856
|
-
tfdt:
|
|
1857
|
-
trun:
|
|
1858
|
-
mdat:
|
|
1854
|
+
mfhd: ys,
|
|
1855
|
+
tfhd: Rs,
|
|
1856
|
+
tfdt: Is,
|
|
1857
|
+
trun: Us,
|
|
1858
|
+
mdat: bs
|
|
1859
1859
|
// For boxes without library writers, we create them manually as Uint8Arrays
|
|
1860
1860
|
};
|
|
1861
1861
|
function se(n) {
|
|
1862
|
-
return
|
|
1862
|
+
return us(n, { writers: Os });
|
|
1863
1863
|
}
|
|
1864
1864
|
function _e(n, e, t, s) {
|
|
1865
1865
|
const r = 12 + s.length, i = new Uint8Array(r), a = new DataView(i.buffer);
|
|
1866
1866
|
return a.setUint32(0, r, !1), i[4] = n.charCodeAt(0), i[5] = n.charCodeAt(1), i[6] = n.charCodeAt(2), i[7] = n.charCodeAt(3), a.setUint32(8, e << 24 | t, !1), i.set(s, 12), i;
|
|
1867
1867
|
}
|
|
1868
|
-
function
|
|
1868
|
+
function Sn() {
|
|
1869
1869
|
const n = new Uint8Array(4);
|
|
1870
1870
|
return _e("stsc", 0, 0, n);
|
|
1871
1871
|
}
|
|
1872
|
-
function
|
|
1872
|
+
function kn() {
|
|
1873
1873
|
const n = new Uint8Array(8);
|
|
1874
1874
|
return _e("stsz", 0, 0, n);
|
|
1875
1875
|
}
|
|
1876
|
-
function
|
|
1876
|
+
function An() {
|
|
1877
1877
|
const n = new Uint8Array(4);
|
|
1878
1878
|
return _e("stco", 0, 0, n);
|
|
1879
1879
|
}
|
|
1880
|
-
function
|
|
1881
|
-
const s = 8 + t.length, i = 8 + (78 + s), a = new Uint8Array(i),
|
|
1882
|
-
let
|
|
1883
|
-
return
|
|
1880
|
+
function zs(n, e, t) {
|
|
1881
|
+
const s = 8 + t.length, i = 8 + (78 + s), a = new Uint8Array(i), c = new DataView(a.buffer);
|
|
1882
|
+
let o = 0;
|
|
1883
|
+
return c.setUint32(o, i, !1), o += 4, a[o++] = 97, a[o++] = 118, a[o++] = 99, a[o++] = 49, o += 6, c.setUint16(o, 1, !1), o += 2, c.setUint16(o, 0, !1), o += 2, c.setUint16(o, 0, !1), o += 2, o += 12, c.setUint16(o, n, !1), o += 2, c.setUint16(o, e, !1), o += 2, c.setUint32(o, 4718592, !1), o += 4, c.setUint32(o, 4718592, !1), o += 4, c.setUint32(o, 0, !1), o += 4, c.setUint16(o, 1, !1), o += 2, o += 32, c.setUint16(o, 24, !1), o += 2, c.setUint16(o, 65535, !1), o += 2, c.setUint32(o, s, !1), o += 4, a[o++] = 97, a[o++] = 118, a[o++] = 99, a[o++] = 67, a.set(t, o), a;
|
|
1884
1884
|
}
|
|
1885
1885
|
function Fe(n) {
|
|
1886
1886
|
const { codedWidth: e, codedHeight: t, description: s, container: r } = n;
|
|
1887
1887
|
if (!e || !t || !s)
|
|
1888
1888
|
throw new Error("Missing required fields to create video init segment");
|
|
1889
|
-
const i = r.kind === "cmaf" ? r.timescale : 1e6, a = r.kind === "cmaf" ? r.trackId : 1,
|
|
1889
|
+
const i = r.kind === "cmaf" ? r.timescale : 1e6, a = r.kind === "cmaf" ? r.trackId : 1, c = {
|
|
1890
1890
|
type: "ftyp",
|
|
1891
1891
|
majorBrand: "isom",
|
|
1892
1892
|
minorVersion: 512,
|
|
1893
1893
|
compatibleBrands: ["isom", "iso6", "mp41"]
|
|
1894
|
-
},
|
|
1894
|
+
}, o = {
|
|
1895
1895
|
type: "mvhd",
|
|
1896
1896
|
version: 0,
|
|
1897
1897
|
flags: 0,
|
|
@@ -1975,16 +1975,16 @@ function Fe(n) {
|
|
|
1975
1975
|
flags: 0,
|
|
1976
1976
|
entryCount: 1,
|
|
1977
1977
|
// biome-ignore lint/suspicious/noExplicitAny: Raw avc1 box since library doesn't handle avcC children
|
|
1978
|
-
entries: [
|
|
1978
|
+
entries: [zs(e, t, q(s))]
|
|
1979
1979
|
}, z = {
|
|
1980
1980
|
type: "stts",
|
|
1981
1981
|
version: 0,
|
|
1982
1982
|
flags: 0,
|
|
1983
1983
|
entryCount: 0,
|
|
1984
1984
|
entries: []
|
|
1985
|
-
}, $ =
|
|
1985
|
+
}, $ = Sn(), D = kn(), x = An(), me = se([c, {
|
|
1986
1986
|
type: "moov",
|
|
1987
|
-
boxes: [
|
|
1987
|
+
boxes: [o, {
|
|
1988
1988
|
type: "trak",
|
|
1989
1989
|
boxes: [u, {
|
|
1990
1990
|
type: "mdia",
|
|
@@ -2017,7 +2017,7 @@ function Fe(n) {
|
|
|
2017
2017
|
return oe;
|
|
2018
2018
|
}
|
|
2019
2019
|
function Ve(n) {
|
|
2020
|
-
const { sampleRate: e, numberOfChannels: t, description: s, codec: r, container: i } = n, a = i.kind === "cmaf" ? i.timescale : 1e6,
|
|
2020
|
+
const { sampleRate: e, numberOfChannels: t, description: s, codec: r, container: i } = n, a = i.kind === "cmaf" ? i.timescale : 1e6, c = i.kind === "cmaf" ? i.trackId : 1, o = {
|
|
2021
2021
|
type: "ftyp",
|
|
2022
2022
|
majorBrand: "isom",
|
|
2023
2023
|
minorVersion: 512,
|
|
@@ -2036,14 +2036,14 @@ function Ve(n) {
|
|
|
2036
2036
|
reserved2: [0, 0],
|
|
2037
2037
|
matrix: he,
|
|
2038
2038
|
preDefined: [0, 0, 0, 0, 0, 0],
|
|
2039
|
-
nextTrackId:
|
|
2039
|
+
nextTrackId: c + 1
|
|
2040
2040
|
}, d = {
|
|
2041
2041
|
type: "tkhd",
|
|
2042
2042
|
version: 0,
|
|
2043
2043
|
flags: 3,
|
|
2044
2044
|
creationTime: 0,
|
|
2045
2045
|
modificationTime: 0,
|
|
2046
|
-
trackId:
|
|
2046
|
+
trackId: c,
|
|
2047
2047
|
reserved1: 0,
|
|
2048
2048
|
duration: 0,
|
|
2049
2049
|
reserved2: [0, 0],
|
|
@@ -2073,7 +2073,7 @@ function Ve(n) {
|
|
|
2073
2073
|
handlerType: "soun",
|
|
2074
2074
|
reserved: [0, 0, 0],
|
|
2075
2075
|
name: "SoundHandler"
|
|
2076
|
-
},
|
|
2076
|
+
}, w = {
|
|
2077
2077
|
type: "smhd",
|
|
2078
2078
|
version: 0,
|
|
2079
2079
|
flags: 0,
|
|
@@ -2099,14 +2099,14 @@ function Ve(n) {
|
|
|
2099
2099
|
flags: 0,
|
|
2100
2100
|
entryCount: 1,
|
|
2101
2101
|
// biome-ignore lint/suspicious/noExplicitAny: Raw sample entry box
|
|
2102
|
-
entries: [
|
|
2102
|
+
entries: [Ns(r, e, t, s)]
|
|
2103
2103
|
}, $ = {
|
|
2104
2104
|
type: "stts",
|
|
2105
2105
|
version: 0,
|
|
2106
2106
|
flags: 0,
|
|
2107
2107
|
entryCount: 0,
|
|
2108
2108
|
entries: []
|
|
2109
|
-
}, D =
|
|
2109
|
+
}, D = Sn(), x = kn(), C = An(), ae = se([o, {
|
|
2110
2110
|
type: "moov",
|
|
2111
2111
|
boxes: [u, {
|
|
2112
2112
|
type: "trak",
|
|
@@ -2114,7 +2114,7 @@ function Ve(n) {
|
|
|
2114
2114
|
type: "mdia",
|
|
2115
2115
|
boxes: [l, f, {
|
|
2116
2116
|
type: "minf",
|
|
2117
|
-
boxes: [
|
|
2117
|
+
boxes: [w, R, {
|
|
2118
2118
|
type: "stbl",
|
|
2119
2119
|
// biome-ignore lint/suspicious/noExplicitAny: Raw boxes for types without library writers
|
|
2120
2120
|
boxes: [z, $, D, x, C]
|
|
@@ -2127,37 +2127,37 @@ function Ve(n) {
|
|
|
2127
2127
|
type: "trex",
|
|
2128
2128
|
version: 0,
|
|
2129
2129
|
flags: 0,
|
|
2130
|
-
trackId:
|
|
2130
|
+
trackId: c,
|
|
2131
2131
|
defaultSampleDescriptionIndex: 1,
|
|
2132
2132
|
defaultSampleDuration: 0,
|
|
2133
2133
|
defaultSampleSize: 0,
|
|
2134
2134
|
defaultSampleFlags: 0
|
|
2135
2135
|
}]
|
|
2136
2136
|
}]
|
|
2137
|
-
}]), oe = ae.reduce((V,
|
|
2137
|
+
}]), oe = ae.reduce((V, On) => V + On.byteLength, 0), Q = new Uint8Array(oe);
|
|
2138
2138
|
let N = 0;
|
|
2139
2139
|
for (const V of ae)
|
|
2140
2140
|
Q.set(new Uint8Array(V.buffer, V.byteOffset, V.byteLength), N), N += V.byteLength;
|
|
2141
2141
|
return Q;
|
|
2142
2142
|
}
|
|
2143
|
-
function
|
|
2143
|
+
function Ns(n, e, t, s) {
|
|
2144
2144
|
if (n.startsWith("mp4a"))
|
|
2145
|
-
return Ns(e, t, s);
|
|
2146
|
-
if (n === "opus")
|
|
2147
2145
|
return qs(e, t, s);
|
|
2146
|
+
if (n === "opus")
|
|
2147
|
+
return Ds(e, t, s);
|
|
2148
2148
|
throw new Error(`Unsupported audio codec: ${n}`);
|
|
2149
2149
|
}
|
|
2150
|
-
function Ns(n, e, t) {
|
|
2151
|
-
const s = xs(n, e, t), i = 8 + (28 + s.length), a = new Uint8Array(i), o = new DataView(a.buffer);
|
|
2152
|
-
let c = 0;
|
|
2153
|
-
return o.setUint32(c, i, !1), c += 4, a[c++] = 109, a[c++] = 112, a[c++] = 52, a[c++] = 97, c += 6, o.setUint16(c, 1, !1), c += 2, c += 8, o.setUint16(c, e, !1), c += 2, o.setUint16(c, 16, !1), c += 2, o.setUint16(c, 0, !1), c += 2, o.setUint16(c, 0, !1), c += 2, o.setUint32(c, n * 65536, !1), c += 4, a.set(s, c), a;
|
|
2154
|
-
}
|
|
2155
2150
|
function qs(n, e, t) {
|
|
2156
|
-
const s = Cs(
|
|
2157
|
-
let
|
|
2158
|
-
return
|
|
2151
|
+
const s = Cs(n, e, t), i = 8 + (28 + s.length), a = new Uint8Array(i), c = new DataView(a.buffer);
|
|
2152
|
+
let o = 0;
|
|
2153
|
+
return c.setUint32(o, i, !1), o += 4, a[o++] = 109, a[o++] = 112, a[o++] = 52, a[o++] = 97, o += 6, c.setUint16(o, 1, !1), o += 2, o += 8, c.setUint16(o, e, !1), o += 2, c.setUint16(o, 16, !1), o += 2, c.setUint16(o, 0, !1), o += 2, c.setUint16(o, 0, !1), o += 2, c.setUint32(o, n * 65536, !1), o += 4, a.set(s, o), a;
|
|
2159
2154
|
}
|
|
2160
|
-
function Ds(n, e) {
|
|
2155
|
+
function Ds(n, e, t) {
|
|
2156
|
+
const s = Fs(e, n, t), i = 8 + (28 + s.length), a = new Uint8Array(i), c = new DataView(a.buffer);
|
|
2157
|
+
let o = 0;
|
|
2158
|
+
return c.setUint32(o, i, !1), o += 4, a[o++] = 79, a[o++] = 112, a[o++] = 117, a[o++] = 115, o += 6, c.setUint16(o, 1, !1), o += 2, o += 8, c.setUint16(o, e, !1), o += 2, c.setUint16(o, 16, !1), o += 2, c.setUint16(o, 0, !1), o += 2, c.setUint16(o, 0, !1), o += 2, c.setUint32(o, n * 65536, !1), o += 4, a.set(s, o), a;
|
|
2159
|
+
}
|
|
2160
|
+
function xs(n, e) {
|
|
2161
2161
|
const s = {
|
|
2162
2162
|
96e3: 0,
|
|
2163
2163
|
88200: 1,
|
|
@@ -2175,22 +2175,22 @@ function Ds(n, e) {
|
|
|
2175
2175
|
}[n] ?? 4, i = 2 << 3 | s >> 1, a = (s & 1) << 7 | e << 3;
|
|
2176
2176
|
return new Uint8Array([i, a]);
|
|
2177
2177
|
}
|
|
2178
|
-
function
|
|
2179
|
-
const s = t ? q(t) :
|
|
2178
|
+
function Cs(n, e, t) {
|
|
2179
|
+
const s = t ? q(t) : xs(n, e), r = s.length, i = 15 + r, a = 5 + i + 3, c = 14 + a, o = new Uint8Array(c), u = new DataView(o.buffer);
|
|
2180
2180
|
let d = 0;
|
|
2181
|
-
return u.setUint32(d,
|
|
2181
|
+
return u.setUint32(d, c, !1), d += 4, o[d++] = 101, o[d++] = 115, o[d++] = 100, o[d++] = 115, u.setUint32(d, 0, !1), d += 4, o[d++] = 3, o[d++] = a, u.setUint16(d, 0, !1), d += 2, o[d++] = 0, o[d++] = 4, o[d++] = i, o[d++] = 64, o[d++] = 21, o[d++] = 0, o[d++] = 0, o[d++] = 0, u.setUint32(d, 0, !1), d += 4, u.setUint32(d, 0, !1), d += 4, o[d++] = 5, o[d++] = r, o.set(s, d), d += r, o[d++] = 6, o[d++] = 1, o[d++] = 2, o;
|
|
2182
2182
|
}
|
|
2183
|
-
function
|
|
2183
|
+
function Fs(n, e, t) {
|
|
2184
2184
|
if (t) {
|
|
2185
|
-
const
|
|
2186
|
-
return new DataView(u.buffer).setUint32(0,
|
|
2185
|
+
const c = q(t), o = 8 + c.length, u = new Uint8Array(o);
|
|
2186
|
+
return new DataView(u.buffer).setUint32(0, o, !1), u[4] = 100, u[5] = 79, u[6] = 112, u[7] = 115, u.set(c, 8), u;
|
|
2187
2187
|
}
|
|
2188
2188
|
const s = 19, r = new Uint8Array(s), i = new DataView(r.buffer);
|
|
2189
2189
|
let a = 0;
|
|
2190
2190
|
return i.setUint32(a, s, !1), a += 4, r[a++] = 100, r[a++] = 79, r[a++] = 112, r[a++] = 115, r[a++] = 0, r[a++] = n, i.setUint16(a, 312, !1), a += 2, i.setUint32(a, e, !1), a += 4, i.setInt16(a, 0, !1), a += 2, r[a++] = 0, r;
|
|
2191
2191
|
}
|
|
2192
|
-
function
|
|
2193
|
-
const { data: e, timestamp: t, duration: s, keyframe: r, sequence: i, trackId: a = 1 } = n,
|
|
2192
|
+
function In(n) {
|
|
2193
|
+
const { data: e, timestamp: t, duration: s, keyframe: r, sequence: i, trackId: a = 1 } = n, c = r ? 33554432 : 16842752, o = {
|
|
2194
2194
|
type: "mfhd",
|
|
2195
2195
|
version: 0,
|
|
2196
2196
|
flags: 0,
|
|
@@ -2217,21 +2217,21 @@ function An(n) {
|
|
|
2217
2217
|
{
|
|
2218
2218
|
sampleDuration: s,
|
|
2219
2219
|
sampleSize: e.byteLength,
|
|
2220
|
-
sampleFlags:
|
|
2220
|
+
sampleFlags: c
|
|
2221
2221
|
}
|
|
2222
2222
|
]
|
|
2223
|
-
},
|
|
2223
|
+
}, w = {
|
|
2224
2224
|
type: "moof",
|
|
2225
|
-
boxes: [
|
|
2225
|
+
boxes: [o, {
|
|
2226
2226
|
type: "traf",
|
|
2227
2227
|
boxes: [u, d, l]
|
|
2228
2228
|
}]
|
|
2229
|
-
}, b = se([
|
|
2229
|
+
}, b = se([w]);
|
|
2230
2230
|
let g = 0;
|
|
2231
2231
|
for (const k of b)
|
|
2232
2232
|
g += k.byteLength;
|
|
2233
2233
|
l.dataOffset = g + 8;
|
|
2234
|
-
const R = se([
|
|
2234
|
+
const R = se([w]);
|
|
2235
2235
|
g = 0;
|
|
2236
2236
|
for (const k of R)
|
|
2237
2237
|
g += k.byteLength;
|
|
@@ -2254,17 +2254,17 @@ function An(n) {
|
|
|
2254
2254
|
}
|
|
2255
2255
|
class J {
|
|
2256
2256
|
#n;
|
|
2257
|
-
#s;
|
|
2258
|
-
#e = [];
|
|
2259
2257
|
#t;
|
|
2258
|
+
#e = [];
|
|
2259
|
+
#r;
|
|
2260
2260
|
// the active group sequence number
|
|
2261
2261
|
// Wake up the consumer when a new frame is available.
|
|
2262
|
-
#
|
|
2262
|
+
#s;
|
|
2263
2263
|
#i = new h([]);
|
|
2264
2264
|
buffered = this.#i;
|
|
2265
2265
|
#a = new T();
|
|
2266
2266
|
constructor(e, t) {
|
|
2267
|
-
this.#n = e, this.#
|
|
2267
|
+
this.#n = e, this.#t = h.from(t?.latency ?? _.Time.Milli.zero), this.#a.spawn(this.#o.bind(this)), this.#a.cleanup(() => {
|
|
2268
2268
|
this.#n.close();
|
|
2269
2269
|
for (const s of this.#e)
|
|
2270
2270
|
s.consumer.close();
|
|
@@ -2275,8 +2275,8 @@ class J {
|
|
|
2275
2275
|
for (; ; ) {
|
|
2276
2276
|
const e = await this.#n.nextGroup();
|
|
2277
2277
|
if (!e) break;
|
|
2278
|
-
if (this.#
|
|
2279
|
-
console.warn(`skipping old group: ${e.sequence} < ${this.#
|
|
2278
|
+
if (this.#r === void 0 && (this.#r = e.sequence), e.sequence < this.#r) {
|
|
2279
|
+
console.warn(`skipping old group: ${e.sequence} < ${this.#r}`), e.close();
|
|
2280
2280
|
continue;
|
|
2281
2281
|
}
|
|
2282
2282
|
const t = {
|
|
@@ -2297,53 +2297,53 @@ class J {
|
|
|
2297
2297
|
timestamp: i,
|
|
2298
2298
|
keyframe: t
|
|
2299
2299
|
};
|
|
2300
|
-
t = !1, e.frames.push(a), (e.latest === void 0 || i > e.latest) && (e.latest = i), this.#u(), e.consumer.sequence === this.#
|
|
2300
|
+
t = !1, e.frames.push(a), (e.latest === void 0 || i > e.latest) && (e.latest = i), this.#u(), e.consumer.sequence === this.#r ? (this.#s?.(), this.#s = void 0) : this.#d();
|
|
2301
2301
|
}
|
|
2302
2302
|
} catch {
|
|
2303
2303
|
} finally {
|
|
2304
|
-
e.done = !0, e.consumer.sequence === this.#
|
|
2304
|
+
e.done = !0, e.consumer.sequence === this.#r && (this.#r += 1), this.#u(), this.#s?.(), this.#s = void 0, e.consumer.close();
|
|
2305
2305
|
}
|
|
2306
2306
|
}
|
|
2307
2307
|
#d() {
|
|
2308
|
-
if (this.#
|
|
2308
|
+
if (this.#r === void 0) return;
|
|
2309
2309
|
let e = !1;
|
|
2310
2310
|
for (; this.#e.length >= 2; ) {
|
|
2311
|
-
const t = _.Time.Micro.fromMilli(this.#
|
|
2311
|
+
const t = _.Time.Micro.fromMilli(this.#t.peek());
|
|
2312
2312
|
let s, r;
|
|
2313
|
-
for (const
|
|
2314
|
-
if (
|
|
2315
|
-
const
|
|
2316
|
-
(s === void 0 ||
|
|
2313
|
+
for (const c of this.#e) {
|
|
2314
|
+
if (c.latest === void 0) continue;
|
|
2315
|
+
const o = c.frames.at(0)?.timestamp ?? c.latest;
|
|
2316
|
+
(s === void 0 || o < s) && (s = o), (r === void 0 || c.latest > r) && (r = c.latest);
|
|
2317
2317
|
}
|
|
2318
2318
|
if (s === void 0 || r === void 0 || r - s <= t) break;
|
|
2319
2319
|
const a = this.#e.shift();
|
|
2320
2320
|
if (!a) break;
|
|
2321
|
-
this.#
|
|
2321
|
+
this.#r = this.#e[0]?.consumer.sequence, console.warn(`skipping slow group: ${a.consumer.sequence} -> ${this.#r}`), a.consumer.close(), a.frames.length = 0, e = !0;
|
|
2322
2322
|
}
|
|
2323
|
-
e && (this.#u(), this.#
|
|
2323
|
+
e && (this.#u(), this.#s?.(), this.#s = void 0);
|
|
2324
2324
|
}
|
|
2325
2325
|
// Returns the next frame in order, along with the group number.
|
|
2326
2326
|
// If frame is undefined, the group is done.
|
|
2327
2327
|
async next() {
|
|
2328
2328
|
for (; ; ) {
|
|
2329
|
-
if (this.#e.length > 0 && this.#
|
|
2329
|
+
if (this.#e.length > 0 && this.#r !== void 0 && this.#e[0].consumer.sequence <= this.#r) {
|
|
2330
2330
|
const t = this.#e[0].frames.shift();
|
|
2331
2331
|
if (t)
|
|
2332
2332
|
return this.#u(), { frame: t, group: this.#e[0].consumer.sequence };
|
|
2333
|
-
if (this.#
|
|
2334
|
-
this.#e[0].consumer.sequence === this.#
|
|
2333
|
+
if (this.#r > this.#e[0].consumer.sequence || this.#e[0].done) {
|
|
2334
|
+
this.#e[0].consumer.sequence === this.#r && (this.#r += 1);
|
|
2335
2335
|
const s = this.#e.shift();
|
|
2336
2336
|
if (s)
|
|
2337
2337
|
return this.#u(), { frame: void 0, group: s.consumer.sequence };
|
|
2338
2338
|
}
|
|
2339
2339
|
}
|
|
2340
|
-
if (this.#
|
|
2340
|
+
if (this.#s)
|
|
2341
2341
|
throw new Error("multiple calls to decode not supported");
|
|
2342
2342
|
const e = new Promise((t) => {
|
|
2343
|
-
this.#
|
|
2343
|
+
this.#s = t;
|
|
2344
2344
|
}).then(() => !0);
|
|
2345
2345
|
if (!await Promise.race([e, this.#a.closed])) {
|
|
2346
|
-
this.#
|
|
2346
|
+
this.#s = void 0;
|
|
2347
2347
|
return;
|
|
2348
2348
|
}
|
|
2349
2349
|
}
|
|
@@ -2359,8 +2359,8 @@ class J {
|
|
|
2359
2359
|
for (const s of this.#e) {
|
|
2360
2360
|
const r = s.frames.at(0);
|
|
2361
2361
|
if (!r || s.latest === void 0) continue;
|
|
2362
|
-
const i = _.Time.Milli.fromMicro(r.timestamp), a = _.Time.Milli.fromMicro(s.latest),
|
|
2363
|
-
|
|
2362
|
+
const i = _.Time.Milli.fromMicro(r.timestamp), a = _.Time.Milli.fromMicro(s.latest), c = e.at(-1), o = t?.done && t.consumer.sequence + 1 === s.consumer.sequence;
|
|
2363
|
+
c && (c.end >= i || o) ? c.end = _.Time.Milli.max(c.end, a) : e.push({ start: i, end: a }), t = s;
|
|
2364
2364
|
}
|
|
2365
2365
|
this.#i.set(e);
|
|
2366
2366
|
}
|
|
@@ -2383,7 +2383,7 @@ async function Be() {
|
|
|
2383
2383
|
polyfill: !0
|
|
2384
2384
|
}), !0))), await we);
|
|
2385
2385
|
}
|
|
2386
|
-
const
|
|
2386
|
+
const Vs = `var __defProp = Object.defineProperty;
|
|
2387
2387
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2388
2388
|
var __esm = (fn, res) => function __init() {
|
|
2389
2389
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
@@ -5133,12 +5133,14 @@ init_stream();
|
|
|
5133
5133
|
var Version2 = {
|
|
5134
5134
|
DRAFT_01: 4279086337,
|
|
5135
5135
|
DRAFT_02: 4279086338,
|
|
5136
|
-
DRAFT_03: 4279086339
|
|
5136
|
+
DRAFT_03: 4279086339,
|
|
5137
|
+
DRAFT_04: 4279086340
|
|
5137
5138
|
};
|
|
5138
5139
|
var VERSION_NAMES2 = {
|
|
5139
5140
|
[Version2.DRAFT_01]: "moq-lite-01",
|
|
5140
5141
|
[Version2.DRAFT_02]: "moq-lite-02",
|
|
5141
|
-
[Version2.DRAFT_03]: "moq-lite-03"
|
|
5142
|
+
[Version2.DRAFT_03]: "moq-lite-03",
|
|
5143
|
+
[Version2.DRAFT_04]: "moq-lite-04"
|
|
5142
5144
|
};
|
|
5143
5145
|
|
|
5144
5146
|
// ../lite/src/lite/connection.ts
|
|
@@ -5390,14 +5392,14 @@ var AudioRingBuffer = class {
|
|
|
5390
5392
|
const dst = newBuffer[channel];
|
|
5391
5393
|
for (let i = 0; i < samplesToKeep; i++) {
|
|
5392
5394
|
const srcPos = (copyStart + i) % src.length;
|
|
5393
|
-
const dstPos = i % dst.length;
|
|
5395
|
+
const dstPos = (copyStart + i) % dst.length;
|
|
5394
5396
|
dst[dstPos] = src[srcPos];
|
|
5395
5397
|
}
|
|
5396
5398
|
}
|
|
5397
5399
|
}
|
|
5398
5400
|
this.#buffer = newBuffer;
|
|
5399
5401
|
this.#readIndex = this.#writeIndex - samplesToKeep;
|
|
5400
|
-
this.#stalled = true;
|
|
5402
|
+
if (samplesToKeep === 0) this.#stalled = true;
|
|
5401
5403
|
}
|
|
5402
5404
|
write(timestamp, data) {
|
|
5403
5405
|
if (data.length !== this.channels) throw new Error("wrong number of channels");
|
|
@@ -5494,7 +5496,7 @@ var Render = class extends AudioWorkletProcessor {
|
|
|
5494
5496
|
if (samplesRead < output[0].length) {
|
|
5495
5497
|
this.#underflow += output[0].length - samplesRead;
|
|
5496
5498
|
} else if (this.#underflow > 0 && this.#buffer) {
|
|
5497
|
-
console.
|
|
5499
|
+
console.debug(\`audio underflow: \${Math.round(1e3 * this.#underflow / this.#buffer.rate)}ms\`);
|
|
5498
5500
|
this.#underflow = 0;
|
|
5499
5501
|
}
|
|
5500
5502
|
this.#stateCounter++;
|
|
@@ -5511,23 +5513,23 @@ var Render = class extends AudioWorkletProcessor {
|
|
|
5511
5513
|
}
|
|
5512
5514
|
};
|
|
5513
5515
|
registerProcessor("render", Render);
|
|
5514
|
-
`,
|
|
5515
|
-
let
|
|
5516
|
+
`, Bs = new Blob([Vs], { type: "application/javascript" }), Ls = URL.createObjectURL(Bs);
|
|
5517
|
+
let $s = class {
|
|
5516
5518
|
source;
|
|
5517
5519
|
enabled;
|
|
5518
5520
|
#n = new h(void 0);
|
|
5519
5521
|
context = this.#n;
|
|
5520
5522
|
// The root of the audio graph, which can be used for custom visualizations.
|
|
5521
|
-
#
|
|
5523
|
+
#t = new h(void 0);
|
|
5522
5524
|
// Downcast to AudioNode so it matches Publish.Audio
|
|
5523
|
-
root = this.#
|
|
5525
|
+
root = this.#t;
|
|
5524
5526
|
#e = new h(void 0);
|
|
5525
5527
|
sampleRate = this.#e;
|
|
5526
|
-
#t = new h(void 0);
|
|
5527
|
-
stats = this.#t;
|
|
5528
|
-
// Current playback timestamp from worklet
|
|
5529
5528
|
#r = new h(void 0);
|
|
5530
|
-
|
|
5529
|
+
stats = this.#r;
|
|
5530
|
+
// Current playback timestamp from worklet
|
|
5531
|
+
#s = new h(void 0);
|
|
5532
|
+
timestamp = this.#s;
|
|
5531
5533
|
// Whether the audio buffer is stalled (waiting to fill)
|
|
5532
5534
|
#i = new h(!0);
|
|
5533
5535
|
stalled = this.#i;
|
|
@@ -5538,7 +5540,7 @@ let Ls = class {
|
|
|
5538
5540
|
buffered = this.#o;
|
|
5539
5541
|
#c = new T();
|
|
5540
5542
|
constructor(e, t) {
|
|
5541
|
-
this.source = e, this.source.supported.set(
|
|
5543
|
+
this.source = e, this.source.supported.set(js), this.enabled = h.from(t?.enabled ?? !1), this.#c.run(this.#d.bind(this)), this.#c.run(this.#l.bind(this)), this.#c.run(this.#u.bind(this)), this.#c.run(this.#f.bind(this));
|
|
5542
5544
|
}
|
|
5543
5545
|
#d(e) {
|
|
5544
5546
|
const t = e.get(this.source.config);
|
|
@@ -5549,25 +5551,25 @@ let Ls = class {
|
|
|
5549
5551
|
sampleRate: s
|
|
5550
5552
|
});
|
|
5551
5553
|
e.set(this.#n, i), e.cleanup(() => i.close()), e.spawn(async () => {
|
|
5552
|
-
if (await i.audioWorklet.addModule(
|
|
5554
|
+
if (await i.audioWorklet.addModule(Ls), i.state === "closed") return;
|
|
5553
5555
|
const a = new AudioWorkletNode(i, "render", {
|
|
5554
5556
|
channelCount: r,
|
|
5555
5557
|
channelCountMode: "explicit"
|
|
5556
5558
|
});
|
|
5557
5559
|
e.cleanup(() => a.disconnect());
|
|
5558
|
-
const
|
|
5560
|
+
const c = {
|
|
5559
5561
|
type: "init",
|
|
5560
5562
|
rate: s,
|
|
5561
5563
|
channels: r,
|
|
5562
|
-
latency: this.source.sync.
|
|
5564
|
+
latency: this.source.sync.buffer.peek()
|
|
5563
5565
|
// Updated reactively via #runLatency
|
|
5564
5566
|
};
|
|
5565
|
-
a.port.postMessage(
|
|
5566
|
-
if (
|
|
5567
|
-
const u =
|
|
5568
|
-
this.#
|
|
5567
|
+
a.port.postMessage(c), a.port.onmessage = (o) => {
|
|
5568
|
+
if (o.data.type === "state") {
|
|
5569
|
+
const u = p.Milli.fromMicro(o.data.timestamp);
|
|
5570
|
+
this.#s.set(u), this.#i.set(o.data.stalled), this.#v(u);
|
|
5569
5571
|
}
|
|
5570
|
-
}, e.set(this.#
|
|
5572
|
+
}, e.set(this.#t, a);
|
|
5571
5573
|
});
|
|
5572
5574
|
}
|
|
5573
5575
|
#l(e) {
|
|
@@ -5577,11 +5579,11 @@ let Ls = class {
|
|
|
5577
5579
|
r.resume();
|
|
5578
5580
|
}
|
|
5579
5581
|
#u(e) {
|
|
5580
|
-
const t = e.get(this.#
|
|
5582
|
+
const t = e.get(this.#t);
|
|
5581
5583
|
if (!t) return;
|
|
5582
5584
|
const r = {
|
|
5583
5585
|
type: "latency",
|
|
5584
|
-
latency: e.get(this.source.sync.
|
|
5586
|
+
latency: e.get(this.source.sync.buffer)
|
|
5585
5587
|
};
|
|
5586
5588
|
t.port.postMessage(r);
|
|
5587
5589
|
}
|
|
@@ -5595,20 +5597,20 @@ let Ls = class {
|
|
|
5595
5597
|
if (!i) return;
|
|
5596
5598
|
const a = e.get(s.active);
|
|
5597
5599
|
if (!a) return;
|
|
5598
|
-
const
|
|
5599
|
-
e.cleanup(() =>
|
|
5600
|
+
const c = a.subscribe(r, W.audio);
|
|
5601
|
+
e.cleanup(() => c.close()), i.container.kind === "cmaf" ? this.#p(e, c, i) : this.#m(e, c, i);
|
|
5600
5602
|
}
|
|
5601
5603
|
#m(e, t, s) {
|
|
5602
5604
|
const r = new J(t, {
|
|
5603
|
-
latency: this.source.sync.
|
|
5605
|
+
latency: this.source.sync.buffer
|
|
5604
5606
|
});
|
|
5605
5607
|
e.cleanup(() => r.close()), e.run((i) => {
|
|
5606
|
-
const a = i.get(r.buffered),
|
|
5607
|
-
this.#o.update(() =>
|
|
5608
|
+
const a = i.get(r.buffered), c = i.get(this.#a);
|
|
5609
|
+
this.#o.update(() => Gs(a, c));
|
|
5608
5610
|
}), e.spawn(async () => {
|
|
5609
5611
|
if (!await Be()) return;
|
|
5610
5612
|
let a = 0;
|
|
5611
|
-
const
|
|
5613
|
+
const c = new AudioDecoder({
|
|
5612
5614
|
output: (u) => {
|
|
5613
5615
|
if (a++, a <= 3) {
|
|
5614
5616
|
u.close();
|
|
@@ -5619,27 +5621,27 @@ let Ls = class {
|
|
|
5619
5621
|
error: (u) => console.error(u)
|
|
5620
5622
|
});
|
|
5621
5623
|
e.cleanup(() => {
|
|
5622
|
-
|
|
5624
|
+
c.state !== "closed" && c.close();
|
|
5623
5625
|
});
|
|
5624
|
-
const
|
|
5625
|
-
for (
|
|
5626
|
+
const o = s.description ? q(s.description) : void 0;
|
|
5627
|
+
for (c.configure({
|
|
5626
5628
|
...s,
|
|
5627
|
-
description:
|
|
5629
|
+
description: o
|
|
5628
5630
|
}); ; ) {
|
|
5629
5631
|
const u = await r.next();
|
|
5630
5632
|
if (!u) break;
|
|
5631
5633
|
const { frame: d } = u;
|
|
5632
5634
|
if (!d) continue;
|
|
5633
|
-
const l =
|
|
5634
|
-
this.source.sync.received(l, "audio"), this.#
|
|
5635
|
-
bytesReceived: (
|
|
5635
|
+
const l = p.Milli.fromMicro(d.timestamp);
|
|
5636
|
+
this.source.sync.received(l, "audio"), this.#r.update((w) => ({
|
|
5637
|
+
bytesReceived: (w?.bytesReceived ?? 0) + d.data.byteLength
|
|
5636
5638
|
}));
|
|
5637
5639
|
const f = new EncodedAudioChunk({
|
|
5638
5640
|
type: d.keyframe ? "key" : "delta",
|
|
5639
5641
|
data: d.data,
|
|
5640
5642
|
timestamp: d.timestamp
|
|
5641
5643
|
});
|
|
5642
|
-
|
|
5644
|
+
c.decode(f);
|
|
5643
5645
|
}
|
|
5644
5646
|
});
|
|
5645
5647
|
}
|
|
@@ -5647,66 +5649,66 @@ let Ls = class {
|
|
|
5647
5649
|
if (s.container.kind !== "cmaf") return;
|
|
5648
5650
|
const { timescale: r } = s.container, i = s.description ? q(s.description) : void 0;
|
|
5649
5651
|
e.run((a) => {
|
|
5650
|
-
const
|
|
5651
|
-
this.#o.update(() =>
|
|
5652
|
+
const c = a.get(this.#a);
|
|
5653
|
+
this.#o.update(() => c);
|
|
5652
5654
|
}), e.spawn(async () => {
|
|
5653
5655
|
if (!await Be()) return;
|
|
5654
|
-
const
|
|
5655
|
-
output: (
|
|
5656
|
-
error: (
|
|
5656
|
+
const c = new AudioDecoder({
|
|
5657
|
+
output: (o) => this.#h(o),
|
|
5658
|
+
error: (o) => console.error(o)
|
|
5657
5659
|
});
|
|
5658
5660
|
for (e.cleanup(() => {
|
|
5659
|
-
|
|
5660
|
-
}),
|
|
5661
|
+
c.state !== "closed" && c.close();
|
|
5662
|
+
}), c.configure({
|
|
5661
5663
|
codec: s.codec,
|
|
5662
5664
|
sampleRate: s.sampleRate,
|
|
5663
5665
|
numberOfChannels: s.numberOfChannels,
|
|
5664
5666
|
description: i
|
|
5665
5667
|
}); ; ) {
|
|
5666
|
-
const
|
|
5667
|
-
if (!
|
|
5668
|
+
const o = await t.nextGroup();
|
|
5669
|
+
if (!o) break;
|
|
5668
5670
|
e.spawn(async () => {
|
|
5669
5671
|
try {
|
|
5670
5672
|
for (; ; ) {
|
|
5671
|
-
const u = await
|
|
5673
|
+
const u = await o.readFrame();
|
|
5672
5674
|
if (!u) break;
|
|
5673
|
-
const d =
|
|
5675
|
+
const d = _n(u, r);
|
|
5674
5676
|
for (const l of d) {
|
|
5675
|
-
const f =
|
|
5676
|
-
this.source.sync.received(f, "audio"), this.#
|
|
5677
|
+
const f = p.Milli.fromMicro(l.timestamp);
|
|
5678
|
+
this.source.sync.received(f, "audio"), this.#r.update((b) => ({
|
|
5677
5679
|
bytesReceived: (b?.bytesReceived ?? 0) + l.data.byteLength
|
|
5678
5680
|
}));
|
|
5679
|
-
const
|
|
5681
|
+
const w = new EncodedAudioChunk({
|
|
5680
5682
|
type: l.keyframe ? "key" : "delta",
|
|
5681
5683
|
data: l.data,
|
|
5682
5684
|
timestamp: l.timestamp
|
|
5683
5685
|
});
|
|
5684
|
-
|
|
5686
|
+
c.decode(w);
|
|
5685
5687
|
}
|
|
5686
5688
|
}
|
|
5687
5689
|
} finally {
|
|
5688
|
-
|
|
5690
|
+
o.close();
|
|
5689
5691
|
}
|
|
5690
5692
|
});
|
|
5691
5693
|
}
|
|
5692
5694
|
});
|
|
5693
5695
|
}
|
|
5694
5696
|
#h(e) {
|
|
5695
|
-
const t = e.timestamp, s =
|
|
5697
|
+
const t = e.timestamp, s = p.Milli.fromMicro(t), r = this.#t.peek();
|
|
5696
5698
|
if (!r) {
|
|
5697
5699
|
e.close();
|
|
5698
5700
|
return;
|
|
5699
5701
|
}
|
|
5700
|
-
const i = e.numberOfFrames / e.sampleRate * 1e6, a =
|
|
5701
|
-
this.#w(s,
|
|
5702
|
-
const
|
|
5702
|
+
const i = e.numberOfFrames / e.sampleRate * 1e6, a = p.Milli.fromMicro(i), c = p.Milli.add(s, a);
|
|
5703
|
+
this.#w(s, c);
|
|
5704
|
+
const o = [];
|
|
5703
5705
|
for (let d = 0; d < e.numberOfChannels; d++) {
|
|
5704
5706
|
const l = new Float32Array(e.numberOfFrames);
|
|
5705
|
-
e.copyTo(l, { format: "f32-planar", planeIndex: d }),
|
|
5707
|
+
e.copyTo(l, { format: "f32-planar", planeIndex: d }), o.push(l);
|
|
5706
5708
|
}
|
|
5707
5709
|
const u = {
|
|
5708
5710
|
type: "data",
|
|
5709
|
-
data:
|
|
5711
|
+
data: o,
|
|
5710
5712
|
timestamp: t
|
|
5711
5713
|
};
|
|
5712
5714
|
r.port.postMessage(
|
|
@@ -5718,7 +5720,7 @@ let Ls = class {
|
|
|
5718
5720
|
e > t || this.#a.mutate((s) => {
|
|
5719
5721
|
for (const r of s)
|
|
5720
5722
|
if (e <= r.end + 1 && t >= r.start) {
|
|
5721
|
-
r.start =
|
|
5723
|
+
r.start = p.Milli.min(r.start, e), r.end = p.Milli.max(r.end, t);
|
|
5722
5724
|
return;
|
|
5723
5725
|
}
|
|
5724
5726
|
s.push({ start: e, end: t }), s.sort((r, i) => r.start - i.start);
|
|
@@ -5728,7 +5730,7 @@ let Ls = class {
|
|
|
5728
5730
|
this.#a.mutate((t) => {
|
|
5729
5731
|
for (; t.length > 0; ) {
|
|
5730
5732
|
if (t[0].end >= e) {
|
|
5731
|
-
t[0].start =
|
|
5733
|
+
t[0].start = p.Milli.max(t[0].start, e);
|
|
5732
5734
|
break;
|
|
5733
5735
|
}
|
|
5734
5736
|
t.shift();
|
|
@@ -5739,25 +5741,25 @@ let Ls = class {
|
|
|
5739
5741
|
this.#c.close();
|
|
5740
5742
|
}
|
|
5741
5743
|
};
|
|
5742
|
-
async function
|
|
5744
|
+
async function js(n) {
|
|
5743
5745
|
const e = n.description ? q(n.description) : void 0;
|
|
5744
5746
|
return (await AudioDecoder.isConfigSupported({
|
|
5745
5747
|
...n,
|
|
5746
5748
|
description: e
|
|
5747
5749
|
})).supported ?? !1;
|
|
5748
5750
|
}
|
|
5749
|
-
function
|
|
5751
|
+
function Gs(n, e) {
|
|
5750
5752
|
if (n.length === 0) return e;
|
|
5751
5753
|
if (e.length === 0) return n;
|
|
5752
5754
|
const t = [], s = [...n, ...e].sort((r, i) => r.start - i.start);
|
|
5753
5755
|
for (const r of s) {
|
|
5754
5756
|
const i = t.at(-1);
|
|
5755
|
-
i && i.end >= r.start ? i.end =
|
|
5757
|
+
i && i.end >= r.start ? i.end = p.Milli.max(i.end, r.end) : t.push({ ...r });
|
|
5756
5758
|
}
|
|
5757
5759
|
return t;
|
|
5758
5760
|
}
|
|
5759
5761
|
const Le = 1e-3, ve = 0.2;
|
|
5760
|
-
class
|
|
5762
|
+
class Zs {
|
|
5761
5763
|
source;
|
|
5762
5764
|
volume;
|
|
5763
5765
|
muted;
|
|
@@ -5766,12 +5768,12 @@ class Gs {
|
|
|
5766
5768
|
paused;
|
|
5767
5769
|
#n = new T();
|
|
5768
5770
|
// The volume to use when unmuted.
|
|
5769
|
-
#
|
|
5771
|
+
#t = 0.5;
|
|
5770
5772
|
// The gain node used to adjust the volume.
|
|
5771
5773
|
#e = new h(void 0);
|
|
5772
5774
|
constructor(e, t) {
|
|
5773
5775
|
this.source = e, this.volume = h.from(t?.volume ?? 0.5), this.muted = h.from(t?.muted ?? !1), this.paused = h.from(t?.paused ?? t?.muted ?? !1), this.#n.run((s) => {
|
|
5774
|
-
s.get(this.muted) ? (this.#
|
|
5776
|
+
s.get(this.muted) ? (this.#t = this.volume.peek() || 0.5, this.volume.set(0)) : this.volume.set(this.#t);
|
|
5775
5777
|
}), this.#n.run((s) => {
|
|
5776
5778
|
const r = !s.get(this.paused) && !s.get(this.muted);
|
|
5777
5779
|
this.source.enabled.set(r);
|
|
@@ -5797,17 +5799,17 @@ class Gs {
|
|
|
5797
5799
|
this.#n.close();
|
|
5798
5800
|
}
|
|
5799
5801
|
}
|
|
5800
|
-
class
|
|
5802
|
+
class Rn {
|
|
5801
5803
|
element;
|
|
5802
5804
|
paused;
|
|
5803
5805
|
#n;
|
|
5804
|
-
#
|
|
5805
|
-
mediaSource = this.#
|
|
5806
|
+
#t = new h(void 0);
|
|
5807
|
+
mediaSource = this.#t;
|
|
5806
5808
|
#e = new T();
|
|
5807
5809
|
constructor(e, t) {
|
|
5808
|
-
this.element = h.from(t?.element), this.paused = h.from(t?.paused ?? !1), this.#n = e, this.#e.run(this.#
|
|
5810
|
+
this.element = h.from(t?.element), this.paused = h.from(t?.paused ?? !1), this.#n = e, this.#e.run(this.#r.bind(this)), this.#e.run(this.#s.bind(this)), this.#e.run(this.#i.bind(this)), this.#e.run(this.#a.bind(this)), this.#e.run(this.#o.bind(this));
|
|
5809
5811
|
}
|
|
5810
|
-
#
|
|
5812
|
+
#r(e) {
|
|
5811
5813
|
const t = e.get(this.element);
|
|
5812
5814
|
if (!t) return;
|
|
5813
5815
|
const s = new MediaSource();
|
|
@@ -5815,22 +5817,22 @@ class In {
|
|
|
5815
5817
|
s,
|
|
5816
5818
|
"sourceopen",
|
|
5817
5819
|
() => {
|
|
5818
|
-
e.set(this.#
|
|
5820
|
+
e.set(this.#t, s);
|
|
5819
5821
|
},
|
|
5820
5822
|
{ once: !0 }
|
|
5821
5823
|
), e.event(s, "error", (r) => {
|
|
5822
5824
|
console.error("[MSE] MediaSource error event:", r);
|
|
5823
5825
|
});
|
|
5824
5826
|
}
|
|
5825
|
-
#
|
|
5827
|
+
#s(e) {
|
|
5826
5828
|
const t = e.get(this.element);
|
|
5827
5829
|
if (!t || e.get(this.paused)) return;
|
|
5828
|
-
const r =
|
|
5830
|
+
const r = p.Milli.toSecond(e.get(this.#n.buffer));
|
|
5829
5831
|
e.interval(() => {
|
|
5830
5832
|
const i = t.buffered;
|
|
5831
5833
|
if (i.length === 0) return;
|
|
5832
|
-
const
|
|
5833
|
-
(
|
|
5834
|
+
const c = i.end(i.length - 1) - r, o = c - t.currentTime;
|
|
5835
|
+
(o > 0.1 || o < -0.1) && (console.warn("seeking", o > 0 ? "forward" : "backward", Math.abs(o).toFixed(3), "seconds"), t.currentTime = c);
|
|
5834
5836
|
}, 100);
|
|
5835
5837
|
}
|
|
5836
5838
|
#i(e) {
|
|
@@ -5859,78 +5861,109 @@ class In {
|
|
|
5859
5861
|
if (!t || e.get(this.paused)) return;
|
|
5860
5862
|
const r = e.get(this.#n.reference);
|
|
5861
5863
|
if (r === void 0) return;
|
|
5862
|
-
const i = e.get(this.#n.
|
|
5863
|
-
t.currentTime =
|
|
5864
|
+
const i = e.get(this.#n.buffer), a = p.Milli.sub(p.Milli.sub(p.Milli.now(), r), i);
|
|
5865
|
+
t.currentTime = p.Milli.toSecond(a);
|
|
5864
5866
|
}
|
|
5865
5867
|
close() {
|
|
5866
5868
|
this.#e.close();
|
|
5867
5869
|
}
|
|
5868
5870
|
}
|
|
5869
|
-
const
|
|
5871
|
+
const gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5870
5872
|
__proto__: null,
|
|
5871
|
-
Muxer:
|
|
5872
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
5873
|
+
Muxer: Rn
|
|
5874
|
+
}, Symbol.toStringTag, { value: "Module" })), Xs = 10, $e = 100;
|
|
5873
5875
|
class Se {
|
|
5874
5876
|
// The earliest time we've received a frame, relative to its timestamp.
|
|
5875
5877
|
// This will keep being updated as we catch up to the live playhead then will be relatively static.
|
|
5876
|
-
// TODO Update this when RTT changes
|
|
5877
5878
|
#n = new h(void 0);
|
|
5878
5879
|
reference = this.#n;
|
|
5879
|
-
// The
|
|
5880
|
+
// The latency setting: "real-time" auto-computes jitter from RTT, a number sets a fixed jitter.
|
|
5881
|
+
latency;
|
|
5882
|
+
// The jitter buffer in milliseconds (always numeric).
|
|
5883
|
+
// In "real-time" mode this is updated automatically from RTT.
|
|
5884
|
+
// When latency is a number, jitter equals that number.
|
|
5880
5885
|
jitter;
|
|
5881
5886
|
// Any additional delay required for audio or video.
|
|
5882
5887
|
audio;
|
|
5883
5888
|
video;
|
|
5884
|
-
// The buffer required
|
|
5885
|
-
#
|
|
5886
|
-
|
|
5887
|
-
// A ghetto way to learn when the reference/
|
|
5889
|
+
// The total buffer required: jitter + max(audio, video).
|
|
5890
|
+
#t = new h(p.Milli.zero);
|
|
5891
|
+
buffer = this.#t;
|
|
5892
|
+
// A ghetto way to learn when the reference/buffer changes.
|
|
5888
5893
|
// There's probably a way to use Effect, but lets keep it simple for now.
|
|
5889
5894
|
#e;
|
|
5890
|
-
//
|
|
5891
|
-
|
|
5895
|
+
// The media timestamp of the most recently received frame.
|
|
5896
|
+
timestamp = new h(void 0);
|
|
5897
|
+
// Per-label tracking: minimum reference and late-frame stats.
|
|
5898
|
+
// The effective #reference is the max across all labels,
|
|
5899
|
+
// ensuring the slowest track sets the pace (late audio stalls early video).
|
|
5900
|
+
#r = /* @__PURE__ */ new Map();
|
|
5901
|
+
// RTT signal from the connection (PROBE or getStats).
|
|
5902
|
+
rtt;
|
|
5903
|
+
// Minimum RTT seen, used as the baseline for jitter calculation.
|
|
5904
|
+
// Avoids inflating jitter due to bufferbloat.
|
|
5905
|
+
#s;
|
|
5892
5906
|
signals = new T();
|
|
5893
5907
|
constructor(e) {
|
|
5894
|
-
this.
|
|
5908
|
+
this.latency = h.from(e?.latency ?? "real-time"), this.jitter = new h($e), this.rtt = e?.rtt, this.audio = h.from(e?.audio), this.video = h.from(e?.video), this.#e = Promise.withResolvers(), this.signals.run(this.#i.bind(this)), this.signals.run(this.#a.bind(this));
|
|
5895
5909
|
}
|
|
5896
|
-
#
|
|
5897
|
-
const t = e.get(this.
|
|
5898
|
-
|
|
5910
|
+
#i(e) {
|
|
5911
|
+
const t = e.get(this.latency);
|
|
5912
|
+
if (typeof t == "number") {
|
|
5913
|
+
this.#s = void 0, this.jitter.set(t);
|
|
5914
|
+
return;
|
|
5915
|
+
}
|
|
5916
|
+
if (this.rtt) {
|
|
5917
|
+
const s = e.get(this.rtt);
|
|
5918
|
+
if (s !== void 0) {
|
|
5919
|
+
this.#s = this.#s !== void 0 ? Math.min(this.#s, s) : s;
|
|
5920
|
+
const r = Math.max(Xs, this.#s * 1.25);
|
|
5921
|
+
this.jitter.set(r);
|
|
5922
|
+
return;
|
|
5923
|
+
}
|
|
5924
|
+
}
|
|
5925
|
+
this.#s = void 0, this.jitter.set($e);
|
|
5926
|
+
}
|
|
5927
|
+
#a(e) {
|
|
5928
|
+
const t = e.get(this.jitter), s = e.get(this.video) ?? p.Milli.zero, r = e.get(this.audio) ?? p.Milli.zero, i = p.Milli.add(p.Milli.max(s, r), t);
|
|
5929
|
+
this.#t.set(i), this.#e.resolve(), this.#e = Promise.withResolvers();
|
|
5899
5930
|
}
|
|
5900
|
-
// Update the reference if this is the earliest frame we've seen, relative to its timestamp.
|
|
5931
|
+
// Update the reference if this is the earliest frame we've seen for this label, relative to its timestamp.
|
|
5932
|
+
// The effective reference is the max across all labels so the slowest track sets the pace.
|
|
5901
5933
|
received(e, t = "") {
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
console.warn(`${c}: ${o.count} late frame(s), max ${u} behind`), this.#t.delete(t);
|
|
5913
|
-
}
|
|
5934
|
+
this.timestamp.update((o) => o === void 0 || e > o ? e : o);
|
|
5935
|
+
const s = p.Milli.now(), r = p.Milli.sub(s, e), i = this.#n.peek();
|
|
5936
|
+
let a = this.#r.get(t);
|
|
5937
|
+
if (a || (a = { ref: r, lateCount: 0, lateMaxMs: 0 }, this.#r.set(t, a)), i !== void 0) {
|
|
5938
|
+
const o = p.Milli.add(p.Milli.sub(i, r), this.#t.peek());
|
|
5939
|
+
if (o < 0)
|
|
5940
|
+
a.lateCount++, a.lateMaxMs = Math.max(a.lateMaxMs, -o);
|
|
5941
|
+
else if (a.lateCount > 0) {
|
|
5942
|
+
const u = t ? `sync[${t}]` : "sync", d = Se.#o(a.lateMaxMs);
|
|
5943
|
+
console.debug(`${u}: ${a.lateCount} late frame(s), max ${d} behind`), a.lateCount = 0, a.lateMaxMs = 0;
|
|
5914
5944
|
}
|
|
5915
|
-
if (r >= i)
|
|
5916
|
-
return;
|
|
5917
5945
|
}
|
|
5918
|
-
|
|
5946
|
+
if (r >= a.ref) return;
|
|
5947
|
+
a.ref = r;
|
|
5948
|
+
let c = r;
|
|
5949
|
+
for (const { ref: o } of this.#r.values())
|
|
5950
|
+
o > c && (c = o);
|
|
5951
|
+
i !== c && (this.#n.set(c), this.#e.resolve(), this.#e = Promise.withResolvers());
|
|
5919
5952
|
}
|
|
5920
5953
|
// Sleep until it's time to render this frame.
|
|
5921
5954
|
async wait(e) {
|
|
5922
5955
|
if (this.#n.peek() === void 0)
|
|
5923
5956
|
throw new Error("reference not set; call update() first");
|
|
5924
5957
|
for (; ; ) {
|
|
5925
|
-
const s =
|
|
5958
|
+
const s = p.Milli.now(), r = p.Milli.sub(s, e), i = this.#n.peek();
|
|
5926
5959
|
if (i === void 0) return;
|
|
5927
|
-
const a =
|
|
5928
|
-
if (a <= 0) return;
|
|
5929
|
-
const
|
|
5930
|
-
if (await Promise.race([this.#e.promise,
|
|
5960
|
+
const a = p.Milli.add(p.Milli.sub(i, r), this.#t.peek());
|
|
5961
|
+
if (a <= 0 || a < 5) return;
|
|
5962
|
+
const c = new Promise((u) => setTimeout(u, a)).then(() => !0);
|
|
5963
|
+
if (await Promise.race([this.#e.promise, c])) return;
|
|
5931
5964
|
}
|
|
5932
5965
|
}
|
|
5933
|
-
static #
|
|
5966
|
+
static #o(e) {
|
|
5934
5967
|
if (e = Math.round(e), e < 1e3) return `${e}ms`;
|
|
5935
5968
|
const t = e / 1e3;
|
|
5936
5969
|
if (t < 60) return `${Math.round(t * 10) / 10}s`;
|
|
@@ -5941,24 +5974,24 @@ class Se {
|
|
|
5941
5974
|
this.signals.close();
|
|
5942
5975
|
}
|
|
5943
5976
|
}
|
|
5944
|
-
const
|
|
5945
|
-
class
|
|
5977
|
+
const Hs = 500, Ws = 100;
|
|
5978
|
+
class Ks {
|
|
5946
5979
|
enabled;
|
|
5947
5980
|
// Don't download any longer
|
|
5948
5981
|
source;
|
|
5949
5982
|
// The current track running, held so we can cancel it when the new track is ready.
|
|
5950
5983
|
#n = new h(void 0);
|
|
5951
5984
|
// Expose the current frame to render as a signal
|
|
5952
|
-
#
|
|
5953
|
-
frame = this.#
|
|
5985
|
+
#t = new h(void 0);
|
|
5986
|
+
frame = this.#t;
|
|
5954
5987
|
// The timestamp of the current frame.
|
|
5955
5988
|
#e = new h(void 0);
|
|
5956
5989
|
timestamp = this.#e;
|
|
5957
5990
|
// The display size of the video in pixels, ideally sourced from the catalog.
|
|
5958
|
-
#
|
|
5959
|
-
display = this.#
|
|
5960
|
-
#
|
|
5961
|
-
stalled = this.#
|
|
5991
|
+
#r = new h(void 0);
|
|
5992
|
+
display = this.#r;
|
|
5993
|
+
#s = new h(!1);
|
|
5994
|
+
stalled = this.#s;
|
|
5962
5995
|
#i = new h(void 0);
|
|
5963
5996
|
stats = this.#i;
|
|
5964
5997
|
// Combined buffered ranges (network jitter + decode buffer)
|
|
@@ -5966,7 +5999,7 @@ class Hs {
|
|
|
5966
5999
|
buffered = this.#a;
|
|
5967
6000
|
#o = new T();
|
|
5968
6001
|
constructor(e, t) {
|
|
5969
|
-
this.enabled = h.from(t?.enabled ?? !1), this.source = e, this.source.supported.set(
|
|
6002
|
+
this.enabled = h.from(t?.enabled ?? !1), this.source = e, this.source.supported.set(Qs), this.#o.run(this.#c.bind(this)), this.#o.run(this.#d.bind(this)), this.#o.run(this.#l.bind(this)), this.#o.run(this.#u.bind(this));
|
|
5970
6003
|
}
|
|
5971
6004
|
#c(e) {
|
|
5972
6005
|
const t = e.getAll([this.enabled, this.source.broadcast, this.source.track, this.source.config]);
|
|
@@ -5974,23 +6007,23 @@ class Hs {
|
|
|
5974
6007
|
this.#n.set(void 0);
|
|
5975
6008
|
return;
|
|
5976
6009
|
}
|
|
5977
|
-
const [s, r, i, a] = t,
|
|
5978
|
-
if (!
|
|
5979
|
-
let
|
|
6010
|
+
const [s, r, i, a] = t, c = e.get(r.active);
|
|
6011
|
+
if (!c) return;
|
|
6012
|
+
let o = new Ys({
|
|
5980
6013
|
source: this.source,
|
|
5981
|
-
broadcast:
|
|
6014
|
+
broadcast: c,
|
|
5982
6015
|
track: i,
|
|
5983
6016
|
config: a,
|
|
5984
6017
|
stats: this.#i
|
|
5985
6018
|
});
|
|
5986
|
-
e.cleanup(() =>
|
|
5987
|
-
if (!
|
|
6019
|
+
e.cleanup(() => o?.close()), e.run((u) => {
|
|
6020
|
+
if (!o) return;
|
|
5988
6021
|
const d = u.get(this.#n);
|
|
5989
6022
|
if (d) {
|
|
5990
|
-
const l = u.get(
|
|
5991
|
-
if (!l || f && f > l +
|
|
6023
|
+
const l = u.get(o.timestamp), f = u.get(d.timestamp);
|
|
6024
|
+
if (!l || f && f > l + Ws) return;
|
|
5992
6025
|
}
|
|
5993
|
-
this.#n.set(
|
|
6026
|
+
this.#n.set(o), o = void 0, u.close();
|
|
5994
6027
|
});
|
|
5995
6028
|
}
|
|
5996
6029
|
#d(e) {
|
|
@@ -6001,7 +6034,7 @@ class Hs {
|
|
|
6001
6034
|
}
|
|
6002
6035
|
e.cleanup(() => t.close()), e.run((s) => {
|
|
6003
6036
|
const r = s.get(t.frame);
|
|
6004
|
-
this.#
|
|
6037
|
+
this.#t.update((i) => (i?.close(), r?.clone()));
|
|
6005
6038
|
}), e.proxy(this.#e, t.timestamp), e.proxy(this.#a, t.buffered);
|
|
6006
6039
|
}
|
|
6007
6040
|
#l(e) {
|
|
@@ -6009,14 +6042,14 @@ class Hs {
|
|
|
6009
6042
|
if (!t) return;
|
|
6010
6043
|
const s = t.display;
|
|
6011
6044
|
if (s) {
|
|
6012
|
-
e.set(this.#
|
|
6045
|
+
e.set(this.#r, {
|
|
6013
6046
|
width: s.width,
|
|
6014
6047
|
height: s.height
|
|
6015
6048
|
});
|
|
6016
6049
|
return;
|
|
6017
6050
|
}
|
|
6018
6051
|
const r = e.get(this.frame);
|
|
6019
|
-
r && e.set(this.#
|
|
6052
|
+
r && e.set(this.#r, {
|
|
6020
6053
|
width: r.displayWidth,
|
|
6021
6054
|
height: r.displayHeight
|
|
6022
6055
|
});
|
|
@@ -6024,20 +6057,20 @@ class Hs {
|
|
|
6024
6057
|
#u(e) {
|
|
6025
6058
|
if (!e.get(this.enabled)) return;
|
|
6026
6059
|
if (!e.get(this.frame)) {
|
|
6027
|
-
this.#
|
|
6060
|
+
this.#s.set(!0);
|
|
6028
6061
|
return;
|
|
6029
6062
|
}
|
|
6030
|
-
this.#
|
|
6031
|
-
this.#
|
|
6032
|
-
},
|
|
6063
|
+
this.#s.set(!1), e.timer(() => {
|
|
6064
|
+
this.#s.set(!0);
|
|
6065
|
+
}, Hs);
|
|
6033
6066
|
}
|
|
6034
6067
|
close() {
|
|
6035
|
-
this.#
|
|
6068
|
+
this.#t.update((e) => {
|
|
6036
6069
|
e?.close();
|
|
6037
6070
|
}), this.#o.close();
|
|
6038
6071
|
}
|
|
6039
6072
|
}
|
|
6040
|
-
class
|
|
6073
|
+
class Ys {
|
|
6041
6074
|
source;
|
|
6042
6075
|
broadcast;
|
|
6043
6076
|
track;
|
|
@@ -6052,22 +6085,22 @@ class Ws {
|
|
|
6052
6085
|
signals = new T();
|
|
6053
6086
|
constructor(e) {
|
|
6054
6087
|
const { codedWidth: t, codedHeight: s, ...r } = e.config;
|
|
6055
|
-
this.source = e.source, this.broadcast = e.broadcast, this.track = e.track, this.config = r, this.stats = e.stats, this.signals.run(this.#
|
|
6088
|
+
this.source = e.source, this.broadcast = e.broadcast, this.track = e.track, this.config = r, this.stats = e.stats, this.signals.run(this.#t.bind(this));
|
|
6056
6089
|
}
|
|
6057
|
-
#
|
|
6090
|
+
#t(e) {
|
|
6058
6091
|
const t = this.broadcast.subscribe(this.track, W.video);
|
|
6059
6092
|
e.cleanup(() => t.close());
|
|
6060
6093
|
const s = new VideoDecoder({
|
|
6061
6094
|
output: async (r) => {
|
|
6062
6095
|
try {
|
|
6063
|
-
const i =
|
|
6096
|
+
const i = p.Milli.fromMicro(r.timestamp);
|
|
6064
6097
|
if (i < (this.timestamp.peek() ?? 0))
|
|
6065
6098
|
return;
|
|
6066
6099
|
this.frame.peek() === void 0 && this.frame.set(r.clone());
|
|
6067
6100
|
const a = this.source.sync.wait(i).then(() => !0);
|
|
6068
6101
|
if (!await Promise.race([a, e.cancel]) || i < (this.timestamp.peek() ?? 0))
|
|
6069
6102
|
return;
|
|
6070
|
-
this.timestamp.set(i), this.#i(i), this.frame.update((
|
|
6103
|
+
this.timestamp.set(i), this.#i(i), this.frame.update((o) => (o?.close(), r.clone()));
|
|
6071
6104
|
} finally {
|
|
6072
6105
|
r.close();
|
|
6073
6106
|
}
|
|
@@ -6079,15 +6112,15 @@ class Ws {
|
|
|
6079
6112
|
});
|
|
6080
6113
|
e.cleanup(() => {
|
|
6081
6114
|
s.state !== "closed" && s.close();
|
|
6082
|
-
}), this.config.container.kind === "cmaf" ? this.#
|
|
6115
|
+
}), this.config.container.kind === "cmaf" ? this.#r(e, t, s) : this.#e(e, t, s);
|
|
6083
6116
|
}
|
|
6084
6117
|
#e(e, t, s) {
|
|
6085
6118
|
const r = new J(t, {
|
|
6086
|
-
latency: this.source.sync.
|
|
6119
|
+
latency: this.source.sync.buffer
|
|
6087
6120
|
});
|
|
6088
6121
|
e.cleanup(() => r.close()), e.run((a) => {
|
|
6089
|
-
const
|
|
6090
|
-
this.buffered.update(() =>
|
|
6122
|
+
const c = a.get(r.buffered), o = a.get(this.#n);
|
|
6123
|
+
this.buffered.update(() => Js(c, o));
|
|
6091
6124
|
}), s.configure({
|
|
6092
6125
|
...this.config,
|
|
6093
6126
|
description: this.config.description ? q(this.config.description) : void 0,
|
|
@@ -6100,34 +6133,34 @@ class Ws {
|
|
|
6100
6133
|
for (; ; ) {
|
|
6101
6134
|
const a = await Promise.race([r.next(), e.cancel]);
|
|
6102
6135
|
if (!a) break;
|
|
6103
|
-
const { frame:
|
|
6104
|
-
if (!
|
|
6136
|
+
const { frame: c, group: o } = a;
|
|
6137
|
+
if (!c) {
|
|
6105
6138
|
i && (i.final = !0);
|
|
6106
6139
|
continue;
|
|
6107
6140
|
}
|
|
6108
|
-
const u =
|
|
6141
|
+
const u = p.Milli.fromMicro(c.timestamp);
|
|
6109
6142
|
this.source.sync.received(u, "video");
|
|
6110
6143
|
const d = new EncodedVideoChunk({
|
|
6111
|
-
type:
|
|
6112
|
-
data:
|
|
6113
|
-
timestamp:
|
|
6144
|
+
type: c.keyframe ? "key" : "delta",
|
|
6145
|
+
data: c.data,
|
|
6146
|
+
timestamp: c.timestamp
|
|
6114
6147
|
});
|
|
6115
6148
|
if (this.stats.update((l) => ({
|
|
6116
6149
|
frameCount: (l?.frameCount ?? 0) + 1,
|
|
6117
|
-
bytesReceived: (l?.bytesReceived ?? 0) +
|
|
6118
|
-
})), i?.group ===
|
|
6119
|
-
const l =
|
|
6120
|
-
this.#
|
|
6150
|
+
bytesReceived: (l?.bytesReceived ?? 0) + c.data.byteLength
|
|
6151
|
+
})), i?.group === o || i?.final && i.group + 1 === o) {
|
|
6152
|
+
const l = p.Milli.fromMicro(i.timestamp), f = p.Milli.fromMicro(c.timestamp);
|
|
6153
|
+
this.#s(l, f);
|
|
6121
6154
|
}
|
|
6122
6155
|
i = {
|
|
6123
|
-
timestamp:
|
|
6124
|
-
group:
|
|
6156
|
+
timestamp: c.timestamp,
|
|
6157
|
+
group: o,
|
|
6125
6158
|
final: !1
|
|
6126
6159
|
}, s.decode(d);
|
|
6127
6160
|
}
|
|
6128
6161
|
});
|
|
6129
6162
|
}
|
|
6130
|
-
#
|
|
6163
|
+
#r(e, t, s) {
|
|
6131
6164
|
if (this.config.container.kind !== "cmaf") return;
|
|
6132
6165
|
const { timescale: r } = this.config.container, i = this.config.description ? q(this.config.description) : void 0;
|
|
6133
6166
|
s.configure({
|
|
@@ -6137,33 +6170,33 @@ class Ws {
|
|
|
6137
6170
|
// @ts-expect-error Only supported by Chrome, so the renderer has to flip manually.
|
|
6138
6171
|
flip: !1
|
|
6139
6172
|
}), e.run((a) => {
|
|
6140
|
-
const
|
|
6141
|
-
this.buffered.update(() =>
|
|
6173
|
+
const c = a.get(this.#n);
|
|
6174
|
+
this.buffered.update(() => c);
|
|
6142
6175
|
}), e.spawn(async () => {
|
|
6143
6176
|
for (; ; ) {
|
|
6144
6177
|
const a = await Promise.race([t.nextGroup(), e.cancel]);
|
|
6145
6178
|
if (!a) break;
|
|
6146
6179
|
e.spawn(async () => {
|
|
6147
|
-
let
|
|
6180
|
+
let c;
|
|
6148
6181
|
try {
|
|
6149
6182
|
for (; ; ) {
|
|
6150
|
-
const
|
|
6151
|
-
if (!
|
|
6152
|
-
const u =
|
|
6183
|
+
const o = await Promise.race([a.readFrame(), e.cancel]);
|
|
6184
|
+
if (!o) break;
|
|
6185
|
+
const u = _n(o, r);
|
|
6153
6186
|
for (const d of u) {
|
|
6154
6187
|
const l = new EncodedVideoChunk({
|
|
6155
6188
|
type: d.keyframe ? "key" : "delta",
|
|
6156
6189
|
data: d.data,
|
|
6157
6190
|
timestamp: d.timestamp
|
|
6158
|
-
}), f =
|
|
6159
|
-
if (this.source.sync.received(f, "video"), this.stats.update((
|
|
6160
|
-
frameCount: (
|
|
6161
|
-
bytesReceived: (
|
|
6162
|
-
})),
|
|
6163
|
-
const
|
|
6164
|
-
this.#
|
|
6191
|
+
}), f = p.Milli.fromMicro(d.timestamp);
|
|
6192
|
+
if (this.source.sync.received(f, "video"), this.stats.update((w) => ({
|
|
6193
|
+
frameCount: (w?.frameCount ?? 0) + 1,
|
|
6194
|
+
bytesReceived: (w?.bytesReceived ?? 0) + d.data.byteLength
|
|
6195
|
+
})), c !== void 0) {
|
|
6196
|
+
const w = p.Milli.fromMicro(c), b = p.Milli.fromMicro(d.timestamp);
|
|
6197
|
+
this.#s(w, b);
|
|
6165
6198
|
}
|
|
6166
|
-
|
|
6199
|
+
c = d.timestamp, s.decode(l);
|
|
6167
6200
|
}
|
|
6168
6201
|
}
|
|
6169
6202
|
} finally {
|
|
@@ -6174,11 +6207,11 @@ class Ws {
|
|
|
6174
6207
|
});
|
|
6175
6208
|
}
|
|
6176
6209
|
// Add a range to the decode buffer (decoded, waiting to render)
|
|
6177
|
-
#
|
|
6210
|
+
#s(e, t) {
|
|
6178
6211
|
e > t || this.#n.mutate((s) => {
|
|
6179
6212
|
for (const r of s)
|
|
6180
6213
|
if (r.start <= t && r.end >= e) {
|
|
6181
|
-
r.start =
|
|
6214
|
+
r.start = p.Milli.min(r.start, e), r.end = p.Milli.max(r.end, t);
|
|
6182
6215
|
return;
|
|
6183
6216
|
}
|
|
6184
6217
|
s.push({ start: e, end: t }), s.sort((r, i) => r.start - i.start);
|
|
@@ -6189,7 +6222,7 @@ class Ws {
|
|
|
6189
6222
|
this.#n.mutate((t) => {
|
|
6190
6223
|
for (; t.length > 0; ) {
|
|
6191
6224
|
if (t[0].end >= e) {
|
|
6192
|
-
t[0].start =
|
|
6225
|
+
t[0].start = p.Milli.max(t[0].start, e);
|
|
6193
6226
|
break;
|
|
6194
6227
|
}
|
|
6195
6228
|
t.shift();
|
|
@@ -6202,17 +6235,17 @@ class Ws {
|
|
|
6202
6235
|
});
|
|
6203
6236
|
}
|
|
6204
6237
|
}
|
|
6205
|
-
function
|
|
6238
|
+
function Js(n, e) {
|
|
6206
6239
|
if (n.length === 0) return e;
|
|
6207
6240
|
if (e.length === 0) return n;
|
|
6208
6241
|
const t = [], s = [...n, ...e].sort((r, i) => r.start - i.start);
|
|
6209
6242
|
for (const r of s) {
|
|
6210
6243
|
const i = t.at(-1);
|
|
6211
|
-
i && i.end >= r.start ? i.end =
|
|
6244
|
+
i && i.end >= r.start ? i.end = p.Milli.max(i.end, r.end) : t.push({ ...r });
|
|
6212
6245
|
}
|
|
6213
6246
|
return t;
|
|
6214
6247
|
}
|
|
6215
|
-
async function
|
|
6248
|
+
async function Qs(n) {
|
|
6216
6249
|
const e = n.description ? q(n.description) : void 0, { supported: t } = await VideoDecoder.isConfigSupported({
|
|
6217
6250
|
codec: n.codec,
|
|
6218
6251
|
description: e,
|
|
@@ -6220,23 +6253,23 @@ async function Ys(n) {
|
|
|
6220
6253
|
});
|
|
6221
6254
|
return t ?? !1;
|
|
6222
6255
|
}
|
|
6223
|
-
let
|
|
6256
|
+
let er = class {
|
|
6224
6257
|
muxer;
|
|
6225
6258
|
source;
|
|
6226
6259
|
// TODO implement stats
|
|
6227
6260
|
#n = new h(void 0);
|
|
6228
6261
|
stats = this.#n;
|
|
6229
|
-
#
|
|
6230
|
-
buffered = this.#
|
|
6262
|
+
#t = new h([]);
|
|
6263
|
+
buffered = this.#t;
|
|
6231
6264
|
#e = new h(!1);
|
|
6232
6265
|
stalled = this.#e;
|
|
6233
|
-
#
|
|
6234
|
-
timestamp = this.#
|
|
6266
|
+
#r = new h(_.Time.Milli.zero);
|
|
6267
|
+
timestamp = this.#r;
|
|
6235
6268
|
signals = new T();
|
|
6236
6269
|
constructor(e, t) {
|
|
6237
|
-
this.muxer = e, this.source = t, this.source.supported.set(
|
|
6270
|
+
this.muxer = e, this.source = t, this.source.supported.set(nr), this.signals.run(this.#s.bind(this)), this.signals.run(this.#c.bind(this)), this.signals.run(this.#d.bind(this));
|
|
6238
6271
|
}
|
|
6239
|
-
#
|
|
6272
|
+
#s(e) {
|
|
6240
6273
|
const t = e.get(this.muxer.element);
|
|
6241
6274
|
if (!t) return;
|
|
6242
6275
|
const s = e.get(this.muxer.mediaSource);
|
|
@@ -6247,16 +6280,16 @@ let Js = class {
|
|
|
6247
6280
|
if (!i) return;
|
|
6248
6281
|
const a = e.get(this.source.track);
|
|
6249
6282
|
if (!a) return;
|
|
6250
|
-
const
|
|
6251
|
-
if (!
|
|
6252
|
-
const
|
|
6283
|
+
const c = e.get(this.source.config);
|
|
6284
|
+
if (!c) return;
|
|
6285
|
+
const o = `video/mp4; codecs="${c.codec}"`, u = s.addSourceBuffer(o);
|
|
6253
6286
|
e.cleanup(() => {
|
|
6254
6287
|
s.removeSourceBuffer(u), u.abort();
|
|
6255
6288
|
}), e.event(u, "error", (d) => {
|
|
6256
6289
|
console.error("[MSE] SourceBuffer error:", d);
|
|
6257
6290
|
}), e.event(u, "updateend", () => {
|
|
6258
|
-
this.#
|
|
6259
|
-
}),
|
|
6291
|
+
this.#t.set(En(u.buffered));
|
|
6292
|
+
}), c.container.kind === "cmaf" ? this.#a(e, i, a, c, u, t) : this.#o(e, i, a, c, u, t);
|
|
6260
6293
|
}
|
|
6261
6294
|
async #i(e, t) {
|
|
6262
6295
|
for (; e.updating; )
|
|
@@ -6266,48 +6299,48 @@ let Js = class {
|
|
|
6266
6299
|
}
|
|
6267
6300
|
#a(e, t, s, r, i, a) {
|
|
6268
6301
|
if (r.container.kind !== "cmaf") throw new Error("unreachable");
|
|
6269
|
-
const
|
|
6270
|
-
e.cleanup(() =>
|
|
6271
|
-
const
|
|
6302
|
+
const c = t.subscribe(s, W.video);
|
|
6303
|
+
e.cleanup(() => c.close());
|
|
6304
|
+
const o = r.container.timescale;
|
|
6272
6305
|
e.spawn(async () => {
|
|
6273
6306
|
const u = Fe(r);
|
|
6274
6307
|
for (await this.#i(i, u); ; ) {
|
|
6275
|
-
const d = await
|
|
6308
|
+
const d = await c.readFrame();
|
|
6276
6309
|
if (!d) return;
|
|
6277
|
-
const l =
|
|
6310
|
+
const l = yn(d, o);
|
|
6278
6311
|
this.source.sync.received(_.Time.Milli.fromMicro(l), "video"), await this.#i(i, d), a.buffered.length > 0 && a.currentTime < a.buffered.start(0) && (a.currentTime = a.buffered.start(0));
|
|
6279
6312
|
}
|
|
6280
6313
|
});
|
|
6281
6314
|
}
|
|
6282
6315
|
#o(e, t, s, r, i, a) {
|
|
6283
|
-
const
|
|
6284
|
-
e.cleanup(() =>
|
|
6285
|
-
const
|
|
6286
|
-
latency: this.source.sync.
|
|
6316
|
+
const c = t.subscribe(s, W.video);
|
|
6317
|
+
e.cleanup(() => c.close());
|
|
6318
|
+
const o = new J(c, {
|
|
6319
|
+
latency: this.source.sync.buffer
|
|
6287
6320
|
});
|
|
6288
|
-
e.cleanup(() =>
|
|
6321
|
+
e.cleanup(() => o.close()), e.spawn(async () => {
|
|
6289
6322
|
const u = Fe(r);
|
|
6290
6323
|
await this.#i(i, u);
|
|
6291
6324
|
let d = 1, l, f;
|
|
6292
6325
|
for (; ; ) {
|
|
6293
|
-
const
|
|
6294
|
-
if (!
|
|
6295
|
-
if (!
|
|
6296
|
-
f =
|
|
6326
|
+
const w = await o.next();
|
|
6327
|
+
if (!w) return;
|
|
6328
|
+
if (!w.frame) continue;
|
|
6329
|
+
f = w.frame;
|
|
6297
6330
|
const b = _.Time.Milli.fromMicro(f.timestamp);
|
|
6298
6331
|
this.source.sync.received(b, "video");
|
|
6299
6332
|
break;
|
|
6300
6333
|
}
|
|
6301
6334
|
for (; ; ) {
|
|
6302
|
-
const
|
|
6303
|
-
if (
|
|
6304
|
-
const b =
|
|
6335
|
+
const w = await o.next();
|
|
6336
|
+
if (w && !w.frame) continue;
|
|
6337
|
+
const b = w?.frame;
|
|
6305
6338
|
if (b) {
|
|
6306
6339
|
l = _.Time.Micro.sub(b.timestamp, f.timestamp);
|
|
6307
6340
|
const R = _.Time.Milli.fromMicro(b.timestamp);
|
|
6308
6341
|
this.source.sync.received(R, "video");
|
|
6309
6342
|
}
|
|
6310
|
-
const g =
|
|
6343
|
+
const g = In({
|
|
6311
6344
|
data: f.data,
|
|
6312
6345
|
timestamp: f.timestamp,
|
|
6313
6346
|
duration: l ?? 0,
|
|
@@ -6336,38 +6369,40 @@ let Js = class {
|
|
|
6336
6369
|
let r;
|
|
6337
6370
|
const i = () => {
|
|
6338
6371
|
const a = _.Time.Milli.fromSecond(s.currentTime);
|
|
6339
|
-
this.#
|
|
6372
|
+
this.#r.set(a), r = s.requestVideoFrameCallback(i);
|
|
6340
6373
|
};
|
|
6341
6374
|
r = s.requestVideoFrameCallback(i), e.cleanup(() => s.cancelVideoFrameCallback(r));
|
|
6342
6375
|
} else
|
|
6343
6376
|
e.event(t, "timeupdate", () => {
|
|
6344
6377
|
const s = _.Time.Milli.fromSecond(t.currentTime);
|
|
6345
|
-
this.#
|
|
6378
|
+
this.#r.set(s);
|
|
6346
6379
|
});
|
|
6347
6380
|
}
|
|
6348
6381
|
close() {
|
|
6349
6382
|
this.source.close(), this.signals.close();
|
|
6350
6383
|
}
|
|
6351
6384
|
};
|
|
6352
|
-
async function
|
|
6385
|
+
async function nr(n) {
|
|
6353
6386
|
return MediaSource.isTypeSupported(`video/mp4; codecs="${n.codec}"`);
|
|
6354
6387
|
}
|
|
6355
|
-
class
|
|
6388
|
+
class tr {
|
|
6356
6389
|
decoder;
|
|
6357
6390
|
// The canvas to render the video to.
|
|
6358
6391
|
canvas;
|
|
6359
6392
|
// Whether the video is paused.
|
|
6360
6393
|
paused;
|
|
6361
|
-
//
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
#
|
|
6394
|
+
// The most recently rendered frame, updated after each rAF paint.
|
|
6395
|
+
frame = new h(void 0);
|
|
6396
|
+
// The media timestamp of the most recently rendered frame.
|
|
6397
|
+
timestamp = new h(void 0);
|
|
6398
|
+
#n = new h(void 0);
|
|
6399
|
+
#t = new h(!1);
|
|
6400
|
+
#e = new T();
|
|
6366
6401
|
constructor(e, t) {
|
|
6367
|
-
this.decoder = e, this.canvas = h.from(t?.canvas), this.paused = h.from(t?.paused ?? !1), this.#
|
|
6402
|
+
this.decoder = e, this.canvas = h.from(t?.canvas), this.paused = h.from(t?.paused ?? !1), this.#e.run((s) => {
|
|
6368
6403
|
const r = s.get(this.canvas);
|
|
6369
|
-
this.#
|
|
6370
|
-
}), this.#
|
|
6404
|
+
this.#n.set(r?.getContext("2d") ?? void 0);
|
|
6405
|
+
}), this.#e.run(this.#s.bind(this)), this.#e.run(this.#i.bind(this)), this.#e.run(this.#a.bind(this)), this.#e.run(this.#r.bind(this));
|
|
6371
6406
|
}
|
|
6372
6407
|
#r(e) {
|
|
6373
6408
|
const t = e.getAll([this.canvas, this.decoder.display]);
|
|
@@ -6376,47 +6411,49 @@ class er {
|
|
|
6376
6411
|
(s.width !== r.width || s.height !== r.height) && (s.width = r.width, s.height = r.height);
|
|
6377
6412
|
}
|
|
6378
6413
|
// Track whether the canvas is visible in the viewport and the tab is focused.
|
|
6379
|
-
#
|
|
6414
|
+
#s(e) {
|
|
6380
6415
|
const t = e.get(this.canvas);
|
|
6381
6416
|
if (!t) {
|
|
6382
|
-
this.#
|
|
6417
|
+
this.#t.set(!1);
|
|
6383
6418
|
return;
|
|
6384
6419
|
}
|
|
6385
6420
|
let s = !1;
|
|
6386
6421
|
const r = () => {
|
|
6387
|
-
this.#
|
|
6422
|
+
this.#t.set(s && !document.hidden);
|
|
6388
6423
|
}, i = new IntersectionObserver(
|
|
6389
6424
|
(a) => {
|
|
6390
|
-
for (const
|
|
6391
|
-
s =
|
|
6425
|
+
for (const c of a)
|
|
6426
|
+
s = c.isIntersecting, r();
|
|
6392
6427
|
},
|
|
6393
6428
|
{ threshold: 0.01 }
|
|
6394
6429
|
);
|
|
6395
|
-
e.event(document, "visibilitychange", r), i.observe(t), e.cleanup(() => i.disconnect()), e.cleanup(() => this.#
|
|
6430
|
+
e.event(document, "visibilitychange", r), i.observe(t), e.cleanup(() => i.disconnect()), e.cleanup(() => this.#t.set(!1));
|
|
6396
6431
|
}
|
|
6397
6432
|
// Detect when video should be downloaded.
|
|
6398
|
-
#
|
|
6399
|
-
const t = e.get(this.paused), s = e.get(this.#
|
|
6433
|
+
#i(e) {
|
|
6434
|
+
const t = e.get(this.paused), s = e.get(this.#t);
|
|
6400
6435
|
if (e.cleanup(() => this.decoder.enabled.set(!1)), !t) {
|
|
6401
6436
|
this.decoder.enabled.set(s);
|
|
6402
6437
|
return;
|
|
6403
6438
|
}
|
|
6404
|
-
const r = e.get(this.
|
|
6439
|
+
const r = e.get(this.frame);
|
|
6405
6440
|
this.decoder.enabled.set(!r);
|
|
6406
6441
|
}
|
|
6407
|
-
#
|
|
6408
|
-
const t = e.get(this.#
|
|
6442
|
+
#a(e) {
|
|
6443
|
+
const t = e.get(this.#n);
|
|
6409
6444
|
if (!t) return;
|
|
6410
|
-
|
|
6411
|
-
|
|
6445
|
+
const s = e.get(this.paused);
|
|
6446
|
+
let r;
|
|
6447
|
+
s || (r = e.get(this.decoder.frame));
|
|
6412
6448
|
let i = requestAnimationFrame(() => {
|
|
6413
|
-
|
|
6449
|
+
const a = r ?? this.frame.peek();
|
|
6450
|
+
this.#o(t, a), r && (this.frame.update((c) => (c?.close(), r.clone())), this.timestamp.set(p.Milli.fromMicro(r.timestamp))), i = void 0;
|
|
6414
6451
|
});
|
|
6415
6452
|
e.cleanup(() => {
|
|
6416
|
-
|
|
6453
|
+
r?.close(), i && cancelAnimationFrame(i);
|
|
6417
6454
|
});
|
|
6418
6455
|
}
|
|
6419
|
-
#
|
|
6456
|
+
#o(e, t) {
|
|
6420
6457
|
if (!t) {
|
|
6421
6458
|
e.fillStyle = "#000", e.fillRect(0, 0, e.canvas.width, e.canvas.height);
|
|
6422
6459
|
return;
|
|
@@ -6425,10 +6462,12 @@ class er {
|
|
|
6425
6462
|
}
|
|
6426
6463
|
// Close the track and all associated resources.
|
|
6427
6464
|
close() {
|
|
6428
|
-
this
|
|
6465
|
+
this.frame.update((e) => {
|
|
6466
|
+
e?.close();
|
|
6467
|
+
}), this.#e.close();
|
|
6429
6468
|
}
|
|
6430
6469
|
}
|
|
6431
|
-
function
|
|
6470
|
+
function sr(n) {
|
|
6432
6471
|
return (e) => {
|
|
6433
6472
|
const t = [], s = [];
|
|
6434
6473
|
for (const [r, i] of e)
|
|
@@ -6439,7 +6478,7 @@ function nr(n) {
|
|
|
6439
6478
|
return t.sort((r, i) => i.size - r.size), t.length > 0 ? t.map((r) => r.name) : s.length > 0 ? (s.sort((r, i) => r.size - i.size), [s[0].name]) : e.map(([r]) => r);
|
|
6440
6479
|
};
|
|
6441
6480
|
}
|
|
6442
|
-
function
|
|
6481
|
+
function rr(n) {
|
|
6443
6482
|
return (e) => {
|
|
6444
6483
|
const t = [], s = [];
|
|
6445
6484
|
for (const [r, i] of e)
|
|
@@ -6447,7 +6486,7 @@ function tr(n) {
|
|
|
6447
6486
|
return t.sort((r, i) => i.bitrate - r.bitrate), t.length > 0 ? t.map((r) => r.name) : s.length > 0 ? (s.sort((r, i) => r.bitrate - i.bitrate), [s[0].name]) : e.map(([r]) => r);
|
|
6448
6487
|
};
|
|
6449
6488
|
}
|
|
6450
|
-
function
|
|
6489
|
+
function ir(n) {
|
|
6451
6490
|
let e = n[0];
|
|
6452
6491
|
for (const t of n) {
|
|
6453
6492
|
const [, s] = t, [, r] = e, i = (s.codedWidth ?? 0) * (s.codedHeight ?? 0), a = (r.codedWidth ?? 0) * (r.codedHeight ?? 0);
|
|
@@ -6459,23 +6498,23 @@ function sr(n) {
|
|
|
6459
6498
|
}
|
|
6460
6499
|
return e[0];
|
|
6461
6500
|
}
|
|
6462
|
-
let
|
|
6501
|
+
let ar = class {
|
|
6463
6502
|
broadcast;
|
|
6464
6503
|
target;
|
|
6465
6504
|
#n = new h(void 0);
|
|
6466
6505
|
catalog = this.#n;
|
|
6467
|
-
#
|
|
6468
|
-
available = this.#
|
|
6506
|
+
#t = new h({});
|
|
6507
|
+
available = this.#t;
|
|
6469
6508
|
// The name of the active rendition.
|
|
6470
6509
|
#e = new h(void 0);
|
|
6471
6510
|
track = this.#e;
|
|
6472
|
-
#
|
|
6473
|
-
config = this.#
|
|
6511
|
+
#r = new h(void 0);
|
|
6512
|
+
config = this.#r;
|
|
6474
6513
|
sync;
|
|
6475
6514
|
supported;
|
|
6476
|
-
#
|
|
6515
|
+
#s = new T();
|
|
6477
6516
|
constructor(e, t) {
|
|
6478
|
-
this.broadcast = h.from(t?.broadcast), this.target = h.from(t?.target), this.sync = e, this.supported = h.from(t?.supported), this.#
|
|
6517
|
+
this.broadcast = h.from(t?.broadcast), this.target = h.from(t?.target), this.sync = e, this.supported = h.from(t?.supported), this.#s.run(this.#i.bind(this)), this.#s.run(this.#a.bind(this)), this.#s.run(this.#o.bind(this));
|
|
6479
6518
|
}
|
|
6480
6519
|
#i(e) {
|
|
6481
6520
|
const t = e.get(this.broadcast);
|
|
@@ -6491,18 +6530,35 @@ let rr = class {
|
|
|
6491
6530
|
const r = {};
|
|
6492
6531
|
for (const [i, a] of Object.entries(s))
|
|
6493
6532
|
await t(a) && (r[i] = a);
|
|
6494
|
-
Object.keys(r).length === 0 && Object.keys(s).length > 0 && console.warn("[Source] No supported video renditions found:", s), this.#
|
|
6533
|
+
Object.keys(r).length === 0 && Object.keys(s).length > 0 && console.warn("[Source] No supported video renditions found:", s), this.#t.set(r);
|
|
6495
6534
|
});
|
|
6496
6535
|
}
|
|
6497
6536
|
#o(e) {
|
|
6498
|
-
const t = e.get(this.#
|
|
6537
|
+
const t = e.get(this.#t);
|
|
6499
6538
|
if (Object.keys(t).length === 0) return;
|
|
6500
|
-
const s = e.get(this.target)
|
|
6539
|
+
const s = e.get(this.target);
|
|
6540
|
+
if (s?.name && s.name in t) {
|
|
6541
|
+
const o = t[s.name];
|
|
6542
|
+
e.set(this.#e, s.name), e.set(this.#r, o), e.set(this.sync.video, o.jitter);
|
|
6543
|
+
return;
|
|
6544
|
+
}
|
|
6545
|
+
let r = s;
|
|
6546
|
+
if (!s?.bitrate) {
|
|
6547
|
+
const o = e.get(this.broadcast), d = (o ? e.get(o.connection) : void 0)?.recvBandwidth;
|
|
6548
|
+
if (d) {
|
|
6549
|
+
const l = e.get(d);
|
|
6550
|
+
if (l != null) {
|
|
6551
|
+
const f = Math.round(l * 0.8);
|
|
6552
|
+
r = { ...s, bitrate: f };
|
|
6553
|
+
}
|
|
6554
|
+
}
|
|
6555
|
+
}
|
|
6556
|
+
const i = this.#c(t, r);
|
|
6501
6557
|
if (!i) return;
|
|
6502
6558
|
const a = t[i];
|
|
6503
|
-
e.set(this.#e, i), e.set(this.#
|
|
6504
|
-
const
|
|
6505
|
-
e.set(this.sync.video,
|
|
6559
|
+
e.set(this.#e, i), e.set(this.#r, a);
|
|
6560
|
+
const c = a.jitter ?? (a.framerate ? Math.ceil(1e3 / a.framerate) : void 0);
|
|
6561
|
+
e.set(this.sync.video, c);
|
|
6506
6562
|
}
|
|
6507
6563
|
/**
|
|
6508
6564
|
* Select the best rendition using a generic filter system.
|
|
@@ -6516,19 +6572,19 @@ let rr = class {
|
|
|
6516
6572
|
if (s.length === 0) return;
|
|
6517
6573
|
if (s.length === 1) return s[0][0];
|
|
6518
6574
|
const r = [];
|
|
6519
|
-
if (t?.pixels != null && r.push(
|
|
6520
|
-
return
|
|
6521
|
-
const i = r.map((
|
|
6522
|
-
for (const
|
|
6523
|
-
if (a.every((
|
|
6524
|
-
return
|
|
6575
|
+
if (t?.pixels != null && r.push(sr(t.pixels)), t?.bitrate != null && r.push(rr(t.bitrate)), r.length === 0)
|
|
6576
|
+
return ir(s);
|
|
6577
|
+
const i = r.map((c) => c(s)), a = i.map((c) => new Set(c));
|
|
6578
|
+
for (const c of i[0])
|
|
6579
|
+
if (a.every((o) => o.has(c)))
|
|
6580
|
+
return c;
|
|
6525
6581
|
console.warn("conflicting rendition filters, no rendition satisfies all criteria");
|
|
6526
6582
|
}
|
|
6527
6583
|
close() {
|
|
6528
|
-
this.#
|
|
6584
|
+
this.#s.close();
|
|
6529
6585
|
}
|
|
6530
6586
|
};
|
|
6531
|
-
function
|
|
6587
|
+
function En(n) {
|
|
6532
6588
|
const e = [];
|
|
6533
6589
|
for (let t = 0; t < n.length; t++) {
|
|
6534
6590
|
const s = _.Time.Milli.fromSecond(n.start(t)), r = _.Time.Milli.fromSecond(n.end(t));
|
|
@@ -6536,7 +6592,7 @@ function Rn(n) {
|
|
|
6536
6592
|
}
|
|
6537
6593
|
return e;
|
|
6538
6594
|
}
|
|
6539
|
-
class
|
|
6595
|
+
class or {
|
|
6540
6596
|
// The source of the video.
|
|
6541
6597
|
source;
|
|
6542
6598
|
// The stats of the video.
|
|
@@ -6551,7 +6607,7 @@ class ir {
|
|
|
6551
6607
|
this.source = e;
|
|
6552
6608
|
}
|
|
6553
6609
|
}
|
|
6554
|
-
class
|
|
6610
|
+
class cr {
|
|
6555
6611
|
source;
|
|
6556
6612
|
// The volume of the audio, between 0 and 1.
|
|
6557
6613
|
volume = new h(0.5);
|
|
@@ -6565,44 +6621,45 @@ class ar {
|
|
|
6565
6621
|
this.source = e;
|
|
6566
6622
|
}
|
|
6567
6623
|
}
|
|
6568
|
-
class
|
|
6624
|
+
class Sr {
|
|
6569
6625
|
element = new h(void 0);
|
|
6570
6626
|
broadcast;
|
|
6627
|
+
latency;
|
|
6571
6628
|
jitter;
|
|
6572
6629
|
paused;
|
|
6573
6630
|
video;
|
|
6574
6631
|
#n;
|
|
6575
6632
|
audio;
|
|
6576
|
-
#
|
|
6633
|
+
#t;
|
|
6577
6634
|
// Used to sync audio and video playback at a target delay.
|
|
6578
6635
|
#e;
|
|
6579
6636
|
signals = new T();
|
|
6580
6637
|
constructor(e) {
|
|
6581
|
-
this.element = h.from(e?.element), this.broadcast = h.from(e?.broadcast), this
|
|
6638
|
+
this.element = h.from(e?.element), this.broadcast = h.from(e?.broadcast), this.#e = new Se({ latency: e?.latency, rtt: e?.rtt }), this.latency = this.#e.latency, this.jitter = this.#e.jitter, this.#n = new ar(this.#e, {
|
|
6582
6639
|
broadcast: this.broadcast
|
|
6583
|
-
}), this.#
|
|
6640
|
+
}), this.#t = new fr(this.#e, {
|
|
6584
6641
|
broadcast: this.broadcast
|
|
6585
|
-
}), this.video = new
|
|
6642
|
+
}), this.video = new or(this.#n), this.audio = new cr(this.#t), this.paused = h.from(e?.paused ?? !1), this.signals.run(this.#r.bind(this));
|
|
6586
6643
|
}
|
|
6587
|
-
#
|
|
6644
|
+
#r(e) {
|
|
6588
6645
|
const t = e.get(this.element);
|
|
6589
|
-
t && (t instanceof HTMLCanvasElement ? this.#
|
|
6646
|
+
t && (t instanceof HTMLCanvasElement ? this.#s(e, t) : t instanceof HTMLVideoElement && this.#i(e, t));
|
|
6590
6647
|
}
|
|
6591
|
-
#
|
|
6592
|
-
const s = new
|
|
6648
|
+
#s(e, t) {
|
|
6649
|
+
const s = new Ks(this.#n), r = new $s(this.#t), i = new Zs(r, {
|
|
6593
6650
|
volume: this.audio.volume,
|
|
6594
6651
|
muted: this.audio.muted,
|
|
6595
6652
|
paused: this.paused
|
|
6596
|
-
}), a = new
|
|
6653
|
+
}), a = new tr(s, { canvas: t, paused: this.paused });
|
|
6597
6654
|
e.cleanup(() => {
|
|
6598
6655
|
s.close(), r.close(), i.close(), a.close();
|
|
6599
6656
|
}), e.proxy(this.video.stats, s.stats), e.proxy(this.video.buffered, s.buffered), e.proxy(this.video.stalled, s.stalled), e.proxy(this.video.timestamp, s.timestamp), e.proxy(this.audio.stats, r.stats), e.proxy(this.audio.buffered, r.buffered);
|
|
6600
6657
|
}
|
|
6601
6658
|
#i(e, t) {
|
|
6602
|
-
const s = new
|
|
6659
|
+
const s = new Rn(this.#e, {
|
|
6603
6660
|
paused: this.paused,
|
|
6604
6661
|
element: t
|
|
6605
|
-
}), r = new
|
|
6662
|
+
}), r = new er(s, this.#n), i = new ur(s, this.#t, {
|
|
6606
6663
|
volume: this.audio.volume,
|
|
6607
6664
|
muted: this.audio.muted
|
|
6608
6665
|
});
|
|
@@ -6614,20 +6671,20 @@ class br {
|
|
|
6614
6671
|
this.signals.close();
|
|
6615
6672
|
}
|
|
6616
6673
|
}
|
|
6617
|
-
class
|
|
6674
|
+
class ur {
|
|
6618
6675
|
muxer;
|
|
6619
6676
|
source;
|
|
6620
6677
|
volume;
|
|
6621
6678
|
muted;
|
|
6622
6679
|
#n = new h(void 0);
|
|
6623
6680
|
stats = this.#n;
|
|
6624
|
-
#
|
|
6625
|
-
buffered = this.#
|
|
6681
|
+
#t = new h([]);
|
|
6682
|
+
buffered = this.#t;
|
|
6626
6683
|
#e = new T();
|
|
6627
6684
|
constructor(e, t, s) {
|
|
6628
|
-
this.muxer = e, this.source = t, this.source.supported.set(
|
|
6685
|
+
this.muxer = e, this.source = t, this.source.supported.set(dr), this.volume = h.from(s?.volume ?? 0.5), this.muted = h.from(s?.muted ?? !1), this.#e.run(this.#r.bind(this)), this.#e.run(this.#o.bind(this));
|
|
6629
6686
|
}
|
|
6630
|
-
#
|
|
6687
|
+
#r(e) {
|
|
6631
6688
|
const t = e.get(this.muxer.element);
|
|
6632
6689
|
if (!t) return;
|
|
6633
6690
|
const s = e.get(this.muxer.mediaSource);
|
|
@@ -6638,20 +6695,20 @@ class or {
|
|
|
6638
6695
|
if (!i) return;
|
|
6639
6696
|
const a = e.get(this.source.track);
|
|
6640
6697
|
if (!a) return;
|
|
6641
|
-
const
|
|
6642
|
-
if (!
|
|
6643
|
-
const
|
|
6698
|
+
const c = e.get(this.source.config);
|
|
6699
|
+
if (!c) return;
|
|
6700
|
+
const o = `audio/mp4; codecs="${c.codec}"`, u = s.addSourceBuffer(o);
|
|
6644
6701
|
e.cleanup(() => {
|
|
6645
6702
|
s.removeSourceBuffer(u), u.abort();
|
|
6646
6703
|
}), e.event(u, "error", (l) => {
|
|
6647
6704
|
console.error("[MSE] SourceBuffer error:", l);
|
|
6648
6705
|
}), e.event(u, "updateend", () => {
|
|
6649
|
-
this.#
|
|
6706
|
+
this.#t.set(En(u.buffered));
|
|
6650
6707
|
});
|
|
6651
6708
|
const d = i.subscribe(a, W.audio);
|
|
6652
|
-
e.cleanup(() => d.close()),
|
|
6709
|
+
e.cleanup(() => d.close()), c.container.kind === "cmaf" ? this.#i(e, d, c, u, t) : this.#a(e, d, c, u, t);
|
|
6653
6710
|
}
|
|
6654
|
-
async #
|
|
6711
|
+
async #s(e, t) {
|
|
6655
6712
|
for (; e.updating; )
|
|
6656
6713
|
await new Promise((s) => e.addEventListener("updateend", s, { once: !0 }));
|
|
6657
6714
|
for (e.appendBuffer(t); e.updating; )
|
|
@@ -6661,23 +6718,23 @@ class or {
|
|
|
6661
6718
|
if (s.container.kind !== "cmaf") throw new Error("unreachable");
|
|
6662
6719
|
const a = s.container.timescale;
|
|
6663
6720
|
e.spawn(async () => {
|
|
6664
|
-
const
|
|
6665
|
-
for (await this.#
|
|
6666
|
-
const
|
|
6667
|
-
if (!
|
|
6668
|
-
const u =
|
|
6669
|
-
this.source.sync.received(_.Time.Milli.fromMicro(u), "audio"), await this.#
|
|
6721
|
+
const c = Ve(s);
|
|
6722
|
+
for (await this.#s(r, c); ; ) {
|
|
6723
|
+
const o = await t.readFrame();
|
|
6724
|
+
if (!o) return;
|
|
6725
|
+
const u = yn(o, a);
|
|
6726
|
+
this.source.sync.received(_.Time.Milli.fromMicro(u), "audio"), await this.#s(r, o), i.buffered.length > 0 && i.currentTime < i.buffered.start(0) && (i.currentTime = i.buffered.start(0));
|
|
6670
6727
|
}
|
|
6671
6728
|
});
|
|
6672
6729
|
}
|
|
6673
6730
|
#a(e, t, s, r, i) {
|
|
6674
6731
|
const a = new J(t, {
|
|
6675
|
-
latency: this.source.sync.
|
|
6732
|
+
latency: this.source.sync.buffer
|
|
6676
6733
|
});
|
|
6677
6734
|
e.cleanup(() => a.close()), e.spawn(async () => {
|
|
6678
|
-
const
|
|
6679
|
-
await this.#
|
|
6680
|
-
let
|
|
6735
|
+
const c = Ve(s);
|
|
6736
|
+
await this.#s(r, c);
|
|
6737
|
+
let o = 1, u, d;
|
|
6681
6738
|
for (; ; ) {
|
|
6682
6739
|
const l = await a.next();
|
|
6683
6740
|
if (!l) return;
|
|
@@ -6696,15 +6753,15 @@ class or {
|
|
|
6696
6753
|
const b = _.Time.Milli.fromMicro(f.timestamp);
|
|
6697
6754
|
this.source.sync.received(b, "audio");
|
|
6698
6755
|
}
|
|
6699
|
-
const
|
|
6756
|
+
const w = In({
|
|
6700
6757
|
data: d.data,
|
|
6701
6758
|
timestamp: d.timestamp,
|
|
6702
6759
|
duration: u ?? 0,
|
|
6703
6760
|
// Default to 0 duration if there's literally one frame then stream FIN.
|
|
6704
6761
|
keyframe: d.keyframe,
|
|
6705
|
-
sequence:
|
|
6762
|
+
sequence: o++
|
|
6706
6763
|
});
|
|
6707
|
-
if (await this.#
|
|
6764
|
+
if (await this.#s(r, w), i.buffered.length > 0 && i.currentTime < i.buffered.start(0) && (i.currentTime = i.buffered.start(0)), !f) return;
|
|
6708
6765
|
d = f;
|
|
6709
6766
|
}
|
|
6710
6767
|
});
|
|
@@ -6721,26 +6778,27 @@ class or {
|
|
|
6721
6778
|
this.#e.close();
|
|
6722
6779
|
}
|
|
6723
6780
|
}
|
|
6724
|
-
async function
|
|
6781
|
+
async function dr(n) {
|
|
6725
6782
|
return MediaSource.isTypeSupported(`audio/mp4; codecs="${n.codec}"`);
|
|
6726
6783
|
}
|
|
6727
|
-
|
|
6784
|
+
const lr = 128, hr = 5;
|
|
6785
|
+
class fr {
|
|
6728
6786
|
broadcast;
|
|
6729
6787
|
target;
|
|
6730
6788
|
#n = new h(void 0);
|
|
6731
6789
|
catalog = this.#n;
|
|
6732
|
-
#
|
|
6733
|
-
available = this.#
|
|
6790
|
+
#t = new h({});
|
|
6791
|
+
available = this.#t;
|
|
6734
6792
|
#e = new h(void 0);
|
|
6735
6793
|
track = this.#e;
|
|
6736
|
-
#
|
|
6737
|
-
config = this.#
|
|
6794
|
+
#r = new h(void 0);
|
|
6795
|
+
config = this.#r;
|
|
6738
6796
|
supported;
|
|
6739
6797
|
// Used to target a latency and synchronize playback of video with audio.
|
|
6740
6798
|
sync;
|
|
6741
|
-
#
|
|
6799
|
+
#s = new T();
|
|
6742
6800
|
constructor(e, t) {
|
|
6743
|
-
this.sync = e, this.broadcast = h.from(t?.broadcast), this.target = h.from(t?.target), this.supported = h.from(t?.supported), this.#
|
|
6801
|
+
this.sync = e, this.broadcast = h.from(t?.broadcast), this.target = h.from(t?.target), this.supported = h.from(t?.supported), this.#s.run(this.#i.bind(this)), this.#s.run(this.#a.bind(this)), this.#s.run(this.#o.bind(this));
|
|
6744
6802
|
}
|
|
6745
6803
|
#i(e) {
|
|
6746
6804
|
const t = e.get(this.broadcast);
|
|
@@ -6754,20 +6812,20 @@ class ur {
|
|
|
6754
6812
|
const r = {};
|
|
6755
6813
|
for (const [i, a] of Object.entries(t))
|
|
6756
6814
|
await s(a) && (r[i] = a);
|
|
6757
|
-
Object.keys(r).length === 0 && Object.keys(t).length > 0 && console.warn("no supported audio renditions found:", t), this.#
|
|
6815
|
+
Object.keys(r).length === 0 && Object.keys(t).length > 0 && console.warn("no supported audio renditions found:", t), this.#t.set(r);
|
|
6758
6816
|
});
|
|
6759
6817
|
}
|
|
6760
6818
|
#o(e) {
|
|
6761
|
-
const t = e.get(this.#
|
|
6819
|
+
const t = e.get(this.#t);
|
|
6762
6820
|
if (Object.keys(t).length === 0) return;
|
|
6763
6821
|
const s = e.get(this.target);
|
|
6764
6822
|
let r;
|
|
6765
6823
|
if (s?.name && s.name in t)
|
|
6766
6824
|
r = { track: s.name, config: t[s.name] };
|
|
6767
6825
|
else if (r = this.#c(t), !r) return;
|
|
6768
|
-
e.set(this.#e, r.track), e.set(this.#
|
|
6769
|
-
const i = r.config.jitter ??
|
|
6770
|
-
e.set(this.sync.audio,
|
|
6826
|
+
e.set(this.#e, r.track), e.set(this.#r, r.config);
|
|
6827
|
+
const i = r.config.jitter ?? mr(r.config) ?? 0, a = Math.ceil(lr / r.config.sampleRate * 1e3) + hr, c = i + a;
|
|
6828
|
+
e.set(this.sync.audio, c);
|
|
6771
6829
|
}
|
|
6772
6830
|
/**
|
|
6773
6831
|
* Select rendition based on the configured strategy.
|
|
@@ -6784,16 +6842,16 @@ class ur {
|
|
|
6784
6842
|
}
|
|
6785
6843
|
}
|
|
6786
6844
|
close() {
|
|
6787
|
-
this.#
|
|
6845
|
+
this.#s.close();
|
|
6788
6846
|
}
|
|
6789
6847
|
}
|
|
6790
|
-
function
|
|
6848
|
+
function mr(n) {
|
|
6791
6849
|
if (n.codec.startsWith("opus"))
|
|
6792
6850
|
return 20;
|
|
6793
6851
|
if (n.codec.startsWith("mp4a"))
|
|
6794
6852
|
return Math.ceil(1024 / n.sampleRate * 1e3);
|
|
6795
6853
|
}
|
|
6796
|
-
class
|
|
6854
|
+
class kr {
|
|
6797
6855
|
connection;
|
|
6798
6856
|
enabled;
|
|
6799
6857
|
name;
|
|
@@ -6801,21 +6859,21 @@ class gr {
|
|
|
6801
6859
|
reload;
|
|
6802
6860
|
#n = new h(void 0);
|
|
6803
6861
|
active = this.#n;
|
|
6804
|
-
#
|
|
6805
|
-
catalog = this.#
|
|
6862
|
+
#t = new h(void 0);
|
|
6863
|
+
catalog = this.#t;
|
|
6806
6864
|
// All actively announced broadcast paths from the connection.
|
|
6807
6865
|
#e;
|
|
6808
6866
|
signals = new T();
|
|
6809
6867
|
constructor(e) {
|
|
6810
|
-
this.connection = h.from(e?.connection), this.name = h.from(e?.name ??
|
|
6868
|
+
this.connection = h.from(e?.connection), this.name = h.from(e?.name ?? zn.empty()), this.enabled = h.from(e?.enabled ?? !1), this.reload = h.from(e?.reload ?? !1), this.#e = e?.announced ?? new h(/* @__PURE__ */ new Set()), this.signals.run(this.#s.bind(this)), this.signals.run(this.#i.bind(this));
|
|
6811
6869
|
}
|
|
6812
|
-
#
|
|
6870
|
+
#r(e) {
|
|
6813
6871
|
if (!e.get(this.reload)) return !0;
|
|
6814
6872
|
const s = e.get(this.name);
|
|
6815
6873
|
return e.get(this.#e).has(s);
|
|
6816
6874
|
}
|
|
6817
|
-
#
|
|
6818
|
-
if (!e.get(this.enabled) || !this.#
|
|
6875
|
+
#s(e) {
|
|
6876
|
+
if (!e.get(this.enabled) || !this.#r(e)) return;
|
|
6819
6877
|
const s = e.get(this.connection);
|
|
6820
6878
|
if (!s) return;
|
|
6821
6879
|
const r = e.get(this.name), i = s.consume(r);
|
|
@@ -6830,14 +6888,14 @@ class gr {
|
|
|
6830
6888
|
e.cleanup(() => i.close()), e.spawn(async () => {
|
|
6831
6889
|
try {
|
|
6832
6890
|
for (; ; ) {
|
|
6833
|
-
const a = await Promise.race([e.cancel,
|
|
6891
|
+
const a = await Promise.race([e.cancel, Wt(i)]);
|
|
6834
6892
|
if (!a) break;
|
|
6835
|
-
console.debug("received catalog", this.name.peek(), a), this.#
|
|
6893
|
+
console.debug("received catalog", this.name.peek(), a), this.#t.set(a), this.status.set("live");
|
|
6836
6894
|
}
|
|
6837
6895
|
} catch (a) {
|
|
6838
6896
|
console.warn("error fetching catalog", this.name.peek(), a);
|
|
6839
6897
|
} finally {
|
|
6840
|
-
this.#
|
|
6898
|
+
this.#t.set(void 0), this.status.set("offline");
|
|
6841
6899
|
}
|
|
6842
6900
|
});
|
|
6843
6901
|
}
|
|
@@ -6846,25 +6904,25 @@ class gr {
|
|
|
6846
6904
|
}
|
|
6847
6905
|
}
|
|
6848
6906
|
export {
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6907
|
+
kr as B,
|
|
6908
|
+
Ks as D,
|
|
6909
|
+
Zs as E,
|
|
6910
|
+
er as M,
|
|
6853
6911
|
W as P,
|
|
6854
|
-
|
|
6855
|
-
|
|
6912
|
+
tr as R,
|
|
6913
|
+
ar as S,
|
|
6856
6914
|
m as a,
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6915
|
+
an as b,
|
|
6916
|
+
$s as c,
|
|
6917
|
+
ur as d,
|
|
6918
|
+
fr as e,
|
|
6919
|
+
vr as f,
|
|
6920
|
+
ln as g,
|
|
6921
|
+
Sr as h,
|
|
6864
6922
|
Se as i,
|
|
6865
|
-
|
|
6923
|
+
gr as m,
|
|
6866
6924
|
S as o,
|
|
6867
6925
|
y as s,
|
|
6868
|
-
|
|
6926
|
+
En as t
|
|
6869
6927
|
};
|
|
6870
|
-
//# sourceMappingURL=broadcast-
|
|
6928
|
+
//# sourceMappingURL=broadcast-CZkbruBC.js.map
|