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,505 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cell Type and Screen Buffer
|
|
3
|
+
*
|
|
4
|
+
* Provides the fundamental Cell type for terminal rendering and a functional
|
|
5
|
+
* screen buffer implementation for managing a grid of cells.
|
|
6
|
+
*
|
|
7
|
+
* @module terminal/screen/cell
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import {
|
|
12
|
+
* createCell,
|
|
13
|
+
* createScreenBuffer,
|
|
14
|
+
* setCell,
|
|
15
|
+
* getCell,
|
|
16
|
+
* fillRect,
|
|
17
|
+
* Attr,
|
|
18
|
+
* } from 'blecsd';
|
|
19
|
+
*
|
|
20
|
+
* // Create a buffer
|
|
21
|
+
* const buffer = createScreenBuffer(80, 24);
|
|
22
|
+
*
|
|
23
|
+
* // Create a styled cell
|
|
24
|
+
* const cell = createCell('X', 0xff0000ff, 0x000000ff, Attr.BOLD);
|
|
25
|
+
*
|
|
26
|
+
* // Set cells in the buffer
|
|
27
|
+
* setCell(buffer, 10, 5, cell);
|
|
28
|
+
*
|
|
29
|
+
* // Fill a region
|
|
30
|
+
* fillRect(buffer, 0, 0, 80, 1, createCell(' ', 0xffffffff, 0x0000ffff));
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* Text attribute bit flags for cell styling.
|
|
35
|
+
*
|
|
36
|
+
* These can be combined using bitwise OR to apply multiple attributes.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* import { Attr } from 'blecsd';
|
|
41
|
+
*
|
|
42
|
+
* // Single attribute
|
|
43
|
+
* const boldAttr = Attr.BOLD;
|
|
44
|
+
*
|
|
45
|
+
* // Combined attributes
|
|
46
|
+
* const boldUnderline = Attr.BOLD | Attr.UNDERLINE;
|
|
47
|
+
*
|
|
48
|
+
* // Check if attribute is set
|
|
49
|
+
* const isBold = (attrs & Attr.BOLD) !== 0;
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare const Attr: {
|
|
53
|
+
/** No attributes */
|
|
54
|
+
readonly NONE: 0;
|
|
55
|
+
/** Bold text */
|
|
56
|
+
readonly BOLD: number;
|
|
57
|
+
/** Dim/faint text */
|
|
58
|
+
readonly DIM: number;
|
|
59
|
+
/** Italic text */
|
|
60
|
+
readonly ITALIC: number;
|
|
61
|
+
/** Underlined text */
|
|
62
|
+
readonly UNDERLINE: number;
|
|
63
|
+
/** Blinking text */
|
|
64
|
+
readonly BLINK: number;
|
|
65
|
+
/** Inverted colors */
|
|
66
|
+
readonly INVERSE: number;
|
|
67
|
+
/** Hidden/invisible text */
|
|
68
|
+
readonly HIDDEN: number;
|
|
69
|
+
/** Strikethrough text */
|
|
70
|
+
readonly STRIKETHROUGH: number;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Type for attribute flags.
|
|
74
|
+
*/
|
|
75
|
+
type AttrFlags = number;
|
|
76
|
+
/**
|
|
77
|
+
* Represents a single terminal cell.
|
|
78
|
+
*
|
|
79
|
+
* Each cell contains a character (which may be multi-byte for Unicode),
|
|
80
|
+
* foreground and background colors packed as 32-bit RGBA values,
|
|
81
|
+
* and packed text attributes.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* import { Cell, createCell, Attr } from 'blecsd';
|
|
86
|
+
*
|
|
87
|
+
* const cell: Cell = {
|
|
88
|
+
* char: 'A',
|
|
89
|
+
* fg: 0xffffffff, // White
|
|
90
|
+
* bg: 0x000000ff, // Black
|
|
91
|
+
* attrs: Attr.BOLD | Attr.UNDERLINE,
|
|
92
|
+
* };
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
interface Cell {
|
|
96
|
+
/** Character to display (may be multi-byte for Unicode) */
|
|
97
|
+
char: string;
|
|
98
|
+
/** Foreground color (packed 32-bit RGBA) */
|
|
99
|
+
fg: number;
|
|
100
|
+
/** Background color (packed 32-bit RGBA) */
|
|
101
|
+
bg: number;
|
|
102
|
+
/** Packed attribute flags */
|
|
103
|
+
attrs: AttrFlags;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Default foreground color (white, fully opaque).
|
|
107
|
+
*/
|
|
108
|
+
declare const DEFAULT_FG = 4294967295;
|
|
109
|
+
/**
|
|
110
|
+
* Default background color (black, fully opaque).
|
|
111
|
+
*/
|
|
112
|
+
declare const DEFAULT_BG = 255;
|
|
113
|
+
/**
|
|
114
|
+
* Default cell character (space).
|
|
115
|
+
*/
|
|
116
|
+
declare const DEFAULT_CHAR = " ";
|
|
117
|
+
/**
|
|
118
|
+
* Creates a new Cell with the specified properties.
|
|
119
|
+
*
|
|
120
|
+
* @param char - Character to display (default: space)
|
|
121
|
+
* @param fg - Foreground color as packed RGBA (default: white)
|
|
122
|
+
* @param bg - Background color as packed RGBA (default: black)
|
|
123
|
+
* @param attrs - Packed attribute flags (default: none)
|
|
124
|
+
* @returns A new Cell object
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* import { createCell, Attr, DEFAULT_FG, DEFAULT_BG } from 'blecsd';
|
|
129
|
+
*
|
|
130
|
+
* // Default empty cell
|
|
131
|
+
* const empty = createCell();
|
|
132
|
+
*
|
|
133
|
+
* // Red 'X' on black
|
|
134
|
+
* const redX = createCell('X', 0xff0000ff, 0x000000ff);
|
|
135
|
+
*
|
|
136
|
+
* // Bold white 'A' on blue
|
|
137
|
+
* const boldA = createCell('A', 0xffffffff, 0x0000ffff, Attr.BOLD);
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
declare function createCell(char?: string, fg?: number, bg?: number, attrs?: AttrFlags): Cell;
|
|
141
|
+
/**
|
|
142
|
+
* Creates a copy of a cell.
|
|
143
|
+
*
|
|
144
|
+
* @param cell - The cell to clone
|
|
145
|
+
* @returns A new Cell with the same values
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* import { createCell, cloneCell } from 'blecsd';
|
|
150
|
+
*
|
|
151
|
+
* const original = createCell('X', 0xff0000ff);
|
|
152
|
+
* const copy = cloneCell(original);
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
declare function cloneCell(cell: Cell): Cell;
|
|
156
|
+
/**
|
|
157
|
+
* Compares two cells for equality.
|
|
158
|
+
*
|
|
159
|
+
* @param a - First cell
|
|
160
|
+
* @param b - Second cell
|
|
161
|
+
* @returns true if cells are identical
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* import { createCell, cellsEqual } from 'blecsd';
|
|
166
|
+
*
|
|
167
|
+
* const a = createCell('X', 0xff0000ff);
|
|
168
|
+
* const b = createCell('X', 0xff0000ff);
|
|
169
|
+
* console.log(cellsEqual(a, b)); // true
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
declare function cellsEqual(a: Cell, b: Cell): boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Checks if a cell has a specific attribute.
|
|
175
|
+
*
|
|
176
|
+
* @param cell - The cell to check
|
|
177
|
+
* @param attr - The attribute flag to check for
|
|
178
|
+
* @returns true if the attribute is set
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* import { createCell, hasAttr, Attr } from 'blecsd';
|
|
183
|
+
*
|
|
184
|
+
* const cell = createCell('X', 0xffffffff, 0x000000ff, Attr.BOLD | Attr.UNDERLINE);
|
|
185
|
+
* console.log(hasAttr(cell, Attr.BOLD)); // true
|
|
186
|
+
* console.log(hasAttr(cell, Attr.BLINK)); // false
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
declare function hasAttr(cell: Cell, attr: AttrFlags): boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Creates a new cell with an attribute added.
|
|
192
|
+
*
|
|
193
|
+
* @param cell - The original cell
|
|
194
|
+
* @param attr - The attribute to add
|
|
195
|
+
* @returns A new cell with the attribute set
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```typescript
|
|
199
|
+
* import { createCell, withAttr, Attr } from 'blecsd';
|
|
200
|
+
*
|
|
201
|
+
* const cell = createCell('X');
|
|
202
|
+
* const boldCell = withAttr(cell, Attr.BOLD);
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
declare function withAttr(cell: Cell, attr: AttrFlags): Cell;
|
|
206
|
+
/**
|
|
207
|
+
* Creates a new cell with an attribute removed.
|
|
208
|
+
*
|
|
209
|
+
* @param cell - The original cell
|
|
210
|
+
* @param attr - The attribute to remove
|
|
211
|
+
* @returns A new cell with the attribute cleared
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```typescript
|
|
215
|
+
* import { createCell, withoutAttr, Attr } from 'blecsd';
|
|
216
|
+
*
|
|
217
|
+
* const cell = createCell('X', 0xffffffff, 0x000000ff, Attr.BOLD);
|
|
218
|
+
* const normalCell = withoutAttr(cell, Attr.BOLD);
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
declare function withoutAttr(cell: Cell, attr: AttrFlags): Cell;
|
|
222
|
+
/**
|
|
223
|
+
* Screen buffer data structure.
|
|
224
|
+
*
|
|
225
|
+
* Uses a flat array of cells for efficient access. The buffer stores
|
|
226
|
+
* cells in row-major order: index = y * width + x.
|
|
227
|
+
*/
|
|
228
|
+
interface ScreenBufferData {
|
|
229
|
+
/** Buffer width in cells */
|
|
230
|
+
readonly width: number;
|
|
231
|
+
/** Buffer height in cells */
|
|
232
|
+
readonly height: number;
|
|
233
|
+
/** Flat array of cells (row-major order) */
|
|
234
|
+
readonly cells: Cell[];
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Creates a new screen buffer filled with default cells.
|
|
238
|
+
*
|
|
239
|
+
* @param width - Buffer width in cells
|
|
240
|
+
* @param height - Buffer height in cells
|
|
241
|
+
* @param defaultCell - Optional default cell to fill with
|
|
242
|
+
* @returns A new ScreenBufferData
|
|
243
|
+
* @throws {Error} If width or height is not positive
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```typescript
|
|
247
|
+
* import { createScreenBuffer, createCell } from 'blecsd';
|
|
248
|
+
*
|
|
249
|
+
* // Create an 80x24 buffer with default cells
|
|
250
|
+
* const buffer = createScreenBuffer(80, 24);
|
|
251
|
+
*
|
|
252
|
+
* // Create a buffer with custom default cell
|
|
253
|
+
* const blueBuffer = createScreenBuffer(80, 24, createCell(' ', 0xffffffff, 0x0000ffff));
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
declare function createScreenBuffer(width: number, height: number, defaultCell?: Cell): ScreenBufferData;
|
|
257
|
+
/**
|
|
258
|
+
* Calculates the array index for a given x,y position.
|
|
259
|
+
*
|
|
260
|
+
* @param buffer - The screen buffer
|
|
261
|
+
* @param x - X coordinate (column)
|
|
262
|
+
* @param y - Y coordinate (row)
|
|
263
|
+
* @returns The array index, or -1 if out of bounds
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* ```typescript
|
|
267
|
+
* import { createScreenBuffer, cellIndex } from 'blecsd';
|
|
268
|
+
*
|
|
269
|
+
* const buffer = createScreenBuffer(80, 24);
|
|
270
|
+
* const idx = cellIndex(buffer, 10, 5);
|
|
271
|
+
* console.log(idx); // 410 (5 * 80 + 10)
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
declare function cellIndex(buffer: ScreenBufferData, x: number, y: number): number;
|
|
275
|
+
/**
|
|
276
|
+
* Checks if coordinates are within buffer bounds.
|
|
277
|
+
*
|
|
278
|
+
* @param buffer - The screen buffer
|
|
279
|
+
* @param x - X coordinate
|
|
280
|
+
* @param y - Y coordinate
|
|
281
|
+
* @returns true if coordinates are valid
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```typescript
|
|
285
|
+
* import { createScreenBuffer, isInBounds } from 'blecsd';
|
|
286
|
+
*
|
|
287
|
+
* const buffer = createScreenBuffer(80, 24);
|
|
288
|
+
* console.log(isInBounds(buffer, 0, 0)); // true
|
|
289
|
+
* console.log(isInBounds(buffer, 80, 0)); // false (out of bounds)
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
declare function isInBounds(buffer: ScreenBufferData, x: number, y: number): boolean;
|
|
293
|
+
/**
|
|
294
|
+
* Gets a cell from the buffer at the specified position.
|
|
295
|
+
*
|
|
296
|
+
* @param buffer - The screen buffer
|
|
297
|
+
* @param x - X coordinate
|
|
298
|
+
* @param y - Y coordinate
|
|
299
|
+
* @returns The cell at (x, y), or undefined if out of bounds
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```typescript
|
|
303
|
+
* import { createScreenBuffer, getCell, setCell, createCell } from 'blecsd';
|
|
304
|
+
*
|
|
305
|
+
* const buffer = createScreenBuffer(80, 24);
|
|
306
|
+
* setCell(buffer, 10, 5, createCell('X'));
|
|
307
|
+
*
|
|
308
|
+
* const cell = getCell(buffer, 10, 5);
|
|
309
|
+
* console.log(cell?.char); // 'X'
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
declare function getCell(buffer: ScreenBufferData, x: number, y: number): Cell | undefined;
|
|
313
|
+
/**
|
|
314
|
+
* Sets a cell in the buffer at the specified position.
|
|
315
|
+
* Mutates the buffer in place for performance.
|
|
316
|
+
*
|
|
317
|
+
* @param buffer - The screen buffer
|
|
318
|
+
* @param x - X coordinate
|
|
319
|
+
* @param y - Y coordinate
|
|
320
|
+
* @param cell - The cell to set
|
|
321
|
+
* @returns true if the cell was set, false if out of bounds
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* ```typescript
|
|
325
|
+
* import { createScreenBuffer, setCell, createCell, Attr } from 'blecsd';
|
|
326
|
+
*
|
|
327
|
+
* const buffer = createScreenBuffer(80, 24);
|
|
328
|
+
* const success = setCell(buffer, 10, 5, createCell('X', 0xff0000ff, 0x000000ff, Attr.BOLD));
|
|
329
|
+
* console.log(success); // true
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
declare function setCell(buffer: ScreenBufferData, x: number, y: number, cell: Cell): boolean;
|
|
333
|
+
/**
|
|
334
|
+
* Sets a character at the specified position, preserving other cell properties.
|
|
335
|
+
* Mutates the buffer in place for performance.
|
|
336
|
+
*
|
|
337
|
+
* @param buffer - The screen buffer
|
|
338
|
+
* @param x - X coordinate
|
|
339
|
+
* @param y - Y coordinate
|
|
340
|
+
* @param char - The character to set
|
|
341
|
+
* @returns true if set, false if out of bounds
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```typescript
|
|
345
|
+
* import { createScreenBuffer, setChar } from 'blecsd';
|
|
346
|
+
*
|
|
347
|
+
* const buffer = createScreenBuffer(80, 24);
|
|
348
|
+
* setChar(buffer, 10, 5, 'X');
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
declare function setChar(buffer: ScreenBufferData, x: number, y: number, char: string): boolean;
|
|
352
|
+
/**
|
|
353
|
+
* Clears the entire buffer to default cells.
|
|
354
|
+
* Mutates the buffer in place.
|
|
355
|
+
*
|
|
356
|
+
* @param buffer - The screen buffer
|
|
357
|
+
* @param clearCell - Optional cell to fill with (default: space with default colors)
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* ```typescript
|
|
361
|
+
* import { createScreenBuffer, clearBuffer, createCell } from 'blecsd';
|
|
362
|
+
*
|
|
363
|
+
* const buffer = createScreenBuffer(80, 24);
|
|
364
|
+
* // ... draw stuff ...
|
|
365
|
+
* clearBuffer(buffer);
|
|
366
|
+
*
|
|
367
|
+
* // Clear to a custom cell
|
|
368
|
+
* clearBuffer(buffer, createCell(' ', 0xffffffff, 0x0000ffff));
|
|
369
|
+
* ```
|
|
370
|
+
*/
|
|
371
|
+
declare function clearBuffer(buffer: ScreenBufferData, clearCell?: Cell): void;
|
|
372
|
+
/**
|
|
373
|
+
* Fills a rectangular region of the buffer with a cell.
|
|
374
|
+
* Mutates the buffer in place. Coordinates are clamped to buffer bounds.
|
|
375
|
+
*
|
|
376
|
+
* @param buffer - The screen buffer
|
|
377
|
+
* @param x - Left edge X coordinate
|
|
378
|
+
* @param y - Top edge Y coordinate
|
|
379
|
+
* @param w - Width of region
|
|
380
|
+
* @param h - Height of region
|
|
381
|
+
* @param cell - Cell to fill with
|
|
382
|
+
*
|
|
383
|
+
* @example
|
|
384
|
+
* ```typescript
|
|
385
|
+
* import { createScreenBuffer, fillRect, createCell } from 'blecsd';
|
|
386
|
+
*
|
|
387
|
+
* const buffer = createScreenBuffer(80, 24);
|
|
388
|
+
*
|
|
389
|
+
* // Fill top row with blue background
|
|
390
|
+
* fillRect(buffer, 0, 0, 80, 1, createCell(' ', 0xffffffff, 0x0000ffff));
|
|
391
|
+
*
|
|
392
|
+
* // Draw a red box at (10, 5) of size 20x5
|
|
393
|
+
* fillRect(buffer, 10, 5, 20, 5, createCell(' ', 0xffffffff, 0xff0000ff));
|
|
394
|
+
* ```
|
|
395
|
+
*/
|
|
396
|
+
declare function fillRect(buffer: ScreenBufferData, x: number, y: number, w: number, h: number, cell: Cell): void;
|
|
397
|
+
/**
|
|
398
|
+
* Resizes a buffer, preserving existing content where possible.
|
|
399
|
+
* Creates a new buffer and copies cells from the old one.
|
|
400
|
+
*
|
|
401
|
+
* @param buffer - The original buffer
|
|
402
|
+
* @param newWidth - New width
|
|
403
|
+
* @param newHeight - New height
|
|
404
|
+
* @param fillCell - Cell to use for newly exposed areas
|
|
405
|
+
* @returns A new resized buffer
|
|
406
|
+
* @throws {Error} If newWidth or newHeight is not positive
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* ```typescript
|
|
410
|
+
* import { createScreenBuffer, resizeBuffer, setCell, createCell } from 'blecsd';
|
|
411
|
+
*
|
|
412
|
+
* const buffer = createScreenBuffer(80, 24);
|
|
413
|
+
* setCell(buffer, 5, 5, createCell('X'));
|
|
414
|
+
*
|
|
415
|
+
* const larger = resizeBuffer(buffer, 120, 40);
|
|
416
|
+
* // Cell at (5, 5) is preserved
|
|
417
|
+
* ```
|
|
418
|
+
*/
|
|
419
|
+
declare function resizeBuffer(buffer: ScreenBufferData, newWidth: number, newHeight: number, fillCell?: Cell): ScreenBufferData;
|
|
420
|
+
/**
|
|
421
|
+
* Writes a string to the buffer starting at the specified position.
|
|
422
|
+
* Multi-byte Unicode characters are handled correctly (each grapheme
|
|
423
|
+
* occupies one cell). Mutates the buffer in place.
|
|
424
|
+
*
|
|
425
|
+
* @param buffer - The screen buffer
|
|
426
|
+
* @param x - Starting X coordinate
|
|
427
|
+
* @param y - Y coordinate
|
|
428
|
+
* @param text - Text to write
|
|
429
|
+
* @param fg - Foreground color (default: white)
|
|
430
|
+
* @param bg - Background color (default: black)
|
|
431
|
+
* @param attrs - Text attributes (default: none)
|
|
432
|
+
* @returns Number of cells written
|
|
433
|
+
*
|
|
434
|
+
* @example
|
|
435
|
+
* ```typescript
|
|
436
|
+
* import { createScreenBuffer, writeString, Attr } from 'blecsd';
|
|
437
|
+
*
|
|
438
|
+
* const buffer = createScreenBuffer(80, 24);
|
|
439
|
+
*
|
|
440
|
+
* // Write white text on black
|
|
441
|
+
* writeString(buffer, 10, 5, 'Hello, World!');
|
|
442
|
+
*
|
|
443
|
+
* // Write bold red text
|
|
444
|
+
* writeString(buffer, 10, 7, 'Warning!', 0xff0000ff, 0x000000ff, Attr.BOLD);
|
|
445
|
+
* ```
|
|
446
|
+
*/
|
|
447
|
+
declare function writeString(buffer: ScreenBufferData, x: number, y: number, text: string, fg?: number, bg?: number, attrs?: AttrFlags): number;
|
|
448
|
+
/**
|
|
449
|
+
* Copies a rectangular region from one buffer to another.
|
|
450
|
+
* Handles overlapping regions correctly.
|
|
451
|
+
*
|
|
452
|
+
* @param src - Source buffer
|
|
453
|
+
* @param dst - Destination buffer
|
|
454
|
+
* @param srcX - Source X coordinate
|
|
455
|
+
* @param srcY - Source Y coordinate
|
|
456
|
+
* @param dstX - Destination X coordinate
|
|
457
|
+
* @param dstY - Destination Y coordinate
|
|
458
|
+
* @param w - Width to copy
|
|
459
|
+
* @param h - Height to copy
|
|
460
|
+
*
|
|
461
|
+
* @example
|
|
462
|
+
* ```typescript
|
|
463
|
+
* import { createScreenBuffer, copyRegion, fillRect, createCell } from 'blecsd';
|
|
464
|
+
*
|
|
465
|
+
* const src = createScreenBuffer(80, 24);
|
|
466
|
+
* const dst = createScreenBuffer(80, 24);
|
|
467
|
+
*
|
|
468
|
+
* // Fill source with pattern
|
|
469
|
+
* fillRect(src, 0, 0, 10, 10, createCell('#', 0xff0000ff, 0x000000ff));
|
|
470
|
+
*
|
|
471
|
+
* // Copy to destination
|
|
472
|
+
* copyRegion(src, dst, 0, 0, 20, 5, 10, 10);
|
|
473
|
+
* ```
|
|
474
|
+
*/
|
|
475
|
+
declare function copyRegion(src: ScreenBufferData, dst: ScreenBufferData, srcX: number, srcY: number, dstX: number, dstY: number, w: number, h: number): void;
|
|
476
|
+
/** A single cell change in a buffer diff */
|
|
477
|
+
interface CellChange {
|
|
478
|
+
readonly x: number;
|
|
479
|
+
readonly y: number;
|
|
480
|
+
readonly cell: Cell;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Computes the difference between two buffers.
|
|
484
|
+
* Returns an array of changed cell positions and their new values.
|
|
485
|
+
* Useful for efficient terminal updates (only output changed cells).
|
|
486
|
+
*
|
|
487
|
+
* @param oldBuffer - Previous buffer state
|
|
488
|
+
* @param newBuffer - Current buffer state
|
|
489
|
+
* @returns Array of { x, y, cell } for changed cells
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* ```typescript
|
|
493
|
+
* import { createScreenBuffer, setCell, createCell, diffBuffers } from 'blecsd';
|
|
494
|
+
*
|
|
495
|
+
* const old = createScreenBuffer(80, 24);
|
|
496
|
+
* const current = createScreenBuffer(80, 24);
|
|
497
|
+
* setCell(current, 10, 5, createCell('X'));
|
|
498
|
+
*
|
|
499
|
+
* const changes = diffBuffers(old, current);
|
|
500
|
+
* // changes = [{ x: 10, y: 5, cell: { char: 'X', ... } }]
|
|
501
|
+
* ```
|
|
502
|
+
*/
|
|
503
|
+
declare function diffBuffers(oldBuffer: ScreenBufferData, newBuffer: ScreenBufferData): CellChange[];
|
|
504
|
+
|
|
505
|
+
export { Attr as A, type Cell as C, DEFAULT_BG as D, type ScreenBufferData as S, type AttrFlags as a, DEFAULT_FG as b, type CellChange as c, DEFAULT_CHAR as d, cellIndex as e, cellsEqual as f, clearBuffer as g, cloneCell as h, copyRegion as i, createCell as j, createScreenBuffer as k, diffBuffers as l, fillRect as m, getCell as n, hasAttr as o, isInBounds as p, setChar as q, resizeBuffer as r, setCell as s, withoutAttr as t, writeString as u, withAttr as w };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {s,M,ja,K,F,A,u,B,z as z$1,y,C,D,v,w,x,t,r,q,p,P,Q}from'./chunk-4X4N4HNQ.js';import {n,a}from'./chunk-PXXGH3BV.js';import {z}from'zod';n();var V=z.object({title:z.string().optional(),width:z.number().int().positive().optional().default(80),height:z.number().int().positive().optional().default(24),targetFPS:z.number().positive().optional().default(60),mouse:z.boolean().optional().default(true),alternateScreen:z.boolean().optional().default(true),hideCursor:z.boolean().optional().default(true),fixedTimestep:z.object({tickRate:z.number().positive().optional().default(60),maxUpdatesPerFrame:z.number().positive().optional().default(5),interpolate:z.boolean().optional().default(true)}).optional()});function ae(b={}){let t=V.parse(b),u=a(),n={width:t.width,height:t.height},r=s(u,n),l=M(),p=ja(),f=K(),i={targetFPS:t.targetFPS};t.fixedTimestep&&(i.fixedTimestepMode={tickRate:t.fixedTimestep.tickRate??60,maxUpdatesPerFrame:t.fixedTimestep.maxUpdatesPerFrame??5,interpolate:t.fixedTimestep.interpolate??true});let y=new Set,c=new Set,d=new Set,C=F(u,i,{onAfterFixedUpdate:(x,g,m)=>{for(let E of c)E(g,m);},onInterpolate:(x,g)=>{for(let m of d)m(g);}});return X({world:u,config:t,screen:r,loop:C,inputBuffer:l,inputState:p,actionManager:f,keyHandlers:new Map,anyKeyHandlers:new Set,mouseHandlers:new Set,updateCallbacks:y,fixedUpdateCallbacks:c,renderCallbacks:d,isQuitting:false})}function X(b){let{world:t$1,config:u$1,screen:n,loop:r$1,inputBuffer:l,inputState:p$1,actionManager:f,keyHandlers:i,anyKeyHandlers:y$1,mouseHandlers:c,updateCallbacks:d,fixedUpdateCallbacks:C$1,renderCallbacks:S}=b;function x$1(e){for(let s of y$1)s(e);let o=i.get(e.name);if(o)for(let s of o)s(e);}function g(e){for(let o of c)o(e);}function m(e){let o=P(l),s=Q(l);for(let v of o)x$1(v.event);for(let v of s)g(v.event);p$1.update(o,s,e),f.update(p$1,e);}function E(){return e=>{let o=r$1.getStats().frameTime/1e3;for(let s of d)s(o);return e}}function q$1(){return e=>{let o=r$1.getStats().frameTime/1e3;return m(o),e}}r$1.registerInputSystem(q$1());let k=false;function _(){k||(r$1.registerSystem(2,E()),k=true);}return {get world(){return t$1},get config(){return u$1},get screen(){return n},get loop(){return r$1},get inputBuffer(){return l},get inputState(){return p$1},createBox(e){return p(t$1,{...e,parent:e?.parent??n})},createText(e){return q(t$1,{...e,parent:e?.parent??n})},createButton(e){return r(t$1,{...e,parent:e?.parent??n})},createInput(e){return t(t$1,{...e,parent:e?.parent??n})},createTextarea(e){return x(t$1,{...e,parent:e?.parent??n})},createTextbox(e){return w(t$1,{...e,parent:e?.parent??n})},createCheckbox(e){return v(t$1,{...e,parent:e?.parent??n})},createRadioButton(e){return D(t$1,{...e,parent:e?.parent??n})},createRadioSet(e){return C(t$1,{...e,parent:e?.parent??n})},createSelect(e){return y(t$1,{...e,parent:e?.parent??n})},createSlider(e){return z$1(t$1,{...e,parent:e?.parent??n})},createProgressBar(e){return B(t$1,{...e,parent:e?.parent??n})},createList(e){return u(t$1,{...e,parent:e?.parent??n})},createForm(e){return A(t$1,{...e,parent:e?.parent??n})},onKey(e,o){return i.has(e)||i.set(e,new Set),i.get(e)?.add(o),()=>{i.get(e)?.delete(o);}},onAnyKey(e){return y$1.add(e),()=>{y$1.delete(e);}},onMouse(e){return c.add(e),()=>{c.delete(e);}},defineActions(e){f.registerAll(e);},isActionActive(e){return f.isActive(e)},isKeyDown(e){return p$1.isKeyDown(e)},onUpdate(e){return _(),d.add(e),()=>{d.delete(e);}},onFixedUpdate(e){return C$1.add(e),()=>{C$1.delete(e);}},onRender(e){return S.add(e),()=>{S.delete(e);}},registerSystem(e,o){return r$1.registerSystem(e,o),()=>{r$1.unregisterSystem(o);}},start(){r$1.start();},stop(){r$1.stop();},pause(){r$1.pause();},resume(){r$1.resume();},quit(){b.isQuitting=true,r$1.stop();},getStats(){return r$1.getStats()},isRunning(){return r$1.isRunning()},isPaused(){return r$1.isPaused()}}}export{V as a,ae as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {z as z$1}from'zod';var S=z$1.number().int().positive(),h=z$1.number().int().nonnegative(),b=z$1.number().min(0).max(100),g=z$1.string().refine(t=>!!(/^#[0-9a-fA-F]{3,8}$/.test(t)||/^rgba?\(/.test(t)||/^hsla?\(/.test(t)||/^[a-zA-Z]+$/.test(t)),{message:"Invalid color format"}),x=z$1.union([z$1.number(),z$1.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"')]),f=z$1.union([z$1.number(),z$1.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z$1.enum(["center","left","right","top","bottom"])]);var r=z$1.object({tickRate:z$1.number().int().min(1).max(240),maxUpdatesPerFrame:z$1.number().int().min(1).max(30),interpolate:z$1.boolean()}),d=z$1.object({targetFPS:z$1.number().min(0).max(240).optional(),fixedTimestep:z$1.boolean().optional(),maxDeltaTime:z$1.number().positive().max(1).optional(),fixedTimestepMode:r.optional()}),v=z$1.object({fps:z$1.number().nonnegative(),frameTime:z$1.number().nonnegative(),frameCount:z$1.number().int().nonnegative(),runningTime:z$1.number().nonnegative(),tickCount:z$1.number().int().nonnegative(),ticksPerSecond:z$1.number().nonnegative(),interpolationAlpha:z$1.number().min(0).max(1),skippedUpdates:z$1.number().int().nonnegative()});var c=z$1.object({x:z$1.number().positive(),y:z$1.number().positive()}).nullable(),y=z$1.object({constrainToParent:z$1.boolean().optional(),constrainAxis:z$1.enum(["x","y"]).nullable().optional(),snapToGrid:c.optional(),minX:z$1.number().finite().optional(),maxX:z$1.number().finite().optional(),minY:z$1.number().finite().optional(),maxY:z$1.number().finite().optional(),bringToFront:z$1.boolean().optional(),frontZIndex:z$1.number().int().min(0).max(65535).optional()}).refine(t=>t.minX!==void 0&&t.maxX!==void 0?t.minX<=t.maxX:true,{message:"minX must be <= maxX"}).refine(t=>t.minY!==void 0&&t.maxY!==void 0?t.minY<=t.maxY:true,{message:"minY must be <= maxY"}),s=z$1.object({type:z$1.literal("key"),key:z$1.string(),raw:z$1.string().optional()}),p=z$1.object({type:z$1.literal("mouse"),action:z$1.string(),x:z$1.number().int().nonnegative(),y:z$1.number().int().nonnegative(),button:z$1.string().optional()}),P=z$1.discriminatedUnion("type",[s,p]),E=z$1.object({lastX:z$1.number().int().nonnegative(),lastY:z$1.number().int().nonnegative(),lastFg:z$1.number().int().nonnegative(),lastBg:z$1.number().int().nonnegative(),lastAttrs:z$1.number().int().nonnegative(),alternateScreen:z$1.boolean()}),C=z$1.object({x:z$1.number().finite(),y:z$1.number().finite(),width:z$1.number().finite().nonnegative(),height:z$1.number().finite().nonnegative()}),I=z$1.object({x:z$1.number().finite(),y:z$1.number().finite(),width:z$1.number().finite().nonnegative(),height:z$1.number().finite().nonnegative(),z:z$1.number().int().min(0).max(65535)}),T=z$1.enum(["focus","blur"]);var u=z$1.enum(["ascii","utf8","utf-8","utf16le","utf-16le","ucs2","ucs-2","base64","base64url","latin1","binary","hex"]),O=z$1.object({isAlternateBuffer:z$1.boolean().optional(),isMouseEnabled:z$1.boolean().optional()}),j=z$1.object({isAlternateBuffer:z$1.boolean().optional(),isMouseEnabled:z$1.boolean().optional(),timeout:z$1.number().int().nonnegative().max(3e5).optional(),maxBuffer:z$1.number().int().positive().max(104857600).optional(),encoding:u.optional()}),A=z$1.object({content:z$1.string().optional(),extension:z$1.string().regex(/^\.\w+$/,"Extension must start with a dot").optional(),editor:z$1.string().min(1).optional(),isAlternateBuffer:z$1.boolean().optional(),isMouseEnabled:z$1.boolean().optional()});var l=z$1.number().int().min(0).max(4294967295),m=z$1.union([z$1.string().regex(/^#[0-9a-fA-F]{3,8}$/,"Invalid hex color format"),l]),z=z$1.union([z$1.number().int().positive(),z$1.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z$1.literal("auto")]),D=z$1.union([z$1.number().int(),z$1.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z$1.enum(["center","left","right","top","bottom"])]),F=z$1.number().int().min(10).max(6e4),B=z$1.number().min(.1).max(10),N=z$1.string().min(1).refine(t=>!t.includes("\0"),{message:"Path must not contain null bytes"}),W=z$1.enum(["left","center","right"]),V=z$1.enum(["top","middle","bottom"]),X=z$1.union([z$1.boolean(),z$1.object({type:z$1.enum(["line","bg","none"]).optional(),fg:m.optional(),bg:m.optional()})]).optional(),Y=z$1.union([z$1.number().int().min(0).max(255),z$1.object({left:z$1.number().int().min(0).max(255).optional(),top:z$1.number().int().min(0).max(255).optional(),right:z$1.number().int().min(0).max(255).optional(),bottom:z$1.number().int().min(0).max(255).optional()})]).optional(),k=z$1.number().min(0).max(1),L=z$1.string().min(1).refine(t=>!t.includes("\0"),{message:"Tree path must not contain null bytes"});export{F as A,B,N as C,W as D,V as E,X as F,Y as G,k as H,L as I,S as a,h as b,b as c,g as d,x as e,f,r as g,d as h,v as i,c as j,y as k,s as l,p as m,P as n,E as o,C as p,I as q,T as r,u as s,O as t,j as u,A as v,l as w,m as x,z as y,D as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var E=Symbol.for("blecsd.error");var n={INVALID_INPUT:"VALIDATION_INVALID_INPUT",INVALID_HEX_COLOR:"VALIDATION_INVALID_HEX_COLOR",INVALID_HEX_LENGTH:"VALIDATION_INVALID_HEX_LENGTH",INVALID_COLOR_OBJECT:"VALIDATION_INVALID_COLOR_OBJECT",INVALID_COLOR_VALUE:"VALIDATION_INVALID_COLOR_VALUE",INVALID_PALETTE_INDEX:"VALIDATION_INVALID_PALETTE_INDEX",INVALID_CUBE_INDEX:"VALIDATION_INVALID_CUBE_INDEX",INVALID_GRAYSCALE_INDEX:"VALIDATION_INVALID_GRAYSCALE_INDEX",INVALID_DIMENSION:"VALIDATION_INVALID_DIMENSION",INVALID_BUFFER_DIMENSIONS:"VALIDATION_INVALID_BUFFER_DIMENSIONS",INVALID_SURROGATE_PAIR:"VALIDATION_INVALID_SURROGATE_PAIR",SCHEMA_VALIDATION_FAILED:"VALIDATION_SCHEMA_FAILED",REQUIRED_FIELD_MISSING:"VALIDATION_REQUIRED_FIELD_MISSING",VALUE_OUT_OF_RANGE:"VALIDATION_VALUE_OUT_OF_RANGE"},i={TERMINAL_ERROR:"TERMINAL_ERROR",NOT_INITIALIZED:"TERMINAL_NOT_INITIALIZED",ALREADY_INITIALIZED:"TERMINAL_ALREADY_INITIALIZED",TERMINFO_NOT_FOUND:"TERMINAL_TERMINFO_NOT_FOUND",NEGOTIATION_NOT_STARTED:"TERMINAL_NEGOTIATION_NOT_STARTED",NEGOTIATION_ALREADY_STARTED:"TERMINAL_NEGOTIATION_ALREADY_STARTED",CAPABILITY_NOT_SUPPORTED:"TERMINAL_CAPABILITY_NOT_SUPPORTED",WRITE_FAILED:"TERMINAL_WRITE_FAILED",READ_FAILED:"TERMINAL_READ_FAILED",CLEANUP_FAILED:"TERMINAL_CLEANUP_FAILED"},d={SYSTEM_ERROR:"SYSTEM_ERROR",LOOP_ALREADY_RUNNING:"SYSTEM_LOOP_ALREADY_RUNNING",LOOP_NOT_RUNNING:"SYSTEM_LOOP_NOT_RUNNING",CANNOT_CHANGE_WORLD:"SYSTEM_CANNOT_CHANGE_WORLD",SYSTEM_EXECUTION_FAILED:"SYSTEM_EXECUTION_FAILED",PHASE_NOT_FOUND:"SYSTEM_PHASE_NOT_FOUND",PHASE_ALREADY_EXISTS:"SYSTEM_PHASE_ALREADY_EXISTS",INVALID_PHASE_ORDER:"SYSTEM_INVALID_PHASE_ORDER",SCHEDULER_NOT_INITIALIZED:"SYSTEM_SCHEDULER_NOT_INITIALIZED"},I={ENTITY_ERROR:"ENTITY_ERROR",NOT_FOUND:"ENTITY_NOT_FOUND",ALREADY_EXISTS:"ENTITY_ALREADY_EXISTS",SCREEN_ALREADY_EXISTS:"ENTITY_SCREEN_ALREADY_EXISTS",INVALID_ID:"ENTITY_INVALID_ID",MISSING_COMPONENT:"ENTITY_MISSING_COMPONENT",HIERARCHY_ERROR:"ENTITY_HIERARCHY_ERROR"},a={COMPONENT_ERROR:"COMPONENT_ERROR",NOT_FOUND:"COMPONENT_NOT_FOUND",ALREADY_EXISTS:"COMPONENT_ALREADY_EXISTS",INVALID_DATA:"COMPONENT_INVALID_DATA",STORE_NOT_INITIALIZED:"COMPONENT_STORE_NOT_INITIALIZED"},T={INPUT_ERROR:"INPUT_ERROR",INVALID_KEY_SEQUENCE:"INPUT_INVALID_KEY_SEQUENCE",INVALID_MOUSE_EVENT:"INPUT_INVALID_MOUSE_EVENT",HANDLER_NOT_REGISTERED:"INPUT_HANDLER_NOT_REGISTERED",BUFFER_OVERFLOW:"INPUT_BUFFER_OVERFLOW"},p={RENDER_ERROR:"RENDER_ERROR",BUFFER_NOT_INITIALIZED:"RENDER_BUFFER_NOT_INITIALIZED",INVALID_COORDINATES:"RENDER_INVALID_COORDINATES",BUFFER_OVERFLOW:"RENDER_BUFFER_OVERFLOW",CYCLE_TIMEOUT:"RENDER_CYCLE_TIMEOUT"},s={CONFIG_ERROR:"CONFIG_ERROR",INVALID_GAME_CONFIG:"CONFIG_INVALID_GAME_CONFIG",INVALID_SCREEN_CONFIG:"CONFIG_INVALID_SCREEN_CONFIG",INVALID_WIDGET_CONFIG:"CONFIG_INVALID_WIDGET_CONFIG",MISSING_REQUIRED:"CONFIG_MISSING_REQUIRED"},C={INTERNAL_ERROR:"INTERNAL_ERROR",UNEXPECTED_STATE:"INTERNAL_UNEXPECTED_STATE",ASSERTION_FAILED:"INTERNAL_ASSERTION_FAILED",NOT_IMPLEMENTED:"INTERNAL_NOT_IMPLEMENTED",UNREACHABLE:"INTERNAL_UNREACHABLE"},u={...n,...i,...d,...I,...a,...T,...p,...s,...C};function S(r,o,e){return {kind:"validation",code:r,message:o,timestamp:Date.now(),cause:e?.cause,context:e?.zodIssues?{...e.context,zodIssues:e.zodIssues}:e?.context}}function A(r,o,e){return {kind:"terminal",code:r,message:o,timestamp:Date.now(),cause:e?.cause,context:e?.context}}function c(r,o,e){return {kind:"system",code:r,message:o,timestamp:Date.now(),cause:e?.cause,context:e?.context}}function D(r,o,e){return {kind:"entity",code:r,message:o,timestamp:Date.now(),cause:e?.cause,context:e?.context}}function L(r,o,e){return {kind:"component",code:r,message:o,timestamp:Date.now(),cause:e?.cause,context:e?.context}}function f(r,o,e){return {kind:"input",code:r,message:o,timestamp:Date.now(),cause:e?.cause,context:e?.context}}function m(r,o,e){return {kind:"render",code:r,message:o,timestamp:Date.now(),cause:e?.cause,context:e?.context}}function x(r,o,e){return {kind:"config",code:r,message:o,timestamp:Date.now(),cause:e?.cause,context:e?.context}}function N(r,o,e){return {kind:"internal",code:r,message:o,timestamp:Date.now(),cause:e?.cause,context:e?.context}}function B(r){let o=new Error(r.message);return o.name=`BlECSd${k(r.kind)}Error`,o[E]=r,r.cause&&(o.cause=r.cause),o}function _(r){return r==null||typeof r!="object"?null:E in r?r[E]:null}function V(r,o,e){let t=_(r);if(t)return t;let y=r instanceof Error?r:void 0,O=r instanceof Error?`${e}: ${r.message}`:`${e}: ${String(r)}`;return N(o,O,{cause:y})}function k(r){return r.charAt(0).toUpperCase()+r.slice(1)}function U(r){return r.kind==="validation"}function g(r){return r.kind==="terminal"}function M(r){return r.kind==="system"}function F(r){return r.kind==="entity"}function Y(r){return r.kind==="component"}function P(r){return r.kind==="input"}function G(r){return r.kind==="render"}function w(r){return r.kind==="config"}function H(r){return r.kind==="internal"}function v(r,o){return r.kind===o}function X(r,o){return r.code===o}function h(r){return r!=null&&typeof r=="object"&&E in r}function K(r){if(r==null||typeof r!="object")return false;let o=r;return typeof o.kind=="string"&&typeof o.code=="string"&&typeof o.message=="string"&&typeof o.timestamp=="number"}function Z(r){return r.context!=null}function b(r){return r.cause!=null}function z(r){return r.context!=null&&r.context.zodIssues!=null&&r.context.zodIssues.length>0}function R(r){return {ok:true,value:r}}function l(r){return {ok:false,error:r}}function W(r){return r.ok===true}function $(r){return r.ok===false}function Q(r){if(r.ok)return r.value;let o=r.error instanceof Error?r.error.message:typeof r.error=="object"&&r.error!==null&&"message"in r.error?String(r.error.message):String(r.error);throw new Error(`Called unwrap on Err: ${o}`)}function j(r,o){return r.ok?r.value:o}function J(r,o){return r.ok?r.value:o(r.error)}function q(r,o){return r.ok?R(o(r.value)):r}function rr(r,o){return r.ok?r:l(o(r.error))}function or(r,o){return r.ok?o(r.value):r}export{F as A,Y as B,P as C,G as D,w as E,H as F,v as G,X as H,h as I,K as J,Z as K,b as L,z as M,R as N,l as O,W as P,$ as Q,Q as R,j as S,J as T,q as U,rr as V,or as W,E as a,n as b,i as c,d,I as e,a as f,T as g,p as h,s as i,C as j,u as k,S as l,A as m,c as n,D as o,L as p,f as q,m as r,x as s,N as t,B as u,_ as v,V as w,U as x,g as y,M as z};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import {b,e as e$3,d as d$2,f as f$3,g as g$1}from'./chunk-DNRXW56C.js';import {e}from'./chunk-FYEBZAWN.js';import {W,g,Y as Y$1,$,_ as _$1,s,x,j as j$1,L,O,d as d$1}from'./chunk-W5OU7Z6J.js';import {f as f$1,e as e$2}from'./chunk-SHUC6JWA.js';import {f as f$2,d}from'./chunk-G7GIWWLE.js';import {n,e as e$1}from'./chunk-PXXGH3BV.js';import {readFileSync}from'fs';import {z}from'zod';n();f$1();var N=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.literal("auto")]),f=z.union([z.number(),z.string().regex(/^\d+(\.\d+)?%$/,'Percentage must be in format "50%"'),z.enum(["center","left","right","top","bottom"])]),J=z.object({left:f.optional(),top:f.optional(),right:f.optional(),bottom:f.optional(),width:N.optional(),height:N.optional(),fg:z.union([z.string(),z.number()]).optional(),bg:z.union([z.string(),z.number()]).optional(),text:z.string(),font:z.union([z.string(),b]).optional(),shrink:z.boolean().optional()}),Y=1e4,c={isBigText:new Uint8Array(Y)},U="terminus-14-bold",T=new Map,a=new Map;function _(t){if(t===void 0)return 0;if(typeof t=="number")return t;switch(t){case "left":case "top":return 0;case "center":return 0;case "right":case "bottom":return 0}return 0}function M(t){return t===void 0||typeof t=="string"&&t==="auto"?"auto":t}async function j(t){return t?typeof t!="string"?t:t==="terminus-14-bold"||t==="terminus-14-normal"?d$2(t):H(t):d$2(U)}function q(t){return t?typeof t!="string"?t:t==="terminus-14-bold"||t==="terminus-14-normal"?e$3(t):T.get(t):e$3(U)}function K(t,i){let n=" ".repeat(t);return Array.from({length:i},()=>n)}function Q(t,i){let n=t.charHeight,r=Array.from({length:n},()=>"");for(let e of Array.from(i)){let u=f$3(t,e)?g$1(t,e):K(t.charWidth,t.charHeight);for(let g=0;g<n;g+=1){let O=u[g]??"";r[g]=`${r[g]}${O}`;}}return r}function B(t,i){let n=i.split(`
|
|
2
|
+
`),r=[];for(let e of n)r.push(...Q(t,e));return r.join(`
|
|
3
|
+
`)}function H(t){let i=T.get(t);if(i)return i;let n=readFileSync(t,"utf8"),r=JSON.parse(n),e=b.parse(r);return T.set(t,e),e}var ft=H;function R(t,i,n){let r=_(n.left),e=_(n.top);s(t,i,r,e);let s$1=M(n.width),u=M(n.height);L(t,i,s$1,u);let g=n.shrink!==false;O(t,i,g);}function X(t,i,n){n.fg===void 0&&n.bg===void 0||d$1(t,i,{fg:n.fg!==void 0?e$2(n.fg):void 0,bg:n.bg!==void 0?e$2(n.bg):void 0});}async function Z(t,i,n){let r=await j(n.font),e$1=B(r,n.text);a.set(i,n.text),e(t,i,e$1);}async function ct(t,i,n){let r=J.parse(n),e=i;c.isBigText[e]=1,R(t,e,r),X(t,e,r),await Z(t,e,r),W(t,e,{focusable:true});let s$1={eid:e,show(){return j$1(t,e,true),s$1},hide(){return j$1(t,e,false),s$1},move(u,g$1){return x(t,e,u,g$1),g(t,e),s$1},setPosition(u,g$1){return s(t,e,u,g$1),g(t,e),s$1},setText(u){return tt(t,e,u,r.font),s$1},getText(){return a.get(e)??""},focus(){return _$1(t,e),s$1},blur(){return $(t,e),s$1},isFocused(){return Y$1(t,e)},append(u){return d(t,e,u),s$1},getChildren(){return f$2(t,e)},destroy(){c.isBigText[e]=0,a.delete(e),e$1(t,e);}};return s$1}function w(t,i,n,r){let e$1=q(r);if(e$1){let s=B(e$1,n);a.set(i,n),e(t,i,s),g(t,i);return}j(r).then(s=>{let u=B(s,n);a.set(i,n),e(t,i,u),g(t,i);});}function tt(t,i,n,r){return w(t,i,n,r),i}function pt(t,i){return c.isBigText[i]===1}function lt(){c.isBigText.fill(0),a.clear();}export{J as a,c as b,H as c,ft as d,ct as e,w as f,pt as g,lt as h};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {k as k$1,s,f,g as g$1}from'./chunk-C5PCEQ6G.js';function w(e,t,n){return {width:e,height:t,frontBuffer:k$1(e,t,n),backBuffer:k$1(e,t,n),dirtyRegions:[],fullRedraw:true}}function C(e){return e.backBuffer}function b(e){let t=e.frontBuffer;e.frontBuffer=e.backBuffer,e.backBuffer=t;}function k(e,t,n,o,r){let f=Math.max(0,t),u=Math.max(0,n),l=Math.min(e.width,t+o),i=Math.min(e.height,n+r);l<=f||i<=u||e.dirtyRegions.push({x:f,y:u,w:l-f,h:i-u});}function v(e){e.dirtyRegions.length=0,e.fullRedraw=false;}function g(e){if(e.dirtyRegions.length<2)return;e.dirtyRegions.sort((o,r)=>o.y!==r.y?o.y-r.y:o.x-r.x);let t=[],n=e.dirtyRegions[0];if(n){for(let o=1;o<e.dirtyRegions.length;o++){let r=e.dirtyRegions[o];r&&(B(n,r)?n=D(n,r):(t.push(n),n=r));}t.push(n),e.dirtyRegions.length=0,e.dirtyRegions.push(...t);}}function B(e,t){let n=e.x+e.w,o=e.y+e.h,r=t.x+t.w,f=t.y+t.h;return !(t.x>n+1||r<e.x-1||t.y>o+1||f<e.y-1)}function D(e,t){let n=Math.min(e.x,t.x),o=Math.min(e.y,t.y),r=Math.max(e.x+e.w,t.x+t.w),f=Math.max(e.y+e.h,t.y+t.h);return {x:n,y:o,w:r-n,h:f-o}}function R(e,t){let n=e.backBuffer;for(let o=0;o<e.height;o++)for(let r=0;r<e.width;r++){let f$1=o*e.width+r,u=n.cells[f$1];u&&t.push({x:r,y:o,cell:f(u)});}}function x(e,t){return t?e?!g$1(e,t):true:false}function m(e,t){let n=e.frontBuffer,o=e.backBuffer;for(let r of e.dirtyRegions)for(let f$1=r.y;f$1<r.y+r.h;f$1++)for(let u=r.x;u<r.x+r.w;u++){let l=f$1*e.width+u,i=n.cells[l],a=o.cells[l];x(i,a)&&a&&t.push({x:u,y:f$1,cell:f(a)});}}function M(e){let t=[];return e.fullRedraw?(R(e,t),t):(e.dirtyRegions.length===0||(g(e),m(e,t)),t)}function S(e,t,n,o){let r=s(e.frontBuffer,t,n,o),f=s(e.backBuffer,t,n,o);return {width:t,height:n,frontBuffer:r,backBuffer:f,dirtyRegions:[],fullRedraw:true}}export{w as a,C as b,b as c,k as d,v as e,M as f,S as g};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {c as c$4}from'./chunk-H2YAOJDW.js';import {O,v,u,x,Z,Ja,X,W as W$2,Nc,nd,Ld,le,pe,$a,db,Bb,ub,Pb,fc,lc,vc,Ac,wc,qe}from'./chunk-P6CJO3BC.js';import {d as d$3,c as c$3,e as e$1}from'./chunk-BCADUCOZ.js';import {c as c$1,d as d$2}from'./chunk-KD55INV7.js';import {k,a,b as b$1,l}from'./chunk-PSXXMBVJ.js';import {s,i,j as j$1}from'./chunk-LCN2ZITE.js';import {d as d$1,e}from'./chunk-FYEBZAWN.js';import {V as V$1,W as W$1,r,K,c as c$2,d as d$4}from'./chunk-W5OU7Z6J.js';import {c,b}from'./chunk-G7GIWWLE.js';import {n,d,h}from'./chunk-PXXGH3BV.js';import {z as z$1}from'zod';s();n();var j=z$1.object({x:z$1.number().optional(),y:z$1.number().optional(),z:z$1.number().optional(),absolute:z$1.boolean().optional()}),R=z$1.object({width:z$1.union([z$1.number(),z$1.string()]).optional(),height:z$1.union([z$1.number(),z$1.string()]).optional(),minWidth:z$1.number().optional(),maxWidth:z$1.number().optional(),minHeight:z$1.number().optional(),maxHeight:z$1.number().optional(),shrink:z$1.boolean().optional()}),L=z$1.object({fg:z$1.number().optional(),bg:z$1.number().optional(),bold:z$1.boolean().optional(),italic:z$1.boolean().optional(),underline:z$1.boolean().optional(),strikethrough:z$1.boolean().optional(),dim:z$1.boolean().optional(),inverse:z$1.boolean().optional(),blink:z$1.boolean().optional(),visible:z$1.boolean().optional()}),W=z$1.object({type:z$1.number().optional(),left:z$1.boolean().optional(),right:z$1.boolean().optional(),top:z$1.boolean().optional(),bottom:z$1.boolean().optional(),fg:z$1.number().optional(),bg:z$1.number().optional(),chars:z$1.custom().optional()}),N=z$1.object({left:z$1.number().optional(),right:z$1.number().optional(),top:z$1.number().optional(),bottom:z$1.number().optional()}),ft=z$1.object({text:z$1.string().optional(),align:z$1.number().optional(),valign:z$1.number().optional(),wrap:z$1.boolean().optional(),parseTags:z$1.boolean().optional()}),ee=z$1.object({clickable:z$1.boolean().optional(),draggable:z$1.boolean().optional(),hoverable:z$1.boolean().optional(),keyable:z$1.boolean().optional(),hoverEffectFg:z$1.number().optional(),hoverEffectBg:z$1.number().optional()}),Q=z$1.object({focusable:z$1.boolean().optional(),tabIndex:z$1.number().optional(),focusEffectFg:z$1.number().optional(),focusEffectBg:z$1.number().optional()}),et=z$1.object({scrollable:z$1.boolean().optional(),scrollX:z$1.number().optional(),scrollY:z$1.number().optional(),scrollWidth:z$1.number().optional(),scrollHeight:z$1.number().optional(),scrollbarVisible:z$1.number().optional()}),dt=z$1.object({parent:z$1.number().optional(),border:W.optional(),padding:N.optional()}).merge(j).merge(R).merge(L),pt=z$1.object({parent:z$1.number().optional(),border:W.optional(),padding:N.optional()}).merge(j).merge(R).merge(L).merge(ft),ct=z$1.object({parent:z$1.number().optional(),label:z$1.string().optional(),border:W.optional(),padding:N.optional()}).merge(j).merge(R).merge(L).merge(ee).merge(Q),mt=z$1.object({width:z$1.number().int().positive(),height:z$1.number().int().positive(),title:z$1.string().optional(),cursorVisible:z$1.boolean().optional(),cursorShape:z$1.number().int().min(0).max(5).optional(),fullUnicode:z$1.boolean().optional(),autoPadding:z$1.boolean().optional()}),gt=z$1.object({parent:z$1.number().optional(),value:z$1.string().optional(),placeholder:z$1.string().optional(),maxLength:z$1.number().optional(),border:W.optional(),padding:N.optional()}).merge(j).merge(R).merge(L).merge(ee).merge(Q),bt=z$1.object({parent:z$1.number().optional(),items:z$1.array(z$1.string()).optional(),selectedIndex:z$1.number().optional(),border:W.optional(),padding:N.optional()}).merge(j).merge(R).merge(L).merge(et).merge(Q),yt=z$1.object({parent:z$1.number().optional(),label:z$1.string().optional(),checked:z$1.boolean().optional(),checkedChar:z$1.string().optional(),uncheckedChar:z$1.string().optional(),border:W.optional(),padding:N.optional()}).merge(j).merge(R).merge(L).merge(ee).merge(Q),vt=z$1.object({parent:z$1.number().optional(),value:z$1.string().optional(),placeholder:z$1.string().optional(),secret:z$1.boolean().optional(),censor:z$1.string().optional(),maxLength:z$1.number().optional(),border:W.optional(),padding:N.optional()}).merge(j).merge(R).merge(L).merge(ee).merge(Q),ht=z$1.object({parent:z$1.number().optional(),value:z$1.string().optional(),placeholder:z$1.string().optional(),maxLength:z$1.number().optional(),scrollable:z$1.boolean().optional(),border:W.optional(),padding:N.optional()}).merge(j).merge(R).merge(L).merge(ee).merge(Q).merge(et),Et=z$1.object({parent:z$1.number().optional(),options:z$1.array(z$1.object({label:z$1.string(),value:z$1.string()})).optional(),selectedIndex:z$1.number().optional(),placeholder:z$1.string().optional(),closedIndicator:z$1.string().optional(),openIndicator:z$1.string().optional(),selectedMark:z$1.string().optional(),border:W.optional(),padding:N.optional()}).merge(j).merge(R).merge(L).merge(ee).merge(Q),St=z$1.object({parent:z$1.number().optional(),min:z$1.number().optional(),max:z$1.number().optional(),value:z$1.number().optional(),step:z$1.number().optional(),orientation:z$1.number().optional(),showValue:z$1.boolean().optional(),trackChar:z$1.string().optional(),thumbChar:z$1.string().optional(),fillChar:z$1.string().optional(),trackFg:z$1.number().optional(),trackBg:z$1.number().optional(),thumbFg:z$1.number().optional(),thumbBg:z$1.number().optional(),fillFg:z$1.number().optional(),fillBg:z$1.number().optional(),border:W.optional(),padding:N.optional()}).merge(j).merge(R).merge(L).merge(ee).merge(Q),xt=z$1.object({parent:z$1.number().optional(),keys:z$1.boolean().optional(),submitOnEnter:z$1.boolean().optional(),fields:z$1.array(z$1.object({name:z$1.string(),entity:z$1.number(),initialValue:z$1.unknown().optional()})).optional(),border:W.optional(),padding:N.optional()}).merge(j).merge(R).merge(L),Bt=z$1.object({parent:z$1.number().optional(),value:z$1.number().optional(),min:z$1.number().optional(),max:z$1.number().optional(),orientation:z$1.number().optional(),showPercentage:z$1.boolean().optional(),fillChar:z$1.string().optional(),emptyChar:z$1.string().optional(),fillFg:z$1.number().optional(),fillBg:z$1.number().optional(),emptyFg:z$1.number().optional(),emptyBg:z$1.number().optional(),border:W.optional(),padding:N.optional()}).merge(j).merge(R).merge(L),kt=z$1.object({parent:z$1.number().optional(),selectedIndex:z$1.number().optional(),border:W.optional(),padding:N.optional()}).merge(j).merge(R).merge(L),Ct=z$1.object({parent:z$1.number().optional(),radioSet:z$1.number().optional(),value:z$1.string().optional(),label:z$1.string().optional(),selected:z$1.boolean().optional(),selectedChar:z$1.string().optional(),unselectedChar:z$1.string().optional(),border:W.optional(),padding:N.optional()}).merge(j).merge(R).merge(L).merge(ee).merge(Q);function P(n,o){h(n,o,r),h(n,o,K),h(n,o,c$2),h(n,o,b),r.x[o]=0,r.y[o]=0,r.z[o]=0,r.absolute[o]=0,K.width[o]=0,K.height[o]=0,K.minWidth[o]=0,K.minHeight[o]=0,K.maxWidth[o]=Number.POSITIVE_INFINITY,K.maxHeight[o]=Number.POSITIVE_INFINITY,K.shrink[o]=0,c$2.visible[o]=1,c$2.dirty[o]=1,c$2.fg[o]=4294967295,c$2.bg[o]=255,c$2.bold[o]=0,c$2.underline[o]=0,c$2.blink[o]=0,c$2.inverse[o]=0,c$2.transparent[o]=0,b.parent[o]=0,b.firstChild[o]=0,b.nextSibling[o]=0,b.prevSibling[o]=0,b.childCount[o]=0,b.depth[o]=0;}function z(n,o){o.x!==void 0&&(r.x[n]=o.x),o.y!==void 0&&(r.y[n]=o.y),o.z!==void 0&&(r.z[n]=o.z),o.absolute!==void 0&&(r.absolute[n]=o.absolute?1:0);}function Ze(n){return typeof n=="string"&&n.endsWith("%")?-(Number.parseFloat(n)+2):n==="auto"?-1:n}function Tt(n,o){o.minWidth!==void 0&&(K.minWidth[n]=o.minWidth),o.maxWidth!==void 0&&(K.maxWidth[n]=o.maxWidth),o.minHeight!==void 0&&(K.minHeight[n]=o.minHeight),o.maxHeight!==void 0&&(K.maxHeight[n]=o.maxHeight),o.shrink!==void 0&&(K.shrink[n]=o.shrink?1:0);}function U(n,o){o.width!==void 0&&(K.width[n]=Ze(o.width)),o.height!==void 0&&(K.height[n]=Ze(o.height)),Tt(n,o);}function H(n,o,e){let t={};e.fg!==void 0&&(t.fg=e.fg),e.bg!==void 0&&(t.bg=e.bg),e.bold!==void 0&&(t.bold=e.bold),e.underline!==void 0&&(t.underline=e.underline),e.inverse!==void 0&&(t.inverse=e.inverse),e.blink!==void 0&&(t.blink=e.blink),Object.keys(t).length>0&&d$4(n,o,t),e.visible!==void 0&&(c$2.visible[o]=e.visible?1:0);}function V(n,o,e){if(!e||!(e.type!==void 0||e.left!==void 0||e.right!==void 0||e.top!==void 0||e.bottom!==void 0||e.fg!==void 0||e.bg!==void 0||e.chars!==void 0))return;i.type[o]=e.type??0,i.left[o]=0,i.right[o]=0,i.top[o]=0,i.bottom[o]=0,i.fg[o]=4294967295,i.bg[o]=255;let l={};e.type!==void 0&&(l.type=e.type),e.left!==void 0&&(l.left=e.left),e.right!==void 0&&(l.right=e.right),e.top!==void 0&&(l.top=e.top),e.bottom!==void 0&&(l.bottom=e.bottom),e.fg!==void 0&&(l.fg=e.fg),e.bg!==void 0&&(l.bg=e.bg),e.chars!==void 0&&(l.chars=e.chars),j$1(n,o,l);}function Y(n,o,e){if(!e||!(e.left!==void 0||e.right!==void 0||e.top!==void 0||e.bottom!==void 0))return;a.left[o]=0,a.right[o]=0,a.top[o]=0,a.bottom[o]=0;let l={};e.left!==void 0&&(l.left=e.left),e.right!==void 0&&(l.right=e.right),e.top!==void 0&&(l.top=e.top),e.bottom!==void 0&&(l.bottom=e.bottom),b$1(n,o,l);}function pn(n,o={}){let e=dt.parse(o),t=d(n);return P(n,t),z(t,e),U(t,e),H(n,t,e),V(n,t,e.border),Y(n,t,e.padding),e.parent!==void 0&&c(n,t,e.parent),t}function te(n,o){h(n,o,d$1),d$1.align[o]=0,d$1.valign[o]=0,d$1.wrap[o]=0,d$1.parseTags[o]=0,d$1.length[o]=0,d$1.hash[o]=0,d$1.contentId[o]=0;}function It(n,o){o.align!==void 0&&(d$1.align[n]=o.align),o.valign!==void 0&&(d$1.valign[n]=o.valign),o.wrap!==void 0&&(d$1.wrap[n]=o.wrap?1:0),o.parseTags!==void 0&&(d$1.parseTags[n]=o.parseTags?1:0);}function Ft(n,o,e$1){if(e$1.text!==void 0){let t={};e$1.align!==void 0&&(t.align=e$1.align),e$1.valign!==void 0&&(t.valign=e$1.valign),e$1.wrap!==void 0&&(t.wrap=e$1.wrap),e$1.parseTags!==void 0&&(t.parseTags=e$1.parseTags),e(n,o,e$1.text,t);}else It(o,e$1);}function cn(n,o={}){let e=pt.parse(o),t=d(n);return P(n,t),z(t,e),U(t,e),H(n,t,e),V(n,t,e.border),Y(n,t,e.padding),te(n,t),Ft(n,t,e),e.parent!==void 0&&c(n,t,e.parent),t}function mn(n,o={}){let e$1=ct.parse(o),t=d(n);P(n,t),z(t,e$1),U(t,e$1),H(n,t,e$1),V(n,t,e$1.border),Y(n,t,e$1.padding),d$1.align[t]=1,d$1.valign[t]=1,d$1.wrap[t]=0,d$1.parseTags[t]=0,d$1.length[t]=0,d$1.hash[t]=0,e$1.label!==void 0&&e(n,t,e$1.label),h(n,t,c$1),c$1.clickable[t]=1,c$1.draggable[t]=0,c$1.hoverable[t]=1,c$1.hovered[t]=0,c$1.pressed[t]=0,c$1.keyable[t]=1,c$1.hoverEffectFg[t]=4294967295,c$1.hoverEffectBg[t]=1145324799;let l={};e$1.clickable!==void 0&&(l.clickable=e$1.clickable),e$1.draggable!==void 0&&(l.draggable=e$1.draggable),e$1.hoverable!==void 0&&(l.hoverable=e$1.hoverable),e$1.keyable!==void 0&&(l.keyable=e$1.keyable),e$1.hoverEffectFg!==void 0&&(l.hoverEffectFg=e$1.hoverEffectFg),e$1.hoverEffectBg!==void 0&&(l.hoverEffectBg=e$1.hoverEffectBg),Object.keys(l).length>0&&d$2(n,t,l),h(n,t,V$1),V$1.focusable[t]=1,V$1.focused[t]=0,V$1.tabIndex[t]=0,V$1.focusEffectFg[t]=4294967295,V$1.focusEffectBg[t]=6750207;let u={};return e$1.focusable!==void 0&&(u.focusable=e$1.focusable),e$1.tabIndex!==void 0&&(u.tabIndex=e$1.tabIndex),e$1.focusEffectFg!==void 0&&(u.focusEffectFg=e$1.focusEffectFg),e$1.focusEffectBg!==void 0&&(u.focusEffectBg=e$1.focusEffectBg),Object.keys(u).length>0&&W$1(n,t,u),e$1.parent!==void 0&&c(n,t,e$1.parent),t}function gn(n,o){if(d$3(n))throw new Error("A screen already exists in this world. Only one screen is allowed.");let e=mt.parse(o),t=d(n);return P(n,t),r.x[t]=0,r.y[t]=0,r.z[t]=0,r.absolute[t]=0,K.width[t]=e.width,K.height[t]=e.height,c$2.visible[t]=1,c$2.dirty[t]=1,b.parent[t]=0,b.depth[t]=0,c$3(n,t,{cursorVisible:e.cursorVisible,cursorShape:e.cursorShape,fullUnicode:e.fullUnicode,autoPadding:e.autoPadding}),e$1(n,t),t}function bn(n,o={}){let e$1=gt.parse(o),t=d(n);P(n,t),z(t,e$1),U(t,e$1),H(n,t,e$1),V(n,t,e$1.border),Y(n,t,e$1.padding),d$1.align[t]=0,d$1.valign[t]=1,d$1.wrap[t]=0,d$1.parseTags[t]=0,d$1.length[t]=0,d$1.hash[t]=0,e$1.value!==void 0&&e(n,t,e$1.value),c$1.clickable[t]=1,c$1.draggable[t]=0,c$1.hoverable[t]=1,c$1.hovered[t]=0,c$1.pressed[t]=0,c$1.keyable[t]=1,c$1.hoverEffectFg[t]=4294967295,c$1.hoverEffectBg[t]=858993663;let l={};e$1.clickable!==void 0&&(l.clickable=e$1.clickable),e$1.draggable!==void 0&&(l.draggable=e$1.draggable),e$1.hoverable!==void 0&&(l.hoverable=e$1.hoverable),e$1.keyable!==void 0&&(l.keyable=e$1.keyable),e$1.hoverEffectFg!==void 0&&(l.hoverEffectFg=e$1.hoverEffectFg),e$1.hoverEffectBg!==void 0&&(l.hoverEffectBg=e$1.hoverEffectBg),Object.keys(l).length>0&&d$2(n,t,l),h(n,t,V$1),V$1.focusable[t]=1,V$1.focused[t]=0,V$1.tabIndex[t]=0,V$1.focusEffectFg[t]=4294967295,V$1.focusEffectBg[t]=6750207;let u={};return e$1.focusable!==void 0&&(u.focusable=e$1.focusable),e$1.tabIndex!==void 0&&(u.tabIndex=e$1.tabIndex),e$1.focusEffectFg!==void 0&&(u.focusEffectFg=e$1.focusEffectFg),e$1.focusEffectBg!==void 0&&(u.focusEffectBg=e$1.focusEffectBg),Object.keys(u).length>0&&W$1(n,t,u),e$1.parent!==void 0&&c(n,t,e$1.parent),t}function Mt(n,o,e){h(n,o,k),k.scrollX[o]=0,k.scrollY[o]=0,k.scrollWidth[o]=0,k.scrollHeight[o]=e,k.scrollbarVisible[o]=2;}function At(n,o,e){let t={};e.scrollable!==void 0&&(t.scrollX=0),e.scrollX!==void 0&&(t.scrollX=e.scrollX),e.scrollY!==void 0&&(t.scrollY=e.scrollY),e.scrollWidth!==void 0&&(t.scrollWidth=e.scrollWidth),e.scrollHeight!==void 0&&(t.scrollHeight=e.scrollHeight),e.scrollbarVisible!==void 0&&(t.scrollbarVisible=e.scrollbarVisible),Object.keys(t).length>0&&l(n,o,t);}function Pt(n){c$1.clickable[n]=1,c$1.draggable[n]=0,c$1.hoverable[n]=0,c$1.hovered[n]=0,c$1.pressed[n]=0,c$1.keyable[n]=1,c$1.hoverEffectFg[n]=4294967295,c$1.hoverEffectBg[n]=1145324799;}function Dt(n,o){h(n,o,V$1),V$1.focusable[o]=1,V$1.focused[o]=0,V$1.tabIndex[o]=0,V$1.focusEffectFg[o]=4294967295,V$1.focusEffectBg[o]=6750207;}function ne(n,o,e){let t={};e.focusable!==void 0&&(t.focusable=e.focusable),e.tabIndex!==void 0&&(t.tabIndex=e.tabIndex),e.focusEffectFg!==void 0&&(t.focusEffectFg=e.focusEffectFg),e.focusEffectBg!==void 0&&(t.focusEffectBg=e.focusEffectBg),Object.keys(t).length>0&&W$1(n,o,t);}function ie(n,o,e){let t={};e.clickable!==void 0&&(t.clickable=e.clickable),e.draggable!==void 0&&(t.draggable=e.draggable),e.hoverable!==void 0&&(t.hoverable=e.hoverable),e.keyable!==void 0&&(t.keyable=e.keyable),e.hoverEffectFg!==void 0&&(t.hoverEffectFg=e.hoverEffectFg),e.hoverEffectBg!==void 0&&(t.hoverEffectBg=e.hoverEffectBg),Object.keys(t).length>0&&d$2(n,o,t);}function ae(n,o){h(n,o,c$1),c$1.clickable[o]=1,c$1.draggable[o]=0,c$1.hoverable[o]=1,c$1.hovered[o]=0,c$1.pressed[o]=0,c$1.keyable[o]=1,c$1.hoverEffectFg[o]=4294967295,c$1.hoverEffectBg[o]=1145324799;}function re(n,o){h(n,o,V$1),V$1.focusable[o]=1,V$1.focused[o]=0,V$1.tabIndex[o]=0,V$1.focusEffectFg[o]=4294967295,V$1.focusEffectBg[o]=6750207;}function Kt(n,o,e){let t={};e.scrollX!==void 0&&(t.scrollX=e.scrollX),e.scrollY!==void 0&&(t.scrollY=e.scrollY),e.scrollWidth!==void 0&&(t.scrollWidth=e.scrollWidth),e.scrollHeight!==void 0&&(t.scrollHeight=e.scrollHeight),e.scrollbarVisible!==void 0&&(t.scrollbarVisible=e.scrollbarVisible),Object.keys(t).length>0&&l(n,o,t);}function Ot(n,o){let e={};o.trackChar!==void 0&&(e.trackChar=o.trackChar),o.thumbChar!==void 0&&(e.thumbChar=o.thumbChar),o.fillChar!==void 0&&(e.fillChar=o.fillChar),o.trackFg!==void 0&&(e.trackFg=o.trackFg),o.trackBg!==void 0&&(e.trackBg=o.trackBg),o.thumbFg!==void 0&&(e.thumbFg=o.thumbFg),o.thumbBg!==void 0&&(e.thumbBg=o.thumbBg),o.fillFg!==void 0&&(e.fillFg=o.fillFg),o.fillBg!==void 0&&(e.fillBg=o.fillBg),qe(n,e);}function yn(n,o={}){let e$1=bt.parse(o),t=d(n);return P(n,t),z(t,e$1),U(t,e$1),H(n,t,e$1),V(n,t,e$1.border),Y(n,t,e$1.padding),te(n,t),e$1.items!==void 0&&e$1.items.length>0&&e(n,t,e$1.items.join(`
|
|
2
|
+
`)),Mt(n,t,e$1.items?.length??0),At(n,t,e$1),Dt(n,t),ne(n,t,e$1),Pt(t),e$1.parent!==void 0&&c(n,t,e$1.parent),t}function vn(n,o={}){let e$1=yt.parse(o),t=d(n);return P(n,t),z(t,e$1),U(t,e$1),H(n,t,e$1),V(n,t,e$1.border),Y(n,t,e$1.padding),te(n,t),d$1.align[t]=0,d$1.valign[t]=1,e$1.label!==void 0&&e(n,t,e$1.label),ae(n,t),ie(n,t,e$1),re(n,t),ne(n,t,e$1),O(t,{checkedChar:e$1.checkedChar??u,uncheckedChar:e$1.uncheckedChar??v}),x(n,t,e$1.checked??false),e$1.parent!==void 0&&c(n,t,e$1.parent),t}function hn(n,o={}){let e$1=vt.parse(o),t=d(n);return P(n,t),z(t,e$1),U(t,e$1),H(n,t,e$1),V(n,t,e$1.border),Y(n,t,e$1.padding),te(n,t),d$1.align[t]=0,d$1.valign[t]=1,e$1.value!==void 0&&e(n,t,e$1.value),ae(n,t),c$1.hoverEffectBg[t]=858993663,ie(n,t,e$1),re(n,t),ne(n,t,e$1),Z(n,t),Ja(t,{secret:e$1.secret??false,censor:e$1.censor??W$2,placeholder:e$1.placeholder??X,maxLength:e$1.maxLength??0}),e$1.parent!==void 0&&c(n,t,e$1.parent),t}function En(n,o={}){let e$1=ht.parse(o),t=d(n);return P(n,t),z(t,e$1),U(t,e$1),H(n,t,e$1),V(n,t,e$1.border),Y(n,t,e$1.padding),te(n,t),d$1.align[t]=0,d$1.valign[t]=0,e$1.value!==void 0&&e(n,t,e$1.value),ae(n,t),c$1.hoverEffectBg[t]=858993663,ie(n,t,e$1),re(n,t),ne(n,t,e$1),e$1.scrollable&&(h(n,t,k),k.scrollX[t]=0,k.scrollY[t]=0,k.scrollWidth[t]=0,k.scrollHeight[t]=0,k.scrollbarVisible[t]=2,Kt(n,t,e$1)),Z(n,t),Ja(t,{secret:false,censor:"",placeholder:e$1.placeholder??X,maxLength:e$1.maxLength??0,multiline:true}),e$1.parent!==void 0&&c(n,t,e$1.parent),t}function Sn(n,o={}){let e$1=Et.parse(o),t=d(n);P(n,t),z(t,e$1),U(t,e$1),H(n,t,e$1),V(n,t,e$1.border),Y(n,t,e$1.padding),te(n,t),d$1.align[t]=0,d$1.valign[t]=1,ae(n,t),c$1.hoverEffectBg[t]=858993663,ie(n,t,e$1),re(n,t),ne(n,t,e$1);let l=e$1.options??[],u=e$1.selectedIndex??-1;Nc(n,t,l,u);let b={};return e$1.closedIndicator!==void 0&&(b.closedIndicator=e$1.closedIndicator),e$1.openIndicator!==void 0&&(b.openIndicator=e$1.openIndicator),e$1.selectedMark!==void 0&&(b.selectedMark=e$1.selectedMark),nd(t,b),u>=0&&l[u]?e(n,t,l[u].label):e$1.placeholder&&e(n,t,e$1.placeholder),e$1.parent!==void 0&&c(n,t,e$1.parent),t}function xn(n,o={}){let e=St.parse(o),t=d(n);P(n,t),z(t,e),U(t,e),H(n,t,e),V(n,t,e.border),Y(n,t,e.padding),ae(n,t),c$1.draggable[t]=1,c$1.hoverEffectBg[t]=858993663,ie(n,t,e),re(n,t),ne(n,t,e);let l=e.min??0,u=e.max??100,b=e.value??0,y=e.step??1;return Ld(n,t,l,u,b,y),e.orientation!==void 0&&le(n,t,e.orientation),e.showValue!==void 0&&pe(n,t,e.showValue),Ot(t,e),e.parent!==void 0&&c(n,t,e.parent),t}function Bn(n,o={}){let e=xt.parse(o),t=d(n);if(P(n,t),z(t,e),U(t,e),H(n,t,e),V(n,t,e.border),Y(n,t,e.padding),$a(n,t,{keys:e.keys??true,submitOnEnter:e.submitOnEnter??true}),e.fields)for(let l of e.fields)db(n,t,l.entity,l.name,l.initialValue);return e.parent!==void 0&&c(n,t,e.parent),t}function kn(n,o={}){let e=Bt.parse(o),t=d(n);return P(n,t),z(t,e),U(t,e),H(n,t,e),V(n,t,e.border),Y(n,t,e.padding),Bb(n,t,{value:e.value??0,min:e.min??0,max:e.max??100,orientation:e.orientation??ub.Horizontal,showPercentage:e.showPercentage??false}),(e.fillChar!==void 0||e.emptyChar!==void 0||e.fillFg!==void 0||e.fillBg!==void 0||e.emptyFg!==void 0||e.emptyBg!==void 0)&&Pb(t,{fillChar:e.fillChar,emptyChar:e.emptyChar,fillFg:e.fillFg,fillBg:e.fillBg,emptyFg:e.emptyFg,emptyBg:e.emptyBg}),e.parent!==void 0&&c(n,t,e.parent),t}function Cn(n,o={}){let e=kt.parse(o),t=d(n);return P(n,t),z(t,e),U(t,e),H(n,t,e),V(n,t,e.border),Y(n,t,e.padding),fc(n,t),e.parent!==void 0&&c(n,t,e.parent),t}function Tn(n,o={}){let e$1=Ct.parse(o),t=d(n);return P(n,t),z(t,e$1),U(t,e$1),H(n,t,e$1),V(n,t,e$1.border),Y(n,t,e$1.padding),te(n,t),d$1.align[t]=0,d$1.valign[t]=1,e$1.label!==void 0&&e(n,t,e$1.label),ae(n,t),c$1.hoverEffectBg[t]=858993663,ie(n,t,e$1),re(n,t),ne(n,t,e$1),lc(n,t,e$1.radioSet),e$1.value!==void 0&&vc(t,e$1.value),(e$1.selectedChar!==void 0||e$1.unselectedChar!==void 0)&&Ac(t,{selectedChar:e$1.selectedChar,unselectedChar:e$1.unselectedChar}),e$1.parent!==void 0&&c(n,t,e$1.parent),e$1.selected&&wc(n,t),t}var jt=(t=>(t[t.STOPPED=0]="STOPPED",t[t.RUNNING=1]="RUNNING",t[t.PAUSED=2]="PAUSED",t))(jt||{});function ue(){let[n,o]=process.hrtime();return n+o/1e9}function Mn(n,o={},e={}){let t=n,l=c$4(),u={...e},b=0,y={targetFPS:o.targetFPS??60,fixedTimestep:o.fixedTimestep??true,maxDeltaTime:o.maxDeltaTime??.1,fixedTimestepMode:o.fixedTimestepMode},B=0,_=y.targetFPS>0?1/y.targetFPS:0,M=0,r=0,s=0,f=0,x=0,k=0,I=0,E=y.fixedTimestepMode?1/y.fixedTimestepMode.tickRate:1/60,q=0,oe=0,a=0,d=0,g=0,h=null,X=null;function Ee(){if(y.targetFPS===0)h=setImmediate(()=>me());else {let S=ue()-B,$=Math.max(0,_-S);$>.001?X=setTimeout(()=>me(),$*1e3):h=setImmediate(()=>me());}}function Se(){h!==null&&(clearImmediate(h),h=null),X!==null&&(clearTimeout(X),X=null);}function xe(p){u.onBeforeInput?.(t,p),t=l.run(t,p),u.onAfterInput?.(t,p),u.onBeforeUpdate?.(t,p),u.onAfterUpdate?.(t,p),u.onBeforeRender?.(t,p),u.onAfterRender?.(t,p),M++;}function Be(p){let S=y.fixedTimestepMode;if(!S)return;u.onBeforeInput?.(t,p),t=l.runInputOnly(t,p),u.onAfterInput?.(t,p),I+=p,g=0;let $=0;for(;I>=E;){if($>=S.maxUpdatesPerFrame){g=Math.floor(I/E),I=I%E;break}u.onBeforeFixedUpdate?.(t,E,q),u.onBeforeUpdate?.(t,E),t=l.runFixedUpdatePhases(t,E),u.onAfterUpdate?.(t,E),u.onAfterFixedUpdate?.(t,E,q),I-=E,q++,oe++,$++;}d=S.interpolate?I/E:0,S.interpolate&&u.onInterpolate&&u.onInterpolate(t,d),u.onBeforeRender?.(t,p),t=l.runRenderPhases(t,p),u.onAfterRender?.(t,p),M++;}function st(p,S){k=S*1e3,f++,p-s>=1&&(x=f,a=oe,f=0,oe=0,s=p);}function me(){if(b!==1)return;let p=ue(),S=p-B;B=p,S>y.maxDeltaTime&&(S=y.maxDeltaTime),y.fixedTimestepMode?Be(S):xe(S),st(p,S),Ee();}let ke={getState(){return b},isRunning(){return b===1},isPaused(){return b===2},isStopped(){return b===0},getStats(){return {fps:x,frameTime:k,frameCount:M,runningTime:b!==0?ue()-r:0,tickCount:q,ticksPerSecond:a,interpolationAlpha:d,skippedUpdates:g}},getInterpolationAlpha(){return d},getFixedTimestepConfig(){return y.fixedTimestepMode},isFixedTimestepMode(){return y.fixedTimestepMode!==void 0},getScheduler(){return l},getWorld(){return t},setWorld(p){if(b!==0)throw new Error("Cannot change world while loop is running");t=p;},setTargetFPS(p){y.targetFPS=p,_=p>0?1/p:0;},getTargetFPS(){return y.targetFPS},registerSystem(p,S,$=0){l.registerSystem(p,S,$);},unregisterSystem(p){l.unregisterSystem(p);},registerInputSystem(p,S=0){l.registerInputSystem(p,S);},setHooks(p){u={...u,...p};},start(){if(b===1)return;let p=b===0;b=1,B=ue(),p?(M=0,r=B,s=B,f=0,I=0,q=0,oe=0,a=0,d=0,g=0,u.onStart?.()):u.onResume?.(),Ee();},stop(){b!==0&&(Se(),b=0,u.onStop?.());},pause(){b===1&&(Se(),b=2,u.onPause?.());},resume(){b===2&&ke.start();},step(p){let S=ue(),$=p??(B>0?S-B:1/60);B=S;let fe=Math.min($,y.maxDeltaTime);y.fixedTimestepMode?Be(fe):xe(fe),k=fe*1e3;},stepFixed(){if(!y.fixedTimestepMode)throw new Error("stepFixed() requires fixedTimestepMode to be enabled");u.onBeforeFixedUpdate?.(t,E,q),u.onBeforeUpdate?.(t,E),t=l.runFixedUpdatePhases(t,E),u.onAfterUpdate?.(t,E),u.onAfterFixedUpdate?.(t,E,q),q++;}};return ke}function An(n){return n?.isRunning()??false}function Pn(n){return n?.isPaused()??false}var Rt=z$1.object({action:z$1.string().min(1,"Action name is required"),keys:z$1.array(z$1.string()).default([]),mouseButtons:z$1.array(z$1.enum(["left","right","middle","wheelUp","wheelDown","unknown"])).optional(),continuous:z$1.boolean().default(false),deadzone:z$1.number().min(0).max(1).default(.1)}),Lt=z$1.object({version:z$1.number().int().positive(),bindings:z$1.array(z$1.object({action:z$1.string(),keys:z$1.array(z$1.string()),mouseButtons:z$1.array(z$1.string()).optional(),continuous:z$1.boolean().optional()}))}),tt={active:false,justActivated:false,justDeactivated:false,activeTime:0,value:0},Wt=1;function Nt(n,o){for(let e of n.keys)if(o.isKeyDown(e))return true;for(let e of n.mouseButtons)if(o.isMouseButtonDown(e))return true;return false}function On(n){let o=new Map,e=new Map,t=new Map,l=new Set;function u(r,s,f){r.active=true,r.justActivated=true,r.activeTime=0,r.value=1,_(s,r,f);}function b(r,s,f){r.active=false,r.justDeactivated=true,r.value=0,_(s,r,f);}function y(r,s,f,x,k){r.activeTime+=x,r.value=1,s.continuous&&_(f,r,k);}function B(r,s,f,x,k){f.justActivated=false,f.justDeactivated=false;let I=f.active,E=Nt(s,k);E&&!I?u(f,r,k):!E&&I?b(f,r,k):E&&y(f,s,r,x,k);}function _(r,s,f){let x=t.get(r);if(x)for(let k of x)k(r,s,f);for(let k of l)k(r,s,f);}let M={register(r){let s=Rt.parse(r),f={action:s.action,keys:[...s.keys],mouseButtons:s.mouseButtons?[...s.mouseButtons]:[],continuous:s.continuous??false,deadzone:s.deadzone??.1};return o.set(s.action,f),e.has(s.action)||e.set(s.action,{...tt}),M},registerAll(r){for(let s of r)M.register(s);return M},unregister(r){let s=o.delete(r);return e.delete(r),t.delete(r),s},hasAction(r){return o.has(r)},getActions(){return [...o.keys()]},getBinding(r){let s=o.get(r);if(s)return {action:s.action,keys:[...s.keys],mouseButtons:s.mouseButtons.length>0?[...s.mouseButtons]:void 0,continuous:s.continuous,deadzone:s.deadzone}},update(r,s){let f=s*1e3;for(let[x,k]of o){let I=e.get(x);I&&B(x,k,I,f,r);}},isActive(r){return e.get(r)?.active??false},isJustActivated(r){return e.get(r)?.justActivated??false},isJustDeactivated(r){return e.get(r)?.justDeactivated??false},getValue(r){return e.get(r)?.value??0},getActiveTime(r){return e.get(r)?.activeTime??0},getState(r){return e.get(r)??tt},getActiveActions(){let r=[];for(let[s,f]of e)f.active&&r.push(s);return r},rebindKeys(r,s){let f=o.get(r);return f?(f.keys=[...s],true):false},rebindMouseButtons(r,s){let f=o.get(r);return f?(f.mouseButtons=[...s],true):false},addKey(r,s){let f=o.get(r);return f?(f.keys.includes(s)||f.keys.push(s),true):false},removeKey(r,s){let f=o.get(r);if(!f)return false;let x=f.keys.indexOf(s);return x!==-1?(f.keys.splice(x,1),true):false},getKeysForAction(r){let s=o.get(r);return s?[...s.keys]:[]},getMouseButtonsForAction(r){let s=o.get(r);return s?[...s.mouseButtons]:[]},getActionsForKey(r){let s=[];for(let[f,x]of o)x.keys.includes(r)&&s.push(f);return s},onAction(r,s){let f=t.get(r);return f||(f=new Set,t.set(r,f)),f.add(s),()=>{f?.delete(s);}},onAnyAction(r){return l.add(r),()=>{l.delete(r);}},saveBindings(){let r=[];for(let[,s]of o)r.push({action:s.action,keys:[...s.keys],mouseButtons:s.mouseButtons.length>0?[...s.mouseButtons]:void 0,continuous:s.continuous||void 0});return {version:Wt,bindings:r}},loadBindings(r){let s=Lt.parse(r);o.clear(),e.clear();for(let f of s.bindings)M.register({action:f.action,keys:f.keys,mouseButtons:f.mouseButtons,continuous:f.continuous});},toJSON(r=false){let s=M.saveBindings();return r?JSON.stringify(s,null,2):JSON.stringify(s)},fromJSON(r){let s=JSON.parse(r);M.loadBindings(s);},resetStates(){for(let r of e.values())r.active=false,r.justActivated=false,r.justDeactivated=false,r.activeTime=0,r.value=0;},clear(){o.clear(),e.clear(),t.clear(),l.clear();}};return n&&M.registerAll(n),M}var jn={platformer:[{action:"move_left",keys:["a","left"],continuous:true},{action:"move_right",keys:["d","right"],continuous:true},{action:"jump",keys:["space","w","up"]},{action:"crouch",keys:["s","down"],continuous:true},{action:"attack",keys:["j","enter"]}],topDown:[{action:"move_up",keys:["w","up"],continuous:true},{action:"move_down",keys:["s","down"],continuous:true},{action:"move_left",keys:["a","left"],continuous:true},{action:"move_right",keys:["d","right"],continuous:true},{action:"action",keys:["space","enter"]}],menu:[{action:"up",keys:["w","up"]},{action:"down",keys:["s","down"]},{action:"left",keys:["a","left"]},{action:"right",keys:["d","right"]},{action:"confirm",keys:["enter","space"]},{action:"cancel",keys:["escape","backspace"]}]};function ce(){return performance.now()}function he(n){return n.length===0?0:n.reduce((e,t)=>e+t,0)/n.length}function nt(n,o){if(n.length===0)return 0;if(n.length===1)return n[0]??0;let e=Math.ceil(o*n.length)-1;return n[Math.max(0,Math.min(e,n.length-1))]??0}function zt(n,o){o&&console.warn(`[InputEventBuffer] Dropped ${n} events due to buffer overflow`);}function Ut(n={}){let o=n.warnOnOverflow??true;return {keyEvents:[],mouseEvents:[],latencySamples:[],frameProcessingTimes:[],frameStartTime:0,totalKeyEvents:0,totalMouseEvents:0,droppedEvents:0,config:{maxBufferSize:n.maxBufferSize??1e3,maxLatencySamples:n.maxLatencySamples??1e3,maxFrameSamples:n.maxFrameSamples??100,warnOnOverflow:o,onOverflow:n.onOverflow??(e=>zt(e,o))}}}function ot(n,o){let e=n.config.maxBufferSize;if(e<=0)return 0;if(o.length>e){let t=o.length-e;return o.splice(0,t),n.droppedEvents+=t,n.config.onOverflow(t),t}return 0}function Ln(n,o,e){n.totalKeyEvents++;let t={type:"key",event:o,timestamp:e??ce()};n.keyEvents.push(t),ot(n,n.keyEvents);}function Wn(n,o,e){n.totalMouseEvents++;let t={type:"mouse",event:o,timestamp:e??ce()};n.mouseEvents.push(t),ot(n,n.mouseEvents);}function Ht(n){let o=n.keyEvents;return n.keyEvents=[],o}function Vt(n){let o=n.mouseEvents;return n.mouseEvents=[],o}function Nn(n){let o=Ht(n),e=Vt(n),t=[...o,...e];return t.sort((l,u)=>l.timestamp-u.timestamp),t}function zn(n){let o=[...n.keyEvents,...n.mouseEvents];return o.sort((e,t)=>e.timestamp-t.timestamp),o}function Un(n){return n.keyEvents}function Hn(n){return n.mouseEvents}function Vn(n){n.keyEvents=[],n.mouseEvents=[];}function Yn(n){return n.keyEvents.length}function _n(n){return n.mouseEvents.length}function Xn(n){return n.keyEvents.length+n.mouseEvents.length}function Gn(n){return n.keyEvents.length>0||n.mouseEvents.length>0}function Jn(n){return {totalKeyEvents:n.totalKeyEvents,totalMouseEvents:n.totalMouseEvents,pendingKeyEvents:n.keyEvents.length,pendingMouseEvents:n.mouseEvents.length,droppedEvents:n.droppedEvents,maxBufferSize:n.config.maxBufferSize}}function qn(n){n.totalKeyEvents=0,n.totalMouseEvents=0,n.droppedEvents=0;}function wn(n){n.frameStartTime=ce();}function $n(n){let e=ce()-n.frameStartTime;return n.frameProcessingTimes.push(e),n.frameProcessingTimes.length>n.config.maxFrameSamples&&n.frameProcessingTimes.shift(),e}function Qn(n,o){n.latencySamples.push(o),n.latencySamples.length>n.config.maxLatencySamples&&n.latencySamples.shift();}function Zn(n,o,e){for(let t=0;t<Math.min(e,10);t++)n.latencySamples.push(o);for(;n.latencySamples.length>n.config.maxLatencySamples;)n.latencySamples.shift();}function it(n){let o=n.latencySamples,e=n.frameProcessingTimes;if(o.length===0)return {min:0,max:0,avg:0,p95:0,p99:0,sampleCount:0,lastFrameProcessingTime:e[e.length-1]??0,avgFrameProcessingTime:he(e)};let t=[...o].sort((l,u)=>l-u);return {min:t[0]??0,max:t[t.length-1]??0,avg:he(t),p95:nt(t,.95),p99:nt(t,.99),sampleCount:t.length,lastFrameProcessingTime:e[e.length-1]??0,avgFrameProcessingTime:he(e)}}function eo(n){n.latencySamples=[],n.frameProcessingTimes=[];}function to(n,o=16){return it(n).p95<=o}function no(n,o=1){return it(n).avgFrameProcessingTime<=o}var oo=Ut();var at={pressed:false,justPressed:false,justReleased:false,heldTime:0,repeatCount:0,lastEventTime:0},se={pressed:false,justPressed:false,justReleased:false,heldTime:0,lastEventTime:0};function rt(){return {x:0,y:0,deltaX:0,deltaY:0,wheelDelta:0,buttons:{left:{...se},right:{...se},middle:{...se},wheelUp:{...se},wheelDown:{...se},unknown:{...se}}}}function Yt(n,o){return n.toLowerCase()}function ao(n={}){let o={trackRepeats:n.trackRepeats??true,debounceTime:n.debounceTime??0,customRepeatRate:n.customRepeatRate??0,customRepeatDelay:n.customRepeatDelay??500},e=new Map,t=rt(),l=0,u=0,b=0,y=false,B=false,_=false;function M(){for(let a of e.values())a.justPressed=false,a.justReleased=false;for(let a of Object.values(t.buttons))a.justPressed=false,a.justReleased=false;}function r(a){for(let d of e.values())d.pressed&&(d.heldTime+=a);}function s(a,d){return o.debounceTime<=0||a.lastEventTime<=0?false:d-a.lastEventTime<o.debounceTime}function f(a){o.trackRepeats&&a.repeatCount++;}function x(a){a.pressed=true,a.justPressed=true,a.justReleased=false,a.heldTime=0,a.repeatCount=0;}function k(a,d){let g=Yt(a.name),h=e.get(g);h||(h={...at},e.set(g,h)),!s(h,d)&&(h.pressed?f(h):x(h),h.lastEventTime=d,a.ctrl&&!h.pressed&&(y=true),a.meta&&!h.pressed&&(B=true),a.shift&&!h.pressed&&(_=true));}function I(a,d){let g=e.get(a);!g||!g.pressed||(g.pressed=false,g.justPressed=false,g.justReleased=true,g.lastEventTime=d,a==="ctrl"&&(y=false),a==="alt"&&(B=false),a==="shift"&&(_=false));}function E(a){let d=t.x,g=t.y;t.x=a.x,t.y=a.y,t.deltaX+=a.x-d,t.deltaY+=a.y-g;}function q(a,d,g){d==="press"&&!a.pressed?(a.pressed=true,a.justPressed=true,a.justReleased=false,a.heldTime=0):d==="release"&&a.pressed&&(a.pressed=false,a.justPressed=false,a.justReleased=true),a.lastEventTime=g;}function oe(a,d){E(a),a.button==="wheelUp"?t.wheelDelta+=1:a.button==="wheelDown"&&(t.wheelDelta-=1);let g=t.buttons[a.button];g&&q(g,a.action,d);}return {update(a,d,g){l++,u=a.length,b=d.length;let h=g*1e3;M(),r(h);for(let X of a)k(X.event,X.timestamp);t.deltaX=0,t.deltaY=0,t.wheelDelta=0;for(let X of d)oe(X.event,X.timestamp);for(let X of Object.values(t.buttons))X.pressed&&(X.heldTime+=h);},isKeyDown(a){return e.get(a.toLowerCase())?.pressed??false},isKeyPressed(a){return e.get(a.toLowerCase())?.justPressed??false},isKeyReleased(a){return e.get(a.toLowerCase())?.justReleased??false},getKeyHeldTime(a){return e.get(a.toLowerCase())?.heldTime??0},getKeyState(a){return e.get(a.toLowerCase())??at},getKeyRepeatCount(a){return e.get(a.toLowerCase())?.repeatCount??0},getPressedKeys(){let a=[];for(let[d,g]of e)g.pressed&&a.push(d);return a},getJustPressedKeys(){let a=[];for(let[d,g]of e)g.justPressed&&a.push(d);return a},getJustReleasedKeys(){let a=[];for(let[d,g]of e)g.justReleased&&a.push(d);return a},isCtrlDown(){return y},isAltDown(){return B},isShiftDown(){return _},hasModifier(){return y||B||_},isMouseButtonDown(a){return t.buttons[a]?.pressed??false},isMouseButtonPressed(a){return t.buttons[a]?.justPressed??false},isMouseButtonReleased(a){return t.buttons[a]?.justReleased??false},getMouseX(){return t.x},getMouseY(){return t.y},getMousePosition(){return {x:t.x,y:t.y}},getMouseDelta(){return {deltaX:t.deltaX,deltaY:t.deltaY}},getWheelDelta(){return t.wheelDelta},getMouseState(){return t},releaseKey(a){I(a.toLowerCase(),performance.now());},releaseAllKeys(){let a=performance.now();for(let[d,g]of e)g.pressed&&I(d,a);y=false,B=false,_=false;},releaseAllMouseButtons(){let a=performance.now();for(let d of Object.values(t.buttons))d.pressed&&(d.pressed=false,d.justReleased=true,d.lastEventTime=a);},releaseAll(){this.releaseAllKeys(),this.releaseAllMouseButtons();},getStats(){let a=0,d=0,g=0;for(let h of e.values())h.pressed&&a++,h.justPressed&&d++,h.justReleased&&g++;return {keysDown:a,keysPressed:d,keysReleased:g,keyEventsThisFrame:u,mouseEventsThisFrame:b,frameCount:l}},getFrameCount(){return l},reset(){e.clear(),t=rt(),l=0,u=0,b=0,y=false,B=false,_=false;}}}function ro(n,o){for(let e of o)if(n.isKeyDown(e))return true;return false}function so(n,o){for(let e of o)if(!n.isKeyDown(e))return false;return true}function lo(n,o){for(let e of o)if(n.isKeyPressed(e))return true;return false}function uo(n){let o=0,e=0;return (n.isKeyDown("a")||n.isKeyDown("left"))&&(o-=1),(n.isKeyDown("d")||n.isKeyDown("right"))&&(o+=1),(n.isKeyDown("w")||n.isKeyDown("up"))&&(e-=1),(n.isKeyDown("s")||n.isKeyDown("down"))&&(e+=1),{x:o,y:e}}export{qn as $,Bn as A,kn as B,Cn as C,Tn as D,jt as E,Mn as F,An as G,Pn as H,Rt as I,Lt as J,On as K,jn as L,Ut as M,Ln as N,Wn as O,Ht as P,Vt as Q,Nn as R,zn as S,Un as T,Hn as U,Vn as V,Yn as W,_n as X,Xn as Y,Gn as Z,Jn as _,dt as a,wn as aa,pt as b,$n as ba,ct as c,Qn as ca,mt as d,Zn as da,gt as e,it as ea,bt as f,eo as fa,yt as g,to as ga,vt as h,no as ha,ht as i,oo as ia,Et as j,ao as ja,St as k,ro as ka,xt as l,so as la,Bt as m,lo as ma,kt as n,uo as na,Ct as o,pn as p,cn as q,mn as r,gn as s,bn as t,yn as u,vn as v,hn as w,En as x,Sn as y,xn as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var k=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var l=(a,b)=>()=>(a&&(b=a(a=0)),b);var m=(a,b)=>{for(var c in b)e(a,c,{get:b[c],enumerable:true});},j=(a,b,c,f)=>{if(b&&typeof b=="object"||typeof b=="function")for(let d of h(b))!i.call(a,d)&&d!==c&&e(a,d,{get:()=>b[d],enumerable:!(f=g(b,d))||f.enumerable});return a};var n=a=>j(e({},"__esModule",{value:true}),a);export{k as a,l as b,m as c,n as d};
|