colorino 0.6.1 → 0.7.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.
- package/dist/browser.cjs +1 -1
- package/dist/browser.d.cts +2 -2
- package/dist/browser.d.mts +2 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.mjs +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.d.cts +2 -2
- package/dist/node.d.mts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.mjs +1 -1
- package/dist/shared/{colorino.DBw7jOfy.d.ts → colorino.D5epIHWO.d.cts} +1 -0
- package/dist/shared/{colorino.DBw7jOfy.d.cts → colorino.D5epIHWO.d.mts} +1 -0
- package/dist/shared/{colorino.DBw7jOfy.d.mts → colorino.D5epIHWO.d.ts} +1 -0
- package/dist/shared/{colorino.B9WUj1qg.cjs → colorino.DZFkhcaF.cjs} +38 -10
- package/dist/shared/{colorino.CsFoITs1.mjs → colorino.Irp6M1AW.mjs} +38 -10
- package/package.json +1 -1
package/dist/browser.cjs
CHANGED
package/dist/browser.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.
|
|
2
|
-
export { L as LogLevel, T as ThemeName, t as themePalettes } from './shared/colorino.
|
|
1
|
+
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.D5epIHWO.cjs';
|
|
2
|
+
export { L as LogLevel, T as ThemeName, t as themePalettes } from './shared/colorino.D5epIHWO.cjs';
|
|
3
3
|
|
|
4
4
|
declare function createColorino(palette?: Partial<Palette>, options?: ColorinoOptions): Colorino;
|
|
5
5
|
|
package/dist/browser.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.
|
|
2
|
-
export { L as LogLevel, T as ThemeName, t as themePalettes } from './shared/colorino.
|
|
1
|
+
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.D5epIHWO.mjs';
|
|
2
|
+
export { L as LogLevel, T as ThemeName, t as themePalettes } from './shared/colorino.D5epIHWO.mjs';
|
|
3
3
|
|
|
4
4
|
declare function createColorino(palette?: Partial<Palette>, options?: ColorinoOptions): Colorino;
|
|
5
5
|
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.
|
|
2
|
-
export { L as LogLevel, T as ThemeName, t as themePalettes } from './shared/colorino.
|
|
1
|
+
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.D5epIHWO.js';
|
|
2
|
+
export { L as LogLevel, T as ThemeName, t as themePalettes } from './shared/colorino.D5epIHWO.js';
|
|
3
3
|
|
|
4
4
|
declare function createColorino(palette?: Partial<Palette>, options?: ColorinoOptions): Colorino;
|
|
5
5
|
|
package/dist/browser.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ColorLevel, t as themePalettes, a as Colorino, I as InputValidator, d as determineBaseTheme } from './shared/colorino.
|
|
1
|
+
import { C as ColorLevel, t as themePalettes, a as Colorino, I as InputValidator, d as determineBaseTheme } from './shared/colorino.Irp6M1AW.mjs';
|
|
2
2
|
|
|
3
3
|
class BrowserColorSupportDetector {
|
|
4
4
|
constructor(_window, _navigator, _overrideTheme) {
|
package/dist/node.cjs
CHANGED
package/dist/node.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.
|
|
2
|
-
export { L as LogLevel, T as ThemeName, t as themePalettes } from './shared/colorino.
|
|
1
|
+
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.D5epIHWO.cjs';
|
|
2
|
+
export { L as LogLevel, T as ThemeName, t as themePalettes } from './shared/colorino.D5epIHWO.cjs';
|
|
3
3
|
|
|
4
4
|
declare function createColorino(palette?: Partial<Palette>, options?: ColorinoOptions): Colorino;
|
|
5
5
|
|
package/dist/node.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.
|
|
2
|
-
export { L as LogLevel, T as ThemeName, t as themePalettes } from './shared/colorino.
|
|
1
|
+
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.D5epIHWO.mjs';
|
|
2
|
+
export { L as LogLevel, T as ThemeName, t as themePalettes } from './shared/colorino.D5epIHWO.mjs';
|
|
3
3
|
|
|
4
4
|
declare function createColorino(palette?: Partial<Palette>, options?: ColorinoOptions): Colorino;
|
|
5
5
|
|
package/dist/node.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.
|
|
2
|
-
export { L as LogLevel, T as ThemeName, t as themePalettes } from './shared/colorino.
|
|
1
|
+
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.D5epIHWO.js';
|
|
2
|
+
export { L as LogLevel, T as ThemeName, t as themePalettes } from './shared/colorino.D5epIHWO.js';
|
|
3
3
|
|
|
4
4
|
declare function createColorino(palette?: Partial<Palette>, options?: ColorinoOptions): Colorino;
|
|
5
5
|
|
package/dist/node.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e as err, O as OscQueryError, o as ok, C as ColorLevel, d as determineBaseTheme, t as themePalettes, a as Colorino, I as InputValidator } from './shared/colorino.
|
|
1
|
+
import { e as err, O as OscQueryError, o as ok, C as ColorLevel, d as determineBaseTheme, t as themePalettes, a as Colorino, I as InputValidator } from './shared/colorino.Irp6M1AW.mjs';
|
|
2
2
|
|
|
3
3
|
class OscThemeQuerier {
|
|
4
4
|
constructor(_stdin, _stdout, _timeout = 300, _cacheTtl = 36e5) {
|
|
@@ -115,19 +115,47 @@ class Colorino {
|
|
|
115
115
|
"[Colorino] No ANSI color support detected in this terminal. See [https://github.com/chalk/supports-color#support-matrix](https://github.com/chalk/supports-color#support-matrix) to learn how to enable terminal color."
|
|
116
116
|
);
|
|
117
117
|
}
|
|
118
|
+
_formatValue(value, maxDepth = 3) {
|
|
119
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
120
|
+
const sanitize = (val, currentDepth) => {
|
|
121
|
+
if (val === null || typeof val !== "object") return val;
|
|
122
|
+
if (seen.has(val)) return "[Circular]";
|
|
123
|
+
seen.add(val);
|
|
124
|
+
if (currentDepth >= maxDepth) return "[Object]";
|
|
125
|
+
if (Array.isArray(val)) {
|
|
126
|
+
return val.map((item) => sanitize(item, currentDepth + 1));
|
|
127
|
+
}
|
|
128
|
+
const result = {};
|
|
129
|
+
for (const key in val) {
|
|
130
|
+
result[key] = sanitize(val[key], currentDepth + 1);
|
|
131
|
+
}
|
|
132
|
+
return result;
|
|
133
|
+
};
|
|
134
|
+
return JSON.stringify(sanitize(value, 0), null, 2);
|
|
135
|
+
}
|
|
118
136
|
_out(level, args) {
|
|
119
137
|
const consoleMethod = isConsoleMethod(level) ? level : "log";
|
|
138
|
+
const processedArgs = args.map((arg) => {
|
|
139
|
+
if (arg !== null && typeof arg === "object" && typeof arg !== "string" && !(arg instanceof Error)) {
|
|
140
|
+
return this._formatValue(arg);
|
|
141
|
+
}
|
|
142
|
+
return arg;
|
|
143
|
+
});
|
|
120
144
|
if (this._colorLevel === ColorLevel.NO_COLOR || this._colorLevel === "UnknownEnv") {
|
|
121
|
-
if (level === "trace") console.trace(...
|
|
122
|
-
else console[consoleMethod](...
|
|
145
|
+
if (level === "trace") console.trace(...processedArgs);
|
|
146
|
+
else console[consoleMethod](...processedArgs);
|
|
123
147
|
return;
|
|
124
148
|
}
|
|
125
149
|
if (this.isBrowser) {
|
|
126
150
|
const hex2 = this._palette[level];
|
|
127
|
-
if (typeof
|
|
128
|
-
console[consoleMethod](
|
|
151
|
+
if (typeof processedArgs[0] === "string") {
|
|
152
|
+
console[consoleMethod](
|
|
153
|
+
`%c${processedArgs[0]}`,
|
|
154
|
+
`color:${hex2}`,
|
|
155
|
+
...processedArgs.slice(1)
|
|
156
|
+
);
|
|
129
157
|
} else {
|
|
130
|
-
console[consoleMethod](...
|
|
158
|
+
console[consoleMethod](...processedArgs);
|
|
131
159
|
}
|
|
132
160
|
return;
|
|
133
161
|
}
|
|
@@ -151,17 +179,17 @@ class Colorino {
|
|
|
151
179
|
break;
|
|
152
180
|
}
|
|
153
181
|
}
|
|
154
|
-
const
|
|
155
|
-
const firstStringIndex =
|
|
182
|
+
const coloredArgs = [...processedArgs];
|
|
183
|
+
const firstStringIndex = coloredArgs.findIndex(
|
|
156
184
|
(arg) => typeof arg === "string"
|
|
157
185
|
);
|
|
158
186
|
if (firstStringIndex !== -1) {
|
|
159
|
-
|
|
187
|
+
coloredArgs[firstStringIndex] = `${ansiCode}${coloredArgs[firstStringIndex]}\x1B[0m`;
|
|
160
188
|
}
|
|
161
189
|
if (level === "trace") {
|
|
162
|
-
console.trace(...
|
|
190
|
+
console.trace(...coloredArgs);
|
|
163
191
|
} else {
|
|
164
|
-
console[consoleMethod](...
|
|
192
|
+
console[consoleMethod](...coloredArgs);
|
|
165
193
|
}
|
|
166
194
|
}
|
|
167
195
|
}
|
|
@@ -113,19 +113,47 @@ class Colorino {
|
|
|
113
113
|
"[Colorino] No ANSI color support detected in this terminal. See [https://github.com/chalk/supports-color#support-matrix](https://github.com/chalk/supports-color#support-matrix) to learn how to enable terminal color."
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
|
+
_formatValue(value, maxDepth = 3) {
|
|
117
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
118
|
+
const sanitize = (val, currentDepth) => {
|
|
119
|
+
if (val === null || typeof val !== "object") return val;
|
|
120
|
+
if (seen.has(val)) return "[Circular]";
|
|
121
|
+
seen.add(val);
|
|
122
|
+
if (currentDepth >= maxDepth) return "[Object]";
|
|
123
|
+
if (Array.isArray(val)) {
|
|
124
|
+
return val.map((item) => sanitize(item, currentDepth + 1));
|
|
125
|
+
}
|
|
126
|
+
const result = {};
|
|
127
|
+
for (const key in val) {
|
|
128
|
+
result[key] = sanitize(val[key], currentDepth + 1);
|
|
129
|
+
}
|
|
130
|
+
return result;
|
|
131
|
+
};
|
|
132
|
+
return JSON.stringify(sanitize(value, 0), null, 2);
|
|
133
|
+
}
|
|
116
134
|
_out(level, args) {
|
|
117
135
|
const consoleMethod = isConsoleMethod(level) ? level : "log";
|
|
136
|
+
const processedArgs = args.map((arg) => {
|
|
137
|
+
if (arg !== null && typeof arg === "object" && typeof arg !== "string" && !(arg instanceof Error)) {
|
|
138
|
+
return this._formatValue(arg);
|
|
139
|
+
}
|
|
140
|
+
return arg;
|
|
141
|
+
});
|
|
118
142
|
if (this._colorLevel === ColorLevel.NO_COLOR || this._colorLevel === "UnknownEnv") {
|
|
119
|
-
if (level === "trace") console.trace(...
|
|
120
|
-
else console[consoleMethod](...
|
|
143
|
+
if (level === "trace") console.trace(...processedArgs);
|
|
144
|
+
else console[consoleMethod](...processedArgs);
|
|
121
145
|
return;
|
|
122
146
|
}
|
|
123
147
|
if (this.isBrowser) {
|
|
124
148
|
const hex2 = this._palette[level];
|
|
125
|
-
if (typeof
|
|
126
|
-
console[consoleMethod](
|
|
149
|
+
if (typeof processedArgs[0] === "string") {
|
|
150
|
+
console[consoleMethod](
|
|
151
|
+
`%c${processedArgs[0]}`,
|
|
152
|
+
`color:${hex2}`,
|
|
153
|
+
...processedArgs.slice(1)
|
|
154
|
+
);
|
|
127
155
|
} else {
|
|
128
|
-
console[consoleMethod](...
|
|
156
|
+
console[consoleMethod](...processedArgs);
|
|
129
157
|
}
|
|
130
158
|
return;
|
|
131
159
|
}
|
|
@@ -149,17 +177,17 @@ class Colorino {
|
|
|
149
177
|
break;
|
|
150
178
|
}
|
|
151
179
|
}
|
|
152
|
-
const
|
|
153
|
-
const firstStringIndex =
|
|
180
|
+
const coloredArgs = [...processedArgs];
|
|
181
|
+
const firstStringIndex = coloredArgs.findIndex(
|
|
154
182
|
(arg) => typeof arg === "string"
|
|
155
183
|
);
|
|
156
184
|
if (firstStringIndex !== -1) {
|
|
157
|
-
|
|
185
|
+
coloredArgs[firstStringIndex] = `${ansiCode}${coloredArgs[firstStringIndex]}\x1B[0m`;
|
|
158
186
|
}
|
|
159
187
|
if (level === "trace") {
|
|
160
|
-
console.trace(...
|
|
188
|
+
console.trace(...coloredArgs);
|
|
161
189
|
} else {
|
|
162
|
-
console[consoleMethod](...
|
|
190
|
+
console[consoleMethod](...coloredArgs);
|
|
163
191
|
}
|
|
164
192
|
}
|
|
165
193
|
}
|