// Callback function to listen for 'play' messages. export type RuntimeListener = () => void; // Public runtime API. export interface Runtime { ready(): void; complete(error?: Error | string | null): void; subscribe(eventName: 'play', listener: RuntimeListener): () => void; acquireInterruptLock(): Promise; addIdleListener(idleCallback?: IdleCallback): RemoveIdleListener; addIdleListener( secondsUntilIdle: number, idleCallback?: IdleCallback ): RemoveIdleListener; addIdleListener( container: HTMLElement | Document, secondsUntilIdle: number, idleCallback?: IdleCallback ): RemoveIdleListener; } // Callback function to be called when the runtime is idle. export type IdleCallback = ((isIdle: boolean) => void) | null; export type RemoveIdleListener = () => Promise; // An interrupt lock that can be acquired to prevent the runtime from being interrupted. export interface InterruptLock { id: string; expiresAt: number; renew(): Promise; release(): Promise; } // A window object with only the required properties for the runtime. This is used // to mock the window object in tests. export interface RuntimeWindow { document: Document | null; Document: any; // eslint-disable-line @typescript-eslint/no-explicit-any HTMLElement: any; // eslint-disable-line @typescript-eslint/no-explicit-any }