import { type ObjectToFunctionPropertyNames, type Observable, type Reference } from "@knyt/artisan"; import type { Effect } from "./Effect.ts"; import { InputStateController } from "./InputStateController.ts"; import { ReactiveControllerHostAdapter } from "./ReactiveControllerHostAdapter.ts"; /** * This symbol is used to attach the controllable adapter * to an object that implements the `Controllable` interface. * * @remarks * * This symbol must be in the runtime-wide symbol registry * (`Symbol.for`) so that the reactive adapter can be * accessed from within different contexts. * * @internal scope: workspace */ export declare const __hostAdapter: unique symbol; /** * An object with a `ControllableAdapter` property. */ export type Controllable = { [__hostAdapter]: ControllableAdapter; }; /** * @internal scope: workspace */ export declare class ControllableAdapter extends ReactiveControllerHostAdapter { #private; /** * Adds a controller that subscribes to an observable and requests * an update on the host whenever the observable emits a value. * * @remarks * * A strong reference to the observable is retained to prevent * it from being garbage collected, */ track>(observable: T): T; /** * Unsubscribes the host from an observable, * stopping updates from being requested on new values, * and removes the strong reference to the observable. * * @remarks * * When called, if the observable is not strongly referenced by any other * part of the code, it may be garbage collected. */ untrack>(observable: T): T; /** * Creates an effect that tracks an observable and requests updates * whenever the observable emits a new value while the element is connected. */ watch>(observable: T): Effect; /** * Creates a reference tracked by the host using the initial value. * * @remarks * * This is a simple way to create reactive state. * A reference is created with the initial value, * and the host subscribes to it. When the value changes, * a request for an update is made on the host. * * @public * * @see {@link Reference} * @see {@link track} */ hold(initialValue: T, onUpdate?: Reference.UpdateHandler): Reference; /** * Creates a controller that manages the state of an input element. * * @beta This is a beta feature and may change in the future. */ controlInput(options: InputStateController.Options): InputStateController; /** * @internal scope: workspace */ stageModification({ shouldModify, modification, }: { /** * Determines whether the modification should be applied immediately. * * @remarks * * If `true`, the modification will be applied immediately * and the root element will be modified. * If `false`, the modification will be staged and applied later * when the root element is connected. * * This value is typically determined by whether the host element * is connected to the DOM or not. * If the host is not connected, the modification will be staged * and applied later when the host is connected. */ shouldModify: boolean; modification: () => Promise; }): Promise; } /** * Determines whether the input is a {@link Controllable}. * * @internal scope: workspace */ export declare function isControllable(value: unknown): value is Controllable; /** * Assert that the object is a {@link Controllable}. * * @internal scope: workspace */ export declare function assertControllable(obj: unknown): asserts obj is Controllable; type MixableMethodName = Exclude, "connectedCallback" | "disconnectedCallback" | "debugLog">; type MixableMemberName = MixableMethodName | "updateComplete"; export declare function applyControllableMixin(Constructor: T, members?: MixableMemberName[]): void; export {}; //# sourceMappingURL=Controllable.d.ts.map