@crustjs/style 0.0.3 → 0.0.4
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/index.js +9 -898
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,899 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// src/ansiCodes.ts
|
|
14
|
-
var exports_ansiCodes = {};
|
|
15
|
-
__export(exports_ansiCodes, {
|
|
16
|
-
yellow: () => yellow,
|
|
17
|
-
white: () => white,
|
|
18
|
-
underline: () => underline,
|
|
19
|
-
strikethrough: () => strikethrough,
|
|
20
|
-
reset: () => reset,
|
|
21
|
-
red: () => red,
|
|
22
|
-
magenta: () => magenta,
|
|
23
|
-
italic: () => italic,
|
|
24
|
-
inverse: () => inverse,
|
|
25
|
-
hidden: () => hidden,
|
|
26
|
-
green: () => green,
|
|
27
|
-
gray: () => gray,
|
|
28
|
-
dim: () => dim,
|
|
29
|
-
cyan: () => cyan,
|
|
30
|
-
brightYellow: () => brightYellow,
|
|
31
|
-
brightWhite: () => brightWhite,
|
|
32
|
-
brightRed: () => brightRed,
|
|
33
|
-
brightMagenta: () => brightMagenta,
|
|
34
|
-
brightGreen: () => brightGreen,
|
|
35
|
-
brightCyan: () => brightCyan,
|
|
36
|
-
brightBlue: () => brightBlue,
|
|
37
|
-
bold: () => bold,
|
|
38
|
-
blue: () => blue,
|
|
39
|
-
black: () => black,
|
|
40
|
-
bgYellow: () => bgYellow,
|
|
41
|
-
bgWhite: () => bgWhite,
|
|
42
|
-
bgRed: () => bgRed,
|
|
43
|
-
bgMagenta: () => bgMagenta,
|
|
44
|
-
bgGreen: () => bgGreen,
|
|
45
|
-
bgCyan: () => bgCyan,
|
|
46
|
-
bgBrightYellow: () => bgBrightYellow,
|
|
47
|
-
bgBrightWhite: () => bgBrightWhite,
|
|
48
|
-
bgBrightRed: () => bgBrightRed,
|
|
49
|
-
bgBrightMagenta: () => bgBrightMagenta,
|
|
50
|
-
bgBrightGreen: () => bgBrightGreen,
|
|
51
|
-
bgBrightCyan: () => bgBrightCyan,
|
|
52
|
-
bgBrightBlue: () => bgBrightBlue,
|
|
53
|
-
bgBrightBlack: () => bgBrightBlack,
|
|
54
|
-
bgBlue: () => bgBlue,
|
|
55
|
-
bgBlack: () => bgBlack
|
|
56
|
-
});
|
|
57
|
-
function pair(open, close) {
|
|
58
|
-
return { open: `\x1B[${open}m`, close: `\x1B[${close}m` };
|
|
59
|
-
}
|
|
60
|
-
var reset = pair(0, 0);
|
|
61
|
-
var bold = pair(1, 22);
|
|
62
|
-
var dim = pair(2, 22);
|
|
63
|
-
var italic = pair(3, 23);
|
|
64
|
-
var underline = pair(4, 24);
|
|
65
|
-
var inverse = pair(7, 27);
|
|
66
|
-
var hidden = pair(8, 28);
|
|
67
|
-
var strikethrough = pair(9, 29);
|
|
68
|
-
var black = pair(30, 39);
|
|
69
|
-
var red = pair(31, 39);
|
|
70
|
-
var green = pair(32, 39);
|
|
71
|
-
var yellow = pair(33, 39);
|
|
72
|
-
var blue = pair(34, 39);
|
|
73
|
-
var magenta = pair(35, 39);
|
|
74
|
-
var cyan = pair(36, 39);
|
|
75
|
-
var white = pair(37, 39);
|
|
76
|
-
var gray = pair(90, 39);
|
|
77
|
-
var brightRed = pair(91, 39);
|
|
78
|
-
var brightGreen = pair(92, 39);
|
|
79
|
-
var brightYellow = pair(93, 39);
|
|
80
|
-
var brightBlue = pair(94, 39);
|
|
81
|
-
var brightMagenta = pair(95, 39);
|
|
82
|
-
var brightCyan = pair(96, 39);
|
|
83
|
-
var brightWhite = pair(97, 39);
|
|
84
|
-
var bgBlack = pair(40, 49);
|
|
85
|
-
var bgRed = pair(41, 49);
|
|
86
|
-
var bgGreen = pair(42, 49);
|
|
87
|
-
var bgYellow = pair(43, 49);
|
|
88
|
-
var bgBlue = pair(44, 49);
|
|
89
|
-
var bgMagenta = pair(45, 49);
|
|
90
|
-
var bgCyan = pair(46, 49);
|
|
91
|
-
var bgWhite = pair(47, 49);
|
|
92
|
-
var bgBrightBlack = pair(100, 49);
|
|
93
|
-
var bgBrightRed = pair(101, 49);
|
|
94
|
-
var bgBrightGreen = pair(102, 49);
|
|
95
|
-
var bgBrightYellow = pair(103, 49);
|
|
96
|
-
var bgBrightBlue = pair(104, 49);
|
|
97
|
-
var bgBrightMagenta = pair(105, 49);
|
|
98
|
-
var bgBrightCyan = pair(106, 49);
|
|
99
|
-
var bgBrightWhite = pair(107, 49);
|
|
100
|
-
// src/text/stripAnsi.ts
|
|
101
|
-
var ANSI_REGEX = /[\x1b\x9b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]/g;
|
|
102
|
-
function stripAnsi(text) {
|
|
103
|
-
return text.replace(ANSI_REGEX, "");
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// src/text/width.ts
|
|
107
|
-
function isFullWidth(codePoint) {
|
|
108
|
-
return codePoint >= 19968 && codePoint <= 40959 || codePoint >= 13312 && codePoint <= 19903 || codePoint >= 131072 && codePoint <= 173791 || codePoint >= 63744 && codePoint <= 64255 || codePoint >= 65281 && codePoint <= 65376 || codePoint >= 65504 && codePoint <= 65510 || codePoint >= 11904 && codePoint <= 12031 || codePoint >= 12032 && codePoint <= 12255 || codePoint >= 12288 && codePoint <= 12351 || codePoint >= 12352 && codePoint <= 12447 || codePoint >= 12448 && codePoint <= 12543 || codePoint >= 12544 && codePoint <= 12591 || codePoint >= 12592 && codePoint <= 12687 || codePoint >= 12800 && codePoint <= 13055 || codePoint >= 13056 && codePoint <= 13311 || codePoint >= 44032 && codePoint <= 55215 || codePoint >= 65072 && codePoint <= 65103;
|
|
109
|
-
}
|
|
110
|
-
function visibleWidth(text) {
|
|
111
|
-
const plain = stripAnsi(text);
|
|
112
|
-
let width = 0;
|
|
113
|
-
for (const char of plain) {
|
|
114
|
-
const codePoint = char.codePointAt(0);
|
|
115
|
-
if (codePoint === undefined) {
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
width += isFullWidth(codePoint) ? 2 : 1;
|
|
119
|
-
}
|
|
120
|
-
return width;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// src/blocks/lists.ts
|
|
124
|
-
function indentMultiline(text, contentIndent) {
|
|
125
|
-
const lines = text.split(`
|
|
126
|
-
`);
|
|
127
|
-
if (lines.length <= 1) {
|
|
128
|
-
return text;
|
|
129
|
-
}
|
|
130
|
-
const padding = " ".repeat(contentIndent);
|
|
131
|
-
return lines.map((line, idx) => idx === 0 ? line : padding + line).join(`
|
|
132
|
-
`);
|
|
133
|
-
}
|
|
134
|
-
function unorderedList(items, options) {
|
|
135
|
-
const marker = options?.marker ?? "\u2022";
|
|
136
|
-
const markerGap = options?.markerGap ?? 1;
|
|
137
|
-
const indent = options?.indent ?? 0;
|
|
138
|
-
const prefix = " ".repeat(indent);
|
|
139
|
-
const gap = " ".repeat(markerGap);
|
|
140
|
-
const markerWidth = visibleWidth(marker);
|
|
141
|
-
const contentIndent = indent + markerWidth + markerGap;
|
|
142
|
-
return items.map((item) => {
|
|
143
|
-
const adjusted = indentMultiline(item, contentIndent);
|
|
144
|
-
return `${prefix}${marker}${gap}${adjusted}`;
|
|
145
|
-
}).join(`
|
|
146
|
-
`);
|
|
147
|
-
}
|
|
148
|
-
function orderedList(items, options) {
|
|
149
|
-
const start = options?.start ?? 1;
|
|
150
|
-
const markerGap = options?.markerGap ?? 1;
|
|
151
|
-
const indent = options?.indent ?? 0;
|
|
152
|
-
if (items.length === 0) {
|
|
153
|
-
return "";
|
|
154
|
-
}
|
|
155
|
-
const prefix = " ".repeat(indent);
|
|
156
|
-
const gap = " ".repeat(markerGap);
|
|
157
|
-
const lastIndex = start + items.length - 1;
|
|
158
|
-
const maxMarkerWidth = `${lastIndex}.`.length;
|
|
159
|
-
return items.map((item, idx) => {
|
|
160
|
-
const index = start + idx;
|
|
161
|
-
const markerText = `${index}.`;
|
|
162
|
-
const paddedMarker = markerText.padStart(maxMarkerWidth, " ");
|
|
163
|
-
const contentIndent = indent + maxMarkerWidth + markerGap;
|
|
164
|
-
const adjusted = indentMultiline(item, contentIndent);
|
|
165
|
-
return `${prefix}${paddedMarker}${gap}${adjusted}`;
|
|
166
|
-
}).join(`
|
|
167
|
-
`);
|
|
168
|
-
}
|
|
169
|
-
function taskList(items, options) {
|
|
170
|
-
const checkedMarker = options?.checkedMarker ?? "[x]";
|
|
171
|
-
const uncheckedMarker = options?.uncheckedMarker ?? "[ ]";
|
|
172
|
-
const markerGap = options?.markerGap ?? 1;
|
|
173
|
-
const indent = options?.indent ?? 0;
|
|
174
|
-
const prefix = " ".repeat(indent);
|
|
175
|
-
const gap = " ".repeat(markerGap);
|
|
176
|
-
const markerWidth = Math.max(visibleWidth(checkedMarker), visibleWidth(uncheckedMarker));
|
|
177
|
-
const contentIndent = indent + markerWidth + markerGap;
|
|
178
|
-
return items.map((item) => {
|
|
179
|
-
const marker = item.checked ? checkedMarker : uncheckedMarker;
|
|
180
|
-
const adjusted = indentMultiline(item.text, contentIndent);
|
|
181
|
-
return `${prefix}${marker}${gap}${adjusted}`;
|
|
182
|
-
}).join(`
|
|
183
|
-
`);
|
|
184
|
-
}
|
|
185
|
-
// src/text/pad.ts
|
|
186
|
-
function padStart(text, width, fillChar = " ") {
|
|
187
|
-
const currentWidth = visibleWidth(text);
|
|
188
|
-
if (currentWidth >= width) {
|
|
189
|
-
return text;
|
|
190
|
-
}
|
|
191
|
-
const padding = fillChar.repeat(width - currentWidth);
|
|
192
|
-
return padding + text;
|
|
193
|
-
}
|
|
194
|
-
function padEnd(text, width, fillChar = " ") {
|
|
195
|
-
const currentWidth = visibleWidth(text);
|
|
196
|
-
if (currentWidth >= width) {
|
|
197
|
-
return text;
|
|
198
|
-
}
|
|
199
|
-
const padding = fillChar.repeat(width - currentWidth);
|
|
200
|
-
return text + padding;
|
|
201
|
-
}
|
|
202
|
-
function center(text, width, fillChar = " ") {
|
|
203
|
-
const currentWidth = visibleWidth(text);
|
|
204
|
-
if (currentWidth >= width) {
|
|
205
|
-
return text;
|
|
206
|
-
}
|
|
207
|
-
const totalPadding = width - currentWidth;
|
|
208
|
-
const leftPadding = Math.floor(totalPadding / 2);
|
|
209
|
-
const rightPadding = totalPadding - leftPadding;
|
|
210
|
-
return fillChar.repeat(leftPadding) + text + fillChar.repeat(rightPadding);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// src/blocks/tables.ts
|
|
214
|
-
function computeColumnWidths(headers, rows, minWidth) {
|
|
215
|
-
const columnCount = headers.length;
|
|
216
|
-
const widths = new Array(columnCount).fill(minWidth);
|
|
217
|
-
for (let col = 0;col < columnCount; col++) {
|
|
218
|
-
const header = headers[col];
|
|
219
|
-
if (header !== undefined) {
|
|
220
|
-
widths[col] = Math.max(widths[col] ?? 0, visibleWidth(header));
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
for (const row of rows) {
|
|
224
|
-
for (let col = 0;col < columnCount; col++) {
|
|
225
|
-
const cell = row[col];
|
|
226
|
-
if (cell !== undefined) {
|
|
227
|
-
widths[col] = Math.max(widths[col] ?? 0, visibleWidth(cell));
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return widths;
|
|
232
|
-
}
|
|
233
|
-
function alignCell(value, width, alignment) {
|
|
234
|
-
switch (alignment) {
|
|
235
|
-
case "right":
|
|
236
|
-
return padStart(value, width);
|
|
237
|
-
case "center":
|
|
238
|
-
return center(value, width);
|
|
239
|
-
default:
|
|
240
|
-
return padEnd(value, width);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
function formatRow(cells, columnWidths, alignments, cellPadding, borderChar) {
|
|
244
|
-
const pad = " ".repeat(cellPadding);
|
|
245
|
-
const formattedCells = columnWidths.map((width, col) => {
|
|
246
|
-
const cell = cells[col] ?? "";
|
|
247
|
-
const alignment = alignments[col] ?? "left";
|
|
248
|
-
const aligned = alignCell(cell, width, alignment);
|
|
249
|
-
return `${pad}${aligned}${pad}`;
|
|
250
|
-
});
|
|
251
|
-
return `${borderChar}${formattedCells.join(borderChar)}${borderChar}`;
|
|
252
|
-
}
|
|
253
|
-
function formatSeparator(columnWidths, cellPadding, separatorChar, borderChar) {
|
|
254
|
-
const segments = columnWidths.map((width) => {
|
|
255
|
-
return separatorChar.repeat(width + cellPadding * 2);
|
|
256
|
-
});
|
|
257
|
-
return `${borderChar}${segments.join(borderChar)}${borderChar}`;
|
|
258
|
-
}
|
|
259
|
-
function table(headers, rows, options) {
|
|
260
|
-
const alignments = options?.align ?? [];
|
|
261
|
-
const minColumnWidth = options?.minColumnWidth ?? 0;
|
|
262
|
-
const cellPadding = options?.cellPadding ?? 1;
|
|
263
|
-
const separatorChar = options?.separatorChar ?? "-";
|
|
264
|
-
const borderChar = options?.borderChar ?? "|";
|
|
265
|
-
const columnWidths = computeColumnWidths(headers, rows, minColumnWidth);
|
|
266
|
-
const lines = [];
|
|
267
|
-
lines.push(formatRow(headers, columnWidths, alignments, cellPadding, borderChar));
|
|
268
|
-
lines.push(formatSeparator(columnWidths, cellPadding, separatorChar, borderChar));
|
|
269
|
-
for (const row of rows) {
|
|
270
|
-
lines.push(formatRow(row, columnWidths, alignments, cellPadding, borderChar));
|
|
271
|
-
}
|
|
272
|
-
return lines.join(`
|
|
273
|
-
`);
|
|
274
|
-
}
|
|
275
|
-
// src/capability.ts
|
|
276
|
-
function resolveCapability(mode, overrides) {
|
|
277
|
-
if (mode === "always") {
|
|
278
|
-
return true;
|
|
279
|
-
}
|
|
280
|
-
if (mode === "never") {
|
|
281
|
-
return false;
|
|
282
|
-
}
|
|
283
|
-
const isTTY = overrides?.isTTY ?? process.stdout?.isTTY ?? false;
|
|
284
|
-
const noColor = overrides?.noColor !== undefined ? overrides.noColor : process.env.NO_COLOR;
|
|
285
|
-
if (noColor !== undefined) {
|
|
286
|
-
return false;
|
|
287
|
-
}
|
|
288
|
-
return isTTY;
|
|
289
|
-
}
|
|
290
|
-
function resolveTrueColor(mode, overrides) {
|
|
291
|
-
if (mode === "always") {
|
|
292
|
-
return true;
|
|
293
|
-
}
|
|
294
|
-
if (mode === "never") {
|
|
295
|
-
return false;
|
|
296
|
-
}
|
|
297
|
-
if (!resolveCapability(mode, overrides)) {
|
|
298
|
-
return false;
|
|
299
|
-
}
|
|
300
|
-
const hasColorTermOverride = overrides !== undefined && "colorTerm" in overrides;
|
|
301
|
-
const colorTerm = hasColorTermOverride ? overrides.colorTerm : process.env.COLORTERM;
|
|
302
|
-
const lowerColorTerm = colorTerm?.toLowerCase();
|
|
303
|
-
if (lowerColorTerm === "truecolor" || lowerColorTerm === "24bit") {
|
|
304
|
-
return true;
|
|
305
|
-
}
|
|
306
|
-
const hasTermOverride = overrides !== undefined && "term" in overrides;
|
|
307
|
-
const term = hasTermOverride ? overrides.term : process.env.TERM;
|
|
308
|
-
if (term !== undefined) {
|
|
309
|
-
const lower = term.toLowerCase();
|
|
310
|
-
if (lower.includes("24bit") || lower.includes("truecolor") || lower.endsWith("-direct")) {
|
|
311
|
-
return true;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
return false;
|
|
315
|
-
}
|
|
316
|
-
// src/styleEngine.ts
|
|
317
|
-
function applyStyle(text, style) {
|
|
318
|
-
if (text === "") {
|
|
319
|
-
return "";
|
|
320
|
-
}
|
|
321
|
-
const { open, close } = style;
|
|
322
|
-
if (text.includes(close)) {
|
|
323
|
-
text = text.replaceAll(close, close + open);
|
|
324
|
-
}
|
|
325
|
-
return open + text + close;
|
|
326
|
-
}
|
|
327
|
-
function composeStyles(...styles) {
|
|
328
|
-
return {
|
|
329
|
-
open: styles.map((s) => s.open).join(""),
|
|
330
|
-
close: styles.map((s) => s.close).reverse().join("")
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// src/colors.ts
|
|
335
|
-
function black2(text) {
|
|
336
|
-
return applyStyle(text, black);
|
|
337
|
-
}
|
|
338
|
-
function red2(text) {
|
|
339
|
-
return applyStyle(text, red);
|
|
340
|
-
}
|
|
341
|
-
function green2(text) {
|
|
342
|
-
return applyStyle(text, green);
|
|
343
|
-
}
|
|
344
|
-
function yellow2(text) {
|
|
345
|
-
return applyStyle(text, yellow);
|
|
346
|
-
}
|
|
347
|
-
function blue2(text) {
|
|
348
|
-
return applyStyle(text, blue);
|
|
349
|
-
}
|
|
350
|
-
function magenta2(text) {
|
|
351
|
-
return applyStyle(text, magenta);
|
|
352
|
-
}
|
|
353
|
-
function cyan2(text) {
|
|
354
|
-
return applyStyle(text, cyan);
|
|
355
|
-
}
|
|
356
|
-
function white2(text) {
|
|
357
|
-
return applyStyle(text, white);
|
|
358
|
-
}
|
|
359
|
-
function gray2(text) {
|
|
360
|
-
return applyStyle(text, gray);
|
|
361
|
-
}
|
|
362
|
-
function brightRed2(text) {
|
|
363
|
-
return applyStyle(text, brightRed);
|
|
364
|
-
}
|
|
365
|
-
function brightGreen2(text) {
|
|
366
|
-
return applyStyle(text, brightGreen);
|
|
367
|
-
}
|
|
368
|
-
function brightYellow2(text) {
|
|
369
|
-
return applyStyle(text, brightYellow);
|
|
370
|
-
}
|
|
371
|
-
function brightBlue2(text) {
|
|
372
|
-
return applyStyle(text, brightBlue);
|
|
373
|
-
}
|
|
374
|
-
function brightMagenta2(text) {
|
|
375
|
-
return applyStyle(text, brightMagenta);
|
|
376
|
-
}
|
|
377
|
-
function brightCyan2(text) {
|
|
378
|
-
return applyStyle(text, brightCyan);
|
|
379
|
-
}
|
|
380
|
-
function brightWhite2(text) {
|
|
381
|
-
return applyStyle(text, brightWhite);
|
|
382
|
-
}
|
|
383
|
-
function bgBlack2(text) {
|
|
384
|
-
return applyStyle(text, bgBlack);
|
|
385
|
-
}
|
|
386
|
-
function bgRed2(text) {
|
|
387
|
-
return applyStyle(text, bgRed);
|
|
388
|
-
}
|
|
389
|
-
function bgGreen2(text) {
|
|
390
|
-
return applyStyle(text, bgGreen);
|
|
391
|
-
}
|
|
392
|
-
function bgYellow2(text) {
|
|
393
|
-
return applyStyle(text, bgYellow);
|
|
394
|
-
}
|
|
395
|
-
function bgBlue2(text) {
|
|
396
|
-
return applyStyle(text, bgBlue);
|
|
397
|
-
}
|
|
398
|
-
function bgMagenta2(text) {
|
|
399
|
-
return applyStyle(text, bgMagenta);
|
|
400
|
-
}
|
|
401
|
-
function bgCyan2(text) {
|
|
402
|
-
return applyStyle(text, bgCyan);
|
|
403
|
-
}
|
|
404
|
-
function bgWhite2(text) {
|
|
405
|
-
return applyStyle(text, bgWhite);
|
|
406
|
-
}
|
|
407
|
-
function bgBrightBlack2(text) {
|
|
408
|
-
return applyStyle(text, bgBrightBlack);
|
|
409
|
-
}
|
|
410
|
-
function bgBrightRed2(text) {
|
|
411
|
-
return applyStyle(text, bgBrightRed);
|
|
412
|
-
}
|
|
413
|
-
function bgBrightGreen2(text) {
|
|
414
|
-
return applyStyle(text, bgBrightGreen);
|
|
415
|
-
}
|
|
416
|
-
function bgBrightYellow2(text) {
|
|
417
|
-
return applyStyle(text, bgBrightYellow);
|
|
418
|
-
}
|
|
419
|
-
function bgBrightBlue2(text) {
|
|
420
|
-
return applyStyle(text, bgBrightBlue);
|
|
421
|
-
}
|
|
422
|
-
function bgBrightMagenta2(text) {
|
|
423
|
-
return applyStyle(text, bgBrightMagenta);
|
|
424
|
-
}
|
|
425
|
-
function bgBrightCyan2(text) {
|
|
426
|
-
return applyStyle(text, bgBrightCyan);
|
|
427
|
-
}
|
|
428
|
-
function bgBrightWhite2(text) {
|
|
429
|
-
return applyStyle(text, bgBrightWhite);
|
|
430
|
-
}
|
|
431
|
-
// src/dynamicColors.ts
|
|
432
|
-
function validateChannel(value, channel) {
|
|
433
|
-
if (!Number.isInteger(value) || value < 0 || value > 255) {
|
|
434
|
-
throw new RangeError(`Invalid ${channel} value: ${String(value)}. Must be an integer between 0 and 255.`);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
function validateRgb(r, g, b) {
|
|
438
|
-
validateChannel(r, "red");
|
|
439
|
-
validateChannel(g, "green");
|
|
440
|
-
validateChannel(b, "blue");
|
|
441
|
-
}
|
|
442
|
-
var HEX_SHORT = /^#([0-9a-f]{3})$/i;
|
|
443
|
-
var HEX_LONG = /^#([0-9a-f]{6})$/i;
|
|
444
|
-
function parseHex(hex) {
|
|
445
|
-
const shortMatch = HEX_SHORT.exec(hex);
|
|
446
|
-
if (shortMatch) {
|
|
447
|
-
const digits = shortMatch[1];
|
|
448
|
-
const r = digits.charAt(0);
|
|
449
|
-
const g = digits.charAt(1);
|
|
450
|
-
const b = digits.charAt(2);
|
|
451
|
-
return [
|
|
452
|
-
Number.parseInt(r + r, 16),
|
|
453
|
-
Number.parseInt(g + g, 16),
|
|
454
|
-
Number.parseInt(b + b, 16)
|
|
455
|
-
];
|
|
456
|
-
}
|
|
457
|
-
const longMatch = HEX_LONG.exec(hex);
|
|
458
|
-
if (longMatch) {
|
|
459
|
-
const digits = longMatch[1];
|
|
460
|
-
return [
|
|
461
|
-
Number.parseInt(digits.slice(0, 2), 16),
|
|
462
|
-
Number.parseInt(digits.slice(2, 4), 16),
|
|
463
|
-
Number.parseInt(digits.slice(4, 6), 16)
|
|
464
|
-
];
|
|
465
|
-
}
|
|
466
|
-
throw new TypeError(`Invalid hex color: "${hex}". Expected format: "#RGB" or "#RRGGBB".`);
|
|
467
|
-
}
|
|
468
|
-
function rgbCode(r, g, b) {
|
|
469
|
-
validateRgb(r, g, b);
|
|
470
|
-
return { open: `\x1B[38;2;${r};${g};${b}m`, close: "\x1B[39m" };
|
|
471
|
-
}
|
|
472
|
-
function bgRgbCode(r, g, b) {
|
|
473
|
-
validateRgb(r, g, b);
|
|
474
|
-
return { open: `\x1B[48;2;${r};${g};${b}m`, close: "\x1B[49m" };
|
|
475
|
-
}
|
|
476
|
-
function hexCode(hex) {
|
|
477
|
-
const [r, g, b] = parseHex(hex);
|
|
478
|
-
return rgbCode(r, g, b);
|
|
479
|
-
}
|
|
480
|
-
function bgHexCode(hex) {
|
|
481
|
-
const [r, g, b] = parseHex(hex);
|
|
482
|
-
return bgRgbCode(r, g, b);
|
|
483
|
-
}
|
|
484
|
-
function rgb(text, r, g, b) {
|
|
485
|
-
return applyStyle(text, rgbCode(r, g, b));
|
|
486
|
-
}
|
|
487
|
-
function bgRgb(text, r, g, b) {
|
|
488
|
-
return applyStyle(text, bgRgbCode(r, g, b));
|
|
489
|
-
}
|
|
490
|
-
function hex(text, hexColor) {
|
|
491
|
-
return applyStyle(text, hexCode(hexColor));
|
|
492
|
-
}
|
|
493
|
-
function bgHex(text, hexColor) {
|
|
494
|
-
return applyStyle(text, bgHexCode(hexColor));
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
// src/styleMethodRegistry.ts
|
|
498
|
-
function readStyleMethodPairs() {
|
|
499
|
-
const { reset: _reset, ...pairs } = exports_ansiCodes;
|
|
500
|
-
return pairs;
|
|
501
|
-
}
|
|
502
|
-
var styleMethodPairs = Object.freeze(readStyleMethodPairs());
|
|
503
|
-
var styleMethodNames = Object.freeze(Object.keys(styleMethodPairs));
|
|
504
|
-
function stylePairFor(name) {
|
|
505
|
-
return styleMethodPairs[name];
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
// src/createStyle.ts
|
|
509
|
-
function applyChain(text, methodNames, enabled) {
|
|
510
|
-
if (!enabled || text === "") {
|
|
511
|
-
return text;
|
|
512
|
-
}
|
|
513
|
-
let result = text;
|
|
514
|
-
for (let i = methodNames.length - 1;i >= 0; i--) {
|
|
515
|
-
const methodName = methodNames[i];
|
|
516
|
-
if (methodName === undefined) {
|
|
517
|
-
continue;
|
|
518
|
-
}
|
|
519
|
-
result = applyStyle(result, stylePairFor(methodName));
|
|
520
|
-
}
|
|
521
|
-
return result;
|
|
522
|
-
}
|
|
523
|
-
function buildChainableStyleFactory(enabled) {
|
|
524
|
-
const cache = new Map;
|
|
525
|
-
function makeKey(methodNames) {
|
|
526
|
-
return methodNames.join("|");
|
|
527
|
-
}
|
|
528
|
-
function createChainableStyle(methodNames) {
|
|
529
|
-
const key = makeKey(methodNames);
|
|
530
|
-
const cached = cache.get(key);
|
|
531
|
-
if (cached) {
|
|
532
|
-
return cached;
|
|
533
|
-
}
|
|
534
|
-
const styleFn = (text) => applyChain(text, methodNames, enabled);
|
|
535
|
-
cache.set(key, styleFn);
|
|
536
|
-
for (const name of styleMethodNames) {
|
|
537
|
-
Object.defineProperty(styleFn, name, {
|
|
538
|
-
configurable: false,
|
|
539
|
-
enumerable: true,
|
|
540
|
-
get() {
|
|
541
|
-
return createChainableStyle([...methodNames, name]);
|
|
542
|
-
}
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
return Object.freeze(styleFn);
|
|
546
|
-
}
|
|
547
|
-
return createChainableStyle;
|
|
548
|
-
}
|
|
549
|
-
function buildStyleMethods(createChainableStyle) {
|
|
550
|
-
const methods = {};
|
|
551
|
-
for (const methodName of styleMethodNames) {
|
|
552
|
-
methods[methodName] = createChainableStyle([methodName]);
|
|
553
|
-
}
|
|
554
|
-
return methods;
|
|
555
|
-
}
|
|
556
|
-
function createStyle(options) {
|
|
557
|
-
const mode = options?.mode ?? "auto";
|
|
558
|
-
const enabled = resolveCapability(mode, options?.overrides);
|
|
559
|
-
const trueColorEnabled = resolveTrueColor(mode, options?.overrides);
|
|
560
|
-
const createChainableStyle = buildChainableStyleFactory(enabled);
|
|
561
|
-
const methods = buildStyleMethods(createChainableStyle);
|
|
562
|
-
const instance = {
|
|
563
|
-
enabled,
|
|
564
|
-
trueColorEnabled,
|
|
565
|
-
apply: enabled ? (text, pair2) => applyStyle(text, pair2) : (text, _pair) => text,
|
|
566
|
-
rgb: trueColorEnabled ? (text, r, g, b) => rgb(text, r, g, b) : (text, _r, _g, _b) => text,
|
|
567
|
-
bgRgb: trueColorEnabled ? (text, r, g, b) => bgRgb(text, r, g, b) : (text, _r, _g, _b) => text,
|
|
568
|
-
hex: trueColorEnabled ? (text, hexColor) => hex(text, hexColor) : (text, _hexColor) => text,
|
|
569
|
-
bgHex: trueColorEnabled ? (text, hexColor) => bgHex(text, hexColor) : (text, _hexColor) => text,
|
|
570
|
-
...methods
|
|
571
|
-
};
|
|
572
|
-
return Object.freeze(instance);
|
|
573
|
-
}
|
|
574
|
-
var style = createStyle();
|
|
575
|
-
// src/modifiers.ts
|
|
576
|
-
function bold2(text) {
|
|
577
|
-
return applyStyle(text, bold);
|
|
578
|
-
}
|
|
579
|
-
function dim2(text) {
|
|
580
|
-
return applyStyle(text, dim);
|
|
581
|
-
}
|
|
582
|
-
function italic2(text) {
|
|
583
|
-
return applyStyle(text, italic);
|
|
584
|
-
}
|
|
585
|
-
function underline2(text) {
|
|
586
|
-
return applyStyle(text, underline);
|
|
587
|
-
}
|
|
588
|
-
function inverse2(text) {
|
|
589
|
-
return applyStyle(text, inverse);
|
|
590
|
-
}
|
|
591
|
-
function hidden2(text) {
|
|
592
|
-
return applyStyle(text, hidden);
|
|
593
|
-
}
|
|
594
|
-
function strikethrough2(text) {
|
|
595
|
-
return applyStyle(text, strikethrough);
|
|
596
|
-
}
|
|
597
|
-
// src/text/wrap.ts
|
|
598
|
-
var ANSI_SEQUENCE = /[\x1b\x9b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]/;
|
|
599
|
-
function isFullWidth2(codePoint) {
|
|
600
|
-
return codePoint >= 19968 && codePoint <= 40959 || codePoint >= 13312 && codePoint <= 19903 || codePoint >= 131072 && codePoint <= 173791 || codePoint >= 63744 && codePoint <= 64255 || codePoint >= 65281 && codePoint <= 65376 || codePoint >= 65504 && codePoint <= 65510 || codePoint >= 11904 && codePoint <= 12031 || codePoint >= 12032 && codePoint <= 12255 || codePoint >= 12288 && codePoint <= 12351 || codePoint >= 12352 && codePoint <= 12447 || codePoint >= 12448 && codePoint <= 12543 || codePoint >= 12544 && codePoint <= 12591 || codePoint >= 12592 && codePoint <= 12687 || codePoint >= 12800 && codePoint <= 13055 || codePoint >= 13056 && codePoint <= 13311 || codePoint >= 44032 && codePoint <= 55215 || codePoint >= 65072 && codePoint <= 65103;
|
|
601
|
-
}
|
|
602
|
-
function isReset(seq) {
|
|
603
|
-
return seq === "\x1B[0m";
|
|
604
|
-
}
|
|
605
|
-
function isSGR(seq) {
|
|
606
|
-
return seq.endsWith("m") && seq.startsWith("\x1B[");
|
|
607
|
-
}
|
|
608
|
-
function wrapText(text, width, options) {
|
|
609
|
-
if (width <= 0) {
|
|
610
|
-
return text;
|
|
611
|
-
}
|
|
612
|
-
const wordBreak = options?.wordBreak ?? true;
|
|
613
|
-
const inputLines = text.split(`
|
|
614
|
-
`);
|
|
615
|
-
const resultLines = [];
|
|
616
|
-
let activeStyles = [];
|
|
617
|
-
for (const inputLine of inputLines) {
|
|
618
|
-
const wrapped = wrapLine(inputLine, width, wordBreak, activeStyles);
|
|
619
|
-
resultLines.push(...wrapped.lines);
|
|
620
|
-
activeStyles = wrapped.activeStyles;
|
|
621
|
-
}
|
|
622
|
-
return resultLines.join(`
|
|
623
|
-
`);
|
|
624
|
-
}
|
|
625
|
-
function wrapLine(line, width, wordBreak, initialStyles) {
|
|
626
|
-
const activeStyles = [...initialStyles];
|
|
627
|
-
const lines = [];
|
|
628
|
-
let currentLine = activeStyles.length > 0 ? activeStyles.join("") : "";
|
|
629
|
-
let currentWidth = 0;
|
|
630
|
-
let lastSpaceIdx = -1;
|
|
631
|
-
let lastSpaceWidth = 0;
|
|
632
|
-
let lastSpaceStyleSnapshot = [];
|
|
633
|
-
let i = 0;
|
|
634
|
-
while (i < line.length) {
|
|
635
|
-
const ansiMatch = line.slice(i).match(ANSI_SEQUENCE);
|
|
636
|
-
if (ansiMatch && ansiMatch.index === 0) {
|
|
637
|
-
const seq = ansiMatch[0];
|
|
638
|
-
if (isSGR(seq)) {
|
|
639
|
-
if (isReset(seq)) {
|
|
640
|
-
activeStyles.length = 0;
|
|
641
|
-
} else {
|
|
642
|
-
activeStyles.push(seq);
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
currentLine += seq;
|
|
646
|
-
i += seq.length;
|
|
647
|
-
continue;
|
|
648
|
-
}
|
|
649
|
-
const char = line[i];
|
|
650
|
-
if (char === undefined) {
|
|
651
|
-
break;
|
|
652
|
-
}
|
|
653
|
-
const codePoint = char.codePointAt(0) ?? 0;
|
|
654
|
-
const charWidth = isFullWidth2(codePoint) ? 2 : 1;
|
|
655
|
-
if (currentWidth + charWidth > width) {
|
|
656
|
-
if (wordBreak && lastSpaceIdx !== -1) {
|
|
657
|
-
const beforeSpace = currentLine.slice(0, lastSpaceIdx);
|
|
658
|
-
const afterSpace = currentLine.slice(lastSpaceIdx + 1);
|
|
659
|
-
const closeSeq = activeStyles.length > 0 ? "\x1B[0m" : "";
|
|
660
|
-
lines.push(beforeSpace + closeSeq);
|
|
661
|
-
const reopenSeq = lastSpaceStyleSnapshot.length > 0 ? lastSpaceStyleSnapshot.join("") : "";
|
|
662
|
-
currentLine = reopenSeq + afterSpace;
|
|
663
|
-
currentWidth = currentWidth - lastSpaceWidth;
|
|
664
|
-
lastSpaceIdx = -1;
|
|
665
|
-
lastSpaceWidth = 0;
|
|
666
|
-
lastSpaceStyleSnapshot = [];
|
|
667
|
-
if (currentWidth + charWidth > width) {
|
|
668
|
-
const closeSeq2 = activeStyles.length > 0 ? "\x1B[0m" : "";
|
|
669
|
-
lines.push(currentLine + closeSeq2);
|
|
670
|
-
const reopenSeq2 = activeStyles.length > 0 ? activeStyles.join("") : "";
|
|
671
|
-
currentLine = reopenSeq2 + char;
|
|
672
|
-
currentWidth = charWidth;
|
|
673
|
-
} else {
|
|
674
|
-
currentLine += char;
|
|
675
|
-
currentWidth += charWidth;
|
|
676
|
-
}
|
|
677
|
-
} else {
|
|
678
|
-
const closeSeq = activeStyles.length > 0 ? "\x1B[0m" : "";
|
|
679
|
-
lines.push(currentLine + closeSeq);
|
|
680
|
-
const reopenSeq = activeStyles.length > 0 ? activeStyles.join("") : "";
|
|
681
|
-
currentLine = reopenSeq + char;
|
|
682
|
-
currentWidth = charWidth;
|
|
683
|
-
lastSpaceIdx = -1;
|
|
684
|
-
lastSpaceWidth = 0;
|
|
685
|
-
lastSpaceStyleSnapshot = [];
|
|
686
|
-
}
|
|
687
|
-
} else {
|
|
688
|
-
if (wordBreak && char === " ") {
|
|
689
|
-
currentLine += char;
|
|
690
|
-
currentWidth += charWidth;
|
|
691
|
-
lastSpaceIdx = currentLine.length - 1;
|
|
692
|
-
lastSpaceWidth = currentWidth;
|
|
693
|
-
lastSpaceStyleSnapshot = [...activeStyles];
|
|
694
|
-
} else {
|
|
695
|
-
currentLine += char;
|
|
696
|
-
currentWidth += charWidth;
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
i += char.length;
|
|
700
|
-
}
|
|
701
|
-
if (currentLine.length > 0) {
|
|
702
|
-
const hasVisibleContent = currentLine.replace(/[\x1b\x9b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]/g, "");
|
|
703
|
-
if (hasVisibleContent.length > 0 || currentLine.length > 0) {
|
|
704
|
-
lines.push(currentLine);
|
|
705
|
-
}
|
|
706
|
-
} else {
|
|
707
|
-
lines.push("");
|
|
708
|
-
}
|
|
709
|
-
return { lines, activeStyles };
|
|
710
|
-
}
|
|
711
|
-
// src/theme/markdownTheme.ts
|
|
712
|
-
function buildDefaultMarkdownTheme(s) {
|
|
713
|
-
const theme = {
|
|
714
|
-
heading1: (value) => s.bold(s.underline(value)),
|
|
715
|
-
heading2: (value) => s.bold(value),
|
|
716
|
-
heading3: (value) => s.bold(s.yellow(value)),
|
|
717
|
-
heading4: (value) => s.yellow(value),
|
|
718
|
-
heading5: (value) => s.dim(s.yellow(value)),
|
|
719
|
-
heading6: (value) => s.dim(value),
|
|
720
|
-
text: (value) => value,
|
|
721
|
-
emphasis: (value) => s.italic(value),
|
|
722
|
-
strong: (value) => s.bold(value),
|
|
723
|
-
strongEmphasis: (value) => s.bold(s.italic(value)),
|
|
724
|
-
strikethrough: (value) => s.strikethrough(value),
|
|
725
|
-
inlineCode: (value) => s.cyan(value),
|
|
726
|
-
linkText: (value) => s.blue(s.underline(value)),
|
|
727
|
-
linkUrl: (value) => s.dim(s.underline(value)),
|
|
728
|
-
autolink: (value) => s.blue(s.underline(value)),
|
|
729
|
-
blockquoteMarker: (value) => s.dim(s.green(value)),
|
|
730
|
-
blockquoteText: (value) => s.italic(value),
|
|
731
|
-
listMarker: (value) => s.dim(value),
|
|
732
|
-
orderedListMarker: (value) => s.dim(value),
|
|
733
|
-
taskChecked: (value) => s.green(value),
|
|
734
|
-
taskUnchecked: (value) => s.dim(value),
|
|
735
|
-
codeFence: (value) => s.dim(value),
|
|
736
|
-
codeInfo: (value) => s.dim(s.italic(value)),
|
|
737
|
-
codeText: (value) => s.cyan(value),
|
|
738
|
-
thematicBreak: (value) => s.dim(value),
|
|
739
|
-
tableHeader: (value) => s.bold(value),
|
|
740
|
-
tableCell: (value) => value,
|
|
741
|
-
tableBorder: (value) => s.dim(value),
|
|
742
|
-
imageAltText: (value) => s.italic(s.magenta(value)),
|
|
743
|
-
imageUrl: (value) => s.dim(s.underline(value))
|
|
744
|
-
};
|
|
745
|
-
return Object.freeze(theme);
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
// src/theme/createMarkdownTheme.ts
|
|
749
|
-
function createMarkdownTheme(options) {
|
|
750
|
-
const styleInstance = createStyle(options?.style);
|
|
751
|
-
const base = buildDefaultMarkdownTheme(styleInstance);
|
|
752
|
-
const overrides = options?.overrides;
|
|
753
|
-
if (!overrides) {
|
|
754
|
-
return base;
|
|
755
|
-
}
|
|
756
|
-
const merged = {
|
|
757
|
-
heading1: overrides.heading1 ?? base.heading1,
|
|
758
|
-
heading2: overrides.heading2 ?? base.heading2,
|
|
759
|
-
heading3: overrides.heading3 ?? base.heading3,
|
|
760
|
-
heading4: overrides.heading4 ?? base.heading4,
|
|
761
|
-
heading5: overrides.heading5 ?? base.heading5,
|
|
762
|
-
heading6: overrides.heading6 ?? base.heading6,
|
|
763
|
-
text: overrides.text ?? base.text,
|
|
764
|
-
emphasis: overrides.emphasis ?? base.emphasis,
|
|
765
|
-
strong: overrides.strong ?? base.strong,
|
|
766
|
-
strongEmphasis: overrides.strongEmphasis ?? base.strongEmphasis,
|
|
767
|
-
strikethrough: overrides.strikethrough ?? base.strikethrough,
|
|
768
|
-
inlineCode: overrides.inlineCode ?? base.inlineCode,
|
|
769
|
-
linkText: overrides.linkText ?? base.linkText,
|
|
770
|
-
linkUrl: overrides.linkUrl ?? base.linkUrl,
|
|
771
|
-
autolink: overrides.autolink ?? base.autolink,
|
|
772
|
-
blockquoteMarker: overrides.blockquoteMarker ?? base.blockquoteMarker,
|
|
773
|
-
blockquoteText: overrides.blockquoteText ?? base.blockquoteText,
|
|
774
|
-
listMarker: overrides.listMarker ?? base.listMarker,
|
|
775
|
-
orderedListMarker: overrides.orderedListMarker ?? base.orderedListMarker,
|
|
776
|
-
taskChecked: overrides.taskChecked ?? base.taskChecked,
|
|
777
|
-
taskUnchecked: overrides.taskUnchecked ?? base.taskUnchecked,
|
|
778
|
-
codeFence: overrides.codeFence ?? base.codeFence,
|
|
779
|
-
codeInfo: overrides.codeInfo ?? base.codeInfo,
|
|
780
|
-
codeText: overrides.codeText ?? base.codeText,
|
|
781
|
-
thematicBreak: overrides.thematicBreak ?? base.thematicBreak,
|
|
782
|
-
tableHeader: overrides.tableHeader ?? base.tableHeader,
|
|
783
|
-
tableCell: overrides.tableCell ?? base.tableCell,
|
|
784
|
-
tableBorder: overrides.tableBorder ?? base.tableBorder,
|
|
785
|
-
imageAltText: overrides.imageAltText ?? base.imageAltText,
|
|
786
|
-
imageUrl: overrides.imageUrl ?? base.imageUrl
|
|
787
|
-
};
|
|
788
|
-
return Object.freeze(merged);
|
|
789
|
-
}
|
|
790
|
-
var defaultTheme = createMarkdownTheme();
|
|
791
|
-
export {
|
|
792
|
-
yellow as yellowCode,
|
|
793
|
-
yellow2 as yellow,
|
|
794
|
-
wrapText,
|
|
795
|
-
white as whiteCode,
|
|
796
|
-
white2 as white,
|
|
797
|
-
visibleWidth,
|
|
798
|
-
unorderedList,
|
|
799
|
-
underline as underlineCode,
|
|
800
|
-
underline2 as underline,
|
|
801
|
-
taskList,
|
|
802
|
-
table,
|
|
803
|
-
style,
|
|
804
|
-
stripAnsi,
|
|
805
|
-
strikethrough as strikethroughCode,
|
|
806
|
-
strikethrough2 as strikethrough,
|
|
807
|
-
rgbCode,
|
|
808
|
-
rgb,
|
|
809
|
-
resolveTrueColor,
|
|
810
|
-
resolveCapability,
|
|
811
|
-
reset,
|
|
812
|
-
red as redCode,
|
|
813
|
-
red2 as red,
|
|
814
|
-
parseHex,
|
|
815
|
-
padStart,
|
|
816
|
-
padEnd,
|
|
817
|
-
orderedList,
|
|
818
|
-
magenta as magentaCode,
|
|
819
|
-
magenta2 as magenta,
|
|
820
|
-
italic as italicCode,
|
|
821
|
-
italic2 as italic,
|
|
822
|
-
inverse as inverseCode,
|
|
823
|
-
inverse2 as inverse,
|
|
824
|
-
hidden as hiddenCode,
|
|
825
|
-
hidden2 as hidden,
|
|
826
|
-
hexCode,
|
|
827
|
-
hex,
|
|
828
|
-
green as greenCode,
|
|
829
|
-
green2 as green,
|
|
830
|
-
gray as grayCode,
|
|
831
|
-
gray2 as gray,
|
|
832
|
-
dim as dimCode,
|
|
833
|
-
dim2 as dim,
|
|
834
|
-
defaultTheme,
|
|
835
|
-
cyan as cyanCode,
|
|
836
|
-
cyan2 as cyan,
|
|
837
|
-
createStyle,
|
|
838
|
-
createMarkdownTheme,
|
|
839
|
-
composeStyles,
|
|
840
|
-
center,
|
|
841
|
-
buildDefaultMarkdownTheme,
|
|
842
|
-
brightYellow as brightYellowCode,
|
|
843
|
-
brightYellow2 as brightYellow,
|
|
844
|
-
brightWhite as brightWhiteCode,
|
|
845
|
-
brightWhite2 as brightWhite,
|
|
846
|
-
brightRed as brightRedCode,
|
|
847
|
-
brightRed2 as brightRed,
|
|
848
|
-
brightMagenta as brightMagentaCode,
|
|
849
|
-
brightMagenta2 as brightMagenta,
|
|
850
|
-
brightGreen as brightGreenCode,
|
|
851
|
-
brightGreen2 as brightGreen,
|
|
852
|
-
brightCyan as brightCyanCode,
|
|
853
|
-
brightCyan2 as brightCyan,
|
|
854
|
-
brightBlue as brightBlueCode,
|
|
855
|
-
brightBlue2 as brightBlue,
|
|
856
|
-
bold as boldCode,
|
|
857
|
-
bold2 as bold,
|
|
858
|
-
blue as blueCode,
|
|
859
|
-
blue2 as blue,
|
|
860
|
-
black as blackCode,
|
|
861
|
-
black2 as black,
|
|
862
|
-
bgYellow as bgYellowCode,
|
|
863
|
-
bgYellow2 as bgYellow,
|
|
864
|
-
bgWhite as bgWhiteCode,
|
|
865
|
-
bgWhite2 as bgWhite,
|
|
866
|
-
bgRgbCode,
|
|
867
|
-
bgRgb,
|
|
868
|
-
bgRed as bgRedCode,
|
|
869
|
-
bgRed2 as bgRed,
|
|
870
|
-
bgMagenta as bgMagentaCode,
|
|
871
|
-
bgMagenta2 as bgMagenta,
|
|
872
|
-
bgHexCode,
|
|
873
|
-
bgHex,
|
|
874
|
-
bgGreen as bgGreenCode,
|
|
875
|
-
bgGreen2 as bgGreen,
|
|
876
|
-
bgCyan as bgCyanCode,
|
|
877
|
-
bgCyan2 as bgCyan,
|
|
878
|
-
bgBrightYellow as bgBrightYellowCode,
|
|
879
|
-
bgBrightYellow2 as bgBrightYellow,
|
|
880
|
-
bgBrightWhite as bgBrightWhiteCode,
|
|
881
|
-
bgBrightWhite2 as bgBrightWhite,
|
|
882
|
-
bgBrightRed as bgBrightRedCode,
|
|
883
|
-
bgBrightRed2 as bgBrightRed,
|
|
884
|
-
bgBrightMagenta as bgBrightMagentaCode,
|
|
885
|
-
bgBrightMagenta2 as bgBrightMagenta,
|
|
886
|
-
bgBrightGreen as bgBrightGreenCode,
|
|
887
|
-
bgBrightGreen2 as bgBrightGreen,
|
|
888
|
-
bgBrightCyan as bgBrightCyanCode,
|
|
889
|
-
bgBrightCyan2 as bgBrightCyan,
|
|
890
|
-
bgBrightBlue as bgBrightBlueCode,
|
|
891
|
-
bgBrightBlue2 as bgBrightBlue,
|
|
892
|
-
bgBrightBlack as bgBrightBlackCode,
|
|
893
|
-
bgBrightBlack2 as bgBrightBlack,
|
|
894
|
-
bgBlue as bgBlueCode,
|
|
895
|
-
bgBlue2 as bgBlue,
|
|
896
|
-
bgBlack as bgBlackCode,
|
|
897
|
-
bgBlack2 as bgBlack,
|
|
898
|
-
applyStyle
|
|
899
|
-
};
|
|
2
|
+
var bz=Object.defineProperty;var yz=(z,Z)=>{for(var V in Z)bz(z,V,{get:Z[V],enumerable:!0,configurable:!0,set:($)=>Z[V]=()=>$})};var q={};yz(q,{yellow:()=>C,white:()=>g,underline:()=>A,strikethrough:()=>T,reset:()=>Nz,red:()=>f,magenta:()=>S,italic:()=>L,inverse:()=>I,hidden:()=>N,green:()=>W,gray:()=>b,dim:()=>R,cyan:()=>P,brightYellow:()=>m,brightWhite:()=>p,brightRed:()=>y,brightMagenta:()=>x,brightGreen:()=>v,brightCyan:()=>h,brightBlue:()=>u,bold:()=>E,blue:()=>w,black:()=>k,bgYellow:()=>l,bgWhite:()=>o,bgRed:()=>d,bgMagenta:()=>s,bgGreen:()=>n,bgCyan:()=>a,bgBrightYellow:()=>zz,bgBrightWhite:()=>Qz,bgBrightRed:()=>t,bgBrightMagenta:()=>Zz,bgBrightGreen:()=>e,bgBrightCyan:()=>$z,bgBrightBlue:()=>Vz,bgBrightBlack:()=>i,bgBlue:()=>r,bgBlack:()=>c});function O(z,Z){return{open:`\x1B[${z}m`,close:`\x1B[${Z}m`}}var Nz=O(0,0),E=O(1,22),R=O(2,22),L=O(3,23),A=O(4,24),I=O(7,27),N=O(8,28),T=O(9,29),k=O(30,39),f=O(31,39),W=O(32,39),C=O(33,39),w=O(34,39),S=O(35,39),P=O(36,39),g=O(37,39),b=O(90,39),y=O(91,39),v=O(92,39),m=O(93,39),u=O(94,39),x=O(95,39),h=O(96,39),p=O(97,39),c=O(40,49),d=O(41,49),n=O(42,49),l=O(43,49),r=O(44,49),s=O(45,49),a=O(46,49),o=O(47,49),i=O(100,49),t=O(101,49),e=O(102,49),zz=O(103,49),Vz=O(104,49),Zz=O(105,49),$z=O(106,49),Qz=O(107,49);var vz=/[\x1b\x9b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]/g;function Xz(z){return z.replace(vz,"")}function mz(z){return z>=19968&&z<=40959||z>=13312&&z<=19903||z>=131072&&z<=173791||z>=63744&&z<=64255||z>=65281&&z<=65376||z>=65504&&z<=65510||z>=11904&&z<=12031||z>=12032&&z<=12255||z>=12288&&z<=12351||z>=12352&&z<=12447||z>=12448&&z<=12543||z>=12544&&z<=12591||z>=12592&&z<=12687||z>=12800&&z<=13055||z>=13056&&z<=13311||z>=44032&&z<=55215||z>=65072&&z<=65103}function D(z){let Z=Xz(z),V=0;for(let $ of Z){let Q=$.codePointAt(0);if(Q===void 0)continue;V+=mz(Q)?2:1}return V}function Yz(z,Z){let V=z.split(`
|
|
3
|
+
`);if(V.length<=1)return z;let $=" ".repeat(Z);return V.map((Q,K)=>K===0?Q:$+Q).join(`
|
|
4
|
+
`)}function uz(z,Z){let V=Z?.marker??"\u2022",$=Z?.markerGap??1,Q=Z?.indent??0,K=" ".repeat(Q),J=" ".repeat($),j=D(V),Y=Q+j+$;return z.map((U)=>{let _=Yz(U,Y);return`${K}${V}${J}${_}`}).join(`
|
|
5
|
+
`)}function xz(z,Z){let V=Z?.start??1,$=Z?.markerGap??1,Q=Z?.indent??0;if(z.length===0)return"";let K=" ".repeat(Q),J=" ".repeat($),Y=`${V+z.length-1}.`.length;return z.map((U,_)=>{let F=`${V+_}.`.padStart(Y," "),Kz=Q+Y+$,B=Yz(U,Kz);return`${K}${F}${J}${B}`}).join(`
|
|
6
|
+
`)}function hz(z,Z){let V=Z?.checkedMarker??"[x]",$=Z?.uncheckedMarker??"[ ]",Q=Z?.markerGap??1,K=Z?.indent??0,J=" ".repeat(K),j=" ".repeat(Q),Y=Math.max(D(V),D($)),U=K+Y+Q;return z.map((_)=>{let H=_.checked?V:$,M=Yz(_.text,U);return`${J}${H}${j}${M}`}).join(`
|
|
7
|
+
`)}function Oz(z,Z,V=" "){let $=D(z);if($>=Z)return z;return V.repeat(Z-$)+z}function Uz(z,Z,V=" "){let $=D(z);if($>=Z)return z;let Q=V.repeat(Z-$);return z+Q}function _z(z,Z,V=" "){let $=D(z);if($>=Z)return z;let Q=Z-$,K=Math.floor(Q/2),J=Q-K;return V.repeat(K)+z+V.repeat(J)}function pz(z,Z,V){let $=z.length,Q=Array($).fill(V);for(let K=0;K<$;K++){let J=z[K];if(J!==void 0)Q[K]=Math.max(Q[K]??0,D(J))}for(let K of Z)for(let J=0;J<$;J++){let j=K[J];if(j!==void 0)Q[J]=Math.max(Q[J]??0,D(j))}return Q}function cz(z,Z,V){switch(V){case"right":return Oz(z,Z);case"center":return _z(z,Z);default:return Uz(z,Z)}}function Tz(z,Z,V,$,Q){let K=" ".repeat($),J=Z.map((j,Y)=>{let U=z[Y]??"",_=V[Y]??"left",H=cz(U,j,_);return`${K}${H}${K}`});return`${Q}${J.join(Q)}${Q}`}function dz(z,Z,V,$){let Q=z.map((K)=>{return V.repeat(K+Z*2)});return`${$}${Q.join($)}${$}`}function nz(z,Z,V){let $=V?.align??[],Q=V?.minColumnWidth??0,K=V?.cellPadding??1,J=V?.separatorChar??"-",j=V?.borderChar??"|",Y=pz(z,Z,Q),U=[];U.push(Tz(z,Y,$,K,j)),U.push(dz(Y,K,J,j));for(let _ of Z)U.push(Tz(_,Y,$,K,j));return U.join(`
|
|
8
|
+
`)}function jz(z,Z){if(z==="always")return!0;if(z==="never")return!1;let V=Z?.isTTY??process.stdout?.isTTY??!1;if((Z?.noColor!==void 0?Z.noColor:process.env.NO_COLOR)!==void 0)return!1;return V}function Dz(z,Z){if(z==="always")return!0;if(z==="never")return!1;if(!jz(z,Z))return!1;let Q=(Z!==void 0&&"colorTerm"in Z?Z.colorTerm:process.env.COLORTERM)?.toLowerCase();if(Q==="truecolor"||Q==="24bit")return!0;let J=Z!==void 0&&"term"in Z?Z.term:process.env.TERM;if(J!==void 0){let j=J.toLowerCase();if(j.includes("24bit")||j.includes("truecolor")||j.endsWith("-direct"))return!0}return!1}function X(z,Z){if(z==="")return"";let{open:V,close:$}=Z;if(z.includes($))z=z.replaceAll($,$+V);return V+z+$}function lz(...z){return{open:z.map((Z)=>Z.open).join(""),close:z.map((Z)=>Z.close).reverse().join("")}}function rz(z){return X(z,k)}function sz(z){return X(z,f)}function az(z){return X(z,W)}function oz(z){return X(z,C)}function iz(z){return X(z,w)}function tz(z){return X(z,S)}function ez(z){return X(z,P)}function zV(z){return X(z,g)}function VV(z){return X(z,b)}function ZV(z){return X(z,y)}function $V(z){return X(z,v)}function QV(z){return X(z,m)}function jV(z){return X(z,u)}function JV(z){return X(z,x)}function KV(z){return X(z,h)}function XV(z){return X(z,p)}function YV(z){return X(z,c)}function OV(z){return X(z,d)}function UV(z){return X(z,n)}function _V(z){return X(z,l)}function DV(z){return X(z,r)}function FV(z){return X(z,s)}function HV(z){return X(z,a)}function BV(z){return X(z,o)}function GV(z){return X(z,i)}function MV(z){return X(z,t)}function qV(z){return X(z,e)}function EV(z){return X(z,zz)}function RV(z){return X(z,Vz)}function LV(z){return X(z,Zz)}function AV(z){return X(z,$z)}function IV(z){return X(z,Qz)}function Fz(z,Z){if(!Number.isInteger(z)||z<0||z>255)throw RangeError(`Invalid ${Z} value: ${String(z)}. Must be an integer between 0 and 255.`)}function kz(z,Z,V){Fz(z,"red"),Fz(Z,"green"),Fz(V,"blue")}var NV=/^#([0-9a-f]{3})$/i,TV=/^#([0-9a-f]{6})$/i;function Hz(z){let Z=NV.exec(z);if(Z){let $=Z[1],Q=$.charAt(0),K=$.charAt(1),J=$.charAt(2);return[Number.parseInt(Q+Q,16),Number.parseInt(K+K,16),Number.parseInt(J+J,16)]}let V=TV.exec(z);if(V){let $=V[1];return[Number.parseInt($.slice(0,2),16),Number.parseInt($.slice(2,4),16),Number.parseInt($.slice(4,6),16)]}throw TypeError(`Invalid hex color: "${z}". Expected format: "#RGB" or "#RRGGBB".`)}function Bz(z,Z,V){return kz(z,Z,V),{open:`\x1B[38;2;${z};${Z};${V}m`,close:"\x1B[39m"}}function Gz(z,Z,V){return kz(z,Z,V),{open:`\x1B[48;2;${z};${Z};${V}m`,close:"\x1B[49m"}}function fz(z){let[Z,V,$]=Hz(z);return Bz(Z,V,$)}function Wz(z){let[Z,V,$]=Hz(z);return Gz(Z,V,$)}function Mz(z,Z,V,$){return X(z,Bz(Z,V,$))}function qz(z,Z,V,$){return X(z,Gz(Z,V,$))}function Ez(z,Z){return X(z,fz(Z))}function Rz(z,Z){return X(z,Wz(Z))}function kV(){let{reset:z,...Z}=q;return Z}var Cz=Object.freeze(kV()),Lz=Object.freeze(Object.keys(Cz));function wz(z){return Cz[z]}function fV(z,Z,V){if(!V||z==="")return z;let $=z;for(let Q=Z.length-1;Q>=0;Q--){let K=Z[Q];if(K===void 0)continue;$=X($,wz(K))}return $}function WV(z){let Z=new Map;function V(Q){return Q.join("|")}function $(Q){let K=V(Q),J=Z.get(K);if(J)return J;let j=(Y)=>fV(Y,Q,z);Z.set(K,j);for(let Y of Lz)Object.defineProperty(j,Y,{configurable:!1,enumerable:!0,get(){return $([...Q,Y])}});return Object.freeze(j)}return $}function CV(z){let Z={};for(let V of Lz)Z[V]=z([V]);return Z}function Jz(z){let Z=z?.mode??"auto",V=jz(Z,z?.overrides),$=Dz(Z,z?.overrides),Q=WV(V),K=CV(Q),J={enabled:V,trueColorEnabled:$,apply:V?(j,Y)=>X(j,Y):(j,Y)=>j,rgb:$?(j,Y,U,_)=>Mz(j,Y,U,_):(j,Y,U,_)=>j,bgRgb:$?(j,Y,U,_)=>qz(j,Y,U,_):(j,Y,U,_)=>j,hex:$?(j,Y)=>Ez(j,Y):(j,Y)=>j,bgHex:$?(j,Y)=>Rz(j,Y):(j,Y)=>j,...K};return Object.freeze(J)}var wV=Jz();function SV(z){return X(z,E)}function PV(z){return X(z,R)}function gV(z){return X(z,L)}function bV(z){return X(z,A)}function yV(z){return X(z,I)}function vV(z){return X(z,N)}function mV(z){return X(z,T)}var uV=/[\x1b\x9b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]/;function xV(z){return z>=19968&&z<=40959||z>=13312&&z<=19903||z>=131072&&z<=173791||z>=63744&&z<=64255||z>=65281&&z<=65376||z>=65504&&z<=65510||z>=11904&&z<=12031||z>=12032&&z<=12255||z>=12288&&z<=12351||z>=12352&&z<=12447||z>=12448&&z<=12543||z>=12544&&z<=12591||z>=12592&&z<=12687||z>=12800&&z<=13055||z>=13056&&z<=13311||z>=44032&&z<=55215||z>=65072&&z<=65103}function hV(z){return z==="\x1B[0m"}function pV(z){return z.endsWith("m")&&z.startsWith("\x1B[")}function cV(z,Z,V){if(Z<=0)return z;let $=V?.wordBreak??!0,Q=z.split(`
|
|
9
|
+
`),K=[],J=[];for(let j of Q){let Y=dV(j,Z,$,J);K.push(...Y.lines),J=Y.activeStyles}return K.join(`
|
|
10
|
+
`)}function dV(z,Z,V,$){let Q=[...$],K=[],J=Q.length>0?Q.join(""):"",j=0,Y=-1,U=0,_=[],H=0;while(H<z.length){let M=z.slice(H).match(uV);if(M&&M.index===0){let G=M[0];if(pV(G))if(hV(G))Q.length=0;else Q.push(G);J+=G,H+=G.length;continue}let F=z[H];if(F===void 0)break;let Kz=F.codePointAt(0)??0,B=xV(Kz)?2:1;if(j+B>Z)if(V&&Y!==-1){let G=J.slice(0,Y),Iz=J.slice(Y+1),Pz=Q.length>0?"\x1B[0m":"";if(K.push(G+Pz),J=(_.length>0?_.join(""):"")+Iz,j=j-U,Y=-1,U=0,_=[],j+B>Z){let gz=Q.length>0?"\x1B[0m":"";K.push(J+gz),J=(Q.length>0?Q.join(""):"")+F,j=B}else J+=F,j+=B}else{let G=Q.length>0?"\x1B[0m":"";K.push(J+G),J=(Q.length>0?Q.join(""):"")+F,j=B,Y=-1,U=0,_=[]}else if(V&&F===" ")J+=F,j+=B,Y=J.length-1,U=j,_=[...Q];else J+=F,j+=B;H+=F.length}if(J.length>0){if(J.replace(/[\x1b\x9b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]/g,"").length>0||J.length>0)K.push(J)}else K.push("");return{lines:K,activeStyles:Q}}function Az(z){return Object.freeze({heading1:(V)=>z.bold(z.underline(V)),heading2:(V)=>z.bold(V),heading3:(V)=>z.bold(z.yellow(V)),heading4:(V)=>z.yellow(V),heading5:(V)=>z.dim(z.yellow(V)),heading6:(V)=>z.dim(V),text:(V)=>V,emphasis:(V)=>z.italic(V),strong:(V)=>z.bold(V),strongEmphasis:(V)=>z.bold(z.italic(V)),strikethrough:(V)=>z.strikethrough(V),inlineCode:(V)=>z.cyan(V),linkText:(V)=>z.blue(z.underline(V)),linkUrl:(V)=>z.dim(z.underline(V)),autolink:(V)=>z.blue(z.underline(V)),blockquoteMarker:(V)=>z.dim(z.green(V)),blockquoteText:(V)=>z.italic(V),listMarker:(V)=>z.dim(V),orderedListMarker:(V)=>z.dim(V),taskChecked:(V)=>z.green(V),taskUnchecked:(V)=>z.dim(V),codeFence:(V)=>z.dim(V),codeInfo:(V)=>z.dim(z.italic(V)),codeText:(V)=>z.cyan(V),thematicBreak:(V)=>z.dim(V),tableHeader:(V)=>z.bold(V),tableCell:(V)=>V,tableBorder:(V)=>z.dim(V),imageAltText:(V)=>z.italic(z.magenta(V)),imageUrl:(V)=>z.dim(z.underline(V))})}function Sz(z){let Z=Jz(z?.style),V=Az(Z),$=z?.overrides;if(!$)return V;let Q={heading1:$.heading1??V.heading1,heading2:$.heading2??V.heading2,heading3:$.heading3??V.heading3,heading4:$.heading4??V.heading4,heading5:$.heading5??V.heading5,heading6:$.heading6??V.heading6,text:$.text??V.text,emphasis:$.emphasis??V.emphasis,strong:$.strong??V.strong,strongEmphasis:$.strongEmphasis??V.strongEmphasis,strikethrough:$.strikethrough??V.strikethrough,inlineCode:$.inlineCode??V.inlineCode,linkText:$.linkText??V.linkText,linkUrl:$.linkUrl??V.linkUrl,autolink:$.autolink??V.autolink,blockquoteMarker:$.blockquoteMarker??V.blockquoteMarker,blockquoteText:$.blockquoteText??V.blockquoteText,listMarker:$.listMarker??V.listMarker,orderedListMarker:$.orderedListMarker??V.orderedListMarker,taskChecked:$.taskChecked??V.taskChecked,taskUnchecked:$.taskUnchecked??V.taskUnchecked,codeFence:$.codeFence??V.codeFence,codeInfo:$.codeInfo??V.codeInfo,codeText:$.codeText??V.codeText,thematicBreak:$.thematicBreak??V.thematicBreak,tableHeader:$.tableHeader??V.tableHeader,tableCell:$.tableCell??V.tableCell,tableBorder:$.tableBorder??V.tableBorder,imageAltText:$.imageAltText??V.imageAltText,imageUrl:$.imageUrl??V.imageUrl};return Object.freeze(Q)}var nV=Sz();export{C as yellowCode,oz as yellow,cV as wrapText,g as whiteCode,zV as white,D as visibleWidth,uz as unorderedList,A as underlineCode,bV as underline,hz as taskList,nz as table,wV as style,Xz as stripAnsi,T as strikethroughCode,mV as strikethrough,Bz as rgbCode,Mz as rgb,Dz as resolveTrueColor,jz as resolveCapability,Nz as reset,f as redCode,sz as red,Hz as parseHex,Oz as padStart,Uz as padEnd,xz as orderedList,S as magentaCode,tz as magenta,L as italicCode,gV as italic,I as inverseCode,yV as inverse,N as hiddenCode,vV as hidden,fz as hexCode,Ez as hex,W as greenCode,az as green,b as grayCode,VV as gray,R as dimCode,PV as dim,nV as defaultTheme,P as cyanCode,ez as cyan,Jz as createStyle,Sz as createMarkdownTheme,lz as composeStyles,_z as center,Az as buildDefaultMarkdownTheme,m as brightYellowCode,QV as brightYellow,p as brightWhiteCode,XV as brightWhite,y as brightRedCode,ZV as brightRed,x as brightMagentaCode,JV as brightMagenta,v as brightGreenCode,$V as brightGreen,h as brightCyanCode,KV as brightCyan,u as brightBlueCode,jV as brightBlue,E as boldCode,SV as bold,w as blueCode,iz as blue,k as blackCode,rz as black,l as bgYellowCode,_V as bgYellow,o as bgWhiteCode,BV as bgWhite,Gz as bgRgbCode,qz as bgRgb,d as bgRedCode,OV as bgRed,s as bgMagentaCode,FV as bgMagenta,Wz as bgHexCode,Rz as bgHex,n as bgGreenCode,UV as bgGreen,a as bgCyanCode,HV as bgCyan,zz as bgBrightYellowCode,EV as bgBrightYellow,Qz as bgBrightWhiteCode,IV as bgBrightWhite,t as bgBrightRedCode,MV as bgBrightRed,Zz as bgBrightMagentaCode,LV as bgBrightMagenta,e as bgBrightGreenCode,qV as bgBrightGreen,$z as bgBrightCyanCode,AV as bgBrightCyan,Vz as bgBrightBlueCode,RV as bgBrightBlue,i as bgBrightBlackCode,GV as bgBrightBlack,r as bgBlueCode,DV as bgBlue,c as bgBlackCode,YV as bgBlack,X as applyStyle};
|