decord/source/stores/SpeakingStore.tsx

427 lines
12 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 5244
// Function ID: 5245
2026-07-29 08:29:29 +00:00
// Name: anyoneHasFlagInContext
2026-08-25 06:04:03 +00:00
// Dependencies: [32, 1391, 4431, 4454, 1981, 676, 4444, 4030, 589, 5245, 709, 2]
2026-07-20 16:05:17 +00:00
2026-08-25 06:04:03 +00:00
// Module 5244 (anyoneHasFlagInContext)
2026-08-24 06:08:38 +00:00
import initializeDefault from "initialize" /* 589 */;
import dispatcherDefault from "dispatcher" /* 709 */;
2026-08-25 06:04:03 +00:00
import applyOverwritesAll from "applyOverwrites" /* 4030 */;
import getUnitIdDefault from "getUnitId" /* 5245 */;
2026-08-24 06:08:38 +00:00
import closure_3 from "_slicedToArray" /* 32 */;
import closure_4 from "ensureGuildLoaded" /* 1391 */;
2026-08-25 06:04:03 +00:00
import closure_5 from "_detectH265HardwareDecode" /* 4431 */;
import closure_6 from "createRTCConnection" /* 4454 */;
import closure_7 from "handleConnectionOpen" /* 1981 */;
2026-08-24 06:08:38 +00:00
import { Permissions } from "ME" /* 676 */;
2026-08-25 06:04:03 +00:00
import DesktopSources from "DesktopSources" /* 4444 */;
2026-07-23 10:11:24 +00:00
2026-07-29 08:29:29 +00:00
function anyoneHasFlagInContext(DEFAULT, VOICE, arg2) {
let flag = arg2;
if (arg2 === undefined) {
flag = false;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const value = map.get(DEFAULT);
if (null == value) {
return false;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
const obj = value[Symbol.iterator]();
while (obj !== undefined) {
let tmp6 = callback;
let tmp7 = callback(tmp4, 2);
let first = tmp7[0];
let flags = tmp7[1].flags;
if (!flag) {
let tmp11 = flags;
if ((flags & VOICE) === VOICE) {
let tmp12 = obj;
obj.return();
let flag2 = true;
return true;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
} else {
let tmp9 = first;
let tmp10 = c12;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return false;
}
}
function handleConnectionOpen(user) {
const id = user.user.id;
const sessionId = user.sessionId;
2026-08-24 06:08:38 +00:00
c14 = null;
2026-07-29 08:29:29 +00:00
}
({ SpeakingFlags: c9, MediaEngineContextTypes: c10 } = DesktopSources);
let map = new Map();
let c12 = null;
let c13 = null;
let c14 = null;
let c15 = false;
2026-08-24 06:08:38 +00:00
const Store = initializeDefault.Store;
2026-07-29 08:29:29 +00:00
class SpeakingStore extends Store {
}
const prototype = SpeakingStore.prototype;
prototype["initialize"] = function initialize() {
this.mustEmitChanges((type) => {
let tmp = "CONNECTION_OPEN" !== type.type;
2026-07-20 16:05:17 +00:00
if (tmp) {
2026-07-29 08:29:29 +00:00
tmp = "VOICE_STATE_UPDATES" !== type.type;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp;
});
2026-08-24 06:08:38 +00:00
this.waitFor(closure_4, closure_5, closure_6, closure_7);
2026-07-29 08:29:29 +00:00
};
prototype["getSpeakingDuration"] = function getSpeakingDuration(id, timestamp) {
let DEFAULT = arg2;
if (arg2 === undefined) {
DEFAULT = constants2.DEFAULT;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let value = map.get(DEFAULT);
let since;
if (value != null) {
value = value.get(id);
if (value != null) {
since = value.since;
}
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let num = 0;
if (null != since) {
num = timestamp - since;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return num;
};
prototype["getSpeakers"] = function getSpeakers() {
let DEFAULT = arg0;
if (arg0 === undefined) {
DEFAULT = constants2.DEFAULT;
}
let value = map.get(DEFAULT);
let keys;
if (value != null) {
keys = value.keys();
}
if (keys == null) {
keys = [];
}
return Array.from(keys).filter((arg0) => {
2026-08-24 06:08:38 +00:00
const VOICE = closure_1_9.VOICE;
let value = closure_1_11.get(DEFAULT);
2026-07-29 08:29:29 +00:00
let flags;
if (value != null) {
value = value.get(arg0);
if (value != null) {
flags = value.flags;
}
}
if (flags == null) {
2026-08-24 06:08:38 +00:00
flags = closure_1_9.NONE;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return (flags & VOICE) === VOICE;
});
};
prototype["isSpeaking"] = function isSpeaking(c12, DEFAULT) {
if (DEFAULT === undefined) {
DEFAULT = constants2.DEFAULT;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const VOICE = constants.VOICE;
let value = map.get(DEFAULT);
2026-07-20 16:05:17 +00:00
let flags;
2026-07-29 08:29:29 +00:00
if (value != null) {
value = value.get(c12);
if (value != null) {
2026-07-20 16:05:17 +00:00
flags = value.flags;
}
}
2026-07-29 08:29:29 +00:00
if (flags == null) {
2026-07-20 16:05:17 +00:00
flags = constants.NONE;
}
2026-07-29 08:29:29 +00:00
return (flags & VOICE) === VOICE;
};
prototype["isPrioritySpeaker"] = function isPrioritySpeaker(c12, DEFAULT) {
if (DEFAULT === undefined) {
DEFAULT = constants2.DEFAULT;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const PRIORITY = constants.PRIORITY;
let value = map.get(DEFAULT);
let flags;
if (value != null) {
value = value.get(c12);
if (value != null) {
flags = value.flags;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
if (flags == null) {
flags = constants.NONE;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return (flags & PRIORITY) === PRIORITY;
};
prototype["isSoundSharing"] = function isSoundSharing(arg0) {
let DEFAULT = arg1;
if (arg1 === undefined) {
2026-07-20 16:05:17 +00:00
DEFAULT = constants2.DEFAULT;
}
2026-07-29 08:29:29 +00:00
const SOUNDSHARE = constants.SOUNDSHARE;
2026-07-20 16:05:17 +00:00
let value = map.get(DEFAULT);
2026-07-29 08:29:29 +00:00
let flags;
if (value != null) {
value = value.get(arg0);
if (value != null) {
flags = value.flags;
}
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (flags == null) {
flags = constants.NONE;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return (flags & SOUNDSHARE) === SOUNDSHARE;
};
prototype["isAnyoneElseSpeaking"] = function isAnyoneElseSpeaking(DEFAULT) {
if (DEFAULT === undefined) {
DEFAULT = constants2.DEFAULT;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return anyoneHasFlagInContext(DEFAULT, constants.VOICE, true);
};
prototype["isCurrentUserSpeaking"] = function isCurrentUserSpeaking(DEFAULT) {
if (DEFAULT === undefined) {
DEFAULT = constants2.DEFAULT;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let isSpeakingResult = null != c12;
if (isSpeakingResult) {
const self = this;
isSpeakingResult = this.isSpeaking(c12, DEFAULT);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return isSpeakingResult;
};
prototype["isCurrentUserPTTActive"] = function isCurrentUserPTTActive() {
return c15;
};
prototype["isAnyonePrioritySpeaking"] = function isAnyonePrioritySpeaking(DEFAULT) {
if (DEFAULT === undefined) {
DEFAULT = constants2.DEFAULT;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return anyoneHasFlagInContext(DEFAULT, constants.VOICE | constants.PRIORITY);
};
prototype["isCurrentUserPrioritySpeaker"] = function isCurrentUserPrioritySpeaker(DEFAULT) {
if (DEFAULT === undefined) {
DEFAULT = constants2.DEFAULT;
}
let isPrioritySpeakerResult = null != c12;
if (isPrioritySpeakerResult) {
const self = this;
isPrioritySpeakerResult = this.isPrioritySpeaker(c12, DEFAULT);
}
return isPrioritySpeakerResult;
};
prototype["isCurrentUserPrioritySpeaking"] = function isCurrentUserPrioritySpeaking(DEFAULT) {
if (DEFAULT === undefined) {
DEFAULT = constants2.DEFAULT;
}
const self = this;
let isPrioritySpeakerResult = null != c12;
if (isPrioritySpeakerResult) {
isPrioritySpeakerResult = self.isPrioritySpeaker(c12, DEFAULT);
}
if (isPrioritySpeakerResult) {
isPrioritySpeakerResult = self.isSpeaking(c12, DEFAULT);
}
return isPrioritySpeakerResult;
};
prototype["getVoiceVolume"] = function getVoiceVolume(arg0) {
let DEFAULT = arg1;
if (arg1 === undefined) {
DEFAULT = constants2.DEFAULT;
}
2026-08-24 06:08:38 +00:00
const config = getUnitIdDefault.getConfig({ location: "SpeakingStore" });
2026-07-29 08:29:29 +00:00
let num = -Infinity;
if (config.enabled) {
num = -Infinity;
if (!config.disableUI) {
let value = map.get(DEFAULT);
let num2;
if (value != null) {
2026-07-20 16:05:17 +00:00
value = value.get(arg0);
2026-07-29 08:29:29 +00:00
if (value != null) {
num2 = value.voiceDb;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
if (num2 == null) {
num2 = -Infinity;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
num = num2;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}
return num;
};
SpeakingStore.displayName = "SpeakingStore";
2026-08-24 06:08:38 +00:00
const speakingStore = new SpeakingStore(dispatcherDefault, {
2026-07-20 16:05:17 +00:00
CONNECTION_OPEN: handleConnectionOpen,
OVERLAY_INITIALIZE: handleConnectionOpen,
SPEAKING: function handleSpeaking(arg0) {
({ context, userId, speakingFlags, voiceDb } = arg0);
let num = speakingFlags;
if ((speakingFlags & constants.PRIORITY) === constants.PRIORITY) {
2026-07-23 10:11:24 +00:00
channel = channel.getChannel(voiceChannelId.getVoiceChannelId());
2026-07-20 16:05:17 +00:00
if (null != channel) {
2026-08-24 06:08:38 +00:00
let obj = applyOverwritesAll;
2026-07-29 08:29:29 +00:00
obj = { permission: null, user: null, context: null };
obj[0] = Permissions.PRIORITY_SPEAKER;
obj[1] = userId;
obj[2] = channel;
2026-07-20 16:05:17 +00:00
if (obj.can(obj)) {
store.setCanHavePriority(userId, true);
num = speakingFlags;
}
}
store.setCanHavePriority(userId, false);
2026-07-29 08:29:29 +00:00
num = speakingFlags & ~tmp.PRIORITY;
2026-07-20 16:05:17 +00:00
}
if ((num & constants.HIDDEN) === constants.HIDDEN) {
num = 0;
}
2026-07-29 08:29:29 +00:00
if (voiceDb === undefined) {
voiceDb = -Infinity;
}
let DEFAULT = context;
if (context === undefined) {
DEFAULT = constants2.DEFAULT;
}
let value = map.get(DEFAULT);
if (null == value) {
const _Map = Map;
map = new Map();
const result = obj3.set(DEFAULT, map);
value = map;
}
value = value.get(userId);
let num2;
if (value != null) {
num2 = value.flags;
}
if (num2 == null) {
num2 = 0;
}
if (0 !== num2) {
if (0 === num) {
value.delete(userId);
let flag3 = true;
if (0 === value.size) {
obj3.delete(context);
flag3 = true;
}
} else {
let since;
if (value != null) {
since = value.since;
}
if (since == null) {
since = null;
}
if ((num2 & tmp.VOICE) === tmp.VOICE !== (num & tmp.VOICE) === tmp.VOICE) {
let timestamp = null;
if (tmp18) {
const _Date = Date;
timestamp = Date.now();
}
since = timestamp;
}
obj = { flags: null, since: null, voiceDb: null };
obj[0] = num;
obj[1] = since;
obj[2] = voiceDb;
const result1 = value.set(userId, obj);
flag3 = true;
}
} else {
flag3 = false;
}
return flag3;
2026-07-20 16:05:17 +00:00
},
VOICE_STATE_UPDATES: function handleVoiceStateUpdates(voiceStates) {
voiceStates = voiceStates.voiceStates;
return voiceStates.reduce((arg0, arg1) => {
({ userId, channelId, sessionId } = arg1);
2026-07-29 08:29:29 +00:00
let tmp2 = userId === closure_12;
2026-07-20 16:05:17 +00:00
if (tmp2) {
2026-07-29 08:29:29 +00:00
tmp2 = sessionId === closure_13;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let tmp4 = tmp;
2026-07-20 16:05:17 +00:00
if (tmp2) {
2026-07-29 08:29:29 +00:00
let tmp6 = channelId;
if (channelId == null) {
tmp6 = null;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
c14 = tmp6;
2026-07-29 08:29:29 +00:00
tmp4 = tmp6;
2026-07-20 16:05:17 +00:00
}
let flag = false;
2026-08-24 06:08:38 +00:00
if (c14 !== tmp4) {
2026-07-29 08:29:29 +00:00
flag = store.delete(constants.DEFAULT) || false;
const tmp9 = store.delete(constants.DEFAULT) || false;
2026-07-20 16:05:17 +00:00
}
if (null == channelId) {
2026-07-29 08:29:29 +00:00
if (userId !== closure_12) {
const DEFAULT2 = constants.DEFAULT;
let value = store.get(DEFAULT2);
let flag3 = false;
if (null != value) {
const deleteResult = value.delete(userId);
flag3 = deleteResult;
if (0 === value.size) {
obj3.delete(DEFAULT2);
flag3 = deleteResult;
}
}
if (!flag3) {
flag3 = flag;
}
obj3 = store;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
flag3 = store.delete(constants.DEFAULT) || flag;
const tmp27 = store.delete(constants.DEFAULT) || flag;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
if (userId === closure_12) {
if (sessionId !== closure_13) {
let tmp13 = store.delete(constants.DEFAULT) || flag;
const tmp19 = store.delete(constants.DEFAULT) || flag;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (!tmp13) {
tmp13 = arg0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp13;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let tmp11 = userId !== closure_12;
if (tmp11) {
tmp11 = channelId !== channelId.getChannelId();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp13 = flag;
if (tmp11) {
const DEFAULT = constants.DEFAULT;
value = store.get(DEFAULT);
let flag2 = false;
if (null != value) {
const deleteResult2 = value.delete(userId);
flag2 = deleteResult2;
if (0 === value.size) {
obj.delete(DEFAULT);
flag2 = deleteResult2;
}
}
if (!flag2) {
flag2 = flag;
}
tmp13 = flag2;
obj = store;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const tmp29 = closure_12;
2026-07-20 16:05:17 +00:00
}
}, false);
},
PUSH_TO_TALK_STATE_CHANGE: function handlePushToTalkStateChange(isActive) {
isActive = isActive.isActive;
}
});
2026-08-24 06:08:38 +00:00
let result = require("set").fileFinishedImporting("stores/SpeakingStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default speakingStore;