colorino 0.13.2 → 0.14.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 DELETED
@@ -1,72 +0,0 @@
1
- 'use strict';
2
-
3
- const inputValidator = require('./shared/colorino.DMgDgITw.cjs');
4
-
5
- class BrowserColorSupportDetector {
6
- constructor(_window, _navigator, _overrideTheme) {
7
- this._window = _window;
8
- this._navigator = _navigator;
9
- this._overrideTheme = _overrideTheme;
10
- }
11
- isBrowserEnv() {
12
- return !!this._window && !!this._navigator?.userAgent;
13
- }
14
- getColorLevel() {
15
- if (!this.isBrowserEnv()) {
16
- return inputValidator.ColorLevel.NO_COLOR;
17
- }
18
- const userAgent = this._navigator.userAgent.toLowerCase();
19
- if (userAgent.includes("chrome")) return inputValidator.ColorLevel.ANSI256;
20
- if (userAgent.includes("firefox")) return inputValidator.ColorLevel.ANSI256;
21
- return inputValidator.ColorLevel.ANSI256;
22
- }
23
- getTheme() {
24
- if (this._overrideTheme) {
25
- return this._overrideTheme;
26
- }
27
- if (!this.isBrowserEnv() || typeof this._window.matchMedia !== "function") {
28
- return "unknown";
29
- }
30
- if (this._window.matchMedia("(prefers-color-scheme: dark)").matches) {
31
- return "dark";
32
- }
33
- if (this._window.matchMedia("(prefers-color-scheme: light)").matches) {
34
- return "light";
35
- }
36
- return "unknown";
37
- }
38
- }
39
-
40
- function createColorino(userPalette = {}, options = {}) {
41
- const validator = new inputValidator.InputValidator();
42
- let detectorThemeOverride;
43
- if (options.theme === "dark" || options.theme === "light") {
44
- detectorThemeOverride = options.theme;
45
- }
46
- const browserDetector = new BrowserColorSupportDetector(
47
- window,
48
- navigator,
49
- detectorThemeOverride
50
- );
51
- const detectedBrowserTheme = browserDetector.getTheme();
52
- const themeOpt = options.theme ?? "auto";
53
- const baseThemeName = inputValidator.determineBaseTheme(
54
- themeOpt,
55
- detectedBrowserTheme
56
- );
57
- const basePalette = inputValidator.themePalettes[baseThemeName];
58
- const finalPalette = { ...basePalette, ...userPalette };
59
- return new inputValidator.MyColorino(
60
- finalPalette,
61
- userPalette,
62
- validator,
63
- browserDetector,
64
- void 0,
65
- options
66
- );
67
- }
68
- const colorino = createColorino();
69
-
70
- exports.themePalettes = inputValidator.themePalettes;
71
- exports.colorino = colorino;
72
- exports.createColorino = createColorino;
@@ -1,8 +0,0 @@
1
- import { P as Palette, C as ColorinoOptions, a as Colorino } from './shared/colorino.FdIbpxRG.cjs';
2
- export { L as LogLevel, T as ThemeName, t as themePalettes } from './shared/colorino.FdIbpxRG.cjs';
3
-
4
- declare function createColorino(userPalette?: Partial<Palette>, options?: ColorinoOptions): Colorino;
5
-
6
- declare const colorino: Colorino;
7
-
8
- export { Colorino, ColorinoOptions, Palette, colorino, createColorino };