import { Readable } from 'node:stream';
import { Queue } from './queue.ts';
import { Projector } from './projector.ts';
/**
 * Options for adding resources.
 */
export interface IBundleResourceOptions {
    /**
     * Access time.
     */
    atime?: null | Date;
    /**
     * Copy source atime if not set.
     */
    atimeCopy?: null | boolean;
    /**
     * Modification time.
     */
    mtime?: null | Date;
    /**
     * Copy source mtime if not set.
     */
    mtimeCopy?: null | boolean;
    /**
     * Mark files and symlinks as executable.
     */
    executable?: null | boolean;
    /**
     * Copy source executable if not set.
     */
    executableCopy?: null | boolean;
    /**
     * Optionally merge directory contents.
     */
    merge?: null | boolean;
    /**
     * Skip recursive directory copy.
     */
    noRecurse?: null | boolean;
}
/**
 * Bundle object.
 */
export declare abstract class Bundle {
    /**
     * File and directory names to exclude when adding a directory.
     */
    excludes: RegExp[];
    /**
     * Bundle main executable path.
     */
    readonly path: string;
    /**
     * Flat bundle.
     */
    readonly flat: boolean;
    /**
     * Projector instance.
     */
    abstract readonly projector: Projector;
    /**
     * Open flag.
     */
    protected _isOpen: boolean;
    /**
     * Close callbacks priority queue.
     */
    protected _closeQueue: Queue;
    /**
     * Bundle constructor.
     *
     * @param path Output path for the main executable.
     * @param flat Flat bundle.
     */
    constructor(path: string, flat?: boolean);
    /**
     * Check if output open.
     *
     * @returns Returns true if open, else false.
     */
    get isOpen(): boolean;
    /**
     * Check if name is excluded file.
     *
     * @param name File name.
     * @returns Returns true if excluded, else false.
     */
    isExcludedFile(name: string): boolean;
    /**
     * Open output.
     */
    open(): Promise<void>;
    /**
     * Close output.
     */
    close(): Promise<void>;
    /**
     * Write out the bundle.
     * Has a callback to write out the resources.
     *
     * @param func Async function.
     * @returns Return value of the async function.
     */
    write<T>(func?: ((self: this) => Promise<T>) | null): Promise<T | null>;
    /**
     * Get path for resource.
     *
     * @param destination Resource destination.
     * @returns Destination path.
     */
    resourcePath(destination: string): string;
    /**
     * Check if path for resource exists.
     *
     * @param destination Resource destination.
     * @returns True if destination exists, else false.
     */
    resourceExists(destination: string): Promise<boolean>;
    /**
     * Copy resource, detecting source type automatically.
     *
     * @param destination Resource destination.
     * @param source Source directory.
     * @param options Resource options.
     */
    copyResource(destination: string, source: string, options?: Readonly<IBundleResourceOptions> | null): Promise<void>;
    /**
     * Copy directory as resource, recursive copy.
     *
     * @param destination Resource destination.
     * @param source Source directory.
     * @param options Resource options.
     */
    copyResourceDirectory(destination: string, source: string, options?: Readonly<IBundleResourceOptions> | null): Promise<void>;
    /**
     * Copy file as resource.
     *
     * @param destination Resource destination.
     * @param source Source file.
     * @param options Resource options.
     */
    copyResourceFile(destination: string, source: string, options?: Readonly<IBundleResourceOptions> | null): Promise<void>;
    /**
     * Copy symlink as resource.
     *
     * @param destination Resource destination.
     * @param source Source symlink.
     * @param options Resource options.
     */
    copyResourceSymlink(destination: string, source: string, options?: Readonly<IBundleResourceOptions> | null): Promise<void>;
    /**
     * Create a resource directory.
     *
     * @param destination Resource destination.
     * @param options Resource options.
     */
    createResourceDirectory(destination: string, options?: Readonly<IBundleResourceOptions> | null): Promise<void>;
    /**
     * Create a resource file.
     *
     * @param destination Resource destination.
     * @param data Resource data.
     * @param options Resource options.
     */
    createResourceFile(destination: string, data: Readonly<Uint8Array> | string, options?: Readonly<IBundleResourceOptions> | null): Promise<void>;
    /**
     * Create a resource symlink.
     *
     * @param destination Resource destination.
     * @param target Symlink target.
     * @param options Resource options.
     */
    createResourceSymlink(destination: string, target: Readonly<Uint8Array> | string, options?: Readonly<IBundleResourceOptions> | null): Promise<void>;
    /**
     * Stream readable source to resource file.
     *
     * @param destination Resource destination.
     * @param data Resource stream.
     * @param options Resource options.
     */
    streamResourceFile(destination: string, data: Readable, options?: Readonly<IBundleResourceOptions> | null): Promise<void>;
    /**
     * Check that output path is valid, else throws.
     */
    protected _checkOutput(): Promise<void>;
    /**
     * Expand resource options copy properties with stat object from source.
     *
     * @param options Options object.
     * @param stat Stat function.
     * @returns Options copy with any values populated.
     */
    protected _expandResourceOptionsCopy(options: Readonly<IBundleResourceOptions>, stat: () => Promise<{
        atime: Date;
        mtime: Date;
        mode: number;
    }>): Promise<IBundleResourceOptions>;
    /**
     * Set resource attributes from options object.
     *
     * @param path File path.
     * @param options Options object.
     */
    protected _setResourceAttributes(path: string, options: Readonly<IBundleResourceOptions>): Promise<void>;
    /**
     * Get file mode executable.
     *
     * @param mode Current mode.
     * @returns Is executable.
     */
    protected _getResourceModeExecutable(mode: number): boolean;
    /**
     * Set file mode executable.
     *
     * @param mode Current mode.
     * @param executable Is executable.
     * @returns File mode.
     */
    protected _setResourceModeExecutable(mode: number, executable: boolean): number;
    /**
     * Open output.
     */
    protected _open(): Promise<void>;
    /**
     * Close output.
     */
    protected _close(): Promise<void>;
    /**
     * Assert bundle is open.
     */
    protected _assertIsOpen(): void;
    /**
     * Assert resource does not exist, returning destination path.
     *
     * @param destination Resource destination.
     * @param ignoreDirectory Ignore directories.
     * @returns Destination path.
     */
    protected _assertNotResourceExists(destination: string, ignoreDirectory?: boolean): Promise<string>;
    /**
     * Get the projector path.
     *
     * @returns This path or the nested path.
     */
    protected _getProjectorPath(): string;
    /**
     * Get nested projector path.
     *
     * @returns Output path.
     */
    protected abstract _getProjectorPathNested(): string;
    /**
     * Create projector instance for the bundle.
     *
     * @returns Projector instance.
     */
    protected abstract _createProjector(): Projector;
}
