@jacob-z/chalk 1.1.0 → 2.0.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 +72 -31
- package/dist/index.cjs +60 -99
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -11
- package/dist/index.d.mts +6 -11
- package/dist/index.mjs +60 -97
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
# @jacob-z/chalk
|
|
2
2
|
|
|
3
|
-
Browser console coloring utilities — a modular, type-safe rewrite of `@alita/chalk`, themed with [Catppuccin
|
|
3
|
+
Browser console coloring utilities — a modular, type-safe rewrite of `@alita/chalk`, themed with [Catppuccin Macchiato](https://catppuccin.com/palette/).
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- `%c` CSS tuple formatters for browser DevTools console output
|
|
8
8
|
- 9 foreground colors: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`, `gray`
|
|
9
9
|
- 8 background colors: `bgBlack`, `bgRed`, `bgGreen`, `bgYellow`, `bgBlue`, `bgMagenta`, `bgCyan`, `bgWhite`
|
|
10
|
-
-
|
|
10
|
+
- Mode switching (`foreground` / `background`) controls logger output style globally
|
|
11
11
|
- `bold()` text formatting
|
|
12
12
|
- `add()` for merging multiple formatted tuples
|
|
13
13
|
- Debug-gated logger methods: `log`, `wait`, `error`, `warn`, `ready`, `info`, `event`, `debug`
|
|
14
14
|
- `hello(title, version)` version banner
|
|
15
15
|
- `image(url)` console image
|
|
16
|
-
- `createChalk(options?)` factory for dependency injection
|
|
16
|
+
- `createChalk(options?)` factory for dependency injection
|
|
17
17
|
- Zero runtime dependencies, fully tree-shakeable
|
|
18
18
|
|
|
19
19
|
## Install
|
|
@@ -30,19 +30,16 @@ Color formatters return `console.log`-ready tuples:
|
|
|
30
30
|
import chalk from '@jacob-z/chalk'
|
|
31
31
|
|
|
32
32
|
chalk.red('text')
|
|
33
|
-
// → ['%ctext', 'color:#
|
|
34
|
-
|
|
35
|
-
chalk.yellow('text')
|
|
36
|
-
// → ['%ctext', 'color:#f9e2af;background:rgba(0,0,0,0.15);padding:0 2px;border-radius:2px']
|
|
33
|
+
// → ['%ctext', 'color:#ed8796']
|
|
37
34
|
|
|
38
35
|
chalk.bgRed('text')
|
|
39
|
-
// → ['%ctext', 'padding: 2px 4px; border-radius: 3px; color: #
|
|
36
|
+
// → ['%ctext', 'padding: 2px 4px; border-radius: 3px; color: #24273a; font-weight: bold; background:#ed8796;']
|
|
40
37
|
|
|
41
38
|
chalk.bold('text')
|
|
42
39
|
// → ['%ctext', 'font-weight: bold;']
|
|
43
40
|
|
|
44
41
|
chalk.add(chalk.red('a'), chalk.blue('b'))
|
|
45
|
-
// → [' %ca %cb', 'color:#
|
|
42
|
+
// → [' %ca %cb', 'color:#ed8796', 'color:#8aadf4']
|
|
46
43
|
```
|
|
47
44
|
|
|
48
45
|
Use with `console.log` spread:
|
|
@@ -52,6 +49,35 @@ console.log(...chalk.red('colored text'))
|
|
|
52
49
|
console.log(...chalk.add(chalk.red('error:'), chalk.bold(' not found')))
|
|
53
50
|
```
|
|
54
51
|
|
|
52
|
+
### Foreground vs Background Methods
|
|
53
|
+
|
|
54
|
+
- **Foreground** (`red`, `green`, `blue`, …) — pure `color:<hex>`, no background or padding
|
|
55
|
+
- **Background** (`bgRed`, `bgGreen`, `bgBlue`, …) — `background:<hex>; color:#24273a; font-weight: bold; padding: 2px 4px; border-radius: 3px;`
|
|
56
|
+
- **bgBlack** special case — dark base background with blue text `#8aadf4`
|
|
57
|
+
|
|
58
|
+
These are fixed regardless of the `mode` setting. Mode only affects logger output.
|
|
59
|
+
|
|
60
|
+
## Mode Switching
|
|
61
|
+
|
|
62
|
+
`createChalk({ mode })` controls how logger methods render. Default is `'background'`.
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import { createChalk } from '@jacob-z/chalk'
|
|
66
|
+
|
|
67
|
+
const bgChalk = createChalk({ console, mode: 'background', isDebug: true })
|
|
68
|
+
const fgChalk = createChalk({ console, mode: 'foreground', isDebug: true })
|
|
69
|
+
|
|
70
|
+
// background mode: label + message share same styled background
|
|
71
|
+
bgChalk.info('loaded')
|
|
72
|
+
// → %c[Info]%c loaded (both segments use background style)
|
|
73
|
+
|
|
74
|
+
// foreground mode: label + message share same foreground color
|
|
75
|
+
fgChalk.info('loaded')
|
|
76
|
+
// → %c[Info]%c loaded (both segments use color:<hex> only)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Logger label and message body use the **same style** — no separate styling for the tag vs the content.
|
|
80
|
+
|
|
55
81
|
## Debug Logging
|
|
56
82
|
|
|
57
83
|
Logger methods only print when debugging is enabled. By default they read `globalThis.alitadebug`:
|
|
@@ -87,33 +113,23 @@ chalk.info('loaded')
|
|
|
87
113
|
|
|
88
114
|
If a console method is unavailable, the logger falls back to `console.log`.
|
|
89
115
|
|
|
90
|
-
## Custom Colors
|
|
91
|
-
|
|
92
|
-
```ts
|
|
93
|
-
import { createChalk } from '@jacob-z/chalk'
|
|
94
|
-
|
|
95
|
-
const chalk = createChalk({
|
|
96
|
-
colors: { brand: '#123456' },
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
chalk.color('brand', 'Brand text') // → ['%cBrand text', 'color:#123456']
|
|
100
|
-
chalk.bgColor('brand', 'Brand block') // → background with custom color
|
|
101
|
-
```
|
|
102
|
-
|
|
103
116
|
## Custom Log Levels
|
|
104
117
|
|
|
118
|
+
Extend the logger with additional methods using built-in color names:
|
|
119
|
+
|
|
105
120
|
```ts
|
|
106
121
|
const chalk = createChalk({
|
|
107
122
|
isDebug: true,
|
|
108
|
-
colors: { trace: '#123456' },
|
|
109
123
|
logLevels: [
|
|
110
|
-
{ name: 'trace', label: 'Trace', color: '
|
|
124
|
+
{ name: 'trace', label: 'Trace', color: 'blue', method: 'debug' },
|
|
111
125
|
],
|
|
112
126
|
})
|
|
113
127
|
|
|
114
|
-
chalk.trace('details') // → [Trace] in
|
|
128
|
+
chalk.trace('details') // → [Trace] in blue via console.debug
|
|
115
129
|
```
|
|
116
130
|
|
|
131
|
+
`color` must be a built-in `ColorName`: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`, `gray`.
|
|
132
|
+
|
|
117
133
|
## Banner & Image
|
|
118
134
|
|
|
119
135
|
```ts
|
|
@@ -121,14 +137,39 @@ chalk.hello('MyApp', '1.0.0') // styled title + version banner
|
|
|
121
137
|
chalk.image('https://example.com/logo.png') // console CSS background image
|
|
122
138
|
```
|
|
123
139
|
|
|
140
|
+
## API
|
|
141
|
+
|
|
142
|
+
### `createChalk(options?)`
|
|
143
|
+
|
|
144
|
+
| Option | Type | Default | Description |
|
|
145
|
+
| ------------ | --------------------------- | ------------------------------- | ------------------------------------- |
|
|
146
|
+
| `console` | `Console` | `globalThis.console` | Console instance for output |
|
|
147
|
+
| `isDebug` | `boolean \| (() => boolean)`| `() => globalThis.alitadebug` | Debug gate for logger methods |
|
|
148
|
+
| `mode` | `'foreground' \| 'background'` | `'background'` | Logger output style |
|
|
149
|
+
| `logLevels` | `LogLevelDefinition[]` | (built-in 8 levels) | Custom logger level definitions |
|
|
150
|
+
|
|
151
|
+
### `getStyle(colors, name, mode)`
|
|
152
|
+
|
|
153
|
+
Low-level utility to get CSS style string for a given color name and mode:
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
import { getStyle, DEFAULT_COLORS } from '@jacob-z/chalk'
|
|
157
|
+
|
|
158
|
+
getStyle(DEFAULT_COLORS, 'red', 'foreground')
|
|
159
|
+
// → 'color:#ed8796'
|
|
160
|
+
|
|
161
|
+
getStyle(DEFAULT_COLORS, 'red', 'background')
|
|
162
|
+
// → 'padding: 2px 4px; border-radius: 3px; color: #24273a; font-weight: bold; background:#ed8796;'
|
|
163
|
+
```
|
|
164
|
+
|
|
124
165
|
## Architecture
|
|
125
166
|
|
|
126
167
|
```
|
|
127
168
|
src/
|
|
128
|
-
types.ts → All public & internal types
|
|
129
|
-
colors.ts →
|
|
130
|
-
format.ts → %c format helpers, add(), bold()
|
|
131
|
-
logger.ts → Debug-gated logger factory
|
|
169
|
+
types.ts → All public & internal types (ChalkMode, ColorName, LogLevelDefinition)
|
|
170
|
+
colors.ts → Macchiato palette, getStyle() (pure functions)
|
|
171
|
+
format.ts → %c format helpers, add(), bold(), coloredText()
|
|
172
|
+
logger.ts → Debug-gated logger factory (mode-aware)
|
|
132
173
|
banner.ts → hello(), image()
|
|
133
174
|
create.ts → createChalk() factory
|
|
134
175
|
index.ts → Default instance + re-exports
|
|
@@ -140,8 +181,8 @@ Design principles vs the original `@alita/chalk`:
|
|
|
140
181
|
- **No global cache** — no `window.chalk` mutation
|
|
141
182
|
- **No module-level side effects** — factory pattern, pure functions
|
|
142
183
|
- **No `any` / `@ts-ignore`** — strict TypeScript throughout
|
|
143
|
-
- **
|
|
144
|
-
- **Dark-mode friendly** —
|
|
184
|
+
- **Mode-driven styling** — single `mode` option controls all logger output
|
|
185
|
+
- **Dark-mode friendly** — Catppuccin Macchiato palette with proper contrast
|
|
145
186
|
|
|
146
187
|
## License
|
|
147
188
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,69 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
|
|
3
|
-
//#region src/colors.ts
|
|
4
|
-
/**
|
|
5
|
-
* Catppuccin Mocha palette — https://catppuccin.com/palette/
|
|
6
|
-
*/
|
|
7
|
-
const DEFAULT_COLORS = {
|
|
8
|
-
black: "#1e1e2e",
|
|
9
|
-
red: "#f38ba8",
|
|
10
|
-
green: "#a6e3a1",
|
|
11
|
-
yellow: "#f9e2af",
|
|
12
|
-
blue: "#89b4fa",
|
|
13
|
-
magenta: "#cba6f7",
|
|
14
|
-
cyan: "#94e2d5",
|
|
15
|
-
white: "#cdd6f4",
|
|
16
|
-
gray: "#6c7086"
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Colors that are dark enough to not need a background on dark consoles.
|
|
20
|
-
* All other built-in Catppuccin Mocha colors are pastel and need a subtle bg.
|
|
21
|
-
*/
|
|
22
|
-
const DARK_FG_COLORS = {
|
|
23
|
-
black: true,
|
|
24
|
-
gray: true
|
|
25
|
-
};
|
|
26
|
-
function createColorMap(customColors = {}) {
|
|
27
|
-
return {
|
|
28
|
-
...DEFAULT_COLORS,
|
|
29
|
-
...customColors
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function resolveColor(colors, name) {
|
|
33
|
-
const color$2 = colors[name];
|
|
34
|
-
if (color$2 === void 0) throw new Error(`Unknown chalk color: ${name}`);
|
|
35
|
-
return color$2;
|
|
36
|
-
}
|
|
37
|
-
/** Returns true when the color is bright enough to need a background in dark consoles. */
|
|
38
|
-
function needsBackground(colors, name) {
|
|
39
|
-
if (DARK_FG_COLORS[name]) return false;
|
|
40
|
-
const hex = colors[name];
|
|
41
|
-
if (!hex) return true;
|
|
42
|
-
return getRelativeLuminance(hex) > .18;
|
|
43
|
-
}
|
|
44
|
-
function getRelativeLuminance(hex) {
|
|
45
|
-
const h = hex.replace("#", "");
|
|
46
|
-
const r = Number.parseInt(h.slice(0, 2), 16) / 255;
|
|
47
|
-
const g = Number.parseInt(h.slice(2, 4), 16) / 255;
|
|
48
|
-
const b = Number.parseInt(h.slice(4, 6), 16) / 255;
|
|
49
|
-
return .2126 * r + .7152 * g + .0722 * b;
|
|
50
|
-
}
|
|
51
|
-
function getForegroundStyle(colors, name) {
|
|
52
|
-
const parts = [`color:${resolveColor(colors, name)}`];
|
|
53
|
-
if (needsBackground(colors, name)) parts.push("background:rgba(0,0,0,0.15)", "padding:0 2px", "border-radius:2px");
|
|
54
|
-
return parts.join(";");
|
|
55
|
-
}
|
|
56
|
-
function getBackgroundStyle(colors, name) {
|
|
57
|
-
return `padding: 2px 4px; border-radius: 3px; color: #1e1e2e; font-weight: bold; background:${resolveColor(colors, name)};`;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
//#endregion
|
|
61
3
|
//#region src/banner.ts
|
|
62
4
|
function createBannerMethods(consoleLike, isDebug) {
|
|
63
5
|
return {
|
|
64
6
|
hello(title, version) {
|
|
65
7
|
if (!isDebug()) return;
|
|
66
|
-
consoleLike.log(`%c ${title} %c V${version} `, "padding: 2px 1px; border-radius: 3px 0 0 3px; color: #
|
|
8
|
+
consoleLike.log(`%c ${title} %c V${version} `, "padding: 2px 1px; border-radius: 3px 0 0 3px; color: #cad3f5; background: #494d64; font-weight: bold;", "padding: 2px 1px; border-radius: 0 3px 3px 0; color: #24273a; background: #a6da95; font-weight: bold;");
|
|
67
9
|
},
|
|
68
10
|
image(url) {
|
|
69
11
|
if (!url) return;
|
|
@@ -73,16 +15,45 @@ function createBannerMethods(consoleLike, isDebug) {
|
|
|
73
15
|
};
|
|
74
16
|
}
|
|
75
17
|
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/colors.ts
|
|
20
|
+
/**
|
|
21
|
+
* Catppuccin Macchiato palette — https://catppuccin.com/palette/
|
|
22
|
+
*/
|
|
23
|
+
const DEFAULT_COLORS = {
|
|
24
|
+
black: "#24273a",
|
|
25
|
+
red: "#ed8796",
|
|
26
|
+
green: "#a6da95",
|
|
27
|
+
yellow: "#eed49f",
|
|
28
|
+
blue: "#8aadf4",
|
|
29
|
+
magenta: "#c6a0f6",
|
|
30
|
+
cyan: "#8bd5ca",
|
|
31
|
+
white: "#cad3f5",
|
|
32
|
+
gray: "#6e738d"
|
|
33
|
+
};
|
|
34
|
+
function resolveColor(colors, name) {
|
|
35
|
+
const color = colors[name];
|
|
36
|
+
if (color === void 0) throw new Error(`Unknown chalk color: ${name}`);
|
|
37
|
+
return color;
|
|
38
|
+
}
|
|
39
|
+
function getForegroundStyle(colors, name) {
|
|
40
|
+
return `color:${resolveColor(colors, name)}`;
|
|
41
|
+
}
|
|
42
|
+
function getBackgroundStyle(colors, name) {
|
|
43
|
+
const hex = resolveColor(colors, name);
|
|
44
|
+
return `padding: 2px 4px; border-radius: 3px; color: ${name === "black" ? colors.blue ?? "#8aadf4" : "#24273a"}; font-weight: bold; background:${hex};`;
|
|
45
|
+
}
|
|
46
|
+
function getStyle(colors, name, mode) {
|
|
47
|
+
return mode === "background" ? getBackgroundStyle(colors, name) : getForegroundStyle(colors, name);
|
|
48
|
+
}
|
|
49
|
+
|
|
76
50
|
//#endregion
|
|
77
51
|
//#region src/format.ts
|
|
78
52
|
function formatText(text, style) {
|
|
79
53
|
return [`%c${text}`, style];
|
|
80
54
|
}
|
|
81
|
-
function
|
|
82
|
-
return formatText(text,
|
|
83
|
-
}
|
|
84
|
-
function bgColor$1(colors, name, text) {
|
|
85
|
-
return formatText(text, getBackgroundStyle(colors, name));
|
|
55
|
+
function coloredText(name, text, mode) {
|
|
56
|
+
return formatText(text, getStyle(DEFAULT_COLORS, name, mode));
|
|
86
57
|
}
|
|
87
58
|
function bold(text) {
|
|
88
59
|
return formatText(text, "font-weight: bold;");
|
|
@@ -147,14 +118,13 @@ const DEFAULT_LOG_LEVELS = [
|
|
|
147
118
|
function getConsoleMethod(consoleLike, method) {
|
|
148
119
|
return consoleLike[method] ?? consoleLike.log;
|
|
149
120
|
}
|
|
150
|
-
function createLogMethod(consoleLike,
|
|
121
|
+
function createLogMethod(consoleLike, isDebug, level, mode, getHooks) {
|
|
151
122
|
return (message, ...args) => {
|
|
152
123
|
const debugValue = isDebug();
|
|
153
124
|
if (debugValue) {
|
|
154
125
|
const method = getConsoleMethod(consoleLike, level.method);
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
method(`%c[${level.label}]%c ${message}`, labelStyle, messageStyle, ...args);
|
|
126
|
+
const style = getStyle(DEFAULT_COLORS, level.color, mode);
|
|
127
|
+
method(`%c[${level.label}]%c ${message}`, style, style, ...args);
|
|
158
128
|
}
|
|
159
129
|
const hooks = getHooks();
|
|
160
130
|
if (hooks.length > 0) {
|
|
@@ -171,7 +141,7 @@ function createLogMethod(consoleLike, colors, isDebug, level, getHooks) {
|
|
|
171
141
|
}
|
|
172
142
|
function createLoggerMethods(options) {
|
|
173
143
|
const levels = options.logLevels ?? DEFAULT_LOG_LEVELS;
|
|
174
|
-
return Object.fromEntries(levels.map((level) => [level.name, createLogMethod(options.console, options.
|
|
144
|
+
return Object.fromEntries(levels.map((level) => [level.name, createLogMethod(options.console, options.isDebug, level, options.mode, options.getHooks)]));
|
|
175
145
|
}
|
|
176
146
|
|
|
177
147
|
//#endregion
|
|
@@ -190,40 +160,40 @@ function resolveDebugPredicate(isDebug) {
|
|
|
190
160
|
}
|
|
191
161
|
function createChalk(options = {}) {
|
|
192
162
|
const consoleLike = resolveConsole(options.console);
|
|
193
|
-
const
|
|
163
|
+
const mode = options.mode ?? "background";
|
|
194
164
|
const isDebug = resolveDebugPredicate(options.isDebug);
|
|
195
165
|
const banner = createBannerMethods(consoleLike, isDebug);
|
|
196
166
|
const hooks = [];
|
|
197
167
|
const getHooks = () => hooks;
|
|
198
168
|
const loggers = createLoggerMethods({
|
|
199
169
|
console: consoleLike,
|
|
200
|
-
|
|
170
|
+
mode,
|
|
201
171
|
isDebug,
|
|
202
172
|
logLevels: options.logLevels,
|
|
203
173
|
getHooks
|
|
204
174
|
});
|
|
175
|
+
const fg = (name) => (text) => coloredText(name, text, "foreground");
|
|
176
|
+
const bg = (name) => (text) => coloredText(name, text, "background");
|
|
205
177
|
const instance = {
|
|
206
178
|
add,
|
|
207
179
|
bold,
|
|
208
180
|
...banner,
|
|
209
|
-
black: (
|
|
210
|
-
red: (
|
|
211
|
-
green: (
|
|
212
|
-
yellow: (
|
|
213
|
-
blue: (
|
|
214
|
-
magenta: (
|
|
215
|
-
cyan: (
|
|
216
|
-
white: (
|
|
217
|
-
bgBlack: (
|
|
218
|
-
bgRed: (
|
|
219
|
-
bgGreen: (
|
|
220
|
-
bgYellow: (
|
|
221
|
-
bgBlue: (
|
|
222
|
-
bgMagenta: (
|
|
223
|
-
bgCyan: (
|
|
224
|
-
bgWhite: (
|
|
225
|
-
color: (name, text) => color$1(colors, name, text),
|
|
226
|
-
bgColor: (name, text) => bgColor$1(colors, name, text),
|
|
181
|
+
black: fg("black"),
|
|
182
|
+
red: fg("red"),
|
|
183
|
+
green: fg("green"),
|
|
184
|
+
yellow: fg("yellow"),
|
|
185
|
+
blue: fg("blue"),
|
|
186
|
+
magenta: fg("magenta"),
|
|
187
|
+
cyan: fg("cyan"),
|
|
188
|
+
white: fg("white"),
|
|
189
|
+
bgBlack: bg("black"),
|
|
190
|
+
bgRed: bg("red"),
|
|
191
|
+
bgGreen: bg("green"),
|
|
192
|
+
bgYellow: bg("yellow"),
|
|
193
|
+
bgBlue: bg("blue"),
|
|
194
|
+
bgMagenta: bg("magenta"),
|
|
195
|
+
bgCyan: bg("cyan"),
|
|
196
|
+
bgWhite: bg("white"),
|
|
227
197
|
log: loggers.log,
|
|
228
198
|
wait: loggers.wait,
|
|
229
199
|
error: loggers.error,
|
|
@@ -242,27 +212,18 @@ function createChalk(options = {}) {
|
|
|
242
212
|
|
|
243
213
|
//#endregion
|
|
244
214
|
//#region src/index.ts
|
|
245
|
-
const defaultColors = createColorMap();
|
|
246
215
|
const chalk = createChalk();
|
|
247
|
-
function color(name, text) {
|
|
248
|
-
return color$1(defaultColors, name, text);
|
|
249
|
-
}
|
|
250
|
-
function bgColor(name, text) {
|
|
251
|
-
return bgColor$1(defaultColors, name, text);
|
|
252
|
-
}
|
|
253
216
|
var src_default = chalk;
|
|
254
217
|
|
|
255
218
|
//#endregion
|
|
256
219
|
exports.DEFAULT_COLORS = DEFAULT_COLORS;
|
|
257
220
|
exports.add = add;
|
|
258
|
-
exports.bgColor = bgColor;
|
|
259
221
|
exports.bold = bold;
|
|
260
222
|
exports.chalk = chalk;
|
|
261
|
-
exports.color = color;
|
|
262
223
|
exports.createChalk = createChalk;
|
|
263
|
-
exports.createColorMap = createColorMap;
|
|
264
224
|
exports.default = src_default;
|
|
265
225
|
exports.getBackgroundStyle = getBackgroundStyle;
|
|
266
226
|
exports.getForegroundStyle = getForegroundStyle;
|
|
227
|
+
exports.getStyle = getStyle;
|
|
267
228
|
exports.resolveColor = resolveColor;
|
|
268
229
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["DEFAULT_COLORS: ColorMap","DARK_FG_COLORS: Record<string, true>","color","color","bgColor","ctx: LogHookContext","noopConsole: ConsoleLike","hooks: LogHook[]","instance: ChalkInstance","color","bgColor","colorWithMap","bgColorWithMap"],"sources":["../src/colors.ts","../src/banner.ts","../src/format.ts","../src/logger.ts","../src/create.ts","../src/index.ts"],"sourcesContent":["import type { ColorMap, CustomColorMap } from './types'\n\n/**\n * Catppuccin Mocha palette — https://catppuccin.com/palette/\n */\nexport const DEFAULT_COLORS: ColorMap = {\n black: '#1e1e2e', // Base\n red: '#f38ba8', // Red\n green: '#a6e3a1', // Green\n yellow: '#f9e2af', // Yellow\n blue: '#89b4fa', // Blue\n magenta: '#cba6f7', // Mauve\n cyan: '#94e2d5', // Teal\n white: '#cdd6f4', // Text\n gray: '#6c7086', // Overlay0\n}\n\n/**\n * Colors that are dark enough to not need a background on dark consoles.\n * All other built-in Catppuccin Mocha colors are pastel and need a subtle bg.\n */\nexport const DARK_FG_COLORS: Record<string, true> = { black: true, gray: true }\n\nexport type ResolvedColorMap = Readonly<ColorMap & CustomColorMap>\n\nexport function createColorMap(customColors: CustomColorMap = {} as CustomColorMap): ResolvedColorMap {\n return {\n ...DEFAULT_COLORS,\n ...customColors,\n }\n}\n\nexport function resolveColor(colors: Readonly<Record<string, string>>, name: string): string {\n const color = colors[name]\n if (color === undefined)\n throw new Error(`Unknown chalk color: ${name}`)\n return color\n}\n\n/** Returns true when the color is bright enough to need a background in dark consoles. */\nfunction needsBackground(colors: Readonly<Record<string, string>>, name: string): boolean {\n if (DARK_FG_COLORS[name])\n return false\n const hex = colors[name]\n if (!hex)\n return true\n return getRelativeLuminance(hex) > 0.18\n}\n\nfunction getRelativeLuminance(hex: string): number {\n const h = hex.replace('#', '')\n const r = Number.parseInt(h.slice(0, 2), 16) / 255\n const g = Number.parseInt(h.slice(2, 4), 16) / 255\n const b = Number.parseInt(h.slice(4, 6), 16) / 255\n return 0.2126 * r + 0.7152 * g + 0.0722 * b\n}\n\nexport function getForegroundStyle(colors: Readonly<Record<string, string>>, name: string): string {\n const hex = resolveColor(colors, name)\n const parts = [`color:${hex}`]\n if (needsBackground(colors, name))\n parts.push('background:rgba(0,0,0,0.15)', 'padding:0 2px', 'border-radius:2px')\n return parts.join(';')\n}\n\nexport function getBackgroundStyle(colors: Readonly<Record<string, string>>, name: string): string {\n const hex = resolveColor(colors, name)\n const textColor = '#1e1e2e'\n return `padding: 2px 4px; border-radius: 3px; color: ${textColor}; font-weight: bold; background:${hex};`\n}\n","import type { ConsoleLike, DebugPredicate } from './types'\n\nexport interface BannerMethods {\n hello: (title: string, version: string) => void\n image: (url: string) => void\n}\n\nexport function createBannerMethods(consoleLike: ConsoleLike, isDebug: DebugPredicate): BannerMethods {\n return {\n hello(title: string, version: string): void {\n if (!isDebug())\n return\n consoleLike.log(\n `%c ${title} %c V${version} `,\n 'padding: 2px 1px; border-radius: 3px 0 0 3px; color: #cdd6f4; background: #45475a; font-weight: bold;',\n 'padding: 2px 1px; border-radius: 0 3px 3px 0; color: #1e1e2e; background: #a6e3a1; font-weight: bold;',\n )\n },\n image(url: string): void {\n if (!url)\n return\n if (!isDebug())\n return\n consoleLike.log(\n '%c ',\n `font-size: 1px; padding: 100px 100px; background: url(${url}) no-repeat center / contain; color: transparent;`,\n )\n },\n }\n}\n","import type { FormattedText } from './types'\nimport { getBackgroundStyle, getForegroundStyle } from './colors'\n\nexport function formatText(text: string, style: string): FormattedText {\n return [`%c${text}`, style]\n}\n\nexport function color(colors: Readonly<Record<string, string>>, name: string, text: string): FormattedText {\n return formatText(text, getForegroundStyle(colors, name))\n}\n\nexport function bgColor(colors: Readonly<Record<string, string>>, name: string, text: string): FormattedText {\n return formatText(text, getBackgroundStyle(colors, name))\n}\n\nexport function bold(text: string): FormattedText {\n return formatText(text, 'font-weight: bold;')\n}\n\nexport function add(...items: readonly FormattedText[]): FormattedText {\n if (items.length === 0)\n return ['%c', '']\n const template = items.map(item => ` ${item[0]}`).join('')\n const styles = items.flatMap(([, ...itemStyles]) => itemStyles)\n return [template, ...styles] as FormattedText\n}\n","import type { ConsoleLike, ConsoleMethodName, DebugPredicate, LogHook, LogHookContext, LogLevelDefinition, LogMethod } from './types'\nimport { getForegroundStyle } from './colors'\n\nexport const DEFAULT_LOG_LEVELS = [\n { name: 'log', label: 'Log', color: 'black', method: 'log' },\n { name: 'wait', label: 'Wait', color: 'cyan', method: 'log' },\n { name: 'error', label: 'Error', color: 'red', method: 'error' },\n { name: 'warn', label: 'Warn', color: 'yellow', method: 'warn' },\n { name: 'ready', label: 'Ready', color: 'green', method: 'log' },\n { name: 'info', label: 'Info', color: 'blue', method: 'info' },\n { name: 'event', label: 'Event', color: 'magenta', method: 'log' },\n { name: 'debug', label: 'Debug', color: 'gray', method: 'debug' },\n] satisfies readonly LogLevelDefinition[]\n\nexport interface CreateLoggerMethodsOptions {\n console: ConsoleLike\n colors: Readonly<Record<string, string>>\n isDebug: DebugPredicate\n logLevels?: readonly LogLevelDefinition[]\n getHooks: () => readonly LogHook[]\n}\n\nfunction getConsoleMethod(consoleLike: ConsoleLike, method: ConsoleMethodName): (...data: unknown[]) => void {\n return consoleLike[method] ?? consoleLike.log\n}\n\nfunction createLogMethod(\n consoleLike: ConsoleLike,\n colors: Readonly<Record<string, string>>,\n isDebug: DebugPredicate,\n level: LogLevelDefinition,\n getHooks: () => readonly LogHook[],\n): LogMethod {\n return (message: string, ...args: unknown[]): void => {\n const debugValue = isDebug()\n\n if (debugValue) {\n const method = getConsoleMethod(consoleLike, level.method)\n const labelStyle = `${getForegroundStyle(colors, level.color)};font-weight: bold;`\n const messageStyle = getForegroundStyle(colors, level.color)\n method(`%c[${level.label}]%c ${message}`, labelStyle, messageStyle, ...args)\n }\n\n const hooks = getHooks()\n if (hooks.length > 0) {\n const ctx: LogHookContext = {\n level: level.name,\n label: level.label,\n message,\n args,\n isDebug: debugValue,\n }\n for (const hook of hooks) {\n hook(ctx)\n }\n }\n }\n}\n\nexport function createLoggerMethods(options: CreateLoggerMethodsOptions): Record<string, LogMethod> {\n const levels = options.logLevels ?? DEFAULT_LOG_LEVELS\n return Object.fromEntries(\n levels.map(level => [\n level.name,\n createLogMethod(options.console, options.colors, options.isDebug, level, options.getHooks),\n ]),\n )\n}\n","import type { ChalkInstance, ConsoleLike, CreateChalkOptions, DebugPredicate, LogHook } from './types'\nimport { createBannerMethods } from './banner'\nimport { createColorMap } from './colors'\nimport { add, bgColor, bold, color } from './format'\nimport { createLoggerMethods } from './logger'\n\nconst noopConsole: ConsoleLike = {\n log: () => {},\n}\n\nfunction readGlobalDebugFlag(): boolean {\n return Object.prototype.hasOwnProperty.call(globalThis, 'alitadebug')\n && Boolean(globalThis.alitadebug)\n}\n\nfunction resolveConsole(consoleLike: ConsoleLike | undefined): ConsoleLike {\n return consoleLike ?? globalThis.console ?? noopConsole\n}\n\nfunction resolveDebugPredicate(isDebug: CreateChalkOptions['isDebug']): DebugPredicate {\n if (typeof isDebug === 'function')\n return isDebug\n if (typeof isDebug === 'boolean')\n return () => isDebug\n return readGlobalDebugFlag\n}\n\nexport function createChalk(options: CreateChalkOptions = {}): ChalkInstance {\n const consoleLike = resolveConsole(options.console)\n const colors = createColorMap(options.colors)\n const isDebug = resolveDebugPredicate(options.isDebug)\n const banner = createBannerMethods(consoleLike, isDebug)\n const hooks: LogHook[] = []\n const getHooks = (): readonly LogHook[] => hooks\n const loggers = createLoggerMethods({\n console: consoleLike,\n colors,\n isDebug,\n logLevels: options.logLevels,\n getHooks,\n })\n\n const instance: ChalkInstance = {\n add,\n bold,\n ...banner,\n black: text => color(colors, 'black', text),\n red: text => color(colors, 'red', text),\n green: text => color(colors, 'green', text),\n yellow: text => color(colors, 'yellow', text),\n blue: text => color(colors, 'blue', text),\n magenta: text => color(colors, 'magenta', text),\n cyan: text => color(colors, 'cyan', text),\n white: text => color(colors, 'white', text),\n bgBlack: text => bgColor(colors, 'black', text),\n bgRed: text => bgColor(colors, 'red', text),\n bgGreen: text => bgColor(colors, 'green', text),\n bgYellow: text => bgColor(colors, 'yellow', text),\n bgBlue: text => bgColor(colors, 'blue', text),\n bgMagenta: text => bgColor(colors, 'magenta', text),\n bgCyan: text => bgColor(colors, 'cyan', text),\n bgWhite: text => bgColor(colors, 'white', text),\n color: (name, text) => color(colors, name, text),\n bgColor: (name, text) => bgColor(colors, name, text),\n log: loggers.log,\n wait: loggers.wait,\n error: loggers.error,\n warn: loggers.warn,\n ready: loggers.ready,\n info: loggers.info,\n event: loggers.event,\n debug: loggers.debug,\n use(hook: LogHook): ChalkInstance {\n hooks.push(hook)\n return instance\n },\n }\n\n return instance\n}\n","import { createColorMap } from './colors'\nimport { createChalk } from './create'\nimport { add, bgColor as bgColorWithMap, bold, color as colorWithMap } from './format'\n\nconst defaultColors = createColorMap()\n\nexport const chalk = createChalk()\n\nexport { add, bold, createChalk }\nexport { createColorMap, DEFAULT_COLORS, getBackgroundStyle, getForegroundStyle, resolveColor } from './colors'\nexport type {\n ChalkInstance,\n ColorMap,\n ColorName,\n ConsoleLike,\n CreateChalkOptions,\n CustomColorMap,\n FormattedText,\n LogHook,\n LogHookContext,\n LogLevelDefinition,\n LogMethod,\n PublicColorName,\n TextFormatter,\n} from './types'\n\nexport function color(name: string, text: string) {\n return colorWithMap(defaultColors, name, text)\n}\n\nexport function bgColor(name: string, text: string) {\n return bgColorWithMap(defaultColors, name, text)\n}\n\nexport default chalk\n"],"mappings":";;;;;;AAKA,MAAaA,iBAA2B;CACtC,OAAO;CACP,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,SAAS;CACT,MAAM;CACN,OAAO;CACP,MAAM;CACP;;;;;AAMD,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K;AAChB,UAAO;;EAEV;AAED,QAAO;;;;;AC1ET,MAAM,gBAAgB,gBAAgB;AAEtC,MAAa,QAAQ,aAAa;AAoBlC,SAAgB,MAAM,MAAc,MAAc;AAChD,QAAOC,QAAa,eAAe,MAAM,KAAK;;AAGhD,SAAgB,QAAQ,MAAc,MAAc;AAClD,QAAOC,UAAe,eAAe,MAAM,KAAK;;AAGlD,kBAAe"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["DEFAULT_COLORS: ColorMap","ctx: LogHookContext","noopConsole: ConsoleLike","hooks: LogHook[]","instance: ChalkInstance"],"sources":["../src/banner.ts","../src/colors.ts","../src/format.ts","../src/logger.ts","../src/create.ts","../src/index.ts"],"sourcesContent":["import type { ConsoleLike, DebugPredicate } from './types'\n\nexport interface BannerMethods {\n hello: (title: string, version: string) => void\n image: (url: string) => void\n}\n\nexport function createBannerMethods(consoleLike: ConsoleLike, isDebug: DebugPredicate): BannerMethods {\n return {\n hello(title: string, version: string): void {\n if (!isDebug())\n return\n consoleLike.log(\n `%c ${title} %c V${version} `,\n 'padding: 2px 1px; border-radius: 3px 0 0 3px; color: #cad3f5; background: #494d64; font-weight: bold;',\n 'padding: 2px 1px; border-radius: 0 3px 3px 0; color: #24273a; background: #a6da95; font-weight: bold;',\n )\n },\n image(url: string): void {\n if (!url)\n return\n if (!isDebug())\n return\n consoleLike.log(\n '%c ',\n `font-size: 1px; padding: 100px 100px; background: url(${url}) no-repeat center / contain; color: transparent;`,\n )\n },\n }\n}\n","import type { ChalkMode, ColorMap } from './types'\n\n/**\n * Catppuccin Macchiato palette — https://catppuccin.com/palette/\n */\nexport const DEFAULT_COLORS: ColorMap = {\n black: '#24273a', // Base\n red: '#ed8796', // Red\n green: '#a6da95', // Green\n yellow: '#eed49f', // Yellow\n blue: '#8aadf4', // Blue\n magenta: '#c6a0f6', // Mauve\n cyan: '#8bd5ca', // Teal\n white: '#cad3f5', // Text\n gray: '#6e738d', // Overlay0\n}\n\nexport function resolveColor(colors: Readonly<Record<string, string>>, name: string): string {\n const color = colors[name]\n if (color === undefined)\n throw new Error(`Unknown chalk color: ${name}`)\n return color\n}\n\nexport function getForegroundStyle(colors: Readonly<Record<string, string>>, name: string): string {\n const hex = resolveColor(colors, name)\n return `color:${hex}`\n}\n\nexport function getBackgroundStyle(colors: Readonly<Record<string, string>>, name: string): string {\n const hex = resolveColor(colors, name)\n const textColor = name === 'black' ? (colors.blue ?? '#8aadf4') : '#24273a'\n return `padding: 2px 4px; border-radius: 3px; color: ${textColor}; font-weight: bold; background:${hex};`\n}\n\nexport function getStyle(colors: Readonly<Record<string, string>>, name: string, mode: ChalkMode): string {\n return mode === 'background'\n ? getBackgroundStyle(colors, name)\n : getForegroundStyle(colors, name)\n}\n","import type { ChalkMode, FormattedText } from './types'\nimport { DEFAULT_COLORS, getStyle } from './colors'\n\nexport function formatText(text: string, style: string): FormattedText {\n return [`%c${text}`, style]\n}\n\nexport function coloredText(name: string, text: string, mode: ChalkMode): FormattedText {\n return formatText(text, getStyle(DEFAULT_COLORS, name, mode))\n}\n\nexport function bold(text: string): FormattedText {\n return formatText(text, 'font-weight: bold;')\n}\n\nexport function add(...items: readonly FormattedText[]): FormattedText {\n if (items.length === 0)\n return ['%c', '']\n const template = items.map(item => ` ${item[0]}`).join('')\n const styles = items.flatMap(([, ...itemStyles]) => itemStyles)\n return [template, ...styles] as FormattedText\n}\n","import type { ChalkMode, ConsoleLike, ConsoleMethodName, DebugPredicate, LogHook, LogHookContext, LogLevelDefinition, LogMethod } from './types'\nimport { DEFAULT_COLORS, getStyle } from './colors'\n\nexport const DEFAULT_LOG_LEVELS = [\n { name: 'log', label: 'Log', color: 'black', method: 'log' },\n { name: 'wait', label: 'Wait', color: 'cyan', method: 'log' },\n { name: 'error', label: 'Error', color: 'red', method: 'error' },\n { name: 'warn', label: 'Warn', color: 'yellow', method: 'warn' },\n { name: 'ready', label: 'Ready', color: 'green', method: 'log' },\n { name: 'info', label: 'Info', color: 'blue', method: 'info' },\n { name: 'event', label: 'Event', color: 'magenta', method: 'log' },\n { name: 'debug', label: 'Debug', color: 'gray', method: 'debug' },\n] satisfies readonly LogLevelDefinition[]\n\nexport interface CreateLoggerMethodsOptions {\n console: ConsoleLike\n mode: ChalkMode\n isDebug: DebugPredicate\n logLevels?: readonly LogLevelDefinition[]\n getHooks: () => readonly LogHook[]\n}\n\nfunction getConsoleMethod(consoleLike: ConsoleLike, method: ConsoleMethodName): (...data: unknown[]) => void {\n return consoleLike[method] ?? consoleLike.log\n}\n\nfunction createLogMethod(\n consoleLike: ConsoleLike,\n isDebug: DebugPredicate,\n level: LogLevelDefinition,\n mode: ChalkMode,\n getHooks: () => readonly LogHook[],\n): LogMethod {\n return (message: string, ...args: unknown[]): void => {\n const debugValue = isDebug()\n\n if (debugValue) {\n const method = getConsoleMethod(consoleLike, level.method)\n const style = getStyle(DEFAULT_COLORS, level.color, mode)\n method(`%c[${level.label}]%c ${message}`, style, style, ...args)\n }\n\n const hooks = getHooks()\n if (hooks.length > 0) {\n const ctx: LogHookContext = {\n level: level.name,\n label: level.label,\n message,\n args,\n isDebug: debugValue,\n }\n for (const hook of hooks) {\n hook(ctx)\n }\n }\n }\n}\n\nexport function createLoggerMethods(options: CreateLoggerMethodsOptions): Record<string, LogMethod> {\n const levels = options.logLevels ?? DEFAULT_LOG_LEVELS\n return Object.fromEntries(\n levels.map(level => [\n level.name,\n createLogMethod(options.console, options.isDebug, level, options.mode, options.getHooks),\n ]),\n )\n}\n","import type { ChalkInstance, ConsoleLike, CreateChalkOptions, DebugPredicate, LogHook } from './types'\nimport { createBannerMethods } from './banner'\nimport { add, bold, coloredText } from './format'\nimport { createLoggerMethods } from './logger'\n\nconst noopConsole: ConsoleLike = {\n log: () => {},\n}\n\nfunction readGlobalDebugFlag(): boolean {\n return Object.prototype.hasOwnProperty.call(globalThis, 'alitadebug')\n && Boolean(globalThis.alitadebug)\n}\n\nfunction resolveConsole(consoleLike: ConsoleLike | undefined): ConsoleLike {\n return consoleLike ?? globalThis.console ?? noopConsole\n}\n\nfunction resolveDebugPredicate(isDebug: CreateChalkOptions['isDebug']): DebugPredicate {\n if (typeof isDebug === 'function')\n return isDebug\n if (typeof isDebug === 'boolean')\n return () => isDebug\n return readGlobalDebugFlag\n}\n\nexport function createChalk(options: CreateChalkOptions = {}): ChalkInstance {\n const consoleLike = resolveConsole(options.console)\n const mode = options.mode ?? 'background'\n const isDebug = resolveDebugPredicate(options.isDebug)\n const banner = createBannerMethods(consoleLike, isDebug)\n const hooks: LogHook[] = []\n const getHooks = (): readonly LogHook[] => hooks\n const loggers = createLoggerMethods({\n console: consoleLike,\n mode,\n isDebug,\n logLevels: options.logLevels,\n getHooks,\n })\n\n const fg = (name: string) => (text: string) => coloredText(name, text, 'foreground')\n const bg = (name: string) => (text: string) => coloredText(name, text, 'background')\n\n const instance: ChalkInstance = {\n add,\n bold,\n ...banner,\n black: fg('black'),\n red: fg('red'),\n green: fg('green'),\n yellow: fg('yellow'),\n blue: fg('blue'),\n magenta: fg('magenta'),\n cyan: fg('cyan'),\n white: fg('white'),\n bgBlack: bg('black'),\n bgRed: bg('red'),\n bgGreen: bg('green'),\n bgYellow: bg('yellow'),\n bgBlue: bg('blue'),\n bgMagenta: bg('magenta'),\n bgCyan: bg('cyan'),\n bgWhite: bg('white'),\n log: loggers.log,\n wait: loggers.wait,\n error: loggers.error,\n warn: loggers.warn,\n ready: loggers.ready,\n info: loggers.info,\n event: loggers.event,\n debug: loggers.debug,\n use(hook: LogHook): ChalkInstance {\n hooks.push(hook)\n return instance\n },\n }\n\n return instance\n}\n","import { createChalk } from './create'\nimport { add, bold } from './format'\n\nexport const chalk = createChalk()\n\nexport { add, bold, createChalk }\nexport { DEFAULT_COLORS, getBackgroundStyle, getForegroundStyle, getStyle, resolveColor } from './colors'\nexport type {\n ChalkInstance,\n ChalkMode,\n ColorMap,\n ColorName,\n ConsoleLike,\n CreateChalkOptions,\n FormattedText,\n LogHook,\n LogHookContext,\n LogLevelDefinition,\n L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;EACpB,OAAO,GAAG,MAAM;EAChB,SAAS,GAAG,QAAQ;EACpB,UAAU,GAAG,SAAS;EACtB,QAAQ,GAAG,OAAO;EAClB,WAAW,GAAG,UAAU;EACxB,QAAQ,GAAG,OAAO;EAClB,SAAS,GAAG,QAAQ;EACpB,KAAK,QAAQ;EACb,MAAM,QAAQ;EACd,OAAO,QAAQ;EACf,MAAM,QAAQ;EACd,OAAO,QAAQ;EACf,MAAM,QAAQ;EACd,OAAO,QAAQ;EACf,OAAO,QAAQ;EACf,IAAI,MAA8B;AAChC,SAAM,KAAK,KAAK;AAChB,UAAO;;EAEV;AAED,QAAO;;;;;AC3ET,MAAa,QAAQ,aAAa;AAoBlC,kBAAe"}
|
package/dist/index.d.cts
CHANGED
|
@@ -11,18 +11,18 @@ type FormattedText = [template: `%c${string}`, ...styles: string[]];
|
|
|
11
11
|
type ColorName = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray';
|
|
12
12
|
type PublicColorName = Exclude<ColorName, 'gray'>;
|
|
13
13
|
type ColorMap = Readonly<Record<ColorName, string>>;
|
|
14
|
-
type
|
|
14
|
+
type ChalkMode = 'foreground' | 'background';
|
|
15
15
|
type DebugPredicate = () => boolean;
|
|
16
16
|
interface LogLevelDefinition {
|
|
17
17
|
name: string;
|
|
18
18
|
label: string;
|
|
19
|
-
color: ColorName
|
|
19
|
+
color: ColorName;
|
|
20
20
|
method: ConsoleMethodName;
|
|
21
21
|
}
|
|
22
22
|
interface CreateChalkOptions {
|
|
23
23
|
console?: ConsoleLike;
|
|
24
|
+
mode?: ChalkMode;
|
|
24
25
|
isDebug?: boolean | DebugPredicate;
|
|
25
|
-
colors?: CustomColorMap;
|
|
26
26
|
logLevels?: readonly LogLevelDefinition[];
|
|
27
27
|
}
|
|
28
28
|
type TextFormatter = (text: string) => FormattedText;
|
|
@@ -64,8 +64,6 @@ interface ChalkInstance {
|
|
|
64
64
|
bgMagenta: TextFormatter;
|
|
65
65
|
bgCyan: TextFormatter;
|
|
66
66
|
bgWhite: TextFormatter;
|
|
67
|
-
color: (name: string, text: string) => FormattedText;
|
|
68
|
-
bgColor: (name: string, text: string) => FormattedText;
|
|
69
67
|
use: (hook: LogHook) => ChalkInstance;
|
|
70
68
|
}
|
|
71
69
|
//#endregion
|
|
@@ -78,19 +76,16 @@ declare function add(...items: readonly FormattedText[]): FormattedText;
|
|
|
78
76
|
//#endregion
|
|
79
77
|
//#region src/colors.d.ts
|
|
80
78
|
/**
|
|
81
|
-
* Catppuccin
|
|
79
|
+
* Catppuccin Macchiato palette — https://catppuccin.com/palette/
|
|
82
80
|
*/
|
|
83
81
|
declare const DEFAULT_COLORS: ColorMap;
|
|
84
|
-
type ResolvedColorMap = Readonly<ColorMap & CustomColorMap>;
|
|
85
|
-
declare function createColorMap(customColors?: CustomColorMap): ResolvedColorMap;
|
|
86
82
|
declare function resolveColor(colors: Readonly<Record<string, string>>, name: string): string;
|
|
87
83
|
declare function getForegroundStyle(colors: Readonly<Record<string, string>>, name: string): string;
|
|
88
84
|
declare function getBackgroundStyle(colors: Readonly<Record<string, string>>, name: string): string;
|
|
85
|
+
declare function getStyle(colors: Readonly<Record<string, string>>, name: string, mode: ChalkMode): string;
|
|
89
86
|
//#endregion
|
|
90
87
|
//#region src/index.d.ts
|
|
91
88
|
declare const chalk: ChalkInstance;
|
|
92
|
-
declare function color(name: string, text: string): FormattedText;
|
|
93
|
-
declare function bgColor(name: string, text: string): FormattedText;
|
|
94
89
|
//#endregion
|
|
95
|
-
export { type ChalkInstance, type ColorMap, type ColorName, type ConsoleLike, type CreateChalkOptions,
|
|
90
|
+
export { type ChalkInstance, type ChalkMode, type ColorMap, type ColorName, type ConsoleLike, type CreateChalkOptions, DEFAULT_COLORS, type FormattedText, type LogHook, type LogHookContext, type LogLevelDefinition, type LogMethod, type PublicColorName, type TextFormatter, add, bold, chalk, chalk as default, createChalk, getBackgroundStyle, getForegroundStyle, getStyle, resolveColor };
|
|
96
91
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -11,18 +11,18 @@ type FormattedText = [template: `%c${string}`, ...styles: string[]];
|
|
|
11
11
|
type ColorName = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray';
|
|
12
12
|
type PublicColorName = Exclude<ColorName, 'gray'>;
|
|
13
13
|
type ColorMap = Readonly<Record<ColorName, string>>;
|
|
14
|
-
type
|
|
14
|
+
type ChalkMode = 'foreground' | 'background';
|
|
15
15
|
type DebugPredicate = () => boolean;
|
|
16
16
|
interface LogLevelDefinition {
|
|
17
17
|
name: string;
|
|
18
18
|
label: string;
|
|
19
|
-
color: ColorName
|
|
19
|
+
color: ColorName;
|
|
20
20
|
method: ConsoleMethodName;
|
|
21
21
|
}
|
|
22
22
|
interface CreateChalkOptions {
|
|
23
23
|
console?: ConsoleLike;
|
|
24
|
+
mode?: ChalkMode;
|
|
24
25
|
isDebug?: boolean | DebugPredicate;
|
|
25
|
-
colors?: CustomColorMap;
|
|
26
26
|
logLevels?: readonly LogLevelDefinition[];
|
|
27
27
|
}
|
|
28
28
|
type TextFormatter = (text: string) => FormattedText;
|
|
@@ -64,8 +64,6 @@ interface ChalkInstance {
|
|
|
64
64
|
bgMagenta: TextFormatter;
|
|
65
65
|
bgCyan: TextFormatter;
|
|
66
66
|
bgWhite: TextFormatter;
|
|
67
|
-
color: (name: string, text: string) => FormattedText;
|
|
68
|
-
bgColor: (name: string, text: string) => FormattedText;
|
|
69
67
|
use: (hook: LogHook) => ChalkInstance;
|
|
70
68
|
}
|
|
71
69
|
//#endregion
|
|
@@ -78,19 +76,16 @@ declare function add(...items: readonly FormattedText[]): FormattedText;
|
|
|
78
76
|
//#endregion
|
|
79
77
|
//#region src/colors.d.ts
|
|
80
78
|
/**
|
|
81
|
-
* Catppuccin
|
|
79
|
+
* Catppuccin Macchiato palette — https://catppuccin.com/palette/
|
|
82
80
|
*/
|
|
83
81
|
declare const DEFAULT_COLORS: ColorMap;
|
|
84
|
-
type ResolvedColorMap = Readonly<ColorMap & CustomColorMap>;
|
|
85
|
-
declare function createColorMap(customColors?: CustomColorMap): ResolvedColorMap;
|
|
86
82
|
declare function resolveColor(colors: Readonly<Record<string, string>>, name: string): string;
|
|
87
83
|
declare function getForegroundStyle(colors: Readonly<Record<string, string>>, name: string): string;
|
|
88
84
|
declare function getBackgroundStyle(colors: Readonly<Record<string, string>>, name: string): string;
|
|
85
|
+
declare function getStyle(colors: Readonly<Record<string, string>>, name: string, mode: ChalkMode): string;
|
|
89
86
|
//#endregion
|
|
90
87
|
//#region src/index.d.ts
|
|
91
88
|
declare const chalk: ChalkInstance;
|
|
92
|
-
declare function color(name: string, text: string): FormattedText;
|
|
93
|
-
declare function bgColor(name: string, text: string): FormattedText;
|
|
94
89
|
//#endregion
|
|
95
|
-
export { type ChalkInstance, type ColorMap, type ColorName, type ConsoleLike, type CreateChalkOptions,
|
|
90
|
+
export { type ChalkInstance, type ChalkMode, type ColorMap, type ColorName, type ConsoleLike, type CreateChalkOptions, DEFAULT_COLORS, type FormattedText, type LogHook, type LogHookContext, type LogLevelDefinition, type LogMethod, type PublicColorName, type TextFormatter, add, bold, chalk, chalk as default, createChalk, getBackgroundStyle, getForegroundStyle, getStyle, resolveColor };
|
|
96
91
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,67 +1,9 @@
|
|
|
1
|
-
//#region src/colors.ts
|
|
2
|
-
/**
|
|
3
|
-
* Catppuccin Mocha palette — https://catppuccin.com/palette/
|
|
4
|
-
*/
|
|
5
|
-
const DEFAULT_COLORS = {
|
|
6
|
-
black: "#1e1e2e",
|
|
7
|
-
red: "#f38ba8",
|
|
8
|
-
green: "#a6e3a1",
|
|
9
|
-
yellow: "#f9e2af",
|
|
10
|
-
blue: "#89b4fa",
|
|
11
|
-
magenta: "#cba6f7",
|
|
12
|
-
cyan: "#94e2d5",
|
|
13
|
-
white: "#cdd6f4",
|
|
14
|
-
gray: "#6c7086"
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Colors that are dark enough to not need a background on dark consoles.
|
|
18
|
-
* All other built-in Catppuccin Mocha colors are pastel and need a subtle bg.
|
|
19
|
-
*/
|
|
20
|
-
const DARK_FG_COLORS = {
|
|
21
|
-
black: true,
|
|
22
|
-
gray: true
|
|
23
|
-
};
|
|
24
|
-
function createColorMap(customColors = {}) {
|
|
25
|
-
return {
|
|
26
|
-
...DEFAULT_COLORS,
|
|
27
|
-
...customColors
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function resolveColor(colors, name) {
|
|
31
|
-
const color$2 = colors[name];
|
|
32
|
-
if (color$2 === void 0) throw new Error(`Unknown chalk color: ${name}`);
|
|
33
|
-
return color$2;
|
|
34
|
-
}
|
|
35
|
-
/** Returns true when the color is bright enough to need a background in dark consoles. */
|
|
36
|
-
function needsBackground(colors, name) {
|
|
37
|
-
if (DARK_FG_COLORS[name]) return false;
|
|
38
|
-
const hex = colors[name];
|
|
39
|
-
if (!hex) return true;
|
|
40
|
-
return getRelativeLuminance(hex) > .18;
|
|
41
|
-
}
|
|
42
|
-
function getRelativeLuminance(hex) {
|
|
43
|
-
const h = hex.replace("#", "");
|
|
44
|
-
const r = Number.parseInt(h.slice(0, 2), 16) / 255;
|
|
45
|
-
const g = Number.parseInt(h.slice(2, 4), 16) / 255;
|
|
46
|
-
const b = Number.parseInt(h.slice(4, 6), 16) / 255;
|
|
47
|
-
return .2126 * r + .7152 * g + .0722 * b;
|
|
48
|
-
}
|
|
49
|
-
function getForegroundStyle(colors, name) {
|
|
50
|
-
const parts = [`color:${resolveColor(colors, name)}`];
|
|
51
|
-
if (needsBackground(colors, name)) parts.push("background:rgba(0,0,0,0.15)", "padding:0 2px", "border-radius:2px");
|
|
52
|
-
return parts.join(";");
|
|
53
|
-
}
|
|
54
|
-
function getBackgroundStyle(colors, name) {
|
|
55
|
-
return `padding: 2px 4px; border-radius: 3px; color: #1e1e2e; font-weight: bold; background:${resolveColor(colors, name)};`;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
//#endregion
|
|
59
1
|
//#region src/banner.ts
|
|
60
2
|
function createBannerMethods(consoleLike, isDebug) {
|
|
61
3
|
return {
|
|
62
4
|
hello(title, version) {
|
|
63
5
|
if (!isDebug()) return;
|
|
64
|
-
consoleLike.log(`%c ${title} %c V${version} `, "padding: 2px 1px; border-radius: 3px 0 0 3px; color: #
|
|
6
|
+
consoleLike.log(`%c ${title} %c V${version} `, "padding: 2px 1px; border-radius: 3px 0 0 3px; color: #cad3f5; background: #494d64; font-weight: bold;", "padding: 2px 1px; border-radius: 0 3px 3px 0; color: #24273a; background: #a6da95; font-weight: bold;");
|
|
65
7
|
},
|
|
66
8
|
image(url) {
|
|
67
9
|
if (!url) return;
|
|
@@ -71,16 +13,45 @@ function createBannerMethods(consoleLike, isDebug) {
|
|
|
71
13
|
};
|
|
72
14
|
}
|
|
73
15
|
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/colors.ts
|
|
18
|
+
/**
|
|
19
|
+
* Catppuccin Macchiato palette — https://catppuccin.com/palette/
|
|
20
|
+
*/
|
|
21
|
+
const DEFAULT_COLORS = {
|
|
22
|
+
black: "#24273a",
|
|
23
|
+
red: "#ed8796",
|
|
24
|
+
green: "#a6da95",
|
|
25
|
+
yellow: "#eed49f",
|
|
26
|
+
blue: "#8aadf4",
|
|
27
|
+
magenta: "#c6a0f6",
|
|
28
|
+
cyan: "#8bd5ca",
|
|
29
|
+
white: "#cad3f5",
|
|
30
|
+
gray: "#6e738d"
|
|
31
|
+
};
|
|
32
|
+
function resolveColor(colors, name) {
|
|
33
|
+
const color = colors[name];
|
|
34
|
+
if (color === void 0) throw new Error(`Unknown chalk color: ${name}`);
|
|
35
|
+
return color;
|
|
36
|
+
}
|
|
37
|
+
function getForegroundStyle(colors, name) {
|
|
38
|
+
return `color:${resolveColor(colors, name)}`;
|
|
39
|
+
}
|
|
40
|
+
function getBackgroundStyle(colors, name) {
|
|
41
|
+
const hex = resolveColor(colors, name);
|
|
42
|
+
return `padding: 2px 4px; border-radius: 3px; color: ${name === "black" ? colors.blue ?? "#8aadf4" : "#24273a"}; font-weight: bold; background:${hex};`;
|
|
43
|
+
}
|
|
44
|
+
function getStyle(colors, name, mode) {
|
|
45
|
+
return mode === "background" ? getBackgroundStyle(colors, name) : getForegroundStyle(colors, name);
|
|
46
|
+
}
|
|
47
|
+
|
|
74
48
|
//#endregion
|
|
75
49
|
//#region src/format.ts
|
|
76
50
|
function formatText(text, style) {
|
|
77
51
|
return [`%c${text}`, style];
|
|
78
52
|
}
|
|
79
|
-
function
|
|
80
|
-
return formatText(text,
|
|
81
|
-
}
|
|
82
|
-
function bgColor$1(colors, name, text) {
|
|
83
|
-
return formatText(text, getBackgroundStyle(colors, name));
|
|
53
|
+
function coloredText(name, text, mode) {
|
|
54
|
+
return formatText(text, getStyle(DEFAULT_COLORS, name, mode));
|
|
84
55
|
}
|
|
85
56
|
function bold(text) {
|
|
86
57
|
return formatText(text, "font-weight: bold;");
|
|
@@ -145,14 +116,13 @@ const DEFAULT_LOG_LEVELS = [
|
|
|
145
116
|
function getConsoleMethod(consoleLike, method) {
|
|
146
117
|
return consoleLike[method] ?? consoleLike.log;
|
|
147
118
|
}
|
|
148
|
-
function createLogMethod(consoleLike,
|
|
119
|
+
function createLogMethod(consoleLike, isDebug, level, mode, getHooks) {
|
|
149
120
|
return (message, ...args) => {
|
|
150
121
|
const debugValue = isDebug();
|
|
151
122
|
if (debugValue) {
|
|
152
123
|
const method = getConsoleMethod(consoleLike, level.method);
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
method(`%c[${level.label}]%c ${message}`, labelStyle, messageStyle, ...args);
|
|
124
|
+
const style = getStyle(DEFAULT_COLORS, level.color, mode);
|
|
125
|
+
method(`%c[${level.label}]%c ${message}`, style, style, ...args);
|
|
156
126
|
}
|
|
157
127
|
const hooks = getHooks();
|
|
158
128
|
if (hooks.length > 0) {
|
|
@@ -169,7 +139,7 @@ function createLogMethod(consoleLike, colors, isDebug, level, getHooks) {
|
|
|
169
139
|
}
|
|
170
140
|
function createLoggerMethods(options) {
|
|
171
141
|
const levels = options.logLevels ?? DEFAULT_LOG_LEVELS;
|
|
172
|
-
return Object.fromEntries(levels.map((level) => [level.name, createLogMethod(options.console, options.
|
|
142
|
+
return Object.fromEntries(levels.map((level) => [level.name, createLogMethod(options.console, options.isDebug, level, options.mode, options.getHooks)]));
|
|
173
143
|
}
|
|
174
144
|
|
|
175
145
|
//#endregion
|
|
@@ -188,40 +158,40 @@ function resolveDebugPredicate(isDebug) {
|
|
|
188
158
|
}
|
|
189
159
|
function createChalk(options = {}) {
|
|
190
160
|
const consoleLike = resolveConsole(options.console);
|
|
191
|
-
const
|
|
161
|
+
const mode = options.mode ?? "background";
|
|
192
162
|
const isDebug = resolveDebugPredicate(options.isDebug);
|
|
193
163
|
const banner = createBannerMethods(consoleLike, isDebug);
|
|
194
164
|
const hooks = [];
|
|
195
165
|
const getHooks = () => hooks;
|
|
196
166
|
const loggers = createLoggerMethods({
|
|
197
167
|
console: consoleLike,
|
|
198
|
-
|
|
168
|
+
mode,
|
|
199
169
|
isDebug,
|
|
200
170
|
logLevels: options.logLevels,
|
|
201
171
|
getHooks
|
|
202
172
|
});
|
|
173
|
+
const fg = (name) => (text) => coloredText(name, text, "foreground");
|
|
174
|
+
const bg = (name) => (text) => coloredText(name, text, "background");
|
|
203
175
|
const instance = {
|
|
204
176
|
add,
|
|
205
177
|
bold,
|
|
206
178
|
...banner,
|
|
207
|
-
black: (
|
|
208
|
-
red: (
|
|
209
|
-
green: (
|
|
210
|
-
yellow: (
|
|
211
|
-
blue: (
|
|
212
|
-
magenta: (
|
|
213
|
-
cyan: (
|
|
214
|
-
white: (
|
|
215
|
-
bgBlack: (
|
|
216
|
-
bgRed: (
|
|
217
|
-
bgGreen: (
|
|
218
|
-
bgYellow: (
|
|
219
|
-
bgBlue: (
|
|
220
|
-
bgMagenta: (
|
|
221
|
-
bgCyan: (
|
|
222
|
-
bgWhite: (
|
|
223
|
-
color: (name, text) => color$1(colors, name, text),
|
|
224
|
-
bgColor: (name, text) => bgColor$1(colors, name, text),
|
|
179
|
+
black: fg("black"),
|
|
180
|
+
red: fg("red"),
|
|
181
|
+
green: fg("green"),
|
|
182
|
+
yellow: fg("yellow"),
|
|
183
|
+
blue: fg("blue"),
|
|
184
|
+
magenta: fg("magenta"),
|
|
185
|
+
cyan: fg("cyan"),
|
|
186
|
+
white: fg("white"),
|
|
187
|
+
bgBlack: bg("black"),
|
|
188
|
+
bgRed: bg("red"),
|
|
189
|
+
bgGreen: bg("green"),
|
|
190
|
+
bgYellow: bg("yellow"),
|
|
191
|
+
bgBlue: bg("blue"),
|
|
192
|
+
bgMagenta: bg("magenta"),
|
|
193
|
+
bgCyan: bg("cyan"),
|
|
194
|
+
bgWhite: bg("white"),
|
|
225
195
|
log: loggers.log,
|
|
226
196
|
wait: loggers.wait,
|
|
227
197
|
error: loggers.error,
|
|
@@ -240,16 +210,9 @@ function createChalk(options = {}) {
|
|
|
240
210
|
|
|
241
211
|
//#endregion
|
|
242
212
|
//#region src/index.ts
|
|
243
|
-
const defaultColors = createColorMap();
|
|
244
213
|
const chalk = createChalk();
|
|
245
|
-
function color(name, text) {
|
|
246
|
-
return color$1(defaultColors, name, text);
|
|
247
|
-
}
|
|
248
|
-
function bgColor(name, text) {
|
|
249
|
-
return bgColor$1(defaultColors, name, text);
|
|
250
|
-
}
|
|
251
214
|
var src_default = chalk;
|
|
252
215
|
|
|
253
216
|
//#endregion
|
|
254
|
-
export { DEFAULT_COLORS, add,
|
|
217
|
+
export { DEFAULT_COLORS, add, bold, chalk, createChalk, src_default as default, getBackgroundStyle, getForegroundStyle, getStyle, resolveColor };
|
|
255
218
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["DEFAULT_COLORS: ColorMap","DARK_FG_COLORS: Record<string, true>","color","color","bgColor","ctx: LogHookContext","noopConsole: ConsoleLike","hooks: LogHook[]","instance: ChalkInstance","color","bgColor","colorWithMap","bgColorWithMap"],"sources":["../src/colors.ts","../src/banner.ts","../src/format.ts","../src/logger.ts","../src/create.ts","../src/index.ts"],"sourcesContent":["import type { ColorMap, CustomColorMap } from './types'\n\n/**\n * Catppuccin Mocha palette — https://catppuccin.com/palette/\n */\nexport const DEFAULT_COLORS: ColorMap = {\n black: '#1e1e2e', // Base\n red: '#f38ba8', // Red\n green: '#a6e3a1', // Green\n yellow: '#f9e2af', // Yellow\n blue: '#89b4fa', // Blue\n magenta: '#cba6f7', // Mauve\n cyan: '#94e2d5', // Teal\n white: '#cdd6f4', // Text\n gray: '#6c7086', // Overlay0\n}\n\n/**\n * Colors that are dark enough to not need a background on dark consoles.\n * All other built-in Catppuccin Mocha colors are pastel and need a subtle bg.\n */\nexport const DARK_FG_COLORS: Record<string, true> = { black: true, gray: true }\n\nexport type ResolvedColorMap = Readonly<ColorMap & CustomColorMap>\n\nexport function createColorMap(customColors: CustomColorMap = {} as CustomColorMap): ResolvedColorMap {\n return {\n ...DEFAULT_COLORS,\n ...customColors,\n }\n}\n\nexport function resolveColor(colors: Readonly<Record<string, string>>, name: string): string {\n const color = colors[name]\n if (color === undefined)\n throw new Error(`Unknown chalk color: ${name}`)\n return color\n}\n\n/** Returns true when the color is bright enough to need a background in dark consoles. */\nfunction needsBackground(colors: Readonly<Record<string, string>>, name: string): boolean {\n if (DARK_FG_COLORS[name])\n return false\n const hex = colors[name]\n if (!hex)\n return true\n return getRelativeLuminance(hex) > 0.18\n}\n\nfunction getRelativeLuminance(hex: string): number {\n const h = hex.replace('#', '')\n const r = Number.parseInt(h.slice(0, 2), 16) / 255\n const g = Number.parseInt(h.slice(2, 4), 16) / 255\n const b = Number.parseInt(h.slice(4, 6), 16) / 255\n return 0.2126 * r + 0.7152 * g + 0.0722 * b\n}\n\nexport function getForegroundStyle(colors: Readonly<Record<string, string>>, name: string): string {\n const hex = resolveColor(colors, name)\n const parts = [`color:${hex}`]\n if (needsBackground(colors, name))\n parts.push('background:rgba(0,0,0,0.15)', 'padding:0 2px', 'border-radius:2px')\n return parts.join(';')\n}\n\nexport function getBackgroundStyle(colors: Readonly<Record<string, string>>, name: string): string {\n const hex = resolveColor(colors, name)\n const textColor = '#1e1e2e'\n return `padding: 2px 4px; border-radius: 3px; color: ${textColor}; font-weight: bold; background:${hex};`\n}\n","import type { ConsoleLike, DebugPredicate } from './types'\n\nexport interface BannerMethods {\n hello: (title: string, version: string) => void\n image: (url: string) => void\n}\n\nexport function createBannerMethods(consoleLike: ConsoleLike, isDebug: DebugPredicate): BannerMethods {\n return {\n hello(title: string, version: string): void {\n if (!isDebug())\n return\n consoleLike.log(\n `%c ${title} %c V${version} `,\n 'padding: 2px 1px; border-radius: 3px 0 0 3px; color: #cdd6f4; background: #45475a; font-weight: bold;',\n 'padding: 2px 1px; border-radius: 0 3px 3px 0; color: #1e1e2e; background: #a6e3a1; font-weight: bold;',\n )\n },\n image(url: string): void {\n if (!url)\n return\n if (!isDebug())\n return\n consoleLike.log(\n '%c ',\n `font-size: 1px; padding: 100px 100px; background: url(${url}) no-repeat center / contain; color: transparent;`,\n )\n },\n }\n}\n","import type { FormattedText } from './types'\nimport { getBackgroundStyle, getForegroundStyle } from './colors'\n\nexport function formatText(text: string, style: string): FormattedText {\n return [`%c${text}`, style]\n}\n\nexport function color(colors: Readonly<Record<string, string>>, name: string, text: string): FormattedText {\n return formatText(text, getForegroundStyle(colors, name))\n}\n\nexport function bgColor(colors: Readonly<Record<string, string>>, name: string, text: string): FormattedText {\n return formatText(text, getBackgroundStyle(colors, name))\n}\n\nexport function bold(text: string): FormattedText {\n return formatText(text, 'font-weight: bold;')\n}\n\nexport function add(...items: readonly FormattedText[]): FormattedText {\n if (items.length === 0)\n return ['%c', '']\n const template = items.map(item => ` ${item[0]}`).join('')\n const styles = items.flatMap(([, ...itemStyles]) => itemStyles)\n return [template, ...styles] as FormattedText\n}\n","import type { ConsoleLike, ConsoleMethodName, DebugPredicate, LogHook, LogHookContext, LogLevelDefinition, LogMethod } from './types'\nimport { getForegroundStyle } from './colors'\n\nexport const DEFAULT_LOG_LEVELS = [\n { name: 'log', label: 'Log', color: 'black', method: 'log' },\n { name: 'wait', label: 'Wait', color: 'cyan', method: 'log' },\n { name: 'error', label: 'Error', color: 'red', method: 'error' },\n { name: 'warn', label: 'Warn', color: 'yellow', method: 'warn' },\n { name: 'ready', label: 'Ready', color: 'green', method: 'log' },\n { name: 'info', label: 'Info', color: 'blue', method: 'info' },\n { name: 'event', label: 'Event', color: 'magenta', method: 'log' },\n { name: 'debug', label: 'Debug', color: 'gray', method: 'debug' },\n] satisfies readonly LogLevelDefinition[]\n\nexport interface CreateLoggerMethodsOptions {\n console: ConsoleLike\n colors: Readonly<Record<string, string>>\n isDebug: DebugPredicate\n logLevels?: readonly LogLevelDefinition[]\n getHooks: () => readonly LogHook[]\n}\n\nfunction getConsoleMethod(consoleLike: ConsoleLike, method: ConsoleMethodName): (...data: unknown[]) => void {\n return consoleLike[method] ?? consoleLike.log\n}\n\nfunction createLogMethod(\n consoleLike: ConsoleLike,\n colors: Readonly<Record<string, string>>,\n isDebug: DebugPredicate,\n level: LogLevelDefinition,\n getHooks: () => readonly LogHook[],\n): LogMethod {\n return (message: string, ...args: unknown[]): void => {\n const debugValue = isDebug()\n\n if (debugValue) {\n const method = getConsoleMethod(consoleLike, level.method)\n const labelStyle = `${getForegroundStyle(colors, level.color)};font-weight: bold;`\n const messageStyle = getForegroundStyle(colors, level.color)\n method(`%c[${level.label}]%c ${message}`, labelStyle, messageStyle, ...args)\n }\n\n const hooks = getHooks()\n if (hooks.length > 0) {\n const ctx: LogHookContext = {\n level: level.name,\n label: level.label,\n message,\n args,\n isDebug: debugValue,\n }\n for (const hook of hooks) {\n hook(ctx)\n }\n }\n }\n}\n\nexport function createLoggerMethods(options: CreateLoggerMethodsOptions): Record<string, LogMethod> {\n const levels = options.logLevels ?? DEFAULT_LOG_LEVELS\n return Object.fromEntries(\n levels.map(level => [\n level.name,\n createLogMethod(options.console, options.colors, options.isDebug, level, options.getHooks),\n ]),\n )\n}\n","import type { ChalkInstance, ConsoleLike, CreateChalkOptions, DebugPredicate, LogHook } from './types'\nimport { createBannerMethods } from './banner'\nimport { createColorMap } from './colors'\nimport { add, bgColor, bold, color } from './format'\nimport { createLoggerMethods } from './logger'\n\nconst noopConsole: ConsoleLike = {\n log: () => {},\n}\n\nfunction readGlobalDebugFlag(): boolean {\n return Object.prototype.hasOwnProperty.call(globalThis, 'alitadebug')\n && Boolean(globalThis.alitadebug)\n}\n\nfunction resolveConsole(consoleLike: ConsoleLike | undefined): ConsoleLike {\n return consoleLike ?? globalThis.console ?? noopConsole\n}\n\nfunction resolveDebugPredicate(isDebug: CreateChalkOptions['isDebug']): DebugPredicate {\n if (typeof isDebug === 'function')\n return isDebug\n if (typeof isDebug === 'boolean')\n return () => isDebug\n return readGlobalDebugFlag\n}\n\nexport function createChalk(options: CreateChalkOptions = {}): ChalkInstance {\n const consoleLike = resolveConsole(options.console)\n const colors = createColorMap(options.colors)\n const isDebug = resolveDebugPredicate(options.isDebug)\n const banner = createBannerMethods(consoleLike, isDebug)\n const hooks: LogHook[] = []\n const getHooks = (): readonly LogHook[] => hooks\n const loggers = createLoggerMethods({\n console: consoleLike,\n colors,\n isDebug,\n logLevels: options.logLevels,\n getHooks,\n })\n\n const instance: ChalkInstance = {\n add,\n bold,\n ...banner,\n black: text => color(colors, 'black', text),\n red: text => color(colors, 'red', text),\n green: text => color(colors, 'green', text),\n yellow: text => color(colors, 'yellow', text),\n blue: text => color(colors, 'blue', text),\n magenta: text => color(colors, 'magenta', text),\n cyan: text => color(colors, 'cyan', text),\n white: text => color(colors, 'white', text),\n bgBlack: text => bgColor(colors, 'black', text),\n bgRed: text => bgColor(colors, 'red', text),\n bgGreen: text => bgColor(colors, 'green', text),\n bgYellow: text => bgColor(colors, 'yellow', text),\n bgBlue: text => bgColor(colors, 'blue', text),\n bgMagenta: text => bgColor(colors, 'magenta', text),\n bgCyan: text => bgColor(colors, 'cyan', text),\n bgWhite: text => bgColor(colors, 'white', text),\n color: (name, text) => color(colors, name, text),\n bgColor: (name, text) => bgColor(colors, name, text),\n log: loggers.log,\n wait: loggers.wait,\n error: loggers.error,\n warn: loggers.warn,\n ready: loggers.ready,\n info: loggers.info,\n event: loggers.event,\n debug: loggers.debug,\n use(hook: LogHook): ChalkInstance {\n hooks.push(hook)\n return instance\n },\n }\n\n return instance\n}\n","import { createColorMap } from './colors'\nimport { createChalk } from './create'\nimport { add, bgColor as bgColorWithMap, bold, color as colorWithMap } from './format'\n\nconst defaultColors = createColorMap()\n\nexport const chalk = createChalk()\n\nexport { add, bold, createChalk }\nexport { createColorMap, DEFAULT_COLORS, getBackgroundStyle, getForegroundStyle, resolveColor } from './colors'\nexport type {\n ChalkInstance,\n ColorMap,\n ColorName,\n ConsoleLike,\n CreateChalkOptions,\n CustomColorMap,\n FormattedText,\n LogHook,\n LogHookContext,\n LogLevelDefinition,\n LogMethod,\n PublicColorName,\n TextFormatter,\n} from './types'\n\nexport function color(name: string, text: string) {\n return colorWithMap(defaultColors, name, text)\n}\n\nexport function bgColor(name: string, text: string) {\n return bgColorWithMap(defaultColors, name, text)\n}\n\nexport default chalk\n"],"mappings":";;;;AAKA,MAAaA,iBAA2B;CACtC,OAAO;CACP,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,SAAS;CACT,MAAM;CACN,OAAO;CACP,MAAM;CACP;;;;;AAMD,MAAaC,iBAAuC;CAAE,OAAO;CAAM,MAAM;CAAM;AAI/E,SAAgB,eAAe,eAA+B,EAAE,EAAsC;AACpG,QAAO;EACL,GAAG;EACH,GAAG;EACJ;;AAGH,SAAgB,aAAa,QAA0C,MAAsB;CAC3F,MAAMC,UAAQ,OAAO;AACrB,KAAIA,YAAU,OACZ,OAAM,IAAI,MAAM,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AAK;;AAGlD,kBAAe"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["DEFAULT_COLORS: ColorMap","ctx: LogHookContext","noopConsole: ConsoleLike","hooks: LogHook[]","instance: ChalkInstance"],"sources":["../src/banner.ts","../src/colors.ts","../src/format.ts","../src/logger.ts","../src/create.ts","../src/index.ts"],"sourcesContent":["import type { ConsoleLike, DebugPredicate } from './types'\n\nexport interface BannerMethods {\n hello: (title: string, version: string) => void\n image: (url: string) => void\n}\n\nexport function createBannerMethods(consoleLike: ConsoleLike, isDebug: DebugPredicate): BannerMethods {\n return {\n hello(title: string, version: string): void {\n if (!isDebug())\n return\n consoleLike.log(\n `%c ${title} %c V${version} `,\n 'padding: 2px 1px; border-radius: 3px 0 0 3px; color: #cad3f5; background: #494d64; font-weight: bold;',\n 'padding: 2px 1px; border-radius: 0 3px 3px 0; color: #24273a; background: #a6da95; font-weight: bold;',\n )\n },\n image(url: string): void {\n if (!url)\n return\n if (!isDebug())\n return\n consoleLike.log(\n '%c ',\n `font-size: 1px; padding: 100px 100px; background: url(${url}) no-repeat center / contain; color: transparent;`,\n )\n },\n }\n}\n","import type { ChalkMode, ColorMap } from './types'\n\n/**\n * Catppuccin Macchiato palette — https://catppuccin.com/palette/\n */\nexport const DEFAULT_COLORS: ColorMap = {\n black: '#24273a', // Base\n red: '#ed8796', // Red\n green: '#a6da95', // Green\n yellow: '#eed49f', // Yellow\n blue: '#8aadf4', // Blue\n magenta: '#c6a0f6', // Mauve\n cyan: '#8bd5ca', // Teal\n white: '#cad3f5', // Text\n gray: '#6e738d', // Overlay0\n}\n\nexport function resolveColor(colors: Readonly<Record<string, string>>, name: string): string {\n const color = colors[name]\n if (color === undefined)\n throw new Error(`Unknown chalk color: ${name}`)\n return color\n}\n\nexport function getForegroundStyle(colors: Readonly<Record<string, string>>, name: string): string {\n const hex = resolveColor(colors, name)\n return `color:${hex}`\n}\n\nexport function getBackgroundStyle(colors: Readonly<Record<string, string>>, name: string): string {\n const hex = resolveColor(colors, name)\n const textColor = name === 'black' ? (colors.blue ?? '#8aadf4') : '#24273a'\n return `padding: 2px 4px; border-radius: 3px; color: ${textColor}; font-weight: bold; background:${hex};`\n}\n\nexport function getStyle(colors: Readonly<Record<string, string>>, name: string, mode: ChalkMode): string {\n return mode === 'background'\n ? getBackgroundStyle(colors, name)\n : getForegroundStyle(colors, name)\n}\n","import type { ChalkMode, FormattedText } from './types'\nimport { DEFAULT_COLORS, getStyle } from './colors'\n\nexport function formatText(text: string, style: string): FormattedText {\n return [`%c${text}`, style]\n}\n\nexport function coloredText(name: string, text: string, mode: ChalkMode): FormattedText {\n return formatText(text, getStyle(DEFAULT_COLORS, name, mode))\n}\n\nexport function bold(text: string): FormattedText {\n return formatText(text, 'font-weight: bold;')\n}\n\nexport function add(...items: readonly FormattedText[]): FormattedText {\n if (items.length === 0)\n return ['%c', '']\n const template = items.map(item => ` ${item[0]}`).join('')\n const styles = items.flatMap(([, ...itemStyles]) => itemStyles)\n return [template, ...styles] as FormattedText\n}\n","import type { ChalkMode, ConsoleLike, ConsoleMethodName, DebugPredicate, LogHook, LogHookContext, LogLevelDefinition, LogMethod } from './types'\nimport { DEFAULT_COLORS, getStyle } from './colors'\n\nexport const DEFAULT_LOG_LEVELS = [\n { name: 'log', label: 'Log', color: 'black', method: 'log' },\n { name: 'wait', label: 'Wait', color: 'cyan', method: 'log' },\n { name: 'error', label: 'Error', color: 'red', method: 'error' },\n { name: 'warn', label: 'Warn', color: 'yellow', method: 'warn' },\n { name: 'ready', label: 'Ready', color: 'green', method: 'log' },\n { name: 'info', label: 'Info', color: 'blue', method: 'info' },\n { name: 'event', label: 'Event', color: 'magenta', method: 'log' },\n { name: 'debug', label: 'Debug', color: 'gray', method: 'debug' },\n] satisfies readonly LogLevelDefinition[]\n\nexport interface CreateLoggerMethodsOptions {\n console: ConsoleLike\n mode: ChalkMode\n isDebug: DebugPredicate\n logLevels?: readonly LogLevelDefinition[]\n getHooks: () => readonly LogHook[]\n}\n\nfunction getConsoleMethod(consoleLike: ConsoleLike, method: ConsoleMethodName): (...data: unknown[]) => void {\n return consoleLike[method] ?? consoleLike.log\n}\n\nfunction createLogMethod(\n consoleLike: ConsoleLike,\n isDebug: DebugPredicate,\n level: LogLevelDefinition,\n mode: ChalkMode,\n getHooks: () => readonly LogHook[],\n): LogMethod {\n return (message: string, ...args: unknown[]): void => {\n const debugValue = isDebug()\n\n if (debugValue) {\n const method = getConsoleMethod(consoleLike, level.method)\n const style = getStyle(DEFAULT_COLORS, level.color, mode)\n method(`%c[${level.label}]%c ${message}`, style, style, ...args)\n }\n\n const hooks = getHooks()\n if (hooks.length > 0) {\n const ctx: LogHookContext = {\n level: level.name,\n label: level.label,\n message,\n args,\n isDebug: debugValue,\n }\n for (const hook of hooks) {\n hook(ctx)\n }\n }\n }\n}\n\nexport function createLoggerMethods(options: CreateLoggerMethodsOptions): Record<string, LogMethod> {\n const levels = options.logLevels ?? DEFAULT_LOG_LEVELS\n return Object.fromEntries(\n levels.map(level => [\n level.name,\n createLogMethod(options.console, options.isDebug, level, options.mode, options.getHooks),\n ]),\n )\n}\n","import type { ChalkInstance, ConsoleLike, CreateChalkOptions, DebugPredicate, LogHook } from './types'\nimport { createBannerMethods } from './banner'\nimport { add, bold, coloredText } from './format'\nimport { createLoggerMethods } from './logger'\n\nconst noopConsole: ConsoleLike = {\n log: () => {},\n}\n\nfunction readGlobalDebugFlag(): boolean {\n return Object.prototype.hasOwnProperty.call(globalThis, 'alitadebug')\n && Boolean(globalThis.alitadebug)\n}\n\nfunction resolveConsole(consoleLike: ConsoleLike | undefined): ConsoleLike {\n return consoleLike ?? globalThis.console ?? noopConsole\n}\n\nfunction resolveDebugPredicate(isDebug: CreateChalkOptions['isDebug']): DebugPredicate {\n if (typeof isDebug === 'function')\n return isDebug\n if (typeof isDebug === 'boolean')\n return () => isDebug\n return readGlobalDebugFlag\n}\n\nexport function createChalk(options: CreateChalkOptions = {}): ChalkInstance {\n const consoleLike = resolveConsole(options.console)\n const mode = options.mode ?? 'background'\n const isDebug = resolveDebugPredicate(options.isDebug)\n const banner = createBannerMethods(consoleLike, isDebug)\n const hooks: LogHook[] = []\n const getHooks = (): readonly LogHook[] => hooks\n const loggers = createLoggerMethods({\n console: consoleLike,\n mode,\n isDebug,\n logLevels: options.logLevels,\n getHooks,\n })\n\n const fg = (name: string) => (text: string) => coloredText(name, text, 'foreground')\n const bg = (name: string) => (text: string) => coloredText(name, text, 'background')\n\n const instance: ChalkInstance = {\n add,\n bold,\n ...banner,\n black: fg('black'),\n red: fg('red'),\n green: fg('green'),\n yellow: fg('yellow'),\n blue: fg('blue'),\n magenta: fg('magenta'),\n cyan: fg('cyan'),\n white: fg('white'),\n bgBlack: bg('black'),\n bgRed: bg('red'),\n bgGreen: bg('green'),\n bgYellow: bg('yellow'),\n bgBlue: bg('blue'),\n bgMagenta: bg('magenta'),\n bgCyan: bg('cyan'),\n bgWhite: bg('white'),\n log: loggers.log,\n wait: loggers.wait,\n error: loggers.error,\n warn: loggers.warn,\n ready: loggers.ready,\n info: loggers.info,\n event: loggers.event,\n debug: loggers.debug,\n use(hook: LogHook): ChalkInstance {\n hooks.push(hook)\n return instance\n },\n }\n\n return instance\n}\n","import { createChalk } from './create'\nimport { add, bold } from './format'\n\nexport const chalk = createChalk()\n\nexport { add, bold, createChalk }\nexport { DEFAULT_COLORS, getBackgroundStyle, getForegroundStyle, getStyle, resolveColor } from './colors'\nexport type {\n ChalkInstance,\n ChalkMode,\n ColorMap,\n ColorName,\n ConsoleLike,\n CreateChalkOptions,\n FormattedText,\n LogHook,\n LogHookContext,\n LogLevelDefinition,\n LogMethod,\n PublicColorName,\n TextFormatter,\n} from './types'\n\nexport default chalk\n"],"mappings":";AAOA,SAAgB,oBAAoB,aAA0B,SAAwC;AACpG,QAAO;EACL,MAAM,OAAe,SAAuB;AAC1C,OAAI,CAAC,SAAS,CACZ;AACF,eAAY,IACV,MAAM,MAAM,OAAO,QAAQ,IAC3B,yGACA,wGACD;;EAEH,M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