@zaly/tui 0.0.4 → 0.0.6

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 (156) hide show
  1. package/dist/actions-CnVzKVID.d.mts +41 -0
  2. package/dist/actions-CnVzKVID.d.mts.map +1 -0
  3. package/dist/actions-DEIKF2ts.mjs +48 -0
  4. package/dist/actions-DEIKF2ts.mjs.map +1 -0
  5. package/dist/{box-DyaByEiG.mjs → box-DepqUtuo.mjs} +2 -2
  6. package/dist/{box-DyaByEiG.mjs.map → box-DepqUtuo.mjs.map} +1 -1
  7. package/dist/{builder-D49ECBEf.mjs → builder-DTz5mppV.mjs} +2 -2
  8. package/dist/{builder-D49ECBEf.mjs.map → builder-DTz5mppV.mjs.map} +1 -1
  9. package/dist/{callbacks-CNjGNxVw.mjs → callbacks-DcMBGQEO.mjs} +2 -2
  10. package/dist/{callbacks-CNjGNxVw.mjs.map → callbacks-DcMBGQEO.mjs.map} +1 -1
  11. package/dist/{client-D6C_uczF.mjs → client-BBdtbLp4.mjs} +5 -10
  12. package/dist/client-BBdtbLp4.mjs.map +1 -0
  13. package/dist/client-cIckDgAj.mjs +2 -0
  14. package/dist/clipboard-l_TWxxTf.mjs +404 -0
  15. package/dist/clipboard-l_TWxxTf.mjs.map +1 -0
  16. package/dist/clipboard.mjs +1 -403
  17. package/dist/ctx-Bt4VlRPg.mjs +2 -0
  18. package/dist/ctx-DjJ1zSbs.mjs +43 -0
  19. package/dist/ctx-DjJ1zSbs.mjs.map +1 -0
  20. package/dist/divider-cclEAdPx.mjs +9 -0
  21. package/dist/divider-cclEAdPx.mjs.map +1 -0
  22. package/dist/files-Aw3iWpXD.d.mts +29 -0
  23. package/dist/files-Aw3iWpXD.d.mts.map +1 -0
  24. package/dist/files-BvThQpOf.mjs +42 -0
  25. package/dist/files-BvThQpOf.mjs.map +1 -0
  26. package/dist/github-Cy2hfWJ7.mjs +137 -0
  27. package/dist/github-Cy2hfWJ7.mjs.map +1 -0
  28. package/dist/github-DS00VoOj.d.mts +64 -0
  29. package/dist/github-DS00VoOj.d.mts.map +1 -0
  30. package/dist/image-BTxDPPiT.d.mts +37 -0
  31. package/dist/image-BTxDPPiT.d.mts.map +1 -0
  32. package/dist/index.mjs +6 -202
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/input-CRBuTrsL.mjs +497 -0
  35. package/dist/input-CRBuTrsL.mjs.map +1 -0
  36. package/dist/{inspect-D1d9t-ni.mjs → inspect-DE5goDzB.mjs} +2 -2
  37. package/dist/{inspect-D1d9t-ni.mjs.map → inspect-DE5goDzB.mjs.map} +1 -1
  38. package/dist/log-Djvrxqk0.mjs +130 -0
  39. package/dist/log-Djvrxqk0.mjs.map +1 -0
  40. package/dist/logger-DDrt03So.mjs +71 -0
  41. package/dist/logger-DDrt03So.mjs.map +1 -0
  42. package/dist/markdown-CTlPe5ks.mjs +124 -0
  43. package/dist/markdown-CTlPe5ks.mjs.map +1 -0
  44. package/dist/markdown.mjs +1 -1
  45. package/dist/overlay-9xNgsuuy.mjs +18 -0
  46. package/dist/overlay-9xNgsuuy.mjs.map +1 -0
  47. package/dist/{picker-ndVVt6qF.mjs → picker-cH-rc7-X.mjs} +5 -5
  48. package/dist/{picker-ndVVt6qF.mjs.map → picker-cH-rc7-X.mjs.map} +1 -1
  49. package/dist/queries-B_lOwEiE.mjs +200 -0
  50. package/dist/queries-B_lOwEiE.mjs.map +1 -0
  51. package/dist/{registry-U654j61Y.mjs → registry-w_w7gZr_.mjs} +3 -5
  52. package/dist/registry-w_w7gZr_.mjs.map +1 -0
  53. package/dist/render-F8pVXN7h.mjs +33 -0
  54. package/dist/render-F8pVXN7h.mjs.map +1 -0
  55. package/dist/renderer-Dgj_qEOA.mjs +2 -0
  56. package/dist/{renderer-CdLCkJB-.mjs → renderer-qSMVeNSV.mjs} +3 -5
  57. package/dist/{renderer-CdLCkJB-.mjs.map → renderer-qSMVeNSV.mjs.map} +1 -1
  58. package/dist/{renderer-CxL4xbkl.mjs → renderer-uMeDzF9B.mjs} +8 -7
  59. package/dist/{renderer-CxL4xbkl.mjs.map → renderer-uMeDzF9B.mjs.map} +1 -1
  60. package/dist/select-m7NE6Rwa.mjs +195 -0
  61. package/dist/select-m7NE6Rwa.mjs.map +1 -0
  62. package/dist/services/logger.mjs +1 -70
  63. package/dist/services/notifier.mjs +2 -2
  64. package/dist/services/picker.d.mts +1 -1
  65. package/dist/services/picker.mjs +6 -6
  66. package/dist/services/prompt.d.mts +1 -1
  67. package/dist/services/prompt.mjs +5 -5
  68. package/dist/shiki/server.d.mts +1 -0
  69. package/dist/shiki/server.mjs +129 -0
  70. package/dist/shiki/server.mjs.map +1 -0
  71. package/dist/{shiki-BrjVUkeh.mjs → shiki-B5NwIiot.mjs} +5 -10
  72. package/dist/shiki-B5NwIiot.mjs.map +1 -0
  73. package/dist/shiki-BK-v9CtF.mjs +12 -0
  74. package/dist/shiki-BK-v9CtF.mjs.map +1 -0
  75. package/dist/show-DR2x1YFc.mjs +85 -0
  76. package/dist/show-DR2x1YFc.mjs.map +1 -0
  77. package/dist/style.mjs +2 -2
  78. package/dist/text-9lwQeqYr.d.mts +33 -0
  79. package/dist/text-9lwQeqYr.d.mts.map +1 -0
  80. package/dist/text-DILrol9j.mjs +32 -0
  81. package/dist/text-DILrol9j.mjs.map +1 -0
  82. package/dist/text-q26V6_Sc.mjs +111 -0
  83. package/dist/text-q26V6_Sc.mjs.map +1 -0
  84. package/dist/text.d.mts +2 -33
  85. package/dist/text.mjs +1 -110
  86. package/dist/{theme.config-CU3B50HN.mjs → theme.config-BptYUq4K.mjs} +4 -4
  87. package/dist/{theme.config-CU3B50HN.mjs.map → theme.config-BptYUq4K.mjs.map} +1 -1
  88. package/dist/themes.mjs +1 -1
  89. package/dist/tree-Bo1afYhe.mjs +73 -0
  90. package/dist/tree-Bo1afYhe.mjs.map +1 -0
  91. package/dist/widget-BkMwhY2p.mjs +40 -0
  92. package/dist/widget-BkMwhY2p.mjs.map +1 -0
  93. package/dist/widget-M7jD8Rgg.d.mts +49 -0
  94. package/dist/widget-M7jD8Rgg.d.mts.map +1 -0
  95. package/dist/widgets/autocomplete.mjs +2 -2
  96. package/dist/widgets/box.mjs +1 -1
  97. package/dist/widgets/code.mjs +7 -7
  98. package/dist/widgets/completions/actions.d.mts +2 -41
  99. package/dist/widgets/completions/actions.mjs +1 -47
  100. package/dist/widgets/completions/files.d.mts +2 -29
  101. package/dist/widgets/completions/files.mjs +1 -41
  102. package/dist/widgets/completions/github.d.mts +2 -64
  103. package/dist/widgets/completions/github.mjs +1 -136
  104. package/dist/widgets/completions/index.d.mts +3 -3
  105. package/dist/widgets/completions/index.mjs +3 -3
  106. package/dist/widgets/diff.d.mts +1 -1
  107. package/dist/widgets/diff.mjs +3 -3
  108. package/dist/widgets/divider.mjs +1 -8
  109. package/dist/widgets/image.d.mts +2 -37
  110. package/dist/widgets/image.mjs +1 -1
  111. package/dist/widgets/input.mjs +1 -496
  112. package/dist/widgets/log.mjs +1 -129
  113. package/dist/widgets/markdown.d.mts +2 -2
  114. package/dist/widgets/markdown.mjs +1 -123
  115. package/dist/widgets/overlay.mjs +1 -17
  116. package/dist/widgets/picker.mjs +1 -1
  117. package/dist/widgets/select.mjs +1 -194
  118. package/dist/widgets/show.mjs +1 -84
  119. package/dist/widgets/text.mjs +1 -31
  120. package/dist/widgets/tree.mjs +1 -72
  121. package/dist/widgets/widget.d.mts +2 -49
  122. package/dist/widgets/widget.mjs +1 -39
  123. package/dist/worker-BvRm4OsW.mjs +2 -0
  124. package/dist/worker-T6SdPzUH.mjs +52 -0
  125. package/dist/worker-T6SdPzUH.mjs.map +1 -0
  126. package/package.json +7 -3
  127. package/dist/client-D6C_uczF.mjs.map +0 -1
  128. package/dist/clipboard.mjs.map +0 -1
  129. package/dist/registry-U654j61Y.mjs.map +0 -1
  130. package/dist/render-DxVLqqB9.mjs +0 -74
  131. package/dist/render-DxVLqqB9.mjs.map +0 -1
  132. package/dist/rolldown-runtime-D7D4PA-g.mjs +0 -13
  133. package/dist/services/logger.mjs.map +0 -1
  134. package/dist/shiki-BrjVUkeh.mjs.map +0 -1
  135. package/dist/text.d.mts.map +0 -1
  136. package/dist/text.mjs.map +0 -1
  137. package/dist/widgets/completions/actions.d.mts.map +0 -1
  138. package/dist/widgets/completions/actions.mjs.map +0 -1
  139. package/dist/widgets/completions/files.d.mts.map +0 -1
  140. package/dist/widgets/completions/files.mjs.map +0 -1
  141. package/dist/widgets/completions/github.d.mts.map +0 -1
  142. package/dist/widgets/completions/github.mjs.map +0 -1
  143. package/dist/widgets/divider.mjs.map +0 -1
  144. package/dist/widgets/image.d.mts.map +0 -1
  145. package/dist/widgets/input.mjs.map +0 -1
  146. package/dist/widgets/log.mjs.map +0 -1
  147. package/dist/widgets/markdown.mjs.map +0 -1
  148. package/dist/widgets/overlay.mjs.map +0 -1
  149. package/dist/widgets/select.mjs.map +0 -1
  150. package/dist/widgets/show.mjs.map +0 -1
  151. package/dist/widgets/text.mjs.map +0 -1
  152. package/dist/widgets/tree.mjs.map +0 -1
  153. package/dist/widgets/widget.d.mts.map +0 -1
  154. package/dist/widgets/widget.mjs.map +0 -1
  155. package/dist/worker-DjHuQSbY.mjs +0 -27
  156. package/dist/worker-DjHuQSbY.mjs.map +0 -1
@@ -0,0 +1,404 @@
1
+ import { safeStat } from "@zaly/shared";
2
+ import { isSSH } from "@zaly/shared/env";
3
+ import { mkdtempSync, writeFileSync } from "node:fs";
4
+ import { join } from "pathe";
5
+ import { Spawn, spawnText, spawnWithInput, which } from "@zaly/shared/process";
6
+ import { tmpdir } from "node:os";
7
+ import { platform } from "node:process";
8
+ //#region src/input/clipboard.ts
9
+ let cached;
10
+ let cacheResolved = false;
11
+ /** Detect + cache the clipboard provider for this process. Returns
12
+ * `undefined` when no provider is available. */
13
+ function getClipboard() {
14
+ if (cacheResolved) return cached;
15
+ cached = detect();
16
+ cacheResolved = true;
17
+ return cached;
18
+ }
19
+ async function readClipboard(kind) {
20
+ const p = getClipboard();
21
+ if (!p) return void 0;
22
+ try {
23
+ return await p.read(kind);
24
+ } catch {
25
+ return;
26
+ }
27
+ }
28
+ /** Reset the cached provider — mostly for tests that want to force a
29
+ * re-probe. Also useful if the environment changes (e.g. Wayland
30
+ * display started after process boot). */
31
+ function resetClipboardCache() {
32
+ cached = void 0;
33
+ cacheResolved = false;
34
+ }
35
+ /**
36
+ * Copy text to the system clipboard.
37
+ *
38
+ * Policy:
39
+ * - **SSH session** → always OSC 52. Native tools on the remote box
40
+ * would write to the remote clipboard, which isn't what the user
41
+ * wants. OSC 52 routes through the local terminal.
42
+ * - **Native tool available** → use it (fast, silent, no prompts).
43
+ * - **Neither** → OSC 52 anyway, fire-and-forget.
44
+ *
45
+ * Resolves to `true` on best-effort delivery; `false` only when we had
46
+ * nothing to try. OSC 52 writes are silent by design — the terminal
47
+ * never confirms receipt — so `true` means "we emitted" not "the
48
+ * user's clipboard definitely has it".
49
+ */
50
+ async function writeClipboardText(text) {
51
+ if (isSSH) {
52
+ writeOsc52(text);
53
+ return true;
54
+ }
55
+ const p = getClipboard();
56
+ if (p?.writeText) try {
57
+ if (await p.writeText(text)) return true;
58
+ } catch {}
59
+ writeOsc52(text);
60
+ return true;
61
+ }
62
+ /**
63
+ * Namespace export for readable call sites:
64
+ *
65
+ * ```ts
66
+ * import { clipboard } from "@zaly/tui"
67
+ *
68
+ * await clipboard.read()
69
+ * await clipboard.read("text")
70
+ * await clipboard.write("hello")
71
+ * clipboard.reset()
72
+ * ```
73
+ */
74
+ const clipboard = {
75
+ read: readClipboard,
76
+ reset: resetClipboardCache,
77
+ write: writeClipboardText
78
+ };
79
+ /** Emit an OSC 52 clipboard write. Fire-and-forget; some terminals
80
+ * ignore or prompt on this, and there's no response channel. */
81
+ function writeOsc52(text) {
82
+ const b64 = Buffer.from(text, "utf8").toString("base64");
83
+ process.stdout.write(`\x1b]52;c;${b64}\x07`);
84
+ }
85
+ function detect() {
86
+ if (platform === "darwin" && which("pbpaste")) return macos();
87
+ if (process.env.WAYLAND_DISPLAY && which("wl-paste")) return wayland();
88
+ if (process.env.DISPLAY) {
89
+ if (which("xsel")) return xsel();
90
+ if (which("xclip")) return xclip();
91
+ }
92
+ if (which("win32yank.exe")) return wsl();
93
+ if (platform === "win32") return windows();
94
+ }
95
+ function macos() {
96
+ return {
97
+ id: "pbpaste",
98
+ read: async (kind) => {
99
+ if (kind === "image") return macosImage();
100
+ if (kind === "files") return macosFiles();
101
+ if (kind === "text") return macosText();
102
+ const img = await macosImage();
103
+ if (img) return img;
104
+ const files = await macosFiles();
105
+ if (files) return files;
106
+ return macosText();
107
+ },
108
+ writeText: (text) => spawnWithInput("pbcopy", [], text)
109
+ };
110
+ }
111
+ async function macosText() {
112
+ const text = await spawnText("pbpaste", []);
113
+ return text === void 0 ? void 0 : {
114
+ kind: "text",
115
+ text
116
+ };
117
+ }
118
+ async function macosImage() {
119
+ const out = await spawnText("osascript", ["-e", `
120
+ try
121
+ set png to (the clipboard as «class PNGf»)
122
+ set b64 to do shell script "base64" with input (png as string)
123
+ return b64
124
+ on error
125
+ return ""
126
+ end try
127
+ `]);
128
+ if (!out) return void 0;
129
+ return writeTempPng(Buffer.from(out.trim(), "base64"));
130
+ }
131
+ async function macosFiles() {
132
+ const out = await spawnText("osascript", ["-e", `
133
+ try
134
+ set theClipboard to the clipboard as «class furl»
135
+ return POSIX path of theClipboard
136
+ on error
137
+ try
138
+ set theList to the clipboard as list
139
+ set posix to ""
140
+ repeat with item_ in theList
141
+ try
142
+ set posix to posix & (POSIX path of item_) & linefeed
143
+ end try
144
+ end repeat
145
+ return posix
146
+ on error
147
+ return ""
148
+ end try
149
+ end try
150
+ `]);
151
+ if (!out) return void 0;
152
+ const paths = out.split(/\r?\n/).map((s) => s.trim()).filter((s) => s !== "");
153
+ return paths.length > 0 ? {
154
+ kind: "files",
155
+ paths
156
+ } : void 0;
157
+ }
158
+ function wayland() {
159
+ return {
160
+ id: "wl-paste",
161
+ read: async (kind) => {
162
+ if (kind === "image") return waylandImage();
163
+ if (kind === "files") return waylandFiles();
164
+ if (kind === "text") return waylandText();
165
+ const types = await spawnText("wl-paste", ["--list-types"]);
166
+ if (!types) return void 0;
167
+ if (/\bimage\/png\b/.test(types)) {
168
+ const img = await waylandImage();
169
+ if (img) return img;
170
+ }
171
+ if (/\btext\/uri-list\b/.test(types)) {
172
+ const files = await waylandFiles();
173
+ if (files) return files;
174
+ }
175
+ return waylandText();
176
+ },
177
+ writeText: (text) => spawnWithInput("wl-copy", ["--type", "text/plain"], text)
178
+ };
179
+ }
180
+ async function waylandImage() {
181
+ const r = await new Spawn("wl-paste", ["--type", "image/png"]).result;
182
+ return r.code === 0 && r.stdout.length > 0 ? writeTempPng(r.stdout) : void 0;
183
+ }
184
+ async function waylandFiles() {
185
+ const paths = parseUriList(await spawnText("wl-paste", ["--type", "text/uri-list"]));
186
+ return paths.length > 0 ? {
187
+ kind: "files",
188
+ paths
189
+ } : void 0;
190
+ }
191
+ async function waylandText() {
192
+ const text = await spawnText("wl-paste", ["--no-newline"]);
193
+ return text === void 0 ? void 0 : {
194
+ kind: "text",
195
+ text
196
+ };
197
+ }
198
+ function xsel() {
199
+ const xclipFallback = which("xclip");
200
+ return {
201
+ id: xclipFallback ? "xsel+xclip" : "xsel",
202
+ read: async (kind) => {
203
+ if (kind === "text") return xselText();
204
+ if (xclipFallback) {
205
+ if (kind === "image") return xclipImage();
206
+ if (kind === "files") return xclipFiles();
207
+ const rich = await xclipRead();
208
+ if (rich && rich.kind !== "text") return rich;
209
+ }
210
+ return xselText();
211
+ },
212
+ writeText: (text) => spawnWithInput("xsel", [
213
+ "--nodetach",
214
+ "-i",
215
+ "-b"
216
+ ], text)
217
+ };
218
+ }
219
+ function xclip() {
220
+ return {
221
+ id: "xclip",
222
+ read: (kind) => {
223
+ if (kind === "image") return xclipImage();
224
+ if (kind === "files") return xclipFiles();
225
+ if (kind === "text") return xclipText();
226
+ return xclipRead();
227
+ },
228
+ writeText: (text) => spawnWithInput("xclip", [
229
+ "-quiet",
230
+ "-i",
231
+ "-selection",
232
+ "clipboard"
233
+ ], text)
234
+ };
235
+ }
236
+ async function xclipRead() {
237
+ const targets = await spawnText("xclip", [
238
+ "-selection",
239
+ "clipboard",
240
+ "-t",
241
+ "TARGETS",
242
+ "-o"
243
+ ]);
244
+ if (!targets) return void 0;
245
+ if (/\bimage\/png\b/.test(targets)) {
246
+ const img = await xclipImage();
247
+ if (img) return img;
248
+ }
249
+ if (/\btext\/uri-list\b/.test(targets)) {
250
+ const files = await xclipFiles();
251
+ if (files) return files;
252
+ }
253
+ return xclipText();
254
+ }
255
+ async function xclipImage() {
256
+ const r = await new Spawn("xclip", [
257
+ "-selection",
258
+ "clipboard",
259
+ "-t",
260
+ "image/png",
261
+ "-o"
262
+ ]).result;
263
+ return r.code === 0 && r.stdout.length > 0 ? writeTempPng(r.stdout) : void 0;
264
+ }
265
+ async function xclipFiles() {
266
+ const paths = parseUriList(await spawnText("xclip", [
267
+ "-selection",
268
+ "clipboard",
269
+ "-t",
270
+ "text/uri-list",
271
+ "-o"
272
+ ]));
273
+ return paths.length > 0 ? {
274
+ kind: "files",
275
+ paths
276
+ } : void 0;
277
+ }
278
+ async function xclipText() {
279
+ const text = await spawnText("xclip", [
280
+ "-o",
281
+ "-selection",
282
+ "clipboard"
283
+ ]);
284
+ return text === void 0 ? void 0 : {
285
+ kind: "text",
286
+ text
287
+ };
288
+ }
289
+ async function xselText() {
290
+ const text = await spawnText("xsel", ["-o", "-b"]);
291
+ return text === void 0 ? void 0 : {
292
+ kind: "text",
293
+ text
294
+ };
295
+ }
296
+ function wsl() {
297
+ return {
298
+ id: "win32yank",
299
+ read: async (kind) => {
300
+ if (kind === "image" || kind === "files") return void 0;
301
+ const text = await spawnText("win32yank.exe", ["-o", "--lf"]);
302
+ return text === void 0 ? void 0 : {
303
+ kind: "text",
304
+ text
305
+ };
306
+ },
307
+ writeText: (text) => spawnWithInput("win32yank.exe", ["-i", "--crlf"], text)
308
+ };
309
+ }
310
+ function windows() {
311
+ return {
312
+ id: "powershell",
313
+ read: async (kind) => {
314
+ if (kind === "image") return windowsImage();
315
+ if (kind === "files") return windowsFiles();
316
+ if (kind === "text") return windowsText();
317
+ const img = await windowsImage();
318
+ if (img) return img;
319
+ const files = await windowsFiles();
320
+ if (files) return files;
321
+ return windowsText();
322
+ },
323
+ writeText: (text) => spawnWithInput("clip", [], text)
324
+ };
325
+ }
326
+ async function windowsText() {
327
+ const text = await spawnText("powershell", [
328
+ "-NoProfile",
329
+ "-NoLogo",
330
+ "-Command",
331
+ "Get-Clipboard"
332
+ ]);
333
+ return text === void 0 ? void 0 : {
334
+ kind: "text",
335
+ text
336
+ };
337
+ }
338
+ async function windowsImage() {
339
+ const tmp = writeTempPath("zaly-clip-", ".png");
340
+ await spawnText("powershell", [
341
+ "-NoProfile",
342
+ "-NoLogo",
343
+ "-Command",
344
+ [
345
+ "Add-Type -AssemblyName System.Windows.Forms",
346
+ "$img = [System.Windows.Forms.Clipboard]::GetImage()",
347
+ `if ($img) { $img.Save('${tmp.replace(/\\/g, String.raw`\\`)}') }`
348
+ ].join("; ")
349
+ ]);
350
+ if ((safeStat(tmp)?.size ?? 0) > 0) return {
351
+ kind: "image",
352
+ path: tmp,
353
+ type: "image/png"
354
+ };
355
+ }
356
+ async function windowsFiles() {
357
+ const out = await spawnText("powershell", [
358
+ "-NoProfile",
359
+ "-NoLogo",
360
+ "-Command",
361
+ "Get-Clipboard -Format FileDropList | ForEach-Object { $_.FullName }"
362
+ ]);
363
+ if (!out) return void 0;
364
+ const paths = out.split(/\r?\n/).map((s) => s.trim()).filter((s) => s !== "");
365
+ return paths.length > 0 ? {
366
+ kind: "files",
367
+ paths
368
+ } : void 0;
369
+ }
370
+ function writeTempPng(bytes) {
371
+ const path = writeTempPath("zaly-clip-", ".png");
372
+ writeFileSync(path, bytes);
373
+ return {
374
+ kind: "image",
375
+ path,
376
+ type: "image/png"
377
+ };
378
+ }
379
+ /** Parse a `text/uri-list` blob (RFC 2483): `file://…\r\n` lines, skip
380
+ * blanks and comment lines (`#…`), decode percent-encoding. Returns
381
+ * absolute filesystem paths. Non-`file://` URIs are dropped — we
382
+ * can't hand a remote URL off as an attachment path. */
383
+ function parseUriList(raw) {
384
+ if (!raw) return [];
385
+ const out = [];
386
+ for (const line of raw.split(/\r?\n/)) {
387
+ const s = line.trim();
388
+ if (s === "" || s.startsWith("#")) continue;
389
+ if (!s.startsWith("file://")) continue;
390
+ try {
391
+ let path = decodeURIComponent(s.slice(7));
392
+ if (/^\/[A-Za-z]:\//.test(path)) path = path.slice(1);
393
+ out.push(path);
394
+ } catch {}
395
+ }
396
+ return out;
397
+ }
398
+ function writeTempPath(prefix, ext) {
399
+ return join(mkdtempSync(join(tmpdir(), prefix)), `clip${ext}`);
400
+ }
401
+ //#endregion
402
+ export { clipboard as t };
403
+
404
+ //# sourceMappingURL=clipboard-l_TWxxTf.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clipboard-l_TWxxTf.mjs","names":[],"sources":["../src/input/clipboard.ts"],"sourcesContent":["import { safeStat } from \"@zaly/shared\"\nimport { isSSH } from \"@zaly/shared/env\"\nimport { Spawn, spawnText, spawnWithInput, which } from \"@zaly/shared/process\"\nimport { mkdtempSync, writeFileSync } from \"node:fs\"\nimport { tmpdir } from \"node:os\"\nimport { platform } from \"node:process\"\nimport { join } from \"pathe\"\n\n/**\n * Read text or image content from the system clipboard.\n *\n * Agent CLIs need this to make `ctrl-v` \"just work\" — most terminals\n * don't forward clipboard paste events (they only forward typed keys),\n * so the app has to query the OS clipboard itself via the platform's\n * native tool. The detection order mirrors Neovim's clipboard provider:\n *\n * 1. macOS → `pbpaste` + `osascript` (for images)\n * 2. Wayland → `wl-paste`\n * 3. X11 (xsel) → `xsel`\n * 4. X11 (xclip) → `xclip`\n * 5. WSL → `win32yank.exe`\n * 6. Windows → PowerShell `Get-Clipboard`\n *\n * The chosen provider is cached per process. Spawn primitives live in\n * `@zaly/shared/process` — this file is just glue plus the per-platform\n * AppleScript/PowerShell snippets.\n */\n\n// ---- types -----------------------------------------------------------\n\n/** Image bytes on the clipboard, already written to a temp PNG. */\nexport interface ClipboardImage {\n kind: \"image\"\n /** Absolute path to a temporary PNG file. Caller takes ownership. */\n path: string\n /** MIME type. PNG only for now; kept for future formats. */\n type: \"image/png\"\n}\n\n/** One or more file references on the clipboard — what you get when\n * the user copies a file in their file manager and pastes. */\nexport interface ClipboardFiles {\n kind: \"files\"\n /** Absolute filesystem paths. */\n paths: string[]\n}\n\n/** Plain text on the clipboard — the common case. */\nexport interface ClipboardText {\n kind: \"text\"\n text: string\n}\n\n/** Anything the clipboard can hold that this library surfaces. */\nexport type ClipboardContent = ClipboardImage | ClipboardFiles | ClipboardText\n\n/** One of the content kinds `ClipboardContent` can take. Derived from\n * the union so adding a new variant doesn't require updating this\n * alias separately. */\nexport type ClipboardKind = ClipboardContent[\"kind\"]\n\n/** Internal provider contract. Each backend owns its own \"probe types,\n * pick best, fetch once\" logic — on platforms like Wayland and X11\n * that can enumerate available types, this avoids doing three or four\n * probe round-trips for every paste.\n *\n * `read(kind?)` takes an optional hint: when specified, the backend\n * can skip type enumeration and fetch that kind directly (fast path\n * for callers that already know what they want). When omitted, the\n * backend returns the richest available content. `writeText` is\n * optional since not every backend supports writes. */\ninterface Provider {\n readonly id: string\n read: (kind?: ClipboardKind) => Promise<ClipboardContent | undefined>\n writeText?: (text: string) => Promise<boolean>\n}\n\n// ---- public API ------------------------------------------------------\n\nlet cached: Provider | undefined\nlet cacheResolved = false\n\n/** Detect + cache the clipboard provider for this process. Returns\n * `undefined` when no provider is available. */\nfunction getClipboard(): Provider | undefined {\n if (cacheResolved) return cached\n cached = detect()\n cacheResolved = true\n return cached\n}\n\n/**\n * Read the system clipboard, returning the richest content available.\n *\n * Priority order (decided by each backend internally):\n * 1. **image** — raw image bytes on the clipboard (e.g. a screenshot\n * from `cmd-shift-4`, or an image copied from a web page).\n * 2. **files** — file URIs (e.g. the user copied a PDF / video in\n * their file manager).\n * 3. **text** — plain text.\n *\n * Resolves to `undefined` when the clipboard is empty, no provider is\n * available, or every read fails. Never throws — clipboard access is\n * best-effort.\n */\nasync function readClipboard(): Promise<ClipboardContent | undefined>\nasync function readClipboard(kind: \"text\"): Promise<ClipboardText | undefined>\nasync function readClipboard(kind: \"image\"): Promise<ClipboardImage | undefined>\nasync function readClipboard(kind: \"files\"): Promise<ClipboardFiles | undefined>\nasync function readClipboard(kind?: ClipboardKind): Promise<ClipboardContent | undefined> {\n const p = getClipboard()\n if (!p) return undefined\n try {\n return await p.read(kind)\n } catch {\n return undefined\n }\n}\n\n/** Reset the cached provider — mostly for tests that want to force a\n * re-probe. Also useful if the environment changes (e.g. Wayland\n * display started after process boot). */\nfunction resetClipboardCache(): void {\n cached = undefined\n cacheResolved = false\n}\n\n/**\n * Copy text to the system clipboard.\n *\n * Policy:\n * - **SSH session** → always OSC 52. Native tools on the remote box\n * would write to the remote clipboard, which isn't what the user\n * wants. OSC 52 routes through the local terminal.\n * - **Native tool available** → use it (fast, silent, no prompts).\n * - **Neither** → OSC 52 anyway, fire-and-forget.\n *\n * Resolves to `true` on best-effort delivery; `false` only when we had\n * nothing to try. OSC 52 writes are silent by design — the terminal\n * never confirms receipt — so `true` means \"we emitted\" not \"the\n * user's clipboard definitely has it\".\n */\nasync function writeClipboardText(text: string): Promise<boolean> {\n if (isSSH) {\n writeOsc52(text)\n return true\n }\n const p = getClipboard()\n if (p?.writeText) {\n try {\n if (await p.writeText(text)) return true\n } catch {\n /* fall through to OSC 52 */\n }\n }\n writeOsc52(text)\n return true\n}\n\n/**\n * Namespace export for readable call sites:\n *\n * ```ts\n * import { clipboard } from \"@zaly/tui\"\n *\n * await clipboard.read()\n * await clipboard.read(\"text\")\n * await clipboard.write(\"hello\")\n * clipboard.reset()\n * ```\n */\nexport const clipboard = {\n read: readClipboard,\n reset: resetClipboardCache,\n write: writeClipboardText,\n}\n\n/** Emit an OSC 52 clipboard write. Fire-and-forget; some terminals\n * ignore or prompt on this, and there's no response channel. */\nfunction writeOsc52(text: string): void {\n const b64 = Buffer.from(text, \"utf8\").toString(\"base64\")\n // `\\x1b]52;c;<base64>\\x07` — `c` targets the system clipboard.\n process.stdout.write(`\\x1b]52;c;${b64}\\x07`)\n}\n\n// ---- detection -------------------------------------------------------\n\nfunction detect(): Provider | undefined {\n if (platform === \"darwin\" && which(\"pbpaste\")) return macos()\n\n // Wayland before X11 — XWayland means both vars can be set on a\n // Wayland session, and wl-paste is the right tool there.\n if (process.env.WAYLAND_DISPLAY && which(\"wl-paste\")) return wayland()\n\n // X11: prefer xsel (nicer selection handling, per Neovim), then xclip.\n if (process.env.DISPLAY) {\n if (which(\"xsel\")) return xsel()\n if (which(\"xclip\")) return xclip()\n }\n\n // WSL exposes Windows' clipboard via win32yank if the user installed it.\n if (which(\"win32yank.exe\")) return wsl()\n\n // Plain Windows: PowerShell is always present on supported versions.\n if (platform === \"win32\") return windows()\n\n return undefined\n}\n\n// ---- backends --------------------------------------------------------\n\nfunction macos(): Provider {\n return {\n id: \"pbpaste\",\n read: async (kind) => {\n // macOS has no cheap \"list types\" call, so when no kind is\n // specified we probe in richness order: image → files → text.\n // Each AppleScript is wrapped in `try…on error` so a miss is\n // an empty string, not a spawn failure.\n if (kind === \"image\") return macosImage()\n if (kind === \"files\") return macosFiles()\n if (kind === \"text\") return macosText()\n const img = await macosImage()\n if (img) return img\n const files = await macosFiles()\n if (files) return files\n return macosText()\n },\n writeText: (text) => spawnWithInput(\"pbcopy\", [], text),\n }\n}\n\nasync function macosText(): Promise<ClipboardText | undefined> {\n const text = await spawnText(\"pbpaste\", [])\n return text === undefined ? undefined : { kind: \"text\", text }\n}\n\nasync function macosImage(): Promise<ClipboardImage | undefined> {\n const script = `\n try\n set png to (the clipboard as «class PNGf»)\n set b64 to do shell script \"base64\" with input (png as string)\n return b64\n on error\n return \"\"\n end try\n `\n const out = await spawnText(\"osascript\", [\"-e\", script])\n if (!out) return undefined\n return writeTempPng(Buffer.from(out.trim(), \"base64\"))\n}\n\nasync function macosFiles(): Promise<ClipboardFiles | undefined> {\n const script = `\n try\n set theClipboard to the clipboard as «class furl»\n return POSIX path of theClipboard\n on error\n try\n set theList to the clipboard as list\n set posix to \"\"\n repeat with item_ in theList\n try\n set posix to posix & (POSIX path of item_) & linefeed\n end try\n end repeat\n return posix\n on error\n return \"\"\n end try\n end try\n `\n const out = await spawnText(\"osascript\", [\"-e\", script])\n if (!out) return undefined\n const paths = out\n .split(/\\r?\\n/)\n .map((s) => s.trim())\n .filter((s) => s !== \"\")\n return paths.length > 0 ? { kind: \"files\", paths } : undefined\n}\n\nfunction wayland(): Provider {\n return {\n id: \"wl-paste\",\n read: async (kind) => {\n if (kind === \"image\") return waylandImage()\n if (kind === \"files\") return waylandFiles()\n if (kind === \"text\") return waylandText()\n // Richest-first: one `--list-types` call decides everything.\n const types = await spawnText(\"wl-paste\", [\"--list-types\"])\n if (!types) return undefined\n if (/\\bimage\\/png\\b/.test(types)) {\n const img = await waylandImage()\n if (img) return img\n }\n if (/\\btext\\/uri-list\\b/.test(types)) {\n const files = await waylandFiles()\n if (files) return files\n }\n return waylandText()\n },\n writeText: (text) => spawnWithInput(\"wl-copy\", [\"--type\", \"text/plain\"], text),\n }\n}\n\nasync function waylandImage(): Promise<ClipboardImage | undefined> {\n const r = await new Spawn(\"wl-paste\", [\"--type\", \"image/png\"]).result\n return r.code === 0 && r.stdout.length > 0 ? writeTempPng(r.stdout) : undefined\n}\n\nasync function waylandFiles(): Promise<ClipboardFiles | undefined> {\n const paths = parseUriList(await spawnText(\"wl-paste\", [\"--type\", \"text/uri-list\"]))\n return paths.length > 0 ? { kind: \"files\", paths } : undefined\n}\n\nasync function waylandText(): Promise<ClipboardText | undefined> {\n const text = await spawnText(\"wl-paste\", [\"--no-newline\"])\n return text === undefined ? undefined : { kind: \"text\", text }\n}\n\nfunction xsel(): Provider {\n // xsel doesn't support MIME-typed targets (no image or file-list\n // reads). When xclip is also installed, delegate non-text reads to\n // it and keep xsel for text only.\n const xclipFallback = which(\"xclip\")\n return {\n id: xclipFallback ? \"xsel+xclip\" : \"xsel\",\n read: async (kind) => {\n if (kind === \"text\") return xselText()\n if (xclipFallback) {\n if (kind === \"image\") return xclipImage()\n if (kind === \"files\") return xclipFiles()\n const rich = await xclipRead()\n if (rich && rich.kind !== \"text\") return rich\n }\n return xselText()\n },\n writeText: (text) => spawnWithInput(\"xsel\", [\"--nodetach\", \"-i\", \"-b\"], text),\n }\n}\n\nfunction xclip(): Provider {\n return {\n id: \"xclip\",\n read: (kind) => {\n if (kind === \"image\") return xclipImage()\n if (kind === \"files\") return xclipFiles()\n if (kind === \"text\") return xclipText()\n return xclipRead()\n },\n writeText: (text) => spawnWithInput(\"xclip\", [\"-quiet\", \"-i\", \"-selection\", \"clipboard\"], text),\n }\n}\n\nasync function xclipRead(): Promise<ClipboardContent | undefined> {\n // One TARGETS call covers the whole decision tree.\n const targets = await spawnText(\"xclip\", [\"-selection\", \"clipboard\", \"-t\", \"TARGETS\", \"-o\"])\n if (!targets) return undefined\n if (/\\bimage\\/png\\b/.test(targets)) {\n const img = await xclipImage()\n if (img) return img\n }\n if (/\\btext\\/uri-list\\b/.test(targets)) {\n const files = await xclipFiles()\n if (files) return files\n }\n return xclipText()\n}\n\nasync function xclipImage(): Promise<ClipboardImage | undefined> {\n const r = await new Spawn(\"xclip\", [\"-selection\", \"clipboard\", \"-t\", \"image/png\", \"-o\"]).result\n return r.code === 0 && r.stdout.length > 0 ? writeTempPng(r.stdout) : undefined\n}\n\nasync function xclipFiles(): Promise<ClipboardFiles | undefined> {\n const paths = parseUriList(\n await spawnText(\"xclip\", [\"-selection\", \"clipboard\", \"-t\", \"text/uri-list\", \"-o\"])\n )\n return paths.length > 0 ? { kind: \"files\", paths } : undefined\n}\n\nasync function xclipText(): Promise<ClipboardText | undefined> {\n const text = await spawnText(\"xclip\", [\"-o\", \"-selection\", \"clipboard\"])\n return text === undefined ? undefined : { kind: \"text\", text }\n}\n\nasync function xselText(): Promise<ClipboardText | undefined> {\n const text = await spawnText(\"xsel\", [\"-o\", \"-b\"])\n return text === undefined ? undefined : { kind: \"text\", text }\n}\n\nfunction wsl(): Provider {\n // win32yank is text-only; image / file paste from WSL would need a\n // different shim, so we only expose text here. `kind === \"image\"`\n // or `\"files\"` always resolves to undefined.\n return {\n id: \"win32yank\",\n read: async (kind) => {\n if (kind === \"image\" || kind === \"files\") return undefined\n const text = await spawnText(\"win32yank.exe\", [\"-o\", \"--lf\"])\n return text === undefined ? undefined : { kind: \"text\", text }\n },\n writeText: (text) => spawnWithInput(\"win32yank.exe\", [\"-i\", \"--crlf\"], text),\n }\n}\n\nfunction windows(): Provider {\n return {\n id: \"powershell\",\n read: async (kind) => {\n if (kind === \"image\") return windowsImage()\n if (kind === \"files\") return windowsFiles()\n if (kind === \"text\") return windowsText()\n const img = await windowsImage()\n if (img) return img\n const files = await windowsFiles()\n if (files) return files\n return windowsText()\n },\n writeText: (text) => spawnWithInput(\"clip\", [], text),\n }\n}\n\nasync function windowsText(): Promise<ClipboardText | undefined> {\n const text = await spawnText(\"powershell\", [\"-NoProfile\", \"-NoLogo\", \"-Command\", \"Get-Clipboard\"])\n return text === undefined ? undefined : { kind: \"text\", text }\n}\n\nasync function windowsImage(): Promise<ClipboardImage | undefined> {\n // PowerShell: fetch image from clipboard, save as PNG to a temp path.\n // Nothing on clipboard → the `if` skips and the file stays empty.\n const tmp = writeTempPath(\"zaly-clip-\", \".png\")\n const script = [\n \"Add-Type -AssemblyName System.Windows.Forms\",\n \"$img = [System.Windows.Forms.Clipboard]::GetImage()\",\n `if ($img) { $img.Save('${tmp.replace(/\\\\/g, String.raw`\\\\`)}') }`,\n ].join(\"; \")\n await spawnText(\"powershell\", [\"-NoProfile\", \"-NoLogo\", \"-Command\", script])\n if ((safeStat(tmp)?.size ?? 0) > 0) return { kind: \"image\", path: tmp, type: \"image/png\" }\n return undefined\n}\n\nasync function windowsFiles(): Promise<ClipboardFiles | undefined> {\n const out = await spawnText(\"powershell\", [\n \"-NoProfile\",\n \"-NoLogo\",\n \"-Command\",\n \"Get-Clipboard -Format FileDropList | ForEach-Object { $_.FullName }\",\n ])\n if (!out) return undefined\n const paths = out\n .split(/\\r?\\n/)\n .map((s) => s.trim())\n .filter((s) => s !== \"\")\n return paths.length > 0 ? { kind: \"files\", paths } : undefined\n}\n\n// ---- temp files + URI list parsing ----------------------------------\n\nfunction writeTempPng(bytes: Buffer): ClipboardImage {\n const path = writeTempPath(\"zaly-clip-\", \".png\")\n writeFileSync(path, bytes)\n return { kind: \"image\", path, type: \"image/png\" }\n}\n\n/** Parse a `text/uri-list` blob (RFC 2483): `file://…\\r\\n` lines, skip\n * blanks and comment lines (`#…`), decode percent-encoding. Returns\n * absolute filesystem paths. Non-`file://` URIs are dropped — we\n * can't hand a remote URL off as an attachment path. */\nfunction parseUriList(raw: string | undefined): string[] {\n if (!raw) return []\n const out: string[] = []\n for (const line of raw.split(/\\r?\\n/)) {\n const s = line.trim()\n if (s === \"\" || s.startsWith(\"#\")) continue\n if (!s.startsWith(\"file://\")) continue\n try {\n let path = decodeURIComponent(s.slice(\"file://\".length))\n // `file:///C:/foo` → `/C:/foo` after the slice. Strip the leading\n // slash so we end up with a real Windows path.\n if (/^\\/[A-Za-z]:\\//.test(path)) path = path.slice(1)\n out.push(path)\n } catch {\n /* malformed URI — skip */\n }\n }\n return out\n}\n\nfunction writeTempPath(prefix: string, ext: string): string {\n const dir = mkdtempSync(join(tmpdir(), prefix))\n return join(dir, `clip${ext}`)\n}\n"],"mappings":";;;;;;;;AA+EA,IAAI;AACJ,IAAI,gBAAgB;;;AAIpB,SAAS,eAAqC;CAC5C,IAAI,eAAe,OAAO;CAC1B,SAAS,OAAO;CAChB,gBAAgB;CAChB,OAAO;AACT;AAoBA,eAAe,cAAc,MAA6D;CACxF,MAAM,IAAI,aAAa;CACvB,IAAI,CAAC,GAAG,OAAO,KAAA;CACf,IAAI;EACF,OAAO,MAAM,EAAE,KAAK,IAAI;C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