@wdio/logger 10.1.0-alpha.29 → 10.1.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.
Files changed (2) hide show
  1. package/build/index.cjs +167 -100
  2. package/package.json +3 -3
package/build/index.cjs CHANGED
@@ -92,11 +92,43 @@ var import_node_fs = __toESM(require("node:fs"), 1);
92
92
  var import_node_util = __toESM(require("node:util"), 1);
93
93
  var import_loglevel = __toESM(require("loglevel"), 1);
94
94
 
95
- // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
95
+ // ../../node_modules/.pnpm/chalk@6.0.1/node_modules/chalk/source/utilities.js
96
+ function stringReplaceAll(string, substring, postfix) {
97
+ let index = string.indexOf(substring);
98
+ if (index === -1) {
99
+ return string;
100
+ }
101
+ const substringLength = substring.length;
102
+ let endIndex = 0;
103
+ let returnValue = "";
104
+ do {
105
+ returnValue += string.slice(endIndex, index) + substring + postfix;
106
+ endIndex = index + substringLength;
107
+ index = string.indexOf(substring, endIndex);
108
+ } while (index !== -1);
109
+ returnValue += string.slice(endIndex);
110
+ return returnValue;
111
+ }
112
+ function stringEncaseCRLFWithFirstIndex(string, prefix2, postfix, index) {
113
+ let endIndex = 0;
114
+ let returnValue = "";
115
+ do {
116
+ const isGotCR = string[index - 1] === "\r";
117
+ returnValue += string.slice(endIndex, isGotCR ? index - 1 : index) + prefix2 + (isGotCR ? "\r\n" : "\n") + postfix;
118
+ endIndex = index + 1;
119
+ index = string.indexOf("\n", endIndex);
120
+ } while (index !== -1);
121
+ returnValue += string.slice(endIndex);
122
+ return returnValue;
123
+ }
124
+
125
+ // ../../node_modules/.pnpm/chalk@6.0.1/node_modules/chalk/source/vendor/ansi-styles/index.js
96
126
  var ANSI_BACKGROUND_OFFSET = 10;
127
+ var ANSI_UNDERLINE_OFFSET = 20;
97
128
  var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
98
129
  var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
99
130
  var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
131
+ var wrapUnderlineAnsi = (code) => `\x1B[58;5;${code < 90 ? code - 30 : code - 90 + 8}m`;
100
132
  var styles = {
101
133
  modifier: {
102
134
  reset: [0, 0],
@@ -105,6 +137,11 @@ var styles = {
105
137
  dim: [2, 22],
106
138
  italic: [3, 23],
107
139
  underline: [4, 24],
140
+ // Extended underline styles (`SGR 4:x` sub-parameters). Not in upstream `ansi-styles`.
141
+ underlineDouble: ["4:2", 24],
142
+ underlineCurly: ["4:3", 24],
143
+ underlineDotted: ["4:4", 24],
144
+ underlineDashed: ["4:5", 24],
108
145
  overline: [53, 55],
109
146
  inverse: [7, 27],
110
147
  hidden: [8, 28],
@@ -155,11 +192,36 @@ var styles = {
155
192
  bgMagentaBright: [105, 49],
156
193
  bgCyanBright: [106, 49],
157
194
  bgWhiteBright: [107, 49]
195
+ },
196
+ // Underline color (`SGR 58`/`59`). Not in upstream `ansi-styles`.
197
+ underlineColor: {
198
+ underlineBlack: ["58;5;0", 59],
199
+ underlineRed: ["58;5;1", 59],
200
+ underlineGreen: ["58;5;2", 59],
201
+ underlineYellow: ["58;5;3", 59],
202
+ underlineBlue: ["58;5;4", 59],
203
+ underlineMagenta: ["58;5;5", 59],
204
+ underlineCyan: ["58;5;6", 59],
205
+ underlineWhite: ["58;5;7", 59],
206
+ // Bright color
207
+ underlineBlackBright: ["58;5;8", 59],
208
+ underlineGray: ["58;5;8", 59],
209
+ // Alias of `underlineBlackBright`
210
+ underlineGrey: ["58;5;8", 59],
211
+ // Alias of `underlineBlackBright`
212
+ underlineRedBright: ["58;5;9", 59],
213
+ underlineGreenBright: ["58;5;10", 59],
214
+ underlineYellowBright: ["58;5;11", 59],
215
+ underlineBlueBright: ["58;5;12", 59],
216
+ underlineMagentaBright: ["58;5;13", 59],
217
+ underlineCyanBright: ["58;5;14", 59],
218
+ underlineWhiteBright: ["58;5;15", 59]
158
219
  }
159
220
  };
160
221
  var modifierNames = Object.keys(styles.modifier);
161
222
  var foregroundColorNames = Object.keys(styles.color);
162
223
  var backgroundColorNames = Object.keys(styles.bgColor);
224
+ var underlineColorNames = Object.keys(styles.underlineColor);
163
225
  var colorNames = [...foregroundColorNames, ...backgroundColorNames];
164
226
  function assembleStyles() {
165
227
  const codes = /* @__PURE__ */ new Map();
@@ -170,7 +232,7 @@ function assembleStyles() {
170
232
  close: `\x1B[${style[1]}m`
171
233
  };
172
234
  group[styleName] = styles[styleName];
173
- codes.set(style[0], style[1]);
235
+ codes.set(Number.parseInt(style[0], 10), style[1]);
174
236
  }
175
237
  Object.defineProperty(styles, groupName, {
176
238
  value: group,
@@ -183,12 +245,16 @@ function assembleStyles() {
183
245
  });
184
246
  styles.color.close = "\x1B[39m";
185
247
  styles.bgColor.close = "\x1B[49m";
248
+ styles.underlineColor.close = "\x1B[59m";
186
249
  styles.color.ansi = wrapAnsi16();
187
250
  styles.color.ansi256 = wrapAnsi256();
188
251
  styles.color.ansi16m = wrapAnsi16m();
189
252
  styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
190
253
  styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
191
254
  styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
255
+ styles.underlineColor.ansi = wrapUnderlineAnsi;
256
+ styles.underlineColor.ansi256 = wrapAnsi256(ANSI_UNDERLINE_OFFSET);
257
+ styles.underlineColor.ansi16m = wrapAnsi16m(ANSI_UNDERLINE_OFFSET);
192
258
  Object.defineProperties(styles, {
193
259
  rgbToAnsi256: {
194
260
  value(red, green, blue) {
@@ -207,7 +273,7 @@ function assembleStyles() {
207
273
  },
208
274
  hexToRgb: {
209
275
  value(hex) {
210
- const matches2 = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
276
+ const matches2 = /[\da-f]{6}|[\da-f]{3}/i.exec(hex.toString(16));
211
277
  if (!matches2) {
212
278
  return [0, 0, 0];
213
279
  }
@@ -217,7 +283,7 @@ function assembleStyles() {
217
283
  }
218
284
  const integer = Number.parseInt(colorString, 16);
219
285
  return [
220
- /* eslint-disable no-bitwise */
286
+ /* eslint-disable no-bitwise -- We need the speed */
221
287
  integer >> 16 & 255,
222
288
  integer >> 8 & 255,
223
289
  integer & 255
@@ -278,7 +344,7 @@ function assembleStyles() {
278
344
  var ansiStyles = assembleStyles();
279
345
  var ansi_styles_default = ansiStyles;
280
346
 
281
- // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js
347
+ // ../../node_modules/.pnpm/chalk@6.0.1/node_modules/chalk/source/vendor/supports-color/index.js
282
348
  var import_node_process = __toESM(require("node:process"), 1);
283
349
  var import_node_os = __toESM(require("node:os"), 1);
284
350
  var import_node_tty = __toESM(require("node:tty"), 1);
@@ -295,16 +361,23 @@ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || has
295
361
  } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
296
362
  flagForceColor = 1;
297
363
  }
364
+ function hasNumericForceColor() {
365
+ return /^\d+$/.test(env.FORCE_COLOR);
366
+ }
298
367
  function envForceColor() {
299
- if ("FORCE_COLOR" in env) {
300
- if (env.FORCE_COLOR === "true") {
301
- return 1;
302
- }
303
- if (env.FORCE_COLOR === "false") {
304
- return 0;
305
- }
306
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
368
+ if (!("FORCE_COLOR" in env)) {
369
+ return;
370
+ }
371
+ if (env.FORCE_COLOR === "false") {
372
+ return 0;
373
+ }
374
+ if (env.FORCE_COLOR === "true" || env.FORCE_COLOR.length === 0) {
375
+ return 1;
307
376
  }
377
+ if (!hasNumericForceColor()) {
378
+ return;
379
+ }
380
+ return Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
308
381
  }
309
382
  function translateLevel(level) {
310
383
  if (level === 0) {
@@ -334,6 +407,9 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
334
407
  return 2;
335
408
  }
336
409
  }
410
+ if (forceColor !== void 0 && hasNumericForceColor()) {
411
+ return forceColor;
412
+ }
337
413
  if ("TF_BUILD" in env && "AGENT_NAME" in env) {
338
414
  return 1;
339
415
  }
@@ -361,7 +437,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
361
437
  return min;
362
438
  }
363
439
  if ("TEAMCITY_VERSION" in env) {
364
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
440
+ return /^(?:9\.0*[1-9]\d*\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
365
441
  }
366
442
  if (env.COLORTERM === "truecolor") {
367
443
  return 3;
@@ -376,7 +452,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
376
452
  return 3;
377
453
  }
378
454
  if ("TERM_PROGRAM" in env) {
379
- const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
455
+ const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".", 1)[0], 10);
380
456
  switch (env.TERM_PROGRAM) {
381
457
  case "iTerm.app": {
382
458
  return version >= 3 ? 3 : 2;
@@ -386,7 +462,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
386
462
  }
387
463
  }
388
464
  }
389
- if (/-256(color)?$/i.test(env.TERM)) {
465
+ if (/-256(?:color)?$/i.test(env.TERM)) {
390
466
  return 2;
391
467
  }
392
468
  if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
@@ -410,54 +486,34 @@ var supportsColor = {
410
486
  };
411
487
  var supports_color_default = supportsColor;
412
488
 
413
- // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.js
414
- function stringReplaceAll(string, substring, replacer) {
415
- let index = string.indexOf(substring);
416
- if (index === -1) {
417
- return string;
418
- }
419
- const substringLength = substring.length;
420
- let endIndex = 0;
421
- let returnValue = "";
422
- do {
423
- returnValue += string.slice(endIndex, index) + substring + replacer;
424
- endIndex = index + substringLength;
425
- index = string.indexOf(substring, endIndex);
426
- } while (index !== -1);
427
- returnValue += string.slice(endIndex);
428
- return returnValue;
429
- }
430
- function stringEncaseCRLFWithFirstIndex(string, prefix2, postfix, index) {
431
- let endIndex = 0;
432
- let returnValue = "";
433
- do {
434
- const gotCR = string[index - 1] === "\r";
435
- returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix2 + (gotCR ? "\r\n" : "\n") + postfix;
436
- endIndex = index + 1;
437
- index = string.indexOf("\n", endIndex);
438
- } while (index !== -1);
439
- returnValue += string.slice(endIndex);
440
- return returnValue;
441
- }
442
-
443
- // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.js
489
+ // ../../node_modules/.pnpm/chalk@6.0.1/node_modules/chalk/source/index.js
444
490
  var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
445
491
  var GENERATOR = /* @__PURE__ */ Symbol("GENERATOR");
446
492
  var STYLER = /* @__PURE__ */ Symbol("STYLER");
447
493
  var IS_EMPTY = /* @__PURE__ */ Symbol("IS_EMPTY");
448
- var levelMapping = [
449
- "ansi",
450
- "ansi",
451
- "ansi256",
452
- "ansi16m"
453
- ];
494
+ var LEVEL = /* @__PURE__ */ Symbol("LEVEL");
454
495
  var styles2 = /* @__PURE__ */ Object.create(null);
496
+ var assertValidLevel = (level) => {
497
+ if (!Number.isSafeInteger(level) || level < 0 || level > 3) {
498
+ throw new Error("The `level` should be an integer from 0 to 3");
499
+ }
500
+ };
501
+ var levelDescriptor = {
502
+ enumerable: true,
503
+ get() {
504
+ return this[LEVEL];
505
+ },
506
+ set(level) {
507
+ assertValidLevel(level);
508
+ this[LEVEL] = level;
509
+ }
510
+ };
455
511
  var applyOptions = (object, options = {}) => {
456
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
457
- throw new Error("The `level` option should be an integer from 0 to 3");
512
+ if (options.level !== void 0) {
513
+ assertValidLevel(options.level);
458
514
  }
459
515
  const colorLevel = stdoutColor ? stdoutColor.level : 0;
460
- object.level = options.level === void 0 ? colorLevel : options.level;
516
+ object[LEVEL] = options.level === void 0 ? colorLevel : options.level;
461
517
  };
462
518
  var chalkFactory = (options) => {
463
519
  const chalk2 = (...strings) => strings.join(" ");
@@ -485,56 +541,59 @@ styles2.visible = {
485
541
  return builder;
486
542
  }
487
543
  };
488
- var getModelAnsi = (model, level, type, ...arguments_) => {
544
+ var createModelConverters = (model, type) => {
545
+ const style = ansi_styles_default[type];
489
546
  if (model === "rgb") {
490
- if (level === "ansi16m") {
491
- return ansi_styles_default[type].ansi16m(...arguments_);
492
- }
493
- if (level === "ansi256") {
494
- return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
495
- }
496
- return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
547
+ const ansi2 = (red, green, blue) => style.ansi(ansi_styles_default.rgbToAnsi(red, green, blue));
548
+ const ansi256 = (red, green, blue) => style.ansi256(ansi_styles_default.rgbToAnsi256(red, green, blue));
549
+ return [ansi2, ansi2, ansi256, style.ansi16m];
497
550
  }
498
551
  if (model === "hex") {
499
- return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
552
+ const ansi2 = (hex) => style.ansi(ansi_styles_default.hexToAnsi(hex));
553
+ const ansi256 = (hex) => style.ansi256(ansi_styles_default.hexToAnsi256(hex));
554
+ return [ansi2, ansi2, ansi256, (hex) => style.ansi16m(...ansi_styles_default.hexToRgb(hex))];
500
555
  }
501
- return ansi_styles_default[type][model](...arguments_);
556
+ const ansi = (code) => style.ansi(ansi_styles_default.ansi256ToAnsi(code));
557
+ return [ansi, ansi, style.ansi256, style.ansi256];
502
558
  };
503
559
  var usedModels = ["rgb", "hex", "ansi256"];
504
560
  for (const model of usedModels) {
505
- styles2[model] = {
506
- get() {
507
- const { level } = this;
508
- return function(...arguments_) {
509
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
510
- return createBuilder(this, styler, this[IS_EMPTY]);
511
- };
512
- }
513
- };
514
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
515
- styles2[bgModel] = {
516
- get() {
517
- const { level } = this;
518
- return function(...arguments_) {
519
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
520
- return createBuilder(this, styler, this[IS_EMPTY]);
521
- };
522
- }
523
- };
561
+ const capitalizedModel = model[0].toUpperCase() + model.slice(1);
562
+ for (const [styleName, type] of [
563
+ [model, "color"],
564
+ ["bg" + capitalizedModel, "bgColor"],
565
+ ["underline" + capitalizedModel, "underlineColor"]
566
+ ]) {
567
+ const { close } = ansi_styles_default[type];
568
+ const converters = createModelConverters(model, type);
569
+ styles2[styleName] = {
570
+ get() {
571
+ const styleFunction = function(first, second, third) {
572
+ const open = converters[this.level](first, second, third);
573
+ return createBuilder(this, createStyler(open, close, this[STYLER]), this[IS_EMPTY]);
574
+ };
575
+ Object.defineProperty(this, styleName, { value: styleFunction });
576
+ return styleFunction;
577
+ }
578
+ };
579
+ }
524
580
  }
525
- var proto = Object.defineProperties(() => {
526
- }, {
527
- ...styles2,
528
- level: {
529
- enumerable: true,
530
- get() {
531
- return this[GENERATOR].level;
532
- },
533
- set(level) {
534
- this[GENERATOR].level = level;
581
+ var proto = Object.defineProperties(
582
+ () => {
583
+ },
584
+ {
585
+ ...styles2,
586
+ level: {
587
+ enumerable: true,
588
+ get() {
589
+ return this[GENERATOR].level;
590
+ },
591
+ set(level) {
592
+ this[GENERATOR].level = level;
593
+ }
535
594
  }
536
595
  }
537
- });
596
+ );
538
597
  var createStyler = (open, close, parent) => {
539
598
  let openAll;
540
599
  let closeAll;
@@ -554,15 +613,23 @@ var createStyler = (open, close, parent) => {
554
613
  };
555
614
  };
556
615
  var createBuilder = (self, _styler, _isEmpty) => {
557
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
616
+ const builder = (...arguments_) => {
617
+ if (arguments_.length === 1) {
618
+ return applyStyle(builder, "" + arguments_[0]);
619
+ }
620
+ if (arguments_.length === 2) {
621
+ return applyStyle(builder, `${arguments_[0] ?? ""} ${arguments_[1] ?? ""}`);
622
+ }
623
+ return applyStyle(builder, arguments_.join(" "));
624
+ };
558
625
  Object.setPrototypeOf(builder, proto);
559
- builder[GENERATOR] = self;
626
+ builder[GENERATOR] = self[GENERATOR] ?? self;
560
627
  builder[STYLER] = _styler;
561
628
  builder[IS_EMPTY] = _isEmpty;
562
629
  return builder;
563
630
  };
564
631
  var applyStyle = (self, string) => {
565
- if (self.level <= 0 || !string) {
632
+ if (self[GENERATOR][LEVEL] <= 0 || !string) {
566
633
  return self[IS_EMPTY] ? "" : string;
567
634
  }
568
635
  let styler = self[STYLER];
@@ -582,7 +649,7 @@ var applyStyle = (self, string) => {
582
649
  }
583
650
  return openAll + string + closeAll;
584
651
  };
585
- Object.defineProperties(createChalk.prototype, styles2);
652
+ Object.defineProperties(createChalk.prototype, { ...styles2, level: levelDescriptor });
586
653
  var chalk = createChalk();
587
654
  var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
588
655
  var source_default = chalk;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/logger",
3
- "version": "10.1.0-alpha.29+6a83650b0",
3
+ "version": "10.1.0",
4
4
  "description": "A helper utility for logging of WebdriverIO packages",
5
5
  "author": "Christian Bromann <mail@bromann.dev>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-logger",
@@ -37,7 +37,7 @@
37
37
  "url": "https://github.com/webdriverio/webdriverio/issues"
38
38
  },
39
39
  "dependencies": {
40
- "chalk": "^5.1.2",
40
+ "chalk": "^6.0.1",
41
41
  "loglevel": "^1.6.0",
42
42
  "loglevel-plugin-prefix": "^0.8.4",
43
43
  "safe-regex2": "^5.0.0",
@@ -46,5 +46,5 @@
46
46
  "publishConfig": {
47
47
  "access": "public"
48
48
  },
49
- "gitHead": "6a83650b0073eba209082b9b9cc801c9de146027"
49
+ "gitHead": "f9e88c9fd7b1665f4e85400d8970c53ec02631bb"
50
50
  }