@ikonai/sdk 0.0.42 → 1.0.0
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/assets/audio-capture-worker-kpORDYGU.js +1138 -0
- package/assets/{audio-playback-worker-CYoIqiGJ.js → audio-playback-worker-Cwm3GaAx.js} +321 -212
- package/assets/{protocol-worker-E7o-6_bZ.js → protocol-worker-DKSTqFKg.js} +228 -207
- package/assets/video-capture-worker-BBs_62Fq.js +963 -0
- package/assets/video-playback-worker-Bfm3r5xW.js +924 -0
- package/client/ikon-client-config.d.ts +6 -10
- package/client/ikon-client.d.ts +4 -5
- package/index.js +1530 -1304
- package/media/audio-constants.d.ts +5 -0
- package/media/ikon-audio-playback.d.ts +53 -0
- package/media/ikon-video-capture.d.ts +0 -1
- package/media/ikon-video-playback.d.ts +0 -2
- package/media/video-constants.d.ts +42 -0
- package/package.json +1 -1
- package/worker/audio-playback-worker.d.ts +3 -0
- package/worker/video-capture-worker.d.ts +3 -1
- package/worker/video-playback-worker.d.ts +3 -0
- package/assets/audio-capture-worker-zx_Os6ad.js +0 -1112
- package/assets/video-capture-worker-CTRX9PKp.js +0 -843
- package/assets/video-playback-worker-CIuL9Crw.js +0 -875
|
@@ -1,875 +0,0 @@
|
|
|
1
|
-
function J(t) {
|
|
2
|
-
if (t.length < 8)
|
|
3
|
-
throw new Error("Protocol message too short");
|
|
4
|
-
return (t[4] | t[5] << 8 | t[6] << 16 | t[7] << 24) >>> 0;
|
|
5
|
-
}
|
|
6
|
-
function x(t) {
|
|
7
|
-
const r = D(t), e = new DataView(r.buffer, r.byteOffset, r.byteLength);
|
|
8
|
-
if (r.length < 27)
|
|
9
|
-
throw new Error("Protocol payload too short");
|
|
10
|
-
const s = e.getUint32(0, !0), n = e.getUint32(4, !0), E = e.getUint32(8, !0), _ = e.getUint32(12, !0), a = e.getUint32(16, !0), f = e.getUint32(20, !0), $ = e.getUint8(24), j = e.getUint8(25), Q = e.getUint8(26);
|
|
11
|
-
if (27 + f * 4 > r.length)
|
|
12
|
-
throw new Error("Protocol header exceeds payload length");
|
|
13
|
-
const B = [];
|
|
14
|
-
let b = 27;
|
|
15
|
-
for (let H = 0; H < f; H++)
|
|
16
|
-
B.push(e.getUint32(b, !0)), b += 4;
|
|
17
|
-
return {
|
|
18
|
-
length: s,
|
|
19
|
-
opcode: n,
|
|
20
|
-
senderId: E,
|
|
21
|
-
trackId: _,
|
|
22
|
-
sequenceId: a,
|
|
23
|
-
targetIds: B,
|
|
24
|
-
payloadVersion: $,
|
|
25
|
-
payloadType: j,
|
|
26
|
-
flags: Q
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function Y(t, r, e) {
|
|
30
|
-
const s = D(t), n = x(s);
|
|
31
|
-
if (r !== void 0 && n.opcode !== r)
|
|
32
|
-
throw new Error(`Unexpected opcode ${n.opcode}`);
|
|
33
|
-
if (n.payloadVersion !== e)
|
|
34
|
-
throw new Error(`Unexpected payload version ${n.payloadVersion}`);
|
|
35
|
-
if (n.payloadType !== 8)
|
|
36
|
-
throw new Error(`Unexpected payload type ${n.payloadType}`);
|
|
37
|
-
const E = 27 + n.targetIds.length * 4;
|
|
38
|
-
return s.subarray(E, n.length);
|
|
39
|
-
}
|
|
40
|
-
var u = /* @__PURE__ */ ((t) => (t[t.Null = 1] = "Null", t[t.Bool = 2] = "Bool", t[t.Int32 = 3] = "Int32", t[t.Int64 = 4] = "Int64", t[t.UInt32 = 5] = "UInt32", t[t.UInt64 = 6] = "UInt64", t[t.Float32 = 7] = "Float32", t[t.Float64 = 8] = "Float64", t[t.Array = 9] = "Array", t[t.Dict = 10] = "Dict", t[t.Object = 11] = "Object", t[t.String = 12] = "String", t[t.Binary = 13] = "Binary", t[t.Guid = 14] = "Guid", t))(u || {});
|
|
41
|
-
const d = 161, Z = 162;
|
|
42
|
-
new TextEncoder();
|
|
43
|
-
const p = new TextDecoder("utf-8", { fatal: !0 });
|
|
44
|
-
class L {
|
|
45
|
-
constructor(r, e, s) {
|
|
46
|
-
this.buffer = r, this.version = e, this.offset = s, this.end = r.length - 1;
|
|
47
|
-
}
|
|
48
|
-
offset;
|
|
49
|
-
end;
|
|
50
|
-
static create(r) {
|
|
51
|
-
const e = D(r);
|
|
52
|
-
if (e.length < 2)
|
|
53
|
-
throw new Error("Teleport payload too short");
|
|
54
|
-
if (e[0] !== d || e[e.length - 1] !== Z)
|
|
55
|
-
throw new Error("Teleport object missing markers");
|
|
56
|
-
const s = { offset: 1 }, n = T(e, s, "InvalidLength");
|
|
57
|
-
return new L(e, n, s.offset);
|
|
58
|
-
}
|
|
59
|
-
next() {
|
|
60
|
-
if (this.offset >= this.end)
|
|
61
|
-
return null;
|
|
62
|
-
if (this.offset + 5 > this.buffer.length)
|
|
63
|
-
throw new Error("Teleport object truncated");
|
|
64
|
-
const r = st(this.buffer, this.offset);
|
|
65
|
-
this.offset += 4;
|
|
66
|
-
const e = this.buffer[this.offset++], s = e >> 4 & 15;
|
|
67
|
-
if ((e & 15) !== 0)
|
|
68
|
-
throw new Error("Teleport field flags must be zero");
|
|
69
|
-
const n = R(s);
|
|
70
|
-
let E;
|
|
71
|
-
if (n >= 0)
|
|
72
|
-
i(this.buffer, this.offset, n), E = this.buffer.subarray(this.offset, this.offset + n), this.offset += n;
|
|
73
|
-
else {
|
|
74
|
-
const _ = { offset: this.offset }, a = T(this.buffer, _, "InvalidLength");
|
|
75
|
-
i(this.buffer, _.offset, a), E = this.buffer.subarray(_.offset, _.offset + a), this.offset = _.offset + a;
|
|
76
|
-
}
|
|
77
|
-
return new tt(r, s, E);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
class N {
|
|
81
|
-
constructor(r, e) {
|
|
82
|
-
this.type = r, this.payload = e;
|
|
83
|
-
}
|
|
84
|
-
asInt32() {
|
|
85
|
-
return this.ensureType(
|
|
86
|
-
3
|
|
87
|
-
/* Int32 */
|
|
88
|
-
), new DataView(this.payload.buffer, this.payload.byteOffset, 4).getInt32(0, !0);
|
|
89
|
-
}
|
|
90
|
-
asUInt32() {
|
|
91
|
-
return this.ensureType(
|
|
92
|
-
5
|
|
93
|
-
/* UInt32 */
|
|
94
|
-
), new DataView(this.payload.buffer, this.payload.byteOffset, 4).getUint32(0, !0);
|
|
95
|
-
}
|
|
96
|
-
asInt64() {
|
|
97
|
-
return this.ensureType(
|
|
98
|
-
4
|
|
99
|
-
/* Int64 */
|
|
100
|
-
), new DataView(this.payload.buffer, this.payload.byteOffset, 8).getBigInt64(0, !0);
|
|
101
|
-
}
|
|
102
|
-
asUInt64() {
|
|
103
|
-
return this.ensureType(
|
|
104
|
-
6
|
|
105
|
-
/* UInt64 */
|
|
106
|
-
), new DataView(this.payload.buffer, this.payload.byteOffset, 8).getBigUint64(0, !0);
|
|
107
|
-
}
|
|
108
|
-
asFloat32() {
|
|
109
|
-
return this.ensureType(
|
|
110
|
-
7
|
|
111
|
-
/* Float32 */
|
|
112
|
-
), new DataView(this.payload.buffer, this.payload.byteOffset, 4).getFloat32(0, !0);
|
|
113
|
-
}
|
|
114
|
-
asFloat64() {
|
|
115
|
-
return this.ensureType(
|
|
116
|
-
8
|
|
117
|
-
/* Float64 */
|
|
118
|
-
), new DataView(this.payload.buffer, this.payload.byteOffset, 8).getFloat64(0, !0);
|
|
119
|
-
}
|
|
120
|
-
asBool() {
|
|
121
|
-
return this.ensureType(
|
|
122
|
-
2
|
|
123
|
-
/* Bool */
|
|
124
|
-
), this.payload.length > 0 && this.payload[0] !== 0;
|
|
125
|
-
}
|
|
126
|
-
asBinary() {
|
|
127
|
-
return this.ensureType(
|
|
128
|
-
13
|
|
129
|
-
/* Binary */
|
|
130
|
-
), this.payload;
|
|
131
|
-
}
|
|
132
|
-
asUtf8() {
|
|
133
|
-
return this.ensureType(
|
|
134
|
-
12
|
|
135
|
-
/* String */
|
|
136
|
-
), this.payload;
|
|
137
|
-
}
|
|
138
|
-
asString() {
|
|
139
|
-
return this.ensureType(
|
|
140
|
-
12
|
|
141
|
-
/* String */
|
|
142
|
-
), p.decode(this.payload);
|
|
143
|
-
}
|
|
144
|
-
asGuid() {
|
|
145
|
-
return this.ensureType(
|
|
146
|
-
14
|
|
147
|
-
/* Guid */
|
|
148
|
-
), I.fromBytes(this.payload);
|
|
149
|
-
}
|
|
150
|
-
asObject() {
|
|
151
|
-
return this.ensureType(
|
|
152
|
-
11
|
|
153
|
-
/* Object */
|
|
154
|
-
), L.create(this.payload);
|
|
155
|
-
}
|
|
156
|
-
asArray() {
|
|
157
|
-
return this.ensureType(
|
|
158
|
-
9
|
|
159
|
-
/* Array */
|
|
160
|
-
), F.create(this.payload);
|
|
161
|
-
}
|
|
162
|
-
asDictionary() {
|
|
163
|
-
return this.ensureType(
|
|
164
|
-
10
|
|
165
|
-
/* Dict */
|
|
166
|
-
), V.create(this.payload);
|
|
167
|
-
}
|
|
168
|
-
ensureType(r) {
|
|
169
|
-
if (this.type !== r)
|
|
170
|
-
throw new Error(`Teleport value has type ${u[this.type]}, expected ${u[r]}`);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
class tt extends N {
|
|
174
|
-
constructor(r, e, s) {
|
|
175
|
-
super(e, s), this.fieldId = r;
|
|
176
|
-
}
|
|
177
|
-
get isNull() {
|
|
178
|
-
return this.type === 1;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
class F {
|
|
182
|
-
payload;
|
|
183
|
-
elementType;
|
|
184
|
-
count;
|
|
185
|
-
offset;
|
|
186
|
-
index = 0;
|
|
187
|
-
constructor(r) {
|
|
188
|
-
if (this.payload = r, r.length === 0)
|
|
189
|
-
throw new Error("Array payload too short");
|
|
190
|
-
const e = r[0];
|
|
191
|
-
if (this.elementType = e >> 4 & 15, (e & 15) !== 0)
|
|
192
|
-
throw new Error("Array flags must be zero");
|
|
193
|
-
const s = { offset: 1 };
|
|
194
|
-
this.count = T(r, s, "ArrayMalformed"), this.offset = s.offset;
|
|
195
|
-
}
|
|
196
|
-
static create(r) {
|
|
197
|
-
return new F(D(r));
|
|
198
|
-
}
|
|
199
|
-
next() {
|
|
200
|
-
if (this.index >= this.count) {
|
|
201
|
-
if (this.offset !== this.payload.length)
|
|
202
|
-
throw new Error("Array payload contains trailing data");
|
|
203
|
-
return null;
|
|
204
|
-
}
|
|
205
|
-
const r = this.readValue();
|
|
206
|
-
return this.index++, r;
|
|
207
|
-
}
|
|
208
|
-
readValue() {
|
|
209
|
-
switch (this.elementType) {
|
|
210
|
-
case 3:
|
|
211
|
-
case 5:
|
|
212
|
-
case 7:
|
|
213
|
-
case 8:
|
|
214
|
-
case 2:
|
|
215
|
-
case 4:
|
|
216
|
-
case 6:
|
|
217
|
-
case 14: {
|
|
218
|
-
const r = R(this.elementType);
|
|
219
|
-
i(this.payload, this.offset, r);
|
|
220
|
-
const e = this.payload.subarray(this.offset, this.offset + r);
|
|
221
|
-
return this.offset += r, new h(this.elementType, e);
|
|
222
|
-
}
|
|
223
|
-
case 12:
|
|
224
|
-
case 13: {
|
|
225
|
-
const r = { offset: this.offset }, e = T(this.payload, r, "ArrayMalformed");
|
|
226
|
-
i(this.payload, r.offset, e);
|
|
227
|
-
const s = this.payload.subarray(r.offset, r.offset + e);
|
|
228
|
-
return this.offset = r.offset + e, new h(this.elementType, s);
|
|
229
|
-
}
|
|
230
|
-
case 11: {
|
|
231
|
-
const r = { offset: this.offset }, e = T(this.payload, r, "ArrayMalformed");
|
|
232
|
-
i(this.payload, r.offset, e);
|
|
233
|
-
const s = this.payload.subarray(r.offset, r.offset + e);
|
|
234
|
-
return this.offset = r.offset + e, new h(11, s);
|
|
235
|
-
}
|
|
236
|
-
case 9: {
|
|
237
|
-
const r = M(this.payload, this.offset), e = this.payload.subarray(this.offset, this.offset + r);
|
|
238
|
-
return this.offset += r, new h(9, e);
|
|
239
|
-
}
|
|
240
|
-
case 10: {
|
|
241
|
-
const r = G(this.payload, this.offset), e = this.payload.subarray(this.offset, this.offset + r);
|
|
242
|
-
return this.offset += r, new h(10, e);
|
|
243
|
-
}
|
|
244
|
-
default:
|
|
245
|
-
throw new Error(`Unsupported array element type ${u[this.elementType]}`);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
class h extends N {
|
|
250
|
-
constructor(r, e) {
|
|
251
|
-
super(r, e);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
class V {
|
|
255
|
-
payload;
|
|
256
|
-
keyType;
|
|
257
|
-
valueType;
|
|
258
|
-
count;
|
|
259
|
-
offset;
|
|
260
|
-
index = 0;
|
|
261
|
-
constructor(r) {
|
|
262
|
-
if (this.payload = r, r.length < 2)
|
|
263
|
-
throw new Error("Dictionary payload too short");
|
|
264
|
-
if (this.keyType = r[0] >> 4 & 15, this.valueType = r[1] >> 4 & 15, (r[0] & 15) !== 0 || (r[1] & 15) !== 0)
|
|
265
|
-
throw new Error("Dictionary key/value flags must be zero");
|
|
266
|
-
k(this.keyType);
|
|
267
|
-
const e = { offset: 2 };
|
|
268
|
-
this.count = T(r, e, "DictMalformed"), this.offset = e.offset;
|
|
269
|
-
}
|
|
270
|
-
static create(r) {
|
|
271
|
-
return new V(D(r));
|
|
272
|
-
}
|
|
273
|
-
next() {
|
|
274
|
-
if (this.index >= this.count) {
|
|
275
|
-
if (this.offset !== this.payload.length)
|
|
276
|
-
throw new Error("Dictionary payload contains trailing data");
|
|
277
|
-
return null;
|
|
278
|
-
}
|
|
279
|
-
const r = this.readKey(), e = this.readValue();
|
|
280
|
-
return this.index++, new rt(r, e);
|
|
281
|
-
}
|
|
282
|
-
readKey() {
|
|
283
|
-
const r = R(this.keyType);
|
|
284
|
-
if (r >= 0) {
|
|
285
|
-
i(this.payload, this.offset, r);
|
|
286
|
-
const e = this.payload.subarray(this.offset, this.offset + r);
|
|
287
|
-
return this.offset += r, new N(this.keyType, e);
|
|
288
|
-
}
|
|
289
|
-
if (this.keyType === 12 || this.keyType === 13) {
|
|
290
|
-
const e = { offset: this.offset }, s = T(this.payload, e, "DictMalformed");
|
|
291
|
-
i(this.payload, e.offset, s);
|
|
292
|
-
const n = this.payload.subarray(e.offset, e.offset + s);
|
|
293
|
-
return this.offset = e.offset + s, new N(this.keyType, n);
|
|
294
|
-
}
|
|
295
|
-
throw new Error("Unsupported dictionary key type");
|
|
296
|
-
}
|
|
297
|
-
readValue() {
|
|
298
|
-
switch (this.valueType) {
|
|
299
|
-
case 12:
|
|
300
|
-
case 13: {
|
|
301
|
-
const r = { offset: this.offset }, e = T(this.payload, r, "DictMalformed");
|
|
302
|
-
i(this.payload, r.offset, e);
|
|
303
|
-
const s = this.payload.subarray(r.offset, r.offset + e);
|
|
304
|
-
return this.offset = r.offset + e, new N(this.valueType, s);
|
|
305
|
-
}
|
|
306
|
-
case 11: {
|
|
307
|
-
const r = { offset: this.offset }, e = T(this.payload, r, "DictMalformed");
|
|
308
|
-
i(this.payload, r.offset, e);
|
|
309
|
-
const s = this.payload.subarray(r.offset, r.offset + e);
|
|
310
|
-
return this.offset = r.offset + e, new N(11, s);
|
|
311
|
-
}
|
|
312
|
-
case 9: {
|
|
313
|
-
const r = M(this.payload, this.offset), e = this.payload.subarray(this.offset, this.offset + r);
|
|
314
|
-
return this.offset += r, new N(9, e);
|
|
315
|
-
}
|
|
316
|
-
case 10: {
|
|
317
|
-
const r = G(this.payload, this.offset), e = this.payload.subarray(this.offset, this.offset + r);
|
|
318
|
-
return this.offset += r, new N(10, e);
|
|
319
|
-
}
|
|
320
|
-
case 3:
|
|
321
|
-
case 5:
|
|
322
|
-
case 7:
|
|
323
|
-
case 8:
|
|
324
|
-
case 2:
|
|
325
|
-
case 4:
|
|
326
|
-
case 6:
|
|
327
|
-
case 14:
|
|
328
|
-
case 1: {
|
|
329
|
-
const r = R(this.valueType);
|
|
330
|
-
i(this.payload, this.offset, r);
|
|
331
|
-
const e = this.payload.subarray(this.offset, this.offset + r);
|
|
332
|
-
return this.offset += r, new N(this.valueType, e);
|
|
333
|
-
}
|
|
334
|
-
default:
|
|
335
|
-
throw new Error(`Unsupported dictionary value type ${u[this.valueType]}`);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
class rt {
|
|
340
|
-
constructor(r, e) {
|
|
341
|
-
this.key = r, this.value = e;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
class I {
|
|
345
|
-
constructor(r) {
|
|
346
|
-
this.bytes = r;
|
|
347
|
-
}
|
|
348
|
-
static fromString(r) {
|
|
349
|
-
if (!r)
|
|
350
|
-
throw new Error("Guid string is empty");
|
|
351
|
-
const e = r.replace(/-/g, "");
|
|
352
|
-
if (e.length !== 32)
|
|
353
|
-
throw new Error("Guid string must be 32 hex characters");
|
|
354
|
-
const s = new Uint8Array(16), n = I.parseHexSlice(e, 0, 8), E = I.parseHexSlice(e, 8, 4), _ = I.parseHexSlice(e, 12, 4);
|
|
355
|
-
I.writeUInt32LE(s, 0, n), I.writeUInt16LE(s, 4, E), I.writeUInt16LE(s, 6, _);
|
|
356
|
-
for (let a = 0; a < 8; a++)
|
|
357
|
-
s[8 + a] = I.parseHexSlice(e, 16 + a * 2, 2);
|
|
358
|
-
return new I(s);
|
|
359
|
-
}
|
|
360
|
-
static fromBytes(r) {
|
|
361
|
-
if (r.length !== 16)
|
|
362
|
-
throw new Error("Guid byte array must be 16 bytes");
|
|
363
|
-
return new I(Uint8Array.from(r));
|
|
364
|
-
}
|
|
365
|
-
static createZero() {
|
|
366
|
-
return new I(new Uint8Array(16));
|
|
367
|
-
}
|
|
368
|
-
static createRandom() {
|
|
369
|
-
const r = new Uint8Array(16), e = globalThis.crypto;
|
|
370
|
-
if (e?.getRandomValues)
|
|
371
|
-
e.getRandomValues(r);
|
|
372
|
-
else
|
|
373
|
-
for (let s = 0; s < r.length; s++)
|
|
374
|
-
r[s] = Math.floor(Math.random() * 256);
|
|
375
|
-
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, new I(r);
|
|
376
|
-
}
|
|
377
|
-
toString() {
|
|
378
|
-
const r = this.bytes;
|
|
379
|
-
return [
|
|
380
|
-
I.toHex(I.readUInt32LE(r, 0), 8),
|
|
381
|
-
I.toHex(I.readUInt16LE(r, 4), 4),
|
|
382
|
-
I.toHex(I.readUInt16LE(r, 6), 4),
|
|
383
|
-
K(r.subarray(8, 10)),
|
|
384
|
-
K(r.subarray(10, 16))
|
|
385
|
-
].join("-");
|
|
386
|
-
}
|
|
387
|
-
asBytes() {
|
|
388
|
-
return this.bytes.slice();
|
|
389
|
-
}
|
|
390
|
-
static parseHexSlice(r, e, s) {
|
|
391
|
-
const n = r.substr(e, s), E = Number.parseInt(n, 16);
|
|
392
|
-
if (Number.isNaN(E))
|
|
393
|
-
throw new Error("Guid string contains invalid characters");
|
|
394
|
-
return E >>> 0;
|
|
395
|
-
}
|
|
396
|
-
static writeUInt32LE(r, e, s) {
|
|
397
|
-
const n = s >>> 0;
|
|
398
|
-
r[e] = n & 255, r[e + 1] = n >>> 8 & 255, r[e + 2] = n >>> 16 & 255, r[e + 3] = n >>> 24 & 255;
|
|
399
|
-
}
|
|
400
|
-
static writeUInt16LE(r, e, s) {
|
|
401
|
-
const n = s & 65535;
|
|
402
|
-
r[e] = n & 255, r[e + 1] = n >>> 8 & 255;
|
|
403
|
-
}
|
|
404
|
-
static readUInt32LE(r, e) {
|
|
405
|
-
return (r[e] | r[e + 1] << 8 | r[e + 2] << 16 | r[e + 3] << 24) >>> 0;
|
|
406
|
-
}
|
|
407
|
-
static readUInt16LE(r, e) {
|
|
408
|
-
return (r[e] | r[e + 1] << 8) & 65535;
|
|
409
|
-
}
|
|
410
|
-
static toHex(r, e) {
|
|
411
|
-
return (r >>> 0).toString(16).padStart(e, "0");
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
function T(t, r, e) {
|
|
415
|
-
if (r.offset >= t.length)
|
|
416
|
-
throw new Error(e);
|
|
417
|
-
let s = 0, n = 0, E = 0;
|
|
418
|
-
for (; r.offset < t.length; ) {
|
|
419
|
-
const _ = t[r.offset++];
|
|
420
|
-
if (E++, s |= (_ & 127) << n, (_ & 128) === 0) {
|
|
421
|
-
if (E !== et(s))
|
|
422
|
-
throw new Error("Teleport VarUInt is not canonical");
|
|
423
|
-
return s >>> 0;
|
|
424
|
-
}
|
|
425
|
-
if (n += 7, n >= 35)
|
|
426
|
-
throw new Error("Teleport VarUInt exceeds 32-bit range");
|
|
427
|
-
}
|
|
428
|
-
throw new Error(e);
|
|
429
|
-
}
|
|
430
|
-
function et(t) {
|
|
431
|
-
return t < 128 ? 1 : t < 16384 ? 2 : t < 2097152 ? 3 : t < 268435456 ? 4 : 5;
|
|
432
|
-
}
|
|
433
|
-
function R(t) {
|
|
434
|
-
switch (t) {
|
|
435
|
-
case 3:
|
|
436
|
-
case 5:
|
|
437
|
-
case 7:
|
|
438
|
-
return 4;
|
|
439
|
-
case 4:
|
|
440
|
-
case 6:
|
|
441
|
-
case 8:
|
|
442
|
-
return 8;
|
|
443
|
-
case 14:
|
|
444
|
-
return 16;
|
|
445
|
-
case 2:
|
|
446
|
-
return 1;
|
|
447
|
-
case 1:
|
|
448
|
-
return 0;
|
|
449
|
-
default:
|
|
450
|
-
return -1;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
function k(t) {
|
|
454
|
-
if (t === 9 || t === 11 || t === 10 || t === 1)
|
|
455
|
-
throw new Error("Dictionary keys must be primitive Teleport types");
|
|
456
|
-
}
|
|
457
|
-
function i(t, r, e) {
|
|
458
|
-
if (r < 0 || e < 0 || r + e > t.length)
|
|
459
|
-
throw new Error("Teleport payload exceeds bounds");
|
|
460
|
-
}
|
|
461
|
-
function st(t, r) {
|
|
462
|
-
return (t[r] | t[r + 1] << 8 | t[r + 2] << 16 | t[r + 3] << 24) >>> 0;
|
|
463
|
-
}
|
|
464
|
-
function M(t, r) {
|
|
465
|
-
if (r >= t.length)
|
|
466
|
-
throw new Error("Array payload exceeds bounds");
|
|
467
|
-
const e = t[r], s = e >> 4 & 15;
|
|
468
|
-
if ((e & 15) !== 0)
|
|
469
|
-
throw new Error("Array flags must be zero");
|
|
470
|
-
const n = { offset: r + 1 }, E = T(t, n, "ArrayMalformed"), _ = R(s);
|
|
471
|
-
if (_ >= 0) {
|
|
472
|
-
const f = _ * E;
|
|
473
|
-
return i(t, n.offset, f), n.offset + f - r;
|
|
474
|
-
}
|
|
475
|
-
let a = n.offset;
|
|
476
|
-
for (let f = 0; f < E; f++)
|
|
477
|
-
a = g(s, t, a, "ArrayMalformed");
|
|
478
|
-
return a - r;
|
|
479
|
-
}
|
|
480
|
-
function G(t, r) {
|
|
481
|
-
if (r + 2 > t.length)
|
|
482
|
-
throw new Error("Dictionary payload too short");
|
|
483
|
-
const e = t[r] >> 4 & 15, s = t[r + 1] >> 4 & 15;
|
|
484
|
-
if ((t[r] & 15) !== 0 || (t[r + 1] & 15) !== 0)
|
|
485
|
-
throw new Error("Dictionary key/value flags must be zero");
|
|
486
|
-
k(e);
|
|
487
|
-
const n = { offset: r + 2 }, E = T(t, n, "DictMalformed");
|
|
488
|
-
let _ = n.offset;
|
|
489
|
-
for (let a = 0; a < E; a++)
|
|
490
|
-
_ = g(e, t, _, "DictMalformed"), _ = g(s, t, _, "DictMalformed");
|
|
491
|
-
return _ - r;
|
|
492
|
-
}
|
|
493
|
-
function g(t, r, e, s) {
|
|
494
|
-
const n = R(t);
|
|
495
|
-
if (n >= 0)
|
|
496
|
-
return i(r, e, n), e + n;
|
|
497
|
-
switch (t) {
|
|
498
|
-
case 12:
|
|
499
|
-
case 13: {
|
|
500
|
-
const E = { offset: e }, _ = T(r, E, s);
|
|
501
|
-
return i(r, E.offset, _), E.offset + _;
|
|
502
|
-
}
|
|
503
|
-
case 11: {
|
|
504
|
-
const E = { offset: e }, _ = T(r, E, s);
|
|
505
|
-
return i(r, E.offset, _), E.offset + _;
|
|
506
|
-
}
|
|
507
|
-
case 9:
|
|
508
|
-
return e + M(r, e);
|
|
509
|
-
case 10:
|
|
510
|
-
return e + G(r, e);
|
|
511
|
-
default:
|
|
512
|
-
throw new Error(`Unsupported Teleport type ${u[t]}`);
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
function K(t) {
|
|
516
|
-
return Array.from(t).map((r) => r.toString(16).padStart(2, "0")).join("");
|
|
517
|
-
}
|
|
518
|
-
function D(t) {
|
|
519
|
-
return t instanceof Uint8Array ? t : new Uint8Array(t);
|
|
520
|
-
}
|
|
521
|
-
var l = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.H264 = 1] = "H264", t[t.Hevc = 2] = "Hevc", t[t.Vp8 = 3] = "Vp8", t))(l || {}), U = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.CONSTANT_GROUP_BITS = 15] = "CONSTANT_GROUP_BITS", t[t.CONSTANT_GROUP_OFFSET = 16] = "CONSTANT_GROUP_OFFSET", t[t.GROUP_CORE = 65536] = "GROUP_CORE", t[t.CORE_AUTH_RESPONSE = 65537] = "CORE_AUTH_RESPONSE", t[t.CORE_AUTH_TICKET = 65538] = "CORE_AUTH_TICKET", t[t.CORE_GLOBAL_STATE = 65539] = "CORE_GLOBAL_STATE", t[t.CORE_ON_SERVER_STATUS_PING = 65540] = "CORE_ON_SERVER_STATUS_PING", t[t.CORE_ON_USER_JOINED = 65541] = "CORE_ON_USER_JOINED", t[t.CORE_ON_USER_LEFT = 65542] = "CORE_ON_USER_LEFT", t[t.CORE_ON_CLIENT_JOINED = 65543] = "CORE_ON_CLIENT_JOINED", t[t.CORE_ON_CLIENT_LEFT = 65544] = "CORE_ON_CLIENT_LEFT", t[t.CORE_ON_SERVER_STARTED = 65545] = "CORE_ON_SERVER_STARTED", t[t.CORE_ON_SERVER_STOPPED = 65546] = "CORE_ON_SERVER_STOPPED", t[t.CORE_ON_SERVER_STOPPING = 65547] = "CORE_ON_SERVER_STOPPING", t[t.CORE_ON_CLIENT_READY = 65548] = "CORE_ON_CLIENT_READY", t[t.CORE_CLIENT_READY = 65549] = "CORE_CLIENT_READY", t[t.CORE_SERVER_INIT = 65550] = "CORE_SERVER_INIT", t[t.CORE_ON_PLUGIN_RELOADED = 65551] = "CORE_ON_PLUGIN_RELOADED", t[t.CORE_SERVER_START = 65552] = "CORE_SERVER_START", t[t.CORE_SERVER_STOP = 65553] = "CORE_SERVER_STOP", t[t.CORE_ON_HOSTED_SERVER_EXIT = 65554] = "CORE_ON_HOSTED_SERVER_EXIT", t[t.CORE_DYNAMIC_CONFIG = 65555] = "CORE_DYNAMIC_CONFIG", t[t.CORE_PROXY_RPC_AUTH_TICKET = 65556] = "CORE_PROXY_RPC_AUTH_TICKET", t[t.CORE_SERVER_INIT2 = 65557] = "CORE_SERVER_INIT2", t[t.GROUP_KEEPALIVE = 131072] = "GROUP_KEEPALIVE", t[t.KEEPALIVE_REQUEST = 131073] = "KEEPALIVE_REQUEST", t[t.KEEPALIVE_RESPONSE = 131074] = "KEEPALIVE_RESPONSE", t[t.GROUP_EVENTS = 262144] = "GROUP_EVENTS", t[t.EVENTS_PROFILE_UPDATE = 262145] = "EVENTS_PROFILE_UPDATE", t[t.EVENTS_CHANNEL_COMPLETE = 262146] = "EVENTS_CHANNEL_COMPLETE", t[t.EVENTS_SPEECH_PLAYBACK_COMPLETE = 262147] = "EVENTS_SPEECH_PLAYBACK_COMPLETE", t[t.GROUP_ANALYTICS = 524288] = "GROUP_ANALYTICS", t[t.ANALYTICS_LOGS = 524289] = "ANALYTICS_LOGS", t[t.ANALYTICS_EVENTS = 524290] = "ANALYTICS_EVENTS", t[t.ANALYTICS_USAGES = 524291] = "ANALYTICS_USAGES", t[t.ANALYTICS_USAGE = 524292] = "ANALYTICS_USAGE", t[t.ANALYTICS_SPECIAL_LOG = 524293] = "ANALYTICS_SPECIAL_LOG", t[t.ANALYTICS_PROCESSING_UPDATE = 524294] = "ANALYTICS_PROCESSING_UPDATE", t[t.ANALYTICS_REACTIVE_PROCESSING_UPDATE = 524295] = "ANALYTICS_REACTIVE_PROCESSING_UPDATE", t[t.ANALYTICS_IKON_PROXY_SERVER_STATS = 524296] = "ANALYTICS_IKON_PROXY_SERVER_STATS", t[t.GROUP_ACTIONS = 1048576] = "GROUP_ACTIONS", t[t.ACTION_CALL = 1048577] = "ACTION_CALL", t[t.ACTION_ACTIVE = 1048578] = "ACTION_ACTIVE", t[t.ACTION_TEXT_OUTPUT = 1048579] = "ACTION_TEXT_OUTPUT", t[t.ACTION_TEXT_OUTPUT_DELTA = 1048580] = "ACTION_TEXT_OUTPUT_DELTA", t[t.ACTION_TEXT_OUTPUT_DELTA_FULL = 1048581] = "ACTION_TEXT_OUTPUT_DELTA_FULL", t[t.ACTION_SET_STATE = 1048582] = "ACTION_SET_STATE", t[t.ACTION_TAP = 1048583] = "ACTION_TAP", t[t.ACTION_PAN = 1048584] = "ACTION_PAN", t[t.ACTION_ZOOM = 1048585] = "ACTION_ZOOM", t[t.ACTION_FILE_UPLOAD_BEGIN = 1048586] = "ACTION_FILE_UPLOAD_BEGIN", t[t.ACTION_FILE_UPLOAD_DATA = 1048587] = "ACTION_FILE_UPLOAD_DATA", t[t.ACTION_FILE_UPLOAD_ACK = 1048588] = "ACTION_FILE_UPLOAD_ACK", t[t.ACTION_FILE_UPLOAD_END = 1048589] = "ACTION_FILE_UPLOAD_END", t[t.ACTION_FILE_UPLOAD_RESULT = 1048590] = "ACTION_FILE_UPLOAD_RESULT", t[t.ACTION_OPEN_CHANNEL = 1048591] = "ACTION_OPEN_CHANNEL", t[t.ACTION_OPEN_EXTERNAL_URL = 1048592] = "ACTION_OPEN_EXTERNAL_URL", t[t.ACTION_UI_OPEN_VIEW = 1048593] = "ACTION_UI_OPEN_VIEW", t[t.ACTION_UI_CLOSE_VIEW = 1048594] = "ACTION_UI_CLOSE_VIEW", t[t.ACTION_UI_BLOCKING_BEGIN = 1048595] = "ACTION_UI_BLOCKING_BEGIN", t[t.ACTION_UI_BLOCKING_END = 1048596] = "ACTION_UI_BLOCKING_END", t[t.ACTION_UI_UPDATE_TEXT_DELTA = 1048597] = "ACTION_UI_UPDATE_TEXT_DELTA", t[t.ACTION_UI_DELETE_CONTAINER = 1048598] = "ACTION_UI_DELETE_CONTAINER", t[t.ACTION_UPDATE_GFX_SHADER = 1048599] = "ACTION_UPDATE_GFX_SHADER", t[t.ACTION_FUNCTION_REGISTER = 1048600] = "ACTION_FUNCTION_REGISTER", t[t.ACTION_FUNCTION_CALL = 1048601] = "ACTION_FUNCTION_CALL", t[t.ACTION_FUNCTION_RESULT = 1048602] = "ACTION_FUNCTION_RESULT", t[t.ACTION_GENERATE_ANSWER = 1048603] = "ACTION_GENERATE_ANSWER", t[t.ACTION_REGENERATE_ANSWER = 1048604] = "ACTION_REGENERATE_ANSWER", t[t.ACTION_CLEAR_CHAT_MESSAGE_HISTORY = 1048605] = "ACTION_CLEAR_CHAT_MESSAGE_HISTORY", t[t.ACTION_CLEAR_STATE = 1048606] = "ACTION_CLEAR_STATE", t[t.ACTION_RELOAD_CHANNELS = 1048607] = "ACTION_RELOAD_CHANNELS", t[t.ACTION_RELOAD_PROFILE = 1048608] = "ACTION_RELOAD_PROFILE", t[t.ACTION_CLASSIFICATION_RESULT = 1048609] = "ACTION_CLASSIFICATION_RESULT", t[t.ACTION_AUDIO_STOP = 1048610] = "ACTION_AUDIO_STOP", t[t.ACTION_CALL_TEXT = 1048611] = "ACTION_CALL_TEXT", t[t.ACTION_RELOAD_APPLICATION = 1048612] = "ACTION_RELOAD_APPLICATION", t[t.ACTION_CANCEL_GENERATION = 1048613] = "ACTION_CANCEL_GENERATION", t[t.ACTION_UI_SET_CONTAINER_STABLE = 1048614] = "ACTION_UI_SET_CONTAINER_STABLE", t[t.ACTION_SPEECH_RECOGNIZED = 1048615] = "ACTION_SPEECH_RECOGNIZED", t[t.ACTION_CALL_RESULT = 1048616] = "ACTION_CALL_RESULT", t[t.ACTION_RELOAD_PROVIDER = 1048617] = "ACTION_RELOAD_PROVIDER", t[t.ACTION_DOWNLOAD = 1048618] = "ACTION_DOWNLOAD", t[t.ACTION_SCROLL_TO_CONTAINER = 1048619] = "ACTION_SCROLL_TO_CONTAINER", t[t.ACTION_UI_CLEAR_STREAM = 1048620] = "ACTION_UI_CLEAR_STREAM", t[t.ACTION_PLAY_SOUND = 1048621] = "ACTION_PLAY_SOUND", t[t.ACTION_ENTER_FULLSCREEN = 1048622] = "ACTION_ENTER_FULLSCREEN", t[t.ACTION_STOP_SOUND = 1048623] = "ACTION_STOP_SOUND", t[t.ACTION_START_RECORDING = 1048624] = "ACTION_START_RECORDING", t[t.ACTION_STOP_RECORDING = 1048625] = "ACTION_STOP_RECORDING", t[t.ACTION_OPTIMISTIC_CLIENT_CALLS = 1048626] = "ACTION_OPTIMISTIC_CLIENT_CALLS", t[t.ACTION_FUNCTION_ENUMERATION_ITEM = 1048627] = "ACTION_FUNCTION_ENUMERATION_ITEM", t[t.ACTION_FUNCTION_ENUMERATION_END = 1048628] = "ACTION_FUNCTION_ENUMERATION_END", t[t.ACTION_FUNCTION_CANCEL = 1048629] = "ACTION_FUNCTION_CANCEL", t[t.ACTION_FUNCTION_DISPOSE = 1048630] = "ACTION_FUNCTION_DISPOSE", t[t.ACTION_FUNCTION_ERROR = 1048631] = "ACTION_FUNCTION_ERROR", t[t.ACTION_FUNCTION_ACK = 1048632] = "ACTION_FUNCTION_ACK", t[t.ACTION_FUNCTION_AWAITING_APPROVAL = 1048633] = "ACTION_FUNCTION_AWAITING_APPROVAL", t[t.ACTION_FUNCTION_APPROVAL_REQUIRED = 1048634] = "ACTION_FUNCTION_APPROVAL_REQUIRED", t[t.ACTION_FUNCTION_APPROVAL_RESPONSE = 1048635] = "ACTION_FUNCTION_APPROVAL_RESPONSE", t[t.UI_UPDATE_ACK = 1048636] = "UI_UPDATE_ACK", t[t.ACTION_CALL2 = 1048637] = "ACTION_CALL2", t[t.ACTION_FUNCTION_REGISTER_BATCH = 1048638] = "ACTION_FUNCTION_REGISTER_BATCH", t[t.GROUP_UI = 2097152] = "GROUP_UI", t[t.UI_STREAM_BEGIN = 2097153] = "UI_STREAM_BEGIN", t[t.UI_STREAM_END = 2097154] = "UI_STREAM_END", t[t.UI_CONTAINER_BEGIN = 2097155] = "UI_CONTAINER_BEGIN", t[t.UI_CONTAINER_END = 2097156] = "UI_CONTAINER_END", t[t.UI_SECTION_BEGIN = 2097157] = "UI_SECTION_BEGIN", t[t.UI_SECTION_END = 2097158] = "UI_SECTION_END", t[t.UI_LIST_BEGIN = 2097159] = "UI_LIST_BEGIN", t[t.UI_LIST_ITEM = 2097160] = "UI_LIST_ITEM", t[t.UI_LIST_END = 2097161] = "UI_LIST_END", t[t.UI_TEXT = 2097162] = "UI_TEXT", t[t.UI_HEADER = 2097163] = "UI_HEADER", t[t.UI_SEPARATOR = 2097164] = "UI_SEPARATOR", t[t.UI_BUTTON = 2097165] = "UI_BUTTON", t[t.UI_ICON_BUTTON = 2097166] = "UI_ICON_BUTTON", t[t.UI_IMAGE = 2097167] = "UI_IMAGE", t[t.UI_FILE = 2097168] = "UI_FILE", t[t.UI_BADGE = 2097169] = "UI_BADGE", t[t.UI_CONTENT_LINK = 2097170] = "UI_CONTENT_LINK", t[t.UI_MAP = 2097171] = "UI_MAP", t[t.UI_VEGA_CHART = 2097172] = "UI_VEGA_CHART", t[t.UI_ICON = 2097173] = "UI_ICON", t[t.UI_FILE_UPLOAD_SECTION_BEGIN = 2097174] = "UI_FILE_UPLOAD_SECTION_BEGIN", t[t.UI_FILE_UPLOAD_SECTION_END = 2097175] = "UI_FILE_UPLOAD_SECTION_END", t[t.UI_MATERIAL_SYMBOL = 2097176] = "UI_MATERIAL_SYMBOL", t[t.UI_BUTTON_BEGIN = 2097177] = "UI_BUTTON_BEGIN", t[t.UI_BUTTON_END = 2097178] = "UI_BUTTON_END", t[t.UI_CONTAINER_DELETE = 2097179] = "UI_CONTAINER_DELETE", t[t.UI_INPUT_TEXT = 2097180] = "UI_INPUT_TEXT", t[t.UI_PROGRESS_BAR = 2097181] = "UI_PROGRESS_BAR", t[t.UI_UPDATE_BEGIN = 2097182] = "UI_UPDATE_BEGIN", t[t.UI_UPDATE_END = 2097183] = "UI_UPDATE_END", t[t.UI_AUTOCOMPLETE = 2097184] = "UI_AUTOCOMPLETE", t[t.UI_CHECKBOX = 2097185] = "UI_CHECKBOX", t[t.UI_QS = 2097186] = "UI_QS", t[t.UI_ELEMENT = 2097187] = "UI_ELEMENT", t[t.UI_STYLES = 2097188] = "UI_STYLES", t[t.UI_SVG = 2097189] = "UI_SVG", t[t.UI_UPDATE = 2097190] = "UI_UPDATE", t[t.UI_INIT = 2097191] = "UI_INIT", t[t.UI_STYLES_BATCH = 2097192] = "UI_STYLES_BATCH", t[t.GROUP_COMMON = 4128768] = "GROUP_COMMON", t[t.GROUP_AUDIO = 4194304] = "GROUP_AUDIO", t[t.AUDIO_STREAM_BEGIN = 4194305] = "AUDIO_STREAM_BEGIN", t[t.AUDIO_STREAM_END = 4194306] = "AUDIO_STREAM_END", t[t.AUDIO_FRAME = 4194307] = "AUDIO_FRAME", t[t.AUDIO_FRAME_VOLUME = 4194308] = "AUDIO_FRAME_VOLUME", t[t.AUDIO_FRAME2 = 4194309] = "AUDIO_FRAME2", t[t.GROUP_VIDEO = 8388608] = "GROUP_VIDEO", t[t.VIDEO_STREAM_BEGIN = 8388609] = "VIDEO_STREAM_BEGIN", t[t.VIDEO_STREAM_END = 8388610] = "VIDEO_STREAM_END", t[t.VIDEO_FRAME = 8388611] = "VIDEO_FRAME", t[t.VIDEO_REQUEST_IDR_FRAME = 8388612] = "VIDEO_REQUEST_IDR_FRAME", t[t.VIDEO_INVALIDATE_FRAME = 8388613] = "VIDEO_INVALIDATE_FRAME", t[t.GROUP_TRACKING = 16777216] = "GROUP_TRACKING", t[t.TRACKING_STREAM_BEGIN = 16777217] = "TRACKING_STREAM_BEGIN", t[t.TRACKING_STREAM_END = 16777218] = "TRACKING_STREAM_END", t[t.TRACKING_FRAME = 16777219] = "TRACKING_FRAME", t[t.GROUP_SCENE = 33554432] = "GROUP_SCENE", t[t.SCENE_MESH = 33554433] = "SCENE_MESH", t[t.SCENE_ARRAY = 33554434] = "SCENE_ARRAY", t[t.GROUP_ALL = 67043328] = "GROUP_ALL", t[t.CONSTANT_GROUP_MASK = 2147418112] = "CONSTANT_GROUP_MASK", t))(U || {});
|
|
522
|
-
const nt = 1, Et = 8388609, _t = 1368629611, It = 2950031986, at = 3284746250, it = 4065070594;
|
|
523
|
-
function Tt(t) {
|
|
524
|
-
const r = {};
|
|
525
|
-
return v(r), r;
|
|
526
|
-
}
|
|
527
|
-
function v(t) {
|
|
528
|
-
return t.Description = "", t.Codec = l.H264, t.Width = 0, t.Height = 0, t;
|
|
529
|
-
}
|
|
530
|
-
function At(t, r) {
|
|
531
|
-
const e = L.create(t);
|
|
532
|
-
return Nt(e, r);
|
|
533
|
-
}
|
|
534
|
-
function Nt(t, r) {
|
|
535
|
-
const e = r ?? Tt();
|
|
536
|
-
return v(e), ft(t, e), e;
|
|
537
|
-
}
|
|
538
|
-
function ft(t, r) {
|
|
539
|
-
let e;
|
|
540
|
-
for (; (e = t.next()) !== null; )
|
|
541
|
-
switch (e.fieldId) {
|
|
542
|
-
case _t: {
|
|
543
|
-
if (e.isNull) throw new Error();
|
|
544
|
-
r.Description = e.asString();
|
|
545
|
-
break;
|
|
546
|
-
}
|
|
547
|
-
case It: {
|
|
548
|
-
if (e.isNull) throw new Error();
|
|
549
|
-
r.Height = e.asInt32();
|
|
550
|
-
break;
|
|
551
|
-
}
|
|
552
|
-
case at: {
|
|
553
|
-
if (e.isNull) throw new Error();
|
|
554
|
-
r.Codec = e.asInt32();
|
|
555
|
-
break;
|
|
556
|
-
}
|
|
557
|
-
case it: {
|
|
558
|
-
if (e.isNull) throw new Error();
|
|
559
|
-
r.Width = e.asInt32();
|
|
560
|
-
break;
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
function Ct(t, r) {
|
|
565
|
-
const e = Y(t, Et, nt);
|
|
566
|
-
return At(e, r);
|
|
567
|
-
}
|
|
568
|
-
const ot = 1, ut = 8388611, Rt = 271275304, ht = 2541432218, Ut = 2986785889, lt = 3105403172, St = 3456383222;
|
|
569
|
-
function Lt(t) {
|
|
570
|
-
const r = {};
|
|
571
|
-
return X(r), r;
|
|
572
|
-
}
|
|
573
|
-
function X(t) {
|
|
574
|
-
return t.Data = new Uint8Array(0), t.FrameNumber = 0, t.IsKey = !1, t.TimestampInUs = 0n, t.DurationInUs = 0, t;
|
|
575
|
-
}
|
|
576
|
-
function Dt(t, r) {
|
|
577
|
-
const e = L.create(t);
|
|
578
|
-
return yt(e, r);
|
|
579
|
-
}
|
|
580
|
-
function yt(t, r) {
|
|
581
|
-
const e = r ?? Lt();
|
|
582
|
-
return X(e), ct(t, e), e;
|
|
583
|
-
}
|
|
584
|
-
function ct(t, r) {
|
|
585
|
-
let e;
|
|
586
|
-
for (; (e = t.next()) !== null; )
|
|
587
|
-
switch (e.fieldId) {
|
|
588
|
-
case Rt: {
|
|
589
|
-
if (e.isNull) throw new Error();
|
|
590
|
-
r.TimestampInUs = e.asUInt64();
|
|
591
|
-
break;
|
|
592
|
-
}
|
|
593
|
-
case ht: {
|
|
594
|
-
if (e.isNull) throw new Error();
|
|
595
|
-
r.DurationInUs = e.asUInt32();
|
|
596
|
-
break;
|
|
597
|
-
}
|
|
598
|
-
case Ut: {
|
|
599
|
-
if (e.isNull) throw new Error();
|
|
600
|
-
r.Data = e.asBinary();
|
|
601
|
-
break;
|
|
602
|
-
}
|
|
603
|
-
case lt: {
|
|
604
|
-
if (e.isNull) throw new Error();
|
|
605
|
-
r.IsKey = e.asBool();
|
|
606
|
-
break;
|
|
607
|
-
}
|
|
608
|
-
case St: {
|
|
609
|
-
if (e.isNull) throw new Error();
|
|
610
|
-
r.FrameNumber = e.asInt32();
|
|
611
|
-
break;
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
function Pt(t, r) {
|
|
616
|
-
const e = Y(t, ut, ot);
|
|
617
|
-
return Dt(e, r);
|
|
618
|
-
}
|
|
619
|
-
let wt = 1;
|
|
620
|
-
function Ot(t, r) {
|
|
621
|
-
return `[${t}] ${r}`;
|
|
622
|
-
}
|
|
623
|
-
function c(t, r, e, s) {
|
|
624
|
-
if ((/* @__PURE__ */ new Date()).toISOString(), wt <= t) {
|
|
625
|
-
const n = Ot(r, e);
|
|
626
|
-
switch (t) {
|
|
627
|
-
case 0:
|
|
628
|
-
console.debug(n, ...s);
|
|
629
|
-
break;
|
|
630
|
-
case 1:
|
|
631
|
-
console.info(n, ...s);
|
|
632
|
-
break;
|
|
633
|
-
case 2:
|
|
634
|
-
console.warn(n, ...s);
|
|
635
|
-
break;
|
|
636
|
-
case 3:
|
|
637
|
-
console.error(n, ...s);
|
|
638
|
-
break;
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
function gt(t) {
|
|
643
|
-
return {
|
|
644
|
-
debug(r, ...e) {
|
|
645
|
-
c(0, t, r, e);
|
|
646
|
-
},
|
|
647
|
-
info(r, ...e) {
|
|
648
|
-
c(1, t, r, e);
|
|
649
|
-
},
|
|
650
|
-
warn(r, ...e) {
|
|
651
|
-
c(2, t, r, e);
|
|
652
|
-
},
|
|
653
|
-
error(r, ...e) {
|
|
654
|
-
c(3, t, r, e);
|
|
655
|
-
}
|
|
656
|
-
};
|
|
657
|
-
}
|
|
658
|
-
const mt = gt("VideoPlaybackWorker"), y = (t, r) => self.postMessage(t, r ?? []);
|
|
659
|
-
let o = null, w = !0;
|
|
660
|
-
const A = /* @__PURE__ */ new Map();
|
|
661
|
-
function P(t) {
|
|
662
|
-
const r = t instanceof Error ? t : new Error(String(t));
|
|
663
|
-
y({ type: "error", error: { name: r.name, message: r.message, stack: r.stack } });
|
|
664
|
-
}
|
|
665
|
-
function O(t) {
|
|
666
|
-
const r = x(t);
|
|
667
|
-
return `${r.senderId}_${r.trackId}`;
|
|
668
|
-
}
|
|
669
|
-
function m(t) {
|
|
670
|
-
const r = A.get(t);
|
|
671
|
-
if (r)
|
|
672
|
-
return r;
|
|
673
|
-
const e = {
|
|
674
|
-
streamId: t,
|
|
675
|
-
watched: !1,
|
|
676
|
-
surface: null,
|
|
677
|
-
ctx2d: null,
|
|
678
|
-
codec: null,
|
|
679
|
-
width: 0,
|
|
680
|
-
height: 0,
|
|
681
|
-
decoder: null,
|
|
682
|
-
decoderCodec: null,
|
|
683
|
-
isKeyFrameRequired: !0
|
|
684
|
-
};
|
|
685
|
-
return A.set(t, e), e;
|
|
686
|
-
}
|
|
687
|
-
function Ft(t) {
|
|
688
|
-
if (t === l.H264) return "avc1.42001E";
|
|
689
|
-
if (t === l.Hevc) return "hvc1.1.6.L93.B0";
|
|
690
|
-
if (t === l.Vp8) return "vp8";
|
|
691
|
-
throw new Error(`Unknown codec: ${t}`);
|
|
692
|
-
}
|
|
693
|
-
function C(t) {
|
|
694
|
-
y({ type: "requestIdr", streamId: t });
|
|
695
|
-
}
|
|
696
|
-
function S(t) {
|
|
697
|
-
if (t.codec == null)
|
|
698
|
-
return;
|
|
699
|
-
const r = Ft(t.codec);
|
|
700
|
-
if (t.decoder || (t.decoder = new VideoDecoder({
|
|
701
|
-
output: (e) => {
|
|
702
|
-
(async () => {
|
|
703
|
-
try {
|
|
704
|
-
if (!w || !t.watched)
|
|
705
|
-
return;
|
|
706
|
-
const s = t.width, n = t.height;
|
|
707
|
-
if (t.ctx2d && t.surface) {
|
|
708
|
-
(t.surface.width !== s || t.surface.height !== n) && (t.surface.width = s, t.surface.height = n), t.ctx2d.drawImage(e, 0, 0, s, n);
|
|
709
|
-
return;
|
|
710
|
-
}
|
|
711
|
-
if (typeof createImageBitmap == "function") {
|
|
712
|
-
const E = await createImageBitmap(e);
|
|
713
|
-
y({ type: "frame", streamId: t.streamId, width: s, height: n, bitmap: E }, [E]);
|
|
714
|
-
return;
|
|
715
|
-
}
|
|
716
|
-
} catch (s) {
|
|
717
|
-
P(s);
|
|
718
|
-
} finally {
|
|
719
|
-
try {
|
|
720
|
-
e.close();
|
|
721
|
-
} catch {
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
})();
|
|
725
|
-
},
|
|
726
|
-
error: (e) => {
|
|
727
|
-
P(e), t.isKeyFrameRequired = !0, C(t.streamId);
|
|
728
|
-
}
|
|
729
|
-
})), t.decoderCodec !== r) {
|
|
730
|
-
t.decoderCodec = r;
|
|
731
|
-
try {
|
|
732
|
-
t.decoder.configure({
|
|
733
|
-
codec: r,
|
|
734
|
-
optimizeForLatency: !0,
|
|
735
|
-
hardwareAcceleration: "prefer-hardware"
|
|
736
|
-
}), t.isKeyFrameRequired = !0, C(t.streamId);
|
|
737
|
-
} catch (e) {
|
|
738
|
-
P(e);
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
function Vt(t) {
|
|
743
|
-
const r = O(t), e = Ct(t), s = m(r);
|
|
744
|
-
s.codec = e.Codec, s.width = e.Width, s.height = e.Height, y({ type: "streamBegin", streamId: r, width: e.Width, height: e.Height, codec: e.Codec }), s.watched && S(s);
|
|
745
|
-
}
|
|
746
|
-
function Mt(t) {
|
|
747
|
-
const r = O(t);
|
|
748
|
-
y({ type: "streamEnd", streamId: r });
|
|
749
|
-
const e = A.get(r);
|
|
750
|
-
if (e) {
|
|
751
|
-
if (e.decoder)
|
|
752
|
-
try {
|
|
753
|
-
e.decoder.close();
|
|
754
|
-
} catch {
|
|
755
|
-
}
|
|
756
|
-
A.delete(r);
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
function W(t) {
|
|
760
|
-
const r = A.get(t);
|
|
761
|
-
r && (r.surface = null, r.ctx2d = null);
|
|
762
|
-
}
|
|
763
|
-
function z(t) {
|
|
764
|
-
const r = A.get(t);
|
|
765
|
-
if (r && (r.watched = !1, r.isKeyFrameRequired = !0, W(t), r.decoder)) {
|
|
766
|
-
try {
|
|
767
|
-
r.decoder.close();
|
|
768
|
-
} catch {
|
|
769
|
-
}
|
|
770
|
-
r.decoder = null, r.decoderCodec = null;
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
function Gt(t) {
|
|
774
|
-
const r = O(t), e = A.get(r);
|
|
775
|
-
if (!e || !w || !e.watched || ((!e.decoder || !e.decoderCodec) && S(e), !e.decoder || !e.decoderCodec))
|
|
776
|
-
return;
|
|
777
|
-
const s = Pt(t);
|
|
778
|
-
if (e.isKeyFrameRequired) {
|
|
779
|
-
if (!s.IsKey)
|
|
780
|
-
return;
|
|
781
|
-
e.isKeyFrameRequired = !1;
|
|
782
|
-
}
|
|
783
|
-
try {
|
|
784
|
-
e.decoder.decode(
|
|
785
|
-
new EncodedVideoChunk({
|
|
786
|
-
type: s.IsKey ? "key" : "delta",
|
|
787
|
-
timestamp: Number(s.TimestampInUs),
|
|
788
|
-
duration: s.DurationInUs,
|
|
789
|
-
data: s.Data
|
|
790
|
-
})
|
|
791
|
-
);
|
|
792
|
-
} catch (n) {
|
|
793
|
-
e.isKeyFrameRequired = !0, C(r), P(n);
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
function Bt(t) {
|
|
797
|
-
const r = O(t), e = A.get(r);
|
|
798
|
-
e && (e.isKeyFrameRequired = !0, e.watched && C(r));
|
|
799
|
-
}
|
|
800
|
-
function bt(t) {
|
|
801
|
-
switch (J(t)) {
|
|
802
|
-
case U.VIDEO_STREAM_BEGIN:
|
|
803
|
-
Vt(t);
|
|
804
|
-
return;
|
|
805
|
-
case U.VIDEO_STREAM_END:
|
|
806
|
-
Mt(t);
|
|
807
|
-
return;
|
|
808
|
-
case U.VIDEO_FRAME:
|
|
809
|
-
Gt(t);
|
|
810
|
-
return;
|
|
811
|
-
case U.VIDEO_INVALIDATE_FRAME:
|
|
812
|
-
Bt(t);
|
|
813
|
-
return;
|
|
814
|
-
default:
|
|
815
|
-
return;
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
function q() {
|
|
819
|
-
if (o) {
|
|
820
|
-
try {
|
|
821
|
-
o.close();
|
|
822
|
-
} catch {
|
|
823
|
-
}
|
|
824
|
-
o = null;
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
function Ht() {
|
|
828
|
-
q();
|
|
829
|
-
for (const t of A.keys())
|
|
830
|
-
z(t);
|
|
831
|
-
A.clear();
|
|
832
|
-
}
|
|
833
|
-
self.addEventListener("message", (t) => {
|
|
834
|
-
const r = t.data;
|
|
835
|
-
if (r.type !== "configure") {
|
|
836
|
-
if (r.type === "attachSurface") {
|
|
837
|
-
const e = r.streamId, s = m(e);
|
|
838
|
-
s.watched = !0, s.surface = r.canvas;
|
|
839
|
-
try {
|
|
840
|
-
s.ctx2d = s.surface.getContext("2d", { alpha: !1 });
|
|
841
|
-
} catch (n) {
|
|
842
|
-
mt.warn(`Failed to create OffscreenCanvas 2D context: ${n}`), s.ctx2d = null;
|
|
843
|
-
}
|
|
844
|
-
s.isKeyFrameRequired = !0, S(s), C(e);
|
|
845
|
-
return;
|
|
846
|
-
}
|
|
847
|
-
if (r.type === "detachSurface") {
|
|
848
|
-
W(r.streamId);
|
|
849
|
-
return;
|
|
850
|
-
}
|
|
851
|
-
if (r.type === "attachProtocolPort") {
|
|
852
|
-
q(), o = r.port, o.start?.(), o.addEventListener("message", (e) => {
|
|
853
|
-
const s = e.data;
|
|
854
|
-
s?.type === "protocol" && s.message instanceof ArrayBuffer && bt(new Uint8Array(s.message));
|
|
855
|
-
});
|
|
856
|
-
return;
|
|
857
|
-
}
|
|
858
|
-
if (r.type === "watchStream") {
|
|
859
|
-
const e = m(r.streamId);
|
|
860
|
-
e.watched = !0, e.isKeyFrameRequired = !0, S(e), C(e.streamId);
|
|
861
|
-
return;
|
|
862
|
-
}
|
|
863
|
-
if (r.type === "unwatchStream") {
|
|
864
|
-
z(r.streamId);
|
|
865
|
-
return;
|
|
866
|
-
}
|
|
867
|
-
if (r.type === "setEnabled") {
|
|
868
|
-
if (w = r.enabled, w)
|
|
869
|
-
for (const e of A.values())
|
|
870
|
-
e.watched && (e.isKeyFrameRequired = !0, S(e), C(e.streamId));
|
|
871
|
-
return;
|
|
872
|
-
}
|
|
873
|
-
r.type === "dispose" && Ht();
|
|
874
|
-
}
|
|
875
|
-
});
|