@oxog/pigment 1.1.0 → 1.1.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/dist/index.d.cts CHANGED
@@ -1,75 +1,8 @@
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';
1
+ import { P as PigmentOptions, a as PigmentInstance, b as Pigment, C as ColorSupport, S as Styler, c as Platform } from './index-C_LwyWae.cjs';
2
+ export { k as BoxBorder, q as BoxChars, v as BoxOptions, m as BoxPluginOptions, B as BuilderPigment, t as ColorInput, E as EventHandler, G as GradientPluginOptions, K as Kernel, r as KernelOptions, f as PigmentContext, g as PigmentEvents, e as PigmentKernel, s as PigmentPluginApi, n as PigmentPluginOptions, d as Plugin, o as SemanticPluginOptions, h as Style, j as StyleFunction, u as ThemeColorType, l as ThemePluginOptions, T as ThemePreset, p as ThemePresetColors, i as plugins } from './index-C_LwyWae.cjs';
3
3
  export { createKernel } from '@oxog/plugin';
4
4
  export { MaybePromise, Unsubscribe } from '@oxog/types';
5
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
- }
72
-
73
6
  /**
74
7
  * Creates a new Pigment instance using @oxog/plugin micro-kernel.
75
8
  *
@@ -88,7 +21,7 @@ declare class BuilderPigment {
88
21
  * forceColor: true, // Force colors
89
22
  * });
90
23
  *
91
- * // With optional plugins
24
+ * // With optional plugins: they add methods to the instance
92
25
  * import { gradientPlugin, themePlugin } from '@oxog/pigment/plugins';
93
26
  *
94
27
  * const pigment = createPigment({
@@ -97,71 +30,43 @@ declare class BuilderPigment {
97
30
  * themePlugin({ preset: 'monokai' })
98
31
  * ]
99
32
  * });
33
+ * pigment.gradient('#ff0000', '#0000ff')('Hello');
34
+ * pigment.theme.keyword('const');
100
35
  * ```
101
36
  */
102
- declare function createPigment(options?: PigmentOptions): Pigment & {
103
- builder: BuilderPigment;
104
- level: number;
105
- supportsColor: ColorSupport;
106
- };
37
+ declare function createPigment(options?: PigmentOptions): PigmentInstance;
107
38
 
39
+ declare const MODIFIER_NAMES: readonly ["bold", "dim", "italic", "underline", "strikethrough", "inverse", "hidden", "reset"];
40
+ declare const COLOR_NAMES: readonly ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "blackBright", "redBright", "greenBright", "yellowBright", "blueBright", "magentaBright", "cyanBright", "whiteBright", "gray", "grey"];
41
+ declare const BACKGROUND_COLOR_NAMES: readonly ["bgBlack", "bgRed", "bgGreen", "bgYellow", "bgBlue", "bgMagenta", "bgCyan", "bgWhite", "bgBlackBright", "bgRedBright", "bgGreenBright", "bgYellowBright", "bgBlueBright", "bgMagentaBright", "bgCyanBright", "bgWhiteBright", "bgGray", "bgGrey"];
42
+
43
+ type ColorLevel = 0 | 1 | 2 | 3;
44
+ /** Style names available as chainable properties, like chalk's. */
45
+ type ChalkStyleName = (typeof MODIFIER_NAMES)[number] | (typeof COLOR_NAMES)[number] | (typeof BACKGROUND_COLOR_NAMES)[number];
46
+ /**
47
+ * Chalk-compatible styler. Every style is a chainable, callable property
48
+ * (`chalk.red.bold('x')`), and setting `level` changes the output like chalk.
49
+ */
50
+ interface Chalk extends Record<ChalkStyleName, Pigment> {
51
+ }
108
52
  declare class Chalk {
109
- level: 0 | 1 | 2 | 3;
110
53
  supportsColor: ColorSupport;
54
+ private currentLevel;
111
55
  private pigment;
112
56
  constructor(options?: {
113
- level?: 0 | 1 | 2 | 3;
57
+ level?: ColorLevel;
114
58
  });
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 ''. */
59
+ /** Color level (0-3). Setting it changes the output of every style. */
60
+ get level(): ColorLevel;
61
+ set level(level: ColorLevel);
62
+ /** Like chalk: returns the text only when colors are enabled, otherwise ''. */
158
63
  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;
64
+ rgb(r: number, g: number, b: number): Pigment;
65
+ bgRgb(r: number, g: number, b: number): Pigment;
66
+ hex(color: string): Pigment;
67
+ bgHex(color: string): Pigment;
68
+ ansi256(code: number): Pigment;
69
+ bgAnsi256(code: number): Pigment;
165
70
  }
166
71
 
167
72
  declare const chalk: Chalk;
@@ -242,10 +147,6 @@ declare function hslToRgb(h: number, s: number, l: number): {
242
147
 
243
148
  declare function rgbToAnsi256(r: number, g: number, b: number): number;
244
149
 
245
- declare const pigment: Pigment & {
246
- builder: BuilderPigment;
247
- level: number;
248
- supportsColor: ColorSupport;
249
- };
150
+ declare const pigment: PigmentInstance;
250
151
 
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 };
152
+ 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,75 +1,8 @@
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';
1
+ import { P as PigmentOptions, a as PigmentInstance, b as Pigment, C as ColorSupport, S as Styler, c as Platform } from './index-C_LwyWae.js';
2
+ export { k as BoxBorder, q as BoxChars, v as BoxOptions, m as BoxPluginOptions, B as BuilderPigment, t as ColorInput, E as EventHandler, G as GradientPluginOptions, K as Kernel, r as KernelOptions, f as PigmentContext, g as PigmentEvents, e as PigmentKernel, s as PigmentPluginApi, n as PigmentPluginOptions, d as Plugin, o as SemanticPluginOptions, h as Style, j as StyleFunction, u as ThemeColorType, l as ThemePluginOptions, T as ThemePreset, p as ThemePresetColors, i as plugins } from './index-C_LwyWae.js';
3
3
  export { createKernel } from '@oxog/plugin';
4
4
  export { MaybePromise, Unsubscribe } from '@oxog/types';
5
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
- }
72
-
73
6
  /**
74
7
  * Creates a new Pigment instance using @oxog/plugin micro-kernel.
75
8
  *
@@ -88,7 +21,7 @@ declare class BuilderPigment {
88
21
  * forceColor: true, // Force colors
89
22
  * });
90
23
  *
91
- * // With optional plugins
24
+ * // With optional plugins: they add methods to the instance
92
25
  * import { gradientPlugin, themePlugin } from '@oxog/pigment/plugins';
93
26
  *
94
27
  * const pigment = createPigment({
@@ -97,71 +30,43 @@ declare class BuilderPigment {
97
30
  * themePlugin({ preset: 'monokai' })
98
31
  * ]
99
32
  * });
33
+ * pigment.gradient('#ff0000', '#0000ff')('Hello');
34
+ * pigment.theme.keyword('const');
100
35
  * ```
101
36
  */
102
- declare function createPigment(options?: PigmentOptions): Pigment & {
103
- builder: BuilderPigment;
104
- level: number;
105
- supportsColor: ColorSupport;
106
- };
37
+ declare function createPigment(options?: PigmentOptions): PigmentInstance;
107
38
 
39
+ declare const MODIFIER_NAMES: readonly ["bold", "dim", "italic", "underline", "strikethrough", "inverse", "hidden", "reset"];
40
+ declare const COLOR_NAMES: readonly ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "blackBright", "redBright", "greenBright", "yellowBright", "blueBright", "magentaBright", "cyanBright", "whiteBright", "gray", "grey"];
41
+ declare const BACKGROUND_COLOR_NAMES: readonly ["bgBlack", "bgRed", "bgGreen", "bgYellow", "bgBlue", "bgMagenta", "bgCyan", "bgWhite", "bgBlackBright", "bgRedBright", "bgGreenBright", "bgYellowBright", "bgBlueBright", "bgMagentaBright", "bgCyanBright", "bgWhiteBright", "bgGray", "bgGrey"];
42
+
43
+ type ColorLevel = 0 | 1 | 2 | 3;
44
+ /** Style names available as chainable properties, like chalk's. */
45
+ type ChalkStyleName = (typeof MODIFIER_NAMES)[number] | (typeof COLOR_NAMES)[number] | (typeof BACKGROUND_COLOR_NAMES)[number];
46
+ /**
47
+ * Chalk-compatible styler. Every style is a chainable, callable property
48
+ * (`chalk.red.bold('x')`), and setting `level` changes the output like chalk.
49
+ */
50
+ interface Chalk extends Record<ChalkStyleName, Pigment> {
51
+ }
108
52
  declare class Chalk {
109
- level: 0 | 1 | 2 | 3;
110
53
  supportsColor: ColorSupport;
54
+ private currentLevel;
111
55
  private pigment;
112
56
  constructor(options?: {
113
- level?: 0 | 1 | 2 | 3;
57
+ level?: ColorLevel;
114
58
  });
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 ''. */
59
+ /** Color level (0-3). Setting it changes the output of every style. */
60
+ get level(): ColorLevel;
61
+ set level(level: ColorLevel);
62
+ /** Like chalk: returns the text only when colors are enabled, otherwise ''. */
158
63
  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;
64
+ rgb(r: number, g: number, b: number): Pigment;
65
+ bgRgb(r: number, g: number, b: number): Pigment;
66
+ hex(color: string): Pigment;
67
+ bgHex(color: string): Pigment;
68
+ ansi256(code: number): Pigment;
69
+ bgAnsi256(code: number): Pigment;
165
70
  }
166
71
 
167
72
  declare const chalk: Chalk;
@@ -242,10 +147,6 @@ declare function hslToRgb(h: number, s: number, l: number): {
242
147
 
243
148
  declare function rgbToAnsi256(r: number, g: number, b: number): number;
244
149
 
245
- declare const pigment: Pigment & {
246
- builder: BuilderPigment;
247
- level: number;
248
- supportsColor: ColorSupport;
249
- };
150
+ declare const pigment: PigmentInstance;
250
151
 
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 };
152
+ 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 };