@termuijs/core 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +71 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # @termuijs/core
2
+
3
+ The rendering engine behind TermUI. Handles screen buffers, layout, input parsing, events, and styling.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @termuijs/core
9
+ ```
10
+
11
+ ## What you get
12
+
13
+ - **Screen** - Double-buffered cell grid with diff-based rendering. Only changed cells get written to stdout.
14
+ - **Renderer** - Converts the screen buffer into ANSI escape sequences at 60fps.
15
+ - **LayoutEngine** - Flexbox-based layout: `flexDirection`, `flexGrow`, `flexShrink`, `alignItems`, `justifyContent`, percentage sizing.
16
+ - **InputParser** - Parses raw stdin into typed key and mouse events. Handles escape sequences, Ctrl combos, and multi-byte characters.
17
+ - **EventEmitter** - Typed event system with `on`, `off`, `once`, and `emit`.
18
+ - **FocusManager** - Tab cycling, focus traps for modals, focus groups for arrow-key navigation.
19
+ - **Style** - Color (RGB, hex, named), borders (single, double, rounded, bold), padding, margin.
20
+ - **LayerManager** - Z-indexed overlay layers for modals and dropdowns.
21
+ - **App** - Ties everything together. Mounts widgets, runs the render loop, dispatches input.
22
+
23
+ ## Usage
24
+
25
+ ```typescript
26
+ import { App, Screen, Style } from '@termuijs/core';
27
+
28
+ const app = new App();
29
+
30
+ // Screen is the cell buffer
31
+ const screen = app.screen;
32
+ screen.setCell(0, 0, { char: 'H', fg: 'red' });
33
+
34
+ // Start the render loop
35
+ app.start();
36
+ ```
37
+
38
+ ## Event bubbling
39
+
40
+ Key events bubble from the focused widget up through its parents. You stop propagation at any level.
41
+
42
+ ```typescript
43
+ import { createKeyEvent } from '@termuijs/core';
44
+
45
+ // Events include stopPropagation() and preventDefault()
46
+ widget.on('key', (event) => {
47
+ if (event.key === 'enter') {
48
+ event.stopPropagation();
49
+ // handle it here, parents won't see it
50
+ }
51
+ });
52
+ ```
53
+
54
+ ## Clip regions
55
+
56
+ Widgets clip their children by default. Nothing renders outside a widget's bounds.
57
+
58
+ ```typescript
59
+ // The screen maintains a clip stack
60
+ screen.pushClip({ x: 5, y: 5, width: 20, height: 10 });
61
+ // All setCell calls outside this rect are discarded
62
+ screen.popClip();
63
+ ```
64
+
65
+ ## API reference
66
+
67
+ See the [docs site](https://termuijs.dev/docs/core/overview) for the full API.
68
+
69
+ ## License
70
+
71
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@termuijs/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Core engine for TermUI — terminal adapter, renderer, layout, events, styling",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",