@yoot/yoot
Version:
The core library for yoot, providing a CDN-agnostic, chainable API for image URL transformations and adapter integration.
52 lines (51 loc) • 1.52 kB
TypeScript
import type { Adapter } from './adapter.ts';
export { adapterStore, YOOT_BRAND };
export type { AdapterStore };
declare const YOOT_BRAND: unique symbol;
/**
* Internal adapter store system.
*
* @remarks
* This returns a singleton object used to register adapters and
* quickly retrieve them based on URL hostname.
*
* @internal
* @returns An object with methods to `register` and `get` adapters.
*/
declare const adapterStore: AdapterStore;
/**
* Internal adapter store system.
*
* @remarks
* This singleton object manages adapter registration, unique storage (using a Set),
* and efficient retrieval via a hostname cache.
* It includes methods for testing, `reset` and `size`.
*
* @internal
* @returns An object with methods to `register`, `get`, `reset`, and get the `size` of the store.
*/
type AdapterStore = {
/** Registers adapter(s). Duplicate instances are ignored due to internal Set. */
register(...adapters: Adapter[]): void;
/**
* Retrieves an adapter for the given URL.
*
* @remarks
* Checks hostname cache first, then iterates the unique set of registered adapters.
*/
get(url: URL): Adapter | undefined;
/**
* Clears the internal cache and registered adapters.
*
* @remarks
* This is useful for debugging and testing purposes.
*/
reset(): void;
/**
* Returns the number of registered adapters.
*
* @remarks
* This is useful for debugging and testing purposes.
*/
size(): number;
};