@e-mc/file-manager 0.8.13 → 0.8.15

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/LICENSE CHANGED
@@ -1,7 +1,7 @@
1
- Copyright 2024 An Pham
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
1
+ Copyright 2024 An Pham
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
7
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,206 +1,206 @@
1
- # @e-mc/file-manager
2
-
3
- * NodeJS 14
4
- * ES2019
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.13/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 { SpawnOptions } from "child_process";
28
- import type { NoParamCallback } from "fs";
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.13/lib/squared.d.ts
195
- - https://www.unpkg.com/@e-mc/types@0.8.13/lib/asset.d.ts
196
- - https://www.unpkg.com/@e-mc/types@0.8.13/lib/core.d.ts
197
- - https://www.unpkg.com/@e-mc/types@0.8.13/lib/filemanager.d.ts
198
- - https://www.unpkg.com/@e-mc/types@0.8.13/lib/logger.d.ts
199
- - https://www.unpkg.com/@e-mc/types@0.8.13/lib/module.d.ts
200
- - https://www.unpkg.com/@e-mc/types@0.8.13/lib/node.d.ts
201
- - https://www.unpkg.com/@e-mc/types@0.8.13/lib/request.d.ts
202
- - https://www.unpkg.com/@e-mc/types@0.8.13/lib/settings.d.ts
203
-
204
- ## LICENSE
205
-
1
+ # @e-mc/file-manager
2
+
3
+ * NodeJS 14
4
+ * ES2019
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.15/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 { SpawnOptions } from "child_process";
28
+ import type { NoParamCallback } from "fs";
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.15/lib/squared.d.ts
195
+ - https://www.unpkg.com/@e-mc/types@0.8.15/lib/asset.d.ts
196
+ - https://www.unpkg.com/@e-mc/types@0.8.15/lib/core.d.ts
197
+ - https://www.unpkg.com/@e-mc/types@0.8.15/lib/filemanager.d.ts
198
+ - https://www.unpkg.com/@e-mc/types@0.8.15/lib/logger.d.ts
199
+ - https://www.unpkg.com/@e-mc/types@0.8.15/lib/module.d.ts
200
+ - https://www.unpkg.com/@e-mc/types@0.8.15/lib/node.d.ts
201
+ - https://www.unpkg.com/@e-mc/types@0.8.15/lib/request.d.ts
202
+ - https://www.unpkg.com/@e-mc/types@0.8.15/lib/settings.d.ts
203
+
204
+ ## LICENSE
205
+
206
206
  MIT
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { FileManagerConstructor } from '../types/lib';
2
- import type { ExternalAsset } from '../types/lib/asset';
3
-
4
- declare const FileManager: FileManagerConstructor<ExternalAsset>;
5
-
1
+ import type { FileManagerConstructor } from '../types/lib';
2
+ import type { ExternalAsset } from '../types/lib/asset';
3
+
4
+ declare const FileManager: FileManagerConstructor<ExternalAsset>;
5
+
6
6
  export = FileManager;
package/index.js CHANGED
@@ -1597,6 +1597,7 @@ class FileManager extends core_1.Host {
1597
1597
  return document === moduleName || Array.isArray(document) && document.includes(moduleName);
1598
1598
  }
1599
1599
  setLocalUri(file, replace) {
1600
+ var _l;
1600
1601
  let uri = file.uri, type;
1601
1602
  if (uri && !file.url && !file.content && !file.base64 && !file.dataView) {
1602
1603
  if (core_1.Host.isFile(uri, 'torrent')) {
@@ -1649,6 +1650,13 @@ class FileManager extends core_1.Host {
1649
1650
  }
1650
1651
  }
1651
1652
  file.fetchType = type;
1653
+ if (file.document) {
1654
+ for (const { instance } of this.Document) {
1655
+ if (this.hasDocument(instance, file.document)) {
1656
+ (_l = instance.setLocalUri) === null || _l === void 0 ? void 0 : _l.call(instance, file, replace);
1657
+ }
1658
+ }
1659
+ }
1652
1660
  const segments = [];
1653
1661
  if (file.moveTo) {
1654
1662
  segments.push(file.moveTo);
@@ -1656,13 +1664,6 @@ class FileManager extends core_1.Host {
1656
1664
  if (file.pathname) {
1657
1665
  segments.push(file.pathname = core_1.Host.toPosix(file.pathname));
1658
1666
  }
1659
- if (file.document) {
1660
- for (const { instance } of this.Document) {
1661
- if (instance.setLocalUri && this.hasDocument(instance, file.document)) {
1662
- instance.setLocalUri(file, replace);
1663
- }
1664
- }
1665
- }
1666
1667
  const pathname = segments.length ? path.join(this.baseDirectory, ...segments) : this.baseDirectory;
1667
1668
  const localUri = file.filename ? path.join(pathname, file.filename) : pathname;
1668
1669
  file.localUri = localUri;
package/package.json CHANGED
@@ -1,34 +1,34 @@
1
- {
2
- "name": "@e-mc/file-manager",
3
- "version": "0.8.13",
4
- "description": "FileManager constructor for E-mc.",
5
- "main": "index.js",
6
- "types": "index.d.ts",
7
- "publishConfig": {
8
- "access": "public"
9
- },
10
- "repository": {
11
- "type": "git",
12
- "url": "git+https://github.com/anpham6/e-mc.git",
13
- "directory": "src/file-manager"
14
- },
15
- "keywords": [
16
- "squared",
17
- "squared-functions"
18
- ],
19
- "author": "An Pham <anpham6@gmail.com>",
20
- "license": "MIT",
21
- "homepage": "https://github.com/anpham6/e-mc#readme",
22
- "dependencies": {
23
- "@e-mc/cloud": "0.8.13",
24
- "@e-mc/compress": "0.8.13",
25
- "@e-mc/core": "0.8.13",
26
- "@e-mc/document": "0.8.13",
27
- "@e-mc/image": "0.8.13",
28
- "@e-mc/request": "0.8.13",
29
- "@e-mc/task": "0.8.13",
30
- "@e-mc/types": "0.8.13",
31
- "@e-mc/watch": "0.8.13",
32
- "picomatch": "^3.0.1"
33
- }
34
- }
1
+ {
2
+ "name": "@e-mc/file-manager",
3
+ "version": "0.8.15",
4
+ "description": "FileManager constructor for E-mc.",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/anpham6/e-mc.git",
13
+ "directory": "src/file-manager"
14
+ },
15
+ "keywords": [
16
+ "squared",
17
+ "squared-functions"
18
+ ],
19
+ "author": "An Pham <anpham6@gmail.com>",
20
+ "license": "MIT",
21
+ "homepage": "https://github.com/anpham6/e-mc#readme",
22
+ "dependencies": {
23
+ "@e-mc/cloud": "0.8.15",
24
+ "@e-mc/compress": "0.8.15",
25
+ "@e-mc/core": "0.8.15",
26
+ "@e-mc/document": "0.8.15",
27
+ "@e-mc/image": "0.8.15",
28
+ "@e-mc/request": "0.8.15",
29
+ "@e-mc/task": "0.8.15",
30
+ "@e-mc/types": "0.8.15",
31
+ "@e-mc/watch": "0.8.15",
32
+ "picomatch": "^3.0.1"
33
+ }
34
+ }