@ikonai/sdk 1.0.46 → 1.0.48
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-z-5Xst2M.js → protocol-worker-9F3vWnC8.js} +346 -363
- package/channel/channel-manager.d.ts +0 -10
- package/index.js +2129 -2142
- package/package.json +1 -1
|
@@ -3,23 +3,23 @@ function j(t) {
|
|
|
3
3
|
throw new Error("Protocol message too short");
|
|
4
4
|
return (t[4] | t[5] << 8 | t[6] << 16 | t[7] << 24) >>> 0;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function v(t) {
|
|
7
7
|
return j(t) & 4294901760;
|
|
8
8
|
}
|
|
9
9
|
function H(t) {
|
|
10
|
-
const e = It(t),
|
|
10
|
+
const e = It(t), n = 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 = n.getUint32(0, !0), s = n.getUint32(4, !0), i = n.getUint32(8, !0), o = n.getUint32(12, !0), a = n.getUint32(16, !0), E = n.getUint32(20, !0), _ = n.getUint8(24), l = n.getUint8(25), T = n.getUint8(26);
|
|
14
14
|
if (27 + E * 4 > e.length)
|
|
15
15
|
throw new Error("Protocol header exceeds payload length");
|
|
16
16
|
const c = [];
|
|
17
17
|
let g = 27;
|
|
18
18
|
for (let O = 0; O < E; O++)
|
|
19
|
-
c.push(
|
|
19
|
+
c.push(n.getUint32(g, !0)), g += 4;
|
|
20
20
|
return {
|
|
21
|
-
length:
|
|
22
|
-
opcode:
|
|
21
|
+
length: r,
|
|
22
|
+
opcode: s,
|
|
23
23
|
senderId: i,
|
|
24
24
|
trackId: o,
|
|
25
25
|
sequenceId: a,
|
|
@@ -29,9 +29,9 @@ function H(t) {
|
|
|
29
29
|
flags: T
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
function Et(t, e, r, s
|
|
32
|
+
function Et(t, e, n, r, s) {
|
|
33
33
|
const E = [], l = 27 + E.length * 4, T = l + e.length, S = new Uint8Array(T), c = new DataView(S.buffer);
|
|
34
|
-
c.setUint32(0, T, !0), c.setUint32(4, t >>> 0, !0), c.setUint32(8,
|
|
34
|
+
c.setUint32(0, T, !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, E.length >>> 0, !0), c.setUint8(24, n & 255), c.setUint8(25, 8), c.setUint8(26, 0);
|
|
35
35
|
let g = 27;
|
|
36
36
|
for (let O = 0; O < E.length; O++)
|
|
37
37
|
c.setUint32(g, E[O] >>> 0, !0), g += 4;
|
|
@@ -47,69 +47,69 @@ class G {
|
|
|
47
47
|
buffer = new D();
|
|
48
48
|
closed = !1;
|
|
49
49
|
cached;
|
|
50
|
-
writeInt32Field(e,
|
|
51
|
-
this.writeFixedField(e, 3, () => this.buffer.writeInt32(
|
|
50
|
+
writeInt32Field(e, n) {
|
|
51
|
+
this.writeFixedField(e, 3, () => this.buffer.writeInt32(n | 0));
|
|
52
52
|
}
|
|
53
|
-
writeUInt32Field(e,
|
|
54
|
-
this.writeFixedField(e, 5, () => this.buffer.writeUInt32(
|
|
53
|
+
writeUInt32Field(e, n) {
|
|
54
|
+
this.writeFixedField(e, 5, () => this.buffer.writeUInt32(n >>> 0));
|
|
55
55
|
}
|
|
56
|
-
writeInt64Field(e,
|
|
57
|
-
this.writeFixedField(e, 4, () => this.buffer.writeBigInt64(
|
|
56
|
+
writeInt64Field(e, n) {
|
|
57
|
+
this.writeFixedField(e, 4, () => this.buffer.writeBigInt64(n));
|
|
58
58
|
}
|
|
59
|
-
writeUInt64Field(e,
|
|
60
|
-
this.writeFixedField(e, 6, () => this.buffer.writeBigUInt64(
|
|
59
|
+
writeUInt64Field(e, n) {
|
|
60
|
+
this.writeFixedField(e, 6, () => this.buffer.writeBigUInt64(n));
|
|
61
61
|
}
|
|
62
|
-
writeFloat32Field(e,
|
|
63
|
-
this.writeFixedField(e, 7, () => this.buffer.writeFloat32(
|
|
62
|
+
writeFloat32Field(e, n) {
|
|
63
|
+
this.writeFixedField(e, 7, () => this.buffer.writeFloat32(n));
|
|
64
64
|
}
|
|
65
|
-
writeFloat64Field(e,
|
|
66
|
-
this.writeFixedField(e, 8, () => this.buffer.writeFloat64(
|
|
65
|
+
writeFloat64Field(e, n) {
|
|
66
|
+
this.writeFixedField(e, 8, () => this.buffer.writeFloat64(n));
|
|
67
67
|
}
|
|
68
|
-
writeBoolField(e,
|
|
69
|
-
this.writeFixedField(e, 2, () => this.buffer.writeByte(
|
|
68
|
+
writeBoolField(e, n) {
|
|
69
|
+
this.writeFixedField(e, 2, () => this.buffer.writeByte(n ? 1 : 0));
|
|
70
70
|
}
|
|
71
|
-
writeGuidField(e,
|
|
72
|
-
const
|
|
73
|
-
if (
|
|
71
|
+
writeGuidField(e, n) {
|
|
72
|
+
const r = n instanceof h ? n.asBytes() : n;
|
|
73
|
+
if (r.length !== 16)
|
|
74
74
|
throw new Error("Guid payload must be 16 bytes");
|
|
75
|
-
this.writeFixedField(e, 14, () => this.buffer.writeBytes(
|
|
75
|
+
this.writeFixedField(e, 14, () => this.buffer.writeBytes(r));
|
|
76
76
|
}
|
|
77
|
-
writeStringField(e,
|
|
78
|
-
const
|
|
79
|
-
this.writeVariableField(e, 12,
|
|
77
|
+
writeStringField(e, n) {
|
|
78
|
+
const r = W.encode(n ?? "");
|
|
79
|
+
this.writeVariableField(e, 12, r);
|
|
80
80
|
}
|
|
81
|
-
writeBinaryField(e,
|
|
82
|
-
this.writeVariableField(e, 13,
|
|
81
|
+
writeBinaryField(e, n) {
|
|
82
|
+
this.writeVariableField(e, 13, n);
|
|
83
83
|
}
|
|
84
|
-
writeObjectField(e,
|
|
85
|
-
const
|
|
86
|
-
s
|
|
87
|
-
const i =
|
|
84
|
+
writeObjectField(e, n, r) {
|
|
85
|
+
const s = new G(n);
|
|
86
|
+
r(s);
|
|
87
|
+
const i = s.finish();
|
|
88
88
|
this.writeVariableField(e, 11, i);
|
|
89
89
|
}
|
|
90
|
-
writeArrayField(e,
|
|
91
|
-
const
|
|
92
|
-
s
|
|
93
|
-
const i =
|
|
90
|
+
writeArrayField(e, n, r) {
|
|
91
|
+
const s = new Y(n);
|
|
92
|
+
r(s);
|
|
93
|
+
const i = s.finish();
|
|
94
94
|
this.writeVariableField(e, 9, i);
|
|
95
95
|
}
|
|
96
|
-
writeDictionaryField(e, r, s
|
|
97
|
-
const i = new z(
|
|
98
|
-
|
|
96
|
+
writeDictionaryField(e, n, r, s) {
|
|
97
|
+
const i = new z(n, r);
|
|
98
|
+
s(i);
|
|
99
99
|
const o = i.finish();
|
|
100
100
|
this.writeVariableField(e, 10, o);
|
|
101
101
|
}
|
|
102
102
|
finish() {
|
|
103
103
|
return this.closed || (this.buffer.writeByte(ht), this.closed = !0, this.cached = this.buffer.toUint8Array()), this.cached;
|
|
104
104
|
}
|
|
105
|
-
writeFixedField(e,
|
|
106
|
-
this.writeFieldHeader(e,
|
|
105
|
+
writeFixedField(e, n, r) {
|
|
106
|
+
this.writeFieldHeader(e, n, 0), r();
|
|
107
107
|
}
|
|
108
|
-
writeVariableField(e,
|
|
109
|
-
this.writeFieldHeader(e,
|
|
108
|
+
writeVariableField(e, n, r) {
|
|
109
|
+
this.writeFieldHeader(e, n, r.length), this.buffer.writeBytes(r);
|
|
110
110
|
}
|
|
111
|
-
writeFieldHeader(e,
|
|
112
|
-
this.buffer.writeUInt32(e >>> 0), this.buffer.writeByte(K(
|
|
111
|
+
writeFieldHeader(e, n, r) {
|
|
112
|
+
this.buffer.writeUInt32(e >>> 0), this.buffer.writeByte(K(n)), Tt(n) && this.buffer.writeVarUInt(r >>> 0);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
class Y {
|
|
@@ -165,18 +165,18 @@ class Y {
|
|
|
165
165
|
14
|
|
166
166
|
/* Guid */
|
|
167
167
|
), this.count++;
|
|
168
|
-
const
|
|
169
|
-
if (
|
|
168
|
+
const n = e instanceof h ? e.asBytes() : e;
|
|
169
|
+
if (n.length !== 16)
|
|
170
170
|
throw new Error("Guid payload must be 16 bytes");
|
|
171
|
-
this.payload.writeBytes(
|
|
171
|
+
this.payload.writeBytes(n);
|
|
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 n = W.encode(e ?? "");
|
|
179
|
+
this.payload.writeVarUInt(n.length), this.payload.writeBytes(n);
|
|
180
180
|
}
|
|
181
181
|
writeBinary(e) {
|
|
182
182
|
this.ensureElementType(
|
|
@@ -184,34 +184,34 @@ class Y {
|
|
|
184
184
|
/* Binary */
|
|
185
185
|
), this.count++, this.payload.writeVarUInt(e.length), this.payload.writeBytes(e);
|
|
186
186
|
}
|
|
187
|
-
writeObject(e,
|
|
187
|
+
writeObject(e, n) {
|
|
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 G(e);
|
|
193
|
+
n(r);
|
|
194
|
+
const s = r.finish();
|
|
195
|
+
this.payload.writeVarUInt(s.length), this.payload.writeBytes(s);
|
|
196
196
|
}
|
|
197
|
-
writeArray(e,
|
|
197
|
+
writeArray(e, n) {
|
|
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 Y(e);
|
|
203
|
+
n(r);
|
|
204
|
+
const s = r.finish();
|
|
205
|
+
this.payload.writeBytes(s);
|
|
206
206
|
}
|
|
207
|
-
writeDictionary(e,
|
|
207
|
+
writeDictionary(e, n, r) {
|
|
208
208
|
this.ensureElementType(
|
|
209
209
|
10
|
|
210
210
|
/* Dict */
|
|
211
211
|
), this.count++;
|
|
212
|
-
const
|
|
213
|
-
s
|
|
214
|
-
const i =
|
|
212
|
+
const s = new z(e, n);
|
|
213
|
+
r(s);
|
|
214
|
+
const i = s.finish();
|
|
215
215
|
this.payload.writeBytes(i);
|
|
216
216
|
}
|
|
217
217
|
finish() {
|
|
@@ -224,8 +224,8 @@ class Y {
|
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
class z {
|
|
227
|
-
constructor(e,
|
|
228
|
-
this.keyType = e, this.valueType =
|
|
227
|
+
constructor(e, n) {
|
|
228
|
+
this.keyType = e, this.valueType = n, ct(e);
|
|
229
229
|
}
|
|
230
230
|
payload = new D();
|
|
231
231
|
count = 0;
|
|
@@ -245,8 +245,8 @@ class z {
|
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
class _t {
|
|
248
|
-
constructor(e, r, s
|
|
249
|
-
this.keyType = e, this.valueType =
|
|
248
|
+
constructor(e, n, r, s) {
|
|
249
|
+
this.keyType = e, this.valueType = n, this.payload = r, this.onComplete = s;
|
|
250
250
|
}
|
|
251
251
|
keyWritten = !1;
|
|
252
252
|
valueWritten = !1;
|
|
@@ -298,18 +298,18 @@ class _t {
|
|
|
298
298
|
14
|
|
299
299
|
/* Guid */
|
|
300
300
|
);
|
|
301
|
-
const
|
|
302
|
-
if (
|
|
301
|
+
const n = e instanceof h ? e.asBytes() : e;
|
|
302
|
+
if (n.length !== 16)
|
|
303
303
|
throw new Error("Guid payload must be 16 bytes");
|
|
304
|
-
this.payload.writeBytes(
|
|
304
|
+
this.payload.writeBytes(n), 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 n = W.encode(e ?? "");
|
|
312
|
+
this.payload.writeVarUInt(n.length), this.payload.writeBytes(n), this.keyWritten = !0;
|
|
313
313
|
}
|
|
314
314
|
writeKeyBinary(e) {
|
|
315
315
|
this.ensureKeyType(
|
|
@@ -364,10 +364,10 @@ class _t {
|
|
|
364
364
|
14
|
|
365
365
|
/* Guid */
|
|
366
366
|
);
|
|
367
|
-
const
|
|
368
|
-
if (
|
|
367
|
+
const n = e instanceof h ? e.asBytes() : e;
|
|
368
|
+
if (n.length !== 16)
|
|
369
369
|
throw new Error("Guid payload must be 16 bytes");
|
|
370
|
-
this.payload.writeBytes(
|
|
370
|
+
this.payload.writeBytes(n), this.valueWritten = !0;
|
|
371
371
|
}
|
|
372
372
|
writeNullValue() {
|
|
373
373
|
this.ensureValueType(
|
|
@@ -386,37 +386,37 @@ class _t {
|
|
|
386
386
|
12
|
|
387
387
|
/* String */
|
|
388
388
|
);
|
|
389
|
-
const
|
|
390
|
-
this.payload.writeVarUInt(
|
|
389
|
+
const n = W.encode(e ?? "");
|
|
390
|
+
this.payload.writeVarUInt(n.length), this.payload.writeBytes(n), this.valueWritten = !0;
|
|
391
391
|
}
|
|
392
|
-
writeValueObject(e,
|
|
392
|
+
writeValueObject(e, n) {
|
|
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 G(e);
|
|
398
|
+
n(r);
|
|
399
|
+
const s = r.finish();
|
|
400
|
+
this.payload.writeVarUInt(s.length), this.payload.writeBytes(s), this.valueWritten = !0;
|
|
401
401
|
}
|
|
402
|
-
writeValueArray(e,
|
|
402
|
+
writeValueArray(e, n) {
|
|
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 Y(e);
|
|
408
|
+
n(r);
|
|
409
|
+
const s = r.finish();
|
|
410
|
+
this.payload.writeBytes(s), this.valueWritten = !0;
|
|
411
411
|
}
|
|
412
|
-
writeValueDictionary(e,
|
|
412
|
+
writeValueDictionary(e, n, r) {
|
|
413
413
|
this.ensureValueType(
|
|
414
414
|
10
|
|
415
415
|
/* Dict */
|
|
416
416
|
);
|
|
417
|
-
const
|
|
418
|
-
s
|
|
419
|
-
const i =
|
|
417
|
+
const s = new z(e, n);
|
|
418
|
+
r(s);
|
|
419
|
+
const i = s.finish();
|
|
420
420
|
this.payload.writeBytes(i), this.valueWritten = !0;
|
|
421
421
|
}
|
|
422
422
|
complete() {
|
|
@@ -442,14 +442,14 @@ class h {
|
|
|
442
442
|
static fromString(e) {
|
|
443
443
|
if (!e)
|
|
444
444
|
throw new Error("Guid string is empty");
|
|
445
|
-
const
|
|
446
|
-
if (
|
|
445
|
+
const n = e.replace(/-/g, "");
|
|
446
|
+
if (n.length !== 32)
|
|
447
447
|
throw new Error("Guid string must be 32 hex characters");
|
|
448
|
-
const
|
|
449
|
-
h.writeUInt32LE(
|
|
448
|
+
const r = new Uint8Array(16), s = h.parseHexSlice(n, 0, 8), i = h.parseHexSlice(n, 8, 4), o = h.parseHexSlice(n, 12, 4);
|
|
449
|
+
h.writeUInt32LE(r, 0, s), h.writeUInt16LE(r, 4, i), h.writeUInt16LE(r, 6, o);
|
|
450
450
|
for (let a = 0; a < 8; a++)
|
|
451
|
-
|
|
452
|
-
return new h(
|
|
451
|
+
r[8 + a] = h.parseHexSlice(n, 16 + a * 2, 2);
|
|
452
|
+
return new h(r);
|
|
453
453
|
}
|
|
454
454
|
static fromBytes(e) {
|
|
455
455
|
if (e.length !== 16)
|
|
@@ -460,12 +460,12 @@ class h {
|
|
|
460
460
|
return new h(new Uint8Array(16));
|
|
461
461
|
}
|
|
462
462
|
static createRandom() {
|
|
463
|
-
const e = new Uint8Array(16),
|
|
464
|
-
if (
|
|
465
|
-
|
|
463
|
+
const e = new Uint8Array(16), n = globalThis.crypto;
|
|
464
|
+
if (n?.getRandomValues)
|
|
465
|
+
n.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 h(e);
|
|
470
470
|
}
|
|
471
471
|
toString() {
|
|
@@ -481,28 +481,28 @@ class h {
|
|
|
481
481
|
asBytes() {
|
|
482
482
|
return this.bytes.slice();
|
|
483
483
|
}
|
|
484
|
-
static parseHexSlice(e,
|
|
485
|
-
const
|
|
484
|
+
static parseHexSlice(e, n, r) {
|
|
485
|
+
const s = e.substr(n, r), i = Number.parseInt(s, 16);
|
|
486
486
|
if (Number.isNaN(i))
|
|
487
487
|
throw new Error("Guid string contains invalid characters");
|
|
488
488
|
return i >>> 0;
|
|
489
489
|
}
|
|
490
|
-
static writeUInt32LE(e,
|
|
491
|
-
const
|
|
492
|
-
e[
|
|
490
|
+
static writeUInt32LE(e, n, r) {
|
|
491
|
+
const s = r >>> 0;
|
|
492
|
+
e[n] = s & 255, e[n + 1] = s >>> 8 & 255, e[n + 2] = s >>> 16 & 255, e[n + 3] = s >>> 24 & 255;
|
|
493
493
|
}
|
|
494
|
-
static writeUInt16LE(e,
|
|
495
|
-
const
|
|
496
|
-
e[
|
|
494
|
+
static writeUInt16LE(e, n, r) {
|
|
495
|
+
const s = r & 65535;
|
|
496
|
+
e[n] = s & 255, e[n + 1] = s >>> 8 & 255;
|
|
497
497
|
}
|
|
498
|
-
static readUInt32LE(e,
|
|
499
|
-
return (e[
|
|
498
|
+
static readUInt32LE(e, n) {
|
|
499
|
+
return (e[n] | e[n + 1] << 8 | e[n + 2] << 16 | e[n + 3] << 24) >>> 0;
|
|
500
500
|
}
|
|
501
|
-
static readUInt16LE(e,
|
|
502
|
-
return (e[
|
|
501
|
+
static readUInt16LE(e, n) {
|
|
502
|
+
return (e[n] | e[n + 1] << 8) & 65535;
|
|
503
503
|
}
|
|
504
|
-
static toHex(e,
|
|
505
|
-
return (e >>> 0).toString(16).padStart(
|
|
504
|
+
static toHex(e, n) {
|
|
505
|
+
return (e >>> 0).toString(16).padStart(n, "0");
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
508
|
class D {
|
|
@@ -514,14 +514,14 @@ class D {
|
|
|
514
514
|
this.buffer = new Uint8Array(D.INITIAL_CAPACITY), this.dataView = new DataView(this.buffer.buffer);
|
|
515
515
|
}
|
|
516
516
|
ensureCapacity(e) {
|
|
517
|
-
const
|
|
518
|
-
if (
|
|
517
|
+
const n = this.length + e;
|
|
518
|
+
if (n <= this.buffer.length)
|
|
519
519
|
return;
|
|
520
|
-
let
|
|
521
|
-
for (;
|
|
522
|
-
|
|
523
|
-
const
|
|
524
|
-
|
|
520
|
+
let r = this.buffer.length;
|
|
521
|
+
for (; r < n; )
|
|
522
|
+
r *= 2;
|
|
523
|
+
const s = new Uint8Array(r);
|
|
524
|
+
s.set(this.buffer.subarray(0, this.length)), this.buffer = s, 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 D {
|
|
|
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 n = e >>> 0;
|
|
552
|
+
for (; n >= 128; )
|
|
553
|
+
this.ensureCapacity(1), this.buffer[this.length++] = n & 127 | 128, n >>>= 7;
|
|
554
|
+
this.ensureCapacity(1), this.buffer[this.length++] = n & 127;
|
|
555
555
|
}
|
|
556
556
|
toUint8Array() {
|
|
557
557
|
return this.buffer.slice(0, this.length);
|
|
@@ -577,24 +577,24 @@ function It(t) {
|
|
|
577
577
|
}
|
|
578
578
|
var N = /* @__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[t.Udp = 512] = "Udp", t[t.UdpDtls = 1024] = "UdpDtls", t))(N || {}), 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.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.CORE_WEBRTC_VIDEO_CAPTURE = 65572] = "CORE_WEBRTC_VIDEO_CAPTURE", t[t.CORE_RELAY_AGENT_AUTH = 65576] = "CORE_RELAY_AGENT_AUTH", t[t.CORE_RELAY_AGENT_AUTH_RESULT = 65577] = "CORE_RELAY_AGENT_AUTH_RESULT", t[t.CORE_RELAY_HEARTBEAT = 65578] = "CORE_RELAY_HEARTBEAT", t[t.CORE_RELAY_TCP_CONNECTION_OPENED = 65579] = "CORE_RELAY_TCP_CONNECTION_OPENED", t[t.CORE_RELAY_TCP_CONNECTION_CLOSED = 65580] = "CORE_RELAY_TCP_CONNECTION_CLOSED", t[t.CORE_RELAY_TCP_DATA = 65581] = "CORE_RELAY_TCP_DATA", t[t.CORE_RELAY_UDP_DATA = 65582] = "CORE_RELAY_UDP_DATA", t[t.CORE_RELAY_ADD_TUNNEL = 65583] = "CORE_RELAY_ADD_TUNNEL", t[t.CORE_RELAY_TUNNEL_ADDED = 65584] = "CORE_RELAY_TUNNEL_ADDED", t[t.CORE_RELAY_REMOVE_TUNNEL = 65585] = "CORE_RELAY_REMOVE_TUNNEL", 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.ANALYTICS_IKON_RELAY_SERVER_STATS = 524297] = "ANALYTICS_IKON_RELAY_SERVER_STATS", t[t.ANALYTICS_IKON_TURN_SERVER_STATS = 524298] = "ANALYTICS_IKON_TURN_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_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.ACTION_FILE_UPLOAD_PRE_START2 = 1048643] = "ACTION_FILE_UPLOAD_PRE_START2", t[t.ACTION_FILE_UPLOAD_PRE_START_RESPONSE2 = 1048644] = "ACTION_FILE_UPLOAD_PRE_START_RESPONSE2", t[t.ACTION_FILE_UPLOAD_START2 = 1048645] = "ACTION_FILE_UPLOAD_START2", t[t.ACTION_FILE_UPLOAD_START_RESPONSE2 = 1048646] = "ACTION_FILE_UPLOAD_START_RESPONSE2", t[t.ACTION_FILE_UPLOAD_DATA2 = 1048647] = "ACTION_FILE_UPLOAD_DATA2", t[t.ACTION_FILE_UPLOAD_ACK2 = 1048648] = "ACTION_FILE_UPLOAD_ACK2", t[t.ACTION_FILE_UPLOAD_END2 = 1048649] = "ACTION_FILE_UPLOAD_END2", t[t.ACTION_FILE_UPLOAD_COMPLETE2 = 1048650] = "ACTION_FILE_UPLOAD_COMPLETE2", t[t.ACTION_FUNCTION_ENUMERATION_ITEM_BATCH = 1048651] = "ACTION_FUNCTION_ENUMERATION_ITEM_BATCH", t[t.ACTION_CALL_ACK = 1048652] = "ACTION_CALL_ACK", 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.AUDIO_SHAPE_FRAME = 4194310] = "AUDIO_SHAPE_FRAME", 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.GROUP_APP_LOCAL = 1073741824] = "GROUP_APP_LOCAL", t[t.CONSTANT_GROUP_MASK = 2147418112] = "CONSTANT_GROUP_MASK", t))(V || {});
|
|
579
579
|
const et = 1, At = 131074;
|
|
580
|
-
function
|
|
580
|
+
function nt(t) {
|
|
581
581
|
return {};
|
|
582
582
|
}
|
|
583
583
|
function ut(t) {
|
|
584
584
|
return new G(et).finish();
|
|
585
585
|
}
|
|
586
|
-
function
|
|
587
|
-
const
|
|
588
|
-
return Et(At,
|
|
586
|
+
function rt(t, e, n) {
|
|
587
|
+
const r = ut();
|
|
588
|
+
return Et(At, r, et, e);
|
|
589
589
|
}
|
|
590
|
-
class
|
|
591
|
-
constructor(e,
|
|
592
|
-
super(e), this.cause =
|
|
590
|
+
class st extends Error {
|
|
591
|
+
constructor(e, n) {
|
|
592
|
+
super(e), this.cause = n, this.name = "ConnectionError";
|
|
593
593
|
}
|
|
594
594
|
}
|
|
595
|
-
class y extends
|
|
596
|
-
constructor(e,
|
|
597
|
-
super(e,
|
|
595
|
+
class y extends st {
|
|
596
|
+
constructor(e, n) {
|
|
597
|
+
super(e, n), this.name = "TransportError";
|
|
598
598
|
}
|
|
599
599
|
}
|
|
600
600
|
class q extends y {
|
|
@@ -602,23 +602,23 @@ class q extends y {
|
|
|
602
602
|
super(`No keepalive received within ${e}ms`), this.name = "KeepaliveTimeoutError";
|
|
603
603
|
}
|
|
604
604
|
}
|
|
605
|
-
class Z extends
|
|
605
|
+
class Z extends st {
|
|
606
606
|
constructor(e) {
|
|
607
607
|
super(`Maximum reconnection attempts (${e}) exceeded`), this.name = "MaxRetriesExceededError";
|
|
608
608
|
}
|
|
609
609
|
}
|
|
610
610
|
function Ct(t, e) {
|
|
611
|
-
return new Promise((
|
|
612
|
-
const
|
|
613
|
-
clearTimeout(i),
|
|
611
|
+
return new Promise((n, r) => {
|
|
612
|
+
const s = () => {
|
|
613
|
+
clearTimeout(i), r(new DOMException("Aborted", "AbortError"));
|
|
614
614
|
}, i = setTimeout(() => {
|
|
615
|
-
e?.removeEventListener("abort",
|
|
615
|
+
e?.removeEventListener("abort", s), n();
|
|
616
616
|
}, t);
|
|
617
617
|
if (e?.aborted) {
|
|
618
|
-
clearTimeout(i),
|
|
618
|
+
clearTimeout(i), r(new DOMException("Aborted", "AbortError"));
|
|
619
619
|
return;
|
|
620
620
|
}
|
|
621
|
-
e?.addEventListener("abort",
|
|
621
|
+
e?.addEventListener("abort", s, { once: !0 });
|
|
622
622
|
});
|
|
623
623
|
}
|
|
624
624
|
let Nt = 1;
|
|
@@ -632,14 +632,14 @@ const ft = /* @__PURE__ */ new Map(), Rt = {
|
|
|
632
632
|
function Ut(t, e) {
|
|
633
633
|
return `[${t}] ${e}`;
|
|
634
634
|
}
|
|
635
|
-
function k(t, e,
|
|
636
|
-
const
|
|
637
|
-
timestamp:
|
|
635
|
+
function k(t, e, n, r) {
|
|
636
|
+
const s = (/* @__PURE__ */ new Date()).toISOString(), i = Rt[t], o = {
|
|
637
|
+
timestamp: s,
|
|
638
638
|
level: t,
|
|
639
639
|
levelName: i,
|
|
640
640
|
component: e,
|
|
641
|
-
message:
|
|
642
|
-
args:
|
|
641
|
+
message: n,
|
|
642
|
+
args: r
|
|
643
643
|
};
|
|
644
644
|
for (const [a, E] of ft) {
|
|
645
645
|
const _ = E?.minLevel ?? 2;
|
|
@@ -650,36 +650,36 @@ function k(t, e, r, s) {
|
|
|
650
650
|
}
|
|
651
651
|
}
|
|
652
652
|
if (Nt <= t) {
|
|
653
|
-
const a = Ut(e,
|
|
653
|
+
const a = Ut(e, n);
|
|
654
654
|
switch (t) {
|
|
655
655
|
case 0:
|
|
656
|
-
console.debug(a, ...
|
|
656
|
+
console.debug(a, ...r);
|
|
657
657
|
break;
|
|
658
658
|
case 1:
|
|
659
|
-
console.info(a, ...
|
|
659
|
+
console.info(a, ...r);
|
|
660
660
|
break;
|
|
661
661
|
case 2:
|
|
662
|
-
console.warn(a, ...
|
|
662
|
+
console.warn(a, ...r);
|
|
663
663
|
break;
|
|
664
664
|
case 3:
|
|
665
|
-
console.error(a, ...
|
|
665
|
+
console.error(a, ...r);
|
|
666
666
|
break;
|
|
667
667
|
}
|
|
668
668
|
}
|
|
669
669
|
}
|
|
670
670
|
function p(t) {
|
|
671
671
|
return {
|
|
672
|
-
debug(e, ...
|
|
673
|
-
k(0, t, e,
|
|
672
|
+
debug(e, ...n) {
|
|
673
|
+
k(0, t, e, n);
|
|
674
674
|
},
|
|
675
|
-
info(e, ...
|
|
676
|
-
k(1, t, e,
|
|
675
|
+
info(e, ...n) {
|
|
676
|
+
k(1, t, e, n);
|
|
677
677
|
},
|
|
678
|
-
warn(e, ...
|
|
679
|
-
k(2, t, e,
|
|
678
|
+
warn(e, ...n) {
|
|
679
|
+
k(2, t, e, n);
|
|
680
680
|
},
|
|
681
|
-
error(e, ...
|
|
682
|
-
k(3, t, e,
|
|
681
|
+
error(e, ...n) {
|
|
682
|
+
k(3, t, e, n);
|
|
683
683
|
}
|
|
684
684
|
};
|
|
685
685
|
}
|
|
@@ -687,15 +687,15 @@ const yt = "ikon-retry";
|
|
|
687
687
|
function St(t, e) {
|
|
688
688
|
if (typeof window > "u")
|
|
689
689
|
return null;
|
|
690
|
-
const
|
|
691
|
-
if (
|
|
692
|
-
return
|
|
693
|
-
const
|
|
694
|
-
return
|
|
690
|
+
const n = new URLSearchParams(window.location.search), r = n.get(t);
|
|
691
|
+
if (r !== null)
|
|
692
|
+
return r;
|
|
693
|
+
const s = n.get(t.replace(/-/g, "_"));
|
|
694
|
+
return s !== null ? s : null;
|
|
695
695
|
}
|
|
696
696
|
function wt(t, e) {
|
|
697
|
-
const
|
|
698
|
-
return
|
|
697
|
+
const n = St(t);
|
|
698
|
+
return n === "true" ? !0 : n === "false" ? !1 : null;
|
|
699
699
|
}
|
|
700
700
|
function Lt() {
|
|
701
701
|
return wt(yt) !== !1;
|
|
@@ -717,10 +717,10 @@ class Pt {
|
|
|
717
717
|
get isConnected() {
|
|
718
718
|
return this.ws?.readyState === WebSocket.OPEN;
|
|
719
719
|
}
|
|
720
|
-
async connect(e,
|
|
720
|
+
async connect(e, n) {
|
|
721
721
|
this.isClosed = !1;
|
|
722
|
-
const
|
|
723
|
-
return new Promise((
|
|
722
|
+
const r = Date.now();
|
|
723
|
+
return new Promise((s, i) => {
|
|
724
724
|
try {
|
|
725
725
|
this.ws = new WebSocket(e), this.ws.binaryType = "arraybuffer";
|
|
726
726
|
} catch (l) {
|
|
@@ -734,9 +734,9 @@ class Pt {
|
|
|
734
734
|
a || (a = !0, E(), this.ws?.close(), b.warn(`WebSocket connection timeout after ${this.connectionTimeoutMs}ms`), i(new y("WebSocket connection timeout")));
|
|
735
735
|
}, this.connectionTimeoutMs);
|
|
736
736
|
this.ws.onopen = () => {
|
|
737
|
-
o = !0, clearTimeout(_), this.ws.send(
|
|
737
|
+
o = !0, clearTimeout(_), this.ws.send(n), this.resetKeepaliveTimeout(), a || (a = !0, b.info(`WebSocket connected in ${Date.now() - r}ms`), s());
|
|
738
738
|
}, this.ws.onerror = () => {
|
|
739
|
-
clearTimeout(_), a || (a = !0, E(), b.debug(`WebSocket connection failed after ${Date.now() -
|
|
739
|
+
clearTimeout(_), a || (a = !0, E(), b.debug(`WebSocket connection failed after ${Date.now() - r}ms`), i(new y("WebSocket connection failed")));
|
|
740
740
|
}, this.ws.onclose = (l) => {
|
|
741
741
|
if (this.clearKeepaliveTimeout(), !o && !a) {
|
|
742
742
|
a = !0, E(), i(new y("WebSocket connection closed before opening"));
|
|
@@ -761,7 +761,7 @@ class Pt {
|
|
|
761
761
|
* Get or create a cached keepalive response message.
|
|
762
762
|
*/
|
|
763
763
|
getKeepaliveResponse() {
|
|
764
|
-
return this.keepaliveResponseMessage || (this.keepaliveResponseMessage =
|
|
764
|
+
return this.keepaliveResponseMessage || (this.keepaliveResponseMessage = rt(nt(), this.sessionId)), this.keepaliveResponseMessage;
|
|
765
765
|
}
|
|
766
766
|
handleProtocolMessage(e) {
|
|
767
767
|
try {
|
|
@@ -770,8 +770,8 @@ class Pt {
|
|
|
770
770
|
return;
|
|
771
771
|
}
|
|
772
772
|
this.resetKeepaliveTimeout(), this.callbacks.onProtocolMessage(e);
|
|
773
|
-
} catch (
|
|
774
|
-
b.error("Failed to process protocol message:",
|
|
773
|
+
} catch (n) {
|
|
774
|
+
b.error("Failed to process protocol message:", n), this.callbacks.onError(n instanceof Error ? n : new Error(String(n)));
|
|
775
775
|
}
|
|
776
776
|
}
|
|
777
777
|
resetKeepaliveTimeout() {
|
|
@@ -814,34 +814,34 @@ class Ot {
|
|
|
814
814
|
get isConnected() {
|
|
815
815
|
return this.transport !== null && this.writer !== null;
|
|
816
816
|
}
|
|
817
|
-
async connect(e,
|
|
817
|
+
async connect(e, n) {
|
|
818
818
|
if (!it())
|
|
819
819
|
throw new y("WebTransport is not supported in this browser");
|
|
820
820
|
this.isClosed = !1;
|
|
821
|
-
const
|
|
821
|
+
const r = Date.now();
|
|
822
822
|
try {
|
|
823
823
|
this.transport = new WebTransport(e);
|
|
824
|
-
let
|
|
824
|
+
let s;
|
|
825
825
|
const i = new Promise((o, a) => {
|
|
826
|
-
|
|
826
|
+
s = setTimeout(
|
|
827
827
|
() => a(new y("WebTransport connection timeout")),
|
|
828
828
|
this.connectionTimeoutMs
|
|
829
829
|
);
|
|
830
830
|
});
|
|
831
831
|
try {
|
|
832
|
-
await Promise.race([this.transport.ready, i]), clearTimeout(
|
|
832
|
+
await Promise.race([this.transport.ready, i]), clearTimeout(s);
|
|
833
833
|
} catch (o) {
|
|
834
|
-
throw clearTimeout(
|
|
834
|
+
throw clearTimeout(s), o instanceof y && U.warn(`WebTransport connection timeout after ${this.connectionTimeoutMs}ms`), o;
|
|
835
835
|
}
|
|
836
|
-
U.info(`WebTransport connected in ${Date.now() -
|
|
836
|
+
U.info(`WebTransport connected in ${Date.now() - r}ms`), this.transport.closed.then(() => {
|
|
837
837
|
this.handleClose("Connection closed", !0);
|
|
838
838
|
}).catch((o) => {
|
|
839
839
|
U.error("WebTransport connection closed with error:", o), this.handleClose(o.message || "Connection error", !1);
|
|
840
|
-
}), this.stream = await this.transport.createBidirectionalStream(), this.reader = this.stream.readable.getReader(), this.writer = this.stream.writable.getWriter(), await this.writer.write(
|
|
841
|
-
} catch (
|
|
840
|
+
}), this.stream = await this.transport.createBidirectionalStream(), this.reader = this.stream.readable.getReader(), this.writer = this.stream.writable.getWriter(), await this.writer.write(n), this.resetKeepaliveTimeout(), this.startReadLoop();
|
|
841
|
+
} catch (s) {
|
|
842
842
|
this.cleanup();
|
|
843
|
-
const i = Date.now() -
|
|
844
|
-
throw U.warn(`WebTransport connection failed after ${i}ms: ${
|
|
843
|
+
const i = Date.now() - r;
|
|
844
|
+
throw U.warn(`WebTransport connection failed after ${i}ms: ${s}`), new y(`Failed to connect WebTransport: ${s}`, s instanceof Error ? s : void 0);
|
|
845
845
|
}
|
|
846
846
|
}
|
|
847
847
|
send(e) {
|
|
@@ -849,8 +849,8 @@ class Ot {
|
|
|
849
849
|
U.warn("Cannot send: WebTransport not connected");
|
|
850
850
|
return;
|
|
851
851
|
}
|
|
852
|
-
this.writer.write(e).catch((
|
|
853
|
-
U.error("Failed to send protocol message:",
|
|
852
|
+
this.writer.write(e).catch((n) => {
|
|
853
|
+
U.error("Failed to send protocol message:", n), this.callbacks.onError(n instanceof Error ? n : new Error(String(n)));
|
|
854
854
|
});
|
|
855
855
|
}
|
|
856
856
|
close() {
|
|
@@ -864,8 +864,8 @@ class Ot {
|
|
|
864
864
|
this.readLoopActive = !0;
|
|
865
865
|
try {
|
|
866
866
|
for (; this.readLoopActive && this.reader; ) {
|
|
867
|
-
const { value: e, done:
|
|
868
|
-
if (
|
|
867
|
+
const { value: e, done: n } = await this.reader.read();
|
|
868
|
+
if (n)
|
|
869
869
|
break;
|
|
870
870
|
e && (this.appendToBuffer(e), this.processBufferedMessages());
|
|
871
871
|
}
|
|
@@ -880,13 +880,13 @@ class Ot {
|
|
|
880
880
|
* Compacts when offset exceeds half capacity and data is sparse.
|
|
881
881
|
*/
|
|
882
882
|
appendToBuffer(e) {
|
|
883
|
-
const
|
|
884
|
-
if (
|
|
885
|
-
if (
|
|
886
|
-
const
|
|
887
|
-
i.set(this.receiveBuffer.subarray(this.receiveBufferOffset,
|
|
883
|
+
const n = this.receiveBufferLength + e.length, r = this.receiveBufferOffset + this.receiveBufferLength;
|
|
884
|
+
if (r + e.length > this.receiveBuffer.length)
|
|
885
|
+
if (n > this.receiveBuffer.length) {
|
|
886
|
+
const s = Math.max(n, this.receiveBuffer.length * 2), i = new Uint8Array(s);
|
|
887
|
+
i.set(this.receiveBuffer.subarray(this.receiveBufferOffset, r)), this.receiveBuffer = i, this.receiveBufferOffset = 0, this.receiveDataViewBuffer = null;
|
|
888
888
|
} else
|
|
889
|
-
this.receiveBuffer.copyWithin(0, this.receiveBufferOffset,
|
|
889
|
+
this.receiveBuffer.copyWithin(0, this.receiveBufferOffset, r), this.receiveBufferOffset = 0;
|
|
890
890
|
this.receiveBuffer.set(e, this.receiveBufferOffset + this.receiveBufferLength), this.receiveBufferLength += e.length;
|
|
891
891
|
}
|
|
892
892
|
/**
|
|
@@ -900,7 +900,7 @@ class Ot {
|
|
|
900
900
|
* Get or create a cached keepalive response message.
|
|
901
901
|
*/
|
|
902
902
|
getKeepaliveResponse() {
|
|
903
|
-
return this.keepaliveResponseMessage || (this.keepaliveResponseMessage =
|
|
903
|
+
return this.keepaliveResponseMessage || (this.keepaliveResponseMessage = rt(nt(), this.sessionId)), this.keepaliveResponseMessage;
|
|
904
904
|
}
|
|
905
905
|
/**
|
|
906
906
|
* Process complete messages from the receive buffer.
|
|
@@ -910,15 +910,15 @@ class Ot {
|
|
|
910
910
|
processBufferedMessages() {
|
|
911
911
|
const e = this.getReceiveDataView();
|
|
912
912
|
for (; this.receiveBufferLength >= tt; ) {
|
|
913
|
-
const
|
|
914
|
-
if (
|
|
915
|
-
U.error(`Invalid message length: ${
|
|
913
|
+
const n = e.getUint32(this.receiveBufferOffset, !0);
|
|
914
|
+
if (n < tt) {
|
|
915
|
+
U.error(`Invalid message length: ${n}`), this.callbacks.onError(new Error(`Invalid protocol message length: ${n}`)), this.receiveBufferOffset = 0, this.receiveBufferLength = 0;
|
|
916
916
|
return;
|
|
917
917
|
}
|
|
918
|
-
if (this.receiveBufferLength <
|
|
918
|
+
if (this.receiveBufferLength < n)
|
|
919
919
|
return;
|
|
920
|
-
const
|
|
921
|
-
this.receiveBufferOffset +=
|
|
920
|
+
const r = this.receiveBuffer.subarray(this.receiveBufferOffset, this.receiveBufferOffset + n);
|
|
921
|
+
this.receiveBufferOffset += n, this.receiveBufferLength -= n, this.handleProtocolMessage(r);
|
|
922
922
|
}
|
|
923
923
|
this.receiveBufferLength === 0 && (this.receiveBufferOffset = 0);
|
|
924
924
|
}
|
|
@@ -932,15 +932,15 @@ class Ot {
|
|
|
932
932
|
return;
|
|
933
933
|
}
|
|
934
934
|
this.resetKeepaliveTimeout(), this.callbacks.onProtocolMessage(e);
|
|
935
|
-
} catch (
|
|
936
|
-
U.error("Failed to process protocol message:",
|
|
935
|
+
} catch (n) {
|
|
936
|
+
U.error("Failed to process protocol message:", n), this.callbacks.onError(n instanceof Error ? n : new Error(String(n)));
|
|
937
937
|
}
|
|
938
938
|
}
|
|
939
939
|
/**
|
|
940
940
|
* Handle connection close.
|
|
941
941
|
*/
|
|
942
|
-
handleClose(e,
|
|
943
|
-
this.isClosed || (this.isClosed = !0, this.clearKeepaliveTimeout(), this.readLoopActive = !1, this.cleanup(), this.callbacks.onClose(e,
|
|
942
|
+
handleClose(e, n) {
|
|
943
|
+
this.isClosed || (this.isClosed = !0, this.clearKeepaliveTimeout(), this.readLoopActive = !1, this.cleanup(), this.callbacks.onClose(e, n));
|
|
944
944
|
}
|
|
945
945
|
/**
|
|
946
946
|
* Reset the keepalive timeout.
|
|
@@ -1051,26 +1051,26 @@ class bt {
|
|
|
1051
1051
|
* Connect the transport to the entrypoint.
|
|
1052
1052
|
*/
|
|
1053
1053
|
async connectTransport() {
|
|
1054
|
-
const e = this.entrypoint,
|
|
1054
|
+
const e = this.entrypoint, n = {
|
|
1055
1055
|
sessionId: this.config.sessionId,
|
|
1056
1056
|
keepaliveTimeoutMs: this.config.keepaliveTimeoutMs,
|
|
1057
1057
|
connectionTimeoutMs: this.config.connectionTimeoutMs,
|
|
1058
1058
|
callbacks: {
|
|
1059
|
-
onProtocolMessage: (
|
|
1060
|
-
onClose: (
|
|
1061
|
-
onError: (
|
|
1059
|
+
onProtocolMessage: (r) => this.handleProtocolMessage(r),
|
|
1060
|
+
onClose: (r, s) => this.handleClose(r, s),
|
|
1061
|
+
onError: (r) => this.handleError(r)
|
|
1062
1062
|
}
|
|
1063
1063
|
};
|
|
1064
1064
|
switch (e.Type) {
|
|
1065
1065
|
case N.WebSocket:
|
|
1066
1066
|
case N.WebSocketProxy:
|
|
1067
|
-
this.transport = new Pt(
|
|
1067
|
+
this.transport = new Pt(n);
|
|
1068
1068
|
break;
|
|
1069
1069
|
case N.WebTransport:
|
|
1070
1070
|
case N.WebTransportProxy:
|
|
1071
1071
|
if (!it())
|
|
1072
1072
|
throw new Error("WebTransport is not supported in this browser");
|
|
1073
|
-
this.transport = new Ot(
|
|
1073
|
+
this.transport = new Ot(n);
|
|
1074
1074
|
break;
|
|
1075
1075
|
default:
|
|
1076
1076
|
throw new Error(`Unsupported entrypoint type: ${N[e.Type]}`);
|
|
@@ -1082,21 +1082,21 @@ class bt {
|
|
|
1082
1082
|
*/
|
|
1083
1083
|
handleProtocolMessage(e) {
|
|
1084
1084
|
try {
|
|
1085
|
-
const
|
|
1086
|
-
if (j(
|
|
1085
|
+
const n = e;
|
|
1086
|
+
if (j(n) === V.CORE_ON_SERVER_STOPPING) {
|
|
1087
1087
|
x.debug("Received server stopping message"), this.setState("stopped"), this.transport?.close();
|
|
1088
1088
|
return;
|
|
1089
1089
|
}
|
|
1090
|
-
this.config.onProtocolMessage?.(
|
|
1091
|
-
} catch (
|
|
1092
|
-
x.error("Failed to handle protocol message:",
|
|
1090
|
+
this.config.onProtocolMessage?.(n);
|
|
1091
|
+
} catch (n) {
|
|
1092
|
+
x.error("Failed to handle protocol message:", n), this.config.onError?.(n instanceof Error ? n : new Error(String(n)));
|
|
1093
1093
|
}
|
|
1094
1094
|
}
|
|
1095
1095
|
/**
|
|
1096
1096
|
* Handle transport close.
|
|
1097
1097
|
*/
|
|
1098
|
-
handleClose(e,
|
|
1099
|
-
this.transport = null, this.config.onClose?.(e,
|
|
1098
|
+
handleClose(e, n) {
|
|
1099
|
+
this.transport = null, this.config.onClose?.(e, n);
|
|
1100
1100
|
}
|
|
1101
1101
|
/**
|
|
1102
1102
|
* Handle transport error.
|
|
@@ -1118,7 +1118,6 @@ class Mt {
|
|
|
1118
1118
|
activeType = null;
|
|
1119
1119
|
state = "idle";
|
|
1120
1120
|
reconnectAttempts = 0;
|
|
1121
|
-
stabilityTimer = null;
|
|
1122
1121
|
shouldReconnect = !0;
|
|
1123
1122
|
entrypoints = [];
|
|
1124
1123
|
abortController = null;
|
|
@@ -1142,10 +1141,10 @@ class Mt {
|
|
|
1142
1141
|
/**
|
|
1143
1142
|
* Connect to the server using the provided entrypoints.
|
|
1144
1143
|
*/
|
|
1145
|
-
async connect(e,
|
|
1144
|
+
async connect(e, n) {
|
|
1146
1145
|
if (this.state !== "idle" && this.state !== "offline")
|
|
1147
1146
|
throw new Error(`Cannot connect: already in state ${this.state}`);
|
|
1148
|
-
if (this.entrypoints = e, this.shouldReconnect = !0, this.reconnectAttempts = 0, this.abortController = new AbortController(),
|
|
1147
|
+
if (this.entrypoints = e, this.shouldReconnect = !0, this.reconnectAttempts = 0, this.abortController = new AbortController(), n?.retry) {
|
|
1149
1148
|
this.attemptReconnect();
|
|
1150
1149
|
return;
|
|
1151
1150
|
}
|
|
@@ -1155,17 +1154,17 @@ class Mt {
|
|
|
1155
1154
|
* Disconnect all channels.
|
|
1156
1155
|
*/
|
|
1157
1156
|
disconnect() {
|
|
1158
|
-
this.shouldReconnect = !1, this.
|
|
1157
|
+
this.shouldReconnect = !1, this.abortController?.abort(), this.abortController = null, this.disconnectAll(), this.setState("idle");
|
|
1159
1158
|
}
|
|
1160
1159
|
/**
|
|
1161
1160
|
* Send a protocol message to the appropriate channel.
|
|
1162
1161
|
* The opcode group is extracted from the message automatically.
|
|
1163
1162
|
*/
|
|
1164
1163
|
sendProtocolMessage(e) {
|
|
1165
|
-
const
|
|
1166
|
-
for (const [
|
|
1167
|
-
if (
|
|
1168
|
-
|
|
1164
|
+
const n = v(e);
|
|
1165
|
+
for (const [r, s] of this.channels)
|
|
1166
|
+
if (r & n) {
|
|
1167
|
+
s.send(e);
|
|
1169
1168
|
return;
|
|
1170
1169
|
}
|
|
1171
1170
|
this.state === "connected" && I.warn("No channel found for message");
|
|
@@ -1174,8 +1173,8 @@ class Mt {
|
|
|
1174
1173
|
* Send a protocol message to all channels (for broadcast messages).
|
|
1175
1174
|
*/
|
|
1176
1175
|
sendToAll(e) {
|
|
1177
|
-
for (const
|
|
1178
|
-
|
|
1176
|
+
for (const n of this.channels.values())
|
|
1177
|
+
n.send(e);
|
|
1179
1178
|
}
|
|
1180
1179
|
/**
|
|
1181
1180
|
* Check health of all channels.
|
|
@@ -1197,8 +1196,8 @@ class Mt {
|
|
|
1197
1196
|
triggerReconnect(e) {
|
|
1198
1197
|
if (this.state === "connected") {
|
|
1199
1198
|
I.debug(`Forcing reconnect: ${e}`);
|
|
1200
|
-
for (const
|
|
1201
|
-
|
|
1199
|
+
for (const n of this.channels.values())
|
|
1200
|
+
n.triggerReconnect(e);
|
|
1202
1201
|
}
|
|
1203
1202
|
}
|
|
1204
1203
|
/**
|
|
@@ -1207,29 +1206,29 @@ class Mt {
|
|
|
1207
1206
|
*/
|
|
1208
1207
|
async connectInternal(e = !1) {
|
|
1209
1208
|
this.setState("connecting");
|
|
1210
|
-
let
|
|
1209
|
+
let n = this.entrypoints;
|
|
1211
1210
|
if (this.config.webRtcEnabled) {
|
|
1212
1211
|
I.debug(`WebRTC enabled, filtering entrypoints (total: ${this.entrypoints.length})`);
|
|
1213
1212
|
for (const i of this.entrypoints)
|
|
1214
1213
|
I.debug(` Entrypoint: type=${i.Type} fromServer=0x${i.OpcodeGroupsFromServer.toString(16)} toServer=0x${i.OpcodeGroupsToServer.toString(16)} uri=${i.Uri}`);
|
|
1215
|
-
|
|
1214
|
+
n = this.entrypoints.filter((i) => i.Type === N.WebRTC ? (I.debug(` Filtered out WebRTC entrypoint (type=${i.Type})`), !1) : !0), I.debug(`After filtering: ${n.length} entrypoints remain for WS/WT channels`);
|
|
1216
1215
|
}
|
|
1217
|
-
const
|
|
1218
|
-
if (
|
|
1216
|
+
const r = this.groupByType(n);
|
|
1217
|
+
if (r.size === 0)
|
|
1219
1218
|
throw this.setState("offline"), new Error("No entrypoints available");
|
|
1220
|
-
let
|
|
1219
|
+
let s;
|
|
1221
1220
|
if (this.config.orderedEndpointTypes && this.config.orderedEndpointTypes.length > 0) {
|
|
1222
|
-
const i = new Set(
|
|
1223
|
-
|
|
1224
|
-
} else this.config.endpointSelector ?
|
|
1225
|
-
this.connectionTimeoutMs =
|
|
1226
|
-
for (const i of
|
|
1221
|
+
const i = new Set(r.keys());
|
|
1222
|
+
s = this.config.orderedEndpointTypes.filter((o) => i.has(o));
|
|
1223
|
+
} else this.config.endpointSelector ? s = this.config.endpointSelector.getOrderedTypes(r) : s = Array.from(r.keys());
|
|
1224
|
+
this.connectionTimeoutMs = s.length > 1 ? 5e3 : 1e4, I.info(`Endpoint types to try: [${s.map((i) => N[i]).join(", ")}], transport timeout: ${this.connectionTimeoutMs}ms`);
|
|
1225
|
+
for (const i of s) {
|
|
1227
1226
|
if (!this.shouldReconnect)
|
|
1228
1227
|
return;
|
|
1229
|
-
const o =
|
|
1228
|
+
const o = r.get(i), a = Date.now();
|
|
1230
1229
|
I.info(`Trying ${N[i]} (${o.length} channel(s))`);
|
|
1231
1230
|
try {
|
|
1232
|
-
await this.connectAllChannels(o), this.config.endpointSelector?.rememberWorkingType(i), this.config.onRememberWorkingType?.(i), this.activeType = i, this.
|
|
1231
|
+
await this.connectAllChannels(o), this.config.endpointSelector?.rememberWorkingType(i), this.config.onRememberWorkingType?.(i), this.activeType = i, this.reconnectAttempts = 0, I.info(`Connected via ${N[i]} in ${Date.now() - a}ms`), this.setState("connected");
|
|
1233
1232
|
return;
|
|
1234
1233
|
} catch (E) {
|
|
1235
1234
|
I.warn(`Failed to connect using ${N[i]} after ${Date.now() - a}ms: ${E instanceof Error ? E.message : E}`);
|
|
@@ -1241,7 +1240,7 @@ class Mt {
|
|
|
1241
1240
|
this.entrypoints = l.entrypoints, this.config.sessionId = l.sessionId;
|
|
1242
1241
|
const T = this.config.webRtcEnabled ? l.entrypoints.filter((c) => c.Type !== N.WebRTC) : l.entrypoints, S = this.groupByType(T);
|
|
1243
1242
|
for (const [c, g] of S)
|
|
1244
|
-
|
|
1243
|
+
r.set(c, g);
|
|
1245
1244
|
} catch (l) {
|
|
1246
1245
|
I.warn(`Failed to refresh entrypoints: ${l}`);
|
|
1247
1246
|
}
|
|
@@ -1255,55 +1254,55 @@ class Mt {
|
|
|
1255
1254
|
async connectAllChannels(e) {
|
|
1256
1255
|
if (e.length === 0)
|
|
1257
1256
|
throw new Error("No entrypoints to connect");
|
|
1258
|
-
const
|
|
1259
|
-
if (
|
|
1260
|
-
const
|
|
1257
|
+
const r = (await Promise.allSettled(e.map((s) => this.connectChannel(s)))).filter((s) => s.status === "rejected");
|
|
1258
|
+
if (r.length > 0) {
|
|
1259
|
+
const s = r.map((i) => {
|
|
1261
1260
|
const o = i.reason;
|
|
1262
1261
|
return o instanceof Error ? o.message : String(o);
|
|
1263
1262
|
});
|
|
1264
|
-
throw new Error(
|
|
1263
|
+
throw new Error(s.join(", "));
|
|
1265
1264
|
}
|
|
1266
1265
|
}
|
|
1267
1266
|
/**
|
|
1268
1267
|
* Connect a single channel.
|
|
1269
1268
|
*/
|
|
1270
1269
|
async connectChannel(e) {
|
|
1271
|
-
const
|
|
1270
|
+
const n = new bt({
|
|
1272
1271
|
entrypoint: e,
|
|
1273
1272
|
sessionId: this.config.sessionId,
|
|
1274
1273
|
keepaliveTimeoutMs: this.config.keepaliveTimeoutMs,
|
|
1275
1274
|
connectionTimeoutMs: this.connectionTimeoutMs,
|
|
1276
|
-
onProtocolMessage: (
|
|
1277
|
-
this.config.onProtocolMessage?.(
|
|
1275
|
+
onProtocolMessage: (r) => {
|
|
1276
|
+
this.config.onProtocolMessage?.(r);
|
|
1278
1277
|
},
|
|
1279
|
-
onStateChange: (
|
|
1280
|
-
this.handleChannelStateChange(e.OpcodeGroupsFromServer,
|
|
1278
|
+
onStateChange: (r) => {
|
|
1279
|
+
this.handleChannelStateChange(e.OpcodeGroupsFromServer, r);
|
|
1281
1280
|
},
|
|
1282
|
-
onClose: (
|
|
1283
|
-
this.handleChannelClose(e.OpcodeGroupsFromServer,
|
|
1281
|
+
onClose: (r, s) => {
|
|
1282
|
+
this.handleChannelClose(e.OpcodeGroupsFromServer, r, s);
|
|
1284
1283
|
},
|
|
1285
|
-
onError: (
|
|
1286
|
-
this.config.onError?.(
|
|
1284
|
+
onError: (r) => {
|
|
1285
|
+
this.config.onError?.(r);
|
|
1287
1286
|
}
|
|
1288
1287
|
});
|
|
1289
|
-
await
|
|
1288
|
+
await n.connect(), this.channels.set(e.OpcodeGroupsFromServer, n);
|
|
1290
1289
|
}
|
|
1291
1290
|
/**
|
|
1292
1291
|
* Group entrypoints by type.
|
|
1293
1292
|
*/
|
|
1294
1293
|
groupByType(e) {
|
|
1295
|
-
const
|
|
1296
|
-
for (const
|
|
1297
|
-
const
|
|
1298
|
-
|
|
1294
|
+
const n = /* @__PURE__ */ new Map();
|
|
1295
|
+
for (const r of e) {
|
|
1296
|
+
const s = n.get(r.Type) ?? [];
|
|
1297
|
+
s.push(r), n.set(r.Type, s);
|
|
1299
1298
|
}
|
|
1300
|
-
return
|
|
1299
|
+
return n;
|
|
1301
1300
|
}
|
|
1302
1301
|
/**
|
|
1303
1302
|
* Handle channel state change.
|
|
1304
1303
|
*/
|
|
1305
|
-
handleChannelStateChange(e,
|
|
1306
|
-
|
|
1304
|
+
handleChannelStateChange(e, n) {
|
|
1305
|
+
n === "stopped" && (this.shouldReconnect = !1, this.disconnectAll(), this.setState("stopped"));
|
|
1307
1306
|
}
|
|
1308
1307
|
/**
|
|
1309
1308
|
* Handle channel close.
|
|
@@ -1313,7 +1312,7 @@ class Mt {
|
|
|
1313
1312
|
* close — including a clean WebSocket code 1000 — just means this transport
|
|
1314
1313
|
* dropped, and we reconnect.
|
|
1315
1314
|
*/
|
|
1316
|
-
handleChannelClose(e,
|
|
1315
|
+
handleChannelClose(e, n, r) {
|
|
1317
1316
|
this.state === "idle" || this.state === "stopped" || this.state === "offline" || this.channels.has(e) && this.state === "connected" && (I.warn("Channel closed unexpectedly, attempting reconnect"), this.disconnectAll(), this.attemptReconnect());
|
|
1318
1317
|
}
|
|
1319
1318
|
/**
|
|
@@ -1342,26 +1341,10 @@ class Mt {
|
|
|
1342
1341
|
* Disconnect all channels.
|
|
1343
1342
|
*/
|
|
1344
1343
|
disconnectAll() {
|
|
1345
|
-
this.clearStabilityTimer();
|
|
1346
1344
|
for (const e of this.channels.values())
|
|
1347
1345
|
e.disconnect();
|
|
1348
1346
|
this.channels.clear(), this.activeType = null;
|
|
1349
1347
|
}
|
|
1350
|
-
/**
|
|
1351
|
-
* Start stability timer that resets reconnect attempts after the connection
|
|
1352
|
-
* survives one keepalive timeout period without dying.
|
|
1353
|
-
*/
|
|
1354
|
-
startStabilityTimer() {
|
|
1355
|
-
this.clearStabilityTimer(), this.stabilityTimer = setTimeout(() => {
|
|
1356
|
-
this.stabilityTimer = null, this.reconnectAttempts = 0;
|
|
1357
|
-
}, this.config.keepaliveTimeoutMs);
|
|
1358
|
-
}
|
|
1359
|
-
/**
|
|
1360
|
-
* Clear the stability timer.
|
|
1361
|
-
*/
|
|
1362
|
-
clearStabilityTimer() {
|
|
1363
|
-
this.stabilityTimer && (clearTimeout(this.stabilityTimer), this.stabilityTimer = null);
|
|
1364
|
-
}
|
|
1365
1348
|
/**
|
|
1366
1349
|
* Update and notify state change.
|
|
1367
1350
|
*/
|
|
@@ -1373,7 +1356,7 @@ const at = p("ProtocolWorker"), L = (t, e) => {
|
|
|
1373
1356
|
self.postMessage(t, e ?? []);
|
|
1374
1357
|
};
|
|
1375
1358
|
let A = null, B = null, d = null, X, C = null;
|
|
1376
|
-
const P = [], f = [],
|
|
1359
|
+
const P = [], f = [], F = /* @__PURE__ */ new Map(), R = [], u = [], w = /* @__PURE__ */ new Map(), $ = [];
|
|
1377
1360
|
function Q() {
|
|
1378
1361
|
try {
|
|
1379
1362
|
A?.disconnect();
|
|
@@ -1386,7 +1369,7 @@ function Q() {
|
|
|
1386
1369
|
f[t].port.close();
|
|
1387
1370
|
} catch {
|
|
1388
1371
|
}
|
|
1389
|
-
P.length = 0, f.length = 0,
|
|
1372
|
+
P.length = 0, f.length = 0, F.clear();
|
|
1390
1373
|
for (let t = 0; t < u.length; t++)
|
|
1391
1374
|
try {
|
|
1392
1375
|
u[t].port.close();
|
|
@@ -1407,35 +1390,35 @@ function Bt() {
|
|
|
1407
1390
|
function dt(t) {
|
|
1408
1391
|
if (X === void 0)
|
|
1409
1392
|
return !0;
|
|
1410
|
-
const e =
|
|
1393
|
+
const e = v(t);
|
|
1411
1394
|
if ((e & X) !== 0)
|
|
1412
1395
|
return !0;
|
|
1413
|
-
const
|
|
1414
|
-
return (e &
|
|
1396
|
+
const n = Bt();
|
|
1397
|
+
return (e & n) !== 0;
|
|
1415
1398
|
}
|
|
1416
1399
|
function ot(t) {
|
|
1417
1400
|
$.length = 0;
|
|
1418
1401
|
for (let e = 0; e < f.length; e++) {
|
|
1419
|
-
const
|
|
1420
|
-
(
|
|
1402
|
+
const n = f[e];
|
|
1403
|
+
(n.opcodeGroupsMask & t) !== 0 && $.push(n.port);
|
|
1421
1404
|
}
|
|
1422
1405
|
return $;
|
|
1423
1406
|
}
|
|
1424
|
-
function vt(t, e) {
|
|
1425
|
-
return (F(t) & e) !== 0;
|
|
1426
|
-
}
|
|
1427
1407
|
function Ft(t, e) {
|
|
1408
|
+
return (v(t) & e) !== 0;
|
|
1409
|
+
}
|
|
1410
|
+
function vt(t, e) {
|
|
1428
1411
|
if (!A || !e || typeof e != "object")
|
|
1429
1412
|
return;
|
|
1430
|
-
const
|
|
1431
|
-
if (!(
|
|
1413
|
+
const n = e;
|
|
1414
|
+
if (!(n.type !== "send" || !(n.message instanceof ArrayBuffer)))
|
|
1432
1415
|
try {
|
|
1433
|
-
const
|
|
1434
|
-
if (!
|
|
1416
|
+
const r = new Uint8Array(n.message);
|
|
1417
|
+
if (!Ft(r, t))
|
|
1435
1418
|
return;
|
|
1436
|
-
A.sendProtocolMessage(
|
|
1437
|
-
} catch (
|
|
1438
|
-
M(
|
|
1419
|
+
A.sendProtocolMessage(r), C && C.postMessage({ direction: "sent", message: Array.from(r) });
|
|
1420
|
+
} catch (r) {
|
|
1421
|
+
M(r);
|
|
1439
1422
|
}
|
|
1440
1423
|
}
|
|
1441
1424
|
async function Gt(t) {
|
|
@@ -1455,42 +1438,42 @@ async function Gt(t) {
|
|
|
1455
1438
|
onError: (e) => {
|
|
1456
1439
|
M(e);
|
|
1457
1440
|
},
|
|
1458
|
-
onRefreshEntrypoints: () => new Promise((e,
|
|
1459
|
-
B = e, d =
|
|
1441
|
+
onRefreshEntrypoints: () => new Promise((e, n) => {
|
|
1442
|
+
B = e, d = n, L({ type: "refreshEntrypoints" });
|
|
1460
1443
|
}),
|
|
1461
1444
|
onProtocolMessage: (e) => {
|
|
1462
1445
|
C && (C.postMessage({ direction: "received", message: Array.from(e) }), j(e) === V.ANALYTICS_LOGS && C.postMessage({ type: "serverLogs", message: Array.from(e) }));
|
|
1463
|
-
const
|
|
1464
|
-
if (!(!
|
|
1446
|
+
const n = v(e), r = dt(e), s = ot(n);
|
|
1447
|
+
if (!(!r && s.length === 0))
|
|
1465
1448
|
try {
|
|
1466
|
-
const i = H(e), o = e.buffer instanceof ArrayBuffer && e.byteOffset === 0 && e.byteLength === e.buffer.byteLength, a =
|
|
1467
|
-
if (a && !
|
|
1449
|
+
const i = H(e), o = e.buffer instanceof ArrayBuffer && e.byteOffset === 0 && e.byteLength === e.buffer.byteLength, a = s.length > 0;
|
|
1450
|
+
if (a && !r && s.length === 1 && o) {
|
|
1468
1451
|
const E = e.buffer;
|
|
1469
|
-
|
|
1452
|
+
s[0].postMessage({ type: "protocol", message: E, headers: i }, [E]);
|
|
1470
1453
|
return;
|
|
1471
1454
|
}
|
|
1472
|
-
if (!a &&
|
|
1455
|
+
if (!a && r && o) {
|
|
1473
1456
|
const E = e.buffer;
|
|
1474
1457
|
L({ type: "protocol", message: E, headers: i }, [E]);
|
|
1475
1458
|
return;
|
|
1476
1459
|
}
|
|
1477
1460
|
if (a && o) {
|
|
1478
1461
|
const E = [];
|
|
1479
|
-
for (let T = 1; T <
|
|
1462
|
+
for (let T = 1; T < s.length; T++)
|
|
1480
1463
|
E.push(e.slice().buffer);
|
|
1481
|
-
const _ =
|
|
1482
|
-
|
|
1483
|
-
for (let T = 1; T <
|
|
1484
|
-
|
|
1464
|
+
const _ = r ? e.slice().buffer : null, l = e.buffer;
|
|
1465
|
+
s[0].postMessage({ type: "protocol", message: l, headers: i }, [l]);
|
|
1466
|
+
for (let T = 1; T < s.length; T++)
|
|
1467
|
+
s[T].postMessage({ type: "protocol", message: E[T - 1], headers: i }, [E[T - 1]]);
|
|
1485
1468
|
_ && L({ type: "protocol", message: _, headers: i }, [_]);
|
|
1486
1469
|
return;
|
|
1487
1470
|
}
|
|
1488
1471
|
if (a)
|
|
1489
|
-
for (const E of
|
|
1472
|
+
for (const E of s) {
|
|
1490
1473
|
const _ = e.slice().buffer;
|
|
1491
1474
|
E.postMessage({ type: "protocol", message: _, headers: i }, [_]);
|
|
1492
1475
|
}
|
|
1493
|
-
if (
|
|
1476
|
+
if (r) {
|
|
1494
1477
|
const E = e.slice().buffer;
|
|
1495
1478
|
L({ type: "protocol", message: E, headers: i }, [E]);
|
|
1496
1479
|
}
|
|
@@ -1503,8 +1486,8 @@ async function Gt(t) {
|
|
|
1503
1486
|
self.addEventListener("message", (t) => {
|
|
1504
1487
|
const e = t.data;
|
|
1505
1488
|
if (e.type === "connect") {
|
|
1506
|
-
Gt(e).catch((
|
|
1507
|
-
at.error(`Failed to connect: ${
|
|
1489
|
+
Gt(e).catch((n) => {
|
|
1490
|
+
at.error(`Failed to connect: ${n}`), M(n), Q();
|
|
1508
1491
|
});
|
|
1509
1492
|
return;
|
|
1510
1493
|
}
|
|
@@ -1516,10 +1499,10 @@ self.addEventListener("message", (t) => {
|
|
|
1516
1499
|
if (!A)
|
|
1517
1500
|
return;
|
|
1518
1501
|
try {
|
|
1519
|
-
const
|
|
1520
|
-
A.sendProtocolMessage(
|
|
1521
|
-
} catch (
|
|
1522
|
-
M(
|
|
1502
|
+
const n = new Uint8Array(e.message);
|
|
1503
|
+
A.sendProtocolMessage(n), C && C.postMessage({ direction: "sent", message: Array.from(n) });
|
|
1504
|
+
} catch (n) {
|
|
1505
|
+
M(n);
|
|
1523
1506
|
}
|
|
1524
1507
|
return;
|
|
1525
1508
|
}
|
|
@@ -1549,16 +1532,16 @@ self.addEventListener("message", (t) => {
|
|
|
1549
1532
|
}
|
|
1550
1533
|
if (e.type === "forwardToPorts") {
|
|
1551
1534
|
try {
|
|
1552
|
-
const
|
|
1553
|
-
if (
|
|
1554
|
-
const i = H(
|
|
1555
|
-
for (const o of
|
|
1556
|
-
const a =
|
|
1535
|
+
const n = new Uint8Array(e.message), r = v(n), s = ot(r);
|
|
1536
|
+
if (s.length > 0) {
|
|
1537
|
+
const i = H(n);
|
|
1538
|
+
for (const o of s) {
|
|
1539
|
+
const a = n.slice().buffer;
|
|
1557
1540
|
o.postMessage({ type: "protocol", message: a, headers: i }, [a]);
|
|
1558
1541
|
}
|
|
1559
1542
|
}
|
|
1560
|
-
} catch (
|
|
1561
|
-
M(
|
|
1543
|
+
} catch (n) {
|
|
1544
|
+
M(n);
|
|
1562
1545
|
}
|
|
1563
1546
|
return;
|
|
1564
1547
|
}
|
|
@@ -1567,65 +1550,65 @@ self.addEventListener("message", (t) => {
|
|
|
1567
1550
|
e.port.start?.();
|
|
1568
1551
|
} catch {
|
|
1569
1552
|
}
|
|
1570
|
-
const
|
|
1571
|
-
P.push(e.portId), f.push({ port: e.port, opcodeGroupsMask: e.opcodeGroupsMask }),
|
|
1553
|
+
const n = P.length;
|
|
1554
|
+
P.push(e.portId), f.push({ port: e.port, opcodeGroupsMask: e.opcodeGroupsMask }), F.set(e.portId, n);
|
|
1572
1555
|
return;
|
|
1573
1556
|
}
|
|
1574
1557
|
if (e.type === "detachPort") {
|
|
1575
|
-
const
|
|
1576
|
-
if (
|
|
1577
|
-
const
|
|
1558
|
+
const n = F.get(e.portId);
|
|
1559
|
+
if (n !== void 0) {
|
|
1560
|
+
const r = f[n];
|
|
1578
1561
|
try {
|
|
1579
|
-
|
|
1562
|
+
r.port.close();
|
|
1580
1563
|
} catch {
|
|
1581
1564
|
}
|
|
1582
|
-
const
|
|
1583
|
-
if (
|
|
1584
|
-
const i = P[
|
|
1585
|
-
P[
|
|
1565
|
+
const s = P.length - 1;
|
|
1566
|
+
if (n !== s) {
|
|
1567
|
+
const i = P[s];
|
|
1568
|
+
P[n] = i, f[n] = f[s], F.set(i, n);
|
|
1586
1569
|
}
|
|
1587
|
-
P.length--, f.length--,
|
|
1570
|
+
P.length--, f.length--, F.delete(e.portId);
|
|
1588
1571
|
}
|
|
1589
1572
|
return;
|
|
1590
1573
|
}
|
|
1591
1574
|
if (e.type === "attachSendPort") {
|
|
1592
|
-
const
|
|
1593
|
-
if (
|
|
1594
|
-
const i = u[
|
|
1575
|
+
const n = w.get(e.portId);
|
|
1576
|
+
if (n !== void 0) {
|
|
1577
|
+
const i = u[n];
|
|
1595
1578
|
try {
|
|
1596
1579
|
i.port.close();
|
|
1597
1580
|
} catch {
|
|
1598
1581
|
}
|
|
1599
1582
|
const o = R.length - 1;
|
|
1600
|
-
if (
|
|
1583
|
+
if (n !== o) {
|
|
1601
1584
|
const a = R[o];
|
|
1602
|
-
R[
|
|
1585
|
+
R[n] = a, u[n] = u[o], w.set(a, n);
|
|
1603
1586
|
}
|
|
1604
1587
|
R.length--, u.length--, w.delete(e.portId);
|
|
1605
1588
|
}
|
|
1606
|
-
const
|
|
1607
|
-
R.push(e.portId), u.push(
|
|
1589
|
+
const r = { port: e.port, opcodeGroupsMask: e.opcodeGroupsMask }, s = R.length;
|
|
1590
|
+
R.push(e.portId), u.push(r), w.set(e.portId, s);
|
|
1608
1591
|
try {
|
|
1609
|
-
|
|
1592
|
+
r.port.start?.();
|
|
1610
1593
|
} catch {
|
|
1611
1594
|
}
|
|
1612
|
-
|
|
1613
|
-
|
|
1595
|
+
r.port.addEventListener("message", (i) => {
|
|
1596
|
+
vt(r.opcodeGroupsMask, i.data);
|
|
1614
1597
|
});
|
|
1615
1598
|
return;
|
|
1616
1599
|
}
|
|
1617
1600
|
if (e.type === "detachSendPort") {
|
|
1618
|
-
const
|
|
1619
|
-
if (
|
|
1620
|
-
const
|
|
1601
|
+
const n = w.get(e.portId);
|
|
1602
|
+
if (n !== void 0) {
|
|
1603
|
+
const r = u[n];
|
|
1621
1604
|
try {
|
|
1622
|
-
|
|
1605
|
+
r.port.close();
|
|
1623
1606
|
} catch {
|
|
1624
1607
|
}
|
|
1625
|
-
const
|
|
1626
|
-
if (
|
|
1627
|
-
const i = R[
|
|
1628
|
-
R[
|
|
1608
|
+
const s = R.length - 1;
|
|
1609
|
+
if (n !== s) {
|
|
1610
|
+
const i = R[s];
|
|
1611
|
+
R[n] = i, u[n] = u[s], w.set(i, n);
|
|
1629
1612
|
}
|
|
1630
1613
|
R.length--, u.length--, w.delete(e.portId);
|
|
1631
1614
|
}
|