@e-mc/types 0.11.7 → 0.12.0
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 +13 -11
- package/constant.d.ts +7 -1
- package/index.d.ts +11 -6
- package/index.js +147 -60
- package/lib/compress.d.ts +5 -4
- package/lib/core.d.ts +127 -2
- package/lib/db.d.ts +2 -0
- package/lib/document.d.ts +11 -11
- package/lib/filemanager.d.ts +3 -3
- package/lib/http.d.ts +4 -0
- package/lib/image.d.ts +1 -0
- package/lib/index.d.ts +53 -27
- package/lib/logger.d.ts +3 -2
- package/lib/module.d.ts +11 -7
- package/lib/object.d.ts +7 -0
- package/lib/request.d.ts +14 -7
- package/lib/settings.d.ts +70 -11
- package/lib/squared.d.ts +18 -7
- package/lib/type.d.ts +0 -8
- package/lib/watch.d.ts +4 -2
- package/package.json +2 -2
- package/lib/compat-v4.d.ts +0 -121
package/lib/core.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import type { DataSource, RequestBase } from './squared';
|
|
1
|
+
import type { DataSource, RequestBase, WorkerAction } from './squared';
|
|
2
2
|
|
|
3
3
|
import type { IExternalConfig, IExternalFunction, IHost, IModule, ModuleConstructor } from './index';
|
|
4
4
|
import type { QueryResult, TimeoutAction } from './db';
|
|
5
|
+
import type { StatusType } from '@e-mc/types/lib/logger';
|
|
5
6
|
import type { Settings } from './node';
|
|
6
7
|
import type { ClientDbSettings, ClientModule, DbCacheValue, DbCoerceSettings, DbSourceOptions } from './settings';
|
|
7
8
|
|
|
9
|
+
import type { TransferListItem, Worker, WorkerOptions } from 'node:worker_threads';
|
|
10
|
+
|
|
11
|
+
import type * as EventEmitter from 'node:events';
|
|
12
|
+
|
|
8
13
|
export interface IdentifierAction {
|
|
9
14
|
uuidKey?: string;
|
|
10
15
|
}
|
|
@@ -77,6 +82,115 @@ export interface ClientDbConstructor<T extends IHost = IHost, U extends ClientMo
|
|
|
77
82
|
new(module?: U, database?: V[]): IClientDb<T, U, V>;
|
|
78
83
|
}
|
|
79
84
|
|
|
85
|
+
export interface IWorkerGroup extends WorkerBase {
|
|
86
|
+
[Symbol.iterator](): IteratorObject<IWorkerChannel, BuiltinIteratorReturn>;
|
|
87
|
+
add(name: string, item: IWorkerChannel, priority?: number): this;
|
|
88
|
+
get(name: string, force?: boolean | number): IWorkerChannel | undefined;
|
|
89
|
+
delete(name: string | IWorkerChannel): boolean;
|
|
90
|
+
free(count?: number): number;
|
|
91
|
+
print(format: "stats" | "errors"): void;
|
|
92
|
+
clear(): void;
|
|
93
|
+
set max(value);
|
|
94
|
+
get max(): number;
|
|
95
|
+
get workers(): IWorkerChannel[];
|
|
96
|
+
get pending(): number;
|
|
97
|
+
get available(): number;
|
|
98
|
+
get errors(): WorkerChannelError[];
|
|
99
|
+
get size(): number;
|
|
100
|
+
get sizeOf(): number;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface WorkerGroupConstructor {
|
|
104
|
+
checkTimeout(value: number, active?: boolean): number;
|
|
105
|
+
readonly prototype: IWorkerGroup;
|
|
106
|
+
new(max?: number, locked?: boolean): IWorkerGroup;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface IWorkerChannel<T = unknown> extends EventEmitter, Iterable<Worker>, WorkerInfo {
|
|
110
|
+
[Symbol.iterator](): IteratorObject<Worker, BuiltinIteratorReturn>;
|
|
111
|
+
sendObject(data: unknown, transferList?: TransferListItem[], callback?: WorkerChannelResponse<T>, ...returnArgs: unknown[]): Worker;
|
|
112
|
+
sendBuffer(data: Buffer, shared?: boolean, callback?: WorkerChannelResponse<T>, ...returnArgs: unknown[]): Worker | null;
|
|
113
|
+
send(data: unknown, transferList?: TransferListItem[]): Promise<T>;
|
|
114
|
+
drop(count?: number): number;
|
|
115
|
+
join(group: IWorkerGroup, label?: string): void;
|
|
116
|
+
quit(): void;
|
|
117
|
+
kill(count?: number): Promise<number>;
|
|
118
|
+
lock(): void;
|
|
119
|
+
addLog(err: unknown, type?: StatusType): void;
|
|
120
|
+
isEmpty(): boolean;
|
|
121
|
+
set min(value);
|
|
122
|
+
get min(): number;
|
|
123
|
+
set max(value);
|
|
124
|
+
get max(): number;
|
|
125
|
+
set idleTimeout(value);
|
|
126
|
+
get idleTimeout(): number;
|
|
127
|
+
get filename(): string;
|
|
128
|
+
get workers(): Worker[];
|
|
129
|
+
get detached(): boolean;
|
|
130
|
+
get lastAccessed(): Date;
|
|
131
|
+
get timesAccessed(): number;
|
|
132
|
+
get frequencyAccessed(): number;
|
|
133
|
+
get pending(): number;
|
|
134
|
+
get available(): number;
|
|
135
|
+
get errors(): WorkerChannelError[];
|
|
136
|
+
get size(): number;
|
|
137
|
+
|
|
138
|
+
/* EventEmitter */
|
|
139
|
+
on(event: "error" | "messageerror" | "abort", listener: (err: Error) => void): this;
|
|
140
|
+
on(event: "exit", listener: (exitCode: number) => void): this;
|
|
141
|
+
on(event: "online", listener: () => void): this;
|
|
142
|
+
on(event: "message", listener: (value: any) => void): this;
|
|
143
|
+
on(event: "data", listener: (data: T) => void): this;
|
|
144
|
+
on(event: "pass", listener: (data: unknown, transferList: TransferListItem[] | undefined) => void): this;
|
|
145
|
+
once(event: "error" | "messageerror" | "abort", listener: (err: Error) => void): this;
|
|
146
|
+
once(event: "exit", listener: (exitCode: number) => void): this;
|
|
147
|
+
once(event: "online", listener: () => void): this;
|
|
148
|
+
once(event: "message", listener: (value: any) => void): this;
|
|
149
|
+
once(event: "data", listener: (data: T) => void): this;
|
|
150
|
+
once(event: "pass", listener: (data: unknown, transferList: TransferListItem[] | undefined) => void): this;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface WorkerChannelConstructor<T = unknown> {
|
|
154
|
+
create<U>(filename: string, name: string): IWorkerChannel<U>;
|
|
155
|
+
create<U>(filename: string, options?: WorkerOptions, name?: string): IWorkerChannel<U>;
|
|
156
|
+
hasPermission(options?: WorkerAction): boolean;
|
|
157
|
+
readonly prototype: IWorkerChannel<T>;
|
|
158
|
+
new(filename: string | URL, options?: WorkerOptions, init?: WorkerChannelInit): IWorkerChannel<T>;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface WorkerBase {
|
|
162
|
+
max: number;
|
|
163
|
+
readonly pending: number;
|
|
164
|
+
readonly available: number;
|
|
165
|
+
readonly errors: WorkerChannelError[];
|
|
166
|
+
readonly size: number;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface WorkerInfo extends WorkerBase {
|
|
170
|
+
min: number;
|
|
171
|
+
readonly filename: string;
|
|
172
|
+
readonly workers: Worker[];
|
|
173
|
+
readonly detached: boolean;
|
|
174
|
+
readonly idleTimeout: number;
|
|
175
|
+
readonly lastAccessed: Date;
|
|
176
|
+
readonly timesAccessed: number;
|
|
177
|
+
readonly frequencyAccessed: number;
|
|
178
|
+
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface WorkerChannelInit {
|
|
182
|
+
max?: number;
|
|
183
|
+
idleTimeout?: number;
|
|
184
|
+
verbose?: boolean;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export interface WorkerChannelError {
|
|
188
|
+
timeStamp: Date;
|
|
189
|
+
type: StatusType;
|
|
190
|
+
value: unknown;
|
|
191
|
+
label?: string;
|
|
192
|
+
}
|
|
193
|
+
|
|
80
194
|
export interface IAbortComponent extends AbortController {
|
|
81
195
|
reset(): void;
|
|
82
196
|
get aborted(): boolean;
|
|
@@ -90,9 +204,13 @@ export interface AbortComponentConstructor {
|
|
|
90
204
|
}
|
|
91
205
|
|
|
92
206
|
export interface IPermission {
|
|
207
|
+
setDiskRead(enabled: boolean): void;
|
|
93
208
|
setDiskRead(pathname?: string | string[], enabled?: boolean): void;
|
|
209
|
+
setDiskWrite(enabled: boolean): void;
|
|
94
210
|
setDiskWrite(pathname?: string | string[], enabled?: boolean): void;
|
|
211
|
+
setUNCRead(enabled: boolean): void;
|
|
95
212
|
setUNCRead(pathname?: string | string[], enabled?: boolean): void;
|
|
213
|
+
setUNCWrite(enabled: boolean): void;
|
|
96
214
|
setUNCWrite(pathname?: string | string[], enabled?: boolean): void;
|
|
97
215
|
getDiskRead(): string | string[];
|
|
98
216
|
getDiskWrite(): string | string[];
|
|
@@ -194,4 +312,11 @@ export interface ResumeThreadOptions {
|
|
|
194
312
|
args: unknown[];
|
|
195
313
|
startTime: number;
|
|
196
314
|
aborted?: boolean;
|
|
197
|
-
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export interface WorkerMessage<T = PlainObject, U = Buffer> {
|
|
318
|
+
data: U;
|
|
319
|
+
options?: T;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export type WorkerChannelResponse<T = unknown> = (result: T, ...args: unknown[]) => void;
|
package/lib/db.d.ts
CHANGED
|
@@ -79,7 +79,9 @@ export interface IDbPool<T extends DbDataSource = DbDataSource, U = unknown, V =
|
|
|
79
79
|
|
|
80
80
|
export interface DbPoolConstructor<T extends DbDataSource = DbDataSource, U = unknown, V = unknown, W = unknown> {
|
|
81
81
|
CACHE_UNUSED: readonly string[];
|
|
82
|
+
CACHE_IGNORE: readonly string[];
|
|
82
83
|
asString(credential: unknown): string;
|
|
84
|
+
canCache(credential: unknown): boolean;
|
|
83
85
|
sanitize(credential: unknown): unknown;
|
|
84
86
|
removeUUIDKey<X>(credential: X & IdentifierAction): X;
|
|
85
87
|
findKey<X extends IDbPool, Y extends DbDataSource>(pools: ObjectMap<X>, uuidKey: unknown, poolKey: string | undefined, ...items: Y[]): X | null;
|
package/lib/document.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LocationUri, MimeTypeAction, StorageAction } from './squared';
|
|
1
|
+
import type { EncodingAction, LocationUri, MimeTypeAction, StorageAction } from './squared';
|
|
2
2
|
|
|
3
3
|
import type { IDocument, IFileManager, IModule } from './index';
|
|
4
4
|
import type { ExternalAsset, InitialValue } from './asset';
|
|
@@ -47,10 +47,9 @@ export interface ChunkData extends ChunkFile {
|
|
|
47
47
|
sourceMap?: SourceMap;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
export interface CacheData {
|
|
50
|
+
export interface CacheData extends EncodingAction {
|
|
51
51
|
uri?: string;
|
|
52
52
|
etag?: string;
|
|
53
|
-
encoding?: BufferEncoding;
|
|
54
53
|
override?: boolean;
|
|
55
54
|
}
|
|
56
55
|
|
|
@@ -81,7 +80,7 @@ export interface TransformOptions<T = AnyObject, U = T> extends TransformOutput
|
|
|
81
80
|
supplementChunks: ChunkData[];
|
|
82
81
|
}
|
|
83
82
|
|
|
84
|
-
export interface ITransformSeries<T = AnyObject, U = T> extends IModule, TransformOptions<T, U> {
|
|
83
|
+
export interface ITransformSeries<T = AnyObject, U = T, V = object> extends IModule, TransformOptions<T, U> {
|
|
85
84
|
readonly type: string;
|
|
86
85
|
init(instance: IModule, dirname?: string): this;
|
|
87
86
|
close(instance: IModule): void;
|
|
@@ -89,12 +88,12 @@ export interface ITransformSeries<T = AnyObject, U = T> extends IModule, Transfo
|
|
|
89
88
|
getMainFile(code?: string, imports?: StringMap): SourceInput<string> | undefined;
|
|
90
89
|
getSourceFiles(imports?: StringMap): SourceInput | undefined;
|
|
91
90
|
toBaseConfig(all?: boolean): T;
|
|
92
|
-
upgrade<
|
|
93
|
-
upgradeESM<
|
|
91
|
+
upgrade<W = unknown>(context: W, dirname?: string, pkgname?: string): W;
|
|
92
|
+
upgradeESM<W = unknown>(context: W, dirname?: string, pkgname?: string): Promise<W>;
|
|
94
93
|
set code(value);
|
|
95
94
|
get code(): string;
|
|
96
95
|
get out(): IOut;
|
|
97
|
-
get metadata():
|
|
96
|
+
get metadata(): V;
|
|
98
97
|
get options(): TransformOutput;
|
|
99
98
|
get productionRelease(): boolean;
|
|
100
99
|
get imported(): boolean;
|
|
@@ -136,12 +135,14 @@ export interface SourceMapOptions extends MimeTypeAction {
|
|
|
136
135
|
export interface SourceMap extends SourceCode {
|
|
137
136
|
output: Map<string, SourceCode>;
|
|
138
137
|
reset(): void;
|
|
138
|
+
nextMap(name: string, code: string, map: unknown, emptySources: boolean): boolean;
|
|
139
139
|
nextMap(name: string, code: string, map: unknown, sourceMappingURL?: string, emptySources?: boolean): boolean;
|
|
140
140
|
set map(value);
|
|
141
141
|
get map(): RawSourceMap | undefined;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
export interface SourceMapConstructor {
|
|
145
|
+
readonly SOURCE_MAPPING_URL: RegExp;
|
|
145
146
|
findSourceMap(code?: string, uri?: string): RawSourceMap | undefined;
|
|
146
147
|
removeSourceMappingURL(value: string): [string, string?, (RawSourceMap | null)?];
|
|
147
148
|
isRaw(map: unknown): map is RawSourceMap;
|
|
@@ -188,12 +189,11 @@ export interface CustomizeOptions {
|
|
|
188
189
|
transform?: DocumentTransform;
|
|
189
190
|
}
|
|
190
191
|
|
|
191
|
-
export interface AsSourceFileOptions {
|
|
192
|
-
encoding?: BufferEncoding;
|
|
192
|
+
export interface AsSourceFileOptions extends EncodingAction {
|
|
193
193
|
cache?: boolean;
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
export type Transformer = FunctionType<Promise<string> | string
|
|
196
|
+
export type Transformer = FunctionType<Promise<string> | string>;
|
|
197
197
|
export type ConfigOrTransformer = AnyObject | Transformer;
|
|
198
|
-
export type PluginConfig = [string,
|
|
198
|
+
export type PluginConfig<T = ConfigOrTransformer> = [string, T | undefined, AnyObject | undefined, boolean?] | [];
|
|
199
199
|
export type TransformCallback<T extends IFileManager<U>, U extends ExternalAsset = ExternalAsset> = (this: T, instance: IDocument<T, U>, requireOrDocumentDir?: NodeJS.Require | string) => Promise<void >;
|
package/lib/filemanager.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BundleAction, ChecksumOutput, FileInfo, LogStatus } from './squared';
|
|
1
|
+
import type { BundleAction, ChecksumOutput, EncodingAction, FileInfo, LogStatus } from './squared';
|
|
2
2
|
|
|
3
3
|
import type { IFileManager, IImage, IModule, ImageConstructor, ModuleConstructor } from './index';
|
|
4
4
|
import type { ExternalAsset } from './asset';
|
|
@@ -64,9 +64,8 @@ export interface HttpDiskCacheAddOptions {
|
|
|
64
64
|
contentLength?: number;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
export interface HttpMemoryCacheAddOptions extends Omit<HttpDiskCacheAddOptions, "buffer"
|
|
67
|
+
export interface HttpMemoryCacheAddOptions extends Omit<HttpDiskCacheAddOptions, "buffer">, EncodingAction {
|
|
68
68
|
toDisk?: string;
|
|
69
|
-
encoding?: BufferEncoding;
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
export interface ReplaceOptions {
|
|
@@ -110,6 +109,7 @@ export interface FindAssetOptions<T extends ExternalAsset = ExternalAsset> {
|
|
|
110
109
|
|
|
111
110
|
export interface ChecksumOptions extends ReadHashOptions, Pick<ChecksumOutput, "include" | "exclude" | "recursive"> {
|
|
112
111
|
dot?: boolean;
|
|
112
|
+
matchBase?: boolean;
|
|
113
113
|
sortBy?: number;
|
|
114
114
|
verbose?: boolean;
|
|
115
115
|
ignore?: string[];
|
package/lib/http.d.ts
CHANGED
package/lib/image.d.ts
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { DataSource, DbDataSource, IncrementalMatch, LogStatus, TaskAction,
|
|
|
4
4
|
|
|
5
5
|
import type { ExternalAsset, FileCommand, FileData, IFileThread, OutputFinalize } from './asset';
|
|
6
6
|
import type { BucketWebsiteOptions, CloudDatabase, CloudFeatures, CloudFunctions, CloudService, CloudStorage, CloudStorageDownload, CloudStorageUpload, DeleteObjectsOptions, UploadAssetOptions } from './cloud';
|
|
7
|
-
import type { BufferResult, CompressFormat, CompressLevel, ReadableOptions, TryFileCompressor } from './compress';
|
|
7
|
+
import type { BrotliCompressLevel, BufferResult, CompressFormat, CompressLevel, ReadableOptions, TryFileCompressor } from './compress';
|
|
8
8
|
import type { ClientDbConstructor, HostInitConfig, IAbortComponent, IClient, IClientDb, IPermission, JoinQueueOptions, PermissionReadWrite, ResumeThreadOptions, ThreadCountStat } from './core';
|
|
9
9
|
import type { BatchQueryResult, DB_TYPE, ErrorQueryCallback, ExecuteBatchQueryOptions, ExecuteQueryOptions, HandleFailOptions, ProcessRowsOptions, QueryResult, SQL_COMMAND } from './db';
|
|
10
10
|
import type { AsSourceFileOptions, ConfigOrTransformer, CustomizeOptions as CustomizeDocument, GenerateLintTableOptions, LintMessage, PluginConfig, SourceCode, SourceInput, SourceMap, SourceMapOptions, TransformAction, TransformCallback, TransformOutput, TransformResult, UpdateGradleOptions } from './document';
|
|
@@ -12,9 +12,9 @@ import type { AssetContentOptions, ChecksumOptions, DeleteFileAddendum, FileOutp
|
|
|
12
12
|
import type { HttpAgentSettings, HttpProtocolVersion, HttpRequestClient, InternetProtocolVersion } from './http';
|
|
13
13
|
import type { CommandData, CropData, QualityData, ResizeData, RotateData, TransformOptions } from './image';
|
|
14
14
|
import type { ExecCommand, LOG_TYPE, LogArguments, LogComponent, LogDate, LogFailOptions, LogMessageOptions, LogOptions, LogProcessOptions, LogState, LogTime, LogType, LogValue, STATUS_TYPE, StatusType } from './logger';
|
|
15
|
-
import type { AsHashOptions, CheckSemVerOptions, CopyDirOptions, CopyDirResult, CopyFileOptions, CreateDirOptions, DeleteFileOptions, FileTypeFormat, GlobDirOptions, MoveFileOptions, ParseFunctionOptions, PermissionOptions, ProtocolType, ReadBufferOptions, ReadFileCallback, ReadFileOptions, ReadHashOptions, ReadTextOptions, RemoveDirOptions, TempDirOptions, WriteFileOptions } from './module';
|
|
15
|
+
import type { AsHashOptions, CheckSemVerOptions, CopyDirOptions, CopyDirResult, CopyFileOptions, CreateDirOptions, DeleteFileOptions, FileTypeFormat, GlobDirOptions, MoveFileOptions, PackageVersionOptions, ParseFunctionOptions, PermissionOptions, PermissionType, ProtocolType, ReadBufferOptions, ReadFileCallback, ReadFileOptions, ReadHashOptions, ReadTextOptions, RemoveDirOptions, TempDirOptions, WriteFileOptions } from './module';
|
|
16
16
|
import type { HighResolutionTime, RequestData, Settings } from './node';
|
|
17
|
-
import type { ApplyOptions, Aria2Options, BufferFormat, DataEncodedResult, DataObjectResult, FormDataPart, HeadersOnCallback, HostConfig, IHttpAdapter, OpenOptions, PostOptions, ProxySettings, PutOptions, ReadExpectType, RequestInit, StatusOnCallback } from './request';
|
|
17
|
+
import type { ApplyOptions, Aria2Options, BufferFormat, DataEncodedResult, DataObjectResult, FormDataPart, HeadersOnCallback, HostConfig, IHttpAdapter, OpenOptions, PostOptions, ProxySettings, PutOptions, RcloneOptions, ReadExpectType, RequestInit, StatusOnCallback } from './request';
|
|
18
18
|
import type { ClientModule, CloudAuthSettings, CloudModule, CloudServiceOptions, CompressModule, CompressSettings, DbCoerceSettings, DbModule, DbSourceOptions, DnsLookupSettings, DocumentComponent, DocumentComponentOption, DocumentModule, HandlerSettings, HttpConnectSettings, HttpMemorySettings, ImageModule, LoggerFormat, LoggerFormatSettings, PoolConfig, RequestModule, RequestSettings, TaskModule, WatchModule } from './settings';
|
|
19
19
|
import type { Command, SpawnResult } from './task';
|
|
20
20
|
import type { IFileGroup, ModifiedPostFinalizeListener, SecureOptions, WatchInitResult } from './watch';
|
|
@@ -26,7 +26,7 @@ import type { ClientRequest, OutgoingHttpHeaders } from 'node:http';
|
|
|
26
26
|
import type { LookupFunction } from 'node:net';
|
|
27
27
|
import type { Readable, Writable } from 'node:stream';
|
|
28
28
|
import type { SecureContextOptions } from 'node:tls';
|
|
29
|
-
import type { BrotliCompress, Gzip } from 'node:zlib';
|
|
29
|
+
import type { BrotliCompress, BrotliOptions, Gzip, ZlibOptions } from 'node:zlib';
|
|
30
30
|
// @ts-ignore
|
|
31
31
|
import type { FileTypeResult } from 'file-type';
|
|
32
32
|
|
|
@@ -57,6 +57,10 @@ declare namespace functions {
|
|
|
57
57
|
get extensions(): T[];
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
interface IWorkerConstructor {
|
|
61
|
+
asBuffer(data: Buffer | Uint8Array): Buffer;
|
|
62
|
+
}
|
|
63
|
+
|
|
60
64
|
interface ICompress<T extends CompressModule = CompressModule, U extends CompressSettings = CompressSettings> extends IModule, IExternalConfig<T, U> {
|
|
61
65
|
level: ObjectMap<number>;
|
|
62
66
|
compressors: ObjectMap<TryFileCompressor>;
|
|
@@ -64,20 +68,23 @@ declare namespace functions {
|
|
|
64
68
|
getLevel(value: string, fallback?: number): number | undefined;
|
|
65
69
|
getReadable(file: string | URL | Buffer, options?: ReadableOptions): Readable;
|
|
66
70
|
createGzip(file: string | Buffer, options?: CompressLevel): Gzip;
|
|
67
|
-
createBrotliCompress(file: string | Buffer, options?:
|
|
71
|
+
createBrotliCompress(file: string | Buffer, options?: BrotliCompressLevel): BrotliCompress;
|
|
68
72
|
createWriteStreamAsGzip(file: string | Buffer, output: string, options?: CompressLevel): WriteStream;
|
|
69
73
|
createWriteStreamAsBrotli(file: string | Buffer, output: string, options?: CompressLevel): WriteStream;
|
|
74
|
+
intoGzipStream(output: string, options?: ZlibOptions): WriteStream;
|
|
75
|
+
intoBrotliStream(output: string, options?: BrotliOptions): WriteStream;
|
|
70
76
|
writeGzip(file: string | Buffer, output: string, options?: CompressLevel): Promise<void>;
|
|
71
77
|
writeBrotli(file: string | Buffer, output: string, options?: CompressLevel): Promise<void>;
|
|
72
78
|
tryFile(file: string | Buffer, options: CompressFormat): Promise<BufferResult>;
|
|
73
79
|
tryFile(file: string | Buffer, output: string, options?: CompressFormat): Promise<BufferResult>;
|
|
74
80
|
tryImage(file: string, options: CompressFormat): Promise<BufferResult>;
|
|
75
81
|
tryImage(file: string | Buffer, output: string, options?: CompressFormat): Promise<BufferResult>;
|
|
82
|
+
hasPermission(type: string, options?: unknown): boolean;
|
|
76
83
|
set chunkSize(value: number | string | undefined);
|
|
77
84
|
get chunkSize(): number | undefined;
|
|
78
85
|
}
|
|
79
86
|
|
|
80
|
-
interface CompressConstructor<T extends CompressModule = CompressModule, U extends CompressSettings = CompressSettings> extends ModuleConstructor {
|
|
87
|
+
interface CompressConstructor<T extends CompressModule = CompressModule, U extends CompressSettings = CompressSettings> extends ModuleConstructor, IWorkerConstructor {
|
|
81
88
|
singleton(): ICompress<T, U>;
|
|
82
89
|
readonly prototype: ICompress<T, U>;
|
|
83
90
|
new(module?: U): ICompress<T, U>;
|
|
@@ -94,21 +101,27 @@ declare namespace functions {
|
|
|
94
101
|
setCommand(value: string | CommandData, outputAs?: string): void;
|
|
95
102
|
getCommand(): string;
|
|
96
103
|
parseCommand(value: string): CommandData;
|
|
97
|
-
parseMethod(value: string):
|
|
98
|
-
parseResize(value: string):
|
|
99
|
-
parseCrop(value: string):
|
|
100
|
-
parseRotate(value: string):
|
|
101
|
-
parseQuality(value: string):
|
|
104
|
+
parseMethod(value: string): [string, unknown[]?][] | null;
|
|
105
|
+
parseResize(value: string): ResizeData | null;
|
|
106
|
+
parseCrop(value: string): CropData | null;
|
|
107
|
+
parseRotate(value: string): RotateData | null;
|
|
108
|
+
parseQuality(value: string): QualityData | null;
|
|
102
109
|
parseOpacity(value: string): number;
|
|
110
|
+
parseWorker(command: string | CommandData, outputType?: string): CommandData | null;
|
|
103
111
|
using?<V extends ExternalAsset>(data: IFileThread<V>, command: string): Promise<unknown>;
|
|
104
112
|
get outputAs(): string;
|
|
105
113
|
set host(value);
|
|
106
114
|
get host(): T | null;
|
|
107
115
|
}
|
|
108
116
|
|
|
109
|
-
interface ImageConstructor<T extends IHost = IHost, U extends ImageModule = ImageModule> extends ModuleConstructor {
|
|
110
|
-
|
|
111
|
-
readonly
|
|
117
|
+
interface ImageConstructor<T extends IHost = IHost, U extends ImageModule = ImageModule> extends ModuleConstructor, IWorkerConstructor {
|
|
118
|
+
readonly MIME_JPEG: string;
|
|
119
|
+
readonly MIME_PNG: string;
|
|
120
|
+
readonly MIME_WEBP: string;
|
|
121
|
+
readonly MIME_SVG: string;
|
|
122
|
+
readonly MIME_GIF: string;
|
|
123
|
+
readonly MIME_BMP: string;
|
|
124
|
+
readonly MIME_TIFF: string;
|
|
112
125
|
transform<V extends TransformOptions>(file: string, command: string, options?: V): Promise<V extends { tempFile: true } ? string : Buffer | null>;
|
|
113
126
|
clamp(value: unknown, min?: number, max?: number): number;
|
|
114
127
|
isBinary(mime: unknown): mime is string;
|
|
@@ -255,7 +268,7 @@ declare namespace functions {
|
|
|
255
268
|
cloudUpload?(state: IScopeOrigin<T, Y>, file: U, url: string, active: boolean): Promise<boolean>;
|
|
256
269
|
cloudFinalize?(state: IScopeOrigin<T, Y>): Promise<unknown[]>;
|
|
257
270
|
watchInit?(watch: IFileGroup<U>, assets: U[], sanitize?: boolean): WatchInitResult | undefined;
|
|
258
|
-
watchModified?(watch: IFileGroup<U>, assets?: U[]): PostFinalizeCallback;
|
|
271
|
+
watchModified?(watch: IFileGroup<U>, assets?: U[], recursive?: [string, string[]][]): PostFinalizeCallback;
|
|
259
272
|
set dataSource(value: DataSource[]);
|
|
260
273
|
get dataSource(): DataSource[];
|
|
261
274
|
set imports(value);
|
|
@@ -289,6 +302,7 @@ declare namespace functions {
|
|
|
289
302
|
setSSLKey(value: string): boolean;
|
|
290
303
|
setSSLCert(value: string): boolean;
|
|
291
304
|
hasSecureProtocol(): boolean;
|
|
305
|
+
getRecursiveFiles(watch: IFileGroup<U>): [string, string[]][];
|
|
292
306
|
whenModified?(assets: U[], postFinalize: PostFinalizeCallback): IFileManager<U>;
|
|
293
307
|
whenModified?(assets: U[], sanitize?: boolean, postFinalize?: PostFinalizeCallback): IFileManager<U>;
|
|
294
308
|
set assets(value: U[]);
|
|
@@ -335,6 +349,8 @@ declare namespace functions {
|
|
|
335
349
|
headersOf(uri: string): OutgoingHttpHeaders | undefined;
|
|
336
350
|
aria2c(uri: string | URL, pathname: string): Promise<string[]>;
|
|
337
351
|
aria2c(uri: string | URL, options?: Aria2Options): Promise<string[]>;
|
|
352
|
+
rclone(uri: string, pathname: string): Promise<string[]>;
|
|
353
|
+
rclone(uri: string, options?: RcloneOptions): Promise<string[]>;
|
|
338
354
|
json(uri: string | URL, options?: OpenOptions): Promise<object | null>;
|
|
339
355
|
pipe(uri: string | URL, to: Writable, options?: OpenOptions): Promise<null>;
|
|
340
356
|
opts<V extends OpenOptions>(url: string | URL, options?: V): HostConfig & V;
|
|
@@ -373,6 +389,7 @@ declare namespace functions {
|
|
|
373
389
|
defineHttpAgent(options: HttpAgentSettings): void;
|
|
374
390
|
defineDnsLookup(options: DnsLookupSettings, clear?: boolean): void;
|
|
375
391
|
getAria2Path(): string;
|
|
392
|
+
getRclonePath(): string;
|
|
376
393
|
readonly prototype: IRequest<T, U>;
|
|
377
394
|
new(module?: T): IRequest<T, U>;
|
|
378
395
|
}
|
|
@@ -414,7 +431,7 @@ declare namespace functions {
|
|
|
414
431
|
install(name: "watch", target: WatchConstructor<IFileManager<T>, T>, module?: WatchModule, ...args: unknown[]): WatchInstance<T> | undefined;
|
|
415
432
|
install(name: "watch", module: WatchModule): WatchInstance<T> | undefined;
|
|
416
433
|
install(name: "compress", module?: CompressModule): ICompress | undefined;
|
|
417
|
-
install(name: string, ...args: unknown[]):
|
|
434
|
+
install<U extends IModule>(name: string, ...args: unknown[]): U | undefined;
|
|
418
435
|
using(...items: FirstOf<T>): this;
|
|
419
436
|
contains(item: T, condition?: FunctionArgs<[T], boolean>): boolean;
|
|
420
437
|
removeCwd(value: unknown): string;
|
|
@@ -440,8 +457,8 @@ declare namespace functions {
|
|
|
440
457
|
removeProcessTimeout(instance: IModule, file: T): void;
|
|
441
458
|
getProcessTimeout(handler: InstallData): number;
|
|
442
459
|
clearProcessTimeout(): void;
|
|
443
|
-
scheduleTask(
|
|
444
|
-
scheduleTask(
|
|
460
|
+
scheduleTask(uri: string | URL, data: unknown, priority: number): Promise<unknown>;
|
|
461
|
+
scheduleTask(uri: string | URL, data: unknown, thenCallback?: FunctionType, catchCallback?: FunctionType, priority?: number): Promise<unknown>;
|
|
445
462
|
setTaskLimit(value: number): void;
|
|
446
463
|
addDownload(value: number | Bufferable, encoding: BufferEncoding): number;
|
|
447
464
|
addDownload(value: number | Bufferable, type?: number | BufferEncoding, encoding?: BufferEncoding): number;
|
|
@@ -461,7 +478,7 @@ declare namespace functions {
|
|
|
461
478
|
fetchObject(uri: string | URL, options?: OpenOptions | BufferFormat): Promise<object | null>;
|
|
462
479
|
fetchBuffer<U extends OpenOptions>(uri: string | URL, options?: U): Promise<DataEncodedResult<U>>;
|
|
463
480
|
fetchFiles(uri: string | URL, pathname: string): Promise<string[]>;
|
|
464
|
-
fetchFiles(uri: string | URL, options?: Aria2Options): Promise<string[]>;
|
|
481
|
+
fetchFiles(uri: string | URL, options?: Aria2Options | RcloneOptions): Promise<string[]>;
|
|
465
482
|
updateProgress(name: "request", id: number | string, receivedBytes: number, totalBytes: number, dataTime?: HighResolutionTime): void;
|
|
466
483
|
start(emptyDir?: boolean): Promise<FinalizeResult>;
|
|
467
484
|
processAssets(emptyDir?: boolean, using?: T[]): void;
|
|
@@ -491,6 +508,7 @@ declare namespace functions {
|
|
|
491
508
|
get cleared(): boolean;
|
|
492
509
|
set finalizeState(value);
|
|
493
510
|
get finalizeState(): number;
|
|
511
|
+
get retryLimit(): number;
|
|
494
512
|
|
|
495
513
|
/* Set */
|
|
496
514
|
add(value: string, parent?: T, type?: number): this;
|
|
@@ -591,6 +609,8 @@ declare namespace functions {
|
|
|
591
609
|
loadSettings(settings: Settings, permission?: PermissionReadWrite, password?: string): boolean;
|
|
592
610
|
isPermission(value: unknown): value is IPermission;
|
|
593
611
|
createPermission(all?: boolean, freeze?: boolean): IPermission;
|
|
612
|
+
kill(username: string, all: true): number;
|
|
613
|
+
kill(username: string, pid: number | number[]): number;
|
|
594
614
|
kill(username: string, iv: BinaryLike, all: true): number;
|
|
595
615
|
kill(username: string, iv: BinaryLike, pid: number | number[]): number;
|
|
596
616
|
getThreadCount(full: true): ThreadCountStat;
|
|
@@ -654,8 +674,8 @@ declare namespace functions {
|
|
|
654
674
|
allSettled<U>(values: readonly (U | PromiseLike<U>)[], rejected?: LogValue, options?: LogFailOptions): Promise<PromiseFulfilledResult<U>[]>;
|
|
655
675
|
formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
|
|
656
676
|
formatFail(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogFailOptions): void;
|
|
657
|
-
writeFail(value: LogValue, message
|
|
658
|
-
writeFail(value: LogValue, message?: unknown,
|
|
677
|
+
writeFail(value: LogValue, message: unknown, options: LogFailOptions): void;
|
|
678
|
+
writeFail(value: LogValue, message?: unknown, type?: LogType | LogFailOptions): void;
|
|
659
679
|
writeTimeProcess(title: string, value: string, startTime: LogTime, options?: LogProcessOptions): void;
|
|
660
680
|
writeTimeElapsed(title: string, value: LogValue, startTime: LogTime, options?: LogMessageOptions): void;
|
|
661
681
|
checkPackage(err: unknown, name: string | undefined, type: LogType): boolean;
|
|
@@ -673,7 +693,9 @@ declare namespace functions {
|
|
|
673
693
|
getLog(...type: StatusType[]): LogStatus<StatusType>[];
|
|
674
694
|
flushLog(): void;
|
|
675
695
|
willAbort(value: unknown): boolean;
|
|
696
|
+
/** @deprecated hasPermission("fs") */
|
|
676
697
|
hasOwnPermission(): boolean;
|
|
698
|
+
hasPermission(type: PermissionType | string, ...values: unknown[]): boolean;
|
|
677
699
|
isFatal(err?: unknown): boolean;
|
|
678
700
|
detach(): void;
|
|
679
701
|
reset(): void;
|
|
@@ -741,10 +763,12 @@ declare namespace functions {
|
|
|
741
763
|
readonly LOG_TYPE: LOG_TYPE;
|
|
742
764
|
readonly LOG_FORMAT: LoggerFormatSettings<LoggerFormat<number>>;
|
|
743
765
|
readonly STATUS_TYPE: STATUS_TYPE;
|
|
766
|
+
readonly REQUIRE_ESM: boolean;
|
|
744
767
|
readonly PLATFORM_WIN32: boolean;
|
|
745
768
|
readonly MAX_TIMEOUT: number;
|
|
746
769
|
readonly TEMP_DIR: string;
|
|
747
|
-
|
|
770
|
+
constructorOf<U extends ModuleConstructor>(value: unknown, moduleName?: string): value is U;
|
|
771
|
+
/** @deprecated @e-mc/types */
|
|
748
772
|
supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
|
|
749
773
|
formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
|
|
750
774
|
writeFail(value: LogValue, message?: unknown, options?: LogFailOptions | LogType): void;
|
|
@@ -754,7 +778,7 @@ declare namespace functions {
|
|
|
754
778
|
asString(value: unknown, cacheKey?: boolean | "throws"): string;
|
|
755
779
|
asHash(data: BinaryLike, options?: AsHashOptions): string;
|
|
756
780
|
asHash(data: BinaryLike, algorithm?: string, options?: HashOptions): string;
|
|
757
|
-
asHash(data: BinaryLike, algorithm?: string,
|
|
781
|
+
asHash(data: BinaryLike, algorithm?: string, encoding?: BinaryToTextEncoding): string;
|
|
758
782
|
readHash(value: string | URL, options?: ReadHashOptions): Promise<string>;
|
|
759
783
|
toPosix(value: unknown, normalize: boolean): string;
|
|
760
784
|
toPosix(value: unknown, filename?: string, normalize?: boolean): string;
|
|
@@ -795,19 +819,21 @@ declare namespace functions {
|
|
|
795
819
|
getMemUsage(format: true): string;
|
|
796
820
|
getMemUsage(format?: boolean): number;
|
|
797
821
|
formatCpuMem(start: CpuUsage, all?: boolean): string;
|
|
822
|
+
getPackageVersion(name: string | [string, string], options?: PackageVersionOptions): string;
|
|
798
823
|
/** @deprecated */
|
|
799
824
|
getPackageVersion(name: string | [string, string], startDir: string, baseDir?: string): string;
|
|
800
825
|
/** @deprecated */
|
|
801
826
|
getPackageVersion(name: string | [string, string], unstable?: boolean, startDir?: string, baseDir?: string): string;
|
|
802
827
|
checkSemVer(name: string | [string, string], options: CheckSemVerOptions): boolean;
|
|
803
|
-
|
|
804
|
-
checkSemVer(name: string | [string, string], min: number | string, max?: number | string, unstable?: boolean, startDir?: string): boolean;
|
|
828
|
+
checkSemVer(name: string | [string, string], min: number | string, max?: number | string): boolean;
|
|
805
829
|
checkSemVer(name: string | [string, string], min: number | string, max: number | string, options?: Omit<CheckSemVerOptions, "min" | "max" | "equals">): boolean;
|
|
806
830
|
/** @deprecated */
|
|
831
|
+
checkSemVer(name: string | [string, string], min: number | string, max?: number | string, unstable?: boolean, startDir?: string): boolean;
|
|
832
|
+
/** @deprecated @e-mc/types */
|
|
807
833
|
sanitizeCmd(value: string): string;
|
|
808
|
-
/** @deprecated */
|
|
834
|
+
/** @deprecated @e-mc/types */
|
|
809
835
|
sanitizeArgs(value: string, doubleQuote?: boolean): string;
|
|
810
|
-
/** @deprecated */
|
|
836
|
+
/** @deprecated @e-mc/types */
|
|
811
837
|
sanitizeArgs(values: string[], doubleQuote?: boolean): string[];
|
|
812
838
|
purgeMemory(percent: number, limit: number, parent?: boolean): Promise<number>;
|
|
813
839
|
purgeMemory(percent?: number, limit?: number | boolean, parent?: unknown): Promise<number>;
|
package/lib/logger.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { HighResolutionTime } from './node';
|
|
|
4
4
|
|
|
5
5
|
import type { LOG_STATE, LOG_TYPE, STATUS_TYPE } from '../index.d';
|
|
6
6
|
|
|
7
|
+
// @ts-ignore
|
|
7
8
|
import type { BackgroundColor as IBackgroundColor, ForegroundColor as IForegroundColor } from 'chalk';
|
|
8
9
|
|
|
9
10
|
type HexColor = `#${string}`;
|
|
@@ -111,6 +112,6 @@ export type BackgroundColor = typeof IBackgroundColor | HexColor;
|
|
|
111
112
|
export type ForegroundColor = typeof IForegroundColor | HexColor;
|
|
112
113
|
export type TextAlign = "left" | "center" | "right";
|
|
113
114
|
export type TextWrapStyle = "ellipsis" | "nowrap" | "ellipsis-end" | "nowrap-end" | "none";
|
|
114
|
-
export type ErrorOutMethod = (err: Error, data: LogTypeValue, require?:
|
|
115
|
-
export type BroadcastOutMethod = (value: string, options: LogMessageOptions, require?:
|
|
115
|
+
export type ErrorOutMethod = (err: Error, data: LogTypeValue, require?: NodeJS.Require) => void;
|
|
116
|
+
export type BroadcastOutMethod = (value: string, options: LogMessageOptions, require?: NodeJS.Require) => void;
|
|
116
117
|
export type BroadcastValue = string | string[] | { value: string | string[]; stripAnsi?: boolean };
|
package/lib/module.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChecksumBase } from './squared';
|
|
1
|
+
import type { ChecksumBase, EncodingAction } from './squared';
|
|
2
2
|
|
|
3
3
|
import type { StreamAction } from './asset';
|
|
4
4
|
|
|
@@ -41,14 +41,12 @@ export interface FileSystemOptions extends PermissionOptions, ThrowsAction {
|
|
|
41
41
|
ignorePermission?: boolean;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export interface ReadFileOptions extends FileSystemOptions, StreamBase, RequireAction {
|
|
44
|
+
export interface ReadFileOptions extends FileSystemOptions, StreamBase, RequireAction, EncodingAction {
|
|
45
45
|
cache?: boolean;
|
|
46
|
-
encoding?: BufferEncoding;
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
export interface WriteFileOptions extends FileSystemOptions {
|
|
48
|
+
export interface WriteFileOptions extends FileSystemOptions, EncodingAction {
|
|
50
49
|
overwrite?: boolean;
|
|
51
|
-
encoding?: BufferEncoding;
|
|
52
50
|
}
|
|
53
51
|
|
|
54
52
|
export interface DeleteFileOptions extends FileSystemOptions {
|
|
@@ -76,6 +74,12 @@ export interface ParseFunctionOptions extends RequireAction {
|
|
|
76
74
|
context?: unknown;
|
|
77
75
|
}
|
|
78
76
|
|
|
77
|
+
export interface PackageVersionOptions {
|
|
78
|
+
unstable?: boolean;
|
|
79
|
+
startDir?: string;
|
|
80
|
+
baseDir?: string;
|
|
81
|
+
}
|
|
82
|
+
|
|
79
83
|
export interface CheckSemVerOptions {
|
|
80
84
|
min?: number;
|
|
81
85
|
max?: number;
|
|
@@ -118,8 +122,7 @@ export interface ReadHashOptions extends ChecksumBase, StreamBase {
|
|
|
118
122
|
chunkSize?: number;
|
|
119
123
|
}
|
|
120
124
|
|
|
121
|
-
export interface ReadBufferOptions extends StreamBase {
|
|
122
|
-
encoding?: BufferEncoding;
|
|
125
|
+
export interface ReadBufferOptions extends StreamBase, EncodingAction {
|
|
123
126
|
cache?: boolean;
|
|
124
127
|
}
|
|
125
128
|
|
|
@@ -137,4 +140,5 @@ export interface TempDirOptions {
|
|
|
137
140
|
export type ReadTextOptions = ReadBufferOptions;
|
|
138
141
|
export type ReadFileCallback<T extends Bufferable = Bufferable> = (err: NodeJS.ErrnoException | null, data?: T) => void;
|
|
139
142
|
export type ProtocolType = "http" | "https" | "http/s" | "ftp" | "sftp" | "s/ftp" | "torrent" | "unc" | "file";
|
|
143
|
+
export type PermissionType = "fs" | "memory" | "memory.user" | "worker";
|
|
140
144
|
export type FileTypeFormat = Bufferable | Uint8Array | ArrayBuffer | Readable;
|
package/lib/object.d.ts
CHANGED
|
@@ -1,30 +1,37 @@
|
|
|
1
|
+
/** @deprecated lib/image **/
|
|
1
2
|
interface Point {
|
|
2
3
|
x: number;
|
|
3
4
|
y: number;
|
|
4
5
|
}
|
|
5
6
|
|
|
7
|
+
/** @deprecated lib/image **/
|
|
6
8
|
interface Dimension {
|
|
7
9
|
width: number;
|
|
8
10
|
height: number;
|
|
9
11
|
}
|
|
10
12
|
|
|
13
|
+
/** @deprecated lib/squared **/
|
|
11
14
|
interface KeyValue<T, U> {
|
|
12
15
|
key: T;
|
|
13
16
|
value: U;
|
|
14
17
|
}
|
|
15
18
|
|
|
19
|
+
/** @deprecated lib/node **/
|
|
16
20
|
interface ErrorCode extends Error {
|
|
17
21
|
code?: unknown;
|
|
18
22
|
}
|
|
19
23
|
|
|
24
|
+
/** @deprecated lib/http **/
|
|
20
25
|
interface AuthValue {
|
|
21
26
|
username?: string;
|
|
22
27
|
password?: string;
|
|
23
28
|
}
|
|
24
29
|
|
|
30
|
+
/** @deprecated lib/settings **/
|
|
25
31
|
interface MinMax<T = number> {
|
|
26
32
|
min?: T;
|
|
27
33
|
max?: T;
|
|
28
34
|
}
|
|
29
35
|
|
|
36
|
+
/** @deprecated lib/node **/
|
|
30
37
|
type HighResolutionTime = bigint | [number, number];
|