/* eslint @typescript-eslint/no-explicit-any: "off" */ /// /// import type { CompressLevel, DataSource, DbDataSource, IncrementalMatch, LogStatus, TaskAction, ViewEngine } from './squared'; import type { ExternalAsset, FileCommand, FileData, IFileThread, OutputFinalize } from './asset'; import type { BucketWebsiteOptions, CloudDatabase, CloudFeatures, CloudFunctions, CloudService, CloudStorage, CloudStorageDownload, CloudStorageUpload } from './cloud'; import type { BufferResult, CompressFormat, TryFileCompressor, TryFileResult, TryImageResult } from './compress'; import type { ClientDbConstructor, HostInitConfig, IAbortComponent, IClient, IClientDb, IPermission, JoinQueueOptions, PermissionReadWrite, ResumeThreadOptions, ThreadCountStat } from './core'; import type { BatchQueryResult, DB_TYPE, ExecuteBatchQueryOptions, ExecuteQueryOptions, HandleFailOptions, PoolConfig, ProcessRowsOptions, QueryResult, SQL_COMMAND } from './db'; import type { AsSourceFileOptions, ConfigOrTransformer, CustomizeOptions as CustomizeDocument, GenerateLintTableOptions, LintMessage, PluginConfig, SourceCode, SourceInput, SourceMap, SourceMapOptions, TransformAction, TransformCallback, TransformOutput, TransformResult, UpdateGradleOptions } from './document'; import type { AssetContentOptions, ChecksumOptions, DeleteFileAddendum, FileOutput, FinalizeResult, FindAssetOptions, IHttpDiskCache, IHttpMemoryCache, InstallData, PostFinalizeCallback, ReplaceOptions } from './filemanager'; import type { HttpAgentSettings, HttpProtocolVersion, HttpRequestClient, InternetProtocolVersion } from './http'; import type { CommandData, CropData, QualityData, ResizeData, RotateData, TransformOptions } from './image'; import type { ExecCommand, LOG_TYPE, LogArguments, LogComponent, LogDate, LogFailOptions, LogMessageOptions, LogOptions, LogProcessOptions, LogTime, LogType, LogValue, STATUS_TYPE, StatusType } from './logger'; import type { AsHashOptions, CheckSemVerOptions, CopyDirOptions, CopyDirResult, CopyFileOptions, CreateDirOptions, DeleteFileOptions, GetTempDirOptions, MoveFileOptions, NormalizeFlags, ParseFunctionOptions, PermissionOptions, ProtocolType, ReadBufferOptions, ReadFileCallback, ReadFileOptions, ReadHashOptions, ReadTextOptions, RemoveDirOptions, WriteFileOptions } from './module'; import type { RequestData, Settings } from './node'; import type { ApplyOptions, Aria2Options, BufferFormat, DataEncodedResult, DataObjectResult, FormDataPart, HeadersOnCallback, HostConfig, OpenOptions, PostOptions, ProxySettings, ReadExpectType, RequestInit, StatusOnCallback } from './request'; import type { ClientModule, CloudModule, CloudServiceOptions, CompressModule, CompressSettings, DbCoerceSettings, DbModule, DbSourceOptions, DnsLookupSettings, DocumentComponent, DocumentComponentOption, DocumentModule, HttpConnectSettings, HttpMemorySettings, ImageModule, RequestModule, RequestSettings, TaskModule, WatchModule } from './settings'; import type { Command, SpawnResult } from './task'; import type { IFileGroup, ModifiedPostFinalizeListener, SecureOptions, WatchInitResult } from './watch'; import type { NoParamCallback, WriteStream } from 'fs'; import type { SpawnOptions } from 'child_process'; import type { BrotliCompress, Gzip } from 'zlib'; import type { Readable, Writable } from 'stream'; import type { LookupFunction } from 'net'; import type { SecureContextOptions } from 'tls'; import type { ClientRequest, OutgoingHttpHeaders } from 'http'; import type { BinaryLike } from 'crypto'; import type * as EventEmitter from 'events'; // @ts-ignore import type * as ws from 'ws'; import type { FileTypeResult } from 'file-type'; type BufferView = BufferContent | NodeJS.ArrayBufferView; type CpuUsage = NodeJS.CpuUsage; declare namespace functions { type WatchInstance = IWatch, T, U, ModifiedPostFinalizeListener>; interface IScopeOrigin { host?: T; instance?: U; } interface IExternalConfig { module: T; init(...args: unknown[]): this; get settings(): U; } interface IExternalFunction { set extensions(values: unknown[]); get extensions(): T[]; } interface ICompress, U extends CompressSettings = CompressSettings> extends IModule, IExternalConfig { level: ObjectMap; compressors: ObjectMap; chunkSize?: number; register(format: string, callback: TryFileCompressor): void; getLevel(value: string, fallback?: number): Undef; getReadable(file: string | URL | Buffer): Readable; createGzip(file: string | Buffer, options?: CompressLevel): Gzip; createBrotliCompress(file: string | Buffer, options?: CompressLevel): BrotliCompress; createWriteStreamAsGzip(file: string | Buffer, output: string, options?: CompressLevel): WriteStream; createWriteStreamAsBrotli(file: string | Buffer, output: string, options?: CompressLevel): WriteStream; tryFile(file: string | Buffer, config: CompressFormat, callback?: TryFileResult): Promise; tryFile(file: string | Buffer, output: string, config: CompressFormat, callback?: TryFileResult): Promise; tryImage(file: string, config: CompressFormat, callback?: TryImageResult): Promise; tryImage(file: string | Buffer, output: string, config: CompressFormat, callback?: TryImageResult): Promise; } interface CompressConstructor = CompressModule, U extends CompressSettings = CompressSettings> extends ModuleConstructor { singleton(): ICompress; readonly prototype: ICompress; new(module?: U): ICompress; } interface IImage extends IClient { resizeData?: ResizeData; cropData?: CropData; rotateData?: RotateData; qualityData?: QualityData; methodData?: [string, unknown[]?][]; opacityValue?: number; setCommand(value: string | CommandData, outputAs?: string): void; getCommand(): string; parseCommand(value: string): CommandData; parseMethod(value: string): Undef<[string, unknown[]?][]>; parseResize(value: string): Undef; parseCrop(value: string): Undef; parseRotate(value: string): Undef; parseQuality(value: string): Undef; parseOpacity(value: string): number; using?(data: IFileThread, command: string): Promise; get outputAs(): string; } interface ImageConstructor extends ModuleConstructor { readonly REGEXP_SIZERANGE: RegExp; transform(file: string, command: string, options?: TransformOptions): Promise | string>; clamp(value: unknown, min?: number, max?: number): number; isBinary(mime: unknown): mime is string; toABGR(buffer: Uint8Array | Buffer): Buffer; /* @deprecated - IImage.using */ using?(this: T, instance: IImage, data: IFileThread, command: string): Promise; readonly prototype: IImage; new(module?: U): IImage; } interface ITask extends IClient { using?(data: IFileThread): Promise; collect?(items: unknown[], preceding?: boolean): Promise[]; map?(tasks: Command[]): Promise>[]; series?(tasks: Command[]): Promise; parallel?(tasks: Command[]): Promise; spawn?(task: PlainObject, callback: (result?: SpawnResult) => void): void; execute?, W extends ExternalAsset>(manager: V, task: PlainObject, callback: (value?: unknown) => void): void; } interface TaskConstructor extends ModuleConstructor { finalize(this: T, instance: ITask, assets: V[]): Promise; /* @deprecated - ITask.using */ using?(this: T, instance: ITask, assets: V[], preceding?: boolean): Promise; readonly prototype: ITask; new(module?: U, ...args: unknown[]): ITask; } interface IDb extends IClientDb { setCredential(item: V): Promise; getCredential(item: V): Undef; hasSource(source: string, ...type: number[]): boolean; applyCommand(...items: V[]): void; executeQuery(item: V, sessionKey: string): Promise; executeQuery(item: V, options?: ExecuteQueryOptions | string): Promise; executeBatchQuery(batch: V[], sessionKey: string, outResult?: BatchQueryResult): Promise; executeBatchQuery(batch: V[], options?: ExecuteBatchQueryOptions | string, outResult?: BatchQueryResult): Promise; processRows(batch: V[], tasks: Promise>[], parallel: boolean): Promise; processRows(batch: V[], tasks: Promise>[], options?: ProcessRowsOptions, outResult?: BatchQueryResult): Promise; handleFail(err: unknown, item: V, options?: HandleFailOptions): boolean; readTLSCert(value: unknown, cache?: boolean): string; readTLSConfig(options: SecureContextOptions, cache?: boolean): void; settingsOf(source: string, name: keyof Omit): unknown; settingsOf(source: string, name: "coerce", component: keyof X): unknown; settingsKey(source: string, name: keyof Omit): unknown; settingsKey(source: string, name: "coerce", component: keyof X): unknown; getPoolConfig(source: string, uuidKey?: string): Undef>; get sourceType(): DB_TYPE; get commandType(): SQL_COMMAND; } interface DbConstructor extends ClientDbConstructor { setPoolConfig(value: ObjectMap): void; getPoolConfig(source: string): Undef>; readonly prototype: IDb; new(module?: U, database?: V[], ...args: unknown[]): IDb; } interface ICloud extends IClientDb { readonly uploaded: string[]; readonly downloaded: string[]; createBucket(service: string, credential: unknown, bucket: string, acl?: unknown, options?: unknown): Promise; createBucket(service: string, credential: unknown, bucket: string, publicRead?: boolean): Promise; setBucketPolicy(service: string, credential: unknown, bucket: string, options: unknown): Promise; setBucketWebsite(service: string, credential: unknown, bucket: string, options: BucketWebsiteOptions): Promise; deleteObjects(service: string, credential: unknown, bucket: string, recursive?: boolean): Promise; uploadObject(service: string, credential: unknown, bucket: string, upload: CloudStorageUpload, localUri: string, beforeResolve?: (value: string) => Void>): Promise; downloadObject(service: string, credential: unknown, bucket: string, download: CloudStorageDownload, beforeResolve?: (value: Null) => Void>>): Promise; getStorage(action: CloudFunctions, data: Undef): Undef; hasStorage(action: CloudFunctions, storage: CloudStorage): CloudStorageUpload | false; getDatabaseRows(item: V, ignoreErrors: boolean, sessionKey?: string): Promise; getDatabaseRows(item: V, sessionKey?: string): Promise; getDatabaseBatchRows(batch: V[], ignoreErrors: boolean, sessionKey?: string): Promise; getDatabaseBatchRows(batch: V[], sessionKey?: string): Promise; hasCredential(feature: CloudFeatures, data: CloudService, credential?: unknown): boolean; getCredential(item: CloudService, unused?: boolean): PlainObject; getSettings(service: string): Undef; settingsOf(service: string, name: "cache"): unknown; settingsOf(service: string, name: "coerce", component: keyof X): unknown; getUploadHandler(service: string, credential: unknown): FunctionType; getDownloadHandler(service: string, credential: unknown): FunctionType; resolveService(service: string, folder?: string): string; } interface CloudConstructor extends ClientDbConstructor { LOG_CLOUD_FAIL: LogMessageOptions; LOG_CLOUD_COMMAND: LogMessageOptions; LOG_CLOUD_WARN: LogMessageOptions; LOG_CLOUD_UPLOAD: LogMessageOptions; LOG_CLOUD_DOWNLOAD: LogMessageOptions; LOG_CLOUD_DELETE: LogMessageOptions; LOG_CLOUD_DELAYED: LogMessageOptions; finalize(this: T, instance: ICloud): Promise; uploadAsset, X extends ExternalAsset>(state: IScopeOrigin>, file: X, ignoreProcess: boolean): Promise[]; uploadAsset, X extends ExternalAsset>(state: IScopeOrigin>, file: X, contentType?: string, ignoreProcess?: boolean): Promise[]; sanitizeAssets(assets: W[]): W[]; readonly prototype: ICloud; new(module?: U, database?: CloudDatabase[], ...args: unknown[]): ICloud; } interface IDocument, U extends ExternalAsset = ExternalAsset, V extends ClientModule = DocumentModule, W extends DocumentComponent = DocumentComponent, X extends DocumentComponentOption = DocumentComponentOption, Y extends ICloud = ICloud> extends IClient> { Db: Null; assets: U[]; config: StandardMap; init(assets: U[], config?: HostInitConfig): this; customize(options?: CustomizeDocument): void; findConfig(data: object, name: string, type?: string): PluginConfig; loadConfig(data: object, name: string): Optional; asSourceFile(value: string, options?: AsSourceFileOptions | boolean): unknown; findVersion(name: StringOfArray, fallback?: string): string; findSourceScope(uri: string, imports: AnyObject): StringMap[]; findSourceRoot(uri: string, imports?: StringMap): Undef; resolveDir(name: string, ...paths: string[]): Undef; locateSourceFiles(file: U, code?: string, bundleContent?: string[]): (imports?: StringMap) => Undef; resolveSourceFile(file: U): (code?: string, imports?: StringMap) => Undef>; tryParse(source: string, format: string, options?: PlainObject): unknown; forDb(item: DataSource): boolean; hasEval(name: string): boolean; settingsOf(name: keyof W, option: keyof X): unknown; parseTemplate(viewEngine: ViewEngine | string, template: string, data: unknown[]): Promise>; transform(type: string, code: string, format: StringOfArray, options?: TransformOutput & TransformAction): Promise>; abort(name?: keyof W | Error, reason?: unknown): void; restart(): void; using?(data: IFileThread): Promise; setLocalUri?(file: U, replace?: boolean): void; resolveUri?(file: U, source: string): string; resolveUri?(file: U, source: string, trailing: string): TupleOf; resolveImports?(file: U, code: string, baseFile?: string | U): Undef; replaceContent?(source: string, statement: RegExpExecArray | string, mimeType?: string): Undef; addCopy?(data: FileCommand, saveAs: string, replace?: boolean): Undef; writeImage?(output: OutputFinalize): boolean; cloudInit?(state: IScopeOrigin): void; cloudObject?(state: IScopeOrigin, file: U): boolean; cloudUpload?(state: IScopeOrigin, file: U, url: string, active: boolean): Promise; cloudFinalize?(state: IScopeOrigin): Promise; watchInit?(watch: IFileGroup, assets: U[], sanitize?: boolean): Undef; watchModified?(watch: IFileGroup, assets?: U[]): PostFinalizeCallback; set dataSource(value: DataSource[]); get dataSource(): DataSource[]; set imports(value); get imports(): StringMap; get watching(): boolean; } interface DocumentConstructor, U extends ExternalAsset = ExternalAsset, V extends ClientModule = DocumentModule, W extends DocumentComponent = DocumentComponent, X extends DocumentComponentOption = DocumentComponentOption, Y extends ICloud = ICloud> extends ModuleConstructor { finalize(this: T, instance: IDocument): Promise; createSourceMap(code: string, remove: boolean): SourceMap; createSourceMap(code: string, uri?: string, remove?: boolean): SourceMap; writeSourceMap(uri: string, data: SourceCode, options?: SourceMapOptions): Undef; updateGradle(source: string, namespaces: string[], value: string, options?: UpdateGradleOptions | boolean): string; generateLintTable(messages: LintMessage[], options: GenerateLintTableOptions): LogComponent[]; /* @deprecated - IDocument.using */ using?(this: T, instance: IDocument, file: U): Promise; cleanup?(this: T, instance: IDocument): Promise; sanitizeAssets?(assets: U[], exclusions?: U[]): U[]; readonly prototype: IDocument; new(module?: V, ...args: unknown[]): IDocument; } interface IWatch, U extends ExternalAsset = ExternalAsset, V extends WatchModule = WatchModule, W extends FunctionType = ModifiedPostFinalizeListener> extends IClient { connectTimeout: number; start(assets: U[], permission?: Null): void; modified(watch: IFileGroup): Promise>; configureServer(options: SecureOptions): boolean; setCA(value: string): boolean; setSSLKey(value: string): boolean; setSSLCert(value: string): boolean; hasSecureProtocol(): boolean; whenModified?(assets: U[], postFinalize: PostFinalizeCallback): IFileManager; whenModified?(assets: U[], sanitize?: boolean | PostFinalizeCallback, postFinalize?: PostFinalizeCallback): IFileManager; set assets(value: U[]); get assets(): U[]; set interval(value); get interval(): number; set port(value); get port(): number; set securePort(value); get securePort(): number; } interface WatchConstructor, U extends ExternalAsset = ExternalAsset, V extends WatchModule = WatchModule, W extends FunctionType = ModifiedPostFinalizeListener> extends ModuleConstructor { createServer(port: number, active: boolean): Null; createServer(port: number, secure?: Null, active?: boolean): Null; shutdown(): void; setTimeout(value: NumString): void; checkTimeout(client: ws): boolean; readonly prototype: IWatch; new(module?: V): IWatch; /* @deprecated */ new(interval?: number, port?: number, securePort?: number, extensions?: unknown[]): IWatch; } interface IRequest, U extends RequestSettings = RequestSettings> extends IModule, IExternalConfig { startTime: number; acceptEncoding: boolean; keepAlive: Null; readTimeout: number; readExpect: ReadExpectType; proxy: Null; init(config?: RequestInit): this; apply(options: ApplyOptions): this; addDns(hostname: string, address: string, timeout: number): void; addDns(hostname: string, address: string, family?: NumString, timeout?: number): void; lookupDns(hostname: string): LookupFunction; proxyOf(uri: string, localhost?: boolean): Undef; statusOn(name: ArrayOf, callback: StatusOnCallback): void; statusOn(name: ArrayOf, globUrl: string, callback: StatusOnCallback): void; headersOn(name: StringOfArray, callback: HeadersOnCallback): void; headersOn(name: StringOfArray, globUrl: string, callback: HeadersOnCallback): void; headersOf(uri: string): Undef; aria2c(uri: string | URL, pathname: string): Promise; aria2c(uri: string | URL, options?: Aria2Options): Promise; json(uri: string | URL, options?: OpenOptions): Promise>; pipe(uri: string | URL, to: Writable, options?: OpenOptions): Promise; opts(url: string | URL, options?: OpenOptions): HostConfig; open(uri: string | URL, options: OpenOptions): HttpRequestClient; head(uri: string | URL, options?: OpenOptions): ClientRequest; post(uri: string | URL, data: unknown, contentType: string): Promise>; post(uri: string | URL, parts: FormDataPart[]): Promise>; post(uri: string | URL, form: AnyObject, parts: FormDataPart[]): Promise>; post(uri: string | URL, data: unknown, options: V): Promise>; post(uri: string | URL, data: unknown, contentType?: string | FormDataPart[] | V, options?: V): Promise>; get(uri: string | URL, options?: W): Promise : DataEncodedResult>; detach(singleton?: boolean): void; reset(): void; close(): void; set agentTimeout(value); get agentTimeout(): number; set httpVersion(value); get httpVersion(): Null; set ipVersion(value); get ipVersion(): InternetProtocolVersion; } interface RequestConstructor = RequestModule, U extends RequestSettings = RequestSettings> extends ModuleConstructor { readCACert(value: string, cache?: boolean): string; readTLSKey(value: string, cache?: boolean): string; readTLSCert(value: string, cache?: boolean): string; isCert(value: string): boolean; fromURL(url: URL, value: string): string; fromStatusCode(value: NumString): string; defineHttpAgent(options: HttpAgentSettings): void; defineDnsLookup(options: DnsLookupSettings, clear?: boolean): void; getAria2Path(): string; readonly prototype: IRequest; new(module?: T): IRequest; } interface IFileManager extends IHost, Set { finalizeState: number; processTimeout: number; cacheToDisk: IHttpDiskCache; cacheToMemory: IHttpMemoryCache; Request: IRequest; Document: InstallData, T>, DocumentConstructor, T>>[]; Task: InstallData[]; Image: Null>>; Cloud: Null; Watch: Null>; Compress: Null>; readonly documentAssets: T[]; readonly taskAssets: (T & Required)[]; readonly dataSourceItems: DataSource[]; readonly files: Set; readonly filesQueued: Set; readonly filesToRemove: Set; readonly filesToCompare: Map; readonly contentToAppend: Map; readonly contentToReplace: Map; readonly processing: IFileThread[]; readonly fetchedAssets: T[]; readonly copiedAssets: T[]; readonly emptyDir: Set; install(name: "document", target: DocumentConstructor, T>, module?: DocumentModule): Undef, T>>; install(name: "task", target: TaskConstructor, module?: TaskModule): Undef; install(name: "cloud", handler: string, module?: CloudModule): Undef; install(name: "cloud", module?: CloudModule): Undef; install(name: "db", module?: DbModule): Undef; install(name: "image", targets: Map, module?: ImageModule): void; install(name: "watch", module: WatchModule): Undef>; install(name: "watch", interval?: NumString, port?: NumString, securePort?: NumString, extensions?: unknown[]): Undef>; install(name: "compress", module?: CompressModule): Undef>; install(name: string, ...args: unknown[]): Undef; using(...items: FirstOf): this; contains(item: T, condition?: FunctionArgs<[T], boolean>): boolean; removeCwd(value: unknown): string; findAsset(value: string | URL, instance?: IModule | FindAssetOptions): Undef; removeAsset(file: T): boolean; replace(file: T, replaceWith: string, options: ReplaceOptions): boolean; replace(file: T, replaceWith: string, mimeType?: string | ReplaceOptions): boolean; rename(file: T, value: string): boolean; performAsyncTask(): void; removeAsyncTask(): void; completeAsyncTask(err?: unknown, uri?: string, parent?: T, type?: number): void; performFinalize(override?: boolean): void; hasDocument(instance: IModule, document: Undef): boolean; getDocumentAssets(instance: IModule, condition?: FunctionArgs<[T], boolean>): T[]; getDataSourceItems(instance: IModule, condition?: FunctionArgs<[DataSource], boolean>): DataSource[]; setLocalUri(file: T, replace?: boolean): FileOutput; getLocalUri(data: FileData): string; getMimeType(data: FileData): string; openThread(instance: IModule, data: IFileThread, timeout?: number): boolean; closeThread(instance: Null, data: IFileThread, callback?: FunctionType): boolean; addProcessTimeout(instance: IModule, file: T, timeout: number): void; removeProcessTimeout(instance: IModule, file: T): void; getProcessTimeout(handler: InstallData): number; clearProcessTimeout(): void; addDownload(value: number | BufferContent, encoding: BufferEncoding): number; addDownload(value: number | BufferContent, type?: number, encoding?: BufferEncoding): number; getDownload(type?: number): TupleOf; transformAsset(data: IFileThread, parent?: T): Promise; addCopy(data: FileCommand, saveAs?: string, replace?: boolean): Undef; findMime(file: T, rename?: boolean): Promise; getUTF8String(file: T, uri?: string): string; getBuffer(file: T, minStreamSize?: U): U extends number ? Promise : Null; getCacheDir(url: string | URL, createDir?: boolean): string; setAssetContent(file: T, content: string, options?: AssetContentOptions): string; getAssetContent(file: T, content?: string): Undef; writeBuffer(file: T, options?: WriteFileOptions): Null; writeImage(document: StringOfArray, output: OutputFinalize): boolean; compressFile(file: T, overwrite?: boolean): Promise; fetchObject(uri: string | URL, format: BufferFormat): Promise>; fetchObject(uri: string | URL, options?: OpenOptions | BufferFormat): Promise>; fetchBuffer(uri: string | URL, options?: U): Promise>; fetchFiles(uri: string | URL, pathname: string): Promise; fetchFiles(uri: string | URL, options?: Aria2Options | string): Promise; start(emptyDir?: boolean): Promise; processAssets(emptyDir?: boolean, using?: T[]): void; deleteFile>(src: string, promises: boolean): U; deleteFile>(src: string, options: DeleteFileOptions & DeleteFileAddendum, promises: boolean): U; deleteFile(src: string, callback?: U): unknown; deleteFile(src: string, options: DeleteFileOptions & DeleteFileAddendum, callback?: U): unknown; restart(recursive?: boolean | "abort", emptyDir?: boolean): void; restart(recursive?: boolean | "abort", exclusions?: string[], emptyDir?: boolean): void; finalizeCompress(assets: T[]): Promise; finalizeDocument(): Promise; finalizeTask(assets: (T & Required)[]): Promise; finalizeCloud(): Promise; finalizeCleanup(): Promise; finalize(): Promise; close(): void; reset(): boolean; get baseDirectory(): string; get config(): RequestData; get assets(): T[]; get incremental(): IncrementalMatch; set restarting(value); get restarting(): boolean; get delayed(): number; set cleared(value); get cleared(): boolean; /* Set */ add(value: string, parent?: T, 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: BufferContent, 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: BufferContent, 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: BufferContent, 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: T[], exclusions?: string[]): T[]; writeChecksum(root: string, options?: ChecksumOptions): Promise; writeChecksum(root: string, to: Undef, options?: ChecksumOptions): Promise>; writeChecksum(root: string, to?: string | ChecksumOptions, options?: ChecksumOptions): Promise>; verifyChecksum(root: string, options?: ChecksumOptions): Promise>; verifyChecksum(root: string, from: Undef, options?: ChecksumOptions): Promise>; verifyChecksum(root: string, from?: string | ChecksumOptions, options?: ChecksumOptions): Promise>; createFileThread(host: IFileManager, file: T): IFileThread; setTimeout(options: ObjectMap): 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; } interface IHost extends IModule { restartable: boolean; readonly modules: Set; readonly subProcesses: Set; readonly startTime: number; using(...items: FirstOf): this; contains(item: unknown, condition?: FunctionType): boolean; find(name: string): Undef; findAll(name: string): IModule[]; willLog(name: string): boolean; ignoreLog(values: boolean | StringOfArray): void; collectLog(level?: boolean): LogStatus[]; willAbort(value: string | IModule): boolean; loadModule(name: string, ...args: any[]): Null; retain(process: IModule): void; release(process: IModule, log?: boolean): boolean; restart(...args: unknown[]): void; joinQueue(options?: JoinQueueOptions): boolean; resumeThread?(options: ResumeThreadOptions): void; set host(value); get host(): null; get config(): Readonly; get errorCount(): number; get username(): string; set done(value); get done(): boolean; get queued(): boolean; } interface HostConstructor extends ModuleConstructor { loadSettings(settings: Settings, password?: string): boolean; loadSettings(settings: Settings, permission?: PermissionReadWrite, password?: string): boolean; isPermission(value: unknown): value is IPermission; createPermission(all?: boolean, freeze?: boolean): IPermission; kill(username: string, iv: BinaryLike, all: true): number; kill(username: string, iv: BinaryLike, pid: ArrayOf | boolean): number; getThreadCount(full: true): ThreadCountStat; getThreadCount(username: string, iv?: BinaryLike): ThreadCountStat; getThreadCount(username?: string | boolean, iv?: BinaryLike): number; getPermissionFromSettings(): IPermission; readonly prototype: IHost; new(config?: HostInitConfig): IHost; } interface IModule extends EventEmitter, IAbortComponent { readonly status: LogStatus[]; readonly errors: unknown[]; supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean; supports(name: string, value?: boolean): boolean; getTempDir(options: GetTempDirOptions): string; getTempDir(uuidDir: boolean, createDir?: boolean): string; getTempDir(pathname: string, createDir?: boolean): string; getTempDir(uuidDir: boolean, filename: string, createDir?: boolean): string; getTempDir(pathname?: string, filename?: string, createDir?: boolean): string; canRead(uri: string, options?: PermissionOptions): boolean; canWrite(uri: string, options?: PermissionOptions): boolean; readFile(src: string): Undef; readFile(src: string, options?: U): Undef : string : U extends { minStreamSize: NumString } ? Promise : Buffer>; readFile(src: string, promises: true): Promise>; readFile(src: string, options: V, promises: true): Promise>; readFile(src: string, callback: U): Undef ? W : BufferContent>; readFile(src: string, options: V, callback: U): Undef ? W : BufferContent>; writeFile(src: string, data: BufferView, options?: WriteFileOptions): U; writeFile>(src: string, data: BufferView, promises: true): U; writeFile>(src: string, data: BufferView, options: WriteFileOptions, promises: true): U; writeFile(src: string, data: BufferView, callback: U): void; writeFile(src: string, data: BufferView, options: WriteFileOptions, callback: U): void; deleteFile(src: string, options?: DeleteFileOptions): U; deleteFile>(src: string, promises: true): U; deleteFile>(src: string, options: DeleteFileOptions, promises: true): U; deleteFile(src: string, callback: U): void; deleteFile(src: string, options: DeleteFileOptions, callback: U): void; copyFile(src: string, dest: string, options?: CopyFileOptions): U; copyFile>(src: string, dest: string, promises: true): U; copyFile>(src: string, dest: string, options: CopyFileOptions, promises: true): U; copyFile(src: string, dest: string, callback: U): void; copyFile(src: string, dest: string, options: CopyFileOptions, callback: U): void; moveFile(src: string, dest: string, options?: MoveFileOptions): U; moveFile>(src: string, dest: string, promises: true): U; moveFile>(src: string, dest: string, options: MoveFileOptions, promises: true): U; moveFile(src: string, dest: string, callback: U): void; moveFile(src: string, dest: string, options: MoveFileOptions, callback: U): void; createDir(src: string, options?: CreateDirOptions): U; createDir>(src: string, promises: true): U; createDir>(src: string, options: CreateDirOptions, promises: true): U; createDir(src: string, callback: U): void; createDir(src: string, options: CreateDirOptions, callback: U): void; removeDir(src: string, options?: RemoveDirOptions): U; removeDir>(src: string, promises: true): U; removeDir>(src: string, options: RemoveDirOptions, promises: true): U; removeDir(src: string, callback: U): void; removeDir(src: string, options: RemoveDirOptions, callback: U): void; allSettled(values: readonly (U | PromiseLike)[], rejected?: LogValue, options?: LogFailOptions | LogType): Promise[]>; formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void; formatFail(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogFailOptions): void; writeFail(value: LogValue, message?: unknown, options?: LogFailOptions | LogType): void; writeTimeProcess(title: string, value: string, startTime: LogTime, options?: LogProcessOptions): void; writeTimeElapsed(title: string, value: LogValue, startTime: LogTime, options?: LogMessageOptions): void; checkPackage(err: unknown, name: Undef, options?: LogFailOptions | LogType): boolean; checkPackage(err: unknown, name: Undef, value?: LogValue, options?: LogFailOptions | LogType): boolean; checkFail(message: unknown, options: LogFailOptions): Undef; writeLog(component: LogComponent, queue?: boolean): void; writeLog(type: StatusType, value: unknown, options?: LogOptions): void; writeLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number): void; addLog(component: LogComponent, queue?: boolean): void; addLog(type: StatusType, value: unknown, from: string, source?: string): void; addLog(type: StatusType, value: unknown, options?: LogOptions): void; addLog(type: StatusType, value: unknown, timeStamp?: LogDate, from?: string, source?: string): void; addLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number, from?: string, source?: string): void; getLog(...type: StatusType[]): LogStatus[]; flushLog(): void; willAbort(value: unknown): boolean; hasOwnPermission(): boolean; isFatal(err?: unknown): boolean; detach(): void; reset(): void; get moduleName(): string; set host(value); get host(): Null; set permission(value); get permission(): Null; get aborted(): boolean; set abortable(value); get abortable(): boolean; get threadable(): boolean; set sessionId(value); get sessionId(): string; set broadcastId(value); get broadcastId(): StringOfArray; get logType(): LOG_TYPE; set logLevel(value: NumString); get logLevel(): number; get statusType(): STATUS_TYPE; set tempDir(value); get tempDir(): string; /* EventEmitter */ 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: BufferContent, 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: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this; once(event: "error", listener: (err: Error) => void): this; once(event: "file:read", listener: (src: string, data: BufferContent, 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: "exec", command: ExecCommand, options?: SpawnOptions): boolean; emit(event: "error", err: Error): boolean; emit(event: "file:read", src: string, data: BufferContent, 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 ModuleConstructor { PROCESS_TIMEOUT: number; LOG_STYLE_FAIL: LogMessageOptions; LOG_STYLE_SUCCESS: LogMessageOptions; LOG_STYLE_INFO: LogMessageOptions; LOG_STYLE_WARN: LogMessageOptions; LOG_STYLE_NOTICE: LogMessageOptions; LOG_STYLE_REVERSE: LogMessageOptions; readonly VERSION: string; readonly LOG_TYPE: LOG_TYPE; readonly STATUS_TYPE: STATUS_TYPE; readonly MAX_TIMEOUT: number; readonly TEMP_DIR: string; supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean; formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void; writeFail(value: LogValue, message?: unknown, options?: LogFailOptions | LogType): void; enabled(key: string, username?: string): boolean; parseFunction(value: unknown, options?: ParseFunctionOptions): Null | U>>; parseFunction(value: unknown, absolute: boolean, sync?: boolean): Null | U>>; asString(value: unknown, cacheKey?: boolean | "throws"): string; asHash(data: BinaryLike, options: AsHashOptions): string; asHash(data: BinaryLike, minLength: number): string; asHash(data: BinaryLike, algorithm?: NumString | AsHashOptions, minLength?: number | AsHashOptions): string; readHash(value: string | URL, options?: ReadHashOptions): Promise; toPosix(value: unknown, normalize: boolean): string; toPosix(value: unknown, filename?: string, normalize?: boolean): string; hasLogType(value: LogType): boolean; isURL(value: string, ...exclude: string[]): boolean; isFile(value: string | URL, type?: ProtocolType): boolean; isDir(value: string | URL): boolean; isPath(value: string | URL, type?: "unc" | "unc-exists"): boolean; isPath(value: string | URL, isFile?: boolean): boolean; isErrorCode(err: unknown, ...code: string[]): boolean; fromLocalPath(value: string): string; resolveFile(value: string): string; resolvePath(value: string, base: string | URL): string; joinPath(...values: [...paths: unknown[], normalize: boolean][]): string; joinPath(...values: unknown[]): string; normalizePath(value: unknown, flags?: boolean | NormalizeFlags): string; createDir(value: string | URL, overwrite?: boolean): boolean; removeDir(value: string | URL, sinceCreated: number, recursive?: boolean): boolean; removeDir(value: string | URL, empty?: boolean, recursive?: boolean): boolean; copyDir(src: string | URL, dest: string | URL, options: CopyDirOptions): Promise; copyDir(src: string | URL, dest: string | URL, move?: boolean, recursive?: boolean): Promise; renameFile(src: string | URL, dest: string | URL, throws?: boolean): boolean; streamFile(src: string, cache: boolean): Promise; streamFile(src: string, options: U): Promise; streamFile(src: string, cache?: boolean | U, options?: U): Promise; readText(value: string | URL, cache: boolean): string; readText(value: string | URL, options: U): U extends { minStreamSize: NumString } ? Promise : string; readText(value: string | URL, encoding?: BufferEncoding | boolean | ReadTextOptions, cache?: boolean): string; readBuffer(value: string | URL, options: U): U extends { minStreamSize: NumString } ? Promise> : Null; readBuffer(value: string | URL, cache?: boolean): Null; resolveMime(data: string | Buffer | Uint8Array | ArrayBuffer): Promise>; lookupMime(value: string, extension?: boolean): string; initCpuUsage(instance?: IModule): CpuUsage; getCpuUsage(start: CpuUsage, format: true): string; getCpuUsage(start: CpuUsage, format?: boolean): number; getMemUsage(format: true): string; getMemUsage(format?: boolean): number; formatCpuMem(start: CpuUsage, all?: boolean): string; getPackageVersion(name: string | TupleOf, startDir: string, baseDir?: string): string; getPackageVersion(name: string | TupleOf, unstable?: boolean, startDir?: string, baseDir?: string): string; checkSemVer(name: string | TupleOf, options: CheckSemVerOptions): boolean; checkSemVer(name: string | TupleOf, min: NumString, max: NumString, options: CheckSemVerOptions): boolean; checkSemVer(name: string | TupleOf, min: NumString, max?: NumString, unstable?: boolean, startDir?: string): boolean; sanitizeCmd(value: string): string; sanitizeArgs(value: string, doubleQuote?: boolean): string; sanitizeArgs(values: string[], doubleQuote?: boolean): string[]; purgeMemory(percent: number, parent: boolean | number): Promise; purgeMemory(percent?: number, limit?: number, parent?: boolean | number): Promise; canWrite(name: "temp" | "home"): boolean; loadSettings(settings: Settings, password?: string): boolean; readonly prototype: IModule; new(): IModule; } } export = functions;