silvery 0.17.0 → 0.17.2
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/dist/UPNG-AVSMjiFE.mjs +5076 -0
- package/dist/UPNG-AVSMjiFE.mjs.map +1 -0
- package/dist/__vite-browser-external-2447137e-D3GdsvS_.mjs +6 -0
- package/dist/__vite-browser-external-2447137e-D3GdsvS_.mjs.map +1 -0
- package/dist/animation-C_PTO0uH.mjs +304 -0
- package/dist/animation-C_PTO0uH.mjs.map +1 -0
- package/dist/ansi-CXLE_pt1.mjs +71 -0
- package/dist/ansi-CXLE_pt1.mjs.map +1 -0
- package/dist/ansi-zmNzgkPB.d.mts +49 -0
- package/dist/ansi-zmNzgkPB.d.mts.map +1 -0
- package/dist/apng-DCWY913R.mjs +3 -0
- package/dist/apng-ENBAJk-H.mjs +70 -0
- package/dist/apng-ENBAJk-H.mjs.map +1 -0
- package/dist/assets/resvgjs.darwin-arm64-BtufyGW1.node +0 -0
- package/dist/backend-CkIkIHR-.mjs +13396 -0
- package/dist/backend-CkIkIHR-.mjs.map +1 -0
- package/dist/backends-CkvbG3js.mjs +1181 -0
- package/dist/backends-CkvbG3js.mjs.map +1 -0
- package/dist/backends-CyJqNLeK.mjs +3 -0
- package/dist/chunk-BSw8zbkd.mjs +37 -0
- package/dist/cli-B-k7Bm56.mjs +4 -0
- package/dist/context-QreF3UHr.mjs +64 -0
- package/dist/context-QreF3UHr.mjs.map +1 -0
- package/dist/derive-D7bFJdfU.d.mts +28 -0
- package/dist/derive-D7bFJdfU.d.mts.map +1 -0
- package/dist/devtools-CscuKaDK.mjs +89 -0
- package/dist/devtools-CscuKaDK.mjs.map +1 -0
- package/dist/devtools-D4oGc6LY.mjs +2 -0
- package/dist/eta-DLiVPaSD.mjs +110 -0
- package/dist/eta-DLiVPaSD.mjs.map +1 -0
- package/dist/flexily-zero-adapter-DmG4Ge8t.mjs +3376 -0
- package/dist/flexily-zero-adapter-DmG4Ge8t.mjs.map +1 -0
- package/dist/flexily-zero-adapter-GHwEW11s.mjs +2 -0
- package/dist/gif-BaJNREpP.mjs +3 -0
- package/dist/gif-Bp6fIyN3.mjs +73 -0
- package/dist/gif-Bp6fIyN3.mjs.map +1 -0
- package/dist/gifenc-GiVCZ9-3.mjs +730 -0
- package/dist/gifenc-GiVCZ9-3.mjs.map +1 -0
- package/dist/image-Dx7gYjkq.mjs +346 -0
- package/dist/image-Dx7gYjkq.mjs.map +1 -0
- package/dist/index-CBcSpGSM.d.mts +3416 -0
- package/dist/index-CBcSpGSM.d.mts.map +1 -0
- package/dist/index-DCVL3jHo.d.mts +634 -0
- package/dist/index-DCVL3jHo.d.mts.map +1 -0
- package/dist/index-p-wBs_wH.d.mts +175 -0
- package/dist/index-p-wBs_wH.d.mts.map +1 -0
- package/dist/index.d.mts +7296 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +9399 -0
- package/dist/index.mjs.map +1 -0
- package/dist/key-mapping-BsUHe_nk.mjs +3 -0
- package/dist/key-mapping-DsyfLEdC.mjs +132 -0
- package/dist/key-mapping-DsyfLEdC.mjs.map +1 -0
- package/dist/layout-engine-B3dsnVLU.mjs +50 -0
- package/dist/layout-engine-B3dsnVLU.mjs.map +1 -0
- package/dist/layout-engine-D_lSR4i9.mjs +2 -0
- package/dist/multi-progress-C0-rkn86.d.mts +180 -0
- package/dist/multi-progress-C0-rkn86.d.mts.map +1 -0
- package/dist/multi-progress-CQVB9lES.mjs +219 -0
- package/dist/multi-progress-CQVB9lES.mjs.map +1 -0
- package/dist/node-Dedx-6xF.mjs +1085 -0
- package/dist/node-Dedx-6xF.mjs.map +1 -0
- package/dist/pipeline-DDOPrjuY.mjs +4387 -0
- package/dist/pipeline-DDOPrjuY.mjs.map +1 -0
- package/dist/progress-bar-COPSBlT9.mjs +155 -0
- package/dist/progress-bar-COPSBlT9.mjs.map +1 -0
- package/dist/reconciler-2lp5VXK7.mjs +16506 -0
- package/dist/reconciler-2lp5VXK7.mjs.map +1 -0
- package/dist/render-string-BXvxTg5P.mjs +201 -0
- package/dist/render-string-BXvxTg5P.mjs.map +1 -0
- package/dist/render-string-hvfpVtoP.mjs +2 -0
- package/dist/resvg-js-V6oMi8CY.mjs +203 -0
- package/dist/resvg-js-V6oMi8CY.mjs.map +1 -0
- package/dist/runtime-BjDHNTxJ.mjs +8723 -0
- package/dist/runtime-BjDHNTxJ.mjs.map +1 -0
- package/dist/runtime.d.mts +2 -0
- package/dist/runtime.mjs +3 -0
- package/dist/spinner-Cgej6Vnb.d.mts +127 -0
- package/dist/spinner-Cgej6Vnb.d.mts.map +1 -0
- package/dist/spinner-DSByknyx.mjs +298 -0
- package/dist/spinner-DSByknyx.mjs.map +1 -0
- package/dist/src-9B5k0JmY.mjs +1629 -0
- package/dist/src-9B5k0JmY.mjs.map +1 -0
- package/dist/src-C9f3hiVG.mjs +3620 -0
- package/dist/src-C9f3hiVG.mjs.map +1 -0
- package/dist/src-fJVbhdn-.mjs +816 -0
- package/dist/src-fJVbhdn-.mjs.map +1 -0
- package/dist/theme.d.mts +115 -0
- package/dist/theme.d.mts.map +1 -0
- package/dist/theme.mjs +8 -0
- package/dist/theme.mjs.map +1 -0
- package/dist/types-Bhj5QkIQ.mjs +13 -0
- package/dist/types-Bhj5QkIQ.mjs.map +1 -0
- package/dist/types-CDgkE-Rw.d.mts +241 -0
- package/dist/types-CDgkE-Rw.d.mts.map +1 -0
- package/dist/ui/animation.d.mts +2 -0
- package/dist/ui/animation.mjs +2 -0
- package/dist/ui/ansi.d.mts +2 -0
- package/dist/ui/ansi.mjs +2 -0
- package/dist/ui/cli.d.mts +5 -0
- package/dist/ui/cli.mjs +7 -0
- package/dist/ui/display.d.mts +35 -0
- package/dist/ui/display.d.mts.map +1 -0
- package/dist/ui/display.mjs +123 -0
- package/dist/ui/display.mjs.map +1 -0
- package/dist/ui/image.d.mts +2 -0
- package/dist/ui/image.mjs +2 -0
- package/dist/ui/input.d.mts +184 -0
- package/dist/ui/input.d.mts.map +1 -0
- package/dist/ui/input.mjs +285 -0
- package/dist/ui/input.mjs.map +1 -0
- package/dist/ui/progress.d.mts +249 -0
- package/dist/ui/progress.d.mts.map +1 -0
- package/dist/ui/progress.mjs +858 -0
- package/dist/ui/progress.mjs.map +1 -0
- package/dist/ui/react.d.mts +280 -0
- package/dist/ui/react.d.mts.map +1 -0
- package/dist/ui/react.mjs +413 -0
- package/dist/ui/react.mjs.map +1 -0
- package/dist/ui/utils.d.mts +86 -0
- package/dist/ui/utils.d.mts.map +1 -0
- package/dist/ui/utils.mjs +2 -0
- package/dist/ui/wrappers.d.mts +3 -0
- package/dist/ui/wrappers.mjs +2 -0
- package/dist/ui.d.mts +6 -0
- package/dist/ui.mjs +7 -0
- package/dist/useLatest-BMIYXd6e.d.mts +154 -0
- package/dist/useLatest-BMIYXd6e.d.mts.map +1 -0
- package/dist/useLayout-BG2cGl15.mjs +139 -0
- package/dist/useLayout-BG2cGl15.mjs.map +1 -0
- package/dist/with-text-input-CmHf_9d6.d.mts +284 -0
- package/dist/with-text-input-CmHf_9d6.d.mts.map +1 -0
- package/dist/wrapper-Dqh0zi2W.mjs +3527 -0
- package/dist/wrapper-Dqh0zi2W.mjs.map +1 -0
- package/dist/wrappers-hhL8EQ_n.mjs +810 -0
- package/dist/wrappers-hhL8EQ_n.mjs.map +1 -0
- package/dist/yoga-adapter-BJ9SOhTY.mjs +245 -0
- package/dist/yoga-adapter-BJ9SOhTY.mjs.map +1 -0
- package/dist/yoga-adapter-Daq6-dw1.mjs +2 -0
- package/package.json +48 -75
- package/CHANGELOG.md +0 -319
- package/dist/chalk.js +0 -4
- package/dist/index.js +0 -270
- package/dist/ink.js +0 -142
- package/dist/runtime.js +0 -135
- package/dist/theme.js +0 -7
- package/dist/ui/animation.js +0 -3
- package/dist/ui/ansi.js +0 -3
- package/dist/ui/cli.js +0 -9
- package/dist/ui/display.js +0 -4
- package/dist/ui/image.js +0 -4
- package/dist/ui/input.js +0 -3
- package/dist/ui/progress.js +0 -9
- package/dist/ui/react.js +0 -4
- package/dist/ui/utils.js +0 -3
- package/dist/ui/wrappers.js +0 -15
- package/dist/ui.js +0 -18
- package/src/index.ts +0 -73
- package/src/runtime.ts +0 -4
- package/src/theme.ts +0 -4
- package/src/ui/animation.ts +0 -2
- package/src/ui/ansi.ts +0 -2
- package/src/ui/cli.ts +0 -3
- package/src/ui/display.ts +0 -2
- package/src/ui/image.ts +0 -2
- package/src/ui/input.ts +0 -2
- package/src/ui/progress.ts +0 -2
- package/src/ui/react.ts +0 -2
- package/src/ui/utils.ts +0 -2
- package/src/ui/wrappers.ts +0 -2
- package/src/ui.ts +0 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gifenc-GiVCZ9-3.mjs","names":[],"sources":["../../../node_modules/.bun/gifenc@1.0.3/node_modules/gifenc/dist/gifenc.js"],"sourcesContent":["var __defProp = Object.defineProperty;\nvar __markAsModule = (target) => __defProp(target, \"__esModule\", {value: true});\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, {get: all[name], enumerable: true});\n};\n\n// src/index.js\n__markAsModule(exports);\n__export(exports, {\n GIFEncoder: () => GIFEncoder,\n applyPalette: () => applyPalette,\n default: () => src_default,\n nearestColor: () => nearestColor,\n nearestColorIndex: () => nearestColorIndex,\n nearestColorIndexWithDistance: () => nearestColorIndexWithDistance,\n prequantize: () => prequantize,\n quantize: () => quantize,\n snapColorsToPalette: () => snapColorsToPalette\n});\n\n// src/constants.js\nvar constants_default = {\n signature: \"GIF\",\n version: \"89a\",\n trailer: 59,\n extensionIntroducer: 33,\n applicationExtensionLabel: 255,\n graphicControlExtensionLabel: 249,\n imageSeparator: 44,\n signatureSize: 3,\n versionSize: 3,\n globalColorTableFlagMask: 128,\n colorResolutionMask: 112,\n sortFlagMask: 8,\n globalColorTableSizeMask: 7,\n applicationIdentifierSize: 8,\n applicationAuthCodeSize: 3,\n disposalMethodMask: 28,\n userInputFlagMask: 2,\n transparentColorFlagMask: 1,\n localColorTableFlagMask: 128,\n interlaceFlagMask: 64,\n idSortFlagMask: 32,\n localColorTableSizeMask: 7\n};\n\n// src/stream.js\nfunction createStream(initialCapacity = 256) {\n let cursor = 0;\n let contents = new Uint8Array(initialCapacity);\n return {\n get buffer() {\n return contents.buffer;\n },\n reset() {\n cursor = 0;\n },\n bytesView() {\n return contents.subarray(0, cursor);\n },\n bytes() {\n return contents.slice(0, cursor);\n },\n writeByte(byte) {\n expand(cursor + 1);\n contents[cursor] = byte;\n cursor++;\n },\n writeBytes(data, offset = 0, byteLength = data.length) {\n expand(cursor + byteLength);\n for (let i = 0; i < byteLength; i++) {\n contents[cursor++] = data[i + offset];\n }\n },\n writeBytesView(data, offset = 0, byteLength = data.byteLength) {\n expand(cursor + byteLength);\n contents.set(data.subarray(offset, offset + byteLength), cursor);\n cursor += byteLength;\n }\n };\n function expand(newCapacity) {\n var prevCapacity = contents.length;\n if (prevCapacity >= newCapacity)\n return;\n var CAPACITY_DOUBLING_MAX = 1024 * 1024;\n newCapacity = Math.max(newCapacity, prevCapacity * (prevCapacity < CAPACITY_DOUBLING_MAX ? 2 : 1.125) >>> 0);\n if (prevCapacity != 0)\n newCapacity = Math.max(newCapacity, 256);\n const oldContents = contents;\n contents = new Uint8Array(newCapacity);\n if (cursor > 0)\n contents.set(oldContents.subarray(0, cursor), 0);\n }\n}\n\n// src/lzwEncode.js\nvar BITS = 12;\nvar DEFAULT_HSIZE = 5003;\nvar MASKS = [\n 0,\n 1,\n 3,\n 7,\n 15,\n 31,\n 63,\n 127,\n 255,\n 511,\n 1023,\n 2047,\n 4095,\n 8191,\n 16383,\n 32767,\n 65535\n];\nfunction lzwEncode(width, height, pixels, colorDepth, outStream = createStream(512), accum = new Uint8Array(256), htab = new Int32Array(DEFAULT_HSIZE), codetab = new Int32Array(DEFAULT_HSIZE)) {\n const hsize = htab.length;\n const initCodeSize = Math.max(2, colorDepth);\n accum.fill(0);\n codetab.fill(0);\n htab.fill(-1);\n let cur_accum = 0;\n let cur_bits = 0;\n const init_bits = initCodeSize + 1;\n const g_init_bits = init_bits;\n let clear_flg = false;\n let n_bits = g_init_bits;\n let maxcode = (1 << n_bits) - 1;\n const ClearCode = 1 << init_bits - 1;\n const EOFCode = ClearCode + 1;\n let free_ent = ClearCode + 2;\n let a_count = 0;\n let ent = pixels[0];\n let hshift = 0;\n for (let fcode = hsize; fcode < 65536; fcode *= 2) {\n ++hshift;\n }\n hshift = 8 - hshift;\n outStream.writeByte(initCodeSize);\n output(ClearCode);\n const length = pixels.length;\n for (let idx = 1; idx < length; idx++) {\n next_block: {\n const c = pixels[idx];\n const fcode = (c << BITS) + ent;\n let i = c << hshift ^ ent;\n if (htab[i] === fcode) {\n ent = codetab[i];\n break next_block;\n }\n const disp = i === 0 ? 1 : hsize - i;\n while (htab[i] >= 0) {\n i -= disp;\n if (i < 0)\n i += hsize;\n if (htab[i] === fcode) {\n ent = codetab[i];\n break next_block;\n }\n }\n output(ent);\n ent = c;\n if (free_ent < 1 << BITS) {\n codetab[i] = free_ent++;\n htab[i] = fcode;\n } else {\n htab.fill(-1);\n free_ent = ClearCode + 2;\n clear_flg = true;\n output(ClearCode);\n }\n }\n }\n output(ent);\n output(EOFCode);\n outStream.writeByte(0);\n return outStream.bytesView();\n function output(code) {\n cur_accum &= MASKS[cur_bits];\n if (cur_bits > 0)\n cur_accum |= code << cur_bits;\n else\n cur_accum = code;\n cur_bits += n_bits;\n while (cur_bits >= 8) {\n accum[a_count++] = cur_accum & 255;\n if (a_count >= 254) {\n outStream.writeByte(a_count);\n outStream.writeBytesView(accum, 0, a_count);\n a_count = 0;\n }\n cur_accum >>= 8;\n cur_bits -= 8;\n }\n if (free_ent > maxcode || clear_flg) {\n if (clear_flg) {\n n_bits = g_init_bits;\n maxcode = (1 << n_bits) - 1;\n clear_flg = false;\n } else {\n ++n_bits;\n maxcode = n_bits === BITS ? 1 << n_bits : (1 << n_bits) - 1;\n }\n }\n if (code == EOFCode) {\n while (cur_bits > 0) {\n accum[a_count++] = cur_accum & 255;\n if (a_count >= 254) {\n outStream.writeByte(a_count);\n outStream.writeBytesView(accum, 0, a_count);\n a_count = 0;\n }\n cur_accum >>= 8;\n cur_bits -= 8;\n }\n if (a_count > 0) {\n outStream.writeByte(a_count);\n outStream.writeBytesView(accum, 0, a_count);\n a_count = 0;\n }\n }\n }\n}\nvar lzwEncode_default = lzwEncode;\n\n// src/rgb-packing.js\nfunction rgb888_to_rgb565(r, g, b) {\n return r << 8 & 63488 | g << 2 & 992 | b >> 3;\n}\nfunction rgba8888_to_rgba4444(r, g, b, a) {\n return r >> 4 | g & 240 | (b & 240) << 4 | (a & 240) << 8;\n}\nfunction rgb888_to_rgb444(r, g, b) {\n return r >> 4 << 8 | g & 240 | b >> 4;\n}\n\n// src/pnnquant2.js\nfunction clamp(value, min, max) {\n return value < min ? min : value > max ? max : value;\n}\nfunction sqr(value) {\n return value * value;\n}\nfunction find_nn(bins, idx, hasAlpha) {\n var nn = 0;\n var err = 1e100;\n const bin1 = bins[idx];\n const n1 = bin1.cnt;\n const wa = bin1.ac;\n const wr = bin1.rc;\n const wg = bin1.gc;\n const wb = bin1.bc;\n for (var i = bin1.fw; i != 0; i = bins[i].fw) {\n const bin = bins[i];\n const n2 = bin.cnt;\n const nerr2 = n1 * n2 / (n1 + n2);\n if (nerr2 >= err)\n continue;\n var nerr = 0;\n if (hasAlpha) {\n nerr += nerr2 * sqr(bin.ac - wa);\n if (nerr >= err)\n continue;\n }\n nerr += nerr2 * sqr(bin.rc - wr);\n if (nerr >= err)\n continue;\n nerr += nerr2 * sqr(bin.gc - wg);\n if (nerr >= err)\n continue;\n nerr += nerr2 * sqr(bin.bc - wb);\n if (nerr >= err)\n continue;\n err = nerr;\n nn = i;\n }\n bin1.err = err;\n bin1.nn = nn;\n}\nfunction create_bin() {\n return {\n ac: 0,\n rc: 0,\n gc: 0,\n bc: 0,\n cnt: 0,\n nn: 0,\n fw: 0,\n bk: 0,\n tm: 0,\n mtm: 0,\n err: 0\n };\n}\nfunction create_bin_list(data, format) {\n const bincount = format === \"rgb444\" ? 4096 : 65536;\n const bins = new Array(bincount);\n const size = data.length;\n if (format === \"rgba4444\") {\n for (let i = 0; i < size; ++i) {\n const color = data[i];\n const a = color >> 24 & 255;\n const b = color >> 16 & 255;\n const g = color >> 8 & 255;\n const r = color & 255;\n const index = rgba8888_to_rgba4444(r, g, b, a);\n let bin = index in bins ? bins[index] : bins[index] = create_bin();\n bin.rc += r;\n bin.gc += g;\n bin.bc += b;\n bin.ac += a;\n bin.cnt++;\n }\n } else if (format === \"rgb444\") {\n for (let i = 0; i < size; ++i) {\n const color = data[i];\n const b = color >> 16 & 255;\n const g = color >> 8 & 255;\n const r = color & 255;\n const index = rgb888_to_rgb444(r, g, b);\n let bin = index in bins ? bins[index] : bins[index] = create_bin();\n bin.rc += r;\n bin.gc += g;\n bin.bc += b;\n bin.cnt++;\n }\n } else {\n for (let i = 0; i < size; ++i) {\n const color = data[i];\n const b = color >> 16 & 255;\n const g = color >> 8 & 255;\n const r = color & 255;\n const index = rgb888_to_rgb565(r, g, b);\n let bin = index in bins ? bins[index] : bins[index] = create_bin();\n bin.rc += r;\n bin.gc += g;\n bin.bc += b;\n bin.cnt++;\n }\n }\n return bins;\n}\nfunction quantize(rgba, maxColors, opts = {}) {\n const {\n format = \"rgb565\",\n clearAlpha = true,\n clearAlphaColor = 0,\n clearAlphaThreshold = 0,\n oneBitAlpha = false\n } = opts;\n if (!rgba || !rgba.buffer) {\n throw new Error(\"quantize() expected RGBA Uint8Array data\");\n }\n if (!(rgba instanceof Uint8Array) && !(rgba instanceof Uint8ClampedArray)) {\n throw new Error(\"quantize() expected RGBA Uint8Array data\");\n }\n const data = new Uint32Array(rgba.buffer);\n let useSqrt = opts.useSqrt !== false;\n const hasAlpha = format === \"rgba4444\";\n const bins = create_bin_list(data, format);\n const bincount = bins.length;\n const bincountMinusOne = bincount - 1;\n const heap = new Uint32Array(bincount + 1);\n var maxbins = 0;\n for (var i = 0; i < bincount; ++i) {\n const bin = bins[i];\n if (bin != null) {\n var d = 1 / bin.cnt;\n if (hasAlpha)\n bin.ac *= d;\n bin.rc *= d;\n bin.gc *= d;\n bin.bc *= d;\n bins[maxbins++] = bin;\n }\n }\n if (sqr(maxColors) / maxbins < 0.022) {\n useSqrt = false;\n }\n var i = 0;\n for (; i < maxbins - 1; ++i) {\n bins[i].fw = i + 1;\n bins[i + 1].bk = i;\n if (useSqrt)\n bins[i].cnt = Math.sqrt(bins[i].cnt);\n }\n if (useSqrt)\n bins[i].cnt = Math.sqrt(bins[i].cnt);\n var h, l, l2;\n for (i = 0; i < maxbins; ++i) {\n find_nn(bins, i, false);\n var err = bins[i].err;\n for (l = ++heap[0]; l > 1; l = l2) {\n l2 = l >> 1;\n if (bins[h = heap[l2]].err <= err)\n break;\n heap[l] = h;\n }\n heap[l] = i;\n }\n var extbins = maxbins - maxColors;\n for (i = 0; i < extbins; ) {\n var tb;\n for (; ; ) {\n var b1 = heap[1];\n tb = bins[b1];\n if (tb.tm >= tb.mtm && bins[tb.nn].mtm <= tb.tm)\n break;\n if (tb.mtm == bincountMinusOne)\n b1 = heap[1] = heap[heap[0]--];\n else {\n find_nn(bins, b1, false);\n tb.tm = i;\n }\n var err = bins[b1].err;\n for (l = 1; (l2 = l + l) <= heap[0]; l = l2) {\n if (l2 < heap[0] && bins[heap[l2]].err > bins[heap[l2 + 1]].err)\n l2++;\n if (err <= bins[h = heap[l2]].err)\n break;\n heap[l] = h;\n }\n heap[l] = b1;\n }\n var nb = bins[tb.nn];\n var n1 = tb.cnt;\n var n2 = nb.cnt;\n var d = 1 / (n1 + n2);\n if (hasAlpha)\n tb.ac = d * (n1 * tb.ac + n2 * nb.ac);\n tb.rc = d * (n1 * tb.rc + n2 * nb.rc);\n tb.gc = d * (n1 * tb.gc + n2 * nb.gc);\n tb.bc = d * (n1 * tb.bc + n2 * nb.bc);\n tb.cnt += nb.cnt;\n tb.mtm = ++i;\n bins[nb.bk].fw = nb.fw;\n bins[nb.fw].bk = nb.bk;\n nb.mtm = bincountMinusOne;\n }\n let palette = [];\n var k = 0;\n for (i = 0; ; ++k) {\n let r = clamp(Math.round(bins[i].rc), 0, 255);\n let g = clamp(Math.round(bins[i].gc), 0, 255);\n let b = clamp(Math.round(bins[i].bc), 0, 255);\n let a = 255;\n if (hasAlpha) {\n a = clamp(Math.round(bins[i].ac), 0, 255);\n if (oneBitAlpha) {\n const threshold = typeof oneBitAlpha === \"number\" ? oneBitAlpha : 127;\n a = a <= threshold ? 0 : 255;\n }\n if (clearAlpha && a <= clearAlphaThreshold) {\n r = g = b = clearAlphaColor;\n a = 0;\n }\n }\n const color = hasAlpha ? [r, g, b, a] : [r, g, b];\n const exists = existsInPalette(palette, color);\n if (!exists)\n palette.push(color);\n if ((i = bins[i].fw) == 0)\n break;\n }\n return palette;\n}\nfunction existsInPalette(palette, color) {\n for (let i = 0; i < palette.length; i++) {\n const p = palette[i];\n let matchesRGB = p[0] === color[0] && p[1] === color[1] && p[2] === color[2];\n let matchesAlpha = p.length >= 4 && color.length >= 4 ? p[3] === color[3] : true;\n if (matchesRGB && matchesAlpha)\n return true;\n }\n return false;\n}\n\n// src/color.js\nfunction euclideanDistanceSquared(a, b) {\n var sum = 0;\n var n;\n for (n = 0; n < a.length; n++) {\n const dx = a[n] - b[n];\n sum += dx * dx;\n }\n return sum;\n}\n\n// src/palettize.js\nfunction roundStep(byte, step) {\n return step > 1 ? Math.round(byte / step) * step : byte;\n}\nfunction prequantize(rgba, {roundRGB = 5, roundAlpha = 10, oneBitAlpha = null} = {}) {\n const data = new Uint32Array(rgba.buffer);\n for (let i = 0; i < data.length; i++) {\n const color = data[i];\n let a = color >> 24 & 255;\n let b = color >> 16 & 255;\n let g = color >> 8 & 255;\n let r = color & 255;\n a = roundStep(a, roundAlpha);\n if (oneBitAlpha) {\n const threshold = typeof oneBitAlpha === \"number\" ? oneBitAlpha : 127;\n a = a <= threshold ? 0 : 255;\n }\n r = roundStep(r, roundRGB);\n g = roundStep(g, roundRGB);\n b = roundStep(b, roundRGB);\n data[i] = a << 24 | b << 16 | g << 8 | r << 0;\n }\n}\nfunction applyPalette(rgba, palette, format = \"rgb565\") {\n if (!rgba || !rgba.buffer) {\n throw new Error(\"quantize() expected RGBA Uint8Array data\");\n }\n if (!(rgba instanceof Uint8Array) && !(rgba instanceof Uint8ClampedArray)) {\n throw new Error(\"quantize() expected RGBA Uint8Array data\");\n }\n if (palette.length > 256) {\n throw new Error(\"applyPalette() only works with 256 colors or less\");\n }\n const data = new Uint32Array(rgba.buffer);\n const length = data.length;\n const bincount = format === \"rgb444\" ? 4096 : 65536;\n const index = new Uint8Array(length);\n const cache = new Array(bincount);\n const hasAlpha = format === \"rgba4444\";\n if (format === \"rgba4444\") {\n for (let i = 0; i < length; i++) {\n const color = data[i];\n const a = color >> 24 & 255;\n const b = color >> 16 & 255;\n const g = color >> 8 & 255;\n const r = color & 255;\n const key = rgba8888_to_rgba4444(r, g, b, a);\n const idx = key in cache ? cache[key] : cache[key] = nearestColorIndexRGBA(r, g, b, a, palette);\n index[i] = idx;\n }\n } else {\n const rgb888_to_key = format === \"rgb444\" ? rgb888_to_rgb444 : rgb888_to_rgb565;\n for (let i = 0; i < length; i++) {\n const color = data[i];\n const b = color >> 16 & 255;\n const g = color >> 8 & 255;\n const r = color & 255;\n const key = rgb888_to_key(r, g, b);\n const idx = key in cache ? cache[key] : cache[key] = nearestColorIndexRGB(r, g, b, palette);\n index[i] = idx;\n }\n }\n return index;\n}\nfunction nearestColorIndexRGBA(r, g, b, a, palette) {\n let k = 0;\n let mindist = 1e100;\n for (let i = 0; i < palette.length; i++) {\n const px2 = palette[i];\n const a2 = px2[3];\n let curdist = sqr2(a2 - a);\n if (curdist > mindist)\n continue;\n const r2 = px2[0];\n curdist += sqr2(r2 - r);\n if (curdist > mindist)\n continue;\n const g2 = px2[1];\n curdist += sqr2(g2 - g);\n if (curdist > mindist)\n continue;\n const b2 = px2[2];\n curdist += sqr2(b2 - b);\n if (curdist > mindist)\n continue;\n mindist = curdist;\n k = i;\n }\n return k;\n}\nfunction nearestColorIndexRGB(r, g, b, palette) {\n let k = 0;\n let mindist = 1e100;\n for (let i = 0; i < palette.length; i++) {\n const px2 = palette[i];\n const r2 = px2[0];\n let curdist = sqr2(r2 - r);\n if (curdist > mindist)\n continue;\n const g2 = px2[1];\n curdist += sqr2(g2 - g);\n if (curdist > mindist)\n continue;\n const b2 = px2[2];\n curdist += sqr2(b2 - b);\n if (curdist > mindist)\n continue;\n mindist = curdist;\n k = i;\n }\n return k;\n}\nfunction snapColorsToPalette(palette, knownColors, threshold = 5) {\n if (!palette.length || !knownColors.length)\n return;\n const paletteRGB = palette.map((p) => p.slice(0, 3));\n const thresholdSq = threshold * threshold;\n const dim = palette[0].length;\n for (let i = 0; i < knownColors.length; i++) {\n let color = knownColors[i];\n if (color.length < dim) {\n color = [color[0], color[1], color[2], 255];\n } else if (color.length > dim) {\n color = color.slice(0, 3);\n } else {\n color = color.slice();\n }\n const r = nearestColorIndexWithDistance(paletteRGB, color.slice(0, 3), euclideanDistanceSquared);\n const idx = r[0];\n const distanceSq = r[1];\n if (distanceSq > 0 && distanceSq <= thresholdSq) {\n palette[idx] = color;\n }\n }\n}\nfunction sqr2(a) {\n return a * a;\n}\nfunction nearestColorIndex(colors, pixel, distanceFn = euclideanDistanceSquared) {\n let minDist = Infinity;\n let minDistIndex = -1;\n for (let j = 0; j < colors.length; j++) {\n const paletteColor = colors[j];\n const dist = distanceFn(pixel, paletteColor);\n if (dist < minDist) {\n minDist = dist;\n minDistIndex = j;\n }\n }\n return minDistIndex;\n}\nfunction nearestColorIndexWithDistance(colors, pixel, distanceFn = euclideanDistanceSquared) {\n let minDist = Infinity;\n let minDistIndex = -1;\n for (let j = 0; j < colors.length; j++) {\n const paletteColor = colors[j];\n const dist = distanceFn(pixel, paletteColor);\n if (dist < minDist) {\n minDist = dist;\n minDistIndex = j;\n }\n }\n return [minDistIndex, minDist];\n}\nfunction nearestColor(colors, pixel, distanceFn = euclideanDistanceSquared) {\n return colors[nearestColorIndex(colors, pixel, distanceFn)];\n}\n\n// src/index.js\nfunction GIFEncoder(opt = {}) {\n const {initialCapacity = 4096, auto = true} = opt;\n const stream = createStream(initialCapacity);\n const HSIZE = 5003;\n const accum = new Uint8Array(256);\n const htab = new Int32Array(HSIZE);\n const codetab = new Int32Array(HSIZE);\n let hasInit = false;\n return {\n reset() {\n stream.reset();\n hasInit = false;\n },\n finish() {\n stream.writeByte(constants_default.trailer);\n },\n bytes() {\n return stream.bytes();\n },\n bytesView() {\n return stream.bytesView();\n },\n get buffer() {\n return stream.buffer;\n },\n get stream() {\n return stream;\n },\n writeHeader,\n writeFrame(index, width, height, opts = {}) {\n const {\n transparent = false,\n transparentIndex = 0,\n delay = 0,\n palette = null,\n repeat = 0,\n colorDepth = 8,\n dispose = -1\n } = opts;\n let first = false;\n if (auto) {\n if (!hasInit) {\n first = true;\n writeHeader();\n hasInit = true;\n }\n } else {\n first = Boolean(opts.first);\n }\n width = Math.max(0, Math.floor(width));\n height = Math.max(0, Math.floor(height));\n if (first) {\n if (!palette) {\n throw new Error(\"First frame must include a { palette } option\");\n }\n encodeLogicalScreenDescriptor(stream, width, height, palette, colorDepth);\n encodeColorTable(stream, palette);\n if (repeat >= 0) {\n encodeNetscapeExt(stream, repeat);\n }\n }\n const delayTime = Math.round(delay / 10);\n encodeGraphicControlExt(stream, dispose, delayTime, transparent, transparentIndex);\n const useLocalColorTable = Boolean(palette) && !first;\n encodeImageDescriptor(stream, width, height, useLocalColorTable ? palette : null);\n if (useLocalColorTable)\n encodeColorTable(stream, palette);\n encodePixels(stream, index, width, height, colorDepth, accum, htab, codetab);\n }\n };\n function writeHeader() {\n writeUTFBytes(stream, \"GIF89a\");\n }\n}\nfunction encodeGraphicControlExt(stream, dispose, delay, transparent, transparentIndex) {\n stream.writeByte(33);\n stream.writeByte(249);\n stream.writeByte(4);\n if (transparentIndex < 0) {\n transparentIndex = 0;\n transparent = false;\n }\n var transp, disp;\n if (!transparent) {\n transp = 0;\n disp = 0;\n } else {\n transp = 1;\n disp = 2;\n }\n if (dispose >= 0) {\n disp = dispose & 7;\n }\n disp <<= 2;\n const userInput = 0;\n stream.writeByte(0 | disp | userInput | transp);\n writeUInt16(stream, delay);\n stream.writeByte(transparentIndex || 0);\n stream.writeByte(0);\n}\nfunction encodeLogicalScreenDescriptor(stream, width, height, palette, colorDepth = 8) {\n const globalColorTableFlag = 1;\n const sortFlag = 0;\n const globalColorTableSize = colorTableSize(palette.length) - 1;\n const fields = globalColorTableFlag << 7 | colorDepth - 1 << 4 | sortFlag << 3 | globalColorTableSize;\n const backgroundColorIndex = 0;\n const pixelAspectRatio = 0;\n writeUInt16(stream, width);\n writeUInt16(stream, height);\n stream.writeBytes([fields, backgroundColorIndex, pixelAspectRatio]);\n}\nfunction encodeNetscapeExt(stream, repeat) {\n stream.writeByte(33);\n stream.writeByte(255);\n stream.writeByte(11);\n writeUTFBytes(stream, \"NETSCAPE2.0\");\n stream.writeByte(3);\n stream.writeByte(1);\n writeUInt16(stream, repeat);\n stream.writeByte(0);\n}\nfunction encodeColorTable(stream, palette) {\n const colorTableLength = 1 << colorTableSize(palette.length);\n for (let i = 0; i < colorTableLength; i++) {\n let color = [0, 0, 0];\n if (i < palette.length) {\n color = palette[i];\n }\n stream.writeByte(color[0]);\n stream.writeByte(color[1]);\n stream.writeByte(color[2]);\n }\n}\nfunction encodeImageDescriptor(stream, width, height, localPalette) {\n stream.writeByte(44);\n writeUInt16(stream, 0);\n writeUInt16(stream, 0);\n writeUInt16(stream, width);\n writeUInt16(stream, height);\n if (localPalette) {\n const interlace = 0;\n const sorted = 0;\n const palSize = colorTableSize(localPalette.length) - 1;\n stream.writeByte(128 | interlace | sorted | 0 | palSize);\n } else {\n stream.writeByte(0);\n }\n}\nfunction encodePixels(stream, index, width, height, colorDepth = 8, accum, htab, codetab) {\n lzwEncode_default(width, height, index, colorDepth, stream, accum, htab, codetab);\n}\nfunction writeUInt16(stream, short) {\n stream.writeByte(short & 255);\n stream.writeByte(short >> 8 & 255);\n}\nfunction writeUTFBytes(stream, text) {\n for (var i = 0; i < text.length; i++) {\n stream.writeByte(text.charCodeAt(i));\n }\n}\nfunction colorTableSize(length) {\n return Math.max(Math.ceil(Math.log2(length)), 1);\n}\nvar src_default = GIFEncoder;\n//# sourceMappingURL=gifenc.js.map\n"],"x_google_ignoreList":[0],"mappings":";;;CAAA,IAAI,YAAY,OAAO;CACvB,IAAI,kBAAkB,WAAW,UAAU,QAAQ,cAAc,EAAC,OAAO,MAAK,CAAC;CAC/E,IAAI,YAAY,QAAQ,QAAQ;AAC9B,OAAK,IAAI,QAAQ,IACf,WAAU,QAAQ,MAAM;GAAC,KAAK,IAAI;GAAO,YAAY;GAAK,CAAC;;AAI/D,gBAAe,QAAQ;AACvB,UAAS,SAAS;EAChB,kBAAkB;EAClB,oBAAoB;EACpB,eAAe;EACf,oBAAoB;EACpB,yBAAyB;EACzB,qCAAqC;EACrC,mBAAmB;EACnB,gBAAgB;EAChB,2BAA2B;EAC5B,CAAC;CAGF,IAAI,oBAAoB;EACtB,WAAW;EACX,SAAS;EACT,SAAS;EACT,qBAAqB;EACrB,2BAA2B;EAC3B,8BAA8B;EAC9B,gBAAgB;EAChB,eAAe;EACf,aAAa;EACb,0BAA0B;EAC1B,qBAAqB;EACrB,cAAc;EACd,0BAA0B;EAC1B,2BAA2B;EAC3B,yBAAyB;EACzB,oBAAoB;EACpB,mBAAmB;EACnB,0BAA0B;EAC1B,yBAAyB;EACzB,mBAAmB;EACnB,gBAAgB;EAChB,yBAAyB;EAC1B;CAGD,SAAS,aAAa,kBAAkB,KAAK;EAC3C,IAAI,SAAS;EACb,IAAI,WAAW,IAAI,WAAW,gBAAgB;AAC9C,SAAO;GACL,IAAI,SAAS;AACX,WAAO,SAAS;;GAElB,QAAQ;AACN,aAAS;;GAEX,YAAY;AACV,WAAO,SAAS,SAAS,GAAG,OAAO;;GAErC,QAAQ;AACN,WAAO,S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1B,UAAO,UAAU,MAAM,GAAG;;;CAG9B,SAAS,sBAAsB,QAAQ,OAAO,QAAQ,cAAc;AAClE,SAAO,UAAU,GAAG;AACpB,cAAY,QAAQ,EAAE;AACtB,cAAY,QAAQ,EAAE;AACtB,cAAY,QAAQ,MAAM;AAC1B,cAAY,QAAQ,OAAO;AAC3B,MAAI,cAAc;GAGhB,MAAM,UAAU,eAAe,aAAa,OAAO,GAAG;AACtD,UAAO,UAAU,MAA+B,QAAQ;QAExD,QAAO,UAAU,EAAE;;CAGvB,SAAS,aAAa,QAAQ,OAAO,OAAO,QAAQ,aAAa,GAAG,OAAO,MAAM,SAAS;AACxF,oBAAkB,OAAO,QAAQ,OAAO,YAAY,QAAQ,OAAO,MAAM,QAAQ;;CAEnF,SAAS,YAAY,QAAQ,OAAO;AAClC,SAAO,UAAU,QAAQ,IAAI;AAC7B,SAAO,UAAU,SAAS,IAAI,IAAI;;CAEpC,SAAS,cAAc,QAAQ,MAAM;AACnC,OAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,IAC/B,QAAO,UAAU,KAAK,WAAW,EAAE,CAAC;;CAGxC,SAAS,eAAe,QAAQ;AAC9B,SAAO,KAAK,IAAI,KAAK,KAAK,KAAK,KAAK,OAAO,CAAC,EAAE,EAAE;;CAElD,IAAI,cAAc"}
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { s as StdoutContext } from "./context-QreF3UHr.mjs";
|
|
2
|
+
import { t as useBoxRect } from "./useLayout-BG2cGl15.mjs";
|
|
3
|
+
import { useContext, useEffect, useMemo, useRef } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { readFileSync } from "node:fs";
|
|
6
|
+
//#region packages/ag-react/src/ui/image/kitty-graphics.ts
|
|
7
|
+
/**
|
|
8
|
+
* Kitty Graphics Protocol
|
|
9
|
+
*
|
|
10
|
+
* Encodes and manages images using the Kitty terminal graphics protocol.
|
|
11
|
+
* Images are transmitted as base64-encoded PNG data via APC (Application
|
|
12
|
+
* Program Command) escape sequences.
|
|
13
|
+
*
|
|
14
|
+
* Protocol reference: https://sw.kovidgoyal.net/kitty/graphics-protocol/
|
|
15
|
+
*
|
|
16
|
+
* Key concepts:
|
|
17
|
+
* - `a=T` — transmit and display the image
|
|
18
|
+
* - `f=100` — format is PNG (raw PNG data, terminal decodes it)
|
|
19
|
+
* - `m=0|1` — 0 = last/only chunk, 1 = more chunks follow
|
|
20
|
+
* - Chunks should be <= 4096 bytes of base64 to avoid overwhelming the terminal
|
|
21
|
+
* - Images can be assigned an `i=<id>` for later deletion
|
|
22
|
+
*/
|
|
23
|
+
const APC_START = "\x1B_G";
|
|
24
|
+
const ST$1 = "\x1B\\";
|
|
25
|
+
/** Maximum base64 bytes per chunk (Kitty recommendation) */
|
|
26
|
+
const MAX_CHUNK_SIZE = 4096;
|
|
27
|
+
/**
|
|
28
|
+
* Encode a PNG image into Kitty graphics protocol escape sequences.
|
|
29
|
+
*
|
|
30
|
+
* The image data is base64-encoded and split into chunks of <= 4096 bytes.
|
|
31
|
+
* Each chunk is wrapped in an APC escape sequence. The first chunk carries
|
|
32
|
+
* the image metadata (action, format, dimensions, ID). Subsequent chunks
|
|
33
|
+
* only carry `m=1` or `m=0` to indicate continuation.
|
|
34
|
+
*
|
|
35
|
+
* @param pngData - Raw PNG image data
|
|
36
|
+
* @param opts - Optional dimensions and ID
|
|
37
|
+
* @returns A string containing the complete escape sequence(s)
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { readFileSync } from "fs"
|
|
42
|
+
* import { encodeKittyImage } from "@silvery/ag-react"
|
|
43
|
+
*
|
|
44
|
+
* const png = readFileSync("photo.png")
|
|
45
|
+
* const seq = encodeKittyImage(png, { width: 40, height: 20 })
|
|
46
|
+
* process.stdout.write(seq)
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
function encodeKittyImage(pngData, opts) {
|
|
50
|
+
const chunks = splitIntoChunks(pngData.toString("base64"), MAX_CHUNK_SIZE);
|
|
51
|
+
if (chunks.length === 0) return `${APC_START}${buildParams(opts, 0)};${ST$1}`;
|
|
52
|
+
if (chunks.length === 1) return `${APC_START}${buildParams(opts, 0)};${chunks[0]}${ST$1}`;
|
|
53
|
+
const parts = [];
|
|
54
|
+
parts.push(`${APC_START}${buildParams(opts, 1)};${chunks[0]}${ST$1}`);
|
|
55
|
+
for (let i = 1; i < chunks.length - 1; i++) parts.push(`${APC_START}m=1;${chunks[i]}${ST$1}`);
|
|
56
|
+
parts.push(`${APC_START}m=0;${chunks[chunks.length - 1]}${ST$1}`);
|
|
57
|
+
return parts.join("");
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Generate an escape sequence to delete a Kitty image by ID.
|
|
61
|
+
*
|
|
62
|
+
* Uses `a=d` (delete) with `d=i` (delete by image ID).
|
|
63
|
+
*
|
|
64
|
+
* @param id - The image ID to delete
|
|
65
|
+
* @returns The delete escape sequence
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* process.stdout.write(deleteKittyImage(42))
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
function deleteKittyImage(id) {
|
|
73
|
+
return `${APC_START}a=d,d=i,i=${id}${ST$1}`;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Check if the current terminal likely supports the Kitty graphics protocol.
|
|
77
|
+
*
|
|
78
|
+
* This is a heuristic based on `TERM` and `TERM_PROGRAM` environment variables.
|
|
79
|
+
* For definitive detection, use a terminal query (send the graphics protocol
|
|
80
|
+
* query and check for a response), but that requires async I/O.
|
|
81
|
+
*
|
|
82
|
+
* Known supporting terminals: Kitty, WezTerm, Ghostty (partial), Konsole (partial).
|
|
83
|
+
*
|
|
84
|
+
* @returns `true` if the terminal likely supports Kitty graphics
|
|
85
|
+
*/
|
|
86
|
+
function isKittyGraphicsSupported() {
|
|
87
|
+
const term = process.env.TERM ?? "";
|
|
88
|
+
const termProgram = process.env.TERM_PROGRAM ?? "";
|
|
89
|
+
if (term === "xterm-kitty" || termProgram === "kitty") return true;
|
|
90
|
+
if (termProgram === "WezTerm") return true;
|
|
91
|
+
if (termProgram === "ghostty") return true;
|
|
92
|
+
if (termProgram === "konsole") return true;
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Build the Kitty graphics protocol parameter string for the first chunk.
|
|
97
|
+
*/
|
|
98
|
+
function buildParams(opts, more) {
|
|
99
|
+
const parts = [
|
|
100
|
+
`a=T`,
|
|
101
|
+
`f=100`,
|
|
102
|
+
`m=${more}`
|
|
103
|
+
];
|
|
104
|
+
if (opts?.width != null) parts.push(`s=${opts.width}`);
|
|
105
|
+
if (opts?.height != null) parts.push(`v=${opts.height}`);
|
|
106
|
+
if (opts?.id != null) parts.push(`i=${opts.id}`);
|
|
107
|
+
return parts.join(",");
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Split a string into chunks of at most `size` characters.
|
|
111
|
+
*/
|
|
112
|
+
function splitIntoChunks(str, size) {
|
|
113
|
+
if (str.length === 0) return [];
|
|
114
|
+
const chunks = [];
|
|
115
|
+
for (let i = 0; i < str.length; i += size) chunks.push(str.slice(i, i + size));
|
|
116
|
+
return chunks;
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region packages/ag-react/src/ui/image/sixel-encoder.ts
|
|
120
|
+
/**
|
|
121
|
+
* Sixel Encoder (Minimal Implementation)
|
|
122
|
+
*
|
|
123
|
+
* Sixel is an older image protocol supported by terminals like xterm, mlterm,
|
|
124
|
+
* foot, and some others. Images are encoded as DCS (Device Control String)
|
|
125
|
+
* sequences where each character encodes 6 vertical pixels.
|
|
126
|
+
*
|
|
127
|
+
* DCS format: `ESC P <params> q <sixel-data> ESC \`
|
|
128
|
+
*
|
|
129
|
+
* This is a minimal implementation that produces valid Sixel output for
|
|
130
|
+
* simple images. For production use with complex images, consider using
|
|
131
|
+
* a dedicated Sixel library that handles color quantization and dithering.
|
|
132
|
+
*
|
|
133
|
+
* Protocol reference: https://en.wikipedia.org/wiki/Sixel
|
|
134
|
+
*
|
|
135
|
+
* TODO: Full Sixel encoding with proper color quantization, dithering,
|
|
136
|
+
* and compression. The current implementation handles basic RGBA image data
|
|
137
|
+
* with a simple nearest-color palette approach.
|
|
138
|
+
*/
|
|
139
|
+
const DCS_START = "\x1BP";
|
|
140
|
+
const ST = "\x1B\\";
|
|
141
|
+
/** Sixel introduces a color with `#<index>;2;<r>;<g>;<b>` (RGB percentages 0-100) */
|
|
142
|
+
const SIXEL_NEWLINE = "-";
|
|
143
|
+
/**
|
|
144
|
+
* Encode RGBA image data as a Sixel escape sequence.
|
|
145
|
+
*
|
|
146
|
+
* This is a basic implementation that:
|
|
147
|
+
* 1. Quantizes colors to a small palette (up to 256 colors)
|
|
148
|
+
* 2. Encodes 6-row bands as Sixel characters
|
|
149
|
+
* 3. Wraps in a DCS escape sequence
|
|
150
|
+
*
|
|
151
|
+
* For transparent pixels (alpha < 128), the background shows through.
|
|
152
|
+
*
|
|
153
|
+
* @param imageData - Image dimensions and RGBA pixel data
|
|
154
|
+
* @returns A DCS escape sequence containing the Sixel-encoded image
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```ts
|
|
158
|
+
* const img = { width: 10, height: 12, data: new Uint8Array(10 * 12 * 4) }
|
|
159
|
+
* const seq = encodeSixel(img)
|
|
160
|
+
* process.stdout.write(seq)
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
function encodeSixel(imageData) {
|
|
164
|
+
const { width, height, data } = imageData;
|
|
165
|
+
if (width === 0 || height === 0 || data.length === 0) return `${DCS_START}q${ST}`;
|
|
166
|
+
const palette = /* @__PURE__ */ new Map();
|
|
167
|
+
const pixelColors = new Uint16Array(width * height);
|
|
168
|
+
let nextColorIndex = 1;
|
|
169
|
+
for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
|
|
170
|
+
const offset = (y * width + x) * 4;
|
|
171
|
+
const r = data[offset];
|
|
172
|
+
const g = data[offset + 1];
|
|
173
|
+
const b = data[offset + 2];
|
|
174
|
+
if (data[offset + 3] < 128) continue;
|
|
175
|
+
const key = `${r >> 2 & 63},${g >> 2 & 63},${b >> 2 & 63}`;
|
|
176
|
+
let idx = palette.get(key);
|
|
177
|
+
if (idx == null) if (nextColorIndex >= 256) idx = 1;
|
|
178
|
+
else {
|
|
179
|
+
idx = nextColorIndex++;
|
|
180
|
+
palette.set(key, idx);
|
|
181
|
+
}
|
|
182
|
+
pixelColors[y * width + x] = idx;
|
|
183
|
+
}
|
|
184
|
+
const parts = [];
|
|
185
|
+
parts.push(`"1;1;${width};${height}`);
|
|
186
|
+
for (const [key, idx] of palette) {
|
|
187
|
+
const [qr, qg, qb] = key.split(",").map(Number);
|
|
188
|
+
const rPct = Math.round(qr / 63 * 100);
|
|
189
|
+
const gPct = Math.round(qg / 63 * 100);
|
|
190
|
+
const bPct = Math.round(qb / 63 * 100);
|
|
191
|
+
parts.push(`#${idx};2;${rPct};${gPct};${bPct}`);
|
|
192
|
+
}
|
|
193
|
+
for (let bandY = 0; bandY < height; bandY += 6) {
|
|
194
|
+
if (bandY > 0) parts.push(SIXEL_NEWLINE);
|
|
195
|
+
const bandColors = /* @__PURE__ */ new Set();
|
|
196
|
+
for (let dy = 0; dy < 6 && bandY + dy < height; dy++) for (let x = 0; x < width; x++) {
|
|
197
|
+
const ci = pixelColors[(bandY + dy) * width + x];
|
|
198
|
+
if (ci > 0) bandColors.add(ci);
|
|
199
|
+
}
|
|
200
|
+
let first = true;
|
|
201
|
+
for (const colorIdx of bandColors) {
|
|
202
|
+
if (!first) parts.push("$");
|
|
203
|
+
first = false;
|
|
204
|
+
parts.push(`#${colorIdx}`);
|
|
205
|
+
for (let x = 0; x < width; x++) {
|
|
206
|
+
let sixelBits = 0;
|
|
207
|
+
for (let dy = 0; dy < 6; dy++) {
|
|
208
|
+
const y = bandY + dy;
|
|
209
|
+
if (y < height && pixelColors[y * width + x] === colorIdx) sixelBits |= 1 << dy;
|
|
210
|
+
}
|
|
211
|
+
parts.push(String.fromCharCode(sixelBits + 63));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return `${DCS_START}q${parts.join("")}${ST}`;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Check if the current terminal likely supports the Sixel protocol.
|
|
219
|
+
*
|
|
220
|
+
* This is a heuristic based on environment variables. For definitive
|
|
221
|
+
* detection, send a DA1 (Device Attributes) query and check for "4"
|
|
222
|
+
* in the response, but that requires async I/O.
|
|
223
|
+
*
|
|
224
|
+
* Known supporting terminals: xterm (with +sixel), mlterm, foot, mintty,
|
|
225
|
+
* WezTerm, Contour, Sixel-enabled builds of various terminals.
|
|
226
|
+
*
|
|
227
|
+
* @returns `true` if the terminal likely supports Sixel
|
|
228
|
+
*/
|
|
229
|
+
function isSixelSupported() {
|
|
230
|
+
const term = process.env.TERM ?? "";
|
|
231
|
+
const termProgram = process.env.TERM_PROGRAM ?? "";
|
|
232
|
+
if (termProgram === "mlterm" || term.startsWith("mlterm")) return true;
|
|
233
|
+
if (termProgram === "foot" || term === "foot" || term === "foot-extra") return true;
|
|
234
|
+
if (termProgram === "WezTerm") return true;
|
|
235
|
+
if (termProgram === "mintty") return true;
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
//#endregion
|
|
239
|
+
//#region packages/ag-react/src/ui/image/Image.tsx
|
|
240
|
+
/**
|
|
241
|
+
* Image Component
|
|
242
|
+
*
|
|
243
|
+
* Renders bitmap images in supported terminals using the Kitty graphics
|
|
244
|
+
* protocol (primary) or Sixel (fallback). When neither is supported,
|
|
245
|
+
* displays a text placeholder.
|
|
246
|
+
*
|
|
247
|
+
* Since terminal images are escape-sequence-based and don't fit the cell
|
|
248
|
+
* buffer model, the component reserves visual space with a Box of the
|
|
249
|
+
* requested dimensions and uses `useEffect` to write image data directly
|
|
250
|
+
* to stdout after render.
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```tsx
|
|
254
|
+
* import { readFileSync } from "fs"
|
|
255
|
+
* import { Image } from "@silvery/ag-react"
|
|
256
|
+
*
|
|
257
|
+
* const png = readFileSync("photo.png")
|
|
258
|
+
* <Image src={png} width={40} height={20} />
|
|
259
|
+
*
|
|
260
|
+
* // With file path
|
|
261
|
+
* <Image src="/path/to/image.png" width={40} height={20} />
|
|
262
|
+
*
|
|
263
|
+
* // Auto-detect protocol, fall back to text
|
|
264
|
+
* <Image src={png} width={40} height={20} fallback="[photo]" />
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
/**
|
|
268
|
+
* Determine the best available image protocol.
|
|
269
|
+
* Returns null if no image protocol is available.
|
|
270
|
+
*/
|
|
271
|
+
function detectProtocol(preferred) {
|
|
272
|
+
if (preferred === "kitty") return isKittyGraphicsSupported() ? "kitty" : null;
|
|
273
|
+
if (preferred === "sixel") return isSixelSupported() ? "sixel" : null;
|
|
274
|
+
if (isKittyGraphicsSupported()) return "kitty";
|
|
275
|
+
if (isSixelSupported()) return "sixel";
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
/** Incrementing image ID counter for Kitty protocol */
|
|
279
|
+
let nextImageId = 1;
|
|
280
|
+
/**
|
|
281
|
+
* Renders a bitmap image in the terminal.
|
|
282
|
+
*
|
|
283
|
+
* The component operates in two phases:
|
|
284
|
+
* 1. **Layout phase**: Renders a Box that reserves the visual space
|
|
285
|
+
* (filled with spaces so the cell buffer has the right dimensions).
|
|
286
|
+
* 2. **Effect phase**: After render, writes the image escape sequence
|
|
287
|
+
* directly to stdout, positioned over the reserved space.
|
|
288
|
+
*
|
|
289
|
+
* When image protocols are not available, the fallback text is shown instead.
|
|
290
|
+
*/
|
|
291
|
+
function Image({ src, width: requestedWidth, height: requestedHeight, fallback = "[image]", protocol: preferredProtocol = "auto" }) {
|
|
292
|
+
const boxRect = useBoxRect();
|
|
293
|
+
const stdoutCtx = useContext(StdoutContext);
|
|
294
|
+
const imageIdRef = useRef(null);
|
|
295
|
+
const pngData = useMemo(() => {
|
|
296
|
+
if (Buffer.isBuffer(src)) return src;
|
|
297
|
+
try {
|
|
298
|
+
return readFileSync(src);
|
|
299
|
+
} catch {
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
}, [src]);
|
|
303
|
+
const effectiveWidth = requestedWidth ?? boxRect.width;
|
|
304
|
+
const effectiveHeight = requestedHeight ?? Math.max(1, Math.floor(effectiveWidth / 2));
|
|
305
|
+
const activeProtocol = useMemo(() => detectProtocol(preferredProtocol), [preferredProtocol]);
|
|
306
|
+
if (activeProtocol === "kitty" && imageIdRef.current == null) imageIdRef.current = nextImageId++;
|
|
307
|
+
useEffect(() => {
|
|
308
|
+
if (!pngData || !stdoutCtx || !activeProtocol) return;
|
|
309
|
+
if (effectiveWidth <= 0 || effectiveHeight <= 0) return;
|
|
310
|
+
const { write } = stdoutCtx;
|
|
311
|
+
if (activeProtocol === "kitty") write(encodeKittyImage(pngData, {
|
|
312
|
+
width: effectiveWidth,
|
|
313
|
+
height: effectiveHeight,
|
|
314
|
+
id: imageIdRef.current ?? void 0
|
|
315
|
+
}));
|
|
316
|
+
else if (activeProtocol === "sixel") {}
|
|
317
|
+
}, [
|
|
318
|
+
pngData,
|
|
319
|
+
stdoutCtx,
|
|
320
|
+
activeProtocol,
|
|
321
|
+
effectiveWidth,
|
|
322
|
+
effectiveHeight
|
|
323
|
+
]);
|
|
324
|
+
useEffect(() => {
|
|
325
|
+
const id = imageIdRef.current;
|
|
326
|
+
if (activeProtocol !== "kitty" || id == null || !stdoutCtx) return;
|
|
327
|
+
return () => {
|
|
328
|
+
stdoutCtx.write(deleteKittyImage(id));
|
|
329
|
+
};
|
|
330
|
+
}, [activeProtocol, stdoutCtx]);
|
|
331
|
+
if (!activeProtocol || !pngData) return /* @__PURE__ */ jsx("silvery-box", {
|
|
332
|
+
width: effectiveWidth,
|
|
333
|
+
height: effectiveHeight,
|
|
334
|
+
children: /* @__PURE__ */ jsx("silvery-text", { children: fallback })
|
|
335
|
+
});
|
|
336
|
+
const spaceLine = " ".repeat(Math.max(0, effectiveWidth));
|
|
337
|
+
return /* @__PURE__ */ jsx("silvery-box", {
|
|
338
|
+
width: effectiveWidth,
|
|
339
|
+
height: effectiveHeight,
|
|
340
|
+
children: /* @__PURE__ */ jsx("silvery-text", { children: Array.from({ length: Math.max(0, effectiveHeight) }, () => spaceLine).join("\n") })
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
//#endregion
|
|
344
|
+
export { encodeKittyImage as a, deleteKittyImage as i, encodeSixel as n, isKittyGraphicsSupported as o, isSixelSupported as r, Image as t };
|
|
345
|
+
|
|
346
|
+
//# sourceMappingURL=image-Dx7gYjkq.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-Dx7gYjkq.mjs","names":["ST"],"sources":["../packages/ag-react/src/ui/image/kitty-graphics.ts","../packages/ag-react/src/ui/image/sixel-encoder.ts","../packages/ag-react/src/ui/image/Image.tsx"],"sourcesContent":["/**\n * Kitty Graphics Protocol\n *\n * Encodes and manages images using the Kitty terminal graphics protocol.\n * Images are transmitted as base64-encoded PNG data via APC (Application\n * Program Command) escape sequences.\n *\n * Protocol reference: https://sw.kovidgoyal.net/kitty/graphics-protocol/\n *\n * Key concepts:\n * - `a=T` — transmit and display the image\n * - `f=100` — format is PNG (raw PNG data, terminal decodes it)\n * - `m=0|1` — 0 = last/only chunk, 1 = more chunks follow\n * - Chunks should be <= 4096 bytes of base64 to avoid overwhelming the terminal\n * - Images can be assigned an `i=<id>` for later deletion\n */\n\nconst APC_START = \"\\x1b_G\"\nconst ST = \"\\x1b\\\\\"\n\n/** Maximum base64 bytes per chunk (Kitty recommendation) */\nconst MAX_CHUNK_SIZE = 4096\n\nexport interface KittyImageOptions {\n /** Image width in terminal columns */\n width?: number\n /** Image height in terminal rows */\n height?: number\n /** Image ID for later reference/deletion (positive integer) */\n id?: number\n}\n\n/**\n * Encode a PNG image into Kitty graphics protocol escape sequences.\n *\n * The image data is base64-encoded and split into chunks of <= 4096 bytes.\n * Each chunk is wrapped in an APC escape sequence. The first chunk carries\n * the image metadata (action, format, dimensions, ID). Subsequent chunks\n * only carry `m=1` or `m=0` to indicate continuation.\n *\n * @param pngData - Raw PNG image data\n * @param opts - Optional dimensions and ID\n * @returns A string containing the complete escape sequence(s)\n *\n * @example\n * ```ts\n * import { readFileSync } from \"fs\"\n * import { encodeKittyImage } from \"@silvery/ag-react\"\n *\n * const png = readFileSync(\"photo.png\")\n * const seq = encodeKittyImage(png, { width: 40, height: 20 })\n * process.stdout.write(seq)\n * ```\n */\nexport function encodeKittyImage(pngData: Buffer, opts?: KittyImageOptions): string {\n const b64 = pngData.toString(\"base64\")\n const chunks = splitIntoChunks(b64, MAX_CHUNK_SIZE)\n\n if (chunks.length === 0) {\n // Empty image — send a single empty payload\n return `${APC_START}${buildParams(opts, 0)};${ST}`\n }\n\n if (chunks.length === 1) {\n // Single chunk — m=0 (last/only)\n return `${APC_START}${buildParams(opts, 0)};${chunks[0]}${ST}`\n }\n\n // Multiple chunks\n const parts: string[] = []\n\n // First chunk carries full metadata, m=1 (more follows)\n parts.push(`${APC_START}${buildParams(opts, 1)};${chunks[0]}${ST}`)\n\n // Middle chunks — only m=1\n for (let i = 1; i < chunks.length - 1; i++) {\n parts.push(`${APC_START}m=1;${chunks[i]}${ST}`)\n }\n\n // Last chunk — m=0\n parts.push(`${APC_START}m=0;${chunks[chunks.length - 1]}${ST}`)\n\n return parts.join(\"\")\n}\n\n/**\n * Generate an escape sequence to delete a Kitty image by ID.\n *\n * Uses `a=d` (delete) with `d=i` (delete by image ID).\n *\n * @param id - The image ID to delete\n * @returns The delete escape sequence\n *\n * @example\n * ```ts\n * process.stdout.write(deleteKittyImage(42))\n * ```\n */\nexport function deleteKittyImage(id: number): string {\n return `${APC_START}a=d,d=i,i=${id}${ST}`\n}\n\n/**\n * Check if the current terminal likely supports the Kitty graphics protocol.\n *\n * This is a heuristic based on `TERM` and `TERM_PROGRAM` environment variables.\n * For definitive detection, use a terminal query (send the graphics protocol\n * query and check for a response), but that requires async I/O.\n *\n * Known supporting terminals: Kitty, WezTerm, Ghostty (partial), Konsole (partial).\n *\n * @returns `true` if the terminal likely supports Kitty graphics\n */\nexport function isKittyGraphicsSupported(): boolean {\n const term = process.env.TERM ?? \"\"\n const termProgram = process.env.TERM_PROGRAM ?? \"\"\n\n // Kitty terminal\n if (term === \"xterm-kitty\" || termProgram === \"kitty\") return true\n\n // WezTerm supports Kitty graphics protocol\n if (termProgram === \"WezTerm\") return true\n\n // Ghostty supports Kitty graphics\n if (termProgram === \"ghostty\") return true\n\n // Konsole 22.04+ supports Kitty graphics\n if (termProgram === \"konsole\") return true\n\n return false\n}\n\n// ============================================================================\n// Internal helpers\n// ============================================================================\n\n/**\n * Build the Kitty graphics protocol parameter string for the first chunk.\n */\nfunction buildParams(opts: KittyImageOptions | undefined, more: 0 | 1): string {\n const parts = [`a=T`, `f=100`, `m=${more}`]\n\n if (opts?.width != null) parts.push(`s=${opts.width}`)\n if (opts?.height != null) parts.push(`v=${opts.height}`)\n if (opts?.id != null) parts.push(`i=${opts.id}`)\n\n return parts.join(\",\")\n}\n\n/**\n * Split a string into chunks of at most `size` characters.\n */\nfunction splitIntoChunks(str: string, size: number): string[] {\n if (str.length === 0) return []\n\n const chunks: string[] = []\n for (let i = 0; i < str.length; i += size) {\n chunks.push(str.slice(i, i + size))\n }\n return chunks\n}\n","/**\n * Sixel Encoder (Minimal Implementation)\n *\n * Sixel is an older image protocol supported by terminals like xterm, mlterm,\n * foot, and some others. Images are encoded as DCS (Device Control String)\n * sequences where each character encodes 6 vertical pixels.\n *\n * DCS format: `ESC P <params> q <sixel-data> ESC \\`\n *\n * This is a minimal implementation that produces valid Sixel output for\n * simple images. For production use with complex images, consider using\n * a dedicated Sixel library that handles color quantization and dithering.\n *\n * Protocol reference: https://en.wikipedia.org/wiki/Sixel\n *\n * TODO: Full Sixel encoding with proper color quantization, dithering,\n * and compression. The current implementation handles basic RGBA image data\n * with a simple nearest-color palette approach.\n */\n\nconst DCS_START = \"\\x1bP\"\nconst ST = \"\\x1b\\\\\"\n\n/** Sixel introduces a color with `#<index>;2;<r>;<g>;<b>` (RGB percentages 0-100) */\nconst SIXEL_NEWLINE = \"-\"\n\nexport interface SixelImageData {\n /** Image width in pixels */\n width: number\n /** Image height in pixels */\n height: number\n /** RGBA pixel data (4 bytes per pixel: R, G, B, A), row-major order */\n data: Uint8Array\n}\n\n/**\n * Encode RGBA image data as a Sixel escape sequence.\n *\n * This is a basic implementation that:\n * 1. Quantizes colors to a small palette (up to 256 colors)\n * 2. Encodes 6-row bands as Sixel characters\n * 3. Wraps in a DCS escape sequence\n *\n * For transparent pixels (alpha < 128), the background shows through.\n *\n * @param imageData - Image dimensions and RGBA pixel data\n * @returns A DCS escape sequence containing the Sixel-encoded image\n *\n * @example\n * ```ts\n * const img = { width: 10, height: 12, data: new Uint8Array(10 * 12 * 4) }\n * const seq = encodeSixel(img)\n * process.stdout.write(seq)\n * ```\n */\nexport function encodeSixel(imageData: SixelImageData): string {\n const { width, height, data } = imageData\n\n if (width === 0 || height === 0 || data.length === 0) {\n return `${DCS_START}q${ST}`\n }\n\n // Build a simple palette by collecting unique (quantized) colors\n const palette = new Map<string, number>()\n const pixelColors = new Uint16Array(width * height) // palette index per pixel (0 = transparent)\n let nextColorIndex = 1 // 0 reserved for transparent/background\n\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const offset = (y * width + x) * 4\n const r = data[offset]!\n const g = data[offset + 1]!\n const b = data[offset + 2]!\n const a = data[offset + 3]!\n\n if (a < 128) {\n // Transparent — leave as 0\n continue\n }\n\n // Quantize to 6-bit per channel (64 levels) to keep palette small\n const qr = (r >> 2) & 0x3f\n const qg = (g >> 2) & 0x3f\n const qb = (b >> 2) & 0x3f\n const key = `${qr},${qg},${qb}`\n\n let idx = palette.get(key)\n if (idx == null) {\n if (nextColorIndex >= 256) {\n // Palette full — find closest existing color (simple fallback)\n idx = 1\n } else {\n idx = nextColorIndex++\n palette.set(key, idx)\n }\n }\n\n pixelColors[y * width + x] = idx\n }\n }\n\n // Build Sixel data\n const parts: string[] = []\n\n // Raster attributes: Pan;Pad;Ph;Pv (aspect ratio 1:1, width, height)\n parts.push(`\"1;1;${width};${height}`)\n\n // Define palette colors\n for (const [key, idx] of palette) {\n const [qr, qg, qb] = key.split(\",\").map(Number)\n // Convert from 6-bit (0-63) to percentage (0-100)\n const rPct = Math.round((qr! / 63) * 100)\n const gPct = Math.round((qg! / 63) * 100)\n const bPct = Math.round((qb! / 63) * 100)\n parts.push(`#${idx};2;${rPct};${gPct};${bPct}`)\n }\n\n // Encode pixel data in 6-row bands\n for (let bandY = 0; bandY < height; bandY += 6) {\n if (bandY > 0) {\n parts.push(SIXEL_NEWLINE) // Move to next sixel row\n }\n\n // For each color in the palette, emit the sixel row\n // (Only emit colors that appear in this band)\n const bandColors = new Set<number>()\n for (let dy = 0; dy < 6 && bandY + dy < height; dy++) {\n for (let x = 0; x < width; x++) {\n const ci = pixelColors[(bandY + dy) * width + x]!\n if (ci > 0) bandColors.add(ci)\n }\n }\n\n let first = true\n for (const colorIdx of bandColors) {\n if (!first) {\n parts.push(\"$\") // Carriage return within sixel line (reposition to start)\n }\n first = false\n\n parts.push(`#${colorIdx}`)\n\n // Build the sixel characters for this color in this band\n for (let x = 0; x < width; x++) {\n let sixelBits = 0\n for (let dy = 0; dy < 6; dy++) {\n const y = bandY + dy\n if (y < height && pixelColors[y * width + x] === colorIdx) {\n sixelBits |= 1 << dy\n }\n }\n // Sixel character = bits + 63 (0x3F)\n parts.push(String.fromCharCode(sixelBits + 63))\n }\n }\n }\n\n return `${DCS_START}q${parts.join(\"\")}${ST}`\n}\n\n/**\n * Check if the current terminal likely supports the Sixel protocol.\n *\n * This is a heuristic based on environment variables. For definitive\n * detection, send a DA1 (Device Attributes) query and check for \"4\"\n * in the response, but that requires async I/O.\n *\n * Known supporting terminals: xterm (with +sixel), mlterm, foot, mintty,\n * WezTerm, Contour, Sixel-enabled builds of various terminals.\n *\n * @returns `true` if the terminal likely supports Sixel\n */\nexport function isSixelSupported(): boolean {\n const term = process.env.TERM ?? \"\"\n const termProgram = process.env.TERM_PROGRAM ?? \"\"\n\n // mlterm supports Sixel natively\n if (termProgram === \"mlterm\" || term.startsWith(\"mlterm\")) return true\n\n // foot supports Sixel\n if (termProgram === \"foot\" || term === \"foot\" || term === \"foot-extra\") return true\n\n // WezTerm supports Sixel\n if (termProgram === \"WezTerm\") return true\n\n // mintty supports Sixel\n if (termProgram === \"mintty\") return true\n\n // xterm might support Sixel if compiled with +sixel\n // We can't know for sure from env alone, so we don't claim support\n // (the user can set protocol='sixel' explicitly)\n\n return false\n}\n","/**\n * Image Component\n *\n * Renders bitmap images in supported terminals using the Kitty graphics\n * protocol (primary) or Sixel (fallback). When neither is supported,\n * displays a text placeholder.\n *\n * Since terminal images are escape-sequence-based and don't fit the cell\n * buffer model, the component reserves visual space with a Box of the\n * requested dimensions and uses `useEffect` to write image data directly\n * to stdout after render.\n *\n * @example\n * ```tsx\n * import { readFileSync } from \"fs\"\n * import { Image } from \"@silvery/ag-react\"\n *\n * const png = readFileSync(\"photo.png\")\n * <Image src={png} width={40} height={20} />\n *\n * // With file path\n * <Image src=\"/path/to/image.png\" width={40} height={20} />\n *\n * // Auto-detect protocol, fall back to text\n * <Image src={png} width={40} height={20} fallback=\"[photo]\" />\n * ```\n */\n\nimport { readFileSync } from \"node:fs\"\nimport { type JSX, useContext, useEffect, useMemo, useRef } from \"react\"\nimport { StdoutContext } from \"@silvery/ag-react/context\"\nimport { useBoxRect } from \"@silvery/ag-react/hooks/useLayout\"\nimport { encodeKittyImage, isKittyGraphicsSupported, deleteKittyImage } from \"./kitty-graphics\"\nimport { isSixelSupported } from \"./sixel-encoder\"\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type ImageProtocol = \"kitty\" | \"sixel\" | \"auto\"\n\nexport interface ImageProps {\n /** PNG image data (Buffer) or file path (string) to a PNG file */\n src: Buffer | string\n /** Width in terminal columns. If omitted, uses available width from layout. */\n width?: number\n /** Height in terminal rows. If omitted, defaults to half the width (rough aspect ratio). */\n height?: number\n /** Text to display when image rendering is not supported. Default: \"[image]\" */\n fallback?: string\n /** Which protocol to use. Default: \"auto\" (tries Kitty, then Sixel, then fallback) */\n protocol?: ImageProtocol\n}\n\n// ============================================================================\n// Protocol Detection\n// ============================================================================\n\n/**\n * Determine the best available image protocol.\n * Returns null if no image protocol is available.\n */\nfunction detectProtocol(preferred: ImageProtocol): \"kitty\" | \"sixel\" | null {\n if (preferred === \"kitty\") {\n return isKittyGraphicsSupported() ? \"kitty\" : null\n }\n if (preferred === \"sixel\") {\n return isSixelSupported() ? \"sixel\" : null\n }\n\n // Auto-detect: prefer Kitty, fall back to Sixel\n if (isKittyGraphicsSupported()) return \"kitty\"\n if (isSixelSupported()) return \"sixel\"\n return null\n}\n\n// ============================================================================\n// Component\n// ============================================================================\n\n/** Incrementing image ID counter for Kitty protocol */\nlet nextImageId = 1\n\n/**\n * Renders a bitmap image in the terminal.\n *\n * The component operates in two phases:\n * 1. **Layout phase**: Renders a Box that reserves the visual space\n * (filled with spaces so the cell buffer has the right dimensions).\n * 2. **Effect phase**: After render, writes the image escape sequence\n * directly to stdout, positioned over the reserved space.\n *\n * When image protocols are not available, the fallback text is shown instead.\n */\nexport function Image({\n src,\n width: requestedWidth,\n height: requestedHeight,\n fallback = \"[image]\",\n protocol: preferredProtocol = \"auto\",\n}: ImageProps): JSX.Element {\n const boxRect = useBoxRect()\n const stdoutCtx = useContext(StdoutContext)\n const imageIdRef = useRef<number | null>(null)\n\n // Resolve image data\n const pngData = useMemo(() => {\n if (Buffer.isBuffer(src)) return src\n // String path — read file synchronously (during render is fine for a path)\n try {\n return readFileSync(src)\n } catch {\n return null\n }\n }, [src])\n\n // Determine effective dimensions\n const effectiveWidth = requestedWidth ?? boxRect.width\n const effectiveHeight = requestedHeight ?? Math.max(1, Math.floor(effectiveWidth / 2))\n\n // Detect protocol support\n const activeProtocol = useMemo(() => detectProtocol(preferredProtocol), [preferredProtocol])\n\n // Assign a stable image ID for Kitty (for cleanup on unmount)\n if (activeProtocol === \"kitty\" && imageIdRef.current == null) {\n imageIdRef.current = nextImageId++\n }\n\n // Write image escape sequences after render\n useEffect(() => {\n if (!pngData || !stdoutCtx || !activeProtocol) return\n if (effectiveWidth <= 0 || effectiveHeight <= 0) return\n\n const { write } = stdoutCtx\n\n if (activeProtocol === \"kitty\") {\n const seq = encodeKittyImage(pngData, {\n width: effectiveWidth,\n height: effectiveHeight,\n id: imageIdRef.current ?? undefined,\n })\n write(seq)\n } else if (activeProtocol === \"sixel\") {\n // For Sixel, we would need the decoded pixel data.\n // Since we receive PNG, and decoding PNG requires a library,\n // Sixel rendering from raw PNG is deferred. The Kitty protocol\n // can transmit PNG directly (f=100), but Sixel cannot.\n // For now, Sixel only works if src is already decoded pixel data.\n // This is a known limitation noted in the module docs.\n //\n // If someone passes a Buffer that's already RGBA pixel data\n // (not PNG), this would need a flag. For now, Sixel falls through\n // to fallback when src is PNG.\n }\n }, [pngData, stdoutCtx, activeProtocol, effectiveWidth, effectiveHeight])\n\n // Cleanup: delete Kitty image on unmount\n useEffect(() => {\n const id = imageIdRef.current\n if (activeProtocol !== \"kitty\" || id == null || !stdoutCtx) return\n\n return () => {\n stdoutCtx.write(deleteKittyImage(id))\n }\n }, [activeProtocol, stdoutCtx])\n\n // If no protocol or no image data, render fallback text\n if (!activeProtocol || !pngData) {\n return (\n <silvery-box width={effectiveWidth} height={effectiveHeight}>\n <silvery-text>{fallback}</silvery-text>\n </silvery-box>\n )\n }\n\n // Reserve visual space with an empty box.\n // The image is drawn over this space via stdout escape sequences.\n // Fill with spaces so the cell buffer allocates the right area.\n const spaceLine = \" \".repeat(Math.max(0, effectiveWidth))\n const spaceContent = Array.from({ length: Math.max(0, effectiveHeight) }, () => spaceLine).join(\"\\n\")\n\n return (\n <silvery-box width={effectiveWidth} height={effectiveHeight}>\n <silvery-text>{spaceContent}</silvery-text>\n </silvery-box>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAM,YAAY;AAClB,MAAMA,OAAK;;AAGX,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;AAiCvB,SAAgB,iBAAiB,SAAiB,MAAkC;CAElF,MAAM,SAAS,gBADH,QAAQ,SAAS,SAAS,EACF,eAAe;AAEnD,KAAI,OAAO,WAAW,EAEpB,QAAO,GAAG,YAAY,YAAY,MAAM,EAAE,CAAC,GAAGA;AAGhD,KAAI,OAAO,WAAW,EAEpB,QAAO,GAAG,YAAY,YAAY,MAAM,EAAE,CAAC,GAAG,OAAO,KAAKA;CAI5D,MAAM,QAAkB,EAAE;AAG1B,OAAM,KAAK,GAAG,YAAY,YAAY,MAAM,EAAE,CAAC,GAAG,OAAO,KAAKA,OAAK;AAGnE,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,SAAS,GAAG,IACrC,OAAM,KAAK,GAAG,UAAU,MAAM,OAAO,KAAKA,OAAK;AAIjD,OAAM,KAAK,GAAG,UAAU,MAAM,OAAO,OAAO,SAAS,KAAKA,OAAK;AAE/D,QAAO,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;AAgBvB,SAAgB,iBAAiB,IAAoB;AACnD,QAAO,GAAG,UAAU,YAAY,KAAKA;;;;;;;;;;;;;AAcvC,SAAgB,2BAAoC;CAClD,MAAM,OAAO,QAAQ,IAAI,QAAQ;CACjC,MAAM,cAAc,QAAQ,IAAI,gBAAgB;AAGhD,KAAI,SAAS,iBAAiB,gBAAgB,QAAS,QAAO;AAG9D,KAAI,gBAAgB,UAAW,QAAO;AAGtC,KAAI,gBAAgB,UAAW,QAAO;AAGtC,KAAI,gBAAgB,UAAW,QAAO;AAEtC,QAAO;;;;;AAUT,SAAS,YAAY,MAAqC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