@shell-shock/plugin-theme 0.2.2 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contexts/index.cjs +4 -0
- package/dist/contexts/index.d.cts +2 -0
- package/dist/contexts/index.d.mts +2 -0
- package/dist/contexts/index.mjs +3 -0
- package/dist/contexts/theme.cjs +28 -0
- package/dist/contexts/theme.d.cts +20 -0
- package/dist/contexts/theme.d.cts.map +1 -0
- package/dist/contexts/theme.d.mts +20 -0
- package/dist/contexts/theme.d.mts.map +1 -0
- package/dist/contexts/theme.mjs +27 -0
- package/dist/contexts/theme.mjs.map +1 -0
- package/dist/helpers/ansi-utils.cjs +692 -0
- package/dist/helpers/ansi-utils.d.cts +75 -0
- package/dist/helpers/ansi-utils.d.cts.map +1 -0
- package/dist/helpers/ansi-utils.d.mts +75 -0
- package/dist/helpers/ansi-utils.d.mts.map +1 -0
- package/dist/helpers/ansi-utils.mjs +689 -0
- package/dist/helpers/ansi-utils.mjs.map +1 -0
- package/dist/helpers/index.cjs +6 -0
- package/dist/helpers/index.d.cts +2 -0
- package/dist/helpers/index.d.mts +2 -0
- package/dist/helpers/index.mjs +3 -0
- package/dist/index.cjs +53 -47
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +52 -47
- package/dist/index.mjs.map +1 -1
- package/dist/style-dictionary/border-styles.mjs.map +1 -1
- package/dist/style-dictionary/colors.mjs.map +1 -1
- package/dist/style-dictionary/helpers.mjs.map +1 -1
- package/dist/style-dictionary/icons.mjs.map +1 -1
- package/dist/style-dictionary/labels.mjs.map +1 -1
- package/dist/style-dictionary/padding.mjs.map +1 -1
- package/dist/style-dictionary/settings.mjs.map +1 -1
- package/dist/themes/storm.mjs.map +1 -1
- package/dist/types/plugin.d.cts +6 -4
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +6 -4
- package/dist/types/plugin.d.mts.map +1 -1
- package/package.json +61 -3
|
@@ -0,0 +1,692 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/helpers/ansi-utils.ts
|
|
3
|
+
const ANSI_BACKGROUND_OFFSET = 10;
|
|
4
|
+
const modifiers = {
|
|
5
|
+
reset: [0, 0],
|
|
6
|
+
bold: [1, 22],
|
|
7
|
+
dim: [2, 22],
|
|
8
|
+
italic: [3, 23],
|
|
9
|
+
underline: [4, 24],
|
|
10
|
+
overline: [53, 55],
|
|
11
|
+
inverse: [7, 27],
|
|
12
|
+
hidden: [8, 28],
|
|
13
|
+
strikethrough: [9, 29]
|
|
14
|
+
};
|
|
15
|
+
const colors = {
|
|
16
|
+
black: [30, 39],
|
|
17
|
+
red: [31, 39],
|
|
18
|
+
green: [32, 39],
|
|
19
|
+
yellow: [33, 39],
|
|
20
|
+
blue: [34, 39],
|
|
21
|
+
magenta: [35, 39],
|
|
22
|
+
cyan: [36, 39],
|
|
23
|
+
white: [37, 39],
|
|
24
|
+
blackBright: [90, 39],
|
|
25
|
+
gray: [90, 39],
|
|
26
|
+
grey: [90, 39],
|
|
27
|
+
redBright: [91, 39],
|
|
28
|
+
greenBright: [92, 39],
|
|
29
|
+
yellowBright: [93, 39],
|
|
30
|
+
blueBright: [94, 39],
|
|
31
|
+
magentaBright: [95, 39],
|
|
32
|
+
cyanBright: [96, 39],
|
|
33
|
+
whiteBright: [97, 39]
|
|
34
|
+
};
|
|
35
|
+
const bgColors = {
|
|
36
|
+
bgBlack: [40, 49],
|
|
37
|
+
bgRed: [41, 49],
|
|
38
|
+
bgGreen: [42, 49],
|
|
39
|
+
bgYellow: [43, 49],
|
|
40
|
+
bgBlue: [44, 49],
|
|
41
|
+
bgMagenta: [45, 49],
|
|
42
|
+
bgCyan: [46, 49],
|
|
43
|
+
bgWhite: [47, 49],
|
|
44
|
+
bgBlackBright: [100, 49],
|
|
45
|
+
bgGray: [100, 49],
|
|
46
|
+
bgGrey: [100, 49],
|
|
47
|
+
bgRedBright: [101, 49],
|
|
48
|
+
bgGreenBright: [102, 49],
|
|
49
|
+
bgYellowBright: [103, 49],
|
|
50
|
+
bgBlueBright: [104, 49],
|
|
51
|
+
bgMagentaBright: [105, 49],
|
|
52
|
+
bgCyanBright: [106, 49],
|
|
53
|
+
bgWhiteBright: [107, 49]
|
|
54
|
+
};
|
|
55
|
+
const wrapAnsi16 = (offset = 0) => (code) => `\\x1b[${code + offset}m`;
|
|
56
|
+
const wrapAnsi256 = (offset = 0) => (code) => `\\x1b[${38 + offset};5;${code}m`;
|
|
57
|
+
const wrapAnsi16m = (offset = 0) => (code) => {
|
|
58
|
+
const [red, green, blue] = hexToRgb(code);
|
|
59
|
+
return `\\x1b[${38 + offset};2;${red};${green};${blue}m`;
|
|
60
|
+
};
|
|
61
|
+
function rgbToAnsi256(red, green, blue) {
|
|
62
|
+
if (red === green && green === blue) {
|
|
63
|
+
if (red < 8) return 16;
|
|
64
|
+
if (red > 248) return 231;
|
|
65
|
+
return Math.round((red - 8) / 247 * 24) + 232;
|
|
66
|
+
}
|
|
67
|
+
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
|
68
|
+
}
|
|
69
|
+
function hexToRgb(hex) {
|
|
70
|
+
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
71
|
+
if (!matches) return [
|
|
72
|
+
0,
|
|
73
|
+
0,
|
|
74
|
+
0
|
|
75
|
+
];
|
|
76
|
+
let [colorString] = matches;
|
|
77
|
+
if (colorString.length === 3) colorString = [...colorString].map((character) => character + character).join("");
|
|
78
|
+
const integer = Number.parseInt(colorString, 16);
|
|
79
|
+
return [
|
|
80
|
+
integer >> 16 & 255,
|
|
81
|
+
integer >> 8 & 255,
|
|
82
|
+
integer & 255
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
function hexToAnsi256(hex) {
|
|
86
|
+
return rgbToAnsi256(...hexToRgb(hex));
|
|
87
|
+
}
|
|
88
|
+
function ansi256ToAnsi(code) {
|
|
89
|
+
if (code < 8) return 30 + code;
|
|
90
|
+
if (code < 16) return 90 + (code - 8);
|
|
91
|
+
let red;
|
|
92
|
+
let green;
|
|
93
|
+
let blue;
|
|
94
|
+
if (code >= 232) {
|
|
95
|
+
red = ((code - 232) * 10 + 8) / 255;
|
|
96
|
+
green = red;
|
|
97
|
+
blue = red;
|
|
98
|
+
} else {
|
|
99
|
+
code -= 16;
|
|
100
|
+
const remainder = code % 36;
|
|
101
|
+
red = Math.floor(code / 36) / 5;
|
|
102
|
+
green = Math.floor(remainder / 6) / 5;
|
|
103
|
+
blue = remainder % 6 / 5;
|
|
104
|
+
}
|
|
105
|
+
const value = Math.max(red, green, blue) * 2;
|
|
106
|
+
if (value === 0) return 30;
|
|
107
|
+
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
|
108
|
+
if (value === 2) result += 60;
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
function hexToAnsi(hex) {
|
|
112
|
+
return ansi256ToAnsi(hexToAnsi256(hex));
|
|
113
|
+
}
|
|
114
|
+
function buildThemeAnsiStyles(theme, wrapFn, convertFn) {
|
|
115
|
+
return {
|
|
116
|
+
text: {
|
|
117
|
+
banner: {
|
|
118
|
+
title: {
|
|
119
|
+
primary: {
|
|
120
|
+
open: wrapFn()(convertFn(theme.text.banner.title.primary)),
|
|
121
|
+
close: wrapAnsi16()(39)
|
|
122
|
+
},
|
|
123
|
+
secondary: {
|
|
124
|
+
open: wrapFn()(convertFn(theme.text.banner.title.secondary)),
|
|
125
|
+
close: wrapAnsi16()(39)
|
|
126
|
+
},
|
|
127
|
+
tertiary: {
|
|
128
|
+
open: wrapFn()(convertFn(theme.text.banner.title.tertiary)),
|
|
129
|
+
close: wrapAnsi16()(39)
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
command: {
|
|
133
|
+
primary: {
|
|
134
|
+
open: wrapFn()(convertFn(theme.text.banner.command.primary)),
|
|
135
|
+
close: wrapAnsi16()(39)
|
|
136
|
+
},
|
|
137
|
+
secondary: {
|
|
138
|
+
open: wrapFn()(convertFn(theme.text.banner.command.secondary)),
|
|
139
|
+
close: wrapAnsi16()(39)
|
|
140
|
+
},
|
|
141
|
+
tertiary: {
|
|
142
|
+
open: wrapFn()(convertFn(theme.text.banner.command.tertiary)),
|
|
143
|
+
close: wrapAnsi16()(39)
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
description: {
|
|
147
|
+
primary: {
|
|
148
|
+
open: wrapFn()(convertFn(theme.text.banner.description.primary)),
|
|
149
|
+
close: wrapAnsi16()(39)
|
|
150
|
+
},
|
|
151
|
+
secondary: {
|
|
152
|
+
open: wrapFn()(convertFn(theme.text.banner.description.secondary)),
|
|
153
|
+
close: wrapAnsi16()(39)
|
|
154
|
+
},
|
|
155
|
+
tertiary: {
|
|
156
|
+
open: wrapFn()(convertFn(theme.text.banner.description.tertiary)),
|
|
157
|
+
close: wrapAnsi16()(39)
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
header: {
|
|
161
|
+
primary: {
|
|
162
|
+
open: wrapFn()(convertFn(theme.text.banner.header.primary)),
|
|
163
|
+
close: wrapAnsi16()(39)
|
|
164
|
+
},
|
|
165
|
+
secondary: {
|
|
166
|
+
open: wrapFn()(convertFn(theme.text.banner.header.secondary)),
|
|
167
|
+
close: wrapAnsi16()(39)
|
|
168
|
+
},
|
|
169
|
+
tertiary: {
|
|
170
|
+
open: wrapFn()(convertFn(theme.text.banner.header.tertiary)),
|
|
171
|
+
close: wrapAnsi16()(39)
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
footer: {
|
|
175
|
+
primary: {
|
|
176
|
+
open: wrapFn()(convertFn(theme.text.banner.footer.primary)),
|
|
177
|
+
close: wrapAnsi16()(39)
|
|
178
|
+
},
|
|
179
|
+
secondary: {
|
|
180
|
+
open: wrapFn()(convertFn(theme.text.banner.footer.secondary)),
|
|
181
|
+
close: wrapAnsi16()(39)
|
|
182
|
+
},
|
|
183
|
+
tertiary: {
|
|
184
|
+
open: wrapFn()(convertFn(theme.text.banner.footer.tertiary)),
|
|
185
|
+
close: wrapAnsi16()(39)
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
link: {
|
|
189
|
+
primary: {
|
|
190
|
+
open: wrapFn()(convertFn(theme.text.banner.link.primary)),
|
|
191
|
+
close: wrapAnsi16()(39)
|
|
192
|
+
},
|
|
193
|
+
secondary: {
|
|
194
|
+
open: wrapFn()(convertFn(theme.text.banner.link.secondary)),
|
|
195
|
+
close: wrapAnsi16()(39)
|
|
196
|
+
},
|
|
197
|
+
tertiary: {
|
|
198
|
+
open: wrapFn()(convertFn(theme.text.banner.link.tertiary)),
|
|
199
|
+
close: wrapAnsi16()(39)
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
heading: {
|
|
204
|
+
primary: {
|
|
205
|
+
open: wrapFn()(convertFn(theme.text.heading.primary)),
|
|
206
|
+
close: wrapAnsi16()(39)
|
|
207
|
+
},
|
|
208
|
+
secondary: {
|
|
209
|
+
open: wrapFn()(convertFn(theme.text.heading.secondary)),
|
|
210
|
+
close: wrapAnsi16()(39)
|
|
211
|
+
},
|
|
212
|
+
tertiary: {
|
|
213
|
+
open: wrapFn()(convertFn(theme.text.heading.tertiary)),
|
|
214
|
+
close: wrapAnsi16()(39)
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
body: {
|
|
218
|
+
primary: {
|
|
219
|
+
open: wrapFn()(convertFn(theme.text.body.primary)),
|
|
220
|
+
close: wrapAnsi16()(39)
|
|
221
|
+
},
|
|
222
|
+
secondary: {
|
|
223
|
+
open: wrapFn()(convertFn(theme.text.body.secondary)),
|
|
224
|
+
close: wrapAnsi16()(39)
|
|
225
|
+
},
|
|
226
|
+
tertiary: {
|
|
227
|
+
open: wrapFn()(convertFn(theme.text.body.tertiary)),
|
|
228
|
+
close: wrapAnsi16()(39)
|
|
229
|
+
},
|
|
230
|
+
link: {
|
|
231
|
+
open: wrapFn()(convertFn(theme.text.body.link)),
|
|
232
|
+
close: wrapAnsi16()(39)
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
message: {
|
|
236
|
+
description: {
|
|
237
|
+
help: {
|
|
238
|
+
open: wrapFn()(convertFn(theme.text.message.description.help)),
|
|
239
|
+
close: wrapAnsi16()(39)
|
|
240
|
+
},
|
|
241
|
+
success: {
|
|
242
|
+
open: wrapFn()(convertFn(theme.text.message.description.success)),
|
|
243
|
+
close: wrapAnsi16()(39)
|
|
244
|
+
},
|
|
245
|
+
info: {
|
|
246
|
+
open: wrapFn()(convertFn(theme.text.message.description.info)),
|
|
247
|
+
close: wrapAnsi16()(39)
|
|
248
|
+
},
|
|
249
|
+
debug: {
|
|
250
|
+
open: wrapFn()(convertFn(theme.text.message.description.debug)),
|
|
251
|
+
close: wrapAnsi16()(39)
|
|
252
|
+
},
|
|
253
|
+
warning: {
|
|
254
|
+
open: wrapFn()(convertFn(theme.text.message.description.warning)),
|
|
255
|
+
close: wrapAnsi16()(39)
|
|
256
|
+
},
|
|
257
|
+
danger: {
|
|
258
|
+
open: wrapFn()(convertFn(theme.text.message.description.danger)),
|
|
259
|
+
close: wrapAnsi16()(39)
|
|
260
|
+
},
|
|
261
|
+
error: {
|
|
262
|
+
open: wrapFn()(convertFn(theme.text.message.description.error)),
|
|
263
|
+
close: wrapAnsi16()(39)
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
link: {
|
|
267
|
+
help: {
|
|
268
|
+
open: wrapFn()(convertFn(theme.text.message.link.help)),
|
|
269
|
+
close: wrapAnsi16()(39)
|
|
270
|
+
},
|
|
271
|
+
success: {
|
|
272
|
+
open: wrapFn()(convertFn(theme.text.message.link.success)),
|
|
273
|
+
close: wrapAnsi16()(39)
|
|
274
|
+
},
|
|
275
|
+
info: {
|
|
276
|
+
open: wrapFn()(convertFn(theme.text.message.link.info)),
|
|
277
|
+
close: wrapAnsi16()(39)
|
|
278
|
+
},
|
|
279
|
+
debug: {
|
|
280
|
+
open: wrapFn()(convertFn(theme.text.message.link.debug)),
|
|
281
|
+
close: wrapAnsi16()(39)
|
|
282
|
+
},
|
|
283
|
+
warning: {
|
|
284
|
+
open: wrapFn()(convertFn(theme.text.message.link.warning)),
|
|
285
|
+
close: wrapAnsi16()(39)
|
|
286
|
+
},
|
|
287
|
+
danger: {
|
|
288
|
+
open: wrapFn()(convertFn(theme.text.message.link.danger)),
|
|
289
|
+
close: wrapAnsi16()(39)
|
|
290
|
+
},
|
|
291
|
+
error: {
|
|
292
|
+
open: wrapFn()(convertFn(theme.text.message.link.error)),
|
|
293
|
+
close: wrapAnsi16()(39)
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
header: {
|
|
297
|
+
help: {
|
|
298
|
+
open: wrapFn()(convertFn(theme.text.message.header.help)),
|
|
299
|
+
close: wrapAnsi16()(39)
|
|
300
|
+
},
|
|
301
|
+
success: {
|
|
302
|
+
open: wrapFn()(convertFn(theme.text.message.header.success)),
|
|
303
|
+
close: wrapAnsi16()(39)
|
|
304
|
+
},
|
|
305
|
+
info: {
|
|
306
|
+
open: wrapFn()(convertFn(theme.text.message.header.info)),
|
|
307
|
+
close: wrapAnsi16()(39)
|
|
308
|
+
},
|
|
309
|
+
debug: {
|
|
310
|
+
open: wrapFn()(convertFn(theme.text.message.header.debug)),
|
|
311
|
+
close: wrapAnsi16()(39)
|
|
312
|
+
},
|
|
313
|
+
warning: {
|
|
314
|
+
open: wrapFn()(convertFn(theme.text.message.header.warning)),
|
|
315
|
+
close: wrapAnsi16()(39)
|
|
316
|
+
},
|
|
317
|
+
danger: {
|
|
318
|
+
open: wrapFn()(convertFn(theme.text.message.header.danger)),
|
|
319
|
+
close: wrapAnsi16()(39)
|
|
320
|
+
},
|
|
321
|
+
error: {
|
|
322
|
+
open: wrapFn()(convertFn(theme.text.message.header.error)),
|
|
323
|
+
close: wrapAnsi16()(39)
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
footer: {
|
|
327
|
+
help: {
|
|
328
|
+
open: wrapFn()(convertFn(theme.text.message.footer.help)),
|
|
329
|
+
close: wrapAnsi16()(39)
|
|
330
|
+
},
|
|
331
|
+
success: {
|
|
332
|
+
open: wrapFn()(convertFn(theme.text.message.footer.success)),
|
|
333
|
+
close: wrapAnsi16()(39)
|
|
334
|
+
},
|
|
335
|
+
info: {
|
|
336
|
+
open: wrapFn()(convertFn(theme.text.message.footer.info)),
|
|
337
|
+
close: wrapAnsi16()(39)
|
|
338
|
+
},
|
|
339
|
+
debug: {
|
|
340
|
+
open: wrapFn()(convertFn(theme.text.message.footer.debug)),
|
|
341
|
+
close: wrapAnsi16()(39)
|
|
342
|
+
},
|
|
343
|
+
warning: {
|
|
344
|
+
open: wrapFn()(convertFn(theme.text.message.footer.warning)),
|
|
345
|
+
close: wrapAnsi16()(39)
|
|
346
|
+
},
|
|
347
|
+
danger: {
|
|
348
|
+
open: wrapFn()(convertFn(theme.text.message.footer.danger)),
|
|
349
|
+
close: wrapAnsi16()(39)
|
|
350
|
+
},
|
|
351
|
+
error: {
|
|
352
|
+
open: wrapFn()(convertFn(theme.text.message.footer.error)),
|
|
353
|
+
close: wrapAnsi16()(39)
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
usage: {
|
|
358
|
+
bin: {
|
|
359
|
+
open: wrapFn()(convertFn(theme.text.usage.bin)),
|
|
360
|
+
close: wrapAnsi16()(39)
|
|
361
|
+
},
|
|
362
|
+
command: {
|
|
363
|
+
open: wrapFn()(convertFn(theme.text.usage.command)),
|
|
364
|
+
close: wrapAnsi16()(39)
|
|
365
|
+
},
|
|
366
|
+
dynamic: {
|
|
367
|
+
open: wrapFn()(convertFn(theme.text.usage.dynamic)),
|
|
368
|
+
close: wrapAnsi16()(39)
|
|
369
|
+
},
|
|
370
|
+
options: {
|
|
371
|
+
open: wrapFn()(convertFn(theme.text.usage.options)),
|
|
372
|
+
close: wrapAnsi16()(39)
|
|
373
|
+
},
|
|
374
|
+
arguments: {
|
|
375
|
+
open: wrapFn()(convertFn(theme.text.usage.arguments)),
|
|
376
|
+
close: wrapAnsi16()(39)
|
|
377
|
+
},
|
|
378
|
+
description: {
|
|
379
|
+
open: wrapFn()(convertFn(theme.text.usage.description)),
|
|
380
|
+
close: wrapAnsi16()(39)
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
prompt: {
|
|
384
|
+
icon: {
|
|
385
|
+
active: {
|
|
386
|
+
open: wrapFn()(convertFn(theme.text.prompt.icon.active)),
|
|
387
|
+
close: wrapAnsi16()(39)
|
|
388
|
+
},
|
|
389
|
+
warning: {
|
|
390
|
+
open: wrapFn()(convertFn(theme.text.prompt.icon.warning)),
|
|
391
|
+
close: wrapAnsi16()(39)
|
|
392
|
+
},
|
|
393
|
+
error: {
|
|
394
|
+
open: wrapFn()(convertFn(theme.text.prompt.icon.error)),
|
|
395
|
+
close: wrapAnsi16()(39)
|
|
396
|
+
},
|
|
397
|
+
submitted: {
|
|
398
|
+
open: wrapFn()(convertFn(theme.text.prompt.icon.submitted)),
|
|
399
|
+
close: wrapAnsi16()(39)
|
|
400
|
+
},
|
|
401
|
+
cancelled: {
|
|
402
|
+
open: wrapFn()(convertFn(theme.text.prompt.icon.cancelled)),
|
|
403
|
+
close: wrapAnsi16()(39)
|
|
404
|
+
},
|
|
405
|
+
disabled: {
|
|
406
|
+
open: wrapFn()(convertFn(theme.text.prompt.icon.disabled)),
|
|
407
|
+
close: wrapAnsi16()(39)
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
message: {
|
|
411
|
+
active: {
|
|
412
|
+
open: wrapFn()(convertFn(theme.text.prompt.message.active)),
|
|
413
|
+
close: wrapAnsi16()(39)
|
|
414
|
+
},
|
|
415
|
+
warning: {
|
|
416
|
+
open: wrapFn()(convertFn(theme.text.prompt.message.warning)),
|
|
417
|
+
close: wrapAnsi16()(39)
|
|
418
|
+
},
|
|
419
|
+
error: {
|
|
420
|
+
open: wrapFn()(convertFn(theme.text.prompt.message.error)),
|
|
421
|
+
close: wrapAnsi16()(39)
|
|
422
|
+
},
|
|
423
|
+
submitted: {
|
|
424
|
+
open: wrapFn()(convertFn(theme.text.prompt.message.submitted)),
|
|
425
|
+
close: wrapAnsi16()(39)
|
|
426
|
+
},
|
|
427
|
+
cancelled: {
|
|
428
|
+
open: wrapFn()(convertFn(theme.text.prompt.message.cancelled)),
|
|
429
|
+
close: wrapAnsi16()(39)
|
|
430
|
+
},
|
|
431
|
+
disabled: {
|
|
432
|
+
open: wrapFn()(convertFn(theme.text.prompt.message.disabled)),
|
|
433
|
+
close: wrapAnsi16()(39)
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
input: {
|
|
437
|
+
active: {
|
|
438
|
+
open: wrapFn()(convertFn(theme.text.prompt.input.active)),
|
|
439
|
+
close: wrapAnsi16()(39)
|
|
440
|
+
},
|
|
441
|
+
inactive: {
|
|
442
|
+
open: wrapFn()(convertFn(theme.text.prompt.input.inactive)),
|
|
443
|
+
close: wrapAnsi16()(39)
|
|
444
|
+
},
|
|
445
|
+
warning: {
|
|
446
|
+
open: wrapFn()(convertFn(theme.text.prompt.input.warning)),
|
|
447
|
+
close: wrapAnsi16()(39)
|
|
448
|
+
},
|
|
449
|
+
error: {
|
|
450
|
+
open: wrapFn()(convertFn(theme.text.prompt.input.error)),
|
|
451
|
+
close: wrapAnsi16()(39)
|
|
452
|
+
},
|
|
453
|
+
submitted: {
|
|
454
|
+
open: wrapFn()(convertFn(theme.text.prompt.input.submitted)),
|
|
455
|
+
close: wrapAnsi16()(39)
|
|
456
|
+
},
|
|
457
|
+
cancelled: {
|
|
458
|
+
open: wrapFn()(convertFn(theme.text.prompt.input.cancelled)),
|
|
459
|
+
close: wrapAnsi16()(39)
|
|
460
|
+
},
|
|
461
|
+
disabled: {
|
|
462
|
+
open: wrapFn()(convertFn(theme.text.prompt.input.disabled)),
|
|
463
|
+
close: wrapAnsi16()(39)
|
|
464
|
+
},
|
|
465
|
+
placeholder: {
|
|
466
|
+
open: wrapFn()(convertFn(theme.text.prompt.input.placeholder)),
|
|
467
|
+
close: wrapAnsi16()(39)
|
|
468
|
+
}
|
|
469
|
+
},
|
|
470
|
+
description: {
|
|
471
|
+
active: {
|
|
472
|
+
open: wrapFn()(convertFn(theme.text.prompt.description.active)),
|
|
473
|
+
close: wrapAnsi16()(39)
|
|
474
|
+
},
|
|
475
|
+
inactive: {
|
|
476
|
+
open: wrapFn()(convertFn(theme.text.prompt.description.inactive)),
|
|
477
|
+
close: wrapAnsi16()(39)
|
|
478
|
+
},
|
|
479
|
+
warning: {
|
|
480
|
+
open: wrapFn()(convertFn(theme.text.prompt.description.warning)),
|
|
481
|
+
close: wrapAnsi16()(39)
|
|
482
|
+
},
|
|
483
|
+
error: {
|
|
484
|
+
open: wrapFn()(convertFn(theme.text.prompt.description.error)),
|
|
485
|
+
close: wrapAnsi16()(39)
|
|
486
|
+
},
|
|
487
|
+
submitted: {
|
|
488
|
+
open: wrapFn()(convertFn(theme.text.prompt.description.submitted)),
|
|
489
|
+
close: wrapAnsi16()(39)
|
|
490
|
+
},
|
|
491
|
+
cancelled: {
|
|
492
|
+
open: wrapFn()(convertFn(theme.text.prompt.description.cancelled)),
|
|
493
|
+
close: wrapAnsi16()(39)
|
|
494
|
+
},
|
|
495
|
+
disabled: {
|
|
496
|
+
open: wrapFn()(convertFn(theme.text.prompt.description.disabled)),
|
|
497
|
+
close: wrapAnsi16()(39)
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
},
|
|
502
|
+
border: {
|
|
503
|
+
banner: {
|
|
504
|
+
divider: {
|
|
505
|
+
primary: {
|
|
506
|
+
open: wrapFn()(convertFn(theme.border.banner.divider.primary)),
|
|
507
|
+
close: wrapAnsi16()(39)
|
|
508
|
+
},
|
|
509
|
+
secondary: {
|
|
510
|
+
open: wrapFn()(convertFn(theme.border.banner.divider.secondary)),
|
|
511
|
+
close: wrapAnsi16()(39)
|
|
512
|
+
},
|
|
513
|
+
tertiary: {
|
|
514
|
+
open: wrapFn()(convertFn(theme.border.banner.divider.tertiary)),
|
|
515
|
+
close: wrapAnsi16()(39)
|
|
516
|
+
}
|
|
517
|
+
},
|
|
518
|
+
outline: {
|
|
519
|
+
primary: {
|
|
520
|
+
open: wrapFn()(convertFn(theme.border.banner.outline.primary)),
|
|
521
|
+
close: wrapAnsi16()(39)
|
|
522
|
+
},
|
|
523
|
+
secondary: {
|
|
524
|
+
open: wrapFn()(convertFn(theme.border.banner.outline.secondary)),
|
|
525
|
+
close: wrapAnsi16()(39)
|
|
526
|
+
},
|
|
527
|
+
tertiary: {
|
|
528
|
+
open: wrapFn()(convertFn(theme.border.banner.outline.tertiary)),
|
|
529
|
+
close: wrapAnsi16()(39)
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
},
|
|
533
|
+
app: {
|
|
534
|
+
divider: {
|
|
535
|
+
primary: {
|
|
536
|
+
open: wrapFn()(convertFn(theme.border.app.divider.primary)),
|
|
537
|
+
close: wrapAnsi16()(39)
|
|
538
|
+
},
|
|
539
|
+
secondary: {
|
|
540
|
+
open: wrapFn()(convertFn(theme.border.app.divider.secondary)),
|
|
541
|
+
close: wrapAnsi16()(39)
|
|
542
|
+
},
|
|
543
|
+
tertiary: {
|
|
544
|
+
open: wrapFn()(convertFn(theme.border.app.divider.tertiary)),
|
|
545
|
+
close: wrapAnsi16()(39)
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
|
+
table: {
|
|
549
|
+
primary: {
|
|
550
|
+
open: wrapFn()(convertFn(theme.border.app.table.primary)),
|
|
551
|
+
close: wrapAnsi16()(39)
|
|
552
|
+
},
|
|
553
|
+
secondary: {
|
|
554
|
+
open: wrapFn()(convertFn(theme.border.app.table.secondary)),
|
|
555
|
+
close: wrapAnsi16()(39)
|
|
556
|
+
},
|
|
557
|
+
tertiary: {
|
|
558
|
+
open: wrapFn()(convertFn(theme.border.app.table.tertiary)),
|
|
559
|
+
close: wrapAnsi16()(39)
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
},
|
|
563
|
+
message: {
|
|
564
|
+
divider: {
|
|
565
|
+
help: {
|
|
566
|
+
open: wrapFn()(convertFn(theme.border.message.divider.help)),
|
|
567
|
+
close: wrapAnsi16()(39)
|
|
568
|
+
},
|
|
569
|
+
success: {
|
|
570
|
+
open: wrapFn()(convertFn(theme.border.message.divider.success)),
|
|
571
|
+
close: wrapAnsi16()(39)
|
|
572
|
+
},
|
|
573
|
+
info: {
|
|
574
|
+
open: wrapFn()(convertFn(theme.border.message.divider.info)),
|
|
575
|
+
close: wrapAnsi16()(39)
|
|
576
|
+
},
|
|
577
|
+
debug: {
|
|
578
|
+
open: wrapFn()(convertFn(theme.border.message.divider.debug)),
|
|
579
|
+
close: wrapAnsi16()(39)
|
|
580
|
+
},
|
|
581
|
+
warning: {
|
|
582
|
+
open: wrapFn()(convertFn(theme.border.message.divider.warning)),
|
|
583
|
+
close: wrapAnsi16()(39)
|
|
584
|
+
},
|
|
585
|
+
danger: {
|
|
586
|
+
open: wrapFn()(convertFn(theme.border.message.divider.danger)),
|
|
587
|
+
close: wrapAnsi16()(39)
|
|
588
|
+
},
|
|
589
|
+
error: {
|
|
590
|
+
open: wrapFn()(convertFn(theme.border.message.divider.error)),
|
|
591
|
+
close: wrapAnsi16()(39)
|
|
592
|
+
}
|
|
593
|
+
},
|
|
594
|
+
outline: {
|
|
595
|
+
help: {
|
|
596
|
+
open: wrapFn()(convertFn(theme.border.message.outline.help)),
|
|
597
|
+
close: wrapAnsi16()(39)
|
|
598
|
+
},
|
|
599
|
+
success: {
|
|
600
|
+
open: wrapFn()(convertFn(theme.border.message.outline.success)),
|
|
601
|
+
close: wrapAnsi16()(39)
|
|
602
|
+
},
|
|
603
|
+
info: {
|
|
604
|
+
open: wrapFn()(convertFn(theme.border.message.outline.info)),
|
|
605
|
+
close: wrapAnsi16()(39)
|
|
606
|
+
},
|
|
607
|
+
debug: {
|
|
608
|
+
open: wrapFn()(convertFn(theme.border.message.outline.debug)),
|
|
609
|
+
close: wrapAnsi16()(39)
|
|
610
|
+
},
|
|
611
|
+
warning: {
|
|
612
|
+
open: wrapFn()(convertFn(theme.border.message.outline.warning)),
|
|
613
|
+
close: wrapAnsi16()(39)
|
|
614
|
+
},
|
|
615
|
+
danger: {
|
|
616
|
+
open: wrapFn()(convertFn(theme.border.message.outline.danger)),
|
|
617
|
+
close: wrapAnsi16()(39)
|
|
618
|
+
},
|
|
619
|
+
error: {
|
|
620
|
+
open: wrapFn()(convertFn(theme.border.message.outline.error)),
|
|
621
|
+
close: wrapAnsi16()(39)
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Generates ANSI styles based on the provided context.
|
|
630
|
+
*
|
|
631
|
+
* @param theme - The theme colors configuration.
|
|
632
|
+
* @returns The generated ANSI styles.
|
|
633
|
+
*/
|
|
634
|
+
function getAnsiStyles(theme) {
|
|
635
|
+
const output = {
|
|
636
|
+
ansi16: {},
|
|
637
|
+
ansi256: {},
|
|
638
|
+
ansi16m: {}
|
|
639
|
+
};
|
|
640
|
+
for (const [key, value] of Object.entries(modifiers)) {
|
|
641
|
+
output.ansi16[key] = {
|
|
642
|
+
open: wrapAnsi16()(value[0]),
|
|
643
|
+
close: wrapAnsi16()(value[1])
|
|
644
|
+
};
|
|
645
|
+
output.ansi256[key] = {
|
|
646
|
+
open: wrapAnsi16()(value[0]),
|
|
647
|
+
close: wrapAnsi16()(value[1])
|
|
648
|
+
};
|
|
649
|
+
output.ansi16m[key] = {
|
|
650
|
+
open: wrapAnsi16()(value[0]),
|
|
651
|
+
close: wrapAnsi16()(value[1])
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
for (const [key, value] of Object.entries(colors)) {
|
|
655
|
+
output.ansi16[key] = {
|
|
656
|
+
open: wrapAnsi16()(value[0]),
|
|
657
|
+
close: wrapAnsi16()(value[1])
|
|
658
|
+
};
|
|
659
|
+
output.ansi256[key] = {
|
|
660
|
+
open: wrapAnsi16()(value[0]),
|
|
661
|
+
close: wrapAnsi16()(value[1])
|
|
662
|
+
};
|
|
663
|
+
output.ansi16m[key] = {
|
|
664
|
+
open: wrapAnsi16()(value[0]),
|
|
665
|
+
close: wrapAnsi16()(value[1])
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
for (const [key, value] of Object.entries(bgColors)) {
|
|
669
|
+
output.ansi16[key] = {
|
|
670
|
+
open: wrapAnsi16(ANSI_BACKGROUND_OFFSET)(value[0]),
|
|
671
|
+
close: wrapAnsi16(ANSI_BACKGROUND_OFFSET)(value[1])
|
|
672
|
+
};
|
|
673
|
+
output.ansi256[key] = {
|
|
674
|
+
open: wrapAnsi16(ANSI_BACKGROUND_OFFSET)(value[0]),
|
|
675
|
+
close: wrapAnsi16(ANSI_BACKGROUND_OFFSET)(value[1])
|
|
676
|
+
};
|
|
677
|
+
output.ansi16m[key] = {
|
|
678
|
+
open: wrapAnsi16(ANSI_BACKGROUND_OFFSET)(value[0]),
|
|
679
|
+
close: wrapAnsi16(ANSI_BACKGROUND_OFFSET)(value[1])
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
output.ansi16.theme = buildThemeAnsiStyles(theme, wrapAnsi16, hexToAnsi);
|
|
683
|
+
output.ansi256.theme = buildThemeAnsiStyles(theme, wrapAnsi256, hexToAnsi256);
|
|
684
|
+
output.ansi16m.theme = buildThemeAnsiStyles(theme, wrapAnsi16m, (code) => code);
|
|
685
|
+
return output;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
//#endregion
|
|
689
|
+
exports.bgColors = bgColors;
|
|
690
|
+
exports.colors = colors;
|
|
691
|
+
exports.getAnsiStyles = getAnsiStyles;
|
|
692
|
+
exports.modifiers = modifiers;
|