@protoqol/vivid-log 2.0.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,224 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Utils = void 0;
7
+ const enums_1 = require("./enums");
8
+ const config_1 = __importDefault(require("./config/config"));
9
+ const ansi_1 = require("./ansi");
10
+ const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
11
+ class Utils {
12
+ static evaluate(loggable, type) {
13
+ if (this.checkTypeLog(loggable) === enums_1.LogSize.SMALL_LOGGABLE) {
14
+ return this.fire(this.logBuilder(loggable, type), this.styleBuilder(type));
15
+ }
16
+ if (this.checkTypeLog(loggable) === enums_1.LogSize.BIG_LOGGABLE) {
17
+ const style = this.styleBuilder(type);
18
+ if (isBrowser) {
19
+ console.log(this.logBuilder(loggable, type, true), style.status, style.time, style.type);
20
+ console.log(loggable);
21
+ console.log("%c ", "padding: 0 5px;font-weight: bolder; border-top: 2px solid " + (window.vividLog?.config?.status[type]?.lightColor || "#000") + ";");
22
+ }
23
+ else {
24
+ console.log(this.logBuilder(loggable, type, true));
25
+ console.log(loggable);
26
+ const color = global.vividLog?.config?.status[type]?.lightColor || config_1.default.status[type]?.lightColor || "#000";
27
+ console.log((0, ansi_1.hexToAnsi)(color) + "-------------------------" + ansi_1.ANSI.reset);
28
+ }
29
+ }
30
+ return false;
31
+ }
32
+ static getType(loggable) {
33
+ let len;
34
+ if (loggable instanceof Error) {
35
+ return "error";
36
+ }
37
+ switch (typeof loggable) {
38
+ case "string":
39
+ len = loggable.length || 0;
40
+ return `string[${len}]`;
41
+ case "boolean":
42
+ return "boolean";
43
+ case "number":
44
+ len = String(loggable).length;
45
+ return `integer[${len}]`;
46
+ case "object":
47
+ if (loggable === null) {
48
+ return "null";
49
+ }
50
+ if (Array.isArray(loggable)) {
51
+ len = loggable.length;
52
+ return `array[${len}]`;
53
+ }
54
+ len = Object.keys(loggable).length;
55
+ return `object[${len}]`;
56
+ case "bigint":
57
+ len = String(loggable).length;
58
+ return `big integer[${len}]`;
59
+ case "function":
60
+ return "function";
61
+ case "symbol":
62
+ return "symbol";
63
+ case "undefined":
64
+ return "undefined";
65
+ default:
66
+ return false;
67
+ }
68
+ }
69
+ static isTypeOfLoggable(variable) {
70
+ return ["log", "debug", "error", "info", "success", "warning"].includes(variable);
71
+ }
72
+ static createTime(format) {
73
+ const time = this.timeObj(format);
74
+ let returnTime = "";
75
+ const formats = time.format;
76
+ for (let iteration = 0; iteration < formats.length; iteration++) {
77
+ switch (formats[iteration]) {
78
+ case "h":
79
+ returnTime += time.h;
80
+ break;
81
+ case "m":
82
+ returnTime += time.m;
83
+ break;
84
+ case "s":
85
+ returnTime += time.s;
86
+ break;
87
+ case "ms":
88
+ returnTime += time.ms;
89
+ break;
90
+ }
91
+ if (iteration !== (formats.length - 1)) {
92
+ returnTime += ":";
93
+ }
94
+ }
95
+ return returnTime.length >= 1 ? returnTime : false;
96
+ }
97
+ static timeObj(format) {
98
+ const date = new Date();
99
+ const cfg = (isBrowser ? window.vividLog?.config : global.vividLog?.config) || config_1.default;
100
+ return {
101
+ format: format.split(":") || cfg.timeNotation.split(":"),
102
+ h: String(date.getHours()).padStart(2, "0"),
103
+ m: String(date.getMinutes()).padStart(2, "0"),
104
+ s: String(date.getSeconds()).padStart(2, "0"),
105
+ ms: String(date.getMilliseconds()).padStart(2, "0"),
106
+ };
107
+ }
108
+ static checkTypeLog(loggable) {
109
+ return (typeof loggable === "string" || typeof loggable === "number" || typeof loggable === "undefined")
110
+ ? enums_1.LogSize.SMALL_LOGGABLE
111
+ : enums_1.LogSize.BIG_LOGGABLE;
112
+ }
113
+ static makeStyleCompatible(css) {
114
+ return css;
115
+ }
116
+ static styleBuilder(type, color) {
117
+ const cfg = (isBrowser ? window.vividLog?.config : global.vividLog?.config) || config_1.default;
118
+ const lightTheme = cfg.iUseLightTheme ? "color: white;" : "";
119
+ const customStyle = cfg.customStyle;
120
+ const fontSize = `font-size: ${cfg.fontSize};`;
121
+ const typeOrColorLight = this.isTypeOfLoggable(type) ? cfg.status[type].lightColor : color;
122
+ const typeOrColorDark = this.isTypeOfLoggable(type) ? cfg.status[type].darkColor : color;
123
+ const style = {
124
+ default: "color: #F1F5F8;" + fontSize,
125
+ labelDefault: `border-radius: 5px; padding: 5px; background: ${typeOrColorLight};`,
126
+ timeDefault: "",
127
+ logNameDefault: "font-weight: bold;",
128
+ typeNameDefault: `background: ${typeOrColorDark};`,
129
+ varDefault: "margin-top: 10px; margin-bottom: 5px;" + lightTheme,
130
+ custom: this.makeStyleCompatible(customStyle),
131
+ };
132
+ return {
133
+ status: style.default + style.labelDefault + style.logNameDefault,
134
+ time: style.default + style.labelDefault + style.timeDefault,
135
+ type: style.default + style.labelDefault + style.typeNameDefault,
136
+ var: style.default + style.varDefault + style.custom,
137
+ };
138
+ }
139
+ static logBuilder(loggable, typeOrLabel, onlyHeader = false) {
140
+ const cfg = (isBrowser ? window.vividLog?.config : global.vividLog?.config) || config_1.default;
141
+ const label = this.isTypeOfLoggable(typeOrLabel) ? cfg.status[typeOrLabel].code : typeOrLabel;
142
+ if (!isBrowser) {
143
+ const time = this.createTime(cfg.timeNotation);
144
+ const type = this.getType(loggable);
145
+ const statusColor = this.isTypeOfLoggable(typeOrLabel) ? cfg.status[typeOrLabel].lightColor : (typeOrLabel === "LABEL" ? "#800080" : "#A52A2A");
146
+ const typeColor = this.isTypeOfLoggable(typeOrLabel) ? cfg.status[typeOrLabel].darkColor : (typeOrLabel === "LABEL" ? "#800080" : "#A52A2A");
147
+ const labelStyled = (0, ansi_1.hexToAnsiBg)(statusColor) + ansi_1.ANSI.white + ansi_1.ANSI.bold + ` ${label} ` + ansi_1.ANSI.reset;
148
+ const timeStyled = (0, ansi_1.hexToAnsiBg)("#444") + ansi_1.ANSI.white + ` ${time} ` + ansi_1.ANSI.reset;
149
+ const typeStyled = (0, ansi_1.hexToAnsiBg)(typeColor) + ansi_1.ANSI.white + ` ${type} ` + ansi_1.ANSI.reset;
150
+ if (!onlyHeader) {
151
+ return `${labelStyled}${timeStyled}${typeStyled}${cfg.newLine ? " " : "\n"} ${loggable}`;
152
+ }
153
+ return `${labelStyled}${timeStyled}${typeStyled}`;
154
+ }
155
+ if (!onlyHeader) {
156
+ return "%c" + label +
157
+ "%c" + this.createTime(cfg.timeNotation) +
158
+ "%c" + this.getType(loggable) + (cfg.newLine ? " " : "\n") +
159
+ "%c " + loggable;
160
+ }
161
+ const typeCode = cfg.status[typeOrLabel]?.code || typeOrLabel;
162
+ return "%c" + typeCode +
163
+ "%c" + this.createTime(cfg.timeNotation) +
164
+ "%c" + this.getType(loggable);
165
+ }
166
+ static resetConfs() {
167
+ const cfg = (isBrowser ? window.vividLog?.config : global.vividLog?.config) || config_1.default;
168
+ cfg.customStyle = "";
169
+ cfg.autoGroup = false;
170
+ return cfg.customStyle === "" && cfg.autoGroup === false;
171
+ }
172
+ static fire(loggable, style) {
173
+ if (this.resetConfs()) {
174
+ if (isBrowser) {
175
+ console.log(loggable, style.status, style.time, style.type, style.var);
176
+ }
177
+ else {
178
+ console.log(loggable);
179
+ }
180
+ return true;
181
+ }
182
+ return false;
183
+ }
184
+ static fireLabel(label, type = "LABEL") {
185
+ const cfg = (isBrowser ? window.vividLog?.config : global.vividLog?.config) || config_1.default;
186
+ if (isBrowser) {
187
+ const compiled = `%c${label}%c${this.createTime(cfg.timeNotation)}%c${type}`;
188
+ const style = this.styleBuilder("purple", "purple");
189
+ style.var = "";
190
+ this.fire(compiled, style);
191
+ }
192
+ else {
193
+ const compiled = this.logBuilder(null, label, true);
194
+ this.fire(compiled, {});
195
+ }
196
+ }
197
+ static loggable(args, type) {
198
+ if (args.length > 1) {
199
+ return this.iterateLoggables(args, type);
200
+ }
201
+ return this.evaluate(args[0], type);
202
+ }
203
+ static iterateLoggables(args, type) {
204
+ const cfg = (isBrowser ? window.vividLog?.config : global.vividLog?.config) || config_1.default;
205
+ if (cfg.autoGroup) {
206
+ this.fireLabel(type.toUpperCase(), `Group[${args.length}]`);
207
+ if (isBrowser && console.groupCollapsed) {
208
+ console.groupCollapsed(type.toUpperCase());
209
+ }
210
+ }
211
+ for (let i = 0; i < args.length; i++) {
212
+ this.evaluate(args[i], "log");
213
+ }
214
+ if (cfg.autoGroup) {
215
+ if (isBrowser && console.groupEnd) {
216
+ console.groupEnd();
217
+ }
218
+ }
219
+ cfg.autoGroup = false;
220
+ return true;
221
+ }
222
+ }
223
+ exports.Utils = Utils;
224
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAgC;AAChC,6DAAqC;AACrC,iCAAoD;AAUpD,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAC;AAE1F,MAAa,KAAK;IACd,MAAM,CAAC,QAAQ,CAAC,QAAa,EAAE,IAAY;QACvC,IAAI,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,eAAO,CAAC,cAAc,EAAE,CAAC;YACzD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/E,CAAC;QAED,IAAI,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,eAAO,CAAC,YAAY,EAAE,CAAC;YACvD,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YAEtC,IAAI,SAAS,EAAE,CAAC;gBACZ,OAAO,CAAC,GAAG,CACP,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,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C,CAAE,MAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,gBAAM,CAAC;QAE/F,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;YAChB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,SAAS,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;YAC5D,IAAI,SAAS,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;gBACtC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;YAC/C,CAAC;QACL,CAAC;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACnC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QAClC,CAAC;QAED,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;YAChB,IAAI,SAAS,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;gBAChC,OAAO,CAAC,QAAQ,EAAE,CAAC;YACvB,CAAC;QACL,CAAC;QAED,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC;QAEtB,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAhQD,sBAgQC"}
@@ -0,0 +1,51 @@
1
+ import { VividLogConfig } from "./config/config";
2
+ export declare class VividLog {
3
+ config: VividLogConfig;
4
+ constructor();
5
+ /**
6
+ * Take over default error log
7
+ */
8
+ takeOver(activate?: boolean): void;
9
+ /**
10
+ * Chain before log to group the all logs
11
+ */
12
+ group(grouped?: boolean): this;
13
+ /**
14
+ * Chain before log to give message a custom style
15
+ */
16
+ style(customStyle?: string): this;
17
+ /**
18
+ * Only log a label
19
+ */
20
+ fireLabel(label: string): this;
21
+ /**
22
+ * Normal priority log
23
+ */
24
+ log(...args: any[]): this;
25
+ /**
26
+ * Debug priority log
27
+ */
28
+ debug(...args: any[]): this;
29
+ /**
30
+ * Error priority log
31
+ */
32
+ err(...args: any[]): this;
33
+ /**
34
+ * Warning priority log
35
+ */
36
+ warn(...args: any[]): this;
37
+ /**
38
+ * Success priority log
39
+ */
40
+ done(...args: any[]): this;
41
+ /**
42
+ * Information priority log
43
+ */
44
+ info(...args: any[]): this;
45
+ /**
46
+ * Custom logging utility
47
+ */
48
+ say(loggable: any, label?: string, color?: string): boolean | void;
49
+ }
50
+ declare const vividLogInstance: VividLog;
51
+ export default vividLogInstance;
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.VividLog = void 0;
7
+ const utils_1 = require("./utils");
8
+ const methods_1 = require("./methods");
9
+ const config_1 = __importDefault(require("./config/config"));
10
+ const enums_1 = require("./enums");
11
+ class VividLog {
12
+ config = config_1.default;
13
+ constructor() {
14
+ if (typeof window !== "undefined") {
15
+ window.vividLog = this;
16
+ }
17
+ else if (typeof global !== "undefined") {
18
+ global.vividLog = this;
19
+ }
20
+ }
21
+ /**
22
+ * Take over default error log
23
+ */
24
+ takeOver(activate = false) {
25
+ methods_1.Methods.takeOver(activate);
26
+ }
27
+ /**
28
+ * Chain before log to group the all logs
29
+ */
30
+ group(grouped = true) {
31
+ this.config.autoGroup = grouped;
32
+ return this;
33
+ }
34
+ /**
35
+ * Chain before log to give message a custom style
36
+ */
37
+ style(customStyle = "") {
38
+ this.config.customStyle = customStyle;
39
+ return this;
40
+ }
41
+ /**
42
+ * Only log a label
43
+ */
44
+ fireLabel(label) {
45
+ utils_1.Utils.fireLabel(label);
46
+ return this;
47
+ }
48
+ /**
49
+ * Normal priority log
50
+ */
51
+ log(...args) {
52
+ utils_1.Utils.loggable(args, "log");
53
+ return this;
54
+ }
55
+ /**
56
+ * Debug priority log
57
+ */
58
+ debug(...args) {
59
+ utils_1.Utils.loggable(args, "debug");
60
+ return this;
61
+ }
62
+ /**
63
+ * Error priority log
64
+ */
65
+ err(...args) {
66
+ utils_1.Utils.loggable(args, "error");
67
+ return this;
68
+ }
69
+ /**
70
+ * Warning priority log
71
+ */
72
+ warn(...args) {
73
+ utils_1.Utils.loggable(args, "warning");
74
+ return this;
75
+ }
76
+ /**
77
+ * Success priority log
78
+ */
79
+ done(...args) {
80
+ utils_1.Utils.loggable(args, "success");
81
+ return this;
82
+ }
83
+ /**
84
+ * Information priority log
85
+ */
86
+ info(...args) {
87
+ utils_1.Utils.loggable(args, "info");
88
+ return this;
89
+ }
90
+ /**
91
+ * Custom logging utility
92
+ */
93
+ say(loggable, label, color) {
94
+ const type = utils_1.Utils.checkTypeLog(loggable);
95
+ if (type === enums_1.LogSize.SMALL_LOGGABLE) {
96
+ return utils_1.Utils.fire(utils_1.Utils.logBuilder(loggable, label || (typeof document !== "undefined" ? document.title : (typeof process !== "undefined" ? "node" : "vividLog"))), utils_1.Utils.styleBuilder(color || "brown", color || "brown"));
97
+ }
98
+ if (type === enums_1.LogSize.BIG_LOGGABLE) {
99
+ const style = utils_1.Utils.styleBuilder("log"); // Default to log style if big
100
+ console.log(utils_1.Utils.logBuilder(loggable, "log", true), style.status, style.time, style.type);
101
+ console.log(loggable);
102
+ console.log("%c ", "padding: 0 5px;font-weight: bolder; border-top: 2px solid " + this.config.status["log"].lightColor + ";");
103
+ return true;
104
+ }
105
+ }
106
+ }
107
+ exports.VividLog = VividLog;
108
+ const vividLogInstance = new VividLog();
109
+ exports.default = vividLogInstance;
110
+ if (typeof window !== "undefined") {
111
+ window.vividLog = vividLogInstance;
112
+ }
113
+ else if (typeof global !== "undefined") {
114
+ global.vividLog = vividLogInstance;
115
+ }
116
+ //# sourceMappingURL=vividLog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vividLog.js","sourceRoot":"","sources":["../../lib/vividLog.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA8B;AAC9B,uCAAkC;AAClC,6DAAuD;AACvD,mC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AC;YACF,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACtB,OAAO,CAAC,GAAG,CACP,6BAA6B,EAC7B,4DAA4D,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,UAAU,GAAG,GAAG,CAC5G,CAAC;YACF,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;CACJ;AAvHD,4BAuHC;AAED,MAAM,gBAAgB,GAAG,IAAI,QAAQ,EAAE,CAAC;AACxC,kBAAe,gBAAgB,CAAC;AAEhC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IAC/B,MAAc,CAAC,QAAQ,GAAG,gBAAgB,CAAC;AAChD,CAAC;KAAM,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IACtC,MAAc,CAAC,QAAQ,GAAG,gBAAgB,CAAC;AAChD,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ const assert = __importStar(require("assert"));
40
+ const utils_1 = require("../lib/utils");
41
+ const enums_1 = require("../lib/enums");
42
+ const vividLog_1 = __importDefault(require("../lib/vividLog"));
43
+ describe("Vivid Log | Testing Suite", function () {
44
+ let v;
45
+ let ENUM;
46
+ before(function () {
47
+ v = vividLog_1.default;
48
+ ENUM = enums_1.LogSize;
49
+ });
50
+ describe("vividLog.methods.takeOver()", function () {
51
+ it("should return true when native error log has been taken over", function () {
52
+ assert.strictEqual(v.takeOver(true), undefined);
53
+ });
54
+ });
55
+ describe("vividLog.util.createTime()", function () {
56
+ it("should return a timestamp (string)", function () {
57
+ assert.ok(utils_1.Utils.createTime("h:m:s"));
58
+ assert.strictEqual(typeof utils_1.Utils.createTime("h:m:s"), "string");
59
+ });
60
+ });
61
+ describe("vividLog.util.getType()", function () {
62
+ it("should return a string[9] with getType('testValue')", function () {
63
+ assert.strictEqual(utils_1.Utils.getType("testValue"), "string[9]");
64
+ });
65
+ it("should return integer[3] with getType(124)", function () {
66
+ assert.strictEqual(utils_1.Utils.getType(124), "integer[3]");
67
+ });
68
+ it("should return boolean with getType(true)", function () {
69
+ assert.strictEqual(utils_1.Utils.getType(true), "boolean");
70
+ });
71
+ it("should return object[2] with getType({t: 'test', s: 'stest'})", function () {
72
+ assert.strictEqual(utils_1.Utils.getType({
73
+ test: "object",
74
+ second: "object",
75
+ }), "object[2]");
76
+ });
77
+ it("should return array[3] with getType([1, 2, 3])", function () {
78
+ assert.strictEqual(utils_1.Utils.getType([1, 2, 3]), "array[3]");
79
+ });
80
+ it("should return null with getType(null)", function () {
81
+ assert.strictEqual(utils_1.Utils.getType(null), "null");
82
+ });
83
+ it("should return error with getType(new Error())", function () {
84
+ assert.strictEqual(utils_1.Utils.getType(new Error("test")), "error");
85
+ });
86
+ it("should return a function with getType(function)", function () {
87
+ assert.strictEqual(utils_1.Utils.getType(function test() {
88
+ var testval = "val";
89
+ }), "function");
90
+ });
91
+ it("should return undefined with getType()", function () {
92
+ assert.strictEqual(utils_1.Utils.getType(true), "boolean");
93
+ });
94
+ });
95
+ describe("Terminal logging", function () {
96
+ it("should log to terminal without crashing", function () {
97
+ v.log("Test terminal log");
98
+ v.done("Test success");
99
+ v.warn("Test warning");
100
+ v.err("Test error");
101
+ v.info("Test info");
102
+ v.debug("Test debug");
103
+ v.say("Test say", "CUSTOM", "#ff00ff");
104
+ v.fireLabel("TEST LABEL");
105
+ });
106
+ it("should log complex objects to terminal without crashing", function () {
107
+ v.log({ a: 1, b: 2 });
108
+ v.err(new Error("Test Error Object"));
109
+ });
110
+ });
111
+ });
112
+ //# sourceMappingURL=test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.js","sourceRoot":"","sources":["../../test/test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AACjC,wCAAmC;AACnC,wCAAqC;AACrC,+DAAuC;AAEvC,QAAQ,CAAC,2BAA2B,EAAE;IAClC,IAAI,CAAM,CAAC;IACX,IAAI,IAAoB,CAAC;IAEzB,MAAM,CAAC;QACH,CAAC,GAAG,kBAAQ,CAAC;QACb,IAAI,GAAG,eAAO,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,6BAA6B,EAAE;QACpC,EAAE,CAAC,8DAA8D,EAAE;YAC/D,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAA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C,EAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAC,CAAC,CAAC;YACpB,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.vividLog=t():e.vividLog=t()}(this,()=>(()=>{"use strict";var e={786(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.hexToAnsiBg=t.hexToAnsi=t.ANSI=void 0,t.ANSI={reset:"",bold:"",italic:"",underline:"",inverse:"",black:"",red:"",green:"",yellow:"",blue:"",magenta:"",cyan:"",white:"",bgBlack:"",bgRed:"",bgGreen:"",bgYellow:"",bgBlue:"",bgMagenta:"",bgCyan:"",bgWhite:""},t.hexToAnsi=e=>(3===(e=e.replace(/^#/,"")).length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),`[38;2;${parseInt(e.substring(0,2),16)};${parseInt(e.substring(2,4),16)};${parseInt(e.substring(4,6),16)}m`),t.hexToAnsiBg=e=>(3===(e=e.replace(/^#/,"")).length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),`[48;2;${parseInt(e.substring(0,2),16)};${parseInt(e.substring(2,4),16)};${parseInt(e.substring(4,6),16)}m`)},180(e,t){Object.defineProperty(t,"__esModule",{value:!0});const o={autoGroup:!0,timeNotation:"h:m:s",iUseLightTheme:!1,customStyle:"",fontSize:"12px",newLine:"undefined"!=typeof navigator&&navigator.userAgent.includes("Firefox"),status:{error:{lightColor:"#da3030",darkColor:"#872323",code:"ERROR"},success:{lightColor:"#00b808",darkColor:"#21872a",code:"SUCCESS"},warning:{lightColor:"#da993e",darkColor:"#875a2a",code:"WARNING"},info:{lightColor:"#b0b52c",darkColor:"#788738",code:"INFO"},debug:{lightColor:"#da43be",darkColor:"#872773",code:"DEBUG"},log:{lightColor:"#65b0b9",darkColor:"#4f7e87",code:"LOG"}}};t.default=o},671(e,t){var o;Object.defineProperty(t,"__esModule",{value:!0}),t.WARNING=t.LOG=t.INFO=t.ERROR=t.DEBUG=t.LogSize=void 0,function(e){e[e.SMALL_LOGGABLE=0]="SMALL_LOGGABLE",e[e.BIG_LOGGABLE=1]="BIG_LOGGABLE"}(o||(t.LogSize=o={})),t.DEBUG={i:2,val:"debug"},t.ERROR={i:3,val:"error"},t.INFO={i:4,val:"info"},t.LOG={i:5,val:"log"},t.WARNING={i:6,val:"warning"}},483(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.Methods=void 0,t.Methods=class{static takeOver(e){if(e)return"undefined"!=typeof window?window.onerror=(e,t,o,i,r)=>!!r&&(window.vividLog?.err(r.stack),!0):"undefined"!=typeof process&&process.on("uncaughtException",e=>{const t=o.g.vividLog;t?t.err(e.stack):console.error(e)}),!0;const t="undefined"!=typeof window?window.vividLog:o.g.vividLog;return t?.style("font-style: italic;").say("f v.takeOver() was called but was not turned on. Do so by using v.takeOver(true)","VividLog","#E3342F"),!1}}},704(e,t,o){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Utils=void 0;const r=o(671),s=i(o(180)),n=o(786),l="undefined"!=typeof window&&void 0!==window.document;t.Utils=class{static evaluate(e,t){if(this.checkTypeLog(e)===r.LogSize.SMALL_LOGGABLE)return this.fire(this.logBuilder(e,t),this.styleBuilder(t));if(this.checkTypeLog(e)===r.LogSize.BIG_LOGGABLE){const i=this.styleBuilder(t);if(l)console.log(this.logBuilder(e,t,!0),i.status,i.time,i.type),console.log(e),console.log("%c ","padding: 0 5px;font-weight: bolder; border-top: 2px solid "+(window.vividLog?.config?.status[t]?.lightColor||"#000")+";");else{console.log(this.logBuilder(e,t,!0)),console.log(e);const i=o.g.vividLog?.config?.status[t]?.lightColor||s.default.status[t]?.lightColor||"#000";console.log((0,n.hexToAnsi)(i)+"-------------------------"+n.ANSI.reset)}}return!1}static getType(e){let t;if(e instanceof Error)return"error";switch(typeof e){case"string":return t=e.length||0,`string[${t}]`;case"boolean":return"boolean";case"number":return t=String(e).length,`integer[${t}]`;case"object":return null===e?"null":Array.isArray(e)?(t=e.length,`array[${t}]`):(t=Object.keys(e).length,`object[${t}]`);case"bigint":return t=String(e).length,`big integer[${t}]`;case"function":return"function";case"symbol":return"symbol";case"undefined":return"undefined";default:return!1}}static isTypeOfLoggable(e){return["log","debug","error","info","success","warning"].includes(e)}static createTime(e){const t=this.timeObj(e);let o="";const i=t.format;for(let e=0;e<i.length;e++){switch(i[e]){case"h":o+=t.h;break;case"m":o+=t.m;break;case"s":o+=t.s;break;case"ms":o+=t.ms}e!==i.length-1&&(o+=":")}return o.length>=1&&o}static timeObj(e){const t=new Date,i=(l?window.vividLog?.config:o.g.vividLog?.config)||s.default;return{format:e.split(":")||i.timeNotation.split(":"),h:String(t.getHours()).padStart(2,"0"),m:String(t.getMinutes()).padStart(2,"0"),s:String(t.getSeconds()).padStart(2,"0"),ms:String(t.getMilliseconds()).padStart(2,"0")}}static checkTypeLog(e){return"string"==typeof e||"number"==typeof e||void 0===e?r.LogSize.SMALL_LOGGABLE:r.LogSize.BIG_LOGGABLE}static makeStyleCompatible(e){return e}static styleBuilder(e,t){const i=(l?window.vividLog?.config:o.g.vividLog?.config)||s.default,r=i.iUseLightTheme?"color: white;":"",n=i.customStyle,g=`color: #F1F5F8;font-size: ${i.fontSize};`,a=`border-radius: 5px; padding: 5px; background: ${this.isTypeOfLoggable(e)?i.status[e].lightColor:t};`;return{status:g+a+"font-weight: bold;",time:g+a+"",type:g+a+`background: ${this.isTypeOfLoggable(e)?i.status[e].darkColor:t};`,var:g+"margin-top: 10px; margin-bottom: 5px;"+r+this.makeStyleCompatible(n)}}static logBuilder(e,t,i=!1){const r=(l?window.vividLog?.config:o.g.vividLog?.config)||s.default,g=this.isTypeOfLoggable(t)?r.status[t].code:t;if(!l){const o=this.createTime(r.timeNotation),s=this.getType(e),l=this.isTypeOfLoggable(t)?r.status[t].lightColor:"LABEL"===t?"#800080":"#A52A2A",a=this.isTypeOfLoggable(t)?r.status[t].darkColor:"LABEL"===t?"#800080":"#A52A2A",u=(0,n.hexToAnsiBg)(l)+n.ANSI.white+n.ANSI.bold+` ${g} `+n.ANSI.reset,d=(0,n.hexToAnsiBg)("#444")+n.ANSI.white+` ${o} `+n.ANSI.reset,c=(0,n.hexToAnsiBg)(a)+n.ANSI.white+` ${s} `+n.ANSI.reset;return i?`${u}${d}${c}`:`${u}${d}${c}${r.newLine?" ":"\n"} ${e}`}return i?"%c"+(r.status[t]?.code||t)+"%c"+this.createTime(r.timeNotation)+"%c"+this.getType(e):"%c"+g+"%c"+this.createTime(r.timeNotation)+"%c"+this.getType(e)+(r.newLine?" ":"\n")+"%c "+e}static resetConfs(){const e=(l?window.vividLog?.config:o.g.vividLog?.config)||s.default;return e.customStyle="",e.autoGroup=!1,""===e.customStyle&&!1===e.autoGroup}static fire(e,t){return!!this.resetConfs()&&(l?console.log(e,t.status,t.time,t.type,t.var):console.log(e),!0)}static fireLabel(e,t="LABEL"){const i=(l?window.vividLog?.config:o.g.vividLog?.config)||s.default;if(l){const o=`%c${e}%c${this.createTime(i.timeNotation)}%c${t}`,r=this.styleBuilder("purple","purple");r.var="",this.fire(o,r)}else{const t=this.logBuilder(null,e,!0);this.fire(t,{})}}static loggable(e,t){return e.length>1?this.iterateLoggables(e,t):this.evaluate(e[0],t)}static iterateLoggables(e,t){const i=(l?window.vividLog?.config:o.g.vividLog?.config)||s.default;i.autoGroup&&(this.fireLabel(t.toUpperCase(),`Group[${e.length}]`),l&&console.groupCollapsed&&console.groupCollapsed(t.toUpperCase()));for(let t=0;t<e.length;t++)this.evaluate(e[t],"log");return i.autoGroup&&l&&console.groupEnd&&console.groupEnd(),i.autoGroup=!1,!0}}},119(e,t,o){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.VividLog=void 0;const r=o(704),s=o(483),n=i(o(180)),l=o(671);class g{config=n.default;constructor(){"undefined"!=typeof window?window.vividLog=this:void 0!==o.g&&(o.g.vividLog=this)}takeOver(e=!1){s.Methods.takeOver(e)}group(e=!0){return this.config.autoGroup=e,this}style(e=""){return this.config.customStyle=e,this}fireLabel(e){return r.Utils.fireLabel(e),this}log(...e){return r.Utils.loggable(e,"log"),this}debug(...e){return r.Utils.loggable(e,"debug"),this}err(...e){return r.Utils.loggable(e,"error"),this}warn(...e){return r.Utils.loggable(e,"warning"),this}done(...e){return r.Utils.loggable(e,"success"),this}info(...e){return r.Utils.loggable(e,"info"),this}say(e,t,o){const i=r.Utils.checkTypeLog(e);if(i===l.LogSize.SMALL_LOGGABLE)return r.Utils.fire(r.Utils.logBuilder(e,t||("undefined"!=typeof document?document.title:"undefined"!=typeof process?"node":"vividLog")),r.Utils.styleBuilder(o||"brown",o||"brown"));if(i===l.LogSize.BIG_LOGGABLE){const t=r.Utils.styleBuilder("log");return console.log(r.Utils.logBuilder(e,"log",!0),t.status,t.time,t.type),console.log(e),console.log("%c ","padding: 0 5px;font-weight: bolder; border-top: 2px solid "+this.config.status.log.lightColor+";"),!0}}}t.VividLog=g;const a=new g;t.default=a,"undefined"!=typeof window?window.vividLog=a:void 0!==o.g&&(o.g.vividLog=a)}},t={};function o(i){var r=t[i];if(void 0!==r)return r.exports;var s=t[i]={exports:{}};return e[i].call(s.exports,s,s.exports,o),s.exports}return o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o(119)})());
2
+ //# sourceMappingURL=vividLog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vividLog.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,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APuB,GCGEyF,EAAoB,I","sources":["webpack://vividLog/webpack/universalModuleDefinition","webpack://vividLog/./lib/ansi.ts","webpack://vividLog/./lib/config/config.ts","webpack://vividLog/./lib/enums.ts","webpack://vividLog/./lib/methods.ts","webpack://vividLog/./lib/utils.ts","webpack://vividLog/./lib/vividLog.ts","webpack://vividLog/webpack/bootstrap","webpack://vividLog/webpack/runtime/global","webpack://vividLog/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"vividLog\"] = factory();\n\telse\n\t\troot[\"vividLog\"] = factory();\n})(this, () => {\nreturn ","export const ANSI = {\r\n reset : \"\\x1b[0m\",\r\n bold : \"\\x1b[1m\",\r\n italic : \"\\x1b[3m\",\r\n underline: \"\\x1b[4m\",\r\n inverse : \"\\x1b[7m\",\r\n black : \"\\x1b[30m\",\r\n red : \"\\x1b[31m\",\r\n green : \"\\x1b[32m\",\r\n yellow : \"\\x1b[33m\",\r\n blue : \"\\x1b[34m\",\r\n magenta : \"\\x1b[35m\",\r\n cyan : \"\\x1b[36m\",\r\n white : \"\\x1b[37m\",\r\n bgBlack : \"\\x1b[40m\",\r\n bgRed : \"\\x1b[41m\",\r\n bgGreen : \"\\x1b[42m\",\r\n bgYellow : \"\\x1b[43m\",\r\n bgBlue : \"\\x1b[44m\",\r\n bgMagenta: \"\\x1b[45m\",\r\n bgCyan : \"\\x1b[46m\",\r\n bgWhite : \"\\x1b[47m\",\r\n};\r\n\r\nexport const hexToAnsi = (hex: string): string => {\r\n hex = hex.replace(/^#/, \"\");\r\n if (hex.length === 3) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];\r\n }\r\n const r = parseInt(hex.substring(0, 2), 16);\r\n const g = parseInt(hex.substring(2, 4), 16);\r\n const b = parseInt(hex.substring(4, 6), 16);\r\n\r\n return `\\x1b[38;2;${r};${g};${b}m`;\r\n};\r\n\r\nexport const hexToAnsiBg = (hex: string): string => {\r\n hex = hex.replace(/^#/, \"\");\r\n if (hex.length === 3) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];\r\n }\r\n const r = parseInt(hex.substring(0, 2), 16);\r\n const g = parseInt(hex.substring(2, 4), 16);\r\n const b = parseInt(hex.substring(4, 6), 16);\r\n\r\n return `\\x1b[48;2;${r};${g};${b}m`;\r\n};\r\n","export interface StatusConfig {\r\n lightColor: string;\r\n\r\n darkColor: string;\r\n\r\n code: string;\r\n}\r\n\r\nexport interface VividLogConfig {\r\n autoGroup: boolean;\r\n\r\n timeNotation: string;\r\n\r\n iUseLightTheme: boolean;\r\n\r\n customStyle: string;\r\n\r\n fontSize: string;\r\n\r\n newLine: boolean;\r\n\r\n status: {\r\n [key: string]: StatusConfig;\r\n };\r\n}\r\n\r\nconst config: VividLogConfig = {\r\n autoGroup : true,\r\n timeNotation : \"h:m:s\",\r\n iUseLightTheme: false,\r\n customStyle : \"\",\r\n fontSize : \"12px\",\r\n newLine : typeof navigator !== \"undefined\" ? navigator.userAgent.includes(\"Firefox\") : false,\r\n status : {\r\n error : {\r\n lightColor: \"#da3030\",\r\n darkColor : \"#872323\",\r\n code : \"ERROR\",\r\n },\r\n success: {\r\n lightColor: \"#00b808\",\r\n darkColor : \"#21872a\",\r\n code : \"SUCCESS\",\r\n },\r\n warning: {\r\n lightColor: \"#da993e\",\r\n darkColor : \"#875a2a\",\r\n code : \"WARNING\",\r\n },\r\n info : {\r\n lightColor: \"#b0b52c\",\r\n darkColor : \"#788738\",\r\n code : \"INFO\",\r\n },\r\n debug : {\r\n lightColor: \"#da43be\",\r\n darkColor : \"#872773\",\r\n code : \"DEBUG\",\r\n },\r\n log : {\r\n lightColor: \"#65b0b9\",\r\n darkColor : \"#4f7e87\",\r\n code : \"LOG\",\r\n },\r\n },\r\n};\r\n\r\nexport default config;\r\n","export enum LogSize {\r\n SMALL_LOGGABLE = 0,\r\n BIG_LOGGABLE = 1,\r\n}\r\n\r\nexport interface LogTypeInfo {\r\n i: number;\r\n\r\n val: string;\r\n}\r\n\r\nexport const DEBUG: LogTypeInfo = {\r\n i : 2,\r\n val: \"debug\",\r\n};\r\n\r\nexport const ERROR: LogTypeInfo = {\r\n i : 3,\r\n val: \"error\",\r\n};\r\n\r\nexport const INFO: LogTypeInfo = {\r\n i : 4,\r\n val: \"info\",\r\n};\r\n\r\nexport const LOG: LogTypeInfo = {\r\n i : 5,\r\n val: \"log\",\r\n};\r\n\r\nexport const WARNING: LogTypeInfo = {\r\n i : 6,\r\n val: \"warning\",\r\n};\r\n","export class Methods {\r\n static takeOver(turnOn: boolean): boolean {\r\n if (turnOn) {\r\n if (typeof window !== \"undefined\") {\r\n window.onerror = (_message, _source, _lineno, _colno, error) => {\r\n if (error) {\r\n window.vividLog?.err(error.stack);\r\n return true;\r\n }\r\n\r\n return false;\r\n };\r\n } else if (typeof process !== \"undefined\") {\r\n process.on(\"uncaughtException\", (error) => {\r\n const vividLog = (global as any).vividLog;\r\n if (vividLog) {\r\n vividLog.err(error.stack);\r\n } else {\r\n console.error(error);\r\n }\r\n });\r\n }\r\n return true;\r\n }\r\n\r\n const vividLog = (typeof window !== \"undefined\") ? window.vividLog : (global as any).vividLog;\r\n\r\n vividLog?.style(\"font-style: italic;\").say(\"f v.takeOver() was called but was not turned on. Do so by using v.takeOver(true)\", \"VividLog\", \"#E3342F\");\r\n\r\n return false;\r\n }\r\n}\r\n","import {LogSize} from \"./enums\";\r\nimport config from \"./config/config\";\r\nimport {ANSI, hexToAnsi, hexToAnsiBg} from \"./ansi\";\r\n\r\ndeclare global {\r\n interface Window {\r\n vividLog: any;\r\n }\r\n\r\n const vividLog: any;\r\n}\r\n\r\nconst isBrowser = typeof window !== \"undefined\" && typeof window.document !== \"undefined\";\r\n\r\nexport class Utils {\r\n static evaluate(loggable: any, type: string): boolean {\r\n if (this.checkTypeLog(loggable) === LogSize.SMALL_LOGGABLE) {\r\n return this.fire(this.logBuilder(loggable, type), this.styleBuilder(type));\r\n }\r\n\r\n if (this.checkTypeLog(loggable) === LogSize.BIG_LOGGABLE) {\r\n const style = this.styleBuilder(type);\r\n\r\n if (isBrowser) {\r\n console.log(\r\n this.logBuilder(loggable, type, true),\r\n style.status,\r\n style.time,\r\n style.type,\r\n );\r\n console.log(loggable);\r\n console.log(\r\n \"%c \",\r\n \"padding: 0 5px;font-weight: bolder; border-top: 2px solid \" + (window.vividLog?.config?.status[type]?.lightColor || \"#000\") + \";\",\r\n );\r\n } else {\r\n console.log(this.logBuilder(loggable, type, true));\r\n console.log(loggable);\r\n const color = (global as any).vividLog?.config?.status[type]?.lightColor || config.status[type]?.lightColor || \"#000\";\r\n console.log(hexToAnsi(color) + \"-------------------------\" + ANSI.reset);\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n static getType(loggable: any): string | false {\r\n let len: number;\r\n\r\n if (loggable instanceof Error) {\r\n return \"error\";\r\n }\r\n\r\n switch (typeof loggable) {\r\n case \"string\":\r\n len = loggable.length || 0;\r\n return `string[${len}]`;\r\n case \"boolean\":\r\n return \"boolean\";\r\n case \"number\":\r\n len = String(loggable).length;\r\n return `integer[${len}]`;\r\n case \"object\":\r\n if (loggable === null) {\r\n return \"null\";\r\n }\r\n if (Array.isArray(loggable)) {\r\n len = loggable.length;\r\n return `array[${len}]`;\r\n }\r\n len = Object.keys(loggable).length;\r\n return `object[${len}]`;\r\n case \"bigint\":\r\n len = String(loggable).length;\r\n return `big integer[${len}]`;\r\n case \"function\":\r\n return \"function\";\r\n case \"symbol\":\r\n return \"symbol\";\r\n case \"undefined\":\r\n return \"undefined\";\r\n default:\r\n return false;\r\n }\r\n }\r\n\r\n static isTypeOfLoggable(variable: string): boolean {\r\n return [\"log\", \"debug\", \"error\", \"info\", \"success\", \"warning\"].includes(variable);\r\n }\r\n\r\n static createTime(format: string): string | false {\r\n const time = this.timeObj(format);\r\n let returnTime = \"\";\r\n const formats = time.format;\r\n\r\n for (let iteration = 0; iteration < formats.length; iteration++) {\r\n switch (formats[iteration]) {\r\n case \"h\":\r\n returnTime += time.h;\r\n break;\r\n case \"m\":\r\n returnTime += time.m;\r\n break;\r\n case \"s\":\r\n returnTime += time.s;\r\n break;\r\n case \"ms\":\r\n returnTime += time.ms;\r\n break;\r\n }\r\n if (iteration !== (formats.length - 1)) {\r\n returnTime += \":\";\r\n }\r\n }\r\n\r\n return returnTime.length >= 1 ? returnTime : false;\r\n }\r\n\r\n static timeObj(format: string) {\r\n const date = new Date();\r\n const cfg = (isBrowser ? window.vividLog?.config : (global as any).vividLog?.config) || config;\r\n\r\n return {\r\n format: format.split(\":\") || cfg.timeNotation.split(\":\"),\r\n h : String(date.getHours()).padStart(2, \"0\"),\r\n m : String(date.getMinutes()).padStart(2, \"0\"),\r\n s : String(date.getSeconds()).padStart(2, \"0\"),\r\n ms : String(date.getMilliseconds()).padStart(2, \"0\"),\r\n };\r\n }\r\n\r\n static checkTypeLog(loggable: any): LogSize {\r\n return (typeof loggable === \"string\" || typeof loggable === \"number\" || typeof loggable === \"undefined\")\r\n ? LogSize.SMALL_LOGGABLE\r\n : LogSize.BIG_LOGGABLE;\r\n }\r\n\r\n static makeStyleCompatible(css: string): string {\r\n return css;\r\n }\r\n\r\n static styleBuilder(type: string, color?: string) {\r\n const cfg = (isBrowser ? window.vividLog?.config : (global as any).vividLog?.config) || config;\r\n const lightTheme = cfg.iUseLightTheme ? \"color: white;\" : \"\";\r\n const customStyle = cfg.customStyle;\r\n const fontSize = `font-size: ${cfg.fontSize};`;\r\n\r\n const typeOrColorLight = this.isTypeOfLoggable(type) ? cfg.status[type].lightColor : color;\r\n const typeOrColorDark = this.isTypeOfLoggable(type) ? cfg.status[type].darkColor : color;\r\n\r\n const style = {\r\n default : \"color: #F1F5F8;\" + fontSize,\r\n labelDefault : `border-radius: 5px; padding: 5px; background: ${typeOrColorLight};`,\r\n timeDefault : \"\",\r\n logNameDefault : \"font-weight: bold;\",\r\n typeNameDefault: `background: ${typeOrColorDark};`,\r\n varDefault : \"margin-top: 10px; margin-bottom: 5px;\" + lightTheme,\r\n custom : this.makeStyleCompatible(customStyle),\r\n };\r\n\r\n return {\r\n status: style.default + style.labelDefault + style.logNameDefault,\r\n time : style.default + style.labelDefault + style.timeDefault,\r\n type : style.default + style.labelDefault + style.typeNameDefault,\r\n var : style.default + style.varDefault + style.custom,\r\n };\r\n }\r\n\r\n static logBuilder(loggable: any, typeOrLabel: string, onlyHeader: boolean = false): string {\r\n const cfg = (isBrowser ? window.vividLog?.config : (global as any).vividLog?.config) || config;\r\n const label = this.isTypeOfLoggable(typeOrLabel) ? cfg.status[typeOrLabel].code : typeOrLabel;\r\n\r\n if (!isBrowser) {\r\n const time = this.createTime(cfg.timeNotation);\r\n const type = this.getType(loggable);\r\n const statusColor = this.isTypeOfLoggable(typeOrLabel) ? cfg.status[typeOrLabel].lightColor : (typeOrLabel === \"LABEL\" ? \"#800080\" : \"#A52A2A\");\r\n const typeColor = this.isTypeOfLoggable(typeOrLabel) ? cfg.status[typeOrLabel].darkColor : (typeOrLabel === \"LABEL\" ? \"#800080\" : \"#A52A2A\");\r\n\r\n const labelStyled = hexToAnsiBg(statusColor) + ANSI.white + ANSI.bold + ` ${label} ` + ANSI.reset;\r\n const timeStyled = hexToAnsiBg(\"#444\") + ANSI.white + ` ${time} ` + ANSI.reset;\r\n const typeStyled = hexToAnsiBg(typeColor) + ANSI.white + ` ${type} ` + ANSI.reset;\r\n\r\n if (!onlyHeader) {\r\n return `${labelStyled}${timeStyled}${typeStyled}${cfg.newLine ? \" \" : \"\\n\"} ${loggable}`;\r\n }\r\n\r\n return `${labelStyled}${timeStyled}${typeStyled}`;\r\n }\r\n\r\n if (!onlyHeader) {\r\n return \"%c\" + label +\r\n \"%c\" + this.createTime(cfg.timeNotation) +\r\n \"%c\" + this.getType(loggable) + (cfg.newLine ? \" \" : \"\\n\") +\r\n \"%c \" + loggable;\r\n }\r\n\r\n const typeCode = cfg.status[typeOrLabel]?.code || typeOrLabel;\r\n\r\n return \"%c\" + typeCode +\r\n \"%c\" + this.createTime(cfg.timeNotation) +\r\n \"%c\" + this.getType(loggable);\r\n }\r\n\r\n static resetConfs(): boolean {\r\n const cfg = (isBrowser ? window.vividLog?.config : (global as any).vividLog?.config) || config;\r\n cfg.customStyle = \"\";\r\n cfg.autoGroup = false;\r\n return cfg.customStyle === \"\" && cfg.autoGroup === false;\r\n }\r\n\r\n static fire(loggable: string, style: any): boolean {\r\n if (this.resetConfs()) {\r\n if (isBrowser) {\r\n console.log(loggable, style.status, style.time, style.type, style.var);\r\n } else {\r\n console.log(loggable);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n static fireLabel(label: string, type: string = \"LABEL\"): void {\r\n const cfg = (isBrowser ? window.vividLog?.config : (global as any).vividLog?.config) || config;\r\n\r\n if (isBrowser) {\r\n const compiled = `%c${label}%c${this.createTime(cfg.timeNotation)}%c${type}`;\r\n const style = this.styleBuilder(\"purple\", \"purple\");\r\n style.var = \"\";\r\n this.fire(compiled, style);\r\n } else {\r\n const compiled = this.logBuilder(null, label, true);\r\n this.fire(compiled, {});\r\n }\r\n }\r\n\r\n static loggable(args: IArguments | any[], type: string): boolean {\r\n if (args.length > 1) {\r\n return this.iterateLoggables(args, type);\r\n }\r\n\r\n return this.evaluate(args[0], type);\r\n }\r\n\r\n static iterateLoggables(args: IArguments | any[], type: string): boolean {\r\n const cfg = (isBrowser ? window.vividLog?.config : (global as any).vividLog?.config) || config;\r\n\r\n if (cfg.autoGroup) {\r\n this.fireLabel(type.toUpperCase(), `Group[${args.length}]`);\r\n if (isBrowser && console.groupCollapsed) {\r\n console.groupCollapsed(type.toUpperCase());\r\n }\r\n }\r\n\r\n for (let i = 0; i < args.length; i++) {\r\n this.evaluate(args[i], \"log\");\r\n }\r\n\r\n if (cfg.autoGroup) {\r\n if (isBrowser && console.groupEnd) {\r\n console.groupEnd();\r\n }\r\n }\r\n\r\n cfg.autoGroup = false;\r\n\r\n return true;\r\n }\r\n}\r\n","import {Utils} from \"./utils\";\r\nimport {Methods} from \"./methods\";\r\nimport config, {VividLogConfig} from \"./config/config\";\r\nimport {LogSize} from \"./enums\";\r\n\r\nexport class VividLog {\r\n public config: VividLogConfig = config;\r\n\r\n constructor() {\r\n if (typeof window !== \"undefined\") {\r\n (window as any).vividLog = this;\r\n } else if (typeof global !== \"undefined\") {\r\n (global as any).vividLog = this;\r\n }\r\n }\r\n\r\n /**\r\n * Take over default error log\r\n */\r\n public takeOver(activate: boolean = false): void {\r\n Methods.takeOver(activate);\r\n }\r\n\r\n /**\r\n * Chain before log to group the all logs\r\n */\r\n public group(grouped: boolean = true): this {\r\n this.config.autoGroup = grouped;\r\n return this;\r\n }\r\n\r\n /**\r\n * Chain before log to give message a custom style\r\n */\r\n public style(customStyle: string = \"\"): this {\r\n this.config.customStyle = customStyle;\r\n return this;\r\n }\r\n\r\n /**\r\n * Only log a label\r\n */\r\n public fireLabel(label: string): this {\r\n Utils.fireLabel(label);\r\n return this;\r\n }\r\n\r\n /**\r\n * Normal priority log\r\n */\r\n public log(...args: any[]): this {\r\n Utils.loggable(args, \"log\");\r\n return this;\r\n }\r\n\r\n /**\r\n * Debug priority log\r\n */\r\n public debug(...args: any[]): this {\r\n Utils.loggable(args, \"debug\");\r\n return this;\r\n }\r\n\r\n /**\r\n * Error priority log\r\n */\r\n public err(...args: any[]): this {\r\n Utils.loggable(args, \"error\");\r\n return this;\r\n }\r\n\r\n /**\r\n * Warning priority log\r\n */\r\n public warn(...args: any[]): this {\r\n Utils.loggable(args, \"warning\");\r\n return this;\r\n }\r\n\r\n /**\r\n * Success priority log\r\n */\r\n public done(...args: any[]): this {\r\n Utils.loggable(args, \"success\");\r\n return this;\r\n }\r\n\r\n /**\r\n * Information priority log\r\n */\r\n public info(...args: any[]): this {\r\n Utils.loggable(args, \"info\");\r\n return this;\r\n }\r\n\r\n /**\r\n * Custom logging utility\r\n */\r\n public say(loggable: any, label?: string, color?: string): boolean | void {\r\n const type = Utils.checkTypeLog(loggable);\r\n\r\n if (type === LogSize.SMALL_LOGGABLE) {\r\n return Utils.fire(\r\n Utils.logBuilder(loggable, label || (typeof document !== \"undefined\" ? document.title : (typeof process !== \"undefined\" ? \"node\" : \"vividLog\"))),\r\n Utils.styleBuilder(color || \"brown\", color || \"brown\"),\r\n );\r\n }\r\n\r\n if (type === LogSize.BIG_LOGGABLE) {\r\n const style = Utils.styleBuilder(\"log\"); // Default to log style if big\r\n console.log(\r\n Utils.logBuilder(loggable, \"log\", true),\r\n style.status,\r\n style.time,\r\n style.type,\r\n );\r\n console.log(loggable);\r\n console.log(\r\n \"%c \",\r\n \"padding: 0 5px;font-weight: bolder; border-top: 2px solid \" + this.config.status[\"log\"].lightColor + \";\",\r\n );\r\n return true;\r\n }\r\n }\r\n}\r\n\r\nconst vividLogInstance = new VividLog();\r\nexport default vividLogInstance;\r\n\r\nif (typeof window !== \"undefined\") {\r\n (window as any).vividLog = vividLogInstance;\r\n} else if (typeof global !== \"undefined\") {\r\n (global as any).vividLog = vividLogInstance;\r\n}\r\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(119);\n"],"names":["root","factory","exports","module","define","amd","this","ANSI","reset","bold","italic","underline","inverse","black","red","green","yellow","blue","magenta","cyan","white","bgBlack","bgRed","bgGreen","bgYellow","bgBlue","bgMagenta","bgCyan","bgWhite","hexToAnsi","hex","replace","length","parseInt","substring","hexToAnsiBg","config","autoGroup","timeNotation","iUseLightTheme","customStyle","fontSize","newLine","navigator","userAgent","includes","status","error","lightColor","darkColor","code","success","warning","info","debug","log","LogSize","DEBUG","i","val","ERROR","INFO","LOG","WARNING","takeOver","turnOn","window","onerror","_message","_source","_lineno","_colno","vividLog","err","stack","process","on","g","console","style","say","isBrowser","document","evaluate","loggable","type","checkTypeLog","SMALL_LOGGABLE","fire","logBuilder","styleBuilder","BIG_LOGGABLE","time","color","getType","len","Error","String","Array","isArray","Object","keys","isTypeOfLoggable","variable","createTime","format","timeObj","returnTime","formats","iteration","h","m","s","ms","date","Date","cfg","split","getHours","padStart","getMinutes","getSeconds","getMilliseconds","makeStyleCompatible","css","lightTheme","var","typeOrLabel","onlyHeader","label","statusColor","typeColor","labelStyled","timeStyled","typeStyled","resetConfs","fireLabel","compiled","args","iterateLoggables","toUpperCase","groupCollapsed","groupEnd","VividLog","constructor","activate","Methods","group","grouped","Utils","warn","done","title","vividLogInstance","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","call","globalThis","Function","e"],"sourceRoot":""}