@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/package.json CHANGED
@@ -1,11 +1,18 @@
1
1
  {
2
2
  "name": "@oxog/pigment",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Terminal styling with micro-kernel plugin architecture, Chalk compatibility, and full @oxog ecosystem integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
9
+ "typesVersions": {
10
+ "*": {
11
+ "plugins": [
12
+ "./dist/plugins/index.d.ts"
13
+ ]
14
+ }
15
+ },
9
16
  "exports": {
10
17
  ".": {
11
18
  "import": {
@@ -28,13 +35,15 @@
28
35
  "default": "./dist/plugins/index.cjs"
29
36
  },
30
37
  "default": "./dist/plugins/index.js"
31
- }
38
+ },
39
+ "./package.json": "./package.json"
32
40
  },
33
41
  "files": [
34
42
  "dist",
35
43
  "README.md",
36
44
  "LICENSE"
37
45
  ],
46
+ "sideEffects": false,
38
47
  "scripts": {
39
48
  "build": "tsup",
40
49
  "dev": "tsup --watch",
@@ -59,7 +68,6 @@
59
68
  "ansi",
60
69
  "styling",
61
70
  "cli",
62
- "zero-dependency",
63
71
  "typescript",
64
72
  "plugin",
65
73
  "micro-kernel",
@@ -76,22 +84,23 @@
76
84
  "url": "https://github.com/ersinkoc/Pigment/issues"
77
85
  },
78
86
  "engines": {
79
- "node": ">=18.0.0"
80
- },
81
- "dependencies": {
82
- "@oxog/plugin": "^1.1.0",
83
- "@oxog/types": "^1.1.2"
87
+ "node": ">=18"
84
88
  },
85
89
  "devDependencies": {
90
+ "@arethetypeswrong/cli": "^0.18.5",
86
91
  "@eslint/js": "10.0.1",
92
+ "@oxog/plugin": "^1.1.0",
93
+ "@oxog/types": "^1.1.2",
87
94
  "@types/node": "^20.0.0",
88
- "@vitest/coverage-v8": "^2.0.0",
95
+ "@vitest/coverage-v8": "^4.1.12",
89
96
  "eslint": "10.16.0",
97
+ "globals": "^17.0.0",
90
98
  "prettier": "^3.0.0",
91
- "tsup": "^8.0.0",
92
- "typescript": "^5.0.0",
99
+ "publint": "^0.3.25",
100
+ "tsup": "^8.5.0",
101
+ "typescript": "^5.9.3",
93
102
  "typescript-eslint": "8.74.0",
94
- "vitest": "^2.0.0"
103
+ "vitest": "^4.1.12"
95
104
  },
96
105
  "publishConfig": {
97
106
  "access": "public"
@@ -1,441 +0,0 @@
1
- import { Plugin as Plugin$1, Kernel as Kernel$1 } from '@oxog/types';
2
- import { KernelInstance } from '@oxog/plugin';
3
-
4
- type PigmentOptions = {
5
- level?: 0 | 1 | 2 | 3;
6
- forceColor?: boolean;
7
- noColor?: boolean;
8
- plugins?: Plugin<PigmentContext>[];
9
- };
10
- type ColorSupport = {
11
- level: 0 | 1 | 2 | 3;
12
- hasBasic: boolean;
13
- has256: boolean;
14
- has16m: boolean;
15
- };
16
- type Styler = (text: string) => string;
17
- type Style = {
18
- name: string;
19
- code: number;
20
- open: string;
21
- close: string;
22
- type: 'modifier' | 'color';
23
- background?: boolean;
24
- };
25
- type Pigment = {
26
- /** Returns the (styled) text when colors are supported, otherwise an empty string */
27
- visible: (text: string) => string;
28
- bold: Pigment;
29
- dim: Pigment;
30
- italic: Pigment;
31
- underline: Pigment;
32
- strikethrough: Pigment;
33
- inverse: Pigment;
34
- hidden: Pigment;
35
- reset: Pigment;
36
- black: Pigment;
37
- red: Pigment;
38
- green: Pigment;
39
- yellow: Pigment;
40
- blue: Pigment;
41
- magenta: Pigment;
42
- cyan: Pigment;
43
- white: Pigment;
44
- blackBright: Pigment;
45
- redBright: Pigment;
46
- greenBright: Pigment;
47
- yellowBright: Pigment;
48
- blueBright: Pigment;
49
- magentaBright: Pigment;
50
- cyanBright: Pigment;
51
- whiteBright: Pigment;
52
- gray: Pigment;
53
- grey: Pigment;
54
- bgBlack: Pigment;
55
- bgRed: Pigment;
56
- bgGreen: Pigment;
57
- bgYellow: Pigment;
58
- bgBlue: Pigment;
59
- bgMagenta: Pigment;
60
- bgCyan: Pigment;
61
- bgWhite: Pigment;
62
- bgBlackBright: Pigment;
63
- bgRedBright: Pigment;
64
- bgGreenBright: Pigment;
65
- bgYellowBright: Pigment;
66
- bgBlueBright: Pigment;
67
- bgMagentaBright: Pigment;
68
- bgCyanBright: Pigment;
69
- bgWhiteBright: Pigment;
70
- bgGray: Pigment;
71
- bgGrey: Pigment;
72
- ansi256(code: number): Pigment;
73
- bgAnsi256(code: number): Pigment;
74
- rgb(r: number, g: number, b: number): Pigment;
75
- bgRgb(r: number, g: number, b: number): Pigment;
76
- hex(color: string): Pigment;
77
- bgHex(color: string): Pigment;
78
- hsl(h: number, s: number, l: number): Pigment;
79
- bgHsl(h: number, s: number, l: number): Pigment;
80
- (text: string): string;
81
- };
82
- /**
83
- * Plugin interface - re-exported from @oxog/types.
84
- * Use this for creating Pigment-compatible plugins.
85
- */
86
- type Plugin<TContext = unknown> = Plugin$1<TContext>;
87
- /**
88
- * Kernel interface - re-exported from @oxog/types.
89
- */
90
- type Kernel<TContext = unknown> = Kernel$1<TContext>;
91
- /**
92
- * Pigment kernel type - extended KernelInstance from @oxog/plugin.
93
- */
94
- type PigmentKernel<TContext = PigmentContext> = KernelInstance<TContext, PigmentEvents>;
95
- /**
96
- * Pigment context shared between plugins.
97
- */
98
- interface PigmentContext {
99
- /** Current color level */
100
- level: 0 | 1 | 2 | 3;
101
- /** Whether colors are enabled */
102
- enabled: boolean;
103
- /** Color support information */
104
- colorSupport: ColorSupport;
105
- /** Registered styles map */
106
- styles?: Map<string, StyleFunction>;
107
- environment?: {
108
- isCI: boolean;
109
- noColor: boolean;
110
- forceColor: boolean;
111
- term: string;
112
- };
113
- /** Colors map */
114
- colors?: {
115
- foreground: Record<string, number>;
116
- background: Record<string, number>;
117
- all: Record<string, number>;
118
- };
119
- /** Utility functions */
120
- utils?: {
121
- hexToRgb: (hex: string) => {
122
- r: number;
123
- g: number;
124
- b: number;
125
- };
126
- hslToRgb: (h: number, s: number, l: number) => {
127
- r: number;
128
- g: number;
129
- b: number;
130
- };
131
- rgbToAnsi256: (r: number, g: number, b: number) => number;
132
- detectColorSupport: (level?: 0 | 1 | 2 | 3) => ColorSupport;
133
- supportsColor: (level?: 0 | 1 | 2 | 3) => ColorSupport;
134
- };
135
- }
136
- /**
137
- * Pigment event map for type-safe events.
138
- */
139
- interface PigmentEvents {
140
- 'plugin:register': {
141
- plugin: Plugin<PigmentContext>;
142
- };
143
- 'plugin:unregister': {
144
- plugin: Plugin<PigmentContext>;
145
- };
146
- 'plugin:init': {
147
- plugin: Plugin<PigmentContext>;
148
- };
149
- 'plugin:destroy': {
150
- plugin: Plugin<PigmentContext>;
151
- };
152
- 'context:change': PigmentContext;
153
- 'style:apply': {
154
- name: string;
155
- text: string;
156
- };
157
- 'error': Error;
158
- [key: string]: unknown;
159
- }
160
- /**
161
- * Style function type.
162
- */
163
- type StyleFunction = {
164
- (text: string): string;
165
- open: string;
166
- close: string;
167
- };
168
- type ThemePreset = 'monokai' | 'dracula' | 'nord' | 'github' | 'vscode' | 'tokyo-night' | 'catppuccin' | 'one-dark' | 'solarized';
169
- type BoxBorder = 'single' | 'double' | 'rounded' | 'bold' | 'classic';
170
- type GradientPluginOptions = {
171
- steps?: number;
172
- };
173
- type ThemePluginOptions = {
174
- preset?: ThemePreset;
175
- custom?: Record<string, string>;
176
- };
177
- type BoxPluginOptions = {
178
- border?: BoxBorder;
179
- padding?: number;
180
- };
181
- type PigmentPluginOptions = {
182
- theme?: ThemePreset;
183
- level?: 0 | 1 | 2 | 3;
184
- };
185
- type Platform = {
186
- isNode: boolean;
187
- isBrowser: boolean;
188
- isWindows: boolean;
189
- isCI: boolean;
190
- hasTTY: boolean;
191
- };
192
- type ThemePresetColors = {
193
- keyword: string;
194
- string: string;
195
- number: string;
196
- comment: string;
197
- error: string;
198
- success: string;
199
- warning: string;
200
- info: string;
201
- };
202
- type SemanticPluginOptions = {
203
- success?: string;
204
- error?: string;
205
- warning?: string;
206
- info?: string;
207
- debug?: string;
208
- };
209
- type BoxChars = {
210
- tl: string;
211
- tr: string;
212
- bl: string;
213
- br: string;
214
- h: string;
215
- v: string;
216
- };
217
- type KernelOptions<TContext> = {
218
- context?: TContext;
219
- };
220
- /**
221
- * Event handler type.
222
- */
223
- type EventHandler = (data?: unknown) => void;
224
-
225
- /**
226
- * Core plugin that provides 16 base ANSI colors + bright variants.
227
- *
228
- * @example
229
- * ```typescript
230
- * const pigment = createPigment();
231
- * pigment.red('Error!');
232
- * pigment.greenBright('Success!');
233
- * ```
234
- */
235
- declare function baseColorsPlugin(): Plugin<PigmentContext>;
236
-
237
- /**
238
- * Core plugin that provides text modifiers (bold, dim, italic, etc.).
239
- *
240
- * @example
241
- * ```typescript
242
- * const pigment = createPigment();
243
- * pigment.bold('Bold text');
244
- * pigment.italic.underline('Styled text');
245
- * ```
246
- */
247
- declare function modifiersPlugin(): Plugin<PigmentContext>;
248
-
249
- /**
250
- * Core plugin that provides 256-color palette support.
251
- *
252
- * @example
253
- * ```typescript
254
- * const pigment = createPigment();
255
- * pigment.ansi256(196)('Bright red');
256
- * pigment.bgAnsi256(21)('Blue background');
257
- * ```
258
- */
259
- declare function ansi256Plugin(): Plugin<PigmentContext>;
260
-
261
- /**
262
- * Core plugin that provides RGB, HEX, and HSL color support.
263
- *
264
- * @example
265
- * ```typescript
266
- * const pigment = createPigment();
267
- * pigment.rgb(255, 136, 0)('Orange text');
268
- * pigment.hex('#FF8800')('Orange text');
269
- * pigment.hsl(30, 100, 50)('Orange text');
270
- * ```
271
- */
272
- declare function trueColorPlugin(): Plugin<PigmentContext>;
273
-
274
- /**
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.
280
- *
281
- * @example
282
- * ```typescript
283
- * const pigment = createPigment();
284
- * // Nested styles work automatically:
285
- * pigment.red(`Error: ${pigment.blue('details')} here`);
286
- * // Output: "Error: " (red), "details" (blue), " here" (red again)
287
- * ```
288
- */
289
- declare function nestingPlugin(): Plugin<PigmentContext>;
290
-
291
- /**
292
- * Core plugin that handles environment detection (NO_COLOR, FORCE_COLOR, TTY).
293
- *
294
- * Respects environment variables:
295
- * - NO_COLOR - disables all colors
296
- * - FORCE_COLOR - forces color level (0, 1, 2, 3)
297
- * - TERM - terminal type detection
298
- * - CI - CI environment detection
299
- *
300
- * @example
301
- * ```typescript
302
- * const pigment = createPigment();
303
- * // Automatically detects environment
304
- * ```
305
- */
306
- declare function environmentPlugin(): Plugin<PigmentContext>;
307
-
308
- /**
309
- * Optional plugin that provides smooth color gradients between two colors.
310
- *
311
- * @example
312
- * ```typescript
313
- * import { createPigment } from '@oxog/pigment';
314
- * import { gradientPlugin } from '@oxog/pigment/plugins';
315
- *
316
- * const pigment = createPigment({
317
- * plugins: [gradientPlugin()]
318
- * });
319
- *
320
- * pigment.gradient('red', 'blue')('Gradient text');
321
- * pigment.rainbow('Rainbow text');
322
- * ```
323
- */
324
- declare function gradientPlugin(options?: GradientPluginOptions): Plugin<PigmentContext>;
325
-
326
- /**
327
- * Optional plugin that provides predefined color themes.
328
- *
329
- * @example
330
- * ```typescript
331
- * import { createPigment } from '@oxog/pigment';
332
- * import { themePlugin } from '@oxog/pigment/plugins';
333
- *
334
- * const pigment = createPigment({
335
- * plugins: [themePlugin({ preset: 'monokai' })]
336
- * });
337
- *
338
- * pigment.theme.keyword('const');
339
- * pigment.theme.string('"hello"');
340
- * pigment.theme.error('Error!');
341
- * ```
342
- *
343
- * Available presets: monokai, dracula, nord, github, vscode, tokyo-night, catppuccin, one-dark, solarized
344
- */
345
- declare function themePlugin(options?: ThemePluginOptions): Plugin<PigmentContext>;
346
-
347
- /**
348
- * Optional plugin that provides semantic colors (success, error, warning, info, debug).
349
- *
350
- * @example
351
- * ```typescript
352
- * import { createPigment } from '@oxog/pigment';
353
- * import { semanticPlugin } from '@oxog/pigment/plugins';
354
- *
355
- * const pigment = createPigment({
356
- * plugins: [semanticPlugin()]
357
- * });
358
- *
359
- * pigment.success('✓ Task completed');
360
- * pigment.error('✗ Task failed');
361
- * pigment.warning('⚠ Check this');
362
- * pigment.info('ℹ Note');
363
- * pigment.debug('[DEBUG] value');
364
- * ```
365
- */
366
- declare function semanticPlugin(options?: SemanticPluginOptions): Plugin<PigmentContext>;
367
-
368
- /**
369
- * Optional plugin that provides box drawing with borders.
370
- *
371
- * @example
372
- * ```typescript
373
- * import { createPigment } from '@oxog/pigment';
374
- * import { boxPlugin } from '@oxog/pigment/plugins';
375
- *
376
- * const pigment = createPigment({
377
- * plugins: [boxPlugin()]
378
- * });
379
- *
380
- * pigment.box('Hello World');
381
- * // ┌─────────────┐
382
- * // │ Hello World │
383
- * // └─────────────┘
384
- *
385
- * pigment.box('Error!', { border: 'double', borderColor: 'red' });
386
- * ```
387
- */
388
- declare function boxPlugin(options?: BoxPluginOptions): Plugin<PigmentContext>;
389
-
390
- /**
391
- * Optional plugin that provides tagged template literal syntax.
392
- *
393
- * @example
394
- * ```typescript
395
- * import { createPigment } from '@oxog/pigment';
396
- * import { templatePlugin } from '@oxog/pigment/plugins';
397
- *
398
- * const pigment = createPigment({
399
- * plugins: [templatePlugin()]
400
- * });
401
- *
402
- * console.log(pigment`{red Error:} {bold ${name}} has {yellow ${count}} issues`);
403
- * ```
404
- */
405
- declare function templatePlugin(): Plugin<PigmentContext>;
406
-
407
- /**
408
- * Plugin that adds Pigment color support to any @oxog kernel.
409
- * Use this in @oxog/log, @oxog/cli, etc.
410
- *
411
- * @example
412
- * ```typescript
413
- * // In @oxog/log or @oxog/cli
414
- * import { pigmentPlugin } from '@oxog/pigment/plugins';
415
- *
416
- * const log = createLogger();
417
- * log.use(pigmentPlugin()); // Adds color support to logger
418
- *
419
- * // Now log has access to colors
420
- * log.pigment.red('Error message');
421
- * ```
422
- */
423
- declare function pigmentPlugin<TContext = unknown>(options?: PigmentPluginOptions): Plugin<TContext>;
424
-
425
- declare const index_ansi256Plugin: typeof ansi256Plugin;
426
- declare const index_baseColorsPlugin: typeof baseColorsPlugin;
427
- declare const index_boxPlugin: typeof boxPlugin;
428
- declare const index_environmentPlugin: typeof environmentPlugin;
429
- declare const index_gradientPlugin: typeof gradientPlugin;
430
- declare const index_modifiersPlugin: typeof modifiersPlugin;
431
- declare const index_nestingPlugin: typeof nestingPlugin;
432
- declare const index_pigmentPlugin: typeof pigmentPlugin;
433
- declare const index_semanticPlugin: typeof semanticPlugin;
434
- declare const index_templatePlugin: typeof templatePlugin;
435
- declare const index_themePlugin: typeof themePlugin;
436
- declare const index_trueColorPlugin: typeof trueColorPlugin;
437
- declare namespace index {
438
- export { index_ansi256Plugin as ansi256Plugin, index_baseColorsPlugin as baseColorsPlugin, index_boxPlugin as boxPlugin, index_environmentPlugin as environmentPlugin, index_gradientPlugin as gradientPlugin, index_modifiersPlugin as modifiersPlugin, index_nestingPlugin as nestingPlugin, index_pigmentPlugin as pigmentPlugin, index_semanticPlugin as semanticPlugin, index_templatePlugin as templatePlugin, index_themePlugin as themePlugin, index_trueColorPlugin as trueColorPlugin };
439
- }
440
-
441
- export { templatePlugin as A, type BoxBorder as B, type ColorSupport as C, pigmentPlugin as D, type EventHandler as E, type GradientPluginOptions as G, type Kernel as K, type PigmentKernel as P, type Styler as S, type ThemePreset as T, type PigmentOptions as a, type Pigment as b, type Platform as c, type Plugin as d, type PigmentContext as e, type PigmentEvents as f, type Style as g, type StyleFunction as h, index as i, type ThemePluginOptions as j, type BoxPluginOptions as k, type PigmentPluginOptions as l, type SemanticPluginOptions as m, type ThemePresetColors as n, type BoxChars as o, type KernelOptions as p, baseColorsPlugin as q, modifiersPlugin as r, ansi256Plugin as s, trueColorPlugin as t, nestingPlugin as u, environmentPlugin as v, gradientPlugin as w, themePlugin as x, semanticPlugin as y, boxPlugin as z };