@silvery/examples 0.17.3 → 0.17.5

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 (111) hide show
  1. package/dist/UPNG-ShUlaTDh.mjs +5074 -0
  2. package/dist/__vite-browser-external-2447137e-Bopa5BFR.mjs +4 -0
  3. package/dist/_banner-A70_y2Vi.mjs +43 -0
  4. package/dist/ansi-0VXlUmNn.mjs +16397 -0
  5. package/dist/apng-B0gRaDVT.mjs +3 -0
  6. package/dist/apng-BTRDTfDW.mjs +68 -0
  7. package/dist/apps/aichat/index.mjs +1298 -0
  8. package/dist/apps/app-todo.mjs +138 -0
  9. package/dist/apps/async-data.mjs +203 -0
  10. package/dist/apps/cli-wizard.mjs +338 -0
  11. package/dist/apps/clipboard.mjs +197 -0
  12. package/dist/apps/components.mjs +863 -0
  13. package/dist/apps/data-explorer.mjs +482 -0
  14. package/dist/apps/dev-tools.mjs +396 -0
  15. package/dist/apps/explorer.mjs +697 -0
  16. package/dist/apps/gallery.mjs +765 -0
  17. package/dist/apps/inline-bench.mjs +115 -0
  18. package/dist/apps/kanban.mjs +279 -0
  19. package/dist/apps/layout-ref.mjs +186 -0
  20. package/dist/apps/outline.mjs +202 -0
  21. package/dist/apps/paste-demo.mjs +188 -0
  22. package/dist/apps/scroll.mjs +85 -0
  23. package/dist/apps/search-filter.mjs +286 -0
  24. package/dist/apps/selection.mjs +354 -0
  25. package/dist/apps/spatial-focus-demo.mjs +387 -0
  26. package/dist/apps/task-list.mjs +257 -0
  27. package/dist/apps/terminal-caps-demo.mjs +314 -0
  28. package/dist/apps/terminal.mjs +871 -0
  29. package/dist/apps/text-selection-demo.mjs +253 -0
  30. package/dist/apps/textarea.mjs +177 -0
  31. package/dist/apps/theme.mjs +660 -0
  32. package/dist/apps/transform.mjs +214 -0
  33. package/dist/apps/virtual-10k.mjs +421 -0
  34. package/dist/assets/resvgjs.darwin-arm64-BtufyGW1.node +0 -0
  35. package/dist/backends-Dj-11kZF.mjs +1179 -0
  36. package/dist/backends-U3QwStfO.mjs +3 -0
  37. package/dist/{cli.mjs → bin/cli.mjs} +15 -19
  38. package/dist/chunk-BSw8zbkd.mjs +37 -0
  39. package/dist/components/counter.mjs +47 -0
  40. package/dist/components/hello.mjs +30 -0
  41. package/dist/components/progress-bar.mjs +58 -0
  42. package/dist/components/select-list.mjs +84 -0
  43. package/dist/components/spinner.mjs +56 -0
  44. package/dist/components/text-input.mjs +61 -0
  45. package/dist/components/virtual-list.mjs +50 -0
  46. package/dist/flexily-zero-adapter-ByVzLTFP.mjs +3374 -0
  47. package/dist/gif-B6NGH5gs.mjs +3 -0
  48. package/dist/gif-CfkOF-iG.mjs +71 -0
  49. package/dist/gifenc-BI4ihP_T.mjs +728 -0
  50. package/dist/key-mapping-5oYQdAQE.mjs +3 -0
  51. package/dist/key-mapping-D4LR1go6.mjs +130 -0
  52. package/dist/layout/dashboard.mjs +1203 -0
  53. package/dist/layout/live-resize.mjs +302 -0
  54. package/dist/layout/overflow.mjs +69 -0
  55. package/dist/layout/text-layout.mjs +334 -0
  56. package/dist/node-nsrAOjH4.mjs +1083 -0
  57. package/dist/plugins-CT0DdV_E.mjs +3056 -0
  58. package/dist/resvg-js-Cnk2o49d.mjs +201 -0
  59. package/dist/src-9ZhfQyzD.mjs +814 -0
  60. package/dist/src-CUUOuRH6.mjs +5322 -0
  61. package/dist/src-jO3Zuzjj.mjs +23538 -0
  62. package/dist/usingCtx-CsEf0xO3.mjs +57 -0
  63. package/dist/yoga-adapter-BSQHuMV9.mjs +237 -0
  64. package/package.json +21 -14
  65. package/_banner.tsx +0 -60
  66. package/apps/aichat/components.tsx +0 -469
  67. package/apps/aichat/index.tsx +0 -220
  68. package/apps/aichat/script.ts +0 -460
  69. package/apps/aichat/state.ts +0 -325
  70. package/apps/aichat/types.ts +0 -19
  71. package/apps/app-todo.tsx +0 -201
  72. package/apps/async-data.tsx +0 -196
  73. package/apps/cli-wizard.tsx +0 -332
  74. package/apps/clipboard.tsx +0 -183
  75. package/apps/components.tsx +0 -658
  76. package/apps/data-explorer.tsx +0 -490
  77. package/apps/dev-tools.tsx +0 -395
  78. package/apps/explorer.tsx +0 -731
  79. package/apps/gallery.tsx +0 -653
  80. package/apps/inline-bench.tsx +0 -138
  81. package/apps/kanban.tsx +0 -265
  82. package/apps/layout-ref.tsx +0 -173
  83. package/apps/outline.tsx +0 -160
  84. package/apps/panes/index.tsx +0 -203
  85. package/apps/paste-demo.tsx +0 -185
  86. package/apps/scroll.tsx +0 -80
  87. package/apps/search-filter.tsx +0 -240
  88. package/apps/selection.tsx +0 -346
  89. package/apps/spatial-focus-demo.tsx +0 -372
  90. package/apps/task-list.tsx +0 -271
  91. package/apps/terminal-caps-demo.tsx +0 -317
  92. package/apps/terminal.tsx +0 -784
  93. package/apps/text-selection-demo.tsx +0 -193
  94. package/apps/textarea.tsx +0 -155
  95. package/apps/theme.tsx +0 -515
  96. package/apps/transform.tsx +0 -229
  97. package/apps/virtual-10k.tsx +0 -405
  98. package/apps/vterm-demo/index.tsx +0 -216
  99. package/components/counter.tsx +0 -49
  100. package/components/hello.tsx +0 -38
  101. package/components/progress-bar.tsx +0 -52
  102. package/components/select-list.tsx +0 -54
  103. package/components/spinner.tsx +0 -44
  104. package/components/text-input.tsx +0 -61
  105. package/components/virtual-list.tsx +0 -56
  106. package/dist/cli.d.mts +0 -1
  107. package/dist/cli.mjs.map +0 -1
  108. package/layout/dashboard.tsx +0 -953
  109. package/layout/live-resize.tsx +0 -282
  110. package/layout/overflow.tsx +0 -51
  111. package/layout/text-layout.tsx +0 -283
@@ -0,0 +1,197 @@
1
+ import { t as _usingCtx } from "../usingCtx-CsEf0xO3.mjs";
2
+ import { t as ExampleBanner } from "../_banner-A70_y2Vi.mjs";
3
+ import { useState } from "react";
4
+ import { Box, H1, Kbd, Lead, Muted, Small, Text, copyToClipboard, createTerm, parseClipboardResponse, render, requestClipboard, useApp, useInput, useStdout } from "silvery";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
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
+ const meta = {
23
+ name: "Clipboard (OSC 52)",
24
+ description: "Copy/paste via OSC 52 terminal protocol",
25
+ features: [
26
+ "copyToClipboard()",
27
+ "requestClipboard()",
28
+ "parseClipboardResponse()",
29
+ "useStdout"
30
+ ]
31
+ };
32
+ const allItems = [
33
+ {
34
+ category: "Colors",
35
+ values: [
36
+ "Crimson",
37
+ "Cerulean",
38
+ "Chartreuse",
39
+ "Coral",
40
+ "Cobalt",
41
+ "Cyan"
42
+ ]
43
+ },
44
+ {
45
+ category: "Languages",
46
+ values: [
47
+ "TypeScript",
48
+ "Rust",
49
+ "Elixir",
50
+ "Haskell",
51
+ "Zig",
52
+ "OCaml"
53
+ ]
54
+ },
55
+ {
56
+ category: "Fruits",
57
+ values: [
58
+ "Mango",
59
+ "Passionfruit",
60
+ "Dragon fruit",
61
+ "Starfruit",
62
+ "Lychee",
63
+ "Rambutan"
64
+ ]
65
+ }
66
+ ].flatMap((group) => group.values.map((value) => ({
67
+ category: group.category,
68
+ value
69
+ })));
70
+ function ListItem({ item, isSelected }) {
71
+ return /* @__PURE__ */ jsxs(Box, {
72
+ paddingX: 1,
73
+ children: [/* @__PURE__ */ jsxs(Text, {
74
+ color: isSelected ? "$bg" : void 0,
75
+ backgroundColor: isSelected ? "$primary" : void 0,
76
+ bold: isSelected,
77
+ children: [isSelected ? " > " : " ", item.value]
78
+ }), /* @__PURE__ */ jsxs(Small, { children: [
79
+ " (",
80
+ item.category,
81
+ ")"
82
+ ] })]
83
+ });
84
+ }
85
+ function StatusBar({ lastCopied, lastPasted }) {
86
+ return /* @__PURE__ */ jsxs(Box, {
87
+ flexDirection: "column",
88
+ borderStyle: "round",
89
+ borderColor: "$border",
90
+ paddingX: 1,
91
+ children: [/* @__PURE__ */ jsxs(Box, {
92
+ gap: 1,
93
+ children: [/* @__PURE__ */ jsx(Muted, { children: "Copied:" }), lastCopied ? /* @__PURE__ */ jsx(Text, {
94
+ color: "$success",
95
+ children: lastCopied
96
+ }) : /* @__PURE__ */ jsx(Lead, { children: "nothing yet" })]
97
+ }), /* @__PURE__ */ jsxs(Box, {
98
+ gap: 1,
99
+ children: [/* @__PURE__ */ jsx(Muted, { children: "Pasted:" }), lastPasted ? /* @__PURE__ */ jsx(Text, {
100
+ color: "$warning",
101
+ children: lastPasted
102
+ }) : /* @__PURE__ */ jsx(Lead, { children: "nothing yet" })]
103
+ })]
104
+ });
105
+ }
106
+ function ClipboardDemo() {
107
+ const { exit } = useApp();
108
+ const { stdout } = useStdout();
109
+ const [selectedIndex, setSelectedIndex] = useState(0);
110
+ const [lastCopied, setLastCopied] = useState(null);
111
+ const [lastPasted, setLastPasted] = useState(null);
112
+ useInput((input, key) => {
113
+ if (input === "q" || key.escape) {
114
+ exit();
115
+ return;
116
+ }
117
+ if (key.upArrow || input === "k") setSelectedIndex((prev) => Math.max(0, prev - 1));
118
+ if (key.downArrow || input === "j") setSelectedIndex((prev) => Math.min(allItems.length - 1, prev + 1));
119
+ if (input === "c") {
120
+ const text = allItems[selectedIndex].value;
121
+ copyToClipboard(stdout, text);
122
+ setLastCopied(text);
123
+ }
124
+ if (input === "v") {
125
+ requestClipboard(stdout);
126
+ setLastPasted("(request sent — check terminal)");
127
+ }
128
+ const parsed = parseClipboardResponse(input);
129
+ if (parsed) setLastPasted(parsed);
130
+ });
131
+ return /* @__PURE__ */ jsxs(Box, {
132
+ flexDirection: "column",
133
+ padding: 1,
134
+ gap: 1,
135
+ children: [
136
+ /* @__PURE__ */ jsxs(Box, {
137
+ flexDirection: "column",
138
+ borderStyle: "round",
139
+ borderColor: "$primary",
140
+ paddingX: 1,
141
+ children: [/* @__PURE__ */ jsxs(Box, {
142
+ marginBottom: 1,
143
+ children: [/* @__PURE__ */ jsx(H1, { children: "Items" }), /* @__PURE__ */ jsxs(Small, { children: [
144
+ " ",
145
+ "— ",
146
+ selectedIndex + 1,
147
+ "/",
148
+ allItems.length
149
+ ] })]
150
+ }), /* @__PURE__ */ jsx(Box, {
151
+ flexDirection: "column",
152
+ overflow: "scroll",
153
+ scrollTo: selectedIndex,
154
+ height: 10,
155
+ children: allItems.map((item, index) => /* @__PURE__ */ jsx(ListItem, {
156
+ item,
157
+ isSelected: index === selectedIndex
158
+ }, `${item.category}-${item.value}`))
159
+ })]
160
+ }),
161
+ /* @__PURE__ */ jsx(StatusBar, {
162
+ lastCopied,
163
+ lastPasted
164
+ }),
165
+ /* @__PURE__ */ jsxs(Muted, { children: [
166
+ " ",
167
+ /* @__PURE__ */ jsx(Kbd, { children: "j/k" }),
168
+ " navigate ",
169
+ /* @__PURE__ */ jsx(Kbd, { children: "c" }),
170
+ " copy ",
171
+ /* @__PURE__ */ jsx(Kbd, { children: "v" }),
172
+ " paste ",
173
+ /* @__PURE__ */ jsx(Kbd, { children: "Esc/q" }),
174
+ " quit"
175
+ ] })
176
+ ]
177
+ });
178
+ }
179
+ async function main() {
180
+ try {
181
+ var _usingCtx$1 = _usingCtx();
182
+ const term = _usingCtx$1.u(createTerm());
183
+ const { waitUntilExit } = await render(/* @__PURE__ */ jsx(ExampleBanner, {
184
+ meta,
185
+ controls: "j/k navigate c copy v paste Esc/q quit",
186
+ children: /* @__PURE__ */ jsx(ClipboardDemo, {})
187
+ }), term);
188
+ await waitUntilExit();
189
+ } catch (_) {
190
+ _usingCtx$1.e = _;
191
+ } finally {
192
+ _usingCtx$1.d();
193
+ }
194
+ }
195
+ if (import.meta.main) await main();
196
+ //#endregion
197
+ export { ClipboardDemo, main, meta };