@rabbit-company/logger 3.0.0 → 3.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.
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Represents a logger utility for logging messages with different log levels.
3
+ */
4
+ export default class Logger {
5
+ private static NDJsonData;
6
+ /**
7
+ * Indicates whether NDJson is enabled.
8
+ * @type {boolean}
9
+ */
10
+ static NDJson: boolean;
11
+ /**
12
+ * The log level of the logger.
13
+ * @type {number}
14
+ */
15
+ static level: number;
16
+ /**
17
+ * Indicates whether colors are enabled for log messages.
18
+ * @type {boolean}
19
+ */
20
+ static colors: boolean;
21
+ /**
22
+ * Defines log levels and their associated numeric values.
23
+ * @type {Record<string, number>}
24
+ */
25
+ static readonly levels: Record<string, number>;
26
+ private static readonly levelsRev;
27
+ /**
28
+ * Parses the log message to ensure it is a string.
29
+ * @param {*} message - The log message.
30
+ * @returns {string | null} - The parsed log message or null if the message is undefined.
31
+ */
32
+ static parseMessage(message: any): string | null;
33
+ /**
34
+ * Formats the log message with timestamp and log level.
35
+ * @param {string} message - The log message.
36
+ * @param {number} logLevel - The log level.
37
+ * @returns {string} - The formatted log message.
38
+ */
39
+ static formatMessage(message: string, logLevel: number): string;
40
+ /**
41
+ * Processes and logs a message with the specified log level.
42
+ * @param {*} message - The log message.
43
+ * @param {number} logLevel - The log level.
44
+ */
45
+ private static processMessage;
46
+ /**
47
+ * Logs an error message.
48
+ * @param {*} message - The error message.
49
+ */
50
+ static error(message: any): void;
51
+ /**
52
+ * Logs a warning message.
53
+ * @param {*} message - The warning message.
54
+ */
55
+ static warn(message: any): void;
56
+ /**
57
+ * Logs an informational message.
58
+ * @param {*} message - The informational message.
59
+ */
60
+ static info(message: any): void;
61
+ /**
62
+ * Logs an HTTP-related message.
63
+ * @param {*} message - The HTTP-related message.
64
+ */
65
+ static http(message: any): void;
66
+ /**
67
+ * Logs a verbose message.
68
+ * @param {*} message - The verbose message.
69
+ */
70
+ static verbose(message: any): void;
71
+ /**
72
+ * Logs a debug message.
73
+ * @param {*} message - The debug message.
74
+ */
75
+ static debug(message: any): void;
76
+ /**
77
+ * Logs a silly message.
78
+ * @param {*} message - The silly message.
79
+ */
80
+ static silly(message: any): void;
81
+ /**
82
+ * Appends a message to NDJson format.
83
+ * @param {string} message - The message to append.
84
+ * @param {number} logLevel - The log level associated with the message.
85
+ */
86
+ static putNDJson(message: string, logLevel: number): void;
87
+ /**
88
+ * Gets the NDJson log.
89
+ * @returns {string} - The NDJson log.
90
+ */
91
+ static getNDJson(): string;
92
+ }
93
+
94
+ export {};
@@ -0,0 +1,500 @@
1
+ // node_modules/chalk/source/vendor/ansi-styles/index.js
2
+ var assembleStyles = function() {
3
+ const codes = new Map;
4
+ for (const [groupName, group] of Object.entries(styles)) {
5
+ for (const [styleName, style] of Object.entries(group)) {
6
+ styles[styleName] = {
7
+ open: `\x1B[${style[0]}m`,
8
+ close: `\x1B[${style[1]}m`
9
+ };
10
+ group[styleName] = styles[styleName];
11
+ codes.set(style[0], style[1]);
12
+ }
13
+ Object.defineProperty(styles, groupName, {
14
+ value: group,
15
+ enumerable: false
16
+ });
17
+ }
18
+ Object.defineProperty(styles, "codes", {
19
+ value: codes,
20
+ enumerable: false
21
+ });
22
+ styles.color.close = "\x1B[39m";
23
+ styles.bgColor.close = "\x1B[49m";
24
+ styles.color.ansi = wrapAnsi16();
25
+ styles.color.ansi256 = wrapAnsi256();
26
+ styles.color.ansi16m = wrapAnsi16m();
27
+ styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
28
+ styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
29
+ styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
30
+ Object.defineProperties(styles, {
31
+ rgbToAnsi256: {
32
+ value(red, green, blue) {
33
+ if (red === green && green === blue) {
34
+ if (red < 8) {
35
+ return 16;
36
+ }
37
+ if (red > 248) {
38
+ return 231;
39
+ }
40
+ return Math.round((red - 8) / 247 * 24) + 232;
41
+ }
42
+ return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
43
+ },
44
+ enumerable: false
45
+ },
46
+ hexToRgb: {
47
+ value(hex) {
48
+ const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
49
+ if (!matches) {
50
+ return [0, 0, 0];
51
+ }
52
+ let [colorString] = matches;
53
+ if (colorString.length === 3) {
54
+ colorString = [...colorString].map((character) => character + character).join("");
55
+ }
56
+ const integer = Number.parseInt(colorString, 16);
57
+ return [
58
+ integer >> 16 & 255,
59
+ integer >> 8 & 255,
60
+ integer & 255
61
+ ];
62
+ },
63
+ enumerable: false
64
+ },
65
+ hexToAnsi256: {
66
+ value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
67
+ enumerable: false
68
+ },
69
+ ansi256ToAnsi: {
70
+ value(code) {
71
+ if (code < 8) {
72
+ return 30 + code;
73
+ }
74
+ if (code < 16) {
75
+ return 90 + (code - 8);
76
+ }
77
+ let red;
78
+ let green;
79
+ let blue;
80
+ if (code >= 232) {
81
+ red = ((code - 232) * 10 + 8) / 255;
82
+ green = red;
83
+ blue = red;
84
+ } else {
85
+ code -= 16;
86
+ const remainder = code % 36;
87
+ red = Math.floor(code / 36) / 5;
88
+ green = Math.floor(remainder / 6) / 5;
89
+ blue = remainder % 6 / 5;
90
+ }
91
+ const value = Math.max(red, green, blue) * 2;
92
+ if (value === 0) {
93
+ return 30;
94
+ }
95
+ let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
96
+ if (value === 2) {
97
+ result += 60;
98
+ }
99
+ return result;
100
+ },
101
+ enumerable: false
102
+ },
103
+ rgbToAnsi: {
104
+ value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
105
+ enumerable: false
106
+ },
107
+ hexToAnsi: {
108
+ value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
109
+ enumerable: false
110
+ }
111
+ });
112
+ return styles;
113
+ };
114
+ var ANSI_BACKGROUND_OFFSET = 10;
115
+ var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
116
+ var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
117
+ var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
118
+ var styles = {
119
+ modifier: {
120
+ reset: [0, 0],
121
+ bold: [1, 22],
122
+ dim: [2, 22],
123
+ italic: [3, 23],
124
+ underline: [4, 24],
125
+ overline: [53, 55],
126
+ inverse: [7, 27],
127
+ hidden: [8, 28],
128
+ strikethrough: [9, 29]
129
+ },
130
+ color: {
131
+ black: [30, 39],
132
+ red: [31, 39],
133
+ green: [32, 39],
134
+ yellow: [33, 39],
135
+ blue: [34, 39],
136
+ magenta: [35, 39],
137
+ cyan: [36, 39],
138
+ white: [37, 39],
139
+ blackBright: [90, 39],
140
+ gray: [90, 39],
141
+ grey: [90, 39],
142
+ redBright: [91, 39],
143
+ greenBright: [92, 39],
144
+ yellowBright: [93, 39],
145
+ blueBright: [94, 39],
146
+ magentaBright: [95, 39],
147
+ cyanBright: [96, 39],
148
+ whiteBright: [97, 39]
149
+ },
150
+ bgColor: {
151
+ bgBlack: [40, 49],
152
+ bgRed: [41, 49],
153
+ bgGreen: [42, 49],
154
+ bgYellow: [43, 49],
155
+ bgBlue: [44, 49],
156
+ bgMagenta: [45, 49],
157
+ bgCyan: [46, 49],
158
+ bgWhite: [47, 49],
159
+ bgBlackBright: [100, 49],
160
+ bgGray: [100, 49],
161
+ bgGrey: [100, 49],
162
+ bgRedBright: [101, 49],
163
+ bgGreenBright: [102, 49],
164
+ bgYellowBright: [103, 49],
165
+ bgBlueBright: [104, 49],
166
+ bgMagentaBright: [105, 49],
167
+ bgCyanBright: [106, 49],
168
+ bgWhiteBright: [107, 49]
169
+ }
170
+ };
171
+ var modifierNames = Object.keys(styles.modifier);
172
+ var foregroundColorNames = Object.keys(styles.color);
173
+ var backgroundColorNames = Object.keys(styles.bgColor);
174
+ var colorNames = [...foregroundColorNames, ...backgroundColorNames];
175
+ var ansiStyles = assembleStyles();
176
+ var ansi_styles_default = ansiStyles;
177
+
178
+ // node_modules/chalk/source/vendor/supports-color/browser.js
179
+ var level = (() => {
180
+ if (navigator.userAgentData) {
181
+ const brand = navigator.userAgentData.brands.find(({ brand: brand2 }) => brand2 === "Chromium");
182
+ if (brand && brand.version > 93) {
183
+ return 3;
184
+ }
185
+ }
186
+ if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) {
187
+ return 1;
188
+ }
189
+ return 0;
190
+ })();
191
+ var colorSupport = level !== 0 && {
192
+ level,
193
+ hasBasic: true,
194
+ has256: level >= 2,
195
+ has16m: level >= 3
196
+ };
197
+ var supportsColor = {
198
+ stdout: colorSupport,
199
+ stderr: colorSupport
200
+ };
201
+ var browser_default = supportsColor;
202
+
203
+ // node_modules/chalk/source/utilities.js
204
+ function stringReplaceAll(string, substring, replacer) {
205
+ let index = string.indexOf(substring);
206
+ if (index === -1) {
207
+ return string;
208
+ }
209
+ const substringLength = substring.length;
210
+ let endIndex = 0;
211
+ let returnValue = "";
212
+ do {
213
+ returnValue += string.slice(endIndex, index) + substring + replacer;
214
+ endIndex = index + substringLength;
215
+ index = string.indexOf(substring, endIndex);
216
+ } while (index !== -1);
217
+ returnValue += string.slice(endIndex);
218
+ return returnValue;
219
+ }
220
+ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
221
+ let endIndex = 0;
222
+ let returnValue = "";
223
+ do {
224
+ const gotCR = string[index - 1] === "\r";
225
+ returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
226
+ endIndex = index + 1;
227
+ index = string.indexOf("\n", endIndex);
228
+ } while (index !== -1);
229
+ returnValue += string.slice(endIndex);
230
+ return returnValue;
231
+ }
232
+
233
+ // node_modules/chalk/source/index.js
234
+ var createChalk = function(options) {
235
+ return chalkFactory(options);
236
+ };
237
+ var { stdout: stdoutColor, stderr: stderrColor } = browser_default;
238
+ var GENERATOR = Symbol("GENERATOR");
239
+ var STYLER = Symbol("STYLER");
240
+ var IS_EMPTY = Symbol("IS_EMPTY");
241
+ var levelMapping = [
242
+ "ansi",
243
+ "ansi",
244
+ "ansi256",
245
+ "ansi16m"
246
+ ];
247
+ var styles2 = Object.create(null);
248
+ var applyOptions = (object, options = {}) => {
249
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
250
+ throw new Error("The `level` option should be an integer from 0 to 3");
251
+ }
252
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
253
+ object.level = options.level === undefined ? colorLevel : options.level;
254
+ };
255
+ var chalkFactory = (options) => {
256
+ const chalk = (...strings) => strings.join(" ");
257
+ applyOptions(chalk, options);
258
+ Object.setPrototypeOf(chalk, createChalk.prototype);
259
+ return chalk;
260
+ };
261
+ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
262
+ for (const [styleName, style] of Object.entries(ansi_styles_default)) {
263
+ styles2[styleName] = {
264
+ get() {
265
+ const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
266
+ Object.defineProperty(this, styleName, { value: builder });
267
+ return builder;
268
+ }
269
+ };
270
+ }
271
+ styles2.visible = {
272
+ get() {
273
+ const builder = createBuilder(this, this[STYLER], true);
274
+ Object.defineProperty(this, "visible", { value: builder });
275
+ return builder;
276
+ }
277
+ };
278
+ var getModelAnsi = (model, level2, type, ...arguments_) => {
279
+ if (model === "rgb") {
280
+ if (level2 === "ansi16m") {
281
+ return ansi_styles_default[type].ansi16m(...arguments_);
282
+ }
283
+ if (level2 === "ansi256") {
284
+ return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
285
+ }
286
+ return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
287
+ }
288
+ if (model === "hex") {
289
+ return getModelAnsi("rgb", level2, type, ...ansi_styles_default.hexToRgb(...arguments_));
290
+ }
291
+ return ansi_styles_default[type][model](...arguments_);
292
+ };
293
+ var usedModels = ["rgb", "hex", "ansi256"];
294
+ for (const model of usedModels) {
295
+ styles2[model] = {
296
+ get() {
297
+ const { level: level2 } = this;
298
+ return function(...arguments_) {
299
+ const styler = createStyler(getModelAnsi(model, levelMapping[level2], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
300
+ return createBuilder(this, styler, this[IS_EMPTY]);
301
+ };
302
+ }
303
+ };
304
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
305
+ styles2[bgModel] = {
306
+ get() {
307
+ const { level: level2 } = this;
308
+ return function(...arguments_) {
309
+ const styler = createStyler(getModelAnsi(model, levelMapping[level2], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
310
+ return createBuilder(this, styler, this[IS_EMPTY]);
311
+ };
312
+ }
313
+ };
314
+ }
315
+ var proto = Object.defineProperties(() => {
316
+ }, {
317
+ ...styles2,
318
+ level: {
319
+ enumerable: true,
320
+ get() {
321
+ return this[GENERATOR].level;
322
+ },
323
+ set(level2) {
324
+ this[GENERATOR].level = level2;
325
+ }
326
+ }
327
+ });
328
+ var createStyler = (open, close, parent) => {
329
+ let openAll;
330
+ let closeAll;
331
+ if (parent === undefined) {
332
+ openAll = open;
333
+ closeAll = close;
334
+ } else {
335
+ openAll = parent.openAll + open;
336
+ closeAll = close + parent.closeAll;
337
+ }
338
+ return {
339
+ open,
340
+ close,
341
+ openAll,
342
+ closeAll,
343
+ parent
344
+ };
345
+ };
346
+ var createBuilder = (self, _styler, _isEmpty) => {
347
+ const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
348
+ Object.setPrototypeOf(builder, proto);
349
+ builder[GENERATOR] = self;
350
+ builder[STYLER] = _styler;
351
+ builder[IS_EMPTY] = _isEmpty;
352
+ return builder;
353
+ };
354
+ var applyStyle = (self, string) => {
355
+ if (self.level <= 0 || !string) {
356
+ return self[IS_EMPTY] ? "" : string;
357
+ }
358
+ let styler = self[STYLER];
359
+ if (styler === undefined) {
360
+ return string;
361
+ }
362
+ const { openAll, closeAll } = styler;
363
+ if (string.includes("\x1B")) {
364
+ while (styler !== undefined) {
365
+ string = stringReplaceAll(string, styler.close, styler.open);
366
+ styler = styler.parent;
367
+ }
368
+ }
369
+ const lfIndex = string.indexOf("\n");
370
+ if (lfIndex !== -1) {
371
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
372
+ }
373
+ return openAll + string + closeAll;
374
+ };
375
+ Object.defineProperties(createChalk.prototype, styles2);
376
+ var chalk = createChalk();
377
+ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
378
+ var source_default = chalk;
379
+
380
+ // src/logger.ts
381
+ class Logger {
382
+ static NDJsonData = "";
383
+ static NDJson = false;
384
+ static level = 2;
385
+ static colors = true;
386
+ static levels = {
387
+ error: 0,
388
+ warn: 1,
389
+ info: 2,
390
+ http: 3,
391
+ verbose: 4,
392
+ debug: 5,
393
+ silly: 6
394
+ };
395
+ static levelsRev = {
396
+ 0: "ERROR",
397
+ 1: "WARN",
398
+ 2: "INFO",
399
+ 3: "HTTP",
400
+ 4: "VERBOSE",
401
+ 5: "DEBUG",
402
+ 6: "SILLY"
403
+ };
404
+ static parseMessage(message) {
405
+ if (typeof message === "undefined")
406
+ return null;
407
+ if (typeof message === "object")
408
+ message = JSON.stringify(message);
409
+ return message;
410
+ }
411
+ static formatMessage(message, logLevel) {
412
+ let type = this.levelsRev[logLevel];
413
+ let date = new Date().toISOString().split(".")[0].replace("T", " ");
414
+ if (this.colors) {
415
+ date = source_default.gray(date);
416
+ switch (logLevel) {
417
+ case 0:
418
+ type = source_default.bold(source_default.red(type));
419
+ message = source_default.red(message);
420
+ break;
421
+ case 1:
422
+ type = source_default.bold(source_default.yellow(type));
423
+ message = source_default.yellow(message);
424
+ break;
425
+ case 2:
426
+ type = source_default.bold(source_default.cyan(type));
427
+ message = source_default.cyan(message);
428
+ break;
429
+ case 3:
430
+ type = source_default.bold(source_default.blue(type));
431
+ message = source_default.blue(message);
432
+ break;
433
+ case 4:
434
+ type = source_default.bold(source_default.blue(type));
435
+ message = source_default.blue(message);
436
+ break;
437
+ case 5:
438
+ type = source_default.bold(source_default.gray(type));
439
+ message = source_default.gray(message);
440
+ break;
441
+ case 6:
442
+ type = source_default.bold(source_default.gray(type));
443
+ message = source_default.gray(message);
444
+ break;
445
+ }
446
+ }
447
+ return `[${date}] ${type} ${message}`;
448
+ }
449
+ static processMessage(message, logLevel) {
450
+ if (this.level < logLevel)
451
+ return;
452
+ message = this.parseMessage(message);
453
+ if (message === null)
454
+ return;
455
+ if (this.NDJson)
456
+ this.putNDJson(message, logLevel);
457
+ switch (logLevel) {
458
+ case 0:
459
+ console.error(this.formatMessage(message, logLevel));
460
+ break;
461
+ case 1:
462
+ console.warn(this.formatMessage(message, logLevel));
463
+ break;
464
+ default:
465
+ console.info(this.formatMessage(message, logLevel));
466
+ break;
467
+ }
468
+ }
469
+ static error(message) {
470
+ this.processMessage(message, 0);
471
+ }
472
+ static warn(message) {
473
+ this.processMessage(message, 1);
474
+ }
475
+ static info(message) {
476
+ this.processMessage(message, 2);
477
+ }
478
+ static http(message) {
479
+ this.processMessage(message, 3);
480
+ }
481
+ static verbose(message) {
482
+ this.processMessage(message, 4);
483
+ }
484
+ static debug(message) {
485
+ this.processMessage(message, 5);
486
+ }
487
+ static silly(message) {
488
+ this.processMessage(message, 6);
489
+ }
490
+ static putNDJson(message, logLevel) {
491
+ let separator = this.NDJsonData.length !== 0 ? "\n" : "";
492
+ this.NDJsonData += separator + JSON.stringify({ time: new Date().toISOString(), level: logLevel, msg: message });
493
+ }
494
+ static getNDJson() {
495
+ return this.NDJsonData ?? "";
496
+ }
497
+ }
498
+ export {
499
+ Logger as default
500
+ };
package/module/logger.js CHANGED
@@ -175,30 +175,131 @@ var colorNames = [...foregroundColorNames, ...backgroundColorNames];
175
175
  var ansiStyles = assembleStyles();
176
176
  var ansi_styles_default = ansiStyles;
177
177
 
178
- // node_modules/chalk/source/vendor/supports-color/browser.js
179
- var level = (() => {
180
- if (navigator.userAgentData) {
181
- const brand = navigator.userAgentData.brands.find(({ brand: brand2 }) => brand2 === "Chromium");
182
- if (brand && brand.version > 93) {
178
+ // node_modules/chalk/source/vendor/supports-color/index.js
179
+ import process from "node:process";
180
+ import os from "node:os";
181
+ import tty from "node:tty";
182
+ var hasFlag = function(flag, argv = globalThis.Deno ? globalThis.Deno.args : process.argv) {
183
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
184
+ const position = argv.indexOf(prefix + flag);
185
+ const terminatorPosition = argv.indexOf("--");
186
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
187
+ };
188
+ var envForceColor = function() {
189
+ if ("FORCE_COLOR" in env) {
190
+ if (env.FORCE_COLOR === "true") {
191
+ return 1;
192
+ }
193
+ if (env.FORCE_COLOR === "false") {
194
+ return 0;
195
+ }
196
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
197
+ }
198
+ };
199
+ var translateLevel = function(level) {
200
+ if (level === 0) {
201
+ return false;
202
+ }
203
+ return {
204
+ level,
205
+ hasBasic: true,
206
+ has256: level >= 2,
207
+ has16m: level >= 3
208
+ };
209
+ };
210
+ var _supportsColor = function(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
211
+ const noFlagForceColor = envForceColor();
212
+ if (noFlagForceColor !== undefined) {
213
+ flagForceColor = noFlagForceColor;
214
+ }
215
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
216
+ if (forceColor === 0) {
217
+ return 0;
218
+ }
219
+ if (sniffFlags) {
220
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
221
+ return 3;
222
+ }
223
+ if (hasFlag("color=256")) {
224
+ return 2;
225
+ }
226
+ }
227
+ if ("TF_BUILD" in env && "AGENT_NAME" in env) {
228
+ return 1;
229
+ }
230
+ if (haveStream && !streamIsTTY && forceColor === undefined) {
231
+ return 0;
232
+ }
233
+ const min = forceColor || 0;
234
+ if (env.TERM === "dumb") {
235
+ return min;
236
+ }
237
+ if (process.platform === "win32") {
238
+ const osRelease = os.release().split(".");
239
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
240
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
241
+ }
242
+ return 1;
243
+ }
244
+ if ("CI" in env) {
245
+ if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) {
183
246
  return 3;
184
247
  }
248
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => (sign in env)) || env.CI_NAME === "codeship") {
249
+ return 1;
250
+ }
251
+ return min;
252
+ }
253
+ if ("TEAMCITY_VERSION" in env) {
254
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
255
+ }
256
+ if (env.COLORTERM === "truecolor") {
257
+ return 3;
258
+ }
259
+ if (env.TERM === "xterm-kitty") {
260
+ return 3;
261
+ }
262
+ if ("TERM_PROGRAM" in env) {
263
+ const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
264
+ switch (env.TERM_PROGRAM) {
265
+ case "iTerm.app": {
266
+ return version >= 3 ? 3 : 2;
267
+ }
268
+ case "Apple_Terminal": {
269
+ return 2;
270
+ }
271
+ }
185
272
  }
186
- if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) {
273
+ if (/-256(color)?$/i.test(env.TERM)) {
274
+ return 2;
275
+ }
276
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
187
277
  return 1;
188
278
  }
189
- return 0;
190
- })();
191
- var colorSupport = level !== 0 && {
192
- level,
193
- hasBasic: true,
194
- has256: level >= 2,
195
- has16m: level >= 3
279
+ if ("COLORTERM" in env) {
280
+ return 1;
281
+ }
282
+ return min;
196
283
  };
284
+ function createSupportsColor(stream, options = {}) {
285
+ const level = _supportsColor(stream, {
286
+ streamIsTTY: stream && stream.isTTY,
287
+ ...options
288
+ });
289
+ return translateLevel(level);
290
+ }
291
+ var { env } = process;
292
+ var flagForceColor;
293
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
294
+ flagForceColor = 0;
295
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
296
+ flagForceColor = 1;
297
+ }
197
298
  var supportsColor = {
198
- stdout: colorSupport,
199
- stderr: colorSupport
299
+ stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
300
+ stderr: createSupportsColor({ isTTY: tty.isatty(2) })
200
301
  };
201
- var browser_default = supportsColor;
302
+ var supports_color_default = supportsColor;
202
303
 
203
304
  // node_modules/chalk/source/utilities.js
204
305
  function stringReplaceAll(string, substring, replacer) {
@@ -234,7 +335,7 @@ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
234
335
  var createChalk = function(options) {
235
336
  return chalkFactory(options);
236
337
  };
237
- var { stdout: stdoutColor, stderr: stderrColor } = browser_default;
338
+ var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
238
339
  var GENERATOR = Symbol("GENERATOR");
239
340
  var STYLER = Symbol("STYLER");
240
341
  var IS_EMPTY = Symbol("IS_EMPTY");
@@ -275,18 +376,18 @@ styles2.visible = {
275
376
  return builder;
276
377
  }
277
378
  };
278
- var getModelAnsi = (model, level2, type, ...arguments_) => {
379
+ var getModelAnsi = (model, level, type, ...arguments_) => {
279
380
  if (model === "rgb") {
280
- if (level2 === "ansi16m") {
381
+ if (level === "ansi16m") {
281
382
  return ansi_styles_default[type].ansi16m(...arguments_);
282
383
  }
283
- if (level2 === "ansi256") {
384
+ if (level === "ansi256") {
284
385
  return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
285
386
  }
286
387
  return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
287
388
  }
288
389
  if (model === "hex") {
289
- return getModelAnsi("rgb", level2, type, ...ansi_styles_default.hexToRgb(...arguments_));
390
+ return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
290
391
  }
291
392
  return ansi_styles_default[type][model](...arguments_);
292
393
  };
@@ -294,9 +395,9 @@ var usedModels = ["rgb", "hex", "ansi256"];
294
395
  for (const model of usedModels) {
295
396
  styles2[model] = {
296
397
  get() {
297
- const { level: level2 } = this;
398
+ const { level } = this;
298
399
  return function(...arguments_) {
299
- const styler = createStyler(getModelAnsi(model, levelMapping[level2], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
400
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
300
401
  return createBuilder(this, styler, this[IS_EMPTY]);
301
402
  };
302
403
  }
@@ -304,9 +405,9 @@ for (const model of usedModels) {
304
405
  const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
305
406
  styles2[bgModel] = {
306
407
  get() {
307
- const { level: level2 } = this;
408
+ const { level } = this;
308
409
  return function(...arguments_) {
309
- const styler = createStyler(getModelAnsi(model, levelMapping[level2], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
410
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
310
411
  return createBuilder(this, styler, this[IS_EMPTY]);
311
412
  };
312
413
  }
@@ -320,8 +421,8 @@ var proto = Object.defineProperties(() => {
320
421
  get() {
321
422
  return this[GENERATOR].level;
322
423
  },
323
- set(level2) {
324
- this[GENERATOR].level = level2;
424
+ set(level) {
425
+ this[GENERATOR].level = level;
325
426
  }
326
427
  }
327
428
  });
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@rabbit-company/logger",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "Simple logger",
5
5
  "main": "./module/logger.js",
6
- "browser": "./module/logger.js",
6
+ "browser": "./browser/logger.js",
7
7
  "type": "module",
8
8
  "homepage": "https://github.com/Rabbit-Company/Logger-JS",
9
9
  "funding": "https://rabbit-company.com/donation",
@@ -15,7 +15,9 @@
15
15
  },
16
16
  "files": [
17
17
  "module/logger.js",
18
- "module/logger.d.ts"
18
+ "module/logger.d.ts",
19
+ "browser/logger.js",
20
+ "browser/logger.d.ts"
19
21
  ],
20
22
  "repository": {
21
23
  "type": "git",
@@ -31,13 +33,13 @@
31
33
  "keywords": [
32
34
  "logger"
33
35
  ],
34
- "devDependencies": {
35
- "@types/bun": "latest",
36
- "bun-plugin-dts": "^0.2.1",
36
+ "devDependencies": {
37
+ "@types/bun": "latest",
38
+ "bun-plugin-dts": "^0.2.1",
37
39
  "@rabbit-company/logger": "^2.1.1",
38
40
  "chalk": "^5.3.0"
39
- },
40
- "peerDependencies": {
41
- "typescript": "^5.0.0"
42
- }
41
+ },
42
+ "peerDependencies": {
43
+ "typescript": "^5.0.0"
44
+ }
43
45
  }