colorino 0.13.0 → 0.13.1
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 +52 -48
- package/package.json +21 -19
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ Colorino is different: it’s a "batteries-included" logging facade with beautif
|
|
|
41
41
|
|
|
42
42
|
## <a id="2"></a>Features
|
|
43
43
|
|
|
44
|
-
- 🎨 **Smart Theming:** Automatically detects
|
|
44
|
+
- 🎨 **Smart Theming:** Automatically detects _dark/light_ mode and applies a high‑contrast base palette by default (Dracula for dark, GitHub Light for light); opt into a coordinated theme preset when you want richer colors.
|
|
45
45
|
- 🤘 **Graceful Color Degradation**: Accepts rich colors (hex/RGB) and automatically down‑samples to the best ANSI‑16/ANSI‑256/Truecolor match for the current environment.
|
|
46
46
|
- 🤝 **Familiar API:** If you know `console.log`, you already know Colorino: all standard log levels are supported.
|
|
47
47
|
- 🔀 **Environment-Aware:** Works in **Node.js** (ANSI color and truecolor) and all major **Browsers** (CSS styles).
|
|
@@ -66,10 +66,10 @@ You can use Colorino directly in the browser without any build step.
|
|
|
66
66
|
<html>
|
|
67
67
|
<head>
|
|
68
68
|
<script type="module">
|
|
69
|
-
import { colorino } from 'https://unpkg.com/colorino/dist/browser.bundle.mjs'
|
|
69
|
+
import { colorino } from 'https://unpkg.com/colorino/dist/browser.bundle.mjs'
|
|
70
70
|
|
|
71
|
-
colorino.info('Hello from the browser!')
|
|
72
|
-
colorino.error('Something went wrong')
|
|
71
|
+
colorino.info('Hello from the browser!')
|
|
72
|
+
colorino.error('Something went wrong')
|
|
73
73
|
</script>
|
|
74
74
|
</head>
|
|
75
75
|
<body></body>
|
|
@@ -119,9 +119,10 @@ Use the factory to create as many loggers as you want (each with its own palette
|
|
|
119
119
|
import { createColorino } from 'colorino'
|
|
120
120
|
|
|
121
121
|
const myLogger = createColorino(
|
|
122
|
-
{
|
|
122
|
+
{
|
|
123
|
+
// Palette (partial)
|
|
123
124
|
error: '#ff007b',
|
|
124
|
-
info: '#3498db'
|
|
125
|
+
info: '#3498db',
|
|
125
126
|
},
|
|
126
127
|
{ disableWarnings: true } // Options (see below)
|
|
127
128
|
)
|
|
@@ -133,17 +134,17 @@ myLogger.info('Rebranded info!')
|
|
|
133
134
|
|
|
134
135
|
`createColorino(palette?, options?)` accepts:
|
|
135
136
|
|
|
136
|
-
| Option | Type
|
|
137
|
-
|
|
138
|
-
| `disableWarnings` | `boolean`
|
|
139
|
-
| `theme` | `ThemeOption` (see below)
|
|
140
|
-
| `disableOscProbe` | `boolean`
|
|
141
|
-
| `maxDepth` | `number`
|
|
137
|
+
| Option | Type | Default | Description |
|
|
138
|
+
| ----------------- | ------------------------- | -------- | -------------------------------------------------------------------------- |
|
|
139
|
+
| `disableWarnings` | `boolean` | `false` | Suppress warnings when color support can't be detected or is disabled. |
|
|
140
|
+
| `theme` | `ThemeOption` (see below) | `'auto'` | Control the active color theme or force a specific mode. |
|
|
141
|
+
| `disableOscProbe` | `boolean` | `false` | Disable OSC 11 terminal theme probing (use only env heuristics for theme). |
|
|
142
|
+
| `maxDepth` | `number` | `5` | Maximum depth when pretty-printing objects in log output. |
|
|
142
143
|
|
|
143
144
|
**`theme` accepts three types of values:**
|
|
144
145
|
|
|
145
146
|
1. **`'auto'`** (Default): Automatically detects your terminal or browser theme (dark/light) and applies the matching default preset.
|
|
146
|
-
When combined with `disableOscProbe: true`, only environment variables are used for theme detection (no OSC 11 probe).
|
|
147
|
+
When combined with `disableOscProbe: true`, only environment variables are used for theme detection (no OSC 11 probe).
|
|
147
148
|
2. **`'dark' | 'light'`**: Forces the logger into a specific mode using the default preset for that mode.
|
|
148
149
|
3. **`ThemeName`**: Forces a specific built-in palette (e.g., `'dracula'`).
|
|
149
150
|
|
|
@@ -151,12 +152,12 @@ When combined with `disableOscProbe: true`, only environment variables are used
|
|
|
151
152
|
|
|
152
153
|
Pass any of these names to the `theme` option to use a specific palette:
|
|
153
154
|
|
|
154
|
-
| Theme Name | Type
|
|
155
|
-
|
|
156
|
-
| `'dracula'` | **Dark** (High Contrast)
|
|
157
|
-
| `'catppuccin-mocha'` | **Dark** (Low Contrast)
|
|
158
|
-
| `'github-light'` | **Light** (High Contrast)| Clean, sharp, high-contrast.
|
|
159
|
-
| `'catppuccin-latte'` | **Light** (Low Contrast)
|
|
155
|
+
| Theme Name | Type | Description |
|
|
156
|
+
| -------------------- | ------------------------- | --------------------------------------- |
|
|
157
|
+
| `'dracula'` | **Dark** (High Contrast) | Vibrant pinks, purples, and cyans. |
|
|
158
|
+
| `'catppuccin-mocha'` | **Dark** (Low Contrast) | Soothing pastel colors. |
|
|
159
|
+
| `'github-light'` | **Light** (High Contrast) | Clean, sharp, high-contrast. |
|
|
160
|
+
| `'catppuccin-latte'` | **Light** (Low Contrast) | Warm, cozy light mode with soft colors. |
|
|
160
161
|
|
|
161
162
|
In auto mode, Colorino uses dracula in dark environments and github-light in light environments.
|
|
162
163
|
|
|
@@ -167,14 +168,14 @@ Set only the colors you care about; everything else uses the detected base theme
|
|
|
167
168
|
|
|
168
169
|
```typescript
|
|
169
170
|
// Only customize error and warn
|
|
170
|
-
const myLogger = createColorino({
|
|
171
|
+
const myLogger = createColorino({
|
|
171
172
|
error: '#ff007b',
|
|
172
|
-
warn: '#ffa500'
|
|
173
|
+
warn: '#ffa500',
|
|
173
174
|
})
|
|
174
175
|
|
|
175
176
|
// Detected dark terminal (uses dracula as base):
|
|
176
177
|
// - error: #ff007b (your custom red)
|
|
177
|
-
// - warn: #ffa500 (your custom orange)
|
|
178
|
+
// - warn: #ffa500 (your custom orange)
|
|
178
179
|
// - info: #8be9fd (dracula cyan)
|
|
179
180
|
// - log: #f8f8f2 (dracula foreground)
|
|
180
181
|
// - debug: #bd93f9 (dracula purple)
|
|
@@ -202,10 +203,7 @@ Overlay your own colors on top of a built-in theme.
|
|
|
202
203
|
|
|
203
204
|
```typescript
|
|
204
205
|
// Use GitHub Light but with a custom error color
|
|
205
|
-
const myLogger = createColorino(
|
|
206
|
-
{ error: '#ff007b' },
|
|
207
|
-
{ theme: 'github-light' }
|
|
208
|
-
)
|
|
206
|
+
const myLogger = createColorino({ error: '#ff007b' }, { theme: 'github-light' })
|
|
209
207
|
```
|
|
210
208
|
|
|
211
209
|
**4. Force a specific mode (uses defaults):**
|
|
@@ -241,16 +239,16 @@ myLogger.info('Still styled by theme.') // Uses the default theme color
|
|
|
241
239
|
|
|
242
240
|
Colorino auto-detects your environment and color support, but you can override behavior using these standard environment variables (compatible with Chalk):
|
|
243
241
|
|
|
244
|
-
| Variable
|
|
245
|
-
|
|
246
|
-
| `NO_COLOR`
|
|
247
|
-
| `FORCE_COLOR`
|
|
248
|
-
| `CLICOLOR`
|
|
249
|
-
| `CLICOLOR_FORCE
|
|
250
|
-
| `TERM`
|
|
251
|
-
| `COLORTERM`
|
|
252
|
-
| `WT_SESSION`
|
|
253
|
-
| `CI`
|
|
242
|
+
| Variable | Effect | Example |
|
|
243
|
+
| ---------------- | --------------------------------------------------------------------- | ------------------------------ |
|
|
244
|
+
| `NO_COLOR` | Forces no color output | `NO_COLOR=1 node app.js` |
|
|
245
|
+
| `FORCE_COLOR` | Forces color level: `0`=off, `1`=ANSI‑16, `2`=ANSI‑256, `3`=Truecolor | `FORCE_COLOR=3 node app.js` |
|
|
246
|
+
| `CLICOLOR` | `"0"` disables color | `CLICOLOR=0 node app.js` |
|
|
247
|
+
| `CLICOLOR_FORCE` | Non‑`"0"` value enables color even if not a TTY | `CLICOLOR_FORCE=1 node app.js` |
|
|
248
|
+
| `TERM` | Terminal type; may influence color support | `TERM=xterm-256color` |
|
|
249
|
+
| `COLORTERM` | `'truecolor'` or `'24bit'` enables truecolor | `COLORTERM=truecolor` |
|
|
250
|
+
| `WT_SESSION` | Enables color detection for Windows Terminal | |
|
|
251
|
+
| `CI` | Many CI platforms default to no color | `CI=1 node app.js` |
|
|
254
252
|
|
|
255
253
|
### <a id="5-6"></a>Colorize Helper (Manual Overrides)
|
|
256
254
|
|
|
@@ -269,13 +267,13 @@ When color is disabled (for example via `NO_COLOR=1` or lack of support), `color
|
|
|
269
267
|
|
|
270
268
|
## <a id="6"></a>Colorino vs. Chalk
|
|
271
269
|
|
|
272
|
-
| Feature
|
|
273
|
-
|
|
274
|
-
| Out-of-box logs
|
|
275
|
-
| Zero-config
|
|
276
|
-
| Node + browser
|
|
277
|
-
| CSS console logs
|
|
278
|
-
| Extensible / Composable
|
|
270
|
+
| Feature | 🎨 **Colorino** | 🖍️ **Chalk** |
|
|
271
|
+
| ----------------------- | ------------------------ | ----------------- |
|
|
272
|
+
| Out-of-box logs | ✔ themed, all log levels | ✘ string styling |
|
|
273
|
+
| Zero-config | ✔ | ✘ manual, per-use |
|
|
274
|
+
| Node + browser | ✔ | ✘ (Node only) |
|
|
275
|
+
| CSS console logs | ✔ | ✘ |
|
|
276
|
+
| Extensible / Composable | ✔ (via factory) | ✘ |
|
|
279
277
|
|
|
280
278
|
## <a id="7"></a>API Reference
|
|
281
279
|
|
|
@@ -310,7 +308,12 @@ Colorino is designed for composition: create a base logger via `createColorino()
|
|
|
310
308
|
This example prefixes every `.info()` and `.error()` call with best‑effort caller context (file/line) derived from a synthetic `Error` stack.
|
|
311
309
|
|
|
312
310
|
```ts
|
|
313
|
-
import {
|
|
311
|
+
import {
|
|
312
|
+
createColorino,
|
|
313
|
+
type Colorino,
|
|
314
|
+
type ColorinoOptions,
|
|
315
|
+
type Palette,
|
|
316
|
+
} from 'colorino'
|
|
314
317
|
|
|
315
318
|
function getCallerContext(): string {
|
|
316
319
|
const err = new Error()
|
|
@@ -334,15 +337,16 @@ function getCallerContext(): string {
|
|
|
334
337
|
|
|
335
338
|
export function createContextLogger(
|
|
336
339
|
palette?: Partial<Palette>,
|
|
337
|
-
options?: ColorinoOptions
|
|
340
|
+
options?: ColorinoOptions
|
|
338
341
|
): Colorino {
|
|
339
342
|
const base = createColorino(palette, options)
|
|
340
343
|
|
|
341
344
|
// Inherit all default methods from the base logger...
|
|
342
|
-
const logger = Object.create(base) as Colorino // Object.create uses `base` as the prototype.
|
|
345
|
+
const logger = Object.create(base) as Colorino // Object.create uses `base` as the prototype.
|
|
343
346
|
|
|
344
347
|
// ...and override only what you need.
|
|
345
|
-
Object.assign(logger, {
|
|
348
|
+
Object.assign(logger, {
|
|
349
|
+
// Object.assign copies these methods onto `logger`.
|
|
346
350
|
info(...args: unknown[]) {
|
|
347
351
|
base.info(`[${getCallerContext()}]`, ...args)
|
|
348
352
|
},
|
|
@@ -375,4 +379,4 @@ logger.error('Failed to load user', { id: 456 })
|
|
|
375
379
|
|
|
376
380
|
## <a id="10"></a>License
|
|
377
381
|
|
|
378
|
-
[MIT](LICENSE.md)
|
|
382
|
+
[MIT](LICENSE.md)
|
package/package.json
CHANGED
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "colorino",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "A super simple colorized logger that gets the most out of your terminal",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"author": "simwai",
|
|
8
5
|
"keywords": [
|
|
6
|
+
"ansi",
|
|
9
7
|
"color",
|
|
8
|
+
"console",
|
|
10
9
|
"logger",
|
|
11
10
|
"terminal",
|
|
12
|
-
"
|
|
13
|
-
"
|
|
11
|
+
"chalk",
|
|
12
|
+
"kuler"
|
|
14
13
|
],
|
|
15
14
|
"homepage": "https://github.com/simwai/colorino",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/simwai/colorino/issues"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"author": "simwai",
|
|
16
20
|
"repository": {
|
|
17
21
|
"type": "git",
|
|
18
22
|
"url": "git+https://github.com/simwai/colorino.git"
|
|
19
23
|
},
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"LICENSE.md",
|
|
27
|
+
"package.json",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"type": "module",
|
|
23
31
|
"main": "./dist/node.cjs",
|
|
24
32
|
"module": "./dist/browser.mjs",
|
|
25
33
|
"types": "./dist/browser.d.ts",
|
|
@@ -35,12 +43,9 @@
|
|
|
35
43
|
"require": "./dist/browser.cjs"
|
|
36
44
|
}
|
|
37
45
|
},
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
"package.json",
|
|
42
|
-
"LICENSE.md"
|
|
43
|
-
],
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
},
|
|
44
49
|
"scripts": {
|
|
45
50
|
"bundle:browser": "node --loader ts-node/esm node_modules/rollup/dist/bin/rollup -c rollup.browser.config.ts",
|
|
46
51
|
"build": "unbuild && npm run bundle:browser",
|
|
@@ -76,7 +81,7 @@
|
|
|
76
81
|
"lint-staged": "^15.2.0",
|
|
77
82
|
"md-toc-cli": "^3.1.1",
|
|
78
83
|
"node-pty": "^1.1.0",
|
|
79
|
-
"oxfmt": "^0.
|
|
84
|
+
"oxfmt": "^0.23.0",
|
|
80
85
|
"oxlint": "^0.2.0",
|
|
81
86
|
"playwright": "^1.57.0",
|
|
82
87
|
"rollup": "^4.54.0",
|
|
@@ -96,8 +101,5 @@
|
|
|
96
101
|
"engines": {
|
|
97
102
|
"node": ">=17.0.0",
|
|
98
103
|
"npm": ">=8.0.0"
|
|
99
|
-
},
|
|
100
|
-
"publishConfig": {
|
|
101
|
-
"access": "public"
|
|
102
104
|
}
|
|
103
105
|
}
|