import React from "react"; import { AtomChange } from "../change/index.ts"; import { DetachedValue } from "../detached/index.ts"; import { EnsoUtils as Utils } from "../utils.ts"; import type { Atom } from "./definition.ts"; import { externalSymbol } from "./internal/base/index.ts"; import { AtomInternal, AtomInternalCollection } from "./internal/index.ts"; export declare class AtomImpl { #private; static prop: string; /** * Creates and memoizes a new instance from the provided initial value. * Just like `useState`, it will not recreate the instance on the value * change. * * @param initialValue - Initial value. * @param deps - Hook dependencies. * * @returns Memoized instance. */ static use(initialValue: Value, deps: React.DependencyList): import("../hooks/index.ts").TypedHook.Memoized>; static create(value: Value, parent?: Atom.Parent.Bare.Ref): AtomImpl; /** * Ensures that the atom is not undefined. It returns a tuple with ensured * atom and dummy atom. If the atom is undefined, the dummy atom will * return as the ensured, otherwise the passed atom. * * It allows to workaround the React Hooks limitation of not being able to * call hooks conditionally. * * The dummy atom is frozen and won't change or trigger any events. * * @param atom - The atom to ensure. Can be undefined. * @returns Atoms tuple, first element - ensured atom, second - dummy atom */ static useEnsure(atom: AtomImpl | Utils.Falsy, mapper?: Atom.Static.Ensure.Bare.Mapper, Result>): AtomImpl; constructor(value: Value, parent?: Atom.Parent.Bare.Ref); deconstruct(): void; readonly id: string; get value(): Value; useValue(props: any): unknown; set(value: Value | DetachedValue, notifyParents?: boolean): this; /** * Paves the atom with the provided fallback value if the atom is undefined * or null. It ensures that the atom has a value, which is useful when * working with deeply nested optional objects, i.e., settings. It allows * creating the necessary atoms to assign validation errors to them, even if * the parents and the atom itself are not set. * * @param fallback - Fallback value to set if the atom is undefined or null. * * @returns Atom without null or undefined value in the type. */ pave(fallback: Utils.NonNullish): AtomImpl>; compute(callback: Atom.Compute.Callback): Computed; useCompute(callback: Atom.Compute.Callback, deps: React.DependencyList): Computed; useMeta(): {}; internal: AtomInternal; get size(): number; remove(key: keyof Value): any; forEach(callback: AtomInternalCollection.Callback): void; map(callback: AtomInternalCollection.Callback): Result[]; find(predicate: AtomInternalCollection.Predicate): AtomImpl | undefined; filter(predicate: AtomInternalCollection.Predicate): AtomImpl[]; self: any; push(item: ItemValue): AtomImpl; insert(index: number, item: ItemValue): AtomImpl; useCollection(): AtomImpl; __parent: Atom.Parent.Bare.Ref | undefined; get root(): any; get parent(): any; get key(): any; get $(): {} | undefined; at(key: keyof Value): any; get try(): Atom.BareTry, keyof Value> | undefined | null; get path(): any; get name(): any; static name(path: any): any; lookup(path: Atom.Path): AtomImpl | undefined; optional(): any; static lastChanges: WeakMap; get lastChanges(): any; get events(): any; trigger(changes: AtomChange, notifyParents?: boolean): void; watch(callback: Atom.Watch.Bare.Callback, sync?: boolean): Atom.Unwatch; useWatch(callback: Atom.Watch.Bare.Callback): void; unwatch(): void; /** * Withholds the atom changes until `unleash` is called. It allows to batch * changes when submitting a form and send the submitting even to the atom * along with the submitting value. * * TODO: I added automatic batching of changes, so all the changes are send * after the current stack is cleared. Check if this functionality is still * needed. */ withhold(): void; unleash(): void; into(intoMapper: any): { from: (fromMapper: any) => any; }; useInto(intoMapper: any, intoDeps: React.DependencyList): import("../hooks/index.ts").TypedHook.Memoized<{ from: import("../hooks/index.ts").TypedHook.Memoized<(fromMapper: any, fromDeps: React.DependencyList) => any>; }>; decompose(): any; useDecompose(callback: any, deps: React.DependencyList): any; decomposeNullish(): any; useDecomposeNullish(callback: any, deps: React.DependencyList): any; discriminate>(discriminator: Discriminator): any; useDiscriminate>(discriminator: Discriminator): any; useDefined(type: Atom.DefinedType): any; shared(): this; get [externalSymbol](): { move: (newKey: any) => void; create: (value: any) => bigint; clear: () => void; }; clearCache(): void; } export declare class AtomProxyInternal { #private; constructor(external: AtomImpl, source: AtomImpl, into: any, from: any); deconstruct(): void; connect(source: AtomImpl): void; } export declare class AtomOptionalInternal { #private; static instances: WeakMap, AtomOptionalInternal>; static instance(atom: AtomImpl): AtomOptionalInternal; constructor(external: AtomImpl, target: Atom.BareOptionalTarget>); get value(): Value; static value(prop: Atom.Prop, target: Atom.BareOptionalTarget>): unknown; at>(key: Key): any; get try(): Atom.BareTry, keyof Value> | undefined | null; get path(): Atom.Path; get root(): AtomImpl; } //# sourceMappingURL=implementation.d.ts.map