decord/alpha/source/lib/websocketTelemetryHook.android.tsx

163 lines
4.3 KiB
TypeScript
Raw Permalink Normal View History

2026-10-13 12:43:34 +00:00
// Module ID: 18724
// Function ID: 18725
// Name: websocketTelemetryHook
2026-07-23 10:11:24 +00:00
// Dependencies: [2]
2026-07-20 16:05:17 +00:00
// Exports: installWebsocketTelemetryHook
2026-10-13 12:43:34 +00:00
// Module 18724 (websocketTelemetryHook)
import size from "module_2" /* 2 */;
2026-08-24 06:08:38 +00:00
const result = size.fileFinishedImporting("lib/websocketTelemetryHook.android.tsx");
2026-07-20 16:05:17 +00:00
export const installWebsocketTelemetryHook = function installWebsocketTelemetryHook(arg0) {
2026-10-03 08:58:59 +00:00
let _globalThis;
let closure_0 = arg0;
2026-08-04 21:03:28 +00:00
function handleMessage(arg0, str) {
2026-10-03 08:58:59 +00:00
function sanitizeUrl(arg0) {
let hostname;
let pathname;
2026-07-29 08:29:29 +00:00
try {
const _URL = URL;
2026-10-03 08:58:59 +00:00
const self = this;
const self2 = this;
2026-07-29 08:29:29 +00:00
const uRL = new URL(arg0);
({ hostname, pathname } = uRL);
if (null != hostname) {
2026-10-03 08:58:59 +00:00
if ("" !== tmp5) {
2026-07-29 08:29:29 +00:00
if (null != pathname) {
if ("" !== pathname) {
2026-10-03 08:58:59 +00:00
let combined;
2026-07-29 08:29:29 +00:00
if ("/" !== pathname) {
const _HermesInternal = HermesInternal;
2026-10-03 08:58:59 +00:00
combined = "" + hostname + pathname;
2026-07-29 08:29:29 +00:00
}
return combined;
}
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
combined = hostname;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
const first = arg0.split("?")[0];
2026-10-03 08:58:59 +00:00
let tmp13 = null;
2026-07-29 08:29:29 +00:00
if ("" !== first) {
2026-10-03 08:58:59 +00:00
tmp13 = first;
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
return tmp13;
2026-07-29 08:29:29 +00:00
} catch (err) {
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
}
const obj = {};
const tmp = sanitizeUrl(arg0);
2026-07-29 08:29:29 +00:00
if (null != tmp) {
obj.url = tmp;
}
let flag = false;
2026-08-04 21:03:28 +00:00
if (typeof str === "string") {
if (str.length > 0) {
if ("{" === str[0]) {
2026-07-29 08:29:29 +00:00
try {
2026-07-20 16:05:17 +00:00
const _JSON = JSON;
2026-08-04 21:03:28 +00:00
const parsed = JSON.parse(str);
2026-07-29 08:29:29 +00:00
let tmp5 = null != parsed;
if (tmp5) {
2026-08-04 21:03:28 +00:00
tmp5 = typeof tmp4 === "object";
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp5) {
2026-10-03 08:58:59 +00:00
if (null != parsed.op) {
obj.op = parsed.op;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
if (null != parsed.s) {
obj.s = parsed.s;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
if (null != parsed.t) {
obj.t = parsed.t;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
let tmp13 = parsed;
if (null != parsed.type) {
obj.type = parsed.type;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
if (null != parsed.evt) {
obj.evt = parsed.evt;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
if (null != parsed.cmd) {
2026-07-20 16:05:17 +00:00
obj.cmd = parsed.cmd;
}
flag = true;
}
2026-07-29 08:29:29 +00:00
} catch (err) {
2026-07-20 16:05:17 +00:00
}
}
}
}
2026-07-29 08:29:29 +00:00
if (!flag) {
2026-08-04 21:03:28 +00:00
flag = null == str;
2026-07-29 08:29:29 +00:00
}
if (!flag) {
2026-08-04 21:03:28 +00:00
flag = typeof str === "string";
2026-07-29 08:29:29 +00:00
}
if (!flag) {
obj.type = "binary";
}
try {
closure_0(obj);
2026-07-29 08:29:29 +00:00
} catch (err) {
2026-07-20 16:05:17 +00:00
}
}
2026-08-04 21:03:28 +00:00
if (typeof globalThis !== "undefined") {
2026-10-03 08:58:59 +00:00
_globalThis = globalThis;
2026-07-20 16:05:17 +00:00
} else {
_globalThis = global;
if (undefined === global) {
const _window = window;
let _window1 = null;
2026-08-04 21:03:28 +00:00
if (typeof window !== "undefined") {
_window1 = window;
2026-07-29 08:29:29 +00:00
}
_globalThis = _window1;
2026-07-20 16:05:17 +00:00
}
}
let _WebSocket1;
2026-07-29 08:29:29 +00:00
if (_globalThis != null) {
_WebSocket1 = _globalThis.WebSocket;
2026-07-20 16:05:17 +00:00
}
if (null != _WebSocket1) {
2026-07-20 16:05:17 +00:00
if (!_globalThis.__discordWebsocketTelemetryPatched) {
const _WebSocket = _globalThis.WebSocket;
2026-07-20 16:05:17 +00:00
class PatchedWebSocket {
2026-07-29 08:29:29 +00:00
constructor() {
2026-10-03 08:58:59 +00:00
let str;
const items = [...arguments];
const obj = _WebSocket(...items);
2026-08-04 21:03:28 +00:00
if (typeof items[0] === "string") {
2026-07-20 16:05:17 +00:00
str = items[0];
} else {
2026-07-29 08:29:29 +00:00
str = obj.url;
2026-10-03 08:58:59 +00:00
let tmp = null;
2026-07-29 08:29:29 +00:00
if (str == null) {
str = "";
2026-07-20 16:05:17 +00:00
}
}
2026-08-04 21:03:28 +00:00
if (typeof obj.addEventListener === "function") {
2026-10-03 08:58:59 +00:00
const listener = obj.addEventListener("message", (event) => {
let data;
2026-10-03 08:58:59 +00:00
const tmp = handleMessage;
const tmp2 = str;
if (event != null) {
data = event.data;
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
tmp(tmp2, data);
2026-07-29 08:29:29 +00:00
});
}
return obj;
2026-07-20 16:05:17 +00:00
}
}
PatchedWebSocket.prototype = _WebSocket.prototype;
const _Object = Object;
const merged = Object.assign(PatchedWebSocket, _WebSocket);
_globalThis.WebSocket = PatchedWebSocket;
2026-10-03 08:58:59 +00:00
let flag = true;
2026-07-20 16:05:17 +00:00
_globalThis.__discordWebsocketTelemetryPatched = true;
}
}
};