/** @typedef {new (...args: any[]) => any} NewTinyClass */ export type NewTinyClass = new (...args: any[]) => any; export type PluginDefinition = { /** * - The unique identifier for the plugin. */ name: string; /** * - Array of plugin names required before applying this one. */ dependencies?: string[]; /** * - Function that receives the base class and returns the extended class. */ apply: (Base: TBase, classes: AppliedPluginClasses) => TExtended; }; /** * @template {NewTinyClass} TBase * @template {NewTinyClass} TExtended * @template {NewTinyClass[]} AppliedPluginClasses * @typedef {Object} PluginDefinition * @property {string} name - The unique identifier for the plugin. * @property {string[]} [dependencies] - Array of plugin names required before applying this one. * @property {(Base: TBase, classes: AppliedPluginClasses) => TExtended} apply - Function that receives the base class and returns the extended class. */ /** * Manages the composition of a base class with multiple optional plugins (Mixins). * @template {NewTinyClass} T * @template {T|NewTinyClass} oldT */ declare class TinyClassManager { #private; /** * Gets the list of plugins currently applied to this instance. * @returns {string[]} Array of applied plugin names. */ get appliedPlugins(): string[]; /** * Gets the list of plugin classes currently applied to this instance. * @returns {[...oldT[], T]} Array of applied plugin classes. */ get appliedPluginClasses(): [...oldT[], T]; /** * Gets the total size of the current class chain hierarchy. * @returns {number} The count of applied plugins plus the core base. */ get size(): number; /** * Holds the current state of the class chain. */ get currentClass(): T; /** * Protects the instance from being consumed or reused after transition. */ get used(): boolean; /** * Initializes the manager with a core class. * @param {T} coreClass - The foundational class to be extended. * @param {oldT[]} [oldClasses=[]] */ constructor(coreClass: T, oldClasses?: oldT[]); /** * Applies a plugin to the class chain using a definition object. * @deprecated Use {@link insert} instead. * @template {NewTinyClass} R * @param {PluginDefinition} plugin - The plugin module to be integrated. * @returns {TinyClassManager} A new manager instance holding the extended class chain. * @throws {Error} Throws if instance is already consumed, plugin is duplicate, or dependencies are missing. */ use(plugin: PluginDefinition): TinyClassManager; /** * Inserts a plugin directly by passing its apply function. * It reads `_tinyDepName` and `_tinyDeps` statically from the returned class. * @template {NewTinyClass} R * @param {(ClassItem: T, classes: [...oldT[], T]) => R} applyFn - Function that receives the base class and returns the extended class. * @returns {TinyClassManager} A new manager instance holding the extended class chain. * @throws {Error} Throws if static properties are missing, instance is consumed, or validation fails. */ insert(applyFn: (ClassItem: T, classes: [...oldT[], T]) => R): TinyClassManager; /** * Finalizes the composition and returns the fully built class. * @returns {T} The final class representing the last extended version in the chain. * @throws {Error} Throws if the manager instance has already been used or finalized. */ build(): T; } export default TinyClassManager; //# sourceMappingURL=TinyClassManager.d.mts.map