@sanctumterra/raknet 1.0.2 → 1.0.3

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.
@@ -1,4 +1,5 @@
1
1
  declare class Logger {
2
+ private static ANSI_COLORS;
2
3
  static info(message: string): void;
3
4
  static warn(message: string): void;
4
5
  static error(message: string): void;
@@ -7,5 +8,6 @@ declare class Logger {
7
8
  static chat(message: string): void;
8
9
  static getCallerPath(): string;
9
10
  static chatColors(text: string): string;
11
+ private static colorize;
10
12
  }
11
13
  export { Logger };
@@ -9,27 +9,26 @@ Object.defineProperty(exports, "Logger", {
9
9
  }
10
10
  });
11
11
  const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
- const _chalk = /*#__PURE__*/ _interop_require_wildcard._(require("chalk"));
13
12
  const _path = /*#__PURE__*/ _interop_require_wildcard._(require("path"));
14
13
  class Logger {
15
14
  static info(message) {
16
- console.info(this.date(), _chalk.blueBright("INFO"), _chalk.cyanBright(message));
15
+ console.info(this.date(), this.colorize("INFO", this.ANSI_COLORS.blue), this.colorize(message, this.ANSI_COLORS.cyan));
17
16
  }
18
17
  static warn(message) {
19
- console.info(this.date(), _chalk.yellow("WARN"), _chalk.yellowBright(message));
18
+ console.warn(this.date(), this.colorize("WARN", this.ANSI_COLORS.yellow), this.colorize(message, this.ANSI_COLORS.yellow + this.ANSI_COLORS.bright));
20
19
  }
21
20
  static error(message) {
22
- console.info(this.date(), _chalk.red("ERROR"), _chalk.redBright(message), this.getCallerPath());
21
+ console.error(this.date(), this.colorize("ERROR", this.ANSI_COLORS.red), this.colorize(message, this.ANSI_COLORS.red + this.ANSI_COLORS.bright), this.getCallerPath());
23
22
  }
24
23
  static debug(message) {
25
- if (process.argv.includes('--debug')) console.info(this.date(), _chalk.gray("DEBUG"), message, this.getCallerPath());
24
+ if (process.argv.includes('--debug')) console.debug(this.date(), this.colorize("DEBUG", this.ANSI_COLORS.gray), message, this.getCallerPath());
26
25
  }
27
26
  static date() {
28
27
  const date = new Date();
29
- return `${_chalk.gray("[")}${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}:${_chalk.dim(date.getMilliseconds())}${_chalk.gray("]")}`;
28
+ return `${this.colorize("[", this.ANSI_COLORS.gray)}${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}:${this.colorize(date.getMilliseconds().toString(), this.ANSI_COLORS.dim)}${this.colorize("]", this.ANSI_COLORS.gray)}`;
30
29
  }
31
30
  static chat(message) {
32
- console.info(this.date(), _chalk.green("CHAT"), this.chatColors(message));
31
+ console.info(this.date(), this.colorize("CHAT", this.ANSI_COLORS.green), this.chatColors(message));
33
32
  }
34
33
  static getCallerPath() {
35
34
  const err = new Error();
@@ -40,31 +39,46 @@ class Logger {
40
39
  if (match) {
41
40
  const filePath = _path.relative(process.cwd(), match[1]);
42
41
  const lineNumber = match[2];
43
- return `${_chalk.magenta(filePath)}:${_chalk.green(lineNumber)}`;
42
+ return `${this.colorize(filePath, this.ANSI_COLORS.magenta)}:${this.colorize(lineNumber, this.ANSI_COLORS.green)}`;
44
43
  }
45
44
  }
46
- return _chalk.magenta("Unknown caller");
45
+ return this.colorize("Unknown caller", this.ANSI_COLORS.magenta);
47
46
  }
48
47
  static chatColors(text) {
49
48
  const ansiColors = {
50
- "0": "\u001B[30m",
51
- "1": "\u001B[34m",
52
- "2": "\u001B[32m",
53
- "3": "\u001B[36m",
54
- "4": "\u001B[31m",
55
- "5": "\u001B[35m",
56
- "6": "\u001B[33m",
57
- "7": "\u001B[37m",
58
- "8": "\u001B[90m",
59
- "9": "\u001B[94m",
60
- "a": "\u001B[92m",
61
- "b": "\u001B[96m",
62
- "c": "\u001B[91m",
63
- "d": "\u001B[95m",
64
- "e": "\u001B[93m",
65
- "f": "\u001B[97m",
66
- "r": "\u001B[0m"
49
+ "0": "\x1b[30m",
50
+ "1": "\x1b[34m",
51
+ "2": "\x1b[32m",
52
+ "3": "\x1b[36m",
53
+ "4": "\x1b[31m",
54
+ "5": "\x1b[35m",
55
+ "6": "\x1b[33m",
56
+ "7": "\x1b[37m",
57
+ "8": "\x1b[90m",
58
+ "9": "\x1b[94m",
59
+ "a": "\x1b[92m",
60
+ "b": "\x1b[96m",
61
+ "c": "\x1b[91m",
62
+ "d": "\x1b[95m",
63
+ "e": "\x1b[93m",
64
+ "f": "\x1b[97m",
65
+ "r": "\x1b[0m"
67
66
  };
68
- return text.replace(/§[\da-fk-or]/g, (m)=>ansiColors[m[1]] || "") + "\u001B[0m";
67
+ return text.replace(/§[\da-fk-or]/g, (m)=>ansiColors[m[1]] || "") + "\x1b[0m";
68
+ }
69
+ static colorize(text, color) {
70
+ return `${color}${text}${this.ANSI_COLORS.reset}`;
69
71
  }
70
72
  }
73
+ Logger.ANSI_COLORS = {
74
+ reset: "\x1b[0m",
75
+ bright: "\x1b[1m",
76
+ dim: "\x1b[2m",
77
+ red: "\x1b[31m",
78
+ green: "\x1b[32m",
79
+ yellow: "\x1b[33m",
80
+ blue: "\x1b[34m",
81
+ magenta: "\x1b[35m",
82
+ cyan: "\x1b[36m",
83
+ gray: "\x1b[90m"
84
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanctumterra/raknet",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "emitDeclarationOnly": true,