@trap_stevo/filetide
Version:
Revolutionizing real-time file transfer with seamless, instant communication across any device. Deliver files instantly, regardless of platform, and experience unparalleled speed and control in managing transfers. Elevate your file-sharing capabilities wi
112 lines (111 loc) • 3.73 kB
JavaScript
;
const {
HUDUtilityManager
} = require("@trap_stevo/legendarybuilderpronodejs-utilities");
const chalk = require("chalk");
const significantMessageColors = ["#00C897", "#00E0FF"];
const noticeMessageColors = ["#4A90E2", "#A3D8F4"];
const infoAccentMessageColors = ["#6B768F", "#8D99AB"];
const errorMessageColors = ["#F94144", "#F3722C"];
const infoMessageColors = ["#028090", "#56cfe1"];
const logHandler = {
"significant": function (includeDate = false, ...message) {
const log = includeDate ? `[${new Date().toLocaleString()}] ~ ` : "";
outputGradient(log + message.join(" "), significantMessageColors);
},
"notice": function (includeDate = false, ...message) {
const log = includeDate ? `[${new Date().toLocaleString()}] ~ ` : "";
outputGradient(log + message.join(" "), noticeMessageColors);
},
"error": function (includeDate = false, ...message) {
const log = includeDate ? `[${new Date().toLocaleString()}] ~ ` : "";
outputGradient(log + message.join(" "), errorMessageColors);
},
"info": function (includeDate = false, ...message) {
const log = includeDate ? `[${new Date().toLocaleString()}] ~ ` : "";
outputGradient(log + message.join(" "), infoMessageColors);
}
};
function gradientText(text, colors, options = {
underline: false
}) {
const gradient = HUDUtilityManager.generateGradientColors(colors, text.length);
let coloredText = "";
const underlineRange = Array.isArray(options.underline) ? options.underline : null;
const underlineNone = options.underline === false;
const underlineAll = options.underline === true;
for (let i = 0; i < text.length; i++) {
const [r, g, b] = gradient[i];
let styledChar = chalk.rgb(r, g, b);
if (underlineAll || underlineRange && i >= underlineRange[0] && i < underlineRange[1]) {
styledChar = styledChar.underline;
}
coloredText += styledChar(text[i]);
}
return coloredText;
}
;
function outputGradient(text, colors, options = {
underline: false
}) {
console.log(gradientText(text, colors, options));
return;
}
;
class FileTideDebugUtilityManager {
constructor() {
if (FileTideDebugUtilityManager.instance) {
return FileTideDebugUtilityManager.instance;
}
this.debugMode = false;
FileTideDebugUtilityManager.instance = this;
}
outputGradient(text, colors, options = {
underline: false
}) {
outputGradient(text, colors, options);
return;
}
gradientText(text, colors, options = {
underline: false
}) {
return gradientText(text, colors, options);
}
createHyperlink(text, url) {
const ESC = "\u001b";
const BEL = "\u0007";
return `${ESC}]8;;${url}${BEL}${text}${ESC}]8;;${BEL}`;
}
setDebugMode(mode) {
this.debugMode = mode;
}
logLink(displayText, url, prefix = "➜", colors = noticeMessageColors.slice(0)) {
const styledText = gradientText(displayText, colors, {
underline: true
});
const link = this.createHyperlink(styledText, url);
const styledPrefix = gradientText(prefix, colors);
process.stdout.write(`${styledPrefix} `);
process.stdout.write(link);
process.stdout.write("\n");
}
log(type = "info", includeDate = false, ...message) {
if (!this.debugMode && type !== "error") {
return;
}
if (logHandler[type]) {
logHandler[type](includeDate, ...message);
return;
}
console.log(new Date().toLocaleString(), chalk.gray("Unknown log type ~ "), type, ...message);
}
}
const instance = new FileTideDebugUtilityManager();
module.exports = {
FileTideDebugUtilityManager: instance,
significantMessageColors,
noticeMessageColors,
errorMessageColors,
infoAccentMessageColors,
infoMessageColors
};