@cjser/chalk 5.6.2-cjser.2
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-cjser/index.cjs +561 -0
- package/license +9 -0
- package/package.json +109 -0
- package/readme.md +302 -0
- package/source/index.d.ts +325 -0
- package/source/index.js +225 -0
- package/source/utilities.js +33 -0
- package/source/vendor/ansi-styles/index.d.ts +236 -0
- package/source/vendor/ansi-styles/index.js +223 -0
- package/source/vendor/supports-color/browser.d.ts +1 -0
- package/source/vendor/supports-color/browser.js +34 -0
- package/source/vendor/supports-color/index.d.ts +55 -0
- package/source/vendor/supports-color/index.js +190 -0
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// packages/@cjser/chalk/source/index.js
|
|
30
|
+
var index_exports = {};
|
|
31
|
+
__export(index_exports, {
|
|
32
|
+
Chalk: () => Chalk,
|
|
33
|
+
backgroundColorNames: () => backgroundColorNames,
|
|
34
|
+
backgroundColors: () => backgroundColorNames,
|
|
35
|
+
chalkStderr: () => chalkStderr,
|
|
36
|
+
colorNames: () => colorNames,
|
|
37
|
+
colors: () => colorNames,
|
|
38
|
+
default: () => index_default,
|
|
39
|
+
foregroundColorNames: () => foregroundColorNames,
|
|
40
|
+
foregroundColors: () => foregroundColorNames,
|
|
41
|
+
modifierNames: () => modifierNames,
|
|
42
|
+
modifiers: () => modifierNames,
|
|
43
|
+
supportsColor: () => stdoutColor,
|
|
44
|
+
supportsColorStderr: () => stderrColor
|
|
45
|
+
});
|
|
46
|
+
module.exports = __toCommonJS(index_exports);
|
|
47
|
+
|
|
48
|
+
// packages/@cjser/chalk/source/vendor/ansi-styles/index.js
|
|
49
|
+
var ANSI_BACKGROUND_OFFSET = 10;
|
|
50
|
+
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
51
|
+
var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
|
52
|
+
var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
|
|
53
|
+
var styles = {
|
|
54
|
+
modifier: {
|
|
55
|
+
reset: [0, 0],
|
|
56
|
+
// 21 isn't widely supported and 22 does the same thing
|
|
57
|
+
bold: [1, 22],
|
|
58
|
+
dim: [2, 22],
|
|
59
|
+
italic: [3, 23],
|
|
60
|
+
underline: [4, 24],
|
|
61
|
+
overline: [53, 55],
|
|
62
|
+
inverse: [7, 27],
|
|
63
|
+
hidden: [8, 28],
|
|
64
|
+
strikethrough: [9, 29]
|
|
65
|
+
},
|
|
66
|
+
color: {
|
|
67
|
+
black: [30, 39],
|
|
68
|
+
red: [31, 39],
|
|
69
|
+
green: [32, 39],
|
|
70
|
+
yellow: [33, 39],
|
|
71
|
+
blue: [34, 39],
|
|
72
|
+
magenta: [35, 39],
|
|
73
|
+
cyan: [36, 39],
|
|
74
|
+
white: [37, 39],
|
|
75
|
+
// Bright color
|
|
76
|
+
blackBright: [90, 39],
|
|
77
|
+
gray: [90, 39],
|
|
78
|
+
// Alias of `blackBright`
|
|
79
|
+
grey: [90, 39],
|
|
80
|
+
// Alias of `blackBright`
|
|
81
|
+
redBright: [91, 39],
|
|
82
|
+
greenBright: [92, 39],
|
|
83
|
+
yellowBright: [93, 39],
|
|
84
|
+
blueBright: [94, 39],
|
|
85
|
+
magentaBright: [95, 39],
|
|
86
|
+
cyanBright: [96, 39],
|
|
87
|
+
whiteBright: [97, 39]
|
|
88
|
+
},
|
|
89
|
+
bgColor: {
|
|
90
|
+
bgBlack: [40, 49],
|
|
91
|
+
bgRed: [41, 49],
|
|
92
|
+
bgGreen: [42, 49],
|
|
93
|
+
bgYellow: [43, 49],
|
|
94
|
+
bgBlue: [44, 49],
|
|
95
|
+
bgMagenta: [45, 49],
|
|
96
|
+
bgCyan: [46, 49],
|
|
97
|
+
bgWhite: [47, 49],
|
|
98
|
+
// Bright color
|
|
99
|
+
bgBlackBright: [100, 49],
|
|
100
|
+
bgGray: [100, 49],
|
|
101
|
+
// Alias of `bgBlackBright`
|
|
102
|
+
bgGrey: [100, 49],
|
|
103
|
+
// Alias of `bgBlackBright`
|
|
104
|
+
bgRedBright: [101, 49],
|
|
105
|
+
bgGreenBright: [102, 49],
|
|
106
|
+
bgYellowBright: [103, 49],
|
|
107
|
+
bgBlueBright: [104, 49],
|
|
108
|
+
bgMagentaBright: [105, 49],
|
|
109
|
+
bgCyanBright: [106, 49],
|
|
110
|
+
bgWhiteBright: [107, 49]
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
var modifierNames = Object.keys(styles.modifier);
|
|
114
|
+
var foregroundColorNames = Object.keys(styles.color);
|
|
115
|
+
var backgroundColorNames = Object.keys(styles.bgColor);
|
|
116
|
+
var colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
|
117
|
+
function assembleStyles() {
|
|
118
|
+
const codes = /* @__PURE__ */ new Map();
|
|
119
|
+
for (const [groupName, group] of Object.entries(styles)) {
|
|
120
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
121
|
+
styles[styleName] = {
|
|
122
|
+
open: `\x1B[${style[0]}m`,
|
|
123
|
+
close: `\x1B[${style[1]}m`
|
|
124
|
+
};
|
|
125
|
+
group[styleName] = styles[styleName];
|
|
126
|
+
codes.set(style[0], style[1]);
|
|
127
|
+
}
|
|
128
|
+
Object.defineProperty(styles, groupName, {
|
|
129
|
+
value: group,
|
|
130
|
+
enumerable: false
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
Object.defineProperty(styles, "codes", {
|
|
134
|
+
value: codes,
|
|
135
|
+
enumerable: false
|
|
136
|
+
});
|
|
137
|
+
styles.color.close = "\x1B[39m";
|
|
138
|
+
styles.bgColor.close = "\x1B[49m";
|
|
139
|
+
styles.color.ansi = wrapAnsi16();
|
|
140
|
+
styles.color.ansi256 = wrapAnsi256();
|
|
141
|
+
styles.color.ansi16m = wrapAnsi16m();
|
|
142
|
+
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
143
|
+
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
144
|
+
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
145
|
+
Object.defineProperties(styles, {
|
|
146
|
+
rgbToAnsi256: {
|
|
147
|
+
value(red, green, blue) {
|
|
148
|
+
if (red === green && green === blue) {
|
|
149
|
+
if (red < 8) {
|
|
150
|
+
return 16;
|
|
151
|
+
}
|
|
152
|
+
if (red > 248) {
|
|
153
|
+
return 231;
|
|
154
|
+
}
|
|
155
|
+
return Math.round((red - 8) / 247 * 24) + 232;
|
|
156
|
+
}
|
|
157
|
+
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
|
158
|
+
},
|
|
159
|
+
enumerable: false
|
|
160
|
+
},
|
|
161
|
+
hexToRgb: {
|
|
162
|
+
value(hex) {
|
|
163
|
+
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
164
|
+
if (!matches) {
|
|
165
|
+
return [0, 0, 0];
|
|
166
|
+
}
|
|
167
|
+
let [colorString] = matches;
|
|
168
|
+
if (colorString.length === 3) {
|
|
169
|
+
colorString = [...colorString].map((character) => character + character).join("");
|
|
170
|
+
}
|
|
171
|
+
const integer = Number.parseInt(colorString, 16);
|
|
172
|
+
return [
|
|
173
|
+
/* eslint-disable no-bitwise */
|
|
174
|
+
integer >> 16 & 255,
|
|
175
|
+
integer >> 8 & 255,
|
|
176
|
+
integer & 255
|
|
177
|
+
/* eslint-enable no-bitwise */
|
|
178
|
+
];
|
|
179
|
+
},
|
|
180
|
+
enumerable: false
|
|
181
|
+
},
|
|
182
|
+
hexToAnsi256: {
|
|
183
|
+
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
184
|
+
enumerable: false
|
|
185
|
+
},
|
|
186
|
+
ansi256ToAnsi: {
|
|
187
|
+
value(code) {
|
|
188
|
+
if (code < 8) {
|
|
189
|
+
return 30 + code;
|
|
190
|
+
}
|
|
191
|
+
if (code < 16) {
|
|
192
|
+
return 90 + (code - 8);
|
|
193
|
+
}
|
|
194
|
+
let red;
|
|
195
|
+
let green;
|
|
196
|
+
let blue;
|
|
197
|
+
if (code >= 232) {
|
|
198
|
+
red = ((code - 232) * 10 + 8) / 255;
|
|
199
|
+
green = red;
|
|
200
|
+
blue = red;
|
|
201
|
+
} else {
|
|
202
|
+
code -= 16;
|
|
203
|
+
const remainder = code % 36;
|
|
204
|
+
red = Math.floor(code / 36) / 5;
|
|
205
|
+
green = Math.floor(remainder / 6) / 5;
|
|
206
|
+
blue = remainder % 6 / 5;
|
|
207
|
+
}
|
|
208
|
+
const value = Math.max(red, green, blue) * 2;
|
|
209
|
+
if (value === 0) {
|
|
210
|
+
return 30;
|
|
211
|
+
}
|
|
212
|
+
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
|
213
|
+
if (value === 2) {
|
|
214
|
+
result += 60;
|
|
215
|
+
}
|
|
216
|
+
return result;
|
|
217
|
+
},
|
|
218
|
+
enumerable: false
|
|
219
|
+
},
|
|
220
|
+
rgbToAnsi: {
|
|
221
|
+
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
222
|
+
enumerable: false
|
|
223
|
+
},
|
|
224
|
+
hexToAnsi: {
|
|
225
|
+
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
226
|
+
enumerable: false
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
return styles;
|
|
230
|
+
}
|
|
231
|
+
var ansiStyles = assembleStyles();
|
|
232
|
+
var ansi_styles_default = ansiStyles;
|
|
233
|
+
|
|
234
|
+
// packages/@cjser/chalk/source/vendor/supports-color/index.js
|
|
235
|
+
var import_node_process = __toESM(require("node:process"), 1);
|
|
236
|
+
var import_node_os = __toESM(require("node:os"), 1);
|
|
237
|
+
var import_node_tty = __toESM(require("node:tty"), 1);
|
|
238
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
|
|
239
|
+
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
240
|
+
const position = argv.indexOf(prefix + flag);
|
|
241
|
+
const terminatorPosition = argv.indexOf("--");
|
|
242
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
243
|
+
}
|
|
244
|
+
var { env } = import_node_process.default;
|
|
245
|
+
var flagForceColor;
|
|
246
|
+
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
247
|
+
flagForceColor = 0;
|
|
248
|
+
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
249
|
+
flagForceColor = 1;
|
|
250
|
+
}
|
|
251
|
+
function envForceColor() {
|
|
252
|
+
if ("FORCE_COLOR" in env) {
|
|
253
|
+
if (env.FORCE_COLOR === "true") {
|
|
254
|
+
return 1;
|
|
255
|
+
}
|
|
256
|
+
if (env.FORCE_COLOR === "false") {
|
|
257
|
+
return 0;
|
|
258
|
+
}
|
|
259
|
+
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function translateLevel(level) {
|
|
263
|
+
if (level === 0) {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
return {
|
|
267
|
+
level,
|
|
268
|
+
hasBasic: true,
|
|
269
|
+
has256: level >= 2,
|
|
270
|
+
has16m: level >= 3
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
274
|
+
const noFlagForceColor = envForceColor();
|
|
275
|
+
if (noFlagForceColor !== void 0) {
|
|
276
|
+
flagForceColor = noFlagForceColor;
|
|
277
|
+
}
|
|
278
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
279
|
+
if (forceColor === 0) {
|
|
280
|
+
return 0;
|
|
281
|
+
}
|
|
282
|
+
if (sniffFlags) {
|
|
283
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
284
|
+
return 3;
|
|
285
|
+
}
|
|
286
|
+
if (hasFlag("color=256")) {
|
|
287
|
+
return 2;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
if ("TF_BUILD" in env && "AGENT_NAME" in env) {
|
|
291
|
+
return 1;
|
|
292
|
+
}
|
|
293
|
+
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
294
|
+
return 0;
|
|
295
|
+
}
|
|
296
|
+
const min = forceColor || 0;
|
|
297
|
+
if (env.TERM === "dumb") {
|
|
298
|
+
return min;
|
|
299
|
+
}
|
|
300
|
+
if (import_node_process.default.platform === "win32") {
|
|
301
|
+
const osRelease = import_node_os.default.release().split(".");
|
|
302
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
303
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
304
|
+
}
|
|
305
|
+
return 1;
|
|
306
|
+
}
|
|
307
|
+
if ("CI" in env) {
|
|
308
|
+
if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
|
|
309
|
+
return 3;
|
|
310
|
+
}
|
|
311
|
+
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
312
|
+
return 1;
|
|
313
|
+
}
|
|
314
|
+
return min;
|
|
315
|
+
}
|
|
316
|
+
if ("TEAMCITY_VERSION" in env) {
|
|
317
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
318
|
+
}
|
|
319
|
+
if (env.COLORTERM === "truecolor") {
|
|
320
|
+
return 3;
|
|
321
|
+
}
|
|
322
|
+
if (env.TERM === "xterm-kitty") {
|
|
323
|
+
return 3;
|
|
324
|
+
}
|
|
325
|
+
if (env.TERM === "xterm-ghostty") {
|
|
326
|
+
return 3;
|
|
327
|
+
}
|
|
328
|
+
if (env.TERM === "wezterm") {
|
|
329
|
+
return 3;
|
|
330
|
+
}
|
|
331
|
+
if ("TERM_PROGRAM" in env) {
|
|
332
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
333
|
+
switch (env.TERM_PROGRAM) {
|
|
334
|
+
case "iTerm.app": {
|
|
335
|
+
return version >= 3 ? 3 : 2;
|
|
336
|
+
}
|
|
337
|
+
case "Apple_Terminal": {
|
|
338
|
+
return 2;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
343
|
+
return 2;
|
|
344
|
+
}
|
|
345
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
346
|
+
return 1;
|
|
347
|
+
}
|
|
348
|
+
if ("COLORTERM" in env) {
|
|
349
|
+
return 1;
|
|
350
|
+
}
|
|
351
|
+
return min;
|
|
352
|
+
}
|
|
353
|
+
function createSupportsColor(stream, options = {}) {
|
|
354
|
+
const level = _supportsColor(stream, {
|
|
355
|
+
streamIsTTY: stream && stream.isTTY,
|
|
356
|
+
...options
|
|
357
|
+
});
|
|
358
|
+
return translateLevel(level);
|
|
359
|
+
}
|
|
360
|
+
var supportsColor = {
|
|
361
|
+
stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
|
|
362
|
+
stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
|
|
363
|
+
};
|
|
364
|
+
var supports_color_default = supportsColor;
|
|
365
|
+
|
|
366
|
+
// packages/@cjser/chalk/source/utilities.js
|
|
367
|
+
function stringReplaceAll(string, substring, replacer) {
|
|
368
|
+
let index = string.indexOf(substring);
|
|
369
|
+
if (index === -1) {
|
|
370
|
+
return string;
|
|
371
|
+
}
|
|
372
|
+
const substringLength = substring.length;
|
|
373
|
+
let endIndex = 0;
|
|
374
|
+
let returnValue = "";
|
|
375
|
+
do {
|
|
376
|
+
returnValue += string.slice(endIndex, index) + substring + replacer;
|
|
377
|
+
endIndex = index + substringLength;
|
|
378
|
+
index = string.indexOf(substring, endIndex);
|
|
379
|
+
} while (index !== -1);
|
|
380
|
+
returnValue += string.slice(endIndex);
|
|
381
|
+
return returnValue;
|
|
382
|
+
}
|
|
383
|
+
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
384
|
+
let endIndex = 0;
|
|
385
|
+
let returnValue = "";
|
|
386
|
+
do {
|
|
387
|
+
const gotCR = string[index - 1] === "\r";
|
|
388
|
+
returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
389
|
+
endIndex = index + 1;
|
|
390
|
+
index = string.indexOf("\n", endIndex);
|
|
391
|
+
} while (index !== -1);
|
|
392
|
+
returnValue += string.slice(endIndex);
|
|
393
|
+
return returnValue;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// packages/@cjser/chalk/source/index.js
|
|
397
|
+
var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
|
|
398
|
+
var GENERATOR = /* @__PURE__ */ Symbol("GENERATOR");
|
|
399
|
+
var STYLER = /* @__PURE__ */ Symbol("STYLER");
|
|
400
|
+
var IS_EMPTY = /* @__PURE__ */ Symbol("IS_EMPTY");
|
|
401
|
+
var levelMapping = [
|
|
402
|
+
"ansi",
|
|
403
|
+
"ansi",
|
|
404
|
+
"ansi256",
|
|
405
|
+
"ansi16m"
|
|
406
|
+
];
|
|
407
|
+
var styles2 = /* @__PURE__ */ Object.create(null);
|
|
408
|
+
var applyOptions = (object, options = {}) => {
|
|
409
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
410
|
+
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
411
|
+
}
|
|
412
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
413
|
+
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
414
|
+
};
|
|
415
|
+
var Chalk = class {
|
|
416
|
+
constructor(options) {
|
|
417
|
+
return chalkFactory(options);
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
var chalkFactory = (options) => {
|
|
421
|
+
const chalk2 = (...strings) => strings.join(" ");
|
|
422
|
+
applyOptions(chalk2, options);
|
|
423
|
+
Object.setPrototypeOf(chalk2, createChalk.prototype);
|
|
424
|
+
return chalk2;
|
|
425
|
+
};
|
|
426
|
+
function createChalk(options) {
|
|
427
|
+
return chalkFactory(options);
|
|
428
|
+
}
|
|
429
|
+
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
430
|
+
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
|
431
|
+
styles2[styleName] = {
|
|
432
|
+
get() {
|
|
433
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
434
|
+
Object.defineProperty(this, styleName, { value: builder });
|
|
435
|
+
return builder;
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
styles2.visible = {
|
|
440
|
+
get() {
|
|
441
|
+
const builder = createBuilder(this, this[STYLER], true);
|
|
442
|
+
Object.defineProperty(this, "visible", { value: builder });
|
|
443
|
+
return builder;
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
var getModelAnsi = (model, level, type, ...arguments_) => {
|
|
447
|
+
if (model === "rgb") {
|
|
448
|
+
if (level === "ansi16m") {
|
|
449
|
+
return ansi_styles_default[type].ansi16m(...arguments_);
|
|
450
|
+
}
|
|
451
|
+
if (level === "ansi256") {
|
|
452
|
+
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
|
|
453
|
+
}
|
|
454
|
+
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
|
|
455
|
+
}
|
|
456
|
+
if (model === "hex") {
|
|
457
|
+
return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
|
|
458
|
+
}
|
|
459
|
+
return ansi_styles_default[type][model](...arguments_);
|
|
460
|
+
};
|
|
461
|
+
var usedModels = ["rgb", "hex", "ansi256"];
|
|
462
|
+
for (const model of usedModels) {
|
|
463
|
+
styles2[model] = {
|
|
464
|
+
get() {
|
|
465
|
+
const { level } = this;
|
|
466
|
+
return function(...arguments_) {
|
|
467
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
|
|
468
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
473
|
+
styles2[bgModel] = {
|
|
474
|
+
get() {
|
|
475
|
+
const { level } = this;
|
|
476
|
+
return function(...arguments_) {
|
|
477
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
|
|
478
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
var proto = Object.defineProperties(() => {
|
|
484
|
+
}, {
|
|
485
|
+
...styles2,
|
|
486
|
+
level: {
|
|
487
|
+
enumerable: true,
|
|
488
|
+
get() {
|
|
489
|
+
return this[GENERATOR].level;
|
|
490
|
+
},
|
|
491
|
+
set(level) {
|
|
492
|
+
this[GENERATOR].level = level;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
var createStyler = (open, close, parent) => {
|
|
497
|
+
let openAll;
|
|
498
|
+
let closeAll;
|
|
499
|
+
if (parent === void 0) {
|
|
500
|
+
openAll = open;
|
|
501
|
+
closeAll = close;
|
|
502
|
+
} else {
|
|
503
|
+
openAll = parent.openAll + open;
|
|
504
|
+
closeAll = close + parent.closeAll;
|
|
505
|
+
}
|
|
506
|
+
return {
|
|
507
|
+
open,
|
|
508
|
+
close,
|
|
509
|
+
openAll,
|
|
510
|
+
closeAll,
|
|
511
|
+
parent
|
|
512
|
+
};
|
|
513
|
+
};
|
|
514
|
+
var createBuilder = (self, _styler, _isEmpty) => {
|
|
515
|
+
const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
516
|
+
Object.setPrototypeOf(builder, proto);
|
|
517
|
+
builder[GENERATOR] = self;
|
|
518
|
+
builder[STYLER] = _styler;
|
|
519
|
+
builder[IS_EMPTY] = _isEmpty;
|
|
520
|
+
return builder;
|
|
521
|
+
};
|
|
522
|
+
var applyStyle = (self, string) => {
|
|
523
|
+
if (self.level <= 0 || !string) {
|
|
524
|
+
return self[IS_EMPTY] ? "" : string;
|
|
525
|
+
}
|
|
526
|
+
let styler = self[STYLER];
|
|
527
|
+
if (styler === void 0) {
|
|
528
|
+
return string;
|
|
529
|
+
}
|
|
530
|
+
const { openAll, closeAll } = styler;
|
|
531
|
+
if (string.includes("\x1B")) {
|
|
532
|
+
while (styler !== void 0) {
|
|
533
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
|
534
|
+
styler = styler.parent;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
const lfIndex = string.indexOf("\n");
|
|
538
|
+
if (lfIndex !== -1) {
|
|
539
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
540
|
+
}
|
|
541
|
+
return openAll + string + closeAll;
|
|
542
|
+
};
|
|
543
|
+
Object.defineProperties(createChalk.prototype, styles2);
|
|
544
|
+
var chalk = createChalk();
|
|
545
|
+
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
546
|
+
var index_default = chalk;
|
|
547
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
548
|
+
0 && (module.exports = {
|
|
549
|
+
Chalk,
|
|
550
|
+
backgroundColorNames,
|
|
551
|
+
backgroundColors,
|
|
552
|
+
chalkStderr,
|
|
553
|
+
colorNames,
|
|
554
|
+
colors,
|
|
555
|
+
foregroundColorNames,
|
|
556
|
+
foregroundColors,
|
|
557
|
+
modifierNames,
|
|
558
|
+
modifiers,
|
|
559
|
+
supportsColor,
|
|
560
|
+
supportsColorStderr
|
|
561
|
+
});
|
package/license
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cjser/chalk",
|
|
3
|
+
"version": "5.6.2-cjser.2",
|
|
4
|
+
"description": "Terminal string styling done right",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://code.moenext.com/3rdeye/cjser.git"
|
|
9
|
+
},
|
|
10
|
+
"funding": "https://github.com/chalk/chalk?sponsor=1",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "./dist-cjser/index.cjs",
|
|
13
|
+
"exports": {
|
|
14
|
+
"require": "./dist-cjser/index.cjs",
|
|
15
|
+
"default": "./source/index.js"
|
|
16
|
+
},
|
|
17
|
+
"imports": {
|
|
18
|
+
"#ansi-styles": "./source/vendor/ansi-styles/index.js",
|
|
19
|
+
"#supports-color": {
|
|
20
|
+
"node": "./source/vendor/supports-color/index.js",
|
|
21
|
+
"default": "./source/vendor/supports-color/browser.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"types": "./source/index.d.ts",
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": "^12.17.0 || ^14.13 || >=16.0.0"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"test": "xo && c8 ava && tsd",
|
|
31
|
+
"bench": "matcha benchmark.js"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"source",
|
|
35
|
+
"!source/index.test-d.ts",
|
|
36
|
+
"dist-cjser"
|
|
37
|
+
],
|
|
38
|
+
"keywords": [
|
|
39
|
+
"color",
|
|
40
|
+
"colour",
|
|
41
|
+
"colors",
|
|
42
|
+
"terminal",
|
|
43
|
+
"console",
|
|
44
|
+
"cli",
|
|
45
|
+
"string",
|
|
46
|
+
"ansi",
|
|
47
|
+
"style",
|
|
48
|
+
"styles",
|
|
49
|
+
"tty",
|
|
50
|
+
"formatting",
|
|
51
|
+
"rgb",
|
|
52
|
+
"256",
|
|
53
|
+
"shell",
|
|
54
|
+
"xterm",
|
|
55
|
+
"log",
|
|
56
|
+
"logging",
|
|
57
|
+
"command-line",
|
|
58
|
+
"text"
|
|
59
|
+
],
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@types/node": "^16.11.10",
|
|
62
|
+
"ava": "^3.15.0",
|
|
63
|
+
"c8": "^7.10.0",
|
|
64
|
+
"color-convert": "^2.0.1",
|
|
65
|
+
"execa": "^6.0.0",
|
|
66
|
+
"log-update": "^5.0.0",
|
|
67
|
+
"matcha": "^0.7.0",
|
|
68
|
+
"tsd": "^0.19.0",
|
|
69
|
+
"xo": "^0.57.0",
|
|
70
|
+
"yoctodelay": "^2.0.0"
|
|
71
|
+
},
|
|
72
|
+
"xo": {
|
|
73
|
+
"rules": {
|
|
74
|
+
"unicorn/prefer-string-slice": "off",
|
|
75
|
+
"@typescript-eslint/consistent-type-imports": "off",
|
|
76
|
+
"@typescript-eslint/consistent-type-exports": "off",
|
|
77
|
+
"@typescript-eslint/consistent-type-definitions": "off",
|
|
78
|
+
"unicorn/expiring-todo-comments": "off"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"c8": {
|
|
82
|
+
"reporter": [
|
|
83
|
+
"text",
|
|
84
|
+
"lcov"
|
|
85
|
+
],
|
|
86
|
+
"exclude": [
|
|
87
|
+
"source/vendor"
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
"cjser": {
|
|
91
|
+
"sourceVersion": "5.6.2",
|
|
92
|
+
"cjserVersion": 2,
|
|
93
|
+
"original": {
|
|
94
|
+
"name": "chalk",
|
|
95
|
+
"version": "5.6.2",
|
|
96
|
+
"main": "./source/index.js",
|
|
97
|
+
"exports": "./source/index.js",
|
|
98
|
+
"repository": "chalk/chalk",
|
|
99
|
+
"files": [
|
|
100
|
+
"source",
|
|
101
|
+
"!source/index.test-d.ts"
|
|
102
|
+
],
|
|
103
|
+
"scripts": {
|
|
104
|
+
"test": "xo && c8 ava && tsd",
|
|
105
|
+
"bench": "matcha benchmark.js"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|