@visulima/colorize 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/LICENSE.md +41 -0
- package/README.md +543 -0
- package/dist/index.cjs +13 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +70 -0
- package/dist/index.d.ts +127 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/package.json +182 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
## @visulima/colorize 1.0.0 (2024-01-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* added colorize and is-ansi-color-supported ([e2d9945](https://github.com/visulima/visulima/commit/e2d9945a5666bc8f3be0aea9b5aca45f2ba44284))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* added cross-env to test ([a7efeec](https://github.com/visulima/visulima/commit/a7efeece3c29bba85549c57a3e5efcfd3417f781))
|
|
12
|
+
* fixed wrong package.json ([43dd507](https://github.com/visulima/visulima/commit/43dd507419c7020251396bfc26854a360e72d605))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Dependencies
|
|
17
|
+
|
|
18
|
+
* **@visulima/is-ansi-color-supported:** upgraded to 1.0.0
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 visulima
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
Colorize is based on https://github.com/webdiscus/ansis
|
|
26
|
+
|
|
27
|
+
ISC License
|
|
28
|
+
|
|
29
|
+
Copyright (c) 2023, webdiscus
|
|
30
|
+
|
|
31
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
32
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
33
|
+
copyright notice and this permission notice appear in all copies.
|
|
34
|
+
|
|
35
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
36
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
37
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
38
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
39
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
40
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
41
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h3>Visulima Colorize</h3>
|
|
3
|
+
<p>
|
|
4
|
+
Terminal and Console string styling done right, powered by <a href="https://github.com/visulima/visulima/packages/is-ansi-color-supported">@visulima/is-ansi-color-supported</a>.
|
|
5
|
+
|
|
6
|
+
Colorize stands as a sleek, lightning-fast alternative to [Chalk][chalk], boasting a plethora of additional, valuable features.<br>
|
|
7
|
+
Elevate your terminal experience by effortlessly adding vibrant colors to your output with its clean and straightforward syntax.<br>
|
|
8
|
+
For instance, you can use `green` to make `` green`Hello World!` `` pop, `` red`Error!` `` to signify Errors, or `` black.bgYellow`Warning!` `` to highlight warnings.
|
|
9
|
+
|
|
10
|
+
</p>
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
<br />
|
|
14
|
+
|
|
15
|
+
<div align="center">
|
|
16
|
+
|
|
17
|
+
[![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url]
|
|
18
|
+
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
<div align="center">
|
|
24
|
+
<p>
|
|
25
|
+
<sup>
|
|
26
|
+
Daniel Bannert's open source work is supported by the community on <a href="https://github.com/sponsors/prisis">GitHub Sponsors</a>
|
|
27
|
+
</sup>
|
|
28
|
+
</p>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Why Colorize?
|
|
34
|
+
|
|
35
|
+
- Supports both **ESM** and **CommonJS**
|
|
36
|
+
- [Standard API](#base-colors) like **chalk**
|
|
37
|
+
- Default import
|
|
38
|
+
- `import colorize from '@visulima/colorize'` or `const colorize = require('@visulima/colorize')`
|
|
39
|
+
- [Named import](#named-import)
|
|
40
|
+
- `import { red } from '@visulima/colorize'` or `const { red } = require('@visulima/colorize')`
|
|
41
|
+
- [Chained syntax](#chained-syntax) `red.bold.underline('text')`
|
|
42
|
+
- [Template literals](#template-literals) `` red`text` ``
|
|
43
|
+
- [Nested **template strings**](#nested-syntax) `` red`R ${green`G`} R` ``
|
|
44
|
+
- [ANSI 256 colors](#256-colors) and [Truecolor](#truecolor) (**RGB**, **HEX**) `` rgb(224, 17, 95)`Ruby` ``, `` hex('#96C')`Amethyst` ``
|
|
45
|
+
- [ANSI codes](#escape-codes) as `open` and `close` property for each style `` `Hello ${red.open}World${red.close}!` ``
|
|
46
|
+
- [Strip ANSI codes](#strip) method `colorize.strip()`
|
|
47
|
+
- [Correct style break](#new-line) at the `end of line` when used `\n` in string
|
|
48
|
+
- Supports the [environment variables](#cli-vars) `NO_COLOR` `FORCE_COLOR` and flags `--no-color` `--color`
|
|
49
|
+
- Supports **Deno**, **Next.JS** runtimes and **Browser**
|
|
50
|
+
- Expressive API
|
|
51
|
+
- Doesn't extend `String.prototype`
|
|
52
|
+
- Up to **x3 faster** than **chalk**, [see benchmarks](#benchmark) and only **4.43 KB** dist code
|
|
53
|
+
- **Auto detects** color support
|
|
54
|
+
- **TypeScript** support out of the box
|
|
55
|
+
- Clean and focused
|
|
56
|
+
|
|
57
|
+
## Install
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
npm install @visulima/colorize
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
yarn add @visulima/colorize
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
pnpm add @visulima/colorize
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Demo
|
|
72
|
+
|
|
73
|
+
<center>
|
|
74
|
+
|
|
75
|
+

|
|
76
|
+
|
|
77
|
+
</center>
|
|
78
|
+
|
|
79
|
+
## Usage
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
// ESM default import
|
|
83
|
+
import colorize from "@visulima/colorize";
|
|
84
|
+
// ESM named import
|
|
85
|
+
import { red, green, blue } from "@visulima/colorize";
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
or
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
// CommonJS default import
|
|
92
|
+
const colorize = require("@visulima/colorize");
|
|
93
|
+
// CommonJS named import
|
|
94
|
+
const { red, green, blue } = require("@visulima/colorize");
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Some examples:
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
console.log(colorize.green("Success!"));
|
|
101
|
+
console.log(green("Success!"));
|
|
102
|
+
|
|
103
|
+
// template string
|
|
104
|
+
console.log(blue`Info!`);
|
|
105
|
+
|
|
106
|
+
// chained syntax
|
|
107
|
+
console.log(green.bold`Success!`);
|
|
108
|
+
|
|
109
|
+
// nested syntax
|
|
110
|
+
console.log(red`The ${blue.underline`file.js`} not found!`);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### API
|
|
114
|
+
|
|
115
|
+
Colors and styles have standard names used by many popular libraries, such
|
|
116
|
+
as [chalk][chalk], [colorette][colorette], [kleur][kleur].
|
|
117
|
+
|
|
118
|
+
| Foreground colors | Background colors | Styles |
|
|
119
|
+
| :-------------------- | :------------------------ | ----------------------------------------------------------------------- |
|
|
120
|
+
| `black` | `bgBlack` | `dim` |
|
|
121
|
+
| `red` | `bgRed` | **`bold`** |
|
|
122
|
+
| `green` | `bgGreen` | _`italic`_ |
|
|
123
|
+
| `yellow` | `bgYellow` | <u>`underline`</u> |
|
|
124
|
+
| `blue` | `bgBlue` | <s>`strikethrough`</s> (alias `strike`) |
|
|
125
|
+
| `magenta` | `bgMagenta` | <s>`doubleUnderline`</s> (_not included, because not widely supported_) |
|
|
126
|
+
| `cyan` | `bgCyan` | <s>`overline`</s> (_not included, because not widely supported_) |
|
|
127
|
+
| `white` | `bgWhite` | <s>`frame`</s> (_not included, because not widely supported_) |
|
|
128
|
+
| `gray` (alias `grey`) | `bgGray` (alias `bgGrey`) | <s>`encircle`</s> (_not included, because not widely supported_) |
|
|
129
|
+
| `blackBright` | `bgBlackBright` | `inverse` |
|
|
130
|
+
| `redBright` | `bgRedBright` | `visible` |
|
|
131
|
+
| `greenBright` | `bgGreenBright` | `hidden` |
|
|
132
|
+
| `yellowBright` | `bgYellowBright` | `reset` |
|
|
133
|
+
| `blueBright` | `bgBlueBright` | |
|
|
134
|
+
| `magentaBright` | `bgMagentaBright` | |
|
|
135
|
+
| `cyanBright` | `bgCyanBright` | |
|
|
136
|
+
| `whiteBright` | `bgWhiteBright` | |
|
|
137
|
+
|
|
138
|
+
### Named import
|
|
139
|
+
|
|
140
|
+
The `@visulima/colorize` supports both the `default import` and `named import`.
|
|
141
|
+
|
|
142
|
+
```js
|
|
143
|
+
// default import
|
|
144
|
+
import colorize from "@visulima/colorize";
|
|
145
|
+
|
|
146
|
+
colorize.red.bold("text");
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
You can import named colors, styles and functions. All imported colors and styles are `chainable`.
|
|
150
|
+
|
|
151
|
+
```js
|
|
152
|
+
// named import
|
|
153
|
+
import { red, hex, italic } from "@visulima/colorize";
|
|
154
|
+
|
|
155
|
+
red.bold("text");
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Default import and named import can be combined.
|
|
159
|
+
|
|
160
|
+
```js
|
|
161
|
+
// default and named import
|
|
162
|
+
import colorize, { red } from "@visulima/colorize";
|
|
163
|
+
|
|
164
|
+
const redText = red("text"); // colorized ANSI string
|
|
165
|
+
const text = colorize.strip(redText); // pure string without ANSI codes
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Template literals
|
|
169
|
+
|
|
170
|
+
The `@visulima/colorize` supports both the function syntax `red('error')` and template literals `` red`error` ``.
|
|
171
|
+
|
|
172
|
+
The `template literals` allow you to make a complex template more readable and shorter.\
|
|
173
|
+
The `function syntax` can be used to colorize a variable.
|
|
174
|
+
|
|
175
|
+
```js
|
|
176
|
+
import { red, blue } from "@visulima/colorize";
|
|
177
|
+
|
|
178
|
+
let message = "error";
|
|
179
|
+
|
|
180
|
+
red(message);
|
|
181
|
+
blue`text`;
|
|
182
|
+
blue`text ${message} text`;
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Chained syntax
|
|
186
|
+
|
|
187
|
+
All colors, styles and functions are chainable. Each color or style can be combined in any order.
|
|
188
|
+
|
|
189
|
+
```js
|
|
190
|
+
import { blue, bold, italic, hex } from "@visulima/colorize";
|
|
191
|
+
|
|
192
|
+
blue.bold`text`;
|
|
193
|
+
|
|
194
|
+
hex("#FF75D1").bgCyan.bold`text`;
|
|
195
|
+
|
|
196
|
+
bold.bgHex("#FF75D1").cyan`text`;
|
|
197
|
+
|
|
198
|
+
italic.yellow.bgMagentaBright`text`;
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Nested syntax
|
|
202
|
+
|
|
203
|
+
You can nest functions and template strings within each other.
|
|
204
|
+
None of the other libraries (chalk, kleur, colorette, colors.js etc.) support nested template strings.
|
|
205
|
+
|
|
206
|
+
Nested template strings:
|
|
207
|
+
|
|
208
|
+
```js
|
|
209
|
+
import { red, green } from "@visulima/colorize";
|
|
210
|
+
|
|
211
|
+
red`red ${green`green`} red`;
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Deep nested chained styles:
|
|
215
|
+
|
|
216
|
+
```js
|
|
217
|
+
import { red, green, cyan, magenta, yellow, italic, underline } from "@visulima/colorize";
|
|
218
|
+
|
|
219
|
+
console.log(red(`red ${italic(`red italic ${underline(`red italic underline`)}`)} red`));
|
|
220
|
+
|
|
221
|
+
// deep nested chained styles
|
|
222
|
+
console.log(green(`green ${yellow(`yellow ${magenta(`magenta ${cyan(`cyan ${red.italic.underline`red italic underline`} cyan`)} magenta`)} yellow`)} green`));
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Output:\
|
|
226
|
+

|
|
227
|
+
|
|
228
|
+
<!--
|
|
229
|
+
Copy of a readme example from https://github.com/webdiscus/ansis
|
|
230
|
+
|
|
231
|
+
ISC License
|
|
232
|
+
|
|
233
|
+
Copyright (c) 2023, webdiscus
|
|
234
|
+
-->
|
|
235
|
+
|
|
236
|
+
Multiline nested template strings:
|
|
237
|
+
|
|
238
|
+
```js
|
|
239
|
+
import { red, green, hex, visible, inverse } from "@visulima/colorize";
|
|
240
|
+
|
|
241
|
+
// defined a truecolor as the constant
|
|
242
|
+
const orange = hex("#FFAB40");
|
|
243
|
+
|
|
244
|
+
// normal colors
|
|
245
|
+
console.log(visible`
|
|
246
|
+
CPU: ${red`${cpu.totalPercent}%`}
|
|
247
|
+
RAM: ${green`${(ram.used / ram.total) * 100}%`}
|
|
248
|
+
DISK: ${orange`${(disk.used / disk.total) * 100}%`}
|
|
249
|
+
`);
|
|
250
|
+
|
|
251
|
+
// inversed colors
|
|
252
|
+
console.log(inverse`
|
|
253
|
+
CPU: ${red`${cpu.totalPercent}%`}
|
|
254
|
+
RAM: ${green`${(ram.used / ram.total) * 100}%`}
|
|
255
|
+
DISK: ${orange`${(disk.used / disk.total) * 100}%`}
|
|
256
|
+
`);
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
Output:\
|
|
260
|
+

|
|
261
|
+
|
|
262
|
+
## ANSI 256 colors
|
|
263
|
+
|
|
264
|
+
The pre-defined set of 256 colors.
|
|
265
|
+
|
|
266
|
+
<center>
|
|
267
|
+
|
|
268
|
+

|
|
269
|
+
|
|
270
|
+
</center>
|
|
271
|
+
|
|
272
|
+
| Code range | Description |
|
|
273
|
+
| ---------: | ----------------------------------------- |
|
|
274
|
+
| 0 - 7 | standard colors |
|
|
275
|
+
| 8 - 15 | bright colors |
|
|
276
|
+
| 16 - 231 | 6 × 6 × 6 cube (216 colors) |
|
|
277
|
+
| 232 - 255 | grayscale from black to white in 24 steps |
|
|
278
|
+
|
|
279
|
+
Foreground function: `ansi256(code)` has short alias `fg(code)`\
|
|
280
|
+
Background function: `bgAnsi256(code)` has short alias `bg(code)`
|
|
281
|
+
|
|
282
|
+
> The `ansi256()` and `bgAnsi256()` methods are implemented for compatibility with the `chalk` API.
|
|
283
|
+
|
|
284
|
+
See [ANSI color codes](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit).
|
|
285
|
+
|
|
286
|
+
```js
|
|
287
|
+
import { bold, ansi256, fg, bgAnsi256, bg } from "@visulima/colorize";
|
|
288
|
+
|
|
289
|
+
// foreground color
|
|
290
|
+
ansi256(96)`Bright Cyan`;
|
|
291
|
+
fg(96)`Bright Cyan`;
|
|
292
|
+
|
|
293
|
+
// background color
|
|
294
|
+
bgAnsi256(105)`Bright Magenta`;
|
|
295
|
+
bg(105)`Bright Magenta`;
|
|
296
|
+
|
|
297
|
+
// function is chainable
|
|
298
|
+
ansi256(96).bold`bold Bright Cyan`;
|
|
299
|
+
|
|
300
|
+
// function is available in each style
|
|
301
|
+
bold.ansi256(96).underline`bold underline Bright Cyan`;
|
|
302
|
+
|
|
303
|
+
// you can combine the functions and styles in any order
|
|
304
|
+
bgAnsi256(105).ansi256(96)`cyan text on magenta background`;
|
|
305
|
+
bg(105).fg(96)`cyan text on magenta background`;
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
## Truecolor (16 million colors)
|
|
309
|
+
|
|
310
|
+
You can use the `hex` or `rgb` format.
|
|
311
|
+
|
|
312
|
+
Foreground function: `hex()` `rgb()`\
|
|
313
|
+
Background function: `bgHex()` `bgRgb()`
|
|
314
|
+
|
|
315
|
+
```js
|
|
316
|
+
import { bold, hex, rgb, bgHex, bgRgb } from "@visulima/colorize";
|
|
317
|
+
|
|
318
|
+
// foreground color
|
|
319
|
+
hex("#E0115F").bold`bold Ruby`;
|
|
320
|
+
hex("#96C")`Amethyst`;
|
|
321
|
+
rgb(224, 17, 95).italic`italic Ruby`;
|
|
322
|
+
|
|
323
|
+
// background color
|
|
324
|
+
bgHex("#E0115F")`Ruby`;
|
|
325
|
+
bgHex("#96C")`Amethyst`;
|
|
326
|
+
bgRgb(224, 17, 95)`Ruby`;
|
|
327
|
+
|
|
328
|
+
// you can combine the functions and styles in any order
|
|
329
|
+
bold.hex("#E0115F").bgHex("#96C")`ruby bold text on amethyst background`;
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
<!--
|
|
333
|
+
Copy of a readme example from https://github.com/webdiscus/ansis
|
|
334
|
+
|
|
335
|
+
ISC License
|
|
336
|
+
|
|
337
|
+
Copyright (c) 2023, webdiscus
|
|
338
|
+
-->
|
|
339
|
+
|
|
340
|
+
## Use ANSI codes
|
|
341
|
+
|
|
342
|
+
You can use the [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) with `open`
|
|
343
|
+
and `close` properties for each style.
|
|
344
|
+
|
|
345
|
+
```js
|
|
346
|
+
import { green, bold } from "@visulima/colorize";
|
|
347
|
+
|
|
348
|
+
// each style has `open` and `close` properties
|
|
349
|
+
console.log(`Hello ${green.open}ANSI${green.close} World!`);
|
|
350
|
+
|
|
351
|
+
// you can define own style which will have the `open` and `close` properties
|
|
352
|
+
const myStyle = bold.italic.black.bgHex("#E0115F");
|
|
353
|
+
|
|
354
|
+
console.log(`Hello ${myStyle.open}ANSI${myStyle.close} World!`);
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
<!--
|
|
358
|
+
Copy of a readme example from https://github.com/webdiscus/ansis
|
|
359
|
+
|
|
360
|
+
ISC License
|
|
361
|
+
|
|
362
|
+
Copyright (c) 2023, webdiscus
|
|
363
|
+
-->
|
|
364
|
+
|
|
365
|
+
## Strip ANSI codes
|
|
366
|
+
|
|
367
|
+
The Colorize class contains the method `strip()` to remove all ANSI codes from string.
|
|
368
|
+
|
|
369
|
+
```js
|
|
370
|
+
import colorize from "@visulima/colorize";
|
|
371
|
+
// or named import
|
|
372
|
+
import { strip } from "@visulima/colorize";
|
|
373
|
+
|
|
374
|
+
const ansiString = colorize.blue`Hello World!`;
|
|
375
|
+
const string = colorize.strip(ansiString);
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
The variable `string` will contain the pure string without ANSI codes.
|
|
379
|
+
|
|
380
|
+
## New lines
|
|
381
|
+
|
|
382
|
+
Supports correct style break at the `end of line`.
|
|
383
|
+
|
|
384
|
+
```js
|
|
385
|
+
import { bgGreen } from "@visulima/colorize";
|
|
386
|
+
|
|
387
|
+
console.log(bgGreen`\nColorize\nNew Line\nNext New Line\n`);
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+

|
|
391
|
+
|
|
392
|
+
## Environment variables and CLI arguments
|
|
393
|
+
|
|
394
|
+
Please check [@visulima/is-ansi-color-supported](https://github.com/visulima/visulima/packages/is-ansi-color-supported) for more information.
|
|
395
|
+
|
|
396
|
+
## Browser support
|
|
397
|
+
|
|
398
|
+
Since Chrome 69, ANSI escape codes are natively supported in the developer console.
|
|
399
|
+
|
|
400
|
+
## Windows
|
|
401
|
+
|
|
402
|
+
If you're on Windows, do yourself a favor and use [Windows Terminal](https://github.com/microsoft/terminal) instead of cmd.exe.
|
|
403
|
+
|
|
404
|
+
## Comparison of most popular libraries
|
|
405
|
+
|
|
406
|
+
| Library<br>**\*\***\_\_**\*\***<br> - name<br> - named import | Code size | Naming colors | ANSI 256<br>colors | True-<br>color | Chained<br>syntax | Nested<br>template strings | New<br>Line | Supports<br>CLI params |
|
|
407
|
+
| :---------------------------------------------------------------- | :----------------------------------------------------------------------------- | :----------------------------------------: | :----------------: | :------------: | :---------------: | :------------------------: | :---------: | :------------------------------------------------------- |
|
|
408
|
+
| [`@visulima/colorize`][npm-url]<br><nobr>`✅ named import`</nobr> |  | **standard**<br>`16` colors | ✅ | ✅ | ✅ | ✅ | ✅ | `NO_COLOR`<br>`FORCE_COLOR`<br>`--no-color`<br>`--color` |
|
|
409
|
+
| [`ansi-colors`][ansi-colors]<br><nobr>`❌ named import`</nobr> |  | **standard**<br>`16` colors | ❌ | ❌ | ✅ | ❌ | ✅ | only<br>`FORCE_COLOR` |
|
|
410
|
+
| [`ansis`][ansis]<br><nobr>`✅ named import`</nobr> |  | **standard**<br>`16` colors | ✅ | ✅ | ✅ | ✅ | ✅ | `NO_COLOR`<br>`FORCE_COLOR`<br>`--no-color`<br>`--color` |
|
|
411
|
+
| [`chalk`][chalk]<br><nobr>`❌ named import`</nobr> |  | **standard**<br>`16` colors | ✅ | ✅ | ✅ | ❌ | ✅ | `NO_COLOR`<br>`FORCE_COLOR`<br>`--no-color`<br>`--color` |
|
|
412
|
+
| [`cli-color`][cli-color]<br><nobr>`❌ named import`</nobr> |  | **standard**<br>`16` colors | ✅ | ❌ | ✅ | ❌ | ❌ | only<br>`NO_COLOR` |
|
|
413
|
+
| [`colorette`][colorette]<br><nobr>`✅ named import`</nobr> |  | **standard**<br>`16` colors | ❌ | ❌ | ❌ | ❌ | ❌ | `NO_COLOR`<br>`FORCE_COLOR`<br>`--no-color`<br>`--color` |
|
|
414
|
+
| [`colors-cli`][colors-cli]<br><nobr>`❌ named import`</nobr> |  | <nobr>_non-standard_</nobr><br>`16` colors | ✅ | ❌ | ✅ | ❌ | ✅ | only<br>`--no-color`<br>`--color` |
|
|
415
|
+
| [`colors.js`][colors.js]<br><nobr>`❌ named import`</nobr> |  | <nobr>_non-standard_</nobr><br>`16` colors | ❌ | ❌ | ✅ | ❌ | ✅ | only<br>`FORCE_COLOR`<br>`--no-color`<br>`--color` |
|
|
416
|
+
| [`kleur`][kleur]<br><nobr>`✅ named import`</nobr> |  | **standard**<br>`8` colors | ❌ | ❌ | ✅ | ❌ | ❌ | only<br>`NO_COLOR`<br>`FORCE_COLOR` |
|
|
417
|
+
| [`picocolors`][picocolors]<br><nobr>`❌ named import`</nobr> |  | **standard**<br>`8` colors | ❌ | ❌ | ❌ | ❌ | ❌ | `NO_COLOR`<br>`FORCE_COLOR`<br>`--no-color`<br>`--color` |
|
|
418
|
+
|
|
419
|
+
> **Note**
|
|
420
|
+
>
|
|
421
|
+
> **Code size**\
|
|
422
|
+
> The size of distributed code that will be loaded via `require` or `import` into your app. It's not a package size.
|
|
423
|
+
>
|
|
424
|
+
> **Named import**\
|
|
425
|
+
> `import { red, green, blue } from 'lib';`\
|
|
426
|
+
> or\
|
|
427
|
+
> `const { red, green, blue } = require('lib');`
|
|
428
|
+
>
|
|
429
|
+
> **Naming colors**
|
|
430
|
+
>
|
|
431
|
+
> - standard: colors have [standard names](#base-colors-and-styles), e.g.: `red`, `redBright`, `bgRed`, `bgRedBright`
|
|
432
|
+
> - _non-standard_: colors have lib-specific names, e.g.: `brightRed`, `bgBrightRed`, `red_b`, `red_btt`
|
|
433
|
+
>
|
|
434
|
+
> **ANSI 256 colors**
|
|
435
|
+
>
|
|
436
|
+
> The method names:
|
|
437
|
+
>
|
|
438
|
+
> - [`@visulima/colorize`][npm-url]: `ansi256(n)` `bgAnsi256(n)` `fg(n)` `bg(n)`
|
|
439
|
+
> - [`ansis`][ansis]: `ansi256(n)` `bgAnsi256(n)` `fg(n)` `bg(n)`
|
|
440
|
+
> - [`chalk`][chalk]: `ansi256(n)` `bgAnsi256(n)`
|
|
441
|
+
> - [`cli-color`][cli-color]: `xterm(n)`
|
|
442
|
+
> - [`colors-cli`][colors-cli]: `x<n>`
|
|
443
|
+
>
|
|
444
|
+
> **Truecolor**
|
|
445
|
+
>
|
|
446
|
+
> The method names:
|
|
447
|
+
>
|
|
448
|
+
> - [`@visulima/colorize`][npm-url]: `hex()` `rgb()`
|
|
449
|
+
> - [`ansis`][ansis]: `hex()` `rgb()`
|
|
450
|
+
> - [`chalk`][chalk]: `hex()` `rgb()`
|
|
451
|
+
>
|
|
452
|
+
> **Chained syntax**\
|
|
453
|
+
> `lib.red.bold('text')`
|
|
454
|
+
>
|
|
455
|
+
> **Nested template strings**\
|
|
456
|
+
> `` lib.red`text ${lib.cyan`nested`} text` ``
|
|
457
|
+
>
|
|
458
|
+
> **New line**\
|
|
459
|
+
> Correct break styles at `end-of-line`.
|
|
460
|
+
>
|
|
461
|
+
> ```
|
|
462
|
+
> lib.bgGreen(`First Line
|
|
463
|
+
> Next Line`);
|
|
464
|
+
> ```
|
|
465
|
+
|
|
466
|
+
<!--
|
|
467
|
+
Modified table from https://github.com/webdiscus/ansis
|
|
468
|
+
|
|
469
|
+
ISC License
|
|
470
|
+
|
|
471
|
+
Copyright (c) 2023, webdiscus
|
|
472
|
+
-->
|
|
473
|
+
|
|
474
|
+
## Benchmark
|
|
475
|
+
|
|
476
|
+
[See benchmark](./__bench__/README.md)
|
|
477
|
+
|
|
478
|
+
## Reference
|
|
479
|
+
|
|
480
|
+
- [The opaque named colors](https://drafts.csswg.org/css-color/#named-colors)
|
|
481
|
+
- [ANSI escape code](https://en.wikipedia.org/wiki/ANSI_escape_code)
|
|
482
|
+
|
|
483
|
+
The [ANSI Escape](https://en.wikipedia.org/wiki/ANSI_escape_code) sequences control code screen.
|
|
484
|
+
|
|
485
|
+
```bash
|
|
486
|
+
echo -e "\033[31;41;4m something here 33[0m"
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
`\033` As the escape character, inform the terminal to switch to the escape mode.
|
|
490
|
+
`[` The beginning of the CSI.
|
|
491
|
+
`m` Make the action to be performed.
|
|
492
|
+
`;` ASCII code separator.
|
|
493
|
+
|
|
494
|
+
## Supported Node.js Versions
|
|
495
|
+
|
|
496
|
+
Libraries in this ecosystem make the best effort to track [Node.js’ release schedule](https://github.com/nodejs/release#release-schedule).
|
|
497
|
+
Here’s [a post on why we think this is important](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a).
|
|
498
|
+
|
|
499
|
+
## Contributing
|
|
500
|
+
|
|
501
|
+
If you would like to help take a look at the [list of issues](https://github.com/visulima/visulima/issues) and check our [Contributing](.github/CONTRIBUTING.md) guild.
|
|
502
|
+
|
|
503
|
+
> **Note:** please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
|
|
504
|
+
|
|
505
|
+
## Credits
|
|
506
|
+
|
|
507
|
+
- [WebDiscus](https://github.com/webdiscus)
|
|
508
|
+
- [Daniel Bannert](https://github.com/prisis)
|
|
509
|
+
- [All Contributors](https://github.com/visulima/visulima/graphs/contributors)
|
|
510
|
+
|
|
511
|
+
## About
|
|
512
|
+
|
|
513
|
+
### Related Projects
|
|
514
|
+
|
|
515
|
+
- [ansis][ansis] - The Node.js library for formatting text in terminal with ANSI colors & styles
|
|
516
|
+
- [ansi-colors][ansi-colors] - Easily add ANSI colors to your text and symbols in the terminal.
|
|
517
|
+
- [chalk][chalk] - Terminal string styling done right
|
|
518
|
+
- [cli-color][cli-color] - Colors and formatting for the console
|
|
519
|
+
- [colorette][colorette] - Easily set your terminal text color & styles
|
|
520
|
+
- [colors-cli][colors-cli] - Terminal string styling done right.
|
|
521
|
+
- [colors.js][colors.js] - get colors in your node.js console
|
|
522
|
+
- [kleur][kleur] - The fastest Node.js library for formatting terminal text with ANSI colors~!
|
|
523
|
+
- [picocolors][picocolors] - Tiny yet powerful colors for terminal
|
|
524
|
+
|
|
525
|
+
## License
|
|
526
|
+
|
|
527
|
+
The visulima colorize is open-sourced software licensed under the [MIT][license-url]
|
|
528
|
+
|
|
529
|
+
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
|
|
530
|
+
[typescript-url]: "typescript"
|
|
531
|
+
[license-image]: https://img.shields.io/npm/l/@visulima/colorize?color=blueviolet&style=for-the-badge
|
|
532
|
+
[license-url]: LICENSE.md "license"
|
|
533
|
+
[npm-image]: https://img.shields.io/npm/v/@visulima/colorize/latest.svg?style=for-the-badge&logo=npm
|
|
534
|
+
[npm-url]: https://www.npmjs.com/package/@visulima/colorize/v/latest "npm"
|
|
535
|
+
[colors.js]: https://github.com/Marak/colors.js
|
|
536
|
+
[colorette]: https://github.com/jorgebucaran/colorette
|
|
537
|
+
[picocolors]: https://github.com/alexeyraspopov/picocolors
|
|
538
|
+
[cli-color]: https://github.com/medikoo/cli-color
|
|
539
|
+
[colors-cli]: https://github.com/jaywcjlove/colors-cli
|
|
540
|
+
[ansi-colors]: https://github.com/doowb/ansi-colors
|
|
541
|
+
[kleur]: https://github.com/lukeed/kleur
|
|
542
|
+
[chalk]: https://github.com/chalk/chalk
|
|
543
|
+
[ansis]: https://github.com/webdiscus/ansis
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var isAnsiColorSupported = require('@visulima/is-ansi-color-supported');
|
|
6
|
+
|
|
7
|
+
function c({onlyFirst:e=!1}={}){let t=["[\\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(t,e?void 0:"g")}var b=e=>{let t=e.replace("#","");if(t.length===3)t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2];else if(t.length!==6)return [0,0,0];let o=Number.parseInt(t,16);return [o>>16&255,o>>8&255,o&255]},l=(e,t,o)=>t>e?t:e>o?o:e,C=(e,t,o)=>{if(t==="")return e;let n=e.indexOf(t);if(n<0)return e;let i=t.length,s=0,g="";for(;~n;)g+=e.slice(s,n)+o,s=n+i,n=e.indexOf(t,s);return g+e.slice(s)};var r=isAnsiColorSupported.isColorSupported()>0?(e,t)=>({close:"\x1B["+t+"m",open:"\x1B["+e+"m"}):()=>({close:"",open:""}),R=e=>r("38;5;"+e,39),x=e=>r("48;5;"+e,49),h=(e,t,o)=>r("38;2;"+e+";"+t+";"+o,39),k=(e,t,o)=>r("48;2;"+e+";"+t+";"+o,49),p={bold:r(1,22),dim:r(2,22),hidden:r(8,28),inverse:r(7,27),italic:r(3,23),overline:r(53,55),reset:r(0,0),strike:r(9,29),strikethrough:r(9,29),underline:r(4,24),visible:{close:"",open:""}},y={bgBlack:r(40,49),bgBlackBright:r(100,49),bgBlue:r(44,49),bgBlueBright:r(104,49),bgCyan:r(46,49),bgCyanBright:r(106,49),bgGray:r(100,49),bgGreen:r(42,49),bgGreenBright:r(102,49),bgGrey:r(100,49),bgMagenta:r(45,49),bgMagentaBright:r(105,49),bgRed:r(41,49),bgRedBright:r(101,49),bgWhite:r(47,49),bgWhiteBright:r(107,49),bgYellow:r(43,49),bgYellowBright:r(103,49),black:r(30,39),blackBright:r(90,39),blue:r(34,39),blueBright:r(94,39),cyan:r(36,39),cyanBright:r(96,39),gray:r(90,39),green:r(32,39),greenBright:r(92,39),grey:r(90,39),magenta:r(35,39),magentaBright:r(95,39),red:r(31,39),redBright:r(91,39),white:r(37,39),whiteBright:r(97,39),yellow:r(33,39),yellowBright:r(93,39)},u={bg:e=>x(l(e,0,255)),bgHex:e=>k(...b(e)),bgRgb:(e,t,o)=>k(l(e,0,255),l(t,0,255),l(o,0,255)),fg:e=>R(l(e,0,255)),hex:e=>h(...b(e)),rgb:(e,t,o)=>h(l(e,0,255),l(t,0,255),l(o,0,255))};var a={},m=null,S=(e,t,o)=>{if(!e)return "";let n=e.raw==null?e:String.raw(e,...t);if(n.includes("\x1B"))for(let i=o;i;i=i.props)n=C(n,i.close,i.open);return n.includes(`
|
|
8
|
+
`)&&(n=n.replace(/(\r*\n)/g,o.closeStack+"$1"+o.openStack)),o.openStack+n+o.closeStack},f=({props:e},{close:t,open:o})=>{let n=(e?.openStack??"")+o,i=t+(e?.closeStack??""),s=(g,...A)=>S(g,A,s.props);return Object.setPrototypeOf(s,m),s.props={close:t,closeStack:i,open:o,openStack:n,props:e},s.open=n,s.close=i,s},z=function(){let e=t=>t;e.strip=t=>t.replaceAll(c(),"");for(let t in y)a[t]={get(){let o=f(this,y[t]);return Object.defineProperty(this,t,{value:o}),o}};for(let t in p)a[t]={get(){let o=f(this,p[t]);return Object.defineProperty(this,t,{value:o}),o}};return m=Object.defineProperties({},a),Object.setPrototypeOf(e,m),e};for(let e in u)a[e]={get(){return (...t)=>f(this,u[e](...t))}};a.ansi256=a.fg;a.bgAnsi256=a.bg;var d=z;var D=new d,q=D,H=d;
|
|
9
|
+
|
|
10
|
+
module.exports = q;
|
|
11
|
+
module.exports.Colorize = H;
|
|
12
|
+
//# sourceMappingURL=out.js.map
|
|
13
|
+
//# sourceMappingURL=index.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/utils.ts","../src/colorize.ts","../src/index.cts"],"names":["ansiRegex","onlyFirst","pattern","isColorSupported","hexToRgb","hex","color","number_","clamp","min","max","stringReplaceAll","string_","searchValue","replaceValue","pos","substringLength","lastPos","result","esc","open","close","createAnsi256","code","createBgAnsi256","createRgb","r","g","b","createBgRgb","baseStyles","baseColors","styleMethods","styles","stylePrototype","wrapText","strings","values","properties","string","currentProperties","createStyle","props","openStack","closeStack","style","Colorize","self","value","name","arguments_","colorize_default","colorize","src_default"],"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,oBAAAE,MAAwB,oCCc1B,IAAMC,EAAYC,GAA0C,CAC/D,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,IAAMC,EAAU,OAAO,SAASD,EAAO,EAAE,EAGzC,MAAO,CAAEC,GAAW,GAAM,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]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]+)*|[a-zA-Z\\\\d]+(?:;[-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 { isColorSupported } from \"@visulima/is-ansi-color-supported\";\n\nimport type { AnsiColors, AnsiStyles, ColorData } from \"./types\";\nimport { clamp, hexToRgb } from \"./utils\";\n\nconst esc: (open: number | string, close: number | string) => ColorData =\n isColorSupported() > 0\n ? (open: number | string, close: number | string): ColorData => {\n // eslint-disable-next-line prefer-template\n return { close: \"\\u001B[\" + close + \"m\", open: \"\\u001B[\" + open + \"m\" };\n }\n : (): ColorData => {\n return { close: \"\", open: \"\" };\n };\n\n// eslint-disable-next-line prefer-template\nconst createAnsi256 = (code: number | string): ColorData => esc(\"38;5;\" + code, 39);\n// eslint-disable-next-line prefer-template\nconst createBgAnsi256 = (code: number | string): ColorData => esc(\"48;5;\" + code, 49);\n// eslint-disable-next-line prefer-template\nconst createRgb = (r: number | string, g: number | string, b: number | string): ColorData => esc(\"38;2;\" + r + \";\" + g + \";\" + b, 39);\n// eslint-disable-next-line prefer-template\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: string) => ColorData;\n bgRgb: (r: number, g: number, b: number) => ColorData;\n fg: (code: number) => ColorData;\n hex: (hex: string) => ColorData;\n rgb: (r: number, g: number, b: number) => ColorData;\n} = {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n bg: (code) => createBgAnsi256(clamp(code, 0, 255)),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n bgHex: (hex) => createBgRgb(...hexToRgb(hex)),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n bgRgb: (r, g, b) => createBgRgb(clamp(r, 0, 255), clamp(g, 0, 255), clamp(b, 0, 255)),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n fg: (code) => createAnsi256(clamp(code, 0, 255)),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n hex: (hex) => createRgb(...hexToRgb(hex)),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\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 * 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: string): [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/**\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 */\nexport const clamp = (number_: number, min: number, max: number): number => (min > number_ ? min : number_ > max ? max : number_);\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 \"./utils\";\n\nconst styles: Record<string, object> = {};\n\nlet stylePrototype: object | null = null;\n\nconst wrapText = (\n strings: ArrayLike<string> | ReadonlyArray<string> | 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 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 prefer-template,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_: 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 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\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 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\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 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\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","import ColorizeImpl from \"./colorize\";\nimport type { ColorizeType } from \"./types\";\n\nconst colorize: ColorizeType = new ColorizeImpl() as ColorizeType;\n\n// eslint-disable-next-line import/no-default-export,import/no-unused-modules\nexport default colorize as ColorizeType;\n\n// eslint-disable-next-line unicorn/prefer-export-from,import/no-unused-modules\nexport const Colorize = ColorizeImpl;\n\n// eslint-disable-next-line import/no-unused-modules\nexport type { AnsiColors, AnsiStyles, ColorizeType } from \"./types\";\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
interface ColorizeType {
|
|
2
|
+
(string: string): string;
|
|
3
|
+
(string: TemplateStringsArray, ...parameters: string[]): string;
|
|
4
|
+
ansi256: (code: number) => this;
|
|
5
|
+
bg: (code: number) => this;
|
|
6
|
+
bgAnsi256: (code: number) => this;
|
|
7
|
+
readonly bgBlack: this;
|
|
8
|
+
readonly bgBlackBright: this;
|
|
9
|
+
readonly bgBlue: this;
|
|
10
|
+
readonly bgBlueBright: this;
|
|
11
|
+
readonly bgCyan: this;
|
|
12
|
+
readonly bgCyanBright: this;
|
|
13
|
+
readonly bgGray: this;
|
|
14
|
+
readonly bgGreen: this;
|
|
15
|
+
readonly bgGreenBright: this;
|
|
16
|
+
readonly bgGrey: this;
|
|
17
|
+
bgHex: (color: string) => this;
|
|
18
|
+
readonly bgMagenta: this;
|
|
19
|
+
readonly bgMagentaBright: this;
|
|
20
|
+
readonly bgRed: this;
|
|
21
|
+
readonly bgRedBright: this;
|
|
22
|
+
bgRgb: (red: number, green: number, blue: number) => this;
|
|
23
|
+
readonly bgWhite: this;
|
|
24
|
+
readonly bgWhiteBright: this;
|
|
25
|
+
readonly bgYellow: this;
|
|
26
|
+
readonly bgYellowBright: this;
|
|
27
|
+
readonly black: this;
|
|
28
|
+
readonly blackBright: this;
|
|
29
|
+
readonly blue: this;
|
|
30
|
+
readonly blueBright: this;
|
|
31
|
+
readonly bold: this;
|
|
32
|
+
readonly close: string;
|
|
33
|
+
readonly cyan: this;
|
|
34
|
+
readonly cyanBright: this;
|
|
35
|
+
readonly dim: this;
|
|
36
|
+
fg: (code: number) => this;
|
|
37
|
+
readonly gray: this;
|
|
38
|
+
readonly green: this;
|
|
39
|
+
readonly greenBright: this;
|
|
40
|
+
readonly grey: this;
|
|
41
|
+
hex: (color: string) => this;
|
|
42
|
+
readonly hidden: this;
|
|
43
|
+
readonly inverse: this;
|
|
44
|
+
readonly italic: this;
|
|
45
|
+
readonly magenta: this;
|
|
46
|
+
readonly magentaBright: this;
|
|
47
|
+
readonly open: string;
|
|
48
|
+
readonly overline: this;
|
|
49
|
+
readonly red: this;
|
|
50
|
+
readonly redBright: this;
|
|
51
|
+
readonly reset: this;
|
|
52
|
+
rgb: (red: number, green: number, blue: number) => this;
|
|
53
|
+
readonly strike: this;
|
|
54
|
+
readonly strikethrough: this;
|
|
55
|
+
strip: (string: string) => string;
|
|
56
|
+
readonly underline: this;
|
|
57
|
+
readonly visible: this;
|
|
58
|
+
readonly white: this;
|
|
59
|
+
readonly whiteBright: this;
|
|
60
|
+
readonly yellow: this;
|
|
61
|
+
readonly yellowBright: this;
|
|
62
|
+
}
|
|
63
|
+
type AnsiStyles = "bold" | "dim" | "hidden" | "inverse" | "italic" | "overline" | "reset" | "strike" | "strikethrough" | "underline" | "visible";
|
|
64
|
+
type AnsiColors = "bgBlack" | "bgBlackBright" | "bgBlue" | "bgBlueBright" | "bgCyan" | "bgCyanBright" | "bgGray" | "bgGreen" | "bgGreenBright" | "bgGrey" | "bgMagenta" | "bgMagentaBright" | "bgRed" | "bgRedBright" | "bgWhite" | "bgWhiteBright" | "bgYellow" | "bgYellowBright" | "black" | "blackBright" | "blue" | "blueBright" | "cyan" | "cyanBright" | "gray" | "green" | "greenBright" | "grey" | "magenta" | "magentaBright" | "red" | "redBright" | "white" | "whiteBright" | "yellow" | "yellowBright";
|
|
65
|
+
|
|
66
|
+
declare const _default: ColorizeType;
|
|
67
|
+
|
|
68
|
+
declare const Colorize: new () => ColorizeType;
|
|
69
|
+
|
|
70
|
+
export { type AnsiColors, type AnsiStyles, Colorize, type ColorizeType, _default as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
interface ColorizeType {
|
|
2
|
+
(string: string): string;
|
|
3
|
+
(string: TemplateStringsArray, ...parameters: string[]): string;
|
|
4
|
+
ansi256: (code: number) => this;
|
|
5
|
+
bg: (code: number) => this;
|
|
6
|
+
bgAnsi256: (code: number) => this;
|
|
7
|
+
readonly bgBlack: this;
|
|
8
|
+
readonly bgBlackBright: this;
|
|
9
|
+
readonly bgBlue: this;
|
|
10
|
+
readonly bgBlueBright: this;
|
|
11
|
+
readonly bgCyan: this;
|
|
12
|
+
readonly bgCyanBright: this;
|
|
13
|
+
readonly bgGray: this;
|
|
14
|
+
readonly bgGreen: this;
|
|
15
|
+
readonly bgGreenBright: this;
|
|
16
|
+
readonly bgGrey: this;
|
|
17
|
+
bgHex: (color: string) => this;
|
|
18
|
+
readonly bgMagenta: this;
|
|
19
|
+
readonly bgMagentaBright: this;
|
|
20
|
+
readonly bgRed: this;
|
|
21
|
+
readonly bgRedBright: this;
|
|
22
|
+
bgRgb: (red: number, green: number, blue: number) => this;
|
|
23
|
+
readonly bgWhite: this;
|
|
24
|
+
readonly bgWhiteBright: this;
|
|
25
|
+
readonly bgYellow: this;
|
|
26
|
+
readonly bgYellowBright: this;
|
|
27
|
+
readonly black: this;
|
|
28
|
+
readonly blackBright: this;
|
|
29
|
+
readonly blue: this;
|
|
30
|
+
readonly blueBright: this;
|
|
31
|
+
readonly bold: this;
|
|
32
|
+
readonly close: string;
|
|
33
|
+
readonly cyan: this;
|
|
34
|
+
readonly cyanBright: this;
|
|
35
|
+
readonly dim: this;
|
|
36
|
+
fg: (code: number) => this;
|
|
37
|
+
readonly gray: this;
|
|
38
|
+
readonly green: this;
|
|
39
|
+
readonly greenBright: this;
|
|
40
|
+
readonly grey: this;
|
|
41
|
+
hex: (color: string) => this;
|
|
42
|
+
readonly hidden: this;
|
|
43
|
+
readonly inverse: this;
|
|
44
|
+
readonly italic: this;
|
|
45
|
+
readonly magenta: this;
|
|
46
|
+
readonly magentaBright: this;
|
|
47
|
+
readonly open: string;
|
|
48
|
+
readonly overline: this;
|
|
49
|
+
readonly red: this;
|
|
50
|
+
readonly redBright: this;
|
|
51
|
+
readonly reset: this;
|
|
52
|
+
rgb: (red: number, green: number, blue: number) => this;
|
|
53
|
+
readonly strike: this;
|
|
54
|
+
readonly strikethrough: this;
|
|
55
|
+
strip: (string: string) => string;
|
|
56
|
+
readonly underline: this;
|
|
57
|
+
readonly visible: this;
|
|
58
|
+
readonly white: this;
|
|
59
|
+
readonly whiteBright: this;
|
|
60
|
+
readonly yellow: this;
|
|
61
|
+
readonly yellowBright: this;
|
|
62
|
+
}
|
|
63
|
+
type AnsiStyles = "bold" | "dim" | "hidden" | "inverse" | "italic" | "overline" | "reset" | "strike" | "strikethrough" | "underline" | "visible";
|
|
64
|
+
type AnsiColors = "bgBlack" | "bgBlackBright" | "bgBlue" | "bgBlueBright" | "bgCyan" | "bgCyanBright" | "bgGray" | "bgGreen" | "bgGreenBright" | "bgGrey" | "bgMagenta" | "bgMagentaBright" | "bgRed" | "bgRedBright" | "bgWhite" | "bgWhiteBright" | "bgYellow" | "bgYellowBright" | "black" | "blackBright" | "blue" | "blueBright" | "cyan" | "cyanBright" | "gray" | "green" | "greenBright" | "grey" | "magenta" | "magentaBright" | "red" | "redBright" | "white" | "whiteBright" | "yellow" | "yellowBright";
|
|
65
|
+
|
|
66
|
+
declare const Colorize: new () => ColorizeType;
|
|
67
|
+
|
|
68
|
+
declare const _default: ColorizeType;
|
|
69
|
+
|
|
70
|
+
declare const ansi256: (code: number) => ColorizeType;
|
|
71
|
+
declare const bg: (code: number) => ColorizeType;
|
|
72
|
+
declare const bgAnsi256: (code: number) => ColorizeType;
|
|
73
|
+
declare const bgBlack: ColorizeType;
|
|
74
|
+
declare const bgBlackBright: ColorizeType;
|
|
75
|
+
declare const bgBlue: ColorizeType;
|
|
76
|
+
declare const bgBlueBright: ColorizeType;
|
|
77
|
+
declare const bgCyan: ColorizeType;
|
|
78
|
+
declare const bgCyanBright: ColorizeType;
|
|
79
|
+
declare const bgGray: ColorizeType;
|
|
80
|
+
declare const bgGreen: ColorizeType;
|
|
81
|
+
declare const bgGreenBright: ColorizeType;
|
|
82
|
+
declare const bgGrey: ColorizeType;
|
|
83
|
+
declare const bgHex: (color: string) => ColorizeType;
|
|
84
|
+
declare const bgMagenta: ColorizeType;
|
|
85
|
+
declare const bgMagentaBright: ColorizeType;
|
|
86
|
+
declare const bgRed: ColorizeType;
|
|
87
|
+
declare const bgRedBright: ColorizeType;
|
|
88
|
+
declare const bgRgb: (red: number, green: number, blue: number) => ColorizeType;
|
|
89
|
+
declare const bgWhite: ColorizeType;
|
|
90
|
+
declare const bgWhiteBright: ColorizeType;
|
|
91
|
+
declare const bgYellow: ColorizeType;
|
|
92
|
+
declare const bgYellowBright: ColorizeType;
|
|
93
|
+
declare const black: ColorizeType;
|
|
94
|
+
declare const blackBright: ColorizeType;
|
|
95
|
+
declare const blue: ColorizeType;
|
|
96
|
+
declare const blueBright: ColorizeType;
|
|
97
|
+
declare const bold: ColorizeType;
|
|
98
|
+
declare const cyan: ColorizeType;
|
|
99
|
+
declare const cyanBright: ColorizeType;
|
|
100
|
+
declare const dim: ColorizeType;
|
|
101
|
+
declare const fg: (code: number) => ColorizeType;
|
|
102
|
+
declare const gray: ColorizeType;
|
|
103
|
+
declare const green: ColorizeType;
|
|
104
|
+
declare const greenBright: ColorizeType;
|
|
105
|
+
declare const grey: ColorizeType;
|
|
106
|
+
declare const hex: (color: string) => ColorizeType;
|
|
107
|
+
declare const hidden: ColorizeType;
|
|
108
|
+
declare const inverse: ColorizeType;
|
|
109
|
+
declare const italic: ColorizeType;
|
|
110
|
+
declare const magenta: ColorizeType;
|
|
111
|
+
declare const magentaBright: ColorizeType;
|
|
112
|
+
declare const overline: ColorizeType;
|
|
113
|
+
declare const red: ColorizeType;
|
|
114
|
+
declare const redBright: ColorizeType;
|
|
115
|
+
declare const reset: ColorizeType;
|
|
116
|
+
declare const rgb: (red: number, green: number, blue: number) => ColorizeType;
|
|
117
|
+
declare const strike: ColorizeType;
|
|
118
|
+
declare const strikethrough: ColorizeType;
|
|
119
|
+
declare const strip: (string: string) => string;
|
|
120
|
+
declare const underline: ColorizeType;
|
|
121
|
+
declare const visible: ColorizeType;
|
|
122
|
+
declare const white: ColorizeType;
|
|
123
|
+
declare const whiteBright: ColorizeType;
|
|
124
|
+
declare const yellow: ColorizeType;
|
|
125
|
+
declare const yellowBright: ColorizeType;
|
|
126
|
+
|
|
127
|
+
export { type AnsiColors, type AnsiStyles, Colorize, type ColorizeType, ansi256, bg, bgAnsi256, bgBlack, bgBlackBright, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGray, bgGreen, bgGreenBright, bgGrey, bgHex, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgRgb, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blackBright, blue, blueBright, bold, cyan, cyanBright, _default as default, dim, fg, gray, green, greenBright, grey, hex, hidden, inverse, italic, magenta, magentaBright, overline, red, redBright, reset, rgb, strike, strikethrough, strip, underline, visible, white, whiteBright, yellow, yellowBright };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { isColorSupported } from '@visulima/is-ansi-color-supported';
|
|
2
|
+
|
|
3
|
+
function b({onlyFirst:e=!1}={}){let t=["[\\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(t,e?void 0:"g")}var c=e=>{let t=e.replace("#","");if(t.length===3)t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2];else if(t.length!==6)return [0,0,0];let o=Number.parseInt(t,16);return [o>>16&255,o>>8&255,o&255]},g=(e,t,o)=>t>e?t:e>o?o:e,f=(e,t,o)=>{if(t==="")return e;let n=e.indexOf(t);if(n<0)return e;let i=t.length,s=0,a="";for(;~n;)a+=e.slice(s,n)+o,s=n+i,n=e.indexOf(t,s);return a+e.slice(s)};var r=isColorSupported()>0?(e,t)=>({close:"\x1B["+t+"m",open:"\x1B["+e+"m"}):()=>({close:"",open:""}),x=e=>r("38;5;"+e,39),w=e=>r("48;5;"+e,49),B=(e,t,o)=>r("38;2;"+e+";"+t+";"+o,39),C=(e,t,o)=>r("48;2;"+e+";"+t+";"+o,49),p={bold:r(1,22),dim:r(2,22),hidden:r(8,28),inverse:r(7,27),italic:r(3,23),overline:r(53,55),reset:r(0,0),strike:r(9,29),strikethrough:r(9,29),underline:r(4,24),visible:{close:"",open:""}},y={bgBlack:r(40,49),bgBlackBright:r(100,49),bgBlue:r(44,49),bgBlueBright:r(104,49),bgCyan:r(46,49),bgCyanBright:r(106,49),bgGray:r(100,49),bgGreen:r(42,49),bgGreenBright:r(102,49),bgGrey:r(100,49),bgMagenta:r(45,49),bgMagentaBright:r(105,49),bgRed:r(41,49),bgRedBright:r(101,49),bgWhite:r(47,49),bgWhiteBright:r(107,49),bgYellow:r(43,49),bgYellowBright:r(103,49),black:r(30,39),blackBright:r(90,39),blue:r(34,39),blueBright:r(94,39),cyan:r(36,39),cyanBright:r(96,39),gray:r(90,39),green:r(32,39),greenBright:r(92,39),grey:r(90,39),magenta:r(35,39),magentaBright:r(95,39),red:r(31,39),redBright:r(91,39),white:r(37,39),whiteBright:r(97,39),yellow:r(33,39),yellowBright:r(93,39)},u={bg:e=>w(g(e,0,255)),bgHex:e=>C(...c(e)),bgRgb:(e,t,o)=>C(g(e,0,255),g(t,0,255),g(o,0,255)),fg:e=>x(g(e,0,255)),hex:e=>B(...c(e)),rgb:(e,t,o)=>B(g(e,0,255),g(t,0,255),g(o,0,255))};var l={},h=null,S=(e,t,o)=>{if(!e)return "";let n=e.raw==null?e:String.raw(e,...t);if(n.includes("\x1B"))for(let i=o;i;i=i.props)n=f(n,i.close,i.open);return n.includes(`
|
|
4
|
+
`)&&(n=n.replace(/(\r*\n)/g,o.closeStack+"$1"+o.openStack)),o.openStack+n+o.closeStack},m=({props:e},{close:t,open:o})=>{let n=(e?.openStack??"")+o,i=t+(e?.closeStack??""),s=(a,...A)=>S(a,A,s.props);return Object.setPrototypeOf(s,h),s.props={close:t,closeStack:i,open:o,openStack:n,props:e},s.open=n,s.close=i,s},z=function(){let e=t=>t;e.strip=t=>t.replaceAll(b(),"");for(let t in y)l[t]={get(){let o=m(this,y[t]);return Object.defineProperty(this,t,{value:o}),o}};for(let t in p)l[t]={get(){let o=m(this,p[t]);return Object.defineProperty(this,t,{value:o}),o}};return h=Object.defineProperties({},l),Object.setPrototypeOf(e,h),e};for(let e in u)l[e]={get(){return (...t)=>m(this,u[e](...t))}};l.ansi256=l.fg;l.bgAnsi256=l.bg;var d=z;var k=new d,Y=k,{ansi256:Z,bg:q,bgAnsi256:H,bgBlack:I,bgBlackBright:E,bgBlue:N,bgBlueBright:$,bgCyan:F,bgCyanBright:J,bgGray:K,bgGreen:Q,bgGreenBright:U,bgGrey:X,bgHex:V,bgMagenta:_,bgMagentaBright:ee,bgRed:re,bgRedBright:te,bgRgb:oe,bgWhite:ne,bgWhiteBright:se,bgYellow:ie,bgYellowBright:ge,black:le,blackBright:ae,blue:be,blueBright:ce,bold:pe,cyan:ye,cyanBright:ue,dim:he,fg:me,gray:de,green:fe,greenBright:Be,grey:Ce,hex:ke,hidden:Ae,inverse:Re,italic:xe,magenta:we,magentaBright:Se,overline:ze,red:De,redBright:Pe,reset:Te,rgb:je,strike:ve,strikethrough:Oe,strip:Ge,underline:Me,visible:Le,white:We,whiteBright:Ye,yellow:Ze,yellowBright:qe}=k;
|
|
5
|
+
|
|
6
|
+
export { d as Colorize, Z as ansi256, q as bg, H as bgAnsi256, I as bgBlack, E as bgBlackBright, N as bgBlue, $ as bgBlueBright, F as bgCyan, J as bgCyanBright, K as bgGray, Q as bgGreen, U as bgGreenBright, X as bgGrey, V as bgHex, _ as bgMagenta, ee as bgMagentaBright, re as bgRed, te as bgRedBright, oe as bgRgb, ne as bgWhite, se as bgWhiteBright, ie as bgYellow, ge as bgYellowBright, le as black, ae as blackBright, be as blue, ce as blueBright, pe as bold, ye as cyan, ue as cyanBright, Y as default, he as dim, me as fg, de as gray, fe as green, Be as greenBright, Ce as grey, ke as hex, Ae as hidden, Re as inverse, xe as italic, we as magenta, Se as magentaBright, ze as overline, De as red, Pe as redBright, Te as reset, je as rgb, ve as strike, Oe as strikethrough, Ge as strip, Me as underline, Le as visible, We as white, Ye as whiteBright, Ze as yellow, qe as yellowBright };
|
|
7
|
+
//# sourceMappingURL=out.js.map
|
|
8
|
+
//# sourceMappingURL=index.js.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/utils.ts","../src/colorize.ts","../src/index.mts"],"names":["ansiRegex","onlyFirst","pattern","isColorSupported","hexToRgb","hex","color","number_","clamp","min","max","stringReplaceAll","string_","searchValue","replaceValue","pos","substringLength","lastPos","result","esc","open","close","createAnsi256","code","createBgAnsi256","createRgb","r","g","b","createBgRgb","baseStyles","baseColors","styleMethods","styles","stylePrototype","wrapText","strings","values","properties","string","currentProperties","createStyle","props","openStack","closeStack","style","Colorize","self","value","name","arguments_","colorize_default","colorize","src_default","ansi256","bg","bgAnsi256","bgBlack","bgBlackBright","bgBlue","bgBlueBright","bgCyan","bgCyanBright","bgGray","bgGreen","bgGreenBright","bgGrey","bgHex","bgMagenta","bgMagentaBright","bgRed","bgRedBright","bgRgb","bgWhite","bgWhiteBright","bgYellow","bgYellowBright","black","blackBright","blue","blueBright","bold","cyan","cyanBright","dim","fg","gray","green","greenBright","grey","hidden","inverse","italic","magenta","magentaBright","overline","red","redBright","reset","rgb","strike","strikethrough","strip","underline","visible","white","whiteBright","yellow","yellowBright"],"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,oBAAAE,MAAwB,oCCc1B,IAAMC,EAAYC,GAA0C,CAC/D,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,IAAMC,EAAU,OAAO,SAASD,EAAO,EAAE,EAGzC,MAAO,CAAEC,GAAW,GAAM,IAAMA,GAAW,EAAK,IAAKA,EAAU,GAAG,CACtE,EAMaC,EAAQ,CAACD,EAAiBE,EAAaC,IAAyBD,EAAMF,EAAUE,EAAMF,EAAUG,EAAMA,EAAMH,EAM5GI,EAAmB,CAACC,EAAiBC,EAAqBC,IAAiC,CAEpG,GAAID,IAAgB,GAChB,OAAOD,EAGX,IAAIG,EAAMH,EAAQ,QAAQC,CAAW,EACrC,GAAIE,EAAM,EACN,OAAOH,EAGX,IAAMI,EAAkBH,EAAY,OAChCI,EAAU,EACVC,EAAS,GAGb,KAAO,CAACH,GACJ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,OAAAqF,GACA,QAAAC,GACA,OAAAC,GACA,QAAAC,GACA,cAAAC,GACA,SAAAC,GACA,IAAAC,GACA,UAAAC,GACA,MAAAC,GACA,IAAAC,GACA,OAAAC,GACA,cAAAC,GACA,MAAAC,GACA,UAAAC,GACA,QAAAC,GACA,MAAAC,GACA,YAAAC,GACA,OAAAC,GACA,aAAAC,EACJ,EAAIxD","sourcesContent":["export default function ansiRegex({onlyFirst = false} = {}) {\n\tconst pattern = [\n\t '[\\\\u001B\\\\u009B][[\\\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\\\d\\\\/#&.:=?%@~_]+)*|[a-zA-Z\\\\d]+(?:;[-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 { isColorSupported } from \"@visulima/is-ansi-color-supported\";\n\nimport type { AnsiColors, AnsiStyles, ColorData } from \"./types\";\nimport { clamp, hexToRgb } from \"./utils\";\n\nconst esc: (open: number | string, close: number | string) => ColorData =\n isColorSupported() > 0\n ? (open: number | string, close: number | string): ColorData => {\n // eslint-disable-next-line prefer-template\n return { close: \"\\u001B[\" + close + \"m\", open: \"\\u001B[\" + open + \"m\" };\n }\n : (): ColorData => {\n return { close: \"\", open: \"\" };\n };\n\n// eslint-disable-next-line prefer-template\nconst createAnsi256 = (code: number | string): ColorData => esc(\"38;5;\" + code, 39);\n// eslint-disable-next-line prefer-template\nconst createBgAnsi256 = (code: number | string): ColorData => esc(\"48;5;\" + code, 49);\n// eslint-disable-next-line prefer-template\nconst createRgb = (r: number | string, g: number | string, b: number | string): ColorData => esc(\"38;2;\" + r + \";\" + g + \";\" + b, 39);\n// eslint-disable-next-line prefer-template\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: string) => ColorData;\n bgRgb: (r: number, g: number, b: number) => ColorData;\n fg: (code: number) => ColorData;\n hex: (hex: string) => ColorData;\n rgb: (r: number, g: number, b: number) => ColorData;\n} = {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n bg: (code) => createBgAnsi256(clamp(code, 0, 255)),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n bgHex: (hex) => createBgRgb(...hexToRgb(hex)),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n bgRgb: (r, g, b) => createBgRgb(clamp(r, 0, 255), clamp(g, 0, 255), clamp(b, 0, 255)),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n fg: (code) => createAnsi256(clamp(code, 0, 255)),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n hex: (hex) => createRgb(...hexToRgb(hex)),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\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 * 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: string): [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/**\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 */\nexport const clamp = (number_: number, min: number, max: number): number => (min > number_ ? min : number_ > max ? max : number_);\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 \"./utils\";\n\nconst styles: Record<string, object> = {};\n\nlet stylePrototype: object | null = null;\n\nconst wrapText = (\n strings: ArrayLike<string> | ReadonlyArray<string> | 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 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 prefer-template,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_: 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 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\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 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\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 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\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","import ColorizeImpl from \"./colorize\";\nimport type { ColorizeType } from \"./types\";\n\nconst colorize: ColorizeType = new ColorizeImpl() as ColorizeType;\n\n// eslint-disable-next-line import/no-default-export\nexport default colorize as ColorizeType;\n\n// eslint-disable-next-line import/no-unused-modules\nexport const {\n ansi256,\n bg,\n bgAnsi256,\n bgBlack,\n bgBlackBright,\n bgBlue,\n bgBlueBright,\n bgCyan,\n bgCyanBright,\n bgGray,\n bgGreen,\n bgGreenBright,\n bgGrey,\n bgHex,\n bgMagenta,\n bgMagentaBright,\n bgRed,\n bgRedBright,\n bgRgb,\n bgWhite,\n bgWhiteBright,\n bgYellow,\n bgYellowBright,\n black,\n blackBright,\n blue,\n blueBright,\n bold,\n cyan,\n cyanBright,\n dim,\n fg,\n gray,\n green,\n greenBright,\n grey,\n hex,\n hidden,\n inverse,\n italic,\n magenta,\n magentaBright,\n overline,\n red,\n redBright,\n reset,\n rgb,\n strike,\n strikethrough,\n strip,\n underline,\n visible,\n white,\n whiteBright,\n yellow,\n yellowBright,\n} = colorize;\n\nexport { default as Colorize } from \"./colorize\";\n\n// eslint-disable-next-line import/no-unused-modules\nexport type { AnsiColors, AnsiStyles, ColorizeType } from \"./types\";\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@visulima/colorize",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Terminal and Console string styling done right.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"256",
|
|
7
|
+
"anolilab",
|
|
8
|
+
"ansi",
|
|
9
|
+
"ansi-colors",
|
|
10
|
+
"blue",
|
|
11
|
+
"chalk",
|
|
12
|
+
"cli",
|
|
13
|
+
"color",
|
|
14
|
+
"colorette",
|
|
15
|
+
"colorize",
|
|
16
|
+
"colors",
|
|
17
|
+
"colors.js",
|
|
18
|
+
"colour",
|
|
19
|
+
"command-line",
|
|
20
|
+
"console",
|
|
21
|
+
"cyan",
|
|
22
|
+
"FORCE_COLOR",
|
|
23
|
+
"formatting",
|
|
24
|
+
"green",
|
|
25
|
+
"kleur",
|
|
26
|
+
"log",
|
|
27
|
+
"logging",
|
|
28
|
+
"magenta",
|
|
29
|
+
"NO_COLOR",
|
|
30
|
+
"picocolors",
|
|
31
|
+
"red",
|
|
32
|
+
"rgb",
|
|
33
|
+
"shell",
|
|
34
|
+
"string",
|
|
35
|
+
"strip-color",
|
|
36
|
+
"style",
|
|
37
|
+
"styles",
|
|
38
|
+
"terminal",
|
|
39
|
+
"text",
|
|
40
|
+
"truecolor",
|
|
41
|
+
"tty",
|
|
42
|
+
"visulima",
|
|
43
|
+
"xterm",
|
|
44
|
+
"yellow"
|
|
45
|
+
],
|
|
46
|
+
"homepage": "https://www.visulima.com/docs/package/colorize",
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "https://github.com/visulima/visulima.git",
|
|
50
|
+
"directory": "packages/colorize"
|
|
51
|
+
},
|
|
52
|
+
"funding": [
|
|
53
|
+
{
|
|
54
|
+
"type": "github",
|
|
55
|
+
"url": "https://github.com/sponsors/prisis"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"type": "consulting",
|
|
59
|
+
"url": "https://anolilab.com/support"
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"license": "MIT",
|
|
63
|
+
"author": {
|
|
64
|
+
"name": "Daniel Bannert",
|
|
65
|
+
"email": "d.bannert@anolilab.de"
|
|
66
|
+
},
|
|
67
|
+
"sideEffects": false,
|
|
68
|
+
"type": "module",
|
|
69
|
+
"exports": {
|
|
70
|
+
".": {
|
|
71
|
+
"browser": "./dist/index.js",
|
|
72
|
+
"require": {
|
|
73
|
+
"types": "./dist/index.d.cts",
|
|
74
|
+
"default": "./dist/index.cjs"
|
|
75
|
+
},
|
|
76
|
+
"import": {
|
|
77
|
+
"types": "./dist/index.d.ts",
|
|
78
|
+
"default": "./dist/index.js"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"./package.json": "./package.json"
|
|
82
|
+
},
|
|
83
|
+
"main": "dist/index.cjs",
|
|
84
|
+
"module": "dist/index.js",
|
|
85
|
+
"types": "dist/index.d.ts",
|
|
86
|
+
"files": [
|
|
87
|
+
"dist/**",
|
|
88
|
+
"README.md",
|
|
89
|
+
"CHANGELOG.md",
|
|
90
|
+
"LICENSE.md"
|
|
91
|
+
],
|
|
92
|
+
"scripts": {
|
|
93
|
+
"build": "cross-env NODE_ENV=development tsup",
|
|
94
|
+
"build:prod": "cross-env NODE_ENV=production tsup",
|
|
95
|
+
"clean": "rimraf node_modules dist .eslintcache",
|
|
96
|
+
"dev": "pnpm run build --watch",
|
|
97
|
+
"lint:eslint": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,cts,mts,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs",
|
|
98
|
+
"lint:eslint:fix": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,cts,mts,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs --fix",
|
|
99
|
+
"lint:packagejson": "publint --strict",
|
|
100
|
+
"lint:prettier": "prettier --config=.prettierrc.cjs --check .",
|
|
101
|
+
"lint:prettier:fix": "prettier --config=.prettierrc.cjs --write .",
|
|
102
|
+
"lint:types": "tsc --noEmit",
|
|
103
|
+
"test": "vitest run",
|
|
104
|
+
"test:bench": "node __bench__",
|
|
105
|
+
"test:coverage": "vitest run --coverage",
|
|
106
|
+
"test:ui": "vitest --ui --coverage.enabled=true",
|
|
107
|
+
"test:watch": "vitest"
|
|
108
|
+
},
|
|
109
|
+
"dependencies": {
|
|
110
|
+
"@visulima/is-ansi-color-supported": "1.0.0"
|
|
111
|
+
},
|
|
112
|
+
"devDependencies": {
|
|
113
|
+
"@anolilab/eslint-config": "^15.0.3",
|
|
114
|
+
"@anolilab/prettier-config": "^5.0.14",
|
|
115
|
+
"@anolilab/semantic-release-preset": "^8.0.3",
|
|
116
|
+
"@babel/core": "^7.23.7",
|
|
117
|
+
"@rushstack/eslint-plugin-security": "^0.8.0",
|
|
118
|
+
"@secretlint/secretlint-rule-preset-recommend": "^8.1.0",
|
|
119
|
+
"@types/micromatch": "^4.0.6",
|
|
120
|
+
"@types/node": "18.18.8",
|
|
121
|
+
"@vitest/coverage-v8": "^1.2.1",
|
|
122
|
+
"@vitest/ui": "^1.2.1",
|
|
123
|
+
"ansi-colors": "4.1.3",
|
|
124
|
+
"ansi-regex": "^6.0.1",
|
|
125
|
+
"ansi-styles": "^6.2.1",
|
|
126
|
+
"ansis": "2.0.3",
|
|
127
|
+
"benchmark": "2.1.4",
|
|
128
|
+
"chalk": "5.3.0",
|
|
129
|
+
"cli-color": "2.0.3",
|
|
130
|
+
"colorette": "2.0.20",
|
|
131
|
+
"colors": "1.4.0",
|
|
132
|
+
"colors-cli": "1.0.33",
|
|
133
|
+
"cross-env": "^7.0.3",
|
|
134
|
+
"eslint": "^8.56.0",
|
|
135
|
+
"eslint-plugin-deprecation": "^2.0.0",
|
|
136
|
+
"eslint-plugin-etc": "^2.0.3",
|
|
137
|
+
"eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
|
|
138
|
+
"eslint-plugin-mdx": "^3.1.5",
|
|
139
|
+
"eslint-plugin-vitest": "^0.3.20",
|
|
140
|
+
"eslint-plugin-vitest-globals": "^1.4.0",
|
|
141
|
+
"kleur": "4.1.5",
|
|
142
|
+
"picocolors": "1.0.0",
|
|
143
|
+
"prettier": "^3.2.4",
|
|
144
|
+
"rimraf": "^5.0.5",
|
|
145
|
+
"secretlint": "8.1.0",
|
|
146
|
+
"semantic-release": "^23.0.0",
|
|
147
|
+
"sort-package-json": "^2.6.0",
|
|
148
|
+
"tsup": "^8.0.1",
|
|
149
|
+
"type-fest": "^4.9.0",
|
|
150
|
+
"typescript": "^5.3.3",
|
|
151
|
+
"vitest": "^1.2.1"
|
|
152
|
+
},
|
|
153
|
+
"engines": {
|
|
154
|
+
"node": ">=18.* <=21.*"
|
|
155
|
+
},
|
|
156
|
+
"publishConfig": {
|
|
157
|
+
"access": "public",
|
|
158
|
+
"provenance": true
|
|
159
|
+
},
|
|
160
|
+
"anolilab": {
|
|
161
|
+
"eslint-config": {
|
|
162
|
+
"plugin": {
|
|
163
|
+
"tsdoc": false
|
|
164
|
+
},
|
|
165
|
+
"warn_on_unsupported_typescript_version": false,
|
|
166
|
+
"info_on_disabling_jsx_react_rule": false,
|
|
167
|
+
"info_on_disabling_prettier_conflict_rule": false,
|
|
168
|
+
"info_on_disabling_jsonc_sort_keys_rule": false,
|
|
169
|
+
"info_on_disabling_etc_no_deprecated": false
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"sources": [
|
|
173
|
+
{
|
|
174
|
+
"source": "src/index.mts",
|
|
175
|
+
"format": "esm"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"source": "src/index.cts",
|
|
179
|
+
"format": "cjs"
|
|
180
|
+
}
|
|
181
|
+
]
|
|
182
|
+
}
|