stain 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -229,7 +229,6 @@ console.log(' ' + stain.underline.yellow.bold(`stain.underline.yellow.bold${stai
229
229
  -->
230
230
 
231
231
 
232
-
233
232
  <br />
234
233
 
235
234
  ## Development/Contributing
@@ -1,5 +1,28 @@
1
+ /** @about
2
+ @file: constants.ts
3
+
4
+ import {
5
+ ESC,
6
+ RESET,
7
+ ANSI,
8
+ XTERM,
9
+ COLORS,
10
+ ANSI_TUPLE,
11
+ } from './constants.ts';
12
+
13
+ *** */
14
+ import type { TupleN } from './types.ts';
15
+ /**
16
+ * ansi escape prefix character
17
+ */
1
18
  export declare const ESC = "\u001B";
19
+ /**
20
+ * ansi reset sequence
21
+ */
2
22
  export declare const RESET = "\u001B[0m";
23
+ /**
24
+ * basic ansi color codes for standard and intense variants
25
+ */
3
26
  export declare const ANSI: {
4
27
  black: number;
5
28
  iblack: number;
@@ -18,9 +41,15 @@ export declare const ANSI: {
18
41
  white: number;
19
42
  iwhite: number;
20
43
  };
44
+ /**
45
+ * xterm 256 color map with keys x0..x255
46
+ */
21
47
  export declare const XTERM: {
22
48
  [k: string]: number;
23
49
  };
50
+ /**
51
+ * merged color map including ansi and xterm
52
+ */
24
53
  export declare const COLORS: {
25
54
  black: number;
26
55
  iblack: number;
@@ -39,17 +68,5 @@ export declare const COLORS: {
39
68
  white: number;
40
69
  iwhite: number;
41
70
  };
42
- /**
43
- * color support level
44
- * @default 3
45
- * @see {@link https://nodejs.org/api/cli.html#force_color1-2-3|Node.js FORCE_COLOR docs}
46
- */
47
- type ColorSpace = 0 | 1;
48
- /**
49
- * COLOR_SPACE - covers all reasonable and most un-reasonable cases
50
- * @implements nodejs.org/api/cli.html#force_color1-2-3
51
- * 0=no-color, 1=16, 2=256, 3=true-color
52
- */
53
- export declare const COLOR_SPACE: ColorSpace;
54
- export {};
71
+ export declare const ANSI_TUPLE: TupleN<16, TupleN<3, number>>;
55
72
  //# sourceMappingURL=constants.d.ts.map
@@ -1,5 +1,28 @@
1
+ /** @about
2
+ @file: constants.ts
3
+
4
+ import {
5
+ ESC,
6
+ RESET,
7
+ ANSI,
8
+ XTERM,
9
+ COLORS,
10
+ ANSI_TUPLE,
11
+ } from './constants.ts';
12
+
13
+ *** */
14
+ import type { TupleN } from './types.ts';
15
+ /**
16
+ * ansi escape prefix character
17
+ */
1
18
  export declare const ESC = "\u001B";
19
+ /**
20
+ * ansi reset sequence
21
+ */
2
22
  export declare const RESET = "\u001B[0m";
23
+ /**
24
+ * basic ansi color codes for standard and intense variants
25
+ */
3
26
  export declare const ANSI: {
4
27
  black: number;
5
28
  iblack: number;
@@ -18,9 +41,15 @@ export declare const ANSI: {
18
41
  white: number;
19
42
  iwhite: number;
20
43
  };
44
+ /**
45
+ * xterm 256 color map with keys x0..x255
46
+ */
21
47
  export declare const XTERM: {
22
48
  [k: string]: number;
23
49
  };
50
+ /**
51
+ * merged color map including ansi and xterm
52
+ */
24
53
  export declare const COLORS: {
25
54
  black: number;
26
55
  iblack: number;
@@ -39,17 +68,5 @@ export declare const COLORS: {
39
68
  white: number;
40
69
  iwhite: number;
41
70
  };
42
- /**
43
- * color support level
44
- * @default 3
45
- * @see {@link https://nodejs.org/api/cli.html#force_color1-2-3|Node.js FORCE_COLOR docs}
46
- */
47
- type ColorSpace = 0 | 1;
48
- /**
49
- * COLOR_SPACE - covers all reasonable and most un-reasonable cases
50
- * @implements nodejs.org/api/cli.html#force_color1-2-3
51
- * 0=no-color, 1=16, 2=256, 3=true-color
52
- */
53
- export declare const COLOR_SPACE: ColorSpace;
54
- export {};
71
+ export declare const ANSI_TUPLE: TupleN<16, TupleN<3, number>>;
55
72
  //# sourceMappingURL=constants.d.ts.map
@@ -1,5 +1,28 @@
1
+ /** @about
2
+ @file: constants.ts
3
+
4
+ import {
5
+ ESC,
6
+ RESET,
7
+ ANSI,
8
+ XTERM,
9
+ COLORS,
10
+ ANSI_TUPLE,
11
+ } from './constants.ts';
12
+
13
+ *** */
14
+ import type { TupleN } from './types.ts';
15
+ /**
16
+ * ansi escape prefix character
17
+ */
1
18
  export declare const ESC = "\u001B";
19
+ /**
20
+ * ansi reset sequence
21
+ */
2
22
  export declare const RESET = "\u001B[0m";
23
+ /**
24
+ * basic ansi color codes for standard and intense variants
25
+ */
3
26
  export declare const ANSI: {
4
27
  black: number;
5
28
  iblack: number;
@@ -18,9 +41,15 @@ export declare const ANSI: {
18
41
  white: number;
19
42
  iwhite: number;
20
43
  };
44
+ /**
45
+ * xterm 256 color map with keys x0..x255
46
+ */
21
47
  export declare const XTERM: {
22
48
  [k: string]: number;
23
49
  };
50
+ /**
51
+ * merged color map including ansi and xterm
52
+ */
24
53
  export declare const COLORS: {
25
54
  black: number;
26
55
  iblack: number;
@@ -39,17 +68,5 @@ export declare const COLORS: {
39
68
  white: number;
40
69
  iwhite: number;
41
70
  };
42
- /**
43
- * color support level
44
- * @default 3
45
- * @see {@link https://nodejs.org/api/cli.html#force_color1-2-3|Node.js FORCE_COLOR docs}
46
- */
47
- type ColorSpace = 0 | 1;
48
- /**
49
- * COLOR_SPACE - covers all reasonable and most un-reasonable cases
50
- * @implements nodejs.org/api/cli.html#force_color1-2-3
51
- * 0=no-color, 1=16, 2=256, 3=true-color
52
- */
53
- export declare const COLOR_SPACE: ColorSpace;
54
- export {};
71
+ export declare const ANSI_TUPLE: TupleN<16, TupleN<3, number>>;
55
72
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,GAAG,WAAW,CAAC;AAC5B,eAAO,MAAM,KAAK,cAAY,CAAC;AAE/B,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;CAiBhB,CAAC;AACF,eAAO,MAAM,KAAK;;CAEjB,CAAC;AACF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;CAAsB,CAAC;AAG1C;;;;GAIG;AACH,KAAK,UAAU,GAAG,CAAC,GAAG,CAAC,CAAC;AAGxB;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,UAgCtB,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;gFAYgF;AAChF,OAAO,KAAK,EACV,MAAM,EACP,MAAM,YAAY,CAAC;AAGpB;;GAEG;AACH,eAAO,MAAM,GAAG,WAAW,CAAC;AAG5B;;GAEG;AACH,eAAO,MAAM,KAAK,cAAY,CAAC;AAG/B;;GAEG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;CAiBhB,CAAC;AAGF;;GAEG;AACH,eAAO,MAAM,KAAK;;CAEjB,CAAC;AAGF;;GAEG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;CAAsB,CAAC;AAE1C,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAiBpD,CAAC"}
package/dist/index.cjs CHANGED
@@ -29,13 +29,14 @@ var __export = (target, all) => {
29
29
  // src/index.ts
30
30
  var exports_src = {};
31
31
  __export(exports_src, {
32
+ xtermTo4Bit: () => xtermTo4Bit,
32
33
  stain: () => stain,
34
+ getColorSpace: () => getColorSpace,
33
35
  default: () => src_default2,
34
36
  createStain: () => createStain,
35
37
  XTERM: () => XTERM,
36
38
  RESET: () => RESET,
37
39
  ESC: () => ESC,
38
- COLOR_SPACE: () => COLOR_SPACE,
39
40
  ANSI: () => ANSI
40
41
  });
41
42
  module.exports = __toCommonJS(exports_src);
@@ -156,6 +157,10 @@ var GLOBAL_THIS2 = /* @__PURE__ */ (() => typeof globalThis === "object" ? globa
156
157
  })(Object);
157
158
  return typeof globalThis === "object" ? globalThis : {};
158
159
  })())();
160
+ var ARGV2 = /* @__PURE__ */ (() => {
161
+ var _a, _b, _c, _d;
162
+ return typeof process === "undefined" ? typeof scriptArgs !== "undefined" ? scriptArgs : [] : (_d = (GLOBAL_THIS2 == null ? undefined : GLOBAL_THIS2["Deno"]) ? (_c = (_a = GLOBAL_THIS2 == null ? undefined : GLOBAL_THIS2["Deno"]) == null ? undefined : _a.args) != null ? _c : ((_b = process["args"]) == null ? undefined : _b.length) ? process["args"] : process["argv"] : process["argv"]) != null ? _d : [];
163
+ })();
159
164
  var ENV2 = /* @__PURE__ */ (() => {
160
165
  var _a, _b, _c, _d;
161
166
  return typeof process === "undefined" ? typeof ((_a = GLOBAL_THIS2 == null ? undefined : GLOBAL_THIS2["std"]) == null ? undefined : _a.getenviron) === "function" ? (_d = (_c = (_b = GLOBAL_THIS2["std"]).getenviron) == null ? undefined : _c.call(_b)) != null ? _d : {} : {} : !(GLOBAL_THIS2 == null ? undefined : GLOBAL_THIS2["Deno"]) ? process["env"] : (() => {
@@ -190,29 +195,88 @@ var ANSI = {
190
195
  };
191
196
  var XTERM = Object.fromEntries(Array(256).fill(0).map((_v, i) => [`x${i}`, i]));
192
197
  var COLORS = { ...ANSI, ...XTERM };
193
- var COLOR_SPACE = /* @__PURE__ */ (() => {
198
+ var ANSI_TUPLE = [
199
+ [0, 0, 0],
200
+ [128, 0, 0],
201
+ [0, 128, 0],
202
+ [128, 128, 0],
203
+ [0, 0, 128],
204
+ [128, 0, 128],
205
+ [0, 128, 128],
206
+ [192, 192, 192],
207
+ [128, 128, 128],
208
+ [255, 0, 0],
209
+ [0, 255, 0],
210
+ [255, 255, 0],
211
+ [0, 0, 255],
212
+ [255, 0, 255],
213
+ [0, 255, 255],
214
+ [255, 255, 255]
215
+ ];
216
+
217
+ // src/utils.ts
218
+ var xtermToRgb = (n) => {
219
+ if (n < 16) {
220
+ return ANSI_TUPLE[n] ?? ANSI_TUPLE[0];
221
+ }
222
+ if (n < 232) {
223
+ n -= 16;
224
+ const reds = [0, 95, 135, 175, 215, 255];
225
+ return [
226
+ reds[Math.floor(n / 36)] ?? 0,
227
+ reds[Math.floor(n % 36 / 6)] ?? 0,
228
+ reds[n % 6] ?? 0
229
+ ];
230
+ }
231
+ const gray = 8 + (n - 232) * 10;
232
+ return [gray, gray, gray];
233
+ };
234
+ var xtermTo4Bit = (n, isBg = 0) => {
235
+ if (n < 16) {
236
+ return (n < 8 ? 40 + n : 100 + (n - 8)) - (isBg ? 0 : 10);
237
+ }
238
+ const [r, g, b] = xtermToRgb(n);
239
+ const ansi = ANSI_TUPLE.map(([sr, sg, sb], idx) => {
240
+ return [
241
+ idx,
242
+ Math.sqrt(Math.pow(r - sr, 2) + Math.pow(g - sg, 2) + Math.pow(b - sb, 2)) * ((!(r === g && g === b) && (sr === sg && sg === sb) ? 2 : 1) + (sg === 0 && sb === 0 && sr > 0 ? 0.1 : 0)) * (idx === 4 || idx === 12 ? r < 50 && g > 100 && g < 200 && b > 200 ? 0.5 : 1 : 1)
243
+ ];
244
+ }).sort((a, b2) => {
245
+ return a[1] - b2[1];
246
+ })[0]?.[0] ?? 0;
247
+ return ansi + (ansi >= 8 ? 82 : 30) + (isBg ? 10 : 0);
248
+ };
249
+ var getColorSpace = (argv = ARGV2, env = ENV2, gthis = globalThis, isTTY = null) => {
194
250
  try {
195
- const reap = src_default();
251
+ const reap = src_default(argv, env, gthis);
196
252
  const forceColor = reap.any("FORCE_COLOR");
197
253
  if (forceColor === "" || forceColor && !isNaN(Number(forceColor)) && Number(forceColor) > 0) {
198
- return 1;
254
+ return 2;
199
255
  }
200
- if (typeof process === "undefined") {
256
+ if (reap.any("NO_COLOR") !== null || reap.any("NODE_DISABLE_COLORS") !== null || /-mono|dumb/i.test(env["TERM"] ?? "")) {
201
257
  return 0;
202
258
  }
203
- if (reap.any("NO_COLOR") !== null || reap.any("NODE_DISABLE_COLORS") !== null || /-mono|dumb/i.test(ENV2["TERM"] ?? "")) {
259
+ if (/^(false|never|no|0)$/i.test(`${reap.opt("color") ?? ""}`.trim())) {
204
260
  return 0;
205
261
  }
206
- if (!(!!process.stdout?.isTTY || !!ENV2["PM2_HOME"] && !!ENV2["pm_id"] || (GLOBAL_THIS2?.["Deno"] ? GLOBAL_THIS2?.["Deno"]?.isatty(1) : !!process.stdout?.isTTY))) {
262
+ if (!!env["PM2_HOME"] && !!env["pm_id"]) {
207
263
  return 0;
208
264
  }
209
- if (/^(false|never|no|0)$/i.test(`${reap.opt("color") ?? ""}`.trim())) {
265
+ if (typeof process === "undefined" && typeof scriptArgs === "undefined") {
210
266
  return 0;
211
267
  }
212
- return 1;
268
+ isTTY = isTTY ?? GLOBAL_THIS2?.["Deno"]?.isatty(1) ?? (typeof process === "undefined" ? null : !!process.stdout?.isTTY);
269
+ if (isTTY === false) {
270
+ return 0;
271
+ }
272
+ const { COLORTERM, TERM, CI } = env;
273
+ if (CI) {
274
+ return 1;
275
+ }
276
+ return COLORTERM === "truecolor" || COLORTERM === "24bit" || TERM && /^xterm-(kitty|direct)$/i.test(TERM) ? 2 : COLORTERM === "ansi256" || COLORTERM === "8bit" || TERM && /-256(colou?r)?$/i.test(TERM) ? 2 : 1;
213
277
  } catch (_err) {}
214
278
  return 0;
215
- })();
279
+ };
216
280
 
217
281
  // src/index.ts
218
282
  var escStain = (str, open, close, fontReplace) => {
@@ -269,15 +333,20 @@ var escStain = (str, open, close, fontReplace) => {
269
333
  return openStr + parts.join("") + closeStr;
270
334
  };
271
335
  var escStainSimple = (str, open, close, _fontReplace) => `${ESC}[${open}m` + (typeof str !== "string" ? String(str) : str) + `${ESC}[${close}m`;
336
+ var _COLOR_SPACE = null;
272
337
  function createStain(opts = {}) {
338
+ if (_COLOR_SPACE === null && opts.noColor === undefined) {
339
+ _COLOR_SPACE = getColorSpace();
340
+ }
273
341
  const {
274
342
  colors,
275
343
  xterm,
276
344
  format = (...args) => args.length > 1 ? args.join(" ") : typeof args[0] !== "string" ? JSON.stringify(args[0]) : args[0],
277
- noColor = COLOR_SPACE === 0,
345
+ colorSpace = _COLOR_SPACE,
346
+ noColor = colorSpace === 0,
278
347
  simpleEscape = false
279
348
  } = opts;
280
- const colorAll = colors ? { ...xterm ? COLORS : ANSI, ...colors } : xterm ? COLORS : ANSI;
349
+ let colorAll = colors ? { ...xterm ? COLORS : ANSI, ...colors } : xterm ? COLORS : ANSI;
281
350
  if (noColor) {
282
351
  const ncFormat = opts?.format ? (...args) => format(...args) : format;
283
352
  for (const prop of Object.keys(colorAll).concat(["bg", "bold", "dim", "normal", "reset", "underline"])) {
@@ -287,6 +356,15 @@ function createStain(opts = {}) {
287
356
  }
288
357
  const escFn = simpleEscape ? escStainSimple : escStain;
289
358
  const color256 = colors ? xterm ? { ...XTERM, ...colors } : colors : xterm ? XTERM : {};
359
+ const force4Bit = xterm && colorSpace === 1;
360
+ if (force4Bit) {
361
+ colorAll = { ...colorAll };
362
+ for (const [key, val] of Object.entries(colorAll)) {
363
+ if (ANSI[key]) {
364
+ colorAll[key] = val - (val >= 90 ? 82 : 30);
365
+ }
366
+ }
367
+ }
290
368
  const colorProxy = (cur = {}) => new Proxy((text) => text, {
291
369
  get: (_target, prop) => {
292
370
  const nxt = { ...cur };
@@ -322,6 +400,14 @@ function createStain(opts = {}) {
322
400
  if (cur.re) {
323
401
  return escFn(res, 0, 0);
324
402
  }
403
+ if (force4Bit && cur?.fg) {
404
+ cur.fg[0] = xtermTo4Bit(cur.fg[0]);
405
+ cur.fg[2] = 0;
406
+ }
407
+ if (force4Bit && cur?.bg) {
408
+ cur.bg[0] = xtermTo4Bit(cur.bg[2] === 0 && cur.bg[0] >= 10 ? cur.bg[0] - 10 : cur.bg[0], 1);
409
+ cur.bg[2] = 0;
410
+ }
325
411
  if (cur.fg) {
326
412
  res = escFn(res, (cur.fg[2] ? "38;5;" : "") + cur.fg[0], cur.fg[1]);
327
413
  }
@@ -342,8 +428,8 @@ function createStain(opts = {}) {
342
428
  });
343
429
  return colorProxy();
344
430
  }
345
- var stain = /* @__PURE__ */ (() => createStain({ xterm: true }))();
431
+ var stain = /* @__PURE__ */ (() => createStain({ xterm: true, noColor: !!getColorSpace() }))();
346
432
  var src_default2 = stain;
347
433
 
348
- //# debugId=8A224414D72D97F164756E2164756E21
434
+ //# debugId=DAB43700023AECAA64756E2164756E21
349
435
  //# sourceMappingURL=index.cjs.map
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../node_modules/cli-reap/dist/index.js", "../node_modules/globables/dist/index.js", "../src/constants.ts", "../src/index.ts"],
3
+ "sources": ["../node_modules/cli-reap/dist/index.js", "../node_modules/globables/dist/index.js", "../src/constants.ts", "../src/utils.ts", "../src/index.ts"],
4
4
  "sourcesContent": [
5
5
  "// node_modules/globables/dist/index.js\nvar GLOBAL_THIS = /* @__PURE__ */ (() => typeof globalThis === \"object\" ? globalThis : (() => {\n (function(Object2) {\n function get() {\n const e = this || self;\n e.globalThis = e, delete Object2.prototype._T_;\n }\n typeof globalThis != \"object\" && (this ? get() : (Object2.defineProperty(Object2.prototype, \"_T_\", { configurable: true, get }), _T_));\n })(Object);\n return typeof globalThis === \"object\" ? globalThis : {};\n})())();\nvar ARGV = /* @__PURE__ */ (() => {\n var _a, _b, _c, _d;\n return typeof process === \"undefined\" ? typeof scriptArgs !== \"undefined\" ? scriptArgs : [] : (_d = (GLOBAL_THIS == null ? undefined : GLOBAL_THIS[\"Deno\"]) ? (_c = (_a = GLOBAL_THIS == null ? undefined : GLOBAL_THIS[\"Deno\"]) == null ? undefined : _a.args) != null ? _c : ((_b = process[\"args\"]) == null ? undefined : _b.length) ? process[\"args\"] : process[\"argv\"] : process[\"argv\"]) != null ? _d : [];\n})();\nvar ENV = /* @__PURE__ */ (() => {\n var _a, _b, _c, _d;\n return typeof process === \"undefined\" ? typeof ((_a = GLOBAL_THIS == null ? undefined : GLOBAL_THIS[\"std\"]) == null ? undefined : _a.getenviron) === \"function\" ? (_d = (_c = (_b = GLOBAL_THIS[\"std\"]).getenviron) == null ? undefined : _c.call(_b)) != null ? _d : {} : {} : !(GLOBAL_THIS == null ? undefined : GLOBAL_THIS[\"Deno\"]) ? process[\"env\"] : (() => {\n var _a2, _b2, _c2, _d2, _e, _f;\n try {\n return (_f = (_c2 = (_b2 = (_a2 = GLOBAL_THIS == null ? undefined : GLOBAL_THIS[\"Deno\"]) == null ? undefined : _a2.env) == null ? undefined : _b2.toObject) == null ? undefined : _c2.call(_b2)) != null ? _f : ((_d2 = process[\"env\"]) == null ? undefined : _d2.toObject) ? (_e = process[\"env\"]) == null ? undefined : _e.toObject() : process[\"env\"];\n } catch (_err) {}\n return {};\n })();\n})();\n\n// src/index.ts\nvar hasArgv = (keys, argv = ARGV) => !argv?.length ? false : !![keys].flat().filter(Boolean).find((key) => new RegExp(`(^|[^\\\\S])(?:--|-)${key}(=|\\\\s|$)`, \"i\").test(argv.join(\" \")));\nvar quoteNorm = (val) => /^['\"]/.test(val) ? val?.replace(/^(['\"])(.*)(['\"])$/, (m, q1, body, q2) => q1 === q2 ? quoteNorm(body) : m) : val;\nvar isFlag = (val) => /^-+\\w/.test(val ?? \"\") && Number.isNaN(Number(val));\nvar isTerm = (val) => val?.trim() === \"--\";\nvar toArgvArray = (key, strict = false, _keys = Array.isArray(key) ? key : [key]) => strict ? _keys : _keys.map((item) => [\n item,\n item.replaceAll(...item.includes(\"_\") ? [\"_\", \"-\"] : [\"-\", \"_\"])\n]).flat();\nvar cliReap = (argv = ARGV, env = ENV, gthis = GLOBAL_THIS, strict = false) => {\n const slice = argv[0] === \"node\" ? 2 : argv[1] === \"run\" ? 3 : isFlag(argv[0]) ? 0 : 1;\n const cur = argv.map(String).slice(slice);\n const cmd = argv.map(String).slice(0, slice);\n const end = !!cur.find(isTerm);\n const getArgv = (keys, optValue = false) => {\n const keyList = toArgvArray(keys, strict);\n for (let i = 0;i < cur.length; i++) {\n const token = cur[i];\n if (isTerm(token)) {\n break;\n }\n if (!token || !isFlag(token)) {\n continue;\n }\n const hasEq = /=/.test(token);\n const part = keyList.map((key) => {\n const [k, ...parts] = token.replace(isFlag(key) ? /(?!)/ : /^\\s*?-+/, \"\").split(hasEq && optValue ? `${key}=` : new RegExp(`^${key}$`, strict ? \"\" : \"i\"));\n return !k?.length ? parts.join(key) : k === key ? key : null;\n }).find((v) => v !== null) ?? 0;\n if (part === 0) {\n continue;\n }\n if (!optValue) {\n cur.splice(i, 1);\n return true;\n }\n if (hasEq) {\n cur.splice(i, 1);\n return quoteNorm(part);\n }\n const next = cur[i + 1];\n if (next !== undefined && !isTerm(next) && !isFlag(next)) {\n cur.splice(i, 2);\n return quoteNorm(next);\n }\n }\n return null;\n };\n const getEnv = (keys) => toArgvArray(keys, strict).map((key) => (key in env) ? env[key] : (key in gthis) ? gthis[key] : null).filter(Boolean)[0] ?? null;\n const getFlag = (keys) => getArgv(keys, false) !== null ? true : null;\n const getOpt = (keys) => getArgv(keys, true);\n const getAny = (keys, defaultValue) => getOpt(keys) ?? getFlag(keys) ?? getEnv(keys) ?? (defaultValue !== undefined ? defaultValue : null);\n const getPos = () => {\n const result = [];\n for (let i = 0;i < cur.length; i++) {\n const token = cur[i];\n if (!token) {\n continue;\n }\n if (isTerm(token)) {\n return [...result, ...cur.slice(i + 1)];\n }\n if (isFlag(token)) {\n continue;\n }\n result.push(token);\n }\n return result;\n };\n return {\n any: getAny,\n cmd: () => cmd,\n cur: () => cur,\n end: () => end,\n env: getEnv,\n flag: getFlag,\n opt: getOpt,\n pos: getPos\n };\n};\nvar cliReapStrict = (argv = ARGV, procEnv = ENV, gthis = GLOBAL_THIS) => cliReap(argv, procEnv, gthis, true);\nvar src_default = cliReap;\nexport {\n quoteNorm,\n isFlag,\n hasArgv,\n src_default as default,\n cliReapStrict,\n cliReap,\n ENV,\n ARGV\n};\n\n//# debugId=D346F45C437553B064756E2164756E21\n//# sourceMappingURL=index.js.map\n",
6
6
  "// src/index.ts\nvar GLOBAL_THIS = /* @__PURE__ */ (() => typeof globalThis === \"object\" ? globalThis : (() => {\n !(function(Object2) {\n function get() {\n const e = this || self;\n e.globalThis = e, delete Object2.prototype._T_;\n }\n \"object\" != typeof globalThis && (this ? get() : (Object2.defineProperty(Object2.prototype, \"_T_\", { configurable: true, get }), _T_));\n })(Object);\n return typeof globalThis === \"object\" ? globalThis : {};\n})())();\nvar ARGV = /* @__PURE__ */ (() => {\n var _a, _b, _c, _d;\n return typeof process === \"undefined\" ? typeof scriptArgs !== \"undefined\" ? scriptArgs : [] : (_d = (GLOBAL_THIS == null ? void 0 : GLOBAL_THIS[\"Deno\"]) ? (_c = (_a = GLOBAL_THIS == null ? void 0 : GLOBAL_THIS[\"Deno\"]) == null ? void 0 : _a.args) != null ? _c : ((_b = process[\"args\"]) == null ? void 0 : _b.length) ? process[\"args\"] : process[\"argv\"] : process[\"argv\"]) != null ? _d : [];\n})();\nvar ARGS = ARGV;\nvar ENV = /* @__PURE__ */ (() => {\n var _a, _b, _c, _d;\n return typeof process === \"undefined\" ? typeof ((_a = GLOBAL_THIS == null ? void 0 : GLOBAL_THIS[\"std\"]) == null ? void 0 : _a.getenviron) === \"function\" ? (_d = (_c = (_b = GLOBAL_THIS[\"std\"]).getenviron) == null ? void 0 : _c.call(_b)) != null ? _d : {} : {} : !(GLOBAL_THIS == null ? void 0 : GLOBAL_THIS[\"Deno\"]) ? process[\"env\"] : (() => {\n var _a2, _b2, _c2, _d2, _e, _f;\n try {\n return (_f = (_c2 = (_b2 = (_a2 = GLOBAL_THIS == null ? void 0 : GLOBAL_THIS[\"Deno\"]) == null ? void 0 : _a2.env) == null ? void 0 : _b2.toObject) == null ? void 0 : _c2.call(_b2)) != null ? _f : ((_d2 = process[\"env\"]) == null ? void 0 : _d2.toObject) ? (_e = process[\"env\"]) == null ? void 0 : _e.toObject() : process[\"env\"];\n } catch (_err) {\n }\n return {};\n })();\n})();\nexport {\n ARGS,\n ARGV,\n ENV,\n GLOBAL_THIS\n};\n//# sourceMappingURL=index.js.map\n",
7
- "import cliReap from 'cli-reap';\nimport {\n ENV,\n GLOBAL_THIS,\n} from 'globables';\n\nexport const ESC = '\\x1B';\nexport const RESET = '\\x1B[0m';\n\nexport const ANSI = {\n black: 30,\n iblack: 90,\n red: 31,\n ired: 91,\n green: 32,\n igreen: 92,\n yellow: 33,\n iyellow: 93,\n blue: 34,\n iblue: 94,\n purple: 35,\n ipurple: 95,\n cyan: 36,\n icyan: 96,\n white: 37,\n iwhite: 97,\n};\nexport const XTERM = Object.fromEntries(\n Array(256).fill(0).map((_v, i) => [`x${i}`, i] as [string, number]),\n);\nexport const COLORS = {...ANSI, ...XTERM};\n\n\n/**\n * color support level\n * @default 3\n * @see {@link https://nodejs.org/api/cli.html#force_color1-2-3|Node.js FORCE_COLOR docs}\n */\ntype ColorSpace = 0 | 1;\n\n\n/**\n * COLOR_SPACE - covers all reasonable and most un-reasonable cases\n * @implements nodejs.org/api/cli.html#force_color1-2-3\n * 0=no-color, 1=16, 2=256, 3=true-color\n */\nexport const COLOR_SPACE: ColorSpace = /* @__PURE__ */ (() => {\n try {\n const reap = cliReap();\n const forceColor = reap.any('FORCE_COLOR');\n // force colors\n if (forceColor === '' || (forceColor && !isNaN(Number(forceColor)) && Number(forceColor) > 0)) {\n return 1;\n }\n // no proc\n if (typeof process === 'undefined') { return 0; }\n\n // no color var\n if (reap.any('NO_COLOR') !== null\n || reap.any('NODE_DISABLE_COLORS') !== null\n || (/-mono|dumb/i).test(ENV['TERM'] ?? '')) { return 0; }\n\n // no tty\n if (!(!!process.stdout?.isTTY\n || (!!ENV['PM2_HOME'] && !!ENV['pm_id'])\n || ((GLOBAL_THIS as never)?.['Deno']\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ? (GLOBAL_THIS as any)?.['Deno']?.isatty(1)\n : !!process.stdout?.isTTY))) { return 0; }\n\n // cli\n if ((/^(false|never|no|0)$/i).test(`${reap.opt('color') ?? ''}`.trim())) {\n return 0;\n }\n return 1;\n } catch (_err) { /* ignore */ }\n // catch/error/fallthrough; plays it safe with no colors\n return 0;\n})();\n\n",
8
- "import {\n COLORS,\n ANSI,\n COLOR_SPACE,\n ESC,\n RESET,\n XTERM,\n} from './constants.ts';\n\ntype EmptyObject = Record<never, never>;\ntype StrNum = string | number;\n\n// fg=foreground\n// bg=background\n// ft=font\n// ue=underline\n// ie=inverse\n// re=reset\n// pr=previous (internal state)\ntype StyleKeys = 'fg' | 'bg' | 'ft' | 'ue' | 'ie' | 're' | 'pr';\ntype AnsiCodeTuple = [on: number, off: number, isCustom?: number];\ntype StyleState = Partial<Record<StyleKeys, AnsiCodeTuple>>;\ntype StainBase = 'black' | 'blue' | 'cyan' | 'green' | 'purple' | 'red' | 'white' | 'yellow';\nexport type StainAnsi = StainBase | `i${StainBase}`;\n\n// generate xterms: x0 to x255\ntype XtermKeysFactory<N extends number, Acc extends string[] = []> =\n Acc['length'] extends N\n ? Acc[number]\n : XtermKeysFactory<N, [...Acc, `x${Acc['length']}`]>;\nexport type StainXterm = XtermKeysFactory<256>;\n\nexport type Stain<\n C extends Record<string, number> = EmptyObject,\n X extends boolean = false,\n> =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ((...args: any[])=> string) &\n {\n bg: Stain<C, X>;\n bold: Stain<C, X>;\n dim: Stain<C, X>;\n normal: Stain<C, X>;\n reset: Stain<C, X>;\n underline: Stain<C, X>;\n inverse: Stain<C, X>;\n } &\n // built-in named colors\n { [K in StainAnsi]: Stain<C, X> } &\n // xterm colors if enabled\n (X extends true ? { [K in StainXterm]: Stain<C, X> } : EmptyObject) &\n // custom colors from opts.colors\n (keyof C extends never ? EmptyObject : { [K in keyof C]: Stain<C, X> });\n\nexport type StainOpts<C extends Record<string, number> = EmptyObject> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n format?: (...args: any[])=> string;\n noColor?: boolean;\n xterm?: boolean;\n colors?: C;\n simpleEscape?: boolean;\n};\n\n\n/**\n * ansi escape-er\n * @note -> without handlin/escapin nesting it simplifies to: `\\x1b[${open}m${str}\\x1b[${close}m`\n * @param {string} str\n * @param {StrNum} open\n * @param {StrNum} close\n * @param {StrNum} fontReplace\n * @return {[type]}\n */\nconst escStain = (str: string, open: StrNum, close: StrNum, fontReplace?: StrNum) => {\n str = typeof str !== 'string' ? String(str) : str; // just in case\n const openStr = ESC + `[${open}m`;\n const closeStr = ESC + `[${close}m`;\n const closeLen = closeStr.length;\n const parts: string[] = [];\n let cursor = 0;\n let seqCount = 0; // count of close sequences for alternating styles\n let resetCount = 0;\n while (true) {\n const idxClose = str.indexOf(closeStr, cursor);\n // next global reset unless it is the reset style\n const idxReset = open === 0 ? -1 : str.indexOf(RESET, cursor);\n let idx = -1;\n let isReset = false;\n // which comes first, cur close sequence or a global reset\n if (idxClose >= 0) {\n if (idxReset >= 0 && idxReset < idxClose) {\n idx = idxReset;\n isReset = true;\n } else {\n idx = idxClose;\n }\n } else if (idxReset >= 0) {\n idx = idxReset;\n isReset = true;\n } else {\n break;\n }\n parts.push(str.substring(cursor, idx));\n\n if (isReset) {\n parts.push(RESET);\n resetCount++;\n // after every second reset restore style\n // e.g: stain.red(`text ${stain.reset('reset')} text`)\n if (resetCount % 2 === 0) { parts.push(openStr); }\n cursor = idx + RESET.length;\n continue;\n }\n\n // a closing sequence; need to determine the correct replacement\n const segment = str.substring(cursor, idx);\n const openInSeg = segment.split(openStr).length;\n const closeInSeg = segment.split(closeStr).length;\n\n let rep = openStr;\n // this roundabout logic is for font styles nesting\n // e.g: stain.bold(`bold ${stain.normal('norm')} bold`)\n if (fontReplace !== undefined && openInSeg <= closeInSeg) {\n // use seqCount to treat the first closeStr as an 'opener' and the second as the 'closer'\n seqCount++;\n const on = ESC + `[${fontReplace}m`; // outer style's open code\n const off = ESC + `[${close}m`; // inner style's open/close code\n rep = (seqCount % 2 === 1) ? on + off : off + on;\n }\n\n parts.push(rep);\n cursor = idx + closeLen;\n }\n parts.push(str.substring(cursor));\n return openStr + parts.join('') + closeStr;\n};\n\n/**\n * simple escape that doesn't handle nested ansi; 1.5-4x+ faster depending on style complexity\n * nested example: stain.red.bold('Bold ' + stain.green.normal('normal') + ' Bold')\n * @param {string} str\n * @param {StrNum} open\n * @param {StrNum} close\n * @param {StrNum} _fontReplace\n * @return {[type]}\n */\nconst escStainSimple = (str: string, open: StrNum, close: StrNum, _fontReplace?: StrNum) =>\n `${ESC}[${open}m` + (typeof str !== 'string' ? String(str) : str) + `${ESC}[${close}m`;\n\n\n/**\n * a nice node typed color api, that isn't \"slow\" at\n * @perf ~6million iter/s - NO_COLOR=~186million iter/s\n */\nfunction createStain<C extends Record<string, number> = EmptyObject>(\n opts?: StainOpts<C> & { xterm?: false }\n): Stain<C, false>;\nfunction createStain<C extends Record<string, number> = EmptyObject>(\n opts: StainOpts<C> & { xterm: true }\n): Stain<C, true>;\nfunction createStain<C extends Record<string, number> = EmptyObject>(\n opts: StainOpts<C> = {},\n): Stain<C, boolean> {\n const {\n colors,\n xterm,\n format = (...args) => args.length > 1\n ? args.join(' ')\n : typeof args[0] !== 'string' ? JSON.stringify(args[0]) : args[0],\n noColor = COLOR_SPACE === 0,\n simpleEscape = false,\n } = opts;\n\n const colorAll: Record<string, number> = colors\n ? {...(xterm ? COLORS : ANSI), ...colors}\n : (xterm ? COLORS : ANSI);\n\n // provies the same api, but doesn't add color, and much, much, much, faster\n if (noColor) {\n // wrapped to avoid poluting the proto on passed in format\n const ncFormat = opts?.format ? (...args: unknown[]) => format(...args) : format;\n for (const prop of Object.keys(colorAll)\n .concat(['bg', 'bold', 'dim', 'normal', 'reset', 'underline'])) {\n // @ts-expect-error not typable\n ncFormat[prop] = ncFormat;\n }\n return ncFormat as Stain<C, boolean>;\n }\n const escFn = simpleEscape ? escStainSimple : escStain;\n // xterm look-up map to determin if xterm\n // @see {@link https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit}\n const color256: Record<string, number> = colors\n ? (xterm ? {...XTERM, ...colors} : colors)\n : (xterm ? XTERM : {});\n\n // our main stain\n const colorProxy = (cur: StyleState = {}) =>\n new Proxy((text: string) => text, {\n get: (_target, prop: string) => {\n const nxt = {...cur};\n const fg = nxt.fg;\n if (colorAll[prop] !== undefined) { // xterm logic\n // keeps track of previous for bg logic\n nxt.pr = [\n fg?.[0] ?? colorAll[prop],\n 39,\n fg?.[2] ?? (color256[prop] !== undefined ? 1 : 0),\n ];\n nxt.fg = [colorAll[prop], 39, color256[prop] !== undefined ? 1 : 0];\n } else if (prop === 'bg' && fg) { // bg/fg logic\n nxt.bg = [fg[0] + (fg[2] || fg[1] === 49 ? 0 : 10), 49, fg[2]] as AnsiCodeTuple;\n // @ts-expect-error to make this type easier we ignore undefined\n if (nxt.pr?.[1] === 39) { nxt.fg = fg[0] === nxt.pr[0] ? undefined : [...nxt.pr]; }\n } else { // font style logic\n const fo = prop === 'bold' ? 1 : prop === 'dim' ? 2 : prop === 'normal' ? 22 : null;\n if (fo) {\n nxt.ft = [fo, 22, 0];\n } else if (prop === 'underline') {\n nxt.ue = [4, 24, 0];\n } else if (prop === 'inverse') {\n nxt.ie = [7, 27, 0];\n } else if (prop === 'reset') {\n nxt.re = [0, 0, 0];\n }\n }\n return colorProxy(nxt);\n },\n apply: (_target, _thisArg, args: string[]) => {\n let res = format(...args);\n // a loop here will dec perf by 6x; and a switch tends to be slower\n if (cur.re) { return escFn(res, 0, 0); }\n if (cur.fg) { res = escFn(res, (cur.fg[2] ? '38;5;' : '') + cur.fg[0], cur.fg[1]); }\n if (cur.bg) { res = escFn(res, (cur.bg[2] ? '48;5;' : '') + cur.bg[0], cur.bg[1]); }\n if (cur.ft) { res = escFn(res, cur.ft[0], cur.ft[1], cur.ft[0]); }\n if (cur.ue) { res = escFn(res, cur.ue[0], cur.ue[1]); }\n if (cur.ie) { res = escFn(res, cur.ie[0], cur.ie[1]); }\n return res;\n },\n });\n return colorProxy() as Stain<C, boolean>;\n}\n\nconst stain = /* @__PURE__ */ (() => createStain({ xterm: true }))();\n\nexport default stain;\nexport {\n stain,\n createStain,\n ANSI,\n COLOR_SPACE,\n ESC,\n RESET,\n XTERM,\n};\n"
7
+ "/** @about\n@file: constants.ts\n\nimport {\n ESC,\n RESET,\n ANSI,\n XTERM,\n COLORS,\n ANSI_TUPLE,\n} from './constants.ts';\n\n*** */\nimport type {\n TupleN,\n} from './types.ts';\n\n\n/**\n * ansi escape prefix character\n */\nexport const ESC = '\\x1B';\n\n\n/**\n * ansi reset sequence\n */\nexport const RESET = '\\x1B[0m';\n\n\n/**\n * basic ansi color codes for standard and intense variants\n */\nexport const ANSI = {\n black: 30,\n iblack: 90,\n red: 31,\n ired: 91,\n green: 32,\n igreen: 92,\n yellow: 33,\n iyellow: 93,\n blue: 34,\n iblue: 94,\n purple: 35,\n ipurple: 95,\n cyan: 36,\n icyan: 96,\n white: 37,\n iwhite: 97,\n};\n\n\n/**\n * xterm 256 color map with keys x0..x255\n */\nexport const XTERM = Object.fromEntries(\n Array(256).fill(0).map((_v, i) => [`x${i}`, i] as [string, number]),\n);\n\n\n/**\n * merged color map including ansi and xterm\n */\nexport const COLORS = {...ANSI, ...XTERM};\n\nexport const ANSI_TUPLE: TupleN<16, TupleN<3, number>> = [\n [0, 0, 0], // black=30 -> rgba(0,0,0,1.0)\n [128, 0, 0], // red=31 -> rgba(128,0,0,1.0)\n [0, 128, 0], // green=32 -> rgba(0,128,0,1.0)\n [128, 128, 0], // yellow=33 -> rgba(128,128,0,1.0)\n [0, 0, 128], // blue=34 -> rgba(0,0,128,1.0)\n [128, 0, 128], // magenta=35 -> rgba(128,0,128,1.0)\n [0, 128, 128], // cyan=36 -> rgba(0,128,128,1.0)\n [192, 192, 192], // white=37 -> rgba(192,192,192,1.0)\n [128, 128, 128], // iblack=90 -> rgba(128,128,128,1.0)\n [255, 0, 0], // ired=91 -> rgba(255,0,0,1.0)\n [0, 255, 0], // igreen=92 -> rgba(0,255,0,1.0)\n [255, 255, 0], // iyellow=93 -> rgba(255,255,0,1.0)\n [0, 0, 255], // iblue=94 -> rgba(0,0,255,1.0)\n [255, 0, 255], // imagenta=95 -> rgba(255,0,255,1.0)\n [0, 255, 255], // icyan=96 -> rgba(0,255,255,1.0)\n [255, 255, 255], // iwhite=97 -> rgba(255,255,255,1.0)\n];\n\n",
8
+ "/** @about\n@file: utils.ts\n\nimport {\n toEntries,\n xtermTo4Bit,\n getColorSpace,\n} from './utils.ts';\n\n*** */\nimport cliReap from 'cli-reap';\nimport {\n ARGV,\n ENV,\n GLOBAL_THIS,\n} from 'globables';\nimport {\n ANSI_TUPLE,\n} from './constants.ts';\nimport type {\n ColorSpace,\n} from './types.ts';\n\n\n/**\n * Converts an XTerm 256-color index to its RGB values.\n *\n * @param n The XTerm 256-color index (0-255).\n * @returns [r, g, b] where each is 0-255.\n */\nconst xtermToRgb = (n: number): [number, number, number] => {\n if (n < 16) {\n return ANSI_TUPLE[n] ?? ANSI_TUPLE[0];\n }\n // 6x6x6 color cube\n if (n < 232) {\n n -= 16;\n const reds = [0, 95, 135, 175, 215, 255];\n return [\n reds[Math.floor(n / 36)] ?? 0,\n reds[Math.floor((n % 36) / 6)] ?? 0,\n reds[n % 6] ?? 0,\n ];\n }\n // grayscale ramp\n const gray = 8 + ((n - 232) * 10);\n return [gray, gray, gray];\n};\n\n\n/**\n * converts an XTerm 8bit (256-color) index to the best 4bit value\n * @param {number} n - xterm index\n * @param {0 | 1} [isBg=0] - if bg\n * @return {number}\n */\nexport const xtermTo4Bit = (n: number, isBg: 0 | 1 = 0): number => {\n if (n < 16) {\n return (n < 8 ? 40 + n : 100 + (n - 8)) - (isBg ? 0 : 10);\n }\n const [r, g, b] = xtermToRgb(n);\n const ansi = ANSI_TUPLE.map(([sr, sg, sb], idx) => {\n return [\n idx,\n // euclidean distance in RGB space\n Math.sqrt(Math.pow(r - sr, 2) + Math.pow(g - sg, 2) + Math.pow(b - sb, 2))\n // grayscale penalty if input isn't gray\n * ((!(r === g && g === b) && (sr === sg && sg === sb) ? 2 : 1)\n // red penalty - to avoid same orange/red warn/error color\n + ((sg === 0) && (sb === 0) && (sr > 0) ? 0.1 : 0))\n // blue boost - to prevent over cyan-idation\n * (idx === 4 || idx === 12\n ? ((r < 50 && g > 100 && g < 200 && b > 200) ? 0.5 : 1)\n : 1),\n ] as const;\n }).sort((a, b) => { return a[1] - b[1]; })[0]?.[0] ?? 0;\n\n return (ansi + (ansi >= 8 ? 82 : 30)) + (isBg ? 10 : 0);\n};\n\n\n/**\n * get basic binary 0 color space\n * 0=no-color, 1=16, 2=256\n * @implements nodejs.org/api/cli.html#force_color1-2-3\n * @param {string[]} argv - argv cli/arguments\n * @param {NodeJS.ProcessEnv} env - ENV variables\n * @param {typeof globalThis} gthis - globalThis\n * @param {boolean} isTTY - if stdout connected to TTY (teletypewriter) terminal\n * @return {ColorSpace}\n */\nexport const getColorSpace = (\n argv = ARGV,\n env = ENV,\n gthis = globalThis,\n isTTY: null | boolean = null,\n): ColorSpace => {\n try {\n const reap = cliReap(argv, env, gthis);\n const forceColor = reap.any('FORCE_COLOR');\n // force colors\n if (forceColor === '' || (forceColor && !isNaN(Number(forceColor)) && Number(forceColor) > 0)) {\n return 2;\n }\n\n // no color var\n if (reap.any('NO_COLOR') !== null\n || reap.any('NODE_DISABLE_COLORS') !== null\n || (/-mono|dumb/i).test(env['TERM'] ?? '')) { return 0; }\n\n // cli: -color=false, -color=no, -color=never\n if ((/^(false|never|no|0)$/i).test(`${reap.opt('color') ?? ''}`.trim())) {\n return 0;\n }\n\n // if pm2 env\n if (!!env['PM2_HOME'] && !!env['pm_id']) { return 0; }\n\n // no proc & not quickjs runtime\n if (typeof process === 'undefined' && typeof scriptArgs === 'undefined') { return 0; }\n\n // no tty - assume if quickjs user will manually define isTTY\n isTTY = isTTY\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ?? (GLOBAL_THIS as any)?.['Deno']?.isatty(1)\n ?? (typeof process === 'undefined' ? null : !!process.stdout?.isTTY);\n if (isTTY === false) { return 0; }\n\n const {COLORTERM, TERM, CI} = env;\n\n // if CI env, keep it 4bit simple\n if (CI) { return 1; }\n\n return ('truecolor' === COLORTERM\n || '24bit' === COLORTERM\n || (TERM && (/^xterm-(kitty|direct)$/i).test(TERM))\n )\n ? 2 // 24bit/xterminary-true-colours (38;2;r;g;b)\n : ('ansi256' === COLORTERM\n || '8bit' === COLORTERM\n || (TERM && (/-256(colou?r)?$/i).test(TERM))\n )\n ? 2 // 8bit/256-colors-are-enough\n : 1; // 4bit; term is ansi or screen,tmux,xterm,color,cygwin,linux,mintty,rxvt,vt...\n } catch (_err) { /* ignore */ }\n // catch/error/fallthrough; plays it safe with no colors\n return 0;\n};\n\n\n",
9
+ "import type {\n EmptyObject,\n StrNum,\n ColorSpace,\n AnsiCodeTuple,\n StyleState,\n Stain,\n StainOpts,\n} from './types.ts';\nimport {\n xtermTo4Bit,\n getColorSpace,\n} from './utils.ts';\nimport {\n ESC,\n RESET,\n ANSI,\n XTERM,\n COLORS,\n} from './constants.ts';\n\n\n/**\n * ansi nested escape-er\n * @note -> without handlin/escapin nesting it simplifies to: `\\x1b[${open}m${str}\\x1b[${close}m`\n * @param {string} str\n * @param {StrNum} open\n * @param {StrNum} close\n * @param {StrNum} fontReplace\n * @return {string}\n */\nconst escStain = (str: string, open: StrNum, close: StrNum, fontReplace?: StrNum) => {\n str = typeof str !== 'string' ? String(str) : str; // just in case\n const openStr = ESC + `[${open}m`;\n const closeStr = ESC + `[${close}m`;\n const closeLen = closeStr.length;\n const parts: string[] = [];\n let cursor = 0;\n let seqCount = 0; // count of close sequences for alternating styles\n let resetCount = 0;\n while (true) {\n const idxClose = str.indexOf(closeStr, cursor);\n // next global reset unless it is the reset style\n const idxReset = open === 0 ? -1 : str.indexOf(RESET, cursor);\n let idx = -1;\n let isReset = false;\n // which comes first, cur close sequence or a global reset\n if (idxClose >= 0) {\n if (idxReset >= 0 && idxReset < idxClose) {\n idx = idxReset;\n isReset = true;\n } else {\n idx = idxClose;\n }\n } else if (idxReset >= 0) {\n idx = idxReset;\n isReset = true;\n } else {\n break;\n }\n parts.push(str.substring(cursor, idx));\n\n if (isReset) {\n parts.push(RESET);\n resetCount++;\n // after every second reset restore style\n // e.g: stain.red(`text ${stain.reset('reset')} text`)\n if (resetCount % 2 === 0) { parts.push(openStr); }\n cursor = idx + RESET.length;\n continue;\n }\n\n // a closing sequence; need to determine the correct replacement\n const segment = str.substring(cursor, idx);\n const openInSeg = segment.split(openStr).length;\n const closeInSeg = segment.split(closeStr).length;\n\n let rep = openStr;\n // this roundabout logic is for font styles nesting\n // e.g: stain.bold(`bold ${stain.normal('norm')} bold`)\n if (fontReplace !== undefined && openInSeg <= closeInSeg) {\n // use seqCount to treat the first closeStr as an 'opener' and the second as the 'closer'\n seqCount++;\n const on = ESC + `[${fontReplace}m`; // outer style's open code\n const off = ESC + `[${close}m`; // inner style's open/close code\n rep = (seqCount % 2 === 1) ? on + off : off + on;\n }\n\n parts.push(rep);\n cursor = idx + closeLen;\n }\n parts.push(str.substring(cursor));\n return openStr + parts.join('') + closeStr;\n};\n\n\n/**\n * simple escape that doesn't handle nested ansi; 1.5-4x+ faster depending on style complexity\n * nested example: stain.red.bold('Bold ' + stain.green.normal('normal') + ' Bold')\n * @param {string} str\n * @param {StrNum} open\n * @param {StrNum} close\n * @param {StrNum} _fontReplace\n * @return {string}\n */\nconst escStainSimple = (str: string, open: StrNum, close: StrNum, _fontReplace?: StrNum) =>\n `${ESC}[${open}m` + (typeof str !== 'string' ? String(str) : str) + `${ESC}[${close}m`;\n\n\n/**\n * cached color space used to avoid repeated environment checks - init on first createStain call\n * @private\n */\nlet _COLOR_SPACE: null | ColorSpace = null;\n\n\n/**\n * creates the main chainable stain\n * returns a callable function that formats input and exposes chainable style and color properties\n * respects noColor xterm custom colors and simpleEscape options\n * @perf ~6million iter/s - NO_COLOR=~186million iter/s\n * @template C extends Record<string, number> custom color map type\n * @param {StainOpts<C>} [opts={}] configuration options\n * @returns {Stain<C, boolean>} stain api with chainable methods and callable formatting\n */\nfunction createStain<C extends Record<string, number> = EmptyObject>(\n opts?: StainOpts<C> & { xterm?: false; }\n): Stain<C, false>;\nfunction createStain<C extends Record<string, number> = EmptyObject>(\n opts: StainOpts<C> & { xterm: true; }\n): Stain<C, true>;\nfunction createStain<C extends Record<string, number> = EmptyObject>(\n opts: StainOpts<C> = {},\n): Stain<C, boolean> {\n // the inital 'stain' export sets 'noColor' otherwise lazy init\n if (_COLOR_SPACE === null && opts.noColor === undefined) { _COLOR_SPACE = getColorSpace(); }\n\n const {\n colors,\n xterm,\n format = (...args) => args.length > 1\n ? args.join(' ')\n : typeof args[0] !== 'string' ? JSON.stringify(args[0]) : args[0],\n colorSpace = _COLOR_SPACE,\n noColor = colorSpace === 0,\n simpleEscape = false,\n } = opts;\n\n let colorAll: Record<string, number> = colors\n ? {...(xterm ? COLORS : ANSI), ...colors}\n : (xterm ? COLORS : ANSI);\n\n // provies the same api, but doesn't add color, and much, much, much, faster\n if (noColor) {\n // wrapped to avoid poluting the proto on passed in format\n const ncFormat = opts?.format ? (...args: unknown[]) => format(...args) : format;\n for (const prop of Object.keys(colorAll)\n .concat(['bg', 'bold', 'dim', 'normal', 'reset', 'underline'])) {\n // @ts-expect-error not typable\n ncFormat[prop] = ncFormat;\n }\n return ncFormat as Stain<C, boolean>;\n }\n const escFn = simpleEscape ? escStainSimple : escStain;\n // xterm look-up map to determin if xterm\n // @see {@link https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit}\n const color256: Record<string, number> = colors\n ? (xterm ? {...XTERM, ...colors} : colors)\n : (xterm ? XTERM : {});\n\n // need to convert xterm colors to 4bit\n const force4Bit = xterm && colorSpace === 1;\n if (force4Bit) {\n colorAll = {...colorAll};\n for (const [key, val] of Object.entries(colorAll)) {\n if (ANSI[key as never]) {\n colorAll[key] = val - (val >= 90 ? 82 : 30);\n }\n }\n }\n\n // our main stain\n const colorProxy = (cur: StyleState = {}) =>\n new Proxy((text: string) => text, {\n get: (_target, prop: string) => {\n const nxt = {...cur};\n const fg = nxt.fg;\n if (colorAll[prop] !== undefined) { // xterm logic\n // keeps track of previous for bg logic\n nxt.pr = [\n fg?.[0] ?? colorAll[prop],\n 39,\n fg?.[2] ?? (color256[prop] !== undefined ? 1 : 0),\n ];\n nxt.fg = [colorAll[prop], 39, color256[prop] !== undefined ? 1 : 0];\n } else if (prop === 'bg' && fg) { // bg/fg logic\n nxt.bg = [fg[0] + (fg[2] || fg[1] === 49 ? 0 : 10), 49, fg[2]] as AnsiCodeTuple;\n // @ts-expect-error to make this type easier we ignore undefined\n if (nxt.pr?.[1] === 39) { nxt.fg = fg[0] === nxt.pr[0] ? undefined : [...nxt.pr]; }\n } else { // font style logic\n const fo = prop === 'bold' ? 1 : prop === 'dim' ? 2 : prop === 'normal' ? 22 : null;\n if (fo) {\n nxt.ft = [fo, 22, 0];\n } else if (prop === 'underline') {\n nxt.ue = [4, 24, 0];\n } else if (prop === 'inverse') {\n nxt.ie = [7, 27, 0];\n } else if (prop === 'reset') {\n nxt.re = [0, 0, 0];\n }\n }\n return colorProxy(nxt);\n },\n apply: (_target, _thisArg, args: string[]) => {\n let res = format(...args);\n // a loop here dec's perf by 6x; and a switch tends to be slower\n if (cur.re) { return escFn(res, 0, 0); }\n\n // 8bit to 4bit force convert\n if (force4Bit && cur?.fg) {\n cur.fg[0] = xtermTo4Bit(cur.fg[0]);\n cur.fg[2] = 0;\n }\n if (force4Bit && cur?.bg) {\n // adjust for intense colors\n cur.bg[0] = xtermTo4Bit(cur.bg[2] === 0 && cur.bg[0] >= 10\n ? cur.bg[0] - 10\n : cur.bg[0], 1);\n cur.bg[2] = 0;\n }\n\n if (cur.fg) { res = escFn(res, (cur.fg[2] ? '38;5;' : '') + cur.fg[0], cur.fg[1]); }\n if (cur.bg) { res = escFn(res, (cur.bg[2] ? '48;5;' : '') + cur.bg[0], cur.bg[1]); }\n if (cur.ft) { res = escFn(res, cur.ft[0], cur.ft[1], cur.ft[0]); }\n if (cur.ue) { res = escFn(res, cur.ue[0], cur.ue[1]); }\n if (cur.ie) { res = escFn(res, cur.ie[0], cur.ie[1]); }\n return res;\n },\n });\n return colorProxy() as Stain<C, boolean>;\n}\n\n\n/**\n * preconfigured exported stain instance with xterm enabled\n */\nconst stain = /* @__PURE__ */ (() =>\n createStain({ xterm: true, noColor: !!getColorSpace() }))();\n\n\nexport default stain;\nexport {\n stain,\n createStain,\n // helpers\n getColorSpace,\n xtermTo4Bit,\n // constants\n ANSI,\n ESC,\n RESET,\n XTERM,\n};\n\n"
9
10
  ],
10
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAI,+BAA+B,MAAM,OAAO,eAAe,WAAW,cAAc,MAAM;AAAA,GAC3F,QAAQ,CAAC,SAAS;AAAA,IACjB,SAAS,GAAG,GAAG;AAAA,MACb,MAAM,IAAI,QAAQ;AAAA,MAClB,EAAE,aAAa,GAAG,OAAO,QAAQ,UAAU;AAAA;AAAA,IAE7C,OAAO,cAAc,aAAa,OAAO,IAAI,KAAK,QAAQ,eAAe,QAAQ,WAAW,OAAO,EAAE,cAAc,MAAM,IAAI,CAAC,GAAG;AAAA,KAChI,MAAM;AAAA,EACT,OAAO,OAAO,eAAe,WAAW,aAAa,CAAC;AAAA,GACrD,GAAG;AACN,IAAI,wBAAwB,MAAM;AAAA,EAChC,IAAI,IAAI,IAAI,IAAI;AAAA,EAChB,OAAO,OAAO,YAAY,cAAc,OAAO,eAAe,cAAc,aAAa,CAAC,KAAK,MAAM,eAAe,OAAO,YAAY,YAAY,YAAY,MAAM,KAAK,eAAe,OAAO,YAAY,YAAY,YAAY,OAAO,YAAY,GAAG,SAAS,OAAO,OAAO,KAAK,QAAQ,YAAY,OAAO,YAAY,GAAG,UAAU,QAAQ,UAAU,QAAQ,UAAU,QAAQ,YAAY,OAAO,KAAK,CAAC;AAAA,GAC9Y;AACH,IAAI,uBAAuB,MAAM;AAAA,EAC/B,IAAI,IAAI,IAAI,IAAI;AAAA,EAChB,OAAO,OAAO,YAAY,cAAc,SAAS,KAAK,eAAe,OAAO,YAAY,YAAY,WAAW,OAAO,YAAY,GAAG,gBAAgB,cAAc,MAAM,MAAM,KAAK,YAAY,QAAQ,eAAe,OAAO,YAAY,G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ACE, ESC, RESET, XTERM } from './constants.ts';
2
- type EmptyObject = Record<never, never>;
3
- type StainBase = 'black' | 'blue' | 'cyan' | 'green' | 'purple' | 'red' | 'white' | 'yellow';
4
- export type StainAnsi = StainBase | `i${StainBase}`;
5
- type XtermKeysFactory<N extends number, Acc extends string[] = []> = Acc['length'] extends N ? Acc[number] : XtermKeysFactory<N, [...Acc, `x${Acc['length']}`]>;
6
- export type StainXterm = XtermKeysFactory<256>;
7
- export type Stain<C extends Record<string, number> = EmptyObject, X extends boolean = false> = ((...args: any[]) => string) & {
8
- bg: Stain<C, X>;
9
- bold: Stain<C, X>;
10
- dim: Stain<C, X>;
11
- normal: Stain<C, X>;
12
- reset: Stain<C, X>;
13
- underline: Stain<C, X>;
14
- inverse: Stain<C, X>;
15
- } & {
16
- [K in StainAnsi]: Stain<C, X>;
17
- } & (X extends true ? {
18
- [K in StainXterm]: Stain<C, X>;
19
- } : EmptyObject) & (keyof C extends never ? EmptyObject : {
20
- [K in keyof C]: Stain<C, X>;
21
- });
22
- export type StainOpts<C extends Record<string, number> = EmptyObject> = {
23
- format?: (...args: any[]) => string;
24
- noColor?: boolean;
25
- xterm?: boolean;
26
- colors?: C;
27
- simpleEscape?: boolean;
28
- };
1
+ import type { EmptyObject, Stain, StainOpts } from './types.ts';
2
+ import { xtermTo4Bit, getColorSpace } from './utils.ts';
3
+ import { ESC, RESET, ANSI, XTERM } from './constants.ts';
29
4
  /**
30
- * a nice node typed color api, that isn't "slow" at
5
+ * creates the main chainable stain
6
+ * returns a callable function that formats input and exposes chainable style and color properties
7
+ * respects noColor xterm custom colors and simpleEscape options
31
8
  * @perf ~6million iter/s - NO_COLOR=~186million iter/s
9
+ * @template C extends Record<string, number> custom color map type
10
+ * @param {StainOpts<C>} [opts={}] configuration options
11
+ * @returns {Stain<C, boolean>} stain api with chainable methods and callable formatting
32
12
  */
33
13
  declare function createStain<C extends Record<string, number> = EmptyObject>(opts?: StainOpts<C> & {
34
14
  xterm?: false;
@@ -36,7 +16,10 @@ declare function createStain<C extends Record<string, number> = EmptyObject>(opt
36
16
  declare function createStain<C extends Record<string, number> = EmptyObject>(opts: StainOpts<C> & {
37
17
  xterm: true;
38
18
  }): Stain<C, true>;
19
+ /**
20
+ * preconfigured exported stain instance with xterm enabled
21
+ */
39
22
  declare const stain: Stain<EmptyObject, true>;
40
23
  export default stain;
41
- export { stain, createStain, ANSI, COLOR_SPACE, ESC, RESET, XTERM, };
24
+ export { stain, createStain, getColorSpace, xtermTo4Bit, ANSI, ESC, RESET, XTERM, };
42
25
  //# sourceMappingURL=index.d.ts.map