@visulima/colorize 2.0.0-alpha.10 → 2.0.0-alpha.11

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.
Files changed (99) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/gradient.cjs +3 -62
  3. package/dist/gradient.d.cts +21 -12
  4. package/dist/gradient.d.mts +21 -12
  5. package/dist/gradient.d.ts +21 -12
  6. package/dist/gradient.mjs +3 -56
  7. package/dist/index.browser.d.mts +203 -60
  8. package/dist/index.browser.d.ts +204 -0
  9. package/dist/index.browser.mjs +1 -61
  10. package/dist/index.server.cjs +2 -255
  11. package/dist/index.server.d.cts +12 -6
  12. package/dist/index.server.d.mts +203 -60
  13. package/dist/index.server.d.ts +12 -6
  14. package/dist/index.server.mjs +1 -61
  15. package/dist/packem_shared/Colorize-BUAQi0t0.js +2 -0
  16. package/dist/packem_shared/Colorize-i0NybjSp.js +1 -0
  17. package/dist/packem_shared/GradientBuilder-CudosKb8.cjs +1 -0
  18. package/dist/packem_shared/GradientBuilder-Du8WSL23.mjs +1 -0
  19. package/dist/packem_shared/colorize.server-BkQZGeaS.mjs +2 -0
  20. package/dist/packem_shared/colorize.server-Dn-gV0MN.cjs +2 -0
  21. package/dist/packem_shared/convertHexToRgb-CJNE3k_E.mjs +1 -0
  22. package/dist/packem_shared/convertHexToRgb-Dvalc5FD.cjs +1 -0
  23. package/dist/packem_shared/rgbToAnsi256--f09kvlF.cjs +1 -0
  24. package/dist/packem_shared/rgbToAnsi256-YETEPW8R.mjs +1 -0
  25. package/dist/packem_shared/types.d-bhP-2hCu.d.cts +154 -0
  26. package/dist/packem_shared/types.d-bhP-2hCu.d.mts +154 -0
  27. package/dist/packem_shared/types.d-bhP-2hCu.d.ts +154 -0
  28. package/dist/template.cjs +2 -152
  29. package/dist/template.d.cts +10 -4
  30. package/dist/template.d.mts +4 -4
  31. package/dist/template.d.ts +10 -4
  32. package/dist/template.mjs +2 -146
  33. package/dist/utils.cjs +1 -13
  34. package/dist/utils.d.cts +13 -2
  35. package/dist/utils.d.mts +13 -2
  36. package/dist/utils.d.ts +13 -2
  37. package/dist/utils.mjs +1 -2
  38. package/package.json +47 -47
  39. package/dist/ansi-codes.d.cts +0 -18
  40. package/dist/ansi-codes.d.mts +0 -18
  41. package/dist/ansi-codes.d.ts +0 -18
  42. package/dist/colorize.browser.d.mts +0 -3
  43. package/dist/colorize.server.d.cts +0 -10
  44. package/dist/colorize.server.d.mts +0 -10
  45. package/dist/colorize.server.d.ts +0 -10
  46. package/dist/css-code.d.mts +0 -11
  47. package/dist/gradient/gradient-builder.d.cts +0 -10
  48. package/dist/gradient/gradient-builder.d.mts +0 -10
  49. package/dist/gradient/gradient-builder.d.ts +0 -10
  50. package/dist/gradient/util/color-names.d.cts +0 -2
  51. package/dist/gradient/util/color-names.d.mts +0 -2
  52. package/dist/gradient/util/color-names.d.ts +0 -2
  53. package/dist/gradient/util/compute.d.cts +0 -2
  54. package/dist/gradient/util/compute.d.mts +0 -2
  55. package/dist/gradient/util/compute.d.ts +0 -2
  56. package/dist/gradient/util/hsv-to-rgb.d.cts +0 -5
  57. package/dist/gradient/util/hsv-to-rgb.d.mts +0 -5
  58. package/dist/gradient/util/hsv-to-rgb.d.ts +0 -5
  59. package/dist/gradient/util/interpolate.d.cts +0 -3
  60. package/dist/gradient/util/interpolate.d.mts +0 -3
  61. package/dist/gradient/util/interpolate.d.ts +0 -3
  62. package/dist/gradient/util/rgb-to-hsv.d.cts +0 -9
  63. package/dist/gradient/util/rgb-to-hsv.d.mts +0 -9
  64. package/dist/gradient/util/rgb-to-hsv.d.ts +0 -9
  65. package/dist/packem_shared/Colorize-BQ-Wlgs0.js +0 -409
  66. package/dist/packem_shared/Colorize-rJUN0RFg.js +0 -250
  67. package/dist/packem_shared/GradientBuilder-CkX4Imo9.mjs +0 -483
  68. package/dist/packem_shared/GradientBuilder-DRrwebdU.cjs +0 -487
  69. package/dist/packem_shared/colorize.server-CwTmhs0e.cjs +0 -198
  70. package/dist/packem_shared/colorize.server-YxoHIDUp.mjs +0 -196
  71. package/dist/packem_shared/convertHexToRgb-51-edHxE.cjs +0 -21
  72. package/dist/packem_shared/convertHexToRgb-BZwJEiMZ.mjs +0 -17
  73. package/dist/packem_shared/rgbToAnsi256-BdS0fomP.mjs +0 -41
  74. package/dist/packem_shared/rgbToAnsi256-DL8eajTz.cjs +0 -47
  75. package/dist/template/make-colorize-template.d.cts +0 -9
  76. package/dist/template/make-colorize-template.d.mts +0 -9
  77. package/dist/template/make-colorize-template.d.ts +0 -9
  78. package/dist/template/make-template.d.cts +0 -10
  79. package/dist/template/make-template.d.mts +0 -10
  80. package/dist/template/make-template.d.ts +0 -10
  81. package/dist/types.d.cts +0 -174
  82. package/dist/types.d.mts +0 -174
  83. package/dist/types.d.ts +0 -174
  84. package/dist/util/ansi-code-hex-map.d.mts +0 -8
  85. package/dist/util/clamp.d.cts +0 -12
  86. package/dist/util/clamp.d.mts +0 -12
  87. package/dist/util/clamp.d.ts +0 -12
  88. package/dist/util/convert-hex-to-rgb.d.cts +0 -8
  89. package/dist/util/convert-hex-to-rgb.d.mts +0 -8
  90. package/dist/util/convert-hex-to-rgb.d.ts +0 -8
  91. package/dist/util/convert-rgb-to-ansi.d.cts +0 -18
  92. package/dist/util/convert-rgb-to-ansi.d.mts +0 -18
  93. package/dist/util/convert-rgb-to-ansi.d.ts +0 -18
  94. package/dist/util/string-replace-all.d.cts +0 -12
  95. package/dist/util/string-replace-all.d.mts +0 -12
  96. package/dist/util/string-replace-all.d.ts +0 -12
  97. package/dist/util/unescape.d.cts +0 -9
  98. package/dist/util/unescape.d.mts +0 -9
  99. package/dist/util/unescape.d.ts +0 -9
@@ -0,0 +1,154 @@
1
+ type ColorValueHex = `#${string}`;
2
+ interface ColorizeType {
3
+ /**
4
+ * Return styled string.
5
+ * @param {string | TemplateStringsArray} string
6
+ */
7
+ (string: number | string): string;
8
+ (string: TemplateStringsArray, ...parameters: string[]): string;
9
+ /**
10
+ * Set [256-color ANSI code](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) for foreground color.
11
+ *
12
+ * Code ranges:
13
+ * ```
14
+ * 0 - 7: standard colors
15
+ * 8 - 15: high intensity colors
16
+ * 16 - 231: 6 × 6 × 6 cube (216 colors)
17
+ * 232 - 255: grayscale from black to white in 24 steps
18
+ * ```
19
+ * @param {number} code in range [0, 255].
20
+ */
21
+ ansi256: (code: number) => this;
22
+ /**
23
+ * Alias for bgAnsi256.
24
+ * @param {number} code in range [0, 255].
25
+ */
26
+ bg: (code: number) => this;
27
+ /**
28
+ * Set [256-color ANSI code](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) for background color.
29
+ *
30
+ * Code ranges:
31
+ * ```
32
+ * 0 - 7: standard colors
33
+ * 8 - 15: high intensity colors
34
+ * 16 - 231: 6 × 6 × 6 cube (216 colors)
35
+ * 232 - 255: grayscale from black to white in 24 steps
36
+ * ```
37
+ * @param {number} code in range [0, 255].
38
+ */
39
+ bgAnsi256: (code: number) => this;
40
+ readonly bgBlack: this;
41
+ readonly bgBlackBright: this;
42
+ readonly bgBlue: this;
43
+ readonly bgBlueBright: this;
44
+ readonly bgCyan: this;
45
+ readonly bgCyanBright: this;
46
+ readonly bgGray: this;
47
+ readonly bgGreen: this;
48
+ readonly bgGreenBright: this;
49
+ readonly bgGrey: this;
50
+ /**
51
+ * Set HEX value for background color.
52
+ * @param {string} color
53
+ */
54
+ bgHex: (color: ColorValueHex) => this;
55
+ readonly bgMagenta: this;
56
+ readonly bgMagentaBright: this;
57
+ readonly bgRed: this;
58
+ readonly bgRedBright: this;
59
+ /**
60
+ * Set RGB values for background color.
61
+ * @param {number} red The red value, in range [0, 255].
62
+ * @param {number} green The green value, in range [0, 255].
63
+ * @param {number} blue The blue value, in range [0, 255].
64
+ */
65
+ bgRgb: (red: number, green: number, blue: number) => this;
66
+ readonly bgWhite: this;
67
+ readonly bgWhiteBright: this;
68
+ readonly bgYellow: this;
69
+ readonly bgYellowBright: this;
70
+ readonly black: this;
71
+ readonly blackBright: this;
72
+ readonly blue: this;
73
+ readonly blueBright: this;
74
+ /** <b>Bold</b> style (high intensity). */
75
+ readonly bold: this;
76
+ /** The ANSI escape sequences for ending the current style. */
77
+ readonly close: string;
78
+ readonly cyan: this;
79
+ readonly cyanBright: this;
80
+ /** Faint style (low intensity or dim). */
81
+ readonly dim: this;
82
+ /**
83
+ * Alias for ansi256.
84
+ * @param {number} code in range [0, 255].
85
+ */
86
+ fg: (code: number) => this;
87
+ readonly gray: this;
88
+ readonly green: this;
89
+ readonly greenBright: this;
90
+ readonly grey: this;
91
+ /**
92
+ * Set HEX value for foreground color.
93
+ * @param {string} color
94
+ */
95
+ hex: (color: ColorValueHex) => this;
96
+ /** Print the invisible text. */
97
+ readonly hidden: this;
98
+ /** Invert background and foreground colors. */
99
+ readonly inverse: this;
100
+ /** <i>Italic</i> style. (Not widely supported) */
101
+ readonly italic: this;
102
+ readonly magenta: this;
103
+ readonly magentaBright: this;
104
+ /** The ANSI escape sequences for starting the current style. */
105
+ readonly open: string;
106
+ /** O̅v̅e̅r̅l̅i̅n̅e̅ style. (Not widely supported) */
107
+ readonly overline: this;
108
+ readonly red: this;
109
+ readonly redBright: this;
110
+ /** Reset the current style. */
111
+ readonly reset: this;
112
+ /**
113
+ * Set RGB values for foreground color.
114
+ * @param {number} red The red value, in range [0, 255].
115
+ * @param {number} green The green value, in range [0, 255].
116
+ * @param {number} blue The blue value, in range [0, 255].
117
+ */
118
+ rgb: (red: number, green: number, blue: number) => this;
119
+ /** S̶t̶r̶i̶k̶e̶t̶h̶r̶o̶u̶g̶h̶ style. (Not widely supported) The alias for `strikethrough`. */
120
+ readonly strike: this;
121
+ /** S̶t̶r̶i̶k̶e̶t̶h̶r̶o̶u̶g̶h̶ style. (Not widely supported) */
122
+ readonly strikethrough: this;
123
+ /**
124
+ * Remove ANSI styling codes.
125
+ * @param {string} string
126
+ * @returns {string}
127
+ */
128
+ strip: (string: string) => string;
129
+ /** U̲n̲d̲e̲r̲l̲i̲n̲e̲ style. (Not widely supported) */
130
+ readonly underline: this;
131
+ /** Print visible text without ANSI styling. */
132
+ readonly visible: this;
133
+ readonly white: this;
134
+ readonly whiteBright: this;
135
+ readonly yellow: this;
136
+ readonly yellowBright: this;
137
+ }
138
+ 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";
139
+ type StopInput = {
140
+ color?: ColorValueHex | CssColorName | RGB | [number, number, number];
141
+ colorLess?: boolean;
142
+ position: number;
143
+ };
144
+ type StopOutput = {
145
+ color: [number, number, number] | undefined;
146
+ colorLess?: boolean;
147
+ position: number;
148
+ };
149
+ type RGB = {
150
+ b: number;
151
+ g: number;
152
+ r: number;
153
+ };
154
+ export { ColorizeType as C, RGB as R, StopOutput as S, ColorValueHex as a, CssColorName as b, StopInput as c };
@@ -0,0 +1,154 @@
1
+ type ColorValueHex = `#${string}`;
2
+ interface ColorizeType {
3
+ /**
4
+ * Return styled string.
5
+ * @param {string | TemplateStringsArray} string
6
+ */
7
+ (string: number | string): string;
8
+ (string: TemplateStringsArray, ...parameters: string[]): string;
9
+ /**
10
+ * Set [256-color ANSI code](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) for foreground color.
11
+ *
12
+ * Code ranges:
13
+ * ```
14
+ * 0 - 7: standard colors
15
+ * 8 - 15: high intensity colors
16
+ * 16 - 231: 6 × 6 × 6 cube (216 colors)
17
+ * 232 - 255: grayscale from black to white in 24 steps
18
+ * ```
19
+ * @param {number} code in range [0, 255].
20
+ */
21
+ ansi256: (code: number) => this;
22
+ /**
23
+ * Alias for bgAnsi256.
24
+ * @param {number} code in range [0, 255].
25
+ */
26
+ bg: (code: number) => this;
27
+ /**
28
+ * Set [256-color ANSI code](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) for background color.
29
+ *
30
+ * Code ranges:
31
+ * ```
32
+ * 0 - 7: standard colors
33
+ * 8 - 15: high intensity colors
34
+ * 16 - 231: 6 × 6 × 6 cube (216 colors)
35
+ * 232 - 255: grayscale from black to white in 24 steps
36
+ * ```
37
+ * @param {number} code in range [0, 255].
38
+ */
39
+ bgAnsi256: (code: number) => this;
40
+ readonly bgBlack: this;
41
+ readonly bgBlackBright: this;
42
+ readonly bgBlue: this;
43
+ readonly bgBlueBright: this;
44
+ readonly bgCyan: this;
45
+ readonly bgCyanBright: this;
46
+ readonly bgGray: this;
47
+ readonly bgGreen: this;
48
+ readonly bgGreenBright: this;
49
+ readonly bgGrey: this;
50
+ /**
51
+ * Set HEX value for background color.
52
+ * @param {string} color
53
+ */
54
+ bgHex: (color: ColorValueHex) => this;
55
+ readonly bgMagenta: this;
56
+ readonly bgMagentaBright: this;
57
+ readonly bgRed: this;
58
+ readonly bgRedBright: this;
59
+ /**
60
+ * Set RGB values for background color.
61
+ * @param {number} red The red value, in range [0, 255].
62
+ * @param {number} green The green value, in range [0, 255].
63
+ * @param {number} blue The blue value, in range [0, 255].
64
+ */
65
+ bgRgb: (red: number, green: number, blue: number) => this;
66
+ readonly bgWhite: this;
67
+ readonly bgWhiteBright: this;
68
+ readonly bgYellow: this;
69
+ readonly bgYellowBright: this;
70
+ readonly black: this;
71
+ readonly blackBright: this;
72
+ readonly blue: this;
73
+ readonly blueBright: this;
74
+ /** <b>Bold</b> style (high intensity). */
75
+ readonly bold: this;
76
+ /** The ANSI escape sequences for ending the current style. */
77
+ readonly close: string;
78
+ readonly cyan: this;
79
+ readonly cyanBright: this;
80
+ /** Faint style (low intensity or dim). */
81
+ readonly dim: this;
82
+ /**
83
+ * Alias for ansi256.
84
+ * @param {number} code in range [0, 255].
85
+ */
86
+ fg: (code: number) => this;
87
+ readonly gray: this;
88
+ readonly green: this;
89
+ readonly greenBright: this;
90
+ readonly grey: this;
91
+ /**
92
+ * Set HEX value for foreground color.
93
+ * @param {string} color
94
+ */
95
+ hex: (color: ColorValueHex) => this;
96
+ /** Print the invisible text. */
97
+ readonly hidden: this;
98
+ /** Invert background and foreground colors. */
99
+ readonly inverse: this;
100
+ /** <i>Italic</i> style. (Not widely supported) */
101
+ readonly italic: this;
102
+ readonly magenta: this;
103
+ readonly magentaBright: this;
104
+ /** The ANSI escape sequences for starting the current style. */
105
+ readonly open: string;
106
+ /** O̅v̅e̅r̅l̅i̅n̅e̅ style. (Not widely supported) */
107
+ readonly overline: this;
108
+ readonly red: this;
109
+ readonly redBright: this;
110
+ /** Reset the current style. */
111
+ readonly reset: this;
112
+ /**
113
+ * Set RGB values for foreground color.
114
+ * @param {number} red The red value, in range [0, 255].
115
+ * @param {number} green The green value, in range [0, 255].
116
+ * @param {number} blue The blue value, in range [0, 255].
117
+ */
118
+ rgb: (red: number, green: number, blue: number) => this;
119
+ /** S̶t̶r̶i̶k̶e̶t̶h̶r̶o̶u̶g̶h̶ style. (Not widely supported) The alias for `strikethrough`. */
120
+ readonly strike: this;
121
+ /** S̶t̶r̶i̶k̶e̶t̶h̶r̶o̶u̶g̶h̶ style. (Not widely supported) */
122
+ readonly strikethrough: this;
123
+ /**
124
+ * Remove ANSI styling codes.
125
+ * @param {string} string
126
+ * @returns {string}
127
+ */
128
+ strip: (string: string) => string;
129
+ /** U̲n̲d̲e̲r̲l̲i̲n̲e̲ style. (Not widely supported) */
130
+ readonly underline: this;
131
+ /** Print visible text without ANSI styling. */
132
+ readonly visible: this;
133
+ readonly white: this;
134
+ readonly whiteBright: this;
135
+ readonly yellow: this;
136
+ readonly yellowBright: this;
137
+ }
138
+ 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";
139
+ type StopInput = {
140
+ color?: ColorValueHex | CssColorName | RGB | [number, number, number];
141
+ colorLess?: boolean;
142
+ position: number;
143
+ };
144
+ type StopOutput = {
145
+ color: [number, number, number] | undefined;
146
+ colorLess?: boolean;
147
+ position: number;
148
+ };
149
+ type RGB = {
150
+ b: number;
151
+ g: number;
152
+ r: number;
153
+ };
154
+ export { ColorizeType as C, RGB as R, StopOutput as S, ColorValueHex as a, CssColorName as b, StopInput as c };
@@ -0,0 +1,154 @@
1
+ type ColorValueHex = `#${string}`;
2
+ interface ColorizeType {
3
+ /**
4
+ * Return styled string.
5
+ * @param {string | TemplateStringsArray} string
6
+ */
7
+ (string: number | string): string;
8
+ (string: TemplateStringsArray, ...parameters: string[]): string;
9
+ /**
10
+ * Set [256-color ANSI code](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) for foreground color.
11
+ *
12
+ * Code ranges:
13
+ * ```
14
+ * 0 - 7: standard colors
15
+ * 8 - 15: high intensity colors
16
+ * 16 - 231: 6 × 6 × 6 cube (216 colors)
17
+ * 232 - 255: grayscale from black to white in 24 steps
18
+ * ```
19
+ * @param {number} code in range [0, 255].
20
+ */
21
+ ansi256: (code: number) => this;
22
+ /**
23
+ * Alias for bgAnsi256.
24
+ * @param {number} code in range [0, 255].
25
+ */
26
+ bg: (code: number) => this;
27
+ /**
28
+ * Set [256-color ANSI code](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) for background color.
29
+ *
30
+ * Code ranges:
31
+ * ```
32
+ * 0 - 7: standard colors
33
+ * 8 - 15: high intensity colors
34
+ * 16 - 231: 6 × 6 × 6 cube (216 colors)
35
+ * 232 - 255: grayscale from black to white in 24 steps
36
+ * ```
37
+ * @param {number} code in range [0, 255].
38
+ */
39
+ bgAnsi256: (code: number) => this;
40
+ readonly bgBlack: this;
41
+ readonly bgBlackBright: this;
42
+ readonly bgBlue: this;
43
+ readonly bgBlueBright: this;
44
+ readonly bgCyan: this;
45
+ readonly bgCyanBright: this;
46
+ readonly bgGray: this;
47
+ readonly bgGreen: this;
48
+ readonly bgGreenBright: this;
49
+ readonly bgGrey: this;
50
+ /**
51
+ * Set HEX value for background color.
52
+ * @param {string} color
53
+ */
54
+ bgHex: (color: ColorValueHex) => this;
55
+ readonly bgMagenta: this;
56
+ readonly bgMagentaBright: this;
57
+ readonly bgRed: this;
58
+ readonly bgRedBright: this;
59
+ /**
60
+ * Set RGB values for background color.
61
+ * @param {number} red The red value, in range [0, 255].
62
+ * @param {number} green The green value, in range [0, 255].
63
+ * @param {number} blue The blue value, in range [0, 255].
64
+ */
65
+ bgRgb: (red: number, green: number, blue: number) => this;
66
+ readonly bgWhite: this;
67
+ readonly bgWhiteBright: this;
68
+ readonly bgYellow: this;
69
+ readonly bgYellowBright: this;
70
+ readonly black: this;
71
+ readonly blackBright: this;
72
+ readonly blue: this;
73
+ readonly blueBright: this;
74
+ /** <b>Bold</b> style (high intensity). */
75
+ readonly bold: this;
76
+ /** The ANSI escape sequences for ending the current style. */
77
+ readonly close: string;
78
+ readonly cyan: this;
79
+ readonly cyanBright: this;
80
+ /** Faint style (low intensity or dim). */
81
+ readonly dim: this;
82
+ /**
83
+ * Alias for ansi256.
84
+ * @param {number} code in range [0, 255].
85
+ */
86
+ fg: (code: number) => this;
87
+ readonly gray: this;
88
+ readonly green: this;
89
+ readonly greenBright: this;
90
+ readonly grey: this;
91
+ /**
92
+ * Set HEX value for foreground color.
93
+ * @param {string} color
94
+ */
95
+ hex: (color: ColorValueHex) => this;
96
+ /** Print the invisible text. */
97
+ readonly hidden: this;
98
+ /** Invert background and foreground colors. */
99
+ readonly inverse: this;
100
+ /** <i>Italic</i> style. (Not widely supported) */
101
+ readonly italic: this;
102
+ readonly magenta: this;
103
+ readonly magentaBright: this;
104
+ /** The ANSI escape sequences for starting the current style. */
105
+ readonly open: string;
106
+ /** O̅v̅e̅r̅l̅i̅n̅e̅ style. (Not widely supported) */
107
+ readonly overline: this;
108
+ readonly red: this;
109
+ readonly redBright: this;
110
+ /** Reset the current style. */
111
+ readonly reset: this;
112
+ /**
113
+ * Set RGB values for foreground color.
114
+ * @param {number} red The red value, in range [0, 255].
115
+ * @param {number} green The green value, in range [0, 255].
116
+ * @param {number} blue The blue value, in range [0, 255].
117
+ */
118
+ rgb: (red: number, green: number, blue: number) => this;
119
+ /** S̶t̶r̶i̶k̶e̶t̶h̶r̶o̶u̶g̶h̶ style. (Not widely supported) The alias for `strikethrough`. */
120
+ readonly strike: this;
121
+ /** S̶t̶r̶i̶k̶e̶t̶h̶r̶o̶u̶g̶h̶ style. (Not widely supported) */
122
+ readonly strikethrough: this;
123
+ /**
124
+ * Remove ANSI styling codes.
125
+ * @param {string} string
126
+ * @returns {string}
127
+ */
128
+ strip: (string: string) => string;
129
+ /** U̲n̲d̲e̲r̲l̲i̲n̲e̲ style. (Not widely supported) */
130
+ readonly underline: this;
131
+ /** Print visible text without ANSI styling. */
132
+ readonly visible: this;
133
+ readonly white: this;
134
+ readonly whiteBright: this;
135
+ readonly yellow: this;
136
+ readonly yellowBright: this;
137
+ }
138
+ 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";
139
+ type StopInput = {
140
+ color?: ColorValueHex | CssColorName | RGB | [number, number, number];
141
+ colorLess?: boolean;
142
+ position: number;
143
+ };
144
+ type StopOutput = {
145
+ color: [number, number, number] | undefined;
146
+ colorLess?: boolean;
147
+ position: number;
148
+ };
149
+ type RGB = {
150
+ b: number;
151
+ g: number;
152
+ r: number;
153
+ };
154
+ export { ColorizeType as C, RGB as R, StopOutput as S, ColorValueHex as a, CssColorName as b, StopInput as c };
package/dist/template.cjs CHANGED
@@ -1,152 +1,2 @@
1
- 'use strict';
2
-
3
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
-
5
- const colorize_server = require('./packem_shared/colorize.server-CwTmhs0e.cjs');
6
- const convertHexToRgb = require('./packem_shared/convertHexToRgb-51-edHxE.cjs');
7
-
8
- const makeColorizeTemplate = (template) => (firstString, ...arguments_) => {
9
- if (!Array.isArray(firstString) || !Array.isArray(firstString.raw)) {
10
- throw new TypeError("A tagged template literal must be provided");
11
- }
12
- const parts = [firstString.raw[0]];
13
- for (let index = 1; index < firstString.raw.length; index += 1) {
14
- parts.push(String(arguments_[index - 1]).replaceAll(/[{}\\]/g, String.raw`\$&`), String(firstString.raw[index]));
15
- }
16
- return template(parts.join(""));
17
- };
18
-
19
- const ESCAPES = /* @__PURE__ */ new Map([
20
- ["0", "\0"],
21
- ["\\", "\\"],
22
- ["a", "\x07"],
23
- ["b", "\b"],
24
- ["e", "\x1B"],
25
- ["f", "\f"],
26
- ["n", "\n"],
27
- ["r", "\r"],
28
- ["t", " "],
29
- ["v", "\v"]
30
- ]);
31
- const unescape = (c) => {
32
- const u = c.startsWith("u");
33
- const bracket = c[1] === "{";
34
- if (u && !bracket && c.length === 5 || c.startsWith("x") && c.length === 3) {
35
- return String.fromCodePoint(Number.parseInt(c.slice(1), 16));
36
- }
37
- if (u && bracket) {
38
- return String.fromCodePoint(Number.parseInt(c.slice(2, -1), 16));
39
- }
40
- return ESCAPES.get(c) ?? c;
41
- };
42
-
43
- const TEMPLATE_REGEX = /\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|\{(~)?(#?[\w:]+(?:\([^)]*\))?(?:\.#?[\w:]+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n))|(\})|((?:.|[\r\n\f])+?)/gi;
44
- const STYLE_REGEX = /(?:^|\.)(?:(\w+)(?:\(([^)]*)\))?|#(?=[:a-f\d]{2,})([a-f\d]{6})?(?::([a-f\d]{6}))?)/gi;
45
- const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
46
- const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi;
47
- const CHUNK_SPLIT_REGEX = /\s*,\s*/;
48
- const parseArguments = (name, value) => {
49
- const results = [];
50
- const chunks = value.trim().split(CHUNK_SPLIT_REGEX);
51
- let matches;
52
- for (const chunk of chunks) {
53
- const number = Number(chunk);
54
- if (!Number.isNaN(number)) {
55
- results.push(number);
56
- } else if (matches = STRING_REGEX.exec(chunk)) {
57
- results.push(
58
- matches[2].replaceAll(ESCAPE_REGEX, (_, escape, character) => {
59
- if (escape) {
60
- return unescape(escape);
61
- }
62
- return character;
63
- })
64
- );
65
- } else {
66
- throw new Error(`Invalid template style argument: ${chunk} (in style '${name}')`);
67
- }
68
- }
69
- return results;
70
- };
71
- const parseStyle = (style) => {
72
- STYLE_REGEX.lastIndex = 0;
73
- const results = [];
74
- let matches;
75
- while ((matches = STYLE_REGEX.exec(style)) !== null) {
76
- const name = matches[1];
77
- if (matches[2]) {
78
- results.push([name, ...parseArguments(name, matches[2])]);
79
- } else if (matches[3] || matches[4]) {
80
- if (matches[3]) {
81
- results.push(["rgb", ...convertHexToRgb.convertHexToRgb(matches[3])]);
82
- }
83
- if (matches[4]) {
84
- results.push(["bgRgb", ...convertHexToRgb.convertHexToRgb(matches[4])]);
85
- }
86
- } else {
87
- results.push([name]);
88
- }
89
- }
90
- return results;
91
- };
92
- const buildStyle = (colorize, styles) => {
93
- const enabled = {};
94
- for (const layer of styles) {
95
- for (const style of layer.styles) {
96
- enabled[style[0]] = layer.inverse ? void 0 : style.slice(1);
97
- }
98
- }
99
- let current = colorize;
100
- for (const [styleName, enabledStyles] of Object.entries(enabled)) {
101
- if (!Array.isArray(enabledStyles)) {
102
- continue;
103
- }
104
- if (!(styleName in current)) {
105
- throw new Error(`Unknown style: ${styleName}`);
106
- }
107
- current = enabledStyles.length > 0 ? current[styleName](...enabledStyles) : current[styleName];
108
- }
109
- return current;
110
- };
111
- const makeTemplate = (colorize) => (string) => {
112
- const styles = [];
113
- const chunks = [];
114
- let chunk = [];
115
- string.replaceAll(
116
- TEMPLATE_REGEX,
117
- // @ts-expect-error - TS doesn't understand that the regex args are defined
118
- (_, escapeCharacter, inverse, style, close, character) => {
119
- if (escapeCharacter) {
120
- chunk.push(unescape(escapeCharacter));
121
- } else if (style) {
122
- const joinedChunk = chunk.join("");
123
- chunk = [];
124
- chunks.push(styles.length === 0 ? joinedChunk : buildStyle(colorize, styles)(joinedChunk));
125
- styles.push({ inverse, styles: parseStyle(style) });
126
- } else if (close) {
127
- if (styles.length === 0) {
128
- throw new Error("Found extraneous } in template literal");
129
- }
130
- chunks.push(buildStyle(colorize, styles)(chunk.join("")));
131
- chunk = [];
132
- styles.pop();
133
- } else {
134
- chunk.push(character);
135
- }
136
- }
137
- );
138
- chunks.push(chunk.join(""));
139
- if (styles.length > 0) {
140
- throw new Error(`template literal is missing ${String(styles.length)} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`);
141
- }
142
- return chunks.join("");
143
- };
144
-
145
- const colorize = new colorize_server.Colorize();
146
- const makeTaggedTemplate = (instance) => makeColorizeTemplate(makeTemplate(instance));
147
- const template = makeTemplate(colorize);
148
- const templateFunction = makeColorizeTemplate(template);
149
-
150
- module.exports = templateFunction;
151
- module.exports.makeTaggedTemplate = makeTaggedTemplate;
152
- module.exports.template = template;
1
+ "use strict";var T=Object.defineProperty;var i=(e,t)=>T(e,"name",{value:t,configurable:!0});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=require("./packem_shared/colorize.server-Dn-gV0MN.cjs"),f=require("./packem_shared/convertHexToRgb-Dvalc5FD.cjs");var A=Object.defineProperty,j=i((e,t)=>A(e,"name",{value:t,configurable:!0}),"n");const h=j(e=>(t,...r)=>{if(!Array.isArray(t)||!Array.isArray(t.raw))throw new TypeError("A tagged template literal must be provided");const a=[t.raw[0]];for(let n=1;n<t.raw.length;n+=1)a.push(String(r[n-1]).replaceAll(/[{}\\]/g,String.raw`\$&`),String(t.raw[n]));return e(a.join(""))},"makeColorizeTemplate");var k=Object.defineProperty,S=i((e,t)=>k(e,"name",{value:t,configurable:!0}),"e$1");const $=new Map([["0","\0"],["\\","\\"],["a","\x07"],["b","\b"],["e","\x1B"],["f","\f"],["n",`
2
+ `],["r","\r"],["t"," "],["v","\v"]]),b=S(e=>{const t=e.startsWith("u"),r=e[1]==="{";return t&&!r&&e.length===5||e.startsWith("x")&&e.length===3?String.fromCodePoint(Number.parseInt(e.slice(1),16)):t&&r?String.fromCodePoint(Number.parseInt(e.slice(2,-1),16)):$.get(e)??e},"unescape");var P=Object.defineProperty,u=i((e,t)=>P(e,"name",{value:t,configurable:!0}),"u");const E=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|\{(~)?(#?[\w:]+(?:\([^)]*\))?(?:\.#?[\w:]+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n))|(\})|((?:.|[\r\n\f])+?)/gi,m=/(?:^|\.)(?:(\w+)(?:\(([^)]*)\))?|#(?=[:a-f\d]{2,})([a-f\d]{6})?(?::([a-f\d]{6}))?)/gi,N=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,O=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi,R=/\s*,\s*/,C=u((e,t)=>{const r=[],a=t.trim().split(R);let n;for(const s of a){const o=Number(s);if(!Number.isNaN(o))r.push(o);else if(n=N.exec(s))r.push(n[2].replaceAll(O,(p,l,c)=>l?b(l):c));else throw new Error(`Invalid template style argument: ${s} (in style '${e}')`)}return r},"parseArguments"),I=u(e=>{m.lastIndex=0;const t=[];let r;for(;(r=m.exec(e))!==null;){const a=r[1];r[2]?t.push([a,...C(a,r[2])]):r[3]||r[4]?(r[3]&&t.push(["rgb",...f.convertHexToRgb(r[3])]),r[4]&&t.push(["bgRgb",...f.convertHexToRgb(r[4])])):t.push([a])}return t},"parseStyle"),d=u((e,t)=>{const r={};for(const n of t)for(const s of n.styles)r[s[0]]=n.inverse?void 0:s.slice(1);let a=e;for(const[n,s]of Object.entries(r))if(Array.isArray(s)){if(!(n in a))throw new Error(`Unknown style: ${n}`);a=s.length>0?a[n](...s):a[n]}return a},"buildStyle"),v=u(e=>t=>{const r=[],a=[];let n=[];if(t.replaceAll(E,(s,o,p,l,c,y)=>{if(o)n.push(b(o));else if(l){const g=n.join("");n=[],a.push(r.length===0?g:d(e,r)(g)),r.push({inverse:p,styles:I(l)})}else if(c){if(r.length===0)throw new Error("Found extraneous } in template literal");a.push(d(e,r)(n.join(""))),n=[],r.pop()}else n.push(y)}),a.push(n.join("")),r.length>0)throw new Error(`template literal is missing ${String(r.length)} closing bracket${r.length===1?"":"s"} (\`}\`)`);return a.join("")},"makeTemplate");var z=Object.defineProperty,H=i((e,t)=>z(e,"name",{value:t,configurable:!0}),"e");const M=new x.A,_=H(e=>h(v(e)),"makeTaggedTemplate"),w=v(M),q=h(w);exports.default=q;exports.makeTaggedTemplate=_;exports.template=w;
@@ -1,5 +1,11 @@
1
- import type { ColorizeType } from "./types.d.cts";
2
- export declare const makeTaggedTemplate: (instance: ColorizeType) => (firstString: TemplateStringsArray, ...arguments_: any[]) => string;
3
- export declare const template: (string: string) => string;
4
- declare const templateFunction: (firstString: TemplateStringsArray, ...arguments_: any[]) => string;
1
+ // @ts-ignore
2
+ templateFunction;
3
+ export { makeTaggedTemplate, template };
4
+ declare namespace templateFunction {
5
+ export const makeTaggedTemplate: (instance: ColorizeType) => (firstString: TemplateStringsArray, ...arguments_: any[]) => string;
6
+ export const template: (string: string) => string;
7
+ export const templateFunction: (firstString: TemplateStringsArray, ...arguments_: any[]) => string;
8
+ import _default = templateFunction;
9
+ export { _default as default };
10
+ }
5
11
  export = templateFunction;
@@ -1,5 +1,5 @@
1
- import type { ColorizeType } from "./types.d.mts";
2
- export declare const makeTaggedTemplate: (instance: ColorizeType) => (firstString: TemplateStringsArray, ...arguments_: any[]) => string;
3
- export declare const template: (string: string) => string;
1
+ import { C as ColorizeType } from "./packem_shared/types.d-bhP-2hCu.mjs";
2
+ declare const makeTaggedTemplate: (instance: ColorizeType) => (firstString: TemplateStringsArray, ...arguments_: any[]) => string;
3
+ declare const template: (string: string) => string;
4
4
  declare const templateFunction: (firstString: TemplateStringsArray, ...arguments_: any[]) => string;
5
- export default templateFunction;
5
+ export { templateFunction as default, makeTaggedTemplate, template };
@@ -1,5 +1,11 @@
1
- import type { ColorizeType } from "./types.d.ts";
2
- export declare const makeTaggedTemplate: (instance: ColorizeType) => (firstString: TemplateStringsArray, ...arguments_: any[]) => string;
3
- export declare const template: (string: string) => string;
4
- declare const templateFunction: (firstString: TemplateStringsArray, ...arguments_: any[]) => string;
1
+ // @ts-ignore
2
+ templateFunction;
3
+ export { makeTaggedTemplate, template };
4
+ declare namespace templateFunction {
5
+ export const makeTaggedTemplate: (instance: ColorizeType) => (firstString: TemplateStringsArray, ...arguments_: any[]) => string;
6
+ export const template: (string: string) => string;
7
+ export const templateFunction: (firstString: TemplateStringsArray, ...arguments_: any[]) => string;
8
+ import _default = templateFunction;
9
+ export { _default as default };
10
+ }
5
11
  export = templateFunction;