@visulima/pail 2.1.15 → 2.1.17

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 (82) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/index.browser.cjs +19 -1
  3. package/dist/index.browser.mjs +14 -1
  4. package/dist/index.server.cjs +442 -5
  5. package/dist/index.server.mjs +437 -5
  6. package/dist/packem_shared/CallerProcessor-CyJFdYGN.mjs +58 -0
  7. package/dist/packem_shared/CallerProcessor-DYrXv6Fp.cjs +60 -0
  8. package/dist/packem_shared/JsonFileReporter-BHaRQMnS.cjs +135 -0
  9. package/dist/packem_shared/JsonFileReporter-CdHau53i.mjs +133 -0
  10. package/dist/packem_shared/JsonReporter-C05lFJhj.mjs +20 -0
  11. package/dist/packem_shared/JsonReporter-DCd8dbfQ.mjs +32 -0
  12. package/dist/packem_shared/JsonReporter-DDubAhfJ.cjs +22 -0
  13. package/dist/packem_shared/JsonReporter-HXYHZuWz.cjs +34 -0
  14. package/dist/packem_shared/MessageFormatterProcessor-CFyi7GWt.mjs +53 -0
  15. package/dist/packem_shared/MessageFormatterProcessor-D_txQ9nO.cjs +55 -0
  16. package/dist/packem_shared/PrettyReporter-Bx3QLZrW.mjs +162 -0
  17. package/dist/packem_shared/PrettyReporter-LWDDriJ1.cjs +200 -0
  18. package/dist/packem_shared/PrettyReporter-XC0Ix5SW.mjs +192 -0
  19. package/dist/packem_shared/PrettyReporter-mFCjMb0i.cjs +168 -0
  20. package/dist/packem_shared/RedactProcessor-CfNkF2lC.mjs +26 -0
  21. package/dist/packem_shared/RedactProcessor-DWE5iqAQ.cjs +26 -0
  22. package/dist/packem_shared/SimpleReporter-CuNgsGVB.mjs +178 -0
  23. package/dist/packem_shared/SimpleReporter-DabZGkIs.cjs +186 -0
  24. package/dist/packem_shared/abstract-json-reporter-CG0EXqip.mjs +55 -0
  25. package/dist/packem_shared/abstract-json-reporter-D4MiU6B-.cjs +57 -0
  26. package/dist/packem_shared/abstract-pretty-reporter-BR_6_JVa.cjs +49 -0
  27. package/dist/packem_shared/abstract-pretty-reporter-izJgxoMv.mjs +46 -0
  28. package/dist/packem_shared/constants-BYYZ5WNW.mjs +114 -0
  29. package/dist/packem_shared/constants-DHfYGxxG.cjs +118 -0
  30. package/dist/packem_shared/format-label-CQCvMzlF.cjs +622 -0
  31. package/dist/packem_shared/format-label-DYMZf3Bg.mjs +610 -0
  32. package/dist/packem_shared/get-longest-label-CM8kLFWH.mjs +11 -0
  33. package/dist/packem_shared/get-longest-label-CQ7lRhgD.cjs +13 -0
  34. package/dist/packem_shared/pail.browser-B3Bi2uPA.cjs +387 -0
  35. package/dist/packem_shared/pail.browser-DZLrCtc5.mjs +384 -0
  36. package/dist/packem_shared/write-console-log-Cu0-IDN-.cjs +18 -0
  37. package/dist/packem_shared/write-console-log-Tptfzg9D.mjs +16 -0
  38. package/dist/packem_shared/write-stream-BBAF33Zm.mjs +8 -0
  39. package/dist/packem_shared/write-stream-CkNf2Ju8.cjs +10 -0
  40. package/dist/processor.browser.cjs +11 -1
  41. package/dist/processor.browser.mjs +2 -1
  42. package/dist/processor.server.cjs +13 -1
  43. package/dist/processor.server.mjs +3 -1
  44. package/dist/reporter.browser.cjs +11 -1
  45. package/dist/reporter.browser.mjs +2 -1
  46. package/dist/reporter.server.cjs +15 -1
  47. package/dist/reporter.server.mjs +4 -1
  48. package/package.json +15 -15
  49. package/dist/packem_shared/CallerProcessor-BBHkvRgS.mjs +0 -1
  50. package/dist/packem_shared/CallerProcessor-CLoY9R76.cjs +0 -1
  51. package/dist/packem_shared/JsonFileReporter-CLEMnuGI.cjs +0 -2
  52. package/dist/packem_shared/JsonFileReporter-lr0s7r9B.mjs +0 -4
  53. package/dist/packem_shared/JsonReporter-CiQkPCv4.cjs +0 -2
  54. package/dist/packem_shared/JsonReporter-CjvkrXUp.cjs +0 -1
  55. package/dist/packem_shared/JsonReporter-DInAbLuf.mjs +0 -1
  56. package/dist/packem_shared/JsonReporter-J50eZjl2.mjs +0 -2
  57. package/dist/packem_shared/MessageFormatterProcessor-CCRIUIdT.cjs +0 -1
  58. package/dist/packem_shared/MessageFormatterProcessor-D_XajTuK.mjs +0 -1
  59. package/dist/packem_shared/PrettyReporter-1SleqVaI.mjs +0 -13
  60. package/dist/packem_shared/PrettyReporter-C_AJrNOj.mjs +0 -5
  61. package/dist/packem_shared/PrettyReporter-CldK9UpN.cjs +0 -13
  62. package/dist/packem_shared/PrettyReporter-CuJWFD0k.cjs +0 -5
  63. package/dist/packem_shared/RedactProcessor-BVZtatWJ.cjs +0 -1
  64. package/dist/packem_shared/RedactProcessor-CxKTN42V.mjs +0 -3
  65. package/dist/packem_shared/SimpleReporter-Cy_0ZeXQ.cjs +0 -11
  66. package/dist/packem_shared/SimpleReporter-DzUWU5Gu.mjs +0 -11
  67. package/dist/packem_shared/abstract-json-reporter-29d4dwOH.mjs +0 -1
  68. package/dist/packem_shared/abstract-json-reporter-Z6bVrpPK.cjs +0 -1
  69. package/dist/packem_shared/abstract-pretty-reporter-CZb4ET-0.cjs +0 -1
  70. package/dist/packem_shared/abstract-pretty-reporter-DgXRHEj-.mjs +0 -1
  71. package/dist/packem_shared/constants-BFrKdBPm.cjs +0 -1
  72. package/dist/packem_shared/constants-BMS51p6Y.mjs +0 -1
  73. package/dist/packem_shared/format-label-B0BaeOry.cjs +0 -8
  74. package/dist/packem_shared/format-label-ECls2QEw.mjs +0 -8
  75. package/dist/packem_shared/get-longest-label-4ISUsE2q.mjs +0 -1
  76. package/dist/packem_shared/get-longest-label-DXpzhu5N.cjs +0 -1
  77. package/dist/packem_shared/pail.browser-D7k9K5zt.mjs +0 -1
  78. package/dist/packem_shared/pail.browser-tTEE0Aky.cjs +0 -1
  79. package/dist/packem_shared/write-console-log-3G15muTS.cjs +0 -1
  80. package/dist/packem_shared/write-console-log-BP95fgQZ.mjs +0 -1
  81. package/dist/packem_shared/write-stream-Bgxqp0HI.cjs +0 -1
  82. package/dist/packem_shared/write-stream-C17GXSxA.mjs +0 -1
@@ -0,0 +1,133 @@
1
+ import { A as AbstractJsonReporter } from './abstract-json-reporter-CG0EXqip.mjs';
2
+
3
+ import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
4
+ const require = __cjs_mod__.createRequire(import.meta.url);
5
+ var __defProp$2 = Object.defineProperty;
6
+ var __name$2 = (target, value) => __defProp$2(target, "name", { value, configurable: true });
7
+ class SafeStreamHandler {
8
+ static {
9
+ __name$2(this, "SafeStreamHandler");
10
+ }
11
+ #ready = true;
12
+ #stream;
13
+ #name;
14
+ constructor(stream, name) {
15
+ this.#stream = stream;
16
+ this.#name = name;
17
+ }
18
+ /**
19
+ * Writes `message` to the instance's internal stream
20
+ * @param message Message to write
21
+ */
22
+ write(message) {
23
+ this.writeStream(message);
24
+ }
25
+ /**
26
+ * Calls `end` on this instance's internal stream
27
+ */
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ end(...arguments_) {
30
+ this.#stream.end(...arguments_);
31
+ }
32
+ get isReady() {
33
+ return this.#ready;
34
+ }
35
+ writeStream(message) {
36
+ if (!this.#ready) {
37
+ console.warn("Stream busy: " + this.#name + '. Write will be dropped: "' + message + '"');
38
+ return;
39
+ }
40
+ this.#ready = false;
41
+ this.#stream.on("error", (error) => {
42
+ throw error;
43
+ });
44
+ this.#stream.on("drain", () => {
45
+ this.#ready = true;
46
+ });
47
+ this.#stream.on("finish", () => {
48
+ this.#ready = true;
49
+ });
50
+ this.#ready = this.#stream.write(message, () => {
51
+ });
52
+ }
53
+ }
54
+
55
+ var __defProp$1 = Object.defineProperty;
56
+ var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
57
+ class RotatingFileStream {
58
+ static {
59
+ __name$1(this, "RotatingFileStream");
60
+ }
61
+ #filePath;
62
+ #immediate;
63
+ #stream;
64
+ #options;
65
+ // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
66
+ #createRfsStream;
67
+ constructor(filePath, writeImmediately = false, options = {}) {
68
+ this.#filePath = filePath;
69
+ this.#immediate = writeImmediately;
70
+ this.#options = options;
71
+ if (!this.#immediate) {
72
+ try {
73
+ this.#createRfsStream = require("rotating-file-stream").createStream;
74
+ } catch {
75
+ throw new Error("The 'rotating-file-stream' package is missing. Make sure to install the 'rotating-file-stream' package.");
76
+ }
77
+ this.#stream = this.#createRfsStream(this.#filePath, options);
78
+ }
79
+ }
80
+ /**
81
+ * Writes `message` to the instance's internal #stream
82
+ * @param message Message to write
83
+ */
84
+ write(message) {
85
+ let fileStream = this.#stream;
86
+ if (this.#immediate) {
87
+ fileStream = this.#createRfsStream(this.#filePath, this.#options);
88
+ }
89
+ const stream = new SafeStreamHandler(fileStream, this.#filePath);
90
+ stream.write(message);
91
+ if (this.#immediate) {
92
+ stream.end();
93
+ }
94
+ }
95
+ /**
96
+ * Ends the instance's internal #stream
97
+ *
98
+ * When `immediate` is not `true`, a call to `write` after calling this method
99
+ * will throw an error.
100
+ */
101
+ end() {
102
+ if (this.#stream !== undefined) {
103
+ this.#stream.end();
104
+ }
105
+ }
106
+ }
107
+
108
+ var __defProp = Object.defineProperty;
109
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
110
+ class JsonFileReporter extends AbstractJsonReporter {
111
+ static {
112
+ __name(this, "JsonFileReporter");
113
+ }
114
+ stream;
115
+ constructor(options) {
116
+ super();
117
+ const { filePath, writeImmediately = false, ...rfsOptions } = options;
118
+ this.stream = new RotatingFileStream(filePath, writeImmediately, {
119
+ compress: "gzip",
120
+ // compress rotated files
121
+ interval: "1d",
122
+ // rotate daily
123
+ size: "10M",
124
+ // rotate every 10 MegaBytes written,
125
+ ...rfsOptions
126
+ });
127
+ }
128
+ _log(message) {
129
+ this.stream.write(message + "\n");
130
+ }
131
+ }
132
+
133
+ export { JsonFileReporter };
@@ -0,0 +1,20 @@
1
+ import { w as writeConsoleLogBasedOnLevel } from './write-console-log-Tptfzg9D.mjs';
2
+ import { A as AbstractJsonReporter } from './abstract-json-reporter-CG0EXqip.mjs';
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ class JsonReporter extends AbstractJsonReporter {
7
+ static {
8
+ __name(this, "JsonReporter");
9
+ }
10
+ constructor(options = {}) {
11
+ super(options);
12
+ }
13
+ // eslint-disable-next-line class-methods-use-this
14
+ _log(message, logLevel) {
15
+ const consoleLogFunction = writeConsoleLogBasedOnLevel(logLevel);
16
+ consoleLogFunction(message);
17
+ }
18
+ }
19
+
20
+ export { JsonReporter as default };
@@ -0,0 +1,32 @@
1
+ import { stdout, stderr } from 'node:process';
2
+ import { w as writeStream } from './write-stream-BBAF33Zm.mjs';
3
+ import { A as AbstractJsonReporter } from './abstract-json-reporter-CG0EXqip.mjs';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ class JsonReporter extends AbstractJsonReporter {
8
+ static {
9
+ __name(this, "JsonReporter");
10
+ }
11
+ #stdout;
12
+ #stderr;
13
+ constructor(options = {}) {
14
+ super(options);
15
+ this.#stdout = stdout;
16
+ this.#stderr = stderr;
17
+ }
18
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
19
+ setStdout(stdout_) {
20
+ this.#stdout = stdout_;
21
+ }
22
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
23
+ setStderr(stderr_) {
24
+ this.#stderr = stderr_;
25
+ }
26
+ _log(message, logLevel) {
27
+ const stream = ["error", "warn"].includes(logLevel) ? this.#stderr : this.#stdout;
28
+ writeStream(message + "\n", stream);
29
+ }
30
+ }
31
+
32
+ export { JsonReporter as default };
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ const writeConsoleLog = require('./write-console-log-Cu0-IDN-.cjs');
4
+ const abstractJsonReporter = require('./abstract-json-reporter-D4MiU6B-.cjs');
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ class JsonReporter extends abstractJsonReporter.AbstractJsonReporter {
9
+ static {
10
+ __name(this, "JsonReporter");
11
+ }
12
+ constructor(options = {}) {
13
+ super(options);
14
+ }
15
+ // eslint-disable-next-line class-methods-use-this
16
+ _log(message, logLevel) {
17
+ const consoleLogFunction = writeConsoleLog.writeConsoleLogBasedOnLevel(logLevel);
18
+ consoleLogFunction(message);
19
+ }
20
+ }
21
+
22
+ module.exports = JsonReporter;
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ const process = require('node:process');
4
+ const writeStream = require('./write-stream-CkNf2Ju8.cjs');
5
+ const abstractJsonReporter = require('./abstract-json-reporter-D4MiU6B-.cjs');
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ class JsonReporter extends abstractJsonReporter.AbstractJsonReporter {
10
+ static {
11
+ __name(this, "JsonReporter");
12
+ }
13
+ #stdout;
14
+ #stderr;
15
+ constructor(options = {}) {
16
+ super(options);
17
+ this.#stdout = process.stdout;
18
+ this.#stderr = process.stderr;
19
+ }
20
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
21
+ setStdout(stdout_) {
22
+ this.#stdout = stdout_;
23
+ }
24
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
25
+ setStderr(stderr_) {
26
+ this.#stderr = stderr_;
27
+ }
28
+ _log(message, logLevel) {
29
+ const stream = ["error", "warn"].includes(logLevel) ? this.#stderr : this.#stdout;
30
+ writeStream.writeStream(message + "\n", stream);
31
+ }
32
+ }
33
+
34
+ module.exports = JsonReporter;
@@ -0,0 +1,53 @@
1
+ import { build } from '@visulima/fmt';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ class MessageFormatterProcessor {
6
+ static {
7
+ __name(this, "MessageFormatterProcessor");
8
+ }
9
+ // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
10
+ #stringify;
11
+ #formatters;
12
+ constructor(options = {}) {
13
+ this.#formatters = options.formatters;
14
+ }
15
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
16
+ setStringify(function_) {
17
+ this.#stringify = function_;
18
+ }
19
+ process(meta) {
20
+ const formatter = build({
21
+ formatters: this.#formatters,
22
+ stringify: /* @__PURE__ */ __name((value) => {
23
+ const stringified = this.#stringify(value);
24
+ if (stringified === undefined) {
25
+ console.warn("Unable to stringify value of type " + typeof value, value);
26
+ return "undefined";
27
+ }
28
+ return stringified;
29
+ }, "stringify")
30
+ });
31
+ if (meta.message !== undefined) {
32
+ meta.message = this._format(formatter, meta.message, meta.context ?? []);
33
+ }
34
+ return meta;
35
+ }
36
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
+ _format(formatter, data, arguments_ = []) {
38
+ if (typeof data === "string") {
39
+ return formatter(data, arguments_);
40
+ }
41
+ if (typeof data === "object" && data !== null) {
42
+ for (const index in data) {
43
+ const value = data[index];
44
+ if (typeof value === "string" || Array.isArray(value) || typeof value === "object") {
45
+ data[index] = this._format(formatter, value, arguments_);
46
+ }
47
+ }
48
+ }
49
+ return data;
50
+ }
51
+ }
52
+
53
+ export { MessageFormatterProcessor as default };
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ const fmt = require('@visulima/fmt');
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ class MessageFormatterProcessor {
8
+ static {
9
+ __name(this, "MessageFormatterProcessor");
10
+ }
11
+ // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
12
+ #stringify;
13
+ #formatters;
14
+ constructor(options = {}) {
15
+ this.#formatters = options.formatters;
16
+ }
17
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
18
+ setStringify(function_) {
19
+ this.#stringify = function_;
20
+ }
21
+ process(meta) {
22
+ const formatter = fmt.build({
23
+ formatters: this.#formatters,
24
+ stringify: /* @__PURE__ */ __name((value) => {
25
+ const stringified = this.#stringify(value);
26
+ if (stringified === undefined) {
27
+ console.warn("Unable to stringify value of type " + typeof value, value);
28
+ return "undefined";
29
+ }
30
+ return stringified;
31
+ }, "stringify")
32
+ });
33
+ if (meta.message !== undefined) {
34
+ meta.message = this._format(formatter, meta.message, meta.context ?? []);
35
+ }
36
+ return meta;
37
+ }
38
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
+ _format(formatter, data, arguments_ = []) {
40
+ if (typeof data === "string") {
41
+ return formatter(data, arguments_);
42
+ }
43
+ if (typeof data === "object" && data !== null) {
44
+ for (const index in data) {
45
+ const value = data[index];
46
+ if (typeof value === "string" || Array.isArray(value) || typeof value === "object") {
47
+ data[index] = this._format(formatter, value, arguments_);
48
+ }
49
+ }
50
+ }
51
+ return data;
52
+ }
53
+ }
54
+
55
+ module.exports = MessageFormatterProcessor;
@@ -0,0 +1,162 @@
1
+ import colorize, { grey, white, underline, bold } from '@visulima/colorize/browser';
2
+ import { format } from '@visulima/fmt';
3
+ import { E as EMPTY_SYMBOL } from './constants-BYYZ5WNW.mjs';
4
+ import { A as AbstractPrettyReporter, g as getLongestBadge } from './abstract-pretty-reporter-izJgxoMv.mjs';
5
+ import { g as getLongestLabel } from './get-longest-label-CM8kLFWH.mjs';
6
+ import { w as writeConsoleLogBasedOnLevel } from './write-console-log-Tptfzg9D.mjs';
7
+
8
+ var __defProp = Object.defineProperty;
9
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
+ class PrettyReporter extends AbstractPrettyReporter {
11
+ static {
12
+ __name(this, "PrettyReporter");
13
+ }
14
+ constructor(options = {}) {
15
+ super({
16
+ uppercase: {
17
+ label: true,
18
+ ...options.uppercase
19
+ },
20
+ ...options
21
+ });
22
+ }
23
+ // eslint-disable-next-line sonarjs/cognitive-complexity
24
+ log(meta) {
25
+ const isNotBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
26
+ const consoleLogFunction = writeConsoleLogBasedOnLevel(meta.type.level);
27
+ const { badge, context, date, error, groups, label, message, prefix, repeated, scope, suffix, type } = meta;
28
+ const { color } = this._loggerTypes[type.name];
29
+ const colorized = color ? colorize[color] : white;
30
+ const items = [];
31
+ if (isNotBrowser && groups.length > 0) {
32
+ const groupSpaces = groups.map(() => " ").join("");
33
+ const cGroup = grey("[" + groups.at(-1) + "]");
34
+ items.push(format(groupSpaces + cGroup[0], cGroup.slice(1)));
35
+ }
36
+ if (date) {
37
+ const cDate = grey(this._styles.dateFormatter(typeof date === "string" ? new Date(date) : date));
38
+ if (isNotBrowser) {
39
+ items.push(format(cDate[0], cDate.slice(1)));
40
+ } else {
41
+ items.push([cDate[0] + " ", ...cDate.slice(1)]);
42
+ }
43
+ }
44
+ if (badge) {
45
+ const cBadge = colorized(badge);
46
+ if (isNotBrowser) {
47
+ items.push(format(cBadge[0], cBadge.slice(1)));
48
+ } else {
49
+ items.push([cBadge[0] + " ", ...cBadge.slice(1)]);
50
+ }
51
+ } else {
52
+ const longestBadge = getLongestBadge(this._loggerTypes);
53
+ if (longestBadge.length > 0) {
54
+ const cBadgePlaceholder = grey(".".repeat(longestBadge.length));
55
+ if (isNotBrowser) {
56
+ items.push(format(cBadgePlaceholder[0] + " ", cBadgePlaceholder.slice(1)));
57
+ } else {
58
+ items.push([cBadgePlaceholder[0] + " ", ...cBadgePlaceholder.slice(1)]);
59
+ }
60
+ }
61
+ }
62
+ const longestLabel = getLongestLabel(this._loggerTypes);
63
+ let repeatedMessage;
64
+ if (repeated) {
65
+ const cRepeated = white("[" + repeated + "x]");
66
+ repeatedMessage = isNotBrowser ? format(cRepeated[0], cRepeated.slice(1)) : [cRepeated[0], ...cRepeated.slice(1)];
67
+ }
68
+ if (label) {
69
+ const cLabel = colorized(this._formatLabel(label));
70
+ if (isNotBrowser) {
71
+ items.push(format(cLabel[0], cLabel.slice(1)));
72
+ } else {
73
+ items.push([cLabel[0], ...cLabel.slice(1)]);
74
+ }
75
+ if (repeatedMessage) {
76
+ items.push(repeatedMessage);
77
+ }
78
+ let lengthDiff = longestLabel.length - label.length;
79
+ if (repeated) {
80
+ lengthDiff -= String(repeated).length + 3;
81
+ } else {
82
+ lengthDiff += 1;
83
+ }
84
+ if (lengthDiff > 0) {
85
+ const cLabelSpacer = grey(".".repeat(lengthDiff));
86
+ if (isNotBrowser) {
87
+ items.push(format(cLabelSpacer[0], cLabelSpacer.slice(1)));
88
+ } else {
89
+ items.push([" " + cLabelSpacer[0], ...cLabelSpacer.slice(1)]);
90
+ }
91
+ }
92
+ } else {
93
+ const cSpacer = grey(".".repeat(longestLabel.length + 1));
94
+ if (isNotBrowser) {
95
+ items.push(format(cSpacer[0], cSpacer.slice(1)));
96
+ } else {
97
+ items.push([cSpacer[0], ...cSpacer.slice(1)]);
98
+ }
99
+ }
100
+ if (Array.isArray(scope) && scope.length > 0) {
101
+ const cScope = grey("[" + scope.join(" > ") + "]");
102
+ if (isNotBrowser) {
103
+ items.push(format(cScope[0], cScope.slice(1)));
104
+ } else {
105
+ items.push([cScope[0], ...cScope.slice(1)]);
106
+ }
107
+ }
108
+ if (prefix) {
109
+ const cPrefix = grey(
110
+ (Array.isArray(scope) && scope.length > 0 ? ". " : " ") + "[" + (this._styles.underline.prefix ? underline(prefix) : prefix) + "] "
111
+ );
112
+ if (isNotBrowser) {
113
+ items.push(format(cPrefix[0], cPrefix.slice(1)));
114
+ } else {
115
+ items.push([cPrefix[0], ...cPrefix.slice(1)]);
116
+ }
117
+ }
118
+ if (message !== EMPTY_SYMBOL) {
119
+ items.push(message);
120
+ }
121
+ if (context) {
122
+ items.push(...context);
123
+ }
124
+ if (error) {
125
+ items.push(error, "\n\n");
126
+ }
127
+ if (suffix) {
128
+ const cSuffix = grey(this._styles.underline.suffix ? underline(suffix) : suffix);
129
+ if (isNotBrowser) {
130
+ items.push(format("\n" + cSuffix[0], cSuffix.slice(1)));
131
+ } else {
132
+ items.push(["\n" + cSuffix[0], ...cSuffix.slice(1)]);
133
+ }
134
+ }
135
+ if (isNotBrowser) {
136
+ consoleLogFunction(...items);
137
+ } else {
138
+ let logMessage = "";
139
+ const css = [];
140
+ const arguments_ = [];
141
+ for (const value of items) {
142
+ if (Array.isArray(value) && value.length > 1 && value[0].includes("%c")) {
143
+ logMessage += value[0];
144
+ css.push(...value.slice(1));
145
+ } else {
146
+ arguments_.push(value);
147
+ }
148
+ }
149
+ consoleLogFunction(logMessage + "%c", ...css, "", ...arguments_);
150
+ }
151
+ }
152
+ _formatLabel(label) {
153
+ let formattedLabel = this._styles.uppercase.label ? label.toUpperCase() : label;
154
+ formattedLabel = this._styles.underline.label ? underline(formattedLabel) : formattedLabel;
155
+ if (this._styles.bold.label) {
156
+ formattedLabel = bold(formattedLabel);
157
+ }
158
+ return formattedLabel;
159
+ }
160
+ }
161
+
162
+ export { PrettyReporter as default };