@silvery/examples 0.4.2 → 0.4.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/bin/cli.ts +8 -1
- package/examples/_banner.tsx +60 -0
- package/examples/apps/aichat/index.tsx +1 -1
- package/examples/apps/app-todo.tsx +1 -1
- package/examples/apps/async-data.tsx +1 -1
- package/examples/apps/cli-wizard.tsx +1 -1
- package/examples/apps/clipboard.tsx +1 -1
- package/examples/apps/components.tsx +1 -1
- package/examples/apps/data-explorer.tsx +1 -1
- package/examples/apps/dev-tools.tsx +1 -1
- package/examples/apps/explorer.tsx +1 -1
- package/examples/apps/gallery.tsx +1 -1
- package/examples/apps/inline-bench.tsx +2 -2
- package/examples/apps/kanban.tsx +1 -1
- package/examples/apps/layout-ref.tsx +1 -1
- package/examples/apps/outline.tsx +1 -1
- package/examples/apps/panes/index.tsx +2 -2
- package/examples/apps/paste-demo.tsx +1 -1
- package/examples/apps/scroll.tsx +1 -1
- package/examples/apps/search-filter.tsx +1 -1
- package/examples/apps/task-list.tsx +1 -1
- package/examples/apps/terminal.tsx +1 -1
- package/examples/apps/textarea.tsx +1 -1
- package/examples/apps/theme.tsx +2 -2
- package/examples/apps/transform.tsx +1 -1
- package/examples/apps/virtual-10k.tsx +2 -2
- package/examples/components/counter.tsx +2 -2
- package/examples/components/hello.tsx +2 -2
- package/examples/components/progress-bar.tsx +2 -2
- package/examples/components/select-list.tsx +2 -2
- package/examples/components/spinner.tsx +2 -2
- package/examples/components/text-input.tsx +2 -2
- package/examples/components/virtual-list.tsx +2 -2
- package/package.json +1 -1
package/bin/cli.ts
CHANGED
|
@@ -258,11 +258,18 @@ async function main(): Promise<void> {
|
|
|
258
258
|
const args = process.argv.slice(2)
|
|
259
259
|
|
|
260
260
|
// Top-level flags
|
|
261
|
-
if (args.includes("--help") || args.includes("-h")
|
|
261
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
262
262
|
printHelp()
|
|
263
263
|
return
|
|
264
264
|
}
|
|
265
265
|
|
|
266
|
+
// No args → list examples
|
|
267
|
+
if (args.length === 0) {
|
|
268
|
+
const examples = await discoverExamples()
|
|
269
|
+
printExampleList(examples)
|
|
270
|
+
return
|
|
271
|
+
}
|
|
272
|
+
|
|
266
273
|
if (args.includes("--version") || args.includes("-v")) {
|
|
267
274
|
try {
|
|
268
275
|
const { resolve } = await import("node:path")
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { Box, Text, Strong, Muted, ThemeProvider, getThemeByName, type Theme } from "silvery"
|
|
3
|
+
|
|
4
|
+
export interface ExampleMeta {
|
|
5
|
+
name: string
|
|
6
|
+
description: string
|
|
7
|
+
/** API features showcased, e.g. ["VirtualList", "useContentRect()"] */
|
|
8
|
+
features?: string[]
|
|
9
|
+
/** Curated demo — shown in CLI viewer (`bun examples`) and web showcase */
|
|
10
|
+
demo?: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
meta: ExampleMeta
|
|
15
|
+
/** Short controls legend, e.g. "j/k navigate q quit" */
|
|
16
|
+
controls?: string
|
|
17
|
+
/** Override theme (from viewer). Falls back to SILVERY_THEME env var. */
|
|
18
|
+
theme?: Theme
|
|
19
|
+
children: React.ReactNode
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Compact header shown when examples run standalone.
|
|
24
|
+
* Wraps children in ThemeProvider for consistent theming.
|
|
25
|
+
*/
|
|
26
|
+
export function ExampleBanner({ meta, controls, theme, children }: Props) {
|
|
27
|
+
const resolvedTheme = theme ?? getThemeByName(process.env.SILVERY_THEME)
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<ThemeProvider theme={resolvedTheme}>
|
|
31
|
+
<Box flexDirection="column" flexGrow={1}>
|
|
32
|
+
{/* One-line header: dimmed to not compete with example UI */}
|
|
33
|
+
<Box paddingX={1} gap={1}>
|
|
34
|
+
<Text dim color="$warning">
|
|
35
|
+
{"▸ silvery"}
|
|
36
|
+
</Text>
|
|
37
|
+
<Strong>{meta.name}</Strong>
|
|
38
|
+
<Muted>— {meta.description}</Muted>
|
|
39
|
+
</Box>
|
|
40
|
+
{meta.features && meta.features.length > 0 && (
|
|
41
|
+
<Box paddingX={1}>
|
|
42
|
+
<Muted>
|
|
43
|
+
{" "}
|
|
44
|
+
{meta.features.join(" · ")}
|
|
45
|
+
</Muted>
|
|
46
|
+
</Box>
|
|
47
|
+
)}
|
|
48
|
+
{controls && (
|
|
49
|
+
<Box paddingX={1}>
|
|
50
|
+
<Muted>
|
|
51
|
+
{" "}
|
|
52
|
+
{controls}
|
|
53
|
+
</Muted>
|
|
54
|
+
</Box>
|
|
55
|
+
)}
|
|
56
|
+
{children}
|
|
57
|
+
</Box>
|
|
58
|
+
</ThemeProvider>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
import React, { useEffect, useRef, useMemo } from "react"
|
|
12
12
|
import { Box, Text, Spinner, ScrollbackList, useTea } from "silvery"
|
|
13
|
-
import { run, useInput, useExit, type Key } from "
|
|
13
|
+
import { run, useInput, useExit, type Key } from "silvery/runtime"
|
|
14
14
|
import type { ExampleMeta } from "../../_banner.js"
|
|
15
15
|
import type { ScriptEntry } from "./types.js"
|
|
16
16
|
import { SCRIPT, generateStressScript, CONTEXT_WINDOW } from "./script.js"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import React from "react"
|
|
26
|
-
import { Box, Text, Muted, Kbd } from "
|
|
26
|
+
import { Box, Text, Muted, Kbd } from "silvery"
|
|
27
27
|
import { createApp, useApp, type AppHandle } from "@silvery/tea/create-app"
|
|
28
28
|
import { pipe, withReact, withTerminal } from "@silvery/tea/plugins"
|
|
29
29
|
import { ExampleBanner, type ExampleMeta } from "../_banner.js"
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* bun examples/apps/inline-bench.tsx
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { TerminalBuffer } from "
|
|
13
|
-
import { createOutputPhase, outputPhase } from "
|
|
12
|
+
import { TerminalBuffer } from "silvery"
|
|
13
|
+
import { createOutputPhase, outputPhase } from "silvery/pipeline/output-phase"
|
|
14
14
|
|
|
15
15
|
const RUNS = 500
|
|
16
16
|
|
package/examples/apps/kanban.tsx
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import React, { useState } from "react"
|
|
12
|
-
import { render, Box, Text, Kbd, Muted, useInput, useApp, createTerm, type Key } from "
|
|
12
|
+
import { render, Box, Text, Kbd, Muted, useInput, useApp, createTerm, type Key } from "silvery"
|
|
13
13
|
import { ExampleBanner, type ExampleMeta } from "../_banner.js"
|
|
14
14
|
|
|
15
15
|
export const meta: ExampleMeta = {
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
import React, { useState, useEffect, useMemo } from "react"
|
|
11
11
|
import { Box, Text, ListView } from "silvery"
|
|
12
|
-
import { SurfaceRegistryProvider, SearchProvider, SearchBar, useSearch } from "
|
|
13
|
-
import { run, useInput, type Key } from "
|
|
12
|
+
import { SurfaceRegistryProvider, SearchProvider, SearchBar, useSearch } from "silvery"
|
|
13
|
+
import { run, useInput, type Key } from "silvery/runtime"
|
|
14
14
|
import type { ExampleMeta } from "../../_banner.js"
|
|
15
15
|
import { SCRIPT } from "../aichat/script.js"
|
|
16
16
|
import type { ScriptEntry } from "../aichat/types.js"
|
package/examples/apps/scroll.tsx
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import React, { useState } from "react"
|
|
8
|
-
import { Box, Text, Kbd, Muted, render, useInput, useApp, createTerm, type Key } from "
|
|
8
|
+
import { Box, Text, Kbd, Muted, render, useInput, useApp, createTerm, type Key } from "silvery"
|
|
9
9
|
import { ExampleBanner, type ExampleMeta } from "../_banner.js"
|
|
10
10
|
|
|
11
11
|
export const meta: ExampleMeta = {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import React, { useState, useDeferredValue, useTransition } from "react"
|
|
11
|
-
import { render, Box, Text, Kbd, Muted, Strong, Lead, useInput, useApp, createTerm, type Key } from "
|
|
11
|
+
import { render, Box, Text, Kbd, Muted, Strong, Lead, useInput, useApp, createTerm, type Key } from "silvery"
|
|
12
12
|
import { ExampleBanner, type ExampleMeta } from "../_banner.js"
|
|
13
13
|
|
|
14
14
|
export const meta: ExampleMeta = {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import React, { useState, useMemo } from "react"
|
|
12
|
-
import { render, Box, Text, Kbd, Muted, useInput, useApp, createTerm, type Key } from "
|
|
12
|
+
import { render, Box, Text, Kbd, Muted, useInput, useApp, createTerm, type Key } from "silvery"
|
|
13
13
|
import { ExampleBanner, type ExampleMeta } from "../_banner.js"
|
|
14
14
|
|
|
15
15
|
export const meta: ExampleMeta = {
|
package/examples/apps/theme.tsx
CHANGED
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
detectTheme,
|
|
38
38
|
type Key,
|
|
39
39
|
type Theme,
|
|
40
|
-
} from "
|
|
40
|
+
} from "silvery"
|
|
41
41
|
import {
|
|
42
42
|
builtinPalettes,
|
|
43
43
|
deriveTheme,
|
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
ansi16LightTheme,
|
|
46
46
|
type ColorPalette,
|
|
47
47
|
type ThemeAdjustment,
|
|
48
|
-
} from "
|
|
48
|
+
} from "silvery/theme"
|
|
49
49
|
import { ExampleBanner, type ExampleMeta } from "../_banner.js"
|
|
50
50
|
|
|
51
51
|
export const meta: ExampleMeta = {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import React, { useState, useCallback, useMemo } from "react"
|
|
25
|
-
import { Box, Text, Strong, Kbd, Muted, Divider, VirtualList, useContentRect } from "
|
|
26
|
-
import { run, useInput, type Key } from "
|
|
25
|
+
import { Box, Text, Strong, Kbd, Muted, Divider, VirtualList, useContentRect } from "silvery"
|
|
26
|
+
import { run, useInput, type Key } from "silvery/runtime"
|
|
27
27
|
import { ExampleBanner, type ExampleMeta } from "../_banner.js"
|
|
28
28
|
|
|
29
29
|
export const meta: ExampleMeta = {
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import React, { useState } from "react"
|
|
11
|
-
import { Box, Text } from "
|
|
12
|
-
import { run, useInput } from "
|
|
11
|
+
import { Box, Text } from "silvery"
|
|
12
|
+
import { run, useInput } from "silvery/runtime"
|
|
13
13
|
|
|
14
14
|
function Counter() {
|
|
15
15
|
const [count, setCount] = useState(0)
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import React from "react"
|
|
10
|
-
import { Box, Text } from "
|
|
11
|
-
import { run, useInput } from "
|
|
10
|
+
import { Box, Text } from "silvery"
|
|
11
|
+
import { run, useInput } from "silvery/runtime"
|
|
12
12
|
|
|
13
13
|
function Hello() {
|
|
14
14
|
useInput(() => "exit" as const)
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import React, { useState } from "react"
|
|
11
|
-
import { Box, Text, ProgressBar } from "
|
|
12
|
-
import { run, useInput } from "
|
|
11
|
+
import { Box, Text, ProgressBar } from "silvery"
|
|
12
|
+
import { run, useInput } from "silvery/runtime"
|
|
13
13
|
|
|
14
14
|
function ProgressBarDemo() {
|
|
15
15
|
const [progress, setProgress] = useState(0.4)
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import React, { useState } from "react"
|
|
11
|
-
import { Box, Text, SelectList } from "
|
|
12
|
-
import { run, useInput } from "
|
|
11
|
+
import { Box, Text, SelectList } from "silvery"
|
|
12
|
+
import { run, useInput } from "silvery/runtime"
|
|
13
13
|
|
|
14
14
|
const languages = [
|
|
15
15
|
{ label: "TypeScript", value: "ts" },
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import React from "react"
|
|
10
|
-
import { Box, Text, Spinner } from "
|
|
11
|
-
import { run, useInput } from "
|
|
10
|
+
import { Box, Text, Spinner } from "silvery"
|
|
11
|
+
import { run, useInput } from "silvery/runtime"
|
|
12
12
|
|
|
13
13
|
function SpinnerDemo() {
|
|
14
14
|
useInput((input, key) => {
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import React, { useState } from "react"
|
|
11
|
-
import { Box, Text, TextInput } from "
|
|
12
|
-
import { run, useInput } from "
|
|
11
|
+
import { Box, Text, TextInput } from "silvery"
|
|
12
|
+
import { run, useInput } from "silvery/runtime"
|
|
13
13
|
|
|
14
14
|
function TextInputDemo() {
|
|
15
15
|
const [value, setValue] = useState("")
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import React from "react"
|
|
11
|
-
import { Box, Text, VirtualList } from "
|
|
12
|
-
import { run, useInput } from "
|
|
11
|
+
import { Box, Text, VirtualList } from "silvery"
|
|
12
|
+
import { run, useInput } from "silvery/runtime"
|
|
13
13
|
|
|
14
14
|
const items = Array.from({ length: 200 }, (_, i) => ({
|
|
15
15
|
id: i,
|
package/package.json
CHANGED