import { Path } from 'webos-path'; export * from 'webos-path'; /* * @Author: chenzhongsheng * @Date: 2022-11-20 18:32:39 * @Description: Coding something * @LastEditors: Please set LastEditors * @LastEditTime: 2023-01-24 00:16:44 */ declare module 'filer.js' { // class Filer {} // export default Filer; } /* * @Author: tackchen * @Date: 2022-09-21 21:10:46 * @Description: Coding something */ interface IJson { [prop: string]: T } interface IFileBaseOption { name: string; entry?: any; } interface IFileBaseInfo { id: string; name: string; _size: number; isDir: boolean; path: Path; fileType: '' | 'unknown' | string; } declare abstract class FileBase implements IFileBaseInfo { isDisk: boolean; id: string; name: string; type: 'file' | 'dir' | 'disk'; isDir: boolean; path: Path; fileType: '' | 'unknown' | string; entry: any; _size: number; get size(): number; parent: Dir | null; loadedCallback: Function[]; triggerLoaded(): void; onloaded(): Promise; constructor({ name, entry, }: IFileBaseOption); setEntry(entry: any): void; setParent(parent: Dir | null): void; remove(): Promise; private markParentClearSize; abstract copy(): FileBase; abstract countSize(): number; } declare type TWriteType = string | object | File | Blob | ArrayBuffer | null; declare class BaseParser { parse(content: TWriteType): string | object | null; parseWrite(content: TWriteType): TWriteType; merge(before: TWriteType, content: TWriteType): TWriteType; } declare const SuffixTypeMap: { readonly txt: "text"; readonly json: "json"; readonly js: "javascript"; readonly html: "html"; readonly java: "java"; }; declare type TSuffixTypeMap = typeof SuffixTypeMap; declare type TSuffixType = keyof TSuffixTypeMap; declare type TFileType = TSuffixTypeMap[TSuffixType]; declare class FileParser { file: File; parser: BaseParser; fileType: TFileType | 'unknown'; suffix: TSuffixType | string; constructor(file: File); parseRead(content: TWriteType): string | object | null; parseWrite(): TWriteType; merge(content: TWriteType): TWriteType; private geneSuffix; } interface IFileOption extends IFileBaseOption { content?: TWriteType; mimetype?: string; } declare class File extends FileBase { content: TWriteType; mimetype: string; fileParser: FileParser; get contentString(): string; constructor({ name, content, entry, mimetype }: IFileOption); countSize(): number; copy(): File; read({ refresh }?: { refresh?: boolean; }): Promise; write({ content, append }?: { content?: TWriteType; append?: boolean; }): Promise; } interface IDirOption extends IFileBaseOption { children?: FileBase[]; } interface ICreateConfig { returnIfExists?: boolean; fromInit?: boolean; } declare class Dir extends FileBase { children: FileBase[]; constructor({ name, children, entry, }: IDirOption); countSize(): number; addChild(file: T, fromInit?: boolean): Promise; createFile(options: IFileOption, { returnIfExists, fromInit, }?: ICreateConfig): Promise; createChildByPath(path: string, isDir: boolean, returnIfExists?: boolean): Promise; createDir(options: IDirOption, config?: ICreateConfig): Promise; exists(name: string): boolean; copy(): FileBase; paste(file: FileBase): void; findChildByPath(pathValue: string | string[]): Promise; filerChild(query: string, deep?: boolean): FileBase[]; findFileByPath(path: string | string[]): Promise; findDirByPath(path: string | string[]): Promise; ls(): string[]; lsDetail(): IFileBaseInfo[]; deepLs(): IJson; } interface IDiskOption { capacity?: number; } declare class Disk extends Dir { isDisk: boolean; static instance: Disk; capacity: number; constructor({ capacity, }?: IDiskOption); initFileSystem(): Promise; clear(): void; } declare function split(str: string, s?: string, last?: boolean): [string, string]; export { Dir, Disk, File, FileBase, ICreateConfig, IDirOption, IDiskOption, IFileBaseInfo, IFileBaseOption, IFileOption, IJson, split };