decord/source/modules/collectibles/profile_effects/useClock.tsx
2026-07-27 11:26:19 +00:00

116 lines
3.8 KiB
TypeScript

// Module ID: 8002
// Function ID: 63773
// Name: allowableMinInterval
// Dependencies: [31, 44, 4560, 2]
// Exports: default
// Module 8002 (allowableMinInterval)
import result from "result";
const result = require("useMountLayoutEffect").fileFinishedImporting("modules/collectibles/profile_effects/useClock.tsx");
export default function _default(arg0) {
let obj = arg1;
const importDefault = arg0;
if (arg1 === undefined) {
obj = {};
}
let num = obj.minInterval;
if (num === undefined) {
num = 41.666666666666664;
}
const allowableMinInterval = obj.allowableMinInterval;
const droppedFramesCallbackThreshold = obj.droppedFramesCallbackThreshold;
const droppedFramesCallback = obj.droppedFramesCallback;
let num2 = obj.droppedFramesResetTime;
if (num2 === undefined) {
num2 = 3000;
}
let closure_6;
let closure_7;
let closure_8;
let closure_9;
let ticking;
let closure_11;
let closure_12;
let callback;
let stop;
let callback2;
closure_6 = allowableMinInterval.useRef(num);
closure_7 = allowableMinInterval.useRef(0);
closure_8 = allowableMinInterval.useRef(undefined);
closure_9 = allowableMinInterval.useRef(undefined);
ticking = allowableMinInterval.useRef(true);
closure_11 = allowableMinInterval.useRef(0);
closure_12 = allowableMinInterval.useRef(undefined);
callback = allowableMinInterval.useCallback(() => {
closure_11.current = 0;
if (null != closure_12.current) {
const _clearTimeout = clearTimeout;
clearTimeout(closure_12.current);
closure_12.current = undefined;
}
}, []);
stop = allowableMinInterval.useCallback(() => {
ticking.current = false;
cancelAnimationFrame(ref2.current);
clearTimeout(closure_12.current);
}, []);
const items = [allowableMinInterval, callback, num2, droppedFramesCallbackThreshold, droppedFramesCallback, arg0];
callback2 = allowableMinInterval.useCallback((current) => {
if (ticking.current) {
if (null == ref3.current) {
ref3.current = current;
}
if (null == ref4.current) {
ref4.current = current;
}
const diff = current - ref4.current;
let num = 120;
const diff1 = current - ref3.current;
if (null != allowableMinInterval) {
num = allowableMinInterval;
}
if (diff1 > 1.5 * Math.min(num, ref.current)) {
ref5.current = ref5.current + 1;
if (null != closure_12.current) {
const _clearTimeout = clearTimeout;
clearTimeout(closure_12.current);
}
const _setTimeout = setTimeout;
closure_12.current = setTimeout(callback, num2);
if (null != droppedFramesCallbackThreshold) {
if (ref5.current > droppedFramesCallbackThreshold) {
callback(num[1])(null != droppedFramesCallback, "useClock - If you set a dropped frames threshold, you must provide a droppedFramesCallback to do something when that threshold is hit");
if (droppedFramesCallback()) {
ref5.current = 0;
}
}
}
}
ref3.current = current;
if (diff >= ref.current - 3) {
ref4.current = current;
callback(diff);
}
const _requestAnimationFrame = requestAnimationFrame;
closure_7.current = requestAnimationFrame(callback2);
}
}, items);
const items1 = [callback2];
const items2 = [num];
const reset = allowableMinInterval.useCallback(() => {
ticking.current = true;
closure_9.current = undefined;
cancelAnimationFrame(ref2.current);
ref2.current = requestAnimationFrame(callback2);
}, items1);
const effect = allowableMinInterval.useEffect(() => {
closure_6.current = num;
}, items2);
importDefault(num[2])(() => {
closure_7.current = requestAnimationFrame(callback2);
return () => outer1_14();
});
return { stop, reset, ticking };
};