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,297 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Virtualized Line Store for Large Text Content
|
|
5
|
+
*
|
|
6
|
+
* High-performance data structure for storing and accessing millions of lines
|
|
7
|
+
* with O(1) random access. Optimized for read-only content with streaming append.
|
|
8
|
+
*
|
|
9
|
+
* @module utils/virtualizedLineStore
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { createLineStore, getLineAtIndex, getLineRange } from 'blecsd';
|
|
14
|
+
*
|
|
15
|
+
* // Create store from content
|
|
16
|
+
* const store = createLineStore(largeTextContent);
|
|
17
|
+
*
|
|
18
|
+
* // O(1) access to any line
|
|
19
|
+
* const line1000 = getLineAtIndex(store, 1000);
|
|
20
|
+
*
|
|
21
|
+
* // Get visible range for viewport
|
|
22
|
+
* const visibleLines = getLineRange(store, 1000, 1025);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Schema for line index validation.
|
|
28
|
+
*/
|
|
29
|
+
declare const LineIndexSchema: z.ZodNumber;
|
|
30
|
+
/**
|
|
31
|
+
* Schema for line range parameters.
|
|
32
|
+
*/
|
|
33
|
+
declare const LineRangeParamsSchema: z.ZodObject<{
|
|
34
|
+
startLine: z.ZodNumber;
|
|
35
|
+
endLine: z.ZodNumber;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
/**
|
|
38
|
+
* Schema for visible lines parameters.
|
|
39
|
+
*/
|
|
40
|
+
declare const VisibleLinesParamsSchema: z.ZodObject<{
|
|
41
|
+
firstVisible: z.ZodNumber;
|
|
42
|
+
visibleCount: z.ZodNumber;
|
|
43
|
+
overscanBefore: z.ZodDefault<z.ZodNumber>;
|
|
44
|
+
overscanAfter: z.ZodDefault<z.ZodNumber>;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
/**
|
|
47
|
+
* Schema for trim parameters.
|
|
48
|
+
*/
|
|
49
|
+
declare const TrimParamsSchema: z.ZodObject<{
|
|
50
|
+
maxLines: z.ZodNumber;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
/** Maximum lines before switching to chunked mode */
|
|
53
|
+
declare const CHUNKED_THRESHOLD = 1000000;
|
|
54
|
+
/**
|
|
55
|
+
* Statistics about a line store.
|
|
56
|
+
*/
|
|
57
|
+
interface LineStoreStats {
|
|
58
|
+
/** Total line count */
|
|
59
|
+
readonly lineCount: number;
|
|
60
|
+
/** Total byte size of content */
|
|
61
|
+
readonly byteSize: number;
|
|
62
|
+
/** Memory used by offset array */
|
|
63
|
+
readonly offsetArrayBytes: number;
|
|
64
|
+
/** Total memory estimate */
|
|
65
|
+
readonly totalMemoryBytes: number;
|
|
66
|
+
/** Average line length */
|
|
67
|
+
readonly avgLineLength: number;
|
|
68
|
+
/** Whether content is indexed */
|
|
69
|
+
readonly indexed: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A range of lines from the store.
|
|
73
|
+
*/
|
|
74
|
+
interface LineRange {
|
|
75
|
+
/** Lines in the range */
|
|
76
|
+
readonly lines: readonly string[];
|
|
77
|
+
/** Start line index (actual) */
|
|
78
|
+
readonly startLine: number;
|
|
79
|
+
/** End line index (exclusive) */
|
|
80
|
+
readonly endLine: number;
|
|
81
|
+
/** Time to extract in milliseconds */
|
|
82
|
+
readonly extractTimeMs: number;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Information about a single line.
|
|
86
|
+
*/
|
|
87
|
+
interface LineInfo {
|
|
88
|
+
/** Line content (without newline) */
|
|
89
|
+
readonly text: string;
|
|
90
|
+
/** Byte offset in buffer */
|
|
91
|
+
readonly offset: number;
|
|
92
|
+
/** Line length in bytes */
|
|
93
|
+
readonly length: number;
|
|
94
|
+
/** Line number (0-based) */
|
|
95
|
+
readonly lineNumber: number;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Immutable view of a virtualized line store.
|
|
99
|
+
*/
|
|
100
|
+
interface VirtualizedLineStore {
|
|
101
|
+
/** Raw content buffer */
|
|
102
|
+
readonly buffer: string;
|
|
103
|
+
/** Line start offsets (position of first char of each line) */
|
|
104
|
+
readonly offsets: Uint32Array;
|
|
105
|
+
/** Total line count */
|
|
106
|
+
readonly lineCount: number;
|
|
107
|
+
/** Total byte size */
|
|
108
|
+
readonly byteSize: number;
|
|
109
|
+
/** Whether offsets are computed */
|
|
110
|
+
readonly indexed: boolean;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Creates a virtualized line store from content.
|
|
114
|
+
*
|
|
115
|
+
* @param content - Text content (newline-separated lines)
|
|
116
|
+
* @returns New line store
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* import { createLineStore } from 'blecsd';
|
|
121
|
+
*
|
|
122
|
+
* const store = createLineStore('Line 1\nLine 2\nLine 3');
|
|
123
|
+
* console.log(store.lineCount); // 3
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
declare function createLineStore(content?: string): VirtualizedLineStore;
|
|
127
|
+
/**
|
|
128
|
+
* Creates a line store from an array of lines.
|
|
129
|
+
*
|
|
130
|
+
* @param lines - Array of line strings
|
|
131
|
+
* @returns New line store
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* import { createLineStoreFromLines } from 'blecsd';
|
|
136
|
+
*
|
|
137
|
+
* const store = createLineStoreFromLines(['Line 1', 'Line 2', 'Line 3']);
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
declare function createLineStoreFromLines(lines: readonly string[]): VirtualizedLineStore;
|
|
141
|
+
/**
|
|
142
|
+
* Creates an empty line store.
|
|
143
|
+
*
|
|
144
|
+
* @returns Empty line store
|
|
145
|
+
*/
|
|
146
|
+
declare function createEmptyLineStore(): VirtualizedLineStore;
|
|
147
|
+
/**
|
|
148
|
+
* Gets a line at a specific index. O(1) operation.
|
|
149
|
+
*
|
|
150
|
+
* @param store - The line store
|
|
151
|
+
* @param index - Line index (0-based)
|
|
152
|
+
* @returns Line content or undefined if out of bounds
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* import { createLineStore, getLineAtIndex } from 'blecsd';
|
|
157
|
+
*
|
|
158
|
+
* const store = createLineStore('Line 1\nLine 2\nLine 3');
|
|
159
|
+
* console.log(getLineAtIndex(store, 1)); // 'Line 2'
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
declare function getLineAtIndex(store: VirtualizedLineStore, index: number): string | undefined;
|
|
163
|
+
/**
|
|
164
|
+
* Gets detailed information about a line.
|
|
165
|
+
*
|
|
166
|
+
* @param store - The line store
|
|
167
|
+
* @param index - Line index (0-based)
|
|
168
|
+
* @returns Line info or undefined if out of bounds
|
|
169
|
+
*/
|
|
170
|
+
declare function getLineInfo(store: VirtualizedLineStore, index: number): LineInfo | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* Gets a range of lines. Optimized for viewport extraction.
|
|
173
|
+
*
|
|
174
|
+
* @param store - The line store
|
|
175
|
+
* @param startLine - Start line index (inclusive)
|
|
176
|
+
* @param endLine - End line index (exclusive)
|
|
177
|
+
* @returns Line range result
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* import { createLineStore, getLineRange } from 'blecsd';
|
|
182
|
+
*
|
|
183
|
+
* const store = createLineStore(largeContent);
|
|
184
|
+
* const viewport = getLineRange(store, 1000, 1025);
|
|
185
|
+
* console.log(viewport.lines.length); // 25
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
declare function getLineRange(store: VirtualizedLineStore, startLine: number, endLine: number): LineRange;
|
|
189
|
+
/**
|
|
190
|
+
* Gets visible lines for a viewport with overscan.
|
|
191
|
+
*
|
|
192
|
+
* @param store - The line store
|
|
193
|
+
* @param firstVisible - First visible line index
|
|
194
|
+
* @param visibleCount - Number of visible lines
|
|
195
|
+
* @param overscanBefore - Extra lines to include before viewport
|
|
196
|
+
* @param overscanAfter - Extra lines to include after viewport
|
|
197
|
+
* @returns Line range with overscan
|
|
198
|
+
*/
|
|
199
|
+
declare function getVisibleLines(store: VirtualizedLineStore, firstVisible: number, visibleCount: number, overscanBefore?: number, overscanAfter?: number): LineRange;
|
|
200
|
+
/**
|
|
201
|
+
* Appends content to the store, returning a new store.
|
|
202
|
+
* Optimized for streaming append (log viewers).
|
|
203
|
+
*
|
|
204
|
+
* @param store - The original store
|
|
205
|
+
* @param content - Content to append
|
|
206
|
+
* @returns New store with appended content
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```typescript
|
|
210
|
+
* import { createLineStore, appendToStore } from 'blecsd';
|
|
211
|
+
*
|
|
212
|
+
* let store = createLineStore('Line 1');
|
|
213
|
+
* store = appendToStore(store, '\nLine 2\nLine 3');
|
|
214
|
+
* console.log(store.lineCount); // 3
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
declare function appendToStore(store: VirtualizedLineStore, content: string): VirtualizedLineStore;
|
|
218
|
+
/**
|
|
219
|
+
* Appends lines to the store.
|
|
220
|
+
*
|
|
221
|
+
* @param store - The original store
|
|
222
|
+
* @param lines - Lines to append
|
|
223
|
+
* @returns New store with appended lines
|
|
224
|
+
*/
|
|
225
|
+
declare function appendLines(store: VirtualizedLineStore, lines: readonly string[]): VirtualizedLineStore;
|
|
226
|
+
/**
|
|
227
|
+
* Gets the line count.
|
|
228
|
+
*
|
|
229
|
+
* @param store - The line store
|
|
230
|
+
* @returns Total line count
|
|
231
|
+
*/
|
|
232
|
+
declare function getLineCount(store: VirtualizedLineStore): number;
|
|
233
|
+
/**
|
|
234
|
+
* Gets the byte size of the content.
|
|
235
|
+
*
|
|
236
|
+
* @param store - The line store
|
|
237
|
+
* @returns Total byte size
|
|
238
|
+
*/
|
|
239
|
+
declare function getByteSize(store: VirtualizedLineStore): number;
|
|
240
|
+
/**
|
|
241
|
+
* Checks if the store is empty.
|
|
242
|
+
*
|
|
243
|
+
* @param store - The line store
|
|
244
|
+
* @returns true if empty
|
|
245
|
+
*/
|
|
246
|
+
declare function isStoreEmpty(store: VirtualizedLineStore): boolean;
|
|
247
|
+
/**
|
|
248
|
+
* Gets statistics about the store.
|
|
249
|
+
*
|
|
250
|
+
* @param store - The line store
|
|
251
|
+
* @returns Store statistics
|
|
252
|
+
*/
|
|
253
|
+
declare function getStoreStats(store: VirtualizedLineStore): LineStoreStats;
|
|
254
|
+
/**
|
|
255
|
+
* Finds the line index for a byte offset.
|
|
256
|
+
* Uses binary search for O(log n) performance.
|
|
257
|
+
*
|
|
258
|
+
* @param store - The line store
|
|
259
|
+
* @param byteOffset - Byte offset in buffer
|
|
260
|
+
* @returns Line index containing the offset
|
|
261
|
+
*/
|
|
262
|
+
declare function getLineForOffset(store: VirtualizedLineStore, byteOffset: number): number;
|
|
263
|
+
/**
|
|
264
|
+
* Gets the byte offset for a line.
|
|
265
|
+
*
|
|
266
|
+
* @param store - The line store
|
|
267
|
+
* @param lineIndex - Line index
|
|
268
|
+
* @returns Byte offset or -1 if out of bounds
|
|
269
|
+
*/
|
|
270
|
+
declare function getOffsetForLine(store: VirtualizedLineStore, lineIndex: number): number;
|
|
271
|
+
/**
|
|
272
|
+
* Exports all content as a string.
|
|
273
|
+
*
|
|
274
|
+
* @param store - The line store
|
|
275
|
+
* @returns Full content
|
|
276
|
+
*/
|
|
277
|
+
declare function exportContent(store: VirtualizedLineStore): string;
|
|
278
|
+
/**
|
|
279
|
+
* Exports a range of lines as a string.
|
|
280
|
+
*
|
|
281
|
+
* @param store - The line store
|
|
282
|
+
* @param startLine - Start line index
|
|
283
|
+
* @param endLine - End line index (exclusive)
|
|
284
|
+
* @returns Content of the line range
|
|
285
|
+
*/
|
|
286
|
+
declare function exportLineRange(store: VirtualizedLineStore, startLine: number, endLine: number): string;
|
|
287
|
+
/**
|
|
288
|
+
* Creates a trimmed store with only the last N lines.
|
|
289
|
+
* Useful for keeping log buffers bounded.
|
|
290
|
+
*
|
|
291
|
+
* @param store - The line store
|
|
292
|
+
* @param maxLines - Maximum lines to keep
|
|
293
|
+
* @returns New store with at most maxLines
|
|
294
|
+
*/
|
|
295
|
+
declare function trimToLineCount(store: VirtualizedLineStore, maxLines: number): VirtualizedLineStore;
|
|
296
|
+
|
|
297
|
+
export { CHUNKED_THRESHOLD as C, LineIndexSchema as L, TrimParamsSchema as T, type VirtualizedLineStore as V, LineRangeParamsSchema as a, type LineStoreStats as b, type LineInfo as c, type LineRange as d, VisibleLinesParamsSchema as e, appendLines as f, appendToStore as g, createEmptyLineStore as h, createLineStore as i, createLineStoreFromLines as j, exportContent as k, exportLineRange as l, getByteSize as m, getLineAtIndex as n, getLineForOffset as o, getLineInfo as p, getLineCount as q, getLineRange as r, getVisibleLines as s, getOffsetForLine as t, getStoreStats as u, isStoreEmpty as v, trimToLineCount as w };
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { E as Entity, W as World } from '../types-BcsvoKzf.js';
|
|
3
|
+
import { BitmapFont } from './fonts/index.js';
|
|
4
|
+
import 'bitecs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* BigText Widget
|
|
8
|
+
*
|
|
9
|
+
* Renders large ASCII art text using bitmap fonts.
|
|
10
|
+
*
|
|
11
|
+
* @module widgets/bigText
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Dimension value that can be a number, percentage string, or 'auto'.
|
|
16
|
+
*/
|
|
17
|
+
type DimensionValue = number | `${number}%` | 'auto';
|
|
18
|
+
/**
|
|
19
|
+
* Position value that can be a number, percentage string, or keyword.
|
|
20
|
+
*/
|
|
21
|
+
type PositionValue = number | `${number}%` | 'center' | 'left' | 'right' | 'top' | 'bottom';
|
|
22
|
+
/**
|
|
23
|
+
* Bitmap font definition for BigText.
|
|
24
|
+
*/
|
|
25
|
+
type FontDefinition = BitmapFont;
|
|
26
|
+
/**
|
|
27
|
+
* Configuration for creating a BigText widget.
|
|
28
|
+
*/
|
|
29
|
+
interface BigTextConfig {
|
|
30
|
+
/** Left position (absolute or percentage) */
|
|
31
|
+
readonly left?: PositionValue;
|
|
32
|
+
/** Top position (absolute or percentage) */
|
|
33
|
+
readonly top?: PositionValue;
|
|
34
|
+
/** Right position (absolute or percentage) */
|
|
35
|
+
readonly right?: PositionValue;
|
|
36
|
+
/** Bottom position (absolute or percentage) */
|
|
37
|
+
readonly bottom?: PositionValue;
|
|
38
|
+
/** Width (absolute, percentage, or 'auto') - defaults to 'auto' */
|
|
39
|
+
readonly width?: DimensionValue;
|
|
40
|
+
/** Height (absolute, percentage, or 'auto') - defaults to 'auto' */
|
|
41
|
+
readonly height?: DimensionValue;
|
|
42
|
+
/** Foreground color (hex string or packed number) */
|
|
43
|
+
readonly fg?: string | number;
|
|
44
|
+
/** Background color (hex string or packed number) */
|
|
45
|
+
readonly bg?: string | number;
|
|
46
|
+
/** Text content */
|
|
47
|
+
readonly text: string;
|
|
48
|
+
/** Font name (built-in), path, or font definition */
|
|
49
|
+
readonly font?: string | FontDefinition;
|
|
50
|
+
/** Whether to shrink to content size (default: true) */
|
|
51
|
+
readonly shrink?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* BigText widget interface providing chainable methods.
|
|
55
|
+
*/
|
|
56
|
+
interface BigTextWidget {
|
|
57
|
+
/** The underlying entity ID */
|
|
58
|
+
readonly eid: Entity;
|
|
59
|
+
/** Shows the widget */
|
|
60
|
+
show(): BigTextWidget;
|
|
61
|
+
/** Hides the widget */
|
|
62
|
+
hide(): BigTextWidget;
|
|
63
|
+
/** Moves the widget by dx, dy */
|
|
64
|
+
move(dx: number, dy: number): BigTextWidget;
|
|
65
|
+
/** Sets the absolute position */
|
|
66
|
+
setPosition(x: number, y: number): BigTextWidget;
|
|
67
|
+
/** Sets the text content */
|
|
68
|
+
setText(text: string): BigTextWidget;
|
|
69
|
+
/** Gets the text content */
|
|
70
|
+
getText(): string;
|
|
71
|
+
/** Focuses the widget */
|
|
72
|
+
focus(): BigTextWidget;
|
|
73
|
+
/** Blurs the widget */
|
|
74
|
+
blur(): BigTextWidget;
|
|
75
|
+
/** Checks if the widget is focused */
|
|
76
|
+
isFocused(): boolean;
|
|
77
|
+
/** Appends a child entity to this widget */
|
|
78
|
+
append(child: Entity): BigTextWidget;
|
|
79
|
+
/** Gets all direct children of this widget */
|
|
80
|
+
getChildren(): Entity[];
|
|
81
|
+
/** Destroys the widget and removes it from the world */
|
|
82
|
+
destroy(): void;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Zod schema for BigText widget configuration.
|
|
86
|
+
*/
|
|
87
|
+
declare const BigTextConfigSchema: z.ZodObject<{
|
|
88
|
+
left: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodEnum<{
|
|
89
|
+
left: "left";
|
|
90
|
+
top: "top";
|
|
91
|
+
right: "right";
|
|
92
|
+
bottom: "bottom";
|
|
93
|
+
center: "center";
|
|
94
|
+
}>]>>;
|
|
95
|
+
top: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodEnum<{
|
|
96
|
+
left: "left";
|
|
97
|
+
top: "top";
|
|
98
|
+
right: "right";
|
|
99
|
+
bottom: "bottom";
|
|
100
|
+
center: "center";
|
|
101
|
+
}>]>>;
|
|
102
|
+
right: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodEnum<{
|
|
103
|
+
left: "left";
|
|
104
|
+
top: "top";
|
|
105
|
+
right: "right";
|
|
106
|
+
bottom: "bottom";
|
|
107
|
+
center: "center";
|
|
108
|
+
}>]>>;
|
|
109
|
+
bottom: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodEnum<{
|
|
110
|
+
left: "left";
|
|
111
|
+
top: "top";
|
|
112
|
+
right: "right";
|
|
113
|
+
bottom: "bottom";
|
|
114
|
+
center: "center";
|
|
115
|
+
}>]>>;
|
|
116
|
+
width: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodLiteral<"auto">]>>;
|
|
117
|
+
height: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodLiteral<"auto">]>>;
|
|
118
|
+
fg: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
119
|
+
bg: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
120
|
+
text: z.ZodString;
|
|
121
|
+
font: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
122
|
+
name: z.ZodString;
|
|
123
|
+
size: z.ZodNumber;
|
|
124
|
+
weight: z.ZodEnum<{
|
|
125
|
+
bold: "bold";
|
|
126
|
+
normal: "normal";
|
|
127
|
+
}>;
|
|
128
|
+
charWidth: z.ZodNumber;
|
|
129
|
+
charHeight: z.ZodNumber;
|
|
130
|
+
chars: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
131
|
+
width: z.ZodNumber;
|
|
132
|
+
height: z.ZodNumber;
|
|
133
|
+
bitmap: z.ZodArray<z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>]>>>;
|
|
134
|
+
}, z.core.$strip>>;
|
|
135
|
+
}, z.core.$strip>]>>;
|
|
136
|
+
shrink: z.ZodOptional<z.ZodBoolean>;
|
|
137
|
+
}, z.core.$strip>;
|
|
138
|
+
/**
|
|
139
|
+
* BigText component marker for identifying BigText entities.
|
|
140
|
+
*/
|
|
141
|
+
declare const BigText: {
|
|
142
|
+
/** Tag indicating this is a BigText widget (1 = yes) */
|
|
143
|
+
isBigText: Uint8Array<ArrayBuffer>;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Loads a bitmap font definition from a JSON file path.
|
|
147
|
+
*
|
|
148
|
+
* @param path - Path to the font JSON file
|
|
149
|
+
* @returns Loaded font definition
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* import { loadFontFromPath } from 'blecsd/widgets/bigText';
|
|
154
|
+
*
|
|
155
|
+
* const font = loadFontFromPath('./fonts/terminus-14-bold.json');
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
declare function loadFontFromPath(path: string): FontDefinition;
|
|
159
|
+
/** @deprecated Use `loadFontFromPath` instead */
|
|
160
|
+
declare const loadFont: typeof loadFontFromPath;
|
|
161
|
+
/**
|
|
162
|
+
* Creates a BigText widget with the given configuration.
|
|
163
|
+
*
|
|
164
|
+
* Returns a Promise because font data is loaded lazily to avoid bundling
|
|
165
|
+
* ~3.2 MB of font JSON into the main entry point.
|
|
166
|
+
*
|
|
167
|
+
* @param world - The ECS world
|
|
168
|
+
* @param entity - The entity to wrap
|
|
169
|
+
* @param config - Widget configuration
|
|
170
|
+
* @returns Promise resolving to the BigText widget instance
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```typescript
|
|
174
|
+
* import { createWorld, addEntity } from '../core/ecs';
|
|
175
|
+
* import { createBigText } from 'blecsd/widgets';
|
|
176
|
+
*
|
|
177
|
+
* const world = createWorld();
|
|
178
|
+
* const eid = addEntity(world);
|
|
179
|
+
*
|
|
180
|
+
* const bigText = await createBigText(world, eid, {
|
|
181
|
+
* text: 'HELLO',
|
|
182
|
+
* font: 'terminus-14-bold',
|
|
183
|
+
* });
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
declare function createBigText(world: World, entity: Entity, config: BigTextConfig): Promise<BigTextWidget>;
|
|
187
|
+
/**
|
|
188
|
+
* Sets the text content of a BigText entity.
|
|
189
|
+
*
|
|
190
|
+
* Uses the cached font if available (synchronous), otherwise falls back
|
|
191
|
+
* to async font loading. For best performance, pre-load fonts with
|
|
192
|
+
* `loadFont()` from `blecsd/widgets/fonts` before calling this.
|
|
193
|
+
*
|
|
194
|
+
* @param world - The ECS world
|
|
195
|
+
* @param eid - The entity ID
|
|
196
|
+
* @param text - The text content
|
|
197
|
+
* @param font - Optional font override (name, path, or font definition)
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```typescript
|
|
201
|
+
* import { setText } from 'blecsd/widgets';
|
|
202
|
+
*
|
|
203
|
+
* setText(world, bigTextEntity, 'NEW TEXT');
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
declare function setText(world: World, eid: Entity, text: string, font?: string | FontDefinition): void;
|
|
207
|
+
/**
|
|
208
|
+
* Checks if an entity is a BigText widget.
|
|
209
|
+
*
|
|
210
|
+
* @param _world - The ECS world (unused, for API consistency)
|
|
211
|
+
* @param eid - The entity ID
|
|
212
|
+
* @returns true if the entity is a BigText widget
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* import { isBigText } from 'blecsd/widgets';
|
|
217
|
+
*
|
|
218
|
+
* if (isBigText(world, entity)) {
|
|
219
|
+
* // Handle big text-specific logic
|
|
220
|
+
* }
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
declare function isBigText(_world: World, eid: Entity): boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Resets the BigText component store. Useful for testing.
|
|
226
|
+
* @internal
|
|
227
|
+
*/
|
|
228
|
+
declare function resetBigTextStore(): void;
|
|
229
|
+
|
|
230
|
+
export { BigText, type BigTextConfig, BigTextConfigSchema, type BigTextWidget, type DimensionValue, type FontDefinition, type PositionValue, createBigText, isBigText, loadFont, loadFontFromPath, resetBigTextStore, setText };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{b as BigText,a as BigTextConfigSchema,e as createBigText,g as isBigText,d as loadFont,c as loadFontFromPath,h as resetBigTextStore,f as setText}from'../chunk-3EGGGI5J.js';import'../chunk-DNRXW56C.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';
|