stain 1.2.0 → 1.3.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/dist/index.d.mts CHANGED
@@ -1,34 +1,14 @@
1
- import { ANSI, COLOR_SPACE, 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
package/dist/index.d.ts CHANGED
@@ -1,34 +1,14 @@
1
- import { ANSI, COLOR_SPACE, 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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,IAAI,EACJ,WAAW,EACX,GAAG,EACH,KAAK,EACL,KAAK,EACN,MAAM,gBAAgB,CAAC;AAExB,KAAK,WAAW,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAaxC,KAAK,SAAS,GAAG,OAAO,GAAG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"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EAKX,KAAK,EACL,SAAS,EACV,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,WAAW,EACX,aAAa,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,GAAG,EACH,KAAK,EACL,IAAI,EACJ,KAAK,EAEN,MAAM,gBAAgB,CAAC;AAiGxB;;;;;;;;GAQG;AACH,iBAAS,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,WAAW,EACjE,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,KAAK,CAAC;CAAE,GACvC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AACnB,iBAAS,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,WAAW,EACjE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG;IAAE,KAAK,EAAE,IAAI,CAAC;CAAE,GACpC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AAiHlB;;GAEG;AACH,QAAA,MAAM,KAAK,0BACkD,CAAC;AAG9D,eAAe,KAAK,CAAC;AACrB,OAAO,EACL,KAAK,EACL,WAAW,EAEX,aAAa,EACb,WAAW,EAEX,IAAI,EACJ,GAAG,EACH,KAAK,EACL,KAAK,GACN,CAAC"}
package/dist/index.js CHANGED
@@ -148,29 +148,84 @@ var ANSI = {
148
148
  };
149
149
  var XTERM = Object.fromEntries(Array(256).fill(0).map((_v, i) => [`x${i}`, i]));
150
150
  var COLORS = { ...ANSI, ...XTERM };
151
- var COLOR_SPACE = /* @__PURE__ */ (() => {
151
+ var ANSI_TUPLE = [
152
+ [0, 0, 0],
153
+ [128, 0, 0],
154
+ [0, 128, 0],
155
+ [128, 128, 0],
156
+ [0, 0, 128],
157
+ [128, 0, 128],
158
+ [0, 128, 128],
159
+ [192, 192, 192],
160
+ [128, 128, 128],
161
+ [255, 0, 0],
162
+ [0, 255, 0],
163
+ [255, 255, 0],
164
+ [0, 0, 255],
165
+ [255, 0, 255],
166
+ [0, 255, 255],
167
+ [255, 255, 255]
168
+ ];
169
+
170
+ // src/utils.ts
171
+ var xtermToRgb = (n) => {
172
+ if (n < 16) {
173
+ return ANSI_TUPLE[n] ?? ANSI_TUPLE[0];
174
+ }
175
+ if (n < 232) {
176
+ n -= 16;
177
+ const reds = [0, 95, 135, 175, 215, 255];
178
+ return [
179
+ reds[Math.floor(n / 36)] ?? 0,
180
+ reds[Math.floor(n % 36 / 6)] ?? 0,
181
+ reds[n % 6] ?? 0
182
+ ];
183
+ }
184
+ const gray = 8 + (n - 232) * 10;
185
+ return [gray, gray, gray];
186
+ };
187
+ var xtermTo4Bit = (n, isBg = 0) => {
188
+ if (n < 16) {
189
+ return (n < 8 ? 40 + n : 100 + (n - 8)) - (isBg ? 0 : 10);
190
+ }
191
+ const [r, g, b] = xtermToRgb(n);
192
+ const ansi = ANSI_TUPLE.map(([sr, sg, sb], idx) => {
193
+ return [
194
+ idx,
195
+ 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)
196
+ ];
197
+ }).sort((a, b2) => {
198
+ return a[1] - b2[1];
199
+ })[0]?.[0] ?? 0;
200
+ return ansi + (ansi >= 8 ? 82 : 30) + (isBg ? 10 : 0);
201
+ };
202
+ var getColorSpace = (argv, env, gthis) => {
152
203
  try {
153
- const reap = src_default();
204
+ const reap = src_default(argv, env, gthis);
154
205
  const forceColor = reap.any("FORCE_COLOR");
155
206
  if (forceColor === "" || forceColor && !isNaN(Number(forceColor)) && Number(forceColor) > 0) {
156
- return 1;
207
+ return 2;
157
208
  }
158
- if (typeof process === "undefined") {
209
+ if (reap.any("NO_COLOR") !== null || reap.any("NODE_DISABLE_COLORS") !== null || /-mono|dumb/i.test(ENV2["TERM"] ?? "")) {
159
210
  return 0;
160
211
  }
161
- if (reap.any("NO_COLOR") !== null || reap.any("NODE_DISABLE_COLORS") !== null || /-mono|dumb/i.test(ENV2["TERM"] ?? "")) {
212
+ if (/^(false|never|no|0)$/i.test(`${reap.opt("color") ?? ""}`.trim())) {
162
213
  return 0;
163
214
  }
164
- if (!(!!process.stdout?.isTTY || !!ENV2["PM2_HOME"] && !!ENV2["pm_id"] || (GLOBAL_THIS2?.["Deno"] ? GLOBAL_THIS2?.["Deno"]?.isatty(1) : !!process.stdout?.isTTY))) {
215
+ if (typeof process === "undefined") {
165
216
  return 0;
166
217
  }
167
- if (/^(false|never|no|0)$/i.test(`${reap.opt("color") ?? ""}`.trim())) {
218
+ if (!(!!process.stdout?.isTTY || !!ENV2["PM2_HOME"] && !!ENV2["pm_id"] || (GLOBAL_THIS2?.["Deno"] ? GLOBAL_THIS2?.["Deno"]?.isatty(1) : !!process.stdout?.isTTY))) {
168
219
  return 0;
169
220
  }
170
- return 1;
221
+ const { COLORTERM, TERM, CI } = ENV2;
222
+ if (CI) {
223
+ return 1;
224
+ }
225
+ 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;
171
226
  } catch (_err) {}
172
227
  return 0;
173
- })();
228
+ };
174
229
 
175
230
  // src/index.ts
176
231
  var escStain = (str, open, close, fontReplace) => {
@@ -227,15 +282,20 @@ var escStain = (str, open, close, fontReplace) => {
227
282
  return openStr + parts.join("") + closeStr;
228
283
  };
229
284
  var escStainSimple = (str, open, close, _fontReplace) => `${ESC}[${open}m` + (typeof str !== "string" ? String(str) : str) + `${ESC}[${close}m`;
285
+ var _COLOR_SPACE = null;
230
286
  function createStain(opts = {}) {
287
+ if (_COLOR_SPACE === null && opts.noColor === undefined) {
288
+ _COLOR_SPACE = getColorSpace();
289
+ }
231
290
  const {
232
291
  colors,
233
292
  xterm,
234
293
  format = (...args) => args.length > 1 ? args.join(" ") : typeof args[0] !== "string" ? JSON.stringify(args[0]) : args[0],
235
- noColor = COLOR_SPACE === 0,
294
+ colorSpace = _COLOR_SPACE,
295
+ noColor = colorSpace === 0,
236
296
  simpleEscape = false
237
297
  } = opts;
238
- const colorAll = colors ? { ...xterm ? COLORS : ANSI, ...colors } : xterm ? COLORS : ANSI;
298
+ let colorAll = colors ? { ...xterm ? COLORS : ANSI, ...colors } : xterm ? COLORS : ANSI;
239
299
  if (noColor) {
240
300
  const ncFormat = opts?.format ? (...args) => format(...args) : format;
241
301
  for (const prop of Object.keys(colorAll).concat(["bg", "bold", "dim", "normal", "reset", "underline"])) {
@@ -245,6 +305,15 @@ function createStain(opts = {}) {
245
305
  }
246
306
  const escFn = simpleEscape ? escStainSimple : escStain;
247
307
  const color256 = colors ? xterm ? { ...XTERM, ...colors } : colors : xterm ? XTERM : {};
308
+ const force4Bit = xterm && colorSpace === 1;
309
+ if (force4Bit) {
310
+ colorAll = { ...colorAll };
311
+ for (const [key, val] of Object.entries(colorAll)) {
312
+ if (ANSI[key]) {
313
+ colorAll[key] = val - (val >= 90 ? 82 : 30);
314
+ }
315
+ }
316
+ }
248
317
  const colorProxy = (cur = {}) => new Proxy((text) => text, {
249
318
  get: (_target, prop) => {
250
319
  const nxt = { ...cur };
@@ -280,6 +349,14 @@ function createStain(opts = {}) {
280
349
  if (cur.re) {
281
350
  return escFn(res, 0, 0);
282
351
  }
352
+ if (force4Bit && cur?.fg) {
353
+ cur.fg[0] = xtermTo4Bit(cur.fg[0]);
354
+ cur.fg[2] = 0;
355
+ }
356
+ if (force4Bit && cur?.bg) {
357
+ cur.bg[0] = xtermTo4Bit(cur.bg[2] === 0 && cur.bg[0] >= 10 ? cur.bg[0] - 10 : cur.bg[0], 1);
358
+ cur.bg[2] = 0;
359
+ }
283
360
  if (cur.fg) {
284
361
  res = escFn(res, (cur.fg[2] ? "38;5;" : "") + cur.fg[0], cur.fg[1]);
285
362
  }
@@ -300,18 +377,19 @@ function createStain(opts = {}) {
300
377
  });
301
378
  return colorProxy();
302
379
  }
303
- var stain = /* @__PURE__ */ (() => createStain({ xterm: true }))();
380
+ var stain = /* @__PURE__ */ (() => createStain({ xterm: true, noColor: !!getColorSpace() }))();
304
381
  var src_default2 = stain;
305
382
  export {
383
+ xtermTo4Bit,
306
384
  stain,
385
+ getColorSpace,
307
386
  src_default2 as default,
308
387
  createStain,
309
388
  XTERM,
310
389
  RESET,
311
390
  ESC,
312
- COLOR_SPACE,
313
391
  ANSI
314
392
  };
315
393
 
316
- //# debugId=1AFEF64166D1452A64756E2164756E21
394
+ //# debugId=6513C7ED4AF96F9A64756E2164756E21
317
395
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -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 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 * @return {ColorSpace}\n */\nexport const getColorSpace = (\n argv?: string[],\n env?: NodeJS.ProcessEnv,\n gthis?: typeof globalThis,\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 // no proc\n if (typeof process === 'undefined') { 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 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,UA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KACpD,IAAI,GAAG,KAAK,KACZ,IAAI,GAAG,IAAI,CAAC;AAAA,QAChB,IAAI,GAAG,KAAK;AAAA,MACd;AAAA,MAEA,IAAI,IAAI,IAAI;AAAA,QAAE,MAAM,MAAM,MAAM,IAAI,GAAG,KAAK,UAAU,MAAM,IAAI,GAAG,IAAI,IAAI,GAAG,EAAE;AAAA,MAAG;AAAA,MACnF,IAAI,IAAI,IAAI;AAAA,QAAE,MAAM,MAAM,MAAM,IAAI,GAAG,KAAK,UAAU,MAAM,IAAI,GAAG,IAAI,IAAI,GAAG,EAAE;AAAA,MAAG;AAAA,MACnF,IAAI,IAAI,IAAI;AAAA,QAAE,MAAM,MAAM,KAAK,IAAI,GAAG,IAAI,IAAI,GAAG,IAAI,IAAI,GAAG,EAAE;AAAA,MAAG;AAAA,MACjE,IAAI,IAAI,IAAI;AAAA,QAAE,MAAM,MAAM,KAAK,IAAI,GAAG,IAAI,IAAI,GAAG,EAAE;AAAA,MAAG;AAAA,MACtD,IAAI,IAAI,IAAI;AAAA,QAAE,MAAM,MAAM,KAAK,IAAI,GAAG,IAAI,IAAI,GAAG,EAAE;AAAA,MAAG;AAAA,MACtD,OAAO;AAAA;AAAA,EAEX,CAAC;AAAA,EACH,OAAO,WAAW;AAAA;AAOpB,IAAM,yBAAyB,MAC7B,YAAY,EAAE,OAAO,MAAM,WAAW,cAAc,EAAE,CAAC,GAAG;AAG5D,IAAe;",
12
+ "debugId": "6513C7ED4AF96F9A64756E2164756E21",
12
13
  "names": []
13
14
  }
@@ -0,0 +1,116 @@
1
+ /** @about
2
+ @file: types.ts
3
+
4
+ import type {
5
+ EmptyObject,
6
+ StrNum,
7
+ TupleN,
8
+ ColorSpace,
9
+ StyleKeys,
10
+ XtermKeysFactory,
11
+ AnsiCodeTuple,
12
+ StyleState,
13
+ StainBase,
14
+ StainAnsi,
15
+ StainXterm,
16
+ } from './types.ts'
17
+
18
+ *** */
19
+ /**
20
+ * empty object utility type for representing no keys
21
+ */
22
+ export type EmptyObject = Record<never, never>;
23
+ /**
24
+ * string or number shorthand
25
+ */
26
+ export type StrNum = string | number;
27
+ /**
28
+ * helper to make tuple of N elements of type T
29
+ * @template N - tuple length (number literal type)
30
+ * @template T - element type (default: string)
31
+ */
32
+ export type TupleN<N extends number, T = string, Acc extends T[] = []> = Acc['length'] extends N ? Acc : TupleN<N, T, [...Acc, T]>;
33
+ /**
34
+ * color support level
35
+ * @default 2
36
+ * @see {@link https://nodejs.org/api/cli.html#force_color1-2-3|Node.js FORCE_COLOR docs}
37
+ */
38
+ export type ColorSpace = 0 | 1 | 2;
39
+ /**
40
+ * Style state keys
41
+ * fg=foreground; bg=background;
42
+ * ft=font; ue=underline; ie=inverse; re=reset;
43
+ * pr=previous (internal state)
44
+ */
45
+ export type StyleKeys = 'fg' | 'bg' | 'ft' | 'ue' | 'ie' | 're' | 'pr';
46
+ /**
47
+ * Generate xterms: x0 to x255
48
+ */
49
+ export type XtermKeysFactory<N extends number, Acc extends string[] = []> = Acc['length'] extends N ? Acc[number] : XtermKeysFactory<N, [...Acc, `x${Acc['length']}`]>;
50
+ /**
51
+ * tuple describing ansi on and off codes with optional flag for custom or xterm usage
52
+ * @typedef {readonly [number, number, number?]} AnsiCodeTuple
53
+ * on index 0 is the open code
54
+ * off index 1 is the close code
55
+ * isCustom index 2 indicates xterm or custom when truthy
56
+ */
57
+ export type AnsiCodeTuple = [on: number, off: number, isCustom?: number];
58
+ /**
59
+ * partial style state map for assembling ansi sequences
60
+ * keys may include fg bg ft ue ie re pr
61
+ */
62
+ export type StyleState = Partial<Record<StyleKeys, AnsiCodeTuple>>;
63
+ /**
64
+ * base named colors supported by ansi
65
+ */
66
+ export type StainBase = 'black' | 'blue' | 'cyan' | 'green' | 'purple' | 'red' | 'white' | 'yellow';
67
+ /**
68
+ * named ansi colors including intense variants prefixed with i (ired for bright red)
69
+ */
70
+ export type StainAnsi = StainBase | `i${StainBase}`;
71
+ /**
72
+ * xterm color keys generated as x0..x255
73
+ */
74
+ export type StainXterm = XtermKeysFactory<256>;
75
+ /**
76
+ * chainable stain api type
77
+ * callable to format input into a string and exposes chainable style and color properties
78
+ * includes bg bold dim normal reset underline inverse and color names
79
+ * includes xterm colors when enabled and custom colors from options
80
+ * @template C extends Record<string, number> custom color map type
81
+ * @template X extends boolean whether xterm is enabled
82
+ */
83
+ export type Stain<C extends Record<string, number> = EmptyObject, X extends boolean = false> = ((...args: any[]) => string) & {
84
+ bg: Stain<C, X>;
85
+ bold: Stain<C, X>;
86
+ dim: Stain<C, X>;
87
+ normal: Stain<C, X>;
88
+ reset: Stain<C, X>;
89
+ underline: Stain<C, X>;
90
+ inverse: Stain<C, X>;
91
+ } & {
92
+ [K in StainAnsi]: Stain<C, X>;
93
+ } & (X extends true ? {
94
+ [K in StainXterm]: Stain<C, X>;
95
+ } : EmptyObject) & (keyof C extends never ? EmptyObject : {
96
+ [K in keyof C]: Stain<C, X>;
97
+ });
98
+ /**
99
+ * options for creating a stain instance
100
+ * @template C extends Record<string, number> custom color map type
101
+ * @property {(...args: any[]) => string} [format] custom formatter for args to string
102
+ * @property {boolean} [noColor] disable color output
103
+ * @property {boolean} [xterm] enable xterm 256 color support
104
+ * @property {C} [colors] custom color name to code map
105
+ * @property {boolean} [simpleEscape] use faster simpler escape without nested handling
106
+ * @property {ColorSpace} [colorSpace] force color space, used primarly for testing
107
+ */
108
+ export type StainOpts<C extends Record<string, number> = EmptyObject> = {
109
+ format?: (...args: any[]) => string;
110
+ noColor?: boolean;
111
+ xterm?: boolean;
112
+ colors?: C;
113
+ simpleEscape?: boolean;
114
+ colorSpace?: ColorSpace;
115
+ };
116
+ //# sourceMappingURL=types.d.ts.map