@moq/watch 0.2.8 → 0.2.10
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/{broadcast-BMWX8K5V.js → broadcast-BImEYz4N.js} +1080 -781
- package/broadcast-BImEYz4N.js.map +1 -0
- package/broadcast.d.ts +3 -0
- package/broadcast.d.ts.map +1 -1
- package/element.d.ts +5 -3
- package/element.d.ts.map +1 -1
- package/element.js +32 -21
- package/element.js.map +1 -1
- package/index.js +2 -2
- package/msf.d.ts +5 -0
- package/msf.d.ts.map +1 -0
- package/package.json +4 -3
- package/broadcast-BMWX8K5V.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { Time as
|
|
3
|
-
import { Signal as h, Effect as
|
|
1
|
+
import * as _ from "@moq/lite";
|
|
2
|
+
import { Time as p, Path as Ht } from "@moq/lite";
|
|
3
|
+
import { Signal as h, Effect as U } from "@moq/signals";
|
|
4
4
|
function w(t, e, n) {
|
|
5
5
|
function s(a, c) {
|
|
6
6
|
if (a._zod || Object.defineProperty(a, "_zod", {
|
|
@@ -35,24 +35,28 @@ function w(t, e, n) {
|
|
|
35
35
|
value: (a) => n?.Parent && a instanceof n.Parent ? !0 : a?._zod?.traits?.has(t)
|
|
36
36
|
}), Object.defineProperty(o, "name", { value: t }), o;
|
|
37
37
|
}
|
|
38
|
-
class
|
|
38
|
+
class Q extends Error {
|
|
39
39
|
constructor() {
|
|
40
40
|
super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
class
|
|
43
|
+
class Gt extends Error {
|
|
44
44
|
constructor(e) {
|
|
45
45
|
super(`Encountered unidirectional transform during encode: ${e}`), this.name = "ZodEncodeError";
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
const
|
|
49
|
-
function
|
|
50
|
-
return
|
|
48
|
+
const Xt = {};
|
|
49
|
+
function ne(t) {
|
|
50
|
+
return Xt;
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function Yt(t) {
|
|
53
|
+
const e = Object.values(t).filter((s) => typeof s == "number");
|
|
54
|
+
return Object.entries(t).filter(([s, i]) => e.indexOf(+s) === -1).map(([s, i]) => i);
|
|
55
|
+
}
|
|
56
|
+
function Kt(t, e) {
|
|
53
57
|
return typeof e == "bigint" ? e.toString() : e;
|
|
54
58
|
}
|
|
55
|
-
function
|
|
59
|
+
function ot(t) {
|
|
56
60
|
return {
|
|
57
61
|
get value() {
|
|
58
62
|
{
|
|
@@ -62,17 +66,17 @@ function Ke(t) {
|
|
|
62
66
|
}
|
|
63
67
|
};
|
|
64
68
|
}
|
|
65
|
-
function
|
|
69
|
+
function at(t) {
|
|
66
70
|
const e = t.startsWith("^") ? 1 : 0, n = t.endsWith("$") ? t.length - 1 : t.length;
|
|
67
71
|
return t.slice(e, n);
|
|
68
72
|
}
|
|
69
|
-
const
|
|
70
|
-
function
|
|
73
|
+
const Pe = /* @__PURE__ */ Symbol("evaluating");
|
|
74
|
+
function R(t, e, n) {
|
|
71
75
|
let s;
|
|
72
76
|
Object.defineProperty(t, e, {
|
|
73
77
|
get() {
|
|
74
|
-
if (s !==
|
|
75
|
-
return s === void 0 && (s =
|
|
78
|
+
if (s !== Pe)
|
|
79
|
+
return s === void 0 && (s = Pe, s = n()), s;
|
|
76
80
|
},
|
|
77
81
|
set(i) {
|
|
78
82
|
Object.defineProperty(t, e, {
|
|
@@ -83,44 +87,45 @@ function U(t, e, n) {
|
|
|
83
87
|
configurable: !0
|
|
84
88
|
});
|
|
85
89
|
}
|
|
86
|
-
const
|
|
90
|
+
const ct = "captureStackTrace" in Error ? Error.captureStackTrace : (...t) => {
|
|
87
91
|
};
|
|
88
|
-
function
|
|
92
|
+
function ge(t) {
|
|
89
93
|
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
90
94
|
}
|
|
91
|
-
function
|
|
92
|
-
if (
|
|
95
|
+
function ut(t) {
|
|
96
|
+
if (ge(t) === !1)
|
|
93
97
|
return !1;
|
|
94
98
|
const e = t.constructor;
|
|
95
99
|
if (e === void 0 || typeof e != "function")
|
|
96
100
|
return !0;
|
|
97
101
|
const n = e.prototype;
|
|
98
|
-
return !(
|
|
102
|
+
return !(ge(n) === !1 || Object.prototype.hasOwnProperty.call(n, "isPrototypeOf") === !1);
|
|
99
103
|
}
|
|
100
|
-
function
|
|
101
|
-
return
|
|
104
|
+
function Jt(t) {
|
|
105
|
+
return ut(t) ? { ...t } : Array.isArray(t) ? [...t] : t;
|
|
102
106
|
}
|
|
103
|
-
|
|
107
|
+
const Qt = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
|
|
108
|
+
function ke(t) {
|
|
104
109
|
return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
105
110
|
}
|
|
106
|
-
function
|
|
111
|
+
function en(t, e, n) {
|
|
107
112
|
const s = new t._zod.constr(e ?? t._zod.def);
|
|
108
113
|
return (!e || n?.parent) && (s._zod.parent = t), s;
|
|
109
114
|
}
|
|
110
|
-
function
|
|
115
|
+
function O(t) {
|
|
111
116
|
return {};
|
|
112
117
|
}
|
|
113
|
-
function
|
|
118
|
+
function tn(t) {
|
|
114
119
|
return Object.keys(t).filter((e) => t[e]._zod.optin === "optional" && t[e]._zod.optout === "optional");
|
|
115
120
|
}
|
|
116
|
-
const
|
|
121
|
+
const nn = {
|
|
117
122
|
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
118
123
|
int32: [-2147483648, 2147483647],
|
|
119
124
|
uint32: [0, 4294967295],
|
|
120
125
|
float32: [-34028234663852886e22, 34028234663852886e22],
|
|
121
126
|
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
122
127
|
};
|
|
123
|
-
function
|
|
128
|
+
function ce(t, e = 0) {
|
|
124
129
|
if (t.aborted === !0)
|
|
125
130
|
return !0;
|
|
126
131
|
for (let n = e; n < t.issues.length; n++)
|
|
@@ -128,79 +133,79 @@ function re(t, e = 0) {
|
|
|
128
133
|
return !0;
|
|
129
134
|
return !1;
|
|
130
135
|
}
|
|
131
|
-
function
|
|
136
|
+
function J(t, e) {
|
|
132
137
|
return e.map((n) => {
|
|
133
138
|
var s;
|
|
134
139
|
return (s = n).path ?? (s.path = []), n.path.unshift(t), n;
|
|
135
140
|
});
|
|
136
141
|
}
|
|
137
|
-
function
|
|
142
|
+
function me(t) {
|
|
138
143
|
return typeof t == "string" ? t : t?.message;
|
|
139
144
|
}
|
|
140
|
-
function
|
|
145
|
+
function se(t, e, n) {
|
|
141
146
|
const s = { ...t, path: t.path ?? [] };
|
|
142
147
|
if (!t.message) {
|
|
143
|
-
const i =
|
|
148
|
+
const i = me(t.inst?._zod.def?.error?.(t)) ?? me(e?.error?.(t)) ?? me(n.customError?.(t)) ?? me(n.localeError?.(t)) ?? "Invalid input";
|
|
144
149
|
s.message = i;
|
|
145
150
|
}
|
|
146
151
|
return delete s.inst, delete s.continue, e?.reportInput || delete s.input, s;
|
|
147
152
|
}
|
|
148
|
-
const
|
|
153
|
+
const lt = (t, e) => {
|
|
149
154
|
t.name = "$ZodError", Object.defineProperty(t, "_zod", {
|
|
150
155
|
value: t._zod,
|
|
151
156
|
enumerable: !1
|
|
152
157
|
}), Object.defineProperty(t, "issues", {
|
|
153
158
|
value: e,
|
|
154
159
|
enumerable: !1
|
|
155
|
-
}), t.message = JSON.stringify(e,
|
|
160
|
+
}), t.message = JSON.stringify(e, Kt, 2), Object.defineProperty(t, "toString", {
|
|
156
161
|
value: () => t.message,
|
|
157
162
|
enumerable: !1
|
|
158
163
|
});
|
|
159
|
-
},
|
|
164
|
+
}, sn = w("$ZodError", lt), ve = w("$ZodError", lt, { Parent: Error }), rn = (t) => (e, n, s, i) => {
|
|
160
165
|
const r = s ? Object.assign(s, { async: !1 }) : { async: !1 }, o = e._zod.run({ value: n, issues: [] }, r);
|
|
161
166
|
if (o instanceof Promise)
|
|
162
|
-
throw new
|
|
167
|
+
throw new Q();
|
|
163
168
|
if (o.issues.length) {
|
|
164
|
-
const a = new (i?.Err ?? t)(o.issues.map((c) =>
|
|
165
|
-
throw
|
|
169
|
+
const a = new (i?.Err ?? t)(o.issues.map((c) => se(c, r, ne())));
|
|
170
|
+
throw ct(a, i?.callee), a;
|
|
166
171
|
}
|
|
167
172
|
return o.value;
|
|
168
|
-
},
|
|
173
|
+
}, on = /* @__PURE__ */ rn(ve), an = (t) => async (e, n, s, i) => {
|
|
169
174
|
const r = s ? Object.assign(s, { async: !0 }) : { async: !0 };
|
|
170
175
|
let o = e._zod.run({ value: n, issues: [] }, r);
|
|
171
176
|
if (o instanceof Promise && (o = await o), o.issues.length) {
|
|
172
|
-
const a = new (i?.Err ?? t)(o.issues.map((c) =>
|
|
173
|
-
throw
|
|
177
|
+
const a = new (i?.Err ?? t)(o.issues.map((c) => se(c, r, ne())));
|
|
178
|
+
throw ct(a, i?.callee), a;
|
|
174
179
|
}
|
|
175
180
|
return o.value;
|
|
176
|
-
},
|
|
181
|
+
}, cn = /* @__PURE__ */ an(ve), un = (t) => (e, n, s) => {
|
|
177
182
|
const i = s ? { ...s, async: !1 } : { async: !1 }, r = e._zod.run({ value: n, issues: [] }, i);
|
|
178
183
|
if (r instanceof Promise)
|
|
179
|
-
throw new
|
|
184
|
+
throw new Q();
|
|
180
185
|
return r.issues.length ? {
|
|
181
186
|
success: !1,
|
|
182
|
-
error: new (t ??
|
|
187
|
+
error: new (t ?? sn)(r.issues.map((o) => se(o, i, ne())))
|
|
183
188
|
} : { success: !0, data: r.value };
|
|
184
|
-
},
|
|
189
|
+
}, dt = /* @__PURE__ */ un(ve), ln = (t) => async (e, n, s) => {
|
|
185
190
|
const i = s ? Object.assign(s, { async: !0 }) : { async: !0 };
|
|
186
191
|
let r = e._zod.run({ value: n, issues: [] }, i);
|
|
187
192
|
return r instanceof Promise && (r = await r), r.issues.length ? {
|
|
188
193
|
success: !1,
|
|
189
|
-
error: new t(r.issues.map((o) =>
|
|
194
|
+
error: new t(r.issues.map((o) => se(o, i, ne())))
|
|
190
195
|
} : { success: !0, data: r.value };
|
|
191
|
-
},
|
|
196
|
+
}, ht = /* @__PURE__ */ ln(ve), dn = (t) => {
|
|
192
197
|
const e = t ? `[\\s\\S]{${t?.minimum ?? 0},${t?.maximum ?? ""}}` : "[\\s\\S]*";
|
|
193
198
|
return new RegExp(`^${e}$`);
|
|
194
|
-
},
|
|
199
|
+
}, hn = /^-?\d+$/, ft = /^-?\d+(?:\.\d+)?$/, fn = /^(?:true|false)$/i, Ue = /* @__PURE__ */ w("$ZodCheck", (t, e) => {
|
|
195
200
|
var n;
|
|
196
201
|
t._zod ?? (t._zod = {}), t._zod.def = e, (n = t._zod).onattach ?? (n.onattach = []);
|
|
197
|
-
}),
|
|
202
|
+
}), mt = {
|
|
198
203
|
number: "number",
|
|
199
204
|
bigint: "bigint",
|
|
200
205
|
object: "date"
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
-
const n =
|
|
206
|
+
}, mn = /* @__PURE__ */ w("$ZodCheckLessThan", (t, e) => {
|
|
207
|
+
Ue.init(t, e);
|
|
208
|
+
const n = mt[typeof e.value];
|
|
204
209
|
t._zod.onattach.push((s) => {
|
|
205
210
|
const i = s._zod.bag, r = (e.inclusive ? i.maximum : i.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
206
211
|
e.value < r && (e.inclusive ? i.maximum = e.value : i.exclusiveMaximum = e.value);
|
|
@@ -215,9 +220,9 @@ const tt = (t, e) => {
|
|
|
215
220
|
continue: !e.abort
|
|
216
221
|
});
|
|
217
222
|
};
|
|
218
|
-
}),
|
|
219
|
-
|
|
220
|
-
const n =
|
|
223
|
+
}), pn = /* @__PURE__ */ w("$ZodCheckGreaterThan", (t, e) => {
|
|
224
|
+
Ue.init(t, e);
|
|
225
|
+
const n = mt[typeof e.value];
|
|
221
226
|
t._zod.onattach.push((s) => {
|
|
222
227
|
const i = s._zod.bag, r = (e.inclusive ? i.minimum : i.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
223
228
|
e.value > r && (e.inclusive ? i.minimum = e.value : i.exclusiveMinimum = e.value);
|
|
@@ -232,12 +237,12 @@ const tt = (t, e) => {
|
|
|
232
237
|
continue: !e.abort
|
|
233
238
|
});
|
|
234
239
|
};
|
|
235
|
-
}),
|
|
236
|
-
|
|
237
|
-
const n = e.format?.includes("int"), s = n ? "int" : "number", [i, r] =
|
|
240
|
+
}), gn = /* @__PURE__ */ w("$ZodCheckNumberFormat", (t, e) => {
|
|
241
|
+
Ue.init(t, e), e.format = e.format || "float64";
|
|
242
|
+
const n = e.format?.includes("int"), s = n ? "int" : "number", [i, r] = nn[e.format];
|
|
238
243
|
t._zod.onattach.push((o) => {
|
|
239
244
|
const a = o._zod.bag;
|
|
240
|
-
a.format = e.format, a.minimum = i, a.maximum = r, n && (a.pattern =
|
|
245
|
+
a.format = e.format, a.minimum = i, a.maximum = r, n && (a.pattern = hn);
|
|
241
246
|
}), t._zod.check = (o) => {
|
|
242
247
|
const a = o.value;
|
|
243
248
|
if (n) {
|
|
@@ -293,13 +298,13 @@ const tt = (t, e) => {
|
|
|
293
298
|
continue: !e.abort
|
|
294
299
|
});
|
|
295
300
|
};
|
|
296
|
-
}),
|
|
301
|
+
}), wn = {
|
|
297
302
|
major: 4,
|
|
298
303
|
minor: 3,
|
|
299
304
|
patch: 6
|
|
300
|
-
},
|
|
305
|
+
}, C = /* @__PURE__ */ w("$ZodType", (t, e) => {
|
|
301
306
|
var n;
|
|
302
|
-
t ?? (t = {}), t._zod.def = e, t._zod.bag = t._zod.bag || {}, t._zod.version =
|
|
307
|
+
t ?? (t = {}), t._zod.def = e, t._zod.bag = t._zod.bag || {}, t._zod.version = wn;
|
|
303
308
|
const s = [...t._zod.def.checks ?? []];
|
|
304
309
|
t._zod.traits.has("$ZodCheck") && s.unshift(t);
|
|
305
310
|
for (const i of s)
|
|
@@ -311,7 +316,7 @@ const tt = (t, e) => {
|
|
|
311
316
|
});
|
|
312
317
|
else {
|
|
313
318
|
const i = (o, a, c) => {
|
|
314
|
-
let u =
|
|
319
|
+
let u = ce(o), l;
|
|
315
320
|
for (const d of a) {
|
|
316
321
|
if (d._zod.def.when) {
|
|
317
322
|
if (!d._zod.def.when(o))
|
|
@@ -320,25 +325,25 @@ const tt = (t, e) => {
|
|
|
320
325
|
continue;
|
|
321
326
|
const f = o.issues.length, g = d._zod.check(o);
|
|
322
327
|
if (g instanceof Promise && c?.async === !1)
|
|
323
|
-
throw new
|
|
328
|
+
throw new Q();
|
|
324
329
|
if (l || g instanceof Promise)
|
|
325
330
|
l = (l ?? Promise.resolve()).then(async () => {
|
|
326
|
-
await g, o.issues.length !== f && (u || (u =
|
|
331
|
+
await g, o.issues.length !== f && (u || (u = ce(o, f)));
|
|
327
332
|
});
|
|
328
333
|
else {
|
|
329
334
|
if (o.issues.length === f)
|
|
330
335
|
continue;
|
|
331
|
-
u || (u =
|
|
336
|
+
u || (u = ce(o, f));
|
|
332
337
|
}
|
|
333
338
|
}
|
|
334
339
|
return l ? l.then(() => o) : o;
|
|
335
340
|
}, r = (o, a, c) => {
|
|
336
|
-
if (
|
|
341
|
+
if (ce(o))
|
|
337
342
|
return o.aborted = !0, o;
|
|
338
343
|
const u = i(a, s, c);
|
|
339
344
|
if (u instanceof Promise) {
|
|
340
345
|
if (c.async === !1)
|
|
341
|
-
throw new
|
|
346
|
+
throw new Q();
|
|
342
347
|
return u.then((l) => t._zod.parse(l, c));
|
|
343
348
|
}
|
|
344
349
|
return t._zod.parse(u, c);
|
|
@@ -353,26 +358,26 @@ const tt = (t, e) => {
|
|
|
353
358
|
const c = t._zod.parse(o, a);
|
|
354
359
|
if (c instanceof Promise) {
|
|
355
360
|
if (a.async === !1)
|
|
356
|
-
throw new
|
|
361
|
+
throw new Q();
|
|
357
362
|
return c.then((u) => i(u, s, a));
|
|
358
363
|
}
|
|
359
364
|
return i(c, s, a);
|
|
360
365
|
};
|
|
361
366
|
}
|
|
362
|
-
|
|
367
|
+
R(t, "~standard", () => ({
|
|
363
368
|
validate: (i) => {
|
|
364
369
|
try {
|
|
365
|
-
const r =
|
|
370
|
+
const r = dt(t, i);
|
|
366
371
|
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
367
372
|
} catch {
|
|
368
|
-
return
|
|
373
|
+
return ht(t, i).then((o) => o.success ? { value: o.data } : { issues: o.error?.issues });
|
|
369
374
|
}
|
|
370
375
|
},
|
|
371
376
|
vendor: "zod",
|
|
372
377
|
version: 1
|
|
373
378
|
}));
|
|
374
|
-
}),
|
|
375
|
-
|
|
379
|
+
}), yn = /* @__PURE__ */ w("$ZodString", (t, e) => {
|
|
380
|
+
C.init(t, e), t._zod.pattern = [...t?._zod.bag?.patterns ?? []].pop() ?? dn(t._zod.bag), t._zod.parse = (n, s) => {
|
|
376
381
|
if (e.coerce)
|
|
377
382
|
try {
|
|
378
383
|
n.value = String(n.value);
|
|
@@ -385,8 +390,8 @@ const tt = (t, e) => {
|
|
|
385
390
|
inst: t
|
|
386
391
|
}), n;
|
|
387
392
|
};
|
|
388
|
-
}),
|
|
389
|
-
|
|
393
|
+
}), pt = /* @__PURE__ */ w("$ZodNumber", (t, e) => {
|
|
394
|
+
C.init(t, e), t._zod.pattern = t._zod.bag.pattern ?? ft, t._zod.parse = (n, s) => {
|
|
390
395
|
if (e.coerce)
|
|
391
396
|
try {
|
|
392
397
|
n.value = Number(n.value);
|
|
@@ -404,10 +409,10 @@ const tt = (t, e) => {
|
|
|
404
409
|
...r ? { received: r } : {}
|
|
405
410
|
}), n;
|
|
406
411
|
};
|
|
407
|
-
}),
|
|
408
|
-
|
|
409
|
-
}),
|
|
410
|
-
|
|
412
|
+
}), vn = /* @__PURE__ */ w("$ZodNumberFormat", (t, e) => {
|
|
413
|
+
gn.init(t, e), pt.init(t, e);
|
|
414
|
+
}), bn = /* @__PURE__ */ w("$ZodBoolean", (t, e) => {
|
|
415
|
+
C.init(t, e), t._zod.pattern = fn, t._zod.parse = (n, s) => {
|
|
411
416
|
if (e.coerce)
|
|
412
417
|
try {
|
|
413
418
|
n.value = !!n.value;
|
|
@@ -422,11 +427,11 @@ const tt = (t, e) => {
|
|
|
422
427
|
}), n;
|
|
423
428
|
};
|
|
424
429
|
});
|
|
425
|
-
function
|
|
426
|
-
t.issues.length && e.issues.push(...
|
|
430
|
+
function Ne(t, e, n) {
|
|
431
|
+
t.issues.length && e.issues.push(...J(n, t.issues)), e.value[n] = t.value;
|
|
427
432
|
}
|
|
428
|
-
const
|
|
429
|
-
|
|
433
|
+
const Sn = /* @__PURE__ */ w("$ZodArray", (t, e) => {
|
|
434
|
+
C.init(t, e), t._zod.parse = (n, s) => {
|
|
430
435
|
const i = n.value;
|
|
431
436
|
if (!Array.isArray(i))
|
|
432
437
|
return n.issues.push({
|
|
@@ -442,25 +447,25 @@ const hn = /* @__PURE__ */ w("$ZodArray", (t, e) => {
|
|
|
442
447
|
value: a,
|
|
443
448
|
issues: []
|
|
444
449
|
}, s);
|
|
445
|
-
c instanceof Promise ? r.push(c.then((u) =>
|
|
450
|
+
c instanceof Promise ? r.push(c.then((u) => Ne(u, n, o))) : Ne(c, n, o);
|
|
446
451
|
}
|
|
447
452
|
return r.length ? Promise.all(r).then(() => n) : n;
|
|
448
453
|
};
|
|
449
454
|
});
|
|
450
|
-
function
|
|
455
|
+
function we(t, e, n, s, i) {
|
|
451
456
|
if (t.issues.length) {
|
|
452
457
|
if (i && !(n in s))
|
|
453
458
|
return;
|
|
454
|
-
e.issues.push(...
|
|
459
|
+
e.issues.push(...J(n, t.issues));
|
|
455
460
|
}
|
|
456
461
|
t.value === void 0 ? n in s && (e.value[n] = void 0) : e.value[n] = t.value;
|
|
457
462
|
}
|
|
458
|
-
function
|
|
463
|
+
function An(t) {
|
|
459
464
|
const e = Object.keys(t.shape);
|
|
460
465
|
for (const s of e)
|
|
461
466
|
if (!t.shape?.[s]?._zod?.traits?.has("$ZodType"))
|
|
462
467
|
throw new Error(`Invalid element at key "${s}": expected a Zod schema`);
|
|
463
|
-
const n =
|
|
468
|
+
const n = tn(t.shape);
|
|
464
469
|
return {
|
|
465
470
|
...t,
|
|
466
471
|
keys: e,
|
|
@@ -469,7 +474,7 @@ function fn(t) {
|
|
|
469
474
|
optionalKeys: new Set(n)
|
|
470
475
|
};
|
|
471
476
|
}
|
|
472
|
-
function
|
|
477
|
+
function _n(t, e, n, s, i, r) {
|
|
473
478
|
const o = [], a = i.keySet, c = i.catchall._zod, u = c.def.type, l = c.optout === "optional";
|
|
474
479
|
for (const d in e) {
|
|
475
480
|
if (a.has(d))
|
|
@@ -479,7 +484,7 @@ function mn(t, e, n, s, i, r) {
|
|
|
479
484
|
continue;
|
|
480
485
|
}
|
|
481
486
|
const f = c.run({ value: e[d], issues: [] }, s);
|
|
482
|
-
f instanceof Promise ? t.push(f.then((g) =>
|
|
487
|
+
f instanceof Promise ? t.push(f.then((g) => we(g, n, d, e, l))) : we(f, n, d, e, l);
|
|
483
488
|
}
|
|
484
489
|
return o.length && n.issues.push({
|
|
485
490
|
code: "unrecognized_keys",
|
|
@@ -488,8 +493,8 @@ function mn(t, e, n, s, i, r) {
|
|
|
488
493
|
inst: r
|
|
489
494
|
}), t.length ? Promise.all(t).then(() => n) : n;
|
|
490
495
|
}
|
|
491
|
-
const
|
|
492
|
-
if (
|
|
496
|
+
const Mn = /* @__PURE__ */ w("$ZodObject", (t, e) => {
|
|
497
|
+
if (C.init(t, e), !Object.getOwnPropertyDescriptor(e, "shape")?.get) {
|
|
493
498
|
const a = e.shape;
|
|
494
499
|
Object.defineProperty(e, "shape", {
|
|
495
500
|
get: () => {
|
|
@@ -500,8 +505,8 @@ const pn = /* @__PURE__ */ w("$ZodObject", (t, e) => {
|
|
|
500
505
|
}
|
|
501
506
|
});
|
|
502
507
|
}
|
|
503
|
-
const s =
|
|
504
|
-
|
|
508
|
+
const s = ot(() => An(e));
|
|
509
|
+
R(t._zod, "propValues", () => {
|
|
505
510
|
const a = e.shape, c = {};
|
|
506
511
|
for (const u in a) {
|
|
507
512
|
const l = a[u]._zod;
|
|
@@ -513,7 +518,7 @@ const pn = /* @__PURE__ */ w("$ZodObject", (t, e) => {
|
|
|
513
518
|
}
|
|
514
519
|
return c;
|
|
515
520
|
});
|
|
516
|
-
const i =
|
|
521
|
+
const i = ge, r = e.catchall;
|
|
517
522
|
let o;
|
|
518
523
|
t._zod.parse = (a, c) => {
|
|
519
524
|
o ?? (o = s.value);
|
|
@@ -528,32 +533,32 @@ const pn = /* @__PURE__ */ w("$ZodObject", (t, e) => {
|
|
|
528
533
|
a.value = {};
|
|
529
534
|
const l = [], d = o.shape;
|
|
530
535
|
for (const f of o.keys) {
|
|
531
|
-
const g = d[f], y = g._zod.optout === "optional",
|
|
532
|
-
|
|
536
|
+
const g = d[f], y = g._zod.optout === "optional", v = g._zod.run({ value: u[f], issues: [] }, c);
|
|
537
|
+
v instanceof Promise ? l.push(v.then((A) => we(A, a, f, u, y))) : we(v, a, f, u, y);
|
|
533
538
|
}
|
|
534
|
-
return r ?
|
|
539
|
+
return r ? _n(l, u, a, c, s.value, t) : l.length ? Promise.all(l).then(() => a) : a;
|
|
535
540
|
};
|
|
536
541
|
});
|
|
537
|
-
function
|
|
542
|
+
function Fe(t, e, n, s) {
|
|
538
543
|
for (const r of t)
|
|
539
544
|
if (r.issues.length === 0)
|
|
540
545
|
return e.value = r.value, e;
|
|
541
|
-
const i = t.filter((r) => !
|
|
546
|
+
const i = t.filter((r) => !ce(r));
|
|
542
547
|
return i.length === 1 ? (e.value = i[0].value, i[0]) : (e.issues.push({
|
|
543
548
|
code: "invalid_union",
|
|
544
549
|
input: e.value,
|
|
545
550
|
inst: n,
|
|
546
|
-
errors: t.map((r) => r.issues.map((o) =>
|
|
551
|
+
errors: t.map((r) => r.issues.map((o) => se(o, s, ne())))
|
|
547
552
|
}), e);
|
|
548
553
|
}
|
|
549
|
-
const
|
|
550
|
-
|
|
554
|
+
const gt = /* @__PURE__ */ w("$ZodUnion", (t, e) => {
|
|
555
|
+
C.init(t, e), R(t._zod, "optin", () => e.options.some((i) => i._zod.optin === "optional") ? "optional" : void 0), R(t._zod, "optout", () => e.options.some((i) => i._zod.optout === "optional") ? "optional" : void 0), R(t._zod, "values", () => {
|
|
551
556
|
if (e.options.every((i) => i._zod.values))
|
|
552
557
|
return new Set(e.options.flatMap((i) => Array.from(i._zod.values)));
|
|
553
|
-
}),
|
|
558
|
+
}), R(t._zod, "pattern", () => {
|
|
554
559
|
if (e.options.every((i) => i._zod.pattern)) {
|
|
555
560
|
const i = e.options.map((r) => r._zod.pattern);
|
|
556
|
-
return new RegExp(`^(${i.map((r) =>
|
|
561
|
+
return new RegExp(`^(${i.map((r) => at(r.source)).join("|")})$`);
|
|
557
562
|
}
|
|
558
563
|
});
|
|
559
564
|
const n = e.options.length === 1, s = e.options[0]._zod.run;
|
|
@@ -575,12 +580,12 @@ const at = /* @__PURE__ */ w("$ZodUnion", (t, e) => {
|
|
|
575
580
|
a.push(u);
|
|
576
581
|
}
|
|
577
582
|
}
|
|
578
|
-
return o ? Promise.all(a).then((c) =>
|
|
583
|
+
return o ? Promise.all(a).then((c) => Fe(c, i, t, r)) : Fe(a, i, t, r);
|
|
579
584
|
};
|
|
580
|
-
}),
|
|
581
|
-
e.inclusive = !1,
|
|
585
|
+
}), zn = /* @__PURE__ */ w("$ZodDiscriminatedUnion", (t, e) => {
|
|
586
|
+
e.inclusive = !1, gt.init(t, e);
|
|
582
587
|
const n = t._zod.parse;
|
|
583
|
-
|
|
588
|
+
R(t._zod, "propValues", () => {
|
|
584
589
|
const i = {};
|
|
585
590
|
for (const r of e.options) {
|
|
586
591
|
const o = r._zod.propValues;
|
|
@@ -594,7 +599,7 @@ const at = /* @__PURE__ */ w("$ZodUnion", (t, e) => {
|
|
|
594
599
|
}
|
|
595
600
|
return i;
|
|
596
601
|
});
|
|
597
|
-
const s =
|
|
602
|
+
const s = ot(() => {
|
|
598
603
|
const i = e.options, r = /* @__PURE__ */ new Map();
|
|
599
604
|
for (const o of i) {
|
|
600
605
|
const a = o._zod.propValues?.[e.discriminator];
|
|
@@ -610,7 +615,7 @@ const at = /* @__PURE__ */ w("$ZodUnion", (t, e) => {
|
|
|
610
615
|
});
|
|
611
616
|
t._zod.parse = (i, r) => {
|
|
612
617
|
const o = i.value;
|
|
613
|
-
if (!
|
|
618
|
+
if (!ge(o))
|
|
614
619
|
return i.issues.push({
|
|
615
620
|
code: "invalid_type",
|
|
616
621
|
expected: "object",
|
|
@@ -628,10 +633,10 @@ const at = /* @__PURE__ */ w("$ZodUnion", (t, e) => {
|
|
|
628
633
|
inst: t
|
|
629
634
|
}), i);
|
|
630
635
|
};
|
|
631
|
-
}),
|
|
632
|
-
|
|
636
|
+
}), kn = /* @__PURE__ */ w("$ZodRecord", (t, e) => {
|
|
637
|
+
C.init(t, e), t._zod.parse = (n, s) => {
|
|
633
638
|
const i = n.value;
|
|
634
|
-
if (!
|
|
639
|
+
if (!ut(i))
|
|
635
640
|
return n.issues.push({
|
|
636
641
|
expected: "record",
|
|
637
642
|
code: "invalid_type",
|
|
@@ -647,8 +652,8 @@ const at = /* @__PURE__ */ w("$ZodUnion", (t, e) => {
|
|
|
647
652
|
a.add(typeof u == "number" ? u.toString() : u);
|
|
648
653
|
const l = e.valueType._zod.run({ value: i[u], issues: [] }, s);
|
|
649
654
|
l instanceof Promise ? r.push(l.then((d) => {
|
|
650
|
-
d.issues.length && n.issues.push(...
|
|
651
|
-
})) : (l.issues.length && n.issues.push(...
|
|
655
|
+
d.issues.length && n.issues.push(...J(u, d.issues)), n.value[u] = d.value;
|
|
656
|
+
})) : (l.issues.length && n.issues.push(...J(u, l.issues)), n.value[u] = l.value);
|
|
652
657
|
}
|
|
653
658
|
let c;
|
|
654
659
|
for (const u in i)
|
|
@@ -667,7 +672,7 @@ const at = /* @__PURE__ */ w("$ZodUnion", (t, e) => {
|
|
|
667
672
|
let c = e.keyType._zod.run({ value: a, issues: [] }, s);
|
|
668
673
|
if (c instanceof Promise)
|
|
669
674
|
throw new Error("Async schemas not supported in object keys currently");
|
|
670
|
-
if (typeof a == "string" &&
|
|
675
|
+
if (typeof a == "string" && ft.test(a) && c.issues.length) {
|
|
671
676
|
const d = e.keyType._zod.run({ value: Number(a), issues: [] }, s);
|
|
672
677
|
if (d instanceof Promise)
|
|
673
678
|
throw new Error("Async schemas not supported in object keys currently");
|
|
@@ -677,7 +682,7 @@ const at = /* @__PURE__ */ w("$ZodUnion", (t, e) => {
|
|
|
677
682
|
e.mode === "loose" ? n.value[a] = i[a] : n.issues.push({
|
|
678
683
|
code: "invalid_key",
|
|
679
684
|
origin: "record",
|
|
680
|
-
issues: c.issues.map((d) =>
|
|
685
|
+
issues: c.issues.map((d) => se(d, s, ne())),
|
|
681
686
|
input: a,
|
|
682
687
|
path: [a],
|
|
683
688
|
inst: t
|
|
@@ -686,17 +691,29 @@ const at = /* @__PURE__ */ w("$ZodUnion", (t, e) => {
|
|
|
686
691
|
}
|
|
687
692
|
const l = e.valueType._zod.run({ value: i[a], issues: [] }, s);
|
|
688
693
|
l instanceof Promise ? r.push(l.then((d) => {
|
|
689
|
-
d.issues.length && n.issues.push(...
|
|
690
|
-
})) : (l.issues.length && n.issues.push(...
|
|
694
|
+
d.issues.length && n.issues.push(...J(a, d.issues)), n.value[c.value] = d.value;
|
|
695
|
+
})) : (l.issues.length && n.issues.push(...J(a, l.issues)), n.value[c.value] = l.value);
|
|
691
696
|
}
|
|
692
697
|
}
|
|
693
698
|
return r.length ? Promise.all(r).then(() => n) : n;
|
|
694
699
|
};
|
|
695
|
-
}),
|
|
696
|
-
|
|
700
|
+
}), Tn = /* @__PURE__ */ w("$ZodEnum", (t, e) => {
|
|
701
|
+
C.init(t, e);
|
|
702
|
+
const n = Yt(e.entries), s = new Set(n);
|
|
703
|
+
t._zod.values = s, t._zod.pattern = new RegExp(`^(${n.filter((i) => Qt.has(typeof i)).map((i) => typeof i == "string" ? ke(i) : i.toString()).join("|")})$`), t._zod.parse = (i, r) => {
|
|
704
|
+
const o = i.value;
|
|
705
|
+
return s.has(o) || i.issues.push({
|
|
706
|
+
code: "invalid_value",
|
|
707
|
+
values: n,
|
|
708
|
+
input: o,
|
|
709
|
+
inst: t
|
|
710
|
+
}), i;
|
|
711
|
+
};
|
|
712
|
+
}), Un = /* @__PURE__ */ w("$ZodLiteral", (t, e) => {
|
|
713
|
+
if (C.init(t, e), e.values.length === 0)
|
|
697
714
|
throw new Error("Cannot create literal schema with no valid values");
|
|
698
715
|
const n = new Set(e.values);
|
|
699
|
-
t._zod.values = n, t._zod.pattern = new RegExp(`^(${e.values.map((s) => typeof s == "string" ?
|
|
716
|
+
t._zod.values = n, t._zod.pattern = new RegExp(`^(${e.values.map((s) => typeof s == "string" ? ke(s) : s ? ke(s.toString()) : String(s)).join("|")})$`), t._zod.parse = (s, i) => {
|
|
700
717
|
const r = s.value;
|
|
701
718
|
return n.has(r) || s.issues.push({
|
|
702
719
|
code: "invalid_value",
|
|
@@ -705,60 +722,60 @@ const at = /* @__PURE__ */ w("$ZodUnion", (t, e) => {
|
|
|
705
722
|
inst: t
|
|
706
723
|
}), s;
|
|
707
724
|
};
|
|
708
|
-
}),
|
|
709
|
-
|
|
725
|
+
}), En = /* @__PURE__ */ w("$ZodTransform", (t, e) => {
|
|
726
|
+
C.init(t, e), t._zod.parse = (n, s) => {
|
|
710
727
|
if (s.direction === "backward")
|
|
711
|
-
throw new
|
|
728
|
+
throw new Gt(t.constructor.name);
|
|
712
729
|
const i = e.transform(n.value, n);
|
|
713
730
|
if (s.async)
|
|
714
731
|
return (i instanceof Promise ? i : Promise.resolve(i)).then((o) => (n.value = o, n));
|
|
715
732
|
if (i instanceof Promise)
|
|
716
|
-
throw new
|
|
733
|
+
throw new Q();
|
|
717
734
|
return n.value = i, n;
|
|
718
735
|
};
|
|
719
736
|
});
|
|
720
|
-
function
|
|
737
|
+
function $e(t, e) {
|
|
721
738
|
return t.issues.length && e === void 0 ? { issues: [], value: void 0 } : t;
|
|
722
739
|
}
|
|
723
|
-
const
|
|
724
|
-
|
|
740
|
+
const xn = /* @__PURE__ */ w("$ZodOptional", (t, e) => {
|
|
741
|
+
C.init(t, e), t._zod.optin = "optional", t._zod.optout = "optional", R(t._zod, "values", () => e.innerType._zod.values ? /* @__PURE__ */ new Set([...e.innerType._zod.values, void 0]) : void 0), R(t._zod, "pattern", () => {
|
|
725
742
|
const n = e.innerType._zod.pattern;
|
|
726
|
-
return n ? new RegExp(`^(${
|
|
743
|
+
return n ? new RegExp(`^(${at(n.source)})?$`) : void 0;
|
|
727
744
|
}), t._zod.parse = (n, s) => {
|
|
728
745
|
if (e.innerType._zod.optin === "optional") {
|
|
729
746
|
const i = e.innerType._zod.run(n, s);
|
|
730
|
-
return i instanceof Promise ? i.then((r) =>
|
|
747
|
+
return i instanceof Promise ? i.then((r) => $e(r, n.value)) : $e(i, n.value);
|
|
731
748
|
}
|
|
732
749
|
return n.value === void 0 ? n : e.innerType._zod.run(n, s);
|
|
733
750
|
};
|
|
734
|
-
}),
|
|
735
|
-
|
|
751
|
+
}), Rn = /* @__PURE__ */ w("$ZodDefault", (t, e) => {
|
|
752
|
+
C.init(t, e), t._zod.optin = "optional", R(t._zod, "values", () => e.innerType._zod.values), t._zod.parse = (n, s) => {
|
|
736
753
|
if (s.direction === "backward")
|
|
737
754
|
return e.innerType._zod.run(n, s);
|
|
738
755
|
if (n.value === void 0)
|
|
739
756
|
return n.value = e.defaultValue, n;
|
|
740
757
|
const i = e.innerType._zod.run(n, s);
|
|
741
|
-
return i instanceof Promise ? i.then((r) =>
|
|
758
|
+
return i instanceof Promise ? i.then((r) => je(r, e)) : je(i, e);
|
|
742
759
|
};
|
|
743
760
|
});
|
|
744
|
-
function
|
|
761
|
+
function je(t, e) {
|
|
745
762
|
return t.value === void 0 && (t.value = e.defaultValue), t;
|
|
746
763
|
}
|
|
747
|
-
const
|
|
748
|
-
|
|
764
|
+
const Bn = /* @__PURE__ */ w("$ZodPipe", (t, e) => {
|
|
765
|
+
C.init(t, e), R(t._zod, "values", () => e.in._zod.values), R(t._zod, "optin", () => e.in._zod.optin), R(t._zod, "optout", () => e.out._zod.optout), R(t._zod, "propValues", () => e.in._zod.propValues), t._zod.parse = (n, s) => {
|
|
749
766
|
if (s.direction === "backward") {
|
|
750
767
|
const r = e.out._zod.run(n, s);
|
|
751
|
-
return r instanceof Promise ? r.then((o) =>
|
|
768
|
+
return r instanceof Promise ? r.then((o) => pe(o, e.in, s)) : pe(r, e.in, s);
|
|
752
769
|
}
|
|
753
770
|
const i = e.in._zod.run(n, s);
|
|
754
|
-
return i instanceof Promise ? i.then((r) =>
|
|
771
|
+
return i instanceof Promise ? i.then((r) => pe(r, e.out, s)) : pe(i, e.out, s);
|
|
755
772
|
};
|
|
756
773
|
});
|
|
757
|
-
function
|
|
774
|
+
function pe(t, e, n) {
|
|
758
775
|
return t.issues.length ? (t.aborted = !0, t) : e._zod.run({ value: t.value, issues: t.issues }, n);
|
|
759
776
|
}
|
|
760
|
-
var
|
|
761
|
-
class
|
|
777
|
+
var Ze;
|
|
778
|
+
class Cn {
|
|
762
779
|
constructor() {
|
|
763
780
|
this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map();
|
|
764
781
|
}
|
|
@@ -787,316 +804,332 @@ class _n {
|
|
|
787
804
|
return this._map.has(e);
|
|
788
805
|
}
|
|
789
806
|
}
|
|
790
|
-
function
|
|
791
|
-
return new
|
|
807
|
+
function In() {
|
|
808
|
+
return new Cn();
|
|
792
809
|
}
|
|
793
|
-
(
|
|
810
|
+
(Ze = globalThis).__zod_globalRegistry ?? (Ze.__zod_globalRegistry = In());
|
|
794
811
|
// @__NO_SIDE_EFFECTS__
|
|
795
|
-
function
|
|
812
|
+
function On(t, e) {
|
|
796
813
|
return new t({
|
|
797
814
|
type: "string",
|
|
798
|
-
...
|
|
815
|
+
...O()
|
|
799
816
|
});
|
|
800
817
|
}
|
|
801
818
|
// @__NO_SIDE_EFFECTS__
|
|
802
|
-
function
|
|
819
|
+
function Dn(t, e) {
|
|
803
820
|
return new t({
|
|
804
821
|
type: "number",
|
|
805
822
|
checks: [],
|
|
806
|
-
...
|
|
823
|
+
...O()
|
|
807
824
|
});
|
|
808
825
|
}
|
|
809
826
|
// @__NO_SIDE_EFFECTS__
|
|
810
|
-
function
|
|
827
|
+
function Ln(t, e) {
|
|
811
828
|
return new t({
|
|
812
829
|
type: "number",
|
|
813
830
|
check: "number_format",
|
|
814
831
|
abort: !1,
|
|
815
832
|
format: "safeint",
|
|
816
|
-
...
|
|
833
|
+
...O()
|
|
817
834
|
});
|
|
818
835
|
}
|
|
819
836
|
// @__NO_SIDE_EFFECTS__
|
|
820
|
-
function
|
|
837
|
+
function Pn(t, e) {
|
|
821
838
|
return new t({
|
|
822
839
|
type: "boolean",
|
|
823
|
-
...
|
|
840
|
+
...O()
|
|
824
841
|
});
|
|
825
842
|
}
|
|
826
843
|
// @__NO_SIDE_EFFECTS__
|
|
827
|
-
function
|
|
828
|
-
return new
|
|
844
|
+
function wt(t, e) {
|
|
845
|
+
return new mn({
|
|
829
846
|
check: "less_than",
|
|
830
|
-
...
|
|
847
|
+
...O(),
|
|
831
848
|
value: t,
|
|
832
849
|
inclusive: !0
|
|
833
850
|
});
|
|
834
851
|
}
|
|
835
852
|
// @__NO_SIDE_EFFECTS__
|
|
836
|
-
function
|
|
837
|
-
return new
|
|
853
|
+
function Nn(t, e) {
|
|
854
|
+
return new pn({
|
|
838
855
|
check: "greater_than",
|
|
839
|
-
...
|
|
856
|
+
...O(),
|
|
840
857
|
value: t,
|
|
841
858
|
inclusive: !0
|
|
842
859
|
});
|
|
843
860
|
}
|
|
844
861
|
// @__NO_SIDE_EFFECTS__
|
|
845
|
-
function
|
|
846
|
-
return /* @__PURE__ */
|
|
862
|
+
function yt(t) {
|
|
863
|
+
return /* @__PURE__ */ Nn(0);
|
|
847
864
|
}
|
|
848
|
-
const
|
|
865
|
+
const I = /* @__PURE__ */ w("ZodMiniType", (t, e) => {
|
|
849
866
|
if (!t._zod)
|
|
850
867
|
throw new Error("Uninitialized schema in ZodMiniType.");
|
|
851
|
-
|
|
868
|
+
C.init(t, e), t.def = e, t.type = e.type, t.parse = (n, s) => on(t, n, s, { callee: t.parse }), t.safeParse = (n, s) => dt(t, n, s), t.parseAsync = async (n, s) => cn(t, n, s, { callee: t.parseAsync }), t.safeParseAsync = async (n, s) => ht(t, n, s), t.check = (...n) => t.clone({
|
|
852
869
|
...e,
|
|
853
870
|
checks: [
|
|
854
871
|
...e.checks ?? [],
|
|
855
872
|
...n.map((s) => typeof s == "function" ? { _zod: { check: s, def: { check: "custom" }, onattach: [] } } : s)
|
|
856
873
|
]
|
|
857
|
-
}, { parent: !0 }), t.with = t.check, t.clone = (n, s) =>
|
|
858
|
-
}),
|
|
859
|
-
|
|
874
|
+
}, { parent: !0 }), t.with = t.check, t.clone = (n, s) => en(t, n, s), t.brand = () => t, t.register = ((n, s) => (n.add(t, s), t)), t.apply = (n) => n(t);
|
|
875
|
+
}), Fn = /* @__PURE__ */ w("ZodMiniString", (t, e) => {
|
|
876
|
+
yn.init(t, e), I.init(t, e);
|
|
860
877
|
});
|
|
861
878
|
// @__NO_SIDE_EFFECTS__
|
|
862
|
-
function
|
|
863
|
-
return /* @__PURE__ */
|
|
879
|
+
function b(t) {
|
|
880
|
+
return /* @__PURE__ */ On(Fn);
|
|
864
881
|
}
|
|
865
|
-
const
|
|
866
|
-
|
|
882
|
+
const vt = /* @__PURE__ */ w("ZodMiniNumber", (t, e) => {
|
|
883
|
+
pt.init(t, e), I.init(t, e);
|
|
867
884
|
});
|
|
868
885
|
// @__NO_SIDE_EFFECTS__
|
|
869
|
-
function
|
|
870
|
-
return /* @__PURE__ */
|
|
886
|
+
function T(t) {
|
|
887
|
+
return /* @__PURE__ */ Dn(vt);
|
|
871
888
|
}
|
|
872
|
-
const
|
|
873
|
-
|
|
889
|
+
const $n = /* @__PURE__ */ w("ZodMiniNumberFormat", (t, e) => {
|
|
890
|
+
vn.init(t, e), vt.init(t, e);
|
|
874
891
|
});
|
|
875
892
|
// @__NO_SIDE_EFFECTS__
|
|
876
|
-
function
|
|
877
|
-
return /* @__PURE__ */
|
|
893
|
+
function bt(t) {
|
|
894
|
+
return /* @__PURE__ */ Ln($n);
|
|
878
895
|
}
|
|
879
|
-
const
|
|
880
|
-
|
|
896
|
+
const jn = /* @__PURE__ */ w("ZodMiniBoolean", (t, e) => {
|
|
897
|
+
bn.init(t, e), I.init(t, e);
|
|
881
898
|
});
|
|
882
899
|
// @__NO_SIDE_EFFECTS__
|
|
883
|
-
function
|
|
884
|
-
return /* @__PURE__ */
|
|
900
|
+
function Ee(t) {
|
|
901
|
+
return /* @__PURE__ */ Pn(jn);
|
|
885
902
|
}
|
|
886
|
-
const
|
|
887
|
-
|
|
903
|
+
const Zn = /* @__PURE__ */ w("ZodMiniArray", (t, e) => {
|
|
904
|
+
Sn.init(t, e), I.init(t, e);
|
|
888
905
|
});
|
|
889
906
|
// @__NO_SIDE_EFFECTS__
|
|
890
|
-
function
|
|
891
|
-
return new
|
|
907
|
+
function G(t, e) {
|
|
908
|
+
return new Zn({
|
|
892
909
|
type: "array",
|
|
893
910
|
element: t,
|
|
894
|
-
...
|
|
911
|
+
...O()
|
|
895
912
|
});
|
|
896
913
|
}
|
|
897
|
-
const
|
|
898
|
-
|
|
914
|
+
const Vn = /* @__PURE__ */ w("ZodMiniObject", (t, e) => {
|
|
915
|
+
Mn.init(t, e), I.init(t, e), R(t, "shape", () => e.shape);
|
|
899
916
|
});
|
|
900
917
|
// @__NO_SIDE_EFFECTS__
|
|
901
|
-
function
|
|
918
|
+
function S(t, e) {
|
|
902
919
|
const n = {
|
|
903
920
|
type: "object",
|
|
904
921
|
shape: t ?? {},
|
|
905
|
-
...
|
|
922
|
+
...O()
|
|
906
923
|
};
|
|
907
|
-
return new
|
|
924
|
+
return new Vn(n);
|
|
908
925
|
}
|
|
909
|
-
const
|
|
910
|
-
|
|
926
|
+
const Wn = /* @__PURE__ */ w("ZodMiniUnion", (t, e) => {
|
|
927
|
+
gt.init(t, e), I.init(t, e);
|
|
911
928
|
});
|
|
912
929
|
// @__NO_SIDE_EFFECTS__
|
|
913
|
-
function
|
|
914
|
-
return new
|
|
930
|
+
function be(t, e) {
|
|
931
|
+
return new Wn({
|
|
915
932
|
type: "union",
|
|
916
933
|
options: t,
|
|
917
|
-
...
|
|
934
|
+
...O()
|
|
918
935
|
});
|
|
919
936
|
}
|
|
920
|
-
const
|
|
921
|
-
|
|
937
|
+
const qn = /* @__PURE__ */ w("ZodMiniDiscriminatedUnion", (t, e) => {
|
|
938
|
+
zn.init(t, e), I.init(t, e);
|
|
922
939
|
});
|
|
923
940
|
// @__NO_SIDE_EFFECTS__
|
|
924
|
-
function
|
|
925
|
-
return new
|
|
941
|
+
function Hn(t, e, n) {
|
|
942
|
+
return new qn({
|
|
926
943
|
type: "union",
|
|
927
944
|
options: e,
|
|
928
945
|
discriminator: t,
|
|
929
|
-
...
|
|
946
|
+
...O()
|
|
930
947
|
});
|
|
931
948
|
}
|
|
932
|
-
const
|
|
933
|
-
|
|
949
|
+
const Gn = /* @__PURE__ */ w("ZodMiniRecord", (t, e) => {
|
|
950
|
+
kn.init(t, e), I.init(t, e);
|
|
934
951
|
});
|
|
935
952
|
// @__NO_SIDE_EFFECTS__
|
|
936
|
-
function
|
|
937
|
-
return new
|
|
953
|
+
function xe(t, e, n) {
|
|
954
|
+
return new Gn({
|
|
938
955
|
type: "record",
|
|
939
956
|
keyType: t,
|
|
940
957
|
valueType: e,
|
|
941
|
-
...
|
|
958
|
+
...O()
|
|
942
959
|
});
|
|
943
960
|
}
|
|
944
|
-
const
|
|
945
|
-
|
|
961
|
+
const Xn = /* @__PURE__ */ w("ZodMiniEnum", (t, e) => {
|
|
962
|
+
Tn.init(t, e), I.init(t, e), t.options = Object.values(e.entries);
|
|
946
963
|
});
|
|
947
964
|
// @__NO_SIDE_EFFECTS__
|
|
948
|
-
function
|
|
949
|
-
|
|
965
|
+
function St(t, e) {
|
|
966
|
+
const n = Array.isArray(t) ? Object.fromEntries(t.map((s) => [s, s])) : t;
|
|
967
|
+
return new Xn({
|
|
968
|
+
type: "enum",
|
|
969
|
+
entries: n,
|
|
970
|
+
...O()
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
const Yn = /* @__PURE__ */ w("ZodMiniLiteral", (t, e) => {
|
|
974
|
+
Un.init(t, e), I.init(t, e);
|
|
975
|
+
});
|
|
976
|
+
// @__NO_SIDE_EFFECTS__
|
|
977
|
+
function Te(t, e) {
|
|
978
|
+
return new Yn({
|
|
950
979
|
type: "literal",
|
|
951
980
|
values: Array.isArray(t) ? t : [t],
|
|
952
|
-
...
|
|
981
|
+
...O()
|
|
953
982
|
});
|
|
954
983
|
}
|
|
955
|
-
const
|
|
956
|
-
|
|
984
|
+
const Kn = /* @__PURE__ */ w("ZodMiniTransform", (t, e) => {
|
|
985
|
+
En.init(t, e), I.init(t, e);
|
|
957
986
|
});
|
|
958
987
|
// @__NO_SIDE_EFFECTS__
|
|
959
|
-
function
|
|
960
|
-
return new
|
|
988
|
+
function At(t) {
|
|
989
|
+
return new Kn({
|
|
961
990
|
type: "transform",
|
|
962
991
|
transform: t
|
|
963
992
|
});
|
|
964
993
|
}
|
|
965
|
-
const
|
|
966
|
-
|
|
994
|
+
const Jn = /* @__PURE__ */ w("ZodMiniOptional", (t, e) => {
|
|
995
|
+
xn.init(t, e), I.init(t, e);
|
|
967
996
|
});
|
|
968
997
|
// @__NO_SIDE_EFFECTS__
|
|
969
|
-
function
|
|
970
|
-
return new
|
|
998
|
+
function m(t) {
|
|
999
|
+
return new Jn({
|
|
971
1000
|
type: "optional",
|
|
972
1001
|
innerType: t
|
|
973
1002
|
});
|
|
974
1003
|
}
|
|
975
|
-
const
|
|
976
|
-
|
|
1004
|
+
const Qn = /* @__PURE__ */ w("ZodMiniDefault", (t, e) => {
|
|
1005
|
+
Rn.init(t, e), I.init(t, e);
|
|
977
1006
|
});
|
|
978
1007
|
// @__NO_SIDE_EFFECTS__
|
|
979
|
-
function
|
|
980
|
-
return new
|
|
1008
|
+
function es(t, e) {
|
|
1009
|
+
return new Qn({
|
|
981
1010
|
type: "default",
|
|
982
1011
|
innerType: t,
|
|
983
1012
|
get defaultValue() {
|
|
984
|
-
return typeof e == "function" ? e() :
|
|
1013
|
+
return typeof e == "function" ? e() : Jt(e);
|
|
985
1014
|
}
|
|
986
1015
|
});
|
|
987
1016
|
}
|
|
988
|
-
const
|
|
989
|
-
|
|
1017
|
+
const ts = /* @__PURE__ */ w("ZodMiniPipe", (t, e) => {
|
|
1018
|
+
Bn.init(t, e), I.init(t, e);
|
|
990
1019
|
});
|
|
991
1020
|
// @__NO_SIDE_EFFECTS__
|
|
992
|
-
function
|
|
993
|
-
return new
|
|
1021
|
+
function _t(t, e) {
|
|
1022
|
+
return new ts({
|
|
994
1023
|
type: "pipe",
|
|
995
1024
|
in: t,
|
|
996
1025
|
out: e
|
|
997
1026
|
});
|
|
998
1027
|
}
|
|
999
|
-
(/* @__PURE__ */
|
|
1000
|
-
const
|
|
1001
|
-
|
|
1028
|
+
(/* @__PURE__ */ T()).check(/* @__PURE__ */ bt(), /* @__PURE__ */ yt(), /* @__PURE__ */ wt(255)).brand("u8");
|
|
1029
|
+
const x = (/* @__PURE__ */ T()).check(/* @__PURE__ */ bt(), /* @__PURE__ */ yt(), /* @__PURE__ */ wt(Number.MAX_SAFE_INTEGER)).brand("u53");
|
|
1030
|
+
function L(t) {
|
|
1031
|
+
return x.parse(t);
|
|
1032
|
+
}
|
|
1033
|
+
const Mt = /* @__PURE__ */ es(
|
|
1034
|
+
/* @__PURE__ */ Hn("kind", [
|
|
1002
1035
|
// The default hang container
|
|
1003
|
-
/* @__PURE__ */
|
|
1036
|
+
/* @__PURE__ */ S({ kind: /* @__PURE__ */ Te("legacy") }),
|
|
1004
1037
|
// CMAF container with timescale for timestamp conversion
|
|
1005
|
-
/* @__PURE__ */
|
|
1006
|
-
kind: /* @__PURE__ */
|
|
1038
|
+
/* @__PURE__ */ S({
|
|
1039
|
+
kind: /* @__PURE__ */ Te("cmaf"),
|
|
1007
1040
|
// Time units per second
|
|
1008
|
-
timescale:
|
|
1041
|
+
timescale: x,
|
|
1009
1042
|
// Track ID used in the moof/mdat fragments
|
|
1010
|
-
trackId:
|
|
1043
|
+
trackId: x
|
|
1011
1044
|
})
|
|
1012
1045
|
]),
|
|
1013
1046
|
{ kind: "legacy" }
|
|
1014
|
-
),
|
|
1015
|
-
name: /* @__PURE__ */
|
|
1016
|
-
}),
|
|
1047
|
+
), ns = /* @__PURE__ */ S({
|
|
1048
|
+
name: /* @__PURE__ */ b()
|
|
1049
|
+
}), Ve = /* @__PURE__ */ S({
|
|
1017
1050
|
// See: https://w3c.github.io/webcodecs/codec_registry.html
|
|
1018
|
-
codec: /* @__PURE__ */
|
|
1051
|
+
codec: /* @__PURE__ */ b(),
|
|
1019
1052
|
// The container format, used to decode the timestamp and more.
|
|
1020
|
-
container:
|
|
1053
|
+
container: Mt,
|
|
1021
1054
|
// The description is used for some codecs.
|
|
1022
1055
|
// If provided, we can initialize the decoder based on the catalog alone.
|
|
1023
1056
|
// Otherwise, the initialization information is in-band.
|
|
1024
|
-
description: /* @__PURE__ */
|
|
1057
|
+
description: /* @__PURE__ */ m(/* @__PURE__ */ b()),
|
|
1025
1058
|
// hex encoded TODO use base64
|
|
1026
1059
|
// The sample rate of the audio in Hz
|
|
1027
|
-
sampleRate:
|
|
1060
|
+
sampleRate: x,
|
|
1028
1061
|
// The number of channels in the audio
|
|
1029
|
-
numberOfChannels:
|
|
1062
|
+
numberOfChannels: x,
|
|
1030
1063
|
// The bitrate of the audio in bits per second
|
|
1031
1064
|
// TODO: Support up to Number.MAX_SAFE_INTEGER
|
|
1032
|
-
bitrate: /* @__PURE__ */
|
|
1065
|
+
bitrate: /* @__PURE__ */ m(x),
|
|
1033
1066
|
// The maximum jitter before the next frame is emitted in milliseconds.
|
|
1034
1067
|
// The player's jitter buffer should be larger than this value.
|
|
1035
1068
|
// If not provided, the player should assume each frame is flushed immediately.
|
|
1036
1069
|
//
|
|
1037
1070
|
// NOTE: The audio "frame" duration depends on the codec, sample rate, etc.
|
|
1038
1071
|
// ex: AAC often uses 1024 samples per frame, so at 44100Hz, this would be 1024/44100 = 23ms
|
|
1039
|
-
jitter: /* @__PURE__ */
|
|
1040
|
-
}),
|
|
1041
|
-
/* @__PURE__ */
|
|
1072
|
+
jitter: /* @__PURE__ */ m(x)
|
|
1073
|
+
}), ss = /* @__PURE__ */ be([
|
|
1074
|
+
/* @__PURE__ */ S({
|
|
1042
1075
|
// A map of track name to rendition configuration.
|
|
1043
1076
|
// This is not an array so it will work with JSON Merge Patch.
|
|
1044
|
-
renditions: /* @__PURE__ */
|
|
1077
|
+
renditions: /* @__PURE__ */ xe(/* @__PURE__ */ b(), Ve)
|
|
1045
1078
|
}),
|
|
1046
1079
|
// Backwards compatibility: transform old {track, config} format to new object format
|
|
1047
|
-
/* @__PURE__ */
|
|
1048
|
-
/* @__PURE__ */
|
|
1049
|
-
track:
|
|
1050
|
-
config:
|
|
1080
|
+
/* @__PURE__ */ _t(
|
|
1081
|
+
/* @__PURE__ */ S({
|
|
1082
|
+
track: ns,
|
|
1083
|
+
config: Ve
|
|
1051
1084
|
}),
|
|
1052
|
-
/* @__PURE__ */
|
|
1085
|
+
/* @__PURE__ */ At((t) => ({
|
|
1053
1086
|
renditions: { [t.track.name]: t.config }
|
|
1054
1087
|
}))
|
|
1055
1088
|
)
|
|
1056
|
-
]),
|
|
1057
|
-
hardware: /* @__PURE__ */
|
|
1058
|
-
software: /* @__PURE__ */
|
|
1059
|
-
unsupported: /* @__PURE__ */
|
|
1060
|
-
}),
|
|
1061
|
-
hardware: /* @__PURE__ */
|
|
1062
|
-
software: /* @__PURE__ */
|
|
1063
|
-
unsupported: /* @__PURE__ */
|
|
1064
|
-
}),
|
|
1065
|
-
video: /* @__PURE__ */
|
|
1066
|
-
audio: /* @__PURE__ */
|
|
1067
|
-
}),
|
|
1068
|
-
name: /* @__PURE__ */
|
|
1069
|
-
}),
|
|
1070
|
-
message: /* @__PURE__ */
|
|
1071
|
-
typing: /* @__PURE__ */
|
|
1072
|
-
}),
|
|
1089
|
+
]), is = /* @__PURE__ */ S({
|
|
1090
|
+
hardware: /* @__PURE__ */ m(/* @__PURE__ */ G(/* @__PURE__ */ b())),
|
|
1091
|
+
software: /* @__PURE__ */ m(/* @__PURE__ */ G(/* @__PURE__ */ b())),
|
|
1092
|
+
unsupported: /* @__PURE__ */ m(/* @__PURE__ */ G(/* @__PURE__ */ b()))
|
|
1093
|
+
}), rs = /* @__PURE__ */ S({
|
|
1094
|
+
hardware: /* @__PURE__ */ m(/* @__PURE__ */ G(/* @__PURE__ */ b())),
|
|
1095
|
+
software: /* @__PURE__ */ m(/* @__PURE__ */ G(/* @__PURE__ */ b())),
|
|
1096
|
+
unsupported: /* @__PURE__ */ m(/* @__PURE__ */ G(/* @__PURE__ */ b()))
|
|
1097
|
+
}), os = /* @__PURE__ */ S({
|
|
1098
|
+
video: /* @__PURE__ */ m(is),
|
|
1099
|
+
audio: /* @__PURE__ */ m(rs)
|
|
1100
|
+
}), de = /* @__PURE__ */ S({
|
|
1101
|
+
name: /* @__PURE__ */ b()
|
|
1102
|
+
}), as = /* @__PURE__ */ S({
|
|
1103
|
+
message: /* @__PURE__ */ m(de),
|
|
1104
|
+
typing: /* @__PURE__ */ m(de)
|
|
1105
|
+
}), zt = /* @__PURE__ */ S({
|
|
1073
1106
|
// The relative X position of the broadcast, from -1 to +1.
|
|
1074
1107
|
// This should be used for audio panning but can also be used for video positioning.
|
|
1075
|
-
x: /* @__PURE__ */
|
|
1108
|
+
x: /* @__PURE__ */ m(/* @__PURE__ */ T()),
|
|
1076
1109
|
// The relative Y position of the broadcast, from -1 to +1.
|
|
1077
1110
|
// This can be used for video positioning, and maybe audio panning.
|
|
1078
|
-
y: /* @__PURE__ */
|
|
1111
|
+
y: /* @__PURE__ */ m(/* @__PURE__ */ T()),
|
|
1079
1112
|
// The relative Z index of the broadcast, where larger values are closer to the viewer.
|
|
1080
1113
|
// This is used to break ties when there are multiple broadcasts at the same position.
|
|
1081
|
-
z: /* @__PURE__ */
|
|
1114
|
+
z: /* @__PURE__ */ m(/* @__PURE__ */ T()),
|
|
1082
1115
|
// The scale of the broadcast, where 1 is 100%
|
|
1083
|
-
s: /* @__PURE__ */
|
|
1084
|
-
}),
|
|
1116
|
+
s: /* @__PURE__ */ m(/* @__PURE__ */ T())
|
|
1117
|
+
}), cs = /* @__PURE__ */ S({
|
|
1085
1118
|
// The initial position of the broadcaster, from -1 to +1 in both dimensions.
|
|
1086
1119
|
// If not provided, then the broadcaster is assumed to be at (0,0)
|
|
1087
1120
|
// This should be used for audio panning but can also be used for video positioning.
|
|
1088
|
-
initial: /* @__PURE__ */
|
|
1121
|
+
initial: /* @__PURE__ */ m(zt),
|
|
1089
1122
|
// If provided, then updates to the position are done via a separate Moq track.
|
|
1090
1123
|
// This is used to avoid a full catalog update every time we want to update a few bytes.
|
|
1091
1124
|
// TODO: These updates currently use JSON for simplicity, but we should use a binary format.
|
|
1092
|
-
track: /* @__PURE__ */
|
|
1125
|
+
track: /* @__PURE__ */ m(de),
|
|
1093
1126
|
// If set, then this broadcaster allows other peers to request position updates via this handle.
|
|
1094
1127
|
// We will have to discover and subscribe to their position updates.
|
|
1095
|
-
handle: /* @__PURE__ */
|
|
1128
|
+
handle: /* @__PURE__ */ m(/* @__PURE__ */ b()),
|
|
1096
1129
|
// If provided, this broadcaster is signaling the location of other peers.
|
|
1097
1130
|
// The payload is a JSON blob keyed by handle for each peer.
|
|
1098
|
-
peers: /* @__PURE__ */
|
|
1099
|
-
}),
|
|
1131
|
+
peers: /* @__PURE__ */ m(de)
|
|
1132
|
+
}), cr = /* @__PURE__ */ xe(/* @__PURE__ */ b(), zt), ee = {
|
|
1100
1133
|
catalog: 100,
|
|
1101
1134
|
chat: 90,
|
|
1102
1135
|
audio: 80,
|
|
@@ -1104,41 +1137,41 @@ const R = (/* @__PURE__ */ Z()).check(/* @__PURE__ */ dt(), /* @__PURE__ */ ut()
|
|
|
1104
1137
|
typing: 40,
|
|
1105
1138
|
location: 20,
|
|
1106
1139
|
preview: 10
|
|
1107
|
-
},
|
|
1108
|
-
id: /* @__PURE__ */
|
|
1109
|
-
name: /* @__PURE__ */
|
|
1110
|
-
avatar: /* @__PURE__ */
|
|
1140
|
+
}, us = /* @__PURE__ */ S({
|
|
1141
|
+
id: /* @__PURE__ */ m(/* @__PURE__ */ b()),
|
|
1142
|
+
name: /* @__PURE__ */ m(/* @__PURE__ */ b()),
|
|
1143
|
+
avatar: /* @__PURE__ */ m(/* @__PURE__ */ b()),
|
|
1111
1144
|
// TODO allow using a track instead of a URL?
|
|
1112
|
-
color: /* @__PURE__ */
|
|
1113
|
-
}),
|
|
1114
|
-
name: /* @__PURE__ */
|
|
1115
|
-
}),
|
|
1145
|
+
color: /* @__PURE__ */ m(/* @__PURE__ */ b())
|
|
1146
|
+
}), ls = /* @__PURE__ */ S({
|
|
1147
|
+
name: /* @__PURE__ */ b()
|
|
1148
|
+
}), We = /* @__PURE__ */ S({
|
|
1116
1149
|
// See: https://w3c.github.io/webcodecs/codec_registry.html
|
|
1117
|
-
codec: /* @__PURE__ */
|
|
1150
|
+
codec: /* @__PURE__ */ b(),
|
|
1118
1151
|
// The container format, used to decode the timestamp and more.
|
|
1119
|
-
container:
|
|
1152
|
+
container: Mt,
|
|
1120
1153
|
// The description is used for some codecs.
|
|
1121
1154
|
// If provided, we can initialize the decoder based on the catalog alone.
|
|
1122
1155
|
// Otherwise, the initialization information is (repeated) before each key-frame.
|
|
1123
|
-
description: /* @__PURE__ */
|
|
1156
|
+
description: /* @__PURE__ */ m(/* @__PURE__ */ b()),
|
|
1124
1157
|
// hex encoded TODO use base64
|
|
1125
1158
|
// The width and height of the video in pixels.
|
|
1126
1159
|
// NOTE: formats that don't use a description can adjust these values in-band.
|
|
1127
|
-
codedWidth: /* @__PURE__ */
|
|
1128
|
-
codedHeight: /* @__PURE__ */
|
|
1160
|
+
codedWidth: /* @__PURE__ */ m(x),
|
|
1161
|
+
codedHeight: /* @__PURE__ */ m(x),
|
|
1129
1162
|
// Ratio of display width/height to coded width/height
|
|
1130
1163
|
// Allows stretching/squishing individual "pixels" of the video
|
|
1131
1164
|
// If not provided, the display ratio is 1:1
|
|
1132
|
-
displayAspectWidth: /* @__PURE__ */
|
|
1133
|
-
displayAspectHeight: /* @__PURE__ */
|
|
1165
|
+
displayAspectWidth: /* @__PURE__ */ m(x),
|
|
1166
|
+
displayAspectHeight: /* @__PURE__ */ m(x),
|
|
1134
1167
|
// The frame rate of the video in frames per second
|
|
1135
|
-
framerate: /* @__PURE__ */
|
|
1168
|
+
framerate: /* @__PURE__ */ m(/* @__PURE__ */ T()),
|
|
1136
1169
|
// The bitrate of the video in bits per second
|
|
1137
1170
|
// TODO: Support up to Number.MAX_SAFE_INTEGER
|
|
1138
|
-
bitrate: /* @__PURE__ */
|
|
1171
|
+
bitrate: /* @__PURE__ */ m(x),
|
|
1139
1172
|
// If true, the decoder will optimize for latency.
|
|
1140
1173
|
// Default: true
|
|
1141
|
-
optimizeForLatency: /* @__PURE__ */
|
|
1174
|
+
optimizeForLatency: /* @__PURE__ */ m(/* @__PURE__ */ Ee()),
|
|
1142
1175
|
// The maximum jitter before the next frame is emitted in milliseconds.
|
|
1143
1176
|
// The player's jitter buffer should be larger than this value.
|
|
1144
1177
|
// If not provided, the player should assume each frame is flushed immediately.
|
|
@@ -1147,36 +1180,36 @@ const R = (/* @__PURE__ */ Z()).check(/* @__PURE__ */ dt(), /* @__PURE__ */ ut()
|
|
|
1147
1180
|
// - If each frame is flushed immediately, this would be 1000/fps.
|
|
1148
1181
|
// - If there can be up to 3 b-frames in a row, this would be 3 * 1000/fps.
|
|
1149
1182
|
// - If frames are buffered into 2s segments, this would be 2s.
|
|
1150
|
-
jitter: /* @__PURE__ */
|
|
1151
|
-
}),
|
|
1152
|
-
/* @__PURE__ */
|
|
1183
|
+
jitter: /* @__PURE__ */ m(x)
|
|
1184
|
+
}), ds = /* @__PURE__ */ be([
|
|
1185
|
+
/* @__PURE__ */ S({
|
|
1153
1186
|
// A map of track name to rendition configuration.
|
|
1154
1187
|
// This is not an array in order for it to work with JSON Merge Patch.
|
|
1155
|
-
renditions: /* @__PURE__ */
|
|
1188
|
+
renditions: /* @__PURE__ */ xe(/* @__PURE__ */ b(), We),
|
|
1156
1189
|
// Render the video at this size in pixels.
|
|
1157
1190
|
// This is separate from the display aspect ratio because it does not require reinitialization.
|
|
1158
|
-
display: /* @__PURE__ */
|
|
1159
|
-
/* @__PURE__ */
|
|
1160
|
-
width:
|
|
1161
|
-
height:
|
|
1191
|
+
display: /* @__PURE__ */ m(
|
|
1192
|
+
/* @__PURE__ */ S({
|
|
1193
|
+
width: x,
|
|
1194
|
+
height: x
|
|
1162
1195
|
})
|
|
1163
1196
|
),
|
|
1164
1197
|
// The rotation of the video in degrees.
|
|
1165
1198
|
// Default: 0
|
|
1166
|
-
rotation: /* @__PURE__ */
|
|
1199
|
+
rotation: /* @__PURE__ */ m(/* @__PURE__ */ T()),
|
|
1167
1200
|
// If true, the decoder will flip the video horizontally
|
|
1168
1201
|
// Default: false
|
|
1169
|
-
flip: /* @__PURE__ */
|
|
1202
|
+
flip: /* @__PURE__ */ m(/* @__PURE__ */ Ee())
|
|
1170
1203
|
}),
|
|
1171
1204
|
// Backwards compatibility: transform old array of {track, config} to new object format
|
|
1172
|
-
/* @__PURE__ */
|
|
1173
|
-
/* @__PURE__ */
|
|
1174
|
-
/* @__PURE__ */
|
|
1175
|
-
track:
|
|
1176
|
-
config:
|
|
1205
|
+
/* @__PURE__ */ _t(
|
|
1206
|
+
/* @__PURE__ */ G(
|
|
1207
|
+
/* @__PURE__ */ S({
|
|
1208
|
+
track: ls,
|
|
1209
|
+
config: We
|
|
1177
1210
|
})
|
|
1178
1211
|
),
|
|
1179
|
-
/* @__PURE__ */
|
|
1212
|
+
/* @__PURE__ */ At((t) => {
|
|
1180
1213
|
const e = t[0]?.config;
|
|
1181
1214
|
return {
|
|
1182
1215
|
renditions: Object.fromEntries(t.map((n) => [n.track.name, n.config])),
|
|
@@ -1186,47 +1219,47 @@ const R = (/* @__PURE__ */ Z()).check(/* @__PURE__ */ dt(), /* @__PURE__ */ ut()
|
|
|
1186
1219
|
};
|
|
1187
1220
|
})
|
|
1188
1221
|
)
|
|
1189
|
-
]),
|
|
1190
|
-
video: /* @__PURE__ */
|
|
1191
|
-
audio: /* @__PURE__ */
|
|
1192
|
-
location: /* @__PURE__ */
|
|
1193
|
-
user: /* @__PURE__ */
|
|
1194
|
-
chat: /* @__PURE__ */
|
|
1195
|
-
capabilities: /* @__PURE__ */
|
|
1196
|
-
preview: /* @__PURE__ */
|
|
1222
|
+
]), hs = /* @__PURE__ */ S({
|
|
1223
|
+
video: /* @__PURE__ */ m(ds),
|
|
1224
|
+
audio: /* @__PURE__ */ m(ss),
|
|
1225
|
+
location: /* @__PURE__ */ m(cs),
|
|
1226
|
+
user: /* @__PURE__ */ m(us),
|
|
1227
|
+
chat: /* @__PURE__ */ m(as),
|
|
1228
|
+
capabilities: /* @__PURE__ */ m(os),
|
|
1229
|
+
preview: /* @__PURE__ */ m(de)
|
|
1197
1230
|
});
|
|
1198
|
-
function
|
|
1231
|
+
function fs(t) {
|
|
1199
1232
|
const n = new TextDecoder().decode(t);
|
|
1200
1233
|
try {
|
|
1201
1234
|
const s = JSON.parse(n);
|
|
1202
|
-
return
|
|
1235
|
+
return hs.parse(s);
|
|
1203
1236
|
} catch (s) {
|
|
1204
1237
|
throw console.warn("invalid catalog", n), s;
|
|
1205
1238
|
}
|
|
1206
1239
|
}
|
|
1207
|
-
async function
|
|
1240
|
+
async function ms(t) {
|
|
1208
1241
|
const e = await t.readFrame();
|
|
1209
1242
|
if (e)
|
|
1210
|
-
return
|
|
1243
|
+
return fs(e);
|
|
1211
1244
|
}
|
|
1212
|
-
function
|
|
1245
|
+
function kt(t) {
|
|
1213
1246
|
return t instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && t instanceof SharedArrayBuffer;
|
|
1214
1247
|
}
|
|
1215
|
-
const
|
|
1216
|
-
function
|
|
1248
|
+
const ps = "utf-16", Ae = "utf-16be", qe = "utf-16le", ue = "utf-8";
|
|
1249
|
+
function Tt(t, e = {}) {
|
|
1217
1250
|
let n;
|
|
1218
|
-
|
|
1251
|
+
kt(t) ? n = new DataView(t) : n = new DataView(t.buffer, t.byteOffset, t.byteLength);
|
|
1219
1252
|
let s = 0, { encoding: i } = e;
|
|
1220
1253
|
if (!i) {
|
|
1221
1254
|
const u = n.getUint8(0), l = n.getUint8(1);
|
|
1222
|
-
u == 239 && l == 187 && n.getUint8(2) == 191 ? (i =
|
|
1255
|
+
u == 239 && l == 187 && n.getUint8(2) == 191 ? (i = ue, s = 3) : u == 254 && l == 255 ? (i = Ae, s = 2) : u == 255 && l == 254 ? (i = qe, s = 2) : i = ue;
|
|
1223
1256
|
}
|
|
1224
1257
|
if (typeof TextDecoder < "u") return new TextDecoder(i).decode(n);
|
|
1225
|
-
const { byteLength: r } = n, o = i !==
|
|
1258
|
+
const { byteLength: r } = n, o = i !== Ae;
|
|
1226
1259
|
let a = "", c;
|
|
1227
1260
|
for (; s < r; ) {
|
|
1228
1261
|
switch (i) {
|
|
1229
|
-
case
|
|
1262
|
+
case ue:
|
|
1230
1263
|
if (c = n.getUint8(s), c < 128) s++;
|
|
1231
1264
|
else if (c >= 194 && c <= 223) if (s + 1 < r) {
|
|
1232
1265
|
const u = n.getUint8(s + 1);
|
|
@@ -1242,9 +1275,9 @@ function bt(t, e = {}) {
|
|
|
1242
1275
|
} else s++;
|
|
1243
1276
|
else s++;
|
|
1244
1277
|
break;
|
|
1245
|
-
case
|
|
1246
|
-
case
|
|
1247
|
-
case
|
|
1278
|
+
case Ae:
|
|
1279
|
+
case ps:
|
|
1280
|
+
case qe:
|
|
1248
1281
|
c = n.getUint16(s, o), s += 2;
|
|
1249
1282
|
break;
|
|
1250
1283
|
}
|
|
@@ -1252,13 +1285,13 @@ function bt(t, e = {}) {
|
|
|
1252
1285
|
}
|
|
1253
1286
|
return a;
|
|
1254
1287
|
}
|
|
1255
|
-
function
|
|
1288
|
+
function gs(t) {
|
|
1256
1289
|
return new TextEncoder().encode(t);
|
|
1257
1290
|
}
|
|
1258
|
-
function
|
|
1291
|
+
function ws(t) {
|
|
1259
1292
|
return { writers: t?.writers ?? {} };
|
|
1260
1293
|
}
|
|
1261
|
-
const
|
|
1294
|
+
const ys = [
|
|
1262
1295
|
"dinf",
|
|
1263
1296
|
"edts",
|
|
1264
1297
|
"grpl",
|
|
@@ -1279,10 +1312,10 @@ const as = [
|
|
|
1279
1312
|
"udta",
|
|
1280
1313
|
"vttc"
|
|
1281
1314
|
];
|
|
1282
|
-
function
|
|
1283
|
-
return "boxes" in t ||
|
|
1315
|
+
function Ut(t) {
|
|
1316
|
+
return "boxes" in t || ys.includes(t.type);
|
|
1284
1317
|
}
|
|
1285
|
-
const
|
|
1318
|
+
const He = "utf8", B = "uint", te = "template", Ge = "string", Xe = "int", Ye = "data";
|
|
1286
1319
|
var k = class {
|
|
1287
1320
|
/**
|
|
1288
1321
|
* Constructs a new IsoBoxWriteView.
|
|
@@ -1340,14 +1373,14 @@ var k = class {
|
|
|
1340
1373
|
this.writeUint(0, 1);
|
|
1341
1374
|
}
|
|
1342
1375
|
}, this.writeUtf8TerminatedString = (n) => {
|
|
1343
|
-
const s =
|
|
1376
|
+
const s = gs(n);
|
|
1344
1377
|
new Uint8Array(this.dataView.buffer).set(s, this.cursor), this.cursor += s.length, this.writeUint(0, 1);
|
|
1345
1378
|
}, this.writeBytes = (n) => {
|
|
1346
1379
|
Array.isArray(n) || (n = [n]);
|
|
1347
1380
|
for (const s of n)
|
|
1348
1381
|
new Uint8Array(this.dataView.buffer).set(s, this.cursor), this.cursor += s.length;
|
|
1349
1382
|
}, this.writeArray = (n, s, i, r) => {
|
|
1350
|
-
const o = s ===
|
|
1383
|
+
const o = s === B ? this.writeUint : s === te ? this.writeTemplate : this.writeInt;
|
|
1351
1384
|
for (let a = 0; a < r; a++) o(n[a] ?? 0, i);
|
|
1352
1385
|
}, this.writeTemplate = (n, s) => {
|
|
1353
1386
|
const r = Math.round(n * Math.pow(2, s === 4 ? 16 : 8));
|
|
@@ -1390,34 +1423,34 @@ var k = class {
|
|
|
1390
1423
|
this.writeUint(t, 1), this.writeUint(e, 3);
|
|
1391
1424
|
}
|
|
1392
1425
|
};
|
|
1393
|
-
function
|
|
1394
|
-
return Array.from(t, (n) =>
|
|
1426
|
+
function Et(t, e) {
|
|
1427
|
+
return Array.from(t, (n) => bs(n, e));
|
|
1395
1428
|
}
|
|
1396
|
-
function
|
|
1397
|
-
const n =
|
|
1429
|
+
function Re(t, e) {
|
|
1430
|
+
const n = Et(t, e);
|
|
1398
1431
|
return {
|
|
1399
1432
|
bytes: n,
|
|
1400
1433
|
size: n.reduce((s, i) => s + i.byteLength, 0)
|
|
1401
1434
|
};
|
|
1402
1435
|
}
|
|
1403
|
-
function
|
|
1404
|
-
const { bytes: s, size: i } =
|
|
1436
|
+
function vs(t, e) {
|
|
1437
|
+
const { bytes: s, size: i } = Re(t.boxes, e), r = 8 + i, o = new k(t.type, r);
|
|
1405
1438
|
return o.writeBytes(s), o;
|
|
1406
1439
|
}
|
|
1407
|
-
function
|
|
1440
|
+
function bs(t, e) {
|
|
1408
1441
|
let n = null;
|
|
1409
1442
|
if ("type" in t) {
|
|
1410
1443
|
const { type: s } = t, i = e.writers?.[s];
|
|
1411
|
-
if (i ? n = i(t, e) :
|
|
1444
|
+
if (i ? n = i(t, e) : Ut(t) ? n = vs(t, e) : "view" in t && (n = t.view), !n) throw new Error(`No writer found for box type: ${s}`);
|
|
1412
1445
|
}
|
|
1413
1446
|
if ("buffer" in t && (n = t), !n) throw new Error("Invalid box");
|
|
1414
1447
|
return new Uint8Array(n.buffer, n.byteOffset, n.byteLength);
|
|
1415
1448
|
}
|
|
1416
|
-
function
|
|
1449
|
+
function Ss(t, e, n) {
|
|
1417
1450
|
const s = n > 0 ? n : t.byteLength - (e - t.byteOffset);
|
|
1418
1451
|
return new Uint8Array(t.buffer, e, Math.max(s, 0));
|
|
1419
1452
|
}
|
|
1420
|
-
function
|
|
1453
|
+
function As(t, e, n) {
|
|
1421
1454
|
let s = NaN;
|
|
1422
1455
|
const i = e - t.byteOffset;
|
|
1423
1456
|
switch (n) {
|
|
@@ -1437,7 +1470,7 @@ function ds(t, e, n) {
|
|
|
1437
1470
|
}
|
|
1438
1471
|
return s;
|
|
1439
1472
|
}
|
|
1440
|
-
function
|
|
1473
|
+
function Y(t, e, n) {
|
|
1441
1474
|
const s = e - t.byteOffset;
|
|
1442
1475
|
let i = NaN, r, o;
|
|
1443
1476
|
switch (n) {
|
|
@@ -1459,43 +1492,43 @@ function H(t, e, n) {
|
|
|
1459
1492
|
}
|
|
1460
1493
|
return i;
|
|
1461
1494
|
}
|
|
1462
|
-
function
|
|
1495
|
+
function Ke(t, e, n) {
|
|
1463
1496
|
let s = "";
|
|
1464
1497
|
for (let i = 0; i < n; i++) {
|
|
1465
|
-
const r =
|
|
1498
|
+
const r = Y(t, e + i, 1);
|
|
1466
1499
|
s += String.fromCharCode(r);
|
|
1467
1500
|
}
|
|
1468
1501
|
return s;
|
|
1469
1502
|
}
|
|
1470
|
-
function
|
|
1503
|
+
function _s(t, e, n) {
|
|
1471
1504
|
const s = n / 2;
|
|
1472
|
-
return
|
|
1505
|
+
return Y(t, e, s) + Y(t, e + s, s) / Math.pow(2, s);
|
|
1473
1506
|
}
|
|
1474
|
-
function
|
|
1507
|
+
function Ms(t, e) {
|
|
1475
1508
|
let n = "", s = e;
|
|
1476
1509
|
for (; s - t.byteOffset < t.byteLength; ) {
|
|
1477
|
-
const i =
|
|
1510
|
+
const i = Y(t, s, 1);
|
|
1478
1511
|
if (i === 0) break;
|
|
1479
1512
|
n += String.fromCharCode(i), s++;
|
|
1480
1513
|
}
|
|
1481
1514
|
return n;
|
|
1482
1515
|
}
|
|
1483
|
-
function
|
|
1516
|
+
function zs(t, e) {
|
|
1484
1517
|
const n = t.byteLength - (e - t.byteOffset);
|
|
1485
|
-
return n > 0 ?
|
|
1518
|
+
return n > 0 ? Tt(new DataView(t.buffer, e, n), { encoding: ue }) : "";
|
|
1486
1519
|
}
|
|
1487
|
-
function
|
|
1520
|
+
function ks(t, e) {
|
|
1488
1521
|
const n = t.byteLength - (e - t.byteOffset);
|
|
1489
1522
|
let s = "";
|
|
1490
1523
|
if (n > 0) {
|
|
1491
1524
|
const i = new DataView(t.buffer, e, n);
|
|
1492
1525
|
let r = 0;
|
|
1493
1526
|
for (; r < n && i.getUint8(r) !== 0; r++) ;
|
|
1494
|
-
s =
|
|
1527
|
+
s = Tt(new DataView(t.buffer, e, r), { encoding: ue });
|
|
1495
1528
|
}
|
|
1496
1529
|
return s;
|
|
1497
1530
|
}
|
|
1498
|
-
var
|
|
1531
|
+
var Ts = class xt {
|
|
1499
1532
|
/**
|
|
1500
1533
|
* Creates a new IsoView instance. Similar to DataView, but with additional
|
|
1501
1534
|
* methods for reading ISO BMFF data. It implements the iterator protocol,
|
|
@@ -1506,35 +1539,35 @@ var gs = class Mt {
|
|
|
1506
1539
|
*/
|
|
1507
1540
|
constructor(e, n) {
|
|
1508
1541
|
this.truncated = !1, this.slice = (s, i) => {
|
|
1509
|
-
const r = new
|
|
1542
|
+
const r = new xt(new DataView(this.dataView.buffer, s, i), this.config), o = this.offset - s, a = i - o;
|
|
1510
1543
|
return this.offset += a, r.jump(o), r;
|
|
1511
1544
|
}, this.read = (s, i = 0) => {
|
|
1512
1545
|
const { dataView: r, offset: o } = this;
|
|
1513
1546
|
let a, c = i;
|
|
1514
1547
|
switch (s) {
|
|
1515
|
-
case
|
|
1516
|
-
a =
|
|
1548
|
+
case B:
|
|
1549
|
+
a = Y(r, o, i);
|
|
1517
1550
|
break;
|
|
1518
|
-
case
|
|
1519
|
-
a =
|
|
1551
|
+
case Xe:
|
|
1552
|
+
a = As(r, o, i);
|
|
1520
1553
|
break;
|
|
1521
|
-
case
|
|
1522
|
-
a =
|
|
1554
|
+
case te:
|
|
1555
|
+
a = _s(r, o, i);
|
|
1523
1556
|
break;
|
|
1524
|
-
case
|
|
1525
|
-
i === -1 ? (a =
|
|
1557
|
+
case Ge:
|
|
1558
|
+
i === -1 ? (a = Ms(r, o), c = a.length + 1) : a = Ke(r, o, i);
|
|
1526
1559
|
break;
|
|
1527
|
-
case
|
|
1528
|
-
a =
|
|
1560
|
+
case Ye:
|
|
1561
|
+
a = Ss(r, o, i), c = a.length;
|
|
1529
1562
|
break;
|
|
1530
|
-
case
|
|
1531
|
-
i === -1 ? (a =
|
|
1563
|
+
case He:
|
|
1564
|
+
i === -1 ? (a = ks(r, o), c = a.length + 1) : a = zs(r, o);
|
|
1532
1565
|
break;
|
|
1533
1566
|
default:
|
|
1534
1567
|
a = -1;
|
|
1535
1568
|
}
|
|
1536
1569
|
return this.offset += c, a;
|
|
1537
|
-
}, this.readUint = (s) => this.read(
|
|
1570
|
+
}, this.readUint = (s) => this.read(B, s), this.readInt = (s) => this.read(Xe, s), this.readString = (s) => this.read(Ge, s), this.readTemplate = (s) => this.read(te, s), this.readData = (s) => this.read(Ye, s), this.readUtf8 = (s) => this.read(He, s), this.readFullBox = () => ({
|
|
1538
1571
|
version: this.readUint(1),
|
|
1539
1572
|
flags: this.readUint(3)
|
|
1540
1573
|
}), this.readArray = (s, i, r) => {
|
|
@@ -1546,11 +1579,11 @@ var gs = class Mt {
|
|
|
1546
1579
|
}, this.readBox = () => {
|
|
1547
1580
|
const { dataView: s, offset: i } = this;
|
|
1548
1581
|
let r = 0;
|
|
1549
|
-
const o =
|
|
1582
|
+
const o = Y(s, i, 4), a = Ke(s, i + 4, 4), c = {
|
|
1550
1583
|
size: o,
|
|
1551
1584
|
type: a
|
|
1552
1585
|
};
|
|
1553
|
-
r += 8, c.size === 1 && (c.largesize =
|
|
1586
|
+
r += 8, c.size === 1 && (c.largesize = Y(s, i + r, 8), r += 8);
|
|
1554
1587
|
const u = c.size === 0 ? this.bytesRemaining : c.largesize ?? c.size;
|
|
1555
1588
|
if (this.cursor + u > s.byteLength)
|
|
1556
1589
|
throw this.truncated = !0, new Error("Truncated box");
|
|
@@ -1564,7 +1597,7 @@ var gs = class Mt {
|
|
|
1564
1597
|
const r = [];
|
|
1565
1598
|
for (let o = 0; o < s; o++) r.push(i());
|
|
1566
1599
|
return r;
|
|
1567
|
-
}, this.dataView =
|
|
1600
|
+
}, this.dataView = kt(e) ? new DataView(e) : e instanceof DataView ? e : new DataView(e.buffer, e.byteOffset, e.byteLength), this.offset = this.dataView.byteOffset, this.config = n || {};
|
|
1568
1601
|
}
|
|
1569
1602
|
/**
|
|
1570
1603
|
* The buffer of the data view.
|
|
@@ -1611,7 +1644,7 @@ var gs = class Mt {
|
|
|
1611
1644
|
const { readers: e = {} } = this.config;
|
|
1612
1645
|
for (; !this.done; ) try {
|
|
1613
1646
|
const n = this.readBox(), { type: s, view: i } = n, r = e[s] || e[s.trim()];
|
|
1614
|
-
if (r && Object.assign(n, r(i, s)),
|
|
1647
|
+
if (r && Object.assign(n, r(i, s)), Ut(n) && !n.boxes) {
|
|
1615
1648
|
const o = [];
|
|
1616
1649
|
for (const a of i) o.push(a);
|
|
1617
1650
|
n.boxes = o;
|
|
@@ -1623,28 +1656,100 @@ var gs = class Mt {
|
|
|
1623
1656
|
}
|
|
1624
1657
|
}
|
|
1625
1658
|
};
|
|
1626
|
-
function
|
|
1659
|
+
function Be(t, e) {
|
|
1627
1660
|
const n = [];
|
|
1628
|
-
for (const s of new
|
|
1661
|
+
for (const s of new Ts(t, e)) n.push(s);
|
|
1629
1662
|
return n;
|
|
1630
1663
|
}
|
|
1631
|
-
function
|
|
1632
|
-
return
|
|
1664
|
+
function Us(t, e) {
|
|
1665
|
+
return Et(t, ws(e));
|
|
1633
1666
|
}
|
|
1634
|
-
function
|
|
1667
|
+
function Es(t, e) {
|
|
1668
|
+
const { readArray: n, readUint: s, readTemplate: i, readBoxes: r } = e;
|
|
1669
|
+
return {
|
|
1670
|
+
type: t,
|
|
1671
|
+
reserved1: n(B, 1, 6),
|
|
1672
|
+
dataReferenceIndex: s(2),
|
|
1673
|
+
reserved2: n(B, 4, 2),
|
|
1674
|
+
channelcount: s(2),
|
|
1675
|
+
samplesize: s(2),
|
|
1676
|
+
preDefined: s(2),
|
|
1677
|
+
reserved3: s(2),
|
|
1678
|
+
samplerate: i(4),
|
|
1679
|
+
boxes: r()
|
|
1680
|
+
};
|
|
1681
|
+
}
|
|
1682
|
+
function Ce(t, e) {
|
|
1683
|
+
const { readArray: n, readUint: s, readInt: i, readTemplate: r, readBoxes: o } = e;
|
|
1684
|
+
return {
|
|
1685
|
+
type: t,
|
|
1686
|
+
reserved1: n(B, 1, 6),
|
|
1687
|
+
dataReferenceIndex: s(2),
|
|
1688
|
+
preDefined1: s(2),
|
|
1689
|
+
reserved2: s(2),
|
|
1690
|
+
preDefined2: n(B, 4, 3),
|
|
1691
|
+
width: s(2),
|
|
1692
|
+
height: s(2),
|
|
1693
|
+
horizresolution: r(4),
|
|
1694
|
+
vertresolution: r(4),
|
|
1695
|
+
reserved3: s(4),
|
|
1696
|
+
frameCount: s(2),
|
|
1697
|
+
compressorName: n(B, 1, 32),
|
|
1698
|
+
depth: s(2),
|
|
1699
|
+
preDefined3: i(2),
|
|
1700
|
+
boxes: o()
|
|
1701
|
+
};
|
|
1702
|
+
}
|
|
1703
|
+
function Je(t) {
|
|
1704
|
+
return Ce("avc1", t);
|
|
1705
|
+
}
|
|
1706
|
+
function xs(t) {
|
|
1707
|
+
return Ce("hev1", t);
|
|
1708
|
+
}
|
|
1709
|
+
function Rs(t) {
|
|
1710
|
+
return Ce("hvc1", t);
|
|
1711
|
+
}
|
|
1712
|
+
function Bs(t) {
|
|
1635
1713
|
return {
|
|
1636
1714
|
type: "mdat",
|
|
1637
1715
|
data: t.readData(-1)
|
|
1638
1716
|
};
|
|
1639
1717
|
}
|
|
1640
|
-
function
|
|
1718
|
+
function Cs(t) {
|
|
1719
|
+
const { version: e, flags: n } = t.readFullBox(), s = t.readUint(e == 1 ? 8 : 4), i = t.readUint(e == 1 ? 8 : 4), r = t.readUint(4), o = t.readUint(e == 1 ? 8 : 4), a = t.readUint(2);
|
|
1720
|
+
return {
|
|
1721
|
+
type: "mdhd",
|
|
1722
|
+
version: e,
|
|
1723
|
+
flags: n,
|
|
1724
|
+
creationTime: s,
|
|
1725
|
+
modificationTime: i,
|
|
1726
|
+
timescale: r,
|
|
1727
|
+
duration: o,
|
|
1728
|
+
language: String.fromCharCode((a >> 10 & 31) + 96, (a >> 5 & 31) + 96, (a & 31) + 96),
|
|
1729
|
+
preDefined: t.readUint(2)
|
|
1730
|
+
};
|
|
1731
|
+
}
|
|
1732
|
+
function Is(t) {
|
|
1641
1733
|
return {
|
|
1642
1734
|
type: "mfhd",
|
|
1643
1735
|
...t.readFullBox(),
|
|
1644
1736
|
sequenceNumber: t.readUint(4)
|
|
1645
1737
|
};
|
|
1646
1738
|
}
|
|
1647
|
-
function
|
|
1739
|
+
function Os(t) {
|
|
1740
|
+
return Es("mp4a", t);
|
|
1741
|
+
}
|
|
1742
|
+
function Ds(t) {
|
|
1743
|
+
const { version: e, flags: n } = t.readFullBox(), s = t.readUint(4);
|
|
1744
|
+
return {
|
|
1745
|
+
type: "stsd",
|
|
1746
|
+
version: e,
|
|
1747
|
+
flags: n,
|
|
1748
|
+
entryCount: s,
|
|
1749
|
+
entries: t.readBoxes(s)
|
|
1750
|
+
};
|
|
1751
|
+
}
|
|
1752
|
+
function Ls(t) {
|
|
1648
1753
|
const { version: e, flags: n } = t.readFullBox();
|
|
1649
1754
|
return {
|
|
1650
1755
|
type: "tfdt",
|
|
@@ -1653,7 +1758,7 @@ function vs(t) {
|
|
|
1653
1758
|
baseMediaDecodeTime: t.readUint(e == 1 ? 8 : 4)
|
|
1654
1759
|
};
|
|
1655
1760
|
}
|
|
1656
|
-
function
|
|
1761
|
+
function Ps(t) {
|
|
1657
1762
|
const { version: e, flags: n } = t.readFullBox();
|
|
1658
1763
|
return {
|
|
1659
1764
|
type: "tfhd",
|
|
@@ -1667,7 +1772,28 @@ function Ss(t) {
|
|
|
1667
1772
|
defaultSampleFlags: n & 32 ? t.readUint(4) : void 0
|
|
1668
1773
|
};
|
|
1669
1774
|
}
|
|
1670
|
-
function
|
|
1775
|
+
function Ns(t) {
|
|
1776
|
+
const { version: e, flags: n } = t.readFullBox(), s = e === 1 ? 8 : 4;
|
|
1777
|
+
return {
|
|
1778
|
+
type: "tkhd",
|
|
1779
|
+
version: e,
|
|
1780
|
+
flags: n,
|
|
1781
|
+
creationTime: t.readUint(s),
|
|
1782
|
+
modificationTime: t.readUint(s),
|
|
1783
|
+
trackId: t.readUint(4),
|
|
1784
|
+
reserved1: t.readUint(4),
|
|
1785
|
+
duration: t.readUint(s),
|
|
1786
|
+
reserved2: t.readArray(B, 4, 2),
|
|
1787
|
+
layer: t.readUint(2),
|
|
1788
|
+
alternateGroup: t.readUint(2),
|
|
1789
|
+
volume: t.readTemplate(2),
|
|
1790
|
+
reserved3: t.readUint(2),
|
|
1791
|
+
matrix: t.readArray(te, 4, 9),
|
|
1792
|
+
width: t.readTemplate(4),
|
|
1793
|
+
height: t.readTemplate(4)
|
|
1794
|
+
};
|
|
1795
|
+
}
|
|
1796
|
+
function Fs(t) {
|
|
1671
1797
|
const { version: e, flags: n } = t.readFullBox(), s = t.readUint(4);
|
|
1672
1798
|
let i, r;
|
|
1673
1799
|
n & 1 && (i = t.readInt(4)), n & 4 && (r = t.readUint(4));
|
|
@@ -1685,70 +1811,70 @@ function Ms(t) {
|
|
|
1685
1811
|
samples: o
|
|
1686
1812
|
};
|
|
1687
1813
|
}
|
|
1688
|
-
function
|
|
1689
|
-
const r = t.entries.length, { bytes: o, size: a } =
|
|
1814
|
+
function $s(t, e) {
|
|
1815
|
+
const r = t.entries.length, { bytes: o, size: a } = Re(t.entries, e), c = new k("dref", 16 + a);
|
|
1690
1816
|
return c.writeFullBox(t.version, t.flags), c.writeUint(r, 4), c.writeBytes(o), c;
|
|
1691
1817
|
}
|
|
1692
|
-
function
|
|
1818
|
+
function js(t) {
|
|
1693
1819
|
const i = t.compatibleBrands.length * 4, r = new k("ftyp", 16 + i);
|
|
1694
1820
|
r.writeString(t.majorBrand), r.writeUint(t.minorVersion, 4);
|
|
1695
1821
|
for (const o of t.compatibleBrands) r.writeString(o);
|
|
1696
1822
|
return r;
|
|
1697
1823
|
}
|
|
1698
|
-
function
|
|
1824
|
+
function Zs(t) {
|
|
1699
1825
|
const o = t.name.length + 1, a = new k("hdlr", 32 + o);
|
|
1700
|
-
return a.writeFullBox(t.version, t.flags), a.writeUint(t.preDefined, 4), a.writeString(t.handlerType), a.writeArray(t.reserved,
|
|
1826
|
+
return a.writeFullBox(t.version, t.flags), a.writeUint(t.preDefined, 4), a.writeString(t.handlerType), a.writeArray(t.reserved, B, 4, 3), a.writeTerminatedString(t.name), a;
|
|
1701
1827
|
}
|
|
1702
|
-
function
|
|
1828
|
+
function Vs(t) {
|
|
1703
1829
|
const e = new k("mdat", 8 + t.data.length);
|
|
1704
1830
|
return e.writeBytes(t.data), e;
|
|
1705
1831
|
}
|
|
1706
|
-
function
|
|
1832
|
+
function Ws(t) {
|
|
1707
1833
|
const e = t.version === 1 ? 8 : 4, n = 8, s = 4, i = e * 3, r = new k("mdhd", n + s + i + 4 + 2 + 2);
|
|
1708
1834
|
r.writeFullBox(t.version, t.flags), r.writeUint(t.creationTime, e), r.writeUint(t.modificationTime, e), r.writeUint(t.timescale, 4), r.writeUint(t.duration, e);
|
|
1709
1835
|
const o = t.language.length >= 3 ? (t.language.charCodeAt(0) - 96 & 31) << 10 | (t.language.charCodeAt(1) - 96 & 31) << 5 | t.language.charCodeAt(2) - 96 & 31 : 0;
|
|
1710
1836
|
return r.writeUint(o, 2), r.writeUint(t.preDefined, 2), r;
|
|
1711
1837
|
}
|
|
1712
|
-
function
|
|
1838
|
+
function qs(t) {
|
|
1713
1839
|
const e = new k("mfhd", 16);
|
|
1714
1840
|
return e.writeFullBox(t.version, t.flags), e.writeUint(t.sequenceNumber, 4), e;
|
|
1715
1841
|
}
|
|
1716
|
-
function
|
|
1842
|
+
function Hs(t) {
|
|
1717
1843
|
const e = t.version === 1 ? 8 : 4, n = 8, s = 4, i = e * 3, r = new k("mvhd", n + s + i + 4 + 4 + 2 + 2 + 8 + 36 + 24 + 4);
|
|
1718
|
-
return r.writeFullBox(t.version, t.flags), r.writeUint(t.creationTime, e), r.writeUint(t.modificationTime, e), r.writeUint(t.timescale, 4), r.writeUint(t.duration, e), r.writeTemplate(t.rate, 4), r.writeTemplate(t.volume, 2), r.writeUint(t.reserved1, 2), r.writeArray(t.reserved2,
|
|
1844
|
+
return r.writeFullBox(t.version, t.flags), r.writeUint(t.creationTime, e), r.writeUint(t.modificationTime, e), r.writeUint(t.timescale, 4), r.writeUint(t.duration, e), r.writeTemplate(t.rate, 4), r.writeTemplate(t.volume, 2), r.writeUint(t.reserved1, 2), r.writeArray(t.reserved2, B, 4, 2), r.writeArray(t.matrix, te, 4, 9), r.writeArray(t.preDefined, B, 4, 6), r.writeUint(t.nextTrackId, 4), r;
|
|
1719
1845
|
}
|
|
1720
|
-
function
|
|
1846
|
+
function Gs(t) {
|
|
1721
1847
|
const e = new k("smhd", 16);
|
|
1722
1848
|
return e.writeFullBox(t.version, t.flags), e.writeUint(t.balance, 2), e.writeUint(t.reserved, 2), e;
|
|
1723
1849
|
}
|
|
1724
|
-
function
|
|
1725
|
-
const r = t.entries.length, { bytes: o, size: a } =
|
|
1850
|
+
function Xs(t, e) {
|
|
1851
|
+
const r = t.entries.length, { bytes: o, size: a } = Re(t.entries, e), c = new k("stsd", 16 + a);
|
|
1726
1852
|
return c.writeFullBox(t.version, t.flags), c.writeUint(r, 4), c.writeBytes(o), c;
|
|
1727
1853
|
}
|
|
1728
|
-
function
|
|
1854
|
+
function Ys(t) {
|
|
1729
1855
|
const i = t.entryCount * 8, r = new k("stts", 16 + i);
|
|
1730
1856
|
r.writeFullBox(t.version, t.flags), r.writeUint(t.entryCount, 4);
|
|
1731
1857
|
for (const o of t.entries)
|
|
1732
1858
|
r.writeUint(o.sampleCount, 4), r.writeUint(o.sampleDelta, 4);
|
|
1733
1859
|
return r;
|
|
1734
1860
|
}
|
|
1735
|
-
function
|
|
1861
|
+
function Ks(t) {
|
|
1736
1862
|
const e = t.version === 1 ? 8 : 4, n = 8, s = 4, i = e, r = new k("tfdt", n + s + i);
|
|
1737
1863
|
return r.writeFullBox(t.version, t.flags), r.writeUint(t.baseMediaDecodeTime, e), r;
|
|
1738
1864
|
}
|
|
1739
|
-
function
|
|
1865
|
+
function Js(t) {
|
|
1740
1866
|
const i = t.flags & 1 ? 8 : 0, r = t.flags & 2 ? 4 : 0, o = t.flags & 8 ? 4 : 0, a = t.flags & 16 ? 4 : 0, c = t.flags & 32 ? 4 : 0, u = new k("tfhd", 16 + i + r + o + a + c);
|
|
1741
1867
|
return u.writeFullBox(t.version, t.flags), u.writeUint(t.trackId, 4), t.flags & 1 && u.writeUint(t.baseDataOffset ?? 0, 8), t.flags & 2 && u.writeUint(t.sampleDescriptionIndex ?? 0, 4), t.flags & 8 && u.writeUint(t.defaultSampleDuration ?? 0, 4), t.flags & 16 && u.writeUint(t.defaultSampleSize ?? 0, 4), t.flags & 32 && u.writeUint(t.defaultSampleFlags ?? 0, 4), u;
|
|
1742
1868
|
}
|
|
1743
|
-
function
|
|
1869
|
+
function Qs(t) {
|
|
1744
1870
|
const e = t.version === 1 ? 8 : 4, n = 8, s = 4, i = e * 3, r = new k("tkhd", n + s + i + 4 + 4 + 8 + 2 + 2 + 2 + 2 + 36 + 4 + 4);
|
|
1745
|
-
return r.writeFullBox(t.version, t.flags), r.writeUint(t.creationTime, e), r.writeUint(t.modificationTime, e), r.writeUint(t.trackId, 4), r.writeUint(t.reserved1, 4), r.writeUint(t.duration, e), r.writeArray(t.reserved2,
|
|
1871
|
+
return r.writeFullBox(t.version, t.flags), r.writeUint(t.creationTime, e), r.writeUint(t.modificationTime, e), r.writeUint(t.trackId, 4), r.writeUint(t.reserved1, 4), r.writeUint(t.duration, e), r.writeArray(t.reserved2, B, 4, 2), r.writeUint(t.layer, 2), r.writeUint(t.alternateGroup, 2), r.writeTemplate(t.volume, 2), r.writeUint(t.reserved3, 2), r.writeArray(t.matrix, te, 4, 9), r.writeTemplate(t.width, 4), r.writeTemplate(t.height, 4), r;
|
|
1746
1872
|
}
|
|
1747
|
-
function
|
|
1873
|
+
function ei(t) {
|
|
1748
1874
|
const e = new k("trex", 32);
|
|
1749
1875
|
return e.writeFullBox(t.version, t.flags), e.writeUint(t.trackId, 4), e.writeUint(t.defaultSampleDescriptionIndex, 4), e.writeUint(t.defaultSampleDuration, 4), e.writeUint(t.defaultSampleSize, 4), e.writeUint(t.defaultSampleFlags, 4), e;
|
|
1750
1876
|
}
|
|
1751
|
-
function
|
|
1877
|
+
function ti(t) {
|
|
1752
1878
|
const i = t.flags & 1 ? 4 : 0, r = t.flags & 4 ? 4 : 0;
|
|
1753
1879
|
let o = 0;
|
|
1754
1880
|
t.flags & 256 && (o += 4), t.flags & 512 && (o += 4), t.flags & 1024 && (o += 4), t.flags & 2048 && (o += 4);
|
|
@@ -1758,48 +1884,96 @@ function Ds(t) {
|
|
|
1758
1884
|
t.flags & 256 && c.writeUint(u.sampleDuration ?? 0, 4), t.flags & 512 && c.writeUint(u.sampleSize ?? 0, 4), t.flags & 1024 && c.writeUint(u.sampleFlags ?? 0, 4), t.flags & 2048 && c.writeUint(u.sampleCompositionTimeOffset ?? 0, 4);
|
|
1759
1885
|
return c;
|
|
1760
1886
|
}
|
|
1761
|
-
function
|
|
1887
|
+
function ni(t) {
|
|
1762
1888
|
const s = t.location.length + 1, i = new k("url ", 12 + s);
|
|
1763
1889
|
return i.writeFullBox(t.version, t.flags), i.writeTerminatedString(t.location), i;
|
|
1764
1890
|
}
|
|
1765
|
-
function
|
|
1891
|
+
function si(t) {
|
|
1766
1892
|
const e = new k("vmhd", 20);
|
|
1767
|
-
return e.writeFullBox(t.version, t.flags), e.writeUint(t.graphicsmode, 2), e.writeArray(t.opcolor,
|
|
1768
|
-
}
|
|
1769
|
-
const
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1893
|
+
return e.writeFullBox(t.version, t.flags), e.writeUint(t.graphicsmode, 2), e.writeArray(t.opcolor, B, 2, 3), e;
|
|
1894
|
+
}
|
|
1895
|
+
const ii = {
|
|
1896
|
+
avc1: Je,
|
|
1897
|
+
avc3: Je,
|
|
1898
|
+
// avc3 has same structure
|
|
1899
|
+
hvc1: Rs,
|
|
1900
|
+
hev1: xs,
|
|
1901
|
+
mp4a: Os,
|
|
1902
|
+
stsd: Ds,
|
|
1903
|
+
mdhd: Cs,
|
|
1904
|
+
tkhd: Ns
|
|
1905
|
+
}, Rt = {
|
|
1906
|
+
mfhd: Is,
|
|
1907
|
+
tfhd: Ps,
|
|
1908
|
+
tfdt: Ls,
|
|
1909
|
+
trun: Fs,
|
|
1910
|
+
mdat: Bs
|
|
1775
1911
|
};
|
|
1776
|
-
function
|
|
1912
|
+
function N(t, e) {
|
|
1777
1913
|
for (const n of t) {
|
|
1778
1914
|
if (e(n))
|
|
1779
1915
|
return n;
|
|
1780
1916
|
const s = n.boxes;
|
|
1781
1917
|
if (s && Array.isArray(s)) {
|
|
1782
|
-
const i =
|
|
1918
|
+
const i = N(s, e);
|
|
1783
1919
|
if (i) return i;
|
|
1784
1920
|
}
|
|
1785
1921
|
}
|
|
1786
1922
|
}
|
|
1787
|
-
function
|
|
1923
|
+
function Ie(t) {
|
|
1788
1924
|
const e = new ArrayBuffer(t.byteLength);
|
|
1789
1925
|
return new Uint8Array(e).set(t), e;
|
|
1790
1926
|
}
|
|
1791
|
-
function
|
|
1927
|
+
function H(t) {
|
|
1792
1928
|
return (e) => e.type === t;
|
|
1793
1929
|
}
|
|
1794
|
-
function
|
|
1795
|
-
const
|
|
1796
|
-
|
|
1930
|
+
function ri(t) {
|
|
1931
|
+
const e = Be(Ie(t), { readers: ii }), n = N(e, H("mdhd"));
|
|
1932
|
+
if (!n)
|
|
1933
|
+
throw new Error("No mdhd box found in init segment");
|
|
1934
|
+
const i = N(e, H("tkhd"))?.trackId ?? 1, r = N(e, H("stsd"));
|
|
1935
|
+
if (!r?.entries || r.entries.length === 0)
|
|
1936
|
+
throw new Error("No stsd box found in init segment");
|
|
1937
|
+
const o = r.entries[0];
|
|
1938
|
+
return {
|
|
1939
|
+
description: oi(o),
|
|
1940
|
+
timescale: n.timescale,
|
|
1941
|
+
trackId: i
|
|
1942
|
+
};
|
|
1943
|
+
}
|
|
1944
|
+
function oi(t) {
|
|
1945
|
+
if (!(!t.boxes || !Array.isArray(t.boxes)))
|
|
1946
|
+
for (const e of t.boxes) {
|
|
1947
|
+
if (e instanceof Uint8Array) {
|
|
1948
|
+
if (e.length > 8) {
|
|
1949
|
+
const s = String.fromCharCode(e[4], e[5], e[6], e[7]);
|
|
1950
|
+
if (s === "avcC" || s === "hvcC" || s === "esds" || s === "dOps")
|
|
1951
|
+
return new Uint8Array(e.slice(8));
|
|
1952
|
+
}
|
|
1953
|
+
continue;
|
|
1954
|
+
}
|
|
1955
|
+
const n = e.type;
|
|
1956
|
+
if (n === "avcC" || n === "hvcC" || n === "esds" || n === "dOps") {
|
|
1957
|
+
if (e.view) {
|
|
1958
|
+
const s = e.view, i = 8, r = s.byteOffset + i, o = e.size - i;
|
|
1959
|
+
return new Uint8Array(s.buffer, r, o);
|
|
1960
|
+
}
|
|
1961
|
+
if (e.data instanceof Uint8Array)
|
|
1962
|
+
return new Uint8Array(e.data);
|
|
1963
|
+
if (e.raw instanceof Uint8Array)
|
|
1964
|
+
return new Uint8Array(e.raw.slice(8));
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
function Bt(t, e) {
|
|
1969
|
+
const n = Be(Ie(t), { readers: Rt });
|
|
1970
|
+
return (N(n, H("tfdt"))?.baseMediaDecodeTime ?? 0) * 1e6 / e;
|
|
1797
1971
|
}
|
|
1798
|
-
function
|
|
1799
|
-
const n =
|
|
1972
|
+
function Ct(t, e) {
|
|
1973
|
+
const n = Be(Ie(t), { readers: Rt }), i = N(n, H("tfdt"))?.baseMediaDecodeTime ?? 0, r = N(n, H("tfhd")), o = r?.defaultSampleDuration ?? 0, a = r?.defaultSampleSize ?? 0, c = r?.defaultSampleFlags ?? 0, u = N(n, H("trun"));
|
|
1800
1974
|
if (!u)
|
|
1801
1975
|
throw new Error("No trun box found in data segment");
|
|
1802
|
-
const l =
|
|
1976
|
+
const l = N(n, H("mdat"));
|
|
1803
1977
|
if (!l)
|
|
1804
1978
|
throw new Error("No mdat box found in data segment");
|
|
1805
1979
|
const d = l.data;
|
|
@@ -1807,28 +1981,28 @@ function Tt(t, e) {
|
|
|
1807
1981
|
throw new Error("No data in mdat box");
|
|
1808
1982
|
const f = [];
|
|
1809
1983
|
let g = 0, y = i;
|
|
1810
|
-
for (let
|
|
1811
|
-
const
|
|
1984
|
+
for (let v = 0; v < u.sampleCount; v++) {
|
|
1985
|
+
const A = u.samples[v] ?? {}, E = A.sampleSize ?? a, M = A.sampleDuration ?? o;
|
|
1812
1986
|
if (E <= 0)
|
|
1813
|
-
throw new Error(`Invalid sample size ${E} for sample ${
|
|
1814
|
-
if (
|
|
1815
|
-
throw new Error(`Invalid sample duration ${
|
|
1987
|
+
throw new Error(`Invalid sample size ${E} for sample ${v} in trun`);
|
|
1988
|
+
if (M <= 0)
|
|
1989
|
+
throw new Error(`Invalid sample duration ${M} for sample ${v} in trun`);
|
|
1816
1990
|
if (g + E > d.length)
|
|
1817
1991
|
throw new Error(
|
|
1818
|
-
`Sample ${
|
|
1992
|
+
`Sample ${v} would overflow mdat: offset=${g}, size=${E}, mdatLength=${d.length}`
|
|
1819
1993
|
);
|
|
1820
|
-
const
|
|
1994
|
+
const X = v === 0 && u.firstSampleFlags !== void 0 ? u.firstSampleFlags : A.sampleFlags ?? c, $ = A.sampleCompositionTimeOffset ?? 0, j = new Uint8Array(d.slice(g, g + E));
|
|
1821
1995
|
g += E;
|
|
1822
|
-
const
|
|
1996
|
+
const Z = y + $, V = Math.round(Z * 1e6 / e), z = X === 0 || (X & 65536) === 0;
|
|
1823
1997
|
f.push({
|
|
1824
|
-
data:
|
|
1825
|
-
timestamp:
|
|
1826
|
-
keyframe:
|
|
1827
|
-
}), y +=
|
|
1998
|
+
data: j,
|
|
1999
|
+
timestamp: V,
|
|
2000
|
+
keyframe: z
|
|
2001
|
+
}), y += M;
|
|
1828
2002
|
}
|
|
1829
2003
|
return f;
|
|
1830
2004
|
}
|
|
1831
|
-
function
|
|
2005
|
+
function F(t) {
|
|
1832
2006
|
if (t = t.startsWith("0x") ? t.slice(2) : t, t.length % 2)
|
|
1833
2007
|
throw new Error("invalid hex string length");
|
|
1834
2008
|
const e = t.match(/.{2}/g);
|
|
@@ -1836,53 +2010,53 @@ function O(t) {
|
|
|
1836
2010
|
throw new Error("invalid hex string format");
|
|
1837
2011
|
return new Uint8Array(e.map((n) => parseInt(n, 16)));
|
|
1838
2012
|
}
|
|
1839
|
-
const
|
|
2013
|
+
const ye = [65536, 0, 0, 0, 65536, 0, 0, 0, 1073741824], ai = {
|
|
1840
2014
|
// Init segment boxes
|
|
1841
|
-
ftyp:
|
|
1842
|
-
mvhd:
|
|
1843
|
-
tkhd:
|
|
1844
|
-
mdhd:
|
|
1845
|
-
hdlr:
|
|
1846
|
-
vmhd:
|
|
1847
|
-
smhd:
|
|
1848
|
-
"url ":
|
|
1849
|
-
dref:
|
|
1850
|
-
stsd:
|
|
1851
|
-
stts:
|
|
1852
|
-
trex:
|
|
2015
|
+
ftyp: js,
|
|
2016
|
+
mvhd: Hs,
|
|
2017
|
+
tkhd: Qs,
|
|
2018
|
+
mdhd: Ws,
|
|
2019
|
+
hdlr: Zs,
|
|
2020
|
+
vmhd: si,
|
|
2021
|
+
smhd: Gs,
|
|
2022
|
+
"url ": ni,
|
|
2023
|
+
dref: $s,
|
|
2024
|
+
stsd: Xs,
|
|
2025
|
+
stts: Ys,
|
|
2026
|
+
trex: ei,
|
|
1853
2027
|
// Data segment boxes
|
|
1854
|
-
mfhd:
|
|
1855
|
-
tfhd:
|
|
1856
|
-
tfdt:
|
|
1857
|
-
trun:
|
|
1858
|
-
mdat:
|
|
2028
|
+
mfhd: qs,
|
|
2029
|
+
tfhd: Js,
|
|
2030
|
+
tfdt: Ks,
|
|
2031
|
+
trun: ti,
|
|
2032
|
+
mdat: Vs
|
|
1859
2033
|
// For boxes without library writers, we create them manually as Uint8Arrays
|
|
1860
2034
|
};
|
|
1861
|
-
function
|
|
1862
|
-
return
|
|
2035
|
+
function le(t) {
|
|
2036
|
+
return Us(t, { writers: ai });
|
|
1863
2037
|
}
|
|
1864
|
-
function
|
|
2038
|
+
function Oe(t, e, n, s) {
|
|
1865
2039
|
const i = 12 + s.length, r = new Uint8Array(i), o = new DataView(r.buffer);
|
|
1866
2040
|
return o.setUint32(0, i, !1), r[4] = t.charCodeAt(0), r[5] = t.charCodeAt(1), r[6] = t.charCodeAt(2), r[7] = t.charCodeAt(3), o.setUint32(8, e << 24 | n, !1), r.set(s, 12), r;
|
|
1867
2041
|
}
|
|
1868
|
-
function
|
|
2042
|
+
function It() {
|
|
1869
2043
|
const t = new Uint8Array(4);
|
|
1870
|
-
return
|
|
2044
|
+
return Oe("stsc", 0, 0, t);
|
|
1871
2045
|
}
|
|
1872
|
-
function
|
|
2046
|
+
function Ot() {
|
|
1873
2047
|
const t = new Uint8Array(8);
|
|
1874
|
-
return
|
|
2048
|
+
return Oe("stsz", 0, 0, t);
|
|
1875
2049
|
}
|
|
1876
|
-
function
|
|
2050
|
+
function Dt() {
|
|
1877
2051
|
const t = new Uint8Array(4);
|
|
1878
|
-
return
|
|
2052
|
+
return Oe("stco", 0, 0, t);
|
|
1879
2053
|
}
|
|
1880
|
-
function
|
|
2054
|
+
function ci(t, e, n) {
|
|
1881
2055
|
const s = 8 + n.length, r = 8 + (78 + s), o = new Uint8Array(r), a = new DataView(o.buffer);
|
|
1882
2056
|
let c = 0;
|
|
1883
2057
|
return a.setUint32(c, r, !1), c += 4, o[c++] = 97, o[c++] = 118, o[c++] = 99, o[c++] = 49, c += 6, a.setUint16(c, 1, !1), c += 2, a.setUint16(c, 0, !1), c += 2, a.setUint16(c, 0, !1), c += 2, c += 12, a.setUint16(c, t, !1), c += 2, a.setUint16(c, e, !1), c += 2, a.setUint32(c, 4718592, !1), c += 4, a.setUint32(c, 4718592, !1), c += 4, a.setUint32(c, 0, !1), c += 4, a.setUint16(c, 1, !1), c += 2, c += 32, a.setUint16(c, 24, !1), c += 2, a.setUint16(c, 65535, !1), c += 2, a.setUint32(c, s, !1), c += 4, o[c++] = 97, o[c++] = 118, o[c++] = 99, o[c++] = 67, o.set(n, c), o;
|
|
1884
2058
|
}
|
|
1885
|
-
function
|
|
2059
|
+
function Qe(t) {
|
|
1886
2060
|
const { codedWidth: e, codedHeight: n, description: s, container: i } = t;
|
|
1887
2061
|
if (!e || !n || !s)
|
|
1888
2062
|
throw new Error("Missing required fields to create video init segment");
|
|
@@ -1906,7 +2080,7 @@ function qe(t) {
|
|
|
1906
2080
|
// 1.0 in 8.8 fixed point
|
|
1907
2081
|
reserved1: 0,
|
|
1908
2082
|
reserved2: [0, 0],
|
|
1909
|
-
matrix:
|
|
2083
|
+
matrix: ye,
|
|
1910
2084
|
preDefined: [0, 0, 0, 0, 0, 0],
|
|
1911
2085
|
nextTrackId: o + 1
|
|
1912
2086
|
}, u = {
|
|
@@ -1925,7 +2099,7 @@ function qe(t) {
|
|
|
1925
2099
|
volume: 0,
|
|
1926
2100
|
// Video tracks have 0 volume
|
|
1927
2101
|
reserved3: 0,
|
|
1928
|
-
matrix:
|
|
2102
|
+
matrix: ye,
|
|
1929
2103
|
width: e * 65536,
|
|
1930
2104
|
// 16.16 fixed point (avoid << which produces signed int)
|
|
1931
2105
|
height: n * 65536
|
|
@@ -1954,7 +2128,7 @@ function qe(t) {
|
|
|
1954
2128
|
// Required to be 1
|
|
1955
2129
|
graphicsmode: 0,
|
|
1956
2130
|
opcolor: [0, 0, 0]
|
|
1957
|
-
},
|
|
2131
|
+
}, v = {
|
|
1958
2132
|
type: "dinf",
|
|
1959
2133
|
boxes: [{
|
|
1960
2134
|
type: "dref",
|
|
@@ -1975,14 +2149,14 @@ function qe(t) {
|
|
|
1975
2149
|
flags: 0,
|
|
1976
2150
|
entryCount: 1,
|
|
1977
2151
|
// biome-ignore lint/suspicious/noExplicitAny: Raw avc1 box since library doesn't handle avcC children
|
|
1978
|
-
entries: [
|
|
1979
|
-
},
|
|
2152
|
+
entries: [ci(e, n, F(s))]
|
|
2153
|
+
}, M = {
|
|
1980
2154
|
type: "stts",
|
|
1981
2155
|
version: 0,
|
|
1982
2156
|
flags: 0,
|
|
1983
2157
|
entryCount: 0,
|
|
1984
2158
|
entries: []
|
|
1985
|
-
},
|
|
2159
|
+
}, X = It(), $ = Ot(), j = Dt(), Se = le([a, {
|
|
1986
2160
|
type: "moov",
|
|
1987
2161
|
boxes: [c, {
|
|
1988
2162
|
type: "trak",
|
|
@@ -1990,10 +2164,10 @@ function qe(t) {
|
|
|
1990
2164
|
type: "mdia",
|
|
1991
2165
|
boxes: [l, d, {
|
|
1992
2166
|
type: "minf",
|
|
1993
|
-
boxes: [f,
|
|
2167
|
+
boxes: [f, v, {
|
|
1994
2168
|
type: "stbl",
|
|
1995
2169
|
// biome-ignore lint/suspicious/noExplicitAny: Raw boxes for types without library writers
|
|
1996
|
-
boxes: [E,
|
|
2170
|
+
boxes: [E, M, X, $, j]
|
|
1997
2171
|
}]
|
|
1998
2172
|
}]
|
|
1999
2173
|
}]
|
|
@@ -2010,13 +2184,13 @@ function qe(t) {
|
|
|
2010
2184
|
defaultSampleFlags: 0
|
|
2011
2185
|
}]
|
|
2012
2186
|
}]
|
|
2013
|
-
}]),
|
|
2014
|
-
let
|
|
2015
|
-
for (const
|
|
2016
|
-
|
|
2017
|
-
return
|
|
2187
|
+
}]), he = Se.reduce((P, W) => P + W.byteLength, 0), fe = new Uint8Array(he);
|
|
2188
|
+
let re = 0;
|
|
2189
|
+
for (const P of Se)
|
|
2190
|
+
fe.set(new Uint8Array(P.buffer, P.byteOffset, P.byteLength), re), re += P.byteLength;
|
|
2191
|
+
return fe;
|
|
2018
2192
|
}
|
|
2019
|
-
function
|
|
2193
|
+
function et(t) {
|
|
2020
2194
|
const { sampleRate: e, numberOfChannels: n, description: s, codec: i, container: r } = t, o = r.kind === "cmaf" ? r.timescale : 1e6, a = r.kind === "cmaf" ? r.trackId : 1, c = {
|
|
2021
2195
|
type: "ftyp",
|
|
2022
2196
|
majorBrand: "isom",
|
|
@@ -2034,7 +2208,7 @@ function He(t) {
|
|
|
2034
2208
|
volume: 256,
|
|
2035
2209
|
reserved1: 0,
|
|
2036
2210
|
reserved2: [0, 0],
|
|
2037
|
-
matrix:
|
|
2211
|
+
matrix: ye,
|
|
2038
2212
|
preDefined: [0, 0, 0, 0, 0, 0],
|
|
2039
2213
|
nextTrackId: a + 1
|
|
2040
2214
|
}, l = {
|
|
@@ -2052,7 +2226,7 @@ function He(t) {
|
|
|
2052
2226
|
volume: 256,
|
|
2053
2227
|
// Audio tracks have volume (1.0 in 8.8 fixed point)
|
|
2054
2228
|
reserved3: 0,
|
|
2055
|
-
matrix:
|
|
2229
|
+
matrix: ye,
|
|
2056
2230
|
width: 0,
|
|
2057
2231
|
height: 0
|
|
2058
2232
|
}, d = {
|
|
@@ -2079,7 +2253,7 @@ function He(t) {
|
|
|
2079
2253
|
flags: 0,
|
|
2080
2254
|
balance: 0,
|
|
2081
2255
|
reserved: 0
|
|
2082
|
-
},
|
|
2256
|
+
}, A = {
|
|
2083
2257
|
type: "dinf",
|
|
2084
2258
|
boxes: [{
|
|
2085
2259
|
type: "dref",
|
|
@@ -2093,20 +2267,20 @@ function He(t) {
|
|
|
2093
2267
|
location: ""
|
|
2094
2268
|
}]
|
|
2095
2269
|
}]
|
|
2096
|
-
},
|
|
2270
|
+
}, M = {
|
|
2097
2271
|
type: "stsd",
|
|
2098
2272
|
version: 0,
|
|
2099
2273
|
flags: 0,
|
|
2100
2274
|
entryCount: 1,
|
|
2101
2275
|
// biome-ignore lint/suspicious/noExplicitAny: Raw sample entry box
|
|
2102
|
-
entries: [
|
|
2103
|
-
},
|
|
2276
|
+
entries: [ui(i, e, n, s)]
|
|
2277
|
+
}, X = {
|
|
2104
2278
|
type: "stts",
|
|
2105
2279
|
version: 0,
|
|
2106
2280
|
flags: 0,
|
|
2107
2281
|
entryCount: 0,
|
|
2108
2282
|
entries: []
|
|
2109
|
-
},
|
|
2283
|
+
}, $ = It(), j = Ot(), Z = Dt(), he = le([c, {
|
|
2110
2284
|
type: "moov",
|
|
2111
2285
|
boxes: [u, {
|
|
2112
2286
|
type: "trak",
|
|
@@ -2114,10 +2288,10 @@ function He(t) {
|
|
|
2114
2288
|
type: "mdia",
|
|
2115
2289
|
boxes: [d, f, {
|
|
2116
2290
|
type: "minf",
|
|
2117
|
-
boxes: [g,
|
|
2291
|
+
boxes: [g, A, {
|
|
2118
2292
|
type: "stbl",
|
|
2119
2293
|
// biome-ignore lint/suspicious/noExplicitAny: Raw boxes for types without library writers
|
|
2120
|
-
boxes: [
|
|
2294
|
+
boxes: [M, X, $, j, Z]
|
|
2121
2295
|
}]
|
|
2122
2296
|
}]
|
|
2123
2297
|
}]
|
|
@@ -2134,30 +2308,30 @@ function He(t) {
|
|
|
2134
2308
|
defaultSampleFlags: 0
|
|
2135
2309
|
}]
|
|
2136
2310
|
}]
|
|
2137
|
-
}]),
|
|
2138
|
-
let
|
|
2139
|
-
for (const
|
|
2140
|
-
|
|
2141
|
-
return
|
|
2311
|
+
}]), fe = he.reduce((W, qt) => W + qt.byteLength, 0), re = new Uint8Array(fe);
|
|
2312
|
+
let P = 0;
|
|
2313
|
+
for (const W of he)
|
|
2314
|
+
re.set(new Uint8Array(W.buffer, W.byteOffset, W.byteLength), P), P += W.byteLength;
|
|
2315
|
+
return re;
|
|
2142
2316
|
}
|
|
2143
|
-
function
|
|
2317
|
+
function ui(t, e, n, s) {
|
|
2144
2318
|
if (t.startsWith("mp4a"))
|
|
2145
|
-
return
|
|
2319
|
+
return li(e, n, s);
|
|
2146
2320
|
if (t === "opus")
|
|
2147
|
-
return
|
|
2321
|
+
return di(e, n, s);
|
|
2148
2322
|
throw new Error(`Unsupported audio codec: ${t}`);
|
|
2149
2323
|
}
|
|
2150
|
-
function
|
|
2151
|
-
const s =
|
|
2324
|
+
function li(t, e, n) {
|
|
2325
|
+
const s = fi(t, e, n), r = 8 + (28 + s.length), o = new Uint8Array(r), a = new DataView(o.buffer);
|
|
2152
2326
|
let c = 0;
|
|
2153
2327
|
return a.setUint32(c, r, !1), c += 4, o[c++] = 109, o[c++] = 112, o[c++] = 52, o[c++] = 97, c += 6, a.setUint16(c, 1, !1), c += 2, c += 8, a.setUint16(c, e, !1), c += 2, a.setUint16(c, 16, !1), c += 2, a.setUint16(c, 0, !1), c += 2, a.setUint16(c, 0, !1), c += 2, a.setUint32(c, t * 65536, !1), c += 4, o.set(s, c), o;
|
|
2154
2328
|
}
|
|
2155
|
-
function
|
|
2156
|
-
const s =
|
|
2329
|
+
function di(t, e, n) {
|
|
2330
|
+
const s = mi(e, t, n), r = 8 + (28 + s.length), o = new Uint8Array(r), a = new DataView(o.buffer);
|
|
2157
2331
|
let c = 0;
|
|
2158
2332
|
return a.setUint32(c, r, !1), c += 4, o[c++] = 79, o[c++] = 112, o[c++] = 117, o[c++] = 115, c += 6, a.setUint16(c, 1, !1), c += 2, c += 8, a.setUint16(c, e, !1), c += 2, a.setUint16(c, 16, !1), c += 2, a.setUint16(c, 0, !1), c += 2, a.setUint16(c, 0, !1), c += 2, a.setUint32(c, t * 65536, !1), c += 4, o.set(s, c), o;
|
|
2159
2333
|
}
|
|
2160
|
-
function
|
|
2334
|
+
function hi(t, e) {
|
|
2161
2335
|
const s = {
|
|
2162
2336
|
96e3: 0,
|
|
2163
2337
|
88200: 1,
|
|
@@ -2175,21 +2349,21 @@ function Ws(t, e) {
|
|
|
2175
2349
|
}[t] ?? 4, r = 2 << 3 | s >> 1, o = (s & 1) << 7 | e << 3;
|
|
2176
2350
|
return new Uint8Array([r, o]);
|
|
2177
2351
|
}
|
|
2178
|
-
function
|
|
2179
|
-
const s = n ?
|
|
2352
|
+
function fi(t, e, n) {
|
|
2353
|
+
const s = n ? F(n) : hi(t, e), i = s.length, r = 15 + i, o = 5 + r + 3, a = 14 + o, c = new Uint8Array(a), u = new DataView(c.buffer);
|
|
2180
2354
|
let l = 0;
|
|
2181
2355
|
return u.setUint32(l, a, !1), l += 4, c[l++] = 101, c[l++] = 115, c[l++] = 100, c[l++] = 115, u.setUint32(l, 0, !1), l += 4, c[l++] = 3, c[l++] = o, u.setUint16(l, 0, !1), l += 2, c[l++] = 0, c[l++] = 4, c[l++] = r, c[l++] = 64, c[l++] = 21, c[l++] = 0, c[l++] = 0, c[l++] = 0, u.setUint32(l, 0, !1), l += 4, u.setUint32(l, 0, !1), l += 4, c[l++] = 5, c[l++] = i, c.set(s, l), l += i, c[l++] = 6, c[l++] = 1, c[l++] = 2, c;
|
|
2182
2356
|
}
|
|
2183
|
-
function
|
|
2357
|
+
function mi(t, e, n) {
|
|
2184
2358
|
if (n) {
|
|
2185
|
-
const a =
|
|
2359
|
+
const a = F(n), c = 8 + a.length, u = new Uint8Array(c);
|
|
2186
2360
|
return new DataView(u.buffer).setUint32(0, c, !1), u[4] = 100, u[5] = 79, u[6] = 112, u[7] = 115, u.set(a, 8), u;
|
|
2187
2361
|
}
|
|
2188
2362
|
const s = 19, i = new Uint8Array(s), r = new DataView(i.buffer);
|
|
2189
2363
|
let o = 0;
|
|
2190
2364
|
return r.setUint32(o, s, !1), o += 4, i[o++] = 100, i[o++] = 79, i[o++] = 112, i[o++] = 115, i[o++] = 0, i[o++] = t, r.setUint16(o, 312, !1), o += 2, r.setUint32(o, e, !1), o += 4, r.setInt16(o, 0, !1), o += 2, i[o++] = 0, i;
|
|
2191
2365
|
}
|
|
2192
|
-
function
|
|
2366
|
+
function Lt(t) {
|
|
2193
2367
|
const { data: e, timestamp: n, duration: s, keyframe: i, sequence: r, trackId: o = 1 } = t, a = i ? 33554432 : 16842752, c = {
|
|
2194
2368
|
type: "mfhd",
|
|
2195
2369
|
version: 0,
|
|
@@ -2226,33 +2400,33 @@ function Bt(t) {
|
|
|
2226
2400
|
type: "traf",
|
|
2227
2401
|
boxes: [u, l, d]
|
|
2228
2402
|
}]
|
|
2229
|
-
}, y =
|
|
2230
|
-
let
|
|
2231
|
-
for (const
|
|
2232
|
-
|
|
2233
|
-
d.dataOffset =
|
|
2234
|
-
const
|
|
2235
|
-
|
|
2236
|
-
for (const
|
|
2237
|
-
|
|
2238
|
-
const E = new ArrayBuffer(e.byteLength),
|
|
2239
|
-
|
|
2240
|
-
const
|
|
2403
|
+
}, y = le([g]);
|
|
2404
|
+
let v = 0;
|
|
2405
|
+
for (const z of y)
|
|
2406
|
+
v += z.byteLength;
|
|
2407
|
+
d.dataOffset = v + 8;
|
|
2408
|
+
const A = le([g]);
|
|
2409
|
+
v = 0;
|
|
2410
|
+
for (const z of A)
|
|
2411
|
+
v += z.byteLength;
|
|
2412
|
+
const E = new ArrayBuffer(e.byteLength), M = new Uint8Array(E);
|
|
2413
|
+
M.set(e);
|
|
2414
|
+
const $ = le([{
|
|
2241
2415
|
type: "mdat",
|
|
2242
|
-
data:
|
|
2416
|
+
data: M
|
|
2243
2417
|
}]);
|
|
2244
|
-
let
|
|
2245
|
-
for (const
|
|
2246
|
-
|
|
2247
|
-
const
|
|
2248
|
-
let
|
|
2249
|
-
for (const
|
|
2250
|
-
|
|
2251
|
-
for (const
|
|
2252
|
-
|
|
2253
|
-
return
|
|
2254
|
-
}
|
|
2255
|
-
class
|
|
2418
|
+
let j = 0;
|
|
2419
|
+
for (const z of $)
|
|
2420
|
+
j += z.byteLength;
|
|
2421
|
+
const Z = new Uint8Array(v + j);
|
|
2422
|
+
let V = 0;
|
|
2423
|
+
for (const z of A)
|
|
2424
|
+
Z.set(new Uint8Array(z.buffer, z.byteOffset, z.byteLength), V), V += z.byteLength;
|
|
2425
|
+
for (const z of $)
|
|
2426
|
+
Z.set(new Uint8Array(z.buffer, z.byteOffset, z.byteLength), V), V += z.byteLength;
|
|
2427
|
+
return Z;
|
|
2428
|
+
}
|
|
2429
|
+
class ie {
|
|
2256
2430
|
#e;
|
|
2257
2431
|
#t;
|
|
2258
2432
|
#n = [];
|
|
@@ -2262,9 +2436,9 @@ class te {
|
|
|
2262
2436
|
#i;
|
|
2263
2437
|
#r = new h([]);
|
|
2264
2438
|
buffered = this.#r;
|
|
2265
|
-
#o = new
|
|
2439
|
+
#o = new U();
|
|
2266
2440
|
constructor(e, n) {
|
|
2267
|
-
this.#e = e, this.#t = h.from(n?.latency ??
|
|
2441
|
+
this.#e = e, this.#t = h.from(n?.latency ?? _.Time.Milli.zero), this.#o.spawn(this.#a.bind(this)), this.#o.cleanup(() => {
|
|
2268
2442
|
this.#e.close();
|
|
2269
2443
|
for (const s of this.#n)
|
|
2270
2444
|
s.consumer.close();
|
|
@@ -2273,7 +2447,7 @@ class te {
|
|
|
2273
2447
|
}
|
|
2274
2448
|
async #a() {
|
|
2275
2449
|
for (; ; ) {
|
|
2276
|
-
const e = await this.#e.
|
|
2450
|
+
const e = await this.#e.recvGroup();
|
|
2277
2451
|
if (!e) break;
|
|
2278
2452
|
if (this.#s === void 0 && (this.#s = e.sequence), e.sequence < this.#s) {
|
|
2279
2453
|
console.warn(`skipping old group: ${e.sequence} < ${this.#s}`), e.close();
|
|
@@ -2292,7 +2466,7 @@ class te {
|
|
|
2292
2466
|
for (; ; ) {
|
|
2293
2467
|
const s = await e.consumer.readFrame();
|
|
2294
2468
|
if (!s) break;
|
|
2295
|
-
const { data: i, timestamp: r } =
|
|
2469
|
+
const { data: i, timestamp: r } = ie.#d(s), o = {
|
|
2296
2470
|
data: i,
|
|
2297
2471
|
timestamp: r,
|
|
2298
2472
|
keyframe: n
|
|
@@ -2308,7 +2482,7 @@ class te {
|
|
|
2308
2482
|
if (this.#s === void 0) return;
|
|
2309
2483
|
let e = !1;
|
|
2310
2484
|
for (; this.#n.length >= 2; ) {
|
|
2311
|
-
const n =
|
|
2485
|
+
const n = _.Time.Micro.fromMilli(this.#t.peek());
|
|
2312
2486
|
let s, i;
|
|
2313
2487
|
for (const a of this.#n) {
|
|
2314
2488
|
if (a.latest === void 0) continue;
|
|
@@ -2350,7 +2524,7 @@ class te {
|
|
|
2350
2524
|
}
|
|
2351
2525
|
// NOTE: A keyframe is always the first frame in a group, so it's not encoded on the wire.
|
|
2352
2526
|
static #d(e) {
|
|
2353
|
-
const [n, s] =
|
|
2527
|
+
const [n, s] = _.Varint.decode(e);
|
|
2354
2528
|
return { timestamp: n, data: s };
|
|
2355
2529
|
}
|
|
2356
2530
|
#l() {
|
|
@@ -2359,8 +2533,8 @@ class te {
|
|
|
2359
2533
|
for (const s of this.#n) {
|
|
2360
2534
|
const i = s.frames.at(0);
|
|
2361
2535
|
if (!i || s.latest === void 0) continue;
|
|
2362
|
-
const r =
|
|
2363
|
-
a && (a.end >= r || c) ? a.end =
|
|
2536
|
+
const r = _.Time.Milli.fromMicro(i.timestamp), o = _.Time.Milli.fromMicro(s.latest), a = e.at(-1), c = n?.done && n.consumer.sequence + 1 === s.consumer.sequence;
|
|
2537
|
+
a && (a.end >= r || c) ? a.end = _.Time.Milli.max(a.end, o) : e.push({ start: r, end: o }), n = s;
|
|
2364
2538
|
}
|
|
2365
2539
|
this.#r.set(e);
|
|
2366
2540
|
}
|
|
@@ -2371,28 +2545,28 @@ class te {
|
|
|
2371
2545
|
this.#n.length = 0;
|
|
2372
2546
|
}
|
|
2373
2547
|
}
|
|
2374
|
-
let
|
|
2375
|
-
async function
|
|
2376
|
-
return globalThis.AudioEncoder && globalThis.AudioDecoder ? !0 : (
|
|
2548
|
+
let _e;
|
|
2549
|
+
async function tt() {
|
|
2550
|
+
return globalThis.AudioEncoder && globalThis.AudioDecoder ? !0 : (_e || (console.warn("using Opus polyfill; performance may be degraded"), _e = Promise.all([
|
|
2377
2551
|
import("./libav-opus-af-BlMWboA7.js"),
|
|
2378
2552
|
import("./main-DGBFe0O7.js")
|
|
2379
2553
|
]).then(async ([t, e]) => (await e.load({
|
|
2380
2554
|
LibAV: t,
|
|
2381
2555
|
polyfill: !0
|
|
2382
|
-
}), !0))), await
|
|
2556
|
+
}), !0))), await _e);
|
|
2383
2557
|
}
|
|
2384
|
-
const
|
|
2385
|
-
function
|
|
2558
|
+
const q = 0, D = 1, oe = 2, K = 3, pi = 4;
|
|
2559
|
+
function Pt(t, e, n) {
|
|
2386
2560
|
if (t <= 0) throw new Error("invalid channels");
|
|
2387
2561
|
if (e <= 0) throw new Error("invalid capacity");
|
|
2388
2562
|
if (n <= 0) throw new Error("invalid sample rate");
|
|
2389
|
-
const s = new SharedArrayBuffer(t * e * Float32Array.BYTES_PER_ELEMENT), i = new SharedArrayBuffer(
|
|
2390
|
-
return Atomics.store(r,
|
|
2563
|
+
const s = new SharedArrayBuffer(t * e * Float32Array.BYTES_PER_ELEMENT), i = new SharedArrayBuffer(pi * Int32Array.BYTES_PER_ELEMENT), r = new Int32Array(i);
|
|
2564
|
+
return Atomics.store(r, K, 1), { channels: t, capacity: e, rate: n, samples: s, control: i };
|
|
2391
2565
|
}
|
|
2392
|
-
function
|
|
2566
|
+
function gi(t, e) {
|
|
2393
2567
|
return (t - e | 0) > 0 ? t : e;
|
|
2394
2568
|
}
|
|
2395
|
-
function
|
|
2569
|
+
function ae(t, e) {
|
|
2396
2570
|
return (t % e + e) % e;
|
|
2397
2571
|
}
|
|
2398
2572
|
function Me(t, e, n) {
|
|
@@ -2402,7 +2576,7 @@ function Me(t, e, n) {
|
|
|
2402
2576
|
if (Atomics.compareExchange(t, e, s, n) === s) return n;
|
|
2403
2577
|
}
|
|
2404
2578
|
}
|
|
2405
|
-
class
|
|
2579
|
+
class De {
|
|
2406
2580
|
channels;
|
|
2407
2581
|
capacity;
|
|
2408
2582
|
rate;
|
|
@@ -2422,59 +2596,59 @@ class Ee {
|
|
|
2422
2596
|
*/
|
|
2423
2597
|
insert(e, n) {
|
|
2424
2598
|
if (n.length !== this.channels) throw new Error("wrong number of channels");
|
|
2425
|
-
let s = Math.round(
|
|
2599
|
+
let s = Math.round(p.Second.fromMicro(e) * this.rate);
|
|
2426
2600
|
const i = n[0].length;
|
|
2427
2601
|
let r = 0;
|
|
2428
|
-
const o = s + i | 0, a = Atomics.load(this.#e,
|
|
2602
|
+
const o = s + i | 0, a = Atomics.load(this.#e, D), c = a - s | 0;
|
|
2429
2603
|
if (c > 0) {
|
|
2430
2604
|
if (c >= i)
|
|
2431
2605
|
return;
|
|
2432
2606
|
r = c, s = s + c | 0;
|
|
2433
2607
|
}
|
|
2434
2608
|
const u = i - r;
|
|
2435
|
-
(o - a | 0) > this.capacity && Me(this.#e,
|
|
2436
|
-
const l = Atomics.load(this.#e,
|
|
2609
|
+
(o - a | 0) > this.capacity && Me(this.#e, D, o - this.capacity | 0);
|
|
2610
|
+
const l = Atomics.load(this.#e, q), d = s - l | 0;
|
|
2437
2611
|
if (d > 0) {
|
|
2438
|
-
const
|
|
2439
|
-
for (let
|
|
2440
|
-
const E = this.#t[
|
|
2441
|
-
for (let
|
|
2442
|
-
E[
|
|
2612
|
+
const v = Math.min(d, this.capacity);
|
|
2613
|
+
for (let A = 0; A < this.channels; A++) {
|
|
2614
|
+
const E = this.#t[A];
|
|
2615
|
+
for (let M = 0; M < v; M++)
|
|
2616
|
+
E[ae(l + M | 0, this.capacity)] = 0;
|
|
2443
2617
|
}
|
|
2444
2618
|
}
|
|
2445
|
-
for (let
|
|
2446
|
-
const
|
|
2447
|
-
for (let
|
|
2448
|
-
E[
|
|
2619
|
+
for (let v = 0; v < this.channels; v++) {
|
|
2620
|
+
const A = n[v], E = this.#t[v];
|
|
2621
|
+
for (let M = 0; M < u; M++)
|
|
2622
|
+
E[ae(s + M | 0, this.capacity)] = A[r + M];
|
|
2449
2623
|
}
|
|
2450
|
-
Atomics.store(this.#e,
|
|
2451
|
-
const f = Atomics.load(this.#e,
|
|
2452
|
-
(g - f | 0) >= y && y > 0 && Atomics.store(this.#e,
|
|
2624
|
+
Atomics.store(this.#e, q, gi(Atomics.load(this.#e, q), o));
|
|
2625
|
+
const f = Atomics.load(this.#e, D), g = Atomics.load(this.#e, q), y = Atomics.load(this.#e, oe);
|
|
2626
|
+
(g - f | 0) >= y && y > 0 && Atomics.store(this.#e, K, 0);
|
|
2453
2627
|
}
|
|
2454
2628
|
/**
|
|
2455
2629
|
* Read audio samples into the output buffers.
|
|
2456
2630
|
* AudioWorklet only. Returns the number of samples read.
|
|
2457
2631
|
*/
|
|
2458
2632
|
read(e) {
|
|
2459
|
-
if (Atomics.load(this.#e,
|
|
2460
|
-
let n = Atomics.load(this.#e,
|
|
2461
|
-
const s = Atomics.load(this.#e,
|
|
2633
|
+
if (Atomics.load(this.#e, K) === 1) return 0;
|
|
2634
|
+
let n = Atomics.load(this.#e, D);
|
|
2635
|
+
const s = Atomics.load(this.#e, q), i = Atomics.load(this.#e, oe), r = s - n | 0;
|
|
2462
2636
|
if (i > 0 && r > i) {
|
|
2463
2637
|
const c = s - i | 0;
|
|
2464
|
-
n = Me(this.#e,
|
|
2638
|
+
n = Me(this.#e, D, c);
|
|
2465
2639
|
}
|
|
2466
2640
|
const o = s - n | 0, a = Math.min(o, e[0].length);
|
|
2467
2641
|
if (a <= 0) return 0;
|
|
2468
2642
|
for (let c = 0; c < this.channels; c++) {
|
|
2469
2643
|
const u = this.#t[c], l = e[c];
|
|
2470
2644
|
for (let d = 0; d < a; d++)
|
|
2471
|
-
l[d] = u[
|
|
2645
|
+
l[d] = u[ae(n + d | 0, this.capacity)];
|
|
2472
2646
|
}
|
|
2473
|
-
return Me(this.#e,
|
|
2647
|
+
return Me(this.#e, D, n + a | 0), a;
|
|
2474
2648
|
}
|
|
2475
2649
|
/** Update the target latency in samples. */
|
|
2476
2650
|
setLatency(e) {
|
|
2477
|
-
Atomics.store(this.#e,
|
|
2651
|
+
Atomics.store(this.#e, oe, e);
|
|
2478
2652
|
}
|
|
2479
2653
|
/**
|
|
2480
2654
|
* Allocate a new ring with `newCapacity` samples and copy the unread window
|
|
@@ -2489,24 +2663,24 @@ class Ee {
|
|
|
2489
2663
|
* by READ/WRITE elsewhere.
|
|
2490
2664
|
*/
|
|
2491
2665
|
resize(e) {
|
|
2492
|
-
const n =
|
|
2666
|
+
const n = Pt(this.channels, e, this.rate), s = new De(n), i = Atomics.load(this.#e, D), r = Atomics.load(this.#e, q), o = Atomics.load(this.#e, oe), a = Atomics.load(this.#e, K), c = r - i | 0, u = Math.max(0, Math.min(c, s.capacity)), l = r - u | 0;
|
|
2493
2667
|
for (let d = 0; d < this.channels; d++) {
|
|
2494
2668
|
const f = this.#t[d], g = s.#t[d];
|
|
2495
2669
|
for (let y = 0; y < u; y++) {
|
|
2496
|
-
const
|
|
2497
|
-
g[
|
|
2670
|
+
const v = l + y | 0;
|
|
2671
|
+
g[ae(v, s.capacity)] = f[ae(v, this.capacity)];
|
|
2498
2672
|
}
|
|
2499
2673
|
}
|
|
2500
|
-
return Atomics.store(s.#e,
|
|
2674
|
+
return Atomics.store(s.#e, D, l), Atomics.store(s.#e, q, r), Atomics.store(s.#e, oe, o), Atomics.store(s.#e, K, a), s;
|
|
2501
2675
|
}
|
|
2502
2676
|
/** Current playback timestamp derived from READ position. */
|
|
2503
2677
|
get timestamp() {
|
|
2504
|
-
const e = Atomics.load(this.#e,
|
|
2505
|
-
return
|
|
2678
|
+
const e = Atomics.load(this.#e, D);
|
|
2679
|
+
return p.Micro.fromSecond(e / this.rate);
|
|
2506
2680
|
}
|
|
2507
2681
|
/** Whether the buffer is stalled (waiting to fill). */
|
|
2508
2682
|
get stalled() {
|
|
2509
|
-
return Atomics.load(this.#e,
|
|
2683
|
+
return Atomics.load(this.#e, K) === 1;
|
|
2510
2684
|
}
|
|
2511
2685
|
/**
|
|
2512
2686
|
* Number of buffered samples (WRITE - READ).
|
|
@@ -2516,16 +2690,16 @@ class Ee {
|
|
|
2516
2690
|
* tests and diagnostics, not control-flow decisions.
|
|
2517
2691
|
*/
|
|
2518
2692
|
get length() {
|
|
2519
|
-
return Atomics.load(this.#e,
|
|
2693
|
+
return Atomics.load(this.#e, q) - Atomics.load(this.#e, D) | 0;
|
|
2520
2694
|
}
|
|
2521
2695
|
}
|
|
2522
|
-
function
|
|
2696
|
+
function wi() {
|
|
2523
2697
|
return !(typeof SharedArrayBuffer > "u" || typeof crossOriginIsolated < "u" && !crossOriginIsolated);
|
|
2524
2698
|
}
|
|
2525
|
-
function
|
|
2526
|
-
return
|
|
2699
|
+
function yi(t, e, n, s) {
|
|
2700
|
+
return wi() ? (console.log("[audio] using SharedArrayBuffer audio buffer"), new vi(t, e, n, s)) : (console.log("[audio] using postMessage audio buffer (SharedArrayBuffer unavailable)"), new bi(t, e, n, s));
|
|
2527
2701
|
}
|
|
2528
|
-
class
|
|
2702
|
+
class vi {
|
|
2529
2703
|
rate;
|
|
2530
2704
|
channels;
|
|
2531
2705
|
#e;
|
|
@@ -2534,11 +2708,11 @@ class Js {
|
|
|
2534
2708
|
timestamp = this.#n;
|
|
2535
2709
|
#s = new h(!0);
|
|
2536
2710
|
stalled = this.#s;
|
|
2537
|
-
#i = new
|
|
2711
|
+
#i = new U();
|
|
2538
2712
|
constructor(e, n, s, i) {
|
|
2539
2713
|
this.#e = e, this.channels = n, this.rate = s;
|
|
2540
|
-
const r = Math.max(s, i * 2), o =
|
|
2541
|
-
this.#t = new
|
|
2714
|
+
const r = Math.max(s, i * 2), o = Pt(n, r, s);
|
|
2715
|
+
this.#t = new De(o), this.#t.setLatency(i);
|
|
2542
2716
|
const a = { type: "init-shared", ...o };
|
|
2543
2717
|
e.port.postMessage(a), this.#i.interval(() => {
|
|
2544
2718
|
this.#n.set(this.#t.timestamp), this.#s.set(this.#t.stalled);
|
|
@@ -2560,7 +2734,7 @@ class Js {
|
|
|
2560
2734
|
this.#i.close();
|
|
2561
2735
|
}
|
|
2562
2736
|
}
|
|
2563
|
-
class
|
|
2737
|
+
class bi {
|
|
2564
2738
|
rate;
|
|
2565
2739
|
channels;
|
|
2566
2740
|
#e;
|
|
@@ -2568,10 +2742,10 @@ class Qs {
|
|
|
2568
2742
|
timestamp = this.#t;
|
|
2569
2743
|
#n = new h(!0);
|
|
2570
2744
|
stalled = this.#n;
|
|
2571
|
-
#s = new
|
|
2745
|
+
#s = new U();
|
|
2572
2746
|
constructor(e, n, s, i) {
|
|
2573
2747
|
this.#e = e, this.channels = n, this.rate = s;
|
|
2574
|
-
const r =
|
|
2748
|
+
const r = p.Milli.fromSecond(i / s), o = { type: "init-post", channels: n, rate: s, latency: r };
|
|
2575
2749
|
e.port.postMessage(o), this.#s.event(e.port, "message", (a) => {
|
|
2576
2750
|
const c = a.data;
|
|
2577
2751
|
c?.type === "state" && (this.#t.set(c.timestamp), this.#n.set(c.stalled));
|
|
@@ -2585,14 +2759,14 @@ class Qs {
|
|
|
2585
2759
|
);
|
|
2586
2760
|
}
|
|
2587
2761
|
setLatency(e) {
|
|
2588
|
-
const s = { type: "latency", latency:
|
|
2762
|
+
const s = { type: "latency", latency: p.Milli.fromSecond(e / this.rate) };
|
|
2589
2763
|
this.#e.port.postMessage(s);
|
|
2590
2764
|
}
|
|
2591
2765
|
close() {
|
|
2592
2766
|
this.#s.close();
|
|
2593
2767
|
}
|
|
2594
2768
|
}
|
|
2595
|
-
const
|
|
2769
|
+
const Si = `var __defProp = Object.defineProperty;
|
|
2596
2770
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2597
2771
|
var __esm = (fn, res) => function __init() {
|
|
2598
2772
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
@@ -3063,8 +3237,8 @@ var Render = class extends AudioWorkletProcessor {
|
|
|
3063
3237
|
}
|
|
3064
3238
|
};
|
|
3065
3239
|
registerProcessor("render", Render);
|
|
3066
|
-
`,
|
|
3067
|
-
let
|
|
3240
|
+
`, Ai = new Blob([Si], { type: "application/javascript" }), _i = URL.createObjectURL(Ai);
|
|
3241
|
+
let Mi = class {
|
|
3068
3242
|
source;
|
|
3069
3243
|
enabled;
|
|
3070
3244
|
#e = new h(void 0);
|
|
@@ -3090,9 +3264,9 @@ let si = class {
|
|
|
3090
3264
|
buffered = this.#a;
|
|
3091
3265
|
// Audio ring bridging main thread and worklet (shared memory or postMessage transport).
|
|
3092
3266
|
#c;
|
|
3093
|
-
#u = new
|
|
3267
|
+
#u = new U();
|
|
3094
3268
|
constructor(e, n) {
|
|
3095
|
-
this.source = e, this.source.supported.set(
|
|
3269
|
+
this.source = e, this.source.supported.set(zi), this.enabled = h.from(n?.enabled ?? !1), this.#u.run(this.#d.bind(this)), this.#u.run(this.#l.bind(this)), this.#u.run(this.#f.bind(this)), this.#u.run(this.#m.bind(this));
|
|
3096
3270
|
}
|
|
3097
3271
|
#d(e) {
|
|
3098
3272
|
const n = e.get(this.source.config);
|
|
@@ -3103,18 +3277,18 @@ let si = class {
|
|
|
3103
3277
|
sampleRate: s
|
|
3104
3278
|
});
|
|
3105
3279
|
e.set(this.#e, r), e.cleanup(() => r.close()), e.spawn(async () => {
|
|
3106
|
-
if (await r.audioWorklet.addModule(
|
|
3280
|
+
if (await r.audioWorklet.addModule(_i), r.state === "closed") return;
|
|
3107
3281
|
const o = new AudioWorkletNode(r, "render", {
|
|
3108
3282
|
channelCount: i,
|
|
3109
3283
|
channelCountMode: "explicit",
|
|
3110
3284
|
outputChannelCount: [i]
|
|
3111
3285
|
});
|
|
3112
3286
|
e.cleanup(() => o.disconnect());
|
|
3113
|
-
const a = this.source.sync.buffer.peek(), c = Math.ceil(s *
|
|
3287
|
+
const a = this.source.sync.buffer.peek(), c = Math.ceil(s * p.Second.fromMilli(a)), u = yi(o, i, s, c);
|
|
3114
3288
|
this.#c = u, e.cleanup(() => {
|
|
3115
3289
|
u.close(), this.#c = void 0;
|
|
3116
3290
|
}), e.run((l) => {
|
|
3117
|
-
const d =
|
|
3291
|
+
const d = p.Milli.fromMicro(l.get(u.timestamp));
|
|
3118
3292
|
this.#i.set(d), this.#y(d);
|
|
3119
3293
|
}), e.run((l) => {
|
|
3120
3294
|
this.#r.set(l.get(u.stalled));
|
|
@@ -3131,7 +3305,7 @@ let si = class {
|
|
|
3131
3305
|
if (!e.get(this.#t)) return;
|
|
3132
3306
|
const s = this.#c;
|
|
3133
3307
|
if (!s) return;
|
|
3134
|
-
const i = e.get(this.source.sync.buffer), r = Math.ceil(s.rate *
|
|
3308
|
+
const i = e.get(this.source.sync.buffer), r = Math.ceil(s.rate * p.Second.fromMilli(i));
|
|
3135
3309
|
s.setLatency(r);
|
|
3136
3310
|
}
|
|
3137
3311
|
#m(e) {
|
|
@@ -3144,18 +3318,18 @@ let si = class {
|
|
|
3144
3318
|
if (!r) return;
|
|
3145
3319
|
const o = e.get(s.active);
|
|
3146
3320
|
if (!o) return;
|
|
3147
|
-
const a = o.subscribe(i,
|
|
3321
|
+
const a = o.subscribe(i, ee.audio);
|
|
3148
3322
|
e.cleanup(() => a.close()), r.container.kind === "cmaf" ? this.#g(e, a, r) : this.#p(e, a, r);
|
|
3149
3323
|
}
|
|
3150
3324
|
#p(e, n, s) {
|
|
3151
|
-
const i = new
|
|
3325
|
+
const i = new ie(n, {
|
|
3152
3326
|
latency: this.source.sync.buffer
|
|
3153
3327
|
});
|
|
3154
3328
|
e.cleanup(() => i.close()), e.run((r) => {
|
|
3155
3329
|
const o = r.get(i.buffered), a = r.get(this.#o);
|
|
3156
|
-
this.#a.update(() =>
|
|
3330
|
+
this.#a.update(() => ki(o, a));
|
|
3157
3331
|
}), e.spawn(async () => {
|
|
3158
|
-
if (!await
|
|
3332
|
+
if (!await tt()) return;
|
|
3159
3333
|
let o = 0;
|
|
3160
3334
|
const a = new AudioDecoder({
|
|
3161
3335
|
output: (u) => {
|
|
@@ -3170,7 +3344,7 @@ let si = class {
|
|
|
3170
3344
|
e.cleanup(() => {
|
|
3171
3345
|
a.state !== "closed" && a.close();
|
|
3172
3346
|
});
|
|
3173
|
-
const c = s.description ?
|
|
3347
|
+
const c = s.description ? F(s.description) : void 0;
|
|
3174
3348
|
for (a.configure({
|
|
3175
3349
|
...s,
|
|
3176
3350
|
description: c
|
|
@@ -3179,7 +3353,7 @@ let si = class {
|
|
|
3179
3353
|
if (!u) break;
|
|
3180
3354
|
const { frame: l } = u;
|
|
3181
3355
|
if (!l) continue;
|
|
3182
|
-
const d =
|
|
3356
|
+
const d = p.Milli.fromMicro(l.timestamp);
|
|
3183
3357
|
this.source.sync.received(d, "audio"), this.#s.update((g) => ({
|
|
3184
3358
|
bytesReceived: (g?.bytesReceived ?? 0) + l.data.byteLength
|
|
3185
3359
|
}));
|
|
@@ -3194,12 +3368,12 @@ let si = class {
|
|
|
3194
3368
|
}
|
|
3195
3369
|
#g(e, n, s) {
|
|
3196
3370
|
if (s.container.kind !== "cmaf") return;
|
|
3197
|
-
const { timescale: i } = s.container, r = s.description ?
|
|
3371
|
+
const { timescale: i } = s.container, r = s.description ? F(s.description) : void 0;
|
|
3198
3372
|
e.run((o) => {
|
|
3199
3373
|
const a = o.get(this.#o);
|
|
3200
3374
|
this.#a.update(() => a);
|
|
3201
3375
|
}), e.spawn(async () => {
|
|
3202
|
-
if (!await
|
|
3376
|
+
if (!await tt()) return;
|
|
3203
3377
|
const a = new AudioDecoder({
|
|
3204
3378
|
output: (c) => this.#h(c),
|
|
3205
3379
|
error: (c) => console.error(c)
|
|
@@ -3212,16 +3386,16 @@ let si = class {
|
|
|
3212
3386
|
numberOfChannels: s.numberOfChannels,
|
|
3213
3387
|
description: r
|
|
3214
3388
|
}); ; ) {
|
|
3215
|
-
const c = await n.
|
|
3389
|
+
const c = await n.recvGroup();
|
|
3216
3390
|
if (!c) break;
|
|
3217
3391
|
e.spawn(async () => {
|
|
3218
3392
|
try {
|
|
3219
3393
|
for (; ; ) {
|
|
3220
3394
|
const u = await c.readFrame();
|
|
3221
3395
|
if (!u) break;
|
|
3222
|
-
const l =
|
|
3396
|
+
const l = Ct(u, i);
|
|
3223
3397
|
for (const d of l) {
|
|
3224
|
-
const f =
|
|
3398
|
+
const f = p.Milli.fromMicro(d.timestamp);
|
|
3225
3399
|
this.source.sync.received(f, "audio"), this.#s.update((y) => ({
|
|
3226
3400
|
bytesReceived: (y?.bytesReceived ?? 0) + d.data.byteLength
|
|
3227
3401
|
}));
|
|
@@ -3241,12 +3415,12 @@ let si = class {
|
|
|
3241
3415
|
});
|
|
3242
3416
|
}
|
|
3243
3417
|
#h(e) {
|
|
3244
|
-
const n = e.timestamp, s =
|
|
3418
|
+
const n = e.timestamp, s = p.Milli.fromMicro(n), i = this.#c;
|
|
3245
3419
|
if (!i) {
|
|
3246
3420
|
e.close();
|
|
3247
3421
|
return;
|
|
3248
3422
|
}
|
|
3249
|
-
const r = e.numberOfFrames / e.sampleRate * 1e6, o =
|
|
3423
|
+
const r = e.numberOfFrames / e.sampleRate * 1e6, o = p.Milli.fromMicro(r), a = p.Milli.add(s, o);
|
|
3250
3424
|
this.#w(s, a);
|
|
3251
3425
|
const c = Math.min(e.numberOfChannels, i.channels), u = [];
|
|
3252
3426
|
for (let l = 0; l < c; l++) {
|
|
@@ -3259,7 +3433,7 @@ let si = class {
|
|
|
3259
3433
|
e > n || this.#o.mutate((s) => {
|
|
3260
3434
|
for (const i of s)
|
|
3261
3435
|
if (e <= i.end + 1 && n >= i.start) {
|
|
3262
|
-
i.start =
|
|
3436
|
+
i.start = p.Milli.min(i.start, e), i.end = p.Milli.max(i.end, n);
|
|
3263
3437
|
return;
|
|
3264
3438
|
}
|
|
3265
3439
|
s.push({ start: e, end: n }), s.sort((i, r) => i.start - r.start);
|
|
@@ -3269,7 +3443,7 @@ let si = class {
|
|
|
3269
3443
|
this.#o.mutate((n) => {
|
|
3270
3444
|
for (; n.length > 0; ) {
|
|
3271
3445
|
if (n[0].end >= e) {
|
|
3272
|
-
n[0].start =
|
|
3446
|
+
n[0].start = p.Milli.max(n[0].start, e);
|
|
3273
3447
|
break;
|
|
3274
3448
|
}
|
|
3275
3449
|
n.shift();
|
|
@@ -3280,32 +3454,32 @@ let si = class {
|
|
|
3280
3454
|
this.#u.close();
|
|
3281
3455
|
}
|
|
3282
3456
|
};
|
|
3283
|
-
async function
|
|
3284
|
-
const e = t.description ?
|
|
3457
|
+
async function zi(t) {
|
|
3458
|
+
const e = t.description ? F(t.description) : void 0;
|
|
3285
3459
|
return (await AudioDecoder.isConfigSupported({
|
|
3286
3460
|
...t,
|
|
3287
3461
|
description: e
|
|
3288
3462
|
})).supported ?? !1;
|
|
3289
3463
|
}
|
|
3290
|
-
function
|
|
3464
|
+
function ki(t, e) {
|
|
3291
3465
|
if (t.length === 0) return e;
|
|
3292
3466
|
if (e.length === 0) return t;
|
|
3293
3467
|
const n = [], s = [...t, ...e].sort((i, r) => i.start - r.start);
|
|
3294
3468
|
for (const i of s) {
|
|
3295
3469
|
const r = n.at(-1);
|
|
3296
|
-
r && r.end >= i.start ? r.end =
|
|
3470
|
+
r && r.end >= i.start ? r.end = p.Milli.max(r.end, i.end) : n.push({ ...i });
|
|
3297
3471
|
}
|
|
3298
3472
|
return n;
|
|
3299
3473
|
}
|
|
3300
|
-
const
|
|
3301
|
-
class
|
|
3474
|
+
const nt = 1e-3, ze = 0.2;
|
|
3475
|
+
class Ti {
|
|
3302
3476
|
source;
|
|
3303
3477
|
volume;
|
|
3304
3478
|
muted;
|
|
3305
3479
|
// Similar to muted, but controls whether we download audio at all.
|
|
3306
3480
|
// That way we can be "muted" but also download audio for visualizations.
|
|
3307
3481
|
paused;
|
|
3308
|
-
#e = new
|
|
3482
|
+
#e = new U();
|
|
3309
3483
|
// The volume to use when unmuted.
|
|
3310
3484
|
#t = 0.5;
|
|
3311
3485
|
// The gain node used to adjust the volume.
|
|
@@ -3331,20 +3505,20 @@ class oi {
|
|
|
3331
3505
|
if (!i) return;
|
|
3332
3506
|
s.cleanup(() => i.gain.cancelScheduledValues(i.context.currentTime));
|
|
3333
3507
|
const r = s.get(this.volume);
|
|
3334
|
-
r <
|
|
3508
|
+
r < nt ? (i.gain.exponentialRampToValueAtTime(nt, i.context.currentTime + ze), i.gain.setValueAtTime(0, i.context.currentTime + ze + 0.01)) : i.gain.exponentialRampToValueAtTime(r, i.context.currentTime + ze);
|
|
3335
3509
|
});
|
|
3336
3510
|
}
|
|
3337
3511
|
close() {
|
|
3338
3512
|
this.#e.close();
|
|
3339
3513
|
}
|
|
3340
3514
|
}
|
|
3341
|
-
class
|
|
3515
|
+
class Nt {
|
|
3342
3516
|
element;
|
|
3343
3517
|
paused;
|
|
3344
3518
|
#e;
|
|
3345
3519
|
#t = new h(void 0);
|
|
3346
3520
|
mediaSource = this.#t;
|
|
3347
|
-
#n = new
|
|
3521
|
+
#n = new U();
|
|
3348
3522
|
constructor(e, n) {
|
|
3349
3523
|
this.element = h.from(n?.element), this.paused = h.from(n?.paused ?? !1), this.#e = e, this.#n.run(this.#s.bind(this)), this.#n.run(this.#i.bind(this)), this.#n.run(this.#r.bind(this)), this.#n.run(this.#o.bind(this)), this.#n.run(this.#a.bind(this));
|
|
3350
3524
|
}
|
|
@@ -3366,7 +3540,7 @@ class It {
|
|
|
3366
3540
|
#i(e) {
|
|
3367
3541
|
const n = e.get(this.element);
|
|
3368
3542
|
if (!n || e.get(this.paused)) return;
|
|
3369
|
-
const i =
|
|
3543
|
+
const i = p.Milli.toSecond(e.get(this.#e.buffer));
|
|
3370
3544
|
e.interval(() => {
|
|
3371
3545
|
const r = n.buffered;
|
|
3372
3546
|
if (r.length === 0) return;
|
|
@@ -3400,18 +3574,18 @@ class It {
|
|
|
3400
3574
|
if (!n || e.get(this.paused)) return;
|
|
3401
3575
|
const i = e.get(this.#e.reference);
|
|
3402
3576
|
if (i === void 0) return;
|
|
3403
|
-
const r = e.get(this.#e.buffer), o =
|
|
3404
|
-
n.currentTime =
|
|
3577
|
+
const r = e.get(this.#e.buffer), o = p.Milli.sub(p.Milli.sub(p.Milli.now(), i), r);
|
|
3578
|
+
n.currentTime = p.Milli.toSecond(o);
|
|
3405
3579
|
}
|
|
3406
3580
|
close() {
|
|
3407
3581
|
this.#n.close();
|
|
3408
3582
|
}
|
|
3409
3583
|
}
|
|
3410
|
-
const
|
|
3584
|
+
const lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3411
3585
|
__proto__: null,
|
|
3412
|
-
Muxer:
|
|
3413
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
3414
|
-
class
|
|
3586
|
+
Muxer: Nt
|
|
3587
|
+
}, Symbol.toStringTag, { value: "Module" })), Ui = 20, st = 100;
|
|
3588
|
+
class Le {
|
|
3415
3589
|
// The earliest time we've received a frame, relative to its timestamp.
|
|
3416
3590
|
// This will keep being updated as we catch up to the live playhead then will be relatively static.
|
|
3417
3591
|
#e = new h(void 0);
|
|
@@ -3426,7 +3600,7 @@ class Ue {
|
|
|
3426
3600
|
audio;
|
|
3427
3601
|
video;
|
|
3428
3602
|
// The total buffer required: jitter + max(audio, video).
|
|
3429
|
-
#t = new h(
|
|
3603
|
+
#t = new h(p.Milli.zero);
|
|
3430
3604
|
buffer = this.#t;
|
|
3431
3605
|
// A ghetto way to learn when the reference/buffer changes.
|
|
3432
3606
|
// There's probably a way to use Effect, but lets keep it simple for now.
|
|
@@ -3440,9 +3614,9 @@ class Ue {
|
|
|
3440
3614
|
// Minimum RTT seen, used as the baseline for jitter calculation.
|
|
3441
3615
|
// Avoids inflating jitter due to bufferbloat.
|
|
3442
3616
|
#i;
|
|
3443
|
-
signals = new
|
|
3617
|
+
signals = new U();
|
|
3444
3618
|
constructor(e) {
|
|
3445
|
-
this.latency = h.from(e?.latency ?? "real-time"), this.jitter = new h(
|
|
3619
|
+
this.latency = h.from(e?.latency ?? "real-time"), this.jitter = new h(st), this.rtt = e?.rtt, this.audio = h.from(e?.audio), this.video = h.from(e?.video), this.#n = Promise.withResolvers(), this.signals.run(this.#r.bind(this)), this.signals.run(this.#o.bind(this));
|
|
3446
3620
|
}
|
|
3447
3621
|
#r(e) {
|
|
3448
3622
|
const n = e.get(this.latency);
|
|
@@ -3454,30 +3628,30 @@ class Ue {
|
|
|
3454
3628
|
const s = e.get(this.rtt);
|
|
3455
3629
|
if (s !== void 0) {
|
|
3456
3630
|
this.#i = this.#i !== void 0 ? Math.min(this.#i, s) : s;
|
|
3457
|
-
const i = Math.max(
|
|
3631
|
+
const i = Math.max(Ui, this.#i * 1.25);
|
|
3458
3632
|
this.jitter.set(i);
|
|
3459
3633
|
return;
|
|
3460
3634
|
}
|
|
3461
3635
|
}
|
|
3462
|
-
this.#i = void 0, this.jitter.set(
|
|
3636
|
+
this.#i = void 0, this.jitter.set(st);
|
|
3463
3637
|
}
|
|
3464
3638
|
#o(e) {
|
|
3465
|
-
const n = e.get(this.jitter), s = e.get(this.video) ??
|
|
3639
|
+
const n = e.get(this.jitter), s = e.get(this.video) ?? p.Milli.zero, i = e.get(this.audio) ?? p.Milli.zero, r = p.Milli.add(p.Milli.max(s, i), n);
|
|
3466
3640
|
this.#t.set(r), this.#n.resolve(), this.#n = Promise.withResolvers();
|
|
3467
3641
|
}
|
|
3468
3642
|
// Update the reference if this is the earliest frame we've seen, relative to its timestamp.
|
|
3469
3643
|
received(e, n = "") {
|
|
3470
3644
|
this.timestamp.update((o) => o === void 0 || e > o ? e : o);
|
|
3471
|
-
const s =
|
|
3645
|
+
const s = p.Milli.now(), i = p.Milli.sub(s, e), r = this.#e.peek();
|
|
3472
3646
|
if (r !== void 0) {
|
|
3473
|
-
const o =
|
|
3647
|
+
const o = p.Milli.add(p.Milli.sub(r, i), this.#t.peek());
|
|
3474
3648
|
if (o < 0) {
|
|
3475
3649
|
const a = this.#s.get(n);
|
|
3476
3650
|
a ? (a.count++, a.maxMs = Math.max(a.maxMs, -o)) : this.#s.set(n, { count: 1, maxMs: -o });
|
|
3477
3651
|
} else {
|
|
3478
3652
|
const a = this.#s.get(n);
|
|
3479
3653
|
if (a) {
|
|
3480
|
-
const c = n ? `sync[${n}]` : "sync", u =
|
|
3654
|
+
const c = n ? `sync[${n}]` : "sync", u = Le.#a(a.maxMs);
|
|
3481
3655
|
console.debug(`${c}: ${a.count} late frame(s), max ${u} behind`), this.#s.delete(n);
|
|
3482
3656
|
}
|
|
3483
3657
|
}
|
|
@@ -3491,16 +3665,16 @@ class Ue {
|
|
|
3491
3665
|
now() {
|
|
3492
3666
|
const e = this.#e.peek();
|
|
3493
3667
|
if (e !== void 0)
|
|
3494
|
-
return
|
|
3668
|
+
return p.Milli.sub(p.Milli.sub(p.Milli.now(), e), this.#t.peek());
|
|
3495
3669
|
}
|
|
3496
3670
|
// Sleep until it's time to render this frame.
|
|
3497
3671
|
async wait(e) {
|
|
3498
3672
|
if (this.#e.peek() === void 0)
|
|
3499
3673
|
throw new Error("reference not set; call update() first");
|
|
3500
3674
|
for (; ; ) {
|
|
3501
|
-
const s =
|
|
3675
|
+
const s = p.Milli.now(), i = p.Milli.sub(s, e), r = this.#e.peek();
|
|
3502
3676
|
if (r === void 0) return;
|
|
3503
|
-
const o =
|
|
3677
|
+
const o = p.Milli.add(p.Milli.sub(r, i), this.#t.peek());
|
|
3504
3678
|
if (o <= 0 || o < 5) return;
|
|
3505
3679
|
const a = new Promise((u) => setTimeout(u, o)).then(() => !0);
|
|
3506
3680
|
if (await Promise.race([this.#n.promise, a])) return;
|
|
@@ -3517,8 +3691,8 @@ class Ue {
|
|
|
3517
3691
|
this.signals.close();
|
|
3518
3692
|
}
|
|
3519
3693
|
}
|
|
3520
|
-
const
|
|
3521
|
-
class
|
|
3694
|
+
const Ei = 500, xi = 100;
|
|
3695
|
+
class Ri {
|
|
3522
3696
|
enabled;
|
|
3523
3697
|
// Don't download any longer
|
|
3524
3698
|
source;
|
|
@@ -3540,9 +3714,9 @@ class li {
|
|
|
3540
3714
|
// Combined buffered ranges (network jitter + decode buffer)
|
|
3541
3715
|
#o = new h([]);
|
|
3542
3716
|
buffered = this.#o;
|
|
3543
|
-
#a = new
|
|
3717
|
+
#a = new U();
|
|
3544
3718
|
constructor(e, n) {
|
|
3545
|
-
this.enabled = h.from(n?.enabled ?? !1), this.source = e, this.source.supported.set(
|
|
3719
|
+
this.enabled = h.from(n?.enabled ?? !1), this.source = e, this.source.supported.set(Ii), this.#a.run(this.#c.bind(this)), this.#a.run(this.#u.bind(this)), this.#a.run(this.#d.bind(this)), this.#a.run(this.#l.bind(this));
|
|
3546
3720
|
}
|
|
3547
3721
|
#c(e) {
|
|
3548
3722
|
const n = e.getAll([this.enabled, this.source.broadcast, this.source.track, this.source.config]);
|
|
@@ -3552,7 +3726,7 @@ class li {
|
|
|
3552
3726
|
}
|
|
3553
3727
|
const [s, i, r, o] = n, a = e.get(i.active);
|
|
3554
3728
|
if (!a) return;
|
|
3555
|
-
let c = new
|
|
3729
|
+
let c = new Bi({
|
|
3556
3730
|
source: this.source,
|
|
3557
3731
|
broadcast: a,
|
|
3558
3732
|
track: r,
|
|
@@ -3564,7 +3738,7 @@ class li {
|
|
|
3564
3738
|
const l = u.get(this.#e);
|
|
3565
3739
|
if (l) {
|
|
3566
3740
|
const d = u.get(c.timestamp), f = u.get(l.timestamp);
|
|
3567
|
-
if (!d || f && f > d +
|
|
3741
|
+
if (!d || f && f > d + xi) return;
|
|
3568
3742
|
}
|
|
3569
3743
|
this.#e.set(c), c = void 0, u.close();
|
|
3570
3744
|
});
|
|
@@ -3605,7 +3779,7 @@ class li {
|
|
|
3605
3779
|
}
|
|
3606
3780
|
this.#i.set(!1), e.timer(() => {
|
|
3607
3781
|
this.#i.set(!0);
|
|
3608
|
-
},
|
|
3782
|
+
}, Ei);
|
|
3609
3783
|
}
|
|
3610
3784
|
close() {
|
|
3611
3785
|
this.#t.update((e) => {
|
|
@@ -3613,7 +3787,7 @@ class li {
|
|
|
3613
3787
|
}), this.#a.close();
|
|
3614
3788
|
}
|
|
3615
3789
|
}
|
|
3616
|
-
class
|
|
3790
|
+
class Bi {
|
|
3617
3791
|
source;
|
|
3618
3792
|
broadcast;
|
|
3619
3793
|
track;
|
|
@@ -3625,18 +3799,18 @@ class di {
|
|
|
3625
3799
|
buffered = new h([]);
|
|
3626
3800
|
// Decoded frames waiting to be rendered.
|
|
3627
3801
|
#e = new h([]);
|
|
3628
|
-
signals = new
|
|
3802
|
+
signals = new U();
|
|
3629
3803
|
constructor(e) {
|
|
3630
3804
|
const { codedWidth: n, codedHeight: s, ...i } = e.config;
|
|
3631
3805
|
this.source = e.source, this.broadcast = e.broadcast, this.track = e.track, this.config = i, this.stats = e.stats, this.signals.run(this.#t.bind(this));
|
|
3632
3806
|
}
|
|
3633
3807
|
#t(e) {
|
|
3634
|
-
const n = this.broadcast.subscribe(this.track,
|
|
3808
|
+
const n = this.broadcast.subscribe(this.track, ee.video);
|
|
3635
3809
|
e.cleanup(() => n.close());
|
|
3636
3810
|
const s = new VideoDecoder({
|
|
3637
3811
|
output: async (i) => {
|
|
3638
3812
|
try {
|
|
3639
|
-
const r =
|
|
3813
|
+
const r = p.Milli.fromMicro(i.timestamp);
|
|
3640
3814
|
if (r < (this.timestamp.peek() ?? 0))
|
|
3641
3815
|
return;
|
|
3642
3816
|
this.frame.peek() === void 0 && this.frame.set(i.clone());
|
|
@@ -3658,15 +3832,15 @@ class di {
|
|
|
3658
3832
|
}), this.config.container.kind === "cmaf" ? this.#s(e, n, s) : this.#n(e, n, s);
|
|
3659
3833
|
}
|
|
3660
3834
|
#n(e, n, s) {
|
|
3661
|
-
const i = new
|
|
3835
|
+
const i = new ie(n, {
|
|
3662
3836
|
latency: this.source.sync.buffer
|
|
3663
3837
|
});
|
|
3664
3838
|
e.cleanup(() => i.close()), e.run((o) => {
|
|
3665
3839
|
const a = o.get(i.buffered), c = o.get(this.#e);
|
|
3666
|
-
this.buffered.update(() =>
|
|
3840
|
+
this.buffered.update(() => Ci(a, c));
|
|
3667
3841
|
}), s.configure({
|
|
3668
3842
|
...this.config,
|
|
3669
|
-
description: this.config.description ?
|
|
3843
|
+
description: this.config.description ? F(this.config.description) : void 0,
|
|
3670
3844
|
optimizeForLatency: this.config.optimizeForLatency ?? !0,
|
|
3671
3845
|
// @ts-expect-error Only supported by Chrome, so the renderer has to flip manually.
|
|
3672
3846
|
flip: !1
|
|
@@ -3681,7 +3855,7 @@ class di {
|
|
|
3681
3855
|
r && (r.final = !0);
|
|
3682
3856
|
continue;
|
|
3683
3857
|
}
|
|
3684
|
-
const u =
|
|
3858
|
+
const u = p.Milli.fromMicro(a.timestamp);
|
|
3685
3859
|
this.source.sync.received(u, "video");
|
|
3686
3860
|
const l = new EncodedVideoChunk({
|
|
3687
3861
|
type: a.keyframe ? "key" : "delta",
|
|
@@ -3692,7 +3866,7 @@ class di {
|
|
|
3692
3866
|
frameCount: (d?.frameCount ?? 0) + 1,
|
|
3693
3867
|
bytesReceived: (d?.bytesReceived ?? 0) + a.data.byteLength
|
|
3694
3868
|
})), r?.group === c || r?.final && r.group + 1 === c) {
|
|
3695
|
-
const d =
|
|
3869
|
+
const d = p.Milli.fromMicro(r.timestamp), f = p.Milli.fromMicro(a.timestamp);
|
|
3696
3870
|
this.#i(d, f);
|
|
3697
3871
|
}
|
|
3698
3872
|
r = {
|
|
@@ -3705,7 +3879,7 @@ class di {
|
|
|
3705
3879
|
}
|
|
3706
3880
|
#s(e, n, s) {
|
|
3707
3881
|
if (this.config.container.kind !== "cmaf") return;
|
|
3708
|
-
const { timescale: i } = this.config.container, r = this.config.description ?
|
|
3882
|
+
const { timescale: i } = this.config.container, r = this.config.description ? F(this.config.description) : void 0;
|
|
3709
3883
|
s.configure({
|
|
3710
3884
|
codec: this.config.codec,
|
|
3711
3885
|
description: r,
|
|
@@ -3717,7 +3891,7 @@ class di {
|
|
|
3717
3891
|
this.buffered.update(() => a);
|
|
3718
3892
|
}), e.spawn(async () => {
|
|
3719
3893
|
for (; ; ) {
|
|
3720
|
-
const o = await Promise.race([n.
|
|
3894
|
+
const o = await Promise.race([n.recvGroup(), e.cancel]);
|
|
3721
3895
|
if (!o) break;
|
|
3722
3896
|
e.spawn(async () => {
|
|
3723
3897
|
let a;
|
|
@@ -3725,18 +3899,18 @@ class di {
|
|
|
3725
3899
|
for (; ; ) {
|
|
3726
3900
|
const c = await Promise.race([o.readFrame(), e.cancel]);
|
|
3727
3901
|
if (!c) break;
|
|
3728
|
-
const u =
|
|
3902
|
+
const u = Ct(c, i);
|
|
3729
3903
|
for (const l of u) {
|
|
3730
3904
|
const d = new EncodedVideoChunk({
|
|
3731
3905
|
type: l.keyframe ? "key" : "delta",
|
|
3732
3906
|
data: l.data,
|
|
3733
3907
|
timestamp: l.timestamp
|
|
3734
|
-
}), f =
|
|
3908
|
+
}), f = p.Milli.fromMicro(l.timestamp);
|
|
3735
3909
|
if (this.source.sync.received(f, "video"), this.stats.update((g) => ({
|
|
3736
3910
|
frameCount: (g?.frameCount ?? 0) + 1,
|
|
3737
3911
|
bytesReceived: (g?.bytesReceived ?? 0) + l.data.byteLength
|
|
3738
3912
|
})), a !== void 0) {
|
|
3739
|
-
const g =
|
|
3913
|
+
const g = p.Milli.fromMicro(a), y = p.Milli.fromMicro(l.timestamp);
|
|
3740
3914
|
this.#i(g, y);
|
|
3741
3915
|
}
|
|
3742
3916
|
a = l.timestamp, s.decode(d);
|
|
@@ -3754,7 +3928,7 @@ class di {
|
|
|
3754
3928
|
e > n || this.#e.mutate((s) => {
|
|
3755
3929
|
for (const i of s)
|
|
3756
3930
|
if (i.start <= n && i.end >= e) {
|
|
3757
|
-
i.start =
|
|
3931
|
+
i.start = p.Milli.min(i.start, e), i.end = p.Milli.max(i.end, n);
|
|
3758
3932
|
return;
|
|
3759
3933
|
}
|
|
3760
3934
|
s.push({ start: e, end: n }), s.sort((i, r) => i.start - r.start);
|
|
@@ -3765,7 +3939,7 @@ class di {
|
|
|
3765
3939
|
this.#e.mutate((n) => {
|
|
3766
3940
|
for (; n.length > 0; ) {
|
|
3767
3941
|
if (n[0].end >= e) {
|
|
3768
|
-
n[0].start =
|
|
3942
|
+
n[0].start = p.Milli.max(n[0].start, e);
|
|
3769
3943
|
break;
|
|
3770
3944
|
}
|
|
3771
3945
|
n.shift();
|
|
@@ -3778,18 +3952,18 @@ class di {
|
|
|
3778
3952
|
});
|
|
3779
3953
|
}
|
|
3780
3954
|
}
|
|
3781
|
-
function
|
|
3955
|
+
function Ci(t, e) {
|
|
3782
3956
|
if (t.length === 0) return e;
|
|
3783
3957
|
if (e.length === 0) return t;
|
|
3784
3958
|
const n = [], s = [...t, ...e].sort((i, r) => i.start - r.start);
|
|
3785
3959
|
for (const i of s) {
|
|
3786
3960
|
const r = n.at(-1);
|
|
3787
|
-
r && r.end >= i.start ? r.end =
|
|
3961
|
+
r && r.end >= i.start ? r.end = p.Milli.max(r.end, i.end) : n.push({ ...i });
|
|
3788
3962
|
}
|
|
3789
3963
|
return n;
|
|
3790
3964
|
}
|
|
3791
|
-
async function
|
|
3792
|
-
const e = t.description ?
|
|
3965
|
+
async function Ii(t) {
|
|
3966
|
+
const e = t.description ? F(t.description) : void 0, { supported: n } = await VideoDecoder.isConfigSupported({
|
|
3793
3967
|
codec: t.codec,
|
|
3794
3968
|
description: e,
|
|
3795
3969
|
optimizeForLatency: t.optimizeForLatency ?? !0
|
|
@@ -3806,7 +3980,7 @@ async function fi(t) {
|
|
|
3806
3980
|
}
|
|
3807
3981
|
return !1;
|
|
3808
3982
|
}
|
|
3809
|
-
let
|
|
3983
|
+
let Oi = class {
|
|
3810
3984
|
muxer;
|
|
3811
3985
|
source;
|
|
3812
3986
|
// TODO implement stats
|
|
@@ -3816,11 +3990,11 @@ let mi = class {
|
|
|
3816
3990
|
buffered = this.#t;
|
|
3817
3991
|
#n = new h(!1);
|
|
3818
3992
|
stalled = this.#n;
|
|
3819
|
-
#s = new h(
|
|
3993
|
+
#s = new h(_.Time.Milli.zero);
|
|
3820
3994
|
timestamp = this.#s;
|
|
3821
|
-
signals = new
|
|
3995
|
+
signals = new U();
|
|
3822
3996
|
constructor(e, n) {
|
|
3823
|
-
this.muxer = e, this.source = n, this.source.supported.set(
|
|
3997
|
+
this.muxer = e, this.source = n, this.source.supported.set(Di), this.signals.run(this.#i.bind(this)), this.signals.run(this.#c.bind(this)), this.signals.run(this.#u.bind(this));
|
|
3824
3998
|
}
|
|
3825
3999
|
#i(e) {
|
|
3826
4000
|
const n = e.get(this.muxer.element);
|
|
@@ -3841,7 +4015,7 @@ let mi = class {
|
|
|
3841
4015
|
}), e.event(u, "error", (l) => {
|
|
3842
4016
|
console.error("[MSE] SourceBuffer error:", l);
|
|
3843
4017
|
}), e.event(u, "updateend", () => {
|
|
3844
|
-
this.#t.set(
|
|
4018
|
+
this.#t.set(Ft(u.buffered));
|
|
3845
4019
|
}), a.container.kind === "cmaf" ? this.#o(e, r, o, a, u, n) : this.#a(e, r, o, a, u, n);
|
|
3846
4020
|
}
|
|
3847
4021
|
async #r(e, n) {
|
|
@@ -3852,27 +4026,27 @@ let mi = class {
|
|
|
3852
4026
|
}
|
|
3853
4027
|
#o(e, n, s, i, r, o) {
|
|
3854
4028
|
if (i.container.kind !== "cmaf") throw new Error("unreachable");
|
|
3855
|
-
const a = n.subscribe(s,
|
|
4029
|
+
const a = n.subscribe(s, ee.video);
|
|
3856
4030
|
e.cleanup(() => a.close());
|
|
3857
4031
|
const c = i.container.timescale;
|
|
3858
4032
|
e.spawn(async () => {
|
|
3859
|
-
const u =
|
|
4033
|
+
const u = Qe(i);
|
|
3860
4034
|
for (await this.#r(r, u); ; ) {
|
|
3861
4035
|
const l = await a.readFrame();
|
|
3862
4036
|
if (!l) return;
|
|
3863
|
-
const d =
|
|
3864
|
-
this.source.sync.received(
|
|
4037
|
+
const d = Bt(l, c);
|
|
4038
|
+
this.source.sync.received(_.Time.Milli.fromMicro(d), "video"), await this.#r(r, l), o.buffered.length > 0 && o.currentTime < o.buffered.start(0) && (o.currentTime = o.buffered.start(0));
|
|
3865
4039
|
}
|
|
3866
4040
|
});
|
|
3867
4041
|
}
|
|
3868
4042
|
#a(e, n, s, i, r, o) {
|
|
3869
|
-
const a = n.subscribe(s,
|
|
4043
|
+
const a = n.subscribe(s, ee.video);
|
|
3870
4044
|
e.cleanup(() => a.close());
|
|
3871
|
-
const c = new
|
|
4045
|
+
const c = new ie(a, {
|
|
3872
4046
|
latency: this.source.sync.buffer
|
|
3873
4047
|
});
|
|
3874
4048
|
e.cleanup(() => c.close()), e.spawn(async () => {
|
|
3875
|
-
const u =
|
|
4049
|
+
const u = Qe(i);
|
|
3876
4050
|
await this.#r(r, u);
|
|
3877
4051
|
let l = 1, d, f;
|
|
3878
4052
|
for (; ; ) {
|
|
@@ -3880,7 +4054,7 @@ let mi = class {
|
|
|
3880
4054
|
if (!g) return;
|
|
3881
4055
|
if (!g.frame) continue;
|
|
3882
4056
|
f = g.frame;
|
|
3883
|
-
const y =
|
|
4057
|
+
const y = _.Time.Milli.fromMicro(f.timestamp);
|
|
3884
4058
|
this.source.sync.received(y, "video");
|
|
3885
4059
|
break;
|
|
3886
4060
|
}
|
|
@@ -3889,11 +4063,11 @@ let mi = class {
|
|
|
3889
4063
|
if (g && !g.frame) continue;
|
|
3890
4064
|
const y = g?.frame;
|
|
3891
4065
|
if (y) {
|
|
3892
|
-
d =
|
|
3893
|
-
const
|
|
3894
|
-
this.source.sync.received(
|
|
4066
|
+
d = _.Time.Micro.sub(y.timestamp, f.timestamp);
|
|
4067
|
+
const A = _.Time.Milli.fromMicro(y.timestamp);
|
|
4068
|
+
this.source.sync.received(A, "video");
|
|
3895
4069
|
}
|
|
3896
|
-
const
|
|
4070
|
+
const v = Lt({
|
|
3897
4071
|
data: f.data,
|
|
3898
4072
|
timestamp: f.timestamp,
|
|
3899
4073
|
duration: d ?? 0,
|
|
@@ -3901,7 +4075,7 @@ let mi = class {
|
|
|
3901
4075
|
keyframe: f.keyframe,
|
|
3902
4076
|
sequence: l++
|
|
3903
4077
|
});
|
|
3904
|
-
if (await this.#r(r,
|
|
4078
|
+
if (await this.#r(r, v), o.buffered.length > 0 && o.currentTime < o.buffered.start(0) && (o.currentTime = o.buffered.start(0)), !y) return;
|
|
3905
4079
|
f = y;
|
|
3906
4080
|
}
|
|
3907
4081
|
});
|
|
@@ -3921,13 +4095,13 @@ let mi = class {
|
|
|
3921
4095
|
const s = n;
|
|
3922
4096
|
let i;
|
|
3923
4097
|
const r = () => {
|
|
3924
|
-
const o =
|
|
4098
|
+
const o = _.Time.Milli.fromSecond(s.currentTime);
|
|
3925
4099
|
this.#s.set(o), i = s.requestVideoFrameCallback(r);
|
|
3926
4100
|
};
|
|
3927
4101
|
i = s.requestVideoFrameCallback(r), e.cleanup(() => s.cancelVideoFrameCallback(i));
|
|
3928
4102
|
} else
|
|
3929
4103
|
e.event(n, "timeupdate", () => {
|
|
3930
|
-
const s =
|
|
4104
|
+
const s = _.Time.Milli.fromSecond(n.currentTime);
|
|
3931
4105
|
this.#s.set(s);
|
|
3932
4106
|
});
|
|
3933
4107
|
}
|
|
@@ -3935,10 +4109,10 @@ let mi = class {
|
|
|
3935
4109
|
this.source.close(), this.signals.close();
|
|
3936
4110
|
}
|
|
3937
4111
|
};
|
|
3938
|
-
async function
|
|
4112
|
+
async function Di(t) {
|
|
3939
4113
|
return MediaSource.isTypeSupported(`video/mp4; codecs="${t.codec}"`);
|
|
3940
4114
|
}
|
|
3941
|
-
class
|
|
4115
|
+
class Li {
|
|
3942
4116
|
decoder;
|
|
3943
4117
|
// The canvas to render the video to.
|
|
3944
4118
|
canvas;
|
|
@@ -3950,7 +4124,7 @@ class gi {
|
|
|
3950
4124
|
timestamp = new h(void 0);
|
|
3951
4125
|
#e = new h(void 0);
|
|
3952
4126
|
#t = new h(!1);
|
|
3953
|
-
#n = new
|
|
4127
|
+
#n = new U();
|
|
3954
4128
|
constructor(e, n) {
|
|
3955
4129
|
this.decoder = e, this.canvas = h.from(n?.canvas), this.paused = h.from(n?.paused ?? !1), this.#n.run((s) => {
|
|
3956
4130
|
const i = s.get(this.canvas);
|
|
@@ -4000,7 +4174,7 @@ class gi {
|
|
|
4000
4174
|
s || (i = e.get(this.decoder.frame));
|
|
4001
4175
|
let r = requestAnimationFrame(() => {
|
|
4002
4176
|
const o = i ?? this.frame.peek();
|
|
4003
|
-
this.#a(n, o), i && (this.frame.update((a) => (a?.close(), i.clone())), this.timestamp.set(
|
|
4177
|
+
this.#a(n, o), i && (this.frame.update((a) => (a?.close(), i.clone())), this.timestamp.set(p.Milli.fromMicro(i.timestamp))), r = void 0;
|
|
4004
4178
|
});
|
|
4005
4179
|
e.cleanup(() => {
|
|
4006
4180
|
i?.close(), r && cancelAnimationFrame(r);
|
|
@@ -4020,7 +4194,7 @@ class gi {
|
|
|
4020
4194
|
}), this.#n.close();
|
|
4021
4195
|
}
|
|
4022
4196
|
}
|
|
4023
|
-
function
|
|
4197
|
+
function Pi(t) {
|
|
4024
4198
|
return (e) => {
|
|
4025
4199
|
const n = [], s = [];
|
|
4026
4200
|
for (const [i, r] of e)
|
|
@@ -4031,7 +4205,7 @@ function wi(t) {
|
|
|
4031
4205
|
return n.sort((i, r) => r.size - i.size), n.length > 0 ? n.map((i) => i.name) : s.length > 0 ? (s.sort((i, r) => i.size - r.size), [s[0].name]) : e.map(([i]) => i);
|
|
4032
4206
|
};
|
|
4033
4207
|
}
|
|
4034
|
-
function
|
|
4208
|
+
function Ni(t) {
|
|
4035
4209
|
return (e) => {
|
|
4036
4210
|
const n = [], s = [];
|
|
4037
4211
|
for (const [i, r] of e)
|
|
@@ -4039,7 +4213,7 @@ function yi(t) {
|
|
|
4039
4213
|
return n.sort((i, r) => r.bitrate - i.bitrate), n.length > 0 ? n.map((i) => i.name) : s.length > 0 ? (s.sort((i, r) => i.bitrate - r.bitrate), [s[0].name]) : e.map(([i]) => i);
|
|
4040
4214
|
};
|
|
4041
4215
|
}
|
|
4042
|
-
function
|
|
4216
|
+
function Fi(t) {
|
|
4043
4217
|
let e = t[0];
|
|
4044
4218
|
for (const n of t) {
|
|
4045
4219
|
const [, s] = n, [, i] = e, r = (s.codedWidth ?? 0) * (s.codedHeight ?? 0), o = (i.codedWidth ?? 0) * (i.codedHeight ?? 0);
|
|
@@ -4051,7 +4225,7 @@ function bi(t) {
|
|
|
4051
4225
|
}
|
|
4052
4226
|
return e[0];
|
|
4053
4227
|
}
|
|
4054
|
-
let
|
|
4228
|
+
let $i = class {
|
|
4055
4229
|
broadcast;
|
|
4056
4230
|
target;
|
|
4057
4231
|
#e = new h(void 0);
|
|
@@ -4065,7 +4239,7 @@ let vi = class {
|
|
|
4065
4239
|
config = this.#s;
|
|
4066
4240
|
sync;
|
|
4067
4241
|
supported;
|
|
4068
|
-
#i = new
|
|
4242
|
+
#i = new U();
|
|
4069
4243
|
constructor(e, n) {
|
|
4070
4244
|
this.broadcast = h.from(n?.broadcast), this.target = h.from(n?.target), this.sync = e, this.supported = h.from(n?.supported), this.#i.run(this.#r.bind(this)), this.#i.run(this.#o.bind(this)), this.#i.run(this.#a.bind(this));
|
|
4071
4245
|
}
|
|
@@ -4125,8 +4299,8 @@ let vi = class {
|
|
|
4125
4299
|
if (s.length === 0) return;
|
|
4126
4300
|
if (s.length === 1) return s[0][0];
|
|
4127
4301
|
const i = [];
|
|
4128
|
-
if (n?.pixels != null && i.push(
|
|
4129
|
-
return
|
|
4302
|
+
if (n?.pixels != null && i.push(Pi(n.pixels)), n?.bitrate != null && i.push(Ni(n.bitrate)), i.length === 0)
|
|
4303
|
+
return Fi(s);
|
|
4130
4304
|
const r = i.map((a) => a(s)), o = r.map((a) => new Set(a));
|
|
4131
4305
|
for (const a of r[0])
|
|
4132
4306
|
if (o.every((c) => c.has(a)))
|
|
@@ -4137,15 +4311,15 @@ let vi = class {
|
|
|
4137
4311
|
this.#i.close();
|
|
4138
4312
|
}
|
|
4139
4313
|
};
|
|
4140
|
-
function
|
|
4314
|
+
function Ft(t) {
|
|
4141
4315
|
const e = [];
|
|
4142
4316
|
for (let n = 0; n < t.length; n++) {
|
|
4143
|
-
const s =
|
|
4317
|
+
const s = _.Time.Milli.fromSecond(t.start(n)), i = _.Time.Milli.fromSecond(t.end(n));
|
|
4144
4318
|
e.push({ start: s, end: i });
|
|
4145
4319
|
}
|
|
4146
4320
|
return e;
|
|
4147
4321
|
}
|
|
4148
|
-
class
|
|
4322
|
+
class ji {
|
|
4149
4323
|
// The source of the video.
|
|
4150
4324
|
source;
|
|
4151
4325
|
// The stats of the video.
|
|
@@ -4155,12 +4329,12 @@ class Si {
|
|
|
4155
4329
|
// Buffered time ranges
|
|
4156
4330
|
buffered = new h([]);
|
|
4157
4331
|
// The timestamp of the current frame
|
|
4158
|
-
timestamp = new h(
|
|
4332
|
+
timestamp = new h(_.Time.Milli.zero);
|
|
4159
4333
|
constructor(e) {
|
|
4160
4334
|
this.source = e;
|
|
4161
4335
|
}
|
|
4162
4336
|
}
|
|
4163
|
-
class
|
|
4337
|
+
class Zi {
|
|
4164
4338
|
source;
|
|
4165
4339
|
// The volume of the audio, between 0 and 1.
|
|
4166
4340
|
volume = new h(0.5);
|
|
@@ -4174,7 +4348,7 @@ class Mi {
|
|
|
4174
4348
|
this.source = e;
|
|
4175
4349
|
}
|
|
4176
4350
|
}
|
|
4177
|
-
class
|
|
4351
|
+
class fr {
|
|
4178
4352
|
element = new h(void 0);
|
|
4179
4353
|
broadcast;
|
|
4180
4354
|
latency;
|
|
@@ -4186,33 +4360,33 @@ class Li {
|
|
|
4186
4360
|
#t;
|
|
4187
4361
|
// Used to sync audio and video playback at a target delay.
|
|
4188
4362
|
sync;
|
|
4189
|
-
signals = new
|
|
4363
|
+
signals = new U();
|
|
4190
4364
|
constructor(e) {
|
|
4191
|
-
this.element = h.from(e?.element), this.broadcast = h.from(e?.broadcast), this.sync = new
|
|
4365
|
+
this.element = h.from(e?.element), this.broadcast = h.from(e?.broadcast), this.sync = new Le({ latency: e?.latency, rtt: e?.rtt }), this.latency = this.sync.latency, this.jitter = this.sync.jitter, this.#e = new $i(this.sync, {
|
|
4192
4366
|
broadcast: this.broadcast
|
|
4193
|
-
}), this.#t = new
|
|
4367
|
+
}), this.#t = new Hi(this.sync, {
|
|
4194
4368
|
broadcast: this.broadcast
|
|
4195
|
-
}), this.video = new
|
|
4369
|
+
}), this.video = new ji(this.#e), this.audio = new Zi(this.#t), this.paused = h.from(e?.paused ?? !1), this.signals.run(this.#n.bind(this));
|
|
4196
4370
|
}
|
|
4197
4371
|
#n(e) {
|
|
4198
4372
|
const n = e.get(this.element);
|
|
4199
4373
|
n && (n instanceof HTMLCanvasElement ? this.#s(e, n) : n instanceof HTMLVideoElement && this.#i(e, n));
|
|
4200
4374
|
}
|
|
4201
4375
|
#s(e, n) {
|
|
4202
|
-
const s = new
|
|
4376
|
+
const s = new Ri(this.#e), i = new Mi(this.#t), r = new Ti(i, {
|
|
4203
4377
|
volume: this.audio.volume,
|
|
4204
4378
|
muted: this.audio.muted,
|
|
4205
4379
|
paused: this.paused
|
|
4206
|
-
}), o = new
|
|
4380
|
+
}), o = new Li(s, { canvas: n, paused: this.paused });
|
|
4207
4381
|
e.cleanup(() => {
|
|
4208
4382
|
s.close(), i.close(), r.close(), o.close();
|
|
4209
4383
|
}), 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, i.stats), e.proxy(this.audio.buffered, i.buffered);
|
|
4210
4384
|
}
|
|
4211
4385
|
#i(e, n) {
|
|
4212
|
-
const s = new
|
|
4386
|
+
const s = new Nt(this.sync, {
|
|
4213
4387
|
paused: this.paused,
|
|
4214
4388
|
element: n
|
|
4215
|
-
}), i = new
|
|
4389
|
+
}), i = new Oi(s, this.#e), r = new Vi(s, this.#t, {
|
|
4216
4390
|
volume: this.audio.volume,
|
|
4217
4391
|
muted: this.audio.muted
|
|
4218
4392
|
});
|
|
@@ -4224,7 +4398,7 @@ class Li {
|
|
|
4224
4398
|
this.signals.close();
|
|
4225
4399
|
}
|
|
4226
4400
|
}
|
|
4227
|
-
class
|
|
4401
|
+
class Vi {
|
|
4228
4402
|
muxer;
|
|
4229
4403
|
source;
|
|
4230
4404
|
volume;
|
|
@@ -4233,9 +4407,9 @@ class _i {
|
|
|
4233
4407
|
stats = this.#e;
|
|
4234
4408
|
#t = new h([]);
|
|
4235
4409
|
buffered = this.#t;
|
|
4236
|
-
#n = new
|
|
4410
|
+
#n = new U();
|
|
4237
4411
|
constructor(e, n, s) {
|
|
4238
|
-
this.muxer = e, this.source = n, this.source.supported.set(
|
|
4412
|
+
this.muxer = e, this.source = n, this.source.supported.set(Wi), this.volume = h.from(s?.volume ?? 0.5), this.muted = h.from(s?.muted ?? !1), this.#n.run(this.#s.bind(this)), this.#n.run(this.#a.bind(this));
|
|
4239
4413
|
}
|
|
4240
4414
|
#s(e) {
|
|
4241
4415
|
const n = e.get(this.muxer.element);
|
|
@@ -4256,9 +4430,9 @@ class _i {
|
|
|
4256
4430
|
}), e.event(u, "error", (d) => {
|
|
4257
4431
|
console.error("[MSE] SourceBuffer error:", d);
|
|
4258
4432
|
}), e.event(u, "updateend", () => {
|
|
4259
|
-
this.#t.set(
|
|
4433
|
+
this.#t.set(Ft(u.buffered));
|
|
4260
4434
|
});
|
|
4261
|
-
const l = r.subscribe(o,
|
|
4435
|
+
const l = r.subscribe(o, ee.audio);
|
|
4262
4436
|
e.cleanup(() => l.close()), a.container.kind === "cmaf" ? this.#r(e, l, a, u, n) : this.#o(e, l, a, u, n);
|
|
4263
4437
|
}
|
|
4264
4438
|
async #i(e, n) {
|
|
@@ -4271,21 +4445,21 @@ class _i {
|
|
|
4271
4445
|
if (s.container.kind !== "cmaf") throw new Error("unreachable");
|
|
4272
4446
|
const o = s.container.timescale;
|
|
4273
4447
|
e.spawn(async () => {
|
|
4274
|
-
const a =
|
|
4448
|
+
const a = et(s);
|
|
4275
4449
|
for (await this.#i(i, a); ; ) {
|
|
4276
4450
|
const c = await n.readFrame();
|
|
4277
4451
|
if (!c) return;
|
|
4278
|
-
const u =
|
|
4279
|
-
this.source.sync.received(
|
|
4452
|
+
const u = Bt(c, o);
|
|
4453
|
+
this.source.sync.received(_.Time.Milli.fromMicro(u), "audio"), await this.#i(i, c), r.buffered.length > 0 && r.currentTime < r.buffered.start(0) && (r.currentTime = r.buffered.start(0));
|
|
4280
4454
|
}
|
|
4281
4455
|
});
|
|
4282
4456
|
}
|
|
4283
4457
|
#o(e, n, s, i, r) {
|
|
4284
|
-
const o = new
|
|
4458
|
+
const o = new ie(n, {
|
|
4285
4459
|
latency: this.source.sync.buffer
|
|
4286
4460
|
});
|
|
4287
4461
|
e.cleanup(() => o.close()), e.spawn(async () => {
|
|
4288
|
-
const a =
|
|
4462
|
+
const a = et(s);
|
|
4289
4463
|
await this.#i(i, a);
|
|
4290
4464
|
let c = 1, u, l;
|
|
4291
4465
|
for (; ; ) {
|
|
@@ -4293,7 +4467,7 @@ class _i {
|
|
|
4293
4467
|
if (!d) return;
|
|
4294
4468
|
if (!d.frame) continue;
|
|
4295
4469
|
l = d.frame;
|
|
4296
|
-
const f =
|
|
4470
|
+
const f = _.Time.Milli.fromMicro(l.timestamp);
|
|
4297
4471
|
this.source.sync.received(f, "audio");
|
|
4298
4472
|
break;
|
|
4299
4473
|
}
|
|
@@ -4302,11 +4476,11 @@ class _i {
|
|
|
4302
4476
|
if (d && !d.frame) continue;
|
|
4303
4477
|
const f = d?.frame;
|
|
4304
4478
|
if (f) {
|
|
4305
|
-
u =
|
|
4306
|
-
const y =
|
|
4479
|
+
u = _.Time.Micro.sub(f.timestamp, l.timestamp);
|
|
4480
|
+
const y = _.Time.Milli.fromMicro(f.timestamp);
|
|
4307
4481
|
this.source.sync.received(y, "audio");
|
|
4308
4482
|
}
|
|
4309
|
-
const g =
|
|
4483
|
+
const g = Lt({
|
|
4310
4484
|
data: l.data,
|
|
4311
4485
|
timestamp: l.timestamp,
|
|
4312
4486
|
duration: u ?? 0,
|
|
@@ -4331,11 +4505,11 @@ class _i {
|
|
|
4331
4505
|
this.#n.close();
|
|
4332
4506
|
}
|
|
4333
4507
|
}
|
|
4334
|
-
async function
|
|
4508
|
+
async function Wi(t) {
|
|
4335
4509
|
return MediaSource.isTypeSupported(`audio/mp4; codecs="${t.codec}"`);
|
|
4336
4510
|
}
|
|
4337
|
-
const
|
|
4338
|
-
class
|
|
4511
|
+
const qi = 128;
|
|
4512
|
+
class Hi {
|
|
4339
4513
|
broadcast;
|
|
4340
4514
|
target;
|
|
4341
4515
|
#e = new h(void 0);
|
|
@@ -4349,7 +4523,7 @@ class ki {
|
|
|
4349
4523
|
supported;
|
|
4350
4524
|
// Used to target a latency and synchronize playback of video with audio.
|
|
4351
4525
|
sync;
|
|
4352
|
-
#i = new
|
|
4526
|
+
#i = new U();
|
|
4353
4527
|
constructor(e, n) {
|
|
4354
4528
|
this.sync = e, this.broadcast = h.from(n?.broadcast), this.target = h.from(n?.target), this.supported = h.from(n?.supported), this.#i.run(this.#r.bind(this)), this.#i.run(this.#o.bind(this)), this.#i.run(this.#a.bind(this));
|
|
4355
4529
|
}
|
|
@@ -4377,7 +4551,7 @@ class ki {
|
|
|
4377
4551
|
i = { track: s.name, config: n[s.name] };
|
|
4378
4552
|
else if (i = this.#c(n), !i) return;
|
|
4379
4553
|
e.set(this.#n, i.track), e.set(this.#s, i.config);
|
|
4380
|
-
const r = i.config.jitter ??
|
|
4554
|
+
const r = i.config.jitter ?? Gi(i.config) ?? 0, o = Math.ceil(qi / i.config.sampleRate * 1e3), a = r + o;
|
|
4381
4555
|
e.set(this.sync.audio, a);
|
|
4382
4556
|
}
|
|
4383
4557
|
/**
|
|
@@ -4398,27 +4572,147 @@ class ki {
|
|
|
4398
4572
|
this.#i.close();
|
|
4399
4573
|
}
|
|
4400
4574
|
}
|
|
4401
|
-
function
|
|
4575
|
+
function Gi(t) {
|
|
4402
4576
|
if (t.codec.startsWith("opus"))
|
|
4403
4577
|
return 20;
|
|
4404
4578
|
if (t.codec.startsWith("mp4a"))
|
|
4405
4579
|
return Math.ceil(1024 / t.sampleRate * 1e3);
|
|
4406
4580
|
}
|
|
4407
|
-
|
|
4581
|
+
const Xi = /* @__PURE__ */ be([
|
|
4582
|
+
/* @__PURE__ */ St(["loc", "cmaf", "legacy", "mediatimeline", "eventtimeline"]),
|
|
4583
|
+
/* @__PURE__ */ b()
|
|
4584
|
+
]), Yi = /* @__PURE__ */ be([
|
|
4585
|
+
/* @__PURE__ */ St(["video", "audio", "audiodescription", "caption", "subtitle", "signlanguage"]),
|
|
4586
|
+
/* @__PURE__ */ b()
|
|
4587
|
+
]), Ki = /* @__PURE__ */ S({
|
|
4588
|
+
name: /* @__PURE__ */ b(),
|
|
4589
|
+
packaging: Xi,
|
|
4590
|
+
isLive: /* @__PURE__ */ Ee(),
|
|
4591
|
+
role: /* @__PURE__ */ m(Yi),
|
|
4592
|
+
codec: /* @__PURE__ */ m(/* @__PURE__ */ b()),
|
|
4593
|
+
width: /* @__PURE__ */ m(/* @__PURE__ */ T()),
|
|
4594
|
+
height: /* @__PURE__ */ m(/* @__PURE__ */ T()),
|
|
4595
|
+
framerate: /* @__PURE__ */ m(/* @__PURE__ */ T()),
|
|
4596
|
+
samplerate: /* @__PURE__ */ m(/* @__PURE__ */ T()),
|
|
4597
|
+
channelConfig: /* @__PURE__ */ m(/* @__PURE__ */ b()),
|
|
4598
|
+
bitrate: /* @__PURE__ */ m(/* @__PURE__ */ T()),
|
|
4599
|
+
initData: /* @__PURE__ */ m(/* @__PURE__ */ b()),
|
|
4600
|
+
renderGroup: /* @__PURE__ */ m(/* @__PURE__ */ T()),
|
|
4601
|
+
altGroup: /* @__PURE__ */ m(/* @__PURE__ */ T()),
|
|
4602
|
+
// Non-standard: maximum delay (ms) between consecutive frames on this track.
|
|
4603
|
+
// The player's buffer must be at least this large to avoid underruns.
|
|
4604
|
+
// Mirrors the `jitter` field in the hang catalog.
|
|
4605
|
+
jitter: /* @__PURE__ */ m(/* @__PURE__ */ T())
|
|
4606
|
+
}), Ji = /* @__PURE__ */ S({
|
|
4607
|
+
version: /* @__PURE__ */ Te(1),
|
|
4608
|
+
tracks: /* @__PURE__ */ G(Ki)
|
|
4609
|
+
});
|
|
4610
|
+
function Qi(t) {
|
|
4611
|
+
const n = new TextDecoder().decode(t);
|
|
4612
|
+
try {
|
|
4613
|
+
const s = JSON.parse(n);
|
|
4614
|
+
return Ji.parse(s);
|
|
4615
|
+
} catch (s) {
|
|
4616
|
+
throw console.warn("invalid MSF catalog", n), s;
|
|
4617
|
+
}
|
|
4618
|
+
}
|
|
4619
|
+
async function er(t) {
|
|
4620
|
+
const e = await t.readFrame();
|
|
4621
|
+
if (e)
|
|
4622
|
+
return Qi(e);
|
|
4623
|
+
}
|
|
4624
|
+
const tr = 48e3, it = 2;
|
|
4625
|
+
function nr(t) {
|
|
4626
|
+
try {
|
|
4627
|
+
const e = atob(t), n = new Uint8Array(e.length);
|
|
4628
|
+
for (let s = 0; s < e.length; s++) n[s] = e.charCodeAt(s);
|
|
4629
|
+
return n;
|
|
4630
|
+
} catch {
|
|
4631
|
+
return;
|
|
4632
|
+
}
|
|
4633
|
+
}
|
|
4634
|
+
function rt(t) {
|
|
4635
|
+
let e = "";
|
|
4636
|
+
for (let n = 0; n < t.length; n++) e += t[n].toString(16).padStart(2, "0");
|
|
4637
|
+
return e;
|
|
4638
|
+
}
|
|
4639
|
+
function $t(t) {
|
|
4640
|
+
const e = t.initData ? nr(t.initData) : void 0;
|
|
4641
|
+
if (t.packaging === "cmaf" && e)
|
|
4642
|
+
try {
|
|
4643
|
+
const n = ri(e);
|
|
4644
|
+
return {
|
|
4645
|
+
container: { kind: "cmaf", timescale: L(n.timescale), trackId: L(n.trackId) },
|
|
4646
|
+
description: n.description ? rt(n.description) : void 0
|
|
4647
|
+
};
|
|
4648
|
+
} catch (n) {
|
|
4649
|
+
console.warn("failed to parse MSF cmaf initData, falling back to legacy", n);
|
|
4650
|
+
}
|
|
4651
|
+
return {
|
|
4652
|
+
container: { kind: "legacy" },
|
|
4653
|
+
description: e ? rt(e) : void 0
|
|
4654
|
+
};
|
|
4655
|
+
}
|
|
4656
|
+
function sr(t) {
|
|
4657
|
+
if (!t.codec) return;
|
|
4658
|
+
const { container: e, description: n } = $t(t);
|
|
4659
|
+
return {
|
|
4660
|
+
codec: t.codec,
|
|
4661
|
+
container: e,
|
|
4662
|
+
description: n,
|
|
4663
|
+
codedWidth: t.width != null ? L(t.width) : void 0,
|
|
4664
|
+
codedHeight: t.height != null ? L(t.height) : void 0,
|
|
4665
|
+
framerate: t.framerate,
|
|
4666
|
+
bitrate: t.bitrate != null ? L(t.bitrate) : void 0,
|
|
4667
|
+
jitter: t.jitter != null ? L(t.jitter) : void 0
|
|
4668
|
+
};
|
|
4669
|
+
}
|
|
4670
|
+
function ir(t) {
|
|
4671
|
+
if (!t.codec) return;
|
|
4672
|
+
const e = (() => {
|
|
4673
|
+
if (!t.channelConfig) return it;
|
|
4674
|
+
const i = Number.parseInt(t.channelConfig, 10);
|
|
4675
|
+
return Number.isFinite(i) ? i : it;
|
|
4676
|
+
})(), { container: n, description: s } = $t(t);
|
|
4677
|
+
return {
|
|
4678
|
+
codec: t.codec,
|
|
4679
|
+
container: n,
|
|
4680
|
+
description: s,
|
|
4681
|
+
sampleRate: L(t.samplerate ?? tr),
|
|
4682
|
+
numberOfChannels: L(e),
|
|
4683
|
+
bitrate: t.bitrate != null ? L(t.bitrate) : void 0,
|
|
4684
|
+
jitter: t.jitter != null ? L(t.jitter) : void 0
|
|
4685
|
+
};
|
|
4686
|
+
}
|
|
4687
|
+
function rr(t) {
|
|
4688
|
+
const e = {}, n = {};
|
|
4689
|
+
for (const i of t.tracks)
|
|
4690
|
+
if (i.role === "video") {
|
|
4691
|
+
const r = sr(i);
|
|
4692
|
+
r && (e[i.name] = r);
|
|
4693
|
+
} else if (i.role === "audio") {
|
|
4694
|
+
const r = ir(i);
|
|
4695
|
+
r && (n[i.name] = r);
|
|
4696
|
+
}
|
|
4697
|
+
const s = {};
|
|
4698
|
+
return Object.keys(e).length > 0 && (s.video = { renditions: e }), Object.keys(n).length > 0 && (s.audio = { renditions: n }), s;
|
|
4699
|
+
}
|
|
4700
|
+
class mr {
|
|
4408
4701
|
connection;
|
|
4409
4702
|
enabled;
|
|
4410
4703
|
name;
|
|
4411
4704
|
status = new h("offline");
|
|
4412
4705
|
reload;
|
|
4706
|
+
catalogFormat;
|
|
4413
4707
|
#e = new h(void 0);
|
|
4414
4708
|
active = this.#e;
|
|
4415
4709
|
#t = new h(void 0);
|
|
4416
4710
|
catalog = this.#t;
|
|
4417
4711
|
// All actively announced broadcast paths from the connection.
|
|
4418
4712
|
#n;
|
|
4419
|
-
signals = new
|
|
4713
|
+
signals = new U();
|
|
4420
4714
|
constructor(e) {
|
|
4421
|
-
this.connection = h.from(e?.connection), this.name = h.from(e?.name ??
|
|
4715
|
+
this.connection = h.from(e?.connection), this.name = h.from(e?.name ?? Ht.empty()), this.enabled = h.from(e?.enabled ?? !1), this.reload = h.from(e?.reload ?? !1), this.catalogFormat = h.from(e?.catalogFormat ?? "hang"), this.#n = e?.announced ?? new h(/* @__PURE__ */ new Set()), this.signals.run(this.#i.bind(this)), this.signals.run(this.#r.bind(this));
|
|
4422
4716
|
}
|
|
4423
4717
|
#s(e) {
|
|
4424
4718
|
if (!e.get(this.reload)) return !0;
|
|
@@ -4435,18 +4729,23 @@ class Oi {
|
|
|
4435
4729
|
#r(e) {
|
|
4436
4730
|
const n = e.getAll([this.enabled, this.active]);
|
|
4437
4731
|
if (!n) return;
|
|
4438
|
-
const [s, i] = n;
|
|
4732
|
+
const [s, i] = n, r = e.get(this.catalogFormat);
|
|
4439
4733
|
this.status.set("loading");
|
|
4440
|
-
const
|
|
4441
|
-
e.cleanup(() =>
|
|
4734
|
+
const o = r === "hang" ? "catalog.json" : "catalog", a = i.subscribe(o, ee.catalog);
|
|
4735
|
+
e.cleanup(() => a.close());
|
|
4736
|
+
const c = r === "hang" ? async () => ms(a) : async () => {
|
|
4737
|
+
const u = await er(a);
|
|
4738
|
+
return u ? rr(u) : void 0;
|
|
4739
|
+
};
|
|
4740
|
+
e.spawn(async () => {
|
|
4442
4741
|
try {
|
|
4443
4742
|
for (; ; ) {
|
|
4444
|
-
const
|
|
4445
|
-
if (!
|
|
4446
|
-
console.debug("received catalog", this.name.peek(),
|
|
4743
|
+
const u = await Promise.race([e.cancel, c()]);
|
|
4744
|
+
if (!u) break;
|
|
4745
|
+
console.debug("received catalog", r, this.name.peek(), u), this.#t.set(u), this.status.set("live");
|
|
4447
4746
|
}
|
|
4448
|
-
} catch (
|
|
4449
|
-
console.warn("error fetching catalog", this.name.peek(),
|
|
4747
|
+
} catch (u) {
|
|
4748
|
+
console.warn("error fetching catalog", this.name.peek(), u);
|
|
4450
4749
|
} finally {
|
|
4451
4750
|
this.#t.set(void 0), this.status.set("offline");
|
|
4452
4751
|
}
|
|
@@ -4457,25 +4756,25 @@ class Oi {
|
|
|
4457
4756
|
}
|
|
4458
4757
|
}
|
|
4459
4758
|
export {
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4759
|
+
mr as B,
|
|
4760
|
+
Ri as D,
|
|
4761
|
+
Ti as E,
|
|
4762
|
+
Oi as M,
|
|
4763
|
+
ee as P,
|
|
4764
|
+
Li as R,
|
|
4765
|
+
$i as S,
|
|
4766
|
+
m as a,
|
|
4767
|
+
Ee as b,
|
|
4768
|
+
Mi as c,
|
|
4769
|
+
Vi as d,
|
|
4770
|
+
Hi as e,
|
|
4771
|
+
cr as f,
|
|
4772
|
+
zt as g,
|
|
4773
|
+
fr as h,
|
|
4774
|
+
Le as i,
|
|
4775
|
+
lr as m,
|
|
4776
|
+
S as o,
|
|
4777
|
+
b as s,
|
|
4778
|
+
Ft as t
|
|
4480
4779
|
};
|
|
4481
|
-
//# sourceMappingURL=broadcast-
|
|
4780
|
+
//# sourceMappingURL=broadcast-BImEYz4N.js.map
|