blecsd 0.6.0 → 0.6.2
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.
- package/README.md +50 -28
- package/dist/blend-BZDmQFAm.d.ts +1215 -0
- package/dist/chunk-3PGACJB6.js +1 -0
- package/dist/chunk-4XW4WIPH.js +1 -0
- package/dist/chunk-7CLV3LTZ.js +4 -0
- package/dist/chunk-APPZ3YHO.js +0 -0
- package/dist/chunk-EKE2BXPS.js +1 -0
- package/dist/chunk-ESMSDY3P.js +1 -0
- package/dist/chunk-FJLSHFCF.js +1 -0
- package/dist/chunk-GIMWA5WA.js +1 -0
- package/dist/chunk-IXUFU6TE.js +3 -0
- package/dist/chunk-JB5KFQPD.js +1 -0
- package/dist/chunk-JCLNGU3K.js +1 -0
- package/dist/chunk-JRRJCATR.js +1 -0
- package/dist/{chunk-UKVY43V3.js → chunk-JWIVZCKW.js} +1 -1
- package/dist/chunk-K5UMVDQX.js +1 -0
- package/dist/chunk-L4FIDOS6.js +1 -0
- package/dist/chunk-LIVVHEOU.js +1 -0
- package/dist/chunk-M5FXA5FL.js +1 -0
- package/dist/{chunk-XH5GTWCV.js → chunk-MEJJLDEQ.js} +1 -1
- package/dist/chunk-NYIMY4UV.js +1 -0
- package/dist/chunk-PQZTNWLA.js +1 -0
- package/dist/chunk-SXOBHRXF.js +2 -0
- package/dist/chunk-T2EQLWMN.js +1 -0
- package/dist/chunk-T62UPG63.js +4 -0
- package/dist/chunk-TPBILYDM.js +10 -0
- package/dist/chunk-UWS6FIU5.js +1 -0
- package/dist/{chunk-4N7IFBRQ.js → chunk-W64J7C25.js} +1 -1
- package/dist/chunk-W6RELN6A.js +1 -0
- package/dist/chunk-ZAJI53SZ.js +1 -0
- package/dist/components/index.d.ts +3 -318
- package/dist/components/index.js +5 -5
- package/dist/core/index.d.ts +6 -251
- package/dist/core/index.js +1 -1
- package/dist/debug/index.js +7 -7
- package/dist/{dirtyTracking-kCS9-NVF.d.ts → dirtyTracking-D0SQrEeo.d.ts} +1 -1
- package/dist/{doubleBuffer-CWASihKh.d.ts → doubleBuffer-d9yVNtj1.d.ts} +21 -1
- package/dist/{mouseParser-CCqSEUVN.d.ts → events-CGqK6LGt.d.ts} +1 -176
- package/dist/index.d.ts +10 -9
- package/dist/index.js +1 -1
- package/dist/{inputStream-COARA4CP.d.ts → inputStream-BoFAEJ7g.d.ts} +205 -2
- package/dist/{interactiveSystem-h92W9W4n.d.ts → interactiveSystem-Dtv3xERg.d.ts} +316 -1
- package/dist/mouseParser-CTNGolIA.d.ts +177 -0
- package/dist/{panelMovement-DGzIQ8Ll.d.ts → panelMovement-DSLYdNOL.d.ts} +5 -4
- package/dist/style/index.d.ts +851 -0
- package/dist/style/index.js +1 -0
- package/dist/styleInheritance-CuRb5Dmp.d.ts +251 -0
- package/dist/systems/index.d.ts +6 -5
- package/dist/systems/index.js +1 -1
- package/dist/terminal/index.d.ts +201 -1295
- package/dist/terminal/index.js +1 -1
- package/dist/testing/index.d.ts +923 -0
- package/dist/testing/index.js +7 -0
- package/dist/text/index.js +1 -1
- package/dist/{textWrap-Ct2J8gO6.d.ts → textWrap-sY-PZzE7.d.ts} +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/widgets/bigText.js +1 -1
- package/dist/widgets/fonts/index.js +1 -1
- package/dist/widgets/index.js +18 -18
- package/package.json +16 -2
- package/dist/chunk-5YWRP2KG.js +0 -3
- package/dist/chunk-73Y45MLV.js +0 -12
- package/dist/chunk-A3GSH6MV.js +0 -1
- package/dist/chunk-A5B2BGUM.js +0 -1
- package/dist/chunk-EMZA6G2M.js +0 -4
- package/dist/chunk-ETFDYZVJ.js +0 -1
- package/dist/chunk-IANAVH2A.js +0 -1
- package/dist/chunk-JVMNMAHX.js +0 -1
- package/dist/chunk-K2QWNDXV.js +0 -1
- package/dist/chunk-LI3ZYXUT.js +0 -1
- package/dist/chunk-QABNK7IA.js +0 -1
- package/dist/chunk-QTDRFJG2.js +0 -1
- package/dist/chunk-SVHITP3F.js +0 -2
- package/dist/chunk-VIT4KE6Q.js +0 -1
- package/dist/chunk-XG5PVDOP.js +0 -1
- package/dist/chunk-YRSSCEAS.js +0 -1
- package/dist/chunk-ZL46COQF.js +0 -1
- /package/dist/{chunk-4XCFTNGN.js → chunk-4EV3YS7F.js} +0 -0
package/README.md
CHANGED
|
@@ -30,47 +30,59 @@ npm install blecsd
|
|
|
30
30
|
Create a terminal app with a bordered panel, text, and keyboard input:
|
|
31
31
|
|
|
32
32
|
```typescript
|
|
33
|
+
import { createWorld, createScreenEntity, createBoxEntity, createTextEntity } from 'blecsd/core';
|
|
34
|
+
import { createDirtyTracker } from 'blecsd/core';
|
|
33
35
|
import {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
} from 'blecsd';
|
|
36
|
+
layoutSystem, renderSystem, outputSystem, cleanup,
|
|
37
|
+
setOutputStream, setOutputBuffer, setRenderBuffer,
|
|
38
|
+
} from 'blecsd/systems';
|
|
39
|
+
import { createProgram, createDoubleBuffer, getBackBuffer } from 'blecsd/terminal';
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
const cols = process.stdout.columns ?? 80;
|
|
42
|
+
const rows = process.stdout.rows ?? 24;
|
|
43
|
+
|
|
44
|
+
// 1. Initialize the terminal (alternate screen, hidden cursor, raw mode)
|
|
45
|
+
const program = createProgram();
|
|
46
|
+
await program.init();
|
|
47
|
+
|
|
48
|
+
// 2. Create the ECS world and screen entity
|
|
41
49
|
const world = createWorld();
|
|
42
|
-
|
|
50
|
+
createScreenEntity(world, { width: cols, height: rows });
|
|
51
|
+
|
|
52
|
+
// 3. Wire up the render pipeline buffers
|
|
53
|
+
setOutputStream(process.stdout);
|
|
54
|
+
const db = createDoubleBuffer(cols, rows);
|
|
55
|
+
setOutputBuffer(db);
|
|
56
|
+
setRenderBuffer(createDirtyTracker(cols, rows), getBackBuffer(db));
|
|
43
57
|
|
|
44
|
-
//
|
|
58
|
+
// 4. Build your UI
|
|
45
59
|
const panel = createBoxEntity(world, {
|
|
46
60
|
x: 2, y: 1, width: 40, height: 12,
|
|
47
|
-
parent: screen,
|
|
48
61
|
border: { type: 1, top: true, bottom: true, left: true, right: true },
|
|
49
62
|
});
|
|
50
63
|
|
|
51
|
-
// Title text
|
|
52
64
|
createTextEntity(world, {
|
|
53
|
-
x: 4, y: 2, text: 'My Dashboard', parent:
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
// A selectable list
|
|
57
|
-
const list = createListEntity(world, {
|
|
58
|
-
x: 4, y: 4, width: 36, height: 6, parent: screen,
|
|
65
|
+
x: 4, y: 2, text: 'My Dashboard', parent: panel,
|
|
59
66
|
});
|
|
60
67
|
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
enableKeys(world, screen);
|
|
64
|
-
|
|
65
|
-
function tick(): void {
|
|
66
|
-
inputSystem(world);
|
|
68
|
+
// 5. Render
|
|
69
|
+
function render(): void {
|
|
67
70
|
layoutSystem(world);
|
|
68
71
|
renderSystem(world);
|
|
69
72
|
outputSystem(world);
|
|
70
73
|
}
|
|
71
74
|
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
render();
|
|
76
|
+
|
|
77
|
+
// 6. Handle keyboard input
|
|
78
|
+
program.on('key', (event) => {
|
|
79
|
+
if (event.name === 'q' || (event.ctrl && event.name === 'c')) {
|
|
80
|
+
cleanup(world);
|
|
81
|
+
program.destroy();
|
|
82
|
+
process.exit(0);
|
|
83
|
+
}
|
|
84
|
+
render();
|
|
85
|
+
});
|
|
74
86
|
```
|
|
75
87
|
|
|
76
88
|
## Namespace Imports
|
|
@@ -105,11 +117,11 @@ const parsed = colors.parseColor('#ff6400');
|
|
|
105
117
|
|
|
106
118
|
| Tier | Import Path | Use Case |
|
|
107
119
|
|------|-------------|----------|
|
|
108
|
-
| **Tier
|
|
109
|
-
| **Tier
|
|
120
|
+
| **Tier 2 (Recommended)** | `'blecsd/core'`, `'blecsd/components'`, `'blecsd/systems'`, etc. | Full module access via subpaths |
|
|
121
|
+
| **Tier 1** | `'blecsd'` | Curated subset for small scripts |
|
|
110
122
|
| **Tier 3** | Deep imports | Internal only |
|
|
111
123
|
|
|
112
|
-
|
|
124
|
+
**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](./docs/guides/export-patterns.md) for details.
|
|
113
125
|
|
|
114
126
|
## Addon Packages
|
|
115
127
|
|
|
@@ -264,7 +276,10 @@ blECSd is a library, not a framework:
|
|
|
264
276
|
4. **You own the world**: Functions take `world` as a parameter; we never hold global state
|
|
265
277
|
|
|
266
278
|
```typescript
|
|
267
|
-
import { createWorld, addEntity
|
|
279
|
+
import { createWorld, addEntity } from 'blecsd/core';
|
|
280
|
+
import { createDirtyTracker } from 'blecsd/core';
|
|
281
|
+
import { layoutSystem, renderSystem, outputSystem, setOutputStream, setOutputBuffer, setRenderBuffer } from 'blecsd/systems';
|
|
282
|
+
import { createDoubleBuffer, getBackBuffer } from 'blecsd/terminal';
|
|
268
283
|
import { position, renderable } from 'blecsd/components';
|
|
269
284
|
|
|
270
285
|
const world = createWorld();
|
|
@@ -274,9 +289,16 @@ const eid = addEntity(world);
|
|
|
274
289
|
position.set(world, eid, 10, 5);
|
|
275
290
|
renderable.show(world, eid);
|
|
276
291
|
|
|
292
|
+
// Initialize buffers (required for render/output systems)
|
|
293
|
+
setOutputStream(process.stdout);
|
|
294
|
+
const db = createDoubleBuffer(80, 24);
|
|
295
|
+
setOutputBuffer(db);
|
|
296
|
+
setRenderBuffer(createDirtyTracker(80, 24), getBackBuffer(db));
|
|
297
|
+
|
|
277
298
|
// Call systems when you want
|
|
278
299
|
layoutSystem(world);
|
|
279
300
|
renderSystem(world);
|
|
301
|
+
outputSystem(world);
|
|
280
302
|
```
|
|
281
303
|
|
|
282
304
|
## Use Cases
|