import { Observable } from "rxjs"; import { NostrEvent } from "../helpers/event.js"; import type { ProfilePointer } from "../helpers/pointers.js"; import { ChainableObservable } from "../observable/chainable.js"; import { CastRefEventStore } from "./cast.js"; export type PubkeyCastConstructor = (new (pointer: ProfilePointer, store: CastRefEventStore) => C) & { cache?: Map>; cacheRegistry?: FinalizationRegistry; }; /** * Cast a pubkey to a specific class instance. * Works like {@link castUser} - returns a cached singleton per pubkey+relay-hints combination. * * @note Instances are held weakly so unused casts can be garbage collected instead of * accumulating one instance per pubkey for the lifetime of the process. */ export declare function castPubkey(pubkey: string | NostrEvent | ProfilePointer, cls: PubkeyCastConstructor, store: CastRefEventStore): C; /** Base class for pubkey-based casts (analogous to {@link EventCast} for events) */ export declare class PubkeyCast { #private; readonly pointer: ProfilePointer; readonly store: CastRefEventStore; /** A global cache of pubkey -> weak instance reference, populated by {@link castPubkey} */ static cache: Map>; /** Cleans up dead {@link cache} entries when their instances are garbage collected */ static cacheRegistry?: FinalizationRegistry; constructor(pointer: ProfilePointer, store: CastRefEventStore); /** The hex pubkey represented by this cast */ get pubkey(): string; /** Internal method for creating a cached observable reference */ protected $$ref(key: string, builder: (store: CastRefEventStore) => Observable): ChainableObservable; }