decord/source/modules/collectibles/profile_effects/useClock.tsx

118 lines
3.8 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 9252
// Function ID: 9253
2026-07-20 16:05:17 +00:00
// Name: allowableMinInterval
2026-08-24 06:08:38 +00:00
// Dependencies: [19, 38, 4766, 2]
2026-07-20 16:05:17 +00:00
// Exports: default
2026-08-24 06:08:38 +00:00
// Module 9252 (allowableMinInterval)
import closure_2 from "noop" /* 19 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
const result = require("set").fileFinishedImporting("modules/collectibles/profile_effects/useClock.tsx");
2026-07-20 16:05:17 +00:00
export default function _default(arg0) {
2026-08-24 06:08:38 +00:00
importDefault = arg0;
2026-07-29 08:29:29 +00:00
let obj = arg1;
2026-07-20 16:05:17 +00:00
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;
}
2026-08-24 06:08:38 +00:00
closure_6 = undefined;
closure_7 = undefined;
closure_8 = undefined;
closure_9 = undefined;
2026-07-20 16:05:17 +00:00
let ticking;
2026-08-24 06:08:38 +00:00
closure_11 = undefined;
closure_12 = undefined;
2026-07-20 16:05:17 +00:00
let callback;
let stop;
let callback2;
2026-07-23 10:11:24 +00:00
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(() => {
2026-07-20 16:05:17 +00:00
closure_11.current = 0;
2026-07-29 08:29:29 +00:00
if (null != ref6.current) {
2026-07-20 16:05:17 +00:00
const _clearTimeout = clearTimeout;
2026-07-29 08:29:29 +00:00
clearTimeout(tmp.current);
tmp.current = undefined;
2026-07-20 16:05:17 +00:00
}
}, []);
2026-07-23 10:11:24 +00:00
stop = allowableMinInterval.useCallback(() => {
2026-07-20 16:05:17 +00:00
ticking.current = false;
cancelAnimationFrame(ref2.current);
2026-07-29 08:29:29 +00:00
clearTimeout(ref6.current);
2026-07-20 16:05:17 +00:00
}, []);
const items = [allowableMinInterval, callback, num2, droppedFramesCallbackThreshold, droppedFramesCallback, arg0];
2026-07-23 10:11:24 +00:00
callback2 = allowableMinInterval.useCallback((current) => {
2026-07-20 16:05:17 +00:00
if (ticking.current) {
if (null == ref3.current) {
2026-07-29 08:29:29 +00:00
tmp2.current = current;
2026-07-20 16:05:17 +00:00
}
if (null == ref4.current) {
2026-07-29 08:29:29 +00:00
tmp4.current = current;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const diff = current - tmp4.current;
2026-08-24 06:08:38 +00:00
num = allowableMinInterval;
2026-07-29 08:29:29 +00:00
const diff1 = current - tmp2.current;
if (allowableMinInterval == null) {
num = 120;
2026-07-20 16:05:17 +00:00
}
if (diff1 > 1.5 * Math.min(num, ref.current)) {
ref5.current = ref5.current + 1;
2026-07-29 08:29:29 +00:00
if (null != ref6.current) {
2026-07-20 16:05:17 +00:00
const _clearTimeout = clearTimeout;
2026-07-29 08:29:29 +00:00
clearTimeout(tmp22.current);
2026-07-20 16:05:17 +00:00
}
const _setTimeout = setTimeout;
2026-07-29 08:29:29 +00:00
ref6.current = setTimeout(callback, num2);
2026-07-20 16:05:17 +00:00
if (null != droppedFramesCallbackThreshold) {
2026-07-29 08:29:29 +00:00
if (tmp21.current > tmp12) {
2026-07-23 10:11:24 +00:00
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");
2026-07-20 16:05:17 +00:00
if (droppedFramesCallback()) {
2026-07-29 08:29:29 +00:00
tmp21.current = 0;
2026-07-20 16:05:17 +00:00
}
}
}
}
ref3.current = current;
2026-07-29 08:29:29 +00:00
if (diff >= tmp8.current - 3) {
tmp4.current = current;
2026-07-23 10:11:24 +00:00
callback(diff);
2026-07-20 16:05:17 +00:00
}
const _requestAnimationFrame = requestAnimationFrame;
closure_7.current = requestAnimationFrame(callback2);
2026-07-29 08:29:29 +00:00
tmp8 = ref;
2026-07-20 16:05:17 +00:00
}
}, items);
const items1 = [callback2];
const items2 = [num];
2026-07-23 10:11:24 +00:00
const reset = allowableMinInterval.useCallback(() => {
2026-07-20 16:05:17 +00:00
ticking.current = true;
closure_9.current = undefined;
cancelAnimationFrame(ref2.current);
ref2.current = requestAnimationFrame(callback2);
}, items1);
2026-07-23 10:11:24 +00:00
const effect = allowableMinInterval.useEffect(() => {
2026-07-20 16:05:17 +00:00
closure_6.current = num;
}, items2);
2026-07-23 10:11:24 +00:00
importDefault(num[2])(() => {
2026-07-20 16:05:17 +00:00
closure_7.current = requestAnimationFrame(callback2);
2026-07-29 08:29:29 +00:00
return () => callback();
2026-07-20 16:05:17 +00:00
});
return { stop, reset, ticking };
};