colorino 0.10.1 → 0.12.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/README.md +360 -351
- package/dist/browser.bundle.cjs +109 -116
- package/dist/browser.bundle.mjs +110 -116
- package/dist/browser.cjs +13 -14
- package/dist/browser.d.cts +5 -5
- package/dist/browser.d.mts +5 -5
- package/dist/browser.d.ts +5 -5
- package/dist/browser.mjs +5 -5
- package/dist/node.cjs +58 -125
- package/dist/node.d.cts +3 -6
- package/dist/node.d.mts +3 -6
- package/dist/node.d.ts +3 -6
- package/dist/node.mjs +40 -106
- package/dist/shared/{colorino.B4p-EEl9.cjs → colorino.BgxwS1Lc.cjs} +106 -122
- package/dist/shared/{colorino.BnDovC2X.mjs → colorino.ClDpLv-k.mjs} +107 -120
- package/dist/shared/{colorino.DjY5jpGa.d.ts → colorino.Dh_05jaQ.d.cts} +3 -4
- package/dist/shared/{colorino.DjY5jpGa.d.cts → colorino.Dh_05jaQ.d.mts} +3 -4
- package/dist/shared/{colorino.DjY5jpGa.d.mts → colorino.Dh_05jaQ.d.ts} +3 -4
- package/package.json +2 -1
|
@@ -63,13 +63,97 @@ function isConsoleMethod(level) {
|
|
|
63
63
|
return ["log", "info", "warn", "error", "trace", "debug"].includes(level);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
const catppuccinMochaPalette = {
|
|
67
|
+
log: "#cdd6f4",
|
|
68
|
+
// Text
|
|
69
|
+
info: "#89b4fa",
|
|
70
|
+
// Blue
|
|
71
|
+
warn: "#f9e2af",
|
|
72
|
+
// Yellow
|
|
73
|
+
error: "#f38ba8",
|
|
74
|
+
// Red
|
|
75
|
+
debug: "#a6adc8",
|
|
76
|
+
// Subtext0
|
|
77
|
+
trace: "#9399b2"
|
|
78
|
+
// Subtext1
|
|
79
|
+
};
|
|
80
|
+
const catppuccinLattePalette = {
|
|
81
|
+
log: "#4c4f69",
|
|
82
|
+
// Text
|
|
83
|
+
info: "#1e66f5",
|
|
84
|
+
// Blue
|
|
85
|
+
warn: "#df8e1d",
|
|
86
|
+
// Yellow
|
|
87
|
+
error: "#d20f39",
|
|
88
|
+
// Red
|
|
89
|
+
debug: "#7c7f93",
|
|
90
|
+
// Subtext0
|
|
91
|
+
trace: "#8c8fa1"
|
|
92
|
+
// Subtext1
|
|
93
|
+
};
|
|
94
|
+
const draculaPalette = {
|
|
95
|
+
log: "#f8f8f2",
|
|
96
|
+
// Foreground
|
|
97
|
+
info: "#8be9fd",
|
|
98
|
+
// Cyan
|
|
99
|
+
warn: "#f1fa8c",
|
|
100
|
+
// Yellow
|
|
101
|
+
error: "#ff5555",
|
|
102
|
+
// Red
|
|
103
|
+
debug: "#bd93f9",
|
|
104
|
+
// Purple
|
|
105
|
+
trace: "#6272a4"
|
|
106
|
+
// Comment
|
|
107
|
+
};
|
|
108
|
+
const githubLightPalette = {
|
|
109
|
+
log: "#24292e",
|
|
110
|
+
// Text
|
|
111
|
+
info: "#0366d6",
|
|
112
|
+
// Blue
|
|
113
|
+
warn: "#f9a002",
|
|
114
|
+
// Yellow
|
|
115
|
+
error: "#d73a49",
|
|
116
|
+
// Red
|
|
117
|
+
debug: "#586069",
|
|
118
|
+
// Gray
|
|
119
|
+
trace: "#6a737d"
|
|
120
|
+
// Gray-light
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const themePalettes = {
|
|
124
|
+
"catppuccin-mocha": catppuccinMochaPalette,
|
|
125
|
+
"catppuccin-latte": catppuccinLattePalette,
|
|
126
|
+
dracula: draculaPalette,
|
|
127
|
+
"github-light": githubLightPalette
|
|
128
|
+
};
|
|
129
|
+
const defaultDarkTheme = "dracula";
|
|
130
|
+
const defaultLightTheme = "github-light";
|
|
131
|
+
function isThemeName(theme) {
|
|
132
|
+
return theme in themePalettes;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function determineBaseTheme(themeOpt, detectedBrowserTheme) {
|
|
136
|
+
let baseThemeName;
|
|
137
|
+
if (isThemeName(themeOpt)) {
|
|
138
|
+
baseThemeName = themeOpt;
|
|
139
|
+
} else if (themeOpt === "light") {
|
|
140
|
+
baseThemeName = defaultLightTheme;
|
|
141
|
+
} else if (themeOpt === "dark") {
|
|
142
|
+
baseThemeName = defaultDarkTheme;
|
|
143
|
+
} else {
|
|
144
|
+
baseThemeName = detectedBrowserTheme === "light" ? defaultLightTheme : defaultDarkTheme;
|
|
145
|
+
}
|
|
146
|
+
return baseThemeName;
|
|
147
|
+
}
|
|
148
|
+
|
|
66
149
|
class MyColorino {
|
|
67
|
-
constructor(
|
|
68
|
-
this.
|
|
150
|
+
constructor(initialPalette, _userPalette, _validator, _browserColorSupportDetector, _nodeColorSupportDetector, _options = {}) {
|
|
151
|
+
this._userPalette = _userPalette;
|
|
69
152
|
this._validator = _validator;
|
|
70
153
|
this._browserColorSupportDetector = _browserColorSupportDetector;
|
|
71
154
|
this._nodeColorSupportDetector = _nodeColorSupportDetector;
|
|
72
155
|
this._options = _options;
|
|
156
|
+
this._palette = initialPalette;
|
|
73
157
|
this.isBrowser = !!this._browserColorSupportDetector;
|
|
74
158
|
this._colorLevel = this._detectColorSupport();
|
|
75
159
|
const validatePaletteResult = this._validator.validatePalette(this._palette);
|
|
@@ -77,10 +161,23 @@ class MyColorino {
|
|
|
77
161
|
if (this._colorLevel !== ColorLevel.NO_COLOR && !this._options.disableWarnings && this._colorLevel === "UnknownEnv") {
|
|
78
162
|
this._maybeWarnUser();
|
|
79
163
|
}
|
|
164
|
+
const themeOpt = this._options.theme ?? "auto";
|
|
165
|
+
if (themeOpt === "auto" && this._nodeColorSupportDetector) {
|
|
166
|
+
this._nodeColorSupportDetector.onTheme((resolvedTheme) => {
|
|
167
|
+
this._appllyResolvedTheme(resolvedTheme);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
80
170
|
}
|
|
81
171
|
_alreadyWarned = false;
|
|
82
172
|
_colorLevel;
|
|
83
173
|
isBrowser;
|
|
174
|
+
_palette;
|
|
175
|
+
_appllyResolvedTheme(resolvedTheme) {
|
|
176
|
+
const themeOpt = this._options.theme ?? "auto";
|
|
177
|
+
const baseThemeName = determineBaseTheme(themeOpt, resolvedTheme);
|
|
178
|
+
const basePalette = themePalettes[baseThemeName];
|
|
179
|
+
this._palette = { ...basePalette, ...this._userPalette };
|
|
180
|
+
}
|
|
84
181
|
log(...args) {
|
|
85
182
|
this._out("log", args);
|
|
86
183
|
}
|
|
@@ -112,10 +209,10 @@ class MyColorino {
|
|
|
112
209
|
if (this._alreadyWarned) return;
|
|
113
210
|
this._alreadyWarned = true;
|
|
114
211
|
console.warn(
|
|
115
|
-
"
|
|
212
|
+
"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
213
|
);
|
|
117
214
|
}
|
|
118
|
-
_formatValue(value, maxDepth = 5) {
|
|
215
|
+
_formatValue(value, maxDepth = this._options.maxDepth ?? 5) {
|
|
119
216
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
120
217
|
const sanitize = (val, currentDepth) => {
|
|
121
218
|
if (val === null || typeof val !== "object") return val;
|
|
@@ -200,7 +297,7 @@ ${arg}`);
|
|
|
200
297
|
}
|
|
201
298
|
_output(consoleMethod, args) {
|
|
202
299
|
if (consoleMethod === "trace") {
|
|
203
|
-
this._printCleanTrace(args
|
|
300
|
+
this._printCleanTrace(args);
|
|
204
301
|
} else {
|
|
205
302
|
console[consoleMethod](...args);
|
|
206
303
|
}
|
|
@@ -221,9 +318,7 @@ ${arg}`);
|
|
|
221
318
|
this._output(consoleMethod, coloredArgs);
|
|
222
319
|
}
|
|
223
320
|
_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");
|
|
321
|
+
return stack.split("\n").filter((line) => !line.match(/.*colorino.*/gi)).join("\n");
|
|
227
322
|
}
|
|
228
323
|
_cleanErrorStack(error) {
|
|
229
324
|
if (!error.stack) return error;
|
|
@@ -233,14 +328,14 @@ ${arg}`);
|
|
|
233
328
|
cloned.stack = cleanStack;
|
|
234
329
|
return cloned;
|
|
235
330
|
}
|
|
236
|
-
_printCleanTrace(args
|
|
331
|
+
_printCleanTrace(args) {
|
|
237
332
|
const error = new Error();
|
|
238
333
|
if (error.stack) {
|
|
239
334
|
const cleanStack = this._filterStack(error.stack);
|
|
240
|
-
console
|
|
335
|
+
console.log(...args, `
|
|
241
336
|
${cleanStack}`);
|
|
242
337
|
} else {
|
|
243
|
-
console
|
|
338
|
+
console.log(...args);
|
|
244
339
|
}
|
|
245
340
|
}
|
|
246
341
|
}
|
|
@@ -734,13 +829,6 @@ class ColorinoError extends Error {
|
|
|
734
829
|
Object.setPrototypeOf(this, ColorinoError.prototype);
|
|
735
830
|
}
|
|
736
831
|
}
|
|
737
|
-
class OscQueryError extends Error {
|
|
738
|
-
constructor(message) {
|
|
739
|
-
super(message);
|
|
740
|
-
this.name = "OscQueryError";
|
|
741
|
-
Object.setPrototypeOf(this, OscQueryError.prototype);
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
832
|
|
|
745
833
|
class InputValidator {
|
|
746
834
|
validateHex(hex) {
|
|
@@ -763,112 +851,8 @@ class InputValidator {
|
|
|
763
851
|
}
|
|
764
852
|
}
|
|
765
853
|
|
|
766
|
-
const catppuccinMochaPalette = {
|
|
767
|
-
log: "#cdd6f4",
|
|
768
|
-
// Text
|
|
769
|
-
info: "#89b4fa",
|
|
770
|
-
// Blue
|
|
771
|
-
warn: "#f9e2af",
|
|
772
|
-
// Yellow
|
|
773
|
-
error: "#f38ba8",
|
|
774
|
-
// Red
|
|
775
|
-
debug: "#a6adc8",
|
|
776
|
-
// Subtext0
|
|
777
|
-
trace: "#9399b2"
|
|
778
|
-
// Subtext1
|
|
779
|
-
};
|
|
780
|
-
const catppuccinLattePalette = {
|
|
781
|
-
log: "#4c4f69",
|
|
782
|
-
// Text
|
|
783
|
-
info: "#1e66f5",
|
|
784
|
-
// Blue
|
|
785
|
-
warn: "#df8e1d",
|
|
786
|
-
// Yellow
|
|
787
|
-
error: "#d20f39",
|
|
788
|
-
// Red
|
|
789
|
-
debug: "#7c7f93",
|
|
790
|
-
// Subtext0
|
|
791
|
-
trace: "#8c8fa1"
|
|
792
|
-
// Subtext1
|
|
793
|
-
};
|
|
794
|
-
const draculaPalette = {
|
|
795
|
-
log: "#f8f8f2",
|
|
796
|
-
// Foreground
|
|
797
|
-
info: "#8be9fd",
|
|
798
|
-
// Cyan
|
|
799
|
-
warn: "#f1fa8c",
|
|
800
|
-
// Yellow
|
|
801
|
-
error: "#ff5555",
|
|
802
|
-
// Red
|
|
803
|
-
debug: "#bd93f9",
|
|
804
|
-
// Purple
|
|
805
|
-
trace: "#6272a4"
|
|
806
|
-
// Comment
|
|
807
|
-
};
|
|
808
|
-
const githubLightPalette = {
|
|
809
|
-
log: "#24292e",
|
|
810
|
-
// Text
|
|
811
|
-
info: "#0366d6",
|
|
812
|
-
// Blue
|
|
813
|
-
warn: "#f9a002",
|
|
814
|
-
// Yellow
|
|
815
|
-
error: "#d73a49",
|
|
816
|
-
// Red
|
|
817
|
-
debug: "#586069",
|
|
818
|
-
// Gray
|
|
819
|
-
trace: "#6a737d"
|
|
820
|
-
// Gray-light
|
|
821
|
-
};
|
|
822
|
-
const minimalDarkPalette = {
|
|
823
|
-
log: "#ffffff",
|
|
824
|
-
info: "#ffffff",
|
|
825
|
-
warn: "#ffffff",
|
|
826
|
-
error: "#ffffff",
|
|
827
|
-
debug: "#ffffff",
|
|
828
|
-
trace: "#ffffff"
|
|
829
|
-
};
|
|
830
|
-
const minimalLightPalette = {
|
|
831
|
-
log: "#000000",
|
|
832
|
-
info: "#000000",
|
|
833
|
-
warn: "#000000",
|
|
834
|
-
error: "#000000",
|
|
835
|
-
debug: "#000000",
|
|
836
|
-
trace: "#000000"
|
|
837
|
-
};
|
|
838
|
-
|
|
839
|
-
const themePalettes = {
|
|
840
|
-
"catppuccin-mocha": catppuccinMochaPalette,
|
|
841
|
-
"catppuccin-latte": catppuccinLattePalette,
|
|
842
|
-
dracula: draculaPalette,
|
|
843
|
-
"github-light": githubLightPalette,
|
|
844
|
-
"minimal-dark": minimalDarkPalette,
|
|
845
|
-
"minimal-light": minimalLightPalette
|
|
846
|
-
};
|
|
847
|
-
const defaultDarkTheme = "minimal-dark";
|
|
848
|
-
const defaultLightTheme = "minimal-light";
|
|
849
|
-
function isThemeName(theme) {
|
|
850
|
-
return theme in themePalettes;
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
function determineBaseTheme(themeOpt, detectedBrowserTheme) {
|
|
854
|
-
let baseThemeName;
|
|
855
|
-
if (isThemeName(themeOpt)) {
|
|
856
|
-
baseThemeName = themeOpt;
|
|
857
|
-
} else if (themeOpt === "light") {
|
|
858
|
-
baseThemeName = defaultLightTheme;
|
|
859
|
-
} else if (themeOpt === "dark") {
|
|
860
|
-
baseThemeName = defaultDarkTheme;
|
|
861
|
-
} else {
|
|
862
|
-
baseThemeName = detectedBrowserTheme === "light" ? defaultLightTheme : defaultDarkTheme;
|
|
863
|
-
}
|
|
864
|
-
return baseThemeName;
|
|
865
|
-
}
|
|
866
|
-
|
|
867
854
|
exports.ColorLevel = ColorLevel;
|
|
868
855
|
exports.InputValidator = InputValidator;
|
|
869
856
|
exports.MyColorino = MyColorino;
|
|
870
|
-
exports.OscQueryError = OscQueryError;
|
|
871
857
|
exports.determineBaseTheme = determineBaseTheme;
|
|
872
|
-
exports.err = err;
|
|
873
|
-
exports.ok = ok;
|
|
874
858
|
exports.themePalettes = themePalettes;
|
|
@@ -61,13 +61,97 @@ function isConsoleMethod(level) {
|
|
|
61
61
|
return ["log", "info", "warn", "error", "trace", "debug"].includes(level);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
const catppuccinMochaPalette = {
|
|
65
|
+
log: "#cdd6f4",
|
|
66
|
+
// Text
|
|
67
|
+
info: "#89b4fa",
|
|
68
|
+
// Blue
|
|
69
|
+
warn: "#f9e2af",
|
|
70
|
+
// Yellow
|
|
71
|
+
error: "#f38ba8",
|
|
72
|
+
// Red
|
|
73
|
+
debug: "#a6adc8",
|
|
74
|
+
// Subtext0
|
|
75
|
+
trace: "#9399b2"
|
|
76
|
+
// Subtext1
|
|
77
|
+
};
|
|
78
|
+
const catppuccinLattePalette = {
|
|
79
|
+
log: "#4c4f69",
|
|
80
|
+
// Text
|
|
81
|
+
info: "#1e66f5",
|
|
82
|
+
// Blue
|
|
83
|
+
warn: "#df8e1d",
|
|
84
|
+
// Yellow
|
|
85
|
+
error: "#d20f39",
|
|
86
|
+
// Red
|
|
87
|
+
debug: "#7c7f93",
|
|
88
|
+
// Subtext0
|
|
89
|
+
trace: "#8c8fa1"
|
|
90
|
+
// Subtext1
|
|
91
|
+
};
|
|
92
|
+
const draculaPalette = {
|
|
93
|
+
log: "#f8f8f2",
|
|
94
|
+
// Foreground
|
|
95
|
+
info: "#8be9fd",
|
|
96
|
+
// Cyan
|
|
97
|
+
warn: "#f1fa8c",
|
|
98
|
+
// Yellow
|
|
99
|
+
error: "#ff5555",
|
|
100
|
+
// Red
|
|
101
|
+
debug: "#bd93f9",
|
|
102
|
+
// Purple
|
|
103
|
+
trace: "#6272a4"
|
|
104
|
+
// Comment
|
|
105
|
+
};
|
|
106
|
+
const githubLightPalette = {
|
|
107
|
+
log: "#24292e",
|
|
108
|
+
// Text
|
|
109
|
+
info: "#0366d6",
|
|
110
|
+
// Blue
|
|
111
|
+
warn: "#f9a002",
|
|
112
|
+
// Yellow
|
|
113
|
+
error: "#d73a49",
|
|
114
|
+
// Red
|
|
115
|
+
debug: "#586069",
|
|
116
|
+
// Gray
|
|
117
|
+
trace: "#6a737d"
|
|
118
|
+
// Gray-light
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const themePalettes = {
|
|
122
|
+
"catppuccin-mocha": catppuccinMochaPalette,
|
|
123
|
+
"catppuccin-latte": catppuccinLattePalette,
|
|
124
|
+
dracula: draculaPalette,
|
|
125
|
+
"github-light": githubLightPalette
|
|
126
|
+
};
|
|
127
|
+
const defaultDarkTheme = "dracula";
|
|
128
|
+
const defaultLightTheme = "github-light";
|
|
129
|
+
function isThemeName(theme) {
|
|
130
|
+
return theme in themePalettes;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function determineBaseTheme(themeOpt, detectedBrowserTheme) {
|
|
134
|
+
let baseThemeName;
|
|
135
|
+
if (isThemeName(themeOpt)) {
|
|
136
|
+
baseThemeName = themeOpt;
|
|
137
|
+
} else if (themeOpt === "light") {
|
|
138
|
+
baseThemeName = defaultLightTheme;
|
|
139
|
+
} else if (themeOpt === "dark") {
|
|
140
|
+
baseThemeName = defaultDarkTheme;
|
|
141
|
+
} else {
|
|
142
|
+
baseThemeName = detectedBrowserTheme === "light" ? defaultLightTheme : defaultDarkTheme;
|
|
143
|
+
}
|
|
144
|
+
return baseThemeName;
|
|
145
|
+
}
|
|
146
|
+
|
|
64
147
|
class MyColorino {
|
|
65
|
-
constructor(
|
|
66
|
-
this.
|
|
148
|
+
constructor(initialPalette, _userPalette, _validator, _browserColorSupportDetector, _nodeColorSupportDetector, _options = {}) {
|
|
149
|
+
this._userPalette = _userPalette;
|
|
67
150
|
this._validator = _validator;
|
|
68
151
|
this._browserColorSupportDetector = _browserColorSupportDetector;
|
|
69
152
|
this._nodeColorSupportDetector = _nodeColorSupportDetector;
|
|
70
153
|
this._options = _options;
|
|
154
|
+
this._palette = initialPalette;
|
|
71
155
|
this.isBrowser = !!this._browserColorSupportDetector;
|
|
72
156
|
this._colorLevel = this._detectColorSupport();
|
|
73
157
|
const validatePaletteResult = this._validator.validatePalette(this._palette);
|
|
@@ -75,10 +159,23 @@ class MyColorino {
|
|
|
75
159
|
if (this._colorLevel !== ColorLevel.NO_COLOR && !this._options.disableWarnings && this._colorLevel === "UnknownEnv") {
|
|
76
160
|
this._maybeWarnUser();
|
|
77
161
|
}
|
|
162
|
+
const themeOpt = this._options.theme ?? "auto";
|
|
163
|
+
if (themeOpt === "auto" && this._nodeColorSupportDetector) {
|
|
164
|
+
this._nodeColorSupportDetector.onTheme((resolvedTheme) => {
|
|
165
|
+
this._appllyResolvedTheme(resolvedTheme);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
78
168
|
}
|
|
79
169
|
_alreadyWarned = false;
|
|
80
170
|
_colorLevel;
|
|
81
171
|
isBrowser;
|
|
172
|
+
_palette;
|
|
173
|
+
_appllyResolvedTheme(resolvedTheme) {
|
|
174
|
+
const themeOpt = this._options.theme ?? "auto";
|
|
175
|
+
const baseThemeName = determineBaseTheme(themeOpt, resolvedTheme);
|
|
176
|
+
const basePalette = themePalettes[baseThemeName];
|
|
177
|
+
this._palette = { ...basePalette, ...this._userPalette };
|
|
178
|
+
}
|
|
82
179
|
log(...args) {
|
|
83
180
|
this._out("log", args);
|
|
84
181
|
}
|
|
@@ -110,10 +207,10 @@ class MyColorino {
|
|
|
110
207
|
if (this._alreadyWarned) return;
|
|
111
208
|
this._alreadyWarned = true;
|
|
112
209
|
console.warn(
|
|
113
|
-
"
|
|
210
|
+
"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
211
|
);
|
|
115
212
|
}
|
|
116
|
-
_formatValue(value, maxDepth = 5) {
|
|
213
|
+
_formatValue(value, maxDepth = this._options.maxDepth ?? 5) {
|
|
117
214
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
118
215
|
const sanitize = (val, currentDepth) => {
|
|
119
216
|
if (val === null || typeof val !== "object") return val;
|
|
@@ -198,7 +295,7 @@ ${arg}`);
|
|
|
198
295
|
}
|
|
199
296
|
_output(consoleMethod, args) {
|
|
200
297
|
if (consoleMethod === "trace") {
|
|
201
|
-
this._printCleanTrace(args
|
|
298
|
+
this._printCleanTrace(args);
|
|
202
299
|
} else {
|
|
203
300
|
console[consoleMethod](...args);
|
|
204
301
|
}
|
|
@@ -219,9 +316,7 @@ ${arg}`);
|
|
|
219
316
|
this._output(consoleMethod, coloredArgs);
|
|
220
317
|
}
|
|
221
318
|
_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");
|
|
319
|
+
return stack.split("\n").filter((line) => !line.match(/.*colorino.*/gi)).join("\n");
|
|
225
320
|
}
|
|
226
321
|
_cleanErrorStack(error) {
|
|
227
322
|
if (!error.stack) return error;
|
|
@@ -231,14 +326,14 @@ ${arg}`);
|
|
|
231
326
|
cloned.stack = cleanStack;
|
|
232
327
|
return cloned;
|
|
233
328
|
}
|
|
234
|
-
_printCleanTrace(args
|
|
329
|
+
_printCleanTrace(args) {
|
|
235
330
|
const error = new Error();
|
|
236
331
|
if (error.stack) {
|
|
237
332
|
const cleanStack = this._filterStack(error.stack);
|
|
238
|
-
console
|
|
333
|
+
console.log(...args, `
|
|
239
334
|
${cleanStack}`);
|
|
240
335
|
} else {
|
|
241
|
-
console
|
|
336
|
+
console.log(...args);
|
|
242
337
|
}
|
|
243
338
|
}
|
|
244
339
|
}
|
|
@@ -732,13 +827,6 @@ class ColorinoError extends Error {
|
|
|
732
827
|
Object.setPrototypeOf(this, ColorinoError.prototype);
|
|
733
828
|
}
|
|
734
829
|
}
|
|
735
|
-
class OscQueryError extends Error {
|
|
736
|
-
constructor(message) {
|
|
737
|
-
super(message);
|
|
738
|
-
this.name = "OscQueryError";
|
|
739
|
-
Object.setPrototypeOf(this, OscQueryError.prototype);
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
830
|
|
|
743
831
|
class InputValidator {
|
|
744
832
|
validateHex(hex) {
|
|
@@ -761,105 +849,4 @@ class InputValidator {
|
|
|
761
849
|
}
|
|
762
850
|
}
|
|
763
851
|
|
|
764
|
-
|
|
765
|
-
log: "#cdd6f4",
|
|
766
|
-
// Text
|
|
767
|
-
info: "#89b4fa",
|
|
768
|
-
// Blue
|
|
769
|
-
warn: "#f9e2af",
|
|
770
|
-
// Yellow
|
|
771
|
-
error: "#f38ba8",
|
|
772
|
-
// Red
|
|
773
|
-
debug: "#a6adc8",
|
|
774
|
-
// Subtext0
|
|
775
|
-
trace: "#9399b2"
|
|
776
|
-
// Subtext1
|
|
777
|
-
};
|
|
778
|
-
const catppuccinLattePalette = {
|
|
779
|
-
log: "#4c4f69",
|
|
780
|
-
// Text
|
|
781
|
-
info: "#1e66f5",
|
|
782
|
-
// Blue
|
|
783
|
-
warn: "#df8e1d",
|
|
784
|
-
// Yellow
|
|
785
|
-
error: "#d20f39",
|
|
786
|
-
// Red
|
|
787
|
-
debug: "#7c7f93",
|
|
788
|
-
// Subtext0
|
|
789
|
-
trace: "#8c8fa1"
|
|
790
|
-
// Subtext1
|
|
791
|
-
};
|
|
792
|
-
const draculaPalette = {
|
|
793
|
-
log: "#f8f8f2",
|
|
794
|
-
// Foreground
|
|
795
|
-
info: "#8be9fd",
|
|
796
|
-
// Cyan
|
|
797
|
-
warn: "#f1fa8c",
|
|
798
|
-
// Yellow
|
|
799
|
-
error: "#ff5555",
|
|
800
|
-
// Red
|
|
801
|
-
debug: "#bd93f9",
|
|
802
|
-
// Purple
|
|
803
|
-
trace: "#6272a4"
|
|
804
|
-
// Comment
|
|
805
|
-
};
|
|
806
|
-
const githubLightPalette = {
|
|
807
|
-
log: "#24292e",
|
|
808
|
-
// Text
|
|
809
|
-
info: "#0366d6",
|
|
810
|
-
// Blue
|
|
811
|
-
warn: "#f9a002",
|
|
812
|
-
// Yellow
|
|
813
|
-
error: "#d73a49",
|
|
814
|
-
// Red
|
|
815
|
-
debug: "#586069",
|
|
816
|
-
// Gray
|
|
817
|
-
trace: "#6a737d"
|
|
818
|
-
// Gray-light
|
|
819
|
-
};
|
|
820
|
-
const minimalDarkPalette = {
|
|
821
|
-
log: "#ffffff",
|
|
822
|
-
info: "#ffffff",
|
|
823
|
-
warn: "#ffffff",
|
|
824
|
-
error: "#ffffff",
|
|
825
|
-
debug: "#ffffff",
|
|
826
|
-
trace: "#ffffff"
|
|
827
|
-
};
|
|
828
|
-
const minimalLightPalette = {
|
|
829
|
-
log: "#000000",
|
|
830
|
-
info: "#000000",
|
|
831
|
-
warn: "#000000",
|
|
832
|
-
error: "#000000",
|
|
833
|
-
debug: "#000000",
|
|
834
|
-
trace: "#000000"
|
|
835
|
-
};
|
|
836
|
-
|
|
837
|
-
const themePalettes = {
|
|
838
|
-
"catppuccin-mocha": catppuccinMochaPalette,
|
|
839
|
-
"catppuccin-latte": catppuccinLattePalette,
|
|
840
|
-
dracula: draculaPalette,
|
|
841
|
-
"github-light": githubLightPalette,
|
|
842
|
-
"minimal-dark": minimalDarkPalette,
|
|
843
|
-
"minimal-light": minimalLightPalette
|
|
844
|
-
};
|
|
845
|
-
const defaultDarkTheme = "minimal-dark";
|
|
846
|
-
const defaultLightTheme = "minimal-light";
|
|
847
|
-
function isThemeName(theme) {
|
|
848
|
-
return theme in themePalettes;
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
function determineBaseTheme(themeOpt, detectedBrowserTheme) {
|
|
852
|
-
let baseThemeName;
|
|
853
|
-
if (isThemeName(themeOpt)) {
|
|
854
|
-
baseThemeName = themeOpt;
|
|
855
|
-
} else if (themeOpt === "light") {
|
|
856
|
-
baseThemeName = defaultLightTheme;
|
|
857
|
-
} else if (themeOpt === "dark") {
|
|
858
|
-
baseThemeName = defaultDarkTheme;
|
|
859
|
-
} else {
|
|
860
|
-
baseThemeName = detectedBrowserTheme === "light" ? defaultLightTheme : defaultDarkTheme;
|
|
861
|
-
}
|
|
862
|
-
return baseThemeName;
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
export { ColorLevel as C, InputValidator as I, MyColorino as M, OscQueryError as O, determineBaseTheme as d, err as e, ok as o, themePalettes as t };
|
|
852
|
+
export { ColorLevel as C, InputValidator as I, MyColorino as M, determineBaseTheme as d, themePalettes as t };
|
|
@@ -2,10 +2,12 @@ type ConsoleMethod = 'log' | 'info' | 'warn' | 'error' | 'trace' | 'debug';
|
|
|
2
2
|
type LogLevel = ConsoleMethod & string;
|
|
3
3
|
type Palette = Record<LogLevel, string>;
|
|
4
4
|
type TerminalTheme = 'dark' | 'light' | 'unknown';
|
|
5
|
-
type ThemeName = 'catppuccin-mocha' | 'catppuccin-latte' | 'dracula' | 'github-light'
|
|
5
|
+
type ThemeName = 'catppuccin-mocha' | 'catppuccin-latte' | 'dracula' | 'github-light';
|
|
6
6
|
interface ColorinoOptions {
|
|
7
7
|
disableWarnings?: boolean;
|
|
8
8
|
theme?: TerminalTheme | ThemeName | 'auto';
|
|
9
|
+
disableOscProbe?: boolean;
|
|
10
|
+
maxDepth?: number;
|
|
9
11
|
}
|
|
10
12
|
interface Colorino {
|
|
11
13
|
log(...args: unknown[]): void;
|
|
@@ -16,7 +18,4 @@ interface Colorino {
|
|
|
16
18
|
trace(...args: unknown[]): void;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
declare const themePalettes: Record<ThemeName, Palette>;
|
|
20
|
-
|
|
21
|
-
export { themePalettes as t };
|
|
22
21
|
export type { ColorinoOptions as C, LogLevel as L, Palette as P, ThemeName as T, Colorino as a };
|
|
@@ -2,10 +2,12 @@ type ConsoleMethod = 'log' | 'info' | 'warn' | 'error' | 'trace' | 'debug';
|
|
|
2
2
|
type LogLevel = ConsoleMethod & string;
|
|
3
3
|
type Palette = Record<LogLevel, string>;
|
|
4
4
|
type TerminalTheme = 'dark' | 'light' | 'unknown';
|
|
5
|
-
type ThemeName = 'catppuccin-mocha' | 'catppuccin-latte' | 'dracula' | 'github-light'
|
|
5
|
+
type ThemeName = 'catppuccin-mocha' | 'catppuccin-latte' | 'dracula' | 'github-light';
|
|
6
6
|
interface ColorinoOptions {
|
|
7
7
|
disableWarnings?: boolean;
|
|
8
8
|
theme?: TerminalTheme | ThemeName | 'auto';
|
|
9
|
+
disableOscProbe?: boolean;
|
|
10
|
+
maxDepth?: number;
|
|
9
11
|
}
|
|
10
12
|
interface Colorino {
|
|
11
13
|
log(...args: unknown[]): void;
|
|
@@ -16,7 +18,4 @@ interface Colorino {
|
|
|
16
18
|
trace(...args: unknown[]): void;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
declare const themePalettes: Record<ThemeName, Palette>;
|
|
20
|
-
|
|
21
|
-
export { themePalettes as t };
|
|
22
21
|
export type { ColorinoOptions as C, LogLevel as L, Palette as P, ThemeName as T, Colorino as a };
|
|
@@ -2,10 +2,12 @@ type ConsoleMethod = 'log' | 'info' | 'warn' | 'error' | 'trace' | 'debug';
|
|
|
2
2
|
type LogLevel = ConsoleMethod & string;
|
|
3
3
|
type Palette = Record<LogLevel, string>;
|
|
4
4
|
type TerminalTheme = 'dark' | 'light' | 'unknown';
|
|
5
|
-
type ThemeName = 'catppuccin-mocha' | 'catppuccin-latte' | 'dracula' | 'github-light'
|
|
5
|
+
type ThemeName = 'catppuccin-mocha' | 'catppuccin-latte' | 'dracula' | 'github-light';
|
|
6
6
|
interface ColorinoOptions {
|
|
7
7
|
disableWarnings?: boolean;
|
|
8
8
|
theme?: TerminalTheme | ThemeName | 'auto';
|
|
9
|
+
disableOscProbe?: boolean;
|
|
10
|
+
maxDepth?: number;
|
|
9
11
|
}
|
|
10
12
|
interface Colorino {
|
|
11
13
|
log(...args: unknown[]): void;
|
|
@@ -16,7 +18,4 @@ interface Colorino {
|
|
|
16
18
|
trace(...args: unknown[]): void;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
declare const themePalettes: Record<ThemeName, Palette>;
|
|
20
|
-
|
|
21
|
-
export { themePalettes as t };
|
|
22
21
|
export type { ColorinoOptions as C, LogLevel as L, Palette as P, ThemeName as T, Colorino as a };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "colorino",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "A super simple colorized logger that gets the most out of your terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"husky": "^9.0.0",
|
|
76
76
|
"lint-staged": "^15.2.0",
|
|
77
77
|
"md-toc-cli": "^3.1.1",
|
|
78
|
+
"node-pty": "^1.1.0",
|
|
78
79
|
"oxfmt": "^0.9.0",
|
|
79
80
|
"oxlint": "^0.2.0",
|
|
80
81
|
"playwright": "^1.57.0",
|