colorino 0.10.1 → 0.11.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 +354 -351
- package/dist/browser.bundle.cjs +127 -116
- package/dist/browser.bundle.mjs +128 -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.BnDovC2X.mjs → colorino.BPD_4Zhq.mjs} +125 -120
- package/dist/shared/{colorino.B4p-EEl9.cjs → colorino.D9xuyiJg.cjs} +124 -122
- package/dist/shared/{colorino.DjY5jpGa.d.ts → colorino.bX_hrCT6.d.cts} +2 -3
- package/dist/shared/{colorino.DjY5jpGa.d.cts → colorino.bX_hrCT6.d.mts} +2 -3
- package/dist/shared/{colorino.DjY5jpGa.d.mts → colorino.bX_hrCT6.d.ts} +2 -3
- package/package.json +2 -1
|
@@ -61,13 +61,115 @@ 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
|
+
const minimalDarkPalette = {
|
|
121
|
+
log: "#ffffff",
|
|
122
|
+
info: "#ffffff",
|
|
123
|
+
warn: "#ffffff",
|
|
124
|
+
error: "#ffffff",
|
|
125
|
+
debug: "#ffffff",
|
|
126
|
+
trace: "#ffffff"
|
|
127
|
+
};
|
|
128
|
+
const minimalLightPalette = {
|
|
129
|
+
log: "#000000",
|
|
130
|
+
info: "#000000",
|
|
131
|
+
warn: "#000000",
|
|
132
|
+
error: "#000000",
|
|
133
|
+
debug: "#000000",
|
|
134
|
+
trace: "#000000"
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const themePalettes = {
|
|
138
|
+
"catppuccin-mocha": catppuccinMochaPalette,
|
|
139
|
+
"catppuccin-latte": catppuccinLattePalette,
|
|
140
|
+
dracula: draculaPalette,
|
|
141
|
+
"github-light": githubLightPalette,
|
|
142
|
+
"minimal-dark": minimalDarkPalette,
|
|
143
|
+
"minimal-light": minimalLightPalette
|
|
144
|
+
};
|
|
145
|
+
const defaultDarkTheme = "minimal-dark";
|
|
146
|
+
const defaultLightTheme = "minimal-light";
|
|
147
|
+
function isThemeName(theme) {
|
|
148
|
+
return theme in themePalettes;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function determineBaseTheme(themeOpt, detectedBrowserTheme) {
|
|
152
|
+
let baseThemeName;
|
|
153
|
+
if (isThemeName(themeOpt)) {
|
|
154
|
+
baseThemeName = themeOpt;
|
|
155
|
+
} else if (themeOpt === "light") {
|
|
156
|
+
baseThemeName = defaultLightTheme;
|
|
157
|
+
} else if (themeOpt === "dark") {
|
|
158
|
+
baseThemeName = defaultDarkTheme;
|
|
159
|
+
} else {
|
|
160
|
+
baseThemeName = detectedBrowserTheme === "light" ? defaultLightTheme : defaultDarkTheme;
|
|
161
|
+
}
|
|
162
|
+
return baseThemeName;
|
|
163
|
+
}
|
|
164
|
+
|
|
64
165
|
class MyColorino {
|
|
65
|
-
constructor(
|
|
66
|
-
this.
|
|
166
|
+
constructor(initialPalette, _userPalette, _validator, _browserColorSupportDetector, _nodeColorSupportDetector, _options = {}) {
|
|
167
|
+
this._userPalette = _userPalette;
|
|
67
168
|
this._validator = _validator;
|
|
68
169
|
this._browserColorSupportDetector = _browserColorSupportDetector;
|
|
69
170
|
this._nodeColorSupportDetector = _nodeColorSupportDetector;
|
|
70
171
|
this._options = _options;
|
|
172
|
+
this._palette = initialPalette;
|
|
71
173
|
this.isBrowser = !!this._browserColorSupportDetector;
|
|
72
174
|
this._colorLevel = this._detectColorSupport();
|
|
73
175
|
const validatePaletteResult = this._validator.validatePalette(this._palette);
|
|
@@ -75,10 +177,23 @@ class MyColorino {
|
|
|
75
177
|
if (this._colorLevel !== ColorLevel.NO_COLOR && !this._options.disableWarnings && this._colorLevel === "UnknownEnv") {
|
|
76
178
|
this._maybeWarnUser();
|
|
77
179
|
}
|
|
180
|
+
const themeOpt = this._options.theme ?? "auto";
|
|
181
|
+
if (themeOpt === "auto" && this._nodeColorSupportDetector) {
|
|
182
|
+
this._nodeColorSupportDetector.onTheme((resolvedTheme) => {
|
|
183
|
+
this._appllyResolvedTheme(resolvedTheme);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
78
186
|
}
|
|
79
187
|
_alreadyWarned = false;
|
|
80
188
|
_colorLevel;
|
|
81
189
|
isBrowser;
|
|
190
|
+
_palette;
|
|
191
|
+
_appllyResolvedTheme(resolvedTheme) {
|
|
192
|
+
const themeOpt = this._options.theme ?? "auto";
|
|
193
|
+
const baseThemeName = determineBaseTheme(themeOpt, resolvedTheme);
|
|
194
|
+
const basePalette = themePalettes[baseThemeName];
|
|
195
|
+
this._palette = { ...basePalette, ...this._userPalette };
|
|
196
|
+
}
|
|
82
197
|
log(...args) {
|
|
83
198
|
this._out("log", args);
|
|
84
199
|
}
|
|
@@ -110,10 +225,10 @@ class MyColorino {
|
|
|
110
225
|
if (this._alreadyWarned) return;
|
|
111
226
|
this._alreadyWarned = true;
|
|
112
227
|
console.warn(
|
|
113
|
-
"
|
|
228
|
+
"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
229
|
);
|
|
115
230
|
}
|
|
116
|
-
_formatValue(value, maxDepth = 5) {
|
|
231
|
+
_formatValue(value, maxDepth = this._options.maxDepth ?? 5) {
|
|
117
232
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
118
233
|
const sanitize = (val, currentDepth) => {
|
|
119
234
|
if (val === null || typeof val !== "object") return val;
|
|
@@ -198,7 +313,7 @@ ${arg}`);
|
|
|
198
313
|
}
|
|
199
314
|
_output(consoleMethod, args) {
|
|
200
315
|
if (consoleMethod === "trace") {
|
|
201
|
-
this._printCleanTrace(args
|
|
316
|
+
this._printCleanTrace(args);
|
|
202
317
|
} else {
|
|
203
318
|
console[consoleMethod](...args);
|
|
204
319
|
}
|
|
@@ -219,9 +334,7 @@ ${arg}`);
|
|
|
219
334
|
this._output(consoleMethod, coloredArgs);
|
|
220
335
|
}
|
|
221
336
|
_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");
|
|
337
|
+
return stack.split("\n").filter((line) => !line.match(/.*colorino.*/gi)).join("\n");
|
|
225
338
|
}
|
|
226
339
|
_cleanErrorStack(error) {
|
|
227
340
|
if (!error.stack) return error;
|
|
@@ -231,14 +344,14 @@ ${arg}`);
|
|
|
231
344
|
cloned.stack = cleanStack;
|
|
232
345
|
return cloned;
|
|
233
346
|
}
|
|
234
|
-
_printCleanTrace(args
|
|
347
|
+
_printCleanTrace(args) {
|
|
235
348
|
const error = new Error();
|
|
236
349
|
if (error.stack) {
|
|
237
350
|
const cleanStack = this._filterStack(error.stack);
|
|
238
|
-
console
|
|
351
|
+
console.log(...args, `
|
|
239
352
|
${cleanStack}`);
|
|
240
353
|
} else {
|
|
241
|
-
console
|
|
354
|
+
console.log(...args);
|
|
242
355
|
}
|
|
243
356
|
}
|
|
244
357
|
}
|
|
@@ -732,13 +845,6 @@ class ColorinoError extends Error {
|
|
|
732
845
|
Object.setPrototypeOf(this, ColorinoError.prototype);
|
|
733
846
|
}
|
|
734
847
|
}
|
|
735
|
-
class OscQueryError extends Error {
|
|
736
|
-
constructor(message) {
|
|
737
|
-
super(message);
|
|
738
|
-
this.name = "OscQueryError";
|
|
739
|
-
Object.setPrototypeOf(this, OscQueryError.prototype);
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
848
|
|
|
743
849
|
class InputValidator {
|
|
744
850
|
validateHex(hex) {
|
|
@@ -761,105 +867,4 @@ class InputValidator {
|
|
|
761
867
|
}
|
|
762
868
|
}
|
|
763
869
|
|
|
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 };
|
|
870
|
+
export { ColorLevel as C, InputValidator as I, MyColorino as M, determineBaseTheme as d, themePalettes as t };
|
|
@@ -63,13 +63,115 @@ 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
|
+
const minimalDarkPalette = {
|
|
123
|
+
log: "#ffffff",
|
|
124
|
+
info: "#ffffff",
|
|
125
|
+
warn: "#ffffff",
|
|
126
|
+
error: "#ffffff",
|
|
127
|
+
debug: "#ffffff",
|
|
128
|
+
trace: "#ffffff"
|
|
129
|
+
};
|
|
130
|
+
const minimalLightPalette = {
|
|
131
|
+
log: "#000000",
|
|
132
|
+
info: "#000000",
|
|
133
|
+
warn: "#000000",
|
|
134
|
+
error: "#000000",
|
|
135
|
+
debug: "#000000",
|
|
136
|
+
trace: "#000000"
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const themePalettes = {
|
|
140
|
+
"catppuccin-mocha": catppuccinMochaPalette,
|
|
141
|
+
"catppuccin-latte": catppuccinLattePalette,
|
|
142
|
+
dracula: draculaPalette,
|
|
143
|
+
"github-light": githubLightPalette,
|
|
144
|
+
"minimal-dark": minimalDarkPalette,
|
|
145
|
+
"minimal-light": minimalLightPalette
|
|
146
|
+
};
|
|
147
|
+
const defaultDarkTheme = "minimal-dark";
|
|
148
|
+
const defaultLightTheme = "minimal-light";
|
|
149
|
+
function isThemeName(theme) {
|
|
150
|
+
return theme in themePalettes;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function determineBaseTheme(themeOpt, detectedBrowserTheme) {
|
|
154
|
+
let baseThemeName;
|
|
155
|
+
if (isThemeName(themeOpt)) {
|
|
156
|
+
baseThemeName = themeOpt;
|
|
157
|
+
} else if (themeOpt === "light") {
|
|
158
|
+
baseThemeName = defaultLightTheme;
|
|
159
|
+
} else if (themeOpt === "dark") {
|
|
160
|
+
baseThemeName = defaultDarkTheme;
|
|
161
|
+
} else {
|
|
162
|
+
baseThemeName = detectedBrowserTheme === "light" ? defaultLightTheme : defaultDarkTheme;
|
|
163
|
+
}
|
|
164
|
+
return baseThemeName;
|
|
165
|
+
}
|
|
166
|
+
|
|
66
167
|
class MyColorino {
|
|
67
|
-
constructor(
|
|
68
|
-
this.
|
|
168
|
+
constructor(initialPalette, _userPalette, _validator, _browserColorSupportDetector, _nodeColorSupportDetector, _options = {}) {
|
|
169
|
+
this._userPalette = _userPalette;
|
|
69
170
|
this._validator = _validator;
|
|
70
171
|
this._browserColorSupportDetector = _browserColorSupportDetector;
|
|
71
172
|
this._nodeColorSupportDetector = _nodeColorSupportDetector;
|
|
72
173
|
this._options = _options;
|
|
174
|
+
this._palette = initialPalette;
|
|
73
175
|
this.isBrowser = !!this._browserColorSupportDetector;
|
|
74
176
|
this._colorLevel = this._detectColorSupport();
|
|
75
177
|
const validatePaletteResult = this._validator.validatePalette(this._palette);
|
|
@@ -77,10 +179,23 @@ class MyColorino {
|
|
|
77
179
|
if (this._colorLevel !== ColorLevel.NO_COLOR && !this._options.disableWarnings && this._colorLevel === "UnknownEnv") {
|
|
78
180
|
this._maybeWarnUser();
|
|
79
181
|
}
|
|
182
|
+
const themeOpt = this._options.theme ?? "auto";
|
|
183
|
+
if (themeOpt === "auto" && this._nodeColorSupportDetector) {
|
|
184
|
+
this._nodeColorSupportDetector.onTheme((resolvedTheme) => {
|
|
185
|
+
this._appllyResolvedTheme(resolvedTheme);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
80
188
|
}
|
|
81
189
|
_alreadyWarned = false;
|
|
82
190
|
_colorLevel;
|
|
83
191
|
isBrowser;
|
|
192
|
+
_palette;
|
|
193
|
+
_appllyResolvedTheme(resolvedTheme) {
|
|
194
|
+
const themeOpt = this._options.theme ?? "auto";
|
|
195
|
+
const baseThemeName = determineBaseTheme(themeOpt, resolvedTheme);
|
|
196
|
+
const basePalette = themePalettes[baseThemeName];
|
|
197
|
+
this._palette = { ...basePalette, ...this._userPalette };
|
|
198
|
+
}
|
|
84
199
|
log(...args) {
|
|
85
200
|
this._out("log", args);
|
|
86
201
|
}
|
|
@@ -112,10 +227,10 @@ class MyColorino {
|
|
|
112
227
|
if (this._alreadyWarned) return;
|
|
113
228
|
this._alreadyWarned = true;
|
|
114
229
|
console.warn(
|
|
115
|
-
"
|
|
230
|
+
"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
231
|
);
|
|
117
232
|
}
|
|
118
|
-
_formatValue(value, maxDepth = 5) {
|
|
233
|
+
_formatValue(value, maxDepth = this._options.maxDepth ?? 5) {
|
|
119
234
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
120
235
|
const sanitize = (val, currentDepth) => {
|
|
121
236
|
if (val === null || typeof val !== "object") return val;
|
|
@@ -200,7 +315,7 @@ ${arg}`);
|
|
|
200
315
|
}
|
|
201
316
|
_output(consoleMethod, args) {
|
|
202
317
|
if (consoleMethod === "trace") {
|
|
203
|
-
this._printCleanTrace(args
|
|
318
|
+
this._printCleanTrace(args);
|
|
204
319
|
} else {
|
|
205
320
|
console[consoleMethod](...args);
|
|
206
321
|
}
|
|
@@ -221,9 +336,7 @@ ${arg}`);
|
|
|
221
336
|
this._output(consoleMethod, coloredArgs);
|
|
222
337
|
}
|
|
223
338
|
_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");
|
|
339
|
+
return stack.split("\n").filter((line) => !line.match(/.*colorino.*/gi)).join("\n");
|
|
227
340
|
}
|
|
228
341
|
_cleanErrorStack(error) {
|
|
229
342
|
if (!error.stack) return error;
|
|
@@ -233,14 +346,14 @@ ${arg}`);
|
|
|
233
346
|
cloned.stack = cleanStack;
|
|
234
347
|
return cloned;
|
|
235
348
|
}
|
|
236
|
-
_printCleanTrace(args
|
|
349
|
+
_printCleanTrace(args) {
|
|
237
350
|
const error = new Error();
|
|
238
351
|
if (error.stack) {
|
|
239
352
|
const cleanStack = this._filterStack(error.stack);
|
|
240
|
-
console
|
|
353
|
+
console.log(...args, `
|
|
241
354
|
${cleanStack}`);
|
|
242
355
|
} else {
|
|
243
|
-
console
|
|
356
|
+
console.log(...args);
|
|
244
357
|
}
|
|
245
358
|
}
|
|
246
359
|
}
|
|
@@ -734,13 +847,6 @@ class ColorinoError extends Error {
|
|
|
734
847
|
Object.setPrototypeOf(this, ColorinoError.prototype);
|
|
735
848
|
}
|
|
736
849
|
}
|
|
737
|
-
class OscQueryError extends Error {
|
|
738
|
-
constructor(message) {
|
|
739
|
-
super(message);
|
|
740
|
-
this.name = "OscQueryError";
|
|
741
|
-
Object.setPrototypeOf(this, OscQueryError.prototype);
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
850
|
|
|
745
851
|
class InputValidator {
|
|
746
852
|
validateHex(hex) {
|
|
@@ -763,112 +869,8 @@ class InputValidator {
|
|
|
763
869
|
}
|
|
764
870
|
}
|
|
765
871
|
|
|
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
872
|
exports.ColorLevel = ColorLevel;
|
|
868
873
|
exports.InputValidator = InputValidator;
|
|
869
874
|
exports.MyColorino = MyColorino;
|
|
870
|
-
exports.OscQueryError = OscQueryError;
|
|
871
875
|
exports.determineBaseTheme = determineBaseTheme;
|
|
872
|
-
exports.err = err;
|
|
873
|
-
exports.ok = ok;
|
|
874
876
|
exports.themePalettes = themePalettes;
|
|
@@ -6,6 +6,8 @@ type ThemeName = 'catppuccin-mocha' | 'catppuccin-latte' | 'dracula' | 'github-l
|
|
|
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 };
|
|
@@ -6,6 +6,8 @@ type ThemeName = 'catppuccin-mocha' | 'catppuccin-latte' | 'dracula' | 'github-l
|
|
|
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 };
|
|
@@ -6,6 +6,8 @@ type ThemeName = 'catppuccin-mocha' | 'catppuccin-latte' | 'dracula' | 'github-l
|
|
|
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.11.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",
|