import { GraphAction, GraphNode, MusterEventSource, NodeData, NodeName, NodeProperties, NodeState, Scope, StatefulGraphNode } from '../types/graph'; import { HashSet } from './hash-set'; import { Stack } from './stack'; export declare type ScopeId = string; export declare type ContextId = string; export declare type NodeId = string; export declare type OperationId = string; export declare type ActionId = NodeId & OperationId; export declare type CachedActionId = number; export declare type UpdateCallback = (value: GraphNode) => void; export declare type DisposeCallback = () => void; export interface Store { debug: boolean; scopes: Map; nodes: Map; actions: Map; instances: Map; resolverQueue: Queue; invalidationQueue: Queue; isFlushing: boolean; isInvalidating: boolean; subscriptions: Map>; events: MusterEventSource; } export interface ScopeCache { scope: Scope; retainCount: number; childScopes: Array; nodes: Array; } export interface NodeCache { node: GraphNode; state: NodeState | undefined; data: NodeData | undefined; retainCount: number; instances: Array; } export declare type ActionCache = { action: GraphAction; } & ({ cacheable: true; instance: CachedAction; instances: undefined; } | { cacheable: false; instance: undefined; instances: Array; }); export interface GraphDependency { target: GraphAction; allowErrors: boolean; allowPending: boolean; invalidate: boolean; } export interface CachedDependency { target: CachedAction; allowErrors: boolean; allowPending: boolean; invalidate: boolean; } export interface CachedAction { id: CachedActionId; action: GraphAction; cacheable: boolean; contextDependencies: Array; dependencies: Array; dependants: Array; next: CachedAction | undefined; value: GraphNode | undefined; dependencyValues: Array | undefined; previousResult: GraphNode | GraphAction | undefined; retainCount: number; queuedAction: QueuedAction | undefined; isInvalidating: boolean; isAwaitingOnInvalidate: boolean; } export interface QueuedAction { target: CachedAction; dependencyStack: number | Stack; dependantStack: number | Stack; visitedDependencies: HashSet | undefined; visitedDependants: HashSet | undefined; } export interface Subscription { callback: UpdateCallback; debug: boolean; } export interface Queue { push(item: T): void; shift(): T | undefined; pop(): T | undefined; unshift(item: T): void; head: QueueItem | undefined; tail: QueueItem | undefined; length: number; } export interface QueueItem { next: QueueItem | undefined; previous: QueueItem | undefined; value: T; } export declare function createStore(events: MusterEventSource, options?: { debug?: boolean; }): Store; export declare function subscribe(store: Store, action: GraphAction, callback: UpdateCallback, debug: boolean): DisposeCallback; export declare function getNodeData(store: Store, node: StatefulGraphNode): D | undefined; export declare function setNodeData(store: Store, node: StatefulGraphNode, data: D): void; export declare function getNodeState(store: Store, node: StatefulGraphNode): NodeState | undefined; export declare function setNodeState(store: Store, node: StatefulGraphNode, state: NodeState): void; export declare function invalidateNode(store: Store, node: GraphNode): boolean; export declare function invalidateNodeAction(store: Store, action: GraphAction): boolean; export declare function disposeScope(store: Store, scope: Scope): void; export declare function retainScope(store: Store, scope: Scope): number; export declare function retainNode(store: Store, node: GraphNode): number; export declare function retainCachedNode(store: Store, nodeCache: NodeCache): number; export declare function retainNodeAction(store: Store, action: GraphAction): number; export declare function releaseScope(store: Store, scope: Scope): number; export declare function releaseNode(store: Store, node: GraphNode): number; export declare function releaseNodeAction(store: Store, action: GraphAction): number;