@kotori-bot/tools
Version:
Tools For Kotori
107 lines (106 loc) • 3.69 kB
JavaScript
/**
* @Package @kotori-bot/tools
* @Version 1.5.2
* @Author Hotaru <me@hotaru.icu>
* @Copyright 2024-2025 Hotaru. All rights reserved.
* @License BAN-ZHINESE-USING
* @Link https://github.com/kotorijs/kotori
* @Date 17:26:22
*/
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var terminal_exports = {};
__export(terminal_exports, {
TerminalAdapter: () => TerminalAdapter,
colors: () => colors,
default: () => terminal_default
});
module.exports = __toCommonJS(terminal_exports);
var import_utils = require("../utils");
const replaceClose = (index, string, close, replace, head = string.substring(0, index) + replace, tail = string.substring(index + close.length), next = tail.indexOf(close)) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
const clearBleed = (index, string, open, close, replace) => index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
const filterEmpty = (open, close, replace = open, at = open.length + 1) => (string) => string || !(string === "" || string === void 0) ? clearBleed(
// biome-ignore lint:
("" + string).indexOf(close, at),
string,
open,
close,
replace
) : "";
const init = (open, close, replace) => filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
const colors = {
reset: init(0, 0),
bold: init(1, 22, "\x1B[22m\x1B[1m"),
dim: init(2, 22, "\x1B[22m\x1B[2m"),
italic: init(3, 23),
underline: init(4, 24),
inverse: init(7, 27),
hidden: init(8, 28),
strikethrough: init(9, 29),
black: init(30, 39),
red: init(31, 39),
green: init(32, 39),
yellow: init(33, 39),
blue: init(34, 39),
magenta: init(35, 39),
cyan: init(36, 39),
white: init(37, 39),
gray: init(90, 39),
bgBlack: init(40, 49),
bgRed: init(41, 49),
bgGreen: init(42, 49),
bgYellow: init(43, 49),
bgBlue: init(44, 49),
bgMagenta: init(45, 49),
bgCyan: init(46, 49),
bgWhite: init(47, 49),
blackBright: init(90, 39),
redBright: init(91, 39),
greenBright: init(92, 39),
yellowBright: init(93, 39),
blueBright: init(94, 39),
magentaBright: init(95, 39),
cyanBright: init(96, 39),
whiteBright: init(97, 39),
bgBlackBright: init(100, 49),
bgRedBright: init(101, 49),
bgGreenBright: init(102, 49),
bgYellowBright: init(103, 49),
bgBlueBright: init(104, 49),
bgMagentaBright: init(105, 49),
bgCyanBright: init(106, 49),
bgWhiteBright: init(107, 49)
};
class TerminalAdapterOrigin {
c = colors;
}
const TerminalAdapter = new Proxy(TerminalAdapterOrigin, {
construct(target, argArray, newTarget) {
const { c } = Reflect.construct(target, argArray, newTarget);
const handleInstance = {};
for (const key of import_utils.colorsIdentity) handleInstance[key] = c[key].bind(c);
return handleInstance;
}
});
var terminal_default = TerminalAdapter;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
TerminalAdapter,
colors
});