@visulima/colorize 1.2.2 → 1.3.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/CHANGELOG.md CHANGED
@@ -1,3 +1,36 @@
1
+ ## @visulima/colorize [1.3.1](https://github.com/visulima/visulima/compare/@visulima/colorize@1.3.0...@visulima/colorize@1.3.1) (2024-03-27)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * added missing os key to package.json ([4ad1268](https://github.com/visulima/visulima/commit/4ad1268ed12cbdcf60aeb46d4c052ed1696bc150))
7
+
8
+
9
+
10
+ ### Dependencies
11
+
12
+ * **@visulima/is-ansi-color-supported:** upgraded to 2.0.2
13
+
14
+ ## @visulima/colorize [1.3.0](https://github.com/visulima/visulima/compare/@visulima/colorize@1.2.2...@visulima/colorize@1.3.0) (2024-03-04)
15
+
16
+
17
+ ### Features
18
+
19
+ * adding new gradient helper ([#324](https://github.com/visulima/visulima/issues/324)) ([49b1ab0](https://github.com/visulima/visulima/commit/49b1ab0c94b1e6c272ae41e2477b064150c9ec49))
20
+ * adding tagged template literals support ([#323](https://github.com/visulima/visulima/issues/323)) ([492e66b](https://github.com/visulima/visulima/commit/492e66b0c9eff631fdedef12cf92f9f258218c56))
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * fixed all found type issues ([eaa40d1](https://github.com/visulima/visulima/commit/eaa40d11f3fc056dfddcc25404bf109587ef2862))
26
+ * minifyWhitespace on prod build, removed @tsconfig/* configs ([410cb73](https://github.com/visulima/visulima/commit/410cb737c44c445a0479bdd49b4100d5daf2d83d))
27
+
28
+
29
+
30
+ ### Dependencies
31
+
32
+ * **@visulima/is-ansi-color-supported:** upgraded to 2.0.1
33
+
1
34
  ## @visulima/colorize [1.2.2](https://github.com/visulima/visulima/compare/@visulima/colorize@1.2.1...@visulima/colorize@1.2.2) (2024-02-28)
2
35
 
3
36
 
package/README.md CHANGED
@@ -40,6 +40,7 @@ For instance, you can use `green` to make `` green`Hello World!` `` pop, `` red`
40
40
  - `import { red } from '@visulima/colorize'` or `const { red } = require('@visulima/colorize')`
41
41
  - [Chained syntax](#chained-syntax) `red.bold.underline('text')`
42
42
  - [Template literals](#template-literals) `` red`text` ``
43
+ - String styling with [tagged template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates), see [template-literals](#tagged-template-literals)
43
44
  - [Nested **template strings**](#nested-syntax) `` red`R ${green`G`} R` ``
44
45
  - [ANSI 256 colors](#256-colors) and [Truecolor](#truecolor) (**RGB**, **HEX**) `` rgb(224, 17, 95)`Ruby` ``, `` hex('#96C')`Amethyst` ``
45
46
  - [ANSI codes](#escape-codes) as `open` and `close` property for each style `` `Hello ${red.open}World${red.close}!` ``
@@ -53,6 +54,7 @@ For instance, you can use `green` to make `` green`Hello World!` `` pop, `` red`
53
54
  - **Auto detects** color support
54
55
  - **TypeScript** support out of the box
55
56
  - Clean and focused
57
+ - [String Gradient´s](#gradient)
56
58
 
57
59
  ## Install
58
60
 
@@ -194,7 +196,7 @@ as [chalk][chalk], [colorette][colorette], [kleur][kleur].
194
196
 
195
197
  The `@visulima/colorize` supports both the `default import` and `named import`.
196
198
 
197
- ```js
199
+ ```typescript
198
200
  // default import
199
201
  import colorize from "@visulima/colorize";
200
202
 
@@ -203,7 +205,7 @@ colorize.red.bold("text");
203
205
 
204
206
  You can import named colors, styles and functions. All imported colors and styles are `chainable`.
205
207
 
206
- ```js
208
+ ```typescript
207
209
  // named import
208
210
  import { red, hex, italic } from "@visulima/colorize";
209
211
 
@@ -212,7 +214,7 @@ red.bold("text");
212
214
 
213
215
  Default import and named import can be combined.
214
216
 
215
- ```js
217
+ ```typescript
216
218
  // default and named import
217
219
  import colorize, { red } from "@visulima/colorize";
218
220
 
@@ -227,7 +229,7 @@ The `@visulima/colorize` supports both the function syntax `red('error')` and te
227
229
  The `template literals` allow you to make a complex template more readable and shorter.\
228
230
  The `function syntax` can be used to colorize a variable.
229
231
 
230
- ```js
232
+ ```typescript
231
233
  import { red, blue } from "@visulima/colorize";
232
234
 
233
235
  let message = "error";
@@ -237,11 +239,62 @@ blue`text`;
237
239
  blue`text ${message} text`;
238
240
  ```
239
241
 
242
+ ## Tagged Template Literals
243
+
244
+ The `@visulima/colorize` supports the [tagged template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates).
245
+
246
+ <!--
247
+ Modified copy of https://github.com/chalk/chalk-template/blob/main/readme.md
248
+
249
+ MIT License
250
+
251
+ Copyright (c) Josh Junon
252
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
253
+ -->
254
+
255
+ ```typescript
256
+ import template from "@visulima/colorize/template";
257
+
258
+ console.log(template`
259
+ CPU: {red ${cpu.totalPercent}%}
260
+ RAM: {green ${(ram.used / ram.total) * 100}%}
261
+ DISK: {rgb(255,131,0) ${(disk.used / disk.total) * 100}%}
262
+ `);
263
+
264
+ const miles = 18;
265
+ const calculateFeet = (miles) => miles * 5280;
266
+
267
+ console.log(template`
268
+ There are {bold 5280 feet} in a mile.
269
+ In {bold ${miles} miles}, there are {green.bold ${calculateFeet(miles)} feet}.
270
+ `);
271
+
272
+ console.log(template`
273
+ There are also {#FF0000 shorthand hex styles} for
274
+ both the {#ABCDEF foreground}, {#:123456 background},
275
+ or {#ABCDEF:123456 both}.
276
+ `);
277
+ ```
278
+
279
+ ### API
280
+
281
+ Blocks are delimited by an opening curly brace (`{`), a style, some content, and a closing curly brace (`}`).
282
+
283
+ Template styles are chained exactly like normal Colorize styles. The following two statements are equivalent:
284
+
285
+ ```typescript
286
+ import colorize from "@visulima/colorize";
287
+ import template from "@visulima/colorize/template";
288
+
289
+ console.log(colorize.bold.rgb(10, 100, 200)("Hello!"));
290
+ console.log(template`{bold.rgb(10,100,200) Hello!}`);
291
+ ```
292
+
240
293
  ## Chained syntax
241
294
 
242
295
  All colors, styles and functions are chainable. Each color or style can be combined in any order.
243
296
 
244
- ```js
297
+ ```typescript
245
298
  import { blue, bold, italic, hex } from "@visulima/colorize";
246
299
 
247
300
  blue.bold`text`;
@@ -260,7 +313,7 @@ None of the other libraries (chalk, kleur, colorette, colors.js etc.) support ne
260
313
 
261
314
  Nested template strings:
262
315
 
263
- ```js
316
+ ```typescript
264
317
  import { red, green } from "@visulima/colorize";
265
318
 
266
319
  red`red ${green`green`} red`;
@@ -268,7 +321,7 @@ red`red ${green`green`} red`;
268
321
 
269
322
  Deep nested chained styles:
270
323
 
271
- ```js
324
+ ```typescript
272
325
  import { red, green, cyan, magenta, yellow, italic, underline } from "@visulima/colorize";
273
326
 
274
327
  console.log(red(`red ${italic(`red italic ${underline(`red italic underline`)}`)} red`));
@@ -290,7 +343,7 @@ Copyright (c) 2023, webdiscus
290
343
 
291
344
  Multiline nested template strings:
292
345
 
293
- ```js
346
+ ```typescript
294
347
  import { red, green, hex, visible, inverse } from "@visulima/colorize";
295
348
 
296
349
  // defined a truecolor as the constant
@@ -342,7 +395,7 @@ Background function: `bgAnsi256(code)` has short alias `bg(code)`
342
395
 
343
396
  See [ANSI color codes](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit).
344
397
 
345
- ```js
398
+ ```typescript
346
399
  import { bold, ansi256, fg, bgAnsi256, bg } from "@visulima/colorize";
347
400
 
348
401
  // foreground color
@@ -371,7 +424,7 @@ You can use the `hex` or `rgb` format.
371
424
  Foreground function: `hex()` `rgb()`\
372
425
  Background function: `bgHex()` `bgRgb()`
373
426
 
374
- ```js
427
+ ```typescript
375
428
  import { bold, hex, rgb, bgHex, bgRgb } from "@visulima/colorize";
376
429
 
377
430
  // foreground color
@@ -401,7 +454,7 @@ Copyright (c) 2023, webdiscus
401
454
  You can use the [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) with `open`
402
455
  and `close` properties for each style.
403
456
 
404
- ```js
457
+ ```typescript
405
458
  import { green, bold } from "@visulima/colorize";
406
459
 
407
460
  // each style has `open` and `close` properties
@@ -425,7 +478,7 @@ Copyright (c) 2023, webdiscus
425
478
 
426
479
  The Colorize class contains the method `strip()` to remove all ANSI codes from string.
427
480
 
428
- ```js
481
+ ```typescript
429
482
  import colorize from "@visulima/colorize";
430
483
  // or named import
431
484
  import { strip } from "@visulima/colorize";
@@ -440,7 +493,7 @@ The variable `string` will contain the pure string without ANSI codes.
440
493
 
441
494
  Supports correct style break at the `end of line`.
442
495
 
443
- ```js
496
+ ```typescript
444
497
  import { bgGreen } from "@visulima/colorize";
445
498
 
446
499
  console.log(bgGreen`\nColorize\nNew Line\nNext New Line\n`);
@@ -525,13 +578,40 @@ If you're on Windows, do yourself a favor and use [Windows Terminal](https://git
525
578
  > ```
526
579
 
527
580
  <!--
528
- Modified table from https://github.com/webdiscus/ansis
581
+ Modified table from https://github.com/webdiscus/ansis
529
582
 
530
- ISC License
583
+ ISC License
531
584
 
532
- Copyright (c) 2023, webdiscus
585
+ Copyright (c) 2023, webdiscus
533
586
  -->
534
587
 
588
+ ## Gradient
589
+
590
+ ![gradient](__assets__/gradient.png)
591
+
592
+ The `@visulima/colorize/gradient` supports the string gradient´s, single and multi line.
593
+
594
+ ```typescript
595
+ import { gradient } from "@visulima/colorize/gradient";
596
+
597
+ console.log(gradient("red", "green", "blue")("Hello World!"));
598
+ ```
599
+
600
+ ### Multi line gradient
601
+
602
+ In some cases, you may want to apply the same horizontal gradient on each line of a long text (or a piece of ASCII art).
603
+
604
+ You can use the `multilineGradient` method of a gradient to ensure that the colors are vertically aligned.
605
+
606
+ ```typescript
607
+ import { multilineGradient, gradient } from "@visulima/colorize/gradient";
608
+
609
+ console.log(multilineGradient(["orange", "yellow"])([" __", " <(o )___", " ( ._> /", " `---'"].join("\n")));
610
+ console.log(gradient(["blue", "cyan", "blue"])("----------------"));
611
+ ```
612
+
613
+ ![duck](__assets__/gradient-multi-line.png)
614
+
535
615
  ## Benchmark
536
616
 
537
617
  [See benchmark](./__bench__/README.md)
@@ -583,6 +663,15 @@ If you would like to help take a look at the [list of issues](https://github.com
583
663
  - [kleur][kleur] - The fastest Node.js library for formatting terminal text with ANSI colors~!
584
664
  - [picocolors][picocolors] - Tiny yet powerful colors for terminal
585
665
 
666
+ Template:
667
+
668
+ - [chalk-template][chalk-template] - Terminal string styling with tagged template literals
669
+
670
+ Gradient:
671
+
672
+ - [tinygradient](https://github.com/mistic100/tinygradient) - Easily generate color gradients with an unlimited number of color stops and steps.
673
+ - [gradient-string](https://github.com/bokub/gradient-string) - Beautiful color gradients in terminal output
674
+
586
675
  ## License
587
676
 
588
677
  The visulima colorize is open-sourced software licensed under the [MIT][license-url]
@@ -601,4 +690,5 @@ The visulima colorize is open-sourced software licensed under the [MIT][license-
601
690
  [ansi-colors]: https://github.com/doowb/ansi-colors
602
691
  [kleur]: https://github.com/lukeed/kleur
603
692
  [chalk]: https://github.com/chalk/chalk
693
+ [chalk-template]: https://github.com/chalk/chalk-template
604
694
  [ansis]: https://github.com/webdiscus/ansis
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ var isAnsiColorSupported = require('@visulima/is-ansi-color-supported');
4
+
5
+ function S({onlyFirst:r=!1}={}){let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(e,r?void 0:"g")}var g=(r,e,t)=>e>r?e:r>t?t:r;var f=r=>{let e=r.replace("#","");if(e.length===3)e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2];else if(e.length!==6)return [0,0,0];let t=Number.parseInt(e,16);return [t>>16&255,t>>8&255,t&255]};var l=isAnsiColorSupported.isStdoutColorSupported()>0?(r,e)=>({close:"\x1B["+e+"m",open:"\x1B["+r+"m"}):()=>({close:"",open:""}),V=r=>l("38;5;"+r,39),E=r=>l("48;5;"+r,49),z=(r,e,t)=>l("38;2;"+r+";"+e+";"+t,39),M=(r,e,t)=>l("48;2;"+r+";"+e+";"+t,49),R={bold:l(1,22),dim:l(2,22),hidden:l(8,28),inverse:l(7,27),italic:l(3,23),overline:l(53,55),reset:l(0,0),strike:l(9,29),strikethrough:l(9,29),underline:l(4,24),visible:{close:"",open:""}},k={bgBlack:l(40,49),bgBlackBright:l(100,49),bgBlue:l(44,49),bgBlueBright:l(104,49),bgCyan:l(46,49),bgCyanBright:l(106,49),bgGray:l(100,49),bgGreen:l(42,49),bgGreenBright:l(102,49),bgGrey:l(100,49),bgMagenta:l(45,49),bgMagentaBright:l(105,49),bgRed:l(41,49),bgRedBright:l(101,49),bgWhite:l(47,49),bgWhiteBright:l(107,49),bgYellow:l(43,49),bgYellowBright:l(103,49),black:l(30,39),blackBright:l(90,39),blue:l(34,39),blueBright:l(94,39),cyan:l(36,39),cyanBright:l(96,39),gray:l(90,39),green:l(32,39),greenBright:l(92,39),grey:l(90,39),magenta:l(35,39),magentaBright:l(95,39),red:l(31,39),redBright:l(91,39),white:l(37,39),whiteBright:l(97,39),yellow:l(33,39),yellowBright:l(93,39)},w={bg:r=>E(g(r,0,255)),bgHex:r=>M(...f(r)),bgRgb:(r,e,t)=>M(g(r,0,255),g(e,0,255),g(t,0,255)),fg:r=>V(g(r,0,255)),hex:r=>z(...f(r)),rgb:(r,e,t)=>z(g(r,0,255),g(e,0,255),g(t,0,255))};var H=(r,e,t)=>{if(e==="")return r;let n=r.indexOf(e);if(n<0)return r;let o=e.length,s=0,i="";for(;~n;)i+=r.slice(s,n)+t,s=n+o,n=r.indexOf(e,s);return i+r.slice(s)};var h={},B=null,L=(r,e,t)=>{if(!r)return "";let n=r.raw==null?r+"":String.raw(r,...e);if(n.includes("\x1B"))for(let o=t;o;o=o.props)n=H(n,o.close,o.open);return n.includes(`
6
+ `)&&(n=n.replace(/(\r*\n)/g,t.closeStack+"$1"+t.openStack)),t.openStack+n+t.closeStack},x=({props:r},{close:e,open:t})=>{let n=(r?.openStack??"")+t,o=e+(r?.closeStack??""),s=(i,...u)=>L(i,u,s.props);return Object.setPrototypeOf(s,B),s.props={close:e,closeStack:o,open:t,openStack:n,props:r},s.open=n,s.close=o,s},Z=function(){let r=e=>e+"";r.strip=e=>e.replaceAll(S(),"");for(let e in k)h[e]={get(){let t=x(this,k[e]);return Object.defineProperty(this,e,{value:t}),t}};for(let e in R)h[e]={get(){let t=x(this,R[e]);return Object.defineProperty(this,e,{value:t}),t}};return B=Object.defineProperties({},h),Object.setPrototypeOf(r,B),r};for(let r in w)h[r]={get(){return (...e)=>x(this,w[r](...e))}};h.ansi256=h.fg;h.bgAnsi256=h.bg;var I=Z;var v={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};var G=(r,e)=>{let t=r.length;if(e=Number.parseInt(e.toString(),10),Number.isNaN(e)||e<2)throw new Error("Invalid number of steps (< 2)");if(e<t)throw new Error("Number of steps cannot be inferior to number of stops");let n=[];for(let s=1;s<t;s++){let i=(e-1)*(r[s].position-r[s-1].position);n.push(Math.max(1,Math.round(i)));}let o=1;for(let s=t-1;s--;)o+=n[s];for(;o!==e;)if(o<e){let s=Math.min(...n);n[n.indexOf(s)]++,o++;}else {let s=Math.max(...n);n[n.indexOf(s)]--,o--;}return n};var P=(r,e,t)=>{let n=0,o=0,s=0,i=Math.floor(r/60),u=r/60-i,a=t*(1-e),p=t*(1-u*e),b=t*(1-(1-u)*e);return i%6===0?(n=t,o=b,s=a):i%6===1?(n=p,o=t,s=a):i%6===2?(n=a,o=t,s=b):i%6===3?(n=a,o=p,s=t):i%6===4?(n=b,o=a,s=t):i%6===5&&(n=t,o=a,s=p),{b:Math.round(s*255),g:Math.round(o*255),r:Math.round(n*255)}};var O=({b:r,g:e,r:t})=>{let n,o,s,i=0,u=0;t/=255,e/=255,r/=255;let a=Math.max(t,e,r),p=a-Math.min(t,e,r),b=c=>(a-c)/6/p+1/2;return p!==0&&(u=p/a,n=b(t),o=b(e),s=b(r),a===t?i=s-o:a===e?i=.3333333333333333+n-s:a===r&&(i=.6666666666666666+o-n),i<0?i+=1:i>1&&(i-=1)),{h:i*360,s:u,v:a}};var W={b:256,g:256,r:256},X={h:360,s:1,v:1},D=(r,e,t)=>{let n={};for(let o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=t===0?0:(e[o]-r[o])/t);return n},N=(r,e,t,n)=>{let o={};for(let s in e)Object.prototype.hasOwnProperty.call(e,s)&&(o[s]=r[s]*t+e[s],o[s]=o[s]<0?o[s]+n[s]:n[s]===1?o[s]:o[s]%n[s]);return o},C=(r,e,t)=>{let n={b:r.color[2],g:r.color[1],r:r.color[0]},o={b:e.color[2],g:e.color[1],r:e.color[0]},s=D(n,o,t),i=[{...n}];for(let u=1;u<t;u++){let a=N(s,n,u,W);i.push({b:Math.floor(a.b),g:Math.floor(a.g),r:Math.floor(a.r)});}return i},A=(r,e,t,n)=>{let o=O({b:r.color[2],g:r.color[1],r:r.color[0]}),s=O({b:e.color[2],g:e.color[1],r:e.color[0]});if(o.s===0||s.s===0)return C(r,e,t);let i;if(typeof n=="boolean")i=n;else {let b=o.h<s.h&&s.h-o.h<180||o.h>s.h&&o.h-s.h>180;i=n==="long"&&b||n==="short"&&!b;}let u=D(o,s,t),a=[{b:r.color[2],g:r.color[1],r:r.color[0]}],p;o.h<=s.h&&!i||o.h>=s.h&&i?p=s.h-o.h:i?p=360-s.h+o.h:p=360-o.h+s.h,u.h=(-1)**(i?1:0)*Math.abs(p)/t;for(let b=1;b<t;b++){let c=N(u,o,b,X);a.push(P(c.h,c.s,c.v));}return a};var y=class r{#e;stops;constructor(e,t){if(this.#e=e,this.stops=[],t.length<2)throw new Error("Invalid number of stops (< 2)");let n=t[0].position!==void 0,o=t.length,s=-1,i=!1;for(let[u,a]of t.entries()){let p={},b=a.position!==void 0;if(n!==b)throw new Error("Cannot mix positioned and non-positioned color stops");if(b){let c=a,d=c.color!==void 0;if(!d&&(i||u===0||u===o-1))throw new Error("Cannot define two consecutive position-only stops");i=!d;let m;if(d&&(Array.isArray(c.color)?m=c.color:typeof c.color=="string"?m=c.color.includes("#")?f(c.color):v[c.color]:c.color.r!==void 0&&c.color.g!==void 0&&c.color.b&&(m=[c.color.r,c.color.g,c.color.b])),p={color:m,colorLess:!d,position:c.position},p.position<0||p.position>1)throw new Error("Color stops positions must be between 0 and 1");if(p.position<s)throw new Error("Color stops positions are not ordered");s=p.position;}else if(Array.isArray(a))p={color:a,position:u/(o-1)};else if(typeof a=="string")p={color:a.includes("#")?f(a):v[a],position:u/(o-1)};else if(a.r!==void 0&&a.g!==void 0&&a.b!==void 0)p={color:[a.r,a.g,a.b],position:u/(o-1)};else throw new Error("Invalid color stop");this.stops.push(p);}this.stops[0].position!==0&&(this.stops.unshift({color:this.stops[0].color,position:0}),o++),this.stops[o-1].position!==1&&this.stops.push({color:this.stops[o-1].color,position:1});}reverse(){let e=[];for(let t of this.stops){let n={...t};n.position=1-t.position,e.push(n);}return new r(this.#e,e.reverse())}loop(){let e=[],t=[];for(let n of this.stops)e.push({color:n.color,position:(n.position||0)/2});for(let n of this.stops.slice(0,-1))t.push({color:n.color,position:1-(n.position||0)/2});return new r(this.#e,[...e,...t.reverse()])}rgb(e){let t=G(this.stops,e),n=[];this.stops.forEach((o,s)=>{if(o.colorLess){let i=C(this.stops[s-1],this.stops[s+1],2);o.color=[i[1].r,i[1].g,i[1].b];}});for(let o=0,s=this.stops.length;o<s-1;o++){let i=C(this.stops[o],this.stops[o+1],t[o]);n.splice(n.length,0,...i.map(u=>this.#e.rgb(u.r,u.g,u.b)));}return n.push(this.#e.rgb(...this.stops.at(-1).color)),n}hsv(e,t=!1){let n=G(this.stops,e),o=[];this.stops.forEach((s,i)=>{if(s.colorLess){let u=A(this.stops[i-1],this.stops[i+1],2,t);s.color=[u[1].r,u[1].g,u[1].b];}});for(let s=0,i=this.stops.length;s<i-1;s++){let u=A(this.stops[s],this.stops[s+1],n[s],t);o.splice(o.length,0,...u.map(a=>this.#e.rgb(a.r,a.g,a.b)));}return o.push(this.#e.rgb(...this.stops.at(-1).color)),o}};var j=new I,T=/\s/g,ye=(r,e)=>{let{hsvSpin:t="short",interpolation:n="rgb"}=e??{},o=new y(j,r);return e?.loop?o=o.loop():e?.reverse&&(o=o.reverse()),s=>{let i=Math.max(s.replaceAll(T,"").length,o.stops.length),u=n==="rgb"?o.rgb(i):o.hsv(i,t),a="";for(let p of s)if(T.test(p))a+=p;else {let b=u.shift();a+=b(p);}return a}},Ce=(r,e)=>{let{hsvSpin:t="short",interpolation:n="rgb"}=e??{},o=new y(j,r);return e?.loop?o=o.loop():e?.reverse&&(o=o.reverse()),s=>{let i=s.split(`
7
+ `),u=Reflect.apply(Math.max,null,[...i.map(b=>b.length),o.stops.length]),a=n==="rgb"?o.rgb(u):o.hsv(u,t),p=[];for(let b of i){let c=[...a],d="";for(let m of b)d+=T.test(m)?m:c.shift()(m);p.push(d);}return p.join(`
8
+ `)}};
9
+
10
+ exports.GradientBuilder = y;
11
+ exports.gradient = ye;
12
+ exports.multilineGradient = Ce;
13
+ //# sourceMappingURL=out.js.map
14
+ //# sourceMappingURL=gradient.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../node_modules/.pnpm/ansi-regex@6.0.1/node_modules/ansi-regex/index.js","../src/ansi-codes.ts","../src/util/clamp.ts","../src/util/hex-to-rgb.ts","../src/util/string-replace-all.ts","../src/colorize.server.ts","../src/gradient/util/color-names.ts","../src/gradient/util/compute.ts","../src/gradient/util/hsv-to-rgb.ts","../src/gradient/util/rgb-to-hsv.ts","../src/gradient/util/interpolate.ts","../src/gradient/gradient-builder.ts","../src/gradient.ts"],"names":["ansiRegex","onlyFirst","pattern","isStdoutColorSupported","clamp","number_","min","max","hexToRgb","hex","color","esc","open","close","createAnsi256","code","createBgAnsi256","createRgb","g","b","createBgRgb","baseStyles","baseColors","styleMethods","stringReplaceAll","string_","searchValue","replaceValue","pos","substringLength","lastPos","result","styles","stylePrototype","wrapText","strings","values","properties","string","currentProperties","createStyle","props","openStack","closeStack","style","Colorize","self","value","name","arguments_","colorize_server_default","colorNames","computeSubSteps","stops","steps","l","substeps","index","step","totalSubsteps","n","hsvToRgb","h","s","v","r","f","p","q","t","rgbToHsv","rdif","gdif","bdif","diff","diffc","RGBA_MAX","HSV_MAX","calculateStepSize","start","end","k","interpolate","interpolateRgb","stop1","stop2","gradient","interpolateHsv","mode","trigonometric","trigShortest","GradientBuilder","_GradientBuilder","#colorize","colorize","havingPositions","lastColorLess","stop_","stop","hasPosition","stopInput","hasColor","stops1","stops2","subSteps","rgbs","rgb","forbiddenChars","options","hsvSpin","interpolation","builder","colorsCount","colors","multilineGradient","lines","results","line","lineColors","lineResult"],"mappings":"AAAe,SAARA,EAA2B,CAAC,UAAAC,EAAY,EAAK,EAAI,CAAC,EAAG,CAC3D,IAAMC,EAAU,CACZ,+HACH,0DACD,EAAE,KAAK,GAAG,EAEV,OAAO,IAAI,OAAOA,EAASD,EAAY,OAAY,GAAG,CACvD,CCCA,OAAS,0BAAAE,MAA8B,oCCKhC,IAAMC,EAAQ,CAACC,EAAiBC,EAAaC,IAAyBD,EAAMD,EAAUC,EAAMD,EAAUE,EAAMA,EAAMF,ECWlH,IAAMG,EAAYC,GAAiD,CACtE,IAAIC,EAAgBD,EAAI,QAAQ,IAAK,EAAE,EAEvC,GAAIC,EAAM,SAAW,EACjBA,EAASA,EAAM,CAAC,EAAgBA,EAAM,CAAC,EAAgBA,EAAM,CAAC,EAAgBA,EAAM,CAAC,EAAgBA,EAAM,CAAC,EAAgBA,EAAM,CAAC,UAC5HA,EAAM,SAAW,EACxB,MAAO,CAAC,EAAG,EAAG,CAAC,EAInB,IAAML,EAAU,OAAO,SAASK,EAAO,EAAE,EAGzC,MAAO,CAAEL,GAAW,GAAM,IAAMA,GAAW,EAAK,IAAKA,EAAU,GAAG,CACtE,EFxBA,IAAMM,EACFR,EAAuB,EAAI,EACrB,CAACS,EAAuBC,KACb,CAAE,MAAO,QAAYA,EAAQ,IAAK,KAAM,QAAYD,EAAO,GAAI,GAE1E,KACW,CAAE,MAAO,GAAI,KAAM,EAAG,GAGrCE,EAAiBC,GAAqCJ,EAAI,QAAUI,EAAM,EAAE,EAE5EC,EAAmBD,GAAqCJ,EAAI,QAAUI,EAAM,EAAE,EAE9EE,EAAY,CAAC,EAAoBC,EAAoBC,IAAkCR,EAAI,QAAU,EAAI,IAAMO,EAAI,IAAMC,EAAG,EAAE,EAE9HC,EAAc,CAAC,EA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[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]*)*)?\\\\u0007)',\n\t\t'(?:(?:\\\\d{1,4}(?:;\\\\d{0,4})*)?[\\\\dA-PR-TZcf-ntqry=><~]))'\n\t].join('|');\n\n\treturn new RegExp(pattern, onlyFirst ? undefined : 'g');\n}\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/ansi-codes.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\nimport { isStdoutColorSupported } from \"@visulima/is-ansi-color-supported\";\n\nimport type { AnsiColors, AnsiStyles, ColorData, ColorValueHex } from \"./types\";\nimport { clamp } from \"./util/clamp\";\nimport { hexToRgb } from \"./util/hex-to-rgb\";\n\nconst esc: (open: number | string, close: number | string) => ColorData =\n isStdoutColorSupported() > 0\n ? (open: number | string, close: number | string): ColorData => {\n return { close: \"\\u001B[\" + close + \"m\", open: \"\\u001B[\" + open + \"m\" };\n }\n : (): ColorData => {\n return { close: \"\", open: \"\" };\n };\n\nconst createAnsi256 = (code: number | string): ColorData => esc(\"38;5;\" + code, 39);\n\nconst createBgAnsi256 = (code: number | string): ColorData => esc(\"48;5;\" + code, 49);\n\nconst createRgb = (r: number | string, g: number | string, b: number | string): ColorData => esc(\"38;2;\" + r + \";\" + g + \";\" + b, 39);\n\nconst createBgRgb = (r: number | string, g: number | string, b: number | string): ColorData => esc(\"48;2;\" + r + \";\" + g + \";\" + b, 49);\n\nexport const baseStyles: Required<Record<AnsiStyles, ColorData>> = {\n // 21 isn't widely supported and 22 does the same thing\n bold: esc(1, 22),\n dim: esc(2, 22),\n hidden: esc(8, 28),\n inverse: esc(7, 27),\n italic: esc(3, 23),\n overline: esc(53, 55),\n reset: esc(0, 0),\n strike: esc(9, 29), // alias for strikethrough\n strikethrough: esc(9, 29),\n underline: esc(4, 24),\n visible: { close: \"\", open: \"\" },\n};\n\nexport const baseColors: Required<Record<AnsiColors, ColorData>> = {\n bgBlack: esc(40, 49),\n bgBlackBright: esc(100, 49),\n bgBlue: esc(44, 49),\n bgBlueBright: esc(104, 49),\n bgCyan: esc(46, 49),\n bgCyanBright: esc(106, 49),\n bgGray: esc(100, 49), // US spelling alias for bgBlackBright\n bgGreen: esc(42, 49),\n bgGreenBright: esc(102, 49),\n bgGrey: esc(100, 49), // UK spelling alias for bgBlackBright\n bgMagenta: esc(45, 49),\n bgMagentaBright: esc(105, 49),\n bgRed: esc(41, 49),\n bgRedBright: esc(101, 49),\n bgWhite: esc(47, 49),\n bgWhiteBright: esc(107, 49),\n bgYellow: esc(43, 49),\n bgYellowBright: esc(103, 49),\n black: esc(30, 39),\n blackBright: esc(90, 39),\n blue: esc(34, 39),\n blueBright: esc(94, 39),\n cyan: esc(36, 39),\n cyanBright: esc(96, 39),\n gray: esc(90, 39), // US spelling alias for blackBright\n green: esc(32, 39),\n greenBright: esc(92, 39),\n grey: esc(90, 39), // UK spelling alias for blackBright\n magenta: esc(35, 39),\n magentaBright: esc(95, 39),\n red: esc(31, 39),\n redBright: esc(91, 39),\n white: esc(37, 39),\n whiteBright: esc(97, 39),\n yellow: esc(33, 39),\n yellowBright: esc(93, 39),\n};\n\nexport const styleMethods: {\n bg: (code: number) => ColorData;\n bgHex: (hex: ColorValueHex) => ColorData;\n bgRgb: (r: number, g: number, b: number) => ColorData;\n fg: (code: number) => ColorData;\n hex: (hex: ColorValueHex) => ColorData;\n rgb: (r: number, g: number, b: number) => ColorData;\n} = {\n bg: (code) => createBgAnsi256(clamp(code, 0, 255)),\n\n bgHex: (hex) => createBgRgb(...hexToRgb(hex)),\n\n bgRgb: (r, g, b) => createBgRgb(clamp(r, 0, 255), clamp(g, 0, 255), clamp(b, 0, 255)),\n\n fg: (code) => createAnsi256(clamp(code, 0, 255)),\n\n hex: (hex) => createRgb(...hexToRgb(hex)),\n\n rgb: (r, g, b) => createRgb(clamp(r, 0, 255), clamp(g, 0, 255), clamp(b, 0, 255)),\n};\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/utils.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\n/**\n * Clamp a number within the inclusive range specified by min and max.\n * @note: The ternary operator is a tick quicker than Math.min(Math.max(num, min), max).\n */\n\nexport const clamp = (number_: number, min: number, max: number): number => (min > number_ ? min : number_ > max ? max : number_);\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/utils.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\nimport type { ColorValueHex } from \"../types\";\n\n/**\n * Convert hex color string to RGB values.\n *\n * A hexadecimal color code can be 3 or 6 digits with an optional \"#\" prefix.\n *\n * The 3 digits specifies an RGB doublet data as a fully opaque color.\n * For example, \"#123\" specifies the color that is represented by \"#112233\".\n *\n * The 6 digits specifies a fully opaque color.\n * For example, \"#112233\".\n *\n * @param {string} hex A string that contains the hexadecimal RGB color representation.\n * @return {[number, number, number]} The red, green, blue values in range [0, 255] .\n */\nexport const hexToRgb = (hex: ColorValueHex): [number, number, number] => {\n let color: string = hex.replace(\"#\", \"\");\n\n if (color.length === 3) {\n color = (color[0] as string) + (color[0] as string) + (color[1] as string) + (color[1] as string) + (color[2] as string) + (color[2] as string);\n } else if (color.length !== 6) {\n return [0, 0, 0];\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const number_ = Number.parseInt(color, 16);\n\n // eslint-disable-next-line no-bitwise\n return [(number_ >> 16) & 255, (number_ >> 8) & 255, number_ & 255];\n};\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/utils.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\n/**\n * Replace all matched strings.\n * Note: this implementation is over 30% faster than String.replaceAll().\n */\nexport const stringReplaceAll = (string_: string, searchValue: string, replaceValue: string): string => {\n // visible style has empty open/close props\n if (searchValue === \"\") {\n return string_;\n }\n\n let pos = string_.indexOf(searchValue);\n if (pos < 0) {\n return string_;\n }\n\n const substringLength = searchValue.length;\n let lastPos = 0;\n let result = \"\";\n\n // eslint-disable-next-line no-loops/no-loops,no-bitwise\n while (~pos) {\n result += string_.slice(lastPos, pos) + replaceValue;\n lastPos = pos + substringLength;\n pos = string_.indexOf(searchValue, lastPos);\n }\n\n return result + string_.slice(lastPos);\n};\n","/**\n * Modified copy of https://github.com/webdiscus/ansis/blob/master/src/index.js\n *\n * ISC License\n *\n * Copyright (c) 2023, webdiscus\n */\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport ansiRegex from \"ansi-regex\";\n\nimport { baseColors, baseStyles, styleMethods } from \"./ansi-codes\";\nimport type { ColorData, ColorizeType } from \"./types\";\nimport { stringReplaceAll } from \"./util/string-replace-all\";\n\nconst styles: Record<string, object> = {};\n\nlet stylePrototype: object | null = null;\n\nconst wrapText = (\n strings: ArrayLike<string> | ReadonlyArray<string> | number | string | { raw: ArrayLike<string> | ReadonlyArray<string> },\n values: string[],\n properties: ColorizeProperties,\n) => {\n if (!strings) {\n return \"\";\n }\n\n let string =\n (strings as { raw?: ArrayLike<string> | ReadonlyArray<string> | null }).raw == null\n ? (((strings as number | string) + \"\") as string)\n : String.raw(strings as { raw: ArrayLike<string> | ReadonlyArray<string> }, ...values);\n\n if (string.includes(\"\\u001B\")) {\n // eslint-disable-next-line no-loops/no-loops,@typescript-eslint/no-unnecessary-condition\n for (let currentProperties = properties; currentProperties; currentProperties = currentProperties.props) {\n string = stringReplaceAll(string, currentProperties.close, currentProperties.open);\n }\n }\n\n if (string.includes(\"\\n\")) {\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n string = string.replace(/(\\r*\\n)/g, properties.closeStack + \"$1\" + properties.openStack);\n }\n\n return properties.openStack + string + properties.closeStack;\n};\n\ntype ColorizeProperties = { close: string; closeStack: string; open: string; openStack: string; props: ColorizeProperties };\n\nconst createStyle = (\n { props }: { props?: ColorizeProperties },\n { close, open }: ColorData,\n): {\n (strings: ArrayLike<string> | ReadonlyArray<string> | string, ...values: string[]): string;\n close: string;\n open: string;\n props: { close: string; closeStack: string; open: string; openStack: string; props?: ColorizeProperties };\n} => {\n const openStack: string = (props?.openStack ?? \"\") + open;\n const closeStack: string = close + (props?.closeStack ?? \"\");\n\n const style = (strings: ArrayLike<string> | ReadonlyArray<string> | string, ...values: string[]) => wrapText(strings, values, style.props);\n\n Object.setPrototypeOf(style, stylePrototype);\n\n style.props = { close, closeStack, open, openStack, props } as ColorizeProperties;\n style.open = openStack;\n style.close = closeStack;\n\n return style;\n};\n\n// eslint-disable-next-line func-names\nconst Colorize = function () {\n const self = (string_: number | string) => string_ + \"\";\n\n self.strip = (value: string): string => value.replaceAll(ansiRegex(), \"\");\n\n // eslint-disable-next-line guard-for-in,no-loops/no-loops,no-restricted-syntax\n for (const name in baseColors) {\n // eslint-disable-next-line security/detect-object-injection\n styles[name] = {\n get() {\n const style = createStyle(this, baseColors[name as keyof typeof baseColors]);\n\n Object.defineProperty(this, name, { value: style });\n\n return style;\n },\n };\n }\n\n // eslint-disable-next-line guard-for-in,no-loops/no-loops,no-restricted-syntax\n for (const name in baseStyles) {\n // eslint-disable-next-line security/detect-object-injection\n styles[name] = {\n get() {\n const style = createStyle(this, baseStyles[name as keyof typeof baseStyles]);\n\n Object.defineProperty(this, name, { value: style });\n\n return style;\n },\n };\n }\n\n // This needs to be the last thing we do, so that the prototype is fully populated.\n stylePrototype = Object.defineProperties({}, styles);\n\n Object.setPrototypeOf(self, stylePrototype);\n\n return self;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n} as any as new () => ColorizeType;\n\n// eslint-disable-next-line guard-for-in,no-loops/no-loops,no-restricted-syntax\nfor (const name in styleMethods) {\n styles[name as keyof typeof styleMethods] = {\n get() {\n return (...arguments_: (number | string)[]) =>\n // @ts-expect-error: TODO: fix typing of `arguments_`\n\n createStyle(this, styleMethods[name as keyof typeof styleMethods](...arguments_));\n },\n };\n}\n\nstyles[\"ansi256\"] = styles[\"fg\"] as object;\nstyles[\"bgAnsi256\"] = styles[\"bg\"] as object;\n\n// eslint-disable-next-line import/no-default-export\nexport default Colorize;\n","// A JSON with color names and its values. Based on http://dev.w3.org/csswg/css-color/#named-colors.\nimport type { CssColorCodes } from \"../../types\";\n\nexport const colorNames: CssColorCodes = {\n aliceblue: [240, 248, 255],\n antiquewhite: [250, 235, 215],\n aqua: [0, 255, 255],\n aquamarine: [127, 255, 212],\n azure: [240, 255, 255],\n beige: [245, 245, 220],\n bisque: [255, 228, 196],\n black: [0, 0, 0],\n blanchedalmond: [255, 235, 205],\n blue: [0, 0, 255],\n blueviolet: [138, 43, 226],\n brown: [165, 42, 42],\n burlywood: [222, 184, 135],\n cadetblue: [95, 158, 160],\n chartreuse: [127, 255, 0],\n chocolate: [210, 105, 30],\n coral: [255, 127, 80],\n cornflowerblue: [100, 149, 237],\n cornsilk: [255, 248, 220],\n crimson: [220, 20, 60],\n cyan: [0, 255, 255],\n darkblue: [0, 0, 139],\n darkcyan: [0, 139, 139],\n darkgoldenrod: [184, 134, 11],\n darkgray: [169, 169, 169],\n darkgreen: [0, 100, 0],\n darkgrey: [169, 169, 169],\n darkkhaki: [189, 183, 107],\n darkmagenta: [139, 0, 139],\n darkolivegreen: [85, 107, 47],\n darkorange: [255, 140, 0],\n darkorchid: [153, 50, 204],\n darkred: [139, 0, 0],\n darksalmon: [233, 150, 122],\n darkseagreen: [143, 188, 143],\n darkslateblue: [72, 61, 139],\n darkslategray: [47, 79, 79],\n darkslategrey: [47, 79, 79],\n darkturquoise: [0, 206, 209],\n darkviolet: [148, 0, 211],\n deeppink: [255, 20, 147],\n deepskyblue: [0, 191, 255],\n dimgray: [105, 105, 105],\n dimgrey: [105, 105, 105],\n dodgerblue: [30, 144, 255],\n firebrick: [178, 34, 34],\n floralwhite: [255, 250, 240],\n forestgreen: [34, 139, 34],\n fuchsia: [255, 0, 255],\n gainsboro: [220, 220, 220],\n ghostwhite: [248, 248, 255],\n gold: [255, 215, 0],\n goldenrod: [218, 165, 32],\n gray: [128, 128, 128],\n green: [0, 128, 0],\n greenyellow: [173, 255, 47],\n grey: [128, 128, 128],\n honeydew: [240, 255, 240],\n hotpink: [255, 105, 180],\n indianred: [205, 92, 92],\n indigo: [75, 0, 130],\n ivory: [255, 255, 240],\n khaki: [240, 230, 140],\n lavender: [230, 230, 250],\n lavenderblush: [255, 240, 245],\n lawngreen: [124, 252, 0],\n lemonchiffon: [255, 250, 205],\n lightblue: [173, 216, 230],\n lightcoral: [240, 128, 128],\n lightcyan: [224, 255, 255],\n lightgoldenrodyellow: [250, 250, 210],\n lightgray: [211, 211, 211],\n lightgreen: [144, 238, 144],\n lightgrey: [211, 211, 211],\n lightpink: [255, 182, 193],\n lightsalmon: [255, 160, 122],\n lightseagreen: [32, 178, 170],\n lightskyblue: [135, 206, 250],\n lightslategray: [119, 136, 153],\n lightslategrey: [119, 136, 153],\n lightsteelblue: [176, 196, 222],\n lightyellow: [255, 255, 224],\n lime: [0, 255, 0],\n limegreen: [50, 205, 50],\n linen: [250, 240, 230],\n magenta: [255, 0, 255],\n maroon: [128, 0, 0],\n mediumaquamarine: [102, 205, 170],\n mediumblue: [0, 0, 205],\n mediumorchid: [186, 85, 211],\n mediumpurple: [147, 112, 219],\n mediumseagreen: [60, 179, 113],\n mediumslateblue: [123, 104, 238],\n mediumspringgreen: [0, 250, 154],\n mediumturquoise: [72, 209, 204],\n mediumvioletred: [199, 21, 133],\n midnightblue: [25, 25, 112],\n mintcream: [245, 255, 250],\n mistyrose: [255, 228, 225],\n moccasin: [255, 228, 181],\n navajowhite: [255, 222, 173],\n navy: [0, 0, 128],\n oldlace: [253, 245, 230],\n olive: [128, 128, 0],\n olivedrab: [107, 142, 35],\n orange: [255, 165, 0],\n orangered: [255, 69, 0],\n orchid: [218, 112, 214],\n palegoldenrod: [238, 232, 170],\n palegreen: [152, 251, 152],\n paleturquoise: [175, 238, 238],\n palevioletred: [219, 112, 147],\n papayawhip: [255, 239, 213],\n peachpuff: [255, 218, 185],\n peru: [205, 133, 63],\n pink: [255, 192, 203],\n plum: [221, 160, 221],\n powderblue: [176, 224, 230],\n purple: [128, 0, 128],\n rebeccapurple: [102, 51, 153],\n red: [255, 0, 0],\n rosybrown: [188, 143, 143],\n royalblue: [65, 105, 225],\n saddlebrown: [139, 69, 19],\n salmon: [250, 128, 114],\n sandybrown: [244, 164, 96],\n seagreen: [46, 139, 87],\n seashell: [255, 245, 238],\n sienna: [160, 82, 45],\n silver: [192, 192, 192],\n skyblue: [135, 206, 235],\n slateblue: [106, 90, 205],\n slategray: [112, 128, 144],\n slategrey: [112, 128, 144],\n snow: [255, 250, 250],\n springgreen: [0, 255, 127],\n steelblue: [70, 130, 180],\n tan: [210, 180, 140],\n teal: [0, 128, 128],\n thistle: [216, 191, 216],\n tomato: [255, 99, 71],\n turquoise: [64, 224, 208],\n violet: [238, 130, 238],\n wheat: [245, 222, 179],\n white: [255, 255, 255],\n whitesmoke: [245, 245, 245],\n yellow: [255, 255, 0],\n yellowgreen: [154, 205, 50],\n};\n","import type { StopOutput } from \"../../types\";\n\nexport const computeSubSteps = (stops: StopOutput[], steps: number): number[] => {\n const l = stops.length;\n\n // eslint-disable-next-line no-param-reassign\n steps = Number.parseInt(steps.toString(), 10);\n\n if (Number.isNaN(steps) || steps < 2) {\n throw new Error(\"Invalid number of steps (< 2)\");\n }\n\n if (steps < l) {\n throw new Error(\"Number of steps cannot be inferior to number of stops\");\n }\n\n const substeps: number[] = [];\n\n // eslint-disable-next-line no-loops/no-loops,no-plusplus\n for (let index = 1; index < l; index++) {\n // eslint-disable-next-line security/detect-object-injection\n const step = (steps - 1) * ((stops[index] as StopOutput).position - (stops[index - 1] as StopOutput).position);\n\n substeps.push(Math.max(1, Math.round(step)));\n }\n\n let totalSubsteps = 1;\n\n // eslint-disable-next-line no-loops/no-loops,no-plusplus\n for (let n = l - 1; n--; ) {\n // eslint-disable-next-line security/detect-object-injection\n totalSubsteps += substeps[n] as number;\n }\n\n // eslint-disable-next-line no-loops/no-loops\n while (totalSubsteps !== steps) {\n if (totalSubsteps < steps) {\n const min = Math.min(...substeps);\n\n // eslint-disable-next-line no-plusplus\n substeps[substeps.indexOf(min)]++;\n // eslint-disable-next-line no-plusplus\n totalSubsteps++;\n } else {\n const max = Math.max(...substeps);\n\n // eslint-disable-next-line no-plusplus\n substeps[substeps.indexOf(max)]--;\n // eslint-disable-next-line no-plusplus\n totalSubsteps--;\n }\n }\n\n return substeps;\n};\n","export const hsvToRgb = (h: number, s: number, v: number): { b: number; g: number; r: number } => {\n let r = 0;\n let g = 0;\n let b = 0;\n\n const index = Math.floor(h / 60);\n const f = h / 60 - index;\n const p = v * (1 - s);\n const q = v * (1 - f * s);\n const t = v * (1 - (1 - f) * s);\n\n if (index % 6 === 0) {\n r = v;\n g = t;\n b = p;\n } else if (index % 6 === 1) {\n r = q;\n g = v;\n b = p;\n } else if (index % 6 === 2) {\n r = p;\n g = v;\n b = t;\n } else if (index % 6 === 3) {\n r = p;\n g = q;\n b = v;\n } else if (index % 6 === 4) {\n r = t;\n g = p;\n b = v;\n } else if (index % 6 === 5) {\n r = v;\n g = p;\n b = q;\n }\n\n return { b: Math.round(b * 255), g: Math.round(g * 255), r: Math.round(r * 255) };\n};\n","export const rgbToHsv = ({ b, g, r }: { b: number; g: number; r: number }): { h: number; s: number; v: number } => {\n let rdif;\n let gdif;\n let bdif;\n let h = 0;\n let s = 0;\n\n // eslint-disable-next-line no-param-reassign\n r /= 255;\n // eslint-disable-next-line no-param-reassign\n g /= 255;\n // eslint-disable-next-line no-param-reassign\n b /= 255;\n\n const v = Math.max(r, g, b);\n const diff = v - Math.min(r, g, b);\n const diffc = (c: number) => (v - c) / 6 / diff + 1 / 2;\n\n if (diff !== 0) {\n s = diff / v;\n rdif = diffc(r);\n gdif = diffc(g);\n bdif = diffc(b);\n\n // eslint-disable-next-line unicorn/prefer-switch\n if (v === r) {\n h = bdif - gdif;\n } else if (v === g) {\n h = 1 / 3 + rdif - bdif;\n } else if (v === b) {\n h = 2 / 3 + gdif - rdif;\n }\n\n if (h < 0) {\n h += 1;\n } else if (h > 1) {\n h -= 1;\n }\n }\n\n return {\n h: h * 360,\n s,\n v,\n };\n};\n","import type { HSVA, RGB, StopOutput } from \"../../types\";\nimport { hsvToRgb } from \"./hsv-to-rgb\";\nimport { rgbToHsv } from \"./rgb-to-hsv\";\n\nconst RGBA_MAX: RGB = { b: 256, g: 256, r: 256 };\nconst HSV_MAX: HSVA = { h: 360, s: 1, v: 1 };\n\nconst calculateStepSize = <T extends Record<string, number>>(start: T, end: T, steps: number): T => {\n const step: T = {} as T;\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const k in start) {\n if (Object.prototype.hasOwnProperty.call(start, k)) {\n // @TODO: Fix this any type\n // eslint-disable-next-line security/detect-object-injection,@typescript-eslint/no-explicit-any\n (step as any)[k] = steps === 0 ? 0 : ((end[k] as number) - (start[k] as number)) / steps;\n }\n }\n\n return step;\n};\n\nconst interpolate = <T extends Record<string, number>>(step: T, start: T, index: number, max: T): T => {\n const color: T = {} as T;\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const k in start) {\n if (Object.prototype.hasOwnProperty.call(start, k)) {\n // @TODO: Fix this any type\n // eslint-disable-next-line security/detect-object-injection,@typescript-eslint/no-explicit-any\n (color as any)[k] = (step[k] as number) * index + (start[k] as number);\n // @TODO: Fix this any type\n // eslint-disable-next-line security/detect-object-injection,@typescript-eslint/no-explicit-any,sonarjs/no-element-overwrite\n (color as any)[k] =\n // eslint-disable-next-line security/detect-object-injection\n (color[k] as number) < 0\n ? // eslint-disable-next-line security/detect-object-injection\n (color[k] as number) + (max[k] as number)\n : // eslint-disable-next-line security/detect-object-injection\n max[k] === 1\n ? // eslint-disable-next-line security/detect-object-injection\n (color[k] as number)\n : // eslint-disable-next-line security/detect-object-injection\n (color[k] as number) % (max[k] as number);\n }\n }\n\n return color;\n};\n\nexport const interpolateRgb = (stop1: StopOutput, stop2: StopOutput, steps: number): RGB[] => {\n const start: RGB = { b: (stop1.color as number[])[2] as number, g: (stop1.color as number[])[1] as number, r: (stop1.color as number[])[0] as number };\n const end: RGB = { b: (stop2.color as number[])[2] as number, g: (stop2.color as number[])[1] as number, r: (stop2.color as number[])[0] as number };\n\n const step = calculateStepSize<RGB>(start, end, steps);\n\n const gradient: RGB[] = [{ ...start }];\n\n // eslint-disable-next-line no-loops/no-loops,no-plusplus\n for (let index = 1; index < steps; index++) {\n const color = interpolate<RGB>(step, start, index, RGBA_MAX);\n\n gradient.push({\n b: Math.floor(color.b as number),\n g: Math.floor(color.g as number),\n r: Math.floor(color.r as number),\n });\n }\n\n return gradient;\n};\n\nexport const interpolateHsv = (\n stop1: StopOutput,\n stop2: StopOutput,\n steps: number,\n mode: boolean | \"long\" | \"short\",\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): RGB[] => {\n const start = rgbToHsv({ b: (stop1.color as number[])[2] as number, g: (stop1.color as number[])[1] as number, r: (stop1.color as number[])[0] as number });\n const end = rgbToHsv({ b: (stop2.color as number[])[2] as number, g: (stop2.color as number[])[1] as number, r: (stop2.color as number[])[0] as number });\n\n if (start.s === 0 || end.s === 0) {\n return interpolateRgb(stop1, stop2, steps);\n }\n\n let trigonometric: boolean;\n\n if (typeof mode === \"boolean\") {\n trigonometric = mode;\n } else {\n const trigShortest = (start.h < end.h && end.h - start.h < 180) || (start.h > end.h && start.h - end.h > 180);\n\n trigonometric = (mode === \"long\" && trigShortest) || (mode === \"short\" && !trigShortest);\n }\n\n const step = calculateStepSize(start, end, steps);\n const gradient: RGB[] = [\n {\n b: (stop1.color as [number, number, number])[2],\n g: (stop1.color as [number, number, number])[1],\n r: (stop1.color as [number, number, number])[0],\n },\n ];\n\n let diff: number;\n\n if ((start.h <= end.h && !trigonometric) || (start.h >= end.h && trigonometric)) {\n diff = end.h - start.h;\n } else if (trigonometric) {\n diff = 360 - end.h + start.h;\n } else {\n diff = 360 - start.h + end.h;\n }\n\n step.h = ((-1) ** (trigonometric ? 1 : 0) * Math.abs(diff)) / steps;\n\n // eslint-disable-next-line no-plusplus,no-loops/no-loops\n for (let index = 1; index < steps; index++) {\n const color = interpolate<HSVA>(step, start, index, HSV_MAX);\n\n gradient.push(hsvToRgb(color.h, color.s, color.v));\n }\n\n return gradient;\n};\n","import type { ColorizeType, ColorValueHex, CssColorName, RGB, StopInput, StopOutput } from \"../types\";\nimport { hexToRgb } from \"../util/hex-to-rgb\";\nimport { colorNames } from \"./util/color-names\";\nimport { computeSubSteps } from \"./util/compute\";\nimport { interpolateHsv, interpolateRgb } from \"./util/interpolate\";\n\nexport class GradientBuilder {\n readonly #colorize: ColorizeType;\n\n public readonly stops: StopOutput[];\n\n // eslint-disable-next-line sonarjs/cognitive-complexity\n public constructor(colorize: ColorizeType, stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[]) {\n this.#colorize = colorize;\n this.stops = [];\n\n if (stops.length < 2) {\n throw new Error(\"Invalid number of stops (< 2)\");\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const havingPositions = (stops[0] as StopInput).position !== undefined;\n\n let l = stops.length;\n let p = -1;\n let lastColorLess = false;\n\n // eslint-disable-next-line no-loops/no-loops,@typescript-eslint/naming-convention,no-restricted-syntax\n for (const [index, stop_] of stops.entries()) {\n let stop = {} as StopOutput;\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const hasPosition = (stop_ as StopInput).position !== undefined;\n\n if (havingPositions !== hasPosition) {\n throw new Error(\"Cannot mix positioned and non-positioned color stops\");\n }\n\n if (hasPosition) {\n const stopInput = stop_ as StopInput;\n\n const hasColor = stopInput.color !== undefined;\n\n if (!hasColor && (lastColorLess || index === 0 || index === l - 1)) {\n throw new Error(\"Cannot define two consecutive position-only stops\");\n }\n\n lastColorLess = !hasColor;\n\n let color: [number, number, number] | undefined;\n\n if (hasColor) {\n if (Array.isArray(stopInput.color)) {\n color = stopInput.color as [number, number, number];\n } else if (typeof stopInput.color === \"string\") {\n color = stopInput.color.includes(\"#\") ? hexToRgb(stopInput.color as ColorValueHex) : colorNames[stopInput.color as CssColorName];\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n } else if ((stopInput.color as RGB).r !== undefined && (stopInput.color as RGB).g !== undefined && (stopInput.color as RGB).b) {\n color = [(stopInput.color as RGB).r, (stopInput.color as RGB).g, (stopInput.color as RGB).b];\n }\n }\n\n stop = {\n color,\n colorLess: !hasColor,\n position: stopInput.position,\n };\n\n if (stop.position < 0 || stop.position > 1) {\n throw new Error(\"Color stops positions must be between 0 and 1\");\n } else if (stop.position < p) {\n throw new Error(\"Color stops positions are not ordered\");\n }\n\n p = stop.position;\n } else if (Array.isArray(stop_)) {\n stop = {\n color: stop_ as [number, number, number],\n position: index / (l - 1),\n };\n } else if (typeof stop_ === \"string\") {\n stop = {\n color: stop_.includes(\"#\") ? hexToRgb(stop_ as ColorValueHex) : colorNames[stop_ as CssColorName],\n position: index / (l - 1),\n };\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n } else if ((stop_ as RGB).r !== undefined && (stop_ as RGB).g !== undefined && (stop_ as RGB).b !== undefined) {\n stop = {\n color: [(stop_ as RGB).r, (stop_ as RGB).g, (stop_ as RGB).b],\n position: index / (l - 1),\n };\n } else {\n throw new Error(\"Invalid color stop\");\n }\n\n this.stops.push(stop);\n }\n\n if ((this.stops[0] as StopOutput).position !== 0) {\n this.stops.unshift({\n color: (this.stops[0] as StopOutput).color,\n position: 0,\n });\n\n // eslint-disable-next-line no-plusplus\n l++;\n }\n\n if ((this.stops[l - 1] as StopOutput).position !== 1) {\n this.stops.push({\n color: (this.stops[l - 1] as StopOutput).color,\n position: 1,\n });\n }\n }\n\n public reverse(): GradientBuilder {\n const stops: StopInput[] = [];\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const stop of this.stops) {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const stop_ = { ...stop };\n\n stop_.position = 1 - stop.position;\n\n stops.push(stop_ as StopInput);\n }\n\n // eslint-disable-next-line etc/no-assign-mutated-array\n return new GradientBuilder(this.#colorize, stops.reverse());\n }\n\n public loop(): GradientBuilder {\n const stops1: StopInput[] = [];\n const stops2: StopInput[] = [];\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const stop of this.stops) {\n stops1.push({\n color: stop.color,\n position: (stop.position || 0) / 2,\n } as StopInput);\n }\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const stop of this.stops.slice(0, -1)) {\n stops2.push({\n color: stop.color,\n position: 1 - (stop.position || 0) / 2,\n } as StopInput);\n }\n\n // eslint-disable-next-line etc/no-assign-mutated-array\n return new GradientBuilder(this.#colorize, [...stops1, ...stops2.reverse()]);\n }\n\n public rgb(steps: number): ColorizeType[] {\n const subSteps = computeSubSteps(this.stops, steps);\n const gradient: ColorizeType[] = [];\n\n this.stops.forEach((stop, index) => {\n if (stop.colorLess) {\n const rgbs = interpolateRgb(this.stops[index - 1] as StopOutput, this.stops[index + 1] as StopOutput, 2);\n // eslint-disable-next-line no-param-reassign\n stop.color = [(rgbs[1] as RGB).r, (rgbs[1] as RGB).g, (rgbs[1] as RGB).b];\n }\n });\n\n // eslint-disable-next-line no-loops/no-loops,no-plusplus\n for (let index = 0, l = this.stops.length; index < l - 1; index++) {\n // eslint-disable-next-line security/detect-object-injection\n const rgbs = interpolateRgb(this.stops[index] as StopOutput, this.stops[index + 1] as StopOutput, subSteps[index] as number);\n\n gradient.splice(gradient.length, 0, ...rgbs.map((rgb) => this.#colorize.rgb(rgb.r, rgb.g, rgb.b)));\n }\n\n gradient.push(this.#colorize.rgb(...((this.stops.at(-1) as StopOutput).color as [number, number, number])));\n\n return gradient;\n }\n\n public hsv(steps: number, mode: boolean | \"long\" | \"short\" = false): ColorizeType[] {\n const subSteps = computeSubSteps(this.stops, steps);\n const gradient: ColorizeType[] = [];\n\n this.stops.forEach((stop, index) => {\n if (stop.colorLess) {\n const rgbs = interpolateHsv(this.stops[index - 1] as StopOutput, this.stops[index + 1] as StopOutput, 2, mode);\n // eslint-disable-next-line no-param-reassign\n stop.color = [(rgbs[1] as RGB).r, (rgbs[1] as RGB).g, (rgbs[1] as RGB).b];\n }\n });\n\n // eslint-disable-next-line no-plusplus,no-loops/no-loops\n for (let index = 0, l = this.stops.length; index < l - 1; index++) {\n // eslint-disable-next-line security/detect-object-injection\n const rgbs = interpolateHsv(this.stops[index] as StopOutput, this.stops[index + 1] as StopOutput, subSteps[index] as number, mode);\n\n gradient.splice(gradient.length, 0, ...rgbs.map((rgb) => this.#colorize.rgb(rgb.r, rgb.g, rgb.b)));\n }\n\n gradient.push(this.#colorize.rgb(...((this.stops.at(-1) as StopOutput).color as [number, number, number])));\n\n return gradient;\n }\n}\n","import ColorizeImpl from \"./colorize.server\";\nimport { GradientBuilder } from \"./gradient/gradient-builder\";\nimport type { ColorizeType, ColorValueHex, CssColorName, RGB, StopInput } from \"./types\";\n\nconst colorize: ColorizeType = new ColorizeImpl() as ColorizeType;\n\nconst forbiddenChars = /\\s/g;\n\nexport const gradient = (\n stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[],\n options?: {\n hsvSpin?: \"long\" | \"short\";\n interpolation?: \"hsv\" | \"rgb\";\n loop?: boolean;\n reverse?: boolean;\n },\n): ((string_: string) => string) => {\n const { hsvSpin = \"short\", interpolation = \"rgb\" } = options ?? {};\n\n let builder = new GradientBuilder(colorize, stops);\n\n if (options?.loop) {\n builder = builder.loop();\n } else if (options?.reverse) {\n builder = builder.reverse();\n }\n\n return (string_: string): string => {\n const colorsCount = Math.max(string_.replaceAll(forbiddenChars, \"\").length, builder.stops.length);\n const colors = interpolation === \"rgb\" ? builder.rgb(colorsCount) : builder.hsv(colorsCount, hsvSpin);\n\n let result = \"\";\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const s of string_) {\n if (forbiddenChars.test(s)) {\n result += s;\n } else {\n const color = colors.shift();\n\n result += (color as ColorizeType)(s);\n }\n }\n\n return result;\n };\n};\n\n// eslint-disable-next-line import/no-unused-modules\nexport const multilineGradient = (\n stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[],\n options?: {\n hsvSpin?: \"long\" | \"short\";\n interpolation?: \"hsv\" | \"rgb\";\n loop?: boolean;\n reverse?: boolean;\n },\n): ((string_: string) => string) => {\n const { hsvSpin = \"short\", interpolation = \"rgb\" } = options ?? {};\n\n let builder = new GradientBuilder(colorize, stops);\n\n if (options?.loop) {\n builder = builder.loop();\n } else if (options?.reverse) {\n builder = builder.reverse();\n }\n\n return (string_: string): string => {\n const lines = string_.split(\"\\n\");\n\n const colorsCount = Reflect.apply(Math.max, null, [...lines.map((l) => l.length), builder.stops.length]);\n const colors = interpolation === \"rgb\" ? builder.rgb(colorsCount) : builder.hsv(colorsCount, hsvSpin);\n\n const results: string[] = [];\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const line of lines) {\n const lineColors = [...colors];\n\n let lineResult = \"\";\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const l of line) {\n lineResult += forbiddenChars.test(l) ? l : (lineColors.shift() as ColorizeType)(l);\n }\n\n results.push(lineResult);\n }\n\n return results.join(\"\\n\");\n };\n};\n\n// eslint-disable-next-line import/no-unused-modules\nexport { GradientBuilder } from \"./gradient/gradient-builder\";\n"]}
@@ -0,0 +1,112 @@
1
+ type ColorValueHex = `#${string}`;
2
+ interface ColorizeType {
3
+ (string: number | string): string;
4
+ (string: TemplateStringsArray, ...parameters: string[]): string;
5
+ ansi256: (code: number) => this;
6
+ bg: (code: number) => this;
7
+ bgAnsi256: (code: number) => this;
8
+ readonly bgBlack: this;
9
+ readonly bgBlackBright: this;
10
+ readonly bgBlue: this;
11
+ readonly bgBlueBright: this;
12
+ readonly bgCyan: this;
13
+ readonly bgCyanBright: this;
14
+ readonly bgGray: this;
15
+ readonly bgGreen: this;
16
+ readonly bgGreenBright: this;
17
+ readonly bgGrey: this;
18
+ bgHex: (color: ColorValueHex) => this;
19
+ readonly bgMagenta: this;
20
+ readonly bgMagentaBright: this;
21
+ readonly bgRed: this;
22
+ readonly bgRedBright: this;
23
+ bgRgb: (red: number, green: number, blue: number) => this;
24
+ readonly bgWhite: this;
25
+ readonly bgWhiteBright: this;
26
+ readonly bgYellow: this;
27
+ readonly bgYellowBright: this;
28
+ readonly black: this;
29
+ readonly blackBright: this;
30
+ readonly blue: this;
31
+ readonly blueBright: this;
32
+ readonly bold: this;
33
+ readonly close: string;
34
+ readonly cyan: this;
35
+ readonly cyanBright: this;
36
+ readonly dim: this;
37
+ fg: (code: number) => this;
38
+ readonly gray: this;
39
+ readonly green: this;
40
+ readonly greenBright: this;
41
+ readonly grey: this;
42
+ hex: (color: ColorValueHex) => this;
43
+ readonly hidden: this;
44
+ readonly inverse: this;
45
+ readonly italic: this;
46
+ readonly magenta: this;
47
+ readonly magentaBright: this;
48
+ readonly open: string;
49
+ readonly overline: this;
50
+ readonly red: this;
51
+ readonly redBright: this;
52
+ readonly reset: this;
53
+ rgb: (red: number, green: number, blue: number) => this;
54
+ readonly strike: this;
55
+ readonly strikethrough: this;
56
+ strip: (string: string) => string;
57
+ readonly underline: this;
58
+ readonly visible: this;
59
+ readonly white: this;
60
+ readonly whiteBright: this;
61
+ readonly yellow: this;
62
+ readonly yellowBright: this;
63
+ }
64
+ type CssColorName = "aliceblue" | "antiquewhite" | "aqua" | "aquamarine" | "azure" | "beige" | "bisque" | "black" | "blanchedalmond" | "blue" | "blueviolet" | "brown" | "burlywood" | "cadetblue" | "chartreuse" | "chocolate" | "coral" | "cornflowerblue" | "cornsilk" | "crimson" | "cyan" | "darkblue" | "darkcyan" | "darkgoldenrod" | "darkgray" | "darkgreen" | "darkgrey" | "darkkhaki" | "darkmagenta" | "darkolivegreen" | "darkorange" | "darkorchid" | "darkred" | "darksalmon" | "darkseagreen" | "darkslateblue" | "darkslategray" | "darkslategrey" | "darkturquoise" | "darkviolet" | "deeppink" | "deepskyblue" | "dimgray" | "dimgrey" | "dodgerblue" | "firebrick" | "floralwhite" | "forestgreen" | "fuchsia" | "gainsboro" | "ghostwhite" | "gold" | "goldenrod" | "gray" | "green" | "greenyellow" | "grey" | "honeydew" | "hotpink" | "indianred" | "indigo" | "ivory" | "khaki" | "lavender" | "lavenderblush" | "lawngreen" | "lemonchiffon" | "lightblue" | "lightcoral" | "lightcyan" | "lightgoldenrodyellow" | "lightgray" | "lightgreen" | "lightgrey" | "lightpink" | "lightsalmon" | "lightseagreen" | "lightskyblue" | "lightslategray" | "lightslategrey" | "lightsteelblue" | "lightyellow" | "lime" | "limegreen" | "linen" | "magenta" | "maroon" | "mediumaquamarine" | "mediumblue" | "mediumorchid" | "mediumpurple" | "mediumseagreen" | "mediumslateblue" | "mediumspringgreen" | "mediumturquoise" | "mediumvioletred" | "midnightblue" | "mintcream" | "mistyrose" | "moccasin" | "navajowhite" | "navy" | "oldlace" | "olive" | "olivedrab" | "orange" | "orangered" | "orchid" | "palegoldenrod" | "palegreen" | "paleturquoise" | "palevioletred" | "papayawhip" | "peachpuff" | "peru" | "pink" | "plum" | "powderblue" | "purple" | "rebeccapurple" | "red" | "rosybrown" | "royalblue" | "saddlebrown" | "salmon" | "sandybrown" | "seagreen" | "seashell" | "sienna" | "silver" | "skyblue" | "slateblue" | "slategray" | "slategrey" | "snow" | "springgreen" | "steelblue" | "tan" | "teal" | "thistle" | "tomato" | "turquoise" | "violet" | "wheat" | "white" | "whitesmoke" | "yellow" | "yellowgreen";
65
+ type StopInput = {
66
+ color?: ColorValueHex | CssColorName | RGB | [number, number, number];
67
+ colorLess?: boolean;
68
+ position: number;
69
+ };
70
+ type StopOutput = {
71
+ color: [number, number, number] | undefined;
72
+ colorLess?: boolean;
73
+ position: number;
74
+ };
75
+ type RGB = {
76
+ b: number;
77
+ g: number;
78
+ r: number;
79
+ };
80
+
81
+ declare class GradientBuilder {
82
+ #private;
83
+ readonly stops: StopOutput[];
84
+ constructor(colorize: ColorizeType, stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[]);
85
+ reverse(): GradientBuilder;
86
+ loop(): GradientBuilder;
87
+ rgb(steps: number): ColorizeType[];
88
+ hsv(steps: number, mode?: boolean | "long" | "short"): ColorizeType[];
89
+ }
90
+
91
+ declare const gradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [
92
+ number,
93
+ number,
94
+ number
95
+ ])[], options?: {
96
+ hsvSpin?: "long" | "short";
97
+ interpolation?: "hsv" | "rgb";
98
+ loop?: boolean;
99
+ reverse?: boolean;
100
+ }) => (string_: string) => string;
101
+ declare const multilineGradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [
102
+ number,
103
+ number,
104
+ number
105
+ ])[], options?: {
106
+ hsvSpin?: "long" | "short";
107
+ interpolation?: "hsv" | "rgb";
108
+ loop?: boolean;
109
+ reverse?: boolean;
110
+ }) => (string_: string) => string;
111
+
112
+ export { GradientBuilder, gradient, multilineGradient };