import { Attribute } from "./kinds/attributes"; import { AttributeDefinition } from "./kinds/definitions"; import { ArborPlugin } from "./plugin"; import { Reifier } from "./reify/reifier"; import { ArborEmitter, ArborMonitor, MutationEmitter, MutationMonitor } from "./events"; import { Maybe } from "purify-ts/Maybe"; import { ReificationOptions } from "./kinds/options"; import { ListChildren } from "./children"; interface ReificationDetails { attr: Attribute; options: Partial; } /** * These are options associated with the operation of an Arbor instance. */ export interface ArborOptions { /** Indicates the underlying tree is immutable (i.e., the nodes in the tree will never be changed) (default: true) */ immutable: boolean; /** A list of potential plugins. (default: []) */ plugins: ArborPlugin[]; /** Default reification options (if any) to be applied to all attributes (default: {}) */ reification: Partial; /** Default reifier for attributes in this tree. (default: `StandardReifier`) */ reifier: Reifier; } /** * The `Arbor` class is used to manage creation of attributes associated with a tree. * The `root` of the tree is provided along with a function, `list`. Given any node * the tree, the `list` function should list all children associated with that node. * Finally, the `opts` argument allows any of the default `ArborOption` values * to be overriden. */ export declare class Arbor { /** Function to provide children for any given node */ list: ListChildren; /** The attribute that returns the parent of any node in the tree */ protected parentAttr: Attribute>; /** A map of already reified attributes (and the definitions they were reified from) */ protected reified: Map, ReificationDetails>; /** An event emitter for tracking attributes (creation, invocation, etc.) */ protected events: ArborEmitter; /** An event emitter for tracking events related to the tree and its structure */ protected mutations: MutationEmitter; /** The (current) root of the tree */ protected treeRoot: T; /** The options associated with this tree (with defaults filled in where necessary) */ protected options: ArborOptions; constructor( /** Initial tree root node */ root: T, /** Function to provide children for any given node */ list: ListChildren, /** Option overrides, if any */ opts?: Partial>); /** The current root of the tree */ get root(): T; /** Use this to subscribe to attribute related events */ get eventMonitor(): ArborMonitor; get mutationMonitor(): MutationMonitor; /** An attribute for retrieving the parent of any node in the tree */ get parent(): Attribute>; /** Use `attach` to perform bulk operations on the `Arbor` instance using a function. */ attach(f: (x: this) => R): R; /** * Add an attribute to the tree by providing a definition of the attribute and (optionally) * any reification options or even a custom reifier. **/ add(def: AttributeDefinition, opts?: Partial, reifier?: Reifier): Attribute; /** * This is a helper function that overlays various partial options * on top of each other. The result is still partial, but it represents * the relative priority of the various ways to override the options. */ protected completeOptions(def: AttributeDefinition, opts?: Partial): Partial; /** * This method should be called for a mutable tree when an update has been * made to a given node. * * @param n */ update(n: N): void; protected performInvalidation(n: T): void; /** * This method is used to change the root of the tree * * @param newroot The new root of the tree * @returns The new parent attribute */ setRoot(newroot: T): void; } export {};