decord/source/lib/VoiceStateAnalytics.tsx
github-actions e510164e6b chore: update source for alpha 346.2
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4759.js (118.4 MB)
2026-09-10 05:38:07 +00:00

133 lines
5.1 KiB
TypeScript

// Module ID: 13850
// Function ID: 13851
// Name: VoiceStateAnalytics
// Dependencies: [1908, 4593, 4598, 4599, 12, 2]
// Module 13850 (VoiceStateAnalytics)
import _mod12 from "module_12" /* 12 */;
import MediaEngineStore from "MediaEngineStore" /* 1908 */;
import VoiceStateStore from "VoiceStateStore" /* 4593 */;
import SortedVoiceStateStore from "SortedVoiceStateStore" /* 4598 */;
require = fn;
const SpeakingFlags = fn(4599).SpeakingFlags;
const size = fn(2);
const result = size.fileFinishedImporting("lib/VoiceStateAnalytics.tsx");
class VoiceStateAnalytics {
constructor(arg0, arg1) {
merged = Object.assign({ maxVoiceStateCount: 1, totalParticipants: null, speaking: null, maxListenerCount: 0, totalListeners: null, maxSpeakerCount: 0, totalSpeakers: null });
set = new Set();
merged[1] = set;
merged[2] = SpeakingFlags.NONE;
set1 = new Set();
merged[4] = set1;
merged[6] = {};
merged.userId = global;
setChannelIdResult = merged.setChannelId(fn);
return merged;
}
}
const prototype = VoiceStateAnalytics.prototype;
prototype["updateVoiceStates"] = function updateVoiceStates(userId, channelId) {
const self = this;
if (channelId === this.channelId) {
const totalParticipants = self.totalParticipants;
totalParticipants.add(userId);
const _Math = Math;
self.maxVoiceStateCount = Math.max(SortedVoiceStateStore.countVoiceStatesForChannel(channelId), self.maxVoiceStateCount);
} else {
if (tmp2) {
self.totalSpeakers[userId] = SpeakingFlags.NONE;
}
if (tmp4) {
self.setChannelId(channelId);
}
tmp2 = null == channelId && userId in self.totalSpeakers;
tmp4 = userId === self.userId && null != channelId;
}
};
prototype["getStats"] = function 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 };
};
prototype["getUserVoiceSettingsStats"] = function getUserVoiceSettingsStats(arg0) {
const settings = MediaEngineStore.getSettings(arg0);
const set = new Set(Object.keys(settings.localMutes));
const set1 = new Set(Object.keys(settings.localVolumes));
set1.delete(this.userId);
set.delete(this.userId);
const obj = { num_local_voice_user_mutes: null, num_local_voice_volumes: null };
const obj4 = _mod12;
obj.num_local_voice_user_mutes = obj4.intersection(Array.from(set), Array.from(this.totalParticipants)).length;
const arr = Array.from(set);
const obj5 = _mod12;
obj.num_local_voice_volumes = obj5.intersection(Array.from(set1), Array.from(this.totalParticipants)).length;
return obj;
};
prototype["setSpeaking"] = function setSpeaking(userId, speaking) {
const self = this;
if (speaking !== SpeakingFlags.NONE) {
const voiceStateForChannel = VoiceStateStore.getVoiceStateForChannel(self.channelId, userId);
if (null != voiceStateForChannel) {
if (!voiceStateForChannel.selfMute) {
if (!voiceStateForChannel.mute) {
self.totalSpeakers[userId] = speaking;
const _Object = Object;
const values = Object.values(self.totalSpeakers);
const _Math = Math;
self.maxSpeakerCount = Math.max(self.maxSpeakerCount, values.filter((item) => item !== constants.NONE).length);
}
}
}
} else if (userId in self.totalSpeakers) {
self.totalSpeakers[userId] = tmp.NONE;
}
if (self.userId === userId) {
if (speaking !== self.speaking) {
if (speaking !== tmp.NONE) {
const _Object2 = Object;
const values2 = Object.values(VoiceStateStore.getVoiceStatesForChannel(self.channelId));
const found = values2.filter((selfDeaf) => {
selfDeaf = selfDeaf.selfDeaf;
let tmp = !selfDeaf;
if (!selfDeaf) {
tmp = !selfDeaf.deaf;
}
return tmp;
});
const item = found.forEach((userId) => {
const totalListeners = self.totalListeners;
return totalListeners.add(userId.userId);
});
const _Math2 = Math;
self.maxListenerCount = Math.max(found.length, self.maxListenerCount);
}
self.speaking = speaking;
}
}
};
prototype["setChannelId"] = function setChannelId(channelId) {
const self = this;
if (channelId !== this.channelId) {
self.channelId = channelId;
const _Set = Set;
const items = [self.userId];
const set = new Set(items);
self.totalParticipants = set;
const _Object = Object;
const keys = Object.keys(VoiceStateStore.getVoiceStatesForChannel(self.channelId));
const item = keys.forEach((item) => {
const totalParticipants = self.totalParticipants;
return totalParticipants.add(item);
});
self.maxVoiceStateCount = keys.length;
self.speaking = SpeakingFlags.NONE;
self.maxListenerCount = 0;
const _Set2 = Set;
const set1 = new Set();
self.totalListeners = set1;
self.maxSpeakerCount = 0;
self.totalSpeakers = {};
}
};
export default VoiceStateAnalytics;