chalk 3.0.0-beta.1 → 4.1.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/index.d.ts +61 -30
- package/package.json +12 -7
- package/readme.md +19 -38
- package/source/index.js +12 -16
- package/source/templates.js +3 -3
package/index.d.ts
CHANGED
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
declare const enum LevelEnum {
|
|
2
|
-
/**
|
|
3
|
-
All colors disabled.
|
|
4
|
-
*/
|
|
5
|
-
None = 0,
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
Basic 16 colors support.
|
|
9
|
-
*/
|
|
10
|
-
Basic = 1,
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
ANSI 256 colors support.
|
|
14
|
-
*/
|
|
15
|
-
Ansi256 = 2,
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
Truecolor 16 million colors support.
|
|
19
|
-
*/
|
|
20
|
-
TrueColor = 3
|
|
21
|
-
}
|
|
22
|
-
|
|
23
1
|
/**
|
|
24
2
|
Basic foreground colors.
|
|
25
3
|
|
|
@@ -89,22 +67,34 @@ declare type Modifiers =
|
|
|
89
67
|
| 'visible';
|
|
90
68
|
|
|
91
69
|
declare namespace chalk {
|
|
92
|
-
|
|
70
|
+
/**
|
|
71
|
+
Levels:
|
|
72
|
+
- `0` - All colors disabled.
|
|
73
|
+
- `1` - Basic 16 colors support.
|
|
74
|
+
- `2` - ANSI 256 colors support.
|
|
75
|
+
- `3` - Truecolor 16 million colors support.
|
|
76
|
+
*/
|
|
77
|
+
type Level = 0 | 1 | 2 | 3;
|
|
93
78
|
|
|
94
79
|
interface Options {
|
|
95
80
|
/**
|
|
96
81
|
Specify the color support for Chalk.
|
|
82
|
+
|
|
97
83
|
By default, color support is automatically detected based on the environment.
|
|
84
|
+
|
|
85
|
+
Levels:
|
|
86
|
+
- `0` - All colors disabled.
|
|
87
|
+
- `1` - Basic 16 colors support.
|
|
88
|
+
- `2` - ANSI 256 colors support.
|
|
89
|
+
- `3` - Truecolor 16 million colors support.
|
|
98
90
|
*/
|
|
99
91
|
level?: Level;
|
|
100
92
|
}
|
|
101
93
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
new (options?: Options): Chalk;
|
|
107
|
-
}
|
|
94
|
+
/**
|
|
95
|
+
Return a new Chalk instance.
|
|
96
|
+
*/
|
|
97
|
+
type Instance = new (options?: Options) => Chalk;
|
|
108
98
|
|
|
109
99
|
/**
|
|
110
100
|
Detect whether the terminal supports color.
|
|
@@ -147,6 +137,13 @@ declare namespace chalk {
|
|
|
147
137
|
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
|
|
148
138
|
`);
|
|
149
139
|
```
|
|
140
|
+
|
|
141
|
+
@example
|
|
142
|
+
```
|
|
143
|
+
import chalk = require('chalk');
|
|
144
|
+
|
|
145
|
+
log(chalk.red.bgBlack`2 + 3 = {bold ${2 + 3}}`)
|
|
146
|
+
```
|
|
150
147
|
*/
|
|
151
148
|
(text: TemplateStringsArray, ...placeholders: unknown[]): string;
|
|
152
149
|
|
|
@@ -161,7 +158,14 @@ declare namespace chalk {
|
|
|
161
158
|
|
|
162
159
|
/**
|
|
163
160
|
The color support for Chalk.
|
|
161
|
+
|
|
164
162
|
By default, color support is automatically detected based on the environment.
|
|
163
|
+
|
|
164
|
+
Levels:
|
|
165
|
+
- `0` - All colors disabled.
|
|
166
|
+
- `1` - Basic 16 colors support.
|
|
167
|
+
- `2` - ANSI 256 colors support.
|
|
168
|
+
- `3` - Truecolor 16 million colors support.
|
|
165
169
|
*/
|
|
166
170
|
level: Level;
|
|
167
171
|
|
|
@@ -213,6 +217,19 @@ declare namespace chalk {
|
|
|
213
217
|
*/
|
|
214
218
|
hwb(hue: number, whiteness: number, blackness: number): Chalk;
|
|
215
219
|
|
|
220
|
+
/**
|
|
221
|
+
Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set text color.
|
|
222
|
+
|
|
223
|
+
30 <= code && code < 38 || 90 <= code && code < 98
|
|
224
|
+
For example, 31 for red, 91 for redBright.
|
|
225
|
+
*/
|
|
226
|
+
ansi(code: number): Chalk;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
|
|
230
|
+
*/
|
|
231
|
+
ansi256(index: number): Chalk;
|
|
232
|
+
|
|
216
233
|
/**
|
|
217
234
|
Use HEX value to set background color.
|
|
218
235
|
|
|
@@ -261,6 +278,20 @@ declare namespace chalk {
|
|
|
261
278
|
*/
|
|
262
279
|
bgHwb(hue: number, whiteness: number, blackness: number): Chalk;
|
|
263
280
|
|
|
281
|
+
/**
|
|
282
|
+
Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set background color.
|
|
283
|
+
|
|
284
|
+
30 <= code && code < 38 || 90 <= code && code < 98
|
|
285
|
+
For example, 31 for red, 91 for redBright.
|
|
286
|
+
Use the foreground code, not the background code (for example, not 41, nor 101).
|
|
287
|
+
*/
|
|
288
|
+
bgAnsi(code: number): Chalk;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color.
|
|
292
|
+
*/
|
|
293
|
+
bgAnsi256(index: number): Chalk;
|
|
294
|
+
|
|
264
295
|
/**
|
|
265
296
|
Modifier: Resets the current color chain.
|
|
266
297
|
*/
|
|
@@ -373,7 +404,7 @@ This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
|
|
373
404
|
*/
|
|
374
405
|
declare const chalk: chalk.Chalk & chalk.ChalkFunction & {
|
|
375
406
|
supportsColor: chalk.ColorSupport | false;
|
|
376
|
-
Level:
|
|
407
|
+
Level: chalk.Level;
|
|
377
408
|
Color: Color;
|
|
378
409
|
ForegroundColor: ForegroundColor;
|
|
379
410
|
BackgroundColor: BackgroundColor;
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chalk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Terminal string styling done right",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "chalk/chalk",
|
|
7
|
+
"funding": "https://github.com/chalk/chalk?sponsor=1",
|
|
7
8
|
"main": "source",
|
|
8
9
|
"engines": {
|
|
9
|
-
"node": ">=
|
|
10
|
+
"node": ">=10"
|
|
10
11
|
},
|
|
11
12
|
"scripts": {
|
|
12
13
|
"test": "xo && nyc ava && tsd",
|
|
@@ -45,19 +46,23 @@
|
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"ava": "^2.4.0",
|
|
48
|
-
"coveralls": "^3.0.
|
|
49
|
-
"execa": "^
|
|
49
|
+
"coveralls": "^3.0.7",
|
|
50
|
+
"execa": "^4.0.0",
|
|
50
51
|
"import-fresh": "^3.1.0",
|
|
51
52
|
"matcha": "^0.7.0",
|
|
52
|
-
"nyc": "^
|
|
53
|
+
"nyc": "^15.0.0",
|
|
53
54
|
"resolve-from": "^5.0.0",
|
|
54
55
|
"tsd": "^0.7.4",
|
|
55
|
-
"xo": "^0.
|
|
56
|
+
"xo": "^0.28.2"
|
|
56
57
|
},
|
|
57
58
|
"xo": {
|
|
58
59
|
"rules": {
|
|
59
60
|
"unicorn/prefer-string-slice": "off",
|
|
60
|
-
"unicorn/prefer-includes": "off"
|
|
61
|
+
"unicorn/prefer-includes": "off",
|
|
62
|
+
"@typescript-eslint/member-ordering": "off",
|
|
63
|
+
"no-redeclare": "off",
|
|
64
|
+
"unicorn/string-content": "off",
|
|
65
|
+
"unicorn/better-regex": "off"
|
|
61
66
|
}
|
|
62
67
|
}
|
|
63
68
|
}
|
package/readme.md
CHANGED
|
@@ -9,13 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
> Terminal string styling done right
|
|
11
11
|
|
|
12
|
-
[](https://travis-ci.org/chalk/chalk) [](https://coveralls.io/github/chalk/chalk?branch=master) [](https://www.npmjs.com/package/chalk?activeTab=dependents) [](https://www.npmjs.com/package/chalk) [](https://www.youtube.com/watch?v=9auOCbH5Ns4) [](https://github.com/xojs/xo) 
|
|
12
|
+
[](https://travis-ci.org/chalk/chalk) [](https://coveralls.io/github/chalk/chalk?branch=master) [](https://www.npmjs.com/package/chalk?activeTab=dependents) [](https://www.npmjs.com/package/chalk) [](https://www.youtube.com/watch?v=9auOCbH5Ns4) [](https://github.com/xojs/xo)  [](https://repl.it/github/chalk/chalk)
|
|
13
13
|
|
|
14
14
|
<img src="https://cdn.jsdelivr.net/gh/chalk/ansi-styles@8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
|
|
15
15
|
|
|
16
|
-
**This readme reflects the next major version that is currently in development. You probably want [the v2 readme](https://www.npmjs.com/package/chalk).**
|
|
17
|
-
|
|
18
|
-
|
|
19
16
|
## Highlights
|
|
20
17
|
|
|
21
18
|
- Expressive API
|
|
@@ -26,8 +23,7 @@
|
|
|
26
23
|
- Doesn't extend `String.prototype`
|
|
27
24
|
- Clean and focused
|
|
28
25
|
- Actively maintained
|
|
29
|
-
- [Used by ~
|
|
30
|
-
|
|
26
|
+
- [Used by ~50,000 packages](https://www.npmjs.com/browse/depended/chalk) as of January 1, 2020
|
|
31
27
|
|
|
32
28
|
## Install
|
|
33
29
|
|
|
@@ -35,7 +31,6 @@
|
|
|
35
31
|
$ npm install chalk
|
|
36
32
|
```
|
|
37
33
|
|
|
38
|
-
|
|
39
34
|
## Usage
|
|
40
35
|
|
|
41
36
|
```js
|
|
@@ -109,7 +104,6 @@ console.log(chalk.green('Hello %s'), name);
|
|
|
109
104
|
//=> 'Hello Sindre'
|
|
110
105
|
```
|
|
111
106
|
|
|
112
|
-
|
|
113
107
|
## API
|
|
114
108
|
|
|
115
109
|
### chalk.`<style>[.<style>...](string, [string...])`
|
|
@@ -132,12 +126,12 @@ If you need to change this in a reusable module, create a new instance:
|
|
|
132
126
|
const ctx = new chalk.Instance({level: 0});
|
|
133
127
|
```
|
|
134
128
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
0
|
|
138
|
-
1
|
|
139
|
-
2
|
|
140
|
-
3
|
|
129
|
+
| Level | Description |
|
|
130
|
+
| :---: | :--- |
|
|
131
|
+
| `0` | All colors disabled |
|
|
132
|
+
| `1` | Basic color support (16 colors) |
|
|
133
|
+
| `2` | 256 color support |
|
|
134
|
+
| `3` | Truecolor support (16 million colors) |
|
|
141
135
|
|
|
142
136
|
### chalk.supportsColor
|
|
143
137
|
|
|
@@ -151,7 +145,6 @@ Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=
|
|
|
151
145
|
|
|
152
146
|
`chalk.stderr` contains a separate instance configured with color support detected for `stderr` stream instead of `stdout`. Override rules from `chalk.supportsColor` apply to this too. `chalk.stderr.supportsColor` is exposed for convenience.
|
|
153
147
|
|
|
154
|
-
|
|
155
148
|
## Styles
|
|
156
149
|
|
|
157
150
|
### Modifiers
|
|
@@ -204,10 +197,9 @@ Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=
|
|
|
204
197
|
- `bgCyanBright`
|
|
205
198
|
- `bgWhiteBright`
|
|
206
199
|
|
|
207
|
-
|
|
208
200
|
## Tagged template literal
|
|
209
201
|
|
|
210
|
-
Chalk can be used as a [tagged template literal](
|
|
202
|
+
Chalk can be used as a [tagged template literal](https://exploringjs.com/es6/ch_template-literals.html#_tagged-template-literals).
|
|
211
203
|
|
|
212
204
|
```js
|
|
213
205
|
const chalk = require('chalk');
|
|
@@ -223,10 +215,11 @@ console.log(chalk`
|
|
|
223
215
|
|
|
224
216
|
Blocks are delimited by an opening curly brace (`{`), a style, some content, and a closing curly brace (`}`).
|
|
225
217
|
|
|
226
|
-
Template styles are chained exactly like normal Chalk styles. The following
|
|
218
|
+
Template styles are chained exactly like normal Chalk styles. The following three statements are equivalent:
|
|
227
219
|
|
|
228
220
|
```js
|
|
229
221
|
console.log(chalk.bold.rgb(10, 100, 200)('Hello!'));
|
|
222
|
+
console.log(chalk.bold.rgb(10, 100, 200)`Hello!`);
|
|
230
223
|
console.log(chalk`{bold.rgb(10,100,200) Hello!}`);
|
|
231
224
|
```
|
|
232
225
|
|
|
@@ -234,7 +227,6 @@ Note that function styles (`rgb()`, `hsl()`, `keyword()`, etc.) may not contain
|
|
|
234
227
|
|
|
235
228
|
All interpolated values (`` chalk`${foo}` ``) are converted to strings via the `.toString()` method. All curly braces (`{` and `}`) in interpolated value strings are escaped.
|
|
236
229
|
|
|
237
|
-
|
|
238
230
|
## 256 and Truecolor color support
|
|
239
231
|
|
|
240
232
|
Chalk supports 256 colors and [Truecolor](https://gist.github.com/XVilka/8346728) (16 million colors) on supported terminal apps.
|
|
@@ -260,20 +252,23 @@ The following color models can be used:
|
|
|
260
252
|
- [`keyword`](https://www.w3.org/wiki/CSS/Properties/color/keywords) (CSS keywords) - Example: `chalk.keyword('orange').bold('Orange!')`
|
|
261
253
|
- [`hsl`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 100, 50).bold('Orange!')`
|
|
262
254
|
- [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsv(32, 100, 100).bold('Orange!')`
|
|
263
|
-
- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model)
|
|
264
|
-
- `
|
|
265
|
-
- `ansi256`
|
|
266
|
-
|
|
255
|
+
- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hwb(32, 0, 50).bold('Orange!')`
|
|
256
|
+
- [`ansi`](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) - Example: `chalk.ansi(31).bgAnsi(93)('red on yellowBright')`
|
|
257
|
+
- [`ansi256`](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) - Example: `chalk.bgAnsi256(194)('Honeydew, more or less')`
|
|
267
258
|
|
|
268
259
|
## Windows
|
|
269
260
|
|
|
270
261
|
If you're on Windows, do yourself a favor and use [Windows Terminal](https://github.com/microsoft/terminal) instead of `cmd.exe`.
|
|
271
262
|
|
|
272
|
-
|
|
273
263
|
## Origin story
|
|
274
264
|
|
|
275
265
|
[colors.js](https://github.com/Marak/colors.js) used to be the most popular string styling module, but it has serious deficiencies like extending `String.prototype` which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68) and the package is unmaintained. Although there are other packages, they either do too much or not enough. Chalk is a clean and focused alternative.
|
|
276
266
|
|
|
267
|
+
## chalk for enterprise
|
|
268
|
+
|
|
269
|
+
Available as part of the Tidelift Subscription.
|
|
270
|
+
|
|
271
|
+
The maintainers of chalk and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-chalk?utm_source=npm-chalk&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
|
277
272
|
|
|
278
273
|
## Related
|
|
279
274
|
|
|
@@ -292,21 +287,7 @@ If you're on Windows, do yourself a favor and use [Windows Terminal](https://git
|
|
|
292
287
|
- [chalk-pipe](https://github.com/LitoMore/chalk-pipe) - Create chalk style schemes with simpler style strings
|
|
293
288
|
- [terminal-link](https://github.com/sindresorhus/terminal-link) - Create clickable links in the terminal
|
|
294
289
|
|
|
295
|
-
|
|
296
290
|
## Maintainers
|
|
297
291
|
|
|
298
292
|
- [Sindre Sorhus](https://github.com/sindresorhus)
|
|
299
293
|
- [Josh Junon](https://github.com/qix-)
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
---
|
|
303
|
-
|
|
304
|
-
<div align="center">
|
|
305
|
-
<b>
|
|
306
|
-
<a href="https://tidelift.com/subscription/pkg/npm-chalk?utm_source=npm-chalk&utm_medium=referral&utm_campaign=readme">Get professional support for Chalk with a Tidelift subscription</a>
|
|
307
|
-
</b>
|
|
308
|
-
<br>
|
|
309
|
-
<sub>
|
|
310
|
-
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
|
311
|
-
</sub>
|
|
312
|
-
</div>
|
package/source/index.js
CHANGED
|
@@ -6,6 +6,8 @@ const {
|
|
|
6
6
|
stringEncaseCRLFWithFirstIndex
|
|
7
7
|
} = require('./util');
|
|
8
8
|
|
|
9
|
+
const {isArray} = Array;
|
|
10
|
+
|
|
9
11
|
// `supportsColor.level` → `ansiStyles.color[name]` mapping
|
|
10
12
|
const levelMapping = [
|
|
11
13
|
'ansi',
|
|
@@ -17,7 +19,7 @@ const levelMapping = [
|
|
|
17
19
|
const styles = Object.create(null);
|
|
18
20
|
|
|
19
21
|
const applyOptions = (object, options = {}) => {
|
|
20
|
-
if (options.level
|
|
22
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
21
23
|
throw new Error('The `level` option should be an integer from 0 to 3');
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -28,6 +30,7 @@ const applyOptions = (object, options = {}) => {
|
|
|
28
30
|
|
|
29
31
|
class ChalkClass {
|
|
30
32
|
constructor(options) {
|
|
33
|
+
// eslint-disable-next-line no-constructor-return
|
|
31
34
|
return chalkFactory(options);
|
|
32
35
|
}
|
|
33
36
|
}
|
|
@@ -134,14 +137,19 @@ const createStyler = (open, close, parent) => {
|
|
|
134
137
|
|
|
135
138
|
const createBuilder = (self, _styler, _isEmpty) => {
|
|
136
139
|
const builder = (...arguments_) => {
|
|
140
|
+
if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
|
|
141
|
+
// Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
|
|
142
|
+
return applyStyle(builder, chalkTag(builder, ...arguments_));
|
|
143
|
+
}
|
|
144
|
+
|
|
137
145
|
// Single argument is hot path, implicit coercion is faster than anything
|
|
138
146
|
// eslint-disable-next-line no-implicit-coercion
|
|
139
147
|
return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
|
|
140
148
|
};
|
|
141
149
|
|
|
142
|
-
//
|
|
150
|
+
// We alter the prototype because we must return a function, but there is
|
|
143
151
|
// no way to create a function with a different prototype
|
|
144
|
-
builder
|
|
152
|
+
Object.setPrototypeOf(builder, proto);
|
|
145
153
|
|
|
146
154
|
builder._generator = self;
|
|
147
155
|
builder._styler = _styler;
|
|
@@ -188,7 +196,7 @@ let template;
|
|
|
188
196
|
const chalkTag = (chalk, ...strings) => {
|
|
189
197
|
const [firstString] = strings;
|
|
190
198
|
|
|
191
|
-
if (!
|
|
199
|
+
if (!isArray(firstString) || !isArray(firstString.raw)) {
|
|
192
200
|
// If chalk() was called by itself or with a string,
|
|
193
201
|
// return the string itself as a string.
|
|
194
202
|
return strings.join(' ');
|
|
@@ -218,16 +226,4 @@ chalk.supportsColor = stdoutColor;
|
|
|
218
226
|
chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
|
|
219
227
|
chalk.stderr.supportsColor = stderrColor;
|
|
220
228
|
|
|
221
|
-
// For TypeScript
|
|
222
|
-
chalk.Level = {
|
|
223
|
-
None: 0,
|
|
224
|
-
Basic: 1,
|
|
225
|
-
Ansi256: 2,
|
|
226
|
-
TrueColor: 3,
|
|
227
|
-
0: 'None',
|
|
228
|
-
1: 'Basic',
|
|
229
|
-
2: 'Ansi256',
|
|
230
|
-
3: 'TrueColor'
|
|
231
|
-
};
|
|
232
|
-
|
|
233
229
|
module.exports = chalk;
|
package/source/templates.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
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;
|
|
3
3
|
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
|
4
4
|
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
|
5
|
-
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}
|
|
5
|
+
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
|
|
6
6
|
|
|
7
7
|
const ESCAPES = new Map([
|
|
8
8
|
['n', '\n'],
|
|
@@ -126,8 +126,8 @@ module.exports = (chalk, temporary) => {
|
|
|
126
126
|
chunks.push(chunk.join(''));
|
|
127
127
|
|
|
128
128
|
if (styles.length > 0) {
|
|
129
|
-
const
|
|
130
|
-
throw new Error(
|
|
129
|
+
const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
|
|
130
|
+
throw new Error(errMessage);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
return chunks.join('');
|