decord/source/stores/IdleStore.tsx

290 lines
8.2 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 5235
// Function ID: 5236
2026-07-29 08:29:29 +00:00
// Name: checkIdleAFK
2026-08-25 06:04:03 +00:00
// Dependencies: [1218, 676, 4444, 500, 4070, 687, 709, 4008, 5236, 636, 589, 2]
2026-07-20 16:05:17 +00:00
2026-08-25 06:04:03 +00:00
// Module 5235 (checkIdleAFK)
2026-08-24 06:08:38 +00:00
import set from "set" /* 500 */;
import initializeDefault from "initialize" /* 589 */;
import debounceDefault from "debounce" /* 636 */;
import setDefault from "set" /* 687 */;
import dispatcherDefault from "dispatcher" /* 709 */;
2026-08-25 06:04:03 +00:00
import setDefault2 from "set" /* 4008 */;
import explicitContentFromProto from "explicitContentFromProto" /* 4070 */;
import _modDef5236 from "module_5236" /* 5236 */;
2026-08-24 06:08:38 +00:00
import closure_4 from "fetchFingerprint" /* 1218 */;
import ME from "ME" /* 676 */;
2026-08-25 06:04:03 +00:00
import { SpeakingFlags } from "DesktopSources" /* 4444 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
2026-07-20 16:05:17 +00:00
function checkIdleAFK() {
2026-07-29 08:29:29 +00:00
if (Date.now() - closure_8 <= closure_5) {
let tmp2 = c11;
if (!c11) {
tmp2 = c12;
}
if (!tmp2) {
2026-08-24 06:08:38 +00:00
let obj = set;
2026-07-29 08:29:29 +00:00
tmp2 = obj.isAndroid() && c13;
const tmp5 = obj.isAndroid() && c13;
}
if (!tmp2) {
if (c9) {
2026-08-24 06:08:38 +00:00
dispatcherDefault.dispatch({ type: "IDLE", idle: false });
const obj2 = dispatcherDefault;
2026-07-20 16:05:17 +00:00
}
}
2026-08-24 06:08:38 +00:00
const AfkTimeout = explicitContentFromProto.AfkTimeout;
2026-07-20 16:05:17 +00:00
const setting = AfkTimeout.getSetting();
if (0 !== setting) {
2026-07-29 08:29:29 +00:00
if (null == closure_3) {
2026-07-20 16:05:17 +00:00
const _Date = Date;
const _Math = Math;
2026-07-29 08:29:29 +00:00
const diff = Date.now() - closure_8;
2026-08-24 06:08:38 +00:00
if (diff <= Math.min(setting * setDefault.Millis.SECOND, tmp)) {
2026-07-29 08:29:29 +00:00
let tmp17 = c11;
if (!c11) {
tmp17 = c12;
}
if (!tmp17) {
const tmp14Result = tmp14(500);
tmp17 = tmp14(500).isAndroid() && c13;
const tmp18 = tmp14(500).isAndroid() && c13;
}
if (!tmp17) {
if (c10) {
tmp28(709).dispatch({ type: "AFK", afk: false });
const tmp28Result = tmp28(709);
2026-07-20 16:05:17 +00:00
}
}
}
2026-07-29 08:29:29 +00:00
tmp28 = importDefault;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
if (!c10) {
2026-08-24 06:08:38 +00:00
dispatcherDefault.dispatch({ type: "AFK", afk: true });
const obj7 = dispatcherDefault;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp14 = require;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (!c9) {
obj = { type: "IDLE", idle: true, idleSince: null };
obj[2] = closure_8;
2026-08-24 06:08:38 +00:00
dispatcherDefault.dispatch(obj);
const obj3 = dispatcherDefault;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
({ IDLE_DURATION: c5, AppStates: closure_6 } = ME);
let closure_8 = Date.now();
let c9 = false;
let c10 = false;
let c11 = false;
let c12 = false;
let c13 = false;
2026-07-23 10:11:24 +00:00
if (require("set").isPlatformEmbedded) {
2026-08-24 06:08:38 +00:00
const importDefaultResult = setDefault2;
2026-07-20 16:05:17 +00:00
let powerMonitor;
2026-07-29 08:29:29 +00:00
if (importDefaultResult != null) {
powerMonitor = importDefaultResult.powerMonitor;
2026-07-20 16:05:17 +00:00
}
if (null != powerMonitor) {
function checkNativeIdle() {
2026-08-24 06:08:38 +00:00
const tmp3 = setDefault2;
2026-07-20 16:05:17 +00:00
let getSystemIdleTimeMs;
2026-07-29 08:29:29 +00:00
if (tmp3 != null) {
const powerMonitor = tmp3.powerMonitor;
if (powerMonitor != null) {
2026-07-20 16:05:17 +00:00
getSystemIdleTimeMs = powerMonitor.getSystemIdleTimeMs;
}
}
if (null != getSystemIdleTimeMs) {
2026-08-25 06:04:03 +00:00
const powerMonitor2 = tmp(4008).powerMonitor;
2026-07-20 16:05:17 +00:00
const systemIdleTimeMs = powerMonitor2.getSystemIdleTimeMs();
if (systemIdleTimeMs instanceof Promise) {
2026-07-29 08:29:29 +00:00
systemIdleTimeMs.then(function handleIdleTime(arg0) {
const diff = Date.now() - arg0;
let tmp2 = null == c3;
if (!tmp2) {
tmp2 = diff > c3;
}
if (tmp2) {
const _Math = Math;
closure_8 = Math.max(diff, closure_8);
c3 = null;
}
callback2();
const timerId = setTimeout(closure_15, 10 * callback(table[5]).Millis.SECOND);
});
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
const _Date = Date;
let diff = Date.now() - systemIdleTimeMs;
let tmp7 = null == c3;
if (!tmp7) {
tmp7 = diff > c3;
}
if (tmp7) {
let _Math = Math;
closure_8 = Math.max(diff, closure_8);
c3 = null;
}
checkIdleAFK();
const _setTimeout = setTimeout;
let timerId = setTimeout(checkNativeIdle, 10 * tmp(687).Millis.SECOND);
2026-07-20 16:05:17 +00:00
}
}
}
checkNativeIdle();
2026-08-24 06:08:38 +00:00
powerMonitor = setDefault2.powerMonitor;
2026-07-20 16:05:17 +00:00
powerMonitor.on("resume", () => {
2026-08-24 06:08:38 +00:00
c11 = false;
2026-07-29 08:29:29 +00:00
checkIdleAFK();
2026-07-20 16:05:17 +00:00
});
2026-08-24 06:08:38 +00:00
let powerMonitor2 = setDefault2.powerMonitor;
2026-07-20 16:05:17 +00:00
powerMonitor2.on("suspend", () => {
2026-08-24 06:08:38 +00:00
c11 = true;
closure_3 = Date.now();
2026-07-29 08:29:29 +00:00
checkIdleAFK();
2026-08-25 06:04:03 +00:00
_modDef5236.disconnect();
2026-07-20 16:05:17 +00:00
});
2026-08-24 06:08:38 +00:00
const powerMonitor3 = setDefault2.powerMonitor;
2026-07-29 08:29:29 +00:00
class IdleStore extends r10079 {
}
2026-07-20 16:05:17 +00:00
powerMonitor3.on("lock-screen", () => {
2026-08-24 06:08:38 +00:00
c12 = true;
closure_3 = Date.now();
2026-07-29 08:29:29 +00:00
checkIdleAFK();
2026-07-20 16:05:17 +00:00
});
2026-07-29 08:29:29 +00:00
obj.on("unlock-screen", () => {
2026-08-24 06:08:38 +00:00
c12 = false;
2026-07-29 08:29:29 +00:00
checkIdleAFK();
2026-07-20 16:05:17 +00:00
});
}
2026-07-29 08:29:29 +00:00
function handleGenericAction(timestamp) {
timestamp = timestamp.timestamp;
let tmp = "OVERLAY_SET_NOT_IDLE" === timestamp.type;
if (tmp) {
tmp = null != timestamp;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let bypassIdleUpdate = tmp;
if (tmp) {
bypassIdleUpdate = timestamp <= timestamp;
}
if (!bypassIdleUpdate) {
bypassIdleUpdate = timestamp.bypassIdleUpdate;
}
if (!bypassIdleUpdate) {
2026-08-24 06:08:38 +00:00
c3 = null;
2026-07-29 08:29:29 +00:00
if (!tmp) {
const _Date = Date;
timestamp = Date.now();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
checkIdleAFK();
}
return false;
}
2026-08-24 06:08:38 +00:00
debounceDefault(() => {
2026-07-29 08:29:29 +00:00
const obj = {};
let timestamp = obj.timestamp;
let tmp = "OVERLAY_SET_NOT_IDLE" === obj.type;
if (tmp) {
tmp = null != timestamp;
}
let bypassIdleUpdate = tmp;
if (tmp) {
bypassIdleUpdate = timestamp <= timestamp;
}
if (!bypassIdleUpdate) {
bypassIdleUpdate = obj.bypassIdleUpdate;
}
if (!bypassIdleUpdate) {
2026-08-24 06:08:38 +00:00
c3 = null;
2026-07-29 08:29:29 +00:00
if (!tmp) {
const _Date = Date;
timestamp = Date.now();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
checkIdleAFK();
}
}, 500);
2026-08-24 06:08:38 +00:00
const Store = initializeDefault.Store;
2026-07-29 08:29:29 +00:00
class IdleStore extends r10079 {
}
const prototype = IdleStore.prototype;
prototype["initialize"] = function initialize() {
2026-08-24 06:08:38 +00:00
this.waitFor(closure_4);
2026-07-29 08:29:29 +00:00
};
prototype["isIdle"] = function isIdle() {
return c9;
};
prototype["isAFK"] = function isAFK() {
return c10;
};
prototype["getIdleSince"] = function getIdleSince() {
let tmp = null;
if (c9) {
tmp = closure_8;
}
return tmp;
};
prototype["getSystemSuspended"] = function getSystemSuspended() {
return c11;
};
prototype["getSystemLocked"] = function getSystemLocked() {
return c12;
};
IdleStore.displayName = "IdleStore";
obj = { IDLE: null, AFK: null, SPEAKING: null, APP_STATE_UPDATE: null, OVERLAY_SET_NOT_IDLE: null, CHANNEL_SELECT: null, VOICE_CHANNEL_SELECT: null, WINDOW_FOCUS: null, OVERLAY_INITIALIZE: null, OVERLAY_SET_INPUT_LOCKED: null };
obj[0] = function handleIdle(idle) {
idle = idle.idle;
};
obj[1] = function handleAFK(afk) {
afk = afk.afk;
};
obj[2] = function handleSpeaking(speakingFlags) {
let tmp2 = speakingFlags.speakingFlags !== SpeakingFlags.NONE;
if (tmp2) {
tmp2 = tmp === id.getId();
}
if (tmp2) {
const obj = {};
let timestamp = obj.timestamp;
let tmp4 = "OVERLAY_SET_NOT_IDLE" === obj.type;
if (tmp4) {
tmp4 = null != timestamp;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let bypassIdleUpdate = tmp4;
if (tmp4) {
bypassIdleUpdate = timestamp <= timestamp;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (!bypassIdleUpdate) {
bypassIdleUpdate = obj.bypassIdleUpdate;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (!bypassIdleUpdate) {
2026-08-24 06:08:38 +00:00
c3 = null;
2026-07-29 08:29:29 +00:00
if (!tmp4) {
const _Date = Date;
timestamp = Date.now();
2026-07-20 16:05:17 +00:00
}
checkIdleAFK();
2026-07-29 08:29:29 +00:00
}
}
return false;
};
obj[3] = function handleAppStateUpdate(state) {
2026-08-24 06:08:38 +00:00
closure_13 = state.state === constants.BACKGROUND;
c3 = null;
closure_8 = Date.now();
2026-07-29 08:29:29 +00:00
checkIdleAFK();
return false;
2026-07-20 16:05:17 +00:00
};
2026-07-29 08:29:29 +00:00
obj[4] = handleGenericAction;
obj[5] = handleGenericAction;
obj[6] = handleGenericAction;
obj[7] = handleGenericAction;
obj[8] = handleGenericAction;
obj[9] = handleGenericAction;
2026-08-24 06:08:38 +00:00
const idleStore = new IdleStore(dispatcherDefault, obj);
const result = require("set").fileFinishedImporting("stores/IdleStore.tsx");
2026-07-29 08:29:29 +00:00
exports.default = idleStore;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
let timerId = setInterval(checkIdleAFK, 30 * setDefault.Millis.SECOND);