import { Graph, Lib, NodysseusNode, NodysseusStore } from "../types.js"; export declare function compareObjectsNeq(value1: any, value2: any): boolean; type NodeKind = "const" | "map" | "var" | "bind"; type Nothing = { __kind: "nothing"; }; export declare const isNothing: (a: any) => a is Nothing; export declare const isNothingOrUndefined: (a: any) => a is Nothing; export declare class State { private value; constructor(value?: T | Nothing); write(value: T | Nothing): void; read(): Nothing | T; } export type WatchNode = { __kind: "watch"; id: string; watch: AsyncIterator; graphNode?: NodysseusNode; }; export declare const isWatchNode: (a: any) => a is AnyNode; export type AnyNode = Node; export type UnwrapNode = T extends AnyNode ? I : never; type AnyNodeMap> = { [k in keyof S]: AnyNode; }; export type Node = { __kind: K; id: string; value: State; }; export type ConstNode = Node<"const", T>; export type VarNode = AnyNode & { __kind: "var"; set: (value: T) => void; compare: (a: T, b: T) => boolean; }; export type MapNode> = Node<"map", T> & { fn: State<(s: S) => T>; cachedInputs: State; isStale: (p: S, n: S) => boolean; inputs: Record; isDirty: State; }; export type BindNode> = T extends AnyNode ? Node<"bind", T> & { isStale: (p: S, n: S) => boolean; fn: (s: S) => T; inputs: { [k in keyof S]: string; }; cachedInputs: State; isDirty: State; } : never; declare class Scope { private nodes; constructor(); add(node: Node): void; get(id: string): AnyNode; has(id: string): boolean; count(): number; findKeys(id: string): string[]; removeAll(id: string): void; } export declare const constNode: (a: T, id?: string) => ConstNode; export declare const varNode: (set: (value: T) => void, compare?: (a: T, b: T) => boolean, id?: string) => VarNode; export declare const mapNode: >(inputs: { [k in keyof S]: AnyNode; }, fn: (s: S) => T, isStale: (previous: S, next: S) => boolean, id?: string) => MapNode; export declare const bindNode: , S extends Record>(inputs: { [k in keyof S]: AnyNode; }, fn: (inputs: S) => T | PromiseLike, isStale?: (p: any, n: any) => boolean, id?: string) => BindNode; export declare const handleError: (e: Error, nodeGraphId: string) => void; type NodeOutputs = AnyNode<{ value: AnyNode; display: AnyNode; metadata: AnyNode; }> & { graphId: string; nodeId: string; }; export type NodeOutputsU = NodeOutputs; export declare class NodysseusRuntime { private id; store: NodysseusStore; private event; scope: Scope; private _outputReturns; private watches; private outputs; private inputs; private rerun; private lib; private eventQueue; private running; private dirtying; constructor(id: any, store: NodysseusStore, lib?: Lib, event?: string); refs(): string[] | Promise; graphExport(graphid: any): any; nodeCount(): void; createWatch(node: AnyNode): AsyncIterable; clearWatch(node: any, watch: any): void; private addWatchFn; private resetOutputs; private checkWatch; private checkWatches; private dirty; constNode(v: T, id?: string, useExisting?: boolean): AnyNode; varNode(initial?: T, compare?: (a: T, b: T) => boolean, id?: string, useExisting?: boolean, dirty?: boolean): VarNode; mapNode>(inputs: { [k in keyof S]: AnyNode; }, fn: (s: S) => T, isStale?: (previous: S, next: S) => boolean, id?: string, useExisting?: boolean): AnyNode; /** * Bind a function that creates a node to inputs. Inspired by monadic bind. */ bindNode, S extends Record>(inputs: { [k in keyof S]: AnyNode; }, fn: (s: S) => T | PromiseLike, isStale?: (previous: S, next: S) => boolean, id?: string, useExisting?: boolean): AnyNode; /** * Uses bindNode to create a switch statement based on a key node */ switchNode>(key: AnyNode, inputs: { [k in keyof S]: AnyNode; }, id?: string, useExisting?: boolean): AnyNode>; accessor>(map: AnyNode> | NodeOutputsU, key: string, id: string, useExisting: boolean, isNodeRun?: boolean): AnyNode; private removeKey; runNodeNode(node: AnyNode>, nodeGraphId: string, useExisting?: boolean): AnyNode; fromNode>(graph: Graph | string, nodeId: string, closure?: AnyNodeMap): NodeOutputs | Promise>; private calcNode; private valueMap; private checkEvents; private mergeClosure; private dereference; private fromNodeInternal; private runNode; runGraphNode(graph: Graph | string, node: string): T | Promise; run(node: AnyNode | Promise> | string, _output?: "display" | "value" | "metadata"): T | Promise; } export {};