@e-mc/types 0.8.3 → 0.8.5
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 +4 -8
- package/README.md +4 -4
- package/constant.d.ts +4 -1
- package/index.d.ts +1 -0
- package/index.js +34 -3
- package/lib/index.d.ts +15 -13
- package/lib/logger.d.ts +0 -1
- package/lib/request.d.ts +2 -1
- package/lib/settings.d.ts +2 -2
- package/lib/type.d.ts +1 -1
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
Copyright
|
|
1
|
+
Copyright 2024 Mile Square Park
|
|
2
2
|
|
|
3
|
-
|
|
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
4
|
|
|
5
|
-
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
10
|
-
|
|
11
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
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
package/constant.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const enum INTERNAL {
|
|
2
|
-
VERSION = '0.8.
|
|
2
|
+
VERSION = '0.8.5',
|
|
3
3
|
TEMP_DIR = 'tmp', // eslint-disable-line @typescript-eslint/no-shadow
|
|
4
4
|
CJS = '__cjs__'
|
|
5
5
|
}
|
|
@@ -187,11 +187,13 @@ export const enum TIME {
|
|
|
187
187
|
|
|
188
188
|
export const enum PACKAGE_NAME {
|
|
189
189
|
CLOUD = '@e-mc/cloud',
|
|
190
|
+
CLOUD_UTIL = '@e-mc/cloud/util',
|
|
190
191
|
COMPAT_V4 = '@e-mc/compat-v4',
|
|
191
192
|
COMPRESS = '@e-mc/compress',
|
|
192
193
|
CORE = '@e-mc/core',
|
|
193
194
|
DB = '@e-mc/db',
|
|
194
195
|
DB_POOL = '@e-mc/db/pool',
|
|
196
|
+
DB_UTIL = '@e-mc/db/util',
|
|
195
197
|
DOCUMENT = '@e-mc/document',
|
|
196
198
|
DOCUMENT_ANDROID = '@pi-r/android',
|
|
197
199
|
DOCUMENT_CHROME = '@pi-r/chrome',
|
|
@@ -204,6 +206,7 @@ export const enum PACKAGE_NAME {
|
|
|
204
206
|
MODULE_LIB_V4 = '@e-mc/module/lib-v4',
|
|
205
207
|
REQUEST = '@e-mc/request',
|
|
206
208
|
REQUEST_HTTP_HOST = '@e-mc/request/http/host',
|
|
209
|
+
REQUEST_UTIL = '@e-mc/request/util',
|
|
207
210
|
TASK = '@e-mc/task',
|
|
208
211
|
TASK_GULP = '@pi-r/gulp',
|
|
209
212
|
TYPES = '@e-mc/types',
|
package/index.d.ts
CHANGED
|
@@ -276,6 +276,7 @@ declare namespace types {
|
|
|
276
276
|
function renameExt(value: string, ext: string, when?: string): string;
|
|
277
277
|
function formatSize(value: string): number;
|
|
278
278
|
function formatSize(value: number, options?: BytesOptions): string;
|
|
279
|
+
function alignSize(value: unknown, kb?: number, factor?: number): number;
|
|
279
280
|
function cascadeObject<T = unknown>(data: object, query: string, fallback?: unknown): T;
|
|
280
281
|
function cloneObject<T>(data: T, deep: boolean): T;
|
|
281
282
|
function cloneObject<T>(data: T, deepIgnore: WeakSet<object>): T;
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.generateUUID = exports.incrementUUID = exports.purgeMemory = exports.errorMessage = void 0;
|
|
3
|
+
exports.validateUUID = exports.randomString = exports.decryptUTF8 = exports.encryptUTF8 = exports.getEncoding = exports.asFunction = exports.coerceObject = exports.cloneObject = exports.cascadeObject = exports.alignSize = exports.formatSize = exports.renameExt = exports.escapePattern = exports.hasGlob = exports.convertTime = exports.formatTime = exports.parseExpires = exports.parseTime = exports.isEmpty = exports.isString = exports.isObject = exports.isPlainObject = exports.isArray = exports.setTempDir = exports.getTempDir = exports.setLogCurrent = exports.getLogCurrent = exports.existsFlag = exports.mainFlag = exports.processFlag = exports.modifiedFlag = exports.watchFlag = exports.usingFlag = exports.cloneFlag = exports.ignoreFlag = exports.hasBit = exports.createAbortError = exports.IMPORT_MAP = exports.THRESHOLD = exports.READDIR_SORT = exports.WATCH_EVENT = exports.DB_TRANSACTION = exports.DB_TYPE = exports.FETCH_TYPE = exports.DOWNLOAD_TYPE = exports.ERR_CODE = exports.ASSET_FLAG = exports.FILE_TYPE = exports.STATUS_TYPE = exports.LOG_TYPE = void 0;
|
|
4
|
+
exports.generateUUID = exports.incrementUUID = exports.purgeMemory = exports.errorMessage = exports.errorValue = void 0;
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const fs = require("fs");
|
|
7
7
|
const crypto = require("crypto");
|
|
@@ -571,9 +571,40 @@ function renameExt(value, ext, when) {
|
|
|
571
571
|
}
|
|
572
572
|
exports.renameExt = renameExt;
|
|
573
573
|
function formatSize(value, options) {
|
|
574
|
-
|
|
574
|
+
if (typeof value === 'number') {
|
|
575
|
+
return (bytes(value, options) || ('0' + (options?.unitSeparator || '') + 'B'));
|
|
576
|
+
}
|
|
577
|
+
return (bytes(value) || 0);
|
|
575
578
|
}
|
|
576
579
|
exports.formatSize = formatSize;
|
|
580
|
+
function alignSize(value, kb = 0, factor = 0) {
|
|
581
|
+
if (value === undefined) {
|
|
582
|
+
return NaN;
|
|
583
|
+
}
|
|
584
|
+
let result = 0;
|
|
585
|
+
switch (typeof value) {
|
|
586
|
+
case 'number':
|
|
587
|
+
if (value < 0) {
|
|
588
|
+
return NaN;
|
|
589
|
+
}
|
|
590
|
+
result = Math.ceil(factor > 0 ? value * Math.pow(1024, factor) : value);
|
|
591
|
+
break;
|
|
592
|
+
case 'string':
|
|
593
|
+
result = formatSize(value);
|
|
594
|
+
if (result < 0) {
|
|
595
|
+
return NaN;
|
|
596
|
+
}
|
|
597
|
+
break;
|
|
598
|
+
default:
|
|
599
|
+
return NaN;
|
|
600
|
+
}
|
|
601
|
+
if (kb > 0) {
|
|
602
|
+
kb = Math.ceil(kb) * 1024;
|
|
603
|
+
return Math.ceil(result / kb) * kb;
|
|
604
|
+
}
|
|
605
|
+
return result;
|
|
606
|
+
}
|
|
607
|
+
exports.alignSize = alignSize;
|
|
577
608
|
function cascadeObject(data, query, fallback) {
|
|
578
609
|
if (isObject(data) && isString(query)) {
|
|
579
610
|
const names = query.trim().split(/(?<!\\)\./).map(item => item.includes('.') ? item.replace(/\\(?=\.)/g, '') : item);
|
package/lib/index.d.ts
CHANGED
|
@@ -35,7 +35,6 @@ import type * as EventEmitter from 'events';
|
|
|
35
35
|
|
|
36
36
|
// @ts-ignore
|
|
37
37
|
import type * as ws from 'ws';
|
|
38
|
-
// @ts-ignore
|
|
39
38
|
import type { FileTypeResult } from 'file-type';
|
|
40
39
|
|
|
41
40
|
type BufferView = BufferContent | NodeJS.ArrayBufferView;
|
|
@@ -66,7 +65,7 @@ declare namespace functions {
|
|
|
66
65
|
chunkSize?: number;
|
|
67
66
|
register(format: string, callback: TryFileCompressor): void;
|
|
68
67
|
getLevel(value: string, fallback?: number): Undef<number>;
|
|
69
|
-
getReadable(file: string | Buffer): Readable;
|
|
68
|
+
getReadable(file: string | URL | Buffer): Readable;
|
|
70
69
|
createGzip(file: string | Buffer, options?: CompressLevel): Gzip;
|
|
71
70
|
createBrotliCompress(file: string | Buffer, options?: CompressLevel): BrotliCompress;
|
|
72
71
|
createWriteStreamAsGzip(file: string | Buffer, output: string, options?: CompressLevel): WriteStream;
|
|
@@ -109,7 +108,7 @@ declare namespace functions {
|
|
|
109
108
|
clamp(value: unknown, min?: number, max?: number): number;
|
|
110
109
|
isBinary(mime: unknown): mime is string;
|
|
111
110
|
toABGR(buffer: Uint8Array | Buffer): Buffer;
|
|
112
|
-
/* @deprecated IImage.using
|
|
111
|
+
/* @deprecated - IImage.using */
|
|
113
112
|
using?<V extends ExternalAsset>(this: T, instance: IImage<T, U>, data: IFileThread<V>, command: string): Promise<unknown>;
|
|
114
113
|
readonly prototype: IImage<T, U>;
|
|
115
114
|
new(module?: U): IImage<T, U>;
|
|
@@ -127,7 +126,7 @@ declare namespace functions {
|
|
|
127
126
|
|
|
128
127
|
interface TaskConstructor<T extends IHost = IHost, U extends TaskModule = TaskModule> extends ModuleConstructor {
|
|
129
128
|
finalize<V extends ExternalAsset>(this: T, instance: ITask<T, U>, assets: V[]): Promise<unknown>;
|
|
130
|
-
/* @deprecated ITask.using
|
|
129
|
+
/* @deprecated - ITask.using */
|
|
131
130
|
using?<V extends ExternalAsset>(this: T, instance: ITask<T, U>, assets: V[], preceding?: boolean): Promise<unknown>;
|
|
132
131
|
readonly prototype: ITask<T, U>;
|
|
133
132
|
new(module?: U, ...args: unknown[]): ITask<T, U>;
|
|
@@ -147,9 +146,9 @@ declare namespace functions {
|
|
|
147
146
|
handleFail(err: unknown, item: V, options?: HandleFailOptions): boolean;
|
|
148
147
|
readTLSCert(value: unknown, cache?: boolean): string;
|
|
149
148
|
readTLSConfig(options: SecureContextOptions, cache?: boolean): void;
|
|
150
|
-
settingsOf(source: string, name:
|
|
149
|
+
settingsOf(source: string, name: keyof Omit<W, "coerce">): unknown;
|
|
151
150
|
settingsOf(source: string, name: "coerce", component: keyof X): unknown;
|
|
152
|
-
settingsKey(source: string, name:
|
|
151
|
+
settingsKey(source: string, name: keyof Omit<W, "coerce">): unknown;
|
|
153
152
|
settingsKey(source: string, name: "coerce", component: keyof X): unknown;
|
|
154
153
|
getPoolConfig(source: string, uuidKey?: string): Undef<Required<PoolConfig>>;
|
|
155
154
|
get sourceType(): DB_TYPE;
|
|
@@ -256,7 +255,7 @@ declare namespace functions {
|
|
|
256
255
|
writeSourceMap(uri: string, data: SourceCode, options?: SourceMapOptions): Undef<string>;
|
|
257
256
|
updateGradle(source: string, namespaces: string[], value: string, options?: UpdateGradleOptions | boolean): string;
|
|
258
257
|
generateLintTable(messages: LintMessage[], options: GenerateLintTableOptions): LogComponent[];
|
|
259
|
-
/* @deprecated IDocument.using
|
|
258
|
+
/* @deprecated - IDocument.using */
|
|
260
259
|
using?(this: T, instance: IDocument<T, U, V, W, X, Y>, file: U): Promise<unknown>;
|
|
261
260
|
cleanup?(this: T, instance: IDocument<T, U, V, W, X, Y>): Promise<unknown>;
|
|
262
261
|
sanitizeAssets?(assets: U[], exclusions?: U[]): U[];
|
|
@@ -266,7 +265,7 @@ declare namespace functions {
|
|
|
266
265
|
|
|
267
266
|
interface IWatch<T extends IFileManager<U>, U extends ExternalAsset = ExternalAsset, V extends WatchModule = WatchModule, W extends FunctionType<unknown, any> = ModifiedPostFinalizeListener<U>> extends IClient<T, V, W> {
|
|
268
267
|
connectTimeout: number;
|
|
269
|
-
start(assets: U[], permission?: IPermission): void;
|
|
268
|
+
start(assets: U[], permission?: Null<IPermission>): void;
|
|
270
269
|
modified(watch: IFileGroup<U>): Promise<Void<FinalizeResult>>;
|
|
271
270
|
configureServer(options: SecureOptions): boolean;
|
|
272
271
|
setCA(value: string): boolean;
|
|
@@ -293,6 +292,7 @@ declare namespace functions {
|
|
|
293
292
|
checkTimeout(client: ws): boolean;
|
|
294
293
|
readonly prototype: IWatch<T, U, V, W>;
|
|
295
294
|
new(module?: V): IWatch<T, U, V, W>;
|
|
295
|
+
/* @deprecated */
|
|
296
296
|
new(interval?: number, port?: number, securePort?: number, extensions?: unknown[]): IWatch<T, U, V, W>;
|
|
297
297
|
}
|
|
298
298
|
|
|
@@ -310,9 +310,9 @@ declare namespace functions {
|
|
|
310
310
|
lookupDns(hostname: string): LookupFunction;
|
|
311
311
|
proxyOf(uri: string, localhost?: boolean): Undef<ProxySettings>;
|
|
312
312
|
statusOn(name: ArrayOf<number>, callback: StatusOnCallback): void;
|
|
313
|
-
statusOn(name: ArrayOf<number>,
|
|
314
|
-
headersOn(name:
|
|
315
|
-
headersOn(name:
|
|
313
|
+
statusOn(name: ArrayOf<number>, globUrl: string, callback: StatusOnCallback): void;
|
|
314
|
+
headersOn(name: StringOfArray, callback: HeadersOnCallback): void;
|
|
315
|
+
headersOn(name: StringOfArray, globUrl: string, callback: HeadersOnCallback): void;
|
|
316
316
|
headersOf(uri: string): Undef<OutgoingHttpHeaders>;
|
|
317
317
|
aria2c(uri: string | URL, pathname: string): Promise<string[]>;
|
|
318
318
|
aria2c(uri: string | URL, options?: Aria2Options): Promise<string[]>;
|
|
@@ -425,8 +425,10 @@ declare namespace functions {
|
|
|
425
425
|
writeBuffer(file: T, options?: WriteFileOptions): Null<Buffer>;
|
|
426
426
|
writeImage(document: StringOfArray, output: OutputFinalize<T>): boolean;
|
|
427
427
|
compressFile(file: T, overwrite?: boolean): Promise<unknown>;
|
|
428
|
+
fetchObject(uri: string | URL, format: BufferFormat): Promise<Null<object>>;
|
|
428
429
|
fetchObject(uri: string | URL, options?: OpenOptions | BufferFormat): Promise<Null<object>>;
|
|
429
430
|
fetchBuffer<U extends OpenOptions>(uri: string | URL, options?: U): Promise<DataEncodedResult<U>>;
|
|
431
|
+
fetchFiles(uri: string | URL, pathname: string): Promise<string[]>;
|
|
430
432
|
fetchFiles(uri: string | URL, options?: Aria2Options | string): Promise<string[]>;
|
|
431
433
|
start(emptyDir?: boolean): Promise<FinalizeResult>;
|
|
432
434
|
processAssets(emptyDir?: boolean, using?: T[]): void;
|
|
@@ -723,8 +725,8 @@ declare namespace functions {
|
|
|
723
725
|
copyDir(src: string | URL, dest: string | URL, move?: boolean, recursive?: boolean): Promise<CopyDirResult>;
|
|
724
726
|
renameFile(src: string | URL, dest: string | URL, throws?: boolean): boolean;
|
|
725
727
|
streamFile<U extends BufferContent>(src: string, cache: boolean): Promise<U>;
|
|
726
|
-
streamFile<U extends
|
|
727
|
-
streamFile<U extends
|
|
728
|
+
streamFile<U extends ReadBufferOptions>(src: string, options: U): Promise<U extends { encoding: string } ? string : Buffer>;
|
|
729
|
+
streamFile<U extends ReadBufferOptions>(src: string, cache?: boolean | U, options?: U): Promise<U extends { encoding: string } ? string : Buffer>;
|
|
728
730
|
readText(value: string | URL, cache: boolean): string;
|
|
729
731
|
readText<U extends ReadTextOptions>(value: string | URL, options: U): U extends { minStreamSize: NumString } ? Promise<string> : string;
|
|
730
732
|
readText(value: string | URL, encoding?: BufferEncoding | boolean | ReadTextOptions, cache?: boolean): string;
|
package/lib/logger.d.ts
CHANGED
package/lib/request.d.ts
CHANGED
|
@@ -65,7 +65,6 @@ export interface OpenOptions extends KeepAliveAction, SilentAction {
|
|
|
65
65
|
postData?: unknown;
|
|
66
66
|
connected?: (headers: IncomingHttpHeaders) => Void<boolean>;
|
|
67
67
|
statusMessage?: string;
|
|
68
|
-
silent?: boolean;
|
|
69
68
|
outFormat?: { out: BufferFormat; parser?: PlainObject };
|
|
70
69
|
outFilename?: Null<string>;
|
|
71
70
|
outHeaders?: Null<IncomingHttpHeaders>;
|
|
@@ -105,7 +104,9 @@ export interface ProxySettings extends KeepAliveAction {
|
|
|
105
104
|
|
|
106
105
|
export interface RequestInit extends ProtocolAction {
|
|
107
106
|
headers?: unknown;
|
|
107
|
+
/* @deprecated - readTimeout */
|
|
108
108
|
requestTimeout?: number;
|
|
109
|
+
readTimeout?: number;
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
export interface ClientConfig {
|
package/lib/settings.d.ts
CHANGED
|
@@ -84,8 +84,8 @@ export interface PermissionModule<T = PermissionSettings> extends PermittedDirec
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
export interface PermissionSettings extends PlainObject {
|
|
87
|
-
picomatch?: PicomatchOptions
|
|
88
|
-
minimatch?: MinimatchOptions
|
|
87
|
+
picomatch?: Null<PicomatchOptions>;
|
|
88
|
+
minimatch?: Null<MinimatchOptions>;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
export interface DownloadModule<T = PlainObject> extends HandlerSettings<T> {
|
package/lib/type.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
type Undef<T> = T | undefined;
|
|
4
4
|
type Null<T> = T | null;
|
|
5
5
|
type Void<T> = T | void;
|
|
6
|
-
type Optional<T> =
|
|
6
|
+
type Optional<T> = T | null | undefined;
|
|
7
7
|
type Nullable<T> = { [P in keyof T]: T[P] | null; };
|
|
8
8
|
type Writeable<T> = { -readonly [P in keyof T]: T[P] };
|
|
9
9
|
type KeyOfType<T, U = any, V = any> = { [K in keyof T]: K extends U ? T[K] extends V ? K : never : never }[keyof T];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/types",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.5",
|
|
4
4
|
"description": "Type definitions for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"squared-functions"
|
|
18
18
|
],
|
|
19
19
|
"author": "An Pham <anpham6@gmail.com>",
|
|
20
|
-
"license": "
|
|
20
|
+
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"bytes": "^3.1.2",
|