/** * Copyright (c) 2018-2025 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal * @author Alexander Rose */ import { List } from 'immutable'; import { UUID } from '../../mol-util/index.js'; import { PluginState } from '../../mol-plugin/state.js'; import { StatefulPluginComponent } from '../component.js'; import { PluginContext } from '../../mol-plugin/context.js'; import { Asset } from '../../mol-util/assets.js'; export { PluginStateSnapshotManager }; interface StateManagerState { current?: UUID; currentAnimationTimeMs?: number; entries: List; isPlaying: boolean; nextSnapshotDelayInMs: number; } declare class PluginStateSnapshotManager extends StatefulPluginComponent { private plugin; static DefaultNextSnapshotDelayInMs: number; private entryMap; private defaultSnapshotId; protected updateState(state: Partial): boolean; readonly events: { changed: import("rxjs").Subject; opened: import("rxjs").Subject; }; get current(): PluginStateSnapshotManager.Entry | undefined; getIndex(e: PluginStateSnapshotManager.Entry): number; getEntry(id: string | undefined): PluginStateSnapshotManager.Entry | undefined; remove(id: string): void; add(e: PluginStateSnapshotManager.Entry): void; replace(id: string, snapshot: PluginState.Snapshot, params?: PluginStateSnapshotManager.EntryParams): void; move(id: string, dir: -1 | 1): void; update(e: PluginStateSnapshotManager.Entry, options: { key?: string; name?: string; description?: string; descriptionFormat?: PluginStateSnapshotManager.DescriptionFormat; }): void; clear(): void; applyKey(key: string): void; setCurrent(id: string): PluginState.Snapshot | undefined; private animationFrameQueue; setSnapshotAnimationFrame(currentAnimationTimeMs: number, load?: boolean): number | undefined; getNextId(id: string | undefined, dir: -1 | 1): UUID | undefined; applyNext(dir: -1 | 1): Promise | undefined; setStateSnapshot(snapshot: PluginStateSnapshotManager.StateSnapshot): Promise; private syncCurrent; getStateSnapshot(options?: { name?: string; description?: string; playOnLoad?: boolean; params?: PluginState.SnapshotParams; }): Promise; serialize(options?: { type: 'json' | 'molj' | 'zip' | 'molx'; params?: PluginState.SnapshotParams; }): Promise; open(file: File): Promise; private timeoutHandle; private next; private startPlayback; play(options?: { delayFirst?: boolean; restart?: boolean; }): Promise; stop(): Promise; togglePlay(): Promise; dispose(): void; constructor(plugin: PluginContext); } declare namespace PluginStateSnapshotManager { type DescriptionFormat = 'markdown' | 'plaintext'; interface EntryParams { key?: string; name?: string; /** Information about the snapshot, to be shown in the UI when the snapshot is loaded. */ description?: string; /** Toggle between markdown and plaintext interpretation of `description`. Default is markdown. */ descriptionFormat?: DescriptionFormat; image?: Asset; } interface Entry extends EntryParams { timestamp: number; snapshot: PluginState.Snapshot; /** Extra data that is not serialized */ _transientData?: any; } function Entry(snapshot: PluginState.Snapshot, params: EntryParams): Entry; function isStateSnapshot(x?: any): x is StateSnapshot; interface StateSnapshot { timestamp: number; version: string; name?: string; description?: string; current: UUID | undefined; playback: { isPlaying: boolean; nextSnapshotDelayInMs: number; }; entries: Entry[]; } function getCanvasImageAsset(ctx: PluginContext, name: string): Promise; }