import type { TOScheduler } from '@arwes/tools'; export type AnimatorControl = { readonly getSettings: () => AnimatorSettingsPartial; readonly setSettings: (settings: AnimatorSettingsPartial | null) => void; readonly getForeign: () => unknown; readonly setForeign: (foreign: unknown) => void; }; export type AnimatorState = 'entered' | 'entering' | 'exiting' | 'exited'; export type AnimatorAction = 'setup' | 'enter' | 'enterEnd' | 'exit' | 'exitEnd' | 'update' | 'refresh'; export type AnimatorManagerName = 'parallel' | 'stagger' | 'staggerReverse' | 'sequence' | 'sequenceReverse' | 'switch'; export type AnimatorSubscriber = (node: AnimatorNode) => void; export type AnimatorWatcher = (node: AnimatorNode) => void; export interface AnimatorManager { readonly name: AnimatorManagerName; readonly getDurationEnter: (childrenNodes?: AnimatorNode[]) => number; readonly enterChildren: (childrenNodes: AnimatorNode[]) => void; readonly exitChildren: (childrenNodes: AnimatorNode[]) => void; readonly destroy: () => void; } export interface AnimatorNode { readonly _parent?: AnimatorNode; readonly _children: Set; readonly _subscribers: Set; readonly _watchers: Set; readonly _scheduler: TOScheduler; readonly _getUserSettings: () => AnimatorSettings; _manager: AnimatorManager; readonly id: string; readonly state: AnimatorState; readonly control: AnimatorControl; readonly settings: AnimatorSettings; readonly subscribe: (subscriber: AnimatorSubscriber) => () => void; readonly unsubscribe: (subscriber: AnimatorSubscriber) => void; readonly send: (newAction: AnimatorAction) => void; } export type AnimatorSystemRegisterSetup = { getSettings: () => AnimatorSettingsPartial; }; export interface AnimatorSystem { readonly id: string; readonly root: AnimatorNode | null; readonly register: (parentNode?: undefined | null | AnimatorNode, setup?: AnimatorSystemRegisterSetup) => AnimatorNode; readonly unregister: (node: AnimatorNode) => void; } export interface AnimatorDuration { enter: number; exit: number; delay: number; offset: number; stagger: number; limit: number; [duration: string]: number; } export interface AnimatorSettings { active: boolean; duration: AnimatorDuration; manager: AnimatorManagerName; merge: boolean; combine: boolean; initialState: 'exited' | 'entered'; condition?: boolean | ((node: AnimatorNode) => boolean); onTransition?: (node: AnimatorNode) => void; } export type AnimatorSettingsPartial = Partial> & { duration?: Partial; }; export interface AnimatorInterface { readonly system: AnimatorSystem; readonly node: AnimatorNode; }