@e-mc/module 0.13.10 → 0.14.1

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.
Files changed (3) hide show
  1. package/README.md +9 -9
  2. package/index.js +293 -281
  3. package/package.json +2 -5
package/index.js CHANGED
@@ -1,18 +1,19 @@
1
1
  "use strict";
2
+
2
3
  var _a;
3
- const path = require("node:path");
4
- const fs = require("node:fs");
5
- const stream = require("node:stream");
6
- const os = require("node:os");
7
- const crypto = require("node:crypto");
8
- const mime = require("mime-types");
9
- const pm = require("picomatch");
10
- const chalk = require("chalk");
11
- const yaml = require("js-yaml");
12
- const EventEmitter = require("node:events");
13
- const node_url_1 = require("node:url");
14
- const node_util_1 = require("node:util");
15
- const types_1 = require("@e-mc/types");
4
+ const path = require('node:path');
5
+ const fs = require('node:fs');
6
+ const stream = require('node:stream');
7
+ const os = require('node:os');
8
+ const pm = require('picomatch');
9
+ const chalk = require('chalk');
10
+ const EventEmitter = require('node:events');
11
+ const { createHash, randomUUID } = require('node:crypto');
12
+ const { fileURLToPath } = require('node:url');
13
+ const { stripVTControlCharacters } = require('node:util');
14
+ const { extension, lookup } = require('mime-types');
15
+ const { load } = require('js-yaml');
16
+ const { ERR_CODE, LOG_TYPE, STATUS_TYPE, THRESHOLD, alignSize, asExt, asFunction, cloneObject, convertTime, encryptUTF8, errorMessage, errorValue, formatSize, formatTime, getEncoding, getTempDir, hasGlob, importESM, isArray, isEmpty, isError, isErrorCode, isFunction, isObject, isPlainObject, isString, parseExpires, purgeMemory, requireESM, sanitizeArgs, sanitizeCmd, setLogCurrent, setTempDir, supported } = require('@e-mc/types');
16
17
  const kModule = Symbol.for('module:constructor');
17
18
  const PROCESS_CWD = process.cwd();
18
19
  const PROCESS_STDOUT = process.stdout;
@@ -20,8 +21,9 @@ const PLATFORM_WIN32 = process.platform === 'win32';
20
21
  const OS_HOMEDIR = os.homedir();
21
22
  const MEM_TOTAL = os.totalmem();
22
23
  const CPU_CORETOTAL = os.cpus().length;
23
- const SUPPORTED_CPUTHREAD = (0, types_1.supported)(23, 9);
24
- const SUPPORTED_CANPARSE = (0, types_1.supported)(19, 9) || (0, types_1.supported)(18, 17, true);
24
+ const SUPPORTED_CPUTHREAD = supported(23, 9);
25
+ const SUPPORTED_CPUPARALLELISM = supported(19, 4) || supported(18, 14, true);
26
+ const SUPPORTED_CANPARSE = supported(19, 9) || supported(18, 17, true);
25
27
  const CACHE_READTEXT = new Map();
26
28
  const CACHE_READBUFFER = new Map();
27
29
  const CACHE_READCJS = new Map();
@@ -100,6 +102,7 @@ const SETTINGS = {
100
102
  file: true,
101
103
  cloud: true,
102
104
  db: true,
105
+ user: true,
103
106
  time_elapsed: true,
104
107
  time_process: true,
105
108
  exec: true,
@@ -146,12 +149,12 @@ const LOG_DIVIDER = chalk.blackBright('|');
146
149
  let LOG_NEWLINE = true;
147
150
  let LOG_EMPTYLINE = false;
148
151
  let LOG_MIN_WIDTH = 0;
149
- let TEMP_DIR = (0, types_1.getTempDir)();
152
+ let TEMP_DIR = getTempDir();
150
153
  let PNPM_VER;
151
154
  let YARN_VER;
152
155
  let FILETYPE_ESM = null;
153
156
  function parseYaml(pathname) {
154
- return yaml.load(fs.readFileSync(pathname, 'utf8'));
157
+ return load(fs.readFileSync(pathname, 'utf8'));
155
158
  }
156
159
  function setPnpmVer() {
157
160
  if (PNPM_VER === undefined) {
@@ -160,7 +163,7 @@ function setPnpmVer() {
160
163
  let baseDir;
161
164
  try {
162
165
  let pathname = path.resolve("node_modules/.modules.yaml"), config;
163
- if (fs.existsSync(pathname) && (0, types_1.isObject)(config = parseYaml(pathname))) {
166
+ if (fs.existsSync(pathname) && isObject(config = parseYaml(pathname))) {
164
167
  if (config.nodeLinker === 'hoisted') {
165
168
  return PNPM_VER = true;
166
169
  }
@@ -176,7 +179,7 @@ function setPnpmVer() {
176
179
  if (!fs.existsSync(pathname = path.resolve(baseDir, "lock.yaml"))) {
177
180
  baseDir = undefined;
178
181
  }
179
- else if ((0, types_1.isObject)(config = parseYaml(pathname))) {
182
+ else if (isObject(config = parseYaml(pathname))) {
180
183
  for (const name in config.packages) {
181
184
  addPnpmPackage(items, name);
182
185
  }
@@ -194,11 +197,11 @@ function setPnpmVer() {
194
197
  function addPnpmPackage(items, value) {
195
198
  let index = (value = value.replace(/^\//, '')).indexOf('(');
196
199
  if (index !== -1) {
197
- value = value.substring(0, index);
200
+ value = value.slice(0, index);
198
201
  }
199
202
  index = value.lastIndexOf(value.indexOf('@', 1) !== -1 ? '@' : '/');
200
- const name = value.substring(0, index);
201
- const version = value.substring(index + 1);
203
+ const name = value.slice(0, index);
204
+ const version = value.slice(index + 1);
202
205
  if (!items.find(item => item[0] === name && item[1] === version)) {
203
206
  items.push([name, version]);
204
207
  }
@@ -209,7 +212,7 @@ function setYarnVer() {
209
212
  try {
210
213
  const pathname = path.resolve(".yarnrc.yml");
211
214
  let config;
212
- if (fs.existsSync(pathname) && (0, types_1.isObject)(config = parseYaml(pathname)) && config.nodeLinker === 'node-modules') {
215
+ if (fs.existsSync(pathname) && isObject(config = parseYaml(pathname)) && config.nodeLinker === 'node-modules') {
213
216
  return YARN_VER = true;
214
217
  }
215
218
  }
@@ -282,7 +285,7 @@ function applyStyle(options, style) {
282
285
  return options;
283
286
  }
284
287
  function checkColorOptions(type, settings, options) {
285
- if (!(0, types_1.isObject)(settings)) {
288
+ if (!isObject(settings)) {
286
289
  return false;
287
290
  }
288
291
  let result = false;
@@ -308,7 +311,7 @@ function checkColorOptions(type, settings, options) {
308
311
  if (typeof settings.hintBold === 'boolean') {
309
312
  options.hintBold ??= settings.hintBold;
310
313
  }
311
- if (type & types_1.LOG_TYPE.FAIL) {
314
+ if (type & LOG_TYPE.FAIL) {
312
315
  return result;
313
316
  }
314
317
  if (settings.titleColor) {
@@ -371,7 +374,7 @@ function tryCreateDir(value) {
371
374
  pathname = ch + pathname;
372
375
  }
373
376
  else if (pathname) {
374
- let dir = value.substring(0, i + 1);
377
+ let dir = value.slice(0, i + 1);
375
378
  subDir.push(pathname);
376
379
  if (fs.existsSync(dir)) {
377
380
  if (!fs.statSync(dir).isDirectory()) {
@@ -457,14 +460,14 @@ function tryIncrementDir(value, increment) {
457
460
  return [outErr, -1];
458
461
  }
459
462
  function errorObject(message) {
460
- if (message instanceof Error) {
463
+ if (isError(message)) {
461
464
  return message;
462
465
  }
463
466
  switch (typeof message) {
464
467
  case 'string':
465
468
  return new Error(message);
466
469
  case 'number':
467
- return (0, types_1.errorMessage)("Error code", message.toString());
470
+ return errorMessage("Error code", message.toString());
468
471
  default:
469
472
  return new Error(Module.asString(message) || "Unknown");
470
473
  }
@@ -489,7 +492,7 @@ function recurseCause(err, out, visited) {
489
492
  visited.add(err);
490
493
  if (Object.hasOwn(err, 'cause')) {
491
494
  const cause = err.cause;
492
- if (cause instanceof Error) {
495
+ if (isError(cause)) {
493
496
  if (message) {
494
497
  out.push(message);
495
498
  }
@@ -498,7 +501,7 @@ function recurseCause(err, out, visited) {
498
501
  }
499
502
  return;
500
503
  }
501
- if ((0, types_1.isString)(cause)) {
504
+ if (isString(cause)) {
502
505
  message = message ? message + ` (${cause})` : cause;
503
506
  }
504
507
  }
@@ -522,7 +525,7 @@ function parseFileArgs(options = {}, callback) {
522
525
  promises = options;
523
526
  options = {};
524
527
  }
525
- else if ((0, types_1.isFunction)(options)) {
528
+ else if (isFunction(options)) {
526
529
  callback = options;
527
530
  options = {};
528
531
  }
@@ -539,7 +542,7 @@ function formatTimeHint(value) {
539
542
  case 's':
540
543
  return (value / 1000) + 's';
541
544
  default:
542
- return (0, types_1.formatTime)(value);
545
+ return formatTime(value);
543
546
  }
544
547
  }
545
548
  function getTimeOffset(value, current) {
@@ -547,10 +550,10 @@ function getTimeOffset(value, current) {
547
550
  return 0;
548
551
  }
549
552
  if (typeof value === 'bigint') {
550
- return Math.max(0, (0, types_1.convertTime)(process.hrtime.bigint() - value));
553
+ return Math.max(0, convertTime(process.hrtime.bigint() - value));
551
554
  }
552
555
  if (Array.isArray(value)) {
553
- return (0, types_1.convertTime)(process.hrtime(value));
556
+ return convertTime(process.hrtime(value));
554
557
  }
555
558
  return (current || Date.now()) - (value instanceof Date ? value.getTime() : value);
556
559
  }
@@ -592,7 +595,7 @@ function getCacheSize() {
592
595
  return CACHE_READTEXT.size + CACHE_READBUFFER.size + CACHE_READCJS.size;
593
596
  }
594
597
  function createMatchNegate(values) {
595
- if (!(0, types_1.isArray)(values)) {
598
+ if (!isArray(values)) {
596
599
  return null;
597
600
  }
598
601
  const result = [[], []];
@@ -604,7 +607,7 @@ function createMatchNegate(values) {
604
607
  value = Module.toPosix(value, true);
605
608
  const invert = value.startsWith('!');
606
609
  if (invert) {
607
- value = value.substring(1);
610
+ value = value.slice(1);
608
611
  }
609
612
  if (value.startsWith('*') && !value.includes('/')) {
610
613
  (invert ? relativeAbs : relative).push(value);
@@ -636,7 +639,7 @@ function listDir(src, paths, depth, include, exclude, excludeDir, outFiles) {
636
639
  for (const file of fs.readdirSync(srcDir, { withFileTypes: true })) {
637
640
  if (file.isFile()) {
638
641
  const pathname = path.join(srcDir, file.name);
639
- const pathglob = pathname.substring(src.length);
642
+ const pathglob = pathname.slice(src.length);
640
643
  if (include(pathglob) && !exclude?.(pathglob)) {
641
644
  outFiles.push(pathname);
642
645
  }
@@ -665,7 +668,7 @@ function encryptMessage(data, cipher, iv) {
665
668
  iv ||= cipher.iv;
666
669
  if (key && iv) {
667
670
  const algorithm = cipher.algorithm || 'aes-256-gcm';
668
- const result = (0, types_1.encryptUTF8)(algorithm, key, iv, data);
671
+ const result = encryptUTF8(algorithm, key, iv, data);
669
672
  if (result) {
670
673
  if (!PROCESS_CIPHER.algorithm) {
671
674
  PROCESS_CIPHER.algorithm = algorithm;
@@ -700,25 +703,8 @@ function formatPercent(value, precision) {
700
703
  value *= 100;
701
704
  return value.toPrecision(value < 0.001 ? 1 : value < 1 ? 2 : precision) + '%';
702
705
  }
703
- function relayMessage(instance, args) {
704
- const host = instance.host || instance;
705
- if (host.logState === 0) {
706
- host.delayMessage(args);
707
- }
708
- else {
709
- Module.formatMessage(...args);
710
- }
711
- }
712
- function setCpuAndMem(instance, options) {
713
- if (!options.messageUnit) {
714
- const usage = CACHE_CPUHOST.get(instance) || instance.host && CACHE_CPUHOST.get(instance.host);
715
- if (usage) {
716
- options.messageUnit = Module.formatCpuMem(usage);
717
- }
718
- }
719
- }
720
706
  function checkExDev(err, src, dest) {
721
- if ((0, types_1.isErrorCode)(err, 'EXDEV')) {
707
+ if (isErrorCode(err, 'EXDEV')) {
722
708
  try {
723
709
  fs.copyFileSync(src, dest);
724
710
  fs.unlinkSync(src);
@@ -738,7 +724,7 @@ function getSessionId(value, width) {
738
724
  return ['', width - 1];
739
725
  }
740
726
  function alignLogColumn(value, width, justify, padding) {
741
- const length = (padding === 0 && REGEXP_ANSIESCAPE.test(value) ? (0, node_util_1.stripVTControlCharacters)(value) : value).length;
727
+ const length = (padding === 0 && REGEXP_ANSIESCAPE.test(value) ? stripVTControlCharacters(value) : value).length;
742
728
  const offset = width - length;
743
729
  const spacing = padding === 1 ? ' ' : '';
744
730
  if (offset <= 0) {
@@ -826,16 +812,16 @@ function truncateStart(value, length = LOG_MIN_WIDTH, style = false) {
826
812
  if (!style || style === 'none') {
827
813
  return value;
828
814
  }
829
- const width = (REGEXP_ANSIESCAPE.test(value) ? (0, node_util_1.stripVTControlCharacters)(value) : value).length;
815
+ const width = (REGEXP_ANSIESCAPE.test(value) ? stripVTControlCharacters(value) : value).length;
830
816
  if (width > length) {
831
817
  switch (style) {
832
818
  case 'nowrap':
833
- return value.substring(0, length);
819
+ return value.slice(0, length);
834
820
  case 'nowrap-end':
835
- return value.substring(width - length);
821
+ return value.slice(width - length);
836
822
  default:
837
823
  if (length > 3) {
838
- return style === 'ellipsis-end' ? '...' + value.substring(width - length + 3) : value.substring(0, length - 3) + '...';
824
+ return style === 'ellipsis-end' ? '...' + value.slice(width - length + 3) : value.slice(0, length - 3) + '...';
839
825
  }
840
826
  break;
841
827
  }
@@ -843,7 +829,7 @@ function truncateStart(value, length = LOG_MIN_WIDTH, style = false) {
843
829
  return length > 0 && width <= length ? value : '';
844
830
  }
845
831
  function truncateEnd(value, length) {
846
- return (REGEXP_ANSIESCAPE.test(value) ? (0, node_util_1.stripVTControlCharacters)(value) : value).length > length ? '...' + value.substring(value.length - length + 3) : value;
832
+ return (REGEXP_ANSIESCAPE.test(value) ? stripVTControlCharacters(value) : value).length > length ? '...' + value.slice(value.length - length + 3) : value;
847
833
  }
848
834
  function isPathUNC(value) {
849
835
  value = value.toString();
@@ -854,38 +840,37 @@ const isHost = (value) => 'username' in value && typeof value.username === 'stri
854
840
  const hasAuth = (users, username) => !!username && (users === true || Array.isArray(users) && users.includes(username));
855
841
  const formatLogMessage = (type, message, unit, ident) => !ident && (type & 256) ? (unit + LOG_DIVIDER + message).trimEnd() : unit ? (type & 256) && ident ? unit + LOG_DIVIDER + message : (message + (ident ? '' : ' ') + unit).trimStart() : message;
856
842
  const hideAbort = (err) => err.name === 'AbortError' && SETTINGS.abort === false;
857
- const asFile = (value) => typeof value === 'string' ? PLATFORM_WIN32 ? value.trim() : value : value instanceof URL && value.protocol === 'file:' ? (0, node_url_1.fileURLToPath)(value) : '';
843
+ const asFile = (value) => typeof value === 'string' ? PLATFORM_WIN32 ? value.trim() : value : value instanceof URL && value.protocol === 'file:' ? fileURLToPath(value) : '';
858
844
  const isFileURL = (value) => /^file:\/\//i.test(value);
859
845
  const sanitizePath = (value) => value && path.resolve(value);
860
846
  const stripPath = (value) => path.normalize(value).replace(REGEXP_PATHEND, '');
861
847
  const ensureDir = (value) => value.endsWith(path.sep) ? value : value + path.sep;
862
848
  const trimDir = (value) => value.endsWith(path.sep) ? value.slice(0, -1) : value;
863
- const getExtension = (value) => path.extname(value).toLowerCase().substring(1);
864
849
  const getBarColor = (index) => SETTINGS.process.cpu_bar_color[index];
865
850
  const hasString = (item, value) => item === value || Array.isArray(item) && item.includes(value);
866
851
  const getCpuTimes = () => os.cpus().reduce((a, b) => a + b.times.user + b.times.sys, 0) * 1000;
867
852
  const autoMemoryCache = () => MEMORY_CACHE_DISK.enabled && MEMORY_CACHE_DISK.max_size > 0;
868
- const errorDirectory = (value) => (0, types_1.errorValue)("Path is not a directory", value);
869
- const errorPermission = (value) => (0, types_1.errorValue)("Unsupported access", asFile(value));
870
- const errorAccess = (failed) => (0, types_1.errorMessage)("Unsupported access", failed.length > 1 ? failed.map(value => `\n- ${value}`).join('') : ' ' + failed[0]);
871
- const errorUnknown = (err, hint) => err instanceof Error ? 'code' in err || 'errno' in err ? err : (0, types_1.errorMessage)("Unknown", err.message, hint) : (0, types_1.errorValue)("Unknown", hint);
853
+ const errorDirectory = (value) => errorValue("Path is not a directory", value);
854
+ const errorPermission = (value) => errorValue("Unsupported access", asFile(value));
855
+ const errorAccess = (failed) => errorMessage("Unsupported access", failed.length > 1 ? failed.map(value => `\n- ${value}`).join('') : ' ' + failed[0]);
856
+ const errorUnknown = (err, hint) => isError(err) ? 'code' in err || 'errno' in err ? err : errorMessage("Unknown", err.message, hint) : errorValue("Unknown", hint);
872
857
  class Module extends EventEmitter {
873
858
  static [kModule] = true;
874
859
  static PROCESS_TIMEOUT = 0;
875
860
  static LOG_STYLE_FAIL = Object.freeze({ titleBgColor: 'bgRed', titleColor: 'white', titleBold: true });
876
- static LOG_STYLE_SUCCESS = Object.freeze({ titleBgColor: 'bgBlack', titleColor: 'green', titleBold: true });
861
+ static LOG_STYLE_SUCCESS = Object.freeze({ titleColor: 'green', titleBold: true, titleJustify: 'center' });
877
862
  static LOG_STYLE_INFO = Object.freeze({ titleBgColor: 'bgBlue', titleColor: 'white' });
878
- static LOG_STYLE_WARN = Object.freeze({ titleBgColor: 'bgBlack', titleColor: 'yellow', titleBold: true });
863
+ static LOG_STYLE_WARN = Object.freeze({ titleColor: 'yellow', titleBold: true, titleJustify: 'center' });
879
864
  static LOG_STYLE_NOTICE = Object.freeze({ titleBgColor: 'bgGrey', titleColor: 'white' });
880
865
  static LOG_STYLE_REVERSE = Object.freeze({ titleBgColor: 'bgWhite', titleColor: 'black', messageBgColor: 'bgGrey' });
881
866
  static get VERSION() {
882
- return "0.13.10";
867
+ return "0.14.1";
883
868
  }
884
869
  static get LOG_TYPE() {
885
- return types_1.LOG_TYPE;
870
+ return LOG_TYPE;
886
871
  }
887
872
  static get STATUS_TYPE() {
888
- return types_1.STATUS_TYPE;
873
+ return STATUS_TYPE;
889
874
  }
890
875
  static get PLATFORM_WIN32() {
891
876
  return PLATFORM_WIN32;
@@ -897,13 +882,13 @@ class Module extends EventEmitter {
897
882
  return TEMP_DIR;
898
883
  }
899
884
  static get LOG_FORMAT() {
900
- return (0, types_1.cloneObject)(SETTINGS.format, true);
885
+ return cloneObject(SETTINGS.format, true);
901
886
  }
902
887
  static constructorOf(value, moduleName = 'module') {
903
888
  return isConstructor(value) && value[Symbol.for(`${moduleName}:constructor`)] === true;
904
889
  }
905
890
  static supported(major, minor = 0, patch = 0, lts) {
906
- return (0, types_1.supported)(major, minor, patch, lts);
891
+ return supported(major, minor, patch, lts);
907
892
  }
908
893
  static enabled(key, username) {
909
894
  switch (key) {
@@ -961,13 +946,14 @@ class Module extends EventEmitter {
961
946
  (value & 2048) && SETTINGS.image === false ||
962
947
  (value & 4096) && SETTINGS.exec === false ||
963
948
  (value & 32768) && SETTINGS.stdout === false ||
964
- (value & 65536) && SETTINGS.db === false) {
949
+ (value & 65536) && SETTINGS.db === false ||
950
+ (value & 131072) && SETTINGS.user === false) {
965
951
  return false;
966
952
  }
967
953
  return true;
968
954
  }
969
955
  static formatMessage(type, title, value, message, options = {}) {
970
- const error = !!message && message instanceof Error;
956
+ const error = !!message && isError(message);
971
957
  if (error && hideAbort(message)) {
972
958
  return;
973
959
  }
@@ -981,7 +967,7 @@ class Module extends EventEmitter {
981
967
  try {
982
968
  const ERROR_OUT = VALUES["error.out"];
983
969
  const errorOptions = { type: type & ~512, value, timeStamp: getTimeStamp(options, true), sessionId };
984
- if ((0, types_1.isFunction)(ERROR_OUT, true)) {
970
+ if (isFunction(ERROR_OUT, true)) {
985
971
  ERROR_OUT(errorObject(message), errorOptions);
986
972
  }
987
973
  else {
@@ -997,10 +983,10 @@ class Module extends EventEmitter {
997
983
  if (!options.rawOutput) {
998
984
  let messageUnitIndent = options.messageUnitIndent, coloring = false;
999
985
  if (!broadcastId) {
1000
- (0, types_1.setLogCurrent)({ type, title, value, message, sessionId });
986
+ setLogCurrent({ type, title, value, message, sessionId });
1001
987
  coloring = !(options.useColor === false || SETTINGS.color === false);
1002
988
  }
1003
- else if ((0, types_1.isPlainObject)(broadcastId)) {
989
+ else if (isPlainObject(broadcastId)) {
1004
990
  coloring = broadcastId.stripAnsi === false;
1005
991
  broadcastId = broadcastId.value;
1006
992
  }
@@ -1038,6 +1024,13 @@ class Module extends EventEmitter {
1038
1024
  if (type & 4096) {
1039
1025
  checkColorOptions(type, SETTINGS.exec, options);
1040
1026
  }
1027
+ else if (type & 131072) {
1028
+ checkColorOptions(type, SETTINGS.user, options);
1029
+ if (!options.titleBgColor) {
1030
+ options.titleBgColor = 'bgBlueBright';
1031
+ titleJustify = 'center';
1032
+ }
1033
+ }
1041
1034
  else if (type & 32) {
1042
1035
  checkColorOptions(type, SETTINGS.file, options);
1043
1036
  }
@@ -1104,8 +1097,8 @@ class Module extends EventEmitter {
1104
1097
  }
1105
1098
  }
1106
1099
  }
1107
- title = titleIndent !== -1 ? ' '.repeat(titleIndent || (formatTitle.width + 3)) : (0, types_1.isString)(title) ? (title = title.toUpperCase(), alignLogColumn(formatTitle.as[title] || title, formatTitle.width, titleJustify, 1)) : '';
1108
- if ((0, types_1.isString)(hint)) {
1100
+ title = titleIndent !== -1 ? ' '.repeat(titleIndent || (formatTitle.width + 3)) : isString(title) ? (title = title.toUpperCase(), alignLogColumn(formatTitle.as[title] || title, formatTitle.width, titleJustify, 1)) : '';
1101
+ if (isString(hint)) {
1109
1102
  const formatHint = format.hint;
1110
1103
  const [L, R] = formatHint.braces;
1111
1104
  let { hintColor, hintBgColor, hintBold } = options, hintWidth = formatHint.width;
@@ -1160,7 +1153,7 @@ class Module extends EventEmitter {
1160
1153
  const [L, R] = formatMessage.braces;
1161
1154
  let u = unit;
1162
1155
  if (u) {
1163
- if ((0, types_1.isObject)(SETTINGS.time_process)) {
1156
+ if (isObject(SETTINGS.time_process)) {
1164
1157
  const time_process = SETTINGS.time_process;
1165
1158
  u = formatLogColumn(u, time_process.messageColor || 'grey', time_process.messageBgColor, time_process.messageBold);
1166
1159
  }
@@ -1171,10 +1164,10 @@ class Module extends EventEmitter {
1171
1164
  const messageTextWrap = options.messageTextWrap;
1172
1165
  const logOptions = { maxLength: messageWidth ?? formatMessage.width, outLength: 0, messageTextWrap };
1173
1166
  m = formatLogColumn(m, messageColor, messageBgColor, messageBold, messageUnitIndent ? format.meter.bgAltColor : undefined, logOptions);
1174
- if (u && messageTextWrap && messageTextWrap !== 'none' && LOG_MIN_WIDTH + logOptions.outLength + (0, node_util_1.stripVTControlCharacters)(unit).length + (messageUnitIndent ? 0 : 1) > PROCESS_STDOUT.columns) {
1167
+ if (u && messageTextWrap && messageTextWrap !== 'none' && LOG_MIN_WIDTH + logOptions.outLength + stripVTControlCharacters(unit).length + (messageUnitIndent ? 0 : 1) > PROCESS_STDOUT.columns) {
1175
1168
  if ((type & 256) && !messageUnitIndent) {
1176
1169
  m = '';
1177
- if (LOG_MIN_WIDTH + (0, node_util_1.stripVTControlCharacters)(u).length > PROCESS_STDOUT.columns) {
1170
+ if (LOG_MIN_WIDTH + stripVTControlCharacters(u).length > PROCESS_STDOUT.columns) {
1178
1171
  u = '';
1179
1172
  }
1180
1173
  }
@@ -1219,7 +1212,7 @@ class Module extends EventEmitter {
1219
1212
  }
1220
1213
  if (!output) {
1221
1214
  const formatMessage = format.message;
1222
- output = (titleIndent !== -1 ? title : title ? title + formatTitle.braces + ' ' : '') + (0, node_util_1.stripVTControlCharacters)(value) + (0, node_util_1.stripVTControlCharacters)(hint) + (id || ' ') + (message && SETTINGS.message !== false ? (error ? '{' : formatMessage.braces[0]) + truncateStart(formatLogMessage(type, (0, node_util_1.stripVTControlCharacters)(this.asString(message)), (0, node_util_1.stripVTControlCharacters)(unit), messageUnitIndent), options.messageWidth ?? formatMessage.width, options.messageTextWrap) + (error ? '}' : formatMessage.braces[1]) : !formatMessage.braces[1] ? formatMessage.braces[0] : '');
1215
+ output = (titleIndent !== -1 ? title : title ? title + formatTitle.braces + ' ' : '') + stripVTControlCharacters(value) + stripVTControlCharacters(hint) + (id || ' ') + (message && SETTINGS.message !== false ? (error ? '{' : formatMessage.braces[0]) + truncateStart(formatLogMessage(type, stripVTControlCharacters(this.asString(message)), stripVTControlCharacters(unit), messageUnitIndent), options.messageWidth ?? formatMessage.width, options.messageTextWrap) + (error ? '}' : formatMessage.braces[1]) : !formatMessage.braces[1] ? formatMessage.braces[0] : '');
1223
1216
  }
1224
1217
  }
1225
1218
  else {
@@ -1229,7 +1222,7 @@ class Module extends EventEmitter {
1229
1222
  if (BROADCAST_OUT) {
1230
1223
  try {
1231
1224
  options = { ...options, broadcastId, timeStamp: getTimeStamp(options, false) };
1232
- if ((0, types_1.isFunction)(BROADCAST_OUT, true)) {
1225
+ if (isFunction(BROADCAST_OUT, true)) {
1233
1226
  BROADCAST_OUT(output, options);
1234
1227
  }
1235
1228
  else {
@@ -1276,7 +1269,7 @@ class Module extends EventEmitter {
1276
1269
  }
1277
1270
  static writeFail(value, message, options) {
1278
1271
  let type;
1279
- if ((0, types_1.isObject)(options)) {
1272
+ if (isObject(options)) {
1280
1273
  ({ type } = options);
1281
1274
  }
1282
1275
  else {
@@ -1299,22 +1292,22 @@ class Module extends EventEmitter {
1299
1292
  if (requireExt === undefined || requireExt === true) {
1300
1293
  requireExt = VALUES["node.require.ext"];
1301
1294
  }
1302
- let result = (0, types_1.asFunction)(value, sync);
1303
- if (!result && (0, types_1.isString)(value)) {
1295
+ let result = asFunction(value, sync);
1296
+ if (!result && isString(value)) {
1304
1297
  let location = value.trim(), pathname;
1305
1298
  if (location.startsWith('npm:')) {
1306
- location = location.substring(4);
1299
+ location = location.slice(4);
1307
1300
  }
1308
1301
  else if (pathname = absolute && path.isAbsolute(location) ? location : this.fromLocalPath(location)) {
1309
- if (requireExt && VALUES["node.require.ext"] && hasString(requireExt, getExtension(pathname))) {
1302
+ if (requireExt && VALUES["node.require.ext"] && hasString(requireExt, asExt(pathname))) {
1310
1303
  try {
1311
- result = checkFunction(options?.default ? (0, types_1.requireESM)(pathname, options.url) : require(pathname));
1304
+ result = checkFunction(options?.default ? requireESM(pathname, options.url) : require(pathname));
1312
1305
  }
1313
1306
  catch {
1314
1307
  }
1315
1308
  }
1316
1309
  try {
1317
- result ||= (0, types_1.asFunction)(fs.readFileSync(pathname, 'utf8'), sync);
1310
+ result ||= asFunction(fs.readFileSync(pathname, 'utf8'), sync);
1318
1311
  }
1319
1312
  catch (err) {
1320
1313
  this.writeFail(["Unable to read file", value], err, 32);
@@ -1322,7 +1315,7 @@ class Module extends EventEmitter {
1322
1315
  }
1323
1316
  if (external && !pathname && VALUES["node.require.npm"] && /^(?:@[a-z\d-*~][a-z\d-*._~]*\/|node:)?[a-z\d-~][a-z\d-._~]*(?:\/.*)?$/.test(location)) {
1324
1317
  try {
1325
- result = checkFunction(options?.default ? (0, types_1.requireESM)(location, options.url) : require(location));
1318
+ result = checkFunction(options?.default ? requireESM(location, options.url) : require(location));
1326
1319
  }
1327
1320
  catch {
1328
1321
  }
@@ -1353,7 +1346,7 @@ class Module extends EventEmitter {
1353
1346
  }
1354
1347
  }
1355
1348
  else if (!Array.isArray(value)) {
1356
- if (value instanceof Error) {
1349
+ if (isError(value)) {
1357
1350
  return value.message;
1358
1351
  }
1359
1352
  if (value instanceof Date) {
@@ -1385,56 +1378,53 @@ class Module extends EventEmitter {
1385
1378
  if (cacheKey === 'throws') {
1386
1379
  throw new Error("Not able to cache");
1387
1380
  }
1388
- return cacheKey ? crypto.randomUUID() : '';
1381
+ return cacheKey ? randomUUID() : '';
1389
1382
  }
1390
1383
  static asHash(data, algorithm, encoding) {
1391
- try {
1392
- if (!algorithm && !encoding) {
1393
- return crypto.createHash("sha256").update(data).digest("hex");
1384
+ let options;
1385
+ if (isObject(algorithm)) {
1386
+ options = { ...algorithm };
1387
+ if ('algorithm' in options) {
1388
+ algorithm = options.algorithm;
1389
+ delete options.algorithm;
1394
1390
  }
1395
- let options;
1396
- if ((0, types_1.isObject)(algorithm)) {
1397
- options = { ...algorithm };
1398
- if ('algorithm' in options) {
1399
- algorithm = options.algorithm;
1400
- delete options.algorithm;
1401
- }
1402
- else {
1403
- algorithm = undefined;
1404
- }
1405
- if ('digestEncoding' in options) {
1406
- encoding = options.digestEncoding;
1407
- delete options.digestEncoding;
1408
- }
1409
- else if ('digest' in options) {
1410
- encoding = options.digest;
1411
- delete options.digest;
1412
- }
1413
- else {
1414
- encoding = undefined;
1415
- }
1391
+ else {
1392
+ algorithm = undefined;
1416
1393
  }
1417
- else if ((0, types_1.isObject)(encoding)) {
1418
- options = encoding;
1394
+ if ('digestEncoding' in options) {
1395
+ encoding = options.digestEncoding;
1396
+ delete options.digestEncoding;
1397
+ }
1398
+ else {
1419
1399
  encoding = undefined;
1420
1400
  }
1421
- return crypto.createHash(algorithm || "sha256", options).update(data).digest(encoding || "hex");
1401
+ }
1402
+ else if (isObject(encoding)) {
1403
+ options = encoding;
1404
+ encoding = undefined;
1405
+ }
1406
+ try {
1407
+ const hash = createHash(algorithm || "sha256", options);
1408
+ hash.setEncoding(encoding || "hex");
1409
+ hash.write(data);
1410
+ hash.end();
1411
+ return hash.read() || '';
1422
1412
  }
1423
1413
  catch {
1424
1414
  return '';
1425
1415
  }
1426
1416
  }
1427
1417
  static async readHash(value, options = {}) {
1428
- const { algorithm, digestEncoding = options.digest, chunkSize = 2097152000 } = options;
1429
- const hash = crypto.createHash(algorithm || "sha256");
1418
+ const { algorithm, digestEncoding, chunkSize = 2097152000 } = options;
1419
+ const hash = createHash(algorithm || "sha256");
1430
1420
  try {
1431
- const minStreamSize = (0, types_1.alignSize)(options.minStreamSize);
1421
+ const minStreamSize = alignSize(options.minStreamSize);
1432
1422
  if (fs.statSync(value).size <= Math.min(minStreamSize > 0 ? minStreamSize : Infinity, 2097152000)) {
1433
1423
  return hash.update(fs.readFileSync(value)).digest(digestEncoding || "hex");
1434
1424
  }
1435
1425
  }
1436
1426
  catch (err) {
1437
- if ((0, types_1.isErrorCode)(err, 'ENOENT', 'EACCES', 'ELOOP', 'ENAMETOOLONG', 'EINVAL')) {
1427
+ if (isErrorCode(err, 'ENOENT', 'EACCES', 'ELOOP', 'ENAMETOOLONG', 'EINVAL')) {
1438
1428
  throw err;
1439
1429
  }
1440
1430
  }
@@ -1474,7 +1464,7 @@ class Module extends EventEmitter {
1474
1464
  if (normalize && PLATFORM_WIN32) {
1475
1465
  const match = /^([A-Z]):\//.exec(pathname);
1476
1466
  if (match) {
1477
- pathname = match[1].toLowerCase() + pathname.substring(1);
1467
+ pathname = match[1].toLowerCase() + pathname.slice(1);
1478
1468
  }
1479
1469
  }
1480
1470
  if (!filename) {
@@ -1578,30 +1568,33 @@ class Module extends EventEmitter {
1578
1568
  }
1579
1569
  }
1580
1570
  catch (err) {
1581
- return !type && (0, types_1.isErrorCode)(err, 'EBUSY', 'EPERM');
1571
+ return !type && isErrorCode(err, 'EBUSY', 'EPERM');
1582
1572
  }
1583
1573
  }
1584
1574
  static isErrorCode(err, ...code) {
1585
- return (0, types_1.isErrorCode)(err, ...code);
1575
+ return isErrorCode(err, ...code);
1586
1576
  }
1587
1577
  static resolveFile(value) {
1588
- if (isFileURL(value = value instanceof URL ? value.toString() : value)) {
1578
+ if (value instanceof URL) {
1579
+ value = value.toString();
1580
+ }
1581
+ if (isFileURL(value)) {
1589
1582
  try {
1590
- return (0, node_url_1.fileURLToPath)(value);
1583
+ return fileURLToPath(value);
1591
1584
  }
1592
1585
  catch {
1593
1586
  }
1594
1587
  return '';
1595
1588
  }
1596
1589
  if (/^\\\\\?\\[A-Za-z]:\\/.test(value)) {
1597
- return PLATFORM_WIN32 && !/\\\\|\\\.+\\|\\[^\n]+?\.+\\/.test(value = value.substring(4)) ? value : '';
1590
+ return PLATFORM_WIN32 && !/\\\\|\\\.+\\|\\[^\n]+?\.+\\/.test(value = value.slice(4)) ? value : '';
1598
1591
  }
1599
1592
  return this.fromLocalPath(value) || value;
1600
1593
  }
1601
1594
  static resolvePath(value, base) {
1602
1595
  try {
1603
1596
  if (this.isURL(value)) {
1604
- return isFileURL(value) ? (0, node_url_1.fileURLToPath)(value) : new URL(value).href;
1597
+ return isFileURL(value) ? fileURLToPath(value) : new URL(value).href;
1605
1598
  }
1606
1599
  if (base instanceof URL || this.isURL(base)) {
1607
1600
  return new URL(value, base).href;
@@ -1616,7 +1609,7 @@ class Module extends EventEmitter {
1616
1609
  }
1617
1610
  static joinPath(...values) {
1618
1611
  const normalize = typeof values.at(-1) === 'boolean' && values.pop();
1619
- const paths = values.filter(item => (0, types_1.isString)(item)).map(value => this.toPosix(value, normalize));
1612
+ const paths = values.filter(item => isString(item)).map(value => this.toPosix(value, normalize));
1620
1613
  let result = paths[0] || '';
1621
1614
  for (let i = 1; i < paths.length; ++i) {
1622
1615
  const trailing = paths[i];
@@ -1646,7 +1639,7 @@ class Module extends EventEmitter {
1646
1639
  return path.join(PROCESS_CWD, value);
1647
1640
  }
1648
1641
  if (ch === '~' && value[1] === '/') {
1649
- return VALUES["permission.home_read"] ? path.join(OS_HOMEDIR, value.substring(2)) : '';
1642
+ return VALUES["permission.home_read"] ? path.join(OS_HOMEDIR, value.slice(2)) : '';
1650
1643
  }
1651
1644
  try {
1652
1645
  if (fs.existsSync(value = path.join(PROCESS_CWD, value))) {
@@ -1681,7 +1674,7 @@ class Module extends EventEmitter {
1681
1674
  }
1682
1675
  }
1683
1676
  catch (err) {
1684
- if ((0, types_1.isErrorCode)(err, 'EBUSY', 'EPERM')) {
1677
+ if (isErrorCode(err, 'EBUSY', 'EPERM')) {
1685
1678
  return false;
1686
1679
  }
1687
1680
  }
@@ -1727,7 +1720,7 @@ class Module extends EventEmitter {
1727
1720
  return Promise.reject(errorDirectory(asFile(dest) || "Unknown"));
1728
1721
  }
1729
1722
  let symFile, symDir, ignoreFile, ignoreDir, silent, overwrite;
1730
- if ((0, types_1.isObject)(move)) {
1723
+ if (isObject(move)) {
1731
1724
  ({ move, recursive, symFile, symDir, ignoreFile, ignoreDir, silent, overwrite } = move);
1732
1725
  }
1733
1726
  recursive ??= true;
@@ -1860,7 +1853,7 @@ class Module extends EventEmitter {
1860
1853
  }
1861
1854
  const pmOpts = PLATFORM_WIN32 ? { nocase: true, windows: true } : {};
1862
1855
  let exclude, excludeDir, recursive;
1863
- if ((0, types_1.isObject)(options)) {
1856
+ if (isObject(options)) {
1864
1857
  if (options.matchBase) {
1865
1858
  pmOpts.matchBase = true;
1866
1859
  }
@@ -1876,7 +1869,7 @@ class Module extends EventEmitter {
1876
1869
  exclude = [];
1877
1870
  for (const value of items) {
1878
1871
  const dirEnd = value.endsWith('/') ? /^[^/][^*]+\/$/ : value.endsWith('\\') ? /^[^\\][^*]+\\$/ : null;
1879
- if (dirEnd?.test(value) && !(0, types_1.hasGlob)(value)) {
1872
+ if (dirEnd?.test(value) && !hasGlob(value)) {
1880
1873
  (excludeDir ||= []).push(this.toPosix(value, true));
1881
1874
  }
1882
1875
  else {
@@ -1899,7 +1892,7 @@ class Module extends EventEmitter {
1899
1892
  return true;
1900
1893
  }
1901
1894
  catch (err) {
1902
- if ((0, types_1.isErrorCode)(err, 'EXDEV')) {
1895
+ if (isErrorCode(err, 'EXDEV')) {
1903
1896
  let copied = false;
1904
1897
  try {
1905
1898
  fs.copyFileSync(src, dest);
@@ -1909,7 +1902,7 @@ class Module extends EventEmitter {
1909
1902
  }
1910
1903
  catch (error) {
1911
1904
  if (copied) {
1912
- this.formatMessage(32, "WARN!", ["Unable to delete file", path.basename(src instanceof URL ? (0, node_url_1.fileURLToPath)(src) : src)], error, { ...this.LOG_STYLE_WARN });
1905
+ this.formatMessage(32, "WARN!", ["Unable to delete file", path.basename(src instanceof URL ? fileURLToPath(src) : src)], error, { ...this.LOG_STYLE_WARN });
1913
1906
  throws = false;
1914
1907
  }
1915
1908
  }
@@ -1921,7 +1914,7 @@ class Module extends EventEmitter {
1921
1914
  return false;
1922
1915
  }
1923
1916
  static async streamFile(value, cache, options) {
1924
- if ((0, types_1.isObject)(cache)) {
1917
+ if (isObject(cache)) {
1925
1918
  options = cache;
1926
1919
  }
1927
1920
  let minStreamSize = 0, encoding, signal;
@@ -1933,7 +1926,7 @@ class Module extends EventEmitter {
1933
1926
  return new Promise(async (resolve) => {
1934
1927
  const fileSize = fs.statSync(src).size;
1935
1928
  let data;
1936
- if (fileSize >= (0, types_1.alignSize)(minStreamSize) || fileSize >= 2097152000) {
1929
+ if (fileSize >= alignSize(minStreamSize) || fileSize >= 2097152000) {
1937
1930
  const readable = fs.createReadStream(src, { signal });
1938
1931
  const chunks = [];
1939
1932
  for await (const chunk of readable) {
@@ -1961,7 +1954,7 @@ class Module extends EventEmitter {
1961
1954
  cache = encoding;
1962
1955
  encoding = undefined;
1963
1956
  }
1964
- else if ((0, types_1.isObject)(encoding)) {
1957
+ else if (isObject(encoding)) {
1965
1958
  options = encoding;
1966
1959
  ({ minStreamSize, encoding, cache } = options);
1967
1960
  }
@@ -1971,7 +1964,7 @@ class Module extends EventEmitter {
1971
1964
  if (cache && (result = getCacheItem(CACHE_READTEXT, src))) {
1972
1965
  return (minStreamSize !== undefined ? Promise.resolve(result) : result);
1973
1966
  }
1974
- encoding = (0, types_1.getEncoding)(encoding);
1967
+ encoding = getEncoding(encoding);
1975
1968
  if (minStreamSize !== undefined) {
1976
1969
  return this.streamFile(src, options);
1977
1970
  }
@@ -1990,7 +1983,7 @@ class Module extends EventEmitter {
1990
1983
  }
1991
1984
  static readBuffer(value, cache) {
1992
1985
  let minStreamSize, options;
1993
- if ((0, types_1.isObject)(cache)) {
1986
+ if (isObject(cache)) {
1994
1987
  options = cache;
1995
1988
  ({ minStreamSize, cache } = options);
1996
1989
  }
@@ -2017,11 +2010,11 @@ class Module extends EventEmitter {
2017
2010
  return (minStreamSize !== undefined ? Promise.resolve(null) : null);
2018
2011
  }
2019
2012
  static async resolveMime(data) {
2020
- FILETYPE_ESM ||= await (0, types_1.importESM)('file-type');
2013
+ FILETYPE_ESM ||= await importESM('file-type');
2021
2014
  return typeof data === 'string' ? FILETYPE_ESM.fileTypeFromFile(data) : stream.Readable.isReadable(data) ? FILETYPE_ESM.fileTypeFromStream(data) : FILETYPE_ESM.fileTypeFromBuffer(data);
2022
2015
  }
2023
- static lookupMime(value, extension) {
2024
- return (extension ? mime.extension(value) : mime.lookup(value)) || '';
2016
+ static lookupMime(value, ext) {
2017
+ return (ext ? extension(value) : lookup(value)) || '';
2025
2018
  }
2026
2019
  static initCpuUsage(instance, thread = true) {
2027
2020
  if (!VALUES["node.process.cpu_usage"]) {
@@ -2073,13 +2066,13 @@ class Module extends EventEmitter {
2073
2066
  switch (unit) {
2074
2067
  case 'B':
2075
2068
  case 'KB':
2076
- return (0, types_1.formatSize)(result, { unit, decimalPlaces: 0, unitSeparator: ' ' });
2069
+ return formatSize(result, { unit, decimalPlaces: 0, unitSeparator: ' ' });
2077
2070
  case 'GB':
2078
2071
  case 'TB':
2079
2072
  case 'PB':
2080
- return (0, types_1.formatSize)(result, { unit, fixedDecimals: true, decimalPlaces: 2, unitSeparator: ' ' });
2073
+ return formatSize(result, { unit, fixedDecimals: true, decimalPlaces: 2, unitSeparator: ' ' });
2081
2074
  default:
2082
- return (0, types_1.formatSize)(result, { unit: 'MB', fixedDecimals: true, decimalPlaces: 1, unitSeparator: ' ' });
2075
+ return formatSize(result, { unit: 'MB', fixedDecimals: true, decimalPlaces: 1, unitSeparator: ' ' });
2083
2076
  }
2084
2077
  }
2085
2078
  return format ? formatPercent(result / MEM_TOTAL, 3) : result;
@@ -2131,7 +2124,7 @@ class Module extends EventEmitter {
2131
2124
  }
2132
2125
  static getPackageVersion(value, options) {
2133
2126
  let unstable, startDir, baseDir;
2134
- if ((0, types_1.isObject)(options)) {
2127
+ if (isObject(options)) {
2135
2128
  ({ unstable, startDir, baseDir } = options);
2136
2129
  }
2137
2130
  let rootPackage;
@@ -2143,7 +2136,7 @@ class Module extends EventEmitter {
2143
2136
  startDir = startDir.replace(REGEXP_PATHEND, '');
2144
2137
  let i = -1, j = PROCESS_CWD.length + 1;
2145
2138
  while ((i = startDir.indexOf(path.sep, j)) !== -1) {
2146
- const current = startDir.substring(0, i);
2139
+ const current = startDir.slice(0, i);
2147
2140
  if (!current.endsWith(path.sep + 'node_modules')) {
2148
2141
  folders.push(current);
2149
2142
  }
@@ -2154,12 +2147,12 @@ class Module extends EventEmitter {
2154
2147
  }
2155
2148
  for (let folder of folders) {
2156
2149
  if (baseDir) {
2157
- folder = path.join(baseDir, folder.substring(PROCESS_CWD.length));
2150
+ folder = path.join(baseDir, folder.slice(PROCESS_CWD.length));
2158
2151
  }
2159
2152
  try {
2160
- const pkg = path.join(folder, `node_modules/${value}/package.json`);
2161
- if (fs.existsSync(pkg)) {
2162
- const { name, version } = JSON.parse(fs.readFileSync(pkg, 'utf8'));
2153
+ const packageJSON = path.join(folder, `node_modules/${value}/package.json`);
2154
+ if (fs.existsSync(packageJSON)) {
2155
+ const { name, version } = require(packageJSON);
2163
2156
  if (name === value && typeof version === 'string') {
2164
2157
  return version.trim();
2165
2158
  }
@@ -2169,7 +2162,7 @@ class Module extends EventEmitter {
2169
2162
  }
2170
2163
  }
2171
2164
  if (setPnpmVer()) {
2172
- if ((0, types_1.isObject)(PNPM_VER)) {
2165
+ if (isObject(PNPM_VER)) {
2173
2166
  if (startDir && !baseDir) {
2174
2167
  return this.getPackageVersion(value, { unstable, startDir, baseDir: PNPM_VER.baseDir || path.join(PROCESS_CWD, 'node_modules/.pnpm') });
2175
2168
  }
@@ -2179,7 +2172,7 @@ class Module extends EventEmitter {
2179
2172
  }
2180
2173
  }
2181
2174
  }
2182
- else if (setYarnVer() && (0, types_1.isObject)(YARN_VER)) {
2175
+ else if (setYarnVer() && isObject(YARN_VER)) {
2183
2176
  folders.forEach((folder, index) => {
2184
2177
  folder = ensureDir(folder).replace(path.sep + 'node_modules' + path.sep, path.sep + 'packages' + path.sep);
2185
2178
  folders[index] = PLATFORM_WIN32 ? folder.toLowerCase() : folder;
@@ -2215,7 +2208,7 @@ class Module extends EventEmitter {
2215
2208
  }
2216
2209
  static checkSemVer(name, min = 0, max = Infinity, options) {
2217
2210
  let unstable, startDir, equals, includes;
2218
- if ((0, types_1.isObject)(min)) {
2211
+ if (isObject(min)) {
2219
2212
  ({ min = 0, max = Infinity, unstable, startDir, equals, includes } = min);
2220
2213
  }
2221
2214
  else if (options) {
@@ -2267,10 +2260,10 @@ class Module extends EventEmitter {
2267
2260
  return true;
2268
2261
  }
2269
2262
  static sanitizeCmd(value, ...args) {
2270
- return (0, types_1.sanitizeCmd)(value, ...args);
2263
+ return sanitizeCmd(value, ...args);
2271
2264
  }
2272
2265
  static sanitizeArgs(values, doubleQuote) {
2273
- return (0, types_1.sanitizeArgs)(values, doubleQuote);
2266
+ return sanitizeArgs(values, doubleQuote);
2274
2267
  }
2275
2268
  static async purgeMemory(percent = 1, limit = 0) {
2276
2269
  if (typeof limit === 'boolean') {
@@ -2286,7 +2279,7 @@ class Module extends EventEmitter {
2286
2279
  CACHE_EXEC = new WeakMap();
2287
2280
  CACHE_CPU = new WeakMap();
2288
2281
  CACHE_CPUHOST = new WeakMap();
2289
- (0, types_1.purgeMemory)();
2282
+ purgeMemory();
2290
2283
  PNPM_VER = undefined;
2291
2284
  YARN_VER = undefined;
2292
2285
  }
@@ -2314,7 +2307,7 @@ class Module extends EventEmitter {
2314
2307
  return result;
2315
2308
  }
2316
2309
  static availableParallelism(factor = 1) {
2317
- return Math.ceil(((0, types_1.supported)(19, 4) || (0, types_1.supported)(18, 14, true) ? os.availableParallelism() : os.cpus().length) * factor);
2310
+ return Math.ceil((SUPPORTED_CPUPARALLELISM ? os.availableParallelism() : os.cpus().length) * factor);
2318
2311
  }
2319
2312
  static canWrite(name) {
2320
2313
  switch (name) {
@@ -2335,7 +2328,7 @@ class Module extends EventEmitter {
2335
2328
  return false;
2336
2329
  }
2337
2330
  }
2338
- else if ((0, types_1.isString)(password)) {
2331
+ else if (isString(password)) {
2339
2332
  VALUES["process.password"] = encryptMessage(password, settings.process?.cipher);
2340
2333
  }
2341
2334
  const { temp, node, permission, memory, error, logger } = settings;
@@ -2362,7 +2355,7 @@ class Module extends EventEmitter {
2362
2355
  VALUES["node.require.ext"] = ext.trim().toLowerCase();
2363
2356
  }
2364
2357
  else if (Array.isArray(ext)) {
2365
- const items = ext.map(value => (0, types_1.isString)(value) ? value.trim().toLowerCase() : '').filter(value => value);
2358
+ const items = ext.map(value => isString(value) ? value.trim().toLowerCase() : '').filter(value => value);
2366
2359
  VALUES["node.require.ext"] = items.length > 0 ? items : '';
2367
2360
  }
2368
2361
  else {
@@ -2395,7 +2388,7 @@ class Module extends EventEmitter {
2395
2388
  if (env && typeof env.apply === 'boolean') {
2396
2389
  VALUES["process.env.apply"] = env.apply;
2397
2390
  }
2398
- if ((0, types_1.isString)(pwd)) {
2391
+ if (isString(pwd)) {
2399
2392
  VALUES["process.password"] ||= encryptMessage(pwd, cipher);
2400
2393
  }
2401
2394
  if (thread) {
@@ -2410,12 +2403,12 @@ class Module extends EventEmitter {
2410
2403
  if (typeof users === 'boolean' || Array.isArray(users)) {
2411
2404
  VALUES["memory.settings.users"] = users;
2412
2405
  }
2413
- if ((0, types_1.isPlainObject)(cache_disk)) {
2406
+ if (isPlainObject(cache_disk)) {
2414
2407
  let { enabled, min_size, max_size, expires, include, exclude } = cache_disk;
2415
2408
  MEMORY_CACHE_DISK.enabled = enabled === true;
2416
2409
  if (min_size !== undefined) {
2417
- if ((0, types_1.isString)(min_size)) {
2418
- min_size = (0, types_1.formatSize)(min_size);
2410
+ if (isString(min_size)) {
2411
+ min_size = formatSize(min_size);
2419
2412
  }
2420
2413
  else if (min_size > 0) {
2421
2414
  min_size *= 1024;
@@ -2423,15 +2416,15 @@ class Module extends EventEmitter {
2423
2416
  MEMORY_CACHE_DISK.min_size = min_size > 0 ? min_size : Infinity;
2424
2417
  }
2425
2418
  if (max_size !== undefined) {
2426
- if ((0, types_1.isString)(max_size)) {
2427
- max_size = (0, types_1.formatSize)(max_size);
2419
+ if (isString(max_size)) {
2420
+ max_size = formatSize(max_size);
2428
2421
  }
2429
2422
  else if (max_size > 0) {
2430
2423
  max_size *= 1024;
2431
2424
  }
2432
2425
  MEMORY_CACHE_DISK.max_size = max_size > 0 ? max_size : 0;
2433
2426
  }
2434
- if (expires !== undefined && (expires = (0, types_1.parseExpires)(expires)) > 0) {
2427
+ if (expires !== undefined && (expires = parseExpires(expires)) > 0) {
2435
2428
  MEMORY_CACHE_DISK.expires = expires;
2436
2429
  }
2437
2430
  MEMORY_CACHE_DISK.include = createMatchNegate(include);
@@ -2444,8 +2437,8 @@ class Module extends EventEmitter {
2444
2437
  SETTINGS.enabled = enabled;
2445
2438
  }
2446
2439
  if (level !== undefined) {
2447
- const value = (0, types_1.isString)(level) ? types_1.STATUS_TYPE[level.trim().toUpperCase()] : level;
2448
- if (value >= -1 && value <= types_1.STATUS_TYPE.TRACE) {
2440
+ const value = isString(level) ? STATUS_TYPE[level.trim().toUpperCase()] : level;
2441
+ if (value >= -1 && value <= STATUS_TYPE.TRACE) {
2449
2442
  VALUES["logger.level"] = value;
2450
2443
  }
2451
2444
  }
@@ -2459,7 +2452,7 @@ class Module extends EventEmitter {
2459
2452
  for (const section in format) {
2460
2453
  const stored = SETTINGS.format[section];
2461
2454
  const target = format[section];
2462
- if (stored && (0, types_1.isPlainObject)(target)) {
2455
+ if (stored && isPlainObject(target)) {
2463
2456
  for (let name in target) {
2464
2457
  const value = target[name];
2465
2458
  switch (name) {
@@ -2497,7 +2490,7 @@ class Module extends EventEmitter {
2497
2490
  }
2498
2491
  break;
2499
2492
  case 'as':
2500
- if ((section === 'title' || section === 'hint') && (0, types_1.isPlainObject)(value)) {
2493
+ if ((section === 'title' || section === 'hint') && isPlainObject(value)) {
2501
2494
  const data = {};
2502
2495
  for (const as in value) {
2503
2496
  if (typeof value[as] === 'string') {
@@ -2510,7 +2503,7 @@ class Module extends EventEmitter {
2510
2503
  case 'braces':
2511
2504
  switch (section) {
2512
2505
  case 'title':
2513
- if ((0, types_1.isString)(value) && value.length === 1) {
2506
+ if (isString(value) && value.length === 1) {
2514
2507
  stored[name] = value;
2515
2508
  }
2516
2509
  break;
@@ -2547,7 +2540,7 @@ class Module extends EventEmitter {
2547
2540
  target[name] = status;
2548
2541
  }
2549
2542
  }
2550
- else if ((0, types_1.isPlainObject)(status)) {
2543
+ else if (isPlainObject(status)) {
2551
2544
  for (const name in status) {
2552
2545
  if (name in target) {
2553
2546
  target[name] = !!status[name];
@@ -2574,7 +2567,7 @@ class Module extends EventEmitter {
2574
2567
  case 'process': {
2575
2568
  const proc = logger.process;
2576
2569
  if (proc) {
2577
- if ((0, types_1.isPlainObject)(proc)) {
2570
+ if (isPlainObject(proc)) {
2578
2571
  if ('cpu_bar_color' in proc) {
2579
2572
  const barColor = proc.cpu_bar_color;
2580
2573
  if (Array.isArray(barColor) && barColor.length === 3 && barColor.every(color => isBackgroundColor(color))) {
@@ -2606,7 +2599,7 @@ class Module extends EventEmitter {
2606
2599
  }
2607
2600
  }
2608
2601
  if (broadcast?.out) {
2609
- VALUES["broadcast.out"] = this.parseFunction(broadcast.out, { external: true, absolute: true });
2602
+ VALUES["broadcast.out"] = this.parseFunction(broadcast.out, { external: true, absolute: true, default: true });
2610
2603
  }
2611
2604
  if (stack_trace && stack_trace !== true && +stack_trace > 0) {
2612
2605
  Error.stackTraceLimit = +stack_trace;
@@ -2615,7 +2608,7 @@ class Module extends EventEmitter {
2615
2608
  }
2616
2609
  if (error) {
2617
2610
  if (error.out) {
2618
- VALUES["error.out"] = this.parseFunction(error.out, { external: true, absolute: true });
2611
+ VALUES["error.out"] = this.parseFunction(error.out, { external: true, absolute: true, default: true });
2619
2612
  }
2620
2613
  if (typeof error.fatal === 'boolean') {
2621
2614
  VALUES["error.fatal"] = error.fatal;
@@ -2630,7 +2623,7 @@ class Module extends EventEmitter {
2630
2623
  VALUES["permission.home_write"] = home_write;
2631
2624
  }
2632
2625
  if (Array.isArray(permission.process_exec)) {
2633
- VALUES["permission.process_exec"] = permission.process_exec.filter(item => (0, types_1.isString)(item) || (0, types_1.isObject)(item) && typeof item.command === 'string').map(exec => {
2626
+ VALUES["permission.process_exec"] = permission.process_exec.filter(item => isString(item) || isObject(item) && typeof item.command === 'string').map(exec => {
2634
2627
  if (typeof exec === 'string') {
2635
2628
  return exec.trim();
2636
2629
  }
@@ -2643,7 +2636,7 @@ class Module extends EventEmitter {
2643
2636
  }
2644
2637
  }
2645
2638
  let dir = settings.temp_dir, env, write, modified = false;
2646
- if ((0, types_1.isPlainObject)(temp)) {
2639
+ if (isPlainObject(temp)) {
2647
2640
  dir ||= temp.dir;
2648
2641
  if (!(temp.env && (env = process.env[temp.env])) && temp.os && !dir) {
2649
2642
  env = os.tmpdir();
@@ -2651,7 +2644,7 @@ class Module extends EventEmitter {
2651
2644
  write = temp.write;
2652
2645
  }
2653
2646
  if (env && this.isDir(env, true)) {
2654
- (0, types_1.setTempDir)(TEMP_DIR = stripPath(env));
2647
+ setTempDir(TEMP_DIR = stripPath(env));
2655
2648
  dir = path.relative(PROCESS_CWD, TEMP_DIR);
2656
2649
  VALUES["temp.dir"] = dir;
2657
2650
  modified = true;
@@ -2659,7 +2652,7 @@ class Module extends EventEmitter {
2659
2652
  else if (dir) {
2660
2653
  if (path.isAbsolute(dir = stripPath(dir))) {
2661
2654
  if (withinDir(dir, PROCESS_CWD)) {
2662
- dir = dir.substring(ensureDir(PROCESS_CWD).length);
2655
+ dir = dir.slice(ensureDir(PROCESS_CWD).length);
2663
2656
  }
2664
2657
  else {
2665
2658
  this.formatMessage(1, "WARN!", "Not permitted to set absolute path", dir, { ...this.LOG_STYLE_WARN, newline: true });
@@ -2668,7 +2661,7 @@ class Module extends EventEmitter {
2668
2661
  }
2669
2662
  do {
2670
2663
  const [output, index] = tryIncrementDir(path.join(PROCESS_CWD, dir), 5);
2671
- if ((0, types_1.isString)(output)) {
2664
+ if (isString(output)) {
2672
2665
  if (index > 0) {
2673
2666
  dir = trimDir(dir) + '_' + index;
2674
2667
  }
@@ -2676,10 +2669,10 @@ class Module extends EventEmitter {
2676
2669
  VALUES["temp.dir"] = dir;
2677
2670
  modified = true;
2678
2671
  }
2679
- (0, types_1.setTempDir)(TEMP_DIR = output);
2672
+ setTempDir(TEMP_DIR = output);
2680
2673
  break;
2681
2674
  }
2682
- if (output instanceof Error) {
2675
+ if (isError(output)) {
2683
2676
  this.writeFail(["Unable to create temp directory", dir], output, 32);
2684
2677
  }
2685
2678
  } while ((dir !== "tmp") && (dir = "tmp"));
@@ -2692,7 +2685,7 @@ class Module extends EventEmitter {
2692
2685
  this.formatMessage(1, 'TEMP', ["Directory was modified", dir], TEMP_DIR + (VALUES["temp.write"] ? ' - writable' : ''), { ...this.LOG_STYLE_NOTICE, newline: true });
2693
2686
  }
2694
2687
  settings.temp_dir = dir;
2695
- if ((0, types_1.isPlainObject)(temp)) {
2688
+ if (isPlainObject(temp)) {
2696
2689
  temp.dir = dir;
2697
2690
  }
2698
2691
  return true;
@@ -2717,7 +2710,7 @@ class Module extends EventEmitter {
2717
2710
  #abortController = new AbortController();
2718
2711
  #abortEvent = null;
2719
2712
  supported(major, minor, patch, lts) {
2720
- return (0, types_1.supported)(major, minor, patch, lts);
2713
+ return supported(major, minor, patch, lts);
2721
2714
  }
2722
2715
  supports(name, value, locked) {
2723
2716
  if (typeof value === 'boolean') {
@@ -2737,7 +2730,7 @@ class Module extends EventEmitter {
2737
2730
  }
2738
2731
  getTempDir(pathname, filename, createDir) {
2739
2732
  let increment = 0, moduleDir, uuidDir;
2740
- if ((0, types_1.isObject)(pathname)) {
2733
+ if (isObject(pathname)) {
2741
2734
  ({ pathname, filename, moduleDir, uuidDir, createDir, increment = 0 } = pathname);
2742
2735
  }
2743
2736
  else {
@@ -2755,18 +2748,18 @@ class Module extends EventEmitter {
2755
2748
  leading.push(this.moduleName);
2756
2749
  }
2757
2750
  let result;
2758
- if ((0, types_1.isString)(pathname)) {
2751
+ if (isString(pathname)) {
2759
2752
  leading.push(pathname);
2760
2753
  createDir ??= true;
2761
2754
  }
2762
2755
  if (uuidDir) {
2763
- leading.push(crypto.randomUUID());
2756
+ leading.push(randomUUID());
2764
2757
  createDir ??= true;
2765
2758
  }
2766
2759
  if ((createDir || increment > 0) && !_a.isDir(result = path.join(...leading))) {
2767
2760
  const [output] = tryIncrementDir(result, increment);
2768
- if (!(0, types_1.isString)(output)) {
2769
- if (output instanceof Error) {
2761
+ if (!isString(output)) {
2762
+ if (isError(output)) {
2770
2763
  this.writeFail(["Unable to create temp directory", result], output, 32);
2771
2764
  }
2772
2765
  return '';
@@ -2774,7 +2767,7 @@ class Module extends EventEmitter {
2774
2767
  result = output;
2775
2768
  }
2776
2769
  if (filename) {
2777
- const trailing = (filename.startsWith('.') ? crypto.randomUUID() : '') + filename;
2770
+ const trailing = (filename.startsWith('.') ? randomUUID() : '') + filename;
2778
2771
  if (result) {
2779
2772
  return path.join(result, trailing);
2780
2773
  }
@@ -2837,12 +2830,12 @@ class Module extends EventEmitter {
2837
2830
  return VALUES["temp.write"] && withinDir(uri, TEMP_DIR, true) || VALUES["permission.home_write"] && withinDir(uri, OS_HOMEDIR, true);
2838
2831
  }
2839
2832
  readFile(src, options = {}, callback) {
2840
- let promises;
2833
+ let promises = false;
2841
2834
  [options, promises, callback] = parseFileArgs(options, callback);
2842
2835
  const outSrc = this.#hasFileSystem(1, src, options, 0);
2843
2836
  if (outSrc) {
2844
2837
  let { encoding, requireExt, minStreamSize, cache } = options;
2845
- encoding &&= (0, types_1.getEncoding)(encoding);
2838
+ encoding &&= getEncoding(encoding);
2846
2839
  const setCache = (data, cjs) => {
2847
2840
  if (data) {
2848
2841
  if (cache || cache !== false && autoMemoryCache()) {
@@ -2852,13 +2845,13 @@ class Module extends EventEmitter {
2852
2845
  }
2853
2846
  };
2854
2847
  let result;
2855
- if (requireExt && VALUES["node.require.ext"] && hasString(requireExt === true ? VALUES["node.require.ext"] : requireExt, getExtension(outSrc))) {
2848
+ if (requireExt && VALUES["node.require.ext"] && hasString(requireExt === true ? VALUES["node.require.ext"] : requireExt, asExt(outSrc))) {
2856
2849
  if (cache) {
2857
2850
  result = getCacheItem(CACHE_READCJS, outSrc);
2858
2851
  }
2859
2852
  if (!result) {
2860
2853
  try {
2861
- result = options.default ? (0, types_1.requireESM)(outSrc, options.url) : require(outSrc);
2854
+ result = options.default ? requireESM(outSrc, options.url) : require(outSrc);
2862
2855
  setCache(result, true);
2863
2856
  checkFunction(result);
2864
2857
  }
@@ -2870,7 +2863,7 @@ class Module extends EventEmitter {
2870
2863
  result ||= (encoding ? getCacheItem(CACHE_READTEXT, outSrc) : getCacheItem(CACHE_READBUFFER, outSrc));
2871
2864
  }
2872
2865
  try {
2873
- if (!isNaN(minStreamSize = (0, types_1.alignSize)(minStreamSize)) || promises && fs.statSync(outSrc).size >= 2097152000) {
2866
+ if (!isNaN(minStreamSize = alignSize(minStreamSize)) || promises && fs.statSync(outSrc).size >= 2097152000) {
2874
2867
  if (result) {
2875
2868
  return Promise.resolve(result);
2876
2869
  }
@@ -2900,7 +2893,7 @@ class Module extends EventEmitter {
2900
2893
  return data;
2901
2894
  });
2902
2895
  }
2903
- if ((0, types_1.isFunction)(callback)) {
2896
+ if (isFunction(callback)) {
2904
2897
  if (result) {
2905
2898
  callback(null, result);
2906
2899
  }
@@ -2929,13 +2922,13 @@ class Module extends EventEmitter {
2929
2922
  if (promises) {
2930
2923
  return Promise.reject(errorPermission(src));
2931
2924
  }
2932
- if ((0, types_1.isFunction)(callback)) {
2925
+ if (isFunction(callback)) {
2933
2926
  callback(errorPermission(src));
2934
2927
  }
2935
2928
  }
2936
2929
  }
2937
2930
  writeFile(src, data, options = {}, callback) {
2938
- let promises;
2931
+ let promises = false;
2939
2932
  [options, promises, callback] = parseFileArgs(options, callback);
2940
2933
  const outSrc = this.#hasFileSystem(2, src, options, 1 | (options.overwrite === false ? 2 : 0));
2941
2934
  if (outSrc) {
@@ -2945,7 +2938,7 @@ class Module extends EventEmitter {
2945
2938
  return true;
2946
2939
  });
2947
2940
  }
2948
- if ((0, types_1.isFunction)(callback)) {
2941
+ if (isFunction(callback)) {
2949
2942
  fs.writeFile(outSrc, data, { encoding: options.encoding }, err => {
2950
2943
  if (!err) {
2951
2944
  this.emit('file:write', outSrc, options);
@@ -2968,7 +2961,7 @@ class Module extends EventEmitter {
2968
2961
  if (promises) {
2969
2962
  return Promise.reject(errorPermission(src));
2970
2963
  }
2971
- if ((0, types_1.isFunction)(callback)) {
2964
+ if (isFunction(callback)) {
2972
2965
  callback(errorPermission(src));
2973
2966
  return;
2974
2967
  }
@@ -2976,7 +2969,7 @@ class Module extends EventEmitter {
2976
2969
  return false;
2977
2970
  }
2978
2971
  deleteFile(src, options = {}, callback) {
2979
- let promises;
2972
+ let promises = false;
2980
2973
  [options, promises, callback] = parseFileArgs(options, callback);
2981
2974
  const outSrc = this.#hasFileSystem(2, src, options, 0);
2982
2975
  if (outSrc) {
@@ -2986,7 +2979,7 @@ class Module extends EventEmitter {
2986
2979
  return true;
2987
2980
  });
2988
2981
  }
2989
- if ((0, types_1.isFunction)(callback)) {
2982
+ if (isFunction(callback)) {
2990
2983
  fs.unlink(outSrc, err => {
2991
2984
  if (!err) {
2992
2985
  this.emit('file:delete', outSrc, options);
@@ -2999,7 +2992,7 @@ class Module extends EventEmitter {
2999
2992
  fs.unlinkSync(outSrc);
3000
2993
  }
3001
2994
  catch (err) {
3002
- if (!(0, types_1.isErrorCode)(err, 'ENOENT')) {
2995
+ if (!isErrorCode(err, 'ENOENT')) {
3003
2996
  this.writeFail(["Unable to delete file", path.basename(outSrc)], err, 32);
3004
2997
  return false;
3005
2998
  }
@@ -3011,7 +3004,7 @@ class Module extends EventEmitter {
3011
3004
  if (promises) {
3012
3005
  return Promise.reject(errorPermission(src));
3013
3006
  }
3014
- if ((0, types_1.isFunction)(callback)) {
3007
+ if (isFunction(callback)) {
3015
3008
  callback(errorPermission(src));
3016
3009
  return;
3017
3010
  }
@@ -3027,7 +3020,7 @@ class Module extends EventEmitter {
3027
3020
  if (promises) {
3028
3021
  return Promise.reject(errorPermission(destDir));
3029
3022
  }
3030
- if ((0, types_1.isFunction)(callback)) {
3023
+ if (isFunction(callback)) {
3031
3024
  callback(errorPermission(destDir));
3032
3025
  return;
3033
3026
  }
@@ -3043,7 +3036,7 @@ class Module extends EventEmitter {
3043
3036
  return true;
3044
3037
  });
3045
3038
  }
3046
- if ((0, types_1.isFunction)(callback)) {
3039
+ if (isFunction(callback)) {
3047
3040
  fs.copyFile(outSrc, outDest, options.mode || 0, err => {
3048
3041
  if (!err) {
3049
3042
  this.emit('file:copy', outDest, options);
@@ -3067,7 +3060,7 @@ class Module extends EventEmitter {
3067
3060
  if (promises) {
3068
3061
  return Promise.reject(errorPermission(src));
3069
3062
  }
3070
- if ((0, types_1.isFunction)(callback)) {
3063
+ if (isFunction(callback)) {
3071
3064
  callback(errorPermission(!outSrc ? src : dest));
3072
3065
  return;
3073
3066
  }
@@ -3084,7 +3077,7 @@ class Module extends EventEmitter {
3084
3077
  if (promises) {
3085
3078
  return Promise.reject(errorPermission(destDir));
3086
3079
  }
3087
- if ((0, types_1.isFunction)(callback)) {
3080
+ if (isFunction(callback)) {
3088
3081
  callback(errorPermission(destDir));
3089
3082
  return;
3090
3083
  }
@@ -3110,7 +3103,7 @@ class Module extends EventEmitter {
3110
3103
  });
3111
3104
  });
3112
3105
  }
3113
- if ((0, types_1.isFunction)(callback)) {
3106
+ if (isFunction(callback)) {
3114
3107
  fs.rename(outSrc, outDest, err => {
3115
3108
  if (err && checkExDev(err, outSrc, outDest)) {
3116
3109
  err = null;
@@ -3144,7 +3137,7 @@ class Module extends EventEmitter {
3144
3137
  if (promises) {
3145
3138
  return Promise.reject(errorPermission(src));
3146
3139
  }
3147
- if ((0, types_1.isFunction)(callback)) {
3140
+ if (isFunction(callback)) {
3148
3141
  callback(errorPermission(src));
3149
3142
  return;
3150
3143
  }
@@ -3152,7 +3145,7 @@ class Module extends EventEmitter {
3152
3145
  return false;
3153
3146
  }
3154
3147
  createDir(src, options = {}, callback) {
3155
- let promises;
3148
+ let promises = false;
3156
3149
  [options, promises, callback] = parseFileArgs(options, callback);
3157
3150
  const outSrc = this.#hasFileSystem(2, src, options, 1);
3158
3151
  if (outSrc) {
@@ -3160,7 +3153,7 @@ class Module extends EventEmitter {
3160
3153
  if (promises) {
3161
3154
  return Promise.resolve(true);
3162
3155
  }
3163
- if ((0, types_1.isFunction)(callback)) {
3156
+ if (isFunction(callback)) {
3164
3157
  callback(null);
3165
3158
  return;
3166
3159
  }
@@ -3171,7 +3164,7 @@ class Module extends EventEmitter {
3171
3164
  if (promises) {
3172
3165
  return Promise.reject(errorDirectory(outSrc));
3173
3166
  }
3174
- if ((0, types_1.isFunction)(callback)) {
3167
+ if (isFunction(callback)) {
3175
3168
  callback(errorDirectory(outSrc));
3176
3169
  return;
3177
3170
  }
@@ -3180,7 +3173,7 @@ class Module extends EventEmitter {
3180
3173
  }
3181
3174
  }
3182
3175
  else {
3183
- if (promises || (0, types_1.isFunction)(callback)) {
3176
+ if (promises || isFunction(callback)) {
3184
3177
  const result = new Promise(resolve => {
3185
3178
  resolve(tryCreateDir(outSrc));
3186
3179
  }).then(success => {
@@ -3212,7 +3205,7 @@ class Module extends EventEmitter {
3212
3205
  if (promises) {
3213
3206
  return Promise.reject(errorPermission(src));
3214
3207
  }
3215
- if ((0, types_1.isFunction)(callback)) {
3208
+ if (isFunction(callback)) {
3216
3209
  callback(errorPermission(src));
3217
3210
  return;
3218
3211
  }
@@ -3220,14 +3213,14 @@ class Module extends EventEmitter {
3220
3213
  return false;
3221
3214
  }
3222
3215
  removeDir(src, options = {}, callback) {
3223
- let promises;
3216
+ let promises = false;
3224
3217
  [options, promises, callback] = parseFileArgs(options, callback);
3225
3218
  const outSrc = this.#hasFileSystem(2, src, options, 1);
3226
3219
  if (outSrc) {
3227
3220
  try {
3228
3221
  if (_a.isDir(outSrc)) {
3229
3222
  const { emptyDir = false, recursive } = options;
3230
- if (promises || (0, types_1.isFunction)(callback)) {
3223
+ if (promises || isFunction(callback)) {
3231
3224
  const result = new Promise((resolve, reject) => {
3232
3225
  const failed = tryRemoveDir(outSrc, emptyDir, !!recursive);
3233
3226
  if (failed.length === 0) {
@@ -3262,7 +3255,7 @@ class Module extends EventEmitter {
3262
3255
  if (promises) {
3263
3256
  return Promise.reject(errorDirectory(outSrc));
3264
3257
  }
3265
- if ((0, types_1.isFunction)(callback)) {
3258
+ if (isFunction(callback)) {
3266
3259
  callback(errorDirectory(outSrc));
3267
3260
  return;
3268
3261
  }
@@ -3271,7 +3264,7 @@ class Module extends EventEmitter {
3271
3264
  if (promises) {
3272
3265
  return Promise.resolve(true);
3273
3266
  }
3274
- if ((0, types_1.isFunction)(callback)) {
3267
+ if (isFunction(callback)) {
3275
3268
  callback(null);
3276
3269
  return;
3277
3270
  }
@@ -3287,7 +3280,7 @@ class Module extends EventEmitter {
3287
3280
  if (promises) {
3288
3281
  return Promise.reject(errorPermission(src));
3289
3282
  }
3290
- if ((0, types_1.isFunction)(callback)) {
3283
+ if (isFunction(callback)) {
3291
3284
  callback(errorPermission(src));
3292
3285
  return;
3293
3286
  }
@@ -3315,7 +3308,7 @@ class Module extends EventEmitter {
3315
3308
  }
3316
3309
  writeFail(value, message, options) {
3317
3310
  let type;
3318
- if ((0, types_1.isObject)(options)) {
3311
+ if (isObject(options)) {
3319
3312
  ({ type } = options);
3320
3313
  }
3321
3314
  else {
@@ -3324,7 +3317,7 @@ class Module extends EventEmitter {
3324
3317
  }
3325
3318
  options = {};
3326
3319
  }
3327
- this.formatFail(type || types_1.LOG_TYPE.SYSTEM, "FAIL!", value, message, options);
3320
+ this.formatFail(type || LOG_TYPE.SYSTEM, "FAIL!", value, message, options);
3328
3321
  }
3329
3322
  writeTimeProcess(title, value, startTime, options = {}) {
3330
3323
  const { type = 0, statusType = 0 } = options;
@@ -3334,11 +3327,11 @@ class Module extends EventEmitter {
3334
3327
  const increment = options.meterIncrement || (http ? meter.http
3335
3328
  : type & 2048 ? meter.image
3336
3329
  : type & 8 ? meter.compress
3337
- : meter.process) || types_1.THRESHOLD.LOGGER_METER_INCREMENT;
3330
+ : meter.process) || THRESHOLD.LOGGER_METER_INCREMENT;
3338
3331
  const duration = getTimeOffset(startTime, 0);
3339
3332
  let meterTime = duration, delayTime = options.delayTime;
3340
3333
  if (typeof delayTime === 'bigint' || Array.isArray(delayTime)) {
3341
- delayTime = Math.max((0, types_1.convertTime)(delayTime), 0);
3334
+ delayTime = Math.max(convertTime(delayTime), 0);
3342
3335
  if (delayTime < meterTime) {
3343
3336
  meterTime -= delayTime;
3344
3337
  }
@@ -3364,14 +3357,14 @@ class Module extends EventEmitter {
3364
3357
  this.addLog(statusType, value, typeof startTime === 'number' ? startTime : undefined, duration);
3365
3358
  }
3366
3359
  if (!options.bypassLog) {
3367
- this.addLog(types_1.STATUS_TYPE.INFO, title + ': ' + value, Date.now(), duration);
3360
+ this.addLog(STATUS_TYPE.INFO, title + ': ' + value, Date.now(), duration);
3368
3361
  }
3369
3362
  if (options.queue && !this._logFlushed) {
3370
3363
  this._logQueued.push(args);
3371
3364
  }
3372
3365
  else if (!this.silent) {
3373
- setCpuAndMem(this, options);
3374
- relayMessage(this, args);
3366
+ this.#setCpuAndMem(options);
3367
+ this.relayMessage(args);
3375
3368
  }
3376
3369
  }
3377
3370
  writeTimeElapsed(title, value, startTime, options = {}) {
@@ -3382,7 +3375,7 @@ class Module extends EventEmitter {
3382
3375
  value = value[0];
3383
3376
  }
3384
3377
  else if (options.showCpu) {
3385
- setCpuAndMem(this, options);
3378
+ this.#setCpuAndMem(options);
3386
3379
  }
3387
3380
  else {
3388
3381
  message = value;
@@ -3405,7 +3398,7 @@ class Module extends EventEmitter {
3405
3398
  this._logQueued.push(args);
3406
3399
  }
3407
3400
  else if (!this.silent) {
3408
- relayMessage(this, args);
3401
+ this.relayMessage(args);
3409
3402
  }
3410
3403
  }
3411
3404
  formatFail(type, title, value, message, options = {}) {
@@ -3447,9 +3440,9 @@ class Module extends EventEmitter {
3447
3440
  let fatal = false;
3448
3441
  if (options.exec && (type & 4096) && target.willAbort("(exec)")) {
3449
3442
  const exec = { ...options.exec };
3450
- let output = VALUES["permission.process_exec"].find(item => exec.command === ((0, types_1.isObject)(item) ? item.command : item));
3443
+ let output = VALUES["permission.process_exec"].find(item => exec.command === (isObject(item) ? item.command : item));
3451
3444
  if (output) {
3452
- if ((0, types_1.isPlainObject)(output)) {
3445
+ if (isPlainObject(output)) {
3453
3446
  output = { ...output };
3454
3447
  if (Array.isArray(output.warn)) {
3455
3448
  (exec.warn ||= []).push(...output.warn);
@@ -3502,7 +3495,8 @@ class Module extends EventEmitter {
3502
3495
  (type & 2048) && target.willAbort("(image)") ||
3503
3496
  (type & 4096) && target.willAbort("(exec)") ||
3504
3497
  (type & 16384) && target.willAbort("(timeout)") ||
3505
- (type & 65536) && target.willAbort("(db)")) {
3498
+ (type & 65536) && target.willAbort("(db)") ||
3499
+ (type & 131072) && target.willAbort("(user)") && host?.username) {
3506
3500
  if (host) {
3507
3501
  if (host.abortable) {
3508
3502
  host.abort();
@@ -3516,15 +3510,15 @@ class Module extends EventEmitter {
3516
3510
  }
3517
3511
  }
3518
3512
  if (message) {
3519
- if (this._logEnabled && !(message instanceof Error && hideAbort(message))) {
3513
+ if (this._logEnabled && !(isError(message) && hideAbort(message))) {
3520
3514
  if (fatal) {
3521
3515
  const timeStamp = Date.now();
3522
- this.addLog(types_1.STATUS_TYPE.FATAL, message, timeStamp, options.startTime ? getTimeOffset(options.startTime, timeStamp) : undefined);
3516
+ this.addLog(STATUS_TYPE.FATAL, message, timeStamp, options.startTime ? getTimeOffset(options.startTime, timeStamp) : undefined);
3523
3517
  }
3524
3518
  else {
3525
- this.addLog(options.statusType || types_1.STATUS_TYPE.ERROR, message);
3519
+ this.addLog(options.statusType || STATUS_TYPE.ERROR, message);
3526
3520
  }
3527
- this.errors.push(message instanceof Error ? formatError(message) : message);
3521
+ this.errors.push(isError(message) ? formatError(message) : message);
3528
3522
  }
3529
3523
  if (this.listenerCount('error') > 0) {
3530
3524
  this.emit('error', errorObject(message));
@@ -3548,7 +3542,7 @@ class Module extends EventEmitter {
3548
3542
  this._logQueued.push(args);
3549
3543
  }
3550
3544
  else if (!this.silent) {
3551
- relayMessage(this, args);
3545
+ this.relayMessage(args);
3552
3546
  }
3553
3547
  }
3554
3548
  checkPackage(err, name, value, options) {
@@ -3556,16 +3550,16 @@ class Module extends EventEmitter {
3556
3550
  options = value;
3557
3551
  value = undefined;
3558
3552
  }
3559
- else if ((0, types_1.isPlainObject)(value)) {
3553
+ else if (isPlainObject(value)) {
3560
3554
  options = value;
3561
3555
  value = undefined;
3562
3556
  }
3563
- if (name && (0, types_1.isErrorCode)(err, types_1.ERR_CODE.MODULE_NOT_FOUND, types_1.ERR_CODE.ERR_MODULE_NOT_FOUND)) {
3557
+ if (name && isErrorCode(err, ERR_CODE.MODULE_NOT_FOUND, ERR_CODE.ERR_MODULE_NOT_FOUND)) {
3564
3558
  if (typeof options === 'number') {
3565
3559
  options = undefined;
3566
3560
  }
3567
3561
  const command = VALUES["node.settings.package_manager"] || (setPnpmVer() ? 'pnpm' : setYarnVer() ? 'yarn' : 'npm');
3568
- this.writeFail("Package not found", err, { ...options, type: types_1.LOG_TYPE.SYSTEM, code: err.code, exec: { command, args: [command === 'npm' ? 'i' : 'add', name] } });
3562
+ this.writeFail("Package not found", err, { ...options, type: LOG_TYPE.SYSTEM, code: err.code, exec: { command, args: [command === 'npm' ? 'i' : 'add', name] } });
3569
3563
  return true;
3570
3564
  }
3571
3565
  if (value) {
@@ -3574,9 +3568,9 @@ class Module extends EventEmitter {
3574
3568
  return false;
3575
3569
  }
3576
3570
  checkFail(message, options) {
3577
- switch (options.code || message instanceof Error && message.code) {
3578
- case types_1.ERR_CODE.MODULE_NOT_FOUND:
3579
- case types_1.ERR_CODE.ERR_MODULE_NOT_FOUND:
3571
+ switch (options.code || isError(message) && message.code) {
3572
+ case ERR_CODE.MODULE_NOT_FOUND:
3573
+ case ERR_CODE.ERR_MODULE_NOT_FOUND:
3580
3574
  if (options.exec) {
3581
3575
  if (!this.aborted) {
3582
3576
  const command = options.exec.command + (options.exec.args ? ' ' + options.exec.args.join(' ') : '');
@@ -3605,7 +3599,7 @@ class Module extends EventEmitter {
3605
3599
  }
3606
3600
  writeLog(type, value, timeStamp, duration) {
3607
3601
  let queue = false;
3608
- if ((0, types_1.isObject)(type)) {
3602
+ if (isObject(type)) {
3609
3603
  if (typeof value === 'boolean') {
3610
3604
  queue = value;
3611
3605
  }
@@ -3613,7 +3607,7 @@ class Module extends EventEmitter {
3613
3607
  }
3614
3608
  const output = _a.asString(value);
3615
3609
  if (output) {
3616
- if ((queue || (0, types_1.isPlainObject)(timeStamp) && timeStamp.queue) && !this._logFlushed) {
3610
+ if ((queue || isPlainObject(timeStamp) && timeStamp.queue) && !this._logFlushed) {
3617
3611
  this._logQueued.push([-1, output]);
3618
3612
  }
3619
3613
  else {
@@ -3626,8 +3620,8 @@ class Module extends EventEmitter {
3626
3620
  if (!this._logEnabled || SETTINGS.production && process.env.NODE_ENV === 'production' && (SETTINGS.production.includes(this.moduleName) || from && SETTINGS.production.includes(from))) {
3627
3621
  return;
3628
3622
  }
3629
- if ((0, types_1.isObject)(type)) {
3630
- ({ type = types_1.STATUS_TYPE.UNKNOWN, value, timeStamp, duration, from, source } = type);
3623
+ if (isObject(type)) {
3624
+ ({ type = STATUS_TYPE.UNKNOWN, value, timeStamp, duration, from, source } = type);
3631
3625
  }
3632
3626
  else if (typeof timeStamp === 'string') {
3633
3627
  if (typeof duration === 'string') {
@@ -3637,12 +3631,12 @@ class Module extends EventEmitter {
3637
3631
  from = timeStamp;
3638
3632
  timeStamp = 0;
3639
3633
  }
3640
- else if ((0, types_1.isPlainObject)(timeStamp)) {
3634
+ else if (isPlainObject(timeStamp)) {
3641
3635
  ({ timeStamp, duration, from, source } = timeStamp);
3642
3636
  }
3643
- const name = types_1.STATUS_TYPE[type] || types_1.STATUS_TYPE[type = 0];
3637
+ const name = STATUS_TYPE[type] || STATUS_TYPE[type = 0];
3644
3638
  const logLevel = this.logLevel;
3645
- if ((0, types_1.isEmpty)(value) || logLevel > 0 && (type > logLevel || type === 0 && logLevel < types_1.STATUS_TYPE.DEBUG) || SETTINGS.status[name.toLowerCase()] === false) {
3639
+ if (isEmpty(value) || logLevel > 0 && (type > logLevel || type === 0 && logLevel < STATUS_TYPE.DEBUG) || SETTINGS.status[name.toLowerCase()] === false) {
3646
3640
  return;
3647
3641
  }
3648
3642
  let message = '';
@@ -3660,15 +3654,15 @@ class Module extends EventEmitter {
3660
3654
  duration = undefined;
3661
3655
  }
3662
3656
  if (typeof value === 'string') {
3663
- message = this.supports('stripAnsi') ? (0, node_util_1.stripVTControlCharacters)(value) : value;
3657
+ message = this.supports('stripAnsi') ? stripVTControlCharacters(value) : value;
3664
3658
  }
3665
- else if (value instanceof Error) {
3659
+ else if (isError(value)) {
3666
3660
  if (value.name === 'AbortError') {
3667
3661
  return;
3668
3662
  }
3669
3663
  if (value.stack && SETTINGS.status.trace) {
3670
3664
  message = value.message;
3671
- this.status.push({ type: types_1.STATUS_TYPE.TRACE, value: message ? value.stack.replace(message, '').trim() : value.stack, timeStamp, name: types_1.STATUS_TYPE[types_1.STATUS_TYPE.TRACE], duration, sessionId: this.sessionId, from: this.moduleName, source });
3665
+ this.status.push({ type: STATUS_TYPE.TRACE, value: message ? value.stack.replace(message, '').trim() : value.stack, timeStamp, name: STATUS_TYPE[STATUS_TYPE.TRACE], duration, sessionId: this.sessionId, from: this.moduleName, source });
3672
3666
  }
3673
3667
  else {
3674
3668
  message = formatError(value);
@@ -3695,15 +3689,15 @@ class Module extends EventEmitter {
3695
3689
  if (args.length === 2) {
3696
3690
  const [type, value] = args;
3697
3691
  if (this.broadcastId) {
3698
- _a.formatMessage(type, '', this.supports('stripAnsi') ? (0, node_util_1.stripVTControlCharacters)(value) : value, null, this.#applySessionId({ sessionId: '' }));
3692
+ _a.formatMessage(type, '', this.supports('stripAnsi') ? stripVTControlCharacters(value) : value, null, this.#applySessionId({ sessionId: '' }));
3699
3693
  }
3700
3694
  else {
3701
3695
  writeLine(args[1]);
3702
- (0, types_1.setLogCurrent)({ type, value });
3696
+ setLogCurrent({ type, value });
3703
3697
  }
3704
3698
  }
3705
3699
  else {
3706
- relayMessage(this, args);
3700
+ this.relayMessage(args);
3707
3701
  }
3708
3702
  }
3709
3703
  logQueued.length = 0;
@@ -3766,12 +3760,24 @@ class Module extends EventEmitter {
3766
3760
  }
3767
3761
  }
3768
3762
  isFatal(err) {
3769
- if (err instanceof Error) {
3763
+ if (isError(err)) {
3770
3764
  const fatal = this.host?.config.error?.fatal;
3771
3765
  return fatal ?? VALUES["error.fatal"];
3772
3766
  }
3773
3767
  return false;
3774
3768
  }
3769
+ relayMessage(args) {
3770
+ const host = this.host;
3771
+ if (host?.logState === 0) {
3772
+ host.delayMessage(args);
3773
+ }
3774
+ else {
3775
+ _a.formatMessage(...args);
3776
+ }
3777
+ }
3778
+ supportsProperty(name) {
3779
+ return !(name in this.#supports) || this.supports(name);
3780
+ }
3775
3781
  #hasFileSystem(type, value, options, flags) {
3776
3782
  const fsWrite = (type & 2) === 2;
3777
3783
  let result;
@@ -3790,19 +3796,19 @@ class Module extends EventEmitter {
3790
3796
  }
3791
3797
  else if (!(result = _a.fromLocalPath(value))) {
3792
3798
  if (options.throwsDoesNotExist) {
3793
- throw (0, types_1.errorValue)("File not found", value);
3799
+ throw errorValue("File not found", value);
3794
3800
  }
3795
3801
  return '';
3796
3802
  }
3797
3803
  if ((flags & 2) === 2 && _a.isPath(result)) {
3798
3804
  if (options.throwsPermission) {
3799
- throw (0, types_1.errorValue)("Not permitted to overwrite file", value);
3805
+ throw errorValue("Not permitted to overwrite file", value);
3800
3806
  }
3801
3807
  return '';
3802
3808
  }
3803
3809
  if ((flags & 1) === 0 && !_a.isPath(result)) {
3804
3810
  if (options.throwsDoesNotExist) {
3805
- throw (0, types_1.errorValue)("File not found", value);
3811
+ throw errorValue("File not found", value);
3806
3812
  }
3807
3813
  return '';
3808
3814
  }
@@ -3867,7 +3873,7 @@ class Module extends EventEmitter {
3867
3873
  }
3868
3874
  }
3869
3875
  else if (!this.supports('stripAnsi')) {
3870
- if ((0, types_1.isPlainObject)(value)) {
3876
+ if (isPlainObject(value)) {
3871
3877
  value.stripAnsi = false;
3872
3878
  }
3873
3879
  else {
@@ -3876,8 +3882,13 @@ class Module extends EventEmitter {
3876
3882
  }
3877
3883
  return options;
3878
3884
  }
3879
- supportsProperty(name) {
3880
- return !(name in this.#supports) || this.supports(name);
3885
+ #setCpuAndMem(options) {
3886
+ if (!options.messageUnit) {
3887
+ const usage = CACHE_CPUHOST.get(this) || this.host && CACHE_CPUHOST.get(this.host);
3888
+ if (usage) {
3889
+ options.messageUnit = _a.formatCpuMem(usage);
3890
+ }
3891
+ }
3881
3892
  }
3882
3893
  get moduleName() {
3883
3894
  return this._moduleName;
@@ -3953,13 +3964,13 @@ class Module extends EventEmitter {
3953
3964
  return this._silent ?? this.host?.silent ?? false;
3954
3965
  }
3955
3966
  get logType() {
3956
- return types_1.LOG_TYPE;
3967
+ return LOG_TYPE;
3957
3968
  }
3958
3969
  set logLevel(value) {
3959
- if ((0, types_1.isString)(value)) {
3960
- value = types_1.STATUS_TYPE[value.toUpperCase()];
3970
+ if (isString(value)) {
3971
+ value = STATUS_TYPE[value.toUpperCase()];
3961
3972
  }
3962
- if (value >= 0 && value <= types_1.STATUS_TYPE.TRACE) {
3973
+ if (value >= 0 && value <= STATUS_TYPE.TRACE) {
3963
3974
  this._logLevel = value;
3964
3975
  }
3965
3976
  }
@@ -3972,14 +3983,14 @@ class Module extends EventEmitter {
3972
3983
  return host ? host.logLevel : 0;
3973
3984
  }
3974
3985
  get statusType() {
3975
- return types_1.STATUS_TYPE;
3986
+ return STATUS_TYPE;
3976
3987
  }
3977
3988
  set tempDir(value) {
3978
3989
  if (path.isAbsolute(value)) {
3979
3990
  if (!withinDir(value, PROCESS_CWD)) {
3980
3991
  return;
3981
3992
  }
3982
- value = value.substring(ensureDir(PROCESS_CWD).length);
3993
+ value = value.slice(ensureDir(PROCESS_CWD).length);
3983
3994
  }
3984
3995
  if (_a.isDir(path.join(PROCESS_CWD, value))) {
3985
3996
  this.#tempDir = value;
@@ -3991,7 +4002,8 @@ class Module extends EventEmitter {
3991
4002
  }
3992
4003
  _a = Module;
3993
4004
  EventEmitter.defaultMaxListeners = Infinity;
3994
- Object.freeze(types_1.LOG_TYPE);
3995
- Object.freeze(types_1.STATUS_TYPE);
4005
+ Object.freeze(LOG_TYPE);
4006
+ Object.freeze(STATUS_TYPE);
3996
4007
  setLogMinWidth();
4008
+
3997
4009
  module.exports = Module;