@e-mc/file-manager 0.8.2 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +202 -3
- package/index.js +393 -362
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -1,7 +1,206 @@
|
|
|
1
|
-
|
|
1
|
+
# @e-mc/file-manager
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
* NodeJS 14
|
|
4
|
+
* ES2020
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
## General Usage
|
|
7
|
+
|
|
8
|
+
* [Read the Docs](https://e-mc.readthedocs.io)
|
|
9
|
+
|
|
10
|
+
## Interface
|
|
11
|
+
|
|
12
|
+
- https://www.unpkg.com/@e-mc/types@0.8.4/lib/index.d.ts
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import type { DataSource, IncrementalMatch, TaskAction } from "./squared";
|
|
16
|
+
|
|
17
|
+
import type { DocumentConstructor, HostConstructor, ICloud, ICompress, IDocument, IHost, IImage, IModule, IRequest, ITask, ImageConstructor, TaskConstructor, WatchInstance } from "./index";
|
|
18
|
+
import type { ExternalAsset, FileCommand, FileData, IFileThread, OutputFinalize } from "./asset";
|
|
19
|
+
import type { IPermission, PermissionReadWrite } from "./core";
|
|
20
|
+
import type { AssetContentOptions, ChecksumOptions, DeleteFileAddendum, FileOutput, FinalizeResult, FindAssetOptions, IHttpDiskCache, IHttpMemoryCache, InstallData, PostFinalizeCallback, ReplaceOptions } from "./filemanager";
|
|
21
|
+
import type { ExecCommand } from "./logger";
|
|
22
|
+
import type { CopyFileOptions, CreateDirOptions, DeleteFileOptions, MoveFileOptions, ReadFileOptions, RemoveDirOptions, WriteFileOptions } from "./module";
|
|
23
|
+
import type { RequestData, Settings } from "./node";
|
|
24
|
+
import type { Aria2Options, BufferFormat, OpenOptions } from "./request";
|
|
25
|
+
import type { CloudModule, CompressModule, DbModule, DocumentModule, HttpConnectSettings, HttpMemorySettings, ImageModule, RequestModule, TaskModule, WatchModule } from "./settings";
|
|
26
|
+
|
|
27
|
+
import type { NoParamCallback } from "fs";
|
|
28
|
+
import type { SpawnOptions } from "child_process";
|
|
29
|
+
|
|
30
|
+
interface IFileManager extends IHost, Set<string> {
|
|
31
|
+
finalizeState: number;
|
|
32
|
+
processTimeout: number;
|
|
33
|
+
cacheToDisk: IHttpDiskCache<ExternalAsset>;
|
|
34
|
+
cacheToMemory: IHttpMemoryCache<ExternalAsset>;
|
|
35
|
+
Request: IRequest<RequestModule>;
|
|
36
|
+
Document: InstallData<IDocument<IFileManager, ExternalAsset>, DocumentConstructor<IFileManager, ExternalAsset>>[];
|
|
37
|
+
Task: InstallData<ITask, TaskConstructor>[];
|
|
38
|
+
Image: Map<string, InstallData<IImage, ImageConstructor>> | null;
|
|
39
|
+
Cloud: ICloud | null;
|
|
40
|
+
Watch: WatchInstance<ExternalAsset> | null;
|
|
41
|
+
Compress: ICompress<CompressModule> | null;
|
|
42
|
+
readonly documentAssets: ExternalAsset[];
|
|
43
|
+
readonly taskAssets: (ExternalAsset & Required<TaskAction>)[];
|
|
44
|
+
readonly dataSourceItems: DataSource[];
|
|
45
|
+
readonly files: Set<string>;
|
|
46
|
+
readonly filesQueued: Set<string>;
|
|
47
|
+
readonly filesToRemove: Set<string>;
|
|
48
|
+
readonly filesToCompare: Map<ExternalAsset, string[]>;
|
|
49
|
+
readonly contentToAppend: Map<string, string[]>;
|
|
50
|
+
readonly contentToReplace: Map<string, string[]>;
|
|
51
|
+
readonly processing: IFileThread[];
|
|
52
|
+
readonly fetchedAssets: ExternalAsset[];
|
|
53
|
+
readonly copiedAssets: ExternalAsset[];
|
|
54
|
+
readonly emptyDir: Set<string>;
|
|
55
|
+
install(name: "document", target: DocumentConstructor<IFileManager, ExternalAsset>, module?: DocumentModule): IDocument<IFileManager, ExternalAsset> | undefined;
|
|
56
|
+
install(name: "task", target: TaskConstructor, module?: TaskModule): ITask | undefined;
|
|
57
|
+
install(name: "cloud", handler: string, module?: CloudModule): ICloud | undefined;
|
|
58
|
+
install(name: "cloud", module?: CloudModule): ICloud | undefined;
|
|
59
|
+
install(name: "db", module?: DbModule): IDb | undefined;
|
|
60
|
+
install(name: "image", targets: Map<string, ImageConstructor>, module?: ImageModule): void;
|
|
61
|
+
install(name: "watch", module: WatchModule): WatchInstance<ExternalAsset> | undefined;
|
|
62
|
+
install(name: "watch", interval?: number | string, port?: number | string, securePort?: number | string, extensions?: unknown[]): WatchInstance<ExternalAsset> | undefined;
|
|
63
|
+
install(name: "compress", module?: CompressModule): ICompress<CompressModule> | undefined;
|
|
64
|
+
install(name: string, ...args: unknown[]): IModule | undefined;
|
|
65
|
+
using(...items: ExternalAsset[] | [boolean, ...ExternalAsset[]]): this;
|
|
66
|
+
contains(item: ExternalAsset, condition?: (...args: [ExternalAsset]) => boolean): boolean;
|
|
67
|
+
removeCwd(value: unknown): string;
|
|
68
|
+
findAsset(value: string | URL, instance?: IModule | FindAssetOptions<ExternalAsset>): ExternalAsset | undefined;
|
|
69
|
+
removeAsset(file: ExternalAsset): boolean;
|
|
70
|
+
replace(file: ExternalAsset, replaceWith: string, options: ReplaceOptions): boolean;
|
|
71
|
+
replace(file: ExternalAsset, replaceWith: string, mimeType?: string | ReplaceOptions): boolean;
|
|
72
|
+
rename(file: ExternalAsset, value: string): boolean;
|
|
73
|
+
performAsyncTask(): void;
|
|
74
|
+
removeAsyncTask(): void;
|
|
75
|
+
completeAsyncTask(err?: unknown, uri?: string, parent?: ExternalAsset, type?: number): void;
|
|
76
|
+
performFinalize(override?: boolean): void;
|
|
77
|
+
hasDocument(instance: IModule, document: string | string[] | undefined): boolean;
|
|
78
|
+
getDocumentAssets(instance: IModule, condition?: (...args: [ExternalAsset]) => boolean): ExternalAsset[];
|
|
79
|
+
getDataSourceItems(instance: IModule, condition?: (...args: [DataSource]) => boolean): DataSource[];
|
|
80
|
+
setLocalUri(file: ExternalAsset, replace?: boolean): FileOutput;
|
|
81
|
+
getLocalUri(data: FileData<ExternalAsset>): string;
|
|
82
|
+
getMimeType(data: FileData<ExternalAsset>): string;
|
|
83
|
+
openThread(instance: IModule, data: IFileThread, timeout?: number): boolean;
|
|
84
|
+
closeThread(instance: IModule | null, data: IFileThread, callback?: (...args: unknown[]) => void): boolean;
|
|
85
|
+
addProcessTimeout(instance: IModule, file: ExternalAsset, timeout: number): void;
|
|
86
|
+
removeProcessTimeout(instance: IModule, file: ExternalAsset): void;
|
|
87
|
+
getProcessTimeout(handler: InstallData): number;
|
|
88
|
+
clearProcessTimeout(): void;
|
|
89
|
+
addDownload(value: number | Buffer | string, encoding: BufferEncoding): number;
|
|
90
|
+
addDownload(value: number | Buffer | string, type?: number, encoding?: BufferEncoding): number;
|
|
91
|
+
getDownload(type?: number): [number, number];
|
|
92
|
+
transformAsset(data: IFileThread, parent?: ExternalAsset): Promise<void>;
|
|
93
|
+
addCopy(data: FileCommand<ExternalAsset>, saveAs?: string, replace?: boolean): string | undefined;
|
|
94
|
+
findMime(file: ExternalAsset, rename?: boolean): Promise<string>;
|
|
95
|
+
getUTF8String(file: ExternalAsset, uri?: string): string;
|
|
96
|
+
getBuffer(file: ExternalAsset, minStreamSize?: number): Promise<Buffer> | Buffer | null;
|
|
97
|
+
getCacheDir(url: string | URL, createDir?: boolean): string;
|
|
98
|
+
setAssetContent(file: ExternalAsset, content: string, options?: AssetContentOptions): string;
|
|
99
|
+
getAssetContent(file: ExternalAsset, content?: string): string | undefined;
|
|
100
|
+
writeBuffer(file: ExternalAsset, options?: WriteFileOptions): Buffer | null;
|
|
101
|
+
writeImage(document: string | string[], output: OutputFinalize<ExternalAsset>): boolean;
|
|
102
|
+
compressFile(file: ExternalAsset, overwrite?: boolean): Promise<unknown>;
|
|
103
|
+
fetchObject(uri: string | URL, format: BufferFormat): Promise<object | null>;
|
|
104
|
+
fetchObject(uri: string | URL, options?: OpenOptions | BufferFormat): Promise<object | null>;
|
|
105
|
+
fetchBuffer(uri: string | URL, options?: OpenOptions): Promise<Buffer | string | null>;
|
|
106
|
+
fetchFiles(uri: string | URL, pathname: string): Promise<string[]>;
|
|
107
|
+
fetchFiles(uri: string | URL, options?: Aria2Options | string): Promise<string[]>;
|
|
108
|
+
start(emptyDir?: boolean): Promise<FinalizeResult>;
|
|
109
|
+
processAssets(emptyDir?: boolean, using?: ExternalAsset[]): void;
|
|
110
|
+
deleteFile(src: string, promises: boolean): Promise<void>;
|
|
111
|
+
deleteFile(src: string, options: DeleteFileOptions & DeleteFileAddendum, promises: boolean): Promise<void>;
|
|
112
|
+
deleteFile(src: string, callback?: NoParamCallback): unknown;
|
|
113
|
+
deleteFile(src: string, options: DeleteFileOptions & DeleteFileAddendum, callback?: NoParamCallback): unknown;
|
|
114
|
+
restart(recursive?: boolean | "abort", emptyDir?: boolean): void;
|
|
115
|
+
restart(recursive?: boolean | "abort", exclusions?: string[], emptyDir?: boolean): void;
|
|
116
|
+
finalizeCompress(assets: ExternalAsset[]): Promise<unknown>;
|
|
117
|
+
finalizeDocument(): Promise<unknown>;
|
|
118
|
+
finalizeTask(assets: (ExternalAsset & Required<TaskAction>)[]): Promise<unknown>;
|
|
119
|
+
finalizeCloud(): Promise<unknown>;
|
|
120
|
+
finalizeCleanup(): Promise<unknown>;
|
|
121
|
+
finalize(): Promise<void>;
|
|
122
|
+
close(): void;
|
|
123
|
+
reset(): boolean;
|
|
124
|
+
get baseDirectory(): string;
|
|
125
|
+
get config(): RequestData;
|
|
126
|
+
get assets(): ExternalAsset[];
|
|
127
|
+
get incremental(): IncrementalMatch;
|
|
128
|
+
set restarting(value);
|
|
129
|
+
get restarting(): boolean;
|
|
130
|
+
get delayed(): number;
|
|
131
|
+
set cleared(value);
|
|
132
|
+
get cleared(): boolean;
|
|
133
|
+
|
|
134
|
+
/* Set */
|
|
135
|
+
add(value: string, parent?: ExternalAsset, type?: number): this;
|
|
136
|
+
delete(value: string, emptyDir?: boolean): boolean;
|
|
137
|
+
has(value: unknown): value is string;
|
|
138
|
+
|
|
139
|
+
/* EventEmitter */
|
|
140
|
+
on(event: "end", listener: PostFinalizeCallback): this;
|
|
141
|
+
on(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
|
|
142
|
+
on(event: "error", listener: (err: Error) => void): this;
|
|
143
|
+
on(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
|
|
144
|
+
on(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
|
|
145
|
+
on(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
|
|
146
|
+
on(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
|
|
147
|
+
on(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
|
|
148
|
+
on(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
|
|
149
|
+
on(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
|
|
150
|
+
once(event: "end", listener: PostFinalizeCallback): this;
|
|
151
|
+
once(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
|
|
152
|
+
once(event: "error", listener: (err: Error) => void): this;
|
|
153
|
+
once(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
|
|
154
|
+
once(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
|
|
155
|
+
once(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
|
|
156
|
+
once(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
|
|
157
|
+
once(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
|
|
158
|
+
once(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
|
|
159
|
+
once(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
|
|
160
|
+
emit(event: "end", result: FinalizeResult): boolean;
|
|
161
|
+
emit(event: "exec", command: ExecCommand, options?: SpawnOptions): boolean;
|
|
162
|
+
emit(event: "error", err: Error): boolean;
|
|
163
|
+
emit(event: "file:read", src: string, data: Buffer | string, options?: ReadFileOptions): boolean;
|
|
164
|
+
emit(event: "file:write", src: string, options?: WriteFileOptions): boolean;
|
|
165
|
+
emit(event: "file:delete", src: string, options?: DeleteFileOptions): boolean;
|
|
166
|
+
emit(event: "file:copy", dest: string, options?: CopyFileOptions): boolean;
|
|
167
|
+
emit(event: "file:move", dest: string, options?: MoveFileOptions): boolean;
|
|
168
|
+
emit(event: "dir:create", src: string, options?: CreateDirOptions): boolean;
|
|
169
|
+
emit(event: "dir:remove", src: string, options?: RemoveDirOptions): boolean;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
interface FileManagerConstructor extends HostConstructor {
|
|
173
|
+
loadSettings(settings: Settings, password?: string): boolean;
|
|
174
|
+
loadSettings(settings: Settings, permission?: PermissionReadWrite, password?: string): boolean;
|
|
175
|
+
sanitizeAssets(assets: ExternalAsset[], exclusions?: string[]): ExternalAsset[];
|
|
176
|
+
writeChecksum(root: string, options?: ChecksumOptions): Promise<string[]>;
|
|
177
|
+
writeChecksum(root: string, to: string | undefined, options?: ChecksumOptions): Promise<string[] | null>;
|
|
178
|
+
writeChecksum(root: string, to?: string | ChecksumOptions, options?: ChecksumOptions): Promise<string[] | null>;
|
|
179
|
+
verifyChecksum(root: string, options?: ChecksumOptions): Promise<[string[], string[]] | null>;
|
|
180
|
+
verifyChecksum(root: string, from: string | undefined, options?: ChecksumOptions): Promise<[string[], string[]] | null>;
|
|
181
|
+
verifyChecksum(root: string, from?: string | ChecksumOptions, options?: ChecksumOptions): Promise<[string[], string[]] | null>;
|
|
182
|
+
createFileThread(host: IFileManager, file: ExternalAsset): IFileThread;
|
|
183
|
+
setTimeout(options: Record<string, number | string>): void;
|
|
184
|
+
defineHttpCache(options: HttpMemorySettings, disk?: boolean): void;
|
|
185
|
+
defineHttpConnect(options: HttpConnectSettings): void;
|
|
186
|
+
readonly prototype: IFileManager;
|
|
187
|
+
new(baseDirectory: string, config: RequestData, postFinalize?: PostFinalizeCallback): IFileManager;
|
|
188
|
+
new(baseDirectory: string, config: RequestData, permission?: IPermission, postFinalize?: PostFinalizeCallback): IFileManager;
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## References
|
|
193
|
+
|
|
194
|
+
- https://www.unpkg.com/@e-mc/types@0.8.4/lib/squared.d.ts
|
|
195
|
+
- https://www.unpkg.com/@e-mc/types@0.8.4/lib/asset.d.ts
|
|
196
|
+
- https://www.unpkg.com/@e-mc/types@0.8.4/lib/core.d.ts
|
|
197
|
+
- https://www.unpkg.com/@e-mc/types@0.8.4/lib/filemanager.d.ts
|
|
198
|
+
- https://www.unpkg.com/@e-mc/types@0.8.4/lib/logger.d.ts
|
|
199
|
+
- https://www.unpkg.com/@e-mc/types@0.8.4/lib/module.d.ts
|
|
200
|
+
- https://www.unpkg.com/@e-mc/types@0.8.4/lib/node.d.ts
|
|
201
|
+
- https://www.unpkg.com/@e-mc/types@0.8.4/lib/request.d.ts
|
|
202
|
+
- https://www.unpkg.com/@e-mc/types@0.8.4/lib/settings.d.ts
|
|
203
|
+
|
|
204
|
+
## LICENSE
|
|
6
205
|
|
|
7
206
|
BSD 3-Clause
|