ansimax 1.3.3 → 1.3.5
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/CHANGELOG.md +279 -0
- package/README.es.md +61 -3
- package/README.md +61 -3
- package/dist/index.d.mts +556 -225
- package/dist/index.d.ts +556 -225
- package/dist/index.js +478 -51
- package/dist/index.mjs +460 -51
- package/examples/all-in-one.cjs +1 -1
- package/examples/all-in-one.mjs +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -379,8 +379,26 @@ var sleepFrame = (ms = FRAME_MS, opts = {}) => sleep(
|
|
|
379
379
|
Math.max(FRAME_MS, Math.round((isFiniteNumber(ms) ? ms : FRAME_MS) / FRAME_MS) * FRAME_MS),
|
|
380
380
|
opts
|
|
381
381
|
);
|
|
382
|
+
var hyperlink = (url, label) => {
|
|
383
|
+
if (typeof url !== "string" || url.length === 0) {
|
|
384
|
+
return typeof label === "string" ? label : "";
|
|
385
|
+
}
|
|
386
|
+
const safeLabel = typeof label === "string" && label.length > 0 ? label : url;
|
|
387
|
+
return `${OSC}8;;${url}${ST}${safeLabel}${OSC}8;;${ST}`;
|
|
388
|
+
};
|
|
389
|
+
var clearLine = () => `${CSI}2K\r`;
|
|
382
390
|
|
|
383
391
|
// src/utils/helpers.ts
|
|
392
|
+
var isFiniteNumber2 = (n) => typeof n === "number" && Number.isFinite(n);
|
|
393
|
+
var safeInt = (value, fallback = 0, min = -Infinity, max = Infinity) => {
|
|
394
|
+
const isRealNumeric = typeof value === "number" || typeof value === "string" && value.trim().length > 0 && Number.isFinite(Number(value));
|
|
395
|
+
if (!isRealNumeric) {
|
|
396
|
+
return Math.max(min, Math.min(max, Math.floor(fallback)));
|
|
397
|
+
}
|
|
398
|
+
const n = Number(value);
|
|
399
|
+
if (!Number.isFinite(n)) return Math.max(min, Math.min(max, Math.floor(fallback)));
|
|
400
|
+
return Math.max(min, Math.min(max, Math.floor(n)));
|
|
401
|
+
};
|
|
384
402
|
var clamp = (n, min, max) => Math.min(Math.max(n, min), max);
|
|
385
403
|
var lerp = (a, b, t) => a + (b - a) * t;
|
|
386
404
|
var clampByte2 = (v) => clamp(Math.round(v), 0, 255);
|
|
@@ -396,25 +414,148 @@ var hexToRgb = (hex) => {
|
|
|
396
414
|
return { r: int >> 16 & 255, g: int >> 8 & 255, b: int & 255 };
|
|
397
415
|
};
|
|
398
416
|
var rgbToHex = (r, g, b) => "#" + [clampByte2(r), clampByte2(g), clampByte2(b)].map((v) => v.toString(16).padStart(2, "0")).join("");
|
|
399
|
-
var
|
|
417
|
+
var rgbToHsl = (rgb) => {
|
|
418
|
+
const r = clamp(rgb.r, 0, 255) / 255;
|
|
419
|
+
const g = clamp(rgb.g, 0, 255) / 255;
|
|
420
|
+
const b = clamp(rgb.b, 0, 255) / 255;
|
|
421
|
+
const max = Math.max(r, g, b);
|
|
422
|
+
const min = Math.min(r, g, b);
|
|
423
|
+
const l = (max + min) / 2;
|
|
424
|
+
if (max === min) {
|
|
425
|
+
return { h: 0, s: 0, l };
|
|
426
|
+
}
|
|
427
|
+
const d = max - min;
|
|
428
|
+
const s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
429
|
+
let h;
|
|
430
|
+
if (max === r) {
|
|
431
|
+
h = ((g - b) / d + (g < b ? 6 : 0)) * 60;
|
|
432
|
+
} else if (max === g) {
|
|
433
|
+
h = ((b - r) / d + 2) * 60;
|
|
434
|
+
} else {
|
|
435
|
+
h = ((r - g) / d + 4) * 60;
|
|
436
|
+
}
|
|
437
|
+
return { h, s, l };
|
|
438
|
+
};
|
|
439
|
+
var hslToRgb = (hsl) => {
|
|
440
|
+
const h = (hsl.h % 360 + 360) % 360 / 360;
|
|
441
|
+
const s = clamp(hsl.s, 0, 1);
|
|
442
|
+
const l = clamp(hsl.l, 0, 1);
|
|
443
|
+
if (s === 0) {
|
|
444
|
+
const v = Math.round(l * 255);
|
|
445
|
+
return { r: v, g: v, b: v };
|
|
446
|
+
}
|
|
447
|
+
const hue2rgb = (p2, q2, t) => {
|
|
448
|
+
let tt = t;
|
|
449
|
+
if (tt < 0) tt += 1;
|
|
450
|
+
if (tt > 1) tt -= 1;
|
|
451
|
+
if (tt < 1 / 6) return p2 + (q2 - p2) * 6 * tt;
|
|
452
|
+
if (tt < 1 / 2) return q2;
|
|
453
|
+
if (tt < 2 / 3) return p2 + (q2 - p2) * (2 / 3 - tt) * 6;
|
|
454
|
+
return p2;
|
|
455
|
+
};
|
|
456
|
+
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
457
|
+
const p = 2 * l - q;
|
|
458
|
+
return {
|
|
459
|
+
r: Math.round(hue2rgb(p, q, h + 1 / 3) * 255),
|
|
460
|
+
g: Math.round(hue2rgb(p, q, h) * 255),
|
|
461
|
+
b: Math.round(hue2rgb(p, q, h - 1 / 3) * 255)
|
|
462
|
+
};
|
|
463
|
+
};
|
|
464
|
+
var _srgbToLinear = (c) => {
|
|
465
|
+
const x = c / 255;
|
|
466
|
+
return x <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
|
|
467
|
+
};
|
|
468
|
+
var _linearToSrgb = (c) => {
|
|
469
|
+
const x = c <= 31308e-7 ? 12.92 * c : 1.055 * Math.pow(c, 1 / 2.4) - 0.055;
|
|
470
|
+
return clampByte2(x * 255);
|
|
471
|
+
};
|
|
472
|
+
var rgbToOklab = (rgb) => {
|
|
473
|
+
const r = _srgbToLinear(rgb.r);
|
|
474
|
+
const g = _srgbToLinear(rgb.g);
|
|
475
|
+
const b = _srgbToLinear(rgb.b);
|
|
476
|
+
const l = 0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b;
|
|
477
|
+
const m = 0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b;
|
|
478
|
+
const s = 0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b;
|
|
479
|
+
const l_ = Math.cbrt(l);
|
|
480
|
+
const m_ = Math.cbrt(m);
|
|
481
|
+
const s_ = Math.cbrt(s);
|
|
482
|
+
return {
|
|
483
|
+
L: 0.2104542553 * l_ + 0.793617785 * m_ - 0.0040720468 * s_,
|
|
484
|
+
a: 1.9779984951 * l_ - 2.428592205 * m_ + 0.4505937099 * s_,
|
|
485
|
+
b: 0.0259040371 * l_ + 0.7827717662 * m_ - 0.808675766 * s_
|
|
486
|
+
};
|
|
487
|
+
};
|
|
488
|
+
var oklabToRgb = (oklab) => {
|
|
489
|
+
const l_ = oklab.L + 0.3963377774 * oklab.a + 0.2158037573 * oklab.b;
|
|
490
|
+
const m_ = oklab.L - 0.1055613458 * oklab.a - 0.0638541728 * oklab.b;
|
|
491
|
+
const s_ = oklab.L - 0.0894841775 * oklab.a - 1.291485548 * oklab.b;
|
|
492
|
+
const l = l_ * l_ * l_;
|
|
493
|
+
const m = m_ * m_ * m_;
|
|
494
|
+
const s = s_ * s_ * s_;
|
|
495
|
+
const r = 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s;
|
|
496
|
+
const g = -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s;
|
|
497
|
+
const b = -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s;
|
|
498
|
+
return {
|
|
499
|
+
r: _linearToSrgb(r),
|
|
500
|
+
g: _linearToSrgb(g),
|
|
501
|
+
b: _linearToSrgb(b)
|
|
502
|
+
};
|
|
503
|
+
};
|
|
504
|
+
var lerpColor = (a, b, t, space = "rgb") => {
|
|
400
505
|
const ct = clamp(t, 0, 1);
|
|
506
|
+
if (space === "oklab") {
|
|
507
|
+
const la = rgbToOklab(a);
|
|
508
|
+
const lb = rgbToOklab(b);
|
|
509
|
+
return oklabToRgb({
|
|
510
|
+
L: lerp(la.L, lb.L, ct),
|
|
511
|
+
a: lerp(la.a, lb.a, ct),
|
|
512
|
+
b: lerp(la.b, lb.b, ct)
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
if (space === "hsl") {
|
|
516
|
+
const ha = rgbToHsl(a);
|
|
517
|
+
const hb = rgbToHsl(b);
|
|
518
|
+
let dh = hb.h - ha.h;
|
|
519
|
+
if (dh > 180) dh -= 360;
|
|
520
|
+
else if (dh < -180) dh += 360;
|
|
521
|
+
const h = ha.h + dh * ct;
|
|
522
|
+
return hslToRgb({
|
|
523
|
+
h,
|
|
524
|
+
s: lerp(ha.s, hb.s, ct),
|
|
525
|
+
l: lerp(ha.l, hb.l, ct)
|
|
526
|
+
});
|
|
527
|
+
}
|
|
401
528
|
return {
|
|
402
529
|
r: Math.round(lerp(a.r, b.r, ct)),
|
|
403
530
|
g: Math.round(lerp(a.g, b.g, ct)),
|
|
404
531
|
b: Math.round(lerp(a.b, b.b, ct))
|
|
405
532
|
};
|
|
406
533
|
};
|
|
407
|
-
var
|
|
534
|
+
var mixColors = (a, b, t, space = "rgb") => {
|
|
535
|
+
const ra = typeof a === "string" ? hexToRgb(a) : a;
|
|
536
|
+
const rb = typeof b === "string" ? hexToRgb(b) : b;
|
|
537
|
+
return lerpColor(ra, rb, t, space);
|
|
538
|
+
};
|
|
539
|
+
var quantizeColor = (color2, levels = 4) => {
|
|
540
|
+
const safeLevels = Math.max(2, Math.floor(levels));
|
|
541
|
+
const step = 255 / (safeLevels - 1);
|
|
542
|
+
return {
|
|
543
|
+
r: Math.round(clampByte2(color2.r) / step) * step | 0,
|
|
544
|
+
g: Math.round(clampByte2(color2.g) / step) * step | 0,
|
|
545
|
+
b: Math.round(clampByte2(color2.b) / step) * step | 0
|
|
546
|
+
};
|
|
547
|
+
};
|
|
548
|
+
var gradientColor = (colors, t, space = "rgb") => {
|
|
408
549
|
if (!Array.isArray(colors) || colors.length === 0) {
|
|
409
550
|
throw new Error("gradientColor requires at least one color stop");
|
|
410
551
|
}
|
|
411
552
|
if (colors.length === 1) return colors[0];
|
|
412
|
-
const safeT =
|
|
553
|
+
const safeT = isFiniteNumber2(t) ? t : 0;
|
|
413
554
|
const ct = clamp(safeT, 0, 1);
|
|
414
555
|
const scaled = ct * (colors.length - 1);
|
|
415
556
|
const lo = Math.floor(scaled);
|
|
416
557
|
const hi = Math.min(lo + 1, colors.length - 1);
|
|
417
|
-
return lerpColor(colors[lo], colors[hi], scaled - lo);
|
|
558
|
+
return lerpColor(colors[lo], colors[hi], scaled - lo, space);
|
|
418
559
|
};
|
|
419
560
|
var rgbTo256 = (r, g, b) => {
|
|
420
561
|
const cr = clampByte2(r), cg = clampByte2(g), cb = clampByte2(b);
|
|
@@ -801,6 +942,35 @@ var padBoth = (str, width, ch = " ") => {
|
|
|
801
942
|
const r = pad - l;
|
|
802
943
|
return ch.repeat(l) + str + ch.repeat(r);
|
|
803
944
|
};
|
|
945
|
+
var gradientStops = (start, end, count, space = "rgb") => {
|
|
946
|
+
const safeCount = Math.max(2, Math.floor(Number.isFinite(count) ? count : 2));
|
|
947
|
+
if (!isHexColor(start) || !isHexColor(end)) return [];
|
|
948
|
+
const a = hexToRgb(start);
|
|
949
|
+
const b = hexToRgb(end);
|
|
950
|
+
const result = [];
|
|
951
|
+
for (let i = 0; i < safeCount; i++) {
|
|
952
|
+
const t = i / (safeCount - 1);
|
|
953
|
+
const c = lerpColor(a, b, t, space);
|
|
954
|
+
result.push(rgbToHex(c.r, c.g, c.b));
|
|
955
|
+
}
|
|
956
|
+
return result;
|
|
957
|
+
};
|
|
958
|
+
var escapeForRegex = (str) => {
|
|
959
|
+
if (typeof str !== "string") return "";
|
|
960
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
961
|
+
};
|
|
962
|
+
var measureBlock = (block) => {
|
|
963
|
+
if (typeof block !== "string" || block.length === 0) {
|
|
964
|
+
return { width: 0, height: 0 };
|
|
965
|
+
}
|
|
966
|
+
const lines = block.split("\n");
|
|
967
|
+
let width = 0;
|
|
968
|
+
for (const line of lines) {
|
|
969
|
+
const w = visibleLen(line);
|
|
970
|
+
if (w > width) width = w;
|
|
971
|
+
}
|
|
972
|
+
return { width, height: lines.length };
|
|
973
|
+
};
|
|
804
974
|
|
|
805
975
|
// src/colors/index.ts
|
|
806
976
|
var _noColor = null;
|
|
@@ -1664,8 +1834,8 @@ var pulse = async (text, opts = {}) => {
|
|
|
1664
1834
|
fireDone(hooks, isAborted(signal));
|
|
1665
1835
|
return;
|
|
1666
1836
|
}
|
|
1667
|
-
const
|
|
1668
|
-
const
|
|
1837
|
+
const c12 = resolveRgb(color1);
|
|
1838
|
+
const c22 = resolveRgb(color2);
|
|
1669
1839
|
const cycles = Math.max(1, Math.round(times));
|
|
1670
1840
|
const halfInterval = Math.max(FRAME_MS, interval);
|
|
1671
1841
|
registerCrashHandlers();
|
|
@@ -1679,7 +1849,7 @@ var pulse = async (text, opts = {}) => {
|
|
|
1679
1849
|
break;
|
|
1680
1850
|
}
|
|
1681
1851
|
await safeWriteAsync(
|
|
1682
|
-
cursor.save() + fgRgb(
|
|
1852
|
+
cursor.save() + fgRgb(c12.r, c12.g, c12.b) + text + reset() + cursor.restore()
|
|
1683
1853
|
);
|
|
1684
1854
|
fireFrame(hooks, frame2++);
|
|
1685
1855
|
await sleep(halfInterval, { signal });
|
|
@@ -1688,14 +1858,14 @@ var pulse = async (text, opts = {}) => {
|
|
|
1688
1858
|
break;
|
|
1689
1859
|
}
|
|
1690
1860
|
await safeWriteAsync(
|
|
1691
|
-
cursor.save() + fgRgb(
|
|
1861
|
+
cursor.save() + fgRgb(c22.r, c22.g, c22.b) + text + reset() + cursor.restore()
|
|
1692
1862
|
);
|
|
1693
1863
|
fireFrame(hooks, frame2++);
|
|
1694
1864
|
await sleep(halfInterval, { signal });
|
|
1695
1865
|
}
|
|
1696
1866
|
if (!aborted) {
|
|
1697
1867
|
await safeWriteAsync(
|
|
1698
|
-
cursor.save() + fgRgb(
|
|
1868
|
+
cursor.save() + fgRgb(c12.r, c12.g, c12.b) + text + reset() + cursor.restore()
|
|
1699
1869
|
);
|
|
1700
1870
|
}
|
|
1701
1871
|
} finally {
|
|
@@ -1924,6 +2094,131 @@ var delay = (ms) => async (opts = {}) => {
|
|
|
1924
2094
|
} catch {
|
|
1925
2095
|
}
|
|
1926
2096
|
};
|
|
2097
|
+
var shake = async (text, opts = {}) => {
|
|
2098
|
+
const {
|
|
2099
|
+
times = 5,
|
|
2100
|
+
intensity = 2,
|
|
2101
|
+
interval = 50,
|
|
2102
|
+
newline = true,
|
|
2103
|
+
signal,
|
|
2104
|
+
reducedMotion = false,
|
|
2105
|
+
onFrame,
|
|
2106
|
+
onDone,
|
|
2107
|
+
onAbort
|
|
2108
|
+
} = opts;
|
|
2109
|
+
const hooks = { onFrame, onDone, onAbort };
|
|
2110
|
+
if (reducedMotion || isAborted(signal)) {
|
|
2111
|
+
safeWrite(text);
|
|
2112
|
+
if (newline) writeln();
|
|
2113
|
+
fireDone(hooks, isAborted(signal));
|
|
2114
|
+
return;
|
|
2115
|
+
}
|
|
2116
|
+
const safeText = typeof text === "string" ? text : "";
|
|
2117
|
+
const safeTimes = Math.max(1, Math.round(times));
|
|
2118
|
+
const safeIntensity = Math.max(1, Math.round(intensity));
|
|
2119
|
+
const safeInterval = Math.max(FRAME_MS, interval);
|
|
2120
|
+
const pattern = [0, safeIntensity, 0, -safeIntensity];
|
|
2121
|
+
registerCrashHandlers();
|
|
2122
|
+
hideCursorSafe();
|
|
2123
|
+
let aborted = false;
|
|
2124
|
+
let frame2 = 0;
|
|
2125
|
+
try {
|
|
2126
|
+
for (let cycle = 0; cycle < safeTimes; cycle++) {
|
|
2127
|
+
for (const offset of pattern) {
|
|
2128
|
+
if (isAborted(signal)) {
|
|
2129
|
+
aborted = true;
|
|
2130
|
+
break;
|
|
2131
|
+
}
|
|
2132
|
+
const prefix = offset > 0 ? " ".repeat(offset) : "";
|
|
2133
|
+
await safeWriteAsync(
|
|
2134
|
+
cursor.save() + screen.clearLine() + "\r" + prefix + safeText + cursor.restore()
|
|
2135
|
+
);
|
|
2136
|
+
fireFrame(hooks, frame2++);
|
|
2137
|
+
await sleep(safeInterval, { signal });
|
|
2138
|
+
}
|
|
2139
|
+
if (aborted) break;
|
|
2140
|
+
}
|
|
2141
|
+
if (!aborted) {
|
|
2142
|
+
await safeWriteAsync(cursor.save() + screen.clearLine() + "\r" + safeText + cursor.restore());
|
|
2143
|
+
}
|
|
2144
|
+
} finally {
|
|
2145
|
+
showCursorSafe();
|
|
2146
|
+
if (newline) writeln();
|
|
2147
|
+
fireDone(hooks, aborted);
|
|
2148
|
+
}
|
|
2149
|
+
};
|
|
2150
|
+
var countUp = async (from, to, opts = {}) => {
|
|
2151
|
+
const {
|
|
2152
|
+
duration = 1500,
|
|
2153
|
+
steps = 60,
|
|
2154
|
+
decimals = 0,
|
|
2155
|
+
format = (n) => n.toString(),
|
|
2156
|
+
easing = (t) => t,
|
|
2157
|
+
newline = true,
|
|
2158
|
+
signal,
|
|
2159
|
+
reducedMotion = false,
|
|
2160
|
+
onFrame,
|
|
2161
|
+
onDone,
|
|
2162
|
+
onAbort
|
|
2163
|
+
} = opts;
|
|
2164
|
+
const hooks = { onFrame, onDone, onAbort };
|
|
2165
|
+
const safeFrom = Number.isFinite(from) ? from : 0;
|
|
2166
|
+
const safeTo = Number.isFinite(to) ? to : 0;
|
|
2167
|
+
const safeDecimals = Math.max(0, Math.min(20, Math.floor(decimals)));
|
|
2168
|
+
const safeFormat = typeof format === "function" ? format : (n) => n.toString();
|
|
2169
|
+
const safeEasing = typeof easing === "function" ? easing : (t) => t;
|
|
2170
|
+
if (reducedMotion || isAborted(signal)) {
|
|
2171
|
+
safeWrite(safeFormat(parseFloat(safeTo.toFixed(safeDecimals))));
|
|
2172
|
+
if (newline) writeln();
|
|
2173
|
+
fireDone(hooks, isAborted(signal));
|
|
2174
|
+
return;
|
|
2175
|
+
}
|
|
2176
|
+
const safeSteps2 = Math.max(1, Math.round(steps));
|
|
2177
|
+
const interval = Math.max(FRAME_MS, Math.round(duration / safeSteps2));
|
|
2178
|
+
registerCrashHandlers();
|
|
2179
|
+
hideCursorSafe();
|
|
2180
|
+
let aborted = false;
|
|
2181
|
+
let frame2 = 0;
|
|
2182
|
+
try {
|
|
2183
|
+
for (let i = 0; i <= safeSteps2; i++) {
|
|
2184
|
+
if (isAborted(signal)) {
|
|
2185
|
+
aborted = true;
|
|
2186
|
+
break;
|
|
2187
|
+
}
|
|
2188
|
+
const t = i / safeSteps2;
|
|
2189
|
+
const eased = safeEasing(Math.max(0, Math.min(1, t)));
|
|
2190
|
+
const current = safeFrom + (safeTo - safeFrom) * eased;
|
|
2191
|
+
const rounded = parseFloat(current.toFixed(safeDecimals));
|
|
2192
|
+
let display;
|
|
2193
|
+
try {
|
|
2194
|
+
display = safeFormat(rounded);
|
|
2195
|
+
} catch {
|
|
2196
|
+
display = String(rounded);
|
|
2197
|
+
}
|
|
2198
|
+
await safeWriteAsync(
|
|
2199
|
+
cursor.save() + screen.clearLine() + "\r" + display + cursor.restore()
|
|
2200
|
+
);
|
|
2201
|
+
fireFrame(hooks, frame2++);
|
|
2202
|
+
if (i < safeSteps2) await sleep(interval, { signal });
|
|
2203
|
+
}
|
|
2204
|
+
if (!aborted) {
|
|
2205
|
+
const final = parseFloat(safeTo.toFixed(safeDecimals));
|
|
2206
|
+
let display;
|
|
2207
|
+
try {
|
|
2208
|
+
display = safeFormat(final);
|
|
2209
|
+
} catch {
|
|
2210
|
+
display = String(final);
|
|
2211
|
+
}
|
|
2212
|
+
await safeWriteAsync(
|
|
2213
|
+
cursor.save() + screen.clearLine() + "\r" + display + cursor.restore()
|
|
2214
|
+
);
|
|
2215
|
+
}
|
|
2216
|
+
} finally {
|
|
2217
|
+
showCursorSafe();
|
|
2218
|
+
if (newline) writeln();
|
|
2219
|
+
fireDone(hooks, aborted);
|
|
2220
|
+
}
|
|
2221
|
+
};
|
|
1927
2222
|
var animate = {
|
|
1928
2223
|
typewriter,
|
|
1929
2224
|
fadeIn,
|
|
@@ -1936,7 +2231,10 @@ var animate = {
|
|
|
1936
2231
|
sequence,
|
|
1937
2232
|
chain: chain2,
|
|
1938
2233
|
parallel,
|
|
1939
|
-
delay
|
|
2234
|
+
delay,
|
|
2235
|
+
// v1.3.4
|
|
2236
|
+
shake,
|
|
2237
|
+
countUp
|
|
1940
2238
|
};
|
|
1941
2239
|
|
|
1942
2240
|
// src/ascii/index.ts
|
|
@@ -2738,14 +3036,14 @@ var ascii = {
|
|
|
2738
3036
|
|
|
2739
3037
|
// src/loaders/index.ts
|
|
2740
3038
|
var canAnimate2 = () => Boolean(process.stdout?.isTTY) && supportsColor() !== "none";
|
|
2741
|
-
var
|
|
3039
|
+
var isFiniteNumber3 = (n) => typeof n === "number" && Number.isFinite(n);
|
|
2742
3040
|
var ensureString3 = (v) => typeof v === "string" ? v : String(v ?? "");
|
|
2743
3041
|
var clampPositiveInt = (n, fallback) => {
|
|
2744
|
-
if (!
|
|
3042
|
+
if (!isFiniteNumber3(n)) return fallback;
|
|
2745
3043
|
return Math.max(1, Math.floor(n));
|
|
2746
3044
|
};
|
|
2747
3045
|
var clampPercent = (p) => {
|
|
2748
|
-
if (!
|
|
3046
|
+
if (!isFiniteNumber3(p)) return 0;
|
|
2749
3047
|
return Math.max(0, Math.min(100, p));
|
|
2750
3048
|
};
|
|
2751
3049
|
var isUnicodeCapable = () => {
|
|
@@ -3137,7 +3435,7 @@ var custom = (frames2, text = "", opts = {}) => {
|
|
|
3137
3435
|
};
|
|
3138
3436
|
var countdown = async (seconds, opts = {}) => {
|
|
3139
3437
|
const { label = "Starting in", color: hex, signal } = opts;
|
|
3140
|
-
const safeSeconds =
|
|
3438
|
+
const safeSeconds = isFiniteNumber3(seconds) ? Math.max(0, Math.floor(seconds)) : 0;
|
|
3141
3439
|
const safeLabel = ensureString3(label);
|
|
3142
3440
|
const colorToUse = safeColor(hex) ? hex : "#ffd700";
|
|
3143
3441
|
if (!canAnimate2() || signal?.aborted) {
|
|
@@ -3344,11 +3642,11 @@ var loader = {
|
|
|
3344
3642
|
};
|
|
3345
3643
|
|
|
3346
3644
|
// src/frames/index.ts
|
|
3347
|
-
var
|
|
3645
|
+
var isFiniteNumber4 = (n) => typeof n === "number" && Number.isFinite(n);
|
|
3348
3646
|
var ensureString4 = (v) => typeof v === "string" ? v : String(v ?? "");
|
|
3349
3647
|
var MAX_FPS = 60;
|
|
3350
3648
|
var clampFps = (fps, fallback) => {
|
|
3351
|
-
if (!
|
|
3649
|
+
if (!isFiniteNumber4(fps)) return fallback;
|
|
3352
3650
|
return Math.max(1, Math.min(MAX_FPS, Math.floor(fps)));
|
|
3353
3651
|
};
|
|
3354
3652
|
var _cursorHiddenCount2 = 0;
|
|
@@ -3447,14 +3745,14 @@ var play = (frames2, opts = {}) => {
|
|
|
3447
3745
|
if (fps !== void 0) {
|
|
3448
3746
|
const safeFps = clampFps(fps, 60);
|
|
3449
3747
|
tickMs = Math.max(FRAME_MS, Math.floor(1e3 / safeFps));
|
|
3450
|
-
} else if (
|
|
3748
|
+
} else if (isFiniteNumber4(interval)) {
|
|
3451
3749
|
tickMs = Math.max(FRAME_MS, Math.floor(interval));
|
|
3452
3750
|
} else {
|
|
3453
3751
|
tickMs = 100;
|
|
3454
3752
|
}
|
|
3455
3753
|
let safeRepeat;
|
|
3456
3754
|
let infinite;
|
|
3457
|
-
if (!
|
|
3755
|
+
if (!isFiniteNumber4(repeat)) {
|
|
3458
3756
|
safeRepeat = 1;
|
|
3459
3757
|
infinite = false;
|
|
3460
3758
|
} else if (repeat === 0) {
|
|
@@ -3579,7 +3877,7 @@ var play = (frames2, opts = {}) => {
|
|
|
3579
3877
|
paused = false;
|
|
3580
3878
|
},
|
|
3581
3879
|
seek: (idx) => {
|
|
3582
|
-
if (!
|
|
3880
|
+
if (!isFiniteNumber4(idx)) return;
|
|
3583
3881
|
const safe = Math.max(0, Math.floor(idx));
|
|
3584
3882
|
frameIdx = frames2.length > 0 ? safe % frames2.length : 0;
|
|
3585
3883
|
},
|
|
@@ -3592,7 +3890,7 @@ var play = (frames2, opts = {}) => {
|
|
|
3592
3890
|
};
|
|
3593
3891
|
};
|
|
3594
3892
|
var generate = (count, fn) => {
|
|
3595
|
-
const safeCount =
|
|
3893
|
+
const safeCount = isFiniteNumber4(count) ? Math.max(0, Math.floor(count)) : 0;
|
|
3596
3894
|
if (typeof fn !== "function") return Array(safeCount).fill("");
|
|
3597
3895
|
return Array.from({ length: safeCount }, (_, i) => {
|
|
3598
3896
|
try {
|
|
@@ -3664,7 +3962,7 @@ var morph = (frameA, frameB, steps = 8, charset = "\u2591\u2592\u2593\u2588\u259
|
|
|
3664
3962
|
const a0 = ensureString4(frameA);
|
|
3665
3963
|
const b0 = ensureString4(frameB);
|
|
3666
3964
|
if (!a0 && !b0) return [""];
|
|
3667
|
-
const n = Math.max(2,
|
|
3965
|
+
const n = Math.max(2, isFiniteNumber4(steps) ? Math.floor(steps) : 8);
|
|
3668
3966
|
const len = Math.max(a0.length, b0.length);
|
|
3669
3967
|
const a = a0.padEnd(len);
|
|
3670
3968
|
const b = b0.padEnd(len);
|
|
@@ -3686,7 +3984,7 @@ var morph = (frameA, frameB, steps = 8, charset = "\u2591\u2592\u2593\u2588\u259
|
|
|
3686
3984
|
var presets2 = {
|
|
3687
3985
|
loadingBar: (opts = {}) => {
|
|
3688
3986
|
const { width = 20, char = "\u2588", empty = "\u2591", label = "Loading" } = opts;
|
|
3689
|
-
const safeWidth = Math.max(0,
|
|
3987
|
+
const safeWidth = Math.max(0, isFiniteNumber4(width) ? Math.floor(width) : 20);
|
|
3690
3988
|
const safeChar = typeof char === "string" && char.length > 0 ? char : "\u2588";
|
|
3691
3989
|
const safeEmpty = typeof empty === "string" && empty.length > 0 ? empty : "\u2591";
|
|
3692
3990
|
const safeLabel = ensureString4(label);
|
|
@@ -3700,7 +3998,7 @@ var presets2 = {
|
|
|
3700
3998
|
/* istanbul ignore next — default opts {} */
|
|
3701
3999
|
ball: (opts = {}) => {
|
|
3702
4000
|
const { width = 20, char = "\u25CF" } = opts;
|
|
3703
|
-
const safeWidth = Math.max(1,
|
|
4001
|
+
const safeWidth = Math.max(1, isFiniteNumber4(width) ? Math.floor(width) : 20);
|
|
3704
4002
|
const safeChar = typeof char === "string" && char.length > 0 ? char : "\u25CF";
|
|
3705
4003
|
const forward = generate(safeWidth, (i) => " ".repeat(i) + safeChar);
|
|
3706
4004
|
const backward = generate(safeWidth, (i) => " ".repeat(safeWidth - i - 1) + safeChar);
|
|
@@ -3710,7 +4008,7 @@ var presets2 = {
|
|
|
3710
4008
|
breathe: (text, opts = {}) => {
|
|
3711
4009
|
const { steps = 8 } = opts;
|
|
3712
4010
|
const safeText = ensureString4(text);
|
|
3713
|
-
const safeSteps2 = Math.max(1,
|
|
4011
|
+
const safeSteps2 = Math.max(1, isFiniteNumber4(steps) ? Math.floor(steps) : 8);
|
|
3714
4012
|
const shades = ["\u2591", "\u2592", "\u2593", "\u2588"];
|
|
3715
4013
|
return generate(safeSteps2 * 2, (i) => {
|
|
3716
4014
|
const t = i < safeSteps2 ? i / safeSteps2 : 1 - (i - safeSteps2) / safeSteps2;
|
|
@@ -3731,22 +4029,22 @@ var presets2 = {
|
|
|
3731
4029
|
var frames = { play, generate, live, morph, presets: presets2 };
|
|
3732
4030
|
|
|
3733
4031
|
// src/components/index.ts
|
|
3734
|
-
var
|
|
4032
|
+
var isFiniteNumber5 = (n) => typeof n === "number" && Number.isFinite(n);
|
|
3735
4033
|
var ensureString5 = (v) => typeof v === "string" ? v : String(v ?? "");
|
|
3736
4034
|
var clampPercent2 = (p) => {
|
|
3737
|
-
if (!
|
|
4035
|
+
if (!isFiniteNumber5(p)) return 0;
|
|
3738
4036
|
return Math.max(0, Math.min(100, p));
|
|
3739
4037
|
};
|
|
3740
4038
|
var clampNonNeg = (n, fallback) => {
|
|
3741
|
-
if (!
|
|
4039
|
+
if (!isFiniteNumber5(n)) return fallback;
|
|
3742
4040
|
return Math.max(0, Math.floor(n));
|
|
3743
4041
|
};
|
|
3744
4042
|
var clampPositive2 = (n, fallback) => {
|
|
3745
|
-
if (!
|
|
4043
|
+
if (!isFiniteNumber5(n)) return fallback;
|
|
3746
4044
|
return Math.max(1, Math.floor(n));
|
|
3747
4045
|
};
|
|
3748
4046
|
var safeSgrCode = (code, fallback) => {
|
|
3749
|
-
if (!
|
|
4047
|
+
if (!isFiniteNumber5(code)) return fallback;
|
|
3750
4048
|
return Math.max(0, Math.min(255, Math.floor(code)));
|
|
3751
4049
|
};
|
|
3752
4050
|
var truncateVisible = (str, maxWidth, ellipsis = "\u2026") => {
|
|
@@ -3784,7 +4082,7 @@ var table = (rows, opts = {}) => {
|
|
|
3784
4082
|
const b = TABLE_BORDERS[borderStyle] ?? TABLE_BORDERS.rounded;
|
|
3785
4083
|
const safePadding = clampNonNeg(padding, 1);
|
|
3786
4084
|
const pad = " ".repeat(safePadding);
|
|
3787
|
-
const safeMaxCol = maxColWidth !== null &&
|
|
4085
|
+
const safeMaxCol = maxColWidth !== null && isFiniteNumber5(maxColWidth) ? Math.max(1, Math.floor(maxColWidth)) : null;
|
|
3788
4086
|
const validRows = rows.filter((r) => Array.isArray(r));
|
|
3789
4087
|
if (validRows.length === 0) return "";
|
|
3790
4088
|
const cols = Math.max(...validRows.map((r) => r.length), 0);
|
|
@@ -3865,7 +4163,7 @@ var progressBar = (percent, opts = {}) => {
|
|
|
3865
4163
|
showPercentage = true,
|
|
3866
4164
|
label = "",
|
|
3867
4165
|
color: color2 = null,
|
|
3868
|
-
gradient:
|
|
4166
|
+
gradient: gradientStops2 = null
|
|
3869
4167
|
} = opts;
|
|
3870
4168
|
const safeWidth = clampPositive2(width, 30);
|
|
3871
4169
|
const safeChar = typeof char === "string" && char.length > 0 ? char : "\u2588";
|
|
@@ -3875,9 +4173,9 @@ var progressBar = (percent, opts = {}) => {
|
|
|
3875
4173
|
const filled = Math.floor(clamped / 100 * safeWidth);
|
|
3876
4174
|
const empty = Math.max(0, safeWidth - filled);
|
|
3877
4175
|
let filledStr = safeChar.repeat(filled);
|
|
3878
|
-
if (Array.isArray(
|
|
3879
|
-
filledStr = gradient(filledStr,
|
|
3880
|
-
} else if (color2 !== null &&
|
|
4176
|
+
if (Array.isArray(gradientStops2) && gradientStops2.length >= 1 && filled > 0) {
|
|
4177
|
+
filledStr = gradient(filledStr, gradientStops2);
|
|
4178
|
+
} else if (color2 !== null && isFiniteNumber5(color2)) {
|
|
3881
4179
|
filledStr = sgr(safeSgrCode(color2, FG.white)) + filledStr + reset();
|
|
3882
4180
|
}
|
|
3883
4181
|
const emptyStr = safeEmpty.repeat(empty);
|
|
@@ -3913,7 +4211,7 @@ var section = (title, opts = {}) => {
|
|
|
3913
4211
|
const safeChar = typeof char === "string" && char.length > 0 ? char : "\u2500";
|
|
3914
4212
|
const safeColor2 = safeSgrCode(colorCode, FG.cyan);
|
|
3915
4213
|
const titleLen = visibleLen(safeTitle);
|
|
3916
|
-
const requestedWidth = width !== null &&
|
|
4214
|
+
const requestedWidth = width !== null && isFiniteNumber5(width) ? Math.max(1, Math.floor(width)) : cols;
|
|
3917
4215
|
const w = Math.max(requestedWidth, titleLen + 2);
|
|
3918
4216
|
const side = Math.floor((w - titleLen - 2) / 2);
|
|
3919
4217
|
const dividerL = sgr(safeColor2) + safeChar.repeat(Math.max(0, side)) + reset();
|
|
@@ -3927,7 +4225,7 @@ var columns = (items, opts = {}) => {
|
|
|
3927
4225
|
const safeCols = clampPositive2(numCols, 2);
|
|
3928
4226
|
const safeGap = clampNonNeg(gap, 2);
|
|
3929
4227
|
const { cols: termCols } = termSize();
|
|
3930
|
-
const totalW = width !== null &&
|
|
4228
|
+
const totalW = width !== null && isFiniteNumber5(width) ? Math.max(safeCols, Math.floor(width)) : termCols;
|
|
3931
4229
|
const colW = Math.max(1, Math.floor((totalW - safeGap * (safeCols - 1)) / safeCols));
|
|
3932
4230
|
const gapStr = " ".repeat(safeGap);
|
|
3933
4231
|
const rows = [];
|
|
@@ -3967,7 +4265,7 @@ var timeline = (events, opts = {}) => {
|
|
|
3967
4265
|
const safeColor2 = safeSgrCode(colorCode, FG.cyan);
|
|
3968
4266
|
const safeDoneColor = safeSgrCode(doneColor, FG.green);
|
|
3969
4267
|
const safePendingColor = safeSgrCode(pendingColor, FG.brightBlack);
|
|
3970
|
-
const computedTimeWidth = timeColumnWidth !== null &&
|
|
4268
|
+
const computedTimeWidth = timeColumnWidth !== null && isFiniteNumber5(timeColumnWidth) ? Math.max(0, Math.floor(timeColumnWidth)) : Math.max(0, ...events.map((e) => e.time ? visibleLen(ensureString5(e.time)) : 0));
|
|
3971
4269
|
const lines = [];
|
|
3972
4270
|
events.forEach((ev, i) => {
|
|
3973
4271
|
const isLast = i === events.length - 1;
|
|
@@ -4159,10 +4457,10 @@ var STYLES = {
|
|
|
4159
4457
|
heavy: { branch: "\u2523\u2501\u2501 ", last: "\u2517\u2501\u2501 ", vert: "\u2503 ", space: " " },
|
|
4160
4458
|
ascii: { branch: "+-- ", last: "`-- ", vert: "| ", space: " " }
|
|
4161
4459
|
};
|
|
4162
|
-
var
|
|
4460
|
+
var isFiniteNumber6 = (n) => typeof n === "number" && Number.isFinite(n);
|
|
4163
4461
|
var ensureString6 = (v) => typeof v === "string" ? v : String(v ?? "");
|
|
4164
4462
|
var clampNonNeg2 = (n, fallback) => {
|
|
4165
|
-
if (!
|
|
4463
|
+
if (!isFiniteNumber6(n)) return fallback;
|
|
4166
4464
|
return Math.max(0, Math.floor(n));
|
|
4167
4465
|
};
|
|
4168
4466
|
var normalizeNewlines = (s) => s.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
@@ -4234,7 +4532,7 @@ var renderChildren = (children, parentContinuation, lines, indentStr, defaultSty
|
|
|
4234
4532
|
if (!Array.isArray(children)) return;
|
|
4235
4533
|
let visible = children;
|
|
4236
4534
|
let collapsedCount = 0;
|
|
4237
|
-
const safeCollapse =
|
|
4535
|
+
const safeCollapse = isFiniteNumber6(collapse) ? Math.floor(collapse) : 0;
|
|
4238
4536
|
if (safeCollapse > 0 && safeCollapse < children.length) {
|
|
4239
4537
|
visible = children.slice(safeCollapse);
|
|
4240
4538
|
collapsedCount = safeCollapse;
|
|
@@ -4304,7 +4602,7 @@ var renderTree = (root, opts = {}) => {
|
|
|
4304
4602
|
} = opts;
|
|
4305
4603
|
const safeStyle = style && STYLES[style] ? style : "normal";
|
|
4306
4604
|
const safeIndent = clampNonNeg2(indent, 0);
|
|
4307
|
-
const safeMaxDepth =
|
|
4605
|
+
const safeMaxDepth = isFiniteNumber6(maxDepth) ? Math.max(0, Math.floor(maxDepth)) : Infinity;
|
|
4308
4606
|
const indentStr = " ".repeat(safeIndent);
|
|
4309
4607
|
const lines = [];
|
|
4310
4608
|
const rootLabel = formatNode(root, 0, palette);
|
|
@@ -4923,13 +5221,13 @@ var themes = {
|
|
|
4923
5221
|
var FULL_BLOCK = "\u2588";
|
|
4924
5222
|
var UPPER_HALF = "\u2580";
|
|
4925
5223
|
var LOWER_HALF = "\u2584";
|
|
4926
|
-
var
|
|
5224
|
+
var isFiniteNumber7 = (n) => typeof n === "number" && Number.isFinite(n);
|
|
4927
5225
|
var clampInt = (n, min, max, fallback) => {
|
|
4928
|
-
if (!
|
|
5226
|
+
if (!isFiniteNumber7(n)) return fallback;
|
|
4929
5227
|
return Math.max(min, Math.min(max, Math.floor(n)));
|
|
4930
5228
|
};
|
|
4931
5229
|
var clampByte3 = (n) => {
|
|
4932
|
-
if (!
|
|
5230
|
+
if (!isFiniteNumber7(n)) return 0;
|
|
4933
5231
|
return Math.max(0, Math.min(255, Math.round(n)));
|
|
4934
5232
|
};
|
|
4935
5233
|
var MAX_DIMENSION = 1e4;
|
|
@@ -5234,7 +5532,7 @@ var gradientRect = (opts = {}) => {
|
|
|
5234
5532
|
const safeW = clampInt(width, 2, MAX_DIMENSION, 40);
|
|
5235
5533
|
const safeH = clampInt(height, 2, MAX_DIMENSION, 10);
|
|
5236
5534
|
let cosA = 1, sinA = 0;
|
|
5237
|
-
if (
|
|
5535
|
+
if (isFiniteNumber7(angle)) {
|
|
5238
5536
|
const rad = angle * Math.PI / 180;
|
|
5239
5537
|
cosA = Math.cos(rad);
|
|
5240
5538
|
sinA = Math.sin(rad);
|
|
@@ -5244,7 +5542,7 @@ var gradientRect = (opts = {}) => {
|
|
|
5244
5542
|
const line = [];
|
|
5245
5543
|
for (let col = 0; col < safeW; col++) {
|
|
5246
5544
|
let t;
|
|
5247
|
-
if (
|
|
5545
|
+
if (isFiniteNumber7(angle)) {
|
|
5248
5546
|
const projection = col / (safeW - 1) * cosA + row / (safeH - 1) * sinA;
|
|
5249
5547
|
t = clamp((projection + 1) / 2, 0, 1);
|
|
5250
5548
|
} else if (style === "horizontal") t = col / (safeW - 1);
|
|
@@ -5301,7 +5599,7 @@ var createCanvas = (width, height, fillColor = null) => {
|
|
|
5301
5599
|
if (y > dirtyMaxY) dirtyMaxY = y;
|
|
5302
5600
|
};
|
|
5303
5601
|
const setInternal = (x, y, color2) => {
|
|
5304
|
-
if (!
|
|
5602
|
+
if (!isFiniteNumber7(x) || !isFiniteNumber7(y)) return;
|
|
5305
5603
|
const ix = Math.floor(x);
|
|
5306
5604
|
const iy = Math.floor(y);
|
|
5307
5605
|
if (iy < 0 || iy >= h || ix < 0 || ix >= w) return;
|
|
@@ -5316,7 +5614,7 @@ var createCanvas = (width, height, fillColor = null) => {
|
|
|
5316
5614
|
},
|
|
5317
5615
|
set: setInternal,
|
|
5318
5616
|
get(x, y) {
|
|
5319
|
-
if (!
|
|
5617
|
+
if (!isFiniteNumber7(x) || !isFiniteNumber7(y)) return null;
|
|
5320
5618
|
const ix = Math.floor(x), iy = Math.floor(y);
|
|
5321
5619
|
return cloneColor(pixels[iy]?.[ix] ?? null);
|
|
5322
5620
|
},
|
|
@@ -5332,7 +5630,7 @@ var createCanvas = (width, height, fillColor = null) => {
|
|
|
5332
5630
|
dirtyMaxY = h - 1;
|
|
5333
5631
|
},
|
|
5334
5632
|
drawRect(x, y, rw, rh, color2, fill = false) {
|
|
5335
|
-
if (!
|
|
5633
|
+
if (!isFiniteNumber7(x) || !isFiniteNumber7(y) || !isFiniteNumber7(rw) || !isFiniteNumber7(rh)) return;
|
|
5336
5634
|
if (rw <= 0 || rh <= 0) return;
|
|
5337
5635
|
const ix = Math.floor(x);
|
|
5338
5636
|
const iy = Math.floor(y);
|
|
@@ -5354,7 +5652,7 @@ var createCanvas = (width, height, fillColor = null) => {
|
|
|
5354
5652
|
}
|
|
5355
5653
|
},
|
|
5356
5654
|
drawCircle(cx, cy, radius, color2, fill = false) {
|
|
5357
|
-
if (!
|
|
5655
|
+
if (!isFiniteNumber7(cx) || !isFiniteNumber7(cy) || !isFiniteNumber7(radius)) return;
|
|
5358
5656
|
if (radius <= 0) return;
|
|
5359
5657
|
const x0 = Math.max(0, Math.floor(cx - radius - 1));
|
|
5360
5658
|
const y0 = Math.max(0, Math.floor(cy - radius - 1));
|
|
@@ -5377,7 +5675,7 @@ var createCanvas = (width, height, fillColor = null) => {
|
|
|
5377
5675
|
}
|
|
5378
5676
|
},
|
|
5379
5677
|
drawSprite(x, y, sprite) {
|
|
5380
|
-
if (!
|
|
5678
|
+
if (!isFiniteNumber7(x) || !isFiniteNumber7(y)) return;
|
|
5381
5679
|
if (!Array.isArray(sprite)) return;
|
|
5382
5680
|
const sx = Math.floor(x);
|
|
5383
5681
|
const sy = Math.floor(y);
|
|
@@ -6134,6 +6432,99 @@ var withConfig = (overrides, fn) => {
|
|
|
6134
6432
|
throw err;
|
|
6135
6433
|
}
|
|
6136
6434
|
};
|
|
6435
|
+
var setConfigValue = (key, value) => {
|
|
6436
|
+
configure({ [key]: value });
|
|
6437
|
+
};
|
|
6438
|
+
var subscribeConfig = onConfigChange;
|
|
6439
|
+
|
|
6440
|
+
// src/utils/easing.ts
|
|
6441
|
+
var c1 = 1.70158;
|
|
6442
|
+
var c2 = c1 * 1.525;
|
|
6443
|
+
var c3 = c1 + 1;
|
|
6444
|
+
var c4 = 2 * Math.PI / 3;
|
|
6445
|
+
var c5 = 2 * Math.PI / 4.5;
|
|
6446
|
+
var _bounceOut = (t) => {
|
|
6447
|
+
const n1 = 7.5625;
|
|
6448
|
+
const d1 = 2.75;
|
|
6449
|
+
if (t < 1 / d1) return n1 * t * t;
|
|
6450
|
+
if (t < 2 / d1) {
|
|
6451
|
+
const x2 = t - 1.5 / d1;
|
|
6452
|
+
return n1 * x2 * x2 + 0.75;
|
|
6453
|
+
}
|
|
6454
|
+
if (t < 2.5 / d1) {
|
|
6455
|
+
const x2 = t - 2.25 / d1;
|
|
6456
|
+
return n1 * x2 * x2 + 0.9375;
|
|
6457
|
+
}
|
|
6458
|
+
const x = t - 2.625 / d1;
|
|
6459
|
+
return n1 * x * x + 0.984375;
|
|
6460
|
+
};
|
|
6461
|
+
var easings = {
|
|
6462
|
+
// ── Linear ──
|
|
6463
|
+
linear: (t) => t,
|
|
6464
|
+
// ── Quadratic (t²) ──
|
|
6465
|
+
easeInQuad: (t) => t * t,
|
|
6466
|
+
easeOutQuad: (t) => 1 - (1 - t) * (1 - t),
|
|
6467
|
+
easeInOutQuad: (t) => t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2,
|
|
6468
|
+
// ── Cubic (t³) ──
|
|
6469
|
+
easeInCubic: (t) => t * t * t,
|
|
6470
|
+
easeOutCubic: (t) => 1 - Math.pow(1 - t, 3),
|
|
6471
|
+
easeInOutCubic: (t) => t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2,
|
|
6472
|
+
// ── Quartic (t⁴) ──
|
|
6473
|
+
easeInQuart: (t) => t * t * t * t,
|
|
6474
|
+
easeOutQuart: (t) => 1 - Math.pow(1 - t, 4),
|
|
6475
|
+
easeInOutQuart: (t) => t < 0.5 ? 8 * t * t * t * t : 1 - Math.pow(-2 * t + 2, 4) / 2,
|
|
6476
|
+
// ── Quintic (t⁵) ──
|
|
6477
|
+
easeInQuint: (t) => t * t * t * t * t,
|
|
6478
|
+
easeOutQuint: (t) => 1 - Math.pow(1 - t, 5),
|
|
6479
|
+
easeInOutQuint: (t) => t < 0.5 ? 16 * t * t * t * t * t : 1 - Math.pow(-2 * t + 2, 5) / 2,
|
|
6480
|
+
// ── Sinusoidal ──
|
|
6481
|
+
easeInSine: (t) => 1 - Math.cos(t * Math.PI / 2),
|
|
6482
|
+
easeOutSine: (t) => Math.sin(t * Math.PI / 2),
|
|
6483
|
+
easeInOutSine: (t) => -(Math.cos(Math.PI * t) - 1) / 2,
|
|
6484
|
+
// ── Exponential ──
|
|
6485
|
+
easeInExpo: (t) => t === 0 ? 0 : Math.pow(2, 10 * t - 10),
|
|
6486
|
+
easeOutExpo: (t) => t === 1 ? 1 : 1 - Math.pow(2, -10 * t),
|
|
6487
|
+
easeInOutExpo: (t) => {
|
|
6488
|
+
if (t === 0) return 0;
|
|
6489
|
+
if (t === 1) return 1;
|
|
6490
|
+
return t < 0.5 ? Math.pow(2, 20 * t - 10) / 2 : (2 - Math.pow(2, -20 * t + 10)) / 2;
|
|
6491
|
+
},
|
|
6492
|
+
// ── Circular ──
|
|
6493
|
+
easeInCirc: (t) => 1 - Math.sqrt(1 - Math.pow(t, 2)),
|
|
6494
|
+
easeOutCirc: (t) => Math.sqrt(1 - Math.pow(t - 1, 2)),
|
|
6495
|
+
easeInOutCirc: (t) => t < 0.5 ? (1 - Math.sqrt(1 - Math.pow(2 * t, 2))) / 2 : (Math.sqrt(1 - Math.pow(-2 * t + 2, 2)) + 1) / 2,
|
|
6496
|
+
// ── Back (overshoots) ──
|
|
6497
|
+
easeInBack: (t) => c3 * t * t * t - c1 * t * t,
|
|
6498
|
+
easeOutBack: (t) => 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2),
|
|
6499
|
+
easeInOutBack: (t) => t < 0.5 ? Math.pow(2 * t, 2) * ((c2 + 1) * 2 * t - c2) / 2 : (Math.pow(2 * t - 2, 2) * ((c2 + 1) * (t * 2 - 2) + c2) + 2) / 2,
|
|
6500
|
+
// ── Elastic (oscillates) ──
|
|
6501
|
+
easeInElastic: (t) => {
|
|
6502
|
+
if (t === 0) return 0;
|
|
6503
|
+
if (t === 1) return 1;
|
|
6504
|
+
return -Math.pow(2, 10 * t - 10) * Math.sin((t * 10 - 10.75) * c4);
|
|
6505
|
+
},
|
|
6506
|
+
easeOutElastic: (t) => {
|
|
6507
|
+
if (t === 0) return 0;
|
|
6508
|
+
if (t === 1) return 1;
|
|
6509
|
+
return Math.pow(2, -10 * t) * Math.sin((t * 10 - 0.75) * c4) + 1;
|
|
6510
|
+
},
|
|
6511
|
+
easeInOutElastic: (t) => {
|
|
6512
|
+
if (t === 0) return 0;
|
|
6513
|
+
if (t === 1) return 1;
|
|
6514
|
+
return t < 0.5 ? -(Math.pow(2, 20 * t - 10) * Math.sin((20 * t - 11.125) * c5)) / 2 : Math.pow(2, -20 * t + 10) * Math.sin((20 * t - 11.125) * c5) / 2 + 1;
|
|
6515
|
+
},
|
|
6516
|
+
// ── Bounce (bouncing ball) ──
|
|
6517
|
+
easeInBounce: (t) => 1 - _bounceOut(1 - t),
|
|
6518
|
+
easeOutBounce: _bounceOut,
|
|
6519
|
+
easeInOutBounce: (t) => t < 0.5 ? (1 - _bounceOut(1 - 2 * t)) / 2 : (1 + _bounceOut(2 * t - 1)) / 2
|
|
6520
|
+
};
|
|
6521
|
+
var resolveEasingByName = (e) => {
|
|
6522
|
+
if (typeof e === "function") return e;
|
|
6523
|
+
if (typeof e === "string" && easings[e]) {
|
|
6524
|
+
return easings[e];
|
|
6525
|
+
}
|
|
6526
|
+
return easings.linear;
|
|
6527
|
+
};
|
|
6137
6528
|
|
|
6138
6529
|
// src/index.ts
|
|
6139
6530
|
var ansimax = { color, animate, ascii, loader, frames, components, trees, themes, images, configure };
|
|
@@ -6169,8 +6560,10 @@ export {
|
|
|
6169
6560
|
chain,
|
|
6170
6561
|
charWidth,
|
|
6171
6562
|
clamp,
|
|
6563
|
+
clampByte2 as clampByte,
|
|
6172
6564
|
clearAnsiCache,
|
|
6173
6565
|
clearColorCache,
|
|
6566
|
+
clearLine,
|
|
6174
6567
|
clearRenderCache,
|
|
6175
6568
|
clearThemeColorCache,
|
|
6176
6569
|
color,
|
|
@@ -6188,6 +6581,8 @@ export {
|
|
|
6188
6581
|
debounce,
|
|
6189
6582
|
index_default as default,
|
|
6190
6583
|
diffLines,
|
|
6584
|
+
easings,
|
|
6585
|
+
escapeForRegex,
|
|
6191
6586
|
escapeRegex,
|
|
6192
6587
|
fg256,
|
|
6193
6588
|
fgRgb,
|
|
@@ -6208,13 +6603,17 @@ export {
|
|
|
6208
6603
|
gradient,
|
|
6209
6604
|
gradientColor,
|
|
6210
6605
|
gradientRect,
|
|
6606
|
+
gradientStops,
|
|
6211
6607
|
graphemes,
|
|
6212
6608
|
grid,
|
|
6213
6609
|
hasFont,
|
|
6214
6610
|
hexToRgb,
|
|
6215
6611
|
hideCursor,
|
|
6612
|
+
hslToRgb,
|
|
6216
6613
|
hsplit,
|
|
6614
|
+
hyperlink,
|
|
6217
6615
|
images,
|
|
6616
|
+
isFiniteNumber2 as isFiniteNumber,
|
|
6218
6617
|
isHexColor,
|
|
6219
6618
|
isNoColor,
|
|
6220
6619
|
json,
|
|
@@ -6226,9 +6625,12 @@ export {
|
|
|
6226
6625
|
listPresets,
|
|
6227
6626
|
loader,
|
|
6228
6627
|
mapTree,
|
|
6628
|
+
measureBlock,
|
|
6229
6629
|
measureTree,
|
|
6230
6630
|
memoize,
|
|
6631
|
+
mixColors,
|
|
6231
6632
|
nextTick,
|
|
6633
|
+
oklabToRgb,
|
|
6232
6634
|
onConfigChange,
|
|
6233
6635
|
onConfigKeyChange,
|
|
6234
6636
|
onResize,
|
|
@@ -6241,6 +6643,7 @@ export {
|
|
|
6241
6643
|
pauseListeners,
|
|
6242
6644
|
presetNames,
|
|
6243
6645
|
presets,
|
|
6646
|
+
quantizeColor,
|
|
6244
6647
|
rainbow,
|
|
6245
6648
|
registerFont,
|
|
6246
6649
|
registerPreset,
|
|
@@ -6256,13 +6659,18 @@ export {
|
|
|
6256
6659
|
resetFramesCursorCount,
|
|
6257
6660
|
resetLoaderCursorCount,
|
|
6258
6661
|
resetNoColor,
|
|
6662
|
+
resolveEasingByName,
|
|
6259
6663
|
resumeListeners,
|
|
6260
6664
|
reverseGradient,
|
|
6261
6665
|
rgbTo256,
|
|
6262
6666
|
rgbToHex,
|
|
6667
|
+
rgbToHsl,
|
|
6668
|
+
rgbToOklab,
|
|
6263
6669
|
rotate90,
|
|
6670
|
+
safeInt,
|
|
6264
6671
|
safeJson,
|
|
6265
6672
|
screen,
|
|
6673
|
+
setConfigValue,
|
|
6266
6674
|
setNoColor,
|
|
6267
6675
|
setTitle,
|
|
6268
6676
|
sgr,
|
|
@@ -6273,6 +6681,7 @@ export {
|
|
|
6273
6681
|
stripAnsi2 as stripAnsi,
|
|
6274
6682
|
stripAnsi as stripAnsiCodes,
|
|
6275
6683
|
stripAnsi3 as stripAnsiColors,
|
|
6684
|
+
subscribeConfig,
|
|
6276
6685
|
supportsColor,
|
|
6277
6686
|
supportsColorLevel,
|
|
6278
6687
|
termSize,
|