@ikonai/sdk 1.6.0 → 1.7.0
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/index.js +752 -661
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1743,72 +1743,72 @@ function eu(e, t, n) {
|
|
|
1743
1743
|
}
|
|
1744
1744
|
//#endregion
|
|
1745
1745
|
//#region src/errors/index.ts
|
|
1746
|
-
var
|
|
1746
|
+
var E = class extends Error {
|
|
1747
1747
|
cause;
|
|
1748
1748
|
constructor(e, t) {
|
|
1749
1749
|
super(e), this.cause = t, this.name = "ConnectionError";
|
|
1750
1750
|
}
|
|
1751
|
-
},
|
|
1751
|
+
}, D = class extends E {
|
|
1752
1752
|
constructor(e, t) {
|
|
1753
1753
|
super(e, t), this.name = "AuthenticationError";
|
|
1754
1754
|
}
|
|
1755
|
-
},
|
|
1755
|
+
}, O = class extends E {
|
|
1756
1756
|
constructor(e, t) {
|
|
1757
1757
|
super(e, t), this.name = "TransportError";
|
|
1758
1758
|
}
|
|
1759
|
-
},
|
|
1759
|
+
}, tu = class extends O {
|
|
1760
1760
|
constructor(e) {
|
|
1761
1761
|
super(`No keepalive received within ${e}ms`), this.name = "KeepaliveTimeoutError";
|
|
1762
1762
|
}
|
|
1763
|
-
},
|
|
1763
|
+
}, k = class extends O {
|
|
1764
1764
|
constructor(e, t) {
|
|
1765
1765
|
super(e, t), this.name = "AuthRejectedError";
|
|
1766
1766
|
}
|
|
1767
|
-
},
|
|
1767
|
+
}, nu = class extends E {
|
|
1768
1768
|
constructor(e) {
|
|
1769
1769
|
super(`Maximum reconnection attempts (${e}) exceeded`), this.name = "MaxRetriesExceededError";
|
|
1770
1770
|
}
|
|
1771
|
-
},
|
|
1771
|
+
}, ru = class extends D {
|
|
1772
1772
|
constructor(e) {
|
|
1773
1773
|
super(`App session provisioning timeout after ${e}ms`), this.name = "ProvisioningTimeoutError";
|
|
1774
1774
|
}
|
|
1775
|
-
},
|
|
1775
|
+
}, iu = class extends D {
|
|
1776
1776
|
constructor(e = "The app failed to start") {
|
|
1777
1777
|
super(e), this.name = "AppStartupFailedError";
|
|
1778
1778
|
}
|
|
1779
|
-
},
|
|
1779
|
+
}, au = class extends D {
|
|
1780
1780
|
constructor(e) {
|
|
1781
1781
|
super(`Space not found for domain: ${e}`), this.name = "SpaceNotFoundError";
|
|
1782
1782
|
}
|
|
1783
|
-
},
|
|
1783
|
+
}, ou = class extends D {
|
|
1784
1784
|
reason;
|
|
1785
1785
|
constructor(e, t) {
|
|
1786
1786
|
super(e), this.reason = t, this.name = "AccessDeniedError";
|
|
1787
1787
|
}
|
|
1788
|
-
},
|
|
1788
|
+
}, su = class extends D {
|
|
1789
1789
|
constructor(e) {
|
|
1790
1790
|
super(e), this.name = "CredentialRejectedError";
|
|
1791
1791
|
}
|
|
1792
|
-
},
|
|
1792
|
+
}, cu = class extends D {
|
|
1793
1793
|
sessionIdentityHash;
|
|
1794
1794
|
constructor(e) {
|
|
1795
1795
|
super(`No live app session for sessionIdentityHash ${e}`), this.sessionIdentityHash = e, this.name = "SessionNotFoundError";
|
|
1796
1796
|
}
|
|
1797
|
-
},
|
|
1797
|
+
}, lu = class extends D {
|
|
1798
1798
|
constructor(e) {
|
|
1799
1799
|
super(e), this.name = "ServerFullError";
|
|
1800
1800
|
}
|
|
1801
|
-
},
|
|
1801
|
+
}, uu = class extends D {
|
|
1802
1802
|
status;
|
|
1803
1803
|
constructor(e, t) {
|
|
1804
1804
|
super(e), this.status = t, this.name = "ServerUnavailableError";
|
|
1805
1805
|
}
|
|
1806
|
-
},
|
|
1806
|
+
}, du = class extends E {
|
|
1807
1807
|
missingFeatures;
|
|
1808
1808
|
constructor(e) {
|
|
1809
1809
|
super(`Browser is not supported: missing required features (${e.join(", ")})`), this.missingFeatures = e, this.name = "BrowserNotSupportedError";
|
|
1810
1810
|
}
|
|
1811
|
-
},
|
|
1811
|
+
}, fu = class extends E {
|
|
1812
1812
|
pinnedTransport;
|
|
1813
1813
|
pinnedTier;
|
|
1814
1814
|
offeredTypes;
|
|
@@ -1819,7 +1819,7 @@ var tu = class extends Error {
|
|
|
1819
1819
|
};
|
|
1820
1820
|
//#endregion
|
|
1821
1821
|
//#region src/utils/delay.ts
|
|
1822
|
-
function
|
|
1822
|
+
function pu(e, t) {
|
|
1823
1823
|
return new Promise((n, r) => {
|
|
1824
1824
|
let i = () => {
|
|
1825
1825
|
clearTimeout(a), r(new DOMException("Aborted", "AbortError"));
|
|
@@ -1835,34 +1835,34 @@ function mu(e, t) {
|
|
|
1835
1835
|
}
|
|
1836
1836
|
//#endregion
|
|
1837
1837
|
//#region src/utils/query-params.ts
|
|
1838
|
-
var
|
|
1839
|
-
function
|
|
1838
|
+
var mu = "ikon-proxy", hu = "ikon-transport", gu = "ikon-connect", _u = "ikon-session", vu = "ikon-same-origin", yu = "ikon-debug", bu = "ikon-debug-overlay", xu = "ikon-inspect", Su = "ikon-lang", Cu = "ikon-audio", wu = "ikon-video", Tu = "ikon-webrtc", Eu = "ikon-ice-transport", Du = "ikon-retry", Ou = "ikon-snapshot", ku = "ikon-signed-out", Au = "ikon_token", ju = "ikon_code", Mu = "ikon_provider", Nu = "ikon_pkce";
|
|
1839
|
+
function A(e) {
|
|
1840
1840
|
if (typeof window > "u") return null;
|
|
1841
1841
|
let t = new URLSearchParams(window.location.search), n = t.get(e);
|
|
1842
1842
|
return n === null ? t.get(e.replace(/-/g, "_")) : n;
|
|
1843
1843
|
}
|
|
1844
|
-
function
|
|
1845
|
-
let t =
|
|
1844
|
+
function j(e) {
|
|
1845
|
+
let t = A(e);
|
|
1846
1846
|
return t === "true" || t !== "false" && null;
|
|
1847
1847
|
}
|
|
1848
|
-
function
|
|
1848
|
+
function Pu(e) {
|
|
1849
1849
|
if (typeof window > "u") return !1;
|
|
1850
1850
|
let t = new URLSearchParams(window.location.search);
|
|
1851
1851
|
return t.has(e) || t.has(e.replace(/-/g, "_"));
|
|
1852
1852
|
}
|
|
1853
|
-
function
|
|
1853
|
+
function Fu(e, t) {
|
|
1854
1854
|
if (typeof window > "u") return;
|
|
1855
1855
|
let n = new URL(window.location.href);
|
|
1856
1856
|
n.searchParams.get(e) !== t && (n.searchParams.set(e, t), window.history.replaceState(null, "", n.toString()));
|
|
1857
1857
|
}
|
|
1858
|
-
function
|
|
1859
|
-
let e =
|
|
1858
|
+
function Iu() {
|
|
1859
|
+
let e = A(mu);
|
|
1860
1860
|
return e === "false" ? "direct" : e === "true" ? "proxy" : e === "lb" || e === "stream" ? "lb" : null;
|
|
1861
1861
|
}
|
|
1862
|
-
function
|
|
1862
|
+
function Lu(e) {
|
|
1863
1863
|
return e === "binary" || e === "sse" || e === "poll" ? e : null;
|
|
1864
1864
|
}
|
|
1865
|
-
var
|
|
1865
|
+
var Ru = {
|
|
1866
1866
|
ws: "websocket",
|
|
1867
1867
|
websocket: "websocket",
|
|
1868
1868
|
wt: "webtransport",
|
|
@@ -1870,70 +1870,70 @@ var zu = {
|
|
|
1870
1870
|
http: "httpstream",
|
|
1871
1871
|
httpstream: "httpstream"
|
|
1872
1872
|
};
|
|
1873
|
-
function
|
|
1874
|
-
let e =
|
|
1873
|
+
function zu() {
|
|
1874
|
+
let e = A(hu)?.toLowerCase();
|
|
1875
1875
|
if (!e) return null;
|
|
1876
|
-
let t =
|
|
1876
|
+
let t = Ru[e];
|
|
1877
1877
|
if (t) return { family: t };
|
|
1878
1878
|
let n = e.lastIndexOf("-");
|
|
1879
1879
|
if (n === -1) return null;
|
|
1880
|
-
let r =
|
|
1880
|
+
let r = Ru[e.slice(0, n)], i = Lu(e.slice(n + 1));
|
|
1881
1881
|
return r !== "httpstream" || !i ? null : {
|
|
1882
1882
|
family: r,
|
|
1883
1883
|
mode: i
|
|
1884
1884
|
};
|
|
1885
1885
|
}
|
|
1886
|
+
function Bu() {
|
|
1887
|
+
return j(yu) === !0;
|
|
1888
|
+
}
|
|
1886
1889
|
function Vu() {
|
|
1887
|
-
return A(
|
|
1890
|
+
return A(Su);
|
|
1888
1891
|
}
|
|
1889
1892
|
function Hu() {
|
|
1890
|
-
|
|
1891
|
-
}
|
|
1892
|
-
function Uu() {
|
|
1893
|
-
let e = k(_u);
|
|
1893
|
+
let e = A(gu);
|
|
1894
1894
|
if (!e || typeof window > "u") return null;
|
|
1895
1895
|
if (/^https?:\/\//i.test(e)) return e;
|
|
1896
1896
|
let t = e.indexOf("~"), n = t < 0 ? e : e.substring(t + 1), r = t < 0 ? window.location.port : e.substring(0, t), i = r ? `${window.location.hostname}:${r}` : window.location.hostname;
|
|
1897
1897
|
return `${window.location.protocol}//${i}/connect?token=${encodeURIComponent(n)}`;
|
|
1898
1898
|
}
|
|
1899
|
+
function Uu() {
|
|
1900
|
+
return j(Cu);
|
|
1901
|
+
}
|
|
1899
1902
|
function Wu() {
|
|
1900
|
-
return
|
|
1903
|
+
return j(wu);
|
|
1901
1904
|
}
|
|
1902
1905
|
function Gu() {
|
|
1903
|
-
return
|
|
1906
|
+
return j(Tu);
|
|
1904
1907
|
}
|
|
1905
1908
|
function Ku() {
|
|
1906
|
-
|
|
1909
|
+
let e = A(Eu);
|
|
1910
|
+
return e === "relay" ? "relay" : e === "all" ? "all" : null;
|
|
1907
1911
|
}
|
|
1908
1912
|
function qu() {
|
|
1909
|
-
|
|
1910
|
-
return e === "relay" ? "relay" : e === "all" ? "all" : null;
|
|
1913
|
+
return j(xu) === !0;
|
|
1911
1914
|
}
|
|
1912
1915
|
function Ju() {
|
|
1913
|
-
return
|
|
1916
|
+
return j(bu) === !0;
|
|
1914
1917
|
}
|
|
1915
1918
|
function Yu() {
|
|
1916
|
-
return
|
|
1919
|
+
return j(vu);
|
|
1917
1920
|
}
|
|
1918
|
-
function
|
|
1919
|
-
return
|
|
1921
|
+
function M() {
|
|
1922
|
+
return j(Du) !== !1;
|
|
1920
1923
|
}
|
|
1921
|
-
function
|
|
1922
|
-
return
|
|
1924
|
+
function Xu() {
|
|
1925
|
+
return j(Ou) === !0;
|
|
1923
1926
|
}
|
|
1924
1927
|
function Zu() {
|
|
1925
|
-
return A(
|
|
1928
|
+
return A(_u);
|
|
1926
1929
|
}
|
|
1927
1930
|
function Qu() {
|
|
1928
|
-
return
|
|
1929
|
-
}
|
|
1930
|
-
function $u() {
|
|
1931
|
-
return Fu(Au);
|
|
1931
|
+
return Pu(ku);
|
|
1932
1932
|
}
|
|
1933
1933
|
//#endregion
|
|
1934
1934
|
//#region src/transport/message-framer.ts
|
|
1935
|
-
var
|
|
1936
|
-
buffer = new Uint8Array(
|
|
1935
|
+
var $u = 4, ed = 65536, td = class {
|
|
1936
|
+
buffer = new Uint8Array(ed);
|
|
1937
1937
|
bufferOffset = 0;
|
|
1938
1938
|
bufferLength = 0;
|
|
1939
1939
|
dataView = null;
|
|
@@ -1941,9 +1941,9 @@ var ed = 4, td = 65536, nd = class {
|
|
|
1941
1941
|
push(e, t) {
|
|
1942
1942
|
this.append(e);
|
|
1943
1943
|
let n = this.getDataView();
|
|
1944
|
-
for (; this.bufferLength >=
|
|
1944
|
+
for (; this.bufferLength >= $u;) {
|
|
1945
1945
|
let e = n.getUint32(this.bufferOffset, !0);
|
|
1946
|
-
if (e <
|
|
1946
|
+
if (e < $u) throw this.reset(), Error(`Invalid protocol message length: ${e}`);
|
|
1947
1947
|
if (this.bufferLength < e) return;
|
|
1948
1948
|
let r = this.buffer.subarray(this.bufferOffset, this.bufferOffset + e);
|
|
1949
1949
|
this.bufferOffset += e, this.bufferLength -= e, t(r);
|
|
@@ -1965,12 +1965,12 @@ var ed = 4, td = 65536, nd = class {
|
|
|
1965
1965
|
let e = this.buffer.buffer;
|
|
1966
1966
|
return this.dataViewBuffer !== e && (this.dataViewBuffer = e, this.dataView = new DataView(e)), this.dataView;
|
|
1967
1967
|
}
|
|
1968
|
-
},
|
|
1968
|
+
}, N = w("HttpStreamTransport"), nd = 1e4, rd = 3500, id = 1048576, ad = 16, od = [
|
|
1969
1969
|
"binary",
|
|
1970
1970
|
"sse",
|
|
1971
1971
|
"poll"
|
|
1972
|
-
],
|
|
1973
|
-
framer = new
|
|
1972
|
+
], sd = class {
|
|
1973
|
+
framer = new td();
|
|
1974
1974
|
callbacks;
|
|
1975
1975
|
sessionId;
|
|
1976
1976
|
keepaliveTimeoutMs;
|
|
@@ -1990,7 +1990,7 @@ var ed = 4, td = 65536, nd = class {
|
|
|
1990
1990
|
sendPumpRunning = !1;
|
|
1991
1991
|
firstMessageResolver = null;
|
|
1992
1992
|
constructor(e) {
|
|
1993
|
-
this.callbacks = e.callbacks, this.sessionId = e.sessionId, this.keepaliveTimeoutMs = e.keepaliveTimeoutMs, this.connectionTimeoutMs = e.connectionTimeoutMs ??
|
|
1993
|
+
this.callbacks = e.callbacks, this.sessionId = e.sessionId, this.keepaliveTimeoutMs = e.keepaliveTimeoutMs, this.connectionTimeoutMs = e.connectionTimeoutMs ?? nd, this.pinnedMode = e.httpStreamMode, this.preferredMode = e.httpStreamPreferredMode;
|
|
1994
1994
|
}
|
|
1995
1995
|
get isConnected() {
|
|
1996
1996
|
return this.connected && !this.isClosed;
|
|
@@ -2000,22 +2000,22 @@ var ed = 4, td = 65536, nd = class {
|
|
|
2000
2000
|
}
|
|
2001
2001
|
async connect(e, t) {
|
|
2002
2002
|
this.isClosed = !1, this.connecting = !0, this.baseUri = e;
|
|
2003
|
-
let n = Date.now(), r = null, i = this.pinnedMode ? [this.pinnedMode] :
|
|
2003
|
+
let n = Date.now(), r = null, i = this.pinnedMode ? [this.pinnedMode] : cd(this.preferredMode);
|
|
2004
2004
|
for (let e of i) {
|
|
2005
|
-
if (this.isClosed) throw new
|
|
2005
|
+
if (this.isClosed) throw new O("HTTP stream closed while connecting");
|
|
2006
2006
|
try {
|
|
2007
|
-
this.sid =
|
|
2007
|
+
this.sid = ud(), await this.openMode(t, e), this.mode = e, this.connected = !0, this.connecting = !1, this.resetKeepaliveTimeout(), N.debug(`HTTP stream connected in ${e} mode in ${Date.now() - n}ms`);
|
|
2008
2008
|
return;
|
|
2009
2009
|
} catch (t) {
|
|
2010
|
-
if (r = t instanceof Error ? t : Error(String(t)), this.abortDownstream(), t instanceof
|
|
2011
|
-
|
|
2010
|
+
if (r = t instanceof Error ? t : Error(String(t)), this.abortDownstream(), t instanceof k) throw this.connecting = !1, t;
|
|
2011
|
+
N.debug(`HTTP stream ${e} mode failed after ${Date.now() - n}ms: ${r.message}`);
|
|
2012
2012
|
}
|
|
2013
2013
|
}
|
|
2014
|
-
throw this.connecting = !1, new
|
|
2014
|
+
throw this.connecting = !1, new O(`HTTP stream failed in every mode: ${r?.message ?? "unknown error"}`, r ?? void 0);
|
|
2015
2015
|
}
|
|
2016
2016
|
send(e) {
|
|
2017
2017
|
if (this.isClosed) {
|
|
2018
|
-
|
|
2018
|
+
N.warn("Cannot send: HTTP stream closed");
|
|
2019
2019
|
return;
|
|
2020
2020
|
}
|
|
2021
2021
|
this.sendQueue.push(e), this.runSendPump();
|
|
@@ -2026,7 +2026,7 @@ var ed = 4, td = 65536, nd = class {
|
|
|
2026
2026
|
async openMode(e, t) {
|
|
2027
2027
|
let n = new AbortController();
|
|
2028
2028
|
this.downstreamAbort = n;
|
|
2029
|
-
let r = Math.min(
|
|
2029
|
+
let r = Math.min(rd, this.connectionTimeoutMs), i = setTimeout(() => n.abort(), r);
|
|
2030
2030
|
try {
|
|
2031
2031
|
await this.openChannel(e, t, n.signal), await this.openDownstream(t, n, r);
|
|
2032
2032
|
} finally {
|
|
@@ -2039,22 +2039,22 @@ var ed = 4, td = 65536, nd = class {
|
|
|
2039
2039
|
r = await fetch(this.openUrl(t), {
|
|
2040
2040
|
method: "POST",
|
|
2041
2041
|
headers: { "Content-Type": "text/plain" },
|
|
2042
|
-
body:
|
|
2042
|
+
body: dd(e),
|
|
2043
2043
|
cache: "no-store",
|
|
2044
2044
|
credentials: "omit",
|
|
2045
2045
|
signal: n
|
|
2046
2046
|
});
|
|
2047
2047
|
} catch (e) {
|
|
2048
|
-
throw n.aborted ? new
|
|
2048
|
+
throw n.aborted ? new O("HTTP stream channel did not open before the mode deadline") : e;
|
|
2049
2049
|
}
|
|
2050
|
-
if (r.status === 401 || r.status === 403) throw new
|
|
2051
|
-
if (!r.ok) throw new
|
|
2050
|
+
if (r.status === 401 || r.status === 403) throw new k(`HTTP stream rejected the auth ticket (${r.status})`);
|
|
2051
|
+
if (!r.ok) throw new O(`HTTP stream could not be opened, status ${r.status}`);
|
|
2052
2052
|
}
|
|
2053
2053
|
async openDownstream(e, t, n) {
|
|
2054
2054
|
this.framer.reset();
|
|
2055
2055
|
let r = new Promise((e, r) => {
|
|
2056
2056
|
let i = () => {
|
|
2057
|
-
this.firstMessageResolver = null, r(new
|
|
2057
|
+
this.firstMessageResolver = null, r(new O(`No server message in ${n}ms`));
|
|
2058
2058
|
};
|
|
2059
2059
|
t.signal.addEventListener("abort", i, { once: !0 }), this.firstMessageResolver = () => {
|
|
2060
2060
|
t.signal.removeEventListener("abort", i), this.firstMessageResolver = null, e();
|
|
@@ -2066,8 +2066,8 @@ var ed = 4, td = 65536, nd = class {
|
|
|
2066
2066
|
credentials: "omit",
|
|
2067
2067
|
signal: t.signal
|
|
2068
2068
|
});
|
|
2069
|
-
if (i.status === 401 || i.status === 403) throw new
|
|
2070
|
-
if (!i.ok || !i.body) throw new
|
|
2069
|
+
if (i.status === 401 || i.status === 403) throw new k(`HTTP stream rejected the auth ticket (${i.status})`);
|
|
2070
|
+
if (!i.ok || !i.body) throw new O(`HTTP stream request failed with status ${i.status}`);
|
|
2071
2071
|
this.runDownstreamLoop(e, i, t), await r;
|
|
2072
2072
|
}
|
|
2073
2073
|
async runDownstreamLoop(e, t, n) {
|
|
@@ -2095,11 +2095,11 @@ var ed = 4, td = 65536, nd = class {
|
|
|
2095
2095
|
}
|
|
2096
2096
|
} catch (e) {
|
|
2097
2097
|
if (n.signal.aborted || this.isClosed) return;
|
|
2098
|
-
|
|
2098
|
+
N.debug(`HTTP stream read loop ended: ${e instanceof Error ? e.message : e}`), this.handleClose("HTTP stream read failed", !1);
|
|
2099
2099
|
}
|
|
2100
2100
|
}
|
|
2101
2101
|
async readResponse(e, t) {
|
|
2102
|
-
let n = t.body.getReader(), r = e === "sse" ? new
|
|
2102
|
+
let n = t.body.getReader(), r = e === "sse" ? new ld() : null;
|
|
2103
2103
|
for (;;) {
|
|
2104
2104
|
let { value: e, done: t } = await n.read();
|
|
2105
2105
|
if (t) return;
|
|
@@ -2128,11 +2128,11 @@ var ed = 4, td = 65536, nd = class {
|
|
|
2128
2128
|
this.handleClose("HTTP stream channel is gone", !1);
|
|
2129
2129
|
return;
|
|
2130
2130
|
}
|
|
2131
|
-
if (!t.ok) throw new
|
|
2131
|
+
if (!t.ok) throw new O(`HTTP stream send failed with status ${t.status}`);
|
|
2132
2132
|
}
|
|
2133
2133
|
} catch (e) {
|
|
2134
2134
|
if (this.isClosed) return;
|
|
2135
|
-
|
|
2135
|
+
N.warn(`HTTP stream send failed: ${e instanceof Error ? e.message : e}`), this.handleClose("HTTP stream send failed", !1);
|
|
2136
2136
|
} finally {
|
|
2137
2137
|
this.sendPumpRunning = !1;
|
|
2138
2138
|
}
|
|
@@ -2142,7 +2142,7 @@ var ed = 4, td = 65536, nd = class {
|
|
|
2142
2142
|
let e = 0, t = 0;
|
|
2143
2143
|
for (; t < this.sendQueue.length;) {
|
|
2144
2144
|
let n = this.sendQueue[t].length;
|
|
2145
|
-
if (t > 0 && e + n >
|
|
2145
|
+
if (t > 0 && e + n > id) break;
|
|
2146
2146
|
e += n, t++;
|
|
2147
2147
|
}
|
|
2148
2148
|
let n = new Uint8Array(e), r = 0;
|
|
@@ -2170,7 +2170,7 @@ var ed = 4, td = 65536, nd = class {
|
|
|
2170
2170
|
}
|
|
2171
2171
|
this.resetKeepaliveTimeout(), this.callbacks.onProtocolMessage(e.slice());
|
|
2172
2172
|
} catch (e) {
|
|
2173
|
-
|
|
2173
|
+
N.error("Failed to process protocol message:", e), this.callbacks.onError(e instanceof Error ? e : Error(String(e)));
|
|
2174
2174
|
}
|
|
2175
2175
|
}
|
|
2176
2176
|
handleClose(e, t) {
|
|
@@ -2181,17 +2181,17 @@ var ed = 4, td = 65536, nd = class {
|
|
|
2181
2181
|
}
|
|
2182
2182
|
resetKeepaliveTimeout() {
|
|
2183
2183
|
this.clearKeepaliveTimeout(), !(this.keepaliveTimeoutMs <= 0) && (this.keepaliveTimeout = setTimeout(() => {
|
|
2184
|
-
|
|
2184
|
+
N.error(`No keepalive received in ${this.keepaliveTimeoutMs}ms, closing HTTP stream`), this.callbacks.onError(new tu(this.keepaliveTimeoutMs)), this.close();
|
|
2185
2185
|
}, this.keepaliveTimeoutMs));
|
|
2186
2186
|
}
|
|
2187
2187
|
clearKeepaliveTimeout() {
|
|
2188
2188
|
this.keepaliveTimeout &&= (clearTimeout(this.keepaliveTimeout), null);
|
|
2189
2189
|
}
|
|
2190
2190
|
};
|
|
2191
|
-
function
|
|
2192
|
-
return e ? [e, ...
|
|
2191
|
+
function cd(e) {
|
|
2192
|
+
return e ? [e, ...od.filter((t) => t !== e)] : od;
|
|
2193
2193
|
}
|
|
2194
|
-
var
|
|
2194
|
+
var ld = class {
|
|
2195
2195
|
decoder = new TextDecoder();
|
|
2196
2196
|
pending = "";
|
|
2197
2197
|
push(e, t) {
|
|
@@ -2199,30 +2199,30 @@ var ud = class {
|
|
|
2199
2199
|
let n = this.pending.indexOf("\n");
|
|
2200
2200
|
for (; n !== -1;) {
|
|
2201
2201
|
let e = this.pending.slice(0, n);
|
|
2202
|
-
this.pending = this.pending.slice(n + 1), e.startsWith("data: ") && t(
|
|
2202
|
+
this.pending = this.pending.slice(n + 1), e.startsWith("data: ") && t(fd(e.slice(6))), n = this.pending.indexOf("\n");
|
|
2203
2203
|
}
|
|
2204
2204
|
}
|
|
2205
2205
|
};
|
|
2206
|
-
function
|
|
2207
|
-
let e = new Uint8Array(
|
|
2206
|
+
function ud() {
|
|
2207
|
+
let e = new Uint8Array(ad);
|
|
2208
2208
|
crypto.getRandomValues(e);
|
|
2209
2209
|
let t = "";
|
|
2210
2210
|
for (let n of e) t += n.toString(16).padStart(2, "0");
|
|
2211
2211
|
return t;
|
|
2212
2212
|
}
|
|
2213
|
-
function
|
|
2213
|
+
function dd(e) {
|
|
2214
2214
|
let t = "";
|
|
2215
2215
|
for (let n of e) t += String.fromCharCode(n);
|
|
2216
2216
|
return btoa(t);
|
|
2217
2217
|
}
|
|
2218
|
-
function
|
|
2218
|
+
function fd(e) {
|
|
2219
2219
|
let t = atob(e), n = new Uint8Array(t.length);
|
|
2220
2220
|
for (let e = 0; e < t.length; e++) n[e] = t.charCodeAt(e);
|
|
2221
2221
|
return n;
|
|
2222
2222
|
}
|
|
2223
2223
|
//#endregion
|
|
2224
2224
|
//#region src/transport/web-socket-transport.ts
|
|
2225
|
-
var
|
|
2225
|
+
var pd = w("WebSocketTransport"), md = 1e4, hd = class {
|
|
2226
2226
|
ws = null;
|
|
2227
2227
|
keepaliveTimeout = null;
|
|
2228
2228
|
isClosed = !1;
|
|
@@ -2245,27 +2245,27 @@ var N = w("WebSocketTransport"), md = 1e4, hd = class {
|
|
|
2245
2245
|
try {
|
|
2246
2246
|
this.ws = new WebSocket(e), this.ws.binaryType = "arraybuffer";
|
|
2247
2247
|
} catch (e) {
|
|
2248
|
-
i(new
|
|
2248
|
+
i(new O(`Failed to create WebSocket: ${e}`, e instanceof Error ? e : void 0));
|
|
2249
2249
|
return;
|
|
2250
2250
|
}
|
|
2251
2251
|
let a = !1, o = !1, s = () => {
|
|
2252
2252
|
clearTimeout(u), this.ws && (this.ws.onopen = null, this.ws.onerror = null, this.ws.onclose = null, this.ws.onmessage = null);
|
|
2253
2253
|
}, c = () => {
|
|
2254
|
-
o || (o = !0, clearTimeout(u), this.firstMessageResolver = null,
|
|
2254
|
+
o || (o = !0, clearTimeout(u), this.firstMessageResolver = null, pd.debug(`WebSocket connected in ${Date.now() - n}ms`), r());
|
|
2255
2255
|
}, l = (e) => {
|
|
2256
2256
|
o || (o = !0, this.firstMessageResolver = null, s(), i(e));
|
|
2257
2257
|
};
|
|
2258
2258
|
this.firstMessageResolver = c;
|
|
2259
2259
|
let u = setTimeout(() => {
|
|
2260
|
-
this.ws?.close(),
|
|
2260
|
+
this.ws?.close(), pd.warn(`WebSocket connection timeout after ${this.connectionTimeoutMs}ms`), l(new O("WebSocket connection timeout"));
|
|
2261
2261
|
}, this.connectionTimeoutMs);
|
|
2262
2262
|
this.ws.onopen = () => {
|
|
2263
2263
|
a = !0, this.ws.send(t), this.resetKeepaliveTimeout();
|
|
2264
2264
|
}, this.ws.onerror = () => {
|
|
2265
|
-
|
|
2265
|
+
pd.debug(`WebSocket connection failed after ${Date.now() - n}ms`), l(new O("WebSocket connection failed"));
|
|
2266
2266
|
}, this.ws.onclose = (e) => {
|
|
2267
2267
|
if (this.clearKeepaliveTimeout(), !o) {
|
|
2268
|
-
l(a ? new
|
|
2268
|
+
l(a ? new k("WebSocket closed before first server message") : new O("WebSocket connection closed before opening"));
|
|
2269
2269
|
return;
|
|
2270
2270
|
}
|
|
2271
2271
|
if (this.isClosed) return;
|
|
@@ -2277,7 +2277,7 @@ var N = w("WebSocketTransport"), md = 1e4, hd = class {
|
|
|
2277
2277
|
});
|
|
2278
2278
|
}
|
|
2279
2279
|
send(e) {
|
|
2280
|
-
this.ws?.readyState === WebSocket.OPEN ? this.ws.send(e) :
|
|
2280
|
+
this.ws?.readyState === WebSocket.OPEN ? this.ws.send(e) : pd.warn("Cannot send: WebSocket not connected");
|
|
2281
2281
|
}
|
|
2282
2282
|
close() {
|
|
2283
2283
|
this.isClosed = !0, this.clearKeepaliveTimeout(), this.ws &&= (this.ws.close(1e3, "Client closing"), null);
|
|
@@ -2294,12 +2294,12 @@ var N = w("WebSocketTransport"), md = 1e4, hd = class {
|
|
|
2294
2294
|
}
|
|
2295
2295
|
this.resetKeepaliveTimeout(), this.callbacks.onProtocolMessage(e);
|
|
2296
2296
|
} catch (e) {
|
|
2297
|
-
|
|
2297
|
+
pd.error("Failed to process protocol message:", e), this.callbacks.onError(e instanceof Error ? e : Error(String(e)));
|
|
2298
2298
|
}
|
|
2299
2299
|
}
|
|
2300
2300
|
resetKeepaliveTimeout() {
|
|
2301
2301
|
this.clearKeepaliveTimeout(), !(this.keepaliveTimeoutMs <= 0) && (this.keepaliveTimeout = setTimeout(() => {
|
|
2302
|
-
|
|
2302
|
+
pd.error(`No keepalive received in ${this.keepaliveTimeoutMs}ms, closing connection`), this.callbacks.onError(new tu(this.keepaliveTimeoutMs)), this.close();
|
|
2303
2303
|
}, this.keepaliveTimeoutMs));
|
|
2304
2304
|
}
|
|
2305
2305
|
clearKeepaliveTimeout() {
|
|
@@ -2317,7 +2317,7 @@ var vd = class {
|
|
|
2317
2317
|
keepaliveTimeout = null;
|
|
2318
2318
|
readLoopActive = !1;
|
|
2319
2319
|
isClosed = !1;
|
|
2320
|
-
framer = new
|
|
2320
|
+
framer = new td();
|
|
2321
2321
|
keepaliveResponseMessage = null;
|
|
2322
2322
|
firstMessageResolver = null;
|
|
2323
2323
|
firstMessageRejecter = null;
|
|
@@ -2332,7 +2332,7 @@ var vd = class {
|
|
|
2332
2332
|
return this.transport !== null && this.writer !== null;
|
|
2333
2333
|
}
|
|
2334
2334
|
async connect(e, t) {
|
|
2335
|
-
if (!_d()) throw new
|
|
2335
|
+
if (!_d()) throw new O("WebTransport is not supported in this browser");
|
|
2336
2336
|
this.isClosed = !1;
|
|
2337
2337
|
let n = Date.now(), r = new Promise((e, t) => {
|
|
2338
2338
|
this.firstMessageResolver = e, this.firstMessageRejecter = t;
|
|
@@ -2340,12 +2340,12 @@ var vd = class {
|
|
|
2340
2340
|
try {
|
|
2341
2341
|
this.transport = new WebTransport(e);
|
|
2342
2342
|
let i, a = new Promise((e, t) => {
|
|
2343
|
-
i = setTimeout(() => t(new
|
|
2343
|
+
i = setTimeout(() => t(new O("WebTransport connection timeout")), this.connectionTimeoutMs);
|
|
2344
2344
|
});
|
|
2345
2345
|
try {
|
|
2346
2346
|
await Promise.race([this.transport.ready, a]);
|
|
2347
2347
|
} catch (e) {
|
|
2348
|
-
throw e instanceof
|
|
2348
|
+
throw e instanceof O && P.warn(`WebTransport connection timeout after ${this.connectionTimeoutMs}ms`), e;
|
|
2349
2349
|
} finally {
|
|
2350
2350
|
clearTimeout(i);
|
|
2351
2351
|
}
|
|
@@ -2355,7 +2355,7 @@ var vd = class {
|
|
|
2355
2355
|
P.error("WebTransport connection closed with error:", e), this.handleClose(e instanceof Error ? e.message : "Connection error", !1);
|
|
2356
2356
|
}), 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();
|
|
2357
2357
|
let o = Math.max(this.connectionTimeoutMs - (Date.now() - n), 1), s, c = new Promise((e, t) => {
|
|
2358
|
-
s = setTimeout(() => t(new
|
|
2358
|
+
s = setTimeout(() => t(new O("WebTransport closed before first server message")), o);
|
|
2359
2359
|
});
|
|
2360
2360
|
try {
|
|
2361
2361
|
await Promise.race([r, c]);
|
|
@@ -2366,7 +2366,7 @@ var vd = class {
|
|
|
2366
2366
|
} catch (e) {
|
|
2367
2367
|
this.firstMessageResolver = null, this.firstMessageRejecter = null, this.isClosed = !0, this.cleanup();
|
|
2368
2368
|
let t = Date.now() - n;
|
|
2369
|
-
throw P.warn(`WebTransport connection failed after ${t}ms: ${e}`), new
|
|
2369
|
+
throw P.warn(`WebTransport connection failed after ${t}ms: ${e}`), new O(`Failed to connect WebTransport: ${e}`, e instanceof Error ? e : void 0);
|
|
2370
2370
|
}
|
|
2371
2371
|
}
|
|
2372
2372
|
send(e) {
|
|
@@ -2414,7 +2414,7 @@ var vd = class {
|
|
|
2414
2414
|
handleClose(e, t) {
|
|
2415
2415
|
if (!this.isClosed) {
|
|
2416
2416
|
if (this.isClosed = !0, this.clearKeepaliveTimeout(), this.readLoopActive = !1, this.cleanup(), this.firstMessageRejecter) {
|
|
2417
|
-
this.firstMessageRejecter(new
|
|
2417
|
+
this.firstMessageRejecter(new k(`WebTransport closed before first server message: ${e}`)), this.firstMessageResolver = null, this.firstMessageRejecter = null;
|
|
2418
2418
|
return;
|
|
2419
2419
|
}
|
|
2420
2420
|
this.callbacks.onClose(e, t);
|
|
@@ -2422,7 +2422,7 @@ var vd = class {
|
|
|
2422
2422
|
}
|
|
2423
2423
|
resetKeepaliveTimeout() {
|
|
2424
2424
|
this.clearKeepaliveTimeout(), !(this.keepaliveTimeoutMs <= 0) && (this.keepaliveTimeout = setTimeout(() => {
|
|
2425
|
-
P.error(`No keepalive received in ${this.keepaliveTimeoutMs}ms, closing connection`), this.callbacks.onError(new
|
|
2425
|
+
P.error(`No keepalive received in ${this.keepaliveTimeoutMs}ms, closing connection`), this.callbacks.onError(new tu(this.keepaliveTimeoutMs)), this.close();
|
|
2426
2426
|
}, this.keepaliveTimeoutMs));
|
|
2427
2427
|
}
|
|
2428
2428
|
clearKeepaliveTimeout() {
|
|
@@ -2457,7 +2457,7 @@ var vd = class {
|
|
|
2457
2457
|
return this.transport?.isConnected ?? !1;
|
|
2458
2458
|
}
|
|
2459
2459
|
get httpStreamMode() {
|
|
2460
|
-
return this.transport instanceof
|
|
2460
|
+
return this.transport instanceof sd ? this.transport.activeMode : null;
|
|
2461
2461
|
}
|
|
2462
2462
|
async connect() {
|
|
2463
2463
|
if (this.state !== "disconnected") throw Error(`Cannot connect: already in state ${this.state}`);
|
|
@@ -2509,7 +2509,7 @@ var vd = class {
|
|
|
2509
2509
|
break;
|
|
2510
2510
|
case x.HttpStream:
|
|
2511
2511
|
case x.HttpStreamProxy:
|
|
2512
|
-
this.transport = new
|
|
2512
|
+
this.transport = new sd(t);
|
|
2513
2513
|
break;
|
|
2514
2514
|
default: throw Error(`Unsupported entrypoint type: ${x[e.Type]}`);
|
|
2515
2515
|
}
|
|
@@ -2531,7 +2531,7 @@ var vd = class {
|
|
|
2531
2531
|
this.transport = null, this.config.onClose?.(e, t);
|
|
2532
2532
|
}
|
|
2533
2533
|
handleError(e) {
|
|
2534
|
-
this.config.onError?.(e), e instanceof
|
|
2534
|
+
this.config.onError?.(e), e instanceof tu && this.handleClose("Keepalive timeout", !1);
|
|
2535
2535
|
}
|
|
2536
2536
|
setState(e) {
|
|
2537
2537
|
this.state !== e && (this.state = e, this.config.onStateChange?.(e));
|
|
@@ -2603,7 +2603,7 @@ var vd = class {
|
|
|
2603
2603
|
let e = new Set(n.keys());
|
|
2604
2604
|
r = this.config.orderedEndpointTypes.filter((t) => e.has(t));
|
|
2605
2605
|
} else r = this.config.endpointSelector ? this.config.endpointSelector.getOrderedTypes(n) : Array.from(n.keys());
|
|
2606
|
-
if (r.length === 0) throw this.setState("offline"), new
|
|
2606
|
+
if (r.length === 0) throw this.setState("offline"), new fu(null, null, [...n.keys()].map((e) => x[e]));
|
|
2607
2607
|
this.connectionTimeoutMs = r.length > 1 ? 5e3 : 1e4, F.debug(`Endpoint types to try: [${r.map((e) => x[e]).join(", ")}], transport timeout: ${this.connectionTimeoutMs}ms`);
|
|
2608
2608
|
for (let e of r) {
|
|
2609
2609
|
if (!this.shouldReconnect) return;
|
|
@@ -2615,7 +2615,7 @@ var vd = class {
|
|
|
2615
2615
|
} catch (t) {
|
|
2616
2616
|
F.warn(`Failed to connect using ${x[e]} after ${Date.now() - r}ms: ${t instanceof Error ? t.message : t}`);
|
|
2617
2617
|
let i = this.channels.size > 0;
|
|
2618
|
-
if (this.disconnectAll(), t instanceof
|
|
2618
|
+
if (this.disconnectAll(), t instanceof k) throw t;
|
|
2619
2619
|
if (i && this.config.onRefreshEntrypoints) try {
|
|
2620
2620
|
F.info("Partial connection detected, refreshing entrypoints");
|
|
2621
2621
|
let e = await this.config.onRefreshEntrypoints();
|
|
@@ -2634,7 +2634,7 @@ var vd = class {
|
|
|
2634
2634
|
let t = (await Promise.allSettled(e.map((e) => this.connectChannel(e)))).filter((e) => e.status === "rejected");
|
|
2635
2635
|
if (t.length > 0) {
|
|
2636
2636
|
let e = t.map((e) => e.reason instanceof Error ? e.reason.message : String(e.reason));
|
|
2637
|
-
throw t.some((e) => e.reason instanceof
|
|
2637
|
+
throw t.some((e) => e.reason instanceof k) ? new k(e.join(", ")) : Error(e.join(", "));
|
|
2638
2638
|
}
|
|
2639
2639
|
}
|
|
2640
2640
|
async connectChannel(e) {
|
|
@@ -2676,18 +2676,18 @@ var vd = class {
|
|
|
2676
2676
|
}
|
|
2677
2677
|
async attemptReconnect() {
|
|
2678
2678
|
if (this.shouldReconnect) {
|
|
2679
|
-
if (!
|
|
2680
|
-
F.warn("Retry disabled via ikon-retry=false, skipping reconnect"), this.setState("offline"), this.config.onError?.(new
|
|
2679
|
+
if (!M()) {
|
|
2680
|
+
F.warn("Retry disabled via ikon-retry=false, skipping reconnect"), this.setState("offline"), this.config.onError?.(new nu(0));
|
|
2681
2681
|
return;
|
|
2682
2682
|
}
|
|
2683
2683
|
if (this.reconnectAttempts >= this.config.maxReconnectAttempts) {
|
|
2684
|
-
F.warn(`Max reconnect attempts (${this.config.maxReconnectAttempts}) reached`), this.setState("offline"), this.config.onError?.(new
|
|
2684
|
+
F.warn(`Max reconnect attempts (${this.config.maxReconnectAttempts}) reached`), this.setState("offline"), this.config.onError?.(new nu(this.config.maxReconnectAttempts));
|
|
2685
2685
|
return;
|
|
2686
2686
|
}
|
|
2687
2687
|
if (this.setState("reconnecting"), this.reconnectAttempts++, this.reconnectAttempts > 1) {
|
|
2688
2688
|
F.info(`Reconnecting in ${this.config.reconnectBackoffMs}ms (attempt ${this.reconnectAttempts}/${this.config.maxReconnectAttempts})`);
|
|
2689
2689
|
try {
|
|
2690
|
-
await
|
|
2690
|
+
await pu(this.config.reconnectBackoffMs, this.abortController?.signal);
|
|
2691
2691
|
} catch {
|
|
2692
2692
|
return;
|
|
2693
2693
|
}
|
|
@@ -2695,11 +2695,11 @@ var vd = class {
|
|
|
2695
2695
|
if (this.shouldReconnect) try {
|
|
2696
2696
|
await this.connectInternal(!0);
|
|
2697
2697
|
} catch (e) {
|
|
2698
|
-
if (e instanceof
|
|
2698
|
+
if (e instanceof k) {
|
|
2699
2699
|
F.warn("Auth rejected during reconnect, stopping retries and signaling full re-auth"), this.config.onError?.(e), this.setState("offline");
|
|
2700
2700
|
return;
|
|
2701
2701
|
}
|
|
2702
|
-
if (e instanceof
|
|
2702
|
+
if (e instanceof fu) {
|
|
2703
2703
|
F.warn(`${e.message} Not retrying`), this.config.onError?.(e), this.setState("offline");
|
|
2704
2704
|
return;
|
|
2705
2705
|
}
|
|
@@ -3544,7 +3544,7 @@ async function zf() {
|
|
|
3544
3544
|
})(), Rf));
|
|
3545
3545
|
}
|
|
3546
3546
|
function Bf() {
|
|
3547
|
-
return typeof window > "u" ||
|
|
3547
|
+
return typeof window > "u" || Yu() === !1 ? !1 : np();
|
|
3548
3548
|
}
|
|
3549
3549
|
function Vf() {
|
|
3550
3550
|
return Bf() ? `${window.location.origin}/ikon/api` : null;
|
|
@@ -3594,7 +3594,7 @@ async function Jf(e) {
|
|
|
3594
3594
|
return e.startsWith("/") ? typeof window > "u" ? await Xf() : `${window.location.origin}${e}` : e;
|
|
3595
3595
|
}
|
|
3596
3596
|
async function Yf(e) {
|
|
3597
|
-
if (
|
|
3597
|
+
if (Yu() === !0) {
|
|
3598
3598
|
let e = Hf();
|
|
3599
3599
|
if (e) return e;
|
|
3600
3600
|
}
|
|
@@ -3621,16 +3621,16 @@ function Zf() {
|
|
|
3621
3621
|
return t;
|
|
3622
3622
|
}
|
|
3623
3623
|
var Qf = [
|
|
3624
|
+
Au,
|
|
3624
3625
|
ju,
|
|
3625
3626
|
Mu,
|
|
3626
|
-
Nu,
|
|
3627
3627
|
"error"
|
|
3628
|
-
], $f = [
|
|
3628
|
+
], $f = [_u, _u.replace(/-/g, "_")];
|
|
3629
3629
|
function ep() {
|
|
3630
3630
|
let e = window.location.pathname.match(/^\/(s|c)\/([^/]+)(.*)$/);
|
|
3631
3631
|
if (!e) return;
|
|
3632
3632
|
let t = new URL(window.location.href);
|
|
3633
|
-
t.pathname = e[3] || "/", t.searchParams.set(
|
|
3633
|
+
t.pathname = e[3] || "/", t.searchParams.set(_u, decodeURIComponent(e[2])), window.history.replaceState(null, "", t.toString());
|
|
3634
3634
|
}
|
|
3635
3635
|
function tp() {
|
|
3636
3636
|
if (typeof window > "u") return { parameters: {} };
|
|
@@ -3638,7 +3638,7 @@ function tp() {
|
|
|
3638
3638
|
let e = Zf(), t = {};
|
|
3639
3639
|
for (let [n, r] of Object.entries(e)) !Qf.includes(n) && !$f.includes(n) && (t[n] = r);
|
|
3640
3640
|
return {
|
|
3641
|
-
sessionIdentityHash:
|
|
3641
|
+
sessionIdentityHash: Zu() ?? void 0,
|
|
3642
3642
|
parameters: t
|
|
3643
3643
|
};
|
|
3644
3644
|
}
|
|
@@ -3742,7 +3742,7 @@ async function Sp(e, t) {
|
|
|
3742
3742
|
if (await xp(e, t)) return !0;
|
|
3743
3743
|
try {
|
|
3744
3744
|
let { code: n, provider: r } = await Cp(window.open("about:blank", "ikon-oauth", "popup,width=520,height=680"), e, t), i = new URL(window.location.href);
|
|
3745
|
-
return i.searchParams.set(
|
|
3745
|
+
return i.searchParams.set(ju, n), i.searchParams.set(Mu, r), window.location.replace(i.toString()), !0;
|
|
3746
3746
|
} catch (t) {
|
|
3747
3747
|
return pp.warn(`Embedded sign-in with ${e} did not complete: ${t instanceof Error ? t.message : String(t)}`), !1;
|
|
3748
3748
|
}
|
|
@@ -3804,7 +3804,7 @@ function wp(e, t) {
|
|
|
3804
3804
|
}
|
|
3805
3805
|
function Tp() {
|
|
3806
3806
|
if (typeof window > "u") return;
|
|
3807
|
-
let e = new URLSearchParams(window.location.search).get(
|
|
3807
|
+
let e = new URLSearchParams(window.location.search).get(Nu);
|
|
3808
3808
|
e && dp(e);
|
|
3809
3809
|
}
|
|
3810
3810
|
//#endregion
|
|
@@ -4228,9 +4228,9 @@ var Mm = [], Nm = !1;
|
|
|
4228
4228
|
function Pm() {
|
|
4229
4229
|
return typeof window < "u" && "Notification" in window;
|
|
4230
4230
|
}
|
|
4231
|
-
function Fm(e, t, n, r) {
|
|
4232
|
-
let
|
|
4233
|
-
return e?.trim() && (
|
|
4231
|
+
function Fm(e, t, n, r, i) {
|
|
4232
|
+
let a = {};
|
|
4233
|
+
return e?.trim() && (a.body = e.trim()), t?.trim() && (a.icon = t.trim()), n?.trim() && (a.tag = n.trim()), r && (a.data = r), i === "High" ? a.requireInteraction = !0 : i === "Low" && (a.silent = !0), a;
|
|
4234
4234
|
}
|
|
4235
4235
|
function Im(e, t, n, r) {
|
|
4236
4236
|
try {
|
|
@@ -4242,27 +4242,73 @@ function Im(e, t, n, r) {
|
|
|
4242
4242
|
window.dispatchEvent(new CustomEvent("ikon.notification-click", { detail: {
|
|
4243
4243
|
launchUrl: n ?? null,
|
|
4244
4244
|
data: r ?? null,
|
|
4245
|
+
action: null,
|
|
4245
4246
|
tag: t.tag ?? null
|
|
4246
4247
|
} })), i.close();
|
|
4247
4248
|
};
|
|
4248
4249
|
} catch {}
|
|
4249
4250
|
}
|
|
4250
|
-
|
|
4251
|
+
var Lm = null, Rm = !1;
|
|
4252
|
+
async function zm() {
|
|
4253
|
+
if (typeof navigator > "u" || !("serviceWorker" in navigator)) return null;
|
|
4254
|
+
if (Lm) return Lm;
|
|
4255
|
+
try {
|
|
4256
|
+
return Lm = await navigator.serviceWorker.register("/push-service-worker.js"), await navigator.serviceWorker.ready, Lm;
|
|
4257
|
+
} catch {
|
|
4258
|
+
return null;
|
|
4259
|
+
}
|
|
4260
|
+
}
|
|
4261
|
+
function Bm() {
|
|
4262
|
+
Rm || typeof navigator > "u" || !("serviceWorker" in navigator) || (Rm = !0, navigator.serviceWorker.addEventListener("message", (e) => {
|
|
4263
|
+
let t = e.data;
|
|
4264
|
+
t && t.type === "ikon.notification-click" && window.dispatchEvent(new CustomEvent("ikon.notification-click", { detail: {
|
|
4265
|
+
launchUrl: t.launchUrl ?? null,
|
|
4266
|
+
data: t.data ?? null,
|
|
4267
|
+
action: t.action ?? null,
|
|
4268
|
+
tag: t.tag ?? null
|
|
4269
|
+
} }));
|
|
4270
|
+
}));
|
|
4271
|
+
}
|
|
4272
|
+
async function Vm(e, t, n, r, i) {
|
|
4273
|
+
let a = await zm();
|
|
4274
|
+
if (!a) return !1;
|
|
4275
|
+
try {
|
|
4276
|
+
let o = {
|
|
4277
|
+
...t,
|
|
4278
|
+
actions: i.map((e) => ({
|
|
4279
|
+
action: e.id,
|
|
4280
|
+
title: e.title
|
|
4281
|
+
})),
|
|
4282
|
+
data: {
|
|
4283
|
+
launchUrl: n ?? null,
|
|
4284
|
+
data: r ?? null,
|
|
4285
|
+
actions: i
|
|
4286
|
+
}
|
|
4287
|
+
};
|
|
4288
|
+
return await a.showNotification(e, o), !0;
|
|
4289
|
+
} catch {
|
|
4290
|
+
return !1;
|
|
4291
|
+
}
|
|
4292
|
+
}
|
|
4293
|
+
async function Hm(e, t, n, r, i) {
|
|
4294
|
+
i && i.length > 0 && await Vm(e, t, n, r, i) || Im(e, t, n, r);
|
|
4295
|
+
}
|
|
4296
|
+
function Um() {
|
|
4251
4297
|
if (Notification.permission !== "granted") {
|
|
4252
4298
|
Mm = [];
|
|
4253
4299
|
return;
|
|
4254
4300
|
}
|
|
4255
4301
|
let e = Mm;
|
|
4256
4302
|
Mm = [];
|
|
4257
|
-
for (let t of e)
|
|
4303
|
+
for (let t of e) Hm(t.title, t.options, t.launchUrl, t.data, t.actions);
|
|
4258
4304
|
}
|
|
4259
|
-
function
|
|
4305
|
+
function Wm() {
|
|
4260
4306
|
if (Nm || typeof window > "u") return;
|
|
4261
4307
|
Nm = !0;
|
|
4262
4308
|
let e = async () => {
|
|
4263
4309
|
try {
|
|
4264
4310
|
if (await Notification.requestPermission() === "granted") {
|
|
4265
|
-
|
|
4311
|
+
Um();
|
|
4266
4312
|
return;
|
|
4267
4313
|
}
|
|
4268
4314
|
} catch {}
|
|
@@ -4272,15 +4318,15 @@ function Rm() {
|
|
|
4272
4318
|
};
|
|
4273
4319
|
window.addEventListener("pointerdown", t), window.addEventListener("keydown", t);
|
|
4274
4320
|
}
|
|
4275
|
-
var
|
|
4321
|
+
var Gm = {
|
|
4276
4322
|
name: "ikon.client.getNotificationPermission",
|
|
4277
4323
|
description: "Get the current notification permission state (granted, denied, default, or unsupported)",
|
|
4278
4324
|
returnType: { kind: "string" }
|
|
4279
4325
|
};
|
|
4280
|
-
function
|
|
4326
|
+
function Km() {
|
|
4281
4327
|
return Pm() ? Notification.permission : "unsupported";
|
|
4282
4328
|
}
|
|
4283
|
-
var
|
|
4329
|
+
var qm = {
|
|
4284
4330
|
name: "ikon.client.showNotification",
|
|
4285
4331
|
description: "Show a notification, requesting permission lazily on the first send",
|
|
4286
4332
|
returnType: { kind: "string" },
|
|
@@ -4323,36 +4369,55 @@ var Vm = {
|
|
|
4323
4369
|
kind: "string",
|
|
4324
4370
|
nullable: !0
|
|
4325
4371
|
}
|
|
4372
|
+
},
|
|
4373
|
+
{
|
|
4374
|
+
name: "priority",
|
|
4375
|
+
type: {
|
|
4376
|
+
kind: "string",
|
|
4377
|
+
nullable: !0
|
|
4378
|
+
}
|
|
4379
|
+
},
|
|
4380
|
+
{
|
|
4381
|
+
name: "actions",
|
|
4382
|
+
type: {
|
|
4383
|
+
kind: "string",
|
|
4384
|
+
nullable: !0
|
|
4385
|
+
}
|
|
4326
4386
|
}
|
|
4327
4387
|
]
|
|
4328
4388
|
};
|
|
4329
|
-
async function
|
|
4389
|
+
async function Jm(e, t, n, r, i, a, o, s) {
|
|
4330
4390
|
if (!Pm() || typeof e != "string" || !e.trim()) return "unsupported";
|
|
4331
|
-
let
|
|
4332
|
-
if (
|
|
4391
|
+
let c = e.trim(), l = Fm(typeof t == "string" ? t : void 0, typeof n == "string" ? n : void 0, typeof r == "string" ? r : void 0, typeof a == "string" ? a : void 0, typeof o == "string" ? o : void 0), u = typeof i == "string" && i.trim() ? i.trim() : void 0, d = typeof a == "string" && a ? a : void 0, f;
|
|
4392
|
+
if (typeof s == "string" && s.trim()) try {
|
|
4393
|
+
let e = JSON.parse(s);
|
|
4394
|
+
Array.isArray(e) && e.length > 0 && (f = e);
|
|
4395
|
+
} catch {}
|
|
4396
|
+
if (Notification.permission === "granted") return await Hm(c, l, u, d, f), "granted";
|
|
4333
4397
|
if (Notification.permission === "denied") return "denied";
|
|
4334
4398
|
try {
|
|
4335
4399
|
let e = await Notification.requestPermission();
|
|
4336
|
-
return e === "granted" &&
|
|
4400
|
+
return e === "granted" && await Hm(c, l, u, d, f), e;
|
|
4337
4401
|
} catch (e) {
|
|
4338
4402
|
return Ep(e) ? (Mm.push({
|
|
4339
|
-
title:
|
|
4340
|
-
options:
|
|
4341
|
-
launchUrl:
|
|
4342
|
-
data:
|
|
4343
|
-
|
|
4403
|
+
title: c,
|
|
4404
|
+
options: l,
|
|
4405
|
+
launchUrl: u,
|
|
4406
|
+
data: d,
|
|
4407
|
+
actions: f
|
|
4408
|
+
}), Wm(), "default") : "denied";
|
|
4344
4409
|
}
|
|
4345
4410
|
}
|
|
4346
|
-
var
|
|
4347
|
-
function
|
|
4348
|
-
|
|
4411
|
+
var Ym = null;
|
|
4412
|
+
function Xm(e) {
|
|
4413
|
+
Ym = e ?? null;
|
|
4349
4414
|
}
|
|
4350
|
-
function
|
|
4415
|
+
function Zm(e) {
|
|
4351
4416
|
let t = (e + "=".repeat((4 - e.length % 4) % 4)).replace(/-/g, "+").replace(/_/g, "/"), n = atob(t), r = new Uint8Array(n.length);
|
|
4352
4417
|
for (let e = 0; e < n.length; e++) r[e] = n.charCodeAt(e);
|
|
4353
4418
|
return r;
|
|
4354
4419
|
}
|
|
4355
|
-
var
|
|
4420
|
+
var Qm = {
|
|
4356
4421
|
name: "ikon.client.getPushSubscription",
|
|
4357
4422
|
description: "Subscribe to Web Push and return the subscription, for offline push registration",
|
|
4358
4423
|
returnType: {
|
|
@@ -4360,14 +4425,14 @@ var Km = {
|
|
|
4360
4425
|
nullable: !0
|
|
4361
4426
|
}
|
|
4362
4427
|
};
|
|
4363
|
-
async function
|
|
4364
|
-
if (typeof window > "u" || !
|
|
4428
|
+
async function $m() {
|
|
4429
|
+
if (typeof window > "u" || !Ym?.enabled || !Ym.vapidPublicKey || !("serviceWorker" in navigator) || !("PushManager" in window) || !Pm() || Notification.permission !== "granted") return null;
|
|
4365
4430
|
try {
|
|
4366
4431
|
let e = await navigator.serviceWorker.register("/push-service-worker.js");
|
|
4367
4432
|
await navigator.serviceWorker.ready;
|
|
4368
4433
|
let t = (await e.pushManager.getSubscription() ?? await e.pushManager.subscribe({
|
|
4369
4434
|
userVisibleOnly: !0,
|
|
4370
|
-
applicationServerKey:
|
|
4435
|
+
applicationServerKey: Zm(Ym.vapidPublicKey)
|
|
4371
4436
|
})).toJSON();
|
|
4372
4437
|
return !t.endpoint || !t.keys?.p256dh || !t.keys?.auth ? null : {
|
|
4373
4438
|
Platform: "web",
|
|
@@ -4380,7 +4445,7 @@ async function qm() {
|
|
|
4380
4445
|
return null;
|
|
4381
4446
|
}
|
|
4382
4447
|
}
|
|
4383
|
-
var
|
|
4448
|
+
var eh = [
|
|
4384
4449
|
{
|
|
4385
4450
|
definition: Bp,
|
|
4386
4451
|
handler: Vp
|
|
@@ -4458,151 +4523,177 @@ var Jm = [
|
|
|
4458
4523
|
handler: jm
|
|
4459
4524
|
},
|
|
4460
4525
|
{
|
|
4461
|
-
definition:
|
|
4462
|
-
handler:
|
|
4526
|
+
definition: Gm,
|
|
4527
|
+
handler: Km
|
|
4463
4528
|
},
|
|
4464
4529
|
{
|
|
4465
|
-
definition:
|
|
4466
|
-
handler:
|
|
4530
|
+
definition: qm,
|
|
4531
|
+
handler: Jm
|
|
4467
4532
|
},
|
|
4468
4533
|
{
|
|
4469
|
-
definition:
|
|
4470
|
-
handler:
|
|
4534
|
+
definition: Qm,
|
|
4535
|
+
handler: $m
|
|
4471
4536
|
}
|
|
4472
4537
|
];
|
|
4473
|
-
function
|
|
4474
|
-
|
|
4475
|
-
|
|
4538
|
+
function th(e) {
|
|
4539
|
+
Bm();
|
|
4540
|
+
let t = eh.map(({ definition: t, handler: n }) => e.register(t, n)), n = null, r = () => {
|
|
4541
|
+
n !== null && typeof navigator < "u" && navigator.geolocation && navigator.geolocation.clearWatch(n), n = null;
|
|
4542
|
+
};
|
|
4543
|
+
return t.push(e.register({
|
|
4544
|
+
name: "ikon.client.startLocationUpdates",
|
|
4545
|
+
description: "Stream GPS location continuously",
|
|
4546
|
+
returnType: { kind: "boolean" }
|
|
4547
|
+
}, async () => typeof navigator > "u" || !navigator.geolocation ? !1 : (r(), n = navigator.geolocation.watchPosition((t) => {
|
|
4548
|
+
e.call("ikon.server.locationUpdate", [
|
|
4549
|
+
t.coords.latitude,
|
|
4550
|
+
t.coords.longitude,
|
|
4551
|
+
t.coords.accuracy,
|
|
4552
|
+
t.coords.speed ?? 0,
|
|
4553
|
+
t.coords.heading ?? -1,
|
|
4554
|
+
t.coords.altitude,
|
|
4555
|
+
t.timestamp
|
|
4556
|
+
]).catch(() => void 0);
|
|
4557
|
+
}, () => void 0, {
|
|
4558
|
+
enableHighAccuracy: !0,
|
|
4559
|
+
maximumAge: 0
|
|
4560
|
+
}), !0))), t.push(e.register({
|
|
4561
|
+
name: "ikon.client.stopLocationUpdates",
|
|
4562
|
+
description: "Stop the GPS location stream",
|
|
4563
|
+
returnType: { kind: "boolean" }
|
|
4564
|
+
}, async () => (r(), !0))), () => {
|
|
4565
|
+
r(), t.forEach((e) => e());
|
|
4566
|
+
};
|
|
4476
4567
|
}
|
|
4477
|
-
function
|
|
4568
|
+
function nh() {
|
|
4478
4569
|
return typeof window < "u" && typeof navigator < "u";
|
|
4479
4570
|
}
|
|
4480
4571
|
//#endregion
|
|
4481
4572
|
//#region src/utils/log-sink.ts
|
|
4482
|
-
var
|
|
4483
|
-
function
|
|
4484
|
-
e.level <
|
|
4573
|
+
var rh = 1e3, ih = C.INFO, H = [], ah = rh, oh = ih, sh = null;
|
|
4574
|
+
function ch(e) {
|
|
4575
|
+
e.level < oh || (H.push(e), H.length > ah && (H = H.slice(-ah)));
|
|
4485
4576
|
}
|
|
4486
|
-
function
|
|
4487
|
-
|
|
4577
|
+
function lh(e) {
|
|
4578
|
+
ah = e?.maxBufferSize ?? rh, oh = e?.minLevel ?? ih, H = [], _e(ch);
|
|
4488
4579
|
}
|
|
4489
|
-
function
|
|
4490
|
-
|
|
4580
|
+
function uh(e) {
|
|
4581
|
+
sh = e;
|
|
4491
4582
|
}
|
|
4492
|
-
function
|
|
4493
|
-
return
|
|
4583
|
+
function dh() {
|
|
4584
|
+
return H;
|
|
4494
4585
|
}
|
|
4495
|
-
function
|
|
4496
|
-
let e =
|
|
4497
|
-
return
|
|
4586
|
+
function fh() {
|
|
4587
|
+
let e = H;
|
|
4588
|
+
return H = [], e;
|
|
4498
4589
|
}
|
|
4499
|
-
function
|
|
4500
|
-
if (!
|
|
4501
|
-
let e =
|
|
4502
|
-
return
|
|
4590
|
+
function ph() {
|
|
4591
|
+
if (!sh || H.length === 0) return 0;
|
|
4592
|
+
let e = fh();
|
|
4593
|
+
return sh(e), e.length;
|
|
4503
4594
|
}
|
|
4504
|
-
function
|
|
4505
|
-
|
|
4595
|
+
function mh() {
|
|
4596
|
+
H = [];
|
|
4506
4597
|
}
|
|
4507
|
-
function
|
|
4508
|
-
return
|
|
4598
|
+
function hh() {
|
|
4599
|
+
return H.length;
|
|
4509
4600
|
}
|
|
4510
|
-
|
|
4601
|
+
lh();
|
|
4511
4602
|
//#endregion
|
|
4512
4603
|
//#region src/utils/log-sender.ts
|
|
4513
|
-
var
|
|
4604
|
+
var gh = w("LogSender"), _h = 1e3, vh = 6e4, yh = 15e3, bh = 10240, xh = 409600, Sh = "…[truncated]", Ch = {
|
|
4514
4605
|
[C.DEBUG]: me.Debug,
|
|
4515
4606
|
[C.INFO]: me.Info,
|
|
4516
4607
|
[C.WARN]: me.Warning,
|
|
4517
4608
|
[C.ERROR]: me.Error
|
|
4518
|
-
},
|
|
4519
|
-
function
|
|
4520
|
-
return e.length <=
|
|
4609
|
+
}, U, wh, W, G = [], K = 0, Th, Eh = 0;
|
|
4610
|
+
function Dh(e) {
|
|
4611
|
+
return e.length <= bh ? e : e.slice(0, 10228) + Sh;
|
|
4521
4612
|
}
|
|
4522
|
-
function
|
|
4613
|
+
function Oh(e) {
|
|
4523
4614
|
return {
|
|
4524
4615
|
Time: e.timestamp,
|
|
4525
|
-
Type:
|
|
4526
|
-
Message:
|
|
4616
|
+
Type: Ch[e.level] ?? me.Info,
|
|
4617
|
+
Message: Dh(`[${e.component}] ${e.message}`),
|
|
4527
4618
|
Parameters: "{}"
|
|
4528
4619
|
};
|
|
4529
4620
|
}
|
|
4530
|
-
function
|
|
4621
|
+
function kh(e) {
|
|
4531
4622
|
return JSON.stringify({
|
|
4532
4623
|
type: "sdk-typescript",
|
|
4533
4624
|
event: { Logs: e }
|
|
4534
4625
|
});
|
|
4535
4626
|
}
|
|
4536
|
-
function
|
|
4627
|
+
function Ah(e) {
|
|
4537
4628
|
if (e.length === 0) return [];
|
|
4538
|
-
let t =
|
|
4629
|
+
let t = xh - kh([]).length, n = [], r = [], i = 0;
|
|
4539
4630
|
for (let a of e) {
|
|
4540
4631
|
let e = JSON.stringify(a).length + 1;
|
|
4541
4632
|
r.length > 0 && i + e > t && (n.push(r), r = [], i = 0), r.push(a), i += e;
|
|
4542
4633
|
}
|
|
4543
4634
|
return r.length > 0 && n.push(r), n;
|
|
4544
4635
|
}
|
|
4545
|
-
async function
|
|
4546
|
-
if (e.length === 0 || !
|
|
4547
|
-
let t = `${
|
|
4636
|
+
async function jh(e) {
|
|
4637
|
+
if (e.length === 0 || !U) return;
|
|
4638
|
+
let t = `${U}/events/logs/json`, n = {
|
|
4548
4639
|
"Content-Type": "application/json",
|
|
4549
|
-
Authorization: `Bearer ${
|
|
4640
|
+
Authorization: `Bearer ${wh}`
|
|
4550
4641
|
}, r = await fetch(t, {
|
|
4551
4642
|
method: "POST",
|
|
4552
4643
|
headers: n,
|
|
4553
|
-
body:
|
|
4554
|
-
signal: B(
|
|
4644
|
+
body: kh(e),
|
|
4645
|
+
signal: B(yh)
|
|
4555
4646
|
});
|
|
4556
4647
|
if (!r.ok) {
|
|
4557
4648
|
if (r.status >= 400 && r.status < 500) {
|
|
4558
|
-
|
|
4649
|
+
gh.warn(`Dropping ${e.length} log entries due to ${r.status}`);
|
|
4559
4650
|
return;
|
|
4560
4651
|
}
|
|
4561
4652
|
throw Error(`Failed to send logs: ${r.status}`);
|
|
4562
4653
|
}
|
|
4563
4654
|
}
|
|
4564
|
-
function
|
|
4565
|
-
if (
|
|
4566
|
-
let e =
|
|
4567
|
-
return Math.min(e,
|
|
4568
|
-
}
|
|
4569
|
-
function
|
|
4570
|
-
|
|
4571
|
-
}
|
|
4572
|
-
async function
|
|
4573
|
-
|
|
4574
|
-
let e =
|
|
4575
|
-
if (
|
|
4576
|
-
|
|
4655
|
+
function Mh() {
|
|
4656
|
+
if (K === 0) return _h;
|
|
4657
|
+
let e = _h * (1 << Math.min(K, 6));
|
|
4658
|
+
return Math.min(e, vh);
|
|
4659
|
+
}
|
|
4660
|
+
function Nh(e) {
|
|
4661
|
+
U && (W = setTimeout(() => void Ph(), e));
|
|
4662
|
+
}
|
|
4663
|
+
async function Ph() {
|
|
4664
|
+
W = void 0;
|
|
4665
|
+
let e = fh();
|
|
4666
|
+
if (G = G.concat(e.map(Oh)), typeof navigator < "u" && navigator.onLine === !1) {
|
|
4667
|
+
Nh(_h);
|
|
4577
4668
|
return;
|
|
4578
4669
|
}
|
|
4579
|
-
if (
|
|
4580
|
-
|
|
4670
|
+
if (G.length === 0) {
|
|
4671
|
+
Nh(_h);
|
|
4581
4672
|
return;
|
|
4582
4673
|
}
|
|
4583
|
-
let t =
|
|
4584
|
-
|
|
4585
|
-
let n =
|
|
4674
|
+
let t = G;
|
|
4675
|
+
G = [];
|
|
4676
|
+
let n = Ah(t), r = !1;
|
|
4586
4677
|
for (let e = 0; e < n.length; e++) try {
|
|
4587
|
-
await
|
|
4678
|
+
await jh(n[e]);
|
|
4588
4679
|
} catch {
|
|
4589
|
-
|
|
4680
|
+
G = n.slice(e).flat().concat(G), r = !0;
|
|
4590
4681
|
break;
|
|
4591
4682
|
}
|
|
4592
|
-
r ?
|
|
4683
|
+
r ? K++ : K = 0, Nh(Mh());
|
|
4593
4684
|
}
|
|
4594
|
-
function
|
|
4595
|
-
|
|
4685
|
+
function Fh() {
|
|
4686
|
+
W !== void 0 && (clearTimeout(W), W = void 0), Nh(0);
|
|
4596
4687
|
}
|
|
4597
|
-
function
|
|
4598
|
-
let n =
|
|
4599
|
-
|
|
4688
|
+
function Ih(e, t) {
|
|
4689
|
+
let n = Eh === 0;
|
|
4690
|
+
Eh++, U = e, wh = t, K = 0, n && (G = [], typeof window < "u" && (Th = Fh, window.addEventListener("online", Th)), Nh(_h));
|
|
4600
4691
|
}
|
|
4601
|
-
function
|
|
4602
|
-
|
|
4692
|
+
function Lh(e) {
|
|
4693
|
+
U && (wh = e, K = 0);
|
|
4603
4694
|
}
|
|
4604
|
-
function
|
|
4605
|
-
if (!
|
|
4695
|
+
function Rh(e, t) {
|
|
4696
|
+
if (!U || !wh) return;
|
|
4606
4697
|
let n = { Events: [{
|
|
4607
4698
|
Time: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4608
4699
|
EventName: e,
|
|
@@ -4612,47 +4703,47 @@ function jh(e, t) {
|
|
|
4612
4703
|
type: "sdk-typescript",
|
|
4613
4704
|
event: n
|
|
4614
4705
|
});
|
|
4615
|
-
fetch(`${
|
|
4706
|
+
fetch(`${U}/events/analytics/json`, {
|
|
4616
4707
|
method: "POST",
|
|
4617
4708
|
headers: {
|
|
4618
4709
|
"Content-Type": "application/json",
|
|
4619
|
-
Authorization: `Bearer ${
|
|
4710
|
+
Authorization: `Bearer ${wh}`
|
|
4620
4711
|
},
|
|
4621
4712
|
body: r
|
|
4622
|
-
}).catch((t) =>
|
|
4713
|
+
}).catch((t) => gh.warn(`Failed to send analytics event ${e}: ${t}`));
|
|
4623
4714
|
}
|
|
4624
|
-
function
|
|
4625
|
-
|
|
4715
|
+
function zh() {
|
|
4716
|
+
Eh > 0 && Eh--, !(Eh > 0) && (W !== void 0 && (clearTimeout(W), W = void 0), Th !== void 0 && typeof window < "u" && (window.removeEventListener("online", Th), Th = void 0), U = void 0, wh = void 0, G = [], K = 0);
|
|
4626
4717
|
}
|
|
4627
4718
|
//#endregion
|
|
4628
4719
|
//#region src/utils/connect-timeline.ts
|
|
4629
|
-
var
|
|
4630
|
-
function
|
|
4720
|
+
var Bh = w("ConnectTimeline"), Vh = "ikon-connect-trace-id", Hh, Uh = !1;
|
|
4721
|
+
function Wh() {
|
|
4631
4722
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`;
|
|
4632
4723
|
}
|
|
4633
|
-
function
|
|
4724
|
+
function Gh() {
|
|
4634
4725
|
try {
|
|
4635
|
-
let e = sessionStorage.getItem(
|
|
4726
|
+
let e = sessionStorage.getItem(Vh);
|
|
4636
4727
|
if (e) return e;
|
|
4637
|
-
let t =
|
|
4638
|
-
return sessionStorage.setItem(
|
|
4728
|
+
let t = Wh();
|
|
4729
|
+
return sessionStorage.setItem(Vh, t), t;
|
|
4639
4730
|
} catch {
|
|
4640
|
-
return
|
|
4731
|
+
return Hh ??= Wh(), Hh;
|
|
4641
4732
|
}
|
|
4642
4733
|
}
|
|
4643
|
-
function
|
|
4734
|
+
function Kh(e) {
|
|
4644
4735
|
if (typeof performance > "u" || typeof performance.getEntriesByType != "function") return;
|
|
4645
4736
|
let t = performance.getEntriesByType("resource");
|
|
4646
4737
|
for (let n = t.length - 1; n >= 0; n--) if (t[n].name.includes(e)) return Math.round(t[n].duration);
|
|
4647
4738
|
}
|
|
4648
|
-
var
|
|
4739
|
+
var qh = [
|
|
4649
4740
|
"/anonymous",
|
|
4650
4741
|
"/init",
|
|
4651
4742
|
"/connect"
|
|
4652
4743
|
];
|
|
4653
|
-
function
|
|
4744
|
+
function Jh() {
|
|
4654
4745
|
if (typeof performance > "u" || typeof performance.getEntriesByType != "function") return;
|
|
4655
|
-
let e = performance.getEntriesByType("resource").filter((e) => !
|
|
4746
|
+
let e = performance.getEntriesByType("resource").filter((e) => !qh.some((t) => e.name.includes(t)));
|
|
4656
4747
|
if (e.length === 0) return;
|
|
4657
4748
|
let t = [], n = 0, r = 0, i = 0;
|
|
4658
4749
|
for (let a of e) t.push(a.duration), a.transferSize === 0 && a.decodedBodySize === 0 ? i++ : a.transferSize === 0 ? r++ : n += a.transferSize;
|
|
@@ -4665,33 +4756,33 @@ function Vh() {
|
|
|
4665
4756
|
assetOpaqueCount: i
|
|
4666
4757
|
};
|
|
4667
4758
|
}
|
|
4668
|
-
function
|
|
4669
|
-
if (
|
|
4670
|
-
|
|
4671
|
-
let t = { connectTraceId:
|
|
4759
|
+
function Yh(e = {}) {
|
|
4760
|
+
if (Uh) return;
|
|
4761
|
+
Uh = !0;
|
|
4762
|
+
let t = { connectTraceId: Gh() };
|
|
4672
4763
|
e.snapshotSeeded !== void 0 && (t.snapshotSeeded = String(e.snapshotSeeded));
|
|
4673
4764
|
try {
|
|
4674
4765
|
if (typeof performance < "u") {
|
|
4675
4766
|
t.firstPaintMs = String(Math.round(performance.now()));
|
|
4676
4767
|
let e = performance.getEntriesByType("navigation")[0];
|
|
4677
4768
|
e && (t.cdnHtmlMs = String(Math.round(e.responseEnd - e.fetchStart)), t.domContentLoadedMs = String(Math.round(e.domContentLoadedEventEnd)));
|
|
4678
|
-
let n =
|
|
4769
|
+
let n = Kh("/anonymous");
|
|
4679
4770
|
n !== void 0 && (t.authMs = String(n));
|
|
4680
|
-
let r =
|
|
4771
|
+
let r = Kh("/init");
|
|
4681
4772
|
r !== void 0 && (t.initMs = String(r));
|
|
4682
|
-
let i =
|
|
4773
|
+
let i = Kh("/connect");
|
|
4683
4774
|
i !== void 0 && (t.connectMs = String(i));
|
|
4684
|
-
let a =
|
|
4775
|
+
let a = Jh();
|
|
4685
4776
|
if (a) for (let [e, n] of Object.entries(a)) t[e] = String(n);
|
|
4686
4777
|
}
|
|
4687
4778
|
} catch (e) {
|
|
4688
|
-
|
|
4779
|
+
Bh.warn(`Failed to read performance timeline: ${e}`);
|
|
4689
4780
|
}
|
|
4690
|
-
|
|
4781
|
+
Rh("client_connect_timeline", t);
|
|
4691
4782
|
}
|
|
4692
4783
|
//#endregion
|
|
4693
4784
|
//#region src/utils/uuid.ts
|
|
4694
|
-
function
|
|
4785
|
+
function Xh() {
|
|
4695
4786
|
let e = globalThis.crypto;
|
|
4696
4787
|
if (e && typeof e.randomUUID == "function") return e.randomUUID();
|
|
4697
4788
|
let t = /* @__PURE__ */ new Uint8Array(16);
|
|
@@ -4704,34 +4795,34 @@ function Uh() {
|
|
|
4704
4795
|
}
|
|
4705
4796
|
//#endregion
|
|
4706
4797
|
//#region src/storage.ts
|
|
4707
|
-
var
|
|
4708
|
-
function
|
|
4709
|
-
if (typeof window > "u" || typeof localStorage > "u") return
|
|
4798
|
+
var Zh = "ikon-device-id";
|
|
4799
|
+
function Qh() {
|
|
4800
|
+
if (typeof window > "u" || typeof localStorage > "u") return Xh();
|
|
4710
4801
|
try {
|
|
4711
|
-
let e = localStorage.getItem(
|
|
4712
|
-
return e || (e =
|
|
4802
|
+
let e = localStorage.getItem(Zh);
|
|
4803
|
+
return e || (e = Xh(), localStorage.setItem(Zh, e)), e;
|
|
4713
4804
|
} catch {
|
|
4714
|
-
return
|
|
4805
|
+
return Xh();
|
|
4715
4806
|
}
|
|
4716
4807
|
}
|
|
4717
|
-
function
|
|
4808
|
+
function $h() {
|
|
4718
4809
|
if (!(typeof localStorage > "u")) try {
|
|
4719
|
-
localStorage.removeItem(
|
|
4810
|
+
localStorage.removeItem(Zh);
|
|
4720
4811
|
} catch {}
|
|
4721
4812
|
}
|
|
4722
|
-
function
|
|
4723
|
-
let t =
|
|
4813
|
+
function eg(e) {
|
|
4814
|
+
let t = ng(e);
|
|
4724
4815
|
return typeof t?.id == "string" ? t.id : null;
|
|
4725
4816
|
}
|
|
4726
|
-
function
|
|
4727
|
-
let t =
|
|
4817
|
+
function tg(e) {
|
|
4818
|
+
let t = ng(e);
|
|
4728
4819
|
return t ? {
|
|
4729
4820
|
userId: typeof t.id == "string" ? t.id : null,
|
|
4730
4821
|
authSession: typeof t.authSession == "string" ? t.authSession : null,
|
|
4731
4822
|
role: typeof t.role == "string" ? t.role : null
|
|
4732
4823
|
} : null;
|
|
4733
4824
|
}
|
|
4734
|
-
function
|
|
4825
|
+
function ng(e) {
|
|
4735
4826
|
try {
|
|
4736
4827
|
let t = e.split(".");
|
|
4737
4828
|
if (t.length !== 3) return null;
|
|
@@ -4743,8 +4834,8 @@ function Yh(e) {
|
|
|
4743
4834
|
}
|
|
4744
4835
|
//#endregion
|
|
4745
4836
|
//#region src/connection/authenticator.ts
|
|
4746
|
-
var
|
|
4747
|
-
function
|
|
4837
|
+
var q = w("Authenticator"), rg = T.GROUP_CORE | T.GROUP_KEEPALIVE | T.GROUP_EVENTS | T.GROUP_ACTIONS | T.GROUP_UI | T.GROUP_AUDIO | T.GROUP_VIDEO | T.GROUP_ANALYTICS | T.GROUP_APP_LOCAL, ig = 2, ag = 6e4, og = 2e3, sg = 1e4, cg = 3e3, lg = 3e3, ug = 3, dg = "X-Ikon-Startup-Failed", fg = "startup_failed", pg = 1e3, mg = 5, hg = "env";
|
|
4838
|
+
function gg(e) {
|
|
4748
4839
|
let t = e.streamPath ? Uf(e.streamPath) : null;
|
|
4749
4840
|
return {
|
|
4750
4841
|
direct: e.url,
|
|
@@ -4752,7 +4843,7 @@ function lg(e) {
|
|
|
4752
4843
|
lb: t ?? void 0
|
|
4753
4844
|
};
|
|
4754
4845
|
}
|
|
4755
|
-
async function
|
|
4846
|
+
async function _g(e, t, n, r) {
|
|
4756
4847
|
if (e) try {
|
|
4757
4848
|
let i = await fetch(`${n}/anonymous`, {
|
|
4758
4849
|
method: "POST",
|
|
@@ -4765,17 +4856,17 @@ async function ug(e, t, n, r) {
|
|
|
4765
4856
|
});
|
|
4766
4857
|
if (!i.ok) {
|
|
4767
4858
|
let e = await i.text().catch(() => "");
|
|
4768
|
-
|
|
4859
|
+
q.warn(`Anonymous auth failed: ${i.status} ${e}`.trim());
|
|
4769
4860
|
return;
|
|
4770
4861
|
}
|
|
4771
4862
|
let a = await i.json();
|
|
4772
4863
|
if (!a.token) {
|
|
4773
|
-
|
|
4864
|
+
q.warn("Anonymous auth returned no token");
|
|
4774
4865
|
return;
|
|
4775
4866
|
}
|
|
4776
|
-
let o =
|
|
4867
|
+
let o = eg(a.token);
|
|
4777
4868
|
if (!o) {
|
|
4778
|
-
|
|
4869
|
+
q.warn("Anonymous auth token had no extractable userId");
|
|
4779
4870
|
return;
|
|
4780
4871
|
}
|
|
4781
4872
|
return {
|
|
@@ -4783,23 +4874,23 @@ async function ug(e, t, n, r) {
|
|
|
4783
4874
|
token: a.token
|
|
4784
4875
|
};
|
|
4785
4876
|
} catch (e) {
|
|
4786
|
-
|
|
4877
|
+
q.warn("Anonymous auth request failed:", e);
|
|
4787
4878
|
return;
|
|
4788
4879
|
}
|
|
4789
4880
|
}
|
|
4790
|
-
async function
|
|
4881
|
+
async function vg(e, t, n, r) {
|
|
4791
4882
|
try {
|
|
4792
4883
|
let i = await fetch(`${e}/profiles/me?space=${encodeURIComponent(t)}`, {
|
|
4793
4884
|
method: "GET",
|
|
4794
4885
|
headers: { Authorization: `Bearer ${n}` },
|
|
4795
4886
|
signal: r
|
|
4796
4887
|
});
|
|
4797
|
-
i.ok ||
|
|
4888
|
+
i.ok || q.warn(`Failed to ensure profile: ${i.status}`);
|
|
4798
4889
|
} catch (e) {
|
|
4799
|
-
|
|
4890
|
+
q.warn("Failed to ensure profile:", e);
|
|
4800
4891
|
}
|
|
4801
4892
|
}
|
|
4802
|
-
async function
|
|
4893
|
+
async function yg(e) {
|
|
4803
4894
|
let t = await e.text().catch(() => "Unknown error");
|
|
4804
4895
|
try {
|
|
4805
4896
|
let e = JSON.parse(t);
|
|
@@ -4807,16 +4898,16 @@ async function fg(e) {
|
|
|
4807
4898
|
} catch {}
|
|
4808
4899
|
return t;
|
|
4809
4900
|
}
|
|
4810
|
-
async function
|
|
4901
|
+
async function bg(e) {
|
|
4811
4902
|
if (e.ok) return;
|
|
4812
|
-
let t = await
|
|
4813
|
-
throw e.status === 403 ? new
|
|
4903
|
+
let t = await yg(e);
|
|
4904
|
+
throw e.status === 403 ? new ou(`Access denied: ${t}`, t) : xg("Failed to get or create profile", e.status, t);
|
|
4814
4905
|
}
|
|
4815
|
-
function
|
|
4906
|
+
function xg(e, t, n) {
|
|
4816
4907
|
let r = `${e}: ${t} ${n}`;
|
|
4817
|
-
return t >= 500 ? new
|
|
4908
|
+
return t >= 500 ? new uu(r, t) : new D(r);
|
|
4818
4909
|
}
|
|
4819
|
-
function
|
|
4910
|
+
function Sg(e, t, n) {
|
|
4820
4911
|
let r = {
|
|
4821
4912
|
method: "POST",
|
|
4822
4913
|
headers: {
|
|
@@ -4828,69 +4919,69 @@ function hg(e, t, n) {
|
|
|
4828
4919
|
};
|
|
4829
4920
|
return t || (r.credentials = "include"), r;
|
|
4830
4921
|
}
|
|
4831
|
-
async function
|
|
4832
|
-
let i = `${e}/init`, a = await fetch(i,
|
|
4922
|
+
async function Cg(e, t, n, r) {
|
|
4923
|
+
let i = `${e}/init`, a = await fetch(i, Sg(t, n, r));
|
|
4833
4924
|
if (!a.ok) {
|
|
4834
|
-
let e = await
|
|
4835
|
-
throw a.status === 401 ? new
|
|
4925
|
+
let e = await yg(a);
|
|
4926
|
+
throw a.status === 401 ? new su(`Backend rejected the credential: ${e}`) : a.status === 403 ? new ou(`Access denied: ${e}`, e) : a.status === 404 && t.sessionIdentityHash ? new cu(t.sessionIdentityHash) : xg("Backend init failed", a.status, e);
|
|
4836
4927
|
}
|
|
4837
4928
|
return a.json();
|
|
4838
4929
|
}
|
|
4839
|
-
function
|
|
4840
|
-
return e.startupFailed ? new
|
|
4930
|
+
function wg(e, t) {
|
|
4931
|
+
return e.startupFailed ? new iu() : new ru(t);
|
|
4841
4932
|
}
|
|
4842
|
-
async function
|
|
4843
|
-
e =
|
|
4844
|
-
let i = B(n ??
|
|
4933
|
+
async function Tg(e, t, n, r) {
|
|
4934
|
+
e = kg(e, r);
|
|
4935
|
+
let i = B(n ?? sg), a = t ? kf([t, i]) : i, o = Date.now(), s = await fetch(e, { signal: a });
|
|
4845
4936
|
if (!s.ok) {
|
|
4846
4937
|
let e = await s.text().catch(() => "Unknown error");
|
|
4847
|
-
throw s.status === 429 ? new
|
|
4938
|
+
throw s.status === 429 ? new lu(`Server is at capacity: ${e}`) : s.headers.get(dg) || e.includes(fg) ? new iu() : xg("Failed to connect", s.status, e);
|
|
4848
4939
|
}
|
|
4849
4940
|
let c = await s.arrayBuffer(), l = await ir(new Uint8Array(c));
|
|
4850
|
-
return
|
|
4941
|
+
return q.debug(`Connect URL fetched in ${Date.now() - o}ms`), { authResponse: l };
|
|
4851
4942
|
}
|
|
4852
|
-
async function
|
|
4943
|
+
async function Eg(e, t) {
|
|
4853
4944
|
try {
|
|
4854
|
-
let n = new URL(e), r = `${n.protocol}//${n.host}/health`, i = B(
|
|
4945
|
+
let n = new URL(e), r = `${n.protocol}//${n.host}/health`, i = B(lg), a = t ? kf([t, i]) : i;
|
|
4855
4946
|
return (await fetch(r, { signal: a })).ok;
|
|
4856
4947
|
} catch {
|
|
4857
4948
|
return !1;
|
|
4858
4949
|
}
|
|
4859
4950
|
}
|
|
4860
|
-
async function
|
|
4951
|
+
async function Dg(e, t, n, r) {
|
|
4861
4952
|
let i = tf(R.filter((t) => e[t]), n, t).map((t) => ({
|
|
4862
4953
|
tier: t,
|
|
4863
4954
|
url: e[t]
|
|
4864
4955
|
}));
|
|
4865
|
-
if (i.length === 0) throw new
|
|
4866
|
-
|
|
4956
|
+
if (i.length === 0) throw new D("No connect URL available");
|
|
4957
|
+
q.debug(`Auth URL order: [${i.map((e) => e.tier).join(", ")}], mode: ${t}, learned tier: ${n}`);
|
|
4867
4958
|
let a = t === "auto" && i.length > 1 && i[0].tier === "direct", o = Date.now(), s = 0;
|
|
4868
|
-
for (; s <
|
|
4959
|
+
for (; s < ig || Date.now() - o < ag;) {
|
|
4869
4960
|
for (let t = 0; t < i.length; t++) {
|
|
4870
|
-
let n = i[t], o = s === 0 && t === 0 && a ?
|
|
4961
|
+
let n = i[t], o = s === 0 && t === 0 && a ? cg : sg;
|
|
4871
4962
|
try {
|
|
4872
|
-
let t = await
|
|
4873
|
-
return t.usedProxyUrl = n.tier !== "direct", t.connectTier = n.tier, t.connectTierUrls = e, t.directUrl = e.direct,
|
|
4963
|
+
let t = await Tg(n.url, r, o);
|
|
4964
|
+
return t.usedProxyUrl = n.tier !== "direct", t.connectTier = n.tier, t.connectTierUrls = e, t.directUrl = e.direct, q.debug(`Auth succeeded via the ${n.tier} URL`), t;
|
|
4874
4965
|
} catch (e) {
|
|
4875
|
-
if (r?.aborted || e instanceof
|
|
4876
|
-
|
|
4966
|
+
if (r?.aborted || e instanceof lu || e instanceof iu) throw e;
|
|
4967
|
+
q.warn(`Auth via the ${n.tier} URL failed (round ${s + 1}, timeout ${o}ms): ${e}`);
|
|
4877
4968
|
}
|
|
4878
4969
|
}
|
|
4879
|
-
s++, await
|
|
4970
|
+
s++, await pu(og, r);
|
|
4880
4971
|
}
|
|
4881
|
-
throw new
|
|
4972
|
+
throw new D("Failed to connect after exhausting all URL attempts");
|
|
4882
4973
|
}
|
|
4883
|
-
function
|
|
4974
|
+
function Og(e = {}) {
|
|
4884
4975
|
let t = Rp();
|
|
4885
4976
|
return jt({
|
|
4886
4977
|
Description: "Ikon SDK TypeScript",
|
|
4887
4978
|
ProductId: "ikon-sdk",
|
|
4888
4979
|
VersionId: "1.0.0",
|
|
4889
|
-
DeviceId:
|
|
4980
|
+
DeviceId: Qh(),
|
|
4890
4981
|
Locale: typeof navigator < "u" ? navigator.language : "en-US",
|
|
4891
4982
|
UserAgent: typeof navigator < "u" ? navigator.userAgent : "",
|
|
4892
4983
|
ClientType: Xp(),
|
|
4893
|
-
SdkCapability:
|
|
4984
|
+
SdkCapability: mg,
|
|
4894
4985
|
ProtocolVersion: 1,
|
|
4895
4986
|
PayloadType: pe.Teleport,
|
|
4896
4987
|
SupportsCompression: De(),
|
|
@@ -4901,37 +4992,37 @@ function xg(e = {}) {
|
|
|
4901
4992
|
IsTouchDevice: Yp(),
|
|
4902
4993
|
InitialPath: rp(),
|
|
4903
4994
|
InitialUrl: ip(),
|
|
4904
|
-
IsSnapshot:
|
|
4995
|
+
IsSnapshot: Xu(),
|
|
4905
4996
|
...e
|
|
4906
4997
|
});
|
|
4907
4998
|
}
|
|
4908
|
-
function
|
|
4909
|
-
if (e.includes(`${
|
|
4910
|
-
let n =
|
|
4911
|
-
return `${e}${e.includes("?") ? "&" : "?"}${
|
|
4999
|
+
function kg(e, t) {
|
|
5000
|
+
if (e.includes(`${hg}=`)) return e;
|
|
5001
|
+
let n = Ag(Nt(t ?? Og()));
|
|
5002
|
+
return `${e}${e.includes("?") ? "&" : "?"}${hg}=${n}`;
|
|
4912
5003
|
}
|
|
4913
|
-
function
|
|
5004
|
+
function Ag(e) {
|
|
4914
5005
|
let t = "";
|
|
4915
5006
|
for (let n of e) t += String.fromCharCode(n);
|
|
4916
5007
|
return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
4917
5008
|
}
|
|
4918
|
-
function
|
|
5009
|
+
function jg(e, t, n = "", r = !0) {
|
|
4919
5010
|
return Ft({
|
|
4920
5011
|
ServerSessionId: "",
|
|
4921
5012
|
ContextType: m.Browser,
|
|
4922
5013
|
UserType: p.Human,
|
|
4923
5014
|
IsInternal: !1,
|
|
4924
5015
|
UserId: t,
|
|
4925
|
-
OpcodeGroupsFromServer: e.opcodeGroupsFromServer ??
|
|
4926
|
-
OpcodeGroupsToServer: e.opcodeGroupsToServer ??
|
|
5016
|
+
OpcodeGroupsFromServer: e.opcodeGroupsFromServer ?? rg,
|
|
5017
|
+
OpcodeGroupsToServer: e.opcodeGroupsToServer ?? rg,
|
|
4927
5018
|
AuthSessionId: n,
|
|
4928
5019
|
IsAnonymous: r,
|
|
4929
5020
|
IsGlobal: !1,
|
|
4930
5021
|
Parameters: e.parameters ?? {}
|
|
4931
5022
|
});
|
|
4932
5023
|
}
|
|
4933
|
-
function
|
|
4934
|
-
return
|
|
5024
|
+
function Mg(e) {
|
|
5025
|
+
return Og({
|
|
4935
5026
|
...e.description === void 0 ? {} : { Description: e.description },
|
|
4936
5027
|
...e.deviceId === void 0 ? {} : { DeviceId: e.deviceId },
|
|
4937
5028
|
...e.productId === void 0 ? {} : { ProductId: e.productId },
|
|
@@ -4940,7 +5031,7 @@ function Tg(e) {
|
|
|
4940
5031
|
...e.locale === void 0 ? {} : { Locale: e.locale }
|
|
4941
5032
|
});
|
|
4942
5033
|
}
|
|
4943
|
-
function
|
|
5034
|
+
function Ng(e) {
|
|
4944
5035
|
return {
|
|
4945
5036
|
ServerSessionId: e.ServerSessionId,
|
|
4946
5037
|
ContextType: e.ContextType,
|
|
@@ -4955,26 +5046,26 @@ function Eg(e) {
|
|
|
4955
5046
|
Parameters: e.Parameters
|
|
4956
5047
|
};
|
|
4957
5048
|
}
|
|
4958
|
-
async function
|
|
5049
|
+
async function Pg(e, t) {
|
|
4959
5050
|
let n = `https://${e.host}:${e.httpsPort}`;
|
|
4960
|
-
|
|
5051
|
+
q.debug(`Authenticating with local server: ${n}`);
|
|
4961
5052
|
let r = {
|
|
4962
5053
|
...Zf(),
|
|
4963
5054
|
...e.parameters
|
|
4964
|
-
}, i = e.deviceId ??
|
|
5055
|
+
}, i = e.deviceId ?? Qh(), a = e.userId, o = e.token;
|
|
4965
5056
|
if (!a) {
|
|
4966
|
-
let n = await
|
|
5057
|
+
let n = await _g(e.spaceId, i, await Yf(e.authUrl), t);
|
|
4967
5058
|
n && (a = n.userId, o = n.token);
|
|
4968
5059
|
}
|
|
4969
|
-
if (a || (a = i,
|
|
5060
|
+
if (a || (a = i, q.debug("Using deviceId as userId fallback")), e.spaceId && o) if (e.token) {
|
|
4970
5061
|
let n = Kf(e.backendUrl);
|
|
4971
|
-
await
|
|
5062
|
+
await bg(await fetch(`${n}/profiles/me?space=${encodeURIComponent(e.spaceId)}`, {
|
|
4972
5063
|
method: "GET",
|
|
4973
5064
|
headers: { Authorization: `Bearer ${o}` },
|
|
4974
5065
|
signal: t
|
|
4975
5066
|
}));
|
|
4976
|
-
} else await
|
|
4977
|
-
let s = e.token ?? e.identityToken ?? o, c = s ?
|
|
5067
|
+
} else await vg(Kf(e.backendUrl), e.spaceId, o, t);
|
|
5068
|
+
let s = e.token ?? e.identityToken ?? o, c = s ? tg(s) : null, l = c?.authSession ?? (e.token ? "authenticated" : ""), u = c?.role ? c.role === "anonymous" : !e.token, d = Ng(jg({
|
|
4978
5069
|
...e,
|
|
4979
5070
|
parameters: r
|
|
4980
5071
|
}, a, l, u)), f = await fetch(`${n}/connect-token`, {
|
|
@@ -4985,16 +5076,16 @@ async function Dg(e, t) {
|
|
|
4985
5076
|
});
|
|
4986
5077
|
if (!f.ok) {
|
|
4987
5078
|
let e = await f.text().catch(() => "Unknown error");
|
|
4988
|
-
throw
|
|
5079
|
+
throw xg("Failed to get connect token", f.status, e);
|
|
4989
5080
|
}
|
|
4990
5081
|
let p = (await f.json()).token;
|
|
4991
|
-
if (!p) throw new
|
|
4992
|
-
let m = `${n}/connect?token=${encodeURIComponent(p)}`, h = await
|
|
5082
|
+
if (!p) throw new D("Server did not return a token");
|
|
5083
|
+
let m = `${n}/connect?token=${encodeURIComponent(p)}`, h = await Tg(m, t, void 0, Mg(e));
|
|
4993
5084
|
return h.directUrl = m, h.backendUrl = Kf(e.backendUrl), h.authToken = o, h;
|
|
4994
5085
|
}
|
|
4995
|
-
async function
|
|
5086
|
+
async function Fg(e, t, n = "auto", r = "direct") {
|
|
4996
5087
|
let i = Gf(e.backendType);
|
|
4997
|
-
|
|
5088
|
+
q.debug(`Authenticating with cloud server: ${i}, space ID: ${e.spaceId}`);
|
|
4998
5089
|
let a = await fetch(`${i}/auth/api-key`, {
|
|
4999
5090
|
method: "POST",
|
|
5000
5091
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5007,14 +5098,14 @@ async function Og(e, t, n = "auto", r = "direct") {
|
|
|
5007
5098
|
});
|
|
5008
5099
|
if (!a.ok) {
|
|
5009
5100
|
let e = await a.text().catch(() => "Unknown error");
|
|
5010
|
-
throw
|
|
5101
|
+
throw xg("API key authentication failed", a.status, e);
|
|
5011
5102
|
}
|
|
5012
5103
|
let o = (await a.json()).token;
|
|
5013
|
-
if (!o) throw new
|
|
5104
|
+
if (!o) throw new D("Backend did not return a token");
|
|
5014
5105
|
let s = Zf(), c = e.provisioningTimeoutMs ?? 6e4, l = {
|
|
5015
5106
|
...s,
|
|
5016
5107
|
...e.parameters
|
|
5017
|
-
}, u = Rp(), d =
|
|
5108
|
+
}, u = Rp(), d = M() ? ug : 1;
|
|
5018
5109
|
for (let a = 0; a < d; a++) try {
|
|
5019
5110
|
let a = {
|
|
5020
5111
|
space: e.spaceId,
|
|
@@ -5022,19 +5113,19 @@ async function Og(e, t, n = "auto", r = "direct") {
|
|
|
5022
5113
|
params: e.parameters,
|
|
5023
5114
|
waitForRunning: !0,
|
|
5024
5115
|
waitForRunningTimeoutMs: c,
|
|
5025
|
-
connectTraceId:
|
|
5116
|
+
connectTraceId: Gh(),
|
|
5026
5117
|
contextType: m.Plugin,
|
|
5027
5118
|
userType: e.userType ?? p.Human,
|
|
5028
5119
|
clientType: e.clientType ?? Xp(),
|
|
5029
5120
|
payloadType: pe.Teleport,
|
|
5030
5121
|
description: e.description ?? "Ikon SDK TypeScript",
|
|
5031
|
-
deviceId: e.deviceId ??
|
|
5122
|
+
deviceId: e.deviceId ?? Qh(),
|
|
5032
5123
|
productId: e.productId ?? "",
|
|
5033
5124
|
versionId: e.versionId ?? "",
|
|
5034
5125
|
installId: e.installId ?? "",
|
|
5035
5126
|
locale: e.locale ?? (typeof navigator < "u" ? navigator.language : "en-US"),
|
|
5036
|
-
opcodeGroupsFromServer: e.opcodeGroupsFromServer ??
|
|
5037
|
-
opcodeGroupsToServer: e.opcodeGroupsToServer ??
|
|
5127
|
+
opcodeGroupsFromServer: e.opcodeGroupsFromServer ?? rg,
|
|
5128
|
+
opcodeGroupsToServer: e.opcodeGroupsToServer ?? rg,
|
|
5038
5129
|
protocolVersion: 1,
|
|
5039
5130
|
userAgent: typeof navigator < "u" ? navigator.userAgent : "",
|
|
5040
5131
|
launchParams: l,
|
|
@@ -5046,26 +5137,26 @@ async function Og(e, t, n = "auto", r = "direct") {
|
|
|
5046
5137
|
initialPath: rp(),
|
|
5047
5138
|
initialUrl: ip(),
|
|
5048
5139
|
sdkType: 2,
|
|
5049
|
-
sdkCapability:
|
|
5140
|
+
sdkCapability: mg,
|
|
5050
5141
|
supportsCompression: De(),
|
|
5051
|
-
isSnapshot:
|
|
5052
|
-
}, s = t ? kf([t, B(c)]) : B(c), d = await
|
|
5053
|
-
if (d.state?.toLowerCase() !== "running" || !d.configuration?.url) throw
|
|
5054
|
-
let f = await
|
|
5055
|
-
return f.backendUrl = i, f.authToken = o, f.brandingRequired = d.configuration.brandingRequired ?? !1,
|
|
5142
|
+
isSnapshot: Xu()
|
|
5143
|
+
}, s = t ? kf([t, B(c)]) : B(c), d = await Cg(i, a, o, s);
|
|
5144
|
+
if (d.state?.toLowerCase() !== "running" || !d.configuration?.url) throw wg(d, c);
|
|
5145
|
+
let f = await Dg(gg(d.configuration), n, r, s);
|
|
5146
|
+
return f.backendUrl = i, f.authToken = o, f.brandingRequired = d.configuration.brandingRequired ?? !1, Xm(d.configuration.push), f;
|
|
5056
5147
|
} catch (e) {
|
|
5057
|
-
if (e instanceof
|
|
5058
|
-
|
|
5148
|
+
if (e instanceof su || e instanceof ou || e instanceof lu || e instanceof cu || e instanceof iu || a === d - 1) throw e;
|
|
5149
|
+
q.debug(`Init attempt ${a + 1}/${d} failed, retrying: ${e}`), await pu(pg * (a + 1), t);
|
|
5059
5150
|
}
|
|
5060
|
-
throw new
|
|
5151
|
+
throw new D("Failed to init after all attempts");
|
|
5061
5152
|
}
|
|
5062
|
-
async function
|
|
5153
|
+
async function Ig(e, t, n = "auto", r = "direct") {
|
|
5063
5154
|
let i = Gf(e.backendType), a = e.token;
|
|
5064
|
-
|
|
5155
|
+
q.debug(`Authenticating with session token to: ${i}, space ID: ${e.spaceId}`);
|
|
5065
5156
|
let o = Zf(), s = e.provisioningTimeoutMs ?? 6e4, c = {
|
|
5066
5157
|
...o,
|
|
5067
5158
|
...e.parameters
|
|
5068
|
-
}, l = Rp(), u =
|
|
5159
|
+
}, l = Rp(), u = M() ? ug : 1;
|
|
5069
5160
|
for (let o = 0; o < u; o++) try {
|
|
5070
5161
|
let o = {
|
|
5071
5162
|
space: e.spaceId,
|
|
@@ -5073,19 +5164,19 @@ async function kg(e, t, n = "auto", r = "direct") {
|
|
|
5073
5164
|
params: e.parameters,
|
|
5074
5165
|
waitForRunning: !0,
|
|
5075
5166
|
waitForRunningTimeoutMs: s,
|
|
5076
|
-
connectTraceId:
|
|
5167
|
+
connectTraceId: Gh(),
|
|
5077
5168
|
contextType: m.Browser,
|
|
5078
5169
|
userType: p.Human,
|
|
5079
5170
|
clientType: Xp(),
|
|
5080
5171
|
payloadType: pe.Teleport,
|
|
5081
5172
|
description: e.description ?? "Ikon SDK TypeScript",
|
|
5082
|
-
deviceId: e.deviceId ??
|
|
5173
|
+
deviceId: e.deviceId ?? Qh(),
|
|
5083
5174
|
productId: e.productId ?? "",
|
|
5084
5175
|
versionId: e.versionId ?? "",
|
|
5085
5176
|
installId: e.installId ?? "",
|
|
5086
5177
|
locale: e.locale ?? (typeof navigator < "u" ? navigator.language : "en-US"),
|
|
5087
|
-
opcodeGroupsFromServer: e.opcodeGroupsFromServer ??
|
|
5088
|
-
opcodeGroupsToServer: e.opcodeGroupsToServer ??
|
|
5178
|
+
opcodeGroupsFromServer: e.opcodeGroupsFromServer ?? rg,
|
|
5179
|
+
opcodeGroupsToServer: e.opcodeGroupsToServer ?? rg,
|
|
5089
5180
|
protocolVersion: 1,
|
|
5090
5181
|
userAgent: typeof navigator < "u" ? navigator.userAgent : "",
|
|
5091
5182
|
launchParams: c,
|
|
@@ -5097,33 +5188,33 @@ async function kg(e, t, n = "auto", r = "direct") {
|
|
|
5097
5188
|
initialPath: rp(),
|
|
5098
5189
|
initialUrl: ip(),
|
|
5099
5190
|
sdkType: 2,
|
|
5100
|
-
sdkCapability:
|
|
5191
|
+
sdkCapability: mg,
|
|
5101
5192
|
supportsCompression: De(),
|
|
5102
|
-
isSnapshot:
|
|
5103
|
-
}, u = t ? kf([t, B(s)]) : B(s), d = await
|
|
5104
|
-
if (d.state?.toLowerCase() !== "running" || !d.configuration?.url) throw
|
|
5105
|
-
let f = await
|
|
5106
|
-
return f.backendUrl = i, f.authToken = a, f.brandingRequired = d.configuration.brandingRequired ?? !1,
|
|
5193
|
+
isSnapshot: Xu()
|
|
5194
|
+
}, u = t ? kf([t, B(s)]) : B(s), d = await Cg(i, o, a, u);
|
|
5195
|
+
if (d.state?.toLowerCase() !== "running" || !d.configuration?.url) throw wg(d, s);
|
|
5196
|
+
let f = await Dg(gg(d.configuration), n, r, u);
|
|
5197
|
+
return f.backendUrl = i, f.authToken = a, f.brandingRequired = d.configuration.brandingRequired ?? !1, Xm(d.configuration.push), f;
|
|
5107
5198
|
} catch (e) {
|
|
5108
|
-
if (e instanceof
|
|
5109
|
-
|
|
5199
|
+
if (e instanceof su || e instanceof ou || e instanceof lu || e instanceof cu || e instanceof iu || o === u - 1) throw e;
|
|
5200
|
+
q.debug(`Init attempt ${o + 1}/${u} failed, retrying: ${e}`), await pu(pg * (o + 1), t);
|
|
5110
5201
|
}
|
|
5111
|
-
throw new
|
|
5202
|
+
throw new D("Failed to init after all attempts");
|
|
5112
5203
|
}
|
|
5113
5204
|
//#endregion
|
|
5114
5205
|
//#region src/functions/type-conversion.ts
|
|
5115
|
-
var
|
|
5116
|
-
function
|
|
5206
|
+
var Lg = /* @__PURE__ */ new Uint8Array();
|
|
5207
|
+
function Rg(e) {
|
|
5117
5208
|
switch (e.kind) {
|
|
5118
5209
|
case "array": return {
|
|
5119
5210
|
kind: "array",
|
|
5120
|
-
element:
|
|
5211
|
+
element: Rg(e.element),
|
|
5121
5212
|
nullable: e.nullable ?? !1
|
|
5122
5213
|
};
|
|
5123
5214
|
case "dictionary": return {
|
|
5124
5215
|
kind: "dictionary",
|
|
5125
5216
|
keyType: e.keyType ?? "string",
|
|
5126
|
-
value:
|
|
5217
|
+
value: Rg(e.value),
|
|
5127
5218
|
nullable: e.nullable ?? !1
|
|
5128
5219
|
};
|
|
5129
5220
|
default: return {
|
|
@@ -5132,17 +5223,17 @@ function jg(e) {
|
|
|
5132
5223
|
};
|
|
5133
5224
|
}
|
|
5134
5225
|
}
|
|
5135
|
-
function
|
|
5226
|
+
function zg(e) {
|
|
5136
5227
|
switch (e.kind) {
|
|
5137
5228
|
case "boolean": return "System.Boolean";
|
|
5138
5229
|
case "number": return "System.Double";
|
|
5139
5230
|
case "string": return "System.String";
|
|
5140
|
-
case "array": return `System.Collections.Generic.List\`1[${
|
|
5141
|
-
case "dictionary": return `System.Collections.Generic.Dictionary\`2[${e.keyType === "int" ? "System.Int32" : "System.String"},${
|
|
5231
|
+
case "array": return `System.Collections.Generic.List\`1[${zg(e.element)}]`;
|
|
5232
|
+
case "dictionary": return `System.Collections.Generic.Dictionary\`2[${e.keyType === "int" ? "System.Int32" : "System.String"},${zg(e.value)}]`;
|
|
5142
5233
|
default: return e;
|
|
5143
5234
|
}
|
|
5144
5235
|
}
|
|
5145
|
-
function
|
|
5236
|
+
function Bg(e, t) {
|
|
5146
5237
|
if (e === void 0 || e === "") return;
|
|
5147
5238
|
let n = JSON.parse(e);
|
|
5148
5239
|
if (n === null) {
|
|
@@ -5151,7 +5242,7 @@ function Ng(e, t) {
|
|
|
5151
5242
|
}
|
|
5152
5243
|
return n;
|
|
5153
5244
|
}
|
|
5154
|
-
function
|
|
5245
|
+
function Vg(e, t) {
|
|
5155
5246
|
if (e === void 0) return "null";
|
|
5156
5247
|
if (e === null) {
|
|
5157
5248
|
if (!t.nullable) throw Error("Value cannot be null for non-nullable type");
|
|
@@ -5159,9 +5250,9 @@ function Pg(e, t) {
|
|
|
5159
5250
|
}
|
|
5160
5251
|
return JSON.stringify(e);
|
|
5161
5252
|
}
|
|
5162
|
-
function
|
|
5253
|
+
function Hg(e, t) {
|
|
5163
5254
|
let r = (e.parameters ?? []).map((e) => {
|
|
5164
|
-
let t =
|
|
5255
|
+
let t = Rg(e.type), n = Object.prototype.hasOwnProperty.call(e, "defaultValue"), r = n ? Vg(e.defaultValue, t) : "";
|
|
5165
5256
|
return {
|
|
5166
5257
|
name: e.name,
|
|
5167
5258
|
descriptor: t,
|
|
@@ -5169,7 +5260,7 @@ function Fg(e, t) {
|
|
|
5169
5260
|
defaultValueJson: r,
|
|
5170
5261
|
description: e.description
|
|
5171
5262
|
};
|
|
5172
|
-
}), i =
|
|
5263
|
+
}), i = Rg(e.returnType);
|
|
5173
5264
|
return {
|
|
5174
5265
|
definition: e,
|
|
5175
5266
|
handler: t,
|
|
@@ -5179,7 +5270,7 @@ function Fg(e, t) {
|
|
|
5179
5270
|
Description: e.description ?? "",
|
|
5180
5271
|
LlmInlineResult: e.llmInlineResult ?? !1,
|
|
5181
5272
|
LlmCallOnlyOnce: e.llmCallOnlyOnce ?? !1,
|
|
5182
|
-
ResultTypeName:
|
|
5273
|
+
ResultTypeName: zg(i),
|
|
5183
5274
|
IsEnumerable: !1,
|
|
5184
5275
|
EnumerableItemTypeName: "",
|
|
5185
5276
|
IsCancellable: !1,
|
|
@@ -5188,10 +5279,10 @@ function Fg(e, t) {
|
|
|
5188
5279
|
Parameters: r.map((e, t) => ({
|
|
5189
5280
|
ParameterIndex: t,
|
|
5190
5281
|
ParameterName: e.name,
|
|
5191
|
-
TypeName:
|
|
5282
|
+
TypeName: zg(e.descriptor),
|
|
5192
5283
|
HasDefaultValue: e.hasDefaultValue,
|
|
5193
5284
|
DefaultValueJson: e.defaultValueJson,
|
|
5194
|
-
DefaultValueData:
|
|
5285
|
+
DefaultValueData: Lg,
|
|
5195
5286
|
IsEnumerable: !1,
|
|
5196
5287
|
EnumerableItemTypeName: "",
|
|
5197
5288
|
Description: e.description ?? ""
|
|
@@ -5203,24 +5294,24 @@ function Fg(e, t) {
|
|
|
5203
5294
|
}
|
|
5204
5295
|
//#endregion
|
|
5205
5296
|
//#region src/functions/types.ts
|
|
5206
|
-
function
|
|
5297
|
+
function Ug(e, t) {
|
|
5207
5298
|
return {
|
|
5208
5299
|
value: e,
|
|
5209
5300
|
data: t
|
|
5210
5301
|
};
|
|
5211
5302
|
}
|
|
5212
|
-
var
|
|
5303
|
+
var Wg = class extends Error {
|
|
5213
5304
|
remoteErrorType;
|
|
5214
5305
|
remoteStackTrace;
|
|
5215
5306
|
code;
|
|
5216
5307
|
constructor(e, t, n, r = "") {
|
|
5217
5308
|
super(e), this.remoteErrorType = t, this.remoteStackTrace = n, this.code = r, this.name = "FunctionCallError";
|
|
5218
5309
|
}
|
|
5219
|
-
},
|
|
5220
|
-
function
|
|
5310
|
+
}, Gg = w("FunctionRegistry"), Kg = /* @__PURE__ */ new Uint8Array(), qg = 3e4;
|
|
5311
|
+
function Jg(e) {
|
|
5221
5312
|
return !e || typeof e != "object" ? !1 : e.data instanceof Uint8Array;
|
|
5222
5313
|
}
|
|
5223
|
-
var
|
|
5314
|
+
var Yg = class {
|
|
5224
5315
|
functions = /* @__PURE__ */ new Map();
|
|
5225
5316
|
remoteFunctions = /* @__PURE__ */ new Map();
|
|
5226
5317
|
pendingCalls = /* @__PURE__ */ new Map();
|
|
@@ -5242,7 +5333,7 @@ var Hg = class {
|
|
|
5242
5333
|
};
|
|
5243
5334
|
}
|
|
5244
5335
|
register(e, t) {
|
|
5245
|
-
let n =
|
|
5336
|
+
let n = Hg(e, t);
|
|
5246
5337
|
return this.functions.set(e.name, n), this.isConnected && this.config && this.sendRegistration(n), () => this.unregister(e.name);
|
|
5247
5338
|
}
|
|
5248
5339
|
unregister(e) {
|
|
@@ -5283,7 +5374,7 @@ var Hg = class {
|
|
|
5283
5374
|
ParameterIndex: t,
|
|
5284
5375
|
TypeName: n ? n.TypeName : this.inferTypeName(e),
|
|
5285
5376
|
ValueJson: JSON.stringify(e ?? null),
|
|
5286
|
-
ValueData:
|
|
5377
|
+
ValueData: Kg
|
|
5287
5378
|
});
|
|
5288
5379
|
}), c = r?.instanceId ? n.fromString(r.instanceId) : n.createZero(), l = jr(wr({
|
|
5289
5380
|
FunctionId: n.fromString(i.id),
|
|
@@ -5296,8 +5387,8 @@ var Hg = class {
|
|
|
5296
5387
|
}), this.config.sessionId, { targetIds: [i.clientSessionId] });
|
|
5297
5388
|
return new Promise((t, n) => {
|
|
5298
5389
|
let r = setTimeout(() => {
|
|
5299
|
-
this.pendingCalls.delete(o.toString()), n(/* @__PURE__ */ Error(`Function call '${e}' timed out after ${
|
|
5300
|
-
},
|
|
5390
|
+
this.pendingCalls.delete(o.toString()), n(/* @__PURE__ */ Error(`Function call '${e}' timed out after ${qg}ms`));
|
|
5391
|
+
}, qg);
|
|
5301
5392
|
this.pendingCalls.set(o.toString(), {
|
|
5302
5393
|
resolve: t,
|
|
5303
5394
|
reject: n,
|
|
@@ -5364,7 +5455,7 @@ var Hg = class {
|
|
|
5364
5455
|
if (t === T.ACTION_FUNCTION_CALL) {
|
|
5365
5456
|
let t = i(e);
|
|
5366
5457
|
return this.handleFunctionCall(e, t.senderId).catch((e) => {
|
|
5367
|
-
|
|
5458
|
+
Gg.error("Failed to handle function call:", e);
|
|
5368
5459
|
}), !0;
|
|
5369
5460
|
}
|
|
5370
5461
|
if (t === T.ACTION_FUNCTION_RESULT) return this.handleFunctionResult(e), !0;
|
|
@@ -5386,7 +5477,7 @@ var Hg = class {
|
|
|
5386
5477
|
handleFunctionResult(e) {
|
|
5387
5478
|
let t = ja(e), n = t.CallId.toString(), r = this.pendingCalls.get(n);
|
|
5388
5479
|
if (!r) {
|
|
5389
|
-
|
|
5480
|
+
Gg.warn(`Received result for unknown call: ${n}`);
|
|
5390
5481
|
return;
|
|
5391
5482
|
}
|
|
5392
5483
|
if (this.pendingCalls.delete(n), clearTimeout(r.timeout), t.ResultData && t.ResultData.length > 0 && !t.ResultJson) {
|
|
@@ -5399,11 +5490,11 @@ var Hg = class {
|
|
|
5399
5490
|
handleFunctionError(e) {
|
|
5400
5491
|
let t = yi(e), n = t.CallId.toString(), r = this.pendingCalls.get(n);
|
|
5401
5492
|
if (!r) {
|
|
5402
|
-
|
|
5493
|
+
Gg.warn(`Received error for unknown call: ${n}`);
|
|
5403
5494
|
return;
|
|
5404
5495
|
}
|
|
5405
5496
|
this.pendingCalls.delete(n), clearTimeout(r.timeout);
|
|
5406
|
-
let i = new
|
|
5497
|
+
let i = new Wg(t.ErrorMessage, t.ErrorTypeName, t.StackTrace, t.ErrorCode), a = {
|
|
5407
5498
|
functionName: r.functionName,
|
|
5408
5499
|
args: r.args
|
|
5409
5500
|
};
|
|
@@ -5439,12 +5530,12 @@ var Hg = class {
|
|
|
5439
5530
|
async handleFunctionCall(e, t) {
|
|
5440
5531
|
let n = await Mr(e);
|
|
5441
5532
|
if (!this.config) {
|
|
5442
|
-
|
|
5533
|
+
Gg.warn(`Dropping call to '${n.FunctionName}' CallId=${n.CallId.toString()}: the function registry is detached, so the session has not finished joining`);
|
|
5443
5534
|
return;
|
|
5444
5535
|
}
|
|
5445
5536
|
let r = this.functions.get(n.FunctionName);
|
|
5446
5537
|
if (!r) {
|
|
5447
|
-
|
|
5538
|
+
Gg.warn(`Received call for unknown function: ${n.FunctionName}`), this.sendError(n.CallId, n.InstanceId, t, /* @__PURE__ */ Error(`Unknown function: ${n.FunctionName}`));
|
|
5448
5539
|
return;
|
|
5449
5540
|
}
|
|
5450
5541
|
this.sendAck(n.CallId, n.InstanceId, t), this.executeFunction(r, n, t);
|
|
@@ -5459,14 +5550,14 @@ var Hg = class {
|
|
|
5459
5550
|
continue;
|
|
5460
5551
|
}
|
|
5461
5552
|
let o = a?.ValueJson;
|
|
5462
|
-
o === void 0 || o === "" ? i.hasDefaultValue ? r.push(
|
|
5553
|
+
o === void 0 || o === "" ? i.hasDefaultValue ? r.push(Bg(i.defaultValueJson, i.descriptor)) : r.push(void 0) : r.push(Bg(o, i.descriptor));
|
|
5463
5554
|
}
|
|
5464
|
-
let i = await e.handler(...r), a = i, o =
|
|
5465
|
-
|
|
5466
|
-
let s =
|
|
5555
|
+
let i = await e.handler(...r), a = i, o = Kg;
|
|
5556
|
+
Jg(i) && (a = i.value, o = new Uint8Array(i.data));
|
|
5557
|
+
let s = Vg(a, e.returnType);
|
|
5467
5558
|
this.sendResult(t.CallId, t.InstanceId, n, e, s, o);
|
|
5468
5559
|
} catch (e) {
|
|
5469
|
-
|
|
5560
|
+
Gg.error(`Function ${t.FunctionName} execution failed:`, e), this.sendError(t.CallId, t.InstanceId, n, e instanceof Error ? e : Error(String(e)));
|
|
5470
5561
|
}
|
|
5471
5562
|
}
|
|
5472
5563
|
sendAck(e, t, n) {
|
|
@@ -5482,7 +5573,7 @@ var Hg = class {
|
|
|
5482
5573
|
let o = Aa(Ca({
|
|
5483
5574
|
CallId: e,
|
|
5484
5575
|
InstanceId: t,
|
|
5485
|
-
ResultTypeName:
|
|
5576
|
+
ResultTypeName: zg(r.returnType),
|
|
5486
5577
|
ResultJson: i,
|
|
5487
5578
|
ResultData: a
|
|
5488
5579
|
}), this.config.sessionId, { targetIds: [n] });
|
|
@@ -5499,7 +5590,7 @@ var Hg = class {
|
|
|
5499
5590
|
}), this.config.sessionId, { targetIds: [n] });
|
|
5500
5591
|
this.config.sendProtocolMessage(i);
|
|
5501
5592
|
}
|
|
5502
|
-
},
|
|
5593
|
+
}, Xg = w("ReactiveRegistry"), Zg = "Ikon.Reactive.Subscribe", Qg = "Ikon.Reactive.Unsubscribe", $g = {
|
|
5503
5594
|
name: "Ikon.Reactive.Update",
|
|
5504
5595
|
description: "Receives reactive value updates pushed from the server when a subscribed reactive changes",
|
|
5505
5596
|
returnType: { kind: "string" },
|
|
@@ -5517,7 +5608,7 @@ var Hg = class {
|
|
|
5517
5608
|
type: { kind: "string" }
|
|
5518
5609
|
}
|
|
5519
5610
|
]
|
|
5520
|
-
},
|
|
5611
|
+
}, e_ = class {
|
|
5521
5612
|
subscribersByKey = /* @__PURE__ */ new Map();
|
|
5522
5613
|
functionRegistry;
|
|
5523
5614
|
updateHandlerUnregister = null;
|
|
@@ -5525,9 +5616,9 @@ var Hg = class {
|
|
|
5525
5616
|
this.functionRegistry = e, this.registerUpdateHandler();
|
|
5526
5617
|
}
|
|
5527
5618
|
async subscribe(e, t, n) {
|
|
5528
|
-
let r = n?.mount ?? "", i =
|
|
5619
|
+
let r = n?.mount ?? "", i = t_(e, r), a = t, o = this.subscribersByKey.get(i), s = !o;
|
|
5529
5620
|
if (o || (o = /* @__PURE__ */ new Set(), this.subscribersByKey.set(i, o)), o.add(a), s) try {
|
|
5530
|
-
t(
|
|
5621
|
+
t(n_(await this.functionRegistry.call(Zg, [e, r])));
|
|
5531
5622
|
} catch (e) {
|
|
5532
5623
|
throw o.delete(a), o.size === 0 && this.subscribersByKey.delete(i), e;
|
|
5533
5624
|
}
|
|
@@ -5539,46 +5630,46 @@ var Hg = class {
|
|
|
5539
5630
|
this.subscribersByKey.clear(), this.updateHandlerUnregister &&= (this.updateHandlerUnregister(), null);
|
|
5540
5631
|
}
|
|
5541
5632
|
unsubscribeOne(e, t, n) {
|
|
5542
|
-
let r =
|
|
5543
|
-
i && (i.delete(n), !(i.size > 0) && (this.subscribersByKey.delete(r), this.functionRegistry.call(
|
|
5544
|
-
|
|
5633
|
+
let r = t_(e, t), i = this.subscribersByKey.get(r);
|
|
5634
|
+
i && (i.delete(n), !(i.size > 0) && (this.subscribersByKey.delete(r), this.functionRegistry.call(Qg, [e, t]).catch((n) => {
|
|
5635
|
+
Xg.warn(`Failed to unsubscribe from '${e}' (mount='${t}'):`, n);
|
|
5545
5636
|
})));
|
|
5546
5637
|
}
|
|
5547
5638
|
registerUpdateHandler() {
|
|
5548
5639
|
let e = (...e) => {
|
|
5549
|
-
let t = e[0], n = e[1] ?? "", r = e[2], i =
|
|
5640
|
+
let t = e[0], n = e[1] ?? "", r = e[2], i = t_(t, n), a = this.subscribersByKey.get(i);
|
|
5550
5641
|
if (!a || a.size === 0) return "";
|
|
5551
|
-
let o =
|
|
5642
|
+
let o = n_(r);
|
|
5552
5643
|
for (let e of a) try {
|
|
5553
5644
|
e(o);
|
|
5554
5645
|
} catch (e) {
|
|
5555
|
-
|
|
5646
|
+
Xg.warn(`Reactive update callback for '${t}' (mount='${n}') threw:`, e);
|
|
5556
5647
|
}
|
|
5557
5648
|
return "";
|
|
5558
5649
|
};
|
|
5559
|
-
this.updateHandlerUnregister = this.functionRegistry.register(
|
|
5650
|
+
this.updateHandlerUnregister = this.functionRegistry.register($g, e);
|
|
5560
5651
|
}
|
|
5561
5652
|
};
|
|
5562
|
-
function
|
|
5653
|
+
function t_(e, t) {
|
|
5563
5654
|
return t.length === 0 ? e : `${e}\0${t}`;
|
|
5564
5655
|
}
|
|
5565
|
-
function
|
|
5656
|
+
function n_(e) {
|
|
5566
5657
|
if (e == null || e === "") return null;
|
|
5567
5658
|
try {
|
|
5568
5659
|
return JSON.parse(e);
|
|
5569
5660
|
} catch (t) {
|
|
5570
|
-
return
|
|
5661
|
+
return Xg.warn("Failed to parse reactive value JSON, returning raw string:", t), e;
|
|
5571
5662
|
}
|
|
5572
5663
|
}
|
|
5573
5664
|
//#endregion
|
|
5574
5665
|
//#region src/login/login-error-interceptor.ts
|
|
5575
|
-
var
|
|
5666
|
+
var r_ = "login_required", i_ = (e, t) => e.code === r_ ? (Tf({
|
|
5576
5667
|
functionName: t.functionName,
|
|
5577
5668
|
args: t.args
|
|
5578
5669
|
}), Sf(e.message), null) : null;
|
|
5579
5670
|
//#endregion
|
|
5580
5671
|
//#region src/media/device-detection.ts
|
|
5581
|
-
function
|
|
5672
|
+
function a_() {
|
|
5582
5673
|
if (typeof navigator > "u") return !1;
|
|
5583
5674
|
let e = navigator.userAgentData;
|
|
5584
5675
|
if (typeof e?.mobile == "boolean") return e.mobile;
|
|
@@ -5587,7 +5678,7 @@ function Qg() {
|
|
|
5587
5678
|
}
|
|
5588
5679
|
//#endregion
|
|
5589
5680
|
//#region src/functions/media-capture-functions.ts
|
|
5590
|
-
function
|
|
5681
|
+
function o_(e) {
|
|
5591
5682
|
let t = e?.facingMode;
|
|
5592
5683
|
if (typeof t == "string") return t === "user" || t === "environment" ? t : void 0;
|
|
5593
5684
|
if (Array.isArray(t)) return t.find((e) => typeof e == "string" && (e === "user" || e === "environment")) ?? void 0;
|
|
@@ -5597,21 +5688,21 @@ function $g(e) {
|
|
|
5597
5688
|
if (Array.isArray(e)) return e.find((e) => e === "user" || e === "environment") ?? void 0;
|
|
5598
5689
|
}
|
|
5599
5690
|
}
|
|
5600
|
-
function
|
|
5691
|
+
function s_(e) {
|
|
5601
5692
|
if (!(typeof e != "string" || !e.trim())) try {
|
|
5602
5693
|
return JSON.parse(e);
|
|
5603
5694
|
} catch {
|
|
5604
5695
|
return;
|
|
5605
5696
|
}
|
|
5606
5697
|
}
|
|
5607
|
-
var
|
|
5698
|
+
var c_ = {
|
|
5608
5699
|
StartVideoCapture: "ikon.client.startVideoCapture",
|
|
5609
5700
|
StartAudioCapture: "ikon.client.startAudioCapture",
|
|
5610
5701
|
StopCapture: "ikon.client.stopCapture",
|
|
5611
5702
|
CaptureImage: "ikon.client.captureImage",
|
|
5612
5703
|
GetMediaDevices: "ikon.client.getMediaDevices"
|
|
5613
|
-
},
|
|
5614
|
-
name:
|
|
5704
|
+
}, l_ = {
|
|
5705
|
+
name: c_.StartVideoCapture,
|
|
5615
5706
|
description: "Start camera or screen capture and stream video frames to the server",
|
|
5616
5707
|
returnType: { kind: "string" },
|
|
5617
5708
|
parameters: [{
|
|
@@ -5629,8 +5720,8 @@ var t_ = {
|
|
|
5629
5720
|
},
|
|
5630
5721
|
description: "JSON encoded capture options"
|
|
5631
5722
|
}]
|
|
5632
|
-
},
|
|
5633
|
-
name:
|
|
5723
|
+
}, u_ = {
|
|
5724
|
+
name: c_.StartAudioCapture,
|
|
5634
5725
|
description: "Start microphone capture and stream audio frames to the server",
|
|
5635
5726
|
returnType: { kind: "string" },
|
|
5636
5727
|
parameters: [{
|
|
@@ -5641,8 +5732,8 @@ var t_ = {
|
|
|
5641
5732
|
},
|
|
5642
5733
|
description: "JSON encoded capture options"
|
|
5643
5734
|
}]
|
|
5644
|
-
},
|
|
5645
|
-
name:
|
|
5735
|
+
}, d_ = {
|
|
5736
|
+
name: c_.StopCapture,
|
|
5646
5737
|
description: "Stop a previously started capture by streamId",
|
|
5647
5738
|
returnType: { kind: "boolean" },
|
|
5648
5739
|
parameters: [{
|
|
@@ -5650,8 +5741,8 @@ var t_ = {
|
|
|
5650
5741
|
type: { kind: "string" },
|
|
5651
5742
|
description: "Stream ID to stop"
|
|
5652
5743
|
}]
|
|
5653
|
-
},
|
|
5654
|
-
name:
|
|
5744
|
+
}, f_ = {
|
|
5745
|
+
name: c_.CaptureImage,
|
|
5655
5746
|
description: "Capture a single image from the camera and return metadata (JSON) plus binary image data",
|
|
5656
5747
|
returnType: { kind: "string" },
|
|
5657
5748
|
parameters: [{
|
|
@@ -5662,24 +5753,24 @@ var t_ = {
|
|
|
5662
5753
|
},
|
|
5663
5754
|
description: "JSON encoded capture options"
|
|
5664
5755
|
}]
|
|
5665
|
-
},
|
|
5666
|
-
name:
|
|
5756
|
+
}, p_ = {
|
|
5757
|
+
name: c_.GetMediaDevices,
|
|
5667
5758
|
description: "Get list of available media input devices",
|
|
5668
5759
|
returnType: { kind: "string" },
|
|
5669
5760
|
parameters: []
|
|
5670
5761
|
};
|
|
5671
|
-
function
|
|
5762
|
+
function m_(e, t) {
|
|
5672
5763
|
let n = [];
|
|
5673
|
-
return n.push(e.register(
|
|
5764
|
+
return n.push(e.register(l_, async (e, n) => {
|
|
5674
5765
|
if (t.isWebRtcCaptureAvailable) {
|
|
5675
5766
|
let e = t.webRtcSignaling;
|
|
5676
5767
|
if (!e) throw Error("WebRTC signaling is not connected");
|
|
5677
|
-
let r =
|
|
5768
|
+
let r = s_(n);
|
|
5678
5769
|
return await e.startVideoCapture(r?.constraints), "webrtc-video";
|
|
5679
5770
|
}
|
|
5680
5771
|
let r = await t.ensureMediaCapture();
|
|
5681
5772
|
if (!r) throw Error("Media capture is not available in this environment");
|
|
5682
|
-
let i =
|
|
5773
|
+
let i = s_(n);
|
|
5683
5774
|
return ((typeof e == "string" && e.trim().toLowerCase() === "screen" ? "screen" : "camera") == "screen" ? await r.video.startScreen({
|
|
5684
5775
|
userGesture: !1,
|
|
5685
5776
|
options: i,
|
|
@@ -5689,22 +5780,22 @@ function s_(e, t) {
|
|
|
5689
5780
|
options: i,
|
|
5690
5781
|
constraints: i?.constraints
|
|
5691
5782
|
})).streamId;
|
|
5692
|
-
})), n.push(e.register(
|
|
5783
|
+
})), n.push(e.register(u_, async (e) => {
|
|
5693
5784
|
if (t.isWebRtcCaptureAvailable) {
|
|
5694
5785
|
let n = t.webRtcSignaling;
|
|
5695
5786
|
if (!n) throw Error("WebRTC signaling is not connected");
|
|
5696
|
-
let r =
|
|
5787
|
+
let r = s_(e);
|
|
5697
5788
|
return await n.startAudioCapture(r?.constraints), "webrtc-audio";
|
|
5698
5789
|
}
|
|
5699
5790
|
let n = await t.ensureMediaCapture();
|
|
5700
5791
|
if (!n) throw Error("Media capture is not available in this environment");
|
|
5701
|
-
let r =
|
|
5792
|
+
let r = s_(e);
|
|
5702
5793
|
return (await n.audio.startMic({
|
|
5703
5794
|
userGesture: !1,
|
|
5704
5795
|
options: r,
|
|
5705
5796
|
constraints: r?.constraints
|
|
5706
5797
|
})).streamId;
|
|
5707
|
-
})), n.push(e.register(
|
|
5798
|
+
})), n.push(e.register(d_, async (e) => {
|
|
5708
5799
|
if (t.isWebRtcCaptureAvailable) {
|
|
5709
5800
|
let e = t.webRtcSignaling;
|
|
5710
5801
|
return e && await e.stopCapture(), !0;
|
|
@@ -5713,20 +5804,20 @@ function s_(e, t) {
|
|
|
5713
5804
|
if (!n || typeof e != "string" || !e.trim()) return !1;
|
|
5714
5805
|
let r = await n.video.stop(e), i = await n.audio.stop(e);
|
|
5715
5806
|
return r || i;
|
|
5716
|
-
})), n.push(e.register(
|
|
5807
|
+
})), n.push(e.register(f_, async (e) => {
|
|
5717
5808
|
let n = await t.ensureMediaCapture();
|
|
5718
5809
|
if (!n) throw Error("Media capture is not available in this environment");
|
|
5719
|
-
let r =
|
|
5720
|
-
if (r.mode === "native" &&
|
|
5810
|
+
let r = s_(e) ?? {};
|
|
5811
|
+
if (r.mode === "native" && a_()) {
|
|
5721
5812
|
let e = await n.image.captureFromNativeCamera({
|
|
5722
|
-
facing:
|
|
5813
|
+
facing: o_(r.constraints),
|
|
5723
5814
|
mime: r.mime,
|
|
5724
5815
|
quality: r.quality,
|
|
5725
5816
|
width: r.width,
|
|
5726
5817
|
height: r.height
|
|
5727
5818
|
});
|
|
5728
5819
|
if (!e) throw Error("Native camera capture was cancelled");
|
|
5729
|
-
return
|
|
5820
|
+
return Ug(JSON.stringify({
|
|
5730
5821
|
mime: e.mime,
|
|
5731
5822
|
width: e.width,
|
|
5732
5823
|
height: e.height
|
|
@@ -5747,12 +5838,12 @@ function s_(e, t) {
|
|
|
5747
5838
|
quality: r.quality,
|
|
5748
5839
|
width: r.width,
|
|
5749
5840
|
height: r.height
|
|
5750
|
-
}),
|
|
5841
|
+
}), Ug(JSON.stringify({
|
|
5751
5842
|
mime: a.mime,
|
|
5752
5843
|
width: a.width,
|
|
5753
5844
|
height: a.height
|
|
5754
5845
|
}), a.data);
|
|
5755
|
-
})), n.push(e.register(
|
|
5846
|
+
})), n.push(e.register(p_, async () => {
|
|
5756
5847
|
if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) return JSON.stringify([]);
|
|
5757
5848
|
let e = (await navigator.mediaDevices.enumerateDevices()).filter((e) => e.kind === "audioinput" || e.kind === "videoinput").map((e) => ({
|
|
5758
5849
|
deviceId: e.deviceId,
|
|
@@ -5767,45 +5858,45 @@ function s_(e, t) {
|
|
|
5767
5858
|
}
|
|
5768
5859
|
//#endregion
|
|
5769
5860
|
//#region src/functions/sound-functions.ts
|
|
5770
|
-
var
|
|
5861
|
+
var h_ = {
|
|
5771
5862
|
PlaySound: "ikon.client.playSound",
|
|
5772
5863
|
StopSound: "ikon.client.stopSound"
|
|
5773
|
-
},
|
|
5774
|
-
function
|
|
5775
|
-
if (!(
|
|
5864
|
+
}, g_ = /* @__PURE__ */ new Map(), J = /* @__PURE__ */ new Map(), __ = 1, v_ = "data:audio/wav;base64,UklGRjIAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQYAAAAAAAAAAAA=", y_ = 8, b_ = [], x_ = !1, Y = null;
|
|
5865
|
+
function S_() {
|
|
5866
|
+
if (!(b_.length > 0 || typeof Audio > "u")) for (let e = 0; e < y_; e++) {
|
|
5776
5867
|
let e = new Audio();
|
|
5777
|
-
e.preload = "auto",
|
|
5868
|
+
e.preload = "auto", b_.push(e);
|
|
5778
5869
|
}
|
|
5779
5870
|
}
|
|
5780
|
-
function
|
|
5781
|
-
if (!
|
|
5782
|
-
|
|
5783
|
-
for (let e of
|
|
5784
|
-
e.src =
|
|
5871
|
+
function C_() {
|
|
5872
|
+
if (!x_) {
|
|
5873
|
+
S_();
|
|
5874
|
+
for (let e of b_) try {
|
|
5875
|
+
e.src = v_;
|
|
5785
5876
|
let t = e.play();
|
|
5786
5877
|
typeof t?.then == "function" ? t.then(() => {
|
|
5787
|
-
e.pause(), e.currentTime = 0,
|
|
5788
|
-
}, () => {}) :
|
|
5878
|
+
e.pause(), e.currentTime = 0, x_ = !0, T_();
|
|
5879
|
+
}, () => {}) : x_ = !0;
|
|
5789
5880
|
} catch {}
|
|
5790
|
-
|
|
5881
|
+
x_ && T_();
|
|
5791
5882
|
}
|
|
5792
5883
|
}
|
|
5793
|
-
function
|
|
5884
|
+
function w_() {
|
|
5794
5885
|
if (Y || typeof window > "u") return;
|
|
5795
|
-
let e = () =>
|
|
5886
|
+
let e = () => C_();
|
|
5796
5887
|
Y = 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 });
|
|
5797
5888
|
}
|
|
5798
|
-
function
|
|
5889
|
+
function T_() {
|
|
5799
5890
|
!Y || typeof window > "u" || (window.removeEventListener("pointerdown", Y, { capture: !0 }), window.removeEventListener("touchend", Y, { capture: !0 }), window.removeEventListener("mousedown", Y, { capture: !0 }), window.removeEventListener("keydown", Y, { capture: !0 }), Y = null);
|
|
5800
5891
|
}
|
|
5801
|
-
function
|
|
5802
|
-
|
|
5803
|
-
for (let e of
|
|
5892
|
+
function E_() {
|
|
5893
|
+
S_();
|
|
5894
|
+
for (let e of b_) if (e.paused || e.ended) return e;
|
|
5804
5895
|
let e = new Audio();
|
|
5805
|
-
return e.preload = "auto",
|
|
5896
|
+
return e.preload = "auto", b_.push(e), e;
|
|
5806
5897
|
}
|
|
5807
|
-
var
|
|
5808
|
-
name:
|
|
5898
|
+
var D_ = {
|
|
5899
|
+
name: h_.PlaySound,
|
|
5809
5900
|
description: "Play a sound effect",
|
|
5810
5901
|
returnType: {
|
|
5811
5902
|
kind: "string",
|
|
@@ -5843,22 +5934,22 @@ var x_ = {
|
|
|
5843
5934
|
}
|
|
5844
5935
|
]
|
|
5845
5936
|
};
|
|
5846
|
-
function
|
|
5937
|
+
function O_(e, t, n, r) {
|
|
5847
5938
|
if (typeof window > "u" || typeof Audio > "u" || typeof e != "string" || !e.trim()) return Promise.resolve(null);
|
|
5848
5939
|
let i = e;
|
|
5849
|
-
if (typeof t == "string" && t &&
|
|
5850
|
-
let t = e.slice(6), n =
|
|
5940
|
+
if (typeof t == "string" && t && g_.set(t, e), e.startsWith("sound:")) {
|
|
5941
|
+
let t = e.slice(6), n = g_.get(t);
|
|
5851
5942
|
if (!n) return Promise.resolve(null);
|
|
5852
5943
|
i = n;
|
|
5853
5944
|
}
|
|
5854
5945
|
return new Promise((e) => {
|
|
5855
5946
|
try {
|
|
5856
|
-
let t =
|
|
5947
|
+
let t = E_();
|
|
5857
5948
|
t.src = i, t.currentTime = 0, t.loop = r === !0, t.volume = typeof n == "number" ? Math.max(0, Math.min(1, n)) : 1;
|
|
5858
|
-
let a = `sound-${
|
|
5859
|
-
|
|
5949
|
+
let a = `sound-${__++}`, o = () => {
|
|
5950
|
+
J.delete(a), t.removeEventListener("ended", o), t.removeEventListener("error", o);
|
|
5860
5951
|
};
|
|
5861
|
-
t.addEventListener("ended", o), t.addEventListener("error", o),
|
|
5952
|
+
t.addEventListener("ended", o), t.addEventListener("error", o), J.set(a, t), t.play().then(() => e(a), () => {
|
|
5862
5953
|
o(), e(null);
|
|
5863
5954
|
});
|
|
5864
5955
|
} catch {
|
|
@@ -5866,8 +5957,8 @@ function S_(e, t, n, r) {
|
|
|
5866
5957
|
}
|
|
5867
5958
|
});
|
|
5868
5959
|
}
|
|
5869
|
-
var
|
|
5870
|
-
name:
|
|
5960
|
+
var k_ = {
|
|
5961
|
+
name: h_.StopSound,
|
|
5871
5962
|
description: "Stop a playing sound by ID",
|
|
5872
5963
|
returnType: { kind: "boolean" },
|
|
5873
5964
|
parameters: [{
|
|
@@ -5876,43 +5967,43 @@ var C_ = {
|
|
|
5876
5967
|
description: "Playback ID from playSound"
|
|
5877
5968
|
}]
|
|
5878
5969
|
};
|
|
5879
|
-
function
|
|
5970
|
+
function A_(e) {
|
|
5880
5971
|
if (typeof e != "string") return !1;
|
|
5881
|
-
let t =
|
|
5972
|
+
let t = J.get(e);
|
|
5882
5973
|
if (!t) return !1;
|
|
5883
5974
|
try {
|
|
5884
|
-
return t.pause(), t.currentTime = 0,
|
|
5975
|
+
return t.pause(), t.currentTime = 0, J.delete(e), !0;
|
|
5885
5976
|
} catch {
|
|
5886
5977
|
return !1;
|
|
5887
5978
|
}
|
|
5888
5979
|
}
|
|
5889
|
-
function
|
|
5890
|
-
|
|
5891
|
-
for (let [e, t] of
|
|
5980
|
+
function j_() {
|
|
5981
|
+
g_.clear();
|
|
5982
|
+
for (let [e, t] of J) {
|
|
5892
5983
|
try {
|
|
5893
5984
|
t.pause(), t.currentTime = 0;
|
|
5894
5985
|
} catch {}
|
|
5895
|
-
|
|
5986
|
+
J.delete(e);
|
|
5896
5987
|
}
|
|
5897
|
-
|
|
5988
|
+
T_();
|
|
5898
5989
|
}
|
|
5899
|
-
var
|
|
5900
|
-
definition:
|
|
5901
|
-
handler:
|
|
5990
|
+
var M_ = [{
|
|
5991
|
+
definition: D_,
|
|
5992
|
+
handler: O_
|
|
5902
5993
|
}, {
|
|
5903
|
-
definition:
|
|
5904
|
-
handler:
|
|
5994
|
+
definition: k_,
|
|
5995
|
+
handler: A_
|
|
5905
5996
|
}];
|
|
5906
|
-
function
|
|
5907
|
-
|
|
5908
|
-
let t =
|
|
5997
|
+
function N_(e) {
|
|
5998
|
+
w_();
|
|
5999
|
+
let t = M_.map(({ definition: t, handler: n }) => e.register(t, n));
|
|
5909
6000
|
return () => {
|
|
5910
|
-
t.forEach((e) => e()),
|
|
6001
|
+
t.forEach((e) => e()), j_();
|
|
5911
6002
|
};
|
|
5912
6003
|
}
|
|
5913
6004
|
//#endregion
|
|
5914
6005
|
//#region src/worker/viseme-worker.ts?worker
|
|
5915
|
-
function
|
|
6006
|
+
function P_(e) {
|
|
5916
6007
|
return new Worker("" + new URL("assets/viseme-worker-D0AKWUTO.js", import.meta.url).href, {
|
|
5917
6008
|
type: "module",
|
|
5918
6009
|
name: e?.name
|
|
@@ -5920,7 +6011,7 @@ function O_(e) {
|
|
|
5920
6011
|
}
|
|
5921
6012
|
//#endregion
|
|
5922
6013
|
//#region src/media/viseme-tracker.ts
|
|
5923
|
-
var
|
|
6014
|
+
var F_ = w("VisemeTracker"), I_ = ge * 2, L_ = class e {
|
|
5924
6015
|
static MAX_WORKER_REBUILD_ATTEMPTS = 3;
|
|
5925
6016
|
client;
|
|
5926
6017
|
worker = null;
|
|
@@ -5940,16 +6031,16 @@ var k_ = w("VisemeTracker"), A_ = ge * 2, j_ = class e {
|
|
|
5940
6031
|
enable() {
|
|
5941
6032
|
if (this.worker) return;
|
|
5942
6033
|
if (typeof Worker > "u") {
|
|
5943
|
-
|
|
6034
|
+
F_.warn("Viseme worker unavailable (Workers not supported)");
|
|
5944
6035
|
return;
|
|
5945
6036
|
}
|
|
5946
6037
|
let t = this.client.createProtocolMessagePort({ opcodeGroupsMask: T.GROUP_AUDIO });
|
|
5947
6038
|
if (!t) return;
|
|
5948
6039
|
this.protocolPort = t;
|
|
5949
6040
|
try {
|
|
5950
|
-
this.worker = new
|
|
6041
|
+
this.worker = new P_();
|
|
5951
6042
|
} catch (e) {
|
|
5952
|
-
|
|
6043
|
+
F_.warn(`Failed to create viseme worker: ${e}`), this.protocolPort.close(), this.protocolPort = null;
|
|
5953
6044
|
return;
|
|
5954
6045
|
}
|
|
5955
6046
|
let n = this.worker;
|
|
@@ -5960,7 +6051,7 @@ var k_ = w("VisemeTracker"), A_ = ge * 2, j_ = class e {
|
|
|
5960
6051
|
t.lineno,
|
|
5961
6052
|
t.colno
|
|
5962
6053
|
].filter((e) => e != null && String(e).length > 0);
|
|
5963
|
-
|
|
6054
|
+
F_.error(`Viseme worker failed: ${n.join(" ")}`.trim()), this.dispose(), this.workerRebuildAttempts < e.MAX_WORKER_REBUILD_ATTEMPTS ? (this.workerRebuildAttempts++, this.enable()) : F_.error("Viseme worker crashed repeatedly, giving up on rebuilds");
|
|
5964
6055
|
}), n.postMessage({
|
|
5965
6056
|
type: "attachProtocolPort",
|
|
5966
6057
|
port: t.port
|
|
@@ -6015,7 +6106,7 @@ var k_ = w("VisemeTracker"), A_ = ge * 2, j_ = class e {
|
|
|
6015
6106
|
if (!t.timingEstablished || t.count === 0) continue;
|
|
6016
6107
|
let n = e - t.playbackStartTime;
|
|
6017
6108
|
if (n < 0) continue;
|
|
6018
|
-
let r = n *
|
|
6109
|
+
let r = n * I_, i = t.frames, a = t.count, o = (t.head - a + S) % S, s = null, c = null;
|
|
6019
6110
|
for (let e = 0; e < a; e++) {
|
|
6020
6111
|
let t = i[(o + e) % S], n = t.samplePosition + Math.max(t.frameSamples, 1);
|
|
6021
6112
|
if (t.samplePosition <= r && (s = t), n > r && !c && (c = t, t.samplePosition <= r)) break;
|
|
@@ -6089,35 +6180,35 @@ var k_ = w("VisemeTracker"), A_ = ge * 2, j_ = class e {
|
|
|
6089
6180
|
}
|
|
6090
6181
|
}
|
|
6091
6182
|
}
|
|
6092
|
-
},
|
|
6093
|
-
function
|
|
6094
|
-
return X ? !0 : (X =
|
|
6183
|
+
}, R_ = w("DebugMode"), X = !1;
|
|
6184
|
+
function z_() {
|
|
6185
|
+
return X ? !0 : (X = Bu(), X && (ve(C.DEBUG), R_.info("Debug mode enabled")), X);
|
|
6095
6186
|
}
|
|
6096
|
-
function
|
|
6187
|
+
function B_() {
|
|
6097
6188
|
return X;
|
|
6098
6189
|
}
|
|
6099
|
-
function
|
|
6100
|
-
X || (X = !0, ve(C.DEBUG),
|
|
6190
|
+
function V_() {
|
|
6191
|
+
X || (X = !0, ve(C.DEBUG), R_.info("Debug mode enabled"), Fu(yu, "true"));
|
|
6101
6192
|
}
|
|
6102
6193
|
//#endregion
|
|
6103
6194
|
//#region src/utils/inspect-mode.ts
|
|
6104
|
-
var
|
|
6105
|
-
function
|
|
6106
|
-
typeof window < "u" && window.dispatchEvent(new Event(
|
|
6195
|
+
var H_ = "ikon-inspect-mode-changed", U_ = !1;
|
|
6196
|
+
function W_() {
|
|
6197
|
+
typeof window < "u" && window.dispatchEvent(new Event(H_));
|
|
6107
6198
|
}
|
|
6108
|
-
function
|
|
6109
|
-
let e =
|
|
6110
|
-
return e !==
|
|
6199
|
+
function G_() {
|
|
6200
|
+
let e = qu();
|
|
6201
|
+
return e !== U_ && (U_ = e, W_()), U_;
|
|
6111
6202
|
}
|
|
6112
|
-
function
|
|
6113
|
-
return
|
|
6203
|
+
function K_() {
|
|
6204
|
+
return U_;
|
|
6114
6205
|
}
|
|
6115
|
-
function
|
|
6116
|
-
|
|
6206
|
+
function q_() {
|
|
6207
|
+
U_ || (U_ = !0, Fu(xu, "true"), W_());
|
|
6117
6208
|
}
|
|
6118
6209
|
//#endregion
|
|
6119
6210
|
//#region src/utils/external-link.ts
|
|
6120
|
-
var
|
|
6211
|
+
var J_ = /* @__PURE__ */ new Set([
|
|
6121
6212
|
"http",
|
|
6122
6213
|
"https",
|
|
6123
6214
|
"file",
|
|
@@ -6134,12 +6225,12 @@ var H_ = /* @__PURE__ */ new Set([
|
|
|
6134
6225
|
"edge",
|
|
6135
6226
|
"moz-extension",
|
|
6136
6227
|
"safari-web-extension"
|
|
6137
|
-
]),
|
|
6138
|
-
function
|
|
6139
|
-
let t =
|
|
6140
|
-
return t ? !
|
|
6228
|
+
]), Y_ = /^([a-z][a-z0-9+.-]*):/i;
|
|
6229
|
+
function X_(e) {
|
|
6230
|
+
let t = Y_.exec(e.trim());
|
|
6231
|
+
return t ? !J_.has(t[1].toLowerCase()) : !1;
|
|
6141
6232
|
}
|
|
6142
|
-
function
|
|
6233
|
+
function Z_(e) {
|
|
6143
6234
|
if (typeof document > "u") return;
|
|
6144
6235
|
let t = document.createElement("iframe");
|
|
6145
6236
|
t.setAttribute("aria-hidden", "true"), t.style.display = "none", document.body.appendChild(t);
|
|
@@ -6153,7 +6244,7 @@ function G_(e) {
|
|
|
6153
6244
|
}
|
|
6154
6245
|
//#endregion
|
|
6155
6246
|
//#region src/utils/browser-support.ts
|
|
6156
|
-
var
|
|
6247
|
+
var Q_ = [
|
|
6157
6248
|
{
|
|
6158
6249
|
name: "WebSocket",
|
|
6159
6250
|
isPresent: () => typeof WebSocket < "u"
|
|
@@ -6175,9 +6266,9 @@ var K_ = [
|
|
|
6175
6266
|
isPresent: () => typeof Promise < "u" && typeof Promise.allSettled == "function"
|
|
6176
6267
|
}
|
|
6177
6268
|
];
|
|
6178
|
-
function
|
|
6269
|
+
function $_() {
|
|
6179
6270
|
let e = [];
|
|
6180
|
-
for (let t of
|
|
6271
|
+
for (let t of Q_) {
|
|
6181
6272
|
let n;
|
|
6182
6273
|
try {
|
|
6183
6274
|
n = t.isPresent();
|
|
@@ -6193,22 +6284,22 @@ function q_() {
|
|
|
6193
6284
|
}
|
|
6194
6285
|
//#endregion
|
|
6195
6286
|
//#region src/transport/transport-probe.ts
|
|
6196
|
-
var
|
|
6197
|
-
async function
|
|
6198
|
-
let r = n?.timeoutMs ??
|
|
6287
|
+
var ev = w("TransportProbe"), tv = 3e3;
|
|
6288
|
+
async function nv(e, t, n) {
|
|
6289
|
+
let r = n?.timeoutMs ?? tv, i = n?.signal;
|
|
6199
6290
|
if (i?.aborted) return !1;
|
|
6200
6291
|
let a = Date.now();
|
|
6201
6292
|
try {
|
|
6202
|
-
let n =
|
|
6203
|
-
return
|
|
6293
|
+
let n = rv(e) ? await av(t, r, i) : await iv(t, r, i);
|
|
6294
|
+
return ev.debug(`Probe ${x[e]} ${t}: ${n ? "reachable" : "unreachable"} in ${Date.now() - a}ms`), n;
|
|
6204
6295
|
} catch (n) {
|
|
6205
|
-
return
|
|
6296
|
+
return ev.debug(`Probe ${x[e]} ${t} failed after ${Date.now() - a}ms: ${n instanceof Error ? n.message : n}`), !1;
|
|
6206
6297
|
}
|
|
6207
6298
|
}
|
|
6208
|
-
function
|
|
6299
|
+
function rv(e) {
|
|
6209
6300
|
return e === x.WebTransport || e === x.WebTransportProxy;
|
|
6210
6301
|
}
|
|
6211
|
-
function
|
|
6302
|
+
function iv(e, t, n) {
|
|
6212
6303
|
return typeof WebSocket > "u" ? Promise.resolve(!1) : new Promise((r) => {
|
|
6213
6304
|
let i = new WebSocket(e), a = !1, o = (e) => {
|
|
6214
6305
|
if (!a) {
|
|
@@ -6222,7 +6313,7 @@ function Q_(e, t, n) {
|
|
|
6222
6313
|
n?.addEventListener("abort", s, { once: !0 }), i.onopen = () => o(!0), i.onerror = () => o(!1), i.onclose = () => o(!1);
|
|
6223
6314
|
});
|
|
6224
6315
|
}
|
|
6225
|
-
async function
|
|
6316
|
+
async function av(e, t, n) {
|
|
6226
6317
|
if (!_d()) return !1;
|
|
6227
6318
|
let r = new WebTransport(e), i;
|
|
6228
6319
|
try {
|
|
@@ -6241,7 +6332,7 @@ async function $_(e, t, n) {
|
|
|
6241
6332
|
}
|
|
6242
6333
|
//#endregion
|
|
6243
6334
|
//#region src/worker/protocol-worker.ts?worker
|
|
6244
|
-
function
|
|
6335
|
+
function ov(e) {
|
|
6245
6336
|
return new Worker("" + new URL("assets/protocol-worker-CW7oSQmQ.js", import.meta.url).href, {
|
|
6246
6337
|
type: "module",
|
|
6247
6338
|
name: e?.name
|
|
@@ -6249,11 +6340,11 @@ function ev(e) {
|
|
|
6249
6340
|
}
|
|
6250
6341
|
//#endregion
|
|
6251
6342
|
//#region src/client/ikon-client.ts
|
|
6252
|
-
var Z = w("IkonClient"),
|
|
6253
|
-
function
|
|
6343
|
+
var Z = w("IkonClient"), sv = [1e4, 3e4];
|
|
6344
|
+
function cv() {
|
|
6254
6345
|
return typeof __IKON_WAIT_FOR_EXTERNAL_CONNECT_URL__ < "u" && __IKON_WAIT_FOR_EXTERNAL_CONNECT_URL__;
|
|
6255
6346
|
}
|
|
6256
|
-
var
|
|
6347
|
+
var lv = class e {
|
|
6257
6348
|
channelManager = null;
|
|
6258
6349
|
protocolWorker = null;
|
|
6259
6350
|
preloadedWorker = null;
|
|
@@ -6343,7 +6434,7 @@ var rv = class e {
|
|
|
6343
6434
|
_joinWatchdogTimer = null;
|
|
6344
6435
|
_serverStopped = !1;
|
|
6345
6436
|
_hasBeenConnected = !1;
|
|
6346
|
-
_waitForExternalConnectUrl =
|
|
6437
|
+
_waitForExternalConnectUrl = cv();
|
|
6347
6438
|
_externalConnectUrlCleanup = null;
|
|
6348
6439
|
get media() {
|
|
6349
6440
|
return this._media;
|
|
@@ -6360,7 +6451,7 @@ var rv = class e {
|
|
|
6360
6451
|
return this._mediaCapture;
|
|
6361
6452
|
}
|
|
6362
6453
|
async ensureMediaCapture() {
|
|
6363
|
-
return this._mediaCapture ? this._mediaCapture :
|
|
6454
|
+
return this._mediaCapture ? this._mediaCapture : nh() ? (this._mediaCapturePromise ||= Promise.resolve().then(() => Wv).then(({ IkonMediaCapture: e }) => (this._mediaCapture = new e(this, this._mediaCaptureConfig), this._mediaCapture)), this._mediaCapturePromise) : null;
|
|
6364
6455
|
}
|
|
6365
6456
|
async ensureMedia() {
|
|
6366
6457
|
return this._media ? this._media : (this._mediaPromise ||= import("./ikon-media-CdIF9gbL.js").then((e) => e.n).then(({ IkonMedia: e }) => (this._media = new e(this, this._mediaConfig), this._media)), this._mediaPromise);
|
|
@@ -6372,7 +6463,7 @@ var rv = class e {
|
|
|
6372
6463
|
return this._videoEnabled;
|
|
6373
6464
|
}
|
|
6374
6465
|
get isWebRtcEnabled() {
|
|
6375
|
-
return (
|
|
6466
|
+
return (Gu() ?? this.config.webRtc?.enabled ?? !0) && (this._audioEnabled || this._videoEnabled);
|
|
6376
6467
|
}
|
|
6377
6468
|
get isWebRtcMediaActive() {
|
|
6378
6469
|
return this.isWebRtcEnabled && !this._webRtcFallbackActive;
|
|
@@ -6415,8 +6506,8 @@ var rv = class e {
|
|
|
6415
6506
|
].filter(Boolean).length;
|
|
6416
6507
|
if (t === 0) throw Error("IkonClient requires one of: \"local\", \"apiKey\", or \"sessionToken\" configuration");
|
|
6417
6508
|
if (t > 1) throw Error("IkonClient accepts only one of: \"local\", \"apiKey\", or \"sessionToken\" configuration");
|
|
6418
|
-
|
|
6419
|
-
let n = e.proxy === !0 ? "proxy" : e.proxy === !1 ? "direct" : e.proxy ?? null, r = e.local ? null :
|
|
6509
|
+
z_(), nh() && zp();
|
|
6510
|
+
let n = e.proxy === !0 ? "proxy" : e.proxy === !1 ? "direct" : e.proxy ?? null, r = e.local ? null : Iu() ?? n, i = r === "proxy" ? "force-proxy" : r === "direct" ? "force-direct" : r === "lb" ? "force-lb" : "auto", a = zu(), o = a ? a.family === "websocket" : null, s = a ? a.family === "webtransport" : null, c = a ? a.family === "httpstream" : null;
|
|
6420
6511
|
this.httpStreamMode = a?.mode;
|
|
6421
6512
|
let l = o ?? e.websocket, u = s ?? e.webtransport ?? !1, d = c ?? e.httpstream;
|
|
6422
6513
|
if (this.endpointSelector = new gf({
|
|
@@ -6429,8 +6520,8 @@ var rv = class e {
|
|
|
6429
6520
|
let e = a ? ` (pinned: ${a.family}${a.mode ? `/${a.mode}` : ""})` : "";
|
|
6430
6521
|
Z.debug(`Transport filter: websocket=${l ?? "auto"}, webtransport=${u ?? "auto"}, httpstream=${d ?? "auto"}${e}`);
|
|
6431
6522
|
}
|
|
6432
|
-
this._functionRegistry = new
|
|
6433
|
-
let f =
|
|
6523
|
+
this._functionRegistry = new Yg(), this._reactiveRegistry = new e_(this._functionRegistry), nh() && !e.disableBrowserFunctions && (this.unregisterBrowserFunctions = th(this._functionRegistry), this.unregisterSoundFunctions = N_(this._functionRegistry)), nh() && (this.unregisterLoginInterceptor = this._functionRegistry.addErrorInterceptor(i_));
|
|
6524
|
+
let f = Uu(), p = Wu();
|
|
6434
6525
|
this._audioEnabled = f ?? e.audio?.enabled ?? !0, this._videoEnabled = p ?? e.video?.enabled ?? !0;
|
|
6435
6526
|
let m = e.audio ? {
|
|
6436
6527
|
performance: e.audio.performance,
|
|
@@ -6441,7 +6532,7 @@ var rv = class e {
|
|
|
6441
6532
|
audio: m,
|
|
6442
6533
|
video: h,
|
|
6443
6534
|
mediaSession: e.mediaSession
|
|
6444
|
-
}, this._mediaCaptureConfig = { audio: { performance: { preferWebCodecs: e.audio?.performance?.preferWebCodecs } } },
|
|
6535
|
+
}, this._mediaCaptureConfig = { audio: { performance: { preferWebCodecs: e.audio?.performance?.preferWebCodecs } } }, nh() && (this.unregisterMediaCaptureFunctions = m_(this._functionRegistry, this));
|
|
6445
6536
|
}
|
|
6446
6537
|
_lastError = void 0;
|
|
6447
6538
|
get lastError() {
|
|
@@ -6497,15 +6588,15 @@ var rv = class e {
|
|
|
6497
6588
|
async connect() {
|
|
6498
6589
|
if (this._connectStarted) throw Error(`Cannot connect: already started (state: ${this.currentState})`);
|
|
6499
6590
|
this._connectStarted = !0;
|
|
6500
|
-
let e =
|
|
6591
|
+
let e = $_();
|
|
6501
6592
|
if (!e.supported) {
|
|
6502
|
-
this.setErrorState(new
|
|
6593
|
+
this.setErrorState(new du(e.missingFeatures));
|
|
6503
6594
|
return;
|
|
6504
6595
|
}
|
|
6505
6596
|
this.setupLifecycleHandlers();
|
|
6506
|
-
let t =
|
|
6597
|
+
let t = Hu();
|
|
6507
6598
|
if (t) {
|
|
6508
|
-
Z.info("Found external connect URL in query parameter"), await this.executeConnection(() =>
|
|
6599
|
+
Z.info("Found external connect URL in query parameter"), await this.executeConnection(() => Tg(t, this.abortController.signal));
|
|
6509
6600
|
return;
|
|
6510
6601
|
}
|
|
6511
6602
|
if (this._waitForExternalConnectUrl) {
|
|
@@ -6516,14 +6607,14 @@ var rv = class e {
|
|
|
6516
6607
|
}
|
|
6517
6608
|
async executeConnection(e) {
|
|
6518
6609
|
if (this._lastError = void 0, this.abortController = new AbortController(), typeof Worker < "u" && !this.preloadedWorker) try {
|
|
6519
|
-
this.preloadedWorker = new
|
|
6610
|
+
this.preloadedWorker = new ov();
|
|
6520
6611
|
} catch {}
|
|
6521
6612
|
this.setState("connecting"), this.connectionTimer = setTimeout(() => {
|
|
6522
6613
|
this.currentState === "connecting" && (Z.error("Connection timeout"), this.abortController?.abort("Connection timeout"), this.setState("offline"), this.config.onError?.(/* @__PURE__ */ Error("Connection timeout")));
|
|
6523
6614
|
}, this.connectionTimeoutMs);
|
|
6524
6615
|
try {
|
|
6525
6616
|
let t = await e();
|
|
6526
|
-
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 && (
|
|
6617
|
+
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 && (Ih(t.backendUrl, t.authToken), this._logSenderStarted = !0), this.probeFasterConnectTiers(t), await this.connectProtocol(this.authResponse.Entrypoints);
|
|
6527
6618
|
} catch (e) {
|
|
6528
6619
|
if (e instanceof DOMException && e.name === "AbortError") return;
|
|
6529
6620
|
throw Z.error("Connection failed:", e), this.clearTimers(), this.setState("offline"), this.config.onError?.(e instanceof Error ? e : Error(String(e))), e;
|
|
@@ -6535,7 +6626,7 @@ var rv = class e {
|
|
|
6535
6626
|
return;
|
|
6536
6627
|
}
|
|
6537
6628
|
let t = this.config.sessionToken?.token ?? this.config.local?.token;
|
|
6538
|
-
if (t &&
|
|
6629
|
+
if (t && eg(e) !== eg(t)) {
|
|
6539
6630
|
Z.error("Ignoring an auth token for a different user; the client must be rebuilt for a new identity");
|
|
6540
6631
|
return;
|
|
6541
6632
|
}
|
|
@@ -6549,7 +6640,7 @@ var rv = class e {
|
|
|
6549
6640
|
};
|
|
6550
6641
|
this.config.local.identityToken === this.config.local.token && (t.identityToken = e), this.config.local = t;
|
|
6551
6642
|
}
|
|
6552
|
-
this._logSenderStarted &&
|
|
6643
|
+
this._logSenderStarted && Lh(e);
|
|
6553
6644
|
for (let t of this._siblings) t.updateAuthToken(e);
|
|
6554
6645
|
}
|
|
6555
6646
|
createSibling(t, n) {
|
|
@@ -6557,7 +6648,7 @@ var rv = class e {
|
|
|
6557
6648
|
return r._tokenOwner = this, this._siblings.add(r), r;
|
|
6558
6649
|
}
|
|
6559
6650
|
disconnect() {
|
|
6560
|
-
Z.info("Disconnecting from Ikon server"), this.sendDisconnectSignal(), this._logSenderStarted &&= (
|
|
6651
|
+
Z.info("Disconnecting from Ikon server"), this.sendDisconnectSignal(), this._logSenderStarted &&= (zh(), !1), this._tokenOwner?._siblings.delete(this), this._tokenOwner = null, this._siblings.clear(), 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, this._environmentTrackingCleanup?.(), this._environmentTrackingCleanup = null;
|
|
6561
6652
|
for (let e of this._webRtcAudioElements.values()) e.pause(), e.srcObject = null, e.remove();
|
|
6562
6653
|
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");
|
|
6563
6654
|
}
|
|
@@ -6790,10 +6881,10 @@ var rv = class e {
|
|
|
6790
6881
|
}
|
|
6791
6882
|
async authenticate() {
|
|
6792
6883
|
let e = this.abortController?.signal;
|
|
6793
|
-
if (this.config.local) return
|
|
6884
|
+
if (this.config.local) return Pg(this.config.local, e);
|
|
6794
6885
|
let t = this.endpointSelector.proxyMode, n = this.endpointSelector.connectTier, r;
|
|
6795
|
-
if (this.config.apiKey) r = await
|
|
6796
|
-
else if (this.config.sessionToken) r = await
|
|
6886
|
+
if (this.config.apiKey) r = await Fg(this.config.apiKey, e, t, n);
|
|
6887
|
+
else if (this.config.sessionToken) r = await Ig(this.config.sessionToken, e, t, n);
|
|
6797
6888
|
else throw Error("No connection configuration provided (need local, apiKey, or sessionToken)");
|
|
6798
6889
|
return r.connectTier && t === "auto" && this.endpointSelector.recordWorkingConnectTier(r.connectTier), r;
|
|
6799
6890
|
}
|
|
@@ -6803,7 +6894,7 @@ var rv = class e {
|
|
|
6803
6894
|
for (let n of this.endpointSelector.getFasterConnectTiers(t)) {
|
|
6804
6895
|
let t = e.connectTierUrls?.[n];
|
|
6805
6896
|
if (t) try {
|
|
6806
|
-
if (await
|
|
6897
|
+
if (await Eg(t)) {
|
|
6807
6898
|
Z.debug(`Background probe: the ${n} tier is reachable, stepping up to it for the next connection`), this.endpointSelector.recordReachableConnectTier(n);
|
|
6808
6899
|
return;
|
|
6809
6900
|
}
|
|
@@ -6842,7 +6933,7 @@ var rv = class e {
|
|
|
6842
6933
|
return;
|
|
6843
6934
|
}
|
|
6844
6935
|
if (t === T.CORE_GLOBAL_STATE && zo(e).then((e) => {
|
|
6845
|
-
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 &&
|
|
6936
|
+
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 && V_(), B_() && this.protocolWorker && (this.protocolWorker.postMessage({
|
|
6846
6937
|
type: "enableDevtools",
|
|
6847
6938
|
enabled: !0
|
|
6848
6939
|
}), this.protocolWorker.postMessage({
|
|
@@ -6929,7 +7020,7 @@ var rv = class e {
|
|
|
6929
7020
|
break;
|
|
6930
7021
|
case "offline":
|
|
6931
7022
|
if (this._reauthInProgress) break;
|
|
6932
|
-
if (this._hasBeenConnected && !this._serverStopped &&
|
|
7023
|
+
if (this._hasBeenConnected && !this._serverStopped && M()) {
|
|
6933
7024
|
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();
|
|
6934
7025
|
break;
|
|
6935
7026
|
}
|
|
@@ -6945,7 +7036,7 @@ var rv = class e {
|
|
|
6945
7036
|
}
|
|
6946
7037
|
setState(e) {
|
|
6947
7038
|
if (!this._isUnloading) {
|
|
6948
|
-
if (e === "offline" && this._hasBeenConnected && !this._serverStopped &&
|
|
7039
|
+
if (e === "offline" && this._hasBeenConnected && !this._serverStopped && M()) {
|
|
6949
7040
|
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();
|
|
6950
7041
|
return;
|
|
6951
7042
|
}
|
|
@@ -6980,7 +7071,7 @@ var rv = class e {
|
|
|
6980
7071
|
let n;
|
|
6981
7072
|
if (this.preloadedWorker) n = this.preloadedWorker, this.preloadedWorker = null;
|
|
6982
7073
|
else try {
|
|
6983
|
-
n = new
|
|
7074
|
+
n = new ov();
|
|
6984
7075
|
} catch (n) {
|
|
6985
7076
|
Z.warn(`Failed to create protocol worker, falling back to main thread: ${n}`), await this.connectProtocolOnMainThread(e, t);
|
|
6986
7077
|
return;
|
|
@@ -7003,11 +7094,11 @@ var rv = class e {
|
|
|
7003
7094
|
let n = o.activeType;
|
|
7004
7095
|
n !== void 0 && (this._activeEndpointType = n, this.endpointSelector.rememberWorkingType(n));
|
|
7005
7096
|
let i = o.httpStreamMode;
|
|
7006
|
-
i !== void 0 && this.rememberHttpStreamModeUnlessPinned(i), t === "connected" &&
|
|
7097
|
+
i !== void 0 && this.rememberHttpStreamModeUnlessPinned(i), t === "connected" && uv(n) && this.warnAboutFallbackTransport(i), this.handleChannelManagerStateChange(t), t === "connected" && !r && (r = !0, a(), e());
|
|
7007
7098
|
return;
|
|
7008
7099
|
}
|
|
7009
7100
|
if (o?.type === "refreshEntrypoints") {
|
|
7010
|
-
this._connectUrl ?
|
|
7101
|
+
this._connectUrl ? Tg(this._connectUrl, this.abortController?.signal).then((e) => {
|
|
7011
7102
|
this.authResponse = e.authResponse, this._sessionId = e.authResponse.ClientContext.SessionId, n.postMessage({
|
|
7012
7103
|
type: "refreshedEntrypoints",
|
|
7013
7104
|
entrypoints: e.authResponse.Entrypoints,
|
|
@@ -7038,14 +7129,14 @@ var rv = class e {
|
|
|
7038
7129
|
r || (i = void 0, t(/* @__PURE__ */ Error("Protocol worker connect timed out")));
|
|
7039
7130
|
}, Jd);
|
|
7040
7131
|
}), i = this.computeOrderedEndpointTypes(e), a = this.getServerKeepaliveTimeoutMs(), o = this.config.timeouts?.reconnectBackoffMs ?? 2e3, s = this.config.timeouts?.maxReconnectAttempts ?? 2;
|
|
7041
|
-
this.updateWorkerInterestMask(),
|
|
7132
|
+
this.updateWorkerInterestMask(), B_() && (n.postMessage({
|
|
7042
7133
|
type: "enableDevtools",
|
|
7043
7134
|
enabled: !0
|
|
7044
7135
|
}), n.postMessage({
|
|
7045
7136
|
type: "setLogLevel",
|
|
7046
7137
|
level: Se()
|
|
7047
|
-
})),
|
|
7048
|
-
let c =
|
|
7138
|
+
})), G_();
|
|
7139
|
+
let c = Gu() ?? this.config.webRtc?.enabled ?? !0;
|
|
7049
7140
|
n.postMessage({
|
|
7050
7141
|
type: "connect",
|
|
7051
7142
|
sessionId: this._sessionId,
|
|
@@ -7074,7 +7165,7 @@ var rv = class e {
|
|
|
7074
7165
|
}
|
|
7075
7166
|
ensureVisemeTracker() {
|
|
7076
7167
|
if (!this._visemeTracker) try {
|
|
7077
|
-
this._visemeTracker = new
|
|
7168
|
+
this._visemeTracker = new L_(this), this._visemeTracker.enable();
|
|
7078
7169
|
} catch (e) {
|
|
7079
7170
|
Z.warn(`Viseme tracker setup failed: ${e}`), this._visemeTracker = null;
|
|
7080
7171
|
}
|
|
@@ -7098,7 +7189,7 @@ var rv = class e {
|
|
|
7098
7189
|
useVideoTrack: this._videoEnabled,
|
|
7099
7190
|
useDataChannel: !0,
|
|
7100
7191
|
iceServers: this.config.webRtc?.iceServers,
|
|
7101
|
-
iceTransportPolicy:
|
|
7192
|
+
iceTransportPolicy: Ku() ?? this.config.webRtc?.iceTransportPolicy ?? this._webRtcReachability.iceTransportPolicy,
|
|
7102
7193
|
shouldAttemptWithoutIceServers: () => this._webRtcReachability.shouldAttemptWithoutIceServers || this._webRtcRetryCount > 0,
|
|
7103
7194
|
onStateChange: (e) => {
|
|
7104
7195
|
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}`);
|
|
@@ -7152,9 +7243,9 @@ var rv = class e {
|
|
|
7152
7243
|
this._webRtcRetryTimer &&= (clearTimeout(this._webRtcRetryTimer), null);
|
|
7153
7244
|
}
|
|
7154
7245
|
scheduleWebRtcRetry() {
|
|
7155
|
-
if (this._webRtcRetryTimer || this._webRtcRetryCount >=
|
|
7156
|
-
let e =
|
|
7157
|
-
Z.info(`Retrying WebRTC in ${Math.round(e / 1e3)}s (attempt ${this._webRtcRetryCount}/${
|
|
7246
|
+
if (this._webRtcRetryTimer || this._webRtcRetryCount >= sv.length) return;
|
|
7247
|
+
let e = sv[this._webRtcRetryCount++];
|
|
7248
|
+
Z.info(`Retrying WebRTC in ${Math.round(e / 1e3)}s (attempt ${this._webRtcRetryCount}/${sv.length})`), this._webRtcRetryTimer = setTimeout(() => {
|
|
7158
7249
|
this._webRtcRetryTimer = null, !(this.currentState !== "connected" || this._webRtcSignaling || !this.isWebRtcEnabled) && this.setupWebRtcSignaling();
|
|
7159
7250
|
}, e);
|
|
7160
7251
|
}
|
|
@@ -7286,7 +7377,7 @@ var rv = class e {
|
|
|
7286
7377
|
}
|
|
7287
7378
|
async connectProtocolOnMainThread(e, t = !1) {
|
|
7288
7379
|
this.workerManagerState = null, this.protocolWorker = null;
|
|
7289
|
-
let n =
|
|
7380
|
+
let n = Gu() ?? this.config.webRtc?.enabled ?? !0;
|
|
7290
7381
|
Z.debug(`Connecting on main thread (webRtcEnabled=${n}, entrypoints=${e.length})`), this.channelManager = new Sd({
|
|
7291
7382
|
sessionId: this._sessionId,
|
|
7292
7383
|
keepaliveTimeoutMs: this.getServerKeepaliveTimeoutMs(),
|
|
@@ -7301,13 +7392,13 @@ var rv = class e {
|
|
|
7301
7392
|
},
|
|
7302
7393
|
onStateChange: (e) => {
|
|
7303
7394
|
let t = this.channelManager?.activeHttpStreamMode;
|
|
7304
|
-
t && this.rememberHttpStreamModeUnlessPinned(t), e === "connected" &&
|
|
7395
|
+
t && this.rememberHttpStreamModeUnlessPinned(t), e === "connected" && uv(this.channelManager?.activeEndpointType ?? void 0) && this.warnAboutFallbackTransport(t ?? void 0), this.handleChannelManagerStateChange(e);
|
|
7305
7396
|
},
|
|
7306
7397
|
onError: (e) => {
|
|
7307
7398
|
this.config.onError?.(e);
|
|
7308
7399
|
},
|
|
7309
7400
|
onRefreshEntrypoints: this._connectUrl ? async () => {
|
|
7310
|
-
let e = await
|
|
7401
|
+
let e = await Tg(this._connectUrl, this.abortController?.signal);
|
|
7311
7402
|
return this.authResponse = e.authResponse, this._sessionId = e.authResponse.ClientContext.SessionId, {
|
|
7312
7403
|
entrypoints: e.authResponse.Entrypoints,
|
|
7313
7404
|
sessionId: this._sessionId
|
|
@@ -7339,7 +7430,7 @@ var rv = class e {
|
|
|
7339
7430
|
warnAboutFallbackTransport(e) {
|
|
7340
7431
|
if (this._fallbackTransportWarned) return;
|
|
7341
7432
|
this._fallbackTransportWarned = !0;
|
|
7342
|
-
let t = this.httpStreamMode !== void 0 ||
|
|
7433
|
+
let t = this.httpStreamMode !== void 0 || zu() !== null, n = typeof window < "u" ? window.location.origin : null, r = t ? "[pinned transport, not a network restriction] " : "";
|
|
7343
7434
|
Z.warn(`${r}${this.fallbackTransportMessage(n, e)}`);
|
|
7344
7435
|
}
|
|
7345
7436
|
fallbackTransportMessage(e, t) {
|
|
@@ -7354,8 +7445,8 @@ var rv = class e {
|
|
|
7354
7445
|
assertPinnedTransportIsAvailable(e) {
|
|
7355
7446
|
let t = this.groupEntrypointsByType(e);
|
|
7356
7447
|
if (t.size === 0 || this.computeOrderedEndpointTypes(e).length > 0) return;
|
|
7357
|
-
let n =
|
|
7358
|
-
throw new
|
|
7448
|
+
let n = zu();
|
|
7449
|
+
throw new fu(n ? `${n.family}${n.mode ? `-${n.mode}` : ""}` : null, Iu(), [...t.keys()].map((e) => x[e]));
|
|
7359
7450
|
}
|
|
7360
7451
|
async revalidateEndpointPreference() {
|
|
7361
7452
|
if (this._revalidationDone || !this.endpointSelector.needsRevalidation()) return;
|
|
@@ -7367,7 +7458,7 @@ var rv = class e {
|
|
|
7367
7458
|
let n = this.groupEntrypointsByType(this._connectedEntrypoints), r = this.abortController?.signal;
|
|
7368
7459
|
for (let e of t) {
|
|
7369
7460
|
let t = n.get(e)?.[0]?.Uri;
|
|
7370
|
-
if (!(t === void 0 || r?.aborted) && await
|
|
7461
|
+
if (!(t === void 0 || r?.aborted) && await nv(e, t, { signal: r })) {
|
|
7371
7462
|
this.endpointSelector.recordFasterTypeReachable(e);
|
|
7372
7463
|
return;
|
|
7373
7464
|
}
|
|
@@ -7424,7 +7515,7 @@ var rv = class e {
|
|
|
7424
7515
|
let e = 3e4, t = await Promise.race([this.authenticate(), new Promise((t, n) => {
|
|
7425
7516
|
setTimeout(() => n(/* @__PURE__ */ Error(`Re-authentication timed out after ${e / 1e3} s`)), e);
|
|
7426
7517
|
})]);
|
|
7427
|
-
this.authResponse = t.authResponse, this._sessionId = t.authResponse.ClientContext.SessionId, this._connectUrl = t.directUrl, this._logSenderStarted && t.authToken &&
|
|
7518
|
+
this.authResponse = t.authResponse, this._sessionId = t.authResponse.ClientContext.SessionId, this._connectUrl = t.directUrl, this._logSenderStarted && t.authToken && Lh(t.authToken), Z.info("Re-authenticated, connecting to new server"), await this.connectProtocol(this.authResponse.Entrypoints);
|
|
7428
7519
|
} catch (e) {
|
|
7429
7520
|
if (e instanceof DOMException && e.name === "AbortError") return;
|
|
7430
7521
|
Z.error("Full re-authentication failed:", e), this.config.onError?.(e instanceof Error ? e : Error(String(e))), this._hasBeenConnected ? this.scheduleReconnectRetry() : (this.clearTimers(), this.setState("offline"));
|
|
@@ -7433,7 +7524,7 @@ var rv = class e {
|
|
|
7433
7524
|
}
|
|
7434
7525
|
}
|
|
7435
7526
|
attemptReconnect() {
|
|
7436
|
-
if (!
|
|
7527
|
+
if (!M()) {
|
|
7437
7528
|
Z.warn("Retry disabled via ikon-retry=false, going offline"), this.clearTimers(), this.setState("offline");
|
|
7438
7529
|
return;
|
|
7439
7530
|
}
|
|
@@ -7460,7 +7551,7 @@ var rv = class e {
|
|
|
7460
7551
|
this.attemptFullReauth();
|
|
7461
7552
|
}
|
|
7462
7553
|
scheduleReconnectRetry() {
|
|
7463
|
-
if (!
|
|
7554
|
+
if (!M()) {
|
|
7464
7555
|
Z.warn("Retry disabled via ikon-retry=false, going offline instead of scheduling retry"), this.clearTimers(), this.setState("offline");
|
|
7465
7556
|
return;
|
|
7466
7557
|
}
|
|
@@ -7497,8 +7588,8 @@ var rv = class e {
|
|
|
7497
7588
|
let t = e.target?.closest?.("a[href]");
|
|
7498
7589
|
if (!t || t.target && t.target !== "_self") return;
|
|
7499
7590
|
let n = t.getAttribute("href") ?? "";
|
|
7500
|
-
if (
|
|
7501
|
-
e.preventDefault(),
|
|
7591
|
+
if (X_(n)) {
|
|
7592
|
+
e.preventDefault(), Z_(n);
|
|
7502
7593
|
return;
|
|
7503
7594
|
}
|
|
7504
7595
|
let r = this.resolveInPlaceDestination(t, n);
|
|
@@ -7612,7 +7703,7 @@ var rv = class e {
|
|
|
7612
7703
|
let e = (e) => {
|
|
7613
7704
|
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) => {
|
|
7614
7705
|
if (!(e instanceof DOMException && e.name === "AbortError")) {
|
|
7615
|
-
if (this._hasBeenConnected &&
|
|
7706
|
+
if (this._hasBeenConnected && M()) {
|
|
7616
7707
|
Z.warn("External connect URL connection failed, scheduling retry:", e), this.scheduleReconnectRetry();
|
|
7617
7708
|
return;
|
|
7618
7709
|
}
|
|
@@ -7631,18 +7722,18 @@ var rv = class e {
|
|
|
7631
7722
|
if (this.currentState !== "waitingForExternalConnectUrl") throw Error(`Cannot connect with external connect URL: already in state ${this.currentState}`);
|
|
7632
7723
|
Z.info("Connecting with external connect URL");
|
|
7633
7724
|
try {
|
|
7634
|
-
await this.executeConnection(() =>
|
|
7725
|
+
await this.executeConnection(() => Tg(e, this.abortController.signal));
|
|
7635
7726
|
} finally {
|
|
7636
7727
|
this._externalConnectUrlCleanup &&= (this._externalConnectUrlCleanup(), null);
|
|
7637
7728
|
}
|
|
7638
7729
|
}
|
|
7639
7730
|
};
|
|
7640
|
-
function
|
|
7731
|
+
function uv(e) {
|
|
7641
7732
|
return e === x.HttpStream || e === x.HttpStreamProxy;
|
|
7642
7733
|
}
|
|
7643
7734
|
//#endregion
|
|
7644
7735
|
//#region src/app-messaging.ts
|
|
7645
|
-
var
|
|
7736
|
+
var dv = class {
|
|
7646
7737
|
client;
|
|
7647
7738
|
constructor(e) {
|
|
7648
7739
|
this.client = e;
|
|
@@ -7660,45 +7751,45 @@ var av = class {
|
|
|
7660
7751
|
}, { close: () => n.close() }) : { close: () => {} };
|
|
7661
7752
|
}
|
|
7662
7753
|
};
|
|
7663
|
-
function
|
|
7664
|
-
return new
|
|
7754
|
+
function fv(e) {
|
|
7755
|
+
return new dv(e);
|
|
7665
7756
|
}
|
|
7666
7757
|
//#endregion
|
|
7667
7758
|
//#region src/client/connection-state.ts
|
|
7668
|
-
function
|
|
7759
|
+
function pv(e) {
|
|
7669
7760
|
return e === "waitingForExternalConnectUrl" || e === "connecting" || e === "connectingSlow" || e === "reconnecting";
|
|
7670
7761
|
}
|
|
7671
|
-
function
|
|
7762
|
+
function mv(e) {
|
|
7672
7763
|
return e === "connected";
|
|
7673
7764
|
}
|
|
7674
|
-
function
|
|
7765
|
+
function hv(e) {
|
|
7675
7766
|
return e === "offline" || e === "offlineError";
|
|
7676
7767
|
}
|
|
7677
|
-
function
|
|
7768
|
+
function gv(e) {
|
|
7678
7769
|
return e === "offlineError";
|
|
7679
7770
|
}
|
|
7680
7771
|
//#endregion
|
|
7681
7772
|
//#region src/utils/opcode-names.ts
|
|
7682
|
-
var
|
|
7683
|
-
for (let [e, t] of Object.entries(T)) typeof t == "number" &&
|
|
7684
|
-
function
|
|
7685
|
-
return
|
|
7773
|
+
var _v = /* @__PURE__ */ new Map();
|
|
7774
|
+
for (let [e, t] of Object.entries(T)) typeof t == "number" && _v.set(t, e);
|
|
7775
|
+
function vv(e) {
|
|
7776
|
+
return _v.get(e) ?? `UNKNOWN_${e}`;
|
|
7686
7777
|
}
|
|
7687
7778
|
//#endregion
|
|
7688
7779
|
//#region src/login/reprovision.ts
|
|
7689
|
-
var
|
|
7690
|
-
function
|
|
7780
|
+
var yv = "ikon-login-app-route";
|
|
7781
|
+
function bv(e) {
|
|
7691
7782
|
if (typeof window > "u") return;
|
|
7692
7783
|
try {
|
|
7693
|
-
sessionStorage.setItem(
|
|
7784
|
+
sessionStorage.setItem(yv, window.location.pathname);
|
|
7694
7785
|
} catch {}
|
|
7695
7786
|
let t = new URL(window.location.href);
|
|
7696
|
-
t.searchParams.set(
|
|
7787
|
+
t.searchParams.set(gu, e), window.location.href = t.toString();
|
|
7697
7788
|
}
|
|
7698
|
-
function
|
|
7789
|
+
function xv() {
|
|
7699
7790
|
let e = null;
|
|
7700
7791
|
try {
|
|
7701
|
-
e = sessionStorage.getItem(
|
|
7792
|
+
e = sessionStorage.getItem(yv), sessionStorage.removeItem(yv);
|
|
7702
7793
|
} catch {}
|
|
7703
7794
|
return {
|
|
7704
7795
|
appRoute: e,
|
|
@@ -7707,7 +7798,7 @@ function hv() {
|
|
|
7707
7798
|
}
|
|
7708
7799
|
//#endregion
|
|
7709
7800
|
//#region src/media/ring-buffer.ts
|
|
7710
|
-
var
|
|
7801
|
+
var Sv = class {
|
|
7711
7802
|
static getStorageForCapacity(e, t) {
|
|
7712
7803
|
let n = Int32Array.BYTES_PER_ELEMENT * 2, r = t.BYTES_PER_ELEMENT * e;
|
|
7713
7804
|
return new SharedArrayBuffer(n + r);
|
|
@@ -7758,7 +7849,7 @@ var gv = class {
|
|
|
7758
7849
|
};
|
|
7759
7850
|
//#endregion
|
|
7760
7851
|
//#region src/worker/audio-capture-worker.ts?worker
|
|
7761
|
-
function
|
|
7852
|
+
function Cv(e) {
|
|
7762
7853
|
return new Worker("" + new URL("assets/audio-capture-worker-CJ5S-nQt.js", import.meta.url).href, {
|
|
7763
7854
|
type: "module",
|
|
7764
7855
|
name: e?.name
|
|
@@ -7766,11 +7857,11 @@ function _v(e) {
|
|
|
7766
7857
|
}
|
|
7767
7858
|
//#endregion
|
|
7768
7859
|
//#region src/media/ikon-audio-capture.ts
|
|
7769
|
-
var Q = w("IkonAudioCapture"),
|
|
7770
|
-
function
|
|
7860
|
+
var Q = w("IkonAudioCapture"), wv = 3, Tv = 200, Ev = 2e3, Dv = 5e3, Ov = 3e3;
|
|
7861
|
+
function kv(e) {
|
|
7771
7862
|
return new Promise((t) => setTimeout(t, e));
|
|
7772
7863
|
}
|
|
7773
|
-
function
|
|
7864
|
+
function Av(e) {
|
|
7774
7865
|
switch (e.name) {
|
|
7775
7866
|
case "NotReadableError": return {
|
|
7776
7867
|
action: "retry",
|
|
@@ -7806,14 +7897,14 @@ function wv(e) {
|
|
|
7806
7897
|
};
|
|
7807
7898
|
}
|
|
7808
7899
|
}
|
|
7809
|
-
function
|
|
7900
|
+
function jv() {
|
|
7810
7901
|
let e = globalThis.crypto;
|
|
7811
7902
|
return e?.randomUUID ? e.randomUUID() : `cap_${Date.now()}_${Math.floor(Math.random() * 1e9)}`;
|
|
7812
7903
|
}
|
|
7813
|
-
function
|
|
7904
|
+
function Mv() {
|
|
7814
7905
|
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";
|
|
7815
7906
|
}
|
|
7816
|
-
var
|
|
7907
|
+
var Nv = class e {
|
|
7817
7908
|
client;
|
|
7818
7909
|
static RESUME_TIMEOUT_MS = 3e3;
|
|
7819
7910
|
worker = null;
|
|
@@ -7874,7 +7965,7 @@ var Dv = class e {
|
|
|
7874
7965
|
notifyError(e, t, n, r) {
|
|
7875
7966
|
if (e.stopped) return;
|
|
7876
7967
|
let i = Date.now(), a = t.name;
|
|
7877
|
-
if (e.lastErrorReason === n && e.lastErrorName === a && i - e.lastErrorTime <
|
|
7968
|
+
if (e.lastErrorReason === n && e.lastErrorName === a && i - e.lastErrorTime < Dv) return;
|
|
7878
7969
|
e.lastErrorTime = i, e.lastErrorReason = n, e.lastErrorName = a;
|
|
7879
7970
|
let o = this.config.autoRestartPolicy;
|
|
7880
7971
|
if (o?.enabled && r) {
|
|
@@ -7932,7 +8023,7 @@ var Dv = class e {
|
|
|
7932
8023
|
if (e.ctx.state === "running") return !0;
|
|
7933
8024
|
if (e.ctx.state !== "suspended") return !1;
|
|
7934
8025
|
let r = Date.now();
|
|
7935
|
-
if (!n && r - e.lastResumeAttemptTime <
|
|
8026
|
+
if (!n && r - e.lastResumeAttemptTime < Ov) return Q.debug(`Resume attempt from ${t} skipped (cooldown)`), !1;
|
|
7936
8027
|
e.lastResumeAttemptTime = r, this.emitDiagnostic({
|
|
7937
8028
|
event: "resume-attempt",
|
|
7938
8029
|
captureId: e.captureId,
|
|
@@ -7968,7 +8059,7 @@ var Dv = class e {
|
|
|
7968
8059
|
attemptResume(e, t, n = !1) {
|
|
7969
8060
|
if (e.stopped || e.ctx.state !== "suspended") return;
|
|
7970
8061
|
let r = Date.now();
|
|
7971
|
-
if (!n && r - e.lastResumeAttemptTime <
|
|
8062
|
+
if (!n && r - e.lastResumeAttemptTime < Ov) {
|
|
7972
8063
|
Q.debug(`Resume attempt from ${t} skipped (cooldown)`);
|
|
7973
8064
|
return;
|
|
7974
8065
|
}
|
|
@@ -8067,7 +8158,7 @@ var Dv = class e {
|
|
|
8067
8158
|
}
|
|
8068
8159
|
ensureWorker() {
|
|
8069
8160
|
if (this.worker) return this.worker;
|
|
8070
|
-
let e = new
|
|
8161
|
+
let e = new Cv();
|
|
8071
8162
|
return this.worker = e, e.addEventListener("message", (e) => {
|
|
8072
8163
|
let t = e.data;
|
|
8073
8164
|
if (t?.type === "error") {
|
|
@@ -8165,25 +8256,25 @@ var Dv = class e {
|
|
|
8165
8256
|
reason: "unknown",
|
|
8166
8257
|
canRetry: !1
|
|
8167
8258
|
};
|
|
8168
|
-
for (let r = 0; r <
|
|
8259
|
+
for (let r = 0; r < wv; r++) try {
|
|
8169
8260
|
return {
|
|
8170
8261
|
stream: await navigator.mediaDevices.getUserMedia({ audio: e }),
|
|
8171
8262
|
error: t,
|
|
8172
8263
|
errorInfo: n
|
|
8173
8264
|
};
|
|
8174
8265
|
} catch (e) {
|
|
8175
|
-
if (t = e instanceof Error ? e : Error(String(e)), n =
|
|
8266
|
+
if (t = e instanceof Error ? e : Error(String(e)), n = Av(t), Q.debug(`getUserMedia attempt ${r + 1}/${wv} failed: ${t.name} (action: ${n.action})`), this.emitDiagnostic({
|
|
8176
8267
|
event: "retry",
|
|
8177
8268
|
details: {
|
|
8178
8269
|
attempt: r + 1,
|
|
8179
|
-
maxAttempts:
|
|
8270
|
+
maxAttempts: wv,
|
|
8180
8271
|
errorName: t.name,
|
|
8181
8272
|
action: n.action
|
|
8182
8273
|
}
|
|
8183
8274
|
}), n.action !== "retry") break;
|
|
8184
8275
|
if (r < 2) {
|
|
8185
|
-
let e =
|
|
8186
|
-
Q.debug(`Retrying getUserMedia in ${e}ms`), await
|
|
8276
|
+
let e = Tv * (r + 1);
|
|
8277
|
+
Q.debug(`Retrying getUserMedia in ${e}ms`), await kv(e);
|
|
8187
8278
|
}
|
|
8188
8279
|
}
|
|
8189
8280
|
return {
|
|
@@ -8194,7 +8285,7 @@ var Dv = class e {
|
|
|
8194
8285
|
}
|
|
8195
8286
|
async ensureWorklet(e) {
|
|
8196
8287
|
if (!we(e)) throw Error("AudioWorklet is not supported in this browser");
|
|
8197
|
-
if (this.workletModuleUrl ||= URL.createObjectURL(new Blob([
|
|
8288
|
+
if (this.workletModuleUrl ||= URL.createObjectURL(new Blob([Mv()], { type: "text/javascript" })), this.workletReady && this.workletContext === e) try {
|
|
8198
8289
|
await this.workletReady;
|
|
8199
8290
|
return;
|
|
8200
8291
|
} catch {
|
|
@@ -8221,7 +8312,7 @@ var Dv = class e {
|
|
|
8221
8312
|
if (!t) throw Error("Cannot start audio capture before client is connected");
|
|
8222
8313
|
if (this.client.isWebRtcCaptureAvailable) return this.startMicWebRtc(e);
|
|
8223
8314
|
this.client.isWebRtcEnabled && Q.warn("WebRTC unavailable, capturing audio via protocol channel");
|
|
8224
|
-
let n =
|
|
8315
|
+
let n = jv(), r = {
|
|
8225
8316
|
captureId: n,
|
|
8226
8317
|
aborted: !1,
|
|
8227
8318
|
stream: null,
|
|
@@ -8259,7 +8350,7 @@ var Dv = class e {
|
|
|
8259
8350
|
let f = xe() ? "sab" : "pcm", p;
|
|
8260
8351
|
if (f === "sab") {
|
|
8261
8352
|
let e = Math.floor(a.sampleRate * 10);
|
|
8262
|
-
p =
|
|
8353
|
+
p = Sv.getStorageForCapacity(e, Float32Array);
|
|
8263
8354
|
}
|
|
8264
8355
|
let m = this.ensureWorker(), h = e.onStopped;
|
|
8265
8356
|
m.postMessage({
|
|
@@ -8407,7 +8498,7 @@ var Dv = class e {
|
|
|
8407
8498
|
};
|
|
8408
8499
|
this.setupAudioContextStateListener(a, _), this.setupVisibilityChangeListener(_), this.setupBFCacheHandlers(_), _.healthCheckTimer = setInterval(() => {
|
|
8409
8500
|
this.performHealthCheck(_);
|
|
8410
|
-
},
|
|
8501
|
+
}, Ev);
|
|
8411
8502
|
let te = () => {
|
|
8412
8503
|
_.stopped || (Q.warn(`Microphone track ended unexpectedly, captureId=${n.substring(0, 8)}`), this.handleRecoverableError(_, /* @__PURE__ */ Error("Microphone track ended unexpectedly"), "track-ended"));
|
|
8413
8504
|
};
|
|
@@ -8556,8 +8647,8 @@ var Dv = class e {
|
|
|
8556
8647
|
let t = this.captures.get(e);
|
|
8557
8648
|
return !t || t.stopped ? !1 : this.attemptResumeAsync(t, "userGesture", !0);
|
|
8558
8649
|
}
|
|
8559
|
-
},
|
|
8560
|
-
function
|
|
8650
|
+
}, Pv = 3e3;
|
|
8651
|
+
function Fv(e, t, n, r) {
|
|
8561
8652
|
if (!n && !r) return {
|
|
8562
8653
|
width: e,
|
|
8563
8654
|
height: t
|
|
@@ -8568,7 +8659,7 @@ function kv(e, t, n, r) {
|
|
|
8568
8659
|
height: Math.max(1, Math.floor(t * o))
|
|
8569
8660
|
};
|
|
8570
8661
|
}
|
|
8571
|
-
async function
|
|
8662
|
+
async function Iv(e, t) {
|
|
8572
8663
|
let n = t.mime ?? "image/jpeg", r = t.quality ?? .92;
|
|
8573
8664
|
if (typeof OffscreenCanvas < "u" && e instanceof OffscreenCanvas) try {
|
|
8574
8665
|
return await e.convertToBlob({
|
|
@@ -8583,7 +8674,7 @@ async function Av(e, t) {
|
|
|
8583
8674
|
}, n, r);
|
|
8584
8675
|
});
|
|
8585
8676
|
}
|
|
8586
|
-
var
|
|
8677
|
+
var Lv = class {
|
|
8587
8678
|
async captureFromStream(e, t = {}) {
|
|
8588
8679
|
let n = e.getVideoTracks()[0];
|
|
8589
8680
|
if (!n) throw Error("No video track available in the provided stream");
|
|
@@ -8594,7 +8685,7 @@ var jv = class {
|
|
|
8594
8685
|
} catch {}
|
|
8595
8686
|
try {
|
|
8596
8687
|
await new Promise((e, t) => {
|
|
8597
|
-
let n = setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for video metadata")),
|
|
8688
|
+
let n = setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for video metadata")), Pv);
|
|
8598
8689
|
r.addEventListener("loadedmetadata", () => {
|
|
8599
8690
|
clearTimeout(n), e();
|
|
8600
8691
|
}, { once: !0 }), r.addEventListener("error", () => {
|
|
@@ -8604,7 +8695,7 @@ var jv = class {
|
|
|
8604
8695
|
try {
|
|
8605
8696
|
await r.play();
|
|
8606
8697
|
} catch {}
|
|
8607
|
-
let { width: e, height: i } =
|
|
8698
|
+
let { width: e, height: i } = Fv(r.videoWidth || (n.getSettings().width ?? 1280), r.videoHeight || (n.getSettings().height ?? 720), t.width, t.height), a;
|
|
8608
8699
|
if (typeof OffscreenCanvas < "u") a = new OffscreenCanvas(e, i);
|
|
8609
8700
|
else {
|
|
8610
8701
|
let t = document.createElement("canvas");
|
|
@@ -8613,7 +8704,7 @@ var jv = class {
|
|
|
8613
8704
|
let o = a.getContext("2d", { alpha: !1 });
|
|
8614
8705
|
if (!o) throw Error("2D canvas context unavailable");
|
|
8615
8706
|
o.drawImage(r, 0, 0, e, i);
|
|
8616
|
-
let s = await
|
|
8707
|
+
let s = await Iv(a, t), c = await s.arrayBuffer();
|
|
8617
8708
|
return {
|
|
8618
8709
|
mime: s.type || t.mime || "image/jpeg",
|
|
8619
8710
|
width: e,
|
|
@@ -8654,7 +8745,7 @@ var jv = class {
|
|
|
8654
8745
|
} catch {}
|
|
8655
8746
|
try {
|
|
8656
8747
|
await new Promise((e, t) => {
|
|
8657
|
-
let n = setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for video metadata")),
|
|
8748
|
+
let n = setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for video metadata")), Pv);
|
|
8658
8749
|
r.addEventListener("loadedmetadata", () => {
|
|
8659
8750
|
clearTimeout(n), e();
|
|
8660
8751
|
}, { once: !0 }), r.addEventListener("error", () => {
|
|
@@ -8664,7 +8755,7 @@ var jv = class {
|
|
|
8664
8755
|
try {
|
|
8665
8756
|
await r.play();
|
|
8666
8757
|
} catch {}
|
|
8667
|
-
let { width: t, height: i } =
|
|
8758
|
+
let { width: t, height: i } = Fv(r.videoWidth || (n.getSettings().width ?? 1280), r.videoHeight || (n.getSettings().height ?? 720), e.width, e.height), a;
|
|
8668
8759
|
if (typeof OffscreenCanvas < "u") a = new OffscreenCanvas(t, i);
|
|
8669
8760
|
else {
|
|
8670
8761
|
let e = document.createElement("canvas");
|
|
@@ -8673,7 +8764,7 @@ var jv = class {
|
|
|
8673
8764
|
let o = a.getContext("2d", { alpha: !1 });
|
|
8674
8765
|
if (!o) throw Error("2D canvas context unavailable");
|
|
8675
8766
|
o.drawImage(r, 0, 0, t, i);
|
|
8676
|
-
let s = await
|
|
8767
|
+
let s = await Iv(a, e), c = await s.arrayBuffer();
|
|
8677
8768
|
return {
|
|
8678
8769
|
mime: s.type || e.mime || "image/jpeg",
|
|
8679
8770
|
width: t,
|
|
@@ -8697,11 +8788,11 @@ var jv = class {
|
|
|
8697
8788
|
}
|
|
8698
8789
|
async captureFromNativeCamera(e = {}) {
|
|
8699
8790
|
if (typeof document > "u") throw Error("Native camera capture requires a DOM environment");
|
|
8700
|
-
let t = await
|
|
8701
|
-
return t ? await
|
|
8791
|
+
let t = await Rv(e.facing);
|
|
8792
|
+
return t ? await zv(t, e) : null;
|
|
8702
8793
|
}
|
|
8703
8794
|
};
|
|
8704
|
-
function
|
|
8795
|
+
function Rv(e) {
|
|
8705
8796
|
return new Promise((t) => {
|
|
8706
8797
|
let n = document.createElement("input");
|
|
8707
8798
|
n.type = "file", n.accept = "image/*", n.setAttribute("capture", e ?? "environment"), n.style.position = "fixed", n.style.left = "-99999px", n.style.top = "0";
|
|
@@ -8727,7 +8818,7 @@ function Mv(e) {
|
|
|
8727
8818
|
n.click();
|
|
8728
8819
|
});
|
|
8729
8820
|
}
|
|
8730
|
-
async function
|
|
8821
|
+
async function zv(e, t) {
|
|
8731
8822
|
let n = URL.createObjectURL(e), r;
|
|
8732
8823
|
try {
|
|
8733
8824
|
r = await new Promise((e, t) => {
|
|
@@ -8737,7 +8828,7 @@ async function Nv(e, t) {
|
|
|
8737
8828
|
} finally {
|
|
8738
8829
|
URL.revokeObjectURL(n);
|
|
8739
8830
|
}
|
|
8740
|
-
let i = r.naturalWidth || r.width, a = r.naturalHeight || r.height, { width: o, height: s } =
|
|
8831
|
+
let i = r.naturalWidth || r.width, a = r.naturalHeight || r.height, { width: o, height: s } = Fv(i, a, t.width, t.height), c = t.mime ?? (e.type === "image/png" ? "image/png" : "image/jpeg"), l = t.quality ?? .92;
|
|
8741
8832
|
if (o === i && s === a && e.type === c) {
|
|
8742
8833
|
let t = await e.arrayBuffer();
|
|
8743
8834
|
return {
|
|
@@ -8764,7 +8855,7 @@ async function Nv(e, t) {
|
|
|
8764
8855
|
}
|
|
8765
8856
|
//#endregion
|
|
8766
8857
|
//#region src/worker/video-capture-worker.ts?worker
|
|
8767
|
-
function
|
|
8858
|
+
function Bv(e) {
|
|
8768
8859
|
return new Worker("" + new URL("assets/video-capture-worker-mvwKyjOn.js", import.meta.url).href, {
|
|
8769
8860
|
type: "module",
|
|
8770
8861
|
name: e?.name
|
|
@@ -8773,16 +8864,16 @@ function Pv(e) {
|
|
|
8773
8864
|
//#endregion
|
|
8774
8865
|
//#region src/media/ikon-video-capture.ts
|
|
8775
8866
|
var $ = w("IkonVideoCapture");
|
|
8776
|
-
function
|
|
8867
|
+
function Vv() {
|
|
8777
8868
|
let e = globalThis.crypto;
|
|
8778
8869
|
return e?.randomUUID ? e.randomUUID() : `cap_${Date.now()}_${Math.floor(Math.random() * 1e9)}`;
|
|
8779
8870
|
}
|
|
8780
|
-
function
|
|
8871
|
+
function Hv() {
|
|
8781
8872
|
let e = globalThis.MediaStreamTrackProcessor;
|
|
8782
8873
|
if (!e) throw Error("MediaStreamTrackProcessor is not available in this browser");
|
|
8783
8874
|
return e;
|
|
8784
8875
|
}
|
|
8785
|
-
var
|
|
8876
|
+
var Uv = class {
|
|
8786
8877
|
client;
|
|
8787
8878
|
worker = null;
|
|
8788
8879
|
protocolPort = null;
|
|
@@ -8798,7 +8889,7 @@ var Lv = class {
|
|
|
8798
8889
|
}
|
|
8799
8890
|
ensureWorker() {
|
|
8800
8891
|
if (this.worker) return this.worker;
|
|
8801
|
-
let e = new
|
|
8892
|
+
let e = new Bv();
|
|
8802
8893
|
return this.worker = e, e.addEventListener("message", (e) => {
|
|
8803
8894
|
let t = e.data;
|
|
8804
8895
|
if (t?.type === "error") {
|
|
@@ -8908,10 +8999,10 @@ var Lv = class {
|
|
|
8908
8999
|
if (this.client.isWebRtcCaptureAvailable && e.sourceType === "camera") return this.startCameraWebRtc(e);
|
|
8909
9000
|
if (this.client.isWebRtcCaptureAvailable && e.sourceType === "screen") return this.startScreenWebRtc(e);
|
|
8910
9001
|
this.client.isWebRtcEnabled && $.warn("WebRTC unavailable, capturing video via protocol channel"), this.ensurePorts();
|
|
8911
|
-
let n =
|
|
9002
|
+
let n = Vv(), r = await this.getMediaStream(e), i = r.getVideoTracks()[0];
|
|
8912
9003
|
if (!i) throw r.getTracks().forEach((e) => e.stop()), Error("No video track available");
|
|
8913
9004
|
e.sourceType === "screen" && await new Promise((e) => setTimeout(e, 200));
|
|
8914
|
-
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 (
|
|
9005
|
+
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 (Hv())({ track: i }).readable, l = this.allocateTrackId(), u = this.ensureWorker(), d = e.sourceType, f = e.onStopped;
|
|
8915
9006
|
u.postMessage({
|
|
8916
9007
|
type: "start",
|
|
8917
9008
|
captureId: n,
|
|
@@ -9034,16 +9125,16 @@ var Lv = class {
|
|
|
9034
9125
|
}
|
|
9035
9126
|
this.protocolPort?.close(), this.protocolPort = null, this.sendPort?.close(), this.sendPort = null;
|
|
9036
9127
|
}
|
|
9037
|
-
},
|
|
9128
|
+
}, Wv = /* @__PURE__ */ d({ IkonMediaCapture: () => Gv }), Gv = class {
|
|
9038
9129
|
audio;
|
|
9039
9130
|
video;
|
|
9040
9131
|
image;
|
|
9041
9132
|
constructor(e, t) {
|
|
9042
|
-
this.audio = new
|
|
9133
|
+
this.audio = new Nv(e, t?.audio), this.video = new Uv(e), this.image = new Lv();
|
|
9043
9134
|
}
|
|
9044
9135
|
dispose() {
|
|
9045
9136
|
this.audio.dispose(), this.video.dispose();
|
|
9046
9137
|
}
|
|
9047
9138
|
};
|
|
9048
9139
|
//#endregion
|
|
9049
|
-
export {
|
|
9140
|
+
export { ou as AccessDeniedError, dv as AppMessaging, iu as AppStartupFailedError, k as AuthRejectedError, D as AuthenticationError, du as BrowserNotSupportedError, R as CONNECT_TIER_LADDER, bd as Channel, Sd as ChannelManager, v as ClientType, E as ConnectionError, m as ContextType, su as CredentialRejectedError, gf as EndpointSelector, x as EntrypointType, Wg as FunctionCallError, Yg as FunctionRegistry, Pf as IKON_AUTH_BASE_URL, Nf as IKON_AUTH_URL_DEV, Mf as IKON_AUTH_URL_PROD, jf as IKON_BACKEND_URL_DEV, Af as IKON_BACKEND_URL_PROD, H_ as IKON_INSPECT_MODE_CHANGED_EVENT, Cu as IKON_PARAM_AUDIO, gu as IKON_PARAM_CONNECT, yu as IKON_PARAM_DEBUG, bu as IKON_PARAM_DEBUG_OVERLAY, Eu as IKON_PARAM_ICE_TRANSPORT, xu as IKON_PARAM_INSPECT, Su as IKON_PARAM_LANG, ju as IKON_PARAM_OAUTH_CODE, Nu as IKON_PARAM_OAUTH_PKCE, Mu as IKON_PARAM_OAUTH_PROVIDER, Au as IKON_PARAM_OAUTH_TOKEN, mu as IKON_PARAM_PROXY, Du as IKON_PARAM_RETRY, vu as IKON_PARAM_SAME_ORIGIN, _u as IKON_PARAM_SESSION, ku as IKON_PARAM_SIGNED_OUT, Ou as IKON_PARAM_SNAPSHOT, hu as IKON_PARAM_TRANSPORT, wu as IKON_PARAM_VIDEO, Tu as IKON_PARAM_WEBRTC, Nv as IkonAudioCapture, re as IkonAudioPlayback, lv as IkonClient, Lv as IkonImageCapture, ue as IkonMedia, Gv as IkonMediaCapture, Uv as IkonVideoCapture, ce as IkonVideoPlayback, tu as KeepaliveTimeoutError, C as LogLevel, nu as MaxRetriesExceededError, fu as NoMatchingEndpointTypeError, T as Opcode, ru as ProvisioningTimeoutError, lu as ServerFullError, uu as ServerUnavailableError, cu as SessionNotFoundError, au as SpaceNotFoundError, O as TransportError, p as UserType, L_ as VisemeTracker, Ed as WEBRTC_AUDIO_BITRATE, Td as WEBRTC_AUDIO_CHANNELS, Cd as WEBRTC_AUDIO_CODEC, Dd as WEBRTC_AUDIO_JITTER_BUFFER_TARGET_MS, wd as WEBRTC_AUDIO_SAMPLE_RATE, Md as WEBRTC_BUNDLE_POLICY, Rd as WEBRTC_DATA_CHANNEL_LABEL, Bd as WEBRTC_DATA_CHANNEL_MAX_RETRANSMITS, zd as WEBRTC_DATA_CHANNEL_ORDERED, Id as WEBRTC_MAX_AUDIO_TRACKS, Ld as WEBRTC_MAX_VIDEO_TRACKS, Nd as WEBRTC_RTCP_MUX_POLICY, Od as WEBRTC_VIDEO_CODEC, kd as WEBRTC_VIDEO_MAX_BITRATE, Ad as WEBRTC_VIDEO_MAX_FRAMERATE, Vd as WebRTCConnection, Hd as WebRTCSignaling, kf as abortSignalAny, B as abortSignalTimeout, Tp as adoptPkceVerifierFromUrl, fv as appMessaging, y as asProtocolMessage, $_ as checkBrowserSupport, $h as clearDeviceId, mh as clearLogBuffer, Cf as clearLoginPrompt, xv as consumeLoginHandoff, Ef as consumeLoginPendingCall, w as createLogger, up as createPkceChallenge, Yf as deriveAuthUrl, qf as deriveBackendType, Kf as deriveBackendUrl, Xf as deriveCrossOriginAuthUrl, q_ as enableInspectMode, eg as extractUserIdFromToken, ph as flushLogs, Uu as getAudioParam, dh as getBufferedLogs, Hu as getConnectParam, Gh as getConnectTraceId, Ju as getDebugOverlayParam, Bu as getDebugParam, Ku as getIceTransportPolicyParam, qu as getInspectParam, Vu as getLangParam, hh as getLogBufferSize, Se as getLogLevel, be as getLogSink, xf as getLoginPromptState, vv as getOpcodeName, Qh as getOrCreateDeviceId, Iu as getProxyTierParam, M as getRetryParam, Hf as getSameOriginAuthUrl, Yu as getSameOriginParam, Zu as getSessionParam, Qu as getSignedOutParam, Xu as getSnapshotParam, zu as getTransportParam, ap as getUrlWithoutSession, Wu as getVideoParam, Gu as getWebRtcParam, z_ as initializeDebugMode, G_ as initializeInspectMode, lh as initializeLogSink, we as isAudioWorkletSupported, nh as isBrowserEnvironment, np as isCloudEnvironment, mv as isConnected, pv as isConnecting, B_ as isDebugModeEnabled, bp as isEmbedded, gv as isError, K_ as isInspectModeEnabled, a_ as isMobileBrowserLikely, hv as isOffline, lp as isPkceSupported, xe as isSharedArrayBufferSupported, _d as isWebTransportSupported, i_ as loginErrorInterceptor, wp as onEmbeddedOAuthResult, tf as orderConnectTiers, tp as parseUrlParams, Xh as randomUuid, c as readOpcode, u as readOpcodeGroup, i as readProtocolMessageHeaders, th as registerBrowserFunctions, Yh as reportConnectTimeline, bv as reprovisionAfterLogin, dp as restorePkceVerifier, ve as setLogLevel, _e as setLogSink, Sf as setLoginPromptRequired, Fu as setSdkUrlParam, uh as setSendLogsCallback, Sp as startEmbeddedOAuthSignIn, Ih as startLogSender, zh as stopLogSender, wf as subscribeLoginPrompt, he as subscribeToLogEvents, fh as takeBufferedLogs, fp as takePkceVerifier, Ug as withResultData };
|