@ikonai/sdk 0.0.42 → 0.0.43
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 +1532 -1311
- 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,843 +0,0 @@
|
|
|
1
|
-
function k(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 v(t) {
|
|
7
|
-
const e = z(t), r = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
8
|
-
if (e.length < 27)
|
|
9
|
-
throw new Error("Protocol payload too short");
|
|
10
|
-
const n = r.getUint32(0, !0), i = r.getUint32(4, !0), E = r.getUint32(8, !0), N = r.getUint32(12, !0), I = r.getUint32(16, !0), s = r.getUint32(20, !0), a = r.getUint8(24), T = r.getUint8(25), h = r.getUint8(26);
|
|
11
|
-
if (27 + s * 4 > e.length)
|
|
12
|
-
throw new Error("Protocol header exceeds payload length");
|
|
13
|
-
const A = [];
|
|
14
|
-
let o = 27;
|
|
15
|
-
for (let w = 0; w < s; w++)
|
|
16
|
-
A.push(r.getUint32(o, !0)), o += 4;
|
|
17
|
-
return {
|
|
18
|
-
length: n,
|
|
19
|
-
opcode: i,
|
|
20
|
-
senderId: E,
|
|
21
|
-
trackId: N,
|
|
22
|
-
sequenceId: I,
|
|
23
|
-
targetIds: A,
|
|
24
|
-
payloadVersion: a,
|
|
25
|
-
payloadType: T,
|
|
26
|
-
flags: h
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function B(t, e, r, n, i) {
|
|
30
|
-
const E = i?.trackId ?? 0, N = i?.sequenceId ?? 0, I = i?.flags ?? 0, s = i?.targetIds ?? [], a = i?.payloadType ?? 8, T = 27 + s.length * 4, h = T + e.length, S = new Uint8Array(h), A = new DataView(S.buffer);
|
|
31
|
-
A.setUint32(0, h, !0), A.setUint32(4, t >>> 0, !0), A.setUint32(8, n >>> 0, !0), A.setUint32(12, E >>> 0, !0), A.setUint32(16, N >>> 0, !0), A.setUint32(20, s.length >>> 0, !0), A.setUint8(24, r & 255), A.setUint8(25, a & 255), A.setUint8(26, I & 255);
|
|
32
|
-
let o = 27;
|
|
33
|
-
for (let w = 0; w < s.length; w++)
|
|
34
|
-
A.setUint32(o, s[w] >>> 0, !0), o += 4;
|
|
35
|
-
return S.set(e, T), S;
|
|
36
|
-
}
|
|
37
|
-
var y = /* @__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))(y || {});
|
|
38
|
-
const W = 161, Y = 162, D = new TextEncoder();
|
|
39
|
-
new TextDecoder("utf-8", { fatal: !0 });
|
|
40
|
-
class l {
|
|
41
|
-
constructor(e = 1) {
|
|
42
|
-
this.version = e, this.buffer.writeByte(W), this.buffer.writeVarUInt(e >>> 0);
|
|
43
|
-
}
|
|
44
|
-
buffer = new f();
|
|
45
|
-
closed = !1;
|
|
46
|
-
cached;
|
|
47
|
-
writeInt32Field(e, r) {
|
|
48
|
-
this.writeFixedField(e, 3, () => this.buffer.writeInt32(r | 0));
|
|
49
|
-
}
|
|
50
|
-
writeUInt32Field(e, r) {
|
|
51
|
-
this.writeFixedField(e, 5, () => this.buffer.writeUInt32(r >>> 0));
|
|
52
|
-
}
|
|
53
|
-
writeInt64Field(e, r) {
|
|
54
|
-
this.writeFixedField(e, 4, () => this.buffer.writeBigInt64(r));
|
|
55
|
-
}
|
|
56
|
-
writeUInt64Field(e, r) {
|
|
57
|
-
this.writeFixedField(e, 6, () => this.buffer.writeBigUInt64(r));
|
|
58
|
-
}
|
|
59
|
-
writeFloat32Field(e, r) {
|
|
60
|
-
this.writeFixedField(e, 7, () => this.buffer.writeFloat32(r));
|
|
61
|
-
}
|
|
62
|
-
writeFloat64Field(e, r) {
|
|
63
|
-
this.writeFixedField(e, 8, () => this.buffer.writeFloat64(r));
|
|
64
|
-
}
|
|
65
|
-
writeBoolField(e, r) {
|
|
66
|
-
this.writeFixedField(e, 2, () => this.buffer.writeByte(r ? 1 : 0));
|
|
67
|
-
}
|
|
68
|
-
writeGuidField(e, r) {
|
|
69
|
-
const n = r instanceof _ ? r.asBytes() : r;
|
|
70
|
-
if (n.length !== 16)
|
|
71
|
-
throw new Error("Guid payload must be 16 bytes");
|
|
72
|
-
this.writeFixedField(e, 14, () => this.buffer.writeBytes(n));
|
|
73
|
-
}
|
|
74
|
-
writeStringField(e, r) {
|
|
75
|
-
const n = D.encode(r ?? "");
|
|
76
|
-
this.writeVariableField(e, 12, n);
|
|
77
|
-
}
|
|
78
|
-
writeBinaryField(e, r) {
|
|
79
|
-
this.writeVariableField(e, 13, r);
|
|
80
|
-
}
|
|
81
|
-
writeObjectField(e, r, n) {
|
|
82
|
-
const i = new l(r);
|
|
83
|
-
n(i);
|
|
84
|
-
const E = i.finish();
|
|
85
|
-
this.writeVariableField(e, 11, E);
|
|
86
|
-
}
|
|
87
|
-
writeArrayField(e, r, n) {
|
|
88
|
-
const i = new O(r);
|
|
89
|
-
n(i);
|
|
90
|
-
const E = i.finish();
|
|
91
|
-
this.writeVariableField(e, 9, E);
|
|
92
|
-
}
|
|
93
|
-
writeDictionaryField(e, r, n, i) {
|
|
94
|
-
const E = new M(r, n);
|
|
95
|
-
i(E);
|
|
96
|
-
const N = E.finish();
|
|
97
|
-
this.writeVariableField(e, 10, N);
|
|
98
|
-
}
|
|
99
|
-
finish() {
|
|
100
|
-
return this.closed || (this.buffer.writeByte(Y), this.closed = !0, this.cached = this.buffer.toUint8Array()), this.cached;
|
|
101
|
-
}
|
|
102
|
-
writeFixedField(e, r, n) {
|
|
103
|
-
this.writeFieldHeader(e, r, 0), n();
|
|
104
|
-
}
|
|
105
|
-
writeVariableField(e, r, n) {
|
|
106
|
-
this.writeFieldHeader(e, r, n.length), this.buffer.writeBytes(n);
|
|
107
|
-
}
|
|
108
|
-
writeFieldHeader(e, r, n) {
|
|
109
|
-
this.buffer.writeUInt32(e >>> 0), this.buffer.writeByte(P(r)), X(r) && this.buffer.writeVarUInt(n >>> 0);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
class O {
|
|
113
|
-
constructor(e) {
|
|
114
|
-
this.elementType = e;
|
|
115
|
-
}
|
|
116
|
-
payload = new f();
|
|
117
|
-
count = 0;
|
|
118
|
-
writeInt32(e) {
|
|
119
|
-
this.ensureElementType(
|
|
120
|
-
3
|
|
121
|
-
/* Int32 */
|
|
122
|
-
), this.count++, this.payload.writeInt32(e | 0);
|
|
123
|
-
}
|
|
124
|
-
writeUInt32(e) {
|
|
125
|
-
this.ensureElementType(
|
|
126
|
-
5
|
|
127
|
-
/* UInt32 */
|
|
128
|
-
), this.count++, this.payload.writeUInt32(e >>> 0);
|
|
129
|
-
}
|
|
130
|
-
writeInt64(e) {
|
|
131
|
-
this.ensureElementType(
|
|
132
|
-
4
|
|
133
|
-
/* Int64 */
|
|
134
|
-
), this.count++, this.payload.writeBigInt64(e);
|
|
135
|
-
}
|
|
136
|
-
writeUInt64(e) {
|
|
137
|
-
this.ensureElementType(
|
|
138
|
-
6
|
|
139
|
-
/* UInt64 */
|
|
140
|
-
), this.count++, this.payload.writeBigUInt64(e);
|
|
141
|
-
}
|
|
142
|
-
writeFloat32(e) {
|
|
143
|
-
this.ensureElementType(
|
|
144
|
-
7
|
|
145
|
-
/* Float32 */
|
|
146
|
-
), this.count++, this.payload.writeFloat32(e);
|
|
147
|
-
}
|
|
148
|
-
writeFloat64(e) {
|
|
149
|
-
this.ensureElementType(
|
|
150
|
-
8
|
|
151
|
-
/* Float64 */
|
|
152
|
-
), this.count++, this.payload.writeFloat64(e);
|
|
153
|
-
}
|
|
154
|
-
writeBool(e) {
|
|
155
|
-
this.ensureElementType(
|
|
156
|
-
2
|
|
157
|
-
/* Bool */
|
|
158
|
-
), this.count++, this.payload.writeByte(e ? 1 : 0);
|
|
159
|
-
}
|
|
160
|
-
writeGuid(e) {
|
|
161
|
-
this.ensureElementType(
|
|
162
|
-
14
|
|
163
|
-
/* Guid */
|
|
164
|
-
), this.count++;
|
|
165
|
-
const r = e instanceof _ ? e.asBytes() : e;
|
|
166
|
-
if (r.length !== 16)
|
|
167
|
-
throw new Error("Guid payload must be 16 bytes");
|
|
168
|
-
this.payload.writeBytes(r);
|
|
169
|
-
}
|
|
170
|
-
writeString(e) {
|
|
171
|
-
this.ensureElementType(
|
|
172
|
-
12
|
|
173
|
-
/* String */
|
|
174
|
-
), this.count++;
|
|
175
|
-
const r = D.encode(e ?? "");
|
|
176
|
-
this.payload.writeVarUInt(r.length), this.payload.writeBytes(r);
|
|
177
|
-
}
|
|
178
|
-
writeBinary(e) {
|
|
179
|
-
this.ensureElementType(
|
|
180
|
-
13
|
|
181
|
-
/* Binary */
|
|
182
|
-
), this.count++, this.payload.writeVarUInt(e.length), this.payload.writeBytes(e);
|
|
183
|
-
}
|
|
184
|
-
writeObject(e, r) {
|
|
185
|
-
this.ensureElementType(
|
|
186
|
-
11
|
|
187
|
-
/* Object */
|
|
188
|
-
), this.count++;
|
|
189
|
-
const n = new l(e);
|
|
190
|
-
r(n);
|
|
191
|
-
const i = n.finish();
|
|
192
|
-
this.payload.writeVarUInt(i.length), this.payload.writeBytes(i);
|
|
193
|
-
}
|
|
194
|
-
writeArray(e, r) {
|
|
195
|
-
this.ensureElementType(
|
|
196
|
-
9
|
|
197
|
-
/* Array */
|
|
198
|
-
), this.count++;
|
|
199
|
-
const n = new O(e);
|
|
200
|
-
r(n);
|
|
201
|
-
const i = n.finish();
|
|
202
|
-
this.payload.writeBytes(i);
|
|
203
|
-
}
|
|
204
|
-
writeDictionary(e, r, n) {
|
|
205
|
-
this.ensureElementType(
|
|
206
|
-
10
|
|
207
|
-
/* Dict */
|
|
208
|
-
), this.count++;
|
|
209
|
-
const i = new M(e, r);
|
|
210
|
-
n(i);
|
|
211
|
-
const E = i.finish();
|
|
212
|
-
this.payload.writeBytes(E);
|
|
213
|
-
}
|
|
214
|
-
finish() {
|
|
215
|
-
const e = new f();
|
|
216
|
-
return e.writeByte(P(this.elementType)), e.writeVarUInt(this.count), e.writeBytes(this.payload.toUint8Array()), e.toUint8Array();
|
|
217
|
-
}
|
|
218
|
-
ensureElementType(e) {
|
|
219
|
-
if (this.elementType !== e)
|
|
220
|
-
throw new Error(`Array element type is ${y[this.elementType]}, expected ${y[e]}`);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
class M {
|
|
224
|
-
constructor(e, r) {
|
|
225
|
-
this.keyType = e, this.valueType = r, j(e);
|
|
226
|
-
}
|
|
227
|
-
payload = new f();
|
|
228
|
-
count = 0;
|
|
229
|
-
entryOpen = !1;
|
|
230
|
-
beginEntry() {
|
|
231
|
-
if (this.entryOpen)
|
|
232
|
-
throw new Error("Previous dictionary entry not completed");
|
|
233
|
-
return this.count++, this.entryOpen = !0, new x(this.keyType, this.valueType, this.payload, () => {
|
|
234
|
-
this.entryOpen = !1;
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
finish() {
|
|
238
|
-
if (this.entryOpen)
|
|
239
|
-
throw new Error("Dictionary entry not completed");
|
|
240
|
-
const e = new f();
|
|
241
|
-
return e.writeByte(P(this.keyType)), e.writeByte(P(this.valueType)), e.writeVarUInt(this.count), e.writeBytes(this.payload.toUint8Array()), e.toUint8Array();
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
class x {
|
|
245
|
-
constructor(e, r, n, i) {
|
|
246
|
-
this.keyType = e, this.valueType = r, this.payload = n, this.onComplete = i;
|
|
247
|
-
}
|
|
248
|
-
keyWritten = !1;
|
|
249
|
-
valueWritten = !1;
|
|
250
|
-
completed = !1;
|
|
251
|
-
writeKeyInt32(e) {
|
|
252
|
-
this.ensureKeyType(
|
|
253
|
-
3
|
|
254
|
-
/* Int32 */
|
|
255
|
-
), this.payload.writeInt32(e | 0), this.keyWritten = !0;
|
|
256
|
-
}
|
|
257
|
-
writeKeyUInt32(e) {
|
|
258
|
-
this.ensureKeyType(
|
|
259
|
-
5
|
|
260
|
-
/* UInt32 */
|
|
261
|
-
), this.payload.writeUInt32(e >>> 0), this.keyWritten = !0;
|
|
262
|
-
}
|
|
263
|
-
writeKeyInt64(e) {
|
|
264
|
-
this.ensureKeyType(
|
|
265
|
-
4
|
|
266
|
-
/* Int64 */
|
|
267
|
-
), this.payload.writeBigInt64(e), this.keyWritten = !0;
|
|
268
|
-
}
|
|
269
|
-
writeKeyUInt64(e) {
|
|
270
|
-
this.ensureKeyType(
|
|
271
|
-
6
|
|
272
|
-
/* UInt64 */
|
|
273
|
-
), this.payload.writeBigUInt64(e), this.keyWritten = !0;
|
|
274
|
-
}
|
|
275
|
-
writeKeyFloat32(e) {
|
|
276
|
-
this.ensureKeyType(
|
|
277
|
-
7
|
|
278
|
-
/* Float32 */
|
|
279
|
-
), this.payload.writeFloat32(e), this.keyWritten = !0;
|
|
280
|
-
}
|
|
281
|
-
writeKeyFloat64(e) {
|
|
282
|
-
this.ensureKeyType(
|
|
283
|
-
8
|
|
284
|
-
/* Float64 */
|
|
285
|
-
), this.payload.writeFloat64(e), this.keyWritten = !0;
|
|
286
|
-
}
|
|
287
|
-
writeKeyBool(e) {
|
|
288
|
-
this.ensureKeyType(
|
|
289
|
-
2
|
|
290
|
-
/* Bool */
|
|
291
|
-
), this.payload.writeByte(e ? 1 : 0), this.keyWritten = !0;
|
|
292
|
-
}
|
|
293
|
-
writeKeyGuid(e) {
|
|
294
|
-
this.ensureKeyType(
|
|
295
|
-
14
|
|
296
|
-
/* Guid */
|
|
297
|
-
);
|
|
298
|
-
const r = e instanceof _ ? e.asBytes() : e;
|
|
299
|
-
if (r.length !== 16)
|
|
300
|
-
throw new Error("Guid payload must be 16 bytes");
|
|
301
|
-
this.payload.writeBytes(r), this.keyWritten = !0;
|
|
302
|
-
}
|
|
303
|
-
writeKeyString(e) {
|
|
304
|
-
this.ensureKeyType(
|
|
305
|
-
12
|
|
306
|
-
/* String */
|
|
307
|
-
);
|
|
308
|
-
const r = D.encode(e ?? "");
|
|
309
|
-
this.payload.writeVarUInt(r.length), this.payload.writeBytes(r), this.keyWritten = !0;
|
|
310
|
-
}
|
|
311
|
-
writeKeyBinary(e) {
|
|
312
|
-
this.ensureKeyType(
|
|
313
|
-
13
|
|
314
|
-
/* Binary */
|
|
315
|
-
), this.payload.writeVarUInt(e.length), this.payload.writeBytes(e), this.keyWritten = !0;
|
|
316
|
-
}
|
|
317
|
-
writeValueInt32(e) {
|
|
318
|
-
this.ensureValueType(
|
|
319
|
-
3
|
|
320
|
-
/* Int32 */
|
|
321
|
-
), this.payload.writeInt32(e | 0), this.valueWritten = !0;
|
|
322
|
-
}
|
|
323
|
-
writeValueUInt32(e) {
|
|
324
|
-
this.ensureValueType(
|
|
325
|
-
5
|
|
326
|
-
/* UInt32 */
|
|
327
|
-
), this.payload.writeUInt32(e >>> 0), this.valueWritten = !0;
|
|
328
|
-
}
|
|
329
|
-
writeValueInt64(e) {
|
|
330
|
-
this.ensureValueType(
|
|
331
|
-
4
|
|
332
|
-
/* Int64 */
|
|
333
|
-
), this.payload.writeBigInt64(e), this.valueWritten = !0;
|
|
334
|
-
}
|
|
335
|
-
writeValueUInt64(e) {
|
|
336
|
-
this.ensureValueType(
|
|
337
|
-
6
|
|
338
|
-
/* UInt64 */
|
|
339
|
-
), this.payload.writeBigUInt64(e), this.valueWritten = !0;
|
|
340
|
-
}
|
|
341
|
-
writeValueFloat32(e) {
|
|
342
|
-
this.ensureValueType(
|
|
343
|
-
7
|
|
344
|
-
/* Float32 */
|
|
345
|
-
), this.payload.writeFloat32(e), this.valueWritten = !0;
|
|
346
|
-
}
|
|
347
|
-
writeValueFloat64(e) {
|
|
348
|
-
this.ensureValueType(
|
|
349
|
-
8
|
|
350
|
-
/* Float64 */
|
|
351
|
-
), this.payload.writeFloat64(e), this.valueWritten = !0;
|
|
352
|
-
}
|
|
353
|
-
writeValueBool(e) {
|
|
354
|
-
this.ensureValueType(
|
|
355
|
-
2
|
|
356
|
-
/* Bool */
|
|
357
|
-
), this.payload.writeByte(e ? 1 : 0), this.valueWritten = !0;
|
|
358
|
-
}
|
|
359
|
-
writeValueGuid(e) {
|
|
360
|
-
this.ensureValueType(
|
|
361
|
-
14
|
|
362
|
-
/* Guid */
|
|
363
|
-
);
|
|
364
|
-
const r = e instanceof _ ? e.asBytes() : e;
|
|
365
|
-
if (r.length !== 16)
|
|
366
|
-
throw new Error("Guid payload must be 16 bytes");
|
|
367
|
-
this.payload.writeBytes(r), this.valueWritten = !0;
|
|
368
|
-
}
|
|
369
|
-
writeNullValue() {
|
|
370
|
-
this.ensureValueType(
|
|
371
|
-
1
|
|
372
|
-
/* Null */
|
|
373
|
-
), this.valueWritten = !0;
|
|
374
|
-
}
|
|
375
|
-
writeValueBinary(e) {
|
|
376
|
-
this.ensureValueType(
|
|
377
|
-
13
|
|
378
|
-
/* Binary */
|
|
379
|
-
), this.payload.writeVarUInt(e.length), this.payload.writeBytes(e), this.valueWritten = !0;
|
|
380
|
-
}
|
|
381
|
-
writeValueString(e) {
|
|
382
|
-
this.ensureValueType(
|
|
383
|
-
12
|
|
384
|
-
/* String */
|
|
385
|
-
);
|
|
386
|
-
const r = D.encode(e ?? "");
|
|
387
|
-
this.payload.writeVarUInt(r.length), this.payload.writeBytes(r), this.valueWritten = !0;
|
|
388
|
-
}
|
|
389
|
-
writeValueObject(e, r) {
|
|
390
|
-
this.ensureValueType(
|
|
391
|
-
11
|
|
392
|
-
/* Object */
|
|
393
|
-
);
|
|
394
|
-
const n = new l(e);
|
|
395
|
-
r(n);
|
|
396
|
-
const i = n.finish();
|
|
397
|
-
this.payload.writeVarUInt(i.length), this.payload.writeBytes(i), this.valueWritten = !0;
|
|
398
|
-
}
|
|
399
|
-
writeValueArray(e, r) {
|
|
400
|
-
this.ensureValueType(
|
|
401
|
-
9
|
|
402
|
-
/* Array */
|
|
403
|
-
);
|
|
404
|
-
const n = new O(e);
|
|
405
|
-
r(n);
|
|
406
|
-
const i = n.finish();
|
|
407
|
-
this.payload.writeBytes(i), this.valueWritten = !0;
|
|
408
|
-
}
|
|
409
|
-
writeValueDictionary(e, r, n) {
|
|
410
|
-
this.ensureValueType(
|
|
411
|
-
10
|
|
412
|
-
/* Dict */
|
|
413
|
-
);
|
|
414
|
-
const i = new M(e, r);
|
|
415
|
-
n(i);
|
|
416
|
-
const E = i.finish();
|
|
417
|
-
this.payload.writeBytes(E), this.valueWritten = !0;
|
|
418
|
-
}
|
|
419
|
-
complete() {
|
|
420
|
-
if (!this.completed) {
|
|
421
|
-
if (!this.keyWritten || !this.valueWritten)
|
|
422
|
-
throw new Error("Dictionary entry must write both key and value");
|
|
423
|
-
this.completed = !0, this.onComplete();
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
ensureKeyType(e) {
|
|
427
|
-
if (this.keyType !== e)
|
|
428
|
-
throw new Error(`Dictionary key type is ${y[this.keyType]}, expected ${y[e]}`);
|
|
429
|
-
}
|
|
430
|
-
ensureValueType(e) {
|
|
431
|
-
if (this.valueType !== e)
|
|
432
|
-
throw new Error(`Dictionary value type is ${y[this.valueType]}, expected ${y[e]}`);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
class _ {
|
|
436
|
-
constructor(e) {
|
|
437
|
-
this.bytes = e;
|
|
438
|
-
}
|
|
439
|
-
static fromString(e) {
|
|
440
|
-
if (!e)
|
|
441
|
-
throw new Error("Guid string is empty");
|
|
442
|
-
const r = e.replace(/-/g, "");
|
|
443
|
-
if (r.length !== 32)
|
|
444
|
-
throw new Error("Guid string must be 32 hex characters");
|
|
445
|
-
const n = new Uint8Array(16), i = _.parseHexSlice(r, 0, 8), E = _.parseHexSlice(r, 8, 4), N = _.parseHexSlice(r, 12, 4);
|
|
446
|
-
_.writeUInt32LE(n, 0, i), _.writeUInt16LE(n, 4, E), _.writeUInt16LE(n, 6, N);
|
|
447
|
-
for (let I = 0; I < 8; I++)
|
|
448
|
-
n[8 + I] = _.parseHexSlice(r, 16 + I * 2, 2);
|
|
449
|
-
return new _(n);
|
|
450
|
-
}
|
|
451
|
-
static fromBytes(e) {
|
|
452
|
-
if (e.length !== 16)
|
|
453
|
-
throw new Error("Guid byte array must be 16 bytes");
|
|
454
|
-
return new _(Uint8Array.from(e));
|
|
455
|
-
}
|
|
456
|
-
static createZero() {
|
|
457
|
-
return new _(new Uint8Array(16));
|
|
458
|
-
}
|
|
459
|
-
static createRandom() {
|
|
460
|
-
const e = new Uint8Array(16), r = globalThis.crypto;
|
|
461
|
-
if (r?.getRandomValues)
|
|
462
|
-
r.getRandomValues(e);
|
|
463
|
-
else
|
|
464
|
-
for (let n = 0; n < e.length; n++)
|
|
465
|
-
e[n] = Math.floor(Math.random() * 256);
|
|
466
|
-
return e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128, new _(e);
|
|
467
|
-
}
|
|
468
|
-
toString() {
|
|
469
|
-
const e = this.bytes;
|
|
470
|
-
return [
|
|
471
|
-
_.toHex(_.readUInt32LE(e, 0), 8),
|
|
472
|
-
_.toHex(_.readUInt16LE(e, 4), 4),
|
|
473
|
-
_.toHex(_.readUInt16LE(e, 6), 4),
|
|
474
|
-
m(e.subarray(8, 10)),
|
|
475
|
-
m(e.subarray(10, 16))
|
|
476
|
-
].join("-");
|
|
477
|
-
}
|
|
478
|
-
asBytes() {
|
|
479
|
-
return this.bytes.slice();
|
|
480
|
-
}
|
|
481
|
-
static parseHexSlice(e, r, n) {
|
|
482
|
-
const i = e.substr(r, n), E = Number.parseInt(i, 16);
|
|
483
|
-
if (Number.isNaN(E))
|
|
484
|
-
throw new Error("Guid string contains invalid characters");
|
|
485
|
-
return E >>> 0;
|
|
486
|
-
}
|
|
487
|
-
static writeUInt32LE(e, r, n) {
|
|
488
|
-
const i = n >>> 0;
|
|
489
|
-
e[r] = i & 255, e[r + 1] = i >>> 8 & 255, e[r + 2] = i >>> 16 & 255, e[r + 3] = i >>> 24 & 255;
|
|
490
|
-
}
|
|
491
|
-
static writeUInt16LE(e, r, n) {
|
|
492
|
-
const i = n & 65535;
|
|
493
|
-
e[r] = i & 255, e[r + 1] = i >>> 8 & 255;
|
|
494
|
-
}
|
|
495
|
-
static readUInt32LE(e, r) {
|
|
496
|
-
return (e[r] | e[r + 1] << 8 | e[r + 2] << 16 | e[r + 3] << 24) >>> 0;
|
|
497
|
-
}
|
|
498
|
-
static readUInt16LE(e, r) {
|
|
499
|
-
return (e[r] | e[r + 1] << 8) & 65535;
|
|
500
|
-
}
|
|
501
|
-
static toHex(e, r) {
|
|
502
|
-
return (e >>> 0).toString(16).padStart(r, "0");
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
class f {
|
|
506
|
-
bytes = [];
|
|
507
|
-
writeByte(e) {
|
|
508
|
-
this.bytes.push(e & 255);
|
|
509
|
-
}
|
|
510
|
-
writeBytes(e) {
|
|
511
|
-
for (let r = 0; r < e.length; r++)
|
|
512
|
-
this.bytes.push(e[r]);
|
|
513
|
-
}
|
|
514
|
-
writeUInt32(e) {
|
|
515
|
-
this.bytes.push(e & 255), this.bytes.push(e >>> 8 & 255), this.bytes.push(e >>> 16 & 255), this.bytes.push(e >>> 24 & 255);
|
|
516
|
-
}
|
|
517
|
-
writeInt32(e) {
|
|
518
|
-
this.writeUInt32(e | 0);
|
|
519
|
-
}
|
|
520
|
-
writeFloat32(e) {
|
|
521
|
-
const r = new DataView(new ArrayBuffer(4));
|
|
522
|
-
r.setFloat32(0, e, !0), this.writeBytes(new Uint8Array(r.buffer));
|
|
523
|
-
}
|
|
524
|
-
writeFloat64(e) {
|
|
525
|
-
const r = new DataView(new ArrayBuffer(8));
|
|
526
|
-
r.setFloat64(0, e, !0), this.writeBytes(new Uint8Array(r.buffer));
|
|
527
|
-
}
|
|
528
|
-
writeBigInt64(e) {
|
|
529
|
-
const r = new DataView(new ArrayBuffer(8));
|
|
530
|
-
r.setBigInt64(0, e, !0), this.writeBytes(new Uint8Array(r.buffer));
|
|
531
|
-
}
|
|
532
|
-
writeBigUInt64(e) {
|
|
533
|
-
const r = new DataView(new ArrayBuffer(8));
|
|
534
|
-
r.setBigUint64(0, e, !0), this.writeBytes(new Uint8Array(r.buffer));
|
|
535
|
-
}
|
|
536
|
-
writeVarUInt(e) {
|
|
537
|
-
let r = e >>> 0;
|
|
538
|
-
for (; r >= 128; )
|
|
539
|
-
this.bytes.push(r & 127 | 128), r >>>= 7;
|
|
540
|
-
this.bytes.push(r & 127);
|
|
541
|
-
}
|
|
542
|
-
toUint8Array() {
|
|
543
|
-
return Uint8Array.from(this.bytes);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
function P(t, e = 0) {
|
|
547
|
-
if ((e & 240) !== 0)
|
|
548
|
-
throw new Error("Teleport flags must fit into 4 bits");
|
|
549
|
-
return (t & 15) << 4 | e & 15;
|
|
550
|
-
}
|
|
551
|
-
function X(t) {
|
|
552
|
-
return t === 12 || t === 13 || t === 9 || t === 11 || t === 10;
|
|
553
|
-
}
|
|
554
|
-
function j(t) {
|
|
555
|
-
if (t === 9 || t === 11 || t === 10 || t === 1)
|
|
556
|
-
throw new Error("Dictionary keys must be primitive Teleport types");
|
|
557
|
-
}
|
|
558
|
-
function m(t) {
|
|
559
|
-
return Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
560
|
-
}
|
|
561
|
-
function z(t) {
|
|
562
|
-
return t instanceof Uint8Array ? t : new Uint8Array(t);
|
|
563
|
-
}
|
|
564
|
-
var C = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.H264 = 1] = "H264", t[t.Hevc = 2] = "Hevc", t[t.Vp8 = 3] = "Vp8", t))(C || {}), c = /* @__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))(c || {});
|
|
565
|
-
const g = 1, Q = 8388609, $ = 1368629611, J = 2950031986, q = 3284746250, Z = 4065070594;
|
|
566
|
-
function d(t) {
|
|
567
|
-
const e = {};
|
|
568
|
-
return p(e), t && Object.assign(e, t), e;
|
|
569
|
-
}
|
|
570
|
-
function p(t) {
|
|
571
|
-
return t.Description = "", t.Codec = C.H264, t.Width = 0, t.Height = 0, t;
|
|
572
|
-
}
|
|
573
|
-
function tt(t) {
|
|
574
|
-
const e = new l(g);
|
|
575
|
-
return et(t, e), e.finish();
|
|
576
|
-
}
|
|
577
|
-
function et(t, e) {
|
|
578
|
-
e.writeStringField($, t.Description), e.writeInt32Field(J, t.Height | 0), e.writeInt32Field(q, t.Codec), e.writeInt32Field(Z, t.Width | 0);
|
|
579
|
-
}
|
|
580
|
-
function rt(t, e, r) {
|
|
581
|
-
const n = tt(t);
|
|
582
|
-
return B(Q, n, g, e, r);
|
|
583
|
-
}
|
|
584
|
-
const b = 1, nt = 8388611, it = 271275304, Et = 2541432218, _t = 2986785889, It = 3105403172, st = 3456383222;
|
|
585
|
-
function at(t) {
|
|
586
|
-
const e = {};
|
|
587
|
-
return Tt(e), t && Object.assign(e, t), e;
|
|
588
|
-
}
|
|
589
|
-
function Tt(t) {
|
|
590
|
-
return t.Data = new Uint8Array(0), t.FrameNumber = 0, t.IsKey = !1, t.TimestampInUs = 0n, t.DurationInUs = 0, t;
|
|
591
|
-
}
|
|
592
|
-
function At(t) {
|
|
593
|
-
const e = new l(b);
|
|
594
|
-
return Nt(t, e), e.finish();
|
|
595
|
-
}
|
|
596
|
-
function Nt(t, e) {
|
|
597
|
-
e.writeUInt64Field(it, t.TimestampInUs), e.writeUInt32Field(Et, t.DurationInUs >>> 0), e.writeBinaryField(_t, t.Data), e.writeBoolField(It, t.IsKey), e.writeInt32Field(st, t.FrameNumber | 0);
|
|
598
|
-
}
|
|
599
|
-
function Ct(t, e, r) {
|
|
600
|
-
const n = At(t);
|
|
601
|
-
return B(nt, n, b, e, r);
|
|
602
|
-
}
|
|
603
|
-
const H = 1, Ut = 8388610;
|
|
604
|
-
function ut(t) {
|
|
605
|
-
const e = {};
|
|
606
|
-
return t && Object.assign(e, t), e;
|
|
607
|
-
}
|
|
608
|
-
function ht(t) {
|
|
609
|
-
return new l(H).finish();
|
|
610
|
-
}
|
|
611
|
-
function Rt(t, e, r) {
|
|
612
|
-
const n = ht();
|
|
613
|
-
return B(Ut, n, H, e, r);
|
|
614
|
-
}
|
|
615
|
-
const G = (t) => self.postMessage(t);
|
|
616
|
-
let U = null, R = null;
|
|
617
|
-
function L(t, e) {
|
|
618
|
-
const r = t instanceof Error ? t : new Error(String(t));
|
|
619
|
-
G({ type: "error", captureId: e, error: { name: r.name, message: r.message, stack: r.stack } });
|
|
620
|
-
}
|
|
621
|
-
function yt(t) {
|
|
622
|
-
if (!Array.isArray(t) || t.length === 0)
|
|
623
|
-
return ["h264", "vp8"];
|
|
624
|
-
const e = [];
|
|
625
|
-
for (const n of t)
|
|
626
|
-
(n === "h264" || n === "vp8" || n === "hevc") && e.push(n);
|
|
627
|
-
if (e.length === 0)
|
|
628
|
-
return ["h264", "vp8"];
|
|
629
|
-
const r = /* @__PURE__ */ new Set();
|
|
630
|
-
for (const n of e)
|
|
631
|
-
r.add(n);
|
|
632
|
-
return Array.from(r);
|
|
633
|
-
}
|
|
634
|
-
function lt(t) {
|
|
635
|
-
return t === "h264" ? C.H264 : t === "vp8" ? C.Vp8 : t === "hevc" ? C.Hevc : C.Unknown;
|
|
636
|
-
}
|
|
637
|
-
const St = {
|
|
638
|
-
[C.Unknown]: [],
|
|
639
|
-
[C.H264]: ["avc1.42001E", "avc1.42E01E", "avc1.4D401E", "avc1.64001F"],
|
|
640
|
-
[C.Vp8]: ["vp8"],
|
|
641
|
-
[C.Hevc]: ["hvc1.1.6.L93.B0"]
|
|
642
|
-
};
|
|
643
|
-
async function wt(t, e, r) {
|
|
644
|
-
const n = Math.max(1, Math.floor(r?.framerate ?? 10)), i = Math.max(5e4, Math.floor(r?.bitrate ?? (t > 1e3 ? 2e6 : 1e6))), E = yt(r?.preferredCodecs);
|
|
645
|
-
for (const N of E) {
|
|
646
|
-
const I = lt(N), s = St[I] ?? [];
|
|
647
|
-
for (const a of s) {
|
|
648
|
-
const T = {
|
|
649
|
-
codec: a,
|
|
650
|
-
width: t,
|
|
651
|
-
height: e,
|
|
652
|
-
bitrate: i,
|
|
653
|
-
framerate: n,
|
|
654
|
-
hardwareAcceleration: "prefer-hardware",
|
|
655
|
-
latencyMode: "realtime"
|
|
656
|
-
};
|
|
657
|
-
try {
|
|
658
|
-
if (typeof VideoEncoder?.isConfigSupported == "function" && !(await VideoEncoder.isConfigSupported(T)).supported)
|
|
659
|
-
continue;
|
|
660
|
-
return { codec: I, config: T };
|
|
661
|
-
} catch {
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
throw new Error("No supported video encoder configuration");
|
|
666
|
-
}
|
|
667
|
-
function ot(t) {
|
|
668
|
-
return t.byteOffset === 0 && t.byteLength === t.buffer.byteLength ? t.buffer : t.slice().buffer;
|
|
669
|
-
}
|
|
670
|
-
function V(t) {
|
|
671
|
-
if (!U)
|
|
672
|
-
return;
|
|
673
|
-
const e = ot(t);
|
|
674
|
-
U.postMessage({ type: "send", message: e }, [e]);
|
|
675
|
-
}
|
|
676
|
-
const u = /* @__PURE__ */ new Map(), F = /* @__PURE__ */ new Map();
|
|
677
|
-
function ft(t) {
|
|
678
|
-
try {
|
|
679
|
-
t.encoder.close();
|
|
680
|
-
} catch {
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
async function Lt(t) {
|
|
684
|
-
if (!U)
|
|
685
|
-
throw new Error("Video capture worker missing send port");
|
|
686
|
-
if (u.get(t.captureId))
|
|
687
|
-
return;
|
|
688
|
-
const r = Math.max(1, Math.floor(t.width)), n = Math.max(1, Math.floor(t.height)), i = await wt(r, n, t.options), E = Math.max(1, Math.floor(t.options?.framerate ?? 10)), N = Math.max(1, Math.floor(t.options?.keyFrameIntervalFrames ?? E * 3)), I = new VideoEncoder({
|
|
689
|
-
output: (a) => {
|
|
690
|
-
const T = u.get(t.captureId);
|
|
691
|
-
if (!T || T.stopped)
|
|
692
|
-
return;
|
|
693
|
-
const h = new Uint8Array(a.byteLength);
|
|
694
|
-
a.copyTo(h);
|
|
695
|
-
const S = at({
|
|
696
|
-
Data: h,
|
|
697
|
-
FrameNumber: T.frameCounter,
|
|
698
|
-
IsKey: a.type === "key",
|
|
699
|
-
TimestampInUs: BigInt(Math.max(0, Math.round(a.timestamp ?? 0))),
|
|
700
|
-
DurationInUs: Math.max(0, Math.round(a.duration ?? 0))
|
|
701
|
-
});
|
|
702
|
-
V(Ct(S, T.senderId, { trackId: T.trackId }));
|
|
703
|
-
},
|
|
704
|
-
error: (a) => {
|
|
705
|
-
L(a, t.captureId);
|
|
706
|
-
}
|
|
707
|
-
});
|
|
708
|
-
I.configure(i.config);
|
|
709
|
-
const s = {
|
|
710
|
-
captureId: t.captureId,
|
|
711
|
-
kind: t.kind,
|
|
712
|
-
senderId: t.senderId,
|
|
713
|
-
trackId: t.trackId,
|
|
714
|
-
width: r,
|
|
715
|
-
height: n,
|
|
716
|
-
codec: i.codec,
|
|
717
|
-
encoder: I,
|
|
718
|
-
encoderConfig: i.config,
|
|
719
|
-
frameCounter: 0,
|
|
720
|
-
keyFrameIntervalFrames: N,
|
|
721
|
-
forceKeyframe: !0,
|
|
722
|
-
stopped: !1
|
|
723
|
-
};
|
|
724
|
-
u.set(t.captureId, s), F.set(t.trackId, t.captureId), V(
|
|
725
|
-
rt(
|
|
726
|
-
d({
|
|
727
|
-
Description: `${t.kind}:${t.captureId}`,
|
|
728
|
-
Codec: s.codec,
|
|
729
|
-
Width: r,
|
|
730
|
-
Height: n
|
|
731
|
-
}),
|
|
732
|
-
t.senderId,
|
|
733
|
-
{ trackId: t.trackId }
|
|
734
|
-
)
|
|
735
|
-
), G({ type: "started", captureId: t.captureId, codec: s.codec, width: r, height: n });
|
|
736
|
-
}
|
|
737
|
-
async function K(t) {
|
|
738
|
-
const e = u.get(t);
|
|
739
|
-
if (e) {
|
|
740
|
-
e.stopped = !0, u.delete(t), F.delete(e.trackId);
|
|
741
|
-
try {
|
|
742
|
-
await e.encoder.flush();
|
|
743
|
-
} catch {
|
|
744
|
-
}
|
|
745
|
-
ft(e), V(Rt(ut({}), e.senderId, { trackId: e.trackId })), G({ type: "stopped", captureId: t });
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
function Dt(t) {
|
|
749
|
-
const e = new Uint8Array(t);
|
|
750
|
-
if (k(e) !== c.VIDEO_REQUEST_IDR_FRAME)
|
|
751
|
-
return;
|
|
752
|
-
const n = v(e), i = F.get(n.trackId);
|
|
753
|
-
if (!i)
|
|
754
|
-
return;
|
|
755
|
-
const E = u.get(i);
|
|
756
|
-
E && (E.forceKeyframe = !0);
|
|
757
|
-
}
|
|
758
|
-
function Pt() {
|
|
759
|
-
for (const t of u.keys())
|
|
760
|
-
K(t);
|
|
761
|
-
if (u.clear(), F.clear(), R) {
|
|
762
|
-
try {
|
|
763
|
-
R.close();
|
|
764
|
-
} catch {
|
|
765
|
-
}
|
|
766
|
-
R = null;
|
|
767
|
-
}
|
|
768
|
-
if (U) {
|
|
769
|
-
try {
|
|
770
|
-
U.close();
|
|
771
|
-
} catch {
|
|
772
|
-
}
|
|
773
|
-
U = null;
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
self.addEventListener("message", (t) => {
|
|
777
|
-
const e = t.data;
|
|
778
|
-
if (e.type === "attachSendPort") {
|
|
779
|
-
if (U)
|
|
780
|
-
try {
|
|
781
|
-
U.close();
|
|
782
|
-
} catch {
|
|
783
|
-
}
|
|
784
|
-
U = e.port;
|
|
785
|
-
try {
|
|
786
|
-
U.start?.();
|
|
787
|
-
} catch {
|
|
788
|
-
}
|
|
789
|
-
return;
|
|
790
|
-
}
|
|
791
|
-
if (e.type === "attachProtocolPort") {
|
|
792
|
-
if (R)
|
|
793
|
-
try {
|
|
794
|
-
R.close();
|
|
795
|
-
} catch {
|
|
796
|
-
}
|
|
797
|
-
R = e.port;
|
|
798
|
-
try {
|
|
799
|
-
R.start?.();
|
|
800
|
-
} catch {
|
|
801
|
-
}
|
|
802
|
-
R.addEventListener("message", (r) => {
|
|
803
|
-
const n = r.data;
|
|
804
|
-
n?.type === "protocol" && n.message instanceof ArrayBuffer && Dt(n.message);
|
|
805
|
-
});
|
|
806
|
-
return;
|
|
807
|
-
}
|
|
808
|
-
if (e.type === "start") {
|
|
809
|
-
Lt(e).catch((r) => L(r, e.captureId));
|
|
810
|
-
return;
|
|
811
|
-
}
|
|
812
|
-
if (e.type === "frame") {
|
|
813
|
-
const r = u.get(e.captureId);
|
|
814
|
-
try {
|
|
815
|
-
if (!r || r.stopped) {
|
|
816
|
-
e.frame.close();
|
|
817
|
-
return;
|
|
818
|
-
}
|
|
819
|
-
if (r.encoder.encodeQueueSize > 4) {
|
|
820
|
-
e.frame.close();
|
|
821
|
-
return;
|
|
822
|
-
}
|
|
823
|
-
r.frameCounter = e.frameNumber;
|
|
824
|
-
const n = r.forceKeyframe || r.frameCounter > 0 && r.frameCounter % r.keyFrameIntervalFrames === 0;
|
|
825
|
-
r.forceKeyframe = !1, r.encoder.encode(e.frame, { keyFrame: n });
|
|
826
|
-
} catch (n) {
|
|
827
|
-
L(n, e.captureId);
|
|
828
|
-
const i = u.get(e.captureId);
|
|
829
|
-
i && (i.forceKeyframe = !0);
|
|
830
|
-
} finally {
|
|
831
|
-
try {
|
|
832
|
-
e.frame.close();
|
|
833
|
-
} catch {
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
return;
|
|
837
|
-
}
|
|
838
|
-
if (e.type === "stop") {
|
|
839
|
-
K(e.captureId).catch((r) => L(r, e.captureId));
|
|
840
|
-
return;
|
|
841
|
-
}
|
|
842
|
-
e.type === "dispose" && Pt();
|
|
843
|
-
});
|