take4-console 0.15.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/CHANGELOG.md +287 -0
- package/LICENSE +21 -0
- package/README.md +986 -0
- package/dist/Screen/InterfaceBuilder.d.mts +43 -0
- package/dist/Screen/InterfaceBuilder.d.mts.map +1 -0
- package/dist/Screen/InterfaceBuilder.mjs +355 -0
- package/dist/Screen/InterfaceBuilder.mjs.map +1 -0
- package/dist/Screen/Pos.d.mts +52 -0
- package/dist/Screen/Pos.d.mts.map +1 -0
- package/dist/Screen/Pos.mjs +105 -0
- package/dist/Screen/Pos.mjs.map +1 -0
- package/dist/Screen/Region.d.mts +31 -0
- package/dist/Screen/Region.d.mts.map +1 -0
- package/dist/Screen/Region.mjs +73 -0
- package/dist/Screen/Region.mjs.map +1 -0
- package/dist/Screen/RegistryHolder.d.mts +6 -0
- package/dist/Screen/RegistryHolder.d.mts.map +1 -0
- package/dist/Screen/RegistryHolder.mjs +14 -0
- package/dist/Screen/RegistryHolder.mjs.map +1 -0
- package/dist/Screen/Screen.d.mts +25 -0
- package/dist/Screen/Screen.d.mts.map +1 -0
- package/dist/Screen/Screen.mjs +100 -0
- package/dist/Screen/Screen.mjs.map +1 -0
- package/dist/Screen/Size.d.mts +23 -0
- package/dist/Screen/Size.d.mts.map +1 -0
- package/dist/Screen/Size.mjs +48 -0
- package/dist/Screen/Size.mjs.map +1 -0
- package/dist/Screen/StyleRegistry.d.mts +32 -0
- package/dist/Screen/StyleRegistry.d.mts.map +1 -0
- package/dist/Screen/StyleRegistry.mjs +80 -0
- package/dist/Screen/StyleRegistry.mjs.map +1 -0
- package/dist/Screen/Window.d.mts +121 -0
- package/dist/Screen/Window.d.mts.map +1 -0
- package/dist/Screen/Window.mjs +407 -0
- package/dist/Screen/Window.mjs.map +1 -0
- package/dist/Screen/WindowManager.d.mts +86 -0
- package/dist/Screen/WindowManager.d.mts.map +1 -0
- package/dist/Screen/WindowManager.mjs +399 -0
- package/dist/Screen/WindowManager.mjs.map +1 -0
- package/dist/Screen/controls/BarChart.d.mts +29 -0
- package/dist/Screen/controls/BarChart.d.mts.map +1 -0
- package/dist/Screen/controls/BarChart.mjs +90 -0
- package/dist/Screen/controls/BarChart.mjs.map +1 -0
- package/dist/Screen/controls/Button.d.mts +16 -0
- package/dist/Screen/controls/Button.d.mts.map +1 -0
- package/dist/Screen/controls/Button.mjs +34 -0
- package/dist/Screen/controls/Button.mjs.map +1 -0
- package/dist/Screen/controls/Checkbox.d.mts +23 -0
- package/dist/Screen/controls/Checkbox.d.mts.map +1 -0
- package/dist/Screen/controls/Checkbox.mjs +55 -0
- package/dist/Screen/controls/Checkbox.mjs.map +1 -0
- package/dist/Screen/controls/LineChart.d.mts +29 -0
- package/dist/Screen/controls/LineChart.d.mts.map +1 -0
- package/dist/Screen/controls/LineChart.mjs +172 -0
- package/dist/Screen/controls/LineChart.mjs.map +1 -0
- package/dist/Screen/controls/ListBox.d.mts +34 -0
- package/dist/Screen/controls/ListBox.d.mts.map +1 -0
- package/dist/Screen/controls/ListBox.mjs +138 -0
- package/dist/Screen/controls/ListBox.mjs.map +1 -0
- package/dist/Screen/controls/ProgressBar.d.mts +26 -0
- package/dist/Screen/controls/ProgressBar.d.mts.map +1 -0
- package/dist/Screen/controls/ProgressBar.mjs +70 -0
- package/dist/Screen/controls/ProgressBar.mjs.map +1 -0
- package/dist/Screen/controls/ProgressBarV.d.mts +22 -0
- package/dist/Screen/controls/ProgressBarV.d.mts.map +1 -0
- package/dist/Screen/controls/ProgressBarV.mjs +61 -0
- package/dist/Screen/controls/ProgressBarV.mjs.map +1 -0
- package/dist/Screen/controls/Radio.d.mts +23 -0
- package/dist/Screen/controls/Radio.d.mts.map +1 -0
- package/dist/Screen/controls/Radio.mjs +55 -0
- package/dist/Screen/controls/Radio.mjs.map +1 -0
- package/dist/Screen/controls/Sparkline.d.mts +29 -0
- package/dist/Screen/controls/Sparkline.d.mts.map +1 -0
- package/dist/Screen/controls/Sparkline.mjs +82 -0
- package/dist/Screen/controls/Sparkline.mjs.map +1 -0
- package/dist/Screen/controls/Spinner.d.mts +37 -0
- package/dist/Screen/controls/Spinner.d.mts.map +1 -0
- package/dist/Screen/controls/Spinner.mjs +87 -0
- package/dist/Screen/controls/Spinner.mjs.map +1 -0
- package/dist/Screen/controls/StatusLED.d.mts +22 -0
- package/dist/Screen/controls/StatusLED.d.mts.map +1 -0
- package/dist/Screen/controls/StatusLED.mjs +51 -0
- package/dist/Screen/controls/StatusLED.mjs.map +1 -0
- package/dist/Screen/controls/Tabs.d.mts +42 -0
- package/dist/Screen/controls/Tabs.d.mts.map +1 -0
- package/dist/Screen/controls/Tabs.mjs +126 -0
- package/dist/Screen/controls/Tabs.mjs.map +1 -0
- package/dist/Screen/controls/TextArea.d.mts +41 -0
- package/dist/Screen/controls/TextArea.d.mts.map +1 -0
- package/dist/Screen/controls/TextArea.mjs +197 -0
- package/dist/Screen/controls/TextArea.mjs.map +1 -0
- package/dist/Screen/controls/TextBox.d.mts +35 -0
- package/dist/Screen/controls/TextBox.d.mts.map +1 -0
- package/dist/Screen/controls/TextBox.mjs +135 -0
- package/dist/Screen/controls/TextBox.mjs.map +1 -0
- package/dist/Screen/types.d.mts +399 -0
- package/dist/Screen/types.d.mts.map +1 -0
- package/dist/Screen/types.mjs +22 -0
- package/dist/Screen/types.mjs.map +1 -0
- package/dist/index.d.mts +26 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +41 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +72 -0
- package/src/Screen/InterfaceBuilder.mts +403 -0
- package/src/Screen/Pos.mts +119 -0
- package/src/Screen/Region.mts +88 -0
- package/src/Screen/RegistryHolder.mts +16 -0
- package/src/Screen/Screen.mts +103 -0
- package/src/Screen/Size.mts +55 -0
- package/src/Screen/StyleRegistry.mts +95 -0
- package/src/Screen/Window.mts +439 -0
- package/src/Screen/WindowManager.mts +472 -0
- package/src/Screen/controls/BarChart.mts +109 -0
- package/src/Screen/controls/Button.mts +40 -0
- package/src/Screen/controls/Checkbox.mts +66 -0
- package/src/Screen/controls/LineChart.mts +202 -0
- package/src/Screen/controls/ListBox.mts +154 -0
- package/src/Screen/controls/ProgressBar.mts +88 -0
- package/src/Screen/controls/ProgressBarV.mts +77 -0
- package/src/Screen/controls/Radio.mts +66 -0
- package/src/Screen/controls/Sparkline.mts +101 -0
- package/src/Screen/controls/Spinner.mts +102 -0
- package/src/Screen/controls/StatusLED.mts +65 -0
- package/src/Screen/controls/Tabs.mts +140 -0
- package/src/Screen/controls/TextArea.mts +194 -0
- package/src/Screen/controls/TextBox.mts +139 -0
- package/src/Screen/types.mts +416 -0
- package/src/demo.mts +171 -0
- package/src/index.mts +105 -0
- package/src/layout.yaml +236 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Window } from './Window.mjs';
|
|
2
|
+
import { Screen } from './Screen.mjs';
|
|
3
|
+
import { WindowManager } from './WindowManager.mjs';
|
|
4
|
+
/** Builds a window hierarchy from a YAML description.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* 1. Create an InterfaceBuilder and call registerCallback() for any onPress/onChange IDs.
|
|
8
|
+
* 2. Call build(yamlText, screen) or buildFromFile(path, screen).
|
|
9
|
+
* 3. Optionally pass a WindowManager to automatically register all focusable controls.
|
|
10
|
+
* 4. The returned Map<string, Window> gives access to windows by their YAML id.
|
|
11
|
+
*
|
|
12
|
+
* YAML schema:
|
|
13
|
+
* windows:
|
|
14
|
+
* - id: myBtn
|
|
15
|
+
* type: button # window | button | textbox | textarea | checkbox | radio
|
|
16
|
+
* pos: center # {x, y} | center | topLeft | topRight | bottomLeft | bottomRight | {preset: top|left|right|bottom, offset?}
|
|
17
|
+
* size: { width: 20, height: 3 } # {width, height} | fill | {fillWidth: N} | {fillHeight: N}
|
|
18
|
+
* label: "Click me"
|
|
19
|
+
* onPress: my_callback
|
|
20
|
+
* children:
|
|
21
|
+
* - ...
|
|
22
|
+
*/
|
|
23
|
+
export declare class InterfaceBuilder {
|
|
24
|
+
private callbacks;
|
|
25
|
+
/** Creates an InterfaceBuilder with an empty callback registry. */
|
|
26
|
+
constructor();
|
|
27
|
+
/** Registers a named callback for use with onPress or onChange in YAML definitions. */
|
|
28
|
+
registerCallback(id: string, fn: (...args: unknown[]) => void): void;
|
|
29
|
+
/** Builds the UI from a YAML string, adds all top-level windows to Screen,
|
|
30
|
+
* and registers focusable controls with WindowManager if provided.
|
|
31
|
+
* Styles defined in the `styles:` section are registered before any windows are built.
|
|
32
|
+
* Returns a map of all windows and controls keyed by their YAML id. */
|
|
33
|
+
build(yamlText: string, screen: Screen, wm?: WindowManager): Map<string, Window>;
|
|
34
|
+
/** Builds the UI from a YAML file. See build() for details. */
|
|
35
|
+
buildFromFile(filePath: string, screen: Screen, wm?: WindowManager): Promise<Map<string, Window>>;
|
|
36
|
+
/** Recursively creates a single widget and all of its children from a YamlWindowDef.
|
|
37
|
+
* Static content strings are collected into contentWrites instead of being written
|
|
38
|
+
* immediately, so they are applied after all sizes are resolved. */
|
|
39
|
+
private buildNode;
|
|
40
|
+
/** Returns a parsed Size from the definition or throws if size is missing. */
|
|
41
|
+
private requireSize;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=InterfaceBuilder.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InterfaceBuilder.d.mts","sourceRoot":"","sources":["../../src/Screen/InterfaceBuilder.mts"],"names":[],"mappings":"AAYA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAsFpD;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAA4C;IAE7D,mEAAmE;;IAKnE,uFAAuF;IAChF,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,IAAI;IAI3E;;;4EAGwE;IACjE,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAmCvF,+DAA+D;IAClD,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAO9G;;yEAEqE;IACrE,OAAO,CAAC,SAAS;IAoNjB,8EAA8E;IAC9E,OAAO,CAAC,WAAW;CAOpB"}
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import { parse } from 'yaml';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { Window } from './Window.mjs';
|
|
4
|
+
import { Pos, pct } from './Pos.mjs';
|
|
5
|
+
import { Size } from './Size.mjs';
|
|
6
|
+
import { getRegistry } from './RegistryHolder.mjs';
|
|
7
|
+
import { Button } from './controls/Button.mjs';
|
|
8
|
+
import { TextBox } from './controls/TextBox.mjs';
|
|
9
|
+
import { TextArea } from './controls/TextArea.mjs';
|
|
10
|
+
import { Checkbox } from './controls/Checkbox.mjs';
|
|
11
|
+
import { Radio } from './controls/Radio.mjs';
|
|
12
|
+
import { StatusLED } from './controls/StatusLED.mjs';
|
|
13
|
+
import { ProgressBar } from './controls/ProgressBar.mjs';
|
|
14
|
+
import { ProgressBarV } from './controls/ProgressBarV.mjs';
|
|
15
|
+
import { LineChart } from './controls/LineChart.mjs';
|
|
16
|
+
import { BarChart } from './controls/BarChart.mjs';
|
|
17
|
+
import { ListBox } from './controls/ListBox.mjs';
|
|
18
|
+
import { Tabs } from './controls/Tabs.mjs';
|
|
19
|
+
import { Sparkline } from './controls/Sparkline.mjs';
|
|
20
|
+
import { Spinner } from './controls/Spinner.mjs';
|
|
21
|
+
/** Converts a YamlAxisValue ("N%", or a number) to a number or Pct instance. */
|
|
22
|
+
function parseAxisValue(v) {
|
|
23
|
+
if (typeof v === 'string') {
|
|
24
|
+
const m = v.match(/^(-?\d+(?:\.\d+)?)%$/);
|
|
25
|
+
if (!m)
|
|
26
|
+
throw new Error(`Invalid axis value: "${v}". Expected a number or "N%" string.`);
|
|
27
|
+
return pct(parseFloat(m[1]));
|
|
28
|
+
}
|
|
29
|
+
return v;
|
|
30
|
+
}
|
|
31
|
+
/** Converts a YamlPosSpec to a Pos instance. */
|
|
32
|
+
function parsePos(spec) {
|
|
33
|
+
if (!spec)
|
|
34
|
+
return new Pos(0, 0);
|
|
35
|
+
if (spec === 'center')
|
|
36
|
+
return Pos.center();
|
|
37
|
+
if (spec === 'topLeft')
|
|
38
|
+
return Pos.topLeft();
|
|
39
|
+
if (spec === 'topRight')
|
|
40
|
+
return Pos.topRight();
|
|
41
|
+
if (spec === 'bottomLeft')
|
|
42
|
+
return Pos.bottomLeft();
|
|
43
|
+
if (spec === 'bottomRight')
|
|
44
|
+
return Pos.bottomRight();
|
|
45
|
+
if (typeof spec === 'object') {
|
|
46
|
+
if ('preset' in spec) {
|
|
47
|
+
const off = spec.offset !== undefined ? parseAxisValue(spec.offset) : 0;
|
|
48
|
+
switch (spec.preset) {
|
|
49
|
+
case 'top': return Pos.top(off);
|
|
50
|
+
case 'left': return Pos.left(off);
|
|
51
|
+
case 'right': return Pos.right(off);
|
|
52
|
+
case 'bottom': return Pos.bottom(off);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if ('x' in spec && 'y' in spec) {
|
|
56
|
+
return new Pos(parseAxisValue(spec.x), parseAxisValue(spec.y));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
throw new Error(`Invalid pos spec: ${JSON.stringify(spec)}`);
|
|
60
|
+
}
|
|
61
|
+
/** Converts a YamlSizeSpec to a Size instance. */
|
|
62
|
+
function parseSize(spec) {
|
|
63
|
+
if (spec === 'fill')
|
|
64
|
+
return Size.fill();
|
|
65
|
+
if (typeof spec === 'object') {
|
|
66
|
+
if ('fillWidth' in spec)
|
|
67
|
+
return Size.fillWidth(parseAxisValue(spec.fillWidth));
|
|
68
|
+
if ('fillHeight' in spec)
|
|
69
|
+
return Size.fillHeight(parseAxisValue(spec.fillHeight));
|
|
70
|
+
if ('width' in spec && 'height' in spec) {
|
|
71
|
+
return new Size(parseAxisValue(spec.width), parseAxisValue(spec.height));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
throw new Error(`Invalid size spec: ${JSON.stringify(spec)}`);
|
|
75
|
+
}
|
|
76
|
+
/** Resolves a YAML background value (style name or numeric StyleId) to a StyleId.
|
|
77
|
+
* String values are looked up by name in the global registry (returns 0 if not found).
|
|
78
|
+
* Numeric values are passed through as-is. Undefined becomes undefined (transparent). */
|
|
79
|
+
function resolveBackground(bg) {
|
|
80
|
+
if (bg === undefined)
|
|
81
|
+
return undefined;
|
|
82
|
+
if (typeof bg === 'string')
|
|
83
|
+
return getRegistry().getNamed(bg) ?? 0;
|
|
84
|
+
return bg;
|
|
85
|
+
}
|
|
86
|
+
// ── InterfaceBuilder ──────────────────────────────────────────────────────────
|
|
87
|
+
/** Builds a window hierarchy from a YAML description.
|
|
88
|
+
*
|
|
89
|
+
* Usage:
|
|
90
|
+
* 1. Create an InterfaceBuilder and call registerCallback() for any onPress/onChange IDs.
|
|
91
|
+
* 2. Call build(yamlText, screen) or buildFromFile(path, screen).
|
|
92
|
+
* 3. Optionally pass a WindowManager to automatically register all focusable controls.
|
|
93
|
+
* 4. The returned Map<string, Window> gives access to windows by their YAML id.
|
|
94
|
+
*
|
|
95
|
+
* YAML schema:
|
|
96
|
+
* windows:
|
|
97
|
+
* - id: myBtn
|
|
98
|
+
* type: button # window | button | textbox | textarea | checkbox | radio
|
|
99
|
+
* pos: center # {x, y} | center | topLeft | topRight | bottomLeft | bottomRight | {preset: top|left|right|bottom, offset?}
|
|
100
|
+
* size: { width: 20, height: 3 } # {width, height} | fill | {fillWidth: N} | {fillHeight: N}
|
|
101
|
+
* label: "Click me"
|
|
102
|
+
* onPress: my_callback
|
|
103
|
+
* children:
|
|
104
|
+
* - ...
|
|
105
|
+
*/
|
|
106
|
+
export class InterfaceBuilder {
|
|
107
|
+
callbacks;
|
|
108
|
+
/** Creates an InterfaceBuilder with an empty callback registry. */
|
|
109
|
+
constructor() {
|
|
110
|
+
this.callbacks = new Map();
|
|
111
|
+
}
|
|
112
|
+
/** Registers a named callback for use with onPress or onChange in YAML definitions. */
|
|
113
|
+
registerCallback(id, fn) {
|
|
114
|
+
this.callbacks.set(id, fn);
|
|
115
|
+
}
|
|
116
|
+
/** Builds the UI from a YAML string, adds all top-level windows to Screen,
|
|
117
|
+
* and registers focusable controls with WindowManager if provided.
|
|
118
|
+
* Styles defined in the `styles:` section are registered before any windows are built.
|
|
119
|
+
* Returns a map of all windows and controls keyed by their YAML id. */
|
|
120
|
+
build(yamlText, screen, wm) {
|
|
121
|
+
const layout = parse(yamlText);
|
|
122
|
+
const result = new Map();
|
|
123
|
+
const pending = [];
|
|
124
|
+
const contentWrites = [];
|
|
125
|
+
// Register YAML-defined named styles before building the window tree.
|
|
126
|
+
if (layout.styles) {
|
|
127
|
+
const registry = getRegistry();
|
|
128
|
+
for (const styleDef of layout.styles) {
|
|
129
|
+
const { name, ...attrs } = styleDef;
|
|
130
|
+
registry.registerNamed(name, attrs);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
for (const def of layout.windows) {
|
|
134
|
+
const win = this.buildNode(def, result, pending, contentWrites, []);
|
|
135
|
+
// Adding to screen resolves percentage-based sizes for the entire subtree.
|
|
136
|
+
screen.addChild(win);
|
|
137
|
+
}
|
|
138
|
+
// Write static content after sizing so text lands in correctly-sized regions.
|
|
139
|
+
for (const { win, text } of contentWrites) {
|
|
140
|
+
win.writeText(text);
|
|
141
|
+
}
|
|
142
|
+
if (wm) {
|
|
143
|
+
for (const { control, parents } of pending) {
|
|
144
|
+
wm.register(control, ...parents);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
/** Builds the UI from a YAML file. See build() for details. */
|
|
150
|
+
async buildFromFile(filePath, screen, wm) {
|
|
151
|
+
const text = await readFile(filePath, 'utf8');
|
|
152
|
+
return this.build(text, screen, wm);
|
|
153
|
+
}
|
|
154
|
+
// ── Private helpers ───────────────────────────────────────────────────────────
|
|
155
|
+
/** Recursively creates a single widget and all of its children from a YamlWindowDef.
|
|
156
|
+
* Static content strings are collected into contentWrites instead of being written
|
|
157
|
+
* immediately, so they are applied after all sizes are resolved. */
|
|
158
|
+
buildNode(def, result, pending, contentWrites, parentChain) {
|
|
159
|
+
const pos = parsePos(def.pos);
|
|
160
|
+
const bgId = resolveBackground(def.background);
|
|
161
|
+
/** Common window properties shared by all control types. */
|
|
162
|
+
const wp = {
|
|
163
|
+
pos,
|
|
164
|
+
size: def.size ? parseSize(def.size) : undefined,
|
|
165
|
+
background: bgId,
|
|
166
|
+
border: def.border,
|
|
167
|
+
active: def.active,
|
|
168
|
+
focused: def.focused,
|
|
169
|
+
disabled: def.disabled,
|
|
170
|
+
label: def.label,
|
|
171
|
+
};
|
|
172
|
+
let win;
|
|
173
|
+
switch (def.type ?? 'window') {
|
|
174
|
+
case 'button': {
|
|
175
|
+
const pressCb = def.onPress ? this.callbacks.get(def.onPress) : undefined;
|
|
176
|
+
wp.size = wp.size ?? this.requireSize(def);
|
|
177
|
+
const btn = new Button(wp, {
|
|
178
|
+
onPress: pressCb ? () => pressCb() : undefined,
|
|
179
|
+
});
|
|
180
|
+
pending.push({ control: btn, parents: [...parentChain] });
|
|
181
|
+
win = btn;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
case 'textbox': {
|
|
185
|
+
wp.size = wp.size ?? this.requireSize(def);
|
|
186
|
+
const tb = new TextBox(wp, {
|
|
187
|
+
value: def.value,
|
|
188
|
+
placeholder: def.placeholder,
|
|
189
|
+
});
|
|
190
|
+
pending.push({ control: tb, parents: [...parentChain] });
|
|
191
|
+
win = tb;
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
case 'textarea': {
|
|
195
|
+
wp.size = wp.size ?? this.requireSize(def);
|
|
196
|
+
const ta = new TextArea(wp, {
|
|
197
|
+
value: def.value,
|
|
198
|
+
placeholder: def.placeholder,
|
|
199
|
+
});
|
|
200
|
+
pending.push({ control: ta, parents: [...parentChain] });
|
|
201
|
+
win = ta;
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
case 'checkbox': {
|
|
205
|
+
const changeCb = def.onChange ? this.callbacks.get(def.onChange) : undefined;
|
|
206
|
+
const cb = new Checkbox(wp, {
|
|
207
|
+
checked: def.checked,
|
|
208
|
+
onChange: changeCb ? (checked) => changeCb(checked) : undefined,
|
|
209
|
+
});
|
|
210
|
+
pending.push({ control: cb, parents: [...parentChain] });
|
|
211
|
+
win = cb;
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
case 'radio': {
|
|
215
|
+
const changeCb = def.onChange ? this.callbacks.get(def.onChange) : undefined;
|
|
216
|
+
const r = new Radio(wp, {
|
|
217
|
+
checked: def.checked,
|
|
218
|
+
onChange: changeCb ? (checked) => changeCb(checked) : undefined,
|
|
219
|
+
});
|
|
220
|
+
pending.push({ control: r, parents: [...parentChain] });
|
|
221
|
+
win = r;
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
case 'statusled': {
|
|
225
|
+
const led = new StatusLED(wp, {
|
|
226
|
+
state: def.state,
|
|
227
|
+
});
|
|
228
|
+
win = led;
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
case 'progressbar': {
|
|
232
|
+
wp.size = wp.size ?? this.requireSize(def);
|
|
233
|
+
const pb = new ProgressBar(wp, {
|
|
234
|
+
value: def.barValue,
|
|
235
|
+
max: def.max,
|
|
236
|
+
showLabel: def.showLabel,
|
|
237
|
+
fillColor: def.fillColor,
|
|
238
|
+
emptyColor: def.emptyColor,
|
|
239
|
+
});
|
|
240
|
+
win = pb;
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
case 'progressbarv': {
|
|
244
|
+
wp.size = wp.size ?? this.requireSize(def);
|
|
245
|
+
const pbv = new ProgressBarV(wp, {
|
|
246
|
+
value: def.barValue,
|
|
247
|
+
max: def.max,
|
|
248
|
+
fillColor: def.fillColor,
|
|
249
|
+
emptyColor: def.emptyColor,
|
|
250
|
+
});
|
|
251
|
+
win = pbv;
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
case 'linechart': {
|
|
255
|
+
wp.size = wp.size ?? this.requireSize(def);
|
|
256
|
+
const lc = new LineChart(wp, {
|
|
257
|
+
data: def.data,
|
|
258
|
+
min: def.min,
|
|
259
|
+
max: def.max,
|
|
260
|
+
color: def.chartColor,
|
|
261
|
+
});
|
|
262
|
+
win = lc;
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
case 'barchart': {
|
|
266
|
+
wp.size = wp.size ?? this.requireSize(def);
|
|
267
|
+
const bc = new BarChart(wp, {
|
|
268
|
+
data: def.data,
|
|
269
|
+
labels: def.barLabels,
|
|
270
|
+
max: def.max,
|
|
271
|
+
barColor: def.chartColor,
|
|
272
|
+
barWidth: def.barWidth,
|
|
273
|
+
});
|
|
274
|
+
win = bc;
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
case 'listbox': {
|
|
278
|
+
const changeCb = def.onChange ? this.callbacks.get(def.onChange) : undefined;
|
|
279
|
+
wp.size = wp.size ?? this.requireSize(def);
|
|
280
|
+
const lb = new ListBox(wp, {
|
|
281
|
+
items: def.items,
|
|
282
|
+
selectedIndex: def.selectedIndex,
|
|
283
|
+
onChange: changeCb ? (idx, item) => changeCb(idx, item) : undefined,
|
|
284
|
+
});
|
|
285
|
+
pending.push({ control: lb, parents: [...parentChain] });
|
|
286
|
+
win = lb;
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
case 'tabs': {
|
|
290
|
+
const changeCb = def.onChange ? this.callbacks.get(def.onChange) : undefined;
|
|
291
|
+
wp.size = wp.size ?? this.requireSize(def);
|
|
292
|
+
const tabs = new Tabs(wp, {
|
|
293
|
+
titles: def.titles,
|
|
294
|
+
activeIndex: def.activeIndex,
|
|
295
|
+
onChange: changeCb ? (idx, title) => changeCb(idx, title) : undefined,
|
|
296
|
+
});
|
|
297
|
+
pending.push({ control: tabs, parents: [...parentChain] });
|
|
298
|
+
win = tabs;
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
case 'sparkline': {
|
|
302
|
+
wp.size = wp.size ?? this.requireSize(def);
|
|
303
|
+
const sp = new Sparkline(wp, {
|
|
304
|
+
data: def.data,
|
|
305
|
+
min: def.min,
|
|
306
|
+
max: def.max,
|
|
307
|
+
color: def.chartColor,
|
|
308
|
+
});
|
|
309
|
+
win = sp;
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
case 'spinner': {
|
|
313
|
+
const sp = new Spinner(wp, {
|
|
314
|
+
style: def.spinnerStyle,
|
|
315
|
+
frame: def.frame,
|
|
316
|
+
running: def.running,
|
|
317
|
+
color: def.chartColor,
|
|
318
|
+
});
|
|
319
|
+
win = sp;
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
default: {
|
|
323
|
+
wp.size = wp.size ?? this.requireSize(def);
|
|
324
|
+
win = new Window(wp);
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
if (def.id)
|
|
329
|
+
result.set(def.id, win);
|
|
330
|
+
// Defer content write – the window may not have its final size yet.
|
|
331
|
+
if (def.content)
|
|
332
|
+
contentWrites.push({ win, text: def.content });
|
|
333
|
+
if (def.children) {
|
|
334
|
+
for (const childDef of def.children) {
|
|
335
|
+
const child = this.buildNode(childDef, result, pending, contentWrites, [win, ...parentChain]);
|
|
336
|
+
if (win instanceof Tabs && childDef.tab !== undefined) {
|
|
337
|
+
win.addChildToTab(childDef.tab, child);
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
win.addChild(child);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return win;
|
|
345
|
+
}
|
|
346
|
+
/** Returns a parsed Size from the definition or throws if size is missing. */
|
|
347
|
+
requireSize(def) {
|
|
348
|
+
if (!def.size) {
|
|
349
|
+
const label = def.id ? `"${def.id}"` : (def.type ?? 'window');
|
|
350
|
+
throw new Error(`Missing required "size" for ${label}.`);
|
|
351
|
+
}
|
|
352
|
+
return parseSize(def.size);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
//# sourceMappingURL=InterfaceBuilder.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InterfaceBuilder.mjs","sourceRoot":"","sources":["../../src/Screen/InterfaceBuilder.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAW5C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtC,OAAO,EAAE,GAAG,EAAO,GAAG,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAY,uBAAuB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAW,wBAAwB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAU,yBAAyB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAU,yBAAyB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAa,sBAAsB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAS,0BAA0B,CAAC;AACxD,OAAO,EAAE,WAAW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E,WAAW,CAAC,GAAkB;QACpC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;YACd,MAAM,KAAK,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,QAAQ,CAAC,CAAC;YAC9D,MAAM,IAAI,KAAK,CAAC,+BAA+B,KAAK,GAAG,CAAC,CAAC;QAC3D,CAAC;QACD,OAAO,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Wraps a percentage value (0–100) for use in Pos and Size constructors. */
|
|
2
|
+
export declare class Pct {
|
|
3
|
+
readonly value: number;
|
|
4
|
+
constructor(value: number);
|
|
5
|
+
}
|
|
6
|
+
/** Creates a Pct instance representing the given percentage. */
|
|
7
|
+
export declare function pct(value: number): Pct;
|
|
8
|
+
/** Encodes a window position. Supports absolute coordinates, edge-relative (negative),
|
|
9
|
+
* percentage-based, center alignment, and named edge presets. */
|
|
10
|
+
export declare class Pos {
|
|
11
|
+
private xSpec;
|
|
12
|
+
private ySpec;
|
|
13
|
+
/** Creates a position.
|
|
14
|
+
* - Positive number: absolute distance from left/top.
|
|
15
|
+
* - Negative number: own right/bottom edge at that distance from parent's right/bottom.
|
|
16
|
+
* - Pct instance: percentage of parent dimension from left/top. */
|
|
17
|
+
constructor(x: number | Pct, y: number | Pct);
|
|
18
|
+
/** Builds a Pos directly from raw AxisSpec values (used by static factories). */
|
|
19
|
+
private static fromSpecs;
|
|
20
|
+
/** Aligns the top-left corner with the parent's top-left corner (0, 0). */
|
|
21
|
+
static topLeft(): Pos;
|
|
22
|
+
/** Aligns the top-right corner with the parent's top-right corner. */
|
|
23
|
+
static topRight(): Pos;
|
|
24
|
+
/** Aligns the bottom-left corner with the parent's bottom-left corner. */
|
|
25
|
+
static bottomLeft(): Pos;
|
|
26
|
+
/** Aligns the bottom-right corner with the parent's bottom-right corner. */
|
|
27
|
+
static bottomRight(): Pos;
|
|
28
|
+
/** Centers the window within the parent on both axes. */
|
|
29
|
+
static center(): Pos;
|
|
30
|
+
/** Aligns the top edge with the parent's top edge; x sets horizontal position. */
|
|
31
|
+
static top(x?: number | Pct): Pos;
|
|
32
|
+
/** Aligns the left edge with the parent's left edge; y sets vertical position. */
|
|
33
|
+
static left(y?: number | Pct): Pos;
|
|
34
|
+
/** Aligns the right edge with the parent's right edge; y sets vertical position. */
|
|
35
|
+
static right(y?: number | Pct): Pos;
|
|
36
|
+
/** Aligns the bottom edge with the parent's bottom edge; x sets horizontal position. */
|
|
37
|
+
static bottom(x?: number | Pct): Pos;
|
|
38
|
+
/** Returns true when both axes are absolute-from-start values (no parent/own-size needed). */
|
|
39
|
+
isAbsolute(): boolean;
|
|
40
|
+
/** Resolves absolute position without needing parent or own dimensions.
|
|
41
|
+
* Only call when isAbsolute() returns true. */
|
|
42
|
+
resolveAbsolute(): {
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
};
|
|
46
|
+
/** Resolves this position to pixel coordinates given parent and own dimensions. */
|
|
47
|
+
resolve(parentW: number, parentH: number, ownW: number, ownH: number): {
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=Pos.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pos.d.mts","sourceRoot":"","sources":["../../src/Screen/Pos.mts"],"names":[],"mappings":"AAEA,6EAA6E;AAC7E,qBAAa,GAAG;aACoB,KAAK,EAAE,MAAM;gBAAb,KAAK,EAAE,MAAM;CAChD;AAED,gEAAgE;AAChE,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAEtC;AAmBD;kEACkE;AAClE,qBAAa,GAAG;IACf,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,KAAK,CAAW;IAExB;;;wEAGoE;gBACjD,CAAC,EAAE,MAAM,GAAG,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG,GAAG;IAKnD,iFAAiF;IACjF,OAAO,CAAC,MAAM,CAAC,SAAS;IAOxB,2EAA2E;WAC7D,OAAO,IAAI,GAAG;IAI5B,sEAAsE;WACxD,QAAQ,IAAI,GAAG;IAI7B,0EAA0E;WAC5D,UAAU,IAAI,GAAG;IAI/B,4EAA4E;WAC9D,WAAW,IAAI,GAAG;IAIhC,yDAAyD;WAC3C,MAAM,IAAI,GAAG;IAI3B,kFAAkF;WACpE,GAAG,CAAC,CAAC,GAAE,MAAM,GAAG,GAAO,GAAG,GAAG;IAI3C,kFAAkF;WACpE,IAAI,CAAC,CAAC,GAAE,MAAM,GAAG,GAAO,GAAG,GAAG;IAI5C,oFAAoF;WACtE,KAAK,CAAC,CAAC,GAAE,MAAM,GAAG,GAAO,GAAG,GAAG;IAI7C,wFAAwF;WAC1E,MAAM,CAAC,CAAC,GAAE,MAAM,GAAG,GAAO,GAAG,GAAG;IAI9C,8FAA8F;IACvF,UAAU,IAAI,OAAO;IAI5B;oDACgD;IACzC,eAAe,IAAI;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;IAOlD,mFAAmF;IAC5E,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;CAMtG"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/** Wraps a percentage value (0–100) for use in Pos and Size constructors. */
|
|
2
|
+
export class Pct {
|
|
3
|
+
value;
|
|
4
|
+
constructor(value) {
|
|
5
|
+
this.value = value;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/** Creates a Pct instance representing the given percentage. */
|
|
9
|
+
export function pct(value) {
|
|
10
|
+
return new Pct(value);
|
|
11
|
+
}
|
|
12
|
+
/** Converts a user-supplied coordinate to an internal AxisSpec. */
|
|
13
|
+
function toAxisSpec(v) {
|
|
14
|
+
if (v instanceof Pct)
|
|
15
|
+
return { mode: 'pct', value: v.value };
|
|
16
|
+
if (v < 0)
|
|
17
|
+
return { mode: 'end', value: -v };
|
|
18
|
+
return { mode: 'start', value: v };
|
|
19
|
+
}
|
|
20
|
+
/** Resolves a single axis spec to a pixel offset. */
|
|
21
|
+
function resolveAxis(spec, parentSize, ownSize) {
|
|
22
|
+
switch (spec.mode) {
|
|
23
|
+
case 'start': return spec.value;
|
|
24
|
+
case 'end': return parentSize - ownSize - spec.value;
|
|
25
|
+
case 'pct': return Math.floor(parentSize * spec.value / 100);
|
|
26
|
+
case 'center': return Math.floor((parentSize - ownSize) / 2);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** Encodes a window position. Supports absolute coordinates, edge-relative (negative),
|
|
30
|
+
* percentage-based, center alignment, and named edge presets. */
|
|
31
|
+
export class Pos {
|
|
32
|
+
xSpec;
|
|
33
|
+
ySpec;
|
|
34
|
+
/** Creates a position.
|
|
35
|
+
* - Positive number: absolute distance from left/top.
|
|
36
|
+
* - Negative number: own right/bottom edge at that distance from parent's right/bottom.
|
|
37
|
+
* - Pct instance: percentage of parent dimension from left/top. */
|
|
38
|
+
constructor(x, y) {
|
|
39
|
+
this.xSpec = toAxisSpec(x);
|
|
40
|
+
this.ySpec = toAxisSpec(y);
|
|
41
|
+
}
|
|
42
|
+
/** Builds a Pos directly from raw AxisSpec values (used by static factories). */
|
|
43
|
+
static fromSpecs(x, y) {
|
|
44
|
+
const p = Object.create(Pos.prototype);
|
|
45
|
+
p.xSpec = x;
|
|
46
|
+
p.ySpec = y;
|
|
47
|
+
return p;
|
|
48
|
+
}
|
|
49
|
+
/** Aligns the top-left corner with the parent's top-left corner (0, 0). */
|
|
50
|
+
static topLeft() {
|
|
51
|
+
return Pos.fromSpecs({ mode: 'start', value: 0 }, { mode: 'start', value: 0 });
|
|
52
|
+
}
|
|
53
|
+
/** Aligns the top-right corner with the parent's top-right corner. */
|
|
54
|
+
static topRight() {
|
|
55
|
+
return Pos.fromSpecs({ mode: 'end', value: 0 }, { mode: 'start', value: 0 });
|
|
56
|
+
}
|
|
57
|
+
/** Aligns the bottom-left corner with the parent's bottom-left corner. */
|
|
58
|
+
static bottomLeft() {
|
|
59
|
+
return Pos.fromSpecs({ mode: 'start', value: 0 }, { mode: 'end', value: 0 });
|
|
60
|
+
}
|
|
61
|
+
/** Aligns the bottom-right corner with the parent's bottom-right corner. */
|
|
62
|
+
static bottomRight() {
|
|
63
|
+
return Pos.fromSpecs({ mode: 'end', value: 0 }, { mode: 'end', value: 0 });
|
|
64
|
+
}
|
|
65
|
+
/** Centers the window within the parent on both axes. */
|
|
66
|
+
static center() {
|
|
67
|
+
return Pos.fromSpecs({ mode: 'center' }, { mode: 'center' });
|
|
68
|
+
}
|
|
69
|
+
/** Aligns the top edge with the parent's top edge; x sets horizontal position. */
|
|
70
|
+
static top(x = 0) {
|
|
71
|
+
return Pos.fromSpecs(toAxisSpec(x), { mode: 'start', value: 0 });
|
|
72
|
+
}
|
|
73
|
+
/** Aligns the left edge with the parent's left edge; y sets vertical position. */
|
|
74
|
+
static left(y = 0) {
|
|
75
|
+
return Pos.fromSpecs({ mode: 'start', value: 0 }, toAxisSpec(y));
|
|
76
|
+
}
|
|
77
|
+
/** Aligns the right edge with the parent's right edge; y sets vertical position. */
|
|
78
|
+
static right(y = 0) {
|
|
79
|
+
return Pos.fromSpecs({ mode: 'end', value: 0 }, toAxisSpec(y));
|
|
80
|
+
}
|
|
81
|
+
/** Aligns the bottom edge with the parent's bottom edge; x sets horizontal position. */
|
|
82
|
+
static bottom(x = 0) {
|
|
83
|
+
return Pos.fromSpecs(toAxisSpec(x), { mode: 'end', value: 0 });
|
|
84
|
+
}
|
|
85
|
+
/** Returns true when both axes are absolute-from-start values (no parent/own-size needed). */
|
|
86
|
+
isAbsolute() {
|
|
87
|
+
return this.xSpec.mode === 'start' && this.ySpec.mode === 'start';
|
|
88
|
+
}
|
|
89
|
+
/** Resolves absolute position without needing parent or own dimensions.
|
|
90
|
+
* Only call when isAbsolute() returns true. */
|
|
91
|
+
resolveAbsolute() {
|
|
92
|
+
return {
|
|
93
|
+
x: this.xSpec.value,
|
|
94
|
+
y: this.ySpec.value,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/** Resolves this position to pixel coordinates given parent and own dimensions. */
|
|
98
|
+
resolve(parentW, parentH, ownW, ownH) {
|
|
99
|
+
return {
|
|
100
|
+
x: resolveAxis(this.xSpec, parentW, ownW),
|
|
101
|
+
y: resolveAxis(this.ySpec, parentH, ownH),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=Pos.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pos.mjs","sourceRoot":"","sources":["../../src/Screen/Pos.mts"],"names":[],"mappings":"AAEA,6EAA6E;AAC7E,MAAM,OAAO,GAAG;IACoB;IAAnC,YAAmC,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;CACpD;AAED,gEAAgE;AAChE,MAAM,UAAU,GAAG,CAAC,KAAa;IAChC,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED,mEAAmE;AACnE,SAAS,UAAU,CAAC,CAAe;IAClC,IAAI,CAAC,YAAY,GAAG;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;IAC7D,IAAI,CAAC,GAAG,CAAC;QAAY,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC;IACvD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE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C;IAED,oFAAoF;IAC7E,MAAM,CAAC,KAAK,CAAC,IAAkB,CAAC;QACtC,OAAO,GAAG,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAChE,CAAC;IAED,wFAAwF;IACjF,MAAM,CAAC,MAAM,CAAC,IAAkB,CAAC;QACvC,OAAO,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,8FAA8F;IACvF,UAAU;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC;IACnE,CAAC;IAED;oDACgD;IACzC,eAAe;QACrB,OAAO;YACN,CAAC,EAAG,IAAI,CAAC,KAA0C,CAAC,KAAK;YACzD,CAAC,EAAG,IAAI,CAAC,KAA0C,CAAC,KAAK;SACzD,CAAC;IACH,CAAC;IAED,mFAAmF;IAC5E,OAAO,CAAC,OAAe,EAAE,OAAe,EAAE,IAAY,EAAE,IAAY;QAC1E,OAAO;YACN,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC;YACzC,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC;SACzC,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { StyleId, TerminalSize } from './types.mjs';
|
|
2
|
+
export declare class Region {
|
|
3
|
+
private chars;
|
|
4
|
+
private styleIds;
|
|
5
|
+
private size;
|
|
6
|
+
/** Allocates a cell buffer for the given dimensions. All cells start with style ID 0 (empty). */
|
|
7
|
+
constructor(width: number, height: number);
|
|
8
|
+
/** Returns the region dimensions (columns × rows). */
|
|
9
|
+
getSize(): TerminalSize;
|
|
10
|
+
/** Returns the style ID stored at (x, y). Throws RangeError if out of bounds. */
|
|
11
|
+
getStyleId(x: number, y: number): StyleId;
|
|
12
|
+
/** Sets only the character at (x, y) without modifying the style ID. Throws RangeError if out of bounds. */
|
|
13
|
+
setChar(x: number, y: number, char: string): void;
|
|
14
|
+
/** Sets the character and style ID at (x, y). Throws RangeError if out of bounds. */
|
|
15
|
+
setCell(x: number, y: number, char: string, styleId?: StyleId): void;
|
|
16
|
+
/** Replaces only the style ID at (x, y) without changing the character. Throws RangeError if out of bounds. */
|
|
17
|
+
setStyleId(x: number, y: number, styleId: StyleId): void;
|
|
18
|
+
/** Resets every cell to a blank space with style ID 0. */
|
|
19
|
+
clear(): void;
|
|
20
|
+
/** Fills every cell with the given character and style ID. */
|
|
21
|
+
fill(char: string, styleId?: StyleId): void;
|
|
22
|
+
/** Returns a readonly view of the character buffer for rendering. */
|
|
23
|
+
getChars(): readonly string[];
|
|
24
|
+
/** Returns a readonly view of the style-ID buffer for rendering. */
|
|
25
|
+
getStyleIds(): readonly number[];
|
|
26
|
+
/** Returns the flat buffer index for the given (x, y) coordinates. */
|
|
27
|
+
private index;
|
|
28
|
+
/** Throws RangeError if the coordinates (x, y) are outside the region boundaries. */
|
|
29
|
+
private assertBounds;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=Region.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Region.d.mts","sourceRoot":"","sources":["../../src/Screen/Region.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEzD,qBAAa,MAAM;IAClB,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,IAAI,CAAe;IAE3B,iGAAiG;gBAC9E,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAO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