import { Meta } from './core';
import { Cache, PromiseProgress, PathEventEmitter, Unsubscribe, PathEvent } from '@ztimson/utils';
import { Momentum } from './momentum';
/** Directory information */
export type DirMeta = FileMeta & {
    /** Folder contents */
    readonly children: (DirMeta | FileMeta)[];
    /** Mime type, always directory */
    readonly mime: 'directory';
};
/** File information */
export type FileMeta = Meta & {
    /** File location */
    readonly path: string;
    /** File name */
    readonly name: string;
    /** File mimetype */
    readonly mime: string;
    /** File size */
    readonly size: number;
    /** Missing from file system */
    readonly missing?: boolean;
    /** Text extracted from file */
    readonly text?: string;
};
/** File storage */
export declare class Storage extends PathEventEmitter {
    protected momentum: Momentum;
    private readonly module;
    private readonly subscribers;
    cache: Cache<string, FileMeta | DirMeta>;
    constructor(momentum: Momentum, module?: string);
    /**
     * List all files
     * @param {string} path Target directory
     * @return {Promise<DirMeta>} Directory metadata
     */
    all(path?: string): Promise<(DirMeta | FileMeta)[]>;
    /**
     * Copy one location to another
     * @param {string} source Source location
     * @param {string} destination Destination of copy
     * @return {Promise<DirMeta | FileMeta>} Metadata of copy
     */
    copy(source: string, destination?: string): Promise<DirMeta | FileMeta>;
    /**
     * Delete location
     * @param {string} path Target module
     * @return {Promise<void>} Returns once complete
     */
    delete(path: string): Promise<number>;
    /**
     * Download module
     * @param {string} path Path to target
     * @param {{downloadAs?: string}} opts Download filename
     * @return {PromiseProgress<Blob>} File as blob with progress tracking
     */
    download(path: string, opts?: {
        'downloadAs'?: string;
    }): PromiseProgress<Blob>;
    /**
     * Retrieve file/folder metadata
     * @param {string} path Path to target
     * @return {Promise<DirMeta | FileMeta>} Metadata
     */
    meta(path?: string): Promise<DirMeta | FileMeta>;
    /**
     * Create a new directory
     * @param {string} path Directory module
     * @return {Promise<DirMeta>} New directory metadata
     */
    mkdir(path: string): Promise<DirMeta>;
    /**
     * Move a file from one location to another
     * @param {string} source Target that will be moved
     * @param {string} destination Destination location
     * @return {Promise<DirMeta | FileMeta>} New file/folder metadata
     */
    move(source: string, destination: string): Promise<DirMeta | FileMeta>;
    /**
     * Create file link & open
     * @param {string} path Path to target
     * @param {false} target Anchor link target: null, _blank, _self
     * @return {string} URL of file
     */
    open(path: string, target: false): string;
    open(path: string, target?: '_blank' | '_self'): Window | null;
    /**
     * Read file as text via extraction or OCR
     * @param {string} path Path to target
     * @param {string} set Update transcribed text
     * @return {Promise<string>} Extracted text
     */
    text(path: string): Promise<string>;
    text(path: string, set: string | null): Promise<FileMeta>;
    /**
     * Upload file(s) to server, Uses file browser if no files provided
     * @param path Path files will be uploaded to
     * @param {File | File[] | null} files Files to upload or null to open file browser
     * @param {string | {accept?: string, rename?: string, multiple?: boolean}} opts file browser options & rename file on upload
     * @return {PromiseProgress<FileMeta[]>} Returns once complete with progress tracking
     */
    upload(path?: string, files?: File | File[] | null, opts?: {
        rename?: string;
        accept?: string;
        multiple?: boolean;
    }): PromiseProgress<FileMeta[]>;
    /**
     * Subscribe to live updates with callback
     * @param path Path to data
     * @param {(value: DirMeta | FileMeta) => any} callback Received changes
     * @param opts Reload data immediately
     * @return {() => void} Function to unsubscribe
     */
    sync(path: string, callback: ((event: PathEvent, value: DirMeta | FileMeta) => any), opts?: {
        reload?: boolean;
    }): Unsubscribe;
}
//# sourceMappingURL=storage.d.ts.map