mirror of
https://github.com/murashit/codex-panel.git
synced 2026-07-22 17:30:31 +00:00
26 lines
757 B
TypeScript
26 lines
757 B
TypeScript
import { beforeEach } from "vitest";
|
|
import { installObsidianDomShims } from "../../../../support/dom";
|
|
|
|
(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
|
|
installObsidianDomShims();
|
|
|
|
beforeEach(() => {
|
|
let nextAnimationFrameId = 1;
|
|
const callbacks = new Map<number, FrameRequestCallback>();
|
|
window.requestAnimationFrame = (callback) => {
|
|
const id = nextAnimationFrameId;
|
|
nextAnimationFrameId += 1;
|
|
callbacks.set(id, callback);
|
|
queueMicrotask(() => {
|
|
const scheduled = callbacks.get(id);
|
|
if (!scheduled) return;
|
|
callbacks.delete(id);
|
|
scheduled(0);
|
|
});
|
|
return id;
|
|
};
|
|
window.cancelAnimationFrame = (id) => {
|
|
callbacks.delete(id);
|
|
};
|
|
});
|