@ikonai/sdk 1.0.50 → 1.0.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/{protocol-worker-Df0FycOk.js → protocol-worker-BXw02zNx.js} +119 -111
- package/index.js +1397 -1388
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ function F(t) {
|
|
|
7
7
|
return Q(t) & 4294901760;
|
|
8
8
|
}
|
|
9
9
|
function H(t) {
|
|
10
|
-
const e =
|
|
10
|
+
const e = ut(t), s = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
11
11
|
if (e.length < 27)
|
|
12
12
|
throw new Error("Protocol payload too short");
|
|
13
13
|
const r = s.getUint32(0, !0), n = s.getUint32(4, !0), i = s.getUint32(8, !0), a = s.getUint32(12, !0), o = s.getUint32(16, !0), l = s.getUint32(20, !0), I = s.getUint8(24), E = s.getUint8(25), h = s.getUint8(26);
|
|
@@ -29,7 +29,7 @@ function H(t) {
|
|
|
29
29
|
flags: h
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function Et(t, e, s, r, n) {
|
|
33
33
|
const l = [], E = 27 + l.length * 4, h = E + e.length, T = new Uint8Array(h), c = new DataView(T.buffer);
|
|
34
34
|
c.setUint32(0, h, !0), c.setUint32(4, t >>> 0, !0), c.setUint32(8, r >>> 0, !0), c.setUint32(12, 0, !0), c.setUint32(16, 0, !0), c.setUint32(20, l.length >>> 0, !0), c.setUint8(24, s & 255), c.setUint8(25, 8), c.setUint8(26, 0);
|
|
35
35
|
let w = 27;
|
|
@@ -38,11 +38,11 @@ function lt(t, e, s, r, n) {
|
|
|
38
38
|
return T.set(e, E), T;
|
|
39
39
|
}
|
|
40
40
|
var D = /* @__PURE__ */ ((t) => (t[t.Null = 1] = "Null", t[t.Bool = 2] = "Bool", t[t.Int32 = 3] = "Int32", t[t.Int64 = 4] = "Int64", t[t.UInt32 = 5] = "UInt32", t[t.UInt64 = 6] = "UInt64", t[t.Float32 = 7] = "Float32", t[t.Float64 = 8] = "Float64", t[t.Array = 9] = "Array", t[t.Dict = 10] = "Dict", t[t.Object = 11] = "Object", t[t.String = 12] = "String", t[t.Binary = 13] = "Binary", t[t.Guid = 14] = "Guid", t))(D || {});
|
|
41
|
-
const
|
|
41
|
+
const ht = 161, _t = 162, W = new TextEncoder();
|
|
42
42
|
new TextDecoder("utf-8", { fatal: !0 });
|
|
43
43
|
class G {
|
|
44
44
|
constructor(e = 1) {
|
|
45
|
-
this.version = e, this.buffer.writeByte(
|
|
45
|
+
this.version = e, this.buffer.writeByte(ht), this.buffer.writeVarUInt(e >>> 0);
|
|
46
46
|
}
|
|
47
47
|
buffer = new O();
|
|
48
48
|
closed = !1;
|
|
@@ -100,7 +100,7 @@ class G {
|
|
|
100
100
|
this.writeVariableField(e, 10, a);
|
|
101
101
|
}
|
|
102
102
|
finish() {
|
|
103
|
-
return this.closed || (this.buffer.writeByte(
|
|
103
|
+
return this.closed || (this.buffer.writeByte(_t), this.closed = !0, this.cached = this.buffer.toUint8Array()), this.cached;
|
|
104
104
|
}
|
|
105
105
|
writeFixedField(e, s, r) {
|
|
106
106
|
this.writeFieldHeader(e, s, 0), r();
|
|
@@ -109,7 +109,7 @@ class G {
|
|
|
109
109
|
this.writeFieldHeader(e, s, r.length), this.buffer.writeBytes(r);
|
|
110
110
|
}
|
|
111
111
|
writeFieldHeader(e, s, r) {
|
|
112
|
-
this.buffer.writeUInt32(e >>> 0), this.buffer.writeByte(K(s)),
|
|
112
|
+
this.buffer.writeUInt32(e >>> 0), this.buffer.writeByte(K(s)), ct(s) && this.buffer.writeVarUInt(r >>> 0);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
class Y {
|
|
@@ -225,7 +225,7 @@ class Y {
|
|
|
225
225
|
}
|
|
226
226
|
class z {
|
|
227
227
|
constructor(e, s) {
|
|
228
|
-
this.keyType = e, this.valueType = s,
|
|
228
|
+
this.keyType = e, this.valueType = s, It(e);
|
|
229
229
|
}
|
|
230
230
|
payload = new O();
|
|
231
231
|
count = 0;
|
|
@@ -233,7 +233,7 @@ class z {
|
|
|
233
233
|
beginEntry() {
|
|
234
234
|
if (this.entryOpen)
|
|
235
235
|
throw new Error("Previous dictionary entry not completed");
|
|
236
|
-
return this.count++, this.entryOpen = !0, new
|
|
236
|
+
return this.count++, this.entryOpen = !0, new Tt(this.keyType, this.valueType, this.payload, () => {
|
|
237
237
|
this.entryOpen = !1;
|
|
238
238
|
});
|
|
239
239
|
}
|
|
@@ -244,7 +244,7 @@ class z {
|
|
|
244
244
|
return e.writeByte(K(this.keyType)), e.writeByte(K(this.valueType)), e.writeVarUInt(this.count), e.writeBytes(this.payload.toUint8Array()), e.toUint8Array();
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
-
class
|
|
247
|
+
class Tt {
|
|
248
248
|
constructor(e, s, r, n) {
|
|
249
249
|
this.keyType = e, this.valueType = s, this.payload = r, this.onComplete = n;
|
|
250
250
|
}
|
|
@@ -562,17 +562,17 @@ function K(t, e = 0) {
|
|
|
562
562
|
throw new Error("Teleport flags must fit into 4 bits");
|
|
563
563
|
return (t & 15) << 4 | e & 15;
|
|
564
564
|
}
|
|
565
|
-
function
|
|
565
|
+
function ct(t) {
|
|
566
566
|
return t === 12 || t === 13 || t === 9 || t === 11 || t === 10;
|
|
567
567
|
}
|
|
568
|
-
function
|
|
568
|
+
function It(t) {
|
|
569
569
|
if (t === 9 || t === 11 || t === 10 || t === 1)
|
|
570
570
|
throw new Error("Dictionary keys must be primitive Teleport types");
|
|
571
571
|
}
|
|
572
572
|
function J(t) {
|
|
573
573
|
return Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
574
574
|
}
|
|
575
|
-
function
|
|
575
|
+
function ut(t) {
|
|
576
576
|
return t instanceof Uint8Array ? t : new Uint8Array(t);
|
|
577
577
|
}
|
|
578
578
|
var N = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.WebSocket = 1] = "WebSocket", t[t.WebSocketProxy = 2] = "WebSocketProxy", t[t.WebTransport = 4] = "WebTransport", t[t.WebTransportProxy = 8] = "WebTransportProxy", t[t.Tcp = 16] = "Tcp", t[t.TcpProxy = 32] = "TcpProxy", t[t.Https = 64] = "Https", t[t.WebRTC = 128] = "WebRTC", t[t.TcpTls = 256] = "TcpTls", t[t.Udp = 512] = "Udp", t[t.UdpDtls = 1024] = "UdpDtls", t))(N || {}), V = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.CONSTANT_GROUP_BITS = 15] = "CONSTANT_GROUP_BITS", t[t.CONSTANT_GROUP_OFFSET = 16] = "CONSTANT_GROUP_OFFSET", t[t.GROUP_CORE = 65536] = "GROUP_CORE", t[t.CORE_AUTH_RESPONSE = 65537] = "CORE_AUTH_RESPONSE", t[t.CORE_AUTH_TICKET = 65538] = "CORE_AUTH_TICKET", t[t.CORE_GLOBAL_STATE = 65539] = "CORE_GLOBAL_STATE", t[t.CORE_ON_SERVER_STATUS_PING = 65540] = "CORE_ON_SERVER_STATUS_PING", t[t.CORE_ON_USER_JOINED = 65541] = "CORE_ON_USER_JOINED", t[t.CORE_ON_USER_LEFT = 65542] = "CORE_ON_USER_LEFT", t[t.CORE_ON_CLIENT_JOINED = 65543] = "CORE_ON_CLIENT_JOINED", t[t.CORE_ON_CLIENT_LEFT = 65544] = "CORE_ON_CLIENT_LEFT", t[t.CORE_ON_SERVER_STARTED = 65545] = "CORE_ON_SERVER_STARTED", t[t.CORE_ON_SERVER_STOPPED = 65546] = "CORE_ON_SERVER_STOPPED", t[t.CORE_ON_SERVER_STOPPING = 65547] = "CORE_ON_SERVER_STOPPING", t[t.CORE_ON_CLIENT_READY = 65548] = "CORE_ON_CLIENT_READY", t[t.CORE_CLIENT_READY = 65549] = "CORE_CLIENT_READY", t[t.CORE_SERVER_INIT = 65550] = "CORE_SERVER_INIT", t[t.CORE_ON_PLUGIN_RELOADED = 65551] = "CORE_ON_PLUGIN_RELOADED", t[t.CORE_SERVER_START = 65552] = "CORE_SERVER_START", t[t.CORE_SERVER_STOP = 65553] = "CORE_SERVER_STOP", t[t.CORE_ON_HOSTED_SERVER_EXIT = 65554] = "CORE_ON_HOSTED_SERVER_EXIT", t[t.CORE_DYNAMIC_CONFIG = 65555] = "CORE_DYNAMIC_CONFIG", t[t.CORE_PROXY_RPC_AUTH_TICKET = 65556] = "CORE_PROXY_RPC_AUTH_TICKET", t[t.CORE_SERVER_INIT2 = 65557] = "CORE_SERVER_INIT2", t[t.CORE_UPDATE_CLIENT_CONTEXT = 65558] = "CORE_UPDATE_CLIENT_CONTEXT", t[t.CORE_BACKGROUND_WORK_ACTIVE = 65559] = "CORE_BACKGROUND_WORK_ACTIVE", t[t.CORE_WEBRTC_OFFER = 65566] = "CORE_WEBRTC_OFFER", t[t.CORE_WEBRTC_ANSWER = 65567] = "CORE_WEBRTC_ANSWER", t[t.CORE_WEBRTC_ICE_CANDIDATE = 65568] = "CORE_WEBRTC_ICE_CANDIDATE", t[t.CORE_WEBRTC_READY = 65569] = "CORE_WEBRTC_READY", t[t.CORE_WEBRTC_AUDIO_SEGMENT = 65570] = "CORE_WEBRTC_AUDIO_SEGMENT", t[t.CORE_WEBRTC_TRACK_MAP = 65571] = "CORE_WEBRTC_TRACK_MAP", t[t.CORE_WEBRTC_VIDEO_CAPTURE = 65572] = "CORE_WEBRTC_VIDEO_CAPTURE", t[t.CORE_RELAY_AGENT_AUTH = 65576] = "CORE_RELAY_AGENT_AUTH", t[t.CORE_RELAY_AGENT_AUTH_RESULT = 65577] = "CORE_RELAY_AGENT_AUTH_RESULT", t[t.CORE_RELAY_HEARTBEAT = 65578] = "CORE_RELAY_HEARTBEAT", t[t.CORE_RELAY_TCP_CONNECTION_OPENED = 65579] = "CORE_RELAY_TCP_CONNECTION_OPENED", t[t.CORE_RELAY_TCP_CONNECTION_CLOSED = 65580] = "CORE_RELAY_TCP_CONNECTION_CLOSED", t[t.CORE_RELAY_TCP_DATA = 65581] = "CORE_RELAY_TCP_DATA", t[t.CORE_RELAY_UDP_DATA = 65582] = "CORE_RELAY_UDP_DATA", t[t.CORE_RELAY_ADD_TUNNEL = 65583] = "CORE_RELAY_ADD_TUNNEL", t[t.CORE_RELAY_TUNNEL_ADDED = 65584] = "CORE_RELAY_TUNNEL_ADDED", t[t.CORE_RELAY_REMOVE_TUNNEL = 65585] = "CORE_RELAY_REMOVE_TUNNEL", t[t.GROUP_KEEPALIVE = 131072] = "GROUP_KEEPALIVE", t[t.KEEPALIVE_REQUEST = 131073] = "KEEPALIVE_REQUEST", t[t.KEEPALIVE_RESPONSE = 131074] = "KEEPALIVE_RESPONSE", t[t.GROUP_EVENTS = 262144] = "GROUP_EVENTS", t[t.EVENTS_PROFILE_UPDATE = 262145] = "EVENTS_PROFILE_UPDATE", t[t.EVENTS_CHANNEL_COMPLETE = 262146] = "EVENTS_CHANNEL_COMPLETE", t[t.EVENTS_SPEECH_PLAYBACK_COMPLETE = 262147] = "EVENTS_SPEECH_PLAYBACK_COMPLETE", t[t.GROUP_ANALYTICS = 524288] = "GROUP_ANALYTICS", t[t.ANALYTICS_LOGS = 524289] = "ANALYTICS_LOGS", t[t.ANALYTICS_EVENTS = 524290] = "ANALYTICS_EVENTS", t[t.ANALYTICS_USAGES = 524291] = "ANALYTICS_USAGES", t[t.ANALYTICS_USAGE = 524292] = "ANALYTICS_USAGE", t[t.ANALYTICS_SPECIAL_LOG = 524293] = "ANALYTICS_SPECIAL_LOG", t[t.ANALYTICS_PROCESSING_UPDATE = 524294] = "ANALYTICS_PROCESSING_UPDATE", t[t.ANALYTICS_REACTIVE_PROCESSING_UPDATE = 524295] = "ANALYTICS_REACTIVE_PROCESSING_UPDATE", t[t.ANALYTICS_IKON_PROXY_SERVER_STATS = 524296] = "ANALYTICS_IKON_PROXY_SERVER_STATS", t[t.ANALYTICS_IKON_RELAY_SERVER_STATS = 524297] = "ANALYTICS_IKON_RELAY_SERVER_STATS", t[t.ANALYTICS_IKON_TURN_SERVER_STATS = 524298] = "ANALYTICS_IKON_TURN_SERVER_STATS", t[t.GROUP_ACTIONS = 1048576] = "GROUP_ACTIONS", t[t.ACTION_CALL = 1048577] = "ACTION_CALL", t[t.ACTION_ACTIVE = 1048578] = "ACTION_ACTIVE", t[t.ACTION_TEXT_OUTPUT = 1048579] = "ACTION_TEXT_OUTPUT", t[t.ACTION_TEXT_OUTPUT_DELTA = 1048580] = "ACTION_TEXT_OUTPUT_DELTA", t[t.ACTION_TEXT_OUTPUT_DELTA_FULL = 1048581] = "ACTION_TEXT_OUTPUT_DELTA_FULL", t[t.ACTION_SET_STATE = 1048582] = "ACTION_SET_STATE", t[t.ACTION_TAP = 1048583] = "ACTION_TAP", t[t.ACTION_PAN = 1048584] = "ACTION_PAN", t[t.ACTION_ZOOM = 1048585] = "ACTION_ZOOM", t[t.ACTION_FILE_UPLOAD_BEGIN = 1048586] = "ACTION_FILE_UPLOAD_BEGIN", t[t.ACTION_FILE_UPLOAD_DATA = 1048587] = "ACTION_FILE_UPLOAD_DATA", t[t.ACTION_FILE_UPLOAD_ACK = 1048588] = "ACTION_FILE_UPLOAD_ACK", t[t.ACTION_FILE_UPLOAD_END = 1048589] = "ACTION_FILE_UPLOAD_END", t[t.ACTION_FILE_UPLOAD_RESULT = 1048590] = "ACTION_FILE_UPLOAD_RESULT", t[t.ACTION_OPEN_CHANNEL = 1048591] = "ACTION_OPEN_CHANNEL", t[t.ACTION_OPEN_EXTERNAL_URL = 1048592] = "ACTION_OPEN_EXTERNAL_URL", t[t.ACTION_UI_OPEN_VIEW = 1048593] = "ACTION_UI_OPEN_VIEW", t[t.ACTION_UI_CLOSE_VIEW = 1048594] = "ACTION_UI_CLOSE_VIEW", t[t.ACTION_UI_BLOCKING_BEGIN = 1048595] = "ACTION_UI_BLOCKING_BEGIN", t[t.ACTION_UI_BLOCKING_END = 1048596] = "ACTION_UI_BLOCKING_END", t[t.ACTION_UI_UPDATE_TEXT_DELTA = 1048597] = "ACTION_UI_UPDATE_TEXT_DELTA", t[t.ACTION_UI_DELETE_CONTAINER = 1048598] = "ACTION_UI_DELETE_CONTAINER", t[t.ACTION_UPDATE_GFX_SHADER = 1048599] = "ACTION_UPDATE_GFX_SHADER", t[t.ACTION_FUNCTION_REGISTER = 1048600] = "ACTION_FUNCTION_REGISTER", t[t.ACTION_FUNCTION_CALL = 1048601] = "ACTION_FUNCTION_CALL", t[t.ACTION_FUNCTION_RESULT = 1048602] = "ACTION_FUNCTION_RESULT", t[t.ACTION_GENERATE_ANSWER = 1048603] = "ACTION_GENERATE_ANSWER", t[t.ACTION_REGENERATE_ANSWER = 1048604] = "ACTION_REGENERATE_ANSWER", t[t.ACTION_CLEAR_CHAT_MESSAGE_HISTORY = 1048605] = "ACTION_CLEAR_CHAT_MESSAGE_HISTORY", t[t.ACTION_CLEAR_STATE = 1048606] = "ACTION_CLEAR_STATE", t[t.ACTION_RELOAD_CHANNELS = 1048607] = "ACTION_RELOAD_CHANNELS", t[t.ACTION_RELOAD_PROFILE = 1048608] = "ACTION_RELOAD_PROFILE", t[t.ACTION_CLASSIFICATION_RESULT = 1048609] = "ACTION_CLASSIFICATION_RESULT", t[t.ACTION_AUDIO_STOP = 1048610] = "ACTION_AUDIO_STOP", t[t.ACTION_CALL_TEXT = 1048611] = "ACTION_CALL_TEXT", t[t.ACTION_RELOAD_APPLICATION = 1048612] = "ACTION_RELOAD_APPLICATION", t[t.ACTION_CANCEL_GENERATION = 1048613] = "ACTION_CANCEL_GENERATION", t[t.ACTION_UI_SET_CONTAINER_STABLE = 1048614] = "ACTION_UI_SET_CONTAINER_STABLE", t[t.ACTION_SPEECH_RECOGNIZED = 1048615] = "ACTION_SPEECH_RECOGNIZED", t[t.ACTION_CALL_RESULT = 1048616] = "ACTION_CALL_RESULT", t[t.ACTION_RELOAD_PROVIDER = 1048617] = "ACTION_RELOAD_PROVIDER", t[t.ACTION_DOWNLOAD = 1048618] = "ACTION_DOWNLOAD", t[t.ACTION_SCROLL_TO_CONTAINER = 1048619] = "ACTION_SCROLL_TO_CONTAINER", t[t.ACTION_UI_CLEAR_STREAM = 1048620] = "ACTION_UI_CLEAR_STREAM", t[t.ACTION_PLAY_SOUND = 1048621] = "ACTION_PLAY_SOUND", t[t.ACTION_ENTER_FULLSCREEN = 1048622] = "ACTION_ENTER_FULLSCREEN", t[t.ACTION_STOP_SOUND = 1048623] = "ACTION_STOP_SOUND", t[t.ACTION_START_RECORDING = 1048624] = "ACTION_START_RECORDING", t[t.ACTION_STOP_RECORDING = 1048625] = "ACTION_STOP_RECORDING", t[t.ACTION_FUNCTION_ENUMERATION_ITEM = 1048627] = "ACTION_FUNCTION_ENUMERATION_ITEM", t[t.ACTION_FUNCTION_ENUMERATION_END = 1048628] = "ACTION_FUNCTION_ENUMERATION_END", t[t.ACTION_FUNCTION_CANCEL = 1048629] = "ACTION_FUNCTION_CANCEL", t[t.ACTION_FUNCTION_DISPOSE = 1048630] = "ACTION_FUNCTION_DISPOSE", t[t.ACTION_FUNCTION_ERROR = 1048631] = "ACTION_FUNCTION_ERROR", t[t.ACTION_FUNCTION_ACK = 1048632] = "ACTION_FUNCTION_ACK", t[t.ACTION_FUNCTION_AWAITING_APPROVAL = 1048633] = "ACTION_FUNCTION_AWAITING_APPROVAL", t[t.ACTION_FUNCTION_APPROVAL_REQUIRED = 1048634] = "ACTION_FUNCTION_APPROVAL_REQUIRED", t[t.ACTION_FUNCTION_APPROVAL_RESPONSE = 1048635] = "ACTION_FUNCTION_APPROVAL_RESPONSE", t[t.UI_UPDATE_ACK = 1048636] = "UI_UPDATE_ACK", t[t.ACTION_CALL2 = 1048637] = "ACTION_CALL2", t[t.ACTION_FUNCTION_REGISTER_BATCH = 1048638] = "ACTION_FUNCTION_REGISTER_BATCH", t[t.ACTION_TRIGGER_GIT_PULL = 1048639] = "ACTION_TRIGGER_GIT_PULL", t[t.ACTION_FILE_UPLOAD_CALLBACK = 1048640] = "ACTION_FILE_UPLOAD_CALLBACK", t[t.ACTION_CUSTOM_USER_MESSAGE = 1048641] = "ACTION_CUSTOM_USER_MESSAGE", t[t.ACTION_URL_CHANGED = 1048642] = "ACTION_URL_CHANGED", t[t.ACTION_FILE_UPLOAD_PRE_START2 = 1048643] = "ACTION_FILE_UPLOAD_PRE_START2", t[t.ACTION_FILE_UPLOAD_PRE_START_RESPONSE2 = 1048644] = "ACTION_FILE_UPLOAD_PRE_START_RESPONSE2", t[t.ACTION_FILE_UPLOAD_START2 = 1048645] = "ACTION_FILE_UPLOAD_START2", t[t.ACTION_FILE_UPLOAD_START_RESPONSE2 = 1048646] = "ACTION_FILE_UPLOAD_START_RESPONSE2", t[t.ACTION_FILE_UPLOAD_DATA2 = 1048647] = "ACTION_FILE_UPLOAD_DATA2", t[t.ACTION_FILE_UPLOAD_ACK2 = 1048648] = "ACTION_FILE_UPLOAD_ACK2", t[t.ACTION_FILE_UPLOAD_END2 = 1048649] = "ACTION_FILE_UPLOAD_END2", t[t.ACTION_FILE_UPLOAD_COMPLETE2 = 1048650] = "ACTION_FILE_UPLOAD_COMPLETE2", t[t.ACTION_FUNCTION_ENUMERATION_ITEM_BATCH = 1048651] = "ACTION_FUNCTION_ENUMERATION_ITEM_BATCH", t[t.ACTION_CALL_ACK = 1048652] = "ACTION_CALL_ACK", t[t.GROUP_UI = 2097152] = "GROUP_UI", t[t.UI_STREAM_BEGIN = 2097153] = "UI_STREAM_BEGIN", t[t.UI_STREAM_END = 2097154] = "UI_STREAM_END", t[t.UI_CONTAINER_BEGIN = 2097155] = "UI_CONTAINER_BEGIN", t[t.UI_CONTAINER_END = 2097156] = "UI_CONTAINER_END", t[t.UI_SECTION_BEGIN = 2097157] = "UI_SECTION_BEGIN", t[t.UI_SECTION_END = 2097158] = "UI_SECTION_END", t[t.UI_LIST_BEGIN = 2097159] = "UI_LIST_BEGIN", t[t.UI_LIST_ITEM = 2097160] = "UI_LIST_ITEM", t[t.UI_LIST_END = 2097161] = "UI_LIST_END", t[t.UI_TEXT = 2097162] = "UI_TEXT", t[t.UI_HEADER = 2097163] = "UI_HEADER", t[t.UI_SEPARATOR = 2097164] = "UI_SEPARATOR", t[t.UI_BUTTON = 2097165] = "UI_BUTTON", t[t.UI_ICON_BUTTON = 2097166] = "UI_ICON_BUTTON", t[t.UI_IMAGE = 2097167] = "UI_IMAGE", t[t.UI_FILE = 2097168] = "UI_FILE", t[t.UI_BADGE = 2097169] = "UI_BADGE", t[t.UI_CONTENT_LINK = 2097170] = "UI_CONTENT_LINK", t[t.UI_MAP = 2097171] = "UI_MAP", t[t.UI_VEGA_CHART = 2097172] = "UI_VEGA_CHART", t[t.UI_ICON = 2097173] = "UI_ICON", t[t.UI_FILE_UPLOAD_SECTION_BEGIN = 2097174] = "UI_FILE_UPLOAD_SECTION_BEGIN", t[t.UI_FILE_UPLOAD_SECTION_END = 2097175] = "UI_FILE_UPLOAD_SECTION_END", t[t.UI_MATERIAL_SYMBOL = 2097176] = "UI_MATERIAL_SYMBOL", t[t.UI_BUTTON_BEGIN = 2097177] = "UI_BUTTON_BEGIN", t[t.UI_BUTTON_END = 2097178] = "UI_BUTTON_END", t[t.UI_CONTAINER_DELETE = 2097179] = "UI_CONTAINER_DELETE", t[t.UI_INPUT_TEXT = 2097180] = "UI_INPUT_TEXT", t[t.UI_PROGRESS_BAR = 2097181] = "UI_PROGRESS_BAR", t[t.UI_UPDATE_BEGIN = 2097182] = "UI_UPDATE_BEGIN", t[t.UI_UPDATE_END = 2097183] = "UI_UPDATE_END", t[t.UI_AUTOCOMPLETE = 2097184] = "UI_AUTOCOMPLETE", t[t.UI_CHECKBOX = 2097185] = "UI_CHECKBOX", t[t.UI_QS = 2097186] = "UI_QS", t[t.UI_ELEMENT = 2097187] = "UI_ELEMENT", t[t.UI_STYLES = 2097188] = "UI_STYLES", t[t.UI_SVG = 2097189] = "UI_SVG", t[t.UI_UPDATE = 2097190] = "UI_UPDATE", t[t.UI_INIT = 2097191] = "UI_INIT", t[t.UI_STYLES_BATCH = 2097192] = "UI_STYLES_BATCH", t[t.UI_STYLES_DELETE = 2097193] = "UI_STYLES_DELETE", t[t.GROUP_COMMON = 4128768] = "GROUP_COMMON", t[t.GROUP_AUDIO = 4194304] = "GROUP_AUDIO", t[t.AUDIO_STREAM_BEGIN = 4194305] = "AUDIO_STREAM_BEGIN", t[t.AUDIO_STREAM_END = 4194306] = "AUDIO_STREAM_END", t[t.AUDIO_FRAME = 4194307] = "AUDIO_FRAME", t[t.AUDIO_FRAME_VOLUME = 4194308] = "AUDIO_FRAME_VOLUME", t[t.AUDIO_FRAME2 = 4194309] = "AUDIO_FRAME2", t[t.AUDIO_SHAPE_FRAME = 4194310] = "AUDIO_SHAPE_FRAME", t[t.GROUP_VIDEO = 8388608] = "GROUP_VIDEO", t[t.VIDEO_STREAM_BEGIN = 8388609] = "VIDEO_STREAM_BEGIN", t[t.VIDEO_STREAM_END = 8388610] = "VIDEO_STREAM_END", t[t.VIDEO_FRAME = 8388611] = "VIDEO_FRAME", t[t.VIDEO_REQUEST_IDR_FRAME = 8388612] = "VIDEO_REQUEST_IDR_FRAME", t[t.VIDEO_INVALIDATE_FRAME = 8388613] = "VIDEO_INVALIDATE_FRAME", t[t.GROUP_TRACKING = 16777216] = "GROUP_TRACKING", t[t.TRACKING_STREAM_BEGIN = 16777217] = "TRACKING_STREAM_BEGIN", t[t.TRACKING_STREAM_END = 16777218] = "TRACKING_STREAM_END", t[t.TRACKING_FRAME = 16777219] = "TRACKING_FRAME", t[t.GROUP_SCENE = 33554432] = "GROUP_SCENE", t[t.SCENE_MESH = 33554433] = "SCENE_MESH", t[t.SCENE_ARRAY = 33554434] = "SCENE_ARRAY", t[t.GROUP_ALL = 67043328] = "GROUP_ALL", t[t.GROUP_APP_LOCAL = 1073741824] = "GROUP_APP_LOCAL", t[t.CONSTANT_GROUP_MASK = 2147418112] = "CONSTANT_GROUP_MASK", t))(V || {});
|
|
@@ -580,24 +580,24 @@ const et = 1, At = 131074;
|
|
|
580
580
|
function st(t) {
|
|
581
581
|
return {};
|
|
582
582
|
}
|
|
583
|
-
function
|
|
583
|
+
function ft(t) {
|
|
584
584
|
return new G(et).finish();
|
|
585
585
|
}
|
|
586
586
|
function rt(t, e, s) {
|
|
587
|
-
const r =
|
|
588
|
-
return
|
|
587
|
+
const r = ft();
|
|
588
|
+
return Et(At, r, et, e);
|
|
589
589
|
}
|
|
590
590
|
class nt extends Error {
|
|
591
591
|
constructor(e, s) {
|
|
592
592
|
super(e), this.cause = s, this.name = "ConnectionError";
|
|
593
593
|
}
|
|
594
594
|
}
|
|
595
|
-
class
|
|
595
|
+
class U extends nt {
|
|
596
596
|
constructor(e, s) {
|
|
597
597
|
super(e, s), this.name = "TransportError";
|
|
598
598
|
}
|
|
599
599
|
}
|
|
600
|
-
class q extends
|
|
600
|
+
class q extends U {
|
|
601
601
|
constructor(e) {
|
|
602
602
|
super(`No keepalive received within ${e}ms`), this.name = "KeepaliveTimeoutError";
|
|
603
603
|
}
|
|
@@ -607,7 +607,7 @@ class Z extends nt {
|
|
|
607
607
|
super(`Maximum reconnection attempts (${e}) exceeded`), this.name = "MaxRetriesExceededError";
|
|
608
608
|
}
|
|
609
609
|
}
|
|
610
|
-
function
|
|
610
|
+
function Ct(t, e) {
|
|
611
611
|
return new Promise((s, r) => {
|
|
612
612
|
const n = () => {
|
|
613
613
|
clearTimeout(i), r(new DOMException("Aborted", "AbortError"));
|
|
@@ -621,8 +621,12 @@ function ft(t, e) {
|
|
|
621
621
|
e?.addEventListener("abort", n, { once: !0 });
|
|
622
622
|
});
|
|
623
623
|
}
|
|
624
|
-
let
|
|
625
|
-
const Nt = /* @__PURE__ */ new Map()
|
|
624
|
+
let it = 1;
|
|
625
|
+
const Nt = /* @__PURE__ */ new Map();
|
|
626
|
+
function Rt(t) {
|
|
627
|
+
it = t;
|
|
628
|
+
}
|
|
629
|
+
const yt = {
|
|
626
630
|
0: "DEBUG",
|
|
627
631
|
1: "INFO",
|
|
628
632
|
2: "WARN",
|
|
@@ -633,7 +637,7 @@ function Ut(t, e) {
|
|
|
633
637
|
return `[${t}] ${e}`;
|
|
634
638
|
}
|
|
635
639
|
function k(t, e, s, r) {
|
|
636
|
-
const n = (/* @__PURE__ */ new Date()).toISOString(), i =
|
|
640
|
+
const n = (/* @__PURE__ */ new Date()).toISOString(), i = yt[t], a = {
|
|
637
641
|
timestamp: n,
|
|
638
642
|
level: t,
|
|
639
643
|
levelName: i,
|
|
@@ -649,7 +653,7 @@ function k(t, e, s, r) {
|
|
|
649
653
|
} catch {
|
|
650
654
|
}
|
|
651
655
|
}
|
|
652
|
-
if (
|
|
656
|
+
if (it <= t) {
|
|
653
657
|
const o = Ut(e, s);
|
|
654
658
|
switch (t) {
|
|
655
659
|
case 0:
|
|
@@ -683,8 +687,8 @@ function p(t) {
|
|
|
683
687
|
}
|
|
684
688
|
};
|
|
685
689
|
}
|
|
686
|
-
const
|
|
687
|
-
function
|
|
690
|
+
const St = "ikon-retry";
|
|
691
|
+
function wt(t, e) {
|
|
688
692
|
if (typeof window > "u")
|
|
689
693
|
return null;
|
|
690
694
|
const s = new URLSearchParams(window.location.search), r = s.get(t);
|
|
@@ -693,15 +697,15 @@ function St(t, e) {
|
|
|
693
697
|
const n = s.get(t.replace(/-/g, "_"));
|
|
694
698
|
return n !== null ? n : null;
|
|
695
699
|
}
|
|
696
|
-
function
|
|
697
|
-
const s =
|
|
700
|
+
function gt(t, e) {
|
|
701
|
+
const s = wt(t);
|
|
698
702
|
return s === "true" ? !0 : s === "false" ? !1 : null;
|
|
699
703
|
}
|
|
700
|
-
function
|
|
701
|
-
return
|
|
704
|
+
function Lt() {
|
|
705
|
+
return gt(St) !== !1;
|
|
702
706
|
}
|
|
703
|
-
const M = p("WebSocketTransport"),
|
|
704
|
-
class
|
|
707
|
+
const M = p("WebSocketTransport"), Pt = 1e4;
|
|
708
|
+
class mt {
|
|
705
709
|
ws = null;
|
|
706
710
|
keepaliveTimeout = null;
|
|
707
711
|
isClosed = !1;
|
|
@@ -715,7 +719,7 @@ class Pt {
|
|
|
715
719
|
callbacks;
|
|
716
720
|
sessionId;
|
|
717
721
|
constructor(e) {
|
|
718
|
-
this.callbacks = e.callbacks, this.sessionId = e.sessionId, this.keepaliveTimeoutMs = e.keepaliveTimeoutMs, this.connectionTimeoutMs = e.connectionTimeoutMs ??
|
|
722
|
+
this.callbacks = e.callbacks, this.sessionId = e.sessionId, this.keepaliveTimeoutMs = e.keepaliveTimeoutMs, this.connectionTimeoutMs = e.connectionTimeoutMs ?? Pt;
|
|
719
723
|
}
|
|
720
724
|
get isConnected() {
|
|
721
725
|
return this.ws?.readyState === WebSocket.OPEN;
|
|
@@ -727,7 +731,7 @@ class Pt {
|
|
|
727
731
|
try {
|
|
728
732
|
this.ws = new WebSocket(e), this.ws.binaryType = "arraybuffer";
|
|
729
733
|
} catch (T) {
|
|
730
|
-
i(new
|
|
734
|
+
i(new U(`Failed to create WebSocket: ${T}`, T instanceof Error ? T : void 0));
|
|
731
735
|
return;
|
|
732
736
|
}
|
|
733
737
|
let a = !1, o = !1;
|
|
@@ -740,16 +744,16 @@ class Pt {
|
|
|
740
744
|
};
|
|
741
745
|
this.firstMessageResolver = I;
|
|
742
746
|
const h = setTimeout(() => {
|
|
743
|
-
this.ws?.close(), M.warn(`WebSocket connection timeout after ${this.connectionTimeoutMs}ms`), E(new
|
|
747
|
+
this.ws?.close(), M.warn(`WebSocket connection timeout after ${this.connectionTimeoutMs}ms`), E(new U("WebSocket connection timeout"));
|
|
744
748
|
}, this.connectionTimeoutMs);
|
|
745
749
|
this.ws.onopen = () => {
|
|
746
750
|
a = !0, this.ws.send(s), this.resetKeepaliveTimeout();
|
|
747
751
|
}, this.ws.onerror = () => {
|
|
748
|
-
M.debug(`WebSocket connection failed after ${Date.now() - r}ms`), E(new
|
|
752
|
+
M.debug(`WebSocket connection failed after ${Date.now() - r}ms`), E(new U("WebSocket connection failed"));
|
|
749
753
|
}, this.ws.onclose = (T) => {
|
|
750
754
|
if (this.clearKeepaliveTimeout(), !o) {
|
|
751
755
|
const g = a ? "WebSocket closed before first server message" : "WebSocket connection closed before opening";
|
|
752
|
-
E(new
|
|
756
|
+
E(new U(g));
|
|
753
757
|
return;
|
|
754
758
|
}
|
|
755
759
|
if (this.isClosed)
|
|
@@ -794,11 +798,11 @@ class Pt {
|
|
|
794
798
|
this.keepaliveTimeout && (clearTimeout(this.keepaliveTimeout), this.keepaliveTimeout = null);
|
|
795
799
|
}
|
|
796
800
|
}
|
|
797
|
-
const S = p("WebTransportTransport"),
|
|
798
|
-
function
|
|
801
|
+
const S = p("WebTransportTransport"), Dt = 1e4, tt = 4, Ot = 65536;
|
|
802
|
+
function at() {
|
|
799
803
|
return typeof WebTransport < "u";
|
|
800
804
|
}
|
|
801
|
-
class
|
|
805
|
+
class Mt {
|
|
802
806
|
transport = null;
|
|
803
807
|
stream = null;
|
|
804
808
|
reader = null;
|
|
@@ -807,7 +811,7 @@ class Ot {
|
|
|
807
811
|
readLoopActive = !1;
|
|
808
812
|
isClosed = !1;
|
|
809
813
|
// Grow-only receive buffer with offset/length tracking to minimize allocations
|
|
810
|
-
receiveBuffer = new Uint8Array(
|
|
814
|
+
receiveBuffer = new Uint8Array(Ot);
|
|
811
815
|
receiveBufferOffset = 0;
|
|
812
816
|
receiveBufferLength = 0;
|
|
813
817
|
// Cached DataView to avoid allocation per message
|
|
@@ -824,14 +828,14 @@ class Ot {
|
|
|
824
828
|
callbacks;
|
|
825
829
|
sessionId;
|
|
826
830
|
constructor(e) {
|
|
827
|
-
this.callbacks = e.callbacks, this.sessionId = e.sessionId, this.keepaliveTimeoutMs = e.keepaliveTimeoutMs, this.connectionTimeoutMs = e.connectionTimeoutMs ??
|
|
831
|
+
this.callbacks = e.callbacks, this.sessionId = e.sessionId, this.keepaliveTimeoutMs = e.keepaliveTimeoutMs, this.connectionTimeoutMs = e.connectionTimeoutMs ?? Dt;
|
|
828
832
|
}
|
|
829
833
|
get isConnected() {
|
|
830
834
|
return this.transport !== null && this.writer !== null;
|
|
831
835
|
}
|
|
832
836
|
async connect(e, s) {
|
|
833
|
-
if (!
|
|
834
|
-
throw new
|
|
837
|
+
if (!at())
|
|
838
|
+
throw new U("WebTransport is not supported in this browser");
|
|
835
839
|
this.isClosed = !1;
|
|
836
840
|
const r = Date.now(), n = new Promise((i, a) => {
|
|
837
841
|
this.firstMessageResolver = i, this.firstMessageRejecter = a;
|
|
@@ -841,14 +845,14 @@ class Ot {
|
|
|
841
845
|
let i;
|
|
842
846
|
const a = new Promise((E, h) => {
|
|
843
847
|
i = setTimeout(
|
|
844
|
-
() => h(new
|
|
848
|
+
() => h(new U("WebTransport connection timeout")),
|
|
845
849
|
this.connectionTimeoutMs
|
|
846
850
|
);
|
|
847
851
|
});
|
|
848
852
|
try {
|
|
849
853
|
await Promise.race([this.transport.ready, a]);
|
|
850
854
|
} catch (E) {
|
|
851
|
-
throw E instanceof
|
|
855
|
+
throw E instanceof U && S.warn(`WebTransport connection timeout after ${this.connectionTimeoutMs}ms`), E;
|
|
852
856
|
} finally {
|
|
853
857
|
clearTimeout(i);
|
|
854
858
|
}
|
|
@@ -861,7 +865,7 @@ class Ot {
|
|
|
861
865
|
let l;
|
|
862
866
|
const I = new Promise((E, h) => {
|
|
863
867
|
l = setTimeout(
|
|
864
|
-
() => h(new
|
|
868
|
+
() => h(new U("WebTransport closed before first server message")),
|
|
865
869
|
o
|
|
866
870
|
);
|
|
867
871
|
});
|
|
@@ -874,7 +878,7 @@ class Ot {
|
|
|
874
878
|
} catch (i) {
|
|
875
879
|
this.firstMessageResolver = null, this.firstMessageRejecter = null, this.cleanup();
|
|
876
880
|
const a = Date.now() - r;
|
|
877
|
-
throw S.warn(`WebTransport connection failed after ${a}ms: ${i}`), new
|
|
881
|
+
throw S.warn(`WebTransport connection failed after ${a}ms: ${i}`), new U(`Failed to connect WebTransport: ${i}`, i instanceof Error ? i : void 0);
|
|
878
882
|
}
|
|
879
883
|
}
|
|
880
884
|
send(e) {
|
|
@@ -976,7 +980,7 @@ class Ot {
|
|
|
976
980
|
handleClose(e, s) {
|
|
977
981
|
if (!this.isClosed) {
|
|
978
982
|
if (this.isClosed = !0, this.clearKeepaliveTimeout(), this.readLoopActive = !1, this.cleanup(), this.firstMessageRejecter) {
|
|
979
|
-
this.firstMessageRejecter(new
|
|
983
|
+
this.firstMessageRejecter(new U(`WebTransport closed before first server message: ${e}`)), this.firstMessageResolver = null, this.firstMessageRejecter = null;
|
|
980
984
|
return;
|
|
981
985
|
}
|
|
982
986
|
this.callbacks.onClose(e, s);
|
|
@@ -1010,7 +1014,7 @@ class Ot {
|
|
|
1010
1014
|
}
|
|
1011
1015
|
}
|
|
1012
1016
|
const x = p("Channel");
|
|
1013
|
-
class
|
|
1017
|
+
class bt {
|
|
1014
1018
|
state = "disconnected";
|
|
1015
1019
|
transport = null;
|
|
1016
1020
|
config;
|
|
@@ -1104,13 +1108,13 @@ class Mt {
|
|
|
1104
1108
|
switch (e.Type) {
|
|
1105
1109
|
case N.WebSocket:
|
|
1106
1110
|
case N.WebSocketProxy:
|
|
1107
|
-
this.transport = new
|
|
1111
|
+
this.transport = new mt(s);
|
|
1108
1112
|
break;
|
|
1109
1113
|
case N.WebTransport:
|
|
1110
1114
|
case N.WebTransportProxy:
|
|
1111
|
-
if (!
|
|
1115
|
+
if (!at())
|
|
1112
1116
|
throw new Error("WebTransport is not supported in this browser");
|
|
1113
|
-
this.transport = new
|
|
1117
|
+
this.transport = new Mt(s);
|
|
1114
1118
|
break;
|
|
1115
1119
|
default:
|
|
1116
1120
|
throw new Error(`Unsupported entrypoint type: ${N[e.Type]}`);
|
|
@@ -1151,8 +1155,8 @@ class Mt {
|
|
|
1151
1155
|
this.state !== e && (this.state = e, this.config.onStateChange?.(e));
|
|
1152
1156
|
}
|
|
1153
1157
|
}
|
|
1154
|
-
const
|
|
1155
|
-
class
|
|
1158
|
+
const u = p("ChannelManager"), vt = 5e3;
|
|
1159
|
+
class dt {
|
|
1156
1160
|
channels = /* @__PURE__ */ new Map();
|
|
1157
1161
|
// keyed by opcode group
|
|
1158
1162
|
activeType = null;
|
|
@@ -1208,7 +1212,7 @@ class vt {
|
|
|
1208
1212
|
n.send(e);
|
|
1209
1213
|
return;
|
|
1210
1214
|
}
|
|
1211
|
-
this.state === "connected" &&
|
|
1215
|
+
this.state === "connected" && u.warn("No channel found for message");
|
|
1212
1216
|
}
|
|
1213
1217
|
/**
|
|
1214
1218
|
* Send a protocol message to all channels (for broadcast messages).
|
|
@@ -1236,7 +1240,7 @@ class vt {
|
|
|
1236
1240
|
*/
|
|
1237
1241
|
triggerReconnect(e) {
|
|
1238
1242
|
if (this.state === "connected") {
|
|
1239
|
-
|
|
1243
|
+
u.debug(`Forcing reconnect: ${e}`);
|
|
1240
1244
|
for (const s of this.channels.values())
|
|
1241
1245
|
s.triggerReconnect(e);
|
|
1242
1246
|
}
|
|
@@ -1249,10 +1253,10 @@ class vt {
|
|
|
1249
1253
|
this.setState("connecting");
|
|
1250
1254
|
let s = this.entrypoints;
|
|
1251
1255
|
if (this.config.webRtcEnabled) {
|
|
1252
|
-
|
|
1256
|
+
u.debug(`WebRTC enabled, filtering entrypoints (total: ${this.entrypoints.length})`);
|
|
1253
1257
|
for (const i of this.entrypoints)
|
|
1254
|
-
|
|
1255
|
-
s = this.entrypoints.filter((i) => i.Type === N.WebRTC ? (
|
|
1258
|
+
u.debug(` Entrypoint: type=${i.Type} fromServer=0x${i.OpcodeGroupsFromServer.toString(16)} toServer=0x${i.OpcodeGroupsToServer.toString(16)} uri=${i.Uri}`);
|
|
1259
|
+
s = this.entrypoints.filter((i) => i.Type === N.WebRTC ? (u.debug(` Filtered out WebRTC entrypoint (type=${i.Type})`), !1) : !0), u.debug(`After filtering: ${s.length} entrypoints remain for WS/WT channels`);
|
|
1256
1260
|
}
|
|
1257
1261
|
const r = this.groupByType(s);
|
|
1258
1262
|
if (r.size === 0)
|
|
@@ -1262,28 +1266,28 @@ class vt {
|
|
|
1262
1266
|
const i = new Set(r.keys());
|
|
1263
1267
|
n = this.config.orderedEndpointTypes.filter((a) => i.has(a));
|
|
1264
1268
|
} else this.config.endpointSelector ? n = this.config.endpointSelector.getOrderedTypes(r) : n = Array.from(r.keys());
|
|
1265
|
-
this.connectionTimeoutMs = n.length > 1 ? 5e3 : 1e4,
|
|
1269
|
+
this.connectionTimeoutMs = n.length > 1 ? 5e3 : 1e4, u.debug(`Endpoint types to try: [${n.map((i) => N[i]).join(", ")}], transport timeout: ${this.connectionTimeoutMs}ms`);
|
|
1266
1270
|
for (const i of n) {
|
|
1267
1271
|
if (!this.shouldReconnect)
|
|
1268
1272
|
return;
|
|
1269
1273
|
const a = r.get(i), o = Date.now();
|
|
1270
|
-
|
|
1274
|
+
u.debug(`Trying ${N[i]} (${a.length} channel(s))`);
|
|
1271
1275
|
try {
|
|
1272
|
-
await this.connectAllChannels(a), this.config.endpointSelector?.rememberWorkingType(i), this.config.onRememberWorkingType?.(i), this.activeType = i,
|
|
1276
|
+
await this.connectAllChannels(a), this.config.endpointSelector?.rememberWorkingType(i), this.config.onRememberWorkingType?.(i), this.activeType = i, u.debug(`Connected via ${N[i]} in ${Date.now() - o}ms`), this.setState("connected"), this.startStabilityTimer();
|
|
1273
1277
|
return;
|
|
1274
1278
|
} catch (l) {
|
|
1275
|
-
|
|
1279
|
+
u.warn(`Failed to connect using ${N[i]} after ${Date.now() - o}ms: ${l instanceof Error ? l.message : l}`);
|
|
1276
1280
|
const I = this.channels.size > 0;
|
|
1277
1281
|
if (this.disconnectAll(), I && this.config.onRefreshEntrypoints)
|
|
1278
1282
|
try {
|
|
1279
|
-
|
|
1283
|
+
u.info("Partial connection detected, refreshing entrypoints");
|
|
1280
1284
|
const E = await this.config.onRefreshEntrypoints();
|
|
1281
1285
|
this.entrypoints = E.entrypoints, this.config.sessionId = E.sessionId;
|
|
1282
1286
|
const h = this.config.webRtcEnabled ? E.entrypoints.filter((c) => c.Type !== N.WebRTC) : E.entrypoints, T = this.groupByType(h);
|
|
1283
1287
|
for (const [c, w] of T)
|
|
1284
1288
|
r.set(c, w);
|
|
1285
1289
|
} catch (E) {
|
|
1286
|
-
|
|
1290
|
+
u.warn(`Failed to refresh entrypoints: ${E}`);
|
|
1287
1291
|
}
|
|
1288
1292
|
}
|
|
1289
1293
|
}
|
|
@@ -1308,7 +1312,7 @@ class vt {
|
|
|
1308
1312
|
* Connect a single channel.
|
|
1309
1313
|
*/
|
|
1310
1314
|
async connectChannel(e) {
|
|
1311
|
-
const s = new
|
|
1315
|
+
const s = new bt({
|
|
1312
1316
|
entrypoint: e,
|
|
1313
1317
|
sessionId: this.config.sessionId,
|
|
1314
1318
|
keepaliveTimeoutMs: this.config.keepaliveTimeoutMs,
|
|
@@ -1354,7 +1358,7 @@ class vt {
|
|
|
1354
1358
|
* dropped, and we reconnect.
|
|
1355
1359
|
*/
|
|
1356
1360
|
handleChannelClose(e, s, r) {
|
|
1357
|
-
this.state === "idle" || this.state === "stopped" || this.state === "offline" || this.channels.has(e) && this.state === "connected" && (
|
|
1361
|
+
this.state === "idle" || this.state === "stopped" || this.state === "offline" || this.channels.has(e) && this.state === "connected" && (u.warn("Channel closed unexpectedly, attempting reconnect"), this.disconnectAll(), this.attemptReconnect());
|
|
1358
1362
|
}
|
|
1359
1363
|
/**
|
|
1360
1364
|
* Attempt to reconnect with fixed-interval retry.
|
|
@@ -1362,15 +1366,15 @@ class vt {
|
|
|
1362
1366
|
*/
|
|
1363
1367
|
async attemptReconnect() {
|
|
1364
1368
|
if (this.shouldReconnect) {
|
|
1365
|
-
if (!
|
|
1366
|
-
|
|
1369
|
+
if (!Lt()) {
|
|
1370
|
+
u.warn("Retry disabled via ikon-retry=false, skipping reconnect"), this.setState("offline"), this.config.onError?.(new Z(0));
|
|
1367
1371
|
return;
|
|
1368
1372
|
}
|
|
1369
1373
|
if (this.reconnectAttempts >= this.config.maxReconnectAttempts) {
|
|
1370
|
-
|
|
1374
|
+
u.warn(`Max reconnect attempts (${this.config.maxReconnectAttempts}) reached`), this.setState("offline"), this.config.onError?.(new Z(this.config.maxReconnectAttempts));
|
|
1371
1375
|
return;
|
|
1372
1376
|
}
|
|
1373
|
-
if (this.setState("reconnecting"), this.reconnectAttempts++, this.reconnectAttempts > 1 ? (
|
|
1377
|
+
if (this.setState("reconnecting"), this.reconnectAttempts++, this.reconnectAttempts > 1 ? (u.info(`Reconnecting in ${this.config.reconnectBackoffMs}ms (attempt ${this.reconnectAttempts}/${this.config.maxReconnectAttempts})`), await Ct(this.config.reconnectBackoffMs, this.abortController?.signal)) : u.info(`Reconnecting immediately (attempt ${this.reconnectAttempts}/${this.config.maxReconnectAttempts})`), !!this.shouldReconnect)
|
|
1374
1378
|
try {
|
|
1375
1379
|
await this.connectInternal(!0);
|
|
1376
1380
|
} catch {
|
|
@@ -1395,24 +1399,24 @@ class vt {
|
|
|
1395
1399
|
startStabilityTimer() {
|
|
1396
1400
|
this.clearStabilityTimer(), this.stabilityTimer = setTimeout(() => {
|
|
1397
1401
|
this.stabilityTimer = null, this.state === "connected" && (this.reconnectAttempts = 0);
|
|
1398
|
-
},
|
|
1402
|
+
}, vt);
|
|
1399
1403
|
}
|
|
1400
1404
|
clearStabilityTimer() {
|
|
1401
1405
|
this.stabilityTimer && (clearTimeout(this.stabilityTimer), this.stabilityTimer = null);
|
|
1402
1406
|
}
|
|
1403
1407
|
}
|
|
1404
|
-
const
|
|
1408
|
+
const ot = p("ProtocolWorker"), P = (t, e) => {
|
|
1405
1409
|
self.postMessage(t, e ?? []);
|
|
1406
1410
|
};
|
|
1407
|
-
let
|
|
1408
|
-
const m = [], R = [], B = /* @__PURE__ */ new Map(),
|
|
1411
|
+
let A = null, v = null, d = null, X, C = null;
|
|
1412
|
+
const m = [], R = [], B = /* @__PURE__ */ new Map(), y = [], f = [], L = /* @__PURE__ */ new Map(), $ = [];
|
|
1409
1413
|
function j() {
|
|
1410
1414
|
try {
|
|
1411
|
-
|
|
1415
|
+
A?.disconnect();
|
|
1412
1416
|
} catch (t) {
|
|
1413
|
-
|
|
1417
|
+
ot.warn(`Failed to disconnect channel manager: ${t}`);
|
|
1414
1418
|
}
|
|
1415
|
-
|
|
1419
|
+
A = null;
|
|
1416
1420
|
for (let t = 0; t < R.length; t++)
|
|
1417
1421
|
try {
|
|
1418
1422
|
R[t].port.close();
|
|
@@ -1424,28 +1428,28 @@ function j() {
|
|
|
1424
1428
|
f[t].port.close();
|
|
1425
1429
|
} catch {
|
|
1426
1430
|
}
|
|
1427
|
-
|
|
1431
|
+
y.length = 0, f.length = 0, L.clear();
|
|
1428
1432
|
}
|
|
1429
1433
|
function b(t) {
|
|
1430
1434
|
const e = t instanceof Error ? t : new Error(String(t));
|
|
1431
1435
|
P({ type: "error", error: { name: e.name, message: e.message, stack: e.stack } });
|
|
1432
1436
|
}
|
|
1433
|
-
function
|
|
1437
|
+
function Bt() {
|
|
1434
1438
|
let t = 0;
|
|
1435
1439
|
for (let e = 0; e < R.length; e++)
|
|
1436
1440
|
t |= R[e].opcodeGroupsMask;
|
|
1437
1441
|
return t;
|
|
1438
1442
|
}
|
|
1439
|
-
function
|
|
1443
|
+
function Ft(t) {
|
|
1440
1444
|
if (X === void 0)
|
|
1441
1445
|
return !0;
|
|
1442
1446
|
const e = F(t);
|
|
1443
1447
|
if ((e & X) !== 0)
|
|
1444
1448
|
return !0;
|
|
1445
|
-
const s =
|
|
1449
|
+
const s = Bt();
|
|
1446
1450
|
return (e & s) !== 0;
|
|
1447
1451
|
}
|
|
1448
|
-
function
|
|
1452
|
+
function lt(t) {
|
|
1449
1453
|
$.length = 0;
|
|
1450
1454
|
for (let e = 0; e < R.length; e++) {
|
|
1451
1455
|
const s = R[e];
|
|
@@ -1453,25 +1457,25 @@ function ot(t) {
|
|
|
1453
1457
|
}
|
|
1454
1458
|
return $;
|
|
1455
1459
|
}
|
|
1456
|
-
function
|
|
1460
|
+
function Gt(t, e) {
|
|
1457
1461
|
return (F(t) & e) !== 0;
|
|
1458
1462
|
}
|
|
1459
|
-
function
|
|
1460
|
-
if (!
|
|
1463
|
+
function Vt(t, e) {
|
|
1464
|
+
if (!A || !e || typeof e != "object")
|
|
1461
1465
|
return;
|
|
1462
1466
|
const s = e;
|
|
1463
1467
|
if (!(s.type !== "send" || !(s.message instanceof ArrayBuffer)))
|
|
1464
1468
|
try {
|
|
1465
1469
|
const r = new Uint8Array(s.message);
|
|
1466
|
-
if (!
|
|
1470
|
+
if (!Gt(r, t))
|
|
1467
1471
|
return;
|
|
1468
|
-
|
|
1472
|
+
A.sendProtocolMessage(r), C && C.postMessage({ direction: "sent", message: Array.from(r) });
|
|
1469
1473
|
} catch (r) {
|
|
1470
1474
|
b(r);
|
|
1471
1475
|
}
|
|
1472
1476
|
}
|
|
1473
|
-
async function
|
|
1474
|
-
j(),
|
|
1477
|
+
async function pt(t) {
|
|
1478
|
+
j(), A = new dt({
|
|
1475
1479
|
sessionId: t.sessionId,
|
|
1476
1480
|
keepaliveTimeoutMs: t.keepaliveTimeoutMs,
|
|
1477
1481
|
reconnectBackoffMs: t.reconnectBackoffMs,
|
|
@@ -1479,10 +1483,10 @@ async function Vt(t) {
|
|
|
1479
1483
|
orderedEndpointTypes: t.orderedEndpointTypes,
|
|
1480
1484
|
webRtcEnabled: t.webRtcEnabled,
|
|
1481
1485
|
onStateChange: (e) => {
|
|
1482
|
-
P({ type: "state", state: e, activeType:
|
|
1486
|
+
P({ type: "state", state: e, activeType: A?.activeEndpointType ?? void 0 });
|
|
1483
1487
|
},
|
|
1484
1488
|
onRememberWorkingType: () => {
|
|
1485
|
-
P({ type: "state", state:
|
|
1489
|
+
P({ type: "state", state: A?.managerState ?? "idle", activeType: A?.activeEndpointType ?? void 0 });
|
|
1486
1490
|
},
|
|
1487
1491
|
onError: (e) => {
|
|
1488
1492
|
b(e);
|
|
@@ -1492,7 +1496,7 @@ async function Vt(t) {
|
|
|
1492
1496
|
}),
|
|
1493
1497
|
onProtocolMessage: (e) => {
|
|
1494
1498
|
C && (C.postMessage({ direction: "received", message: Array.from(e) }), Q(e) === V.ANALYTICS_LOGS && C.postMessage({ type: "serverLogs", message: Array.from(e) }));
|
|
1495
|
-
const s = F(e), r =
|
|
1499
|
+
const s = F(e), r = Ft(e), n = lt(s);
|
|
1496
1500
|
if (!(!r && n.length === 0))
|
|
1497
1501
|
try {
|
|
1498
1502
|
const i = H(e), a = e.buffer instanceof ArrayBuffer && e.byteOffset === 0 && e.byteLength === e.buffer.byteLength, o = n.length > 0;
|
|
@@ -1530,13 +1534,13 @@ async function Vt(t) {
|
|
|
1530
1534
|
b(i);
|
|
1531
1535
|
}
|
|
1532
1536
|
}
|
|
1533
|
-
}), await
|
|
1537
|
+
}), await A.connect(t.entrypoints, { retry: t.retry });
|
|
1534
1538
|
}
|
|
1535
1539
|
self.addEventListener("message", (t) => {
|
|
1536
1540
|
const e = t.data;
|
|
1537
1541
|
if (e.type === "connect") {
|
|
1538
|
-
|
|
1539
|
-
|
|
1542
|
+
pt(e).catch((s) => {
|
|
1543
|
+
ot.error(`Failed to connect: ${s}`), b(s), j();
|
|
1540
1544
|
});
|
|
1541
1545
|
return;
|
|
1542
1546
|
}
|
|
@@ -1545,11 +1549,11 @@ self.addEventListener("message", (t) => {
|
|
|
1545
1549
|
return;
|
|
1546
1550
|
}
|
|
1547
1551
|
if (e.type === "send") {
|
|
1548
|
-
if (!
|
|
1552
|
+
if (!A)
|
|
1549
1553
|
return;
|
|
1550
1554
|
try {
|
|
1551
1555
|
const s = new Uint8Array(e.message);
|
|
1552
|
-
|
|
1556
|
+
A.sendProtocolMessage(s), C && C.postMessage({ direction: "sent", message: Array.from(s) });
|
|
1553
1557
|
} catch (s) {
|
|
1554
1558
|
b(s);
|
|
1555
1559
|
}
|
|
@@ -1563,12 +1567,16 @@ self.addEventListener("message", (t) => {
|
|
|
1563
1567
|
e.enabled && !C ? C = new BroadcastChannel("ikon:devtools") : !e.enabled && C && (C.close(), C = null);
|
|
1564
1568
|
return;
|
|
1565
1569
|
}
|
|
1570
|
+
if (e.type === "setLogLevel") {
|
|
1571
|
+
Rt(e.level);
|
|
1572
|
+
return;
|
|
1573
|
+
}
|
|
1566
1574
|
if (e.type === "checkHealth") {
|
|
1567
|
-
|
|
1575
|
+
A?.checkHealth();
|
|
1568
1576
|
return;
|
|
1569
1577
|
}
|
|
1570
1578
|
if (e.type === "triggerReconnect") {
|
|
1571
|
-
|
|
1579
|
+
A?.triggerReconnect(e.reason);
|
|
1572
1580
|
return;
|
|
1573
1581
|
}
|
|
1574
1582
|
if (e.type === "refreshedEntrypoints") {
|
|
@@ -1581,7 +1589,7 @@ self.addEventListener("message", (t) => {
|
|
|
1581
1589
|
}
|
|
1582
1590
|
if (e.type === "forwardToPorts") {
|
|
1583
1591
|
try {
|
|
1584
|
-
const s = new Uint8Array(e.message), r = F(s), n =
|
|
1592
|
+
const s = new Uint8Array(e.message), r = F(s), n = lt(r);
|
|
1585
1593
|
if (n.length > 0) {
|
|
1586
1594
|
const i = H(s);
|
|
1587
1595
|
for (const a of n) {
|
|
@@ -1628,21 +1636,21 @@ self.addEventListener("message", (t) => {
|
|
|
1628
1636
|
i.port.close();
|
|
1629
1637
|
} catch {
|
|
1630
1638
|
}
|
|
1631
|
-
const a =
|
|
1639
|
+
const a = y.length - 1;
|
|
1632
1640
|
if (s !== a) {
|
|
1633
|
-
const o =
|
|
1634
|
-
|
|
1641
|
+
const o = y[a];
|
|
1642
|
+
y[s] = o, f[s] = f[a], L.set(o, s);
|
|
1635
1643
|
}
|
|
1636
|
-
|
|
1644
|
+
y.length--, f.length--, L.delete(e.portId);
|
|
1637
1645
|
}
|
|
1638
|
-
const r = { port: e.port, opcodeGroupsMask: e.opcodeGroupsMask }, n =
|
|
1639
|
-
|
|
1646
|
+
const r = { port: e.port, opcodeGroupsMask: e.opcodeGroupsMask }, n = y.length;
|
|
1647
|
+
y.push(e.portId), f.push(r), L.set(e.portId, n);
|
|
1640
1648
|
try {
|
|
1641
1649
|
r.port.start?.();
|
|
1642
1650
|
} catch {
|
|
1643
1651
|
}
|
|
1644
1652
|
r.port.addEventListener("message", (i) => {
|
|
1645
|
-
|
|
1653
|
+
Vt(r.opcodeGroupsMask, i.data);
|
|
1646
1654
|
});
|
|
1647
1655
|
return;
|
|
1648
1656
|
}
|
|
@@ -1654,12 +1662,12 @@ self.addEventListener("message", (t) => {
|
|
|
1654
1662
|
r.port.close();
|
|
1655
1663
|
} catch {
|
|
1656
1664
|
}
|
|
1657
|
-
const n =
|
|
1665
|
+
const n = y.length - 1;
|
|
1658
1666
|
if (s !== n) {
|
|
1659
|
-
const i =
|
|
1660
|
-
|
|
1667
|
+
const i = y[n];
|
|
1668
|
+
y[s] = i, f[s] = f[n], L.set(i, s);
|
|
1661
1669
|
}
|
|
1662
|
-
|
|
1670
|
+
y.length--, f.length--, L.delete(e.portId);
|
|
1663
1671
|
}
|
|
1664
1672
|
return;
|
|
1665
1673
|
}
|