ink-sdl 0.2.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -30
- package/dist/chunk-BOQYTA3S.js +2822 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +437 -0
- package/dist/index.d.ts +412 -245
- package/dist/index.js +25 -2269
- package/package.json +6 -2
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
createSdlStreams
|
|
4
|
+
} from "./chunk-BOQYTA3S.js";
|
|
5
|
+
|
|
6
|
+
// src/cli.tsx
|
|
7
|
+
import { parseArgs } from "util";
|
|
8
|
+
import { render } from "ink";
|
|
9
|
+
|
|
10
|
+
// src/Demo/index.tsx
|
|
11
|
+
import { useState, useEffect } from "react";
|
|
12
|
+
import { Text, Box, useInput, Spacer, Newline } from "ink";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
var TIMER_INTERVAL_MS = 1e3;
|
|
15
|
+
var PERCENT_MAX = 100;
|
|
16
|
+
var DEFAULT_PROGRESS_WIDTH = 20;
|
|
17
|
+
var SCALE_DECIMAL_PLACES = 2;
|
|
18
|
+
var PROGRESS_MEM_MULTIPLIER = 0.7;
|
|
19
|
+
var PROGRESS_MEM_OFFSET = 30;
|
|
20
|
+
var PROGRESS_DSK_MULTIPLIER = 0.4;
|
|
21
|
+
var PROGRESS_DSK_OFFSET = 60;
|
|
22
|
+
var ANIMATION_WIDTH = 10;
|
|
23
|
+
var ANSI_256_SAMPLE_COLORS = [196, 208, 226, 46, 51, 21, 129, 201];
|
|
24
|
+
var TextStylesTab = () => /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: 1, children: [
|
|
25
|
+
/* @__PURE__ */ jsx(Text, { bold: true, children: "Text Styles" }),
|
|
26
|
+
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", paddingLeft: 1, children: [
|
|
27
|
+
/* @__PURE__ */ jsx(Text, { children: "Normal text" }),
|
|
28
|
+
/* @__PURE__ */ jsx(Text, { bold: true, children: "Bold text" }),
|
|
29
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "Dim text" }),
|
|
30
|
+
/* @__PURE__ */ jsx(Text, { italic: true, children: "Italic text" }),
|
|
31
|
+
/* @__PURE__ */ jsx(Text, { underline: true, children: "Underlined text" }),
|
|
32
|
+
/* @__PURE__ */ jsx(Text, { strikethrough: true, children: "Strikethrough text" }),
|
|
33
|
+
/* @__PURE__ */ jsx(Text, { inverse: true, children: "Inverse text" }),
|
|
34
|
+
/* @__PURE__ */ jsx(Text, { bold: true, italic: true, underline: true, children: "Combined: bold + italic + underline" })
|
|
35
|
+
] }),
|
|
36
|
+
/* @__PURE__ */ jsx(Text, { bold: true, children: "Emoji" }),
|
|
37
|
+
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", paddingLeft: 1, children: [
|
|
38
|
+
/* @__PURE__ */ jsx(Text, { children: "Smileys: \u{1F600} \u{1F60E} \u{1F973} \u{1F60D} \u{1F914} \u{1F634}" }),
|
|
39
|
+
/* @__PURE__ */ jsx(Text, { children: "Hands: \u{1F44B} \u{1F44D} \u{1F44E} \u{1F44F} \u{1F64C} \u270C\uFE0F" }),
|
|
40
|
+
/* @__PURE__ */ jsx(Text, { children: "Animals: \u{1F431} \u{1F436} \u{1F98A} \u{1F43B} \u{1F43C} \u{1F981}" }),
|
|
41
|
+
/* @__PURE__ */ jsx(Text, { children: "Food: \u{1F34E} \u{1F355} \u{1F354} \u{1F32E} \u{1F363} \u{1F369}" }),
|
|
42
|
+
/* @__PURE__ */ jsx(Text, { children: "Objects: \u2B50 \u{1F525} \u{1F4A1} \u{1F389} \u{1F680} \u{1F4BB}" })
|
|
43
|
+
] })
|
|
44
|
+
] });
|
|
45
|
+
var BasicColorsTab = () => /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: 1, children: [
|
|
46
|
+
/* @__PURE__ */ jsx(Text, { bold: true, children: "ANSI 16 Colors" }),
|
|
47
|
+
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", paddingLeft: 1, children: [
|
|
48
|
+
/* @__PURE__ */ jsx(Text, { children: "Foreground:" }),
|
|
49
|
+
/* @__PURE__ */ jsxs(Box, { gap: 1, flexWrap: "wrap", children: [
|
|
50
|
+
/* @__PURE__ */ jsx(Text, { color: "black", backgroundColor: "white", children: "black" }),
|
|
51
|
+
/* @__PURE__ */ jsx(Text, { color: "red", children: "red" }),
|
|
52
|
+
/* @__PURE__ */ jsx(Text, { color: "green", children: "green" }),
|
|
53
|
+
/* @__PURE__ */ jsx(Text, { color: "yellow", children: "yellow" }),
|
|
54
|
+
/* @__PURE__ */ jsx(Text, { color: "blue", children: "blue" }),
|
|
55
|
+
/* @__PURE__ */ jsx(Text, { color: "magenta", children: "magenta" }),
|
|
56
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "cyan" }),
|
|
57
|
+
/* @__PURE__ */ jsx(Text, { color: "white", children: "white" })
|
|
58
|
+
] }),
|
|
59
|
+
/* @__PURE__ */ jsxs(Box, { gap: 1, flexWrap: "wrap", marginTop: 1, children: [
|
|
60
|
+
/* @__PURE__ */ jsx(Text, { color: "blackBright", children: "gray" }),
|
|
61
|
+
/* @__PURE__ */ jsx(Text, { color: "redBright", children: "redBright" }),
|
|
62
|
+
/* @__PURE__ */ jsx(Text, { color: "greenBright", children: "greenBright" }),
|
|
63
|
+
/* @__PURE__ */ jsx(Text, { color: "yellowBright", children: "yellowBright" }),
|
|
64
|
+
/* @__PURE__ */ jsx(Text, { color: "blueBright", children: "blueBright" }),
|
|
65
|
+
/* @__PURE__ */ jsx(Text, { color: "magentaBright", children: "magentaBright" }),
|
|
66
|
+
/* @__PURE__ */ jsx(Text, { color: "cyanBright", children: "cyanBright" }),
|
|
67
|
+
/* @__PURE__ */ jsx(Text, { color: "whiteBright", children: "whiteBright" })
|
|
68
|
+
] }),
|
|
69
|
+
/* @__PURE__ */ jsx(Newline, {}),
|
|
70
|
+
/* @__PURE__ */ jsx(Text, { children: "Background:" }),
|
|
71
|
+
/* @__PURE__ */ jsxs(Box, { gap: 1, flexWrap: "wrap", children: [
|
|
72
|
+
/* @__PURE__ */ jsx(Text, { backgroundColor: "red", children: " red " }),
|
|
73
|
+
/* @__PURE__ */ jsx(Text, { backgroundColor: "green", children: " green " }),
|
|
74
|
+
/* @__PURE__ */ jsxs(Text, { backgroundColor: "yellow", color: "black", children: [
|
|
75
|
+
" ",
|
|
76
|
+
"yellow",
|
|
77
|
+
" "
|
|
78
|
+
] }),
|
|
79
|
+
/* @__PURE__ */ jsx(Text, { backgroundColor: "blue", children: " blue " }),
|
|
80
|
+
/* @__PURE__ */ jsx(Text, { backgroundColor: "magenta", children: " magenta " }),
|
|
81
|
+
/* @__PURE__ */ jsxs(Text, { backgroundColor: "cyan", color: "black", children: [
|
|
82
|
+
" ",
|
|
83
|
+
"cyan",
|
|
84
|
+
" "
|
|
85
|
+
] })
|
|
86
|
+
] })
|
|
87
|
+
] })
|
|
88
|
+
] });
|
|
89
|
+
var ExtendedColorsTab = () => /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: 1, children: [
|
|
90
|
+
/* @__PURE__ */ jsx(Text, { bold: true, children: "Extended Colors" }),
|
|
91
|
+
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", paddingLeft: 1, children: [
|
|
92
|
+
/* @__PURE__ */ jsx(Text, { children: "ANSI 256 (color codes):" }),
|
|
93
|
+
/* @__PURE__ */ jsx(Box, { gap: 1, children: ANSI_256_SAMPLE_COLORS.map((code) => /* @__PURE__ */ jsxs(Text, { color: `ansi256-${code}`, children: [
|
|
94
|
+
"#",
|
|
95
|
+
code
|
|
96
|
+
] }, code)) }),
|
|
97
|
+
/* @__PURE__ */ jsx(Newline, {}),
|
|
98
|
+
/* @__PURE__ */ jsx(Text, { children: "RGB True Color (hex):" }),
|
|
99
|
+
/* @__PURE__ */ jsxs(Box, { gap: 1, children: [
|
|
100
|
+
/* @__PURE__ */ jsx(Text, { color: "#ff6b6b", children: "#ff6b6b" }),
|
|
101
|
+
/* @__PURE__ */ jsx(Text, { color: "#ffd93d", children: "#ffd93d" }),
|
|
102
|
+
/* @__PURE__ */ jsx(Text, { color: "#6bcb77", children: "#6bcb77" }),
|
|
103
|
+
/* @__PURE__ */ jsx(Text, { color: "#4d96ff", children: "#4d96ff" }),
|
|
104
|
+
/* @__PURE__ */ jsx(Text, { color: "#9b5de5", children: "#9b5de5" }),
|
|
105
|
+
/* @__PURE__ */ jsx(Text, { color: "#f15bb5", children: "#f15bb5" })
|
|
106
|
+
] }),
|
|
107
|
+
/* @__PURE__ */ jsx(Newline, {}),
|
|
108
|
+
/* @__PURE__ */ jsx(Text, { children: "Gradient effect:" }),
|
|
109
|
+
/* @__PURE__ */ jsx(Box, { children: [
|
|
110
|
+
{ char: "R", color: "#ff0000" },
|
|
111
|
+
{ char: "A", color: "#ff7f00" },
|
|
112
|
+
{ char: "I", color: "#ffff00" },
|
|
113
|
+
{ char: "N", color: "#00ff00" },
|
|
114
|
+
{ char: "B", color: "#0000ff" },
|
|
115
|
+
{ char: "O", color: "#4b0082" },
|
|
116
|
+
{ char: "W", color: "#9400d3" }
|
|
117
|
+
].map(({ char, color }) => /* @__PURE__ */ jsx(Text, { color, children: char }, char)) })
|
|
118
|
+
] })
|
|
119
|
+
] });
|
|
120
|
+
var LayoutTab = () => /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: 1, children: [
|
|
121
|
+
/* @__PURE__ */ jsx(Text, { bold: true, children: "Box Layouts & Borders" }),
|
|
122
|
+
/* @__PURE__ */ jsxs(Box, { gap: 2, paddingLeft: 1, children: [
|
|
123
|
+
/* @__PURE__ */ jsxs(
|
|
124
|
+
Box,
|
|
125
|
+
{
|
|
126
|
+
flexDirection: "column",
|
|
127
|
+
borderStyle: "single",
|
|
128
|
+
borderColor: "cyan",
|
|
129
|
+
paddingX: 1,
|
|
130
|
+
children: [
|
|
131
|
+
/* @__PURE__ */ jsx(Text, { children: "Single" }),
|
|
132
|
+
/* @__PURE__ */ jsx(Text, { children: "Border" })
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
/* @__PURE__ */ jsxs(
|
|
137
|
+
Box,
|
|
138
|
+
{
|
|
139
|
+
flexDirection: "column",
|
|
140
|
+
borderStyle: "double",
|
|
141
|
+
borderColor: "yellow",
|
|
142
|
+
paddingX: 1,
|
|
143
|
+
children: [
|
|
144
|
+
/* @__PURE__ */ jsx(Text, { children: "Double" }),
|
|
145
|
+
/* @__PURE__ */ jsx(Text, { children: "Border" })
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
/* @__PURE__ */ jsxs(
|
|
150
|
+
Box,
|
|
151
|
+
{
|
|
152
|
+
flexDirection: "column",
|
|
153
|
+
borderStyle: "round",
|
|
154
|
+
borderColor: "green",
|
|
155
|
+
paddingX: 1,
|
|
156
|
+
children: [
|
|
157
|
+
/* @__PURE__ */ jsx(Text, { children: "Round" }),
|
|
158
|
+
/* @__PURE__ */ jsx(Text, { children: "Border" })
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
),
|
|
162
|
+
/* @__PURE__ */ jsxs(
|
|
163
|
+
Box,
|
|
164
|
+
{
|
|
165
|
+
flexDirection: "column",
|
|
166
|
+
borderStyle: "bold",
|
|
167
|
+
borderColor: "magenta",
|
|
168
|
+
paddingX: 1,
|
|
169
|
+
children: [
|
|
170
|
+
/* @__PURE__ */ jsx(Text, { children: "Bold" }),
|
|
171
|
+
/* @__PURE__ */ jsx(Text, { children: "Border" })
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
] }),
|
|
176
|
+
/* @__PURE__ */ jsx(Box, { paddingLeft: 1, marginTop: 1, children: /* @__PURE__ */ jsxs(
|
|
177
|
+
Box,
|
|
178
|
+
{
|
|
179
|
+
borderStyle: "single",
|
|
180
|
+
borderColor: "blue",
|
|
181
|
+
padding: 1,
|
|
182
|
+
flexDirection: "column",
|
|
183
|
+
width: 40,
|
|
184
|
+
children: [
|
|
185
|
+
/* @__PURE__ */ jsxs(Box, { justifyContent: "space-between", children: [
|
|
186
|
+
/* @__PURE__ */ jsx(Text, { children: "Left" }),
|
|
187
|
+
/* @__PURE__ */ jsx(Text, { children: "Right" })
|
|
188
|
+
] }),
|
|
189
|
+
/* @__PURE__ */ jsx(Box, { justifyContent: "center", marginY: 1, children: /* @__PURE__ */ jsx(Text, { color: "cyan", children: "Centered content" }) }),
|
|
190
|
+
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, { dimColor: true, children: "Nested box with padding" }) })
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
) })
|
|
194
|
+
] });
|
|
195
|
+
var ProgressBar = ({
|
|
196
|
+
value,
|
|
197
|
+
width = DEFAULT_PROGRESS_WIDTH,
|
|
198
|
+
color = "green"
|
|
199
|
+
}) => {
|
|
200
|
+
const filled = Math.round(value / PERCENT_MAX * width);
|
|
201
|
+
const empty = width - filled;
|
|
202
|
+
return /* @__PURE__ */ jsxs(Text, { children: [
|
|
203
|
+
/* @__PURE__ */ jsx(Text, { color, children: "\u2588".repeat(filled) }),
|
|
204
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u2591".repeat(empty) }),
|
|
205
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
206
|
+
" ",
|
|
207
|
+
value.toFixed(0),
|
|
208
|
+
"%"
|
|
209
|
+
] })
|
|
210
|
+
] });
|
|
211
|
+
};
|
|
212
|
+
var DynamicTab = ({
|
|
213
|
+
elapsed,
|
|
214
|
+
progress
|
|
215
|
+
}) => {
|
|
216
|
+
const spinnerFrames = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
217
|
+
const spinnerFrame = spinnerFrames[elapsed % spinnerFrames.length];
|
|
218
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: 1, children: [
|
|
219
|
+
/* @__PURE__ */ jsx(Text, { bold: true, children: "Dynamic Updates" }),
|
|
220
|
+
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", paddingLeft: 1, children: [
|
|
221
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
222
|
+
"Elapsed: ",
|
|
223
|
+
/* @__PURE__ */ jsxs(Text, { color: "cyan", children: [
|
|
224
|
+
elapsed,
|
|
225
|
+
"s"
|
|
226
|
+
] })
|
|
227
|
+
] }),
|
|
228
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
229
|
+
"Spinner: ",
|
|
230
|
+
/* @__PURE__ */ jsx(Text, { color: "yellow", children: spinnerFrame }),
|
|
231
|
+
" Loading..."
|
|
232
|
+
] }),
|
|
233
|
+
/* @__PURE__ */ jsx(Newline, {}),
|
|
234
|
+
/* @__PURE__ */ jsx(Text, { children: "Progress bars:" }),
|
|
235
|
+
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", paddingLeft: 1, children: [
|
|
236
|
+
/* @__PURE__ */ jsxs(Box, { gap: 1, children: [
|
|
237
|
+
/* @__PURE__ */ jsx(Text, { children: "CPU:" }),
|
|
238
|
+
/* @__PURE__ */ jsx(ProgressBar, { value: progress, color: "green" })
|
|
239
|
+
] }),
|
|
240
|
+
/* @__PURE__ */ jsxs(Box, { gap: 1, children: [
|
|
241
|
+
/* @__PURE__ */ jsx(Text, { children: "MEM:" }),
|
|
242
|
+
/* @__PURE__ */ jsx(
|
|
243
|
+
ProgressBar,
|
|
244
|
+
{
|
|
245
|
+
value: (progress * PROGRESS_MEM_MULTIPLIER + PROGRESS_MEM_OFFSET) % PERCENT_MAX,
|
|
246
|
+
color: "blue"
|
|
247
|
+
}
|
|
248
|
+
)
|
|
249
|
+
] }),
|
|
250
|
+
/* @__PURE__ */ jsxs(Box, { gap: 1, children: [
|
|
251
|
+
/* @__PURE__ */ jsx(Text, { children: "DSK:" }),
|
|
252
|
+
/* @__PURE__ */ jsx(
|
|
253
|
+
ProgressBar,
|
|
254
|
+
{
|
|
255
|
+
value: (progress * PROGRESS_DSK_MULTIPLIER + PROGRESS_DSK_OFFSET) % PERCENT_MAX,
|
|
256
|
+
color: "yellow"
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
] })
|
|
260
|
+
] }),
|
|
261
|
+
/* @__PURE__ */ jsx(Newline, {}),
|
|
262
|
+
/* @__PURE__ */ jsx(Text, { children: "Animation:" }),
|
|
263
|
+
/* @__PURE__ */ jsx(Box, { paddingLeft: 1, children: /* @__PURE__ */ jsx(Text, { color: "cyan", children: "\u25CF".padStart(elapsed % ANIMATION_WIDTH + 1, " ").padEnd(ANIMATION_WIDTH, " ") }) })
|
|
264
|
+
] })
|
|
265
|
+
] });
|
|
266
|
+
};
|
|
267
|
+
var TAB_STYLES = 0;
|
|
268
|
+
var TAB_COLORS = 1;
|
|
269
|
+
var TAB_EXTENDED = 2;
|
|
270
|
+
var TAB_LAYOUT = 3;
|
|
271
|
+
var TAB_DYNAMIC = 4;
|
|
272
|
+
var MENU_ITEMS = [
|
|
273
|
+
{ id: "styles", label: "Text Styles" },
|
|
274
|
+
{ id: "colors", label: "Basic Colors" },
|
|
275
|
+
{ id: "extended", label: "Extended Colors" },
|
|
276
|
+
{ id: "layout", label: "Layouts" },
|
|
277
|
+
{ id: "dynamic", label: "Dynamic" }
|
|
278
|
+
];
|
|
279
|
+
var DemoApp = ({ scaleFactor: scaleFactor2, cacheStats: cacheStats2 }) => {
|
|
280
|
+
const [selectedTab, setSelectedTab] = useState(0);
|
|
281
|
+
const [elapsed, setElapsed] = useState(0);
|
|
282
|
+
const [progress, setProgress] = useState(0);
|
|
283
|
+
useEffect(() => {
|
|
284
|
+
const timer = setInterval(() => {
|
|
285
|
+
setElapsed((e) => e + 1);
|
|
286
|
+
setProgress((p) => (p + 2) % PERCENT_MAX);
|
|
287
|
+
}, TIMER_INTERVAL_MS);
|
|
288
|
+
return () => clearInterval(timer);
|
|
289
|
+
}, []);
|
|
290
|
+
useInput((input, key) => {
|
|
291
|
+
if (key.leftArrow || input === "h") {
|
|
292
|
+
setSelectedTab((t) => t > 0 ? t - 1 : MENU_ITEMS.length - 1);
|
|
293
|
+
} else if (key.rightArrow || input === "l") {
|
|
294
|
+
setSelectedTab((t) => t < MENU_ITEMS.length - 1 ? t + 1 : 0);
|
|
295
|
+
} else if (key.tab) {
|
|
296
|
+
setSelectedTab((t) => (t + 1) % MENU_ITEMS.length);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", padding: 1, children: [
|
|
300
|
+
/* @__PURE__ */ jsxs(Box, { borderStyle: "double", borderColor: "cyan", paddingX: 2, children: [
|
|
301
|
+
/* @__PURE__ */ jsx(Text, { bold: true, color: "cyan", children: "ink-sdl Demo" }),
|
|
302
|
+
/* @__PURE__ */ jsx(Spacer, {}),
|
|
303
|
+
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
304
|
+
"Scale: ",
|
|
305
|
+
scaleFactor2.toFixed(SCALE_DECIMAL_PLACES),
|
|
306
|
+
"x",
|
|
307
|
+
cacheStats2 ? ` | Cache: ${cacheStats2.size}/${cacheStats2.maxSize}` : ""
|
|
308
|
+
] })
|
|
309
|
+
] }),
|
|
310
|
+
/* @__PURE__ */ jsx(Box, { marginY: 1, gap: 1, children: MENU_ITEMS.map(
|
|
311
|
+
(item, i) => i === selectedTab ? /* @__PURE__ */ jsx(
|
|
312
|
+
Box,
|
|
313
|
+
{
|
|
314
|
+
borderStyle: "round",
|
|
315
|
+
borderColor: "cyan",
|
|
316
|
+
paddingX: 1,
|
|
317
|
+
children: /* @__PURE__ */ jsx(Text, { color: "cyan", bold: true, children: item.label })
|
|
318
|
+
},
|
|
319
|
+
item.id
|
|
320
|
+
) : /* @__PURE__ */ jsx(
|
|
321
|
+
Box,
|
|
322
|
+
{
|
|
323
|
+
borderStyle: "single",
|
|
324
|
+
borderColor: "gray",
|
|
325
|
+
paddingX: 1,
|
|
326
|
+
children: /* @__PURE__ */ jsx(Text, { children: item.label })
|
|
327
|
+
},
|
|
328
|
+
item.id
|
|
329
|
+
)
|
|
330
|
+
) }),
|
|
331
|
+
/* @__PURE__ */ jsxs(
|
|
332
|
+
Box,
|
|
333
|
+
{
|
|
334
|
+
flexDirection: "column",
|
|
335
|
+
borderStyle: "single",
|
|
336
|
+
borderColor: "gray",
|
|
337
|
+
padding: 1,
|
|
338
|
+
minHeight: 15,
|
|
339
|
+
children: [
|
|
340
|
+
selectedTab === TAB_STYLES && /* @__PURE__ */ jsx(TextStylesTab, {}),
|
|
341
|
+
selectedTab === TAB_COLORS && /* @__PURE__ */ jsx(BasicColorsTab, {}),
|
|
342
|
+
selectedTab === TAB_EXTENDED && /* @__PURE__ */ jsx(ExtendedColorsTab, {}),
|
|
343
|
+
selectedTab === TAB_LAYOUT && /* @__PURE__ */ jsx(LayoutTab, {}),
|
|
344
|
+
selectedTab === TAB_DYNAMIC && /* @__PURE__ */ jsx(DynamicTab, { elapsed, progress })
|
|
345
|
+
]
|
|
346
|
+
}
|
|
347
|
+
),
|
|
348
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u2190 \u2192 or h/l to switch tabs | Tab to cycle | Ctrl+C to exit" }) })
|
|
349
|
+
] });
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
// src/cli.tsx
|
|
353
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
354
|
+
var DEFAULT_WIDTH = 800;
|
|
355
|
+
var DEFAULT_HEIGHT = 600;
|
|
356
|
+
var { values: args } = parseArgs({
|
|
357
|
+
options: {
|
|
358
|
+
title: { type: "string" },
|
|
359
|
+
width: { type: "string" },
|
|
360
|
+
height: { type: "string" },
|
|
361
|
+
font: { type: "string" },
|
|
362
|
+
"font-name": { type: "string" },
|
|
363
|
+
"font-size": { type: "string" },
|
|
364
|
+
"scale-factor": { type: "string" },
|
|
365
|
+
"system-font": { type: "boolean", default: false },
|
|
366
|
+
background: { type: "string" },
|
|
367
|
+
fullscreen: { type: "string" },
|
|
368
|
+
borderless: { type: "boolean", default: false },
|
|
369
|
+
"min-width": { type: "string" },
|
|
370
|
+
"min-height": { type: "string" },
|
|
371
|
+
help: { type: "boolean", short: "h", default: false }
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
if (args.help) {
|
|
375
|
+
console.log(`
|
|
376
|
+
ink-sdl - Render Ink apps in SDL windows
|
|
377
|
+
|
|
378
|
+
Usage: npx ink-sdl [options]
|
|
379
|
+
|
|
380
|
+
Options:
|
|
381
|
+
--title <string> Window title
|
|
382
|
+
--width <number> Window width in pixels (default: 800)
|
|
383
|
+
--height <number> Window height in pixels (default: 600)
|
|
384
|
+
--font <path> Path to a custom TTF font file
|
|
385
|
+
--font-name <name> Font name to find in system directories
|
|
386
|
+
--font-size <number> Font size in points (default: 16)
|
|
387
|
+
--scale-factor <number> Override scale factor (auto-detect if omitted)
|
|
388
|
+
--system-font Use system monospace font instead of Cozette
|
|
389
|
+
--background <hex> Background color (e.g., "#1a1a2e")
|
|
390
|
+
--fullscreen <mode> Fullscreen mode ("true" or "desktop")
|
|
391
|
+
--borderless Remove window decorations
|
|
392
|
+
--min-width <number> Minimum window width in pixels
|
|
393
|
+
--min-height <number> Minimum window height in pixels
|
|
394
|
+
-h, --help Show this help message
|
|
395
|
+
|
|
396
|
+
For library usage, see: https://github.com/anthropics/ink-sdl
|
|
397
|
+
`);
|
|
398
|
+
process.exit(0);
|
|
399
|
+
}
|
|
400
|
+
var parseFullscreen = (value) => {
|
|
401
|
+
if (value === "true") {
|
|
402
|
+
return true;
|
|
403
|
+
}
|
|
404
|
+
if (value === "desktop") {
|
|
405
|
+
return "desktop";
|
|
406
|
+
}
|
|
407
|
+
return void 0;
|
|
408
|
+
};
|
|
409
|
+
var sdlOptions = {
|
|
410
|
+
title: args.title ?? "ink-sdl Demo",
|
|
411
|
+
width: args.width ? parseInt(args.width, 10) : DEFAULT_WIDTH,
|
|
412
|
+
height: args.height ? parseInt(args.height, 10) : DEFAULT_HEIGHT,
|
|
413
|
+
systemFont: args["system-font"],
|
|
414
|
+
borderless: args.borderless,
|
|
415
|
+
...args.font && { fontPath: args.font },
|
|
416
|
+
...args["font-name"] && { fontName: args["font-name"] },
|
|
417
|
+
...args["font-size"] && { fontSize: parseInt(args["font-size"], 10) },
|
|
418
|
+
...args["scale-factor"] && {
|
|
419
|
+
scaleFactor: parseFloat(args["scale-factor"])
|
|
420
|
+
},
|
|
421
|
+
...args.background && { backgroundColor: args.background },
|
|
422
|
+
...args.fullscreen && { fullscreen: parseFullscreen(args.fullscreen) },
|
|
423
|
+
...args["min-width"] && { minWidth: parseInt(args["min-width"], 10) },
|
|
424
|
+
...args["min-height"] && { minHeight: parseInt(args["min-height"], 10) }
|
|
425
|
+
};
|
|
426
|
+
var { stdin, stdout, window, renderer } = createSdlStreams(sdlOptions);
|
|
427
|
+
var scaleFactor = renderer.getScaleFactor();
|
|
428
|
+
var cacheStats = window.getCacheStats();
|
|
429
|
+
render(/* @__PURE__ */ jsx2(DemoApp, { scaleFactor, cacheStats }), {
|
|
430
|
+
stdin,
|
|
431
|
+
stdout
|
|
432
|
+
});
|
|
433
|
+
window.on("close", () => process.exit(0));
|
|
434
|
+
process.on("SIGINT", () => {
|
|
435
|
+
window.close();
|
|
436
|
+
process.exit(0);
|
|
437
|
+
});
|