colorino 0.8.0 → 0.9.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.CwcatZ-Z.mjs → colorino.B23laVKA.mjs} +63 -27
- package/dist/shared/{colorino.5b7Tq7_-.d.cts → colorino.DVUvKR4R.d.cts} +7 -0
- package/dist/shared/{colorino.5b7Tq7_-.d.mts → colorino.DVUvKR4R.d.mts} +7 -0
- package/dist/shared/{colorino.5b7Tq7_-.d.ts → colorino.DVUvKR4R.d.ts} +7 -0
- package/dist/shared/{colorino.B2VY_Grv.cjs → colorino.Y3oJ89MM.cjs} +63 -27
- 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.DVUvKR4R.cjs';
|
|
2
|
+
export { L as LogLevel, T as ThemeName, t as themePalettes } from './shared/colorino.DVUvKR4R.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.DVUvKR4R.mjs';
|
|
2
|
+
export { L as LogLevel, T as ThemeName, t as themePalettes } from './shared/colorino.DVUvKR4R.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.DVUvKR4R.js';
|
|
2
|
+
export { L as LogLevel, T as ThemeName, t as themePalettes } from './shared/colorino.DVUvKR4R.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.B23laVKA.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.DVUvKR4R.cjs';
|
|
2
|
+
export { L as LogLevel, T as ThemeName, t as themePalettes } from './shared/colorino.DVUvKR4R.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.DVUvKR4R.mjs';
|
|
2
|
+
export { L as LogLevel, T as ThemeName, t as themePalettes } from './shared/colorino.DVUvKR4R.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.DVUvKR4R.js';
|
|
2
|
+
export { L as LogLevel, T as ThemeName, t as themePalettes } from './shared/colorino.DVUvKR4R.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.B23laVKA.mjs';
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
3
|
|
|
4
4
|
class OscThemeQuerier {
|
|
@@ -125,24 +125,27 @@ class Colorino {
|
|
|
125
125
|
}
|
|
126
126
|
const result = {};
|
|
127
127
|
for (const key in val) {
|
|
128
|
-
result[key] = sanitize(
|
|
128
|
+
result[key] = sanitize(
|
|
129
|
+
val[key],
|
|
130
|
+
currentDepth + 1
|
|
131
|
+
);
|
|
129
132
|
}
|
|
130
133
|
return result;
|
|
131
134
|
};
|
|
132
135
|
return JSON.stringify(sanitize(value, 0), null, 2);
|
|
133
136
|
}
|
|
134
|
-
|
|
135
|
-
const consoleMethod = isConsoleMethod(level) ? level : "log";
|
|
137
|
+
_processArgs(args) {
|
|
136
138
|
const processedArgs = [];
|
|
137
139
|
let previousWasObject = false;
|
|
138
140
|
for (const arg of args) {
|
|
139
141
|
const isFormattableObject = arg !== null && typeof arg === "object" && typeof arg !== "string" && !(arg instanceof Error);
|
|
140
142
|
const isError = arg instanceof Error;
|
|
141
143
|
if (isFormattableObject) {
|
|
142
|
-
processedArgs.push(
|
|
144
|
+
processedArgs.push(`
|
|
145
|
+
${this._formatValue(arg)}`);
|
|
143
146
|
previousWasObject = true;
|
|
144
147
|
} else if (isError) {
|
|
145
|
-
processedArgs.push("\n", arg);
|
|
148
|
+
processedArgs.push("\n", this._cleanErrorStack(arg));
|
|
146
149
|
previousWasObject = true;
|
|
147
150
|
} else {
|
|
148
151
|
if (typeof arg === "string" && previousWasObject) {
|
|
@@ -154,25 +157,17 @@ ${arg}`);
|
|
|
154
157
|
previousWasObject = false;
|
|
155
158
|
}
|
|
156
159
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const hex2 = this._palette[level];
|
|
164
|
-
if (typeof processedArgs[0] === "string") {
|
|
165
|
-
console[consoleMethod](
|
|
166
|
-
`%c${processedArgs[0]}`,
|
|
167
|
-
`color:${hex2}`,
|
|
168
|
-
...processedArgs.slice(1)
|
|
169
|
-
);
|
|
170
|
-
} else {
|
|
171
|
-
console[consoleMethod](...processedArgs);
|
|
172
|
-
}
|
|
173
|
-
return;
|
|
160
|
+
return processedArgs;
|
|
161
|
+
}
|
|
162
|
+
_applyBrowserColors(consoleMethod, args) {
|
|
163
|
+
const hex = this._palette[consoleMethod];
|
|
164
|
+
if (typeof args[0] === "string") {
|
|
165
|
+
return [`%c${args[0]}`, `color:${hex}`, ...args.slice(1)];
|
|
174
166
|
}
|
|
175
|
-
|
|
167
|
+
return args;
|
|
168
|
+
}
|
|
169
|
+
_applyNodeColors(consoleMethod, args) {
|
|
170
|
+
const hex = this._palette[consoleMethod];
|
|
176
171
|
let ansiCode;
|
|
177
172
|
switch (this._colorLevel) {
|
|
178
173
|
case ColorLevel.TRUECOLOR: {
|
|
@@ -192,17 +187,58 @@ ${arg}`);
|
|
|
192
187
|
break;
|
|
193
188
|
}
|
|
194
189
|
}
|
|
195
|
-
const coloredArgs = [...
|
|
190
|
+
const coloredArgs = [...args];
|
|
196
191
|
const firstStringIndex = coloredArgs.findIndex(
|
|
197
192
|
(arg) => typeof arg === "string"
|
|
198
193
|
);
|
|
199
194
|
if (firstStringIndex !== -1) {
|
|
200
195
|
coloredArgs[firstStringIndex] = `${ansiCode}${coloredArgs[firstStringIndex]}\x1B[0m`;
|
|
201
196
|
}
|
|
202
|
-
|
|
203
|
-
|
|
197
|
+
return coloredArgs;
|
|
198
|
+
}
|
|
199
|
+
_output(consoleMethod, args) {
|
|
200
|
+
if (consoleMethod === "trace") {
|
|
201
|
+
this._printCleanTrace(args, consoleMethod);
|
|
202
|
+
} else {
|
|
203
|
+
console[consoleMethod](...args);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
_out(level, args) {
|
|
207
|
+
const consoleMethod = isConsoleMethod(level) ? level : "log";
|
|
208
|
+
const processedArgs = this._processArgs(args);
|
|
209
|
+
if (this._colorLevel === ColorLevel.NO_COLOR || this._colorLevel === "UnknownEnv") {
|
|
210
|
+
this._output(consoleMethod, processedArgs);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (this.isBrowser) {
|
|
214
|
+
const coloredArgs2 = this._applyBrowserColors(consoleMethod, processedArgs);
|
|
215
|
+
this._output(consoleMethod, coloredArgs2);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const coloredArgs = this._applyNodeColors(consoleMethod, processedArgs);
|
|
219
|
+
this._output(consoleMethod, coloredArgs);
|
|
220
|
+
}
|
|
221
|
+
_filterStack(stack) {
|
|
222
|
+
return stack.split("\n").filter(
|
|
223
|
+
(line) => !line.includes("colorino.js") && !line.includes("Colorino._out") && !line.includes("Colorino.error") && !line.includes("Colorino.warn") && !line.includes("Colorino.debug") && !line.includes("Colorino.info") && !line.includes("Colorino.log") && !line.includes("Colorino.trace") && !line.includes("Colorino._cleanErrorStack") && !line.includes("Colorino._printCleanTrace") && !line.includes("Colorino._filterStack")
|
|
224
|
+
).join("\n");
|
|
225
|
+
}
|
|
226
|
+
_cleanErrorStack(error) {
|
|
227
|
+
if (!error.stack) return error;
|
|
228
|
+
const cleanStack = this._filterStack(error.stack);
|
|
229
|
+
const cloned = Object.create(Object.getPrototypeOf(error));
|
|
230
|
+
Object.assign(cloned, error);
|
|
231
|
+
cloned.stack = cleanStack;
|
|
232
|
+
return cloned;
|
|
233
|
+
}
|
|
234
|
+
_printCleanTrace(args, method) {
|
|
235
|
+
const error = new Error();
|
|
236
|
+
if (error.stack) {
|
|
237
|
+
const cleanStack = this._filterStack(error.stack);
|
|
238
|
+
console[method](...args, `
|
|
239
|
+
${cleanStack}`);
|
|
204
240
|
} else {
|
|
205
|
-
console[
|
|
241
|
+
console[method](...args);
|
|
206
242
|
}
|
|
207
243
|
}
|
|
208
244
|
}
|
|
@@ -449,7 +449,14 @@ declare class Colorino {
|
|
|
449
449
|
private _detectColorSupport;
|
|
450
450
|
private _maybeWarnUser;
|
|
451
451
|
private _formatValue;
|
|
452
|
+
private _processArgs;
|
|
453
|
+
private _applyBrowserColors;
|
|
454
|
+
private _applyNodeColors;
|
|
455
|
+
private _output;
|
|
452
456
|
private _out;
|
|
457
|
+
private _filterStack;
|
|
458
|
+
private _cleanErrorStack;
|
|
459
|
+
private _printCleanTrace;
|
|
453
460
|
}
|
|
454
461
|
|
|
455
462
|
declare const themePalettes: Record<ThemeName, Palette>;
|
|
@@ -449,7 +449,14 @@ declare class Colorino {
|
|
|
449
449
|
private _detectColorSupport;
|
|
450
450
|
private _maybeWarnUser;
|
|
451
451
|
private _formatValue;
|
|
452
|
+
private _processArgs;
|
|
453
|
+
private _applyBrowserColors;
|
|
454
|
+
private _applyNodeColors;
|
|
455
|
+
private _output;
|
|
452
456
|
private _out;
|
|
457
|
+
private _filterStack;
|
|
458
|
+
private _cleanErrorStack;
|
|
459
|
+
private _printCleanTrace;
|
|
453
460
|
}
|
|
454
461
|
|
|
455
462
|
declare const themePalettes: Record<ThemeName, Palette>;
|
|
@@ -449,7 +449,14 @@ declare class Colorino {
|
|
|
449
449
|
private _detectColorSupport;
|
|
450
450
|
private _maybeWarnUser;
|
|
451
451
|
private _formatValue;
|
|
452
|
+
private _processArgs;
|
|
453
|
+
private _applyBrowserColors;
|
|
454
|
+
private _applyNodeColors;
|
|
455
|
+
private _output;
|
|
452
456
|
private _out;
|
|
457
|
+
private _filterStack;
|
|
458
|
+
private _cleanErrorStack;
|
|
459
|
+
private _printCleanTrace;
|
|
453
460
|
}
|
|
454
461
|
|
|
455
462
|
declare const themePalettes: Record<ThemeName, Palette>;
|
|
@@ -127,24 +127,27 @@ class Colorino {
|
|
|
127
127
|
}
|
|
128
128
|
const result = {};
|
|
129
129
|
for (const key in val) {
|
|
130
|
-
result[key] = sanitize(
|
|
130
|
+
result[key] = sanitize(
|
|
131
|
+
val[key],
|
|
132
|
+
currentDepth + 1
|
|
133
|
+
);
|
|
131
134
|
}
|
|
132
135
|
return result;
|
|
133
136
|
};
|
|
134
137
|
return JSON.stringify(sanitize(value, 0), null, 2);
|
|
135
138
|
}
|
|
136
|
-
|
|
137
|
-
const consoleMethod = isConsoleMethod(level) ? level : "log";
|
|
139
|
+
_processArgs(args) {
|
|
138
140
|
const processedArgs = [];
|
|
139
141
|
let previousWasObject = false;
|
|
140
142
|
for (const arg of args) {
|
|
141
143
|
const isFormattableObject = arg !== null && typeof arg === "object" && typeof arg !== "string" && !(arg instanceof Error);
|
|
142
144
|
const isError = arg instanceof Error;
|
|
143
145
|
if (isFormattableObject) {
|
|
144
|
-
processedArgs.push(
|
|
146
|
+
processedArgs.push(`
|
|
147
|
+
${this._formatValue(arg)}`);
|
|
145
148
|
previousWasObject = true;
|
|
146
149
|
} else if (isError) {
|
|
147
|
-
processedArgs.push("\n", arg);
|
|
150
|
+
processedArgs.push("\n", this._cleanErrorStack(arg));
|
|
148
151
|
previousWasObject = true;
|
|
149
152
|
} else {
|
|
150
153
|
if (typeof arg === "string" && previousWasObject) {
|
|
@@ -156,25 +159,17 @@ ${arg}`);
|
|
|
156
159
|
previousWasObject = false;
|
|
157
160
|
}
|
|
158
161
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const hex2 = this._palette[level];
|
|
166
|
-
if (typeof processedArgs[0] === "string") {
|
|
167
|
-
console[consoleMethod](
|
|
168
|
-
`%c${processedArgs[0]}`,
|
|
169
|
-
`color:${hex2}`,
|
|
170
|
-
...processedArgs.slice(1)
|
|
171
|
-
);
|
|
172
|
-
} else {
|
|
173
|
-
console[consoleMethod](...processedArgs);
|
|
174
|
-
}
|
|
175
|
-
return;
|
|
162
|
+
return processedArgs;
|
|
163
|
+
}
|
|
164
|
+
_applyBrowserColors(consoleMethod, args) {
|
|
165
|
+
const hex = this._palette[consoleMethod];
|
|
166
|
+
if (typeof args[0] === "string") {
|
|
167
|
+
return [`%c${args[0]}`, `color:${hex}`, ...args.slice(1)];
|
|
176
168
|
}
|
|
177
|
-
|
|
169
|
+
return args;
|
|
170
|
+
}
|
|
171
|
+
_applyNodeColors(consoleMethod, args) {
|
|
172
|
+
const hex = this._palette[consoleMethod];
|
|
178
173
|
let ansiCode;
|
|
179
174
|
switch (this._colorLevel) {
|
|
180
175
|
case ColorLevel.TRUECOLOR: {
|
|
@@ -194,17 +189,58 @@ ${arg}`);
|
|
|
194
189
|
break;
|
|
195
190
|
}
|
|
196
191
|
}
|
|
197
|
-
const coloredArgs = [...
|
|
192
|
+
const coloredArgs = [...args];
|
|
198
193
|
const firstStringIndex = coloredArgs.findIndex(
|
|
199
194
|
(arg) => typeof arg === "string"
|
|
200
195
|
);
|
|
201
196
|
if (firstStringIndex !== -1) {
|
|
202
197
|
coloredArgs[firstStringIndex] = `${ansiCode}${coloredArgs[firstStringIndex]}\x1B[0m`;
|
|
203
198
|
}
|
|
204
|
-
|
|
205
|
-
|
|
199
|
+
return coloredArgs;
|
|
200
|
+
}
|
|
201
|
+
_output(consoleMethod, args) {
|
|
202
|
+
if (consoleMethod === "trace") {
|
|
203
|
+
this._printCleanTrace(args, consoleMethod);
|
|
204
|
+
} else {
|
|
205
|
+
console[consoleMethod](...args);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
_out(level, args) {
|
|
209
|
+
const consoleMethod = isConsoleMethod(level) ? level : "log";
|
|
210
|
+
const processedArgs = this._processArgs(args);
|
|
211
|
+
if (this._colorLevel === ColorLevel.NO_COLOR || this._colorLevel === "UnknownEnv") {
|
|
212
|
+
this._output(consoleMethod, processedArgs);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (this.isBrowser) {
|
|
216
|
+
const coloredArgs2 = this._applyBrowserColors(consoleMethod, processedArgs);
|
|
217
|
+
this._output(consoleMethod, coloredArgs2);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const coloredArgs = this._applyNodeColors(consoleMethod, processedArgs);
|
|
221
|
+
this._output(consoleMethod, coloredArgs);
|
|
222
|
+
}
|
|
223
|
+
_filterStack(stack) {
|
|
224
|
+
return stack.split("\n").filter(
|
|
225
|
+
(line) => !line.includes("colorino.js") && !line.includes("Colorino._out") && !line.includes("Colorino.error") && !line.includes("Colorino.warn") && !line.includes("Colorino.debug") && !line.includes("Colorino.info") && !line.includes("Colorino.log") && !line.includes("Colorino.trace") && !line.includes("Colorino._cleanErrorStack") && !line.includes("Colorino._printCleanTrace") && !line.includes("Colorino._filterStack")
|
|
226
|
+
).join("\n");
|
|
227
|
+
}
|
|
228
|
+
_cleanErrorStack(error) {
|
|
229
|
+
if (!error.stack) return error;
|
|
230
|
+
const cleanStack = this._filterStack(error.stack);
|
|
231
|
+
const cloned = Object.create(Object.getPrototypeOf(error));
|
|
232
|
+
Object.assign(cloned, error);
|
|
233
|
+
cloned.stack = cleanStack;
|
|
234
|
+
return cloned;
|
|
235
|
+
}
|
|
236
|
+
_printCleanTrace(args, method) {
|
|
237
|
+
const error = new Error();
|
|
238
|
+
if (error.stack) {
|
|
239
|
+
const cleanStack = this._filterStack(error.stack);
|
|
240
|
+
console[method](...args, `
|
|
241
|
+
${cleanStack}`);
|
|
206
242
|
} else {
|
|
207
|
-
console[
|
|
243
|
+
console[method](...args);
|
|
208
244
|
}
|
|
209
245
|
}
|
|
210
246
|
}
|