This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

+58
View File
@@ -0,0 +1,58 @@
// Metro module 5134 (f5135).
import Dispatcher from "../Dispatcher";
class AutomaticLifecycleManager {
constructor() {
const r5 = {
__proto__: new.target.prototype,
initializedCount: 0,
actions: {},
stores: null
};
r5.stores = new Map();
return r5;
}
initialize() {
this.initializedCount = this.initializedCount + 1;
if (!(this.initializedCount > 1)) {
this._initialize();
Object.entries(this.actions).forEach((item) => {
const [r23, r7] = item;
let r32 = r7;
if (typeof r32 !== "function") {
r32 = r7.callback;
}
Dispatcher.subscribe(r23, r32);
});
this.stores.forEach((store, index) => {
index.addChangeListener(store);
store();
});
}
}
terminate(a0) {
if (!(this.initializedCount <= 0)) {
if (a0) {
this.initializedCount = 0;
} else {
this.initializedCount = this.initializedCount - 1;
}
if (this.initializedCount === 0) {
this._terminate();
Object.entries(this.actions).forEach((item) => {
const [r23, r7] = item;
let r32 = r7;
if (typeof r32 !== "function") {
r32 = r7.callback;
}
Dispatcher.unsubscribe(r23, r32);
});
this.stores.forEach((store, index) => {
index.removeChangeListener(store);
});
}
}
}
_initialize() {}
_terminate() {}
}
export default AutomaticLifecycleManager;
+44
View File
@@ -0,0 +1,44 @@
// Metro module 4222 (f4223).
import { cachedFunction } from "../utils/FunctionUtils";
class CachedEntriesMap {
version = 0;
data = new Map();
cachedValues = cachedFunction(() => Array.from(this.data.values()));
cachedKeys = cachedFunction(() => Array.from(this.data.keys()));
cachedEntries = cachedFunction(() => Array.from(this.data.entries()));
keys() {
return this.cachedKeys(this.version);
}
values() {
return this.cachedValues(this.version);
}
entries() {
return this.cachedEntries(this.version);
}
size() {
return this.data.size;
}
get(a0) {
return this.data.get(a0);
}
set(a0, a1) {
if (this.data.get(a0) !== a1) {
this.data.set(a0, a1);
this.version = this.version + 1;
}
}
delete(a0) {
const r4 = this.data.delete(a0);
if (r4) {
this.version = this.version + 1;
}
return r4;
}
clear() {
if (this.data.size !== 0) {
this.data.clear();
this.version = this.version + 1;
}
}
}
export default CachedEntriesMap;
File diff suppressed because it is too large. Load diff
+3
View File
@@ -0,0 +1,3 @@
// Metro module 3800 (f3801).
const DiscordNative = window.DiscordNative;
export default DiscordNative;
@@ -0,0 +1,15 @@
// Metro module 4861 (f4862).
import { createApexExperiment } from "../modules/experiments/apex/index";
const apexExperiment = createApexExperiment({
name: "2026-04-ensure-received-messages-added-in-order",
kind: "user",
defaultConfig: {
enabled: false
},
variations: {
1: {
enabled: true
}
}
});
export default apexExperiment;
+156
View File
@@ -0,0 +1,156 @@
// Metro module 4273 (f4274).
import Module12 from "../_bundle/Module12";
import Module3771 from "../_bundle/Module3771";
let DEFAULT_WEIGHT;
const DEFAULT_FRECENCY = (a0, a1, a2) => Math.ceil(a0 * (a1 / a2.numOfRecentUses));
DEFAULT_WEIGHT = (a0) => a0 <= 3 ? 100 : a0 <= 15 ? 70 : a0 <= 30 ? 50 : a0 <= 45 ? 30 : a0 <= 80 ? 10 : 1;
class Frecency {
constructor({ computeBonus, computeWeight = DEFAULT_WEIGHT, computeFrecency = DEFAULT_FRECENCY, calculateMaxTotalUse = false, lookupKey, afterCompute, numFrequentlyItems = 32, maxSamples = 10 }) {
this.computeBonus = computeBonus;
this.computeWeight = computeWeight;
this.computeFrecency = computeFrecency;
this.calculateMaxTotalUse = calculateMaxTotalUse;
this.afterCompute = afterCompute;
this.lookupKey = lookupKey;
this.usageHistory = {};
this.frequently = [];
this.maxSamples = maxSamples;
this.numFrequentlyItems = numFrequentlyItems;
this.dirty = false;
this.version = 0;
}
overwriteHistory(a0, a1) {
this.usageHistory = Module12.mapValues(a0 == null ? {} : a0, (a0) => ({
...a0,
frecency: -1
}));
if (a1 != null) {
a1.forEach((item) => this.track(item.key, {
timestamp: item.timestamp
}));
}
this.markDirty();
}
markDirty() {
this.dirty = true;
this.version = this.version + 1;
}
isDirty() {
return this.dirty;
}
track(a0, r3 = {}) {
let r33, length2, maxSamples2;
let timestamp = r3.timestamp;
let usesSinceLastTrack = r3.usesSinceLastTrack;
if (a0 != null) {
const r11 = Object.hasOwn(this.usageHistory, a0) ? this.usageHistory[a0] : void 0;
if (r11 == null) {
if (usesSinceLastTrack == null) {
usesSinceLastTrack = 1;
}
if (timestamp == null) {
timestamp = Date.now();
}
r33 = {
totalUses: usesSinceLastTrack,
recentUses: [timestamp],
frecency: -1,
score: 0
};
} else {
r11.frecency = -1;
r11.totalUses = r11.totalUses + (usesSinceLastTrack == null ? 1 : usesSinceLastTrack);
if (timestamp == null) {
r11.recentUses.push(Date.now());
} else {
r11.recentUses.push(timestamp);
r11.recentUses.sort();
}
const length = r11.recentUses.length;
const maxSamples = this.maxSamples;
r33 = r11;
if (length > maxSamples) {
do {
r11.recentUses.shift();
length2 = r11.recentUses.length;
maxSamples2 = this.maxSamples;
r33 = r11;
} while (length2 > maxSamples2);
}
}
this.usageHistory[a0] = r33;
this.markDirty();
}
}
getEntry(a0) {
let r1 = null;
if (a0 != null) {
if (this.dirty) {
this.compute();
}
r1 = Object.prototype.hasOwnProperty.call(this.usageHistory, a0) ? this.usageHistory[a0] : void 0;
}
return r1;
}
getScore(a0) {
const entry = this.getEntry(a0);
return entry != null ? entry.score : null;
}
getFrecency(a0) {
const entry = this.getEntry(a0);
return entry != null ? entry.frecency : null;
}
compute() {
let c14070_1 = Module3771();
let c14070_0 = this.calculateMaxTotalUse ? Module12.maxBy(Object.values(this.usageHistory), (a0) => a0.totalUses) : null;
Module12.forEach(this.usageHistory, (a0, a1) => {
let c25020_1;
let c25020_0 = a0;
const { totalUses, recentUses } = a0;
if (a0.frecency === -1) {
c25020_1 = this.computeBonus(a1) / 100;
a0.score = 0;
Module12.forEach(recentUses, (a0, a1) => {
if (a1 >= this.maxSamples) {
return false;
}
const r20 = this.computeWeight(c14070_1.diff(Module3771(a0), "days"));
c25020_0.score = c25020_0.score + c25020_1 * r20;
});
if (a0.score > 0) {
if (a0.recentUses.length > 0) {
a0.frecency = this.computeFrecency(totalUses, a0.score, {
numOfRecentUses: recentUses.length,
maxTotalUse: c14070_0?.totalUses
});
}
this.usageHistory[a1] = a0;
} else {
delete this.usageHistory[a1];
}
}
});
this.frequently = Module12(this.usageHistory).map((item, index) => {
const r4 = this.lookupKey(index);
return r4 != null ? [r4, item.frecency] : null;
}).filter((item) => item !== null).sortBy((item) => {
const [, r13] = item;
return -r13;
}).map((item) => {
const [r8] = item;
return r8;
}).take(this.numFrequentlyItems).value();
this.dirty = false;
this.afterCompute(this.usageHistory, this._frequently);
}
get frequently() {
if (this.dirty) {
this.compute();
}
return this._frequently;
}
set frequently(a0) {
this._frequently = a0;
}
}
export default Frecency;
+68
View File
@@ -0,0 +1,68 @@
// Metro module 6028 (f6029).
import { Digest, TDigest } from "../_bundle/TDigest";
export class Histogram {
constructor() {
return {
__proto__: new.target.prototype,
digest: new Digest(),
total: 0,
samples: 0,
totalWeight: 0
};
}
getSamples() {
return this.samples;
}
addSample(a0, r6 = 1) {
this.total = this.total + a0 * r6;
this.totalWeight = this.totalWeight + r6;
this.samples = this.samples + 1;
TDigest.prototype.push.call(this.digest, a0, r6);
this.digest.check_continuous();
}
addSamples(a0, r6 = 1) {
let c15368_0 = r6;
this.total = this.total + a0.reduce((acc, item) => acc + item * c15368_0, 0);
this.totalWeight = this.totalWeight + r6 * a0.length;
this.samples = this.samples + a0.length;
TDigest.prototype.push.call(this.digest, a0, r6);
this.digest.check_continuous();
}
getReport(r0 = [25, 50, 75, 90, 95]) {
const percentiles = {};
for (const item of r0) {
let r27 = this.digest.percentile(item / 100);
if (r27 == null) {
r27 = 0;
}
percentiles[item] = r27;
}
let min = this.digest.percentile(0);
if (min == null) {
min = 0;
}
let max = this.digest.percentile(1);
if (max == null) {
max = 0;
}
let count = this.digest.size();
if (count == null) {
count = 0;
}
return {
min,
max,
count,
percentiles,
mean: this.totalWeight > 0 ? this.total / this.totalWeight : 0,
samples: this.samples
};
}
getPercentile(a0) {
let r7 = this.digest.percentile(a0 / 100);
if (r7 == null) {
r7 = 0;
}
return r7;
}
}
+3
View File
@@ -0,0 +1,3 @@
// Metro module 16099 (f16100).
import * as _Module510 from "../_bundle/Module510";
export const IdGenerator = _Module510.IdGenerator;
+57
View File
@@ -0,0 +1,57 @@
// Metro module 11807 (f11808).
import ChannelStore from "../stores/ChannelStore";
import Durations from "../utils/Durations";
import Queue from "../utils/Queue";
import Logger from "../modules/debug/Logger";
import MessageActionCreators from "../actions/MessageActionCreators";
import ChannelActionCreators from "../actions/ChannelActionCreators";
import { $callWithNewTarget } from "../_hermes/prelude";
let c8095_3 = 1 * Durations.Millis.SECOND + 10;
let c8095_4 = {
GROUP_DM: 0,
0: "GROUP_DM",
USER: 1,
1: "USER",
CHANNEL: 2,
2: "CHANNEL"
};
class InviteQueue extends Queue {
constructor() {
const logger = new Logger("InviteQueue");
super(logger, c8095_3);
}
_sendInvite(a0, a1, a2, a3, c19186_0) {
MessageActionCreators.sendInvite(a0.id, a1, a2, a3).then(() => c19186_0(null, true), () => c19186_0(null, false));
}
drain(a0, a1) {
let inviteAnalyticsMetadata, c19187_1, c19187_2, location2;
L5: {
c19187_1 = a0;
c19187_2 = a1;
location2 = a0.location;
inviteAnalyticsMetadata = a0.inviteAnalyticsMetadata;
const type = a0.type;
if (c8095_4.GROUP_DM !== type && c8095_4.CHANNEL !== type) {
if (c8095_4.USER !== type) {
break L5;
}
ChannelActionCreators.ensurePrivateChannel(a0.user.id).then((result) => {
const channel = ChannelStore.getChannel(result);
if (channel != null) {
this._sendInvite(channel, c19187_1.inviteKey, location2, inviteAnalyticsMetadata, c19187_2);
} else {
c19187_2(null, false);
}
}, () => c19187_2(null, false));
} else {
this._sendInvite(a0.channel, a0.inviteKey, location2, inviteAnalyticsMetadata, a1);
}
}
}
}
const prototypeOf = Object.getPrototypeOf(InviteQueue);
const logger = new Logger("InviteQueue");
const r45 = Object.create(InviteQueue.prototype);
const r48 = $callWithNewTarget(prototypeOf, r45, InviteQueue, logger, c8095_3);
export default r48 instanceof Object ? r48 : r45;
export { c8095_4 as InvitePropertiesType };
+8
View File
@@ -0,0 +1,8 @@
// Metro module 12957 (f12958).
import { isMac, isMacWeb } from "../utils/PlatformUtils";
const r18 = isMac() ? "cmd" : isMacWeb() ? "cmd" : "ctrl";
const r27 = isMac() ? "opt" : isMacWeb() ? "opt" : "alt";
const r36 = isMac() ? "return" : isMacWeb() ? "return" : "enter";
export { r18 as modKey };
export { r27 as altKey };
export { r36 as returnKey };
+22
View File
@@ -0,0 +1,22 @@
// Metro module 4368 (f4369).
class LifecycleManager {
constructor() {
return {
__proto__: new.target.prototype,
isInitialized: false
};
}
initialize(...args) {
if (!this.isInitialized) {
this.isInitialized = true;
this._initialize.apply(this, [...args]);
}
}
terminate() {
if (this.isInitialized) {
this.isInitialized = false;
this._terminate();
}
}
}
export default LifecycleManager;
+18
View File
@@ -0,0 +1,18 @@
// Metro module 7893 (f7894).
let prototype, LimitedMap;
const LimitedMap2 = class LimitedMap extends Map {
constructor(a0) {
super();
this.maxSize = a0;
}
set(a0, a1) {
if (this.size >= this.maxSize) {
this.delete(this.keys().next().value);
}
return Reflect.get(Object.getPrototypeOf(prototype), "set", this).call(this, a0, a1);
}
};
const prototype2 = LimitedMap2.prototype;
LimitedMap = LimitedMap2;
prototype = prototype2;
export default LimitedMap;
+350
View File
@@ -0,0 +1,350 @@
// Metro module 6145 (f6146).
import DevSettingsStore from "../modules/devtools/dev_settings/DevSettingsStore";
import AuthenticationStore from "../stores/AuthenticationStore";
import NetworkStore from "../stores/NetworkStore";
import { AnalyticEvents, AbortCodes, Endpoints } from "../Constants";
import { MESSAGE_HTTP_TIMEOUT_RETRY_OPTIONS } from "../modules/messages/MessageConstants";
import Durations from "../utils/Durations";
import Queue from "../utils/Queue";
import Logger from "../modules/debug/Logger";
import { trackWithMetadata } from "../modules/app_analytics/AppAnalyticsUtils";
import getOverlayMessageAnaylticsLocation_native from "../modules/overlay/getOverlayMessageAnaylticsLocation.native";
import { getSignalStrength } from "../modules/network/NetStats.android";
import { HTTP } from "../_bundle/sendRequest";
import { InteractionTypes } from "../flow/Server";
import Module38 from "../_bundle/Module38";
import { CloudUploadStatus } from "./uploader/CloudUpload";
import { getAttachmentPayload } from "../utils/UploadUtils";
import { maxFileSize } from "../utils/FileUtils";
import { $callWithNewTarget } from "../_hermes/prelude";
function $mk77798($env) {
return (a0, a1) => {
let env25716 = {
$parent: $env
};
const { channelId, messageId, isCrossposted, ...body } = a0;
env25716[0] = messageId;
env25716[1] = void 0;
const abortController = new AbortController();
env25716[1] = abortController;
const responseHandler = $env[0].createResponseHandler(messageId, a1);
const r25 = $env.$parent;
const r29 = {
url: r25[10].MESSAGE(channelId, messageId),
body,
retries: 1,
oldFormErrors: true,
signal: abortController.signal,
rejectWithError: true,
onRequestCreated: () => {
env25716.$parent[0].requests.set(env25716[0], env25716[1]);
}
};
if (isCrossposted) {
r29.failImmediatelyWhenRateLimited = true;
}
(0, r25[0])(r25[2][12]).HTTP.patch(r29, responseHandler);
};
}
let c3887_16, prototype, c3888_0;
let env3887;
let env3888;
const r3 = env3887 = {};
const _excluded = ["channelId", "analyticsLocation"];
const _excluded2 = ["channelId", "analyticsLocation"];
const c3887_13 = {
SEND: 0,
0: "SEND",
EDIT: 1,
1: "EDIT",
COMMAND: 2,
2: "COMMAND",
SEND_ANNOUNCEMENT: 3,
3: "SEND_ANNOUNCEMENT"
};
const c3887_14 = [1 * Durations.Millis.MINUTE, 5 * Durations.Millis.MINUTE];
class MessageQueue extends Queue {
constructor(maxSize = 5) {
let env15503;
const logger = new Logger("MessageQueue");
super(logger);
const r21 = env15503 = {
$parent: env3887
};
env15503[0] = this;
this.requests = new Map();
this.analyticsTimeouts = new Map();
this.handleEdit = $mk77798(r21);
this.maxSize = maxSize;
}
isFull() {
return this.queue.length >= this.maxSize;
}
drain(a0, a1) {
this.logger.log("Draining Message Queue with: ", a0.type);
const type = a0.type;
if (c3887_13.SEND === type) {
this.handleSend(a0.message, a1);
} else if (c3887_13.SEND_ANNOUNCEMENT === type) {
this.handleSendAnnouncement(a0.message, a1);
} else if (c3887_13.EDIT === type) {
this.handleEdit(a0.message, a1);
} else if (c3887_13.COMMAND === type) {
this.handleCommand(a0.message, a1);
}
}
cancelRequest(a0) {
this.logger.log("Cancel message send: ", a0);
const r9 = this.requests.get(a0);
if (r9 != null) {
r9.abort();
}
this.requests.delete(a0);
this.cancelQueueMetricTimers(a0);
}
cancelPendingSendRequests(a0) {
const r1 = [];
const r6 = [];
while (this.queue.length > 0) {
const r8 = this.queue.shift();
const message = r8.message;
if (message.type === c3887_13.SEND && message.message.channelId === a0) {
r1.push(message.message);
} else {
r6.push(r8);
}
}
const queue = this.queue;
queue.push.apply(queue, [...r6]);
this.logger.log("Cancel pending send requests", r1.length);
return r1;
}
clear() {
this.requests.forEach((request) => request.abort());
this.requests.clear();
this.analyticsTimeouts.forEach((analyticsTimeout, index) => this.cancelQueueMetricTimers(index));
Reflect.get(Object.getPrototypeOf(prototype), "clear", this).call(this);
}
startQueueMetricTimers(a0) {
this.analyticsTimeouts.set(a0, c3887_14.map((item) => {
const queued_duration_ms = item;
return setTimeout(() => {
trackWithMetadata(AnalyticEvents.SEND_MESSAGE_QUEUED, {
queued_duration_ms
});
}, item);
}));
}
cancelQueueMetricTimers(a0) {
const r5 = this.analyticsTimeouts.get(a0);
if (r5 != null) {
r5.forEach(clearTimeout);
}
this.analyticsTimeouts.delete(a0);
}
createResponseHandler(c15505_1, c15505_0) {
return (a0) => {
if (c15505_1 != null) {
this.requests.delete(c15505_1);
this.cancelQueueMetricTimers(c15505_1);
}
if (a0.hasErr) {
return c15505_0(null, a0);
}
L12: {
L7: {
if (a0.body != null) {
if (a0.body.code !== AbortCodes.SLOWMODE_RATE_LIMITED && a0.body.code !== AbortCodes.CHANNEL_FOLLOWING_EDIT_RATE_LIMITED) {
break L7;
}
c15505_0(null, a0);
break L12;
}
}
if (a0.status === 429) {
const r8 = parseInt(a0.headers["retry-after"]);
const isNaN2 = isNaN(r8);
if (isNaN2) {
c15505_0(null, a0);
} else {
c15505_0({
retryAfter: r8 * Durations.Millis.SECOND
});
}
} else {
c15505_0(null, a0);
}
}
};
}
handleSend(a0, a1) {
const { channelId, analyticsLocation, ...rest } = a0;
let location2 = getOverlayMessageAnaylticsLocation_native();
if (location2 == null) {
location2 = analyticsLocation;
}
const context = location2 != null ? {
location: location2
} : void 0;
const signalStrength = getSignalStrength();
const body = {
mobile_network_type: NetworkStore.getType(),
...rest,
...signalStrength != null && {
signal_strength: signalStrength
}
};
if (DevSettingsStore.get("send_fail_100")) {
this.logger.log("Skipping message send because send_fail_100 is enabled");
a1(null, {
ok: false,
hasErr: false,
status: 500,
headers: {},
body: "{}",
text: "Simulated failure"
});
return void 0;
}
const responseHandler = this.createResponseHandler(a0.nonce, a1);
const abortController = new AbortController();
let c15506_0 = abortController;
this.startQueueMetricTimers(a0.nonce);
HTTP.post({
url: Endpoints.MESSAGES(channelId),
body,
context,
oldFormErrors: true,
...MESSAGE_HTTP_TIMEOUT_RETRY_OPTIONS,
signal: abortController.signal,
rejectWithError: true,
onRequestCreated: () => {
if (a0.nonce != null) {
this.requests.set(a0.nonce, c15506_0);
}
}
}, responseHandler);
}
handleSendAnnouncement(a0, a1) {
const { channelId, analyticsLocation, ...rest } = a0;
let location2 = getOverlayMessageAnaylticsLocation_native();
if (location2 == null) {
location2 = analyticsLocation;
}
const context = location2 != null ? {
location: location2
} : void 0;
const signalStrength = getSignalStrength();
const body = {
mobile_network_type: NetworkStore.getType(),
...rest,
...signalStrength != null && {
signal_strength: signalStrength
}
};
if (DevSettingsStore.get("send_fail_100")) {
this.logger.log("Skipping message send because send_fail_100 is enabled");
a1(null, {
ok: false,
hasErr: false,
status: 500,
headers: {},
body: "{}",
text: "Simulated failure"
});
return void 0;
}
const responseHandler = this.createResponseHandler(a0.nonce, a1);
const abortController = new AbortController();
let c15507_0 = abortController;
this.startQueueMetricTimers(a0.nonce);
HTTP.post({
url: Endpoints.MESSAGES_ANNOUNCEMENT(channelId),
body,
context,
oldFormErrors: true,
...MESSAGE_HTTP_TIMEOUT_RETRY_OPTIONS,
signal: abortController.signal,
rejectWithError: true,
onRequestCreated: () => {
if (a0.nonce != null) {
this.requests.set(a0.nonce, c15507_0);
}
}
}, responseHandler);
}
handleCommand({ applicationId, guildId, channelId, data, nonce, attachments, maxSizeCallback, analytics_location, sectionName, source }, a1) {
let c15508_0;
c15508_0 = void 0;
const body = {
type: InteractionTypes.APPLICATION_COMMAND,
application_id: applicationId,
guild_id: guildId,
channel_id: channelId,
session_id: AuthenticationStore.getSessionId(),
data,
nonce,
analytics_location,
section_name: sectionName,
source
};
if (attachments != null) {
body.data.attachments = attachments.map((attachment, index) => {
Module38(attachment.status === CloudUploadStatus.COMPLETED, "Uploads must be staged before trying to send a message");
return getAttachmentPayload(attachment, index);
});
}
const abortController = new AbortController();
c15508_0 = abortController;
HTTP.post({
url: Endpoints.INTERACTIONS,
body,
signal: abortController.signal,
rejectWithError: true,
onRequestCreated: (a0) => {
this.requests.set(nonce, c15508_0);
a0.on("progress", ({ total }) => {
const r14 = maxFileSize(guildId);
if (total != null && total > r14) {
this.cancelRequest(nonce);
if (maxSizeCallback != null) {
maxSizeCallback(r14);
}
}
});
}
}, this.createResponseHandler(nonce, a1));
}
}
const prototype2 = MessageQueue.prototype;
c3887_16 = MessageQueue;
prototype = prototype2;
const prototypeOf = Object.getPrototypeOf(MessageQueue);
const logger = new Logger("MessageQueue");
const r86 = Object.create(MessageQueue.prototype);
const r89 = $callWithNewTarget(prototypeOf, r86, MessageQueue, logger);
const r90 = r89 instanceof Object ? r89 : r86;
const r92 = env3888 = {
$parent: r3
};
c3888_0 = r90;
r90.requests = new Map();
r90.analyticsTimeouts = new Map();
r90.handleEdit = $mk77798(r92);
r90.maxSize = 5;
export default r90;
export { c3887_13 as MessageDataType };
export function isMessageDataSend(a0) {
const type = a0.type;
return type === c3887_13.SEND || a0.type === c3887_13.SEND_ANNOUNCEMENT;
}
export function isMessageDataEdit(a0) {
return a0.type === c3887_13.EDIT;
}
export function isMessageDataCommand(a0) {
return a0.type === c3887_13.COMMAND;
}
export function getFailedMessageId(a0) {
const type = a0.type;
return type === c3887_13.SEND || a0.type === c3887_13.SEND_ANNOUNCEMENT ? a0.message.nonce : a0.type === c3887_13.EDIT ? a0.message.messageId : a0.message.data.id;
}
+40
View File
@@ -0,0 +1,40 @@
// Metro module 15743 (f15744).
class ModalRegistry {
constructor(a0) {
this.modals = a0;
this.stores = (function calculateStores(a0) {
const set = new Set();
for (const item of a0) {
for (const store of item.stores) {
set.add(store);
}
}
return Array.from(set);
})(a0);
}
getStores() {
return this.stores;
}
getOpenModal() {
const key = this.modals.findIndex((modal) => modal.isOpen());
if (key === -1) {
return null;
}
const r10 = this.modals[key];
const getProps = r10.getProps;
let props = getProps == null ? void 0 : getProps.call(r10);
if (props == null) {
props = {};
}
return {
key,
component: r10.getComponent(),
props,
closable: r10.closable == null || r10.closable,
backdropInstant: r10.backdropInstant != null && r10.backdropInstant,
backdropStyle: r10.backdropStyle,
disableAnimation: r10.disableAnimation != null && r10.disableAnimation
};
}
}
export default ModalRegistry;
+40
View File
@@ -0,0 +1,40 @@
// Metro module 3820 (f3821).
class MuteTimers {
timers = {};
reset() {
Object.values(this.timers).forEach((item) => clearTimeout(item));
this.timers = {};
}
setTimer(a0, a1, a2) {
if (a0 == null) {
return false;
}
if (a1 == null) {
return false;
}
const r10 = a1.end_time == null ? null : new Date(a1.end_time).getTime() - Date.now();
let r22 = r10 != null;
if (r22) {
let r23 = r10 <= 0;
if (!r23) {
this.timers[a0] = setTimeout(a2, Math.max(0, r10));
r23 = false;
}
r22 = r23;
}
return r22;
}
clearTimer(a0) {
if (a0 != null && a0 in this.timers) {
clearTimeout(this.timers[a0]);
delete this.timers[a0];
}
}
}
export default MuteTimers;
export function computeIsMuted({ muted, mute_config }) {
return !!muted && (mute_config == null || mute_config.end_time == null || new Date(mute_config.end_time) >= new Date());
}
export function isTemporarilyMuted({ muted, mute_config }) {
return !!muted && mute_config != null && mute_config.end_time != null && new Date(mute_config.end_time) >= new Date();
}
+79
View File
@@ -0,0 +1,79 @@
// Metro module 12875 (f12876).
import NetworkStore from "../stores/NetworkStore";
import { NetworkConnectionSpeeds, NetworkConnectionTypes } from "../Constants";
import { now } from "../_bundle/sleep";
class NetworkQuality {
_networkStats = this._initStats();
_lastSampleTimestamp = now();
_initStats() {
const r0 = {
effectiveConnectionSpeedBuckets: {},
connectionTypeBuckets: {}
};
let c20278_0 = r0;
Object.values(NetworkConnectionTypes).forEach((item) => {
c20278_0.connectionTypeBuckets[item] = 0;
});
Object.values(NetworkConnectionSpeeds).forEach((item) => {
c20278_0.effectiveConnectionSpeedBuckets[item] = 0;
});
return r0;
}
getStats() {
const _networkStats = this._networkStats;
const r9 = _networkStats.connectionTypeBuckets[NetworkConnectionTypes.WIFI];
const duration_connection_type_wifi = r9 != null ? Math.round(r9) : 0;
const r10 = _networkStats.connectionTypeBuckets[NetworkConnectionTypes.CELLULAR];
const duration_connection_type_cellular = r10 != null ? Math.round(r10) : 0;
const r24 = _networkStats.connectionTypeBuckets[NetworkConnectionTypes.ETHERNET];
const duration_connection_type_ethernet = r24 != null ? Math.round(r24) : 0;
const r32 = _networkStats.connectionTypeBuckets[NetworkConnectionTypes.BLUETOOTH];
const duration_connection_type_bluetooth = r32 != null ? Math.round(r32) : 0;
const r40 = _networkStats.connectionTypeBuckets[NetworkConnectionTypes.OTHER];
const duration_connection_type_other = r40 != null ? Math.round(r40) : 0;
const r48 = _networkStats.connectionTypeBuckets[NetworkConnectionTypes.UNKNOWN];
const duration_connection_type_unknown = r48 != null ? Math.round(r48) : 0;
const r56 = _networkStats.connectionTypeBuckets[NetworkConnectionTypes.NONE];
const duration_connection_type_none = r56 != null ? Math.round(r56) : 0;
const r65 = _networkStats.effectiveConnectionSpeedBuckets[NetworkConnectionSpeeds.TWO_G];
const duration_effective_connection_speed_2g = r65 != null ? Math.round(r65) : 0;
const r73 = _networkStats.effectiveConnectionSpeedBuckets[NetworkConnectionSpeeds.THREE_G];
const duration_effective_connection_speed_3g = r73 != null ? Math.round(r73) : 0;
const r81 = _networkStats.effectiveConnectionSpeedBuckets[NetworkConnectionSpeeds.FOUR_G];
const duration_effective_connection_speed_4g = r81 != null ? Math.round(r81) : 0;
const r89 = _networkStats.effectiveConnectionSpeedBuckets[NetworkConnectionSpeeds.FIVE_G];
const duration_effective_connection_speed_5g = r89 != null ? Math.round(r89) : 0;
const r97 = _networkStats.effectiveConnectionSpeedBuckets[NetworkConnectionSpeeds.UNKNOWN];
return {
duration_connection_type_wifi,
duration_connection_type_cellular,
duration_connection_type_ethernet,
duration_connection_type_bluetooth,
duration_connection_type_other,
duration_connection_type_unknown,
duration_connection_type_none,
duration_effective_connection_speed_2g,
duration_effective_connection_speed_3g,
duration_effective_connection_speed_4g,
duration_effective_connection_speed_5g,
duration_effective_connection_speed_unknown: r97 != null ? Math.round(r97) : 0
};
}
incrementNetworkStats(a0) {
const r10 = (a0 - this._lastSampleTimestamp) / 1000;
let r7 = NetworkStore.getEffectiveConnectionSpeed();
if (r7 === NetworkConnectionSpeeds.SLOW_TWO_G) {
r7 = NetworkConnectionSpeeds.TWO_G;
}
let r14 = NetworkStore.getType();
if (r14 === NetworkConnectionTypes.WIMAX) {
r14 = NetworkConnectionTypes.WIFI;
}
const effectiveConnectionSpeedBuckets = this._networkStats.effectiveConnectionSpeedBuckets;
effectiveConnectionSpeedBuckets[r7] = effectiveConnectionSpeedBuckets[r7] + r10;
const connectionTypeBuckets = this._networkStats.connectionTypeBuckets;
connectionTypeBuckets[r14] = connectionTypeBuckets[r14] + r10;
this._lastSampleTimestamp = a0;
}
}
export default NetworkQuality;
+111
View File
@@ -0,0 +1,111 @@
// Metro module 12777 (f12778).
let c8808_0 = {
IDLE: "idle",
LOADING: "loading",
SUCCESS: "success",
ERROR: "error"
};
let c8808_1 = {
IDLE: "idle",
LOADING: "loading",
VALID: "valid",
STALE: "stale",
ERROR: "error"
};
export { c8808_1 as NetworkTtlCacheStatus };
export class NetworkTtlCache {
constructor(r2 = {}) {
const r7 = {
__proto__: new.target.prototype,
value: null,
fetchState: c8808_0.IDLE,
fetchedAt: null
};
let ttlMs = r2.ttlMs;
if (ttlMs == null) {
ttlMs = null;
}
r7.ttlMs = ttlMs;
return r7;
}
setTtl(a0) {
this.ttlMs = a0;
}
setLoading() {
this.fetchState = c8808_0.LOADING;
}
setValue(a0) {
this.value = a0;
this.fetchState = c8808_0.SUCCESS;
this.fetchedAt = Date.now();
}
setError() {
this.fetchState = c8808_0.ERROR;
}
clear() {
this.value = null;
this.fetchState = c8808_0.IDLE;
this.fetchedAt = null;
}
getValue() {
return this.value;
}
getFetchState() {
return this.fetchState;
}
getFetchedAt() {
return this.fetchedAt;
}
forceExpire() {
this.fetchedAt = null;
}
isExpired() {
return this.ttlMs != null && (this.fetchedAt == null || Date.now() - this.fetchedAt >= this.ttlMs);
}
shouldFetch() {
return this.fetchState !== c8808_0.LOADING && (this.fetchState === c8808_0.IDLE || this.isExpired());
}
isLoading() {
return this.fetchState === c8808_0.LOADING;
}
isValid() {
return this.fetchState === c8808_0.SUCCESS && !this.isExpired();
}
isError() {
return this.fetchState === c8808_0.ERROR;
}
getStatus() {
const fetchState = this.fetchState;
if (c8808_0.IDLE === fetchState) {
return c8808_1.IDLE;
}
if (c8808_0.LOADING === fetchState) {
return c8808_1.LOADING;
}
if (c8808_0.ERROR === fetchState) {
return c8808_1.ERROR;
}
if (c8808_0.SUCCESS === fetchState) {
return this.isExpired() ? c8808_1.STALE : c8808_1.VALID;
}
}
getValueWithStatus() {
return {
value: this.value,
status: this.getStatus()
};
}
serialize() {
return this.value == null ? null : this.fetchedAt == null ? null : {
value: this.value,
fetchedAt: this.fetchedAt
};
}
restore(a0) {
if (a0 != null) {
this.value = a0.value;
this.fetchedAt = a0.fetchedAt;
this.fetchState = c8808_0.SUCCESS;
}
}
}
+104
View File
@@ -0,0 +1,104 @@
// Metro module 1412 (f1413).
import Module1413, { TypeTag } from "../_bundle/Module1413";
import Module38 from "../_bundle/Module38";
import { areSetsEqual } from "../_bundle/Module1414";
import shallowEqual, { areArraysShallowEqual } from "../_bundle/shallowEqual";
let isPlainRecordDataEqual;
const isValueEqual = function isValueEqual(a0, a1) {
let r1;
L22: {
if (a0 != null && a1 != null) {
r1 = a0 === a1;
if (r1) {
break L22;
}
r1 = a0 instanceof Date && a1 instanceof Date ? a0.getTime() === a1.getTime() : a0 instanceof Set && a1 instanceof Set ? areSetsEqual(a0, a1) : Array.isArray(a0) && Array.isArray(a1) ? areArraysShallowEqual(a0, a1) : (typeof a0 === "object" ? typeof a1 === "object" : typeof a0 === "object") && shallowEqual(a0, a1);
} else {
r1 = a0 === a1;
}
}
return r1;
};
isPlainRecordDataEqual = function isPlainRecordDataEqual(a0, a1) {
if (a0 === a1) {
return true;
}
for (const item of Object.keys(a0)) {
if (isValueEqual(a0[item], a1[item])) {
continue;
}
return false;
}
return true;
};
export default Module1413;
export { TypeTag };
export function set(a0, a1, a2) {
const isValueEqual2 = isValueEqual(a0[a1], a2);
let r10 = a0;
if (!isValueEqual2) {
const r11 = {
...a0
};
r11[a1] = a2;
r10 = r11;
}
return r10;
}
export function merge(a0, a1) {
let r12;
let r4 = a0;
let r6 = null;
let r5 = null;
for (const key in a1) {
r12 = r6;
r5 = r12;
const r17 = a0[key];
const r14 = a1[key];
const r13 = r14 === void 0 || isValueEqual(r17, r14);
r6 = r12;
if (!r13) {
if (r12 == null) {
const r20 = {
...a0
};
r20[key] = r14;
r12 = r20;
} else {
r12[key] = r14;
}
r6 = r12;
}
}
r12 = r6;
r5 = r12;
if (r5 != null) {
r4 = r5;
}
return r4;
}
export function tryReuseExistingInPlacePlainRecord(a0, a1, a2) {
let r4 = a1;
Module38(a1 == null || a1[TypeTag] === a0, "Existing record type does not match the expected type");
if (!(a1 != null && isPlainRecordDataEqual(a1, a2))) {
a2[TypeTag] = a0;
r4 = a2;
}
return r4;
}
export function objectIsPlainRecordOfType(a0, a1) {
return (typeof a1 === "object" ? a1 != null : typeof a1 === "object") && (TypeTag in a1 && a1[TypeTag]) === a0;
}
export function constructInPlace(a0, a1) {
a1[TypeTag] = a0;
return a1;
}
export function copyConstruct(a0, a1) {
const r0 = {
...a1
};
r0[TypeTag] = a0;
return r0;
}
export { isValueEqual };
export { isPlainRecordDataEqual };
+613
View File
@@ -0,0 +1,613 @@
// Metro module 4871 (f4872).
import { PlatformTypes } from "../Constants";
import { ApplicationIdentityConnections } from "../modules/user_application_identity/UserApplicationIdentityConstants";
import { unsafe_getRawColor } from "../_bundle/Module711";
import * as _Module4873 from "../_bundle/Module4873";
import * as _Module4874 from "../_bundle/Module4874";
import * as _Module4875 from "../_bundle/Module4875";
import * as _Module4876 from "../_bundle/Module4876";
import * as _Module4877 from "../_bundle/Module4877";
import * as _Module4878 from "../_bundle/Module4878";
import * as _Module4879 from "../_bundle/Module4879";
import * as _Module4880 from "../_bundle/Module4880";
import * as _Module4881 from "../_bundle/Module4881";
import * as _Module4882 from "../_bundle/Module4882";
import * as _Module4883 from "../_bundle/Module4883";
import * as _Module4884 from "../_bundle/Module4884";
import { battlenetSocialSDKMigrationExperiment, getIsRiotSocialSDKMigrationEnabled, useIsRiotSocialSDKMigrationEnabled } from "../modules/application_account_linking/experiments/socialSDKMigration";
import * as _Module4885 from "../_bundle/Module4885";
import * as _Module4886 from "../_bundle/Module4886";
import * as _Module4887 from "../_bundle/Module4887";
import * as _Module4888 from "../_bundle/Module4888";
import * as _Module4889 from "../_bundle/Module4889";
import * as _Module4890 from "../_bundle/Module4890";
import * as _Module4891 from "../_bundle/Module4891";
import * as _Module4892 from "../_bundle/Module4892";
import * as _Module4893 from "../_bundle/Module4893";
import * as _Module4894 from "../_bundle/Module4894";
import * as _Module4895 from "../_bundle/Module4895";
import * as _Module4896 from "../_bundle/Module4896";
import * as _Module4897 from "../_bundle/Module4897";
import * as _Module4898 from "../_bundle/Module4898";
import * as _Module4899 from "../_bundle/Module4899";
import * as _Module4900 from "../_bundle/Module4900";
import * as _Module4901 from "../_bundle/Module4901";
import * as _Module4902 from "../_bundle/Module4902";
import * as _Module4903 from "../_bundle/Module4903";
import * as _Module4904 from "../_bundle/Module4904";
import * as _Module4905 from "../_bundle/Module4905";
import * as _Module4906 from "../_bundle/Module4906";
import * as _Module4907 from "../_bundle/Module4907";
import * as _Module4908 from "../_bundle/Module4908";
import * as _Module4909 from "../_bundle/Module4909";
import * as _Module4910 from "../_bundle/Module4910";
import * as _Module4911 from "../_bundle/Module4911";
import * as _Module4912 from "../_bundle/Module4912";
import * as _Module4913 from "../_bundle/Module4913";
import * as _Module4914 from "../_bundle/Module4914";
import * as _Module4915 from "../_bundle/Module4915";
import * as _Module4916 from "../_bundle/Module4916";
import * as _Module4917 from "../_bundle/Module4917";
import * as _Module4918 from "../_bundle/Module4918";
import * as _Module4919 from "../_bundle/Module4919";
import * as _Module4920 from "../_bundle/Module4920";
import * as _Module4921 from "../_bundle/Module4921";
import * as _Module4922 from "../_bundle/Module4922";
import * as _Module4923 from "../_bundle/Module4923";
import * as _Module4924 from "../_bundle/Module4924";
import * as _Module4925 from "../_bundle/Module4925";
import * as _Module4926 from "../_bundle/Module4926";
import * as _Module4927 from "../_bundle/Module4927";
import * as _Module4928 from "../_bundle/Module4928";
import * as _Module4929 from "../_bundle/Module4929";
import * as _Module4930 from "../_bundle/Module4930";
import * as _Module4931 from "../_bundle/Module4931";
import * as _Module4932 from "../_bundle/Module4932";
import * as _Module4933 from "../_bundle/Module4933";
import * as _Module4934 from "../_bundle/Module4934";
import * as _Module4935 from "../_bundle/Module4935";
import * as _Module4936 from "../_bundle/Module4936";
import * as _Module4937 from "../_bundle/Module4937";
import * as _Module4938 from "../_bundle/Module4938";
import * as _Module4939 from "../_bundle/Module4939";
import * as _Module4940 from "../_bundle/Module4940";
import * as _Module4941 from "../_bundle/Module4941";
import * as _Module4942 from "../_bundle/Module4942";
import * as _Module4943 from "../_bundle/Module4943";
import * as _Module4944 from "../_bundle/Module4944";
import * as _Module4945 from "../_bundle/Module4945";
import * as _Module4946 from "../_bundle/Module4946";
import * as _Module4947 from "../_bundle/Module4947";
import * as _Module4948 from "../_bundle/Module4948";
import * as _Module4949 from "../_bundle/Module4949";
import * as _Module4950 from "../_bundle/Module4950";
import * as _Module4951 from "../_bundle/Module4951";
import * as _Module4952 from "../_bundle/Module4952";
import * as _Module4953 from "../_bundle/Module4953";
import * as _Module4954 from "../_bundle/Module4954";
import * as _Module4955 from "../_bundle/Module4955";
import * as _Module4956 from "../_bundle/Module4956";
import * as _Module4957 from "../_bundle/Module4957";
import * as _Module4958 from "../_bundle/Module4958";
import * as _Module4959 from "../_bundle/Module4959";
import * as _Module4960 from "../_bundle/Module4960";
import * as _Module4961 from "../_bundle/Module4961";
import * as _Module4962 from "../_bundle/Module4962";
import * as _Module4963 from "../_bundle/Module4963";
import * as _Module4964 from "../_bundle/Module4964";
import * as _Module4965 from "../_bundle/Module4965";
import * as _Module4966 from "../_bundle/Module4966";
import * as _Module4967 from "../_bundle/Module4967";
import * as _Module4968 from "../_bundle/Module4968";
import * as _Module4969 from "../_bundle/Module4969";
import * as _Module4970 from "../_bundle/Module4970";
import * as _Module4971 from "../_bundle/Module4971";
import * as _Module4972 from "../_bundle/Module4972";
import * as _Module4973 from "../_bundle/Module4973";
import * as _Module4974 from "../_bundle/Module4974";
import * as _Module4975 from "../_bundle/Module4975";
import * as _Module4976 from "../_bundle/Module4976";
import * as _Module4977 from "../_bundle/Module4977";
import * as _Module4978 from "../_bundle/Module4978";
import * as _Module4979 from "../_bundle/Module4979";
import * as _Module4980 from "../_bundle/Module4980";
import * as _Module4981 from "../_bundle/Module4981";
import * as _Module4982 from "../_bundle/Module4982";
import * as _Module4983 from "../_bundle/Module4983";
import * as _Module4984 from "../_bundle/Module4984";
import * as _Module4985 from "../_bundle/Module4985";
import * as _Module4986 from "../_bundle/Module4986";
import * as _Module4987 from "../_bundle/Module4987";
import * as _Module4988 from "../_bundle/Module4988";
import * as _Module4989 from "../_bundle/Module4989";
import * as _Module4990 from "../_bundle/Module4990";
import * as _Module4991 from "../_bundle/Module4991";
import * as _Module4992 from "../_bundle/Module4992";
import * as _Module4993 from "../_bundle/Module4993";
import * as _Module4994 from "../_bundle/Module4994";
import Module12 from "../_bundle/Module12";
import URLUtils from "../utils/URLUtils";
let c3002_4, c3002_5;
let c3002_3 = [{
type: PlatformTypes.TWITCH,
name: "Twitch",
color: unsafe_getRawColor("PLATFORM_TWITCH"),
icon: {
lightPNG: _Module4873,
darkPNG: _Module4873,
whitePNG: _Module4874,
lightSVG: _Module4875,
darkSVG: _Module4875,
whiteSVG: _Module4876
},
enabled: true,
getPlatformUserUrl: (a0) => `https://www.twitch.tv/${encodeURIComponent(a0.name)}`,
domains: ["twitch.tv", "twitch.com"]
}, {
type: PlatformTypes.YOUTUBE,
name: "YouTube",
color: unsafe_getRawColor("PLATFORM_YOUTUBE"),
icon: {
lightPNG: _Module4877,
darkPNG: _Module4877,
whitePNG: _Module4878,
lightSVG: _Module4879,
darkSVG: _Module4879,
whiteSVG: _Module4880
},
enabled: true,
getPlatformUserUrl: (a0) => `https://www.youtube.com/channel/${encodeURIComponent(a0.id)}`,
domains: ["youtube.com", "youtu.be"]
}, {
type: PlatformTypes.BATTLENET,
name: "Battle.net",
color: unsafe_getRawColor("PLATFORM_BATTLENET"),
icon: {
lightPNG: _Module4881,
darkPNG: _Module4881,
whitePNG: _Module4882,
lightSVG: _Module4883,
darkSVG: _Module4883,
whiteSVG: _Module4884,
blackSVG: _Module4883
},
enabled: true,
migrationData: {
replacedBy: ApplicationIdentityConnections.BATTLENET,
getMigrationExperimentEnabled: (a0) => battlenetSocialSDKMigrationExperiment.getConfig({
location: a0
}).enabled,
useMigrationExperimentEnabled: (a0) => battlenetSocialSDKMigrationExperiment.useConfig({
location: a0
}).enabled,
helpCenterLink: "https://discord.com/blog/link-world-of-warcraft-with-discord"
}
}, {
type: PlatformTypes.BLUESKY,
name: "Bluesky",
icon: {
lightPNG: _Module4885,
darkPNG: _Module4885,
whitePNG: _Module4886,
lightSVG: _Module4887,
darkSVG: _Module4887,
whiteSVG: _Module4888
},
enabled: true,
getPlatformUserUrl: (a0) => `https://bsky.app/profile/${encodeURIComponent(a0.id).replaceAll("%3A", ":")}`,
isFederated: true,
hasMetadata: true
}, {
type: PlatformTypes.BUNGIE,
name: "Bungie.net",
color: unsafe_getRawColor("PLATFORM_BUNGIE"),
icon: {
lightPNG: _Module4889,
darkPNG: _Module4890,
whitePNG: _Module4891,
lightSVG: _Module4892,
darkSVG: _Module4893,
whiteSVG: _Module4894
},
enabled: true
}, {
type: PlatformTypes.SKYPE,
name: "Skype",
color: unsafe_getRawColor("PLATFORM_SKYPE"),
icon: {
lightPNG: _Module4895,
darkPNG: _Module4895,
whitePNG: _Module4896,
lightSVG: _Module4897,
darkSVG: _Module4897,
whiteSVG: _Module4898
},
enabled: false,
getPlatformUserUrl: (a0) => `skype:${encodeURIComponent(a0.id)}?userinfo`
}, {
type: PlatformTypes.LEAGUE_OF_LEGENDS,
name: "League of Legends",
color: unsafe_getRawColor("PLATFORM_LOL"),
icon: {
lightPNG: _Module4899,
darkPNG: _Module4899,
whitePNG: _Module4900,
lightSVG: _Module4901,
darkSVG: _Module4901,
whiteSVG: _Module4902
},
enabled: true,
migrationData: {
replacedBy: ApplicationIdentityConnections.RIOT_GAMES,
getMigrationExperimentEnabled: (a0) => getIsRiotSocialSDKMigrationEnabled({
location: a0
}),
useMigrationExperimentEnabled: (a0) => useIsRiotSocialSDKMigrationEnabled({
location: a0
}),
helpCenterLink: "https://www.riotgames.com/en/riot-games-discord-account-linking"
}
}, {
type: PlatformTypes.STEAM,
name: "Steam",
color: unsafe_getRawColor("PLATFORM_STEAM"),
icon: {
lightPNG: _Module4903,
darkPNG: _Module4904,
whitePNG: _Module4904,
lightSVG: _Module4905,
darkSVG: _Module4906,
whiteSVG: _Module4906
},
enabled: true,
getPlatformUserUrl: (a0) => `https://steamcommunity.com/profiles/${encodeURIComponent(a0.id)}`,
hasMetadata: true
}, {
type: PlatformTypes.REDDIT,
name: "Reddit",
color: unsafe_getRawColor("PLATFORM_REDDIT"),
icon: {
lightPNG: _Module4907,
darkPNG: _Module4907,
whitePNG: _Module4908,
lightSVG: _Module4909,
darkSVG: _Module4909,
whiteSVG: _Module4910
},
enabled: true,
domains: ["reddit.com"],
getPlatformUserUrl: (a0) => `https://www.reddit.com/u/${encodeURIComponent(a0.name)}`,
hasMetadata: true
}, {
type: PlatformTypes.FACEBOOK,
name: "Facebook",
color: unsafe_getRawColor("PLATFORM_FACEBOOK"),
icon: {
lightPNG: _Module4911,
darkPNG: _Module4911,
whitePNG: _Module4912,
lightSVG: _Module4913,
darkSVG: _Module4913,
whiteSVG: _Module4914
},
domains: ["facebook.com"],
enabled: true
}, {
type: PlatformTypes.TWITTER_LEGACY,
name: "Twitter",
color: unsafe_getRawColor("PLATFORM_TWITTER"),
icon: {
lightPNG: _Module4915,
darkPNG: _Module4915,
whitePNG: _Module4916,
lightSVG: _Module4917,
darkSVG: _Module4917,
whiteSVG: _Module4918
},
enabled: false,
getPlatformUserUrl: (a0) => `https://twitter.com/${encodeURIComponent(a0.name)}`,
domains: ["twitter.com"],
hasMetadata: true
}, {
type: PlatformTypes.TWITTER,
name: "X",
color: unsafe_getRawColor("PLATFORM_TWITTER"),
icon: {
lightPNG: _Module4919,
darkPNG: _Module4920,
whitePNG: _Module4921,
lightSVG: _Module4922,
darkSVG: _Module4923,
whiteSVG: _Module4924
},
enabled: true,
getPlatformUserUrl: (a0) => `https://x.com/${encodeURIComponent(a0.name)}`,
domains: ["x.com"],
hasMetadata: true
}, {
type: PlatformTypes.SPOTIFY,
name: "Spotify",
color: unsafe_getRawColor("PLATFORM_SPOTIFY"),
icon: {
lightPNG: _Module4925,
darkPNG: _Module4925,
whitePNG: _Module4926,
lightSVG: _Module4927,
darkSVG: _Module4927,
whiteSVG: _Module4928
},
enabled: true,
getPlatformUserUrl: (a0) => `https://open.spotify.com/user/${encodeURIComponent(a0.id)}`
}, {
type: PlatformTypes.XBOX,
name: "Xbox",
color: unsafe_getRawColor("PLATFORM_XBOX"),
icon: {
lightPNG: _Module4929,
darkPNG: _Module4930,
whitePNG: _Module4930,
lightSVG: _Module4931,
darkSVG: _Module4932,
whiteSVG: _Module4932,
customPNG: _Module4933
},
enabled: true
}, {
type: PlatformTypes.SAMSUNG,
name: "Samsung Galaxy",
color: unsafe_getRawColor("PLATFORM_SAMSUNG"),
icon: {
lightPNG: _Module4934,
darkPNG: _Module4934,
whitePNG: _Module4935,
lightSVG: _Module4936,
darkSVG: _Module4936,
whiteSVG: _Module4937
},
enabled: false
}, {
type: PlatformTypes.GITHUB,
name: "GitHub",
color: unsafe_getRawColor("PLATFORM_GITHUB"),
icon: {
lightPNG: _Module4938,
darkPNG: _Module4939,
whitePNG: _Module4939,
lightSVG: _Module4940,
darkSVG: _Module4941,
whiteSVG: _Module4941
},
enabled: true,
getPlatformUserUrl: (a0) => `https://github.com/${encodeURIComponent(a0.name)}`,
domains: ["github.com"]
}, {
type: PlatformTypes.PLAYSTATION,
name: "PlayStation Network",
color: unsafe_getRawColor("PLATFORM_PLAYSTATION"),
icon: {
lightPNG: _Module4942,
darkPNG: _Module4943,
whitePNG: _Module4943,
lightSVG: _Module4944,
darkSVG: _Module4945,
whiteSVG: _Module4945
},
enabled: true
}, {
type: PlatformTypes.PLAYSTATION_STAGING,
name: "PlayStation Network (Staging)",
color: unsafe_getRawColor("PLATFORM_PLAYSTATION"),
icon: {
lightPNG: _Module4943,
darkPNG: _Module4942,
whitePNG: _Module4942,
lightSVG: _Module4945,
darkSVG: _Module4944,
whiteSVG: _Module4944
},
enabled: false
}, {
type: PlatformTypes.EPIC_GAMES,
name: "Epic Games",
icon: {
lightPNG: _Module4946,
darkPNG: _Module4947,
whitePNG: _Module4947,
lightSVG: _Module4948,
darkSVG: _Module4949,
whiteSVG: _Module4949
},
enabled: true
}, {
type: PlatformTypes.RIOT_GAMES,
name: "Riot Games",
icon: {
lightPNG: _Module4950,
darkPNG: _Module4950,
whitePNG: _Module4951,
lightSVG: _Module4952,
darkSVG: _Module4952,
whiteSVG: _Module4953,
blackSVG: _Module4954
},
enabled: true,
migrationData: {
replacedBy: ApplicationIdentityConnections.RIOT_GAMES,
getMigrationExperimentEnabled: (a0) => getIsRiotSocialSDKMigrationEnabled({
location: a0
}),
useMigrationExperimentEnabled: (a0) => useIsRiotSocialSDKMigrationEnabled({
location: a0
}),
helpCenterLink: "https://www.riotgames.com/en/riot-games-discord-account-linking"
}
}, {
type: PlatformTypes.ROBLOX,
name: "Roblox",
icon: {
lightPNG: _Module4955,
darkPNG: _Module4956,
whitePNG: _Module4957,
lightSVG: _Module4958,
darkSVG: _Module4959,
whiteSVG: _Module4960
},
enabled: true,
getPlatformUserUrl: (a0) => `https://roblox.com/users/${encodeURIComponent(a0.id)}/profile`
}, {
type: PlatformTypes.PAYPAL,
name: "PayPal",
icon: {
lightPNG: _Module4961,
darkPNG: _Module4961,
whitePNG: _Module4962,
lightSVG: _Module4963,
darkSVG: _Module4963,
whiteSVG: _Module4964
},
enabled: true,
hasMetadata: true
}, {
type: PlatformTypes.EBAY,
name: "eBay",
icon: {
lightPNG: _Module4965,
darkPNG: _Module4965,
whitePNG: _Module4966,
lightSVG: _Module4967,
darkSVG: _Module4967,
whiteSVG: _Module4968
},
enabled: true,
hasMetadata: true,
getPlatformUserUrl: (a0) => `https://www.ebay.com/usr/${encodeURIComponent(a0.name)}`
}, {
type: PlatformTypes.TIKTOK,
name: "TikTok",
icon: {
lightPNG: _Module4969,
darkPNG: _Module4970,
whitePNG: _Module4970,
lightSVG: _Module4971,
darkSVG: _Module4972,
whiteSVG: _Module4972
},
enabled: false,
hasMetadata: true,
domains: ["tiktok.com"],
getPlatformUserUrl: (a0) => `https://www.tiktok.com/@${encodeURIComponent(a0.name)}`
}, {
type: PlatformTypes.INSTAGRAM,
name: "Instagram",
icon: {
lightPNG: _Module4973,
darkPNG: _Module4973,
whitePNG: _Module4974,
lightSVG: _Module4975,
darkSVG: _Module4975,
whiteSVG: _Module4976
},
enabled: false,
domains: ["instagram.com"],
getPlatformUserUrl: (a0) => `https://www.instagram.com/${encodeURIComponent(a0.name)}`
}, {
type: PlatformTypes.MASTODON,
name: "Mastodon",
icon: {
lightPNG: _Module4977,
darkPNG: _Module4977,
whitePNG: _Module4978,
lightSVG: _Module4979,
darkSVG: _Module4979,
whiteSVG: _Module4980
},
enabled: false,
getPlatformUserUrl: (a0) => a0.id,
isFederated: true,
hasMetadata: true
}, {
type: PlatformTypes.CRUNCHYROLL,
name: "Crunchyroll",
color: unsafe_getRawColor("PLATFORM_CRUNCHYROLL"),
icon: {
lightPNG: _Module4981,
darkPNG: _Module4981,
whitePNG: _Module4981,
lightSVG: _Module4982,
darkSVG: _Module4982,
whiteSVG: _Module4983
},
enabled: true
}, {
type: PlatformTypes.DOMAIN,
name: "Domain",
icon: {
lightPNG: _Module4984,
darkPNG: _Module4985,
whitePNG: _Module4985,
lightSVG: _Module4986,
darkSVG: _Module4987,
whiteSVG: _Module4987
},
getPlatformUserUrl: (a0) => `https://${a0.id}/`,
enabled: true
}, {
type: PlatformTypes.AMAZON_MUSIC,
name: "Amazon Music",
icon: {
lightPNG: _Module4988,
darkPNG: _Module4988,
whitePNG: _Module4988,
lightSVG: _Module4989,
darkSVG: _Module4989,
whiteSVG: _Module4989
},
enabled: true
}, {
type: PlatformTypes.META_QUEST_OR_HORIZON,
name: "Meta Quest",
icon: {
lightPNG: _Module4990,
darkPNG: _Module4991,
whitePNG: _Module4992,
lightSVG: _Module4993,
darkSVG: _Module4994,
whiteSVG: _Module4994
},
enabled: false
}];
c3002_4 = Module12.keyBy(c3002_3, "type");
c3002_5 = {};
c3002_3.forEach((item) => {
const domains = item.domains;
if (domains != null) {
domains.forEach((domain) => {
c3002_5[domain] = item;
});
}
});
const r610 = {
get: (a0) => {
let r4 = c3002_4[a0];
if (r4 == null) {
r4 = null;
}
return r4;
},
getByUrl: (a0) => {
const r10 = URLUtils.toURLSafe(a0);
if (r10 != null) {
const hostname = r10.hostname;
return c3002_5[hostname.startsWith("www.") ? hostname.slice(4) : hostname];
}
},
isSupported: (a0) => Object.prototype.hasOwnProperty.call(c3002_4, a0),
map: (a0) => c3002_3.map(a0),
filter: (a0) => {
const r5 = c3002_3.filter(a0);
r5.sort((a, b) => a.name.localeCompare(b.name));
return r5;
},
find: (a0) => c3002_3.find(a0)
};
export default r610;
+353
View File
@@ -0,0 +1,353 @@
// Metro module 10109 (f10110).
let c6729_0, _nonTokenType;
const getMatch2 = function getMatch(a0, a1, a2) {
if (a1 == null) {
return null;
}
const r5 = 0 < a1.length;
let r1 = 0;
if (r5) {
do {
const r18 = a1[r1];
const r25 = a0.match(r18.regex);
const r26 = r25 == null;
const r3 = r1;
let r10 = null;
if (!r26) {
const r27 = [...r25];
r27.index = a2;
r10 = r27;
}
L36: {
if (r10 != null) {
const cache2 = r18.cache;
let r28 = cache2 != null;
let r11 = void 0;
if (r28) {
const r31 = cache2.get(r10[0]);
r28 = r31 != null;
r11 = r31;
}
let r32 = r11;
if (r28) {
const r37 = {
__proto__: Token.prototype
};
if (r11 instanceof Token) {
r37.match = [...r11.match];
r37.start = r11.start;
r37.type = r11.type;
if (r11._data != null) {
r37._data = r11._data;
}
} else if (r11 != null) {
r37.match = [...r11];
let start = 0;
if (typeof r11 !== "string") {
let index = r11.index;
if (index == null) {
index = 0;
}
start = index;
}
r37.start = start;
r37.type = void 0;
} else {
r37.match = [];
r37.start = 0;
r37.type = void 0;
}
r37.start = r10.index;
r32 = r37;
}
if (r32 == null) {
const type2 = r18.type;
const r63 = {
__proto__: Token.prototype
};
if (r10 instanceof Token) {
r63.match = [...r10.match];
r63.start = r10.start;
r63.type = r10.type;
if (r10._data != null) {
r63._data = r10._data;
}
} else if (r10 != null) {
r63.match = [...r10];
let start2 = 0;
if (typeof r10 !== "string") {
let index2 = r10.index;
if (index2 == null) {
index2 = 0;
}
start2 = index2;
}
r63.start = start2;
r63.type = type2;
} else {
r63.match = [];
r63.start = 0;
r63.type = type2;
}
if (r18.validator != null && !r18.validator(r63)) {
break L36;
}
const r87 = cache2 == null || (cache2 == null ? void 0 : cache2.has(r10[0]));
r32 = r63;
if (!r87) {
cache2.set(r10[0], r63);
r32 = r63;
}
}
return r32;
}
}
r1 = r3 + 1;
} while (r1 < a1.length);
}
return null;
};
c6729_0 = /.+/g;
_nonTokenType = "NON_TOKEN";
export class QueryTokenizer {
constructor(r4 = []) {
this._rules = [];
this._followers = {};
this._nonTokenType = _nonTokenType;
this.reset();
r4.forEach((item) => this.addRule(item));
}
reset() {
this._rules = [];
this._followers = {};
this._nonTokenType = _nonTokenType;
}
addRule({ type, follows, validator, regex: regex2 }) {
let cache;
let regex = regex2;
const r19 = regex2.source.charAt(0);
let regex3 = regex2;
if (r19 !== "^") {
const regExp = new RegExp(`^${regex2.source}`, regex2.flags);
regex = regExp;
regex3 = regExp;
}
const r3 = validator != null;
let cache2 = void 0;
if (r3) {
cache = new Map();
cache2 = cache;
}
if (follows != null) {
follows.forEach((follow) => {
if (this._followers[follow] == null) {
this._followers[follow] = [];
}
this._followers[follow].push({
regex,
type,
validator,
cache
});
});
} else {
this._rules.push({
regex: regex3,
type,
validator,
cache: cache2
});
}
}
tokenize(a0) {
let r19, r36, r37, length2;
let r15 = a0;
const r5 = [];
const r3 = a0.length > 0;
let r11 = 0;
let r8 = "";
let r14 = void 0;
let index3 = 0;
let r13 = "";
if (r3) {
do {
const r34 = this._getMatch(r15, r14, r11 + r8.length);
const index4 = r11;
const r20 = r8;
const r23 = r15;
let r18 = r14;
if (r34 != null) {
if (r20 !== "") {
const r27 = r20.match(c6729_0);
const r38 = r27 == null;
let r39 = null;
if (!r38) {
const r40 = [...r27];
r40.index = index4;
r39 = r40;
}
const _nonTokenType2 = this._nonTokenType;
const r46 = {
__proto__: Token.prototype
};
if (r39 instanceof Token) {
r46.match = [...r39.match];
r46.start = r39.start;
r46.type = r39.type;
if (r39._data != null) {
r46._data = r39._data;
}
} else if (r39 != null) {
r46.match = [...r39];
let start = 0;
if (typeof r39 !== "string") {
let index = r39.index;
if (index == null) {
index = 0;
}
start = index;
}
r46.start = start;
r46.type = _nonTokenType2;
} else {
r46.match = [];
r46.start = 0;
r46.type = _nonTokenType2;
}
r5.push(r46);
}
r5.push(r34);
r37 = index4 + (r34.length + r20.length);
r19 = r23.substring(r34.length);
r36 = "";
r18 = r34;
} else {
r36 = r20 + r23[0];
r19 = r23.substring(1);
r37 = index4;
}
length2 = r19.length;
r11 = r37;
r8 = r36;
r15 = r19;
r14 = r18;
index3 = r11;
r13 = r8;
} while (length2 > 0);
}
if (r13 !== "") {
const r78 = r13.match(c6729_0);
const r79 = r78 == null;
let r80 = null;
if (!r79) {
const r81 = [...r78];
r81.index = index3;
r80 = r81;
}
const _nonTokenType3 = this._nonTokenType;
const r91 = {
__proto__: Token.prototype
};
if (r80 instanceof Token) {
r91.match = [...r80.match];
r91.start = r80.start;
r91.type = r80.type;
if (r80._data != null) {
r91._data = r80._data;
}
} else if (r80 != null) {
r91.match = [...r80];
let start2 = 0;
if (typeof r80 !== "string") {
let index2 = r80.index;
if (index2 == null) {
index2 = 0;
}
start2 = index2;
}
r91.start = start2;
r91.type = _nonTokenType3;
} else {
r91.match = [];
r91.start = 0;
r91.type = _nonTokenType3;
}
r5.push(r91);
}
return r5;
}
clearCache() {
this._rules.forEach(({ cache: cache2 }) => cache2 == null ? void 0 : cache2.clear());
const _followers = this._followers;
for (const key in _followers) {
this._followers[key].forEach(({ cache: cache2 }) => cache2 == null ? void 0 : cache2.clear());
}
}
_getMatch(a0, a1, a2) {
const r12 = a1 != null ? a1.type : null;
let r14 = a1?.end === a2 ? getMatch2(a0, this._followers[String(r12)], a2) : void 0;
if (r14 == null) {
r14 = getMatch2(a0, this._rules, a2);
}
return r14;
}
}
class Token {
constructor(a0, a1) {
if (a0 instanceof Token) {
this.match = [...a0.match];
this.start = a0.start;
this.type = a0.type;
if (a0._data != null) {
this._data = a0._data;
}
} else if (a0 != null) {
this.match = [...a0];
let start = 0;
if (typeof a0 !== "string") {
let index = a0.index;
if (index == null) {
index = 0;
}
start = index;
}
this.start = start;
this.type = a1;
} else {
this.match = [];
this.start = 0;
this.type = a1;
}
}
get end() {
return this.start + this.length;
}
get length() {
return this.match[0].length;
}
valueOf() {
return this.match[0];
}
getFullMatch() {
return this.match[0];
}
getMatch(r3 = 0) {
return this.match[r3];
}
setData(a0, a1) {
if (this._data == null) {
this._data = new Map();
}
this._data.set(a0, a1);
}
getData(a0) {
if (this._data != null) {
return this._data.get(a0);
}
}
}
QueryTokenizer.NON_TOKEN_TYPE = "NON_TOKEN";
QueryTokenizer.Token = Token;
export default QueryTokenizer;
export const NON_TOKEN_TYPE = "NON_TOKEN";
export { Token };
+57
View File
@@ -0,0 +1,57 @@
// Metro module 5730 (f5731).
import Module12 from "../_bundle/Module12";
function $mk76876($env) {
return (a0) => {
if (a0 != null) {
const r6 = $env;
const inbound = a0.rtp.inbound;
for (const key in inbound) {
for (const item of a0.rtp.inbound[key]) {
const r48 = `inbound-${key}-${item.type}`;
const r50 = r6[0];
if (!(r48 in r50.bytes)) {
r50.bytes[r48] = 0;
}
r50.bytes[r48] = item.bytesReceived;
}
}
for (const item2 of a0.rtp.outbound) {
const r74 = `outbound-${item2.type}`;
const r76 = r6[0];
if (!(r74 in r76.bytes)) {
r76.bytes[r74] = 0;
}
r76.bytes[r74] = item2.bytesSent;
}
}
};
}
let c3557_2 = [];
class RTCBandwidthMonitor {
constructor() {
let env15064;
const r1 = env15064 = {};
env15064[0] = this;
this.bytes = {};
this.record = $mk76876(r1);
}
static create() {
let env15065;
const r7 = {
__proto__: RTCBandwidthMonitor.prototype
};
const r8 = env15065 = {};
env15065[0] = r7;
r7.bytes = {};
r7.record = $mk76876(r8);
c3557_2.push(r7);
return r7.record;
}
getTotalBytes() {
return Module12.sum(Object.values(this.bytes));
}
}
export default RTCBandwidthMonitor;
export function getRTCTotalBytes() {
return Module12.sum(c3557_2.map((item) => item.getTotalBytes()));
}
File diff suppressed because it is too large. Load diff
+17
View File
@@ -0,0 +1,17 @@
// Metro module 4285 (f4286).
const r8 = {
State: "state",
Speaking: "speaking",
VideoSourceQualityChanged: "video-source-quality-changed",
Video: "video",
Flags: "flags",
Platform: "platform",
Ping: "ping",
ClientConnect: "client-connect",
ClientDisconnect: "client-disconnect",
OutboundLossRate: "outboundlossrate",
SecureFramesUpdate: "secure-frames-update",
RosterMapUpdate: "roster-map-update",
UsersMerged: "users-merged"
};
export { r8 as RTCConnectionEvent };
+105
View File
@@ -0,0 +1,105 @@
// Metro module 12860 (f12861).
import { RTCConnectionStates } from "../Constants";
import { now } from "../_bundle/sleep";
import Module12 from "../_bundle/Module12";
import zipWithNext from "./zipWithNext";
function $mk109004($env) {
return (a0) => a0.state === $env[0] ? a0.durationMs : 0;
}
export class StateHistory {
constructor(a0) {
const r5 = {
__proto__: new.target.prototype,
current: null,
history: []
};
if (a0 != null) {
r5.update(a0);
}
return r5;
}
reset(a0) {
this.current = null;
this.history = [];
if (a0 != null) {
this.update(a0);
}
}
update(a0) {
if (this.current !== a0) {
this.current = a0;
this.history.push({
state: a0,
startTime: now()
});
}
}
getVoiceConnectionSuccessStats(r4 = now()) {
let env20258;
let env20259;
let env20260;
let env20261;
let env20262;
let env20263;
let env20264;
let env20265;
const stateDurations = this.getStateDurations(r4);
const AWAITING_ENDPOINT = RTCConnectionStates.AWAITING_ENDPOINT;
const r6 = env20258 = {};
env20258[0] = AWAITING_ENDPOINT;
const r21 = {
state_awaiting_endpoint_ms: Module12.sumBy(stateDurations, $mk109004(r6)),
state_authenticating_ms: null,
state_connecting_ms: null,
state_disconnected_ms: null,
state_ice_checking_ms: null,
state_no_route_ms: null,
state_rtc_connecting_ms: null,
state_rtc_disconnected_ms: null
};
const AUTHENTICATING = RTCConnectionStates.AUTHENTICATING;
const r23 = env20259 = {};
env20259[0] = AUTHENTICATING;
r21.state_authenticating_ms = Module12.sumBy(stateDurations, $mk109004(r23));
const CONNECTING = RTCConnectionStates.CONNECTING;
const r30 = env20260 = {};
env20260[0] = CONNECTING;
r21.state_connecting_ms = Module12.sumBy(stateDurations, $mk109004(r30));
const DISCONNECTED = RTCConnectionStates.DISCONNECTED;
const r37 = env20261 = {};
env20261[0] = DISCONNECTED;
r21.state_disconnected_ms = Module12.sumBy(stateDurations, $mk109004(r37));
const ICE_CHECKING = RTCConnectionStates.ICE_CHECKING;
const r44 = env20262 = {};
env20262[0] = ICE_CHECKING;
r21.state_ice_checking_ms = Module12.sumBy(stateDurations, $mk109004(r44));
const NO_ROUTE = RTCConnectionStates.NO_ROUTE;
const r51 = env20263 = {};
env20263[0] = NO_ROUTE;
r21.state_no_route_ms = Module12.sumBy(stateDurations, $mk109004(r51));
const RTC_CONNECTING = RTCConnectionStates.RTC_CONNECTING;
const r58 = env20264 = {};
env20264[0] = RTC_CONNECTING;
r21.state_rtc_connecting_ms = Module12.sumBy(stateDurations, $mk109004(r58));
const RTC_DISCONNECTED = RTCConnectionStates.RTC_DISCONNECTED;
const r65 = env20265 = {};
env20265[0] = RTC_DISCONNECTED;
r21.state_rtc_disconnected_ms = Module12.sumBy(stateDurations, $mk109004(r65));
return r21;
}
getStateDurations(a0) {
if (this.history.length === 0) {
return [];
}
const r13 = zipWithNext(this.history, (a0, a1) => ({
state: a0.state,
durationMs: a1.startTime - a0.startTime
}));
const r19 = Module12.last(this.history);
r13.push({
state: r19.state,
durationMs: a0 - r19.startTime
});
return r13;
}
}
+788
View File
@@ -0,0 +1,788 @@
// Metro module 12865 (f12866).
import DeveloperOptionsStore from "../stores/DeveloperOptionsStore";
import { MediaTypes, MediaEngineContextTypes, SpeakingFlags } from "../_bundle/Module4250";
import Durations from "../utils/Durations";
import TypedEventEmitter from "../_bundle/TypedEventEmitter";
import Backoff from "../_bundle/Backoff";
import Logger from "../modules/debug/Logger";
import { now } from "../_bundle/sleep";
import { isPlatformEmbedded } from "../utils/PlatformUtils";
import Module38 from "../_bundle/Module38";
function $mk90528() {
return (a0) => ({
name: a0.name,
type: a0.type,
priority: 1000 * a0.priority,
payload_type: a0.payloadType,
rtx_payload_type: a0.rtxPayloadType,
encode: a0.encode,
decode: a0.decode
});
}
function $mk90529() {
return (a0) => ({
type: a0.type,
rid: a0.rid,
ssrc: a0.ssrc,
active: a0.active,
quality: a0.quality,
rtx_ssrc: a0.rtxSsrc,
max_bitrate: a0.maxBitrate,
max_framerate: a0.maxFrameRate,
max_resolution: a0.maxResolution != null ? {
type: a0.maxResolution.type,
width: a0.maxResolution.width,
height: a0.maxResolution.height
} : void 0
});
}
function $mk90530($env) {
return (a0) => {
const type = a0.type;
return {
type: type === "audio" ? MediaTypes.AUDIO : type === "test" ? MediaTypes.TEST : type === "screen" ? MediaTypes.SCREEN : MediaTypes.VIDEO,
rid: a0.rid,
ssrc: a0.ssrc,
rtxSsrc: a0.rtx_ssrc,
active: a0.active,
quality: a0.quality,
maxBitrate: a0.max_bitrate,
maxFrameRate: a0.max_framerate,
maxResolution: a0.max_resolution != null ? {
type: a0.max_resolution.type,
width: a0.max_resolution.width,
height: a0.max_resolution.height
} : void 0
};
};
}
let c8870_8, c8870_9, c8870_10, c8870_11, c8870_12, c8870_13, c8870_14, c8870_15;
let env8870 = {};
const noop = function noop() {};
c8870_8 = {
IDENTIFY: 0,
0: "IDENTIFY",
SELECT_PROTOCOL: 1,
1: "SELECT_PROTOCOL",
READY: 2,
2: "READY",
HEARTBEAT: 3,
3: "HEARTBEAT",
SELECT_PROTOCOL_ACK: 4,
4: "SELECT_PROTOCOL_ACK",
SPEAKING: 5,
5: "SPEAKING",
HEARTBEAT_ACK: 6,
6: "HEARTBEAT_ACK",
RESUME: 7,
7: "RESUME",
HELLO: 8,
8: "HELLO",
RESUMED: 9,
9: "RESUMED",
CLIENT_CONNECT: 11,
11: "CLIENT_CONNECT",
VIDEO: 12,
12: "VIDEO",
CLIENT_DISCONNECT: 13,
13: "CLIENT_DISCONNECT",
SESSION_UPDATE: 14,
14: "SESSION_UPDATE",
MEDIA_SINK_WANTS: 15,
15: "MEDIA_SINK_WANTS",
VOICE_BACKEND_VERSION: 16,
16: "VOICE_BACKEND_VERSION",
CHANNEL_OPTIONS_UPDATE: 17,
17: "CHANNEL_OPTIONS_UPDATE",
FLAGS: 18,
18: "FLAGS",
PLATFORM: 20,
20: "PLATFORM",
DAVE_PROTOCOL_PREPARE_TRANSITION: 21,
21: "DAVE_PROTOCOL_PREPARE_TRANSITION",
DAVE_PROTOCOL_EXECUTE_TRANSITION: 22,
22: "DAVE_PROTOCOL_EXECUTE_TRANSITION",
DAVE_PROTOCOL_READY_FOR_TRANSITION: 23,
23: "DAVE_PROTOCOL_READY_FOR_TRANSITION",
DAVE_PROTOCOL_PREPARE_EPOCH: 24,
24: "DAVE_PROTOCOL_PREPARE_EPOCH",
MLS_EXTERNAL_SENDER_PACKAGE: 25,
25: "MLS_EXTERNAL_SENDER_PACKAGE",
MLS_KEY_PACKAGE: 26,
26: "MLS_KEY_PACKAGE",
MLS_PROPOSALS: 27,
27: "MLS_PROPOSALS",
MLS_COMMIT_WELCOME: 28,
28: "MLS_COMMIT_WELCOME",
MLS_PREPARE_COMMIT_TRANSITION: 29,
29: "MLS_PREPARE_COMMIT_TRANSITION",
MLS_WELCOME: 30,
30: "MLS_WELCOME",
MLS_INVALID_COMMIT_WELCOME: 31,
31: "MLS_INVALID_COMMIT_WELCOME",
CLIENT_CANNOT_REACH_RTC_SERVER: 32,
32: "CLIENT_CANNOT_REACH_RTC_SERVER"
};
c8870_9 = {
AUTHENTICATION_FAILED: 4004,
4004: "AUTHENTICATION_FAILED",
INVALID_SESSION: 4006,
4006: "INVALID_SESSION",
SERVER_NOT_FOUND: 4011,
4011: "SERVER_NOT_FOUND",
SERVER_CRASH: 4015,
4015: "SERVER_CRASH",
CANCELED: 4016,
4016: "CANCELED",
HEARTBEAT_TIMEOUT: 4800,
4800: "HEARTBEAT_TIMEOUT",
UNRESUMABLE: 4801,
4801: "UNRESUMABLE",
RESET_BACKOFF: 4802,
4802: "RESET_BACKOFF"
};
c8870_10 = {
DISCONNECTED: 0,
0: "DISCONNECTED",
CONNECTING: 1,
1: "CONNECTING",
IDENTIFYING: 2,
2: "IDENTIFYING",
RESUMING: 3,
3: "RESUMING",
CONNECTED: 4,
4: "CONNECTED",
RECONNECTING: 5,
5: "RECONNECTING"
};
c8870_11 = 20 * Durations.Millis.SECOND;
c8870_12 = 1 * Durations.Millis.MINUTE;
c8870_13 = 5 * Durations.Millis.SECOND;
c8870_14 = {
Connecting: "connecting",
Connect: "connect",
Disconnect: "disconnect",
Resuming: "resuming",
Ready: "ready",
Speaking: "speaking",
Video: "video",
Ping: "ping",
ClientConnect: "client-connect",
ClientDisconnect: "client-disconnect",
Codecs: "codecs",
MediaSessionId: "media-session-id",
MediaSinkWants: "media-sink-wants",
VoiceBackendVersion: "voice-backend-version",
KeyframeInterval: "keyframe-interval",
ChannelOptionsUpdateSecureFramesProtocol: "update-secure-frames-protocol",
Flags: "flags",
Platform: "platform",
SDP: "sdp",
Encryption: "encryption",
BandwidthEstimationExperiment: "bandwidth-estimation-experiment",
SecureFramesInit: "secure-frames-init",
SecureFramesPrepareTransition: "secure-frames-prepare-transition",
SecureFramesExecuteTransition: "secure-frames-execute-transition",
SecureFramesPrepareEpoch: "secure-frames-prepare-epoch",
MLSExternalSenderPackage: "mls-external-sender-package",
MLSProposals: "mls-proposals",
MLSPrepareCommitTransition: "mls-prepare-commit-transition",
MLSWelcome: "mls-welcome",
ReceiveMessage: "receive-message",
SendMessage: "send-message"
};
class RTCControlSocket extends TypedEventEmitter {
constructor(a0, r10 = MediaEngineContextTypes.DEFAULT) {
super();
this.backoff = new Backoff(1000, 5000);
this.serverVersion = 0;
this.url = a0;
this.logger = new Logger(`RTCControlSocket(${r10})`);
this.logger.enableNativeLogger(true);
this.webSocket = null;
this.connectionState = c8870_10.DISCONNECTED;
this.helloTimeout = null;
this.lastHeartbeatAckTime = null;
this.heartbeatInterval = null;
this.heartbeater = null;
this.heartbeatAck = true;
this.expeditedHeartbeatTimeout = null;
this.heartbeatIntervalModifier = 1;
this.connectionStartTime = 0;
this.lastRecvSeqNum = null;
this.sessionId = null;
this.serverId = null;
this.channelId = null;
this.token = null;
this.resumable = false;
}
createWebSocket() {
this.logger.info(`[CONNECT] ${this.url}`);
if (this.webSocket !== null) {
this.logger.error("Connect called with already existing websocket");
this.cleanupWebSocket((a0) => a0.close(4000));
}
this.connectionStartTime = now();
this.helloTimeout = setTimeout(() => {
const r13 = now();
this.handleClose(false, 0, `The connection timed out after ${r13 - this.connectionStartTime} ms - did not receive OP_HELLO in time.`);
}, c8870_11);
const webSocket = new WebSocket(`${this.url}?v=9`);
this.webSocket = webSocket;
webSocket.binaryType = "arraybuffer";
webSocket.onopen = () => {
const connectionState = this.connectionState;
if (connectionState === c8870_10.CONNECTING) {
this.emit(c8870_14.Connect);
} else if (this.connectionState === c8870_10.RECONNECTING) {
this.doResumeOrClose();
}
this.connectionState = c8870_10.CONNECTED;
const r7 = now() - this.connectionStartTime;
this.logger.info(`[CONNECTED] ${this.url} in ${r7} ms`);
this.emit(c8870_14.Ping, Math.round(r7 / 2));
};
webSocket.onmessage = (a0) => {
const r25 = this.parseWebSocketMessage(a0);
const { op, seq, d: r26 } = r25;
const r9 = env8870;
this.emit(c8870_14.ReceiveMessage, op, r26);
if (seq) {
this.lastRecvSeqNum = seq;
}
if (DeveloperOptionsStore.isLoggingGatewayEvents) {
if (r26 instanceof Uint8Array) {
this.logger.info(`~> ${op}: 0x${[...r26].map((item) => item.toString(16).padStart(2, "0")).join("")}`);
} else {
this.logger.info(`~> ${op}: ${JSON.stringify(r26)}`);
}
}
if (c8870_8.HELLO === op) {
this.clearHelloTimeout();
this.handleHello(r26);
} else if (c8870_8.READY === op) {
this.handleReady(r26);
} else if (c8870_8.RESUMED === op) {
this.handleResumed(r26);
} else if (c8870_8.SELECT_PROTOCOL_ACK === op) {
if (r26.bandwidth_estimation_experiment) {
this.emit(c8870_14.BandwidthEstimationExperiment, r26.bandwidth_estimation_experiment);
}
this.emit(c8870_14.Codecs, r26.audio_codec, r26.video_codec);
if (r26.media_session_id) {
this.emit(c8870_14.MediaSessionId, r26.media_session_id);
}
if (r26.sdp) {
this.emit(c8870_14.SDP, r26.sdp);
} else if (r26.mode) {
this.emit(c8870_14.Encryption, r26.mode, r26.secret_key);
}
if (r26.keyframe_interval) {
this.emit(c8870_14.KeyframeInterval, r26.keyframe_interval);
}
this.emit(c8870_14.SecureFramesInit, r26.dave_protocol_version || 0);
this.resumable = true;
} else if (c8870_8.SPEAKING === op) {
const speaking2 = r26.speaking;
let r229 = speaking2;
if (typeof r229 === "boolean") {
r229 = speaking2 ? SpeakingFlags.VOICE : SpeakingFlags.NONE;
}
this.emit(c8870_14.Speaking, r26.user_id, r26.ssrc, r229);
} else if (c8870_8.HEARTBEAT === op) {
this.sendHeartbeat();
} else if (c8870_8.HEARTBEAT_ACK === op) {
this.handleHeartbeatAck(r26);
} else if (c8870_8.VIDEO === op) {
const Video = c8870_14.Video;
const { user_id, audio_ssrc, video_ssrc, streams } = r26;
let r216 = streams == null ? void 0 : streams.map($mk90530(r9));
if (r216 == null) {
r216 = [];
}
this.emit(Video, user_id, audio_ssrc, video_ssrc, r216);
} else if (c8870_8.CLIENT_CONNECT === op) {
this.emit(c8870_14.ClientConnect, r26.user_ids);
} else if (c8870_8.CLIENT_DISCONNECT === op) {
this.emit(c8870_14.ClientDisconnect, r26.user_id);
} else if (c8870_8.SESSION_UPDATE === op) {
if (!(r26.audio_codec == null && r26.video_codec == null)) {
this.emit(c8870_14.Codecs, r26.audio_codec, r26.video_codec);
}
if (r26.media_session_id != null) {
this.emit(c8870_14.MediaSessionId, r26.media_session_id);
}
if (r26.keyframe_interval) {
this.emit(c8870_14.KeyframeInterval, r26.keyframe_interval);
}
} else if (c8870_8.MEDIA_SINK_WANTS === op) {
this.emit(c8870_14.MediaSinkWants, r26);
} else if (c8870_8.VOICE_BACKEND_VERSION === op) {
if (r26.voice != null && r26.rtc_worker != null) {
this.emit(c8870_14.VoiceBackendVersion, r26.voice, r26.rtc_worker);
}
} else if (c8870_8.FLAGS === op) {
if (r26.flags != null && r26.user_id != null) {
this.emit(c8870_14.Flags, r26.user_id, r26.flags);
}
} else if (c8870_8.PLATFORM === op) {
if (r26.platform != null && r26.user_id != null) {
this.emit(c8870_14.Platform, r26.user_id, r26.platform);
}
} else if (c8870_8.DAVE_PROTOCOL_PREPARE_TRANSITION === op) {
if (r26.transition_id != null && r26.protocol_version != null) {
this.emit(c8870_14.SecureFramesPrepareTransition, r26.transition_id, r26.protocol_version);
}
} else if (c8870_8.DAVE_PROTOCOL_EXECUTE_TRANSITION === op) {
if (r26.transition_id != null) {
this.emit(c8870_14.SecureFramesExecuteTransition, r26.transition_id);
}
} else if (c8870_8.DAVE_PROTOCOL_PREPARE_EPOCH === op) {
if (r26.epoch != null && r26.protocol_version != null) {
this.emit(c8870_14.SecureFramesPrepareEpoch, r26.epoch, r26.protocol_version);
}
} else if (c8870_8.MLS_EXTERNAL_SENDER_PACKAGE === op) {
this.emit(c8870_14.MLSExternalSenderPackage, r26);
} else if (c8870_8.MLS_PROPOSALS === op) {
this.emit(c8870_14.MLSProposals, r26);
} else if (c8870_8.MLS_PREPARE_COMMIT_TRANSITION === op) {
this.emit(c8870_14.MLSPrepareCommitTransition, new DataView(r26.buffer, r26.byteOffset, 2).getUint16(0, false), r26.slice(2));
} else if (c8870_8.MLS_WELCOME === op) {
this.emit(c8870_14.MLSWelcome, new DataView(r26.buffer, r26.byteOffset, 2).getUint16(0, false), r26.slice(2));
} else {
this.logger.info(`Unhandled op ${op}`);
}
};
webSocket.onerror = () => this.handleClose(false, 0, "An error with the websocket occurred");
webSocket.onclose = (a0) => this.handleClose(a0.wasClean, a0.code, a0.reason);
}
send(a0, r7 = null) {
const webSocket = this.webSocket;
if (webSocket != null && webSocket.readyState === WebSocket.OPEN) {
const r15 = JSON.stringify({
op: a0,
d: r7
});
if (DeveloperOptionsStore.isLoggingGatewayEvents) {
this.logger.info(`<~ ${r15}`);
}
this.emit(c8870_14.SendMessage, a0, r7);
try {
webSocket.send(r15);
} catch ($e) {}
}
}
sendBinary(a0, a1) {
const webSocket = this.webSocket;
if (webSocket != null && webSocket.readyState === WebSocket.OPEN) {
const uint8Array = new Uint8Array(a1.byteLength + 1);
uint8Array[0] = a0;
uint8Array.set(a1, 1);
try {
webSocket.send(uint8Array.buffer);
} catch ($e) {}
}
}
doResumeOrClose() {
L9: {
L7: {
const lastHeartbeatAckTime = now();
if (this.serverId !== null && this.channelId !== null && this.token !== null && this.sessionId !== null && this.resumable) {
if (this.lastHeartbeatAckTime != null && !(lastHeartbeatAckTime - this.lastHeartbeatAckTime <= c8870_12)) {
break L7;
}
this.doResume();
this.lastHeartbeatAckTime = lastHeartbeatAckTime;
break L9;
}
}
this.disconnect(false, c8870_9.UNRESUMABLE, "Cannot resume connection.");
}
}
doResume() {
let lastRecvSeqNum = this.lastRecvSeqNum;
if (lastRecvSeqNum == null) {
lastRecvSeqNum = -1;
}
const logger = this.logger;
let serverId = this.serverId;
if (serverId == null) {
serverId = "";
}
let channelId = this.channelId;
if (channelId == null) {
channelId = "";
}
let sessionId = this.sessionId;
if (sessionId == null) {
sessionId = "";
}
logger.info(`[RESUME] resuming session. serverId=${serverId} channelId=${channelId} sessionId=${sessionId} seqAck=${lastRecvSeqNum}`);
this.emit(c8870_14.Resuming);
this.connectionState = c8870_10.RESUMING;
this.send(c8870_8.RESUME, {
token: this.token,
session_id: this.sessionId,
server_id: this.serverId,
channel_id: this.channelId,
seq_ack: lastRecvSeqNum
});
}
handleHello(a0) {
let r27, r28;
let serverVersion = a0.v;
if (serverVersion == null) {
serverVersion = 3;
}
this.serverVersion = serverVersion;
if (this.serverVersion <= 3) {
this.heartbeatInterval = a0.heartbeat_interval * (isPlatformEmbedded ? 0.25 : 0.1);
r27 = dependencyMap;
r28 = require;
} else {
this.heartbeatInterval = a0.heartbeat_interval * this.heartbeatIntervalModifier;
r27 = dependencyMap;
r28 = require;
if (!isPlatformEmbedded) {
const r13 = Math;
let heartbeatInterval = this.heartbeatInterval;
if (heartbeatInterval == null) {
heartbeatInterval = NaN;
}
this.heartbeatInterval = r13.min(c8870_13, heartbeatInterval);
r27 = dependencyMap;
r28 = require;
}
}
const r14 = r28(r27[6]).now() - this.connectionStartTime;
const logger = this.logger;
let heartbeatInterval2 = this.heartbeatInterval;
if (heartbeatInterval2 == null) {
heartbeatInterval2 = "??";
}
logger.info(`[HELLO] heartbeat interval: ${heartbeatInterval2}, version: ${this.serverVersion}, took ${r14} ms`);
this.startHeartbeater();
}
handleReady(a0) {
const r13 = env8870;
this.backoff.succeed();
this.logger.info(`[READY] took ${now() - this.connectionStartTime} ms`);
if (this.serverVersion >= 6) {
this.send(c8870_8.VOICE_BACKEND_VERSION, {});
}
const emit = this.emit;
const Ready = c8870_14.Ready;
const { ip, port, modes, ssrc, streams } = a0;
let r50 = streams == null ? void 0 : streams.map($mk90530(r13));
if (r50 == null) {
r50 = [];
}
emit.call(this, Ready, ip, port, modes, ssrc, r50, a0.experiments);
}
handleResumed() {
this.backoff.succeed();
}
handleClose(a0, a1, a2) {
let r6 = a0;
let c20272_1 = a0;
this.connectionState = c8870_10.DISCONNECTED;
if (!a0) {
r6 = false;
}
c20272_1 = r6;
this.cleanupWebSocket();
if (a1 !== c8870_9.AUTHENTICATION_FAILED && a1 !== c8870_9.SERVER_CRASH && a1 !== c8870_9.SERVER_NOT_FOUND && a1 !== c8870_9.INVALID_SESSION) {
if (this.backoff.fails > 3) {
this.logger.warn("[WS CLOSED] Backoff exceed. Resetting.");
this.disconnect(r6, a1, a2);
} else {
const r39 = this.backoff.fail(() => this.reconnect(c20272_1, a1, a2));
this.logger.warn(`[WS CLOSED] (clean: ${r6.toString()}, code: ${a1}, reason: ${a2}) retrying in ${(r39 / 1000).toFixed(2)} seconds.`);
}
return void 0;
}
return this.disconnect(r6, a1, a2);
}
disconnect(a0, a1, a2) {
this.logger.warn(`[DISCONNECT] (${a0.toString()}, ${a1}, ${a2})`);
this.cleanupWebSocket();
this.cleanupState();
this.connectionState = c8870_10.DISCONNECTED;
this.emit(c8870_14.Disconnect, a0, a1, a2);
}
reconnect(a0, a1, a2) {
this.logger.info(`[RECONNECT] wasClean=${a0.toString()} code=${a1} reason=${a2}`);
this.cleanupWebSocket((a0) => a0.close(4000));
this.connectionState = c8870_10.RECONNECTING;
this.createWebSocket();
}
cleanupWebSocket(a0) {
this.stopHeartbeater();
this.clearHelloTimeout();
const webSocket = this.webSocket;
this.webSocket = null;
if (webSocket != null) {
webSocket.onopen = noop;
webSocket.onmessage = noop;
webSocket.onerror = noop;
webSocket.onclose = noop;
if (a0 != null) {
a0(webSocket);
}
}
this.backoff.cancel();
}
cleanupState() {
this.serverId = null;
this.channelId = null;
this.sessionId = null;
this.token = null;
this.resumable = false;
this.lastRecvSeqNum = null;
}
parseWebSocketMessage(a0) {
if (a0.data instanceof ArrayBuffer) {
const uint8Array = new Uint8Array(a0.data);
const seq = this.serverVersion >= 8 ? new DataView(uint8Array.buffer).getUint16(0, false) : null;
const r32 = this.serverVersion >= 8 ? 2 : 0;
return {
op: uint8Array[r32],
seq,
d: uint8Array.subarray(r32 + 1)
};
}
return JSON.parse(a0.data);
}
clearHelloTimeout() {
if (this.helloTimeout != null) {
clearTimeout(this.helloTimeout);
this.helloTimeout = null;
}
}
handleHeartbeatAck(a0) {
this.logger.info("Heartbeat ACK received");
const r9 = this.serverVersion >= 8 ? a0.t : a0;
this.emit(c8870_14.Ping, now() - r9);
this.lastHeartbeatAckTime = now();
this.heartbeatAck = true;
if (this.expeditedHeartbeatTimeout !== null) {
clearTimeout(this.expeditedHeartbeatTimeout);
this.expeditedHeartbeatTimeout = null;
this.logger.info("Expedited heartbeat succeeded");
}
}
handleHeartbeatTimeout() {
this.cleanupWebSocket((a0) => a0.close(4000));
this.logger.warn(`[HEARTBEAT ACK TIMEOUT] reconnecting in ${(this.backoff.fail(() => this.reconnect(false, c8870_9.HEARTBEAT_TIMEOUT, "Heartbeat timeout.")) / 1000).toFixed(2)} seconds.`);
}
startHeartbeater() {
Module38(this.heartbeatInterval != null, "RTCControlSocket: Heartbeat interval should never null here.");
this.logger.info(`Starting heartbeat with interval: ${this.heartbeatInterval}`);
if (this.heartbeater !== null) {
clearInterval(this.heartbeater);
}
this.heartbeatAck = true;
this.heartbeater = setInterval(() => {
if (this.heartbeatAck) {
this.heartbeatAck = false;
this.sendHeartbeat();
} else if (this.expeditedHeartbeatTimeout === null) {
this.handleHeartbeatTimeout();
}
}, this.heartbeatInterval);
}
sendHeartbeat() {
if (this.serverVersion >= 8) {
let lastRecvSeqNum = this.lastRecvSeqNum;
if (lastRecvSeqNum == null) {
lastRecvSeqNum = -1;
}
this.logger.info(`Sending heartbeat with last received sequence number: ${lastRecvSeqNum}`);
this.send(c8870_8.HEARTBEAT, {
t: now(),
seq_ack: lastRecvSeqNum
});
} else {
this.logger.info("Sending heartbeat");
this.send(c8870_8.HEARTBEAT, now());
}
}
stopHeartbeater() {
if (this.heartbeater !== null) {
clearInterval(this.heartbeater);
this.heartbeater = null;
}
if (this.expeditedHeartbeatTimeout !== null) {
clearTimeout(this.expeditedHeartbeatTimeout);
this.expeditedHeartbeatTimeout = null;
}
}
connect() {
let r0;
const connectionState = this.connectionState;
if (connectionState !== c8870_10.DISCONNECTED) {
this.logger.error("Cannot start a new connection, connection state is not disconnected");
r0 = false;
} else {
this.connectionState = c8870_10.CONNECTING;
this.createWebSocket();
this.emit(c8870_14.Connecting);
r0 = true;
}
return r0;
}
identify({ serverId, channelId, userId, sessionId, token, maxDaveProtocolVersion, video: video2 = false, streamParameters }) {
this.serverId = serverId;
this.channelId = channelId;
this.sessionId = sessionId;
this.token = token;
this.connectionState = c8870_10.IDENTIFYING;
this.send(c8870_8.IDENTIFY, {
server_id: serverId,
channel_id: channelId,
user_id: userId,
session_id: sessionId,
token,
max_dave_protocol_version: maxDaveProtocolVersion,
video: video2,
streams: streamParameters == null ? void 0 : streamParameters.map($mk90529())
});
}
expeditedHeartbeat(a0, r9 = "", r5 = true) {
if (this.webSocket != null) {
this.logger.info("Performing an expedited heartbeat " + (r9 !== "" ? "reason: " + r9 : ""));
this.heartbeatAck = false;
this.sendHeartbeat();
if (this.expeditedHeartbeatTimeout !== null) {
clearTimeout(this.expeditedHeartbeatTimeout);
}
this.expeditedHeartbeatTimeout = setTimeout(() => {
this.expeditedHeartbeatTimeout = null;
if (this.heartbeatAck === false) {
this.handleHeartbeatTimeout();
}
}, a0);
} else {
if (r5) {
return this.resetBackoff(r9);
}
this.logger.info("Expedited heartbeat requested, but is disconnected and a reset was not requested " + (r9 !== "" ? "reason: " + r9 : ""));
}
return false;
}
resetBackoff(r4 = "") {
let r10 = this.backoff.fails > 0 && this.webSocket == null;
if (r10) {
this.logger.info("Connection backoff reset " + (r4 !== "" ? "for reason: " + r4 : ""));
this.backoff.succeed();
this.reconnect(false, c8870_9.RESET_BACKOFF, "Reset backoff.");
r10 = true;
}
return r10;
}
close() {
this.logger.info("CLOSE");
this.cleanupWebSocket((a0) => a0.close(4000));
this.cleanupState();
this.connectionState = c8870_10.DISCONNECTED;
this.emit(c8870_14.Disconnect, true, 1000, "Force Close");
}
destroy() {
this.close();
}
selectProtocol(a0, a1, a2, a3) {
let r6, data;
L17: {
const r3 = {};
const r1 = a2 == null;
r6 = r3;
data = null;
if (!r1) {
if ("sdp" in a2 && a2.sdp != null && a2.sdp !== "") {
data = a2.sdp;
r6 = {
...a2,
codecs: a2.codecs.map($mk90528()),
rtc_connection_id: a1
};
break L17;
}
const r18 = "address" in a2 && a2.address != null && a2.address !== "" && Boolean(a2.port) && a2.mode != null && a2.mode !== "";
r6 = r3;
data = void 0;
if (r18) {
const r31 = {
address: a2.address,
port: a2.port,
mode: a2.mode
};
r6 = {
...a2,
codecs: a2.codecs.map($mk90528()),
rtc_connection_id: a1,
experiments: a3
};
data = r31;
}
}
}
this.send(c8870_8.SELECT_PROTOCOL, {
protocol: a0,
data,
...r6
});
}
updateSession(a0) {
this.send(c8870_8.SESSION_UPDATE, {
codecs: a0.codecs.map($mk90528())
});
}
speaking(a0, delay = 0, ssrc = 0) {
this.send(c8870_8.SPEAKING, {
speaking: this.serverVersion <= 3 ? Boolean(a0) : a0,
delay,
ssrc
});
}
video(a0, a1, a2, a3) {
this.send(c8870_8.VIDEO, {
audio_ssrc: a0,
video_ssrc: a1,
rtx_ssrc: a2,
streams: a3 == null ? void 0 : a3.map($mk90529())
});
}
mediaSinkWants(a0) {
if (this.serverVersion >= 5) {
this.send(c8870_8.MEDIA_SINK_WANTS, a0);
}
}
secureFramesReadyForTransition(a0) {
this.send(c8870_8.DAVE_PROTOCOL_READY_FOR_TRANSITION, {
transition_id: a0
});
}
sendMLSKeyPackage(a0) {
this.logger.info("Sending MLS key package");
this.sendBinary(c8870_8.MLS_KEY_PACKAGE, new Uint8Array(a0));
}
sendMLSCommitWelcome(a0) {
this.logger.info("Sending MLS commit + welcome message");
this.sendBinary(c8870_8.MLS_COMMIT_WELCOME, new Uint8Array(a0));
}
flagMLSInvalidCommitWelcome(a0) {
this.send(c8870_8.MLS_INVALID_COMMIT_WELCOME, {
transition_id: a0
});
}
noRoute() {
this.send(c8870_8.CLIENT_CANNOT_REACH_RTC_SERVER, {});
}
setHeartbeatIntervalModifier(a0) {
this.heartbeatIntervalModifier = a0;
}
}
c8870_15 = RTCControlSocket;
export default RTCControlSocket;
export { c8870_8 as RTCSocketOpcode };
export { c8870_14 as SocketEvent };
+523
View File
@@ -0,0 +1,523 @@
// Metro module 12862 (f12863).
import AuthenticationStore from "../stores/AuthenticationStore";
import { VideoToggleState } from "../Constants";
import { SimulcastOverrideQuality } from "../_bundle/Module4250";
import Durations from "../utils/Durations";
import { getFirefoxVersion } from "../utils/BrowserUtils";
import { getBrowserInvertedWantsConfig } from "../modules/media_engine/BrowserInvertedWantsExperiment";
import TypedEventEmitter from "../_bundle/TypedEventEmitter";
import { MediaSinkWantsLadder } from "../_bundle/MediaSinkWantsLadder";
import { DelayedCall, Timeout } from "../_bundle/Timeout";
import { WindowVisibilityVideoManager, WindowVisibilityEvent } from "./WindowVisibilityVideoManager";
import SnowflakeUtils from "../utils/SnowflakeUtils";
import { isDesktop } from "../utils/PlatformUtils";
import shallowEqual from "../_bundle/shallowEqual";
import Module12 from "../_bundle/Module12";
import { BaseConnectionEvent } from "../_bundle/Module4286";
let any, c8867_8, c8867_9, c8867_10, c8867_11, c8867_12;
const getDefaultWants = function getDefaultWants(wantsLevel) {
return getBrowserInvertedWantsConfig("RTCMediaSinkWantsManager.getDefaultWants").invertWants ? {
...c8867_8
} : {
any: wantsLevel
};
};
any = 100;
c8867_8 = {
any: 0
};
c8867_9 = 30 * Durations.Millis.SECOND;
c8867_10 = 120 * Durations.Millis.SECOND;
c8867_11 = getFirefoxVersion() !== -1;
c8867_12 = {
UserSSRCUpdate: "user-ssrc-update",
Update: "update"
};
class RTCMediaSinkWantsManager extends TypedEventEmitter {
constructor(a0, a1, a2, ladder = new MediaSinkWantsLadder()) {
super();
const _this = this;
this.connection = null;
this.audioSsrcs = {};
this.videoSsrcs = {};
this.remoteVideoSsrcs = {};
this.framesReceived = {};
this.streamIds = {};
this.offscreenUsers = {};
this.offscreenDisabledUsers = {};
this.streamPixelCounts = {};
this.latestWants = getBrowserInvertedWantsConfig("RTCMediaSinkWantsManager.getDefaultWants").invertWants ? {
...c8867_8
} : {
any
};
this.participants = new Set();
this.selectedParticipantId = null;
this.pipOpen = false;
this.simulcastDebugOverrides = new Map();
this.videoHealthManager = null;
this.otherUsers = new Set();
this.delayedUpdate = () => {
_this.delayedCall.delay();
};
this.addLru = (a0, a1, a2) => {
let length2;
a2.push(a0);
if (!(a2.length <= 3)) {
const length = a2.length;
let r1 = 0;
const r6 = 0 < length;
let r2 = -1;
let r10 = -1;
let r17 = -1;
if (r6) {
do {
const r21 = a1 - _this.offscreenUsers[a2[r1]];
const r3 = r1;
let r0 = r2;
let r22 = r10;
if (r21 > r22) {
r0 = r3;
r22 = r21;
}
r1 = r3 + 1;
length2 = a2.length;
r2 = r0;
r10 = r22;
r17 = r2;
} while (r1 < length2);
}
_this.offscreenDisabledUsers[a2[r17]] = true;
a2.splice(r17, 1);
}
};
this.updateOffscreenUsers = () => {
let r33;
const connection = _this.connection;
if (connection == null ? void 0 : connection.getActiveOutputSinkTrackingEnabled()) {
const r39 = Date.now();
const r8 = [];
let r47 = SnowflakeUtils.entries(_this.streamIds)[Symbol.iterator]();
const next = r47.next;
while (true) {
const r16 = r47 === void 0 ? void 0 : (r33 = next.call(r47)).done ? r47 = void 0 : r33.value;
if (r47 === void 0) {
if (!(r8.length > 0)) {
_this.offscreenTimeout.stop();
break;
}
let r102 = r39 + _this.getOffscreenTimeoutMs();
for (const item of r8) {
const r109 = Math;
const r111 = r102;
r102 = r109.min(r111, _this.offscreenUsers[item] + _this.getOffscreenTimeoutMs());
}
_this.offscreenTimeout.start(r102 - r39, _this.update);
break;
}
try {
const [r54, r55] = r16;
if (r55 != null) {
const connection2 = _this.connection;
const r18 = connection2 == null ? void 0 : connection2.getHasActiveVideoOutputSink(r55);
const offscreenUsers = _this.offscreenUsers;
if (r18) {
delete offscreenUsers[r54];
delete _this.offscreenDisabledUsers[r54];
} else if (offscreenUsers[r54] == null) {
const offscreenUsers2 = _this.offscreenUsers;
offscreenUsers2[r54] = r39;
_this.addLru(r54, r39, r8);
} else if (!_this.offscreenDisabledUsers[r54]) {
if (r39 - _this.offscreenUsers[r54] >= _this.getOffscreenTimeoutMs()) {
_this.offscreenDisabledUsers[r54] = true;
} else {
_this.addLru(r54, r39, r8);
}
}
}
} catch (r90) {
if (r47 !== void 0 && typeof r47.return === "function") {
try {
r47.return();
} catch {}
}
throw r90;
}
}
}
};
this.handleLocalVideoDisabled = () => {
_this.update();
};
this.handleLocalMute = () => {
_this.update();
};
this.update = function update(r32 = []) {
let r54;
const wantsLevel = _this.getWantsLevel();
let latestWants = getDefaultWants(wantsLevel);
const invertWants2 = getBrowserInvertedWantsConfig("RTCMediaSinkWantsManager.update").invertWants;
let r65 = latestWants;
if (invertWants2) {
_this.invertWants(latestWants, wantsLevel);
r65 = c8867_11 ? {
...latestWants
} : latestWants;
}
_this.updateOffscreenUsers();
const r18 = isDesktop() && _this.isOneToOneCall() && !_this.isStageChannel;
for (const item of SnowflakeUtils.entries(_this.videoSsrcs)) {
const [r35, r99] = item;
let r100 = [];
let r101 = false;
let r107 = _this.streamPixelCounts[_this.streamIds[r35]];
if (r107 == null) {
r107 = 0;
}
const wantsLevel2 = _this.getWantsLevel(r107);
let ssrc2 = r99[0].ssrc;
if (_this.shouldReceiveFromUser(r35)) {
const r132 = r35 === _this.selectedParticipantId && wantsLevel !== any && !_this.pipOpen;
if (r99.length > 1) {
let r143 = r99[Symbol.iterator]();
const next = r143.next;
while (true) {
const r146 = r143 === void 0 ? void 0 : (r54 = next.call(r143)).done ? r143 = void 0 : r54.value;
if (r143 === void 0) {
if (!_this.supportsSeamless) {
break;
}
if (_this.framesReceived[ssrc2]) {
break;
}
r101 = true;
r100 = [ssrc2];
for (const item3 of r99) {
if (item3.ssrc !== ssrc2 && _this.framesReceived[item3.ssrc]) {
if (item3.quality === any) {
latestWants[item3.ssrc] = any;
} else {
latestWants[item3.ssrc] = r18 ? wantsLevel2 : wantsLevel;
}
r100.push(item3.ssrc);
}
}
break;
}
try {
if (r146.quality === any) {
const ssrc = r146.ssrc;
if (r132) {
latestWants[ssrc] = any;
ssrc2 = r146.ssrc;
} else {
latestWants[ssrc] = 0;
}
} else if (r132) {
latestWants[r146.ssrc] = 0;
} else {
if (r18) {
latestWants[r146.ssrc] = wantsLevel2;
}
ssrc2 = r146.ssrc;
}
} catch (r162) {
if (r143 !== void 0 && typeof r143.return === "function") {
try {
r143.return();
} catch {}
}
throw r162;
}
}
} else if (r132) {
latestWants[ssrc2] = any;
} else if (r18) {
latestWants[ssrc2] = wantsLevel2;
}
} else {
for (const item2 of r99) {
latestWants[item2.ssrc] = 0;
}
}
const simulcastOverrideQuality = _this.getSimulcastOverrideQuality(r35);
if (simulcastOverrideQuality === SimulcastOverrideQuality.HIGH) {
latestWants[ssrc2] = any;
} else if (simulcastOverrideQuality === SimulcastOverrideQuality.LOW) {
latestWants[ssrc2] = 50;
}
if (!(_this.supportsSeamless && r101)) {
r100 = [ssrc2];
}
for (const item4 of r99) {
if (!r100.includes(item4.ssrc)) {
delete _this.framesReceived[item4.ssrc];
}
}
let r243 = r32.includes(r35);
if (!r243) {
r243 = _this.remoteVideoSsrcs[r35] !== void 0 && !shallowEqual(_this.remoteVideoSsrcs[r35], r100);
}
if (!r243) {
continue;
}
const remoteVideoSsrcs = _this.remoteVideoSsrcs;
const r264 = r100;
remoteVideoSsrcs[r35] = [...r264];
_this.emit(c8867_12.UserSSRCUpdate, r35, _this.audioSsrcs[r35], r264);
}
if (c8867_11) {
latestWants = r65;
}
for (const item5 of Object.entries(_this.audioSsrcs)) {
const [r293, r294] = item5;
const connection = _this.connection;
if (connection == null ? void 0 : connection.getLocalMute(r293)) {
latestWants[r294] = 0;
}
}
if (!(_this.connection == null || Module12.isEqual(_this.latestWants, latestWants))) {
_this.latestWants = latestWants;
_this.emit(c8867_12.Update, latestWants);
}
return latestWants;
};
this.incomingVideoEnabledChanged = () => {
_this.update();
};
this.userId = a0;
this.isStageChannel = a1;
this.supportsSeamless = a2;
this.ladder = ladder;
this.delayedCall = new DelayedCall(100, this.update);
this.offscreenTimeout = new Timeout();
WindowVisibilityVideoManager.on(WindowVisibilityEvent.IncomingVideoEnabledChanged, this.incomingVideoEnabledChanged);
}
getWantsLevel(r5 = 0) {
return this.ladder.getMaxSinkValue(this.getVideoParticipantCount(), r5);
}
userVideoDisabled(a0) {
return this.offscreenDisabledUsers[a0];
}
isOneToOneCall() {
return this.otherUsers.size === 1;
}
updateCallUserIds(a0) {
this.otherUsers = new Set(a0);
this.otherUsers.delete(AuthenticationStore.getId());
this.update();
}
shouldReceiveFromUser(a0) {
const connection = this.connection;
let r4 = connection == null ? void 0 : connection.getLocalVideoDisabled(a0);
if (!r4) {
let r12 = this.userVideoDisabled(a0);
if (r12) {
const videoHealthManager = this.videoHealthManager;
r12 = (videoHealthManager == null ? void 0 : videoHealthManager.getCurrentVideoToggleState(a0)) !== VideoToggleState.AUTO_PROBING;
}
r4 = r12;
}
return WindowVisibilityVideoManager.isIncomingVideoEnabled() && !r4;
}
invertWants(a0, a1) {
for (const item of Object.values(this.videoSsrcs)) {
for (const item2 of item) {
if (c8867_11) {
if (item2.quality !== any) {
a0[item2.ssrc] = any;
} else {
a0[item2.ssrc] = 0;
}
} else {
a0[item2.ssrc] = a1;
}
}
}
for (const item3 of Object.values(this.audioSsrcs)) {
a0[item3] = any;
}
}
getAudioSSRCs() {
return this.audioSsrcs;
}
setConnection(a0, r2 = true) {
const connection = this.connection;
if (connection != null) {
connection.removeListener(BaseConnectionEvent.LocalVideoDisabled, this.handleLocalVideoDisabled);
}
const connection2 = this.connection;
if (connection2 != null) {
connection2.removeListener(BaseConnectionEvent.LocalMute, this.handleLocalMute);
}
const connection3 = this.connection;
if (connection3 != null) {
connection3.removeListener(BaseConnectionEvent.ActiveSinksChange, this.delayedUpdate);
}
this.connection = a0;
const connection4 = this.connection;
if (connection4 != null) {
connection4.addListener(BaseConnectionEvent.LocalVideoDisabled, this.handleLocalVideoDisabled);
}
const connection5 = this.connection;
if (connection5 != null) {
connection5.addListener(BaseConnectionEvent.LocalMute, this.handleLocalMute);
}
const connection6 = this.connection;
if (connection6 != null) {
connection6.addListener(BaseConnectionEvent.ActiveSinksChange, this.delayedUpdate);
}
if (r2) {
this.update();
}
}
setAudioSSRC(a0, a1) {
if (a1 > 0) {
this.audioSsrcs[a0] = a1;
} else {
delete this.audioSsrcs[a0];
}
return this.update();
}
setVideoSSRCs(a0, a1) {
const r26 = a1.filter((item) => {
let active = item.active;
if (active) {
let ssrc = item.ssrc;
if (ssrc == null) {
ssrc = 0;
}
active = ssrc > 0;
}
return active;
}).map((item) => {
let quality = item.quality;
if (quality == null) {
quality = any;
}
return {
quality,
ssrc: item.ssrc
};
});
if (r26.length > 0) {
this.videoSsrcs[a0] = r26;
this.participants.add(a0);
} else {
if (this.videoSsrcs[a0] !== void 0) {
for (const item of this.videoSsrcs[a0]) {
delete this.framesReceived[item.ssrc];
}
}
delete this.remoteVideoSsrcs[a0];
delete this.videoSsrcs[a0];
this.participants.delete(a0);
this.emit(c8867_12.UserSSRCUpdate, a0, this.audioSsrcs[a0], []);
}
return this.update(Array.from(this.participants));
}
setFirstFrameReceived(a0) {
this.framesReceived[a0] = true;
return this.update();
}
setStreamId(a0, a1) {
if (a1 != null) {
this.streamIds[a0] = a1;
} else {
if (a0 in this.streamIds) {
delete this.streamPixelCounts[this.streamIds[a0]];
}
delete this.streamIds[a0];
}
return this.update();
}
destroyUser(a0) {
delete this.audioSsrcs[a0];
delete this.videoSsrcs[a0];
this.participants.delete(a0);
delete this.streamPixelCounts[this.streamIds[a0]];
delete this.streamIds[a0];
return this.update(Array.from(this.participants));
}
reset() {
this.setConnection(null, false);
this.audioSsrcs = {};
this.videoSsrcs = {};
this.remoteVideoSsrcs = {};
this.framesReceived = {};
this.streamIds = {};
this.streamPixelCounts = {};
this.latestWants = getBrowserInvertedWantsConfig("RTCMediaSinkWantsManager.getDefaultWants").invertWants ? {
...c8867_8
} : {
any
};
WindowVisibilityVideoManager.off(WindowVisibilityEvent.IncomingVideoEnabledChanged, this.incomingVideoEnabledChanged);
}
setSelectedParticipant(a0) {
if (a0 === this.selectedParticipantId) {
return this.latestWants;
}
const r0 = this.selectedParticipantId != null && this.selectedParticipantId !== this.userId;
const r11 = [];
if (r0) {
r11.push(this.selectedParticipantId);
}
if (a0 != null) {
if (this.participants.has(a0)) {
this.selectedParticipantId = a0;
r11.push(a0);
} else {
if (this.userId !== a0) {
return this.latestWants;
}
this.selectedParticipantId = a0;
}
} else {
this.selectedParticipantId = null;
}
return this.update(r11.filter((item) => this.videoSsrcs[item]?.length > 1));
}
setPipOpen(a0) {
this.pipOpen = a0;
return this.selectedParticipantId != null ? this.update([this.selectedParticipantId]) : this.latestWants;
}
getOffscreenDisabledUsers() {
return this.offscreenDisabledUsers;
}
setSimulcastDebugOverride(a0, a1) {
this.simulcastDebugOverrides.set(a0, a1);
this.update();
}
setVideoSize(a0, a1) {
if (a1 > 0) {
this.streamPixelCounts[a0] = a1;
} else {
delete this.streamPixelCounts[a0];
}
this.delayedUpdate();
}
getVideoParticipantCount() {
let r0 = 0;
for (const item of Object.keys(this.videoSsrcs)) {
const connection = this.connection;
if (!(connection == null ? void 0 : connection.getLocalVideoDisabled(item))) {
r0 = r0 + 1;
}
}
return r0;
}
getOffscreenTimeoutMs() {
return this.isStageChannel ? c8867_10 : c8867_9;
}
getSimulcastOverrideQuality(a0) {
return this.simulcastDebugOverrides.has(a0) ? this.simulcastDebugOverrides.get(a0) : SimulcastOverrideQuality.NO_OVERRIDE;
}
}
export default RTCMediaSinkWantsManager;
export const DEFAULT_WANTS_FULL = {
any: 100
};
export { c8867_8 as DEFAULT_WANTS_DISABLED };
export { c8867_12 as RTCMediaSinkWantsManagerEvent };
+138
View File
@@ -0,0 +1,138 @@
// Metro module 1883 (f1884).
class Record {
constructor() {
return {
__proto__: new.target.prototype
};
}
toJS() {
return {
...this
};
}
set(a0, a1) {
let r16;
L6: {
const r3 = this[a0];
if (a1 instanceof Date && r3 instanceof Date) {
const time = a1.getTime();
const time2 = r3.getTime();
r16 = this;
if (time === time2) {
break L6;
}
}
let r17 = this;
if (r3 !== a1) {
const constructor = this.constructor;
const r19 = {
...this
};
r19[a0] = a1;
r17 = new constructor(r19);
}
r16 = r17;
}
return r16;
}
merge(a0) {
let r15;
let r5 = null;
let r8 = null;
for (const key in a0) {
r15 = r5;
r8 = r15;
const hasOwnProperty = a0.hasOwnProperty(key);
r5 = r15;
if (hasOwnProperty) {
const r17 = this[key];
const r14 = a0[key];
const r2 = r14 instanceof Date && r17 instanceof Date && r14.getTime() === r17.getTime();
r5 = r15;
if (!r2) {
let r28 = r15;
if (r17 !== r14) {
const r29 = r15 == null ? {
...this
} : r15;
r29[key] = a0[key];
r28 = r29;
}
r5 = r28;
}
}
}
r15 = r5;
r8 = r15;
return r8 != null ? new this.constructor(r8) : this;
}
update(a0, a1, a2) {
let r6 = a2;
let r3 = a1;
if (a2 == null) {
r3 = void 0;
r6 = a1;
}
const r9 = this[a0];
let r17 = r9 instanceof Record ? r9 : r9 instanceof Array ? [...r9] : r9 instanceof Object ? {
...r9
} : r9;
if (r17 === void 0) {
r17 = r3;
}
return this.set(a0, r6(r17));
}
}
export default Record;
export class TypedRecord {
constructor() {
return {
__proto__: new.target.prototype
};
}
toJS() {
return {
...this
};
}
set(a0, a1) {
const merge2 = this.merge;
const r0 = {};
r0[a0] = a1;
return merge2.call(this, r0);
}
merge(a0) {
let r11;
let r3 = null;
let r6 = null;
for (const key in a0) {
r11 = r3;
r6 = r11;
const hasOwnProperty = a0.hasOwnProperty(key);
r3 = r11;
if (hasOwnProperty) {
const r13 = a0[key];
const r17 = this[key];
r3 = r11;
if (r17 !== r13) {
const r18 = r11 == null ? this.toJS() : r11;
r18[key] = a0[key];
r3 = r18;
}
}
}
r11 = r3;
r6 = r11;
return r6 != null ? new this.constructor(r6) : this;
}
update(a0, a1, a2) {
const r7 = this[a0];
let r6 = r7 instanceof Record ? r7 : r7 instanceof Array ? [...r7] : r7 instanceof Object ? {
...r7
} : r7;
if (r6 === void 0) {
r6 = a1;
}
return this.set(a0, a2(r6));
}
}
+64
View File
@@ -0,0 +1,64 @@
// Metro module 4283 (f4284).
class SoundshareStatsAggregator {
_report = {
soundshare_attach_requested_count: 0,
soundshare_capturing_count: 0,
soundshare_capture_stopped_count: 0,
soundshare_hooked_count: 0,
soundshare_recv_connect_count: 0,
soundshare_recv_disconnect_count: 0,
soundshare_recv_started_count: 0,
soundshare_recv_stopped_count: 0,
soundshare_recv_failed_count: 0,
soundshare_recv_format_count: 0,
soundshare_send_announce_count: 0,
soundshare_send_start_count: 0,
soundshare_send_stop_count: 0,
soundshare_malformed_trace_count: 0,
soundshare_audio_detected_count: 0,
soundshare_state_transition_detached_count: 0,
soundshare_state_transition_waiting_count: 0,
soundshare_state_transition_attached_count: 0,
soundshare_state_transition_started_count: 0,
soundshare_state_transition_playing_count: 0,
soundshare_state_transition_silence_count: 0,
soundshare_unknown_event_count: 0,
soundshare_first_pid: 0,
soundshare_last_pid: 0,
soundshare_unique_pids: 0,
soundshare_first_session: null,
soundshare_last_session: null
};
_pids = new Set();
traceEvent(a0, a1) {
const _report = this._report;
const r15 = a1.type === "soundshare_state_transition" ? `soundshare_state_transition_${["detached", "waiting", "attached", "started", "playing", "silence"][a1.newState]}_count` : `${a1.type}_count`;
if (_report[r15] !== void 0) {
if (_report[r15] < 32767) {
_report[r15] = _report[r15] + 1;
}
} else {
_report.soundshare_unknown_event_count = _report.soundshare_unknown_event_count + 1;
}
if ("pid" in a1) {
if (_report.soundshare_first_pid === 0) {
_report.soundshare_first_pid = a1.pid;
}
_report.soundshare_last_pid = a1.pid;
this._pids.add(a1.pid);
}
if (a0 != null) {
if (_report.soundshare_first_session == null) {
_report.soundshare_first_session = a0;
}
_report.soundshare_last_session = a0;
}
}
getStats() {
return {
...this._report,
soundshare_unique_pids: this._pids.size
};
}
}
export default SoundshareStatsAggregator;
+63
View File
@@ -0,0 +1,63 @@
// Metro module 12732 (f12733).
import isUndefinedOrNull from "../_bundle/isUndefinedOrNull";
class StateManager {
constructor(alwaysUpdateState = true) {
const r5 = {
__proto__: new.target.prototype,
dirty: false
};
r5.state = r5.getInitialState();
r5.alwaysUpdateState = alwaysUpdateState;
return r5;
}
shouldCommit() {
return true;
}
setState(a0) {
this.state = {
...this.state,
...a0
};
}
getState() {
return this.state;
}
reset() {
this.dirty = false;
this.state = this.getInitialState();
}
update(r7 = {}, r2 = false) {
const nextState = this.getNextState({
...this.state,
...r7
});
if (r2) {
this.dirty = !isUndefinedOrNull(nextState, this.getInitialState());
} else {
for (const item of Object.keys(nextState)) {
let dirty = this.dirty;
if (!dirty) {
const state = this.state;
dirty = !isUndefinedOrNull(state[item], nextState[item]);
}
this.dirty = dirty;
}
}
const r55 = this.dirty && this.shouldCommit();
if (r55 || this.alwaysUpdateState) {
this.state = nextState;
}
let r59 = !!r55;
if (r59) {
this.dirty = false;
this.didCommit(this.state);
r59 = true;
}
return r59;
}
forceUpdate() {
this.dirty = false;
this.didCommit(this.state);
}
}
export default StateManager;
+131
View File
@@ -0,0 +1,131 @@
// Metro module 6034 (f6035).
import { Histogram } from "./Histogram";
import ProcessUtils_native from "../utils/ProcessUtils.native";
import { getDeviceState } from "../modules/device/DeviceState";
class SystemResources {
constructor() {
const r14 = {
__proto__: new.target.prototype,
cpuHistogram: new Histogram(),
memoryHistogram: null,
startCPU: null
};
r14.memoryHistogram = new Histogram();
r14.startCPU = ProcessUtils_native.getCumulativeCPUUsage();
r14.lastCPU = r14.startCPU;
r14.lastBattery = null;
return r14;
}
getStats() {
const report = this.cpuHistogram.getReport();
const report2 = this.memoryHistogram.getReport();
const cumulativeCPUUsage = ProcessUtils_native.getCumulativeCPUUsage();
let client_performance_cpu_mean = this.startCPU == null ? void 0 : cumulativeCPUUsage == null ? void 0 : 100 * (cumulativeCPUUsage.usage - this.startCPU.usage) / ((cumulativeCPUUsage.sampleTime - this.startCPU.sampleTime) / 1000);
if (client_performance_cpu_mean == null) {
client_performance_cpu_mean = report.mean;
}
return {
client_performance_cpu_percentile25: report.percentiles[25],
client_performance_cpu_percentile50: report.percentiles[50],
client_performance_cpu_percentile75: report.percentiles[75],
client_performance_cpu_percentile90: report.percentiles[90],
client_performance_cpu_percentile95: report.percentiles[95],
client_performance_cpu_mean,
client_performance_memory_percentile25: report2.percentiles[25],
client_performance_memory_percentile50: report2.percentiles[50],
client_performance_memory_percentile75: report2.percentiles[75],
client_performance_memory_percentile90: report2.percentiles[90],
client_performance_memory_percentile95: report2.percentiles[95],
client_performance_memory_min: report2.min,
client_performance_memory_max: report2.max,
client_performance_memory_mean: report2.mean
};
}
takeSample() {
const cumulativeCPUUsage = ProcessUtils_native.getCumulativeCPUUsage();
const currentMemoryUsageKB = ProcessUtils_native.getCurrentMemoryUsageKB();
if (cumulativeCPUUsage != null) {
const r6 = this.lastCPU != null;
let r2 = true;
if (r6) {
const r31 = cumulativeCPUUsage.sampleTime - this.lastCPU.sampleTime;
r2 = false;
if (r31 >= 1) {
this.cpuHistogram.addSample((cumulativeCPUUsage.usage - this.lastCPU.usage) / (r31 / 1000) * 100, r31);
r2 = true;
}
}
if (r2) {
this.lastCPU = cumulativeCPUUsage;
}
} else {
const currentCPUUsagePercent = ProcessUtils_native.getCurrentCPUUsagePercent();
if (currentCPUUsagePercent != null) {
this.cpuHistogram.addSample(currentCPUUsagePercent);
}
}
if (currentMemoryUsageKB != null) {
this.memoryHistogram.addSample(currentMemoryUsageKB);
}
}
async getCurrentBattery() {
let batteryLevel;
let c25680_3 = 0;
try {
c25680_3 = 1;
batteryLevel = (await getDeviceState({
fallback: false
})).batteryLevel;
c25680_3 = 0;
} catch ($e) {
let r8 = $e;
if (c25680_3 !== 0) {
while (true) {
try {
c25680_3 = 0;
} catch ($e) {
r8 = $e;
if (c25680_3 === 0) {
break;
}
continue;
}
return null;
}
}
throw r8;
}
return batteryLevel;
}
async setLastBattery() {
const _this = this;
const _this3 = _this;
_this3.lastBattery = await _this.getCurrentBattery();
}
async getBatteryLevelStats() {
let r50;
const _this2 = this;
let c25682_1;
let c29651_0;
L13: {
c25682_1 = void 0;
c29651_0 = void 0;
c29651_0 = await _this2.getCurrentBattery();
if (_this2.lastBattery != null && c29651_0 != null) {
r50 = {
startBattery: _this2.lastBattery,
currentBattery: c29651_0,
batteryUsageRounded: Math.round(1000 * (c29651_0 - _this2.lastBattery)) / 1000
};
break L13;
}
r50 = {
startBattery: _this2.lastBattery,
currentBattery: c29651_0,
batteryUsageRounded: null
};
}
return r50;
}
}
export default SystemResources;
+42
View File
@@ -0,0 +1,42 @@
// Metro module 12876 (f12877).
import { Histogram } from "./Histogram";
import { BaseConnectionEvent } from "../_bundle/Module4286";
import Module12 from "../_bundle/Module12";
class SystemResponsiveness {
sampleStats = (a0) => {
if (a0 != null) {
Module12.forEach(a0.rtp.outbound, (a0) => {
if (a0.type === "audio") {
let pttQueueLatencyMicrosSamples = a0.pttQueueLatencyMicrosSamples;
if (pttQueueLatencyMicrosSamples == null) {
pttQueueLatencyMicrosSamples = [];
}
for (const item of pttQueueLatencyMicrosSamples) {
this.pttQueueLatencyHistogram.addSample(item / 1000);
}
}
});
}
};
constructor(a0) {
this.connection = a0;
this.pttQueueLatencyHistogram = new Histogram();
}
start() {
this.connection.on(BaseConnectionEvent.Stats, this.sampleStats);
}
stop() {
this.connection.off(BaseConnectionEvent.Stats, this.sampleStats);
}
getPttQueueLatencyStats() {
const report = this.pttQueueLatencyHistogram.getReport([50, 95]);
return {
ptt_queue_latency_max: report.max,
ptt_queue_latency_mean: report.mean,
ptt_queue_latency_p50: report.percentiles[50],
ptt_queue_latency_p95: report.percentiles[95],
ptt_queue_latency_samples: report.samples
};
}
}
export default SystemResponsiveness;
+196
View File
@@ -0,0 +1,196 @@
// Metro module 12879 (f12880).
import { VideoToggleState } from "../Constants";
import Logger from "../modules/debug/Logger";
import { isMobile } from "../_bundle/Module4426";
import dispatchAutoDisableVideo from "../modules/media_engine/dispatchAutoDisableVideo";
import { now } from "../_bundle/sleep";
import Durations from "../utils/Durations";
export class VideoHealthManager {
static defaultConfig = {
featureEnabled: isMobile,
windowLength: 5,
allowedPoorFpsRatio: 1,
fpsThreshold: 5,
backoffTimeSec: 15
};
constructor(a0, a1, a2, a3) {
const r27 = {
__proto__: new.target.prototype,
logger: new Logger("VideoHealthManager"),
disabled: false,
perUserFpsWindow: null,
prevFramesCodec: null,
prevTimestamp: null,
streamDisabledUsers: null,
retryBackoffCache: null,
timeoutIdCache: null,
currentVideoAutoToggleState: null,
enableQueue: null
};
r27.perUserFpsWindow = {};
r27.prevFramesCodec = {};
r27.prevTimestamp = {};
r27.streamDisabledUsers = new Set();
r27.retryBackoffCache = {};
r27.timeoutIdCache = {};
r27.currentVideoAutoToggleState = {};
r27.enableQueue = [];
r27.windowLength = a0;
r27.fpsThreshold = a2;
r27.fpsWindowBorderlineCount = Math.ceil(a0 * a1);
r27.backoffTimeSec = a3;
r27.logger.enableNativeLogger(true);
r27.logger.info(`constructor with windowLength = ${r27.windowLength},
fpsWindowBorderlineCount = ${r27.fpsWindowBorderlineCount},
fpsThreshold = ${r27.fpsThreshold},
backoffTimeSec = ${a3}`);
return r27;
}
calculateFps(a0, a1, a2) {
if (this.prevFramesCodec[a0] !== -1 && !(a1 < this.prevFramesCodec[a0]) && !(a2 < this.prevTimestamp[a0]) && !(a2 > this.prevTimestamp[a0] + 1000 * this.windowLength)) {
if (a2 < this.prevTimestamp[a0] + 900) {
return NaN;
}
const r24 = this.elapsedSeconds(a2, this.prevTimestamp[a0]);
this.prevTimestamp[a0] = a2;
const r29 = (a1 - this.prevFramesCodec[a0]) / r24;
this.prevFramesCodec[a0] = a1;
return r29;
}
this.prevFramesCodec[a0] = a1;
this.prevTimestamp[a0] = a2;
this.perUserFpsWindow[a0] = [];
return NaN;
}
updateFps(a0, a1, a2) {
L15: {
if (!this.disabled && !this.streamDisabledUsers.has(a0)) {
const r8 = this.calculateFps(a0, a1, a2);
if (!(r8 < 0) && Number.isFinite(r8)) {
this.perUserFpsWindow[a0].push(r8);
if (this.perUserFpsWindow[a0].length < this.windowLength) {
return void 0;
}
if (this.perUserFpsWindow[a0].length > this.windowLength) {
this.perUserFpsWindow[a0].shift();
}
if (this.perUserFpsWindow[a0].filter((item) => item < this.fpsThreshold).length >= this.fpsWindowBorderlineCount) {
this.logger.info(`${a0}: detected poor network quality, turning off video`);
this.streamDisabledUsers.add(a0);
this.currentVideoAutoToggleState[a0] = VideoToggleState.DISABLED;
dispatchAutoDisableVideo(a0, VideoToggleState.DISABLED);
this.startReenableBackoffTimer(a0);
} else if (this.currentVideoAutoToggleState[a0] === VideoToggleState.AUTO_PROBING) {
this.currentVideoAutoToggleState[a0] = VideoToggleState.AUTO_ENABLED;
this.logger.info(`acceptable conditions reached, will reset and send a AUTO_ENABLED for user ${a0}`);
dispatchAutoDisableVideo(a0, VideoToggleState.AUTO_ENABLED);
}
if (this.probingUserId !== a0) {
break L15;
}
this.probingUserId = void 0;
this.tryReenableQueue();
break L15;
}
return void 0;
}
}
}
startReenableBackoffTimer(a0) {
if (!this.disabled) {
this.logger.info(`startReenableBackoffTimer for user ${a0}`);
const r19 = this.retryBackoffCache[a0];
const { lastBackoffTime, expBackoffFactor } = r19;
const expBackoffFactor2 = lastBackoffTime !== null ? expBackoffFactor > 16 ? 1 : this.elapsedSeconds(now(), lastBackoffTime) > 600 ? 1 : expBackoffFactor * 2 : 1;
this.retryBackoffCache[a0] = {
lastBackoffTime: now(),
expBackoffFactor: expBackoffFactor2
};
const r50 = expBackoffFactor2 * this.backoffTimeSec * Durations.Millis.SECOND;
this.logger.info(`starting backoff timer with time = ${r50} milliseconds`);
this.timeoutIdCache[a0] = setTimeout(() => {
this.queueReenable(a0);
}, r50);
}
}
queueReenable(a0) {
this.enableQueue.push(a0);
this.tryReenableQueue();
}
tryReenableQueue() {
let r14;
L7: {
if (!this.disabled) {
if (this.probingUserId != null && this.probingUserId in this.perUserFpsWindow) {
break L7;
}
const r9 = this.enableQueue.shift();
if (r9 != null && !this.reenableVideo(r9)) {
do {
r14 = this.enableQueue.shift();
if (r14 == null) {
break;
}
} while (!this.reenableVideo(r14));
}
}
}
}
reenableVideo(a0) {
let r0 = a0 in this.perUserFpsWindow;
if (r0) {
this.logger.info(`reenableVideo called for user ${a0} - time = ${now()}`);
this.stateCleanupBeforeEnable(a0);
this.currentVideoAutoToggleState[a0] = VideoToggleState.AUTO_PROBING;
this.probingUserId = a0;
dispatchAutoDisableVideo(a0, VideoToggleState.AUTO_PROBING);
r0 = true;
}
return r0;
}
elapsedSeconds(a0, a1) {
return (a0 - a1) / 1000;
}
stateCleanupBeforeEnable(a0) {
this.logger.info("VideoHealthManager::stateCleanupBeforeEnable");
this.perUserFpsWindow[a0] = [];
this.prevFramesCodec[a0] = -1;
this.streamDisabledUsers.delete(a0);
}
getCurrentVideoToggleState(a0) {
return this.currentVideoAutoToggleState[a0];
}
createUser(a0) {
this.logger.info(`VideoHealthManager::createUser ${a0}`);
if (!(a0 in this.perUserFpsWindow)) {
this.perUserFpsWindow[a0] = [];
this.prevFramesCodec[a0] = -1;
this.currentVideoAutoToggleState[a0] = VideoToggleState.NONE;
this.retryBackoffCache[a0] = {
lastBackoffTime: null,
expBackoffFactor: 1
};
}
}
deleteUser(a0) {
this.logger.info(`VideoHealthManager::deleteUser ${a0}`);
delete this.perUserFpsWindow[a0];
delete this.prevFramesCodec[a0];
delete this.retryBackoffCache[a0];
delete this.currentVideoAutoToggleState[a0];
this.streamDisabledUsers.delete(a0);
if (a0 === this.probingUserId) {
this.probingUserId = void 0;
this.tryReenableQueue();
}
clearTimeout(this.timeoutIdCache[a0]);
delete this.timeoutIdCache[a0];
}
disable() {
this.disabled = true;
const perUserFpsWindow = this.perUserFpsWindow;
for (const key in perUserFpsWindow) {
this.deleteUser(key);
}
}
}
+1078
View File
File diff suppressed because it is too large. Load diff
+982
View File
@@ -0,0 +1,982 @@
// Metro module 6027 (f6028).
import _slicedToArray from "../_bundle/_slicedToArray";
import { Histogram } from "./Histogram";
import SystemResources from "./SystemResources";
import { StopWatch } from "../_bundle/sleep";
let c3815_4, c3815_5, c3815_6, _excluded, c3815_8, c3815_9, c3815_10, c3815_11, c3815_12, c3815_13, parseDecoder, RawVideoStats;
const parseEncoder = function parseEncoder(a0) {
if (a0 == null) {
return c3815_9.UNKNOWN;
}
for (const item of Object.keys(c3815_11)) {
if (!a0.toLowerCase().includes(item)) {
continue;
}
return c3815_11[item];
}
return c3815_9.UNCATEGORIZED;
};
parseDecoder = function parseDecoder(decoderImplementationName) {
if (decoderImplementationName == null) {
return c3815_10.UNKNOWN;
}
for (const item of Object.keys(c3815_12)) {
if (!decoderImplementationName.toLowerCase().includes(item)) {
continue;
}
return c3815_12[item];
}
return c3815_10.UNCATEGORIZED;
};
c3815_4 = [0, 500000, 1000000, 1500000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000];
c3815_5 = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60];
c3815_6 = [720, 480, 360];
_excluded = ["framesCodec", "framesNetwork", "packets", "packetsLost", "framesDropped", "networkFramesDropped", "framesCodecError", "bytes", "nackCount", "pliCount", "qpSum", "freezeCount", "pauseCount", "totalFreezesDuration", "totalPausesDuration", "totalFramesDuration", "totalDecodeTime", "keyframes", "passthroughCount", "cryptorSuccessCount", "cryptorFailureCount", "cryptorDuration", "cryptorAttempts", "cryptorMissingKeyCount", "cryptorInvalidNonceCount", "qualityDecodeErrors", "qualityDecoderReboots", "qualityScoreErrors", "qualityFrameDrops", "qualitySizeMismatches", "screenshareFramesUnique"];
c3815_8 = {
H264: "H264",
H265: "H265",
VP8: "VP8",
VP9: "VP9",
AV1: "AV1",
UNKNOWN: "UNKNOWN"
};
c3815_9 = {
NVIDIA_CUDA: "nvidia_cuda",
NVIDIA_DIRECT_3D: "nvidia_direct_3d",
NVIDIA_VULKAN: "nvidia_vulkan",
OPENH264: "openh264",
VIDEOTOOLBOX: "videotoolbox",
AMD_DIRECT_3D: "amd_direct_3d",
AMD_VAAPI: "amd_vaapi",
INTEL: "intel",
INTEL_DIRECT_3D: "intel_direct_3d",
INTEL_VAAPI: "intel_vaapi",
VP8_LIBVPX: "vp8_libvpx",
EXYNOS: "exynos",
QUALCOMM: "qualcomm",
MEDIATEK: "mediatek",
WMF_SW: "wmf_sw",
WMF_HW: "wmf_hw",
WMF_DIRECT_3D: "wmf_direct_3d",
WMF_DIRECT_3D_INTEL: "wmf_direct_3d_intel",
WMF_DIRECT_3D_NVIDIA: "wmf_direct_3d_nvidia",
WMF_DIRECT_3D_AMD: "wmf_direct_3d_amd",
WMF_CHROME: "wmf_chrome",
UNCATEGORIZED: "uncategorized",
UNKNOWN: "unknown"
};
c3815_10 = {
VIDEOTOOLBOX: "videotoolbox",
VP8_LIBVPX: "vp8_libvpx",
ELECTRON: "electron",
FFMPEG: "ffmpeg",
DAV1D: "dav1d",
WEBRTC: "WebRTC",
EXYNOS: "exynos",
QUALCOMM: "qualcomm",
MEDIATEK: "mediatek",
UNCATEGORIZED: "uncategorized",
D3D11VIDEODECODER: "d3d11videodecoder",
ANDROID: "android",
UNKNOWN: "unknown"
};
c3815_11 = Object.freeze({
"mediafoundation direct3d intel": c3815_9.WMF_DIRECT_3D_INTEL,
"mediafoundation direct3d nvidia": c3815_9.WMF_DIRECT_3D_NVIDIA,
"mediafoundation direct3d amd": c3815_9.WMF_DIRECT_3D_AMD,
mediafoundationvideoencodeaccelerator: c3815_9.WMF_CHROME,
"nvidia: cuda": c3815_9.NVIDIA_CUDA,
"nvidia: direct3d": c3815_9.NVIDIA_DIRECT_3D,
"nvidia: vulkan": c3815_9.NVIDIA_VULKAN,
"amd: direct3d": c3815_9.AMD_DIRECT_3D,
"amd: vaapi": c3815_9.AMD_VAAPI,
"intel: direct3d": c3815_9.INTEL_DIRECT_3D,
"intel: vaapi": c3815_9.INTEL_VAAPI,
intel: c3815_9.INTEL,
videotoolbox: c3815_9.VIDEOTOOLBOX,
openh264: c3815_9.OPENH264,
libvpx: c3815_9.VP8_LIBVPX,
"c2.exynos": c3815_9.EXYNOS,
"omx.exynos": c3815_9.EXYNOS,
"c2.qti": c3815_9.QUALCOMM,
"omx.qcom": c3815_9.QUALCOMM,
"c2.mtk": c3815_9.MEDIATEK,
"omx.mtk": c3815_9.MEDIATEK,
"mediafoundation sw": c3815_9.WMF_SW,
"mediafoundation hw": c3815_9.WMF_HW,
"mediafoundation direct3d": c3815_9.WMF_DIRECT_3D
});
c3815_12 = Object.freeze({
videotoolbox: c3815_10.VIDEOTOOLBOX,
libvpx: c3815_10.VP8_LIBVPX,
electron: c3815_10.ELECTRON,
ffmpeg: c3815_10.FFMPEG,
dav1d: c3815_10.DAV1D,
webrtc: c3815_10.WEBRTC,
"c2.exynos": c3815_10.EXYNOS,
"omx.exynos": c3815_10.EXYNOS,
"c2.qti": c3815_10.QUALCOMM,
"omx.qcom": c3815_10.QUALCOMM,
"c2.mtk": c3815_10.MEDIATEK,
"omx.mtk": c3815_10.MEDIATEK,
d3d11videodecoder: c3815_10.D3D11VIDEODECODER,
"c2.android": c3815_10.ANDROID,
"omx.google": c3815_10.ANDROID
});
c3815_13 = {
None: 0,
0: "None",
ClientSideDisableVideo: 1,
1: "ClientSideDisableVideo",
SenderStopped: 2,
2: "SenderStopped"
};
const RawVideoStats2 = class RawVideoStats {
constructor() {
return {
__proto__: new.target.prototype,
bytes: 0,
framesCodec: 0,
framesCodecError: null,
framesNetwork: 0,
resolution: 0,
minorResolution: 0,
majorResolution: 0,
timestamp: 0,
packets: 0,
packetsLost: 0,
framesDropped: 0,
networkFramesDropped: 0,
nackCount: 0,
pliCount: 0,
encoder: null,
decoder: null,
codecType: null,
qpSum: 0,
freezeCount: 0,
pauseCount: 0,
totalFreezesDuration: 0,
totalPausesDuration: 0,
totalFramesDuration: 0,
totalDecodeTime: 0,
vmafScore: null,
psnrDb: null,
outboundSinkWant: null,
keyframes: null,
framesDroppedRateLimiter: null,
framesDroppedEncoderQueue: null,
framesDroppedCongestionWindow: null,
framesDroppedEncoder: null,
passthroughCount: 0,
cryptorSuccessCount: 0,
cryptorFailureCount: 0,
cryptorDuration: 0,
cryptorAttempts: 0,
cryptorMaxAttempts: 0,
cryptorMissingKeyCount: 0,
cryptorInvalidNonceCount: 0,
qualityDecodeErrors: 0,
qualityDecoderReboots: 0,
qualityScoreErrors: 0,
qualityFrameDrops: 0,
qualitySizeMismatches: 0,
localWant: 0,
consecutiveStaticColorFrames: 0,
screenshareFramesUnique: 0
};
}
static parseInboundStats(a0, a1) {
let UNKNOWN;
const r16 = {
__proto__: RawVideoStats.prototype,
bytes: 0,
framesCodec: 0,
framesCodecError: null,
framesNetwork: 0,
resolution: 0,
minorResolution: 0,
majorResolution: 0,
timestamp: 0,
packets: 0,
packetsLost: 0,
framesDropped: 0,
networkFramesDropped: 0,
nackCount: 0,
pliCount: 0,
encoder: null,
decoder: null,
codecType: null,
qpSum: 0,
freezeCount: 0,
pauseCount: 0,
totalFreezesDuration: 0,
totalPausesDuration: 0,
totalFramesDuration: 0,
totalDecodeTime: 0,
vmafScore: null,
psnrDb: null,
outboundSinkWant: null,
keyframes: null,
framesDroppedRateLimiter: null,
framesDroppedEncoderQueue: null,
framesDroppedCongestionWindow: null,
framesDroppedEncoder: null,
passthroughCount: 0,
cryptorSuccessCount: 0,
cryptorFailureCount: 0,
cryptorDuration: 0,
cryptorAttempts: 0,
cryptorMaxAttempts: 0,
cryptorMissingKeyCount: 0,
cryptorInvalidNonceCount: 0,
qualityDecodeErrors: 0,
qualityDecoderReboots: 0,
qualityScoreErrors: 0,
qualityFrameDrops: 0,
qualitySizeMismatches: 0,
localWant: 0,
consecutiveStaticColorFrames: 0,
screenshareFramesUnique: 0
};
if (a0 != null) {
r16.bytes = a0.bytesReceived;
r16.framesCodec = a0.framesDecoded;
let framesDecodeErrors = a0.framesDecodeErrors;
if (framesDecodeErrors == null) {
framesDecodeErrors = null;
}
r16.framesCodecError = framesDecodeErrors;
r16.framesNetwork = a0.framesReceived;
r16.packets = a0.packetsReceived;
r16.packetsLost = a0.packetsLost;
let framesDropped = a0.framesDropped;
if (framesDropped == null) {
framesDropped = 0;
}
r16.framesDropped = framesDropped;
let networkFramesDropped = a0.networkFramesDropped;
if (networkFramesDropped == null) {
networkFramesDropped = 0;
}
r16.networkFramesDropped = networkFramesDropped;
r16.resolution = a0.resolution != null ? a0.resolution.height : 0;
r16.minorResolution = a0.resolution != null ? Math.min(a0.resolution.height, a0.resolution.width) : 0;
const majorResolution = a0.resolution != null ? Math.max(a0.resolution.height, a0.resolution.width) : 0;
L34: {
r16.majorResolution = majorResolution;
r16.timestamp = a1;
r16.nackCount = a0.nackCount;
r16.pliCount = a0.pliCount;
r16.decoder = parseDecoder(a0.decoderImplementationName);
const name = a0.codec.name;
if (name == null) {
UNKNOWN = c3815_8.UNKNOWN;
} else {
const r53 = name.toUpperCase();
if (r53 === "H264") {
UNKNOWN = c3815_8.H264;
} else if (r53 === "H265") {
UNKNOWN = c3815_8.H265;
} else if (r53 === "VP8") {
UNKNOWN = c3815_8.VP8;
} else if (r53 === "VP9") {
UNKNOWN = c3815_8.VP9;
} else {
if (r53 !== "AV1" && r53 !== "AV1X") {
UNKNOWN = c3815_8.UNKNOWN;
break L34;
}
UNKNOWN = c3815_8.AV1;
}
}
}
r16.codecType = UNKNOWN;
r16.qpSum = 0;
r16.freezeCount = a0.freezeCount;
r16.pauseCount = a0.pauseCount;
r16.totalFreezesDuration = a0.totalFreezesDuration;
r16.totalPausesDuration = a0.totalPausesDuration;
r16.totalFramesDuration = a0.totalFramesDuration;
let totalDecodeTime = a0.totalDecodeTime;
if (totalDecodeTime == null) {
totalDecodeTime = 0;
}
r16.totalDecodeTime = totalDecodeTime;
let keyFramesDecoded = a0.keyFramesDecoded;
if (keyFramesDecoded == null) {
keyFramesDecoded = null;
}
r16.keyframes = keyFramesDecoded;
let passthroughCount = a0.passthroughCount;
if (passthroughCount == null) {
passthroughCount = 0;
}
r16.passthroughCount = passthroughCount;
let decryptSuccessCount = a0.decryptSuccessCount;
if (decryptSuccessCount == null) {
decryptSuccessCount = 0;
}
r16.cryptorSuccessCount = decryptSuccessCount;
let decryptFailureCount = a0.decryptFailureCount;
if (decryptFailureCount == null) {
decryptFailureCount = 0;
}
r16.cryptorFailureCount = decryptFailureCount;
let decryptDuration = a0.decryptDuration;
if (decryptDuration == null) {
decryptDuration = 0;
}
r16.cryptorDuration = decryptDuration;
let decryptAttempts = a0.decryptAttempts;
if (decryptAttempts == null) {
decryptAttempts = 0;
}
r16.cryptorAttempts = decryptAttempts;
let decryptMissingKeyCount = a0.decryptMissingKeyCount;
if (decryptMissingKeyCount == null) {
decryptMissingKeyCount = 0;
}
r16.cryptorMissingKeyCount = decryptMissingKeyCount;
let decryptInvalidNonceCount = a0.decryptInvalidNonceCount;
if (decryptInvalidNonceCount == null) {
decryptInvalidNonceCount = 0;
}
r16.cryptorInvalidNonceCount = decryptInvalidNonceCount;
let sinkWantLocalAsInt = a0.sinkWantLocalAsInt;
if (sinkWantLocalAsInt == null) {
sinkWantLocalAsInt = 0;
}
r16.localWant = sinkWantLocalAsInt;
}
return r16;
}
static parseOutboundStats(a0, a1) {
let UNKNOWN;
let r16 = {
__proto__: RawVideoStats.prototype,
bytes: 0,
framesCodec: 0,
framesCodecError: null,
framesNetwork: 0,
resolution: 0,
minorResolution: 0,
majorResolution: 0,
timestamp: 0,
packets: 0,
packetsLost: 0,
framesDropped: 0,
networkFramesDropped: 0,
nackCount: 0,
pliCount: 0,
encoder: null,
decoder: null,
codecType: null,
qpSum: 0,
freezeCount: 0,
pauseCount: 0,
totalFreezesDuration: 0,
totalPausesDuration: 0,
totalFramesDuration: 0,
totalDecodeTime: 0,
vmafScore: null,
psnrDb: null,
outboundSinkWant: null,
keyframes: null,
framesDroppedRateLimiter: null,
framesDroppedEncoderQueue: null,
framesDroppedCongestionWindow: null,
framesDroppedEncoder: null,
passthroughCount: 0,
cryptorSuccessCount: 0,
cryptorFailureCount: 0,
cryptorDuration: 0,
cryptorAttempts: 0,
cryptorMaxAttempts: 0,
cryptorMissingKeyCount: 0,
cryptorInvalidNonceCount: 0,
qualityDecodeErrors: 0,
qualityDecoderReboots: 0,
qualityScoreErrors: 0,
qualityFrameDrops: 0,
qualitySizeMismatches: 0,
localWant: 0,
consecutiveStaticColorFrames: 0,
screenshareFramesUnique: 0
};
if (a0 != null) {
let framesSent = a0.framesSent;
if (framesSent == null) {
framesSent = 0;
}
let packetsLost = a0.packetsLost;
if (packetsLost == null) {
packetsLost = 0;
}
const r17 = {
bytes: a0.bytesSent,
framesCodec: a0.framesEncoded,
framesCodecError: null,
framesNetwork: framesSent,
packets: a0.packetsSent,
packetsLost,
framesDropped: 0,
networkFramesDropped: 0,
resolution: a0.resolution != null ? a0.resolution.height : 0,
minorResolution: a0.resolution != null ? Math.min(a0.resolution.height, a0.resolution.width) : 0,
majorResolution: null,
timestamp: null,
encoder: null,
decoder: null,
codecType: null,
nackCount: null,
pliCount: null,
qpSum: null,
freezeCount: null,
pauseCount: 0,
totalFreezesDuration: null,
totalPausesDuration: 0,
totalFramesDuration: null,
totalDecodeTime: 0,
outboundSinkWant: null,
vmafScore: null,
qualityDecodeErrors: null,
qualityDecoderReboots: null,
qualityScoreErrors: null,
qualityFrameDrops: null,
qualitySizeMismatches: null,
psnrDb: null,
keyframes: null,
framesDroppedRateLimiter: null,
framesDroppedEncoderQueue: null,
framesDroppedCongestionWindow: null,
framesDroppedEncoder: null,
passthroughCount: null,
cryptorSuccessCount: null,
cryptorFailureCount: null,
cryptorDuration: null,
cryptorAttempts: null,
cryptorMaxAttempts: null,
cryptorMissingKeyCount: null,
cryptorInvalidNonceCount: 0,
localWant: 0,
consecutiveStaticColorFrames: null,
screenshareFramesUnique: 0
};
const majorResolution = a0.resolution != null ? Math.max(a0.resolution.height, a0.resolution.width) : 0;
L32: {
r17.majorResolution = majorResolution;
r17.timestamp = a1;
r17.encoder = parseEncoder(a0.encoderImplementationName);
const name = a0.codec.name;
if (name == null) {
UNKNOWN = c3815_8.UNKNOWN;
} else {
const r49 = name.toUpperCase();
if (r49 === "H264") {
UNKNOWN = c3815_8.H264;
} else if (r49 === "H265") {
UNKNOWN = c3815_8.H265;
} else if (r49 === "VP8") {
UNKNOWN = c3815_8.VP8;
} else if (r49 === "VP9") {
UNKNOWN = c3815_8.VP9;
} else {
if (r49 !== "AV1" && r49 !== "AV1X") {
UNKNOWN = c3815_8.UNKNOWN;
break L32;
}
UNKNOWN = c3815_8.AV1;
}
}
}
r17.codecType = UNKNOWN;
r17.nackCount = a0.nackCount;
r17.pliCount = a0.pliCount;
r17.qpSum = a0.qpSum;
let freezeCount = a0.freezeCount;
if (freezeCount == null) {
freezeCount = 0;
}
r17.freezeCount = freezeCount;
let totalFreezesDuration = a0.totalFreezesDuration;
if (totalFreezesDuration == null) {
totalFreezesDuration = 0;
}
r17.totalFreezesDuration = totalFreezesDuration;
let totalFramesDuration = a0.totalFramesDuration;
if (totalFramesDuration == null) {
totalFramesDuration = 0;
}
r17.totalFramesDuration = totalFramesDuration;
let sinkWantAsInt = a0.sinkWantAsInt;
if (sinkWantAsInt == null) {
sinkWantAsInt = null;
}
r17.outboundSinkWant = sinkWantAsInt;
let encoderQualityVmaf = a0.encoderQualityVmaf;
if (encoderQualityVmaf == null) {
encoderQualityVmaf = null;
}
r17.vmafScore = encoderQualityVmaf;
let qualityDecodeErrors = a0.qualityDecodeErrors;
if (qualityDecodeErrors == null) {
qualityDecodeErrors = 0;
}
r17.qualityDecodeErrors = qualityDecodeErrors;
let qualityDecoderReboots = a0.qualityDecoderReboots;
if (qualityDecoderReboots == null) {
qualityDecoderReboots = 0;
}
r17.qualityDecoderReboots = qualityDecoderReboots;
let qualityScoreErrors = a0.qualityScoreErrors;
if (qualityScoreErrors == null) {
qualityScoreErrors = 0;
}
r17.qualityScoreErrors = qualityScoreErrors;
let qualityFrameDrops = a0.qualityFrameDrops;
if (qualityFrameDrops == null) {
qualityFrameDrops = 0;
}
r17.qualityFrameDrops = qualityFrameDrops;
let qualitySizeMismatches = a0.qualitySizeMismatches;
if (qualitySizeMismatches == null) {
qualitySizeMismatches = 0;
}
r17.qualitySizeMismatches = qualitySizeMismatches;
let encoderQualityPsnr = a0.encoderQualityPsnr;
if (encoderQualityPsnr == null) {
encoderQualityPsnr = null;
}
r17.psnrDb = encoderQualityPsnr;
let keyFramesEncoded = a0.keyFramesEncoded;
if (keyFramesEncoded == null) {
keyFramesEncoded = null;
}
r17.keyframes = keyFramesEncoded;
let framesDroppedRateLimiter = a0.framesDroppedRateLimiter;
if (framesDroppedRateLimiter == null) {
framesDroppedRateLimiter = null;
}
r17.framesDroppedRateLimiter = framesDroppedRateLimiter;
let framesDroppedEncoderQueue = a0.framesDroppedEncoderQueue;
if (framesDroppedEncoderQueue == null) {
framesDroppedEncoderQueue = null;
}
r17.framesDroppedEncoderQueue = framesDroppedEncoderQueue;
let framesDroppedCongestionWindow = a0.framesDroppedCongestionWindow;
if (framesDroppedCongestionWindow == null) {
framesDroppedCongestionWindow = null;
}
r17.framesDroppedCongestionWindow = framesDroppedCongestionWindow;
let framesDroppedEncoder = a0.framesDroppedEncoder;
if (framesDroppedEncoder == null) {
framesDroppedEncoder = null;
}
r17.framesDroppedEncoder = framesDroppedEncoder;
let passthroughCount = a0.passthroughCount;
if (passthroughCount == null) {
passthroughCount = 0;
}
r17.passthroughCount = passthroughCount;
let encryptSuccessCount = a0.encryptSuccessCount;
if (encryptSuccessCount == null) {
encryptSuccessCount = 0;
}
r17.cryptorSuccessCount = encryptSuccessCount;
let encryptFailureCount = a0.encryptFailureCount;
if (encryptFailureCount == null) {
encryptFailureCount = 0;
}
r17.cryptorFailureCount = encryptFailureCount;
let encryptDuration = a0.encryptDuration;
if (encryptDuration == null) {
encryptDuration = 0;
}
r17.cryptorDuration = encryptDuration;
let encryptAttempts = a0.encryptAttempts;
if (encryptAttempts == null) {
encryptAttempts = 0;
}
r17.cryptorAttempts = encryptAttempts;
let encryptMaxAttempts = a0.encryptMaxAttempts;
if (encryptMaxAttempts == null) {
encryptMaxAttempts = 0;
}
r17.cryptorMaxAttempts = encryptMaxAttempts;
let encryptMissingKeyCount = a0.encryptMissingKeyCount;
if (encryptMissingKeyCount == null) {
encryptMissingKeyCount = 0;
}
r17.cryptorMissingKeyCount = encryptMissingKeyCount;
let consecutiveStaticColorFrames = a0.consecutiveStaticColorFrames;
if (consecutiveStaticColorFrames == null) {
consecutiveStaticColorFrames = 0;
}
r17.consecutiveStaticColorFrames = consecutiveStaticColorFrames;
r16 = r17;
}
return r16;
}
};
RawVideoStats2.prototype;
RawVideoStats = RawVideoStats2;
export class InboundStats {
decoderBuckets = Object.fromEntries(Object.values(c3815_10).map((a0) => [a0, 0]));
codecBuckets = {
H264: 0,
H265: 0,
VP8: 0,
VP9: 0,
AV1: 0,
UNKNOWN: 0
};
statsWindow = [];
hasSeededAggregation = false;
fpsHistogram = new Histogram();
bitrateHistogram = new Histogram();
inboundBitrateEstimateHistogram = new Histogram();
resolutionHistogram = new Histogram();
localWantHistogram = new Histogram();
systemResources = new SystemResources();
decoderCodec = c3815_8.UNKNOWN;
aggregatedProperties = {
framesCodec: 0,
framesNetwork: 0,
packets: 0,
packetsLost: 0,
framesDropped: 0,
networkFramesDropped: 0,
framesCodecError: 0,
bytes: 0,
nackCount: 0,
pliCount: 0,
qpSum: 0,
freezeCount: 0,
pauseCount: 0,
totalFreezesDuration: 0,
totalPausesDuration: 0,
totalFramesDuration: 0,
totalDecodeTime: 0,
keyframes: 0,
passthroughCount: 0,
cryptorSuccessCount: 0,
cryptorFailureCount: 0,
cryptorDuration: 0,
cryptorAttempts: 0,
cryptorMissingKeyCount: 0,
cryptorInvalidNonceCount: 0,
qualityDecodeErrors: 0,
qualityDecoderReboots: 0,
qualityScoreErrors: 0,
qualityFrameDrops: 0,
qualitySizeMismatches: 0,
screenshareFramesUnique: 0
};
aggregationDuration = 0;
bitrateBuckets = {};
fpsBuckets = {};
resolutionBuckets = {};
resolutionTotal = 0;
minorResolutionTotal = 0;
majorResolutionTotal = 0;
intervalTotal = 0;
cryptorMaxAttempts = 0;
minWidth = null;
minHeight = null;
maxConsecutiveStaticColorFrames = 0;
videoStoppedReason = c3815_13.None;
constructor(a0) {
this.startTime = a0.now();
this.videoStoppedWatch = new StopWatch(a0);
c3815_4.forEach((item) => {
this.bitrateBuckets[item] = 0;
});
c3815_5.forEach((item) => {
this.fpsBuckets[item] = 0;
});
c3815_6.forEach((item) => {
this.resolutionBuckets[item] = 0;
});
}
get isVideoStopped() {
return this.videoStoppedReason !== c3815_13.None;
}
get videoStoppedDuration() {
return this.videoStoppedWatch.elapsed();
}
collectAggregationStats(a0, a1) {
for (const item of _excluded) {
const r23 = a0[item];
if (r23 !== null) {
let r15 = a1[item];
if (r15 == null) {
r15 = 0;
}
const r26 = r15;
const aggregatedProperties = this.aggregatedProperties;
aggregatedProperties[item] = aggregatedProperties[item] + (r15 > r23 ? r23 : r23 - r26);
}
}
this.aggregationDuration = this.aggregationDuration + (a0.timestamp - a1.timestamp);
}
setVideoStopped(a0, a1) {
const videoStoppedReason = this.videoStoppedReason;
if (a0) {
this.videoStoppedReason = videoStoppedReason | a1;
this.videoStoppedWatch.start();
return void 0;
}
this.videoStoppedReason = videoStoppedReason & ~a1;
if (this.videoStoppedReason === c3815_13.None) {
this.statsWindow.splice(0);
this.videoStoppedWatch.stop();
}
}
appendAndIncrementStats(a0) {
let c15367_0, resolution, c15367_2, c15367_3;
if (!this.isVideoStopped) {
this.statsWindow.push(a0);
if (this.statsWindow.length < 2) {
if (!this.hasSeededAggregation) {
this.hasSeededAggregation = true;
const r186 = {
__proto__: RawVideoStats.prototype,
bytes: 0,
framesCodec: 0,
framesCodecError: null,
framesNetwork: 0,
resolution: 0,
minorResolution: 0,
majorResolution: 0,
timestamp: 0,
packets: 0,
packetsLost: 0,
framesDropped: 0,
networkFramesDropped: 0,
nackCount: 0,
pliCount: 0,
encoder: null,
decoder: null,
codecType: null,
qpSum: 0,
freezeCount: 0,
pauseCount: 0,
totalFreezesDuration: 0,
totalPausesDuration: 0,
totalFramesDuration: 0,
totalDecodeTime: 0,
vmafScore: null,
psnrDb: null,
outboundSinkWant: null,
keyframes: null,
framesDroppedRateLimiter: null,
framesDroppedEncoderQueue: null,
framesDroppedCongestionWindow: null,
framesDroppedEncoder: null,
passthroughCount: 0,
cryptorSuccessCount: 0,
cryptorFailureCount: 0,
cryptorDuration: 0,
cryptorAttempts: 0,
cryptorMaxAttempts: 0,
cryptorMissingKeyCount: 0,
cryptorInvalidNonceCount: 0,
qualityDecodeErrors: 0,
qualityDecoderReboots: 0,
qualityScoreErrors: 0,
qualityFrameDrops: 0,
qualitySizeMismatches: 0,
localWant: 0,
consecutiveStaticColorFrames: 0,
screenshareFramesUnique: 0
};
r186.timestamp = a0.timestamp;
this.collectAggregationStats(a0, r186);
}
} else {
const r34 = this.statsWindow[this.statsWindow.length - 1];
const r15 = this.statsWindow[this.statsWindow.length - 2];
this.collectAggregationStats(r34, r15);
if (this.cryptorFailureBeforeSuccessCount == null && a0.cryptorSuccessCount > 0) {
let cryptorFailureCount = this.aggregatedProperties.cryptorFailureCount;
if (cryptorFailureCount == null) {
cryptorFailureCount = 0;
}
this.cryptorFailureBeforeSuccessCount = cryptorFailureCount;
}
const { bytes, framesCodec, timestamp } = r34;
resolution = r34.resolution;
const { minorResolution, majorResolution, encoder, decoder, codecType, localWant } = r34;
const r50 = (timestamp - r15.timestamp) / 1000;
c15367_2 = r50;
this.intervalTotal = this.intervalTotal + r50;
this.resolutionTotal = this.resolutionTotal + resolution * r50;
this.minorResolutionTotal = this.minorResolutionTotal + minorResolution * r50;
this.majorResolutionTotal = this.majorResolutionTotal + majorResolution * r50;
this.cryptorMaxAttempts = Math.max(this.cryptorMaxAttempts, r34.cryptorMaxAttempts);
if (encoder != null && codecType != null && "encoderBuckets" in this) {
const encoderBuckets = this.encoderBuckets;
encoderBuckets[encoder] = encoderBuckets[encoder] + r50;
const codecBuckets = this.codecBuckets;
codecBuckets[codecType] = codecBuckets[codecType] + r50;
if (r34.codecType != null && r34.codecType !== c3815_8.UNKNOWN) {
this.encoderCodec = r34.codecType;
}
if (a0.vmafScore != null && a0.vmafScore >= 0) {
this.vmafScoreNum = this.vmafScoreNum + 1;
this.vmafScoreSum = this.vmafScoreSum + a0.vmafScore;
this.vmafHistogram.addSample(a0.vmafScore);
}
if (a0.psnrDb != null && a0.psnrDb >= 0) {
this.psnrDbNum = this.psnrDbNum + 1;
this.psnrDbSum = this.psnrDbSum + a0.psnrDb;
this.psnrHistogram.addSample(a0.psnrDb);
}
if (a0.outboundSinkWant != null && a0.outboundSinkWant !== 0) {
this.outboundSinkWantNum = this.outboundSinkWantNum + 1;
this.outboundSinkWantSum = this.outboundSinkWantSum + a0.outboundSinkWant;
}
this.consecutiveStaticColorFramesMax = Math.max(this.consecutiveStaticColorFramesMax, a0.consecutiveStaticColorFrames);
}
if (decoder != null && codecType != null && "decoderBuckets" in this) {
const decoderBuckets = this.decoderBuckets;
decoderBuckets[decoder] = decoderBuckets[decoder] + r50;
const codecBuckets2 = this.codecBuckets;
codecBuckets2[codecType] = codecBuckets2[codecType] + r50;
if (r34.codecType != null && r34.codecType !== c3815_8.UNKNOWN) {
this.decoderCodec = r34.codecType;
}
}
if (!(this.statsWindow.length < 6)) {
const r141 = this.statsWindow[this.statsWindow.length - 3];
const { bytes: bytes2, framesCodec: framesCodec2, timestamp: timestamp2 } = r141;
c3815_6.forEach((item) => {
if (resolution <= item) {
const resolutionBuckets = this.resolutionBuckets;
resolutionBuckets[item] = resolutionBuckets[item] + c15367_2;
}
});
const r150 = (timestamp - timestamp2) / 1000;
const r154 = 8 * (bytes - bytes2) / r150;
c15367_3 = r154;
const r156 = (framesCodec - framesCodec2) / r150;
c15367_0 = r156;
c3815_4.forEach((item) => {
if (c15367_3 <= item) {
const bitrateBuckets = this.bitrateBuckets;
bitrateBuckets[item] = bitrateBuckets[item] + c15367_2;
}
});
c3815_5.forEach((item) => {
if (c15367_0 <= item) {
const fpsBuckets = this.fpsBuckets;
fpsBuckets[item] = fpsBuckets[item] + c15367_2;
}
});
this.resolutionHistogram.addSample(resolution);
this.bitrateHistogram.addSample(r154);
this.fpsHistogram.addSample(r156);
this.localWantHistogram.addSample(localWant);
this.statsWindow.shift();
}
}
}
}
addSystemResources() {
this.systemResources.takeSample();
}
appendTransportStats(a0) {
if (a0.inboundBitrateEstimate != null) {
this.inboundBitrateEstimateHistogram.addSample(a0.inboundBitrateEstimate);
}
}
getCodecsUsed() {
const set = new Set();
for (const item of Object.entries(this.codecBuckets)) {
const r34 = _slicedToArray(item, 2);
const r35 = r34[0];
if (r34[1] > 0) {
set.add(r35);
}
}
return set;
}
}
export { c3815_8 as CodecTypes };
export { c3815_9 as Encoders };
export { c3815_10 as Decoders };
export { c3815_13 as VideoStoppedReasons };
export { parseEncoder };
export { parseDecoder };
export function parseCodecType(a0) {
let UNKNOWN;
L19: {
if (a0 == null) {
UNKNOWN = c3815_8.UNKNOWN;
} else {
const r4 = a0.toUpperCase();
if (r4 === "H264") {
UNKNOWN = c3815_8.H264;
} else if (r4 === "H265") {
UNKNOWN = c3815_8.H265;
} else if (r4 === "VP8") {
UNKNOWN = c3815_8.VP8;
} else if (r4 === "VP9") {
UNKNOWN = c3815_8.VP9;
} else {
if (r4 !== "AV1" && r4 !== "AV1X") {
UNKNOWN = c3815_8.UNKNOWN;
break L19;
}
UNKNOWN = c3815_8.AV1;
}
}
}
return UNKNOWN;
}
export { RawVideoStats };
class OutboundStats extends InboundStats {
encoderBuckets = Object.fromEntries(Object.values(c3815_9).map((a0) => [a0, 0]));
encoderCodec = c3815_8.UNKNOWN;
targetFrames = 0;
targetBytesMax = 0;
targetBytesNetwork = 0;
targetBitrateHistogram = new Histogram();
outboundBytesAvailable = 0;
outboundBandwidthSurplus = new Histogram();
averageEncodeTime = 0;
vmafScoreSum = 0;
vmafScoreNum = 0;
vmafHistogram = new Histogram();
psnrDbSum = 0;
psnrDbNum = 0;
psnrHistogram = new Histogram();
qualityDecodeErrors = 0;
qualityDecoderReboots = 0;
qualityScoreErrors = 0;
qualityFrameDrops = 0;
qualitySizeMismatches = 0;
outboundSinkWantSum = 0;
outboundSinkWantNum = 0;
framesDroppedRateLimiter = null;
framesDroppedEncoderQueue = null;
framesDroppedCongestionWindow = null;
framesDroppedEncoder = null;
consecutiveStaticColorFramesMax = 0;
appendTargetRates(a0, a1, a2, a3) {
if (!(this.statsWindow.length < 2)) {
const r9 = a0 == null ? 0 : a0;
const r7 = a1 == null ? 0 : a1;
const r8 = a2 == null ? 0 : a2;
const r13 = a3 == null ? 0 : a3;
const r25 = (this.statsWindow[this.statsWindow.length - 1].timestamp - this.statsWindow[this.statsWindow.length - 2].timestamp) / 1000;
this.targetFrames = this.targetFrames + r9 * r25;
this.targetBytesNetwork = this.targetBytesNetwork + r7 / 8 * r25;
this.targetBytesMax = this.targetBytesMax + r8 / 8 * r25;
this.outboundBytesAvailable = this.outboundBytesAvailable + r13 / 8 * r25;
this.targetBitrateHistogram.addSample(r7);
this.outboundBandwidthSurplus.addSample(r13 - r7);
}
}
}
export { OutboundStats };
+72
View File
@@ -0,0 +1,72 @@
// Metro module 10557 (f10558).
import AuthenticationStore from "../stores/AuthenticationStore";
import ChannelStore from "../stores/ChannelStore";
import NetworkStore from "../stores/NetworkStore";
import RTCConnectionStore from "../stores/RTCConnectionStore";
import VoiceStateStore from "../stores/VoiceStateStore";
import { AnalyticEvents } from "../Constants";
import Logger from "../modules/debug/Logger";
import { now } from "../_bundle/sleep";
import AnalyticsUtils from "../utils/AnalyticsUtils";
const r29 = {
SELF_VIDEO: "self_video",
SELF_STREAM: "self_stream",
REMOTE_VIDEO: "remote_video",
REMOTE_STREAM: "remote_stream",
CHANGE_VIDEO_BACKGROUND: "change_video_background",
REPLAY_VIDEO_STREAM: "replay_video_stream"
};
let c7094_9 = new Map();
export { r29 as VideoSpinnerContext };
export class VideoSpinnerTimer {
constructor(a0) {
const r8 = {
__proto__: new.target.prototype,
spinnerVisibleStart: null
};
r8.logger = new Logger(a0);
return r8;
}
onSpinnerStarted() {
if (this.spinnerVisibleStart == null) {
this.spinnerVisibleStart = now();
}
}
trackSpinnerDuration(a0, a1, a2) {
if (this.spinnerVisibleStart != null) {
let r27 = c7094_9.get(a2);
if (r27 == null) {
r27 = 0;
}
const event_count_for_stream = r27 + 1;
c7094_9.set(a2, event_count_for_stream);
const duration_video_spinner_visible_ms = now() - this.spinnerVisibleStart;
this.spinnerVisibleStart = null;
if (duration_video_spinner_visible_ms < 0) {
this.logger.warn(`spinner duration is negative: ${duration_video_spinner_visible_ms} ms
[${a0}, count for stream: ${event_count_for_stream}]`);
} else {
this.logger.info(`spinner visible for ${duration_video_spinner_visible_ms} ms
[${a0}, count for stream: ${event_count_for_stream}]`);
const guildId = RTCConnectionStore.getGuildId();
const userVoiceChannelId = VoiceStateStore.getUserVoiceChannelId(guildId, AuthenticationStore.getId());
const channel = ChannelStore.getChannel(userVoiceChannelId);
const channel_type = channel != null ? channel.isGuildVoice() ? "guild_voice" : channel.isGuildStageVoice() ? "is_stage_channel" : channel.isDM() ? "dm" : channel.isGroupDM() ? "group_dm" : null : null;
AnalyticsUtils.track(AnalyticEvents.VIDEO_SPINNER_SHOWN_V2, {
video_spinner_context: a0,
duration_video_spinner_visible_ms,
rtc_connection_id: RTCConnectionStore.getRTCConnectionId(),
media_session_id: RTCConnectionStore.getMediaSessionId(),
event_count_for_stream,
guild_id: guildId,
channel_id: userVoiceChannelId,
channel_type,
spinning_user_id: a1,
connection_type: NetworkStore.getType(),
effective_connection_speed: NetworkStore.getEffectiveConnectionSpeed(),
service_provider: NetworkStore.getServiceProvider()
});
}
}
}
}
+200
View File
@@ -0,0 +1,200 @@
// Metro module 12877 (f12878).
import { TimeStampProducer, StopWatch, DurationEnabled } from "../_bundle/sleep";
import { BaseConnectionEvent } from "../_bundle/Module4301";
let c8877_2 = [1, 100, 1000, 10000];
let c8877_3 = [100, 500, 1000, 5000];
class VoiceDuration {
constructor(a0, a1, timestampProducer = TimeStampProducer) {
const r19 = {
__proto__: new.target.prototype,
listeningUsers: new Set(),
timesUntilSpeakingDurationMilestonesMs: null,
speakingMinimumChunks: null,
speakingMinimumChunkCounts: null,
speechEventCount: 0
};
r19.timesUntilSpeakingDurationMilestonesMs = new Map();
r19.speakingMinimumChunks = new Map();
r19.speakingMinimumChunkCounts = new Map();
r19.userId = a0;
r19.connection = a1;
r19.timestampProducer = timestampProducer;
r19.listening = new StopWatch(r19.timestampProducer);
r19.speaking = new StopWatch(r19.timestampProducer);
r19.participation = new StopWatch(r19.timestampProducer);
r19.connected = new StopWatch(r19.timestampProducer);
r19.muted = new StopWatch(r19.timestampProducer);
r19.deafened = new StopWatch(r19.timestampProducer);
r19.noiseCancellation = new DurationEnabled(a1.getNoiseCancellation(), r19.timestampProducer);
r19.spatialAudio = new DurationEnabled(a1.getSpatialAudioEnabled(), r19.timestampProducer);
return r19;
}
start(r9 = false, r8 = false) {
this.listeningUsers.clear();
this.listening.reset();
this.speaking.reset();
this.participation.reset();
this.muted.reset();
this.deafened.reset();
this.connected.reset();
this.noiseCancellation.reset();
this.spatialAudio.reset();
this.timesUntilSpeakingDurationMilestonesMs.clear();
this.speakingMinimumChunks.clear();
this.speakingMinimumChunkCounts.clear();
this.speechEventCount = 0;
this.connected.start();
this.connection.on(BaseConnectionEvent.Speaking, (a0, a1) => {
if (this.userId === a0) {
this.onSpeaking(a1 !== 0);
} else {
this.onListening(a1 !== 0, a0);
}
});
this.onMuted(r9);
this.onDeafened(r8);
this.connection.on(BaseConnectionEvent.Mute, (a0) => {
this.onMuted(a0);
});
this.connection.on(BaseConnectionEvent.Deafen, (a0) => {
this.onDeafened(a0);
});
}
onSpeaking(a0) {
if (a0) {
this.speaking.start();
this.participation.start();
this.speechEventCount = this.speechEventCount + 1;
} else {
const lastStartTime2 = this.connected.lastStartTime;
const lastStartTime = this.speaking.lastStartTime;
const lastElapsed = this.speaking.lastElapsed;
this.addSpeechChunk();
this.speaking.stop();
if (!this.listening.isRunning()) {
this.participation.stop();
}
this.computeSpeakingDurationMilestones(lastStartTime2, lastStartTime, lastElapsed);
}
}
onListening(a0, a1) {
const listeningUsers = this.listeningUsers;
if (a0) {
listeningUsers.add(a1);
this.listening.start();
this.participation.start();
} else if (listeningUsers.delete(a1) && this.listeningUsers.size === 0) {
this.listening.stop();
if (!this.speaking.isRunning()) {
this.participation.stop();
}
}
}
onMuted(a0) {
const muted = this.muted;
if (a0) {
muted.start();
} else {
muted.stop();
}
}
onDeafened(a0) {
const deafened = this.deafened;
if (a0) {
deafened.start();
} else {
deafened.stop();
}
}
computeSpeakingDurationMilestones(a0, a1, c20281_3) {
let c20281_0;
if (a0 != null && a1 != null) {
c20281_0 = this.speaking.elapsed().asMilliseconds();
c8877_2.filter((item) => !this.timesUntilSpeakingDurationMilestonesMs.has(item)).filter((item) => c20281_0 >= item).forEach((item) => {
this.timesUntilSpeakingDurationMilestonesMs.set(item, a1 - a0 + item - c20281_3);
});
}
}
addSpeechChunk() {
let c20282_0;
const lastStartTime = this.speaking.lastStartTime;
if (lastStartTime != null) {
c20282_0 = this.timestampProducer.now() - lastStartTime;
c8877_3.filter((item) => c20282_0 >= item).forEach((item) => {
let r7 = this.speakingMinimumChunks.get(item);
if (r7 == null) {
r7 = 0;
}
this.speakingMinimumChunks.set(item, r7 + c20282_0);
let r15 = this.speakingMinimumChunkCounts.get(item);
if (r15 == null) {
r15 = 0;
}
this.speakingMinimumChunkCounts.set(item, r15 + 1);
});
}
}
setNoiseCancellationEnabled(a0) {
this.noiseCancellation.value = a0;
}
setSpatialAudioEnabled(a0) {
this.spatialAudio.value = a0;
}
stop() {
this.addSpeechChunk();
const lastStartTime2 = this.connected.lastStartTime;
const lastStartTime = this.speaking.lastStartTime;
const lastElapsed = this.speaking.lastElapsed;
this.speaking.stop();
this.listening.stop();
this.participation.stop();
this.connected.stop();
this.muted.stop();
this.noiseCancellation.value = false;
this.spatialAudio.value = false;
this.computeSpeakingDurationMilestones(lastStartTime2, lastStartTime, lastElapsed);
}
getDurationStats() {
const lastStartTime = this.speaking.lastStartTime;
const r12 = this.timestampProducer.now();
let c20283_0 = lastStartTime != null ? r12 - lastStartTime : 0;
this.computeSpeakingDurationMilestones(this.connected.lastStartTime, this.speaking.lastStartTime, this.speaking.lastElapsed);
return {
duration_listening_ms: this.listening.elapsed().asMilliseconds(),
duration_speaking_ms: this.speaking.elapsed().asMilliseconds(),
duration_participation_ms: this.participation.elapsed().asMilliseconds(),
duration_connected_ms: this.connected.elapsed().asMilliseconds(),
duration_muted_ms: this.muted.elapsed().asMilliseconds(),
duration_deafened_ms: this.deafened.elapsed().asMilliseconds(),
duration_noise_cancellation_enabled_ms: this.noiseCancellation.totalDuration(),
duration_spatial_ms: this.spatialAudio.totalDuration(),
speech_event_count: this.speechEventCount,
...c8877_2.filter((item) => this.timesUntilSpeakingDurationMilestonesMs.has(item)).reduce((acc, item) => {
const r0 = {
...acc
};
r0[`time_to_first_${item}ms_speech_ms`] = this.timesUntilSpeakingDurationMilestonesMs.get(item);
return r0;
}, {}),
...c8877_3.filter((item) => this.speakingMinimumChunks.has(item) || c20283_0 >= item).reduce((acc, item) => {
const r4 = {
...acc
};
const r16 = `duration_speaking_gte_${item}ms_ms`;
let r19 = this.speakingMinimumChunks.get(item);
if (r19 == null) {
r19 = 0;
}
r4[r16] = r19 + (c20283_0 >= item ? c20283_0 : 0);
const r27 = `speech_event_count_gte_${item}ms`;
let r30 = this.speakingMinimumChunkCounts.get(item);
if (r30 == null) {
r30 = 0;
}
r4[r27] = r30 + (c20283_0 >= item ? 1 : 0);
return r4;
}, {})
};
}
}
export default VoiceDuration;
+858
View File
@@ -0,0 +1,858 @@
// Metro module 12874 (f12875).
import { Histogram } from "./Histogram";
import TypedEventEmitter from "../_bundle/TypedEventEmitter";
import NetworkQuality from "./NetworkQuality";
import SystemResources from "./SystemResources";
import { BaseConnectionEvent } from "../_bundle/Module4286";
import Module12 from "../_bundle/Module12";
import { now } from "../_bundle/sleep";
let c8874_4 = {
InputDeviceSampleRateChanged: "input-device-sample-rate-changed"
};
class VoiceQuality extends TypedEventEmitter {
constructor(a0) {
super();
const _this = this;
this.sampleAudioDevice = (a0, a1) => {
if (a0 !== void 0) {
if (a0.restartCount !== void 0) {
const restartCount = a0.restartCount;
let restartCount2 = a1.restartCount;
if (restartCount2 == null) {
restartCount2 = {
accumulated: 0,
lastValue: 0
};
}
const { accumulated, lastValue } = restartCount2;
a1.restartCount = {
accumulated: lastValue > restartCount ? accumulated + restartCount : accumulated + (restartCount - lastValue),
lastValue: restartCount
};
}
if (a0.bufferViolations !== void 0) {
const bufferViolations = a0.bufferViolations;
let bufferViolations2 = a1.bufferViolations;
if (bufferViolations2 == null) {
bufferViolations2 = {
accumulated: 0,
lastValue: 0
};
}
const { accumulated: accumulated2, lastValue: lastValue2 } = bufferViolations2;
a1.bufferViolations = {
accumulated: lastValue2 > bufferViolations ? accumulated2 + bufferViolations : accumulated2 + (bufferViolations - lastValue2),
lastValue: bufferViolations
};
}
let timeToFirstCallbackMs = a0.timeToFirstCallbackMs;
if (timeToFirstCallbackMs == null) {
timeToFirstCallbackMs = 0;
}
if (timeToFirstCallbackMs !== 0 && a1.timeToFirstCallbackMs === void 0) {
a1.timeToFirstCallbackMs = a0.timeToFirstCallbackMs;
}
let sessionSampleRate = a0.sessionSampleRate;
if (sessionSampleRate == null) {
sessionSampleRate = 0;
}
if (sessionSampleRate !== 0) {
if (a1.sessionSampleRate !== a0.sessionSampleRate) {
const InputDeviceSampleRateChanged = c8874_4.InputDeviceSampleRateChanged;
let sessionSampleRate2 = a0.sessionSampleRate;
if (sessionSampleRate2 == null) {
sessionSampleRate2 = 0;
}
_this.emit(InputDeviceSampleRateChanged, sessionSampleRate2);
}
a1.sessionSampleRate = a0.sessionSampleRate;
}
if (a0.timeFromConnectToFirstCallbackMs !== void 0 && a1.timeFromConnectToFirstCallbackMs === void 0) {
a1.timeFromConnectToFirstCallbackMs = a0.timeFromConnectToFirstCallbackMs;
}
}
};
this.appendTargetRates = function appendTargetRates(a0, r8 = 0, r7 = 0) {
if (a0.previousTimestampMs !== 0) {
const previousTimestampMs = performance.now();
a0.aggregationDurationMs = a0.aggregationDurationMs + (previousTimestampMs - a0.previousTimestampMs);
const r2 = (previousTimestampMs - a0.previousTimestampMs) / 1000;
a0.bytesAvailable = a0.bytesAvailable + r8 / 8 * r2;
a0.bytesTarget = a0.bytesTarget + r7 / 8 * r2;
a0.previousTimestampMs = previousTimestampMs;
} else {
a0.previousTimestampMs = performance.now();
}
};
this.sampleStats = (a0) => {
let c27375_1;
let c27375_0 = a0;
if (a0 != null) {
_this.networkQuality.incrementNetworkStats(now());
_this.systemResources.takeSample();
const duration = _this.duration;
duration.connected = duration.connected + 1;
const packetsSent = _this.outboundStats.packetsSent;
const r34 = Module12.reduce(_this.inboundStats, (a0, a1) => {
a0.packetsReceived = a0.packetsReceived + a1.packetsReceived;
return a0;
}, {
packetsReceived: 0
});
c27375_1 = 0;
Module12.forEach(a0.rtp.outbound, (a0) => {
if (a0.type === "audio") {
let bitrateTarget = a0.bitrateTarget;
if (bitrateTarget == null) {
bitrateTarget = 0;
}
c27375_1 = bitrateTarget;
let packetsLost = a0.packetsLost;
if (packetsLost == null) {
packetsLost = 0;
}
let passthroughCount = a0.passthroughCount;
if (passthroughCount == null) {
passthroughCount = 0;
}
let encryptSuccessCount = a0.encryptSuccessCount;
if (encryptSuccessCount == null) {
encryptSuccessCount = 0;
}
let encryptFailureCount = a0.encryptFailureCount;
if (encryptFailureCount == null) {
encryptFailureCount = 0;
}
let encryptDuration = a0.encryptDuration;
if (encryptDuration == null) {
encryptDuration = 0;
}
let encryptAttempts = a0.encryptAttempts;
if (encryptAttempts == null) {
encryptAttempts = 0;
}
let encryptMaxAttempts = a0.encryptMaxAttempts;
if (encryptMaxAttempts == null) {
encryptMaxAttempts = 0;
}
let encryptMissingKeyCount = a0.encryptMissingKeyCount;
if (encryptMissingKeyCount == null) {
encryptMissingKeyCount = 0;
}
_this.outboundStats = {
..._this.outboundStats,
packetsSent: a0.packetsSent,
bytesSent: a0.bytesSent,
packetsLost,
passthroughCount,
encryptSuccessCount,
encryptFailureCount,
encryptDuration,
encryptAttempts,
encryptMaxAttempts,
encryptMissingKeyCount
};
if (Boolean(a0.audioDetected) === true && a0.audioLevel != null) {
_this.outboundStats.speakingAudioLevel.addSample(20 * Math.log(a0.audioLevel));
}
}
});
_this.decryptionFailures = a0.transport.decryptionFailures;
_this.routingFailures = a0.transport.routingFailures;
_this.appendTargetRates(_this.outboundStats, a0.transport.availableOutgoingBitrate, c27375_1);
Module12.forEach(a0.rtp.inbound, (a0, c30586_0) => {
Module12.forEach(a0, (a0) => {
if (a0.type === "audio") {
const inboundStats = _this.inboundStats;
const r17 = inboundStats[c30586_0];
let ping = c27375_0.transport.ping;
if (ping == null) {
ping = 0;
}
const { packetsReceived, packetsLost, bytesReceived } = a0;
let nackCount = a0.nackCount;
let fecPacketsReceived = a0.fecPacketsReceived;
if (fecPacketsReceived == null) {
fecPacketsReceived = 0;
}
let fecPacketsDiscarded = a0.fecPacketsDiscarded;
if (fecPacketsDiscarded == null) {
fecPacketsDiscarded = 0;
}
let jitterBuffer = a0.jitterBuffer;
if (jitterBuffer == null) {
jitterBuffer = 0;
}
let audioJitterBufferHistogram2 = r17 == null ? void 0 : r17.bufferStats.audioJitterBufferHistogram;
if (audioJitterBufferHistogram2 == null) {
audioJitterBufferHistogram2 = new Histogram();
}
let audioJitterTargetHistogram2 = r17 == null ? void 0 : r17.bufferStats.audioJitterTargetHistogram;
if (audioJitterTargetHistogram2 == null) {
audioJitterTargetHistogram2 = new Histogram();
}
let audioJitterDelayHistogram2 = r17 == null ? void 0 : r17.bufferStats.audioJitterDelayHistogram;
if (audioJitterDelayHistogram2 == null) {
audioJitterDelayHistogram2 = new Histogram();
}
const bufferStats = {
audioJitterBuffer: a0.audioJitterBuffer,
audioJitterBufferHistogram: audioJitterBufferHistogram2,
audioJitterTarget: a0.audioJitterTarget,
audioJitterTargetHistogram: audioJitterTargetHistogram2,
audioJitterDelay: a0.audioJitterDelay,
audioJitterDelayHistogram: audioJitterDelayHistogram2,
relativeReceptionDelay: a0.relativeReceptionDelay,
relativePlayoutDelay: a0.relativePlayoutDelay
};
const audioJitterBufferHistogram = bufferStats.audioJitterBufferHistogram;
let audioJitterBufferSamples = a0.audioJitterBufferSamples;
if (audioJitterBufferSamples == null) {
audioJitterBufferSamples = [];
}
audioJitterBufferHistogram.addSamples(audioJitterBufferSamples);
const audioJitterDelayHistogram = bufferStats.audioJitterDelayHistogram;
let audioJitterDelaySamples = a0.audioJitterDelaySamples;
if (audioJitterDelaySamples == null) {
audioJitterDelaySamples = [];
}
audioJitterDelayHistogram.addSamples(audioJitterDelaySamples);
const audioJitterTargetHistogram = bufferStats.audioJitterTargetHistogram;
let audioJitterTargetSamples = a0.audioJitterTargetSamples;
if (audioJitterTargetSamples == null) {
audioJitterTargetSamples = [];
}
audioJitterTargetHistogram.addSamples(audioJitterTargetSamples);
const frameOpStats = {
silent: a0.opSilence,
normal: a0.opNormal,
merged: a0.opMerge,
expanded: a0.opExpand,
accelerated: a0.opAccelerate,
preemptiveExpanded: a0.opPreemptiveExpand,
cng: a0.opCNG
};
let passthroughCount = a0.passthroughCount;
if (passthroughCount == null) {
passthroughCount = 0;
}
let decryptSuccessCount = a0.decryptSuccessCount;
if (decryptSuccessCount == null) {
decryptSuccessCount = 0;
}
let decryptFailureCount = a0.decryptFailureCount;
if (decryptFailureCount == null) {
decryptFailureCount = 0;
}
let decryptDuration = a0.decryptDuration;
if (decryptDuration == null) {
decryptDuration = 0;
}
let decryptAttempts = a0.decryptAttempts;
if (decryptAttempts == null) {
decryptAttempts = 0;
}
let decryptMissingKeyCount = a0.decryptMissingKeyCount;
if (decryptMissingKeyCount == null) {
decryptMissingKeyCount = 0;
}
let decryptInvalidNonceCount = a0.decryptInvalidNonceCount;
if (decryptInvalidNonceCount == null) {
decryptInvalidNonceCount = 0;
}
const r98 = {
passthroughCount,
decryptSuccessCount,
decryptFailureCount,
decryptDuration,
decryptAttempts,
decryptMissingKeyCount,
decryptInvalidNonceCount
};
if (r17 != null) {
const r120 = packetsReceived - r17.packetsReceived;
const r28 = packetsLost - r17.packetsLost;
const mosBuckets = r17.mosBuckets;
let decryptFailureBeforeSuccessCount = r17.decryptFailureBeforeSuccessCount;
if (decryptFailureBeforeSuccessCount == null) {
decryptFailureBeforeSuccessCount = r98.decryptSuccessCount > 0 ? r98.decryptFailureCount : void 0;
}
const r128 = r120 > 0 && r28 >= 0;
let mos = 0;
if (r128) {
const r140 = _this.calculateMos(ping + jitterBuffer, Module12.clamp(r28 / (r120 + r28), 0, 1));
const r144 = Math.floor(r140);
mosBuckets[r144] = mosBuckets[r144] + 1;
mos = r140;
}
const inboundStats2 = _this.inboundStats;
if (nackCount == null) {
nackCount = 0;
}
inboundStats2[c30586_0] = {
packetsReceived,
bytesReceived,
packetsLost,
nackCount,
fecPacketsReceived,
fecPacketsDiscarded,
mos,
mosSum: r17.mosSum + mos,
mosCount: r17.mosCount + (mos > 0 ? 1 : 0),
mosBuckets,
bufferStats,
frameOpStats,
decryptFailureBeforeSuccessCount,
...r98
};
const periodicInboundStats2 = _this.periodicInboundStats;
const r162 = {
previousTimestampMs: _this.periodicInboundStats[c30586_0].previousTimestampMs,
previous: _this.periodicInboundStats[c30586_0].previous,
currentTimestampMs: performance.now(),
current: frameOpStats,
accelerateRateSum: null,
expandRateSum: null,
preemptiveExpandRateSum: null,
speechExpandRateSum: null,
numRateSamples: null
};
const accelerateRateSum = _this.periodicInboundStats[c30586_0].accelerateRateSum;
let accelerateRate2 = a0.accelerateRate;
if (accelerateRate2 == null) {
accelerateRate2 = 0;
}
r162.accelerateRateSum = accelerateRateSum + accelerateRate2;
const expandRateSum = _this.periodicInboundStats[c30586_0].expandRateSum;
let expandRate2 = a0.expandRate;
if (expandRate2 == null) {
expandRate2 = 0;
}
r162.expandRateSum = expandRateSum + expandRate2;
const preemptiveExpandRateSum = _this.periodicInboundStats[c30586_0].preemptiveExpandRateSum;
let preemptiveExpandRate2 = a0.preemptiveExpandRate;
if (preemptiveExpandRate2 == null) {
preemptiveExpandRate2 = 0;
}
r162.preemptiveExpandRateSum = preemptiveExpandRateSum + preemptiveExpandRate2;
const speechExpandRateSum = _this.periodicInboundStats[c30586_0].speechExpandRateSum;
let speechExpandRate2 = a0.speechExpandRate;
if (speechExpandRate2 == null) {
speechExpandRate2 = 0;
}
r162.speechExpandRateSum = speechExpandRateSum + speechExpandRate2;
r162.numRateSamples = _this.periodicInboundStats[c30586_0].numRateSamples + 1;
periodicInboundStats2[c30586_0] = r162;
} else {
_this.inboundStats[c30586_0] = {
packetsReceived,
bytesReceived,
packetsLost,
nackCount: nackCount == null ? 0 : nackCount,
fecPacketsReceived,
fecPacketsDiscarded,
mos: 0,
mosSum: 0,
mosCount: 0,
mosBuckets: [0, 0, 0, 0, 0],
bufferStats,
frameOpStats,
...r98
};
const periodicInboundStats = _this.periodicInboundStats;
const r111 = {
previousTimestampMs: performance.now(),
previous: frameOpStats,
currentTimestampMs: performance.now(),
current: frameOpStats,
accelerateRateSum: null,
expandRateSum: null,
preemptiveExpandRateSum: null,
speechExpandRateSum: null,
numRateSamples: 1
};
let accelerateRate = a0.accelerateRate;
if (accelerateRate == null) {
accelerateRate = 0;
}
r111.accelerateRateSum = accelerateRate;
let expandRate = a0.expandRate;
if (expandRate == null) {
expandRate = 0;
}
r111.expandRateSum = expandRate;
let preemptiveExpandRate = a0.preemptiveExpandRate;
if (preemptiveExpandRate == null) {
preemptiveExpandRate = 0;
}
r111.preemptiveExpandRateSum = preemptiveExpandRate;
let speechExpandRate = a0.speechExpandRate;
if (speechExpandRate == null) {
speechExpandRate = 0;
}
r111.speechExpandRateSum = speechExpandRate;
periodicInboundStats[c30586_0] = r111;
}
}
});
});
if (a0.audioDevice !== void 0) {
_this.sampleAudioDevice(a0.audioDevice.input, _this.inputDeviceStats);
_this.sampleAudioDevice(a0.audioDevice.output, _this.outputDeviceStats);
}
const r4 = _this.outboundStats.packetsSent > packetsSent;
let r72 = false;
if (r4) {
const duration2 = _this.duration;
duration2.speaking = duration2.speaking + 1;
r72 = true;
}
const r85 = Module12.reduce(_this.inboundStats, (a0, a1) => {
a0.packetsReceived = a0.packetsReceived + a1.packetsReceived;
return a0;
}, {
packetsReceived: 0
}).packetsReceived > r34.packetsReceived;
let r2 = false;
if (r85) {
const duration3 = _this.duration;
duration3.listening = duration3.listening + 1;
r2 = true;
}
if (!r72) {
r72 = r2;
}
if (r72) {
const duration4 = _this.duration;
duration4.participation = duration4.participation + 1;
}
}
};
this.connection = a0;
this.networkQuality = new NetworkQuality();
this.systemResources = new SystemResources();
this.inboundStats = {};
this.outboundStats = {
packetsSent: 0,
bytesSent: 0,
packetsLost: 0,
passthroughCount: 0,
encryptSuccessCount: 0,
encryptFailureCount: 0,
encryptDuration: 0,
encryptAttempts: 0,
encryptMaxAttempts: 0,
encryptMissingKeyCount: 0,
bytesAvailable: 0,
bytesTarget: 0,
previousTimestampMs: 0,
aggregationDurationMs: 0,
speakingAudioLevel: new Histogram()
};
this.duration = {
listening: 0,
speaking: 0,
participation: 0,
connected: 0
};
this.periodicInboundStats = {};
this.inputDeviceStats = {};
this.outputDeviceStats = {};
}
start() {
this.connection.on(BaseConnectionEvent.Stats, this.sampleStats);
}
stop() {
this.connection.off(BaseConnectionEvent.Stats, this.sampleStats);
}
getMosStats() {
const r12 = Module12.reduce(this.inboundStats, (a0, a1) => {
a0.mosSum = a0.mosSum + a1.mosSum;
a0.mosCount = a0.mosCount + a1.mosCount;
let r0 = 0;
while (true) {
const mosBuckets = a0.mosBuckets;
mosBuckets[r0] = mosBuckets[r0] + a1.mosBuckets[r0];
r0 = r0 + 1;
if (!(r0 < 5)) {
return a0;
}
}
}, {
mosSum: 0,
mosCount: 0,
mosBuckets: [0, 0, 0, 0, 0]
});
return {
mos_mean: r12.mosCount > 0 ? r12.mosSum / r12.mosCount : 0,
mos_1: r12.mosBuckets[1],
mos_2: r12.mosBuckets[2],
mos_3: r12.mosBuckets[3],
mos_4: r12.mosBuckets[4]
};
}
getPacketStats() {
const r11 = Module12.reduce(this.inboundStats, (a0, a1) => {
a0.packetsReceived = a0.packetsReceived + a1.packetsReceived;
a0.packetsReceivedLost = a0.packetsReceivedLost + a1.packetsLost;
a0.nackCount = a0.nackCount + a1.nackCount;
a0.fecPacketsReceived = a0.fecPacketsReceived + a1.fecPacketsReceived;
a0.fecPacketsDiscarded = a0.fecPacketsDiscarded + a1.fecPacketsDiscarded;
return a0;
}, {
packetsReceived: 0,
packetsReceivedLost: 0,
nackCount: 0,
fecPacketsReceived: 0,
fecPacketsDiscarded: 0
});
return {
packets_sent: this.outboundStats.packetsSent,
packets_sent_lost: this.outboundStats.packetsLost,
packets_received: r11.packetsReceived,
packets_received_lost: r11.packetsReceivedLost,
num_nacks_sent: r11.nackCount,
fec_packets_received: r11.fecPacketsReceived,
fec_packets_discarded: r11.fecPacketsDiscarded
};
}
getBytesStats() {
const bytes_received = Module12.reduce(this.inboundStats, (a0, a1) => a0 + a1.bytesReceived, 0);
const r17 = this.outboundStats.aggregationDurationMs / 1000;
return {
bytes_sent: this.outboundStats.bytesSent,
bytes_received,
outbound_bandwidth_estimate: 0 < r17 ? Math.round(8 * this.outboundStats.bytesAvailable / r17) : 0,
audio_target_bitrate: 0 < r17 ? Math.round(8 * this.outboundStats.bytesTarget / r17) : 0
};
}
getNetworkStats() {
return this.networkQuality.getStats();
}
getSystemResourceStats() {
return this.systemResources.getStats();
}
getBufferStats() {
const r31 = Module12.reduce(this.inboundStats, (a0, a1) => {
const r8 = a1.bufferStats.audioJitterBufferHistogram.getSamples() > 0 ? a1.bufferStats.audioJitterBufferHistogram.getPercentile(75) : a1.bufferStats.audioJitterBuffer != null ? a1.bufferStats.audioJitterBuffer.p75 : null;
let r20 = a0;
const r22 = a0 == null ? null : a0.audioJitterBufferHistogram.getSamples() > 0 ? a0.audioJitterBufferHistogram.getPercentile(75) : a0.audioJitterBuffer != null ? a0.audioJitterBuffer.p75 : null;
if (a0 == null || r22 == null || r8 != null && r8 > r22) {
r20 = a1.bufferStats;
}
return r20;
}, null);
const audio_jitter_buffer = r31 != null ? r31.audioJitterBufferHistogram.getSamples() > 0 ? r31.audioJitterBufferHistogram : r31.audioJitterBuffer != null ? r31.audioJitterBuffer : null : null;
const audio_jitter_target = r31 != null ? r31.audioJitterTargetHistogram.getSamples() > 0 ? r31.audioJitterTargetHistogram : r31.audioJitterTarget != null ? r31.audioJitterTarget : null : null;
const audio_jitter_delay = r31 != null ? r31.audioJitterDelayHistogram.getSamples() > 0 ? r31.audioJitterDelayHistogram : r31.audioJitterDelay != null ? r31.audioJitterDelay : null : null;
let relative_reception_delay = r31?.relativeReceptionDelay;
if (relative_reception_delay == null) {
relative_reception_delay = null;
}
let relative_playout_delay = r31?.relativePlayoutDelay;
if (relative_playout_delay == null) {
relative_playout_delay = null;
}
const r16 = {
audio_jitter_buffer,
audio_jitter_target,
audio_jitter_delay,
relative_reception_delay,
relative_playout_delay
};
const r59 = {};
for (const key in r16) {
const r21 = r16[key];
if (r21 instanceof Histogram) {
const report = r21.getReport([75, 95, 99]);
r59[key + "_mean"] = Math.round(report.mean);
r59[key + "_p75"] = Math.round(report.percentiles[75]);
r59[key + "_p95"] = Math.round(report.percentiles[95]);
r59[key + "_p99"] = Math.round(report.percentiles[99]);
r59[key + "_max"] = Math.round(report.max);
} else {
r59[key + "_mean"] = r21 != null ? r21.mean : 0;
r59[key + "_p75"] = r21 != null ? r21.p75 : 0;
r59[key + "_p95"] = r21 != null ? r21.p95 : 0;
r59[key + "_p99"] = r21 != null ? r21.p99 : 0;
r59[key + "_max"] = r21 != null ? r21.max : 0;
}
}
return {
...r59
};
}
getFrameOpStats() {
const r11 = Module12.reduce(this.inboundStats, (a0, a1) => {
if (a1.frameOpStats.silent != null) {
a0.silent = a0.silent + a1.frameOpStats.silent;
}
if (a1.frameOpStats.normal != null) {
a0.normal = a0.normal + a1.frameOpStats.normal;
}
if (a1.frameOpStats.merged != null) {
a0.merged = a0.merged + a1.frameOpStats.merged;
}
if (a1.frameOpStats.expanded != null) {
a0.expanded = a0.expanded + a1.frameOpStats.expanded;
}
if (a1.frameOpStats.accelerated != null) {
a0.accelerated = a0.accelerated + a1.frameOpStats.accelerated;
}
if (a1.frameOpStats.preemptiveExpanded != null) {
a0.preemptiveExpanded = a0.preemptiveExpanded + a1.frameOpStats.preemptiveExpanded;
}
if (a1.frameOpStats.cng != null) {
a0.cng = a0.cng + a1.frameOpStats.cng;
}
return a0;
}, {
silent: 0,
normal: 0,
merged: 0,
expanded: 0,
accelerated: 0,
preemptiveExpanded: 0,
cng: 0
});
return {
frame_op_silent: r11.silent,
frame_op_normal: r11.normal,
frame_op_merged: r11.merged,
frame_op_expanded: r11.expanded,
frame_op_accelerated: r11.accelerated,
frame_op_preemptive_expanded: r11.preemptiveExpanded,
frame_op_cng: r11.cng
};
}
getDurationStats() {
return {
duration_listening: this.duration.listening,
duration_speaking: this.duration.speaking,
duration_participation: this.duration.participation,
duration_connected: this.duration.connected
};
}
getTransportStats() {
return {
decryption_failures: this.decryptionFailures,
routing_failures: this.routingFailures
};
}
getE2EEStats() {
const r11 = Module12.reduce(this.inboundStats, (a0, a1) => {
const passthroughCount2 = a0.passthroughCount;
let passthroughCount = a1.passthroughCount;
if (passthroughCount == null) {
passthroughCount = 0;
}
a0.passthroughCount = passthroughCount2 + passthroughCount;
const decryptSuccessCount = a0.decryptSuccessCount;
let decryptSuccessCount2 = a1.decryptSuccessCount;
if (decryptSuccessCount2 == null) {
decryptSuccessCount2 = 0;
}
a0.decryptSuccessCount = decryptSuccessCount + decryptSuccessCount2;
const decryptFailureCount = a0.decryptFailureCount;
let decryptFailureCount2 = a1.decryptFailureCount;
if (decryptFailureCount2 == null) {
decryptFailureCount2 = 0;
}
a0.decryptFailureCount = decryptFailureCount + decryptFailureCount2;
const decryptDuration = a0.decryptDuration;
let decryptDuration2 = a1.decryptDuration;
if (decryptDuration2 == null) {
decryptDuration2 = 0;
}
a0.decryptDuration = decryptDuration + decryptDuration2;
const decryptAttempts = a0.decryptAttempts;
let decryptAttempts2 = a1.decryptAttempts;
if (decryptAttempts2 == null) {
decryptAttempts2 = 0;
}
a0.decryptAttempts = decryptAttempts + decryptAttempts2;
const decryptMissingKeyCount = a0.decryptMissingKeyCount;
let decryptMissingKeyCount2 = a1.decryptMissingKeyCount;
if (decryptMissingKeyCount2 == null) {
decryptMissingKeyCount2 = 0;
}
a0.decryptMissingKeyCount = decryptMissingKeyCount + decryptMissingKeyCount2;
const decryptInvalidNonceCount = a0.decryptInvalidNonceCount;
let decryptInvalidNonceCount2 = a1.decryptInvalidNonceCount;
if (decryptInvalidNonceCount2 == null) {
decryptInvalidNonceCount2 = 0;
}
a0.decryptInvalidNonceCount = decryptInvalidNonceCount + decryptInvalidNonceCount2;
const decryptFailureAfterSuccessCount = a0.decryptFailureAfterSuccessCount;
let decryptFailureCount3 = a1.decryptFailureCount;
if (decryptFailureCount3 == null) {
decryptFailureCount3 = 0;
}
let decryptFailureBeforeSuccessCount = a1.decryptFailureBeforeSuccessCount;
if (decryptFailureBeforeSuccessCount == null) {
decryptFailureBeforeSuccessCount = 0;
}
a0.decryptFailureAfterSuccessCount = decryptFailureAfterSuccessCount + (decryptFailureCount3 - decryptFailureBeforeSuccessCount);
return a0;
}, {
passthroughCount: 0,
decryptSuccessCount: 0,
decryptFailureCount: 0,
decryptDuration: 0,
decryptAttempts: 0,
decryptMissingKeyCount: 0,
decryptInvalidNonceCount: 0,
decryptFailureAfterSuccessCount: 0
});
return {
decrypt_passthrough_count: r11.passthroughCount,
decrypt_success_count: r11.decryptSuccessCount,
decrypt_failure_count: r11.decryptFailureCount,
decrypt_duration: r11.decryptDuration,
decrypt_attempts: r11.decryptAttempts,
decrypt_missing_key_count: r11.decryptMissingKeyCount,
decrypt_invalid_nonce_count: r11.decryptInvalidNonceCount,
decrypt_failure_after_success_count: r11.decryptFailureAfterSuccessCount,
encrypt_passthrough_count: this.outboundStats.passthroughCount,
encrypt_success_count: this.outboundStats.encryptSuccessCount,
encrypt_failure_count: this.outboundStats.encryptFailureCount,
encrypt_duration: this.outboundStats.encryptDuration,
encrypt_attempts: this.outboundStats.encryptAttempts,
encrypt_max_attempts: this.outboundStats.encryptMaxAttempts,
encrypt_missing_key_count: this.outboundStats.encryptMissingKeyCount
};
}
getAudioDeviceStats() {
return {
input_device_restart_count: this.inputDeviceStats.restartCount?.accumulated,
output_device_restart_count: this.outputDeviceStats.restartCount?.accumulated,
input_device_time_to_first_audio: this.inputDeviceStats.timeToFirstCallbackMs,
output_device_time_to_first_audio: this.outputDeviceStats.timeToFirstCallbackMs,
input_device_buffer_overfull_count: this.inputDeviceStats.bufferViolations?.accumulated,
output_device_buffer_underrun_count: this.outputDeviceStats.bufferViolations?.accumulated,
input_device_session_sample_rate: this.inputDeviceStats.sessionSampleRate,
output_device_session_sample_rate: this.outputDeviceStats.sessionSampleRate,
input_device_time_from_connect_to_first_audio_ms: this.inputDeviceStats.timeFromConnectToFirstCallbackMs,
output_device_time_from_connect_to_first_audio_ms: this.outputDeviceStats.timeFromConnectToFirstCallbackMs
};
}
getAudioLevelStats() {
const report = this.outboundStats.speakingAudioLevel.getReport([1, 5, 10, 25, 50, 75, 90, 95, 99]);
return {
outbound_audio_level_db_p1: report.percentiles[1],
outbound_audio_level_db_p5: report.percentiles[5],
outbound_audio_level_db_p10: report.percentiles[10],
outbound_audio_level_db_p25: report.percentiles[25],
outbound_audio_level_db_p50: report.percentiles[50],
outbound_audio_level_db_p75: report.percentiles[75],
outbound_audio_level_db_p90: report.percentiles[90],
outbound_audio_level_db_p95: report.percentiles[95],
outbound_audio_level_db_p99: report.percentiles[99],
outbound_audio_level_db_max: report.max,
outbound_audio_level_db_mean: report.mean
};
}
getPeriodicStats() {
const r0 = [];
for (const item of Object.entries(this.periodicInboundStats)) {
const [userId, r44] = item;
const { previous, current, currentTimestampMs, previousTimestampMs, numRateSamples } = r44;
if (previousTimestampMs !== void 0 && currentTimestampMs > previousTimestampMs) {
const durationMs = currentTimestampMs - previousTimestampMs;
let silent = current.silent;
if (silent == null) {
let silent2 = previous.silent;
if (silent2 == null) {
silent2 = 0;
}
silent = 0 - silent2;
}
let normal = current.normal;
if (normal == null) {
let normal2 = previous.normal;
if (normal2 == null) {
normal2 = 0;
}
normal = 0 - normal2;
}
let merged = current.merged;
if (merged == null) {
let merged2 = previous.merged;
if (merged2 == null) {
merged2 = 0;
}
merged = 0 - merged2;
}
let expanded = current.expanded;
if (expanded == null) {
let expanded2 = previous.expanded;
if (expanded2 == null) {
expanded2 = 0;
}
expanded = 0 - expanded2;
}
let accelerated = current.accelerated;
if (accelerated == null) {
let accelerated2 = previous.accelerated;
if (accelerated2 == null) {
accelerated2 = 0;
}
accelerated = 0 - accelerated2;
}
let preemptiveExpanded = current.preemptiveExpanded;
if (preemptiveExpanded == null) {
let preemptiveExpanded2 = previous.preemptiveExpanded;
if (preemptiveExpanded2 == null) {
preemptiveExpanded2 = 0;
}
preemptiveExpanded = 0 - preemptiveExpanded2;
}
let cng = current.cng;
if (cng == null) {
let cng2 = previous.cng;
if (cng2 == null) {
cng2 = 0;
}
cng = 0 - cng2;
}
const accelerateRateSum = r44.accelerateRateSum;
const r58 = {
userId,
silent,
normal,
merged,
expanded,
accelerated,
preemptiveExpanded,
cng,
accelerateRate: accelerateRateSum / numRateSamples,
expandRate: r44.expandRateSum / numRateSamples,
preemptiveExpandRate: r44.preemptiveExpandRateSum / numRateSamples,
speechExpandRate: r44.speechExpandRateSum / numRateSamples,
durationMs
};
if (r58.normal + r58.merged + r58.expanded + r58.accelerated + r58.preemptiveExpanded > 0) {
r0.push(r58);
}
}
const periodicInboundStats = this.periodicInboundStats;
periodicInboundStats[userId].accelerateRateSum = 0;
this.periodicInboundStats[userId].expandRateSum = 0;
this.periodicInboundStats[userId].preemptiveExpandRateSum = 0;
this.periodicInboundStats[userId].speechExpandRateSum = 0;
this.periodicInboundStats[userId].numRateSamples = 0;
this.periodicInboundStats[userId].previous = current;
this.periodicInboundStats[userId].previousTimestampMs = currentTimestampMs;
}
return r0;
}
calculateMos(a0, a1) {
const r12 = this.calculateR(a0, a1);
return r12 < 0 ? 1 : r12 > 100 ? 4.5 : 1 + 0.035 * r12 + 0.0000071 * r12 * (r12 - 60) * (100 - r12);
}
calculateR(a0, a1) {
return 93.4 - (0.024 * a0 + (a0 > 177.3 ? 0.11 * (a0 - 177.3) : 0)) - (10 + 122 * a1 / (a1 + 10));
}
}
export default VoiceQuality;
export { c8874_4 as VoiceQualityEvent };
+100
View File
@@ -0,0 +1,100 @@
// Metro module 12882 (f12883).
import MediaEngineStore from "../stores/MediaEngineStore";
import VoiceStateStore from "../stores/VoiceStateStore";
import SortedVoiceStateStore from "../stores/views/SortedVoiceStateStore";
import { SpeakingFlags } from "../_bundle/Module4250";
import { intersection } from "../_bundle/Module12";
class VoiceStateAnalytics {
constructor(a0, a1) {
const r9 = {
__proto__: new.target.prototype,
maxVoiceStateCount: 1,
totalParticipants: new Set(),
speaking: null,
maxListenerCount: 0,
totalListeners: null,
maxSpeakerCount: 0,
totalSpeakers: null
};
r9.speaking = SpeakingFlags.NONE;
r9.totalListeners = new Set();
r9.totalSpeakers = {};
r9.userId = a0;
r9.setChannelId(a1);
return r9;
}
updateVoiceStates(a0, a1) {
if (a1 === this.channelId) {
this.totalParticipants.add(a0);
this.maxVoiceStateCount = Math.max(SortedVoiceStateStore.countVoiceStatesForChannel(a1), this.maxVoiceStateCount);
} else {
if (a1 == null && a0 in this.totalSpeakers) {
this.totalSpeakers[a0] = SpeakingFlags.NONE;
}
if (a0 === this.userId && a1 != null) {
this.setChannelId(a1);
}
}
}
getStats() {
return {
max_voice_state_count: this.maxVoiceStateCount,
total_voice_state_count: this.totalParticipants.size,
max_listener_count: this.maxListenerCount,
total_listener_count: this.totalListeners.size,
max_speaker_count: this.maxSpeakerCount,
total_speaker_count: Object.keys(this.totalSpeakers).length
};
}
getUserVoiceSettingsStats(a0) {
const settings = MediaEngineStore.getSettings(a0);
const set = new Set(Object.keys(settings.localMutes));
const set2 = new Set(Object.keys(settings.localVolumes));
set2.delete(this.userId);
set.delete(this.userId);
return {
num_local_voice_user_mutes: intersection(Array.from(set), Array.from(this.totalParticipants)).length,
num_local_voice_volumes: intersection(Array.from(set2), Array.from(this.totalParticipants)).length
};
}
setSpeaking(a0, a1) {
if (a1 !== SpeakingFlags.NONE) {
const voiceStateForChannel = VoiceStateStore.getVoiceStateForChannel(this.channelId, a0);
if (voiceStateForChannel != null && !voiceStateForChannel.selfMute && !voiceStateForChannel.mute) {
this.totalSpeakers[a0] = a1;
this.maxSpeakerCount = Math.max(this.maxSpeakerCount, Object.values(this.totalSpeakers).filter((item) => item !== SpeakingFlags.NONE).length);
}
} else if (a0 in this.totalSpeakers) {
this.totalSpeakers[a0] = SpeakingFlags.NONE;
}
if (this.userId === a0) {
if (a1 === this.speaking) {
return void 0;
}
if (a1 !== SpeakingFlags.NONE) {
const r46 = Object.values(VoiceStateStore.getVoiceStatesForChannel(this.channelId)).filter((item) => {
const selfDeaf = item.selfDeaf;
return selfDeaf ? !selfDeaf : !item.deaf;
});
r46.forEach((item) => this.totalListeners.add(item.userId));
this.maxListenerCount = Math.max(r46.length, this.maxListenerCount);
}
this.speaking = a1;
}
}
setChannelId(a0) {
if (a0 !== this.channelId) {
this.channelId = a0;
this.totalParticipants = new Set([this.userId]);
const r22 = Object.keys(VoiceStateStore.getVoiceStatesForChannel(this.channelId));
r22.forEach((item) => this.totalParticipants.add(item));
this.maxVoiceStateCount = r22.length;
this.speaking = SpeakingFlags.NONE;
this.maxListenerCount = 0;
this.totalListeners = new Set();
this.maxSpeakerCount = 0;
this.totalSpeakers = {};
}
}
}
export default VoiceStateAnalytics;
+9
View File
@@ -0,0 +1,9 @@
// Metro module 10560 (f10561).
import AppStateStore from "../stores/native/AppStateStore";
import { AppStates } from "../Constants";
import ExternalPip_android from "../modules/external_pip/ExternalPip.android";
export default function isDiscordVisible() {
const r1 = AppStateStore.getState() === AppStates.BACKGROUND;
const isInPipMode = ExternalPip_android.isInPipMode();
return r1 ? isInPipMode : !r1;
};
+60
View File
@@ -0,0 +1,60 @@
// Metro module 10559 (f10560).
import TypedEventEmitter from "../_bundle/TypedEventEmitter";
import { Timeout } from "../_bundle/Timeout";
import Logger from "../modules/debug/Logger";
import Durations from "../utils/Durations";
import Dispatcher from "../Dispatcher";
import ExternalPip_android from "../modules/external_pip/ExternalPip.android";
import WindowVisibilityUtils_native from "./WindowVisibilityUtils.native";
let c7096_3 = {
WindowVisibilityChanged: "window-visibility-changed",
IncomingVideoEnabledChanged: "incoming-video-enabled-changed"
};
class WindowVisibilityVideoManager extends TypedEventEmitter {
disableVideoTimer = new Timeout();
discordVisible = true;
incomingVideoEnabled = true;
lastEnabledChange = performance.now();
logger = new Logger("WindowVisibilityVideoManager");
HIDDEN_WINDOW_DISABLE_VIDEO_DURATION_MS = 30 * Durations.Millis.SECOND;
update = () => {
if (this.discordVisible !== WindowVisibilityUtils_native()) {
this.discordVisible = WindowVisibilityUtils_native();
this.emit(c7096_3.WindowVisibilityChanged, this.discordVisible);
const discordVisible = this.discordVisible;
const disableVideoTimer = this.disableVideoTimer;
if (discordVisible) {
disableVideoTimer.stop();
this.setIncomingVideoEnabled(true);
} else {
disableVideoTimer.start(this.HIDDEN_WINDOW_DISABLE_VIDEO_DURATION_MS, () => {
this.setIncomingVideoEnabled(false);
});
}
}
};
constructor() {
super();
Dispatcher.subscribe("WINDOW_VISIBILITY_CHANGE", this.update);
Dispatcher.subscribe("APP_STATE_UPDATE", this.update);
ExternalPip_android.addOnPipModeChangedListener(this.update);
}
isIncomingVideoEnabled() {
return this.incomingVideoEnabled;
}
lastIncomingVideoEnabledChangeTime() {
return this.lastEnabledChange;
}
setIncomingVideoEnabled(a0) {
const incomingVideoEnabled = this.incomingVideoEnabled;
this.incomingVideoEnabled = a0;
if (incomingVideoEnabled !== a0) {
this.logger.info(`Incoming video enabled changed, incomingVideoEnabled = ${this.incomingVideoEnabled}`);
this.lastEnabledChange = performance.now();
this.emit(c7096_3.IncomingVideoEnabledChanged, this.incomingVideoEnabled);
}
}
}
const windowVisibilityVideoManager = new WindowVisibilityVideoManager();
export { c7096_3 as WindowVisibilityEvent };
export { windowVisibilityVideoManager as WindowVisibilityVideoManager };
+58
View File
@@ -0,0 +1,58 @@
// Metro module 4057 (f4058).
import { createWithEqualityFn } from "../_bundle/identity_700";
import { subscribeWithSelector } from "../_bundle/createJSONStorage";
import { batchUpdates } from "../_bundle/Module705";
function $mk103488($env) {
return () => $env.$parent[1].setState($env[0]);
}
let env2330 = {};
const defaultStatesAreEqual = function defaultStatesAreEqual(a0, a1) {
return a0 === a1;
};
export function createZustandStore(a0) {
let env13816 = {
$parent: env2330
};
env13816[0] = a0;
env13816[1] = createWithEqualityFn(subscribeWithSelector((c24920_0, a1, a2) => (0, env13816[0])((c29258_0) => batchUpdates(() => c24920_0(c29258_0)), a1, a2)));
const setState = (a0) => {
let env24921;
const r1 = env24921 = {
$parent: env13816
};
env24921[0] = a0;
batchUpdates($mk103488(r1));
};
env13816[2] = setState;
return {
useState: function useState(a0, r3 = defaultStatesAreEqual) {
return (0, env13816[1])(a0, r3);
},
getState: function getState(a0) {
const state = env13816[1].getState();
return a0 != null ? a0(state) : state;
},
useField: function useField(c24922_0, r3 = defaultStatesAreEqual) {
if (r3 === void 0) {
r3 = defaultStatesAreEqual;
}
return (0, env13816[1])((a0) => a0[c24922_0], r3);
},
getField: function getField(a0) {
return env13816[1].getState()[a0];
},
subscribe: function subscribe(a0, a1, a2) {
return env13816[1].subscribe(a0, a1, a2);
},
setState,
resetState: function resetState() {
const initialState = env13816[1].getInitialState();
let env24923;
const r8 = env24923 = {
$parent: env13816
};
env24923[0] = initialState;
batchUpdates($mk103488(r8));
}
};
}
+509
View File
@@ -0,0 +1,509 @@
// Metro module 8207 (f8208).
import ApplicationStore from "../modules/applications/ApplicationStore";
import "../modules/guild_scheduled_events/GuildScheduledEventStore";
import "../modules/slayer_storefront/SocialLayerStorefrontStore";
import AuthenticationStore from "../stores/AuthenticationStore";
import GuildMemberStore from "../stores/GuildMemberStore";
import "../stores/GuildStore";
import InviteStore from "../stores/InviteStore";
import "../stores/MessageStore";
import SelectedChannelStore from "../stores/SelectedChannelStore";
import SelectedGuildStore from "../stores/SelectedGuildStore";
import SortedGuildStore from "../stores/SortedGuildStore";
import { InviteStates, AbortCodes, AppContext, JoinGuildSources, Routes, AnalyticEvents } from "../Constants";
import { CollectibleShopTab, CollectiblesMobileShopScreen } from "../modules/collectibles/CollectiblesShopConstants";
import { isGameShopPath } from "../modules/slayer_storefront/SocialLayerStorefrontConstants";
import Dispatcher from "../Dispatcher";
import { getInviteInstanceId } from "../modules/instant_invite/InviteCodeUtils";
import InstantInviteActionCreators from "../actions/InstantInviteActionCreators";
import safeTransitionTo_native from "../modules/links/safeTransitionTo.native";
import { findCodedLink } from "../modules/coded_links/findCodedLinks";
import { CodedLinkType } from "../modules/coded_links/CodedLink";
import { parseStorefrontSkuCodedLink } from "../modules/application_storefront/storefrontMessageEmbedCodedLink";
import openURL from "./openURL";
import AnalyticsUtils from "../utils/AnalyticsUtils";
import getEmbeddedActivitiesManager_native from "../modules/activities/utils/getEmbeddedActivitiesManager.native";
import { getPlayInContext } from "../modules/applications/message_embed/utils/getPlayInContext";
import { getCustomActivityLinkParams } from "../modules/activities/utils/CustomActivityLinkUtils";
import { runPrimaryAppCommandOrJoinEmbeddedActivity } from "../modules/activities/EmbeddedActivitiesActionCreators";
import ChannelActionCreators from "../actions/ChannelActionCreators";
import handleUsePrimaryEntryPointAppCommand from "../modules/activities/handleUsePrimaryEntryPointAppCommand";
import { openSocialLayerStorefrontProductDetailsModal, openSocialLayerStorefrontUnsupportedOnMobileAlert } from "../modules/slayer_storefront/native/SocialLayerStorefrontNativeActionCreators";
import { getIsEligibleForQuests } from "../modules/quests/lib/QuestsEligibility";
import URLUtils from "../utils/URLUtils";
import { openQuestHome } from "../modules/quests/native/QuestUtils.native";
import { QuestContent } from "../_bundle/Module5038";
import { isVirtualCurrencyEnabled } from "../modules/virtual_currency/hooks/native/useVirtualCurrencyMobileEnabled";
import AppAnalyticsUtils from "../modules/app_analytics/AppAnalyticsUtils";
import { tryParseEventDetailsPath } from "../modules/links/LinkUtils";
import { isSuspiciousDownload } from "../modules/suspicious_downloads/SuspiciousDownloadUtils";
import SuspiciousDownloadModalActionCreators_native from "../modules/suspicious_downloads/SuspiciousDownloadModalActionCreators.native";
function $mk115124($env) {
return (a0) => !$env[9].has(a0.id);
}
let c5215_20;
let env5215 = {};
const openInviteModal = async function openInviteModal(a0, code, invite_instance_id) {
await Dispatcher.dispatch({
type: "DISPLAYED_INVITE_SHOW",
code,
username: void 0,
deeplinkAttemptId: void 0,
invite_instance_id
});
};
env5215[19] = function _handleInviteCodedLink() {
const r8 = async (c26135_0, c26135_1) => {
let invite, roles, c26135_4, c26135_5;
L67: {
L41: {
L39: {
L42: {
let env29904;
c26135_5 = env5215;
const r14 = env29904 = {};
c26135_4 = r14;
env29904[0] = void 0;
env29904[1] = void 0;
env29904[2] = void 0;
env29904[3] = void 0;
env29904[4] = void 0;
env29904[5] = void 0;
env29904[6] = void 0;
env29904[7] = void 0;
env29904[8] = void 0;
env29904[9] = void 0;
const code2 = c26135_0.code;
env29904[0] = code2;
const inviteInstanceId = getInviteInstanceId(code2, c26135_1);
env29904[1] = inviteInstanceId;
env29904[2] = InviteStore.getInvite(code2);
if (env29904[2] != null && env29904[2].state !== InviteStates.ERROR) {
if (env29904[2] == null) {
break L67;
}
if (env29904[2].state !== InviteStates.EXPIRED && env29904[2].state !== InviteStates.BANNED && env29904[2].state !== InviteStates.ERROR) {
env29904[3] = SortedGuildStore.getFlattenedGuildIds();
const r244 = env29904[2];
env29904[4] = r244 == null ? void 0 : r244.guild?.id;
env29904[5] = env29904[4] != null && env29904[3].includes(env29904[4]);
env29904[6] = false;
if (env29904[5] && env29904[2].roles != null && env29904[2].roles.length > 0) {
env29904[7] = AuthenticationStore.getId();
env29904[8] = GuildMemberStore.getMember(env29904[4], env29904[7]);
const r279 = Set;
roles = env29904[8]?.roles;
if (roles == null) {
roles = [];
}
const r283 = c26135_4;
env29904[9] = new r279(roles);
env29904[6] = env29904[2].roles.some($mk115124(r283));
}
if (env29904[5] && !env29904[6]) {
InstantInviteActionCreators.transitionToInvite(env29904[2], {
forceTransition: true
});
break L67;
}
await (0, openInviteModal)(env29904[2], env29904[0], env29904[1]);
break L39;
}
await (0, openInviteModal)(env29904[2], env29904[0], env29904[1]);
break L41;
}
invite = (await InstantInviteActionCreators.resolveInvite(code2, "Markdown Link", {
inviteInstanceId
})).invite;
if (invite == null) {
invite = void 0;
}
env29904[2] = invite;
if (env29904[2] != null) {
if (env29904[2].state !== InviteStates.EXPIRED && env29904[2].state !== InviteStates.BANNED && env29904[2].state !== InviteStates.ERROR) {
env29904[3] = SortedGuildStore.getFlattenedGuildIds();
const r117 = env29904[2];
env29904[4] = r117 == null ? void 0 : r117.guild?.id;
env29904[5] = env29904[4] != null && env29904[3].includes(env29904[4]);
env29904[6] = false;
if (env29904[5] && env29904[2].roles != null && env29904[2].roles.length > 0) {
env29904[7] = AuthenticationStore.getId();
env29904[8] = GuildMemberStore.getMember(env29904[4], env29904[7]);
const r152 = Set;
roles = env29904[8]?.roles;
if (roles == null) {
roles = [];
}
const r156 = c26135_4;
env29904[9] = new r152(roles);
env29904[6] = env29904[2].roles.some($mk115124(r156));
}
if (env29904[5] && !env29904[6]) {
InstantInviteActionCreators.transitionToInvite(env29904[2], {
forceTransition: true
});
break L42;
}
await (0, openInviteModal)(env29904[2], env29904[0], env29904[1]);
break L39;
}
await (0, openInviteModal)(env29904[2], env29904[0], env29904[1]);
break L41;
}
}
return void 0;
}
return void 0;
}
return void 0;
}
};
env5215[19] = r8;
return r8.apply(this, arguments);
};
AbortCodes;
AppContext;
JoinGuildSources;
Routes;
c5215_20 = {
skipExtensionCheck: void 0,
analyticsLocations: []
};
export default function getOnClick(a0) {
let r24, r109, skipExtensionCheck;
let env16348 = {
$parent: env5215
};
env16348[0] = a0;
let r5 = arguments[1];
if (r5 === void 0) {
r5 = c5215_20;
}
L5: {
skipExtensionCheck = r5.skipExtensionCheck;
env16348[1] = r5.analyticsLocations;
env16348[2] = r5.messageId;
r5.channelId;
env16348[3] = void 0;
env16348[4] = void 0;
env16348[5] = void 0;
r24 = findCodedLink(a0);
env16348[3] = r24;
if (r24 != null) {
if (r24.type !== CodedLinkType.INVITE && r24.type !== CodedLinkType.EMBEDDED_ACTIVITY_INVITE) {
break L5;
}
return (a0) => {
if (a0 != null) {
a0.preventDefault();
}
(function handleInviteCodedLink() {
return env5215[19].apply(this, arguments);
})(env16348[3], env16348[2]);
return true;
};
}
}
L9: {
if (r24 != null) {
if (r24.type !== CodedLinkType.APP_DIRECTORY_PROFILE && r24.type !== CodedLinkType.APP_DIRECTORY_STOREFRONT && r24.type !== CodedLinkType.APP_DIRECTORY_STOREFRONT_SKU) {
break L9;
}
return (a0) => {
let r25;
if (a0 != null) {
a0.preventDefault();
}
L8: {
const r5 = env16348[3];
const code2 = r5.code;
if (r5.type !== CodedLinkType.APP_DIRECTORY_PROFILE && r5.type !== CodedLinkType.APP_DIRECTORY_STOREFRONT) {
r25 = parseStorefrontSkuCodedLink(code2);
if (r25 != null) {
break L8;
}
r25 = {
applicationId: void 0,
skuId: void 0
};
} else {
r25 = {
applicationId: code2,
skuId: void 0
};
}
}
const applicationId = r25.applicationId;
r25.skuId;
let guild_id = SelectedGuildStore.getGuildId();
if (guild_id == null) {
guild_id = void 0;
}
if (applicationId != null) {
AnalyticsUtils.track(AnalyticEvents.APP_DIRECTORY_PROFILE_EMBED_URL_CLICKED, {
application_id: applicationId,
device_platform: "mobile_native",
guild_id,
channel_id: SelectedChannelStore.getChannelId()
});
}
openURL(env16348[0]);
return true;
};
}
}
if (r24 != null && r24.type === CodedLinkType.ACTIVITY_BOOKMARK) {
return (a0) => {
if (a0 != null) {
a0.preventDefault();
}
let env26136 = {
$parent: env16348
};
const r24 = env16348[3];
const code2 = r24.code;
env26136[0] = code2;
const url = r24.url;
const application = ApplicationStore.getApplication(code2);
const uRL = new URL(url);
env26136[1] = uRL;
let r33 = uRL.searchParams.get("referrer_id");
if (r33 == null) {
r33 = void 0;
}
env26136[2] = r33;
env26136[3] = getEmbeddedActivitiesManager_native();
const playInContext = getPlayInContext(code2);
const currentChannelId = playInContext.currentChannelId;
env26136[4] = currentChannelId;
env26136[5] = playInContext.instanceId;
const isCurrentlyInInstance = playInContext.isCurrentlyInInstance;
if (playInContext.canLaunchInChannel) {
let r62 = isCurrentlyInInstance ? !isCurrentlyInInstance : currentChannelId != null;
if (r62) {
const customActivityLinkParams = getCustomActivityLinkParams(code2, uRL.searchParams.get("link_id"), uRL.searchParams.get("custom_id"));
let c26138_0 = async (c31449_0) => {
let c31449_2;
c31449_2 = void 0;
let c31973_0 = c31449_0.customId;
await void 0;
const r11 = c31449_2;
const r12 = r11.$parent;
await runPrimaryAppCommandOrJoinEmbeddedActivity({
channelId: r12[4],
applicationId: r12[0],
isStart: r12[5] == null,
embeddedActivitiesManager: r12[3],
customId: c31973_0,
referrerId: r12[2],
analyticsLocations: r11.$parent.$parent[1]
});
};
customActivityLinkParams.then(function() {
return c26138_0.apply(this, arguments);
}).catch(() => {});
r62 = true;
}
return r62;
}
const recipientIds = application == null ? void 0 : application.bot?.id;
let r47 = recipientIds != null;
if (r47) {
const r52 = ChannelActionCreators.openPrivateChannel({
recipientIds
});
let c26137_0 = async (c31450_0) => {
let c31450_2;
c31450_2 = void 0;
let c31974_0 = c31450_0;
const r33 = env26136[0];
const r34 = env26136[1];
let c31974_1 = (await getCustomActivityLinkParams(r33, r34.searchParams.get("link_id"), r34.searchParams.get("custom_id"))).customId;
handleUsePrimaryEntryPointAppCommand({
targetApplicationId: env26136[0],
channelId: c31974_0,
analyticsLocations: env26136.$parent[1],
customId: c31974_1,
referrerId: env26136[2]
});
};
r52.then(function() {
return c26137_0.apply(this, arguments);
}).catch(() => {});
r47 = true;
}
return r47;
};
}
if (r24 != null && r24.type === CodedLinkType.GUILD_PRODUCT) {
return (a0) => {
if (a0 != null) {
a0.preventDefault();
}
let [c26139_0, c26139_1] = env16348[3].code.split("-");
import("../modules/guild_products/GuildProductLinkActionCreators.native").then((result) => {
(0, result.openGuildProductLink)(c26139_0, c26139_1);
});
return true;
};
}
if (r24 != null && r24.type === CodedLinkType.SOCIAL_LAYER_STOREFRONT) {
return (a0) => {
if (a0 != null) {
a0.preventDefault();
}
const [skuId, ] = env16348[3].code.split("-");
(0, openSocialLayerStorefrontProductDetailsModal)({
skuId,
analyticsLocations: env16348[1]
});
return true;
};
}
if (r24 != null && r24.type === CodedLinkType.SOCIAL_LAYER_STOREFRONT_APP) {
return (a0) => {
if (a0 != null) {
a0.preventDefault();
}
const [skuId, ] = env16348[3].code.split("-");
(0, openSocialLayerStorefrontProductDetailsModal)({
skuId,
analyticsLocations: env16348[1]
});
return true;
};
}
if (r24 != null && r24.type === CodedLinkType.QUESTS_EMBED && getIsEligibleForQuests()) {
return (a0) => {
if (a0 != null) {
a0.preventDefault();
}
const r9 = env16348[3];
let r20 = URLUtils.toURLSafe(r9.url);
if (r20 == null) {
r20 = {};
}
const search = r20.search;
const r2 = search != null;
let filter = void 0;
let sort = void 0;
if (r2) {
const uRLSearchParams = new URLSearchParams(search);
let r28 = uRLSearchParams.get("sort");
if (r28 == null) {
r28 = void 0;
}
let r31 = uRLSearchParams.get("filter");
if (r31 == null) {
r31 = void 0;
}
filter = r31;
sort = r28;
}
if (sort == null) {
sort = null;
}
if (filter == null) {
filter = null;
}
openQuestHome({
scrollToQuestId: r9.code,
sort,
filter,
fromContent: QuestContent.QUEST_SHARE_LINK
});
return true;
};
}
if (r24 != null && r24.type === CodedLinkType.COLLECTIBLES_SHOP) {
return (a0) => {
if (a0 != null) {
a0.preventDefault();
}
const enabled = isVirtualCurrencyEnabled().enabled;
import("../modules/collectibles/CollectiblesActionCreators").then(({ openCollectiblesShopMobile }) => {
const [r8, r15] = env16348[3].code.split("-");
const r2 = r15 !== "";
const screen = enabled && r8 === CollectibleShopTab.ORBS ? CollectiblesMobileShopScreen.ORBS : r2 ? CollectiblesMobileShopScreen.SHOP_ALL : CollectiblesMobileShopScreen.FEATURED_PAGE;
const analyticsLocations = env16348[1];
openCollectiblesShopMobile({
analyticsSource: analyticsLocations[analyticsLocations.length - 1],
analyticsLocations,
screen,
initialProductSkuId: r2 ? r15 : void 0
});
});
return true;
};
}
let r86 = URLUtils.toURLSafe(a0);
if (r86 == null) {
r86 = {};
}
let host = r86.host;
let hostname = r86.hostname;
const pathname = r86.pathname;
env16348[4] = pathname;
const { search, hash } = r86;
let r90 = URLUtils.isDiscordHostname(hostname == null ? null : hostname);
if (!r90) {
if (host == null) {
host = null;
}
if (hostname == null) {
hostname = null;
}
r90 = URLUtils.isDiscordLocalhost(host, hostname);
}
if (r90 && pathname != null && (0, isGameShopPath)(pathname)) {
return (a0) => {
if (a0 != null) {
a0.preventDefault();
}
(0, openSocialLayerStorefrontUnsupportedOnMobileAlert)();
return true;
};
}
if (pathname != null && r90 && URLUtils.isAppRoute(pathname)) {
const r114 = {
navigationReplace: false,
openChannel: true
};
env16348[5] = r114;
if (search != null) {
r114.search = search;
}
if (hash != null) {
r114.hash = hash;
}
return (a0) => {
if (a0 != null) {
a0.preventDefault();
}
safeTransitionTo_native(env16348[4], env16348[5]);
return true;
};
}
if (r24 != null && r24.type === CodedLinkType.APP_OAUTH2_LINK) {
r109 = (a0) => {
if (a0 != null) {
a0.preventDefault();
}
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.APP_OAUTH2_LINK_EMBED_URL_CLICKED, {
application_id: env16348[3].code
});
openURL(env16348[0]);
return true;
};
} else {
tryParseEventDetailsPath(pathname);
r109 = skipExtensionCheck ? void 0 : isSuspiciousDownload(a0) == null ? void 0 : (a0) => {
if (a0 != null) {
a0.preventDefault();
}
SuspiciousDownloadModalActionCreators_native.show(env16348[0]);
return true;
};
}
return r109;
};
+5
View File
@@ -0,0 +1,5 @@
// Metro module 16101 (f16102).
import * as _DeviceUtils from "../utils/native/DeviceUtils";
export default function getTimeZone() {
return _DeviceUtils.getTimeZone();
};
+63
View File
@@ -0,0 +1,63 @@
// Metro module 6058 (f6059).
import LRUCache from "../../_bundle/LRUCache";
import Module12 from "../../_bundle/Module12";
function $mk77679($env) {
return (a0, a1) => {
$env[0][a1] = a0;
};
}
class GuildChannelSubscriptions {
constructor(a0) {
const r3 = {
__proto__: new.target.prototype,
_subscriptions: {}
};
r3._onChange = a0;
return r3;
}
reset() {
this._subscriptions = {};
}
get(a0) {
let env15429;
const r3 = this._get(a0);
const r4 = env15429 = {};
const r5 = {};
env15429[0] = r5;
r3.forEach($mk77679(r4));
return r5;
}
_get(a0) {
let r8 = this._subscriptions[a0];
if (r8 == null) {
r8 = new LRUCache({
max: 5
});
}
return r8;
}
clear(a0) {
delete this._subscriptions[a0];
}
subscribe(a0, a1, a2) {
const r8 = this._get(a0);
const isEqual = Module12.isEqual(r8.get(a1), a2);
let r17 = !isEqual;
if (!isEqual) {
let env15430;
r8.set(a1, a2);
this._subscriptions[a0] = r8;
const _onChange = this._onChange;
const r22 = env15430 = {};
const r23 = {};
env15430[0] = r23;
r8.forEach($mk77679(r22));
_onChange.call(this, a0, r23);
r17 = true;
}
return r17;
}
}
export default GuildChannelSubscriptions;
export const MINIMUM_RANGE = 100;
export const DEFAULT_RANGES = [[0, 99]];
+149
View File
@@ -0,0 +1,149 @@
// Metro module 5016 (f5017).
import { DelayedCall } from "../../_bundle/Timeout";
import Module12 from "../../_bundle/Module12";
function $mk75223($env) {
return (a0) => {
const r1 = $env;
return (0, r1[1])(r1[0], a0);
};
}
class GuildMemberRequestState {
constructor(a0, a1) {
let env14540;
const r1 = env14540 = {};
env14540[0] = a0;
env14540[1] = a1;
const r11 = {
__proto__: new.target.prototype,
_pendingRequests: new Set(),
_sentRequests: null,
_unacknowledgedRequests: null
};
r11._sentRequests = new Set();
r11._unacknowledgedRequests = new Set();
r11._guildId = a0;
r11._guildMemberExists = $mk75223(r1);
return r11;
}
acknowledge(a0) {
this._unacknowledgedRequests.delete(a0);
this._pendingRequests.delete(a0);
}
flushRequests(a0) {
let c14541_0;
if (this._pendingRequests.size !== 0) {
const r5 = [];
c14541_0 = r5;
this._pendingRequests.forEach((_pendingRequest) => {
if (!this._guildMemberExists(_pendingRequest)) {
this._unacknowledgedRequests.add(_pendingRequest);
this._sentRequests.add(_pendingRequest);
c14541_0.push(_pendingRequest);
}
});
if (r5.length > 0) {
a0(this._guildId, r5);
}
this._pendingRequests.clear();
}
}
requestUnacknowledged() {
let r1 = this._unacknowledgedRequests.size !== 0;
if (r1) {
this._unacknowledgedRequests.forEach((_unacknowledgedRequest) => {
if (this._guildMemberExists(_unacknowledgedRequest)) {
this._unacknowledgedRequests.delete(_unacknowledgedRequest);
} else {
this._pendingRequests.add(_unacknowledgedRequest);
}
});
r1 = this._pendingRequests.size !== 0 && void 0;
}
return r1;
}
request(a0) {
if (!this._guildMemberExists(a0) && !this._sentRequests.has(a0) && !this._pendingRequests.has(a0)) {
this._pendingRequests.add(a0);
return void 0;
}
return false;
}
}
class GuildMemberRequester {
_guildStates = {};
_flush = new DelayedCall(0, () => this.flushRequests());
constructor(a0, a1) {
this._guildMemberExists = a0;
this._onChange = a1;
}
reset() {
this._guildStates = {};
this._flush.cancel();
}
request(a0, a1) {
if (this._getGuildState(a0).request(a1) !== false) {
this._flush.delay(false);
}
}
acknowledge(a0, a1) {
this._getGuildState(a0).acknowledge(a1);
}
flushRequests() {
Module12.forEach(this._guildStates, (a0) => a0.flushRequests(this._onChange));
}
requestUnacknowledged() {
if (Module12.reduce(this._guildStates, (a0, a1) => a1.requestUnacknowledged() !== false || a0, false)) {
this._flush.delay();
}
}
_getGuildState(a0) {
let r11 = this._guildStates[a0];
if (r11 == null) {
const _guildStates = this._guildStates;
const _guildMemberExists = this._guildMemberExists;
let env14545;
const r15 = env14545 = {};
env14545[0] = a0;
env14545[1] = _guildMemberExists;
const r20 = {
__proto__: GuildMemberRequestState.prototype,
_pendingRequests: new Set(),
_sentRequests: null,
_unacknowledgedRequests: null
};
r20._sentRequests = new Set();
r20._unacknowledgedRequests = new Set();
r20._guildId = a0;
r20._guildMemberExists = $mk75223(r15);
_guildStates[a0] = r20;
r11 = r20;
}
return r11;
}
getDebugState(c14546_0) {
const pendingRequestGuildIds = [];
let c14546_1 = pendingRequestGuildIds;
const unacknowledgedRequestGuildIds = [];
let c14546_2 = unacknowledgedRequestGuildIds;
const sentRequestGuildIds = [];
let c14546_3 = sentRequestGuildIds;
Module12.forEach(this._guildStates, (a0) => {
const _pendingRequests = a0._pendingRequests;
if (_pendingRequests.has(c14546_0)) {
c14546_1.push(a0._guildId);
}
if (a0._unacknowledgedRequests.has(c14546_0)) {
c14546_2.push(a0._guildId);
}
if (a0._sentRequests.has(c14546_0)) {
c14546_3.push(a0._guildId);
}
});
return {
pendingRequestGuildIds,
unacknowledgedRequestGuildIds,
sentRequestGuildIds
};
}
}
export default GuildMemberRequester;
+110
View File
@@ -0,0 +1,110 @@
// Metro module 6057 (f6058).
import Durations from "../../utils/Durations";
import { DelayedCall } from "../../_bundle/Timeout";
import SnowflakeUtils from "../../utils/SnowflakeUtils";
import Logger from "../../modules/debug/Logger";
import Module12 from "../../_bundle/Module12";
let c3840_3 = 1 * Durations.Millis.MINUTE;
class GuildMemberSubscriptions {
_subscriptions = {};
_unsubscriptions = {};
_unsubscribe = new DelayedCall(c3840_3, () => this.flushUnsubscriptions());
constructor(a0) {
this._onChange = a0;
}
reset() {
this._subscriptions = {};
this._unsubscriptions = {};
this._unsubscribe.cancel();
}
get(a0) {
let r3 = this._subscriptions[a0];
if (r3 == null) {
r3 = {};
}
return SnowflakeUtils.keys(r3);
}
clear(a0) {
delete this._subscriptions[a0];
delete this._unsubscriptions[a0];
}
subscribe(a0, a1) {
let r7 = this._subscriptions[a0];
if (r7 == null) {
r7 = {};
}
let r6 = r7[a1];
if (r6 == null) {
r6 = 0;
}
r7[a1] = r6 + 1;
this._subscriptions[a0] = r7;
if (r7[a1] === 1) {
this._onChange(a0, this.get(a0));
}
this.checkForLeaks(a0, a1);
}
isSubscribed(a0, a1) {
return this._subscriptions[a0] != null && this._subscriptions[a0][a1] != null;
}
isSubscribedToAnyMember(a0) {
return this.get(a0).length > 0;
}
unsubscribe(a0, a1) {
if (this.isSubscribed(a0, a1)) {
let r9 = this._unsubscriptions[a0];
if (r9 == null) {
r9 = {};
}
let r5 = r9[a1];
if (r5 == null) {
r5 = 0;
}
r9[a1] = r5 + 1;
this._unsubscriptions[a0] = r9;
if (r9[a1] === 1) {
this._unsubscribe.delay(false);
}
}
}
checkForLeaks(a0, a1) {
const r8 = this._subscriptions[a0];
let r13 = r8 == null ? void 0 : r8[a1];
if (r13 == null) {
r13 = 0;
}
const r15 = this._unsubscriptions[a0];
let r17 = r15 == null ? void 0 : r15[a1];
if (r17 == null) {
r17 = 0;
}
const r9 = r13 - r17;
if (r9 > 5) {
new Logger("GuildMemberSubscriptions").warn(`GuildMemberSubscriptions.subscribe(...): Potential reference leak! (${r9} subscriptions)`);
}
}
flushUnsubscriptions() {
if (!Module12.isEmpty(this._unsubscriptions)) {
Module12.forEach(this._unsubscriptions, (a0, a1) => {
const r6 = this._subscriptions[a1];
let c25688_0 = r6;
Module12.forEach(a0, (a0, a1) => {
let r5 = c25688_0[a1];
if (r5 == null) {
r5 = 0;
}
c25688_0[a1] = r5 - a0;
if (c25688_0[a1] <= 0) {
delete c25688_0[a1];
}
});
if (Module12.isEmpty(r6)) {
delete this._subscriptions[a1];
}
this._onChange(a1, this.get(a1));
});
this._unsubscriptions = {};
}
}
}
export default GuildMemberSubscriptions;
+162
View File
@@ -0,0 +1,162 @@
// Metro module 6056 (f6057).
import { ME } from "../../Constants";
import { isFavoritesGuildId } from "../../modules/favorites/FavoritesUtils";
import GuildMemberSubscriptions from "./GuildMemberSubscriptions";
import * as _GuildChannelSubscriptions from "./GuildChannelSubscriptions";
import GuildChannelSubscriptions from "./GuildChannelSubscriptions";
import GuildThreadSubscriptions from "./GuildThreadSubscriptions";
import { DelayedCall } from "../../_bundle/Timeout";
import Module12 from "../../_bundle/Module12";
class GuildSubscriptions {
_members = new GuildMemberSubscriptions((a0, a1) => this._enqueue(a0, {
members: a1
}));
_channels = new GuildChannelSubscriptions((a0, a1) => this._enqueue(a0, {
channels: a1
}));
_threadMemberLists = new GuildThreadSubscriptions((a0, a1) => this._enqueue(a0, {
thread_member_lists: a1
}));
_typing = new Set();
_threads = new Set();
_activities = new Set();
_memberUpdates = new Set();
_subscribed = new Set();
_pending = {};
_flush = new DelayedCall(0, () => this.flush());
constructor(a0) {
this._onChange = a0;
}
_enqueue(a0, a1) {
this._pending[a0] = {
...this._pending[a0],
...a1
};
this._flush.delay();
}
reset() {
this._subscribed.clear();
this._pending = {};
this._members.reset();
this._memberUpdates.clear();
this._channels.reset();
this._threadMemberLists.reset();
this._typing.clear();
this._threads.clear();
this._activities.clear();
}
get(a0) {
return {
typing: this._typing.has(a0),
threads: this._threads.has(a0),
activities: this._activities.has(a0),
members: this._members.get(a0),
member_updates: this._memberUpdates.has(a0),
channels: this._channels.get(a0),
thread_member_lists: this._threadMemberLists.get(a0)
};
}
getSubscribedThreadIds() {
return this._threadMemberLists.getSubscribedThreadIds();
}
isSubscribedToThreads(a0) {
return this._threads.has(a0);
}
isSubscribedToAnyMember(a0) {
let r5 = this._members.isSubscribedToAnyMember(a0);
if (r5 == null) {
r5 = false;
}
return r5;
}
isSubscribedToMemberUpdates(a0) {
let member_updates = this.get(a0).member_updates;
if (member_updates == null) {
member_updates = false;
}
return member_updates;
}
forEach(a0) {
this._subscribed.forEach(a0);
}
clearWithoutFlushing(a0, a1) {
if (!(a1 ? !a1 : this._threads.has(a0))) {
this._subscribed.delete(a0);
}
delete this._pending[a0];
this._members.clear(a0);
this._channels.clear(a0);
this._threadMemberLists.clear(a0);
this._typing.delete(a0);
this._memberUpdates.delete(a0);
if (a1) {
this._threads.delete(a0);
}
this._activities.delete(a0);
}
flush() {
Module12.forEach(this._pending, (a0, a1) => {
this._subscribed.add(a1);
});
this._onChange(this._pending);
this._pending = {};
}
subscribeUser(a0, a1) {
if (a0 != null && a0 !== "null" && a0 !== ME && a0 !== "undefined" && !isFavoritesGuildId(a0)) {
this._members.subscribe(a0, a1);
}
}
unsubscribeUser(a0, a1) {
if (a0 != null && a0 !== "null" && a0 !== ME && a0 !== "undefined" && !isFavoritesGuildId(a0)) {
this._members.unsubscribe(a0, a1);
}
}
subscribeChannel(a0, a1, a2) {
return !!(a0 != null && a0 !== "null" && a0 !== ME && a0 !== "undefined" && !isFavoritesGuildId(a0)) && this._channels.subscribe(a0, a1, a2);
}
subscribeToMemberUpdates(a0) {
if (a0 != null && a0 !== "null" && a0 !== ME && a0 !== "undefined" && !isFavoritesGuildId(a0)) {
this._enqueue(a0, {
member_updates: true
});
this._memberUpdates.add(a0);
return void 0;
}
return false;
}
unsubscribeFromMemberUpdates(a0) {
if (a0 != null && a0 !== "null" && a0 !== ME && a0 !== "undefined" && !isFavoritesGuildId(a0)) {
this._enqueue(a0, {
member_updates: false
});
return void 0;
}
return false;
}
subscribeThreadMemberList(a0, a1, a2) {
return !!(a0 != null && a0 !== "null" && a0 !== ME && a0 !== "undefined" && !isFavoritesGuildId(a0)) && this._threadMemberLists.subscribe(a0, a1, a2);
}
unsubscribeThreadMemberList(a0, a1) {
return !!(a0 != null && a0 !== "null" && a0 !== ME && a0 !== "undefined" && !isFavoritesGuildId(a0)) && this._threadMemberLists.unsubscribe(a0, a1);
}
subscribeToGuild(a0) {
this._subscribeToFeature(a0, this._typing, {
typing: true
});
this._subscribeToFeature(a0, this._activities, {
activities: true
});
this._subscribeToFeature(a0, this._threads, {
threads: true
});
}
_subscribeToFeature(a0, a1, a2) {
if (a0 != null && a0 !== "null" && a0 !== ME && a0 !== "undefined" && !isFavoritesGuildId(a0) && !a1.has(a0)) {
a1.add(a0);
this._enqueue(a0, a2);
}
}
}
export default GuildSubscriptions;
export const MINIMUM_RANGE = _GuildChannelSubscriptions.MINIMUM_RANGE;
export const DEFAULT_RANGES = _GuildChannelSubscriptions.DEFAULT_RANGES;
+75
View File
@@ -0,0 +1,75 @@
// Metro module 6059 (f6060).
import LRUCache from "../../_bundle/LRUCache";
class GuildThreadSubscriptions {
constructor(a0) {
const r3 = {
__proto__: new.target.prototype,
_subscriptions: {}
};
r3._onChange = a0;
return r3;
}
reset() {
this._subscriptions = {};
}
get(a0) {
return this._get(a0).keys();
}
getSubscribedThreadIds() {
const set = new Set();
const _subscriptions = this._subscriptions;
for (const key in _subscriptions) {
for (const item of this._subscriptions[key].keys()) {
set.add(item);
}
}
return set;
}
_get(a0) {
let r8 = this._subscriptions[a0];
if (r8 == null) {
r8 = new LRUCache({
max: 3,
updateAgeOnGet: true
});
}
return r8;
}
clear(a0) {
if (a0 in this._subscriptions) {
delete this._subscriptions[a0];
this._onChange(a0, []);
}
}
subscribe(a0, a1, a2) {
let r29;
const r4 = this._get(a0);
if (r4.has(a1)) {
r4.set(a1, Date.now());
r29 = false;
} else {
if (a2 != null && r4.has(a2)) {
r4.set(a2, Date.now());
}
r4.set(a1, Date.now());
this._subscriptions[a0] = r4;
this._onChange(a0, r4.keys());
r29 = true;
}
return r29;
}
unsubscribe(a0, a1) {
if (a0 in this._subscriptions) {
const r6 = this._subscriptions[a0];
let r12 = !!r6.has(a1);
if (r12) {
r6.del(a1);
this._onChange(a0, r6.keys());
r12 = true;
}
return r12;
}
return false;
}
}
export default GuildThreadSubscriptions;
+100
View File
@@ -0,0 +1,100 @@
// Metro module 6070 (f6071).
import _objectWithoutProperties from "../../_bundle/_objectWithoutProperties";
import * as Module19 from "react";
import { forwardRef, useEffect } from "react";
import Module12 from "../../_bundle/Module12";
import { subscribeMembers, unsubscribeMembers } from "../../actions/GuildSubscriptionsActionCreators";
import shallowEqual from "../../_bundle/shallowEqual";
import SentryUtils_native from "../../utils/SentryUtils.native";
import { $callWithNewTarget, $deriveClass } from "../../_hermes/prelude";
const _excluded = ["forwardedRef"];
let c3850_7 = false;
export default function subscribeGuildMembers(c15456_0) {
return (a0) => {
let Component3, c25692_2;
let Component2 = a0;
let displayName = a0.displayName;
if (displayName == null) {
displayName = a0.name;
}
if (displayName == null) {
displayName = "Component";
}
const displayName2 = `SubscribeGuildMembersContainer(${displayName})`;
const r16 = $deriveClass(function WrappedComponent(a0) {
const r4 = new.target;
const prototypeOf = Object.getPrototypeOf(c25692_2);
const r2 = Object.create(r4.prototype);
const r11 = $callWithNewTarget(prototypeOf, r2, r4, a0);
const r12 = r11 instanceof Object ? r11 : r2;
const _subscriptions = c15456_0(a0);
Module12.forEach(_subscriptions, (a0, a1) => subscribeMembers(a1, a0));
r12._subscriptions = _subscriptions;
return r12;
}, Module19.Component);
const prototype = r16.prototype;
Object.defineProperty(prototype, "componentDidUpdate", {
value: function componentDidUpdate(a0) {
if (!shallowEqual(this.props, a0)) {
const _subscriptions = c15456_0(this.props);
if (!(this._subscriptions != null && Module12.isEqual(this._subscriptions, _subscriptions))) {
if (this._subscriptions != null) {
Module12.forEach(this._subscriptions, (a0, a1) => unsubscribeMembers(a1, a0));
}
Module12.forEach(_subscriptions, (a0, a1) => subscribeMembers(a1, a0));
this._subscriptions = _subscriptions;
}
}
},
writable: true,
configurable: true
});
Object.defineProperty(prototype, "componentWillUnmount", {
value: function componentWillUnmount() {
if (this._subscriptions != null) {
Module12.forEach(this._subscriptions, (a0, a1) => unsubscribeMembers(a1, a0));
}
},
writable: true,
configurable: true
});
Object.defineProperty(prototype, "render", {
value: function render() {
const props = this.props;
return <Component2 ref={props.forwardedRef} {..._objectWithoutProperties(props, _excluded)} />;
},
writable: true,
configurable: true
});
c25692_2 = r16;
r16.displayName = displayName2;
Component3 = r16;
const r24 = forwardRef((a0, a1) => <Component3 {...a0} forwardedRef={a1} />);
r24.displayName = `ForwardRef(${displayName2})`;
return r24;
};
};
export const MAX_GUILD_MEMBER_SUBSCRIPTIONS = 50;
export function useSubscribeGuildMembers(a0, a1) {
let c15457_0 = a0;
const reason = a1;
useEffect(() => {
Module12.forEach(c15457_0, (a0, a1) => {
const r2 = c3850_7;
if (r2 ? !r2 : a0.length > 50) {
c3850_7 = true;
SentryUtils_native.captureMessage("SubscribeGuildMembers called with more than 50 userIds.", {
extra: {
count: a0.length,
guildId: a1,
reason
}
});
}
subscribeMembers(a1, a0);
});
return () => {
Module12.forEach(c15457_0, (a0, a1) => unsubscribeMembers(a1, a0));
};
}, [a0, a1]);
}
+13
View File
@@ -0,0 +1,13 @@
// Metro module 12893 (f12894).
export function isHookModuleTooOld() {
return true;
}
export function attachToProcess() {
return Promise.resolve();
}
export function cancelAttachToProcess() {
return Promise.resolve();
}
export function findSteamProcess() {
return Promise.resolve(null);
}
+12
View File
@@ -0,0 +1,12 @@
// Metro module 4237 (f4238).
import { inject } from "../_bundle/Module4238";
import * as _VoiceConnection from "../_bundle/VoiceConnection";
inject({
supported: () => true,
supportsFeature: function supportsFeature(a0) {
return this.getVoiceEngine().supportsFeature(a0);
},
setProcessPriority: () => {},
getVoiceEngine: () => _VoiceConnection.default,
getOpenH264LibraryPath: () => {}
});
+52
View File
@@ -0,0 +1,52 @@
// Metro module 3879 (f3880).
import LocaleStore from "../modules/user_settings/LocaleStore";
import * as _SystemDateFormatter_native from "../modules/system_date_format/SystemDateFormatter.native";
import { systemLocale, initialLocale } from "../intl/index.native";
const makeIntlFormatter = function makeIntlFormatter(locale, a1) {
let format;
try {
format = Intl.DateTimeFormat(locale, a1).format;
} catch ($e) {
return Intl.DateTimeFormat(void 0, a1).format;
}
return format;
};
export function makeFormatter(a0) {
let r7 = (function tryMakeNativeFormatter(a0, a1) {
let c24873_2, c24873_3;
let c24873_0 = a0;
if (_SystemDateFormatter_native.makeFormatter == null) {
return null;
}
L11: {
try {
const r17 = a0 != null && a0.split("-")[0] === (systemLocale == null ? void 0 : systemLocale.split("-")[0]);
const r32 = _SystemDateFormatter_native.makeFormatter(a0 === initialLocale ? r17 ? void 0 : a0 : a0, a1);
c24873_2 = r32;
if (r32 == null) {
break L11;
}
c24873_3 = null;
} catch ($e) {
return null;
}
return function(a0) {
let r6;
try {
r6 = c24873_2(a0);
} catch ($e) {
if (c24873_3 == null) {
c24873_3 = makeIntlFormatter(c24873_0, a1);
}
return c24873_3(a0);
}
return r6;
};
}
return null;
})(LocaleStore.locale, a0);
if (r7 == null) {
r7 = makeIntlFormatter(LocaleStore.locale, a0);
}
return r7;
}
File diff suppressed because it is too large. Load diff
+131
View File
@@ -0,0 +1,131 @@
// Metro module 10982 (f10983).
import * as _Module17 from "react-native";
import { AnalyticEvents } from "../../Constants";
import Logger from "../../modules/debug/Logger";
import { isIOS } from "../../utils/PlatformUtils";
import { match } from "../../_bundle/Module4389";
import AnalyticsUtils from "../../utils/AnalyticsUtils";
import MonitoringAgent from "../../modules/monitoring/MonitoringAgent";
function $mk116085($env) {
return (a0) => {
if (a0.isLoadedFromFileSystem()) {
const r4 = a0.scaledAssetURLNearBundle();
const uri = BundleUpdaterManager.resolvedOTAAssetURI(r4.uri);
return uri !== r4.uri ? {
...r4,
uri
} : null;
}
return null;
};
}
let c7397_9;
let env7397 = {};
const { NativeModules, NativeEventEmitter } = _Module17;
const c7397_5 = new Logger("BundleUpdater");
const BundleUpdaterManager = NativeModules.BundleUpdaterManager;
const c7397_7 = new NativeEventEmitter(BundleUpdaterManager);
const c7397_8 = {
downloaded: "BundleDownloaded",
otaUpdateChecked: "OtaUpdateChecked"
};
c7397_9 = void 0;
class BundleUpdater {
constructor() {
return {
__proto__: new.target.prototype
};
}
static getInitialBundleDownloaded() {
return BundleUpdaterManager.getInitialBundleDownloaded();
}
static getInitialOtaUpdateChecked() {
return BundleUpdaterManager.getInitialOtaUpdateChecked();
}
static addEventListener(a0, a1) {
c7397_7.addListener(c7397_8[a0], a1);
}
static checkForUpdateAndReload() {
BundleUpdaterManager.checkForUpdateAndReload();
}
static verifyOtaFiles() {
return BundleUpdaterManager.verifyOtaFiles();
}
static getBuildOverrideCookieContents() {
return BundleUpdaterManager.getBuildOverrideCookieContents();
}
static setBuildOverrideCookieHeader(a0) {
return BundleUpdaterManager.setBuildOverrideCookieHeader(a0);
}
static getOtaRootPath() {
return BundleUpdaterManager.getOtaRootPath();
}
static getOtaStatus() {
return BundleUpdaterManager.getOtaStatus();
}
static getManifestInfo() {
return BundleUpdaterManager.getManifestInfo();
}
static async setupOTAAssetFallback() {
let default2, c26895_1;
L15: {
let env30325;
const r10 = env30325 = {
$parent: env7397
};
c26895_1 = r10;
env30325[0] = void 0;
if (isIOS()) {
env30325[0] = await import("../../_bundle/resolveAssetSource");
const default3 = env30325[0].default;
default2 = default3;
if (default3 == null) {
default2 = env30325[0];
}
default2.addCustomSourceTransformer($mk116085(env7397));
break L15;
}
return void 0;
}
}
static emitOtaMetric(a0) {
match(a0).with({
type: "OtaCheckAttempt"
}, (a0) => {
c7397_5.verbose("OTA check attempt", a0);
AnalyticsUtils.track(AnalyticEvents.MOBILE_OTA_CHECK_ATTEMPT, {
result: a0.result,
duration_seconds: a0.durationSeconds,
bytes_received: a0.bytesReceived,
error: a0.error,
used_streaming: a0.usedStreaming
});
return MonitoringAgent.increment(c7397_9.prepareOtaMetricForDatadog(a0, ["result"]));
}).with({
type: "OtaAssetDownloadAttempt"
}, (a0) => {
c7397_5.verbose("OTA asset download attempt", a0);
AnalyticsUtils.track(AnalyticEvents.MOBILE_OTA_ASSET_DOWNLOAD_ATTEMPT, {
result: a0.result,
duration_seconds: a0.durationSeconds,
error: a0.error,
url: a0.url,
status_code: a0.statusCode,
bytes_received: a0.bytesReceived
});
return MonitoringAgent.increment(c7397_9.prepareOtaMetricForDatadog(a0, ["result", "statusCode"]));
}).exhaustive();
}
static prepareOtaMetricForDatadog(a0) {
let r4 = arguments[1];
if (r4 === void 0) {
r4 = [];
}
return {
name: a0.type,
tags: r4.map((item) => `${item}:${a0[item]}`)
};
}
}
c7397_9 = BundleUpdater;
export default BundleUpdater;
File diff suppressed because it is too large. Load diff
+19
View File
@@ -0,0 +1,19 @@
// Metro module 3886 (f3887).
import { Linking } from "react-native";
import * as _handleURL from "../../modules/links/native/handleURL";
const r15 = {
openURL: function openURL(a0, a1, allowExternal = true) {
(0, _handleURL.default)(a0, a1, {
allowExternal
});
},
openURLExternally: (a0, a1) => {
(0, _handleURL.default)(a0, a1, {
forceExternalBrowser: true
});
},
performURLNavigation: (a0) => {
Linking.openURL(a0).catch(() => {});
}
};
export default r15;
+11
View File
@@ -0,0 +1,11 @@
// Metro module 3880 (f3881).
import * as _handleURL from "../modules/links/native/handleURL";
export default async function openURL(c24874_0, c24874_1) {
let c29235_0 = c24874_0;
let c29235_1 = c24874_1;
(0, _handleURL.default)(c24874_0);
(0, (await import("./getOnClick")).default)(c29235_0, {
skipExtensionCheck: c29235_1,
analyticsLocations: []
});
};
+270
View File
@@ -0,0 +1,270 @@
// Metro module 10694 (f10695).
import { NativeModules, NativeEventEmitter } from "react-native";
import * as _PlatformUtils from "../../utils/PlatformUtils";
import PushNotificationIOS from "../../_bundle/PushNotificationIOS_10695";
import * as _Module10351 from "../../_bundle/Module10351";
import openNotificationSettings_native from "../../modules/native_permissions/mobile/openNotificationSettings.native";
import { HermesBuiltin } from "../../_hermes/prelude";
function $mk85340($env) {
return () => {
const r1 = {};
const r3 = $env[0];
HermesBuiltin.copyDataProperties(r1, r3);
r1.message = r3.message != null ? JSON.parse(r3.message) : null;
return r1;
};
}
function $mk85341() {
return () => {
throw new Error("TODO: Implement on Android");
};
}
function $mk85342() {
return () => {
throw new Error("TODO: Implement on Android");
};
}
function $mk85343() {
return () => {
throw new Error("TODO: Implement on Android");
};
}
function $mk85344() {
return () => {
throw new Error("TODO: Implement on Android");
};
}
function $mk85345() {
return () => {
throw new Error("TODO: Implement on Android");
};
}
function $mk85346() {
return () => {
throw new Error("TODO: Implement on Android");
};
}
function $mk85347() {
return (a0) => {
throw new Error(`Not implemented on Android: ${a0}`);
};
}
const PushNotificationAndroid = NativeModules.PushNotificationAndroid;
let c7188_5 = PushNotificationAndroid != null ? new NativeEventEmitter(NativeModules.PushNotificationAndroid) : null;
const r26 = {
getInitialNotification: () => _PlatformUtils.isAndroid() ? new Promise((c26796_0) => {
PushNotificationAndroid.getInitialNotification().then((result) => {
let env30284;
const r4 = env30284 = {};
env30284[0] = result;
c26796_0(result != null ? {
getData: $mk85340(r4),
getMessage: $mk85341(),
getSound: $mk85342(),
getCategory: $mk85343(),
getAlert: $mk85344(),
getContentAvailable: $mk85345(),
getBadgeCount: $mk85346(),
finish: $mk85347()
} : null);
});
}) : PushNotificationIOS.getInitialNotification(),
setCurrentUser: (a0, a1) => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.setCurrentUser(a0, a1);
}
},
setMultiAccountUsers: (a0) => {
const r7 = JSON.stringify(a0);
if (_PlatformUtils.isAndroid()) {
if (PushNotificationAndroid != null) {
const setMultiAccountUsernames = PushNotificationAndroid.setMultiAccountUsernames;
if (setMultiAccountUsernames != null) {
setMultiAccountUsernames.call(PushNotificationAndroid, r7);
}
}
} else {
const NSUserDefaultsBridge = NativeModules.NSUserDefaultsBridge;
if (NSUserDefaultsBridge != null) {
const setMultiAccountUsersJSONString = NSUserDefaultsBridge.setMultiAccountUsersJSONString;
if (setMultiAccountUsersJSONString != null) {
setMultiAccountUsersJSONString.call(NSUserDefaultsBridge, r7);
}
}
}
},
clearPushNotificationLogs: () => {
if (_PlatformUtils.isAndroid()) {
_Module10351.default.clearLogs();
}
},
setApplicationIconBadgeNumber: (a0) => {
if (!_PlatformUtils.isAndroid()) {
PushNotificationIOS.setApplicationIconBadgeNumber(a0);
}
},
clearAllNotifications: () => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.clearAllNotifications();
} else {
PushNotificationIOS.setApplicationIconBadgeNumber(0);
}
},
presentLocalNotification: (a0) => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.presentLocalNotification(a0);
} else {
PushNotificationIOS.presentLocalNotification(a0);
}
},
getDeliveredNotifications: () => {
const isAndroid = _PlatformUtils.isAndroid();
const r4 = Promise;
return isAndroid ? r4.resolve([]) : new r4((a0) => {
PushNotificationIOS.getDeliveredNotifications(a0);
});
},
removeDeliveredNotifications: (a0) => {
if (!_PlatformUtils.isAndroid()) {
PushNotificationIOS.removeDeliveredNotifications(a0);
}
},
scheduleLocalNotification: (a0) => {
if (!_PlatformUtils.isAndroid()) {
PushNotificationIOS.scheduleLocalNotification(a0);
}
},
getScheduledLocalNotifications: (a0) => {
if (!_PlatformUtils.isAndroid()) {
PushNotificationIOS.getScheduledLocalNotifications(a0);
}
},
cancelLocalNotifications: (a0) => {
if (!_PlatformUtils.isAndroid()) {
PushNotificationIOS.cancelLocalNotifications(a0);
}
},
cancelAllLocalNotifications: () => {
if (!_PlatformUtils.isAndroid()) {
PushNotificationIOS.cancelAllLocalNotifications();
}
},
checkPermissions: (a0) => {
if (_PlatformUtils.isAndroid()) {
a0({});
} else {
PushNotificationIOS.checkPermissions(a0);
}
},
requestPermissions: (a0) => _PlatformUtils.isAndroid() ? new Promise((resolve) => resolve({})) : PushNotificationIOS.requestPermissions(a0),
openNotificationSettings: () => {
openNotificationSettings_native();
},
addNotificationEventListener: (a0, a1) => {
if (_PlatformUtils.isAndroid()) {
if (a0 === "notification") {
c7188_5.addListener("notification", (a0) => {
let env26797;
const r4 = env26797 = {};
env26797[0] = a0;
const r3 = a0 == null ? null : {
getData: $mk85340(r4),
getMessage: $mk85341(),
getSound: $mk85342(),
getCategory: $mk85343(),
getAlert: $mk85344(),
getContentAvailable: $mk85345(),
getBadgeCount: $mk85346(),
finish: $mk85347()
};
if (r3 != null) {
a1(r3);
}
});
}
if (a0 === "localNotification") {
c7188_5.addListener("localNotification", (a0) => {
let env26798;
const r4 = env26798 = {};
env26798[0] = a0;
const r3 = a0 == null ? null : {
getData: $mk85340(r4),
getMessage: $mk85341(),
getSound: $mk85342(),
getCategory: $mk85343(),
getAlert: $mk85344(),
getContentAvailable: $mk85345(),
getBadgeCount: $mk85346(),
finish: $mk85347()
};
if (r3 != null) {
a1(r3);
}
});
}
PushNotificationAndroid.registerEventListener(a0);
} else {
PushNotificationIOS.addEventListener(a0, a1);
}
},
addRegisterEventListener: (a0) => {
let c18203_0 = a0;
if (_PlatformUtils.isAndroid()) {
c7188_5.addListener("register", (a0) => {
c18203_0(a0.token);
});
PushNotificationAndroid.registerEventListener("register");
} else {
PushNotificationIOS.addEventListener("register", a0);
}
},
getSoundsEnabled: () => new Promise((resolve) => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.getSoundsEnabled().then((result) => resolve(result));
} else {
resolve(false);
}
}),
getVibrationsEnabled: () => new Promise((resolve) => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.getVibrationsEnabled().then((result) => resolve(result));
} else {
resolve(false);
}
}),
getLightsEnabled: () => new Promise((resolve) => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.getLightsEnabled().then((result) => resolve(result));
} else {
resolve(false);
}
}),
setSoundsEnabled: (a0) => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.setSoundsEnabled(a0);
}
},
setVibrationsEnabled: (a0) => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.setVibrationsEnabled(a0);
}
},
setLightsEnabled: (a0) => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.setLightsEnabled(a0);
}
},
setAndroidNotifyEveryTime: (a0) => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.setNotifyEveryTime(a0);
}
},
shouldAndroidNotifyEveryTime: () => new Promise((resolve) => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.shouldNotifyEveryTime().then((result) => resolve(result));
} else {
resolve(false);
}
})
};
export default r26;
+39
View File
@@ -0,0 +1,39 @@
// Metro module 12733 (f12734).
export default function rateLimit(c19990_0, c19990_1, c19990_2) {
let c19990_3;
let c19990_4 = [];
const wrapper2 = function wrapper(...args) {
let r25;
let c27354_0 = args;
const r14 = Date.now();
if (c19990_3 != null) {
clearTimeout(c19990_3);
c19990_3 = null;
}
const length = c19990_4.length;
let r19 = c19990_4;
if (length > 0) {
const r20 = c19990_4[0];
r19 = c19990_4;
if (r20 <= r14) {
do {
c19990_4.shift();
const length2 = c19990_4.length;
r19 = c19990_4;
if (!(length2 > 0)) {
break;
}
r25 = c19990_4[0];
r19 = c19990_4;
} while (r25 <= r14);
}
}
if (r19.length < c19990_0) {
r19.push(r14 + c19990_1);
c19990_2.apply(void 0, [...args]);
} else {
c19990_3 = setTimeout(() => wrapper2.apply(void 0, [...c27354_0]), r19[0] - r14);
}
};
return wrapper2;
};
+116
View File
@@ -0,0 +1,116 @@
// Metro module 15547 (f15548).
import Module12 from "../../_bundle/Module12";
import { snowballStem } from "./snowballStemmer";
import { SEARCH_PARTIAL_NAME_MATCH_MIN_QUERY_LENGTH, SEARCH_PARTIAL_NAME_MATCH_MAX_QUERY_LENGTH } from "../../_bundle/Module15550";
let c11074_3, lowercase, isStopWord, isBlank, shouldHighlight, highlightAST;
const stripPossessive = function stripPossessive(a0) {
return a0.replace(/('|\u2019|\uFF07)(s|S)$/, "");
};
lowercase = function lowercase(a0) {
return a0.toLowerCase();
};
isStopWord = function isStopWord(a0) {
return c11074_3.has(a0);
};
isBlank = function isBlank(a0) {
return a0.length === 0;
};
shouldHighlight = function shouldHighlight(a0, a1, r0 = false) {
const r19 = lowercase(stripPossessive(a0));
if (isBlank(r19)) {
return false;
}
if (isStopWord(r19)) {
return false;
}
const r29 = snowballStem(r19);
if (!r0) {
return a1.has(r29);
}
for (const item of a1.values()) {
if (!r29.includes(item)) {
continue;
}
return true;
}
return false;
};
highlightAST = function highlightAST(a0, a1, a2) {
let c22142_0, c22142_1, c22142_2, content;
L14: {
c22142_0 = a1;
c22142_1 = a2;
if (Array.isArray(a0)) {
a0.forEach((item) => {
highlightAST(item, c22142_0, c22142_1);
return item;
});
} else if (a0.type === "list") {
a0.items.forEach((item) => {
highlightAST(item, c22142_0, c22142_1);
return item;
});
} else {
if (typeof a0.content === "string" && a0.type !== "codeBlock") {
const content2 = [];
c22142_2 = content2;
content = "";
a0.content.split(/(\W+)/g).forEach((item) => {
const shouldHighlight2 = shouldHighlight(item, c22142_0, c22142_1);
if (shouldHighlight2) {
if (content.length > 0) {
c22142_2.push({
type: "text",
content
});
}
c22142_2.push({
type: "highlight",
content: item
});
content = "";
} else {
content = content + item;
}
});
if (!(content2.length > 0)) {
break L14;
}
if (content.length > 0) {
content2.push({
type: "text",
content
});
}
if (a0.type === "text") {
a0.content = content2;
break L14;
}
a0.content = [{
type: "text",
content: content2
}];
break L14;
}
if (a0.content != null) {
highlightAST(a0.content, a1, a2);
}
}
}
return a0;
};
c11074_3 = new Set(["a", "an", "and", "are", "as", "at", "be", "but", "by", "for", "if", "in", "into", "is", "it", "no", "not", "of", "on", "or", "such", "that", "the", "their", "then", "there", "these", "they", "this", "to", "was", "will", "with"]);
export function analyze(a0) {
return Module12(a0.split(/\W+/)).map(stripPossessive).reject(isBlank).map(lowercase).reject(isStopWord).map(snowballStem).value();
}
export { shouldHighlight };
export { highlightAST };
export function createASTHighlighter(a0, r4 = false) {
let c22143_0 = r4;
let c22143_1 = a0.length >= SEARCH_PARTIAL_NAME_MATCH_MIN_QUERY_LENGTH && a0.length <= SEARCH_PARTIAL_NAME_MATCH_MAX_QUERY_LENGTH;
let c22143_2 = new Set(Module12(a0.split(/\W+/)).map(stripPossessive).reject(isBlank).map(lowercase).reject(isStopWord).map(snowballStem).value());
return (a0) => {
highlightAST(a0, c22143_2, c22143_1 && c22143_0);
return a0;
};
}
+6
View File
@@ -0,0 +1,6 @@
// Metro module 15548 (f15549).
import { newStemmer } from "../../_bundle/Module15549";
let c11075_0 = newStemmer("english");
export function snowballStem(a0) {
return c11075_0.stem(a0);
}
+82
View File
@@ -0,0 +1,82 @@
// Metro module 5196 (f5197).
import DesktopNativeUtils from "../../utils/web/DesktopNativeUtils";
class LanguageDetector {
constructor(a0, a1) {
const r5 = {
__proto__: new.target.prototype,
_shouldProcess: false,
_processing: false,
_minimumTimeRemaining: 5
};
r5._language = a0;
r5._languageHint = a0;
r5._onChange = a1;
a1(a0);
return r5;
}
get language() {
return this._language;
}
set language(a0) {
if (this._language !== a0) {
this._language = a0;
this._onChange(a0);
}
}
set languageHint(a0) {
this._languageHint = a0;
}
process(c14724_0) {
if (!this._processing) {
this._processing = true;
requestIdleCallback((a0) => {
let c25380_0 = a0;
const r7 = a0.timeRemaining();
if (r7 <= this._minimumTimeRemaining) {
this._processEnd();
} else {
if (c14724_0.length > 256) {
c14724_0 = c14724_0.slice(0, 256);
}
const r8 = c14724_0;
const _languageHint2 = this._languageHint;
let c25381_0 = r8;
const _languageHint = _languageHint2;
DesktopNativeUtils.ensureModule("discord_spellcheck").then(() => {
const cld = DesktopNativeUtils.requireModule("discord_spellcheck").cld;
return new Promise((c31934_0, c31934_1) => {
cld.detect(c25381_0, {
httpHint: _languageHint,
encodingHint: "UTF8"
}, (a0, a1) => {
L7: {
if (a0 != null) {
c31934_1(new Error(a0.message));
} else {
if (a1.reliable && !(a1.languages[0].percent < 90) && !(a1.languages[0].score < 500)) {
c31934_0(a1.languages[0].code);
break L7;
}
c31934_1(new Error("Not enough reliable text."));
}
}
});
});
}).then((result) => {
this.language = result;
this._processEnd(c25380_0.didTimeout);
}, () => {
this._processEnd(c25380_0.didTimeout);
});
}
});
}
}
_processEnd(r2 = false) {
this._processing = false;
if (r2) {
this._minimumTimeRemaining = this._minimumTimeRemaining + 1;
}
}
}
export default LanguageDetector;
+180
View File
@@ -0,0 +1,180 @@
// Metro module 5193 (f5194).
import _slicedToArray from "../../_bundle/_slicedToArray";
import LocaleStore from "../../modules/user_settings/LocaleStore";
import Logger from "../../modules/debug/Logger";
import DiscordNative from "../DiscordNative";
import fallbackLocales from "./fallbackLocales";
import { parse } from "../../_bundle/Module5195";
import LanguageDetector from "./LanguageDetector";
import Module12 from "../../_bundle/Module12";
import * as _Module1859 from "../../_bundle/Module1859";
import { isNotNullish } from "../../utils/GlobalUtils";
function $mk114669($env) {
return function attachToInput(a0) {
let env31364 = {
$parent: $env
};
env31364[0] = a0;
if (document.body != null) {
document.body.addEventListener("beforeinput", (a0) => (0, env31364.$parent[10])(env31364[0], a0.target), true);
}
};
}
let c3137_6, c3137_7, c3137_10;
let env3137 = {};
const normalizeLocale = function normalizeLocale(a0) {
let r11 = fallbackLocales[a0];
if (r11 == null) {
r11 = a0;
}
const r18 = parse(r11.replace(/[_-]/g, "-"));
const r9 = r11;
if (r18 != null && r18.langtag.language != null && r18.langtag.region != null) {
const langtag = r18.langtag;
const { language, region } = langtag;
return `${language.language.toLowerCase()}-${region.toUpperCase()}`;
}
c3137_6.error(`${r9} is not a valid locale.`);
};
c3137_6 = new Logger("Spellchecker");
c3137_7 = DiscordNative?.spellCheck;
export class Spellchecker {
constructor(a0) {
let c14721_0 = a0;
this._enabled = true;
this.misspelledWord = "";
this.corrections = [];
const r20 = _slicedToArray(LocaleStore.locale.split("-"), 2);
const r21 = r20[0];
let c14721_1 = r21;
this.regionPreference = r20[1];
const availableLanguages = this.getAvailableLanguages(a0);
this.languageDetector = new LanguageDetector(r21, (a0) => {
const r12 = `${a0}-${this.regionPreference}`;
if (c14721_0.indexOf(r12) !== -1) {
this.setLocale(r12);
} else {
let r17 = availableLanguages[a0];
if (r17 == null) {
r17 = fallbackLocales[c14721_1];
}
if (r17 != null) {
this.setLocale(r17);
}
}
});
c3137_7.on("spellcheck-result", (a0, a1) => {
let misspelledWord = a0;
if (a0 == null) {
misspelledWord = "";
}
let corrections = a1;
this.misspelledWord = misspelledWord;
if (a1 == null) {
corrections = [];
}
this.corrections = corrections;
});
}
get enabled() {
return this._enabled;
}
set enabled(a0) {
this._enabled = a0;
}
setLearnedWords(a0) {
c3137_7.setLearnedWords(a0);
}
setLocale(a0) {
const r6 = c3137_7.setLocale(a0);
if (r6 != null) {
r6.then((result) => {
c3137_6.info(`Switching to ${a0}`, result ? "(available)" : "(unavailable)");
});
}
}
setAppLocale(a0) {
this.regionPreference = a0.split("-")[1];
}
detectLanguage(a0) {
if (this.enabled) {
this.languageDetector.process(a0);
}
}
getAvailableLanguages(a0) {
const r0 = {};
let c14723_0 = r0;
a0.forEach((item) => {
const [r5] = item.split("-");
let r13 = c14723_0[r5];
if (r13 == null) {
r13 = item;
}
c14723_0[r5] = r13;
});
return r0;
}
isMisspelled(a0) {
return this.misspelledWord !== "" && a0 === this.misspelledWord;
}
getCorrectionsForMisspelling(a0, a1) {
return this.isMisspelled(a0, a1) ? this.corrections : [];
}
getCachedMisspelling() {
return {
misspelledWord: this.misspelledWord,
corrections: this.corrections
};
}
replaceMisspelling(a0) {
c3137_7.replaceMisspelling(a0);
}
}
c3137_10 = Module12.debounce((a0, a1) => {
let r4;
L7: {
const r0 = a1 == null;
r4 = null;
if (!r0) {
if (!_Module1859.isElement(a1, HTMLInputElement) && !_Module1859.isElement(a1, HTMLTextAreaElement)) {
const isElement = _Module1859.isElement(a1);
r4 = void 0;
if (!isElement) {
break L7;
}
const hasAttribute = a1.hasAttribute("contenteditable");
r4 = void 0;
if (!hasAttribute) {
break L7;
}
r4 = a1.textContent;
break L7;
}
r4 = a1.value;
}
}
if (r4 != null) {
a0.detectLanguage(r4);
}
}, 250);
export async function install() {
let env29481;
const r9 = env3137;
let c25379_2 = r9;
const r26 = env29481 = {
$parent: r9
};
let c25379_1 = r26;
env29481[0] = void 0;
env29481[1] = void 0;
const availableDictionaries = await c3137_7.getAvailableDictionaries();
let c25379_0 = availableDictionaries;
if (availableDictionaries == null) {
c25379_0 = [];
}
env29481[0] = c25379_0.map(normalizeLocale).filter(isNotNullish);
env29481[1] = new Spellchecker(env29481[0]);
const r57 = env29481[1];
$mk114669(env3137)(r57);
return env29481[1];
}
+140
View File
@@ -0,0 +1,140 @@
// Metro module 5194 (f5195).
export default {
aa: "aa-ET",
af: "af-ZA",
ak: "ak-GH",
am: "am-ET",
an: "an-ES",
ar: "ar-MA",
as: "as-IN",
ay: "ay-PE",
az: "az-AZ",
be: "be-BY",
bg: "bg-BG",
bi: "bi-TV",
bn: "bn-BD",
bo: "bo-CN",
br: "br-FR",
bs: "bs-BA",
ca: "ca-ES",
ce: "ce-RU",
cs: "cs-CZ",
cv: "cv-RU",
cy: "cy-GB",
da: "da-DK",
de: "de-DE",
dv: "dv-MV",
dz: "dz-BT",
el: "el-GR",
en: "en-US",
es: "es-ES",
et: "et-EE",
eu: "eu-ES",
fa: "fa-IR",
ff: "ff-SN",
fi: "fi-FI",
fo: "fo-FO",
fr: "fr-FR",
fy: "fy-DE",
ga: "ga-IE",
gd: "gd-GB",
gl: "gl-ES",
gu: "gu-IN",
gv: "gv-GB",
ha: "ha-NG",
he: "he-IL",
hi: "hi-IN",
hr: "hr-HR",
ht: "ht-HT",
hu: "hu-HU",
hy: "hy-AM",
ia: "ia-FR",
id: "id-ID",
ig: "ig-NG",
ik: "ik-CA",
is: "is-IS",
it: "it-IT",
iu: "iu-CA",
ja: "ja-JP",
ka: "ka-GE",
kk: "kk-KZ",
kl: "kl-GL",
km: "km-KH",
kn: "kn-IN",
ko: "ko-KR",
ks: "ks-IN",
ku: "ku-TR",
kw: "kw-GB",
ky: "ky-KG",
lb: "lb-LU",
lg: "lg-UG",
li: "li-BE",
ln: "ln-CD",
lo: "lo-LA",
lt: "lt-LT",
lv: "lv-LV",
mg: "mg-MG",
mh: "mh-MH",
mi: "mi-NZ",
mk: "mk-MK",
ml: "ml-IN",
mn: "mn-MN",
mr: "mr-IN",
ms: "ms-MY",
mt: "mt-MT",
my: "my-MM",
nb: "nb-NO",
ne: "ne-NP",
nl: "nl-NL",
nn: "nn-NO",
nr: "nr-ZA",
oc: "oc-FR",
om: "om-KE",
or: "or-IN",
os: "os-RU",
pa: "pa-PK",
pl: "pl-PL",
ps: "ps-AF",
pt: "pt-PT",
ro: "ro-RO",
ru: "ru-RU",
rw: "rw-RW",
sa: "sa-IN",
sc: "sc-IT",
sd: "sd-IN",
se: "se-NO",
si: "si-LK",
sk: "sk-SK",
sl: "sl-SI",
so: "so-SO",
sq: "sq-AL",
sr: "sr-RS",
ss: "ss-ZA",
st: "st-ZA",
sv: "sv-SE",
sw: "sw-KE",
ta: "ta-IN",
te: "te-IN",
tg: "tg-TJ",
th: "th-TH",
ti: "ti-ER",
tk: "tk-TM",
tl: "tl-PH",
tn: "tn-ZA",
tr: "tr-TR",
ts: "ts-ZA",
tt: "tt-RU",
ug: "ug-CN",
uk: "uk-UA",
ur: "ur-PK",
uz: "uz-UZ",
ve: "ve-ZA",
vi: "vi-VN",
wa: "wa-BE",
wo: "wo-SN",
xh: "xh-ZA",
yi: "yi-US",
yo: "yo-NG",
zh: "zh-CN",
zu: "zu-ZA"
};
+289
View File
@@ -0,0 +1,289 @@
// Metro module 16098 (f16099).
import ExperimentStore from "../modules/experiments/ExperimentStore";
import { AbortCodes } from "../Constants";
import noop from "../_bundle/noop";
import { IdGenerator } from "./IdGenerator";
import URLUtils from "../utils/URLUtils";
import { createApexExperiment } from "../modules/experiments/apex/index";
import Dispatcher from "../Dispatcher";
import { setRejectWithMigratedError, setRequestPatch, getAPIBaseURL, setAwaitOnline } from "../_bundle/sendRequest";
import * as _AuthenticationStore from "../stores/AuthenticationStore";
import * as _DeveloperOptionsStore from "../stores/DeveloperOptionsStore";
import * as _LocaleStore from "../modules/user_settings/LocaleStore";
import * as _UserStore from "../stores/UserStore";
import * as _AnalyticsUtils from "../utils/AnalyticsUtils";
import { isPlatformEmbedded, isAndroid } from "../utils/PlatformUtils";
import { updateDynamicSuperProperties } from "../modules/analytics/updateDynamicSuperProperties";
import { NativeModules } from "react-native";
import * as _Module666 from "../_bundle/Module666";
import getTimeZone_native from "./getTimeZone.native";
import trackHttpRequest from "../modules/telemetry_ring/trackHttpRequest";
import { report } from "../modules/debug/LogAggregator";
import SentryUtils_native from "../utils/SentryUtils.native";
import { isLimitedAccessErrorCode } from "../modules/user_limited_access/UserLimitedAccessUtils";
import * as _GuildLimitedAccessUtils from "../modules/guild_limited_access/GuildLimitedAccessUtils";
import NetworkUtils from "../utils/NetworkUtils";
let _excluded, c11523_7, c11523_8, c11523_10;
let c11524_0;
let env11523 = {};
const isAnalyticsEndpoint = function isAnalyticsEndpoint(a0) {
let r12;
try {
r12 = c11523_8.test(new URL(a0).pathname);
} catch ($e) {
return c11523_8.test(a0);
}
return r12;
};
_excluded = ["https://cdn.discordapp.com/bad-domains/updated_hashes.json", "https://cdn.discordapp.com/bad-domains/hashes.json"];
noop.parse[""] = JSON.parse;
c11523_7 = new IdGenerator();
c11523_8 = /\/api(\/v\d+)?\/science/;
c11523_10 = createApexExperiment({
name: "2026-07-reject-with-error-kill-switch",
kind: "user",
defaultConfig: {
migrationKilled: false
},
variations: {
1: {
migrationKilled: true
}
}
});
env11523[11] = null;
Dispatcher.subscribe("LOGOUT", () => {
env11523[11] = null;
});
setRejectWithMigratedError(function isRejectWithMigratedErrorEnabled() {
let r1 = env11523[11];
if (r1 == null) {
let r8 = !ExperimentStore.hasLoadedExperiments;
if (ExperimentStore.hasLoadedExperiments) {
const r2 = !c11523_10.getConfig({
location: "reject_with_error_migration"
}).migrationKilled;
env11523[11] = r2;
r8 = r2;
}
r1 = r8;
}
return r1;
});
setRequestPatch({
prepareRequest: (a0) => {
let shouldTrackHttpRequest2;
let c22788_0 = a0;
let c22788_1 = performance.now();
if (a0.url[0] === "/") {
a0.url = getAPIBaseURL() + a0.url;
if (!("Authorization" in a0.header || "authorization" in a0.header)) {
a0.set("Authorization", _AuthenticationStore.default.getToken());
}
updateDynamicSuperProperties();
const superPropertiesBase64 = _AnalyticsUtils.default.getSuperPropertiesBase64();
if (superPropertiesBase64 != null) {
a0.set("X-Super-Properties", superPropertiesBase64);
}
const fingerprint = _AuthenticationStore.default.getFingerprint();
if (fingerprint != null && fingerprint !== "") {
a0.set("X-Fingerprint", fingerprint);
}
const installationForTracking = _AuthenticationStore.default.getInstallationForTracking();
if (installationForTracking != null && installationForTracking !== "") {
a0.set("X-Installation-ID", installationForTracking);
}
if (isPlatformEmbedded) {
const r81 = isAndroid() ? _Module666.default : NativeModules.LocalizationManager;
let r84 = [];
if (r81 != null) {
let Languages = r81.getConstants().Languages;
if (Languages == null) {
Languages = [];
}
r84 = Languages;
}
a0.set("Accept-Language", (function populateQValues(a0) {
let c28221_0 = 10;
return a0.reduce((acc, item) => {
if (c28221_0 === 10) {
acc.push(item);
} else {
acc.push.call(acc, `${item};q=0.${c28221_0}`);
}
c28221_0 = Math.max(c28221_0 - 1, 1);
return acc;
}, []).join(",");
})(r84));
}
a0.set("X-Discord-Locale", _LocaleStore.default.locale);
const timeZone_native = getTimeZone_native();
if (timeZone_native != null) {
a0.set("X-Discord-Timezone", timeZone_native);
}
const debugOptionsHeaderValue = _DeveloperOptionsStore.default.getDebugOptionsHeaderValue();
if (debugOptionsHeaderValue != null && debugOptionsHeaderValue !== "") {
a0.set("X-Debug-Options", debugOptionsHeaderValue);
}
const routingKeyHeaderValue = _DeveloperOptionsStore.default.getRoutingKeyHeaderValue();
if (routingKeyHeaderValue != null && routingKeyHeaderValue !== "") {
a0.set("X-Routing-Key", routingKeyHeaderValue);
}
if (_DeveloperOptionsStore.default.isTracingRequests) {
const currentUser = _UserStore.default.getCurrentUser();
let r125 = currentUser?.id;
if (r125 == null) {
r125 = "0";
}
const r126 = c11523_7.generate(r125);
a0.set("x-client-trace-id", r126);
try {
if (!isAnalyticsEndpoint(new URL(a0.url).pathname)) {
(function getDatadogAPMUrl(a0) {
const uRLSearchParams = new URLSearchParams();
uRLSearchParams.append("query", `@http.x_client_trace_id:"${a0}"`);
uRLSearchParams.append("showAllSpans", "true");
const r35 = URLUtils.toURLSafe(`traces?${uRLSearchParams.toString()}`, "https://datadog.discord.tools/apm/");
return r35 != null ? r35.toString() : null;
})(r126);
}
} catch ($e) {}
}
}
shouldTrackHttpRequest2 = (function shouldTrackHttpRequest(a0) {
return !isAnalyticsEndpoint(a0);
})(a0.url);
report("Network", `Sending ${a0.method} to ${a0.url}`);
a0.on("response", (a0) => {
const r6 = a0 != null ? a0.status >= 400 ? a0.text : null : null;
const r20 = r6 == null ? "" : `and body: ${r6}`;
report("Network", `Completed ${c22788_0.method} to ${c22788_0.url} with status: ${a0?.status} ${r20}`);
if (shouldTrackHttpRequest2) {
trackHttpRequest({
url: c22788_0.url,
method: c22788_0.method,
status_code: a0?.status,
duration_ms: Math.round(performance.now() - c22788_1)
});
shouldTrackHttpRequest2 = false;
}
});
a0.on("error", (a0, a1) => {
report("Network", `Failed ${c22788_0.method} to ${c22788_0.url} with status ${a0?.status} and body: ${a1?.text}`);
if (a0 != null && "parse" in a0 && a0.parse) {
const r42 = _excluded.includes(c22788_0.url);
let responseText2 = "[FILTERED]";
if (r42) {
const xhr = c22788_0.xhr;
const r44 = xhr == null;
let r45 = void 0;
if (!r44) {
const responseText = xhr.responseText;
r45 = responseText == null ? void 0 : responseText.slice(0, 1000);
}
responseText2 = r45;
}
SentryUtils_native.addBreadcrumb({
category: "superagent",
message: "Failed to parse HTTP response.",
data: {
method: c22788_0.method,
url: c22788_0.url,
responseText: responseText2,
status: a0.status
}
});
}
if (shouldTrackHttpRequest2) {
trackHttpRequest({
url: c22788_0.url,
method: c22788_0.method,
status_code: a1?.status,
duration_ms: Math.round(performance.now() - c22788_1)
});
shouldTrackHttpRequest2 = false;
}
});
},
interceptResponse: (a0, a1, a2) => {
let r46;
let c22789_0, c22789_1, c22789_2;
L31: {
c22789_0 = a0;
c22789_1 = a1;
c22789_2 = a2;
if (a0.statusCode === 400) {
if (a0.body?.captcha_key) {
Promise.all([import("../modules/captcha/CaptchaUtils.native"), import("../modules/captcha/SharedCaptchaUtils")]).then((result) => {
const [{ default: default2 }, { extractCaptchaPropsFromResponse }] = result;
return default2.showCaptchaAsync(extractCaptchaPropsFromResponse(c22789_0.body));
}).then(({ captcha_key, captcha_rqtoken, captcha_session_id }) => {
const r2 = {
"X-Captcha-Key": captcha_key
};
if (captcha_rqtoken != null) {
r2["X-Captcha-Rqtoken"] = captcha_rqtoken;
}
if (captcha_session_id != null) {
r2["X-Captcha-Session-Id"] = captcha_session_id;
}
c22789_1(r2);
}).catch(a2);
r46 = true;
break L31;
}
}
if (a0.statusCode === 401) {
if (a0.body?.code === AbortCodes.MFA_REQUIRED) {
if (a0.body?.mfa) {
import("../modules/mfa/MFAActionCreators").then((result) => {
(0, result.openMFAModal)(c22789_0.body.mfa, c22789_1, c22789_2);
}).catch(a2);
r46 = true;
break L31;
}
}
}
if (isLimitedAccessErrorCode(a0.statusCode, a0.body?.code)) {
import("../modules/quarantine/openQuarantineModeInfoModal.native").then((result) => {
(0, result.default)();
});
r46 = false;
} else if (_GuildLimitedAccessUtils.isLimitedAccessErrorCode(a0.statusCode, a0.body?.code)) {
import("../modules/guild_limited_access/openGuildLimitedAccessInfoModal.native").then((result) => {
result.default(c22789_0.body?.guild_id);
});
r46 = false;
} else {
r46 = a0.statusCode === 403 && a0.body?.code === AbortCodes.RESTRICTED_HOURS_ACTIVE;
if (r46) {
import("../modules/parent_tools/RestrictedHoursActionCreators.native").then((result) => {
(0, result.openRestrictedHoursModal)();
});
r46 = false;
}
}
}
return r46;
}
});
c11524_0 = void 0;
c11524_0 = async (c28222_0) => {
let c28222_2;
let c30952_0;
L13: {
c28222_2 = void 0;
c30952_0 = c28222_0;
report("Network", `Request to ${c28222_0} failed, will retry.`);
if (NetworkUtils.isOnline()) {
break L13;
}
await NetworkUtils.awaitOnline();
report("Network", `Network detected online, retrying ${c30952_0}`);
return void 0;
}
};
setAwaitOnline(function() {
const apply = c11524_0.apply;
return c11524_0.apply(this, arguments);
});
+137
View File
@@ -0,0 +1,137 @@
// Metro module 10349 (f10350).
import { DebugLogCategory, Endpoints } from "../Constants";
import Logger from "../modules/debug/Logger";
import { readFile } from "../utils/FileManagerUtils.android";
import { UploadVoiceDebugLogsError, UploadErrorCodes } from "../errors/index";
import { HTTP } from "../_bundle/sendRequest";
let c6925_5 = new Logger("uploadRtcLogFiles");
export async function uploadRtcLogFiles(c26663_0) {
let r45;
let c26663_1, c26663_2, c26663_5;
let c26663_6 = 0;
let c30212_0, c30212_1, c30212_2, c30212_3, c30212_4;
let r14 = "uploadRtcLogFiles: Log file upload error: status: ";
L23: {
try {
c30212_0 = c26663_0;
c30212_1 = void 0;
c30212_2 = void 0;
const r58 = ["discord-webrtc_0", "discord-webrtc_1", "discord-last-webrtc_0", "discord-last-webrtc_1"];
c26663_2 = r58;
const r60 = r58[Symbol.iterator]();
c26663_2 = r60.next;
c26663_1 = r60;
const r62 = c26663_2;
let r63 = c26663_1;
const r64 = r63 === void 0 ? void 0 : (r45 = r62.call(r63)).done ? r63 = void 0 : r45.value;
c26663_1 = r63;
if (r63 === void 0) {
break L23;
}
c30212_1 = r64;
c30212_2 = "";
c26663_6 = 2;
let r79 = await readFile("documents", c30212_1, "utf8");
r14 = "uploadRtcLogFiles: Log file upload error: status: ";
let r95 = "uploadRtcLogFiles: Log file is too big, skipping upload";
while (true) {
c30212_2 = r79;
if (r79 == null) {
c26663_6 = 0;
} else if (c30212_2.length > c30212_0) {
c6925_5.warn(r95);
c26663_6 = 0;
} else {
c26663_6 = 3;
await HTTP.post({
url: Endpoints.DEBUG_LOG(DebugLogCategory.ANDROID_APP, c30212_1),
body: c30212_2,
headers: {
"Content-Type": "text/plain"
},
rejectWithError: false
});
r14 = "uploadRtcLogFiles: Log file upload error: status: ";
c26663_6 = 0;
}
const r148 = c26663_2;
let r149 = c26663_1;
const r150 = r149 === void 0 ? void 0 : (r45 = r148.call(r149)).done ? r149 = void 0 : r45.value;
c26663_1 = r149;
if (r149 === void 0) {
break;
}
c30212_1 = r150;
c30212_2 = "";
c26663_6 = 2;
r79 = await readFile("documents", c30212_1, "utf8");
r14 = "uploadRtcLogFiles: Log file upload error: status: ";
r95 = "uploadRtcLogFiles: Log file is too big, skipping upload";
}
} catch ($e) {
const r55 = $e;
let r8 = r55;
c26663_5 = r55;
let r56 = c26663_6;
if (r56 !== 0) {
while (true) {
if (r56 === 1) {
try {
const r268 = c26663_5;
c26663_6 = 0;
const r270 = c26663_1;
if (r270 !== void 0 && typeof r270.return === "function") {
try {
r270.return();
} catch {}
}
throw r268;
} catch (r267) {
r8 = r267;
c26663_5 = r267;
r56 = c26663_6;
if (r56 === 0) {
break;
}
}
} else if (r56 === 2) {
try {
const r240 = c26663_5;
c26663_6 = 1;
c30212_3 = r240;
c6925_5.error(`uploadRtcLogFiles: Log file reading error: ${c30212_3.message}`);
throw new UploadVoiceDebugLogsError(UploadErrorCodes.READ);
} catch (r237) {
r8 = r237;
c26663_5 = r237;
r56 = c26663_6;
if (r56 === 0) {
break;
}
}
} else {
try {
const r191 = c26663_5;
c26663_6 = 1;
c30212_4 = r191;
c6925_5.error(HermesInternal.concat.call(r14, c30212_4.status, ", message: ", c30212_4.message));
if (c30212_4.status === 429) {
throw new UploadVoiceDebugLogsError(UploadErrorCodes.PROGRESS);
}
throw new UploadVoiceDebugLogsError(UploadErrorCodes.UPLOAD);
} catch (r188) {
r8 = r188;
c26663_5 = r188;
r56 = c26663_6;
if (r56 === 0) {
break;
}
}
}
}
}
throw r8;
}
return void 0;
}
}
File diff suppressed because it is too large. Load diff
+73
View File
@@ -0,0 +1,73 @@
// Metro module 4722 (f4723).
import { EventEmitter } from "../../_bundle/EventEmitter_652";
import { getFile } from "../../utils/UploadUtils";
import Module12 from "../../_bundle/Module12";
import { classifyFile } from "../../utils/FileUtils";
import { v4 } from "../../_bundle/Module514";
let c2880_4 = {
REACT_NATIVE: 0,
0: "REACT_NATIVE",
WEB: 1,
1: "WEB"
};
const r20 = {
FILE_ATTACHMENT: 0,
0: "FILE_ATTACHMENT",
IMAGE_PICKER: 1,
1: "IMAGE_PICKER",
IMAGE_EDITOR: 2,
2: "IMAGE_EDITOR"
};
class Upload extends EventEmitter {
allowOptimization = true;
constructor(a0) {
super();
this.item = a0;
if (a0.platform === c2880_4.REACT_NATIVE) {
let id2 = a0.id;
if (id2 == null) {
id2 = a0.uri;
}
this.id = id2;
const file = getFile({
uri: a0.uri,
overrideFilename: a0.filename,
overrideType: a0.mimeType
});
this.filename = file.filename;
this.isImage = file.isImage;
this.isVideo = file.isVideo;
this.mimeType = file.type;
this.origin = a0.origin;
this.durationSecs = a0.durationSecs;
this.waveform = a0.waveform;
} else {
let id = a0.id;
if (id == null) {
id = Module12.uniqueId("upload");
}
this.id = id;
this.classification = classifyFile(a0.file);
this.isImage = this.classification === "image";
this.isVideo = this.classification === "video";
this.filename = a0.file.name;
this.mimeType = a0.file.type;
this.origin = a0.origin;
}
this.isThumbnail = a0.isThumbnail;
this.clip = a0.clip;
this.uniqueId = v4();
this.spoiler = false;
this.description = null;
}
cancel() {}
resetState() {
return this;
}
}
export default Upload;
export { c2880_4 as UploadPlatform };
export function isResolvedUpload(a0) {
return a0.isVideo !== void 0 && a0.isImage !== void 0;
}
export { r20 as UploadOrigin };
+54
View File
@@ -0,0 +1,54 @@
// Metro module 4763 (f4764).
import ChannelStore from "../../stores/ChannelStore";
import { Endpoints, MAX_UPLOAD_COUNT } from "../../Constants";
import { maxFileSize } from "../../utils/FileUtils";
import { MAX_TOTAL_ATTACHMENT_SIZE } from "../../utils/UploadUtils";
import GuildProductAttachmentUploadTarget from "../../modules/guild_products/GuildProductAttachmentUploadTarget";
import ICYMIAttachmentUploadTarget from "../../modules/icymi/ICYMIAttachmentUploadTarget";
let c2914_8;
class MessageAttachmentUploadTarget {
constructor() {
return {
__proto__: new.target.prototype
};
}
getCreateAttachmentURL(a0) {
return Endpoints.MESSAGE_CREATE_ATTACHMENT_UPLOAD(a0);
}
getDeleteUploadURL(a0) {
return Endpoints.MESSAGE_DELETE_UPLOAD(a0);
}
getMaxFileSize(a0) {
return maxFileSize(ChannelStore.getBasicChannel(a0)?.guild_id);
}
getMaxAttachmentsCount() {
return MAX_UPLOAD_COUNT;
}
getMaxTotalAttachmentSize() {
return MAX_TOTAL_ATTACHMENT_SIZE;
}
get shouldReactNativeCompressUploads() {
return true;
}
}
c2914_8 = {
MESSAGE_ATTACHMENT: 0,
0: "MESSAGE_ATTACHMENT",
GUILD_PRODUCT_ATTACHMENT: 1,
1: "GUILD_PRODUCT_ATTACHMENT",
GRAVITY_ATTACHMENT: 2,
2: "GRAVITY_ATTACHMENT"
};
export { c2914_8 as UploadTargets };
export function getUploadTarget(a0) {
if (c2914_8.GUILD_PRODUCT_ATTACHMENT === a0) {
return new GuildProductAttachmentUploadTarget();
}
if (c2914_8.GRAVITY_ATTACHMENT === a0) {
return new ICYMIAttachmentUploadTarget();
}
c2914_8.MESSAGE_ATTACHMENT;
return {
__proto__: MessageAttachmentUploadTarget.prototype
};
}
+121
View File
@@ -0,0 +1,121 @@
// Metro module 4729 (f4730).
import { UploadPlatform } from "./Upload";
import { HTTP } from "../../_bundle/sendRequest";
import { fileIsInAppDir } from "../../utils/AttachmentFile.native";
import { isLibdiscoreInitialized, getHttpClientAPI } from "../../_bundle/Module1869";
export function doesImageMatchUpload(a0, a1) {
L12: {
if (a1.id !== a0.uri) {
if (a1.id != null && a1.id === a0.id) {
break L12;
}
if (a1.item.platform === UploadPlatform.REACT_NATIVE) {
const item = a1.item;
const filename = a0.filename;
let r24 = item.originalUri === a0.uri;
if (!r24) {
let r1 = filename == null;
if (!r1) {
const originalUri = item.originalUri;
r1 = !(originalUri == null ? void 0 : originalUri.includes(filename));
}
r24 = !r1;
}
return r24;
}
return false;
}
}
return true;
}
export function calculateProgress(a0, a1) {
return a1 !== 0 ? Math.min(Math.floor(a0 / a1 * 100), 100) : 0;
}
export class DefaultHttpClient {
constructor() {
return {
__proto__: new.target.prototype
};
}
sliceBody(a0, a1) {
return a0 instanceof File ? a0.slice(a1) : a0;
}
doUpload(a0, a1) {
if (a1?.fileByteRange != null) {
a0.body = this.sliceBody(a0.body, a1.fileByteRange.start);
}
return HTTP.put(a0);
}
}
export function canUploadNatively(a0) {
return a0.platform === UploadPlatform.REACT_NATIVE && a0.uri != null && fileIsInAppDir(a0.uri) && isLibdiscoreInitialized();
}
export class LibdiscoreHttpClient {
constructor() {
const prototype = new.target.prototype;
if (isLibdiscoreInitialized()) {
return {
__proto__: prototype
};
}
throw new Error("Libdiscore is not loaded");
}
doUpload(a0, a1) {
let c14413_2;
const httpClientAPI = getHttpClientAPI();
if (httpClientAPI == null) {
throw new Error("Libdiscore client is not available");
}
const r21 = a0.body?.uri !== void 0 && typeof a0.body.uri === "string";
let path = void 0;
if (r21) {
const r27 = a0.body.uri.startsWith("file://");
const uri = a0.body.uri;
path = r27 ? uri.slice(7) : uri;
}
if (path !== void 0 && path !== "") {
c14413_2 = httpClientAPI.httpRequest(a0.url, {
method: "PUT",
body: {
path,
byteRangeStart: a1 == null ? void 0 : a1.fileByteRange?.start,
byteRangeEnd: a1 == null ? void 0 : a1.fileByteRange?.end
},
headers: a0.headers
});
return new Promise((c25268_0, c25268_1) => {
const pollStatus2 = function pollStatus() {
if (httpClientAPI != null) {
if (a0.signal?.aborted) {
c25268_1(new Error("Request cancelled"));
httpClientAPI.cancelHttpRequest(c14413_2);
return void 0;
}
const httpRequestStatus = httpClientAPI.getHttpRequestStatus(c14413_2);
if (httpRequestStatus?.status === "success") {
c25268_0({
status: httpRequestStatus.response?.status,
headers: httpRequestStatus.response?.headers,
text: httpRequestStatus.response?.body
});
} else if (httpRequestStatus?.status === "error") {
c25268_1(new Error(httpRequestStatus.error));
} else if (httpRequestStatus?.status === "progressing") {
if (a0.onRequestProgress !== void 0 && httpRequestStatus.uploaded_bytes != null && httpRequestStatus.uploaded_bytes > 0) {
a0.onRequestProgress({
loaded: httpRequestStatus.uploaded_bytes,
total: httpRequestStatus.total_bytes
});
}
setTimeout(pollStatus2, 50);
} else {
c25268_1(new Error("Unknown upload status"));
}
}
};
pollStatus2();
});
}
throw new Error("No file path found in request body");
}
}
+422
View File
@@ -0,0 +1,422 @@
// Metro module 6151 (f6152).
import { AbortCodes } from "../../Constants";
import { FileUploadErrorTypes } from "../../modules/messages/MessageConstants";
import Logger from "../../modules/debug/Logger";
import { EventEmitter } from "../../_bundle/EventEmitter_652";
import Module12 from "../../_bundle/Module12";
import { getUploadTarget } from "./UploadTargets";
import { getKestrelConfig, getEffectiveKestrelLimit } from "../../modules/media_uploads/experiments/KestrelExperiment";
import { calculateProgress } from "./UploadUtils";
import { cancelGetAttachmentFile } from "../../utils/AttachmentFile.native";
import { HermesBuiltin } from "../../_hermes/prelude";
let c3893_7;
let env3893 = {};
const c3893_6 = new Logger("UploaderBase.tsx");
class UploaderBase extends EventEmitter {
_aborted = false;
_errored = false;
files = [];
_lastUpdate = 0;
_loaded = 0;
alreadyStarted = false;
_handleStart = (a0) => {
this._cancel = a0;
if (!this.alreadyStarted) {
this.emit("start", this._file);
}
this.alreadyStarted = true;
};
_handleProgress = (a0, a1, a2) => {
const _lastUpdate = Date.now();
const progress = calculateProgress(a0, a1);
const r11 = Math;
const rate = r11.floor((a0 - this._loaded) / ((_lastUpdate - this._lastUpdate) / 1000));
if (a2 != null) {
const items = this._file.items;
if (items != null) {
items.forEach((item) => {
item.item.progress = a2[item.id];
});
}
}
this._lastUpdate = _lastUpdate;
this._loaded = a0;
this._file = {
...this._file,
currentSize: a1,
progress,
rate
};
this.emit("progress", this._file);
};
_handleException = (a0) => {
this._handleError({
reason: {
type: FileUploadErrorTypes.ERROR_SOURCE_UNKNOWN,
msg: a0.toString()
}
});
};
_handleAborted = () => {
this.clearProcessingMessageInterval();
};
_handleError = ({ code, reason, body }) => {
this.clearProcessingMessageInterval();
if (!this._aborted) {
this._errored = true;
c3893_6.log(`_handleError: ${code} (${JSON.stringify(reason)}) for ${this.id}`);
this.emit("error", this._file, code, body, reason);
this.removeAllListeners();
}
};
_handleComplete = (a0) => {
this.clearProcessingMessageInterval();
c3893_6.log(`_handleComplete for ${this.id}`);
this.emit("complete", this._file, a0);
this.removeAllListeners();
};
id = Module12.uniqueId("Uploader");
_file = {
id: this.id,
currentSize: 0,
totalPreCompressionSize: 0,
compressionProgress: 0,
progress: 0,
rate: 0,
hasImage: false,
hasVideo: false,
attachmentsCount: 0,
items: void 0
};
constructor() {
super();
}
_fileSize() {
return this.files.reduce((acc, { currentSize: currentSize3 }) => {
if (currentSize3 == null) {
currentSize3 = 0;
}
return acc + currentSize3;
}, 0);
}
async compressAndCheckFileSize() {
let r39, r110, r207;
const _this = this;
let c25722_0, files, currentSize, currentSize2, c25722_6;
let c25722_7 = 0;
let c29674_0, c29674_1, c29674_2, c29674_3, c29674_4;
L43: {
L42: {
L41: {
L35: {
L34: {
L37: {
try {
c29674_0 = void 0;
c29674_1 = void 0;
c29674_2 = void 0;
c29674_3 = void 0;
const r24 = _this.files[0];
const uploadTarget = getUploadTarget(r24 == null ? void 0 : r24.item?.target);
c29674_0 = uploadTarget;
if (_this.files.length > uploadTarget.getMaxAttachmentsCount()) {
c3893_6.log(`Too many attachments for ${_this.id}`);
_this._handleError({
code: AbortCodes.TOO_MANY_ATTACHMENTS
});
break L43;
}
c29674_1 = getKestrelConfig({
location: "UploaderBase.compressAndCheckFileSize"
});
c3893_6.log(`compressing files for ${_this.id}`);
const files2 = _this.files;
files = files2;
const r96 = files2[Symbol.iterator]();
files = r96.next;
c25722_0 = r96;
const r98 = files;
let r99 = c25722_0;
const r100 = r99 === void 0 ? void 0 : (r39 = r98.call(r99)).done ? r99 = void 0 : r39.value;
c25722_0 = r99;
if (r99 === void 0) {
r110 = !(_this._fileSize() > c29674_0.getMaxTotalAttachmentSize());
if (r110) {
break L42;
}
_this._handleError({
code: AbortCodes.ENTITY_TOO_LARGE,
reason: {
type: FileUploadErrorTypes.POSTCOMPRESSION_SUM_TOO_LARGE
}
});
break L41;
}
c29674_2 = r100;
c25722_7 = 2;
await c29674_2.reactNativeCompressAndExtractData();
let r133 = "compressAndCheckFileSize() file has been cancelled for compression - ";
while (true) {
if (c29674_2.isCancelled()) {
c3893_6.log(HermesInternal.concat.call(r133, c29674_2.id));
c25722_7 = 0;
} else {
const currentSize3 = c29674_2.currentSize;
currentSize = currentSize3;
if (currentSize3 == null) {
currentSize = 0;
}
if (currentSize === 0) {
_this._handleError({
code: AbortCodes.ENTITY_EMPTY
});
c25722_7 = 0;
const r162 = c25722_0;
if (r162 !== void 0 && typeof r162.return === "function") {
r162.return();
}
break L37;
}
c29674_3 = getEffectiveKestrelLimit(c29674_1, c29674_0.getMaxFileSize(c29674_2.channelId));
const currentSize4 = c29674_2.currentSize;
currentSize2 = currentSize4;
if (currentSize4 == null) {
currentSize2 = 0;
}
if (currentSize2 > c29674_3) {
_this._handleError({
code: AbortCodes.ENTITY_TOO_LARGE,
reason: {
type: FileUploadErrorTypes.POSTCOMPRESSION_INDIVIDUAL_FILE_TOO_LARGE
}
});
c25722_7 = 0;
const r193 = c25722_0;
if (r193 !== void 0 && typeof r193.return === "function") {
r193.return();
}
break;
}
c25722_7 = 0;
}
const r195 = files;
let r196 = c25722_0;
const r197 = r196 === void 0 ? void 0 : (r39 = r195.call(r196)).done ? r196 = void 0 : r39.value;
c25722_0 = r196;
if (r196 === void 0) {
r207 = !(_this._fileSize() > c29674_0.getMaxTotalAttachmentSize());
if (r207) {
break L35;
}
_this._handleError({
code: AbortCodes.ENTITY_TOO_LARGE,
reason: {
type: FileUploadErrorTypes.POSTCOMPRESSION_SUM_TOO_LARGE
}
});
break L34;
}
c29674_2 = r197;
c25722_7 = 2;
await c29674_2.reactNativeCompressAndExtractData();
r133 = "compressAndCheckFileSize() file has been cancelled for compression - ";
}
} catch ($e) {
const r47 = $e;
let r8 = r47;
c25722_6 = r47;
let r48 = c25722_7;
if (r48 !== 0) {
while (true) {
if (r48 !== 1) {
try {
const r266 = c25722_6;
c25722_7 = 1;
c29674_4 = r266;
_this._handleException(c29674_4);
c25722_7 = 0;
const r272 = c25722_0;
if (r272 !== void 0 && typeof r272.return === "function") {
r272.return();
}
} catch (r263) {
r8 = r263;
c25722_6 = r263;
r48 = c25722_7;
if (r48 === 0) {
break;
}
continue;
}
return false;
}
try {
const r277 = c25722_6;
c25722_7 = 0;
const r279 = c25722_0;
if (r279 !== void 0 && typeof r279.return === "function") {
try {
r279.return();
} catch {}
}
throw r277;
} catch (r276) {
r8 = r276;
c25722_6 = r276;
r48 = c25722_7;
if (r48 === 0) {
break;
}
}
}
}
throw r8;
}
return false;
}
return false;
}
return 0;
}
return r207;
}
return 0;
}
return r110;
}
return false;
}
setUploadingTextForUI() {
const hasImage = this.files.some((file) => file.isImage);
const hasVideo = this.files.some((file) => file.isVideo);
const totalPostCompressionSize = this._fileSize();
c3893_6.log(`setUploadingTextForUI - total content: ${totalPostCompressionSize} bytes and ${this.files.length} attachments for ${this.id}`);
this._file = {
...this._file,
totalPostCompressionSize,
currentSize: totalPostCompressionSize,
hasVideo,
hasImage,
attachmentsCount: this.files.length,
items: this.files
};
}
_recomputeProgress() {
const r6 = this._recomputeProgressTotal();
this._handleProgress(r6.loaded, r6.total, this._recomputeProgressByFile());
}
_recomputeProgressTotal() {
const total = this._fileSize();
return {
loaded: this.files.reduce((acc, { loaded }) => {
if (loaded == null) {
loaded = 0;
}
return acc + loaded;
}, 0),
total
};
}
_recomputeProgressByFile() {
const r0 = {};
let c15524_0 = r0;
this.files.forEach((file) => {
c15524_0[file.id] = calculateProgress(file.loaded, file.currentSize);
});
return r0;
}
_addAttachmentsToPayload(a0, a1, a2) {
const r5 = {
...a0
};
return Module12.set(r5, a1, [...Module12.get(r5, a1, []), ...a2]);
}
clearProcessingMessageInterval() {
if (this.processingMessageChangeInterval != null) {
clearInterval(this.processingMessageChangeInterval);
this.processingMessageChangeInterval = void 0;
}
}
cancel() {
c3893_6.log(`cancel() for ${this.id}`);
if (!this._aborted) {
this._aborted = true;
const _cancel = this._cancel;
if (_cancel != null) {
_cancel.call(this);
}
this.files.forEach((file) => file.cancel());
this._handleComplete();
}
}
async cancelItem(a0) {
let env15525 = {
$parent: env3893
};
env15525[0] = a0;
env15525[1] = this;
let c25723_0, c25723_1, c25723_2;
L15: {
L14: {
let env29675;
const r14 = env15525;
c25723_2 = r14;
const r10 = env29675 = {
$parent: r14
};
c25723_1 = r10;
env29675[0] = void 0;
c3893_6.log(`Cancel called for ${env15525[1].id} for item ${env15525[0]}`);
const r41 = env15525[1].files.find((file) => file.id === env15525[0]);
env29675[0] = r41;
if (r41 == null) {
break L15;
}
if (r41.isCancelled()) {
break L15;
}
const r49 = env15525[1].files.indexOf(r41);
const r50 = env15525[1];
c25723_0 = 0;
const r22 = env15525[1].files.slice(0, r49);
const files2 = [];
c25723_0 = HermesBuiltin.arraySpread(files2, r22, c25723_0);
c25723_0 = HermesBuiltin.arraySpread(files2, env15525[1].files.slice(r49 + 1), c25723_0);
r50.files = files2;
env15525[1]._file = {
...env15525[1]._file,
items: env15525[1].files
};
await cancelGetAttachmentFile(r41);
env29675[0].cancel();
env15525[1].emit("cancel-upload-item", env15525[1]._file);
if (env15525[1].files.length !== 0) {
break L14;
}
env15525[1].cancel();
}
return void 0;
}
}
upload(a0) {
if (this._cancel != null) {
throw new Error("Uploader.upload(...): An upload is already in progress.");
}
this._lastUpdate = Date.now();
this._loaded = 0;
this._file = {
id: this.id,
currentSize: 0,
totalPreCompressionSize: 0,
compressionProgress: 0,
progress: 0,
rate: 0,
hasImage: false,
hasVideo: false,
attachmentsCount: 0,
items: a0
};
}
}
c3893_7 = UploaderBase;
export default UploaderBase;
+89
View File
@@ -0,0 +1,89 @@
// Metro module 6152 (f6153).
import Logger from "../../modules/debug/Logger";
let c3894_1 = new Logger("UploaderQueue.tsx");
class UploaderQueue {
constructor() {
return {
__proto__: new.target.prototype,
queue: [],
drainingQueue: false
};
}
enqueue(a0) {
this.queue.unshift(a0);
c3894_1.log("enqueue() - alreadying draining? " + (this.drainingQueue ? "yes" : "no"));
if (!this.drainingQueue) {
this.drainQueue();
}
}
async drainQueue() {
const _this = this;
let c25724_0, c25724_1, c25724_2;
let c25724_3 = 0;
const r20 = "drainQueue() - No uploads left, setting drainingQueue to false";
const r15 = void 0;
L13: {
L12: {
try {
let env29676;
c25724_1 = r15;
const r36 = env29676 = {};
c25724_0 = r36;
env29676[0] = void 0;
_this.drainingQueue = true;
c3894_1.log(`drainQueue() - starting, queue length: ${_this.queue.length}`);
const r46 = _this.queue.pop();
if (r46 == null) {
c3894_1.log(r20);
_this.drainingQueue = false;
break L13;
}
c25724_3 = 1;
c3894_1.log("drainQueue() - start uploader");
env29676[0] = r46();
await new Promise((resolve) => {
const r4 = env29676[0];
if (r4._aborted || r4._errored) {
resolve();
}
r4.addListener("complete", () => resolve());
r4.addListener("error", () => resolve());
});
c3894_1.log(`drainQueue() Uploader complete - ${env29676[0].id}`);
c25724_3 = 0;
_this.drainQueue();
} catch ($e) {
const r34 = $e;
let r8 = r34;
c25724_2 = r34;
if (c25724_3 !== 0) {
while (true) {
try {
const r107 = c25724_2;
c25724_3 = 0;
env29676[1] = r107;
c3894_1.error(env29676[1]);
_this.drainQueue();
break L12;
} catch (r103) {
r8 = r103;
c25724_2 = r103;
if (c25724_3 === 0) {
break;
}
}
}
}
throw r8;
}
}
return void 0;
}
}
}
const r31 = {
__proto__: UploaderQueue.prototype,
queue: [],
drainingQueue: false
};
export default r31;
+399
View File
@@ -0,0 +1,399 @@
// Metro module 6150 (f6151).
import * as _Module17 from "react-native";
import { AbortCodes, NOOP } from "../../../Constants";
import { DEFAULT_MOBILE_PRE_COMPRESSION_MAX_ATTACHMENT_SIZE, FileUploadErrorTypes } from "../../../modules/messages/MessageConstants";
import Logger from "../../../modules/debug/Logger";
import UploaderBase from "../UploaderBase";
import BackgroundTaskManager_native from "../../../modules/messages/BackgroundTaskManager.native";
import { intl, t } from "../../../intl/index.native";
import { getKestrelConfig, getEffectiveKestrelLimit } from "../../../modules/media_uploads/experiments/KestrelExperiment";
import { getFileSize } from "../../../utils/native/UploadUtils";
import { getUploadTarget } from "../UploadTargets";
import UploaderQueue from "../UploaderQueue";
import { isAndroid } from "../../../utils/PlatformUtils";
import stageAttachmentFiles from "../stageAttachmentFiles";
import { CloudUploadStatus } from "../CloudUpload";
import { UploadPlatform } from "../Upload";
import Module12 from "../../../_bundle/Module12";
function $mk114879($env) {
return () => {
const r2 = $env[0];
r2.startUpload();
return r2;
};
}
function $mk114880($env) {
return (a0) => a0.status === CloudUploadStatus.COMPLETED;
}
let c3892_11, prototype;
let env3892 = {};
const { NativeEventEmitter, NativeModules } = _Module17;
const c3892_8 = new Logger("CloudUploader(Native).tsx");
const c3892_9 = new NativeEventEmitter(NativeModules.MediaManager);
class CloudUploader extends UploaderBase {
mediaEventSubscriptions = new Map();
uploadItems = new Map();
preCompressionFileSizes = [];
async uploadFiles(a0) {
let r40, r116, r202, r241, r256, r281, r345;
let env15519 = {
$parent: env3892
};
env15519[3] = this;
env15519[1] = a0;
env15519[2] = () => {
const r1 = env15519[3];
return Reflect.get(Object.getPrototypeOf(prototype), "upload", r1);
};
env15519[0] = this;
let c25719_0, files, c25719_2, c25719_3, c25719_4;
let c25719_5 = 0;
const r15 = env15519;
L30: {
L29: {
L28: {
L27: {
try {
let env29672;
c25719_3 = r15;
const r50 = env29672 = {
$parent: r15
};
c25719_2 = r50;
env29672[0] = void 0;
env29672[1] = void 0;
env29672[2] = void 0;
env29672[3] = void 0;
env29672[4] = void 0;
env29672[5] = void 0;
env29672[6] = void 0;
env29672[7] = void 0;
env29672[0] = BackgroundTaskManager_native.backgroundTaskIdentifierInvalid;
env15519[0].once("start", async () => {
let c31393_0 = env29672;
env29672[0] = await BackgroundTaskManager_native.startBackgroundTask({
title: intl.string(t["B/HSDd"]),
content: intl.formatToPlainString(t.D0noUt, {
count: env15519[1].length
})
});
if (env15519[0]._aborted) {
BackgroundTaskManager_native.endBackgroundTask(env29672[0]);
}
});
const onCompleteTask = () => {
BackgroundTaskManager_native.endBackgroundTask(env29672[0]);
const r11 = env15519[0];
const r13 = env29672[1];
r11.removeListener("complete", r13);
r11.removeListener("error", r13);
};
env29672[1] = onCompleteTask;
env15519[0].once("error", onCompleteTask);
env15519[0].once("complete", onCompleteTask);
env29672[2] = new Promise((c31394_0, c31394_1) => {
const r4 = env15519[0];
r4.once("error", (a0, a1, a2, a3) => {
c31394_1({
file: a0,
code: a1,
responseBody: a2,
reason: a3
});
});
r4.once("complete", () => {
const r3 = env15519[0];
if (!r3._errored) {
c31394_0(r3.files);
}
});
});
c25719_5 = 1;
const r69 = env15519[0];
const files3 = env15519[1];
r69.files = files3;
(0, env15519[2])().call(env15519[0], files3);
env15519[0]._file.attachmentsCount = files3.length;
env15519[0]._handleStart(void 0);
env29672[3] = getKestrelConfig({
location: "CloudUploader.native.uploadFiles"
});
env29672[4] = 0;
const files2 = env15519[0].files;
files = files2;
const r93 = files2[Symbol.iterator]();
files = r93.next;
c25719_0 = r93;
const r95 = files;
let r96 = c25719_0;
const r97 = r96 === void 0 ? void 0 : (r40 = r95.call(r96)).done ? r96 = void 0 : r40.value;
c25719_0 = r96;
if (r96 === void 0) {
c3892_8.log(`${env15519[0].id} queued`);
UploaderQueue.enqueue($mk114879(env15519));
r116 = env29672[2];
c25719_5 = 0;
break L30;
}
c25719_5 = 2;
env29672[5] = r97;
let r135 = await getFileSize(env29672[5].item.uri);
while (true) {
env29672[6] = r135;
env15519[0].preCompressionFileSizes.push(env29672[6]);
env29672[5].preCompressionSize = env29672[6];
env29672[4] = env29672[4] + env29672[6];
env15519[0]._file.totalPreCompressionSize = env29672[4];
env15519[0]._file.currentSize = env29672[4];
env29672[7] = getUploadTarget(env29672[5].item.target);
if (env29672[6] > Math.max(env29672[7].getMaxFileSize(env29672[5].channelId), DEFAULT_MOBILE_PRE_COMPRESSION_MAX_ATTACHMENT_SIZE)) {
env15519[0]._handleError({
code: AbortCodes.ENTITY_TOO_LARGE,
reason: {
type: FileUploadErrorTypes.PRECOMPRESSION_INDIVIDUAL_FILE_TOO_LARGE
}
});
r202 = env29672[2];
c25719_5 = 1;
const r203 = c25719_0;
if (r203 !== void 0 && typeof r203.return === "function") {
r203.return();
}
c25719_5 = 0;
break L29;
}
if (env29672[3].enabled) {
if (env29672[6] > getEffectiveKestrelLimit(env29672[3], env29672[7].getMaxFileSize(env29672[5].channelId))) {
env15519[0]._handleError({
code: AbortCodes.ENTITY_TOO_LARGE,
reason: {
type: FileUploadErrorTypes.PRECOMPRESSION_INDIVIDUAL_FILE_TOO_LARGE
}
});
r241 = env29672[2];
c25719_5 = 1;
const r242 = c25719_0;
if (r242 !== void 0 && typeof r242.return === "function") {
r242.return();
}
c25719_5 = 0;
break;
}
}
if (env29672[4] > env29672[7].getMaxTotalAttachmentSize()) {
env15519[0]._handleError({
code: AbortCodes.ENTITY_TOO_LARGE,
reason: {
type: FileUploadErrorTypes.PRECOMPRESSION_SUM_TOO_LARGE
}
});
r256 = env29672[2];
c25719_5 = 1;
const r257 = c25719_0;
if (r257 !== void 0 && typeof r257.return === "function") {
r257.return();
}
c25719_5 = 0;
break L28;
}
c25719_5 = 1;
const r259 = files;
let r260 = c25719_0;
const r261 = r260 === void 0 ? void 0 : (r40 = r259.call(r260)).done ? r260 = void 0 : r40.value;
c25719_0 = r260;
if (r260 === void 0) {
c3892_8.log(`${env15519[0].id} queued`);
UploaderQueue.enqueue($mk114879(env15519));
r281 = env29672[2];
c25719_5 = 0;
break L27;
}
c25719_5 = 2;
env29672[5] = r261;
r135 = await getFileSize(env29672[5].item.uri);
}
} catch ($e) {
const r48 = $e;
let r8 = r48;
c25719_4 = r48;
let r49 = c25719_5;
if (r49 !== 0) {
while (true) {
if (r49 === 1) {
try {
const r329 = c25719_4;
c25719_5 = 0;
env29672[8] = r329;
c3892_8.log(`${env15519[0].id} failed in CloudUploader uploadFiles ${env29672[8]}`);
env15519[0]._handleException(env29672[8]);
r345 = env29672[2];
} catch (r326) {
r8 = r326;
c25719_4 = r326;
r49 = c25719_5;
if (r49 === 0) {
break;
}
continue;
}
return r345;
}
try {
const r321 = c25719_4;
c25719_5 = 1;
const r323 = c25719_0;
if (r323 !== void 0 && typeof r323.return === "function") {
try {
r323.return();
} catch {}
}
throw r321;
} catch (r320) {
r8 = r320;
c25719_4 = r320;
r49 = c25719_5;
if (r49 === 0) {
break;
}
}
}
}
throw r8;
}
return r241;
}
return r281;
}
return r256;
}
return r202;
}
return r116;
}
async startUpload() {
const _this = this;
let c25720_0, c25720_1, c25720_2;
let c25720_3 = 0;
const r19 = void 0;
const r18 = env3892;
L28: {
L25: {
L26: {
try {
let env29673;
c25720_1 = r19;
const r40 = env29673 = {
$parent: r18
};
c25720_0 = r40;
if (_this._aborted) {
_this._handleAborted();
break L28;
}
_this._handleStart(NOOP);
c25720_3 = 1;
if (isAndroid()) {
_this.observeCompressionProgress(_this.files);
}
if (await _this.compressAndCheckFileSize()) {
_this.setUploadingTextForUI();
await stageAttachmentFiles(_this.files, true, _this._recomputeProgress.bind(_this));
if (_this.files.length === 0) {
c3892_8.log(`All uploads cancelled for ${_this.id}`);
_this._handleComplete();
c25720_3 = 0;
break L26;
}
if (_this.files.every($mk114880(env3892))) {
const items = _this._file.items;
if (items != null) {
items.forEach((item) => {
item.item.progress = 100;
});
}
_this._file = {
..._this._file,
progress: 100
};
_this.emit("progress", _this._file);
c3892_8.log(`All uploads complete for ${_this.id}`);
_this._handleComplete();
c25720_3 = 0;
break L25;
}
throw new Error("Not all attachments were uploaded successfully");
}
c25720_3 = 0;
} catch ($e) {
const r38 = $e;
let r8 = r38;
c25720_2 = r38;
if (c25720_3 !== 0) {
while (true) {
try {
const r195 = c25720_2;
c25720_3 = 0;
env29673[0] = r195;
_this._handleException(env29673[0]);
break L25;
} catch (r191) {
r8 = r191;
c25720_2 = r191;
if (c25720_3 === 0) {
break;
}
}
}
}
throw r8;
}
return void 0;
}
return void 0;
}
return void 0;
}
}
observeCompressionProgress(a0) {
a0.forEach(({ item }) => {
if (item.platform === UploadPlatform.REACT_NATIVE) {
item.compressionProgress = 0;
this.uploadItems.set(item.uri, item);
}
});
this.mediaEventSubscriptions.set(this._file.id, c3892_9.addListener("compression-progress", ({ uri, progress }) => {
if (this.uploadItems.has(uri)) {
this.uploadItems.get(uri).compressionProgress = progress;
const compressionProgress = Module12.meanBy([...this.uploadItems.values()], "compressionProgress");
if (compressionProgress >= 100) {
const r37 = this.mediaEventSubscriptions.get(this._file.id);
if (r37 != null) {
r37.remove();
}
this.mediaEventSubscriptions.delete(this._file.id);
this.uploadItems.clear();
const items = this._file.items;
if (items != null) {
items.forEach((item) => {
item.item.compressionProgress = 100;
});
}
this._file = {
...this._file,
compressionProgress: 100
};
} else {
this._file = {
...this._file,
compressionProgress
};
}
this.emit("compression-progress", this._file);
}
}));
}
}
const prototype2 = CloudUploader.prototype;
c3892_11 = CloudUploader;
prototype = prototype2;
export default CloudUploader;
@@ -0,0 +1,57 @@
// Metro module 4762 (f4763).
import LocaleStore from "../../../modules/user_settings/LocaleStore";
import AuthenticationStore from "../../../stores/AuthenticationStore";
import DeveloperOptionsStore from "../../../stores/DeveloperOptionsStore";
import { getAttachmentPayload } from "../../../utils/UploadUtils";
import Module12 from "../../../_bundle/Module12";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
export function getUploadPayload(a0) {
return {
filename: a0.filename,
file_size: a0.currentSize,
id: Module12.uniqueId(),
original_content_type: void 0
};
}
const r19 = {
getUploadPayload
};
export default r19;
export function prepareMessagePayload(a0, a1, a2, a3) {
let body;
const attachments = [];
let c14426_0 = attachments;
a1.forEach((item, index) => {
c14426_0.push({
...getAttachmentPayload(item, index)
});
});
if (a3 != null && a2 != null) {
const r8 = {
...a2
};
body = Module12.set(r8, a3, [...Module12.get(r8, a3, []), ...attachments]);
} else {
body = {
...a2,
attachments
};
}
const headers = {
Authorization: a0,
"X-Debug-Options": DeveloperOptionsStore.getDebugOptionsHeaderValue(),
"Accept-Language": LocaleStore.locale
};
const superPropertiesBase64 = AnalyticsUtils.getSuperPropertiesBase64();
if (superPropertiesBase64 != null) {
headers["X-Super-Properties"] = superPropertiesBase64;
}
const fingerprint = AuthenticationStore.getFingerprint();
if (fingerprint != null) {
headers["X-Fingerprint"] = fingerprint;
}
return {
headers,
body
};
}
+76
View File
@@ -0,0 +1,76 @@
// Metro module 6153 (f6154).
import "../../Constants";
function $mk114884($env) {
return (a0) => {
let env31396 = {
$parent: $env
};
env31396[0] = a0;
return new Promise((resolve, reject) => {
let r4;
let c31950_0, c31950_1;
L13: {
c31950_0 = resolve;
c31950_1 = reject;
r4 = env31396[0];
const status = r4.status;
const r13 = env31396.$parent.$parent;
const r8 = r13[0];
const r6 = r13[1];
if (r8(r6[2]).CloudUploadStatus.NOT_STARTED === status) {
r4.upload();
} else if (r8(r6[2]).CloudUploadStatus.COMPLETED === status) {
resolve("complete");
} else if (r8(r6[2]).CloudUploadStatus.ERROR === status) {
if (env31396.$parent[1] && r4.error !== r13[3].ENTITY_TOO_LARGE) {
r4.upload();
break L13;
}
reject(new Error("File failed to upload"));
} else if (r8(r6[2]).CloudUploadStatus.CANCELED === status) {
reject(new Error("Upload is canceled"));
} else if (r8(r6[2]).CloudUploadStatus.REMOVED_FROM_MSG_DRAFT === status) {
reject(new Error("Upload is removed from draft"));
}
}
r4.on("complete", () => {
c31950_0("complete");
});
r4.on("error", () => {
c31950_1(new Error(`File ${env31396[0].id} failed to upload`));
});
r4.on("progress", $mk118754(env31396.$parent));
});
};
}
function $mk118754($env) {
return (a0, a1) => {
const r3 = $env[2];
if (r3 != null) {
r3(a0, a1);
}
};
}
let env3895 = {};
export default async function stageAttachmentFiles(c25725_0, c25725_1, c25725_2) {
let env29677;
const r10 = env29677 = {
$parent: env3895
};
let c25725_3 = r10;
env29677[1] = void 0;
env29677[2] = void 0;
env29677[0] = c25725_0;
if (c25725_1 !== void 0) {
env29677[1] = c25725_1;
env29677[2] = c25725_2;
env29677[3] = void 0;
} else {
env29677[1] = false;
env29677[2] = c25725_2;
env29677[3] = void 0;
}
await void 0;
env29677[3] = env29677[0].map($mk114884(c25725_3));
await Promise.all(env29677[3]);
};
+435
View File
@@ -0,0 +1,435 @@
// Metro module 4770 (f4771).
import Logger from "../../modules/debug/Logger";
import { DiscordImageFactory } from "../../modules/media/web/utils/DiscordImageFactory";
import MurmurHashV3 from "../../_bundle/MurmurHashV3";
function $mk114622($env) {
return (a0) => {
$env[1].toBlob(a0, "image/webp", 1);
};
}
function $mk114623($env) {
return (c31360_0, c31360_1) => {
const r1 = $env;
r1[8].onload = () => c31360_0();
r1[8].onerror = () => c31360_1(new Error("failed to load image"));
r1[8].src = r1[9];
};
}
function $mk114625($env) {
return function performWebPConversion() {
return $env[9].apply(this, arguments);
};
}
let hashImageData, c2920_4, c2920_5;
let env2920 = {};
export async function _shouldConvertToWebP(c25294_0) {
let r79, r96, r97, r98, ALREADY_WEBP, ANIMATED_IMAGE, CONVERSION_FAILED, CORRUPTED_FILE, HAS_TRANSPARENCY, ICC_DETECTION_FAILED, ICC_NON_SRGB_PROFILE, PNG8_FORMAT, UNSUPPORTED_FORMAT;
let c25294_1, c25294_2, c25294_3;
let c25294_4 = 0;
const r21 = env2920;
L34: {
L32: {
L31: {
L30: {
L29: {
L28: {
try {
let env29438;
c25294_2 = r21;
const r48 = env29438 = {};
c25294_1 = r48;
env29438[0] = c25294_0;
env29438[1] = void 0;
env29438[2] = void 0;
if (c25294_0.type === "image/webp") {
c2920_4.verbose("[WebP] File already WebP format");
ALREADY_WEBP = c2920_5.ALREADY_WEBP;
break L34;
}
if (["image/png"].includes(c25294_0.type)) {
c25294_4 = 1;
if (typeof c25294_0.arrayBuffer === "function") {
r79 = await c25294_0.arrayBuffer();
r96 = "[webp] png uses actual transparency - skipping conversion";
r97 = "[webp] png is animated (apng) - skipping conversion";
r98 = "[webp] png is PNG8 format (indexed color) - skipping conversion";
} else {
r79 = await new Promise((c31358_0, c31358_1) => {
const fileReader = new FileReader();
let c31358_2 = fileReader;
fileReader.onload = () => c31358_0(c31358_2.result);
fileReader.onerror = () => c31358_1(new Error("Failed to read file as ArrayBuffer"));
fileReader.readAsArrayBuffer(env29438[0]);
});
r96 = "[webp] png uses actual transparency - skipping conversion";
r97 = "[webp] png is animated (apng) - skipping conversion";
r98 = "[webp] png is PNG8 format (indexed color) - skipping conversion";
}
env29438[1] = r79;
c25294_4 = 2;
const r113 = DiscordImageFactory.create(env29438[1]);
env29438[2] = r113;
if (r113 == null) {
throw new Error("DiscordImage.create returned null");
}
if (env29438[2].hasTransparency()) {
c2920_4.verbose(r96);
HAS_TRANSPARENCY = c2920_5.HAS_TRANSPARENCY;
c25294_4 = 0;
break L32;
}
if (env29438[2].isAnimated()) {
c2920_4.verbose(r97);
ANIMATED_IMAGE = c2920_5.ANIMATED_IMAGE;
c25294_4 = 0;
break L31;
}
if (env29438[2].isPng8()) {
c2920_4.verbose(r98);
PNG8_FORMAT = c2920_5.PNG8_FORMAT;
c25294_4 = 0;
break L30;
}
c25294_4 = 3;
if (await env29438[2].hasSrgbIccProfile()) {
c25294_4 = 0;
break L29;
}
ICC_NON_SRGB_PROFILE = c2920_5.ICC_NON_SRGB_PROFILE;
c25294_4 = 0;
break L28;
}
c2920_4.verbose(`[WebP] Unsupported format: ${c25294_0.type}`);
UNSUPPORTED_FORMAT = c2920_5.UNSUPPORTED_FORMAT;
} catch ($e) {
const r46 = $e;
let r8 = r46;
c25294_3 = r46;
let r47 = c25294_4;
if (r47 !== 0) {
while (true) {
if (r47 === 1) {
try {
const r251 = c25294_3;
c25294_4 = 0;
env29438[3] = r251;
c2920_4.warn("[WebP] Failed to read file data:", env29438[3]);
CONVERSION_FAILED = c2920_5.CONVERSION_FAILED;
} catch (r248) {
r8 = r248;
c25294_3 = r248;
r47 = c25294_4;
if (r47 === 0) {
break;
}
continue;
}
return CONVERSION_FAILED;
}
if (r47 === 2) {
try {
const r237 = c25294_3;
c25294_4 = 0;
env29438[4] = r237;
c2920_4.warn("[WebP] PNG analysis failed:", env29438[4]);
CORRUPTED_FILE = c2920_5.CORRUPTED_FILE;
} catch (r234) {
r8 = r234;
c25294_3 = r234;
r47 = c25294_4;
if (r47 === 0) {
break;
}
continue;
}
return CORRUPTED_FILE;
}
try {
const r223 = c25294_3;
c25294_4 = 0;
env29438[5] = r223;
c2920_4.warn("[WebP] ICC profile detection failed:", env29438[5]);
ICC_DETECTION_FAILED = c2920_5.ICC_DETECTION_FAILED;
} catch (r220) {
r8 = r220;
c25294_3 = r220;
r47 = c25294_4;
if (r47 === 0) {
break;
}
continue;
}
return ICC_DETECTION_FAILED;
}
}
throw r8;
}
return UNSUPPORTED_FORMAT;
}
return ICC_NON_SRGB_PROFILE;
}
return null;
}
return PNG8_FORMAT;
}
return ANIMATED_IMAGE;
}
return HAS_TRANSPARENCY;
}
return ALREADY_WEBP;
}
hashImageData = function hashImageData(a0) {
return MurmurHashV3(new Uint8Array(a0.data.buffer)).toString(16);
};
env2920[9] = function _performWebPConversion() {
const r8 = async (c25295_0) => {
let r397;
let c25295_1, c25295_2, c25295_3;
let c25295_4 = 0;
const r26 = env2920;
try {
let env29439;
c25295_2 = r26;
const r78 = env29439 = {};
c25295_1 = r78;
env29439[0] = c25295_0;
env29439[1] = void 0;
env29439[2] = void 0;
env29439[3] = void 0;
env29439[4] = void 0;
env29439[5] = void 0;
env29439[6] = void 0;
env29439[7] = void 0;
env29439[8] = void 0;
env29439[9] = void 0;
env29439[10] = void 0;
env29439[11] = void 0;
env29439[12] = void 0;
env29439[13] = void 0;
env29439[14] = void 0;
const element = document.createElement("canvas");
env29439[1] = element;
const context = element.getContext("2d");
env29439[2] = context;
if (context == null) {
throw new Error("could not get canvas context");
}
env29439[3] = new Image();
env29439[4] = URL.createObjectURL(c25295_0);
c25295_4 = 1;
await new Promise((c31359_0, c31359_1) => {
const r6 = env29439[3];
r6.onload = () => c31359_0();
r6.onerror = () => c31359_1(new Error("failed to load image"));
r6.src = env29439[4];
});
env29439[1].width = env29439[3].width;
env29439[1].height = env29439[3].height;
env29439[2].drawImage(env29439[3], 0, 0);
c25295_4 = 0;
URL.revokeObjectURL(env29439[4]);
env29439[5] = await new Promise($mk114622(c25295_1));
if (env29439[5] == null) {
throw new Error("failed to convert to webp");
}
env29439[6] = performance.now();
env29439[7] = await env29439[2].getImageData(0, 0, env29439[1].width, env29439[1].height);
env29439[2].clearRect(0, 0, env29439[1].width, env29439[1].height);
env29439[8] = new Image();
env29439[9] = URL.createObjectURL(env29439[5]);
const r263 = c25295_1;
c25295_4 = 2;
await new Promise($mk114623(r263));
env29439[2].drawImage(env29439[8], 0, 0);
c25295_4 = 0;
URL.revokeObjectURL(env29439[9]);
env29439[10] = await env29439[2].getImageData(0, 0, env29439[1].width, env29439[1].height);
env29439[11] = hashImageData(env29439[7]);
env29439[12] = hashImageData(env29439[10]);
env29439[13] = env29439[11] === env29439[12];
env29439[14] = performance.now() - env29439[6];
c2920_4.verbose(`[WebP] Pixel hash results: fileName=${env29439[0].name} fileLength={${env29439[0].size}} width=${env29439[8].width} height=${env29439[8].height} pixelHash=${env29439[11]} mezzanineFileLength={${env29439[5].size}} mezzaninePixelHash=${env29439[12]} match=${env29439[13]} elapsed_ms=${Math.round(env29439[14])}`);
r397 = env29439[13] ? {
success: true,
webpBlob: env29439[5],
pixelHashTimeMs: env29439[14]
} : {
success: false,
reason: c2920_5.PIXEL_HASH_MISMATCH,
pixelHashTimeMs: env29439[14]
};
} catch ($e) {
const r76 = $e;
let r7 = r76;
c25295_3 = r76;
let r77 = c25295_4;
if (r77 !== 0) {
while (true) {
if (r77 === 1) {
try {
const r418 = c25295_3;
c25295_4 = 0;
URL.revokeObjectURL(env29439[4]);
throw r418;
} catch (r416) {
r7 = r416;
c25295_3 = r416;
r77 = c25295_4;
if (r77 === 0) {
break;
}
}
} else {
try {
const r408 = c25295_3;
c25295_4 = 0;
URL.revokeObjectURL(env29439[9]);
throw r408;
} catch (r406) {
r7 = r406;
c25295_3 = r406;
r77 = c25295_4;
if (r77 === 0) {
break;
}
}
}
}
}
throw r7;
}
return r397;
};
env2920[9] = r8;
return r8.apply(this, arguments);
};
c2920_4 = new Logger("WebP");
c2920_5 = {
ALREADY_WEBP: "already_webp",
UNSUPPORTED_FORMAT: "unsupported_format",
ANIMATED_IMAGE: "animated_image",
HAS_TRANSPARENCY: "has_transparency",
PNG8_FORMAT: "png8_format",
INSUFFICIENT_SAVINGS: "insufficient_savings",
CONVERSION_FAILED: "conversion_failed",
CORRUPTED_FILE: "corrupted_file",
PIXEL_HASH_MISMATCH: "pixel_hash_mismatch",
ICC_NON_SRGB_PROFILE: "icc_non_srgb_profile",
ICC_DETECTION_FAILED: "icc_detection_failed",
UNKNOWN_ERROR: "unknown_error"
};
export { c2920_5 as ConversionFailureReason };
export async function maybeConvertToWebP(c25296_0) {
let r110, r191, r229, r255;
let reason, c25296_2, c25296_3, c25296_4;
let c25296_5 = 0;
const r22 = env2920;
L27: {
L26: {
L23: {
try {
let env29440;
c25296_3 = r22;
const r30 = env29440 = {
$parent: r22
};
c25296_2 = r30;
env29440[0] = c25296_0;
env29440[1] = void 0;
env29440[2] = void 0;
env29440[4] = void 0;
env29440[5] = void 0;
env29440[6] = void 0;
env29440[7] = void 0;
env29440[8] = void 0;
env29440[3] = function createFailedResult(a0, sizeAfter = env29440[0].size) {
const originalFile = env29440[0];
return {
success: false,
originalFile,
sizeBefore: originalFile.size,
sizeAfter,
compressionRatio: originalFile.size > 0 ? sizeAfter / originalFile.size : 1,
reason: a0,
compressTimeMs: Math.round(performance.now() - env29440[2])
};
};
if (c25296_0 == null) {
throw new Error("file is null or undefined");
}
c2920_4.verbose(`[WebP] Starting conversion for: ${c25296_0.name}`);
env29440[2] = performance.now();
c25296_5 = 1;
env29440[4] = await _shouldConvertToWebP(c25296_0);
if (env29440[4] != null) {
c2920_4.verbose(`[WebP] Conversion rejected: ${env29440[4]}`);
r110 = (0, env29440[3])(env29440[4]);
c25296_5 = 0;
break L27;
}
const r113 = env29440[0];
env29440[5] = await $mk114625(env2920)(r113);
if (env29440[5].success && env29440[5].webpBlob != null) {
env29440[6] = env29440[5].webpBlob;
env29440[7] = env29440[0].size > 0 ? env29440[6].size / env29440[0].size : 1;
env29440[8] = 1 - env29440[7];
if (env29440[8] < 0) {
c2920_4.verbose(`[WebP] Insufficient savings: ${Math.round(100 * env29440[8])}% < 0% (${env29440[0].size} -> ${env29440[6].size} bytes)`);
r191 = (0, env29440[3])(c2920_5.INSUFFICIENT_SAVINGS, env29440[6].size);
} else {
env29440[1] = performance.now() - env29440[2];
c2920_4.verbose(`[WebP] Conversion successful: ${env29440[0].name} to WebP in ${Math.round(env29440[1])}ms`);
r191 = {
success: true,
originalFile: env29440[0],
convertedBlob: env29440[6],
sizeBefore: env29440[0].size,
sizeAfter: env29440[6].size,
compressionRatio: env29440[7],
hashTimeMs: env29440[5].pixelHashTimeMs,
compressTimeMs: Math.round(env29440[1])
};
}
c25296_5 = 0;
break L23;
}
const r151 = env29440[3];
reason = env29440[5].reason;
if (reason == null) {
reason = c2920_5.UNKNOWN_ERROR;
}
r229 = r151(reason);
c25296_5 = 0;
break L26;
} catch ($e) {
const r51 = $e;
let r8 = r51;
c25296_4 = r51;
if (c25296_5 !== 0) {
while (true) {
try {
const r241 = c25296_4;
c25296_5 = 0;
env29440[9] = r241;
c2920_4.error(`[WebP] Conversion failed for ${env29440[0].name}:`, env29440[9]);
r255 = (0, env29440[3])(c2920_5.CONVERSION_FAILED);
} catch (r237) {
r8 = r237;
c25296_4 = r237;
if (c25296_5 === 0) {
break;
}
continue;
}
return r255;
}
}
throw r8;
}
}
return r191;
}
return r229;
}
return r110;
}
+71
View File
@@ -0,0 +1,71 @@
// Metro module 7949 (f7950).
import DiscordMd5 from "../../modules/discord_md5/DiscordMd5";
import { ORIGINAL_MD5_HEADER } from "./originalMd5Header";
let c5020_4 = /^[a-f0-9]{32}$/;
class InlineUploader {
constructor(a0, a1) {
this.surface = a0;
this.originalMd5Promise = a1;
}
static fromBlob(a0, a1) {
const originalMd5Promise = DiscordMd5.fromBlob(a1).catch(() => null);
const r18 = {
__proto__: InlineUploader.prototype
};
r18.surface = a0;
r18.originalMd5Promise = originalMd5Promise;
return r18;
}
getOriginalMd5() {
return this.originalMd5Promise;
}
static buildHeadersForMd5(a0, a1) {
const r5 = (function serializeOriginalMd5Header(a0) {
if (a0 == null) {
return null;
}
if (typeof a0 === "string") {
return c5020_4.test(a0) ? a0 : null;
}
const r6 = [];
for (const item of Object.keys(a0)) {
const r31 = a0[item];
if (r31 != null && c5020_4.test(r31)) {
r6.push([item, r31]);
}
}
const length = r6.length;
let r43 = null;
if (length !== 0) {
r6.sort((a, b) => {
const [r14] = a;
const [r20] = b;
return r14 < r20 ? -1 : r14 > r20 ? 1 : 0;
});
r43 = r6.map((item) => {
const [r26, r8] = item;
return `${r26.toLowerCase()}="${r8}"`;
}).join(", ");
}
return r43;
})(a0);
let r9 = a1;
if (r5 != null) {
const r10 = {
...a1
};
r10[ORIGINAL_MD5_HEADER] = r5;
r9 = r10;
}
return r9;
}
async buildHeaders(c16123_0) {
const _this = this;
let c26066_2;
c26066_2 = void 0;
let c26066_1 = InlineUploader;
const buildHeadersForMd52 = InlineUploader.buildHeadersForMd5;
return buildHeadersForMd52.call(c26066_1, await _this.originalMd5Promise, c16123_0);
}
}
export default InlineUploader;
@@ -0,0 +1,2 @@
// Metro module 7950 (f7951).
export const ORIGINAL_MD5_HEADER = "X-Discord-Original-MD5";
@@ -0,0 +1,27 @@
// Metro module 7946 (f7947).
import { UploadTypes } from "../../modules/image_cropping/web/ImageCroppingConstants";
let c5019_1 = {
USER_DEFAULT_PROFILE_AVATAR: "USER_DEFAULT_PROFILE_AVATAR",
USER_DEFAULT_PROFILE_BANNER: "USER_DEFAULT_PROFILE_BANNER",
USER_GUILD_PROFILE_AVATAR: "USER_GUILD_PROFILE_AVATAR",
USER_GUILD_PROFILE_BANNER: "USER_GUILD_PROFILE_BANNER",
GUILD_ICON: "GUILD_ICON",
GUILD_BANNER: "GUILD_BANNER",
GUILD_DISCOVERY_SPLASH: "GUILD_DISCOVERY_SPLASH",
GUILD_INVITE_SPLASH: "GUILD_INVITE_SPLASH",
EMOJI: "EMOJI",
STICKER: "STICKER"
};
export { c5019_1 as SafetyScannedUploadSurface };
export function getSafetyScannedUploadSurfaceForProfileCustomization(a0, a1) {
if (UploadTypes.AVATAR === a0) {
return a1 != null ? c5019_1.USER_GUILD_PROFILE_AVATAR : c5019_1.USER_DEFAULT_PROFILE_AVATAR;
}
if (UploadTypes.BANNER === a0) {
return a1 != null ? c5019_1.USER_GUILD_PROFILE_BANNER : c5019_1.USER_DEFAULT_PROFILE_BANNER;
}
if (UploadTypes.GUILD_BANNER !== a0 && UploadTypes.VIDEO_BACKGROUND !== a0 && UploadTypes.SCHEDULED_EVENT_IMAGE !== a0 && UploadTypes.HOME_HEADER !== a0 && UploadTypes.AVATAR_DECORATION !== a0 && UploadTypes.GUILD_ICON !== a0) {
return void 0;
}
return null;
}
+112
View File
@@ -0,0 +1,112 @@
// Metro module 16733 (f16734).
export function installWebsocketTelemetryHook(c23398_0) {
let globalThis2;
let WebSocket2;
const handleMessage2 = function handleMessage(a0, a1) {
const r2 = {};
const url = (function sanitizeUrl(a0) {
let r21;
L11: {
L9: {
try {
const uRL = new URL(a0);
const { hostname, pathname } = uRL;
if (hostname == null) {
break L11;
}
if (hostname !== "") {
if (pathname != null && pathname !== "" && pathname !== "/") {
r21 = `${hostname}${pathname}`;
break L9;
}
r21 = hostname;
break L9;
}
break L11;
} catch ($e) {
break L11;
}
}
return r21;
}
const r28 = a0.split("?")[0];
return r28 !== "" ? r28 : null;
})(a0);
if (url != null) {
r2.url = url;
}
let r11 = false;
if (typeof a1 === "string" && a1.length > 0 && a1[0] === "{") {
try {
const r17 = JSON.parse(a1);
if (r17 != null && typeof r17 === "object") {
if (r17.op != null) {
r2.op = r17.op;
}
if (r17.s != null) {
r2.s = r17.s;
}
if (r17.t != null) {
r2.t = r17.t;
}
if (r17.type != null) {
r2.type = r17.type;
}
if (r17.evt != null) {
r2.evt = r17.evt;
}
if (r17.cmd != null) {
r2.cmd = r17.cmd;
}
r11 = true;
}
} catch ($e) {}
}
if (!r11) {
r11 = a1 == null;
}
if (!r11) {
r11 = typeof a1 === "string";
}
if (!r11) {
r2.type = "binary";
}
try {
c23398_0(r2);
} catch ($e) {}
};
if (typeof globalThis.globalThis !== "undefined") {
globalThis2 = globalThis.globalThis;
} else {
globalThis2 = global;
if (global === void 0) {
globalThis2 = typeof globalThis.window !== "undefined" ? window : null;
}
}
if (globalThis2?.WebSocket != null && !globalThis2.__discordWebsocketTelemetryPatched) {
WebSocket2 = globalThis2.WebSocket;
const PatchedWebSocket = function PatchedWebSocket(...args) {
let r15;
const webSocket2 = new WebSocket2(...[...args]);
if (typeof args[0] === "string") {
r15 = args[0];
} else {
r15 = webSocket2.url;
if (r15 == null) {
r15 = "";
}
}
let c28511_0 = r15;
if (typeof webSocket2.addEventListener === "function") {
webSocket2.addEventListener("message", (a0) => {
handleMessage2(c28511_0, a0?.data);
});
}
return webSocket2;
};
PatchedWebSocket.prototype = WebSocket2.prototype;
Object.assign(PatchedWebSocket, WebSocket2);
globalThis2.WebSocket = PatchedWebSocket;
globalThis2.__discordWebsocketTelemetryPatched = true;
}
}
+21
View File
@@ -0,0 +1,21 @@
// Metro module 12861 (f12862).
export default function zipWithNext(a0, a1) {
let length;
if (a0.length < 2) {
return [];
}
const r12 = [];
let r7 = a0[0];
const r4 = 1 < a0.length;
let r13 = 1;
if (r4) {
do {
const r10 = a0[r13];
r12.push(a1(r7, r10));
r13 = r13 + 1;
length = a0.length;
r7 = r10;
} while (r13 < length);
}
return r12;
};