import type { LiteralUnion } from 'type-fest'; import type { ComponentCacheObject, NuiComponent } from '../types'; type ComponentCacheHookEvent = 'add' | 'clear' | 'remove'; interface ComponentCacheHook { add(args: { component: NuiComponent.Instance; page: LiteralUnion<'unknown', string>; pageId?: string; }): void; clear(components: { [id: string]: NuiComponent.Instance; }): void; remove(args: { id: string | undefined; page: string | undefined; }): void; } declare class ComponentCache { #private; static _inst: ComponentCache; [Symbol.iterator](): { next(): { done: boolean; value: ComponentCacheObject | undefined; }; }; constructor(); get length(): number; on(e: 'add', fn: ComponentCacheHook['add']): this; on(e: 'clear', fn: ComponentCacheHook['clear']): this; on(e: 'remove', fn: ComponentCacheHook['remove']): this; emit(evt: Evt, ...args: Parameters): any[]; add(component: NuiComponent.Instance, pageId?: string, pageName?: string): ComponentCacheObject; clear(page?: string): this; find(kind: 'page', pageName: string): ComponentCacheObject; find(cb: (obj: ComponentCacheObject) => boolean | null | undefined): ComponentCacheObject; get(): Map; get(component: NuiComponent.Instance | string | undefined): ComponentCacheObject; has(component: NuiComponent.Instance | string | undefined): boolean; remove(component: NuiComponent.Instance | string): this; /** * Filter results by page name (if cb is a string) or callback (if by function) * @param cb Page name or callback function * @returns { ComponentCacheObject[] } */ filter(cb: string | ((obj: ComponentCacheObject) => boolean)): ComponentCacheObject[]; forEach(cb: (obj: ComponentCacheObject) => void): void; map(cb: (obj: ComponentCacheObject) => V): unknown[]; reduce(cb: (acc: A, obj: ComponentCacheObject) => A, initialValue: A): A; } export default ComponentCache;