@e-mc/types 0.13.10 → 0.14.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 +16 -11
- package/constant.d.ts +6 -3
- package/index.d.ts +12 -6
- package/index.js +157 -123
- package/lib/asset.d.ts +9 -7
- package/lib/compress.d.ts +3 -1
- package/lib/core.d.ts +5 -2
- package/lib/document.d.ts +2 -1
- package/lib/dom.d.ts +9 -0
- package/lib/filemanager.d.ts +6 -6
- package/lib/index.d.ts +50 -49
- package/lib/module.d.ts +1 -1
- package/lib/object.d.ts +17 -37
- package/lib/request.d.ts +0 -10
- package/lib/settings.d.ts +16 -14
- package/lib/squared.d.ts +0 -2
- package/lib/type.d.ts +3 -2
- package/package.json +9 -2
package/lib/filemanager.d.ts
CHANGED
|
@@ -36,13 +36,13 @@ export interface InstallData<T extends IModule = IModule, U extends ModuleConstr
|
|
|
36
36
|
params: unknown[];
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export interface IHttpDiskCache<T extends ExternalAsset = ExternalAsset> {
|
|
39
|
+
export interface IHttpDiskCache<T extends IFileManager<U>, U extends ExternalAsset = ExternalAsset> {
|
|
40
40
|
limit: number;
|
|
41
41
|
expires: number;
|
|
42
|
-
readonly host:
|
|
42
|
+
readonly host: T;
|
|
43
43
|
has(uri: string | URL): boolean;
|
|
44
|
-
add<
|
|
45
|
-
within(value:
|
|
44
|
+
add<V extends HttpDiskCacheAddOptions>(uri: string | URL, etag: string, target: Bufferable, options?: V): void;
|
|
45
|
+
within(value: U | number): boolean;
|
|
46
46
|
clear(value?: unknown): void;
|
|
47
47
|
set enabled(value);
|
|
48
48
|
get enabled(): boolean;
|
|
@@ -52,10 +52,10 @@ export interface IHttpDiskCache<T extends ExternalAsset = ExternalAsset> {
|
|
|
52
52
|
get include(): string[];
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
export interface IHttpMemoryCache<T extends ExternalAsset = ExternalAsset> extends IHttpDiskCache<T> {
|
|
55
|
+
export interface IHttpMemoryCache<T extends IFileManager<U>, U extends ExternalAsset = ExternalAsset> extends IHttpDiskCache<T, U> {
|
|
56
56
|
toDisk: [number, number];
|
|
57
57
|
purge(percent?: number, limit?: number): void;
|
|
58
|
-
withinDisk(value:
|
|
58
|
+
withinDisk(value: U | number): boolean;
|
|
59
59
|
clear(uri?: string | URL): void;
|
|
60
60
|
}
|
|
61
61
|
|
package/lib/index.d.ts
CHANGED
|
@@ -15,12 +15,12 @@ import type { ExecCommand, LOG_TYPE, LogArguments, LogComponent, LogDate, LogFai
|
|
|
15
15
|
import type { AsHashOptions, CheckSemVerOptions, CopyDirOptions, CopyDirResult, CopyFileOptions, CreateDirOptions, DeleteFileOptions, DirectoryActionType, FileActionType, FileTypeFormat, GlobDirOptions, MoveFileOptions, PackageVersionOptions, ParseFunctionOptions, PermissionOptions, PermissionType, ProtocolType, ReadBufferOptions, ReadFileCallback, ReadFileOptions, ReadHashOptions, ReadTextOptions, RemoveDirOptions, TempDirOptions, WriteFileOptions } from './module';
|
|
16
16
|
import type { ErrorCode, HighResolutionTime, RequestData, Settings } from './node';
|
|
17
17
|
import type { ApplyOptions, Aria2Options, BufferFormat, DataEncodedResult, DataObjectResult, HeadersOnCallback, HostConfig, IHttpAdapter, OpenOptions, PostFileParts as PostFileParts, PostOptions, ProxySettings, PutOptions, RcloneOptions, ReadExpectType, RequestInit, StatusOnCallback } from './request';
|
|
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';
|
|
18
|
+
import type { ClientModule, CloudAuthSettings, CloudModule, CloudServiceOptions, CompressModule, CompressSettings, DbCoerceSettings, DbModule, DbSettings, DbSourceOptions, DnsLookupSettings, DocumentComponent, DocumentComponentOption, DocumentModule, HandlerSettings, HttpConnectSettings, HttpMemorySettings, ImageModule, ImportModule, 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';
|
|
21
21
|
|
|
22
22
|
import type { SpawnOptions } from 'node:child_process';
|
|
23
|
-
import type { BinaryLike,
|
|
23
|
+
import type { BinaryLike, HashOptions } from 'node:crypto';
|
|
24
24
|
import type { NoParamCallback, WriteStream } from 'node:fs';
|
|
25
25
|
import type { ClientRequest, OutgoingHttpHeaders } from 'node:http';
|
|
26
26
|
import type { LookupFunction } from 'node:net';
|
|
@@ -40,7 +40,6 @@ type BufferView = Bufferable | NodeJS.ArrayBufferView;
|
|
|
40
40
|
type CpuUsage = NodeJS.CpuUsage;
|
|
41
41
|
|
|
42
42
|
declare namespace functions {
|
|
43
|
-
type WatchInstance<T extends ExternalAsset, U extends WatchModule = WatchModule> = IWatch<IFileManager<T>, T, U, ModifiedPostFinalizeListener<T>>;
|
|
44
43
|
type FormatMessageArgs = [type: LogType, title: string, value: LogValue, message: unknown, options: LogMessageOptions];
|
|
45
44
|
|
|
46
45
|
interface IScopeOrigin<T extends IHost = IHost, U extends IModule = IModule> {
|
|
@@ -54,7 +53,7 @@ declare namespace functions {
|
|
|
54
53
|
get settings(): U;
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
interface IExternalFunction<T extends FunctionType<any
|
|
56
|
+
interface IExternalFunction<T extends FunctionType<any>> {
|
|
58
57
|
set extensions(values: unknown[]);
|
|
59
58
|
get extensions(): T[];
|
|
60
59
|
}
|
|
@@ -110,13 +109,13 @@ declare namespace functions {
|
|
|
110
109
|
parseQuality(value: string): QualityData | null;
|
|
111
110
|
parseOpacity(value: string): number;
|
|
112
111
|
parseWorker(command: string | CommandData, outputType?: string): CommandData | null;
|
|
113
|
-
using?(data: IFileThread<V>, command: string): Promise<unknown>;
|
|
112
|
+
using?(data: IFileThread<T, V>, command: string): Promise<unknown>;
|
|
114
113
|
get outputAs(): string;
|
|
115
114
|
set host(value);
|
|
116
115
|
get host(): T | null;
|
|
117
116
|
}
|
|
118
117
|
|
|
119
|
-
interface ImageConstructor<T extends IHost = IHost, U extends ImageModule = ImageModule> extends ClientConstructor, IWorkerConstructor {
|
|
118
|
+
interface ImageConstructor<T extends IHost = IHost, U extends ImageModule = ImageModule, V extends ExternalAsset = ExternalAsset> extends ClientConstructor, IWorkerConstructor {
|
|
120
119
|
readonly MIME_JPEG: string;
|
|
121
120
|
readonly MIME_PNG: string;
|
|
122
121
|
readonly MIME_WEBP: string;
|
|
@@ -124,16 +123,16 @@ declare namespace functions {
|
|
|
124
123
|
readonly MIME_GIF: string;
|
|
125
124
|
readonly MIME_BMP: string;
|
|
126
125
|
readonly MIME_TIFF: string;
|
|
127
|
-
transform<
|
|
126
|
+
transform<W extends TransformOptions>(file: string, command: string, options?: W): Promise<W extends { tempFile: true } ? string : Buffer | null>;
|
|
128
127
|
clamp(value: unknown, min?: number, max?: number): number;
|
|
129
128
|
isBinary(mime: unknown): mime is string;
|
|
130
129
|
toABGR(buffer: Uint8Array | Buffer): Buffer;
|
|
131
|
-
readonly prototype: IImage<T, U>;
|
|
132
|
-
new(module?: U, ...args: unknown[]): IImage<T, U>;
|
|
130
|
+
readonly prototype: IImage<T, U, V>;
|
|
131
|
+
new(module?: U, ...args: unknown[]): IImage<T, U, V>;
|
|
133
132
|
}
|
|
134
133
|
|
|
135
134
|
interface ITask<T extends IHost = IHost, U extends TaskModule = TaskModule, V extends ExternalAsset = ExternalAsset> extends IClient<T, U> {
|
|
136
|
-
using?(data: IFileThread<V>): Promise<unknown>;
|
|
135
|
+
using?(data: IFileThread<T, V>): Promise<unknown>;
|
|
137
136
|
collect?(items: unknown[], preceding?: boolean): Promise<SpawnResult>[];
|
|
138
137
|
map?(tasks: Command[]): Promise<SpawnResult | void>[];
|
|
139
138
|
series?(tasks: Command[]): Promise<unknown>;
|
|
@@ -144,10 +143,10 @@ declare namespace functions {
|
|
|
144
143
|
get host(): T | null;
|
|
145
144
|
}
|
|
146
145
|
|
|
147
|
-
interface TaskConstructor<T extends IHost = IHost, U extends TaskModule = TaskModule> extends ClientConstructor {
|
|
148
|
-
finalize
|
|
149
|
-
readonly prototype: ITask<T, U>;
|
|
150
|
-
new(module?: U, ...args: unknown[]): ITask<T, U>;
|
|
146
|
+
interface TaskConstructor<T extends IHost = IHost, U extends TaskModule = TaskModule, V extends ExternalAsset = ExternalAsset> extends ClientConstructor {
|
|
147
|
+
finalize(this: T, instance: ITask<T, U, V>, assets: V[]): Promise<unknown>;
|
|
148
|
+
readonly prototype: ITask<T, U, V>;
|
|
149
|
+
new(module?: U, ...args: unknown[]): ITask<T, U, V>;
|
|
151
150
|
}
|
|
152
151
|
|
|
153
152
|
interface IDb<T extends IHost = IHost, U extends DbModule = DbModule, V extends DbDataSource = DbDataSource, W extends DbSourceOptions = DbSourceOptions, X extends DbCoerceSettings = DbCoerceSettings> extends IClientDb<T, U, V, W, X> {
|
|
@@ -221,6 +220,8 @@ declare namespace functions {
|
|
|
221
220
|
}
|
|
222
221
|
|
|
223
222
|
interface DbConstructor<T extends IHost = IHost, U extends DbModule = DbModule, V extends DbDataSource = DbDataSource> extends ClientDbConstructor<T> {
|
|
223
|
+
readonly HASH_ALGORITHM: string;
|
|
224
|
+
loadSettings(settings: Settings & { db?: DbSettings }, password?: string): boolean;
|
|
224
225
|
setPoolConfig(value: ObjectMap<PoolConfig>): void;
|
|
225
226
|
getPoolConfig(source: string): Required<PoolConfig> | undefined;
|
|
226
227
|
readonly prototype: IDb<T, U, V>;
|
|
@@ -252,8 +253,8 @@ declare namespace functions {
|
|
|
252
253
|
settingsOf(service: string, name: "cache"): unknown;
|
|
253
254
|
settingsOf(service: string, name: "coerce", component: keyof DbCoerceSettings): unknown;
|
|
254
255
|
settingsOf(service: string, name: "auth", component: keyof CloudAuthSettings): unknown;
|
|
255
|
-
getUploadHandler(service: string, credential: unknown):
|
|
256
|
-
getDownloadHandler(service: string, credential: unknown):
|
|
256
|
+
getUploadHandler(service: string, credential: unknown): FunctionReturn<void>;
|
|
257
|
+
getDownloadHandler(service: string, credential: unknown): FunctionReturn<void>;
|
|
257
258
|
resolveService(service: string, folder?: string): string;
|
|
258
259
|
set host(value);
|
|
259
260
|
get host(): T | null;
|
|
@@ -279,7 +280,7 @@ declare namespace functions {
|
|
|
279
280
|
new(module?: U, database?: CloudDatabase[], ...args: unknown[]): ICloud<T, U, V>;
|
|
280
281
|
}
|
|
281
282
|
|
|
282
|
-
interface IDocument<T extends IFileManager<U>, U extends ExternalAsset = ExternalAsset, V extends ClientModule = DocumentModule, W extends DocumentComponent = DocumentComponent, X extends DocumentComponentOption = DocumentComponentOption, Y extends ICloud = ICloud<T
|
|
283
|
+
interface IDocument<T extends IFileManager<U>, U extends ExternalAsset = ExternalAsset, V extends ClientModule = DocumentModule, W extends DocumentComponent = DocumentComponent, X extends DocumentComponentOption = DocumentComponentOption, Y extends ICloud = ICloud<T>, Z extends FunctionReturn<any> = TransformCallback<T, U>> extends IClient<T, V, Z> {
|
|
283
284
|
Db: IDb | null;
|
|
284
285
|
assets: U[];
|
|
285
286
|
config: StandardMap;
|
|
@@ -290,11 +291,11 @@ declare namespace functions {
|
|
|
290
291
|
asSourceFile(value: string, cache: boolean): unknown;
|
|
291
292
|
asSourceFile(value: string, options?: AsSourceFileOptions): unknown;
|
|
292
293
|
findVersion(name: string | string[], fallback?: string): string;
|
|
293
|
-
findSourceScope(uri: string, imports:
|
|
294
|
-
findSourceRoot(uri: string, imports?:
|
|
294
|
+
findSourceScope(uri: string, imports: ImportModule): StringMap[];
|
|
295
|
+
findSourceRoot(uri: string, imports?: ImportModule): string | undefined;
|
|
295
296
|
resolveDir(name: string, ...paths: string[]): string | undefined;
|
|
296
|
-
locateSourceFiles(file: U, code?: string, bundleContent?: string[]): (imports?:
|
|
297
|
-
resolveSourceFile(file: U): (code?: string, imports?:
|
|
297
|
+
locateSourceFiles(file: U, code?: string, bundleContent?: string[]): (imports?: ImportModule) => SourceInput | undefined;
|
|
298
|
+
resolveSourceFile(file: U): (code?: string, imports?: ImportModule) => SourceInput<string> | undefined;
|
|
298
299
|
tryParse(source: string, format: string, options?: PlainObject): unknown;
|
|
299
300
|
forDb(item: DataSource): boolean;
|
|
300
301
|
hasEval(name: string): boolean;
|
|
@@ -304,7 +305,7 @@ declare namespace functions {
|
|
|
304
305
|
abort(err: Error): void;
|
|
305
306
|
abort(name?: keyof W, reason?: unknown): void;
|
|
306
307
|
restart(): void;
|
|
307
|
-
using?(data: IFileThread<U>): Promise<unknown>;
|
|
308
|
+
using?(data: IFileThread<T, U>): Promise<unknown>;
|
|
308
309
|
setLocalUri?(file: U, replace?: boolean): void;
|
|
309
310
|
resolveUri?(file: U, source: string): string;
|
|
310
311
|
resolveUri?(file: U, source: string, trailing: string): [string, string];
|
|
@@ -321,7 +322,7 @@ declare namespace functions {
|
|
|
321
322
|
set dataSource(value: DataSource[]);
|
|
322
323
|
get dataSource(): DataSource[];
|
|
323
324
|
set imports(value);
|
|
324
|
-
get imports():
|
|
325
|
+
get imports(): ImportModule;
|
|
325
326
|
get watching(): boolean;
|
|
326
327
|
set host(value);
|
|
327
328
|
get host(): T | null;
|
|
@@ -333,9 +334,9 @@ declare namespace functions {
|
|
|
333
334
|
createSourceMap(code: string, uri?: string, remove?: boolean): SourceMap;
|
|
334
335
|
writeSourceMap(uri: string, data: SourceCode, options?: SourceMapOptions): string | undefined;
|
|
335
336
|
/** @deprecated */
|
|
336
|
-
updateGradle(source: string, namespaces: string[], value: string, upgrade: boolean): string;
|
|
337
|
+
updateGradle(source: string, namespaces: (string | RegExp)[], value: string | string[], upgrade: boolean): string;
|
|
337
338
|
/** @deprecated */
|
|
338
|
-
updateGradle(source: string, namespaces: string[], value: string, options?: UpdateGradleOptions): string;
|
|
339
|
+
updateGradle(source: string, namespaces: (string | RegExp)[], value: string | string[], options?: UpdateGradleOptions): string;
|
|
339
340
|
generateLintTable(messages: LintMessage[], options: GenerateLintTableOptions): LogComponent[];
|
|
340
341
|
cleanup?(this: T, instance: IDocument<T, U, V, W, X, Y>): Promise<unknown>;
|
|
341
342
|
sanitizeAssets?(assets: U[], exclusions?: unknown[]): U[];
|
|
@@ -343,7 +344,7 @@ declare namespace functions {
|
|
|
343
344
|
new(module?: V, ...args: unknown[]): IDocument<T, U, V, W, X, Y>;
|
|
344
345
|
}
|
|
345
346
|
|
|
346
|
-
interface IWatch<T extends IFileManager<U>, U extends ExternalAsset = ExternalAsset, V extends WatchModule = WatchModule, W extends
|
|
347
|
+
interface IWatch<T extends IFileManager<U>, U extends ExternalAsset = ExternalAsset, V extends WatchModule = WatchModule, W extends FunctionReturn<PostFinalizeCallback> = ModifiedPostFinalizeListener<U>> extends IClient<T, V, W> {
|
|
347
348
|
connectTimeout: number;
|
|
348
349
|
init(config?: HostInitConfig): this;
|
|
349
350
|
start(assets: U[], permission?: IPermission | null): void;
|
|
@@ -354,8 +355,8 @@ declare namespace functions {
|
|
|
354
355
|
setSSLCert(value: string): boolean;
|
|
355
356
|
hasSecureProtocol(): boolean;
|
|
356
357
|
getRecursiveFiles(watch: IFileGroup<U>): [string, string[]][];
|
|
357
|
-
whenModified?(assets: U[], postFinalize: PostFinalizeCallback):
|
|
358
|
-
whenModified?(assets: U[], sanitize?: boolean, postFinalize?: PostFinalizeCallback):
|
|
358
|
+
whenModified?(assets: U[], postFinalize: PostFinalizeCallback): T;
|
|
359
|
+
whenModified?(assets: U[], sanitize?: boolean, postFinalize?: PostFinalizeCallback): T;
|
|
359
360
|
set assets(value: U[]);
|
|
360
361
|
get assets(): U[];
|
|
361
362
|
set interval(value);
|
|
@@ -368,7 +369,7 @@ declare namespace functions {
|
|
|
368
369
|
get host(): T | null;
|
|
369
370
|
}
|
|
370
371
|
|
|
371
|
-
interface WatchConstructor<T extends IFileManager<U>, U extends ExternalAsset = ExternalAsset, V extends WatchModule = WatchModule, W extends
|
|
372
|
+
interface WatchConstructor<T extends IFileManager<U>, U extends ExternalAsset = ExternalAsset, V extends WatchModule = WatchModule, W extends FunctionReturn<PostFinalizeCallback> = ModifiedPostFinalizeListener<U>> extends ClientConstructor {
|
|
372
373
|
createServer(port: number, active: boolean): ws.Server | null;
|
|
373
374
|
createServer(port: number, secure?: SecureOptions | null, active?: boolean): ws.Server | null;
|
|
374
375
|
shutdown(): void;
|
|
@@ -448,11 +449,11 @@ declare namespace functions {
|
|
|
448
449
|
interface IFileManager<T extends ExternalAsset = ExternalAsset> extends IHost, Set<string> {
|
|
449
450
|
processTimeout: number;
|
|
450
451
|
Request: IRequest;
|
|
451
|
-
Document: InstallData<IDocument<
|
|
452
|
+
Document: InstallData<IDocument<IFileManager<T>, T>, DocumentConstructor<IFileManager<T>, T>>[];
|
|
452
453
|
Task: InstallData<ITask, TaskConstructor>[];
|
|
453
454
|
Image: ImageMimeMap | null;
|
|
454
455
|
Cloud: ICloud | null;
|
|
455
|
-
Watch:
|
|
456
|
+
Watch: IWatch<this, T> | null;
|
|
456
457
|
Compress: ICompress | null;
|
|
457
458
|
readonly documentAssets: T[];
|
|
458
459
|
readonly taskAssets: Array<T & Required<TaskAction>>;
|
|
@@ -463,12 +464,12 @@ declare namespace functions {
|
|
|
463
464
|
readonly filesToCompare: Map<T, string[]>;
|
|
464
465
|
readonly contentToAppend: Map<string, string[]>;
|
|
465
466
|
readonly contentToReplace: Map<string, string[]>;
|
|
466
|
-
readonly processing: IFileThread<T>[];
|
|
467
|
+
readonly processing: IFileThread<IHost, T>[];
|
|
467
468
|
readonly fetchedAssets: T[];
|
|
468
469
|
readonly copiedAssets: T[];
|
|
469
470
|
readonly emptyDir: Set<string>;
|
|
470
|
-
readonly cacheToDisk: IHttpDiskCache<T>;
|
|
471
|
-
readonly cacheToMemory: IHttpMemoryCache<T>;
|
|
471
|
+
readonly cacheToDisk: IHttpDiskCache<this, T>;
|
|
472
|
+
readonly cacheToMemory: IHttpMemoryCache<this, T>;
|
|
472
473
|
install(name: "document", handler: string, module?: DocumentModule, ...args: unknown[]): IDocument<this, T> | undefined;
|
|
473
474
|
install(name: "document", target: DocumentConstructor<this, T>, module?: DocumentModule, ...args: unknown[]): IDocument<this, T> | undefined;
|
|
474
475
|
install(name: "task", handler: string, module?: TaskModule, ...args: unknown[]): ITask | undefined;
|
|
@@ -478,9 +479,9 @@ declare namespace functions {
|
|
|
478
479
|
install(name: "image", handler: string, module?: ImageModule, ...args: unknown[]): IImage | undefined;
|
|
479
480
|
install(name: "image", target: ImageConstructor, module?: ImageModule, ...args: unknown[]): IImage | undefined;
|
|
480
481
|
install(name: "image", targets: Map<string, ImageConstructor>, module?: ImageModule): void;
|
|
481
|
-
install(name: "watch", handler: string, module?: WatchModule, ...args: unknown[]):
|
|
482
|
-
install(name: "watch", target: WatchConstructor<this, T>, module?: WatchModule, ...args: unknown[]):
|
|
483
|
-
install(name: "watch", module: WatchModule):
|
|
482
|
+
install(name: "watch", handler: string, module?: WatchModule, ...args: unknown[]): IWatch<this, T> | undefined;
|
|
483
|
+
install(name: "watch", target: WatchConstructor<this, T>, module?: WatchModule, ...args: unknown[]): IWatch<this, T> | undefined;
|
|
484
|
+
install(name: "watch", module: WatchModule): IWatch<this, T> | undefined;
|
|
484
485
|
install(name: "compress", module?: CompressModule): ICompress | undefined;
|
|
485
486
|
install<U extends IModule>(name: string, ...args: unknown[]): U | undefined;
|
|
486
487
|
using(...items: FirstOf<T>): this;
|
|
@@ -502,14 +503,14 @@ declare namespace functions {
|
|
|
502
503
|
setLocalUri(file: T, replace?: boolean): FileOutput;
|
|
503
504
|
getLocalUri(data: FileData<T>): string;
|
|
504
505
|
getMimeType(data: FileData<T>): string;
|
|
505
|
-
openThread(instance: IModule, data: IFileThread<T>, timeout?: number): boolean;
|
|
506
|
-
closeThread(instance: IModule | null, data: IFileThread<T>, callback?: FunctionType<void>): boolean;
|
|
506
|
+
openThread(instance: IModule, data: IFileThread<IHost, T>, timeout?: number): boolean;
|
|
507
|
+
closeThread(instance: IModule | null, data: IFileThread<IHost, T>, callback?: FunctionType<void>): boolean;
|
|
507
508
|
addProcessTimeout(instance: IModule, file: T, timeout: number): void;
|
|
508
509
|
removeProcessTimeout(instance: IModule, file: T): void;
|
|
509
510
|
getProcessTimeout(handler: InstallData): number;
|
|
510
511
|
clearProcessTimeout(): void;
|
|
511
512
|
scheduleTask(uri: string | URL, data: unknown, priority: number): Promise<unknown>;
|
|
512
|
-
scheduleTask(uri: string | URL, data: unknown, thenCallback?:
|
|
513
|
+
scheduleTask(uri: string | URL, data: unknown, thenCallback?: FunctionReturn, catchCallback?: FunctionReturn, priority?: number): Promise<unknown>;
|
|
513
514
|
setTaskLimit(value: number): void;
|
|
514
515
|
addDownload(value: number | Bufferable, encoding: BufferEncoding): number;
|
|
515
516
|
addDownload(value: number | Bufferable, type?: number | BufferEncoding, encoding?: BufferEncoding): number;
|
|
@@ -517,7 +518,7 @@ declare namespace functions {
|
|
|
517
518
|
checkHash(checksum: ChecksumValue, options: CheckHashOptions): boolean;
|
|
518
519
|
checkHash(checksum: ChecksumValue, data: Optional<Bufferable>, uri: string | URL | undefined): boolean;
|
|
519
520
|
checkHash(checksum: ChecksumValue, data: Bufferable, options?: CheckHashOptions): boolean;
|
|
520
|
-
transformAsset(data: IFileThread<T>, parent?: T, override?: boolean): Promise<boolean>;
|
|
521
|
+
transformAsset(data: IFileThread<IHost, T>, parent?: T, override?: boolean): Promise<boolean>;
|
|
521
522
|
addCopy(data: FileCommand<T>, saveAs?: string, replace?: boolean): string | undefined;
|
|
522
523
|
handleFilePermission(file: T): void;
|
|
523
524
|
findMime(file: T, rename?: boolean): Promise<string>;
|
|
@@ -614,24 +615,24 @@ declare namespace functions {
|
|
|
614
615
|
emit(event: "asset:permission", file: T): boolean;
|
|
615
616
|
}
|
|
616
617
|
|
|
617
|
-
interface FileManagerConstructor<T extends ExternalAsset> extends HostConstructor {
|
|
618
|
+
interface FileManagerConstructor<T extends IFileManager<U>, U extends ExternalAsset> extends HostConstructor {
|
|
618
619
|
purgeMemory(percent?: number, limit?: number | boolean, parent?: number | boolean): Promise<number>;
|
|
619
620
|
loadSettings(settings: Settings, password?: string): boolean;
|
|
620
621
|
loadSettings(settings: Settings, permission?: PermissionReadWrite, password?: string): boolean;
|
|
621
|
-
sanitizeAssets(assets:
|
|
622
|
+
sanitizeAssets(assets: U[], exclusions?: string[]): U[];
|
|
622
623
|
writeChecksum(root: string, options: ChecksumOptions): Promise<string[]>;
|
|
623
624
|
writeChecksum(root: string, to?: string | ChecksumOptions, options?: ChecksumOptions): Promise<string[] | null>;
|
|
624
625
|
verifyChecksum(root: string, options: ChecksumOptions): Promise<[string[], string[], number] | null>;
|
|
625
626
|
verifyChecksum(root: string, from?: string | ChecksumOptions, options?: ChecksumOptions): Promise<[string[], string[], number] | null>;
|
|
626
|
-
createFileThread(host:
|
|
627
|
+
createFileThread(host: T, file: U): IFileThread<T, U>;
|
|
627
628
|
setTimeout(options: ObjectMap<number | string>): void;
|
|
628
629
|
defineHttpCache(options: HttpMemorySettings, disk?: boolean): void;
|
|
629
630
|
defineHttpConnect(options: HttpConnectSettings): void;
|
|
630
631
|
defineHttpAdapter(module: unknown): void;
|
|
631
632
|
generateSessionId(): string;
|
|
632
|
-
readonly prototype:
|
|
633
|
-
new(baseDirectory: string, config: RequestData<
|
|
634
|
-
new(baseDirectory: string, config: RequestData<
|
|
633
|
+
readonly prototype: T;
|
|
634
|
+
new(baseDirectory: string, config: RequestData<U>, postFinalize?: PostFinalizeCallback): T;
|
|
635
|
+
new(baseDirectory: string, config: RequestData<U>, permission?: IPermission | null, postFinalize?: PostFinalizeCallback): T;
|
|
635
636
|
}
|
|
636
637
|
|
|
637
638
|
interface IHost extends IModule {
|
|
@@ -640,7 +641,7 @@ declare namespace functions {
|
|
|
640
641
|
readonly subProcesses: Set<IModule>;
|
|
641
642
|
readonly startTime: number;
|
|
642
643
|
using(...items: FirstOf<unknown>): this;
|
|
643
|
-
contains(item: unknown, condition?:
|
|
644
|
+
contains(item: unknown, condition?: FunctionReturn<boolean>): boolean;
|
|
644
645
|
find(name: string): IModule | undefined;
|
|
645
646
|
findAll(name: string): IModule[];
|
|
646
647
|
willLog(name: string): boolean;
|
|
@@ -851,7 +852,7 @@ declare namespace functions {
|
|
|
851
852
|
asString(value: unknown, cacheKey?: boolean | "throws"): string;
|
|
852
853
|
asHash(data: BinaryLike, options?: AsHashOptions): string;
|
|
853
854
|
asHash(data: BinaryLike, algorithm?: string, options?: HashOptions): string;
|
|
854
|
-
asHash(data: BinaryLike, algorithm?: string, encoding?:
|
|
855
|
+
asHash(data: BinaryLike, algorithm?: string, encoding?: BufferEncoding): string;
|
|
855
856
|
readHash(value: string | URL, options?: ReadHashOptions): Promise<string>;
|
|
856
857
|
toPosix(value: unknown, normalize: boolean): string;
|
|
857
858
|
toPosix(value: unknown, filename?: string, normalize?: boolean): string;
|
package/lib/module.d.ts
CHANGED
|
@@ -132,7 +132,7 @@ export interface ReadBufferOptions extends StreamBase, EncodingAction {
|
|
|
132
132
|
cache?: boolean;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
export interface AsHashOptions extends HashOptions, ChecksumBase {}
|
|
135
|
+
export interface AsHashOptions extends HashOptions, ChecksumBase<BufferEncoding> {}
|
|
136
136
|
|
|
137
137
|
export interface TempDirOptions {
|
|
138
138
|
pathname?: string;
|
package/lib/object.d.ts
CHANGED
|
@@ -1,41 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
interface ErrorConstructor {
|
|
2
|
+
/**
|
|
3
|
+
* Indicates whether the argument provided is a built-in Error instance or not.
|
|
4
|
+
*/
|
|
5
|
+
isError(error: unknown): error is Error;
|
|
5
6
|
}
|
|
6
7
|
|
|
7
|
-
/** @deprecated lib/image **/
|
|
8
|
-
interface Dimension {
|
|
9
|
-
width: number;
|
|
10
|
-
height: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/** @deprecated lib/squared **/
|
|
14
|
-
interface KeyValue<T, U> {
|
|
15
|
-
key: T;
|
|
16
|
-
value: U;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** @deprecated lib/node **/
|
|
20
|
-
interface ErrorCode extends Error {
|
|
21
|
-
code?: unknown;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** @deprecated lib/http **/
|
|
25
|
-
interface AuthValue {
|
|
26
|
-
username?: string;
|
|
27
|
-
password?: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** @deprecated lib/settings **/
|
|
31
|
-
interface MinMax<T = number> {
|
|
32
|
-
min?: T;
|
|
33
|
-
max?: T;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** @deprecated lib/node **/
|
|
37
|
-
type HighResolutionTime = bigint | [number, number];
|
|
38
|
-
|
|
39
8
|
interface RegExpConstructor {
|
|
40
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Escapes any RegExp syntax characters in the input string, returning a
|
|
11
|
+
* new string that can be safely interpolated into a RegExp as a literal
|
|
12
|
+
* string to match.
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const regExp = new RegExp(RegExp.escape("foo.bar"));
|
|
16
|
+
* regExp.test("foo.bar"); // true
|
|
17
|
+
* regExp.test("foo!bar"); // false
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
escape(string: string): string;
|
|
41
21
|
}
|
package/lib/request.d.ts
CHANGED
|
@@ -38,16 +38,6 @@ export interface IHttpHost {
|
|
|
38
38
|
success(version: HttpProtocolVersion, status?: boolean): number;
|
|
39
39
|
failed(version: HttpProtocolVersion, status?: boolean): number;
|
|
40
40
|
error(version: HttpProtocolVersion, status?: boolean): number;
|
|
41
|
-
/** @deprecated altSvc.did */
|
|
42
|
-
didAltSvc(version: HttpProtocolVersion): boolean;
|
|
43
|
-
/** @deprecated altSvc.next */
|
|
44
|
-
nextAltSvc(): boolean;
|
|
45
|
-
/** @deprecated altSvc.close */
|
|
46
|
-
closeAltSvc(error?: boolean): boolean;
|
|
47
|
-
/** @deprecated altSvc.clear */
|
|
48
|
-
clearAltSvc(version?: HttpProtocolVersion): void;
|
|
49
|
-
/** @deprecated altSvc.flag */
|
|
50
|
-
flagAltSvc(version: HttpProtocolVersion, value: number): void;
|
|
51
41
|
reset(): void;
|
|
52
42
|
v1(): boolean;
|
|
53
43
|
v2(): boolean;
|
package/lib/settings.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { HashAlgorithm } from './asset';
|
|
|
4
4
|
import type { CloudSource } from './cloud';
|
|
5
5
|
import type { PermissionAction, PermissionReadWrite, PermittedDirectories } from './core';
|
|
6
6
|
import type { DbSource, TimeoutAction } from './db';
|
|
7
|
+
import type { ImportMap } from './document';
|
|
7
8
|
import type { AuthValue, HttpOutgoingHeaders, SecureConfig, ServerPort } from './http';
|
|
8
9
|
import type { BackgroundColor, BroadcastOutMethod, ErrorOutMethod, ForegroundColor, LoggerColor, LoggerStatus, TextAlign, TextWrapStyle } from './logger';
|
|
9
10
|
import type { ExecAction, IncludeAction } from './module';
|
|
@@ -12,7 +13,7 @@ import type { SpawnOptions } from 'node:child_process';
|
|
|
12
13
|
import type { BinaryLike, CipherGCMTypes } from 'node:crypto';
|
|
13
14
|
import type { LookupAddress } from 'node:dns';
|
|
14
15
|
import type { AgentOptions } from 'node:http';
|
|
15
|
-
import type { BrotliOptions, ZlibOptions } from 'node:zlib';
|
|
16
|
+
import type { BrotliOptions, ZlibOptions, ZstdOptions } from 'node:zlib';
|
|
16
17
|
// @ts-ignore
|
|
17
18
|
import type { BackgroundColor as IBackgroundColor } from 'chalk';
|
|
18
19
|
// @ts-ignore
|
|
@@ -20,8 +21,6 @@ import type { Unit } from 'bytes';
|
|
|
20
21
|
// @ts-ignore
|
|
21
22
|
import type { MinimatchOptions } from 'minimatch';
|
|
22
23
|
// @ts-ignore
|
|
23
|
-
import type { Options as ZopfliOptions } from 'node-zopfli';
|
|
24
|
-
// @ts-ignore
|
|
25
24
|
import type { PicomatchOptions } from 'picomatch';
|
|
26
25
|
|
|
27
26
|
export interface DownloadAction {
|
|
@@ -143,8 +142,11 @@ export interface DownloadModule<T = PlainObject> extends HandlerSettings<T>, Exp
|
|
|
143
142
|
csv?: boolean;
|
|
144
143
|
differ?: string;
|
|
145
144
|
error?: string;
|
|
146
|
-
|
|
145
|
+
format?: string;
|
|
146
|
+
separator?: string;
|
|
147
|
+
timeformat?: string;
|
|
147
148
|
hash: "md5" | "SHA-1" | "DropboxHash";
|
|
149
|
+
cutoff_mode?: "HARD" | "SOFT" | "CAUTIOUS";
|
|
148
150
|
ignore_case_sync?: boolean;
|
|
149
151
|
ignore_checksum?: boolean;
|
|
150
152
|
ignore_existing?: boolean;
|
|
@@ -165,6 +167,7 @@ export interface DownloadModule<T = PlainObject> extends HandlerSettings<T>, Exp
|
|
|
165
167
|
no_traverse?: boolean;
|
|
166
168
|
no_update_dir_modtime?: boolean;
|
|
167
169
|
no_update_modtime?: boolean;
|
|
170
|
+
order_by?: string;
|
|
168
171
|
refresh_times?: boolean;
|
|
169
172
|
size_only?: boolean;
|
|
170
173
|
streaming_upload_cutoff?: string;
|
|
@@ -183,7 +186,7 @@ export interface DownloadModule<T = PlainObject> extends HandlerSettings<T>, Exp
|
|
|
183
186
|
|
|
184
187
|
export interface DocumentModule<T = DocumentSettings, U = DbSettings> extends ClientModule<T> {
|
|
185
188
|
eval?: DocumentEval;
|
|
186
|
-
imports?:
|
|
189
|
+
imports?: ImportModule;
|
|
187
190
|
versions?: StringMap;
|
|
188
191
|
format?: AnyObject;
|
|
189
192
|
db?: DbModule<U>;
|
|
@@ -194,11 +197,11 @@ export interface DocumentEval {
|
|
|
194
197
|
absolute?: boolean;
|
|
195
198
|
}
|
|
196
199
|
|
|
197
|
-
export interface DocumentGroup<T = { imports?:
|
|
200
|
+
export interface DocumentGroup<T = { imports?: ImportModule } & AnyObject, U = AnyObject> {
|
|
198
201
|
transform?: T;
|
|
199
202
|
view_engine?: U;
|
|
200
203
|
pages?: ObjectMap<AnyObject>;
|
|
201
|
-
imports?:
|
|
204
|
+
imports?: ImportModule;
|
|
202
205
|
}
|
|
203
206
|
|
|
204
207
|
export interface DocumentUserSettings<T = AnyObject, U = T> extends DocumentGroup<T, U>, PlainObject {
|
|
@@ -232,7 +235,8 @@ export type DocumentComponentOptions = DocumentComponent<DocumentComponentOption
|
|
|
232
235
|
export interface ClientDbSettings<T = PlainObject> extends ClientSettings<T>, PurgeAction {
|
|
233
236
|
session_expires?: number | string;
|
|
234
237
|
user_key?: ObjectMap<DbSourceOptions>;
|
|
235
|
-
imports?:
|
|
238
|
+
imports?: ImportModule;
|
|
239
|
+
cache?: { dir?: string; algorithm?: string };
|
|
236
240
|
}
|
|
237
241
|
|
|
238
242
|
export interface MemoryModule<T = MemorySettings> extends HandlerSettings<T>, Record<string, T | ObjectMap<PurgeBase> | undefined> {}
|
|
@@ -363,8 +367,7 @@ export interface WatchSettings<T = WatchUserSettings> extends ClientSettings<Obj
|
|
|
363
367
|
export interface CompressModule<U = CompressSettings> extends HandlerSettings<U> {
|
|
364
368
|
gzip?: ZlibOptions;
|
|
365
369
|
brotli?: BrotliOptions;
|
|
366
|
-
|
|
367
|
-
zopfli?: ZopfliOptions;
|
|
370
|
+
zstd?: ZstdOptions;
|
|
368
371
|
}
|
|
369
372
|
|
|
370
373
|
export interface CompressSettings extends PlainObject {
|
|
@@ -373,8 +376,7 @@ export interface CompressSettings extends PlainObject {
|
|
|
373
376
|
cache_expires?: number | string;
|
|
374
377
|
gzip_level?: number | string;
|
|
375
378
|
brotli_quality?: number | string;
|
|
376
|
-
|
|
377
|
-
zopfli_iterations?: number | string;
|
|
379
|
+
zstd_compression_level?: number | string;
|
|
378
380
|
chunk_size?: number | string;
|
|
379
381
|
}
|
|
380
382
|
|
|
@@ -403,8 +405,6 @@ export interface ErrorModule<T = ErrorSettings> extends HandlerModule<T, ErrorOu
|
|
|
403
405
|
out?: string | ErrorOutMethod;
|
|
404
406
|
abort?: string[];
|
|
405
407
|
fatal?: boolean;
|
|
406
|
-
/** @deprecated retry_limit */
|
|
407
|
-
recursion_limit?: number | string;
|
|
408
408
|
retry_limit?: number | string;
|
|
409
409
|
}
|
|
410
410
|
|
|
@@ -446,6 +446,7 @@ export interface LoggerModule<T = number | string, U = boolean | T, V = LoggerFo
|
|
|
446
446
|
file?: boolean | LoggerColor;
|
|
447
447
|
cloud?: boolean | LoggerColor;
|
|
448
448
|
db?: boolean | LoggerColor;
|
|
449
|
+
user?: boolean | LoggerColor;
|
|
449
450
|
time_elapsed?: boolean | LoggerColor;
|
|
450
451
|
time_process?: boolean | LoggerColor;
|
|
451
452
|
exec?: boolean | LoggerColor;
|
|
@@ -580,6 +581,7 @@ export interface MinMax<T = number> {
|
|
|
580
581
|
max?: T;
|
|
581
582
|
}
|
|
582
583
|
|
|
584
|
+
export type ImportModule = ImportMap & StringMap;
|
|
583
585
|
export type WatchUserSettings = ObjectMap<WatchInterval>;
|
|
584
586
|
export type DocumentTransform = boolean | "etag" | HashAlgorithm | HashConfig | null;
|
|
585
587
|
|
package/lib/squared.d.ts
CHANGED
package/lib/type.d.ts
CHANGED
|
@@ -8,8 +8,9 @@ type MapOfType<T, U = any, V = any> = { [K in KeyOfType<T, U, V>]: K extends U ?
|
|
|
8
8
|
type Constructor<out T> = new(...args: any[]) => T;
|
|
9
9
|
type ConstructorDerived<T> = Pick<T, { [K in keyof T]: T[K] extends new() => any ? never : K }[keyof T]>;
|
|
10
10
|
|
|
11
|
-
type FunctionType<T = unknown, U = unknown> = (...args: U[]) => T;
|
|
12
|
-
type
|
|
11
|
+
type FunctionType<out T = unknown, in U = unknown> = (...args: U[]) => T;
|
|
12
|
+
type FunctionReturn<out T = unknown, in U = any> = (...args: U[]) => T;
|
|
13
|
+
type FunctionArgs<in T extends unknown[], out U = unknown> = (...args: T) => U;
|
|
13
14
|
|
|
14
15
|
type IntBool = boolean | 0 | 1;
|
|
15
16
|
type ArrayOf<T> = T | T[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Type definitions for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -23,6 +23,13 @@
|
|
|
23
23
|
"chalk": "4.1.2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"typescript": "
|
|
26
|
+
"typescript": "6.0.3"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@types/bytes": "*",
|
|
30
|
+
"@types/picomatch": "*",
|
|
31
|
+
"@types/ws": "*",
|
|
32
|
+
"file-type": "*",
|
|
33
|
+
"minimatch": "*"
|
|
27
34
|
}
|
|
28
35
|
}
|