/// import { Readable } from 'stream'; import { Queue } from './queue'; import { Projector } from './projector'; /** * 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 constructor. * * @param path Output path for the main executable. */ export declare abstract class Bundle extends Object { /** * File and directory names to exclude when adding a directory. */ excludes: RegExp[]; /** * Bundle main executable path. */ readonly path: string; /** * Projector instance. */ abstract readonly projector: Projector; /** * Open flag. */ protected _isOpen: boolean; /** * Close callbacks priority queue. */ protected _closeQueue: Queue; constructor(path: string); /** * 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 with file. * * @param player Player path. * @param configFile Config file. */ openFile(player: string, configFile: string | null): Promise; /** * Open output with data. * * @param player Player path. * @param configData Config data. */ openData(player: string, configData: Readonly | null): Promise; /** * Close output. */ close(): Promise; /** * Write out projector with player and file. * Has a callback to write out the resources. * * @param player Player path. * @param configFile Config file. * @param func Async function. * @returns Return value of the async function. */ withFile(player: string, configFile: string | null, func?: ((self: this) => Promise) | null): Promise; /** * Write out projector with player and data. * Has a callback to write out the resources. * * @param player Player path. * @param configData Config data. * @param func Async function. * @returns Return value of the async function. */ withData(player: string, configData: Readonly | null, func?: ((self: this) => Promise) | null): Promise; /** * 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; /** * 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 | null): Promise; /** * 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 | null): Promise; /** * Copy file as resource. * * @param destination Resource destination. * @param source Source file. * @param options Resource options. */ copyResourceFile(destination: string, source: string, options?: Readonly | null): Promise; /** * Copy symlink as resource. * * @param destination Resource destination. * @param source Source symlink. * @param options Resource options. */ copyResourceSymlink(destination: string, source: string, options?: Readonly | null): Promise; /** * Create a resource directory. * * @param destination Resource destination. * @param options Resource options. */ createResourceDirectory(destination: string, options?: Readonly | null): Promise; /** * Create a resource file. * * @param destination Resource destination. * @param data Resource data. * @param options Resource options. */ createResourceFile(destination: string, data: Readonly | string, options?: Readonly | null): Promise; /** * Create a resource symlink. * * @param destination Resource destination. * @param target Symlink target. * @param options Resource options. */ createResourceSymlink(destination: string, target: Readonly | string, options?: Readonly | null): Promise; /** * 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 | null): Promise; /** * Check that output path is valid, else throws. */ protected _checkOutput(): Promise; /** * 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, stat: (() => Promise<{ atime: Date; mtime: Date; mode: number; }>)): Promise; /** * Set resource attributes from options object. * * @param path File path. * @param options Options object. */ protected _setResourceAttributes(path: string, options: Readonly): Promise; /** * 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 with data. * * @param player Player path. * @param configData Config data. */ protected _openData(player: string, configData: Readonly | null): Promise; /** * Close output. */ protected _close(): Promise; /** * 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; /** * Main application file extension. * * @returns File extension. */ abstract get extension(): string; /** * Create projector instance for the bundle. * * @returns Projector instance. */ protected abstract _createProjector(): Projector; /** * Write the launcher file. */ protected abstract _writeLauncher(): Promise; }