@silvery/examples 0.5.6 → 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.
Files changed (112) hide show
  1. package/dist/UPNG-Cy7ViL8f.mjs +5074 -0
  2. package/dist/__vite-browser-external-2447137e-BML7CYau.mjs +4 -0
  3. package/dist/_banner-DLPxCqVy.mjs +44 -0
  4. package/dist/ansi-CCE2pVS0.mjs +16397 -0
  5. package/dist/apng-HhhBjRGt.mjs +68 -0
  6. package/dist/apng-mwUQbTTF.mjs +3 -0
  7. package/dist/apps/aichat/index.mjs +1299 -0
  8. package/dist/apps/app-todo.mjs +139 -0
  9. package/dist/apps/async-data.mjs +204 -0
  10. package/dist/apps/cli-wizard.mjs +339 -0
  11. package/dist/apps/clipboard.mjs +198 -0
  12. package/dist/apps/components.mjs +864 -0
  13. package/dist/apps/data-explorer.mjs +483 -0
  14. package/dist/apps/dev-tools.mjs +397 -0
  15. package/dist/apps/explorer.mjs +698 -0
  16. package/dist/apps/gallery.mjs +766 -0
  17. package/dist/apps/inline-bench.mjs +115 -0
  18. package/dist/apps/kanban.mjs +280 -0
  19. package/dist/apps/layout-ref.mjs +187 -0
  20. package/dist/apps/outline.mjs +203 -0
  21. package/dist/apps/paste-demo.mjs +189 -0
  22. package/dist/apps/scroll.mjs +86 -0
  23. package/dist/apps/search-filter.mjs +287 -0
  24. package/dist/apps/selection.mjs +355 -0
  25. package/dist/apps/spatial-focus-demo.mjs +388 -0
  26. package/dist/apps/task-list.mjs +258 -0
  27. package/dist/apps/terminal-caps-demo.mjs +315 -0
  28. package/dist/apps/terminal.mjs +872 -0
  29. package/dist/apps/text-selection-demo.mjs +254 -0
  30. package/dist/apps/textarea.mjs +178 -0
  31. package/dist/apps/theme.mjs +661 -0
  32. package/dist/apps/transform.mjs +215 -0
  33. package/dist/apps/virtual-10k.mjs +422 -0
  34. package/dist/assets/resvgjs.darwin-arm64-BtufyGW1.node +0 -0
  35. package/dist/backends-Bahh9mKN.mjs +1179 -0
  36. package/dist/backends-CCtCDQ94.mjs +3 -0
  37. package/dist/{cli.mjs → bin/cli.mjs} +21 -25
  38. package/dist/chunk-BSw8zbkd.mjs +37 -0
  39. package/dist/components/counter.mjs +48 -0
  40. package/dist/components/hello.mjs +31 -0
  41. package/dist/components/progress-bar.mjs +59 -0
  42. package/dist/components/select-list.mjs +85 -0
  43. package/dist/components/spinner.mjs +57 -0
  44. package/dist/components/text-input.mjs +62 -0
  45. package/dist/components/virtual-list.mjs +51 -0
  46. package/dist/flexily-zero-adapter-UB-ra8fR.mjs +3374 -0
  47. package/dist/gif-BZaqPPVX.mjs +3 -0
  48. package/dist/gif-BtnXuxLF.mjs +71 -0
  49. package/dist/gifenc-CLRW41dk.mjs +728 -0
  50. package/dist/jsx-runtime-dMs_8fNu.mjs +241 -0
  51. package/dist/key-mapping-5oYQdAQE.mjs +3 -0
  52. package/dist/key-mapping-D4LR1go6.mjs +130 -0
  53. package/dist/layout/dashboard.mjs +1204 -0
  54. package/dist/layout/live-resize.mjs +303 -0
  55. package/dist/layout/overflow.mjs +70 -0
  56. package/dist/layout/text-layout.mjs +335 -0
  57. package/dist/node-NuJ94BWl.mjs +1083 -0
  58. package/dist/plugins-D1KtkT4a.mjs +3057 -0
  59. package/dist/resvg-js-C_8Wps1F.mjs +201 -0
  60. package/dist/src-BTEVGpd9.mjs +23538 -0
  61. package/dist/src-CUUOuRH6.mjs +5322 -0
  62. package/dist/src-CzfRafCQ.mjs +814 -0
  63. package/dist/usingCtx-CsEf0xO3.mjs +57 -0
  64. package/dist/yoga-adapter-BVtQ5OJR.mjs +237 -0
  65. package/package.json +19 -14
  66. package/_banner.tsx +0 -60
  67. package/apps/aichat/components.tsx +0 -469
  68. package/apps/aichat/index.tsx +0 -220
  69. package/apps/aichat/script.ts +0 -460
  70. package/apps/aichat/state.ts +0 -325
  71. package/apps/aichat/types.ts +0 -19
  72. package/apps/app-todo.tsx +0 -201
  73. package/apps/async-data.tsx +0 -196
  74. package/apps/cli-wizard.tsx +0 -332
  75. package/apps/clipboard.tsx +0 -183
  76. package/apps/components.tsx +0 -658
  77. package/apps/data-explorer.tsx +0 -490
  78. package/apps/dev-tools.tsx +0 -395
  79. package/apps/explorer.tsx +0 -731
  80. package/apps/gallery.tsx +0 -653
  81. package/apps/inline-bench.tsx +0 -138
  82. package/apps/kanban.tsx +0 -265
  83. package/apps/layout-ref.tsx +0 -173
  84. package/apps/outline.tsx +0 -160
  85. package/apps/panes/index.tsx +0 -203
  86. package/apps/paste-demo.tsx +0 -185
  87. package/apps/scroll.tsx +0 -77
  88. package/apps/search-filter.tsx +0 -240
  89. package/apps/selection.tsx +0 -342
  90. package/apps/spatial-focus-demo.tsx +0 -368
  91. package/apps/task-list.tsx +0 -271
  92. package/apps/terminal-caps-demo.tsx +0 -334
  93. package/apps/terminal.tsx +0 -800
  94. package/apps/text-selection-demo.tsx +0 -189
  95. package/apps/textarea.tsx +0 -155
  96. package/apps/theme.tsx +0 -515
  97. package/apps/transform.tsx +0 -229
  98. package/apps/virtual-10k.tsx +0 -405
  99. package/apps/vterm-demo/index.tsx +0 -216
  100. package/components/counter.tsx +0 -45
  101. package/components/hello.tsx +0 -34
  102. package/components/progress-bar.tsx +0 -48
  103. package/components/select-list.tsx +0 -50
  104. package/components/spinner.tsx +0 -40
  105. package/components/text-input.tsx +0 -57
  106. package/components/virtual-list.tsx +0 -52
  107. package/dist/cli.d.mts +0 -1
  108. package/dist/cli.mjs.map +0 -1
  109. package/layout/dashboard.tsx +0 -953
  110. package/layout/live-resize.tsx +0 -282
  111. package/layout/overflow.tsx +0 -51
  112. package/layout/text-layout.tsx +0 -283
@@ -0,0 +1,198 @@
1
+ import { t as _usingCtx } from "../usingCtx-CsEf0xO3.mjs";
2
+ import { t as require_jsx_runtime } from "../jsx-runtime-dMs_8fNu.mjs";
3
+ import { t as ExampleBanner } from "../_banner-DLPxCqVy.mjs";
4
+ import { useState } from "react";
5
+ import { Box, H1, Kbd, Lead, Muted, Small, Text, copyToClipboard, createTerm, parseClipboardResponse, render, requestClipboard, useApp, useInput, useStdout } from "silvery";
6
+ //#region apps/clipboard.tsx
7
+ /**
8
+ * OSC 52 Clipboard Demo
9
+ *
10
+ * Shows copy/paste across terminal sessions using the OSC 52 protocol.
11
+ * Select items from a list, copy them to the system clipboard, and
12
+ * request clipboard contents back — all without native clipboard access.
13
+ *
14
+ * Features:
15
+ * - Navigate a list of items with j/k
16
+ * - Press c to copy selected item via OSC 52
17
+ * - Press v to request clipboard contents
18
+ * - Status bar shows last copied/pasted text
19
+ *
20
+ * Run: bun vendor/silvery/examples/apps/clipboard.tsx
21
+ */
22
+ var import_jsx_runtime = require_jsx_runtime();
23
+ const meta = {
24
+ name: "Clipboard (OSC 52)",
25
+ description: "Copy/paste via OSC 52 terminal protocol",
26
+ features: [
27
+ "copyToClipboard()",
28
+ "requestClipboard()",
29
+ "parseClipboardResponse()",
30
+ "useStdout"
31
+ ]
32
+ };
33
+ const allItems = [
34
+ {
35
+ category: "Colors",
36
+ values: [
37
+ "Crimson",
38
+ "Cerulean",
39
+ "Chartreuse",
40
+ "Coral",
41
+ "Cobalt",
42
+ "Cyan"
43
+ ]
44
+ },
45
+ {
46
+ category: "Languages",
47
+ values: [
48
+ "TypeScript",
49
+ "Rust",
50
+ "Elixir",
51
+ "Haskell",
52
+ "Zig",
53
+ "OCaml"
54
+ ]
55
+ },
56
+ {
57
+ category: "Fruits",
58
+ values: [
59
+ "Mango",
60
+ "Passionfruit",
61
+ "Dragon fruit",
62
+ "Starfruit",
63
+ "Lychee",
64
+ "Rambutan"
65
+ ]
66
+ }
67
+ ].flatMap((group) => group.values.map((value) => ({
68
+ category: group.category,
69
+ value
70
+ })));
71
+ function ListItem({ item, isSelected }) {
72
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
73
+ paddingX: 1,
74
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, {
75
+ color: isSelected ? "$bg" : void 0,
76
+ backgroundColor: isSelected ? "$primary" : void 0,
77
+ bold: isSelected,
78
+ children: [isSelected ? " > " : " ", item.value]
79
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Small, { children: [
80
+ " (",
81
+ item.category,
82
+ ")"
83
+ ] })]
84
+ });
85
+ }
86
+ function StatusBar({ lastCopied, lastPasted }) {
87
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
88
+ flexDirection: "column",
89
+ borderStyle: "round",
90
+ borderColor: "$border",
91
+ paddingX: 1,
92
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
93
+ gap: 1,
94
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Muted, { children: "Copied:" }), lastCopied ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
95
+ color: "$success",
96
+ children: lastCopied
97
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Lead, { children: "nothing yet" })]
98
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
99
+ gap: 1,
100
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Muted, { children: "Pasted:" }), lastPasted ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
101
+ color: "$warning",
102
+ children: lastPasted
103
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Lead, { children: "nothing yet" })]
104
+ })]
105
+ });
106
+ }
107
+ function ClipboardDemo() {
108
+ const { exit } = useApp();
109
+ const { stdout } = useStdout();
110
+ const [selectedIndex, setSelectedIndex] = useState(0);
111
+ const [lastCopied, setLastCopied] = useState(null);
112
+ const [lastPasted, setLastPasted] = useState(null);
113
+ useInput((input, key) => {
114
+ if (input === "q" || key.escape) {
115
+ exit();
116
+ return;
117
+ }
118
+ if (key.upArrow || input === "k") setSelectedIndex((prev) => Math.max(0, prev - 1));
119
+ if (key.downArrow || input === "j") setSelectedIndex((prev) => Math.min(allItems.length - 1, prev + 1));
120
+ if (input === "c") {
121
+ const text = allItems[selectedIndex].value;
122
+ copyToClipboard(stdout, text);
123
+ setLastCopied(text);
124
+ }
125
+ if (input === "v") {
126
+ requestClipboard(stdout);
127
+ setLastPasted("(request sent — check terminal)");
128
+ }
129
+ const parsed = parseClipboardResponse(input);
130
+ if (parsed) setLastPasted(parsed);
131
+ });
132
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
133
+ flexDirection: "column",
134
+ padding: 1,
135
+ gap: 1,
136
+ children: [
137
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
138
+ flexDirection: "column",
139
+ borderStyle: "round",
140
+ borderColor: "$primary",
141
+ paddingX: 1,
142
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, {
143
+ marginBottom: 1,
144
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(H1, { children: "Items" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Small, { children: [
145
+ " ",
146
+ "— ",
147
+ selectedIndex + 1,
148
+ "/",
149
+ allItems.length
150
+ ] })]
151
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, {
152
+ flexDirection: "column",
153
+ overflow: "scroll",
154
+ scrollTo: selectedIndex,
155
+ height: 10,
156
+ children: allItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ListItem, {
157
+ item,
158
+ isSelected: index === selectedIndex
159
+ }, `${item.category}-${item.value}`))
160
+ })]
161
+ }),
162
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusBar, {
163
+ lastCopied,
164
+ lastPasted
165
+ }),
166
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Muted, { children: [
167
+ " ",
168
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Kbd, { children: "j/k" }),
169
+ " navigate ",
170
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Kbd, { children: "c" }),
171
+ " copy ",
172
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Kbd, { children: "v" }),
173
+ " paste ",
174
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Kbd, { children: "Esc/q" }),
175
+ " quit"
176
+ ] })
177
+ ]
178
+ });
179
+ }
180
+ async function main() {
181
+ try {
182
+ var _usingCtx$1 = _usingCtx();
183
+ const term = _usingCtx$1.u(createTerm());
184
+ const { waitUntilExit } = await render(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExampleBanner, {
185
+ meta,
186
+ controls: "j/k navigate c copy v paste Esc/q quit",
187
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ClipboardDemo, {})
188
+ }), term);
189
+ await waitUntilExit();
190
+ } catch (_) {
191
+ _usingCtx$1.e = _;
192
+ } finally {
193
+ _usingCtx$1.d();
194
+ }
195
+ }
196
+ if (import.meta.main) await main();
197
+ //#endregion
198
+ export { ClipboardDemo, main, meta };