@oxog/pigment 1.0.1 → 1.1.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 +4 -1
- package/dist/{index-BE-MUtRO.d.cts → index-CLqJXFfX.d.cts} +16 -2
- package/dist/{index-BE-MUtRO.d.ts → index-CLqJXFfX.d.ts} +16 -2
- package/dist/index.cjs +542 -100
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +541 -100
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.cjs +534 -95
- package/dist/plugins/index.cjs.map +1 -1
- package/dist/plugins/index.d.cts +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +534 -95
- package/dist/plugins/index.js.map +1 -1
- package/package.json +38 -23
package/README.md
CHANGED
|
@@ -167,7 +167,7 @@ pigment.bgHsl(210, 100, 50)('Blue background');
|
|
|
167
167
|
## Environment Detection
|
|
168
168
|
|
|
169
169
|
```typescript
|
|
170
|
-
import { pigment, supportsColor } from '@oxog/pigment';
|
|
170
|
+
import { pigment, supportsColor, resetColorSupportCache } from '@oxog/pigment';
|
|
171
171
|
|
|
172
172
|
// Check color support
|
|
173
173
|
console.log(supportsColor);
|
|
@@ -175,6 +175,9 @@ console.log(supportsColor);
|
|
|
175
175
|
|
|
176
176
|
// Override level
|
|
177
177
|
const pigment = createPigment({ level: 3 });
|
|
178
|
+
|
|
179
|
+
// Reset cached detection (useful for testing)
|
|
180
|
+
resetColorSupportCache();
|
|
178
181
|
```
|
|
179
182
|
|
|
180
183
|
### Environment Variables
|
|
@@ -23,6 +23,8 @@ type Style = {
|
|
|
23
23
|
background?: boolean;
|
|
24
24
|
};
|
|
25
25
|
type Pigment = {
|
|
26
|
+
/** Returns the (styled) text when colors are supported, otherwise an empty string */
|
|
27
|
+
visible: (text: string) => string;
|
|
26
28
|
bold: Pigment;
|
|
27
29
|
dim: Pigment;
|
|
28
30
|
italic: Pigment;
|
|
@@ -102,6 +104,12 @@ interface PigmentContext {
|
|
|
102
104
|
colorSupport: ColorSupport;
|
|
103
105
|
/** Registered styles map */
|
|
104
106
|
styles?: Map<string, StyleFunction>;
|
|
107
|
+
environment?: {
|
|
108
|
+
isCI: boolean;
|
|
109
|
+
noColor: boolean;
|
|
110
|
+
forceColor: boolean;
|
|
111
|
+
term: string;
|
|
112
|
+
};
|
|
105
113
|
/** Colors map */
|
|
106
114
|
colors?: {
|
|
107
115
|
foreground: Record<string, number>;
|
|
@@ -264,12 +272,18 @@ declare function ansi256Plugin(): Plugin<PigmentContext>;
|
|
|
264
272
|
declare function trueColorPlugin(): Plugin<PigmentContext>;
|
|
265
273
|
|
|
266
274
|
/**
|
|
267
|
-
* Core plugin that
|
|
275
|
+
* Core plugin that enables nested/composed style support.
|
|
276
|
+
*
|
|
277
|
+
* Nesting is handled directly in applyStyles() by replacing inner reset codes
|
|
278
|
+
* with outer style reopeners. This plugin just sets the enabled flag for
|
|
279
|
+
* compatibility and to indicate nesting support is active.
|
|
268
280
|
*
|
|
269
281
|
* @example
|
|
270
282
|
* ```typescript
|
|
271
283
|
* const pigment = createPigment();
|
|
272
|
-
*
|
|
284
|
+
* // Nested styles work automatically:
|
|
285
|
+
* pigment.red(`Error: ${pigment.blue('details')} here`);
|
|
286
|
+
* // Output: "Error: " (red), "details" (blue), " here" (red again)
|
|
273
287
|
* ```
|
|
274
288
|
*/
|
|
275
289
|
declare function nestingPlugin(): Plugin<PigmentContext>;
|
|
@@ -23,6 +23,8 @@ type Style = {
|
|
|
23
23
|
background?: boolean;
|
|
24
24
|
};
|
|
25
25
|
type Pigment = {
|
|
26
|
+
/** Returns the (styled) text when colors are supported, otherwise an empty string */
|
|
27
|
+
visible: (text: string) => string;
|
|
26
28
|
bold: Pigment;
|
|
27
29
|
dim: Pigment;
|
|
28
30
|
italic: Pigment;
|
|
@@ -102,6 +104,12 @@ interface PigmentContext {
|
|
|
102
104
|
colorSupport: ColorSupport;
|
|
103
105
|
/** Registered styles map */
|
|
104
106
|
styles?: Map<string, StyleFunction>;
|
|
107
|
+
environment?: {
|
|
108
|
+
isCI: boolean;
|
|
109
|
+
noColor: boolean;
|
|
110
|
+
forceColor: boolean;
|
|
111
|
+
term: string;
|
|
112
|
+
};
|
|
105
113
|
/** Colors map */
|
|
106
114
|
colors?: {
|
|
107
115
|
foreground: Record<string, number>;
|
|
@@ -264,12 +272,18 @@ declare function ansi256Plugin(): Plugin<PigmentContext>;
|
|
|
264
272
|
declare function trueColorPlugin(): Plugin<PigmentContext>;
|
|
265
273
|
|
|
266
274
|
/**
|
|
267
|
-
* Core plugin that
|
|
275
|
+
* Core plugin that enables nested/composed style support.
|
|
276
|
+
*
|
|
277
|
+
* Nesting is handled directly in applyStyles() by replacing inner reset codes
|
|
278
|
+
* with outer style reopeners. This plugin just sets the enabled flag for
|
|
279
|
+
* compatibility and to indicate nesting support is active.
|
|
268
280
|
*
|
|
269
281
|
* @example
|
|
270
282
|
* ```typescript
|
|
271
283
|
* const pigment = createPigment();
|
|
272
|
-
*
|
|
284
|
+
* // Nested styles work automatically:
|
|
285
|
+
* pigment.red(`Error: ${pigment.blue('details')} here`);
|
|
286
|
+
* // Output: "Error: " (red), "details" (blue), " here" (red again)
|
|
273
287
|
* ```
|
|
274
288
|
*/
|
|
275
289
|
declare function nestingPlugin(): Plugin<PigmentContext>;
|