Files
discord-decomp/sources/lib/VoiceDuration.tsx
T
2026-07-28 01:06:53 +03:00

320 lines
18 KiB
TypeScript

/* Metro module 12405; source: lib/VoiceDuration.tsx; dependencies: [6, 7, 4303, 4464, 2] */
import ClassCallCheck from '../by-id/module-00006-ClassCallCheck.js'; /* Metro dependency 6 */
import CreateClass from '../by-id/module-00007-CreateClass.js'; /* Metro dependency 7 */
import * as FileImportTrackerModule from '../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as BaseConnectionEventModule from '../external/discord_common/js/packages/media-engine/BaseConnectionEvent.tsx'; /* Metro dependency 4464 */
function _fun94577(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#94577, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:6, offset: 0x0211dd63, size: 162 bytes, params: 8, frame: 19
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_4 = [1, 100, 1000, 10000];
const env0_5 = [100, 500, 1000, 5000];
const value = _fun94578();
(FileImportTrackerModule).fileFinishedImporting('lib/VoiceDuration.tsx');
exports.default = value;
function _fun94578() { // fn#94578, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:156, offset: 0x0211de05, size: 313 bytes, params: 1, frame: 15
return CreateClass(VoiceDuration, [{key: 'start', value: value_94580}, {key: 'onSpeaking', value: value_94584},
{key: 'onListening', value: value_94585}, {key: 'onMuted', value: function(a0) {
var muted = this.muted;
if (a0) {
muted.start();
} else {
muted.stop();
}
}}, {key: 'onDeafened', value: function(a0) {
var deafened = this.deafened;
if (a0) {
deafened.start();
} else {
deafened.stop();
}
}}, {key: 'computeSpeakingDurationMilestones', value: value_94588}, {key: 'addSpeechChunk', value: value_94592},
{key: 'setNoiseCancellationEnabled', value: function(a0) {
this.noiseCancellation.value = a0;
}}, {key: 'setSpatialAudioEnabled', value: function(a0) {
this.spatialAudio.value = a0;
}}, {key: 'stop', value: value_94597}, {key: 'getDurationStats', value: value_94598}]);
function VoiceDuration(a0, a1) { // fn#94579, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:177, offset: 0x0211df3e, size: 634 bytes, params: 3, frame: 19
let value = a2;
const r4 = value !== undefined ? value : (require(4303) /* metro dependency 4303: TimeUtils */).TimeStampProducer;
value = environment.__proto__;
env1_2(this, VoiceDuration);
this.userId = a0;
this.connection = a1;
this.timestampProducer = r4;
const Set = global.Set;
const value3 = Object.create(Set.prototype, {constructor: {value: Set}});
const set = new Set();
this.listeningUsers = set instanceof Object ? set : value3;
let Map = global.Map;
const value5 = Object.create(Map.prototype, {constructor: {value: Map}});
let map = new Map();
this.timesUntilSpeakingDurationMilestonesMs = map instanceof Object ? map : value5;
Map = global.Map;
const value7 = Object.create(Map.prototype, {constructor: {value: Map}});
map = new Map();
this.speakingMinimumChunks = map instanceof Object ? map : value7;
Map = global.Map;
const value9 = Object.create(Map.prototype, {constructor: {value: Map}});
map = new Map();
this.speakingMinimumChunkCounts = map instanceof Object ? map : value9;
this.speechEventCount = 0;
const StopWatch = (require(4303) /* metro dependency 4303: TimeUtils */).StopWatch;
let timestampProducer = this.timestampProducer;
let stopWatch = new StopWatch(timestampProducer);
this.listening = stopWatch;
this.speaking = new StopWatch(this.timestampProducer);
this.participation = new StopWatch(this.timestampProducer);
this.connected = new StopWatch(this.timestampProducer);
this.muted = new StopWatch(this.timestampProducer);
this.deafened = new StopWatch(this.timestampProducer);
const DurationEnabled = (require(4303) /* metro dependency 4303: TimeUtils */).DurationEnabled;
stopWatch = a1.getNoiseCancellation();
timestampProducer = this.timestampProducer;
const value11 = Object.create(DurationEnabled.prototype, {constructor: {value: DurationEnabled}});
let durationEnabled = new DurationEnabled(stopWatch, timestampProducer);
this.noiseCancellation = durationEnabled instanceof Object ? durationEnabled : value11;
stopWatch = a1.getSpatialAudioEnabled();
timestampProducer = this.timestampProducer;
const value12 = Object.create(DurationEnabled.prototype, {constructor: {value: DurationEnabled}});
durationEnabled = new DurationEnabled(stopWatch, timestampProducer);
this.spatialAudio = durationEnabled instanceof Object ? durationEnabled : value12;
}
function value_94580() { // fn#94580, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:1082, offset: 0x0211e1b8, size: 420 bytes, params: 1, frame: 21
var environment;
let value = a0;
const value2 = a1;
const r8 = value !== undefined ? value : false;
const r7 = value2 !== undefined ? value2 : 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();
let connection = this.connection;
let on = connection.on;
value = environment.__proto__;
const BaseConnectionEvent = (BaseConnectionEventModule).BaseConnectionEvent;
const Speaking = BaseConnectionEvent.Speaking;
Reflect.apply(on, connection, [Speaking, _fun94581]);
this.onMuted(r8);
this.onDeafened(r7);
connection = this.connection;
on = connection.on;
const Mute = BaseConnectionEvent.Mute;
Reflect.apply(on, connection, [Mute, _fun94582]);
connection = this.connection;
on = connection.on;
const Deafen = BaseConnectionEvent.Deafen;
Reflect.apply(on, connection, [Deafen, _fun94583]);
function _fun94581(a0, a1) { // fn#94581, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:1554, offset: 0x0211e35c, size: 75 bytes, params: 3, frame: 15
const userId = env0_0.userId;
if (userId === a0) {
env0_0.onSpeaking(a1 !== 0);
} else {
env0_0.onListening(a1 !== 0, a0);
}
}
function _fun94582(a0) { // fn#94582, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:1718, offset: 0x0211e3a7, size: 25 bytes, params: 2, frame: 11
env0_0.onMuted(a0);
}
function _fun94583(a0) { // fn#94583, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:1796, offset: 0x0211e3c0, size: 25 bytes, params: 2, frame: 11
env0_0.onDeafened(a0);
}
}
function value_94588(a0, a1, a2) { // fn#94588, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:2646, offset: 0x0211e567, size: 132 bytes, params: 4, frame: 13
var environment;
var value;
const env0_1 = a0;
const env0_2 = a1;
const env0_3 = a2;
if (a0 != null) {
if (a1 != null) {
value = this.speaking.elapsed();
var env0_4 = value.asMilliseconds();
value = environment.__proto__;
value = env1_4.filter(_fun94589);
value = value.filter(_fun94590);
value.forEach(_fun94591);
}
}
function _fun94589(a0) { // fn#94589, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:2740, offset: 0x0211e5eb, size: 31 bytes, params: 2, frame: 11
const timesUntilSpeakingDurationMilestonesMs = env0_0.timesUntilSpeakingDurationMilestonesMs;
return !timesUntilSpeakingDurationMilestonesMs.has(a0);
}
function _fun94590(a0) { // fn#94590, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:2805, offset: 0x0211e60a, size: 16 bytes, params: 2, frame: 2
return env0_4 >= a0;
}
function _fun94591(a0) { // fn#94591, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:2824, offset: 0x0211e61a, size: 55 bytes, params: 2, frame: 15
const timesUntilSpeakingDurationMilestonesMs = env0_0.timesUntilSpeakingDurationMilestonesMs;
timesUntilSpeakingDurationMilestonesMs.set(a0, require - env0_1 + a0 - importDefault);
}
}
function value_94592() { // fn#94592, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:2921, offset: 0x0211e651, size: 95 bytes, params: 1, frame: 12
var environment;
var timestampProducer;
var value;
const lastStartTime = this.speaking.lastStartTime;
if (lastStartTime != null) {
timestampProducer = this.timestampProducer;
var env0_1 = timestampProducer.now() - lastStartTime;
value = environment.__proto__;
value = env1_5.filter(_fun94593);
value.forEach(_fun94594);
}
function _fun94593(a0) { // fn#94593, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:3025, offset: 0x0211e6b0, size: 16 bytes, params: 2, frame: 2
return env0_1 >= a0;
}
function _fun94594(a0) { // fn#94594, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:3044, offset: 0x0211e6c0, size: 129 bytes, params: 2, frame: 18
const value2 = env0_0.speakingMinimumChunks.get(a0);
const value3 = 0;
const r8 = value2 ?? value3;
const binding = env0_0;
binding.speakingMinimumChunks.set(a0, r8 + env0_1);
env0_0.speakingMinimumChunkCounts.set(a0, (binding.speakingMinimumChunkCounts.get(a0) ?? value3) + 1);
}
}
function value_94598() { // fn#94598, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:3804, offset: 0x0211e819, size: 464 bytes, params: 1, frame: 17
var environment;
const lastStartTime = this.speaking.lastStartTime;
let value = this.timestampProducer.now();
if (lastStartTime != null) {
value -= lastStartTime;
}
this.computeSpeakingDurationMilestones(this.connected.lastStartTime, this.speaking.lastStartTime,
this.speaking.lastElapsed);
const object = {};
object.duration_listening_ms = this.listening.elapsed().asMilliseconds();
object.duration_speaking_ms = this.speaking.elapsed().asMilliseconds();
object.duration_participation_ms = this.participation.elapsed().asMilliseconds();
object.duration_connected_ms = this.connected.elapsed().asMilliseconds();
object.duration_muted_ms = this.muted.elapsed().asMilliseconds();
object.duration_deafened_ms = this.deafened.elapsed().asMilliseconds();
object.duration_noise_cancellation_enabled_ms = this.noiseCancellation.totalDuration();
object.duration_spatial_ms = this.spatialAudio.totalDuration();
object.speech_event_count = this.speechEventCount;
value = environment.__proto__;
const value3 = env1_4.filter(_fun94599);
copyDataProperties(object, value3.reduce(_fun94600, {}), undefined);
value = env1_5.filter(_fun94601);
copyDataProperties(object, value.reduce(_fun94602, {}), undefined);
return object;
function _fun94599(a0) { // fn#94599, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:4593, offset: 0x0211e9e9, size: 28 bytes, params: 2, frame: 11
return env0_0.timesUntilSpeakingDurationMilestonesMs.has(a0);
}
function _fun94600(a0, a1) { // fn#94600, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:4657, offset: 0x0211ea05, size: 76 bytes, params: 3, frame: 14
const object = {};
copyDataProperties(object, a0, a1);
const value = 'time_to_first_' + a1 + 'ms_speech_ms';
const timesUntilSpeakingDurationMilestonesMs = env0_0.timesUntilSpeakingDurationMilestonesMs;
const get = timesUntilSpeakingDurationMilestonesMs.get;
object[value] = Reflect.apply(get, timesUntilSpeakingDurationMilestonesMs, [a1]);
return object;
}
function _fun94601(a0) { // fn#94601, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:4777, offset: 0x0211ea51, size: 39 bytes, params: 2, frame: 12
return env0_0.speakingMinimumChunks.has(a0) || env0_1 >= a0;
}
function _fun94602(a0, a1) { // fn#94602, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:4830, offset: 0x0211ea78, size: 195 bytes, params: 3, frame: 19
const object = {};
copyDataProperties(object, a0, undefined);
const value = 'duration_speaking_gte_' + a1 + 'ms_ms';
const value3 = env0_0.speakingMinimumChunks.get(a1);
const value4 = 0;
object[value] = (value3 ?? value4) + (env0_1 >= a1 ? env0_1 : value4);
object['speech_event_count_gte_' + a1 + 'ms'] = (env0_0.speakingMinimumChunkCounts.get(a1) ?? value4) + (env0_1 >= a1 ? 1 : value4);
return object;
}
}
}
}
function value_94584(a0) { // fn#94584, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:1848, offset: 0x0211e3d9, size: 170 bytes, params: 2, frame: 16
var lastStartTime;
var speaking;
var lastStartTime2;
var lastElapsed;
var listening;
var speechEventCount;
if (a0) {
this.speaking.start();
this.participation.start();
speechEventCount = this.speechEventCount;
this.speechEventCount = typeof speechEventCount === 'bigint' ? speechEventCount + 1n : +speechEventCount + 1;
} else {
lastStartTime = this.connected.lastStartTime;
speaking = this.speaking;
lastStartTime2 = speaking.lastStartTime;
speaking = this.speaking;
lastElapsed = speaking.lastElapsed;
this.addSpeechChunk();
speaking = this.speaking;
speaking.stop();
listening = this.listening;
if (!listening.isRunning()) {
this.participation.stop();
}
this.computeSpeakingDurationMilestones(lastStartTime, lastStartTime2, lastElapsed);
}
}
function value_94585(a0, a1) { // fn#94585, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:2207, offset: 0x0211e483, size: 148 bytes, params: 3, frame: 14
var speaking;
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();
speaking = this.speaking;
if (!speaking.isRunning()) {
this.participation.stop();
}
}
}
function value_94597() { // fn#94597, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12591:3432, offset: 0x0211e76d, size: 172 bytes, params: 1, frame: 16
this.addSpeechChunk();
const lastStartTime = this.connected.lastStartTime;
const lastStartTime2 = 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(lastStartTime, lastStartTime2, lastElapsed);
}
global.__d(_fun94577, 12405, [6, 7, 4303, 4464, 2]) /* metro module 12405, dependencies: [6, 7, 4303, 4464, 2] */;