@ikonai/sdk 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/audio-playback-worker-BREAezCI.js +1 -0
- package/assets/protocol-worker-sC4mqNcM.js +1 -0
- package/assets/{video-capture-worker-CXXGkUg0.js → video-capture-worker-D5jsT6I4.js} +1 -1
- package/assets/{video-playback-worker-BpnzByZm.js → video-playback-worker-DcvXKGnT.js} +1 -1
- package/assets/{viseme-worker-DFgMth_1.js → viseme-worker-TOrhAq2M.js} +1 -1
- package/{capabilities-z1yDaWz3.js → capabilities-7u4F63vq.js} +1 -1
- package/connection/urls.d.ts +12 -2
- package/{ikon-media-ZZqVys00.js → ikon-media--ap3vpXf.js} +3 -3
- package/index.d.ts +3 -1
- package/index.js +1027 -917
- package/package.json +1 -1
- package/utils/embedded-oauth.d.ts +30 -0
- package/utils/pkce.d.ts +13 -0
- package/assets/audio-playback-worker-x-Mt8MXY.js +0 -1
- package/assets/protocol-worker-G-c3_38g.js +0 -1
package/index.js
CHANGED
|
@@ -1,113 +1,113 @@
|
|
|
1
|
-
import { A as e, C as t, D as n, E as r, F as i, I as a, L as o, M as s, N as c, O as l, P as u, R as d, S as f, T as p, _ as m, a as h, b as g, c as ee, d as _, f as te, g as ne, h as re, i as ie, j as v, k as y, l as ae, m as oe, o as se, p as ce, r as le, s as ue, t as de, u as fe, v as b, w as pe, x as me, y as he } from "./ikon-media
|
|
2
|
-
import { _ as ge, a as _e, c as
|
|
1
|
+
import { A as e, C as t, D as n, E as r, F as i, I as a, L as o, M as s, N as c, O as l, P as u, R as d, S as f, T as p, _ as m, a as h, b as g, c as ee, d as _, f as te, g as ne, h as re, i as ie, j as v, k as y, l as ae, m as oe, o as se, p as ce, r as le, s as ue, t as de, u as fe, v as b, w as pe, x as me, y as he } from "./ikon-media--ap3vpXf.js";
|
|
2
|
+
import { _ as ge, a as _e, c as x, d as S, f as C, g as ve, h as ye, l as be, m as xe, n as Se, p as Ce, s as we, t as Te, u as Ee, v as w } from "./capabilities-7u4F63vq.js";
|
|
3
3
|
//#region ../../shared/protocol/src/compression.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
6
|
-
return
|
|
4
|
+
var De;
|
|
5
|
+
function Oe() {
|
|
6
|
+
return De === void 0 && (De = typeof CompressionStream < "u" && typeof DecompressionStream < "u"), De;
|
|
7
7
|
}
|
|
8
|
-
var
|
|
9
|
-
function
|
|
8
|
+
var ke = 1048637, Ae = 727023925, je = 3395085689, Me = 3748161056;
|
|
9
|
+
function Ne(e) {
|
|
10
10
|
let t = new y(2);
|
|
11
|
-
return
|
|
11
|
+
return Pe(e, t), t.finish();
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
t.writeGuidField(
|
|
13
|
+
function Pe(e, t) {
|
|
14
|
+
t.writeGuidField(Ae, e.ActionId), t.writeStringField(je, e.PayloadJson), t.writeGuidField(Me, e.CallId);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
let r =
|
|
18
|
-
return s(
|
|
16
|
+
function Fe(e, t, n) {
|
|
17
|
+
let r = Ne(e);
|
|
18
|
+
return s(ke, r, 2, t, n);
|
|
19
19
|
}
|
|
20
|
-
var
|
|
21
|
-
function
|
|
20
|
+
var Ie = 1048652, Le = 3748161056;
|
|
21
|
+
function Re(e) {
|
|
22
22
|
let t = {};
|
|
23
|
-
return
|
|
23
|
+
return ze(t), e && Object.assign(t, e), t;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function ze(e) {
|
|
26
26
|
return e.CallId = n.fromBytes(/* @__PURE__ */ new Uint8Array(16)), e;
|
|
27
27
|
}
|
|
28
|
+
function Be(e, t) {
|
|
29
|
+
return Ve(l.create(e), t);
|
|
30
|
+
}
|
|
28
31
|
function Ve(e, t) {
|
|
29
|
-
|
|
32
|
+
let n = t ?? Re();
|
|
33
|
+
return ze(n), He(e, n), n;
|
|
30
34
|
}
|
|
31
35
|
function He(e, t) {
|
|
32
|
-
let n = t ?? ze();
|
|
33
|
-
return Be(n), Ue(e, n), n;
|
|
34
|
-
}
|
|
35
|
-
function Ue(e, t) {
|
|
36
36
|
let n;
|
|
37
37
|
for (; (n = e.next()) !== null;) switch (n.fieldId) {
|
|
38
|
-
case
|
|
38
|
+
case Le:
|
|
39
39
|
if (n.isNull) throw Error();
|
|
40
40
|
t.CallId = n.asGuid();
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
async function
|
|
44
|
-
return
|
|
43
|
+
async function Ue(e, t) {
|
|
44
|
+
return Be(await o(e, Ie, 1), t);
|
|
45
45
|
}
|
|
46
|
-
var
|
|
47
|
-
function
|
|
46
|
+
var We = 1048654, Ge = 2838554230, Ke = 3673535008, qe = 3748161056;
|
|
47
|
+
function Je(e) {
|
|
48
48
|
let t = {};
|
|
49
|
-
return
|
|
49
|
+
return Ye(t), e && Object.assign(t, e), t;
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function Ye(e) {
|
|
52
52
|
return e.CallId = n.fromBytes(/* @__PURE__ */ new Uint8Array(16)), e.Success = !1, e.ErrorMessage = "", e;
|
|
53
53
|
}
|
|
54
|
+
function Xe(e, t) {
|
|
55
|
+
return Ze(l.create(e), t);
|
|
56
|
+
}
|
|
54
57
|
function Ze(e, t) {
|
|
55
|
-
|
|
58
|
+
let n = t ?? Je();
|
|
59
|
+
return Ye(n), Qe(e, n), n;
|
|
56
60
|
}
|
|
57
61
|
function Qe(e, t) {
|
|
58
|
-
let n = t ?? Ye();
|
|
59
|
-
return Xe(n), $e(e, n), n;
|
|
60
|
-
}
|
|
61
|
-
function $e(e, t) {
|
|
62
62
|
let n;
|
|
63
63
|
for (; (n = e.next()) !== null;) switch (n.fieldId) {
|
|
64
|
-
case
|
|
64
|
+
case Ge:
|
|
65
65
|
if (n.isNull) throw Error();
|
|
66
66
|
t.ErrorMessage = n.asString();
|
|
67
67
|
break;
|
|
68
|
-
case
|
|
68
|
+
case Ke:
|
|
69
69
|
if (n.isNull) throw Error();
|
|
70
70
|
t.Success = n.asBool();
|
|
71
71
|
break;
|
|
72
|
-
case
|
|
72
|
+
case qe:
|
|
73
73
|
if (n.isNull) throw Error();
|
|
74
74
|
t.CallId = n.asGuid();
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
async function
|
|
78
|
-
return
|
|
77
|
+
async function $e(e, t) {
|
|
78
|
+
return Xe(await o(e, We, 1), t);
|
|
79
79
|
}
|
|
80
|
-
var
|
|
81
|
-
function
|
|
80
|
+
var et = 1048642, tt = 3748018590;
|
|
81
|
+
function nt(e) {
|
|
82
82
|
let t = {};
|
|
83
|
-
return
|
|
83
|
+
return rt(t), e && Object.assign(t, e), t;
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function rt(e) {
|
|
86
86
|
return e.Path = "", e;
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function it(e) {
|
|
89
89
|
let t = new y(1);
|
|
90
|
-
return
|
|
90
|
+
return at(e, t), t.finish();
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
t.writeStringField(
|
|
92
|
+
function at(e, t) {
|
|
93
|
+
t.writeStringField(tt, e.Path);
|
|
94
94
|
}
|
|
95
|
-
function
|
|
96
|
-
let r =
|
|
97
|
-
return s(
|
|
95
|
+
function ot(e, t, n) {
|
|
96
|
+
let r = it(e);
|
|
97
|
+
return s(et, r, 1, t, n);
|
|
98
98
|
}
|
|
99
99
|
//#endregion
|
|
100
100
|
//#region ../../shared/protocol/src/messages/context.ts
|
|
101
|
-
var
|
|
101
|
+
var st = 76337612, ct = 185396121, lt = 227309410, ut = 250031587, dt = 388632637, ft = 417197284, pt = 425972532, mt = 469070965, ht = 470595159, gt = 594855258, _t = 617065367, vt = 661691032, yt = 781727218, bt = 834078886, xt = 1043273762, St = 1236999138, Ct = 1286979607, wt = 1368629611, Tt = 1437068682, Et = 1668375353, Dt = 1715899485, Ot = 1719830747, kt = 1942830531, At = 1999510636, jt = 2033288346, Mt = 2079864626, Nt = 2142346422, Pt = 2228539873, Ft = 2232517119, It = 2388060749, Lt = 2504065971, Rt = 2598291686, zt = 2719718823, Bt = 2810953526, Vt = 2840065720, Ht = 2885165957, Ut = 3542818975, Wt = 3586157513;
|
|
102
102
|
function Gt(e) {
|
|
103
103
|
let t = {};
|
|
104
104
|
return Kt(t), e && Object.assign(t, e), t;
|
|
105
105
|
}
|
|
106
106
|
function Kt(e) {
|
|
107
|
-
return e.ContextType = m.Unknown, e.UserType = p.Unknown, e.PayloadType = me.Unknown, e.Description = "", e.UserId = "", e.DeviceId = "", e.ProductId = "", e.VersionId = "", e.InstallId = "", e.Locale = "", e.SessionId = -1, e.IsInternal = !1, e.IsSnapshot = !1, e.SnapshotVariant = "", e.IsReady = !1, e.HasInput = !1, e.AuthSessionId = "", e.IsAnonymous = !1, e.IsGlobal = !1, e.ReceiveAllMessages = !1, e.PreciseJoinedAt = BigInt(0), e.UserAgent = "", e.ClientType = ne.Unknown, e.UniqueSessionId = "", e.Parameters = Object.create(null), e.SdkType = f.Unknown, e.SdkCapability = 0, e.ViewportWidth = 0, e.ViewportHeight = 0, e.Theme = "", e.Timezone = "", e.IsTouchDevice = !1, e.InitialPath = "", e.StyleFormat = pe.Css, e.SupportsCompression = !0, e.IsSoftDisconnected = !1, e.SoftDisconnectAt = BigInt(0), e;
|
|
107
|
+
return e.ContextType = m.Unknown, e.UserType = p.Unknown, e.PayloadType = me.Unknown, e.Description = "", e.UserId = "", e.DeviceId = "", e.ProductId = "", e.VersionId = "", e.InstallId = "", e.Locale = "", e.SessionId = -1, e.IsInternal = !1, e.IsSnapshot = !1, e.SnapshotVariant = "", e.IsReady = !1, e.HasInput = !1, e.AuthSessionId = "", e.IsAnonymous = !1, e.IsGlobal = !1, e.ReceiveAllMessages = !1, e.PreciseJoinedAt = BigInt(0), e.UserAgent = "", e.ClientType = ne.Unknown, e.UniqueSessionId = "", e.Parameters = Object.create(null), e.SdkType = f.Unknown, e.SdkCapability = 0, e.ViewportWidth = 0, e.ViewportHeight = 0, e.Theme = "", e.Timezone = "", e.IsTouchDevice = !1, e.InitialPath = "", e.InitialUrl = "", e.StyleFormat = pe.Css, e.SupportsCompression = !0, e.IsSoftDisconnected = !1, e.SoftDisconnectAt = BigInt(0), e;
|
|
108
108
|
}
|
|
109
109
|
function qt(t, n) {
|
|
110
|
-
n.writeStringField(
|
|
110
|
+
n.writeStringField(st, t.DeviceId), n.writeStringField(ct, t.InstallId), n.writeStringField(lt, t.InitialUrl), n.writeStringField(ut, t.Theme), n.writeStringField(dt, t.UserAgent), n.writeInt32Field(ft, t.ContextType), n.writeUInt64Field(pt, t.SoftDisconnectAt), n.writeBoolField(mt, t.HasInput), n.writeInt32Field(ht, t.UserType), n.writeStringField(gt, t.InitialPath), n.writeBoolField(_t, t.IsSoftDisconnected), n.writeBoolField(vt, t.SupportsCompression), n.writeStringField(yt, t.UserId), n.writeStringField(bt, t.ProductId), n.writeStringField(xt, t.AuthSessionId), n.writeBoolField(St, t.ReceiveAllMessages), n.writeInt32Field(Ct, t.ViewportHeight | 0), n.writeStringField(wt, t.Description), n.writeInt32Field(Tt, t.SdkCapability | 0), n.writeBoolField(Et, t.IsSnapshot), n.writeStringField(Dt, t.Locale), n.writeBoolField(Ot, t.IsAnonymous), n.writeInt32Field(kt, t.SdkType), n.writeInt32Field(At, t.SessionId | 0), n.writeInt32Field(jt, t.ViewportWidth | 0), n.writeUInt64Field(Mt, t.PreciseJoinedAt), n.writeInt32Field(Nt, t.PayloadType), n.writeInt32Field(Pt, t.StyleFormat), n.writeBoolField(Ft, t.IsTouchDevice), n.writeBoolField(It, t.IsGlobal), n.writeStringField(Lt, t.SnapshotVariant), n.writeStringField(Rt, t.VersionId), n.writeStringField(zt, t.UniqueSessionId), n.writeInt32Field(Bt, t.ClientType), n.writeBoolField(Vt, t.IsReady), n.writeDictionaryField(Ht, e.String, e.String, (e) => {
|
|
111
111
|
let n = t.Parameters;
|
|
112
112
|
for (let t of Object.keys(n)) {
|
|
113
113
|
let r = t, i = n[t];
|
|
@@ -124,14 +124,18 @@ function Jt(e, t) {
|
|
|
124
124
|
function Yt(e, t) {
|
|
125
125
|
let n;
|
|
126
126
|
for (; (n = e.next()) !== null;) switch (n.fieldId) {
|
|
127
|
-
case
|
|
127
|
+
case st:
|
|
128
128
|
if (n.isNull) throw Error();
|
|
129
129
|
t.DeviceId = n.asString();
|
|
130
130
|
break;
|
|
131
|
-
case
|
|
131
|
+
case ct:
|
|
132
132
|
if (n.isNull) throw Error();
|
|
133
133
|
t.InstallId = n.asString();
|
|
134
134
|
break;
|
|
135
|
+
case lt:
|
|
136
|
+
if (n.isNull) throw Error();
|
|
137
|
+
t.InitialUrl = n.asString();
|
|
138
|
+
break;
|
|
135
139
|
case ut:
|
|
136
140
|
if (n.isNull) throw Error();
|
|
137
141
|
t.Theme = n.asString();
|
|
@@ -288,7 +292,7 @@ function Zt(e) {
|
|
|
288
292
|
return Qt(t), e && Object.assign(t, e), t;
|
|
289
293
|
}
|
|
290
294
|
function Qt(e) {
|
|
291
|
-
return e.ServerSessionId = "", e.ContextType = m.Unknown, e.UserType = p.Unknown, e.PayloadType = me.Unknown, e.IsInternal = !1, e.IsSnapshot = !1, e.SnapshotVariant = "", e.Description = "", e.UserId = "", e.DeviceId = "", e.ProductId = "", e.VersionId = "", e.InstallId = "", e.Locale = "", e.OpcodeGroupsFromServer =
|
|
295
|
+
return e.ServerSessionId = "", e.ContextType = m.Unknown, e.UserType = p.Unknown, e.PayloadType = me.Unknown, e.IsInternal = !1, e.IsSnapshot = !1, e.SnapshotVariant = "", e.Description = "", e.UserId = "", e.DeviceId = "", e.ProductId = "", e.VersionId = "", e.InstallId = "", e.Locale = "", e.OpcodeGroupsFromServer = w.NONE, e.OpcodeGroupsToServer = w.NONE, e.ProtocolVersion = 0, e.HasInput = !1, e.AuthSessionId = "", e.IsAnonymous = !1, e.IsGlobal = !1, e.ReceiveAllMessages = !1, e.UserAgent = "", e.ClientType = ne.Unknown, e.Parameters = Object.create(null), e.SdkType = f.Unknown, e.SdkCapability = 0, e.ViewportWidth = 0, e.ViewportHeight = 0, e.Theme = "", e.Timezone = "", e.IsTouchDevice = !1, e.InitialPath = "", e.InitialUrl = "", e.StyleFormat = pe.Css, e.SupportsCompression = !0, e;
|
|
292
296
|
}
|
|
293
297
|
var $t = 746516514, en = 877841741, tn = 1175184220, nn = 1368629611, rn = 2341021724, an = 3167053791, on = 3632106223, sn = 3686066300;
|
|
294
298
|
function cn(e) {
|
|
@@ -296,7 +300,7 @@ function cn(e) {
|
|
|
296
300
|
return ln(t), e && Object.assign(t, e), t;
|
|
297
301
|
}
|
|
298
302
|
function ln(e) {
|
|
299
|
-
return e.Type = b.None, e.Uri = "", e.OpcodeGroupsFromServer =
|
|
303
|
+
return e.Type = b.None, e.Uri = "", e.OpcodeGroupsFromServer = w.NONE, e.OpcodeGroupsToServer = w.NONE, e.Priority = 0, e.Description = "", e.AuthTicket = /* @__PURE__ */ new Uint8Array(), e.IsUnreliable = !1, e;
|
|
300
304
|
}
|
|
301
305
|
function un(e, t) {
|
|
302
306
|
let n = t ?? cn();
|
|
@@ -1611,7 +1615,7 @@ function Gc(e) {
|
|
|
1611
1615
|
return Kc(t), e && Object.assign(t, e), t;
|
|
1612
1616
|
}
|
|
1613
1617
|
function Kc(e) {
|
|
1614
|
-
return e.Sdp = "", e.OpcodeGroupsFromServer =
|
|
1618
|
+
return e.Sdp = "", e.OpcodeGroupsFromServer = w.NONE, e.OpcodeGroupsToServer = w.NONE, e.UseAudioTrack = !1, e.UseVideoTrack = !1, e.UseDataChannel = !1, e;
|
|
1615
1619
|
}
|
|
1616
1620
|
function qc(e) {
|
|
1617
1621
|
let t = new y(1);
|
|
@@ -1731,19 +1735,19 @@ var Dl = class extends Error {
|
|
|
1731
1735
|
constructor(e, t) {
|
|
1732
1736
|
super(e), this.cause = t, this.name = "ConnectionError";
|
|
1733
1737
|
}
|
|
1734
|
-
},
|
|
1738
|
+
}, T = class extends Dl {
|
|
1735
1739
|
constructor(e, t) {
|
|
1736
1740
|
super(e, t), this.name = "AuthenticationError";
|
|
1737
1741
|
}
|
|
1738
|
-
},
|
|
1742
|
+
}, E = class extends Dl {
|
|
1739
1743
|
constructor(e, t) {
|
|
1740
1744
|
super(e, t), this.name = "TransportError";
|
|
1741
1745
|
}
|
|
1742
|
-
}, Ol = class extends
|
|
1746
|
+
}, Ol = class extends E {
|
|
1743
1747
|
constructor(e) {
|
|
1744
1748
|
super(`No keepalive received within ${e}ms`), this.name = "KeepaliveTimeoutError";
|
|
1745
1749
|
}
|
|
1746
|
-
},
|
|
1750
|
+
}, D = class extends E {
|
|
1747
1751
|
constructor(e, t) {
|
|
1748
1752
|
super(e, t), this.name = "AuthRejectedError";
|
|
1749
1753
|
}
|
|
@@ -1751,33 +1755,33 @@ var Dl = class extends Error {
|
|
|
1751
1755
|
constructor(e) {
|
|
1752
1756
|
super(`Maximum reconnection attempts (${e}) exceeded`), this.name = "MaxRetriesExceededError";
|
|
1753
1757
|
}
|
|
1754
|
-
}, Al = class extends
|
|
1758
|
+
}, Al = class extends T {
|
|
1755
1759
|
constructor(e) {
|
|
1756
1760
|
super(`App session provisioning timeout after ${e}ms`), this.name = "ProvisioningTimeoutError";
|
|
1757
1761
|
}
|
|
1758
|
-
},
|
|
1762
|
+
}, O = class extends T {
|
|
1759
1763
|
constructor(e = "The app failed to start") {
|
|
1760
1764
|
super(e), this.name = "AppStartupFailedError";
|
|
1761
1765
|
}
|
|
1762
|
-
}, jl = class extends
|
|
1766
|
+
}, jl = class extends T {
|
|
1763
1767
|
constructor(e) {
|
|
1764
1768
|
super(`Space not found for domain: ${e}`), this.name = "SpaceNotFoundError";
|
|
1765
1769
|
}
|
|
1766
|
-
}, Ml = class extends
|
|
1770
|
+
}, Ml = class extends T {
|
|
1767
1771
|
reason;
|
|
1768
1772
|
constructor(e, t) {
|
|
1769
1773
|
super(e), this.reason = t, this.name = "AccessDeniedError";
|
|
1770
1774
|
}
|
|
1771
|
-
}, Nl = class extends
|
|
1775
|
+
}, Nl = class extends T {
|
|
1772
1776
|
sessionIdentityHash;
|
|
1773
1777
|
constructor(e) {
|
|
1774
1778
|
super(`No live app session for sessionIdentityHash ${e}`), this.sessionIdentityHash = e, this.name = "SessionNotFoundError";
|
|
1775
1779
|
}
|
|
1776
|
-
}, Pl = class extends
|
|
1780
|
+
}, Pl = class extends T {
|
|
1777
1781
|
constructor(e) {
|
|
1778
1782
|
super(e), this.name = "ServerFullError";
|
|
1779
1783
|
}
|
|
1780
|
-
}, Fl = class extends
|
|
1784
|
+
}, Fl = class extends T {
|
|
1781
1785
|
status;
|
|
1782
1786
|
constructor(e, t) {
|
|
1783
1787
|
super(e), this.status = t, this.name = "ServerUnavailableError";
|
|
@@ -1807,78 +1811,78 @@ function Ll(e, t) {
|
|
|
1807
1811
|
//#endregion
|
|
1808
1812
|
//#region src/utils/query-params.ts
|
|
1809
1813
|
var Rl = "ikon-proxy", zl = "ikon-websocket", Bl = "ikon-webtransport", Vl = "ikon-debug", Hl = "ikon-lang", Ul = "ikon-server-url", Wl = "ikon-audio", Gl = "ikon-video", Kl = "ikon-webrtc", ql = "ikon-ice-transport", Jl = "ikon-inspect", Yl = "ikon-debug-overlay", Xl = "ikon-auth", Zl = "ikon-retry", Ql = "ikon-api", $l = "ikon-snapshot", eu = "ikon-session";
|
|
1810
|
-
function
|
|
1814
|
+
function k(e, t) {
|
|
1811
1815
|
if (typeof window > "u") return null;
|
|
1812
1816
|
let n = new URLSearchParams(window.location.search), r = n.get(e);
|
|
1813
1817
|
if (r !== null) return r;
|
|
1814
1818
|
let i = n.get(e.replace(/-/g, "_"));
|
|
1815
1819
|
return i === null ? t ? n.get(t) : null : i;
|
|
1816
1820
|
}
|
|
1817
|
-
function
|
|
1818
|
-
let n =
|
|
1821
|
+
function A(e, t) {
|
|
1822
|
+
let n = k(e, t);
|
|
1819
1823
|
return n === "true" || n !== "false" && null;
|
|
1820
1824
|
}
|
|
1821
|
-
function
|
|
1825
|
+
function tu(e, t) {
|
|
1822
1826
|
if (typeof window > "u") return;
|
|
1823
1827
|
let n = new URL(window.location.href);
|
|
1824
1828
|
n.searchParams.get(e) !== t && (n.searchParams.set(e, t), window.history.replaceState(null, "", n.toString()));
|
|
1825
1829
|
}
|
|
1830
|
+
function nu() {
|
|
1831
|
+
return A(Rl);
|
|
1832
|
+
}
|
|
1826
1833
|
function ru() {
|
|
1827
|
-
return
|
|
1834
|
+
return A(zl);
|
|
1828
1835
|
}
|
|
1829
1836
|
function iu() {
|
|
1830
|
-
return
|
|
1837
|
+
return A(Bl);
|
|
1831
1838
|
}
|
|
1832
1839
|
function au() {
|
|
1833
|
-
return
|
|
1840
|
+
return A(Vl) === !0;
|
|
1834
1841
|
}
|
|
1835
1842
|
function ou() {
|
|
1836
|
-
return
|
|
1843
|
+
return k(Hl);
|
|
1837
1844
|
}
|
|
1838
1845
|
function su() {
|
|
1839
|
-
return
|
|
1846
|
+
return k(Ul);
|
|
1840
1847
|
}
|
|
1841
1848
|
function cu() {
|
|
1842
|
-
return
|
|
1849
|
+
return A(Wl);
|
|
1843
1850
|
}
|
|
1844
1851
|
function lu() {
|
|
1845
|
-
return
|
|
1852
|
+
return A(Gl);
|
|
1846
1853
|
}
|
|
1847
1854
|
function uu() {
|
|
1848
|
-
return
|
|
1855
|
+
return A(Kl);
|
|
1849
1856
|
}
|
|
1850
1857
|
function du() {
|
|
1851
|
-
|
|
1858
|
+
let e = k(ql);
|
|
1859
|
+
return e === "relay" ? "relay" : e === "all" ? "all" : null;
|
|
1852
1860
|
}
|
|
1853
1861
|
function fu() {
|
|
1854
|
-
|
|
1855
|
-
return e === "relay" ? "relay" : e === "all" ? "all" : null;
|
|
1862
|
+
return A(Jl) === !0;
|
|
1856
1863
|
}
|
|
1857
1864
|
function pu() {
|
|
1858
|
-
return
|
|
1865
|
+
return A(Yl) === !0;
|
|
1859
1866
|
}
|
|
1860
1867
|
function mu() {
|
|
1861
|
-
|
|
1862
|
-
}
|
|
1863
|
-
function hu() {
|
|
1864
|
-
let e = tu(Xl);
|
|
1868
|
+
let e = k(Xl);
|
|
1865
1869
|
return e === "true" || e === "same";
|
|
1866
1870
|
}
|
|
1867
|
-
function
|
|
1868
|
-
return
|
|
1871
|
+
function j() {
|
|
1872
|
+
return A(Zl) !== !1;
|
|
1873
|
+
}
|
|
1874
|
+
function hu() {
|
|
1875
|
+
return A(Ql);
|
|
1869
1876
|
}
|
|
1870
1877
|
function gu() {
|
|
1871
|
-
return
|
|
1878
|
+
return A($l) === !0;
|
|
1872
1879
|
}
|
|
1873
1880
|
function _u() {
|
|
1874
|
-
return
|
|
1875
|
-
}
|
|
1876
|
-
function vu() {
|
|
1877
|
-
return tu(eu);
|
|
1881
|
+
return k(eu);
|
|
1878
1882
|
}
|
|
1879
1883
|
//#endregion
|
|
1880
1884
|
//#region src/transport/web-socket-transport.ts
|
|
1881
|
-
var
|
|
1885
|
+
var vu = C("WebSocketTransport"), yu = 1e4, bu = class {
|
|
1882
1886
|
ws = null;
|
|
1883
1887
|
keepaliveTimeout = null;
|
|
1884
1888
|
isClosed = !1;
|
|
@@ -1901,27 +1905,27 @@ var A = S("WebSocketTransport"), yu = 1e4, bu = class {
|
|
|
1901
1905
|
try {
|
|
1902
1906
|
this.ws = new WebSocket(e), this.ws.binaryType = "arraybuffer";
|
|
1903
1907
|
} catch (e) {
|
|
1904
|
-
i(new
|
|
1908
|
+
i(new E(`Failed to create WebSocket: ${e}`, e instanceof Error ? e : void 0));
|
|
1905
1909
|
return;
|
|
1906
1910
|
}
|
|
1907
1911
|
let a = !1, o = !1, s = () => {
|
|
1908
1912
|
clearTimeout(u), this.ws && (this.ws.onopen = null, this.ws.onerror = null, this.ws.onclose = null, this.ws.onmessage = null);
|
|
1909
1913
|
}, c = () => {
|
|
1910
|
-
o || (o = !0, clearTimeout(u), this.firstMessageResolver = null,
|
|
1914
|
+
o || (o = !0, clearTimeout(u), this.firstMessageResolver = null, vu.debug(`WebSocket connected in ${Date.now() - n}ms`), r());
|
|
1911
1915
|
}, l = (e) => {
|
|
1912
1916
|
o || (o = !0, this.firstMessageResolver = null, s(), i(e));
|
|
1913
1917
|
};
|
|
1914
1918
|
this.firstMessageResolver = c;
|
|
1915
1919
|
let u = setTimeout(() => {
|
|
1916
|
-
this.ws?.close(),
|
|
1920
|
+
this.ws?.close(), vu.warn(`WebSocket connection timeout after ${this.connectionTimeoutMs}ms`), l(new E("WebSocket connection timeout"));
|
|
1917
1921
|
}, this.connectionTimeoutMs);
|
|
1918
1922
|
this.ws.onopen = () => {
|
|
1919
1923
|
a = !0, this.ws.send(t), this.resetKeepaliveTimeout();
|
|
1920
1924
|
}, this.ws.onerror = () => {
|
|
1921
|
-
|
|
1925
|
+
vu.debug(`WebSocket connection failed after ${Date.now() - n}ms`), l(new E("WebSocket connection failed"));
|
|
1922
1926
|
}, this.ws.onclose = (e) => {
|
|
1923
1927
|
if (this.clearKeepaliveTimeout(), !o) {
|
|
1924
|
-
l(a ? new
|
|
1928
|
+
l(a ? new D("WebSocket closed before first server message") : new E("WebSocket connection closed before opening"));
|
|
1925
1929
|
return;
|
|
1926
1930
|
}
|
|
1927
1931
|
if (this.isClosed) return;
|
|
@@ -1933,7 +1937,7 @@ var A = S("WebSocketTransport"), yu = 1e4, bu = class {
|
|
|
1933
1937
|
});
|
|
1934
1938
|
}
|
|
1935
1939
|
send(e) {
|
|
1936
|
-
this.ws?.readyState === WebSocket.OPEN ? this.ws.send(e) :
|
|
1940
|
+
this.ws?.readyState === WebSocket.OPEN ? this.ws.send(e) : vu.warn("Cannot send: WebSocket not connected");
|
|
1937
1941
|
}
|
|
1938
1942
|
close() {
|
|
1939
1943
|
this.isClosed = !0, this.clearKeepaliveTimeout(), this.ws &&= (this.ws.close(1e3, "Client closing"), null);
|
|
@@ -1944,24 +1948,24 @@ var A = S("WebSocketTransport"), yu = 1e4, bu = class {
|
|
|
1944
1948
|
handleProtocolMessage(e) {
|
|
1945
1949
|
try {
|
|
1946
1950
|
let t = i(e).opcode;
|
|
1947
|
-
if (this.firstMessageResolver && this.firstMessageResolver(), t ===
|
|
1951
|
+
if (this.firstMessageResolver && this.firstMessageResolver(), t === w.KEEPALIVE_REQUEST) {
|
|
1948
1952
|
this.send(this.getKeepaliveResponse()), this.resetKeepaliveTimeout();
|
|
1949
1953
|
return;
|
|
1950
1954
|
}
|
|
1951
1955
|
this.resetKeepaliveTimeout(), this.callbacks.onProtocolMessage(e);
|
|
1952
1956
|
} catch (e) {
|
|
1953
|
-
|
|
1957
|
+
vu.error("Failed to process protocol message:", e), this.callbacks.onError(e instanceof Error ? e : Error(String(e)));
|
|
1954
1958
|
}
|
|
1955
1959
|
}
|
|
1956
1960
|
resetKeepaliveTimeout() {
|
|
1957
1961
|
this.clearKeepaliveTimeout(), !(this.keepaliveTimeoutMs <= 0) && (this.keepaliveTimeout = setTimeout(() => {
|
|
1958
|
-
|
|
1962
|
+
vu.error(`No keepalive received in ${this.keepaliveTimeoutMs}ms, closing connection`), this.callbacks.onError(new Ol(this.keepaliveTimeoutMs)), this.close();
|
|
1959
1963
|
}, this.keepaliveTimeoutMs));
|
|
1960
1964
|
}
|
|
1961
1965
|
clearKeepaliveTimeout() {
|
|
1962
1966
|
this.keepaliveTimeout &&= (clearTimeout(this.keepaliveTimeout), null);
|
|
1963
1967
|
}
|
|
1964
|
-
},
|
|
1968
|
+
}, M = C("WebTransportTransport"), xu = 1e4, Su = 4, Cu = 65536;
|
|
1965
1969
|
function wu() {
|
|
1966
1970
|
return typeof WebTransport < "u";
|
|
1967
1971
|
}
|
|
@@ -1992,7 +1996,7 @@ var Tu = class {
|
|
|
1992
1996
|
return this.transport !== null && this.writer !== null;
|
|
1993
1997
|
}
|
|
1994
1998
|
async connect(e, t) {
|
|
1995
|
-
if (!wu()) throw new
|
|
1999
|
+
if (!wu()) throw new E("WebTransport is not supported in this browser");
|
|
1996
2000
|
this.isClosed = !1;
|
|
1997
2001
|
let n = Date.now(), r = new Promise((e, t) => {
|
|
1998
2002
|
this.firstMessageResolver = e, this.firstMessageRejecter = t;
|
|
@@ -2000,42 +2004,42 @@ var Tu = class {
|
|
|
2000
2004
|
try {
|
|
2001
2005
|
this.transport = new WebTransport(e);
|
|
2002
2006
|
let i, a = new Promise((e, t) => {
|
|
2003
|
-
i = setTimeout(() => t(new
|
|
2007
|
+
i = setTimeout(() => t(new E("WebTransport connection timeout")), this.connectionTimeoutMs);
|
|
2004
2008
|
});
|
|
2005
2009
|
try {
|
|
2006
2010
|
await Promise.race([this.transport.ready, a]);
|
|
2007
2011
|
} catch (e) {
|
|
2008
|
-
throw e instanceof
|
|
2012
|
+
throw e instanceof E && M.warn(`WebTransport connection timeout after ${this.connectionTimeoutMs}ms`), e;
|
|
2009
2013
|
} finally {
|
|
2010
2014
|
clearTimeout(i);
|
|
2011
2015
|
}
|
|
2012
2016
|
this.transport.closed.then(() => {
|
|
2013
2017
|
this.handleClose("Connection closed", !0);
|
|
2014
2018
|
}).catch((e) => {
|
|
2015
|
-
|
|
2019
|
+
M.error("WebTransport connection closed with error:", e), this.handleClose(e instanceof Error ? e.message : "Connection error", !1);
|
|
2016
2020
|
}), this.stream = await this.transport.createBidirectionalStream(), this.reader = this.stream.readable.getReader(), this.writer = this.stream.writable.getWriter(), await this.writer.write(t), this.resetKeepaliveTimeout(), this.startReadLoop();
|
|
2017
2021
|
let o = Math.max(this.connectionTimeoutMs - (Date.now() - n), 1), s, c = new Promise((e, t) => {
|
|
2018
|
-
s = setTimeout(() => t(new
|
|
2022
|
+
s = setTimeout(() => t(new E("WebTransport closed before first server message")), o);
|
|
2019
2023
|
});
|
|
2020
2024
|
try {
|
|
2021
2025
|
await Promise.race([r, c]);
|
|
2022
2026
|
} finally {
|
|
2023
2027
|
clearTimeout(s);
|
|
2024
2028
|
}
|
|
2025
|
-
this.firstMessageResolver = null, this.firstMessageRejecter = null,
|
|
2029
|
+
this.firstMessageResolver = null, this.firstMessageRejecter = null, M.info(`WebTransport connected in ${Date.now() - n}ms`);
|
|
2026
2030
|
} catch (e) {
|
|
2027
2031
|
this.firstMessageResolver = null, this.firstMessageRejecter = null, this.isClosed = !0, this.cleanup();
|
|
2028
2032
|
let t = Date.now() - n;
|
|
2029
|
-
throw
|
|
2033
|
+
throw M.warn(`WebTransport connection failed after ${t}ms: ${e}`), new E(`Failed to connect WebTransport: ${e}`, e instanceof Error ? e : void 0);
|
|
2030
2034
|
}
|
|
2031
2035
|
}
|
|
2032
2036
|
send(e) {
|
|
2033
2037
|
if (!this.writer) {
|
|
2034
|
-
|
|
2038
|
+
M.warn("Cannot send: WebTransport not connected");
|
|
2035
2039
|
return;
|
|
2036
2040
|
}
|
|
2037
2041
|
this.writer.write(e).catch((e) => {
|
|
2038
|
-
|
|
2042
|
+
M.error("Failed to send protocol message:", e), this.callbacks.onError(e instanceof Error ? e : Error(String(e)));
|
|
2039
2043
|
});
|
|
2040
2044
|
}
|
|
2041
2045
|
close() {
|
|
@@ -2052,7 +2056,7 @@ var Tu = class {
|
|
|
2052
2056
|
}
|
|
2053
2057
|
this.readLoopActive && this.handleClose("Stream ended", !1);
|
|
2054
2058
|
} catch (e) {
|
|
2055
|
-
this.readLoopActive && (
|
|
2059
|
+
this.readLoopActive && (M.error("Read loop error:", e), this.callbacks.onError(e instanceof Error ? e : Error(String(e))));
|
|
2056
2060
|
}
|
|
2057
2061
|
}
|
|
2058
2062
|
}
|
|
@@ -2076,7 +2080,7 @@ var Tu = class {
|
|
|
2076
2080
|
for (; this.receiveBufferLength >= Su;) {
|
|
2077
2081
|
let t = e.getUint32(this.receiveBufferOffset, !0);
|
|
2078
2082
|
if (t < Su) {
|
|
2079
|
-
|
|
2083
|
+
M.error(`Invalid message length: ${t}`), this.callbacks.onError(/* @__PURE__ */ Error(`Invalid protocol message length: ${t}`)), this.receiveBufferOffset = 0, this.receiveBufferLength = 0;
|
|
2080
2084
|
return;
|
|
2081
2085
|
}
|
|
2082
2086
|
if (this.receiveBufferLength < t) return;
|
|
@@ -2088,19 +2092,19 @@ var Tu = class {
|
|
|
2088
2092
|
handleProtocolMessage(e) {
|
|
2089
2093
|
try {
|
|
2090
2094
|
let t = i(e).opcode;
|
|
2091
|
-
if (this.firstMessageResolver && this.firstMessageResolver(), t ===
|
|
2095
|
+
if (this.firstMessageResolver && this.firstMessageResolver(), t === w.KEEPALIVE_REQUEST) {
|
|
2092
2096
|
this.send(this.getKeepaliveResponse()), this.resetKeepaliveTimeout();
|
|
2093
2097
|
return;
|
|
2094
2098
|
}
|
|
2095
2099
|
this.resetKeepaliveTimeout(), this.callbacks.onProtocolMessage(e);
|
|
2096
2100
|
} catch (e) {
|
|
2097
|
-
|
|
2101
|
+
M.error("Failed to process protocol message:", e), this.callbacks.onError(e instanceof Error ? e : Error(String(e)));
|
|
2098
2102
|
}
|
|
2099
2103
|
}
|
|
2100
2104
|
handleClose(e, t) {
|
|
2101
2105
|
if (!this.isClosed) {
|
|
2102
2106
|
if (this.isClosed = !0, this.clearKeepaliveTimeout(), this.readLoopActive = !1, this.cleanup(), this.firstMessageRejecter) {
|
|
2103
|
-
this.firstMessageRejecter(new
|
|
2107
|
+
this.firstMessageRejecter(new D(`WebTransport closed before first server message: ${e}`)), this.firstMessageResolver = null, this.firstMessageRejecter = null;
|
|
2104
2108
|
return;
|
|
2105
2109
|
}
|
|
2106
2110
|
this.callbacks.onClose(e, t);
|
|
@@ -2108,7 +2112,7 @@ var Tu = class {
|
|
|
2108
2112
|
}
|
|
2109
2113
|
resetKeepaliveTimeout() {
|
|
2110
2114
|
this.clearKeepaliveTimeout(), !(this.keepaliveTimeoutMs <= 0) && (this.keepaliveTimeout = setTimeout(() => {
|
|
2111
|
-
|
|
2115
|
+
M.error(`No keepalive received in ${this.keepaliveTimeoutMs}ms, closing connection`), this.callbacks.onError(new Ol(this.keepaliveTimeoutMs)), this.close();
|
|
2112
2116
|
}, this.keepaliveTimeoutMs));
|
|
2113
2117
|
}
|
|
2114
2118
|
clearKeepaliveTimeout() {
|
|
@@ -2122,7 +2126,7 @@ var Tu = class {
|
|
|
2122
2126
|
this.transport = null;
|
|
2123
2127
|
}
|
|
2124
2128
|
}
|
|
2125
|
-
}, Eu =
|
|
2129
|
+
}, Eu = C("Channel"), Du = class {
|
|
2126
2130
|
state = "disconnected";
|
|
2127
2131
|
transport = null;
|
|
2128
2132
|
config;
|
|
@@ -2195,7 +2199,7 @@ var Tu = class {
|
|
|
2195
2199
|
handleProtocolMessage(e) {
|
|
2196
2200
|
try {
|
|
2197
2201
|
let t = v(e);
|
|
2198
|
-
if (c(t) ===
|
|
2202
|
+
if (c(t) === w.CORE_ON_SERVER_STOPPING) {
|
|
2199
2203
|
Eu.debug("Received server stopping message"), this.setState("stopped"), this.transport?.close();
|
|
2200
2204
|
return;
|
|
2201
2205
|
}
|
|
@@ -2213,7 +2217,7 @@ var Tu = class {
|
|
|
2213
2217
|
setState(e) {
|
|
2214
2218
|
this.state !== e && (this.state = e, this.config.onStateChange?.(e));
|
|
2215
2219
|
}
|
|
2216
|
-
},
|
|
2220
|
+
}, N = C("ChannelManager"), Ou = 5e3, ku = class {
|
|
2217
2221
|
channels = /* @__PURE__ */ new Map();
|
|
2218
2222
|
activeType = null;
|
|
2219
2223
|
state = "idle";
|
|
@@ -2250,7 +2254,7 @@ var Tu = class {
|
|
|
2250
2254
|
r.send(e);
|
|
2251
2255
|
return;
|
|
2252
2256
|
}
|
|
2253
|
-
this.state === "connected" &&
|
|
2257
|
+
this.state === "connected" && N.warn("No channel found for message");
|
|
2254
2258
|
}
|
|
2255
2259
|
sendToAll(e) {
|
|
2256
2260
|
for (let t of this.channels.values()) t.send(e);
|
|
@@ -2260,7 +2264,7 @@ var Tu = class {
|
|
|
2260
2264
|
}
|
|
2261
2265
|
triggerReconnect(e) {
|
|
2262
2266
|
if (this.state === "connected") {
|
|
2263
|
-
|
|
2267
|
+
N.debug(`Forcing reconnect: ${e}`);
|
|
2264
2268
|
for (let t of this.channels.values()) t.triggerReconnect(e);
|
|
2265
2269
|
}
|
|
2266
2270
|
}
|
|
@@ -2273,26 +2277,26 @@ var Tu = class {
|
|
|
2273
2277
|
let e = new Set(n.keys());
|
|
2274
2278
|
r = this.config.orderedEndpointTypes.filter((t) => e.has(t));
|
|
2275
2279
|
} else r = this.config.endpointSelector ? this.config.endpointSelector.getOrderedTypes(n) : Array.from(n.keys());
|
|
2276
|
-
this.connectionTimeoutMs = r.length > 1 ? 5e3 : 1e4,
|
|
2280
|
+
this.connectionTimeoutMs = r.length > 1 ? 5e3 : 1e4, N.debug(`Endpoint types to try: [${r.map((e) => b[e]).join(", ")}], transport timeout: ${this.connectionTimeoutMs}ms`);
|
|
2277
2281
|
for (let e of r) {
|
|
2278
2282
|
if (!this.shouldReconnect) return;
|
|
2279
2283
|
let t = n.get(e), r = Date.now();
|
|
2280
|
-
|
|
2284
|
+
N.debug(`Trying ${b[e]} (${t.length} channel(s))`);
|
|
2281
2285
|
try {
|
|
2282
|
-
await this.connectAllChannels(t), this.config.endpointSelector?.rememberWorkingType(e), this.config.onRememberWorkingType?.(e), this.activeType = e,
|
|
2286
|
+
await this.connectAllChannels(t), this.config.endpointSelector?.rememberWorkingType(e), this.config.onRememberWorkingType?.(e), this.activeType = e, N.debug(`Connected via ${b[e]} in ${Date.now() - r}ms`), this.setState("connected"), this.startStabilityTimer();
|
|
2283
2287
|
return;
|
|
2284
2288
|
} catch (t) {
|
|
2285
|
-
|
|
2289
|
+
N.warn(`Failed to connect using ${b[e]} after ${Date.now() - r}ms: ${t instanceof Error ? t.message : t}`);
|
|
2286
2290
|
let i = this.channels.size > 0;
|
|
2287
|
-
if (this.disconnectAll(), t instanceof
|
|
2291
|
+
if (this.disconnectAll(), t instanceof D) throw t;
|
|
2288
2292
|
if (i && this.config.onRefreshEntrypoints) try {
|
|
2289
|
-
|
|
2293
|
+
N.info("Partial connection detected, refreshing entrypoints");
|
|
2290
2294
|
let e = await this.config.onRefreshEntrypoints();
|
|
2291
2295
|
this.entrypoints = e.entrypoints, this.config.sessionId = e.sessionId;
|
|
2292
2296
|
let t = e.entrypoints.filter((e) => e.Type !== b.WebRTC), r = this.groupByType(t);
|
|
2293
2297
|
for (let [e, t] of r) n.set(e, t);
|
|
2294
2298
|
} catch (e) {
|
|
2295
|
-
|
|
2299
|
+
N.warn(`Failed to refresh entrypoints: ${e}`);
|
|
2296
2300
|
}
|
|
2297
2301
|
}
|
|
2298
2302
|
}
|
|
@@ -2303,7 +2307,7 @@ var Tu = class {
|
|
|
2303
2307
|
let t = (await Promise.allSettled(e.map((e) => this.connectChannel(e)))).filter((e) => e.status === "rejected");
|
|
2304
2308
|
if (t.length > 0) {
|
|
2305
2309
|
let e = t.map((e) => e.reason instanceof Error ? e.reason.message : String(e.reason));
|
|
2306
|
-
throw t.some((e) => e.reason instanceof
|
|
2310
|
+
throw t.some((e) => e.reason instanceof D) ? new D(e.join(", ")) : Error(e.join(", "));
|
|
2307
2311
|
}
|
|
2308
2312
|
}
|
|
2309
2313
|
async connectChannel(e) {
|
|
@@ -2339,31 +2343,31 @@ var Tu = class {
|
|
|
2339
2343
|
t === "stopped" && (this.shouldReconnect = !1, this.disconnectAll(), this.setState("stopped"));
|
|
2340
2344
|
}
|
|
2341
2345
|
handleChannelClose(e, t, n) {
|
|
2342
|
-
this.state !== "idle" && this.state !== "stopped" && this.state !== "offline" && this.channels.has(e) && this.state === "connected" && (
|
|
2346
|
+
this.state !== "idle" && this.state !== "stopped" && this.state !== "offline" && this.channels.has(e) && this.state === "connected" && (N.warn("Channel closed unexpectedly, attempting reconnect"), this.disconnectAll(), this.attemptReconnect());
|
|
2343
2347
|
}
|
|
2344
2348
|
async attemptReconnect() {
|
|
2345
2349
|
if (this.shouldReconnect) {
|
|
2346
|
-
if (!
|
|
2347
|
-
|
|
2350
|
+
if (!j()) {
|
|
2351
|
+
N.warn("Retry disabled via ikon-retry=false, skipping reconnect"), this.setState("offline"), this.config.onError?.(new kl(0));
|
|
2348
2352
|
return;
|
|
2349
2353
|
}
|
|
2350
2354
|
if (this.reconnectAttempts >= this.config.maxReconnectAttempts) {
|
|
2351
|
-
|
|
2355
|
+
N.warn(`Max reconnect attempts (${this.config.maxReconnectAttempts}) reached`), this.setState("offline"), this.config.onError?.(new kl(this.config.maxReconnectAttempts));
|
|
2352
2356
|
return;
|
|
2353
2357
|
}
|
|
2354
2358
|
if (this.setState("reconnecting"), this.reconnectAttempts++, this.reconnectAttempts > 1) {
|
|
2355
|
-
|
|
2359
|
+
N.info(`Reconnecting in ${this.config.reconnectBackoffMs}ms (attempt ${this.reconnectAttempts}/${this.config.maxReconnectAttempts})`);
|
|
2356
2360
|
try {
|
|
2357
2361
|
await Ll(this.config.reconnectBackoffMs, this.abortController?.signal);
|
|
2358
2362
|
} catch {
|
|
2359
2363
|
return;
|
|
2360
2364
|
}
|
|
2361
|
-
} else
|
|
2365
|
+
} else N.info(`Reconnecting immediately (attempt ${this.reconnectAttempts}/${this.config.maxReconnectAttempts})`);
|
|
2362
2366
|
if (this.shouldReconnect) try {
|
|
2363
2367
|
await this.connectInternal(!0);
|
|
2364
2368
|
} catch (e) {
|
|
2365
|
-
if (e instanceof
|
|
2366
|
-
|
|
2369
|
+
if (e instanceof D) {
|
|
2370
|
+
N.warn("Auth rejected during reconnect, stopping retries and signaling full re-auth"), this.config.onError?.(e), this.setState("offline");
|
|
2367
2371
|
return;
|
|
2368
2372
|
}
|
|
2369
2373
|
await this.attemptReconnect();
|
|
@@ -2385,7 +2389,7 @@ var Tu = class {
|
|
|
2385
2389
|
clearStabilityTimer() {
|
|
2386
2390
|
this.stabilityTimer &&= (clearTimeout(this.stabilityTimer), null);
|
|
2387
2391
|
}
|
|
2388
|
-
}, Au = "opus", ju = 48e3, Mu = 2, Nu = 64e3, Pu = 150, Fu = "VP8", Iu = 5e6, Lu = 30, Ru = .05, zu = "max-bundle", Bu = "require", Vu = 5e3, Hu = 8e3, Uu = 16, Wu = 16, Gu = "ikon-data", Ku = !1, qu = 0,
|
|
2392
|
+
}, Au = "opus", ju = 48e3, Mu = 2, Nu = 64e3, Pu = 150, Fu = "VP8", Iu = 5e6, Lu = 30, Ru = .05, zu = "max-bundle", Bu = "require", Vu = 5e3, Hu = 8e3, Uu = 16, Wu = 16, Gu = "ikon-data", Ku = !1, qu = 0, P = C("WebRTCConnection"), Ju = class {
|
|
2389
2393
|
pc = null;
|
|
2390
2394
|
dataChannel = null;
|
|
2391
2395
|
_state = "new";
|
|
@@ -2432,11 +2436,11 @@ var Tu = class {
|
|
|
2432
2436
|
type: t
|
|
2433
2437
|
};
|
|
2434
2438
|
if (await this.pc.setRemoteDescription(n), this.hasRemoteDescription = !0, this.pendingCandidates.length > 0) {
|
|
2435
|
-
|
|
2439
|
+
P.debug(`Flushing ${this.pendingCandidates.length} queued ICE candidates`);
|
|
2436
2440
|
for (let e of this.pendingCandidates) try {
|
|
2437
2441
|
await this.pc.addIceCandidate(e);
|
|
2438
2442
|
} catch (e) {
|
|
2439
|
-
|
|
2443
|
+
P.warn("Failed to add queued ICE candidate:", e);
|
|
2440
2444
|
}
|
|
2441
2445
|
this.pendingCandidates = [];
|
|
2442
2446
|
}
|
|
@@ -2454,21 +2458,21 @@ var Tu = class {
|
|
|
2454
2458
|
return this.pc.addTrack(e, t);
|
|
2455
2459
|
}
|
|
2456
2460
|
async replaceTrack(e, t, n) {
|
|
2457
|
-
if (!this.pc) return
|
|
2461
|
+
if (!this.pc) return P.warn(`replaceTrack(${e}): no peer connection`), null;
|
|
2458
2462
|
let r = this.pc.getTransceivers().filter((t) => t.receiver.track?.kind === e);
|
|
2459
2463
|
if (n !== void 0) {
|
|
2460
2464
|
let i = r[n];
|
|
2461
|
-
return i ? (await i.sender.replaceTrack(t), i.sender) : (
|
|
2465
|
+
return i ? (await i.sender.replaceTrack(t), i.sender) : (P.warn(`replaceTrack(${e}[${n}]): no transceiver at index`), null);
|
|
2462
2466
|
}
|
|
2463
2467
|
let i = r[0];
|
|
2464
|
-
return i ? (await i.sender.replaceTrack(t), i.sender) : (
|
|
2468
|
+
return i ? (await i.sender.replaceTrack(t), i.sender) : (P.warn(`replaceTrack(${e}): no matching transceiver found`), null);
|
|
2465
2469
|
}
|
|
2466
2470
|
removeTrack(e) {
|
|
2467
2471
|
this.pc && this.pc.removeTrack(e);
|
|
2468
2472
|
}
|
|
2469
2473
|
sendDataChannelMessage(e) {
|
|
2470
2474
|
if (!this.dataChannel || this.dataChannel.readyState !== "open") {
|
|
2471
|
-
|
|
2475
|
+
P.warn("DataChannel not open, cannot send message");
|
|
2472
2476
|
return;
|
|
2473
2477
|
}
|
|
2474
2478
|
this.dataChannel.send(e);
|
|
@@ -2498,7 +2502,7 @@ var Tu = class {
|
|
|
2498
2502
|
try {
|
|
2499
2503
|
e.receiver.jitterBufferTarget = 150;
|
|
2500
2504
|
} catch (e) {
|
|
2501
|
-
|
|
2505
|
+
P.warn("Failed to set jitterBufferTarget:", e);
|
|
2502
2506
|
}
|
|
2503
2507
|
let n = e.streams[0] ?? new MediaStream([t]), r = this.audioTrackCount++;
|
|
2504
2508
|
this.config.onAudioTrack?.(r, t, n);
|
|
@@ -2506,30 +2510,30 @@ var Tu = class {
|
|
|
2506
2510
|
try {
|
|
2507
2511
|
e.receiver.playoutDelayHint = Ru;
|
|
2508
2512
|
} catch (e) {
|
|
2509
|
-
|
|
2513
|
+
P.warn("Failed to set playoutDelayHint:", e);
|
|
2510
2514
|
}
|
|
2511
2515
|
let n = new MediaStream([t]), r = this.videoTrackCount;
|
|
2512
2516
|
this.videoTrackCount++, this.config.onVideoTrack?.(r, t, n);
|
|
2513
2517
|
}
|
|
2514
2518
|
}, this.pc.ondatachannel = (e) => {
|
|
2515
|
-
|
|
2519
|
+
P.debug("Received data channel:", e.channel.label), this.setupDataChannelHandlers(e.channel);
|
|
2516
2520
|
});
|
|
2517
2521
|
}
|
|
2518
2522
|
setupDataChannelHandlers(e) {
|
|
2519
2523
|
e.binaryType = "arraybuffer", e.onopen = () => {
|
|
2520
|
-
|
|
2524
|
+
P.debug("DataChannel opened"), this.config.onDataChannelOpen?.();
|
|
2521
2525
|
}, e.onclose = () => {
|
|
2522
|
-
|
|
2526
|
+
P.debug("DataChannel closed"), this.config.onDataChannelClose?.();
|
|
2523
2527
|
}, e.onmessage = (e) => {
|
|
2524
2528
|
e.data instanceof ArrayBuffer && this.config.onDataChannelMessage?.(e.data);
|
|
2525
2529
|
}, e.onerror = (e) => {
|
|
2526
|
-
|
|
2530
|
+
P.error("DataChannel error:", e);
|
|
2527
2531
|
};
|
|
2528
2532
|
}
|
|
2529
2533
|
setState(e) {
|
|
2530
2534
|
this._state !== e && (this._state = e, this.config.onStateChange?.(e));
|
|
2531
2535
|
}
|
|
2532
|
-
},
|
|
2536
|
+
}, F = C("WebRTCSignaling"), Yu = class {
|
|
2533
2537
|
config;
|
|
2534
2538
|
connection = null;
|
|
2535
2539
|
sendMessage = null;
|
|
@@ -2551,14 +2555,14 @@ var Tu = class {
|
|
|
2551
2555
|
}
|
|
2552
2556
|
async connect(e) {
|
|
2553
2557
|
if (this.isConnecting || this.connection?.state === "connected") {
|
|
2554
|
-
|
|
2558
|
+
F.warn("WebRTC already connecting or connected");
|
|
2555
2559
|
return;
|
|
2556
2560
|
}
|
|
2557
|
-
|
|
2561
|
+
F.debug(`Starting WebRTC connection (audio=${this.config.useAudioTrack}, video=${this.config.useVideoTrack}, dataChannel=${this.config.useDataChannel})`), this.isConnecting = !0, this.audioTrackCount = 0, this.videoTrackCount = 0, this.sendMessage = e;
|
|
2558
2562
|
try {
|
|
2559
2563
|
let e = await this.requestIceServers();
|
|
2560
2564
|
if (e.length === 0 && this.config.shouldAttemptWithoutIceServers?.() === !1) {
|
|
2561
|
-
|
|
2565
|
+
F.debug("No ICE servers and no remembered direct success — abandoning WebRTC so media starts on the protocol channel"), this.isConnecting = !1, this.config.onStateChange?.("failed");
|
|
2562
2566
|
return;
|
|
2563
2567
|
}
|
|
2564
2568
|
let t = {
|
|
@@ -2569,7 +2573,7 @@ var Tu = class {
|
|
|
2569
2573
|
iceTransportPolicy: this.config.iceTransportPolicy,
|
|
2570
2574
|
onIceCandidate: (e) => this.handleLocalIceCandidate(e),
|
|
2571
2575
|
onStateChange: (e) => {
|
|
2572
|
-
|
|
2576
|
+
F.debug(`WebRTC connection state: ${e}`), e === "connected" && F.debug(`WebRTC tracks: ${this.audioTrackCount} audio, ${this.videoTrackCount} video`), this.config.onStateChange?.(e);
|
|
2573
2577
|
},
|
|
2574
2578
|
onDataChannelMessage: this.config.onDataChannelMessage,
|
|
2575
2579
|
onDataChannelOpen: this.config.onDataChannelOpen,
|
|
@@ -2585,7 +2589,7 @@ var Tu = class {
|
|
|
2585
2589
|
let n = await this.connection.createOffer();
|
|
2586
2590
|
this.sendOffer(n);
|
|
2587
2591
|
} catch (e) {
|
|
2588
|
-
throw
|
|
2592
|
+
throw F.error("Failed to start WebRTC connection:", e), this.isConnecting = !1, e;
|
|
2589
2593
|
}
|
|
2590
2594
|
}
|
|
2591
2595
|
handleProtocolMessage(e) {
|
|
@@ -2628,29 +2632,29 @@ var Tu = class {
|
|
|
2628
2632
|
return r && r.active ? r : null;
|
|
2629
2633
|
}
|
|
2630
2634
|
async startAudioCapture(e) {
|
|
2631
|
-
this.audioCaptureConstraints = e, await this.acquireAudioTrack(),
|
|
2635
|
+
this.audioCaptureConstraints = e, await this.acquireAudioTrack(), F.debug("Started audio capture via WebRTC");
|
|
2632
2636
|
}
|
|
2633
2637
|
startAudioSegment(e) {
|
|
2634
2638
|
if (!this.sendMessage) {
|
|
2635
|
-
|
|
2639
|
+
F.warn("Cannot start audio segment: no send function");
|
|
2636
2640
|
return;
|
|
2637
2641
|
}
|
|
2638
2642
|
this.audioSegmentActive = !0;
|
|
2639
2643
|
let t = this.audioCaptureStream?.getAudioTracks()[0];
|
|
2640
2644
|
t && t.readyState === "live" ? t.enabled = !0 : this.acquireAudioTrack().then((e) => {
|
|
2641
|
-
e && (this.audioSegmentActive ? e.enabled = !0 :
|
|
2645
|
+
e && (this.audioSegmentActive ? e.enabled = !0 : be() && this.releaseAudioTrack());
|
|
2642
2646
|
}).catch((e) => {
|
|
2643
|
-
|
|
2647
|
+
F.warn(`Failed to re-acquire microphone for audio segment: ${String(e)}`);
|
|
2644
2648
|
});
|
|
2645
2649
|
let n = cc(ic({
|
|
2646
2650
|
IsStart: !0,
|
|
2647
2651
|
CorrelationId: e
|
|
2648
2652
|
}), this.config.sessionId);
|
|
2649
|
-
this.sendMessage(n),
|
|
2653
|
+
this.sendMessage(n), F.debug("Started audio segment");
|
|
2650
2654
|
}
|
|
2651
2655
|
endAudioSegment(e) {
|
|
2652
2656
|
if (!this.sendMessage) {
|
|
2653
|
-
|
|
2657
|
+
F.warn("Cannot end audio segment: no send function");
|
|
2654
2658
|
return;
|
|
2655
2659
|
}
|
|
2656
2660
|
this.audioSegmentActive = !1;
|
|
@@ -2660,7 +2664,7 @@ var Tu = class {
|
|
|
2660
2664
|
}), this.config.sessionId);
|
|
2661
2665
|
this.sendMessage(t);
|
|
2662
2666
|
let n = this.audioCaptureStream?.getAudioTracks()[0];
|
|
2663
|
-
n && (n.enabled = !1,
|
|
2667
|
+
n && (n.enabled = !1, be() && this.releaseAudioTrack()), F.debug("Ended audio segment");
|
|
2664
2668
|
}
|
|
2665
2669
|
async acquireAudioTrack() {
|
|
2666
2670
|
let e = await navigator.mediaDevices.getUserMedia({
|
|
@@ -2694,7 +2698,7 @@ var Tu = class {
|
|
|
2694
2698
|
let a = i.getVideoTracks()[0];
|
|
2695
2699
|
if (a) {
|
|
2696
2700
|
let e = a.getSettings();
|
|
2697
|
-
|
|
2701
|
+
F.debug(`Camera capture (track ${n}): ${e.width}x${e.height}@${e.frameRate}fps`);
|
|
2698
2702
|
let i = await this.connection?.replaceTrack("video", a, n);
|
|
2699
2703
|
i && await this.applyEncodingParams(i, t), this.sendVideoStreamBegin("camera", n, e.width ?? 0, e.height ?? 0, e.frameRate ?? 30, r);
|
|
2700
2704
|
}
|
|
@@ -2709,7 +2713,7 @@ var Tu = class {
|
|
|
2709
2713
|
let a = i.getVideoTracks()[0];
|
|
2710
2714
|
if (a) {
|
|
2711
2715
|
let e = a.getSettings();
|
|
2712
|
-
|
|
2716
|
+
F.debug(`Screen capture (track ${n}): ${e.width}x${e.height}@${e.frameRate}fps`);
|
|
2713
2717
|
let i = await this.connection?.replaceTrack("video", a, n);
|
|
2714
2718
|
i && await this.applyEncodingParams(i, t), this.sendVideoStreamBegin("screen", n, e.width ?? 0, e.height ?? 0, e.frameRate ?? 30, r);
|
|
2715
2719
|
}
|
|
@@ -2722,7 +2726,7 @@ var Tu = class {
|
|
|
2722
2726
|
for (let e of t.getTracks()) e.stop();
|
|
2723
2727
|
this.videoCaptureStreams.delete(e), await this.connection?.replaceTrack("video", null, e);
|
|
2724
2728
|
}
|
|
2725
|
-
|
|
2729
|
+
F.debug(`Stopped video capture (track ${e})`);
|
|
2726
2730
|
}
|
|
2727
2731
|
sendVideoStreamBegin(e, t, n, i, a, o) {
|
|
2728
2732
|
if (!this.sendMessage) return;
|
|
@@ -2745,7 +2749,7 @@ var Tu = class {
|
|
|
2745
2749
|
this.sendMessage(fe(t, this.config.sessionId, { trackId: e }));
|
|
2746
2750
|
}
|
|
2747
2751
|
stopAudioCapture() {
|
|
2748
|
-
this.audioSegmentActive = !1, this.releaseAudioTrack(), this.audioCaptureConstraints = void 0,
|
|
2752
|
+
this.audioSegmentActive = !1, this.releaseAudioTrack(), this.audioCaptureConstraints = void 0, F.debug("Stopped audio capture");
|
|
2749
2753
|
}
|
|
2750
2754
|
async stopCapture() {
|
|
2751
2755
|
for (let e of [...this.videoCaptureStreams.keys()]) await this.stopVideoCapture(e);
|
|
@@ -2753,19 +2757,19 @@ var Tu = class {
|
|
|
2753
2757
|
for (let e of this.audioCaptureStream.getTracks()) e.stop();
|
|
2754
2758
|
this.audioCaptureStream = null, await this.connection?.replaceTrack("audio", null);
|
|
2755
2759
|
}
|
|
2756
|
-
this.audioCaptureConstraints = void 0,
|
|
2760
|
+
this.audioCaptureConstraints = void 0, F.debug("Stopped all capture");
|
|
2757
2761
|
}
|
|
2758
2762
|
async applyEncodingParams(e, t) {
|
|
2759
2763
|
try {
|
|
2760
2764
|
let n = t ?? 5e6, r = e.getParameters();
|
|
2761
2765
|
r.encodings?.length || (r.encodings = [{}]), r.encodings[0].maxBitrate = n, r.degradationPreference = "balanced", await e.setParameters(r);
|
|
2762
2766
|
} catch (e) {
|
|
2763
|
-
|
|
2767
|
+
F.warn("Failed to set encoding params:", e);
|
|
2764
2768
|
}
|
|
2765
2769
|
}
|
|
2766
2770
|
sendOffer(e) {
|
|
2767
2771
|
if (!this.sendMessage) {
|
|
2768
|
-
|
|
2772
|
+
F.error("Cannot send offer: no send function");
|
|
2769
2773
|
return;
|
|
2770
2774
|
}
|
|
2771
2775
|
let t = Yc(Gc({
|
|
@@ -2776,7 +2780,7 @@ var Tu = class {
|
|
|
2776
2780
|
UseVideoTrack: this.config.useVideoTrack,
|
|
2777
2781
|
UseDataChannel: this.config.useDataChannel
|
|
2778
2782
|
}), this.config.sessionId);
|
|
2779
|
-
this.sendMessage(t),
|
|
2783
|
+
this.sendMessage(t), F.debug("Sent WebRTC offer");
|
|
2780
2784
|
}
|
|
2781
2785
|
async requestIceServers() {
|
|
2782
2786
|
let e = this.config.iceServers ?? [];
|
|
@@ -2785,7 +2789,7 @@ var Tu = class {
|
|
|
2785
2789
|
this.iceServersResolve = e;
|
|
2786
2790
|
}), n, r = new Promise((t) => {
|
|
2787
2791
|
n = setTimeout(() => {
|
|
2788
|
-
|
|
2792
|
+
F.warn("Timed out waiting for ICE servers from server, proceeding without TURN"), t(e);
|
|
2789
2793
|
}, Vu);
|
|
2790
2794
|
}), i = Dc();
|
|
2791
2795
|
this.sendMessage(kc(i, this.config.sessionId));
|
|
@@ -2797,9 +2801,9 @@ var Tu = class {
|
|
|
2797
2801
|
let t = this.config.iceServers ?? [];
|
|
2798
2802
|
try {
|
|
2799
2803
|
let n = Lc(e), r = n.IceServersJson ? JSON.parse(n.IceServersJson) : [];
|
|
2800
|
-
|
|
2804
|
+
F.debug(`Received ${r.length} ICE server(s) from server`), this.iceServersResolve([...t, ...r]);
|
|
2801
2805
|
} catch (e) {
|
|
2802
|
-
|
|
2806
|
+
F.warn("Failed to parse ICE servers response, proceeding with configured servers:", e), this.iceServersResolve(t);
|
|
2803
2807
|
}
|
|
2804
2808
|
}
|
|
2805
2809
|
async handleAnswer(e) {
|
|
@@ -2807,9 +2811,9 @@ var Tu = class {
|
|
|
2807
2811
|
let t = ec(e);
|
|
2808
2812
|
await this.connection?.setRemoteDescription(t.Sdp, "answer");
|
|
2809
2813
|
let n = this.parseVideoCodecFromSdp(t.Sdp);
|
|
2810
|
-
|
|
2814
|
+
F.debug(`WebRTC answer received and applied (video=${n})`);
|
|
2811
2815
|
} catch (e) {
|
|
2812
|
-
|
|
2816
|
+
F.error("Failed to handle WebRTC answer:", e);
|
|
2813
2817
|
}
|
|
2814
2818
|
}
|
|
2815
2819
|
parseVideoCodecFromSdp(e) {
|
|
@@ -2837,15 +2841,15 @@ var Tu = class {
|
|
|
2837
2841
|
});
|
|
2838
2842
|
}
|
|
2839
2843
|
} catch (e) {
|
|
2840
|
-
|
|
2844
|
+
F.error("Failed to add ICE candidate:", e);
|
|
2841
2845
|
}
|
|
2842
2846
|
}
|
|
2843
2847
|
handleReady(e) {
|
|
2844
2848
|
try {
|
|
2845
2849
|
let t = il(e);
|
|
2846
|
-
t.Success ? (
|
|
2850
|
+
t.Success ? (F.debug("WebRTC connection ready"), this.isConnecting = !1) : (F.error(`WebRTC connection failed (server): ${t.ErrorMessage}`), this.config.onStateChange?.("failed"), this.disconnect());
|
|
2847
2851
|
} catch (e) {
|
|
2848
|
-
|
|
2852
|
+
F.error("Failed to handle WebRTC ready:", e);
|
|
2849
2853
|
}
|
|
2850
2854
|
}
|
|
2851
2855
|
handleTrackMap(e) {
|
|
@@ -2853,10 +2857,10 @@ var Tu = class {
|
|
|
2853
2857
|
let t = vl(e);
|
|
2854
2858
|
this.config.onTrackMap?.(t);
|
|
2855
2859
|
} catch (e) {
|
|
2856
|
-
|
|
2860
|
+
F.error("Failed to handle WebRTC track map:", e);
|
|
2857
2861
|
}
|
|
2858
2862
|
}
|
|
2859
|
-
}, Xu =
|
|
2863
|
+
}, Xu = C("WebRtcReachability"), Zu = "ikon-webrtc-reachability", Qu = /* @__PURE__ */ new Set([
|
|
2860
2864
|
"direct",
|
|
2861
2865
|
"relay",
|
|
2862
2866
|
"failed"
|
|
@@ -2914,7 +2918,7 @@ async function ed(e) {
|
|
|
2914
2918
|
let i = (n === void 0 ? void 0 : t.get(n)) ?? r.find((e) => e.nominated) ?? r[0];
|
|
2915
2919
|
if (i?.localCandidateId === void 0) return null;
|
|
2916
2920
|
let a = t.get(i.localCandidateId);
|
|
2917
|
-
return a?.candidateType === void 0 ? null : a.candidateType === "relay";
|
|
2921
|
+
return a?.candidateType === void 0 ? null : a.candidateType === "relay" || typeof a.relayProtocol == "string";
|
|
2918
2922
|
}
|
|
2919
2923
|
var td = 3e4, nd = 3e5, rd = 1e4, id = "ikon-login-pending-call", ad = /* @__PURE__ */ new Set(), od = {
|
|
2920
2924
|
required: !1,
|
|
@@ -2962,7 +2966,7 @@ function md() {
|
|
|
2962
2966
|
function hd() {
|
|
2963
2967
|
return typeof DOMException == "function" ? new DOMException("The operation timed out.", "TimeoutError") : /* @__PURE__ */ Error("The operation timed out.");
|
|
2964
2968
|
}
|
|
2965
|
-
function
|
|
2969
|
+
function I(e) {
|
|
2966
2970
|
let t = md();
|
|
2967
2971
|
if (t && typeof t.timeout == "function") return t.timeout(e);
|
|
2968
2972
|
let n = new AbortController();
|
|
@@ -2988,7 +2992,6 @@ function gd(e) {
|
|
|
2988
2992
|
var _d = "https://api.prod.ikon.live", vd = "https://api.dev.ikon.live", yd = "https://auth.ikonai.com", bd = "https://auth.dev.ikonai.com", xd = "https://auth.ikonai.com", Sd = [
|
|
2989
2993
|
".ikonai.app",
|
|
2990
2994
|
".ikonai.com",
|
|
2991
|
-
".ikonai.run",
|
|
2992
2995
|
".ikon.live"
|
|
2993
2996
|
];
|
|
2994
2997
|
function Cd(e) {
|
|
@@ -2998,7 +3001,7 @@ var wd = null, Td = null;
|
|
|
2998
3001
|
async function Ed() {
|
|
2999
3002
|
return wd || (typeof window > "u" ? null : Td || (Td = (async () => {
|
|
3000
3003
|
try {
|
|
3001
|
-
let e = await fetch(`${window.location.origin}/ikon/api/env`, { signal:
|
|
3004
|
+
let e = await fetch(`${window.location.origin}/ikon/api/env`, { signal: I(5e3) });
|
|
3002
3005
|
if (!e.ok) return null;
|
|
3003
3006
|
let t = await e.json();
|
|
3004
3007
|
return t.env === "development" || t.env === "production" ? (wd = t.env, t.env) : null;
|
|
@@ -3010,10 +3013,10 @@ async function Ed() {
|
|
|
3010
3013
|
})(), Td));
|
|
3011
3014
|
}
|
|
3012
3015
|
function Dd() {
|
|
3013
|
-
return typeof window > "u" ||
|
|
3016
|
+
return typeof window > "u" || hu() === !1 || !Vd() ? null : `${window.location.origin}/ikon/api`;
|
|
3014
3017
|
}
|
|
3015
3018
|
function Od() {
|
|
3016
|
-
return typeof window > "u" || !
|
|
3019
|
+
return typeof window > "u" || !Vd() ? null : `${window.location.origin}/ikon/auth`;
|
|
3017
3020
|
}
|
|
3018
3021
|
function kd(e) {
|
|
3019
3022
|
return e.startsWith("/") ? typeof window > "u" ? Md() === "development" ? vd : _d : `${window.location.origin}${e}` : e;
|
|
@@ -3030,7 +3033,7 @@ function jd(e) {
|
|
|
3030
3033
|
PROD: !0,
|
|
3031
3034
|
SSR: !1
|
|
3032
3035
|
}.VITE_IKON_BACKEND_URL;
|
|
3033
|
-
return t ? kd(t) : Dd() || (typeof window > "u" ? _d :
|
|
3036
|
+
return t ? kd(t) : Dd() || (typeof window > "u" ? _d : Vd() ? (Cd(window.location.hostname) ?? wd ?? "production") === "development" ? vd : _d : vd);
|
|
3034
3037
|
}
|
|
3035
3038
|
function Md() {
|
|
3036
3039
|
let e = {
|
|
@@ -3048,14 +3051,17 @@ function Md() {
|
|
|
3048
3051
|
PROD: !0,
|
|
3049
3052
|
SSR: !1
|
|
3050
3053
|
}.VITE_IKON_BACKEND_URL;
|
|
3051
|
-
return t && !t.startsWith("/") ? t.includes(".dev.") ? "development" : "production" : typeof window > "u" ? "production" :
|
|
3054
|
+
return t && !t.startsWith("/") ? t.includes(".dev.") ? "development" : "production" : typeof window > "u" ? "production" : Vd() ? Cd(window.location.hostname) ?? wd ?? "production" : "development";
|
|
3052
3055
|
}
|
|
3053
3056
|
async function Nd(e) {
|
|
3054
|
-
|
|
3057
|
+
return e.startsWith("/") ? typeof window > "u" ? await Fd() : `${window.location.origin}${e}` : e;
|
|
3058
|
+
}
|
|
3059
|
+
async function Pd(e) {
|
|
3060
|
+
if (mu()) {
|
|
3055
3061
|
let e = Od();
|
|
3056
3062
|
if (e) return e;
|
|
3057
3063
|
}
|
|
3058
|
-
if (e) return e;
|
|
3064
|
+
if (e) return await Nd(e);
|
|
3059
3065
|
let t = {
|
|
3060
3066
|
BASE_URL: "./",
|
|
3061
3067
|
DEV: !1,
|
|
@@ -3063,47 +3069,48 @@ async function Nd(e) {
|
|
|
3063
3069
|
PROD: !0,
|
|
3064
3070
|
SSR: !1
|
|
3065
3071
|
}.VITE_IKON_AUTH_URL;
|
|
3066
|
-
if (t) return t;
|
|
3072
|
+
if (t) return await Nd(t);
|
|
3067
3073
|
{
|
|
3068
3074
|
let e = Od();
|
|
3069
3075
|
if (e) return e;
|
|
3070
3076
|
}
|
|
3071
|
-
return
|
|
3077
|
+
return Fd();
|
|
3072
3078
|
}
|
|
3073
|
-
async function
|
|
3079
|
+
async function Fd() {
|
|
3074
3080
|
if (typeof window > "u") return yd;
|
|
3075
|
-
if (!
|
|
3081
|
+
if (!Vd()) return bd;
|
|
3076
3082
|
let e = Cd(window.location.hostname);
|
|
3077
3083
|
return e ? e === "development" ? bd : yd : await Ed() === "development" ? bd : yd;
|
|
3078
3084
|
}
|
|
3079
|
-
function
|
|
3085
|
+
function Id() {
|
|
3080
3086
|
if (typeof window > "u") return {};
|
|
3081
3087
|
let e = new URLSearchParams(window.location.search), t = {};
|
|
3082
3088
|
for (let [n, r] of e.entries()) t[n] = r;
|
|
3083
3089
|
return t;
|
|
3084
3090
|
}
|
|
3085
|
-
var
|
|
3091
|
+
var Ld = [
|
|
3086
3092
|
"ikon_token",
|
|
3093
|
+
"ikon_code",
|
|
3087
3094
|
"ikon_provider",
|
|
3088
3095
|
"error"
|
|
3089
|
-
],
|
|
3090
|
-
function
|
|
3096
|
+
], Rd = [eu, eu.replace(/-/g, "_")];
|
|
3097
|
+
function zd() {
|
|
3091
3098
|
let e = window.location.pathname.match(/^\/(s|c)\/([^/]+)(.*)$/);
|
|
3092
3099
|
if (!e) return;
|
|
3093
3100
|
let t = new URL(window.location.href);
|
|
3094
3101
|
t.pathname = e[3] || "/", t.searchParams.set(eu, decodeURIComponent(e[2])), window.history.replaceState(null, "", t.toString());
|
|
3095
3102
|
}
|
|
3096
|
-
function
|
|
3103
|
+
function Bd() {
|
|
3097
3104
|
if (typeof window > "u") return { parameters: {} };
|
|
3098
|
-
|
|
3099
|
-
let e =
|
|
3100
|
-
for (let [n, r] of Object.entries(e)) !
|
|
3105
|
+
zd();
|
|
3106
|
+
let e = Id(), t = {};
|
|
3107
|
+
for (let [n, r] of Object.entries(e)) !Ld.includes(n) && !Rd.includes(n) && (t[n] = r);
|
|
3101
3108
|
return {
|
|
3102
|
-
sessionIdentityHash:
|
|
3109
|
+
sessionIdentityHash: _u() ?? void 0,
|
|
3103
3110
|
parameters: t
|
|
3104
3111
|
};
|
|
3105
3112
|
}
|
|
3106
|
-
function
|
|
3113
|
+
function Vd() {
|
|
3107
3114
|
if (typeof window > "u") return !1;
|
|
3108
3115
|
let e = window.location.hostname;
|
|
3109
3116
|
if (e === "localhost" || e === "127.0.0.1" || e === "::1" || e.startsWith("10.") || e.startsWith("192.168.")) return !1;
|
|
@@ -3113,41 +3120,135 @@ function I() {
|
|
|
3113
3120
|
}
|
|
3114
3121
|
return !0;
|
|
3115
3122
|
}
|
|
3116
|
-
function
|
|
3123
|
+
function Hd() {
|
|
3117
3124
|
if (typeof window > "u") return "";
|
|
3118
|
-
let e = window.location.pathname || "/", t =
|
|
3125
|
+
let e = window.location.pathname || "/", t = Wd(window.location.search);
|
|
3126
|
+
return t.length > 0 ? `${e}?${t}` : e;
|
|
3127
|
+
}
|
|
3128
|
+
function Ud() {
|
|
3129
|
+
if (typeof window > "u") return "";
|
|
3130
|
+
let e = window.location.origin;
|
|
3131
|
+
return !e || e === "null" ? "" : `${e}${Hd()}`;
|
|
3132
|
+
}
|
|
3133
|
+
function Wd(e) {
|
|
3134
|
+
let t = new URLSearchParams(e);
|
|
3119
3135
|
for (let e of [...t.keys()]) (e.startsWith("ikon-") || e.startsWith("ikon_")) && t.delete(e);
|
|
3120
|
-
|
|
3121
|
-
|
|
3136
|
+
return t.toString();
|
|
3137
|
+
}
|
|
3138
|
+
//#endregion
|
|
3139
|
+
//#region src/utils/pkce.ts
|
|
3140
|
+
var Gd = "ikon-auth-pkce-verifier";
|
|
3141
|
+
function Kd(e) {
|
|
3142
|
+
let t = e instanceof Uint8Array ? e : new Uint8Array(e), n = "";
|
|
3143
|
+
for (let e of t) n += String.fromCharCode(e);
|
|
3144
|
+
return btoa(n).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
3145
|
+
}
|
|
3146
|
+
function qd() {
|
|
3147
|
+
return typeof window < "u" && !!window.crypto?.subtle && !!window.sessionStorage;
|
|
3148
|
+
}
|
|
3149
|
+
async function Jd() {
|
|
3150
|
+
if (!qd()) return null;
|
|
3151
|
+
try {
|
|
3152
|
+
let e = Kd(window.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32))), t = await window.crypto.subtle.digest("SHA-256", new TextEncoder().encode(e));
|
|
3153
|
+
return window.sessionStorage.setItem(Gd, e), Kd(t);
|
|
3154
|
+
} catch {
|
|
3155
|
+
return null;
|
|
3156
|
+
}
|
|
3157
|
+
}
|
|
3158
|
+
function Yd() {
|
|
3159
|
+
try {
|
|
3160
|
+
let e = window.sessionStorage.getItem(Gd);
|
|
3161
|
+
return window.sessionStorage.removeItem(Gd), e;
|
|
3162
|
+
} catch {
|
|
3163
|
+
return null;
|
|
3164
|
+
}
|
|
3165
|
+
}
|
|
3166
|
+
//#endregion
|
|
3167
|
+
//#region src/utils/embedded-oauth.ts
|
|
3168
|
+
var Xd = "/oauth/popup-callback", Zd = 3e5;
|
|
3169
|
+
function Qd() {
|
|
3170
|
+
if (typeof window > "u") return !1;
|
|
3171
|
+
try {
|
|
3172
|
+
return window.top !== window.self;
|
|
3173
|
+
} catch {
|
|
3174
|
+
return !0;
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3177
|
+
async function $d(e, t) {
|
|
3178
|
+
try {
|
|
3179
|
+
let { code: n, provider: r } = await ef(e, t), i = new URL(window.location.href);
|
|
3180
|
+
return i.searchParams.set("ikon_code", n), i.searchParams.set("ikon_provider", r), window.location.replace(i.toString()), !0;
|
|
3181
|
+
} catch {
|
|
3182
|
+
return !1;
|
|
3183
|
+
}
|
|
3184
|
+
}
|
|
3185
|
+
async function ef(e, t) {
|
|
3186
|
+
let n = window.open("about:blank", "ikon-oauth", "popup,width=520,height=680");
|
|
3187
|
+
if (!n) throw Error("The sign-in window was blocked. Allow pop-ups for this site and try again.");
|
|
3188
|
+
let r;
|
|
3189
|
+
try {
|
|
3190
|
+
r = await Fd();
|
|
3191
|
+
let i = `${r}${Xd}`, a = await Jd(), o = a ? `&code_challenge=${encodeURIComponent(a)}` : "";
|
|
3192
|
+
n.location.href = `${r}/oauth/${encodeURIComponent(e)}?space=${encodeURIComponent(t)}&return=${encodeURIComponent(i)}${o}`;
|
|
3193
|
+
} catch (e) {
|
|
3194
|
+
throw n.close(), e;
|
|
3195
|
+
}
|
|
3196
|
+
let i = r;
|
|
3197
|
+
return await new Promise((t, r) => {
|
|
3198
|
+
let a = !1, o = (e) => {
|
|
3199
|
+
a || (a = !0, window.removeEventListener("message", s), window.clearInterval(c), window.clearTimeout(l), e());
|
|
3200
|
+
}, s = (n) => {
|
|
3201
|
+
if (n.origin !== i) return;
|
|
3202
|
+
let a = n.data;
|
|
3203
|
+
if (!a || a.source !== "ikon-oauth-popup") return;
|
|
3204
|
+
if (a.error || !a.code) {
|
|
3205
|
+
o(() => r(Error(a.error || "The sign-in did not complete")));
|
|
3206
|
+
return;
|
|
3207
|
+
}
|
|
3208
|
+
let s = a.code, c = a.provider ?? e;
|
|
3209
|
+
o(() => t({
|
|
3210
|
+
code: s,
|
|
3211
|
+
provider: c
|
|
3212
|
+
}));
|
|
3213
|
+
};
|
|
3214
|
+
window.addEventListener("message", s);
|
|
3215
|
+
let c = window.setInterval(() => {
|
|
3216
|
+
n.closed && o(() => r(/* @__PURE__ */ Error("The sign-in window was closed before it finished")));
|
|
3217
|
+
}, 500), l = window.setTimeout(() => {
|
|
3218
|
+
o(() => {
|
|
3219
|
+
n.close(), r(/* @__PURE__ */ Error("The sign-in timed out"));
|
|
3220
|
+
});
|
|
3221
|
+
}, Zd);
|
|
3222
|
+
});
|
|
3122
3223
|
}
|
|
3123
3224
|
//#endregion
|
|
3124
3225
|
//#region src/utils/user-gesture.ts
|
|
3125
|
-
function
|
|
3226
|
+
function tf(e) {
|
|
3126
3227
|
if (!e || typeof e != "object") return !1;
|
|
3127
3228
|
let t = e, n = typeof t.name == "string" ? t.name : "", r = typeof t.message == "string" ? t.message : "";
|
|
3128
3229
|
return !!(n === "NotAllowedError" || n === "SecurityError" || r.toLowerCase().includes("permission") || r.toLowerCase().includes("user gesture"));
|
|
3129
3230
|
}
|
|
3130
3231
|
//#endregion
|
|
3131
3232
|
//#region src/utils/app-routes.ts
|
|
3132
|
-
var
|
|
3133
|
-
function
|
|
3233
|
+
var nf = ["/ikon", "/api"];
|
|
3234
|
+
function rf(e) {
|
|
3134
3235
|
if (!e) return !1;
|
|
3135
3236
|
let t = e.split(/[?#]/)[0], n = t.startsWith("/") ? t : "/" + t;
|
|
3136
|
-
return
|
|
3237
|
+
return nf.some((e) => n === e || n.startsWith(e + "/"));
|
|
3137
3238
|
}
|
|
3138
3239
|
//#endregion
|
|
3139
3240
|
//#region src/functions/browser-functions.ts
|
|
3140
|
-
var
|
|
3141
|
-
function
|
|
3241
|
+
var af = "ikon-theme", of = "ikon-theme-user", sf = "ikon-theme-change";
|
|
3242
|
+
function cf(e) {
|
|
3142
3243
|
typeof document < "u" && document.documentElement && document.documentElement.setAttribute("data-theme", e);
|
|
3143
3244
|
}
|
|
3144
|
-
function
|
|
3245
|
+
function lf() {
|
|
3145
3246
|
return typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
3146
3247
|
}
|
|
3147
|
-
function
|
|
3148
|
-
return typeof window > "u" || !window.localStorage ? "light" : window.localStorage.getItem(
|
|
3248
|
+
function uf() {
|
|
3249
|
+
return typeof window > "u" || !window.localStorage ? "light" : window.localStorage.getItem(of) || window.localStorage.getItem(af) || lf();
|
|
3149
3250
|
}
|
|
3150
|
-
function
|
|
3251
|
+
function df() {
|
|
3151
3252
|
return typeof window > "u" ? {
|
|
3152
3253
|
width: 0,
|
|
3153
3254
|
height: 0
|
|
@@ -3156,17 +3257,17 @@ function Xd() {
|
|
|
3156
3257
|
height: window.innerHeight
|
|
3157
3258
|
};
|
|
3158
3259
|
}
|
|
3159
|
-
function
|
|
3260
|
+
function ff() {
|
|
3160
3261
|
if (typeof window > "u" || !window.localStorage) return "light";
|
|
3161
|
-
let e = window.localStorage.getItem(
|
|
3262
|
+
let e = window.localStorage.getItem(of), t = window.localStorage.getItem(af);
|
|
3162
3263
|
if (e || t) {
|
|
3163
3264
|
let n = e ?? t;
|
|
3164
|
-
return
|
|
3265
|
+
return cf(n), n;
|
|
3165
3266
|
}
|
|
3166
|
-
let n =
|
|
3167
|
-
return window.localStorage.setItem(
|
|
3267
|
+
let n = lf();
|
|
3268
|
+
return window.localStorage.setItem(af, n), cf(n), n;
|
|
3168
3269
|
}
|
|
3169
|
-
var
|
|
3270
|
+
var pf = {
|
|
3170
3271
|
name: "ikon.client.getTheme",
|
|
3171
3272
|
description: "Get the currently selected client theme",
|
|
3172
3273
|
returnType: {
|
|
@@ -3174,12 +3275,12 @@ var Qd = {
|
|
|
3174
3275
|
nullable: !0
|
|
3175
3276
|
}
|
|
3176
3277
|
};
|
|
3177
|
-
function
|
|
3278
|
+
function mf() {
|
|
3178
3279
|
if (typeof window > "u" || !window.localStorage) return null;
|
|
3179
|
-
let e = window.localStorage.getItem(
|
|
3280
|
+
let e = window.localStorage.getItem(of), t = window.localStorage.getItem(af);
|
|
3180
3281
|
return e ?? t ?? null;
|
|
3181
3282
|
}
|
|
3182
|
-
var
|
|
3283
|
+
var hf = {
|
|
3183
3284
|
name: "ikon.client.setTheme",
|
|
3184
3285
|
description: "Update the client UI theme",
|
|
3185
3286
|
returnType: { kind: "boolean" },
|
|
@@ -3196,38 +3297,38 @@ var ef = {
|
|
|
3196
3297
|
description: "Whether to persist as user preference"
|
|
3197
3298
|
}]
|
|
3198
3299
|
};
|
|
3199
|
-
function
|
|
3300
|
+
function gf(e, t) {
|
|
3200
3301
|
if (typeof window > "u" || !window.localStorage || typeof e != "string") return !1;
|
|
3201
3302
|
let n = e.trim().toLowerCase();
|
|
3202
3303
|
if (!n) return !1;
|
|
3203
3304
|
let r = t === void 0 || !!t, i = window.localStorage;
|
|
3204
|
-
r ? i.setItem(
|
|
3305
|
+
r ? i.setItem(of, n) : i.removeItem(of), i.setItem(af, n);
|
|
3205
3306
|
try {
|
|
3206
|
-
window.dispatchEvent(new CustomEvent(
|
|
3307
|
+
window.dispatchEvent(new CustomEvent(sf, { detail: { mode: n } }));
|
|
3207
3308
|
} catch {}
|
|
3208
|
-
return
|
|
3309
|
+
return cf(n), !0;
|
|
3209
3310
|
}
|
|
3210
|
-
var
|
|
3311
|
+
var _f = {
|
|
3211
3312
|
name: "ikon.client.getLanguage",
|
|
3212
3313
|
description: "Get the browser language preference",
|
|
3213
3314
|
returnType: { kind: "string" }
|
|
3214
3315
|
};
|
|
3215
|
-
function
|
|
3316
|
+
function vf() {
|
|
3216
3317
|
return typeof navigator > "u" ? "en-US" : navigator.language || "en-US";
|
|
3217
3318
|
}
|
|
3218
|
-
var
|
|
3319
|
+
var yf = {
|
|
3219
3320
|
name: "ikon.client.getTimezone",
|
|
3220
3321
|
description: "Get the browser timezone (IANA format)",
|
|
3221
3322
|
returnType: { kind: "string" }
|
|
3222
3323
|
};
|
|
3223
|
-
function
|
|
3324
|
+
function bf() {
|
|
3224
3325
|
try {
|
|
3225
3326
|
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
3226
3327
|
} catch {
|
|
3227
3328
|
return "UTC";
|
|
3228
3329
|
}
|
|
3229
3330
|
}
|
|
3230
|
-
function
|
|
3331
|
+
function xf() {
|
|
3231
3332
|
if (typeof Intl > "u") return "";
|
|
3232
3333
|
try {
|
|
3233
3334
|
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
@@ -3235,15 +3336,15 @@ function sf() {
|
|
|
3235
3336
|
return "";
|
|
3236
3337
|
}
|
|
3237
3338
|
}
|
|
3238
|
-
function
|
|
3339
|
+
function Sf() {
|
|
3239
3340
|
return typeof navigator > "u" ? !1 : navigator.maxTouchPoints > 0;
|
|
3240
3341
|
}
|
|
3241
|
-
function
|
|
3342
|
+
function Cf() {
|
|
3242
3343
|
if (typeof navigator > "u" || typeof window > "u") return ne.Unknown;
|
|
3243
3344
|
let e = navigator.maxTouchPoints > 0, t = window.innerWidth <= 1024;
|
|
3244
3345
|
return e && t ? ne.MobileWeb : ne.DesktopWeb;
|
|
3245
3346
|
}
|
|
3246
|
-
var
|
|
3347
|
+
var wf = {
|
|
3247
3348
|
name: "ikon.client.getUrl",
|
|
3248
3349
|
description: "Get the current browser URL path and query string",
|
|
3249
3350
|
returnType: {
|
|
@@ -3251,10 +3352,10 @@ var uf = {
|
|
|
3251
3352
|
nullable: !0
|
|
3252
3353
|
}
|
|
3253
3354
|
};
|
|
3254
|
-
function
|
|
3355
|
+
function Tf() {
|
|
3255
3356
|
return typeof window > "u" ? null : window.location.pathname + window.location.search;
|
|
3256
3357
|
}
|
|
3257
|
-
var
|
|
3358
|
+
var Ef = {
|
|
3258
3359
|
name: "ikon.client.setUrl",
|
|
3259
3360
|
description: "Update the browser URL without triggering a page reload",
|
|
3260
3361
|
returnType: { kind: "boolean" },
|
|
@@ -3282,10 +3383,10 @@ var ff = {
|
|
|
3282
3383
|
}
|
|
3283
3384
|
]
|
|
3284
3385
|
};
|
|
3285
|
-
function
|
|
3386
|
+
function Df(e, t, n) {
|
|
3286
3387
|
if (typeof window > "u" || !window.history || typeof e != "string") return !1;
|
|
3287
3388
|
let r = e.trim();
|
|
3288
|
-
if (!r || /^[a-z][a-z0-9+.-]*:/i.test(r) || r.startsWith("//") ||
|
|
3389
|
+
if (!r || /^[a-z][a-z0-9+.-]*:/i.test(r) || r.startsWith("//") || rf(r)) return !1;
|
|
3289
3390
|
try {
|
|
3290
3391
|
let e = !!t, i = n && !r.includes("?") ? r + window.location.search : r;
|
|
3291
3392
|
return e ? window.history.replaceState(null, "", i) : window.history.pushState(null, "", i), !0;
|
|
@@ -3293,7 +3394,7 @@ function pf(e, t, n) {
|
|
|
3293
3394
|
return !1;
|
|
3294
3395
|
}
|
|
3295
3396
|
}
|
|
3296
|
-
var
|
|
3397
|
+
var Of = {
|
|
3297
3398
|
name: "ikon.client.openExternalUrl",
|
|
3298
3399
|
description: "Open an external URL in a new browser tab",
|
|
3299
3400
|
returnType: { kind: "boolean" },
|
|
@@ -3303,7 +3404,7 @@ var mf = {
|
|
|
3303
3404
|
description: "The URL to open. Must be absolute (e.g., starts with https://)."
|
|
3304
3405
|
}]
|
|
3305
3406
|
};
|
|
3306
|
-
function
|
|
3407
|
+
function kf(e) {
|
|
3307
3408
|
if (typeof window > "u" || typeof window.open != "function" || typeof e != "string") return !1;
|
|
3308
3409
|
let t = e.trim();
|
|
3309
3410
|
if (!t || /^javascript:/i.test(t)) return !1;
|
|
@@ -3313,7 +3414,7 @@ function hf(e) {
|
|
|
3313
3414
|
return !1;
|
|
3314
3415
|
}
|
|
3315
3416
|
}
|
|
3316
|
-
var
|
|
3417
|
+
var Af = {
|
|
3317
3418
|
name: "ikon.client.vibrate",
|
|
3318
3419
|
description: "Trigger haptic feedback on supported devices",
|
|
3319
3420
|
returnType: { kind: "boolean" },
|
|
@@ -3323,7 +3424,7 @@ var gf = {
|
|
|
3323
3424
|
description: "Duration in ms, or comma-separated pattern (e.g., \"200\" or \"100,50,100\")"
|
|
3324
3425
|
}]
|
|
3325
3426
|
};
|
|
3326
|
-
function
|
|
3427
|
+
function jf(e) {
|
|
3327
3428
|
if (typeof navigator > "u" || !navigator.vibrate || typeof e != "string") return !1;
|
|
3328
3429
|
try {
|
|
3329
3430
|
let t = e.split(",").map((e) => parseInt(e.trim(), 10));
|
|
@@ -3332,16 +3433,16 @@ function _f(e) {
|
|
|
3332
3433
|
return !1;
|
|
3333
3434
|
}
|
|
3334
3435
|
}
|
|
3335
|
-
var L = null,
|
|
3336
|
-
async function
|
|
3436
|
+
var L = null, Mf = !1, Nf = !1;
|
|
3437
|
+
async function Pf() {
|
|
3337
3438
|
if (!(typeof navigator > "u" || !("wakeLock" in navigator))) try {
|
|
3338
3439
|
L = await navigator.wakeLock.request("screen");
|
|
3339
3440
|
} catch {}
|
|
3340
3441
|
}
|
|
3341
|
-
function
|
|
3342
|
-
document.visibilityState === "visible" &&
|
|
3442
|
+
function Ff() {
|
|
3443
|
+
document.visibilityState === "visible" && Mf && (!L || L.released) && Pf();
|
|
3343
3444
|
}
|
|
3344
|
-
var
|
|
3445
|
+
var If = {
|
|
3345
3446
|
name: "ikon.client.keepScreenAwake",
|
|
3346
3447
|
description: "Prevent or allow the screen to sleep",
|
|
3347
3448
|
returnType: { kind: "boolean" },
|
|
@@ -3351,15 +3452,15 @@ var Sf = {
|
|
|
3351
3452
|
description: "Whether to keep the screen awake"
|
|
3352
3453
|
}]
|
|
3353
3454
|
};
|
|
3354
|
-
async function
|
|
3455
|
+
async function Lf(e) {
|
|
3355
3456
|
if (typeof navigator > "u" || !("wakeLock" in navigator)) return !1;
|
|
3356
3457
|
try {
|
|
3357
|
-
return e ? (
|
|
3458
|
+
return e ? (Mf = !0, (!L || L.released) && (L = await navigator.wakeLock.request("screen")), Nf ||= (document.addEventListener("visibilitychange", Ff), !0)) : (Mf = !1, Nf &&= (document.removeEventListener("visibilitychange", Ff), !1), L &&= (await L.release(), null)), !0;
|
|
3358
3459
|
} catch {
|
|
3359
3460
|
return !1;
|
|
3360
3461
|
}
|
|
3361
3462
|
}
|
|
3362
|
-
var
|
|
3463
|
+
var Rf = {
|
|
3363
3464
|
name: "ikon.client.getVisibility",
|
|
3364
3465
|
description: "Get the current page visibility state",
|
|
3365
3466
|
returnType: {
|
|
@@ -3367,10 +3468,10 @@ var wf = {
|
|
|
3367
3468
|
nullable: !0
|
|
3368
3469
|
}
|
|
3369
3470
|
};
|
|
3370
|
-
function
|
|
3471
|
+
function zf() {
|
|
3371
3472
|
return typeof document > "u" ? null : document.visibilityState || null;
|
|
3372
3473
|
}
|
|
3373
|
-
var
|
|
3474
|
+
var Bf = {
|
|
3374
3475
|
name: "ikon.client.scrollTo",
|
|
3375
3476
|
description: "Scroll the page to a specific position",
|
|
3376
3477
|
returnType: { kind: "boolean" },
|
|
@@ -3395,7 +3496,7 @@ var Ef = {
|
|
|
3395
3496
|
}
|
|
3396
3497
|
]
|
|
3397
3498
|
};
|
|
3398
|
-
function
|
|
3499
|
+
function Vf(e, t, n) {
|
|
3399
3500
|
if (typeof window > "u" || typeof e != "number" || typeof t != "number") return !1;
|
|
3400
3501
|
try {
|
|
3401
3502
|
return window.scrollTo({
|
|
@@ -3407,7 +3508,7 @@ function Df(e, t, n) {
|
|
|
3407
3508
|
return !1;
|
|
3408
3509
|
}
|
|
3409
3510
|
}
|
|
3410
|
-
var
|
|
3511
|
+
var Hf = {
|
|
3411
3512
|
name: "ikon.client.getBatteryLevel",
|
|
3412
3513
|
description: "Get the current battery level (0-100)",
|
|
3413
3514
|
returnType: {
|
|
@@ -3415,7 +3516,7 @@ var Of = {
|
|
|
3415
3516
|
nullable: !0
|
|
3416
3517
|
}
|
|
3417
3518
|
};
|
|
3418
|
-
async function
|
|
3519
|
+
async function Uf() {
|
|
3419
3520
|
if (typeof navigator > "u" || !("getBattery" in navigator)) return null;
|
|
3420
3521
|
try {
|
|
3421
3522
|
let e = await navigator.getBattery();
|
|
@@ -3424,7 +3525,7 @@ async function kf() {
|
|
|
3424
3525
|
return null;
|
|
3425
3526
|
}
|
|
3426
3527
|
}
|
|
3427
|
-
var
|
|
3528
|
+
var Wf = {
|
|
3428
3529
|
name: "ikon.client.getNetworkType",
|
|
3429
3530
|
description: "Get the current network connection type",
|
|
3430
3531
|
returnType: {
|
|
@@ -3432,17 +3533,17 @@ var Af = {
|
|
|
3432
3533
|
nullable: !0
|
|
3433
3534
|
}
|
|
3434
3535
|
};
|
|
3435
|
-
function
|
|
3536
|
+
function Gf() {
|
|
3436
3537
|
if (typeof navigator > "u") return null;
|
|
3437
3538
|
let e = navigator.connection;
|
|
3438
3539
|
return e && (e.effectiveType || e.type) || null;
|
|
3439
3540
|
}
|
|
3440
|
-
var
|
|
3541
|
+
var Kf = {
|
|
3441
3542
|
name: "ikon.client.requestFullscreen",
|
|
3442
3543
|
description: "Request the browser to enter fullscreen mode",
|
|
3443
3544
|
returnType: { kind: "boolean" }
|
|
3444
3545
|
};
|
|
3445
|
-
async function
|
|
3546
|
+
async function qf() {
|
|
3446
3547
|
if (typeof document > "u" || !document.documentElement) return !1;
|
|
3447
3548
|
try {
|
|
3448
3549
|
let e = document.documentElement, t = e.requestFullscreen?.bind(e) ?? e.webkitRequestFullscreen?.bind(e);
|
|
@@ -3451,12 +3552,12 @@ async function Nf() {
|
|
|
3451
3552
|
return !1;
|
|
3452
3553
|
}
|
|
3453
3554
|
}
|
|
3454
|
-
var
|
|
3555
|
+
var Jf = {
|
|
3455
3556
|
name: "ikon.client.exitFullscreen",
|
|
3456
3557
|
description: "Exit browser fullscreen mode",
|
|
3457
3558
|
returnType: { kind: "boolean" }
|
|
3458
3559
|
};
|
|
3459
|
-
function
|
|
3560
|
+
function Yf() {
|
|
3460
3561
|
if (typeof document > "u") return !1;
|
|
3461
3562
|
try {
|
|
3462
3563
|
let e = document.exitFullscreen?.bind(document) ?? document.webkitExitFullscreen?.bind(document);
|
|
@@ -3465,25 +3566,25 @@ function Ff() {
|
|
|
3465
3566
|
return !1;
|
|
3466
3567
|
}
|
|
3467
3568
|
}
|
|
3468
|
-
var
|
|
3569
|
+
var Xf = {
|
|
3469
3570
|
name: "ikon.client.logout",
|
|
3470
3571
|
description: "Clear the auth session and return to the login screen at the site root",
|
|
3471
3572
|
returnType: { kind: "boolean" }
|
|
3472
|
-
},
|
|
3473
|
-
function
|
|
3573
|
+
}, Zf = ["ikon-auth-", "ikon-live-snapshot"];
|
|
3574
|
+
function Qf() {
|
|
3474
3575
|
if (typeof window > "u" || !window.localStorage) return !1;
|
|
3475
3576
|
try {
|
|
3476
3577
|
let e = [];
|
|
3477
3578
|
for (let t = 0; t < window.localStorage.length; t++) {
|
|
3478
3579
|
let n = window.localStorage.key(t);
|
|
3479
|
-
n &&
|
|
3580
|
+
n && Zf.some((e) => n.startsWith(e)) && e.push(n);
|
|
3480
3581
|
}
|
|
3481
3582
|
return e.forEach((e) => window.localStorage.removeItem(e)), setTimeout(() => window.location.replace(window.location.origin + "/"), 100), !0;
|
|
3482
3583
|
} catch {
|
|
3483
3584
|
return !1;
|
|
3484
3585
|
}
|
|
3485
3586
|
}
|
|
3486
|
-
var
|
|
3587
|
+
var $f = {
|
|
3487
3588
|
name: "ikon.client.login",
|
|
3488
3589
|
description: "Start the sign-in flow for an OAuth provider (e.g. google, microsoft)",
|
|
3489
3590
|
parameters: [{
|
|
@@ -3492,14 +3593,15 @@ var zf = {
|
|
|
3492
3593
|
}],
|
|
3493
3594
|
returnType: { kind: "boolean" }
|
|
3494
3595
|
};
|
|
3495
|
-
async function
|
|
3596
|
+
async function ep(e) {
|
|
3496
3597
|
if (typeof window > "u" || typeof e != "string" || e.length === 0 || e === "guest" || e === "global" || e === "email" || e === "passkey") return !1;
|
|
3497
3598
|
let t = window.__IKON_AUTH_CONFIG__, n = t?.spaceId;
|
|
3498
3599
|
if (!n) return !1;
|
|
3499
|
-
|
|
3500
|
-
|
|
3600
|
+
if (Qd()) return await $d(e, n);
|
|
3601
|
+
let r = await Pd(t?.authUrl), i = window.location.origin + window.location.pathname + window.location.search, a = await Jd(), o = a ? `&code_challenge=${encodeURIComponent(a)}` : "";
|
|
3602
|
+
return window.location.href = `${r}/oauth/${encodeURIComponent(e)}?space=${encodeURIComponent(n)}&return=${encodeURIComponent(i)}${o}`, !0;
|
|
3501
3603
|
}
|
|
3502
|
-
var
|
|
3604
|
+
var tp = {
|
|
3503
3605
|
name: "ikon.client.loginShow",
|
|
3504
3606
|
description: "Show the login UI with an optional reason",
|
|
3505
3607
|
parameters: [{
|
|
@@ -3508,15 +3610,15 @@ var Vf = {
|
|
|
3508
3610
|
}],
|
|
3509
3611
|
returnType: { kind: "boolean" }
|
|
3510
3612
|
};
|
|
3511
|
-
function
|
|
3613
|
+
function np(e) {
|
|
3512
3614
|
return typeof window > "u" ? !1 : (ld(typeof e == "string" ? e : null), !0);
|
|
3513
3615
|
}
|
|
3514
|
-
var
|
|
3616
|
+
var rp = {
|
|
3515
3617
|
name: "ikon.client.getLocation",
|
|
3516
3618
|
description: "Get the current GPS location",
|
|
3517
3619
|
returnType: { kind: "string" }
|
|
3518
3620
|
};
|
|
3519
|
-
function
|
|
3621
|
+
function ip() {
|
|
3520
3622
|
return typeof navigator > "u" || !navigator.geolocation ? Promise.resolve(null) : new Promise((e) => {
|
|
3521
3623
|
navigator.geolocation.getCurrentPosition((t) => {
|
|
3522
3624
|
e({
|
|
@@ -3530,15 +3632,15 @@ function Wf() {
|
|
|
3530
3632
|
});
|
|
3531
3633
|
});
|
|
3532
3634
|
}
|
|
3533
|
-
var
|
|
3534
|
-
function
|
|
3635
|
+
var ap = [], op = !1;
|
|
3636
|
+
function sp() {
|
|
3535
3637
|
return typeof window < "u" && "Notification" in window;
|
|
3536
3638
|
}
|
|
3537
|
-
function
|
|
3639
|
+
function cp(e, t, n, r) {
|
|
3538
3640
|
let i = {};
|
|
3539
3641
|
return e?.trim() && (i.body = e.trim()), t?.trim() && (i.icon = t.trim()), n?.trim() && (i.tag = n.trim()), r && (i.data = r), i;
|
|
3540
3642
|
}
|
|
3541
|
-
function
|
|
3643
|
+
function lp(e, t, n, r) {
|
|
3542
3644
|
try {
|
|
3543
3645
|
let i = new Notification(e, t);
|
|
3544
3646
|
i.onclick = () => {
|
|
@@ -3553,40 +3655,40 @@ function Yf(e, t, n, r) {
|
|
|
3553
3655
|
};
|
|
3554
3656
|
} catch {}
|
|
3555
3657
|
}
|
|
3556
|
-
function
|
|
3658
|
+
function up() {
|
|
3557
3659
|
if (Notification.permission !== "granted") {
|
|
3558
|
-
|
|
3660
|
+
ap = [];
|
|
3559
3661
|
return;
|
|
3560
3662
|
}
|
|
3561
|
-
let e =
|
|
3562
|
-
|
|
3563
|
-
for (let t of e)
|
|
3663
|
+
let e = ap;
|
|
3664
|
+
ap = [];
|
|
3665
|
+
for (let t of e) lp(t.title, t.options, t.launchUrl, t.data);
|
|
3564
3666
|
}
|
|
3565
|
-
function
|
|
3566
|
-
if (
|
|
3567
|
-
|
|
3667
|
+
function dp() {
|
|
3668
|
+
if (op || typeof window > "u") return;
|
|
3669
|
+
op = !0;
|
|
3568
3670
|
let e = async () => {
|
|
3569
3671
|
try {
|
|
3570
3672
|
if (await Notification.requestPermission() === "granted") {
|
|
3571
|
-
|
|
3673
|
+
up();
|
|
3572
3674
|
return;
|
|
3573
3675
|
}
|
|
3574
3676
|
} catch {}
|
|
3575
|
-
|
|
3677
|
+
ap = [];
|
|
3576
3678
|
}, t = () => {
|
|
3577
|
-
window.removeEventListener("pointerdown", t), window.removeEventListener("keydown", t),
|
|
3679
|
+
window.removeEventListener("pointerdown", t), window.removeEventListener("keydown", t), op = !1, e();
|
|
3578
3680
|
};
|
|
3579
3681
|
window.addEventListener("pointerdown", t), window.addEventListener("keydown", t);
|
|
3580
3682
|
}
|
|
3581
|
-
var
|
|
3683
|
+
var fp = {
|
|
3582
3684
|
name: "ikon.client.getNotificationPermission",
|
|
3583
3685
|
description: "Get the current notification permission state (granted, denied, default, or unsupported)",
|
|
3584
3686
|
returnType: { kind: "string" }
|
|
3585
3687
|
};
|
|
3586
|
-
function
|
|
3587
|
-
return
|
|
3688
|
+
function pp() {
|
|
3689
|
+
return sp() ? Notification.permission : "unsupported";
|
|
3588
3690
|
}
|
|
3589
|
-
var
|
|
3691
|
+
var mp = {
|
|
3590
3692
|
name: "ikon.client.showNotification",
|
|
3591
3693
|
description: "Show a notification, requesting permission lazily on the first send",
|
|
3592
3694
|
returnType: { kind: "string" },
|
|
@@ -3632,33 +3734,33 @@ var ep = {
|
|
|
3632
3734
|
}
|
|
3633
3735
|
]
|
|
3634
3736
|
};
|
|
3635
|
-
async function
|
|
3636
|
-
if (!
|
|
3637
|
-
let o = e.trim(), s =
|
|
3638
|
-
if (Notification.permission === "granted") return
|
|
3737
|
+
async function hp(e, t, n, r, i, a) {
|
|
3738
|
+
if (!sp() || typeof e != "string" || !e.trim()) return "unsupported";
|
|
3739
|
+
let o = e.trim(), s = cp(typeof t == "string" ? t : void 0, typeof n == "string" ? n : void 0, typeof r == "string" ? r : void 0, typeof a == "string" ? a : void 0), c = typeof i == "string" && i.trim() ? i.trim() : void 0, l = typeof a == "string" && a ? a : void 0;
|
|
3740
|
+
if (Notification.permission === "granted") return lp(o, s, c, l), "granted";
|
|
3639
3741
|
if (Notification.permission === "denied") return "denied";
|
|
3640
3742
|
try {
|
|
3641
3743
|
let e = await Notification.requestPermission();
|
|
3642
|
-
return e === "granted" &&
|
|
3744
|
+
return e === "granted" && lp(o, s, c, l), e;
|
|
3643
3745
|
} catch (e) {
|
|
3644
|
-
return
|
|
3746
|
+
return tf(e) ? (ap.push({
|
|
3645
3747
|
title: o,
|
|
3646
3748
|
options: s,
|
|
3647
3749
|
launchUrl: c,
|
|
3648
3750
|
data: l
|
|
3649
|
-
}),
|
|
3751
|
+
}), dp(), "default") : "denied";
|
|
3650
3752
|
}
|
|
3651
3753
|
}
|
|
3652
|
-
var
|
|
3653
|
-
function
|
|
3654
|
-
|
|
3754
|
+
var gp = null;
|
|
3755
|
+
function _p(e) {
|
|
3756
|
+
gp = e ?? null;
|
|
3655
3757
|
}
|
|
3656
|
-
function
|
|
3758
|
+
function vp(e) {
|
|
3657
3759
|
let t = (e + "=".repeat((4 - e.length % 4) % 4)).replace(/-/g, "+").replace(/_/g, "/"), n = atob(t), r = new Uint8Array(n.length);
|
|
3658
3760
|
for (let e = 0; e < n.length; e++) r[e] = n.charCodeAt(e);
|
|
3659
3761
|
return r;
|
|
3660
3762
|
}
|
|
3661
|
-
var
|
|
3763
|
+
var yp = {
|
|
3662
3764
|
name: "ikon.client.getPushSubscription",
|
|
3663
3765
|
description: "Subscribe to Web Push and return the subscription, for offline push registration",
|
|
3664
3766
|
returnType: {
|
|
@@ -3666,14 +3768,14 @@ var ap = {
|
|
|
3666
3768
|
nullable: !0
|
|
3667
3769
|
}
|
|
3668
3770
|
};
|
|
3669
|
-
async function
|
|
3670
|
-
if (typeof window > "u" || !
|
|
3771
|
+
async function bp() {
|
|
3772
|
+
if (typeof window > "u" || !gp?.enabled || !gp.vapidPublicKey || !("serviceWorker" in navigator) || !("PushManager" in window) || !sp() || Notification.permission !== "granted") return null;
|
|
3671
3773
|
try {
|
|
3672
3774
|
let e = await navigator.serviceWorker.register("/push-service-worker.js");
|
|
3673
3775
|
await navigator.serviceWorker.ready;
|
|
3674
3776
|
let t = (await e.pushManager.getSubscription() ?? await e.pushManager.subscribe({
|
|
3675
3777
|
userVisibleOnly: !0,
|
|
3676
|
-
applicationServerKey:
|
|
3778
|
+
applicationServerKey: vp(gp.vapidPublicKey)
|
|
3677
3779
|
})).toJSON();
|
|
3678
3780
|
return !t.endpoint || !t.keys?.p256dh || !t.keys?.auth ? null : {
|
|
3679
3781
|
Platform: "web",
|
|
@@ -3686,98 +3788,98 @@ async function op() {
|
|
|
3686
3788
|
return null;
|
|
3687
3789
|
}
|
|
3688
3790
|
}
|
|
3689
|
-
var
|
|
3791
|
+
var xp = [
|
|
3690
3792
|
{
|
|
3691
|
-
definition:
|
|
3692
|
-
handler:
|
|
3793
|
+
definition: pf,
|
|
3794
|
+
handler: mf
|
|
3693
3795
|
},
|
|
3694
3796
|
{
|
|
3695
|
-
definition:
|
|
3696
|
-
handler:
|
|
3797
|
+
definition: hf,
|
|
3798
|
+
handler: gf
|
|
3697
3799
|
},
|
|
3698
3800
|
{
|
|
3699
|
-
definition:
|
|
3700
|
-
handler:
|
|
3801
|
+
definition: _f,
|
|
3802
|
+
handler: vf
|
|
3701
3803
|
},
|
|
3702
3804
|
{
|
|
3703
|
-
definition:
|
|
3704
|
-
handler:
|
|
3805
|
+
definition: yf,
|
|
3806
|
+
handler: bf
|
|
3705
3807
|
},
|
|
3706
3808
|
{
|
|
3707
|
-
definition:
|
|
3708
|
-
handler:
|
|
3809
|
+
definition: wf,
|
|
3810
|
+
handler: Tf
|
|
3709
3811
|
},
|
|
3710
3812
|
{
|
|
3711
|
-
definition:
|
|
3712
|
-
handler:
|
|
3813
|
+
definition: Ef,
|
|
3814
|
+
handler: Df
|
|
3713
3815
|
},
|
|
3714
3816
|
{
|
|
3715
|
-
definition:
|
|
3716
|
-
handler:
|
|
3817
|
+
definition: Of,
|
|
3818
|
+
handler: kf
|
|
3717
3819
|
},
|
|
3718
3820
|
{
|
|
3719
|
-
definition:
|
|
3720
|
-
handler:
|
|
3821
|
+
definition: Af,
|
|
3822
|
+
handler: jf
|
|
3721
3823
|
},
|
|
3722
3824
|
{
|
|
3723
|
-
definition:
|
|
3724
|
-
handler:
|
|
3825
|
+
definition: If,
|
|
3826
|
+
handler: Lf
|
|
3725
3827
|
},
|
|
3726
3828
|
{
|
|
3727
|
-
definition:
|
|
3728
|
-
handler:
|
|
3829
|
+
definition: Rf,
|
|
3830
|
+
handler: zf
|
|
3729
3831
|
},
|
|
3730
3832
|
{
|
|
3731
|
-
definition:
|
|
3732
|
-
handler:
|
|
3833
|
+
definition: Bf,
|
|
3834
|
+
handler: Vf
|
|
3733
3835
|
},
|
|
3734
3836
|
{
|
|
3735
|
-
definition:
|
|
3736
|
-
handler:
|
|
3837
|
+
definition: Hf,
|
|
3838
|
+
handler: Uf
|
|
3737
3839
|
},
|
|
3738
3840
|
{
|
|
3739
|
-
definition:
|
|
3740
|
-
handler:
|
|
3841
|
+
definition: Wf,
|
|
3842
|
+
handler: Gf
|
|
3741
3843
|
},
|
|
3742
3844
|
{
|
|
3743
|
-
definition:
|
|
3744
|
-
handler:
|
|
3845
|
+
definition: Kf,
|
|
3846
|
+
handler: qf
|
|
3745
3847
|
},
|
|
3746
3848
|
{
|
|
3747
|
-
definition:
|
|
3748
|
-
handler:
|
|
3849
|
+
definition: Jf,
|
|
3850
|
+
handler: Yf
|
|
3749
3851
|
},
|
|
3750
3852
|
{
|
|
3751
|
-
definition:
|
|
3752
|
-
handler:
|
|
3853
|
+
definition: Xf,
|
|
3854
|
+
handler: Qf
|
|
3753
3855
|
},
|
|
3754
3856
|
{
|
|
3755
|
-
definition:
|
|
3756
|
-
handler:
|
|
3857
|
+
definition: $f,
|
|
3858
|
+
handler: ep
|
|
3757
3859
|
},
|
|
3758
3860
|
{
|
|
3759
|
-
definition:
|
|
3760
|
-
handler:
|
|
3861
|
+
definition: tp,
|
|
3862
|
+
handler: np
|
|
3761
3863
|
},
|
|
3762
3864
|
{
|
|
3763
|
-
definition:
|
|
3764
|
-
handler:
|
|
3865
|
+
definition: rp,
|
|
3866
|
+
handler: ip
|
|
3765
3867
|
},
|
|
3766
3868
|
{
|
|
3767
|
-
definition:
|
|
3768
|
-
handler:
|
|
3869
|
+
definition: fp,
|
|
3870
|
+
handler: pp
|
|
3769
3871
|
},
|
|
3770
3872
|
{
|
|
3771
|
-
definition:
|
|
3772
|
-
handler:
|
|
3873
|
+
definition: mp,
|
|
3874
|
+
handler: hp
|
|
3773
3875
|
},
|
|
3774
3876
|
{
|
|
3775
|
-
definition:
|
|
3776
|
-
handler:
|
|
3877
|
+
definition: yp,
|
|
3878
|
+
handler: bp
|
|
3777
3879
|
}
|
|
3778
3880
|
];
|
|
3779
|
-
function
|
|
3780
|
-
let t =
|
|
3881
|
+
function Sp(e) {
|
|
3882
|
+
let t = xp.map(({ definition: t, handler: n }) => e.register(t, n));
|
|
3781
3883
|
return () => t.forEach((e) => e());
|
|
3782
3884
|
}
|
|
3783
3885
|
function R() {
|
|
@@ -3785,126 +3887,126 @@ function R() {
|
|
|
3785
3887
|
}
|
|
3786
3888
|
//#endregion
|
|
3787
3889
|
//#region src/utils/log-sink.ts
|
|
3788
|
-
var
|
|
3789
|
-
function
|
|
3790
|
-
e.level <
|
|
3890
|
+
var Cp = 1e3, wp = S.INFO, z = [], Tp = Cp, Ep = wp, Dp = null;
|
|
3891
|
+
function Op(e) {
|
|
3892
|
+
e.level < Ep || (z.push(e), z.length > Tp && (z = z.slice(-Tp)));
|
|
3791
3893
|
}
|
|
3792
|
-
function
|
|
3793
|
-
|
|
3894
|
+
function kp(e) {
|
|
3895
|
+
Tp = e?.maxBufferSize ?? Cp, Ep = e?.minLevel ?? wp, z = [], ve(Op);
|
|
3794
3896
|
}
|
|
3795
|
-
function
|
|
3796
|
-
|
|
3897
|
+
function Ap(e) {
|
|
3898
|
+
Dp = e;
|
|
3797
3899
|
}
|
|
3798
|
-
function
|
|
3900
|
+
function jp() {
|
|
3799
3901
|
return z;
|
|
3800
3902
|
}
|
|
3801
|
-
function
|
|
3903
|
+
function Mp() {
|
|
3802
3904
|
let e = z;
|
|
3803
3905
|
return z = [], e;
|
|
3804
3906
|
}
|
|
3805
|
-
function
|
|
3806
|
-
if (!
|
|
3807
|
-
let e =
|
|
3808
|
-
return
|
|
3907
|
+
function Np() {
|
|
3908
|
+
if (!Dp || z.length === 0) return 0;
|
|
3909
|
+
let e = Mp();
|
|
3910
|
+
return Dp(e), e.length;
|
|
3809
3911
|
}
|
|
3810
|
-
function
|
|
3912
|
+
function Pp() {
|
|
3811
3913
|
z = [];
|
|
3812
3914
|
}
|
|
3813
|
-
function
|
|
3915
|
+
function Fp() {
|
|
3814
3916
|
return z.length;
|
|
3815
3917
|
}
|
|
3816
|
-
|
|
3918
|
+
kp();
|
|
3817
3919
|
//#endregion
|
|
3818
3920
|
//#region src/utils/log-sender.ts
|
|
3819
|
-
var
|
|
3820
|
-
[
|
|
3821
|
-
[
|
|
3822
|
-
[
|
|
3823
|
-
[
|
|
3824
|
-
}, B,
|
|
3825
|
-
function
|
|
3826
|
-
return e.length <=
|
|
3827
|
-
}
|
|
3828
|
-
function
|
|
3921
|
+
var Ip = C("LogSender"), Lp = 1e3, Rp = 6e4, zp = 15e3, Bp = 10240, Vp = 409600, Hp = "…[truncated]", Up = {
|
|
3922
|
+
[S.DEBUG]: he.Debug,
|
|
3923
|
+
[S.INFO]: he.Info,
|
|
3924
|
+
[S.WARN]: he.Warning,
|
|
3925
|
+
[S.ERROR]: he.Error
|
|
3926
|
+
}, B, Wp, V, H = [], Gp = 0, Kp;
|
|
3927
|
+
function qp(e) {
|
|
3928
|
+
return e.length <= Bp ? e : e.slice(0, 10228) + Hp;
|
|
3929
|
+
}
|
|
3930
|
+
function Jp(e) {
|
|
3829
3931
|
return {
|
|
3830
3932
|
Time: e.timestamp,
|
|
3831
|
-
Type:
|
|
3832
|
-
Message:
|
|
3933
|
+
Type: Up[e.level] ?? he.Info,
|
|
3934
|
+
Message: qp(`[${e.component}] ${e.message}`),
|
|
3833
3935
|
Parameters: "{}"
|
|
3834
3936
|
};
|
|
3835
3937
|
}
|
|
3836
|
-
function
|
|
3938
|
+
function Yp(e) {
|
|
3837
3939
|
return JSON.stringify({
|
|
3838
3940
|
type: "sdk-typescript",
|
|
3839
3941
|
event: { Logs: e }
|
|
3840
3942
|
});
|
|
3841
3943
|
}
|
|
3842
|
-
function
|
|
3944
|
+
function Xp(e) {
|
|
3843
3945
|
if (e.length === 0) return [];
|
|
3844
|
-
let t =
|
|
3946
|
+
let t = Vp - Yp([]).length, n = [], r = [], i = 0;
|
|
3845
3947
|
for (let a of e) {
|
|
3846
3948
|
let e = JSON.stringify(a).length + 1;
|
|
3847
3949
|
r.length > 0 && i + e > t && (n.push(r), r = [], i = 0), r.push(a), i += e;
|
|
3848
3950
|
}
|
|
3849
3951
|
return r.length > 0 && n.push(r), n;
|
|
3850
3952
|
}
|
|
3851
|
-
async function
|
|
3953
|
+
async function Zp(e) {
|
|
3852
3954
|
if (e.length === 0 || !B) return;
|
|
3853
3955
|
let t = `${B}/events/logs/json`, n = {
|
|
3854
3956
|
"Content-Type": "application/json",
|
|
3855
|
-
Authorization: `Bearer ${
|
|
3957
|
+
Authorization: `Bearer ${Wp}`
|
|
3856
3958
|
}, r = await fetch(t, {
|
|
3857
3959
|
method: "POST",
|
|
3858
3960
|
headers: n,
|
|
3859
|
-
body:
|
|
3860
|
-
signal:
|
|
3961
|
+
body: Yp(e),
|
|
3962
|
+
signal: I(zp)
|
|
3861
3963
|
});
|
|
3862
3964
|
if (!r.ok) {
|
|
3863
3965
|
if (r.status >= 400 && r.status < 500) {
|
|
3864
|
-
|
|
3966
|
+
Ip.warn(`Dropping ${e.length} log entries due to ${r.status}`);
|
|
3865
3967
|
return;
|
|
3866
3968
|
}
|
|
3867
3969
|
throw Error(`Failed to send logs: ${r.status}`);
|
|
3868
3970
|
}
|
|
3869
3971
|
}
|
|
3870
|
-
function
|
|
3871
|
-
if (
|
|
3872
|
-
let e =
|
|
3873
|
-
return Math.min(e,
|
|
3972
|
+
function Qp() {
|
|
3973
|
+
if (Gp === 0) return Lp;
|
|
3974
|
+
let e = Lp * (1 << Math.min(Gp, 6));
|
|
3975
|
+
return Math.min(e, Rp);
|
|
3874
3976
|
}
|
|
3875
|
-
function
|
|
3876
|
-
B && (V = setTimeout(() => void
|
|
3977
|
+
function $p(e) {
|
|
3978
|
+
B && (V = setTimeout(() => void em(), e));
|
|
3877
3979
|
}
|
|
3878
|
-
async function
|
|
3980
|
+
async function em() {
|
|
3879
3981
|
V = void 0;
|
|
3880
|
-
let e =
|
|
3881
|
-
if (H = H.concat(e.map(
|
|
3882
|
-
|
|
3982
|
+
let e = Mp();
|
|
3983
|
+
if (H = H.concat(e.map(Jp)), typeof navigator < "u" && navigator.onLine === !1) {
|
|
3984
|
+
$p(Lp);
|
|
3883
3985
|
return;
|
|
3884
3986
|
}
|
|
3885
3987
|
if (H.length === 0) {
|
|
3886
|
-
|
|
3988
|
+
$p(Lp);
|
|
3887
3989
|
return;
|
|
3888
3990
|
}
|
|
3889
3991
|
let t = H;
|
|
3890
3992
|
H = [];
|
|
3891
|
-
let n =
|
|
3993
|
+
let n = Xp(t), r = !1;
|
|
3892
3994
|
for (let e = 0; e < n.length; e++) try {
|
|
3893
|
-
await
|
|
3995
|
+
await Zp(n[e]);
|
|
3894
3996
|
} catch {
|
|
3895
3997
|
H = n.slice(e).flat().concat(H), r = !0;
|
|
3896
3998
|
break;
|
|
3897
3999
|
}
|
|
3898
|
-
r ?
|
|
4000
|
+
r ? Gp++ : Gp = 0, $p(Qp());
|
|
3899
4001
|
}
|
|
3900
|
-
function
|
|
3901
|
-
V !== void 0 && (clearTimeout(V), V = void 0),
|
|
4002
|
+
function tm() {
|
|
4003
|
+
V !== void 0 && (clearTimeout(V), V = void 0), $p(0);
|
|
3902
4004
|
}
|
|
3903
|
-
function
|
|
3904
|
-
|
|
4005
|
+
function nm(e, t) {
|
|
4006
|
+
im(), B = e, Wp = t, Gp = 0, typeof window < "u" && (Kp = tm, window.addEventListener("online", Kp)), $p(Lp);
|
|
3905
4007
|
}
|
|
3906
|
-
function
|
|
3907
|
-
if (!B || !
|
|
4008
|
+
function rm(e, t) {
|
|
4009
|
+
if (!B || !Wp) return;
|
|
3908
4010
|
let n = { Events: [{
|
|
3909
4011
|
Time: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3910
4012
|
EventName: e,
|
|
@@ -3918,60 +4020,60 @@ function Hp(e, t) {
|
|
|
3918
4020
|
method: "POST",
|
|
3919
4021
|
headers: {
|
|
3920
4022
|
"Content-Type": "application/json",
|
|
3921
|
-
Authorization: `Bearer ${
|
|
4023
|
+
Authorization: `Bearer ${Wp}`
|
|
3922
4024
|
},
|
|
3923
4025
|
body: r
|
|
3924
|
-
}).catch((t) =>
|
|
4026
|
+
}).catch((t) => Ip.warn(`Failed to send analytics event ${e}: ${t}`));
|
|
3925
4027
|
}
|
|
3926
|
-
function
|
|
3927
|
-
V !== void 0 && (clearTimeout(V), V = void 0),
|
|
4028
|
+
function im() {
|
|
4029
|
+
V !== void 0 && (clearTimeout(V), V = void 0), Kp !== void 0 && typeof window < "u" && (window.removeEventListener("online", Kp), Kp = void 0), B = void 0, Wp = void 0, H = [], Gp = 0;
|
|
3928
4030
|
}
|
|
3929
4031
|
//#endregion
|
|
3930
4032
|
//#region src/utils/connect-timeline.ts
|
|
3931
|
-
var
|
|
3932
|
-
function
|
|
4033
|
+
var am = C("ConnectTimeline"), om = "ikon-connect-trace-id", sm, cm = !1;
|
|
4034
|
+
function lm() {
|
|
3933
4035
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`;
|
|
3934
4036
|
}
|
|
3935
|
-
function
|
|
4037
|
+
function um() {
|
|
3936
4038
|
try {
|
|
3937
|
-
let e = sessionStorage.getItem(
|
|
4039
|
+
let e = sessionStorage.getItem(om);
|
|
3938
4040
|
if (e) return e;
|
|
3939
|
-
let t =
|
|
3940
|
-
return sessionStorage.setItem(
|
|
4041
|
+
let t = lm();
|
|
4042
|
+
return sessionStorage.setItem(om, t), t;
|
|
3941
4043
|
} catch {
|
|
3942
|
-
return
|
|
4044
|
+
return sm ??= lm(), sm;
|
|
3943
4045
|
}
|
|
3944
4046
|
}
|
|
3945
|
-
function
|
|
4047
|
+
function dm(e) {
|
|
3946
4048
|
if (typeof performance > "u" || typeof performance.getEntriesByType != "function") return;
|
|
3947
4049
|
let t = performance.getEntriesByType("resource");
|
|
3948
4050
|
for (let n = t.length - 1; n >= 0; n--) if (t[n].name.includes(e)) return Math.round(t[n].duration);
|
|
3949
4051
|
}
|
|
3950
|
-
function
|
|
3951
|
-
if (
|
|
3952
|
-
|
|
3953
|
-
let t = { connectTraceId:
|
|
4052
|
+
function fm(e = {}) {
|
|
4053
|
+
if (cm) return;
|
|
4054
|
+
cm = !0;
|
|
4055
|
+
let t = { connectTraceId: um() };
|
|
3954
4056
|
e.snapshotSeeded !== void 0 && (t.snapshotSeeded = String(e.snapshotSeeded));
|
|
3955
4057
|
try {
|
|
3956
4058
|
if (typeof performance < "u") {
|
|
3957
4059
|
t.firstPaintMs = String(Math.round(performance.now()));
|
|
3958
4060
|
let e = performance.getEntriesByType("navigation")[0];
|
|
3959
4061
|
e && (t.cdnHtmlMs = String(Math.round(e.responseEnd - e.fetchStart)), t.domContentLoadedMs = String(Math.round(e.domContentLoadedEventEnd)));
|
|
3960
|
-
let n =
|
|
4062
|
+
let n = dm("/anonymous");
|
|
3961
4063
|
n !== void 0 && (t.authMs = String(n));
|
|
3962
|
-
let r =
|
|
4064
|
+
let r = dm("/init");
|
|
3963
4065
|
r !== void 0 && (t.initMs = String(r));
|
|
3964
|
-
let i =
|
|
4066
|
+
let i = dm("/connect");
|
|
3965
4067
|
i !== void 0 && (t.connectMs = String(i));
|
|
3966
4068
|
}
|
|
3967
4069
|
} catch (e) {
|
|
3968
|
-
|
|
4070
|
+
am.warn(`Failed to read performance timeline: ${e}`);
|
|
3969
4071
|
}
|
|
3970
|
-
|
|
4072
|
+
rm("client_connect_timeline", t);
|
|
3971
4073
|
}
|
|
3972
4074
|
//#endregion
|
|
3973
4075
|
//#region src/utils/uuid.ts
|
|
3974
|
-
function
|
|
4076
|
+
function pm() {
|
|
3975
4077
|
let e = globalThis.crypto;
|
|
3976
4078
|
if (e && typeof e.randomUUID == "function") return e.randomUUID();
|
|
3977
4079
|
let t = /* @__PURE__ */ new Uint8Array(16);
|
|
@@ -3984,34 +4086,34 @@ function Qp() {
|
|
|
3984
4086
|
}
|
|
3985
4087
|
//#endregion
|
|
3986
4088
|
//#region src/storage.ts
|
|
3987
|
-
var
|
|
3988
|
-
function
|
|
3989
|
-
if (typeof window > "u" || typeof localStorage > "u") return
|
|
4089
|
+
var mm = "ikon-device-id";
|
|
4090
|
+
function hm() {
|
|
4091
|
+
if (typeof window > "u" || typeof localStorage > "u") return pm();
|
|
3990
4092
|
try {
|
|
3991
|
-
let e = localStorage.getItem(
|
|
3992
|
-
return e || (e =
|
|
4093
|
+
let e = localStorage.getItem(mm);
|
|
4094
|
+
return e || (e = pm(), localStorage.setItem(mm, e)), e;
|
|
3993
4095
|
} catch {
|
|
3994
|
-
return
|
|
4096
|
+
return pm();
|
|
3995
4097
|
}
|
|
3996
4098
|
}
|
|
3997
|
-
function
|
|
4099
|
+
function gm() {
|
|
3998
4100
|
if (!(typeof localStorage > "u")) try {
|
|
3999
|
-
localStorage.removeItem(
|
|
4101
|
+
localStorage.removeItem(mm);
|
|
4000
4102
|
} catch {}
|
|
4001
4103
|
}
|
|
4002
|
-
function
|
|
4003
|
-
let t =
|
|
4104
|
+
function _m(e) {
|
|
4105
|
+
let t = ym(e);
|
|
4004
4106
|
return typeof t?.id == "string" ? t.id : null;
|
|
4005
4107
|
}
|
|
4006
|
-
function
|
|
4007
|
-
let t =
|
|
4108
|
+
function vm(e) {
|
|
4109
|
+
let t = ym(e);
|
|
4008
4110
|
return t ? {
|
|
4009
4111
|
userId: typeof t.id == "string" ? t.id : null,
|
|
4010
4112
|
authSession: typeof t.authSession == "string" ? t.authSession : null,
|
|
4011
4113
|
role: typeof t.role == "string" ? t.role : null
|
|
4012
4114
|
} : null;
|
|
4013
4115
|
}
|
|
4014
|
-
function
|
|
4116
|
+
function ym(e) {
|
|
4015
4117
|
try {
|
|
4016
4118
|
let t = e.split(".");
|
|
4017
4119
|
if (t.length !== 3) return null;
|
|
@@ -4023,8 +4125,8 @@ function im(e) {
|
|
|
4023
4125
|
}
|
|
4024
4126
|
//#endregion
|
|
4025
4127
|
//#region src/connection/authenticator.ts
|
|
4026
|
-
var
|
|
4027
|
-
async function
|
|
4128
|
+
var U = C("Authenticator"), W = w.GROUP_CORE | w.GROUP_KEEPALIVE | w.GROUP_EVENTS | w.GROUP_ACTIONS | w.GROUP_UI | w.GROUP_AUDIO | w.GROUP_VIDEO | w.GROUP_ANALYTICS | w.GROUP_APP_LOCAL, bm = 2, xm = 6e4, Sm = 2e3, Cm = 1e4, wm = 3e3, Tm = 3e3, Em = 3, Dm = "X-Ikon-Startup-Failed", Om = "startup_failed", km = 1e3, Am = 4;
|
|
4129
|
+
async function jm(e, t, n, r) {
|
|
4028
4130
|
if (e) try {
|
|
4029
4131
|
let i = await fetch(`${n}/anonymous`, {
|
|
4030
4132
|
method: "POST",
|
|
@@ -4037,17 +4139,17 @@ async function gm(e, t, n, r) {
|
|
|
4037
4139
|
});
|
|
4038
4140
|
if (!i.ok) {
|
|
4039
4141
|
let e = await i.text().catch(() => "");
|
|
4040
|
-
|
|
4142
|
+
U.warn(`Anonymous auth failed: ${i.status} ${e}`.trim());
|
|
4041
4143
|
return;
|
|
4042
4144
|
}
|
|
4043
4145
|
let a = await i.json();
|
|
4044
4146
|
if (!a.token) {
|
|
4045
|
-
|
|
4147
|
+
U.warn("Anonymous auth returned no token");
|
|
4046
4148
|
return;
|
|
4047
4149
|
}
|
|
4048
|
-
let o =
|
|
4150
|
+
let o = _m(a.token);
|
|
4049
4151
|
if (!o) {
|
|
4050
|
-
|
|
4152
|
+
U.warn("Anonymous auth token had no extractable userId");
|
|
4051
4153
|
return;
|
|
4052
4154
|
}
|
|
4053
4155
|
return {
|
|
@@ -4055,23 +4157,23 @@ async function gm(e, t, n, r) {
|
|
|
4055
4157
|
token: a.token
|
|
4056
4158
|
};
|
|
4057
4159
|
} catch (e) {
|
|
4058
|
-
|
|
4160
|
+
U.warn("Anonymous auth request failed:", e);
|
|
4059
4161
|
return;
|
|
4060
4162
|
}
|
|
4061
4163
|
}
|
|
4062
|
-
async function
|
|
4164
|
+
async function Mm(e, t, n, r) {
|
|
4063
4165
|
try {
|
|
4064
4166
|
let i = await fetch(`${e}/profiles/me?space=${encodeURIComponent(t)}`, {
|
|
4065
4167
|
method: "GET",
|
|
4066
4168
|
headers: { Authorization: `Bearer ${n}` },
|
|
4067
4169
|
signal: r
|
|
4068
4170
|
});
|
|
4069
|
-
i.ok ||
|
|
4171
|
+
i.ok || U.warn(`Failed to ensure profile: ${i.status}`);
|
|
4070
4172
|
} catch (e) {
|
|
4071
|
-
|
|
4173
|
+
U.warn("Failed to ensure profile:", e);
|
|
4072
4174
|
}
|
|
4073
4175
|
}
|
|
4074
|
-
async function
|
|
4176
|
+
async function Nm(e) {
|
|
4075
4177
|
let t = await e.text().catch(() => "Unknown error");
|
|
4076
4178
|
try {
|
|
4077
4179
|
let e = JSON.parse(t);
|
|
@@ -4079,16 +4181,16 @@ async function vm(e) {
|
|
|
4079
4181
|
} catch {}
|
|
4080
4182
|
return t;
|
|
4081
4183
|
}
|
|
4082
|
-
async function
|
|
4184
|
+
async function Pm(e) {
|
|
4083
4185
|
if (e.ok) return;
|
|
4084
|
-
let t = await
|
|
4085
|
-
throw e.status === 403 ? new Ml(`Access denied: ${t}`, t) :
|
|
4186
|
+
let t = await Nm(e);
|
|
4187
|
+
throw e.status === 403 ? new Ml(`Access denied: ${t}`, t) : Fm("Failed to get or create profile", e.status, t);
|
|
4086
4188
|
}
|
|
4087
|
-
function
|
|
4189
|
+
function Fm(e, t, n) {
|
|
4088
4190
|
let r = `${e}: ${t} ${n}`;
|
|
4089
|
-
return t >= 500 ? new Fl(r, t) : new
|
|
4191
|
+
return t >= 500 ? new Fl(r, t) : new T(r);
|
|
4090
4192
|
}
|
|
4091
|
-
function
|
|
4193
|
+
function Im(e, t, n) {
|
|
4092
4194
|
let r = {
|
|
4093
4195
|
method: "POST",
|
|
4094
4196
|
headers: {
|
|
@@ -4100,35 +4202,35 @@ function xm(e, t, n) {
|
|
|
4100
4202
|
};
|
|
4101
4203
|
return t || (r.credentials = "include"), r;
|
|
4102
4204
|
}
|
|
4103
|
-
async function
|
|
4104
|
-
let i = `${e}/init`, a = await fetch(i,
|
|
4205
|
+
async function Lm(e, t, n, r) {
|
|
4206
|
+
let i = `${e}/init`, a = await fetch(i, Im(t, n, r));
|
|
4105
4207
|
if (!a.ok) {
|
|
4106
|
-
let e = await
|
|
4107
|
-
throw a.status === 403 ? new Ml(`Access denied: ${e}`, e) : a.status === 404 && t.sessionIdentityHash ? new Nl(t.sessionIdentityHash) :
|
|
4208
|
+
let e = await Nm(a);
|
|
4209
|
+
throw a.status === 403 ? new Ml(`Access denied: ${e}`, e) : a.status === 404 && t.sessionIdentityHash ? new Nl(t.sessionIdentityHash) : Fm("Backend init failed", a.status, e);
|
|
4108
4210
|
}
|
|
4109
4211
|
return a.json();
|
|
4110
4212
|
}
|
|
4111
|
-
function
|
|
4112
|
-
return e.startupFailed ? new
|
|
4213
|
+
function Rm(e, t) {
|
|
4214
|
+
return e.startupFailed ? new O() : new Al(t);
|
|
4113
4215
|
}
|
|
4114
|
-
async function
|
|
4115
|
-
let r =
|
|
4216
|
+
async function G(e, t, n) {
|
|
4217
|
+
let r = I(n ?? Cm), i = t ? gd([t, r]) : r, a = Date.now(), o = await fetch(e, { signal: i });
|
|
4116
4218
|
if (!o.ok) {
|
|
4117
4219
|
let e = await o.text().catch(() => "Unknown error");
|
|
4118
|
-
throw o.status === 429 ? new Pl(`Server is at capacity: ${e}`) : o.headers.get(
|
|
4220
|
+
throw o.status === 429 ? new Pl(`Server is at capacity: ${e}`) : o.headers.get(Dm) || e.includes(Om) ? new O() : Fm("Failed to connect", o.status, e);
|
|
4119
4221
|
}
|
|
4120
4222
|
let s = await o.arrayBuffer(), c = await An(new Uint8Array(s));
|
|
4121
|
-
return
|
|
4223
|
+
return U.debug(`Connect URL fetched in ${Date.now() - a}ms`), { authResponse: c };
|
|
4122
4224
|
}
|
|
4123
|
-
async function
|
|
4225
|
+
async function zm(e, t) {
|
|
4124
4226
|
try {
|
|
4125
|
-
let n = new URL(e), r = `${n.protocol}//${n.host}/health`, i =
|
|
4227
|
+
let n = new URL(e), r = `${n.protocol}//${n.host}/health`, i = I(Tm), a = t ? gd([t, i]) : i;
|
|
4126
4228
|
return (await fetch(r, { signal: a })).ok;
|
|
4127
4229
|
} catch {
|
|
4128
4230
|
return !1;
|
|
4129
4231
|
}
|
|
4130
4232
|
}
|
|
4131
|
-
async function
|
|
4233
|
+
async function Bm(e, t, n, r, i) {
|
|
4132
4234
|
let a = [];
|
|
4133
4235
|
if (n === "force-proxy" ? t && a.push({
|
|
4134
4236
|
url: t,
|
|
@@ -4148,62 +4250,63 @@ async function Tm(e, t, n, r, i) {
|
|
|
4148
4250
|
}), t && a.push({
|
|
4149
4251
|
url: t,
|
|
4150
4252
|
isProxy: !0
|
|
4151
|
-
})), a.length === 0) throw new
|
|
4152
|
-
|
|
4253
|
+
})), a.length === 0) throw new T("No connect URL available");
|
|
4254
|
+
U.debug(`Auth URL order: [${a.map((e) => e.isProxy ? "proxy" : "direct").join(", ")}], mode: ${n}, proxyPreferred: ${r}`);
|
|
4153
4255
|
let o = n === "auto" && a.length > 1 && !a[0].isProxy, s = Date.now(), c = 0;
|
|
4154
|
-
for (; c <
|
|
4256
|
+
for (; c < bm || Date.now() - s < xm;) {
|
|
4155
4257
|
for (let t = 0; t < a.length; t++) {
|
|
4156
|
-
let n = a[t], r = c === 0 && t === 0 && o ?
|
|
4258
|
+
let n = a[t], r = c === 0 && t === 0 && o ? wm : Cm;
|
|
4157
4259
|
try {
|
|
4158
|
-
let t = await
|
|
4159
|
-
return t.usedProxyUrl = n.isProxy, t.directUrl = e,
|
|
4260
|
+
let t = await G(n.url, i, r);
|
|
4261
|
+
return t.usedProxyUrl = n.isProxy, t.directUrl = e, U.debug(`Auth succeeded via ${n.isProxy ? "proxy" : "direct"} URL`), t;
|
|
4160
4262
|
} catch (e) {
|
|
4161
|
-
if (i?.aborted || e instanceof Pl || e instanceof
|
|
4162
|
-
|
|
4263
|
+
if (i?.aborted || e instanceof Pl || e instanceof O) throw e;
|
|
4264
|
+
U.warn(`Auth via ${n.isProxy ? "proxy" : "direct"} URL failed (round ${c + 1}, timeout ${r}ms): ${e}`);
|
|
4163
4265
|
}
|
|
4164
4266
|
}
|
|
4165
|
-
c++, await Ll(
|
|
4267
|
+
c++, await Ll(Sm, i);
|
|
4166
4268
|
}
|
|
4167
|
-
throw new
|
|
4269
|
+
throw new T("Failed to connect after exhausting all URL attempts");
|
|
4168
4270
|
}
|
|
4169
|
-
function
|
|
4170
|
-
let i =
|
|
4271
|
+
function Vm(e, t, n = "", r = !0) {
|
|
4272
|
+
let i = df();
|
|
4171
4273
|
return Zt({
|
|
4172
4274
|
ServerSessionId: "",
|
|
4173
4275
|
ContextType: m.Browser,
|
|
4174
4276
|
UserType: p.Human,
|
|
4175
4277
|
PayloadType: me.Teleport,
|
|
4176
4278
|
IsInternal: !1,
|
|
4177
|
-
IsSnapshot:
|
|
4279
|
+
IsSnapshot: gu(),
|
|
4178
4280
|
Description: e.description ?? "Ikon SDK TypeScript",
|
|
4179
4281
|
UserId: t,
|
|
4180
|
-
DeviceId: e.deviceId ??
|
|
4282
|
+
DeviceId: e.deviceId ?? hm(),
|
|
4181
4283
|
ProductId: e.productId ?? "ikon-sdk",
|
|
4182
4284
|
VersionId: e.versionId ?? "1.0.0",
|
|
4183
4285
|
InstallId: e.installId ?? "",
|
|
4184
4286
|
Locale: e.locale ?? (typeof navigator < "u" ? navigator.language : "en-US"),
|
|
4185
|
-
OpcodeGroupsFromServer: e.opcodeGroupsFromServer ??
|
|
4186
|
-
OpcodeGroupsToServer: e.opcodeGroupsToServer ??
|
|
4287
|
+
OpcodeGroupsFromServer: e.opcodeGroupsFromServer ?? W,
|
|
4288
|
+
OpcodeGroupsToServer: e.opcodeGroupsToServer ?? W,
|
|
4187
4289
|
ProtocolVersion: 1,
|
|
4188
|
-
SdkCapability:
|
|
4290
|
+
SdkCapability: Am,
|
|
4189
4291
|
HasInput: !1,
|
|
4190
4292
|
AuthSessionId: n,
|
|
4191
4293
|
IsAnonymous: r,
|
|
4192
4294
|
IsGlobal: !1,
|
|
4193
4295
|
ReceiveAllMessages: !1,
|
|
4194
4296
|
UserAgent: typeof navigator < "u" ? navigator.userAgent : "",
|
|
4195
|
-
ClientType:
|
|
4297
|
+
ClientType: Cf(),
|
|
4196
4298
|
Parameters: e.parameters ?? {},
|
|
4197
4299
|
ViewportWidth: i.width,
|
|
4198
4300
|
ViewportHeight: i.height,
|
|
4199
|
-
Theme:
|
|
4200
|
-
Timezone:
|
|
4201
|
-
IsTouchDevice:
|
|
4202
|
-
InitialPath:
|
|
4203
|
-
|
|
4301
|
+
Theme: uf(),
|
|
4302
|
+
Timezone: xf(),
|
|
4303
|
+
IsTouchDevice: Sf(),
|
|
4304
|
+
InitialPath: Hd(),
|
|
4305
|
+
InitialUrl: Ud(),
|
|
4306
|
+
SupportsCompression: Oe()
|
|
4204
4307
|
});
|
|
4205
4308
|
}
|
|
4206
|
-
function
|
|
4309
|
+
function Hm(e) {
|
|
4207
4310
|
return {
|
|
4208
4311
|
ServerSessionId: e.ServerSessionId,
|
|
4209
4312
|
ContextType: e.ContextType,
|
|
@@ -4236,29 +4339,30 @@ function Dm(e) {
|
|
|
4236
4339
|
Timezone: e.Timezone,
|
|
4237
4340
|
IsTouchDevice: e.IsTouchDevice,
|
|
4238
4341
|
InitialPath: e.InitialPath,
|
|
4342
|
+
InitialUrl: e.InitialUrl,
|
|
4239
4343
|
SupportsCompression: e.SupportsCompression
|
|
4240
4344
|
};
|
|
4241
4345
|
}
|
|
4242
|
-
async function
|
|
4346
|
+
async function Um(e, t) {
|
|
4243
4347
|
let n = `https://${e.host}:${e.httpsPort}`;
|
|
4244
|
-
|
|
4348
|
+
U.debug(`Authenticating with local server: ${n}`);
|
|
4245
4349
|
let r = {
|
|
4246
|
-
...
|
|
4350
|
+
...Id(),
|
|
4247
4351
|
...e.parameters
|
|
4248
|
-
}, i = e.deviceId ??
|
|
4352
|
+
}, i = e.deviceId ?? hm(), a = e.userId, o = e.token;
|
|
4249
4353
|
if (!a) {
|
|
4250
|
-
let n = await
|
|
4354
|
+
let n = await jm(e.spaceId, i, await Pd(e.authUrl), t);
|
|
4251
4355
|
n && (a = n.userId, o = n.token);
|
|
4252
4356
|
}
|
|
4253
|
-
if (a || (a = i,
|
|
4357
|
+
if (a || (a = i, U.debug("Using deviceId as userId fallback")), e.spaceId && o) if (e.token) {
|
|
4254
4358
|
let n = jd(e.backendUrl);
|
|
4255
|
-
await
|
|
4359
|
+
await Pm(await fetch(`${n}/profiles/me?space=${encodeURIComponent(e.spaceId)}`, {
|
|
4256
4360
|
method: "GET",
|
|
4257
4361
|
headers: { Authorization: `Bearer ${o}` },
|
|
4258
4362
|
signal: t
|
|
4259
4363
|
}));
|
|
4260
|
-
} else await
|
|
4261
|
-
let s = e.token ?? e.identityToken ?? o, c = s ?
|
|
4364
|
+
} else await Mm(jd(e.backendUrl), e.spaceId, o, t);
|
|
4365
|
+
let s = e.token ?? e.identityToken ?? o, c = s ? vm(s) : null, l = c?.authSession ?? (e.token ? "authenticated" : ""), u = c?.role ? c.role === "anonymous" : !e.token, d = Hm(Vm({
|
|
4262
4366
|
...e,
|
|
4263
4367
|
parameters: r
|
|
4264
4368
|
}, a, l, u)), f = await fetch(`${n}/connect-token`, {
|
|
@@ -4269,16 +4373,16 @@ async function Om(e, t) {
|
|
|
4269
4373
|
});
|
|
4270
4374
|
if (!f.ok) {
|
|
4271
4375
|
let e = await f.text().catch(() => "Unknown error");
|
|
4272
|
-
throw
|
|
4376
|
+
throw Fm("Failed to get connect token", f.status, e);
|
|
4273
4377
|
}
|
|
4274
4378
|
let p = (await f.json()).token;
|
|
4275
|
-
if (!p) throw new
|
|
4276
|
-
let m = `${n}/connect?token=${encodeURIComponent(p)}`, h = await
|
|
4379
|
+
if (!p) throw new T("Server did not return a token");
|
|
4380
|
+
let m = `${n}/connect?token=${encodeURIComponent(p)}`, h = await G(m, t);
|
|
4277
4381
|
return h.directUrl = m, h.backendUrl = jd(e.backendUrl), h.authToken = o, h;
|
|
4278
4382
|
}
|
|
4279
|
-
async function
|
|
4383
|
+
async function Wm(e, t, n = "auto", r = !1) {
|
|
4280
4384
|
let i = Ad(e.backendType);
|
|
4281
|
-
|
|
4385
|
+
U.debug(`Authenticating with cloud server: ${i}, space ID: ${e.spaceId}`);
|
|
4282
4386
|
let a = await fetch(`${i}/auth/api-key`, {
|
|
4283
4387
|
method: "POST",
|
|
4284
4388
|
headers: { "Content-Type": "application/json" },
|
|
@@ -4291,14 +4395,14 @@ async function km(e, t, n = "auto", r = !1) {
|
|
|
4291
4395
|
});
|
|
4292
4396
|
if (!a.ok) {
|
|
4293
4397
|
let e = await a.text().catch(() => "Unknown error");
|
|
4294
|
-
throw
|
|
4398
|
+
throw Fm("API key authentication failed", a.status, e);
|
|
4295
4399
|
}
|
|
4296
4400
|
let o = (await a.json()).token;
|
|
4297
|
-
if (!o) throw new
|
|
4298
|
-
let s =
|
|
4401
|
+
if (!o) throw new T("Backend did not return a token");
|
|
4402
|
+
let s = Id(), c = e.provisioningTimeoutMs ?? 6e4, l = {
|
|
4299
4403
|
...s,
|
|
4300
4404
|
...e.parameters
|
|
4301
|
-
}, u =
|
|
4405
|
+
}, u = df(), d = j() ? Em : 1;
|
|
4302
4406
|
for (let a = 0; a < d; a++) try {
|
|
4303
4407
|
let a = {
|
|
4304
4408
|
space: e.spaceId,
|
|
@@ -4306,49 +4410,50 @@ async function km(e, t, n = "auto", r = !1) {
|
|
|
4306
4410
|
params: e.parameters,
|
|
4307
4411
|
waitForRunning: !0,
|
|
4308
4412
|
waitForRunningTimeoutMs: c,
|
|
4309
|
-
connectTraceId:
|
|
4413
|
+
connectTraceId: um(),
|
|
4310
4414
|
contextType: m.Plugin,
|
|
4311
4415
|
userType: e.userType ?? p.Human,
|
|
4312
|
-
clientType: e.clientType ??
|
|
4416
|
+
clientType: e.clientType ?? Cf(),
|
|
4313
4417
|
payloadType: me.Teleport,
|
|
4314
4418
|
description: e.description ?? "Ikon SDK TypeScript",
|
|
4315
|
-
deviceId: e.deviceId ??
|
|
4419
|
+
deviceId: e.deviceId ?? hm(),
|
|
4316
4420
|
productId: e.productId ?? "",
|
|
4317
4421
|
versionId: e.versionId ?? "",
|
|
4318
4422
|
installId: e.installId ?? "",
|
|
4319
4423
|
locale: e.locale ?? (typeof navigator < "u" ? navigator.language : "en-US"),
|
|
4320
|
-
opcodeGroupsFromServer: e.opcodeGroupsFromServer ??
|
|
4321
|
-
opcodeGroupsToServer: e.opcodeGroupsToServer ??
|
|
4424
|
+
opcodeGroupsFromServer: e.opcodeGroupsFromServer ?? W,
|
|
4425
|
+
opcodeGroupsToServer: e.opcodeGroupsToServer ?? W,
|
|
4322
4426
|
protocolVersion: 1,
|
|
4323
4427
|
userAgent: typeof navigator < "u" ? navigator.userAgent : "",
|
|
4324
4428
|
launchParams: l,
|
|
4325
4429
|
viewportWidth: u.width,
|
|
4326
4430
|
viewportHeight: u.height,
|
|
4327
|
-
theme:
|
|
4328
|
-
timezone:
|
|
4329
|
-
isTouchDevice:
|
|
4330
|
-
initialPath:
|
|
4431
|
+
theme: uf(),
|
|
4432
|
+
timezone: xf(),
|
|
4433
|
+
isTouchDevice: Sf(),
|
|
4434
|
+
initialPath: Hd(),
|
|
4435
|
+
initialUrl: Ud(),
|
|
4331
4436
|
sdkType: 2,
|
|
4332
|
-
sdkCapability:
|
|
4333
|
-
supportsCompression:
|
|
4334
|
-
isSnapshot:
|
|
4335
|
-
}, s = t ? gd([t,
|
|
4336
|
-
if (d.state?.toLowerCase() !== "running" || !d.configuration?.url) throw
|
|
4337
|
-
let f = await
|
|
4338
|
-
return f.backendUrl = i, f.authToken = o, f.brandingRequired = d.configuration.brandingRequired ?? !1,
|
|
4437
|
+
sdkCapability: Am,
|
|
4438
|
+
supportsCompression: Oe(),
|
|
4439
|
+
isSnapshot: gu()
|
|
4440
|
+
}, s = t ? gd([t, I(c)]) : I(c), d = await Lm(i, a, o, s);
|
|
4441
|
+
if (d.state?.toLowerCase() !== "running" || !d.configuration?.url) throw Rm(d, c);
|
|
4442
|
+
let f = await Bm(d.configuration.url, d.configuration.proxyUrl, n, r, s);
|
|
4443
|
+
return f.backendUrl = i, f.authToken = o, f.brandingRequired = d.configuration.brandingRequired ?? !1, _p(d.configuration.push), f;
|
|
4339
4444
|
} catch (e) {
|
|
4340
|
-
if (e instanceof Ml || e instanceof Pl || e instanceof Nl || e instanceof
|
|
4341
|
-
|
|
4445
|
+
if (e instanceof Ml || e instanceof Pl || e instanceof Nl || e instanceof O || a === d - 1) throw e;
|
|
4446
|
+
U.debug(`Init attempt ${a + 1}/${d} failed, retrying: ${e}`), await Ll(km * (a + 1), t);
|
|
4342
4447
|
}
|
|
4343
|
-
throw new
|
|
4448
|
+
throw new T("Failed to init after all attempts");
|
|
4344
4449
|
}
|
|
4345
|
-
async function
|
|
4450
|
+
async function Gm(e, t, n = "auto", r = !1) {
|
|
4346
4451
|
let i = Ad(e.backendType), a = e.token;
|
|
4347
|
-
|
|
4348
|
-
let o =
|
|
4452
|
+
U.debug(`Authenticating with session token to: ${i}, space ID: ${e.spaceId}`);
|
|
4453
|
+
let o = Id(), s = e.provisioningTimeoutMs ?? 6e4, c = {
|
|
4349
4454
|
...o,
|
|
4350
4455
|
...e.parameters
|
|
4351
|
-
}, l =
|
|
4456
|
+
}, l = df(), u = j() ? Em : 1;
|
|
4352
4457
|
for (let o = 0; o < u; o++) try {
|
|
4353
4458
|
let o = {
|
|
4354
4459
|
space: e.spaceId,
|
|
@@ -4356,56 +4461,57 @@ async function Am(e, t, n = "auto", r = !1) {
|
|
|
4356
4461
|
params: e.parameters,
|
|
4357
4462
|
waitForRunning: !0,
|
|
4358
4463
|
waitForRunningTimeoutMs: s,
|
|
4359
|
-
connectTraceId:
|
|
4464
|
+
connectTraceId: um(),
|
|
4360
4465
|
contextType: m.Browser,
|
|
4361
4466
|
userType: p.Human,
|
|
4362
|
-
clientType:
|
|
4467
|
+
clientType: Cf(),
|
|
4363
4468
|
payloadType: me.Teleport,
|
|
4364
4469
|
description: e.description ?? "Ikon SDK TypeScript",
|
|
4365
|
-
deviceId: e.deviceId ??
|
|
4470
|
+
deviceId: e.deviceId ?? hm(),
|
|
4366
4471
|
productId: e.productId ?? "",
|
|
4367
4472
|
versionId: e.versionId ?? "",
|
|
4368
4473
|
installId: e.installId ?? "",
|
|
4369
4474
|
locale: e.locale ?? (typeof navigator < "u" ? navigator.language : "en-US"),
|
|
4370
|
-
opcodeGroupsFromServer: e.opcodeGroupsFromServer ??
|
|
4371
|
-
opcodeGroupsToServer: e.opcodeGroupsToServer ??
|
|
4475
|
+
opcodeGroupsFromServer: e.opcodeGroupsFromServer ?? W,
|
|
4476
|
+
opcodeGroupsToServer: e.opcodeGroupsToServer ?? W,
|
|
4372
4477
|
protocolVersion: 1,
|
|
4373
4478
|
userAgent: typeof navigator < "u" ? navigator.userAgent : "",
|
|
4374
4479
|
launchParams: c,
|
|
4375
4480
|
viewportWidth: l.width,
|
|
4376
4481
|
viewportHeight: l.height,
|
|
4377
|
-
theme:
|
|
4378
|
-
timezone:
|
|
4379
|
-
isTouchDevice:
|
|
4380
|
-
initialPath:
|
|
4482
|
+
theme: uf(),
|
|
4483
|
+
timezone: xf(),
|
|
4484
|
+
isTouchDevice: Sf(),
|
|
4485
|
+
initialPath: Hd(),
|
|
4486
|
+
initialUrl: Ud(),
|
|
4381
4487
|
sdkType: 2,
|
|
4382
|
-
sdkCapability:
|
|
4383
|
-
supportsCompression:
|
|
4384
|
-
isSnapshot:
|
|
4385
|
-
}, u = t ? gd([t,
|
|
4386
|
-
if (d.state?.toLowerCase() !== "running" || !d.configuration?.url) throw
|
|
4387
|
-
let f = await
|
|
4388
|
-
return f.backendUrl = i, f.authToken = a, f.brandingRequired = d.configuration.brandingRequired ?? !1,
|
|
4488
|
+
sdkCapability: Am,
|
|
4489
|
+
supportsCompression: Oe(),
|
|
4490
|
+
isSnapshot: gu()
|
|
4491
|
+
}, u = t ? gd([t, I(s)]) : I(s), d = await Lm(i, o, a, u);
|
|
4492
|
+
if (d.state?.toLowerCase() !== "running" || !d.configuration?.url) throw Rm(d, s);
|
|
4493
|
+
let f = await Bm(d.configuration.url, d.configuration.proxyUrl, n, r, u);
|
|
4494
|
+
return f.backendUrl = i, f.authToken = a, f.brandingRequired = d.configuration.brandingRequired ?? !1, _p(d.configuration.push), f;
|
|
4389
4495
|
} catch (e) {
|
|
4390
|
-
if (e instanceof Ml || e instanceof Pl || e instanceof Nl || e instanceof
|
|
4391
|
-
|
|
4496
|
+
if (e instanceof Ml || e instanceof Pl || e instanceof Nl || e instanceof O || o === u - 1) throw e;
|
|
4497
|
+
U.debug(`Init attempt ${o + 1}/${u} failed, retrying: ${e}`), await Ll(km * (o + 1), t);
|
|
4392
4498
|
}
|
|
4393
|
-
throw new
|
|
4499
|
+
throw new T("Failed to init after all attempts");
|
|
4394
4500
|
}
|
|
4395
4501
|
//#endregion
|
|
4396
4502
|
//#region src/functions/type-conversion.ts
|
|
4397
|
-
var
|
|
4398
|
-
function
|
|
4503
|
+
var Km = /* @__PURE__ */ new Uint8Array();
|
|
4504
|
+
function qm(e) {
|
|
4399
4505
|
switch (e.kind) {
|
|
4400
4506
|
case "array": return {
|
|
4401
4507
|
kind: "array",
|
|
4402
|
-
element:
|
|
4508
|
+
element: qm(e.element),
|
|
4403
4509
|
nullable: e.nullable ?? !1
|
|
4404
4510
|
};
|
|
4405
4511
|
case "dictionary": return {
|
|
4406
4512
|
kind: "dictionary",
|
|
4407
4513
|
keyType: e.keyType ?? "string",
|
|
4408
|
-
value:
|
|
4514
|
+
value: qm(e.value),
|
|
4409
4515
|
nullable: e.nullable ?? !1
|
|
4410
4516
|
};
|
|
4411
4517
|
default: return {
|
|
@@ -4414,17 +4520,17 @@ function Mm(e) {
|
|
|
4414
4520
|
};
|
|
4415
4521
|
}
|
|
4416
4522
|
}
|
|
4417
|
-
function
|
|
4523
|
+
function Jm(e) {
|
|
4418
4524
|
switch (e.kind) {
|
|
4419
4525
|
case "boolean": return "System.Boolean";
|
|
4420
4526
|
case "number": return "System.Double";
|
|
4421
4527
|
case "string": return "System.String";
|
|
4422
|
-
case "array": return `System.Collections.Generic.List\`1[${
|
|
4423
|
-
case "dictionary": return `System.Collections.Generic.Dictionary\`2[${e.keyType === "int" ? "System.Int32" : "System.String"},${
|
|
4528
|
+
case "array": return `System.Collections.Generic.List\`1[${Jm(e.element)}]`;
|
|
4529
|
+
case "dictionary": return `System.Collections.Generic.Dictionary\`2[${e.keyType === "int" ? "System.Int32" : "System.String"},${Jm(e.value)}]`;
|
|
4424
4530
|
default: return e;
|
|
4425
4531
|
}
|
|
4426
4532
|
}
|
|
4427
|
-
function
|
|
4533
|
+
function Ym(e, t) {
|
|
4428
4534
|
if (e === void 0 || e === "") return;
|
|
4429
4535
|
let n = JSON.parse(e);
|
|
4430
4536
|
if (n === null) {
|
|
@@ -4433,7 +4539,7 @@ function Pm(e, t) {
|
|
|
4433
4539
|
}
|
|
4434
4540
|
return n;
|
|
4435
4541
|
}
|
|
4436
|
-
function
|
|
4542
|
+
function Xm(e, t) {
|
|
4437
4543
|
if (e === void 0) return "null";
|
|
4438
4544
|
if (e === null) {
|
|
4439
4545
|
if (!t.nullable) throw Error("Value cannot be null for non-nullable type");
|
|
@@ -4441,9 +4547,9 @@ function Fm(e, t) {
|
|
|
4441
4547
|
}
|
|
4442
4548
|
return JSON.stringify(e);
|
|
4443
4549
|
}
|
|
4444
|
-
function
|
|
4550
|
+
function Zm(e, t) {
|
|
4445
4551
|
let r = (e.parameters ?? []).map((e) => {
|
|
4446
|
-
let t =
|
|
4552
|
+
let t = qm(e.type), n = Object.prototype.hasOwnProperty.call(e, "defaultValue"), r = n ? Xm(e.defaultValue, t) : "";
|
|
4447
4553
|
return {
|
|
4448
4554
|
name: e.name,
|
|
4449
4555
|
descriptor: t,
|
|
@@ -4451,7 +4557,7 @@ function Im(e, t) {
|
|
|
4451
4557
|
defaultValueJson: r,
|
|
4452
4558
|
description: e.description
|
|
4453
4559
|
};
|
|
4454
|
-
}), i =
|
|
4560
|
+
}), i = qm(e.returnType);
|
|
4455
4561
|
return {
|
|
4456
4562
|
definition: e,
|
|
4457
4563
|
handler: t,
|
|
@@ -4461,7 +4567,7 @@ function Im(e, t) {
|
|
|
4461
4567
|
Description: e.description ?? "",
|
|
4462
4568
|
LlmInlineResult: e.llmInlineResult ?? !1,
|
|
4463
4569
|
LlmCallOnlyOnce: e.llmCallOnlyOnce ?? !1,
|
|
4464
|
-
ResultTypeName:
|
|
4570
|
+
ResultTypeName: Jm(i),
|
|
4465
4571
|
IsEnumerable: !1,
|
|
4466
4572
|
EnumerableItemTypeName: "",
|
|
4467
4573
|
IsCancellable: !1,
|
|
@@ -4470,10 +4576,10 @@ function Im(e, t) {
|
|
|
4470
4576
|
Parameters: r.map((e, t) => ({
|
|
4471
4577
|
ParameterIndex: t,
|
|
4472
4578
|
ParameterName: e.name,
|
|
4473
|
-
TypeName:
|
|
4579
|
+
TypeName: Jm(e.descriptor),
|
|
4474
4580
|
HasDefaultValue: e.hasDefaultValue,
|
|
4475
4581
|
DefaultValueJson: e.defaultValueJson,
|
|
4476
|
-
DefaultValueData:
|
|
4582
|
+
DefaultValueData: Km,
|
|
4477
4583
|
IsEnumerable: !1,
|
|
4478
4584
|
EnumerableItemTypeName: "",
|
|
4479
4585
|
Description: e.description ?? ""
|
|
@@ -4485,24 +4591,24 @@ function Im(e, t) {
|
|
|
4485
4591
|
}
|
|
4486
4592
|
//#endregion
|
|
4487
4593
|
//#region src/functions/types.ts
|
|
4488
|
-
function
|
|
4594
|
+
function Qm(e, t) {
|
|
4489
4595
|
return {
|
|
4490
4596
|
value: e,
|
|
4491
4597
|
data: t
|
|
4492
4598
|
};
|
|
4493
4599
|
}
|
|
4494
|
-
var
|
|
4600
|
+
var $m = class extends Error {
|
|
4495
4601
|
remoteErrorType;
|
|
4496
4602
|
remoteStackTrace;
|
|
4497
4603
|
code;
|
|
4498
4604
|
constructor(e, t, n, r = "") {
|
|
4499
4605
|
super(e), this.remoteErrorType = t, this.remoteStackTrace = n, this.code = r, this.name = "FunctionCallError";
|
|
4500
4606
|
}
|
|
4501
|
-
},
|
|
4502
|
-
function
|
|
4607
|
+
}, eh = C("FunctionRegistry"), th = /* @__PURE__ */ new Uint8Array(), nh = 3e4;
|
|
4608
|
+
function rh(e) {
|
|
4503
4609
|
return !e || typeof e != "object" ? !1 : e.data instanceof Uint8Array;
|
|
4504
4610
|
}
|
|
4505
|
-
var
|
|
4611
|
+
var ih = class {
|
|
4506
4612
|
functions = /* @__PURE__ */ new Map();
|
|
4507
4613
|
remoteFunctions = /* @__PURE__ */ new Map();
|
|
4508
4614
|
pendingCalls = /* @__PURE__ */ new Map();
|
|
@@ -4524,7 +4630,7 @@ var Um = class {
|
|
|
4524
4630
|
};
|
|
4525
4631
|
}
|
|
4526
4632
|
register(e, t) {
|
|
4527
|
-
let n =
|
|
4633
|
+
let n = Zm(e, t);
|
|
4528
4634
|
return this.functions.set(e.name, n), this.isConnected && this.config && this.sendRegistration(n), () => this.unregister(e.name);
|
|
4529
4635
|
}
|
|
4530
4636
|
unregister(e) {
|
|
@@ -4565,7 +4671,7 @@ var Um = class {
|
|
|
4565
4671
|
ParameterIndex: t,
|
|
4566
4672
|
TypeName: n ? n.TypeName : this.inferTypeName(e),
|
|
4567
4673
|
ValueJson: JSON.stringify(e ?? null),
|
|
4568
|
-
ValueData:
|
|
4674
|
+
ValueData: th
|
|
4569
4675
|
});
|
|
4570
4676
|
}), c = r?.instanceId ? n.fromString(r.instanceId) : n.createZero(), l = rr(Xn({
|
|
4571
4677
|
FunctionId: n.fromString(i.id),
|
|
@@ -4578,8 +4684,8 @@ var Um = class {
|
|
|
4578
4684
|
}), this.config.sessionId, { targetIds: [i.clientSessionId] });
|
|
4579
4685
|
return new Promise((t, n) => {
|
|
4580
4686
|
let r = setTimeout(() => {
|
|
4581
|
-
this.pendingCalls.delete(o.toString()), n(/* @__PURE__ */ Error(`Function call '${e}' timed out after ${
|
|
4582
|
-
},
|
|
4687
|
+
this.pendingCalls.delete(o.toString()), n(/* @__PURE__ */ Error(`Function call '${e}' timed out after ${nh}ms`));
|
|
4688
|
+
}, nh);
|
|
4583
4689
|
this.pendingCalls.set(o.toString(), {
|
|
4584
4690
|
resolve: t,
|
|
4585
4691
|
reject: n,
|
|
@@ -4643,19 +4749,19 @@ var Um = class {
|
|
|
4643
4749
|
for (let [t, n] of this.remoteFunctions.entries()) e.has(n.id) || this.remoteFunctions.delete(t);
|
|
4644
4750
|
}
|
|
4645
4751
|
handleProtocolMessage(e, t) {
|
|
4646
|
-
if (t ===
|
|
4752
|
+
if (t === w.ACTION_FUNCTION_CALL) {
|
|
4647
4753
|
let t = i(e);
|
|
4648
4754
|
return this.handleFunctionCall(e, t.senderId).catch((e) => {
|
|
4649
|
-
|
|
4755
|
+
eh.error("Failed to handle function call:", e);
|
|
4650
4756
|
}), !0;
|
|
4651
4757
|
}
|
|
4652
|
-
if (t ===
|
|
4653
|
-
if (t ===
|
|
4654
|
-
if (t ===
|
|
4758
|
+
if (t === w.ACTION_FUNCTION_RESULT) return this.handleFunctionResult(e), !0;
|
|
4759
|
+
if (t === w.ACTION_FUNCTION_ERROR) return this.handleFunctionError(e), !0;
|
|
4760
|
+
if (t === w.ACTION_FUNCTION_REGISTER) {
|
|
4655
4761
|
let t = i(e);
|
|
4656
4762
|
return t.senderId !== this.config?.sessionId && this.registerRemoteFunction(pi(e), t.senderId), !0;
|
|
4657
4763
|
}
|
|
4658
|
-
if (t ===
|
|
4764
|
+
if (t === w.ACTION_FUNCTION_REGISTER_BATCH) {
|
|
4659
4765
|
let t = i(e);
|
|
4660
4766
|
if (t.senderId !== this.config?.sessionId) {
|
|
4661
4767
|
let n = Bi(e);
|
|
@@ -4668,7 +4774,7 @@ var Um = class {
|
|
|
4668
4774
|
handleFunctionResult(e) {
|
|
4669
4775
|
let t = ra(e), n = t.CallId.toString(), r = this.pendingCalls.get(n);
|
|
4670
4776
|
if (!r) {
|
|
4671
|
-
|
|
4777
|
+
eh.warn(`Received result for unknown call: ${n}`);
|
|
4672
4778
|
return;
|
|
4673
4779
|
}
|
|
4674
4780
|
if (this.pendingCalls.delete(n), clearTimeout(r.timeout), t.ResultData && t.ResultData.length > 0 && !t.ResultJson) {
|
|
@@ -4681,11 +4787,11 @@ var Um = class {
|
|
|
4681
4787
|
handleFunctionError(e) {
|
|
4682
4788
|
let t = Gr(e), n = t.CallId.toString(), r = this.pendingCalls.get(n);
|
|
4683
4789
|
if (!r) {
|
|
4684
|
-
|
|
4790
|
+
eh.warn(`Received error for unknown call: ${n}`);
|
|
4685
4791
|
return;
|
|
4686
4792
|
}
|
|
4687
4793
|
this.pendingCalls.delete(n), clearTimeout(r.timeout);
|
|
4688
|
-
let i = new
|
|
4794
|
+
let i = new $m(t.ErrorMessage, t.ErrorTypeName, t.StackTrace, t.ErrorCode), a = {
|
|
4689
4795
|
functionName: r.functionName,
|
|
4690
4796
|
args: r.args
|
|
4691
4797
|
};
|
|
@@ -4721,7 +4827,7 @@ var Um = class {
|
|
|
4721
4827
|
async handleFunctionCall(e, t) {
|
|
4722
4828
|
let n = await ir(e), r = this.functions.get(n.FunctionName);
|
|
4723
4829
|
if (!r) {
|
|
4724
|
-
|
|
4830
|
+
eh.warn(`Received call for unknown function: ${n.FunctionName}`), this.sendError(n.CallId, n.InstanceId, t, /* @__PURE__ */ Error(`Unknown function: ${n.FunctionName}`));
|
|
4725
4831
|
return;
|
|
4726
4832
|
}
|
|
4727
4833
|
this.sendAck(n.CallId, n.InstanceId, t), this.executeFunction(r, n, t);
|
|
@@ -4736,14 +4842,14 @@ var Um = class {
|
|
|
4736
4842
|
continue;
|
|
4737
4843
|
}
|
|
4738
4844
|
let o = a?.ValueJson;
|
|
4739
|
-
o === void 0 || o === "" ? i.hasDefaultValue ? r.push(
|
|
4845
|
+
o === void 0 || o === "" ? i.hasDefaultValue ? r.push(Ym(i.defaultValueJson, i.descriptor)) : r.push(void 0) : r.push(Ym(o, i.descriptor));
|
|
4740
4846
|
}
|
|
4741
|
-
let i = await e.handler(...r), a = i, o =
|
|
4742
|
-
|
|
4743
|
-
let s =
|
|
4847
|
+
let i = await e.handler(...r), a = i, o = th;
|
|
4848
|
+
rh(i) && (a = i.value, o = new Uint8Array(i.data));
|
|
4849
|
+
let s = Xm(a, e.returnType);
|
|
4744
4850
|
this.sendResult(t.CallId, t.InstanceId, n, e, s, o);
|
|
4745
4851
|
} catch (e) {
|
|
4746
|
-
|
|
4852
|
+
eh.error(`Function ${t.FunctionName} execution failed:`, e), this.sendError(t.CallId, t.InstanceId, n, e instanceof Error ? e : Error(String(e)));
|
|
4747
4853
|
}
|
|
4748
4854
|
}
|
|
4749
4855
|
sendAck(e, t, n) {
|
|
@@ -4759,7 +4865,7 @@ var Um = class {
|
|
|
4759
4865
|
let o = na(Yi({
|
|
4760
4866
|
CallId: e,
|
|
4761
4867
|
InstanceId: t,
|
|
4762
|
-
ResultTypeName:
|
|
4868
|
+
ResultTypeName: Jm(r.returnType),
|
|
4763
4869
|
ResultJson: i,
|
|
4764
4870
|
ResultData: a
|
|
4765
4871
|
}), this.config.sessionId, { targetIds: [n] });
|
|
@@ -4776,7 +4882,7 @@ var Um = class {
|
|
|
4776
4882
|
}), this.config.sessionId, { targetIds: [n] });
|
|
4777
4883
|
this.config.sendProtocolMessage(i);
|
|
4778
4884
|
}
|
|
4779
|
-
},
|
|
4885
|
+
}, ah = C("ReactiveRegistry"), oh = "Ikon.Reactive.Subscribe", sh = "Ikon.Reactive.Unsubscribe", ch = {
|
|
4780
4886
|
name: "Ikon.Reactive.Update",
|
|
4781
4887
|
description: "Receives reactive value updates pushed from the server when a subscribed reactive changes",
|
|
4782
4888
|
returnType: { kind: "string" },
|
|
@@ -4794,7 +4900,7 @@ var Um = class {
|
|
|
4794
4900
|
type: { kind: "string" }
|
|
4795
4901
|
}
|
|
4796
4902
|
]
|
|
4797
|
-
},
|
|
4903
|
+
}, lh = class {
|
|
4798
4904
|
subscribersByKey = /* @__PURE__ */ new Map();
|
|
4799
4905
|
functionRegistry;
|
|
4800
4906
|
updateHandlerUnregister = null;
|
|
@@ -4802,9 +4908,9 @@ var Um = class {
|
|
|
4802
4908
|
this.functionRegistry = e, this.registerUpdateHandler();
|
|
4803
4909
|
}
|
|
4804
4910
|
async subscribe(e, t, n) {
|
|
4805
|
-
let r = n?.mount ?? "", i =
|
|
4911
|
+
let r = n?.mount ?? "", i = uh(e, r), a = t, o = this.subscribersByKey.get(i), s = !o;
|
|
4806
4912
|
if (o || (o = /* @__PURE__ */ new Set(), this.subscribersByKey.set(i, o)), o.add(a), s) try {
|
|
4807
|
-
t(
|
|
4913
|
+
t(dh(await this.functionRegistry.call(oh, [e, r])));
|
|
4808
4914
|
} catch (e) {
|
|
4809
4915
|
throw o.delete(a), o.size === 0 && this.subscribersByKey.delete(i), e;
|
|
4810
4916
|
}
|
|
@@ -4816,46 +4922,46 @@ var Um = class {
|
|
|
4816
4922
|
this.subscribersByKey.clear(), this.updateHandlerUnregister &&= (this.updateHandlerUnregister(), null);
|
|
4817
4923
|
}
|
|
4818
4924
|
unsubscribeOne(e, t, n) {
|
|
4819
|
-
let r =
|
|
4820
|
-
i && (i.delete(n), !(i.size > 0) && (this.subscribersByKey.delete(r), this.functionRegistry.call(
|
|
4821
|
-
|
|
4925
|
+
let r = uh(e, t), i = this.subscribersByKey.get(r);
|
|
4926
|
+
i && (i.delete(n), !(i.size > 0) && (this.subscribersByKey.delete(r), this.functionRegistry.call(sh, [e, t]).catch((n) => {
|
|
4927
|
+
ah.warn(`Failed to unsubscribe from '${e}' (mount='${t}'):`, n);
|
|
4822
4928
|
})));
|
|
4823
4929
|
}
|
|
4824
4930
|
registerUpdateHandler() {
|
|
4825
4931
|
let e = (...e) => {
|
|
4826
|
-
let t = e[0], n = e[1] ?? "", r = e[2], i =
|
|
4932
|
+
let t = e[0], n = e[1] ?? "", r = e[2], i = uh(t, n), a = this.subscribersByKey.get(i);
|
|
4827
4933
|
if (!a || a.size === 0) return "";
|
|
4828
|
-
let o =
|
|
4934
|
+
let o = dh(r);
|
|
4829
4935
|
for (let e of a) try {
|
|
4830
4936
|
e(o);
|
|
4831
4937
|
} catch (e) {
|
|
4832
|
-
|
|
4938
|
+
ah.warn(`Reactive update callback for '${t}' (mount='${n}') threw:`, e);
|
|
4833
4939
|
}
|
|
4834
4940
|
return "";
|
|
4835
4941
|
};
|
|
4836
|
-
this.updateHandlerUnregister = this.functionRegistry.register(
|
|
4942
|
+
this.updateHandlerUnregister = this.functionRegistry.register(ch, e);
|
|
4837
4943
|
}
|
|
4838
4944
|
};
|
|
4839
|
-
function
|
|
4945
|
+
function uh(e, t) {
|
|
4840
4946
|
return t.length === 0 ? e : `${e}\0${t}`;
|
|
4841
4947
|
}
|
|
4842
|
-
function
|
|
4948
|
+
function dh(e) {
|
|
4843
4949
|
if (e == null || e === "") return null;
|
|
4844
4950
|
try {
|
|
4845
4951
|
return JSON.parse(e);
|
|
4846
4952
|
} catch (t) {
|
|
4847
|
-
return
|
|
4953
|
+
return ah.warn("Failed to parse reactive value JSON, returning raw string:", t), e;
|
|
4848
4954
|
}
|
|
4849
4955
|
}
|
|
4850
4956
|
//#endregion
|
|
4851
4957
|
//#region src/login/login-error-interceptor.ts
|
|
4852
|
-
var
|
|
4958
|
+
var fh = "login_required", ph = (e, t) => e.code === fh ? (fd({
|
|
4853
4959
|
functionName: t.functionName,
|
|
4854
4960
|
args: t.args
|
|
4855
4961
|
}), ld(e.message), null) : null;
|
|
4856
4962
|
//#endregion
|
|
4857
4963
|
//#region src/media/device-detection.ts
|
|
4858
|
-
function
|
|
4964
|
+
function mh() {
|
|
4859
4965
|
if (typeof navigator > "u") return !1;
|
|
4860
4966
|
let e = navigator.userAgentData;
|
|
4861
4967
|
if (typeof e?.mobile == "boolean") return e.mobile;
|
|
@@ -4864,7 +4970,7 @@ function $m() {
|
|
|
4864
4970
|
}
|
|
4865
4971
|
//#endregion
|
|
4866
4972
|
//#region src/functions/media-capture-functions.ts
|
|
4867
|
-
function
|
|
4973
|
+
function hh(e) {
|
|
4868
4974
|
let t = e?.facingMode;
|
|
4869
4975
|
if (typeof t == "string") return t === "user" || t === "environment" ? t : void 0;
|
|
4870
4976
|
if (Array.isArray(t)) return t.find((e) => typeof e == "string" && (e === "user" || e === "environment")) ?? void 0;
|
|
@@ -4874,21 +4980,21 @@ function eh(e) {
|
|
|
4874
4980
|
if (Array.isArray(e)) return e.find((e) => e === "user" || e === "environment") ?? void 0;
|
|
4875
4981
|
}
|
|
4876
4982
|
}
|
|
4877
|
-
function
|
|
4983
|
+
function gh(e) {
|
|
4878
4984
|
if (!(typeof e != "string" || !e.trim())) try {
|
|
4879
4985
|
return JSON.parse(e);
|
|
4880
4986
|
} catch {
|
|
4881
4987
|
return;
|
|
4882
4988
|
}
|
|
4883
4989
|
}
|
|
4884
|
-
var
|
|
4990
|
+
var _h = {
|
|
4885
4991
|
StartVideoCapture: "ikon.client.startVideoCapture",
|
|
4886
4992
|
StartAudioCapture: "ikon.client.startAudioCapture",
|
|
4887
4993
|
StopCapture: "ikon.client.stopCapture",
|
|
4888
4994
|
CaptureImage: "ikon.client.captureImage",
|
|
4889
4995
|
GetMediaDevices: "ikon.client.getMediaDevices"
|
|
4890
|
-
},
|
|
4891
|
-
name:
|
|
4996
|
+
}, vh = {
|
|
4997
|
+
name: _h.StartVideoCapture,
|
|
4892
4998
|
description: "Start camera or screen capture and stream video frames to the server",
|
|
4893
4999
|
returnType: { kind: "string" },
|
|
4894
5000
|
parameters: [{
|
|
@@ -4906,8 +5012,8 @@ var nh = {
|
|
|
4906
5012
|
},
|
|
4907
5013
|
description: "JSON encoded capture options"
|
|
4908
5014
|
}]
|
|
4909
|
-
},
|
|
4910
|
-
name:
|
|
5015
|
+
}, yh = {
|
|
5016
|
+
name: _h.StartAudioCapture,
|
|
4911
5017
|
description: "Start microphone capture and stream audio frames to the server",
|
|
4912
5018
|
returnType: { kind: "string" },
|
|
4913
5019
|
parameters: [{
|
|
@@ -4918,8 +5024,8 @@ var nh = {
|
|
|
4918
5024
|
},
|
|
4919
5025
|
description: "JSON encoded capture options"
|
|
4920
5026
|
}]
|
|
4921
|
-
},
|
|
4922
|
-
name:
|
|
5027
|
+
}, bh = {
|
|
5028
|
+
name: _h.StopCapture,
|
|
4923
5029
|
description: "Stop a previously started capture by streamId",
|
|
4924
5030
|
returnType: { kind: "boolean" },
|
|
4925
5031
|
parameters: [{
|
|
@@ -4927,8 +5033,8 @@ var nh = {
|
|
|
4927
5033
|
type: { kind: "string" },
|
|
4928
5034
|
description: "Stream ID to stop"
|
|
4929
5035
|
}]
|
|
4930
|
-
},
|
|
4931
|
-
name:
|
|
5036
|
+
}, xh = {
|
|
5037
|
+
name: _h.CaptureImage,
|
|
4932
5038
|
description: "Capture a single image from the camera and return metadata (JSON) plus binary image data",
|
|
4933
5039
|
returnType: { kind: "string" },
|
|
4934
5040
|
parameters: [{
|
|
@@ -4939,24 +5045,24 @@ var nh = {
|
|
|
4939
5045
|
},
|
|
4940
5046
|
description: "JSON encoded capture options"
|
|
4941
5047
|
}]
|
|
4942
|
-
},
|
|
4943
|
-
name:
|
|
5048
|
+
}, Sh = {
|
|
5049
|
+
name: _h.GetMediaDevices,
|
|
4944
5050
|
description: "Get list of available media input devices",
|
|
4945
5051
|
returnType: { kind: "string" },
|
|
4946
5052
|
parameters: []
|
|
4947
5053
|
};
|
|
4948
|
-
function
|
|
5054
|
+
function Ch(e, t) {
|
|
4949
5055
|
let n = [];
|
|
4950
|
-
return n.push(e.register(
|
|
5056
|
+
return n.push(e.register(vh, async (e, n) => {
|
|
4951
5057
|
if (t.isWebRtcCaptureAvailable) {
|
|
4952
5058
|
let e = t.webRtcSignaling;
|
|
4953
5059
|
if (!e) throw Error("WebRTC signaling is not connected");
|
|
4954
|
-
let r =
|
|
5060
|
+
let r = gh(n);
|
|
4955
5061
|
return await e.startVideoCapture(r?.constraints), "webrtc-video";
|
|
4956
5062
|
}
|
|
4957
5063
|
let r = await t.ensureMediaCapture();
|
|
4958
5064
|
if (!r) throw Error("Media capture is not available in this environment");
|
|
4959
|
-
let i =
|
|
5065
|
+
let i = gh(n);
|
|
4960
5066
|
return ((typeof e == "string" && e.trim().toLowerCase() === "screen" ? "screen" : "camera") == "screen" ? await r.video.startScreen({
|
|
4961
5067
|
userGesture: !1,
|
|
4962
5068
|
options: i,
|
|
@@ -4966,22 +5072,22 @@ function ch(e, t) {
|
|
|
4966
5072
|
options: i,
|
|
4967
5073
|
constraints: i?.constraints
|
|
4968
5074
|
})).streamId;
|
|
4969
|
-
})), n.push(e.register(
|
|
5075
|
+
})), n.push(e.register(yh, async (e) => {
|
|
4970
5076
|
if (t.isWebRtcCaptureAvailable) {
|
|
4971
5077
|
let n = t.webRtcSignaling;
|
|
4972
5078
|
if (!n) throw Error("WebRTC signaling is not connected");
|
|
4973
|
-
let r =
|
|
5079
|
+
let r = gh(e);
|
|
4974
5080
|
return await n.startAudioCapture(r?.constraints), "webrtc-audio";
|
|
4975
5081
|
}
|
|
4976
5082
|
let n = await t.ensureMediaCapture();
|
|
4977
5083
|
if (!n) throw Error("Media capture is not available in this environment");
|
|
4978
|
-
let r =
|
|
5084
|
+
let r = gh(e);
|
|
4979
5085
|
return (await n.audio.startMic({
|
|
4980
5086
|
userGesture: !1,
|
|
4981
5087
|
options: r,
|
|
4982
5088
|
constraints: r?.constraints
|
|
4983
5089
|
})).streamId;
|
|
4984
|
-
})), n.push(e.register(
|
|
5090
|
+
})), n.push(e.register(bh, async (e) => {
|
|
4985
5091
|
if (t.isWebRtcCaptureAvailable) {
|
|
4986
5092
|
let e = t.webRtcSignaling;
|
|
4987
5093
|
return e && await e.stopCapture(), !0;
|
|
@@ -4990,20 +5096,20 @@ function ch(e, t) {
|
|
|
4990
5096
|
if (!n || typeof e != "string" || !e.trim()) return !1;
|
|
4991
5097
|
let r = await n.video.stop(e), i = await n.audio.stop(e);
|
|
4992
5098
|
return r || i;
|
|
4993
|
-
})), n.push(e.register(
|
|
5099
|
+
})), n.push(e.register(xh, async (e) => {
|
|
4994
5100
|
let n = await t.ensureMediaCapture();
|
|
4995
5101
|
if (!n) throw Error("Media capture is not available in this environment");
|
|
4996
|
-
let r =
|
|
4997
|
-
if (r.mode === "native" &&
|
|
5102
|
+
let r = gh(e) ?? {};
|
|
5103
|
+
if (r.mode === "native" && mh()) {
|
|
4998
5104
|
let e = await n.image.captureFromNativeCamera({
|
|
4999
|
-
facing:
|
|
5105
|
+
facing: hh(r.constraints),
|
|
5000
5106
|
mime: r.mime,
|
|
5001
5107
|
quality: r.quality,
|
|
5002
5108
|
width: r.width,
|
|
5003
5109
|
height: r.height
|
|
5004
5110
|
});
|
|
5005
5111
|
if (!e) throw Error("Native camera capture was cancelled");
|
|
5006
|
-
return
|
|
5112
|
+
return Qm(JSON.stringify({
|
|
5007
5113
|
mime: e.mime,
|
|
5008
5114
|
width: e.width,
|
|
5009
5115
|
height: e.height
|
|
@@ -5024,12 +5130,12 @@ function ch(e, t) {
|
|
|
5024
5130
|
quality: r.quality,
|
|
5025
5131
|
width: r.width,
|
|
5026
5132
|
height: r.height
|
|
5027
|
-
}),
|
|
5133
|
+
}), Qm(JSON.stringify({
|
|
5028
5134
|
mime: a.mime,
|
|
5029
5135
|
width: a.width,
|
|
5030
5136
|
height: a.height
|
|
5031
5137
|
}), a.data);
|
|
5032
|
-
})), n.push(e.register(
|
|
5138
|
+
})), n.push(e.register(Sh, async () => {
|
|
5033
5139
|
if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) return JSON.stringify([]);
|
|
5034
5140
|
let e = (await navigator.mediaDevices.enumerateDevices()).filter((e) => e.kind === "audioinput" || e.kind === "videoinput").map((e) => ({
|
|
5035
5141
|
deviceId: e.deviceId,
|
|
@@ -5044,45 +5150,45 @@ function ch(e, t) {
|
|
|
5044
5150
|
}
|
|
5045
5151
|
//#endregion
|
|
5046
5152
|
//#region src/functions/sound-functions.ts
|
|
5047
|
-
var
|
|
5153
|
+
var wh = {
|
|
5048
5154
|
PlaySound: "ikon.client.playSound",
|
|
5049
5155
|
StopSound: "ikon.client.stopSound"
|
|
5050
|
-
},
|
|
5051
|
-
function
|
|
5052
|
-
if (!(
|
|
5156
|
+
}, Th = /* @__PURE__ */ new Map(), K = /* @__PURE__ */ new Map(), Eh = 1, Dh = "data:audio/wav;base64,UklGRjIAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQYAAAAAAAAAAAA=", Oh = 8, kh = [], Ah = !1, q = null;
|
|
5157
|
+
function jh() {
|
|
5158
|
+
if (!(kh.length > 0 || typeof Audio > "u")) for (let e = 0; e < Oh; e++) {
|
|
5053
5159
|
let e = new Audio();
|
|
5054
|
-
e.preload = "auto",
|
|
5160
|
+
e.preload = "auto", kh.push(e);
|
|
5055
5161
|
}
|
|
5056
5162
|
}
|
|
5057
|
-
function
|
|
5058
|
-
if (!
|
|
5059
|
-
|
|
5060
|
-
for (let e of
|
|
5061
|
-
e.src =
|
|
5163
|
+
function Mh() {
|
|
5164
|
+
if (!Ah) {
|
|
5165
|
+
jh();
|
|
5166
|
+
for (let e of kh) try {
|
|
5167
|
+
e.src = Dh;
|
|
5062
5168
|
let t = e.play();
|
|
5063
5169
|
typeof t?.then == "function" ? t.then(() => {
|
|
5064
|
-
e.pause(), e.currentTime = 0,
|
|
5065
|
-
}, () => {}) :
|
|
5170
|
+
e.pause(), e.currentTime = 0, Ah = !0, Ph();
|
|
5171
|
+
}, () => {}) : Ah = !0;
|
|
5066
5172
|
} catch {}
|
|
5067
|
-
|
|
5173
|
+
Ah && Ph();
|
|
5068
5174
|
}
|
|
5069
5175
|
}
|
|
5070
|
-
function
|
|
5176
|
+
function Nh() {
|
|
5071
5177
|
if (q || typeof window > "u") return;
|
|
5072
|
-
let e = () =>
|
|
5178
|
+
let e = () => Mh();
|
|
5073
5179
|
q = e, window.addEventListener("pointerdown", e, { capture: !0 }), window.addEventListener("touchend", e, { capture: !0 }), window.addEventListener("mousedown", e, { capture: !0 }), window.addEventListener("keydown", e, { capture: !0 });
|
|
5074
5180
|
}
|
|
5075
|
-
function
|
|
5181
|
+
function Ph() {
|
|
5076
5182
|
!q || typeof window > "u" || (window.removeEventListener("pointerdown", q, { capture: !0 }), window.removeEventListener("touchend", q, { capture: !0 }), window.removeEventListener("mousedown", q, { capture: !0 }), window.removeEventListener("keydown", q, { capture: !0 }), q = null);
|
|
5077
5183
|
}
|
|
5078
|
-
function
|
|
5079
|
-
|
|
5080
|
-
for (let e of
|
|
5184
|
+
function Fh() {
|
|
5185
|
+
jh();
|
|
5186
|
+
for (let e of kh) if (e.paused || e.ended) return e;
|
|
5081
5187
|
let e = new Audio();
|
|
5082
|
-
return e.preload = "auto",
|
|
5188
|
+
return e.preload = "auto", kh.push(e), e;
|
|
5083
5189
|
}
|
|
5084
|
-
var
|
|
5085
|
-
name:
|
|
5190
|
+
var Ih = {
|
|
5191
|
+
name: wh.PlaySound,
|
|
5086
5192
|
description: "Play a sound effect",
|
|
5087
5193
|
returnType: {
|
|
5088
5194
|
kind: "string",
|
|
@@ -5120,22 +5226,22 @@ var Sh = {
|
|
|
5120
5226
|
}
|
|
5121
5227
|
]
|
|
5122
5228
|
};
|
|
5123
|
-
function
|
|
5229
|
+
function Lh(e, t, n, r) {
|
|
5124
5230
|
if (typeof window > "u" || typeof Audio > "u" || typeof e != "string" || !e.trim()) return Promise.resolve(null);
|
|
5125
5231
|
let i = e;
|
|
5126
|
-
if (typeof t == "string" && t &&
|
|
5127
|
-
let t = e.slice(6), n =
|
|
5232
|
+
if (typeof t == "string" && t && Th.set(t, e), e.startsWith("sound:")) {
|
|
5233
|
+
let t = e.slice(6), n = Th.get(t);
|
|
5128
5234
|
if (!n) return Promise.resolve(null);
|
|
5129
5235
|
i = n;
|
|
5130
5236
|
}
|
|
5131
5237
|
return new Promise((e) => {
|
|
5132
5238
|
try {
|
|
5133
|
-
let t =
|
|
5239
|
+
let t = Fh();
|
|
5134
5240
|
t.src = i, t.currentTime = 0, t.loop = r === !0, t.volume = typeof n == "number" ? Math.max(0, Math.min(1, n)) : 1;
|
|
5135
|
-
let a = `sound-${
|
|
5136
|
-
|
|
5241
|
+
let a = `sound-${Eh++}`, o = () => {
|
|
5242
|
+
K.delete(a), t.removeEventListener("ended", o), t.removeEventListener("error", o);
|
|
5137
5243
|
};
|
|
5138
|
-
t.addEventListener("ended", o), t.addEventListener("error", o),
|
|
5244
|
+
t.addEventListener("ended", o), t.addEventListener("error", o), K.set(a, t), t.play().then(() => e(a), () => {
|
|
5139
5245
|
o(), e(null);
|
|
5140
5246
|
});
|
|
5141
5247
|
} catch {
|
|
@@ -5143,8 +5249,8 @@ function Ch(e, t, n, r) {
|
|
|
5143
5249
|
}
|
|
5144
5250
|
});
|
|
5145
5251
|
}
|
|
5146
|
-
var
|
|
5147
|
-
name:
|
|
5252
|
+
var Rh = {
|
|
5253
|
+
name: wh.StopSound,
|
|
5148
5254
|
description: "Stop a playing sound by ID",
|
|
5149
5255
|
returnType: { kind: "boolean" },
|
|
5150
5256
|
parameters: [{
|
|
@@ -5153,51 +5259,51 @@ var wh = {
|
|
|
5153
5259
|
description: "Playback ID from playSound"
|
|
5154
5260
|
}]
|
|
5155
5261
|
};
|
|
5156
|
-
function
|
|
5262
|
+
function zh(e) {
|
|
5157
5263
|
if (typeof e != "string") return !1;
|
|
5158
|
-
let t =
|
|
5264
|
+
let t = K.get(e);
|
|
5159
5265
|
if (!t) return !1;
|
|
5160
5266
|
try {
|
|
5161
|
-
return t.pause(), t.currentTime = 0,
|
|
5267
|
+
return t.pause(), t.currentTime = 0, K.delete(e), !0;
|
|
5162
5268
|
} catch {
|
|
5163
5269
|
return !1;
|
|
5164
5270
|
}
|
|
5165
5271
|
}
|
|
5166
|
-
function
|
|
5167
|
-
|
|
5168
|
-
for (let [e, t] of
|
|
5272
|
+
function Bh() {
|
|
5273
|
+
Th.clear();
|
|
5274
|
+
for (let [e, t] of K) {
|
|
5169
5275
|
try {
|
|
5170
5276
|
t.pause(), t.currentTime = 0;
|
|
5171
5277
|
} catch {}
|
|
5172
|
-
|
|
5278
|
+
K.delete(e);
|
|
5173
5279
|
}
|
|
5174
|
-
|
|
5280
|
+
Ph();
|
|
5175
5281
|
}
|
|
5176
|
-
var
|
|
5177
|
-
definition:
|
|
5178
|
-
handler:
|
|
5282
|
+
var Vh = [{
|
|
5283
|
+
definition: Ih,
|
|
5284
|
+
handler: Lh
|
|
5179
5285
|
}, {
|
|
5180
|
-
definition:
|
|
5181
|
-
handler:
|
|
5286
|
+
definition: Rh,
|
|
5287
|
+
handler: zh
|
|
5182
5288
|
}];
|
|
5183
|
-
function
|
|
5184
|
-
|
|
5185
|
-
let t =
|
|
5289
|
+
function Hh(e) {
|
|
5290
|
+
Nh();
|
|
5291
|
+
let t = Vh.map(({ definition: t, handler: n }) => e.register(t, n));
|
|
5186
5292
|
return () => {
|
|
5187
|
-
t.forEach((e) => e()),
|
|
5293
|
+
t.forEach((e) => e()), Bh();
|
|
5188
5294
|
};
|
|
5189
5295
|
}
|
|
5190
5296
|
//#endregion
|
|
5191
5297
|
//#region src/worker/viseme-worker.ts?worker
|
|
5192
|
-
function
|
|
5193
|
-
return new Worker("" + new URL("assets/viseme-worker-
|
|
5298
|
+
function Uh(e) {
|
|
5299
|
+
return new Worker("" + new URL("assets/viseme-worker-TOrhAq2M.js", import.meta.url).href, {
|
|
5194
5300
|
type: "module",
|
|
5195
5301
|
name: e?.name
|
|
5196
5302
|
});
|
|
5197
5303
|
}
|
|
5198
5304
|
//#endregion
|
|
5199
5305
|
//#region src/media/viseme-tracker.ts
|
|
5200
|
-
var
|
|
5306
|
+
var Wh = C("VisemeTracker"), Gh = _e * 2, Kh = class e {
|
|
5201
5307
|
static MAX_WORKER_REBUILD_ATTEMPTS = 3;
|
|
5202
5308
|
client;
|
|
5203
5309
|
worker = null;
|
|
@@ -5217,16 +5323,16 @@ var Ah = S("VisemeTracker"), jh = _e * 2, Mh = class e {
|
|
|
5217
5323
|
enable() {
|
|
5218
5324
|
if (this.worker) return;
|
|
5219
5325
|
if (typeof Worker > "u") {
|
|
5220
|
-
|
|
5326
|
+
Wh.warn("Viseme worker unavailable (Workers not supported)");
|
|
5221
5327
|
return;
|
|
5222
5328
|
}
|
|
5223
|
-
let t = this.client.createProtocolMessagePort({ opcodeGroupsMask:
|
|
5329
|
+
let t = this.client.createProtocolMessagePort({ opcodeGroupsMask: w.GROUP_AUDIO });
|
|
5224
5330
|
if (!t) return;
|
|
5225
5331
|
this.protocolPort = t;
|
|
5226
5332
|
try {
|
|
5227
|
-
this.worker = new
|
|
5333
|
+
this.worker = new Uh();
|
|
5228
5334
|
} catch (e) {
|
|
5229
|
-
|
|
5335
|
+
Wh.warn(`Failed to create viseme worker: ${e}`), this.protocolPort.close(), this.protocolPort = null;
|
|
5230
5336
|
return;
|
|
5231
5337
|
}
|
|
5232
5338
|
let n = this.worker;
|
|
@@ -5237,7 +5343,7 @@ var Ah = S("VisemeTracker"), jh = _e * 2, Mh = class e {
|
|
|
5237
5343
|
t.lineno,
|
|
5238
5344
|
t.colno
|
|
5239
5345
|
].filter((e) => e != null && String(e).length > 0);
|
|
5240
|
-
|
|
5346
|
+
Wh.error(`Viseme worker failed: ${n.join(" ")}`.trim()), this.dispose(), this.workerRebuildAttempts < e.MAX_WORKER_REBUILD_ATTEMPTS ? (this.workerRebuildAttempts++, this.enable()) : Wh.error("Viseme worker crashed repeatedly, giving up on rebuilds");
|
|
5241
5347
|
}), n.postMessage({
|
|
5242
5348
|
type: "attachProtocolPort",
|
|
5243
5349
|
port: t.port
|
|
@@ -5292,9 +5398,9 @@ var Ah = S("VisemeTracker"), jh = _e * 2, Mh = class e {
|
|
|
5292
5398
|
if (!t.timingEstablished || t.count === 0) continue;
|
|
5293
5399
|
let n = e - t.playbackStartTime;
|
|
5294
5400
|
if (n < 0) continue;
|
|
5295
|
-
let r = n *
|
|
5401
|
+
let r = n * Gh, i = t.frames, a = t.count, o = (t.head - a + x) % x, s = null, c = null;
|
|
5296
5402
|
for (let e = 0; e < a; e++) {
|
|
5297
|
-
let t = i[(o + e) %
|
|
5403
|
+
let t = i[(o + e) % x], n = t.samplePosition + Math.max(t.frameSamples, 1);
|
|
5298
5404
|
if (t.samplePosition <= r && (s = t), n > r && !c && (c = t, t.samplePosition <= r)) break;
|
|
5299
5405
|
}
|
|
5300
5406
|
if (!s || r > s.samplePosition + Math.max(s.frameSamples, 1) && !c) continue;
|
|
@@ -5309,7 +5415,7 @@ var Ah = S("VisemeTracker"), jh = _e * 2, Mh = class e {
|
|
|
5309
5415
|
return null;
|
|
5310
5416
|
}
|
|
5311
5417
|
setVisemeDelayMs(e) {
|
|
5312
|
-
this.visemeDelayMs = Math.min(200, Math.max(
|
|
5418
|
+
this.visemeDelayMs = Math.min(200, Math.max(we, e));
|
|
5313
5419
|
}
|
|
5314
5420
|
getVisemeDelayMs() {
|
|
5315
5421
|
return this.visemeDelayMs;
|
|
@@ -5318,8 +5424,8 @@ var Ah = S("VisemeTracker"), jh = _e * 2, Mh = class e {
|
|
|
5318
5424
|
if (e.type === "streamBegin") {
|
|
5319
5425
|
if (this.streamShapeSets.has(e.streamId)) return;
|
|
5320
5426
|
if (e.shapeSets && e.shapeSets.length > 0 && (this.streamShapeSets.set(e.streamId, e.shapeSets), this.currentShapeSetValues.set(e.streamId, /* @__PURE__ */ new Map()), e.shapeSets.some((e) => e.Name === "Viseme"))) {
|
|
5321
|
-
let t = Array(
|
|
5322
|
-
for (let e = 0; e <
|
|
5427
|
+
let t = Array(x);
|
|
5428
|
+
for (let e = 0; e < x; e++) t[e] = {
|
|
5323
5429
|
samplePosition: 0,
|
|
5324
5430
|
frameSamples: 0,
|
|
5325
5431
|
mouthOpenY: 0,
|
|
@@ -5357,44 +5463,44 @@ var Ah = S("VisemeTracker"), jh = _e * 2, Mh = class e {
|
|
|
5357
5463
|
if (!(!c || c.Values.length < 2)) {
|
|
5358
5464
|
if (o.currentEpoch !== t && (o.currentEpoch = t, o.timingEstablished = !1, o.count = 0, o.head = 0), !o.timingEstablished) {
|
|
5359
5465
|
o.epochTimestampSamples = n;
|
|
5360
|
-
let e = Math.min(200, Math.max(
|
|
5466
|
+
let e = Math.min(200, Math.max(we, this.visemeDelayMs));
|
|
5361
5467
|
o.playbackStartTime = performance.now() / 1e3 + e / 1e3, o.timingEstablished = !0;
|
|
5362
5468
|
}
|
|
5363
5469
|
if (r > 0) {
|
|
5364
5470
|
let e = o.frames[o.head];
|
|
5365
|
-
e.samplePosition = n - o.epochTimestampSamples, e.frameSamples = r, e.mouthOpenY = c.Values[0], e.mouthForm = c.Values[1], o.head = (o.head + 1) %
|
|
5471
|
+
e.samplePosition = n - o.epochTimestampSamples, e.frameSamples = r, e.mouthOpenY = c.Values[0], e.mouthForm = c.Values[1], o.head = (o.head + 1) % x, o.count < 1500 && o.count++;
|
|
5366
5472
|
}
|
|
5367
5473
|
}
|
|
5368
5474
|
}
|
|
5369
|
-
},
|
|
5370
|
-
function
|
|
5371
|
-
return J ? !0 : (J =
|
|
5475
|
+
}, qh = C("DebugMode"), J = !1;
|
|
5476
|
+
function Jh() {
|
|
5477
|
+
return J ? !0 : (J = au(), J && (ye(S.DEBUG), qh.info("Debug mode enabled")), J);
|
|
5372
5478
|
}
|
|
5373
|
-
function
|
|
5479
|
+
function Yh() {
|
|
5374
5480
|
return J;
|
|
5375
5481
|
}
|
|
5376
|
-
function
|
|
5377
|
-
J || (J = !0,
|
|
5482
|
+
function Xh() {
|
|
5483
|
+
J || (J = !0, ye(S.DEBUG), qh.info("Debug mode enabled"), tu(Vl, "true"));
|
|
5378
5484
|
}
|
|
5379
5485
|
//#endregion
|
|
5380
5486
|
//#region src/utils/inspect-mode.ts
|
|
5381
|
-
var
|
|
5382
|
-
function
|
|
5383
|
-
typeof window < "u" && window.dispatchEvent(new Event(
|
|
5487
|
+
var Zh = "ikon-inspect-mode-changed", Y = !1;
|
|
5488
|
+
function Qh() {
|
|
5489
|
+
typeof window < "u" && window.dispatchEvent(new Event(Zh));
|
|
5384
5490
|
}
|
|
5385
|
-
function
|
|
5386
|
-
let e =
|
|
5387
|
-
return e !== Y && (Y = e,
|
|
5491
|
+
function $h() {
|
|
5492
|
+
let e = fu();
|
|
5493
|
+
return e !== Y && (Y = e, Qh()), Y;
|
|
5388
5494
|
}
|
|
5389
|
-
function
|
|
5495
|
+
function eg() {
|
|
5390
5496
|
return Y;
|
|
5391
5497
|
}
|
|
5392
|
-
function
|
|
5393
|
-
Y || (Y = !0,
|
|
5498
|
+
function tg() {
|
|
5499
|
+
Y || (Y = !0, tu(Jl, "true"), Qh());
|
|
5394
5500
|
}
|
|
5395
5501
|
//#endregion
|
|
5396
5502
|
//#region src/utils/external-link.ts
|
|
5397
|
-
var
|
|
5503
|
+
var ng = /* @__PURE__ */ new Set([
|
|
5398
5504
|
"http",
|
|
5399
5505
|
"https",
|
|
5400
5506
|
"file",
|
|
@@ -5411,12 +5517,12 @@ var Hh = /* @__PURE__ */ new Set([
|
|
|
5411
5517
|
"edge",
|
|
5412
5518
|
"moz-extension",
|
|
5413
5519
|
"safari-web-extension"
|
|
5414
|
-
]),
|
|
5415
|
-
function
|
|
5416
|
-
let t =
|
|
5417
|
-
return t ? !
|
|
5520
|
+
]), rg = /^([a-z][a-z0-9+.-]*):/i;
|
|
5521
|
+
function ig(e) {
|
|
5522
|
+
let t = rg.exec(e.trim());
|
|
5523
|
+
return t ? !ng.has(t[1].toLowerCase()) : !1;
|
|
5418
5524
|
}
|
|
5419
|
-
function
|
|
5525
|
+
function ag(e) {
|
|
5420
5526
|
if (typeof document > "u") return;
|
|
5421
5527
|
let t = document.createElement("iframe");
|
|
5422
5528
|
t.setAttribute("aria-hidden", "true"), t.style.display = "none", document.body.appendChild(t);
|
|
@@ -5430,7 +5536,7 @@ function Gh(e) {
|
|
|
5430
5536
|
}
|
|
5431
5537
|
//#endregion
|
|
5432
5538
|
//#region src/utils/browser-support.ts
|
|
5433
|
-
var
|
|
5539
|
+
var og = [
|
|
5434
5540
|
{
|
|
5435
5541
|
name: "WebSocket",
|
|
5436
5542
|
isPresent: () => typeof WebSocket < "u"
|
|
@@ -5452,9 +5558,9 @@ var Kh = [
|
|
|
5452
5558
|
isPresent: () => typeof Promise < "u" && typeof Promise.allSettled == "function"
|
|
5453
5559
|
}
|
|
5454
5560
|
];
|
|
5455
|
-
function
|
|
5561
|
+
function sg() {
|
|
5456
5562
|
let e = [];
|
|
5457
|
-
for (let t of
|
|
5563
|
+
for (let t of og) {
|
|
5458
5564
|
let n;
|
|
5459
5565
|
try {
|
|
5460
5566
|
n = t.isPresent();
|
|
@@ -5470,22 +5576,22 @@ function qh() {
|
|
|
5470
5576
|
}
|
|
5471
5577
|
//#endregion
|
|
5472
5578
|
//#region src/transport/transport-probe.ts
|
|
5473
|
-
var
|
|
5474
|
-
async function
|
|
5475
|
-
let r = n?.timeoutMs ??
|
|
5579
|
+
var cg = C("TransportProbe"), lg = 3e3;
|
|
5580
|
+
async function ug(e, t, n) {
|
|
5581
|
+
let r = n?.timeoutMs ?? lg, i = n?.signal;
|
|
5476
5582
|
if (i?.aborted) return !1;
|
|
5477
5583
|
let a = Date.now();
|
|
5478
5584
|
try {
|
|
5479
|
-
let n =
|
|
5480
|
-
return
|
|
5585
|
+
let n = dg(e) ? await pg(t, r, i) : await fg(t, r, i);
|
|
5586
|
+
return cg.debug(`Probe ${b[e]} ${t}: ${n ? "reachable" : "unreachable"} in ${Date.now() - a}ms`), n;
|
|
5481
5587
|
} catch (n) {
|
|
5482
|
-
return
|
|
5588
|
+
return cg.debug(`Probe ${b[e]} ${t} failed after ${Date.now() - a}ms: ${n instanceof Error ? n.message : n}`), !1;
|
|
5483
5589
|
}
|
|
5484
5590
|
}
|
|
5485
|
-
function
|
|
5591
|
+
function dg(e) {
|
|
5486
5592
|
return e === b.WebTransport || e === b.WebTransportProxy;
|
|
5487
5593
|
}
|
|
5488
|
-
function
|
|
5594
|
+
function fg(e, t, n) {
|
|
5489
5595
|
return typeof WebSocket > "u" ? Promise.resolve(!1) : new Promise((r) => {
|
|
5490
5596
|
let i = new WebSocket(e), a = !1, o = (e) => {
|
|
5491
5597
|
if (!a) {
|
|
@@ -5499,7 +5605,7 @@ function Qh(e, t, n) {
|
|
|
5499
5605
|
n?.addEventListener("abort", s, { once: !0 }), i.onopen = () => o(!0), i.onerror = () => o(!1), i.onclose = () => o(!1);
|
|
5500
5606
|
});
|
|
5501
5607
|
}
|
|
5502
|
-
async function
|
|
5608
|
+
async function pg(e, t, n) {
|
|
5503
5609
|
if (!wu()) return !1;
|
|
5504
5610
|
let r = new WebTransport(e), i;
|
|
5505
5611
|
try {
|
|
@@ -5518,20 +5624,20 @@ async function $h(e, t, n) {
|
|
|
5518
5624
|
}
|
|
5519
5625
|
//#endregion
|
|
5520
5626
|
//#region src/worker/protocol-worker.ts?worker
|
|
5521
|
-
function
|
|
5522
|
-
return new Worker("" + new URL("assets/protocol-worker-
|
|
5627
|
+
function mg(e) {
|
|
5628
|
+
return new Worker("" + new URL("assets/protocol-worker-sC4mqNcM.js", import.meta.url).href, {
|
|
5523
5629
|
type: "module",
|
|
5524
5630
|
name: e?.name
|
|
5525
5631
|
});
|
|
5526
5632
|
}
|
|
5527
5633
|
//#endregion
|
|
5528
5634
|
//#region src/client/endpoint-selector.ts
|
|
5529
|
-
var
|
|
5635
|
+
var hg = {
|
|
5530
5636
|
[b.WebTransport]: 0,
|
|
5531
5637
|
[b.WebSocket]: 1,
|
|
5532
5638
|
[b.WebTransportProxy]: 2,
|
|
5533
5639
|
[b.WebSocketProxy]: 3
|
|
5534
|
-
},
|
|
5640
|
+
}, gg = /* @__PURE__ */ new Set([b.WebTransportProxy, b.WebSocketProxy]), _g = /* @__PURE__ */ new Set([b.WebTransport, b.WebSocket]), vg = /* @__PURE__ */ new Set([b.WebSocket, b.WebSocketProxy]), yg = /* @__PURE__ */ new Set([b.WebTransport, b.WebTransportProxy]), X = C("EndpointSelector"), bg = "ikon-endpoint-type", xg = "ikon-proxy-preferred", Sg = "ikon-endpoint-timestamp", Cg = "ikon-endpoint-revalidated", wg = 864e5, Tg = class {
|
|
5535
5641
|
isLocal;
|
|
5536
5642
|
_proxyMode;
|
|
5537
5643
|
_websocket;
|
|
@@ -5553,27 +5659,27 @@ var tg = {
|
|
|
5553
5659
|
markProxyPreferred() {
|
|
5554
5660
|
this._proxyPreferred = !0;
|
|
5555
5661
|
try {
|
|
5556
|
-
localStorage.setItem(
|
|
5662
|
+
localStorage.setItem(xg, "true"), localStorage.setItem(Sg, String(Date.now()));
|
|
5557
5663
|
} catch {}
|
|
5558
5664
|
X.debug("Marked proxy as preferred");
|
|
5559
5665
|
}
|
|
5560
5666
|
clearProxyPreference() {
|
|
5561
5667
|
this._proxyPreferred = !1;
|
|
5562
5668
|
try {
|
|
5563
|
-
localStorage.removeItem(
|
|
5669
|
+
localStorage.removeItem(xg);
|
|
5564
5670
|
} catch {}
|
|
5565
5671
|
}
|
|
5566
5672
|
getOrderedTypes(e) {
|
|
5567
5673
|
let t = Array.from(e.keys());
|
|
5568
5674
|
if (this.isLocal) return t;
|
|
5569
5675
|
let n;
|
|
5570
|
-
n = this._proxyMode === "force-proxy" ? t.filter((e) =>
|
|
5571
|
-
let r = [...n].sort((e, t) => (
|
|
5676
|
+
n = this._proxyMode === "force-proxy" ? t.filter((e) => gg.has(e)) : this._proxyMode === "force-direct" ? t.filter((e) => _g.has(e)) : t, n = this.filterByTransport(n);
|
|
5677
|
+
let r = [...n].sort((e, t) => (hg[e] ?? 999) - (hg[t] ?? 999));
|
|
5572
5678
|
if (this._proxyMode === "auto" && this._proxyPreferred) {
|
|
5573
|
-
let e = r.filter((e) =>
|
|
5679
|
+
let e = r.filter((e) => gg.has(e)), t = r.filter((e) => _g.has(e));
|
|
5574
5680
|
r.length = 0, r.push(...e, ...t);
|
|
5575
5681
|
}
|
|
5576
|
-
if (this.workingEndpointType !== null && e.has(this.workingEndpointType) && (!this._proxyPreferred ||
|
|
5682
|
+
if (this.workingEndpointType !== null && e.has(this.workingEndpointType) && (!this._proxyPreferred || gg.has(this.workingEndpointType))) {
|
|
5577
5683
|
let e = r.indexOf(this.workingEndpointType);
|
|
5578
5684
|
e > 0 && (r.splice(e, 1), r.unshift(this.workingEndpointType));
|
|
5579
5685
|
}
|
|
@@ -5587,17 +5693,17 @@ var tg = {
|
|
|
5587
5693
|
}
|
|
5588
5694
|
this.workingEndpointType = e;
|
|
5589
5695
|
try {
|
|
5590
|
-
localStorage.setItem(
|
|
5696
|
+
localStorage.setItem(bg, String(e)), localStorage.setItem(Sg, String(Date.now())), localStorage.getItem(Cg) === null && localStorage.setItem(Cg, String(Date.now()));
|
|
5591
5697
|
} catch {}
|
|
5592
|
-
if (
|
|
5698
|
+
if (gg.has(e)) {
|
|
5593
5699
|
this._proxyPreferred = !0;
|
|
5594
5700
|
try {
|
|
5595
|
-
localStorage.setItem(
|
|
5701
|
+
localStorage.setItem(xg, "true");
|
|
5596
5702
|
} catch {}
|
|
5597
|
-
} else if (
|
|
5703
|
+
} else if (_g.has(e)) {
|
|
5598
5704
|
this._proxyPreferred = !1;
|
|
5599
5705
|
try {
|
|
5600
|
-
localStorage.removeItem(
|
|
5706
|
+
localStorage.removeItem(xg);
|
|
5601
5707
|
} catch {}
|
|
5602
5708
|
}
|
|
5603
5709
|
X.debug(`Remembered working type: ${b[e]}`);
|
|
@@ -5606,37 +5712,37 @@ var tg = {
|
|
|
5606
5712
|
clearRememberedType() {
|
|
5607
5713
|
this.workingEndpointType = null;
|
|
5608
5714
|
try {
|
|
5609
|
-
localStorage.removeItem(
|
|
5715
|
+
localStorage.removeItem(bg);
|
|
5610
5716
|
} catch {}
|
|
5611
5717
|
}
|
|
5612
5718
|
needsRevalidation() {
|
|
5613
5719
|
if (this.isLocal || this._proxyMode !== "auto" || this.workingEndpointType === null && !this._proxyPreferred) return !1;
|
|
5614
5720
|
let e = this.revalidationAgeMs();
|
|
5615
|
-
return e !== null && e >
|
|
5721
|
+
return e !== null && e > wg;
|
|
5616
5722
|
}
|
|
5617
5723
|
getFasterTypes(e, t) {
|
|
5618
|
-
let n =
|
|
5619
|
-
return this.filterByTransport(Array.from(t.keys())).filter((e) => (
|
|
5724
|
+
let n = hg[e] ?? 999;
|
|
5725
|
+
return this.filterByTransport(Array.from(t.keys())).filter((e) => (hg[e] ?? 999) < n).sort((e, t) => (hg[e] ?? 999) - (hg[t] ?? 999));
|
|
5620
5726
|
}
|
|
5621
5727
|
recordFasterTypeReachable(e) {
|
|
5622
5728
|
X.debug(`Faster endpoint type ${b[e]} is reachable again, dropping learned preference`), this.clearRememberedType(), this.clearProxyPreference();
|
|
5623
5729
|
try {
|
|
5624
|
-
localStorage.removeItem(
|
|
5730
|
+
localStorage.removeItem(Sg), localStorage.removeItem(Cg);
|
|
5625
5731
|
} catch {}
|
|
5626
5732
|
}
|
|
5627
5733
|
recordFasterTypesUnreachable() {
|
|
5628
5734
|
try {
|
|
5629
|
-
localStorage.setItem(
|
|
5735
|
+
localStorage.setItem(Cg, String(Date.now()));
|
|
5630
5736
|
} catch {}
|
|
5631
5737
|
X.debug("Faster endpoint types still unreachable, keeping the learned preference");
|
|
5632
5738
|
}
|
|
5633
5739
|
filterByTransport(e) {
|
|
5634
5740
|
let t = this._websocket, n = this._webtransport;
|
|
5635
|
-
return t === void 0 && n === void 0 || t === !0 && n === !0 ? e : e.filter((e) => t === !0 && n === void 0 ?
|
|
5741
|
+
return t === void 0 && n === void 0 || t === !0 && n === !0 ? e : e.filter((e) => t === !0 && n === void 0 ? vg.has(e) : n === !0 && t === void 0 ? yg.has(e) : t === !1 ? !vg.has(e) : n !== !1 || !yg.has(e));
|
|
5636
5742
|
}
|
|
5637
5743
|
revalidationAgeMs() {
|
|
5638
5744
|
try {
|
|
5639
|
-
let e = localStorage.getItem(
|
|
5745
|
+
let e = localStorage.getItem(Cg);
|
|
5640
5746
|
if (e === null) return null;
|
|
5641
5747
|
let t = Date.now() - Number(e);
|
|
5642
5748
|
return Number.isFinite(t) ? t : null;
|
|
@@ -5646,12 +5752,12 @@ var tg = {
|
|
|
5646
5752
|
}
|
|
5647
5753
|
loadRememberedType() {
|
|
5648
5754
|
try {
|
|
5649
|
-
let e = localStorage.getItem(
|
|
5755
|
+
let e = localStorage.getItem(bg);
|
|
5650
5756
|
if (e !== null) {
|
|
5651
5757
|
let t = Number(e);
|
|
5652
5758
|
if (b[t] !== void 0) {
|
|
5653
5759
|
this.workingEndpointType = t;
|
|
5654
|
-
let e = localStorage.getItem(
|
|
5760
|
+
let e = localStorage.getItem(Sg), n = e ? Math.round((Date.now() - Number(e)) / 36e5) : "?";
|
|
5655
5761
|
X.debug(`Loaded remembered type: ${b[t]} (age: ${n}h)`);
|
|
5656
5762
|
}
|
|
5657
5763
|
}
|
|
@@ -5659,14 +5765,14 @@ var tg = {
|
|
|
5659
5765
|
}
|
|
5660
5766
|
loadProxyPreference() {
|
|
5661
5767
|
try {
|
|
5662
|
-
this._proxyPreferred = localStorage.getItem(
|
|
5768
|
+
this._proxyPreferred = localStorage.getItem(xg) === "true", this._proxyPreferred && X.debug("Loaded proxy preference: preferred");
|
|
5663
5769
|
} catch {}
|
|
5664
5770
|
}
|
|
5665
|
-
}, Z =
|
|
5666
|
-
function
|
|
5771
|
+
}, Z = C("IkonClient"), Eg = [1e4, 3e4];
|
|
5772
|
+
function Dg() {
|
|
5667
5773
|
return typeof __IKON_WAIT_FOR_EXTERNAL_CONNECT_URL__ < "u" && __IKON_WAIT_FOR_EXTERNAL_CONNECT_URL__;
|
|
5668
5774
|
}
|
|
5669
|
-
var
|
|
5775
|
+
var Og = class {
|
|
5670
5776
|
channelManager = null;
|
|
5671
5777
|
protocolWorker = null;
|
|
5672
5778
|
preloadedWorker = null;
|
|
@@ -5746,7 +5852,7 @@ var mg = class {
|
|
|
5746
5852
|
_reconnectTimer = null;
|
|
5747
5853
|
_serverStopped = !1;
|
|
5748
5854
|
_hasBeenConnected = !1;
|
|
5749
|
-
_waitForExternalConnectUrl =
|
|
5855
|
+
_waitForExternalConnectUrl = Dg();
|
|
5750
5856
|
_externalConnectUrlCleanup = null;
|
|
5751
5857
|
get media() {
|
|
5752
5858
|
return this._media;
|
|
@@ -5763,10 +5869,10 @@ var mg = class {
|
|
|
5763
5869
|
return this._mediaCapture;
|
|
5764
5870
|
}
|
|
5765
5871
|
async ensureMediaCapture() {
|
|
5766
|
-
return this._mediaCapture ? this._mediaCapture : R() ? (this._mediaCapturePromise ||= Promise.resolve().then(() =>
|
|
5872
|
+
return this._mediaCapture ? this._mediaCapture : R() ? (this._mediaCapturePromise ||= Promise.resolve().then(() => c_).then(({ IkonMediaCapture: e }) => (this._mediaCapture = new e(this, this._mediaCaptureConfig), this._mediaCapture)), this._mediaCapturePromise) : null;
|
|
5767
5873
|
}
|
|
5768
5874
|
async ensureMedia() {
|
|
5769
|
-
return this._media ? this._media : (this._mediaPromise ||= import("./ikon-media
|
|
5875
|
+
return this._media ? this._media : (this._mediaPromise ||= import("./ikon-media--ap3vpXf.js").then((e) => e.n).then(({ IkonMedia: e }) => (this._media = new e(this, this._mediaConfig), this._media)), this._mediaPromise);
|
|
5770
5876
|
}
|
|
5771
5877
|
get isAudioEnabled() {
|
|
5772
5878
|
return this._audioEnabled;
|
|
@@ -5775,7 +5881,7 @@ var mg = class {
|
|
|
5775
5881
|
return this._videoEnabled;
|
|
5776
5882
|
}
|
|
5777
5883
|
get isWebRtcEnabled() {
|
|
5778
|
-
return (
|
|
5884
|
+
return (uu() ?? this.config.webRtc?.enabled ?? !0) && (this._audioEnabled || this._videoEnabled);
|
|
5779
5885
|
}
|
|
5780
5886
|
get isWebRtcMediaActive() {
|
|
5781
5887
|
return this.isWebRtcEnabled && !this._webRtcFallbackActive;
|
|
@@ -5809,15 +5915,15 @@ var mg = class {
|
|
|
5809
5915
|
].filter(Boolean).length;
|
|
5810
5916
|
if (t === 0) throw Error("IkonClient requires one of: \"local\", \"apiKey\", or \"sessionToken\" configuration");
|
|
5811
5917
|
if (t > 1) throw Error("IkonClient accepts only one of: \"local\", \"apiKey\", or \"sessionToken\" configuration");
|
|
5812
|
-
|
|
5813
|
-
let n = e.local ? null :
|
|
5814
|
-
this.endpointSelector = new
|
|
5918
|
+
Jh(), R() && ff();
|
|
5919
|
+
let n = e.local ? null : nu() ?? e.proxy ?? null, r = n === !0 ? "force-proxy" : n === !1 ? "force-direct" : "auto", i = e.local ? null : ru(), a = e.local ? null : iu(), o = i ?? e.websocket, s = a ?? e.webtransport ?? !1;
|
|
5920
|
+
this.endpointSelector = new Tg({
|
|
5815
5921
|
local: e.local,
|
|
5816
5922
|
proxyMode: r,
|
|
5817
5923
|
websocket: o,
|
|
5818
5924
|
webtransport: s
|
|
5819
|
-
}), r === "auto" ? this.endpointSelector.proxyPreferred && Z.debug("Proxy preferred (from previous session)") : Z.debug(`Proxy mode: ${r}`), (o !== void 0 || s !== void 0) && Z.debug(`Transport filter: websocket=${o ?? "auto"}, webtransport=${s ?? "auto"}`), this._functionRegistry = new
|
|
5820
|
-
let c =
|
|
5925
|
+
}), r === "auto" ? this.endpointSelector.proxyPreferred && Z.debug("Proxy preferred (from previous session)") : Z.debug(`Proxy mode: ${r}`), (o !== void 0 || s !== void 0) && Z.debug(`Transport filter: websocket=${o ?? "auto"}, webtransport=${s ?? "auto"}`), this._functionRegistry = new ih(), this._reactiveRegistry = new lh(this._functionRegistry), R() && !e.disableBrowserFunctions && (this.unregisterBrowserFunctions = Sp(this._functionRegistry), this.unregisterSoundFunctions = Hh(this._functionRegistry)), R() && (this.unregisterLoginInterceptor = this._functionRegistry.addErrorInterceptor(ph));
|
|
5926
|
+
let c = cu(), l = lu();
|
|
5821
5927
|
this._audioEnabled = c ?? e.audio?.enabled ?? !0, this._videoEnabled = l ?? e.video?.enabled ?? !0;
|
|
5822
5928
|
let u = e.audio ? {
|
|
5823
5929
|
performance: e.audio.performance,
|
|
@@ -5828,7 +5934,7 @@ var mg = class {
|
|
|
5828
5934
|
audio: u,
|
|
5829
5935
|
video: d,
|
|
5830
5936
|
mediaSession: e.mediaSession
|
|
5831
|
-
}, this._mediaCaptureConfig = { audio: { performance: { preferWebCodecs: e.audio?.performance?.preferWebCodecs } } }, R() && (this.unregisterMediaCaptureFunctions =
|
|
5937
|
+
}, this._mediaCaptureConfig = { audio: { performance: { preferWebCodecs: e.audio?.performance?.preferWebCodecs } } }, R() && (this.unregisterMediaCaptureFunctions = Ch(this._functionRegistry, this));
|
|
5832
5938
|
}
|
|
5833
5939
|
_lastError = void 0;
|
|
5834
5940
|
get lastError() {
|
|
@@ -5881,15 +5987,15 @@ var mg = class {
|
|
|
5881
5987
|
async connect() {
|
|
5882
5988
|
if (this._connectStarted) throw Error(`Cannot connect: already started (state: ${this.currentState})`);
|
|
5883
5989
|
this._connectStarted = !0;
|
|
5884
|
-
let e =
|
|
5990
|
+
let e = sg();
|
|
5885
5991
|
if (!e.supported) {
|
|
5886
5992
|
this.setErrorState(new Il(e.missingFeatures));
|
|
5887
5993
|
return;
|
|
5888
5994
|
}
|
|
5889
5995
|
this.setupLifecycleHandlers();
|
|
5890
|
-
let t =
|
|
5996
|
+
let t = su();
|
|
5891
5997
|
if (t) {
|
|
5892
|
-
Z.info("Found external connect URL in query parameter"), await this.executeConnection(() =>
|
|
5998
|
+
Z.info("Found external connect URL in query parameter"), await this.executeConnection(() => G(t, this.abortController.signal));
|
|
5893
5999
|
return;
|
|
5894
6000
|
}
|
|
5895
6001
|
if (this._waitForExternalConnectUrl) {
|
|
@@ -5900,17 +6006,17 @@ var mg = class {
|
|
|
5900
6006
|
}
|
|
5901
6007
|
async executeConnection(e) {
|
|
5902
6008
|
if (this._lastError = void 0, this.abortController = new AbortController(), typeof Worker < "u" && !this.preloadedWorker) try {
|
|
5903
|
-
this.preloadedWorker = new
|
|
6009
|
+
this.preloadedWorker = new mg();
|
|
5904
6010
|
} catch {}
|
|
5905
6011
|
this.setState("connecting"), this.connectionTimer = setTimeout(() => {
|
|
5906
6012
|
this.currentState === "connecting" && (Z.error("Connection timeout"), this.abortController?.abort("Connection timeout"), this.setState("offline"), this.config.onError?.(/* @__PURE__ */ Error("Connection timeout")));
|
|
5907
6013
|
}, this.connectionTimeoutMs);
|
|
5908
6014
|
try {
|
|
5909
6015
|
let t = await e();
|
|
5910
|
-
if (this.authResponse = t.authResponse, this._sessionId = t.authResponse.ClientContext.SessionId, this._connectUrl = t.directUrl, this._brandingRequired = t.brandingRequired ?? !1, Z.info(`Authenticated to Ikon server (ikonServerId=${t.authResponse.IkonServerId}, appSessionId=${t.authResponse.AppSessionId})`), !this.config.local && t.backendUrl && t.authToken &&
|
|
6016
|
+
if (this.authResponse = t.authResponse, this._sessionId = t.authResponse.ClientContext.SessionId, this._connectUrl = t.directUrl, this._brandingRequired = t.brandingRequired ?? !1, Z.info(`Authenticated to Ikon server (ikonServerId=${t.authResponse.IkonServerId}, appSessionId=${t.authResponse.AppSessionId})`), !this.config.local && t.backendUrl && t.authToken && nm(t.backendUrl, t.authToken), t.usedProxyUrl && t.directUrl && this.endpointSelector.proxyMode === "auto") {
|
|
5911
6017
|
Z.debug("Auth fell back to proxy, marking proxy preferred");
|
|
5912
6018
|
let e = t.directUrl;
|
|
5913
|
-
|
|
6019
|
+
zm(e).then((e) => {
|
|
5914
6020
|
e && (Z.debug("Background probe: direct server reachable, clearing proxy preference for next connection"), this.endpointSelector.clearProxyPreference());
|
|
5915
6021
|
}).catch(() => {});
|
|
5916
6022
|
}
|
|
@@ -5921,7 +6027,7 @@ var mg = class {
|
|
|
5921
6027
|
}
|
|
5922
6028
|
}
|
|
5923
6029
|
disconnect() {
|
|
5924
|
-
Z.info("Disconnecting from Ikon server"), this.sendDisconnectSignal(),
|
|
6030
|
+
Z.info("Disconnecting from Ikon server"), this.sendDisconnectSignal(), im(), this.clearTimers(), this.cleanupLifecycleHandlers(), this._externalConnectUrlCleanup &&= (this._externalConnectUrlCleanup(), null), this._media?.dispose(), this._mediaCapture?.dispose(), this.unregisterMediaCaptureFunctions &&= (this.unregisterMediaCaptureFunctions(), null), this.unregisterSoundFunctions &&= (this.unregisterSoundFunctions(), null), this.unregisterBrowserFunctions &&= (this.unregisterBrowserFunctions(), null), this.unregisterLoginInterceptor &&= (this.unregisterLoginInterceptor(), null), this.abortController?.abort(), this.abortController = null, this._fullReauthAttempted = !1, this._softReconnectAttempted = !1, this._lastFailureWasAuthRejected = !1, this._reauthInProgress = !1, this._disconnectedAt = null, this._serverStopped = !1, this._hasBeenConnected = !1, this.releaseKeepaliveLock(), this.disconnectProtocol(), this.authResponse = null, this._sessionId = void 0, this._globalState = null, this._globalStateReceived = !1, this._channelsConnected = !1, this._joinedHandled = !1, this._environmentTrackingSetup = !1;
|
|
5925
6031
|
for (let e of this._webRtcAudioElements.values()) e.pause(), e.srcObject = null, e.remove();
|
|
5926
6032
|
this._webRtcAudioElements.clear(), this._webRtcAudioStreams.clear(), this._webRtcVideoStreams.clear(), this._webRtcTrackMap.clear(), this._pendingActiveAudioTracks.clear(), this.removeWebRtcAudioUnlockHandler(), this._webRtcMediaSession.cleanup(), this._functionRegistry.detach(), this._reactiveRegistry.detach(), this.setState("offline");
|
|
5927
6033
|
}
|
|
@@ -5942,7 +6048,7 @@ var mg = class {
|
|
|
5942
6048
|
});
|
|
5943
6049
|
}
|
|
5944
6050
|
sendActionCallCore(e, t) {
|
|
5945
|
-
let r = n.createRandom(), i =
|
|
6051
|
+
let r = n.createRandom(), i = Fe({
|
|
5946
6052
|
ActionId: n.fromString(e),
|
|
5947
6053
|
PayloadJson: t ?? "{}",
|
|
5948
6054
|
CallId: r
|
|
@@ -5992,7 +6098,11 @@ var mg = class {
|
|
|
5992
6098
|
this.channelManager.sendProtocolMessage(e);
|
|
5993
6099
|
return;
|
|
5994
6100
|
}
|
|
5995
|
-
|
|
6101
|
+
if (this.currentState === "connected") {
|
|
6102
|
+
Z.warn("Cannot send: not connected");
|
|
6103
|
+
return;
|
|
6104
|
+
}
|
|
6105
|
+
Z.debug(`Cannot send while ${this.currentState}: no transport`);
|
|
5996
6106
|
}
|
|
5997
6107
|
sendUpdateClientContext(e) {
|
|
5998
6108
|
if (!this._sessionId) {
|
|
@@ -6128,10 +6238,10 @@ var mg = class {
|
|
|
6128
6238
|
}
|
|
6129
6239
|
async authenticate() {
|
|
6130
6240
|
let e = this.abortController?.signal;
|
|
6131
|
-
if (this.config.local) return
|
|
6241
|
+
if (this.config.local) return Um(this.config.local, e);
|
|
6132
6242
|
let t = this.endpointSelector.proxyMode, n = this.endpointSelector.proxyPreferred, r;
|
|
6133
|
-
if (this.config.apiKey) r = await
|
|
6134
|
-
else if (this.config.sessionToken) r = await
|
|
6243
|
+
if (this.config.apiKey) r = await Wm(this.config.apiKey, e, t, n);
|
|
6244
|
+
else if (this.config.sessionToken) r = await Gm(this.config.sessionToken, e, t, n);
|
|
6135
6245
|
else throw Error("No connection configuration provided (need local, apiKey, or sessionToken)");
|
|
6136
6246
|
return r.usedProxyUrl && t === "auto" && this.endpointSelector.markProxyPreferred(), r;
|
|
6137
6247
|
}
|
|
@@ -6142,8 +6252,8 @@ var mg = class {
|
|
|
6142
6252
|
this.notifyMessageSubscribers(e, t, n);
|
|
6143
6253
|
return;
|
|
6144
6254
|
}
|
|
6145
|
-
if (t ===
|
|
6146
|
-
|
|
6255
|
+
if (t === w.ACTION_CALL_ACK) {
|
|
6256
|
+
Ue(e).then((e) => {
|
|
6147
6257
|
let t = e.CallId.toString(), n = this._pendingActionAcks.get(t);
|
|
6148
6258
|
n !== void 0 && (clearTimeout(n), this._pendingActionAcks.delete(t));
|
|
6149
6259
|
}).catch((e) => {
|
|
@@ -6151,8 +6261,8 @@ var mg = class {
|
|
|
6151
6261
|
});
|
|
6152
6262
|
return;
|
|
6153
6263
|
}
|
|
6154
|
-
if (t ===
|
|
6155
|
-
|
|
6264
|
+
if (t === w.ACTION_RESULT) {
|
|
6265
|
+
$e(e).then((e) => {
|
|
6156
6266
|
let t = e.CallId.toString(), n = this._actionIdByCallId.get(t);
|
|
6157
6267
|
this._actionIdByCallId.delete(t);
|
|
6158
6268
|
let r = this._pendingActionResults.get(t);
|
|
@@ -6165,21 +6275,21 @@ var mg = class {
|
|
|
6165
6275
|
}), this.notifyMessageSubscribers(e, t, n);
|
|
6166
6276
|
return;
|
|
6167
6277
|
}
|
|
6168
|
-
if (t ===
|
|
6169
|
-
this._globalState = e, this._sessionId !== void 0 && this._functionRegistry.syncFromGlobalState(e, this._sessionId), this._media?.audio.syncStreamsFromGlobalState(e), this._media?.video.syncStreamsFromGlobalState(e), this._visemeTracker?.syncStreamsFromGlobalState(e), this._globalState.DebugMode &&
|
|
6278
|
+
if (t === w.CORE_GLOBAL_STATE && uo(e).then((e) => {
|
|
6279
|
+
this._globalState = e, this._sessionId !== void 0 && this._functionRegistry.syncFromGlobalState(e, this._sessionId), this._media?.audio.syncStreamsFromGlobalState(e), this._media?.video.syncStreamsFromGlobalState(e), this._visemeTracker?.syncStreamsFromGlobalState(e), this._globalState.DebugMode && Xh(), Yh() && this.protocolWorker && (this.protocolWorker.postMessage({
|
|
6170
6280
|
type: "enableDevtools",
|
|
6171
6281
|
enabled: !0
|
|
6172
6282
|
}), this.protocolWorker.postMessage({
|
|
6173
6283
|
type: "setLogLevel",
|
|
6174
|
-
level:
|
|
6284
|
+
level: Ce()
|
|
6175
6285
|
})), this._globalStateReceived || (this._globalStateReceived = !0, this.tryHandleJoined());
|
|
6176
6286
|
}).catch((e) => {
|
|
6177
6287
|
Z.error("Failed to parse GlobalState:", e);
|
|
6178
|
-
}), t ===
|
|
6288
|
+
}), t === w.CORE_CLIENT_INITIALIZATION && wa(e).then((e) => {
|
|
6179
6289
|
this._sessionId !== void 0 && this._functionRegistry.registerFromClientInitialization(e, this._sessionId);
|
|
6180
6290
|
}).catch((e) => {
|
|
6181
6291
|
Z.error("Failed to parse ClientInitialization:", e);
|
|
6182
|
-
}), t ===
|
|
6292
|
+
}), t === w.CORE_CLIENT_LIFECYCLE_BATCH) {
|
|
6183
6293
|
let t = rs(e), n = i(e).senderId;
|
|
6184
6294
|
for (let e of t.Events) {
|
|
6185
6295
|
if (e.ClientContext.SessionId === this._sessionId) continue;
|
|
@@ -6188,7 +6298,7 @@ var mg = class {
|
|
|
6188
6298
|
}
|
|
6189
6299
|
return;
|
|
6190
6300
|
}
|
|
6191
|
-
if (t ===
|
|
6301
|
+
if (t === w.CORE_ON_FRONTEND_RELOADED) {
|
|
6192
6302
|
Z.info("Frontend rebuilt — reloading the page"), typeof window < "u" && window.location.reload();
|
|
6193
6303
|
return;
|
|
6194
6304
|
}
|
|
@@ -6196,11 +6306,11 @@ var mg = class {
|
|
|
6196
6306
|
}
|
|
6197
6307
|
buildLifecycleMessageFromEvent(e, t) {
|
|
6198
6308
|
switch (e.EventOpcode) {
|
|
6199
|
-
case
|
|
6200
|
-
case
|
|
6201
|
-
case
|
|
6202
|
-
case
|
|
6203
|
-
case
|
|
6309
|
+
case w.CORE_ON_CLIENT_JOINED: return hs({ ClientContext: e.ClientContext }, t);
|
|
6310
|
+
case w.CORE_ON_CLIENT_READY: return Ts({ ClientContext: e.ClientContext }, t);
|
|
6311
|
+
case w.CORE_ON_CLIENT_LEFT: return bs({ ClientContext: e.ClientContext }, t);
|
|
6312
|
+
case w.CORE_ON_USER_JOINED: return As({ ClientContext: e.ClientContext }, t);
|
|
6313
|
+
case w.CORE_ON_USER_LEFT: return Fs({ ClientContext: e.ClientContext }, t);
|
|
6204
6314
|
default: return;
|
|
6205
6315
|
}
|
|
6206
6316
|
}
|
|
@@ -6253,7 +6363,7 @@ var mg = class {
|
|
|
6253
6363
|
break;
|
|
6254
6364
|
case "offline":
|
|
6255
6365
|
if (this._reauthInProgress) break;
|
|
6256
|
-
if (this._hasBeenConnected && !this._serverStopped &&
|
|
6366
|
+
if (this._hasBeenConnected && !this._serverStopped && j()) {
|
|
6257
6367
|
this.currentState === "connected" && (this._channelsConnected = !1, this._globalStateReceived = !1, this._joinedHandled = !1, this._functionRegistry.detach(), this._reactiveRegistry.detach(), this.releaseKeepaliveLock(), this.setState("reconnecting")), this.attemptReconnect();
|
|
6258
6368
|
break;
|
|
6259
6369
|
}
|
|
@@ -6269,7 +6379,7 @@ var mg = class {
|
|
|
6269
6379
|
}
|
|
6270
6380
|
setState(e) {
|
|
6271
6381
|
if (!this._isUnloading) {
|
|
6272
|
-
if (e === "offline" && this._hasBeenConnected && !this._serverStopped &&
|
|
6382
|
+
if (e === "offline" && this._hasBeenConnected && !this._serverStopped && j()) {
|
|
6273
6383
|
Z.error("Refusing to set offline state from connected session — scheduling reconnect retry instead. This is a bug; investigate the call site."), this.setState("reconnecting"), this.scheduleReconnectRetry();
|
|
6274
6384
|
return;
|
|
6275
6385
|
}
|
|
@@ -6304,7 +6414,7 @@ var mg = class {
|
|
|
6304
6414
|
let n;
|
|
6305
6415
|
if (this.preloadedWorker) n = this.preloadedWorker, this.preloadedWorker = null;
|
|
6306
6416
|
else try {
|
|
6307
|
-
n = new
|
|
6417
|
+
n = new mg();
|
|
6308
6418
|
} catch (n) {
|
|
6309
6419
|
Z.warn(`Failed to create protocol worker, falling back to main thread: ${n}`), await this.connectProtocolOnMainThread(e, t);
|
|
6310
6420
|
return;
|
|
@@ -6329,7 +6439,7 @@ var mg = class {
|
|
|
6329
6439
|
return;
|
|
6330
6440
|
}
|
|
6331
6441
|
if (o?.type === "refreshEntrypoints") {
|
|
6332
|
-
this._connectUrl ?
|
|
6442
|
+
this._connectUrl ? G(this._connectUrl, this.abortController?.signal).then((e) => {
|
|
6333
6443
|
this.authResponse = e.authResponse, this._sessionId = e.authResponse.ClientContext.SessionId, n.postMessage({
|
|
6334
6444
|
type: "refreshedEntrypoints",
|
|
6335
6445
|
entrypoints: e.authResponse.Entrypoints,
|
|
@@ -6360,14 +6470,14 @@ var mg = class {
|
|
|
6360
6470
|
r || (i = void 0, t(/* @__PURE__ */ Error("Protocol worker connect timed out")));
|
|
6361
6471
|
}, td);
|
|
6362
6472
|
}), i = this.computeOrderedEndpointTypes(e), a = this.getServerKeepaliveTimeoutMs(), o = this.config.timeouts?.reconnectBackoffMs ?? 2e3, s = this.config.timeouts?.maxReconnectAttempts ?? 2;
|
|
6363
|
-
this.updateWorkerInterestMask(),
|
|
6473
|
+
this.updateWorkerInterestMask(), Yh() && (n.postMessage({
|
|
6364
6474
|
type: "enableDevtools",
|
|
6365
6475
|
enabled: !0
|
|
6366
6476
|
}), n.postMessage({
|
|
6367
6477
|
type: "setLogLevel",
|
|
6368
|
-
level:
|
|
6369
|
-
})),
|
|
6370
|
-
let c =
|
|
6478
|
+
level: Ce()
|
|
6479
|
+
})), $h();
|
|
6480
|
+
let c = uu() ?? this.config.webRtc?.enabled ?? !0;
|
|
6371
6481
|
n.postMessage({
|
|
6372
6482
|
type: "connect",
|
|
6373
6483
|
sessionId: this._sessionId,
|
|
@@ -6394,7 +6504,7 @@ var mg = class {
|
|
|
6394
6504
|
}
|
|
6395
6505
|
ensureVisemeTracker() {
|
|
6396
6506
|
if (!this._visemeTracker) try {
|
|
6397
|
-
this._visemeTracker = new
|
|
6507
|
+
this._visemeTracker = new Kh(this), this._visemeTracker.enable();
|
|
6398
6508
|
} catch (e) {
|
|
6399
6509
|
Z.warn(`Viseme tracker setup failed: ${e}`), this._visemeTracker = null;
|
|
6400
6510
|
}
|
|
@@ -6408,8 +6518,8 @@ var mg = class {
|
|
|
6408
6518
|
}
|
|
6409
6519
|
}
|
|
6410
6520
|
async setupWebRtcSignaling() {
|
|
6411
|
-
let e =
|
|
6412
|
-
this._audioEnabled && (e |=
|
|
6521
|
+
let e = w.NONE;
|
|
6522
|
+
this._audioEnabled && (e |= w.GROUP_AUDIO), this._videoEnabled && (e |= w.GROUP_VIDEO);
|
|
6413
6523
|
let t = {
|
|
6414
6524
|
sessionId: this._sessionId,
|
|
6415
6525
|
opcodeGroupsFromServer: e,
|
|
@@ -6418,7 +6528,7 @@ var mg = class {
|
|
|
6418
6528
|
useVideoTrack: this._videoEnabled,
|
|
6419
6529
|
useDataChannel: !0,
|
|
6420
6530
|
iceServers: this.config.webRtc?.iceServers,
|
|
6421
|
-
iceTransportPolicy:
|
|
6531
|
+
iceTransportPolicy: du() ?? this.config.webRtc?.iceTransportPolicy ?? this._webRtcReachability.iceTransportPolicy,
|
|
6422
6532
|
shouldAttemptWithoutIceServers: () => this._webRtcReachability.shouldAttemptWithoutIceServers || this._webRtcRetryCount > 0,
|
|
6423
6533
|
onStateChange: (e) => {
|
|
6424
6534
|
e === "connected" ? (this.clearWebRtcConnectWatchdog(), this._webRtcRetryCount = 0, this.rememberWebRtcReachability(), this._media?.audio.setWebRtcActive(!0), this._media?.video.setWebRtcActive(!0)) : e === "failed" && this.fallbackToCustomPlayback(`webrtc connection ${e}`);
|
|
@@ -6472,9 +6582,9 @@ var mg = class {
|
|
|
6472
6582
|
this._webRtcRetryTimer &&= (clearTimeout(this._webRtcRetryTimer), null);
|
|
6473
6583
|
}
|
|
6474
6584
|
scheduleWebRtcRetry() {
|
|
6475
|
-
if (this._webRtcRetryTimer || this._webRtcRetryCount >=
|
|
6476
|
-
let e =
|
|
6477
|
-
Z.info(`Retrying WebRTC in ${Math.round(e / 1e3)}s (attempt ${this._webRtcRetryCount}/${
|
|
6585
|
+
if (this._webRtcRetryTimer || this._webRtcRetryCount >= Eg.length) return;
|
|
6586
|
+
let e = Eg[this._webRtcRetryCount++];
|
|
6587
|
+
Z.info(`Retrying WebRTC in ${Math.round(e / 1e3)}s (attempt ${this._webRtcRetryCount}/${Eg.length})`), this._webRtcRetryTimer = setTimeout(() => {
|
|
6478
6588
|
this._webRtcRetryTimer = null, !(this.currentState !== "connected" || this._webRtcSignaling || !this.isWebRtcEnabled) && this.setupWebRtcSignaling();
|
|
6479
6589
|
}, e);
|
|
6480
6590
|
}
|
|
@@ -6509,7 +6619,7 @@ var mg = class {
|
|
|
6509
6619
|
this.ensureWebRtcAudioUnlockHandler();
|
|
6510
6620
|
}), this.scheduleWebRtcAudioPlaybackVerification(e));
|
|
6511
6621
|
};
|
|
6512
|
-
n.addEventListener("pause", r), n.addEventListener("stalled", r), n.addEventListener("error", r),
|
|
6622
|
+
n.addEventListener("pause", r), n.addEventListener("stalled", r), n.addEventListener("error", r), Ee() && this.ensureWebRtcAudioUnlockHandler(), n.play().then(() => {
|
|
6513
6623
|
setTimeout(() => {
|
|
6514
6624
|
this._webRtcAudioElements.has(e) && (n.volume = 0, n.muted = !1, n.play().then(() => {
|
|
6515
6625
|
let t = 0, r = setInterval(() => {
|
|
@@ -6606,7 +6716,7 @@ var mg = class {
|
|
|
6606
6716
|
}
|
|
6607
6717
|
async connectProtocolOnMainThread(e, t = !1) {
|
|
6608
6718
|
this.workerManagerState = null, this.protocolWorker = null;
|
|
6609
|
-
let n =
|
|
6719
|
+
let n = uu() ?? this.config.webRtc?.enabled ?? !0;
|
|
6610
6720
|
Z.debug(`Connecting on main thread (webRtcEnabled=${n}, entrypoints=${e.length})`), this.channelManager = new ku({
|
|
6611
6721
|
sessionId: this._sessionId,
|
|
6612
6722
|
keepaliveTimeoutMs: this.getServerKeepaliveTimeoutMs(),
|
|
@@ -6624,7 +6734,7 @@ var mg = class {
|
|
|
6624
6734
|
this.config.onError?.(e);
|
|
6625
6735
|
},
|
|
6626
6736
|
onRefreshEntrypoints: this._connectUrl ? async () => {
|
|
6627
|
-
let e = await
|
|
6737
|
+
let e = await G(this._connectUrl, this.abortController?.signal);
|
|
6628
6738
|
return this.authResponse = e.authResponse, this._sessionId = e.authResponse.ClientContext.SessionId, {
|
|
6629
6739
|
entrypoints: e.authResponse.Entrypoints,
|
|
6630
6740
|
sessionId: this._sessionId
|
|
@@ -6666,7 +6776,7 @@ var mg = class {
|
|
|
6666
6776
|
let n = this.groupEntrypointsByType(this._connectedEntrypoints), r = this.abortController?.signal;
|
|
6667
6777
|
for (let e of t) {
|
|
6668
6778
|
let t = n.get(e)?.[0]?.Uri;
|
|
6669
|
-
if (!(t === void 0 || r?.aborted) && await
|
|
6779
|
+
if (!(t === void 0 || r?.aborted) && await ug(e, t, { signal: r })) {
|
|
6670
6780
|
this.endpointSelector.recordFasterTypeReachable(e);
|
|
6671
6781
|
return;
|
|
6672
6782
|
}
|
|
@@ -6682,7 +6792,7 @@ var mg = class {
|
|
|
6682
6792
|
});
|
|
6683
6793
|
return;
|
|
6684
6794
|
}
|
|
6685
|
-
let e =
|
|
6795
|
+
let e = w.GROUP_CORE | w.GROUP_ACTIONS;
|
|
6686
6796
|
for (let [, t] of this.messageSubscribers.entries()) {
|
|
6687
6797
|
if (!t || t.opcodeGroupsMask === void 0) {
|
|
6688
6798
|
this.protocolWorker.postMessage({
|
|
@@ -6732,7 +6842,7 @@ var mg = class {
|
|
|
6732
6842
|
}
|
|
6733
6843
|
}
|
|
6734
6844
|
attemptReconnect() {
|
|
6735
|
-
if (!
|
|
6845
|
+
if (!j()) {
|
|
6736
6846
|
Z.warn("Retry disabled via ikon-retry=false, going offline"), this.clearTimers(), this.setState("offline");
|
|
6737
6847
|
return;
|
|
6738
6848
|
}
|
|
@@ -6759,7 +6869,7 @@ var mg = class {
|
|
|
6759
6869
|
this.attemptFullReauth();
|
|
6760
6870
|
}
|
|
6761
6871
|
scheduleReconnectRetry() {
|
|
6762
|
-
if (!
|
|
6872
|
+
if (!j()) {
|
|
6763
6873
|
Z.warn("Retry disabled via ikon-retry=false, going offline instead of scheduling retry"), this.clearTimers(), this.setState("offline");
|
|
6764
6874
|
return;
|
|
6765
6875
|
}
|
|
@@ -6796,8 +6906,8 @@ var mg = class {
|
|
|
6796
6906
|
let t = e.target?.closest?.("a[href]");
|
|
6797
6907
|
if (!t || t.target && t.target !== "_self") return;
|
|
6798
6908
|
let n = t.getAttribute("href") ?? "";
|
|
6799
|
-
if (
|
|
6800
|
-
e.preventDefault(),
|
|
6909
|
+
if (ig(n)) {
|
|
6910
|
+
e.preventDefault(), ag(n);
|
|
6801
6911
|
return;
|
|
6802
6912
|
}
|
|
6803
6913
|
let r = this.resolveInPlaceDestination(t, n);
|
|
@@ -6816,7 +6926,7 @@ var mg = class {
|
|
|
6816
6926
|
} catch {
|
|
6817
6927
|
return null;
|
|
6818
6928
|
}
|
|
6819
|
-
return n.origin !== window.location.origin || n.protocol !== "http:" && n.protocol !== "https:" || n.hash && n.pathname === window.location.pathname && n.search === window.location.search ||
|
|
6929
|
+
return n.origin !== window.location.origin || n.protocol !== "http:" && n.protocol !== "https:" || n.hash && n.pathname === window.location.pathname && n.search === window.location.search || rf(n.pathname) ? null : n;
|
|
6820
6930
|
}
|
|
6821
6931
|
sendDisconnectSignal() {
|
|
6822
6932
|
if (this._sessionId !== void 0 && this.currentState === "connected") try {
|
|
@@ -6853,7 +6963,7 @@ var mg = class {
|
|
|
6853
6963
|
}
|
|
6854
6964
|
sendUrlChanged() {
|
|
6855
6965
|
if (!this._sessionId) return;
|
|
6856
|
-
let e =
|
|
6966
|
+
let e = ot(nt({ Path: window.location.pathname + window.location.search }), this._sessionId);
|
|
6857
6967
|
this.sendProtocolMessage(e);
|
|
6858
6968
|
}
|
|
6859
6969
|
checkConnectionHealth() {
|
|
@@ -6892,14 +7002,14 @@ var mg = class {
|
|
|
6892
7002
|
});
|
|
6893
7003
|
}, 150);
|
|
6894
7004
|
}), window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => {
|
|
6895
|
-
this.sendUpdateClientContext({ theme:
|
|
7005
|
+
this.sendUpdateClientContext({ theme: uf() });
|
|
6896
7006
|
});
|
|
6897
7007
|
}
|
|
6898
7008
|
setupExternalConnectUrlListener() {
|
|
6899
7009
|
let e = (e) => {
|
|
6900
7010
|
e.data?.type === "IKON_EXTERNAL_CONNECT_URL" && typeof e.data.serverUrl == "string" && (Z.info("Received external connect URL from parent window"), this.handleExternalConnectUrl(e.data.serverUrl).catch((e) => {
|
|
6901
7011
|
if (!(e instanceof DOMException && e.name === "AbortError")) {
|
|
6902
|
-
if (this._hasBeenConnected &&
|
|
7012
|
+
if (this._hasBeenConnected && j()) {
|
|
6903
7013
|
Z.warn("External connect URL connection failed, scheduling retry:", e), this.scheduleReconnectRetry();
|
|
6904
7014
|
return;
|
|
6905
7015
|
}
|
|
@@ -6918,12 +7028,12 @@ var mg = class {
|
|
|
6918
7028
|
if (this.currentState !== "waitingForExternalConnectUrl") throw Error(`Cannot connect with external connect URL: already in state ${this.currentState}`);
|
|
6919
7029
|
Z.info("Connecting with external connect URL");
|
|
6920
7030
|
try {
|
|
6921
|
-
await this.executeConnection(() =>
|
|
7031
|
+
await this.executeConnection(() => G(e, this.abortController.signal));
|
|
6922
7032
|
} finally {
|
|
6923
7033
|
this._externalConnectUrlCleanup &&= (this._externalConnectUrlCleanup(), null);
|
|
6924
7034
|
}
|
|
6925
7035
|
}
|
|
6926
|
-
},
|
|
7036
|
+
}, kg = class {
|
|
6927
7037
|
client;
|
|
6928
7038
|
constructor(e) {
|
|
6929
7039
|
this.client = e;
|
|
@@ -6932,7 +7042,7 @@ var mg = class {
|
|
|
6932
7042
|
this.client.sendProtocolMessage(e.toProtocolMessage(t, this.client.sessionId ?? 0));
|
|
6933
7043
|
}
|
|
6934
7044
|
on(e, t) {
|
|
6935
|
-
let n = this.client.createProtocolMessagePort({ opcodeGroupsMask:
|
|
7045
|
+
let n = this.client.createProtocolMessagePort({ opcodeGroupsMask: w.GROUP_APP_LOCAL });
|
|
6936
7046
|
return n ? (n.port.onmessage = async (n) => {
|
|
6937
7047
|
let r = n.data;
|
|
6938
7048
|
if (r?.type !== "protocol" || r.headers?.opcode !== e.opcode) return;
|
|
@@ -6941,45 +7051,45 @@ var mg = class {
|
|
|
6941
7051
|
}, { close: () => n.close() }) : { close: () => {} };
|
|
6942
7052
|
}
|
|
6943
7053
|
};
|
|
6944
|
-
function
|
|
6945
|
-
return new
|
|
7054
|
+
function Ag(e) {
|
|
7055
|
+
return new kg(e);
|
|
6946
7056
|
}
|
|
6947
7057
|
//#endregion
|
|
6948
7058
|
//#region src/client/connection-state.ts
|
|
6949
|
-
function
|
|
7059
|
+
function jg(e) {
|
|
6950
7060
|
return e === "waitingForExternalConnectUrl" || e === "connecting" || e === "connectingSlow" || e === "reconnecting";
|
|
6951
7061
|
}
|
|
6952
|
-
function
|
|
7062
|
+
function Mg(e) {
|
|
6953
7063
|
return e === "connected";
|
|
6954
7064
|
}
|
|
6955
|
-
function
|
|
7065
|
+
function Ng(e) {
|
|
6956
7066
|
return e === "offline" || e === "offlineError";
|
|
6957
7067
|
}
|
|
6958
|
-
function
|
|
7068
|
+
function Pg(e) {
|
|
6959
7069
|
return e === "offlineError";
|
|
6960
7070
|
}
|
|
6961
7071
|
//#endregion
|
|
6962
7072
|
//#region src/utils/opcode-names.ts
|
|
6963
|
-
var
|
|
6964
|
-
for (let [e, t] of Object.entries(
|
|
6965
|
-
function
|
|
6966
|
-
return
|
|
7073
|
+
var Fg = /* @__PURE__ */ new Map();
|
|
7074
|
+
for (let [e, t] of Object.entries(w)) typeof t == "number" && Fg.set(t, e);
|
|
7075
|
+
function Ig(e) {
|
|
7076
|
+
return Fg.get(e) ?? `UNKNOWN_${e}`;
|
|
6967
7077
|
}
|
|
6968
7078
|
//#endregion
|
|
6969
7079
|
//#region src/login/reprovision.ts
|
|
6970
|
-
var
|
|
6971
|
-
function
|
|
7080
|
+
var Lg = "ikon-login-app-route";
|
|
7081
|
+
function Rg(e) {
|
|
6972
7082
|
if (typeof window > "u") return;
|
|
6973
7083
|
try {
|
|
6974
|
-
sessionStorage.setItem(
|
|
7084
|
+
sessionStorage.setItem(Lg, window.location.pathname);
|
|
6975
7085
|
} catch {}
|
|
6976
7086
|
let t = new URL(window.location.href);
|
|
6977
7087
|
t.searchParams.set(Ul, e), window.location.href = t.toString();
|
|
6978
7088
|
}
|
|
6979
|
-
function
|
|
7089
|
+
function zg() {
|
|
6980
7090
|
let e = null;
|
|
6981
7091
|
try {
|
|
6982
|
-
e = sessionStorage.getItem(
|
|
7092
|
+
e = sessionStorage.getItem(Lg), sessionStorage.removeItem(Lg);
|
|
6983
7093
|
} catch {}
|
|
6984
7094
|
return {
|
|
6985
7095
|
appRoute: e,
|
|
@@ -6988,7 +7098,7 @@ function Tg() {
|
|
|
6988
7098
|
}
|
|
6989
7099
|
//#endregion
|
|
6990
7100
|
//#region src/media/ring-buffer.ts
|
|
6991
|
-
var
|
|
7101
|
+
var Bg = class {
|
|
6992
7102
|
static getStorageForCapacity(e, t) {
|
|
6993
7103
|
let n = Int32Array.BYTES_PER_ELEMENT * 2, r = t.BYTES_PER_ELEMENT * e;
|
|
6994
7104
|
return new SharedArrayBuffer(n + r);
|
|
@@ -7039,7 +7149,7 @@ var Eg = class {
|
|
|
7039
7149
|
};
|
|
7040
7150
|
//#endregion
|
|
7041
7151
|
//#region src/worker/audio-capture-worker.ts?worker
|
|
7042
|
-
function
|
|
7152
|
+
function Vg(e) {
|
|
7043
7153
|
return new Worker("" + new URL("assets/audio-capture-worker-CJ5S-nQt.js", import.meta.url).href, {
|
|
7044
7154
|
type: "module",
|
|
7045
7155
|
name: e?.name
|
|
@@ -7047,11 +7157,11 @@ function Dg(e) {
|
|
|
7047
7157
|
}
|
|
7048
7158
|
//#endregion
|
|
7049
7159
|
//#region src/media/ikon-audio-capture.ts
|
|
7050
|
-
var Q =
|
|
7051
|
-
function
|
|
7160
|
+
var Q = C("IkonAudioCapture"), Hg = 3, Ug = 200, Wg = 2e3, Gg = 5e3, Kg = 3e3;
|
|
7161
|
+
function qg(e) {
|
|
7052
7162
|
return new Promise((t) => setTimeout(t, e));
|
|
7053
7163
|
}
|
|
7054
|
-
function
|
|
7164
|
+
function Jg(e) {
|
|
7055
7165
|
switch (e.name) {
|
|
7056
7166
|
case "NotReadableError": return {
|
|
7057
7167
|
action: "retry",
|
|
@@ -7087,14 +7197,14 @@ function Pg(e) {
|
|
|
7087
7197
|
};
|
|
7088
7198
|
}
|
|
7089
7199
|
}
|
|
7090
|
-
function
|
|
7200
|
+
function Yg() {
|
|
7091
7201
|
let e = globalThis.crypto;
|
|
7092
7202
|
return e?.randomUUID ? e.randomUUID() : `cap_${Date.now()}_${Math.floor(Math.random() * 1e9)}`;
|
|
7093
7203
|
}
|
|
7094
|
-
function
|
|
7204
|
+
function Xg() {
|
|
7095
7205
|
return "\nclass RingBuffer {\n static getStorageForCapacity(capacity, type) {\n const indexBytes = Int32Array.BYTES_PER_ELEMENT * 2;\n const dataBytes = type.BYTES_PER_ELEMENT * capacity;\n return new SharedArrayBuffer(indexBytes + dataBytes);\n }\n\n constructor(sharedArrayBuffer, type) {\n this.buf = sharedArrayBuffer;\n this.readWrite = new Int32Array(sharedArrayBuffer, 0, 2);\n const dataOffset = Int32Array.BYTES_PER_ELEMENT * 2;\n const dataLength = (sharedArrayBuffer.byteLength - dataOffset) / Float32Array.BYTES_PER_ELEMENT;\n this.storage = new type(sharedArrayBuffer, dataOffset, dataLength);\n }\n\n get capacity() {\n return this.storage.length;\n }\n\n available_read() {\n const read = Atomics.load(this.readWrite, 0);\n const write = Atomics.load(this.readWrite, 1);\n if (write >= read) return write - read;\n return this.capacity - (read - write);\n }\n\n available_write() {\n return this.capacity - this.available_read() - 1;\n }\n\n push(input) {\n const writable = Math.min(this.available_write(), input.length);\n if (writable <= 0) return 0;\n\n const read = Atomics.load(this.readWrite, 0);\n let write = Atomics.load(this.readWrite, 1);\n\n const firstPart = Math.min(writable, this.capacity - write);\n this.storage.set(input.subarray(0, firstPart), write);\n const remaining = writable - firstPart;\n if (remaining > 0) {\n this.storage.set(input.subarray(firstPart, firstPart + remaining), 0);\n }\n\n write = (write + writable) % this.capacity;\n Atomics.store(this.readWrite, 1, write);\n Atomics.notify(this.readWrite, 1);\n if (this.available_read() > this.capacity - 2) {\n Atomics.store(this.readWrite, 0, read);\n }\n\n return writable;\n }\n}\n\nconst RENDER_QUANTUM_SIZE = 128;\n\nclass IkonAudioCaptureProcessor extends AudioWorkletProcessor {\n constructor(options) {\n super();\n const cfg = options?.processorOptions || {};\n this.channels = cfg.channels || 1;\n this.transport = cfg.transport || 'pcm';\n this.ring = null;\n this.temp = new Float32Array(RENDER_QUANTUM_SIZE * this.channels);\n\n if (this.transport === 'sab' && cfg.sharedArrayBuffer) {\n this.ring = new RingBuffer(cfg.sharedArrayBuffer, Float32Array);\n }\n\n // Pre-allocated rotating transfer buffers for PCM mode\n // We use two buffers and alternate between them since postMessage transfers ownership\n this.transferBuffers = [\n new Float32Array(RENDER_QUANTUM_SIZE),\n new Float32Array(RENDER_QUANTUM_SIZE)\n ];\n this.transferBufferIndex = 0;\n\n this.port.postMessage({ type: 'ready' });\n }\n\n process(inputs) {\n const input = inputs[0];\n if (!input || input.length === 0) {\n return true;\n }\n\n const frames = input[0]?.length || 0;\n if (frames === 0) {\n return true;\n }\n\n const channelCount = input.length;\n for (let i = 0; i < frames; i++) {\n let sum = 0;\n for (let ch = 0; ch < channelCount; ch++) {\n const channel = input[ch];\n sum += channel ? (channel[i] || 0) : 0;\n }\n this.temp[i] = sum / channelCount;\n }\n\n const out = this.temp.subarray(0, frames);\n if (this.transport === 'sab' && this.ring) {\n this.ring.push(out);\n return true;\n }\n\n // Use rotating pre-allocated transfer buffer\n let buffer = this.transferBuffers[this.transferBufferIndex];\n // If buffer was transferred (detached), recreate it\n if (buffer.byteLength === 0) {\n buffer = new Float32Array(RENDER_QUANTUM_SIZE);\n this.transferBuffers[this.transferBufferIndex] = buffer;\n }\n buffer.set(out);\n const toSend = buffer.subarray(0, frames);\n this.port.postMessage({ type: 'pcm', pcm: toSend }, [buffer.buffer]);\n // Flip to next buffer for next call\n this.transferBufferIndex = (this.transferBufferIndex + 1) % 2;\n return true;\n }\n}\n\nregisterProcessor('ikon-audio-capture', IkonAudioCaptureProcessor);\n";
|
|
7096
7206
|
}
|
|
7097
|
-
var
|
|
7207
|
+
var Zg = class e {
|
|
7098
7208
|
client;
|
|
7099
7209
|
static RESUME_TIMEOUT_MS = 3e3;
|
|
7100
7210
|
worker = null;
|
|
@@ -7155,7 +7265,7 @@ var Lg = class e {
|
|
|
7155
7265
|
notifyError(e, t, n, r) {
|
|
7156
7266
|
if (e.stopped) return;
|
|
7157
7267
|
let i = Date.now(), a = t.name;
|
|
7158
|
-
if (e.lastErrorReason === n && e.lastErrorName === a && i - e.lastErrorTime <
|
|
7268
|
+
if (e.lastErrorReason === n && e.lastErrorName === a && i - e.lastErrorTime < Gg) return;
|
|
7159
7269
|
e.lastErrorTime = i, e.lastErrorReason = n, e.lastErrorName = a;
|
|
7160
7270
|
let o = this.config.autoRestartPolicy;
|
|
7161
7271
|
if (o?.enabled && r) {
|
|
@@ -7213,7 +7323,7 @@ var Lg = class e {
|
|
|
7213
7323
|
if (e.ctx.state === "running") return !0;
|
|
7214
7324
|
if (e.ctx.state !== "suspended") return !1;
|
|
7215
7325
|
let r = Date.now();
|
|
7216
|
-
if (!n && r - e.lastResumeAttemptTime <
|
|
7326
|
+
if (!n && r - e.lastResumeAttemptTime < Kg) return Q.debug(`Resume attempt from ${t} skipped (cooldown)`), !1;
|
|
7217
7327
|
e.lastResumeAttemptTime = r, this.emitDiagnostic({
|
|
7218
7328
|
event: "resume-attempt",
|
|
7219
7329
|
captureId: e.captureId,
|
|
@@ -7249,7 +7359,7 @@ var Lg = class e {
|
|
|
7249
7359
|
attemptResume(e, t, n = !1) {
|
|
7250
7360
|
if (e.stopped || e.ctx.state !== "suspended") return;
|
|
7251
7361
|
let r = Date.now();
|
|
7252
|
-
if (!n && r - e.lastResumeAttemptTime <
|
|
7362
|
+
if (!n && r - e.lastResumeAttemptTime < Kg) {
|
|
7253
7363
|
Q.debug(`Resume attempt from ${t} skipped (cooldown)`);
|
|
7254
7364
|
return;
|
|
7255
7365
|
}
|
|
@@ -7348,7 +7458,7 @@ var Lg = class e {
|
|
|
7348
7458
|
}
|
|
7349
7459
|
ensureWorker() {
|
|
7350
7460
|
if (this.worker) return this.worker;
|
|
7351
|
-
let e = new
|
|
7461
|
+
let e = new Vg();
|
|
7352
7462
|
return this.worker = e, e.addEventListener("message", (e) => {
|
|
7353
7463
|
let t = e.data;
|
|
7354
7464
|
if (t?.type === "error") {
|
|
@@ -7374,7 +7484,7 @@ var Lg = class e {
|
|
|
7374
7484
|
if (!this.client.sessionId) throw Error("Cannot start audio capture before client is connected");
|
|
7375
7485
|
let e = this.ensureWorker();
|
|
7376
7486
|
if (!this.sendPort) {
|
|
7377
|
-
let t = this.client.createProtocolSendPort({ opcodeGroupsMask:
|
|
7487
|
+
let t = this.client.createProtocolSendPort({ opcodeGroupsMask: w.GROUP_AUDIO });
|
|
7378
7488
|
if (!t) throw Error("Failed to create protocol send port for audio capture");
|
|
7379
7489
|
this.sendPort = t, e.postMessage({
|
|
7380
7490
|
type: "attachSendPort",
|
|
@@ -7446,25 +7556,25 @@ var Lg = class e {
|
|
|
7446
7556
|
reason: "unknown",
|
|
7447
7557
|
canRetry: !1
|
|
7448
7558
|
};
|
|
7449
|
-
for (let r = 0; r <
|
|
7559
|
+
for (let r = 0; r < Hg; r++) try {
|
|
7450
7560
|
return {
|
|
7451
7561
|
stream: await navigator.mediaDevices.getUserMedia({ audio: e }),
|
|
7452
7562
|
error: t,
|
|
7453
7563
|
errorInfo: n
|
|
7454
7564
|
};
|
|
7455
7565
|
} catch (e) {
|
|
7456
|
-
if (t = e instanceof Error ? e : Error(String(e)), n =
|
|
7566
|
+
if (t = e instanceof Error ? e : Error(String(e)), n = Jg(t), Q.debug(`getUserMedia attempt ${r + 1}/${Hg} failed: ${t.name} (action: ${n.action})`), this.emitDiagnostic({
|
|
7457
7567
|
event: "retry",
|
|
7458
7568
|
details: {
|
|
7459
7569
|
attempt: r + 1,
|
|
7460
|
-
maxAttempts:
|
|
7570
|
+
maxAttempts: Hg,
|
|
7461
7571
|
errorName: t.name,
|
|
7462
7572
|
action: n.action
|
|
7463
7573
|
}
|
|
7464
7574
|
}), n.action !== "retry") break;
|
|
7465
7575
|
if (r < 2) {
|
|
7466
|
-
let e =
|
|
7467
|
-
Q.debug(`Retrying getUserMedia in ${e}ms`), await
|
|
7576
|
+
let e = Ug * (r + 1);
|
|
7577
|
+
Q.debug(`Retrying getUserMedia in ${e}ms`), await qg(e);
|
|
7468
7578
|
}
|
|
7469
7579
|
}
|
|
7470
7580
|
return {
|
|
@@ -7474,8 +7584,8 @@ var Lg = class e {
|
|
|
7474
7584
|
};
|
|
7475
7585
|
}
|
|
7476
7586
|
async ensureWorklet(e) {
|
|
7477
|
-
if (!
|
|
7478
|
-
if (this.workletModuleUrl ||= URL.createObjectURL(new Blob([
|
|
7587
|
+
if (!Te(e)) throw Error("AudioWorklet is not supported in this browser");
|
|
7588
|
+
if (this.workletModuleUrl ||= URL.createObjectURL(new Blob([Xg()], { type: "text/javascript" })), this.workletReady && this.workletContext === e) try {
|
|
7479
7589
|
await this.workletReady;
|
|
7480
7590
|
return;
|
|
7481
7591
|
} catch {
|
|
@@ -7502,7 +7612,7 @@ var Lg = class e {
|
|
|
7502
7612
|
if (!t) throw Error("Cannot start audio capture before client is connected");
|
|
7503
7613
|
if (this.client.isWebRtcCaptureAvailable) return this.startMicWebRtc(e);
|
|
7504
7614
|
this.client.isWebRtcEnabled && Q.warn("WebRTC unavailable, capturing audio via protocol channel");
|
|
7505
|
-
let n =
|
|
7615
|
+
let n = Yg(), r = {
|
|
7506
7616
|
captureId: n,
|
|
7507
7617
|
aborted: !1,
|
|
7508
7618
|
stream: null,
|
|
@@ -7537,10 +7647,10 @@ var Lg = class e {
|
|
|
7537
7647
|
r.source = u;
|
|
7538
7648
|
let d = a.createGain();
|
|
7539
7649
|
d.gain.value = 0, d.connect(a.destination), r.gain = d;
|
|
7540
|
-
let f =
|
|
7650
|
+
let f = Se() ? "sab" : "pcm", p;
|
|
7541
7651
|
if (f === "sab") {
|
|
7542
7652
|
let e = Math.floor(a.sampleRate * 10);
|
|
7543
|
-
p =
|
|
7653
|
+
p = Bg.getStorageForCapacity(e, Float32Array);
|
|
7544
7654
|
}
|
|
7545
7655
|
let m = this.ensureWorker(), h = e.onStopped;
|
|
7546
7656
|
m.postMessage({
|
|
@@ -7639,7 +7749,7 @@ var Lg = class e {
|
|
|
7639
7749
|
_.stopped || (m.postMessage({
|
|
7640
7750
|
type: "endSegment",
|
|
7641
7751
|
captureId: n
|
|
7642
|
-
}),
|
|
7752
|
+
}), be() && _.stop());
|
|
7643
7753
|
},
|
|
7644
7754
|
stop: async (e = "user") => {
|
|
7645
7755
|
if (!_.stopped) {
|
|
@@ -7688,7 +7798,7 @@ var Lg = class e {
|
|
|
7688
7798
|
};
|
|
7689
7799
|
this.setupAudioContextStateListener(a, _), this.setupVisibilityChangeListener(_), this.setupBFCacheHandlers(_), _.healthCheckTimer = setInterval(() => {
|
|
7690
7800
|
this.performHealthCheck(_);
|
|
7691
|
-
},
|
|
7801
|
+
}, Wg);
|
|
7692
7802
|
let te = () => {
|
|
7693
7803
|
_.stopped || (Q.warn(`Microphone track ended unexpectedly, captureId=${n.substring(0, 8)}`), this.handleRecoverableError(_, /* @__PURE__ */ Error("Microphone track ended unexpectedly"), "track-ended"));
|
|
7694
7804
|
};
|
|
@@ -7837,8 +7947,8 @@ var Lg = class e {
|
|
|
7837
7947
|
let t = this.captures.get(e);
|
|
7838
7948
|
return !t || t.stopped ? !1 : this.attemptResumeAsync(t, "userGesture", !0);
|
|
7839
7949
|
}
|
|
7840
|
-
},
|
|
7841
|
-
function
|
|
7950
|
+
}, Qg = 3e3;
|
|
7951
|
+
function $g(e, t, n, r) {
|
|
7842
7952
|
if (!n && !r) return {
|
|
7843
7953
|
width: e,
|
|
7844
7954
|
height: t
|
|
@@ -7849,7 +7959,7 @@ function zg(e, t, n, r) {
|
|
|
7849
7959
|
height: Math.max(1, Math.floor(t * o))
|
|
7850
7960
|
};
|
|
7851
7961
|
}
|
|
7852
|
-
async function
|
|
7962
|
+
async function e_(e, t) {
|
|
7853
7963
|
let n = t.mime ?? "image/jpeg", r = t.quality ?? .92;
|
|
7854
7964
|
if (typeof OffscreenCanvas < "u" && e instanceof OffscreenCanvas) try {
|
|
7855
7965
|
return await e.convertToBlob({
|
|
@@ -7864,7 +7974,7 @@ async function Bg(e, t) {
|
|
|
7864
7974
|
}, n, r);
|
|
7865
7975
|
});
|
|
7866
7976
|
}
|
|
7867
|
-
var
|
|
7977
|
+
var t_ = class {
|
|
7868
7978
|
async captureFromStream(e, t = {}) {
|
|
7869
7979
|
let n = e.getVideoTracks()[0];
|
|
7870
7980
|
if (!n) throw Error("No video track available in the provided stream");
|
|
@@ -7875,7 +7985,7 @@ var Vg = class {
|
|
|
7875
7985
|
} catch {}
|
|
7876
7986
|
try {
|
|
7877
7987
|
await new Promise((e, t) => {
|
|
7878
|
-
let n = setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for video metadata")),
|
|
7988
|
+
let n = setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for video metadata")), Qg);
|
|
7879
7989
|
r.addEventListener("loadedmetadata", () => {
|
|
7880
7990
|
clearTimeout(n), e();
|
|
7881
7991
|
}, { once: !0 }), r.addEventListener("error", () => {
|
|
@@ -7885,7 +7995,7 @@ var Vg = class {
|
|
|
7885
7995
|
try {
|
|
7886
7996
|
await r.play();
|
|
7887
7997
|
} catch {}
|
|
7888
|
-
let { width: e, height: i } =
|
|
7998
|
+
let { width: e, height: i } = $g(r.videoWidth || (n.getSettings().width ?? 1280), r.videoHeight || (n.getSettings().height ?? 720), t.width, t.height), a;
|
|
7889
7999
|
if (typeof OffscreenCanvas < "u") a = new OffscreenCanvas(e, i);
|
|
7890
8000
|
else {
|
|
7891
8001
|
let t = document.createElement("canvas");
|
|
@@ -7894,7 +8004,7 @@ var Vg = class {
|
|
|
7894
8004
|
let o = a.getContext("2d", { alpha: !1 });
|
|
7895
8005
|
if (!o) throw Error("2D canvas context unavailable");
|
|
7896
8006
|
o.drawImage(r, 0, 0, e, i);
|
|
7897
|
-
let s = await
|
|
8007
|
+
let s = await e_(a, t), c = await s.arrayBuffer();
|
|
7898
8008
|
return {
|
|
7899
8009
|
mime: s.type || t.mime || "image/jpeg",
|
|
7900
8010
|
width: e,
|
|
@@ -7935,7 +8045,7 @@ var Vg = class {
|
|
|
7935
8045
|
} catch {}
|
|
7936
8046
|
try {
|
|
7937
8047
|
await new Promise((e, t) => {
|
|
7938
|
-
let n = setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for video metadata")),
|
|
8048
|
+
let n = setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for video metadata")), Qg);
|
|
7939
8049
|
r.addEventListener("loadedmetadata", () => {
|
|
7940
8050
|
clearTimeout(n), e();
|
|
7941
8051
|
}, { once: !0 }), r.addEventListener("error", () => {
|
|
@@ -7945,7 +8055,7 @@ var Vg = class {
|
|
|
7945
8055
|
try {
|
|
7946
8056
|
await r.play();
|
|
7947
8057
|
} catch {}
|
|
7948
|
-
let { width: t, height: i } =
|
|
8058
|
+
let { width: t, height: i } = $g(r.videoWidth || (n.getSettings().width ?? 1280), r.videoHeight || (n.getSettings().height ?? 720), e.width, e.height), a;
|
|
7949
8059
|
if (typeof OffscreenCanvas < "u") a = new OffscreenCanvas(t, i);
|
|
7950
8060
|
else {
|
|
7951
8061
|
let e = document.createElement("canvas");
|
|
@@ -7954,7 +8064,7 @@ var Vg = class {
|
|
|
7954
8064
|
let o = a.getContext("2d", { alpha: !1 });
|
|
7955
8065
|
if (!o) throw Error("2D canvas context unavailable");
|
|
7956
8066
|
o.drawImage(r, 0, 0, t, i);
|
|
7957
|
-
let s = await
|
|
8067
|
+
let s = await e_(a, e), c = await s.arrayBuffer();
|
|
7958
8068
|
return {
|
|
7959
8069
|
mime: s.type || e.mime || "image/jpeg",
|
|
7960
8070
|
width: t,
|
|
@@ -7978,11 +8088,11 @@ var Vg = class {
|
|
|
7978
8088
|
}
|
|
7979
8089
|
async captureFromNativeCamera(e = {}) {
|
|
7980
8090
|
if (typeof document > "u") throw Error("Native camera capture requires a DOM environment");
|
|
7981
|
-
let t = await
|
|
7982
|
-
return t ? await
|
|
8091
|
+
let t = await n_(e.facing);
|
|
8092
|
+
return t ? await r_(t, e) : null;
|
|
7983
8093
|
}
|
|
7984
8094
|
};
|
|
7985
|
-
function
|
|
8095
|
+
function n_(e) {
|
|
7986
8096
|
return new Promise((t) => {
|
|
7987
8097
|
let n = document.createElement("input");
|
|
7988
8098
|
n.type = "file", n.accept = "image/*", n.setAttribute("capture", e ?? "environment"), n.style.position = "fixed", n.style.left = "-99999px", n.style.top = "0";
|
|
@@ -8008,7 +8118,7 @@ function Hg(e) {
|
|
|
8008
8118
|
n.click();
|
|
8009
8119
|
});
|
|
8010
8120
|
}
|
|
8011
|
-
async function
|
|
8121
|
+
async function r_(e, t) {
|
|
8012
8122
|
let n = URL.createObjectURL(e), r;
|
|
8013
8123
|
try {
|
|
8014
8124
|
r = await new Promise((e, t) => {
|
|
@@ -8018,7 +8128,7 @@ async function Ug(e, t) {
|
|
|
8018
8128
|
} finally {
|
|
8019
8129
|
URL.revokeObjectURL(n);
|
|
8020
8130
|
}
|
|
8021
|
-
let i = r.naturalWidth || r.width, a = r.naturalHeight || r.height, { width: o, height: s } =
|
|
8131
|
+
let i = r.naturalWidth || r.width, a = r.naturalHeight || r.height, { width: o, height: s } = $g(i, a, t.width, t.height), c = t.mime ?? (e.type === "image/png" ? "image/png" : "image/jpeg"), l = t.quality ?? .92;
|
|
8022
8132
|
if (o === i && s === a && e.type === c) {
|
|
8023
8133
|
let t = await e.arrayBuffer();
|
|
8024
8134
|
return {
|
|
@@ -8045,25 +8155,25 @@ async function Ug(e, t) {
|
|
|
8045
8155
|
}
|
|
8046
8156
|
//#endregion
|
|
8047
8157
|
//#region src/worker/video-capture-worker.ts?worker
|
|
8048
|
-
function
|
|
8049
|
-
return new Worker("" + new URL("assets/video-capture-worker-
|
|
8158
|
+
function i_(e) {
|
|
8159
|
+
return new Worker("" + new URL("assets/video-capture-worker-D5jsT6I4.js", import.meta.url).href, {
|
|
8050
8160
|
type: "module",
|
|
8051
8161
|
name: e?.name
|
|
8052
8162
|
});
|
|
8053
8163
|
}
|
|
8054
8164
|
//#endregion
|
|
8055
8165
|
//#region src/media/ikon-video-capture.ts
|
|
8056
|
-
var $ =
|
|
8057
|
-
function
|
|
8166
|
+
var $ = C("IkonVideoCapture");
|
|
8167
|
+
function a_() {
|
|
8058
8168
|
let e = globalThis.crypto;
|
|
8059
8169
|
return e?.randomUUID ? e.randomUUID() : `cap_${Date.now()}_${Math.floor(Math.random() * 1e9)}`;
|
|
8060
8170
|
}
|
|
8061
|
-
function
|
|
8171
|
+
function o_() {
|
|
8062
8172
|
let e = globalThis.MediaStreamTrackProcessor;
|
|
8063
8173
|
if (!e) throw Error("MediaStreamTrackProcessor is not available in this browser");
|
|
8064
8174
|
return e;
|
|
8065
8175
|
}
|
|
8066
|
-
var
|
|
8176
|
+
var s_ = class {
|
|
8067
8177
|
client;
|
|
8068
8178
|
worker = null;
|
|
8069
8179
|
protocolPort = null;
|
|
@@ -8079,7 +8189,7 @@ var qg = class {
|
|
|
8079
8189
|
}
|
|
8080
8190
|
ensureWorker() {
|
|
8081
8191
|
if (this.worker) return this.worker;
|
|
8082
|
-
let e = new
|
|
8192
|
+
let e = new i_();
|
|
8083
8193
|
return this.worker = e, e.addEventListener("message", (e) => {
|
|
8084
8194
|
let t = e.data;
|
|
8085
8195
|
if (t?.type === "error") {
|
|
@@ -8105,7 +8215,7 @@ var qg = class {
|
|
|
8105
8215
|
if (!this.client.sessionId) throw Error("Cannot start video capture before client is connected");
|
|
8106
8216
|
let e = this.ensureWorker();
|
|
8107
8217
|
if (!this.sendPort) {
|
|
8108
|
-
let t = this.client.createProtocolSendPort({ opcodeGroupsMask:
|
|
8218
|
+
let t = this.client.createProtocolSendPort({ opcodeGroupsMask: w.GROUP_VIDEO });
|
|
8109
8219
|
if (!t) throw Error("Failed to create protocol send port for video capture");
|
|
8110
8220
|
this.sendPort = t, e.postMessage({
|
|
8111
8221
|
type: "attachSendPort",
|
|
@@ -8113,7 +8223,7 @@ var qg = class {
|
|
|
8113
8223
|
}, [t.port]);
|
|
8114
8224
|
}
|
|
8115
8225
|
if (!this.protocolPort) {
|
|
8116
|
-
let t = this.client.createProtocolMessagePort({ opcodeGroupsMask:
|
|
8226
|
+
let t = this.client.createProtocolMessagePort({ opcodeGroupsMask: w.GROUP_VIDEO });
|
|
8117
8227
|
t && (this.protocolPort = t, e.postMessage({
|
|
8118
8228
|
type: "attachProtocolPort",
|
|
8119
8229
|
port: t.port
|
|
@@ -8189,10 +8299,10 @@ var qg = class {
|
|
|
8189
8299
|
if (this.client.isWebRtcCaptureAvailable && e.sourceType === "camera") return this.startCameraWebRtc(e);
|
|
8190
8300
|
if (this.client.isWebRtcCaptureAvailable && e.sourceType === "screen") return this.startScreenWebRtc(e);
|
|
8191
8301
|
this.client.isWebRtcEnabled && $.warn("WebRTC unavailable, capturing video via protocol channel"), this.ensurePorts();
|
|
8192
|
-
let n =
|
|
8302
|
+
let n = a_(), r = await this.getMediaStream(e), i = r.getVideoTracks()[0];
|
|
8193
8303
|
if (!i) throw r.getTracks().forEach((e) => e.stop()), Error("No video track available");
|
|
8194
8304
|
e.sourceType === "screen" && await new Promise((e) => setTimeout(e, 200));
|
|
8195
|
-
let a = i.getSettings(), o = e.sourceType === "screen" ? a.width ?? 1280 : e.options?.width ?? a.width ?? 1280, s = e.sourceType === "screen" ? a.height ?? 720 : e.options?.height ?? a.height ?? 720, c = new (
|
|
8305
|
+
let a = i.getSettings(), o = e.sourceType === "screen" ? a.width ?? 1280 : e.options?.width ?? a.width ?? 1280, s = e.sourceType === "screen" ? a.height ?? 720 : e.options?.height ?? a.height ?? 720, c = new (o_())({ track: i }).readable, l = this.allocateTrackId(), u = this.ensureWorker(), d = e.sourceType, f = e.onStopped;
|
|
8196
8306
|
u.postMessage({
|
|
8197
8307
|
type: "start",
|
|
8198
8308
|
captureId: n,
|
|
@@ -8315,16 +8425,16 @@ var qg = class {
|
|
|
8315
8425
|
}
|
|
8316
8426
|
this.protocolPort?.close(), this.protocolPort = null, this.sendPort?.close(), this.sendPort = null;
|
|
8317
8427
|
}
|
|
8318
|
-
},
|
|
8428
|
+
}, c_ = /* @__PURE__ */ d({ IkonMediaCapture: () => l_ }), l_ = class {
|
|
8319
8429
|
audio;
|
|
8320
8430
|
video;
|
|
8321
8431
|
image;
|
|
8322
8432
|
constructor(e, t) {
|
|
8323
|
-
this.audio = new
|
|
8433
|
+
this.audio = new Zg(e, t?.audio), this.video = new s_(e), this.image = new t_();
|
|
8324
8434
|
}
|
|
8325
8435
|
dispose() {
|
|
8326
8436
|
this.audio.dispose(), this.video.dispose();
|
|
8327
8437
|
}
|
|
8328
8438
|
};
|
|
8329
8439
|
//#endregion
|
|
8330
|
-
export { Ml as AccessDeniedError,
|
|
8440
|
+
export { Ml as AccessDeniedError, kg as AppMessaging, O as AppStartupFailedError, D as AuthRejectedError, T as AuthenticationError, Il as BrowserNotSupportedError, Du as Channel, ku as ChannelManager, ne as ClientType, Dl as ConnectionError, m as ContextType, Tg as EndpointSelector, b as EntrypointType, $m as FunctionCallError, ih as FunctionRegistry, xd as IKON_AUTH_BASE_URL, bd as IKON_AUTH_URL_DEV, yd as IKON_AUTH_URL_PROD, vd as IKON_BACKEND_URL_DEV, _d as IKON_BACKEND_URL_PROD, Zh as IKON_INSPECT_MODE_CHANGED_EVENT, Wl as IKON_PARAM_AUDIO, Xl as IKON_PARAM_AUTH, Vl as IKON_PARAM_DEBUG, Yl as IKON_PARAM_DEBUG_OVERLAY, Jl as IKON_PARAM_INSPECT, Hl as IKON_PARAM_LANG, Rl as IKON_PARAM_PROXY, Zl as IKON_PARAM_RETRY, Ul as IKON_PARAM_SERVER_URL, Gl as IKON_PARAM_VIDEO, Kl as IKON_PARAM_WEBRTC, zl as IKON_PARAM_WEBSOCKET, Bl as IKON_PARAM_WEBTRANSPORT, Zg as IkonAudioCapture, ie as IkonAudioPlayback, Og as IkonClient, t_ as IkonImageCapture, de as IkonMedia, l_ as IkonMediaCapture, s_ as IkonVideoCapture, le as IkonVideoPlayback, Ol as KeepaliveTimeoutError, S as LogLevel, kl as MaxRetriesExceededError, w as Opcode, Al as ProvisioningTimeoutError, Pl as ServerFullError, Fl as ServerUnavailableError, Nl as SessionNotFoundError, jl as SpaceNotFoundError, E as TransportError, p as UserType, Kh as VisemeTracker, Nu as WEBRTC_AUDIO_BITRATE, Mu as WEBRTC_AUDIO_CHANNELS, Au as WEBRTC_AUDIO_CODEC, Pu as WEBRTC_AUDIO_JITTER_BUFFER_TARGET_MS, ju as WEBRTC_AUDIO_SAMPLE_RATE, zu as WEBRTC_BUNDLE_POLICY, Gu as WEBRTC_DATA_CHANNEL_LABEL, qu as WEBRTC_DATA_CHANNEL_MAX_RETRANSMITS, Ku as WEBRTC_DATA_CHANNEL_ORDERED, Uu as WEBRTC_MAX_AUDIO_TRACKS, Wu as WEBRTC_MAX_VIDEO_TRACKS, Bu as WEBRTC_RTCP_MUX_POLICY, Fu as WEBRTC_VIDEO_CODEC, Iu as WEBRTC_VIDEO_MAX_BITRATE, Lu as WEBRTC_VIDEO_MAX_FRAMERATE, Ju as WebRTCConnection, Yu as WebRTCSignaling, gd as abortSignalAny, I as abortSignalTimeout, Ag as appMessaging, v as asProtocolMessage, sg as checkBrowserSupport, gm as clearDeviceId, Pp as clearLogBuffer, ud as clearLoginPrompt, zg as consumeLoginHandoff, pd as consumeLoginPendingCall, C as createLogger, Jd as createPkceChallenge, Pd as deriveAuthUrl, Md as deriveBackendType, jd as deriveBackendUrl, Fd as deriveCrossOriginAuthUrl, tg as enableInspectMode, _m as extractUserIdFromToken, Np as flushLogs, cu as getAudioParam, mu as getAuthSameOriginParam, jp as getBufferedLogs, um as getConnectTraceId, pu as getDebugOverlayParam, au as getDebugParam, fu as getInspectParam, ou as getLangParam, Fp as getLogBufferSize, Ce as getLogLevel, xe as getLogSink, cd as getLoginPromptState, Ig as getOpcodeName, hm as getOrCreateDeviceId, nu as getProxyParam, j as getRetryParam, Od as getSameOriginAuthUrl, su as getServerUrlParam, lu as getVideoParam, uu as getWebRtcParam, ru as getWebSocketParam, iu as getWebTransportParam, Jh as initializeDebugMode, $h as initializeInspectMode, kp as initializeLogSink, Te as isAudioWorkletSupported, R as isBrowserEnvironment, Vd as isCloudEnvironment, Mg as isConnected, jg as isConnecting, Yh as isDebugModeEnabled, Qd as isEmbedded, Pg as isError, eg as isInspectModeEnabled, mh as isMobileBrowserLikely, Ng as isOffline, qd as isPkceSupported, Se as isSharedArrayBufferSupported, wu as isWebTransportSupported, ph as loginErrorInterceptor, Bd as parseUrlParams, pm as randomUuid, c as readOpcode, u as readOpcodeGroup, i as readProtocolMessageHeaders, Sp as registerBrowserFunctions, fm as reportConnectTimeline, Rg as reprovisionAfterLogin, ye as setLogLevel, ve as setLogSink, ld as setLoginPromptRequired, tu as setSdkUrlParam, Ap as setSendLogsCallback, $d as startEmbeddedOAuthSignIn, nm as startLogSender, im as stopLogSender, dd as subscribeLoginPrompt, ge as subscribeToLogEvents, Mp as takeBufferedLogs, Yd as takePkceVerifier, Qm as withResultData };
|