New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

blecsd

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blecsd

A modern, high-performance terminal UI library built on TypeScript and ECS architecture

latest
Source
npmnpm
Version
0.6.2
Version published
Maintainers
1
Created
Source

blECSd

CI npm version

dvdBounce

A high-performance terminal UI library built on TypeScript and bitECS.

blECSd provides a complete toolkit for building terminal applications: dashboards, file managers, system monitors, CLI tools, and games. It combines the performance of an Entity Component System with production-ready widgets and form controls.

Features

  • 43 Widgets: Box, Panel, Tabs, List, Table, Tree, Terminal, Video, 3D Viewport, and more
  • Form Controls: Textarea, Textbox, Checkbox, RadioButton, Switch, Select, ProgressBar, Form
  • 41 Components: Position, Renderable, Focusable, Interactive, Animation, Collision, Camera, and more
  • 21 Systems: Layout, Input, Render, Animation, Collision, SpatialHash, VisibilityCulling, and more
  • Physics-based Animations: Velocity, acceleration, friction for smooth transitions
  • Virtualized Rendering: Efficiently render 1000s of items
  • State Machines: Built-in FSM support for complex UI state

Install

npm install blecsd

Quick Start

Create a terminal app with a bordered panel, text, and keyboard input:

import { createWorld, createScreenEntity, createBoxEntity, createTextEntity } from 'blecsd/core';
import { createDirtyTracker } from 'blecsd/core';
import {
  layoutSystem, renderSystem, outputSystem, cleanup,
  setOutputStream, setOutputBuffer, setRenderBuffer,
} from 'blecsd/systems';
import { createProgram, createDoubleBuffer, getBackBuffer } from 'blecsd/terminal';

const cols = process.stdout.columns ?? 80;
const rows = process.stdout.rows ?? 24;

// 1. Initialize the terminal (alternate screen, hidden cursor, raw mode)
const program = createProgram();
await program.init();

// 2. Create the ECS world and screen entity
const world = createWorld();
createScreenEntity(world, { width: cols, height: rows });

// 3. Wire up the render pipeline buffers
setOutputStream(process.stdout);
const db = createDoubleBuffer(cols, rows);
setOutputBuffer(db);
setRenderBuffer(createDirtyTracker(cols, rows), getBackBuffer(db));

// 4. Build your UI
const panel = createBoxEntity(world, {
  x: 2, y: 1, width: 40, height: 12,
  border: { type: 1, top: true, bottom: true, left: true, right: true },
});

createTextEntity(world, {
  x: 4, y: 2, text: 'My Dashboard', parent: panel,
});

// 5. Render
function render(): void {
  layoutSystem(world);
  renderSystem(world);
  outputSystem(world);
}

render();

// 6. Handle keyboard input
program.on('key', (event) => {
  if (event.name === 'q' || (event.ctrl && event.name === 'c')) {
    cleanup(world);
    program.destroy();
    process.exit(0);
  }
  render();
});

Namespace Imports

blECSd organizes its API into discoverable namespace objects. Instead of importing dozens of individual functions, import a namespace and explore it with autocomplete:

import { position, scroll, content } from 'blecsd/components';
import { rope, colors, unicode } from 'blecsd/utils';
import { cursor, program, screen } from 'blecsd/terminal';

// Position operations
position.set(world, eid, 10, 5);
position.moveBy(world, eid, 1, 0);
position.zIndex.bringToFront(world, eid, siblings);

// Scroll control
scroll.by(world, eid, 0, 10);
scroll.toTop(world, eid);

// Text manipulation with rope data structure
const r = rope.create('Hello');
const modified = rope.insert(r, 5, ' World');
const text = rope.getText(modified);

// Color utilities
const hex = colors.rgbToHex(255, 100, 0);
const parsed = colors.parseColor('#ff6400');

Import Tiers

TierImport PathUse Case
Tier 2 (Recommended)'blecsd/core', 'blecsd/components', 'blecsd/systems', etc.Full module access via subpaths
Tier 1'blecsd'Curated subset for small scripts
Tier 3Deep importsInternal only

Use subpath imports (Tier 2) for all applications. They provide full API access, clear organization by domain, and reduced naming conflicts. The main 'blecsd' entry re-exports a curated subset for convenience. See the Export Patterns Guide for details.

Addon Packages

Specialized functionality is available as separate packages:

PackageDescriptionInstall
@blecsd/3d3D rendering with braille, halfblock, sixel, kitty backendsnpm i @blecsd/3d
@blecsd/aiLLM UI widgets: conversation, streaming markdown, token trackingnpm i @blecsd/ai
@blecsd/audioAudio channel management and sound triggersnpm i @blecsd/audio
@blecsd/gameHigh-level createGame() API for terminal gamesnpm i @blecsd/game
@blecsd/mediaGIF/PNG parsing, ANSI rendering, image/video widgetsnpm i @blecsd/media

Each addon package also provides namespace objects for discoverability:

// 3D math via namespaces
import { vec3, mat4, projection } from '@blecsd/3d';
const v = vec3.add(vec3.create(1, 0, 0), vec3.create(0, 1, 0));
const mvp = mat4.multiply(projection.perspective(60, 1.5, 0.1, 100), viewMatrix);

// AI widgets via namespaces
import { conversation, tokenTracker } from '@blecsd/ai';
conversation.addMessage(state, { role: 'user', content: 'Hello' });

// Media via namespaces
import { gif, png } from '@blecsd/media';
const frames = gif.parse.parseGIF(buffer);

Addon packages also support subpath imports for tree-shaking:

import { vec3Add, vec3Cross } from '@blecsd/3d/math';
import { parseGIF } from '@blecsd/media/gif';

Widgets

WidgetDescription
BarChartBar chart visualization
BigTextLarge ASCII art text
BoxBase container with borders, padding, content
ButtonClickable button with hover/focus states
CheckboxBoolean toggle with customizable characters
FileManagerFile browser with directory navigation
FormForm field management, validation, submit
GaugeCircular/radial gauge display
HoverTextTooltip/hover text display
ImageImage rendering with various formats
LayoutFlex/grid layout container
LineHorizontal/vertical separator
LineChartLine chart visualization
ListSelectable list with keyboard/mouse support
ListbarHorizontal navigation bar
ListTableTable-style list display
LoadingLoading indicator with spinner
LogScrollable log viewer
MessageMessage box with buttons
ModalModal dialog overlay
PanelBox with title bar, collapsible, close button
ProgressBarProgress indicator, horizontal/vertical
PromptInput prompt dialog
QuestionQuestion dialog with yes/no buttons
RadioButtonSingle selection from group
ScrollableBoxContainer with scroll support
ScrollableTextScrollable text area
SparklineSparkline chart visualization
SplitPaneSplit pane container with resize
StreamingTextText display with typewriter effect
SwitchToggle switch control
TableData table with headers, columns, sorting
TabsTabbed container with keyboard navigation
TerminalANSI terminal emulator with PTY support
TextText display with alignment, wrapping
TextareaMulti-line text editor
TextboxSingle-line text input
TextEditingText editing utilities
ToastToast notification popup
TreeHierarchical tree view with expand/collapse
VideoVideo playback widget
Viewport3d3D scene renderer
VirtualizedListEfficient list for large datasets

Components

blECSd provides ECS components that work with any bitECS world. Each component has a corresponding namespace object for typed access:

import { position, content, list, scroll } from 'blecsd/components';

position.set(world, eid, 10, 5);       // set x, y
content.set(world, eid, 'Hello');       // set text content
list.select(world, eid, 2);            // select item at index
scroll.toBottom(world, eid);           // scroll to end
ComponentNamespacePurpose
AnimationanimationFrame-based sprite animations
BorderborderBox borders (single, double, rounded, bold, ascii)
CameracameraViewport, target following, bounds
CollisioncollisionAABB/circle collision detection, layers, triggers
ContentcontentText content, alignment, wrapping, tag parsing
DimensionsdimensionsWidth, height, min/max constraints, percentages
FocusablefocusKeyboard focus, tab order
HierarchyhierarchyParent-child relationships, traversal
ListlistList widget state, selection, virtualization
PositionpositionX/Y coordinates, z-index, absolute positioning
RenderablerenderableColors, visibility, dirty tracking
ScrollablescrollScroll position, scrollbars, virtual viewport
TabletableTable state, columns, rows, sorting
TextInputtextInputText input, cursor, selection, validation
VelocityvelocityMovement with speed, friction, max speed

See API Reference for the complete list of all 41 components.

Systems

SystemPurpose
animationSystemUpdate sprite animations
behaviorSystemExecute behavior trees
cameraSystemUpdate camera following target
collisionSystemDetect and resolve collisions
dragSystemHandle drag and drop
focusSystemManage focus, tab navigation
frameBudgetFrame time profiling and budget management
inputSystemProcess keyboard/mouse input
layoutSystemCalculate positions, dimensions
movementSystemApply velocity to position
outputSystemWrite buffer to terminal
panelMovementHandle panel drag/resize
particleSystemUpdate particle effects
renderSystemRender entities to screen buffer
smoothScrollSmooth scrolling animations
spatialHashSpatial partitioning for collision
stateMachineSystemProcess state machine transitions
tilemapRendererRender tilemap layers
virtualizedRenderSystemEfficient rendering for large datasets
visibilityCullingFrustum/viewport culling
workerPoolBackground task processing

Library Design

blECSd is a library, not a framework:

  • Components work standalone: Import them into any bitECS world
  • No required update loop: All systems are callable functions
  • Mix and match: Use our input parsing with your rendering, or vice versa
  • You own the world: Functions take world as a parameter; we never hold global state
import { createWorld, addEntity } from 'blecsd/core';
import { createDirtyTracker } from 'blecsd/core';
import { layoutSystem, renderSystem, outputSystem, setOutputStream, setOutputBuffer, setRenderBuffer } from 'blecsd/systems';
import { createDoubleBuffer, getBackBuffer } from 'blecsd/terminal';
import { position, renderable } from 'blecsd/components';

const world = createWorld();
const eid = addEntity(world);

// Use namespace helpers for typed access
position.set(world, eid, 10, 5);
renderable.show(world, eid);

// Initialize buffers (required for render/output systems)
setOutputStream(process.stdout);
const db = createDoubleBuffer(80, 24);
setOutputBuffer(db);
setRenderBuffer(createDirtyTracker(80, 24), getBackBuffer(db));

// Call systems when you want
layoutSystem(world);
renderSystem(world);
outputSystem(world);

Use Cases

  • Dashboards: System monitors, log viewers, status displays
  • File Managers: Tree views, virtualized lists, panels
  • CLI Tools: Forms, menus, progress indicators
  • Dev Tools: Debug panels, profilers, inspectors
  • Games: Roguelikes, text adventures, puzzle games
  • AI Interfaces: LLM chat, streaming output, token tracking (via @blecsd/ai)
  • 3D Terminals: Wireframe viewers, model inspectors (via @blecsd/3d)

Comparison

FeatureblECSdInkblessedTextual
ArchitectureECS + PackedStore (data-oriented)React (component)Class-basedWidget classes
LanguageTypeScriptTypeScript/JSXJavaScriptPython
Widgets43 built-inFew built-inMany built-inMany built-in
AnimationPhysics-basedManualManualCSS-like
VirtualizationBuilt-inManualManualBuilt-in
Game supportFirst-classLimitedLimitedLimited

Choose blECSd if you want data-oriented design, physics-based animations, or game development support. Choose Ink for React-style development. Choose Textual for Python projects.

Documentation

Getting Started

API Reference

Guides

Examples

  • Examples Repository: File manager, multiplexer, system monitor, ANSI viewer, telnet server, and more

Development

pnpm install
pnpm test
pnpm lint
pnpm build

Benchmarking

Run performance benchmarks to measure system performance:

# Run all benchmarks
pnpm bench

# Run CI benchmarks (fast subset for regression detection)
pnpm bench:ci

# Run real-world scenario benchmarks
pnpm bench:scenarios

# Update performance baseline
pnpm bench:update-baseline

# Check for performance regressions (vs baseline)
pnpm bench:check-regression

The CI automatically checks for performance regressions on pull requests. If any benchmark regresses by more than 20%, the build will fail.

License

MIT

Keywords

terminal

FAQs

Package last updated on 23 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts