grootx-vcs 1.0.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 +356 -0
- package/dist/cli.js +4427 -0
- package/package.json +23 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,4427 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// @bun
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
function __accessProp(key) {
|
|
9
|
+
return this[key];
|
|
10
|
+
}
|
|
11
|
+
var __toESMCache_node;
|
|
12
|
+
var __toESMCache_esm;
|
|
13
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
14
|
+
var canCache = mod != null && typeof mod === "object";
|
|
15
|
+
if (canCache) {
|
|
16
|
+
var cache = isNodeMode
|
|
17
|
+
? (__toESMCache_node ??= new WeakMap())
|
|
18
|
+
: (__toESMCache_esm ??= new WeakMap());
|
|
19
|
+
var cached = cache.get(mod);
|
|
20
|
+
if (cached) return cached;
|
|
21
|
+
}
|
|
22
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
23
|
+
const to =
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule
|
|
25
|
+
? __defProp(target, "default", { value: mod, enumerable: true })
|
|
26
|
+
: target;
|
|
27
|
+
for (let key of __getOwnPropNames(mod))
|
|
28
|
+
if (!__hasOwnProp.call(to, key))
|
|
29
|
+
__defProp(to, key, {
|
|
30
|
+
get: __accessProp.bind(mod, key),
|
|
31
|
+
enumerable: true,
|
|
32
|
+
});
|
|
33
|
+
if (canCache) cache.set(mod, to);
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __commonJS = (cb, mod) => () => (
|
|
37
|
+
mod || cb((mod = { exports: {} }).exports, mod),
|
|
38
|
+
mod.exports
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
// node_modules/emoji-regex/index.js
|
|
42
|
+
var require_emoji_regex = __commonJS((exports, module) => {
|
|
43
|
+
module.exports = () => {
|
|
44
|
+
return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// node_modules/cli-boxes/boxes.json
|
|
49
|
+
var require_boxes = __commonJS((exports, module) => {
|
|
50
|
+
module.exports = {
|
|
51
|
+
single: {
|
|
52
|
+
topLeft: "┌",
|
|
53
|
+
top: "─",
|
|
54
|
+
topRight: "┐",
|
|
55
|
+
right: "│",
|
|
56
|
+
bottomRight: "┘",
|
|
57
|
+
bottom: "─",
|
|
58
|
+
bottomLeft: "└",
|
|
59
|
+
left: "│",
|
|
60
|
+
},
|
|
61
|
+
double: {
|
|
62
|
+
topLeft: "╔",
|
|
63
|
+
top: "═",
|
|
64
|
+
topRight: "╗",
|
|
65
|
+
right: "║",
|
|
66
|
+
bottomRight: "╝",
|
|
67
|
+
bottom: "═",
|
|
68
|
+
bottomLeft: "╚",
|
|
69
|
+
left: "║",
|
|
70
|
+
},
|
|
71
|
+
round: {
|
|
72
|
+
topLeft: "╭",
|
|
73
|
+
top: "─",
|
|
74
|
+
topRight: "╮",
|
|
75
|
+
right: "│",
|
|
76
|
+
bottomRight: "╯",
|
|
77
|
+
bottom: "─",
|
|
78
|
+
bottomLeft: "╰",
|
|
79
|
+
left: "│",
|
|
80
|
+
},
|
|
81
|
+
bold: {
|
|
82
|
+
topLeft: "┏",
|
|
83
|
+
top: "━",
|
|
84
|
+
topRight: "┓",
|
|
85
|
+
right: "┃",
|
|
86
|
+
bottomRight: "┛",
|
|
87
|
+
bottom: "━",
|
|
88
|
+
bottomLeft: "┗",
|
|
89
|
+
left: "┃",
|
|
90
|
+
},
|
|
91
|
+
singleDouble: {
|
|
92
|
+
topLeft: "╓",
|
|
93
|
+
top: "─",
|
|
94
|
+
topRight: "╖",
|
|
95
|
+
right: "║",
|
|
96
|
+
bottomRight: "╜",
|
|
97
|
+
bottom: "─",
|
|
98
|
+
bottomLeft: "╙",
|
|
99
|
+
left: "║",
|
|
100
|
+
},
|
|
101
|
+
doubleSingle: {
|
|
102
|
+
topLeft: "╒",
|
|
103
|
+
top: "═",
|
|
104
|
+
topRight: "╕",
|
|
105
|
+
right: "│",
|
|
106
|
+
bottomRight: "╛",
|
|
107
|
+
bottom: "═",
|
|
108
|
+
bottomLeft: "╘",
|
|
109
|
+
left: "│",
|
|
110
|
+
},
|
|
111
|
+
classic: {
|
|
112
|
+
topLeft: "+",
|
|
113
|
+
top: "-",
|
|
114
|
+
topRight: "+",
|
|
115
|
+
right: "|",
|
|
116
|
+
bottomRight: "+",
|
|
117
|
+
bottom: "-",
|
|
118
|
+
bottomLeft: "+",
|
|
119
|
+
left: "|",
|
|
120
|
+
},
|
|
121
|
+
arrow: {
|
|
122
|
+
topLeft: "↘",
|
|
123
|
+
top: "↓",
|
|
124
|
+
topRight: "↙",
|
|
125
|
+
right: "←",
|
|
126
|
+
bottomRight: "↖",
|
|
127
|
+
bottom: "↑",
|
|
128
|
+
bottomLeft: "↗",
|
|
129
|
+
left: "→",
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// node_modules/cli-boxes/index.js
|
|
135
|
+
var require_cli_boxes = __commonJS((exports, module) => {
|
|
136
|
+
var cliBoxes = require_boxes();
|
|
137
|
+
module.exports = cliBoxes;
|
|
138
|
+
module.exports.default = cliBoxes;
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// node_modules/ansi-align/node_modules/string-width/node_modules/strip-ansi/node_modules/ansi-regex/index.js
|
|
142
|
+
var require_ansi_regex = __commonJS((exports, module) => {
|
|
143
|
+
module.exports = ({ onlyFirst = false } = {}) => {
|
|
144
|
+
const pattern = [
|
|
145
|
+
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
146
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))",
|
|
147
|
+
].join("|");
|
|
148
|
+
return new RegExp(pattern, onlyFirst ? undefined : "g");
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// node_modules/ansi-align/node_modules/string-width/node_modules/strip-ansi/index.js
|
|
153
|
+
var require_strip_ansi = __commonJS((exports, module) => {
|
|
154
|
+
var ansiRegex2 = require_ansi_regex();
|
|
155
|
+
module.exports = (string) =>
|
|
156
|
+
typeof string === "string" ? string.replace(ansiRegex2(), "") : string;
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// node_modules/is-fullwidth-code-point/index.js
|
|
160
|
+
var require_is_fullwidth_code_point = __commonJS((exports, module) => {
|
|
161
|
+
var isFullwidthCodePoint = (codePoint) => {
|
|
162
|
+
if (Number.isNaN(codePoint)) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
if (
|
|
166
|
+
codePoint >= 4352 &&
|
|
167
|
+
(codePoint <= 4447 ||
|
|
168
|
+
codePoint === 9001 ||
|
|
169
|
+
codePoint === 9002 ||
|
|
170
|
+
(11904 <= codePoint &&
|
|
171
|
+
codePoint <= 12871 &&
|
|
172
|
+
codePoint !== 12351) ||
|
|
173
|
+
(12880 <= codePoint && codePoint <= 19903) ||
|
|
174
|
+
(19968 <= codePoint && codePoint <= 42182) ||
|
|
175
|
+
(43360 <= codePoint && codePoint <= 43388) ||
|
|
176
|
+
(44032 <= codePoint && codePoint <= 55203) ||
|
|
177
|
+
(63744 <= codePoint && codePoint <= 64255) ||
|
|
178
|
+
(65040 <= codePoint && codePoint <= 65049) ||
|
|
179
|
+
(65072 <= codePoint && codePoint <= 65131) ||
|
|
180
|
+
(65281 <= codePoint && codePoint <= 65376) ||
|
|
181
|
+
(65504 <= codePoint && codePoint <= 65510) ||
|
|
182
|
+
(110592 <= codePoint && codePoint <= 110593) ||
|
|
183
|
+
(127488 <= codePoint && codePoint <= 127569) ||
|
|
184
|
+
(131072 <= codePoint && codePoint <= 262141))
|
|
185
|
+
) {
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
return false;
|
|
189
|
+
};
|
|
190
|
+
module.exports = isFullwidthCodePoint;
|
|
191
|
+
module.exports.default = isFullwidthCodePoint;
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// node_modules/ansi-align/node_modules/string-width/node_modules/emoji-regex/index.js
|
|
195
|
+
var require_emoji_regex2 = __commonJS((exports, module) => {
|
|
196
|
+
module.exports = function () {
|
|
197
|
+
return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
|
|
198
|
+
};
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// node_modules/ansi-align/node_modules/string-width/index.js
|
|
202
|
+
var require_string_width = __commonJS((exports, module) => {
|
|
203
|
+
var stripAnsi2 = require_strip_ansi();
|
|
204
|
+
var isFullwidthCodePoint = require_is_fullwidth_code_point();
|
|
205
|
+
var emojiRegex2 = require_emoji_regex2();
|
|
206
|
+
var stringWidth2 = (string) => {
|
|
207
|
+
if (typeof string !== "string" || string.length === 0) {
|
|
208
|
+
return 0;
|
|
209
|
+
}
|
|
210
|
+
string = stripAnsi2(string);
|
|
211
|
+
if (string.length === 0) {
|
|
212
|
+
return 0;
|
|
213
|
+
}
|
|
214
|
+
string = string.replace(emojiRegex2(), " ");
|
|
215
|
+
let width = 0;
|
|
216
|
+
for (let i = 0; i < string.length; i++) {
|
|
217
|
+
const code = string.codePointAt(i);
|
|
218
|
+
if (code <= 31 || (code >= 127 && code <= 159)) {
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
if (code >= 768 && code <= 879) {
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
if (code > 65535) {
|
|
225
|
+
i++;
|
|
226
|
+
}
|
|
227
|
+
width += isFullwidthCodePoint(code) ? 2 : 1;
|
|
228
|
+
}
|
|
229
|
+
return width;
|
|
230
|
+
};
|
|
231
|
+
module.exports = stringWidth2;
|
|
232
|
+
module.exports.default = stringWidth2;
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
// node_modules/ansi-align/index.js
|
|
236
|
+
var require_ansi_align = __commonJS((exports, module) => {
|
|
237
|
+
var stringWidth2 = require_string_width();
|
|
238
|
+
function ansiAlign(text, opts) {
|
|
239
|
+
if (!text) return text;
|
|
240
|
+
opts = opts || {};
|
|
241
|
+
const align = opts.align || "center";
|
|
242
|
+
if (align === "left") return text;
|
|
243
|
+
const split =
|
|
244
|
+
opts.split ||
|
|
245
|
+
`
|
|
246
|
+
`;
|
|
247
|
+
const pad = opts.pad || " ";
|
|
248
|
+
const widthDiffFn = align !== "right" ? halfDiff : fullDiff;
|
|
249
|
+
let returnString = false;
|
|
250
|
+
if (!Array.isArray(text)) {
|
|
251
|
+
returnString = true;
|
|
252
|
+
text = String(text).split(split);
|
|
253
|
+
}
|
|
254
|
+
let width;
|
|
255
|
+
let maxWidth = 0;
|
|
256
|
+
text = text
|
|
257
|
+
.map(function (str) {
|
|
258
|
+
str = String(str);
|
|
259
|
+
width = stringWidth2(str);
|
|
260
|
+
maxWidth = Math.max(width, maxWidth);
|
|
261
|
+
return {
|
|
262
|
+
str,
|
|
263
|
+
width,
|
|
264
|
+
};
|
|
265
|
+
})
|
|
266
|
+
.map(function (obj) {
|
|
267
|
+
return (
|
|
268
|
+
new Array(widthDiffFn(maxWidth, obj.width) + 1).join(pad) +
|
|
269
|
+
obj.str
|
|
270
|
+
);
|
|
271
|
+
});
|
|
272
|
+
return returnString ? text.join(split) : text;
|
|
273
|
+
}
|
|
274
|
+
ansiAlign.left = function left(text) {
|
|
275
|
+
return ansiAlign(text, { align: "left" });
|
|
276
|
+
};
|
|
277
|
+
ansiAlign.center = function center(text) {
|
|
278
|
+
return ansiAlign(text, { align: "center" });
|
|
279
|
+
};
|
|
280
|
+
ansiAlign.right = function right(text) {
|
|
281
|
+
return ansiAlign(text, { align: "right" });
|
|
282
|
+
};
|
|
283
|
+
module.exports = ansiAlign;
|
|
284
|
+
function halfDiff(maxWidth, curWidth) {
|
|
285
|
+
return Math.floor((maxWidth - curWidth) / 2);
|
|
286
|
+
}
|
|
287
|
+
function fullDiff(maxWidth, curWidth) {
|
|
288
|
+
return maxWidth - curWidth;
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
// src/commands/init.ts
|
|
293
|
+
import path2 from "path";
|
|
294
|
+
import fs2 from "fs";
|
|
295
|
+
|
|
296
|
+
// node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
297
|
+
var ANSI_BACKGROUND_OFFSET = 10;
|
|
298
|
+
var wrapAnsi16 =
|
|
299
|
+
(offset = 0) =>
|
|
300
|
+
(code) =>
|
|
301
|
+
`\x1B[${code + offset}m`;
|
|
302
|
+
var wrapAnsi256 =
|
|
303
|
+
(offset = 0) =>
|
|
304
|
+
(code) =>
|
|
305
|
+
`\x1B[${38 + offset};5;${code}m`;
|
|
306
|
+
var wrapAnsi16m =
|
|
307
|
+
(offset = 0) =>
|
|
308
|
+
(red, green, blue) =>
|
|
309
|
+
`\x1B[${38 + offset};2;${red};${green};${blue}m`;
|
|
310
|
+
var styles = {
|
|
311
|
+
modifier: {
|
|
312
|
+
reset: [0, 0],
|
|
313
|
+
bold: [1, 22],
|
|
314
|
+
dim: [2, 22],
|
|
315
|
+
italic: [3, 23],
|
|
316
|
+
underline: [4, 24],
|
|
317
|
+
overline: [53, 55],
|
|
318
|
+
inverse: [7, 27],
|
|
319
|
+
hidden: [8, 28],
|
|
320
|
+
strikethrough: [9, 29],
|
|
321
|
+
},
|
|
322
|
+
color: {
|
|
323
|
+
black: [30, 39],
|
|
324
|
+
red: [31, 39],
|
|
325
|
+
green: [32, 39],
|
|
326
|
+
yellow: [33, 39],
|
|
327
|
+
blue: [34, 39],
|
|
328
|
+
magenta: [35, 39],
|
|
329
|
+
cyan: [36, 39],
|
|
330
|
+
white: [37, 39],
|
|
331
|
+
blackBright: [90, 39],
|
|
332
|
+
gray: [90, 39],
|
|
333
|
+
grey: [90, 39],
|
|
334
|
+
redBright: [91, 39],
|
|
335
|
+
greenBright: [92, 39],
|
|
336
|
+
yellowBright: [93, 39],
|
|
337
|
+
blueBright: [94, 39],
|
|
338
|
+
magentaBright: [95, 39],
|
|
339
|
+
cyanBright: [96, 39],
|
|
340
|
+
whiteBright: [97, 39],
|
|
341
|
+
},
|
|
342
|
+
bgColor: {
|
|
343
|
+
bgBlack: [40, 49],
|
|
344
|
+
bgRed: [41, 49],
|
|
345
|
+
bgGreen: [42, 49],
|
|
346
|
+
bgYellow: [43, 49],
|
|
347
|
+
bgBlue: [44, 49],
|
|
348
|
+
bgMagenta: [45, 49],
|
|
349
|
+
bgCyan: [46, 49],
|
|
350
|
+
bgWhite: [47, 49],
|
|
351
|
+
bgBlackBright: [100, 49],
|
|
352
|
+
bgGray: [100, 49],
|
|
353
|
+
bgGrey: [100, 49],
|
|
354
|
+
bgRedBright: [101, 49],
|
|
355
|
+
bgGreenBright: [102, 49],
|
|
356
|
+
bgYellowBright: [103, 49],
|
|
357
|
+
bgBlueBright: [104, 49],
|
|
358
|
+
bgMagentaBright: [105, 49],
|
|
359
|
+
bgCyanBright: [106, 49],
|
|
360
|
+
bgWhiteBright: [107, 49],
|
|
361
|
+
},
|
|
362
|
+
};
|
|
363
|
+
var modifierNames = Object.keys(styles.modifier);
|
|
364
|
+
var foregroundColorNames = Object.keys(styles.color);
|
|
365
|
+
var backgroundColorNames = Object.keys(styles.bgColor);
|
|
366
|
+
var colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
|
367
|
+
function assembleStyles() {
|
|
368
|
+
const codes = new Map();
|
|
369
|
+
for (const [groupName, group] of Object.entries(styles)) {
|
|
370
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
371
|
+
styles[styleName] = {
|
|
372
|
+
open: `\x1B[${style[0]}m`,
|
|
373
|
+
close: `\x1B[${style[1]}m`,
|
|
374
|
+
};
|
|
375
|
+
group[styleName] = styles[styleName];
|
|
376
|
+
codes.set(style[0], style[1]);
|
|
377
|
+
}
|
|
378
|
+
Object.defineProperty(styles, groupName, {
|
|
379
|
+
value: group,
|
|
380
|
+
enumerable: false,
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
Object.defineProperty(styles, "codes", {
|
|
384
|
+
value: codes,
|
|
385
|
+
enumerable: false,
|
|
386
|
+
});
|
|
387
|
+
styles.color.close = "\x1B[39m";
|
|
388
|
+
styles.bgColor.close = "\x1B[49m";
|
|
389
|
+
styles.color.ansi = wrapAnsi16();
|
|
390
|
+
styles.color.ansi256 = wrapAnsi256();
|
|
391
|
+
styles.color.ansi16m = wrapAnsi16m();
|
|
392
|
+
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
393
|
+
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
394
|
+
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
395
|
+
Object.defineProperties(styles, {
|
|
396
|
+
rgbToAnsi256: {
|
|
397
|
+
value(red, green, blue) {
|
|
398
|
+
if (red === green && green === blue) {
|
|
399
|
+
if (red < 8) {
|
|
400
|
+
return 16;
|
|
401
|
+
}
|
|
402
|
+
if (red > 248) {
|
|
403
|
+
return 231;
|
|
404
|
+
}
|
|
405
|
+
return Math.round(((red - 8) / 247) * 24) + 232;
|
|
406
|
+
}
|
|
407
|
+
return (
|
|
408
|
+
16 +
|
|
409
|
+
36 * Math.round((red / 255) * 5) +
|
|
410
|
+
6 * Math.round((green / 255) * 5) +
|
|
411
|
+
Math.round((blue / 255) * 5)
|
|
412
|
+
);
|
|
413
|
+
},
|
|
414
|
+
enumerable: false,
|
|
415
|
+
},
|
|
416
|
+
hexToRgb: {
|
|
417
|
+
value(hex) {
|
|
418
|
+
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
419
|
+
if (!matches) {
|
|
420
|
+
return [0, 0, 0];
|
|
421
|
+
}
|
|
422
|
+
let [colorString] = matches;
|
|
423
|
+
if (colorString.length === 3) {
|
|
424
|
+
colorString = [...colorString]
|
|
425
|
+
.map((character) => character + character)
|
|
426
|
+
.join("");
|
|
427
|
+
}
|
|
428
|
+
const integer = Number.parseInt(colorString, 16);
|
|
429
|
+
return [
|
|
430
|
+
(integer >> 16) & 255,
|
|
431
|
+
(integer >> 8) & 255,
|
|
432
|
+
integer & 255,
|
|
433
|
+
];
|
|
434
|
+
},
|
|
435
|
+
enumerable: false,
|
|
436
|
+
},
|
|
437
|
+
hexToAnsi256: {
|
|
438
|
+
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
439
|
+
enumerable: false,
|
|
440
|
+
},
|
|
441
|
+
ansi256ToAnsi: {
|
|
442
|
+
value(code) {
|
|
443
|
+
if (code < 8) {
|
|
444
|
+
return 30 + code;
|
|
445
|
+
}
|
|
446
|
+
if (code < 16) {
|
|
447
|
+
return 90 + (code - 8);
|
|
448
|
+
}
|
|
449
|
+
let red;
|
|
450
|
+
let green;
|
|
451
|
+
let blue;
|
|
452
|
+
if (code >= 232) {
|
|
453
|
+
red = ((code - 232) * 10 + 8) / 255;
|
|
454
|
+
green = red;
|
|
455
|
+
blue = red;
|
|
456
|
+
} else {
|
|
457
|
+
code -= 16;
|
|
458
|
+
const remainder = code % 36;
|
|
459
|
+
red = Math.floor(code / 36) / 5;
|
|
460
|
+
green = Math.floor(remainder / 6) / 5;
|
|
461
|
+
blue = (remainder % 6) / 5;
|
|
462
|
+
}
|
|
463
|
+
const value = Math.max(red, green, blue) * 2;
|
|
464
|
+
if (value === 0) {
|
|
465
|
+
return 30;
|
|
466
|
+
}
|
|
467
|
+
let result =
|
|
468
|
+
30 +
|
|
469
|
+
((Math.round(blue) << 2) |
|
|
470
|
+
(Math.round(green) << 1) |
|
|
471
|
+
Math.round(red));
|
|
472
|
+
if (value === 2) {
|
|
473
|
+
result += 60;
|
|
474
|
+
}
|
|
475
|
+
return result;
|
|
476
|
+
},
|
|
477
|
+
enumerable: false,
|
|
478
|
+
},
|
|
479
|
+
rgbToAnsi: {
|
|
480
|
+
value: (red, green, blue) =>
|
|
481
|
+
styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
482
|
+
enumerable: false,
|
|
483
|
+
},
|
|
484
|
+
hexToAnsi: {
|
|
485
|
+
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
486
|
+
enumerable: false,
|
|
487
|
+
},
|
|
488
|
+
});
|
|
489
|
+
return styles;
|
|
490
|
+
}
|
|
491
|
+
var ansiStyles = assembleStyles();
|
|
492
|
+
var ansi_styles_default = ansiStyles;
|
|
493
|
+
|
|
494
|
+
// node_modules/chalk/source/vendor/supports-color/index.js
|
|
495
|
+
import process2 from "node:process";
|
|
496
|
+
import os from "node:os";
|
|
497
|
+
import tty from "node:tty";
|
|
498
|
+
function hasFlag(
|
|
499
|
+
flag,
|
|
500
|
+
argv = globalThis.Deno ? globalThis.Deno.args : process2.argv,
|
|
501
|
+
) {
|
|
502
|
+
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
503
|
+
const position = argv.indexOf(prefix + flag);
|
|
504
|
+
const terminatorPosition = argv.indexOf("--");
|
|
505
|
+
return (
|
|
506
|
+
position !== -1 &&
|
|
507
|
+
(terminatorPosition === -1 || position < terminatorPosition)
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
var { env } = process2;
|
|
511
|
+
var flagForceColor;
|
|
512
|
+
if (
|
|
513
|
+
hasFlag("no-color") ||
|
|
514
|
+
hasFlag("no-colors") ||
|
|
515
|
+
hasFlag("color=false") ||
|
|
516
|
+
hasFlag("color=never")
|
|
517
|
+
) {
|
|
518
|
+
flagForceColor = 0;
|
|
519
|
+
} else if (
|
|
520
|
+
hasFlag("color") ||
|
|
521
|
+
hasFlag("colors") ||
|
|
522
|
+
hasFlag("color=true") ||
|
|
523
|
+
hasFlag("color=always")
|
|
524
|
+
) {
|
|
525
|
+
flagForceColor = 1;
|
|
526
|
+
}
|
|
527
|
+
function envForceColor() {
|
|
528
|
+
if ("FORCE_COLOR" in env) {
|
|
529
|
+
if (env.FORCE_COLOR === "true") {
|
|
530
|
+
return 1;
|
|
531
|
+
}
|
|
532
|
+
if (env.FORCE_COLOR === "false") {
|
|
533
|
+
return 0;
|
|
534
|
+
}
|
|
535
|
+
return env.FORCE_COLOR.length === 0
|
|
536
|
+
? 1
|
|
537
|
+
: Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
function translateLevel(level) {
|
|
541
|
+
if (level === 0) {
|
|
542
|
+
return false;
|
|
543
|
+
}
|
|
544
|
+
return {
|
|
545
|
+
level,
|
|
546
|
+
hasBasic: true,
|
|
547
|
+
has256: level >= 2,
|
|
548
|
+
has16m: level >= 3,
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
552
|
+
const noFlagForceColor = envForceColor();
|
|
553
|
+
if (noFlagForceColor !== undefined) {
|
|
554
|
+
flagForceColor = noFlagForceColor;
|
|
555
|
+
}
|
|
556
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
557
|
+
if (forceColor === 0) {
|
|
558
|
+
return 0;
|
|
559
|
+
}
|
|
560
|
+
if (sniffFlags) {
|
|
561
|
+
if (
|
|
562
|
+
hasFlag("color=16m") ||
|
|
563
|
+
hasFlag("color=full") ||
|
|
564
|
+
hasFlag("color=truecolor")
|
|
565
|
+
) {
|
|
566
|
+
return 3;
|
|
567
|
+
}
|
|
568
|
+
if (hasFlag("color=256")) {
|
|
569
|
+
return 2;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
if ("TF_BUILD" in env && "AGENT_NAME" in env) {
|
|
573
|
+
return 1;
|
|
574
|
+
}
|
|
575
|
+
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
576
|
+
return 0;
|
|
577
|
+
}
|
|
578
|
+
const min = forceColor || 0;
|
|
579
|
+
if (env.TERM === "dumb") {
|
|
580
|
+
return min;
|
|
581
|
+
}
|
|
582
|
+
if (process2.platform === "win32") {
|
|
583
|
+
const osRelease = os.release().split(".");
|
|
584
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
585
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
586
|
+
}
|
|
587
|
+
return 1;
|
|
588
|
+
}
|
|
589
|
+
if ("CI" in env) {
|
|
590
|
+
if (
|
|
591
|
+
["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some(
|
|
592
|
+
(key) => key in env,
|
|
593
|
+
)
|
|
594
|
+
) {
|
|
595
|
+
return 3;
|
|
596
|
+
}
|
|
597
|
+
if (
|
|
598
|
+
["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some(
|
|
599
|
+
(sign) => sign in env,
|
|
600
|
+
) ||
|
|
601
|
+
env.CI_NAME === "codeship"
|
|
602
|
+
) {
|
|
603
|
+
return 1;
|
|
604
|
+
}
|
|
605
|
+
return min;
|
|
606
|
+
}
|
|
607
|
+
if ("TEAMCITY_VERSION" in env) {
|
|
608
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION)
|
|
609
|
+
? 1
|
|
610
|
+
: 0;
|
|
611
|
+
}
|
|
612
|
+
if (env.COLORTERM === "truecolor") {
|
|
613
|
+
return 3;
|
|
614
|
+
}
|
|
615
|
+
if (env.TERM === "xterm-kitty") {
|
|
616
|
+
return 3;
|
|
617
|
+
}
|
|
618
|
+
if (env.TERM === "xterm-ghostty") {
|
|
619
|
+
return 3;
|
|
620
|
+
}
|
|
621
|
+
if (env.TERM === "wezterm") {
|
|
622
|
+
return 3;
|
|
623
|
+
}
|
|
624
|
+
if ("TERM_PROGRAM" in env) {
|
|
625
|
+
const version = Number.parseInt(
|
|
626
|
+
(env.TERM_PROGRAM_VERSION || "").split(".")[0],
|
|
627
|
+
10,
|
|
628
|
+
);
|
|
629
|
+
switch (env.TERM_PROGRAM) {
|
|
630
|
+
case "iTerm.app": {
|
|
631
|
+
return version >= 3 ? 3 : 2;
|
|
632
|
+
}
|
|
633
|
+
case "Apple_Terminal": {
|
|
634
|
+
return 2;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
639
|
+
return 2;
|
|
640
|
+
}
|
|
641
|
+
if (
|
|
642
|
+
/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(
|
|
643
|
+
env.TERM,
|
|
644
|
+
)
|
|
645
|
+
) {
|
|
646
|
+
return 1;
|
|
647
|
+
}
|
|
648
|
+
if ("COLORTERM" in env) {
|
|
649
|
+
return 1;
|
|
650
|
+
}
|
|
651
|
+
return min;
|
|
652
|
+
}
|
|
653
|
+
function createSupportsColor(stream, options = {}) {
|
|
654
|
+
const level = _supportsColor(stream, {
|
|
655
|
+
streamIsTTY: stream && stream.isTTY,
|
|
656
|
+
...options,
|
|
657
|
+
});
|
|
658
|
+
return translateLevel(level);
|
|
659
|
+
}
|
|
660
|
+
var supportsColor = {
|
|
661
|
+
stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
|
|
662
|
+
stderr: createSupportsColor({ isTTY: tty.isatty(2) }),
|
|
663
|
+
};
|
|
664
|
+
var supports_color_default = supportsColor;
|
|
665
|
+
|
|
666
|
+
// node_modules/chalk/source/utilities.js
|
|
667
|
+
function stringReplaceAll(string, substring, replacer) {
|
|
668
|
+
let index = string.indexOf(substring);
|
|
669
|
+
if (index === -1) {
|
|
670
|
+
return string;
|
|
671
|
+
}
|
|
672
|
+
const substringLength = substring.length;
|
|
673
|
+
let endIndex = 0;
|
|
674
|
+
let returnValue = "";
|
|
675
|
+
do {
|
|
676
|
+
returnValue += string.slice(endIndex, index) + substring + replacer;
|
|
677
|
+
endIndex = index + substringLength;
|
|
678
|
+
index = string.indexOf(substring, endIndex);
|
|
679
|
+
} while (index !== -1);
|
|
680
|
+
returnValue += string.slice(endIndex);
|
|
681
|
+
return returnValue;
|
|
682
|
+
}
|
|
683
|
+
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
684
|
+
let endIndex = 0;
|
|
685
|
+
let returnValue = "";
|
|
686
|
+
do {
|
|
687
|
+
const gotCR = string[index - 1] === "\r";
|
|
688
|
+
returnValue +=
|
|
689
|
+
string.slice(endIndex, gotCR ? index - 1 : index) +
|
|
690
|
+
prefix +
|
|
691
|
+
(gotCR
|
|
692
|
+
? `\r
|
|
693
|
+
`
|
|
694
|
+
: `
|
|
695
|
+
`) +
|
|
696
|
+
postfix;
|
|
697
|
+
endIndex = index + 1;
|
|
698
|
+
index = string.indexOf(
|
|
699
|
+
`
|
|
700
|
+
`,
|
|
701
|
+
endIndex,
|
|
702
|
+
);
|
|
703
|
+
} while (index !== -1);
|
|
704
|
+
returnValue += string.slice(endIndex);
|
|
705
|
+
return returnValue;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
// node_modules/chalk/source/index.js
|
|
709
|
+
var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
|
|
710
|
+
var GENERATOR = Symbol("GENERATOR");
|
|
711
|
+
var STYLER = Symbol("STYLER");
|
|
712
|
+
var IS_EMPTY = Symbol("IS_EMPTY");
|
|
713
|
+
var levelMapping = ["ansi", "ansi", "ansi256", "ansi16m"];
|
|
714
|
+
var styles2 = Object.create(null);
|
|
715
|
+
var applyOptions = (object, options = {}) => {
|
|
716
|
+
if (
|
|
717
|
+
options.level &&
|
|
718
|
+
!(
|
|
719
|
+
Number.isInteger(options.level) &&
|
|
720
|
+
options.level >= 0 &&
|
|
721
|
+
options.level <= 3
|
|
722
|
+
)
|
|
723
|
+
) {
|
|
724
|
+
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
725
|
+
}
|
|
726
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
727
|
+
object.level = options.level === undefined ? colorLevel : options.level;
|
|
728
|
+
};
|
|
729
|
+
var chalkFactory = (options) => {
|
|
730
|
+
const chalk = (...strings) => strings.join(" ");
|
|
731
|
+
applyOptions(chalk, options);
|
|
732
|
+
Object.setPrototypeOf(chalk, createChalk.prototype);
|
|
733
|
+
return chalk;
|
|
734
|
+
};
|
|
735
|
+
function createChalk(options) {
|
|
736
|
+
return chalkFactory(options);
|
|
737
|
+
}
|
|
738
|
+
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
739
|
+
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
|
740
|
+
styles2[styleName] = {
|
|
741
|
+
get() {
|
|
742
|
+
const builder = createBuilder(
|
|
743
|
+
this,
|
|
744
|
+
createStyler(style.open, style.close, this[STYLER]),
|
|
745
|
+
this[IS_EMPTY],
|
|
746
|
+
);
|
|
747
|
+
Object.defineProperty(this, styleName, { value: builder });
|
|
748
|
+
return builder;
|
|
749
|
+
},
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
styles2.visible = {
|
|
753
|
+
get() {
|
|
754
|
+
const builder = createBuilder(this, this[STYLER], true);
|
|
755
|
+
Object.defineProperty(this, "visible", { value: builder });
|
|
756
|
+
return builder;
|
|
757
|
+
},
|
|
758
|
+
};
|
|
759
|
+
var getModelAnsi = (model, level, type, ...arguments_) => {
|
|
760
|
+
if (model === "rgb") {
|
|
761
|
+
if (level === "ansi16m") {
|
|
762
|
+
return ansi_styles_default[type].ansi16m(...arguments_);
|
|
763
|
+
}
|
|
764
|
+
if (level === "ansi256") {
|
|
765
|
+
return ansi_styles_default[type].ansi256(
|
|
766
|
+
ansi_styles_default.rgbToAnsi256(...arguments_),
|
|
767
|
+
);
|
|
768
|
+
}
|
|
769
|
+
return ansi_styles_default[type].ansi(
|
|
770
|
+
ansi_styles_default.rgbToAnsi(...arguments_),
|
|
771
|
+
);
|
|
772
|
+
}
|
|
773
|
+
if (model === "hex") {
|
|
774
|
+
return getModelAnsi(
|
|
775
|
+
"rgb",
|
|
776
|
+
level,
|
|
777
|
+
type,
|
|
778
|
+
...ansi_styles_default.hexToRgb(...arguments_),
|
|
779
|
+
);
|
|
780
|
+
}
|
|
781
|
+
return ansi_styles_default[type][model](...arguments_);
|
|
782
|
+
};
|
|
783
|
+
var usedModels = ["rgb", "hex", "ansi256"];
|
|
784
|
+
for (const model of usedModels) {
|
|
785
|
+
styles2[model] = {
|
|
786
|
+
get() {
|
|
787
|
+
const { level } = this;
|
|
788
|
+
return function (...arguments_) {
|
|
789
|
+
const styler = createStyler(
|
|
790
|
+
getModelAnsi(
|
|
791
|
+
model,
|
|
792
|
+
levelMapping[level],
|
|
793
|
+
"color",
|
|
794
|
+
...arguments_,
|
|
795
|
+
),
|
|
796
|
+
ansi_styles_default.color.close,
|
|
797
|
+
this[STYLER],
|
|
798
|
+
);
|
|
799
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
800
|
+
};
|
|
801
|
+
},
|
|
802
|
+
};
|
|
803
|
+
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
804
|
+
styles2[bgModel] = {
|
|
805
|
+
get() {
|
|
806
|
+
const { level } = this;
|
|
807
|
+
return function (...arguments_) {
|
|
808
|
+
const styler = createStyler(
|
|
809
|
+
getModelAnsi(
|
|
810
|
+
model,
|
|
811
|
+
levelMapping[level],
|
|
812
|
+
"bgColor",
|
|
813
|
+
...arguments_,
|
|
814
|
+
),
|
|
815
|
+
ansi_styles_default.bgColor.close,
|
|
816
|
+
this[STYLER],
|
|
817
|
+
);
|
|
818
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
819
|
+
};
|
|
820
|
+
},
|
|
821
|
+
};
|
|
822
|
+
}
|
|
823
|
+
var proto = Object.defineProperties(() => {}, {
|
|
824
|
+
...styles2,
|
|
825
|
+
level: {
|
|
826
|
+
enumerable: true,
|
|
827
|
+
get() {
|
|
828
|
+
return this[GENERATOR].level;
|
|
829
|
+
},
|
|
830
|
+
set(level) {
|
|
831
|
+
this[GENERATOR].level = level;
|
|
832
|
+
},
|
|
833
|
+
},
|
|
834
|
+
});
|
|
835
|
+
var createStyler = (open, close, parent) => {
|
|
836
|
+
let openAll;
|
|
837
|
+
let closeAll;
|
|
838
|
+
if (parent === undefined) {
|
|
839
|
+
openAll = open;
|
|
840
|
+
closeAll = close;
|
|
841
|
+
} else {
|
|
842
|
+
openAll = parent.openAll + open;
|
|
843
|
+
closeAll = close + parent.closeAll;
|
|
844
|
+
}
|
|
845
|
+
return {
|
|
846
|
+
open,
|
|
847
|
+
close,
|
|
848
|
+
openAll,
|
|
849
|
+
closeAll,
|
|
850
|
+
parent,
|
|
851
|
+
};
|
|
852
|
+
};
|
|
853
|
+
var createBuilder = (self, _styler, _isEmpty) => {
|
|
854
|
+
const builder = (...arguments_) =>
|
|
855
|
+
applyStyle(
|
|
856
|
+
builder,
|
|
857
|
+
arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "),
|
|
858
|
+
);
|
|
859
|
+
Object.setPrototypeOf(builder, proto);
|
|
860
|
+
builder[GENERATOR] = self;
|
|
861
|
+
builder[STYLER] = _styler;
|
|
862
|
+
builder[IS_EMPTY] = _isEmpty;
|
|
863
|
+
return builder;
|
|
864
|
+
};
|
|
865
|
+
var applyStyle = (self, string) => {
|
|
866
|
+
if (self.level <= 0 || !string) {
|
|
867
|
+
return self[IS_EMPTY] ? "" : string;
|
|
868
|
+
}
|
|
869
|
+
let styler = self[STYLER];
|
|
870
|
+
if (styler === undefined) {
|
|
871
|
+
return string;
|
|
872
|
+
}
|
|
873
|
+
const { openAll, closeAll } = styler;
|
|
874
|
+
if (string.includes("\x1B")) {
|
|
875
|
+
while (styler !== undefined) {
|
|
876
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
|
877
|
+
styler = styler.parent;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
const lfIndex = string.indexOf(`
|
|
881
|
+
`);
|
|
882
|
+
if (lfIndex !== -1) {
|
|
883
|
+
string = stringEncaseCRLFWithFirstIndex(
|
|
884
|
+
string,
|
|
885
|
+
closeAll,
|
|
886
|
+
openAll,
|
|
887
|
+
lfIndex,
|
|
888
|
+
);
|
|
889
|
+
}
|
|
890
|
+
return openAll + string + closeAll;
|
|
891
|
+
};
|
|
892
|
+
Object.defineProperties(createChalk.prototype, styles2);
|
|
893
|
+
var chalk = createChalk();
|
|
894
|
+
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
895
|
+
var source_default = chalk;
|
|
896
|
+
|
|
897
|
+
// node_modules/figlet/dist/node-figlet.mjs
|
|
898
|
+
import * as fs from "fs";
|
|
899
|
+
import * as path from "path";
|
|
900
|
+
|
|
901
|
+
// node_modules/figlet/dist/figlet-C8Ns3Vyn.js
|
|
902
|
+
var LAYOUT = {
|
|
903
|
+
FULL_WIDTH: 0,
|
|
904
|
+
FITTING: 1,
|
|
905
|
+
SMUSHING: 2,
|
|
906
|
+
CONTROLLED_SMUSHING: 3,
|
|
907
|
+
};
|
|
908
|
+
|
|
909
|
+
class FigletFont {
|
|
910
|
+
constructor() {
|
|
911
|
+
this.comment = "";
|
|
912
|
+
this.numChars = 0;
|
|
913
|
+
this.options = {};
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
var fontList = [
|
|
917
|
+
"1Row",
|
|
918
|
+
"3-D",
|
|
919
|
+
"3D Diagonal",
|
|
920
|
+
"3D-ASCII",
|
|
921
|
+
"3x5",
|
|
922
|
+
"4Max",
|
|
923
|
+
"5 Line Oblique",
|
|
924
|
+
"AMC 3 Line",
|
|
925
|
+
"AMC 3 Liv1",
|
|
926
|
+
"AMC AAA01",
|
|
927
|
+
"AMC Neko",
|
|
928
|
+
"AMC Razor",
|
|
929
|
+
"AMC Razor2",
|
|
930
|
+
"AMC Slash",
|
|
931
|
+
"AMC Slider",
|
|
932
|
+
"AMC Thin",
|
|
933
|
+
"AMC Tubes",
|
|
934
|
+
"AMC Untitled",
|
|
935
|
+
"ANSI Compact",
|
|
936
|
+
"ANSI Regular",
|
|
937
|
+
"ANSI Shadow",
|
|
938
|
+
"ASCII 12",
|
|
939
|
+
"ASCII 9",
|
|
940
|
+
"ASCII New Roman",
|
|
941
|
+
"Acrobatic",
|
|
942
|
+
"Alligator",
|
|
943
|
+
"Alligator2",
|
|
944
|
+
"Alpha",
|
|
945
|
+
"Alphabet",
|
|
946
|
+
"Arrows",
|
|
947
|
+
"Avatar",
|
|
948
|
+
"B1FF",
|
|
949
|
+
"Babyface Lame",
|
|
950
|
+
"Babyface Leet",
|
|
951
|
+
"Banner",
|
|
952
|
+
"Banner3-D",
|
|
953
|
+
"Banner3",
|
|
954
|
+
"Banner4",
|
|
955
|
+
"Barbwire",
|
|
956
|
+
"Basic",
|
|
957
|
+
"Bear",
|
|
958
|
+
"Bell",
|
|
959
|
+
"Benjamin",
|
|
960
|
+
"Big ASCII 12",
|
|
961
|
+
"Big ASCII 9",
|
|
962
|
+
"Big Chief",
|
|
963
|
+
"Big Money-ne",
|
|
964
|
+
"Big Money-nw",
|
|
965
|
+
"Big Money-se",
|
|
966
|
+
"Big Money-sw",
|
|
967
|
+
"Big Mono 12",
|
|
968
|
+
"Big Mono 9",
|
|
969
|
+
"Big",
|
|
970
|
+
"Bigfig",
|
|
971
|
+
"Binary",
|
|
972
|
+
"Block",
|
|
973
|
+
"Blocks",
|
|
974
|
+
"Bloody",
|
|
975
|
+
"BlurVision ASCII",
|
|
976
|
+
"Bolger",
|
|
977
|
+
"Braced",
|
|
978
|
+
"Bright",
|
|
979
|
+
"Broadway KB",
|
|
980
|
+
"Broadway",
|
|
981
|
+
"Bubble",
|
|
982
|
+
"Bulbhead",
|
|
983
|
+
"Caligraphy",
|
|
984
|
+
"Caligraphy2",
|
|
985
|
+
"Calvin S",
|
|
986
|
+
"Cards",
|
|
987
|
+
"Catwalk",
|
|
988
|
+
"Chiseled",
|
|
989
|
+
"Chunky",
|
|
990
|
+
"Circle",
|
|
991
|
+
"Classy",
|
|
992
|
+
"Coder Mini",
|
|
993
|
+
"Coinstak",
|
|
994
|
+
"Cola",
|
|
995
|
+
"Colossal",
|
|
996
|
+
"Computer",
|
|
997
|
+
"Contessa",
|
|
998
|
+
"Contrast",
|
|
999
|
+
"Cosmike",
|
|
1000
|
+
"Cosmike2",
|
|
1001
|
+
"Crawford",
|
|
1002
|
+
"Crawford2",
|
|
1003
|
+
"Crazy",
|
|
1004
|
+
"Cricket",
|
|
1005
|
+
"Cursive",
|
|
1006
|
+
"Cyberlarge",
|
|
1007
|
+
"Cybermedium",
|
|
1008
|
+
"Cybersmall",
|
|
1009
|
+
"Cygnet",
|
|
1010
|
+
"DANC4",
|
|
1011
|
+
"DOS Rebel",
|
|
1012
|
+
"DWhistled",
|
|
1013
|
+
"Dancing Font",
|
|
1014
|
+
"Decimal",
|
|
1015
|
+
"Def Leppard",
|
|
1016
|
+
"Delta Corps Priest 1",
|
|
1017
|
+
"DiamFont",
|
|
1018
|
+
"Diamond",
|
|
1019
|
+
"Diet Cola",
|
|
1020
|
+
"Digital",
|
|
1021
|
+
"Doh",
|
|
1022
|
+
"Doom",
|
|
1023
|
+
"Dot Matrix",
|
|
1024
|
+
"Double Shorts",
|
|
1025
|
+
"Double",
|
|
1026
|
+
"Dr Pepper",
|
|
1027
|
+
"Efti Chess",
|
|
1028
|
+
"Efti Font",
|
|
1029
|
+
"Efti Italic",
|
|
1030
|
+
"Efti Piti",
|
|
1031
|
+
"Efti Robot",
|
|
1032
|
+
"Efti Wall",
|
|
1033
|
+
"Efti Water",
|
|
1034
|
+
"Electronic",
|
|
1035
|
+
"Elite",
|
|
1036
|
+
"Emboss 2",
|
|
1037
|
+
"Emboss",
|
|
1038
|
+
"Epic",
|
|
1039
|
+
"Fender",
|
|
1040
|
+
"Filter",
|
|
1041
|
+
"Fire Font-k",
|
|
1042
|
+
"Fire Font-s",
|
|
1043
|
+
"Flipped",
|
|
1044
|
+
"Flower Power",
|
|
1045
|
+
"Font Font",
|
|
1046
|
+
"Four Tops",
|
|
1047
|
+
"Fraktur",
|
|
1048
|
+
"Fun Face",
|
|
1049
|
+
"Fun Faces",
|
|
1050
|
+
"Future Smooth",
|
|
1051
|
+
"Future Thin",
|
|
1052
|
+
"Future",
|
|
1053
|
+
"Fuzzy",
|
|
1054
|
+
"Georgi16",
|
|
1055
|
+
"Georgia11",
|
|
1056
|
+
"Ghost",
|
|
1057
|
+
"Ghoulish",
|
|
1058
|
+
"Glenyn",
|
|
1059
|
+
"Goofy",
|
|
1060
|
+
"Gothic",
|
|
1061
|
+
"Graceful",
|
|
1062
|
+
"Gradient",
|
|
1063
|
+
"Graffiti",
|
|
1064
|
+
"Greek",
|
|
1065
|
+
"Heart Left",
|
|
1066
|
+
"Heart Right",
|
|
1067
|
+
"Henry 3D",
|
|
1068
|
+
"Hex",
|
|
1069
|
+
"Hieroglyphs",
|
|
1070
|
+
"Hollywood",
|
|
1071
|
+
"Horizontal Left",
|
|
1072
|
+
"Horizontal Right",
|
|
1073
|
+
"ICL-1900",
|
|
1074
|
+
"Impossible",
|
|
1075
|
+
"Invita",
|
|
1076
|
+
"Isometric1",
|
|
1077
|
+
"Isometric2",
|
|
1078
|
+
"Isometric3",
|
|
1079
|
+
"Isometric4",
|
|
1080
|
+
"Italic",
|
|
1081
|
+
"Ivrit",
|
|
1082
|
+
"JS Block Letters",
|
|
1083
|
+
"JS Bracket Letters",
|
|
1084
|
+
"JS Capital Curves",
|
|
1085
|
+
"JS Cursive",
|
|
1086
|
+
"JS Stick Letters",
|
|
1087
|
+
"Jacky",
|
|
1088
|
+
"Jazmine",
|
|
1089
|
+
"Jerusalem",
|
|
1090
|
+
"Katakana",
|
|
1091
|
+
"Kban",
|
|
1092
|
+
"Keyboard",
|
|
1093
|
+
"Knob",
|
|
1094
|
+
"Konto Slant",
|
|
1095
|
+
"Konto",
|
|
1096
|
+
"LCD",
|
|
1097
|
+
"Larry 3D 2",
|
|
1098
|
+
"Larry 3D",
|
|
1099
|
+
"Lean",
|
|
1100
|
+
"Letter",
|
|
1101
|
+
"Letters",
|
|
1102
|
+
"Lil Devil",
|
|
1103
|
+
"Line Blocks",
|
|
1104
|
+
"Linux",
|
|
1105
|
+
"Lockergnome",
|
|
1106
|
+
"Madrid",
|
|
1107
|
+
"Marquee",
|
|
1108
|
+
"Maxfour",
|
|
1109
|
+
"Merlin1",
|
|
1110
|
+
"Merlin2",
|
|
1111
|
+
"Mike",
|
|
1112
|
+
"Mini",
|
|
1113
|
+
"Mirror",
|
|
1114
|
+
"Mnemonic",
|
|
1115
|
+
"Modular",
|
|
1116
|
+
"Mono 12",
|
|
1117
|
+
"Mono 9",
|
|
1118
|
+
"Morse",
|
|
1119
|
+
"Morse2",
|
|
1120
|
+
"Moscow",
|
|
1121
|
+
"Mshebrew210",
|
|
1122
|
+
"Muzzle",
|
|
1123
|
+
"NScript",
|
|
1124
|
+
"NT Greek",
|
|
1125
|
+
"NV Script",
|
|
1126
|
+
"Nancyj-Fancy",
|
|
1127
|
+
"Nancyj-Improved",
|
|
1128
|
+
"Nancyj-Underlined",
|
|
1129
|
+
"Nancyj",
|
|
1130
|
+
"Nipples",
|
|
1131
|
+
"O8",
|
|
1132
|
+
"OS2",
|
|
1133
|
+
"Octal",
|
|
1134
|
+
"Ogre",
|
|
1135
|
+
"Old Banner",
|
|
1136
|
+
"Pagga",
|
|
1137
|
+
"Patorjk's Cheese",
|
|
1138
|
+
"Patorjk-HeX",
|
|
1139
|
+
"Pawp",
|
|
1140
|
+
"Peaks Slant",
|
|
1141
|
+
"Peaks",
|
|
1142
|
+
"Pebbles",
|
|
1143
|
+
"Pepper",
|
|
1144
|
+
"Poison",
|
|
1145
|
+
"Puffy",
|
|
1146
|
+
"Puzzle",
|
|
1147
|
+
"Pyramid",
|
|
1148
|
+
"Rammstein",
|
|
1149
|
+
"Rebel",
|
|
1150
|
+
"Rectangles",
|
|
1151
|
+
"Red Phoenix",
|
|
1152
|
+
"Relief",
|
|
1153
|
+
"Relief2",
|
|
1154
|
+
"Reverse",
|
|
1155
|
+
"Roman",
|
|
1156
|
+
"Rot13",
|
|
1157
|
+
"Rotated",
|
|
1158
|
+
"Rounded",
|
|
1159
|
+
"Rowan Cap",
|
|
1160
|
+
"Rozzo",
|
|
1161
|
+
"RubiFont",
|
|
1162
|
+
"Runic",
|
|
1163
|
+
"Runyc",
|
|
1164
|
+
"S Blood",
|
|
1165
|
+
"SL Script",
|
|
1166
|
+
"Santa Clara",
|
|
1167
|
+
"Script",
|
|
1168
|
+
"Serifcap",
|
|
1169
|
+
"Shaded Blocky",
|
|
1170
|
+
"Shadow",
|
|
1171
|
+
"Shimrod",
|
|
1172
|
+
"Short",
|
|
1173
|
+
"Slant Relief",
|
|
1174
|
+
"Slant",
|
|
1175
|
+
"Slide",
|
|
1176
|
+
"Small ASCII 12",
|
|
1177
|
+
"Small ASCII 9",
|
|
1178
|
+
"Small Block",
|
|
1179
|
+
"Small Braille",
|
|
1180
|
+
"Small Caps",
|
|
1181
|
+
"Small Isometric1",
|
|
1182
|
+
"Small Keyboard",
|
|
1183
|
+
"Small Mono 12",
|
|
1184
|
+
"Small Mono 9",
|
|
1185
|
+
"Small Poison",
|
|
1186
|
+
"Small Script",
|
|
1187
|
+
"Small Shadow",
|
|
1188
|
+
"Small Slant",
|
|
1189
|
+
"Small Tengwar",
|
|
1190
|
+
"Small",
|
|
1191
|
+
"Soft",
|
|
1192
|
+
"Speed",
|
|
1193
|
+
"Spliff",
|
|
1194
|
+
"Stacey",
|
|
1195
|
+
"Stampate",
|
|
1196
|
+
"Stampatello",
|
|
1197
|
+
"Standard",
|
|
1198
|
+
"Star Strips",
|
|
1199
|
+
"Star Wars",
|
|
1200
|
+
"Stellar",
|
|
1201
|
+
"Stforek",
|
|
1202
|
+
"Stick Letters",
|
|
1203
|
+
"Stop",
|
|
1204
|
+
"Straight",
|
|
1205
|
+
"Stronger Than All",
|
|
1206
|
+
"Sub-Zero",
|
|
1207
|
+
"Swamp Land",
|
|
1208
|
+
"Swan",
|
|
1209
|
+
"Sweet",
|
|
1210
|
+
"THIS",
|
|
1211
|
+
"Tanja",
|
|
1212
|
+
"Tengwar",
|
|
1213
|
+
"Term",
|
|
1214
|
+
"Terrace",
|
|
1215
|
+
"Test1",
|
|
1216
|
+
"The Edge",
|
|
1217
|
+
"Thick",
|
|
1218
|
+
"Thin",
|
|
1219
|
+
"Thorned",
|
|
1220
|
+
"Three Point",
|
|
1221
|
+
"Ticks Slant",
|
|
1222
|
+
"Ticks",
|
|
1223
|
+
"Tiles",
|
|
1224
|
+
"Tinker-Toy",
|
|
1225
|
+
"Tmplr",
|
|
1226
|
+
"Tombstone",
|
|
1227
|
+
"Train",
|
|
1228
|
+
"Trek",
|
|
1229
|
+
"Tsalagi",
|
|
1230
|
+
"Tubular",
|
|
1231
|
+
"Twisted",
|
|
1232
|
+
"Two Point",
|
|
1233
|
+
"USA Flag",
|
|
1234
|
+
"Univers",
|
|
1235
|
+
"Upside Down Text",
|
|
1236
|
+
"Varsity",
|
|
1237
|
+
"Wavescape",
|
|
1238
|
+
"Wavy",
|
|
1239
|
+
"Weird",
|
|
1240
|
+
"Wet Letter",
|
|
1241
|
+
"Whimsy",
|
|
1242
|
+
"WideTerm",
|
|
1243
|
+
"Wow",
|
|
1244
|
+
"miniwi",
|
|
1245
|
+
];
|
|
1246
|
+
var renamedFonts = {
|
|
1247
|
+
"ANSI-Compact": "ANSI Compact",
|
|
1248
|
+
};
|
|
1249
|
+
var getFontName = (name) => {
|
|
1250
|
+
return renamedFonts[name] ? renamedFonts[name] : name;
|
|
1251
|
+
};
|
|
1252
|
+
function escapeRegExpChar(char) {
|
|
1253
|
+
const specialChars = /[.*+?^${}()|[\]\\]/;
|
|
1254
|
+
return specialChars.test(char) ? "\\" + char : char;
|
|
1255
|
+
}
|
|
1256
|
+
var figlet = (() => {
|
|
1257
|
+
const { FULL_WIDTH = 0, FITTING, SMUSHING, CONTROLLED_SMUSHING } = LAYOUT;
|
|
1258
|
+
const figFonts = {};
|
|
1259
|
+
const figDefaults = {
|
|
1260
|
+
font: "Standard",
|
|
1261
|
+
fontPath: "./fonts",
|
|
1262
|
+
fetchFontIfMissing: true,
|
|
1263
|
+
};
|
|
1264
|
+
function removeEndChar(line, lineNum, fontHeight) {
|
|
1265
|
+
const endChar = escapeRegExpChar(line.trim().slice(-1)) || "@";
|
|
1266
|
+
const endCharRegEx =
|
|
1267
|
+
lineNum === fontHeight - 1
|
|
1268
|
+
? new RegExp(endChar + endChar + "?\\s*$")
|
|
1269
|
+
: new RegExp(endChar + "\\s*$");
|
|
1270
|
+
return line.replace(endCharRegEx, "");
|
|
1271
|
+
}
|
|
1272
|
+
function getSmushingRules(oldLayout = -1, newLayout = null) {
|
|
1273
|
+
let rules = {};
|
|
1274
|
+
let val;
|
|
1275
|
+
let codes = [
|
|
1276
|
+
[16384, "vLayout", SMUSHING],
|
|
1277
|
+
[8192, "vLayout", FITTING],
|
|
1278
|
+
[4096, "vRule5", true],
|
|
1279
|
+
[2048, "vRule4", true],
|
|
1280
|
+
[1024, "vRule3", true],
|
|
1281
|
+
[512, "vRule2", true],
|
|
1282
|
+
[256, "vRule1", true],
|
|
1283
|
+
[128, "hLayout", SMUSHING],
|
|
1284
|
+
[64, "hLayout", FITTING],
|
|
1285
|
+
[32, "hRule6", true],
|
|
1286
|
+
[16, "hRule5", true],
|
|
1287
|
+
[8, "hRule4", true],
|
|
1288
|
+
[4, "hRule3", true],
|
|
1289
|
+
[2, "hRule2", true],
|
|
1290
|
+
[1, "hRule1", true],
|
|
1291
|
+
];
|
|
1292
|
+
val = newLayout !== null ? newLayout : oldLayout;
|
|
1293
|
+
for (const [code, rule, value] of codes) {
|
|
1294
|
+
if (val >= code) {
|
|
1295
|
+
val -= code;
|
|
1296
|
+
if (rules[rule] === undefined) {
|
|
1297
|
+
rules[rule] = value;
|
|
1298
|
+
}
|
|
1299
|
+
} else if (rule !== "vLayout" && rule !== "hLayout") {
|
|
1300
|
+
rules[rule] = false;
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
if (typeof rules["hLayout"] === "undefined") {
|
|
1304
|
+
if (oldLayout === 0) {
|
|
1305
|
+
rules["hLayout"] = FITTING;
|
|
1306
|
+
} else if (oldLayout === -1) {
|
|
1307
|
+
rules["hLayout"] = FULL_WIDTH;
|
|
1308
|
+
} else {
|
|
1309
|
+
if (
|
|
1310
|
+
rules["hRule1"] ||
|
|
1311
|
+
rules["hRule2"] ||
|
|
1312
|
+
rules["hRule3"] ||
|
|
1313
|
+
rules["hRule4"] ||
|
|
1314
|
+
rules["hRule5"] ||
|
|
1315
|
+
rules["hRule6"]
|
|
1316
|
+
) {
|
|
1317
|
+
rules["hLayout"] = CONTROLLED_SMUSHING;
|
|
1318
|
+
} else {
|
|
1319
|
+
rules["hLayout"] = SMUSHING;
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
} else if (rules["hLayout"] === SMUSHING) {
|
|
1323
|
+
if (
|
|
1324
|
+
rules["hRule1"] ||
|
|
1325
|
+
rules["hRule2"] ||
|
|
1326
|
+
rules["hRule3"] ||
|
|
1327
|
+
rules["hRule4"] ||
|
|
1328
|
+
rules["hRule5"] ||
|
|
1329
|
+
rules["hRule6"]
|
|
1330
|
+
) {
|
|
1331
|
+
rules["hLayout"] = CONTROLLED_SMUSHING;
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
if (typeof rules["vLayout"] === "undefined") {
|
|
1335
|
+
if (
|
|
1336
|
+
rules["vRule1"] ||
|
|
1337
|
+
rules["vRule2"] ||
|
|
1338
|
+
rules["vRule3"] ||
|
|
1339
|
+
rules["vRule4"] ||
|
|
1340
|
+
rules["vRule5"]
|
|
1341
|
+
) {
|
|
1342
|
+
rules["vLayout"] = CONTROLLED_SMUSHING;
|
|
1343
|
+
} else {
|
|
1344
|
+
rules["vLayout"] = FULL_WIDTH;
|
|
1345
|
+
}
|
|
1346
|
+
} else if (rules["vLayout"] === SMUSHING) {
|
|
1347
|
+
if (
|
|
1348
|
+
rules["vRule1"] ||
|
|
1349
|
+
rules["vRule2"] ||
|
|
1350
|
+
rules["vRule3"] ||
|
|
1351
|
+
rules["vRule4"] ||
|
|
1352
|
+
rules["vRule5"]
|
|
1353
|
+
) {
|
|
1354
|
+
rules["vLayout"] = CONTROLLED_SMUSHING;
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
return rules;
|
|
1358
|
+
}
|
|
1359
|
+
function hRule1_Smush(ch1, ch2, hardBlank = "") {
|
|
1360
|
+
if (ch1 === ch2 && ch1 !== hardBlank) {
|
|
1361
|
+
return ch1;
|
|
1362
|
+
}
|
|
1363
|
+
return false;
|
|
1364
|
+
}
|
|
1365
|
+
function hRule2_Smush(ch1, ch2) {
|
|
1366
|
+
let rule2Str = "|/\\[]{}()<>";
|
|
1367
|
+
if (ch1 === "_") {
|
|
1368
|
+
if (rule2Str.indexOf(ch2) !== -1) {
|
|
1369
|
+
return ch2;
|
|
1370
|
+
}
|
|
1371
|
+
} else if (ch2 === "_") {
|
|
1372
|
+
if (rule2Str.indexOf(ch1) !== -1) {
|
|
1373
|
+
return ch1;
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
return false;
|
|
1377
|
+
}
|
|
1378
|
+
function hRule3_Smush(ch1, ch2) {
|
|
1379
|
+
let rule3Classes = "| /\\ [] {} () <>";
|
|
1380
|
+
let r3_pos1 = rule3Classes.indexOf(ch1);
|
|
1381
|
+
let r3_pos2 = rule3Classes.indexOf(ch2);
|
|
1382
|
+
if (r3_pos1 !== -1 && r3_pos2 !== -1) {
|
|
1383
|
+
if (r3_pos1 !== r3_pos2 && Math.abs(r3_pos1 - r3_pos2) !== 1) {
|
|
1384
|
+
const startPos = Math.max(r3_pos1, r3_pos2);
|
|
1385
|
+
const endPos = startPos + 1;
|
|
1386
|
+
return rule3Classes.substring(startPos, endPos);
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
return false;
|
|
1390
|
+
}
|
|
1391
|
+
function hRule4_Smush(ch1, ch2) {
|
|
1392
|
+
let rule4Str = "[] {} ()";
|
|
1393
|
+
let r4_pos1 = rule4Str.indexOf(ch1);
|
|
1394
|
+
let r4_pos2 = rule4Str.indexOf(ch2);
|
|
1395
|
+
if (r4_pos1 !== -1 && r4_pos2 !== -1) {
|
|
1396
|
+
if (Math.abs(r4_pos1 - r4_pos2) <= 1) {
|
|
1397
|
+
return "|";
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
return false;
|
|
1401
|
+
}
|
|
1402
|
+
function hRule5_Smush(ch1, ch2) {
|
|
1403
|
+
const patterns = {
|
|
1404
|
+
"/\\": "|",
|
|
1405
|
+
"\\/": "Y",
|
|
1406
|
+
"><": "X",
|
|
1407
|
+
};
|
|
1408
|
+
return patterns[ch1 + ch2] || false;
|
|
1409
|
+
}
|
|
1410
|
+
function hRule6_Smush(ch1, ch2, hardBlank = "") {
|
|
1411
|
+
if (ch1 === hardBlank && ch2 === hardBlank) {
|
|
1412
|
+
return hardBlank;
|
|
1413
|
+
}
|
|
1414
|
+
return false;
|
|
1415
|
+
}
|
|
1416
|
+
function vRule1_Smush(ch1, ch2) {
|
|
1417
|
+
if (ch1 === ch2) {
|
|
1418
|
+
return ch1;
|
|
1419
|
+
}
|
|
1420
|
+
return false;
|
|
1421
|
+
}
|
|
1422
|
+
function vRule2_Smush(ch1, ch2) {
|
|
1423
|
+
return hRule2_Smush(ch1, ch2);
|
|
1424
|
+
}
|
|
1425
|
+
function vRule3_Smush(ch1, ch2) {
|
|
1426
|
+
return hRule3_Smush(ch1, ch2);
|
|
1427
|
+
}
|
|
1428
|
+
function vRule4_Smush(ch1, ch2) {
|
|
1429
|
+
if ((ch1 === "-" && ch2 === "_") || (ch1 === "_" && ch2 === "-")) {
|
|
1430
|
+
return "=";
|
|
1431
|
+
}
|
|
1432
|
+
return false;
|
|
1433
|
+
}
|
|
1434
|
+
function vRule5_Smush(ch1, ch2) {
|
|
1435
|
+
if (ch1 === "|" && ch2 === "|") {
|
|
1436
|
+
return "|";
|
|
1437
|
+
}
|
|
1438
|
+
return false;
|
|
1439
|
+
}
|
|
1440
|
+
function uni_Smush(ch1, ch2, hardBlank) {
|
|
1441
|
+
if (ch2 === " " || ch2 === "") {
|
|
1442
|
+
return ch1;
|
|
1443
|
+
} else if (ch2 === hardBlank && ch1 !== " ") {
|
|
1444
|
+
return ch1;
|
|
1445
|
+
} else {
|
|
1446
|
+
return ch2;
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
function canVerticalSmush(txt1, txt2, opts) {
|
|
1450
|
+
if (opts.fittingRules && opts.fittingRules.vLayout === FULL_WIDTH) {
|
|
1451
|
+
return "invalid";
|
|
1452
|
+
}
|
|
1453
|
+
let ii,
|
|
1454
|
+
len = Math.min(txt1.length, txt2.length),
|
|
1455
|
+
ch1,
|
|
1456
|
+
ch2,
|
|
1457
|
+
endSmush = false,
|
|
1458
|
+
validSmush;
|
|
1459
|
+
if (len === 0) {
|
|
1460
|
+
return "invalid";
|
|
1461
|
+
}
|
|
1462
|
+
for (ii = 0; ii < len; ii++) {
|
|
1463
|
+
ch1 = txt1.substring(ii, ii + 1);
|
|
1464
|
+
ch2 = txt2.substring(ii, ii + 1);
|
|
1465
|
+
if (ch1 !== " " && ch2 !== " ") {
|
|
1466
|
+
if (
|
|
1467
|
+
opts.fittingRules &&
|
|
1468
|
+
opts.fittingRules.vLayout === FITTING
|
|
1469
|
+
) {
|
|
1470
|
+
return "invalid";
|
|
1471
|
+
} else if (
|
|
1472
|
+
opts.fittingRules &&
|
|
1473
|
+
opts.fittingRules.vLayout === SMUSHING
|
|
1474
|
+
) {
|
|
1475
|
+
return "end";
|
|
1476
|
+
} else {
|
|
1477
|
+
if (vRule5_Smush(ch1, ch2)) {
|
|
1478
|
+
endSmush = endSmush || false;
|
|
1479
|
+
continue;
|
|
1480
|
+
}
|
|
1481
|
+
validSmush = false;
|
|
1482
|
+
validSmush =
|
|
1483
|
+
opts.fittingRules && opts.fittingRules.vRule1
|
|
1484
|
+
? vRule1_Smush(ch1, ch2)
|
|
1485
|
+
: validSmush;
|
|
1486
|
+
validSmush =
|
|
1487
|
+
!validSmush &&
|
|
1488
|
+
opts.fittingRules &&
|
|
1489
|
+
opts.fittingRules.vRule2
|
|
1490
|
+
? vRule2_Smush(ch1, ch2)
|
|
1491
|
+
: validSmush;
|
|
1492
|
+
validSmush =
|
|
1493
|
+
!validSmush &&
|
|
1494
|
+
opts.fittingRules &&
|
|
1495
|
+
opts.fittingRules.vRule3
|
|
1496
|
+
? vRule3_Smush(ch1, ch2)
|
|
1497
|
+
: validSmush;
|
|
1498
|
+
validSmush =
|
|
1499
|
+
!validSmush &&
|
|
1500
|
+
opts.fittingRules &&
|
|
1501
|
+
opts.fittingRules.vRule4
|
|
1502
|
+
? vRule4_Smush(ch1, ch2)
|
|
1503
|
+
: validSmush;
|
|
1504
|
+
endSmush = true;
|
|
1505
|
+
if (!validSmush) {
|
|
1506
|
+
return "invalid";
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
if (endSmush) {
|
|
1512
|
+
return "end";
|
|
1513
|
+
} else {
|
|
1514
|
+
return "valid";
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
function getVerticalSmushDist(lines1, lines2, opts) {
|
|
1518
|
+
let maxDist = lines1.length;
|
|
1519
|
+
let len1 = lines1.length;
|
|
1520
|
+
let subLines1, subLines2, slen;
|
|
1521
|
+
let curDist = 1;
|
|
1522
|
+
let ii, ret, result;
|
|
1523
|
+
while (curDist <= maxDist) {
|
|
1524
|
+
subLines1 = lines1.slice(Math.max(0, len1 - curDist), len1);
|
|
1525
|
+
subLines2 = lines2.slice(0, Math.min(maxDist, curDist));
|
|
1526
|
+
slen = subLines2.length;
|
|
1527
|
+
result = "";
|
|
1528
|
+
for (ii = 0; ii < slen; ii++) {
|
|
1529
|
+
ret = canVerticalSmush(subLines1[ii], subLines2[ii], opts);
|
|
1530
|
+
if (ret === "end") {
|
|
1531
|
+
result = ret;
|
|
1532
|
+
} else if (ret === "invalid") {
|
|
1533
|
+
result = ret;
|
|
1534
|
+
break;
|
|
1535
|
+
} else {
|
|
1536
|
+
if (result === "") {
|
|
1537
|
+
result = "valid";
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
if (result === "invalid") {
|
|
1542
|
+
curDist--;
|
|
1543
|
+
break;
|
|
1544
|
+
}
|
|
1545
|
+
if (result === "end") {
|
|
1546
|
+
break;
|
|
1547
|
+
}
|
|
1548
|
+
if (result === "valid") {
|
|
1549
|
+
curDist++;
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
return Math.min(maxDist, curDist);
|
|
1553
|
+
}
|
|
1554
|
+
function verticallySmushLines(line1, line2, opts) {
|
|
1555
|
+
let ii,
|
|
1556
|
+
len = Math.min(line1.length, line2.length);
|
|
1557
|
+
let ch1,
|
|
1558
|
+
ch2,
|
|
1559
|
+
result = "",
|
|
1560
|
+
validSmush;
|
|
1561
|
+
const fittingRules = opts.fittingRules || {};
|
|
1562
|
+
for (ii = 0; ii < len; ii++) {
|
|
1563
|
+
ch1 = line1.substring(ii, ii + 1);
|
|
1564
|
+
ch2 = line2.substring(ii, ii + 1);
|
|
1565
|
+
if (ch1 !== " " && ch2 !== " ") {
|
|
1566
|
+
if (fittingRules.vLayout === FITTING) {
|
|
1567
|
+
result += uni_Smush(ch1, ch2);
|
|
1568
|
+
} else if (fittingRules.vLayout === SMUSHING) {
|
|
1569
|
+
result += uni_Smush(ch1, ch2);
|
|
1570
|
+
} else {
|
|
1571
|
+
validSmush = false;
|
|
1572
|
+
validSmush = fittingRules.vRule5
|
|
1573
|
+
? vRule5_Smush(ch1, ch2)
|
|
1574
|
+
: validSmush;
|
|
1575
|
+
validSmush =
|
|
1576
|
+
!validSmush && fittingRules.vRule1
|
|
1577
|
+
? vRule1_Smush(ch1, ch2)
|
|
1578
|
+
: validSmush;
|
|
1579
|
+
validSmush =
|
|
1580
|
+
!validSmush && fittingRules.vRule2
|
|
1581
|
+
? vRule2_Smush(ch1, ch2)
|
|
1582
|
+
: validSmush;
|
|
1583
|
+
validSmush =
|
|
1584
|
+
!validSmush && fittingRules.vRule3
|
|
1585
|
+
? vRule3_Smush(ch1, ch2)
|
|
1586
|
+
: validSmush;
|
|
1587
|
+
validSmush =
|
|
1588
|
+
!validSmush && fittingRules.vRule4
|
|
1589
|
+
? vRule4_Smush(ch1, ch2)
|
|
1590
|
+
: validSmush;
|
|
1591
|
+
result += validSmush;
|
|
1592
|
+
}
|
|
1593
|
+
} else {
|
|
1594
|
+
result += uni_Smush(ch1, ch2);
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
return result;
|
|
1598
|
+
}
|
|
1599
|
+
function verticalSmush(lines1, lines2, overlap, opts) {
|
|
1600
|
+
let len1 = lines1.length;
|
|
1601
|
+
let len2 = lines2.length;
|
|
1602
|
+
let piece1 = lines1.slice(0, Math.max(0, len1 - overlap));
|
|
1603
|
+
let piece2_1 = lines1.slice(Math.max(0, len1 - overlap), len1);
|
|
1604
|
+
let piece2_2 = lines2.slice(0, Math.min(overlap, len2));
|
|
1605
|
+
let ii,
|
|
1606
|
+
len,
|
|
1607
|
+
line,
|
|
1608
|
+
piece2 = [],
|
|
1609
|
+
piece3;
|
|
1610
|
+
len = piece2_1.length;
|
|
1611
|
+
for (ii = 0; ii < len; ii++) {
|
|
1612
|
+
if (ii >= len2) {
|
|
1613
|
+
line = piece2_1[ii];
|
|
1614
|
+
} else {
|
|
1615
|
+
line = verticallySmushLines(piece2_1[ii], piece2_2[ii], opts);
|
|
1616
|
+
}
|
|
1617
|
+
piece2.push(line);
|
|
1618
|
+
}
|
|
1619
|
+
piece3 = lines2.slice(Math.min(overlap, len2), len2);
|
|
1620
|
+
return [...piece1, ...piece2, ...piece3];
|
|
1621
|
+
}
|
|
1622
|
+
function padLines(lines, numSpaces) {
|
|
1623
|
+
const padding = " ".repeat(numSpaces);
|
|
1624
|
+
return lines.map((line) => line + padding);
|
|
1625
|
+
}
|
|
1626
|
+
function smushVerticalFigLines(output, lines, opts) {
|
|
1627
|
+
let len1 = output[0].length;
|
|
1628
|
+
let len2 = lines[0].length;
|
|
1629
|
+
let overlap;
|
|
1630
|
+
if (len1 > len2) {
|
|
1631
|
+
lines = padLines(lines, len1 - len2);
|
|
1632
|
+
} else if (len2 > len1) {
|
|
1633
|
+
output = padLines(output, len2 - len1);
|
|
1634
|
+
}
|
|
1635
|
+
overlap = getVerticalSmushDist(output, lines, opts);
|
|
1636
|
+
return verticalSmush(output, lines, overlap, opts);
|
|
1637
|
+
}
|
|
1638
|
+
function getHorizontalSmushLength(txt1, txt2, opts) {
|
|
1639
|
+
const fittingRules = opts.fittingRules || {};
|
|
1640
|
+
if (fittingRules.hLayout === FULL_WIDTH) {
|
|
1641
|
+
return 0;
|
|
1642
|
+
}
|
|
1643
|
+
let ii,
|
|
1644
|
+
len1 = txt1.length,
|
|
1645
|
+
len2 = txt2.length;
|
|
1646
|
+
let maxDist = len1;
|
|
1647
|
+
let curDist = 1;
|
|
1648
|
+
let breakAfter = false;
|
|
1649
|
+
let seg1, seg2, ch1, ch2;
|
|
1650
|
+
if (len1 === 0) {
|
|
1651
|
+
return 0;
|
|
1652
|
+
}
|
|
1653
|
+
distCal: while (curDist <= maxDist) {
|
|
1654
|
+
const seg1StartPos = len1 - curDist;
|
|
1655
|
+
seg1 = txt1.substring(seg1StartPos, seg1StartPos + curDist);
|
|
1656
|
+
seg2 = txt2.substring(0, Math.min(curDist, len2));
|
|
1657
|
+
for (ii = 0; ii < Math.min(curDist, len2); ii++) {
|
|
1658
|
+
ch1 = seg1.substring(ii, ii + 1);
|
|
1659
|
+
ch2 = seg2.substring(ii, ii + 1);
|
|
1660
|
+
if (ch1 !== " " && ch2 !== " ") {
|
|
1661
|
+
if (fittingRules.hLayout === FITTING) {
|
|
1662
|
+
curDist = curDist - 1;
|
|
1663
|
+
break distCal;
|
|
1664
|
+
} else if (fittingRules.hLayout === SMUSHING) {
|
|
1665
|
+
if (ch1 === opts.hardBlank || ch2 === opts.hardBlank) {
|
|
1666
|
+
curDist = curDist - 1;
|
|
1667
|
+
}
|
|
1668
|
+
break distCal;
|
|
1669
|
+
} else {
|
|
1670
|
+
breakAfter = true;
|
|
1671
|
+
const validSmush =
|
|
1672
|
+
(fittingRules.hRule1 &&
|
|
1673
|
+
hRule1_Smush(ch1, ch2, opts.hardBlank)) ||
|
|
1674
|
+
(fittingRules.hRule2 && hRule2_Smush(ch1, ch2)) ||
|
|
1675
|
+
(fittingRules.hRule3 && hRule3_Smush(ch1, ch2)) ||
|
|
1676
|
+
(fittingRules.hRule4 && hRule4_Smush(ch1, ch2)) ||
|
|
1677
|
+
(fittingRules.hRule5 && hRule5_Smush(ch1, ch2)) ||
|
|
1678
|
+
(fittingRules.hRule6 &&
|
|
1679
|
+
hRule6_Smush(ch1, ch2, opts.hardBlank));
|
|
1680
|
+
if (!validSmush) {
|
|
1681
|
+
curDist = curDist - 1;
|
|
1682
|
+
break distCal;
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
if (breakAfter) {
|
|
1688
|
+
break;
|
|
1689
|
+
}
|
|
1690
|
+
curDist++;
|
|
1691
|
+
}
|
|
1692
|
+
return Math.min(maxDist, curDist);
|
|
1693
|
+
}
|
|
1694
|
+
function horizontalSmush(textBlock1, textBlock2, overlap, opts) {
|
|
1695
|
+
let ii,
|
|
1696
|
+
jj,
|
|
1697
|
+
outputFig = [],
|
|
1698
|
+
overlapStart,
|
|
1699
|
+
piece1,
|
|
1700
|
+
piece2,
|
|
1701
|
+
piece3,
|
|
1702
|
+
len1,
|
|
1703
|
+
len2,
|
|
1704
|
+
txt1,
|
|
1705
|
+
txt2;
|
|
1706
|
+
const fittingRules = opts.fittingRules || {};
|
|
1707
|
+
if (typeof opts.height !== "number") {
|
|
1708
|
+
throw new Error("height is not defined.");
|
|
1709
|
+
}
|
|
1710
|
+
for (ii = 0; ii < opts.height; ii++) {
|
|
1711
|
+
txt1 = textBlock1[ii];
|
|
1712
|
+
txt2 = textBlock2[ii];
|
|
1713
|
+
len1 = txt1.length;
|
|
1714
|
+
len2 = txt2.length;
|
|
1715
|
+
overlapStart = len1 - overlap;
|
|
1716
|
+
piece1 = txt1.slice(0, Math.max(0, overlapStart));
|
|
1717
|
+
piece2 = "";
|
|
1718
|
+
const seg1StartPos = Math.max(0, len1 - overlap);
|
|
1719
|
+
let seg1 = txt1.substring(seg1StartPos, seg1StartPos + overlap);
|
|
1720
|
+
let seg2 = txt2.substring(0, Math.min(overlap, len2));
|
|
1721
|
+
for (jj = 0; jj < overlap; jj++) {
|
|
1722
|
+
let ch1 = jj < len1 ? seg1.substring(jj, jj + 1) : " ";
|
|
1723
|
+
let ch2 = jj < len2 ? seg2.substring(jj, jj + 1) : " ";
|
|
1724
|
+
if (ch1 !== " " && ch2 !== " ") {
|
|
1725
|
+
if (
|
|
1726
|
+
fittingRules.hLayout === FITTING ||
|
|
1727
|
+
fittingRules.hLayout === SMUSHING
|
|
1728
|
+
) {
|
|
1729
|
+
piece2 += uni_Smush(ch1, ch2, opts.hardBlank);
|
|
1730
|
+
} else {
|
|
1731
|
+
const nextCh =
|
|
1732
|
+
(fittingRules.hRule1 &&
|
|
1733
|
+
hRule1_Smush(ch1, ch2, opts.hardBlank)) ||
|
|
1734
|
+
(fittingRules.hRule2 && hRule2_Smush(ch1, ch2)) ||
|
|
1735
|
+
(fittingRules.hRule3 && hRule3_Smush(ch1, ch2)) ||
|
|
1736
|
+
(fittingRules.hRule4 && hRule4_Smush(ch1, ch2)) ||
|
|
1737
|
+
(fittingRules.hRule5 && hRule5_Smush(ch1, ch2)) ||
|
|
1738
|
+
(fittingRules.hRule6 &&
|
|
1739
|
+
hRule6_Smush(ch1, ch2, opts.hardBlank)) ||
|
|
1740
|
+
uni_Smush(ch1, ch2, opts.hardBlank);
|
|
1741
|
+
piece2 += nextCh;
|
|
1742
|
+
}
|
|
1743
|
+
} else {
|
|
1744
|
+
piece2 += uni_Smush(ch1, ch2, opts.hardBlank);
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
if (overlap >= len2) {
|
|
1748
|
+
piece3 = "";
|
|
1749
|
+
} else {
|
|
1750
|
+
piece3 = txt2.substring(
|
|
1751
|
+
overlap,
|
|
1752
|
+
overlap + Math.max(0, len2 - overlap),
|
|
1753
|
+
);
|
|
1754
|
+
}
|
|
1755
|
+
outputFig[ii] = piece1 + piece2 + piece3;
|
|
1756
|
+
}
|
|
1757
|
+
return outputFig;
|
|
1758
|
+
}
|
|
1759
|
+
function newFigChar(len) {
|
|
1760
|
+
return new Array(len).fill("");
|
|
1761
|
+
}
|
|
1762
|
+
const figLinesWidth = function (textLines) {
|
|
1763
|
+
return Math.max(...textLines.map((line) => line.length));
|
|
1764
|
+
};
|
|
1765
|
+
function joinFigArray(array, len, opts) {
|
|
1766
|
+
return array.reduce(function (acc, data) {
|
|
1767
|
+
return horizontalSmush(acc, data.fig, data.overlap || 0, opts);
|
|
1768
|
+
}, newFigChar(len));
|
|
1769
|
+
}
|
|
1770
|
+
function breakWord(figChars, len, opts) {
|
|
1771
|
+
for (let i = figChars.length - 1; i > 0; i--) {
|
|
1772
|
+
const w = joinFigArray(figChars.slice(0, i), len, opts);
|
|
1773
|
+
if (figLinesWidth(w) <= opts.width) {
|
|
1774
|
+
return {
|
|
1775
|
+
outputFigText: w,
|
|
1776
|
+
chars: figChars.slice(i),
|
|
1777
|
+
};
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
return { outputFigText: newFigChar(len), chars: figChars };
|
|
1781
|
+
}
|
|
1782
|
+
function generateFigTextLines(txt, figChars, opts) {
|
|
1783
|
+
let charIndex,
|
|
1784
|
+
figChar,
|
|
1785
|
+
overlap = 0,
|
|
1786
|
+
row,
|
|
1787
|
+
outputFigText,
|
|
1788
|
+
len,
|
|
1789
|
+
height = opts.height,
|
|
1790
|
+
outputFigLines = [],
|
|
1791
|
+
maxWidth,
|
|
1792
|
+
nextFigChars = {
|
|
1793
|
+
chars: [],
|
|
1794
|
+
overlap,
|
|
1795
|
+
},
|
|
1796
|
+
figWords = [],
|
|
1797
|
+
char,
|
|
1798
|
+
isSpace,
|
|
1799
|
+
textFigWord,
|
|
1800
|
+
textFigLine,
|
|
1801
|
+
tmpBreak;
|
|
1802
|
+
if (typeof height !== "number") {
|
|
1803
|
+
throw new Error("height is not defined.");
|
|
1804
|
+
}
|
|
1805
|
+
outputFigText = newFigChar(height);
|
|
1806
|
+
const fittingRules = opts.fittingRules || {};
|
|
1807
|
+
if (opts.printDirection === 1) {
|
|
1808
|
+
txt = txt.split("").reverse().join("");
|
|
1809
|
+
}
|
|
1810
|
+
len = txt.length;
|
|
1811
|
+
for (charIndex = 0; charIndex < len; charIndex++) {
|
|
1812
|
+
char = txt.substring(charIndex, charIndex + 1);
|
|
1813
|
+
isSpace = char.match(/\s/);
|
|
1814
|
+
figChar = figChars[char.charCodeAt(0)];
|
|
1815
|
+
textFigLine = null;
|
|
1816
|
+
if (figChar) {
|
|
1817
|
+
if (fittingRules.hLayout !== FULL_WIDTH) {
|
|
1818
|
+
overlap = 1e4;
|
|
1819
|
+
for (row = 0; row < height; row++) {
|
|
1820
|
+
overlap = Math.min(
|
|
1821
|
+
overlap,
|
|
1822
|
+
getHorizontalSmushLength(
|
|
1823
|
+
outputFigText[row],
|
|
1824
|
+
figChar[row],
|
|
1825
|
+
opts,
|
|
1826
|
+
),
|
|
1827
|
+
);
|
|
1828
|
+
}
|
|
1829
|
+
overlap = overlap === 1e4 ? 0 : overlap;
|
|
1830
|
+
}
|
|
1831
|
+
if (opts.width > 0) {
|
|
1832
|
+
if (opts.whitespaceBreak) {
|
|
1833
|
+
textFigWord = joinFigArray(
|
|
1834
|
+
nextFigChars.chars.concat([
|
|
1835
|
+
{
|
|
1836
|
+
fig: figChar,
|
|
1837
|
+
overlap,
|
|
1838
|
+
},
|
|
1839
|
+
]),
|
|
1840
|
+
height,
|
|
1841
|
+
opts,
|
|
1842
|
+
);
|
|
1843
|
+
textFigLine = joinFigArray(
|
|
1844
|
+
figWords.concat([
|
|
1845
|
+
{
|
|
1846
|
+
fig: textFigWord,
|
|
1847
|
+
overlap: nextFigChars.overlap,
|
|
1848
|
+
},
|
|
1849
|
+
]),
|
|
1850
|
+
height,
|
|
1851
|
+
opts,
|
|
1852
|
+
);
|
|
1853
|
+
maxWidth = figLinesWidth(textFigLine);
|
|
1854
|
+
} else {
|
|
1855
|
+
textFigLine = horizontalSmush(
|
|
1856
|
+
outputFigText,
|
|
1857
|
+
figChar,
|
|
1858
|
+
overlap,
|
|
1859
|
+
opts,
|
|
1860
|
+
);
|
|
1861
|
+
maxWidth = figLinesWidth(textFigLine);
|
|
1862
|
+
}
|
|
1863
|
+
if (maxWidth >= opts.width && charIndex > 0) {
|
|
1864
|
+
if (opts.whitespaceBreak) {
|
|
1865
|
+
outputFigText = joinFigArray(
|
|
1866
|
+
figWords.slice(0, -1),
|
|
1867
|
+
height,
|
|
1868
|
+
opts,
|
|
1869
|
+
);
|
|
1870
|
+
if (figWords.length > 1) {
|
|
1871
|
+
outputFigLines.push(outputFigText);
|
|
1872
|
+
outputFigText = newFigChar(height);
|
|
1873
|
+
}
|
|
1874
|
+
figWords = [];
|
|
1875
|
+
} else {
|
|
1876
|
+
outputFigLines.push(outputFigText);
|
|
1877
|
+
outputFigText = newFigChar(height);
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
if (opts.width > 0 && opts.whitespaceBreak) {
|
|
1882
|
+
if (!isSpace || charIndex === len - 1) {
|
|
1883
|
+
nextFigChars.chars.push({ fig: figChar, overlap });
|
|
1884
|
+
}
|
|
1885
|
+
if (isSpace || charIndex === len - 1) {
|
|
1886
|
+
tmpBreak = null;
|
|
1887
|
+
while (true) {
|
|
1888
|
+
textFigLine = joinFigArray(
|
|
1889
|
+
nextFigChars.chars,
|
|
1890
|
+
height,
|
|
1891
|
+
opts,
|
|
1892
|
+
);
|
|
1893
|
+
maxWidth = figLinesWidth(textFigLine);
|
|
1894
|
+
if (maxWidth >= opts.width) {
|
|
1895
|
+
tmpBreak = breakWord(
|
|
1896
|
+
nextFigChars.chars,
|
|
1897
|
+
height,
|
|
1898
|
+
opts,
|
|
1899
|
+
);
|
|
1900
|
+
nextFigChars = { chars: tmpBreak.chars };
|
|
1901
|
+
outputFigLines.push(tmpBreak.outputFigText);
|
|
1902
|
+
} else {
|
|
1903
|
+
break;
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
if (maxWidth > 0) {
|
|
1907
|
+
if (tmpBreak) {
|
|
1908
|
+
figWords.push({ fig: textFigLine, overlap: 1 });
|
|
1909
|
+
} else {
|
|
1910
|
+
figWords.push({
|
|
1911
|
+
fig: textFigLine,
|
|
1912
|
+
overlap: nextFigChars.overlap,
|
|
1913
|
+
});
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
if (isSpace) {
|
|
1917
|
+
figWords.push({ fig: figChar, overlap });
|
|
1918
|
+
outputFigText = newFigChar(height);
|
|
1919
|
+
}
|
|
1920
|
+
if (charIndex === len - 1) {
|
|
1921
|
+
outputFigText = joinFigArray(
|
|
1922
|
+
figWords,
|
|
1923
|
+
height,
|
|
1924
|
+
opts,
|
|
1925
|
+
);
|
|
1926
|
+
}
|
|
1927
|
+
nextFigChars = {
|
|
1928
|
+
chars: [],
|
|
1929
|
+
overlap,
|
|
1930
|
+
};
|
|
1931
|
+
continue;
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
outputFigText = horizontalSmush(
|
|
1935
|
+
outputFigText,
|
|
1936
|
+
figChar,
|
|
1937
|
+
overlap,
|
|
1938
|
+
opts,
|
|
1939
|
+
);
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
if (figLinesWidth(outputFigText) > 0) {
|
|
1943
|
+
outputFigLines.push(outputFigText);
|
|
1944
|
+
}
|
|
1945
|
+
if (!opts.showHardBlanks) {
|
|
1946
|
+
outputFigLines.forEach(function (outputFigText2) {
|
|
1947
|
+
len = outputFigText2.length;
|
|
1948
|
+
for (row = 0; row < len; row++) {
|
|
1949
|
+
outputFigText2[row] = outputFigText2[row].replace(
|
|
1950
|
+
new RegExp("\\" + opts.hardBlank, "g"),
|
|
1951
|
+
" ",
|
|
1952
|
+
);
|
|
1953
|
+
}
|
|
1954
|
+
});
|
|
1955
|
+
}
|
|
1956
|
+
if (txt === "" && outputFigLines.length === 0) {
|
|
1957
|
+
outputFigLines.push(new Array(height).fill(""));
|
|
1958
|
+
}
|
|
1959
|
+
return outputFigLines;
|
|
1960
|
+
}
|
|
1961
|
+
const getHorizontalFittingRules = function (layout, options) {
|
|
1962
|
+
let params;
|
|
1963
|
+
const fittingRules = options.fittingRules || {};
|
|
1964
|
+
if (layout === "default") {
|
|
1965
|
+
params = {
|
|
1966
|
+
hLayout: fittingRules.hLayout,
|
|
1967
|
+
hRule1: fittingRules.hRule1,
|
|
1968
|
+
hRule2: fittingRules.hRule2,
|
|
1969
|
+
hRule3: fittingRules.hRule3,
|
|
1970
|
+
hRule4: fittingRules.hRule4,
|
|
1971
|
+
hRule5: fittingRules.hRule5,
|
|
1972
|
+
hRule6: fittingRules.hRule6,
|
|
1973
|
+
};
|
|
1974
|
+
} else if (layout === "full") {
|
|
1975
|
+
params = {
|
|
1976
|
+
hLayout: FULL_WIDTH,
|
|
1977
|
+
hRule1: false,
|
|
1978
|
+
hRule2: false,
|
|
1979
|
+
hRule3: false,
|
|
1980
|
+
hRule4: false,
|
|
1981
|
+
hRule5: false,
|
|
1982
|
+
hRule6: false,
|
|
1983
|
+
};
|
|
1984
|
+
} else if (layout === "fitted") {
|
|
1985
|
+
params = {
|
|
1986
|
+
hLayout: FITTING,
|
|
1987
|
+
hRule1: false,
|
|
1988
|
+
hRule2: false,
|
|
1989
|
+
hRule3: false,
|
|
1990
|
+
hRule4: false,
|
|
1991
|
+
hRule5: false,
|
|
1992
|
+
hRule6: false,
|
|
1993
|
+
};
|
|
1994
|
+
} else if (layout === "controlled smushing") {
|
|
1995
|
+
params = {
|
|
1996
|
+
hLayout: CONTROLLED_SMUSHING,
|
|
1997
|
+
hRule1: true,
|
|
1998
|
+
hRule2: true,
|
|
1999
|
+
hRule3: true,
|
|
2000
|
+
hRule4: true,
|
|
2001
|
+
hRule5: true,
|
|
2002
|
+
hRule6: true,
|
|
2003
|
+
};
|
|
2004
|
+
} else if (layout === "universal smushing") {
|
|
2005
|
+
params = {
|
|
2006
|
+
hLayout: SMUSHING,
|
|
2007
|
+
hRule1: false,
|
|
2008
|
+
hRule2: false,
|
|
2009
|
+
hRule3: false,
|
|
2010
|
+
hRule4: false,
|
|
2011
|
+
hRule5: false,
|
|
2012
|
+
hRule6: false,
|
|
2013
|
+
};
|
|
2014
|
+
} else {
|
|
2015
|
+
return;
|
|
2016
|
+
}
|
|
2017
|
+
return params;
|
|
2018
|
+
};
|
|
2019
|
+
const getVerticalFittingRules = function (layout, options) {
|
|
2020
|
+
let params = {};
|
|
2021
|
+
const fittingRules = options.fittingRules || {};
|
|
2022
|
+
if (layout === "default") {
|
|
2023
|
+
params = {
|
|
2024
|
+
vLayout: fittingRules.vLayout,
|
|
2025
|
+
vRule1: fittingRules.vRule1,
|
|
2026
|
+
vRule2: fittingRules.vRule2,
|
|
2027
|
+
vRule3: fittingRules.vRule3,
|
|
2028
|
+
vRule4: fittingRules.vRule4,
|
|
2029
|
+
vRule5: fittingRules.vRule5,
|
|
2030
|
+
};
|
|
2031
|
+
} else if (layout === "full") {
|
|
2032
|
+
params = {
|
|
2033
|
+
vLayout: FULL_WIDTH,
|
|
2034
|
+
vRule1: false,
|
|
2035
|
+
vRule2: false,
|
|
2036
|
+
vRule3: false,
|
|
2037
|
+
vRule4: false,
|
|
2038
|
+
vRule5: false,
|
|
2039
|
+
};
|
|
2040
|
+
} else if (layout === "fitted") {
|
|
2041
|
+
params = {
|
|
2042
|
+
vLayout: FITTING,
|
|
2043
|
+
vRule1: false,
|
|
2044
|
+
vRule2: false,
|
|
2045
|
+
vRule3: false,
|
|
2046
|
+
vRule4: false,
|
|
2047
|
+
vRule5: false,
|
|
2048
|
+
};
|
|
2049
|
+
} else if (layout === "controlled smushing") {
|
|
2050
|
+
params = {
|
|
2051
|
+
vLayout: CONTROLLED_SMUSHING,
|
|
2052
|
+
vRule1: true,
|
|
2053
|
+
vRule2: true,
|
|
2054
|
+
vRule3: true,
|
|
2055
|
+
vRule4: true,
|
|
2056
|
+
vRule5: true,
|
|
2057
|
+
};
|
|
2058
|
+
} else if (layout === "universal smushing") {
|
|
2059
|
+
params = {
|
|
2060
|
+
vLayout: SMUSHING,
|
|
2061
|
+
vRule1: false,
|
|
2062
|
+
vRule2: false,
|
|
2063
|
+
vRule3: false,
|
|
2064
|
+
vRule4: false,
|
|
2065
|
+
vRule5: false,
|
|
2066
|
+
};
|
|
2067
|
+
} else {
|
|
2068
|
+
return;
|
|
2069
|
+
}
|
|
2070
|
+
return params;
|
|
2071
|
+
};
|
|
2072
|
+
const generateText = function (fontName, options, txt) {
|
|
2073
|
+
txt = txt
|
|
2074
|
+
.replace(
|
|
2075
|
+
/\r\n/g,
|
|
2076
|
+
`
|
|
2077
|
+
`,
|
|
2078
|
+
)
|
|
2079
|
+
.replace(
|
|
2080
|
+
/\r/g,
|
|
2081
|
+
`
|
|
2082
|
+
`,
|
|
2083
|
+
);
|
|
2084
|
+
const actualFontName = getFontName(fontName);
|
|
2085
|
+
let lines = txt.split(`
|
|
2086
|
+
`);
|
|
2087
|
+
let figLines = [];
|
|
2088
|
+
let ii, len, output;
|
|
2089
|
+
len = lines.length;
|
|
2090
|
+
for (ii = 0; ii < len; ii++) {
|
|
2091
|
+
figLines = figLines.concat(
|
|
2092
|
+
generateFigTextLines(
|
|
2093
|
+
lines[ii],
|
|
2094
|
+
figFonts[actualFontName],
|
|
2095
|
+
options,
|
|
2096
|
+
),
|
|
2097
|
+
);
|
|
2098
|
+
}
|
|
2099
|
+
len = figLines.length;
|
|
2100
|
+
output = figLines[0];
|
|
2101
|
+
for (ii = 1; ii < len; ii++) {
|
|
2102
|
+
output = smushVerticalFigLines(output, figLines[ii], options);
|
|
2103
|
+
}
|
|
2104
|
+
return output
|
|
2105
|
+
? output.join(`
|
|
2106
|
+
`)
|
|
2107
|
+
: "";
|
|
2108
|
+
};
|
|
2109
|
+
function _reworkFontOpts(fontMeta, options) {
|
|
2110
|
+
let myOpts;
|
|
2111
|
+
if (typeof structuredClone !== "undefined") {
|
|
2112
|
+
myOpts = structuredClone(fontMeta);
|
|
2113
|
+
} else {
|
|
2114
|
+
myOpts = JSON.parse(JSON.stringify(fontMeta));
|
|
2115
|
+
}
|
|
2116
|
+
myOpts.showHardBlanks = options.showHardBlanks || false;
|
|
2117
|
+
myOpts.width = options.width || -1;
|
|
2118
|
+
myOpts.whitespaceBreak = options.whitespaceBreak || false;
|
|
2119
|
+
if (options.horizontalLayout) {
|
|
2120
|
+
const params = getHorizontalFittingRules(
|
|
2121
|
+
options.horizontalLayout,
|
|
2122
|
+
fontMeta,
|
|
2123
|
+
);
|
|
2124
|
+
if (params) {
|
|
2125
|
+
Object.assign(myOpts.fittingRules, params);
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
if (options.verticalLayout) {
|
|
2129
|
+
const params = getVerticalFittingRules(
|
|
2130
|
+
options.verticalLayout,
|
|
2131
|
+
fontMeta,
|
|
2132
|
+
);
|
|
2133
|
+
if (params) {
|
|
2134
|
+
Object.assign(myOpts.fittingRules, params);
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
myOpts.printDirection =
|
|
2138
|
+
options.printDirection !== null &&
|
|
2139
|
+
options.printDirection !== undefined
|
|
2140
|
+
? options.printDirection
|
|
2141
|
+
: fontMeta.printDirection;
|
|
2142
|
+
return myOpts;
|
|
2143
|
+
}
|
|
2144
|
+
const me = async function (txt, optionsOrFontOrCallback, callback) {
|
|
2145
|
+
return me.text(txt, optionsOrFontOrCallback, callback);
|
|
2146
|
+
};
|
|
2147
|
+
me.text = async function (txt, optionsOrFontOrCallback, callback) {
|
|
2148
|
+
txt = txt + "";
|
|
2149
|
+
let options, next;
|
|
2150
|
+
if (typeof optionsOrFontOrCallback === "function") {
|
|
2151
|
+
next = optionsOrFontOrCallback;
|
|
2152
|
+
options = { font: figDefaults.font };
|
|
2153
|
+
} else if (typeof optionsOrFontOrCallback === "string") {
|
|
2154
|
+
options = { font: optionsOrFontOrCallback };
|
|
2155
|
+
next = callback;
|
|
2156
|
+
} else if (optionsOrFontOrCallback) {
|
|
2157
|
+
options = optionsOrFontOrCallback;
|
|
2158
|
+
next = callback;
|
|
2159
|
+
} else {
|
|
2160
|
+
options = { font: figDefaults.font };
|
|
2161
|
+
next = callback;
|
|
2162
|
+
}
|
|
2163
|
+
const fontName = options.font || figDefaults.font;
|
|
2164
|
+
try {
|
|
2165
|
+
const fontOpts = await me.loadFont(fontName);
|
|
2166
|
+
const generatedTxt = fontOpts
|
|
2167
|
+
? generateText(
|
|
2168
|
+
fontName,
|
|
2169
|
+
_reworkFontOpts(fontOpts, options),
|
|
2170
|
+
txt,
|
|
2171
|
+
)
|
|
2172
|
+
: "";
|
|
2173
|
+
if (next) {
|
|
2174
|
+
next(null, generatedTxt);
|
|
2175
|
+
}
|
|
2176
|
+
return generatedTxt;
|
|
2177
|
+
} catch (err) {
|
|
2178
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
2179
|
+
if (next) {
|
|
2180
|
+
next(error);
|
|
2181
|
+
return "";
|
|
2182
|
+
}
|
|
2183
|
+
throw error;
|
|
2184
|
+
}
|
|
2185
|
+
};
|
|
2186
|
+
me.textSync = function (txt, options) {
|
|
2187
|
+
txt = txt + "";
|
|
2188
|
+
if (typeof options === "string") {
|
|
2189
|
+
options = { font: options };
|
|
2190
|
+
} else {
|
|
2191
|
+
options = options || {};
|
|
2192
|
+
}
|
|
2193
|
+
const fontName = options.font || figDefaults.font;
|
|
2194
|
+
let fontOpts = _reworkFontOpts(me.loadFontSync(fontName), options);
|
|
2195
|
+
return generateText(fontName, fontOpts, txt);
|
|
2196
|
+
};
|
|
2197
|
+
me.metadata = async function (fontName, callback) {
|
|
2198
|
+
fontName = fontName + "";
|
|
2199
|
+
try {
|
|
2200
|
+
const fontOpts = await me.loadFont(fontName);
|
|
2201
|
+
if (!fontOpts) {
|
|
2202
|
+
throw new Error("Error loading font.");
|
|
2203
|
+
}
|
|
2204
|
+
const actualFontName = getFontName(fontName);
|
|
2205
|
+
const font = figFonts[actualFontName] || {};
|
|
2206
|
+
const result = [fontOpts, font.comment || ""];
|
|
2207
|
+
if (callback) {
|
|
2208
|
+
callback(null, fontOpts, font.comment);
|
|
2209
|
+
}
|
|
2210
|
+
return result;
|
|
2211
|
+
} catch (err) {
|
|
2212
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
2213
|
+
if (callback) {
|
|
2214
|
+
callback(error);
|
|
2215
|
+
return null;
|
|
2216
|
+
}
|
|
2217
|
+
throw error;
|
|
2218
|
+
}
|
|
2219
|
+
};
|
|
2220
|
+
me.defaults = function (opts) {
|
|
2221
|
+
if (opts && typeof opts === "object") {
|
|
2222
|
+
Object.assign(figDefaults, opts);
|
|
2223
|
+
}
|
|
2224
|
+
if (typeof structuredClone !== "undefined") {
|
|
2225
|
+
return structuredClone(figDefaults);
|
|
2226
|
+
} else {
|
|
2227
|
+
return JSON.parse(JSON.stringify(figDefaults));
|
|
2228
|
+
}
|
|
2229
|
+
};
|
|
2230
|
+
me.parseFont = function (fontName, data, override = true) {
|
|
2231
|
+
if (figFonts[fontName] && !override) {
|
|
2232
|
+
return figFonts[fontName].options;
|
|
2233
|
+
}
|
|
2234
|
+
data = data
|
|
2235
|
+
.replace(
|
|
2236
|
+
/\r\n/g,
|
|
2237
|
+
`
|
|
2238
|
+
`,
|
|
2239
|
+
)
|
|
2240
|
+
.replace(
|
|
2241
|
+
/\r/g,
|
|
2242
|
+
`
|
|
2243
|
+
`,
|
|
2244
|
+
);
|
|
2245
|
+
const font = new FigletFont();
|
|
2246
|
+
const lines = data.split(`
|
|
2247
|
+
`);
|
|
2248
|
+
const headerLine = lines.shift();
|
|
2249
|
+
if (!headerLine) {
|
|
2250
|
+
throw new Error("Invalid font file: missing header");
|
|
2251
|
+
}
|
|
2252
|
+
const headerData = headerLine.split(" ");
|
|
2253
|
+
const opts = {
|
|
2254
|
+
hardBlank: headerData[0].substring(5, 6),
|
|
2255
|
+
height: parseInt(headerData[1], 10),
|
|
2256
|
+
baseline: parseInt(headerData[2], 10),
|
|
2257
|
+
maxLength: parseInt(headerData[3], 10),
|
|
2258
|
+
oldLayout: parseInt(headerData[4], 10),
|
|
2259
|
+
numCommentLines: parseInt(headerData[5], 10),
|
|
2260
|
+
printDirection: headerData[6] ? parseInt(headerData[6], 10) : 0,
|
|
2261
|
+
fullLayout: headerData[7] ? parseInt(headerData[7], 10) : null,
|
|
2262
|
+
codeTagCount: headerData[8] ? parseInt(headerData[8], 10) : null,
|
|
2263
|
+
};
|
|
2264
|
+
const hardBlank = opts.hardBlank || "";
|
|
2265
|
+
if (
|
|
2266
|
+
hardBlank.length !== 1 ||
|
|
2267
|
+
[
|
|
2268
|
+
opts.height,
|
|
2269
|
+
opts.baseline,
|
|
2270
|
+
opts.maxLength,
|
|
2271
|
+
opts.oldLayout,
|
|
2272
|
+
opts.numCommentLines,
|
|
2273
|
+
].some((val) => val === null || val === undefined || isNaN(val))
|
|
2274
|
+
) {
|
|
2275
|
+
throw new Error("FIGlet header contains invalid values.");
|
|
2276
|
+
}
|
|
2277
|
+
if (opts.height == null || opts.numCommentLines == null) {
|
|
2278
|
+
throw new Error("FIGlet header contains invalid values.");
|
|
2279
|
+
}
|
|
2280
|
+
opts.fittingRules = getSmushingRules(opts.oldLayout, opts.fullLayout);
|
|
2281
|
+
font.options = opts;
|
|
2282
|
+
const charNums = [];
|
|
2283
|
+
for (let i = 32; i <= 126; i++) {
|
|
2284
|
+
charNums.push(i);
|
|
2285
|
+
}
|
|
2286
|
+
charNums.push(196, 214, 220, 228, 246, 252, 223);
|
|
2287
|
+
if (
|
|
2288
|
+
lines.length <
|
|
2289
|
+
opts.numCommentLines + opts.height * charNums.length
|
|
2290
|
+
) {
|
|
2291
|
+
throw new Error(
|
|
2292
|
+
`FIGlet file is missing data. Line length: ${lines.length}. Comment lines: ${opts.numCommentLines}. Height: ${opts.height}. Num chars: ${charNums.length}.`,
|
|
2293
|
+
);
|
|
2294
|
+
}
|
|
2295
|
+
font.comment = lines.splice(0, opts.numCommentLines).join(`
|
|
2296
|
+
`);
|
|
2297
|
+
font.numChars = 0;
|
|
2298
|
+
while (lines.length > 0 && font.numChars < charNums.length) {
|
|
2299
|
+
const cNum = charNums[font.numChars];
|
|
2300
|
+
font[cNum] = lines.splice(0, opts.height);
|
|
2301
|
+
for (let i = 0; i < opts.height; i++) {
|
|
2302
|
+
if (typeof font[cNum][i] === "undefined") {
|
|
2303
|
+
font[cNum][i] = "";
|
|
2304
|
+
} else {
|
|
2305
|
+
font[cNum][i] = removeEndChar(
|
|
2306
|
+
font[cNum][i],
|
|
2307
|
+
i,
|
|
2308
|
+
opts.height,
|
|
2309
|
+
);
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
font.numChars++;
|
|
2313
|
+
}
|
|
2314
|
+
while (lines.length > 0) {
|
|
2315
|
+
const cNumLine = lines.shift();
|
|
2316
|
+
if (!cNumLine || cNumLine.trim() === "") break;
|
|
2317
|
+
let cNum = cNumLine.split(" ")[0];
|
|
2318
|
+
let parsedNum;
|
|
2319
|
+
if (/^-?0[xX][0-9a-fA-F]+$/.test(cNum)) {
|
|
2320
|
+
parsedNum = parseInt(cNum, 16);
|
|
2321
|
+
} else if (/^-?0[0-7]+$/.test(cNum)) {
|
|
2322
|
+
parsedNum = parseInt(cNum, 8);
|
|
2323
|
+
} else if (/^-?[0-9]+$/.test(cNum)) {
|
|
2324
|
+
parsedNum = parseInt(cNum, 10);
|
|
2325
|
+
} else {
|
|
2326
|
+
throw new Error(`Error parsing data. Invalid data: ${cNum}`);
|
|
2327
|
+
}
|
|
2328
|
+
if (
|
|
2329
|
+
parsedNum === -1 ||
|
|
2330
|
+
parsedNum < -2147483648 ||
|
|
2331
|
+
parsedNum > 2147483647
|
|
2332
|
+
) {
|
|
2333
|
+
const msg =
|
|
2334
|
+
parsedNum === -1
|
|
2335
|
+
? "The char code -1 is not permitted."
|
|
2336
|
+
: `The char code cannot be ${parsedNum < -2147483648 ? "less than -2147483648" : "greater than 2147483647"}.`;
|
|
2337
|
+
throw new Error(`Error parsing data. ${msg}`);
|
|
2338
|
+
}
|
|
2339
|
+
font[parsedNum] = lines.splice(0, opts.height);
|
|
2340
|
+
for (let i = 0; i < opts.height; i++) {
|
|
2341
|
+
if (typeof font[parsedNum][i] === "undefined") {
|
|
2342
|
+
font[parsedNum][i] = "";
|
|
2343
|
+
} else {
|
|
2344
|
+
font[parsedNum][i] = removeEndChar(
|
|
2345
|
+
font[parsedNum][i],
|
|
2346
|
+
i,
|
|
2347
|
+
opts.height,
|
|
2348
|
+
);
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2351
|
+
font.numChars++;
|
|
2352
|
+
}
|
|
2353
|
+
figFonts[fontName] = font;
|
|
2354
|
+
return opts;
|
|
2355
|
+
};
|
|
2356
|
+
me.loadedFonts = () => {
|
|
2357
|
+
return Object.keys(figFonts);
|
|
2358
|
+
};
|
|
2359
|
+
me.clearLoadedFonts = () => {
|
|
2360
|
+
Object.keys(figFonts).forEach((key) => {
|
|
2361
|
+
delete figFonts[key];
|
|
2362
|
+
});
|
|
2363
|
+
};
|
|
2364
|
+
me.loadFont = async function (fontName, callback) {
|
|
2365
|
+
const actualFontName = getFontName(fontName);
|
|
2366
|
+
if (figFonts[actualFontName]) {
|
|
2367
|
+
const result = figFonts[actualFontName].options;
|
|
2368
|
+
if (callback) {
|
|
2369
|
+
callback(null, result);
|
|
2370
|
+
}
|
|
2371
|
+
return Promise.resolve(result);
|
|
2372
|
+
}
|
|
2373
|
+
try {
|
|
2374
|
+
if (!figDefaults.fetchFontIfMissing) {
|
|
2375
|
+
throw new Error(`Font is not loaded: ${actualFontName}`);
|
|
2376
|
+
}
|
|
2377
|
+
const response = await fetch(
|
|
2378
|
+
`${figDefaults.fontPath}/${actualFontName}.flf`,
|
|
2379
|
+
);
|
|
2380
|
+
if (!response.ok) {
|
|
2381
|
+
throw new Error(
|
|
2382
|
+
`Network response was not ok: ${response.status}`,
|
|
2383
|
+
);
|
|
2384
|
+
}
|
|
2385
|
+
const text = await response.text();
|
|
2386
|
+
const result = me.parseFont(actualFontName, text);
|
|
2387
|
+
if (callback) {
|
|
2388
|
+
callback(null, result);
|
|
2389
|
+
}
|
|
2390
|
+
return result;
|
|
2391
|
+
} catch (error) {
|
|
2392
|
+
const err =
|
|
2393
|
+
error instanceof Error ? error : new Error(String(error));
|
|
2394
|
+
if (callback) {
|
|
2395
|
+
callback(err);
|
|
2396
|
+
return null;
|
|
2397
|
+
}
|
|
2398
|
+
throw err;
|
|
2399
|
+
}
|
|
2400
|
+
};
|
|
2401
|
+
me.loadFontSync = function (name) {
|
|
2402
|
+
const actualFontName = getFontName(name);
|
|
2403
|
+
if (figFonts[actualFontName]) {
|
|
2404
|
+
return figFonts[actualFontName].options;
|
|
2405
|
+
}
|
|
2406
|
+
throw new Error(
|
|
2407
|
+
"Synchronous font loading is not implemented for the browser, it will only work for fonts already loaded.",
|
|
2408
|
+
);
|
|
2409
|
+
};
|
|
2410
|
+
me.preloadFonts = async function (fonts, callback) {
|
|
2411
|
+
try {
|
|
2412
|
+
for (const name of fonts) {
|
|
2413
|
+
const actualFontName = getFontName(name);
|
|
2414
|
+
const response = await fetch(
|
|
2415
|
+
`${figDefaults.fontPath}/${actualFontName}.flf`,
|
|
2416
|
+
);
|
|
2417
|
+
if (!response.ok) {
|
|
2418
|
+
throw new Error(
|
|
2419
|
+
`Failed to preload fonts. Error fetching font: ${actualFontName}, status code: ${response.statusText}`,
|
|
2420
|
+
);
|
|
2421
|
+
}
|
|
2422
|
+
const data = await response.text();
|
|
2423
|
+
me.parseFont(actualFontName, data);
|
|
2424
|
+
}
|
|
2425
|
+
if (callback) {
|
|
2426
|
+
callback();
|
|
2427
|
+
}
|
|
2428
|
+
} catch (error) {
|
|
2429
|
+
const err =
|
|
2430
|
+
error instanceof Error ? error : new Error(String(error));
|
|
2431
|
+
if (callback) {
|
|
2432
|
+
callback(err);
|
|
2433
|
+
return;
|
|
2434
|
+
}
|
|
2435
|
+
throw error;
|
|
2436
|
+
}
|
|
2437
|
+
};
|
|
2438
|
+
me.fonts = function (callback) {
|
|
2439
|
+
return new Promise(function (resolve, reject) {
|
|
2440
|
+
resolve(fontList);
|
|
2441
|
+
if (callback) {
|
|
2442
|
+
callback(null, fontList);
|
|
2443
|
+
}
|
|
2444
|
+
});
|
|
2445
|
+
};
|
|
2446
|
+
me.fontsSync = function () {
|
|
2447
|
+
return fontList;
|
|
2448
|
+
};
|
|
2449
|
+
me.figFonts = figFonts;
|
|
2450
|
+
return me;
|
|
2451
|
+
})();
|
|
2452
|
+
|
|
2453
|
+
// node_modules/figlet/dist/node-figlet.mjs
|
|
2454
|
+
import { fileURLToPath } from "url";
|
|
2455
|
+
var __filename2 = fileURLToPath(import.meta.url);
|
|
2456
|
+
var __dirname2 = path.dirname(__filename2);
|
|
2457
|
+
var fontPath = path.join(__dirname2, "/../fonts/");
|
|
2458
|
+
var nodeFiglet = figlet;
|
|
2459
|
+
nodeFiglet.defaults({ fontPath });
|
|
2460
|
+
nodeFiglet.loadFont = function (name, callback) {
|
|
2461
|
+
const actualFontName = getFontName(name);
|
|
2462
|
+
return new Promise((resolve, reject) => {
|
|
2463
|
+
if (nodeFiglet.figFonts[actualFontName]) {
|
|
2464
|
+
if (callback) {
|
|
2465
|
+
callback(null, nodeFiglet.figFonts[actualFontName].options);
|
|
2466
|
+
}
|
|
2467
|
+
resolve(nodeFiglet.figFonts[actualFontName].options);
|
|
2468
|
+
return;
|
|
2469
|
+
}
|
|
2470
|
+
fs.readFile(
|
|
2471
|
+
path.join(nodeFiglet.defaults().fontPath, actualFontName + ".flf"),
|
|
2472
|
+
{ encoding: "utf-8" },
|
|
2473
|
+
(err, fontData) => {
|
|
2474
|
+
if (err) {
|
|
2475
|
+
if (callback) {
|
|
2476
|
+
callback(err);
|
|
2477
|
+
}
|
|
2478
|
+
reject(err);
|
|
2479
|
+
return;
|
|
2480
|
+
}
|
|
2481
|
+
fontData = fontData + "";
|
|
2482
|
+
try {
|
|
2483
|
+
const font = nodeFiglet.parseFont(actualFontName, fontData);
|
|
2484
|
+
if (callback) {
|
|
2485
|
+
callback(null, font);
|
|
2486
|
+
}
|
|
2487
|
+
resolve(font);
|
|
2488
|
+
} catch (error) {
|
|
2489
|
+
const typedError =
|
|
2490
|
+
error instanceof Error
|
|
2491
|
+
? error
|
|
2492
|
+
: new Error(String(error));
|
|
2493
|
+
if (callback) {
|
|
2494
|
+
callback(typedError);
|
|
2495
|
+
}
|
|
2496
|
+
reject(typedError);
|
|
2497
|
+
}
|
|
2498
|
+
},
|
|
2499
|
+
);
|
|
2500
|
+
});
|
|
2501
|
+
};
|
|
2502
|
+
nodeFiglet.loadFontSync = function (font) {
|
|
2503
|
+
const actualFontName = getFontName(font);
|
|
2504
|
+
if (nodeFiglet.figFonts[actualFontName]) {
|
|
2505
|
+
return nodeFiglet.figFonts[actualFontName].options;
|
|
2506
|
+
}
|
|
2507
|
+
const fontData =
|
|
2508
|
+
fs.readFileSync(
|
|
2509
|
+
path.join(nodeFiglet.defaults().fontPath, actualFontName + ".flf"),
|
|
2510
|
+
{
|
|
2511
|
+
encoding: "utf-8",
|
|
2512
|
+
},
|
|
2513
|
+
) + "";
|
|
2514
|
+
return nodeFiglet.parseFont(actualFontName, fontData);
|
|
2515
|
+
};
|
|
2516
|
+
nodeFiglet.fonts = function (next) {
|
|
2517
|
+
return new Promise((resolve, reject) => {
|
|
2518
|
+
const fontList2 = [];
|
|
2519
|
+
fs.readdir(nodeFiglet.defaults().fontPath, (err, files) => {
|
|
2520
|
+
if (err) {
|
|
2521
|
+
next && next(err);
|
|
2522
|
+
reject(err);
|
|
2523
|
+
return;
|
|
2524
|
+
}
|
|
2525
|
+
files.forEach((file) => {
|
|
2526
|
+
if (/\.flf$/.test(file)) {
|
|
2527
|
+
fontList2.push(file.replace(/\.flf$/, ""));
|
|
2528
|
+
}
|
|
2529
|
+
});
|
|
2530
|
+
next && next(null, fontList2);
|
|
2531
|
+
resolve(fontList2);
|
|
2532
|
+
});
|
|
2533
|
+
});
|
|
2534
|
+
};
|
|
2535
|
+
nodeFiglet.fontsSync = function () {
|
|
2536
|
+
const fontList2 = [];
|
|
2537
|
+
fs.readdirSync(nodeFiglet.defaults().fontPath).forEach((file) => {
|
|
2538
|
+
if (/\.flf$/.test(file)) {
|
|
2539
|
+
fontList2.push(file.replace(/\.flf$/, ""));
|
|
2540
|
+
}
|
|
2541
|
+
});
|
|
2542
|
+
return fontList2;
|
|
2543
|
+
};
|
|
2544
|
+
|
|
2545
|
+
// node_modules/boxen/index.js
|
|
2546
|
+
import process3 from "node:process";
|
|
2547
|
+
|
|
2548
|
+
// node_modules/ansi-regex/index.js
|
|
2549
|
+
function ansiRegex({ onlyFirst = false } = {}) {
|
|
2550
|
+
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
2551
|
+
const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
|
|
2552
|
+
const csi =
|
|
2553
|
+
"[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
|
|
2554
|
+
const pattern = `${osc}|${csi}`;
|
|
2555
|
+
return new RegExp(pattern, onlyFirst ? undefined : "g");
|
|
2556
|
+
}
|
|
2557
|
+
|
|
2558
|
+
// node_modules/strip-ansi/index.js
|
|
2559
|
+
var regex = ansiRegex();
|
|
2560
|
+
function stripAnsi(string) {
|
|
2561
|
+
if (typeof string !== "string") {
|
|
2562
|
+
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
2563
|
+
}
|
|
2564
|
+
if (!string.includes("\x1B") && !string.includes("")) {
|
|
2565
|
+
return string;
|
|
2566
|
+
}
|
|
2567
|
+
return string.replace(regex, "");
|
|
2568
|
+
}
|
|
2569
|
+
|
|
2570
|
+
// node_modules/get-east-asian-width/lookup-data.js
|
|
2571
|
+
var ambiguousRanges = [
|
|
2572
|
+
161, 161, 164, 164, 167, 168, 170, 170, 173, 174, 176, 180, 182, 186, 188,
|
|
2573
|
+
191, 198, 198, 208, 208, 215, 216, 222, 225, 230, 230, 232, 234, 236, 237,
|
|
2574
|
+
240, 240, 242, 243, 247, 250, 252, 252, 254, 254, 257, 257, 273, 273, 275,
|
|
2575
|
+
275, 283, 283, 294, 295, 299, 299, 305, 307, 312, 312, 319, 322, 324, 324,
|
|
2576
|
+
328, 331, 333, 333, 338, 339, 358, 359, 363, 363, 462, 462, 464, 464, 466,
|
|
2577
|
+
466, 468, 468, 470, 470, 472, 472, 474, 474, 476, 476, 593, 593, 609, 609,
|
|
2578
|
+
708, 708, 711, 711, 713, 715, 717, 717, 720, 720, 728, 731, 733, 733, 735,
|
|
2579
|
+
735, 768, 879, 913, 929, 931, 937, 945, 961, 963, 969, 1025, 1025, 1040,
|
|
2580
|
+
1103, 1105, 1105, 8208, 8208, 8211, 8214, 8216, 8217, 8220, 8221, 8224,
|
|
2581
|
+
8226, 8228, 8231, 8240, 8240, 8242, 8243, 8245, 8245, 8251, 8251, 8254,
|
|
2582
|
+
8254, 8308, 8308, 8319, 8319, 8321, 8324, 8364, 8364, 8451, 8451, 8453,
|
|
2583
|
+
8453, 8457, 8457, 8467, 8467, 8470, 8470, 8481, 8482, 8486, 8486, 8491,
|
|
2584
|
+
8491, 8531, 8532, 8539, 8542, 8544, 8555, 8560, 8569, 8585, 8585, 8592,
|
|
2585
|
+
8601, 8632, 8633, 8658, 8658, 8660, 8660, 8679, 8679, 8704, 8704, 8706,
|
|
2586
|
+
8707, 8711, 8712, 8715, 8715, 8719, 8719, 8721, 8721, 8725, 8725, 8730,
|
|
2587
|
+
8730, 8733, 8736, 8739, 8739, 8741, 8741, 8743, 8748, 8750, 8750, 8756,
|
|
2588
|
+
8759, 8764, 8765, 8776, 8776, 8780, 8780, 8786, 8786, 8800, 8801, 8804,
|
|
2589
|
+
8807, 8810, 8811, 8814, 8815, 8834, 8835, 8838, 8839, 8853, 8853, 8857,
|
|
2590
|
+
8857, 8869, 8869, 8895, 8895, 8978, 8978, 9312, 9449, 9451, 9547, 9552,
|
|
2591
|
+
9587, 9600, 9615, 9618, 9621, 9632, 9633, 9635, 9641, 9650, 9651, 9654,
|
|
2592
|
+
9655, 9660, 9661, 9664, 9665, 9670, 9672, 9675, 9675, 9678, 9681, 9698,
|
|
2593
|
+
9701, 9711, 9711, 9733, 9734, 9737, 9737, 9742, 9743, 9756, 9756, 9758,
|
|
2594
|
+
9758, 9792, 9792, 9794, 9794, 9824, 9825, 9827, 9829, 9831, 9834, 9836,
|
|
2595
|
+
9837, 9839, 9839, 9886, 9887, 9919, 9919, 9926, 9933, 9935, 9939, 9941,
|
|
2596
|
+
9953, 9955, 9955, 9960, 9961, 9963, 9969, 9972, 9972, 9974, 9977, 9979,
|
|
2597
|
+
9980, 9982, 9983, 10045, 10045, 10102, 10111, 11094, 11097, 12872, 12879,
|
|
2598
|
+
57344, 63743, 65024, 65039, 65533, 65533, 127232, 127242, 127248, 127277,
|
|
2599
|
+
127280, 127337, 127344, 127373, 127375, 127376, 127387, 127404, 917760,
|
|
2600
|
+
917999, 983040, 1048573, 1048576, 1114109,
|
|
2601
|
+
];
|
|
2602
|
+
var fullwidthRanges = [12288, 12288, 65281, 65376, 65504, 65510];
|
|
2603
|
+
var halfwidthRanges = [
|
|
2604
|
+
8361, 8361, 65377, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498,
|
|
2605
|
+
65500, 65512, 65518,
|
|
2606
|
+
];
|
|
2607
|
+
var narrowRanges = [
|
|
2608
|
+
32, 126, 162, 163, 165, 166, 172, 172, 175, 175, 10214, 10221, 10629, 10630,
|
|
2609
|
+
];
|
|
2610
|
+
var wideRanges = [
|
|
2611
|
+
4352, 4447, 8986, 8987, 9001, 9002, 9193, 9196, 9200, 9200, 9203, 9203,
|
|
2612
|
+
9725, 9726, 9748, 9749, 9776, 9783, 9800, 9811, 9855, 9855, 9866, 9871,
|
|
2613
|
+
9875, 9875, 9889, 9889, 9898, 9899, 9917, 9918, 9924, 9925, 9934, 9934,
|
|
2614
|
+
9940, 9940, 9962, 9962, 9970, 9971, 9973, 9973, 9978, 9978, 9981, 9981,
|
|
2615
|
+
9989, 9989, 9994, 9995, 10024, 10024, 10060, 10060, 10062, 10062, 10067,
|
|
2616
|
+
10069, 10071, 10071, 10133, 10135, 10160, 10160, 10175, 10175, 11035, 11036,
|
|
2617
|
+
11088, 11088, 11093, 11093, 11904, 11929, 11931, 12019, 12032, 12245, 12272,
|
|
2618
|
+
12287, 12289, 12350, 12353, 12438, 12441, 12543, 12549, 12591, 12593, 12686,
|
|
2619
|
+
12688, 12773, 12783, 12830, 12832, 12871, 12880, 42124, 42128, 42182, 43360,
|
|
2620
|
+
43388, 44032, 55203, 63744, 64255, 65040, 65049, 65072, 65106, 65108, 65126,
|
|
2621
|
+
65128, 65131, 94176, 94180, 94192, 94198, 94208, 101589, 101631, 101662,
|
|
2622
|
+
101760, 101874, 110576, 110579, 110581, 110587, 110589, 110590, 110592,
|
|
2623
|
+
110882, 110898, 110898, 110928, 110930, 110933, 110933, 110948, 110951,
|
|
2624
|
+
110960, 111355, 119552, 119638, 119648, 119670, 126980, 126980, 127183,
|
|
2625
|
+
127183, 127374, 127374, 127377, 127386, 127488, 127490, 127504, 127547,
|
|
2626
|
+
127552, 127560, 127568, 127569, 127584, 127589, 127744, 127776, 127789,
|
|
2627
|
+
127797, 127799, 127868, 127870, 127891, 127904, 127946, 127951, 127955,
|
|
2628
|
+
127968, 127984, 127988, 127988, 127992, 128062, 128064, 128064, 128066,
|
|
2629
|
+
128252, 128255, 128317, 128331, 128334, 128336, 128359, 128378, 128378,
|
|
2630
|
+
128405, 128406, 128420, 128420, 128507, 128591, 128640, 128709, 128716,
|
|
2631
|
+
128716, 128720, 128722, 128725, 128728, 128732, 128735, 128747, 128748,
|
|
2632
|
+
128756, 128764, 128992, 129003, 129008, 129008, 129292, 129338, 129340,
|
|
2633
|
+
129349, 129351, 129535, 129648, 129660, 129664, 129674, 129678, 129734,
|
|
2634
|
+
129736, 129736, 129741, 129756, 129759, 129770, 129775, 129784, 131072,
|
|
2635
|
+
196605, 196608, 262141,
|
|
2636
|
+
];
|
|
2637
|
+
|
|
2638
|
+
// node_modules/get-east-asian-width/utilities.js
|
|
2639
|
+
var isInRange = (ranges, codePoint) => {
|
|
2640
|
+
let low = 0;
|
|
2641
|
+
let high = Math.floor(ranges.length / 2) - 1;
|
|
2642
|
+
while (low <= high) {
|
|
2643
|
+
const mid = Math.floor((low + high) / 2);
|
|
2644
|
+
const i = mid * 2;
|
|
2645
|
+
if (codePoint < ranges[i]) {
|
|
2646
|
+
high = mid - 1;
|
|
2647
|
+
} else if (codePoint > ranges[i + 1]) {
|
|
2648
|
+
low = mid + 1;
|
|
2649
|
+
} else {
|
|
2650
|
+
return true;
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
return false;
|
|
2654
|
+
};
|
|
2655
|
+
|
|
2656
|
+
// node_modules/get-east-asian-width/lookup.js
|
|
2657
|
+
var minimumAmbiguousCodePoint = ambiguousRanges[0];
|
|
2658
|
+
var maximumAmbiguousCodePoint = ambiguousRanges.at(-1);
|
|
2659
|
+
var minimumFullWidthCodePoint = fullwidthRanges[0];
|
|
2660
|
+
var maximumFullWidthCodePoint = fullwidthRanges.at(-1);
|
|
2661
|
+
var minimumHalfWidthCodePoint = halfwidthRanges[0];
|
|
2662
|
+
var maximumHalfWidthCodePoint = halfwidthRanges.at(-1);
|
|
2663
|
+
var minimumNarrowCodePoint = narrowRanges[0];
|
|
2664
|
+
var maximumNarrowCodePoint = narrowRanges.at(-1);
|
|
2665
|
+
var minimumWideCodePoint = wideRanges[0];
|
|
2666
|
+
var maximumWideCodePoint = wideRanges.at(-1);
|
|
2667
|
+
var commonCjkCodePoint = 19968;
|
|
2668
|
+
var [wideFastPathStart, wideFastPathEnd] = findWideFastPathRange(wideRanges);
|
|
2669
|
+
function findWideFastPathRange(ranges) {
|
|
2670
|
+
let fastPathStart = ranges[0];
|
|
2671
|
+
let fastPathEnd = ranges[1];
|
|
2672
|
+
for (let index = 0; index < ranges.length; index += 2) {
|
|
2673
|
+
const start = ranges[index];
|
|
2674
|
+
const end = ranges[index + 1];
|
|
2675
|
+
if (commonCjkCodePoint >= start && commonCjkCodePoint <= end) {
|
|
2676
|
+
return [start, end];
|
|
2677
|
+
}
|
|
2678
|
+
if (end - start > fastPathEnd - fastPathStart) {
|
|
2679
|
+
fastPathStart = start;
|
|
2680
|
+
fastPathEnd = end;
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
return [fastPathStart, fastPathEnd];
|
|
2684
|
+
}
|
|
2685
|
+
var isAmbiguous = (codePoint) => {
|
|
2686
|
+
if (
|
|
2687
|
+
codePoint < minimumAmbiguousCodePoint ||
|
|
2688
|
+
codePoint > maximumAmbiguousCodePoint
|
|
2689
|
+
) {
|
|
2690
|
+
return false;
|
|
2691
|
+
}
|
|
2692
|
+
return isInRange(ambiguousRanges, codePoint);
|
|
2693
|
+
};
|
|
2694
|
+
var isFullWidth = (codePoint) => {
|
|
2695
|
+
if (
|
|
2696
|
+
codePoint < minimumFullWidthCodePoint ||
|
|
2697
|
+
codePoint > maximumFullWidthCodePoint
|
|
2698
|
+
) {
|
|
2699
|
+
return false;
|
|
2700
|
+
}
|
|
2701
|
+
return isInRange(fullwidthRanges, codePoint);
|
|
2702
|
+
};
|
|
2703
|
+
var isWide = (codePoint) => {
|
|
2704
|
+
if (codePoint >= wideFastPathStart && codePoint <= wideFastPathEnd) {
|
|
2705
|
+
return true;
|
|
2706
|
+
}
|
|
2707
|
+
if (codePoint < minimumWideCodePoint || codePoint > maximumWideCodePoint) {
|
|
2708
|
+
return false;
|
|
2709
|
+
}
|
|
2710
|
+
return isInRange(wideRanges, codePoint);
|
|
2711
|
+
};
|
|
2712
|
+
|
|
2713
|
+
// node_modules/get-east-asian-width/index.js
|
|
2714
|
+
function validate(codePoint) {
|
|
2715
|
+
if (!Number.isSafeInteger(codePoint)) {
|
|
2716
|
+
throw new TypeError(
|
|
2717
|
+
`Expected a code point, got \`${typeof codePoint}\`.`,
|
|
2718
|
+
);
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
|
|
2722
|
+
validate(codePoint);
|
|
2723
|
+
if (
|
|
2724
|
+
isFullWidth(codePoint) ||
|
|
2725
|
+
isWide(codePoint) ||
|
|
2726
|
+
(ambiguousAsWide && isAmbiguous(codePoint))
|
|
2727
|
+
) {
|
|
2728
|
+
return 2;
|
|
2729
|
+
}
|
|
2730
|
+
return 1;
|
|
2731
|
+
}
|
|
2732
|
+
|
|
2733
|
+
// node_modules/string-width/index.js
|
|
2734
|
+
var import_emoji_regex = __toESM(require_emoji_regex(), 1);
|
|
2735
|
+
var segmenter = new Intl.Segmenter();
|
|
2736
|
+
var defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
|
|
2737
|
+
function stringWidth(string, options = {}) {
|
|
2738
|
+
if (typeof string !== "string" || string.length === 0) {
|
|
2739
|
+
return 0;
|
|
2740
|
+
}
|
|
2741
|
+
const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options;
|
|
2742
|
+
if (!countAnsiEscapeCodes) {
|
|
2743
|
+
string = stripAnsi(string);
|
|
2744
|
+
}
|
|
2745
|
+
if (string.length === 0) {
|
|
2746
|
+
return 0;
|
|
2747
|
+
}
|
|
2748
|
+
let width = 0;
|
|
2749
|
+
const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
|
|
2750
|
+
for (const { segment: character } of segmenter.segment(string)) {
|
|
2751
|
+
const codePoint = character.codePointAt(0);
|
|
2752
|
+
if (codePoint <= 31 || (codePoint >= 127 && codePoint <= 159)) {
|
|
2753
|
+
continue;
|
|
2754
|
+
}
|
|
2755
|
+
if ((codePoint >= 8203 && codePoint <= 8207) || codePoint === 65279) {
|
|
2756
|
+
continue;
|
|
2757
|
+
}
|
|
2758
|
+
if (
|
|
2759
|
+
(codePoint >= 768 && codePoint <= 879) ||
|
|
2760
|
+
(codePoint >= 6832 && codePoint <= 6911) ||
|
|
2761
|
+
(codePoint >= 7616 && codePoint <= 7679) ||
|
|
2762
|
+
(codePoint >= 8400 && codePoint <= 8447) ||
|
|
2763
|
+
(codePoint >= 65056 && codePoint <= 65071)
|
|
2764
|
+
) {
|
|
2765
|
+
continue;
|
|
2766
|
+
}
|
|
2767
|
+
if (codePoint >= 55296 && codePoint <= 57343) {
|
|
2768
|
+
continue;
|
|
2769
|
+
}
|
|
2770
|
+
if (codePoint >= 65024 && codePoint <= 65039) {
|
|
2771
|
+
continue;
|
|
2772
|
+
}
|
|
2773
|
+
if (defaultIgnorableCodePointRegex.test(character)) {
|
|
2774
|
+
continue;
|
|
2775
|
+
}
|
|
2776
|
+
if (import_emoji_regex.default().test(character)) {
|
|
2777
|
+
width += 2;
|
|
2778
|
+
continue;
|
|
2779
|
+
}
|
|
2780
|
+
width += eastAsianWidth(codePoint, eastAsianWidthOptions);
|
|
2781
|
+
}
|
|
2782
|
+
return width;
|
|
2783
|
+
}
|
|
2784
|
+
|
|
2785
|
+
// node_modules/widest-line/index.js
|
|
2786
|
+
function widestLine(string) {
|
|
2787
|
+
let lineWidth = 0;
|
|
2788
|
+
for (const line of string.split(`
|
|
2789
|
+
`)) {
|
|
2790
|
+
lineWidth = Math.max(lineWidth, stringWidth(line));
|
|
2791
|
+
}
|
|
2792
|
+
return lineWidth;
|
|
2793
|
+
}
|
|
2794
|
+
|
|
2795
|
+
// node_modules/boxen/index.js
|
|
2796
|
+
var import_cli_boxes = __toESM(require_cli_boxes(), 1);
|
|
2797
|
+
|
|
2798
|
+
// node_modules/camelcase/index.js
|
|
2799
|
+
var UPPERCASE = /[\p{Lu}]/u;
|
|
2800
|
+
var LOWERCASE = /[\p{Ll}]/u;
|
|
2801
|
+
var LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/gu;
|
|
2802
|
+
var IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
|
|
2803
|
+
var SEPARATORS = /[_.\- ]+/;
|
|
2804
|
+
var LEADING_SEPARATORS = new RegExp("^" + SEPARATORS.source);
|
|
2805
|
+
var SEPARATORS_AND_IDENTIFIER = new RegExp(
|
|
2806
|
+
SEPARATORS.source + IDENTIFIER.source,
|
|
2807
|
+
"gu",
|
|
2808
|
+
);
|
|
2809
|
+
var NUMBERS_AND_IDENTIFIER = new RegExp("\\d+" + IDENTIFIER.source, "gu");
|
|
2810
|
+
var preserveCamelCase = (
|
|
2811
|
+
string,
|
|
2812
|
+
toLowerCase,
|
|
2813
|
+
toUpperCase,
|
|
2814
|
+
preserveConsecutiveUppercase,
|
|
2815
|
+
) => {
|
|
2816
|
+
let isLastCharLower = false;
|
|
2817
|
+
let isLastCharUpper = false;
|
|
2818
|
+
let isLastLastCharUpper = false;
|
|
2819
|
+
let isLastLastCharPreserved = false;
|
|
2820
|
+
for (let index = 0; index < string.length; index++) {
|
|
2821
|
+
const character = string[index];
|
|
2822
|
+
isLastLastCharPreserved = index > 2 ? string[index - 3] === "-" : true;
|
|
2823
|
+
if (isLastCharLower && UPPERCASE.test(character)) {
|
|
2824
|
+
string = string.slice(0, index) + "-" + string.slice(index);
|
|
2825
|
+
isLastCharLower = false;
|
|
2826
|
+
isLastLastCharUpper = isLastCharUpper;
|
|
2827
|
+
isLastCharUpper = true;
|
|
2828
|
+
index++;
|
|
2829
|
+
} else if (
|
|
2830
|
+
isLastCharUpper &&
|
|
2831
|
+
isLastLastCharUpper &&
|
|
2832
|
+
LOWERCASE.test(character) &&
|
|
2833
|
+
(!isLastLastCharPreserved || preserveConsecutiveUppercase)
|
|
2834
|
+
) {
|
|
2835
|
+
string = string.slice(0, index - 1) + "-" + string.slice(index - 1);
|
|
2836
|
+
isLastLastCharUpper = isLastCharUpper;
|
|
2837
|
+
isLastCharUpper = false;
|
|
2838
|
+
isLastCharLower = true;
|
|
2839
|
+
} else {
|
|
2840
|
+
isLastCharLower =
|
|
2841
|
+
toLowerCase(character) === character &&
|
|
2842
|
+
toUpperCase(character) !== character;
|
|
2843
|
+
isLastLastCharUpper = isLastCharUpper;
|
|
2844
|
+
isLastCharUpper =
|
|
2845
|
+
toUpperCase(character) === character &&
|
|
2846
|
+
toLowerCase(character) !== character;
|
|
2847
|
+
}
|
|
2848
|
+
}
|
|
2849
|
+
return string;
|
|
2850
|
+
};
|
|
2851
|
+
var preserveConsecutiveUppercase = (input, toLowerCase) => {
|
|
2852
|
+
LEADING_CAPITAL.lastIndex = 0;
|
|
2853
|
+
return input.replaceAll(LEADING_CAPITAL, (match) => toLowerCase(match));
|
|
2854
|
+
};
|
|
2855
|
+
var postProcess = (input, toUpperCase) => {
|
|
2856
|
+
SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
|
|
2857
|
+
NUMBERS_AND_IDENTIFIER.lastIndex = 0;
|
|
2858
|
+
return input
|
|
2859
|
+
.replaceAll(NUMBERS_AND_IDENTIFIER, (match, pattern, offset) =>
|
|
2860
|
+
["_", "-"].includes(input.charAt(offset + match.length))
|
|
2861
|
+
? match
|
|
2862
|
+
: toUpperCase(match),
|
|
2863
|
+
)
|
|
2864
|
+
.replaceAll(SEPARATORS_AND_IDENTIFIER, (_, identifier) =>
|
|
2865
|
+
toUpperCase(identifier),
|
|
2866
|
+
);
|
|
2867
|
+
};
|
|
2868
|
+
function camelCase(input, options) {
|
|
2869
|
+
if (!(typeof input === "string" || Array.isArray(input))) {
|
|
2870
|
+
throw new TypeError("Expected the input to be `string | string[]`");
|
|
2871
|
+
}
|
|
2872
|
+
options = {
|
|
2873
|
+
pascalCase: false,
|
|
2874
|
+
preserveConsecutiveUppercase: false,
|
|
2875
|
+
...options,
|
|
2876
|
+
};
|
|
2877
|
+
if (Array.isArray(input)) {
|
|
2878
|
+
input = input
|
|
2879
|
+
.map((x) => x.trim())
|
|
2880
|
+
.filter((x) => x.length)
|
|
2881
|
+
.join("-");
|
|
2882
|
+
} else {
|
|
2883
|
+
input = input.trim();
|
|
2884
|
+
}
|
|
2885
|
+
if (input.length === 0) {
|
|
2886
|
+
return "";
|
|
2887
|
+
}
|
|
2888
|
+
const toLowerCase =
|
|
2889
|
+
options.locale === false
|
|
2890
|
+
? (string) => string.toLowerCase()
|
|
2891
|
+
: (string) => string.toLocaleLowerCase(options.locale);
|
|
2892
|
+
const toUpperCase =
|
|
2893
|
+
options.locale === false
|
|
2894
|
+
? (string) => string.toUpperCase()
|
|
2895
|
+
: (string) => string.toLocaleUpperCase(options.locale);
|
|
2896
|
+
if (input.length === 1) {
|
|
2897
|
+
if (SEPARATORS.test(input)) {
|
|
2898
|
+
return "";
|
|
2899
|
+
}
|
|
2900
|
+
return options.pascalCase ? toUpperCase(input) : toLowerCase(input);
|
|
2901
|
+
}
|
|
2902
|
+
const hasUpperCase = input !== toLowerCase(input);
|
|
2903
|
+
if (hasUpperCase) {
|
|
2904
|
+
input = preserveCamelCase(
|
|
2905
|
+
input,
|
|
2906
|
+
toLowerCase,
|
|
2907
|
+
toUpperCase,
|
|
2908
|
+
options.preserveConsecutiveUppercase,
|
|
2909
|
+
);
|
|
2910
|
+
}
|
|
2911
|
+
input = input.replace(LEADING_SEPARATORS, "");
|
|
2912
|
+
input = options.preserveConsecutiveUppercase
|
|
2913
|
+
? preserveConsecutiveUppercase(input, toLowerCase)
|
|
2914
|
+
: toLowerCase(input);
|
|
2915
|
+
if (options.pascalCase) {
|
|
2916
|
+
input = toUpperCase(input.charAt(0)) + input.slice(1);
|
|
2917
|
+
}
|
|
2918
|
+
return postProcess(input, toUpperCase);
|
|
2919
|
+
}
|
|
2920
|
+
|
|
2921
|
+
// node_modules/boxen/index.js
|
|
2922
|
+
var import_ansi_align = __toESM(require_ansi_align(), 1);
|
|
2923
|
+
|
|
2924
|
+
// node_modules/ansi-styles/index.js
|
|
2925
|
+
var ANSI_BACKGROUND_OFFSET2 = 10;
|
|
2926
|
+
var wrapAnsi162 =
|
|
2927
|
+
(offset = 0) =>
|
|
2928
|
+
(code) =>
|
|
2929
|
+
`\x1B[${code + offset}m`;
|
|
2930
|
+
var wrapAnsi2562 =
|
|
2931
|
+
(offset = 0) =>
|
|
2932
|
+
(code) =>
|
|
2933
|
+
`\x1B[${38 + offset};5;${code}m`;
|
|
2934
|
+
var wrapAnsi16m2 =
|
|
2935
|
+
(offset = 0) =>
|
|
2936
|
+
(red, green, blue) =>
|
|
2937
|
+
`\x1B[${38 + offset};2;${red};${green};${blue}m`;
|
|
2938
|
+
var styles3 = {
|
|
2939
|
+
modifier: {
|
|
2940
|
+
reset: [0, 0],
|
|
2941
|
+
bold: [1, 22],
|
|
2942
|
+
dim: [2, 22],
|
|
2943
|
+
italic: [3, 23],
|
|
2944
|
+
underline: [4, 24],
|
|
2945
|
+
overline: [53, 55],
|
|
2946
|
+
inverse: [7, 27],
|
|
2947
|
+
hidden: [8, 28],
|
|
2948
|
+
strikethrough: [9, 29],
|
|
2949
|
+
},
|
|
2950
|
+
color: {
|
|
2951
|
+
black: [30, 39],
|
|
2952
|
+
red: [31, 39],
|
|
2953
|
+
green: [32, 39],
|
|
2954
|
+
yellow: [33, 39],
|
|
2955
|
+
blue: [34, 39],
|
|
2956
|
+
magenta: [35, 39],
|
|
2957
|
+
cyan: [36, 39],
|
|
2958
|
+
white: [37, 39],
|
|
2959
|
+
blackBright: [90, 39],
|
|
2960
|
+
gray: [90, 39],
|
|
2961
|
+
grey: [90, 39],
|
|
2962
|
+
redBright: [91, 39],
|
|
2963
|
+
greenBright: [92, 39],
|
|
2964
|
+
yellowBright: [93, 39],
|
|
2965
|
+
blueBright: [94, 39],
|
|
2966
|
+
magentaBright: [95, 39],
|
|
2967
|
+
cyanBright: [96, 39],
|
|
2968
|
+
whiteBright: [97, 39],
|
|
2969
|
+
},
|
|
2970
|
+
bgColor: {
|
|
2971
|
+
bgBlack: [40, 49],
|
|
2972
|
+
bgRed: [41, 49],
|
|
2973
|
+
bgGreen: [42, 49],
|
|
2974
|
+
bgYellow: [43, 49],
|
|
2975
|
+
bgBlue: [44, 49],
|
|
2976
|
+
bgMagenta: [45, 49],
|
|
2977
|
+
bgCyan: [46, 49],
|
|
2978
|
+
bgWhite: [47, 49],
|
|
2979
|
+
bgBlackBright: [100, 49],
|
|
2980
|
+
bgGray: [100, 49],
|
|
2981
|
+
bgGrey: [100, 49],
|
|
2982
|
+
bgRedBright: [101, 49],
|
|
2983
|
+
bgGreenBright: [102, 49],
|
|
2984
|
+
bgYellowBright: [103, 49],
|
|
2985
|
+
bgBlueBright: [104, 49],
|
|
2986
|
+
bgMagentaBright: [105, 49],
|
|
2987
|
+
bgCyanBright: [106, 49],
|
|
2988
|
+
bgWhiteBright: [107, 49],
|
|
2989
|
+
},
|
|
2990
|
+
};
|
|
2991
|
+
var modifierNames2 = Object.keys(styles3.modifier);
|
|
2992
|
+
var foregroundColorNames2 = Object.keys(styles3.color);
|
|
2993
|
+
var backgroundColorNames2 = Object.keys(styles3.bgColor);
|
|
2994
|
+
var colorNames2 = [...foregroundColorNames2, ...backgroundColorNames2];
|
|
2995
|
+
function assembleStyles2() {
|
|
2996
|
+
const codes = new Map();
|
|
2997
|
+
for (const [groupName, group] of Object.entries(styles3)) {
|
|
2998
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
2999
|
+
styles3[styleName] = {
|
|
3000
|
+
open: `\x1B[${style[0]}m`,
|
|
3001
|
+
close: `\x1B[${style[1]}m`,
|
|
3002
|
+
};
|
|
3003
|
+
group[styleName] = styles3[styleName];
|
|
3004
|
+
codes.set(style[0], style[1]);
|
|
3005
|
+
}
|
|
3006
|
+
Object.defineProperty(styles3, groupName, {
|
|
3007
|
+
value: group,
|
|
3008
|
+
enumerable: false,
|
|
3009
|
+
});
|
|
3010
|
+
}
|
|
3011
|
+
Object.defineProperty(styles3, "codes", {
|
|
3012
|
+
value: codes,
|
|
3013
|
+
enumerable: false,
|
|
3014
|
+
});
|
|
3015
|
+
styles3.color.close = "\x1B[39m";
|
|
3016
|
+
styles3.bgColor.close = "\x1B[49m";
|
|
3017
|
+
styles3.color.ansi = wrapAnsi162();
|
|
3018
|
+
styles3.color.ansi256 = wrapAnsi2562();
|
|
3019
|
+
styles3.color.ansi16m = wrapAnsi16m2();
|
|
3020
|
+
styles3.bgColor.ansi = wrapAnsi162(ANSI_BACKGROUND_OFFSET2);
|
|
3021
|
+
styles3.bgColor.ansi256 = wrapAnsi2562(ANSI_BACKGROUND_OFFSET2);
|
|
3022
|
+
styles3.bgColor.ansi16m = wrapAnsi16m2(ANSI_BACKGROUND_OFFSET2);
|
|
3023
|
+
Object.defineProperties(styles3, {
|
|
3024
|
+
rgbToAnsi256: {
|
|
3025
|
+
value(red, green, blue) {
|
|
3026
|
+
if (red === green && green === blue) {
|
|
3027
|
+
if (red < 8) {
|
|
3028
|
+
return 16;
|
|
3029
|
+
}
|
|
3030
|
+
if (red > 248) {
|
|
3031
|
+
return 231;
|
|
3032
|
+
}
|
|
3033
|
+
return Math.round(((red - 8) / 247) * 24) + 232;
|
|
3034
|
+
}
|
|
3035
|
+
return (
|
|
3036
|
+
16 +
|
|
3037
|
+
36 * Math.round((red / 255) * 5) +
|
|
3038
|
+
6 * Math.round((green / 255) * 5) +
|
|
3039
|
+
Math.round((blue / 255) * 5)
|
|
3040
|
+
);
|
|
3041
|
+
},
|
|
3042
|
+
enumerable: false,
|
|
3043
|
+
},
|
|
3044
|
+
hexToRgb: {
|
|
3045
|
+
value(hex) {
|
|
3046
|
+
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
3047
|
+
if (!matches) {
|
|
3048
|
+
return [0, 0, 0];
|
|
3049
|
+
}
|
|
3050
|
+
let [colorString] = matches;
|
|
3051
|
+
if (colorString.length === 3) {
|
|
3052
|
+
colorString = [...colorString]
|
|
3053
|
+
.map((character) => character + character)
|
|
3054
|
+
.join("");
|
|
3055
|
+
}
|
|
3056
|
+
const integer = Number.parseInt(colorString, 16);
|
|
3057
|
+
return [
|
|
3058
|
+
(integer >> 16) & 255,
|
|
3059
|
+
(integer >> 8) & 255,
|
|
3060
|
+
integer & 255,
|
|
3061
|
+
];
|
|
3062
|
+
},
|
|
3063
|
+
enumerable: false,
|
|
3064
|
+
},
|
|
3065
|
+
hexToAnsi256: {
|
|
3066
|
+
value: (hex) => styles3.rgbToAnsi256(...styles3.hexToRgb(hex)),
|
|
3067
|
+
enumerable: false,
|
|
3068
|
+
},
|
|
3069
|
+
ansi256ToAnsi: {
|
|
3070
|
+
value(code) {
|
|
3071
|
+
if (code < 8) {
|
|
3072
|
+
return 30 + code;
|
|
3073
|
+
}
|
|
3074
|
+
if (code < 16) {
|
|
3075
|
+
return 90 + (code - 8);
|
|
3076
|
+
}
|
|
3077
|
+
let red;
|
|
3078
|
+
let green;
|
|
3079
|
+
let blue;
|
|
3080
|
+
if (code >= 232) {
|
|
3081
|
+
red = ((code - 232) * 10 + 8) / 255;
|
|
3082
|
+
green = red;
|
|
3083
|
+
blue = red;
|
|
3084
|
+
} else {
|
|
3085
|
+
code -= 16;
|
|
3086
|
+
const remainder = code % 36;
|
|
3087
|
+
red = Math.floor(code / 36) / 5;
|
|
3088
|
+
green = Math.floor(remainder / 6) / 5;
|
|
3089
|
+
blue = (remainder % 6) / 5;
|
|
3090
|
+
}
|
|
3091
|
+
const value = Math.max(red, green, blue) * 2;
|
|
3092
|
+
if (value === 0) {
|
|
3093
|
+
return 30;
|
|
3094
|
+
}
|
|
3095
|
+
let result =
|
|
3096
|
+
30 +
|
|
3097
|
+
((Math.round(blue) << 2) |
|
|
3098
|
+
(Math.round(green) << 1) |
|
|
3099
|
+
Math.round(red));
|
|
3100
|
+
if (value === 2) {
|
|
3101
|
+
result += 60;
|
|
3102
|
+
}
|
|
3103
|
+
return result;
|
|
3104
|
+
},
|
|
3105
|
+
enumerable: false,
|
|
3106
|
+
},
|
|
3107
|
+
rgbToAnsi: {
|
|
3108
|
+
value: (red, green, blue) =>
|
|
3109
|
+
styles3.ansi256ToAnsi(styles3.rgbToAnsi256(red, green, blue)),
|
|
3110
|
+
enumerable: false,
|
|
3111
|
+
},
|
|
3112
|
+
hexToAnsi: {
|
|
3113
|
+
value: (hex) => styles3.ansi256ToAnsi(styles3.hexToAnsi256(hex)),
|
|
3114
|
+
enumerable: false,
|
|
3115
|
+
},
|
|
3116
|
+
});
|
|
3117
|
+
return styles3;
|
|
3118
|
+
}
|
|
3119
|
+
var ansiStyles2 = assembleStyles2();
|
|
3120
|
+
var ansi_styles_default2 = ansiStyles2;
|
|
3121
|
+
|
|
3122
|
+
// node_modules/wrap-ansi/index.js
|
|
3123
|
+
var ESCAPES = new Set(["\x1B", ""]);
|
|
3124
|
+
var END_CODE = 39;
|
|
3125
|
+
var ANSI_ESCAPE_BELL = "\x07";
|
|
3126
|
+
var ANSI_CSI = "[";
|
|
3127
|
+
var ANSI_OSC = "]";
|
|
3128
|
+
var ANSI_SGR_TERMINATOR = "m";
|
|
3129
|
+
var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
3130
|
+
var wrapAnsiCode = (code) =>
|
|
3131
|
+
`${ESCAPES.values().next().value}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
3132
|
+
var wrapAnsiHyperlink = (url) =>
|
|
3133
|
+
`${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
3134
|
+
var wordLengths = (string) =>
|
|
3135
|
+
string.split(" ").map((character) => stringWidth(character));
|
|
3136
|
+
var wrapWord = (rows, word, columns) => {
|
|
3137
|
+
const characters = [...word];
|
|
3138
|
+
let isInsideEscape = false;
|
|
3139
|
+
let isInsideLinkEscape = false;
|
|
3140
|
+
let visible = stringWidth(stripAnsi(rows.at(-1)));
|
|
3141
|
+
for (const [index, character] of characters.entries()) {
|
|
3142
|
+
const characterLength = stringWidth(character);
|
|
3143
|
+
if (visible + characterLength <= columns) {
|
|
3144
|
+
rows[rows.length - 1] += character;
|
|
3145
|
+
} else {
|
|
3146
|
+
rows.push(character);
|
|
3147
|
+
visible = 0;
|
|
3148
|
+
}
|
|
3149
|
+
if (ESCAPES.has(character)) {
|
|
3150
|
+
isInsideEscape = true;
|
|
3151
|
+
const ansiEscapeLinkCandidate = characters
|
|
3152
|
+
.slice(index + 1, index + 1 + ANSI_ESCAPE_LINK.length)
|
|
3153
|
+
.join("");
|
|
3154
|
+
isInsideLinkEscape = ansiEscapeLinkCandidate === ANSI_ESCAPE_LINK;
|
|
3155
|
+
}
|
|
3156
|
+
if (isInsideEscape) {
|
|
3157
|
+
if (isInsideLinkEscape) {
|
|
3158
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
3159
|
+
isInsideEscape = false;
|
|
3160
|
+
isInsideLinkEscape = false;
|
|
3161
|
+
}
|
|
3162
|
+
} else if (character === ANSI_SGR_TERMINATOR) {
|
|
3163
|
+
isInsideEscape = false;
|
|
3164
|
+
}
|
|
3165
|
+
continue;
|
|
3166
|
+
}
|
|
3167
|
+
visible += characterLength;
|
|
3168
|
+
if (visible === columns && index < characters.length - 1) {
|
|
3169
|
+
rows.push("");
|
|
3170
|
+
visible = 0;
|
|
3171
|
+
}
|
|
3172
|
+
}
|
|
3173
|
+
if (!visible && rows.at(-1).length > 0 && rows.length > 1) {
|
|
3174
|
+
rows[rows.length - 2] += rows.pop();
|
|
3175
|
+
}
|
|
3176
|
+
};
|
|
3177
|
+
var stringVisibleTrimSpacesRight = (string) => {
|
|
3178
|
+
const words = string.split(" ");
|
|
3179
|
+
let last = words.length;
|
|
3180
|
+
while (last > 0) {
|
|
3181
|
+
if (stringWidth(words[last - 1]) > 0) {
|
|
3182
|
+
break;
|
|
3183
|
+
}
|
|
3184
|
+
last--;
|
|
3185
|
+
}
|
|
3186
|
+
if (last === words.length) {
|
|
3187
|
+
return string;
|
|
3188
|
+
}
|
|
3189
|
+
return words.slice(0, last).join(" ") + words.slice(last).join("");
|
|
3190
|
+
};
|
|
3191
|
+
var exec = (string, columns, options = {}) => {
|
|
3192
|
+
if (options.trim !== false && string.trim() === "") {
|
|
3193
|
+
return "";
|
|
3194
|
+
}
|
|
3195
|
+
let returnValue = "";
|
|
3196
|
+
let escapeCode;
|
|
3197
|
+
let escapeUrl;
|
|
3198
|
+
const lengths = wordLengths(string);
|
|
3199
|
+
let rows = [""];
|
|
3200
|
+
for (const [index, word] of string.split(" ").entries()) {
|
|
3201
|
+
if (options.trim !== false) {
|
|
3202
|
+
rows[rows.length - 1] = rows.at(-1).trimStart();
|
|
3203
|
+
}
|
|
3204
|
+
let rowLength = stringWidth(rows.at(-1));
|
|
3205
|
+
if (index !== 0) {
|
|
3206
|
+
if (
|
|
3207
|
+
rowLength >= columns &&
|
|
3208
|
+
(options.wordWrap === false || options.trim === false)
|
|
3209
|
+
) {
|
|
3210
|
+
rows.push("");
|
|
3211
|
+
rowLength = 0;
|
|
3212
|
+
}
|
|
3213
|
+
if (rowLength > 0 || options.trim === false) {
|
|
3214
|
+
rows[rows.length - 1] += " ";
|
|
3215
|
+
rowLength++;
|
|
3216
|
+
}
|
|
3217
|
+
}
|
|
3218
|
+
if (options.hard && lengths[index] > columns) {
|
|
3219
|
+
const remainingColumns = columns - rowLength;
|
|
3220
|
+
const breaksStartingThisLine =
|
|
3221
|
+
1 +
|
|
3222
|
+
Math.floor((lengths[index] - remainingColumns - 1) / columns);
|
|
3223
|
+
const breaksStartingNextLine = Math.floor(
|
|
3224
|
+
(lengths[index] - 1) / columns,
|
|
3225
|
+
);
|
|
3226
|
+
if (breaksStartingNextLine < breaksStartingThisLine) {
|
|
3227
|
+
rows.push("");
|
|
3228
|
+
}
|
|
3229
|
+
wrapWord(rows, word, columns);
|
|
3230
|
+
continue;
|
|
3231
|
+
}
|
|
3232
|
+
if (
|
|
3233
|
+
rowLength + lengths[index] > columns &&
|
|
3234
|
+
rowLength > 0 &&
|
|
3235
|
+
lengths[index] > 0
|
|
3236
|
+
) {
|
|
3237
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
3238
|
+
wrapWord(rows, word, columns);
|
|
3239
|
+
continue;
|
|
3240
|
+
}
|
|
3241
|
+
rows.push("");
|
|
3242
|
+
}
|
|
3243
|
+
if (
|
|
3244
|
+
rowLength + lengths[index] > columns &&
|
|
3245
|
+
options.wordWrap === false
|
|
3246
|
+
) {
|
|
3247
|
+
wrapWord(rows, word, columns);
|
|
3248
|
+
continue;
|
|
3249
|
+
}
|
|
3250
|
+
rows[rows.length - 1] += word;
|
|
3251
|
+
}
|
|
3252
|
+
if (options.trim !== false) {
|
|
3253
|
+
rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
3254
|
+
}
|
|
3255
|
+
const preString = rows.join(`
|
|
3256
|
+
`);
|
|
3257
|
+
const pre = [...preString];
|
|
3258
|
+
let preStringIndex = 0;
|
|
3259
|
+
for (const [index, character] of pre.entries()) {
|
|
3260
|
+
returnValue += character;
|
|
3261
|
+
if (ESCAPES.has(character)) {
|
|
3262
|
+
const { groups } = new RegExp(
|
|
3263
|
+
`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`,
|
|
3264
|
+
).exec(preString.slice(preStringIndex)) || { groups: {} };
|
|
3265
|
+
if (groups.code !== undefined) {
|
|
3266
|
+
const code2 = Number.parseFloat(groups.code);
|
|
3267
|
+
escapeCode = code2 === END_CODE ? undefined : code2;
|
|
3268
|
+
} else if (groups.uri !== undefined) {
|
|
3269
|
+
escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3272
|
+
const code = ansi_styles_default2.codes.get(Number(escapeCode));
|
|
3273
|
+
if (
|
|
3274
|
+
pre[index + 1] ===
|
|
3275
|
+
`
|
|
3276
|
+
`
|
|
3277
|
+
) {
|
|
3278
|
+
if (escapeUrl) {
|
|
3279
|
+
returnValue += wrapAnsiHyperlink("");
|
|
3280
|
+
}
|
|
3281
|
+
if (escapeCode && code) {
|
|
3282
|
+
returnValue += wrapAnsiCode(code);
|
|
3283
|
+
}
|
|
3284
|
+
} else if (
|
|
3285
|
+
character ===
|
|
3286
|
+
`
|
|
3287
|
+
`
|
|
3288
|
+
) {
|
|
3289
|
+
if (escapeCode && code) {
|
|
3290
|
+
returnValue += wrapAnsiCode(escapeCode);
|
|
3291
|
+
}
|
|
3292
|
+
if (escapeUrl) {
|
|
3293
|
+
returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
3294
|
+
}
|
|
3295
|
+
}
|
|
3296
|
+
preStringIndex += character.length;
|
|
3297
|
+
}
|
|
3298
|
+
return returnValue;
|
|
3299
|
+
};
|
|
3300
|
+
function wrapAnsi(string, columns, options) {
|
|
3301
|
+
return String(string)
|
|
3302
|
+
.normalize()
|
|
3303
|
+
.replaceAll(
|
|
3304
|
+
`\r
|
|
3305
|
+
`,
|
|
3306
|
+
`
|
|
3307
|
+
`,
|
|
3308
|
+
)
|
|
3309
|
+
.split(
|
|
3310
|
+
`
|
|
3311
|
+
`,
|
|
3312
|
+
)
|
|
3313
|
+
.map((line) => exec(line, columns, options)).join(`
|
|
3314
|
+
`);
|
|
3315
|
+
}
|
|
3316
|
+
|
|
3317
|
+
// node_modules/boxen/index.js
|
|
3318
|
+
var import_cli_boxes2 = __toESM(require_cli_boxes(), 1);
|
|
3319
|
+
var NEWLINE = `
|
|
3320
|
+
`;
|
|
3321
|
+
var PAD = " ";
|
|
3322
|
+
var NONE = "none";
|
|
3323
|
+
var terminalColumns = () => {
|
|
3324
|
+
const { env: env2, stdout, stderr } = process3;
|
|
3325
|
+
if (stdout?.columns) {
|
|
3326
|
+
return stdout.columns;
|
|
3327
|
+
}
|
|
3328
|
+
if (stderr?.columns) {
|
|
3329
|
+
return stderr.columns;
|
|
3330
|
+
}
|
|
3331
|
+
if (env2.COLUMNS) {
|
|
3332
|
+
return Number.parseInt(env2.COLUMNS, 10);
|
|
3333
|
+
}
|
|
3334
|
+
return 80;
|
|
3335
|
+
};
|
|
3336
|
+
var getObject = (detail) =>
|
|
3337
|
+
typeof detail === "number"
|
|
3338
|
+
? {
|
|
3339
|
+
top: detail,
|
|
3340
|
+
right: detail * 3,
|
|
3341
|
+
bottom: detail,
|
|
3342
|
+
left: detail * 3,
|
|
3343
|
+
}
|
|
3344
|
+
: {
|
|
3345
|
+
top: 0,
|
|
3346
|
+
right: 0,
|
|
3347
|
+
bottom: 0,
|
|
3348
|
+
left: 0,
|
|
3349
|
+
...detail,
|
|
3350
|
+
};
|
|
3351
|
+
var getBorderWidth = (borderStyle) => (borderStyle === NONE ? 0 : 2);
|
|
3352
|
+
var getBorderChars = (borderStyle) => {
|
|
3353
|
+
const sides = [
|
|
3354
|
+
"topLeft",
|
|
3355
|
+
"topRight",
|
|
3356
|
+
"bottomRight",
|
|
3357
|
+
"bottomLeft",
|
|
3358
|
+
"left",
|
|
3359
|
+
"right",
|
|
3360
|
+
"top",
|
|
3361
|
+
"bottom",
|
|
3362
|
+
];
|
|
3363
|
+
let characters;
|
|
3364
|
+
if (borderStyle === NONE) {
|
|
3365
|
+
borderStyle = {};
|
|
3366
|
+
for (const side of sides) {
|
|
3367
|
+
borderStyle[side] = "";
|
|
3368
|
+
}
|
|
3369
|
+
}
|
|
3370
|
+
if (typeof borderStyle === "string") {
|
|
3371
|
+
characters = import_cli_boxes.default[borderStyle];
|
|
3372
|
+
if (!characters) {
|
|
3373
|
+
throw new TypeError(`Invalid border style: ${borderStyle}`);
|
|
3374
|
+
}
|
|
3375
|
+
} else {
|
|
3376
|
+
if (typeof borderStyle?.vertical === "string") {
|
|
3377
|
+
borderStyle.left = borderStyle.vertical;
|
|
3378
|
+
borderStyle.right = borderStyle.vertical;
|
|
3379
|
+
}
|
|
3380
|
+
if (typeof borderStyle?.horizontal === "string") {
|
|
3381
|
+
borderStyle.top = borderStyle.horizontal;
|
|
3382
|
+
borderStyle.bottom = borderStyle.horizontal;
|
|
3383
|
+
}
|
|
3384
|
+
for (const side of sides) {
|
|
3385
|
+
if (
|
|
3386
|
+
borderStyle[side] === null ||
|
|
3387
|
+
typeof borderStyle[side] !== "string"
|
|
3388
|
+
) {
|
|
3389
|
+
throw new TypeError(`Invalid border style: ${side}`);
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
characters = borderStyle;
|
|
3393
|
+
}
|
|
3394
|
+
return characters;
|
|
3395
|
+
};
|
|
3396
|
+
var makeTitle = (text, horizontal, alignment) => {
|
|
3397
|
+
let title = "";
|
|
3398
|
+
const textWidth = stringWidth(text);
|
|
3399
|
+
switch (alignment) {
|
|
3400
|
+
case "left": {
|
|
3401
|
+
title = text + horizontal.slice(textWidth);
|
|
3402
|
+
break;
|
|
3403
|
+
}
|
|
3404
|
+
case "right": {
|
|
3405
|
+
title = horizontal.slice(textWidth) + text;
|
|
3406
|
+
break;
|
|
3407
|
+
}
|
|
3408
|
+
default: {
|
|
3409
|
+
horizontal = horizontal.slice(textWidth);
|
|
3410
|
+
if (horizontal.length % 2 === 1) {
|
|
3411
|
+
horizontal = horizontal.slice(
|
|
3412
|
+
Math.floor(horizontal.length / 2),
|
|
3413
|
+
);
|
|
3414
|
+
title = horizontal.slice(1) + text + horizontal;
|
|
3415
|
+
} else {
|
|
3416
|
+
horizontal = horizontal.slice(horizontal.length / 2);
|
|
3417
|
+
title = horizontal + text + horizontal;
|
|
3418
|
+
}
|
|
3419
|
+
break;
|
|
3420
|
+
}
|
|
3421
|
+
}
|
|
3422
|
+
return title;
|
|
3423
|
+
};
|
|
3424
|
+
var makeContentText = (text, { padding, width, textAlignment, height }) => {
|
|
3425
|
+
text = import_ansi_align.default(text, { align: textAlignment });
|
|
3426
|
+
let lines = text.split(NEWLINE);
|
|
3427
|
+
const textWidth = widestLine(text);
|
|
3428
|
+
const max = width - padding.left - padding.right;
|
|
3429
|
+
if (textWidth > max) {
|
|
3430
|
+
const newLines = [];
|
|
3431
|
+
for (const line of lines) {
|
|
3432
|
+
const createdLines = wrapAnsi(line, max, { hard: true });
|
|
3433
|
+
const alignedLines = import_ansi_align.default(createdLines, {
|
|
3434
|
+
align: textAlignment,
|
|
3435
|
+
});
|
|
3436
|
+
const alignedLinesArray = alignedLines.split(`
|
|
3437
|
+
`);
|
|
3438
|
+
const longestLength = Math.max(
|
|
3439
|
+
...alignedLinesArray.map((s) => stringWidth(s)),
|
|
3440
|
+
);
|
|
3441
|
+
for (const alignedLine of alignedLinesArray) {
|
|
3442
|
+
let paddedLine;
|
|
3443
|
+
switch (textAlignment) {
|
|
3444
|
+
case "center": {
|
|
3445
|
+
paddedLine =
|
|
3446
|
+
PAD.repeat((max - longestLength) / 2) + alignedLine;
|
|
3447
|
+
break;
|
|
3448
|
+
}
|
|
3449
|
+
case "right": {
|
|
3450
|
+
paddedLine =
|
|
3451
|
+
PAD.repeat(max - longestLength) + alignedLine;
|
|
3452
|
+
break;
|
|
3453
|
+
}
|
|
3454
|
+
default: {
|
|
3455
|
+
paddedLine = alignedLine;
|
|
3456
|
+
break;
|
|
3457
|
+
}
|
|
3458
|
+
}
|
|
3459
|
+
newLines.push(paddedLine);
|
|
3460
|
+
}
|
|
3461
|
+
}
|
|
3462
|
+
lines = newLines;
|
|
3463
|
+
}
|
|
3464
|
+
if (textAlignment === "center" && textWidth < max) {
|
|
3465
|
+
lines = lines.map((line) => PAD.repeat((max - textWidth) / 2) + line);
|
|
3466
|
+
} else if (textAlignment === "right" && textWidth < max) {
|
|
3467
|
+
lines = lines.map((line) => PAD.repeat(max - textWidth) + line);
|
|
3468
|
+
}
|
|
3469
|
+
const paddingLeft = PAD.repeat(padding.left);
|
|
3470
|
+
const paddingRight = PAD.repeat(padding.right);
|
|
3471
|
+
lines = lines.map((line) => {
|
|
3472
|
+
const newLine = paddingLeft + line + paddingRight;
|
|
3473
|
+
return newLine + PAD.repeat(width - stringWidth(newLine));
|
|
3474
|
+
});
|
|
3475
|
+
if (padding.top > 0) {
|
|
3476
|
+
lines = [
|
|
3477
|
+
...Array.from({ length: padding.top }).fill(PAD.repeat(width)),
|
|
3478
|
+
...lines,
|
|
3479
|
+
];
|
|
3480
|
+
}
|
|
3481
|
+
if (padding.bottom > 0) {
|
|
3482
|
+
lines = [
|
|
3483
|
+
...lines,
|
|
3484
|
+
...Array.from({ length: padding.bottom }).fill(PAD.repeat(width)),
|
|
3485
|
+
];
|
|
3486
|
+
}
|
|
3487
|
+
if (height && lines.length > height) {
|
|
3488
|
+
lines = lines.slice(0, height);
|
|
3489
|
+
} else if (height && lines.length < height) {
|
|
3490
|
+
lines = [
|
|
3491
|
+
...lines,
|
|
3492
|
+
...Array.from({ length: height - lines.length }).fill(
|
|
3493
|
+
PAD.repeat(width),
|
|
3494
|
+
),
|
|
3495
|
+
];
|
|
3496
|
+
}
|
|
3497
|
+
return lines.join(NEWLINE);
|
|
3498
|
+
};
|
|
3499
|
+
var boxContent = (content, contentWidth, options) => {
|
|
3500
|
+
const colorizeBorder = (border) => {
|
|
3501
|
+
const newBorder = options.borderColor
|
|
3502
|
+
? getColorFunction(options.borderColor)(border)
|
|
3503
|
+
: border;
|
|
3504
|
+
return options.dimBorder ? source_default.dim(newBorder) : newBorder;
|
|
3505
|
+
};
|
|
3506
|
+
const colorizeContent = (content2) =>
|
|
3507
|
+
options.backgroundColor
|
|
3508
|
+
? getBGColorFunction(options.backgroundColor)(content2)
|
|
3509
|
+
: content2;
|
|
3510
|
+
const chars = getBorderChars(options.borderStyle);
|
|
3511
|
+
const columns = terminalColumns();
|
|
3512
|
+
let marginLeft = PAD.repeat(options.margin.left);
|
|
3513
|
+
if (options.float === "center") {
|
|
3514
|
+
const marginWidth = Math.max(
|
|
3515
|
+
(columns - contentWidth - getBorderWidth(options.borderStyle)) / 2,
|
|
3516
|
+
0,
|
|
3517
|
+
);
|
|
3518
|
+
marginLeft = PAD.repeat(marginWidth);
|
|
3519
|
+
} else if (options.float === "right") {
|
|
3520
|
+
const marginWidth = Math.max(
|
|
3521
|
+
columns -
|
|
3522
|
+
contentWidth -
|
|
3523
|
+
options.margin.right -
|
|
3524
|
+
getBorderWidth(options.borderStyle),
|
|
3525
|
+
0,
|
|
3526
|
+
);
|
|
3527
|
+
marginLeft = PAD.repeat(marginWidth);
|
|
3528
|
+
}
|
|
3529
|
+
let result = "";
|
|
3530
|
+
if (options.margin.top) {
|
|
3531
|
+
result += NEWLINE.repeat(options.margin.top);
|
|
3532
|
+
}
|
|
3533
|
+
if (options.borderStyle !== NONE || options.title) {
|
|
3534
|
+
result +=
|
|
3535
|
+
colorizeBorder(
|
|
3536
|
+
marginLeft +
|
|
3537
|
+
chars.topLeft +
|
|
3538
|
+
(options.title
|
|
3539
|
+
? makeTitle(
|
|
3540
|
+
options.title,
|
|
3541
|
+
chars.top.repeat(contentWidth),
|
|
3542
|
+
options.titleAlignment,
|
|
3543
|
+
)
|
|
3544
|
+
: chars.top.repeat(contentWidth)) +
|
|
3545
|
+
chars.topRight,
|
|
3546
|
+
) + NEWLINE;
|
|
3547
|
+
}
|
|
3548
|
+
const lines = content.split(NEWLINE);
|
|
3549
|
+
result += lines
|
|
3550
|
+
.map(
|
|
3551
|
+
(line) =>
|
|
3552
|
+
marginLeft +
|
|
3553
|
+
colorizeBorder(chars.left) +
|
|
3554
|
+
colorizeContent(line) +
|
|
3555
|
+
colorizeBorder(chars.right),
|
|
3556
|
+
)
|
|
3557
|
+
.join(NEWLINE);
|
|
3558
|
+
if (options.borderStyle !== NONE) {
|
|
3559
|
+
result +=
|
|
3560
|
+
NEWLINE +
|
|
3561
|
+
colorizeBorder(
|
|
3562
|
+
marginLeft +
|
|
3563
|
+
chars.bottomLeft +
|
|
3564
|
+
chars.bottom.repeat(contentWidth) +
|
|
3565
|
+
chars.bottomRight,
|
|
3566
|
+
);
|
|
3567
|
+
}
|
|
3568
|
+
if (options.margin.bottom) {
|
|
3569
|
+
result += NEWLINE.repeat(options.margin.bottom);
|
|
3570
|
+
}
|
|
3571
|
+
return result;
|
|
3572
|
+
};
|
|
3573
|
+
var sanitizeOptions = (options) => {
|
|
3574
|
+
if (options.fullscreen && process3?.stdout) {
|
|
3575
|
+
let newDimensions = [process3.stdout.columns, process3.stdout.rows];
|
|
3576
|
+
if (typeof options.fullscreen === "function") {
|
|
3577
|
+
newDimensions = options.fullscreen(...newDimensions);
|
|
3578
|
+
}
|
|
3579
|
+
options.width ||= newDimensions[0];
|
|
3580
|
+
options.height ||= newDimensions[1];
|
|
3581
|
+
}
|
|
3582
|
+
options.width &&= Math.max(
|
|
3583
|
+
1,
|
|
3584
|
+
options.width - getBorderWidth(options.borderStyle),
|
|
3585
|
+
);
|
|
3586
|
+
options.height &&= Math.max(
|
|
3587
|
+
1,
|
|
3588
|
+
options.height - getBorderWidth(options.borderStyle),
|
|
3589
|
+
);
|
|
3590
|
+
return options;
|
|
3591
|
+
};
|
|
3592
|
+
var formatTitle = (title, borderStyle) =>
|
|
3593
|
+
borderStyle === NONE ? title : ` ${title} `;
|
|
3594
|
+
var determineDimensions = (text, options) => {
|
|
3595
|
+
options = sanitizeOptions(options);
|
|
3596
|
+
const widthOverride = options.width !== undefined;
|
|
3597
|
+
const columns = terminalColumns();
|
|
3598
|
+
const borderWidth = getBorderWidth(options.borderStyle);
|
|
3599
|
+
const maxWidth =
|
|
3600
|
+
columns - options.margin.left - options.margin.right - borderWidth;
|
|
3601
|
+
const widest =
|
|
3602
|
+
widestLine(
|
|
3603
|
+
wrapAnsi(text, columns - borderWidth, { hard: true, trim: false }),
|
|
3604
|
+
) +
|
|
3605
|
+
options.padding.left +
|
|
3606
|
+
options.padding.right;
|
|
3607
|
+
if (options.title && widthOverride) {
|
|
3608
|
+
options.title = options.title.slice(0, Math.max(0, options.width - 2));
|
|
3609
|
+
options.title &&= formatTitle(options.title, options.borderStyle);
|
|
3610
|
+
} else if (options.title) {
|
|
3611
|
+
options.title = options.title.slice(0, Math.max(0, maxWidth - 2));
|
|
3612
|
+
if (options.title) {
|
|
3613
|
+
options.title = formatTitle(options.title, options.borderStyle);
|
|
3614
|
+
if (stringWidth(options.title) > widest) {
|
|
3615
|
+
options.width = stringWidth(options.title);
|
|
3616
|
+
}
|
|
3617
|
+
}
|
|
3618
|
+
}
|
|
3619
|
+
options.width ||= widest;
|
|
3620
|
+
if (!widthOverride) {
|
|
3621
|
+
if (
|
|
3622
|
+
options.margin.left &&
|
|
3623
|
+
options.margin.right &&
|
|
3624
|
+
options.width > maxWidth
|
|
3625
|
+
) {
|
|
3626
|
+
const spaceForMargins = columns - options.width - borderWidth;
|
|
3627
|
+
const multiplier =
|
|
3628
|
+
spaceForMargins / (options.margin.left + options.margin.right);
|
|
3629
|
+
options.margin.left = Math.max(
|
|
3630
|
+
0,
|
|
3631
|
+
Math.floor(options.margin.left * multiplier),
|
|
3632
|
+
);
|
|
3633
|
+
options.margin.right = Math.max(
|
|
3634
|
+
0,
|
|
3635
|
+
Math.floor(options.margin.right * multiplier),
|
|
3636
|
+
);
|
|
3637
|
+
}
|
|
3638
|
+
options.width = Math.min(
|
|
3639
|
+
options.width,
|
|
3640
|
+
columns - borderWidth - options.margin.left - options.margin.right,
|
|
3641
|
+
);
|
|
3642
|
+
}
|
|
3643
|
+
if (options.width - (options.padding.left + options.padding.right) <= 0) {
|
|
3644
|
+
options.padding.left = 0;
|
|
3645
|
+
options.padding.right = 0;
|
|
3646
|
+
}
|
|
3647
|
+
if (
|
|
3648
|
+
options.height &&
|
|
3649
|
+
options.height - (options.padding.top + options.padding.bottom) <= 0
|
|
3650
|
+
) {
|
|
3651
|
+
options.padding.top = 0;
|
|
3652
|
+
options.padding.bottom = 0;
|
|
3653
|
+
}
|
|
3654
|
+
return options;
|
|
3655
|
+
};
|
|
3656
|
+
var isHex = (color) => color.match(/^#(?:[0-f]{3}){1,2}$/i);
|
|
3657
|
+
var isColorValid = (color) =>
|
|
3658
|
+
typeof color === "string" && (source_default[color] ?? isHex(color));
|
|
3659
|
+
var getColorFunction = (color) =>
|
|
3660
|
+
isHex(color) ? source_default.hex(color) : source_default[color];
|
|
3661
|
+
var getBGColorFunction = (color) =>
|
|
3662
|
+
isHex(color)
|
|
3663
|
+
? source_default.bgHex(color)
|
|
3664
|
+
: source_default[camelCase(["bg", color])];
|
|
3665
|
+
function boxen(text, options) {
|
|
3666
|
+
options = {
|
|
3667
|
+
padding: 0,
|
|
3668
|
+
borderStyle: "single",
|
|
3669
|
+
dimBorder: false,
|
|
3670
|
+
textAlignment: "left",
|
|
3671
|
+
float: "left",
|
|
3672
|
+
titleAlignment: "left",
|
|
3673
|
+
...options,
|
|
3674
|
+
};
|
|
3675
|
+
if (options.align) {
|
|
3676
|
+
options.textAlignment = options.align;
|
|
3677
|
+
}
|
|
3678
|
+
if (options.borderColor && !isColorValid(options.borderColor)) {
|
|
3679
|
+
throw new Error(`${options.borderColor} is not a valid borderColor`);
|
|
3680
|
+
}
|
|
3681
|
+
if (options.backgroundColor && !isColorValid(options.backgroundColor)) {
|
|
3682
|
+
throw new Error(
|
|
3683
|
+
`${options.backgroundColor} is not a valid backgroundColor`,
|
|
3684
|
+
);
|
|
3685
|
+
}
|
|
3686
|
+
options.padding = getObject(options.padding);
|
|
3687
|
+
options.margin = getObject(options.margin);
|
|
3688
|
+
options = determineDimensions(text, options);
|
|
3689
|
+
text = makeContentText(text, options);
|
|
3690
|
+
return boxContent(text, options.width, options);
|
|
3691
|
+
}
|
|
3692
|
+
|
|
3693
|
+
// src/commands/init.ts
|
|
3694
|
+
var primary = source_default.hex("#7dd3fc");
|
|
3695
|
+
var secondary = source_default.hex("#e5e7eb");
|
|
3696
|
+
var muted = source_default.hex("#94a3b8");
|
|
3697
|
+
function init() {
|
|
3698
|
+
let grootFolderPath = path2.join(process.cwd(), ".groot");
|
|
3699
|
+
let grootIgnoreFolderPath = path2.join(process.cwd(), ".grootignore");
|
|
3700
|
+
if (
|
|
3701
|
+
fs2.existsSync(grootFolderPath) &&
|
|
3702
|
+
fs2.existsSync(grootIgnoreFolderPath)
|
|
3703
|
+
) {
|
|
3704
|
+
console.log("Already Initialized an empty groot repository!");
|
|
3705
|
+
} else {
|
|
3706
|
+
fs2.mkdirSync(grootFolderPath);
|
|
3707
|
+
fs2.mkdirSync(path2.join(grootFolderPath, "objects"));
|
|
3708
|
+
fs2.mkdirSync(path2.join(grootFolderPath, "commits"));
|
|
3709
|
+
fs2.writeFileSync(path2.join(grootFolderPath, "index.json"), "{}");
|
|
3710
|
+
fs2.writeFileSync(path2.join(grootFolderPath, "HEAD.json"), "null");
|
|
3711
|
+
fs2.writeFileSync(
|
|
3712
|
+
path2.join(grootIgnoreFolderPath),
|
|
3713
|
+
`node_modules
|
|
3714
|
+
.git
|
|
3715
|
+
.gitignore
|
|
3716
|
+
.groot
|
|
3717
|
+
.grootignore`,
|
|
3718
|
+
);
|
|
3719
|
+
const title = nodeFiglet.textSync("GROOT", {
|
|
3720
|
+
font: "ANSI Shadow",
|
|
3721
|
+
horizontalLayout: "default",
|
|
3722
|
+
});
|
|
3723
|
+
console.log(`
|
|
3724
|
+
`);
|
|
3725
|
+
console.log(primary(title));
|
|
3726
|
+
console.log(
|
|
3727
|
+
boxen(secondary.bold(" Welcome to Groot VCS "), {
|
|
3728
|
+
padding: { top: 1, bottom: 1, left: 3, right: 3 },
|
|
3729
|
+
borderStyle: "round",
|
|
3730
|
+
borderColor: "#7dd3fc",
|
|
3731
|
+
}),
|
|
3732
|
+
);
|
|
3733
|
+
console.log(secondary("\uD83D\uDCC1 Repo: ") + muted(process.cwd()));
|
|
3734
|
+
console.log(primary("✨ Repo initialized successfully"));
|
|
3735
|
+
console.log(`
|
|
3736
|
+
`);
|
|
3737
|
+
}
|
|
3738
|
+
}
|
|
3739
|
+
|
|
3740
|
+
// src/commands/add.ts
|
|
3741
|
+
import fs4 from "fs";
|
|
3742
|
+
import path4 from "path";
|
|
3743
|
+
import crypto from "crypto";
|
|
3744
|
+
|
|
3745
|
+
// src/utils.ts
|
|
3746
|
+
import path3 from "path";
|
|
3747
|
+
import fs3 from "fs";
|
|
3748
|
+
function readGrootIgnore() {
|
|
3749
|
+
let grootIgnoreContent;
|
|
3750
|
+
let grootIgnorePath = path3.join(fetchGrootPath(), ".grootignore");
|
|
3751
|
+
grootIgnoreContent = readFileTryCatch(grootIgnorePath)
|
|
3752
|
+
.split(
|
|
3753
|
+
`
|
|
3754
|
+
`,
|
|
3755
|
+
)
|
|
3756
|
+
.map((eachWord) => eachWord.trim())
|
|
3757
|
+
.filter((eachWord) => eachWord !== "");
|
|
3758
|
+
return grootIgnoreContent;
|
|
3759
|
+
}
|
|
3760
|
+
function fetchGrootPath() {
|
|
3761
|
+
let currentPath = path3.join(process.cwd());
|
|
3762
|
+
while (currentPath != path3.dirname(currentPath)) {
|
|
3763
|
+
if (fs3.existsSync(path3.join(currentPath, ".groot")))
|
|
3764
|
+
return currentPath;
|
|
3765
|
+
currentPath = path3.dirname(currentPath);
|
|
3766
|
+
}
|
|
3767
|
+
console.log(`groot was never initialized, please run groot init`);
|
|
3768
|
+
process.exit(1);
|
|
3769
|
+
}
|
|
3770
|
+
function readFileTryCatch(filePath) {
|
|
3771
|
+
let fileContent = "";
|
|
3772
|
+
let absolutePath = path3.resolve(filePath);
|
|
3773
|
+
try {
|
|
3774
|
+
fileContent = fs3.readFileSync(absolutePath, "utf-8");
|
|
3775
|
+
} catch (e) {
|
|
3776
|
+
console.log(`File doesn't exist at path: ${filePath}`);
|
|
3777
|
+
process.exit(1);
|
|
3778
|
+
}
|
|
3779
|
+
return fileContent;
|
|
3780
|
+
}
|
|
3781
|
+
function fetchIndexJsonPath() {
|
|
3782
|
+
return path3.join(fetchGrootPath(), ".groot", "index.json");
|
|
3783
|
+
}
|
|
3784
|
+
function fetchIndexJsonContent() {
|
|
3785
|
+
return JSON.parse(readFileTryCatch(fetchIndexJsonPath()));
|
|
3786
|
+
}
|
|
3787
|
+
function getHeadCommit() {
|
|
3788
|
+
let grootDirPath = fetchGrootPath();
|
|
3789
|
+
let headJsonPath = path3.join(grootDirPath, ".groot", "HEAD.json");
|
|
3790
|
+
let HEAD = JSON.parse(readFileTryCatch(headJsonPath));
|
|
3791
|
+
let headCommitPath = path3.join(
|
|
3792
|
+
grootDirPath,
|
|
3793
|
+
".groot",
|
|
3794
|
+
"commits",
|
|
3795
|
+
`${HEAD}.json`,
|
|
3796
|
+
);
|
|
3797
|
+
return JSON.parse(readFileTryCatch(headCommitPath));
|
|
3798
|
+
}
|
|
3799
|
+
|
|
3800
|
+
// src/commands/add.ts
|
|
3801
|
+
function add(filePath) {
|
|
3802
|
+
let fileContent = readFileTryCatch(filePath);
|
|
3803
|
+
let absolutePath = path4.resolve(filePath);
|
|
3804
|
+
let grootDirPath = fetchGrootPath();
|
|
3805
|
+
const hash = crypto.createHash("sha256").update(fileContent).digest("hex");
|
|
3806
|
+
const objectPath = path4.join(grootDirPath, ".groot", "objects", hash);
|
|
3807
|
+
fs4.writeFileSync(objectPath, fileContent);
|
|
3808
|
+
const indexJsonPath = path4.join(grootDirPath, ".groot", "index.json");
|
|
3809
|
+
const indexJsonFilecontent = JSON.parse(readFileTryCatch(indexJsonPath));
|
|
3810
|
+
let headPath = path4.join(grootDirPath, ".groot", "HEAD.json");
|
|
3811
|
+
let head = JSON.parse(readFileTryCatch(headPath));
|
|
3812
|
+
let allSnapshots;
|
|
3813
|
+
if (head === null) {
|
|
3814
|
+
allSnapshots = {};
|
|
3815
|
+
} else {
|
|
3816
|
+
let headCommit = JSON.parse(
|
|
3817
|
+
readFileTryCatch(
|
|
3818
|
+
path4.join(grootDirPath, ".groot", "commits", head + ".json"),
|
|
3819
|
+
),
|
|
3820
|
+
);
|
|
3821
|
+
allSnapshots = headCommit.snapshot;
|
|
3822
|
+
}
|
|
3823
|
+
if (allSnapshots[absolutePath] === hash) {
|
|
3824
|
+
console.log("nothing to stage, file unchanged");
|
|
3825
|
+
} else {
|
|
3826
|
+
indexJsonFilecontent[absolutePath] = hash;
|
|
3827
|
+
fs4.writeFileSync(
|
|
3828
|
+
indexJsonPath,
|
|
3829
|
+
JSON.stringify(indexJsonFilecontent, null, 2),
|
|
3830
|
+
);
|
|
3831
|
+
console.log(`Staging area updated successfully.`);
|
|
3832
|
+
}
|
|
3833
|
+
}
|
|
3834
|
+
|
|
3835
|
+
// src/commands/commit.ts
|
|
3836
|
+
import fs5 from "fs";
|
|
3837
|
+
import path5 from "path";
|
|
3838
|
+
import crypto2 from "crypto";
|
|
3839
|
+
function commit(message) {
|
|
3840
|
+
let grootDirPath = fetchGrootPath();
|
|
3841
|
+
let indexJsonPath = path5.join(grootDirPath, ".groot", "index.json");
|
|
3842
|
+
let indexJsonFilecontent = JSON.parse(readFileTryCatch(indexJsonPath));
|
|
3843
|
+
if (Object.keys(indexJsonFilecontent).length === 0) {
|
|
3844
|
+
console.log(`Nothing staged which is pending to be commit`);
|
|
3845
|
+
} else {
|
|
3846
|
+
let headPath = path5.join(grootDirPath, ".groot", "HEAD.json");
|
|
3847
|
+
let head = JSON.parse(readFileTryCatch(headPath));
|
|
3848
|
+
let retrievedRecord;
|
|
3849
|
+
if (head === null) {
|
|
3850
|
+
retrievedRecord = indexJsonFilecontent;
|
|
3851
|
+
} else {
|
|
3852
|
+
let parentCommitPath = path5.join(
|
|
3853
|
+
grootDirPath,
|
|
3854
|
+
".groot",
|
|
3855
|
+
"commits",
|
|
3856
|
+
`${head}.json`,
|
|
3857
|
+
);
|
|
3858
|
+
let parentCommitContent = JSON.parse(
|
|
3859
|
+
readFileTryCatch(parentCommitPath),
|
|
3860
|
+
);
|
|
3861
|
+
let mergedRecords = {
|
|
3862
|
+
...parentCommitContent.snapshot,
|
|
3863
|
+
...indexJsonFilecontent,
|
|
3864
|
+
};
|
|
3865
|
+
retrievedRecord = mergedRecords;
|
|
3866
|
+
}
|
|
3867
|
+
let commitObject = {
|
|
3868
|
+
commitId: "",
|
|
3869
|
+
commitMessage: message,
|
|
3870
|
+
timeStamp: new Date().toISOString(),
|
|
3871
|
+
snapshot: retrievedRecord,
|
|
3872
|
+
parent: head,
|
|
3873
|
+
};
|
|
3874
|
+
let commitIdHash = crypto2
|
|
3875
|
+
.createHash("sha256")
|
|
3876
|
+
.update(JSON.stringify(commitObject))
|
|
3877
|
+
.digest("hex");
|
|
3878
|
+
commitObject.commitId = commitIdHash;
|
|
3879
|
+
let commitFilePath = path5.join(
|
|
3880
|
+
grootDirPath,
|
|
3881
|
+
".groot",
|
|
3882
|
+
"commits",
|
|
3883
|
+
commitIdHash + ".json",
|
|
3884
|
+
);
|
|
3885
|
+
fs5.writeFileSync(
|
|
3886
|
+
commitFilePath,
|
|
3887
|
+
JSON.stringify(commitObject, null, 2),
|
|
3888
|
+
);
|
|
3889
|
+
fs5.writeFileSync(headPath, JSON.stringify(commitIdHash, null, 2));
|
|
3890
|
+
fs5.writeFileSync(indexJsonPath, JSON.stringify({}, null, 2));
|
|
3891
|
+
}
|
|
3892
|
+
}
|
|
3893
|
+
|
|
3894
|
+
// src/commands/log.ts
|
|
3895
|
+
import path6 from "path";
|
|
3896
|
+
function log() {
|
|
3897
|
+
iterateCommits(false);
|
|
3898
|
+
}
|
|
3899
|
+
function logOneline() {
|
|
3900
|
+
iterateCommits(true);
|
|
3901
|
+
}
|
|
3902
|
+
function iterateCommits(oneline) {
|
|
3903
|
+
let grootDirPath = fetchGrootPath();
|
|
3904
|
+
let commitPointer = getHeadPointer(grootDirPath);
|
|
3905
|
+
let headPointer = true;
|
|
3906
|
+
while (commitPointer != null) {
|
|
3907
|
+
let commitPath = path6.join(
|
|
3908
|
+
grootDirPath,
|
|
3909
|
+
".groot",
|
|
3910
|
+
"commits",
|
|
3911
|
+
`${commitPointer}` + ".json",
|
|
3912
|
+
);
|
|
3913
|
+
let commitContent = JSON.parse(readFileTryCatch(commitPath));
|
|
3914
|
+
if (oneline) {
|
|
3915
|
+
printLogOnelineDetails(commitContent, headPointer);
|
|
3916
|
+
} else {
|
|
3917
|
+
printLogDetails(commitContent, headPointer);
|
|
3918
|
+
}
|
|
3919
|
+
headPointer = false;
|
|
3920
|
+
commitPointer = commitContent.parent;
|
|
3921
|
+
}
|
|
3922
|
+
}
|
|
3923
|
+
function getHeadPointer(grootDirPath) {
|
|
3924
|
+
let headJSONPath = path6.join(grootDirPath, ".groot", "HEAD.json");
|
|
3925
|
+
let headContent = JSON.parse(readFileTryCatch(headJSONPath));
|
|
3926
|
+
return headContent;
|
|
3927
|
+
}
|
|
3928
|
+
function printLogDetails(commitContent, headPointer) {
|
|
3929
|
+
if (headPointer) {
|
|
3930
|
+
console.log(
|
|
3931
|
+
`\x1B[38;2;255;247;205mcommit ${commitContent.commitId}\x1B[0m` +
|
|
3932
|
+
`\x1B[38;2;147;233;204m(Head->)\x1B[0m`,
|
|
3933
|
+
);
|
|
3934
|
+
} else {
|
|
3935
|
+
console.log(
|
|
3936
|
+
`\x1B[38;2;255;247;205mcommit ${commitContent.commitId}\x1B[0m`,
|
|
3937
|
+
);
|
|
3938
|
+
}
|
|
3939
|
+
const date = new Date(commitContent.timeStamp);
|
|
3940
|
+
let formattedDate = date.toLocaleDateString(`en-US`, {
|
|
3941
|
+
weekday: "short",
|
|
3942
|
+
month: "short",
|
|
3943
|
+
day: "numeric",
|
|
3944
|
+
});
|
|
3945
|
+
let formattedTime = date.toLocaleTimeString("en-US", {
|
|
3946
|
+
hour: "numeric",
|
|
3947
|
+
minute: "numeric",
|
|
3948
|
+
second: "2-digit",
|
|
3949
|
+
hour12: false,
|
|
3950
|
+
});
|
|
3951
|
+
let fullYear = date.getFullYear().toString();
|
|
3952
|
+
let timeZone = date.getTimezoneOffset();
|
|
3953
|
+
let offSetSign = timeZone < 0 ? "+" : "-";
|
|
3954
|
+
let absTimeZone = Math.abs(timeZone);
|
|
3955
|
+
let actualTimeZone = `${offSetSign}${Math.floor(absTimeZone / 60)
|
|
3956
|
+
.toString()
|
|
3957
|
+
.padStart(2, "0")}:${(absTimeZone % 60).toString().padStart(2, "0")}`;
|
|
3958
|
+
console.log(
|
|
3959
|
+
`\x1B[38;2;211;224;234mDate: ${formattedDate} ${formattedTime} ${fullYear} ${actualTimeZone}\x1B[0m`,
|
|
3960
|
+
);
|
|
3961
|
+
console.log(`
|
|
3962
|
+
\x1B[38;2;152;222;217m${commitContent.commitMessage}\x1B[0m
|
|
3963
|
+
`);
|
|
3964
|
+
}
|
|
3965
|
+
function printLogOnelineDetails(commitContent, headPointer) {
|
|
3966
|
+
let commitId = commitContent.commitId.substring(0, 8);
|
|
3967
|
+
if (headPointer) {
|
|
3968
|
+
console.log(
|
|
3969
|
+
`\x1B[38;2;255;247;205m${commitId}\x1B[0m` +
|
|
3970
|
+
`\x1B[38;2;147;233;204m(Head->)\x1B[0m` +
|
|
3971
|
+
` ${commitContent.commitMessage}`,
|
|
3972
|
+
);
|
|
3973
|
+
} else {
|
|
3974
|
+
console.log(
|
|
3975
|
+
`\x1B[38;2;255;247;205m${commitId}\x1B[0m` +
|
|
3976
|
+
` ${commitContent.commitMessage}`,
|
|
3977
|
+
);
|
|
3978
|
+
}
|
|
3979
|
+
}
|
|
3980
|
+
|
|
3981
|
+
// src/commands/status.ts
|
|
3982
|
+
import path7 from "path";
|
|
3983
|
+
import fs6 from "fs";
|
|
3984
|
+
import crypto3 from "crypto";
|
|
3985
|
+
var stagingArea = [];
|
|
3986
|
+
var modifiedFile = [];
|
|
3987
|
+
var unTrackedFile = [];
|
|
3988
|
+
function status() {
|
|
3989
|
+
stagingArea = [];
|
|
3990
|
+
modifiedFile = [];
|
|
3991
|
+
unTrackedFile = [];
|
|
3992
|
+
let grootIgnoreContentSet = new Set(readGrootIgnore());
|
|
3993
|
+
let indexJsonPath = path7.join(fetchGrootPath(), ".groot", "index.json");
|
|
3994
|
+
let grootFolderPath = fetchGrootPath();
|
|
3995
|
+
let headJsonContent = JSON.parse(
|
|
3996
|
+
readFileTryCatch(path7.join(grootFolderPath, ".groot", `HEAD.json`)),
|
|
3997
|
+
);
|
|
3998
|
+
let allSnapShots = {};
|
|
3999
|
+
if (headJsonContent !== null) {
|
|
4000
|
+
let headCommitContent = JSON.parse(
|
|
4001
|
+
readFileTryCatch(
|
|
4002
|
+
path7.join(
|
|
4003
|
+
grootFolderPath,
|
|
4004
|
+
".groot",
|
|
4005
|
+
"commits",
|
|
4006
|
+
`${headJsonContent}.json`,
|
|
4007
|
+
),
|
|
4008
|
+
),
|
|
4009
|
+
);
|
|
4010
|
+
allSnapShots = headCommitContent.snapshot;
|
|
4011
|
+
}
|
|
4012
|
+
let indexJsonRecord = JSON.parse(readFileTryCatch(indexJsonPath));
|
|
4013
|
+
scanDirectory(
|
|
4014
|
+
grootFolderPath,
|
|
4015
|
+
grootIgnoreContentSet,
|
|
4016
|
+
indexJsonRecord,
|
|
4017
|
+
allSnapShots,
|
|
4018
|
+
);
|
|
4019
|
+
if (
|
|
4020
|
+
stagingArea.length === 0 &&
|
|
4021
|
+
modifiedFile.length === 0 &&
|
|
4022
|
+
unTrackedFile.length === 0
|
|
4023
|
+
) {
|
|
4024
|
+
printEmptyStagingArea();
|
|
4025
|
+
}
|
|
4026
|
+
printStagingArea(stagingArea, allSnapShots);
|
|
4027
|
+
printModifiedFiles(modifiedFile);
|
|
4028
|
+
printUntrackedFiles(unTrackedFile);
|
|
4029
|
+
}
|
|
4030
|
+
function scanDirectory(
|
|
4031
|
+
dirPath,
|
|
4032
|
+
grootIgnoreContentSet,
|
|
4033
|
+
indexJsonRecord,
|
|
4034
|
+
allSnapShots,
|
|
4035
|
+
) {
|
|
4036
|
+
let projectDirArray = fs6.readdirSync(dirPath);
|
|
4037
|
+
projectDirArray.forEach((eachPath) => {
|
|
4038
|
+
let dynamicPathOfdirPath = path7.join(dirPath, eachPath);
|
|
4039
|
+
if (!grootIgnoreContentSet.has(path7.basename(dynamicPathOfdirPath))) {
|
|
4040
|
+
if (fs6.statSync(dynamicPathOfdirPath).isDirectory()) {
|
|
4041
|
+
scanDirectory(
|
|
4042
|
+
dynamicPathOfdirPath,
|
|
4043
|
+
grootIgnoreContentSet,
|
|
4044
|
+
indexJsonRecord,
|
|
4045
|
+
allSnapShots,
|
|
4046
|
+
);
|
|
4047
|
+
} else {
|
|
4048
|
+
let receivedFileContent =
|
|
4049
|
+
readFileTryCatch(dynamicPathOfdirPath);
|
|
4050
|
+
let receivedFileContentHash = crypto3
|
|
4051
|
+
.createHash("sha256")
|
|
4052
|
+
.update(receivedFileContent)
|
|
4053
|
+
.digest("hex");
|
|
4054
|
+
let dynamicFileContent = {
|
|
4055
|
+
file: dynamicPathOfdirPath,
|
|
4056
|
+
hash: receivedFileContentHash,
|
|
4057
|
+
};
|
|
4058
|
+
let checkIndexJsonValue = checkIndexJSON(
|
|
4059
|
+
dynamicFileContent,
|
|
4060
|
+
indexJsonRecord,
|
|
4061
|
+
);
|
|
4062
|
+
if (checkIndexJsonValue === "modified") {
|
|
4063
|
+
modifiedFile.push(dynamicFileContent.file);
|
|
4064
|
+
} else if (checkIndexJsonValue) {
|
|
4065
|
+
stagingArea.push(dynamicFileContent.file);
|
|
4066
|
+
} else {
|
|
4067
|
+
let checkCommitSnapshotValue = checkCommitSnapshot(
|
|
4068
|
+
dynamicFileContent,
|
|
4069
|
+
allSnapShots,
|
|
4070
|
+
);
|
|
4071
|
+
if (checkCommitSnapshotValue === "modified") {
|
|
4072
|
+
modifiedFile.push(dynamicFileContent.file);
|
|
4073
|
+
} else if (checkCommitSnapshotValue === "untracked") {
|
|
4074
|
+
unTrackedFile.push(dynamicFileContent.file);
|
|
4075
|
+
}
|
|
4076
|
+
}
|
|
4077
|
+
}
|
|
4078
|
+
}
|
|
4079
|
+
});
|
|
4080
|
+
}
|
|
4081
|
+
function checkIndexJSON(dynamicFileContent, indexJsonRecord) {
|
|
4082
|
+
let currFileHash = indexJsonRecord[dynamicFileContent.file];
|
|
4083
|
+
if (currFileHash !== undefined) {
|
|
4084
|
+
if (currFileHash === dynamicFileContent.hash) {
|
|
4085
|
+
return true;
|
|
4086
|
+
} else {
|
|
4087
|
+
return "modified";
|
|
4088
|
+
}
|
|
4089
|
+
}
|
|
4090
|
+
return false;
|
|
4091
|
+
}
|
|
4092
|
+
function checkCommitSnapshot(dynamicFileContent, allSnapShots) {
|
|
4093
|
+
let snapShotHash = allSnapShots[dynamicFileContent.file];
|
|
4094
|
+
if (snapShotHash !== undefined) {
|
|
4095
|
+
if (snapShotHash === dynamicFileContent.hash) {
|
|
4096
|
+
return false;
|
|
4097
|
+
} else {
|
|
4098
|
+
return "modified";
|
|
4099
|
+
}
|
|
4100
|
+
}
|
|
4101
|
+
return "untracked";
|
|
4102
|
+
}
|
|
4103
|
+
function printEmptyStagingArea() {
|
|
4104
|
+
console.log(`nothing to commit, working tree clean`);
|
|
4105
|
+
}
|
|
4106
|
+
function printStagingArea(pathArray, allSnapShots) {
|
|
4107
|
+
if (pathArray.length === 0) return;
|
|
4108
|
+
console.log(`Changes waiting to be committed:`);
|
|
4109
|
+
console.log(
|
|
4110
|
+
`use "groot restore --staged <file>..." to unstage or else groot /help`,
|
|
4111
|
+
);
|
|
4112
|
+
pathArray.forEach((eachPath) => {
|
|
4113
|
+
let modified = allSnapShots[eachPath] !== undefined;
|
|
4114
|
+
let fileType = modified ? "modified" : "new file";
|
|
4115
|
+
console.log(
|
|
4116
|
+
` \x1B[38;2;160;213;133m${fileType}: ${eachPath}\x1B[0m`,
|
|
4117
|
+
);
|
|
4118
|
+
});
|
|
4119
|
+
}
|
|
4120
|
+
function printUntrackedFiles(pathArray) {
|
|
4121
|
+
if (pathArray.length === 0) return;
|
|
4122
|
+
console.log(`Untracked files:`);
|
|
4123
|
+
console.log(
|
|
4124
|
+
` (use "groot add <file>..." to include what will be committed or else groot /help`,
|
|
4125
|
+
);
|
|
4126
|
+
pathArray.forEach((eachPath) => {
|
|
4127
|
+
console.log(
|
|
4128
|
+
` \x1B[38;2;255;90;90m${path7.basename(eachPath)}\x1B[0m`,
|
|
4129
|
+
);
|
|
4130
|
+
});
|
|
4131
|
+
}
|
|
4132
|
+
function printModifiedFiles(pathArray) {
|
|
4133
|
+
if (pathArray.length === 0) return;
|
|
4134
|
+
console.log(`Changes not staged for commit:`);
|
|
4135
|
+
console.log(
|
|
4136
|
+
` (use "groot add <file>..." to update what will be committed or else groot /help`,
|
|
4137
|
+
);
|
|
4138
|
+
pathArray.forEach((eachPath) => {
|
|
4139
|
+
console.log(
|
|
4140
|
+
` \x1B[38;2;245;200;87mmodified: ${eachPath}\x1B[0m`,
|
|
4141
|
+
);
|
|
4142
|
+
});
|
|
4143
|
+
}
|
|
4144
|
+
|
|
4145
|
+
// src/commands/help.ts
|
|
4146
|
+
function help() {
|
|
4147
|
+
const section = `\x1B[38;2;130;150;180m`;
|
|
4148
|
+
const command = `\x1B[38;2;140;200;140m`;
|
|
4149
|
+
const reset = `\x1B[0m`;
|
|
4150
|
+
console.log(`These are the available Groot commands: `);
|
|
4151
|
+
console.log(`
|
|
4152
|
+
${section}start a working area${reset}`);
|
|
4153
|
+
console.log(
|
|
4154
|
+
` ${command}groot init${reset} Create an empty Groot repository`,
|
|
4155
|
+
);
|
|
4156
|
+
console.log(`
|
|
4157
|
+
${section}work on the current change${reset}`);
|
|
4158
|
+
console.log(
|
|
4159
|
+
` ${command}groot add <file>${reset} Add file contents to the index`,
|
|
4160
|
+
);
|
|
4161
|
+
console.log(`
|
|
4162
|
+
${section}examine the history and state${reset}`);
|
|
4163
|
+
console.log(
|
|
4164
|
+
` ${command}groot log${reset} Show complete commit logs`,
|
|
4165
|
+
);
|
|
4166
|
+
console.log(
|
|
4167
|
+
` ${command}groot log --oneline${reset} Show condensed one-line commit logs`,
|
|
4168
|
+
);
|
|
4169
|
+
console.log(
|
|
4170
|
+
` ${command}groot status${reset} Show working tree status`,
|
|
4171
|
+
);
|
|
4172
|
+
console.log(`
|
|
4173
|
+
${section}compare changes${reset}`);
|
|
4174
|
+
console.log(
|
|
4175
|
+
` ${command}groot diff <file>${reset} Show differences between working file and HEAD`,
|
|
4176
|
+
);
|
|
4177
|
+
console.log(`
|
|
4178
|
+
${section}save your work${reset}`);
|
|
4179
|
+
console.log(
|
|
4180
|
+
` ${command}groot commit -m "message"${reset} Record changes to the repository`,
|
|
4181
|
+
);
|
|
4182
|
+
console.log(`
|
|
4183
|
+
${section}other${reset}`);
|
|
4184
|
+
console.log(
|
|
4185
|
+
` ${command}groot help${reset} Show this help message`,
|
|
4186
|
+
);
|
|
4187
|
+
console.log();
|
|
4188
|
+
}
|
|
4189
|
+
|
|
4190
|
+
// src/commands/restore.ts
|
|
4191
|
+
import fs7 from "fs";
|
|
4192
|
+
import path8 from "path";
|
|
4193
|
+
function restore(fileNameToUnstaged) {
|
|
4194
|
+
let indexJsonFileContent = fetchIndexJsonContent();
|
|
4195
|
+
if (indexJsonFileContent[path8.resolve(fileNameToUnstaged)] === undefined) {
|
|
4196
|
+
console.log(`${fileNameToUnstaged} is not staged`);
|
|
4197
|
+
return;
|
|
4198
|
+
}
|
|
4199
|
+
delete indexJsonFileContent[path8.resolve(fileNameToUnstaged)];
|
|
4200
|
+
fs7.writeFileSync(
|
|
4201
|
+
fetchIndexJsonPath(),
|
|
4202
|
+
JSON.stringify(indexJsonFileContent, null, 2),
|
|
4203
|
+
);
|
|
4204
|
+
}
|
|
4205
|
+
|
|
4206
|
+
// src/commands/diff.ts
|
|
4207
|
+
import path9 from "path";
|
|
4208
|
+
function diff(filePath) {
|
|
4209
|
+
const completeFilePath = path9.resolve(filePath);
|
|
4210
|
+
console.log(`completeFilePath : ${completeFilePath}`);
|
|
4211
|
+
const oldFileContent = getOldFileContent(completeFilePath);
|
|
4212
|
+
const newFileContent = getNewFileContent(completeFilePath);
|
|
4213
|
+
const resultNode = myersDiffAlgorithm(oldFileContent, newFileContent);
|
|
4214
|
+
printResult(resultNode);
|
|
4215
|
+
}
|
|
4216
|
+
function myersDiffAlgorithm(oldFileContent, newFileContent) {
|
|
4217
|
+
const m = oldFileContent.length;
|
|
4218
|
+
const n = newFileContent.length;
|
|
4219
|
+
const totalSize = 2 * (m + n) + 1;
|
|
4220
|
+
const offSet = m + n;
|
|
4221
|
+
const V = new Int32Array(totalSize).fill(-1);
|
|
4222
|
+
const goal_k = m - n;
|
|
4223
|
+
const snapShots = [];
|
|
4224
|
+
let finalNode = { row: 0, col: 0 };
|
|
4225
|
+
for (let d = 0; d <= m + n; d++) {
|
|
4226
|
+
const prevV = new Int32Array(V);
|
|
4227
|
+
for (let k = -d; k <= d; k += 2) {
|
|
4228
|
+
const idx = k + offSet;
|
|
4229
|
+
const right = prevV[idx - 1];
|
|
4230
|
+
const down = prevV[idx + 1] + 1;
|
|
4231
|
+
V[idx] = Math.max(right, down);
|
|
4232
|
+
const row = V[idx];
|
|
4233
|
+
const col = row - k;
|
|
4234
|
+
const position = { row, col };
|
|
4235
|
+
finalNode = greedyConsumeDiagonals(
|
|
4236
|
+
position,
|
|
4237
|
+
oldFileContent,
|
|
4238
|
+
newFileContent,
|
|
4239
|
+
);
|
|
4240
|
+
V[idx] = finalNode.row;
|
|
4241
|
+
if (k === goal_k && V[idx] === m) {
|
|
4242
|
+
snapShots.push(new Int32Array(V));
|
|
4243
|
+
finalNode = { row: m, col: n };
|
|
4244
|
+
return construction(
|
|
4245
|
+
finalNode,
|
|
4246
|
+
snapShots,
|
|
4247
|
+
oldFileContent,
|
|
4248
|
+
newFileContent,
|
|
4249
|
+
);
|
|
4250
|
+
}
|
|
4251
|
+
}
|
|
4252
|
+
snapShots.push(new Int32Array(V));
|
|
4253
|
+
}
|
|
4254
|
+
throw new Error("Myers diff failed — no path found");
|
|
4255
|
+
}
|
|
4256
|
+
function greedyConsumeDiagonals(position, oldFiles, newFiles) {
|
|
4257
|
+
let row = position.row;
|
|
4258
|
+
let col = position.col;
|
|
4259
|
+
while (
|
|
4260
|
+
row < oldFiles.length &&
|
|
4261
|
+
col < newFiles.length &&
|
|
4262
|
+
oldFiles[row] === newFiles[col]
|
|
4263
|
+
) {
|
|
4264
|
+
row += 1;
|
|
4265
|
+
col += 1;
|
|
4266
|
+
}
|
|
4267
|
+
if (row > oldFiles.length) row = oldFiles.length;
|
|
4268
|
+
if (col > newFiles.length) col = newFiles.length;
|
|
4269
|
+
return { row, col };
|
|
4270
|
+
}
|
|
4271
|
+
function construction(finalNode, snapshot, oldFileContent, newFileContent) {
|
|
4272
|
+
const moves = [];
|
|
4273
|
+
const m = oldFileContent.length;
|
|
4274
|
+
const n = newFileContent.length;
|
|
4275
|
+
const offSet = m + n;
|
|
4276
|
+
let x = finalNode.row - 1;
|
|
4277
|
+
let y = finalNode.col - 1;
|
|
4278
|
+
for (let d = snapshot.length - 1; d >= 1; d--) {
|
|
4279
|
+
const V = snapshot[d - 1];
|
|
4280
|
+
while (x >= 0 && y >= 0 && oldFileContent[x] === newFileContent[y]) {
|
|
4281
|
+
moves.push({ line: oldFileContent[x], moveType: "unchanged" });
|
|
4282
|
+
x -= 1;
|
|
4283
|
+
y -= 1;
|
|
4284
|
+
}
|
|
4285
|
+
let k = x - y;
|
|
4286
|
+
let left = V[k + 1 + offSet];
|
|
4287
|
+
let up = V[k - 1 + offSet];
|
|
4288
|
+
if (x >= 0) {
|
|
4289
|
+
if (up > left) {
|
|
4290
|
+
moves.push({ line: oldFileContent[x], moveType: "delete" });
|
|
4291
|
+
x -= 1;
|
|
4292
|
+
}
|
|
4293
|
+
}
|
|
4294
|
+
if (y >= 0) {
|
|
4295
|
+
if (left > up) {
|
|
4296
|
+
moves.push({ line: newFileContent[y], moveType: "add" });
|
|
4297
|
+
y -= 1;
|
|
4298
|
+
}
|
|
4299
|
+
}
|
|
4300
|
+
}
|
|
4301
|
+
while (x >= 0 && y >= 0 && oldFileContent[x] === newFileContent[y]) {
|
|
4302
|
+
moves.push({ line: oldFileContent[x], moveType: "unchanged" });
|
|
4303
|
+
x -= 1;
|
|
4304
|
+
y -= 1;
|
|
4305
|
+
}
|
|
4306
|
+
return moves.reverse();
|
|
4307
|
+
}
|
|
4308
|
+
function getOldFileContent(completeFilePath) {
|
|
4309
|
+
let grootDirPath = path9.join(fetchGrootPath(), ".groot");
|
|
4310
|
+
let headCommit = getHeadCommit();
|
|
4311
|
+
let oldFileHash = headCommit.snapshot[completeFilePath];
|
|
4312
|
+
if (!oldFileHash) {
|
|
4313
|
+
console.log(`file was never committed before: ${completeFilePath}`);
|
|
4314
|
+
process.exit(0);
|
|
4315
|
+
}
|
|
4316
|
+
let fileContent = readFileTryCatch(
|
|
4317
|
+
path9.join(grootDirPath, "objects", `${oldFileHash}`),
|
|
4318
|
+
).split(`
|
|
4319
|
+
`);
|
|
4320
|
+
if (fileContent[fileContent.length - 1] === "") {
|
|
4321
|
+
fileContent = fileContent.slice(0, -1);
|
|
4322
|
+
}
|
|
4323
|
+
return fileContent;
|
|
4324
|
+
}
|
|
4325
|
+
function getNewFileContent(completeFilePath) {
|
|
4326
|
+
let fileContent = readFileTryCatch(completeFilePath).split(`
|
|
4327
|
+
`);
|
|
4328
|
+
if (fileContent[fileContent.length - 1] === "") {
|
|
4329
|
+
fileContent = fileContent.slice(0, -1);
|
|
4330
|
+
}
|
|
4331
|
+
return fileContent;
|
|
4332
|
+
}
|
|
4333
|
+
function printResult(result) {
|
|
4334
|
+
let output = "";
|
|
4335
|
+
for (let move of result) {
|
|
4336
|
+
if (move.moveType === "unchanged") {
|
|
4337
|
+
output += ` ${move.line}
|
|
4338
|
+
`;
|
|
4339
|
+
} else if (move.moveType === "delete") {
|
|
4340
|
+
output += source_default.red(`- ${move.line}
|
|
4341
|
+
`);
|
|
4342
|
+
} else if (move.moveType === "add") {
|
|
4343
|
+
output += source_default.green(`+ ${move.line}
|
|
4344
|
+
`);
|
|
4345
|
+
}
|
|
4346
|
+
}
|
|
4347
|
+
console.log(
|
|
4348
|
+
`
|
|
4349
|
+
` + output,
|
|
4350
|
+
);
|
|
4351
|
+
}
|
|
4352
|
+
|
|
4353
|
+
// src/cli.ts
|
|
4354
|
+
var args = process.argv.slice(2);
|
|
4355
|
+
var command = args[0];
|
|
4356
|
+
switch (command) {
|
|
4357
|
+
case "init":
|
|
4358
|
+
init();
|
|
4359
|
+
break;
|
|
4360
|
+
case "add":
|
|
4361
|
+
if (!args[1]) {
|
|
4362
|
+
console.log("Please provide a filename. Usage: groot add <file>");
|
|
4363
|
+
break;
|
|
4364
|
+
}
|
|
4365
|
+
add(args[1]);
|
|
4366
|
+
break;
|
|
4367
|
+
case "commit":
|
|
4368
|
+
if (args[1] !== "-m") {
|
|
4369
|
+
console.log(
|
|
4370
|
+
`Please use proper format. Do groot help for more information`,
|
|
4371
|
+
);
|
|
4372
|
+
break;
|
|
4373
|
+
} else {
|
|
4374
|
+
if (!args[2]) {
|
|
4375
|
+
console.log(
|
|
4376
|
+
`Please provide a commit message. Usage groot commit -m "commit message"`,
|
|
4377
|
+
);
|
|
4378
|
+
break;
|
|
4379
|
+
}
|
|
4380
|
+
commit(args[2]);
|
|
4381
|
+
break;
|
|
4382
|
+
}
|
|
4383
|
+
case "log":
|
|
4384
|
+
if (!args[1]) {
|
|
4385
|
+
log();
|
|
4386
|
+
break;
|
|
4387
|
+
} else if (args[1] === "--oneline") {
|
|
4388
|
+
logOneline();
|
|
4389
|
+
break;
|
|
4390
|
+
} else {
|
|
4391
|
+
console.log(
|
|
4392
|
+
`Invalid command, please refer groot help for all commands!`,
|
|
4393
|
+
);
|
|
4394
|
+
break;
|
|
4395
|
+
}
|
|
4396
|
+
case "status":
|
|
4397
|
+
status();
|
|
4398
|
+
break;
|
|
4399
|
+
case "restore":
|
|
4400
|
+
if (args[1] !== "--staged") {
|
|
4401
|
+
console.log(
|
|
4402
|
+
`Invalid command, please refer groot help for all commands!`,
|
|
4403
|
+
);
|
|
4404
|
+
break;
|
|
4405
|
+
}
|
|
4406
|
+
if (!args[2]) {
|
|
4407
|
+
console.log(
|
|
4408
|
+
`Please provide a file name, or refer groot help for all commands!`,
|
|
4409
|
+
);
|
|
4410
|
+
break;
|
|
4411
|
+
}
|
|
4412
|
+
restore(args[2]);
|
|
4413
|
+
break;
|
|
4414
|
+
case "help":
|
|
4415
|
+
help();
|
|
4416
|
+
break;
|
|
4417
|
+
case "diff":
|
|
4418
|
+
if (!args[1]) {
|
|
4419
|
+
console.log(`Please provide a filename. Usage: groot diff <file>`);
|
|
4420
|
+
break;
|
|
4421
|
+
}
|
|
4422
|
+
diff(args[1]);
|
|
4423
|
+
break;
|
|
4424
|
+
default:
|
|
4425
|
+
help();
|
|
4426
|
+
break;
|
|
4427
|
+
}
|