Files
discord-decomp/_bundle/eventFromEnvelope.js
T
2026-11-01 12:12:55 +02:00

155 lines
4.7 KiB
JavaScript

// Metro module 897 (f898).
import { forEachEnvelopeItem, createEnvelope } from "./forEachEnvelopeItem";
import { dsnFromString } from "./dsnFromString";
import { getEnvelopeEndpointWithUrlEncodedAuth } from "./Module875";
import { HermesBuiltin } from "../_hermes/prelude";
function $mk67305($env) {
return (a0, a1) => {
const r1 = $env;
if (r1[0].includes(a1)) {
r1[1] = Array.isArray(a0) ? a0[1] : void 0;
}
return !!r1[1];
};
}
let c737_3;
let env737 = {};
export function eventFromEnvelope(a0, a1) {
let env12548;
const r1 = env12548 = {};
env12548[0] = a1;
forEachEnvelopeItem(a0, $mk67305(r1));
return env12548[1];
}
Object.defineProperty(exports, Symbol.toStringTag, {
value: "Module"
});
c737_3 = "MULTIPLEXED_TRANSPORT_EXTRA_KEY";
export const MULTIPLEXED_TRANSPORT_EXTRA_KEY = "MULTIPLEXED_TRANSPORT_EXTRA_KEY";
export function makeMultiplexedTransport(c12549_0, c12549_1) {
return (a0) => {
let c23899_1, c23899_2, c23899_3, _send2, _flush2;
let c23899_0 = a0;
const getTransport2 = function getTransport(a0, a1) {
let r34;
const r4 = a1 ? `${a0}:${a1}` : a0;
let r20 = c23899_2.get(r4);
if (!r20) {
const r8 = env737;
const r24 = dsnFromString(a0);
if (!r24) {
return void 0;
}
const envelopeEndpointWithUrlEncodedAuth = getEnvelopeEndpointWithUrlEncodedAuth(r24, c23899_0.tunnel);
const r32 = {};
if (a1) {
let env28685 = {
$parent: r8
};
env28685[0] = a1;
HermesBuiltin.copyDataProperties(r32, c23899_0);
r32.url = envelopeEndpointWithUrlEncodedAuth;
const r40 = c12549_0(r32);
let c28686_1 = r40;
let c28686_0 = async (c32085_0) => {
const r19 = eventFromEnvelope(c32085_0, ["event", "transaction", "profile", "replay_event"]);
if (r19) {
r19.release = env28685[0];
}
return c28686_1.send(c32085_0);
};
r34 = {
...r40,
send: function send(a0) {
return c28686_0.apply(this, arguments);
}
};
} else {
HermesBuiltin.copyDataProperties(r32, c23899_0);
r32.url = envelopeEndpointWithUrlEncodedAuth;
r34 = c12549_0(r32);
}
c23899_2.set(r4, r34);
r20 = r34;
}
return [a0, r20];
};
_send2 = function _send() {
const r9 = async (envelope) => {
let c31855_0 = envelope;
const r31 = c23899_3({
envelope,
getEvent: function getEvent(a0) {
let r4 = a0;
if (!a0?.length) {
r4 = ["event"];
}
let env32086;
const r9 = env32086 = {};
env32086[0] = r4;
forEachEnvelopeItem(c31855_0, $mk67305(r9));
return env32086[1];
}
}).map((item) => typeof item === "string" ? getTransport2(item, void 0) : getTransport2(item.dsn, item.release)).filter((item) => !!item);
return (await Promise.all((r31.length ? r31 : [["", c23899_1]]).map((item) => {
const [dsn, r27] = item;
const send2 = r27.send;
const r11 = c31855_0[0];
return send2.call(r27, createEnvelope(dsn ? {
...r11,
dsn
} : r11, c31855_0[1]));
})))[0];
};
_send2 = r9;
return r9.apply(this, arguments);
};
_flush2 = function _flush() {
const r9 = async (c31171_0) => {
let env31856;
const r8 = env31856 = {};
let c31171_2 = r8;
env31856[0] = c31171_0;
let c31171_1 = 0;
const r14 = c23899_2.values();
const r12 = [,];
const r26 = HermesBuiltin.arraySpread(r12, r14, c31171_1);
c31171_1 = r26;
r12[r26] = c23899_1;
c31171_1 = c31171_1 + 1;
return (await Promise.all(r12.map((item) => item.flush(env31856[0])))).every((item) => item);
};
_flush2 = r9;
return r9.apply(this, arguments);
};
c23899_1 = c12549_0(a0);
c23899_2 = new Map();
c23899_3 = c12549_1 || ((a0) => {
let r18;
const event = a0.getEvent();
const r2 = event == null;
let r9 = void 0;
if (!r2) {
const extra = event.extra;
r9 = extra == null ? void 0 : extra[c737_3];
}
if (r9) {
const r12 = Array;
const extra2 = event.extra;
r18 = r12.isArray(extra2[c737_3]) ? event.extra[c737_3] : [];
} else {
r18 = [];
}
return r18;
});
return {
send: function send(a0) {
return _send2.apply(this, arguments);
},
flush: function flush(a0) {
return _flush2.apply(this, arguments);
}
};
};
}