@moq/watch 0.2.11 → 0.2.12
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/README.md +7 -7
- package/audio/buffer.d.ts +1 -1
- package/audio/buffer.d.ts.map +1 -1
- package/audio/decoder.d.ts +1 -1
- package/audio/decoder.d.ts.map +1 -1
- package/audio/render.d.ts +1 -1
- package/audio/render.d.ts.map +1 -1
- package/audio/ring-buffer.d.ts +1 -1
- package/audio/ring-buffer.d.ts.map +1 -1
- package/audio/shared-ring-buffer.d.ts +1 -1
- package/audio/shared-ring-buffer.d.ts.map +1 -1
- package/audio/source.d.ts.map +1 -1
- package/backend.d.ts +1 -1
- package/backend.d.ts.map +1 -1
- package/{broadcast-b74Ew4Ql.js → broadcast-CLjMphZS.js} +1108 -1013
- package/broadcast-CLjMphZS.js.map +1 -0
- package/broadcast.d.ts +4 -3
- package/broadcast.d.ts.map +1 -1
- package/chat/index.d.ts +1 -1
- package/chat/index.d.ts.map +1 -1
- package/chat/message.d.ts +1 -1
- package/chat/message.d.ts.map +1 -1
- package/chat/typing.d.ts +1 -1
- package/chat/typing.d.ts.map +1 -1
- package/dom-BsFrLb_F.js +35 -0
- package/dom-BsFrLb_F.js.map +1 -0
- package/element.d.ts +4 -4
- package/element.d.ts.map +1 -1
- package/element.js +43 -32
- package/element.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +12 -11
- package/index.js.map +1 -1
- package/libav-opus-af-BlMWboA7.js.map +1 -1
- package/location/index.d.ts +1 -1
- package/location/index.d.ts.map +1 -1
- package/location/peers.d.ts +1 -1
- package/location/peers.d.ts.map +1 -1
- package/location/window.d.ts +1 -1
- package/location/window.d.ts.map +1 -1
- package/main-DGBFe0O7.js.map +1 -1
- package/package.json +7 -8
- package/preview.d.ts +1 -1
- package/preview.d.ts.map +1 -1
- package/support/element.js +49 -60
- package/support/element.js.map +1 -1
- package/sync.d.ts +2 -2
- package/sync.d.ts.map +1 -1
- package/ui/components/buffer-control.d.ts +5 -0
- package/ui/components/buffer-control.d.ts.map +1 -0
- package/ui/components/buffering-indicator.d.ts +4 -0
- package/ui/components/buffering-indicator.d.ts.map +1 -0
- package/ui/components/fullscreen-button.d.ts +4 -0
- package/ui/components/fullscreen-button.d.ts.map +1 -0
- package/ui/components/offline-indicator.d.ts +4 -0
- package/ui/components/offline-indicator.d.ts.map +1 -0
- package/ui/components/play-pause.d.ts +4 -0
- package/ui/components/play-pause.d.ts.map +1 -0
- package/ui/components/quality-selector.d.ts +4 -0
- package/ui/components/quality-selector.d.ts.map +1 -0
- package/ui/components/stats-button.d.ts +3 -0
- package/ui/components/stats-button.d.ts.map +1 -0
- package/ui/components/volume-slider.d.ts +4 -0
- package/ui/components/volume-slider.d.ts.map +1 -0
- package/ui/components/watch-status-indicator.d.ts +4 -0
- package/ui/components/watch-status-indicator.d.ts.map +1 -0
- package/ui/element.d.ts +11 -4
- package/ui/element.d.ts.map +1 -1
- package/ui/element.js +382 -0
- package/ui/element.js.map +1 -0
- package/ui/icons.d.ts +16 -0
- package/ui/icons.d.ts.map +1 -0
- package/ui/stats.d.ts +4 -0
- package/ui/stats.d.ts.map +1 -0
- package/video/backend.d.ts +1 -1
- package/video/backend.d.ts.map +1 -1
- package/video/decoder.d.ts +1 -1
- package/video/decoder.d.ts.map +1 -1
- package/video/mse.d.ts +1 -1
- package/video/mse.d.ts.map +1 -1
- package/video/renderer.d.ts +1 -1
- package/video/renderer.d.ts.map +1 -1
- package/video/source.d.ts +2 -0
- package/video/source.d.ts.map +1 -1
- package/broadcast-b74Ew4Ql.js.map +0 -1
- package/ui/components/BufferControl.d.ts +0 -8
- package/ui/components/BufferControl.d.ts.map +0 -1
- package/ui/components/BufferingIndicator.d.ts +0 -2
- package/ui/components/BufferingIndicator.d.ts.map +0 -1
- package/ui/components/FullscreenButton.d.ts +0 -2
- package/ui/components/FullscreenButton.d.ts.map +0 -1
- package/ui/components/PlayPauseButton.d.ts +0 -2
- package/ui/components/PlayPauseButton.d.ts.map +0 -1
- package/ui/components/QualitySelector.d.ts +0 -3
- package/ui/components/QualitySelector.d.ts.map +0 -1
- package/ui/components/StatsButton.d.ts +0 -5
- package/ui/components/StatsButton.d.ts.map +0 -1
- package/ui/components/VolumeSlider.d.ts +0 -2
- package/ui/components/VolumeSlider.d.ts.map +0 -1
- package/ui/components/WatchControls.d.ts +0 -2
- package/ui/components/WatchControls.d.ts.map +0 -1
- package/ui/components/WatchStatusIndicator.d.ts +0 -2
- package/ui/components/WatchStatusIndicator.d.ts.map +0 -1
- package/ui/context.d.ts +0 -44
- package/ui/context.d.ts.map +0 -1
- package/ui/hooks/use-watch-ui.d.ts +0 -3
- package/ui/hooks/use-watch-ui.d.ts.map +0 -1
- package/ui/index.d.ts +0 -7
- package/ui/index.d.ts.map +0 -1
- package/ui/index.js +0 -1065
- package/ui/index.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { Time as
|
|
1
|
+
import * as A from "@moq/net";
|
|
2
|
+
import { Time as g, Path as en } from "@moq/net";
|
|
3
3
|
import { Signal as h, Effect as E } from "@moq/signals";
|
|
4
|
-
function
|
|
4
|
+
function y(t, e, n) {
|
|
5
5
|
function s(c, a) {
|
|
6
6
|
if (c._zod || Object.defineProperty(c, "_zod", {
|
|
7
7
|
value: {
|
|
@@ -35,28 +35,28 @@ function g(t, e, n) {
|
|
|
35
35
|
value: (c) => n?.Parent && c instanceof n.Parent ? !0 : c?._zod?.traits?.has(t)
|
|
36
36
|
}), Object.defineProperty(o, "name", { value: t }), o;
|
|
37
37
|
}
|
|
38
|
-
class
|
|
38
|
+
class ee extends Error {
|
|
39
39
|
constructor() {
|
|
40
40
|
super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
class
|
|
43
|
+
class tn 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 nn = {};
|
|
49
|
+
function ie(t) {
|
|
50
|
+
return nn;
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function sn(t) {
|
|
53
53
|
const e = Object.values(t).filter((s) => typeof s == "number");
|
|
54
54
|
return Object.entries(t).filter(([s, i]) => e.indexOf(+s) === -1).map(([s, i]) => i);
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function rn(t, e) {
|
|
57
57
|
return typeof e == "bigint" ? e.toString() : e;
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function lt(t) {
|
|
60
60
|
return {
|
|
61
61
|
get value() {
|
|
62
62
|
{
|
|
@@ -66,17 +66,17 @@ function ct(t) {
|
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function dt(t) {
|
|
70
70
|
const e = t.startsWith("^") ? 1 : 0, n = t.endsWith("$") ? t.length - 1 : t.length;
|
|
71
71
|
return t.slice(e, n);
|
|
72
72
|
}
|
|
73
|
-
const
|
|
74
|
-
function
|
|
73
|
+
const Ze = /* @__PURE__ */ Symbol("evaluating");
|
|
74
|
+
function B(t, e, n) {
|
|
75
75
|
let s;
|
|
76
76
|
Object.defineProperty(t, e, {
|
|
77
77
|
get() {
|
|
78
|
-
if (s !==
|
|
79
|
-
return s === void 0 && (s =
|
|
78
|
+
if (s !== Ze)
|
|
79
|
+
return s === void 0 && (s = Ze, s = n()), s;
|
|
80
80
|
},
|
|
81
81
|
set(i) {
|
|
82
82
|
Object.defineProperty(t, e, {
|
|
@@ -87,45 +87,45 @@ function x(t, e, n) {
|
|
|
87
87
|
configurable: !0
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
|
-
const
|
|
90
|
+
const ht = "captureStackTrace" in Error ? Error.captureStackTrace : (...t) => {
|
|
91
91
|
};
|
|
92
|
-
function
|
|
92
|
+
function be(t) {
|
|
93
93
|
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
94
94
|
}
|
|
95
|
-
function
|
|
96
|
-
if (
|
|
95
|
+
function ft(t) {
|
|
96
|
+
if (be(t) === !1)
|
|
97
97
|
return !1;
|
|
98
98
|
const e = t.constructor;
|
|
99
99
|
if (e === void 0 || typeof e != "function")
|
|
100
100
|
return !0;
|
|
101
101
|
const n = e.prototype;
|
|
102
|
-
return !(
|
|
102
|
+
return !(be(n) === !1 || Object.prototype.hasOwnProperty.call(n, "isPrototypeOf") === !1);
|
|
103
103
|
}
|
|
104
|
-
function
|
|
105
|
-
return
|
|
104
|
+
function on(t) {
|
|
105
|
+
return ft(t) ? { ...t } : Array.isArray(t) ? [...t] : t;
|
|
106
106
|
}
|
|
107
|
-
const
|
|
108
|
-
function
|
|
107
|
+
const an = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
|
|
108
|
+
function Ce(t) {
|
|
109
109
|
return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
110
110
|
}
|
|
111
|
-
function
|
|
111
|
+
function cn(t, e, n) {
|
|
112
112
|
const s = new t._zod.constr(e ?? t._zod.def);
|
|
113
113
|
return (!e || n?.parent) && (s._zod.parent = t), s;
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function C(t) {
|
|
116
116
|
return {};
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function un(t) {
|
|
119
119
|
return Object.keys(t).filter((e) => t[e]._zod.optin === "optional" && t[e]._zod.optout === "optional");
|
|
120
120
|
}
|
|
121
|
-
const
|
|
121
|
+
const ln = {
|
|
122
122
|
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
123
123
|
int32: [-2147483648, 2147483647],
|
|
124
124
|
uint32: [0, 4294967295],
|
|
125
125
|
float32: [-34028234663852886e22, 34028234663852886e22],
|
|
126
126
|
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
127
127
|
};
|
|
128
|
-
function
|
|
128
|
+
function le(t, e = 0) {
|
|
129
129
|
if (t.aborted === !0)
|
|
130
130
|
return !0;
|
|
131
131
|
for (let n = e; n < t.issues.length; n++)
|
|
@@ -133,79 +133,79 @@ function ce(t, e = 0) {
|
|
|
133
133
|
return !0;
|
|
134
134
|
return !1;
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function Q(t, e) {
|
|
137
137
|
return e.map((n) => {
|
|
138
138
|
var s;
|
|
139
139
|
return (s = n).path ?? (s.path = []), n.path.unshift(t), n;
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function ge(t) {
|
|
143
143
|
return typeof t == "string" ? t : t?.message;
|
|
144
144
|
}
|
|
145
|
-
function
|
|
145
|
+
function re(t, e, n) {
|
|
146
146
|
const s = { ...t, path: t.path ?? [] };
|
|
147
147
|
if (!t.message) {
|
|
148
|
-
const i =
|
|
148
|
+
const i = ge(t.inst?._zod.def?.error?.(t)) ?? ge(e?.error?.(t)) ?? ge(n.customError?.(t)) ?? ge(n.localeError?.(t)) ?? "Invalid input";
|
|
149
149
|
s.message = i;
|
|
150
150
|
}
|
|
151
151
|
return delete s.inst, delete s.continue, e?.reportInput || delete s.input, s;
|
|
152
152
|
}
|
|
153
|
-
const
|
|
153
|
+
const mt = (t, e) => {
|
|
154
154
|
t.name = "$ZodError", Object.defineProperty(t, "_zod", {
|
|
155
155
|
value: t._zod,
|
|
156
156
|
enumerable: !1
|
|
157
157
|
}), Object.defineProperty(t, "issues", {
|
|
158
158
|
value: e,
|
|
159
159
|
enumerable: !1
|
|
160
|
-
}), t.message = JSON.stringify(e,
|
|
160
|
+
}), t.message = JSON.stringify(e, rn, 2), Object.defineProperty(t, "toString", {
|
|
161
161
|
value: () => t.message,
|
|
162
162
|
enumerable: !1
|
|
163
163
|
});
|
|
164
|
-
},
|
|
164
|
+
}, dn = y("$ZodError", mt), _e = y("$ZodError", mt, { Parent: Error }), hn = (t) => (e, n, s, i) => {
|
|
165
165
|
const r = s ? Object.assign(s, { async: !1 }) : { async: !1 }, o = e._zod.run({ value: n, issues: [] }, r);
|
|
166
166
|
if (o instanceof Promise)
|
|
167
|
-
throw new
|
|
167
|
+
throw new ee();
|
|
168
168
|
if (o.issues.length) {
|
|
169
|
-
const c = new (i?.Err ?? t)(o.issues.map((a) =>
|
|
170
|
-
throw
|
|
169
|
+
const c = new (i?.Err ?? t)(o.issues.map((a) => re(a, r, ie())));
|
|
170
|
+
throw ht(c, i?.callee), c;
|
|
171
171
|
}
|
|
172
172
|
return o.value;
|
|
173
|
-
},
|
|
173
|
+
}, fn = /* @__PURE__ */ hn(_e), mn = (t) => async (e, n, s, i) => {
|
|
174
174
|
const r = s ? Object.assign(s, { async: !0 }) : { async: !0 };
|
|
175
175
|
let o = e._zod.run({ value: n, issues: [] }, r);
|
|
176
176
|
if (o instanceof Promise && (o = await o), o.issues.length) {
|
|
177
|
-
const c = new (i?.Err ?? t)(o.issues.map((a) =>
|
|
178
|
-
throw
|
|
177
|
+
const c = new (i?.Err ?? t)(o.issues.map((a) => re(a, r, ie())));
|
|
178
|
+
throw ht(c, i?.callee), c;
|
|
179
179
|
}
|
|
180
180
|
return o.value;
|
|
181
|
-
},
|
|
181
|
+
}, pn = /* @__PURE__ */ mn(_e), gn = (t) => (e, n, s) => {
|
|
182
182
|
const i = s ? { ...s, async: !1 } : { async: !1 }, r = e._zod.run({ value: n, issues: [] }, i);
|
|
183
183
|
if (r instanceof Promise)
|
|
184
|
-
throw new
|
|
184
|
+
throw new ee();
|
|
185
185
|
return r.issues.length ? {
|
|
186
186
|
success: !1,
|
|
187
|
-
error: new (t ??
|
|
187
|
+
error: new (t ?? dn)(r.issues.map((o) => re(o, i, ie())))
|
|
188
188
|
} : { success: !0, data: r.value };
|
|
189
|
-
},
|
|
189
|
+
}, pt = /* @__PURE__ */ gn(_e), wn = (t) => async (e, n, s) => {
|
|
190
190
|
const i = s ? Object.assign(s, { async: !0 }) : { async: !0 };
|
|
191
191
|
let r = e._zod.run({ value: n, issues: [] }, i);
|
|
192
192
|
return r instanceof Promise && (r = await r), r.issues.length ? {
|
|
193
193
|
success: !1,
|
|
194
|
-
error: new t(r.issues.map((o) =>
|
|
194
|
+
error: new t(r.issues.map((o) => re(o, i, ie())))
|
|
195
195
|
} : { success: !0, data: r.value };
|
|
196
|
-
},
|
|
196
|
+
}, gt = /* @__PURE__ */ wn(_e), yn = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/, bn = (t) => {
|
|
197
197
|
const e = t ? `[\\s\\S]{${t?.minimum ?? 0},${t?.maximum ?? ""}}` : "[\\s\\S]*";
|
|
198
198
|
return new RegExp(`^${e}$`);
|
|
199
|
-
},
|
|
199
|
+
}, vn = /^-?\d+$/, wt = /^-?\d+(?:\.\d+)?$/, Sn = /^(?:true|false)$/i, ze = /* @__PURE__ */ y("$ZodCheck", (t, e) => {
|
|
200
200
|
var n;
|
|
201
201
|
t._zod ?? (t._zod = {}), t._zod.def = e, (n = t._zod).onattach ?? (n.onattach = []);
|
|
202
|
-
}),
|
|
202
|
+
}), yt = {
|
|
203
203
|
number: "number",
|
|
204
204
|
bigint: "bigint",
|
|
205
205
|
object: "date"
|
|
206
|
-
},
|
|
207
|
-
|
|
208
|
-
const n =
|
|
206
|
+
}, An = /* @__PURE__ */ y("$ZodCheckLessThan", (t, e) => {
|
|
207
|
+
ze.init(t, e);
|
|
208
|
+
const n = yt[typeof e.value];
|
|
209
209
|
t._zod.onattach.push((s) => {
|
|
210
210
|
const i = s._zod.bag, r = (e.inclusive ? i.maximum : i.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
211
211
|
e.value < r && (e.inclusive ? i.maximum = e.value : i.exclusiveMaximum = e.value);
|
|
@@ -220,9 +220,9 @@ const ht = (t, e) => {
|
|
|
220
220
|
continue: !e.abort
|
|
221
221
|
});
|
|
222
222
|
};
|
|
223
|
-
}),
|
|
224
|
-
|
|
225
|
-
const n =
|
|
223
|
+
}), _n = /* @__PURE__ */ y("$ZodCheckGreaterThan", (t, e) => {
|
|
224
|
+
ze.init(t, e);
|
|
225
|
+
const n = yt[typeof e.value];
|
|
226
226
|
t._zod.onattach.push((s) => {
|
|
227
227
|
const i = s._zod.bag, r = (e.inclusive ? i.minimum : i.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
228
228
|
e.value > r && (e.inclusive ? i.minimum = e.value : i.exclusiveMinimum = e.value);
|
|
@@ -237,12 +237,12 @@ const ht = (t, e) => {
|
|
|
237
237
|
continue: !e.abort
|
|
238
238
|
});
|
|
239
239
|
};
|
|
240
|
-
}),
|
|
241
|
-
|
|
242
|
-
const n = e.format?.includes("int"), s = n ? "int" : "number", [i, r] =
|
|
240
|
+
}), zn = /* @__PURE__ */ y("$ZodCheckNumberFormat", (t, e) => {
|
|
241
|
+
ze.init(t, e), e.format = e.format || "float64";
|
|
242
|
+
const n = e.format?.includes("int"), s = n ? "int" : "number", [i, r] = ln[e.format];
|
|
243
243
|
t._zod.onattach.push((o) => {
|
|
244
244
|
const c = o._zod.bag;
|
|
245
|
-
c.format = e.format, c.minimum = i, c.maximum = r, n && (c.pattern =
|
|
245
|
+
c.format = e.format, c.minimum = i, c.maximum = r, n && (c.pattern = vn);
|
|
246
246
|
}), t._zod.check = (o) => {
|
|
247
247
|
const c = o.value;
|
|
248
248
|
if (n) {
|
|
@@ -298,9 +298,9 @@ const ht = (t, e) => {
|
|
|
298
298
|
continue: !e.abort
|
|
299
299
|
});
|
|
300
300
|
};
|
|
301
|
-
}),
|
|
301
|
+
}), Mn = /* @__PURE__ */ y("$ZodCheckStringFormat", (t, e) => {
|
|
302
302
|
var n, s;
|
|
303
|
-
|
|
303
|
+
ze.init(t, e), t._zod.onattach.push((i) => {
|
|
304
304
|
const r = i._zod.bag;
|
|
305
305
|
r.format = e.format, e.pattern && (r.patterns ?? (r.patterns = /* @__PURE__ */ new Set()), r.patterns.add(e.pattern));
|
|
306
306
|
}), e.pattern ? (n = t._zod).check ?? (n.check = (i) => {
|
|
@@ -315,13 +315,13 @@ const ht = (t, e) => {
|
|
|
315
315
|
});
|
|
316
316
|
}) : (s = t._zod).check ?? (s.check = () => {
|
|
317
317
|
});
|
|
318
|
-
}),
|
|
318
|
+
}), kn = {
|
|
319
319
|
major: 4,
|
|
320
320
|
minor: 3,
|
|
321
321
|
patch: 6
|
|
322
|
-
},
|
|
322
|
+
}, I = /* @__PURE__ */ y("$ZodType", (t, e) => {
|
|
323
323
|
var n;
|
|
324
|
-
t ?? (t = {}), t._zod.def = e, t._zod.bag = t._zod.bag || {}, t._zod.version =
|
|
324
|
+
t ?? (t = {}), t._zod.def = e, t._zod.bag = t._zod.bag || {}, t._zod.version = kn;
|
|
325
325
|
const s = [...t._zod.def.checks ?? []];
|
|
326
326
|
t._zod.traits.has("$ZodCheck") && s.unshift(t);
|
|
327
327
|
for (const i of s)
|
|
@@ -333,34 +333,34 @@ const ht = (t, e) => {
|
|
|
333
333
|
});
|
|
334
334
|
else {
|
|
335
335
|
const i = (o, c, a) => {
|
|
336
|
-
let u =
|
|
336
|
+
let u = le(o), l;
|
|
337
337
|
for (const d of c) {
|
|
338
338
|
if (d._zod.def.when) {
|
|
339
339
|
if (!d._zod.def.when(o))
|
|
340
340
|
continue;
|
|
341
341
|
} else if (u)
|
|
342
342
|
continue;
|
|
343
|
-
const f = o.issues.length,
|
|
344
|
-
if (
|
|
345
|
-
throw new
|
|
346
|
-
if (l ||
|
|
343
|
+
const f = o.issues.length, p = d._zod.check(o);
|
|
344
|
+
if (p instanceof Promise && a?.async === !1)
|
|
345
|
+
throw new ee();
|
|
346
|
+
if (l || p instanceof Promise)
|
|
347
347
|
l = (l ?? Promise.resolve()).then(async () => {
|
|
348
|
-
await
|
|
348
|
+
await p, o.issues.length !== f && (u || (u = le(o, f)));
|
|
349
349
|
});
|
|
350
350
|
else {
|
|
351
351
|
if (o.issues.length === f)
|
|
352
352
|
continue;
|
|
353
|
-
u || (u =
|
|
353
|
+
u || (u = le(o, f));
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
356
|
return l ? l.then(() => o) : o;
|
|
357
357
|
}, r = (o, c, a) => {
|
|
358
|
-
if (
|
|
358
|
+
if (le(o))
|
|
359
359
|
return o.aborted = !0, o;
|
|
360
360
|
const u = i(c, s, a);
|
|
361
361
|
if (u instanceof Promise) {
|
|
362
362
|
if (a.async === !1)
|
|
363
|
-
throw new
|
|
363
|
+
throw new ee();
|
|
364
364
|
return u.then((l) => t._zod.parse(l, a));
|
|
365
365
|
}
|
|
366
366
|
return t._zod.parse(u, a);
|
|
@@ -375,26 +375,26 @@ const ht = (t, e) => {
|
|
|
375
375
|
const a = t._zod.parse(o, c);
|
|
376
376
|
if (a instanceof Promise) {
|
|
377
377
|
if (c.async === !1)
|
|
378
|
-
throw new
|
|
378
|
+
throw new ee();
|
|
379
379
|
return a.then((u) => i(u, s, c));
|
|
380
380
|
}
|
|
381
381
|
return i(a, s, c);
|
|
382
382
|
};
|
|
383
383
|
}
|
|
384
|
-
|
|
384
|
+
B(t, "~standard", () => ({
|
|
385
385
|
validate: (i) => {
|
|
386
386
|
try {
|
|
387
|
-
const r =
|
|
387
|
+
const r = pt(t, i);
|
|
388
388
|
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
389
389
|
} catch {
|
|
390
|
-
return
|
|
390
|
+
return gt(t, i).then((o) => o.success ? { value: o.data } : { issues: o.error?.issues });
|
|
391
391
|
}
|
|
392
392
|
},
|
|
393
393
|
vendor: "zod",
|
|
394
394
|
version: 1
|
|
395
395
|
}));
|
|
396
|
-
}),
|
|
397
|
-
|
|
396
|
+
}), bt = /* @__PURE__ */ y("$ZodString", (t, e) => {
|
|
397
|
+
I.init(t, e), t._zod.pattern = [...t?._zod.bag?.patterns ?? []].pop() ?? bn(t._zod.bag), t._zod.parse = (n, s) => {
|
|
398
398
|
if (e.coerce)
|
|
399
399
|
try {
|
|
400
400
|
n.value = String(n.value);
|
|
@@ -407,10 +407,10 @@ const ht = (t, e) => {
|
|
|
407
407
|
inst: t
|
|
408
408
|
}), n;
|
|
409
409
|
};
|
|
410
|
-
}),
|
|
411
|
-
|
|
410
|
+
}), vt = /* @__PURE__ */ y("$ZodStringFormat", (t, e) => {
|
|
411
|
+
Mn.init(t, e), bt.init(t, e);
|
|
412
412
|
});
|
|
413
|
-
function
|
|
413
|
+
function Tn(t) {
|
|
414
414
|
if (t === "")
|
|
415
415
|
return !0;
|
|
416
416
|
if (t.length % 4 !== 0)
|
|
@@ -421,9 +421,9 @@ function zn(t) {
|
|
|
421
421
|
return !1;
|
|
422
422
|
}
|
|
423
423
|
}
|
|
424
|
-
const
|
|
425
|
-
e.pattern ?? (e.pattern =
|
|
426
|
-
|
|
424
|
+
const Un = /* @__PURE__ */ y("$ZodBase64", (t, e) => {
|
|
425
|
+
e.pattern ?? (e.pattern = yn), vt.init(t, e), t._zod.bag.contentEncoding = "base64", t._zod.check = (n) => {
|
|
426
|
+
Tn(n.value) || n.issues.push({
|
|
427
427
|
code: "invalid_format",
|
|
428
428
|
format: "base64",
|
|
429
429
|
input: n.value,
|
|
@@ -431,8 +431,8 @@ const Mn = /* @__PURE__ */ g("$ZodBase64", (t, e) => {
|
|
|
431
431
|
continue: !e.abort
|
|
432
432
|
});
|
|
433
433
|
};
|
|
434
|
-
}),
|
|
435
|
-
|
|
434
|
+
}), St = /* @__PURE__ */ y("$ZodNumber", (t, e) => {
|
|
435
|
+
I.init(t, e), t._zod.pattern = t._zod.bag.pattern ?? wt, t._zod.parse = (n, s) => {
|
|
436
436
|
if (e.coerce)
|
|
437
437
|
try {
|
|
438
438
|
n.value = Number(n.value);
|
|
@@ -450,10 +450,10 @@ const Mn = /* @__PURE__ */ g("$ZodBase64", (t, e) => {
|
|
|
450
450
|
...r ? { received: r } : {}
|
|
451
451
|
}), n;
|
|
452
452
|
};
|
|
453
|
-
}),
|
|
454
|
-
|
|
455
|
-
}),
|
|
456
|
-
|
|
453
|
+
}), En = /* @__PURE__ */ y("$ZodNumberFormat", (t, e) => {
|
|
454
|
+
zn.init(t, e), St.init(t, e);
|
|
455
|
+
}), xn = /* @__PURE__ */ y("$ZodBoolean", (t, e) => {
|
|
456
|
+
I.init(t, e), t._zod.pattern = Sn, t._zod.parse = (n, s) => {
|
|
457
457
|
if (e.coerce)
|
|
458
458
|
try {
|
|
459
459
|
n.value = !!n.value;
|
|
@@ -468,11 +468,11 @@ const Mn = /* @__PURE__ */ g("$ZodBase64", (t, e) => {
|
|
|
468
468
|
}), n;
|
|
469
469
|
};
|
|
470
470
|
});
|
|
471
|
-
function
|
|
472
|
-
t.issues.length && e.issues.push(...
|
|
471
|
+
function Ve(t, e, n) {
|
|
472
|
+
t.issues.length && e.issues.push(...Q(n, t.issues)), e.value[n] = t.value;
|
|
473
473
|
}
|
|
474
|
-
const
|
|
475
|
-
|
|
474
|
+
const Bn = /* @__PURE__ */ y("$ZodArray", (t, e) => {
|
|
475
|
+
I.init(t, e), t._zod.parse = (n, s) => {
|
|
476
476
|
const i = n.value;
|
|
477
477
|
if (!Array.isArray(i))
|
|
478
478
|
return n.issues.push({
|
|
@@ -488,25 +488,25 @@ const Un = /* @__PURE__ */ g("$ZodArray", (t, e) => {
|
|
|
488
488
|
value: c,
|
|
489
489
|
issues: []
|
|
490
490
|
}, s);
|
|
491
|
-
a instanceof Promise ? r.push(a.then((u) =>
|
|
491
|
+
a instanceof Promise ? r.push(a.then((u) => Ve(u, n, o))) : Ve(a, n, o);
|
|
492
492
|
}
|
|
493
493
|
return r.length ? Promise.all(r).then(() => n) : n;
|
|
494
494
|
};
|
|
495
495
|
});
|
|
496
|
-
function
|
|
496
|
+
function ve(t, e, n, s, i) {
|
|
497
497
|
if (t.issues.length) {
|
|
498
498
|
if (i && !(n in s))
|
|
499
499
|
return;
|
|
500
|
-
e.issues.push(...
|
|
500
|
+
e.issues.push(...Q(n, t.issues));
|
|
501
501
|
}
|
|
502
502
|
t.value === void 0 ? n in s && (e.value[n] = void 0) : e.value[n] = t.value;
|
|
503
503
|
}
|
|
504
|
-
function
|
|
504
|
+
function Rn(t) {
|
|
505
505
|
const e = Object.keys(t.shape);
|
|
506
506
|
for (const s of e)
|
|
507
507
|
if (!t.shape?.[s]?._zod?.traits?.has("$ZodType"))
|
|
508
508
|
throw new Error(`Invalid element at key "${s}": expected a Zod schema`);
|
|
509
|
-
const n =
|
|
509
|
+
const n = un(t.shape);
|
|
510
510
|
return {
|
|
511
511
|
...t,
|
|
512
512
|
keys: e,
|
|
@@ -515,7 +515,7 @@ function En(t) {
|
|
|
515
515
|
optionalKeys: new Set(n)
|
|
516
516
|
};
|
|
517
517
|
}
|
|
518
|
-
function
|
|
518
|
+
function Cn(t, e, n, s, i, r) {
|
|
519
519
|
const o = [], c = i.keySet, a = i.catchall._zod, u = a.def.type, l = a.optout === "optional";
|
|
520
520
|
for (const d in e) {
|
|
521
521
|
if (c.has(d))
|
|
@@ -525,7 +525,7 @@ function xn(t, e, n, s, i, r) {
|
|
|
525
525
|
continue;
|
|
526
526
|
}
|
|
527
527
|
const f = a.run({ value: e[d], issues: [] }, s);
|
|
528
|
-
f instanceof Promise ? t.push(f.then((
|
|
528
|
+
f instanceof Promise ? t.push(f.then((p) => ve(p, n, d, e, l))) : ve(f, n, d, e, l);
|
|
529
529
|
}
|
|
530
530
|
return o.length && n.issues.push({
|
|
531
531
|
code: "unrecognized_keys",
|
|
@@ -534,8 +534,8 @@ function xn(t, e, n, s, i, r) {
|
|
|
534
534
|
inst: r
|
|
535
535
|
}), t.length ? Promise.all(t).then(() => n) : n;
|
|
536
536
|
}
|
|
537
|
-
const
|
|
538
|
-
if (
|
|
537
|
+
const In = /* @__PURE__ */ y("$ZodObject", (t, e) => {
|
|
538
|
+
if (I.init(t, e), !Object.getOwnPropertyDescriptor(e, "shape")?.get) {
|
|
539
539
|
const c = e.shape;
|
|
540
540
|
Object.defineProperty(e, "shape", {
|
|
541
541
|
get: () => {
|
|
@@ -546,8 +546,8 @@ const Bn = /* @__PURE__ */ g("$ZodObject", (t, e) => {
|
|
|
546
546
|
}
|
|
547
547
|
});
|
|
548
548
|
}
|
|
549
|
-
const s =
|
|
550
|
-
|
|
549
|
+
const s = lt(() => Rn(e));
|
|
550
|
+
B(t._zod, "propValues", () => {
|
|
551
551
|
const c = e.shape, a = {};
|
|
552
552
|
for (const u in c) {
|
|
553
553
|
const l = c[u]._zod;
|
|
@@ -559,7 +559,7 @@ const Bn = /* @__PURE__ */ g("$ZodObject", (t, e) => {
|
|
|
559
559
|
}
|
|
560
560
|
return a;
|
|
561
561
|
});
|
|
562
|
-
const i =
|
|
562
|
+
const i = be, r = e.catchall;
|
|
563
563
|
let o;
|
|
564
564
|
t._zod.parse = (c, a) => {
|
|
565
565
|
o ?? (o = s.value);
|
|
@@ -574,32 +574,32 @@ const Bn = /* @__PURE__ */ g("$ZodObject", (t, e) => {
|
|
|
574
574
|
c.value = {};
|
|
575
575
|
const l = [], d = o.shape;
|
|
576
576
|
for (const f of o.keys) {
|
|
577
|
-
const
|
|
578
|
-
|
|
577
|
+
const p = d[f], b = p._zod.optout === "optional", w = p._zod.run({ value: u[f], issues: [] }, a);
|
|
578
|
+
w instanceof Promise ? l.push(w.then((v) => ve(v, c, f, u, b))) : ve(w, c, f, u, b);
|
|
579
579
|
}
|
|
580
|
-
return r ?
|
|
580
|
+
return r ? Cn(l, u, c, a, s.value, t) : l.length ? Promise.all(l).then(() => c) : c;
|
|
581
581
|
};
|
|
582
582
|
});
|
|
583
|
-
function
|
|
583
|
+
function We(t, e, n, s) {
|
|
584
584
|
for (const r of t)
|
|
585
585
|
if (r.issues.length === 0)
|
|
586
586
|
return e.value = r.value, e;
|
|
587
|
-
const i = t.filter((r) => !
|
|
587
|
+
const i = t.filter((r) => !le(r));
|
|
588
588
|
return i.length === 1 ? (e.value = i[0].value, i[0]) : (e.issues.push({
|
|
589
589
|
code: "invalid_union",
|
|
590
590
|
input: e.value,
|
|
591
591
|
inst: n,
|
|
592
|
-
errors: t.map((r) => r.issues.map((o) =>
|
|
592
|
+
errors: t.map((r) => r.issues.map((o) => re(o, s, ie())))
|
|
593
593
|
}), e);
|
|
594
594
|
}
|
|
595
|
-
const
|
|
596
|
-
|
|
595
|
+
const At = /* @__PURE__ */ y("$ZodUnion", (t, e) => {
|
|
596
|
+
I.init(t, e), B(t._zod, "optin", () => e.options.some((i) => i._zod.optin === "optional") ? "optional" : void 0), B(t._zod, "optout", () => e.options.some((i) => i._zod.optout === "optional") ? "optional" : void 0), B(t._zod, "values", () => {
|
|
597
597
|
if (e.options.every((i) => i._zod.values))
|
|
598
598
|
return new Set(e.options.flatMap((i) => Array.from(i._zod.values)));
|
|
599
|
-
}),
|
|
599
|
+
}), B(t._zod, "pattern", () => {
|
|
600
600
|
if (e.options.every((i) => i._zod.pattern)) {
|
|
601
601
|
const i = e.options.map((r) => r._zod.pattern);
|
|
602
|
-
return new RegExp(`^(${i.map((r) =>
|
|
602
|
+
return new RegExp(`^(${i.map((r) => dt(r.source)).join("|")})$`);
|
|
603
603
|
}
|
|
604
604
|
});
|
|
605
605
|
const n = e.options.length === 1, s = e.options[0]._zod.run;
|
|
@@ -621,12 +621,12 @@ const vt = /* @__PURE__ */ g("$ZodUnion", (t, e) => {
|
|
|
621
621
|
c.push(u);
|
|
622
622
|
}
|
|
623
623
|
}
|
|
624
|
-
return o ? Promise.all(c).then((a) =>
|
|
624
|
+
return o ? Promise.all(c).then((a) => We(a, i, t, r)) : We(c, i, t, r);
|
|
625
625
|
};
|
|
626
|
-
}),
|
|
627
|
-
e.inclusive = !1,
|
|
626
|
+
}), Dn = /* @__PURE__ */ y("$ZodDiscriminatedUnion", (t, e) => {
|
|
627
|
+
e.inclusive = !1, At.init(t, e);
|
|
628
628
|
const n = t._zod.parse;
|
|
629
|
-
|
|
629
|
+
B(t._zod, "propValues", () => {
|
|
630
630
|
const i = {};
|
|
631
631
|
for (const r of e.options) {
|
|
632
632
|
const o = r._zod.propValues;
|
|
@@ -640,7 +640,7 @@ const vt = /* @__PURE__ */ g("$ZodUnion", (t, e) => {
|
|
|
640
640
|
}
|
|
641
641
|
return i;
|
|
642
642
|
});
|
|
643
|
-
const s =
|
|
643
|
+
const s = lt(() => {
|
|
644
644
|
const i = e.options, r = /* @__PURE__ */ new Map();
|
|
645
645
|
for (const o of i) {
|
|
646
646
|
const c = o._zod.propValues?.[e.discriminator];
|
|
@@ -656,7 +656,7 @@ const vt = /* @__PURE__ */ g("$ZodUnion", (t, e) => {
|
|
|
656
656
|
});
|
|
657
657
|
t._zod.parse = (i, r) => {
|
|
658
658
|
const o = i.value;
|
|
659
|
-
if (!
|
|
659
|
+
if (!be(o))
|
|
660
660
|
return i.issues.push({
|
|
661
661
|
code: "invalid_type",
|
|
662
662
|
expected: "object",
|
|
@@ -674,10 +674,10 @@ const vt = /* @__PURE__ */ g("$ZodUnion", (t, e) => {
|
|
|
674
674
|
inst: t
|
|
675
675
|
}), i);
|
|
676
676
|
};
|
|
677
|
-
}),
|
|
678
|
-
|
|
677
|
+
}), On = /* @__PURE__ */ y("$ZodRecord", (t, e) => {
|
|
678
|
+
I.init(t, e), t._zod.parse = (n, s) => {
|
|
679
679
|
const i = n.value;
|
|
680
|
-
if (!
|
|
680
|
+
if (!ft(i))
|
|
681
681
|
return n.issues.push({
|
|
682
682
|
expected: "record",
|
|
683
683
|
code: "invalid_type",
|
|
@@ -693,8 +693,8 @@ const vt = /* @__PURE__ */ g("$ZodUnion", (t, e) => {
|
|
|
693
693
|
c.add(typeof u == "number" ? u.toString() : u);
|
|
694
694
|
const l = e.valueType._zod.run({ value: i[u], issues: [] }, s);
|
|
695
695
|
l instanceof Promise ? r.push(l.then((d) => {
|
|
696
|
-
d.issues.length && n.issues.push(...
|
|
697
|
-
})) : (l.issues.length && n.issues.push(...
|
|
696
|
+
d.issues.length && n.issues.push(...Q(u, d.issues)), n.value[u] = d.value;
|
|
697
|
+
})) : (l.issues.length && n.issues.push(...Q(u, l.issues)), n.value[u] = l.value);
|
|
698
698
|
}
|
|
699
699
|
let a;
|
|
700
700
|
for (const u in i)
|
|
@@ -713,7 +713,7 @@ const vt = /* @__PURE__ */ g("$ZodUnion", (t, e) => {
|
|
|
713
713
|
let a = e.keyType._zod.run({ value: c, issues: [] }, s);
|
|
714
714
|
if (a instanceof Promise)
|
|
715
715
|
throw new Error("Async schemas not supported in object keys currently");
|
|
716
|
-
if (typeof c == "string" &&
|
|
716
|
+
if (typeof c == "string" && wt.test(c) && a.issues.length) {
|
|
717
717
|
const d = e.keyType._zod.run({ value: Number(c), issues: [] }, s);
|
|
718
718
|
if (d instanceof Promise)
|
|
719
719
|
throw new Error("Async schemas not supported in object keys currently");
|
|
@@ -723,7 +723,7 @@ const vt = /* @__PURE__ */ g("$ZodUnion", (t, e) => {
|
|
|
723
723
|
e.mode === "loose" ? n.value[c] = i[c] : n.issues.push({
|
|
724
724
|
code: "invalid_key",
|
|
725
725
|
origin: "record",
|
|
726
|
-
issues: a.issues.map((d) =>
|
|
726
|
+
issues: a.issues.map((d) => re(d, s, ie())),
|
|
727
727
|
input: c,
|
|
728
728
|
path: [c],
|
|
729
729
|
inst: t
|
|
@@ -732,16 +732,16 @@ const vt = /* @__PURE__ */ g("$ZodUnion", (t, e) => {
|
|
|
732
732
|
}
|
|
733
733
|
const l = e.valueType._zod.run({ value: i[c], issues: [] }, s);
|
|
734
734
|
l instanceof Promise ? r.push(l.then((d) => {
|
|
735
|
-
d.issues.length && n.issues.push(...
|
|
736
|
-
})) : (l.issues.length && n.issues.push(...
|
|
735
|
+
d.issues.length && n.issues.push(...Q(c, d.issues)), n.value[a.value] = d.value;
|
|
736
|
+
})) : (l.issues.length && n.issues.push(...Q(c, l.issues)), n.value[a.value] = l.value);
|
|
737
737
|
}
|
|
738
738
|
}
|
|
739
739
|
return r.length ? Promise.all(r).then(() => n) : n;
|
|
740
740
|
};
|
|
741
|
-
}),
|
|
742
|
-
|
|
743
|
-
const n =
|
|
744
|
-
t._zod.values = s, t._zod.pattern = new RegExp(`^(${n.filter((i) =>
|
|
741
|
+
}), Ln = /* @__PURE__ */ y("$ZodEnum", (t, e) => {
|
|
742
|
+
I.init(t, e);
|
|
743
|
+
const n = sn(e.entries), s = new Set(n);
|
|
744
|
+
t._zod.values = s, t._zod.pattern = new RegExp(`^(${n.filter((i) => an.has(typeof i)).map((i) => typeof i == "string" ? Ce(i) : i.toString()).join("|")})$`), t._zod.parse = (i, r) => {
|
|
745
745
|
const o = i.value;
|
|
746
746
|
return s.has(o) || i.issues.push({
|
|
747
747
|
code: "invalid_value",
|
|
@@ -750,11 +750,11 @@ const vt = /* @__PURE__ */ g("$ZodUnion", (t, e) => {
|
|
|
750
750
|
inst: t
|
|
751
751
|
}), i;
|
|
752
752
|
};
|
|
753
|
-
}),
|
|
754
|
-
if (
|
|
753
|
+
}), Fn = /* @__PURE__ */ y("$ZodLiteral", (t, e) => {
|
|
754
|
+
if (I.init(t, e), e.values.length === 0)
|
|
755
755
|
throw new Error("Cannot create literal schema with no valid values");
|
|
756
756
|
const n = new Set(e.values);
|
|
757
|
-
t._zod.values = n, t._zod.pattern = new RegExp(`^(${e.values.map((s) => typeof s == "string" ?
|
|
757
|
+
t._zod.values = n, t._zod.pattern = new RegExp(`^(${e.values.map((s) => typeof s == "string" ? Ce(s) : s ? Ce(s.toString()) : String(s)).join("|")})$`), t._zod.parse = (s, i) => {
|
|
758
758
|
const r = s.value;
|
|
759
759
|
return n.has(r) || s.issues.push({
|
|
760
760
|
code: "invalid_value",
|
|
@@ -763,60 +763,60 @@ const vt = /* @__PURE__ */ g("$ZodUnion", (t, e) => {
|
|
|
763
763
|
inst: t
|
|
764
764
|
}), s;
|
|
765
765
|
};
|
|
766
|
-
}),
|
|
767
|
-
|
|
766
|
+
}), $n = /* @__PURE__ */ y("$ZodTransform", (t, e) => {
|
|
767
|
+
I.init(t, e), t._zod.parse = (n, s) => {
|
|
768
768
|
if (s.direction === "backward")
|
|
769
|
-
throw new
|
|
769
|
+
throw new tn(t.constructor.name);
|
|
770
770
|
const i = e.transform(n.value, n);
|
|
771
771
|
if (s.async)
|
|
772
772
|
return (i instanceof Promise ? i : Promise.resolve(i)).then((o) => (n.value = o, n));
|
|
773
773
|
if (i instanceof Promise)
|
|
774
|
-
throw new
|
|
774
|
+
throw new ee();
|
|
775
775
|
return n.value = i, n;
|
|
776
776
|
};
|
|
777
777
|
});
|
|
778
|
-
function
|
|
778
|
+
function qe(t, e) {
|
|
779
779
|
return t.issues.length && e === void 0 ? { issues: [], value: void 0 } : t;
|
|
780
780
|
}
|
|
781
|
-
const
|
|
782
|
-
|
|
781
|
+
const Pn = /* @__PURE__ */ y("$ZodOptional", (t, e) => {
|
|
782
|
+
I.init(t, e), t._zod.optin = "optional", t._zod.optout = "optional", B(t._zod, "values", () => e.innerType._zod.values ? /* @__PURE__ */ new Set([...e.innerType._zod.values, void 0]) : void 0), B(t._zod, "pattern", () => {
|
|
783
783
|
const n = e.innerType._zod.pattern;
|
|
784
|
-
return n ? new RegExp(`^(${
|
|
784
|
+
return n ? new RegExp(`^(${dt(n.source)})?$`) : void 0;
|
|
785
785
|
}), t._zod.parse = (n, s) => {
|
|
786
786
|
if (e.innerType._zod.optin === "optional") {
|
|
787
787
|
const i = e.innerType._zod.run(n, s);
|
|
788
|
-
return i instanceof Promise ? i.then((r) =>
|
|
788
|
+
return i instanceof Promise ? i.then((r) => qe(r, n.value)) : qe(i, n.value);
|
|
789
789
|
}
|
|
790
790
|
return n.value === void 0 ? n : e.innerType._zod.run(n, s);
|
|
791
791
|
};
|
|
792
|
-
}),
|
|
793
|
-
|
|
792
|
+
}), Nn = /* @__PURE__ */ y("$ZodDefault", (t, e) => {
|
|
793
|
+
I.init(t, e), t._zod.optin = "optional", B(t._zod, "values", () => e.innerType._zod.values), t._zod.parse = (n, s) => {
|
|
794
794
|
if (s.direction === "backward")
|
|
795
795
|
return e.innerType._zod.run(n, s);
|
|
796
796
|
if (n.value === void 0)
|
|
797
797
|
return n.value = e.defaultValue, n;
|
|
798
798
|
const i = e.innerType._zod.run(n, s);
|
|
799
|
-
return i instanceof Promise ? i.then((r) =>
|
|
799
|
+
return i instanceof Promise ? i.then((r) => He(r, e)) : He(i, e);
|
|
800
800
|
};
|
|
801
801
|
});
|
|
802
|
-
function
|
|
802
|
+
function He(t, e) {
|
|
803
803
|
return t.value === void 0 && (t.value = e.defaultValue), t;
|
|
804
804
|
}
|
|
805
|
-
const
|
|
806
|
-
|
|
805
|
+
const jn = /* @__PURE__ */ y("$ZodPipe", (t, e) => {
|
|
806
|
+
I.init(t, e), B(t._zod, "values", () => e.in._zod.values), B(t._zod, "optin", () => e.in._zod.optin), B(t._zod, "optout", () => e.out._zod.optout), B(t._zod, "propValues", () => e.in._zod.propValues), t._zod.parse = (n, s) => {
|
|
807
807
|
if (s.direction === "backward") {
|
|
808
808
|
const r = e.out._zod.run(n, s);
|
|
809
|
-
return r instanceof Promise ? r.then((o) =>
|
|
809
|
+
return r instanceof Promise ? r.then((o) => we(o, e.in, s)) : we(r, e.in, s);
|
|
810
810
|
}
|
|
811
811
|
const i = e.in._zod.run(n, s);
|
|
812
|
-
return i instanceof Promise ? i.then((r) =>
|
|
812
|
+
return i instanceof Promise ? i.then((r) => we(r, e.out, s)) : we(i, e.out, s);
|
|
813
813
|
};
|
|
814
814
|
});
|
|
815
|
-
function
|
|
815
|
+
function we(t, e, n) {
|
|
816
816
|
return t.issues.length ? (t.aborted = !0, t) : e._zod.run({ value: t.value, issues: t.issues }, n);
|
|
817
817
|
}
|
|
818
|
-
var
|
|
819
|
-
class
|
|
818
|
+
var Ge;
|
|
819
|
+
class Zn {
|
|
820
820
|
constructor() {
|
|
821
821
|
this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map();
|
|
822
822
|
}
|
|
@@ -845,323 +845,333 @@ class Pn {
|
|
|
845
845
|
return this._map.has(e);
|
|
846
846
|
}
|
|
847
847
|
}
|
|
848
|
-
function
|
|
849
|
-
return new
|
|
848
|
+
function Vn() {
|
|
849
|
+
return new Zn();
|
|
850
850
|
}
|
|
851
|
-
(
|
|
851
|
+
(Ge = globalThis).__zod_globalRegistry ?? (Ge.__zod_globalRegistry = Vn());
|
|
852
852
|
// @__NO_SIDE_EFFECTS__
|
|
853
|
-
function
|
|
853
|
+
function Wn(t, e) {
|
|
854
854
|
return new t({
|
|
855
855
|
type: "string",
|
|
856
|
-
...
|
|
856
|
+
...C()
|
|
857
857
|
});
|
|
858
858
|
}
|
|
859
859
|
// @__NO_SIDE_EFFECTS__
|
|
860
|
-
function
|
|
860
|
+
function qn(t, e) {
|
|
861
861
|
return new t({
|
|
862
862
|
type: "string",
|
|
863
863
|
format: "base64",
|
|
864
864
|
check: "string_format",
|
|
865
865
|
abort: !1,
|
|
866
|
-
...
|
|
866
|
+
...C()
|
|
867
867
|
});
|
|
868
868
|
}
|
|
869
869
|
// @__NO_SIDE_EFFECTS__
|
|
870
|
-
function
|
|
870
|
+
function Hn(t, e) {
|
|
871
871
|
return new t({
|
|
872
872
|
type: "number",
|
|
873
873
|
checks: [],
|
|
874
|
-
...
|
|
874
|
+
...C()
|
|
875
875
|
});
|
|
876
876
|
}
|
|
877
877
|
// @__NO_SIDE_EFFECTS__
|
|
878
|
-
function
|
|
878
|
+
function Gn(t, e) {
|
|
879
879
|
return new t({
|
|
880
880
|
type: "number",
|
|
881
881
|
check: "number_format",
|
|
882
882
|
abort: !1,
|
|
883
883
|
format: "safeint",
|
|
884
|
-
...
|
|
884
|
+
...C()
|
|
885
885
|
});
|
|
886
886
|
}
|
|
887
887
|
// @__NO_SIDE_EFFECTS__
|
|
888
|
-
function
|
|
888
|
+
function Xn(t, e) {
|
|
889
889
|
return new t({
|
|
890
890
|
type: "boolean",
|
|
891
|
-
...
|
|
891
|
+
...C()
|
|
892
892
|
});
|
|
893
893
|
}
|
|
894
894
|
// @__NO_SIDE_EFFECTS__
|
|
895
|
-
function
|
|
896
|
-
return new
|
|
895
|
+
function _t(t, e) {
|
|
896
|
+
return new An({
|
|
897
897
|
check: "less_than",
|
|
898
|
-
...
|
|
898
|
+
...C(),
|
|
899
899
|
value: t,
|
|
900
900
|
inclusive: !0
|
|
901
901
|
});
|
|
902
902
|
}
|
|
903
903
|
// @__NO_SIDE_EFFECTS__
|
|
904
|
-
function
|
|
905
|
-
return new
|
|
904
|
+
function Yn(t, e) {
|
|
905
|
+
return new _n({
|
|
906
906
|
check: "greater_than",
|
|
907
|
-
...
|
|
907
|
+
...C(),
|
|
908
908
|
value: t,
|
|
909
909
|
inclusive: !0
|
|
910
910
|
});
|
|
911
911
|
}
|
|
912
912
|
// @__NO_SIDE_EFFECTS__
|
|
913
|
-
function
|
|
914
|
-
return /* @__PURE__ */
|
|
913
|
+
function zt(t) {
|
|
914
|
+
return /* @__PURE__ */ Yn(0);
|
|
915
915
|
}
|
|
916
|
-
const
|
|
916
|
+
const D = /* @__PURE__ */ y("ZodMiniType", (t, e) => {
|
|
917
917
|
if (!t._zod)
|
|
918
918
|
throw new Error("Uninitialized schema in ZodMiniType.");
|
|
919
|
-
|
|
919
|
+
I.init(t, e), t.def = e, t.type = e.type, t.parse = (n, s) => fn(t, n, s, { callee: t.parse }), t.safeParse = (n, s) => pt(t, n, s), t.parseAsync = async (n, s) => pn(t, n, s, { callee: t.parseAsync }), t.safeParseAsync = async (n, s) => gt(t, n, s), t.check = (...n) => t.clone({
|
|
920
920
|
...e,
|
|
921
921
|
checks: [
|
|
922
922
|
...e.checks ?? [],
|
|
923
923
|
...n.map((s) => typeof s == "function" ? { _zod: { check: s, def: { check: "custom" }, onattach: [] } } : s)
|
|
924
924
|
]
|
|
925
|
-
}, { parent: !0 }), t.with = t.check, t.clone = (n, s) =>
|
|
926
|
-
}),
|
|
927
|
-
|
|
925
|
+
}, { parent: !0 }), t.with = t.check, t.clone = (n, s) => cn(t, n, s), t.brand = () => t, t.register = ((n, s) => (n.add(t, s), t)), t.apply = (n) => n(t);
|
|
926
|
+
}), Mt = /* @__PURE__ */ y("ZodMiniString", (t, e) => {
|
|
927
|
+
bt.init(t, e), D.init(t, e);
|
|
928
928
|
});
|
|
929
929
|
// @__NO_SIDE_EFFECTS__
|
|
930
|
-
function
|
|
931
|
-
return /* @__PURE__ */
|
|
930
|
+
function S(t) {
|
|
931
|
+
return /* @__PURE__ */ Wn(Mt);
|
|
932
932
|
}
|
|
933
|
-
const
|
|
934
|
-
|
|
935
|
-
}),
|
|
936
|
-
|
|
933
|
+
const Kn = /* @__PURE__ */ y("ZodMiniStringFormat", (t, e) => {
|
|
934
|
+
vt.init(t, e), Mt.init(t, e);
|
|
935
|
+
}), Jn = /* @__PURE__ */ y("ZodMiniBase64", (t, e) => {
|
|
936
|
+
Un.init(t, e), Kn.init(t, e);
|
|
937
937
|
});
|
|
938
938
|
// @__NO_SIDE_EFFECTS__
|
|
939
|
-
function
|
|
940
|
-
return /* @__PURE__ */
|
|
939
|
+
function Qn(t) {
|
|
940
|
+
return /* @__PURE__ */ qn(Jn);
|
|
941
941
|
}
|
|
942
|
-
const
|
|
943
|
-
|
|
942
|
+
const kt = /* @__PURE__ */ y("ZodMiniNumber", (t, e) => {
|
|
943
|
+
St.init(t, e), D.init(t, e);
|
|
944
944
|
});
|
|
945
945
|
// @__NO_SIDE_EFFECTS__
|
|
946
946
|
function U(t) {
|
|
947
|
-
return /* @__PURE__ */
|
|
947
|
+
return /* @__PURE__ */ Hn(kt);
|
|
948
948
|
}
|
|
949
|
-
const
|
|
950
|
-
|
|
949
|
+
const es = /* @__PURE__ */ y("ZodMiniNumberFormat", (t, e) => {
|
|
950
|
+
En.init(t, e), kt.init(t, e);
|
|
951
951
|
});
|
|
952
952
|
// @__NO_SIDE_EFFECTS__
|
|
953
|
-
function
|
|
954
|
-
return /* @__PURE__ */
|
|
953
|
+
function Tt(t) {
|
|
954
|
+
return /* @__PURE__ */ Gn(es);
|
|
955
955
|
}
|
|
956
|
-
const
|
|
957
|
-
|
|
956
|
+
const ts = /* @__PURE__ */ y("ZodMiniBoolean", (t, e) => {
|
|
957
|
+
xn.init(t, e), D.init(t, e);
|
|
958
958
|
});
|
|
959
959
|
// @__NO_SIDE_EFFECTS__
|
|
960
|
-
function
|
|
961
|
-
return /* @__PURE__ */
|
|
960
|
+
function Ie(t) {
|
|
961
|
+
return /* @__PURE__ */ Xn(ts);
|
|
962
962
|
}
|
|
963
|
-
const
|
|
964
|
-
|
|
963
|
+
const ns = /* @__PURE__ */ y("ZodMiniArray", (t, e) => {
|
|
964
|
+
Bn.init(t, e), D.init(t, e);
|
|
965
965
|
});
|
|
966
966
|
// @__NO_SIDE_EFFECTS__
|
|
967
967
|
function q(t, e) {
|
|
968
|
-
return new
|
|
968
|
+
return new ns({
|
|
969
969
|
type: "array",
|
|
970
970
|
element: t,
|
|
971
|
-
...
|
|
971
|
+
...C()
|
|
972
972
|
});
|
|
973
973
|
}
|
|
974
|
-
const
|
|
975
|
-
|
|
974
|
+
const ss = /* @__PURE__ */ y("ZodMiniObject", (t, e) => {
|
|
975
|
+
In.init(t, e), D.init(t, e), B(t, "shape", () => e.shape);
|
|
976
976
|
});
|
|
977
977
|
// @__NO_SIDE_EFFECTS__
|
|
978
|
-
function
|
|
978
|
+
function z(t, e) {
|
|
979
979
|
const n = {
|
|
980
980
|
type: "object",
|
|
981
981
|
shape: t ?? {},
|
|
982
|
-
...
|
|
982
|
+
...C()
|
|
983
983
|
};
|
|
984
|
-
return new
|
|
984
|
+
return new ss(n);
|
|
985
985
|
}
|
|
986
|
-
const
|
|
987
|
-
|
|
986
|
+
const is = /* @__PURE__ */ y("ZodMiniUnion", (t, e) => {
|
|
987
|
+
At.init(t, e), D.init(t, e);
|
|
988
988
|
});
|
|
989
989
|
// @__NO_SIDE_EFFECTS__
|
|
990
|
-
function
|
|
991
|
-
return new
|
|
990
|
+
function Me(t, e) {
|
|
991
|
+
return new is({
|
|
992
992
|
type: "union",
|
|
993
993
|
options: t,
|
|
994
|
-
...
|
|
994
|
+
...C()
|
|
995
995
|
});
|
|
996
996
|
}
|
|
997
|
-
const
|
|
998
|
-
|
|
997
|
+
const rs = /* @__PURE__ */ y("ZodMiniDiscriminatedUnion", (t, e) => {
|
|
998
|
+
Dn.init(t, e), D.init(t, e);
|
|
999
999
|
});
|
|
1000
1000
|
// @__NO_SIDE_EFFECTS__
|
|
1001
|
-
function
|
|
1002
|
-
return new
|
|
1001
|
+
function os(t, e, n) {
|
|
1002
|
+
return new rs({
|
|
1003
1003
|
type: "union",
|
|
1004
1004
|
options: e,
|
|
1005
1005
|
discriminator: t,
|
|
1006
|
-
...
|
|
1006
|
+
...C()
|
|
1007
1007
|
});
|
|
1008
1008
|
}
|
|
1009
|
-
const
|
|
1010
|
-
|
|
1009
|
+
const as = /* @__PURE__ */ y("ZodMiniRecord", (t, e) => {
|
|
1010
|
+
On.init(t, e), D.init(t, e);
|
|
1011
1011
|
});
|
|
1012
1012
|
// @__NO_SIDE_EFFECTS__
|
|
1013
|
-
function
|
|
1014
|
-
return new
|
|
1013
|
+
function De(t, e, n) {
|
|
1014
|
+
return new as({
|
|
1015
1015
|
type: "record",
|
|
1016
1016
|
keyType: t,
|
|
1017
1017
|
valueType: e,
|
|
1018
|
-
...
|
|
1018
|
+
...C()
|
|
1019
1019
|
});
|
|
1020
1020
|
}
|
|
1021
|
-
const
|
|
1022
|
-
|
|
1021
|
+
const cs = /* @__PURE__ */ y("ZodMiniEnum", (t, e) => {
|
|
1022
|
+
Ln.init(t, e), D.init(t, e), t.options = Object.values(e.entries);
|
|
1023
1023
|
});
|
|
1024
1024
|
// @__NO_SIDE_EFFECTS__
|
|
1025
|
-
function
|
|
1025
|
+
function Ut(t, e) {
|
|
1026
1026
|
const n = Array.isArray(t) ? Object.fromEntries(t.map((s) => [s, s])) : t;
|
|
1027
|
-
return new
|
|
1027
|
+
return new cs({
|
|
1028
1028
|
type: "enum",
|
|
1029
1029
|
entries: n,
|
|
1030
|
-
...
|
|
1030
|
+
...C()
|
|
1031
1031
|
});
|
|
1032
1032
|
}
|
|
1033
|
-
const
|
|
1034
|
-
|
|
1033
|
+
const us = /* @__PURE__ */ y("ZodMiniLiteral", (t, e) => {
|
|
1034
|
+
Fn.init(t, e), D.init(t, e);
|
|
1035
1035
|
});
|
|
1036
1036
|
// @__NO_SIDE_EFFECTS__
|
|
1037
|
-
function
|
|
1038
|
-
return new
|
|
1037
|
+
function ye(t, e) {
|
|
1038
|
+
return new us({
|
|
1039
1039
|
type: "literal",
|
|
1040
1040
|
values: Array.isArray(t) ? t : [t],
|
|
1041
|
-
...
|
|
1041
|
+
...C()
|
|
1042
1042
|
});
|
|
1043
1043
|
}
|
|
1044
|
-
const
|
|
1045
|
-
|
|
1044
|
+
const ls = /* @__PURE__ */ y("ZodMiniTransform", (t, e) => {
|
|
1045
|
+
$n.init(t, e), D.init(t, e);
|
|
1046
1046
|
});
|
|
1047
1047
|
// @__NO_SIDE_EFFECTS__
|
|
1048
|
-
function
|
|
1049
|
-
return new
|
|
1048
|
+
function Et(t) {
|
|
1049
|
+
return new ls({
|
|
1050
1050
|
type: "transform",
|
|
1051
1051
|
transform: t
|
|
1052
1052
|
});
|
|
1053
1053
|
}
|
|
1054
|
-
const
|
|
1055
|
-
|
|
1054
|
+
const ds = /* @__PURE__ */ y("ZodMiniOptional", (t, e) => {
|
|
1055
|
+
Pn.init(t, e), D.init(t, e);
|
|
1056
1056
|
});
|
|
1057
1057
|
// @__NO_SIDE_EFFECTS__
|
|
1058
1058
|
function m(t) {
|
|
1059
|
-
return new
|
|
1059
|
+
return new ds({
|
|
1060
1060
|
type: "optional",
|
|
1061
1061
|
innerType: t
|
|
1062
1062
|
});
|
|
1063
1063
|
}
|
|
1064
|
-
const
|
|
1065
|
-
|
|
1064
|
+
const hs = /* @__PURE__ */ y("ZodMiniDefault", (t, e) => {
|
|
1065
|
+
Nn.init(t, e), D.init(t, e);
|
|
1066
1066
|
});
|
|
1067
1067
|
// @__NO_SIDE_EFFECTS__
|
|
1068
|
-
function
|
|
1069
|
-
return new
|
|
1068
|
+
function fs(t, e) {
|
|
1069
|
+
return new hs({
|
|
1070
1070
|
type: "default",
|
|
1071
1071
|
innerType: t,
|
|
1072
1072
|
get defaultValue() {
|
|
1073
|
-
return typeof e == "function" ? e() :
|
|
1073
|
+
return typeof e == "function" ? e() : on(e);
|
|
1074
1074
|
}
|
|
1075
1075
|
});
|
|
1076
1076
|
}
|
|
1077
|
-
const
|
|
1078
|
-
|
|
1077
|
+
const ms = /* @__PURE__ */ y("ZodMiniPipe", (t, e) => {
|
|
1078
|
+
jn.init(t, e), D.init(t, e);
|
|
1079
1079
|
});
|
|
1080
1080
|
// @__NO_SIDE_EFFECTS__
|
|
1081
|
-
function
|
|
1082
|
-
return new
|
|
1081
|
+
function xt(t, e) {
|
|
1082
|
+
return new ms({
|
|
1083
1083
|
type: "pipe",
|
|
1084
1084
|
in: t,
|
|
1085
1085
|
out: e
|
|
1086
1086
|
});
|
|
1087
1087
|
}
|
|
1088
|
-
|
|
1089
|
-
|
|
1088
|
+
(/* @__PURE__ */ U()).check(/* @__PURE__ */ Tt(), /* @__PURE__ */ zt(), /* @__PURE__ */ _t(255)).brand("u8");
|
|
1089
|
+
const x = (/* @__PURE__ */ U()).check(/* @__PURE__ */ Tt(), /* @__PURE__ */ zt(), /* @__PURE__ */ _t(Number.MAX_SAFE_INTEGER)).brand("u53");
|
|
1090
|
+
function V(t) {
|
|
1091
|
+
return x.parse(t);
|
|
1092
|
+
}
|
|
1093
|
+
const Bt = /* @__PURE__ */ fs(
|
|
1094
|
+
/* @__PURE__ */ os("kind", [
|
|
1090
1095
|
// The default hang container
|
|
1091
|
-
/* @__PURE__ */
|
|
1092
|
-
// CMAF container with base64-encoded init segment (ftyp+moov)
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1096
|
+
/* @__PURE__ */ z({ kind: /* @__PURE__ */ ye("legacy") }),
|
|
1097
|
+
// CMAF container with base64-encoded init segment (ftyp+moov).
|
|
1098
|
+
// `timescale` and `trackId` are deprecated: they duplicate info in `init`
|
|
1099
|
+
// and are accepted only so catalogs from newer publishers (which still
|
|
1100
|
+
// emit them for older players) round-trip cleanly.
|
|
1101
|
+
/* @__PURE__ */ z({
|
|
1102
|
+
kind: /* @__PURE__ */ ye("cmaf"),
|
|
1103
|
+
init: /* @__PURE__ */ Qn(),
|
|
1104
|
+
timescale: /* @__PURE__ */ m(x),
|
|
1105
|
+
trackId: /* @__PURE__ */ m(x)
|
|
1106
|
+
}),
|
|
1107
|
+
// Low Overhead Container.
|
|
1108
|
+
/* @__PURE__ */ z({ kind: /* @__PURE__ */ ye("loc") })
|
|
1098
1109
|
]),
|
|
1099
1110
|
{ kind: "legacy" }
|
|
1100
|
-
)
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
function V(t) {
|
|
1104
|
-
return D.parse(t);
|
|
1105
|
-
}
|
|
1106
|
-
const hs = /* @__PURE__ */ S({
|
|
1107
|
-
name: /* @__PURE__ */ v()
|
|
1108
|
-
}), Ge = /* @__PURE__ */ S({
|
|
1111
|
+
), ps = /* @__PURE__ */ z({
|
|
1112
|
+
name: /* @__PURE__ */ S()
|
|
1113
|
+
}), Xe = /* @__PURE__ */ z({
|
|
1109
1114
|
// See: https://w3c.github.io/webcodecs/codec_registry.html
|
|
1110
|
-
codec: /* @__PURE__ */
|
|
1115
|
+
codec: /* @__PURE__ */ S(),
|
|
1111
1116
|
// The container format, used to decode the timestamp and more.
|
|
1112
|
-
container:
|
|
1117
|
+
container: Bt,
|
|
1113
1118
|
// The description is used for some codecs.
|
|
1114
1119
|
// If provided, we can initialize the decoder based on the catalog alone.
|
|
1115
1120
|
// Otherwise, the initialization information is in-band.
|
|
1116
|
-
description: /* @__PURE__ */ m(/* @__PURE__ */
|
|
1121
|
+
description: /* @__PURE__ */ m(/* @__PURE__ */ S()),
|
|
1117
1122
|
// hex encoded TODO use base64
|
|
1118
1123
|
// The sample rate of the audio in Hz
|
|
1119
|
-
sampleRate:
|
|
1124
|
+
sampleRate: x,
|
|
1120
1125
|
// The number of channels in the audio
|
|
1121
|
-
numberOfChannels:
|
|
1126
|
+
numberOfChannels: x,
|
|
1122
1127
|
// The bitrate of the audio in bits per second
|
|
1123
1128
|
// TODO: Support up to Number.MAX_SAFE_INTEGER
|
|
1124
|
-
bitrate: /* @__PURE__ */ m(
|
|
1129
|
+
bitrate: /* @__PURE__ */ m(x),
|
|
1125
1130
|
// The maximum jitter before the next frame is emitted in milliseconds.
|
|
1126
1131
|
// The player's jitter buffer should be larger than this value.
|
|
1127
1132
|
// If not provided, the player should assume each frame is flushed immediately.
|
|
1128
1133
|
//
|
|
1129
1134
|
// NOTE: The audio "frame" duration depends on the codec, sample rate, etc.
|
|
1130
1135
|
// ex: AAC often uses 1024 samples per frame, so at 44100Hz, this would be 1024/44100 = 23ms
|
|
1131
|
-
jitter: /* @__PURE__ */ m(
|
|
1132
|
-
}),
|
|
1133
|
-
/* @__PURE__ */
|
|
1136
|
+
jitter: /* @__PURE__ */ m(x)
|
|
1137
|
+
}), gs = /* @__PURE__ */ Me([
|
|
1138
|
+
/* @__PURE__ */ z({
|
|
1134
1139
|
// A map of track name to rendition configuration.
|
|
1135
1140
|
// This is not an array so it will work with JSON Merge Patch.
|
|
1136
|
-
renditions: /* @__PURE__ */
|
|
1141
|
+
renditions: /* @__PURE__ */ De(/* @__PURE__ */ S(), Xe)
|
|
1137
1142
|
}),
|
|
1138
1143
|
// Backwards compatibility: transform old {track, config} format to new object format
|
|
1139
|
-
/* @__PURE__ */
|
|
1140
|
-
/* @__PURE__ */
|
|
1141
|
-
track:
|
|
1142
|
-
config:
|
|
1144
|
+
/* @__PURE__ */ xt(
|
|
1145
|
+
/* @__PURE__ */ z({
|
|
1146
|
+
track: ps,
|
|
1147
|
+
config: Xe
|
|
1143
1148
|
}),
|
|
1144
|
-
/* @__PURE__ */
|
|
1149
|
+
/* @__PURE__ */ Et((t) => ({
|
|
1145
1150
|
renditions: { [t.track.name]: t.config }
|
|
1146
1151
|
}))
|
|
1147
1152
|
)
|
|
1148
|
-
]),
|
|
1149
|
-
hardware: /* @__PURE__ */ m(/* @__PURE__ */ q(/* @__PURE__ */
|
|
1150
|
-
software: /* @__PURE__ */ m(/* @__PURE__ */ q(/* @__PURE__ */
|
|
1151
|
-
unsupported: /* @__PURE__ */ m(/* @__PURE__ */ q(/* @__PURE__ */
|
|
1152
|
-
}),
|
|
1153
|
-
hardware: /* @__PURE__ */ m(/* @__PURE__ */ q(/* @__PURE__ */
|
|
1154
|
-
software: /* @__PURE__ */ m(/* @__PURE__ */ q(/* @__PURE__ */
|
|
1155
|
-
unsupported: /* @__PURE__ */ m(/* @__PURE__ */ q(/* @__PURE__ */
|
|
1156
|
-
}),
|
|
1157
|
-
video: /* @__PURE__ */ m(
|
|
1158
|
-
audio: /* @__PURE__ */ m(
|
|
1159
|
-
}),
|
|
1160
|
-
name: /* @__PURE__ */
|
|
1161
|
-
}),
|
|
1162
|
-
message: /* @__PURE__ */ m(
|
|
1163
|
-
typing: /* @__PURE__ */ m(
|
|
1164
|
-
}),
|
|
1153
|
+
]), ws = /* @__PURE__ */ z({
|
|
1154
|
+
hardware: /* @__PURE__ */ m(/* @__PURE__ */ q(/* @__PURE__ */ S())),
|
|
1155
|
+
software: /* @__PURE__ */ m(/* @__PURE__ */ q(/* @__PURE__ */ S())),
|
|
1156
|
+
unsupported: /* @__PURE__ */ m(/* @__PURE__ */ q(/* @__PURE__ */ S()))
|
|
1157
|
+
}), ys = /* @__PURE__ */ z({
|
|
1158
|
+
hardware: /* @__PURE__ */ m(/* @__PURE__ */ q(/* @__PURE__ */ S())),
|
|
1159
|
+
software: /* @__PURE__ */ m(/* @__PURE__ */ q(/* @__PURE__ */ S())),
|
|
1160
|
+
unsupported: /* @__PURE__ */ m(/* @__PURE__ */ q(/* @__PURE__ */ S()))
|
|
1161
|
+
}), bs = /* @__PURE__ */ z({
|
|
1162
|
+
video: /* @__PURE__ */ m(ws),
|
|
1163
|
+
audio: /* @__PURE__ */ m(ys)
|
|
1164
|
+
}), fe = /* @__PURE__ */ z({
|
|
1165
|
+
name: /* @__PURE__ */ S()
|
|
1166
|
+
}), vs = /* @__PURE__ */ z({
|
|
1167
|
+
message: /* @__PURE__ */ m(fe),
|
|
1168
|
+
typing: /* @__PURE__ */ m(fe)
|
|
1169
|
+
}), Rt = ["hang", "msf"], Ss = "hang";
|
|
1170
|
+
function As(t) {
|
|
1171
|
+
for (const e of Rt)
|
|
1172
|
+
if (t.endsWith(`.${e}`)) return e;
|
|
1173
|
+
}
|
|
1174
|
+
const Ct = /* @__PURE__ */ z({
|
|
1165
1175
|
// The relative X position of the broadcast, from -1 to +1.
|
|
1166
1176
|
// This should be used for audio panning but can also be used for video positioning.
|
|
1167
1177
|
x: /* @__PURE__ */ m(/* @__PURE__ */ U()),
|
|
@@ -1173,22 +1183,22 @@ const hs = /* @__PURE__ */ S({
|
|
|
1173
1183
|
z: /* @__PURE__ */ m(/* @__PURE__ */ U()),
|
|
1174
1184
|
// The scale of the broadcast, where 1 is 100%
|
|
1175
1185
|
s: /* @__PURE__ */ m(/* @__PURE__ */ U())
|
|
1176
|
-
}),
|
|
1186
|
+
}), _s = /* @__PURE__ */ z({
|
|
1177
1187
|
// The initial position of the broadcaster, from -1 to +1 in both dimensions.
|
|
1178
1188
|
// If not provided, then the broadcaster is assumed to be at (0,0)
|
|
1179
1189
|
// This should be used for audio panning but can also be used for video positioning.
|
|
1180
|
-
initial: /* @__PURE__ */ m(
|
|
1190
|
+
initial: /* @__PURE__ */ m(Ct),
|
|
1181
1191
|
// If provided, then updates to the position are done via a separate Moq track.
|
|
1182
1192
|
// This is used to avoid a full catalog update every time we want to update a few bytes.
|
|
1183
1193
|
// TODO: These updates currently use JSON for simplicity, but we should use a binary format.
|
|
1184
|
-
track: /* @__PURE__ */ m(
|
|
1194
|
+
track: /* @__PURE__ */ m(fe),
|
|
1185
1195
|
// If set, then this broadcaster allows other peers to request position updates via this handle.
|
|
1186
1196
|
// We will have to discover and subscribe to their position updates.
|
|
1187
|
-
handle: /* @__PURE__ */ m(/* @__PURE__ */
|
|
1197
|
+
handle: /* @__PURE__ */ m(/* @__PURE__ */ S()),
|
|
1188
1198
|
// If provided, this broadcaster is signaling the location of other peers.
|
|
1189
1199
|
// The payload is a JSON blob keyed by handle for each peer.
|
|
1190
|
-
peers: /* @__PURE__ */ m(
|
|
1191
|
-
}),
|
|
1200
|
+
peers: /* @__PURE__ */ m(fe)
|
|
1201
|
+
}), Ur = /* @__PURE__ */ De(/* @__PURE__ */ S(), Ct), te = {
|
|
1192
1202
|
catalog: 100,
|
|
1193
1203
|
chat: 90,
|
|
1194
1204
|
audio: 80,
|
|
@@ -1196,41 +1206,41 @@ const hs = /* @__PURE__ */ S({
|
|
|
1196
1206
|
typing: 40,
|
|
1197
1207
|
location: 20,
|
|
1198
1208
|
preview: 10
|
|
1199
|
-
},
|
|
1200
|
-
id: /* @__PURE__ */ m(/* @__PURE__ */
|
|
1201
|
-
name: /* @__PURE__ */ m(/* @__PURE__ */
|
|
1202
|
-
avatar: /* @__PURE__ */ m(/* @__PURE__ */
|
|
1209
|
+
}, zs = /* @__PURE__ */ z({
|
|
1210
|
+
id: /* @__PURE__ */ m(/* @__PURE__ */ S()),
|
|
1211
|
+
name: /* @__PURE__ */ m(/* @__PURE__ */ S()),
|
|
1212
|
+
avatar: /* @__PURE__ */ m(/* @__PURE__ */ S()),
|
|
1203
1213
|
// TODO allow using a track instead of a URL?
|
|
1204
|
-
color: /* @__PURE__ */ m(/* @__PURE__ */
|
|
1205
|
-
}),
|
|
1206
|
-
name: /* @__PURE__ */
|
|
1207
|
-
}),
|
|
1214
|
+
color: /* @__PURE__ */ m(/* @__PURE__ */ S())
|
|
1215
|
+
}), Ms = /* @__PURE__ */ z({
|
|
1216
|
+
name: /* @__PURE__ */ S()
|
|
1217
|
+
}), Ye = /* @__PURE__ */ z({
|
|
1208
1218
|
// See: https://w3c.github.io/webcodecs/codec_registry.html
|
|
1209
|
-
codec: /* @__PURE__ */
|
|
1219
|
+
codec: /* @__PURE__ */ S(),
|
|
1210
1220
|
// The container format, used to decode the timestamp and more.
|
|
1211
|
-
container:
|
|
1221
|
+
container: Bt,
|
|
1212
1222
|
// The description is used for some codecs.
|
|
1213
1223
|
// If provided, we can initialize the decoder based on the catalog alone.
|
|
1214
1224
|
// Otherwise, the initialization information is (repeated) before each key-frame.
|
|
1215
|
-
description: /* @__PURE__ */ m(/* @__PURE__ */
|
|
1225
|
+
description: /* @__PURE__ */ m(/* @__PURE__ */ S()),
|
|
1216
1226
|
// hex encoded TODO use base64
|
|
1217
1227
|
// The width and height of the video in pixels.
|
|
1218
1228
|
// NOTE: formats that don't use a description can adjust these values in-band.
|
|
1219
|
-
codedWidth: /* @__PURE__ */ m(
|
|
1220
|
-
codedHeight: /* @__PURE__ */ m(
|
|
1229
|
+
codedWidth: /* @__PURE__ */ m(x),
|
|
1230
|
+
codedHeight: /* @__PURE__ */ m(x),
|
|
1221
1231
|
// Ratio of display width/height to coded width/height
|
|
1222
1232
|
// Allows stretching/squishing individual "pixels" of the video
|
|
1223
1233
|
// If not provided, the display ratio is 1:1
|
|
1224
|
-
displayAspectWidth: /* @__PURE__ */ m(
|
|
1225
|
-
displayAspectHeight: /* @__PURE__ */ m(
|
|
1234
|
+
displayAspectWidth: /* @__PURE__ */ m(x),
|
|
1235
|
+
displayAspectHeight: /* @__PURE__ */ m(x),
|
|
1226
1236
|
// The frame rate of the video in frames per second
|
|
1227
1237
|
framerate: /* @__PURE__ */ m(/* @__PURE__ */ U()),
|
|
1228
1238
|
// The bitrate of the video in bits per second
|
|
1229
1239
|
// TODO: Support up to Number.MAX_SAFE_INTEGER
|
|
1230
|
-
bitrate: /* @__PURE__ */ m(
|
|
1240
|
+
bitrate: /* @__PURE__ */ m(x),
|
|
1231
1241
|
// If true, the decoder will optimize for latency.
|
|
1232
1242
|
// Default: true
|
|
1233
|
-
optimizeForLatency: /* @__PURE__ */ m(/* @__PURE__ */
|
|
1243
|
+
optimizeForLatency: /* @__PURE__ */ m(/* @__PURE__ */ Ie()),
|
|
1234
1244
|
// The maximum jitter before the next frame is emitted in milliseconds.
|
|
1235
1245
|
// The player's jitter buffer should be larger than this value.
|
|
1236
1246
|
// If not provided, the player should assume each frame is flushed immediately.
|
|
@@ -1239,18 +1249,18 @@ const hs = /* @__PURE__ */ S({
|
|
|
1239
1249
|
// - If each frame is flushed immediately, this would be 1000/fps.
|
|
1240
1250
|
// - If there can be up to 3 b-frames in a row, this would be 3 * 1000/fps.
|
|
1241
1251
|
// - If frames are buffered into 2s segments, this would be 2s.
|
|
1242
|
-
jitter: /* @__PURE__ */ m(
|
|
1243
|
-
}),
|
|
1244
|
-
/* @__PURE__ */
|
|
1252
|
+
jitter: /* @__PURE__ */ m(x)
|
|
1253
|
+
}), ks = /* @__PURE__ */ Me([
|
|
1254
|
+
/* @__PURE__ */ z({
|
|
1245
1255
|
// A map of track name to rendition configuration.
|
|
1246
1256
|
// This is not an array in order for it to work with JSON Merge Patch.
|
|
1247
|
-
renditions: /* @__PURE__ */
|
|
1257
|
+
renditions: /* @__PURE__ */ De(/* @__PURE__ */ S(), Ye),
|
|
1248
1258
|
// Render the video at this size in pixels.
|
|
1249
1259
|
// This is separate from the display aspect ratio because it does not require reinitialization.
|
|
1250
1260
|
display: /* @__PURE__ */ m(
|
|
1251
|
-
/* @__PURE__ */
|
|
1252
|
-
width:
|
|
1253
|
-
height:
|
|
1261
|
+
/* @__PURE__ */ z({
|
|
1262
|
+
width: x,
|
|
1263
|
+
height: x
|
|
1254
1264
|
})
|
|
1255
1265
|
),
|
|
1256
1266
|
// The rotation of the video in degrees.
|
|
@@ -1258,17 +1268,17 @@ const hs = /* @__PURE__ */ S({
|
|
|
1258
1268
|
rotation: /* @__PURE__ */ m(/* @__PURE__ */ U()),
|
|
1259
1269
|
// If true, the decoder will flip the video horizontally
|
|
1260
1270
|
// Default: false
|
|
1261
|
-
flip: /* @__PURE__ */ m(/* @__PURE__ */
|
|
1271
|
+
flip: /* @__PURE__ */ m(/* @__PURE__ */ Ie())
|
|
1262
1272
|
}),
|
|
1263
1273
|
// Backwards compatibility: transform old array of {track, config} to new object format
|
|
1264
|
-
/* @__PURE__ */
|
|
1274
|
+
/* @__PURE__ */ xt(
|
|
1265
1275
|
/* @__PURE__ */ q(
|
|
1266
|
-
/* @__PURE__ */
|
|
1267
|
-
track:
|
|
1268
|
-
config:
|
|
1276
|
+
/* @__PURE__ */ z({
|
|
1277
|
+
track: Ms,
|
|
1278
|
+
config: Ye
|
|
1269
1279
|
})
|
|
1270
1280
|
),
|
|
1271
|
-
/* @__PURE__ */
|
|
1281
|
+
/* @__PURE__ */ Et((t) => {
|
|
1272
1282
|
const e = t[0]?.config;
|
|
1273
1283
|
return {
|
|
1274
1284
|
renditions: Object.fromEntries(t.map((n) => [n.track.name, n.config])),
|
|
@@ -1278,47 +1288,79 @@ const hs = /* @__PURE__ */ S({
|
|
|
1278
1288
|
};
|
|
1279
1289
|
})
|
|
1280
1290
|
)
|
|
1281
|
-
]),
|
|
1282
|
-
video: /* @__PURE__ */ m(
|
|
1283
|
-
audio: /* @__PURE__ */ m(
|
|
1284
|
-
location: /* @__PURE__ */ m(
|
|
1285
|
-
user: /* @__PURE__ */ m(
|
|
1286
|
-
chat: /* @__PURE__ */ m(
|
|
1287
|
-
capabilities: /* @__PURE__ */ m(
|
|
1288
|
-
preview: /* @__PURE__ */ m(
|
|
1291
|
+
]), Ts = /* @__PURE__ */ z({
|
|
1292
|
+
video: /* @__PURE__ */ m(ks),
|
|
1293
|
+
audio: /* @__PURE__ */ m(gs),
|
|
1294
|
+
location: /* @__PURE__ */ m(_s),
|
|
1295
|
+
user: /* @__PURE__ */ m(zs),
|
|
1296
|
+
chat: /* @__PURE__ */ m(vs),
|
|
1297
|
+
capabilities: /* @__PURE__ */ m(bs),
|
|
1298
|
+
preview: /* @__PURE__ */ m(fe)
|
|
1289
1299
|
});
|
|
1290
|
-
function
|
|
1300
|
+
function Us(t) {
|
|
1291
1301
|
const n = new TextDecoder().decode(t);
|
|
1292
1302
|
try {
|
|
1293
1303
|
const s = JSON.parse(n);
|
|
1294
|
-
return
|
|
1304
|
+
return Ts.parse(s);
|
|
1295
1305
|
} catch (s) {
|
|
1296
1306
|
throw console.warn("invalid catalog", n), s;
|
|
1297
1307
|
}
|
|
1298
1308
|
}
|
|
1299
|
-
async function
|
|
1309
|
+
async function Es(t) {
|
|
1300
1310
|
const e = await t.readFrame();
|
|
1301
1311
|
if (e)
|
|
1302
|
-
return
|
|
1312
|
+
return Us(e);
|
|
1303
1313
|
}
|
|
1304
|
-
|
|
1314
|
+
const xs = 6, Bs = 8, Ke = 1e6;
|
|
1315
|
+
let ke = class {
|
|
1316
|
+
decode(e) {
|
|
1317
|
+
const [n, s] = A.Varint.decode(e);
|
|
1318
|
+
if (s.byteLength < n)
|
|
1319
|
+
throw new Error("loc: properties_length exceeds frame size");
|
|
1320
|
+
const i = s.subarray(0, n), r = s.subarray(n);
|
|
1321
|
+
let o, c, a = 0, u = !0, l = i;
|
|
1322
|
+
for (; l.byteLength > 0; ) {
|
|
1323
|
+
const [p, b] = A.Varint.decode(l), w = u ? p : a + p;
|
|
1324
|
+
if (u = !1, a = w, l = b, w % 2 === 0) {
|
|
1325
|
+
const [v, _] = A.Varint.decode(l);
|
|
1326
|
+
if (l = _, w === xs)
|
|
1327
|
+
o = v;
|
|
1328
|
+
else if (w === Bs) {
|
|
1329
|
+
if (v === 0)
|
|
1330
|
+
throw new Error("loc: timescale property must be non-zero");
|
|
1331
|
+
c = v;
|
|
1332
|
+
}
|
|
1333
|
+
} else {
|
|
1334
|
+
const [v, _] = A.Varint.decode(l);
|
|
1335
|
+
if (_.byteLength < v)
|
|
1336
|
+
throw new Error("loc: property length exceeds remaining bytes");
|
|
1337
|
+
l = _.subarray(v);
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
if (o === void 0)
|
|
1341
|
+
throw new Error("loc: frame missing required timestamp property");
|
|
1342
|
+
const d = c ?? Ke, f = Math.round(o * Ke / d);
|
|
1343
|
+
return [{ data: r, timestamp: f, keyframe: !1 }];
|
|
1344
|
+
}
|
|
1345
|
+
};
|
|
1346
|
+
function It(t) {
|
|
1305
1347
|
return t instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && t instanceof SharedArrayBuffer;
|
|
1306
1348
|
}
|
|
1307
|
-
const
|
|
1308
|
-
function
|
|
1349
|
+
const Rs = "utf-16", Ee = "utf-16be", Je = "utf-16le", de = "utf-8";
|
|
1350
|
+
function Dt(t, e = {}) {
|
|
1309
1351
|
let n;
|
|
1310
|
-
|
|
1352
|
+
It(t) ? n = new DataView(t) : n = new DataView(t.buffer, t.byteOffset, t.byteLength);
|
|
1311
1353
|
let s = 0, { encoding: i } = e;
|
|
1312
1354
|
if (!i) {
|
|
1313
1355
|
const u = n.getUint8(0), l = n.getUint8(1);
|
|
1314
|
-
u == 239 && l == 187 && n.getUint8(2) == 191 ? (i =
|
|
1356
|
+
u == 239 && l == 187 && n.getUint8(2) == 191 ? (i = de, s = 3) : u == 254 && l == 255 ? (i = Ee, s = 2) : u == 255 && l == 254 ? (i = Je, s = 2) : i = de;
|
|
1315
1357
|
}
|
|
1316
1358
|
if (typeof TextDecoder < "u") return new TextDecoder(i).decode(n);
|
|
1317
|
-
const { byteLength: r } = n, o = i !==
|
|
1359
|
+
const { byteLength: r } = n, o = i !== Ee;
|
|
1318
1360
|
let c = "", a;
|
|
1319
1361
|
for (; s < r; ) {
|
|
1320
1362
|
switch (i) {
|
|
1321
|
-
case
|
|
1363
|
+
case de:
|
|
1322
1364
|
if (a = n.getUint8(s), a < 128) s++;
|
|
1323
1365
|
else if (a >= 194 && a <= 223) if (s + 1 < r) {
|
|
1324
1366
|
const u = n.getUint8(s + 1);
|
|
@@ -1334,9 +1376,9 @@ function Rt(t, e = {}) {
|
|
|
1334
1376
|
} else s++;
|
|
1335
1377
|
else s++;
|
|
1336
1378
|
break;
|
|
1337
|
-
case
|
|
1338
|
-
case
|
|
1339
|
-
case
|
|
1379
|
+
case Ee:
|
|
1380
|
+
case Rs:
|
|
1381
|
+
case Je:
|
|
1340
1382
|
a = n.getUint16(s, o), s += 2;
|
|
1341
1383
|
break;
|
|
1342
1384
|
}
|
|
@@ -1344,13 +1386,13 @@ function Rt(t, e = {}) {
|
|
|
1344
1386
|
}
|
|
1345
1387
|
return c;
|
|
1346
1388
|
}
|
|
1347
|
-
function
|
|
1389
|
+
function Cs(t) {
|
|
1348
1390
|
return new TextEncoder().encode(t);
|
|
1349
1391
|
}
|
|
1350
|
-
function
|
|
1392
|
+
function Is(t) {
|
|
1351
1393
|
return { writers: t?.writers ?? {} };
|
|
1352
1394
|
}
|
|
1353
|
-
const
|
|
1395
|
+
const Ds = [
|
|
1354
1396
|
"dinf",
|
|
1355
1397
|
"edts",
|
|
1356
1398
|
"grpl",
|
|
@@ -1371,11 +1413,11 @@ const Us = [
|
|
|
1371
1413
|
"udta",
|
|
1372
1414
|
"vttc"
|
|
1373
1415
|
];
|
|
1374
|
-
function
|
|
1375
|
-
return "boxes" in t ||
|
|
1416
|
+
function Ot(t) {
|
|
1417
|
+
return "boxes" in t || Ds.includes(t.type);
|
|
1376
1418
|
}
|
|
1377
|
-
const
|
|
1378
|
-
var
|
|
1419
|
+
const Qe = "utf8", R = "uint", ne = "template", et = "string", tt = "int", nt = "data";
|
|
1420
|
+
var T = class {
|
|
1379
1421
|
/**
|
|
1380
1422
|
* Constructs a new IsoBoxWriteView.
|
|
1381
1423
|
*
|
|
@@ -1432,14 +1474,14 @@ var k = class {
|
|
|
1432
1474
|
this.writeUint(0, 1);
|
|
1433
1475
|
}
|
|
1434
1476
|
}, this.writeUtf8TerminatedString = (n) => {
|
|
1435
|
-
const s =
|
|
1477
|
+
const s = Cs(n);
|
|
1436
1478
|
new Uint8Array(this.dataView.buffer).set(s, this.cursor), this.cursor += s.length, this.writeUint(0, 1);
|
|
1437
1479
|
}, this.writeBytes = (n) => {
|
|
1438
1480
|
Array.isArray(n) || (n = [n]);
|
|
1439
1481
|
for (const s of n)
|
|
1440
1482
|
new Uint8Array(this.dataView.buffer).set(s, this.cursor), this.cursor += s.length;
|
|
1441
1483
|
}, this.writeArray = (n, s, i, r) => {
|
|
1442
|
-
const o = s ===
|
|
1484
|
+
const o = s === R ? this.writeUint : s === ne ? this.writeTemplate : this.writeInt;
|
|
1443
1485
|
for (let c = 0; c < r; c++) o(n[c] ?? 0, i);
|
|
1444
1486
|
}, this.writeTemplate = (n, s) => {
|
|
1445
1487
|
const r = Math.round(n * Math.pow(2, s === 4 ? 16 : 8));
|
|
@@ -1482,34 +1524,34 @@ var k = class {
|
|
|
1482
1524
|
this.writeUint(t, 1), this.writeUint(e, 3);
|
|
1483
1525
|
}
|
|
1484
1526
|
};
|
|
1485
|
-
function
|
|
1486
|
-
return Array.from(t, (n) =>
|
|
1527
|
+
function Lt(t, e) {
|
|
1528
|
+
return Array.from(t, (n) => Ls(n, e));
|
|
1487
1529
|
}
|
|
1488
|
-
function
|
|
1489
|
-
const n =
|
|
1530
|
+
function Oe(t, e) {
|
|
1531
|
+
const n = Lt(t, e);
|
|
1490
1532
|
return {
|
|
1491
1533
|
bytes: n,
|
|
1492
1534
|
size: n.reduce((s, i) => s + i.byteLength, 0)
|
|
1493
1535
|
};
|
|
1494
1536
|
}
|
|
1495
|
-
function
|
|
1496
|
-
const { bytes: s, size: i } =
|
|
1537
|
+
function Os(t, e) {
|
|
1538
|
+
const { bytes: s, size: i } = Oe(t.boxes, e), r = 8 + i, o = new T(t.type, r);
|
|
1497
1539
|
return o.writeBytes(s), o;
|
|
1498
1540
|
}
|
|
1499
|
-
function
|
|
1541
|
+
function Ls(t, e) {
|
|
1500
1542
|
let n = null;
|
|
1501
1543
|
if ("type" in t) {
|
|
1502
1544
|
const { type: s } = t, i = e.writers?.[s];
|
|
1503
|
-
if (i ? n = i(t, e) :
|
|
1545
|
+
if (i ? n = i(t, e) : Ot(t) ? n = Os(t, e) : "view" in t && (n = t.view), !n) throw new Error(`No writer found for box type: ${s}`);
|
|
1504
1546
|
}
|
|
1505
1547
|
if ("buffer" in t && (n = t), !n) throw new Error("Invalid box");
|
|
1506
1548
|
return new Uint8Array(n.buffer, n.byteOffset, n.byteLength);
|
|
1507
1549
|
}
|
|
1508
|
-
function
|
|
1550
|
+
function Fs(t, e, n) {
|
|
1509
1551
|
const s = n > 0 ? n : t.byteLength - (e - t.byteOffset);
|
|
1510
1552
|
return new Uint8Array(t.buffer, e, Math.max(s, 0));
|
|
1511
1553
|
}
|
|
1512
|
-
function
|
|
1554
|
+
function $s(t, e, n) {
|
|
1513
1555
|
let s = NaN;
|
|
1514
1556
|
const i = e - t.byteOffset;
|
|
1515
1557
|
switch (n) {
|
|
@@ -1551,7 +1593,7 @@ function Y(t, e, n) {
|
|
|
1551
1593
|
}
|
|
1552
1594
|
return i;
|
|
1553
1595
|
}
|
|
1554
|
-
function
|
|
1596
|
+
function st(t, e, n) {
|
|
1555
1597
|
let s = "";
|
|
1556
1598
|
for (let i = 0; i < n; i++) {
|
|
1557
1599
|
const r = Y(t, e + i, 1);
|
|
@@ -1559,11 +1601,11 @@ function tt(t, e, n) {
|
|
|
1559
1601
|
}
|
|
1560
1602
|
return s;
|
|
1561
1603
|
}
|
|
1562
|
-
function
|
|
1604
|
+
function Ps(t, e, n) {
|
|
1563
1605
|
const s = n / 2;
|
|
1564
1606
|
return Y(t, e, s) + Y(t, e + s, s) / Math.pow(2, s);
|
|
1565
1607
|
}
|
|
1566
|
-
function
|
|
1608
|
+
function Ns(t, e) {
|
|
1567
1609
|
let n = "", s = e;
|
|
1568
1610
|
for (; s - t.byteOffset < t.byteLength; ) {
|
|
1569
1611
|
const i = Y(t, s, 1);
|
|
@@ -1572,22 +1614,22 @@ function Is(t, e) {
|
|
|
1572
1614
|
}
|
|
1573
1615
|
return n;
|
|
1574
1616
|
}
|
|
1575
|
-
function
|
|
1617
|
+
function js(t, e) {
|
|
1576
1618
|
const n = t.byteLength - (e - t.byteOffset);
|
|
1577
|
-
return n > 0 ?
|
|
1619
|
+
return n > 0 ? Dt(new DataView(t.buffer, e, n), { encoding: de }) : "";
|
|
1578
1620
|
}
|
|
1579
|
-
function
|
|
1621
|
+
function Zs(t, e) {
|
|
1580
1622
|
const n = t.byteLength - (e - t.byteOffset);
|
|
1581
1623
|
let s = "";
|
|
1582
1624
|
if (n > 0) {
|
|
1583
1625
|
const i = new DataView(t.buffer, e, n);
|
|
1584
1626
|
let r = 0;
|
|
1585
1627
|
for (; r < n && i.getUint8(r) !== 0; r++) ;
|
|
1586
|
-
s =
|
|
1628
|
+
s = Dt(new DataView(t.buffer, e, r), { encoding: de });
|
|
1587
1629
|
}
|
|
1588
1630
|
return s;
|
|
1589
1631
|
}
|
|
1590
|
-
var
|
|
1632
|
+
var Vs = class Ft {
|
|
1591
1633
|
/**
|
|
1592
1634
|
* Creates a new IsoView instance. Similar to DataView, but with additional
|
|
1593
1635
|
* methods for reading ISO BMFF data. It implements the iterator protocol,
|
|
@@ -1598,35 +1640,35 @@ var Ls = class Dt {
|
|
|
1598
1640
|
*/
|
|
1599
1641
|
constructor(e, n) {
|
|
1600
1642
|
this.truncated = !1, this.slice = (s, i) => {
|
|
1601
|
-
const r = new
|
|
1643
|
+
const r = new Ft(new DataView(this.dataView.buffer, s, i), this.config), o = this.offset - s, c = i - o;
|
|
1602
1644
|
return this.offset += c, r.jump(o), r;
|
|
1603
1645
|
}, this.read = (s, i = 0) => {
|
|
1604
1646
|
const { dataView: r, offset: o } = this;
|
|
1605
1647
|
let c, a = i;
|
|
1606
1648
|
switch (s) {
|
|
1607
|
-
case
|
|
1649
|
+
case R:
|
|
1608
1650
|
c = Y(r, o, i);
|
|
1609
1651
|
break;
|
|
1610
|
-
case
|
|
1611
|
-
c =
|
|
1652
|
+
case tt:
|
|
1653
|
+
c = $s(r, o, i);
|
|
1612
1654
|
break;
|
|
1613
|
-
case
|
|
1614
|
-
c =
|
|
1615
|
-
break;
|
|
1616
|
-
case Je:
|
|
1617
|
-
i === -1 ? (c = Is(r, o), a = c.length + 1) : c = tt(r, o, i);
|
|
1655
|
+
case ne:
|
|
1656
|
+
c = Ps(r, o, i);
|
|
1618
1657
|
break;
|
|
1619
1658
|
case et:
|
|
1620
|
-
c =
|
|
1659
|
+
i === -1 ? (c = Ns(r, o), a = c.length + 1) : c = st(r, o, i);
|
|
1660
|
+
break;
|
|
1661
|
+
case nt:
|
|
1662
|
+
c = Fs(r, o, i), a = c.length;
|
|
1621
1663
|
break;
|
|
1622
|
-
case
|
|
1623
|
-
i === -1 ? (c =
|
|
1664
|
+
case Qe:
|
|
1665
|
+
i === -1 ? (c = Zs(r, o), a = c.length + 1) : c = js(r, o);
|
|
1624
1666
|
break;
|
|
1625
1667
|
default:
|
|
1626
1668
|
c = -1;
|
|
1627
1669
|
}
|
|
1628
1670
|
return this.offset += a, c;
|
|
1629
|
-
}, this.readUint = (s) => this.read(
|
|
1671
|
+
}, this.readUint = (s) => this.read(R, s), this.readInt = (s) => this.read(tt, s), this.readString = (s) => this.read(et, s), this.readTemplate = (s) => this.read(ne, s), this.readData = (s) => this.read(nt, s), this.readUtf8 = (s) => this.read(Qe, s), this.readFullBox = () => ({
|
|
1630
1672
|
version: this.readUint(1),
|
|
1631
1673
|
flags: this.readUint(3)
|
|
1632
1674
|
}), this.readArray = (s, i, r) => {
|
|
@@ -1638,7 +1680,7 @@ var Ls = class Dt {
|
|
|
1638
1680
|
}, this.readBox = () => {
|
|
1639
1681
|
const { dataView: s, offset: i } = this;
|
|
1640
1682
|
let r = 0;
|
|
1641
|
-
const o = Y(s, i, 4), c =
|
|
1683
|
+
const o = Y(s, i, 4), c = st(s, i + 4, 4), a = {
|
|
1642
1684
|
size: o,
|
|
1643
1685
|
type: c
|
|
1644
1686
|
};
|
|
@@ -1656,7 +1698,7 @@ var Ls = class Dt {
|
|
|
1656
1698
|
const r = [];
|
|
1657
1699
|
for (let o = 0; o < s; o++) r.push(i());
|
|
1658
1700
|
return r;
|
|
1659
|
-
}, this.dataView =
|
|
1701
|
+
}, this.dataView = It(e) ? new DataView(e) : e instanceof DataView ? e : new DataView(e.buffer, e.byteOffset, e.byteLength), this.offset = this.dataView.byteOffset, this.config = n || {};
|
|
1660
1702
|
}
|
|
1661
1703
|
/**
|
|
1662
1704
|
* The buffer of the data view.
|
|
@@ -1703,7 +1745,7 @@ var Ls = class Dt {
|
|
|
1703
1745
|
const { readers: e = {} } = this.config;
|
|
1704
1746
|
for (; !this.done; ) try {
|
|
1705
1747
|
const n = this.readBox(), { type: s, view: i } = n, r = e[s] || e[s.trim()];
|
|
1706
|
-
if (r && Object.assign(n, r(i, s)),
|
|
1748
|
+
if (r && Object.assign(n, r(i, s)), Ot(n) && !n.boxes) {
|
|
1707
1749
|
const o = [];
|
|
1708
1750
|
for (const c of i) o.push(c);
|
|
1709
1751
|
n.boxes = o;
|
|
@@ -1715,21 +1757,21 @@ var Ls = class Dt {
|
|
|
1715
1757
|
}
|
|
1716
1758
|
}
|
|
1717
1759
|
};
|
|
1718
|
-
function
|
|
1760
|
+
function Le(t, e) {
|
|
1719
1761
|
const n = [];
|
|
1720
|
-
for (const s of new
|
|
1762
|
+
for (const s of new Vs(t, e)) n.push(s);
|
|
1721
1763
|
return n;
|
|
1722
1764
|
}
|
|
1723
|
-
function
|
|
1724
|
-
return
|
|
1765
|
+
function Ws(t, e) {
|
|
1766
|
+
return Lt(t, Is(e));
|
|
1725
1767
|
}
|
|
1726
|
-
function
|
|
1768
|
+
function qs(t, e) {
|
|
1727
1769
|
const { readArray: n, readUint: s, readTemplate: i, readBoxes: r } = e;
|
|
1728
1770
|
return {
|
|
1729
1771
|
type: t,
|
|
1730
|
-
reserved1: n(
|
|
1772
|
+
reserved1: n(R, 1, 6),
|
|
1731
1773
|
dataReferenceIndex: s(2),
|
|
1732
|
-
reserved2: n(
|
|
1774
|
+
reserved2: n(R, 4, 2),
|
|
1733
1775
|
channelcount: s(2),
|
|
1734
1776
|
samplesize: s(2),
|
|
1735
1777
|
preDefined: s(2),
|
|
@@ -1738,43 +1780,43 @@ function Ns(t, e) {
|
|
|
1738
1780
|
boxes: r()
|
|
1739
1781
|
};
|
|
1740
1782
|
}
|
|
1741
|
-
function
|
|
1783
|
+
function Fe(t, e) {
|
|
1742
1784
|
const { readArray: n, readUint: s, readInt: i, readTemplate: r, readBoxes: o } = e;
|
|
1743
1785
|
return {
|
|
1744
1786
|
type: t,
|
|
1745
|
-
reserved1: n(
|
|
1787
|
+
reserved1: n(R, 1, 6),
|
|
1746
1788
|
dataReferenceIndex: s(2),
|
|
1747
1789
|
preDefined1: s(2),
|
|
1748
1790
|
reserved2: s(2),
|
|
1749
|
-
preDefined2: n(
|
|
1791
|
+
preDefined2: n(R, 4, 3),
|
|
1750
1792
|
width: s(2),
|
|
1751
1793
|
height: s(2),
|
|
1752
1794
|
horizresolution: r(4),
|
|
1753
1795
|
vertresolution: r(4),
|
|
1754
1796
|
reserved3: s(4),
|
|
1755
1797
|
frameCount: s(2),
|
|
1756
|
-
compressorName: n(
|
|
1798
|
+
compressorName: n(R, 1, 32),
|
|
1757
1799
|
depth: s(2),
|
|
1758
1800
|
preDefined3: i(2),
|
|
1759
1801
|
boxes: o()
|
|
1760
1802
|
};
|
|
1761
1803
|
}
|
|
1762
|
-
function
|
|
1763
|
-
return
|
|
1804
|
+
function it(t) {
|
|
1805
|
+
return Fe("avc1", t);
|
|
1764
1806
|
}
|
|
1765
|
-
function
|
|
1766
|
-
return
|
|
1807
|
+
function Hs(t) {
|
|
1808
|
+
return Fe("hev1", t);
|
|
1767
1809
|
}
|
|
1768
|
-
function
|
|
1769
|
-
return
|
|
1810
|
+
function Gs(t) {
|
|
1811
|
+
return Fe("hvc1", t);
|
|
1770
1812
|
}
|
|
1771
|
-
function
|
|
1813
|
+
function Xs(t) {
|
|
1772
1814
|
return {
|
|
1773
1815
|
type: "mdat",
|
|
1774
1816
|
data: t.readData(-1)
|
|
1775
1817
|
};
|
|
1776
1818
|
}
|
|
1777
|
-
function
|
|
1819
|
+
function Ys(t) {
|
|
1778
1820
|
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), c = t.readUint(2);
|
|
1779
1821
|
return {
|
|
1780
1822
|
type: "mdhd",
|
|
@@ -1788,17 +1830,17 @@ function Zs(t) {
|
|
|
1788
1830
|
preDefined: t.readUint(2)
|
|
1789
1831
|
};
|
|
1790
1832
|
}
|
|
1791
|
-
function
|
|
1833
|
+
function Ks(t) {
|
|
1792
1834
|
return {
|
|
1793
1835
|
type: "mfhd",
|
|
1794
1836
|
...t.readFullBox(),
|
|
1795
1837
|
sequenceNumber: t.readUint(4)
|
|
1796
1838
|
};
|
|
1797
1839
|
}
|
|
1798
|
-
function
|
|
1799
|
-
return
|
|
1840
|
+
function Js(t) {
|
|
1841
|
+
return qs("mp4a", t);
|
|
1800
1842
|
}
|
|
1801
|
-
function
|
|
1843
|
+
function Qs(t) {
|
|
1802
1844
|
const { version: e, flags: n } = t.readFullBox(), s = t.readUint(4);
|
|
1803
1845
|
return {
|
|
1804
1846
|
type: "stsd",
|
|
@@ -1808,7 +1850,7 @@ function qs(t) {
|
|
|
1808
1850
|
entries: t.readBoxes(s)
|
|
1809
1851
|
};
|
|
1810
1852
|
}
|
|
1811
|
-
function
|
|
1853
|
+
function ei(t) {
|
|
1812
1854
|
const { version: e, flags: n } = t.readFullBox();
|
|
1813
1855
|
return {
|
|
1814
1856
|
type: "tfdt",
|
|
@@ -1817,7 +1859,7 @@ function Hs(t) {
|
|
|
1817
1859
|
baseMediaDecodeTime: t.readUint(e == 1 ? 8 : 4)
|
|
1818
1860
|
};
|
|
1819
1861
|
}
|
|
1820
|
-
function
|
|
1862
|
+
function ti(t) {
|
|
1821
1863
|
const { version: e, flags: n } = t.readFullBox();
|
|
1822
1864
|
return {
|
|
1823
1865
|
type: "tfhd",
|
|
@@ -1831,7 +1873,7 @@ function Gs(t) {
|
|
|
1831
1873
|
defaultSampleFlags: n & 32 ? t.readUint(4) : void 0
|
|
1832
1874
|
};
|
|
1833
1875
|
}
|
|
1834
|
-
function
|
|
1876
|
+
function ni(t) {
|
|
1835
1877
|
const { version: e, flags: n } = t.readFullBox(), s = e === 1 ? 8 : 4;
|
|
1836
1878
|
return {
|
|
1837
1879
|
type: "tkhd",
|
|
@@ -1842,17 +1884,17 @@ function Xs(t) {
|
|
|
1842
1884
|
trackId: t.readUint(4),
|
|
1843
1885
|
reserved1: t.readUint(4),
|
|
1844
1886
|
duration: t.readUint(s),
|
|
1845
|
-
reserved2: t.readArray(
|
|
1887
|
+
reserved2: t.readArray(R, 4, 2),
|
|
1846
1888
|
layer: t.readUint(2),
|
|
1847
1889
|
alternateGroup: t.readUint(2),
|
|
1848
1890
|
volume: t.readTemplate(2),
|
|
1849
1891
|
reserved3: t.readUint(2),
|
|
1850
|
-
matrix: t.readArray(
|
|
1892
|
+
matrix: t.readArray(ne, 4, 9),
|
|
1851
1893
|
width: t.readTemplate(4),
|
|
1852
1894
|
height: t.readTemplate(4)
|
|
1853
1895
|
};
|
|
1854
1896
|
}
|
|
1855
|
-
function
|
|
1897
|
+
function si(t) {
|
|
1856
1898
|
return {
|
|
1857
1899
|
type: "trex",
|
|
1858
1900
|
...t.readFullBox(),
|
|
@@ -1863,7 +1905,7 @@ function Ys(t) {
|
|
|
1863
1905
|
defaultSampleFlags: t.readUint(4)
|
|
1864
1906
|
};
|
|
1865
1907
|
}
|
|
1866
|
-
function
|
|
1908
|
+
function ii(t) {
|
|
1867
1909
|
const { version: e, flags: n } = t.readFullBox(), s = t.readUint(4);
|
|
1868
1910
|
let i, r;
|
|
1869
1911
|
n & 1 && (i = t.readInt(4)), n & 4 && (r = t.readUint(4));
|
|
@@ -1881,104 +1923,104 @@ function Ks(t) {
|
|
|
1881
1923
|
samples: o
|
|
1882
1924
|
};
|
|
1883
1925
|
}
|
|
1884
|
-
function
|
|
1885
|
-
const r = t.entries.length, { bytes: o, size: c } =
|
|
1926
|
+
function ri(t, e) {
|
|
1927
|
+
const r = t.entries.length, { bytes: o, size: c } = Oe(t.entries, e), a = new T("dref", 16 + c);
|
|
1886
1928
|
return a.writeFullBox(t.version, t.flags), a.writeUint(r, 4), a.writeBytes(o), a;
|
|
1887
1929
|
}
|
|
1888
|
-
function
|
|
1889
|
-
const i = t.compatibleBrands.length * 4, r = new
|
|
1930
|
+
function oi(t) {
|
|
1931
|
+
const i = t.compatibleBrands.length * 4, r = new T("ftyp", 16 + i);
|
|
1890
1932
|
r.writeString(t.majorBrand), r.writeUint(t.minorVersion, 4);
|
|
1891
1933
|
for (const o of t.compatibleBrands) r.writeString(o);
|
|
1892
1934
|
return r;
|
|
1893
1935
|
}
|
|
1894
|
-
function
|
|
1895
|
-
const o = t.name.length + 1, c = new
|
|
1896
|
-
return c.writeFullBox(t.version, t.flags), c.writeUint(t.preDefined, 4), c.writeString(t.handlerType), c.writeArray(t.reserved,
|
|
1936
|
+
function ai(t) {
|
|
1937
|
+
const o = t.name.length + 1, c = new T("hdlr", 32 + o);
|
|
1938
|
+
return c.writeFullBox(t.version, t.flags), c.writeUint(t.preDefined, 4), c.writeString(t.handlerType), c.writeArray(t.reserved, R, 4, 3), c.writeTerminatedString(t.name), c;
|
|
1897
1939
|
}
|
|
1898
|
-
function
|
|
1899
|
-
const e = new
|
|
1940
|
+
function ci(t) {
|
|
1941
|
+
const e = new T("mdat", 8 + t.data.length);
|
|
1900
1942
|
return e.writeBytes(t.data), e;
|
|
1901
1943
|
}
|
|
1902
|
-
function
|
|
1903
|
-
const e = t.version === 1 ? 8 : 4, n = 8, s = 4, i = e * 3, r = new
|
|
1944
|
+
function ui(t) {
|
|
1945
|
+
const e = t.version === 1 ? 8 : 4, n = 8, s = 4, i = e * 3, r = new T("mdhd", n + s + i + 4 + 2 + 2);
|
|
1904
1946
|
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);
|
|
1905
1947
|
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;
|
|
1906
1948
|
return r.writeUint(o, 2), r.writeUint(t.preDefined, 2), r;
|
|
1907
1949
|
}
|
|
1908
|
-
function
|
|
1909
|
-
const e = new
|
|
1950
|
+
function li(t) {
|
|
1951
|
+
const e = new T("mfhd", 16);
|
|
1910
1952
|
return e.writeFullBox(t.version, t.flags), e.writeUint(t.sequenceNumber, 4), e;
|
|
1911
1953
|
}
|
|
1912
|
-
function
|
|
1913
|
-
const e = t.version === 1 ? 8 : 4, n = 8, s = 4, i = e * 3, r = new
|
|
1914
|
-
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,
|
|
1954
|
+
function di(t) {
|
|
1955
|
+
const e = t.version === 1 ? 8 : 4, n = 8, s = 4, i = e * 3, r = new T("mvhd", n + s + i + 4 + 4 + 2 + 2 + 8 + 36 + 24 + 4);
|
|
1956
|
+
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, R, 4, 2), r.writeArray(t.matrix, ne, 4, 9), r.writeArray(t.preDefined, R, 4, 6), r.writeUint(t.nextTrackId, 4), r;
|
|
1915
1957
|
}
|
|
1916
|
-
function
|
|
1917
|
-
const e = new
|
|
1958
|
+
function hi(t) {
|
|
1959
|
+
const e = new T("smhd", 16);
|
|
1918
1960
|
return e.writeFullBox(t.version, t.flags), e.writeUint(t.balance, 2), e.writeUint(t.reserved, 2), e;
|
|
1919
1961
|
}
|
|
1920
|
-
function
|
|
1921
|
-
const r = t.entries.length, { bytes: o, size: c } =
|
|
1962
|
+
function fi(t, e) {
|
|
1963
|
+
const r = t.entries.length, { bytes: o, size: c } = Oe(t.entries, e), a = new T("stsd", 16 + c);
|
|
1922
1964
|
return a.writeFullBox(t.version, t.flags), a.writeUint(r, 4), a.writeBytes(o), a;
|
|
1923
1965
|
}
|
|
1924
|
-
function
|
|
1925
|
-
const i = t.entryCount * 8, r = new
|
|
1966
|
+
function mi(t) {
|
|
1967
|
+
const i = t.entryCount * 8, r = new T("stts", 16 + i);
|
|
1926
1968
|
r.writeFullBox(t.version, t.flags), r.writeUint(t.entryCount, 4);
|
|
1927
1969
|
for (const o of t.entries)
|
|
1928
1970
|
r.writeUint(o.sampleCount, 4), r.writeUint(o.sampleDelta, 4);
|
|
1929
1971
|
return r;
|
|
1930
1972
|
}
|
|
1931
|
-
function
|
|
1932
|
-
const e = t.version === 1 ? 8 : 4, n = 8, s = 4, i = e, r = new
|
|
1973
|
+
function pi(t) {
|
|
1974
|
+
const e = t.version === 1 ? 8 : 4, n = 8, s = 4, i = e, r = new T("tfdt", n + s + i);
|
|
1933
1975
|
return r.writeFullBox(t.version, t.flags), r.writeUint(t.baseMediaDecodeTime, e), r;
|
|
1934
1976
|
}
|
|
1935
|
-
function
|
|
1936
|
-
const i = t.flags & 1 ? 8 : 0, r = t.flags & 2 ? 4 : 0, o = t.flags & 8 ? 4 : 0, c = t.flags & 16 ? 4 : 0, a = t.flags & 32 ? 4 : 0, u = new
|
|
1977
|
+
function gi(t) {
|
|
1978
|
+
const i = t.flags & 1 ? 8 : 0, r = t.flags & 2 ? 4 : 0, o = t.flags & 8 ? 4 : 0, c = t.flags & 16 ? 4 : 0, a = t.flags & 32 ? 4 : 0, u = new T("tfhd", 16 + i + r + o + c + a);
|
|
1937
1979
|
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;
|
|
1938
1980
|
}
|
|
1939
|
-
function
|
|
1940
|
-
const e = t.version === 1 ? 8 : 4, n = 8, s = 4, i = e * 3, r = new
|
|
1941
|
-
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,
|
|
1981
|
+
function wi(t) {
|
|
1982
|
+
const e = t.version === 1 ? 8 : 4, n = 8, s = 4, i = e * 3, r = new T("tkhd", n + s + i + 4 + 4 + 8 + 2 + 2 + 2 + 2 + 36 + 4 + 4);
|
|
1983
|
+
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, R, 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, ne, 4, 9), r.writeTemplate(t.width, 4), r.writeTemplate(t.height, 4), r;
|
|
1942
1984
|
}
|
|
1943
|
-
function
|
|
1944
|
-
const e = new
|
|
1985
|
+
function yi(t) {
|
|
1986
|
+
const e = new T("trex", 32);
|
|
1945
1987
|
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;
|
|
1946
1988
|
}
|
|
1947
|
-
function
|
|
1989
|
+
function bi(t) {
|
|
1948
1990
|
const i = t.flags & 1 ? 4 : 0, r = t.flags & 4 ? 4 : 0;
|
|
1949
1991
|
let o = 0;
|
|
1950
1992
|
t.flags & 256 && (o += 4), t.flags & 512 && (o += 4), t.flags & 1024 && (o += 4), t.flags & 2048 && (o += 4);
|
|
1951
|
-
const c = o * t.sampleCount, a = new
|
|
1993
|
+
const c = o * t.sampleCount, a = new T("trun", 16 + i + r + c);
|
|
1952
1994
|
a.writeFullBox(t.version, t.flags), a.writeUint(t.sampleCount, 4), t.flags & 1 && a.writeUint(t.dataOffset ?? 0, 4), t.flags & 4 && a.writeUint(t.firstSampleFlags ?? 0, 4);
|
|
1953
1995
|
for (const u of t.samples)
|
|
1954
1996
|
t.flags & 256 && a.writeUint(u.sampleDuration ?? 0, 4), t.flags & 512 && a.writeUint(u.sampleSize ?? 0, 4), t.flags & 1024 && a.writeUint(u.sampleFlags ?? 0, 4), t.flags & 2048 && a.writeUint(u.sampleCompositionTimeOffset ?? 0, 4);
|
|
1955
1997
|
return a;
|
|
1956
1998
|
}
|
|
1957
|
-
function
|
|
1958
|
-
const s = t.location.length + 1, i = new
|
|
1999
|
+
function vi(t) {
|
|
2000
|
+
const s = t.location.length + 1, i = new T("url ", 12 + s);
|
|
1959
2001
|
return i.writeFullBox(t.version, t.flags), i.writeTerminatedString(t.location), i;
|
|
1960
2002
|
}
|
|
1961
|
-
function
|
|
1962
|
-
const e = new
|
|
1963
|
-
return e.writeFullBox(t.version, t.flags), e.writeUint(t.graphicsmode, 2), e.writeArray(t.opcolor,
|
|
2003
|
+
function Si(t) {
|
|
2004
|
+
const e = new T("vmhd", 20);
|
|
2005
|
+
return e.writeFullBox(t.version, t.flags), e.writeUint(t.graphicsmode, 2), e.writeArray(t.opcolor, R, 2, 3), e;
|
|
1964
2006
|
}
|
|
1965
|
-
const
|
|
1966
|
-
avc1:
|
|
1967
|
-
avc3:
|
|
2007
|
+
const Ai = {
|
|
2008
|
+
avc1: it,
|
|
2009
|
+
avc3: it,
|
|
1968
2010
|
// avc3 has same structure
|
|
1969
|
-
hvc1:
|
|
1970
|
-
hev1:
|
|
1971
|
-
mp4a:
|
|
1972
|
-
stsd:
|
|
1973
|
-
mdhd:
|
|
1974
|
-
tkhd:
|
|
1975
|
-
trex:
|
|
1976
|
-
},
|
|
1977
|
-
mfhd:
|
|
1978
|
-
tfhd:
|
|
1979
|
-
tfdt:
|
|
1980
|
-
trun:
|
|
1981
|
-
mdat:
|
|
2011
|
+
hvc1: Gs,
|
|
2012
|
+
hev1: Hs,
|
|
2013
|
+
mp4a: Js,
|
|
2014
|
+
stsd: Qs,
|
|
2015
|
+
mdhd: Ys,
|
|
2016
|
+
tkhd: ni,
|
|
2017
|
+
trex: si
|
|
2018
|
+
}, $t = {
|
|
2019
|
+
mfhd: Ks,
|
|
2020
|
+
tfhd: ti,
|
|
2021
|
+
tfdt: ei,
|
|
2022
|
+
trun: ii,
|
|
2023
|
+
mdat: Xs
|
|
1982
2024
|
};
|
|
1983
2025
|
function L(t, e) {
|
|
1984
2026
|
for (const n of t) {
|
|
@@ -1991,21 +2033,21 @@ function L(t, e) {
|
|
|
1991
2033
|
}
|
|
1992
2034
|
}
|
|
1993
2035
|
}
|
|
1994
|
-
function
|
|
2036
|
+
function $e(t) {
|
|
1995
2037
|
const e = new ArrayBuffer(t.byteLength);
|
|
1996
2038
|
return new Uint8Array(e).set(t), e;
|
|
1997
2039
|
}
|
|
1998
2040
|
function W(t) {
|
|
1999
2041
|
return (e) => e.type === t;
|
|
2000
2042
|
}
|
|
2001
|
-
function
|
|
2002
|
-
const e =
|
|
2043
|
+
function oe(t) {
|
|
2044
|
+
const e = Le($e(t), { readers: Ai }), n = L(e, W("mdhd"));
|
|
2003
2045
|
if (!n)
|
|
2004
2046
|
throw new Error("No mdhd box found in init segment");
|
|
2005
2047
|
const i = L(e, W("tkhd"))?.trackId ?? 1, r = L(e, W("stsd"));
|
|
2006
2048
|
if (!r?.entries || r.entries.length === 0)
|
|
2007
2049
|
throw new Error("No stsd box found in init segment");
|
|
2008
|
-
const o = r.entries[0], c =
|
|
2050
|
+
const o = r.entries[0], c = _i(o), a = L(
|
|
2009
2051
|
e,
|
|
2010
2052
|
(u) => u.type === "trex" && u.trackId === i
|
|
2011
2053
|
);
|
|
@@ -2018,7 +2060,7 @@ function ze(t) {
|
|
|
2018
2060
|
defaultSampleFlags: a?.defaultSampleFlags ?? 0
|
|
2019
2061
|
};
|
|
2020
2062
|
}
|
|
2021
|
-
function
|
|
2063
|
+
function _i(t) {
|
|
2022
2064
|
if (!(!t.boxes || !Array.isArray(t.boxes)))
|
|
2023
2065
|
for (const e of t.boxes) {
|
|
2024
2066
|
if (e instanceof Uint8Array) {
|
|
@@ -2027,7 +2069,7 @@ function gi(t) {
|
|
|
2027
2069
|
if (s === "avcC" || s === "hvcC" || s === "dOps")
|
|
2028
2070
|
return new Uint8Array(e.slice(8));
|
|
2029
2071
|
if (s === "esds")
|
|
2030
|
-
return
|
|
2072
|
+
return rt(new Uint8Array(e.slice(8)));
|
|
2031
2073
|
}
|
|
2032
2074
|
continue;
|
|
2033
2075
|
}
|
|
@@ -2048,11 +2090,11 @@ function gi(t) {
|
|
|
2048
2090
|
const i = e.view, r = 8;
|
|
2049
2091
|
s = new Uint8Array(i.buffer, i.byteOffset + r, e.size - r);
|
|
2050
2092
|
} else e.data instanceof Uint8Array ? s = new Uint8Array(e.data) : e.raw instanceof Uint8Array && (s = new Uint8Array(e.raw.slice(8)));
|
|
2051
|
-
if (s) return
|
|
2093
|
+
if (s) return rt(s);
|
|
2052
2094
|
}
|
|
2053
2095
|
}
|
|
2054
2096
|
}
|
|
2055
|
-
function
|
|
2097
|
+
function rt(t) {
|
|
2056
2098
|
let e = 4;
|
|
2057
2099
|
for (; e < t.length; ) {
|
|
2058
2100
|
const n = t[e++];
|
|
@@ -2066,12 +2108,12 @@ function st(t) {
|
|
|
2066
2108
|
n === 3 ? e += 3 : n === 4 ? e += 13 : e += s;
|
|
2067
2109
|
}
|
|
2068
2110
|
}
|
|
2069
|
-
function
|
|
2070
|
-
const n =
|
|
2111
|
+
function Pt(t, e) {
|
|
2112
|
+
const n = Le($e(t), { readers: $t });
|
|
2071
2113
|
return (L(n, W("tfdt"))?.baseMediaDecodeTime ?? 0) * 1e6 / e.timescale;
|
|
2072
2114
|
}
|
|
2073
|
-
function
|
|
2074
|
-
const n =
|
|
2115
|
+
function zi(t, e) {
|
|
2116
|
+
const n = Le($e(t), { readers: $t }), i = L(n, W("tfdt"))?.baseMediaDecodeTime ?? 0, r = L(n, W("tfhd")), o = r?.defaultSampleDuration ?? e.defaultSampleDuration, c = r?.defaultSampleSize ?? e.defaultSampleSize, a = r?.defaultSampleFlags ?? e.defaultSampleFlags, u = L(n, W("trun"));
|
|
2075
2117
|
if (!u)
|
|
2076
2118
|
throw new Error("No trun box found in data segment");
|
|
2077
2119
|
const l = L(n, W("mdat"));
|
|
@@ -2081,29 +2123,29 @@ function wi(t, e) {
|
|
|
2081
2123
|
if (!d)
|
|
2082
2124
|
throw new Error("No data in mdat box");
|
|
2083
2125
|
const f = [];
|
|
2084
|
-
let
|
|
2085
|
-
for (let
|
|
2086
|
-
const
|
|
2087
|
-
if (
|
|
2088
|
-
throw new Error(`Invalid sample size ${
|
|
2089
|
-
if (
|
|
2090
|
-
throw new Error(`Invalid sample duration ${
|
|
2091
|
-
if (
|
|
2126
|
+
let p = 0, b = i;
|
|
2127
|
+
for (let w = 0; w < u.sampleCount; w++) {
|
|
2128
|
+
const v = u.samples[w] ?? {}, _ = v.sampleSize ?? c, M = v.sampleDuration ?? o;
|
|
2129
|
+
if (_ <= 0)
|
|
2130
|
+
throw new Error(`Invalid sample size ${_} for sample ${w} in trun`);
|
|
2131
|
+
if (M < 0)
|
|
2132
|
+
throw new Error(`Invalid sample duration ${M} for sample ${w} in trun`);
|
|
2133
|
+
if (p + _ > d.length)
|
|
2092
2134
|
throw new Error(
|
|
2093
|
-
`Sample ${
|
|
2135
|
+
`Sample ${w} would overflow mdat: offset=${p}, size=${_}, mdatLength=${d.length}`
|
|
2094
2136
|
);
|
|
2095
|
-
const H =
|
|
2096
|
-
|
|
2097
|
-
const X =
|
|
2137
|
+
const H = w === 0 && u.firstSampleFlags !== void 0 ? u.firstSampleFlags : v.sampleFlags ?? a, P = v.sampleCompositionTimeOffset ?? 0, G = new Uint8Array(d.slice(p, p + _));
|
|
2138
|
+
p += _;
|
|
2139
|
+
const X = b + P, N = Math.round(X * 1e6 / e.timescale), k = H === 0 || (H & 65536) === 0;
|
|
2098
2140
|
f.push({
|
|
2099
2141
|
data: G,
|
|
2100
|
-
timestamp:
|
|
2101
|
-
keyframe:
|
|
2102
|
-
}),
|
|
2142
|
+
timestamp: N,
|
|
2143
|
+
keyframe: k
|
|
2144
|
+
}), b += M;
|
|
2103
2145
|
}
|
|
2104
2146
|
return f;
|
|
2105
2147
|
}
|
|
2106
|
-
function
|
|
2148
|
+
function $(t) {
|
|
2107
2149
|
if (t = t.startsWith("0x") ? t.slice(2) : t, t.length % 2)
|
|
2108
2150
|
throw new Error("invalid hex string length");
|
|
2109
2151
|
const e = t.match(/.{2}/g);
|
|
@@ -2111,53 +2153,53 @@ function N(t) {
|
|
|
2111
2153
|
throw new Error("invalid hex string format");
|
|
2112
2154
|
return new Uint8Array(e.map((n) => parseInt(n, 16)));
|
|
2113
2155
|
}
|
|
2114
|
-
const
|
|
2156
|
+
const Se = [65536, 0, 0, 0, 65536, 0, 0, 0, 1073741824], Mi = {
|
|
2115
2157
|
// Init segment boxes
|
|
2116
|
-
ftyp:
|
|
2117
|
-
mvhd:
|
|
2118
|
-
tkhd:
|
|
2119
|
-
mdhd:
|
|
2120
|
-
hdlr:
|
|
2121
|
-
vmhd:
|
|
2122
|
-
smhd:
|
|
2123
|
-
"url ":
|
|
2124
|
-
dref:
|
|
2125
|
-
stsd:
|
|
2126
|
-
stts:
|
|
2127
|
-
trex:
|
|
2158
|
+
ftyp: oi,
|
|
2159
|
+
mvhd: di,
|
|
2160
|
+
tkhd: wi,
|
|
2161
|
+
mdhd: ui,
|
|
2162
|
+
hdlr: ai,
|
|
2163
|
+
vmhd: Si,
|
|
2164
|
+
smhd: hi,
|
|
2165
|
+
"url ": vi,
|
|
2166
|
+
dref: ri,
|
|
2167
|
+
stsd: fi,
|
|
2168
|
+
stts: mi,
|
|
2169
|
+
trex: yi,
|
|
2128
2170
|
// Data segment boxes
|
|
2129
|
-
mfhd:
|
|
2130
|
-
tfhd:
|
|
2131
|
-
tfdt:
|
|
2132
|
-
trun:
|
|
2133
|
-
mdat:
|
|
2171
|
+
mfhd: li,
|
|
2172
|
+
tfhd: gi,
|
|
2173
|
+
tfdt: pi,
|
|
2174
|
+
trun: bi,
|
|
2175
|
+
mdat: ci
|
|
2134
2176
|
// For boxes without library writers, we create them manually as Uint8Arrays
|
|
2135
2177
|
};
|
|
2136
|
-
function
|
|
2137
|
-
return
|
|
2178
|
+
function he(t) {
|
|
2179
|
+
return Ws(t, { writers: Mi });
|
|
2138
2180
|
}
|
|
2139
|
-
function
|
|
2181
|
+
function Pe(t, e, n, s) {
|
|
2140
2182
|
const i = 12 + s.length, r = new Uint8Array(i), o = new DataView(r.buffer);
|
|
2141
2183
|
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;
|
|
2142
2184
|
}
|
|
2143
|
-
function
|
|
2185
|
+
function Nt() {
|
|
2144
2186
|
const t = new Uint8Array(4);
|
|
2145
|
-
return
|
|
2187
|
+
return Pe("stsc", 0, 0, t);
|
|
2146
2188
|
}
|
|
2147
|
-
function
|
|
2189
|
+
function jt() {
|
|
2148
2190
|
const t = new Uint8Array(8);
|
|
2149
|
-
return
|
|
2191
|
+
return Pe("stsz", 0, 0, t);
|
|
2150
2192
|
}
|
|
2151
|
-
function
|
|
2193
|
+
function Zt() {
|
|
2152
2194
|
const t = new Uint8Array(4);
|
|
2153
|
-
return
|
|
2195
|
+
return Pe("stco", 0, 0, t);
|
|
2154
2196
|
}
|
|
2155
|
-
function
|
|
2197
|
+
function ki(t, e, n) {
|
|
2156
2198
|
const s = 8 + n.length, r = 8 + (78 + s), o = new Uint8Array(r), c = new DataView(o.buffer);
|
|
2157
2199
|
let a = 0;
|
|
2158
2200
|
return c.setUint32(a, r, !1), a += 4, o[a++] = 97, o[a++] = 118, o[a++] = 99, o[a++] = 49, a += 6, c.setUint16(a, 1, !1), a += 2, c.setUint16(a, 0, !1), a += 2, c.setUint16(a, 0, !1), a += 2, a += 12, c.setUint16(a, t, !1), a += 2, c.setUint16(a, e, !1), a += 2, c.setUint32(a, 4718592, !1), a += 4, c.setUint32(a, 4718592, !1), a += 4, c.setUint32(a, 0, !1), a += 4, c.setUint16(a, 1, !1), a += 2, a += 32, c.setUint16(a, 24, !1), a += 2, c.setUint16(a, 65535, !1), a += 2, c.setUint32(a, s, !1), a += 4, o[a++] = 97, o[a++] = 118, o[a++] = 99, o[a++] = 67, o.set(n, a), o;
|
|
2159
2201
|
}
|
|
2160
|
-
function
|
|
2202
|
+
function Ti(t) {
|
|
2161
2203
|
const { codedWidth: e, codedHeight: n, description: s } = t;
|
|
2162
2204
|
if (!e || !n || !s)
|
|
2163
2205
|
throw new Error("Missing required fields to create video init segment");
|
|
@@ -2181,7 +2223,7 @@ function vi(t) {
|
|
|
2181
2223
|
// 1.0 in 8.8 fixed point
|
|
2182
2224
|
reserved1: 0,
|
|
2183
2225
|
reserved2: [0, 0],
|
|
2184
|
-
matrix:
|
|
2226
|
+
matrix: Se,
|
|
2185
2227
|
preDefined: [0, 0, 0, 0, 0, 0],
|
|
2186
2228
|
nextTrackId: r + 1
|
|
2187
2229
|
}, a = {
|
|
@@ -2200,7 +2242,7 @@ function vi(t) {
|
|
|
2200
2242
|
volume: 0,
|
|
2201
2243
|
// Video tracks have 0 volume
|
|
2202
2244
|
reserved3: 0,
|
|
2203
|
-
matrix:
|
|
2245
|
+
matrix: Se,
|
|
2204
2246
|
width: e * 65536,
|
|
2205
2247
|
// 16.16 fixed point (avoid << which produces signed int)
|
|
2206
2248
|
height: n * 65536
|
|
@@ -2229,7 +2271,7 @@ function vi(t) {
|
|
|
2229
2271
|
// Required to be 1
|
|
2230
2272
|
graphicsmode: 0,
|
|
2231
2273
|
opcolor: [0, 0, 0]
|
|
2232
|
-
},
|
|
2274
|
+
}, b = {
|
|
2233
2275
|
type: "dinf",
|
|
2234
2276
|
boxes: [{
|
|
2235
2277
|
type: "dref",
|
|
@@ -2244,20 +2286,20 @@ function vi(t) {
|
|
|
2244
2286
|
location: ""
|
|
2245
2287
|
}]
|
|
2246
2288
|
}]
|
|
2247
|
-
},
|
|
2289
|
+
}, v = {
|
|
2248
2290
|
type: "stsd",
|
|
2249
2291
|
version: 0,
|
|
2250
2292
|
flags: 0,
|
|
2251
2293
|
entryCount: 1,
|
|
2252
2294
|
// biome-ignore lint/suspicious/noExplicitAny: Raw avc1 box since library doesn't handle avcC children
|
|
2253
|
-
entries: [
|
|
2254
|
-
},
|
|
2295
|
+
entries: [ki(e, n, $(s))]
|
|
2296
|
+
}, _ = {
|
|
2255
2297
|
type: "stts",
|
|
2256
2298
|
version: 0,
|
|
2257
2299
|
flags: 0,
|
|
2258
2300
|
entryCount: 0,
|
|
2259
2301
|
entries: []
|
|
2260
|
-
},
|
|
2302
|
+
}, M = Nt(), H = jt(), P = Zt(), Ue = he([o, {
|
|
2261
2303
|
type: "moov",
|
|
2262
2304
|
boxes: [c, {
|
|
2263
2305
|
type: "trak",
|
|
@@ -2265,10 +2307,10 @@ function vi(t) {
|
|
|
2265
2307
|
type: "mdia",
|
|
2266
2308
|
boxes: [u, l, {
|
|
2267
2309
|
type: "minf",
|
|
2268
|
-
boxes: [d,
|
|
2310
|
+
boxes: [d, b, {
|
|
2269
2311
|
type: "stbl",
|
|
2270
2312
|
// biome-ignore lint/suspicious/noExplicitAny: Raw boxes for types without library writers
|
|
2271
|
-
boxes: [
|
|
2313
|
+
boxes: [v, _, M, H, P]
|
|
2272
2314
|
}]
|
|
2273
2315
|
}]
|
|
2274
2316
|
}]
|
|
@@ -2285,13 +2327,13 @@ function vi(t) {
|
|
|
2285
2327
|
defaultSampleFlags: 0
|
|
2286
2328
|
}]
|
|
2287
2329
|
}]
|
|
2288
|
-
}]),
|
|
2289
|
-
let
|
|
2290
|
-
for (const F of
|
|
2291
|
-
|
|
2292
|
-
return
|
|
2330
|
+
}]), me = Ue.reduce((F, j) => F + j.byteLength, 0), pe = new Uint8Array(me);
|
|
2331
|
+
let ae = 0;
|
|
2332
|
+
for (const F of Ue)
|
|
2333
|
+
pe.set(new Uint8Array(F.buffer, F.byteOffset, F.byteLength), ae), ae += F.byteLength;
|
|
2334
|
+
return pe;
|
|
2293
2335
|
}
|
|
2294
|
-
function
|
|
2336
|
+
function Ui(t) {
|
|
2295
2337
|
const { sampleRate: e, numberOfChannels: n, description: s, codec: i } = t, r = 1e6, o = 1, c = {
|
|
2296
2338
|
type: "ftyp",
|
|
2297
2339
|
majorBrand: "isom",
|
|
@@ -2309,7 +2351,7 @@ function Si(t) {
|
|
|
2309
2351
|
volume: 256,
|
|
2310
2352
|
reserved1: 0,
|
|
2311
2353
|
reserved2: [0, 0],
|
|
2312
|
-
matrix:
|
|
2354
|
+
matrix: Se,
|
|
2313
2355
|
preDefined: [0, 0, 0, 0, 0, 0],
|
|
2314
2356
|
nextTrackId: o + 1
|
|
2315
2357
|
}, u = {
|
|
@@ -2327,7 +2369,7 @@ function Si(t) {
|
|
|
2327
2369
|
volume: 256,
|
|
2328
2370
|
// Audio tracks have volume (1.0 in 8.8 fixed point)
|
|
2329
2371
|
reserved3: 0,
|
|
2330
|
-
matrix:
|
|
2372
|
+
matrix: Se,
|
|
2331
2373
|
width: 0,
|
|
2332
2374
|
height: 0
|
|
2333
2375
|
}, l = {
|
|
@@ -2354,7 +2396,7 @@ function Si(t) {
|
|
|
2354
2396
|
flags: 0,
|
|
2355
2397
|
balance: 0,
|
|
2356
2398
|
reserved: 0
|
|
2357
|
-
},
|
|
2399
|
+
}, w = {
|
|
2358
2400
|
type: "dinf",
|
|
2359
2401
|
boxes: [{
|
|
2360
2402
|
type: "dref",
|
|
@@ -2368,20 +2410,20 @@ function Si(t) {
|
|
|
2368
2410
|
location: ""
|
|
2369
2411
|
}]
|
|
2370
2412
|
}]
|
|
2371
|
-
},
|
|
2413
|
+
}, _ = {
|
|
2372
2414
|
type: "stsd",
|
|
2373
2415
|
version: 0,
|
|
2374
2416
|
flags: 0,
|
|
2375
2417
|
entryCount: 1,
|
|
2376
2418
|
// biome-ignore lint/suspicious/noExplicitAny: Raw sample entry box
|
|
2377
|
-
entries: [
|
|
2378
|
-
},
|
|
2419
|
+
entries: [Ei(i, e, n, s)]
|
|
2420
|
+
}, M = {
|
|
2379
2421
|
type: "stts",
|
|
2380
2422
|
version: 0,
|
|
2381
2423
|
flags: 0,
|
|
2382
2424
|
entryCount: 0,
|
|
2383
2425
|
entries: []
|
|
2384
|
-
}, H =
|
|
2426
|
+
}, H = Nt(), P = jt(), G = Zt(), me = he([c, {
|
|
2385
2427
|
type: "moov",
|
|
2386
2428
|
boxes: [a, {
|
|
2387
2429
|
type: "trak",
|
|
@@ -2389,10 +2431,10 @@ function Si(t) {
|
|
|
2389
2431
|
type: "mdia",
|
|
2390
2432
|
boxes: [l, d, {
|
|
2391
2433
|
type: "minf",
|
|
2392
|
-
boxes: [f,
|
|
2434
|
+
boxes: [f, w, {
|
|
2393
2435
|
type: "stbl",
|
|
2394
2436
|
// biome-ignore lint/suspicious/noExplicitAny: Raw boxes for types without library writers
|
|
2395
|
-
boxes: [
|
|
2437
|
+
boxes: [_, M, H, P, G]
|
|
2396
2438
|
}]
|
|
2397
2439
|
}]
|
|
2398
2440
|
}]
|
|
@@ -2409,30 +2451,30 @@ function Si(t) {
|
|
|
2409
2451
|
defaultSampleFlags: 0
|
|
2410
2452
|
}]
|
|
2411
2453
|
}]
|
|
2412
|
-
}]),
|
|
2454
|
+
}]), pe = me.reduce((j, Qt) => j + Qt.byteLength, 0), ae = new Uint8Array(pe);
|
|
2413
2455
|
let F = 0;
|
|
2414
|
-
for (const j of
|
|
2415
|
-
|
|
2416
|
-
return
|
|
2456
|
+
for (const j of me)
|
|
2457
|
+
ae.set(new Uint8Array(j.buffer, j.byteOffset, j.byteLength), F), F += j.byteLength;
|
|
2458
|
+
return ae;
|
|
2417
2459
|
}
|
|
2418
|
-
function
|
|
2460
|
+
function Ei(t, e, n, s) {
|
|
2419
2461
|
if (t.startsWith("mp4a"))
|
|
2420
|
-
return
|
|
2462
|
+
return xi(e, n, s);
|
|
2421
2463
|
if (t === "opus")
|
|
2422
|
-
return
|
|
2464
|
+
return Bi(e, n, s);
|
|
2423
2465
|
throw new Error(`Unsupported audio codec: ${t}`);
|
|
2424
2466
|
}
|
|
2425
|
-
function
|
|
2426
|
-
const s =
|
|
2467
|
+
function xi(t, e, n) {
|
|
2468
|
+
const s = Ci(t, e, n), r = 8 + (28 + s.length), o = new Uint8Array(r), c = new DataView(o.buffer);
|
|
2427
2469
|
let a = 0;
|
|
2428
2470
|
return c.setUint32(a, r, !1), a += 4, o[a++] = 109, o[a++] = 112, o[a++] = 52, o[a++] = 97, a += 6, c.setUint16(a, 1, !1), a += 2, a += 8, c.setUint16(a, e, !1), a += 2, c.setUint16(a, 16, !1), a += 2, c.setUint16(a, 0, !1), a += 2, c.setUint16(a, 0, !1), a += 2, c.setUint32(a, t * 65536, !1), a += 4, o.set(s, a), o;
|
|
2429
2471
|
}
|
|
2430
|
-
function
|
|
2431
|
-
const s =
|
|
2472
|
+
function Bi(t, e, n) {
|
|
2473
|
+
const s = Ii(e, t, n), r = 8 + (28 + s.length), o = new Uint8Array(r), c = new DataView(o.buffer);
|
|
2432
2474
|
let a = 0;
|
|
2433
2475
|
return c.setUint32(a, r, !1), a += 4, o[a++] = 79, o[a++] = 112, o[a++] = 117, o[a++] = 115, a += 6, c.setUint16(a, 1, !1), a += 2, a += 8, c.setUint16(a, e, !1), a += 2, c.setUint16(a, 16, !1), a += 2, c.setUint16(a, 0, !1), a += 2, c.setUint16(a, 0, !1), a += 2, c.setUint32(a, t * 65536, !1), a += 4, o.set(s, a), o;
|
|
2434
2476
|
}
|
|
2435
|
-
function
|
|
2477
|
+
function Ri(t, e) {
|
|
2436
2478
|
const s = {
|
|
2437
2479
|
96e3: 0,
|
|
2438
2480
|
88200: 1,
|
|
@@ -2450,21 +2492,21 @@ function Mi(t, e) {
|
|
|
2450
2492
|
}[t] ?? 4, r = 2 << 3 | s >> 1, o = (s & 1) << 7 | e << 3;
|
|
2451
2493
|
return new Uint8Array([r, o]);
|
|
2452
2494
|
}
|
|
2453
|
-
function
|
|
2454
|
-
const s = n ?
|
|
2495
|
+
function Ci(t, e, n) {
|
|
2496
|
+
const s = n ? $(n) : Ri(t, e), i = s.length, r = 15 + i, o = 5 + r + 3, c = 14 + o, a = new Uint8Array(c), u = new DataView(a.buffer);
|
|
2455
2497
|
let l = 0;
|
|
2456
2498
|
return u.setUint32(l, c, !1), l += 4, a[l++] = 101, a[l++] = 115, a[l++] = 100, a[l++] = 115, u.setUint32(l, 0, !1), l += 4, a[l++] = 3, a[l++] = o, u.setUint16(l, 0, !1), l += 2, a[l++] = 0, a[l++] = 4, a[l++] = r, a[l++] = 64, a[l++] = 21, a[l++] = 0, a[l++] = 0, a[l++] = 0, u.setUint32(l, 0, !1), l += 4, u.setUint32(l, 0, !1), l += 4, a[l++] = 5, a[l++] = i, a.set(s, l), l += i, a[l++] = 6, a[l++] = 1, a[l++] = 2, a;
|
|
2457
2499
|
}
|
|
2458
|
-
function
|
|
2500
|
+
function Ii(t, e, n) {
|
|
2459
2501
|
if (n) {
|
|
2460
|
-
const c =
|
|
2502
|
+
const c = $(n), a = 8 + c.length, u = new Uint8Array(a);
|
|
2461
2503
|
return new DataView(u.buffer).setUint32(0, a, !1), u[4] = 100, u[5] = 79, u[6] = 112, u[7] = 115, u.set(c, 8), u;
|
|
2462
2504
|
}
|
|
2463
2505
|
const s = 19, i = new Uint8Array(s), r = new DataView(i.buffer);
|
|
2464
2506
|
let o = 0;
|
|
2465
2507
|
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;
|
|
2466
2508
|
}
|
|
2467
|
-
function
|
|
2509
|
+
function Vt(t) {
|
|
2468
2510
|
const { data: e, timestamp: n, duration: s, keyframe: i, sequence: r, trackId: o = 1 } = t, c = i ? 33554432 : 16842752, a = {
|
|
2469
2511
|
type: "mfhd",
|
|
2470
2512
|
version: 0,
|
|
@@ -2495,52 +2537,52 @@ function $t(t) {
|
|
|
2495
2537
|
sampleFlags: c
|
|
2496
2538
|
}
|
|
2497
2539
|
]
|
|
2498
|
-
},
|
|
2540
|
+
}, p = {
|
|
2499
2541
|
type: "moof",
|
|
2500
2542
|
boxes: [a, {
|
|
2501
2543
|
type: "traf",
|
|
2502
2544
|
boxes: [u, l, d]
|
|
2503
2545
|
}]
|
|
2504
|
-
},
|
|
2505
|
-
let
|
|
2506
|
-
for (const
|
|
2507
|
-
|
|
2508
|
-
d.dataOffset =
|
|
2509
|
-
const
|
|
2510
|
-
|
|
2511
|
-
for (const
|
|
2512
|
-
|
|
2513
|
-
const
|
|
2514
|
-
|
|
2515
|
-
const P =
|
|
2546
|
+
}, b = he([p]);
|
|
2547
|
+
let w = 0;
|
|
2548
|
+
for (const k of b)
|
|
2549
|
+
w += k.byteLength;
|
|
2550
|
+
d.dataOffset = w + 8;
|
|
2551
|
+
const v = he([p]);
|
|
2552
|
+
w = 0;
|
|
2553
|
+
for (const k of v)
|
|
2554
|
+
w += k.byteLength;
|
|
2555
|
+
const _ = new ArrayBuffer(e.byteLength), M = new Uint8Array(_);
|
|
2556
|
+
M.set(e);
|
|
2557
|
+
const P = he([{
|
|
2516
2558
|
type: "mdat",
|
|
2517
|
-
data:
|
|
2559
|
+
data: M
|
|
2518
2560
|
}]);
|
|
2519
2561
|
let G = 0;
|
|
2520
|
-
for (const
|
|
2521
|
-
G +=
|
|
2522
|
-
const X = new Uint8Array(
|
|
2523
|
-
let
|
|
2524
|
-
for (const
|
|
2525
|
-
X.set(new Uint8Array(
|
|
2526
|
-
for (const
|
|
2527
|
-
X.set(new Uint8Array(
|
|
2562
|
+
for (const k of P)
|
|
2563
|
+
G += k.byteLength;
|
|
2564
|
+
const X = new Uint8Array(w + G);
|
|
2565
|
+
let N = 0;
|
|
2566
|
+
for (const k of v)
|
|
2567
|
+
X.set(new Uint8Array(k.buffer, k.byteOffset, k.byteLength), N), N += k.byteLength;
|
|
2568
|
+
for (const k of P)
|
|
2569
|
+
X.set(new Uint8Array(k.buffer, k.byteOffset, k.byteLength), N), N += k.byteLength;
|
|
2528
2570
|
return X;
|
|
2529
2571
|
}
|
|
2530
|
-
let
|
|
2572
|
+
let Wt = class {
|
|
2531
2573
|
#e;
|
|
2532
2574
|
constructor(e) {
|
|
2533
2575
|
this.#e = e;
|
|
2534
2576
|
}
|
|
2535
2577
|
decode(e) {
|
|
2536
|
-
return
|
|
2578
|
+
return zi(e, this.#e).map((n) => ({
|
|
2537
2579
|
data: n.data,
|
|
2538
2580
|
timestamp: n.timestamp,
|
|
2539
2581
|
keyframe: n.keyframe
|
|
2540
2582
|
}));
|
|
2541
2583
|
}
|
|
2542
2584
|
};
|
|
2543
|
-
class
|
|
2585
|
+
class se {
|
|
2544
2586
|
#e;
|
|
2545
2587
|
#t;
|
|
2546
2588
|
#n;
|
|
@@ -2553,7 +2595,7 @@ class ne {
|
|
|
2553
2595
|
buffered = this.#a;
|
|
2554
2596
|
#o = new E();
|
|
2555
2597
|
constructor(e, n) {
|
|
2556
|
-
this.#e = e, this.#t = n.format, this.#n = h.from(n.latency ??
|
|
2598
|
+
this.#e = e, this.#t = n.format, this.#n = h.from(n.latency ?? A.Time.Milli.zero), this.#o.spawn(this.#c.bind(this)), this.#o.cleanup(() => {
|
|
2557
2599
|
this.#e.close();
|
|
2558
2600
|
for (const s of this.#s)
|
|
2559
2601
|
s.consumer.close();
|
|
@@ -2603,7 +2645,7 @@ class ne {
|
|
|
2603
2645
|
if (this.#i === void 0) return;
|
|
2604
2646
|
let e = !1;
|
|
2605
2647
|
for (; this.#s.length >= 2; ) {
|
|
2606
|
-
const n =
|
|
2648
|
+
const n = A.Time.Micro.fromMilli(this.#n.peek());
|
|
2607
2649
|
let s, i;
|
|
2608
2650
|
for (const c of this.#s) {
|
|
2609
2651
|
if (c.latest === void 0) continue;
|
|
@@ -2622,25 +2664,27 @@ class ne {
|
|
|
2622
2664
|
async next() {
|
|
2623
2665
|
for (; ; ) {
|
|
2624
2666
|
if (this.#s.length > 0 && this.#i !== void 0 && this.#s[0].consumer.sequence <= this.#i) {
|
|
2625
|
-
const
|
|
2626
|
-
if (
|
|
2627
|
-
return this.#l(), { frame:
|
|
2667
|
+
const s = this.#s[0].frames.shift();
|
|
2668
|
+
if (s)
|
|
2669
|
+
return this.#l(), { frame: s, group: this.#s[0].consumer.sequence };
|
|
2628
2670
|
if (this.#i > this.#s[0].consumer.sequence || this.#s[0].done) {
|
|
2629
2671
|
this.#s[0].consumer.sequence === this.#i && (this.#i += 1);
|
|
2630
|
-
const
|
|
2631
|
-
if (
|
|
2632
|
-
return this.#l(), { frame: void 0, group:
|
|
2672
|
+
const i = this.#s.shift();
|
|
2673
|
+
if (i)
|
|
2674
|
+
return this.#l(), { frame: void 0, group: i.consumer.sequence };
|
|
2633
2675
|
}
|
|
2634
2676
|
}
|
|
2635
2677
|
if (this.#r)
|
|
2636
2678
|
throw new Error("multiple calls to next not supported");
|
|
2637
|
-
const e =
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
this.#r =
|
|
2642
|
-
|
|
2643
|
-
|
|
2679
|
+
const e = this.#o.abort;
|
|
2680
|
+
if (e.aborted) return;
|
|
2681
|
+
const n = await new Promise((s) => {
|
|
2682
|
+
const i = () => s(!0);
|
|
2683
|
+
e.addEventListener("abort", i, { once: !0 }), this.#r = () => {
|
|
2684
|
+
e.removeEventListener("abort", i), s(!1);
|
|
2685
|
+
};
|
|
2686
|
+
});
|
|
2687
|
+
if (this.#r = void 0, n) return;
|
|
2644
2688
|
}
|
|
2645
2689
|
}
|
|
2646
2690
|
#l() {
|
|
@@ -2649,8 +2693,8 @@ class ne {
|
|
|
2649
2693
|
for (const s of this.#s) {
|
|
2650
2694
|
const i = s.frames.at(0);
|
|
2651
2695
|
if (!i || s.latest === void 0) continue;
|
|
2652
|
-
const r =
|
|
2653
|
-
c && (c.end >= r || a) ? c.end =
|
|
2696
|
+
const r = A.Time.Milli.fromMicro(i.timestamp), o = A.Time.Milli.fromMicro(s.latest), c = e.at(-1), a = n?.done && n.consumer.sequence + 1 === s.consumer.sequence;
|
|
2697
|
+
c && (c.end >= r || a) ? c.end = A.Time.Milli.max(c.end, o) : e.push({ start: r, end: o }), n = s;
|
|
2654
2698
|
}
|
|
2655
2699
|
this.#a.set(e);
|
|
2656
2700
|
}
|
|
@@ -2658,59 +2702,59 @@ class ne {
|
|
|
2658
2702
|
this.#o.close();
|
|
2659
2703
|
}
|
|
2660
2704
|
}
|
|
2661
|
-
class
|
|
2705
|
+
class Te {
|
|
2662
2706
|
decode(e) {
|
|
2663
|
-
const [n, s] =
|
|
2707
|
+
const [n, s] = A.Varint.decode(e);
|
|
2664
2708
|
return [{ data: s, timestamp: n, keyframe: !1 }];
|
|
2665
2709
|
}
|
|
2666
2710
|
}
|
|
2667
|
-
function
|
|
2711
|
+
function Ae(t, e) {
|
|
2668
2712
|
if (t.length === 0) return e;
|
|
2669
2713
|
if (e.length === 0) return t;
|
|
2670
2714
|
const n = [], s = [...t, ...e].sort((i, r) => i.start - r.start);
|
|
2671
2715
|
for (const i of s) {
|
|
2672
2716
|
const r = n.at(-1);
|
|
2673
|
-
r && r.end >= i.start ? r.end =
|
|
2717
|
+
r && r.end >= i.start ? r.end = g.Milli.max(r.end, i.end) : n.push({ ...i });
|
|
2674
2718
|
}
|
|
2675
2719
|
return n;
|
|
2676
2720
|
}
|
|
2677
|
-
let
|
|
2678
|
-
async function
|
|
2679
|
-
return globalThis.AudioEncoder && globalThis.AudioDecoder ? !0 : (
|
|
2721
|
+
let xe;
|
|
2722
|
+
async function ot() {
|
|
2723
|
+
return globalThis.AudioEncoder && globalThis.AudioDecoder ? !0 : (xe || (console.warn("using Opus polyfill; performance may be degraded"), xe = Promise.all([
|
|
2680
2724
|
import("./libav-opus-af-BlMWboA7.js"),
|
|
2681
2725
|
import("./main-DGBFe0O7.js")
|
|
2682
2726
|
]).then(async ([t, e]) => (await e.load({
|
|
2683
2727
|
LibAV: t,
|
|
2684
2728
|
polyfill: !0
|
|
2685
|
-
}), !0))), await
|
|
2729
|
+
}), !0))), await xe);
|
|
2686
2730
|
}
|
|
2687
|
-
function
|
|
2731
|
+
function K(t) {
|
|
2688
2732
|
const e = atob(t), n = new Uint8Array(e.length);
|
|
2689
2733
|
for (let s = 0; s < e.length; s++) n[s] = e.charCodeAt(s);
|
|
2690
2734
|
return n;
|
|
2691
2735
|
}
|
|
2692
|
-
const Z = 0, O = 1,
|
|
2693
|
-
function
|
|
2736
|
+
const Z = 0, O = 1, ce = 2, J = 3, Di = 4;
|
|
2737
|
+
function qt(t, e, n) {
|
|
2694
2738
|
if (t <= 0) throw new Error("invalid channels");
|
|
2695
2739
|
if (e <= 0) throw new Error("invalid capacity");
|
|
2696
2740
|
if (n <= 0) throw new Error("invalid sample rate");
|
|
2697
|
-
const s = new SharedArrayBuffer(t * e * Float32Array.BYTES_PER_ELEMENT), i = new SharedArrayBuffer(
|
|
2698
|
-
return Atomics.store(r,
|
|
2741
|
+
const s = new SharedArrayBuffer(t * e * Float32Array.BYTES_PER_ELEMENT), i = new SharedArrayBuffer(Di * Int32Array.BYTES_PER_ELEMENT), r = new Int32Array(i);
|
|
2742
|
+
return Atomics.store(r, J, 1), { channels: t, capacity: e, rate: n, samples: s, control: i };
|
|
2699
2743
|
}
|
|
2700
|
-
function
|
|
2744
|
+
function Oi(t, e) {
|
|
2701
2745
|
return (t - e | 0) > 0 ? t : e;
|
|
2702
2746
|
}
|
|
2703
|
-
function
|
|
2747
|
+
function ue(t, e) {
|
|
2704
2748
|
return (t % e + e) % e;
|
|
2705
2749
|
}
|
|
2706
|
-
function
|
|
2750
|
+
function Be(t, e, n) {
|
|
2707
2751
|
for (; ; ) {
|
|
2708
2752
|
const s = Atomics.load(t, e);
|
|
2709
2753
|
if ((n - s | 0) <= 0) return s;
|
|
2710
2754
|
if (Atomics.compareExchange(t, e, s, n) === s) return n;
|
|
2711
2755
|
}
|
|
2712
2756
|
}
|
|
2713
|
-
class
|
|
2757
|
+
class Ne {
|
|
2714
2758
|
channels;
|
|
2715
2759
|
capacity;
|
|
2716
2760
|
rate;
|
|
@@ -2730,7 +2774,7 @@ class Pe {
|
|
|
2730
2774
|
*/
|
|
2731
2775
|
insert(e, n) {
|
|
2732
2776
|
if (n.length !== this.channels) throw new Error("wrong number of channels");
|
|
2733
|
-
let s = Math.round(
|
|
2777
|
+
let s = Math.round(g.Second.fromMicro(e) * this.rate);
|
|
2734
2778
|
const i = n[0].length;
|
|
2735
2779
|
let r = 0;
|
|
2736
2780
|
const o = s + i | 0, c = Atomics.load(this.#e, O), a = c - s | 0;
|
|
@@ -2740,49 +2784,49 @@ class Pe {
|
|
|
2740
2784
|
r = a, s = s + a | 0;
|
|
2741
2785
|
}
|
|
2742
2786
|
const u = i - r;
|
|
2743
|
-
(o - c | 0) > this.capacity &&
|
|
2787
|
+
(o - c | 0) > this.capacity && Be(this.#e, O, o - this.capacity | 0);
|
|
2744
2788
|
const l = Atomics.load(this.#e, Z), d = s - l | 0;
|
|
2745
2789
|
if (d > 0) {
|
|
2746
|
-
const
|
|
2747
|
-
for (let
|
|
2748
|
-
const
|
|
2749
|
-
for (let
|
|
2750
|
-
|
|
2790
|
+
const w = Math.min(d, this.capacity);
|
|
2791
|
+
for (let v = 0; v < this.channels; v++) {
|
|
2792
|
+
const _ = this.#t[v];
|
|
2793
|
+
for (let M = 0; M < w; M++)
|
|
2794
|
+
_[ue(l + M | 0, this.capacity)] = 0;
|
|
2751
2795
|
}
|
|
2752
2796
|
}
|
|
2753
|
-
for (let
|
|
2754
|
-
const
|
|
2755
|
-
for (let
|
|
2756
|
-
|
|
2797
|
+
for (let w = 0; w < this.channels; w++) {
|
|
2798
|
+
const v = n[w], _ = this.#t[w];
|
|
2799
|
+
for (let M = 0; M < u; M++)
|
|
2800
|
+
_[ue(s + M | 0, this.capacity)] = v[r + M];
|
|
2757
2801
|
}
|
|
2758
|
-
Atomics.store(this.#e, Z,
|
|
2759
|
-
const f = Atomics.load(this.#e, O),
|
|
2760
|
-
(
|
|
2802
|
+
Atomics.store(this.#e, Z, Oi(Atomics.load(this.#e, Z), o));
|
|
2803
|
+
const f = Atomics.load(this.#e, O), p = Atomics.load(this.#e, Z), b = Atomics.load(this.#e, ce);
|
|
2804
|
+
(p - f | 0) >= b && b > 0 && Atomics.store(this.#e, J, 0);
|
|
2761
2805
|
}
|
|
2762
2806
|
/**
|
|
2763
2807
|
* Read audio samples into the output buffers.
|
|
2764
2808
|
* AudioWorklet only. Returns the number of samples read.
|
|
2765
2809
|
*/
|
|
2766
2810
|
read(e) {
|
|
2767
|
-
if (Atomics.load(this.#e,
|
|
2811
|
+
if (Atomics.load(this.#e, J) === 1) return 0;
|
|
2768
2812
|
let n = Atomics.load(this.#e, O);
|
|
2769
|
-
const s = Atomics.load(this.#e, Z), i = Atomics.load(this.#e,
|
|
2813
|
+
const s = Atomics.load(this.#e, Z), i = Atomics.load(this.#e, ce), r = s - n | 0;
|
|
2770
2814
|
if (i > 0 && r > i) {
|
|
2771
2815
|
const a = s - i | 0;
|
|
2772
|
-
n =
|
|
2816
|
+
n = Be(this.#e, O, a);
|
|
2773
2817
|
}
|
|
2774
2818
|
const o = s - n | 0, c = Math.min(o, e[0].length);
|
|
2775
2819
|
if (c <= 0) return 0;
|
|
2776
2820
|
for (let a = 0; a < this.channels; a++) {
|
|
2777
2821
|
const u = this.#t[a], l = e[a];
|
|
2778
2822
|
for (let d = 0; d < c; d++)
|
|
2779
|
-
l[d] = u[
|
|
2823
|
+
l[d] = u[ue(n + d | 0, this.capacity)];
|
|
2780
2824
|
}
|
|
2781
|
-
return
|
|
2825
|
+
return Be(this.#e, O, n + c | 0), c;
|
|
2782
2826
|
}
|
|
2783
2827
|
/** Update the target latency in samples. */
|
|
2784
2828
|
setLatency(e) {
|
|
2785
|
-
Atomics.store(this.#e,
|
|
2829
|
+
Atomics.store(this.#e, ce, e);
|
|
2786
2830
|
}
|
|
2787
2831
|
/**
|
|
2788
2832
|
* Allocate a new ring with `newCapacity` samples and copy the unread window
|
|
@@ -2797,24 +2841,24 @@ class Pe {
|
|
|
2797
2841
|
* by READ/WRITE elsewhere.
|
|
2798
2842
|
*/
|
|
2799
2843
|
resize(e) {
|
|
2800
|
-
const n =
|
|
2844
|
+
const n = qt(this.channels, e, this.rate), s = new Ne(n), i = Atomics.load(this.#e, O), r = Atomics.load(this.#e, Z), o = Atomics.load(this.#e, ce), c = Atomics.load(this.#e, J), a = r - i | 0, u = Math.max(0, Math.min(a, s.capacity)), l = r - u | 0;
|
|
2801
2845
|
for (let d = 0; d < this.channels; d++) {
|
|
2802
|
-
const f = this.#t[d],
|
|
2803
|
-
for (let
|
|
2804
|
-
const
|
|
2805
|
-
|
|
2846
|
+
const f = this.#t[d], p = s.#t[d];
|
|
2847
|
+
for (let b = 0; b < u; b++) {
|
|
2848
|
+
const w = l + b | 0;
|
|
2849
|
+
p[ue(w, s.capacity)] = f[ue(w, this.capacity)];
|
|
2806
2850
|
}
|
|
2807
2851
|
}
|
|
2808
|
-
return Atomics.store(s.#e, O, l), Atomics.store(s.#e, Z, r), Atomics.store(s.#e,
|
|
2852
|
+
return Atomics.store(s.#e, O, l), Atomics.store(s.#e, Z, r), Atomics.store(s.#e, ce, o), Atomics.store(s.#e, J, c), s;
|
|
2809
2853
|
}
|
|
2810
2854
|
/** Current playback timestamp derived from READ position. */
|
|
2811
2855
|
get timestamp() {
|
|
2812
2856
|
const e = Atomics.load(this.#e, O);
|
|
2813
|
-
return
|
|
2857
|
+
return g.Micro.fromSecond(e / this.rate);
|
|
2814
2858
|
}
|
|
2815
2859
|
/** Whether the buffer is stalled (waiting to fill). */
|
|
2816
2860
|
get stalled() {
|
|
2817
|
-
return Atomics.load(this.#e,
|
|
2861
|
+
return Atomics.load(this.#e, J) === 1;
|
|
2818
2862
|
}
|
|
2819
2863
|
/**
|
|
2820
2864
|
* Number of buffered samples (WRITE - READ).
|
|
@@ -2827,13 +2871,13 @@ class Pe {
|
|
|
2827
2871
|
return Atomics.load(this.#e, Z) - Atomics.load(this.#e, O) | 0;
|
|
2828
2872
|
}
|
|
2829
2873
|
}
|
|
2830
|
-
function
|
|
2874
|
+
function Li() {
|
|
2831
2875
|
return !(typeof SharedArrayBuffer > "u" || typeof crossOriginIsolated < "u" && !crossOriginIsolated);
|
|
2832
2876
|
}
|
|
2833
|
-
function
|
|
2834
|
-
return
|
|
2877
|
+
function Fi(t, e, n, s) {
|
|
2878
|
+
return Li() ? (console.log("[audio] using SharedArrayBuffer audio buffer"), new $i(t, e, n, s)) : (console.log("[audio] using postMessage audio buffer (SharedArrayBuffer unavailable)"), new Pi(t, e, n, s));
|
|
2835
2879
|
}
|
|
2836
|
-
class
|
|
2880
|
+
class $i {
|
|
2837
2881
|
rate;
|
|
2838
2882
|
channels;
|
|
2839
2883
|
#e;
|
|
@@ -2845,8 +2889,8 @@ class Ri {
|
|
|
2845
2889
|
#i = new E();
|
|
2846
2890
|
constructor(e, n, s, i) {
|
|
2847
2891
|
this.#e = e, this.channels = n, this.rate = s;
|
|
2848
|
-
const r = Math.max(s, i * 2), o =
|
|
2849
|
-
this.#t = new
|
|
2892
|
+
const r = Math.max(s, i * 2), o = qt(n, r, s);
|
|
2893
|
+
this.#t = new Ne(o), this.#t.setLatency(i);
|
|
2850
2894
|
const c = { type: "init-shared", ...o };
|
|
2851
2895
|
e.port.postMessage(c), this.#i.interval(() => {
|
|
2852
2896
|
this.#n.set(this.#t.timestamp), this.#s.set(this.#t.stalled);
|
|
@@ -2868,7 +2912,7 @@ class Ri {
|
|
|
2868
2912
|
this.#i.close();
|
|
2869
2913
|
}
|
|
2870
2914
|
}
|
|
2871
|
-
class
|
|
2915
|
+
class Pi {
|
|
2872
2916
|
rate;
|
|
2873
2917
|
channels;
|
|
2874
2918
|
#e;
|
|
@@ -2879,7 +2923,7 @@ class Ci {
|
|
|
2879
2923
|
#s = new E();
|
|
2880
2924
|
constructor(e, n, s, i) {
|
|
2881
2925
|
this.#e = e, this.channels = n, this.rate = s;
|
|
2882
|
-
const r =
|
|
2926
|
+
const r = g.Milli.fromSecond(i / s), o = { type: "init-post", channels: n, rate: s, latency: r };
|
|
2883
2927
|
e.port.postMessage(o), this.#s.event(e.port, "message", (c) => {
|
|
2884
2928
|
const a = c.data;
|
|
2885
2929
|
a?.type === "state" && (this.#t.set(a.timestamp), this.#n.set(a.stalled));
|
|
@@ -2893,14 +2937,14 @@ class Ci {
|
|
|
2893
2937
|
);
|
|
2894
2938
|
}
|
|
2895
2939
|
setLatency(e) {
|
|
2896
|
-
const s = { type: "latency", latency:
|
|
2940
|
+
const s = { type: "latency", latency: g.Milli.fromSecond(e / this.rate) };
|
|
2897
2941
|
this.#e.port.postMessage(s);
|
|
2898
2942
|
}
|
|
2899
2943
|
close() {
|
|
2900
2944
|
this.#s.close();
|
|
2901
2945
|
}
|
|
2902
2946
|
}
|
|
2903
|
-
const
|
|
2947
|
+
const Ni = `var __defProp = Object.defineProperty;
|
|
2904
2948
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2905
2949
|
var __esm = (fn, res) => function __init() {
|
|
2906
2950
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
@@ -2910,17 +2954,17 @@ var __export = (target, all) => {
|
|
|
2910
2954
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
2911
2955
|
};
|
|
2912
2956
|
|
|
2913
|
-
// ../
|
|
2957
|
+
// ../net/src/path.ts
|
|
2914
2958
|
var init_path = __esm({
|
|
2915
|
-
"../
|
|
2959
|
+
"../net/src/path.ts"() {
|
|
2916
2960
|
"use strict";
|
|
2917
2961
|
}
|
|
2918
2962
|
});
|
|
2919
2963
|
|
|
2920
|
-
// ../
|
|
2964
|
+
// ../net/src/varint.ts
|
|
2921
2965
|
var MAX_U6, MAX_U14, MAX_U30, MAX_U53, MAX_U64, MAX_U62;
|
|
2922
2966
|
var init_varint = __esm({
|
|
2923
|
-
"../
|
|
2967
|
+
"../net/src/varint.ts"() {
|
|
2924
2968
|
"use strict";
|
|
2925
2969
|
MAX_U6 = 2 ** 6 - 1;
|
|
2926
2970
|
MAX_U14 = 2 ** 14 - 1;
|
|
@@ -2931,10 +2975,10 @@ var init_varint = __esm({
|
|
|
2931
2975
|
}
|
|
2932
2976
|
});
|
|
2933
2977
|
|
|
2934
|
-
// ../
|
|
2978
|
+
// ../net/src/index.ts
|
|
2935
2979
|
init_path();
|
|
2936
2980
|
|
|
2937
|
-
// ../
|
|
2981
|
+
// ../net/src/time.ts
|
|
2938
2982
|
var time_exports = {};
|
|
2939
2983
|
__export(time_exports, {
|
|
2940
2984
|
Micro: () => Micro,
|
|
@@ -3007,7 +3051,7 @@ var Second = {
|
|
|
3007
3051
|
min: (a, b) => Math.min(a, b)
|
|
3008
3052
|
};
|
|
3009
3053
|
|
|
3010
|
-
// ../
|
|
3054
|
+
// ../net/src/index.ts
|
|
3011
3055
|
init_varint();
|
|
3012
3056
|
|
|
3013
3057
|
// src/audio/ring-buffer.ts
|
|
@@ -3371,8 +3415,8 @@ var Render = class extends AudioWorkletProcessor {
|
|
|
3371
3415
|
}
|
|
3372
3416
|
};
|
|
3373
3417
|
registerProcessor("render", Render);
|
|
3374
|
-
`,
|
|
3375
|
-
let
|
|
3418
|
+
`, ji = new Blob([Ni], { type: "application/javascript" }), Zi = URL.createObjectURL(ji);
|
|
3419
|
+
let Vi = class {
|
|
3376
3420
|
source;
|
|
3377
3421
|
enabled;
|
|
3378
3422
|
#e = new h(void 0);
|
|
@@ -3400,7 +3444,7 @@ let Li = class {
|
|
|
3400
3444
|
#c;
|
|
3401
3445
|
#u = new E();
|
|
3402
3446
|
constructor(e, n) {
|
|
3403
|
-
this.source = e, this.source.supported.set(
|
|
3447
|
+
this.source = e, this.source.supported.set(Wi), 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.#h.bind(this)), this.#u.run(this.#m.bind(this));
|
|
3404
3448
|
}
|
|
3405
3449
|
#d(e) {
|
|
3406
3450
|
const n = e.get(this.source.config);
|
|
@@ -3411,18 +3455,18 @@ let Li = class {
|
|
|
3411
3455
|
sampleRate: s
|
|
3412
3456
|
});
|
|
3413
3457
|
e.set(this.#e, r), e.cleanup(() => r.close()), e.spawn(async () => {
|
|
3414
|
-
if (await r.audioWorklet.addModule(
|
|
3458
|
+
if (await r.audioWorklet.addModule(Zi), r.state === "closed") return;
|
|
3415
3459
|
const o = new AudioWorkletNode(r, "render", {
|
|
3416
3460
|
channelCount: i,
|
|
3417
3461
|
channelCountMode: "explicit",
|
|
3418
3462
|
outputChannelCount: [i]
|
|
3419
3463
|
});
|
|
3420
3464
|
e.cleanup(() => o.disconnect());
|
|
3421
|
-
const c = this.source.sync.buffer.peek(), a = Math.ceil(s *
|
|
3465
|
+
const c = this.source.sync.buffer.peek(), a = Math.ceil(s * g.Second.fromMilli(c)), u = Fi(o, i, s, a);
|
|
3422
3466
|
this.#c = u, e.cleanup(() => {
|
|
3423
3467
|
u.close(), this.#c = void 0;
|
|
3424
3468
|
}), e.run((l) => {
|
|
3425
|
-
const d =
|
|
3469
|
+
const d = g.Milli.fromMicro(l.get(u.timestamp));
|
|
3426
3470
|
this.#i.set(d), this.#y(d);
|
|
3427
3471
|
}), e.run((l) => {
|
|
3428
3472
|
this.#r.set(l.get(u.stalled));
|
|
@@ -3435,11 +3479,11 @@ let Li = class {
|
|
|
3435
3479
|
const [s, i] = n;
|
|
3436
3480
|
i.resume();
|
|
3437
3481
|
}
|
|
3438
|
-
#
|
|
3482
|
+
#h(e) {
|
|
3439
3483
|
if (!e.get(this.#t)) return;
|
|
3440
3484
|
const s = this.#c;
|
|
3441
3485
|
if (!s) return;
|
|
3442
|
-
const i = e.get(this.source.sync.buffer), r = Math.ceil(s.rate *
|
|
3486
|
+
const i = e.get(this.source.sync.buffer), r = Math.ceil(s.rate * g.Second.fromMilli(i));
|
|
3443
3487
|
s.setLatency(r);
|
|
3444
3488
|
}
|
|
3445
3489
|
#m(e) {
|
|
@@ -3452,68 +3496,68 @@ let Li = class {
|
|
|
3452
3496
|
if (!r) return;
|
|
3453
3497
|
const o = e.get(s.active);
|
|
3454
3498
|
if (!o) return;
|
|
3455
|
-
const c = o.subscribe(i,
|
|
3499
|
+
const c = o.subscribe(i, te.audio);
|
|
3456
3500
|
e.cleanup(() => c.close()), r.container.kind === "cmaf" ? this.#g(e, c, r) : this.#p(e, c, r);
|
|
3457
3501
|
}
|
|
3458
3502
|
#p(e, n, s) {
|
|
3459
|
-
const i = new
|
|
3460
|
-
format:
|
|
3503
|
+
const i = s.container.kind === "loc" ? new ke() : new Te(), r = new se(n, {
|
|
3504
|
+
format: i,
|
|
3461
3505
|
latency: this.source.sync.buffer
|
|
3462
3506
|
});
|
|
3463
|
-
e.cleanup(() =>
|
|
3464
|
-
const
|
|
3465
|
-
this.#o.update(() =>
|
|
3507
|
+
e.cleanup(() => r.close()), e.run((o) => {
|
|
3508
|
+
const c = o.get(r.buffered), a = o.get(this.#a);
|
|
3509
|
+
this.#o.update(() => Ae(c, a));
|
|
3466
3510
|
}), e.spawn(async () => {
|
|
3467
|
-
if (!await
|
|
3468
|
-
let
|
|
3469
|
-
const
|
|
3470
|
-
output: (
|
|
3471
|
-
if (
|
|
3472
|
-
|
|
3511
|
+
if (!await ot()) return;
|
|
3512
|
+
let c = 0;
|
|
3513
|
+
const a = new AudioDecoder({
|
|
3514
|
+
output: (l) => {
|
|
3515
|
+
if (c++, c <= 3) {
|
|
3516
|
+
l.close();
|
|
3473
3517
|
return;
|
|
3474
3518
|
}
|
|
3475
|
-
this.#
|
|
3519
|
+
this.#f(l);
|
|
3476
3520
|
},
|
|
3477
|
-
error: (
|
|
3521
|
+
error: (l) => console.error(l)
|
|
3478
3522
|
});
|
|
3479
3523
|
e.cleanup(() => {
|
|
3480
|
-
|
|
3524
|
+
a.state !== "closed" && a.close();
|
|
3481
3525
|
});
|
|
3482
|
-
const
|
|
3483
|
-
for (
|
|
3526
|
+
const u = s.codec === "opus" ? void 0 : s.description ? $(s.description) : void 0;
|
|
3527
|
+
for (a.configure({
|
|
3484
3528
|
...s,
|
|
3485
|
-
description:
|
|
3529
|
+
description: u
|
|
3486
3530
|
}); ; ) {
|
|
3487
|
-
const
|
|
3488
|
-
if (!
|
|
3489
|
-
const { frame:
|
|
3490
|
-
if (!
|
|
3491
|
-
const
|
|
3492
|
-
this.source.sync.received(
|
|
3493
|
-
bytesReceived: (
|
|
3531
|
+
const l = await r.next();
|
|
3532
|
+
if (!l) break;
|
|
3533
|
+
const { frame: d } = l;
|
|
3534
|
+
if (!d) continue;
|
|
3535
|
+
const f = g.Milli.fromMicro(d.timestamp);
|
|
3536
|
+
this.source.sync.received(f, "audio"), this.#s.update((b) => ({
|
|
3537
|
+
bytesReceived: (b?.bytesReceived ?? 0) + d.data.byteLength
|
|
3494
3538
|
}));
|
|
3495
|
-
const
|
|
3496
|
-
type:
|
|
3497
|
-
data:
|
|
3498
|
-
timestamp:
|
|
3539
|
+
const p = new EncodedAudioChunk({
|
|
3540
|
+
type: d.keyframe ? "key" : "delta",
|
|
3541
|
+
data: d.data,
|
|
3542
|
+
timestamp: d.timestamp
|
|
3499
3543
|
});
|
|
3500
|
-
|
|
3544
|
+
a.decode(p);
|
|
3501
3545
|
}
|
|
3502
3546
|
});
|
|
3503
3547
|
}
|
|
3504
3548
|
#g(e, n, s) {
|
|
3505
3549
|
if (s.container.kind !== "cmaf") return;
|
|
3506
|
-
const i =
|
|
3507
|
-
format: new
|
|
3550
|
+
const i = K(s.container.init), r = oe(i), o = s.codec === "opus" ? void 0 : s.description ? $(s.description) : r.description, c = new se(n, {
|
|
3551
|
+
format: new Wt(r),
|
|
3508
3552
|
latency: this.source.sync.buffer
|
|
3509
3553
|
});
|
|
3510
3554
|
e.cleanup(() => c.close()), e.run((a) => {
|
|
3511
3555
|
const u = a.get(c.buffered), l = a.get(this.#a);
|
|
3512
|
-
this.#o.update(() =>
|
|
3556
|
+
this.#o.update(() => Ae(u, l));
|
|
3513
3557
|
}), e.spawn(async () => {
|
|
3514
|
-
if (!await
|
|
3558
|
+
if (!await ot()) return;
|
|
3515
3559
|
const u = new AudioDecoder({
|
|
3516
|
-
output: (l) => this.#
|
|
3560
|
+
output: (l) => this.#f(l),
|
|
3517
3561
|
error: (l) => console.error(l)
|
|
3518
3562
|
});
|
|
3519
3563
|
for (e.cleanup(() => {
|
|
@@ -3524,13 +3568,13 @@ let Li = class {
|
|
|
3524
3568
|
numberOfChannels: s.numberOfChannels,
|
|
3525
3569
|
description: o
|
|
3526
3570
|
}); ; ) {
|
|
3527
|
-
const l = await
|
|
3571
|
+
const l = await c.next();
|
|
3528
3572
|
if (!l) break;
|
|
3529
3573
|
const { frame: d } = l;
|
|
3530
3574
|
if (!d) continue;
|
|
3531
|
-
const f =
|
|
3532
|
-
if (this.source.sync.received(f, "audio"), this.#s.update((
|
|
3533
|
-
bytesReceived: (
|
|
3575
|
+
const f = g.Milli.fromMicro(d.timestamp);
|
|
3576
|
+
if (this.source.sync.received(f, "audio"), this.#s.update((p) => ({
|
|
3577
|
+
bytesReceived: (p?.bytesReceived ?? 0) + d.data.byteLength
|
|
3534
3578
|
})), u.state === "closed") break;
|
|
3535
3579
|
u.decode(
|
|
3536
3580
|
new EncodedAudioChunk({
|
|
@@ -3542,13 +3586,13 @@ let Li = class {
|
|
|
3542
3586
|
}
|
|
3543
3587
|
});
|
|
3544
3588
|
}
|
|
3545
|
-
#
|
|
3546
|
-
const n = e.timestamp, s =
|
|
3589
|
+
#f(e) {
|
|
3590
|
+
const n = e.timestamp, s = g.Milli.fromMicro(n), i = this.#c;
|
|
3547
3591
|
if (!i) {
|
|
3548
3592
|
e.close();
|
|
3549
3593
|
return;
|
|
3550
3594
|
}
|
|
3551
|
-
const r = e.numberOfFrames / e.sampleRate * 1e6, o =
|
|
3595
|
+
const r = e.numberOfFrames / e.sampleRate * 1e6, o = g.Milli.fromMicro(r), c = g.Milli.add(s, o);
|
|
3552
3596
|
this.#w(s, c);
|
|
3553
3597
|
const a = Math.min(e.numberOfChannels, i.channels), u = [];
|
|
3554
3598
|
for (let l = 0; l < a; l++) {
|
|
@@ -3561,7 +3605,7 @@ let Li = class {
|
|
|
3561
3605
|
e > n || this.#a.mutate((s) => {
|
|
3562
3606
|
for (const i of s)
|
|
3563
3607
|
if (e <= i.end + 1 && n >= i.start) {
|
|
3564
|
-
i.start =
|
|
3608
|
+
i.start = g.Milli.min(i.start, e), i.end = g.Milli.max(i.end, n);
|
|
3565
3609
|
return;
|
|
3566
3610
|
}
|
|
3567
3611
|
s.push({ start: e, end: n }), s.sort((i, r) => i.start - r.start);
|
|
@@ -3571,7 +3615,7 @@ let Li = class {
|
|
|
3571
3615
|
this.#a.mutate((n) => {
|
|
3572
3616
|
for (; n.length > 0; ) {
|
|
3573
3617
|
if (n[0].end >= e) {
|
|
3574
|
-
n[0].start =
|
|
3618
|
+
n[0].start = g.Milli.max(n[0].start, e);
|
|
3575
3619
|
break;
|
|
3576
3620
|
}
|
|
3577
3621
|
n.shift();
|
|
@@ -3582,15 +3626,25 @@ let Li = class {
|
|
|
3582
3626
|
this.#u.close();
|
|
3583
3627
|
}
|
|
3584
3628
|
};
|
|
3585
|
-
async function
|
|
3586
|
-
|
|
3629
|
+
async function Wi(t) {
|
|
3630
|
+
let e;
|
|
3631
|
+
if (t.codec !== "opus") {
|
|
3632
|
+
if (t.description)
|
|
3633
|
+
e = $(t.description);
|
|
3634
|
+
else if (t.container.kind === "cmaf")
|
|
3635
|
+
try {
|
|
3636
|
+
e = oe(K(t.container.init)).description;
|
|
3637
|
+
} catch (s) {
|
|
3638
|
+
return console.warn(`audio: malformed CMAF init segment for codec ${t.codec}`, s), !1;
|
|
3639
|
+
}
|
|
3640
|
+
}
|
|
3587
3641
|
return (await AudioDecoder.isConfigSupported({
|
|
3588
3642
|
...t,
|
|
3589
3643
|
description: e
|
|
3590
3644
|
})).supported ?? !1;
|
|
3591
3645
|
}
|
|
3592
|
-
const
|
|
3593
|
-
class
|
|
3646
|
+
const at = 1e-3, Re = 0.2;
|
|
3647
|
+
class qi {
|
|
3594
3648
|
source;
|
|
3595
3649
|
volume;
|
|
3596
3650
|
muted;
|
|
@@ -3623,14 +3677,14 @@ class Ni {
|
|
|
3623
3677
|
if (!i) return;
|
|
3624
3678
|
s.cleanup(() => i.gain.cancelScheduledValues(i.context.currentTime));
|
|
3625
3679
|
const r = s.get(this.volume);
|
|
3626
|
-
r <
|
|
3680
|
+
r < at ? (i.gain.exponentialRampToValueAtTime(at, i.context.currentTime + Re), i.gain.setValueAtTime(0, i.context.currentTime + Re + 0.01)) : i.gain.exponentialRampToValueAtTime(r, i.context.currentTime + Re);
|
|
3627
3681
|
});
|
|
3628
3682
|
}
|
|
3629
3683
|
close() {
|
|
3630
3684
|
this.#e.close();
|
|
3631
3685
|
}
|
|
3632
3686
|
}
|
|
3633
|
-
class
|
|
3687
|
+
class Ht {
|
|
3634
3688
|
element;
|
|
3635
3689
|
paused;
|
|
3636
3690
|
#e;
|
|
@@ -3658,7 +3712,7 @@ class Vt {
|
|
|
3658
3712
|
#i(e) {
|
|
3659
3713
|
const n = e.get(this.element);
|
|
3660
3714
|
if (!n || e.get(this.paused)) return;
|
|
3661
|
-
const i =
|
|
3715
|
+
const i = g.Milli.toSecond(e.get(this.#e.buffer));
|
|
3662
3716
|
e.interval(() => {
|
|
3663
3717
|
const r = n.buffered;
|
|
3664
3718
|
if (r.length === 0) return;
|
|
@@ -3692,18 +3746,18 @@ class Vt {
|
|
|
3692
3746
|
if (!n || e.get(this.paused)) return;
|
|
3693
3747
|
const i = e.get(this.#e.reference);
|
|
3694
3748
|
if (i === void 0) return;
|
|
3695
|
-
const r = e.get(this.#e.buffer), o =
|
|
3696
|
-
n.currentTime =
|
|
3749
|
+
const r = e.get(this.#e.buffer), o = g.Milli.sub(g.Milli.sub(g.Milli.now(), i), r);
|
|
3750
|
+
n.currentTime = g.Milli.toSecond(o);
|
|
3697
3751
|
}
|
|
3698
3752
|
close() {
|
|
3699
3753
|
this.#n.close();
|
|
3700
3754
|
}
|
|
3701
3755
|
}
|
|
3702
|
-
const
|
|
3756
|
+
const Rr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3703
3757
|
__proto__: null,
|
|
3704
|
-
Muxer:
|
|
3705
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
3706
|
-
class
|
|
3758
|
+
Muxer: Ht
|
|
3759
|
+
}, Symbol.toStringTag, { value: "Module" })), Hi = 20, ct = 100;
|
|
3760
|
+
class je {
|
|
3707
3761
|
// The earliest time we've received a frame, relative to its timestamp.
|
|
3708
3762
|
// This will keep being updated as we catch up to the live playhead then will be relatively static.
|
|
3709
3763
|
#e = new h(void 0);
|
|
@@ -3718,7 +3772,7 @@ class $e {
|
|
|
3718
3772
|
audio;
|
|
3719
3773
|
video;
|
|
3720
3774
|
// The total buffer required: jitter + max(audio, video).
|
|
3721
|
-
#t = new h(
|
|
3775
|
+
#t = new h(g.Milli.zero);
|
|
3722
3776
|
buffer = this.#t;
|
|
3723
3777
|
// A ghetto way to learn when the reference/buffer changes.
|
|
3724
3778
|
// There's probably a way to use Effect, but lets keep it simple for now.
|
|
@@ -3734,7 +3788,7 @@ class $e {
|
|
|
3734
3788
|
#r;
|
|
3735
3789
|
signals = new E();
|
|
3736
3790
|
constructor(e) {
|
|
3737
|
-
this.latency = h.from(e?.latency ?? "real-time"), this.jitter = new h(
|
|
3791
|
+
this.latency = h.from(e?.latency ?? "real-time"), this.jitter = new h(ct), this.#i = e?.connection, this.audio = h.from(e?.audio), this.video = h.from(e?.video), this.#n = Promise.withResolvers(), this.signals.run(this.#a.bind(this)), this.signals.run(this.#o.bind(this));
|
|
3738
3792
|
}
|
|
3739
3793
|
#a(e) {
|
|
3740
3794
|
const n = e.get(this.latency);
|
|
@@ -3745,29 +3799,29 @@ class $e {
|
|
|
3745
3799
|
const i = (this.#i ? e.get(this.#i) : void 0)?.rtt, r = i ? e.get(i) : void 0;
|
|
3746
3800
|
if (r !== void 0) {
|
|
3747
3801
|
this.#r = this.#r !== void 0 ? Math.min(this.#r, r) : r;
|
|
3748
|
-
const o = Math.max(
|
|
3802
|
+
const o = Math.max(Hi, this.#r * 1.25);
|
|
3749
3803
|
this.jitter.set(o);
|
|
3750
3804
|
return;
|
|
3751
3805
|
}
|
|
3752
|
-
this.#r = void 0, this.jitter.set(
|
|
3806
|
+
this.#r = void 0, this.jitter.set(ct);
|
|
3753
3807
|
}
|
|
3754
3808
|
#o(e) {
|
|
3755
|
-
const n = e.get(this.jitter), s = e.get(this.video) ??
|
|
3809
|
+
const n = e.get(this.jitter), s = e.get(this.video) ?? g.Milli.zero, i = e.get(this.audio) ?? g.Milli.zero, r = g.Milli.add(g.Milli.max(s, i), n);
|
|
3756
3810
|
this.#t.set(r), this.#n.resolve(), this.#n = Promise.withResolvers();
|
|
3757
3811
|
}
|
|
3758
3812
|
// Update the reference if this is the earliest frame we've seen, relative to its timestamp.
|
|
3759
3813
|
received(e, n = "") {
|
|
3760
3814
|
this.timestamp.update((o) => o === void 0 || e > o ? e : o);
|
|
3761
|
-
const s =
|
|
3815
|
+
const s = g.Milli.now(), i = g.Milli.sub(s, e), r = this.#e.peek();
|
|
3762
3816
|
if (r !== void 0) {
|
|
3763
|
-
const o =
|
|
3817
|
+
const o = g.Milli.add(g.Milli.sub(r, i), this.#t.peek());
|
|
3764
3818
|
if (o < 0) {
|
|
3765
3819
|
const c = this.#s.get(n);
|
|
3766
3820
|
c ? (c.count++, c.maxMs = Math.max(c.maxMs, -o)) : this.#s.set(n, { count: 1, maxMs: -o });
|
|
3767
3821
|
} else {
|
|
3768
3822
|
const c = this.#s.get(n);
|
|
3769
3823
|
if (c) {
|
|
3770
|
-
const a = n ? `sync[${n}]` : "sync", u =
|
|
3824
|
+
const a = n ? `sync[${n}]` : "sync", u = je.#c(c.maxMs);
|
|
3771
3825
|
console.debug(`${a}: ${c.count} late frame(s), max ${u} behind`), this.#s.delete(n);
|
|
3772
3826
|
}
|
|
3773
3827
|
}
|
|
@@ -3781,16 +3835,16 @@ class $e {
|
|
|
3781
3835
|
now() {
|
|
3782
3836
|
const e = this.#e.peek();
|
|
3783
3837
|
if (e !== void 0)
|
|
3784
|
-
return
|
|
3838
|
+
return g.Milli.sub(g.Milli.sub(g.Milli.now(), e), this.#t.peek());
|
|
3785
3839
|
}
|
|
3786
3840
|
// Sleep until it's time to render this frame.
|
|
3787
3841
|
async wait(e) {
|
|
3788
3842
|
if (this.#e.peek() === void 0)
|
|
3789
3843
|
throw new Error("reference not set; call update() first");
|
|
3790
3844
|
for (; ; ) {
|
|
3791
|
-
const s =
|
|
3845
|
+
const s = g.Milli.now(), i = g.Milli.sub(s, e), r = this.#e.peek();
|
|
3792
3846
|
if (r === void 0) return;
|
|
3793
|
-
const o =
|
|
3847
|
+
const o = g.Milli.add(g.Milli.sub(r, i), this.#t.peek());
|
|
3794
3848
|
if (o <= 0 || o < 5) return;
|
|
3795
3849
|
const c = new Promise((u) => setTimeout(u, o)).then(() => !0);
|
|
3796
3850
|
if (await Promise.race([this.#n.promise, c])) return;
|
|
@@ -3807,8 +3861,8 @@ class $e {
|
|
|
3807
3861
|
this.signals.close();
|
|
3808
3862
|
}
|
|
3809
3863
|
}
|
|
3810
|
-
const
|
|
3811
|
-
class
|
|
3864
|
+
const Gi = 500, Xi = 100;
|
|
3865
|
+
class Yi {
|
|
3812
3866
|
enabled;
|
|
3813
3867
|
// Don't download any longer
|
|
3814
3868
|
source;
|
|
@@ -3831,18 +3885,26 @@ class Zi {
|
|
|
3831
3885
|
#a = new h([]);
|
|
3832
3886
|
buffered = this.#a;
|
|
3833
3887
|
#o = new E();
|
|
3888
|
+
#c() {
|
|
3889
|
+
this.#t.update((e) => {
|
|
3890
|
+
e?.close();
|
|
3891
|
+
}), this.#n.set(void 0);
|
|
3892
|
+
}
|
|
3834
3893
|
constructor(e, n) {
|
|
3835
|
-
this.enabled = h.from(n?.enabled ?? !1), this.source = e, this.source.supported.set(
|
|
3894
|
+
this.enabled = h.from(n?.enabled ?? !1), this.source = e, this.source.supported.set(Ji), this.#o.run(this.#u.bind(this)), this.#o.run(this.#d.bind(this)), this.#o.run(this.#l.bind(this)), this.#o.run(this.#h.bind(this));
|
|
3836
3895
|
}
|
|
3837
|
-
#
|
|
3896
|
+
#u(e) {
|
|
3838
3897
|
const n = e.getAll([this.enabled, this.source.broadcast, this.source.track, this.source.config]);
|
|
3839
3898
|
if (!n) {
|
|
3840
3899
|
this.#e.set(void 0);
|
|
3841
3900
|
return;
|
|
3842
3901
|
}
|
|
3843
3902
|
const [s, i, r, o] = n, c = e.get(i.active);
|
|
3844
|
-
if (!c)
|
|
3845
|
-
|
|
3903
|
+
if (!c) {
|
|
3904
|
+
this.#e.set(void 0), this.#c(), this.#a.set([]);
|
|
3905
|
+
return;
|
|
3906
|
+
}
|
|
3907
|
+
let a = new Ki({
|
|
3846
3908
|
source: this.source,
|
|
3847
3909
|
broadcast: c,
|
|
3848
3910
|
track: r,
|
|
@@ -3854,12 +3916,12 @@ class Zi {
|
|
|
3854
3916
|
const l = u.get(this.#e);
|
|
3855
3917
|
if (l) {
|
|
3856
3918
|
const d = u.get(a.timestamp), f = u.get(l.timestamp);
|
|
3857
|
-
if (!d || f && f > d +
|
|
3919
|
+
if (!d || f && f > d + Xi) return;
|
|
3858
3920
|
}
|
|
3859
3921
|
this.#e.set(a), a = void 0, u.close();
|
|
3860
3922
|
});
|
|
3861
3923
|
}
|
|
3862
|
-
#
|
|
3924
|
+
#d(e) {
|
|
3863
3925
|
const n = e.get(this.#e);
|
|
3864
3926
|
if (!n) {
|
|
3865
3927
|
this.#a.set([]);
|
|
@@ -3870,7 +3932,7 @@ class Zi {
|
|
|
3870
3932
|
this.#t.update((r) => (r?.close(), i?.clone()));
|
|
3871
3933
|
}), e.proxy(this.#n, n.timestamp), e.proxy(this.#a, n.buffered);
|
|
3872
3934
|
}
|
|
3873
|
-
#
|
|
3935
|
+
#l(e) {
|
|
3874
3936
|
const n = e.get(this.source.catalog);
|
|
3875
3937
|
if (!n) return;
|
|
3876
3938
|
const s = n.display;
|
|
@@ -3887,7 +3949,7 @@ class Zi {
|
|
|
3887
3949
|
height: i.displayHeight
|
|
3888
3950
|
});
|
|
3889
3951
|
}
|
|
3890
|
-
#
|
|
3952
|
+
#h(e) {
|
|
3891
3953
|
if (!e.get(this.enabled)) return;
|
|
3892
3954
|
if (!e.get(this.frame)) {
|
|
3893
3955
|
this.#i.set(!0);
|
|
@@ -3895,15 +3957,13 @@ class Zi {
|
|
|
3895
3957
|
}
|
|
3896
3958
|
this.#i.set(!1), e.timer(() => {
|
|
3897
3959
|
this.#i.set(!0);
|
|
3898
|
-
},
|
|
3960
|
+
}, Gi);
|
|
3899
3961
|
}
|
|
3900
3962
|
close() {
|
|
3901
|
-
this.#
|
|
3902
|
-
e?.close();
|
|
3903
|
-
}), this.#o.close();
|
|
3963
|
+
this.#c(), this.#o.close();
|
|
3904
3964
|
}
|
|
3905
3965
|
}
|
|
3906
|
-
class
|
|
3966
|
+
class Ki {
|
|
3907
3967
|
source;
|
|
3908
3968
|
broadcast;
|
|
3909
3969
|
track;
|
|
@@ -3921,12 +3981,12 @@ class Vi {
|
|
|
3921
3981
|
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));
|
|
3922
3982
|
}
|
|
3923
3983
|
#t(e) {
|
|
3924
|
-
const n = this.broadcast.subscribe(this.track,
|
|
3984
|
+
const n = this.broadcast.subscribe(this.track, te.video);
|
|
3925
3985
|
e.cleanup(() => n.close());
|
|
3926
3986
|
const s = new VideoDecoder({
|
|
3927
3987
|
output: async (i) => {
|
|
3928
3988
|
try {
|
|
3929
|
-
const r =
|
|
3989
|
+
const r = g.Milli.fromMicro(i.timestamp);
|
|
3930
3990
|
if (r < (this.timestamp.peek() ?? 0))
|
|
3931
3991
|
return;
|
|
3932
3992
|
this.frame.peek() === void 0 && this.frame.set(i.clone());
|
|
@@ -3948,61 +4008,63 @@ class Vi {
|
|
|
3948
4008
|
}), this.config.container.kind === "cmaf" ? this.#s(e, n, s) : this.#n(e, n, s);
|
|
3949
4009
|
}
|
|
3950
4010
|
#n(e, n, s) {
|
|
3951
|
-
const i = new
|
|
3952
|
-
format:
|
|
4011
|
+
const i = this.config.container.kind === "loc" ? new ke() : new Te(), r = new se(n, {
|
|
4012
|
+
format: i,
|
|
3953
4013
|
latency: this.source.sync.buffer
|
|
3954
4014
|
});
|
|
3955
|
-
e.cleanup(() =>
|
|
3956
|
-
const
|
|
3957
|
-
this.buffered.update(() =>
|
|
4015
|
+
e.cleanup(() => r.close()), e.run((c) => {
|
|
4016
|
+
const a = c.get(r.buffered), u = c.get(this.#e);
|
|
4017
|
+
this.buffered.update(() => Ae(a, u));
|
|
3958
4018
|
}), s.configure({
|
|
3959
4019
|
...this.config,
|
|
3960
|
-
description: this.config.description ?
|
|
4020
|
+
description: this.config.description ? $(this.config.description) : void 0,
|
|
3961
4021
|
optimizeForLatency: this.config.optimizeForLatency ?? !0,
|
|
3962
4022
|
// @ts-expect-error Only supported by Chrome, so the renderer has to flip manually.
|
|
3963
4023
|
flip: !1
|
|
3964
4024
|
});
|
|
3965
|
-
let
|
|
4025
|
+
let o;
|
|
3966
4026
|
e.spawn(async () => {
|
|
3967
4027
|
for (; ; ) {
|
|
3968
|
-
const
|
|
3969
|
-
if (!
|
|
3970
|
-
const { frame:
|
|
3971
|
-
if (!
|
|
3972
|
-
|
|
4028
|
+
const c = await r.next();
|
|
4029
|
+
if (!c) break;
|
|
4030
|
+
const { frame: a, group: u } = c;
|
|
4031
|
+
if (!a) {
|
|
4032
|
+
o && (o.final = !0);
|
|
3973
4033
|
continue;
|
|
3974
4034
|
}
|
|
3975
|
-
const
|
|
3976
|
-
this.source.sync.received(
|
|
3977
|
-
const
|
|
3978
|
-
type:
|
|
3979
|
-
data:
|
|
3980
|
-
timestamp:
|
|
4035
|
+
const l = g.Milli.fromMicro(a.timestamp);
|
|
4036
|
+
this.source.sync.received(l, "video");
|
|
4037
|
+
const d = new EncodedVideoChunk({
|
|
4038
|
+
type: a.keyframe ? "key" : "delta",
|
|
4039
|
+
data: a.data,
|
|
4040
|
+
timestamp: a.timestamp
|
|
3981
4041
|
});
|
|
3982
|
-
|
|
3983
|
-
frameCount: (
|
|
3984
|
-
bytesReceived: (
|
|
3985
|
-
}))
|
|
3986
|
-
|
|
3987
|
-
|
|
4042
|
+
this.stats.update((p) => ({
|
|
4043
|
+
frameCount: (p?.frameCount ?? 0) + 1,
|
|
4044
|
+
bytesReceived: (p?.bytesReceived ?? 0) + a.data.byteLength
|
|
4045
|
+
}));
|
|
4046
|
+
const f = o;
|
|
4047
|
+
if (f && (f.group === u || f.final && f.group + 1 === u)) {
|
|
4048
|
+
const p = g.Milli.fromMicro(f.timestamp), b = g.Milli.fromMicro(a.timestamp);
|
|
4049
|
+
this.#i(p, b);
|
|
3988
4050
|
}
|
|
3989
|
-
|
|
3990
|
-
timestamp:
|
|
3991
|
-
group:
|
|
4051
|
+
o = {
|
|
4052
|
+
timestamp: a.timestamp,
|
|
4053
|
+
group: u,
|
|
3992
4054
|
final: !1
|
|
3993
|
-
}, s.decode(
|
|
4055
|
+
}, s.decode(d);
|
|
3994
4056
|
}
|
|
3995
4057
|
});
|
|
3996
4058
|
}
|
|
3997
4059
|
#s(e, n, s) {
|
|
3998
4060
|
if (this.config.container.kind !== "cmaf") return;
|
|
3999
|
-
const i =
|
|
4000
|
-
format: new
|
|
4061
|
+
const i = K(this.config.container.init), r = oe(i), o = this.config.description ? $(this.config.description) : r.description, c = new se(n, {
|
|
4062
|
+
format: new Wt(r),
|
|
4001
4063
|
latency: this.source.sync.buffer
|
|
4002
4064
|
});
|
|
4003
4065
|
e.cleanup(() => c.close()), e.run((u) => {
|
|
4004
4066
|
const l = u.get(c.buffered), d = u.get(this.#e);
|
|
4005
|
-
this.buffered.update(() =>
|
|
4067
|
+
this.buffered.update(() => Ae(l, d));
|
|
4006
4068
|
}), s.configure({
|
|
4007
4069
|
codec: this.config.codec,
|
|
4008
4070
|
description: o,
|
|
@@ -4013,20 +4075,22 @@ class Vi {
|
|
|
4013
4075
|
let a;
|
|
4014
4076
|
e.spawn(async () => {
|
|
4015
4077
|
for (; ; ) {
|
|
4016
|
-
const u = await
|
|
4078
|
+
const u = await c.next();
|
|
4017
4079
|
if (!u) break;
|
|
4018
4080
|
const { frame: l, group: d } = u;
|
|
4019
4081
|
if (!l) {
|
|
4020
4082
|
a && (a.final = !0);
|
|
4021
4083
|
continue;
|
|
4022
4084
|
}
|
|
4023
|
-
const f =
|
|
4024
|
-
|
|
4025
|
-
frameCount: (
|
|
4026
|
-
bytesReceived: (
|
|
4027
|
-
}))
|
|
4028
|
-
|
|
4029
|
-
|
|
4085
|
+
const f = g.Milli.fromMicro(l.timestamp);
|
|
4086
|
+
this.source.sync.received(f, "video"), this.stats.update((b) => ({
|
|
4087
|
+
frameCount: (b?.frameCount ?? 0) + 1,
|
|
4088
|
+
bytesReceived: (b?.bytesReceived ?? 0) + l.data.byteLength
|
|
4089
|
+
}));
|
|
4090
|
+
const p = a;
|
|
4091
|
+
if (p && (p.group === d || p.final && p.group + 1 === d)) {
|
|
4092
|
+
const b = g.Milli.fromMicro(p.timestamp), w = g.Milli.fromMicro(l.timestamp);
|
|
4093
|
+
this.#i(b, w);
|
|
4030
4094
|
}
|
|
4031
4095
|
if (a = {
|
|
4032
4096
|
timestamp: l.timestamp,
|
|
@@ -4048,7 +4112,7 @@ class Vi {
|
|
|
4048
4112
|
e > n || this.#e.mutate((s) => {
|
|
4049
4113
|
for (const i of s)
|
|
4050
4114
|
if (i.start <= n && i.end >= e) {
|
|
4051
|
-
i.start =
|
|
4115
|
+
i.start = g.Milli.min(i.start, e), i.end = g.Milli.max(i.end, n);
|
|
4052
4116
|
return;
|
|
4053
4117
|
}
|
|
4054
4118
|
s.push({ start: e, end: n }), s.sort((i, r) => i.start - r.start);
|
|
@@ -4059,7 +4123,7 @@ class Vi {
|
|
|
4059
4123
|
this.#e.mutate((n) => {
|
|
4060
4124
|
for (; n.length > 0; ) {
|
|
4061
4125
|
if (n[0].end >= e) {
|
|
4062
|
-
n[0].start =
|
|
4126
|
+
n[0].start = g.Milli.max(n[0].start, e);
|
|
4063
4127
|
break;
|
|
4064
4128
|
}
|
|
4065
4129
|
n.shift();
|
|
@@ -4072,8 +4136,17 @@ class Vi {
|
|
|
4072
4136
|
});
|
|
4073
4137
|
}
|
|
4074
4138
|
}
|
|
4075
|
-
async function
|
|
4076
|
-
|
|
4139
|
+
async function Ji(t) {
|
|
4140
|
+
let e;
|
|
4141
|
+
if (t.description)
|
|
4142
|
+
e = $(t.description);
|
|
4143
|
+
else if (t.container.kind === "cmaf")
|
|
4144
|
+
try {
|
|
4145
|
+
e = oe(K(t.container.init)).description;
|
|
4146
|
+
} catch (s) {
|
|
4147
|
+
return console.warn(`video: malformed CMAF init segment for codec ${t.codec}`, s), !1;
|
|
4148
|
+
}
|
|
4149
|
+
const { supported: n } = await VideoDecoder.isConfigSupported({
|
|
4077
4150
|
codec: t.codec,
|
|
4078
4151
|
description: e,
|
|
4079
4152
|
optimizeForLatency: t.optimizeForLatency ?? !0
|
|
@@ -4090,7 +4163,7 @@ async function Wi(t) {
|
|
|
4090
4163
|
}
|
|
4091
4164
|
return !1;
|
|
4092
4165
|
}
|
|
4093
|
-
let
|
|
4166
|
+
let Qi = class {
|
|
4094
4167
|
muxer;
|
|
4095
4168
|
source;
|
|
4096
4169
|
// TODO implement stats
|
|
@@ -4100,11 +4173,11 @@ let qi = class {
|
|
|
4100
4173
|
buffered = this.#t;
|
|
4101
4174
|
#n = new h(!1);
|
|
4102
4175
|
stalled = this.#n;
|
|
4103
|
-
#s = new h(
|
|
4176
|
+
#s = new h(A.Time.Milli.zero);
|
|
4104
4177
|
timestamp = this.#s;
|
|
4105
4178
|
signals = new E();
|
|
4106
4179
|
constructor(e, n) {
|
|
4107
|
-
this.muxer = e, this.source = n, this.source.supported.set(
|
|
4180
|
+
this.muxer = e, this.source = n, this.source.supported.set(er), this.signals.run(this.#i.bind(this)), this.signals.run(this.#c.bind(this)), this.signals.run(this.#u.bind(this));
|
|
4108
4181
|
}
|
|
4109
4182
|
#i(e) {
|
|
4110
4183
|
const n = e.get(this.muxer.element);
|
|
@@ -4125,7 +4198,7 @@ let qi = class {
|
|
|
4125
4198
|
}), e.event(u, "error", (l) => {
|
|
4126
4199
|
console.error("[MSE] SourceBuffer error:", l);
|
|
4127
4200
|
}), e.event(u, "updateend", () => {
|
|
4128
|
-
this.#t.set(
|
|
4201
|
+
this.#t.set(Gt(u.buffered));
|
|
4129
4202
|
}), c.container.kind === "cmaf" ? this.#a(e, r, o, c, u, n) : this.#o(e, r, o, c, u, n);
|
|
4130
4203
|
}
|
|
4131
4204
|
async #r(e, n) {
|
|
@@ -4136,57 +4209,57 @@ let qi = class {
|
|
|
4136
4209
|
}
|
|
4137
4210
|
#a(e, n, s, i, r, o) {
|
|
4138
4211
|
if (i.container.kind !== "cmaf") throw new Error("unreachable");
|
|
4139
|
-
const c = n.subscribe(s,
|
|
4212
|
+
const c = n.subscribe(s, te.video);
|
|
4140
4213
|
e.cleanup(() => c.close());
|
|
4141
|
-
const a =
|
|
4214
|
+
const a = K(i.container.init), u = oe(a);
|
|
4142
4215
|
e.spawn(async () => {
|
|
4143
4216
|
for (await this.#r(r, a); ; ) {
|
|
4144
4217
|
const l = await c.readFrame();
|
|
4145
4218
|
if (!l) return;
|
|
4146
|
-
const d =
|
|
4147
|
-
this.source.sync.received(
|
|
4219
|
+
const d = Pt(l, u);
|
|
4220
|
+
this.source.sync.received(A.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));
|
|
4148
4221
|
}
|
|
4149
4222
|
});
|
|
4150
4223
|
}
|
|
4151
4224
|
#o(e, n, s, i, r, o) {
|
|
4152
|
-
const c = n.subscribe(s,
|
|
4225
|
+
const c = n.subscribe(s, te.video);
|
|
4153
4226
|
e.cleanup(() => c.close());
|
|
4154
|
-
const a = new
|
|
4155
|
-
format:
|
|
4227
|
+
const a = i.container.kind === "loc" ? new ke() : new Te(), u = new se(c, {
|
|
4228
|
+
format: a,
|
|
4156
4229
|
latency: this.source.sync.buffer
|
|
4157
4230
|
});
|
|
4158
|
-
e.cleanup(() =>
|
|
4159
|
-
const
|
|
4160
|
-
await this.#r(r,
|
|
4161
|
-
let
|
|
4231
|
+
e.cleanup(() => u.close()), e.spawn(async () => {
|
|
4232
|
+
const l = Ti(i);
|
|
4233
|
+
await this.#r(r, l);
|
|
4234
|
+
let d = 1, f, p;
|
|
4162
4235
|
for (; ; ) {
|
|
4163
|
-
const
|
|
4164
|
-
if (!
|
|
4165
|
-
if (!
|
|
4166
|
-
|
|
4167
|
-
const
|
|
4168
|
-
this.source.sync.received(
|
|
4236
|
+
const b = await u.next();
|
|
4237
|
+
if (!b) return;
|
|
4238
|
+
if (!b.frame) continue;
|
|
4239
|
+
p = b.frame;
|
|
4240
|
+
const w = A.Time.Milli.fromMicro(p.timestamp);
|
|
4241
|
+
this.source.sync.received(w, "video");
|
|
4169
4242
|
break;
|
|
4170
4243
|
}
|
|
4171
4244
|
for (; ; ) {
|
|
4172
|
-
const
|
|
4173
|
-
if (
|
|
4174
|
-
const
|
|
4175
|
-
if (
|
|
4176
|
-
|
|
4177
|
-
const
|
|
4178
|
-
this.source.sync.received(
|
|
4245
|
+
const b = await u.next();
|
|
4246
|
+
if (b && !b.frame) continue;
|
|
4247
|
+
const w = b?.frame;
|
|
4248
|
+
if (w) {
|
|
4249
|
+
f = A.Time.Micro.sub(w.timestamp, p.timestamp);
|
|
4250
|
+
const _ = A.Time.Milli.fromMicro(w.timestamp);
|
|
4251
|
+
this.source.sync.received(_, "video");
|
|
4179
4252
|
}
|
|
4180
|
-
const
|
|
4181
|
-
data:
|
|
4182
|
-
timestamp:
|
|
4183
|
-
duration:
|
|
4253
|
+
const v = Vt({
|
|
4254
|
+
data: p.data,
|
|
4255
|
+
timestamp: p.timestamp,
|
|
4256
|
+
duration: f ?? 0,
|
|
4184
4257
|
// Default to 0 duration if there's literally one frame then stream FIN.
|
|
4185
|
-
keyframe:
|
|
4186
|
-
sequence:
|
|
4258
|
+
keyframe: p.keyframe,
|
|
4259
|
+
sequence: d++
|
|
4187
4260
|
});
|
|
4188
|
-
if (await this.#r(r,
|
|
4189
|
-
|
|
4261
|
+
if (await this.#r(r, v), o.buffered.length > 0 && o.currentTime < o.buffered.start(0) && (o.currentTime = o.buffered.start(0)), !w) return;
|
|
4262
|
+
p = w;
|
|
4190
4263
|
}
|
|
4191
4264
|
});
|
|
4192
4265
|
}
|
|
@@ -4205,13 +4278,13 @@ let qi = class {
|
|
|
4205
4278
|
const s = n;
|
|
4206
4279
|
let i;
|
|
4207
4280
|
const r = () => {
|
|
4208
|
-
const o =
|
|
4281
|
+
const o = A.Time.Milli.fromSecond(s.currentTime);
|
|
4209
4282
|
this.#s.set(o), i = s.requestVideoFrameCallback(r);
|
|
4210
4283
|
};
|
|
4211
4284
|
i = s.requestVideoFrameCallback(r), e.cleanup(() => s.cancelVideoFrameCallback(i));
|
|
4212
4285
|
} else
|
|
4213
4286
|
e.event(n, "timeupdate", () => {
|
|
4214
|
-
const s =
|
|
4287
|
+
const s = A.Time.Milli.fromSecond(n.currentTime);
|
|
4215
4288
|
this.#s.set(s);
|
|
4216
4289
|
});
|
|
4217
4290
|
}
|
|
@@ -4219,10 +4292,10 @@ let qi = class {
|
|
|
4219
4292
|
this.source.close(), this.signals.close();
|
|
4220
4293
|
}
|
|
4221
4294
|
};
|
|
4222
|
-
async function
|
|
4295
|
+
async function er(t) {
|
|
4223
4296
|
return MediaSource.isTypeSupported(`video/mp4; codecs="${t.codec}"`);
|
|
4224
4297
|
}
|
|
4225
|
-
class
|
|
4298
|
+
class tr {
|
|
4226
4299
|
decoder;
|
|
4227
4300
|
// The canvas to render the video to.
|
|
4228
4301
|
canvas;
|
|
@@ -4273,21 +4346,20 @@ class Gi {
|
|
|
4273
4346
|
this.decoder.enabled.set(s);
|
|
4274
4347
|
return;
|
|
4275
4348
|
}
|
|
4276
|
-
const i = e.get(this.frame);
|
|
4349
|
+
const i = e.get(this.decoder.frame);
|
|
4277
4350
|
this.decoder.enabled.set(!i);
|
|
4278
4351
|
}
|
|
4279
4352
|
#a(e) {
|
|
4280
4353
|
const n = e.get(this.#e);
|
|
4281
4354
|
if (!n) return;
|
|
4282
|
-
const s = e.get(this.
|
|
4283
|
-
let i
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
this.#o(n, o), i && (this.frame.update((c) => (c?.close(), i.clone())), this.timestamp.set(p.Milli.fromMicro(i.timestamp))), r = void 0;
|
|
4355
|
+
const s = e.get(this.decoder.frame);
|
|
4356
|
+
let i = requestAnimationFrame(() => {
|
|
4357
|
+
this.#o(n, s), s ? (this.frame.update((r) => (r?.close(), s.clone())), this.timestamp.set(g.Milli.fromMicro(s.timestamp))) : (this.frame.update((r) => {
|
|
4358
|
+
r?.close();
|
|
4359
|
+
}), this.timestamp.set(void 0)), i = void 0;
|
|
4288
4360
|
});
|
|
4289
4361
|
e.cleanup(() => {
|
|
4290
|
-
i
|
|
4362
|
+
i && cancelAnimationFrame(i);
|
|
4291
4363
|
});
|
|
4292
4364
|
}
|
|
4293
4365
|
#o(e, n) {
|
|
@@ -4301,10 +4373,10 @@ class Gi {
|
|
|
4301
4373
|
close() {
|
|
4302
4374
|
this.frame.update((e) => {
|
|
4303
4375
|
e?.close();
|
|
4304
|
-
}), this.#n.close();
|
|
4376
|
+
}), this.timestamp.set(void 0), this.#n.close();
|
|
4305
4377
|
}
|
|
4306
4378
|
}
|
|
4307
|
-
function
|
|
4379
|
+
function nr(t) {
|
|
4308
4380
|
return (e) => {
|
|
4309
4381
|
const n = [], s = [];
|
|
4310
4382
|
for (const [i, r] of e)
|
|
@@ -4315,7 +4387,18 @@ function Xi(t) {
|
|
|
4315
4387
|
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);
|
|
4316
4388
|
};
|
|
4317
4389
|
}
|
|
4318
|
-
function
|
|
4390
|
+
function sr(t, e) {
|
|
4391
|
+
return (n) => {
|
|
4392
|
+
const s = [], i = [];
|
|
4393
|
+
for (const [r, o] of n) {
|
|
4394
|
+
if (!o.codedWidth || !o.codedHeight) continue;
|
|
4395
|
+
const c = o.codedWidth * o.codedHeight, a = t == null || o.codedWidth <= t, u = e == null || o.codedHeight <= e;
|
|
4396
|
+
a && u ? s.push({ name: r, size: c }) : i.push({ name: r, size: c });
|
|
4397
|
+
}
|
|
4398
|
+
return s.sort((r, o) => o.size - r.size), s.length > 0 ? s.map((r) => r.name) : i.length > 0 ? (i.sort((r, o) => r.size - o.size), [i[0].name]) : n.map(([r]) => r);
|
|
4399
|
+
};
|
|
4400
|
+
}
|
|
4401
|
+
function ir(t) {
|
|
4319
4402
|
return (e) => {
|
|
4320
4403
|
const n = [], s = [];
|
|
4321
4404
|
for (const [i, r] of e)
|
|
@@ -4323,7 +4406,7 @@ function Yi(t) {
|
|
|
4323
4406
|
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);
|
|
4324
4407
|
};
|
|
4325
4408
|
}
|
|
4326
|
-
function
|
|
4409
|
+
function rr(t) {
|
|
4327
4410
|
let e = t[0];
|
|
4328
4411
|
for (const n of t) {
|
|
4329
4412
|
const [, s] = n, [, i] = e, r = (s.codedWidth ?? 0) * (s.codedHeight ?? 0), o = (i.codedWidth ?? 0) * (i.codedHeight ?? 0);
|
|
@@ -4335,7 +4418,7 @@ function Ki(t) {
|
|
|
4335
4418
|
}
|
|
4336
4419
|
return e[0];
|
|
4337
4420
|
}
|
|
4338
|
-
let
|
|
4421
|
+
let or = class {
|
|
4339
4422
|
broadcast;
|
|
4340
4423
|
target;
|
|
4341
4424
|
#e = new h(void 0);
|
|
@@ -4409,8 +4492,8 @@ let Ji = class {
|
|
|
4409
4492
|
if (s.length === 0) return;
|
|
4410
4493
|
if (s.length === 1) return s[0][0];
|
|
4411
4494
|
const i = [];
|
|
4412
|
-
if (n?.pixels != null && i.push(
|
|
4413
|
-
return
|
|
4495
|
+
if (n?.pixels != null && i.push(nr(n.pixels)), (n?.width != null || n?.height != null) && i.push(sr(n.width, n.height)), n?.bitrate != null && i.push(ir(n.bitrate)), i.length === 0)
|
|
4496
|
+
return rr(s);
|
|
4414
4497
|
const r = i.map((c) => c(s)), o = r.map((c) => new Set(c));
|
|
4415
4498
|
for (const c of r[0])
|
|
4416
4499
|
if (o.every((a) => a.has(c)))
|
|
@@ -4421,15 +4504,15 @@ let Ji = class {
|
|
|
4421
4504
|
this.#i.close();
|
|
4422
4505
|
}
|
|
4423
4506
|
};
|
|
4424
|
-
function
|
|
4507
|
+
function Gt(t) {
|
|
4425
4508
|
const e = [];
|
|
4426
4509
|
for (let n = 0; n < t.length; n++) {
|
|
4427
|
-
const s =
|
|
4510
|
+
const s = A.Time.Milli.fromSecond(t.start(n)), i = A.Time.Milli.fromSecond(t.end(n));
|
|
4428
4511
|
e.push({ start: s, end: i });
|
|
4429
4512
|
}
|
|
4430
4513
|
return e;
|
|
4431
4514
|
}
|
|
4432
|
-
class
|
|
4515
|
+
class ar {
|
|
4433
4516
|
// The source of the video.
|
|
4434
4517
|
source;
|
|
4435
4518
|
// The stats of the video.
|
|
@@ -4439,12 +4522,12 @@ class Qi {
|
|
|
4439
4522
|
// Buffered time ranges
|
|
4440
4523
|
buffered = new h([]);
|
|
4441
4524
|
// The timestamp of the current frame
|
|
4442
|
-
timestamp = new h(
|
|
4525
|
+
timestamp = new h(A.Time.Milli.zero);
|
|
4443
4526
|
constructor(e) {
|
|
4444
4527
|
this.source = e;
|
|
4445
4528
|
}
|
|
4446
4529
|
}
|
|
4447
|
-
class
|
|
4530
|
+
class cr {
|
|
4448
4531
|
source;
|
|
4449
4532
|
// The volume of the audio, between 0 and 1.
|
|
4450
4533
|
volume = new h(0.5);
|
|
@@ -4460,7 +4543,7 @@ class er {
|
|
|
4460
4543
|
this.source = e;
|
|
4461
4544
|
}
|
|
4462
4545
|
}
|
|
4463
|
-
class
|
|
4546
|
+
class Dr {
|
|
4464
4547
|
element = new h(void 0);
|
|
4465
4548
|
broadcast;
|
|
4466
4549
|
latency;
|
|
@@ -4474,31 +4557,34 @@ class Mr {
|
|
|
4474
4557
|
sync;
|
|
4475
4558
|
signals = new E();
|
|
4476
4559
|
constructor(e) {
|
|
4477
|
-
this.element = h.from(e?.element), this.broadcast = h.from(e?.broadcast), this.sync = new
|
|
4560
|
+
this.element = h.from(e?.element), this.broadcast = h.from(e?.broadcast), this.sync = new je({ latency: e?.latency, connection: e?.connection }), this.latency = this.sync.latency, this.jitter = this.sync.jitter, this.#e = new or(this.sync, {
|
|
4478
4561
|
broadcast: this.broadcast
|
|
4479
|
-
}), this.#t = new
|
|
4562
|
+
}), this.#t = new hr(this.sync, {
|
|
4480
4563
|
broadcast: this.broadcast
|
|
4481
|
-
}), this.video = new
|
|
4564
|
+
}), this.video = new ar(this.#e), this.audio = new cr(this.#t), this.paused = h.from(e?.paused ?? !1), this.signals.run(this.#n.bind(this));
|
|
4482
4565
|
}
|
|
4483
4566
|
#n(e) {
|
|
4484
4567
|
const n = e.get(this.element);
|
|
4485
4568
|
n && (n instanceof HTMLCanvasElement ? this.#s(e, n) : n instanceof HTMLVideoElement && this.#i(e, n));
|
|
4486
4569
|
}
|
|
4487
4570
|
#s(e, n) {
|
|
4488
|
-
const s = new
|
|
4571
|
+
const s = new Yi(this.#e), i = new Vi(this.#t), r = new qi(i, {
|
|
4489
4572
|
volume: this.audio.volume,
|
|
4490
4573
|
muted: this.audio.muted,
|
|
4491
4574
|
paused: this.paused
|
|
4492
|
-
}), o = new
|
|
4575
|
+
}), o = new tr(s, {
|
|
4576
|
+
canvas: n,
|
|
4577
|
+
paused: this.paused
|
|
4578
|
+
});
|
|
4493
4579
|
e.cleanup(() => {
|
|
4494
4580
|
s.close(), i.close(), r.close(), o.close();
|
|
4495
4581
|
}), 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), e.proxy(this.audio.context, i.context);
|
|
4496
4582
|
}
|
|
4497
4583
|
#i(e, n) {
|
|
4498
|
-
const s = new
|
|
4584
|
+
const s = new Ht(this.sync, {
|
|
4499
4585
|
paused: this.paused,
|
|
4500
4586
|
element: n
|
|
4501
|
-
}), i = new
|
|
4587
|
+
}), i = new Qi(s, this.#e), r = new ur(s, this.#t, {
|
|
4502
4588
|
volume: this.audio.volume,
|
|
4503
4589
|
muted: this.audio.muted
|
|
4504
4590
|
});
|
|
@@ -4507,10 +4593,10 @@ class Mr {
|
|
|
4507
4593
|
}), e.proxy(this.video.stats, i.stats), e.proxy(this.video.buffered, i.buffered), e.proxy(this.video.stalled, i.stalled), e.proxy(this.video.timestamp, i.timestamp), e.proxy(this.audio.stats, r.stats), e.proxy(this.audio.buffered, r.buffered), e.proxy(this.audio.context, r.context);
|
|
4508
4594
|
}
|
|
4509
4595
|
close() {
|
|
4510
|
-
this.signals.close();
|
|
4596
|
+
this.signals.close(), this.#e.close(), this.#t.close(), this.sync.close();
|
|
4511
4597
|
}
|
|
4512
4598
|
}
|
|
4513
|
-
class
|
|
4599
|
+
class ur {
|
|
4514
4600
|
muxer;
|
|
4515
4601
|
source;
|
|
4516
4602
|
volume;
|
|
@@ -4523,7 +4609,7 @@ class tr {
|
|
|
4523
4609
|
context = new h(void 0);
|
|
4524
4610
|
#n = new E();
|
|
4525
4611
|
constructor(e, n, s) {
|
|
4526
|
-
this.muxer = e, this.source = n, this.source.supported.set(
|
|
4612
|
+
this.muxer = e, this.source = n, this.source.supported.set(lr), 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.#o.bind(this));
|
|
4527
4613
|
}
|
|
4528
4614
|
#s(e) {
|
|
4529
4615
|
const n = e.get(this.muxer.element);
|
|
@@ -4544,9 +4630,9 @@ class tr {
|
|
|
4544
4630
|
}), e.event(u, "error", (d) => {
|
|
4545
4631
|
console.error("[MSE] SourceBuffer error:", d);
|
|
4546
4632
|
}), e.event(u, "updateend", () => {
|
|
4547
|
-
this.#t.set(
|
|
4633
|
+
this.#t.set(Gt(u.buffered));
|
|
4548
4634
|
});
|
|
4549
|
-
const l = r.subscribe(o,
|
|
4635
|
+
const l = r.subscribe(o, te.audio);
|
|
4550
4636
|
e.cleanup(() => l.close()), c.container.kind === "cmaf" ? this.#r(e, l, c, u, n) : this.#a(e, l, c, u, n);
|
|
4551
4637
|
}
|
|
4552
4638
|
async #i(e, n) {
|
|
@@ -4557,53 +4643,53 @@ class tr {
|
|
|
4557
4643
|
}
|
|
4558
4644
|
#r(e, n, s, i, r) {
|
|
4559
4645
|
if (s.container.kind !== "cmaf") throw new Error("unreachable");
|
|
4560
|
-
const o =
|
|
4646
|
+
const o = K(s.container.init), c = oe(o);
|
|
4561
4647
|
e.spawn(async () => {
|
|
4562
4648
|
for (await this.#i(i, o); ; ) {
|
|
4563
4649
|
const a = await n.readFrame();
|
|
4564
4650
|
if (!a) return;
|
|
4565
|
-
const u =
|
|
4566
|
-
this.source.sync.received(
|
|
4651
|
+
const u = Pt(a, c);
|
|
4652
|
+
this.source.sync.received(A.Time.Milli.fromMicro(u), "audio"), await this.#i(i, a), r.buffered.length > 0 && r.currentTime < r.buffered.start(0) && (r.currentTime = r.buffered.start(0));
|
|
4567
4653
|
}
|
|
4568
4654
|
});
|
|
4569
4655
|
}
|
|
4570
4656
|
#a(e, n, s, i, r) {
|
|
4571
|
-
const o = new
|
|
4572
|
-
format:
|
|
4657
|
+
const o = s.container.kind === "loc" ? new ke() : new Te(), c = new se(n, {
|
|
4658
|
+
format: o,
|
|
4573
4659
|
latency: this.source.sync.buffer
|
|
4574
4660
|
});
|
|
4575
|
-
e.cleanup(() =>
|
|
4576
|
-
const
|
|
4577
|
-
await this.#i(i,
|
|
4578
|
-
let
|
|
4661
|
+
e.cleanup(() => c.close()), e.spawn(async () => {
|
|
4662
|
+
const a = Ui(s);
|
|
4663
|
+
await this.#i(i, a);
|
|
4664
|
+
let u = 1, l, d;
|
|
4579
4665
|
for (; ; ) {
|
|
4580
|
-
const
|
|
4581
|
-
if (!
|
|
4582
|
-
if (!
|
|
4583
|
-
|
|
4584
|
-
const
|
|
4585
|
-
this.source.sync.received(
|
|
4666
|
+
const f = await c.next();
|
|
4667
|
+
if (!f) return;
|
|
4668
|
+
if (!f.frame) continue;
|
|
4669
|
+
d = f.frame;
|
|
4670
|
+
const p = A.Time.Milli.fromMicro(d.timestamp);
|
|
4671
|
+
this.source.sync.received(p, "audio");
|
|
4586
4672
|
break;
|
|
4587
4673
|
}
|
|
4588
4674
|
for (; ; ) {
|
|
4589
|
-
const
|
|
4590
|
-
if (
|
|
4591
|
-
const
|
|
4592
|
-
if (
|
|
4593
|
-
|
|
4594
|
-
const
|
|
4595
|
-
this.source.sync.received(
|
|
4675
|
+
const f = await c.next();
|
|
4676
|
+
if (f && !f.frame) continue;
|
|
4677
|
+
const p = f?.frame;
|
|
4678
|
+
if (p) {
|
|
4679
|
+
l = A.Time.Micro.sub(p.timestamp, d.timestamp);
|
|
4680
|
+
const w = A.Time.Milli.fromMicro(p.timestamp);
|
|
4681
|
+
this.source.sync.received(w, "audio");
|
|
4596
4682
|
}
|
|
4597
|
-
const
|
|
4598
|
-
data:
|
|
4599
|
-
timestamp:
|
|
4600
|
-
duration:
|
|
4683
|
+
const b = Vt({
|
|
4684
|
+
data: d.data,
|
|
4685
|
+
timestamp: d.timestamp,
|
|
4686
|
+
duration: l ?? 0,
|
|
4601
4687
|
// Default to 0 duration if there's literally one frame then stream FIN.
|
|
4602
|
-
keyframe:
|
|
4603
|
-
sequence:
|
|
4688
|
+
keyframe: d.keyframe,
|
|
4689
|
+
sequence: u++
|
|
4604
4690
|
});
|
|
4605
|
-
if (await this.#i(i,
|
|
4606
|
-
|
|
4691
|
+
if (await this.#i(i, b), r.buffered.length > 0 && r.currentTime < r.buffered.start(0) && (r.currentTime = r.buffered.start(0)), !p) return;
|
|
4692
|
+
d = p;
|
|
4607
4693
|
}
|
|
4608
4694
|
});
|
|
4609
4695
|
}
|
|
@@ -4619,11 +4705,11 @@ class tr {
|
|
|
4619
4705
|
this.#n.close();
|
|
4620
4706
|
}
|
|
4621
4707
|
}
|
|
4622
|
-
async function
|
|
4708
|
+
async function lr(t) {
|
|
4623
4709
|
return MediaSource.isTypeSupported(`audio/mp4; codecs="${t.codec}"`);
|
|
4624
4710
|
}
|
|
4625
|
-
const
|
|
4626
|
-
class
|
|
4711
|
+
const dr = 128;
|
|
4712
|
+
class hr {
|
|
4627
4713
|
broadcast;
|
|
4628
4714
|
target;
|
|
4629
4715
|
#e = new h(void 0);
|
|
@@ -4665,7 +4751,7 @@ class ir {
|
|
|
4665
4751
|
i = { track: s.name, config: n[s.name] };
|
|
4666
4752
|
else if (i = this.#c(n), !i) return;
|
|
4667
4753
|
e.set(this.#n, i.track), e.set(this.#s, i.config);
|
|
4668
|
-
const r = i.config.jitter ??
|
|
4754
|
+
const r = i.config.jitter ?? fr(i.config) ?? 0, o = Math.ceil(dr / i.config.sampleRate * 1e3), c = r + o;
|
|
4669
4755
|
e.set(this.sync.audio, c);
|
|
4670
4756
|
}
|
|
4671
4757
|
/**
|
|
@@ -4677,6 +4763,9 @@ class ir {
|
|
|
4677
4763
|
for (const [s, i] of n)
|
|
4678
4764
|
if (i.container.kind === "legacy")
|
|
4679
4765
|
return { track: s, config: i };
|
|
4766
|
+
for (const [s, i] of n)
|
|
4767
|
+
if (i.container.kind === "loc")
|
|
4768
|
+
return { track: s, config: i };
|
|
4680
4769
|
for (const [s, i] of n)
|
|
4681
4770
|
if (i.container.kind === "cmaf")
|
|
4682
4771
|
return { track: s, config: i };
|
|
@@ -4686,65 +4775,65 @@ class ir {
|
|
|
4686
4775
|
this.#i.close();
|
|
4687
4776
|
}
|
|
4688
4777
|
}
|
|
4689
|
-
function
|
|
4778
|
+
function fr(t) {
|
|
4690
4779
|
if (t.codec.startsWith("opus"))
|
|
4691
4780
|
return 20;
|
|
4692
4781
|
if (t.codec.startsWith("mp4a"))
|
|
4693
4782
|
return Math.ceil(1024 / t.sampleRate * 1e3);
|
|
4694
4783
|
}
|
|
4695
|
-
const
|
|
4696
|
-
/* @__PURE__ */
|
|
4697
|
-
/* @__PURE__ */
|
|
4698
|
-
]),
|
|
4699
|
-
/* @__PURE__ */
|
|
4700
|
-
/* @__PURE__ */
|
|
4701
|
-
]),
|
|
4702
|
-
name: /* @__PURE__ */
|
|
4703
|
-
packaging:
|
|
4704
|
-
isLive: /* @__PURE__ */
|
|
4705
|
-
role: /* @__PURE__ */ m(
|
|
4706
|
-
codec: /* @__PURE__ */ m(/* @__PURE__ */
|
|
4784
|
+
const mr = /* @__PURE__ */ Me([
|
|
4785
|
+
/* @__PURE__ */ Ut(["loc", "cmaf", "legacy", "mediatimeline", "eventtimeline"]),
|
|
4786
|
+
/* @__PURE__ */ S()
|
|
4787
|
+
]), pr = /* @__PURE__ */ Me([
|
|
4788
|
+
/* @__PURE__ */ Ut(["video", "audio", "audiodescription", "caption", "subtitle", "signlanguage"]),
|
|
4789
|
+
/* @__PURE__ */ S()
|
|
4790
|
+
]), gr = /* @__PURE__ */ z({
|
|
4791
|
+
name: /* @__PURE__ */ S(),
|
|
4792
|
+
packaging: mr,
|
|
4793
|
+
isLive: /* @__PURE__ */ Ie(),
|
|
4794
|
+
role: /* @__PURE__ */ m(pr),
|
|
4795
|
+
codec: /* @__PURE__ */ m(/* @__PURE__ */ S()),
|
|
4707
4796
|
width: /* @__PURE__ */ m(/* @__PURE__ */ U()),
|
|
4708
4797
|
height: /* @__PURE__ */ m(/* @__PURE__ */ U()),
|
|
4709
4798
|
framerate: /* @__PURE__ */ m(/* @__PURE__ */ U()),
|
|
4710
4799
|
samplerate: /* @__PURE__ */ m(/* @__PURE__ */ U()),
|
|
4711
|
-
channelConfig: /* @__PURE__ */ m(/* @__PURE__ */
|
|
4800
|
+
channelConfig: /* @__PURE__ */ m(/* @__PURE__ */ S()),
|
|
4712
4801
|
bitrate: /* @__PURE__ */ m(/* @__PURE__ */ U()),
|
|
4713
|
-
initData: /* @__PURE__ */ m(/* @__PURE__ */
|
|
4802
|
+
initData: /* @__PURE__ */ m(/* @__PURE__ */ S()),
|
|
4714
4803
|
renderGroup: /* @__PURE__ */ m(/* @__PURE__ */ U()),
|
|
4715
4804
|
altGroup: /* @__PURE__ */ m(/* @__PURE__ */ U()),
|
|
4716
4805
|
// Non-standard: maximum delay (ms) between consecutive frames on this track.
|
|
4717
4806
|
// The player's buffer must be at least this large to avoid underruns.
|
|
4718
4807
|
// Mirrors the `jitter` field in the hang catalog.
|
|
4719
4808
|
jitter: /* @__PURE__ */ m(/* @__PURE__ */ U())
|
|
4720
|
-
}),
|
|
4721
|
-
version: /* @__PURE__ */
|
|
4722
|
-
tracks: /* @__PURE__ */ q(
|
|
4809
|
+
}), wr = /* @__PURE__ */ z({
|
|
4810
|
+
version: /* @__PURE__ */ ye(1),
|
|
4811
|
+
tracks: /* @__PURE__ */ q(gr)
|
|
4723
4812
|
});
|
|
4724
|
-
function
|
|
4813
|
+
function yr(t) {
|
|
4725
4814
|
const n = new TextDecoder().decode(t);
|
|
4726
4815
|
try {
|
|
4727
4816
|
const s = JSON.parse(n);
|
|
4728
|
-
return
|
|
4817
|
+
return wr.parse(s);
|
|
4729
4818
|
} catch (s) {
|
|
4730
4819
|
throw console.warn("invalid MSF catalog", n), s;
|
|
4731
4820
|
}
|
|
4732
4821
|
}
|
|
4733
|
-
async function
|
|
4822
|
+
async function br(t) {
|
|
4734
4823
|
const e = await t.readFrame();
|
|
4735
4824
|
if (e)
|
|
4736
|
-
return
|
|
4825
|
+
return yr(e);
|
|
4737
4826
|
}
|
|
4738
|
-
const
|
|
4739
|
-
function
|
|
4827
|
+
const vr = 48e3, ut = 2;
|
|
4828
|
+
function Sr(t) {
|
|
4740
4829
|
let e = "";
|
|
4741
4830
|
for (let n = 0; n < t.length; n++) e += t[n].toString(16).padStart(2, "0");
|
|
4742
4831
|
return e;
|
|
4743
4832
|
}
|
|
4744
|
-
function
|
|
4833
|
+
function Xt(t) {
|
|
4745
4834
|
let e;
|
|
4746
4835
|
try {
|
|
4747
|
-
e = t.initData ?
|
|
4836
|
+
e = t.initData ? K(t.initData) : void 0;
|
|
4748
4837
|
} catch {
|
|
4749
4838
|
e = void 0;
|
|
4750
4839
|
}
|
|
@@ -4755,12 +4844,12 @@ function qt(t) {
|
|
|
4755
4844
|
description: void 0
|
|
4756
4845
|
} : {
|
|
4757
4846
|
container: { kind: "legacy" },
|
|
4758
|
-
description: e ?
|
|
4847
|
+
description: e ? Sr(e) : void 0
|
|
4759
4848
|
};
|
|
4760
4849
|
}
|
|
4761
|
-
function
|
|
4850
|
+
function Ar(t) {
|
|
4762
4851
|
if (!t.codec) return;
|
|
4763
|
-
const { container: e, description: n } =
|
|
4852
|
+
const { container: e, description: n } = Xt(t);
|
|
4764
4853
|
return {
|
|
4765
4854
|
codec: t.codec,
|
|
4766
4855
|
container: e,
|
|
@@ -4772,43 +4861,48 @@ function mr(t) {
|
|
|
4772
4861
|
jitter: t.jitter != null ? V(t.jitter) : void 0
|
|
4773
4862
|
};
|
|
4774
4863
|
}
|
|
4775
|
-
function
|
|
4864
|
+
function _r(t) {
|
|
4776
4865
|
if (!t.codec) return;
|
|
4777
4866
|
const e = (() => {
|
|
4778
|
-
if (!t.channelConfig) return
|
|
4867
|
+
if (!t.channelConfig) return ut;
|
|
4779
4868
|
const i = Number.parseInt(t.channelConfig, 10);
|
|
4780
|
-
return Number.isFinite(i) ? i :
|
|
4781
|
-
})(), { container: n, description: s } =
|
|
4869
|
+
return Number.isFinite(i) ? i : ut;
|
|
4870
|
+
})(), { container: n, description: s } = Xt(t);
|
|
4782
4871
|
return {
|
|
4783
4872
|
codec: t.codec,
|
|
4784
4873
|
container: n,
|
|
4785
4874
|
description: s,
|
|
4786
|
-
sampleRate: V(t.samplerate ??
|
|
4875
|
+
sampleRate: V(t.samplerate ?? vr),
|
|
4787
4876
|
numberOfChannels: V(e),
|
|
4788
4877
|
bitrate: t.bitrate != null ? V(t.bitrate) : void 0,
|
|
4789
4878
|
jitter: t.jitter != null ? V(t.jitter) : void 0
|
|
4790
4879
|
};
|
|
4791
4880
|
}
|
|
4792
|
-
function
|
|
4881
|
+
function zr(t) {
|
|
4793
4882
|
const e = {}, n = {};
|
|
4794
4883
|
for (const i of t.tracks)
|
|
4795
4884
|
if (i.role === "video") {
|
|
4796
|
-
const r =
|
|
4885
|
+
const r = Ar(i);
|
|
4797
4886
|
r && (e[i.name] = r);
|
|
4798
4887
|
} else if (i.role === "audio") {
|
|
4799
|
-
const r =
|
|
4888
|
+
const r = _r(i);
|
|
4800
4889
|
r && (n[i.name] = r);
|
|
4801
4890
|
}
|
|
4802
4891
|
const s = {};
|
|
4803
4892
|
return Object.keys(e).length > 0 && (s.video = { renditions: e }), Object.keys(n).length > 0 && (s.audio = { renditions: n }), s;
|
|
4804
4893
|
}
|
|
4805
|
-
const
|
|
4806
|
-
|
|
4894
|
+
const Mr = [...Rt, "manual"];
|
|
4895
|
+
function Or(t) {
|
|
4896
|
+
if (t !== null)
|
|
4897
|
+
return Mr.find((e) => e === t);
|
|
4898
|
+
}
|
|
4899
|
+
class Lr {
|
|
4807
4900
|
connection;
|
|
4808
4901
|
enabled;
|
|
4809
4902
|
name;
|
|
4810
4903
|
status = new h("offline");
|
|
4811
4904
|
reload;
|
|
4905
|
+
// `undefined` means auto-detect from the broadcast name extension.
|
|
4812
4906
|
catalogFormat;
|
|
4813
4907
|
#e = new h(void 0);
|
|
4814
4908
|
active = this.#e;
|
|
@@ -4823,7 +4917,7 @@ class Tr {
|
|
|
4823
4917
|
#n = new h(!1);
|
|
4824
4918
|
signals = new E();
|
|
4825
4919
|
constructor(e) {
|
|
4826
|
-
this.connection = h.from(e?.connection), this.name = h.from(e?.name ??
|
|
4920
|
+
this.connection = h.from(e?.connection), this.name = h.from(e?.name ?? en.empty()), this.enabled = h.from(e?.enabled ?? !1), this.reload = h.from(e?.reload ?? !1), this.catalogFormat = h.from(e?.catalogFormat), this.catalog = h.from(e?.catalog), this.#t = e?.announced ?? new h(/* @__PURE__ */ new Set()), this.signals.run(this.#s.bind(this)), this.signals.run(this.#i.bind(this)), this.signals.run(this.#r.bind(this));
|
|
4827
4921
|
}
|
|
4828
4922
|
#s(e) {
|
|
4829
4923
|
if (!e.get(this.reload)) {
|
|
@@ -4846,30 +4940,30 @@ class Tr {
|
|
|
4846
4940
|
}
|
|
4847
4941
|
#r(e) {
|
|
4848
4942
|
if (!e.get(this.enabled)) return;
|
|
4849
|
-
const s = e.get(this.catalogFormat);
|
|
4850
|
-
if (
|
|
4851
|
-
const
|
|
4852
|
-
this.status.set(
|
|
4943
|
+
const s = e.get(this.catalogFormat), i = e.get(this.name), r = s ?? As(i) ?? Ss;
|
|
4944
|
+
if (r === "manual") {
|
|
4945
|
+
const l = e.get(this.catalog);
|
|
4946
|
+
this.status.set(l ? "live" : "loading");
|
|
4853
4947
|
return;
|
|
4854
4948
|
}
|
|
4855
|
-
const
|
|
4856
|
-
if (!
|
|
4949
|
+
const o = e.get(this.active);
|
|
4950
|
+
if (!o) return;
|
|
4857
4951
|
this.status.set("loading");
|
|
4858
|
-
const
|
|
4859
|
-
e.cleanup(() =>
|
|
4860
|
-
const
|
|
4861
|
-
const
|
|
4862
|
-
return
|
|
4952
|
+
const c = r === "hang" ? "catalog.json" : "catalog", a = o.subscribe(c, te.catalog);
|
|
4953
|
+
e.cleanup(() => a.close());
|
|
4954
|
+
const u = r === "hang" ? async () => Es(a) : async () => {
|
|
4955
|
+
const l = await br(a);
|
|
4956
|
+
return l ? zr(l) : void 0;
|
|
4863
4957
|
};
|
|
4864
4958
|
e.spawn(async () => {
|
|
4865
4959
|
try {
|
|
4866
4960
|
for (; ; ) {
|
|
4867
|
-
const
|
|
4868
|
-
if (!
|
|
4869
|
-
console.debug("received catalog",
|
|
4961
|
+
const l = await Promise.race([e.cancel, u()]);
|
|
4962
|
+
if (!l) break;
|
|
4963
|
+
console.debug("received catalog", r, this.name.peek(), l), this.catalog.set(l), this.status.set("live");
|
|
4870
4964
|
}
|
|
4871
|
-
} catch (
|
|
4872
|
-
console.warn("error fetching catalog", this.name.peek(),
|
|
4965
|
+
} catch (l) {
|
|
4966
|
+
console.warn("error fetching catalog", this.name.peek(), l);
|
|
4873
4967
|
} finally {
|
|
4874
4968
|
this.catalog.set(void 0), this.status.set("offline");
|
|
4875
4969
|
}
|
|
@@ -4880,26 +4974,27 @@ class Tr {
|
|
|
4880
4974
|
}
|
|
4881
4975
|
}
|
|
4882
4976
|
export {
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4977
|
+
Lr as B,
|
|
4978
|
+
Mr as C,
|
|
4979
|
+
Yi as D,
|
|
4980
|
+
qi as E,
|
|
4981
|
+
Qi as M,
|
|
4982
|
+
te as P,
|
|
4983
|
+
tr as R,
|
|
4984
|
+
or as S,
|
|
4891
4985
|
m as a,
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4986
|
+
Ie as b,
|
|
4987
|
+
Vi as c,
|
|
4988
|
+
ur as d,
|
|
4989
|
+
hr as e,
|
|
4990
|
+
Ur as f,
|
|
4991
|
+
Ct as g,
|
|
4992
|
+
Dr as h,
|
|
4993
|
+
je as i,
|
|
4994
|
+
Rr as m,
|
|
4995
|
+
z as o,
|
|
4996
|
+
Or as p,
|
|
4997
|
+
S as s,
|
|
4998
|
+
Gt as t
|
|
4904
4999
|
};
|
|
4905
|
-
//# sourceMappingURL=broadcast-
|
|
5000
|
+
//# sourceMappingURL=broadcast-CLjMphZS.js.map
|