@e-mc/types 0.9.7 → 0.10.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 -9
- package/constant.d.ts +37 -8
- package/index.d.ts +27 -14
- package/index.js +319 -218
- package/lib/asset.d.ts +2 -2
- package/lib/cloud.d.ts +1 -1
- package/lib/compat-v4.d.ts +11 -6
- package/lib/compress.d.ts +9 -8
- package/lib/core.d.ts +7 -7
- package/lib/db.d.ts +13 -9
- package/lib/document.d.ts +6 -4
- package/lib/filemanager.d.ts +10 -9
- package/lib/http.d.ts +2 -1
- package/lib/index.d.ts +53 -46
- package/lib/logger.d.ts +3 -0
- package/lib/module.d.ts +21 -38
- package/lib/node.d.ts +2 -2
- package/lib/object.d.ts +0 -2
- package/lib/request.d.ts +8 -4
- package/lib/settings.d.ts +86 -66
- package/lib/squared.d.ts +8 -45
- package/lib/type.d.ts +6 -4
- package/package.json +2 -2
- package/lib/dom.d.ts +0 -9
package/index.js
CHANGED
|
@@ -1,24 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports.
|
|
3
|
-
exports.
|
|
2
|
+
exports.generateUUID = exports.IMPORT_MAP = exports.THRESHOLD = exports.READDIR_SORT = exports.WATCH_EVENT = exports.TRANSFER_TYPE = 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_STATE = exports.LOG_TYPE = void 0;
|
|
3
|
+
exports.createAbortError = createAbortError;
|
|
4
|
+
exports.hasBit = hasBit;
|
|
5
|
+
exports.ignoreFlag = ignoreFlag;
|
|
6
|
+
exports.cloneFlag = cloneFlag;
|
|
7
|
+
exports.usingFlag = usingFlag;
|
|
8
|
+
exports.watchFlag = watchFlag;
|
|
9
|
+
exports.modifiedFlag = modifiedFlag;
|
|
10
|
+
exports.processFlag = processFlag;
|
|
11
|
+
exports.mainFlag = mainFlag;
|
|
12
|
+
exports.existsFlag = existsFlag;
|
|
13
|
+
exports.getLogCurrent = getLogCurrent;
|
|
14
|
+
exports.setLogCurrent = setLogCurrent;
|
|
15
|
+
exports.getTempDir = getTempDir;
|
|
16
|
+
exports.setTempDir = setTempDir;
|
|
17
|
+
exports.isArray = isArray;
|
|
18
|
+
exports.isPlainObject = isPlainObject;
|
|
19
|
+
exports.isObject = isObject;
|
|
20
|
+
exports.isString = isString;
|
|
21
|
+
exports.isEmpty = isEmpty;
|
|
22
|
+
exports.parseTime = parseTime;
|
|
23
|
+
exports.parseExpires = parseExpires;
|
|
24
|
+
exports.formatTime = formatTime;
|
|
25
|
+
exports.convertTime = convertTime;
|
|
26
|
+
exports.hasGlob = hasGlob;
|
|
27
|
+
exports.escapePattern = escapePattern;
|
|
28
|
+
exports.renameExt = renameExt;
|
|
29
|
+
exports.formatSize = formatSize;
|
|
30
|
+
exports.alignSize = alignSize;
|
|
31
|
+
exports.cascadeObject = cascadeObject;
|
|
32
|
+
exports.cloneObject = cloneObject;
|
|
33
|
+
exports.coerceObject = coerceObject;
|
|
34
|
+
exports.asFunction = asFunction;
|
|
35
|
+
exports.getEncoding = getEncoding;
|
|
36
|
+
exports.encryptUTF8 = encryptUTF8;
|
|
37
|
+
exports.decryptUTF8 = decryptUTF8;
|
|
38
|
+
exports.randomString = randomString;
|
|
39
|
+
exports.validateUUID = validateUUID;
|
|
40
|
+
exports.errorValue = errorValue;
|
|
41
|
+
exports.errorMessage = errorMessage;
|
|
42
|
+
exports.purgeMemory = purgeMemory;
|
|
43
|
+
exports.incrementUUID = incrementUUID;
|
|
44
|
+
exports.hashKey = hashKey;
|
|
45
|
+
exports.supported = supported;
|
|
46
|
+
exports.importESM = importESM;
|
|
4
47
|
const path = require("path");
|
|
5
48
|
const fs = require("fs");
|
|
6
49
|
const crypto = require("crypto");
|
|
7
50
|
const bytes = require("bytes");
|
|
51
|
+
const url_1 = require("url");
|
|
8
52
|
class AbortError extends Error {
|
|
9
53
|
constructor() {
|
|
10
|
-
super("
|
|
11
|
-
this.
|
|
12
|
-
|
|
54
|
+
super("This operation was aborted");
|
|
55
|
+
Error.captureStackTrace(this, this.constructor);
|
|
56
|
+
}
|
|
57
|
+
set name(value) { }
|
|
58
|
+
get name() {
|
|
59
|
+
return 'AbortError';
|
|
60
|
+
}
|
|
61
|
+
set code(value) { }
|
|
62
|
+
get code() {
|
|
63
|
+
return 20;
|
|
13
64
|
}
|
|
14
65
|
}
|
|
66
|
+
const [VER_MAJOR, VER_MINOR, VER_PATCH] = process.version.substring(1).split('.').map(value => +value);
|
|
15
67
|
const REGEXP_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
16
|
-
const REGEXP_FUNCTION = /^(async\s+)?(function(?:\b|\s+)[\w_$]*\s*\(([^)]*)\)\s*\{(
|
|
17
|
-
const REGEXP_FUNCTION_ARROW = /^(async\s+)?(\(([^)]*)\)\s*=>\s*(?:\{(
|
|
68
|
+
const REGEXP_FUNCTION = /^(async\s+)?(function(?:\b|\s+)[\w_$]*\s*\(([^)]*)\)\s*\{(.*)\})$/s;
|
|
69
|
+
const REGEXP_FUNCTION_ARROW = /^(async\s+)?(\(([^)]*)\)\s*=>\s*(?:\{(.*)\}|(?!\s|{)((?:(?<!return\s+)(?:"[^"\n]*"|'[^'\n]*'|`[^`]*`|[^\n;"'`]))*;)))$/s;
|
|
18
70
|
const REGEXP_GLOB = /(?<!\\)(?:(?:[^*]|^)\*{1,2}(?:[^*]|$)|\{[^}]+\}|\[[!^][^\]]+\]|[!?*+@]\([^)]+\))/;
|
|
71
|
+
const REGEXP_NATIVE = /^new\s+(Date|RegExp|URL|(?:Weak)?(?:Map|Set))\((.*)\)$/s;
|
|
19
72
|
const ASYNC_FUNCTION = Object.getPrototypeOf(async () => { }).constructor;
|
|
20
73
|
let CACHE_COERCED = new WeakSet();
|
|
21
74
|
let LOG_CURRENT = null;
|
|
75
|
+
let SUPPORTED_DOMEXCEPTION = false;
|
|
76
|
+
let SUPPORTED_HASHSINGLE = false;
|
|
22
77
|
let TEMP_DIR = path.join(process.cwd(), "tmp");
|
|
23
78
|
let INCREMENT_COUNT = 65536;
|
|
24
79
|
let INCREMENT_PREFIX = '';
|
|
@@ -202,6 +257,81 @@ function getProperties(obj, inherited, nonenumerable, symbol) {
|
|
|
202
257
|
}
|
|
203
258
|
return symbol ? attrs.concat(Object.getOwnPropertySymbols(obj)) : attrs;
|
|
204
259
|
}
|
|
260
|
+
function parseStringDefault(value) {
|
|
261
|
+
if (value.length <= 8) {
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
switch (value.substring(0, 3)) {
|
|
265
|
+
case 'new': {
|
|
266
|
+
const match = REGEXP_NATIVE.exec(value.trimEnd());
|
|
267
|
+
if (match) {
|
|
268
|
+
try {
|
|
269
|
+
const text = match[2].trim();
|
|
270
|
+
switch (match[1]) {
|
|
271
|
+
case 'Date':
|
|
272
|
+
return new Date(trimQuote(text));
|
|
273
|
+
case 'URL':
|
|
274
|
+
case 'RegExp': {
|
|
275
|
+
const pattern = /^("[^"]+"|'[^']+'|[^\s,]+)(?:\s*,\s*("[^"]+"|'[^']+'|\S+))?$/.exec(text);
|
|
276
|
+
if (pattern) {
|
|
277
|
+
return new (match[1] === 'URL' ? URL : RegExp)(trimQuote(pattern[1]), pattern[2] ? trimQuote(pattern[2]) : '');
|
|
278
|
+
}
|
|
279
|
+
throw errorValue("Invalid parameters", text);
|
|
280
|
+
}
|
|
281
|
+
default: {
|
|
282
|
+
let values = [];
|
|
283
|
+
if (text.startsWith('[') && text.endsWith(']')) {
|
|
284
|
+
values = JSON.parse(text);
|
|
285
|
+
}
|
|
286
|
+
else if (text) {
|
|
287
|
+
throw errorValue("Invalid parameters", text);
|
|
288
|
+
}
|
|
289
|
+
switch (match[1]) {
|
|
290
|
+
case 'Map':
|
|
291
|
+
return new Map(values);
|
|
292
|
+
case 'WeakMap':
|
|
293
|
+
return new WeakMap(values);
|
|
294
|
+
case 'Set':
|
|
295
|
+
return new Set(values);
|
|
296
|
+
case 'WeakSet':
|
|
297
|
+
return new WeakSet(values);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
catch {
|
|
303
|
+
return undefined;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
case 'asy':
|
|
309
|
+
case 'fun':
|
|
310
|
+
return asFunction(value);
|
|
311
|
+
case 'Num':
|
|
312
|
+
switch (value) {
|
|
313
|
+
case 'Number.EPSILON':
|
|
314
|
+
return Number.EPSILON;
|
|
315
|
+
case 'Number.MAX_SAFE_INTEGER':
|
|
316
|
+
return Number.MAX_SAFE_INTEGER;
|
|
317
|
+
case 'Number.MAX_VALUE':
|
|
318
|
+
return Number.MAX_VALUE;
|
|
319
|
+
case 'Number.MIN_SAFE_INTEGER':
|
|
320
|
+
return Number.MIN_SAFE_INTEGER;
|
|
321
|
+
case 'Number.MIN_VALUE':
|
|
322
|
+
return Number.MIN_VALUE;
|
|
323
|
+
case 'Number.NaN':
|
|
324
|
+
return Number.NaN;
|
|
325
|
+
case 'Number.NEGATIVE_INFINITY':
|
|
326
|
+
return Number.NEGATIVE_INFINITY;
|
|
327
|
+
case 'Number.POSITIVE_INFINITY':
|
|
328
|
+
return Number.POSITIVE_INFINITY;
|
|
329
|
+
}
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
const padStart = (value, char) => value > 9 ? value.toString() : char + value;
|
|
205
335
|
const convertScrypt = (key, iv, data) => crypto.scryptSync(key, iv, Math.ceil(data.length / 16) * 16);
|
|
206
336
|
const isFunction = (value) => typeof value === 'function';
|
|
207
337
|
var LOG_TYPE;
|
|
@@ -324,139 +454,159 @@ var THRESHOLD;
|
|
|
324
454
|
THRESHOLD[THRESHOLD["WATCH_INTERVAL"] = 500] = "WATCH_INTERVAL";
|
|
325
455
|
THRESHOLD[THRESHOLD["WATCH_CHANGE"] = 100] = "WATCH_CHANGE";
|
|
326
456
|
})(THRESHOLD || (exports.THRESHOLD = THRESHOLD = {}));
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
457
|
+
exports.IMPORT_MAP = {
|
|
458
|
+
"@squared-functions/cloud": "@e-mc/cloud",
|
|
459
|
+
"@squared-functions/cloud/util": "@e-mc/cloud/util",
|
|
460
|
+
"@squared-functions/compress-v3": "@e-mc/compress",
|
|
461
|
+
"@squared-functions/core": "@e-mc/core",
|
|
462
|
+
"@squared-functions/db": "@e-mc/db",
|
|
463
|
+
"@squared-functions/db/pool": "@e-mc/db/pool",
|
|
464
|
+
"@squared-functions/db/util": "@e-mc/db/util",
|
|
465
|
+
"@squared-functions/document": "@e-mc/document",
|
|
466
|
+
"@squared-functions/document/parse": "@e-mc/document/parse",
|
|
467
|
+
"@squared-functions/document/parse/dom": "@e-mc/document/parse/dom",
|
|
468
|
+
"@squared-functions/document/transform": "@e-mc/document/transform",
|
|
469
|
+
"@squared-functions/document/asset": "@e-mc/document/asset",
|
|
470
|
+
"@squared-functions/document/util": "@e-mc/document/util",
|
|
471
|
+
"@squared-functions/file-manager": "@e-mc/file-manager",
|
|
472
|
+
"@squared-functions/file-manager/http/host": "@e-mc/request/http/host",
|
|
473
|
+
"@squared-functions/image-v3": "@e-mc/image",
|
|
474
|
+
"@squared-functions/module": "@e-mc/module",
|
|
475
|
+
"@squared-functions/task": "@e-mc/task",
|
|
476
|
+
"@squared-functions/types": "@e-mc/types",
|
|
477
|
+
"@squared-functions/watch": "@e-mc/watch",
|
|
478
|
+
"@squared-functions/watch/filegroup": "@e-mc/watch/filegroup",
|
|
479
|
+
"@squared-functions/document/android": "@pi-r/android",
|
|
480
|
+
"@squared-functions/document/android/extensions/app/manifest": "@pi-r/android/extensions/app/manifest",
|
|
481
|
+
"@squared-functions/document/android/extensions/gradle/dependencies": "@pi-r/android/extensions/gradle/dependencies",
|
|
482
|
+
"@squared-functions/document/android/extensions/gradle/settings": "@pi-r/android/extensions/gradle/settings",
|
|
483
|
+
"@squared-functions/document/android/extensions/task": "@pi-r/android/extensions/task",
|
|
484
|
+
"@squared-functions/document/chrome": "@pi-r/chrome",
|
|
485
|
+
"@squared-functions/image/jimp": "@pi-r/jimp",
|
|
486
|
+
"@squared-functions/image/jimp/util": "@pi-r/jimp/util",
|
|
487
|
+
"@squared-functions/image-v3/jimp": "@pi-r/jimp",
|
|
488
|
+
"@squared-functions/task/gulp": "@pi-r/gulp",
|
|
489
|
+
"@squared-functions/cloud/atlas": "@pi-r/atlas",
|
|
490
|
+
"@squared-functions/cloud/aws": "@pi-r/aws",
|
|
491
|
+
"@squared-functions/cloud/aws/download": "@pi-r/aws/download",
|
|
492
|
+
"@squared-functions/cloud/aws/upload": "@pi-r/aws/upload",
|
|
493
|
+
"@squared-functions/cloud/aws-v3": "@pi-r/aws-v3",
|
|
494
|
+
"@squared-functions/cloud/aws-v3/download": "@pi-r/aws-v3/download",
|
|
495
|
+
"@squared-functions/cloud/aws-v3/upload": "@pi-r/aws-v3/upload",
|
|
496
|
+
"@squared-functions/cloud/azure": "@pi-r/azure",
|
|
497
|
+
"@squared-functions/cloud/azure/download": "@pi-r/azure/download",
|
|
498
|
+
"@squared-functions/cloud/azure/upload": "@pi-r/azure/upload",
|
|
499
|
+
"@squared-functions/cloud/gcp": "@pi-r/gcp",
|
|
500
|
+
"@squared-functions/cloud/gcp/download": "@pi-r/gcp/download",
|
|
501
|
+
"@squared-functions/cloud/gcp/upload": "@pi-r/gcp/upload",
|
|
502
|
+
"@squared-functions/cloud/ibm": "@pi-r/ibm",
|
|
503
|
+
"@squared-functions/cloud/ibm/download": "@pi-r/ibm/download",
|
|
504
|
+
"@squared-functions/cloud/ibm/upload": "@pi-r/ibm/upload",
|
|
505
|
+
"@squared-functions/cloud/ibm-v1": "@pi-r/ibm",
|
|
506
|
+
"@squared-functions/cloud/ibm-v1/download": "@pi-r/ibm/download",
|
|
507
|
+
"@squared-functions/cloud/ibm-v1/upload": "@pi-r/ibm/upload",
|
|
508
|
+
"@squared-functions/cloud/minio": "@pi-r/minio",
|
|
509
|
+
"@squared-functions/cloud/minio/download": "@pi-r/minio/download",
|
|
510
|
+
"@squared-functions/cloud/minio/upload": "@pi-r/minio/upload",
|
|
511
|
+
"@squared-functions/cloud/oci": "@pi-r/oci",
|
|
512
|
+
"@squared-functions/cloud/oci/download": "@pi-r/oci/download",
|
|
513
|
+
"@squared-functions/cloud/oci/upload": "@pi-r/oci/upload",
|
|
514
|
+
"@squared-functions/db/mongodb": "@pi-r/mongodb",
|
|
515
|
+
"@squared-functions/db/mssql": "@pi-r/mssql",
|
|
516
|
+
"@squared-functions/db/mysql": "@pi-r/mysql",
|
|
517
|
+
"@squared-functions/db/oracle": "@pi-r/oracle",
|
|
518
|
+
"@squared-functions/db/postgres": "@pi-r/postgres",
|
|
519
|
+
"@squared-functions/db/redis": "@pi-r/redis",
|
|
520
|
+
"@squared-functions/document/packages/@babel/core": "@pi-r/babel",
|
|
521
|
+
"@squared-functions/document/packages/clean-css": "@pi-r/clean-css",
|
|
522
|
+
"@squared-functions/document/packages/eslint": "@pi-r/eslint",
|
|
523
|
+
"@squared-functions/document/packages/html-minifier": "@pi-r/html-minifier-terser",
|
|
524
|
+
"@squared-functions/document/packages/html-minifier-terser": "@pi-r/html-minifier-terser",
|
|
525
|
+
"@squared-functions/document/packages/html-validate": "@pi-r/html-validate",
|
|
526
|
+
"@squared-functions/document/packages/postcss": "@pi-r/postcss",
|
|
527
|
+
"@squared-functions/document/packages/posthtml": "@pi-r/posthtml",
|
|
528
|
+
"@squared-functions/document/packages/prettier": "@pi-r/prettier",
|
|
529
|
+
"@squared-functions/document/packages/rollup": "@pi-r/rollup",
|
|
530
|
+
"@squared-functions/document/packages/sass": "@pi-r/sass",
|
|
531
|
+
"@squared-functions/document/packages/stylelint": "@pi-r/stylelint",
|
|
532
|
+
"@squared-functions/document/packages/svgo": "@pi-r/svgo",
|
|
533
|
+
"@squared-functions/document/packages/terser": "@pi-r/terser",
|
|
534
|
+
"@squared-functions/document/packages/uglify-js": "@pi-r/uglify-js",
|
|
535
|
+
"atlas": "@pi-r/atlas",
|
|
536
|
+
"aws": "@pi-r/aws",
|
|
537
|
+
"aws-v3": "@pi-r/aws-v3",
|
|
538
|
+
"az": "@pi-r/azure",
|
|
539
|
+
"azure": "@pi-r/azure",
|
|
540
|
+
"gcloud": "@pi-r/gcp",
|
|
541
|
+
"gcp": "@pi-r/gcp",
|
|
542
|
+
"ibm": "@pi-r/ibm",
|
|
543
|
+
"minio": "@pi-r/minio",
|
|
544
|
+
"oci": "@pi-r/oci",
|
|
545
|
+
"tinify": "@pi-r/tinify",
|
|
546
|
+
"mariadb": "@pi-r/mariadb",
|
|
547
|
+
"mongodb": "@pi-r/mongodb",
|
|
548
|
+
"mssql": "@pi-r/mssql",
|
|
549
|
+
"mysql": "@pi-r/mysql",
|
|
550
|
+
"oracle": "@pi-r/oracle",
|
|
551
|
+
"postgres": "@pi-r/postgres",
|
|
552
|
+
"redis": "@pi-r/redis",
|
|
553
|
+
"@babel/core": "@pi-r/babel",
|
|
554
|
+
"clean-css": "@pi-r/clean-css",
|
|
555
|
+
"csso": "@pi-r/csso",
|
|
556
|
+
"eslint": "@pi-r/eslint",
|
|
557
|
+
"html-minifier": "@pi-r/html-minifier",
|
|
558
|
+
"html-minifier-terser": "@pi-r/html-minifier-terser",
|
|
559
|
+
"html-validate": "@pi-r/html-validate",
|
|
560
|
+
"postcss": "@pi-r/postcss",
|
|
561
|
+
"posthtml": "@pi-r/posthtml",
|
|
562
|
+
"prettier": "@pi-r/prettier",
|
|
563
|
+
"rollup": "@pi-r/rollup",
|
|
564
|
+
"sass": "@pi-r/sass",
|
|
565
|
+
"stylelint": "@pi-r/stylelint",
|
|
566
|
+
"svgo": "@pi-r/svgo",
|
|
567
|
+
"terser": "@pi-r/terser",
|
|
568
|
+
"uglify-js": "@pi-r/uglify-js"
|
|
569
|
+
};
|
|
407
570
|
function createAbortError(reject) {
|
|
408
|
-
const result = new AbortError();
|
|
571
|
+
const result = SUPPORTED_DOMEXCEPTION ? new DOMException("This operation was aborted", 'AbortError') : new AbortError();
|
|
409
572
|
return (reject ? Promise.reject(result) : result);
|
|
410
573
|
}
|
|
411
|
-
exports.createAbortError = createAbortError;
|
|
412
574
|
function hasBit(value, flags) {
|
|
413
575
|
return typeof value === 'number' && (value & flags) > 0;
|
|
414
576
|
}
|
|
415
|
-
exports.hasBit = hasBit;
|
|
416
577
|
function ignoreFlag(value) {
|
|
417
578
|
return typeof value === 'number' && (value & 1) === 1;
|
|
418
579
|
}
|
|
419
|
-
exports.ignoreFlag = ignoreFlag;
|
|
420
580
|
function cloneFlag(value) {
|
|
421
581
|
return typeof value === 'number' && (value & 2) === 2;
|
|
422
582
|
}
|
|
423
|
-
exports.cloneFlag = cloneFlag;
|
|
424
583
|
function usingFlag(value) {
|
|
425
584
|
return typeof value === 'number' && (value & 4) === 4;
|
|
426
585
|
}
|
|
427
|
-
exports.usingFlag = usingFlag;
|
|
428
586
|
function watchFlag(value) {
|
|
429
587
|
return typeof value === 'number' && (value & 8) === 8;
|
|
430
588
|
}
|
|
431
|
-
exports.watchFlag = watchFlag;
|
|
432
589
|
function modifiedFlag(value) {
|
|
433
590
|
return typeof value === 'number' && (value & 16) === 16;
|
|
434
591
|
}
|
|
435
|
-
exports.modifiedFlag = modifiedFlag;
|
|
436
592
|
function processFlag(value) {
|
|
437
593
|
return typeof value === 'number' && (value & 32) === 32;
|
|
438
594
|
}
|
|
439
|
-
exports.processFlag = processFlag;
|
|
440
595
|
function mainFlag(value) {
|
|
441
596
|
return typeof value === 'number' && (value & 64) === 64;
|
|
442
597
|
}
|
|
443
|
-
exports.mainFlag = mainFlag;
|
|
444
598
|
function existsFlag(value) {
|
|
445
599
|
return typeof value === 'number' && (value & 128) === 128;
|
|
446
600
|
}
|
|
447
|
-
exports.existsFlag = existsFlag;
|
|
448
601
|
function getLogCurrent() {
|
|
449
602
|
return LOG_CURRENT;
|
|
450
603
|
}
|
|
451
|
-
exports.getLogCurrent = getLogCurrent;
|
|
452
604
|
function setLogCurrent(value) {
|
|
453
605
|
LOG_CURRENT = value;
|
|
454
606
|
}
|
|
455
|
-
exports.setLogCurrent = setLogCurrent;
|
|
456
607
|
function getTempDir() {
|
|
457
608
|
return TEMP_DIR;
|
|
458
609
|
}
|
|
459
|
-
exports.getTempDir = getTempDir;
|
|
460
610
|
function setTempDir(value) {
|
|
461
611
|
try {
|
|
462
612
|
if (path.isAbsolute(value) && fs.statSync(value).isDirectory()) {
|
|
@@ -468,27 +618,21 @@ function setTempDir(value) {
|
|
|
468
618
|
}
|
|
469
619
|
return false;
|
|
470
620
|
}
|
|
471
|
-
exports.setTempDir = setTempDir;
|
|
472
621
|
function isArray(value) {
|
|
473
622
|
return Array.isArray(value) && value.length > 0;
|
|
474
623
|
}
|
|
475
|
-
exports.isArray = isArray;
|
|
476
624
|
function isPlainObject(value) {
|
|
477
625
|
return typeof value === 'object' && value !== null && (value.constructor === Object || Object.getPrototypeOf(value) === null);
|
|
478
626
|
}
|
|
479
|
-
exports.isPlainObject = isPlainObject;
|
|
480
627
|
function isObject(value) {
|
|
481
628
|
return typeof value === 'object' && value !== null;
|
|
482
629
|
}
|
|
483
|
-
exports.isObject = isObject;
|
|
484
630
|
function isString(value) {
|
|
485
631
|
return typeof value === 'string' && value.length > 0;
|
|
486
632
|
}
|
|
487
|
-
exports.isString = isString;
|
|
488
633
|
function isEmpty(value) {
|
|
489
634
|
return value === undefined || value === null || value === '' || Array.isArray(value) && value.length === 0;
|
|
490
635
|
}
|
|
491
|
-
exports.isEmpty = isEmpty;
|
|
492
636
|
function parseTime(value, start = 0) {
|
|
493
637
|
const seconds = +value;
|
|
494
638
|
if (isNaN(seconds) && isString(value)) {
|
|
@@ -534,22 +678,44 @@ function parseTime(value, start = 0) {
|
|
|
534
678
|
}
|
|
535
679
|
return 0;
|
|
536
680
|
}
|
|
537
|
-
exports.parseTime = parseTime;
|
|
538
681
|
function parseExpires(value, start = 0) {
|
|
539
682
|
if (+value < 0 || value === 'never') {
|
|
540
683
|
return Infinity;
|
|
541
684
|
}
|
|
542
685
|
return parseTime(value, start);
|
|
543
686
|
}
|
|
544
|
-
exports.parseExpires = parseExpires;
|
|
545
687
|
function formatTime(value, elapsed, char = ' ') {
|
|
546
|
-
const result = [];
|
|
547
688
|
if (elapsed === true) {
|
|
548
689
|
value = Date.now() - value;
|
|
549
690
|
}
|
|
550
691
|
else if (isString(elapsed)) {
|
|
551
692
|
char = elapsed;
|
|
552
693
|
}
|
|
694
|
+
if (char === ':') {
|
|
695
|
+
let result = '';
|
|
696
|
+
if (value >= 3600000) {
|
|
697
|
+
const h = Math.floor(value / 3600000);
|
|
698
|
+
value -= h * 3600000;
|
|
699
|
+
result = h + ':';
|
|
700
|
+
}
|
|
701
|
+
if (value >= 60000) {
|
|
702
|
+
const m = Math.floor(value / 60000);
|
|
703
|
+
value -= m * 60000;
|
|
704
|
+
result += padStart(m, result ? '0' : ' ') + ':';
|
|
705
|
+
}
|
|
706
|
+
else {
|
|
707
|
+
result += '0:';
|
|
708
|
+
}
|
|
709
|
+
if (value >= 1000) {
|
|
710
|
+
const s = Math.floor(value / 1000);
|
|
711
|
+
result += padStart(s, '0');
|
|
712
|
+
}
|
|
713
|
+
else {
|
|
714
|
+
result += '00';
|
|
715
|
+
}
|
|
716
|
+
return result;
|
|
717
|
+
}
|
|
718
|
+
const result = [];
|
|
553
719
|
if (value < 1000) {
|
|
554
720
|
return value + 'ms';
|
|
555
721
|
}
|
|
@@ -568,7 +734,6 @@ function formatTime(value, elapsed, char = ' ') {
|
|
|
568
734
|
}
|
|
569
735
|
return result.join(char);
|
|
570
736
|
}
|
|
571
|
-
exports.formatTime = formatTime;
|
|
572
737
|
function convertTime(value, format) {
|
|
573
738
|
let result;
|
|
574
739
|
if (Array.isArray(value)) {
|
|
@@ -580,11 +745,9 @@ function convertTime(value, format) {
|
|
|
580
745
|
}
|
|
581
746
|
return result;
|
|
582
747
|
}
|
|
583
|
-
exports.convertTime = convertTime;
|
|
584
748
|
function hasGlob(value) {
|
|
585
749
|
return REGEXP_GLOB.test(value);
|
|
586
750
|
}
|
|
587
|
-
exports.hasGlob = hasGlob;
|
|
588
751
|
function escapePattern(value, lookBehind) {
|
|
589
752
|
switch (typeof value) {
|
|
590
753
|
case 'string': {
|
|
@@ -622,7 +785,6 @@ function escapePattern(value, lookBehind) {
|
|
|
622
785
|
return '';
|
|
623
786
|
}
|
|
624
787
|
}
|
|
625
|
-
exports.escapePattern = escapePattern;
|
|
626
788
|
function renameExt(value, ext, when) {
|
|
627
789
|
if (!ext.startsWith('.')) {
|
|
628
790
|
ext = '.' + ext;
|
|
@@ -642,7 +804,6 @@ function renameExt(value, ext, when) {
|
|
|
642
804
|
}
|
|
643
805
|
return value + ext;
|
|
644
806
|
}
|
|
645
|
-
exports.renameExt = renameExt;
|
|
646
807
|
function formatSize(value, options) {
|
|
647
808
|
let result;
|
|
648
809
|
if (typeof value === 'number') {
|
|
@@ -653,7 +814,6 @@ function formatSize(value, options) {
|
|
|
653
814
|
}
|
|
654
815
|
return result;
|
|
655
816
|
}
|
|
656
|
-
exports.formatSize = formatSize;
|
|
657
817
|
function alignSize(value, kb = 0, factor = 0) {
|
|
658
818
|
if (value === undefined) {
|
|
659
819
|
return NaN;
|
|
@@ -681,7 +841,6 @@ function alignSize(value, kb = 0, factor = 0) {
|
|
|
681
841
|
}
|
|
682
842
|
return result;
|
|
683
843
|
}
|
|
684
|
-
exports.alignSize = alignSize;
|
|
685
844
|
function cascadeObject(data, query, fallback) {
|
|
686
845
|
if (isObject(data)) {
|
|
687
846
|
const names = query.trim().split(/(?<!\\)\./).map(item => item.includes('.') ? item.replace(/\\(?=\.)/g, '') : item);
|
|
@@ -708,7 +867,6 @@ function cascadeObject(data, query, fallback) {
|
|
|
708
867
|
}
|
|
709
868
|
return fallback;
|
|
710
869
|
}
|
|
711
|
-
exports.cascadeObject = cascadeObject;
|
|
712
870
|
function cloneObject(data, options) {
|
|
713
871
|
let target, deep, deepIgnore, mergeArray, mergeDepth = Infinity, typedArray, inherited, nonenumerable, symbol, preserve;
|
|
714
872
|
if (options === true) {
|
|
@@ -795,7 +953,6 @@ function cloneObject(data, options) {
|
|
|
795
953
|
}
|
|
796
954
|
return target;
|
|
797
955
|
}
|
|
798
|
-
exports.cloneObject = cloneObject;
|
|
799
956
|
function coerceObject(data, parseString, cache) {
|
|
800
957
|
if (typeof parseString === 'boolean') {
|
|
801
958
|
cache = parseString;
|
|
@@ -804,91 +961,7 @@ function coerceObject(data, parseString, cache) {
|
|
|
804
961
|
else if (parseString && typeof parseString !== 'function') {
|
|
805
962
|
return data;
|
|
806
963
|
}
|
|
807
|
-
|
|
808
|
-
parseString = (value) => {
|
|
809
|
-
if (value.length <= 8) {
|
|
810
|
-
return null;
|
|
811
|
-
}
|
|
812
|
-
switch (value.substring(0, 3)) {
|
|
813
|
-
case 'new': {
|
|
814
|
-
const match = /^new\s+(Date|RegExp|URL|Map|WeakMap|Set|WeakSet)\(([\S\s]*)\)$/.exec(value.trimEnd());
|
|
815
|
-
if (match) {
|
|
816
|
-
try {
|
|
817
|
-
const removeQuotes = (content) => content.trim().replace(/^["']/g, '').replace(/["']$/g, '').trim();
|
|
818
|
-
const errorCreate = () => errorValue("Invalid parameters", match[2].trim());
|
|
819
|
-
switch (match[1]) {
|
|
820
|
-
case 'Date':
|
|
821
|
-
return new Date(match[2].replace(/["']/g, '').trim());
|
|
822
|
-
case 'URL':
|
|
823
|
-
case 'RegExp': {
|
|
824
|
-
const pattern = /^("[^"]+"|'[^']+'|[^\s,]+)(?:\s*,\s*("[^"]+"|'[^']+'|\S+))?$/.exec(match[2].trim());
|
|
825
|
-
if (pattern) {
|
|
826
|
-
return new (match[1] === 'URL' ? URL : RegExp)(removeQuotes(pattern[1]), pattern[2] ? removeQuotes(pattern[2]) : '');
|
|
827
|
-
}
|
|
828
|
-
throw errorCreate();
|
|
829
|
-
}
|
|
830
|
-
default: {
|
|
831
|
-
const text = match[2].trim();
|
|
832
|
-
let values = [];
|
|
833
|
-
if (text.startsWith('[') && text.endsWith(']')) {
|
|
834
|
-
values = JSON.parse(text);
|
|
835
|
-
}
|
|
836
|
-
else if (text) {
|
|
837
|
-
throw errorCreate();
|
|
838
|
-
}
|
|
839
|
-
switch (match[1]) {
|
|
840
|
-
case 'Map':
|
|
841
|
-
return new Map(values);
|
|
842
|
-
case 'WeakMap':
|
|
843
|
-
return new WeakMap(values);
|
|
844
|
-
case 'Set':
|
|
845
|
-
return new Set(values);
|
|
846
|
-
case 'WeakSet':
|
|
847
|
-
return new WeakSet(values);
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
catch {
|
|
853
|
-
return undefined;
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
break;
|
|
857
|
-
}
|
|
858
|
-
case 'asy':
|
|
859
|
-
if (value.substring(3, 5) === 'nc') {
|
|
860
|
-
return asFunction(value);
|
|
861
|
-
}
|
|
862
|
-
break;
|
|
863
|
-
case 'fun':
|
|
864
|
-
if (value.substring(3, 8) === 'ction') {
|
|
865
|
-
return asFunction(value);
|
|
866
|
-
}
|
|
867
|
-
break;
|
|
868
|
-
case 'Num':
|
|
869
|
-
switch (value) {
|
|
870
|
-
case 'Number.EPSILON':
|
|
871
|
-
return Number.EPSILON;
|
|
872
|
-
case 'Number.MAX_SAFE_INTEGER':
|
|
873
|
-
return Number.MAX_SAFE_INTEGER;
|
|
874
|
-
case 'Number.MAX_VALUE':
|
|
875
|
-
return Number.MAX_VALUE;
|
|
876
|
-
case 'Number.MIN_SAFE_INTEGER':
|
|
877
|
-
return Number.MIN_SAFE_INTEGER;
|
|
878
|
-
case 'Number.MIN_VALUE':
|
|
879
|
-
return Number.MIN_VALUE;
|
|
880
|
-
case 'Number.NaN':
|
|
881
|
-
return Number.NaN;
|
|
882
|
-
case 'Number.NEGATIVE_INFINITY':
|
|
883
|
-
return Number.NEGATIVE_INFINITY;
|
|
884
|
-
case 'Number.POSITIVE_INFINITY':
|
|
885
|
-
return Number.POSITIVE_INFINITY;
|
|
886
|
-
}
|
|
887
|
-
break;
|
|
888
|
-
}
|
|
889
|
-
return null;
|
|
890
|
-
};
|
|
891
|
-
}
|
|
964
|
+
parseString || (parseString = parseStringDefault);
|
|
892
965
|
if (Array.isArray(data)) {
|
|
893
966
|
for (let i = 0, length = data.length; i < length; ++i) {
|
|
894
967
|
data[i] = recurseObject(data[i], parseString, new WeakSet(), cache);
|
|
@@ -897,7 +970,6 @@ function coerceObject(data, parseString, cache) {
|
|
|
897
970
|
}
|
|
898
971
|
return recurseObject(data, parseString, new WeakSet(), cache);
|
|
899
972
|
}
|
|
900
|
-
exports.coerceObject = coerceObject;
|
|
901
973
|
function asFunction(value, sync = true) {
|
|
902
974
|
if (isFunction(value)) {
|
|
903
975
|
return value;
|
|
@@ -920,14 +992,14 @@ function asFunction(value, sync = true) {
|
|
|
920
992
|
}
|
|
921
993
|
return null;
|
|
922
994
|
}
|
|
923
|
-
exports.asFunction = asFunction;
|
|
924
995
|
function getEncoding(value, fallback = 'utf-8') {
|
|
925
996
|
if (typeof value === 'string') {
|
|
926
997
|
switch (value = value.trim().toLowerCase()) {
|
|
927
998
|
case 'utf8':
|
|
928
999
|
case 'utf-8':
|
|
1000
|
+
case 'unicode-1-1-utf-8':
|
|
1001
|
+
return 'utf-8';
|
|
929
1002
|
case 'utf16le':
|
|
930
|
-
return value;
|
|
931
1003
|
case 'utf-16le':
|
|
932
1004
|
case 'utf16':
|
|
933
1005
|
case 'utf-16':
|
|
@@ -939,7 +1011,6 @@ function getEncoding(value, fallback = 'utf-8') {
|
|
|
939
1011
|
}
|
|
940
1012
|
return fallback;
|
|
941
1013
|
}
|
|
942
|
-
exports.getEncoding = getEncoding;
|
|
943
1014
|
function encryptUTF8(algorithm, key, iv, data, encoding = 'hex') {
|
|
944
1015
|
if (checkCipherType(algorithm) && isString(data)) {
|
|
945
1016
|
try {
|
|
@@ -950,7 +1021,6 @@ function encryptUTF8(algorithm, key, iv, data, encoding = 'hex') {
|
|
|
950
1021
|
}
|
|
951
1022
|
}
|
|
952
1023
|
}
|
|
953
|
-
exports.encryptUTF8 = encryptUTF8;
|
|
954
1024
|
function decryptUTF8(algorithm, key, iv, data, encoding = 'hex') {
|
|
955
1025
|
if (checkCipherType(algorithm) && isString(data)) {
|
|
956
1026
|
try {
|
|
@@ -961,7 +1031,6 @@ function decryptUTF8(algorithm, key, iv, data, encoding = 'hex') {
|
|
|
961
1031
|
}
|
|
962
1032
|
}
|
|
963
1033
|
}
|
|
964
|
-
exports.decryptUTF8 = decryptUTF8;
|
|
965
1034
|
function randomString(format, dictionary) {
|
|
966
1035
|
if (format !== '8-4-4-4-12' || dictionary) {
|
|
967
1036
|
const match = format.match(/(\d+|[^\d]+)/g);
|
|
@@ -998,31 +1067,63 @@ function randomString(format, dictionary) {
|
|
|
998
1067
|
}
|
|
999
1068
|
}
|
|
1000
1069
|
}
|
|
1001
|
-
return
|
|
1070
|
+
return crypto.randomUUID();
|
|
1002
1071
|
}
|
|
1003
|
-
exports.randomString = randomString;
|
|
1004
1072
|
function validateUUID(value) {
|
|
1005
1073
|
return typeof value === 'string' && value.length === 36 && REGEXP_UUID.test(value);
|
|
1006
1074
|
}
|
|
1007
|
-
exports.validateUUID = validateUUID;
|
|
1008
1075
|
function errorValue(value, hint) {
|
|
1009
1076
|
return new Error(value + (hint ? ` (${hint})` : ''));
|
|
1010
1077
|
}
|
|
1011
|
-
exports.errorValue = errorValue;
|
|
1012
1078
|
function errorMessage(title, value, hint) {
|
|
1013
1079
|
return new Error((title !== '' ? title + ': ' : '') + value + (hint ? ` (${hint})` : ''));
|
|
1014
1080
|
}
|
|
1015
|
-
exports.errorMessage = errorMessage;
|
|
1016
1081
|
function purgeMemory(percent) {
|
|
1017
1082
|
CACHE_COERCED = new WeakSet();
|
|
1018
1083
|
}
|
|
1019
|
-
exports.purgeMemory = purgeMemory;
|
|
1020
1084
|
function incrementUUID(restart) {
|
|
1021
1085
|
if (restart || INCREMENT_COUNT === 65536) {
|
|
1022
1086
|
INCREMENT_COUNT = 0;
|
|
1023
|
-
INCREMENT_PREFIX =
|
|
1087
|
+
INCREMENT_PREFIX = crypto.randomUUID().substring(0, 33);
|
|
1024
1088
|
}
|
|
1025
1089
|
return INCREMENT_PREFIX + (INCREMENT_COUNT++).toString(16).padStart(4, '0');
|
|
1026
1090
|
}
|
|
1027
|
-
|
|
1091
|
+
function hashKey(data, algorithm = 'md5', encoding = 'base64') {
|
|
1092
|
+
try {
|
|
1093
|
+
return SUPPORTED_HASHSINGLE ? crypto.hash(algorithm, data, encoding) : crypto.createHash(algorithm).update(data).digest(encoding);
|
|
1094
|
+
}
|
|
1095
|
+
catch {
|
|
1096
|
+
return crypto.randomUUID();
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
function supported(major, minor = 0, patch = 0, lts) {
|
|
1100
|
+
if (VER_MAJOR < major) {
|
|
1101
|
+
return false;
|
|
1102
|
+
}
|
|
1103
|
+
if (VER_MAJOR === major) {
|
|
1104
|
+
if (VER_MINOR < minor) {
|
|
1105
|
+
return false;
|
|
1106
|
+
}
|
|
1107
|
+
if (VER_MINOR === minor) {
|
|
1108
|
+
return VER_PATCH >= patch;
|
|
1109
|
+
}
|
|
1110
|
+
return true;
|
|
1111
|
+
}
|
|
1112
|
+
return !lts;
|
|
1113
|
+
}
|
|
1114
|
+
async function importESM(name, isDefault, fromPath) {
|
|
1115
|
+
if (fromPath && path.isAbsolute(name)) {
|
|
1116
|
+
name = (0, url_1.pathToFileURL)(name).toString();
|
|
1117
|
+
}
|
|
1118
|
+
const result = import(name);
|
|
1119
|
+
if (isDefault) {
|
|
1120
|
+
const out = await result;
|
|
1121
|
+
if (isObject(out) && 'default' in out) {
|
|
1122
|
+
return out.default;
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
return result;
|
|
1126
|
+
}
|
|
1028
1127
|
exports.generateUUID = crypto.randomUUID.bind(crypto);
|
|
1128
|
+
SUPPORTED_DOMEXCEPTION = supported(17);
|
|
1129
|
+
SUPPORTED_HASHSINGLE = supported(20, 12, 0, true) || supported(21, 7);
|