silvery 0.19.2 → 0.21.1

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 (172) hide show
  1. package/README.md +9 -4
  2. package/dist/Text-BRf-59j2.mjs +237 -0
  3. package/dist/Text-BRf-59j2.mjs.map +1 -0
  4. package/dist/ag-BeFC4S2N.mjs +8727 -0
  5. package/dist/ag-BeFC4S2N.mjs.map +1 -0
  6. package/dist/{animation-Cn64yepo.mjs → animation-N8MFybTk.mjs} +2 -2
  7. package/dist/animation-N8MFybTk.mjs.map +1 -0
  8. package/dist/{ansi-CLOitHKx.mjs → ansi-C6Qs1Wn2.mjs} +1 -1
  9. package/dist/{ansi-CLOitHKx.mjs.map → ansi-C6Qs1Wn2.mjs.map} +1 -1
  10. package/dist/{ansi-Cc33mW54.d.mts → ansi-CBkam1ty.d.mts} +1 -1
  11. package/dist/{ansi-Cc33mW54.d.mts.map → ansi-CBkam1ty.d.mts.map} +1 -1
  12. package/dist/ansi-OYRLxxZQ.mjs +10669 -0
  13. package/dist/ansi-OYRLxxZQ.mjs.map +1 -0
  14. package/dist/bound-term-BumfuXXW.d.mts +4902 -0
  15. package/dist/bound-term-BumfuXXW.d.mts.map +1 -0
  16. package/dist/{chunk-Vs_PY4HZ.mjs → chunk-hT5z_Zn9.mjs} +1 -3
  17. package/dist/cli-DG6zsfsS.mjs +4 -0
  18. package/dist/context-BU5LkkIy.mjs.map +1 -1
  19. package/dist/{devtools-DxkSLXDA.mjs → devtools-9zfhpFyG.mjs} +3 -3
  20. package/dist/{devtools-DxkSLXDA.mjs.map → devtools-9zfhpFyG.mjs.map} +1 -1
  21. package/dist/devtools-nmPUmYU_.mjs +2 -0
  22. package/dist/easing-B0oZKDki.d.mts +24 -0
  23. package/dist/easing-B0oZKDki.d.mts.map +1 -0
  24. package/dist/{eta-Bb3RH3wh.mjs → eta-DGOuC8yU.mjs} +5 -1
  25. package/dist/{eta-Bb3RH3wh.mjs.map → eta-DGOuC8yU.mjs.map} +1 -1
  26. package/dist/flexily-zero-adapter-CEJOcbNp.mjs +306 -0
  27. package/dist/flexily-zero-adapter-CEJOcbNp.mjs.map +1 -0
  28. package/dist/{flexily-zero-adapter-CMxXhdOL.mjs → flexily-zero-adapter-D6hcFgrH.mjs} +1 -1
  29. package/dist/image-1nRyKa60.mjs +5960 -0
  30. package/dist/image-1nRyKa60.mjs.map +1 -0
  31. package/dist/{index-D3saHouR.d.mts → index-2E1jYgak.d.mts} +1057 -1133
  32. package/dist/index-2E1jYgak.d.mts.map +1 -0
  33. package/dist/index-Bi4Jdz5g.d.mts +453 -0
  34. package/dist/index-Bi4Jdz5g.d.mts.map +1 -0
  35. package/dist/index-Dg1YaeJb.d.mts +336 -0
  36. package/dist/index-Dg1YaeJb.d.mts.map +1 -0
  37. package/dist/{index-BXslOebb.d.mts → index-DnuadDNL.d.mts} +5750 -4158
  38. package/dist/index-DnuadDNL.d.mts.map +1 -0
  39. package/dist/index.d.mts +8 -5
  40. package/dist/index.d.mts.map +1 -1
  41. package/dist/index.mjs +16 -12
  42. package/dist/index.mjs.map +1 -1
  43. package/dist/layout-engine-Ca_nbtfL.mjs +67 -0
  44. package/dist/layout-engine-Ca_nbtfL.mjs.map +1 -0
  45. package/dist/{layout-engine-B6Cdz1yZ.mjs → layout-engine-CgsoBRIn.mjs} +1 -1
  46. package/dist/layout-signals-Dch2EiCy.mjs +1111 -0
  47. package/dist/layout-signals-Dch2EiCy.mjs.map +1 -0
  48. package/dist/mouse-events-hnbJZRwK.mjs +1071 -0
  49. package/dist/mouse-events-hnbJZRwK.mjs.map +1 -0
  50. package/dist/{multi-progress-DAQC7eap.d.mts → multi-progress-Bg4ngK80.d.mts} +2 -2
  51. package/dist/{multi-progress-DAQC7eap.d.mts.map → multi-progress-Bg4ngK80.d.mts.map} +1 -1
  52. package/dist/{multi-progress-Bq9Oi_WI.mjs → multi-progress-CaXTuL9G.mjs} +3 -3
  53. package/dist/{multi-progress-Bq9Oi_WI.mjs.map → multi-progress-CaXTuL9G.mjs.map} +1 -1
  54. package/dist/{node-BeWlnCPY.mjs → node-BiFu8I9Y.mjs} +4 -4
  55. package/dist/node-BiFu8I9Y.mjs.map +1 -0
  56. package/dist/progress-B_UPy6zk.mjs +675 -0
  57. package/dist/progress-B_UPy6zk.mjs.map +1 -0
  58. package/dist/{progress-bar-CXE5Qfkd.mjs → progress-bar-DmIMPdL0.mjs} +4 -4
  59. package/dist/{progress-bar-CXE5Qfkd.mjs.map → progress-bar-DmIMPdL0.mjs.map} +1 -1
  60. package/dist/reconciler-NBDSEm8k.mjs +2178 -0
  61. package/dist/reconciler-NBDSEm8k.mjs.map +1 -0
  62. package/dist/render-string-B4h4SmK7.mjs +211 -0
  63. package/dist/render-string-B4h4SmK7.mjs.map +1 -0
  64. package/dist/{render-string-CDCeYkS3.mjs → render-string-BntLj7Xq.mjs} +1 -1
  65. package/dist/runtime.d.mts +3 -2
  66. package/dist/runtime.mjs +3 -3
  67. package/dist/{src-B5GjfG7g.mjs → schemes-DYt2ushj.mjs} +23 -1812
  68. package/dist/schemes-DYt2ushj.mjs.map +1 -0
  69. package/dist/{spinner-CGo34vyR.d.mts → spinner-CLgzJ_QF.d.mts} +2 -2
  70. package/dist/{spinner-CGo34vyR.d.mts.map → spinner-CLgzJ_QF.d.mts.map} +1 -1
  71. package/dist/{spinner-CeOmcuw_.mjs → spinner-Py8_-hn9.mjs} +23 -8
  72. package/dist/spinner-Py8_-hn9.mjs.map +1 -0
  73. package/dist/src-B9S_woYc.mjs +25024 -0
  74. package/dist/src-B9S_woYc.mjs.map +1 -0
  75. package/dist/src-CbhWmUnF.mjs +3928 -0
  76. package/dist/src-CbhWmUnF.mjs.map +1 -0
  77. package/dist/src-Dvq-s8iD.mjs +939 -0
  78. package/dist/src-Dvq-s8iD.mjs.map +1 -0
  79. package/dist/src-Oe6x5PrS.mjs +4621 -0
  80. package/dist/src-Oe6x5PrS.mjs.map +1 -0
  81. package/dist/{types-Bk2yw9Qj.mjs → src-WeA_J4BV.mjs} +34 -94
  82. package/dist/src-WeA_J4BV.mjs.map +1 -0
  83. package/dist/steps-DYrzCUCK.d.mts +202 -0
  84. package/dist/steps-DYrzCUCK.d.mts.map +1 -0
  85. package/dist/svg-DhxQkz-O.mjs +255 -0
  86. package/dist/svg-DhxQkz-O.mjs.map +1 -0
  87. package/dist/svg-Hk7lIl4F.d.mts +82 -0
  88. package/dist/svg-Hk7lIl4F.d.mts.map +1 -0
  89. package/dist/term.d.mts +3 -0
  90. package/dist/term.mjs +4 -0
  91. package/dist/theme.d.mts +95 -2
  92. package/dist/theme.d.mts.map +1 -0
  93. package/dist/theme.mjs +4 -3
  94. package/dist/{types-BH_v3iMT.d.mts → types-Bx-XZNbE.d.mts} +2 -15
  95. package/dist/types-Bx-XZNbE.d.mts.map +1 -0
  96. package/dist/ui/animation.d.mts +2 -1
  97. package/dist/ui/animation.mjs +1 -1
  98. package/dist/ui/ansi.d.mts +1 -1
  99. package/dist/ui/ansi.mjs +1 -1
  100. package/dist/ui/cli.d.mts +3 -3
  101. package/dist/ui/cli.mjs +5 -5
  102. package/dist/ui/display.d.mts +1 -1
  103. package/dist/ui/display.mjs.map +1 -1
  104. package/dist/ui/image.d.mts +2 -2
  105. package/dist/ui/image.mjs +2 -2
  106. package/dist/ui/input.d.mts +1 -1
  107. package/dist/ui/input.mjs.map +1 -1
  108. package/dist/ui/progress.d.mts +5 -249
  109. package/dist/ui/progress.mjs +5 -858
  110. package/dist/ui/react.d.mts +1 -1
  111. package/dist/ui/react.mjs +2 -2
  112. package/dist/ui/react.mjs.map +1 -1
  113. package/dist/ui/recording-chrome-react.d.mts +21 -0
  114. package/dist/ui/recording-chrome-react.d.mts.map +1 -0
  115. package/dist/ui/recording-chrome-react.mjs +105 -0
  116. package/dist/ui/recording-chrome-react.mjs.map +1 -0
  117. package/dist/ui/recording-chrome.d.mts +2 -0
  118. package/dist/ui/recording-chrome.mjs +2 -0
  119. package/dist/ui/utils.mjs +1 -1
  120. package/dist/ui/wrappers.d.mts +3 -3
  121. package/dist/ui/wrappers.mjs +2 -2
  122. package/dist/ui.d.mts +7 -6
  123. package/dist/ui.mjs +8 -7
  124. package/dist/{useLatest-Bg2x4bfP.d.mts → useLatest-DC8i7guK.d.mts} +5 -25
  125. package/dist/useLatest-DC8i7guK.d.mts.map +1 -0
  126. package/dist/useLayout-BKsQl2Or.mjs +424 -0
  127. package/dist/useLayout-BKsQl2Or.mjs.map +1 -0
  128. package/dist/{with-text-input-CRfoiFFG.d.mts → with-text-input-DG4f7JII.d.mts} +4 -55
  129. package/dist/with-text-input-DG4f7JII.d.mts.map +1 -0
  130. package/dist/wrapper-D7gNSsgf.mjs +3589 -0
  131. package/dist/wrapper-D7gNSsgf.mjs.map +1 -0
  132. package/dist/{wrappers-UTADQkSY.mjs → wrappers-CypAzrMO.mjs} +19 -161
  133. package/dist/wrappers-CypAzrMO.mjs.map +1 -0
  134. package/dist/yoga-adapter-1ex8r0ws.mjs +2 -0
  135. package/dist/{yoga-adapter-8oRGRw8V.mjs → yoga-adapter-SsEIqMc1.mjs} +28 -2
  136. package/dist/yoga-adapter-SsEIqMc1.mjs.map +1 -0
  137. package/package.json +63 -12
  138. package/dist/animation-Cn64yepo.mjs.map +0 -1
  139. package/dist/cli-BKp0YtBD.mjs +0 -4
  140. package/dist/devtools-9QY4teqI.mjs +0 -2
  141. package/dist/flexily-zero-adapter-BlQa46nr.mjs +0 -3385
  142. package/dist/flexily-zero-adapter-BlQa46nr.mjs.map +0 -1
  143. package/dist/image-CTII5QWI.mjs +0 -477
  144. package/dist/image-CTII5QWI.mjs.map +0 -1
  145. package/dist/index-BXslOebb.d.mts.map +0 -1
  146. package/dist/index-BnA7mNpo.d.mts +0 -175
  147. package/dist/index-BnA7mNpo.d.mts.map +0 -1
  148. package/dist/index-D3saHouR.d.mts.map +0 -1
  149. package/dist/layout-engine-ClUgv6jB.mjs +0 -50
  150. package/dist/layout-engine-ClUgv6jB.mjs.map +0 -1
  151. package/dist/node-BeWlnCPY.mjs.map +0 -1
  152. package/dist/reconciler-Cwgm8hRR.mjs +0 -8459
  153. package/dist/reconciler-Cwgm8hRR.mjs.map +0 -1
  154. package/dist/render-string-Darrg7ku.mjs +0 -5529
  155. package/dist/render-string-Darrg7ku.mjs.map +0 -1
  156. package/dist/spinner-CeOmcuw_.mjs.map +0 -1
  157. package/dist/src-B5GjfG7g.mjs.map +0 -1
  158. package/dist/src-CChwjk0Z.mjs +0 -738
  159. package/dist/src-CChwjk0Z.mjs.map +0 -1
  160. package/dist/src-CF-6UN01.mjs +0 -19434
  161. package/dist/src-CF-6UN01.mjs.map +0 -1
  162. package/dist/src-NCKb8kE5.mjs +0 -2660
  163. package/dist/src-NCKb8kE5.mjs.map +0 -1
  164. package/dist/types-BH_v3iMT.d.mts.map +0 -1
  165. package/dist/types-Bk2yw9Qj.mjs.map +0 -1
  166. package/dist/ui/progress.d.mts.map +0 -1
  167. package/dist/ui/progress.mjs.map +0 -1
  168. package/dist/useLatest-Bg2x4bfP.d.mts.map +0 -1
  169. package/dist/with-text-input-CRfoiFFG.d.mts.map +0 -1
  170. package/dist/wrappers-UTADQkSY.mjs.map +0 -1
  171. package/dist/yoga-adapter-8oRGRw8V.mjs.map +0 -1
  172. package/dist/yoga-adapter-D_CcxSt5.mjs +0 -2
@@ -0,0 +1,336 @@
1
+ import { P as TerminalCaps } from "./index-2E1jYgak.mjs";
2
+ import { JSX } from "react";
3
+
4
+ //#region packages/ag-react/src/ui/image/kitty-graphics.d.ts
5
+ interface KittyImageOptions {
6
+ /** Image width in terminal columns */
7
+ width?: number;
8
+ /** Image height in terminal rows */
9
+ height?: number;
10
+ /** Image ID for later reference/deletion (positive integer) */
11
+ id?: number;
12
+ /**
13
+ * Transmit only — store the image but do NOT place it.
14
+ *
15
+ * Default `false`: action is `a=T` (transmit and display at cursor).
16
+ * Set to `true` for `a=t` (transmit only) — store the image bytes for
17
+ * later placement via {@link placeKittyImage}, without consuming a cell.
18
+ * The two-step flow lets a moving consumer (e.g. an `<Image>` that
19
+ * re-positions on scroll) transmit the PNG bytes once and re-place
20
+ * with a tiny APC packet on every subsequent move — eliminating the
21
+ * "delete-and-retransmit" flicker that re-encoding the full base64
22
+ * blob on every position change otherwise produces.
23
+ */
24
+ transmitOnly?: boolean;
25
+ /** Z-index stacking order. Defaults to 1 so images remain above reserved cells. */
26
+ zIndex?: number;
27
+ /** Pixel offset inside the first cell. Kitty keys: X/Y. */
28
+ pixelOffset?: {
29
+ readonly x?: number;
30
+ readonly y?: number;
31
+ };
32
+ /** Source rectangle in image pixels. Kitty keys: x/y/w/h. */
33
+ sourceRect?: {
34
+ readonly x?: number;
35
+ readonly y?: number;
36
+ readonly width?: number;
37
+ readonly height?: number;
38
+ };
39
+ /** Create a virtual placement for a Unicode placeholder. Kitty key: U=1. */
40
+ virtualPlacement?: boolean;
41
+ }
42
+ /** Options for {@link placeKittyImage}. */
43
+ interface KittyPlaceOptions {
44
+ /** Image ID previously transmitted via `a=t` (or `a=T`). */
45
+ id: number;
46
+ /** Display width in terminal columns. */
47
+ width?: number;
48
+ /** Display height in terminal rows. */
49
+ height?: number;
50
+ /**
51
+ * Placement ID for this displayed instance. Defaults to 1.
52
+ *
53
+ * Multiple placements of the same `id` can coexist if you give them
54
+ * different `placementId`s — each is independently delete-able via
55
+ * {@link deleteKittyPlacement}.
56
+ */
57
+ placementId?: number;
58
+ /** Z-index stacking order. Defaults to 1 so images remain above reserved cells. */
59
+ zIndex?: number;
60
+ /** Pixel offset inside the first cell. Kitty keys: X/Y. */
61
+ pixelOffset?: {
62
+ readonly x?: number;
63
+ readonly y?: number;
64
+ };
65
+ /** Source rectangle in image pixels. Kitty keys: x/y/w/h. */
66
+ sourceRect?: {
67
+ readonly x?: number;
68
+ readonly y?: number;
69
+ readonly width?: number;
70
+ readonly height?: number;
71
+ };
72
+ /** Create a virtual placement for a Unicode placeholder. Kitty key: U=1. */
73
+ virtualPlacement?: boolean;
74
+ }
75
+ /**
76
+ * Encode a PNG image into Kitty graphics protocol escape sequences.
77
+ *
78
+ * The image data is base64-encoded and split into chunks of <= 4096 bytes.
79
+ * Each chunk is wrapped in an APC escape sequence. The first chunk carries
80
+ * the image metadata (action, format, dimensions, ID). Subsequent chunks
81
+ * only carry `m=1` or `m=0` to indicate continuation.
82
+ *
83
+ * @param pngData - Raw PNG image data
84
+ * @param opts - Optional dimensions and ID
85
+ * @returns A string containing the complete escape sequence(s)
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * import { readFileSync } from "fs"
90
+ * import { encodeKittyImage } from "@silvery/ag-react"
91
+ *
92
+ * const png = readFileSync("photo.png")
93
+ * const seq = encodeKittyImage(png, { width: 40, height: 20 })
94
+ * process.stdout.write(seq)
95
+ * ```
96
+ */
97
+ declare function encodeKittyImage(pngData: Buffer, opts?: KittyImageOptions): string;
98
+ /**
99
+ * Generate an escape sequence to delete a Kitty image by ID.
100
+ *
101
+ * Uses `a=d` (delete) with `d=i` (delete by image ID). Removes both the
102
+ * stored image bytes AND every placement of it. Use
103
+ * {@link deleteKittyPlacement} to remove a single placement while keeping
104
+ * the image stored for later re-placement.
105
+ *
106
+ * @param id - The image ID to delete
107
+ * @returns The delete escape sequence
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * process.stdout.write(deleteKittyImage(42))
112
+ * ```
113
+ */
114
+ declare function deleteKittyImage(id: number): string;
115
+ /**
116
+ * Delete a single placement of a stored image, keeping the image bytes.
117
+ *
118
+ * Uses `a=d` with `d=i` (image id) and `p=` (placement id). The image
119
+ * remains stored on the terminal — re-place via {@link placeKittyImage}
120
+ * without re-transmitting the PNG.
121
+ *
122
+ * @param id - Image ID
123
+ * @param placementId - Placement ID (defaults to 1)
124
+ */
125
+ declare function deleteKittyPlacement(id: number, placementId?: number): string;
126
+ /**
127
+ * Place an already-transmitted image at the current cursor position.
128
+ *
129
+ * Uses `a=p` (place existing image). The image must have been previously
130
+ * transmitted with `transmitOnly: true` (or `a=T` — which transmits AND
131
+ * places, but you can still re-place separately afterwards). This is the
132
+ * fast path for a moving image: transmit the PNG once, then emit a tiny
133
+ * APC packet for each position update — no re-encoding of base64 bytes.
134
+ *
135
+ * Pair with {@link deleteKittyPlacement} to clear the prior placement
136
+ * before placing at a new cursor position. Skipping the delete leaves a
137
+ * stacked copy at the old position.
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * // Transmit once
142
+ * write(encodeKittyImage(png, { id: 42, transmitOnly: true }))
143
+ * // Place at cursor (which the caller positions via CSI ;H)
144
+ * write(placeKittyImage({ id: 42, width: 40, height: 20 }))
145
+ * // Move: clear old placement, position cursor, place again
146
+ * write(deleteKittyPlacement(42))
147
+ * write(`\x1b[10;5H`) // move cursor
148
+ * write(placeKittyImage({ id: 42, width: 40, height: 20 }))
149
+ * ```
150
+ */
151
+ declare function placeKittyImage(opts: KittyPlaceOptions): string;
152
+ /**
153
+ * Check if the current terminal likely supports the Kitty graphics protocol.
154
+ *
155
+ * Pass a profile or caps fixture when available. Without one, this falls
156
+ * back to {@link createTerminalProfile} — the canonical single-source-of-
157
+ * truth entry point in `@silvery/ansi/profile`. Direct reads of terminal-
158
+ * signal env vars (TERM / TERM_PROGRAM / …) are banned outside that module
159
+ * — see `scripts/lint-env-reads.ts`.
160
+ *
161
+ * For definitive detection, use a terminal query (send the graphics protocol
162
+ * query and check for a response), but that requires async I/O.
163
+ *
164
+ * Known supporting terminals: Kitty, WezTerm, Ghostty (partial), Konsole (partial).
165
+ *
166
+ * @returns `true` if the terminal likely supports Kitty graphics
167
+ */
168
+ declare function isKittyGraphicsSupported(profile?: {
169
+ readonly caps?: Pick<TerminalCaps, "kittyGraphics">;
170
+ readonly emulator?: {
171
+ program: string;
172
+ TERM: string;
173
+ };
174
+ } | {
175
+ program: string;
176
+ TERM: string;
177
+ }): boolean;
178
+ //#endregion
179
+ //#region packages/ag-react/src/ui/image/sixel-encoder.d.ts
180
+ /**
181
+ * Sixel Encoder (Minimal Implementation)
182
+ *
183
+ * Sixel is an older image protocol supported by terminals like xterm, mlterm,
184
+ * foot, and some others. Images are encoded as DCS (Device Control String)
185
+ * sequences where each character encodes 6 vertical pixels.
186
+ *
187
+ * DCS format: `ESC P <params> q <sixel-data> ESC \`
188
+ *
189
+ * This is a minimal implementation that produces valid Sixel output for
190
+ * simple images. For production use with complex images, consider using
191
+ * a dedicated Sixel library that handles color quantization and dithering.
192
+ *
193
+ * Protocol reference: https://en.wikipedia.org/wiki/Sixel
194
+ *
195
+ * TODO: Full Sixel encoding with proper color quantization, dithering,
196
+ * and compression. The current implementation handles basic RGBA image data
197
+ * with a simple nearest-color palette approach.
198
+ */
199
+ interface SixelImageData {
200
+ /** Image width in pixels */
201
+ width: number;
202
+ /** Image height in pixels */
203
+ height: number;
204
+ /** RGBA pixel data (4 bytes per pixel: R, G, B, A), row-major order */
205
+ data: Uint8Array;
206
+ }
207
+ /**
208
+ * Decode a PNG buffer into RGBA pixel data suitable for {@link encodeSixel}.
209
+ *
210
+ * The Sixel protocol cannot transmit PNG directly (unlike Kitty's `f=100`),
211
+ * so terminals that fall back to Sixel need raw RGBA pixels. This helper
212
+ * uses upng-js — a small (~30 KB) pure-JS PNG decoder with one tiny
213
+ * dependency (pako) — to bridge PNG → RGBA.
214
+ *
215
+ * Returns `null` if the buffer is not a valid PNG. Callers should fall back
216
+ * to a text placeholder in that case.
217
+ *
218
+ * Supports all PNG flavors UPNG handles: 8/16-bit depth, RGB/RGBA/grayscale/
219
+ * palette, interlaced. Animated PNGs (APNG) collapse to the first frame —
220
+ * Sixel itself is single-frame.
221
+ *
222
+ * @example
223
+ * ```ts
224
+ * import { readFileSync } from "fs"
225
+ * import { decodePngToRgba, encodeSixel } from "./sixel-encoder"
226
+ *
227
+ * const png = readFileSync("photo.png")
228
+ * const rgba = decodePngToRgba(png)
229
+ * if (rgba) {
230
+ * process.stdout.write(encodeSixel(rgba))
231
+ * }
232
+ * ```
233
+ */
234
+ declare function decodePngToRgba(pngData: Buffer | Uint8Array): SixelImageData | null;
235
+ /**
236
+ * Encode RGBA image data as a Sixel escape sequence.
237
+ *
238
+ * This is a basic implementation that:
239
+ * 1. Quantizes colors to a small palette (up to 256 colors)
240
+ * 2. Encodes 6-row bands as Sixel characters
241
+ * 3. Wraps in a DCS escape sequence
242
+ *
243
+ * For transparent pixels (alpha < 128), the background shows through.
244
+ *
245
+ * @param imageData - Image dimensions and RGBA pixel data
246
+ * @returns A DCS escape sequence containing the Sixel-encoded image
247
+ *
248
+ * @example
249
+ * ```ts
250
+ * const img = { width: 10, height: 12, data: new Uint8Array(10 * 12 * 4) }
251
+ * const seq = encodeSixel(img)
252
+ * process.stdout.write(seq)
253
+ * ```
254
+ */
255
+ declare function encodeSixel(imageData: SixelImageData): string;
256
+ /**
257
+ * Check if the current terminal likely supports the Sixel protocol.
258
+ *
259
+ * Pass `caps` (from `term.caps` or a {@link TerminalCaps} fixture) when
260
+ * available. Without caps, this falls back to {@link createTerminalProfile}
261
+ * — the canonical single-source-of-truth entry point in
262
+ * `@silvery/ansi/profile`. Direct reads of terminal-signal env vars
263
+ * (TERM / TERM_PROGRAM / …) are banned outside that module — see
264
+ * `scripts/lint-env-reads.ts`.
265
+ *
266
+ * For definitive detection, send a DA1 (Device Attributes) query and check
267
+ * for "4" in the response, but that requires async I/O.
268
+ *
269
+ * Known supporting terminals: xterm (with +sixel), mlterm, foot, mintty,
270
+ * WezTerm, Contour, Sixel-enabled builds of various terminals.
271
+ *
272
+ * @returns `true` if the terminal likely supports Sixel
273
+ */
274
+ declare function isSixelSupported(emulator?: {
275
+ program: string;
276
+ TERM: string;
277
+ }): boolean;
278
+ //#endregion
279
+ //#region packages/ag-react/src/ui/image/Image.d.ts
280
+ type ImageProtocol = "kitty" | "sixel" | "auto";
281
+ interface ImageProps {
282
+ /** PNG image data (Buffer) or file path (string) to a PNG file */
283
+ src: Buffer | string;
284
+ /** Width in terminal columns. If omitted, uses available width from layout. */
285
+ width?: number;
286
+ /** Height in terminal rows. If omitted, defaults to half the width (rough aspect ratio). */
287
+ height?: number;
288
+ /** Text to display when image rendering is not supported. Default: "[image]" */
289
+ fallback?: string;
290
+ /** Which protocol to use. Default: "auto" (tries Kitty, then Sixel, then fallback) */
291
+ protocol?: ImageProtocol;
292
+ /** Kitty placement id. Defaults to 1. */
293
+ placementId?: number;
294
+ /** Kitty z-index. Defaults to 1 so images render above reserved cells. */
295
+ zIndex?: number;
296
+ /** Kitty sub-cell pixel offset inside the first cell. */
297
+ pixelOffset?: {
298
+ readonly x?: number;
299
+ readonly y?: number;
300
+ };
301
+ /** Kitty source crop rectangle in image pixels. */
302
+ sourceRect?: {
303
+ readonly x?: number;
304
+ readonly y?: number;
305
+ readonly width?: number;
306
+ readonly height?: number;
307
+ };
308
+ /** Kitty virtual placement flag for Unicode placeholder rendering. */
309
+ virtualPlacement?: boolean;
310
+ }
311
+ /**
312
+ * Renders a bitmap image in the terminal.
313
+ *
314
+ * The component operates in two phases:
315
+ * 1. **Layout phase**: Renders a Box that reserves the visual space
316
+ * (filled with spaces so the cell buffer has the right dimensions).
317
+ * 2. **Commit phase**: Queues terminal image artifacts positioned over the
318
+ * reserved space.
319
+ *
320
+ * When image protocols are not available, the fallback text is shown instead.
321
+ */
322
+ declare function Image({
323
+ src,
324
+ width: requestedWidth,
325
+ height: requestedHeight,
326
+ fallback,
327
+ protocol: preferredProtocol,
328
+ placementId,
329
+ zIndex,
330
+ pixelOffset,
331
+ sourceRect,
332
+ virtualPlacement
333
+ }: ImageProps): JSX.Element;
334
+ //#endregion
335
+ export { encodeSixel as a, KittyPlaceOptions as c, encodeKittyImage as d, isKittyGraphicsSupported as f, decodePngToRgba as i, deleteKittyImage as l, ImageProps as n, isSixelSupported as o, placeKittyImage as p, SixelImageData as r, KittyImageOptions as s, Image as t, deleteKittyPlacement as u };
336
+ //# sourceMappingURL=index-Dg1YaeJb.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-Dg1YaeJb.d.mts","names":[],"sources":["../packages/ag-react/src/ui/image/kitty-graphics.ts","../packages/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