@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 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") || args.length === 0) {
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 "@silvery/ag-term/runtime"
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 "../../src/index.js"
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"
@@ -20,7 +20,7 @@ import {
20
20
  createTerm,
21
21
  ErrorBoundary,
22
22
  type Key,
23
- } from "../../src/index.js"
23
+ } from "silvery"
24
24
  import { ExampleBanner, type ExampleMeta } from "../_banner.js"
25
25
 
26
26
  export const meta: ExampleMeta = {
@@ -35,7 +35,7 @@ import {
35
35
  Code,
36
36
  type Key,
37
37
  type SelectOption,
38
- } from "../../src/index.js"
38
+ } from "silvery"
39
39
  import { ExampleBanner, type ExampleMeta } from "../_banner.js"
40
40
 
41
41
  export const meta: ExampleMeta = {
@@ -32,7 +32,7 @@ import {
32
32
  requestClipboard,
33
33
  parseClipboardResponse,
34
34
  type Key,
35
- } from "../../src/index.js"
35
+ } from "silvery"
36
36
  import { ExampleBanner, type ExampleMeta } from "../_banner.js"
37
37
 
38
38
  export const meta: ExampleMeta = {
@@ -50,7 +50,7 @@ import {
50
50
  Tab,
51
51
  TabPanel,
52
52
  type Key,
53
- } from "../../src/index.js"
53
+ } from "silvery"
54
54
  import { ExampleBanner, type ExampleMeta } from "../_banner.js"
55
55
 
56
56
  export const meta: ExampleMeta = {
@@ -35,7 +35,7 @@ import {
35
35
  Muted,
36
36
  Lead,
37
37
  type Key,
38
- } from "../../src/index.js"
38
+ } from "silvery"
39
39
  import { ExampleBanner, type ExampleMeta } from "../_banner.js"
40
40
 
41
41
  export const meta: ExampleMeta = {
@@ -37,7 +37,7 @@ import {
37
37
  Kbd,
38
38
  Muted,
39
39
  type Key,
40
- } from "../../src/index.js"
40
+ } from "silvery"
41
41
  import { ExampleBanner, type ExampleMeta } from "../_banner.js"
42
42
 
43
43
  export const meta: ExampleMeta = {
@@ -39,7 +39,7 @@ import {
39
39
  Kbd,
40
40
  Muted,
41
41
  type Key,
42
- } from "../../src/index.js"
42
+ } from "silvery"
43
43
  import { ExampleBanner, type ExampleMeta } from "../_banner.js"
44
44
 
45
45
  export const meta: ExampleMeta = {
@@ -29,7 +29,7 @@ import {
29
29
  useContentRect,
30
30
  createTerm,
31
31
  type Key,
32
- } from "../../src/index.js"
32
+ } from "silvery"
33
33
  import { ExampleBanner, type ExampleMeta } from "../_banner.js"
34
34
 
35
35
  export const meta: ExampleMeta = {
@@ -9,8 +9,8 @@
9
9
  * bun examples/apps/inline-bench.tsx
10
10
  */
11
11
 
12
- import { TerminalBuffer } from "@silvery/ag-term/buffer"
13
- import { createOutputPhase, outputPhase } from "@silvery/ag-term/pipeline/output-phase"
12
+ import { TerminalBuffer } from "silvery"
13
+ import { createOutputPhase, outputPhase } from "silvery/pipeline/output-phase"
14
14
 
15
15
  const RUNS = 500
16
16
 
@@ -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 "../../src/index.js"
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 = {
@@ -20,7 +20,7 @@ import {
20
20
  createTerm,
21
21
  type BoxHandle,
22
22
  type Key,
23
- } from "../../src/index.js"
23
+ } from "silvery"
24
24
  import { ExampleBanner, type ExampleMeta } from "../_banner.js"
25
25
 
26
26
  export const meta: ExampleMeta = {
@@ -26,7 +26,7 @@ import {
26
26
  useContentRect,
27
27
  createTerm,
28
28
  type Key,
29
- } from "../../src/index.js"
29
+ } from "silvery"
30
30
  import { ExampleBanner, type ExampleMeta } from "../_banner.js"
31
31
 
32
32
  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 "@silvery/ag-react"
13
- import { run, useInput, type Key } from "@silvery/ag-term/runtime"
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"
@@ -28,7 +28,7 @@ import {
28
28
  useApp,
29
29
  createTerm,
30
30
  type Key,
31
- } from "../../src/index.js"
31
+ } from "silvery"
32
32
  import { ExampleBanner, type ExampleMeta } from "../_banner.js"
33
33
 
34
34
  export const meta: ExampleMeta = {
@@ -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 "../../src/index.js"
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 "../../src/index.js"
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 "../../src/index.js"
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 = {
@@ -49,7 +49,7 @@ import {
49
49
  parseFocusEvent,
50
50
  type Key,
51
51
  type ParsedKeypress,
52
- } from "../../src/index.js"
52
+ } from "silvery"
53
53
  import { ExampleBanner, type ExampleMeta } from "../_banner.js"
54
54
 
55
55
  export const meta: ExampleMeta = {
@@ -22,7 +22,7 @@ import {
22
22
  useApp,
23
23
  createTerm,
24
24
  type Key,
25
- } from "../../src/index.js"
25
+ } from "silvery"
26
26
  import { ExampleBanner, type ExampleMeta } from "../_banner.js"
27
27
 
28
28
  export const meta: ExampleMeta = {
@@ -37,7 +37,7 @@ import {
37
37
  detectTheme,
38
38
  type Key,
39
39
  type Theme,
40
- } from "../../src/index.js"
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 "@silvery/theme"
48
+ } from "silvery/theme"
49
49
  import { ExampleBanner, type ExampleMeta } from "../_banner.js"
50
50
 
51
51
  export const meta: ExampleMeta = {
@@ -27,7 +27,7 @@ import {
27
27
  useApp,
28
28
  createTerm,
29
29
  type Key,
30
- } from "../../src/index.js"
30
+ } from "silvery"
31
31
  import { ExampleBanner, type ExampleMeta } from "../_banner.js"
32
32
 
33
33
  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 "../../src/index.js"
26
- import { run, useInput, type Key } from "@silvery/ag-term/runtime"
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 "../../src/index.js"
12
- import { run, useInput } from "@silvery/ag-term/runtime"
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 "../../src/index.js"
11
- import { run, useInput } from "@silvery/ag-term/runtime"
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 "../../src/index.js"
12
- import { run, useInput } from "@silvery/ag-term/runtime"
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 "../../src/index.js"
12
- import { run, useInput } from "@silvery/ag-term/runtime"
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 "../../src/index.js"
11
- import { run, useInput } from "@silvery/ag-term/runtime"
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 "../../src/index.js"
12
- import { run, useInput } from "@silvery/ag-term/runtime"
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 "../../src/index.js"
12
- import { run, useInput } from "@silvery/ag-term/runtime"
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@silvery/examples",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Example apps and component demos for silvery \u2014 bunx @silvery/examples <name>",
5
5
  "license": "MIT",
6
6
  "author": "Bj\u00f8rn Stabell <bjorn@stabell.org>",