@silvery/examples 0.17.3 → 0.17.4
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/dist/UPNG-Cy7ViL8f.mjs +5074 -0
- package/dist/__vite-browser-external-2447137e-BML7CYau.mjs +4 -0
- package/dist/_banner-DLPxCqVy.mjs +44 -0
- package/dist/ansi-CCE2pVS0.mjs +16397 -0
- package/dist/apng-HhhBjRGt.mjs +68 -0
- package/dist/apng-mwUQbTTF.mjs +3 -0
- package/dist/apps/aichat/index.mjs +1299 -0
- package/dist/apps/app-todo.mjs +139 -0
- package/dist/apps/async-data.mjs +204 -0
- package/dist/apps/cli-wizard.mjs +339 -0
- package/dist/apps/clipboard.mjs +198 -0
- package/dist/apps/components.mjs +864 -0
- package/dist/apps/data-explorer.mjs +483 -0
- package/dist/apps/dev-tools.mjs +397 -0
- package/dist/apps/explorer.mjs +698 -0
- package/dist/apps/gallery.mjs +766 -0
- package/dist/apps/inline-bench.mjs +115 -0
- package/dist/apps/kanban.mjs +280 -0
- package/dist/apps/layout-ref.mjs +187 -0
- package/dist/apps/outline.mjs +203 -0
- package/dist/apps/paste-demo.mjs +189 -0
- package/dist/apps/scroll.mjs +86 -0
- package/dist/apps/search-filter.mjs +287 -0
- package/dist/apps/selection.mjs +355 -0
- package/dist/apps/spatial-focus-demo.mjs +388 -0
- package/dist/apps/task-list.mjs +258 -0
- package/dist/apps/terminal-caps-demo.mjs +315 -0
- package/dist/apps/terminal.mjs +872 -0
- package/dist/apps/text-selection-demo.mjs +254 -0
- package/dist/apps/textarea.mjs +178 -0
- package/dist/apps/theme.mjs +661 -0
- package/dist/apps/transform.mjs +215 -0
- package/dist/apps/virtual-10k.mjs +422 -0
- package/dist/assets/resvgjs.darwin-arm64-BtufyGW1.node +0 -0
- package/dist/backends-Bahh9mKN.mjs +1179 -0
- package/dist/backends-CCtCDQ94.mjs +3 -0
- package/dist/{cli.mjs → bin/cli.mjs} +15 -19
- package/dist/chunk-BSw8zbkd.mjs +37 -0
- package/dist/components/counter.mjs +48 -0
- package/dist/components/hello.mjs +31 -0
- package/dist/components/progress-bar.mjs +59 -0
- package/dist/components/select-list.mjs +85 -0
- package/dist/components/spinner.mjs +57 -0
- package/dist/components/text-input.mjs +62 -0
- package/dist/components/virtual-list.mjs +51 -0
- package/dist/flexily-zero-adapter-UB-ra8fR.mjs +3374 -0
- package/dist/gif-BZaqPPVX.mjs +3 -0
- package/dist/gif-BtnXuxLF.mjs +71 -0
- package/dist/gifenc-CLRW41dk.mjs +728 -0
- package/dist/jsx-runtime-dMs_8fNu.mjs +241 -0
- package/dist/key-mapping-5oYQdAQE.mjs +3 -0
- package/dist/key-mapping-D4LR1go6.mjs +130 -0
- package/dist/layout/dashboard.mjs +1204 -0
- package/dist/layout/live-resize.mjs +303 -0
- package/dist/layout/overflow.mjs +70 -0
- package/dist/layout/text-layout.mjs +335 -0
- package/dist/node-NuJ94BWl.mjs +1083 -0
- package/dist/plugins-D1KtkT4a.mjs +3057 -0
- package/dist/resvg-js-C_8Wps1F.mjs +201 -0
- package/dist/src-BTEVGpd9.mjs +23538 -0
- package/dist/src-CUUOuRH6.mjs +5322 -0
- package/dist/src-CzfRafCQ.mjs +814 -0
- package/dist/usingCtx-CsEf0xO3.mjs +57 -0
- package/dist/yoga-adapter-BVtQ5OJR.mjs +237 -0
- package/package.json +18 -13
- package/_banner.tsx +0 -60
- package/apps/aichat/components.tsx +0 -469
- package/apps/aichat/index.tsx +0 -220
- package/apps/aichat/script.ts +0 -460
- package/apps/aichat/state.ts +0 -325
- package/apps/aichat/types.ts +0 -19
- package/apps/app-todo.tsx +0 -201
- package/apps/async-data.tsx +0 -196
- package/apps/cli-wizard.tsx +0 -332
- package/apps/clipboard.tsx +0 -183
- package/apps/components.tsx +0 -658
- package/apps/data-explorer.tsx +0 -490
- package/apps/dev-tools.tsx +0 -395
- package/apps/explorer.tsx +0 -731
- package/apps/gallery.tsx +0 -653
- package/apps/inline-bench.tsx +0 -138
- package/apps/kanban.tsx +0 -265
- package/apps/layout-ref.tsx +0 -173
- package/apps/outline.tsx +0 -160
- package/apps/panes/index.tsx +0 -203
- package/apps/paste-demo.tsx +0 -185
- package/apps/scroll.tsx +0 -80
- package/apps/search-filter.tsx +0 -240
- package/apps/selection.tsx +0 -346
- package/apps/spatial-focus-demo.tsx +0 -372
- package/apps/task-list.tsx +0 -271
- package/apps/terminal-caps-demo.tsx +0 -317
- package/apps/terminal.tsx +0 -784
- package/apps/text-selection-demo.tsx +0 -193
- package/apps/textarea.tsx +0 -155
- package/apps/theme.tsx +0 -515
- package/apps/transform.tsx +0 -229
- package/apps/virtual-10k.tsx +0 -405
- package/apps/vterm-demo/index.tsx +0 -216
- package/components/counter.tsx +0 -49
- package/components/hello.tsx +0 -38
- package/components/progress-bar.tsx +0 -52
- package/components/select-list.tsx +0 -54
- package/components/spinner.tsx +0 -44
- package/components/text-input.tsx +0 -61
- package/components/virtual-list.tsx +0 -56
- package/dist/cli.d.mts +0 -1
- package/dist/cli.mjs.map +0 -1
- package/layout/dashboard.tsx +0 -953
- package/layout/live-resize.tsx +0 -282
- package/layout/overflow.tsx +0 -51
- package/layout/text-layout.tsx +0 -283
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Terminal Capabilities Demo
|
|
3
|
-
*
|
|
4
|
-
* A "terminal health check" dashboard that probes all supported terminal
|
|
5
|
-
* protocols and displays their status in real time.
|
|
6
|
-
*
|
|
7
|
-
* Probed protocols:
|
|
8
|
-
* - Synchronized Output (Mode 2026)
|
|
9
|
-
* - SGR Mouse (Mode 1006)
|
|
10
|
-
* - Bracketed Paste (Mode 2004)
|
|
11
|
-
* - Focus Reporting (Mode 1004)
|
|
12
|
-
* - Kitty Keyboard (CSI u)
|
|
13
|
-
* - Mode 2031 Color Scheme Detection
|
|
14
|
-
* - DEC 1020-1023 Width Detection (UTF-8, CJK, Emoji, Private-Use)
|
|
15
|
-
* - OSC 66 Text Sizing
|
|
16
|
-
* - OSC 52 Clipboard
|
|
17
|
-
* - OSC 5522 Advanced Clipboard
|
|
18
|
-
* - OSC 8 Hyperlinks
|
|
19
|
-
* - Image Support (Kitty Graphics / Sixel)
|
|
20
|
-
* - DA1/DA2/DA3 Device Attributes
|
|
21
|
-
*
|
|
22
|
-
* Run: bun vendor/silvery/examples/apps/terminal-caps-demo.tsx
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import React, { useState } from "react"
|
|
26
|
-
import { Box, Text, H3, Muted, Kbd, render, useInput, useApp, type Key } from "silvery"
|
|
27
|
-
import {
|
|
28
|
-
detectTerminalCaps,
|
|
29
|
-
type TerminalCaps,
|
|
30
|
-
createWidthDetector,
|
|
31
|
-
type TerminalWidthConfig,
|
|
32
|
-
DEFAULT_WIDTH_CONFIG,
|
|
33
|
-
detectKittyFromStdio,
|
|
34
|
-
} from "@silvery/ag-term"
|
|
35
|
-
import { createColorSchemeDetector, type ColorScheme } from "@silvery/ag-term/ansi"
|
|
36
|
-
import { ExampleBanner, type ExampleMeta } from "../_banner.js"
|
|
37
|
-
|
|
38
|
-
export const meta: ExampleMeta = {
|
|
39
|
-
name: "Terminal Capabilities",
|
|
40
|
-
description: "Probe and display all supported terminal protocols",
|
|
41
|
-
demo: true,
|
|
42
|
-
features: ["detectTerminalCaps()", "Mode 2031", "DEC 1020-1023", "OSC 66", "OSC 52", "OSC 5522", "DA1/DA2/DA3"],
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// ============================================================================
|
|
46
|
-
// Types
|
|
47
|
-
// ============================================================================
|
|
48
|
-
|
|
49
|
-
type CapStatus = "supported" | "not-supported" | "probing" | "detected"
|
|
50
|
-
|
|
51
|
-
interface CapEntry {
|
|
52
|
-
name: string
|
|
53
|
-
status: CapStatus
|
|
54
|
-
detail?: string
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// ============================================================================
|
|
58
|
-
// Status indicator component
|
|
59
|
-
// ============================================================================
|
|
60
|
-
|
|
61
|
-
function StatusIcon({ status }: { status: CapStatus }) {
|
|
62
|
-
switch (status) {
|
|
63
|
-
case "supported":
|
|
64
|
-
return <Text color="$success">{"✓"}</Text>
|
|
65
|
-
case "not-supported":
|
|
66
|
-
return <Text color="$error">{"✗"}</Text>
|
|
67
|
-
case "probing":
|
|
68
|
-
return <Text color="$warning">{"?"}</Text>
|
|
69
|
-
case "detected":
|
|
70
|
-
return <Text color="$warning">{"?"}</Text>
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function CapRow({ entry, width }: { entry: CapEntry; width: number }) {
|
|
75
|
-
const label = entry.detail ? `${entry.name}: ${entry.detail}` : entry.name
|
|
76
|
-
const padded = label.length < width ? label + " ".repeat(width - label.length) : label
|
|
77
|
-
return (
|
|
78
|
-
<Box>
|
|
79
|
-
<StatusIcon status={entry.status} />
|
|
80
|
-
<Text> </Text>
|
|
81
|
-
<Text color={entry.status === "not-supported" ? "$muted" : undefined}>{padded}</Text>
|
|
82
|
-
</Box>
|
|
83
|
-
)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// ============================================================================
|
|
87
|
-
// Build capability entries from detected caps
|
|
88
|
-
// ============================================================================
|
|
89
|
-
|
|
90
|
-
function buildStaticEntries(caps: TerminalCaps): CapEntry[] {
|
|
91
|
-
const bool = (supported: boolean): CapStatus => (supported ? "supported" : "not-supported")
|
|
92
|
-
|
|
93
|
-
return [
|
|
94
|
-
{ name: "Synchronized Output (Mode 2026)", status: bool(caps.syncOutput) },
|
|
95
|
-
{ name: "SGR Mouse (Mode 1006)", status: bool(caps.mouse) },
|
|
96
|
-
{ name: "Bracketed Paste (Mode 2004)", status: bool(caps.bracketedPaste) },
|
|
97
|
-
{ name: "Focus Reporting (Mode 1004)", status: bool(caps.bracketedPaste) }, // focus follows paste support heuristic
|
|
98
|
-
{ name: "Kitty Keyboard (CSI u)", status: bool(caps.kittyKeyboard) },
|
|
99
|
-
{ name: "OSC 52 Clipboard", status: bool(caps.osc52) },
|
|
100
|
-
{ name: "OSC 8 Hyperlinks", status: bool(caps.hyperlinks) },
|
|
101
|
-
{
|
|
102
|
-
name: "Image Support",
|
|
103
|
-
status: caps.kittyGraphics || caps.sixel ? "supported" : "not-supported",
|
|
104
|
-
detail: caps.kittyGraphics ? "Kitty" : caps.sixel ? "Sixel" : "none",
|
|
105
|
-
},
|
|
106
|
-
{ name: "Notifications (OSC 9/99)", status: bool(caps.notifications) },
|
|
107
|
-
{ name: "Underline Styles (SGR 4:x)", status: bool(caps.underlineStyles) },
|
|
108
|
-
{ name: "Underline Color (SGR 58)", status: bool(caps.underlineColor) },
|
|
109
|
-
{ name: "Unicode", status: bool(caps.unicode) },
|
|
110
|
-
{ name: "Nerd Font", status: bool(caps.nerdfont) },
|
|
111
|
-
]
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// ============================================================================
|
|
115
|
-
// Main app component
|
|
116
|
-
// ============================================================================
|
|
117
|
-
|
|
118
|
-
function TerminalCapsApp({
|
|
119
|
-
initialProbes,
|
|
120
|
-
}: {
|
|
121
|
-
initialProbes?: { colorScheme: ColorScheme; widthConfig: TerminalWidthConfig | null; kittyDetected: boolean | null }
|
|
122
|
-
}) {
|
|
123
|
-
const { exit } = useApp()
|
|
124
|
-
const [caps] = useState<TerminalCaps>(() => detectTerminalCaps())
|
|
125
|
-
const [colorScheme] = useState<ColorScheme>(initialProbes?.colorScheme ?? "unknown")
|
|
126
|
-
const [widthConfig] = useState<TerminalWidthConfig | null>(initialProbes?.widthConfig ?? null)
|
|
127
|
-
const [kittyDetected] = useState<boolean | null>(initialProbes?.kittyDetected ?? null)
|
|
128
|
-
|
|
129
|
-
// Quit on q or Esc
|
|
130
|
-
useInput((input: string, key: Key) => {
|
|
131
|
-
if (input === "q" || key.escape) {
|
|
132
|
-
exit()
|
|
133
|
-
}
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
// Probing is done before render() in main() — no useEffect needed.
|
|
137
|
-
// This avoids stdin conflicts between protocol responses and useInput.
|
|
138
|
-
|
|
139
|
-
// Build the display entries
|
|
140
|
-
const staticEntries = buildStaticEntries(caps)
|
|
141
|
-
|
|
142
|
-
// Override Kitty detection if we have live results
|
|
143
|
-
if (kittyDetected !== null) {
|
|
144
|
-
const kittyEntry = staticEntries.find((e) => e.name.startsWith("Kitty Keyboard"))
|
|
145
|
-
if (kittyEntry) {
|
|
146
|
-
kittyEntry.status = kittyDetected ? "supported" : "not-supported"
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Dynamic probe entries
|
|
151
|
-
const probeEntries: CapEntry[] = [
|
|
152
|
-
{
|
|
153
|
-
name: "Mode 2031 Color Scheme",
|
|
154
|
-
status: colorScheme === "unknown" ? "probing" : "detected",
|
|
155
|
-
detail: colorScheme === "unknown" ? "probing..." : colorScheme,
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
name: "DEC 1020 UTF-8",
|
|
159
|
-
status: widthConfig === null ? "probing" : "detected",
|
|
160
|
-
detail: widthConfig === null ? "probing..." : widthConfig.utf8 ? "enabled" : "disabled",
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
name: "DEC 1021 CJK Width",
|
|
164
|
-
status: widthConfig === null ? "probing" : "detected",
|
|
165
|
-
detail: widthConfig === null ? "probing..." : String(widthConfig.cjkWidth),
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
name: "DEC 1022 Emoji Width",
|
|
169
|
-
status: widthConfig === null ? "probing" : "detected",
|
|
170
|
-
detail: widthConfig === null ? "probing..." : String(widthConfig.emojiWidth),
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
name: "DEC 1023 Private Width",
|
|
174
|
-
status: widthConfig === null ? "probing" : "detected",
|
|
175
|
-
detail: widthConfig === null ? "probing..." : String(widthConfig.privateUseWidth),
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
name: "OSC 66 Text Sizing",
|
|
179
|
-
status: caps.textSizingSupported ? "supported" : "not-supported",
|
|
180
|
-
detail: caps.textSizingSupported ? "supported" : "not supported",
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
name: "OSC 5522 Advanced Clipboard",
|
|
184
|
-
// Kitty 0.28+ supports this; approximate via kitty detection
|
|
185
|
-
status: caps.term === "xterm-kitty" ? "supported" : "not-supported",
|
|
186
|
-
detail: caps.term === "xterm-kitty" ? "Kitty" : "not supported",
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
name: "DA1/DA2/DA3",
|
|
190
|
-
// All modern terminals respond to DA queries
|
|
191
|
-
status: caps.program !== "" ? "supported" : "not-supported",
|
|
192
|
-
},
|
|
193
|
-
]
|
|
194
|
-
|
|
195
|
-
// Terminal info header
|
|
196
|
-
const termProgram = caps.program || "(unknown)"
|
|
197
|
-
const termType = caps.term || "(unknown)"
|
|
198
|
-
const colorLevel = caps.colorLevel
|
|
199
|
-
|
|
200
|
-
// Column width for alignment
|
|
201
|
-
const colWidth = 38
|
|
202
|
-
|
|
203
|
-
return (
|
|
204
|
-
<Box flexDirection="column" paddingX={1} paddingY={1}>
|
|
205
|
-
<H3>Terminal Capabilities Probe</H3>
|
|
206
|
-
|
|
207
|
-
{/* Terminal identity */}
|
|
208
|
-
<Box paddingBottom={1}>
|
|
209
|
-
<Muted>
|
|
210
|
-
Terminal: {termProgram} ({termType}) | Colors: {colorLevel} | Background:{" "}
|
|
211
|
-
{caps.darkBackground ? "dark" : "light"}
|
|
212
|
-
</Muted>
|
|
213
|
-
</Box>
|
|
214
|
-
|
|
215
|
-
{/* Two-column layout */}
|
|
216
|
-
<Box>
|
|
217
|
-
{/* Left column: static capabilities */}
|
|
218
|
-
<Box flexDirection="column" width={colWidth + 4}>
|
|
219
|
-
<Text bold color="$primary">
|
|
220
|
-
Static Detection
|
|
221
|
-
</Text>
|
|
222
|
-
<Box height={1} />
|
|
223
|
-
{staticEntries.map((entry) => (
|
|
224
|
-
<CapRow key={entry.name} entry={entry} width={colWidth} />
|
|
225
|
-
))}
|
|
226
|
-
</Box>
|
|
227
|
-
|
|
228
|
-
{/* Right column: runtime probes */}
|
|
229
|
-
<Box flexDirection="column" width={colWidth + 4}>
|
|
230
|
-
<Text bold color="$primary">
|
|
231
|
-
Runtime Probes
|
|
232
|
-
</Text>
|
|
233
|
-
<Box height={1} />
|
|
234
|
-
{probeEntries.map((entry) => (
|
|
235
|
-
<CapRow key={entry.name} entry={entry} width={colWidth} />
|
|
236
|
-
))}
|
|
237
|
-
</Box>
|
|
238
|
-
</Box>
|
|
239
|
-
|
|
240
|
-
{/* Footer */}
|
|
241
|
-
<Box paddingTop={1}>
|
|
242
|
-
<Muted>
|
|
243
|
-
<Kbd>q</Kbd> or <Kbd>Esc</Kbd> to quit
|
|
244
|
-
</Muted>
|
|
245
|
-
</Box>
|
|
246
|
-
</Box>
|
|
247
|
-
)
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// ============================================================================
|
|
251
|
-
// Main
|
|
252
|
-
// ============================================================================
|
|
253
|
-
|
|
254
|
-
export async function main() {
|
|
255
|
-
// Probe BEFORE render() starts — avoids stdin conflict with useInput.
|
|
256
|
-
// Once render() owns stdin, protocol responses leak as visible text.
|
|
257
|
-
let probeResults: {
|
|
258
|
-
colorScheme: ColorScheme
|
|
259
|
-
widthConfig: TerminalWidthConfig | null
|
|
260
|
-
kittyDetected: boolean | null
|
|
261
|
-
} = { colorScheme: "unknown", widthConfig: null, kittyDetected: null }
|
|
262
|
-
|
|
263
|
-
if (process.stdin.isTTY) {
|
|
264
|
-
process.stdin.setRawMode(true)
|
|
265
|
-
process.stdin.resume()
|
|
266
|
-
|
|
267
|
-
const write = (data: string) => process.stdout.write(data)
|
|
268
|
-
const onData = (handler: (data: string) => void): (() => void) => {
|
|
269
|
-
const h = (chunk: Buffer | string) => handler(typeof chunk === "string" ? chunk : chunk.toString())
|
|
270
|
-
process.stdin.on("data", h)
|
|
271
|
-
return () => process.stdin.removeListener("data", h)
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// Run all probes in parallel with 500ms timeout
|
|
275
|
-
const [colorResult, widthResult, kittyResult] = await Promise.allSettled([
|
|
276
|
-
new Promise<ColorScheme>((resolve) => {
|
|
277
|
-
const det = createColorSchemeDetector({ write, onData, timeoutMs: 500 })
|
|
278
|
-
det.subscribe((s) => {
|
|
279
|
-
resolve(s)
|
|
280
|
-
det.stop()
|
|
281
|
-
})
|
|
282
|
-
det.start()
|
|
283
|
-
setTimeout(() => {
|
|
284
|
-
resolve(det.scheme)
|
|
285
|
-
det.stop()
|
|
286
|
-
}, 600)
|
|
287
|
-
}),
|
|
288
|
-
createWidthDetector({ write, onData, timeoutMs: 500 })
|
|
289
|
-
.detect()
|
|
290
|
-
.catch(() => null),
|
|
291
|
-
detectKittyFromStdio(process.stdout, process.stdin, 500)
|
|
292
|
-
.then((r) => r.supported)
|
|
293
|
-
.catch(() => false),
|
|
294
|
-
])
|
|
295
|
-
|
|
296
|
-
probeResults = {
|
|
297
|
-
colorScheme: colorResult.status === "fulfilled" ? colorResult.value : "unknown",
|
|
298
|
-
widthConfig: widthResult.status === "fulfilled" ? widthResult.value : null,
|
|
299
|
-
kittyDetected: kittyResult.status === "fulfilled" ? kittyResult.value : false,
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
process.stdin.setRawMode(false)
|
|
303
|
-
process.stdin.pause()
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
const { waitUntilExit } = await render(
|
|
307
|
-
<ExampleBanner meta={meta} controls="q/Esc quit">
|
|
308
|
-
<TerminalCapsApp initialProbes={probeResults} />
|
|
309
|
-
</ExampleBanner>,
|
|
310
|
-
)
|
|
311
|
-
|
|
312
|
-
await waitUntilExit()
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
if (import.meta.main) {
|
|
316
|
-
await main()
|
|
317
|
-
}
|