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
package/dist/browser.bundle.cjs
CHANGED
|
@@ -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
|
}
|
|
@@ -756,107 +851,6 @@ class InputValidator {
|
|
|
756
851
|
}
|
|
757
852
|
}
|
|
758
853
|
|
|
759
|
-
const catppuccinMochaPalette = {
|
|
760
|
-
log: "#cdd6f4",
|
|
761
|
-
// Text
|
|
762
|
-
info: "#89b4fa",
|
|
763
|
-
// Blue
|
|
764
|
-
warn: "#f9e2af",
|
|
765
|
-
// Yellow
|
|
766
|
-
error: "#f38ba8",
|
|
767
|
-
// Red
|
|
768
|
-
debug: "#a6adc8",
|
|
769
|
-
// Subtext0
|
|
770
|
-
trace: "#9399b2"
|
|
771
|
-
// Subtext1
|
|
772
|
-
};
|
|
773
|
-
const catppuccinLattePalette = {
|
|
774
|
-
log: "#4c4f69",
|
|
775
|
-
// Text
|
|
776
|
-
info: "#1e66f5",
|
|
777
|
-
// Blue
|
|
778
|
-
warn: "#df8e1d",
|
|
779
|
-
// Yellow
|
|
780
|
-
error: "#d20f39",
|
|
781
|
-
// Red
|
|
782
|
-
debug: "#7c7f93",
|
|
783
|
-
// Subtext0
|
|
784
|
-
trace: "#8c8fa1"
|
|
785
|
-
// Subtext1
|
|
786
|
-
};
|
|
787
|
-
const draculaPalette = {
|
|
788
|
-
log: "#f8f8f2",
|
|
789
|
-
// Foreground
|
|
790
|
-
info: "#8be9fd",
|
|
791
|
-
// Cyan
|
|
792
|
-
warn: "#f1fa8c",
|
|
793
|
-
// Yellow
|
|
794
|
-
error: "#ff5555",
|
|
795
|
-
// Red
|
|
796
|
-
debug: "#bd93f9",
|
|
797
|
-
// Purple
|
|
798
|
-
trace: "#6272a4"
|
|
799
|
-
// Comment
|
|
800
|
-
};
|
|
801
|
-
const githubLightPalette = {
|
|
802
|
-
log: "#24292e",
|
|
803
|
-
// Text
|
|
804
|
-
info: "#0366d6",
|
|
805
|
-
// Blue
|
|
806
|
-
warn: "#f9a002",
|
|
807
|
-
// Yellow
|
|
808
|
-
error: "#d73a49",
|
|
809
|
-
// Red
|
|
810
|
-
debug: "#586069",
|
|
811
|
-
// Gray
|
|
812
|
-
trace: "#6a737d"
|
|
813
|
-
// Gray-light
|
|
814
|
-
};
|
|
815
|
-
const minimalDarkPalette = {
|
|
816
|
-
log: "#ffffff",
|
|
817
|
-
info: "#ffffff",
|
|
818
|
-
warn: "#ffffff",
|
|
819
|
-
error: "#ffffff",
|
|
820
|
-
debug: "#ffffff",
|
|
821
|
-
trace: "#ffffff"
|
|
822
|
-
};
|
|
823
|
-
const minimalLightPalette = {
|
|
824
|
-
log: "#000000",
|
|
825
|
-
info: "#000000",
|
|
826
|
-
warn: "#000000",
|
|
827
|
-
error: "#000000",
|
|
828
|
-
debug: "#000000",
|
|
829
|
-
trace: "#000000"
|
|
830
|
-
};
|
|
831
|
-
|
|
832
|
-
const themePalettes = {
|
|
833
|
-
"catppuccin-mocha": catppuccinMochaPalette,
|
|
834
|
-
"catppuccin-latte": catppuccinLattePalette,
|
|
835
|
-
dracula: draculaPalette,
|
|
836
|
-
"github-light": githubLightPalette,
|
|
837
|
-
"minimal-dark": minimalDarkPalette,
|
|
838
|
-
"minimal-light": minimalLightPalette
|
|
839
|
-
};
|
|
840
|
-
const defaultDarkTheme = "minimal-dark";
|
|
841
|
-
const defaultLightTheme = "minimal-light";
|
|
842
|
-
function isThemeName(theme) {
|
|
843
|
-
return theme in themePalettes;
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
function determineBaseTheme(themeOpt, detectedBrowserTheme) {
|
|
847
|
-
let baseThemeName;
|
|
848
|
-
if (isThemeName(themeOpt)) {
|
|
849
|
-
baseThemeName = themeOpt;
|
|
850
|
-
} else if (themeOpt === "light") {
|
|
851
|
-
baseThemeName = defaultLightTheme;
|
|
852
|
-
} else if (themeOpt === "dark") {
|
|
853
|
-
baseThemeName = defaultDarkTheme;
|
|
854
|
-
} else {
|
|
855
|
-
baseThemeName = detectedBrowserTheme === "light" ? defaultLightTheme : defaultDarkTheme;
|
|
856
|
-
}
|
|
857
|
-
return baseThemeName;
|
|
858
|
-
}
|
|
859
|
-
|
|
860
854
|
class BrowserColorSupportDetector {
|
|
861
855
|
constructor(_window, _navigator, _overrideTheme) {
|
|
862
856
|
this._window = _window;
|
|
@@ -892,7 +886,7 @@ class BrowserColorSupportDetector {
|
|
|
892
886
|
}
|
|
893
887
|
}
|
|
894
888
|
|
|
895
|
-
function createColorino(
|
|
889
|
+
function createColorino(userPalette = {}, options = {}) {
|
|
896
890
|
const validator = new InputValidator();
|
|
897
891
|
let detectorThemeOverride;
|
|
898
892
|
if (options.theme === "dark" || options.theme === "light") {
|
|
@@ -910,9 +904,10 @@ function createColorino(palette = {}, options = {}) {
|
|
|
910
904
|
detectedBrowserTheme
|
|
911
905
|
);
|
|
912
906
|
const basePalette = themePalettes[baseThemeName];
|
|
913
|
-
const finalPalette = { ...basePalette, ...
|
|
907
|
+
const finalPalette = { ...basePalette, ...userPalette };
|
|
914
908
|
return new MyColorino(
|
|
915
909
|
finalPalette,
|
|
910
|
+
userPalette,
|
|
916
911
|
validator,
|
|
917
912
|
browserDetector,
|
|
918
913
|
// Always use browser detector
|
|
@@ -921,8 +916,6 @@ function createColorino(palette = {}, options = {}) {
|
|
|
921
916
|
options
|
|
922
917
|
);
|
|
923
918
|
}
|
|
924
|
-
const colorino = createColorino();
|
|
925
919
|
|
|
926
|
-
exports.colorino = colorino;
|
|
927
920
|
exports.createColorino = createColorino;
|
|
928
921
|
exports.themePalettes = themePalettes;
|
package/dist/browser.bundle.mjs
CHANGED
|
@@ -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
|
}
|
|
@@ -754,107 +849,6 @@ class InputValidator {
|
|
|
754
849
|
}
|
|
755
850
|
}
|
|
756
851
|
|
|
757
|
-
const catppuccinMochaPalette = {
|
|
758
|
-
log: "#cdd6f4",
|
|
759
|
-
// Text
|
|
760
|
-
info: "#89b4fa",
|
|
761
|
-
// Blue
|
|
762
|
-
warn: "#f9e2af",
|
|
763
|
-
// Yellow
|
|
764
|
-
error: "#f38ba8",
|
|
765
|
-
// Red
|
|
766
|
-
debug: "#a6adc8",
|
|
767
|
-
// Subtext0
|
|
768
|
-
trace: "#9399b2"
|
|
769
|
-
// Subtext1
|
|
770
|
-
};
|
|
771
|
-
const catppuccinLattePalette = {
|
|
772
|
-
log: "#4c4f69",
|
|
773
|
-
// Text
|
|
774
|
-
info: "#1e66f5",
|
|
775
|
-
// Blue
|
|
776
|
-
warn: "#df8e1d",
|
|
777
|
-
// Yellow
|
|
778
|
-
error: "#d20f39",
|
|
779
|
-
// Red
|
|
780
|
-
debug: "#7c7f93",
|
|
781
|
-
// Subtext0
|
|
782
|
-
trace: "#8c8fa1"
|
|
783
|
-
// Subtext1
|
|
784
|
-
};
|
|
785
|
-
const draculaPalette = {
|
|
786
|
-
log: "#f8f8f2",
|
|
787
|
-
// Foreground
|
|
788
|
-
info: "#8be9fd",
|
|
789
|
-
// Cyan
|
|
790
|
-
warn: "#f1fa8c",
|
|
791
|
-
// Yellow
|
|
792
|
-
error: "#ff5555",
|
|
793
|
-
// Red
|
|
794
|
-
debug: "#bd93f9",
|
|
795
|
-
// Purple
|
|
796
|
-
trace: "#6272a4"
|
|
797
|
-
// Comment
|
|
798
|
-
};
|
|
799
|
-
const githubLightPalette = {
|
|
800
|
-
log: "#24292e",
|
|
801
|
-
// Text
|
|
802
|
-
info: "#0366d6",
|
|
803
|
-
// Blue
|
|
804
|
-
warn: "#f9a002",
|
|
805
|
-
// Yellow
|
|
806
|
-
error: "#d73a49",
|
|
807
|
-
// Red
|
|
808
|
-
debug: "#586069",
|
|
809
|
-
// Gray
|
|
810
|
-
trace: "#6a737d"
|
|
811
|
-
// Gray-light
|
|
812
|
-
};
|
|
813
|
-
const minimalDarkPalette = {
|
|
814
|
-
log: "#ffffff",
|
|
815
|
-
info: "#ffffff",
|
|
816
|
-
warn: "#ffffff",
|
|
817
|
-
error: "#ffffff",
|
|
818
|
-
debug: "#ffffff",
|
|
819
|
-
trace: "#ffffff"
|
|
820
|
-
};
|
|
821
|
-
const minimalLightPalette = {
|
|
822
|
-
log: "#000000",
|
|
823
|
-
info: "#000000",
|
|
824
|
-
warn: "#000000",
|
|
825
|
-
error: "#000000",
|
|
826
|
-
debug: "#000000",
|
|
827
|
-
trace: "#000000"
|
|
828
|
-
};
|
|
829
|
-
|
|
830
|
-
const themePalettes = {
|
|
831
|
-
"catppuccin-mocha": catppuccinMochaPalette,
|
|
832
|
-
"catppuccin-latte": catppuccinLattePalette,
|
|
833
|
-
dracula: draculaPalette,
|
|
834
|
-
"github-light": githubLightPalette,
|
|
835
|
-
"minimal-dark": minimalDarkPalette,
|
|
836
|
-
"minimal-light": minimalLightPalette
|
|
837
|
-
};
|
|
838
|
-
const defaultDarkTheme = "minimal-dark";
|
|
839
|
-
const defaultLightTheme = "minimal-light";
|
|
840
|
-
function isThemeName(theme) {
|
|
841
|
-
return theme in themePalettes;
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
function determineBaseTheme(themeOpt, detectedBrowserTheme) {
|
|
845
|
-
let baseThemeName;
|
|
846
|
-
if (isThemeName(themeOpt)) {
|
|
847
|
-
baseThemeName = themeOpt;
|
|
848
|
-
} else if (themeOpt === "light") {
|
|
849
|
-
baseThemeName = defaultLightTheme;
|
|
850
|
-
} else if (themeOpt === "dark") {
|
|
851
|
-
baseThemeName = defaultDarkTheme;
|
|
852
|
-
} else {
|
|
853
|
-
baseThemeName = detectedBrowserTheme === "light" ? defaultLightTheme : defaultDarkTheme;
|
|
854
|
-
}
|
|
855
|
-
return baseThemeName;
|
|
856
|
-
}
|
|
857
|
-
|
|
858
852
|
class BrowserColorSupportDetector {
|
|
859
853
|
constructor(_window, _navigator, _overrideTheme) {
|
|
860
854
|
this._window = _window;
|
|
@@ -890,7 +884,7 @@ class BrowserColorSupportDetector {
|
|
|
890
884
|
}
|
|
891
885
|
}
|
|
892
886
|
|
|
893
|
-
function createColorino(
|
|
887
|
+
function createColorino(userPalette = {}, options = {}) {
|
|
894
888
|
const validator = new InputValidator();
|
|
895
889
|
let detectorThemeOverride;
|
|
896
890
|
if (options.theme === "dark" || options.theme === "light") {
|
|
@@ -908,9 +902,10 @@ function createColorino(palette = {}, options = {}) {
|
|
|
908
902
|
detectedBrowserTheme
|
|
909
903
|
);
|
|
910
904
|
const basePalette = themePalettes[baseThemeName];
|
|
911
|
-
const finalPalette = { ...basePalette, ...
|
|
905
|
+
const finalPalette = { ...basePalette, ...userPalette };
|
|
912
906
|
return new MyColorino(
|
|
913
907
|
finalPalette,
|
|
908
|
+
userPalette,
|
|
914
909
|
validator,
|
|
915
910
|
browserDetector,
|
|
916
911
|
// Always use browser detector
|
|
@@ -919,6 +914,5 @@ function createColorino(palette = {}, options = {}) {
|
|
|
919
914
|
options
|
|
920
915
|
);
|
|
921
916
|
}
|
|
922
|
-
const colorino = createColorino();
|
|
923
917
|
|
|
924
|
-
export {
|
|
918
|
+
export { createColorino, themePalettes };
|
package/dist/browser.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const inputValidator = require('./shared/colorino.BgxwS1Lc.cjs');
|
|
4
4
|
|
|
5
5
|
class BrowserColorSupportDetector {
|
|
6
6
|
constructor(_window, _navigator, _overrideTheme) {
|
|
@@ -13,12 +13,12 @@ class BrowserColorSupportDetector {
|
|
|
13
13
|
}
|
|
14
14
|
getColorLevel() {
|
|
15
15
|
if (!this.isBrowserEnv()) {
|
|
16
|
-
return
|
|
16
|
+
return inputValidator.ColorLevel.NO_COLOR;
|
|
17
17
|
}
|
|
18
18
|
const userAgent = this._navigator.userAgent.toLowerCase();
|
|
19
|
-
if (userAgent.includes("chrome")) return
|
|
20
|
-
if (userAgent.includes("firefox")) return
|
|
21
|
-
return
|
|
19
|
+
if (userAgent.includes("chrome")) return inputValidator.ColorLevel.ANSI256;
|
|
20
|
+
if (userAgent.includes("firefox")) return inputValidator.ColorLevel.ANSI256;
|
|
21
|
+
return inputValidator.ColorLevel.ANSI256;
|
|
22
22
|
}
|
|
23
23
|
getTheme() {
|
|
24
24
|
if (this._overrideTheme) {
|
|
@@ -37,8 +37,8 @@ class BrowserColorSupportDetector {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
function createColorino(
|
|
41
|
-
const validator = new
|
|
40
|
+
function createColorino(userPalette = {}, options = {}) {
|
|
41
|
+
const validator = new inputValidator.InputValidator();
|
|
42
42
|
let detectorThemeOverride;
|
|
43
43
|
if (options.theme === "dark" || options.theme === "light") {
|
|
44
44
|
detectorThemeOverride = options.theme;
|
|
@@ -50,14 +50,15 @@ function createColorino(palette = {}, options = {}) {
|
|
|
50
50
|
);
|
|
51
51
|
const detectedBrowserTheme = browserDetector.getTheme();
|
|
52
52
|
const themeOpt = options.theme ?? "auto";
|
|
53
|
-
const baseThemeName =
|
|
53
|
+
const baseThemeName = inputValidator.determineBaseTheme(
|
|
54
54
|
themeOpt,
|
|
55
55
|
detectedBrowserTheme
|
|
56
56
|
);
|
|
57
|
-
const basePalette =
|
|
58
|
-
const finalPalette = { ...basePalette, ...
|
|
59
|
-
return new
|
|
57
|
+
const basePalette = inputValidator.themePalettes[baseThemeName];
|
|
58
|
+
const finalPalette = { ...basePalette, ...userPalette };
|
|
59
|
+
return new inputValidator.MyColorino(
|
|
60
60
|
finalPalette,
|
|
61
|
+
userPalette,
|
|
61
62
|
validator,
|
|
62
63
|
browserDetector,
|
|
63
64
|
// Always use browser detector
|
|
@@ -66,8 +67,6 @@ function createColorino(palette = {}, options = {}) {
|
|
|
66
67
|
options
|
|
67
68
|
);
|
|
68
69
|
}
|
|
69
|
-
const colorino = createColorino();
|
|
70
70
|
|
|
71
|
-
exports.themePalettes =
|
|
72
|
-
exports.colorino = colorino;
|
|
71
|
+
exports.themePalettes = inputValidator.themePalettes;
|
|
73
72
|
exports.createColorino = createColorino;
|
package/dist/browser.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.
|
|
2
|
-
export { L as LogLevel
|
|
1
|
+
import { T as ThemeName, P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.Dh_05jaQ.cjs';
|
|
2
|
+
export { L as LogLevel } from './shared/colorino.Dh_05jaQ.cjs';
|
|
3
3
|
|
|
4
|
-
declare
|
|
4
|
+
declare const themePalettes: Record<ThemeName, Palette>;
|
|
5
5
|
|
|
6
|
-
declare
|
|
6
|
+
declare function createColorino(userPalette?: Partial<Palette>, options?: ColorinoOptions): Colorino;
|
|
7
7
|
|
|
8
|
-
export { Colorino, ColorinoOptions, Palette,
|
|
8
|
+
export { Colorino, ColorinoOptions, Palette, ThemeName, createColorino, themePalettes };
|