/// <reference types="node" />
import { SecurityKeystore } from './security/keystore';
import { Signature } from './signature';
import { Hasher } from './hasher';
/**
 * Options for adding resources.
 */
export interface IPackagerResourceOptions {
    /**
     * Mark file as executable.
     */
    executable?: boolean | null;
    /**
     * Specific file modification time.
     */
    mtime?: Date | null;
}
/**
 * Packager constructor.
 *
 * @param path Output path.
 */
export declare abstract class Packager extends Object {
    /**
     * Make a debug build.
     */
    debug: boolean;
    /**
     * Keystore object to use for signing.
     */
    keystore: Readonly<SecurityKeystore> | null;
    /**
     * Timestamp URL.
     */
    timestampUrl: string | null;
    /**
     * File and directory names to exclude when added a directory.
     */
    excludes: RegExp[];
    /**
     * Output path.
     */
    readonly path: string;
    /**
     * Open flag.
     */
    protected _isOpen: boolean;
    /**
     * Adding a resource flag.
     */
    protected _isAddingResource: boolean;
    /**
     * Hasher object.
     */
    protected _hasher: Hasher;
    /**
     * Signature object.
     */
    protected _signature: Signature | null;
    constructor(path: string);
    /**
     * Check if output open.
     *
     * @returns Returns true if open, else false.
     */
    get isOpen(): boolean;
    /**
     * Open with application descriptor XML data.
     *
     * @param applicationData XML data.
     */
    open(applicationData: Readonly<Buffer>): Promise<void>;
    /**
     * Open with application descriptor file.
     *
     * @param descriptorFile Application descriptor file.
     */
    openFile(descriptorFile: string): Promise<void>;
    /**
     * Close output.
     */
    close(): Promise<void>;
    /**
     * Run asyncronous function with automatic open and close.
     *
     * @param applicationData XML data.
     * @param func Async function.
     * @returns Return value of the async function.
     */
    with<T>(applicationData: Readonly<Buffer>, func: (self: this) => Promise<T>): Promise<T>;
    /**
     * Run asyncronous function with automatic open and close.
     *
     * @param descriptorFile Application descriptor file.
     * @param func Async function.
     * @returns Return value of the async function.
     */
    withFile<T>(descriptorFile: string, func: (self: this) => Promise<T>): Promise<T>;
    /**
     * Check if name is excluded file.
     *
     * @param name File name.
     * @returns Returns true if excluded, else false.
     */
    isExcludedFile(name: string): boolean;
    /**
     * Add resource with file.
     *
     * @param source File path.
     * @param destination Packaged file relative destination.
     * @param options Resource options.
     */
    addResourceFile(source: string, destination?: string | null, options?: Readonly<IPackagerResourceOptions> | null): Promise<void>;
    /**
     * Add resource with directory.
     * Walks the directory looking for files to add, skips excluded file names.
     *
     * @param source Directory path.
     * @param destination Packaged directory relative destination.
     * @param options Resource options.
     */
    addResourceDirectory(source: string, destination?: string | null, options?: Readonly<IPackagerResourceOptions> | null): Promise<void>;
    /**
     * Add resource with data.
     *
     * @param destination Packaged file relative destination.
     * @param data Resource data.
     * @param options Resource options.
     */
    addResource(destination: string, data: Readonly<Buffer>, options?: Readonly<IPackagerResourceOptions> | null): Promise<void>;
    /**
     * Create Hasher object.
     *
     * @returns Hasher object.
     */
    protected _createHasher(): Hasher;
    /**
     * Create Signature object.
     *
     * @returns Hasher object.
     */
    protected _createSignature(): Signature;
    /**
     * Path of the mimetype meta resource.
     *
     * @returns Resource path.
     */
    protected get _metaResourceMimetypePath(): string;
    /**
     * Path of the application meta resource.
     *
     * @returns Resource path.
     */
    protected get _metaResourceApplicationPath(): string;
    /**
     * Path of the hash meta resource.
     *
     * @returns Resource path.
     */
    protected get _metaResourceHashPath(): string;
    /**
     * Path of the debug meta resource.
     *
     * @returns Resource path.
     */
    protected get _metaResourceDebugPath(): string;
    /**
     * Path of the signatures meta resource.
     *
     * @returns Resource path.
     */
    protected get _metaResourceSignaturesPath(): string;
    /**
     * Get encoded mimetype data.
     *
     * @returns Mimetype buffer.
     */
    protected _getMimetypeData(): Buffer;
    /**
     * Get the keystore object.
     *
     * @returns Keystore object.
     */
    protected _getKeystore(): Readonly<SecurityKeystore>;
    /**
     * Add resource with data, with options controlling hashing and signing.
     *
     * @param destination Packaged file relative destination.
     * @param data Resource data.
     * @param options Resource options.
     * @param hashed This file is hashed.
     * @param signed This file is signed.
     */
    protected _addResource(destination: string, data: Readonly<Buffer>, options: Readonly<IPackagerResourceOptions>, hashed: boolean, signed: boolean): Promise<void>;
    /**
     * Add meta resources start.
     *
     * @param applicationData XML data.
     */
    protected _addMetaResourcesStart(applicationData: Readonly<Buffer>): Promise<void>;
    /**
     * Add meta resources end.
     */
    protected _addMetaResourcesEnd(): Promise<void>;
    /**
     * Add meta resource for the mimetype.
     */
    protected _addMetaResourceMimetype(): Promise<void>;
    /**
     * Add meta resource for the application descriptor.
     *
     * @param applicationData The application descriptor data.
     */
    protected _addMetaResourceApplication(applicationData: Readonly<Buffer>): Promise<void>;
    /**
     * Add meta resource for the hash (needs updating on close).
     */
    protected _addMetaResourceHash(): Promise<void>;
    /**
     * Add meta resource for debug.
     */
    protected _addMetaResourceDebug(): Promise<void>;
    /**
     * Add resource for signatures.
     */
    protected _addMetaResourceSignatures(): Promise<void>;
    /**
     * Init application info from descriptor data.
     *
     * @param applicationData The application descriptor data.
     */
    protected _applicationInfoInit(applicationData: Readonly<Buffer>): void;
    /**
     * Clear application info from descriptor data.
     */
    protected _applicationInfoClear(): void;
    /**
     * Open path as archive.
     *
     * @param path Archive path.
     * @returns Archive instance.
     */
    protected _openArchive(path: string): Promise<import("@shockpkg/archive-files").Archive>;
    /**
     * Package mimetype.
     *
     * @returns Mimetype string.
     */
    abstract get mimetype(): string;
    /**
     * Package signed.
     *
     * @returns Boolean for if package is signed or not.
     */
    abstract get signed(): boolean;
    /**
     * Open implementation.
     *
     * @param applicationData The application descriptor data.
     */
    protected abstract _open(applicationData: Readonly<Buffer>): Promise<void>;
    /**
     * Close implementation.
     */
    protected abstract _close(): Promise<void>;
    /**
     * Write resource with data implementation.
     *
     * @param destination Packaged file relative destination.
     * @param data Resource data.
     * @param options Resource options.
     */
    protected abstract _writeResource(destination: string, data: Readonly<Buffer>, options: Readonly<IPackagerResourceOptions>): Promise<void>;
}
