@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
|
@@ -0,0 +1,963 @@
|
|
|
1
|
+
function J(t) {
|
|
2
|
+
if (t.length < 8)
|
|
3
|
+
throw new Error("Protocol message too short");
|
|
4
|
+
return (t[4] | t[5] << 8 | t[6] << 16 | t[7] << 24) >>> 0;
|
|
5
|
+
}
|
|
6
|
+
function Z(t) {
|
|
7
|
+
const e = nt(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 i = r.getUint32(0, !0), n = r.getUint32(4, !0), E = r.getUint32(8, !0), I = r.getUint32(12, !0), s = r.getUint32(16, !0), a = r.getUint32(20, !0), C = r.getUint8(24), N = r.getUint8(25), U = r.getUint8(26);
|
|
11
|
+
if (27 + a * 4 > e.length)
|
|
12
|
+
throw new Error("Protocol header exceeds payload length");
|
|
13
|
+
const T = [];
|
|
14
|
+
let R = 27;
|
|
15
|
+
for (let h = 0; h < a; h++)
|
|
16
|
+
T.push(r.getUint32(R, !0)), R += 4;
|
|
17
|
+
return {
|
|
18
|
+
length: i,
|
|
19
|
+
opcode: n,
|
|
20
|
+
senderId: E,
|
|
21
|
+
trackId: I,
|
|
22
|
+
sequenceId: s,
|
|
23
|
+
targetIds: T,
|
|
24
|
+
payloadVersion: C,
|
|
25
|
+
payloadType: N,
|
|
26
|
+
flags: U
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function b(t, e, r, i, n) {
|
|
30
|
+
const E = n?.trackId ?? 0, I = n?.sequenceId ?? 0, s = n?.flags ?? 0, a = n?.targetIds ?? [], C = n?.payloadType ?? 8, N = 27 + a.length * 4, U = N + e.length, u = new Uint8Array(U), T = new DataView(u.buffer);
|
|
31
|
+
T.setUint32(0, U, !0), T.setUint32(4, t >>> 0, !0), T.setUint32(8, i >>> 0, !0), T.setUint32(12, E >>> 0, !0), T.setUint32(16, I >>> 0, !0), T.setUint32(20, a.length >>> 0, !0), T.setUint8(24, r & 255), T.setUint8(25, C & 255), T.setUint8(26, s & 255);
|
|
32
|
+
let R = 27;
|
|
33
|
+
for (let h = 0; h < a.length; h++)
|
|
34
|
+
T.setUint32(R, a[h] >>> 0, !0), R += 4;
|
|
35
|
+
return u.set(e, N), u;
|
|
36
|
+
}
|
|
37
|
+
var w = /* @__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))(w || {});
|
|
38
|
+
const p = 161, tt = 162, F = new TextEncoder();
|
|
39
|
+
new TextDecoder("utf-8", { fatal: !0 });
|
|
40
|
+
class L {
|
|
41
|
+
constructor(e = 1) {
|
|
42
|
+
this.version = e, this.buffer.writeByte(p), this.buffer.writeVarUInt(e >>> 0);
|
|
43
|
+
}
|
|
44
|
+
buffer = new y();
|
|
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 i = r instanceof _ ? r.asBytes() : r;
|
|
70
|
+
if (i.length !== 16)
|
|
71
|
+
throw new Error("Guid payload must be 16 bytes");
|
|
72
|
+
this.writeFixedField(e, 14, () => this.buffer.writeBytes(i));
|
|
73
|
+
}
|
|
74
|
+
writeStringField(e, r) {
|
|
75
|
+
const i = F.encode(r ?? "");
|
|
76
|
+
this.writeVariableField(e, 12, i);
|
|
77
|
+
}
|
|
78
|
+
writeBinaryField(e, r) {
|
|
79
|
+
this.writeVariableField(e, 13, r);
|
|
80
|
+
}
|
|
81
|
+
writeObjectField(e, r, i) {
|
|
82
|
+
const n = new L(r);
|
|
83
|
+
i(n);
|
|
84
|
+
const E = n.finish();
|
|
85
|
+
this.writeVariableField(e, 11, E);
|
|
86
|
+
}
|
|
87
|
+
writeArrayField(e, r, i) {
|
|
88
|
+
const n = new B(r);
|
|
89
|
+
i(n);
|
|
90
|
+
const E = n.finish();
|
|
91
|
+
this.writeVariableField(e, 9, E);
|
|
92
|
+
}
|
|
93
|
+
writeDictionaryField(e, r, i, n) {
|
|
94
|
+
const E = new H(r, i);
|
|
95
|
+
n(E);
|
|
96
|
+
const I = E.finish();
|
|
97
|
+
this.writeVariableField(e, 10, I);
|
|
98
|
+
}
|
|
99
|
+
finish() {
|
|
100
|
+
return this.closed || (this.buffer.writeByte(tt), this.closed = !0, this.cached = this.buffer.toUint8Array()), this.cached;
|
|
101
|
+
}
|
|
102
|
+
writeFixedField(e, r, i) {
|
|
103
|
+
this.writeFieldHeader(e, r, 0), i();
|
|
104
|
+
}
|
|
105
|
+
writeVariableField(e, r, i) {
|
|
106
|
+
this.writeFieldHeader(e, r, i.length), this.buffer.writeBytes(i);
|
|
107
|
+
}
|
|
108
|
+
writeFieldHeader(e, r, i) {
|
|
109
|
+
this.buffer.writeUInt32(e >>> 0), this.buffer.writeByte(V(r)), rt(r) && this.buffer.writeVarUInt(i >>> 0);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
class B {
|
|
113
|
+
constructor(e) {
|
|
114
|
+
this.elementType = e;
|
|
115
|
+
}
|
|
116
|
+
payload = new y();
|
|
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 = F.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 i = new L(e);
|
|
190
|
+
r(i);
|
|
191
|
+
const n = i.finish();
|
|
192
|
+
this.payload.writeVarUInt(n.length), this.payload.writeBytes(n);
|
|
193
|
+
}
|
|
194
|
+
writeArray(e, r) {
|
|
195
|
+
this.ensureElementType(
|
|
196
|
+
9
|
|
197
|
+
/* Array */
|
|
198
|
+
), this.count++;
|
|
199
|
+
const i = new B(e);
|
|
200
|
+
r(i);
|
|
201
|
+
const n = i.finish();
|
|
202
|
+
this.payload.writeBytes(n);
|
|
203
|
+
}
|
|
204
|
+
writeDictionary(e, r, i) {
|
|
205
|
+
this.ensureElementType(
|
|
206
|
+
10
|
|
207
|
+
/* Dict */
|
|
208
|
+
), this.count++;
|
|
209
|
+
const n = new H(e, r);
|
|
210
|
+
i(n);
|
|
211
|
+
const E = n.finish();
|
|
212
|
+
this.payload.writeBytes(E);
|
|
213
|
+
}
|
|
214
|
+
finish() {
|
|
215
|
+
const e = new y();
|
|
216
|
+
return e.writeByte(V(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 ${w[this.elementType]}, expected ${w[e]}`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
class H {
|
|
224
|
+
constructor(e, r) {
|
|
225
|
+
this.keyType = e, this.valueType = r, it(e);
|
|
226
|
+
}
|
|
227
|
+
payload = new y();
|
|
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 et(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 y();
|
|
241
|
+
return e.writeByte(V(this.keyType)), e.writeByte(V(this.valueType)), e.writeVarUInt(this.count), e.writeBytes(this.payload.toUint8Array()), e.toUint8Array();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
class et {
|
|
245
|
+
constructor(e, r, i, n) {
|
|
246
|
+
this.keyType = e, this.valueType = r, this.payload = i, this.onComplete = n;
|
|
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 = F.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 = F.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 i = new L(e);
|
|
395
|
+
r(i);
|
|
396
|
+
const n = i.finish();
|
|
397
|
+
this.payload.writeVarUInt(n.length), this.payload.writeBytes(n), this.valueWritten = !0;
|
|
398
|
+
}
|
|
399
|
+
writeValueArray(e, r) {
|
|
400
|
+
this.ensureValueType(
|
|
401
|
+
9
|
|
402
|
+
/* Array */
|
|
403
|
+
);
|
|
404
|
+
const i = new B(e);
|
|
405
|
+
r(i);
|
|
406
|
+
const n = i.finish();
|
|
407
|
+
this.payload.writeBytes(n), this.valueWritten = !0;
|
|
408
|
+
}
|
|
409
|
+
writeValueDictionary(e, r, i) {
|
|
410
|
+
this.ensureValueType(
|
|
411
|
+
10
|
|
412
|
+
/* Dict */
|
|
413
|
+
);
|
|
414
|
+
const n = new H(e, r);
|
|
415
|
+
i(n);
|
|
416
|
+
const E = n.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 ${w[this.keyType]}, expected ${w[e]}`);
|
|
429
|
+
}
|
|
430
|
+
ensureValueType(e) {
|
|
431
|
+
if (this.valueType !== e)
|
|
432
|
+
throw new Error(`Dictionary value type is ${w[this.valueType]}, expected ${w[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 i = new Uint8Array(16), n = _.parseHexSlice(r, 0, 8), E = _.parseHexSlice(r, 8, 4), I = _.parseHexSlice(r, 12, 4);
|
|
446
|
+
_.writeUInt32LE(i, 0, n), _.writeUInt16LE(i, 4, E), _.writeUInt16LE(i, 6, I);
|
|
447
|
+
for (let s = 0; s < 8; s++)
|
|
448
|
+
i[8 + s] = _.parseHexSlice(r, 16 + s * 2, 2);
|
|
449
|
+
return new _(i);
|
|
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 i = 0; i < e.length; i++)
|
|
465
|
+
e[i] = 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
|
+
d(e.subarray(8, 10)),
|
|
475
|
+
d(e.subarray(10, 16))
|
|
476
|
+
].join("-");
|
|
477
|
+
}
|
|
478
|
+
asBytes() {
|
|
479
|
+
return this.bytes.slice();
|
|
480
|
+
}
|
|
481
|
+
static parseHexSlice(e, r, i) {
|
|
482
|
+
const n = e.substr(r, i), E = Number.parseInt(n, 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, i) {
|
|
488
|
+
const n = i >>> 0;
|
|
489
|
+
e[r] = n & 255, e[r + 1] = n >>> 8 & 255, e[r + 2] = n >>> 16 & 255, e[r + 3] = n >>> 24 & 255;
|
|
490
|
+
}
|
|
491
|
+
static writeUInt16LE(e, r, i) {
|
|
492
|
+
const n = i & 65535;
|
|
493
|
+
e[r] = n & 255, e[r + 1] = n >>> 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 y {
|
|
506
|
+
static INITIAL_CAPACITY = 256;
|
|
507
|
+
buffer;
|
|
508
|
+
dataView;
|
|
509
|
+
length = 0;
|
|
510
|
+
constructor() {
|
|
511
|
+
this.buffer = new Uint8Array(y.INITIAL_CAPACITY), this.dataView = new DataView(this.buffer.buffer);
|
|
512
|
+
}
|
|
513
|
+
ensureCapacity(e) {
|
|
514
|
+
const r = this.length + e;
|
|
515
|
+
if (r <= this.buffer.length)
|
|
516
|
+
return;
|
|
517
|
+
let i = this.buffer.length;
|
|
518
|
+
for (; i < r; )
|
|
519
|
+
i *= 2;
|
|
520
|
+
const n = new Uint8Array(i);
|
|
521
|
+
n.set(this.buffer.subarray(0, this.length)), this.buffer = n, this.dataView = new DataView(this.buffer.buffer);
|
|
522
|
+
}
|
|
523
|
+
writeByte(e) {
|
|
524
|
+
this.ensureCapacity(1), this.buffer[this.length++] = e & 255;
|
|
525
|
+
}
|
|
526
|
+
writeBytes(e) {
|
|
527
|
+
this.ensureCapacity(e.length), this.buffer.set(e, this.length), this.length += e.length;
|
|
528
|
+
}
|
|
529
|
+
writeUInt32(e) {
|
|
530
|
+
this.ensureCapacity(4), this.dataView.setUint32(this.length, e >>> 0, !0), this.length += 4;
|
|
531
|
+
}
|
|
532
|
+
writeInt32(e) {
|
|
533
|
+
this.ensureCapacity(4), this.dataView.setInt32(this.length, e | 0, !0), this.length += 4;
|
|
534
|
+
}
|
|
535
|
+
writeFloat32(e) {
|
|
536
|
+
this.ensureCapacity(4), this.dataView.setFloat32(this.length, e, !0), this.length += 4;
|
|
537
|
+
}
|
|
538
|
+
writeFloat64(e) {
|
|
539
|
+
this.ensureCapacity(8), this.dataView.setFloat64(this.length, e, !0), this.length += 8;
|
|
540
|
+
}
|
|
541
|
+
writeBigInt64(e) {
|
|
542
|
+
this.ensureCapacity(8), this.dataView.setBigInt64(this.length, e, !0), this.length += 8;
|
|
543
|
+
}
|
|
544
|
+
writeBigUInt64(e) {
|
|
545
|
+
this.ensureCapacity(8), this.dataView.setBigUint64(this.length, e, !0), this.length += 8;
|
|
546
|
+
}
|
|
547
|
+
writeVarUInt(e) {
|
|
548
|
+
let r = e >>> 0;
|
|
549
|
+
for (; r >= 128; )
|
|
550
|
+
this.ensureCapacity(1), this.buffer[this.length++] = r & 127 | 128, r >>>= 7;
|
|
551
|
+
this.ensureCapacity(1), this.buffer[this.length++] = r & 127;
|
|
552
|
+
}
|
|
553
|
+
toUint8Array() {
|
|
554
|
+
return this.buffer.slice(0, this.length);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
function V(t, e = 0) {
|
|
558
|
+
if ((e & 240) !== 0)
|
|
559
|
+
throw new Error("Teleport flags must fit into 4 bits");
|
|
560
|
+
return (t & 15) << 4 | e & 15;
|
|
561
|
+
}
|
|
562
|
+
function rt(t) {
|
|
563
|
+
return t === 12 || t === 13 || t === 9 || t === 11 || t === 10;
|
|
564
|
+
}
|
|
565
|
+
function it(t) {
|
|
566
|
+
if (t === 9 || t === 11 || t === 10 || t === 1)
|
|
567
|
+
throw new Error("Dictionary keys must be primitive Teleport types");
|
|
568
|
+
}
|
|
569
|
+
function d(t) {
|
|
570
|
+
return Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
571
|
+
}
|
|
572
|
+
function nt(t) {
|
|
573
|
+
return t instanceof Uint8Array ? t : new Uint8Array(t);
|
|
574
|
+
}
|
|
575
|
+
var A = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.H264 = 1] = "H264", t[t.Vp8 = 2] = "Vp8", t[t.Vp9 = 3] = "Vp9", t[t.Av1 = 4] = "Av1", t))(A || {}), v = /* @__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.ACTION_TRIGGER_GIT_PULL = 1048639] = "ACTION_TRIGGER_GIT_PULL", 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.UI_STYLES_DELETE = 2097193] = "UI_STYLES_DELETE", 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))(v || {});
|
|
576
|
+
const k = 1, Et = 8388609, _t = 164808083, at = 1368629611, It = 2739413426, st = 2768375929, Tt = 2950031986, At = 3284746250, Nt = 4065070594;
|
|
577
|
+
function ht(t) {
|
|
578
|
+
const e = {};
|
|
579
|
+
return Ct(e), t && Object.assign(e, t), e;
|
|
580
|
+
}
|
|
581
|
+
function Ct(t) {
|
|
582
|
+
return t.Description = "", t.Codec = A.H264, t.Width = 0, t.Height = 0, t.Framerate = 30, t.Bitrate = 0, t.IsHardwareAccelerated = !1, t;
|
|
583
|
+
}
|
|
584
|
+
function ut(t) {
|
|
585
|
+
const e = new L(k);
|
|
586
|
+
return lt(t, e), e.finish();
|
|
587
|
+
}
|
|
588
|
+
function lt(t, e) {
|
|
589
|
+
e.writeInt32Field(_t, t.Framerate | 0), e.writeStringField(at, t.Description), e.writeBoolField(It, t.IsHardwareAccelerated), e.writeInt32Field(st, t.Bitrate | 0), e.writeInt32Field(Tt, t.Height | 0), e.writeInt32Field(At, t.Codec), e.writeInt32Field(Nt, t.Width | 0);
|
|
590
|
+
}
|
|
591
|
+
function Ut(t, e, r) {
|
|
592
|
+
const i = ut(t);
|
|
593
|
+
return b(Et, i, k, e, r);
|
|
594
|
+
}
|
|
595
|
+
const W = 1, Rt = 8388611, ot = 271275304, ft = 2541432218, St = 2986785889, wt = 3105403172, yt = 3456383222;
|
|
596
|
+
function Lt(t) {
|
|
597
|
+
const e = {};
|
|
598
|
+
return Dt(e), t && Object.assign(e, t), e;
|
|
599
|
+
}
|
|
600
|
+
function Dt(t) {
|
|
601
|
+
return t.Data = new Uint8Array(0), t.FrameNumber = 0, t.IsKey = !1, t.TimestampInUs = 0n, t.DurationInUs = 0, t;
|
|
602
|
+
}
|
|
603
|
+
function ct(t) {
|
|
604
|
+
const e = new L(W);
|
|
605
|
+
return Pt(t, e), e.finish();
|
|
606
|
+
}
|
|
607
|
+
function Pt(t, e) {
|
|
608
|
+
e.writeUInt64Field(ot, t.TimestampInUs), e.writeUInt32Field(ft, t.DurationInUs >>> 0), e.writeBinaryField(St, t.Data), e.writeBoolField(wt, t.IsKey), e.writeInt32Field(yt, t.FrameNumber | 0);
|
|
609
|
+
}
|
|
610
|
+
function Ot(t, e, r) {
|
|
611
|
+
const i = ct(t);
|
|
612
|
+
return b(Rt, i, W, e, r);
|
|
613
|
+
}
|
|
614
|
+
const Y = 1, Ft = 8388610;
|
|
615
|
+
function Vt(t) {
|
|
616
|
+
const e = {};
|
|
617
|
+
return t && Object.assign(e, t), e;
|
|
618
|
+
}
|
|
619
|
+
function gt(t) {
|
|
620
|
+
return new L(Y).finish();
|
|
621
|
+
}
|
|
622
|
+
function Bt(t, e, r) {
|
|
623
|
+
const i = gt();
|
|
624
|
+
return b(Ft, i, Y, e, r);
|
|
625
|
+
}
|
|
626
|
+
const x = 30, Mt = 30 * 3, X = [
|
|
627
|
+
"avc1.42001f",
|
|
628
|
+
// Baseline L3.1 (720p60, 1080p30)
|
|
629
|
+
"avc1.4d001f",
|
|
630
|
+
// Main L3.1
|
|
631
|
+
"avc1.42001e",
|
|
632
|
+
// Baseline L3.0 (720p30)
|
|
633
|
+
"avc1.4d001e",
|
|
634
|
+
// Main L3.0
|
|
635
|
+
"avc1.640028",
|
|
636
|
+
// High L4.0 (1080p)
|
|
637
|
+
"avc1.4d0028"
|
|
638
|
+
// Main L4.0 (1080p)
|
|
639
|
+
];
|
|
640
|
+
X[0];
|
|
641
|
+
const Gt = "vp8", $ = [
|
|
642
|
+
"vp09.00.10.08",
|
|
643
|
+
// Profile 0, Level 1.0, 8-bit (most compatible)
|
|
644
|
+
"vp09.00.20.08",
|
|
645
|
+
// Profile 0, Level 2.0, 8-bit
|
|
646
|
+
"vp09.00.30.08",
|
|
647
|
+
// Profile 0, Level 3.0, 8-bit (720p)
|
|
648
|
+
"vp09.00.40.08"
|
|
649
|
+
// Profile 0, Level 4.0, 8-bit (1080p)
|
|
650
|
+
];
|
|
651
|
+
$[0];
|
|
652
|
+
const j = [
|
|
653
|
+
"av01.0.04M.08",
|
|
654
|
+
// Main profile, Level 3.0, 8-bit (720p)
|
|
655
|
+
"av01.0.05M.08",
|
|
656
|
+
// Main profile, Level 3.1, 8-bit
|
|
657
|
+
"av01.0.08M.08",
|
|
658
|
+
// Main profile, Level 4.0, 8-bit (1080p)
|
|
659
|
+
"av01.0.01M.08"
|
|
660
|
+
// Main profile, Level 2.0, 8-bit (lower res fallback)
|
|
661
|
+
];
|
|
662
|
+
j[0];
|
|
663
|
+
const K = ["h264", "vp8", "vp9", "av1"], mt = [
|
|
664
|
+
{ width: 1920, height: 1080 },
|
|
665
|
+
// 1080p
|
|
666
|
+
{ width: 1280, height: 720 },
|
|
667
|
+
// 720p
|
|
668
|
+
{ width: 960, height: 540 },
|
|
669
|
+
// 540p (qHD)
|
|
670
|
+
{ width: 640, height: 480 },
|
|
671
|
+
// 480p (VGA)
|
|
672
|
+
{ width: 640, height: 360 }
|
|
673
|
+
// 360p
|
|
674
|
+
], bt = 0.1, Ht = 30, dt = 5e4, Kt = 5e5, vt = 8e6, kt = 8, Wt = 3, g = (t) => self.postMessage(t);
|
|
675
|
+
let l = null, o = null;
|
|
676
|
+
function P(t, e) {
|
|
677
|
+
const r = t instanceof Error ? t : new Error(String(t));
|
|
678
|
+
g({ type: "error", captureId: e, error: { name: r.name, message: r.message, stack: r.stack } });
|
|
679
|
+
}
|
|
680
|
+
function Yt(t) {
|
|
681
|
+
if (!Array.isArray(t) || t.length === 0)
|
|
682
|
+
return K.slice();
|
|
683
|
+
const e = [];
|
|
684
|
+
for (const i of t)
|
|
685
|
+
(i === "h264" || i === "vp8" || i === "vp9" || i === "av1") && e.push(i);
|
|
686
|
+
if (e.length === 0)
|
|
687
|
+
return K.slice();
|
|
688
|
+
const r = /* @__PURE__ */ new Set();
|
|
689
|
+
for (const i of e)
|
|
690
|
+
r.add(i);
|
|
691
|
+
return Array.from(r);
|
|
692
|
+
}
|
|
693
|
+
function xt(t) {
|
|
694
|
+
return t === "h264" ? A.H264 : t === "vp8" ? A.Vp8 : t === "vp9" ? A.Vp9 : t === "av1" ? A.Av1 : A.Unknown;
|
|
695
|
+
}
|
|
696
|
+
const Xt = {
|
|
697
|
+
[A.Unknown]: [],
|
|
698
|
+
[A.H264]: X,
|
|
699
|
+
[A.Vp8]: [Gt],
|
|
700
|
+
[A.Vp9]: $,
|
|
701
|
+
[A.Av1]: j
|
|
702
|
+
};
|
|
703
|
+
function $t(t, e, r, i) {
|
|
704
|
+
const n = t * e, E = bt * (r / Ht), I = Math.floor(n * E);
|
|
705
|
+
return Math.max(dt, Math.floor(i ?? Math.max(Kt, Math.min(I, vt))));
|
|
706
|
+
}
|
|
707
|
+
function jt(t, e) {
|
|
708
|
+
const r = [{ width: t, height: e }];
|
|
709
|
+
for (const i of mt)
|
|
710
|
+
(i.width < t || i.height < e) && (r.some((n) => n.width === i.width && n.height === i.height) || r.push(i));
|
|
711
|
+
return r;
|
|
712
|
+
}
|
|
713
|
+
async function Qt(t, e, r, i, n, E, I) {
|
|
714
|
+
const s = {
|
|
715
|
+
codec: e,
|
|
716
|
+
width: r,
|
|
717
|
+
height: i,
|
|
718
|
+
bitrate: n,
|
|
719
|
+
framerate: E,
|
|
720
|
+
latencyMode: "realtime",
|
|
721
|
+
...t === A.H264 ? { avc: { format: "annexb" } } : {}
|
|
722
|
+
};
|
|
723
|
+
if (typeof VideoEncoder?.isConfigSupported != "function")
|
|
724
|
+
return null;
|
|
725
|
+
if (I) {
|
|
726
|
+
const a = { ...s, hardwareAcceleration: I };
|
|
727
|
+
try {
|
|
728
|
+
const C = await VideoEncoder.isConfigSupported(a);
|
|
729
|
+
if (C.supported) {
|
|
730
|
+
const N = C.config ?? a;
|
|
731
|
+
return { config: N, isHardwareAccelerated: N.hardwareAcceleration === "prefer-hardware" };
|
|
732
|
+
}
|
|
733
|
+
} catch {
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
try {
|
|
737
|
+
const a = await VideoEncoder.isConfigSupported(s);
|
|
738
|
+
if (a.supported)
|
|
739
|
+
return { config: a.config ?? s, isHardwareAccelerated: !1 };
|
|
740
|
+
} catch {
|
|
741
|
+
}
|
|
742
|
+
return null;
|
|
743
|
+
}
|
|
744
|
+
async function qt(t, e, r) {
|
|
745
|
+
const i = Math.max(1, Math.floor(r?.framerate ?? x)), n = Yt(r?.preferredCodecs), I = r?.hardwareAcceleration === "preferSoftware" ? ["prefer-software", "prefer-hardware", void 0] : ["prefer-hardware", "prefer-software", void 0], s = jt(t, e);
|
|
746
|
+
for (const a of s) {
|
|
747
|
+
const C = $t(a.width, a.height, i, r?.bitrate);
|
|
748
|
+
for (const N of I)
|
|
749
|
+
for (const U of n) {
|
|
750
|
+
const u = xt(U), T = Xt[u] ?? [];
|
|
751
|
+
for (const R of T) {
|
|
752
|
+
const h = await Qt(u, R, a.width, a.height, C, i, N);
|
|
753
|
+
if (h)
|
|
754
|
+
return { codec: u, config: h.config, isHardwareAccelerated: h.isHardwareAccelerated };
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
throw new Error("No supported video encoder configuration");
|
|
759
|
+
}
|
|
760
|
+
function zt(t) {
|
|
761
|
+
return t.byteOffset === 0 && t.byteLength === t.buffer.byteLength ? t.buffer : t.slice().buffer;
|
|
762
|
+
}
|
|
763
|
+
function m(t) {
|
|
764
|
+
if (!l)
|
|
765
|
+
return;
|
|
766
|
+
const e = zt(t);
|
|
767
|
+
l.postMessage({ type: "send", message: e }, [e]);
|
|
768
|
+
}
|
|
769
|
+
const f = /* @__PURE__ */ new Map(), M = /* @__PURE__ */ new Map(), D = [];
|
|
770
|
+
function Jt(t) {
|
|
771
|
+
for (let e = 0; e < D.length; e++)
|
|
772
|
+
if (D[e].length >= t) {
|
|
773
|
+
const r = D[e];
|
|
774
|
+
return D.splice(e, 1), r.length === t ? r : new Uint8Array(r.buffer, 0, t);
|
|
775
|
+
}
|
|
776
|
+
return new Uint8Array(t);
|
|
777
|
+
}
|
|
778
|
+
function Zt(t) {
|
|
779
|
+
D.length < kt && t.buffer.byteLength > 0 && D.push(new Uint8Array(t.buffer));
|
|
780
|
+
}
|
|
781
|
+
function pt(t) {
|
|
782
|
+
try {
|
|
783
|
+
t.encoder.close();
|
|
784
|
+
} catch {
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
function te(t, e) {
|
|
788
|
+
try {
|
|
789
|
+
if (t.stopped || t.encoder.encodeQueueSize > Wt)
|
|
790
|
+
return;
|
|
791
|
+
t.frameCounter += 1;
|
|
792
|
+
const r = t.forceKeyframe || t.frameCounter > 0 && t.frameCounter % t.keyFrameIntervalFrames === 0;
|
|
793
|
+
t.forceKeyframe = !1, t.encoder.encode(e, { keyFrame: r });
|
|
794
|
+
} catch (r) {
|
|
795
|
+
P(r, t.captureId), t.forceKeyframe = !0;
|
|
796
|
+
} finally {
|
|
797
|
+
try {
|
|
798
|
+
e.close();
|
|
799
|
+
} catch {
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
async function ee(t) {
|
|
804
|
+
try {
|
|
805
|
+
for (; !t.stopped; ) {
|
|
806
|
+
const e = await t.reader.read();
|
|
807
|
+
if (e.done)
|
|
808
|
+
break;
|
|
809
|
+
const r = e.value;
|
|
810
|
+
r && te(t, r);
|
|
811
|
+
}
|
|
812
|
+
} catch (e) {
|
|
813
|
+
t.stopped || P(e, t.captureId);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
async function re(t) {
|
|
817
|
+
if (!l)
|
|
818
|
+
throw new Error("Video capture worker missing send port");
|
|
819
|
+
if (f.get(t.captureId))
|
|
820
|
+
return;
|
|
821
|
+
const r = Math.max(1, Math.floor(t.width)), i = Math.max(1, Math.floor(t.height)), n = await qt(r, i, t.options), E = Math.max(1, Math.floor(t.options?.keyFrameIntervalFrames ?? Mt)), I = n.config.width ?? r, s = n.config.height ?? i, a = n.config.framerate ?? x, C = n.config.bitrate ?? 0, N = t.trackSettings?.frameRate, U = N ?? a, u = new VideoEncoder({
|
|
822
|
+
output: (S) => {
|
|
823
|
+
const c = f.get(t.captureId);
|
|
824
|
+
if (!c || c.stopped)
|
|
825
|
+
return;
|
|
826
|
+
const G = Jt(S.byteLength);
|
|
827
|
+
S.copyTo(G);
|
|
828
|
+
const q = Lt({
|
|
829
|
+
Data: G,
|
|
830
|
+
FrameNumber: c.frameCounter,
|
|
831
|
+
IsKey: S.type === "key",
|
|
832
|
+
TimestampInUs: BigInt(Math.max(0, Math.round(S.timestamp ?? 0))),
|
|
833
|
+
DurationInUs: Math.max(0, Math.round(S.duration ?? 0))
|
|
834
|
+
}), z = Ot(q, c.senderId, { trackId: c.trackId });
|
|
835
|
+
Zt(G), m(z);
|
|
836
|
+
},
|
|
837
|
+
error: (S) => {
|
|
838
|
+
P(S, t.captureId);
|
|
839
|
+
}
|
|
840
|
+
});
|
|
841
|
+
u.configure(n.config);
|
|
842
|
+
const T = n.isHardwareAccelerated ? "hardware" : "software", R = N !== void 0 ? `${Math.round(U)}fps (track)` : `${Math.round(a)}fps (configured)`;
|
|
843
|
+
g({
|
|
844
|
+
type: "log",
|
|
845
|
+
message: `Encoder configured: codec=${n.config.codec}, ${I}x${s}@${R}, bitrate=${C}bps, hw=${T}`
|
|
846
|
+
});
|
|
847
|
+
const h = t.readable.getReader(), O = {
|
|
848
|
+
captureId: t.captureId,
|
|
849
|
+
kind: t.kind,
|
|
850
|
+
senderId: t.senderId,
|
|
851
|
+
trackId: t.trackId,
|
|
852
|
+
width: I,
|
|
853
|
+
height: s,
|
|
854
|
+
codec: n.codec,
|
|
855
|
+
encoder: u,
|
|
856
|
+
encoderConfig: n.config,
|
|
857
|
+
reader: h,
|
|
858
|
+
frameCounter: 0,
|
|
859
|
+
keyFrameIntervalFrames: E,
|
|
860
|
+
forceKeyframe: !0,
|
|
861
|
+
stopped: !1,
|
|
862
|
+
isHardwareAccelerated: n.isHardwareAccelerated
|
|
863
|
+
};
|
|
864
|
+
f.set(t.captureId, O), M.set(t.trackId, t.captureId), m(
|
|
865
|
+
Ut(
|
|
866
|
+
ht({
|
|
867
|
+
Description: `${t.kind}:${t.captureId}`,
|
|
868
|
+
Codec: O.codec,
|
|
869
|
+
Width: I,
|
|
870
|
+
Height: s,
|
|
871
|
+
Framerate: U,
|
|
872
|
+
Bitrate: C,
|
|
873
|
+
IsHardwareAccelerated: n.isHardwareAccelerated
|
|
874
|
+
}),
|
|
875
|
+
t.senderId,
|
|
876
|
+
{ trackId: t.trackId }
|
|
877
|
+
)
|
|
878
|
+
), g({ type: "started", captureId: t.captureId, codec: O.codec, width: I, height: s }), ee(O);
|
|
879
|
+
}
|
|
880
|
+
async function Q(t) {
|
|
881
|
+
const e = f.get(t);
|
|
882
|
+
if (e) {
|
|
883
|
+
e.stopped = !0, f.delete(t), M.delete(e.trackId);
|
|
884
|
+
try {
|
|
885
|
+
await e.reader.cancel();
|
|
886
|
+
} catch {
|
|
887
|
+
}
|
|
888
|
+
try {
|
|
889
|
+
await e.encoder.flush();
|
|
890
|
+
} catch {
|
|
891
|
+
}
|
|
892
|
+
pt(e), m(Bt(Vt({}), e.senderId, { trackId: e.trackId })), g({ type: "stopped", captureId: t });
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
function ie(t) {
|
|
896
|
+
const e = new Uint8Array(t);
|
|
897
|
+
if (J(e) !== v.VIDEO_REQUEST_IDR_FRAME)
|
|
898
|
+
return;
|
|
899
|
+
const i = Z(e), n = M.get(i.trackId);
|
|
900
|
+
if (!n)
|
|
901
|
+
return;
|
|
902
|
+
const E = f.get(n);
|
|
903
|
+
E && (E.forceKeyframe = !0);
|
|
904
|
+
}
|
|
905
|
+
function ne() {
|
|
906
|
+
for (const t of f.keys())
|
|
907
|
+
Q(t);
|
|
908
|
+
if (f.clear(), M.clear(), o) {
|
|
909
|
+
try {
|
|
910
|
+
o.close();
|
|
911
|
+
} catch {
|
|
912
|
+
}
|
|
913
|
+
o = null;
|
|
914
|
+
}
|
|
915
|
+
if (l) {
|
|
916
|
+
try {
|
|
917
|
+
l.close();
|
|
918
|
+
} catch {
|
|
919
|
+
}
|
|
920
|
+
l = null;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
self.addEventListener("message", (t) => {
|
|
924
|
+
const e = t.data;
|
|
925
|
+
if (e.type === "attachSendPort") {
|
|
926
|
+
if (l)
|
|
927
|
+
try {
|
|
928
|
+
l.close();
|
|
929
|
+
} catch {
|
|
930
|
+
}
|
|
931
|
+
l = e.port;
|
|
932
|
+
try {
|
|
933
|
+
l.start?.();
|
|
934
|
+
} catch {
|
|
935
|
+
}
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
if (e.type === "attachProtocolPort") {
|
|
939
|
+
if (o)
|
|
940
|
+
try {
|
|
941
|
+
o.close();
|
|
942
|
+
} catch {
|
|
943
|
+
}
|
|
944
|
+
o = e.port, o.addEventListener("message", (r) => {
|
|
945
|
+
const i = r.data;
|
|
946
|
+
i?.type === "protocol" && i.message instanceof ArrayBuffer && ie(i.message);
|
|
947
|
+
});
|
|
948
|
+
try {
|
|
949
|
+
o.start?.();
|
|
950
|
+
} catch {
|
|
951
|
+
}
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
if (e.type === "start") {
|
|
955
|
+
re(e).catch((r) => P(r, e.captureId));
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
if (e.type === "stop") {
|
|
959
|
+
Q(e.captureId).catch((r) => P(r, e.captureId));
|
|
960
|
+
return;
|
|
961
|
+
}
|
|
962
|
+
e.type === "dispose" && ne();
|
|
963
|
+
});
|