import * as t from '@rekajs/types'; import { computedFn } from 'mobx-utils'; import { ExtensionDefinition } from './extension'; import { Externals } from './externals'; import { Frame, FrameOpts } from './frame'; import { Head } from './head'; import { HistoryManager } from './history'; import { CustomKindDefinition, RekaChangeOpts, RekaLoadOpts, RekaOpts, StateSubscriberOpts } from './interfaces'; import { ChangesetListener } from './observer'; import { ExtensionVolatileStateKey, ExternalVolatileStateKey } from './symbols'; export declare class Reka { private readonly opts?; id: string; /** * A list of RekaComponent instances */ frames: Frame[]; /** * The primary State data structure. Changes to the State will cause all Frames to recompute their output View */ state: t.State; head: Head; private kinds; private observer; private extensions; private history; private idToFrame; private init; loaded: boolean; externals: Externals; changes: any[]; volatile: { [key: string]: any; [ExtensionVolatileStateKey]: Record; [ExternalVolatileStateKey]: Record; }; constructor(opts?: RekaOpts | undefined); setHistoryManager(manager: HistoryManager): void; canUndo(): boolean; canRedo(): boolean; undo(): void; redo(): void; private createCustomKindsDefinition; getCustomKind(name: string): CustomKindDefinition; getExternalState(key: string): any; getVolatileState(key: string): any; setVolatileState(key: string, value: V): V; /** * @deprecated - Use setVolatileState() */ get updateVolatileState(): (key: string, value: V) => V; updateExternalState(key: string, value: any): void; /** * Get the Program AST node from State. Shorthand for state.program */ get program(): t.Program; /** * All components that exists in the instance. Includes RekaComponents in the Program AST and ExternalComponents that was passed to the instance in the constructor. */ get components(): { externals: t.Component[]; program: t.RekaComponent[]; }; /** * Load a new State data type */ load(state: t.State, opts?: RekaLoadOpts): void; /** * Sync changes made to the State to all active Frames. You usually do not need to call this manually. */ sync(evaluateImmediately?: boolean): Promise; /** * Perform a mutation to the State */ change(mutator: () => void, opts?: RekaChangeOpts): Promise | undefined; /** * Create a new Frame instance */ createFrame(opts: FrameOpts, cb?: () => void): Frame; /** * Remove an existing Frame instance */ removeFrame(frame: Frame): void; /** * Get a Frame instance by its id */ getFrame(id: string): Frame | undefined; /** * Get an Extension's state from its definition */ getExtension>(definition: D): import("./extension").Extension; /** * Get an AST node by its id from the State */ getNodeFromId(id: string, expectedType?: t.TypeConstructor): T; /** * Get the nearest parent Node of a given AST node in the State. */ getParentNode(node: t.Type, expectedParentType?: t.TypeConstructor): T | null; /** * Get the nearest parent Node and its relative path of a given AST node in the State. */ getNodeLocation(node: t.Type): { parent: t.Type; path: (string | number)[]; }; get getNodePathStr(): (node: t.Type, nearest?: boolean) => any; /** * Listen for changes and mutations made to the State */ listenToChangeset(subscriber: ChangesetListener): () => void; /** * Subscribe to changes made in a Reka instance */ subscribe(collect: (reka: Reka) => C, onCollect: (collected: C, prevCollected?: C) => void, opts?: StateSubscriberOpts): () => void; /** * Watch changes made within a Reka instance */ watch(cb: () => void): () => void; get createCachedQuery(): typeof computedFn; /** * Dispose instance, stops all future computations */ dispose(): void; toJSON(): t.State; get getIdentifiablesAtNode(): (node: t.ASTNode, opts?: import("./scope").GetIdentifiableOpts | undefined) => import("./interfaces").IdentifiableWithScope[]; get getIdentifiableFromIdentifier(): (identifier: t.Identifier) => t.Identifiable | null; getComponentSlots(component: t.Component): never[] | Map>; /** * Create a new Reka instance */ static create(opts?: RekaOpts): Reka; }