@oxog/pigment 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,74 +1,5 @@
1
- import { P as PigmentKernel, a as PigmentOptions, b as Pigment, C as ColorSupport, S as Styler, c as Platform } from './index-CLqJXFfX.cjs';
2
- export { B as BoxBorder, o as BoxChars, k as BoxPluginOptions, E as EventHandler, G as GradientPluginOptions, K as Kernel, p as KernelOptions, e as PigmentContext, f as PigmentEvents, l as PigmentPluginOptions, d as Plugin, m as SemanticPluginOptions, g as Style, h as StyleFunction, j as ThemePluginOptions, T as ThemePreset, n as ThemePresetColors, i as plugins } from './index-CLqJXFfX.cjs';
3
- export { createKernel } from '@oxog/plugin';
4
- export { MaybePromise, Unsubscribe } from '@oxog/types';
5
-
6
- /**
7
- * Builder-pattern Pigment for explicit composition.
8
- *
9
- * @example
10
- * ```typescript
11
- * const builder = new BuilderPigment(kernel);
12
- * const styled = builder.bold().red().paint('Error!');
13
- * ```
14
- */
15
- declare class BuilderPigment {
16
- private styles;
17
- constructor(_kernel: PigmentKernel);
18
- bold(): this;
19
- dim(): this;
20
- italic(): this;
21
- underline(): this;
22
- strikethrough(): this;
23
- inverse(): this;
24
- hidden(): this;
25
- reset(): this;
26
- black(): this;
27
- red(): this;
28
- green(): this;
29
- yellow(): this;
30
- blue(): this;
31
- magenta(): this;
32
- cyan(): this;
33
- white(): this;
34
- blackBright(): this;
35
- redBright(): this;
36
- greenBright(): this;
37
- yellowBright(): this;
38
- blueBright(): this;
39
- magentaBright(): this;
40
- cyanBright(): this;
41
- whiteBright(): this;
42
- gray(): this;
43
- grey(): this;
44
- bgBlack(): this;
45
- bgRed(): this;
46
- bgGreen(): this;
47
- bgYellow(): this;
48
- bgBlue(): this;
49
- bgMagenta(): this;
50
- bgCyan(): this;
51
- bgWhite(): this;
52
- bgBlackBright(): this;
53
- bgRedBright(): this;
54
- bgGreenBright(): this;
55
- bgYellowBright(): this;
56
- bgBlueBright(): this;
57
- bgMagentaBright(): this;
58
- bgCyanBright(): this;
59
- bgWhiteBright(): this;
60
- bgGray(): this;
61
- bgGrey(): this;
62
- ansi256(code: number): this;
63
- bgAnsi256(code: number): this;
64
- rgb(r: number, g: number, b: number): this;
65
- bgRgb(r: number, g: number, b: number): this;
66
- hex(color: string): this;
67
- bgHex(color: string): this;
68
- hsl(h: number, s: number, l: number): this;
69
- bgHsl(h: number, s: number, l: number): this;
70
- paint(text: string): string;
71
- }
1
+ import { P as PigmentOptions, a as PigmentInstance, b as Pigment, C as ColorSupport, S as Styler, c as Platform } from './index-DsggPsSl.cjs';
2
+ export { B as BoxBorder, d as BoxChars, e as BoxOptions, f as BoxPluginOptions, g as BuilderPigment, h as ColorInput, E as EventHandler, G as GradientPluginOptions, K as Kernel, i as KernelOptions, M as MaybePromise, j as PigmentContext, k as PigmentEvents, l as PigmentKernel, m as PigmentPluginApi, n as PigmentPluginOptions, o as Plugin, p as SemanticPluginOptions, q as Style, r as StyleFunction, T as ThemeColorType, s as ThemePluginOptions, t as ThemePreset, u as ThemePresetColors, U as Unsubscribe, v as createKernel, w as plugins } from './index-DsggPsSl.cjs';
72
3
 
73
4
  /**
74
5
  * Creates a new Pigment instance using @oxog/plugin micro-kernel.
@@ -88,7 +19,7 @@ declare class BuilderPigment {
88
19
  * forceColor: true, // Force colors
89
20
  * });
90
21
  *
91
- * // With optional plugins
22
+ * // With optional plugins: they add methods to the instance
92
23
  * import { gradientPlugin, themePlugin } from '@oxog/pigment/plugins';
93
24
  *
94
25
  * const pigment = createPigment({
@@ -97,71 +28,43 @@ declare class BuilderPigment {
97
28
  * themePlugin({ preset: 'monokai' })
98
29
  * ]
99
30
  * });
31
+ * pigment.gradient('#ff0000', '#0000ff')('Hello');
32
+ * pigment.theme.keyword('const');
100
33
  * ```
101
34
  */
102
- declare function createPigment(options?: PigmentOptions): Pigment & {
103
- builder: BuilderPigment;
104
- level: number;
105
- supportsColor: ColorSupport;
106
- };
35
+ declare function createPigment(options?: PigmentOptions): PigmentInstance;
107
36
 
37
+ declare const MODIFIER_NAMES: readonly ["bold", "dim", "italic", "underline", "strikethrough", "inverse", "hidden", "reset"];
38
+ declare const COLOR_NAMES: readonly ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "blackBright", "redBright", "greenBright", "yellowBright", "blueBright", "magentaBright", "cyanBright", "whiteBright", "gray", "grey"];
39
+ declare const BACKGROUND_COLOR_NAMES: readonly ["bgBlack", "bgRed", "bgGreen", "bgYellow", "bgBlue", "bgMagenta", "bgCyan", "bgWhite", "bgBlackBright", "bgRedBright", "bgGreenBright", "bgYellowBright", "bgBlueBright", "bgMagentaBright", "bgCyanBright", "bgWhiteBright", "bgGray", "bgGrey"];
40
+
41
+ type ColorLevel = 0 | 1 | 2 | 3;
42
+ /** Style names available as chainable properties, like chalk's. */
43
+ type ChalkStyleName = (typeof MODIFIER_NAMES)[number] | (typeof COLOR_NAMES)[number] | (typeof BACKGROUND_COLOR_NAMES)[number];
44
+ /**
45
+ * Chalk-compatible styler. Every style is a chainable, callable property
46
+ * (`chalk.red.bold('x')`), and setting `level` changes the output like chalk.
47
+ */
48
+ interface Chalk extends Record<ChalkStyleName, Pigment> {
49
+ }
108
50
  declare class Chalk {
109
- level: 0 | 1 | 2 | 3;
110
51
  supportsColor: ColorSupport;
52
+ private currentLevel;
111
53
  private pigment;
112
54
  constructor(options?: {
113
- level?: 0 | 1 | 2 | 3;
55
+ level?: ColorLevel;
114
56
  });
115
- red(text: string): string;
116
- green(text: string): string;
117
- yellow(text: string): string;
118
- blue(text: string): string;
119
- magenta(text: string): string;
120
- cyan(text: string): string;
121
- white(text: string): string;
122
- black(text: string): string;
123
- redBright(text: string): string;
124
- greenBright(text: string): string;
125
- yellowBright(text: string): string;
126
- blueBright(text: string): string;
127
- magentaBright(text: string): string;
128
- cyanBright(text: string): string;
129
- whiteBright(text: string): string;
130
- gray(text: string): string;
131
- grey(text: string): string;
132
- bgRed(text: string): string;
133
- bgGreen(text: string): string;
134
- bgYellow(text: string): string;
135
- bgBlue(text: string): string;
136
- bgMagenta(text: string): string;
137
- bgCyan(text: string): string;
138
- bgWhite(text: string): string;
139
- bgBlack(text: string): string;
140
- bgRedBright(text: string): string;
141
- bgGreenBright(text: string): string;
142
- bgYellowBright(text: string): string;
143
- bgBlueBright(text: string): string;
144
- bgMagentaBright(text: string): string;
145
- bgCyanBright(text: string): string;
146
- bgWhiteBright(text: string): string;
147
- bgGray(text: string): string;
148
- bgGrey(text: string): string;
149
- bold(text: string): string;
150
- dim(text: string): string;
151
- italic(text: string): string;
152
- underline(text: string): string;
153
- strikethrough(text: string): string;
154
- inverse(text: string): string;
155
- hidden(text: string): string;
156
- reset(text: string): string;
157
- /** Like chalk: returns the text only when colors are supported, otherwise ''. */
57
+ /** Color level (0-3). Setting it changes the output of every style. */
58
+ get level(): ColorLevel;
59
+ set level(level: ColorLevel);
60
+ /** Like chalk: returns the text only when colors are enabled, otherwise ''. */
158
61
  visible(text: string): string;
159
- rgb(r: number, g: number, b: number): (text: string) => string;
160
- bgRgb(r: number, g: number, b: number): (text: string) => string;
161
- hex(color: string): (text: string) => string;
162
- bgHex(color: string): (text: string) => string;
163
- ansi256(code: number): (text: string) => string;
164
- bgAnsi256(code: number): (text: string) => string;
62
+ rgb(r: number, g: number, b: number): Pigment;
63
+ bgRgb(r: number, g: number, b: number): Pigment;
64
+ hex(color: string): Pigment;
65
+ bgHex(color: string): Pigment;
66
+ ansi256(code: number): Pigment;
67
+ bgAnsi256(code: number): Pigment;
165
68
  }
166
69
 
167
70
  declare const chalk: Chalk;
@@ -242,10 +145,6 @@ declare function hslToRgb(h: number, s: number, l: number): {
242
145
 
243
146
  declare function rgbToAnsi256(r: number, g: number, b: number): number;
244
147
 
245
- declare const pigment: Pigment & {
246
- builder: BuilderPigment;
247
- level: number;
248
- supportsColor: ColorSupport;
249
- };
148
+ declare const pigment: PigmentInstance;
250
149
 
251
- export { BuilderPigment, ColorSupport, Pigment, PigmentKernel, PigmentOptions, Platform, Styler, bgBlack, bgBlackBright, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGray, bgGreen, bgGreenBright, bgGrey, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blackBright, blue, blueBright, bold, compose, createPigment, cyan, cyanBright, chalk as default, detectColorSupport, detectPlatform, dim, gray, green, greenBright, grey, hasTTY, hexToRgb, hidden, hslToRgb, inverse, isBrowser, isCI, isNode, isWindows, italic, magenta, magentaBright, pigment, red, redBright, reset, resetColorSupportCache, rgbToAnsi256, strikethrough, supportsColor, underline, validateHex, white, whiteBright, yellow, yellowBright };
150
+ export { ColorSupport, Pigment, PigmentInstance, PigmentOptions, Platform, Styler, bgBlack, bgBlackBright, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGray, bgGreen, bgGreenBright, bgGrey, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blackBright, blue, blueBright, bold, compose, createPigment, cyan, cyanBright, chalk as default, detectColorSupport, detectPlatform, dim, gray, green, greenBright, grey, hasTTY, hexToRgb, hidden, hslToRgb, inverse, isBrowser, isCI, isNode, isWindows, italic, magenta, magentaBright, pigment, red, redBright, reset, resetColorSupportCache, rgbToAnsi256, strikethrough, supportsColor, underline, validateHex, white, whiteBright, yellow, yellowBright };
package/dist/index.d.ts CHANGED
@@ -1,74 +1,5 @@
1
- import { P as PigmentKernel, a as PigmentOptions, b as Pigment, C as ColorSupport, S as Styler, c as Platform } from './index-CLqJXFfX.js';
2
- export { B as BoxBorder, o as BoxChars, k as BoxPluginOptions, E as EventHandler, G as GradientPluginOptions, K as Kernel, p as KernelOptions, e as PigmentContext, f as PigmentEvents, l as PigmentPluginOptions, d as Plugin, m as SemanticPluginOptions, g as Style, h as StyleFunction, j as ThemePluginOptions, T as ThemePreset, n as ThemePresetColors, i as plugins } from './index-CLqJXFfX.js';
3
- export { createKernel } from '@oxog/plugin';
4
- export { MaybePromise, Unsubscribe } from '@oxog/types';
5
-
6
- /**
7
- * Builder-pattern Pigment for explicit composition.
8
- *
9
- * @example
10
- * ```typescript
11
- * const builder = new BuilderPigment(kernel);
12
- * const styled = builder.bold().red().paint('Error!');
13
- * ```
14
- */
15
- declare class BuilderPigment {
16
- private styles;
17
- constructor(_kernel: PigmentKernel);
18
- bold(): this;
19
- dim(): this;
20
- italic(): this;
21
- underline(): this;
22
- strikethrough(): this;
23
- inverse(): this;
24
- hidden(): this;
25
- reset(): this;
26
- black(): this;
27
- red(): this;
28
- green(): this;
29
- yellow(): this;
30
- blue(): this;
31
- magenta(): this;
32
- cyan(): this;
33
- white(): this;
34
- blackBright(): this;
35
- redBright(): this;
36
- greenBright(): this;
37
- yellowBright(): this;
38
- blueBright(): this;
39
- magentaBright(): this;
40
- cyanBright(): this;
41
- whiteBright(): this;
42
- gray(): this;
43
- grey(): this;
44
- bgBlack(): this;
45
- bgRed(): this;
46
- bgGreen(): this;
47
- bgYellow(): this;
48
- bgBlue(): this;
49
- bgMagenta(): this;
50
- bgCyan(): this;
51
- bgWhite(): this;
52
- bgBlackBright(): this;
53
- bgRedBright(): this;
54
- bgGreenBright(): this;
55
- bgYellowBright(): this;
56
- bgBlueBright(): this;
57
- bgMagentaBright(): this;
58
- bgCyanBright(): this;
59
- bgWhiteBright(): this;
60
- bgGray(): this;
61
- bgGrey(): this;
62
- ansi256(code: number): this;
63
- bgAnsi256(code: number): this;
64
- rgb(r: number, g: number, b: number): this;
65
- bgRgb(r: number, g: number, b: number): this;
66
- hex(color: string): this;
67
- bgHex(color: string): this;
68
- hsl(h: number, s: number, l: number): this;
69
- bgHsl(h: number, s: number, l: number): this;
70
- paint(text: string): string;
71
- }
1
+ import { P as PigmentOptions, a as PigmentInstance, b as Pigment, C as ColorSupport, S as Styler, c as Platform } from './index-DsggPsSl.js';
2
+ export { B as BoxBorder, d as BoxChars, e as BoxOptions, f as BoxPluginOptions, g as BuilderPigment, h as ColorInput, E as EventHandler, G as GradientPluginOptions, K as Kernel, i as KernelOptions, M as MaybePromise, j as PigmentContext, k as PigmentEvents, l as PigmentKernel, m as PigmentPluginApi, n as PigmentPluginOptions, o as Plugin, p as SemanticPluginOptions, q as Style, r as StyleFunction, T as ThemeColorType, s as ThemePluginOptions, t as ThemePreset, u as ThemePresetColors, U as Unsubscribe, v as createKernel, w as plugins } from './index-DsggPsSl.js';
72
3
 
73
4
  /**
74
5
  * Creates a new Pigment instance using @oxog/plugin micro-kernel.
@@ -88,7 +19,7 @@ declare class BuilderPigment {
88
19
  * forceColor: true, // Force colors
89
20
  * });
90
21
  *
91
- * // With optional plugins
22
+ * // With optional plugins: they add methods to the instance
92
23
  * import { gradientPlugin, themePlugin } from '@oxog/pigment/plugins';
93
24
  *
94
25
  * const pigment = createPigment({
@@ -97,71 +28,43 @@ declare class BuilderPigment {
97
28
  * themePlugin({ preset: 'monokai' })
98
29
  * ]
99
30
  * });
31
+ * pigment.gradient('#ff0000', '#0000ff')('Hello');
32
+ * pigment.theme.keyword('const');
100
33
  * ```
101
34
  */
102
- declare function createPigment(options?: PigmentOptions): Pigment & {
103
- builder: BuilderPigment;
104
- level: number;
105
- supportsColor: ColorSupport;
106
- };
35
+ declare function createPigment(options?: PigmentOptions): PigmentInstance;
107
36
 
37
+ declare const MODIFIER_NAMES: readonly ["bold", "dim", "italic", "underline", "strikethrough", "inverse", "hidden", "reset"];
38
+ declare const COLOR_NAMES: readonly ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "blackBright", "redBright", "greenBright", "yellowBright", "blueBright", "magentaBright", "cyanBright", "whiteBright", "gray", "grey"];
39
+ declare const BACKGROUND_COLOR_NAMES: readonly ["bgBlack", "bgRed", "bgGreen", "bgYellow", "bgBlue", "bgMagenta", "bgCyan", "bgWhite", "bgBlackBright", "bgRedBright", "bgGreenBright", "bgYellowBright", "bgBlueBright", "bgMagentaBright", "bgCyanBright", "bgWhiteBright", "bgGray", "bgGrey"];
40
+
41
+ type ColorLevel = 0 | 1 | 2 | 3;
42
+ /** Style names available as chainable properties, like chalk's. */
43
+ type ChalkStyleName = (typeof MODIFIER_NAMES)[number] | (typeof COLOR_NAMES)[number] | (typeof BACKGROUND_COLOR_NAMES)[number];
44
+ /**
45
+ * Chalk-compatible styler. Every style is a chainable, callable property
46
+ * (`chalk.red.bold('x')`), and setting `level` changes the output like chalk.
47
+ */
48
+ interface Chalk extends Record<ChalkStyleName, Pigment> {
49
+ }
108
50
  declare class Chalk {
109
- level: 0 | 1 | 2 | 3;
110
51
  supportsColor: ColorSupport;
52
+ private currentLevel;
111
53
  private pigment;
112
54
  constructor(options?: {
113
- level?: 0 | 1 | 2 | 3;
55
+ level?: ColorLevel;
114
56
  });
115
- red(text: string): string;
116
- green(text: string): string;
117
- yellow(text: string): string;
118
- blue(text: string): string;
119
- magenta(text: string): string;
120
- cyan(text: string): string;
121
- white(text: string): string;
122
- black(text: string): string;
123
- redBright(text: string): string;
124
- greenBright(text: string): string;
125
- yellowBright(text: string): string;
126
- blueBright(text: string): string;
127
- magentaBright(text: string): string;
128
- cyanBright(text: string): string;
129
- whiteBright(text: string): string;
130
- gray(text: string): string;
131
- grey(text: string): string;
132
- bgRed(text: string): string;
133
- bgGreen(text: string): string;
134
- bgYellow(text: string): string;
135
- bgBlue(text: string): string;
136
- bgMagenta(text: string): string;
137
- bgCyan(text: string): string;
138
- bgWhite(text: string): string;
139
- bgBlack(text: string): string;
140
- bgRedBright(text: string): string;
141
- bgGreenBright(text: string): string;
142
- bgYellowBright(text: string): string;
143
- bgBlueBright(text: string): string;
144
- bgMagentaBright(text: string): string;
145
- bgCyanBright(text: string): string;
146
- bgWhiteBright(text: string): string;
147
- bgGray(text: string): string;
148
- bgGrey(text: string): string;
149
- bold(text: string): string;
150
- dim(text: string): string;
151
- italic(text: string): string;
152
- underline(text: string): string;
153
- strikethrough(text: string): string;
154
- inverse(text: string): string;
155
- hidden(text: string): string;
156
- reset(text: string): string;
157
- /** Like chalk: returns the text only when colors are supported, otherwise ''. */
57
+ /** Color level (0-3). Setting it changes the output of every style. */
58
+ get level(): ColorLevel;
59
+ set level(level: ColorLevel);
60
+ /** Like chalk: returns the text only when colors are enabled, otherwise ''. */
158
61
  visible(text: string): string;
159
- rgb(r: number, g: number, b: number): (text: string) => string;
160
- bgRgb(r: number, g: number, b: number): (text: string) => string;
161
- hex(color: string): (text: string) => string;
162
- bgHex(color: string): (text: string) => string;
163
- ansi256(code: number): (text: string) => string;
164
- bgAnsi256(code: number): (text: string) => string;
62
+ rgb(r: number, g: number, b: number): Pigment;
63
+ bgRgb(r: number, g: number, b: number): Pigment;
64
+ hex(color: string): Pigment;
65
+ bgHex(color: string): Pigment;
66
+ ansi256(code: number): Pigment;
67
+ bgAnsi256(code: number): Pigment;
165
68
  }
166
69
 
167
70
  declare const chalk: Chalk;
@@ -242,10 +145,6 @@ declare function hslToRgb(h: number, s: number, l: number): {
242
145
 
243
146
  declare function rgbToAnsi256(r: number, g: number, b: number): number;
244
147
 
245
- declare const pigment: Pigment & {
246
- builder: BuilderPigment;
247
- level: number;
248
- supportsColor: ColorSupport;
249
- };
148
+ declare const pigment: PigmentInstance;
250
149
 
251
- export { BuilderPigment, ColorSupport, Pigment, PigmentKernel, PigmentOptions, Platform, Styler, bgBlack, bgBlackBright, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGray, bgGreen, bgGreenBright, bgGrey, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blackBright, blue, blueBright, bold, compose, createPigment, cyan, cyanBright, chalk as default, detectColorSupport, detectPlatform, dim, gray, green, greenBright, grey, hasTTY, hexToRgb, hidden, hslToRgb, inverse, isBrowser, isCI, isNode, isWindows, italic, magenta, magentaBright, pigment, red, redBright, reset, resetColorSupportCache, rgbToAnsi256, strikethrough, supportsColor, underline, validateHex, white, whiteBright, yellow, yellowBright };
150
+ export { ColorSupport, Pigment, PigmentInstance, PigmentOptions, Platform, Styler, bgBlack, bgBlackBright, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGray, bgGreen, bgGreenBright, bgGrey, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blackBright, blue, blueBright, bold, compose, createPigment, cyan, cyanBright, chalk as default, detectColorSupport, detectPlatform, dim, gray, green, greenBright, grey, hasTTY, hexToRgb, hidden, hslToRgb, inverse, isBrowser, isCI, isNode, isWindows, italic, magenta, magentaBright, pigment, red, redBright, reset, resetColorSupportCache, rgbToAnsi256, strikethrough, supportsColor, underline, validateHex, white, whiteBright, yellow, yellowBright };