beeline-cli
Version:
A terminal wallet for the Hive blockchain - type, sign, rule the chain
490 lines • 19 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.themes = exports.MatrixRain = exports.neonSymbols = exports.matrixChalk = exports.neonChalk = exports.matrixGradients = exports.neonGradients = exports.matrixColors = exports.neonColors = void 0;
exports.createNeonBanner = createNeonBanner;
exports.createNeonBox = createNeonBox;
exports.createNeonGrid = createNeonGrid;
exports.neonSpinner = neonSpinner;
exports.matrixSpinner = matrixSpinner;
exports.createMatrixBanner = createMatrixBanner;
exports.createMatrixBox = createMatrixBox;
exports.playMatrixRain = playMatrixRain;
exports.addMatrixFlair = addMatrixFlair;
exports.setTheme = setTheme;
exports.getTheme = getTheme;
exports.getCurrentThemeName = getCurrentThemeName;
exports.listThemes = listThemes;
const chalk_1 = __importDefault(require("chalk"));
const gradient_string_1 = __importDefault(require("gradient-string"));
const figlet_1 = __importDefault(require("figlet"));
const fs = __importStar(require("fs-extra"));
const path = __importStar(require("path"));
const os = __importStar(require("os"));
exports.neonColors = {
cyan: '#00FFFF',
magenta: '#FF00FF',
electric: '#00FF00',
green: '#32CD32',
purple: '#9D00FF',
pink: '#FF1493',
orange: '#FF4500',
yellow: '#FFFF00',
white: '#FFFFFF',
darkCyan: '#008B8B',
darkMagenta: '#8B008B'
};
exports.matrixColors = {
brightGreen: '#00FF41',
green: '#00FF00',
darkGreen: '#008F11',
mediumGreen: '#00AA00',
black: '#000000',
white: '#FFFFFF'
};
exports.neonGradients = {
cyber: (0, gradient_string_1.default)(['#00FFFF', '#FF00FF']),
matrix: (0, gradient_string_1.default)(['#00FF41', '#008F11']),
synthwave: (0, gradient_string_1.default)(['#FF00FF', '#00FFFF', '#FFFF00']),
electric: (0, gradient_string_1.default)(['#00FFFF', '#9D00FF']),
sunset: (0, gradient_string_1.default)(['#FF4500', '#FF1493', '#9D00FF'])
};
exports.matrixGradients = {
rain: (0, gradient_string_1.default)(['#FFFFFF', '#00FF41', '#008F11']),
code: (0, gradient_string_1.default)(['#00FF41', '#00AA00']),
terminal: (0, gradient_string_1.default)(['#00FF00', '#008F11'])
};
exports.neonChalk = {
cyan: chalk_1.default.hex(exports.neonColors.cyan),
magenta: chalk_1.default.hex(exports.neonColors.magenta),
electric: chalk_1.default.hex(exports.neonColors.electric),
green: chalk_1.default.hex(exports.neonColors.green),
purple: chalk_1.default.hex(exports.neonColors.purple),
pink: chalk_1.default.hex(exports.neonColors.pink),
orange: chalk_1.default.hex(exports.neonColors.orange),
yellow: chalk_1.default.hex(exports.neonColors.yellow),
white: chalk_1.default.hex(exports.neonColors.white),
darkCyan: chalk_1.default.hex(exports.neonColors.darkCyan),
darkMagenta: chalk_1.default.hex(exports.neonColors.darkMagenta),
// Special effects
glow: (text) => chalk_1.default.bold.hex(exports.neonColors.cyan)(text),
pulse: (text) => chalk_1.default.bold.hex(exports.neonColors.magenta)(text),
error: (text) => chalk_1.default.bold.hex(exports.neonColors.pink)(text),
success: (text) => chalk_1.default.bold.hex(exports.neonColors.electric)(text),
warning: (text) => chalk_1.default.bold.hex(exports.neonColors.orange)(text),
info: (text) => chalk_1.default.bold.hex(exports.neonColors.cyan)(text),
// Grid elements
border: chalk_1.default.hex(exports.neonColors.darkCyan),
accent: chalk_1.default.hex(exports.neonColors.magenta),
highlight: chalk_1.default.bold.hex(exports.neonColors.yellow)
};
exports.matrixChalk = {
brightGreen: chalk_1.default.hex(exports.matrixColors.brightGreen),
green: chalk_1.default.hex(exports.matrixColors.green),
darkGreen: chalk_1.default.hex(exports.matrixColors.darkGreen),
mediumGreen: chalk_1.default.hex(exports.matrixColors.mediumGreen),
white: chalk_1.default.hex(exports.matrixColors.white),
black: chalk_1.default.hex(exports.matrixColors.black),
// Special effects
glow: (text) => chalk_1.default.bold.hex(exports.matrixColors.brightGreen)(text),
pulse: (text) => chalk_1.default.bold.hex(exports.matrixColors.green)(text),
error: (text) => chalk_1.default.bold.hex(exports.matrixColors.brightGreen)(text),
success: (text) => chalk_1.default.bold.hex(exports.matrixColors.brightGreen)(text),
warning: (text) => chalk_1.default.bold.hex(exports.matrixColors.green)(text),
info: (text) => chalk_1.default.bold.hex(exports.matrixColors.mediumGreen)(text),
// Grid elements
border: chalk_1.default.hex(exports.matrixColors.darkGreen),
accent: chalk_1.default.hex(exports.matrixColors.brightGreen),
highlight: chalk_1.default.bold.hex(exports.matrixColors.white)
};
exports.neonSymbols = {
bullet: '▶',
arrow: '→',
check: '✔',
cross: '✖',
star: '★',
diamond: '◆',
square: '■',
circle: '●',
triangle: '▲',
line: '─',
verticalLine: '│',
corner: '└',
tee: '├',
grid: '▓',
block: '█',
shade: '░',
mediumShade: '▒',
darkShade: '▓',
warning: '⚠',
info: 'ℹ',
pause: '⏸',
download: '⬇',
search: '🔍',
vote: '🗳',
proxy: '🔗',
list: '📋'
};
async function createNeonBanner(text) {
return new Promise((resolve, reject) => {
figlet_1.default.text(text, {
font: 'ANSI Shadow',
horizontalLayout: 'fitted',
verticalLayout: 'fitted'
}, (err, data) => {
if (err) {
reject(err);
return;
}
if (data) {
resolve(exports.neonGradients.cyber(data));
}
else {
reject(new Error('Failed to generate banner'));
}
});
});
}
function createNeonBox(content, title) {
const lines = content.split('\n');
const maxLength = Math.max(...lines.map(line => line.length));
const width = Math.max(maxLength + 4, title ? title.length + 4 : 0);
let box = '';
// Top border
if (title) {
const titlePadding = Math.floor((width - title.length - 2) / 2);
const leftPadding = '─'.repeat(titlePadding);
const rightPadding = '─'.repeat(width - title.length - 2 - titlePadding);
box += exports.neonChalk.border(`┌${leftPadding}`) + exports.neonChalk.accent(` ${title} `) + exports.neonChalk.border(`${rightPadding}┐\n`);
}
else {
box += exports.neonChalk.border('┌' + '─'.repeat(width - 2) + '┐\n');
}
// Content
lines.forEach(line => {
const padding = ' '.repeat(width - line.length - 4);
box += exports.neonChalk.border('│ ') + line + padding + exports.neonChalk.border(' │\n');
});
// Bottom border
box += exports.neonChalk.border('└' + '─'.repeat(width - 2) + '┘');
return box;
}
function createNeonGrid(width = 60) {
let grid = '';
// Create a cyberpunk grid pattern
for (let i = 0; i < 3; i++) {
let line = '';
for (let j = 0; j < width; j += 3) {
if (Math.random() > 0.7) {
line += exports.neonChalk.cyan(exports.neonSymbols.block);
}
else if (Math.random() > 0.5) {
line += exports.neonChalk.darkCyan(exports.neonSymbols.mediumShade);
}
else {
line += exports.neonChalk.darkCyan(exports.neonSymbols.shade);
}
if (j + 1 < width) {
line += exports.neonChalk.border(' ');
}
if (j + 2 < width) {
line += Math.random() > 0.8 ? exports.neonChalk.magenta(exports.neonSymbols.darkShade) : ' ';
}
}
grid += line + '\n';
}
return grid;
}
function neonSpinner(text) {
const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
let i = 0;
return setInterval(() => {
process.stdout.write(`\r${exports.neonChalk.cyan(frames[i % frames.length])} ${exports.neonChalk.glow(text)}`);
i++;
}, 80);
}
function matrixSpinner(text) {
const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
let i = 0;
return setInterval(() => {
process.stdout.write(`\r${exports.matrixChalk.brightGreen(frames[i % frames.length])} ${exports.matrixChalk.glow(text)}`);
i++;
}, 80);
}
async function createMatrixBanner(text) {
return new Promise((resolve, reject) => {
figlet_1.default.text(text, {
font: 'ANSI Shadow',
horizontalLayout: 'fitted',
verticalLayout: 'fitted'
}, (err, data) => {
if (err) {
reject(err);
return;
}
if (data) {
resolve(exports.matrixGradients.rain(data));
}
else {
reject(new Error('Failed to generate banner'));
}
});
});
}
function createMatrixBox(content, title) {
const lines = content.split('\n');
const maxLength = Math.max(...lines.map(line => line.length));
const width = Math.max(maxLength + 4, title ? title.length + 4 : 0);
let box = '';
// Top border
if (title) {
const titlePadding = Math.floor((width - title.length - 2) / 2);
const leftPadding = '─'.repeat(titlePadding);
const rightPadding = '─'.repeat(width - title.length - 2 - titlePadding);
box += exports.matrixChalk.border(`┌${leftPadding}`) + exports.matrixChalk.accent(` ${title} `) + exports.matrixChalk.border(`${rightPadding}┐\n`);
}
else {
box += exports.matrixChalk.border('┌' + '─'.repeat(width - 2) + '┐\n');
}
// Content
lines.forEach(line => {
const padding = ' '.repeat(width - line.length - 4);
box += exports.matrixChalk.border('│ ') + line + padding + exports.matrixChalk.border(' │\n');
});
// Bottom border
box += exports.matrixChalk.border('└' + '─'.repeat(width - 2) + '┘');
return box;
}
class MatrixRain {
constructor(width = 80, height = 25) {
this.columns = [];
this.isRunning = false;
// Matrix-style characters (mix of katakana, numbers, and symbols)
this.matrixChars = [
'ア', 'カ', 'サ', 'タ', 'ナ', 'ハ', 'マ', 'ヤ', 'ラ', 'ワ',
'イ', 'キ', 'シ', 'チ', 'ニ', 'ヒ', 'ミ', 'リ', 'ウ', 'ク',
'ス', 'ツ', 'ヌ', 'フ', 'ム', 'ユ', 'ル', 'エ', 'ケ', 'セ',
'テ', 'ネ', 'ヘ', 'メ', 'レ', 'オ', 'コ', 'ソ', 'ト', 'ノ',
'ホ', 'モ', 'ヨ', 'ロ', 'ヲ', 'ン', '0', '1', '2', '3', '4',
'5', '6', '7', '8', '9', ':', '・', '"', '=', '*', '+', '-',
'<', '>', '¦', '|', 'ç', 'リ'
];
this.width = width;
this.height = height;
this.initializeColumns();
}
initializeColumns() {
this.columns = [];
const numColumns = Math.floor(this.width / 2);
for (let i = 0; i < numColumns; i++) {
this.columns.push({
x: i * 2,
y: Math.floor(Math.random() * -this.height),
speed: Math.random() * 3 + 1,
chars: [],
length: Math.floor(Math.random() * 20) + 5
});
}
}
getRandomChar() {
return this.matrixChars[Math.floor(Math.random() * this.matrixChars.length)];
}
renderFrame() {
const screen = Array(this.height).fill(null).map(() => Array(this.width).fill(' '));
// Update and render each column
this.columns.forEach(column => {
// Move column down
column.y += column.speed;
// Reset column if it's off screen
if (column.y > this.height + column.length) {
column.y = Math.floor(Math.random() * -20) - column.length;
column.speed = Math.random() * 3 + 1;
column.length = Math.floor(Math.random() * 20) + 5;
column.chars = [];
}
// Generate new characters for the column
while (column.chars.length < column.length) {
column.chars.push(this.getRandomChar());
}
// Render the column
for (let i = 0; i < column.length; i++) {
const y = Math.floor(column.y - i);
const x = column.x;
if (y >= 0 && y < this.height && x >= 0 && x < this.width) {
const char = column.chars[i] || this.getRandomChar();
let coloredChar;
if (i === 0) {
// Head of the stream - bright white
coloredChar = exports.matrixChalk.white(char);
}
else if (i < 3) {
// Bright green for the leading characters
coloredChar = exports.matrixChalk.brightGreen(char);
}
else if (i < 8) {
// Medium green for middle characters
coloredChar = exports.matrixChalk.green(char);
}
else {
// Dark green for trailing characters
coloredChar = exports.matrixChalk.darkGreen(char);
}
screen[y][x] = coloredChar;
}
}
});
// Convert screen to string
return screen.map(row => row.join('')).join('\n');
}
start(duration = 3000) {
return new Promise((resolve) => {
if (this.isRunning) {
resolve();
return;
}
this.isRunning = true;
console.clear();
process.stdout.write('\x1b[?25l'); // Hide cursor
this.intervalId = setInterval(() => {
console.clear();
process.stdout.write(this.renderFrame());
}, 100);
setTimeout(() => {
this.stop();
resolve();
}, duration);
});
}
stop() {
if (this.intervalId) {
clearInterval(this.intervalId);
this.intervalId = undefined;
}
this.isRunning = false;
process.stdout.write('\x1b[?25h'); // Show cursor
console.clear();
}
}
exports.MatrixRain = MatrixRain;
async function playMatrixRain(duration = 3000, width, height) {
const rain = new MatrixRain(width, height);
await rain.start(duration);
}
// Subtle Matrix-themed command output enhancement
function addMatrixFlair(text) {
const currentThemeName = getCurrentThemeName();
// Only add flair for Matrix theme, and do it synchronously to avoid delays
if (typeof currentThemeName === 'object' && currentThemeName instanceof Promise) {
// If it's a promise, just return the text as-is to avoid async complications
return text;
}
if (currentThemeName === 'matrix') {
// Add subtle Matrix characters as a prefix/suffix without blocking
const matrixChars = ['ア', 'カ', 'サ', 'タ', 'ナ', 'ハ', '0', '1'];
const randomChar = matrixChars[Math.floor(Math.random() * matrixChars.length)];
const matrixTheme = exports.themes.matrix;
// Add a subtle Matrix character prefix in dark green occasionally
if (Math.random() < 0.1) { // 10% chance
return matrixTheme.chalk.info(randomChar) + ' ' + text;
}
}
return text;
}
exports.themes = {
cyberpunk: {
name: 'Neon',
colors: exports.neonColors,
chalk: exports.neonChalk,
gradients: exports.neonGradients,
createBanner: createNeonBanner,
createBox: createNeonBox,
spinner: neonSpinner
},
matrix: {
name: 'Terminal',
colors: exports.matrixColors,
chalk: exports.matrixChalk,
gradients: exports.matrixGradients,
createBanner: createMatrixBanner,
createBox: createMatrixBox,
spinner: matrixSpinner
}
};
let currentTheme = 'cyberpunk';
const CONFIG_DIR = path.join(os.homedir(), '.beeline');
const THEME_CONFIG_FILE = path.join(CONFIG_DIR, 'theme.json');
// Load theme from config file on module initialization
async function loadTheme() {
try {
if (await fs.pathExists(THEME_CONFIG_FILE)) {
const config = await fs.readJson(THEME_CONFIG_FILE);
if (config.theme && exports.themes[config.theme]) {
currentTheme = config.theme;
}
}
}
catch (error) {
// Ignore errors, use default theme
}
}
// Save theme to config file
async function saveTheme(theme) {
try {
await fs.ensureDir(CONFIG_DIR);
await fs.writeJson(THEME_CONFIG_FILE, { theme });
}
catch (error) {
// Ignore errors, theme just won't persist
}
}
async function setTheme(theme) {
currentTheme = theme;
await saveTheme(theme);
}
async function getTheme() {
await loadTheme();
return exports.themes[currentTheme];
}
async function getCurrentThemeName() {
await loadTheme();
return currentTheme;
}
function listThemes() {
return Object.keys(exports.themes);
}
//# sourceMappingURL=neon.js.map