@ikonai/sdk 1.0.27 → 1.0.29
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/{protocol-worker-Cj8zX_U0.js → protocol-worker-CGvoUu0T.js} +495 -445
- package/channel/channel-manager.d.ts +21 -1
- package/channel/channel.d.ts +5 -0
- package/client/endpoint-selector.d.ts +5 -0
- package/client/ikon-client-config.d.ts +21 -8
- package/client/ikon-client.d.ts +15 -0
- package/connection/urls.d.ts +0 -10
- package/index.d.ts +1 -0
- package/index.js +1669 -1525
- package/package.json +1 -1
- package/transport/web-socket-transport.d.ts +1 -0
- package/transport/web-transport-transport.d.ts +1 -0
- package/utils/debug-mode.d.ts +2 -2
- package/utils/query-params.d.ts +35 -0
|
@@ -7,116 +7,116 @@ function W(t) {
|
|
|
7
7
|
return $(t) & 4294901760;
|
|
8
8
|
}
|
|
9
9
|
function X(t) {
|
|
10
|
-
const e = Et(t),
|
|
10
|
+
const e = Et(t), s = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
11
11
|
if (e.length < 27)
|
|
12
12
|
throw new Error("Protocol payload too short");
|
|
13
|
-
const
|
|
13
|
+
const r = s.getUint32(0, !0), i = s.getUint32(4, !0), n = s.getUint32(8, !0), a = s.getUint32(12, !0), o = s.getUint32(16, !0), l = s.getUint32(20, !0), h = s.getUint8(24), N = s.getUint8(25), _ = s.getUint8(26);
|
|
14
14
|
if (27 + l * 4 > e.length)
|
|
15
15
|
throw new Error("Protocol header exceeds payload length");
|
|
16
|
-
const
|
|
17
|
-
let
|
|
18
|
-
for (let
|
|
19
|
-
|
|
16
|
+
const c = [];
|
|
17
|
+
let O = 27;
|
|
18
|
+
for (let b = 0; b < l; b++)
|
|
19
|
+
c.push(s.getUint32(O, !0)), O += 4;
|
|
20
20
|
return {
|
|
21
|
-
length:
|
|
22
|
-
opcode:
|
|
23
|
-
senderId:
|
|
21
|
+
length: r,
|
|
22
|
+
opcode: i,
|
|
23
|
+
senderId: n,
|
|
24
24
|
trackId: a,
|
|
25
25
|
sequenceId: o,
|
|
26
|
-
targetIds:
|
|
26
|
+
targetIds: c,
|
|
27
27
|
payloadVersion: h,
|
|
28
|
-
payloadType:
|
|
28
|
+
payloadType: N,
|
|
29
29
|
flags: _
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
const l = [],
|
|
34
|
-
|
|
35
|
-
let
|
|
36
|
-
for (let
|
|
37
|
-
|
|
38
|
-
return
|
|
32
|
+
function it(t, e, s, r, i) {
|
|
33
|
+
const l = [], N = 27 + l.length * 4, _ = N + e.length, P = new Uint8Array(_), c = new DataView(P.buffer);
|
|
34
|
+
c.setUint32(0, _, !0), c.setUint32(4, t >>> 0, !0), c.setUint32(8, r >>> 0, !0), c.setUint32(12, 0, !0), c.setUint32(16, 0, !0), c.setUint32(20, l.length >>> 0, !0), c.setUint8(24, s & 255), c.setUint8(25, 8), c.setUint8(26, 0);
|
|
35
|
+
let O = 27;
|
|
36
|
+
for (let b = 0; b < l.length; b++)
|
|
37
|
+
c.setUint32(O, l[b] >>> 0, !0), O += 4;
|
|
38
|
+
return P.set(e, N), P;
|
|
39
39
|
}
|
|
40
40
|
var g = /* @__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))(g || {});
|
|
41
|
-
const
|
|
41
|
+
const nt = 161, at = 162, V = new TextEncoder();
|
|
42
42
|
new TextDecoder("utf-8", { fatal: !0 });
|
|
43
43
|
class M {
|
|
44
44
|
constructor(e = 1) {
|
|
45
|
-
this.version = e, this.buffer.writeByte(
|
|
45
|
+
this.version = e, this.buffer.writeByte(nt), this.buffer.writeVarUInt(e >>> 0);
|
|
46
46
|
}
|
|
47
|
-
buffer = new
|
|
47
|
+
buffer = new m();
|
|
48
48
|
closed = !1;
|
|
49
49
|
cached;
|
|
50
|
-
writeInt32Field(e,
|
|
51
|
-
this.writeFixedField(e, 3, () => this.buffer.writeInt32(
|
|
50
|
+
writeInt32Field(e, s) {
|
|
51
|
+
this.writeFixedField(e, 3, () => this.buffer.writeInt32(s | 0));
|
|
52
52
|
}
|
|
53
|
-
writeUInt32Field(e,
|
|
54
|
-
this.writeFixedField(e, 5, () => this.buffer.writeUInt32(
|
|
53
|
+
writeUInt32Field(e, s) {
|
|
54
|
+
this.writeFixedField(e, 5, () => this.buffer.writeUInt32(s >>> 0));
|
|
55
55
|
}
|
|
56
|
-
writeInt64Field(e,
|
|
57
|
-
this.writeFixedField(e, 4, () => this.buffer.writeBigInt64(
|
|
56
|
+
writeInt64Field(e, s) {
|
|
57
|
+
this.writeFixedField(e, 4, () => this.buffer.writeBigInt64(s));
|
|
58
58
|
}
|
|
59
|
-
writeUInt64Field(e,
|
|
60
|
-
this.writeFixedField(e, 6, () => this.buffer.writeBigUInt64(
|
|
59
|
+
writeUInt64Field(e, s) {
|
|
60
|
+
this.writeFixedField(e, 6, () => this.buffer.writeBigUInt64(s));
|
|
61
61
|
}
|
|
62
|
-
writeFloat32Field(e,
|
|
63
|
-
this.writeFixedField(e, 7, () => this.buffer.writeFloat32(
|
|
62
|
+
writeFloat32Field(e, s) {
|
|
63
|
+
this.writeFixedField(e, 7, () => this.buffer.writeFloat32(s));
|
|
64
64
|
}
|
|
65
|
-
writeFloat64Field(e,
|
|
66
|
-
this.writeFixedField(e, 8, () => this.buffer.writeFloat64(
|
|
65
|
+
writeFloat64Field(e, s) {
|
|
66
|
+
this.writeFixedField(e, 8, () => this.buffer.writeFloat64(s));
|
|
67
67
|
}
|
|
68
|
-
writeBoolField(e,
|
|
69
|
-
this.writeFixedField(e, 2, () => this.buffer.writeByte(
|
|
68
|
+
writeBoolField(e, s) {
|
|
69
|
+
this.writeFixedField(e, 2, () => this.buffer.writeByte(s ? 1 : 0));
|
|
70
70
|
}
|
|
71
|
-
writeGuidField(e,
|
|
72
|
-
const
|
|
73
|
-
if (
|
|
71
|
+
writeGuidField(e, s) {
|
|
72
|
+
const r = s instanceof E ? s.asBytes() : s;
|
|
73
|
+
if (r.length !== 16)
|
|
74
74
|
throw new Error("Guid payload must be 16 bytes");
|
|
75
|
-
this.writeFixedField(e, 14, () => this.buffer.writeBytes(
|
|
76
|
-
}
|
|
77
|
-
writeStringField(e,
|
|
78
|
-
const
|
|
79
|
-
this.writeVariableField(e, 12,
|
|
80
|
-
}
|
|
81
|
-
writeBinaryField(e,
|
|
82
|
-
this.writeVariableField(e, 13,
|
|
83
|
-
}
|
|
84
|
-
writeObjectField(e,
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
this.writeVariableField(e, 11,
|
|
89
|
-
}
|
|
90
|
-
writeArrayField(e,
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
this.writeVariableField(e, 9,
|
|
95
|
-
}
|
|
96
|
-
writeDictionaryField(e,
|
|
97
|
-
const
|
|
98
|
-
n
|
|
99
|
-
const a =
|
|
75
|
+
this.writeFixedField(e, 14, () => this.buffer.writeBytes(r));
|
|
76
|
+
}
|
|
77
|
+
writeStringField(e, s) {
|
|
78
|
+
const r = V.encode(s ?? "");
|
|
79
|
+
this.writeVariableField(e, 12, r);
|
|
80
|
+
}
|
|
81
|
+
writeBinaryField(e, s) {
|
|
82
|
+
this.writeVariableField(e, 13, s);
|
|
83
|
+
}
|
|
84
|
+
writeObjectField(e, s, r) {
|
|
85
|
+
const i = new M(s);
|
|
86
|
+
r(i);
|
|
87
|
+
const n = i.finish();
|
|
88
|
+
this.writeVariableField(e, 11, n);
|
|
89
|
+
}
|
|
90
|
+
writeArrayField(e, s, r) {
|
|
91
|
+
const i = new K(s);
|
|
92
|
+
r(i);
|
|
93
|
+
const n = i.finish();
|
|
94
|
+
this.writeVariableField(e, 9, n);
|
|
95
|
+
}
|
|
96
|
+
writeDictionaryField(e, s, r, i) {
|
|
97
|
+
const n = new Q(s, r);
|
|
98
|
+
i(n);
|
|
99
|
+
const a = n.finish();
|
|
100
100
|
this.writeVariableField(e, 10, a);
|
|
101
101
|
}
|
|
102
102
|
finish() {
|
|
103
103
|
return this.closed || (this.buffer.writeByte(at), this.closed = !0, this.cached = this.buffer.toUint8Array()), this.cached;
|
|
104
104
|
}
|
|
105
|
-
writeFixedField(e,
|
|
106
|
-
this.writeFieldHeader(e,
|
|
105
|
+
writeFixedField(e, s, r) {
|
|
106
|
+
this.writeFieldHeader(e, s, 0), r();
|
|
107
107
|
}
|
|
108
|
-
writeVariableField(e,
|
|
109
|
-
this.writeFieldHeader(e,
|
|
108
|
+
writeVariableField(e, s, r) {
|
|
109
|
+
this.writeFieldHeader(e, s, r.length), this.buffer.writeBytes(r);
|
|
110
110
|
}
|
|
111
|
-
writeFieldHeader(e,
|
|
112
|
-
this.buffer.writeUInt32(e >>> 0), this.buffer.writeByte(k(
|
|
111
|
+
writeFieldHeader(e, s, r) {
|
|
112
|
+
this.buffer.writeUInt32(e >>> 0), this.buffer.writeByte(k(s)), lt(s) && this.buffer.writeVarUInt(r >>> 0);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
class K {
|
|
116
116
|
constructor(e) {
|
|
117
117
|
this.elementType = e;
|
|
118
118
|
}
|
|
119
|
-
payload = new
|
|
119
|
+
payload = new m();
|
|
120
120
|
count = 0;
|
|
121
121
|
writeInt32(e) {
|
|
122
122
|
this.ensureElementType(
|
|
@@ -165,18 +165,18 @@ class K {
|
|
|
165
165
|
14
|
|
166
166
|
/* Guid */
|
|
167
167
|
), this.count++;
|
|
168
|
-
const
|
|
169
|
-
if (
|
|
168
|
+
const s = e instanceof E ? e.asBytes() : e;
|
|
169
|
+
if (s.length !== 16)
|
|
170
170
|
throw new Error("Guid payload must be 16 bytes");
|
|
171
|
-
this.payload.writeBytes(
|
|
171
|
+
this.payload.writeBytes(s);
|
|
172
172
|
}
|
|
173
173
|
writeString(e) {
|
|
174
174
|
this.ensureElementType(
|
|
175
175
|
12
|
|
176
176
|
/* String */
|
|
177
177
|
), this.count++;
|
|
178
|
-
const
|
|
179
|
-
this.payload.writeVarUInt(
|
|
178
|
+
const s = V.encode(e ?? "");
|
|
179
|
+
this.payload.writeVarUInt(s.length), this.payload.writeBytes(s);
|
|
180
180
|
}
|
|
181
181
|
writeBinary(e) {
|
|
182
182
|
this.ensureElementType(
|
|
@@ -184,38 +184,38 @@ class K {
|
|
|
184
184
|
/* Binary */
|
|
185
185
|
), this.count++, this.payload.writeVarUInt(e.length), this.payload.writeBytes(e);
|
|
186
186
|
}
|
|
187
|
-
writeObject(e,
|
|
187
|
+
writeObject(e, s) {
|
|
188
188
|
this.ensureElementType(
|
|
189
189
|
11
|
|
190
190
|
/* Object */
|
|
191
191
|
), this.count++;
|
|
192
|
-
const
|
|
193
|
-
r
|
|
194
|
-
const
|
|
195
|
-
this.payload.writeVarUInt(
|
|
192
|
+
const r = new M(e);
|
|
193
|
+
s(r);
|
|
194
|
+
const i = r.finish();
|
|
195
|
+
this.payload.writeVarUInt(i.length), this.payload.writeBytes(i);
|
|
196
196
|
}
|
|
197
|
-
writeArray(e,
|
|
197
|
+
writeArray(e, s) {
|
|
198
198
|
this.ensureElementType(
|
|
199
199
|
9
|
|
200
200
|
/* Array */
|
|
201
201
|
), this.count++;
|
|
202
|
-
const
|
|
203
|
-
r
|
|
204
|
-
const
|
|
205
|
-
this.payload.writeBytes(
|
|
202
|
+
const r = new K(e);
|
|
203
|
+
s(r);
|
|
204
|
+
const i = r.finish();
|
|
205
|
+
this.payload.writeBytes(i);
|
|
206
206
|
}
|
|
207
|
-
writeDictionary(e,
|
|
207
|
+
writeDictionary(e, s, r) {
|
|
208
208
|
this.ensureElementType(
|
|
209
209
|
10
|
|
210
210
|
/* Dict */
|
|
211
211
|
), this.count++;
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
const
|
|
215
|
-
this.payload.writeBytes(
|
|
212
|
+
const i = new Q(e, s);
|
|
213
|
+
r(i);
|
|
214
|
+
const n = i.finish();
|
|
215
|
+
this.payload.writeBytes(n);
|
|
216
216
|
}
|
|
217
217
|
finish() {
|
|
218
|
-
const e = new
|
|
218
|
+
const e = new m();
|
|
219
219
|
return e.writeByte(k(this.elementType)), e.writeVarUInt(this.count), e.writeBytes(this.payload.toUint8Array()), e.toUint8Array();
|
|
220
220
|
}
|
|
221
221
|
ensureElementType(e) {
|
|
@@ -224,10 +224,10 @@ class K {
|
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
class Q {
|
|
227
|
-
constructor(e,
|
|
228
|
-
this.keyType = e, this.valueType =
|
|
227
|
+
constructor(e, s) {
|
|
228
|
+
this.keyType = e, this.valueType = s, ht(e);
|
|
229
229
|
}
|
|
230
|
-
payload = new
|
|
230
|
+
payload = new m();
|
|
231
231
|
count = 0;
|
|
232
232
|
entryOpen = !1;
|
|
233
233
|
beginEntry() {
|
|
@@ -240,13 +240,13 @@ class Q {
|
|
|
240
240
|
finish() {
|
|
241
241
|
if (this.entryOpen)
|
|
242
242
|
throw new Error("Dictionary entry not completed");
|
|
243
|
-
const e = new
|
|
243
|
+
const e = new m();
|
|
244
244
|
return e.writeByte(k(this.keyType)), e.writeByte(k(this.valueType)), e.writeVarUInt(this.count), e.writeBytes(this.payload.toUint8Array()), e.toUint8Array();
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
class ot {
|
|
248
|
-
constructor(e,
|
|
249
|
-
this.keyType = e, this.valueType =
|
|
248
|
+
constructor(e, s, r, i) {
|
|
249
|
+
this.keyType = e, this.valueType = s, this.payload = r, this.onComplete = i;
|
|
250
250
|
}
|
|
251
251
|
keyWritten = !1;
|
|
252
252
|
valueWritten = !1;
|
|
@@ -298,18 +298,18 @@ class ot {
|
|
|
298
298
|
14
|
|
299
299
|
/* Guid */
|
|
300
300
|
);
|
|
301
|
-
const
|
|
302
|
-
if (
|
|
301
|
+
const s = e instanceof E ? e.asBytes() : e;
|
|
302
|
+
if (s.length !== 16)
|
|
303
303
|
throw new Error("Guid payload must be 16 bytes");
|
|
304
|
-
this.payload.writeBytes(
|
|
304
|
+
this.payload.writeBytes(s), this.keyWritten = !0;
|
|
305
305
|
}
|
|
306
306
|
writeKeyString(e) {
|
|
307
307
|
this.ensureKeyType(
|
|
308
308
|
12
|
|
309
309
|
/* String */
|
|
310
310
|
);
|
|
311
|
-
const
|
|
312
|
-
this.payload.writeVarUInt(
|
|
311
|
+
const s = V.encode(e ?? "");
|
|
312
|
+
this.payload.writeVarUInt(s.length), this.payload.writeBytes(s), this.keyWritten = !0;
|
|
313
313
|
}
|
|
314
314
|
writeKeyBinary(e) {
|
|
315
315
|
this.ensureKeyType(
|
|
@@ -364,10 +364,10 @@ class ot {
|
|
|
364
364
|
14
|
|
365
365
|
/* Guid */
|
|
366
366
|
);
|
|
367
|
-
const
|
|
368
|
-
if (
|
|
367
|
+
const s = e instanceof E ? e.asBytes() : e;
|
|
368
|
+
if (s.length !== 16)
|
|
369
369
|
throw new Error("Guid payload must be 16 bytes");
|
|
370
|
-
this.payload.writeBytes(
|
|
370
|
+
this.payload.writeBytes(s), this.valueWritten = !0;
|
|
371
371
|
}
|
|
372
372
|
writeNullValue() {
|
|
373
373
|
this.ensureValueType(
|
|
@@ -386,38 +386,38 @@ class ot {
|
|
|
386
386
|
12
|
|
387
387
|
/* String */
|
|
388
388
|
);
|
|
389
|
-
const
|
|
390
|
-
this.payload.writeVarUInt(
|
|
389
|
+
const s = V.encode(e ?? "");
|
|
390
|
+
this.payload.writeVarUInt(s.length), this.payload.writeBytes(s), this.valueWritten = !0;
|
|
391
391
|
}
|
|
392
|
-
writeValueObject(e,
|
|
392
|
+
writeValueObject(e, s) {
|
|
393
393
|
this.ensureValueType(
|
|
394
394
|
11
|
|
395
395
|
/* Object */
|
|
396
396
|
);
|
|
397
|
-
const
|
|
398
|
-
r
|
|
399
|
-
const
|
|
400
|
-
this.payload.writeVarUInt(
|
|
397
|
+
const r = new M(e);
|
|
398
|
+
s(r);
|
|
399
|
+
const i = r.finish();
|
|
400
|
+
this.payload.writeVarUInt(i.length), this.payload.writeBytes(i), this.valueWritten = !0;
|
|
401
401
|
}
|
|
402
|
-
writeValueArray(e,
|
|
402
|
+
writeValueArray(e, s) {
|
|
403
403
|
this.ensureValueType(
|
|
404
404
|
9
|
|
405
405
|
/* Array */
|
|
406
406
|
);
|
|
407
|
-
const
|
|
408
|
-
r
|
|
409
|
-
const
|
|
410
|
-
this.payload.writeBytes(
|
|
407
|
+
const r = new K(e);
|
|
408
|
+
s(r);
|
|
409
|
+
const i = r.finish();
|
|
410
|
+
this.payload.writeBytes(i), this.valueWritten = !0;
|
|
411
411
|
}
|
|
412
|
-
writeValueDictionary(e,
|
|
412
|
+
writeValueDictionary(e, s, r) {
|
|
413
413
|
this.ensureValueType(
|
|
414
414
|
10
|
|
415
415
|
/* Dict */
|
|
416
416
|
);
|
|
417
|
-
const
|
|
418
|
-
|
|
419
|
-
const
|
|
420
|
-
this.payload.writeBytes(
|
|
417
|
+
const i = new Q(e, s);
|
|
418
|
+
r(i);
|
|
419
|
+
const n = i.finish();
|
|
420
|
+
this.payload.writeBytes(n), this.valueWritten = !0;
|
|
421
421
|
}
|
|
422
422
|
complete() {
|
|
423
423
|
if (!this.completed) {
|
|
@@ -442,14 +442,14 @@ class E {
|
|
|
442
442
|
static fromString(e) {
|
|
443
443
|
if (!e)
|
|
444
444
|
throw new Error("Guid string is empty");
|
|
445
|
-
const
|
|
446
|
-
if (
|
|
445
|
+
const s = e.replace(/-/g, "");
|
|
446
|
+
if (s.length !== 32)
|
|
447
447
|
throw new Error("Guid string must be 32 hex characters");
|
|
448
|
-
const
|
|
449
|
-
E.writeUInt32LE(
|
|
448
|
+
const r = new Uint8Array(16), i = E.parseHexSlice(s, 0, 8), n = E.parseHexSlice(s, 8, 4), a = E.parseHexSlice(s, 12, 4);
|
|
449
|
+
E.writeUInt32LE(r, 0, i), E.writeUInt16LE(r, 4, n), E.writeUInt16LE(r, 6, a);
|
|
450
450
|
for (let o = 0; o < 8; o++)
|
|
451
|
-
|
|
452
|
-
return new E(
|
|
451
|
+
r[8 + o] = E.parseHexSlice(s, 16 + o * 2, 2);
|
|
452
|
+
return new E(r);
|
|
453
453
|
}
|
|
454
454
|
static fromBytes(e) {
|
|
455
455
|
if (e.length !== 16)
|
|
@@ -460,12 +460,12 @@ class E {
|
|
|
460
460
|
return new E(new Uint8Array(16));
|
|
461
461
|
}
|
|
462
462
|
static createRandom() {
|
|
463
|
-
const e = new Uint8Array(16),
|
|
464
|
-
if (
|
|
465
|
-
|
|
463
|
+
const e = new Uint8Array(16), s = globalThis.crypto;
|
|
464
|
+
if (s?.getRandomValues)
|
|
465
|
+
s.getRandomValues(e);
|
|
466
466
|
else
|
|
467
|
-
for (let
|
|
468
|
-
e[
|
|
467
|
+
for (let r = 0; r < e.length; r++)
|
|
468
|
+
e[r] = Math.floor(Math.random() * 256);
|
|
469
469
|
return e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128, new E(e);
|
|
470
470
|
}
|
|
471
471
|
toString() {
|
|
@@ -481,47 +481,47 @@ class E {
|
|
|
481
481
|
asBytes() {
|
|
482
482
|
return this.bytes.slice();
|
|
483
483
|
}
|
|
484
|
-
static parseHexSlice(e,
|
|
485
|
-
const
|
|
486
|
-
if (Number.isNaN(
|
|
484
|
+
static parseHexSlice(e, s, r) {
|
|
485
|
+
const i = e.substr(s, r), n = Number.parseInt(i, 16);
|
|
486
|
+
if (Number.isNaN(n))
|
|
487
487
|
throw new Error("Guid string contains invalid characters");
|
|
488
|
-
return
|
|
488
|
+
return n >>> 0;
|
|
489
489
|
}
|
|
490
|
-
static writeUInt32LE(e,
|
|
491
|
-
const
|
|
492
|
-
e[
|
|
490
|
+
static writeUInt32LE(e, s, r) {
|
|
491
|
+
const i = r >>> 0;
|
|
492
|
+
e[s] = i & 255, e[s + 1] = i >>> 8 & 255, e[s + 2] = i >>> 16 & 255, e[s + 3] = i >>> 24 & 255;
|
|
493
493
|
}
|
|
494
|
-
static writeUInt16LE(e,
|
|
495
|
-
const
|
|
496
|
-
e[
|
|
494
|
+
static writeUInt16LE(e, s, r) {
|
|
495
|
+
const i = r & 65535;
|
|
496
|
+
e[s] = i & 255, e[s + 1] = i >>> 8 & 255;
|
|
497
497
|
}
|
|
498
|
-
static readUInt32LE(e,
|
|
499
|
-
return (e[
|
|
498
|
+
static readUInt32LE(e, s) {
|
|
499
|
+
return (e[s] | e[s + 1] << 8 | e[s + 2] << 16 | e[s + 3] << 24) >>> 0;
|
|
500
500
|
}
|
|
501
|
-
static readUInt16LE(e,
|
|
502
|
-
return (e[
|
|
501
|
+
static readUInt16LE(e, s) {
|
|
502
|
+
return (e[s] | e[s + 1] << 8) & 65535;
|
|
503
503
|
}
|
|
504
|
-
static toHex(e,
|
|
505
|
-
return (e >>> 0).toString(16).padStart(
|
|
504
|
+
static toHex(e, s) {
|
|
505
|
+
return (e >>> 0).toString(16).padStart(s, "0");
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
|
-
class
|
|
508
|
+
class m {
|
|
509
509
|
static INITIAL_CAPACITY = 256;
|
|
510
510
|
buffer;
|
|
511
511
|
dataView;
|
|
512
512
|
length = 0;
|
|
513
513
|
constructor() {
|
|
514
|
-
this.buffer = new Uint8Array(
|
|
514
|
+
this.buffer = new Uint8Array(m.INITIAL_CAPACITY), this.dataView = new DataView(this.buffer.buffer);
|
|
515
515
|
}
|
|
516
516
|
ensureCapacity(e) {
|
|
517
|
-
const
|
|
518
|
-
if (
|
|
517
|
+
const s = this.length + e;
|
|
518
|
+
if (s <= this.buffer.length)
|
|
519
519
|
return;
|
|
520
|
-
let
|
|
521
|
-
for (;
|
|
522
|
-
|
|
523
|
-
const
|
|
524
|
-
|
|
520
|
+
let r = this.buffer.length;
|
|
521
|
+
for (; r < s; )
|
|
522
|
+
r *= 2;
|
|
523
|
+
const i = new Uint8Array(r);
|
|
524
|
+
i.set(this.buffer.subarray(0, this.length)), this.buffer = i, this.dataView = new DataView(this.buffer.buffer);
|
|
525
525
|
}
|
|
526
526
|
writeByte(e) {
|
|
527
527
|
this.ensureCapacity(1), this.buffer[this.length++] = e & 255;
|
|
@@ -548,10 +548,10 @@ class P {
|
|
|
548
548
|
this.ensureCapacity(8), this.dataView.setBigUint64(this.length, e, !0), this.length += 8;
|
|
549
549
|
}
|
|
550
550
|
writeVarUInt(e) {
|
|
551
|
-
let
|
|
552
|
-
for (;
|
|
553
|
-
this.ensureCapacity(1), this.buffer[this.length++] =
|
|
554
|
-
this.ensureCapacity(1), this.buffer[this.length++] =
|
|
551
|
+
let s = e >>> 0;
|
|
552
|
+
for (; s >= 128; )
|
|
553
|
+
this.ensureCapacity(1), this.buffer[this.length++] = s & 127 | 128, s >>>= 7;
|
|
554
|
+
this.ensureCapacity(1), this.buffer[this.length++] = s & 127;
|
|
555
555
|
}
|
|
556
556
|
toUint8Array() {
|
|
557
557
|
return this.buffer.slice(0, this.length);
|
|
@@ -575,7 +575,7 @@ function j(t) {
|
|
|
575
575
|
function Et(t) {
|
|
576
576
|
return t instanceof Uint8Array ? t : new Uint8Array(t);
|
|
577
577
|
}
|
|
578
|
-
var y = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.WebSocket = 1] = "WebSocket", t[t.WebSocketProxy = 2] = "WebSocketProxy", t[t.WebTransport = 4] = "WebTransport", t[t.WebTransportProxy = 8] = "WebTransportProxy", t[t.Tcp = 16] = "Tcp", t[t.TcpProxy = 32] = "TcpProxy", t[t.Https = 64] = "Https", t[t.WebRTC = 128] = "WebRTC", t[t.TcpTls = 256] = "TcpTls", t))(y || {}), m = /* @__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.CORE_UPDATE_CLIENT_CONTEXT = 65558] = "CORE_UPDATE_CLIENT_CONTEXT", t[t.CORE_BACKGROUND_WORK_ACTIVE = 65559] = "CORE_BACKGROUND_WORK_ACTIVE", t[t.CORE_WEBRTC_OFFER = 65566] = "CORE_WEBRTC_OFFER", t[t.CORE_WEBRTC_ANSWER = 65567] = "CORE_WEBRTC_ANSWER", t[t.CORE_WEBRTC_ICE_CANDIDATE = 65568] = "CORE_WEBRTC_ICE_CANDIDATE", t[t.CORE_WEBRTC_READY = 65569] = "CORE_WEBRTC_READY", t[t.CORE_WEBRTC_AUDIO_SEGMENT = 65570] = "CORE_WEBRTC_AUDIO_SEGMENT", t[t.CORE_WEBRTC_TRACK_MAP = 65571] = "CORE_WEBRTC_TRACK_MAP", 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.ACTION_FILE_UPLOAD_CALLBACK = 1048640] = "ACTION_FILE_UPLOAD_CALLBACK", t[t.ACTION_CUSTOM_USER_MESSAGE = 1048641] = "ACTION_CUSTOM_USER_MESSAGE", t[t.ACTION_URL_CHANGED = 1048642] = "ACTION_URL_CHANGED", 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))(m || {});
|
|
578
|
+
var R = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.WebSocket = 1] = "WebSocket", t[t.WebSocketProxy = 2] = "WebSocketProxy", t[t.WebTransport = 4] = "WebTransport", t[t.WebTransportProxy = 8] = "WebTransportProxy", t[t.Tcp = 16] = "Tcp", t[t.TcpProxy = 32] = "TcpProxy", t[t.Https = 64] = "Https", t[t.WebRTC = 128] = "WebRTC", t[t.TcpTls = 256] = "TcpTls", t))(R || {}), d = /* @__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.CORE_UPDATE_CLIENT_CONTEXT = 65558] = "CORE_UPDATE_CLIENT_CONTEXT", t[t.CORE_BACKGROUND_WORK_ACTIVE = 65559] = "CORE_BACKGROUND_WORK_ACTIVE", t[t.CORE_WEBRTC_OFFER = 65566] = "CORE_WEBRTC_OFFER", t[t.CORE_WEBRTC_ANSWER = 65567] = "CORE_WEBRTC_ANSWER", t[t.CORE_WEBRTC_ICE_CANDIDATE = 65568] = "CORE_WEBRTC_ICE_CANDIDATE", t[t.CORE_WEBRTC_READY = 65569] = "CORE_WEBRTC_READY", t[t.CORE_WEBRTC_AUDIO_SEGMENT = 65570] = "CORE_WEBRTC_AUDIO_SEGMENT", t[t.CORE_WEBRTC_TRACK_MAP = 65571] = "CORE_WEBRTC_TRACK_MAP", 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.ACTION_FILE_UPLOAD_CALLBACK = 1048640] = "ACTION_FILE_UPLOAD_CALLBACK", t[t.ACTION_CUSTOM_USER_MESSAGE = 1048641] = "ACTION_CUSTOM_USER_MESSAGE", t[t.ACTION_URL_CHANGED = 1048642] = "ACTION_URL_CHANGED", 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))(d || {});
|
|
579
579
|
const J = 1, _t = 131074;
|
|
580
580
|
function Z(t) {
|
|
581
581
|
return {};
|
|
@@ -583,18 +583,18 @@ function Z(t) {
|
|
|
583
583
|
function Tt(t) {
|
|
584
584
|
return new M(J).finish();
|
|
585
585
|
}
|
|
586
|
-
function tt(t, e,
|
|
587
|
-
const
|
|
588
|
-
return
|
|
586
|
+
function tt(t, e, s) {
|
|
587
|
+
const r = Tt();
|
|
588
|
+
return it(_t, r, J, e);
|
|
589
589
|
}
|
|
590
590
|
class et extends Error {
|
|
591
|
-
constructor(e,
|
|
592
|
-
super(e), this.cause =
|
|
591
|
+
constructor(e, s) {
|
|
592
|
+
super(e), this.cause = s, this.name = "ConnectionError";
|
|
593
593
|
}
|
|
594
594
|
}
|
|
595
595
|
class L extends et {
|
|
596
|
-
constructor(e,
|
|
597
|
-
super(e,
|
|
596
|
+
constructor(e, s) {
|
|
597
|
+
super(e, s), this.name = "TransportError";
|
|
598
598
|
}
|
|
599
599
|
}
|
|
600
600
|
class z extends L {
|
|
@@ -602,44 +602,44 @@ class z extends L {
|
|
|
602
602
|
super(`No keepalive received within ${e}ms`), this.name = "KeepaliveTimeoutError";
|
|
603
603
|
}
|
|
604
604
|
}
|
|
605
|
-
class
|
|
605
|
+
class ct extends et {
|
|
606
606
|
constructor(e) {
|
|
607
607
|
super(`Maximum reconnection attempts (${e}) exceeded`), this.name = "MaxRetriesExceededError";
|
|
608
608
|
}
|
|
609
609
|
}
|
|
610
|
-
function
|
|
611
|
-
return new Promise((
|
|
612
|
-
const
|
|
613
|
-
clearTimeout(
|
|
614
|
-
},
|
|
615
|
-
e?.removeEventListener("abort",
|
|
610
|
+
function It(t, e) {
|
|
611
|
+
return new Promise((s, r) => {
|
|
612
|
+
const i = () => {
|
|
613
|
+
clearTimeout(n), r(new Error("Aborted"));
|
|
614
|
+
}, n = setTimeout(() => {
|
|
615
|
+
e?.removeEventListener("abort", i), s();
|
|
616
616
|
}, t);
|
|
617
617
|
if (e?.aborted) {
|
|
618
|
-
clearTimeout(
|
|
618
|
+
clearTimeout(n), r(new Error("Aborted"));
|
|
619
619
|
return;
|
|
620
620
|
}
|
|
621
|
-
e?.addEventListener("abort",
|
|
621
|
+
e?.addEventListener("abort", i, { once: !0 });
|
|
622
622
|
});
|
|
623
623
|
}
|
|
624
624
|
let ut = 1;
|
|
625
|
-
const At = /* @__PURE__ */ new Map(),
|
|
625
|
+
const At = /* @__PURE__ */ new Map(), Ct = {
|
|
626
626
|
0: "DEBUG",
|
|
627
627
|
1: "INFO",
|
|
628
628
|
2: "WARN",
|
|
629
629
|
3: "ERROR",
|
|
630
630
|
4: "NONE"
|
|
631
631
|
};
|
|
632
|
-
function
|
|
632
|
+
function ft(t, e) {
|
|
633
633
|
return `[${t}] ${e}`;
|
|
634
634
|
}
|
|
635
|
-
function
|
|
636
|
-
const
|
|
637
|
-
timestamp:
|
|
635
|
+
function p(t, e, s, r) {
|
|
636
|
+
const i = (/* @__PURE__ */ new Date()).toISOString(), n = Ct[t], a = {
|
|
637
|
+
timestamp: i,
|
|
638
638
|
level: t,
|
|
639
|
-
levelName:
|
|
639
|
+
levelName: n,
|
|
640
640
|
component: e,
|
|
641
|
-
message:
|
|
642
|
-
args:
|
|
641
|
+
message: s,
|
|
642
|
+
args: r
|
|
643
643
|
};
|
|
644
644
|
for (const [o, l] of At) {
|
|
645
645
|
const h = l?.minLevel ?? 2;
|
|
@@ -650,43 +650,44 @@ function G(t, e, r, s) {
|
|
|
650
650
|
}
|
|
651
651
|
}
|
|
652
652
|
if (ut <= t) {
|
|
653
|
-
const o =
|
|
653
|
+
const o = ft(e, s);
|
|
654
654
|
switch (t) {
|
|
655
655
|
case 0:
|
|
656
|
-
console.debug(o, ...
|
|
656
|
+
console.debug(o, ...r);
|
|
657
657
|
break;
|
|
658
658
|
case 1:
|
|
659
|
-
console.info(o, ...
|
|
659
|
+
console.info(o, ...r);
|
|
660
660
|
break;
|
|
661
661
|
case 2:
|
|
662
|
-
console.warn(o, ...
|
|
662
|
+
console.warn(o, ...r);
|
|
663
663
|
break;
|
|
664
664
|
case 3:
|
|
665
|
-
console.error(o, ...
|
|
665
|
+
console.error(o, ...r);
|
|
666
666
|
break;
|
|
667
667
|
}
|
|
668
668
|
}
|
|
669
669
|
}
|
|
670
670
|
function F(t) {
|
|
671
671
|
return {
|
|
672
|
-
debug(e, ...
|
|
673
|
-
|
|
672
|
+
debug(e, ...s) {
|
|
673
|
+
p(0, t, e, s);
|
|
674
674
|
},
|
|
675
|
-
info(e, ...
|
|
676
|
-
|
|
675
|
+
info(e, ...s) {
|
|
676
|
+
p(1, t, e, s);
|
|
677
677
|
},
|
|
678
|
-
warn(e, ...
|
|
679
|
-
|
|
678
|
+
warn(e, ...s) {
|
|
679
|
+
p(2, t, e, s);
|
|
680
680
|
},
|
|
681
|
-
error(e, ...
|
|
682
|
-
|
|
681
|
+
error(e, ...s) {
|
|
682
|
+
p(3, t, e, s);
|
|
683
683
|
}
|
|
684
684
|
};
|
|
685
685
|
}
|
|
686
|
-
const
|
|
686
|
+
const G = F("WebSocketTransport"), Nt = 1e4;
|
|
687
687
|
class Rt {
|
|
688
688
|
ws = null;
|
|
689
689
|
keepaliveTimeout = null;
|
|
690
|
+
isClosed = !1;
|
|
690
691
|
// Pre-allocated keepalive response message to avoid allocation per keepalive
|
|
691
692
|
keepaliveResponseMessage = null;
|
|
692
693
|
keepaliveTimeoutMs;
|
|
@@ -698,41 +699,43 @@ class Rt {
|
|
|
698
699
|
get isConnected() {
|
|
699
700
|
return this.ws?.readyState === WebSocket.OPEN;
|
|
700
701
|
}
|
|
701
|
-
async connect(e,
|
|
702
|
-
return new Promise((
|
|
702
|
+
async connect(e, s) {
|
|
703
|
+
return this.isClosed = !1, new Promise((r, i) => {
|
|
703
704
|
try {
|
|
704
705
|
this.ws = new WebSocket(e), this.ws.binaryType = "arraybuffer";
|
|
705
706
|
} catch (h) {
|
|
706
|
-
|
|
707
|
+
i(new L(`Failed to create WebSocket: ${h}`, h instanceof Error ? h : void 0));
|
|
707
708
|
return;
|
|
708
709
|
}
|
|
709
|
-
let
|
|
710
|
+
let n = !1, a = !1;
|
|
710
711
|
const o = () => {
|
|
711
712
|
clearTimeout(l), this.ws && (this.ws.onopen = null, this.ws.onerror = null, this.ws.onclose = null, this.ws.onmessage = null);
|
|
712
713
|
}, l = setTimeout(() => {
|
|
713
|
-
a || (a = !0, o(), this.ws?.close(),
|
|
714
|
-
},
|
|
714
|
+
a || (a = !0, o(), this.ws?.close(), i(new L("WebSocket connection timeout")));
|
|
715
|
+
}, Nt);
|
|
715
716
|
this.ws.onopen = () => {
|
|
716
|
-
|
|
717
|
+
n = !0, clearTimeout(l), this.ws.send(s), this.resetKeepaliveTimeout(), a || (a = !0, r());
|
|
717
718
|
}, this.ws.onerror = () => {
|
|
718
|
-
clearTimeout(l),
|
|
719
|
+
clearTimeout(l), G.error("WebSocket error"), a || (a = !0, o(), i(new L("WebSocket connection failed")));
|
|
719
720
|
}, this.ws.onclose = (h) => {
|
|
720
|
-
if (this.clearKeepaliveTimeout(), !
|
|
721
|
-
a = !0, o(),
|
|
721
|
+
if (this.clearKeepaliveTimeout(), !n && !a) {
|
|
722
|
+
a = !0, o(), i(new L("WebSocket connection closed before opening"));
|
|
722
723
|
return;
|
|
723
724
|
}
|
|
724
|
-
|
|
725
|
-
|
|
725
|
+
if (this.isClosed)
|
|
726
|
+
return;
|
|
727
|
+
const N = h.wasClean && (h.code === 1e3 || h.code === 1001), _ = h.code === 1e3 || h.code === 1001, P = h.reason || `code=${h.code}`;
|
|
728
|
+
this.callbacks.onClose(P, N, _);
|
|
726
729
|
}, this.ws.onmessage = (h) => {
|
|
727
730
|
this.handleProtocolMessage(new Uint8Array(h.data));
|
|
728
731
|
};
|
|
729
732
|
});
|
|
730
733
|
}
|
|
731
734
|
send(e) {
|
|
732
|
-
this.ws?.readyState === WebSocket.OPEN ? this.ws.send(e) :
|
|
735
|
+
this.ws?.readyState === WebSocket.OPEN ? this.ws.send(e) : G.warn("Cannot send: WebSocket not connected");
|
|
733
736
|
}
|
|
734
737
|
close() {
|
|
735
|
-
this.clearKeepaliveTimeout(), this.ws && (this.ws.close(1e3, "Client closing"), this.ws = null);
|
|
738
|
+
this.isClosed = !0, this.clearKeepaliveTimeout(), this.ws && (this.ws.close(1e3, "Client closing"), this.ws = null);
|
|
736
739
|
}
|
|
737
740
|
/**
|
|
738
741
|
* Get or create a cached keepalive response message.
|
|
@@ -742,37 +745,38 @@ class Rt {
|
|
|
742
745
|
}
|
|
743
746
|
handleProtocolMessage(e) {
|
|
744
747
|
try {
|
|
745
|
-
if (X(e).opcode ===
|
|
748
|
+
if (X(e).opcode === d.KEEPALIVE_REQUEST) {
|
|
746
749
|
this.send(this.getKeepaliveResponse()), this.resetKeepaliveTimeout();
|
|
747
750
|
return;
|
|
748
751
|
}
|
|
749
752
|
this.resetKeepaliveTimeout(), this.callbacks.onProtocolMessage(e);
|
|
750
|
-
} catch (
|
|
751
|
-
|
|
753
|
+
} catch (s) {
|
|
754
|
+
G.error("Failed to process protocol message:", s), this.callbacks.onError(s instanceof Error ? s : new Error(String(s)));
|
|
752
755
|
}
|
|
753
756
|
}
|
|
754
757
|
resetKeepaliveTimeout() {
|
|
755
758
|
this.clearKeepaliveTimeout(), this.keepaliveTimeout = setTimeout(() => {
|
|
756
|
-
|
|
759
|
+
G.error(`No keepalive received in ${this.keepaliveTimeoutMs}ms, closing connection`), this.callbacks.onError(new z(this.keepaliveTimeoutMs)), this.close();
|
|
757
760
|
}, this.keepaliveTimeoutMs);
|
|
758
761
|
}
|
|
759
762
|
clearKeepaliveTimeout() {
|
|
760
763
|
this.keepaliveTimeout && (clearTimeout(this.keepaliveTimeout), this.keepaliveTimeout = null);
|
|
761
764
|
}
|
|
762
765
|
}
|
|
763
|
-
const
|
|
764
|
-
function
|
|
766
|
+
const y = F("WebTransportTransport"), q = 4, yt = 65536;
|
|
767
|
+
function st() {
|
|
765
768
|
return typeof WebTransport < "u";
|
|
766
769
|
}
|
|
767
|
-
class
|
|
770
|
+
class St {
|
|
768
771
|
transport = null;
|
|
769
772
|
stream = null;
|
|
770
773
|
reader = null;
|
|
771
774
|
writer = null;
|
|
772
775
|
keepaliveTimeout = null;
|
|
773
776
|
readLoopActive = !1;
|
|
777
|
+
isClosed = !1;
|
|
774
778
|
// Grow-only receive buffer with offset/length tracking to minimize allocations
|
|
775
|
-
receiveBuffer = new Uint8Array(
|
|
779
|
+
receiveBuffer = new Uint8Array(yt);
|
|
776
780
|
receiveBufferOffset = 0;
|
|
777
781
|
receiveBufferLength = 0;
|
|
778
782
|
// Cached DataView to avoid allocation per message
|
|
@@ -789,30 +793,31 @@ class yt {
|
|
|
789
793
|
get isConnected() {
|
|
790
794
|
return this.transport !== null && this.writer !== null;
|
|
791
795
|
}
|
|
792
|
-
async connect(e,
|
|
793
|
-
if (!
|
|
796
|
+
async connect(e, s) {
|
|
797
|
+
if (!st())
|
|
794
798
|
throw new L("WebTransport is not supported in this browser");
|
|
799
|
+
this.isClosed = !1;
|
|
795
800
|
try {
|
|
796
|
-
this.transport = new WebTransport(e), await this.transport.ready,
|
|
801
|
+
this.transport = new WebTransport(e), await this.transport.ready, y.debug(`Connected to WebTransport entrypoint: ${e}`), this.transport.closed.then(() => {
|
|
797
802
|
this.handleClose("Connection closed", !0);
|
|
798
|
-
}).catch((
|
|
799
|
-
|
|
800
|
-
}), this.stream = await this.transport.createBidirectionalStream(), this.reader = this.stream.readable.getReader(), this.writer = this.stream.writable.getWriter(), await this.writer.write(
|
|
801
|
-
} catch (
|
|
802
|
-
throw this.cleanup(), new L(`Failed to connect WebTransport: ${
|
|
803
|
+
}).catch((r) => {
|
|
804
|
+
y.error("WebTransport connection closed with error:", r), this.handleClose(r.message || "Connection error", !1);
|
|
805
|
+
}), this.stream = await this.transport.createBidirectionalStream(), this.reader = this.stream.readable.getReader(), this.writer = this.stream.writable.getWriter(), await this.writer.write(s), this.resetKeepaliveTimeout(), this.startReadLoop();
|
|
806
|
+
} catch (r) {
|
|
807
|
+
throw this.cleanup(), new L(`Failed to connect WebTransport: ${r}`, r instanceof Error ? r : void 0);
|
|
803
808
|
}
|
|
804
809
|
}
|
|
805
810
|
send(e) {
|
|
806
811
|
if (!this.writer) {
|
|
807
|
-
|
|
812
|
+
y.warn("Cannot send: WebTransport not connected");
|
|
808
813
|
return;
|
|
809
814
|
}
|
|
810
|
-
this.writer.write(e).catch((
|
|
811
|
-
|
|
815
|
+
this.writer.write(e).catch((s) => {
|
|
816
|
+
y.error("Failed to send protocol message:", s), this.callbacks.onError(s instanceof Error ? s : new Error(String(s)));
|
|
812
817
|
});
|
|
813
818
|
}
|
|
814
819
|
close() {
|
|
815
|
-
this.clearKeepaliveTimeout(), this.readLoopActive = !1, this.cleanup();
|
|
820
|
+
this.isClosed = !0, this.clearKeepaliveTimeout(), this.readLoopActive = !1, this.cleanup();
|
|
816
821
|
}
|
|
817
822
|
/**
|
|
818
823
|
* Start the read loop to receive messages.
|
|
@@ -822,13 +827,14 @@ class yt {
|
|
|
822
827
|
this.readLoopActive = !0;
|
|
823
828
|
try {
|
|
824
829
|
for (; this.readLoopActive && this.reader; ) {
|
|
825
|
-
const { value: e, done:
|
|
826
|
-
if (
|
|
830
|
+
const { value: e, done: s } = await this.reader.read();
|
|
831
|
+
if (s)
|
|
827
832
|
break;
|
|
828
833
|
e && (this.appendToBuffer(e), this.processBufferedMessages());
|
|
829
834
|
}
|
|
835
|
+
this.readLoopActive && this.handleClose("Stream ended", !1);
|
|
830
836
|
} catch (e) {
|
|
831
|
-
this.readLoopActive && (
|
|
837
|
+
this.readLoopActive && (y.error("Read loop error:", e), this.callbacks.onError(e instanceof Error ? e : new Error(String(e))));
|
|
832
838
|
}
|
|
833
839
|
}
|
|
834
840
|
}
|
|
@@ -837,13 +843,13 @@ class yt {
|
|
|
837
843
|
* Compacts when offset exceeds half capacity and data is sparse.
|
|
838
844
|
*/
|
|
839
845
|
appendToBuffer(e) {
|
|
840
|
-
const
|
|
841
|
-
if (
|
|
842
|
-
if (
|
|
843
|
-
const
|
|
844
|
-
|
|
846
|
+
const s = this.receiveBufferLength + e.length, r = this.receiveBufferOffset + this.receiveBufferLength;
|
|
847
|
+
if (r + e.length > this.receiveBuffer.length)
|
|
848
|
+
if (s > this.receiveBuffer.length) {
|
|
849
|
+
const i = Math.max(s, this.receiveBuffer.length * 2), n = new Uint8Array(i);
|
|
850
|
+
n.set(this.receiveBuffer.subarray(this.receiveBufferOffset, r)), this.receiveBuffer = n, this.receiveBufferOffset = 0, this.receiveDataViewBuffer = null;
|
|
845
851
|
} else
|
|
846
|
-
this.receiveBuffer.copyWithin(0, this.receiveBufferOffset,
|
|
852
|
+
this.receiveBuffer.copyWithin(0, this.receiveBufferOffset, r), this.receiveBufferOffset = 0;
|
|
847
853
|
this.receiveBuffer.set(e, this.receiveBufferOffset + this.receiveBufferLength), this.receiveBufferLength += e.length;
|
|
848
854
|
}
|
|
849
855
|
/**
|
|
@@ -867,15 +873,15 @@ class yt {
|
|
|
867
873
|
processBufferedMessages() {
|
|
868
874
|
const e = this.getReceiveDataView();
|
|
869
875
|
for (; this.receiveBufferLength >= q; ) {
|
|
870
|
-
const
|
|
871
|
-
if (
|
|
872
|
-
|
|
876
|
+
const s = e.getUint32(this.receiveBufferOffset, !0);
|
|
877
|
+
if (s < q) {
|
|
878
|
+
y.error(`Invalid message length: ${s}`), this.callbacks.onError(new Error(`Invalid protocol message length: ${s}`)), this.receiveBufferOffset = 0, this.receiveBufferLength = 0;
|
|
873
879
|
return;
|
|
874
880
|
}
|
|
875
|
-
if (this.receiveBufferLength <
|
|
881
|
+
if (this.receiveBufferLength < s)
|
|
876
882
|
return;
|
|
877
|
-
const
|
|
878
|
-
this.receiveBufferOffset +=
|
|
883
|
+
const r = this.receiveBuffer.subarray(this.receiveBufferOffset, this.receiveBufferOffset + s);
|
|
884
|
+
this.receiveBufferOffset += s, this.receiveBufferLength -= s, this.handleProtocolMessage(r);
|
|
879
885
|
}
|
|
880
886
|
this.receiveBufferLength === 0 && (this.receiveBufferOffset = 0);
|
|
881
887
|
}
|
|
@@ -884,27 +890,27 @@ class yt {
|
|
|
884
890
|
*/
|
|
885
891
|
handleProtocolMessage(e) {
|
|
886
892
|
try {
|
|
887
|
-
if (X(e).opcode ===
|
|
893
|
+
if (X(e).opcode === d.KEEPALIVE_REQUEST) {
|
|
888
894
|
this.send(this.getKeepaliveResponse()), this.resetKeepaliveTimeout();
|
|
889
895
|
return;
|
|
890
896
|
}
|
|
891
897
|
this.resetKeepaliveTimeout(), this.callbacks.onProtocolMessage(e);
|
|
892
|
-
} catch (
|
|
893
|
-
|
|
898
|
+
} catch (s) {
|
|
899
|
+
y.error("Failed to process protocol message:", s), this.callbacks.onError(s instanceof Error ? s : new Error(String(s)));
|
|
894
900
|
}
|
|
895
901
|
}
|
|
896
902
|
/**
|
|
897
903
|
* Handle connection close.
|
|
898
904
|
*/
|
|
899
|
-
handleClose(e,
|
|
900
|
-
this.clearKeepaliveTimeout(), this.readLoopActive = !1, this.cleanup(), this.callbacks.onClose(e,
|
|
905
|
+
handleClose(e, s) {
|
|
906
|
+
this.isClosed || (this.isClosed = !0, this.clearKeepaliveTimeout(), this.readLoopActive = !1, this.cleanup(), this.callbacks.onClose(e, s, !1));
|
|
901
907
|
}
|
|
902
908
|
/**
|
|
903
909
|
* Reset the keepalive timeout.
|
|
904
910
|
*/
|
|
905
911
|
resetKeepaliveTimeout() {
|
|
906
912
|
this.clearKeepaliveTimeout(), this.keepaliveTimeout = setTimeout(() => {
|
|
907
|
-
|
|
913
|
+
y.error(`No keepalive received in ${this.keepaliveTimeoutMs}ms, closing connection`), this.callbacks.onError(new z(this.keepaliveTimeoutMs)), this.close();
|
|
908
914
|
}, this.keepaliveTimeoutMs);
|
|
909
915
|
}
|
|
910
916
|
/**
|
|
@@ -927,7 +933,7 @@ class yt {
|
|
|
927
933
|
}
|
|
928
934
|
}
|
|
929
935
|
const D = F("Channel");
|
|
930
|
-
class
|
|
936
|
+
class Ut {
|
|
931
937
|
state = "disconnected";
|
|
932
938
|
transport = null;
|
|
933
939
|
config;
|
|
@@ -978,6 +984,13 @@ class wt {
|
|
|
978
984
|
disconnect() {
|
|
979
985
|
this.transport && (this.transport.close(), this.transport = null), this.setState("disconnected");
|
|
980
986
|
}
|
|
987
|
+
/**
|
|
988
|
+
* Check transport health and trigger close if the connection is dead.
|
|
989
|
+
* Used after tab resume to detect WebSockets closed by the OS while suspended.
|
|
990
|
+
*/
|
|
991
|
+
checkHealth() {
|
|
992
|
+
this.state === "connected" && this.transport && !this.transport.isConnected && this.handleClose("Transport dead after tab resume", !1);
|
|
993
|
+
}
|
|
981
994
|
/**
|
|
982
995
|
* Send a protocol message through the channel.
|
|
983
996
|
*/
|
|
@@ -992,28 +1005,28 @@ class wt {
|
|
|
992
1005
|
* Connect the transport to the entrypoint.
|
|
993
1006
|
*/
|
|
994
1007
|
async connectTransport() {
|
|
995
|
-
const e = this.entrypoint,
|
|
1008
|
+
const e = this.entrypoint, s = {
|
|
996
1009
|
sessionId: this.config.sessionId,
|
|
997
1010
|
keepaliveTimeoutMs: this.config.keepaliveTimeoutMs,
|
|
998
1011
|
callbacks: {
|
|
999
|
-
onProtocolMessage: (
|
|
1000
|
-
onClose: (
|
|
1001
|
-
onError: (
|
|
1012
|
+
onProtocolMessage: (r) => this.handleProtocolMessage(r),
|
|
1013
|
+
onClose: (r, i, n) => this.handleClose(r, i, n),
|
|
1014
|
+
onError: (r) => this.handleError(r)
|
|
1002
1015
|
}
|
|
1003
1016
|
};
|
|
1004
1017
|
switch (e.Type) {
|
|
1005
|
-
case
|
|
1006
|
-
case
|
|
1007
|
-
this.transport = new Rt(
|
|
1018
|
+
case R.WebSocket:
|
|
1019
|
+
case R.WebSocketProxy:
|
|
1020
|
+
this.transport = new Rt(s);
|
|
1008
1021
|
break;
|
|
1009
|
-
case
|
|
1010
|
-
case
|
|
1011
|
-
if (!
|
|
1022
|
+
case R.WebTransport:
|
|
1023
|
+
case R.WebTransportProxy:
|
|
1024
|
+
if (!st())
|
|
1012
1025
|
throw new Error("WebTransport is not supported in this browser");
|
|
1013
|
-
this.transport = new
|
|
1026
|
+
this.transport = new St(s);
|
|
1014
1027
|
break;
|
|
1015
1028
|
default:
|
|
1016
|
-
throw new Error(`Unsupported entrypoint type: ${
|
|
1029
|
+
throw new Error(`Unsupported entrypoint type: ${R[e.Type]}`);
|
|
1017
1030
|
}
|
|
1018
1031
|
await this.transport.connect(e.Uri, e.AuthTicket);
|
|
1019
1032
|
}
|
|
@@ -1022,21 +1035,21 @@ class wt {
|
|
|
1022
1035
|
*/
|
|
1023
1036
|
handleProtocolMessage(e) {
|
|
1024
1037
|
try {
|
|
1025
|
-
const
|
|
1026
|
-
if ($(
|
|
1038
|
+
const s = e;
|
|
1039
|
+
if ($(s) === d.CORE_ON_SERVER_STOPPING) {
|
|
1027
1040
|
D.debug("Received server stopping message"), this.setState("stopped"), this.transport?.close();
|
|
1028
1041
|
return;
|
|
1029
1042
|
}
|
|
1030
|
-
this.config.onProtocolMessage?.(
|
|
1031
|
-
} catch (
|
|
1032
|
-
D.error("Failed to handle protocol message:",
|
|
1043
|
+
this.config.onProtocolMessage?.(s);
|
|
1044
|
+
} catch (s) {
|
|
1045
|
+
D.error("Failed to handle protocol message:", s), this.config.onError?.(s instanceof Error ? s : new Error(String(s)));
|
|
1033
1046
|
}
|
|
1034
1047
|
}
|
|
1035
1048
|
/**
|
|
1036
1049
|
* Handle transport close.
|
|
1037
1050
|
*/
|
|
1038
|
-
handleClose(e,
|
|
1039
|
-
this.transport = null, this.config.onClose?.(e,
|
|
1051
|
+
handleClose(e, s, r) {
|
|
1052
|
+
this.transport = null, this.config.onClose?.(e, s, r);
|
|
1040
1053
|
}
|
|
1041
1054
|
/**
|
|
1042
1055
|
* Handle transport error.
|
|
@@ -1051,16 +1064,19 @@ class wt {
|
|
|
1051
1064
|
this.state !== e && (this.state = e, this.config.onStateChange?.(e));
|
|
1052
1065
|
}
|
|
1053
1066
|
}
|
|
1054
|
-
const
|
|
1055
|
-
class
|
|
1067
|
+
const T = F("ChannelManager");
|
|
1068
|
+
class wt {
|
|
1056
1069
|
channels = /* @__PURE__ */ new Map();
|
|
1057
1070
|
// keyed by opcode group
|
|
1058
1071
|
activeType = null;
|
|
1059
1072
|
state = "idle";
|
|
1060
1073
|
reconnectAttempts = 0;
|
|
1074
|
+
stabilityTimer = null;
|
|
1061
1075
|
shouldReconnect = !0;
|
|
1062
1076
|
entrypoints = [];
|
|
1063
1077
|
abortController = null;
|
|
1078
|
+
demotedTypes = /* @__PURE__ */ new Set();
|
|
1079
|
+
connectionStable = !1;
|
|
1064
1080
|
config;
|
|
1065
1081
|
constructor(e) {
|
|
1066
1082
|
this.config = e;
|
|
@@ -1083,33 +1099,44 @@ class St {
|
|
|
1083
1099
|
async connect(e) {
|
|
1084
1100
|
if (this.state !== "idle" && this.state !== "offline")
|
|
1085
1101
|
throw new Error(`Cannot connect: already in state ${this.state}`);
|
|
1086
|
-
this.entrypoints = e, this.shouldReconnect = !0, this.reconnectAttempts = 0, this.abortController = new AbortController(), await this.connectInternal();
|
|
1102
|
+
this.entrypoints = e, this.shouldReconnect = !0, this.reconnectAttempts = 0, this.demotedTypes.clear(), this.connectionStable = !1, this.abortController = new AbortController(), await this.connectInternal();
|
|
1087
1103
|
}
|
|
1088
1104
|
/**
|
|
1089
1105
|
* Disconnect all channels.
|
|
1090
1106
|
*/
|
|
1091
1107
|
disconnect() {
|
|
1092
|
-
this.shouldReconnect = !1, this.abortController?.abort(), this.abortController = null, this.disconnectAll(), this.setState("idle");
|
|
1108
|
+
this.shouldReconnect = !1, this.clearStabilityTimer(), this.abortController?.abort(), this.abortController = null, this.disconnectAll(), this.setState("idle");
|
|
1093
1109
|
}
|
|
1094
1110
|
/**
|
|
1095
1111
|
* Send a protocol message to the appropriate channel.
|
|
1096
1112
|
* The opcode group is extracted from the message automatically.
|
|
1097
1113
|
*/
|
|
1098
1114
|
sendProtocolMessage(e) {
|
|
1099
|
-
const
|
|
1100
|
-
for (const [
|
|
1101
|
-
if (
|
|
1102
|
-
|
|
1115
|
+
const s = W(e);
|
|
1116
|
+
for (const [r, i] of this.channels)
|
|
1117
|
+
if (r & s) {
|
|
1118
|
+
i.send(e);
|
|
1103
1119
|
return;
|
|
1104
1120
|
}
|
|
1105
|
-
|
|
1121
|
+
T.warn("No channel found for message");
|
|
1106
1122
|
}
|
|
1107
1123
|
/**
|
|
1108
1124
|
* Send a protocol message to all channels (for broadcast messages).
|
|
1109
1125
|
*/
|
|
1110
1126
|
sendToAll(e) {
|
|
1111
|
-
for (const
|
|
1112
|
-
|
|
1127
|
+
for (const s of this.channels.values())
|
|
1128
|
+
s.send(e);
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Check health of all channels.
|
|
1132
|
+
* Used after tab resume to detect WebSockets closed by the OS while suspended.
|
|
1133
|
+
* Only checks when connected — non-sudden disconnects (SDK-initiated or server
|
|
1134
|
+
* stopping) clear the channels and transition to idle/stopped before this runs.
|
|
1135
|
+
*/
|
|
1136
|
+
checkHealth() {
|
|
1137
|
+
if (this.state === "connected")
|
|
1138
|
+
for (const e of this.channels.values())
|
|
1139
|
+
e.checkHealth();
|
|
1113
1140
|
}
|
|
1114
1141
|
/**
|
|
1115
1142
|
* Internal connect implementation.
|
|
@@ -1117,39 +1144,43 @@ class St {
|
|
|
1117
1144
|
*/
|
|
1118
1145
|
async connectInternal(e = !1) {
|
|
1119
1146
|
this.setState("connecting");
|
|
1120
|
-
let
|
|
1147
|
+
let s = this.entrypoints;
|
|
1121
1148
|
if (this.config.webRtcEnabled) {
|
|
1122
|
-
|
|
1149
|
+
T.debug(`WebRTC enabled, filtering entrypoints (total: ${this.entrypoints.length})`);
|
|
1123
1150
|
for (const a of this.entrypoints)
|
|
1124
|
-
|
|
1125
|
-
const
|
|
1126
|
-
|
|
1127
|
-
if (a.Type ===
|
|
1128
|
-
return
|
|
1151
|
+
T.debug(` Entrypoint: type=${a.Type} fromServer=0x${a.OpcodeGroupsFromServer.toString(16)} toServer=0x${a.OpcodeGroupsToServer.toString(16)} uri=${a.Uri}`);
|
|
1152
|
+
const n = d.GROUP_AUDIO | d.GROUP_VIDEO;
|
|
1153
|
+
s = this.entrypoints.filter((a) => {
|
|
1154
|
+
if (a.Type === R.WebRTC)
|
|
1155
|
+
return T.debug(` Filtered out WebRTC entrypoint (type=${a.Type})`), !1;
|
|
1129
1156
|
const o = a.OpcodeGroupsFromServer | a.OpcodeGroupsToServer;
|
|
1130
|
-
return (o & ~
|
|
1131
|
-
}),
|
|
1157
|
+
return (o & ~n) === 0 ? (T.debug(` Filtered out audio/video-only entrypoint (type=${a.Type}, groups=0x${o.toString(16)})`), !1) : !0;
|
|
1158
|
+
}), T.debug(`After filtering: ${s.length} entrypoints remain for WS/WT channels`);
|
|
1132
1159
|
}
|
|
1133
|
-
const
|
|
1134
|
-
if (
|
|
1160
|
+
const r = this.groupByType(s);
|
|
1161
|
+
if (r.size === 0)
|
|
1135
1162
|
throw this.setState("offline"), new Error("No entrypoints available");
|
|
1136
|
-
let
|
|
1163
|
+
let i;
|
|
1137
1164
|
if (this.config.orderedEndpointTypes && this.config.orderedEndpointTypes.length > 0) {
|
|
1138
|
-
const
|
|
1139
|
-
|
|
1140
|
-
} else this.config.endpointSelector ?
|
|
1141
|
-
|
|
1165
|
+
const n = new Set(r.keys());
|
|
1166
|
+
i = this.config.orderedEndpointTypes.filter((a) => n.has(a));
|
|
1167
|
+
} else this.config.endpointSelector ? i = this.config.endpointSelector.getOrderedTypes(r) : i = Array.from(r.keys());
|
|
1168
|
+
if (this.demotedTypes.size > 0) {
|
|
1169
|
+
const n = i.filter((o) => !this.demotedTypes.has(o)), a = i.filter((o) => this.demotedTypes.has(o));
|
|
1170
|
+
i = [...n, ...a];
|
|
1171
|
+
}
|
|
1172
|
+
for (const n of i) {
|
|
1142
1173
|
if (!this.shouldReconnect)
|
|
1143
1174
|
return;
|
|
1144
|
-
const a =
|
|
1175
|
+
const a = r.get(n);
|
|
1145
1176
|
try {
|
|
1146
|
-
await this.connectAllChannels(a), this.config.endpointSelector?.rememberWorkingType(
|
|
1177
|
+
await this.connectAllChannels(a), this.config.endpointSelector?.rememberWorkingType(n), this.config.onRememberWorkingType?.(n), this.activeType = n, this.startStabilityTimer(), this.setState("connected");
|
|
1147
1178
|
return;
|
|
1148
1179
|
} catch (o) {
|
|
1149
|
-
|
|
1180
|
+
T.warn(`Failed to connect using ${R[n]}: ${o}`), this.disconnectAll();
|
|
1150
1181
|
}
|
|
1151
1182
|
}
|
|
1152
|
-
throw
|
|
1183
|
+
throw T.error("All endpoint types failed"), e || this.setState("offline"), new Error("Failed to connect using any endpoint type");
|
|
1153
1184
|
}
|
|
1154
1185
|
/**
|
|
1155
1186
|
* Connect all channels for a given endpoint type in parallel.
|
|
@@ -1157,91 +1188,106 @@ class St {
|
|
|
1157
1188
|
async connectAllChannels(e) {
|
|
1158
1189
|
if (e.length === 0)
|
|
1159
1190
|
throw new Error("No entrypoints to connect");
|
|
1160
|
-
const
|
|
1161
|
-
if (
|
|
1162
|
-
const
|
|
1163
|
-
throw new Error(`${
|
|
1191
|
+
const r = (await Promise.allSettled(e.map((i) => this.connectChannel(i)))).filter((i) => i.status === "rejected");
|
|
1192
|
+
if (r.length > 0) {
|
|
1193
|
+
const i = r.map((n) => n.reason);
|
|
1194
|
+
throw new Error(`${r.length} channel(s) failed: ${i.join(", ")}`);
|
|
1164
1195
|
}
|
|
1165
1196
|
}
|
|
1166
1197
|
/**
|
|
1167
1198
|
* Connect a single channel.
|
|
1168
1199
|
*/
|
|
1169
1200
|
async connectChannel(e) {
|
|
1170
|
-
const
|
|
1201
|
+
const s = new Ut({
|
|
1171
1202
|
entrypoint: e,
|
|
1172
1203
|
sessionId: this.config.sessionId,
|
|
1173
1204
|
keepaliveTimeoutMs: this.config.keepaliveTimeoutMs,
|
|
1174
|
-
onProtocolMessage: (
|
|
1175
|
-
this.config.onProtocolMessage?.(
|
|
1205
|
+
onProtocolMessage: (r) => {
|
|
1206
|
+
this.config.onProtocolMessage?.(r);
|
|
1176
1207
|
},
|
|
1177
|
-
onStateChange: (
|
|
1178
|
-
this.handleChannelStateChange(e.OpcodeGroupsFromServer,
|
|
1208
|
+
onStateChange: (r) => {
|
|
1209
|
+
this.handleChannelStateChange(e.OpcodeGroupsFromServer, r);
|
|
1179
1210
|
},
|
|
1180
|
-
onClose: (
|
|
1181
|
-
this.handleChannelClose(e.OpcodeGroupsFromServer,
|
|
1211
|
+
onClose: (r, i, n) => {
|
|
1212
|
+
this.handleChannelClose(e.OpcodeGroupsFromServer, r, i, n);
|
|
1182
1213
|
},
|
|
1183
|
-
onError: (
|
|
1184
|
-
this.config.onError?.(
|
|
1214
|
+
onError: (r) => {
|
|
1215
|
+
this.config.onError?.(r);
|
|
1185
1216
|
}
|
|
1186
1217
|
});
|
|
1187
|
-
await
|
|
1218
|
+
await s.connect(), this.channels.set(e.OpcodeGroupsFromServer, s);
|
|
1188
1219
|
}
|
|
1189
1220
|
/**
|
|
1190
1221
|
* Group entrypoints by type.
|
|
1191
1222
|
*/
|
|
1192
1223
|
groupByType(e) {
|
|
1193
|
-
const
|
|
1194
|
-
for (const
|
|
1195
|
-
const
|
|
1196
|
-
|
|
1224
|
+
const s = /* @__PURE__ */ new Map();
|
|
1225
|
+
for (const r of e) {
|
|
1226
|
+
const i = s.get(r.Type) ?? [];
|
|
1227
|
+
i.push(r), s.set(r.Type, i);
|
|
1197
1228
|
}
|
|
1198
|
-
return
|
|
1229
|
+
return s;
|
|
1199
1230
|
}
|
|
1200
1231
|
/**
|
|
1201
1232
|
* Handle channel state change.
|
|
1202
1233
|
*/
|
|
1203
|
-
handleChannelStateChange(e,
|
|
1204
|
-
|
|
1234
|
+
handleChannelStateChange(e, s) {
|
|
1235
|
+
s === "stopped" && (this.shouldReconnect = !1, this.disconnectAll(), this.setState("stopped"));
|
|
1205
1236
|
}
|
|
1206
1237
|
/**
|
|
1207
1238
|
* Handle channel close.
|
|
1208
1239
|
*/
|
|
1209
|
-
handleChannelClose(e,
|
|
1210
|
-
if (!(this.state === "idle" || this.state === "stopped" || this.state === "offline")) {
|
|
1211
|
-
if (
|
|
1212
|
-
|
|
1240
|
+
handleChannelClose(e, s, r, i) {
|
|
1241
|
+
if (!(this.state === "idle" || this.state === "stopped" || this.state === "offline") && this.channels.has(e)) {
|
|
1242
|
+
if (i) {
|
|
1243
|
+
T.debug("Channel closed by server"), this.shouldReconnect = !1, this.disconnectAll(), this.setState("stopped");
|
|
1213
1244
|
return;
|
|
1214
1245
|
}
|
|
1215
|
-
this.state === "connected" && (
|
|
1246
|
+
this.state === "connected" && (!this.connectionStable && this.activeType !== null && (T.warn(`Connection unstable with ${R[this.activeType]}, demoting`), this.demotedTypes.add(this.activeType)), T.error("Channel closed unexpectedly, attempting reconnect"), this.disconnectAll(), this.attemptReconnect());
|
|
1216
1247
|
}
|
|
1217
1248
|
}
|
|
1218
1249
|
/**
|
|
1219
|
-
* Attempt to reconnect with
|
|
1250
|
+
* Attempt to reconnect with fixed-interval retry.
|
|
1251
|
+
* First attempt is immediate, subsequent attempts wait reconnectBackoffMs.
|
|
1220
1252
|
*/
|
|
1221
1253
|
async attemptReconnect() {
|
|
1222
|
-
if (
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
return;
|
|
1227
|
-
}
|
|
1228
|
-
this.setState("reconnecting"), this.reconnectAttempts++;
|
|
1229
|
-
const e = this.config.reconnectBackoffMs * Math.pow(2, this.reconnectAttempts - 1);
|
|
1230
|
-
if (I.info(`Reconnecting in ${e}ms (attempt ${this.reconnectAttempts}/${this.config.maxReconnectAttempts})`), await ct(e, this.abortController?.signal), !!this.shouldReconnect)
|
|
1231
|
-
try {
|
|
1232
|
-
await this.connectInternal(!0);
|
|
1233
|
-
} catch (r) {
|
|
1234
|
-
I.error("Reconnect failed:", r), await this.attemptReconnect();
|
|
1254
|
+
if (this.shouldReconnect) {
|
|
1255
|
+
if (this.reconnectAttempts >= this.config.maxReconnectAttempts) {
|
|
1256
|
+
T.error(`Max reconnect attempts (${this.config.maxReconnectAttempts}) reached`), this.setState("offline"), this.config.onError?.(new ct(this.config.maxReconnectAttempts));
|
|
1257
|
+
return;
|
|
1235
1258
|
}
|
|
1259
|
+
if (this.setState("reconnecting"), this.reconnectAttempts++, this.reconnectAttempts > 1 ? (T.info(`Reconnecting in ${this.config.reconnectBackoffMs}ms (attempt ${this.reconnectAttempts}/${this.config.maxReconnectAttempts})`), await It(this.config.reconnectBackoffMs, this.abortController?.signal)) : T.info(`Reconnecting immediately (attempt ${this.reconnectAttempts}/${this.config.maxReconnectAttempts})`), !!this.shouldReconnect)
|
|
1260
|
+
try {
|
|
1261
|
+
await this.connectInternal(!0);
|
|
1262
|
+
} catch (e) {
|
|
1263
|
+
T.error("Reconnect failed:", e), await this.attemptReconnect();
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1236
1266
|
}
|
|
1237
1267
|
/**
|
|
1238
1268
|
* Disconnect all channels.
|
|
1239
1269
|
*/
|
|
1240
1270
|
disconnectAll() {
|
|
1271
|
+
this.clearStabilityTimer();
|
|
1241
1272
|
for (const e of this.channels.values())
|
|
1242
1273
|
e.disconnect();
|
|
1243
1274
|
this.channels.clear(), this.activeType = null;
|
|
1244
1275
|
}
|
|
1276
|
+
/**
|
|
1277
|
+
* Start stability timer that resets reconnect attempts after the connection
|
|
1278
|
+
* survives one keepalive timeout period without dying.
|
|
1279
|
+
*/
|
|
1280
|
+
startStabilityTimer() {
|
|
1281
|
+
this.clearStabilityTimer(), this.connectionStable = !1, this.stabilityTimer = setTimeout(() => {
|
|
1282
|
+
this.stabilityTimer = null, this.reconnectAttempts = 0, this.connectionStable = !0, this.demotedTypes.clear();
|
|
1283
|
+
}, this.config.keepaliveTimeoutMs);
|
|
1284
|
+
}
|
|
1285
|
+
/**
|
|
1286
|
+
* Clear the stability timer.
|
|
1287
|
+
*/
|
|
1288
|
+
clearStabilityTimer() {
|
|
1289
|
+
this.stabilityTimer && (clearTimeout(this.stabilityTimer), this.stabilityTimer = null);
|
|
1290
|
+
}
|
|
1245
1291
|
/**
|
|
1246
1292
|
* Update and notify state change.
|
|
1247
1293
|
*/
|
|
@@ -1249,39 +1295,39 @@ class St {
|
|
|
1249
1295
|
this.state !== e && (this.state = e, this.config.onStateChange?.(e));
|
|
1250
1296
|
}
|
|
1251
1297
|
}
|
|
1252
|
-
const
|
|
1298
|
+
const rt = F("ProtocolWorker"), w = (t, e) => {
|
|
1253
1299
|
self.postMessage(t, e ?? []);
|
|
1254
1300
|
};
|
|
1255
|
-
let
|
|
1256
|
-
const
|
|
1301
|
+
let A = null, H, u = null;
|
|
1302
|
+
const U = [], C = [], v = /* @__PURE__ */ new Map(), f = [], I = [], S = /* @__PURE__ */ new Map(), x = [];
|
|
1257
1303
|
function Y() {
|
|
1258
1304
|
try {
|
|
1259
|
-
|
|
1305
|
+
A?.disconnect();
|
|
1260
1306
|
} catch (t) {
|
|
1261
|
-
|
|
1307
|
+
rt.warn(`Failed to disconnect channel manager: ${t}`);
|
|
1262
1308
|
}
|
|
1263
|
-
|
|
1264
|
-
for (let t = 0; t <
|
|
1309
|
+
A = null;
|
|
1310
|
+
for (let t = 0; t < C.length; t++)
|
|
1265
1311
|
try {
|
|
1266
|
-
|
|
1312
|
+
C[t].port.close();
|
|
1267
1313
|
} catch {
|
|
1268
1314
|
}
|
|
1269
|
-
|
|
1270
|
-
for (let t = 0; t <
|
|
1315
|
+
U.length = 0, C.length = 0, v.clear();
|
|
1316
|
+
for (let t = 0; t < I.length; t++)
|
|
1271
1317
|
try {
|
|
1272
|
-
|
|
1318
|
+
I[t].port.close();
|
|
1273
1319
|
} catch {
|
|
1274
1320
|
}
|
|
1275
|
-
|
|
1321
|
+
f.length = 0, I.length = 0, S.clear();
|
|
1276
1322
|
}
|
|
1277
1323
|
function B(t) {
|
|
1278
1324
|
const e = t instanceof Error ? t : new Error(String(t));
|
|
1279
|
-
|
|
1325
|
+
w({ type: "error", error: { name: e.name, message: e.message, stack: e.stack } });
|
|
1280
1326
|
}
|
|
1281
1327
|
function gt() {
|
|
1282
1328
|
let t = 0;
|
|
1283
|
-
for (let e = 0; e <
|
|
1284
|
-
t |=
|
|
1329
|
+
for (let e = 0; e < C.length; e++)
|
|
1330
|
+
t |= C[e].opcodeGroupsMask;
|
|
1285
1331
|
return t;
|
|
1286
1332
|
}
|
|
1287
1333
|
function Lt(t) {
|
|
@@ -1290,36 +1336,36 @@ function Lt(t) {
|
|
|
1290
1336
|
const e = W(t);
|
|
1291
1337
|
if ((e & H) !== 0)
|
|
1292
1338
|
return !0;
|
|
1293
|
-
const
|
|
1294
|
-
return (e &
|
|
1339
|
+
const s = gt();
|
|
1340
|
+
return (e & s) !== 0;
|
|
1295
1341
|
}
|
|
1296
|
-
function
|
|
1342
|
+
function mt(t) {
|
|
1297
1343
|
x.length = 0;
|
|
1298
|
-
for (let e = 0; e <
|
|
1299
|
-
const
|
|
1300
|
-
(
|
|
1344
|
+
for (let e = 0; e < C.length; e++) {
|
|
1345
|
+
const s = C[e];
|
|
1346
|
+
(s.opcodeGroupsMask & t) !== 0 && x.push(s.port);
|
|
1301
1347
|
}
|
|
1302
1348
|
return x;
|
|
1303
1349
|
}
|
|
1304
|
-
function
|
|
1350
|
+
function dt(t, e) {
|
|
1305
1351
|
return (W(t) & e) !== 0;
|
|
1306
1352
|
}
|
|
1307
|
-
function
|
|
1308
|
-
if (!
|
|
1353
|
+
function Pt(t, e) {
|
|
1354
|
+
if (!A || !e || typeof e != "object")
|
|
1309
1355
|
return;
|
|
1310
|
-
const
|
|
1311
|
-
if (!(
|
|
1356
|
+
const s = e;
|
|
1357
|
+
if (!(s.type !== "send" || !(s.message instanceof ArrayBuffer)))
|
|
1312
1358
|
try {
|
|
1313
|
-
const
|
|
1314
|
-
if (!
|
|
1359
|
+
const r = new Uint8Array(s.message);
|
|
1360
|
+
if (!dt(r, t))
|
|
1315
1361
|
return;
|
|
1316
|
-
|
|
1317
|
-
} catch (
|
|
1318
|
-
B(
|
|
1362
|
+
A.sendProtocolMessage(r), u && u.postMessage({ direction: "sent", message: Array.from(r) });
|
|
1363
|
+
} catch (r) {
|
|
1364
|
+
B(r);
|
|
1319
1365
|
}
|
|
1320
1366
|
}
|
|
1321
|
-
async function
|
|
1322
|
-
Y(),
|
|
1367
|
+
async function bt(t) {
|
|
1368
|
+
Y(), A = new wt({
|
|
1323
1369
|
sessionId: t.sessionId,
|
|
1324
1370
|
keepaliveTimeoutMs: t.keepaliveTimeoutMs,
|
|
1325
1371
|
reconnectBackoffMs: t.reconnectBackoffMs,
|
|
@@ -1327,76 +1373,76 @@ async function dt(t) {
|
|
|
1327
1373
|
orderedEndpointTypes: t.orderedEndpointTypes,
|
|
1328
1374
|
webRtcEnabled: t.webRtcEnabled,
|
|
1329
1375
|
onStateChange: (e) => {
|
|
1330
|
-
|
|
1376
|
+
w({ type: "state", state: e, activeType: A?.activeEndpointType ?? void 0 });
|
|
1331
1377
|
},
|
|
1332
1378
|
onRememberWorkingType: () => {
|
|
1333
|
-
|
|
1379
|
+
w({ type: "state", state: A?.managerState ?? "idle", activeType: A?.activeEndpointType ?? void 0 });
|
|
1334
1380
|
},
|
|
1335
1381
|
onError: (e) => {
|
|
1336
1382
|
B(e);
|
|
1337
1383
|
},
|
|
1338
1384
|
onProtocolMessage: (e) => {
|
|
1339
|
-
u && (u.postMessage({ direction: "received", message: Array.from(e) }), $(e) ===
|
|
1340
|
-
const
|
|
1341
|
-
if (!(!
|
|
1385
|
+
u && (u.postMessage({ direction: "received", message: Array.from(e) }), $(e) === d.ANALYTICS_LOGS && u.postMessage({ type: "serverLogs", message: Array.from(e) }));
|
|
1386
|
+
const s = W(e), r = Lt(e), i = mt(s);
|
|
1387
|
+
if (!(!r && i.length === 0))
|
|
1342
1388
|
try {
|
|
1343
|
-
const
|
|
1344
|
-
if (o && !
|
|
1389
|
+
const n = X(e), a = e.buffer instanceof ArrayBuffer && e.byteOffset === 0 && e.byteLength === e.buffer.byteLength, o = i.length > 0;
|
|
1390
|
+
if (o && !r && i.length === 1 && a) {
|
|
1345
1391
|
const l = e.buffer;
|
|
1346
|
-
|
|
1392
|
+
i[0].postMessage({ type: "protocol", message: l, headers: n }, [l]);
|
|
1347
1393
|
return;
|
|
1348
1394
|
}
|
|
1349
|
-
if (!o &&
|
|
1395
|
+
if (!o && r && a) {
|
|
1350
1396
|
const l = e.buffer;
|
|
1351
|
-
|
|
1397
|
+
w({ type: "protocol", message: l, headers: n }, [l]);
|
|
1352
1398
|
return;
|
|
1353
1399
|
}
|
|
1354
1400
|
if (o && a) {
|
|
1355
1401
|
const l = [];
|
|
1356
|
-
for (let _ = 1; _ <
|
|
1402
|
+
for (let _ = 1; _ < i.length; _++)
|
|
1357
1403
|
l.push(e.slice().buffer);
|
|
1358
|
-
const h =
|
|
1359
|
-
|
|
1360
|
-
for (let _ = 1; _ <
|
|
1361
|
-
|
|
1362
|
-
h &&
|
|
1404
|
+
const h = r ? e.slice().buffer : null, N = e.buffer;
|
|
1405
|
+
i[0].postMessage({ type: "protocol", message: N, headers: n }, [N]);
|
|
1406
|
+
for (let _ = 1; _ < i.length; _++)
|
|
1407
|
+
i[_].postMessage({ type: "protocol", message: l[_ - 1], headers: n }, [l[_ - 1]]);
|
|
1408
|
+
h && w({ type: "protocol", message: h, headers: n }, [h]);
|
|
1363
1409
|
return;
|
|
1364
1410
|
}
|
|
1365
1411
|
if (o)
|
|
1366
|
-
for (const l of
|
|
1412
|
+
for (const l of i) {
|
|
1367
1413
|
const h = e.slice().buffer;
|
|
1368
|
-
l.postMessage({ type: "protocol", message: h, headers:
|
|
1414
|
+
l.postMessage({ type: "protocol", message: h, headers: n }, [h]);
|
|
1369
1415
|
}
|
|
1370
|
-
if (
|
|
1416
|
+
if (r) {
|
|
1371
1417
|
const l = e.slice().buffer;
|
|
1372
|
-
|
|
1418
|
+
w({ type: "protocol", message: l, headers: n }, [l]);
|
|
1373
1419
|
}
|
|
1374
|
-
} catch (
|
|
1375
|
-
B(
|
|
1420
|
+
} catch (n) {
|
|
1421
|
+
B(n);
|
|
1376
1422
|
}
|
|
1377
1423
|
}
|
|
1378
|
-
}), await
|
|
1424
|
+
}), await A.connect(t.entrypoints);
|
|
1379
1425
|
}
|
|
1380
1426
|
self.addEventListener("message", (t) => {
|
|
1381
1427
|
const e = t.data;
|
|
1382
1428
|
if (e.type === "connect") {
|
|
1383
|
-
|
|
1384
|
-
|
|
1429
|
+
bt(e).catch((s) => {
|
|
1430
|
+
rt.error(`Failed to connect: ${s}`), B(s), Y();
|
|
1385
1431
|
});
|
|
1386
1432
|
return;
|
|
1387
1433
|
}
|
|
1388
1434
|
if (e.type === "disconnect") {
|
|
1389
|
-
Y(),
|
|
1435
|
+
Y(), w({ type: "state", state: "idle" });
|
|
1390
1436
|
return;
|
|
1391
1437
|
}
|
|
1392
1438
|
if (e.type === "send") {
|
|
1393
|
-
if (!
|
|
1439
|
+
if (!A)
|
|
1394
1440
|
return;
|
|
1395
1441
|
try {
|
|
1396
|
-
const
|
|
1397
|
-
|
|
1398
|
-
} catch (
|
|
1399
|
-
B(
|
|
1442
|
+
const s = new Uint8Array(e.message);
|
|
1443
|
+
A.sendProtocolMessage(s), u && u.postMessage({ direction: "sent", message: Array.from(s) });
|
|
1444
|
+
} catch (s) {
|
|
1445
|
+
B(s);
|
|
1400
1446
|
}
|
|
1401
1447
|
return;
|
|
1402
1448
|
}
|
|
@@ -1408,72 +1454,76 @@ self.addEventListener("message", (t) => {
|
|
|
1408
1454
|
e.enabled && !u ? u = new BroadcastChannel("ikon:devtools") : !e.enabled && u && (u.close(), u = null);
|
|
1409
1455
|
return;
|
|
1410
1456
|
}
|
|
1457
|
+
if (e.type === "checkHealth") {
|
|
1458
|
+
A?.checkHealth();
|
|
1459
|
+
return;
|
|
1460
|
+
}
|
|
1411
1461
|
if (e.type === "attachPort") {
|
|
1412
1462
|
try {
|
|
1413
1463
|
e.port.start?.();
|
|
1414
1464
|
} catch {
|
|
1415
1465
|
}
|
|
1416
|
-
const
|
|
1417
|
-
|
|
1466
|
+
const s = U.length;
|
|
1467
|
+
U.push(e.portId), C.push({ port: e.port, opcodeGroupsMask: e.opcodeGroupsMask }), v.set(e.portId, s);
|
|
1418
1468
|
return;
|
|
1419
1469
|
}
|
|
1420
1470
|
if (e.type === "detachPort") {
|
|
1421
|
-
const
|
|
1422
|
-
if (
|
|
1423
|
-
const
|
|
1471
|
+
const s = v.get(e.portId);
|
|
1472
|
+
if (s !== void 0) {
|
|
1473
|
+
const r = C[s];
|
|
1424
1474
|
try {
|
|
1425
|
-
|
|
1475
|
+
r.port.close();
|
|
1426
1476
|
} catch {
|
|
1427
1477
|
}
|
|
1428
|
-
const
|
|
1429
|
-
if (
|
|
1430
|
-
const
|
|
1431
|
-
|
|
1478
|
+
const i = U.length - 1;
|
|
1479
|
+
if (s !== i) {
|
|
1480
|
+
const n = U[i];
|
|
1481
|
+
U[s] = n, C[s] = C[i], v.set(n, s);
|
|
1432
1482
|
}
|
|
1433
|
-
|
|
1483
|
+
U.length--, C.length--, v.delete(e.portId);
|
|
1434
1484
|
}
|
|
1435
1485
|
return;
|
|
1436
1486
|
}
|
|
1437
1487
|
if (e.type === "attachSendPort") {
|
|
1438
|
-
const
|
|
1439
|
-
if (
|
|
1440
|
-
const
|
|
1488
|
+
const s = S.get(e.portId);
|
|
1489
|
+
if (s !== void 0) {
|
|
1490
|
+
const n = I[s];
|
|
1441
1491
|
try {
|
|
1442
|
-
|
|
1492
|
+
n.port.close();
|
|
1443
1493
|
} catch {
|
|
1444
1494
|
}
|
|
1445
|
-
const a =
|
|
1446
|
-
if (
|
|
1447
|
-
const o =
|
|
1448
|
-
|
|
1495
|
+
const a = f.length - 1;
|
|
1496
|
+
if (s !== a) {
|
|
1497
|
+
const o = f[a];
|
|
1498
|
+
f[s] = o, I[s] = I[a], S.set(o, s);
|
|
1449
1499
|
}
|
|
1450
|
-
|
|
1500
|
+
f.length--, I.length--, S.delete(e.portId);
|
|
1451
1501
|
}
|
|
1452
|
-
const
|
|
1453
|
-
|
|
1502
|
+
const r = { port: e.port, opcodeGroupsMask: e.opcodeGroupsMask }, i = f.length;
|
|
1503
|
+
f.push(e.portId), I.push(r), S.set(e.portId, i);
|
|
1454
1504
|
try {
|
|
1455
|
-
|
|
1505
|
+
r.port.start?.();
|
|
1456
1506
|
} catch {
|
|
1457
1507
|
}
|
|
1458
|
-
|
|
1459
|
-
|
|
1508
|
+
r.port.addEventListener("message", (n) => {
|
|
1509
|
+
Pt(r.opcodeGroupsMask, n.data);
|
|
1460
1510
|
});
|
|
1461
1511
|
return;
|
|
1462
1512
|
}
|
|
1463
1513
|
if (e.type === "detachSendPort") {
|
|
1464
|
-
const
|
|
1465
|
-
if (
|
|
1466
|
-
const
|
|
1514
|
+
const s = S.get(e.portId);
|
|
1515
|
+
if (s !== void 0) {
|
|
1516
|
+
const r = I[s];
|
|
1467
1517
|
try {
|
|
1468
|
-
|
|
1518
|
+
r.port.close();
|
|
1469
1519
|
} catch {
|
|
1470
1520
|
}
|
|
1471
|
-
const
|
|
1472
|
-
if (
|
|
1473
|
-
const
|
|
1474
|
-
|
|
1521
|
+
const i = f.length - 1;
|
|
1522
|
+
if (s !== i) {
|
|
1523
|
+
const n = f[i];
|
|
1524
|
+
f[s] = n, I[s] = I[i], S.set(n, s);
|
|
1475
1525
|
}
|
|
1476
|
-
|
|
1526
|
+
f.length--, I.length--, S.delete(e.portId);
|
|
1477
1527
|
}
|
|
1478
1528
|
return;
|
|
1479
1529
|
}
|