UNPKG

@kya-os/cli

Version:

CLI for KYA-OS MCP-I setup and management

80 lines 2.33 kB
/** * Core types and interfaces for the Terminal Effects Engine * Based on TerminalTextEffects Python library architecture */ /** * Abstract base class for effects */ export class BaseEffect { constructor() { this.text = ""; this.config = { frameRate: 30, useXTermColors: false, noColor: false, }; this.characters = []; this.frameCount = 0; this.isInitialized = false; } initialize(text, config) { this.text = text; this.config = { ...this.config, ...config }; this.characters = this.createCharacters(text); this.isInitialized = true; this.onInitialize(); } reset() { this.frameCount = 0; this.characters = this.createCharacters(this.text); this.onReset(); } cleanup() { this.characters = []; this.onCleanup(); } onCleanup() { // Optional cleanup hook } createCharacters(text) { const lines = text.split("\n"); const characters = []; lines.forEach((line, y) => { [...line].forEach((char, x) => { if (char !== " ") { characters.push({ id: `${x}-${y}`, originalSymbol: char, originalPosition: { x, y }, currentPosition: { x, y }, visual: { symbol: char, colors: { fg: null, bg: null }, }, }); } }); }); return characters; } getCanvasDimensions() { if (this.config.canvas) { return this.config.canvas; } // Calculate from text if no canvas specified const lines = this.text.split("\n"); const height = lines.length; const width = Math.max(...lines.map((line) => line.length)); return { width, height }; } } /** * Type guard for Color types */ export function isRGBColor(color) { return typeof color === "string" && /^[0-9a-fA-F]{6}$/.test(color); } export function isXTermColor(color) { return typeof color === "number" && color >= 0 && color <= 255; } //# sourceMappingURL=types.js.map