import { Schema as S, Stream } from 'effect'; /** * Configuration for the `animationFrame` Subscription helper. * * `isActive(model)` controls whether the request-animation-frame loop is * scheduled at all. When it returns `false` (e.g. the game is paused, the * scene is static, or the canvas is offscreen), no rAF callbacks fire and * no Messages are emitted. The Subscription system automatically restarts * the loop when `isActive` flips back to `true`. */ export type AnimationFrameConfig = Readonly<{ isActive: (model: Model) => boolean; toMessage: (deltaTime: number) => Message; }>; /** * Build a Subscription that emits a Message on every * `requestAnimationFrame` tick, with the inter-frame delta in milliseconds. * * @example * ```typescript * const subscriptions = Subscription.make()(_entry => ({ * frame: Subscription.animationFrame({ * isActive: model => model.isPlaying, * toMessage: deltaTime => Tick({ deltaTime }), * }), * })) * ``` * * The browser pauses `requestAnimationFrame` when the tab is hidden, so * `deltaTime` may spike to several seconds on the first frame after the * tab regains focus. If your `update` function multiplies `deltaTime` * against motion or physics, cap it to a reasonable maximum (32ms is * typical) before using it. Otherwise a multi-second `deltaTime` can send * moving objects flying across the screen in one frame. * * Returns an entry shape, not a branded Subscription. Pass it into * `Subscription.make` as an entry value. */ export declare const animationFrame: (config: AnimationFrameConfig) => { dependenciesSchema: S.Struct<{ readonly isActive: S.Boolean; }>; modelToDependencies: (model: Model) => { isActive: boolean; }; dependenciesToStream: ({ isActive }: { readonly isActive: boolean; }) => Stream.Stream; }; //# sourceMappingURL=animationFrame.d.ts.map