/** * The storage type for hook listeners. `(...args: never[]) => unknown` is the "top type" of * functions: every function is assignable to it (parameter contravariance -- `never` is assignable * to every type), yet it cannot be invoked without a deliberate cast. This lets the hooks system * accept any correctly-typed listener without resorting to `any`, while confining the unavoidable * dynamically-typed call to a single cast at the dispatch boundary (`fastCall`). */ export type HookCallback = (...args: never[]) => unknown; export interface HookEntry { callback: HookCallback; orderIndex: number; runOnce: boolean; initialHook: boolean; /** * Intrusive singly-linked-list pointer to the next entry. The entry IS the list node (no wrapper * object) so dispatch reads `entry.callback` with a single indirection. `null` marks the tail. */ next: HookEntry | null; } /** * A per-hook singly-linked list. `head`/`tail` allow O(1) append; dispatch walks `head` → `next`. */ interface HookList { head: HookEntry | null; tail: HookEntry | null; } /** * The class represents a collection that allows to manage hooks (add, remove). * * Storage is a `Map`. Removal is a true delete (relink) — there * is no soft-delete `skip` flag and no periodic compaction. An in-flight `run()` stays correct because it * reads `entry.next` fresh after each callback (a later entry removed mid-run is skipped) and never nulls a * removed node's `next` (a callback removing itself can still advance). * * @class HooksBucket */ export declare class HooksBucket { #private; /** * Initializes the bucket and pre-creates empty hook collections for all currently registered hook names. */ constructor(); /** * Gets the internal linked list for the provided hook name. Used by the dispatcher (`Hooks#runHandlers`) * to walk entries without materializing an array on the hot path. * * @param {string} hookName The name of the hook. * @returns {HookList|null} */ getList(hookName: string): HookList | null; /** * Gets all live hooks for the provided hook name as an array, in execution order. The returned entries are * the live list nodes (not copies), so an in-place `addAsFixed` callback swap is reflected in a * previously returned array — relied on by the framework wrappers. * * @param {string} hookName The name of the hook. * @returns {HookEntry[]} */ getHooks(hookName: string): HookEntry[]; /** * Adds a new hook to the collection. * * @param {string} hookName The name of the hook. * @param {Function} callback The callback function to add. * @param {{ orderIndex?: number, runOnce?: boolean, initialHook?: boolean }} options The options object. */ add(hookName: string, callback: HookCallback, options?: { orderIndex?: number; runOnce?: boolean; initialHook?: boolean; }): void; /** * Checks if there are any live hooks for the provided hook name. * * @param {string} hookName The name of the hook. * @returns {boolean} */ has(hookName: string): boolean; /** * Removes a hook from the collection (true delete). Returns `true` if the callback was found and removed, * `false` otherwise. * * @param {string} hookName The name of the hook. * @param {*} callback The callback function to remove. * @returns {boolean} */ remove(hookName: string, callback: HookCallback): boolean; /** * Destroys the bucket. */ destroy(): void; } export {};