@ikonai/sdk 0.0.31 → 0.0.32
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.
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
function
|
|
1
|
+
function ht(t) {
|
|
2
2
|
if (t.length < 8)
|
|
3
3
|
throw new Error("Protocol message too short");
|
|
4
4
|
return (t[4] | t[5] << 8 | t[6] << 16 | t[7] << 24) >>> 0;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
const e =
|
|
6
|
+
function q(t) {
|
|
7
|
+
const e = F(t), r = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
8
8
|
if (e.length < 27)
|
|
9
9
|
throw new Error("Protocol payload too short");
|
|
10
|
-
const s = r.getUint32(0, !0), n = r.getUint32(4, !0), a = r.getUint32(8, !0), i = r.getUint32(12, !0), o = r.getUint32(16, !0), _ = r.getUint32(20, !0), h = r.getUint8(24),
|
|
10
|
+
const s = r.getUint32(0, !0), n = r.getUint32(4, !0), a = r.getUint32(8, !0), i = r.getUint32(12, !0), o = r.getUint32(16, !0), _ = r.getUint32(20, !0), h = r.getUint8(24), I = r.getUint8(25), E = r.getUint8(26);
|
|
11
11
|
if (27 + _ * 4 > e.length)
|
|
12
12
|
throw new Error("Protocol header exceeds payload length");
|
|
13
13
|
const c = [];
|
|
14
|
-
let
|
|
15
|
-
for (let
|
|
16
|
-
c.push(r.getUint32(
|
|
14
|
+
let O = 27;
|
|
15
|
+
for (let m = 0; m < _; m++)
|
|
16
|
+
c.push(r.getUint32(O, !0)), O += 4;
|
|
17
17
|
return {
|
|
18
18
|
length: s,
|
|
19
19
|
opcode: n,
|
|
@@ -22,12 +22,12 @@ function z(t) {
|
|
|
22
22
|
sequenceId: o,
|
|
23
23
|
targetIds: c,
|
|
24
24
|
payloadVersion: h,
|
|
25
|
-
payloadType:
|
|
26
|
-
flags:
|
|
25
|
+
payloadType: I,
|
|
26
|
+
flags: E
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
const s =
|
|
29
|
+
function tt(t, e, r) {
|
|
30
|
+
const s = F(t), n = q(s);
|
|
31
31
|
if (e !== void 0 && n.opcode !== e)
|
|
32
32
|
throw new Error(`Unexpected opcode ${n.opcode}`);
|
|
33
33
|
if (n.payloadVersion !== r)
|
|
@@ -37,44 +37,44 @@ function j(t, e, r) {
|
|
|
37
37
|
const a = 27 + n.targetIds.length * 4;
|
|
38
38
|
return s.subarray(a, n.length);
|
|
39
39
|
}
|
|
40
|
-
var
|
|
41
|
-
const
|
|
40
|
+
var D = /* @__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))(D || {});
|
|
41
|
+
const It = 161, ft = 162;
|
|
42
42
|
new TextEncoder();
|
|
43
|
-
const
|
|
44
|
-
class
|
|
43
|
+
const ut = new TextDecoder("utf-8", { fatal: !0 });
|
|
44
|
+
class M {
|
|
45
45
|
constructor(e, r, s) {
|
|
46
46
|
this.buffer = e, this.version = r, this.offset = s, this.end = e.length - 1;
|
|
47
47
|
}
|
|
48
48
|
offset;
|
|
49
49
|
end;
|
|
50
50
|
static create(e) {
|
|
51
|
-
const r =
|
|
51
|
+
const r = F(e);
|
|
52
52
|
if (r.length < 2)
|
|
53
53
|
throw new Error("Teleport payload too short");
|
|
54
|
-
if (r[0] !==
|
|
54
|
+
if (r[0] !== It || r[r.length - 1] !== ft)
|
|
55
55
|
throw new Error("Teleport object missing markers");
|
|
56
|
-
const s = { offset: 1 }, n =
|
|
57
|
-
return new
|
|
56
|
+
const s = { offset: 1 }, n = A(r, s, "InvalidLength");
|
|
57
|
+
return new M(r, n, s.offset);
|
|
58
58
|
}
|
|
59
59
|
next() {
|
|
60
60
|
if (this.offset >= this.end)
|
|
61
61
|
return null;
|
|
62
62
|
if (this.offset + 5 > this.buffer.length)
|
|
63
63
|
throw new Error("Teleport object truncated");
|
|
64
|
-
const e =
|
|
64
|
+
const e = Nt(this.buffer, this.offset);
|
|
65
65
|
this.offset += 4;
|
|
66
66
|
const r = this.buffer[this.offset++], s = r >> 4 & 15;
|
|
67
67
|
if ((r & 15) !== 0)
|
|
68
68
|
throw new Error("Teleport field flags must be zero");
|
|
69
|
-
const n =
|
|
69
|
+
const n = d(s);
|
|
70
70
|
let a;
|
|
71
71
|
if (n >= 0)
|
|
72
72
|
u(this.buffer, this.offset, n), a = this.buffer.subarray(this.offset, this.offset + n), this.offset += n;
|
|
73
73
|
else {
|
|
74
|
-
const i = { offset: this.offset }, o =
|
|
74
|
+
const i = { offset: this.offset }, o = A(this.buffer, i, "InvalidLength");
|
|
75
75
|
u(this.buffer, i.offset, o), a = this.buffer.subarray(i.offset, i.offset + o), this.offset = i.offset + o;
|
|
76
76
|
}
|
|
77
|
-
return new
|
|
77
|
+
return new At(e, s, a);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
class C {
|
|
@@ -139,38 +139,38 @@ class C {
|
|
|
139
139
|
return this.ensureType(
|
|
140
140
|
12
|
|
141
141
|
/* String */
|
|
142
|
-
),
|
|
142
|
+
), ut.decode(this.payload);
|
|
143
143
|
}
|
|
144
144
|
asGuid() {
|
|
145
145
|
return this.ensureType(
|
|
146
146
|
14
|
|
147
147
|
/* Guid */
|
|
148
|
-
),
|
|
148
|
+
), f.fromBytes(this.payload);
|
|
149
149
|
}
|
|
150
150
|
asObject() {
|
|
151
151
|
return this.ensureType(
|
|
152
152
|
11
|
|
153
153
|
/* Object */
|
|
154
|
-
),
|
|
154
|
+
), M.create(this.payload);
|
|
155
155
|
}
|
|
156
156
|
asArray() {
|
|
157
157
|
return this.ensureType(
|
|
158
158
|
9
|
|
159
159
|
/* Array */
|
|
160
|
-
),
|
|
160
|
+
), x.create(this.payload);
|
|
161
161
|
}
|
|
162
162
|
asDictionary() {
|
|
163
163
|
return this.ensureType(
|
|
164
164
|
10
|
|
165
165
|
/* Dict */
|
|
166
|
-
),
|
|
166
|
+
), H.create(this.payload);
|
|
167
167
|
}
|
|
168
168
|
ensureType(e) {
|
|
169
169
|
if (this.type !== e)
|
|
170
|
-
throw new Error(`Teleport value has type ${
|
|
170
|
+
throw new Error(`Teleport value has type ${D[this.type]}, expected ${D[e]}`);
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
class
|
|
173
|
+
class At extends C {
|
|
174
174
|
constructor(e, r, s) {
|
|
175
175
|
super(r, s), this.fieldId = e;
|
|
176
176
|
}
|
|
@@ -178,7 +178,7 @@ class ot extends C {
|
|
|
178
178
|
return this.type === 1;
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
-
class
|
|
181
|
+
class x {
|
|
182
182
|
payload;
|
|
183
183
|
elementType;
|
|
184
184
|
count;
|
|
@@ -191,10 +191,10 @@ class V {
|
|
|
191
191
|
if (this.elementType = r >> 4 & 15, (r & 15) !== 0)
|
|
192
192
|
throw new Error("Array flags must be zero");
|
|
193
193
|
const s = { offset: 1 };
|
|
194
|
-
this.count =
|
|
194
|
+
this.count = A(e, s, "ArrayMalformed"), this.offset = s.offset;
|
|
195
195
|
}
|
|
196
196
|
static create(e) {
|
|
197
|
-
return new
|
|
197
|
+
return new x(F(e));
|
|
198
198
|
}
|
|
199
199
|
next() {
|
|
200
200
|
if (this.index >= this.count) {
|
|
@@ -215,43 +215,43 @@ class V {
|
|
|
215
215
|
case 4:
|
|
216
216
|
case 6:
|
|
217
217
|
case 14: {
|
|
218
|
-
const e =
|
|
218
|
+
const e = d(this.elementType);
|
|
219
219
|
u(this.payload, this.offset, e);
|
|
220
220
|
const r = this.payload.subarray(this.offset, this.offset + e);
|
|
221
|
-
return this.offset += e, new
|
|
221
|
+
return this.offset += e, new w(this.elementType, r);
|
|
222
222
|
}
|
|
223
223
|
case 12:
|
|
224
224
|
case 13: {
|
|
225
|
-
const e = { offset: this.offset }, r =
|
|
225
|
+
const e = { offset: this.offset }, r = A(this.payload, e, "ArrayMalformed");
|
|
226
226
|
u(this.payload, e.offset, r);
|
|
227
227
|
const s = this.payload.subarray(e.offset, e.offset + r);
|
|
228
|
-
return this.offset = e.offset + r, new
|
|
228
|
+
return this.offset = e.offset + r, new w(this.elementType, s);
|
|
229
229
|
}
|
|
230
230
|
case 11: {
|
|
231
|
-
const e = { offset: this.offset }, r =
|
|
231
|
+
const e = { offset: this.offset }, r = A(this.payload, e, "ArrayMalformed");
|
|
232
232
|
u(this.payload, e.offset, r);
|
|
233
233
|
const s = this.payload.subarray(e.offset, e.offset + r);
|
|
234
|
-
return this.offset = e.offset + r, new
|
|
234
|
+
return this.offset = e.offset + r, new w(11, s);
|
|
235
235
|
}
|
|
236
236
|
case 9: {
|
|
237
|
-
const e =
|
|
238
|
-
return this.offset += e, new
|
|
237
|
+
const e = Y(this.payload, this.offset), r = this.payload.subarray(this.offset, this.offset + e);
|
|
238
|
+
return this.offset += e, new w(9, r);
|
|
239
239
|
}
|
|
240
240
|
case 10: {
|
|
241
|
-
const e =
|
|
242
|
-
return this.offset += e, new
|
|
241
|
+
const e = K(this.payload, this.offset), r = this.payload.subarray(this.offset, this.offset + e);
|
|
242
|
+
return this.offset += e, new w(10, r);
|
|
243
243
|
}
|
|
244
244
|
default:
|
|
245
|
-
throw new Error(`Unsupported array element type ${
|
|
245
|
+
throw new Error(`Unsupported array element type ${D[this.elementType]}`);
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
|
-
class
|
|
249
|
+
class w extends C {
|
|
250
250
|
constructor(e, r) {
|
|
251
251
|
super(e, r);
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
|
-
class
|
|
254
|
+
class H {
|
|
255
255
|
payload;
|
|
256
256
|
keyType;
|
|
257
257
|
valueType;
|
|
@@ -263,12 +263,12 @@ class k {
|
|
|
263
263
|
throw new Error("Dictionary payload too short");
|
|
264
264
|
if (this.keyType = e[0] >> 4 & 15, this.valueType = e[1] >> 4 & 15, (e[0] & 15) !== 0 || (e[1] & 15) !== 0)
|
|
265
265
|
throw new Error("Dictionary key/value flags must be zero");
|
|
266
|
-
|
|
266
|
+
et(this.keyType);
|
|
267
267
|
const r = { offset: 2 };
|
|
268
|
-
this.count =
|
|
268
|
+
this.count = A(e, r, "DictMalformed"), this.offset = r.offset;
|
|
269
269
|
}
|
|
270
270
|
static create(e) {
|
|
271
|
-
return new
|
|
271
|
+
return new H(F(e));
|
|
272
272
|
}
|
|
273
273
|
next() {
|
|
274
274
|
if (this.index >= this.count) {
|
|
@@ -277,17 +277,17 @@ class k {
|
|
|
277
277
|
return null;
|
|
278
278
|
}
|
|
279
279
|
const e = this.readKey(), r = this.readValue();
|
|
280
|
-
return this.index++, new
|
|
280
|
+
return this.index++, new ct(e, r);
|
|
281
281
|
}
|
|
282
282
|
readKey() {
|
|
283
|
-
const e =
|
|
283
|
+
const e = d(this.keyType);
|
|
284
284
|
if (e >= 0) {
|
|
285
285
|
u(this.payload, this.offset, e);
|
|
286
286
|
const r = this.payload.subarray(this.offset, this.offset + e);
|
|
287
287
|
return this.offset += e, new C(this.keyType, r);
|
|
288
288
|
}
|
|
289
289
|
if (this.keyType === 12 || this.keyType === 13) {
|
|
290
|
-
const r = { offset: this.offset }, s =
|
|
290
|
+
const r = { offset: this.offset }, s = A(this.payload, r, "DictMalformed");
|
|
291
291
|
u(this.payload, r.offset, s);
|
|
292
292
|
const n = this.payload.subarray(r.offset, r.offset + s);
|
|
293
293
|
return this.offset = r.offset + s, new C(this.keyType, n);
|
|
@@ -298,23 +298,23 @@ class k {
|
|
|
298
298
|
switch (this.valueType) {
|
|
299
299
|
case 12:
|
|
300
300
|
case 13: {
|
|
301
|
-
const e = { offset: this.offset }, r =
|
|
301
|
+
const e = { offset: this.offset }, r = A(this.payload, e, "DictMalformed");
|
|
302
302
|
u(this.payload, e.offset, r);
|
|
303
303
|
const s = this.payload.subarray(e.offset, e.offset + r);
|
|
304
304
|
return this.offset = e.offset + r, new C(this.valueType, s);
|
|
305
305
|
}
|
|
306
306
|
case 11: {
|
|
307
|
-
const e = { offset: this.offset }, r =
|
|
307
|
+
const e = { offset: this.offset }, r = A(this.payload, e, "DictMalformed");
|
|
308
308
|
u(this.payload, e.offset, r);
|
|
309
309
|
const s = this.payload.subarray(e.offset, e.offset + r);
|
|
310
310
|
return this.offset = e.offset + r, new C(11, s);
|
|
311
311
|
}
|
|
312
312
|
case 9: {
|
|
313
|
-
const e =
|
|
313
|
+
const e = Y(this.payload, this.offset), r = this.payload.subarray(this.offset, this.offset + e);
|
|
314
314
|
return this.offset += e, new C(9, r);
|
|
315
315
|
}
|
|
316
316
|
case 10: {
|
|
317
|
-
const e =
|
|
317
|
+
const e = K(this.payload, this.offset), r = this.payload.subarray(this.offset, this.offset + e);
|
|
318
318
|
return this.offset += e, new C(10, r);
|
|
319
319
|
}
|
|
320
320
|
case 3:
|
|
@@ -326,22 +326,22 @@ class k {
|
|
|
326
326
|
case 6:
|
|
327
327
|
case 14:
|
|
328
328
|
case 1: {
|
|
329
|
-
const e =
|
|
329
|
+
const e = d(this.valueType);
|
|
330
330
|
u(this.payload, this.offset, e);
|
|
331
331
|
const r = this.payload.subarray(this.offset, this.offset + e);
|
|
332
332
|
return this.offset += e, new C(this.valueType, r);
|
|
333
333
|
}
|
|
334
334
|
default:
|
|
335
|
-
throw new Error(`Unsupported dictionary value type ${
|
|
335
|
+
throw new Error(`Unsupported dictionary value type ${D[this.valueType]}`);
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
|
-
class
|
|
339
|
+
class ct {
|
|
340
340
|
constructor(e, r) {
|
|
341
341
|
this.key = e, this.value = r;
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
|
-
class
|
|
344
|
+
class f {
|
|
345
345
|
constructor(e) {
|
|
346
346
|
this.bytes = e;
|
|
347
347
|
}
|
|
@@ -351,19 +351,19 @@ class l {
|
|
|
351
351
|
const r = e.replace(/-/g, "");
|
|
352
352
|
if (r.length !== 32)
|
|
353
353
|
throw new Error("Guid string must be 32 hex characters");
|
|
354
|
-
const s = new Uint8Array(16), n =
|
|
355
|
-
|
|
354
|
+
const s = new Uint8Array(16), n = f.parseHexSlice(r, 0, 8), a = f.parseHexSlice(r, 8, 4), i = f.parseHexSlice(r, 12, 4);
|
|
355
|
+
f.writeUInt32LE(s, 0, n), f.writeUInt16LE(s, 4, a), f.writeUInt16LE(s, 6, i);
|
|
356
356
|
for (let o = 0; o < 8; o++)
|
|
357
|
-
s[8 + o] =
|
|
358
|
-
return new
|
|
357
|
+
s[8 + o] = f.parseHexSlice(r, 16 + o * 2, 2);
|
|
358
|
+
return new f(s);
|
|
359
359
|
}
|
|
360
360
|
static fromBytes(e) {
|
|
361
361
|
if (e.length !== 16)
|
|
362
362
|
throw new Error("Guid byte array must be 16 bytes");
|
|
363
|
-
return new
|
|
363
|
+
return new f(Uint8Array.from(e));
|
|
364
364
|
}
|
|
365
365
|
static createZero() {
|
|
366
|
-
return new
|
|
366
|
+
return new f(new Uint8Array(16));
|
|
367
367
|
}
|
|
368
368
|
static createRandom() {
|
|
369
369
|
const e = new Uint8Array(16), r = globalThis.crypto;
|
|
@@ -372,16 +372,16 @@ class l {
|
|
|
372
372
|
else
|
|
373
373
|
for (let s = 0; s < e.length; s++)
|
|
374
374
|
e[s] = Math.floor(Math.random() * 256);
|
|
375
|
-
return e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128, new
|
|
375
|
+
return e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128, new f(e);
|
|
376
376
|
}
|
|
377
377
|
toString() {
|
|
378
378
|
const e = this.bytes;
|
|
379
379
|
return [
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
380
|
+
f.toHex(f.readUInt32LE(e, 0), 8),
|
|
381
|
+
f.toHex(f.readUInt16LE(e, 4), 4),
|
|
382
|
+
f.toHex(f.readUInt16LE(e, 6), 4),
|
|
383
|
+
z(e.subarray(8, 10)),
|
|
384
|
+
z(e.subarray(10, 16))
|
|
385
385
|
].join("-");
|
|
386
386
|
}
|
|
387
387
|
asBytes() {
|
|
@@ -411,14 +411,14 @@ class l {
|
|
|
411
411
|
return (e >>> 0).toString(16).padStart(r, "0");
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
|
-
function
|
|
414
|
+
function A(t, e, r) {
|
|
415
415
|
if (e.offset >= t.length)
|
|
416
416
|
throw new Error(r);
|
|
417
417
|
let s = 0, n = 0, a = 0;
|
|
418
418
|
for (; e.offset < t.length; ) {
|
|
419
419
|
const i = t[e.offset++];
|
|
420
420
|
if (a++, s |= (i & 127) << n, (i & 128) === 0) {
|
|
421
|
-
if (a !==
|
|
421
|
+
if (a !== Tt(s))
|
|
422
422
|
throw new Error("Teleport VarUInt is not canonical");
|
|
423
423
|
return s >>> 0;
|
|
424
424
|
}
|
|
@@ -427,10 +427,10 @@ function f(t, e, r) {
|
|
|
427
427
|
}
|
|
428
428
|
throw new Error(r);
|
|
429
429
|
}
|
|
430
|
-
function
|
|
430
|
+
function Tt(t) {
|
|
431
431
|
return t < 128 ? 1 : t < 16384 ? 2 : t < 2097152 ? 3 : t < 268435456 ? 4 : 5;
|
|
432
432
|
}
|
|
433
|
-
function
|
|
433
|
+
function d(t) {
|
|
434
434
|
switch (t) {
|
|
435
435
|
case 3:
|
|
436
436
|
case 5:
|
|
@@ -450,7 +450,7 @@ function y(t) {
|
|
|
450
450
|
return -1;
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
|
-
function
|
|
453
|
+
function et(t) {
|
|
454
454
|
if (t === 9 || t === 11 || t === 10 || t === 1)
|
|
455
455
|
throw new Error("Dictionary keys must be primitive Teleport types");
|
|
456
456
|
}
|
|
@@ -458,190 +458,190 @@ function u(t, e, r) {
|
|
|
458
458
|
if (e < 0 || r < 0 || e + r > t.length)
|
|
459
459
|
throw new Error("Teleport payload exceeds bounds");
|
|
460
460
|
}
|
|
461
|
-
function
|
|
461
|
+
function Nt(t, e) {
|
|
462
462
|
return (t[e] | t[e + 1] << 8 | t[e + 2] << 16 | t[e + 3] << 24) >>> 0;
|
|
463
463
|
}
|
|
464
|
-
function
|
|
464
|
+
function Y(t, e) {
|
|
465
465
|
if (e >= t.length)
|
|
466
466
|
throw new Error("Array payload exceeds bounds");
|
|
467
467
|
const r = t[e], s = r >> 4 & 15;
|
|
468
468
|
if ((r & 15) !== 0)
|
|
469
469
|
throw new Error("Array flags must be zero");
|
|
470
|
-
const n = { offset: e + 1 }, a =
|
|
470
|
+
const n = { offset: e + 1 }, a = A(t, n, "ArrayMalformed"), i = d(s);
|
|
471
471
|
if (i >= 0) {
|
|
472
472
|
const _ = i * a;
|
|
473
473
|
return u(t, n.offset, _), n.offset + _ - e;
|
|
474
474
|
}
|
|
475
475
|
let o = n.offset;
|
|
476
476
|
for (let _ = 0; _ < a; _++)
|
|
477
|
-
o =
|
|
477
|
+
o = p(s, t, o, "ArrayMalformed");
|
|
478
478
|
return o - e;
|
|
479
479
|
}
|
|
480
|
-
function
|
|
480
|
+
function K(t, e) {
|
|
481
481
|
if (e + 2 > t.length)
|
|
482
482
|
throw new Error("Dictionary payload too short");
|
|
483
483
|
const r = t[e] >> 4 & 15, s = t[e + 1] >> 4 & 15;
|
|
484
484
|
if ((t[e] & 15) !== 0 || (t[e + 1] & 15) !== 0)
|
|
485
485
|
throw new Error("Dictionary key/value flags must be zero");
|
|
486
|
-
|
|
487
|
-
const n = { offset: e + 2 }, a =
|
|
486
|
+
et(r);
|
|
487
|
+
const n = { offset: e + 2 }, a = A(t, n, "DictMalformed");
|
|
488
488
|
let i = n.offset;
|
|
489
489
|
for (let o = 0; o < a; o++)
|
|
490
|
-
i =
|
|
490
|
+
i = p(r, t, i, "DictMalformed"), i = p(s, t, i, "DictMalformed");
|
|
491
491
|
return i - e;
|
|
492
492
|
}
|
|
493
|
-
function
|
|
494
|
-
const n =
|
|
493
|
+
function p(t, e, r, s) {
|
|
494
|
+
const n = d(t);
|
|
495
495
|
if (n >= 0)
|
|
496
496
|
return u(e, r, n), r + n;
|
|
497
497
|
switch (t) {
|
|
498
498
|
case 12:
|
|
499
499
|
case 13: {
|
|
500
|
-
const a = { offset: r }, i =
|
|
500
|
+
const a = { offset: r }, i = A(e, a, s);
|
|
501
501
|
return u(e, a.offset, i), a.offset + i;
|
|
502
502
|
}
|
|
503
503
|
case 11: {
|
|
504
|
-
const a = { offset: r }, i =
|
|
504
|
+
const a = { offset: r }, i = A(e, a, s);
|
|
505
505
|
return u(e, a.offset, i), a.offset + i;
|
|
506
506
|
}
|
|
507
507
|
case 9:
|
|
508
|
-
return r +
|
|
508
|
+
return r + Y(e, r);
|
|
509
509
|
case 10:
|
|
510
|
-
return r +
|
|
510
|
+
return r + K(e, r);
|
|
511
511
|
default:
|
|
512
|
-
throw new Error(`Unsupported Teleport type ${
|
|
512
|
+
throw new Error(`Unsupported Teleport type ${D[t]}`);
|
|
513
513
|
}
|
|
514
514
|
}
|
|
515
|
-
function
|
|
515
|
+
function z(t) {
|
|
516
516
|
return Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
517
517
|
}
|
|
518
|
-
function
|
|
518
|
+
function F(t) {
|
|
519
519
|
return t instanceof Uint8Array ? t : new Uint8Array(t);
|
|
520
520
|
}
|
|
521
|
-
var T = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.Opus = 1] = "Opus", t[t.Mp3 = 2] = "Mp3", t[t.RawPcm16 = 3] = "RawPcm16", t))(T || {}),
|
|
522
|
-
const
|
|
523
|
-
function
|
|
521
|
+
var T = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.Opus = 1] = "Opus", t[t.Mp3 = 2] = "Mp3", t[t.RawPcm16 = 3] = "RawPcm16", t))(T || {}), G = /* @__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))(G || {});
|
|
522
|
+
const Ct = 1, St = 4194309, Rt = 205938238, Ut = 1594075008, mt = 2026534360, Lt = 3409001585, yt = 3466650495, Dt = 4007456593, dt = 4017217601, Pt = 4065417427, Ot = 4086360332;
|
|
523
|
+
function wt(t) {
|
|
524
524
|
const e = {};
|
|
525
|
-
return
|
|
525
|
+
return rt(e), e;
|
|
526
526
|
}
|
|
527
|
-
function
|
|
527
|
+
function rt(t) {
|
|
528
528
|
return t.Samples = new Uint8Array(0), t.Epoch = 0, t.Sequence = 0, t.FrameSizeInInterleavedSamples = 0, t.TimeStampInInterleavedSamples = 0n, t.IsFirst = !1, t.IsLast = !1, t.AverageVolume = 0, t.AudioEventEstimatedDuration = 0, t;
|
|
529
529
|
}
|
|
530
|
-
function
|
|
531
|
-
const r =
|
|
532
|
-
return
|
|
530
|
+
function gt(t, e) {
|
|
531
|
+
const r = M.create(t);
|
|
532
|
+
return Mt(r, e);
|
|
533
533
|
}
|
|
534
|
-
function
|
|
535
|
-
const r = e ??
|
|
536
|
-
return
|
|
534
|
+
function Mt(t, e) {
|
|
535
|
+
const r = e ?? wt();
|
|
536
|
+
return rt(r), Ft(t, r), r;
|
|
537
537
|
}
|
|
538
|
-
function
|
|
538
|
+
function Ft(t, e) {
|
|
539
539
|
let r;
|
|
540
540
|
for (; (r = t.next()) !== null; )
|
|
541
541
|
switch (r.fieldId) {
|
|
542
|
-
case
|
|
542
|
+
case Rt: {
|
|
543
543
|
if (r.isNull) throw new Error();
|
|
544
544
|
e.AverageVolume = r.asFloat32();
|
|
545
545
|
break;
|
|
546
546
|
}
|
|
547
|
-
case
|
|
547
|
+
case Ut: {
|
|
548
548
|
if (r.isNull) throw new Error();
|
|
549
549
|
e.IsFirst = r.asBool();
|
|
550
550
|
break;
|
|
551
551
|
}
|
|
552
|
-
case
|
|
552
|
+
case mt: {
|
|
553
553
|
if (r.isNull) throw new Error();
|
|
554
554
|
e.TimeStampInInterleavedSamples = r.asUInt64();
|
|
555
555
|
break;
|
|
556
556
|
}
|
|
557
|
-
case
|
|
557
|
+
case Lt: {
|
|
558
558
|
if (r.isNull) throw new Error();
|
|
559
559
|
e.Samples = r.asBinary();
|
|
560
560
|
break;
|
|
561
561
|
}
|
|
562
|
-
case
|
|
562
|
+
case yt: {
|
|
563
563
|
if (r.isNull) throw new Error();
|
|
564
564
|
e.AudioEventEstimatedDuration = r.asFloat32();
|
|
565
565
|
break;
|
|
566
566
|
}
|
|
567
|
-
case
|
|
567
|
+
case Dt: {
|
|
568
568
|
if (r.isNull) throw new Error();
|
|
569
569
|
e.FrameSizeInInterleavedSamples = r.asUInt32();
|
|
570
570
|
break;
|
|
571
571
|
}
|
|
572
|
-
case
|
|
572
|
+
case dt: {
|
|
573
573
|
if (r.isNull) throw new Error();
|
|
574
574
|
e.IsLast = r.asBool();
|
|
575
575
|
break;
|
|
576
576
|
}
|
|
577
|
-
case
|
|
577
|
+
case Pt: {
|
|
578
578
|
if (r.isNull) throw new Error();
|
|
579
579
|
e.Sequence = r.asUInt32();
|
|
580
580
|
break;
|
|
581
581
|
}
|
|
582
|
-
case
|
|
582
|
+
case Ot: {
|
|
583
583
|
if (r.isNull) throw new Error();
|
|
584
584
|
e.Epoch = r.asUInt32();
|
|
585
585
|
break;
|
|
586
586
|
}
|
|
587
587
|
}
|
|
588
588
|
}
|
|
589
|
-
function
|
|
590
|
-
const r =
|
|
591
|
-
return
|
|
589
|
+
function Bt(t, e) {
|
|
590
|
+
const r = tt(t, St, Ct);
|
|
591
|
+
return gt(r, e);
|
|
592
592
|
}
|
|
593
|
-
const
|
|
594
|
-
function
|
|
593
|
+
const bt = 1, Gt = 4194305, Vt = 1368629611, kt = 2431514951, vt = 2914494629, pt = 3284746250, xt = 4101844078;
|
|
594
|
+
function Ht(t) {
|
|
595
595
|
const e = {};
|
|
596
|
-
return
|
|
596
|
+
return st(e), e;
|
|
597
597
|
}
|
|
598
|
-
function
|
|
598
|
+
function st(t) {
|
|
599
599
|
return t.Description = "", t.Codec = T.Unknown, t.SampleRate = 0, t.Channels = 0, t.BitDepth = 0, t;
|
|
600
600
|
}
|
|
601
|
-
function
|
|
602
|
-
const r =
|
|
603
|
-
return
|
|
601
|
+
function Yt(t, e) {
|
|
602
|
+
const r = M.create(t);
|
|
603
|
+
return Kt(r, e);
|
|
604
604
|
}
|
|
605
|
-
function
|
|
606
|
-
const r = e ??
|
|
607
|
-
return
|
|
605
|
+
function Kt(t, e) {
|
|
606
|
+
const r = e ?? Ht();
|
|
607
|
+
return st(r), Wt(t, r), r;
|
|
608
608
|
}
|
|
609
|
-
function
|
|
609
|
+
function Wt(t, e) {
|
|
610
610
|
let r;
|
|
611
611
|
for (; (r = t.next()) !== null; )
|
|
612
612
|
switch (r.fieldId) {
|
|
613
|
-
case
|
|
613
|
+
case Vt: {
|
|
614
614
|
if (r.isNull) throw new Error();
|
|
615
615
|
e.Description = r.asString();
|
|
616
616
|
break;
|
|
617
617
|
}
|
|
618
|
-
case
|
|
618
|
+
case kt: {
|
|
619
619
|
if (r.isNull) throw new Error();
|
|
620
620
|
e.Channels = r.asInt32();
|
|
621
621
|
break;
|
|
622
622
|
}
|
|
623
|
-
case
|
|
623
|
+
case vt: {
|
|
624
624
|
if (r.isNull) throw new Error();
|
|
625
625
|
e.BitDepth = r.asInt32();
|
|
626
626
|
break;
|
|
627
627
|
}
|
|
628
|
-
case
|
|
628
|
+
case pt: {
|
|
629
629
|
if (r.isNull) throw new Error();
|
|
630
630
|
e.Codec = r.asInt32();
|
|
631
631
|
break;
|
|
632
632
|
}
|
|
633
|
-
case
|
|
633
|
+
case xt: {
|
|
634
634
|
if (r.isNull) throw new Error();
|
|
635
635
|
e.SampleRate = r.asInt32();
|
|
636
636
|
break;
|
|
637
637
|
}
|
|
638
638
|
}
|
|
639
639
|
}
|
|
640
|
-
function
|
|
641
|
-
const r =
|
|
642
|
-
return
|
|
640
|
+
function Xt(t, e) {
|
|
641
|
+
const r = tt(t, Gt, bt);
|
|
642
|
+
return Yt(r, e);
|
|
643
643
|
}
|
|
644
|
-
class
|
|
644
|
+
class j {
|
|
645
645
|
static getStorageForCapacity(e, r) {
|
|
646
646
|
const s = Int32Array.BYTES_PER_ELEMENT * 2, n = r.BYTES_PER_ELEMENT * e;
|
|
647
647
|
return new SharedArrayBuffer(s + n);
|
|
@@ -695,9 +695,9 @@ class W {
|
|
|
695
695
|
return s = (s + r) % this.capacity, Atomics.store(this.readWrite, 0, s), r;
|
|
696
696
|
}
|
|
697
697
|
}
|
|
698
|
-
const
|
|
699
|
-
function
|
|
700
|
-
if (typeof SharedArrayBuffer > "u" || typeof Atomics > "u" ||
|
|
698
|
+
const zt = globalThis;
|
|
699
|
+
function jt() {
|
|
700
|
+
if (typeof SharedArrayBuffer > "u" || typeof Atomics > "u" || zt.crossOriginIsolated === !1)
|
|
701
701
|
return !1;
|
|
702
702
|
try {
|
|
703
703
|
new SharedArrayBuffer(1);
|
|
@@ -706,13 +706,13 @@ function xt() {
|
|
|
706
706
|
}
|
|
707
707
|
return !0;
|
|
708
708
|
}
|
|
709
|
-
let
|
|
710
|
-
function
|
|
709
|
+
let $t = 1;
|
|
710
|
+
function Qt(t, e) {
|
|
711
711
|
return `[${t}] ${e}`;
|
|
712
712
|
}
|
|
713
|
-
function
|
|
714
|
-
if ((/* @__PURE__ */ new Date()).toISOString(),
|
|
715
|
-
const n =
|
|
713
|
+
function b(t, e, r, s) {
|
|
714
|
+
if ((/* @__PURE__ */ new Date()).toISOString(), $t <= t) {
|
|
715
|
+
const n = Qt(e, r);
|
|
716
716
|
switch (t) {
|
|
717
717
|
case 0:
|
|
718
718
|
console.debug(n, ...s);
|
|
@@ -729,35 +729,35 @@ function F(t, e, r, s) {
|
|
|
729
729
|
}
|
|
730
730
|
}
|
|
731
731
|
}
|
|
732
|
-
function
|
|
732
|
+
function Jt(t) {
|
|
733
733
|
return {
|
|
734
734
|
debug(e, ...r) {
|
|
735
|
-
|
|
735
|
+
b(0, t, e, r);
|
|
736
736
|
},
|
|
737
737
|
info(e, ...r) {
|
|
738
|
-
|
|
738
|
+
b(1, t, e, r);
|
|
739
739
|
},
|
|
740
740
|
warn(e, ...r) {
|
|
741
|
-
|
|
741
|
+
b(2, t, e, r);
|
|
742
742
|
},
|
|
743
743
|
error(e, ...r) {
|
|
744
|
-
|
|
744
|
+
b(3, t, e, r);
|
|
745
745
|
}
|
|
746
746
|
};
|
|
747
747
|
}
|
|
748
|
-
const
|
|
748
|
+
const nt = 48e3, it = 2, Zt = 1500, qt = 10, $ = 80, te = 50, Q = 64, ee = Jt("AudioPlaybackWorker"), P = (t, e) => {
|
|
749
749
|
self.postMessage(t, e ?? []);
|
|
750
|
-
},
|
|
751
|
-
let
|
|
752
|
-
function
|
|
750
|
+
}, re = jt();
|
|
751
|
+
let V = "pcm", at = !0, R = nt, S = it, y = null;
|
|
752
|
+
function L(t, e) {
|
|
753
753
|
const r = t instanceof Error ? t : new Error(String(t));
|
|
754
|
-
|
|
754
|
+
P({ type: "error", error: { name: r.name, message: r.message, stack: r.stack }, streamId: e });
|
|
755
755
|
}
|
|
756
|
-
function
|
|
757
|
-
const e =
|
|
756
|
+
function W(t) {
|
|
757
|
+
const e = q(t);
|
|
758
758
|
return `${e.senderId}_${e.trackId}`;
|
|
759
759
|
}
|
|
760
|
-
class
|
|
760
|
+
class se {
|
|
761
761
|
mode;
|
|
762
762
|
ring = null;
|
|
763
763
|
sab = void 0;
|
|
@@ -765,22 +765,23 @@ class Qt {
|
|
|
765
765
|
outputSampleRate;
|
|
766
766
|
outputChannels;
|
|
767
767
|
closed = !1;
|
|
768
|
-
|
|
769
|
-
|
|
768
|
+
// Pre-allocated batch buffer for PCM mode to avoid per-frame allocations
|
|
769
|
+
pcmBatchBuffer = null;
|
|
770
|
+
pcmBatchOffset = 0;
|
|
770
771
|
lastPcmFlushTimeMs = 0;
|
|
771
772
|
constructor(e) {
|
|
772
|
-
this.streamId = e, this.mode = "pcm", this.outputSampleRate = R, this.outputChannels = S, this.rebind(
|
|
773
|
+
this.streamId = e, this.mode = "pcm", this.outputSampleRate = R, this.outputChannels = S, this.rebind(V);
|
|
773
774
|
}
|
|
774
775
|
close() {
|
|
775
|
-
this.closed = !0, this.
|
|
776
|
+
this.closed = !0, this.pcmBatchBuffer = null, this.pcmBatchOffset = 0, this.ring = null, this.sab = void 0;
|
|
776
777
|
}
|
|
777
778
|
setOutputFormat(e, r) {
|
|
778
779
|
this.outputSampleRate = e, this.outputChannels = r;
|
|
779
780
|
}
|
|
780
781
|
rebind(e) {
|
|
781
782
|
if (!this.closed) {
|
|
782
|
-
if (this.mode = e, e === "sab" &&
|
|
783
|
-
const r = Math.floor(
|
|
783
|
+
if (this.mode = e, e === "sab" && re) {
|
|
784
|
+
const r = Math.floor(Zt * this.outputSampleRate * this.outputChannels / 1e3), s = j.getStorageForCapacity(r, Float32Array), n = new j(s, Float32Array);
|
|
784
785
|
n.flush(), this.sab = s, this.ring = n;
|
|
785
786
|
return;
|
|
786
787
|
}
|
|
@@ -788,44 +789,46 @@ class Qt {
|
|
|
788
789
|
}
|
|
789
790
|
}
|
|
790
791
|
flushPendingPcm(e) {
|
|
791
|
-
if (this.closed || this.mode !== "pcm" || this.
|
|
792
|
+
if (this.closed || this.mode !== "pcm" || this.pcmBatchOffset <= 0)
|
|
792
793
|
return;
|
|
793
|
-
const r = performance.now(), s = Math.max(1, Math.round(this.outputSampleRate * this.outputChannels *
|
|
794
|
-
if (!(e || this.
|
|
794
|
+
const r = performance.now(), s = Math.max(1, Math.round(this.outputSampleRate * this.outputChannels * $ / 1e3));
|
|
795
|
+
if (!(e || this.pcmBatchOffset >= s || this.lastPcmFlushTimeMs > 0 && r - this.lastPcmFlushTimeMs >= te))
|
|
795
796
|
return;
|
|
796
|
-
const a = new Float32Array(this.
|
|
797
|
-
|
|
798
|
-
for (const o of this.pendingPcmChunks)
|
|
799
|
-
a.set(o, i), i += o.length;
|
|
800
|
-
this.pendingPcmChunks = [], this.pendingPcmSamples = 0, this.lastPcmFlushTimeMs = r, D({ type: "pcm", streamId: this.streamId, pcm: a }, [a.buffer]);
|
|
797
|
+
const a = new Float32Array(this.pcmBatchOffset);
|
|
798
|
+
a.set(this.pcmBatchBuffer.subarray(0, this.pcmBatchOffset)), this.pcmBatchOffset = 0, this.lastPcmFlushTimeMs = r, P({ type: "pcm", streamId: this.streamId, pcm: a }, [a.buffer]);
|
|
801
799
|
}
|
|
802
800
|
drainPcm() {
|
|
803
801
|
this.flushPendingPcm(!0);
|
|
804
802
|
}
|
|
805
803
|
writePcm(e) {
|
|
806
|
-
if (
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
n.length > i && (n = n.subarray(n.length - i)), r.push(n);
|
|
804
|
+
if (this.closed)
|
|
805
|
+
return;
|
|
806
|
+
if (this.mode === "sab" && this.ring) {
|
|
807
|
+
const n = this.ring, a = this.outputChannels;
|
|
808
|
+
let i = e;
|
|
809
|
+
const o = Math.floor(Math.max(0, n.capacity - 1) / a) * a;
|
|
810
|
+
i.length > o && (i = i.subarray(i.length - o));
|
|
811
|
+
const _ = Math.floor(n.availableWrite() / a) * a;
|
|
812
|
+
if (_ <= 0)
|
|
816
813
|
return;
|
|
817
|
-
|
|
818
|
-
|
|
814
|
+
i.length > _ && (i = i.subarray(i.length - _)), n.push(i);
|
|
815
|
+
return;
|
|
819
816
|
}
|
|
817
|
+
const r = Math.max(1, Math.round(this.outputSampleRate * this.outputChannels * $ / 1e3)), s = this.pcmBatchOffset + e.length;
|
|
818
|
+
if (!this.pcmBatchBuffer || this.pcmBatchBuffer.length < s) {
|
|
819
|
+
const n = Math.max(s, r * 2), a = new Float32Array(n);
|
|
820
|
+
this.pcmBatchBuffer && this.pcmBatchOffset > 0 && a.set(this.pcmBatchBuffer.subarray(0, this.pcmBatchOffset)), this.pcmBatchBuffer = a;
|
|
821
|
+
}
|
|
822
|
+
this.pcmBatchBuffer.set(e, this.pcmBatchOffset), this.pcmBatchOffset += e.length, this.lastPcmFlushTimeMs === 0 && (this.lastPcmFlushTimeMs = performance.now()), this.flushPendingPcm(!1);
|
|
820
823
|
}
|
|
821
824
|
getSharedArrayBuffer() {
|
|
822
825
|
return this.sab;
|
|
823
826
|
}
|
|
824
827
|
flush() {
|
|
825
|
-
this.closed || (this.
|
|
828
|
+
this.closed || (this.pcmBatchOffset = 0, this.lastPcmFlushTimeMs = 0, this.ring?.flush());
|
|
826
829
|
}
|
|
827
830
|
}
|
|
828
|
-
function
|
|
831
|
+
function ne(t) {
|
|
829
832
|
switch (t) {
|
|
830
833
|
case T.Opus:
|
|
831
834
|
return "opus";
|
|
@@ -835,15 +838,15 @@ function Jt(t) {
|
|
|
835
838
|
return null;
|
|
836
839
|
}
|
|
837
840
|
}
|
|
838
|
-
let
|
|
839
|
-
function
|
|
841
|
+
let g = null;
|
|
842
|
+
function ie(t) {
|
|
840
843
|
const e = new DataView(t.buffer, t.byteOffset, t.byteLength), r = Math.floor(t.byteLength / 2);
|
|
841
|
-
(!
|
|
844
|
+
(!g || g.length < r) && (g = new Float32Array(r));
|
|
842
845
|
for (let s = 0; s < r; s++)
|
|
843
|
-
|
|
844
|
-
return
|
|
846
|
+
g[s] = e.getInt16(s * 2, !0) / 32768;
|
|
847
|
+
return g.subarray(0, r);
|
|
845
848
|
}
|
|
846
|
-
class
|
|
849
|
+
class X {
|
|
847
850
|
inputSampleRate;
|
|
848
851
|
inputChannels;
|
|
849
852
|
sink;
|
|
@@ -871,52 +874,52 @@ class H {
|
|
|
871
874
|
}
|
|
872
875
|
convertAudioData(e) {
|
|
873
876
|
const r = e.numberOfFrames, s = e.numberOfChannels, n = e.format, a = typeof n == "string" && n.includes("planar"), i = "f32-planar", o = "f32", _ = () => {
|
|
874
|
-
const
|
|
875
|
-
for (let
|
|
877
|
+
const E = new Array(s);
|
|
878
|
+
for (let l = 0; l < s; l++) {
|
|
876
879
|
const c = new Float32Array(r);
|
|
877
|
-
e.copyTo(c, { planeIndex:
|
|
880
|
+
e.copyTo(c, { planeIndex: l, format: i }), E[l] = c;
|
|
878
881
|
}
|
|
879
|
-
return
|
|
882
|
+
return Te(E, r);
|
|
880
883
|
}, h = () => {
|
|
881
|
-
const
|
|
882
|
-
return e.copyTo(
|
|
884
|
+
const E = new Float32Array(r * s);
|
|
885
|
+
return e.copyTo(E, { planeIndex: 0, format: o }), E;
|
|
883
886
|
};
|
|
884
|
-
let
|
|
887
|
+
let I;
|
|
885
888
|
if (a)
|
|
886
889
|
try {
|
|
887
|
-
|
|
888
|
-
} catch (
|
|
889
|
-
|
|
890
|
+
I = _();
|
|
891
|
+
} catch (E) {
|
|
892
|
+
ee.debug(`Failed to read planar audio data, falling back to interleaved copy: ${E}`), I = h();
|
|
890
893
|
}
|
|
891
894
|
else
|
|
892
|
-
|
|
893
|
-
return
|
|
895
|
+
I = h();
|
|
896
|
+
return I;
|
|
894
897
|
}
|
|
895
898
|
convertPcmBuffer(e, r, s) {
|
|
896
899
|
if (e.length === 0)
|
|
897
900
|
return e;
|
|
898
901
|
let n = e, a = e.length, i = r;
|
|
899
902
|
if (s !== R) {
|
|
900
|
-
const o = a / i, h = Math.max(1, Math.round(o * R / s)) * i,
|
|
901
|
-
a =
|
|
903
|
+
const o = a / i, h = Math.max(1, Math.round(o * R / s)) * i, I = this.getResampleBuffer(h);
|
|
904
|
+
a = Ce(n, I, i, s, R), n = I;
|
|
902
905
|
}
|
|
903
906
|
if (i !== S) {
|
|
904
907
|
const _ = a / i * S, h = this.getRemixBuffer(_);
|
|
905
|
-
a =
|
|
908
|
+
a = Se(n.subarray(0, a), h, i, S), n = h, i = S;
|
|
906
909
|
}
|
|
907
910
|
return n.subarray(0, a);
|
|
908
911
|
}
|
|
909
912
|
}
|
|
910
|
-
class
|
|
913
|
+
class ae extends X {
|
|
911
914
|
feedChunk(e) {
|
|
912
915
|
e.isFirst && this.reset();
|
|
913
|
-
const r =
|
|
916
|
+
const r = ie(e.data);
|
|
914
917
|
this.writeConvertedPcm(r, this.inputChannels, this.inputSampleRate), e.isLast && this.reset();
|
|
915
918
|
}
|
|
916
919
|
close() {
|
|
917
920
|
}
|
|
918
921
|
}
|
|
919
|
-
class
|
|
922
|
+
class oe extends X {
|
|
920
923
|
decoder;
|
|
921
924
|
codec;
|
|
922
925
|
constructor(e) {
|
|
@@ -926,7 +929,7 @@ class te extends H {
|
|
|
926
929
|
const s = this.convertAudioData(r);
|
|
927
930
|
this.writeConvertedPcm(s, r.numberOfChannels, r.sampleRate);
|
|
928
931
|
} catch (s) {
|
|
929
|
-
|
|
932
|
+
L(s);
|
|
930
933
|
} finally {
|
|
931
934
|
try {
|
|
932
935
|
r.close();
|
|
@@ -935,7 +938,7 @@ class te extends H {
|
|
|
935
938
|
}
|
|
936
939
|
},
|
|
937
940
|
error: (r) => {
|
|
938
|
-
|
|
941
|
+
L(r);
|
|
939
942
|
}
|
|
940
943
|
}), this.decoder.configure({ codec: e.codec, numberOfChannels: e.inputChannels, sampleRate: e.inputSampleRate });
|
|
941
944
|
}
|
|
@@ -953,7 +956,7 @@ class te extends H {
|
|
|
953
956
|
), e.isLast && this.decoder.flush().catch(() => {
|
|
954
957
|
});
|
|
955
958
|
} catch (r) {
|
|
956
|
-
|
|
959
|
+
L(r);
|
|
957
960
|
try {
|
|
958
961
|
this.reset();
|
|
959
962
|
} catch {
|
|
@@ -965,7 +968,7 @@ class te extends H {
|
|
|
965
968
|
try {
|
|
966
969
|
this.decoder.reset(), this.decoder.configure({ codec: this.codec, numberOfChannels: this.inputChannels, sampleRate: this.inputSampleRate });
|
|
967
970
|
} catch (e) {
|
|
968
|
-
|
|
971
|
+
L(e);
|
|
969
972
|
}
|
|
970
973
|
}
|
|
971
974
|
close() {
|
|
@@ -975,13 +978,15 @@ class te extends H {
|
|
|
975
978
|
}
|
|
976
979
|
}
|
|
977
980
|
}
|
|
978
|
-
class
|
|
981
|
+
class _e extends X {
|
|
979
982
|
decoder = null;
|
|
980
983
|
isReady = !1;
|
|
981
984
|
decoderSampleRate = 48e3;
|
|
982
985
|
resetTask = null;
|
|
983
986
|
pendingChunks = [];
|
|
984
987
|
resetGeneration = 0;
|
|
988
|
+
// Pre-allocated buffer for packet copies when byteOffset != 0
|
|
989
|
+
packetBuffer = null;
|
|
985
990
|
async initialise(e, r) {
|
|
986
991
|
const { OpusDecoder: s } = await import("./index-CvFH-Dkf.js"), a = [8e3, 12e3, 16e3, 24e3, 48e3].reduce((i, o) => Math.abs(o - r) < Math.abs(i - r) ? o : i);
|
|
987
992
|
this.decoderSampleRate = a, this.decoder = new s({ channels: e, sampleRate: this.decoderSampleRate }), await this.decoder.ready, this.isReady = !0;
|
|
@@ -999,17 +1004,22 @@ class ee extends H {
|
|
|
999
1004
|
if (this.resetTask)
|
|
1000
1005
|
return;
|
|
1001
1006
|
if (!this.isReady || !this.decoder) {
|
|
1002
|
-
this.pendingChunks =
|
|
1007
|
+
this.pendingChunks.length = 0;
|
|
1003
1008
|
return;
|
|
1004
1009
|
}
|
|
1005
|
-
|
|
1010
|
+
const e = this.pendingChunks, r = e.length;
|
|
1011
|
+
if (r === 0)
|
|
1006
1012
|
return;
|
|
1007
|
-
|
|
1008
|
-
for (let
|
|
1009
|
-
if (this.decodeChunk(e[
|
|
1010
|
-
|
|
1013
|
+
let s = 0;
|
|
1014
|
+
for (let n = 0; n < r; n++)
|
|
1015
|
+
if (this.decodeChunk(e[n]), s++, this.resetTask) {
|
|
1016
|
+
const a = r - s;
|
|
1017
|
+
for (let i = 0; i < a; i++)
|
|
1018
|
+
e[i] = e[s + i];
|
|
1019
|
+
e.length = a;
|
|
1011
1020
|
return;
|
|
1012
1021
|
}
|
|
1022
|
+
e.length = 0;
|
|
1013
1023
|
}
|
|
1014
1024
|
reset() {
|
|
1015
1025
|
super.reset();
|
|
@@ -1021,19 +1031,30 @@ class ee extends H {
|
|
|
1021
1031
|
decodeChunk(e) {
|
|
1022
1032
|
if (!(!this.isReady || !this.decoder))
|
|
1023
1033
|
try {
|
|
1024
|
-
|
|
1034
|
+
const r = e.data.byteLength;
|
|
1035
|
+
if (r === 0)
|
|
1025
1036
|
return;
|
|
1026
|
-
|
|
1027
|
-
|
|
1037
|
+
let s;
|
|
1038
|
+
e.data.byteOffset === 0 && r === e.data.buffer.byteLength ? s = e.data : ((!this.packetBuffer || this.packetBuffer.length < r) && (this.packetBuffer = new Uint8Array(Math.max(r, 512))), this.packetBuffer.set(e.data), s = this.packetBuffer.subarray(0, r));
|
|
1039
|
+
const n = this.decoder.decodeFrame(s), a = n.channelData, i = n.samplesDecoded, o = a.length;
|
|
1040
|
+
if (!o || !i)
|
|
1028
1041
|
return;
|
|
1029
|
-
const
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
for (let
|
|
1033
|
-
|
|
1034
|
-
|
|
1042
|
+
const _ = i * o, h = this.getInterleavedBuffer(_);
|
|
1043
|
+
if (o === 2) {
|
|
1044
|
+
const I = a[0], E = a[1];
|
|
1045
|
+
for (let l = 0, c = 0; l < i; l++)
|
|
1046
|
+
h[c++] = I[l], h[c++] = E[l];
|
|
1047
|
+
} else if (o === 1)
|
|
1048
|
+
h.set(a[0].subarray(0, i));
|
|
1049
|
+
else {
|
|
1050
|
+
let I = 0;
|
|
1051
|
+
for (let E = 0; E < i; E++)
|
|
1052
|
+
for (let l = 0; l < o; l++)
|
|
1053
|
+
h[I++] = a[l][E];
|
|
1054
|
+
}
|
|
1055
|
+
this.writeConvertedPcm(h.subarray(0, _), o, this.decoderSampleRate), e.isLast && this.reset();
|
|
1035
1056
|
} catch (r) {
|
|
1036
|
-
|
|
1057
|
+
L(r), this.scheduleReset();
|
|
1037
1058
|
}
|
|
1038
1059
|
}
|
|
1039
1060
|
feedChunk(e) {
|
|
@@ -1050,24 +1071,24 @@ class ee extends H {
|
|
|
1050
1071
|
this.decoder?.free();
|
|
1051
1072
|
} catch {
|
|
1052
1073
|
}
|
|
1053
|
-
this.decoder = null;
|
|
1074
|
+
this.decoder = null, this.packetBuffer = null, this.pendingChunks.length = 0;
|
|
1054
1075
|
}
|
|
1055
1076
|
}
|
|
1056
1077
|
const N = /* @__PURE__ */ new Map();
|
|
1057
|
-
async function
|
|
1078
|
+
async function Ee(t) {
|
|
1058
1079
|
if (t.closed || t.decoder)
|
|
1059
1080
|
return;
|
|
1060
1081
|
if (t.codec === T.RawPcm16) {
|
|
1061
|
-
t.decoder = new
|
|
1082
|
+
t.decoder = new ae({ inputChannels: t.inputChannels, inputSampleRate: t.inputSampleRate, sink: t.sink });
|
|
1062
1083
|
return;
|
|
1063
1084
|
}
|
|
1064
1085
|
if (t.codec !== T.Opus && t.codec !== T.Mp3)
|
|
1065
1086
|
throw new Error(`Unsupported audio codec: ${T[t.codec] ?? t.codec}`);
|
|
1066
|
-
const e =
|
|
1067
|
-
if (
|
|
1087
|
+
const e = ne(t.codec);
|
|
1088
|
+
if (at && typeof AudioDecoder < "u" && e !== null)
|
|
1068
1089
|
try {
|
|
1069
1090
|
if ((await AudioDecoder.isConfigSupported({ codec: e, numberOfChannels: t.inputChannels, sampleRate: t.inputSampleRate })).supported) {
|
|
1070
|
-
const n = new
|
|
1091
|
+
const n = new oe({
|
|
1071
1092
|
codec: e,
|
|
1072
1093
|
inputChannels: t.inputChannels,
|
|
1073
1094
|
inputSampleRate: t.inputSampleRate,
|
|
@@ -1083,7 +1104,7 @@ async function re(t) {
|
|
|
1083
1104
|
} catch {
|
|
1084
1105
|
}
|
|
1085
1106
|
if (t.codec === T.Opus) {
|
|
1086
|
-
const s = new
|
|
1107
|
+
const s = new _e({ inputChannels: t.inputChannels, inputSampleRate: t.inputSampleRate, sink: t.sink });
|
|
1087
1108
|
if (await s.initialise(t.inputChannels, t.inputSampleRate), t.closed) {
|
|
1088
1109
|
s.close();
|
|
1089
1110
|
return;
|
|
@@ -1093,7 +1114,7 @@ async function re(t) {
|
|
|
1093
1114
|
}
|
|
1094
1115
|
throw new Error(`No available decoder for codec: ${T[t.codec] ?? t.codec}`);
|
|
1095
1116
|
}
|
|
1096
|
-
function
|
|
1117
|
+
function le(t) {
|
|
1097
1118
|
if (t.closed) {
|
|
1098
1119
|
t.pendingFrames.splice(0);
|
|
1099
1120
|
try {
|
|
@@ -1107,25 +1128,25 @@ function se(t) {
|
|
|
1107
1128
|
return;
|
|
1108
1129
|
const e = t.pendingFrames.splice(0);
|
|
1109
1130
|
for (const r of e)
|
|
1110
|
-
|
|
1131
|
+
ot(t, r);
|
|
1111
1132
|
}
|
|
1112
|
-
function
|
|
1133
|
+
function ot(t, e) {
|
|
1113
1134
|
if (t.closed || !t.decoder)
|
|
1114
1135
|
return;
|
|
1115
1136
|
const r = e.Epoch, s = Number(e.TimeStampInInterleavedSamples), n = e.FrameSizeInInterleavedSamples;
|
|
1116
1137
|
if (t.currentEpoch !== r && (t.currentEpoch = r, t.epochSet = !1, t.lastArrivalTimeMs = 0, t.jitterMs = 0, t.sink.flush(), t.decoder.reset()), !t.epochSet) {
|
|
1117
1138
|
t.epochSet = !0;
|
|
1118
|
-
const
|
|
1119
|
-
t.expectedIntervalMs = n * 1e3 /
|
|
1139
|
+
const l = t.inputSampleRate * t.inputChannels;
|
|
1140
|
+
t.expectedIntervalMs = n * 1e3 / l;
|
|
1120
1141
|
}
|
|
1121
1142
|
const a = performance.now();
|
|
1122
1143
|
if (t.lastArrivalTimeMs > 0) {
|
|
1123
|
-
const
|
|
1124
|
-
t.jitterMs = t.jitterMs + (c - t.jitterMs) /
|
|
1144
|
+
const l = a - t.lastArrivalTimeMs, c = Math.abs(l - t.expectedIntervalMs);
|
|
1145
|
+
t.jitterMs = t.jitterMs + (c - t.jitterMs) / qt;
|
|
1125
1146
|
}
|
|
1126
1147
|
t.lastArrivalTimeMs = a;
|
|
1127
|
-
const i = t.inputSampleRate * t.inputChannels, o = R * S, _ = Math.round(s * o / i), h = Math.round(n * o / i),
|
|
1128
|
-
|
|
1148
|
+
const i = t.inputSampleRate * t.inputChannels, o = R * S, _ = Math.round(s * o / i), h = Math.round(n * o / i), I = Math.round(s * 1e6 / i), E = Math.round(n * 1e6 / i);
|
|
1149
|
+
P({
|
|
1129
1150
|
type: "frame",
|
|
1130
1151
|
streamId: t.streamId,
|
|
1131
1152
|
epoch: r,
|
|
@@ -1138,12 +1159,12 @@ function et(t, e) {
|
|
|
1138
1159
|
data: e.Samples,
|
|
1139
1160
|
isFirst: e.IsFirst,
|
|
1140
1161
|
isLast: e.IsLast,
|
|
1141
|
-
timestampUs:
|
|
1142
|
-
durationUs:
|
|
1162
|
+
timestampUs: I,
|
|
1163
|
+
durationUs: E
|
|
1143
1164
|
});
|
|
1144
1165
|
}
|
|
1145
|
-
function
|
|
1146
|
-
const e =
|
|
1166
|
+
function he(t) {
|
|
1167
|
+
const e = W(t), r = Xt(t), s = N.get(e);
|
|
1147
1168
|
if (s) {
|
|
1148
1169
|
s.closed = !0, s.pendingFrames.splice(0);
|
|
1149
1170
|
try {
|
|
@@ -1156,7 +1177,7 @@ function ne(t) {
|
|
|
1156
1177
|
}
|
|
1157
1178
|
N.delete(e);
|
|
1158
1179
|
}
|
|
1159
|
-
const n = new
|
|
1180
|
+
const n = new se(e), a = {
|
|
1160
1181
|
streamId: e,
|
|
1161
1182
|
codec: r.Codec,
|
|
1162
1183
|
inputSampleRate: r.SampleRate,
|
|
@@ -1172,22 +1193,22 @@ function ne(t) {
|
|
|
1172
1193
|
jitterMs: 0,
|
|
1173
1194
|
expectedIntervalMs: 20
|
|
1174
1195
|
};
|
|
1175
|
-
N.set(e, a),
|
|
1196
|
+
N.set(e, a), P({
|
|
1176
1197
|
type: "streamBegin",
|
|
1177
1198
|
streamId: e,
|
|
1178
1199
|
sharedArrayBuffer: n.getSharedArrayBuffer()
|
|
1179
1200
|
});
|
|
1180
1201
|
}
|
|
1181
|
-
function
|
|
1202
|
+
function Ie() {
|
|
1182
1203
|
for (const t of N.values())
|
|
1183
|
-
|
|
1204
|
+
P({
|
|
1184
1205
|
type: "streamBegin",
|
|
1185
1206
|
streamId: t.streamId,
|
|
1186
1207
|
sharedArrayBuffer: t.sink.getSharedArrayBuffer()
|
|
1187
1208
|
});
|
|
1188
1209
|
}
|
|
1189
|
-
function
|
|
1190
|
-
const e =
|
|
1210
|
+
function fe(t) {
|
|
1211
|
+
const e = W(t), r = N.get(e);
|
|
1191
1212
|
if (r) {
|
|
1192
1213
|
r.closed = !0, r.pendingFrames.splice(0);
|
|
1193
1214
|
try {
|
|
@@ -1198,48 +1219,48 @@ function ae(t) {
|
|
|
1198
1219
|
r.decoder?.close();
|
|
1199
1220
|
} catch {
|
|
1200
1221
|
}
|
|
1201
|
-
r.decoder = null, N.delete(e),
|
|
1222
|
+
r.decoder = null, N.delete(e), P({ type: "streamEnd", streamId: e });
|
|
1202
1223
|
}
|
|
1203
1224
|
}
|
|
1204
|
-
function
|
|
1205
|
-
const e =
|
|
1225
|
+
function ue(t) {
|
|
1226
|
+
const e = W(t), r = N.get(e);
|
|
1206
1227
|
if (!r || r.closed)
|
|
1207
1228
|
return;
|
|
1208
|
-
const s =
|
|
1229
|
+
const s = Bt(t);
|
|
1209
1230
|
if (!r.decoder) {
|
|
1210
|
-
r.pendingFrames.length >=
|
|
1211
|
-
r.closed ||
|
|
1231
|
+
r.pendingFrames.length >= Q && r.pendingFrames.splice(0, r.pendingFrames.length - Q + 1), r.pendingFrames.push(s), r.initTask || (r.initTask = Ee(r).then(() => le(r)).catch((n) => {
|
|
1232
|
+
r.closed || L(n, e);
|
|
1212
1233
|
}));
|
|
1213
1234
|
return;
|
|
1214
1235
|
}
|
|
1215
|
-
|
|
1236
|
+
ot(r, s);
|
|
1216
1237
|
}
|
|
1217
|
-
function
|
|
1218
|
-
switch (
|
|
1219
|
-
case
|
|
1220
|
-
|
|
1238
|
+
function Ae(t) {
|
|
1239
|
+
switch (ht(t)) {
|
|
1240
|
+
case G.AUDIO_STREAM_BEGIN:
|
|
1241
|
+
he(t);
|
|
1221
1242
|
return;
|
|
1222
|
-
case
|
|
1223
|
-
|
|
1243
|
+
case G.AUDIO_STREAM_END:
|
|
1244
|
+
fe(t);
|
|
1224
1245
|
return;
|
|
1225
|
-
case
|
|
1226
|
-
|
|
1246
|
+
case G.AUDIO_FRAME2:
|
|
1247
|
+
ue(t);
|
|
1227
1248
|
return;
|
|
1228
1249
|
default:
|
|
1229
1250
|
return;
|
|
1230
1251
|
}
|
|
1231
1252
|
}
|
|
1232
|
-
function
|
|
1233
|
-
if (
|
|
1253
|
+
function _t() {
|
|
1254
|
+
if (y) {
|
|
1234
1255
|
try {
|
|
1235
|
-
|
|
1256
|
+
y.close();
|
|
1236
1257
|
} catch {
|
|
1237
1258
|
}
|
|
1238
|
-
|
|
1259
|
+
y = null;
|
|
1239
1260
|
}
|
|
1240
1261
|
}
|
|
1241
|
-
function
|
|
1242
|
-
|
|
1262
|
+
function ce() {
|
|
1263
|
+
_t();
|
|
1243
1264
|
for (const t of N.values()) {
|
|
1244
1265
|
try {
|
|
1245
1266
|
t.sink.drainPcm(), t.sink.close();
|
|
@@ -1255,49 +1276,76 @@ function Ee() {
|
|
|
1255
1276
|
self.addEventListener("message", (t) => {
|
|
1256
1277
|
const e = t.data;
|
|
1257
1278
|
if (e.type === "configure") {
|
|
1258
|
-
|
|
1279
|
+
V = e.transport, at = e.preferWebCodecs ?? !0, R = Number.isFinite(e.outputSampleRate) && e.outputSampleRate > 0 ? e.outputSampleRate : nt, S = Number.isFinite(e.outputChannels) && e.outputChannels > 0 ? e.outputChannels : it;
|
|
1259
1280
|
return;
|
|
1260
1281
|
}
|
|
1261
1282
|
if (e.type === "attachProtocolPort") {
|
|
1262
|
-
|
|
1283
|
+
_t(), y = e.port, y.start?.(), y.addEventListener("message", (r) => {
|
|
1263
1284
|
const s = r.data;
|
|
1264
|
-
s?.type === "protocol" && s.message instanceof ArrayBuffer &&
|
|
1285
|
+
s?.type === "protocol" && s.message instanceof ArrayBuffer && Ae(new Uint8Array(s.message));
|
|
1265
1286
|
});
|
|
1266
1287
|
return;
|
|
1267
1288
|
}
|
|
1268
1289
|
if (e.type === "rebind") {
|
|
1269
|
-
|
|
1290
|
+
V = e.transport, typeof e.outputSampleRate == "number" && Number.isFinite(e.outputSampleRate) && e.outputSampleRate > 0 && (R = e.outputSampleRate), typeof e.outputChannels == "number" && Number.isFinite(e.outputChannels) && e.outputChannels > 0 && (S = e.outputChannels);
|
|
1270
1291
|
for (const r of N.values())
|
|
1271
|
-
r.sink.setOutputFormat(R, S), r.sink.rebind(
|
|
1272
|
-
|
|
1292
|
+
r.sink.setOutputFormat(R, S), r.sink.rebind(V);
|
|
1293
|
+
Ie();
|
|
1273
1294
|
return;
|
|
1274
1295
|
}
|
|
1275
|
-
e.type === "dispose" &&
|
|
1296
|
+
e.type === "dispose" && ce();
|
|
1276
1297
|
});
|
|
1277
|
-
let
|
|
1278
|
-
function
|
|
1279
|
-
|
|
1298
|
+
let U = null;
|
|
1299
|
+
function Te(t, e) {
|
|
1300
|
+
const r = t.length;
|
|
1301
|
+
if (r === 1)
|
|
1280
1302
|
return t[0];
|
|
1281
|
-
const
|
|
1282
|
-
(!
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1303
|
+
const s = e * r;
|
|
1304
|
+
if ((!U || U.length < s) && (U = new Float32Array(s)), r === 2) {
|
|
1305
|
+
const n = t[0], a = t[1];
|
|
1306
|
+
for (let i = 0, o = 0; i < e; i++)
|
|
1307
|
+
U[o++] = n[i], U[o++] = a[i];
|
|
1308
|
+
} else {
|
|
1309
|
+
let n = 0;
|
|
1310
|
+
for (let a = 0; a < e; a++)
|
|
1311
|
+
for (let i = 0; i < r; i++)
|
|
1312
|
+
U[n++] = t[i][a];
|
|
1313
|
+
}
|
|
1314
|
+
return U.subarray(0, s);
|
|
1315
|
+
}
|
|
1316
|
+
const J = 3;
|
|
1317
|
+
function Z(t) {
|
|
1318
|
+
if (t === 0)
|
|
1319
|
+
return 1;
|
|
1320
|
+
const e = Math.PI * t;
|
|
1321
|
+
return Math.sin(e) / e;
|
|
1288
1322
|
}
|
|
1289
|
-
function
|
|
1323
|
+
function Ne(t, e) {
|
|
1324
|
+
return t === 0 ? 1 : Math.abs(t) >= e ? 0 : Z(t) * Z(t / e);
|
|
1325
|
+
}
|
|
1326
|
+
function Ce(t, e, r, s, n) {
|
|
1290
1327
|
if (s === n)
|
|
1291
1328
|
return e.set(t), t.length;
|
|
1292
|
-
const a = t.length / r, i = Math.max(1, Math.round(a * n / s));
|
|
1293
|
-
for (let
|
|
1294
|
-
for (let
|
|
1295
|
-
const
|
|
1296
|
-
|
|
1329
|
+
const a = t.length / r, i = Math.max(1, Math.round(a * n / s)), o = s / n, _ = o > 1 ? o : 1, h = Math.ceil(J * _);
|
|
1330
|
+
for (let I = 0; I < r; I++)
|
|
1331
|
+
for (let E = 0; E < i; E++) {
|
|
1332
|
+
const l = E * o, c = Math.floor(l);
|
|
1333
|
+
let O = 0, m = 0;
|
|
1334
|
+
for (let k = -h + 1; k <= h; k++) {
|
|
1335
|
+
const B = c + k;
|
|
1336
|
+
if (B < 0 || B >= a)
|
|
1337
|
+
continue;
|
|
1338
|
+
const Et = (l - B) / _, v = Ne(Et, J);
|
|
1339
|
+
if (v !== 0) {
|
|
1340
|
+
const lt = t[B * r + I] ?? 0;
|
|
1341
|
+
O += lt * v, m += v;
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
e[E * r + I] = m > 0 ? O / m : 0;
|
|
1297
1345
|
}
|
|
1298
1346
|
return i * r;
|
|
1299
1347
|
}
|
|
1300
|
-
function
|
|
1348
|
+
function Se(t, e, r, s) {
|
|
1301
1349
|
const n = t.length / r;
|
|
1302
1350
|
if (r === s)
|
|
1303
1351
|
return e.set(t), t.length;
|