tool-log 0.0.3 → 0.0.5

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.
package/README.md ADDED
@@ -0,0 +1,134 @@
1
+ # tool-log
2
+
3
+ > Цветная консоль для логирования
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.6%2B-blue.svg)](https://www.typescriptlang.org/)
7
+
8
+ ## Особенности
9
+
10
+ - 🎨 **Цветной вывод** — 9 цветов текста + 9 цветов фона
11
+ - ⚡ **Шорткоты** — методы `red()`, `green()`, `cyan()` и др.
12
+ - 🏷️ **Опциональные цвета** — переопределение цветов для отдельного вызова
13
+ - 📦 **Любые типы** — строки, числа, булевы, объекты, массивы, `null`, `undefined`
14
+ - 🚫 **Dev-only** — автоматическая блокировка логов в продакшене
15
+ - 📐 **Деструктуризация** — безопасное извлечение методов
16
+
17
+ ## Установка
18
+
19
+ ```bash
20
+ npm install tool-log
21
+ ```
22
+
23
+ ## Быстрый старт
24
+
25
+ ```typescript
26
+ import { ClassLog } from 'tool-log';
27
+
28
+ const log = new ClassLog({ textColor: 'green', bgColor: 'bgBlack' });
29
+
30
+ log.red('Ошибка подключения');
31
+ log.green({ status: 'ok', users: 42 });
32
+ log.cyan('Готово', 123, true);
33
+ ```
34
+
35
+ ## API
36
+
37
+ ### Конструктор
38
+
39
+ ```typescript
40
+ new ClassLog(config?: ColorOptions)
41
+ ```
42
+
43
+ **Options:**
44
+
45
+ | Параметр | Тип | По умолчанию | Описание |
46
+ |----------|-----|--------------|----------|
47
+ | `textColor` | `TextColor` | `'white'` | Цвет текста по умолчанию |
48
+ | `bgColor` | `BgColor` | `null` | Цвет фона по умолчанию |
49
+
50
+ ### Методы
51
+
52
+ #### `color(...args: LogValue[], options?: ColorOptions): void`
53
+ #### `info(...args: unknown[]): void`
54
+
55
+ Базовый метод для цветного вывода и дефолтный метод завязанные на isLogLocalhost.
56
+
57
+ ```typescript
58
+ log.color('С фоном', { textColor: 'red', bgColor: 'bgWhite' });
59
+ log.info('С фоном', 2);
60
+ ```
61
+
62
+ #### Шорткоты
63
+
64
+ ```typescript
65
+ log.red('Ошибка');
66
+ log.blue('Информация');
67
+ log.yellow('Предупреждение');
68
+ log.green('Успех');
69
+ log.cyan('Данные');
70
+ log.magenta('Декор');
71
+ log.gray('Отладка');
72
+ log.black('Текст');
73
+ log.white('Текст');
74
+ ```
75
+
76
+ #### Деструктуризация
77
+
78
+ ```typescript
79
+ const { red, green, cyan } = log;
80
+ red('ошибка');
81
+ green({ ok: true });
82
+ ```
83
+
84
+ ### Типы
85
+
86
+ ```typescript
87
+ type LogValue = string | number | boolean | null | undefined | object | Function;
88
+
89
+ type TextColor = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray';
90
+ type BgColor = 'bgBlack' | 'bgRed' | 'bgGreen' | 'bgYellow' | 'bgBlue' | 'bgMagenta' | 'bgCyan' | 'bgWhite';
91
+ ```
92
+
93
+ ## Примеры
94
+
95
+ ### Несколько значений
96
+
97
+ ```typescript
98
+ log.green('Юзер', { id: 1, name: 'Иван' }, [1, 2, 3]);
99
+ log.cyan('флаг:', false, 'счётчик:', 42, 'null:', null);
100
+ ```
101
+
102
+ ### Объекты и массивы
103
+
104
+ ```typescript
105
+ log.green({ status: 'ok', users: 42 });
106
+ log.yellow([1, 2, 3, { nested: true }]);
107
+ ```
108
+
109
+ ### Несколько логгеров
110
+
111
+ ```typescript
112
+ const infoLog = new ClassLog({ textColor: 'cyan' });
113
+ const errorLog = new ClassLog({ textColor: 'white', bgColor: 'bgRed' });
114
+
115
+ infoLog.cyan({ status: 'ok' });
116
+ errorLog.red('Критическая ошибка');
117
+ ```
118
+
119
+ ## Разработка
120
+
121
+ ```bash
122
+ # Запуск dev-сервера
123
+ npm run dev
124
+
125
+ # Сборка
126
+ npm run build
127
+
128
+ # Публикация
129
+ npm run release:patch # или minor/major
130
+ ```
131
+
132
+ ## License
133
+
134
+ [MIT](LICENSE) © [Vladimir Kurguzov](mailto:kurguzov74@gmail.com)
package/dist/index.cjs ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";var x=r=>{throw TypeError(r)};var C=(r,o,t)=>o.has(r)||x("Cannot "+t);var s=(r,o,t)=>(C(r,o,"read from private field"),t?t.call(r):o.get(r)),g=(r,o,t)=>o.has(r)?x("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(r):o.set(r,t),m=(r,o,t,n)=>(C(r,o,"write to private field"),n?n.call(r,t):o.set(r,t),t),i=(r,o,t)=>(C(r,o,"access private method"),t);function W(){return typeof window<"u"?window.location.hostname:null}var d=W();d&&console.log("isLogLocalhost === ",d);var u,h,y,c,e,a,L,w,k,V,v,B,p,A,f=class{constructor(o={}){g(this,e);g(this,u,{reset:"\x1B[0m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m"});g(this,h);g(this,y);g(this,c);m(this,h,o.textColor??"white"),m(this,y,o.bgColor??null),m(this,c,d)}info(...o){s(this,c)&&console.log(...o)}color(...o){if(!s(this,c))return;let[t,n]=i(this,e,L).call(this,o),b=n.textColor??s(this,h),O=n.bgColor??s(this,y),j=i(this,e,k).call(this,b,O),R=s(this,u).reset,T=i(this,e,V).call(this,t).split(`
2
+ `).map(S=>j+S+R).join(`
3
+ `);console.log(T)}get black(){return i(this,e,a).call(this,"black")}get red(){return i(this,e,a).call(this,"red")}get green(){return i(this,e,a).call(this,"green")}get yellow(){return i(this,e,a).call(this,"yellow")}get blue(){return i(this,e,a).call(this,"blue")}get magenta(){return i(this,e,a).call(this,"magenta")}get cyan(){return i(this,e,a).call(this,"cyan")}get white(){return i(this,e,a).call(this,"white")}get gray(){return i(this,e,a).call(this,"gray")}};u=new WeakMap,h=new WeakMap,y=new WeakMap,c=new WeakMap,e=new WeakSet,a=function(o){return s(this,c)?(...t)=>{this.color(...t,{textColor:o})}:(...t)=>{}},L=function(o){if(o.length===0)return[[],{}];let t=o[o.length-1];return i(this,e,w).call(this,t)?[o.slice(0,-1),t]:[o,{}]},w=function(o){if(!o||typeof o!="object"||Array.isArray(o))return!1;let t=o,n=Object.keys(t);return!(n.length===0||!n.every(b=>b==="textColor"||b==="bgColor")||"textColor"in t&&!(t.textColor in s(this,u))||"bgColor"in t&&!(t.bgColor in s(this,u)))},k=function(o,t){let n=t?s(this,u)[t]:"",b=s(this,u)[o]??s(this,u).white;return n+b},V=function(o){return o.map(t=>i(this,e,v).call(this,t)).join(" ")},v=function(o){if(o===null)return"null";if(o===void 0)return"undefined";let t=typeof o;if(t==="string"||t==="number"||t==="boolean"||t==="bigint"||t==="symbol"||t==="function")return String(o);try{return JSON.stringify(o,i(this,e,B),2)}catch{return String(o)}},B=function(o,t){return typeof t=="bigint"?t.toString()+"n":typeof t=="function"?`[Function: ${t.name||"anonymous"}]`:typeof t=="symbol"?t.toString():t},p=new WeakSet,A=function(){let o=d;if(typeof o=="boolean")return o;if(typeof o=="function")try{return!!o()}catch{return!1}if(o&&typeof o=="object"){let t=o;if("default"in t){let n=t.default;if(typeof n=="boolean")return n;if(typeof n=="function")try{return!!n()}catch{}}if("isLogLocalhost"in t){let n=t.isLogLocalhost;if(typeof n=="boolean")return n;if(typeof n=="function")try{return!!n()}catch{}}}return!1},g(f,p);var l=new f({textColor:"green",bgColor:"bgBlack"});l.color("\u0421 \u0444\u043E\u043D\u043E\u043C",{textColor:"red",bgColor:"bgWhite"});l.color("\u0422\u0435\u043A\u0441\u0442",123,{nested:!0},{textColor:"red",bgColor:"bgWhite"});l.info("\u043F\u0435\u0440\u0432\u044B\u0439",2,{test:"\u0432\u0442\u043E\u0440\u043E\u0439"});l.red("\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u044F");l.blue("\u0418\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F");l.gray(null);l.white(void 0);l.red("\u041E\u0448\u0438\u0431\u043A\u0430",404,!0);l.green("\u042E\u0437\u0435\u0440",{id:1,name:"\u0418\u0432\u0430\u043D"},[1,2,3]);l.yellow("a","b","c");l.cyan("\u0444\u043B\u0430\u0433:",!1,"\u0441\u0447\u0451\u0442\u0447\u0438\u043A:",42,"null:",null);l.green({status:"ok",users:42});l.yellow([1,2,3,{nested:!0}]);var{red:F,green:_,cyan:D}=l;F("\u043E\u0448\u0438\u0431\u043A\u0430 \u0438\u0437 \u0434\u0435\u0441\u0442\u0440\u0443\u043A\u0442\u0443\u0440\u0438\u0437\u0430\u0446\u0438\u0438");_({ok:!0});D("\u0433\u043E\u0442\u043E\u0432\u043E");var E=new f({textColor:"cyan"}),G=new f({textColor:"white",bgColor:"bgRed"});E.cyan({status:"ok"},`
4
+ `,"test",`
5
+ `,123);G.color("\u041A\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043A\u0430\u044F \u043E\u0448\u0438\u0431\u043A\u0430",500);
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ var x=r=>{throw TypeError(r)};var C=(r,o,t)=>o.has(r)||x("Cannot "+t);var s=(r,o,t)=>(C(r,o,"read from private field"),t?t.call(r):o.get(r)),g=(r,o,t)=>o.has(r)?x("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(r):o.set(r,t),m=(r,o,t,n)=>(C(r,o,"write to private field"),n?n.call(r,t):o.set(r,t),t),i=(r,o,t)=>(C(r,o,"access private method"),t);function W(){return typeof window<"u"?window.location.hostname:null}var d=W();d&&console.log("isLogLocalhost === ",d);var u,h,y,c,e,a,L,w,k,V,v,B,p,A,f=class{constructor(o={}){g(this,e);g(this,u,{reset:"\x1B[0m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m"});g(this,h);g(this,y);g(this,c);m(this,h,o.textColor??"white"),m(this,y,o.bgColor??null),m(this,c,d)}info(...o){s(this,c)&&console.log(...o)}color(...o){if(!s(this,c))return;let[t,n]=i(this,e,L).call(this,o),b=n.textColor??s(this,h),O=n.bgColor??s(this,y),j=i(this,e,k).call(this,b,O),R=s(this,u).reset,T=i(this,e,V).call(this,t).split(`
2
+ `).map(S=>j+S+R).join(`
3
+ `);console.log(T)}get black(){return i(this,e,a).call(this,"black")}get red(){return i(this,e,a).call(this,"red")}get green(){return i(this,e,a).call(this,"green")}get yellow(){return i(this,e,a).call(this,"yellow")}get blue(){return i(this,e,a).call(this,"blue")}get magenta(){return i(this,e,a).call(this,"magenta")}get cyan(){return i(this,e,a).call(this,"cyan")}get white(){return i(this,e,a).call(this,"white")}get gray(){return i(this,e,a).call(this,"gray")}};u=new WeakMap,h=new WeakMap,y=new WeakMap,c=new WeakMap,e=new WeakSet,a=function(o){return s(this,c)?(...t)=>{this.color(...t,{textColor:o})}:(...t)=>{}},L=function(o){if(o.length===0)return[[],{}];let t=o[o.length-1];return i(this,e,w).call(this,t)?[o.slice(0,-1),t]:[o,{}]},w=function(o){if(!o||typeof o!="object"||Array.isArray(o))return!1;let t=o,n=Object.keys(t);return!(n.length===0||!n.every(b=>b==="textColor"||b==="bgColor")||"textColor"in t&&!(t.textColor in s(this,u))||"bgColor"in t&&!(t.bgColor in s(this,u)))},k=function(o,t){let n=t?s(this,u)[t]:"",b=s(this,u)[o]??s(this,u).white;return n+b},V=function(o){return o.map(t=>i(this,e,v).call(this,t)).join(" ")},v=function(o){if(o===null)return"null";if(o===void 0)return"undefined";let t=typeof o;if(t==="string"||t==="number"||t==="boolean"||t==="bigint"||t==="symbol"||t==="function")return String(o);try{return JSON.stringify(o,i(this,e,B),2)}catch{return String(o)}},B=function(o,t){return typeof t=="bigint"?t.toString()+"n":typeof t=="function"?`[Function: ${t.name||"anonymous"}]`:typeof t=="symbol"?t.toString():t},p=new WeakSet,A=function(){let o=d;if(typeof o=="boolean")return o;if(typeof o=="function")try{return!!o()}catch{return!1}if(o&&typeof o=="object"){let t=o;if("default"in t){let n=t.default;if(typeof n=="boolean")return n;if(typeof n=="function")try{return!!n()}catch{}}if("isLogLocalhost"in t){let n=t.isLogLocalhost;if(typeof n=="boolean")return n;if(typeof n=="function")try{return!!n()}catch{}}}return!1},g(f,p);var l=new f({textColor:"green",bgColor:"bgBlack"});l.color("\u0421 \u0444\u043E\u043D\u043E\u043C",{textColor:"red",bgColor:"bgWhite"});l.color("\u0422\u0435\u043A\u0441\u0442",123,{nested:!0},{textColor:"red",bgColor:"bgWhite"});l.info("\u043F\u0435\u0440\u0432\u044B\u0439",2,{test:"\u0432\u0442\u043E\u0440\u043E\u0439"});l.red("\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u044F");l.blue("\u0418\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F");l.gray(null);l.white(void 0);l.red("\u041E\u0448\u0438\u0431\u043A\u0430",404,!0);l.green("\u042E\u0437\u0435\u0440",{id:1,name:"\u0418\u0432\u0430\u043D"},[1,2,3]);l.yellow("a","b","c");l.cyan("\u0444\u043B\u0430\u0433:",!1,"\u0441\u0447\u0451\u0442\u0447\u0438\u043A:",42,"null:",null);l.green({status:"ok",users:42});l.yellow([1,2,3,{nested:!0}]);var{red:F,green:_,cyan:D}=l;F("\u043E\u0448\u0438\u0431\u043A\u0430 \u0438\u0437 \u0434\u0435\u0441\u0442\u0440\u0443\u043A\u0442\u0443\u0440\u0438\u0437\u0430\u0446\u0438\u0438");_({ok:!0});D("\u0433\u043E\u0442\u043E\u0432\u043E");var E=new f({textColor:"cyan"}),G=new f({textColor:"white",bgColor:"bgRed"});E.cyan({status:"ok"},`
4
+ `,"test",`
5
+ `,123);G.color("\u041A\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043A\u0430\u044F \u043E\u0448\u0438\u0431\u043A\u0430",500);
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
- "version": "0.0.3",
9
+ "version": "0.0.5",
10
10
  "type": "module",
11
11
  "main": "./dist/index.cjs",
12
12
  "module": "./dist/index.js",
@@ -23,7 +23,7 @@
23
23
  ],
24
24
  "scripts": {
25
25
  "dev": "vite --open --host",
26
- "build": "tsup src/example.ts --format esm,cjs --clean --dts --minify",
26
+ "build": "tsup index.ts --format esm,cjs --clean --dts --minify",
27
27
  "ver:patch": "npm version patch --no-git-tag-version",
28
28
  "ver:minor": "npm version minor --no-git-tag-version",
29
29
  "ver:major": "npm version major --no-git-tag-version",
package/dist/example.cjs DELETED
@@ -1,5 +0,0 @@
1
- "use strict";var p=r=>{throw TypeError(r)};var C=(r,o,t)=>o.has(r)||p("Cannot "+t);var s=(r,o,t)=>(C(r,o,"read from private field"),t?t.call(r):o.get(r)),g=(r,o,t)=>o.has(r)?p("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(r):o.set(r,t),m=(r,o,t,n)=>(C(r,o,"write to private field"),n?n.call(r,t):o.set(r,t),t),l=(r,o,t)=>(C(r,o,"access private method"),t);function W(){return typeof window<"u"?window.location.hostname:null}var d=W();d&&console.log("isLogLocalhost === ",d);var u,h,y,b,e,a,L,w,V,k,v,B,x,A,c=class{constructor(o={}){g(this,e);g(this,u,{reset:"\x1B[0m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m"});g(this,h);g(this,y);g(this,b);m(this,h,o.textColor??"white"),m(this,y,o.bgColor??null),m(this,b,d)}color(...o){if(!s(this,b))return;let[t,n]=l(this,e,L).call(this,o),f=n.textColor??s(this,h),O=n.bgColor??s(this,y),j=l(this,e,V).call(this,f,O),R=s(this,u).reset,T=l(this,e,k).call(this,t).split(`
2
- `).map(S=>j+S+R).join(`
3
- `);console.log(T)}get black(){return l(this,e,a).call(this,"black")}get red(){return l(this,e,a).call(this,"red")}get green(){return l(this,e,a).call(this,"green")}get yellow(){return l(this,e,a).call(this,"yellow")}get blue(){return l(this,e,a).call(this,"blue")}get magenta(){return l(this,e,a).call(this,"magenta")}get cyan(){return l(this,e,a).call(this,"cyan")}get white(){return l(this,e,a).call(this,"white")}get gray(){return l(this,e,a).call(this,"gray")}};u=new WeakMap,h=new WeakMap,y=new WeakMap,b=new WeakMap,e=new WeakSet,a=function(o){return s(this,b)?(...t)=>{this.color(...t,{textColor:o})}:(...t)=>{}},L=function(o){if(o.length===0)return[[],{}];let t=o[o.length-1];return l(this,e,w).call(this,t)?[o.slice(0,-1),t]:[o,{}]},w=function(o){if(!o||typeof o!="object"||Array.isArray(o))return!1;let t=o,n=Object.keys(t);return!(n.length===0||!n.every(f=>f==="textColor"||f==="bgColor")||"textColor"in t&&!(t.textColor in s(this,u))||"bgColor"in t&&!(t.bgColor in s(this,u)))},V=function(o,t){let n=t?s(this,u)[t]:"",f=s(this,u)[o]??s(this,u).white;return n+f},k=function(o){return o.map(t=>l(this,e,v).call(this,t)).join(" ")},v=function(o){if(o===null)return"null";if(o===void 0)return"undefined";let t=typeof o;if(t==="string"||t==="number"||t==="boolean"||t==="bigint"||t==="symbol"||t==="function")return String(o);try{return JSON.stringify(o,l(this,e,B),2)}catch{return String(o)}},B=function(o,t){return typeof t=="bigint"?t.toString()+"n":typeof t=="function"?`[Function: ${t.name||"anonymous"}]`:typeof t=="symbol"?t.toString():t},x=new WeakSet,A=function(){let o=d;if(typeof o=="boolean")return o;if(typeof o=="function")try{return!!o()}catch{return!1}if(o&&typeof o=="object"){let t=o;if("default"in t){let n=t.default;if(typeof n=="boolean")return n;if(typeof n=="function")try{return!!n()}catch{}}if("isLogLocalhost"in t){let n=t.isLogLocalhost;if(typeof n=="boolean")return n;if(typeof n=="function")try{return!!n()}catch{}}}return!1},g(c,x);var i=new c({textColor:"green",bgColor:"bgBlack"});i.color("\u0421 \u0444\u043E\u043D\u043E\u043C",{textColor:"red",bgColor:"bgWhite"});i.color("\u0422\u0435\u043A\u0441\u0442",123,{nested:!0},{textColor:"red",bgColor:"bgWhite"});i.red("\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u044F");i.blue("\u0418\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F");i.gray(null);i.white(void 0);i.red("\u041E\u0448\u0438\u0431\u043A\u0430",404,!0);i.green("\u042E\u0437\u0435\u0440",{id:1,name:"\u0418\u0432\u0430\u043D"},[1,2,3]);i.yellow("a","b","c");i.cyan("\u0444\u043B\u0430\u0433:",!1,"\u0441\u0447\u0451\u0442\u0447\u0438\u043A:",42,"null:",null);i.green({status:"ok",users:42});i.yellow([1,2,3,{nested:!0}]);var{red:F,green:_,cyan:D}=i;F("\u043E\u0448\u0438\u0431\u043A\u0430 \u0438\u0437 \u0434\u0435\u0441\u0442\u0440\u0443\u043A\u0442\u0443\u0440\u0438\u0437\u0430\u0446\u0438\u0438");_({ok:!0});D("\u0433\u043E\u0442\u043E\u0432\u043E");var E=new c({textColor:"cyan"}),G=new c({textColor:"white",bgColor:"bgRed"});E.cyan({status:"ok"},`
4
- `,"test",`
5
- `,123);G.color("\u041A\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043A\u0430\u044F \u043E\u0448\u0438\u0431\u043A\u0430",500);
package/dist/example.js DELETED
@@ -1,5 +0,0 @@
1
- var p=r=>{throw TypeError(r)};var C=(r,o,t)=>o.has(r)||p("Cannot "+t);var s=(r,o,t)=>(C(r,o,"read from private field"),t?t.call(r):o.get(r)),g=(r,o,t)=>o.has(r)?p("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(r):o.set(r,t),m=(r,o,t,n)=>(C(r,o,"write to private field"),n?n.call(r,t):o.set(r,t),t),l=(r,o,t)=>(C(r,o,"access private method"),t);function W(){return typeof window<"u"?window.location.hostname:null}var d=W();d&&console.log("isLogLocalhost === ",d);var u,h,y,b,e,a,L,w,V,k,v,B,x,A,c=class{constructor(o={}){g(this,e);g(this,u,{reset:"\x1B[0m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m"});g(this,h);g(this,y);g(this,b);m(this,h,o.textColor??"white"),m(this,y,o.bgColor??null),m(this,b,d)}color(...o){if(!s(this,b))return;let[t,n]=l(this,e,L).call(this,o),f=n.textColor??s(this,h),O=n.bgColor??s(this,y),j=l(this,e,V).call(this,f,O),R=s(this,u).reset,T=l(this,e,k).call(this,t).split(`
2
- `).map(S=>j+S+R).join(`
3
- `);console.log(T)}get black(){return l(this,e,a).call(this,"black")}get red(){return l(this,e,a).call(this,"red")}get green(){return l(this,e,a).call(this,"green")}get yellow(){return l(this,e,a).call(this,"yellow")}get blue(){return l(this,e,a).call(this,"blue")}get magenta(){return l(this,e,a).call(this,"magenta")}get cyan(){return l(this,e,a).call(this,"cyan")}get white(){return l(this,e,a).call(this,"white")}get gray(){return l(this,e,a).call(this,"gray")}};u=new WeakMap,h=new WeakMap,y=new WeakMap,b=new WeakMap,e=new WeakSet,a=function(o){return s(this,b)?(...t)=>{this.color(...t,{textColor:o})}:(...t)=>{}},L=function(o){if(o.length===0)return[[],{}];let t=o[o.length-1];return l(this,e,w).call(this,t)?[o.slice(0,-1),t]:[o,{}]},w=function(o){if(!o||typeof o!="object"||Array.isArray(o))return!1;let t=o,n=Object.keys(t);return!(n.length===0||!n.every(f=>f==="textColor"||f==="bgColor")||"textColor"in t&&!(t.textColor in s(this,u))||"bgColor"in t&&!(t.bgColor in s(this,u)))},V=function(o,t){let n=t?s(this,u)[t]:"",f=s(this,u)[o]??s(this,u).white;return n+f},k=function(o){return o.map(t=>l(this,e,v).call(this,t)).join(" ")},v=function(o){if(o===null)return"null";if(o===void 0)return"undefined";let t=typeof o;if(t==="string"||t==="number"||t==="boolean"||t==="bigint"||t==="symbol"||t==="function")return String(o);try{return JSON.stringify(o,l(this,e,B),2)}catch{return String(o)}},B=function(o,t){return typeof t=="bigint"?t.toString()+"n":typeof t=="function"?`[Function: ${t.name||"anonymous"}]`:typeof t=="symbol"?t.toString():t},x=new WeakSet,A=function(){let o=d;if(typeof o=="boolean")return o;if(typeof o=="function")try{return!!o()}catch{return!1}if(o&&typeof o=="object"){let t=o;if("default"in t){let n=t.default;if(typeof n=="boolean")return n;if(typeof n=="function")try{return!!n()}catch{}}if("isLogLocalhost"in t){let n=t.isLogLocalhost;if(typeof n=="boolean")return n;if(typeof n=="function")try{return!!n()}catch{}}}return!1},g(c,x);var i=new c({textColor:"green",bgColor:"bgBlack"});i.color("\u0421 \u0444\u043E\u043D\u043E\u043C",{textColor:"red",bgColor:"bgWhite"});i.color("\u0422\u0435\u043A\u0441\u0442",123,{nested:!0},{textColor:"red",bgColor:"bgWhite"});i.red("\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u044F");i.blue("\u0418\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F");i.gray(null);i.white(void 0);i.red("\u041E\u0448\u0438\u0431\u043A\u0430",404,!0);i.green("\u042E\u0437\u0435\u0440",{id:1,name:"\u0418\u0432\u0430\u043D"},[1,2,3]);i.yellow("a","b","c");i.cyan("\u0444\u043B\u0430\u0433:",!1,"\u0441\u0447\u0451\u0442\u0447\u0438\u043A:",42,"null:",null);i.green({status:"ok",users:42});i.yellow([1,2,3,{nested:!0}]);var{red:F,green:_,cyan:D}=i;F("\u043E\u0448\u0438\u0431\u043A\u0430 \u0438\u0437 \u0434\u0435\u0441\u0442\u0440\u0443\u043A\u0442\u0443\u0440\u0438\u0437\u0430\u0446\u0438\u0438");_({ok:!0});D("\u0433\u043E\u0442\u043E\u0432\u043E");var E=new c({textColor:"cyan"}),G=new c({textColor:"white",bgColor:"bgRed"});E.cyan({status:"ok"},`
4
- `,"test",`
5
- `,123);G.color("\u041A\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043A\u0430\u044F \u043E\u0448\u0438\u0431\u043A\u0430",500);
File without changes
File without changes