/** * Represents an object manager that controls the lifetime of other objects. **/ export declare class ObjectManager { /** * Initializes a new instance of {@link ObjectManager}. **/ constructor(); /** * Disposes the {@link ObjectManager} instance. **/ dispose(): void; [Symbol.dispose](): void; /** * Gets the object manager ID. **/ get id(): number; /** * Indicates whether the object manager was created with the {@link pushObjectManager} method or the {@link withObjectManager} decorator. **/ get stacked(): boolean; /** * Checks if the {@link ObjectManager} instance has not yet been disposed. **/ checkAlive(): void; } /** * Gets a value indicating if there is at least one {@link ObjectManager} on the stack. * @returns true if the current {@link ObjectManager} exists, false if the stack is empty. */ export declare function hasCurrentObjectManager(): boolean; /** * Gets the currently active {@link ObjectManager} from the stack. * @returns The current {@link ObjectManager}. */ export declare function getCurrentObjectManager(): ObjectManager; /** * Creates and pushed an {@link ObjectManager} to the global stack. */ export declare function pushObjectManager(): void; /** * Poppes and disposes the {@link ObjectManager} at the top of the global stack. */ export declare function popObjectManager(): void; /** * Decorator function that automatically manages resources for class methods and functions. * Creates an {@link ObjectManager} that is automatically disposed when the function completes. * Supports both synchronous and asynchronous functions while preserving return values. * * @remarks * This decorator provides automatic resource management for functions and class methods. * It handles both synchronous and asynchronous operations, ensuring proper cleanup * even when exceptions occur or promises are rejected. * * @example * **Usage as a method decorator:** * ```typescript * class PdfService { * @withObjectManager * createPdf() { * const doc = new PdfDocument(); // Automatically registered with ObjectManager * const brush = new Brush(); // Automatically registered with ObjectManager * ... * * @withObjectManager * async createPdfAsync() { * const doc = new PdfDocument(); * await someAsyncOperation(); * ... * ``` * * @example * **Usage as a function wrapper:** * ```typescript * const createPdf = withObjectManager(() => { * const doc = new PdfDocument(); * ... * }); * * const createPdfAsync = withObjectManager(async () => { * const doc = new PdfDocument(); * await someAsyncOperation(); * ... * }); * ``` * * @example * **Usage with new-style decorators (TypeScript 5.0+):** * ```typescript * class Service { * @withObjectManager * method() { * // Automatic resource management * } * } * ``` * * @param target - The class prototype, constructor, or function to be decorated * @param propertyKey - The name of the method being decorated (for class methods) * @param descriptor - The property descriptor for the method (for class methods) * @returns The modified property descriptor or wrapped function * * @throws {Error} When resource cleanup fails. Errors are logged but not rethrown to preserve original error flow. * * @public */ export declare function withObjectManager(target: any, propertyKey?: string, descriptor?: PropertyDescriptor): any;