项目文件夹

文件
wehub-resource-sync 2771cff92b
CI / lint (push) Failing after 1s
CI / typecheck (push) Failing after 2s
CI / test (push) Failing after 1s
CI / build (push) Has been skipped
chore: import upstream snapshot with attribution
2026-07-13 12:22:56 +08:00

27 行
691 B
TypeScript

type TestWindow = typeof globalThis & {
cancelAnimationFrame?: (handle: number) => void;
requestAnimationFrame?: (callback: FrameRequestCallback) => number;
};
const testWindow = globalThis as TestWindow;
if (!testWindow.requestAnimationFrame) {
testWindow.requestAnimationFrame = (callback: FrameRequestCallback): number => (
Number(setTimeout(() => callback(Date.now()), 0))
);
}
if (!testWindow.cancelAnimationFrame) {
testWindow.cancelAnimationFrame = (handle: number): void => {
clearTimeout(handle);
};
}
if (!('window' in globalThis)) {
Object.defineProperty(globalThis, 'window', {
configurable: true,
value: testWindow,
writable: true,
});
}