/** * Copyright (c) 2018-2025 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal */ import { StateObject, StateObjectCell, StateObjectSelector } from './object.js'; import { StateTree } from './tree.js'; import { StateTransform } from './transform.js'; import { StateTransformer } from './transformer.js'; import { RuntimeContext, Task } from '../mol-task/index.js'; import { StateSelection } from './state/selection.js'; import { StateBuilder } from './state/builder.js'; import { StateAction } from './action.js'; import { StateActionManager } from './action/manager.js'; import { LogEntry } from '../mol-util/log-entry.js'; export { State }; declare class State { private _tree; protected errorFree: boolean; private ev; readonly globalContext: unknown; readonly events: { cell: { stateUpdated: import("rxjs").Subject; created: import("rxjs").Subject; removed: import("rxjs").Subject; }; object: { updated: import("rxjs").Subject; created: import("rxjs").Subject; removed: import("rxjs").Subject; }; log: import("rxjs").Subject; changed: import("rxjs").Subject<{ state: State; inTransaction: boolean; }>; historyUpdated: import("rxjs").Subject<{ state: State; }>; }; readonly behaviors: { currentObject: import("rxjs").BehaviorSubject; isUpdating: import("rxjs").BehaviorSubject; }; readonly actions: StateActionManager; readonly runTask: (task: Task) => Promise; get tree(): StateTree; get transforms(): StateTree.Transforms; get current(): string; get root(): StateObjectCell>, StateTransform>, StateObject>, any>>>; build(): StateBuilder.Root; readonly cells: State.Cells; private spine; private refResolvers; registerRefResolver(name: string, resolver: (state: State, ref: StateTransform.Ref) => StateObject | undefined): void; removeRefResolver(name: string): void; tryGetCellData: (ref: StateTransform.Ref) => T extends StateObject ? D : never; private historyCapacity; private history; private addHistory; private clearHistory; get latestUndoLabel(): string | undefined; get canUndo(): boolean; private undoingHistory; undo(): Task; getSnapshot(): State.Snapshot; setSnapshot(snapshot: State.Snapshot): Task; setCurrent(ref: StateTransform.Ref): void; updateCellState(ref: StateTransform.Ref, stateOrProvider: ((old: StateTransform.State) => Partial) | Partial): void; dispose(): void; /** * Select Cells using the provided selector. * @example state.query(StateSelection.Generators.byRef('test').ancestorOfType(type)) * @example state.query('test') */ select(selector: StateSelection.Selector): StateSelection.CellSeq; /** * Select Cells by building a query generated on the fly. * @example state.select(q => q.byRef('test').subtree()) */ selectQ(selector: (q: typeof StateSelection.Generators) => StateSelection.Selector): StateSelection.CellSeq; /** * Creates a Task that applies the specified StateAction (i.e. must use run* on the result) * If no ref is specified, apply to root. */ applyAction(action: A, params: StateAction.Params, ref?: StateTransform.Ref): Task; private inTransaction; private inTransactionError; /** Apply series of updates to the state. If any of them fail, revert to the original state. */ transaction(edits: (ctx: RuntimeContext) => Promise | void, options?: { canUndo?: string | boolean; rethrowErrors?: boolean; }): Task; private _inUpdate; /** * Determines whether the state is currently "inside" updateTree function. * This is different from "isUpdating" which wraps entire transactions. */ get inUpdate(): boolean; /** * Queues up a reconciliation of the existing state tree. * * If the tree is StateBuilder.To, the corresponding StateObject is returned by the task. * @param tree Tree instance or a tree builder instance * @param doNotReportTiming Indicates whether to log timing of the individual transforms */ updateTree(tree: StateBuilder.To, options?: Partial): Task>; updateTree(tree: StateTree | StateBuilder, options?: Partial): Task; private reverted; private updateQueue; private _revertibleTreeUpdate; private _updateTree; private updateTreeAndCreateCtx; constructor(rootObject: StateObject, params: State.Params); } declare namespace State { interface Params { runTask(task: Task): Promise; globalContext?: unknown; rootState?: StateTransform.State; historyCapacity?: number; } function create(rootObject: StateObject, params: Params): State; type Cells = ReadonlyMap; type Tree = StateTree; type Builder = StateBuilder; interface ObjectEvent { state: State; ref: Ref; } namespace ObjectEvent { function isCell(e: ObjectEvent, cell?: StateObjectCell): boolean; } interface Snapshot { readonly tree: StateTree.Serialized; } interface UpdateOptions { doNotLogTiming: boolean; doNotUpdateCurrent: boolean; revertIfAborted: boolean; revertOnError: boolean; canUndo: boolean | string; } } type Ref = StateTransform.Ref;