- NodeJS 14
- ES2020
import type { DataSource, IncrementalMatch, TaskAction } from "./squared";
import type { DocumentConstructor, HostConstructor, ICloud, ICompress, IDocument, IHost, IImage, IModule, IRequest, ITask, ImageConstructor, TaskConstructor, WatchInstance } from "./index";
import type { ExternalAsset, FileCommand, FileData, IFileThread, OutputFinalize } from "./asset";
import type { IPermission, PermissionReadWrite } from "./core";
import type { AssetContentOptions, ChecksumOptions, DeleteFileAddendum, FileOutput, FinalizeResult, FindAssetOptions, IHttpDiskCache, IHttpMemoryCache, InstallData, PostFinalizeCallback, ReplaceOptions } from "./filemanager";
import type { ExecCommand } from "./logger";
import type { CopyFileOptions, CreateDirOptions, DeleteFileOptions, MoveFileOptions, ReadFileOptions, RemoveDirOptions, WriteFileOptions } from "./module";
import type { RequestData, Settings } from "./node";
import type { Aria2Options, BufferFormat, OpenOptions } from "./request";
import type { CloudModule, CompressModule, DbModule, DocumentModule, HttpConnectSettings, HttpMemorySettings, ImageModule, RequestModule, TaskModule, WatchModule } from "./settings";
import type { SpawnOptions } from "child_process";
import type { NoParamCallback } from "fs";
interface IFileManager extends IHost, Set<string> {
finalizeState: number;
processTimeout: number;
cacheToDisk: IHttpDiskCache<ExternalAsset>;
cacheToMemory: IHttpMemoryCache<ExternalAsset>;
Request: IRequest<RequestModule>;
Document: InstallData<IDocument<IFileManager, ExternalAsset>, DocumentConstructor<IFileManager, ExternalAsset>>[];
Task: InstallData<ITask, TaskConstructor>[];
Image: Map<string, InstallData<IImage, ImageConstructor>> | null;
Cloud: ICloud | null;
Watch: WatchInstance<ExternalAsset> | null;
Compress: ICompress<CompressModule> | null;
readonly documentAssets: ExternalAsset[];
readonly taskAssets: (ExternalAsset & Required<TaskAction>)[];
readonly dataSourceItems: DataSource[];
readonly files: Set<string>;
readonly filesQueued: Set<string>;
readonly filesToRemove: Set<string>;
readonly filesToCompare: Map<ExternalAsset, string[]>;
readonly contentToAppend: Map<string, string[]>;
readonly contentToReplace: Map<string, string[]>;
readonly processing: IFileThread[];
readonly fetchedAssets: ExternalAsset[];
readonly copiedAssets: ExternalAsset[];
readonly emptyDir: Set<string>;
install(name: "document", target: DocumentConstructor<IFileManager, ExternalAsset>, module?: DocumentModule): IDocument<IFileManager, ExternalAsset> | undefined;
install(name: "task", target: TaskConstructor, module?: TaskModule): ITask | undefined;
install(name: "cloud", handler: string, module?: CloudModule): ICloud | undefined;
install(name: "cloud", module?: CloudModule): ICloud | undefined;
install(name: "db", module?: DbModule): IDb | undefined;
install(name: "image", targets: Map<string, ImageConstructor>, module?: ImageModule): void;
install(name: "watch", module: WatchModule): WatchInstance<ExternalAsset> | undefined;
install(name: "watch", interval?: number | string, port?: number | string, securePort?: number | string, extensions?: unknown[]): WatchInstance<ExternalAsset> | undefined;
install(name: "compress", module?: CompressModule): ICompress<CompressModule> | undefined;
install(name: string, ...args: unknown[]): IModule | undefined;
using(...items: ExternalAsset[] | [boolean, ...ExternalAsset[]]): this;
contains(item: ExternalAsset, condition?: (...args: [ExternalAsset]) => boolean): boolean;
removeCwd(value: unknown): string;
findAsset(value: string | URL, instance?: IModule | FindAssetOptions<ExternalAsset>): ExternalAsset | undefined;
removeAsset(file: ExternalAsset): boolean;
replace(file: ExternalAsset, replaceWith: string, options: ReplaceOptions): boolean;
replace(file: ExternalAsset, replaceWith: string, mimeType?: string | ReplaceOptions): boolean;
rename(file: ExternalAsset, value: string): boolean;
performAsyncTask(): void;
removeAsyncTask(): void;
completeAsyncTask(err?: unknown, uri?: string, parent?: ExternalAsset, type?: number): void;
performFinalize(override?: boolean): void;
hasDocument(instance: IModule, document: string | string[] | undefined): boolean;
getDocumentAssets(instance: IModule, condition?: (...args: [ExternalAsset]) => boolean): ExternalAsset[];
getDataSourceItems(instance: IModule, condition?: (...args: [DataSource]) => boolean): DataSource[];
setLocalUri(file: ExternalAsset, replace?: boolean): FileOutput;
getLocalUri(data: FileData<ExternalAsset>): string;
getMimeType(data: FileData<ExternalAsset>): string;
openThread(instance: IModule, data: IFileThread, timeout?: number): boolean;
closeThread(instance: IModule | null, data: IFileThread, callback?: (...args: unknown[]) => void): boolean;
addProcessTimeout(instance: IModule, file: ExternalAsset, timeout: number): void;
removeProcessTimeout(instance: IModule, file: ExternalAsset): void;
getProcessTimeout(handler: InstallData): number;
clearProcessTimeout(): void;
addDownload(value: number | Buffer | string, encoding: BufferEncoding): number;
addDownload(value: number | Buffer | string, type?: number, encoding?: BufferEncoding): number;
getDownload(type?: number): [number, number];
transformAsset(data: IFileThread, parent?: ExternalAsset): Promise<void>;
addCopy(data: FileCommand<ExternalAsset>, saveAs?: string, replace?: boolean): string | undefined;
findMime(file: ExternalAsset, rename?: boolean): Promise<string>;
getUTF8String(file: ExternalAsset, uri?: string): string;
getBuffer(file: ExternalAsset, minStreamSize?: number): Promise<Buffer> | Buffer | null;
getCacheDir(url: string | URL, createDir?: boolean): string;
setAssetContent(file: ExternalAsset, content: string, options?: AssetContentOptions): string;
getAssetContent(file: ExternalAsset, content?: string): string | undefined;
writeBuffer(file: ExternalAsset, options?: WriteFileOptions): Buffer | null;
writeImage(document: string | string[], output: OutputFinalize<ExternalAsset>): boolean;
compressFile(file: ExternalAsset, overwrite?: boolean): Promise<unknown>;
fetchObject(uri: string | URL, format: BufferFormat): Promise<object | null>;
fetchObject(uri: string | URL, options?: OpenOptions | BufferFormat): Promise<object | null>;
fetchBuffer(uri: string | URL, options?: OpenOptions): Promise<Buffer | string | null>;
fetchFiles(uri: string | URL, pathname: string): Promise<string[]>;
fetchFiles(uri: string | URL, options?: Aria2Options | string): Promise<string[]>;
start(emptyDir?: boolean): Promise<FinalizeResult>;
processAssets(emptyDir?: boolean, using?: ExternalAsset[]): void;
deleteFile(src: string, promises: boolean): Promise<void>;
deleteFile(src: string, options: DeleteFileOptions & DeleteFileAddendum, promises: boolean): Promise<void>;
deleteFile(src: string, callback?: NoParamCallback): unknown;
deleteFile(src: string, options: DeleteFileOptions & DeleteFileAddendum, callback?: NoParamCallback): unknown;
restart(recursive?: boolean | "abort", emptyDir?: boolean): void;
restart(recursive?: boolean | "abort", exclusions?: string[], emptyDir?: boolean): void;
finalizeCompress(assets: ExternalAsset[]): Promise<unknown>;
finalizeDocument(): Promise<unknown>;
finalizeTask(assets: (ExternalAsset & Required<TaskAction>)[]): Promise<unknown>;
finalizeCloud(): Promise<unknown>;
finalizeCleanup(): Promise<unknown>;
finalize(): Promise<void>;
close(): void;
reset(): boolean;
get baseDirectory(): string;
get config(): RequestData;
get assets(): ExternalAsset[];
get incremental(): IncrementalMatch;
set restarting(value);
get restarting(): boolean;
get delayed(): number;
set cleared(value);
get cleared(): boolean;
/* Set */
add(value: string, parent?: ExternalAsset, type?: number): this;
delete(value: string, emptyDir?: boolean): boolean;
has(value: unknown): value is string;
/* EventEmitter */
on(event: "end", listener: PostFinalizeCallback): this;
on(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
on(event: "error", listener: (err: Error) => void): this;
on(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
on(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
on(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
on(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
on(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
on(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
on(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
once(event: "end", listener: PostFinalizeCallback): this;
once(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
once(event: "error", listener: (err: Error) => void): this;
once(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
once(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
once(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
once(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
once(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
once(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
once(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
emit(event: "end", result: FinalizeResult): boolean;
emit(event: "exec", command: ExecCommand, options?: SpawnOptions): boolean;
emit(event: "error", err: Error): boolean;
emit(event: "file:read", src: string, data: Buffer | string, options?: ReadFileOptions): boolean;
emit(event: "file:write", src: string, options?: WriteFileOptions): boolean;
emit(event: "file:delete", src: string, options?: DeleteFileOptions): boolean;
emit(event: "file:copy", dest: string, options?: CopyFileOptions): boolean;
emit(event: "file:move", dest: string, options?: MoveFileOptions): boolean;
emit(event: "dir:create", src: string, options?: CreateDirOptions): boolean;
emit(event: "dir:remove", src: string, options?: RemoveDirOptions): boolean;
}
interface FileManagerConstructor extends HostConstructor {
loadSettings(settings: Settings, password?: string): boolean;
loadSettings(settings: Settings, permission?: PermissionReadWrite, password?: string): boolean;
sanitizeAssets(assets: ExternalAsset[], exclusions?: string[]): ExternalAsset[];
writeChecksum(root: string, options?: ChecksumOptions): Promise<string[]>;
writeChecksum(root: string, to: string | undefined, options?: ChecksumOptions): Promise<string[] | null>;
writeChecksum(root: string, to?: string | ChecksumOptions, options?: ChecksumOptions): Promise<string[] | null>;
verifyChecksum(root: string, options?: ChecksumOptions): Promise<[string[], string[]] | null>;
verifyChecksum(root: string, from: string | undefined, options?: ChecksumOptions): Promise<[string[], string[]] | null>;
verifyChecksum(root: string, from?: string | ChecksumOptions, options?: ChecksumOptions): Promise<[string[], string[]] | null>;
createFileThread(host: IFileManager, file: ExternalAsset): IFileThread;
setTimeout(options: Record<string, number | string>): void;
defineHttpCache(options: HttpMemorySettings, disk?: boolean): void;
defineHttpConnect(options: HttpConnectSettings): void;
readonly prototype: IFileManager;
new(baseDirectory: string, config: RequestData, postFinalize?: PostFinalizeCallback): IFileManager;
new(baseDirectory: string, config: RequestData, permission?: IPermission, postFinalize?: PostFinalizeCallback): IFileManager;
}
- https://www.unpkg.com/@e-mc/types@0.8.7/lib/squared.d.ts
- https://www.unpkg.com/@e-mc/types@0.8.7/lib/asset.d.ts
- https://www.unpkg.com/@e-mc/types@0.8.7/lib/core.d.ts
- https://www.unpkg.com/@e-mc/types@0.8.7/lib/filemanager.d.ts
- https://www.unpkg.com/@e-mc/types@0.8.7/lib/logger.d.ts
- https://www.unpkg.com/@e-mc/types@0.8.7/lib/module.d.ts
- https://www.unpkg.com/@e-mc/types@0.8.7/lib/node.d.ts
- https://www.unpkg.com/@e-mc/types@0.8.7/lib/request.d.ts
- https://www.unpkg.com/@e-mc/types@0.8.7/lib/settings.d.ts
BSD 3-Clause