import { State } from "./state.js"; //#region src/context.d.ts type Accept = T | State.Type | Record>; type Expect = (state: T, downstream: boolean) => (() => void) | void; declare namespace Context { export { Accept, Expect }; } declare class Context { static get root(): Context; /** Get the context for a State. Adapters may override to provide framework context. */ static get(state?: State): Context; id: string; parent?: Context; scope: Set; consume: Map, Set<[Expect, boolean | undefined]> | null>; provide: Map, Set<[State, boolean]> | null>; protected inputs: Record; private cleanup; constructor(arg?: Context | Accept); private traverse; private register; /** Find specified type upstream. Throws if not found. */ get(Type: State.Extends, required?: true): T; /** Find specified type upstream. Returns undefined if not found. */ get(Type: State.Extends, required?: boolean): T | undefined; /** Subscribe to a type becoming available in context. */ get(Type: State.Extends, callback: Expect, downstream?: boolean): () => void; /** Lookup excluding a specific instance (used by State.prototype.get for upstream-of-self semantics). */ get(Type: State.Extends, arg: boolean | Expect | undefined, downstream: boolean | undefined, skip: State): T | undefined | (() => void); /** * Register one or more States to this context. * * Context will add or remove States as needed to keep with provided input. * * @param inputs State, State class, or map of States / State classes to register. * @param forEach Optional callback to run for each State registered. Receives * whether this context created the State - and so will destroy it - as * opposed to it having been provided already active. May return a callback * to run before that entry is dropped. */ set(inputs: Accept, forEach?: (state: T, owned: boolean) => (() => void) | void): this; add(I: State, explicit?: boolean): () => void; /** * Create a child context, optionally registering one or more States to it. * * @param inputs State, State class, or map of States / State classes to register. */ push(inputs?: Accept): Context; /** * Remove all States from this context. * * Will also run any cleanup callbacks registered when States were added. */ pop(): void; } /** * Add `value` to the context `state` was added to. A context-less `state` holds * it instead - every context adding `state` later adds its held children too. */ declare function join(state: State, value: State): () => void; //#endregion export { Context, join }; //# sourceMappingURL=context.d.ts.map