blecsd 0.1.0
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/LICENSE +20 -0
- package/README.md +220 -0
- package/dist/3d/index.d.ts +5 -0
- package/dist/3d/index.js +1 -0
- package/dist/audio/index.d.ts +177 -0
- package/dist/audio/index.js +1 -0
- package/dist/border-D_Jb4ZJV.d.ts +257 -0
- package/dist/cell-DwIu2ryP.d.ts +505 -0
- package/dist/chunk-2UBBZFE4.js +1 -0
- package/dist/chunk-35LCBY6P.js +1 -0
- package/dist/chunk-3B7MIVW6.js +1 -0
- package/dist/chunk-3EGGGI5J.js +3 -0
- package/dist/chunk-4LWWONFK.js +1 -0
- package/dist/chunk-4X4N4HNQ.js +2 -0
- package/dist/chunk-5PELJRUQ.js +1 -0
- package/dist/chunk-AEJIX2MW.js +1 -0
- package/dist/chunk-AQ7LW75B.js +1 -0
- package/dist/chunk-AXZQAH4X.js +1 -0
- package/dist/chunk-B6Z2JFRY.js +1 -0
- package/dist/chunk-BCADUCOZ.js +1 -0
- package/dist/chunk-C5PCEQ6G.js +1 -0
- package/dist/chunk-CIK4AMUA.js +1 -0
- package/dist/chunk-DNRXW56C.js +1 -0
- package/dist/chunk-FC5FFAAC.js +12 -0
- package/dist/chunk-FGHEFXLK.js +1 -0
- package/dist/chunk-FYEBZAWN.js +1 -0
- package/dist/chunk-G7GIWWLE.js +1 -0
- package/dist/chunk-GYHI26UE.js +1 -0
- package/dist/chunk-H2YAOJDW.js +1 -0
- package/dist/chunk-J4JZ2NU2.js +1 -0
- package/dist/chunk-JKVHO4LH.js +1 -0
- package/dist/chunk-K2B2OXQ5.js +5 -0
- package/dist/chunk-K37L3G4Z.js +4 -0
- package/dist/chunk-KD55INV7.js +1 -0
- package/dist/chunk-KFAK4A3G.js +1 -0
- package/dist/chunk-LCN2ZITE.js +1 -0
- package/dist/chunk-LYSK5S63.js +1 -0
- package/dist/chunk-NZ55KBM6.js +1 -0
- package/dist/chunk-OMMJ7B5P.js +1 -0
- package/dist/chunk-OUXUPF3V.js +33 -0
- package/dist/chunk-OVT2PPGW.js +19 -0
- package/dist/chunk-P6CJO3BC.js +1 -0
- package/dist/chunk-PSXXMBVJ.js +1 -0
- package/dist/chunk-PXXGH3BV.js +1 -0
- package/dist/chunk-QIKIOVP2.js +1 -0
- package/dist/chunk-SHUC6JWA.js +1 -0
- package/dist/chunk-TDXJDLY6.js +6 -0
- package/dist/chunk-TWSWTBYL.js +1 -0
- package/dist/chunk-TYMY2TBR.js +3 -0
- package/dist/chunk-VNZ6CWJA.js +2 -0
- package/dist/chunk-VOCM5T2G.js +5 -0
- package/dist/chunk-W5OU7Z6J.js +1 -0
- package/dist/chunk-WNG4A3K7.js +4 -0
- package/dist/chunk-XQIGERNI.js +1 -0
- package/dist/chunk-XZA63ZPO.js +1 -0
- package/dist/chunk-YAMOSPWB.js +4 -0
- package/dist/chunk-YD6ULIUR.js +1 -0
- package/dist/chunk-Z4EZERNE.js +1 -0
- package/dist/cli/init.d.ts +86 -0
- package/dist/cli/init.js +179 -0
- package/dist/color-B78w3zH-.d.ts +79 -0
- package/dist/components/index.d.ts +10298 -0
- package/dist/components/index.js +1 -0
- package/dist/core/index.d.ts +6700 -0
- package/dist/core/index.js +1 -0
- package/dist/debug/index.d.ts +711 -0
- package/dist/debug/index.js +1 -0
- package/dist/doubleBuffer-CKQFmlPN.d.ts +95 -0
- package/dist/errors/index.d.ts +1110 -0
- package/dist/errors/index.js +1 -0
- package/dist/events-BbbxkgvX.d.ts +125 -0
- package/dist/game/index.d.ts +486 -0
- package/dist/game/index.js +1 -0
- package/dist/gameLoop-BIPW7-OY.d.ts +219 -0
- package/dist/index-zSGJ2eUk.d.ts +3156 -0
- package/dist/index.d.ts +246 -0
- package/dist/index.js +1 -0
- package/dist/input/index.d.ts +158 -0
- package/dist/input/index.js +1 -0
- package/dist/inputActions-CefRUBuT.d.ts +2637 -0
- package/dist/keyParser-Bwm8-l7v.d.ts +229 -0
- package/dist/mouseParser-Cfrbn3AX.d.ts +177 -0
- package/dist/parser-iMHmQuUh.d.ts +265 -0
- package/dist/program-BZaKqDKH.d.ts +141 -0
- package/dist/renderable-jTMOA-GK.d.ts +302 -0
- package/dist/scheduler-DcfoFuum.d.ts +86 -0
- package/dist/schemas/index.d.ts +936 -0
- package/dist/schemas/index.js +1 -0
- package/dist/systems/index.d.ts +4036 -0
- package/dist/systems/index.js +1 -0
- package/dist/terminal/index.d.ts +7357 -0
- package/dist/terminal/index.js +1 -0
- package/dist/terminus-14-bold-HWSPRLJD.js +1 -0
- package/dist/terminus-14-normal-T3SWMH4D.js +1 -0
- package/dist/tilemap-D1HJvKy3.d.ts +1211 -0
- package/dist/types-BcsvoKzf.d.ts +68 -0
- package/dist/utils/index.d.ts +6104 -0
- package/dist/utils/index.js +1 -0
- package/dist/viewport3d-xI33-_wq.d.ts +182 -0
- package/dist/virtualScrollback-DvZTRU8a.d.ts +274 -0
- package/dist/virtualViewport-Dx2iJliO.d.ts +2334 -0
- package/dist/virtualizedLineStore-DwPEvPkk.d.ts +297 -0
- package/dist/widgets/bigText.d.ts +230 -0
- package/dist/widgets/bigText.js +1 -0
- package/dist/widgets/fonts/index.d.ts +211 -0
- package/dist/widgets/fonts/index.js +1 -0
- package/dist/widgets/index.d.ts +8591 -0
- package/dist/widgets/index.js +1 -0
- package/package.json +213 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as BLECSD_ERROR_SYMBOL,k as BlECSdErrorCode,f as ComponentErrorCode,i as ConfigErrorCode,e as EntityErrorCode,g as InputErrorCode,j as InternalErrorCode,h as RenderErrorCode,d as SystemErrorCode,c as TerminalErrorCode,b as ValidationErrorCode,p as createComponentError,s as createConfigError,o as createEntityError,q as createInputError,t as createInternalError,r as createRenderError,n as createSystemError,m as createTerminalError,l as createValidationError,O as err,W as flatMap,v as fromNativeError,J as hasBlECSdErrorShape,L as hasCause,K as hasContext,H as hasErrorCode,M as hasZodIssues,I as isBlECSdError,B as isComponentError,E as isConfigError,A as isEntityError,Q as isErr,G as isErrorKind,C as isInputError,F as isInternalError,P as isOk,D as isRenderError,z as isSystemError,y as isTerminalError,x as isValidationError,U as map,V as mapError,N as ok,u as toNativeError,R as unwrap,S as unwrapOr,T as unwrapOrElse,w as wrapError}from'../chunk-3B7MIVW6.js';import'../chunk-5PELJRUQ.js';
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { U as Unsubscribe } from './types-BcsvoKzf.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Typed EventEmitter implementation for type-safe event handling
|
|
5
|
+
* @module core/events
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Generic event handler type.
|
|
10
|
+
* Takes the event payload and returns nothing.
|
|
11
|
+
*/
|
|
12
|
+
type EventHandler<T> = (event: T) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Base event map type constraint.
|
|
15
|
+
* Any object type mapping event names to payload types satisfies this constraint.
|
|
16
|
+
* You don't need to explicitly extend this; any interface with string keys works.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // This works automatically:
|
|
21
|
+
* interface MyEvents {
|
|
22
|
+
* 'player:moved': { x: number; y: number };
|
|
23
|
+
* 'game:over': { score: number };
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
type EventMap = Record<string, any>;
|
|
28
|
+
/**
|
|
29
|
+
* UI events emitted by interactive elements.
|
|
30
|
+
*/
|
|
31
|
+
interface UIEventMap {
|
|
32
|
+
click: {
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
button: number;
|
|
36
|
+
};
|
|
37
|
+
keypress: {
|
|
38
|
+
key: string;
|
|
39
|
+
ctrl: boolean;
|
|
40
|
+
meta: boolean;
|
|
41
|
+
shift: boolean;
|
|
42
|
+
};
|
|
43
|
+
focus: {
|
|
44
|
+
target: unknown;
|
|
45
|
+
};
|
|
46
|
+
blur: {
|
|
47
|
+
target: unknown;
|
|
48
|
+
};
|
|
49
|
+
mouseenter: {
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
};
|
|
53
|
+
mouseleave: {
|
|
54
|
+
x: number;
|
|
55
|
+
y: number;
|
|
56
|
+
};
|
|
57
|
+
mousemove: {
|
|
58
|
+
x: number;
|
|
59
|
+
y: number;
|
|
60
|
+
};
|
|
61
|
+
mousedown: {
|
|
62
|
+
x: number;
|
|
63
|
+
y: number;
|
|
64
|
+
button: number;
|
|
65
|
+
};
|
|
66
|
+
mouseup: {
|
|
67
|
+
x: number;
|
|
68
|
+
y: number;
|
|
69
|
+
button: number;
|
|
70
|
+
};
|
|
71
|
+
scroll: {
|
|
72
|
+
direction: 'up' | 'down';
|
|
73
|
+
amount: number;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Screen-level events.
|
|
78
|
+
*/
|
|
79
|
+
interface ScreenEventMap {
|
|
80
|
+
resize: {
|
|
81
|
+
width: number;
|
|
82
|
+
height: number;
|
|
83
|
+
};
|
|
84
|
+
render: {
|
|
85
|
+
frameTime: number;
|
|
86
|
+
};
|
|
87
|
+
destroy: Record<string, never>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Type-safe EventBus interface.
|
|
91
|
+
*
|
|
92
|
+
* @typeParam T - Event map defining event names and payload types
|
|
93
|
+
*/
|
|
94
|
+
interface EventBus<T extends EventMap> {
|
|
95
|
+
on<K extends keyof T>(event: K, handler: EventHandler<T[K]>): Unsubscribe;
|
|
96
|
+
once<K extends keyof T>(event: K, handler: EventHandler<T[K]>): Unsubscribe;
|
|
97
|
+
off<K extends keyof T>(event: K, handler: EventHandler<T[K]>): EventBus<T>;
|
|
98
|
+
emit<K extends keyof T>(event: K, payload: T[K]): boolean;
|
|
99
|
+
removeAllListeners<K extends keyof T>(event?: K): EventBus<T>;
|
|
100
|
+
listenerCount<K extends keyof T>(event: K): number;
|
|
101
|
+
eventNames(): Array<keyof T>;
|
|
102
|
+
hasListeners<K extends keyof T>(event: K): boolean;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Create a new type-safe event bus.
|
|
106
|
+
*
|
|
107
|
+
* @typeParam T - Event map defining event names and payload types
|
|
108
|
+
* @returns A new EventBus instance
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* import { createEventBus } from 'blecsd';
|
|
113
|
+
*
|
|
114
|
+
* interface GameEvents {
|
|
115
|
+
* 'enemy:spawn': { type: string; x: number; y: number };
|
|
116
|
+
* 'player:death': { cause: string };
|
|
117
|
+
* }
|
|
118
|
+
*
|
|
119
|
+
* const events = createEventBus<GameEvents>();
|
|
120
|
+
* events.on('enemy:spawn', (e) => console.log(`${e.type} at ${e.x}, ${e.y}`));
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
declare function createEventBus<T extends EventMap>(): EventBus<T>;
|
|
124
|
+
|
|
125
|
+
export { type EventBus as E, type ScreenEventMap as S, type UIEventMap as U, type EventHandler as a, type EventMap as b, createEventBus as c };
|
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { I as InputEventBufferData, a as InputState, B as BoxConfig, T as TextConfig, b as ButtonConfig, c as InputConfig, d as TextareaConfig, e as TextboxConfig, C as CheckboxConfig, R as RadioButtonConfig, f as RadioSetConfig, S as SelectConfig, g as SliderConfig, P as ProgressBarConfig, L as ListConfig, F as FormConfig, A as ActionBinding } from '../inputActions-CefRUBuT.js';
|
|
3
|
+
import { G as GameLoop, L as LoopStats } from '../gameLoop-BIPW7-OY.js';
|
|
4
|
+
import { W as World, E as Entity, U as Unsubscribe, L as LoopPhase, S as System } from '../types-BcsvoKzf.js';
|
|
5
|
+
import { M as MouseEvent } from '../mouseParser-Cfrbn3AX.js';
|
|
6
|
+
import { K as KeyEvent } from '../program-BZaKqDKH.js';
|
|
7
|
+
import { K as KeyName } from '../keyParser-Bwm8-l7v.js';
|
|
8
|
+
import '../border-D_Jb4ZJV.js';
|
|
9
|
+
import '../scheduler-DcfoFuum.js';
|
|
10
|
+
import 'bitecs';
|
|
11
|
+
import 'node:stream';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* High-level Game API for blECSd
|
|
15
|
+
*
|
|
16
|
+
* This module provides a simplified interface for creating terminal games.
|
|
17
|
+
* It wraps the ECS implementation with a more intuitive API.
|
|
18
|
+
*
|
|
19
|
+
* @module game
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { createGame } from 'blecsd';
|
|
24
|
+
*
|
|
25
|
+
* const game = createGame({
|
|
26
|
+
* title: 'My Game',
|
|
27
|
+
* width: 80,
|
|
28
|
+
* height: 24,
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* // Create UI elements
|
|
32
|
+
* const box = game.createBox({ x: 5, y: 2, width: 20, height: 10 });
|
|
33
|
+
* const text = game.createText({ x: 6, y: 3, text: 'Hello World!' });
|
|
34
|
+
*
|
|
35
|
+
* // Handle input
|
|
36
|
+
* game.onKey('q', () => game.quit());
|
|
37
|
+
* game.onKey('space', () => console.log('Space pressed!'));
|
|
38
|
+
*
|
|
39
|
+
* // Game loop hooks
|
|
40
|
+
* game.onUpdate((dt) => {
|
|
41
|
+
* // Game logic here
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* // Start the game
|
|
45
|
+
* game.start();
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Game configuration schema.
|
|
51
|
+
*/
|
|
52
|
+
declare const GameConfigSchema: z.ZodObject<{
|
|
53
|
+
title: z.ZodOptional<z.ZodString>;
|
|
54
|
+
width: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
55
|
+
height: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
56
|
+
targetFPS: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
57
|
+
mouse: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
58
|
+
alternateScreen: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
59
|
+
hideCursor: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
60
|
+
fixedTimestep: z.ZodOptional<z.ZodObject<{
|
|
61
|
+
tickRate: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
62
|
+
maxUpdatesPerFrame: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
63
|
+
interpolate: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
64
|
+
}, z.core.$strip>>;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
/**
|
|
67
|
+
* Game configuration type.
|
|
68
|
+
*/
|
|
69
|
+
type GameConfig = z.input<typeof GameConfigSchema>;
|
|
70
|
+
/**
|
|
71
|
+
* Resolved game configuration with defaults applied.
|
|
72
|
+
*/
|
|
73
|
+
type ResolvedGameConfig = z.output<typeof GameConfigSchema>;
|
|
74
|
+
/**
|
|
75
|
+
* Key event handler function.
|
|
76
|
+
*/
|
|
77
|
+
type KeyHandler = (event: KeyEvent) => void;
|
|
78
|
+
/**
|
|
79
|
+
* Mouse event handler function.
|
|
80
|
+
*/
|
|
81
|
+
type MouseHandler = (event: MouseEvent) => void;
|
|
82
|
+
/**
|
|
83
|
+
* Update callback function.
|
|
84
|
+
* @param deltaTime - Time since last frame in seconds
|
|
85
|
+
*/
|
|
86
|
+
type UpdateCallback = (deltaTime: number) => void;
|
|
87
|
+
/**
|
|
88
|
+
* Fixed update callback function.
|
|
89
|
+
* @param deltaTime - Fixed delta time in seconds
|
|
90
|
+
* @param tick - Current tick number
|
|
91
|
+
*/
|
|
92
|
+
type FixedUpdateCallback = (deltaTime: number, tick: number) => void;
|
|
93
|
+
/**
|
|
94
|
+
* Render callback function.
|
|
95
|
+
* @param alpha - Interpolation factor (0-1) for smooth rendering
|
|
96
|
+
*/
|
|
97
|
+
type RenderCallback = (alpha: number) => void;
|
|
98
|
+
/**
|
|
99
|
+
* Game instance returned by createGame.
|
|
100
|
+
* Provides a high-level API for creating terminal games.
|
|
101
|
+
*/
|
|
102
|
+
interface Game {
|
|
103
|
+
/**
|
|
104
|
+
* The underlying ECS world.
|
|
105
|
+
* Use this for advanced ECS operations.
|
|
106
|
+
*/
|
|
107
|
+
readonly world: World;
|
|
108
|
+
/**
|
|
109
|
+
* The game configuration.
|
|
110
|
+
*/
|
|
111
|
+
readonly config: ResolvedGameConfig;
|
|
112
|
+
/**
|
|
113
|
+
* The root screen entity.
|
|
114
|
+
*/
|
|
115
|
+
readonly screen: Entity;
|
|
116
|
+
/**
|
|
117
|
+
* The game loop instance.
|
|
118
|
+
*/
|
|
119
|
+
readonly loop: GameLoop;
|
|
120
|
+
/**
|
|
121
|
+
* The input buffer for raw input events.
|
|
122
|
+
*/
|
|
123
|
+
readonly inputBuffer: InputEventBufferData;
|
|
124
|
+
/**
|
|
125
|
+
* The input state tracker.
|
|
126
|
+
*/
|
|
127
|
+
readonly inputState: InputState;
|
|
128
|
+
/**
|
|
129
|
+
* Creates a box entity.
|
|
130
|
+
*
|
|
131
|
+
* @param config - Box configuration
|
|
132
|
+
* @returns The created entity ID
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* const box = game.createBox({
|
|
137
|
+
* x: 5, y: 2,
|
|
138
|
+
* width: 20, height: 10,
|
|
139
|
+
* border: { type: 1 },
|
|
140
|
+
* style: { fg: 0xff0000ff }
|
|
141
|
+
* });
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
createBox(config?: BoxConfig): Entity;
|
|
145
|
+
/**
|
|
146
|
+
* Creates a text entity.
|
|
147
|
+
*
|
|
148
|
+
* @param config - Text configuration
|
|
149
|
+
* @returns The created entity ID
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* const text = game.createText({
|
|
154
|
+
* x: 10, y: 5,
|
|
155
|
+
* text: 'Hello World!',
|
|
156
|
+
* style: { bold: true }
|
|
157
|
+
* });
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
createText(config?: TextConfig): Entity;
|
|
161
|
+
/**
|
|
162
|
+
* Creates a button entity.
|
|
163
|
+
*
|
|
164
|
+
* @param config - Button configuration
|
|
165
|
+
* @returns The created entity ID
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* const button = game.createButton({
|
|
170
|
+
* x: 5, y: 10,
|
|
171
|
+
* text: 'Click Me',
|
|
172
|
+
* onPress: () => console.log('Pressed!')
|
|
173
|
+
* });
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
createButton(config?: ButtonConfig): Entity;
|
|
177
|
+
/**
|
|
178
|
+
* Creates a text input entity.
|
|
179
|
+
*
|
|
180
|
+
* @param config - Input configuration
|
|
181
|
+
* @returns The created entity ID
|
|
182
|
+
*/
|
|
183
|
+
createInput(config?: InputConfig): Entity;
|
|
184
|
+
/**
|
|
185
|
+
* Creates a textarea entity.
|
|
186
|
+
*
|
|
187
|
+
* @param config - Textarea configuration
|
|
188
|
+
* @returns The created entity ID
|
|
189
|
+
*/
|
|
190
|
+
createTextarea(config?: TextareaConfig): Entity;
|
|
191
|
+
/**
|
|
192
|
+
* Creates a textbox entity.
|
|
193
|
+
*
|
|
194
|
+
* @param config - Textbox configuration
|
|
195
|
+
* @returns The created entity ID
|
|
196
|
+
*/
|
|
197
|
+
createTextbox(config?: TextboxConfig): Entity;
|
|
198
|
+
/**
|
|
199
|
+
* Creates a checkbox entity.
|
|
200
|
+
*
|
|
201
|
+
* @param config - Checkbox configuration
|
|
202
|
+
* @returns The created entity ID
|
|
203
|
+
*/
|
|
204
|
+
createCheckbox(config?: CheckboxConfig): Entity;
|
|
205
|
+
/**
|
|
206
|
+
* Creates a radio button entity.
|
|
207
|
+
*
|
|
208
|
+
* @param config - Radio button configuration
|
|
209
|
+
* @returns The created entity ID
|
|
210
|
+
*/
|
|
211
|
+
createRadioButton(config?: RadioButtonConfig): Entity;
|
|
212
|
+
/**
|
|
213
|
+
* Creates a radio set entity.
|
|
214
|
+
*
|
|
215
|
+
* @param config - Radio set configuration
|
|
216
|
+
* @returns The created entity ID
|
|
217
|
+
*/
|
|
218
|
+
createRadioSet(config?: RadioSetConfig): Entity;
|
|
219
|
+
/**
|
|
220
|
+
* Creates a select dropdown entity.
|
|
221
|
+
*
|
|
222
|
+
* @param config - Select configuration
|
|
223
|
+
* @returns The created entity ID
|
|
224
|
+
*/
|
|
225
|
+
createSelect(config?: SelectConfig): Entity;
|
|
226
|
+
/**
|
|
227
|
+
* Creates a slider entity.
|
|
228
|
+
*
|
|
229
|
+
* @param config - Slider configuration
|
|
230
|
+
* @returns The created entity ID
|
|
231
|
+
*/
|
|
232
|
+
createSlider(config?: SliderConfig): Entity;
|
|
233
|
+
/**
|
|
234
|
+
* Creates a progress bar entity.
|
|
235
|
+
*
|
|
236
|
+
* @param config - Progress bar configuration
|
|
237
|
+
* @returns The created entity ID
|
|
238
|
+
*/
|
|
239
|
+
createProgressBar(config?: ProgressBarConfig): Entity;
|
|
240
|
+
/**
|
|
241
|
+
* Creates a list entity.
|
|
242
|
+
*
|
|
243
|
+
* @param config - List configuration
|
|
244
|
+
* @returns The created entity ID
|
|
245
|
+
*/
|
|
246
|
+
createList(config?: ListConfig): Entity;
|
|
247
|
+
/**
|
|
248
|
+
* Creates a form entity.
|
|
249
|
+
*
|
|
250
|
+
* @param config - Form configuration
|
|
251
|
+
* @returns The created entity ID
|
|
252
|
+
*/
|
|
253
|
+
createForm(config?: FormConfig): Entity;
|
|
254
|
+
/**
|
|
255
|
+
* Registers a handler for a specific key.
|
|
256
|
+
*
|
|
257
|
+
* @param key - The key to listen for (e.g., 'q', 'escape', 'space')
|
|
258
|
+
* @param handler - The callback function
|
|
259
|
+
* @returns Function to unsubscribe the handler
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```typescript
|
|
263
|
+
* const unsub = game.onKey('q', () => game.quit());
|
|
264
|
+
* const unsub2 = game.onKey('escape', () => showMenu());
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
onKey(key: KeyName | string, handler: KeyHandler): Unsubscribe;
|
|
268
|
+
/**
|
|
269
|
+
* Registers a handler for any key press.
|
|
270
|
+
*
|
|
271
|
+
* @param handler - The callback function
|
|
272
|
+
* @returns Function to unsubscribe the handler
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```typescript
|
|
276
|
+
* game.onAnyKey((event) => {
|
|
277
|
+
* console.log(`Key pressed: ${event.name}`);
|
|
278
|
+
* });
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
onAnyKey(handler: KeyHandler): Unsubscribe;
|
|
282
|
+
/**
|
|
283
|
+
* Registers a handler for mouse events.
|
|
284
|
+
*
|
|
285
|
+
* @param handler - The callback function
|
|
286
|
+
* @returns Function to unsubscribe the handler
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* ```typescript
|
|
290
|
+
* game.onMouse((event) => {
|
|
291
|
+
* console.log(`Mouse at ${event.x}, ${event.y}`);
|
|
292
|
+
* });
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
onMouse(handler: MouseHandler): Unsubscribe;
|
|
296
|
+
/**
|
|
297
|
+
* Defines input action mappings.
|
|
298
|
+
*
|
|
299
|
+
* @param bindings - Array of action bindings
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```typescript
|
|
303
|
+
* game.defineActions([
|
|
304
|
+
* { action: 'jump', keys: ['space', 'w'] },
|
|
305
|
+
* { action: 'shoot', keys: ['f'], mouseButtons: ['left'] },
|
|
306
|
+
* ]);
|
|
307
|
+
*
|
|
308
|
+
* // Later, check action state
|
|
309
|
+
* if (game.isActionActive('jump')) {
|
|
310
|
+
* player.jump();
|
|
311
|
+
* }
|
|
312
|
+
* ```
|
|
313
|
+
*/
|
|
314
|
+
defineActions(bindings: readonly ActionBinding[]): void;
|
|
315
|
+
/**
|
|
316
|
+
* Checks if an action is currently active.
|
|
317
|
+
*
|
|
318
|
+
* @param action - The action name
|
|
319
|
+
* @returns true if the action is active
|
|
320
|
+
*/
|
|
321
|
+
isActionActive(action: string): boolean;
|
|
322
|
+
/**
|
|
323
|
+
* Checks if a key is currently held down.
|
|
324
|
+
*
|
|
325
|
+
* @param key - The key to check
|
|
326
|
+
* @returns true if the key is held
|
|
327
|
+
*/
|
|
328
|
+
isKeyDown(key: KeyName | string): boolean;
|
|
329
|
+
/**
|
|
330
|
+
* Registers an update callback.
|
|
331
|
+
* Called every frame with variable delta time.
|
|
332
|
+
*
|
|
333
|
+
* @param callback - The update function
|
|
334
|
+
* @returns Function to unsubscribe
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* ```typescript
|
|
338
|
+
* game.onUpdate((dt) => {
|
|
339
|
+
* player.x += player.velocity * dt;
|
|
340
|
+
* });
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
onUpdate(callback: UpdateCallback): Unsubscribe;
|
|
344
|
+
/**
|
|
345
|
+
* Registers a fixed update callback.
|
|
346
|
+
* Called at a fixed rate for deterministic physics.
|
|
347
|
+
* Only works when fixedTimestep is configured.
|
|
348
|
+
*
|
|
349
|
+
* @param callback - The fixed update function
|
|
350
|
+
* @returns Function to unsubscribe
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* ```typescript
|
|
354
|
+
* game.onFixedUpdate((dt, tick) => {
|
|
355
|
+
* physics.step(dt);
|
|
356
|
+
* });
|
|
357
|
+
* ```
|
|
358
|
+
*/
|
|
359
|
+
onFixedUpdate(callback: FixedUpdateCallback): Unsubscribe;
|
|
360
|
+
/**
|
|
361
|
+
* Registers a render callback.
|
|
362
|
+
* Called after update with interpolation alpha.
|
|
363
|
+
*
|
|
364
|
+
* @param callback - The render function
|
|
365
|
+
* @returns Function to unsubscribe
|
|
366
|
+
*
|
|
367
|
+
* @example
|
|
368
|
+
* ```typescript
|
|
369
|
+
* game.onRender((alpha) => {
|
|
370
|
+
* // Interpolate positions for smooth rendering
|
|
371
|
+
* const x = lerp(prevX, currX, alpha);
|
|
372
|
+
* drawSprite(x, y);
|
|
373
|
+
* });
|
|
374
|
+
* ```
|
|
375
|
+
*/
|
|
376
|
+
onRender(callback: RenderCallback): Unsubscribe;
|
|
377
|
+
/**
|
|
378
|
+
* Registers a system to run at a specific loop phase.
|
|
379
|
+
*
|
|
380
|
+
* @param phase - The loop phase
|
|
381
|
+
* @param system - The system function
|
|
382
|
+
* @returns Function to unregister the system
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* ```typescript
|
|
386
|
+
* game.registerSystem(LoopPhase.UPDATE, movementSystem);
|
|
387
|
+
* game.registerSystem(LoopPhase.PHYSICS, collisionSystem);
|
|
388
|
+
* ```
|
|
389
|
+
*/
|
|
390
|
+
registerSystem(phase: LoopPhase, system: System): Unsubscribe;
|
|
391
|
+
/**
|
|
392
|
+
* Starts the game loop.
|
|
393
|
+
*
|
|
394
|
+
* @example
|
|
395
|
+
* ```typescript
|
|
396
|
+
* game.start();
|
|
397
|
+
* ```
|
|
398
|
+
*/
|
|
399
|
+
start(): void;
|
|
400
|
+
/**
|
|
401
|
+
* Stops the game loop.
|
|
402
|
+
*
|
|
403
|
+
* @example
|
|
404
|
+
* ```typescript
|
|
405
|
+
* game.stop();
|
|
406
|
+
* ```
|
|
407
|
+
*/
|
|
408
|
+
stop(): void;
|
|
409
|
+
/**
|
|
410
|
+
* Pauses the game loop.
|
|
411
|
+
* Input is still processed while paused.
|
|
412
|
+
*
|
|
413
|
+
* @example
|
|
414
|
+
* ```typescript
|
|
415
|
+
* game.pause();
|
|
416
|
+
* ```
|
|
417
|
+
*/
|
|
418
|
+
pause(): void;
|
|
419
|
+
/**
|
|
420
|
+
* Resumes the game loop from pause.
|
|
421
|
+
*
|
|
422
|
+
* @example
|
|
423
|
+
* ```typescript
|
|
424
|
+
* game.resume();
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
427
|
+
resume(): void;
|
|
428
|
+
/**
|
|
429
|
+
* Quits the game and performs cleanup.
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* ```typescript
|
|
433
|
+
* game.onKey('q', () => game.quit());
|
|
434
|
+
* ```
|
|
435
|
+
*/
|
|
436
|
+
quit(): void;
|
|
437
|
+
/**
|
|
438
|
+
* Gets the current loop statistics.
|
|
439
|
+
*
|
|
440
|
+
* @returns Current FPS, frame time, etc.
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* ```typescript
|
|
444
|
+
* const stats = game.getStats();
|
|
445
|
+
* console.log(`FPS: ${stats.fps}`);
|
|
446
|
+
* ```
|
|
447
|
+
*/
|
|
448
|
+
getStats(): LoopStats;
|
|
449
|
+
/**
|
|
450
|
+
* Checks if the game is currently running.
|
|
451
|
+
*/
|
|
452
|
+
isRunning(): boolean;
|
|
453
|
+
/**
|
|
454
|
+
* Checks if the game is currently paused.
|
|
455
|
+
*/
|
|
456
|
+
isPaused(): boolean;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Creates a new game instance.
|
|
460
|
+
*
|
|
461
|
+
* @param config - Game configuration
|
|
462
|
+
* @returns A Game instance
|
|
463
|
+
*
|
|
464
|
+
* @example
|
|
465
|
+
* ```typescript
|
|
466
|
+
* import { createGame } from 'blecsd';
|
|
467
|
+
*
|
|
468
|
+
* const game = createGame({
|
|
469
|
+
* title: 'My Game',
|
|
470
|
+
* width: 80,
|
|
471
|
+
* height: 24,
|
|
472
|
+
* });
|
|
473
|
+
*
|
|
474
|
+
* // Create widgets
|
|
475
|
+
* const box = game.createBox({ x: 0, y: 0, width: 80, height: 24 });
|
|
476
|
+
*
|
|
477
|
+
* // Handle input
|
|
478
|
+
* game.onKey('q', () => game.quit());
|
|
479
|
+
*
|
|
480
|
+
* // Start the game
|
|
481
|
+
* game.start();
|
|
482
|
+
* ```
|
|
483
|
+
*/
|
|
484
|
+
declare function createGame(config?: GameConfig): Game;
|
|
485
|
+
|
|
486
|
+
export { type FixedUpdateCallback, type Game, type GameConfig, GameConfigSchema, type KeyHandler, type MouseHandler, type RenderCallback, type ResolvedGameConfig, type UpdateCallback, createGame };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as GameConfigSchema,b as createGame}from'../chunk-2UBBZFE4.js';import'../chunk-4X4N4HNQ.js';import'../chunk-H2YAOJDW.js';import'../chunk-P6CJO3BC.js';import'../chunk-KFAK4A3G.js';import'../chunk-BCADUCOZ.js';import'../chunk-KD55INV7.js';import'../chunk-PSXXMBVJ.js';import'../chunk-LCN2ZITE.js';import'../chunk-FYEBZAWN.js';import'../chunk-W5OU7Z6J.js';import'../chunk-Z4EZERNE.js';import'../chunk-WNG4A3K7.js';import'../chunk-SHUC6JWA.js';import'../chunk-G7GIWWLE.js';import'../chunk-PXXGH3BV.js';import'../chunk-5PELJRUQ.js';
|