hopdeck 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.en.md +2 -1
- package/README.md +2 -1
- package/THIRD_PARTY_NOTICES.md +4 -0
- package/bin/hopdeck.js +84 -20
- package/lib/i18n.js +2 -0
- package/lib/sixel.js +90 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Cambios
|
|
2
2
|
|
|
3
|
+
## 1.2.4
|
|
4
|
+
|
|
5
|
+
### Nuevo
|
|
6
|
+
- **Logotipo con el texto convertido a trazados** (Inter 800): se ve igual en cualquier equipo y en la página de npm, sin depender de la fuente instalada. Se añaden copias PNG en `docs/`.
|
|
7
|
+
- **Imagen real al pasar el cursor por `[Image #N]`** en terminales con Sixel (Windows Terminal 1.22 o posterior, iTerm2, WezTerm, foot, Konsole…). Hopdeck pregunta al terminal si lo admite y, si es así, dibuja la imagen con todos sus píxeles dentro del cuadro del hover; el texto del chat que queda debajo se repinta al apartar el cursor. Si no lo admite se mantiene la vista de bloques. `HOPDECK_SIXEL=1` lo fuerza y `HOPDECK_SIXEL=0` lo desactiva.
|
|
8
|
+
- **Clic en `[Image #N]` abre la imagen en grande** en el visor de imágenes del sistema, a su tamaño real. La vista rápida del terminal solo puede dibujar dos píxeles por carácter: una captura de pantalla de 1917 px de ancho quedaba en unos 50 y no se podía leer. Arrastrar para copiar texto y hacer clic en otro texto siguen igual. El cuadro del hover avisa («clic: abrir en grande») y es algo más grande.
|
|
9
|
+
|
|
3
10
|
## 1.2.3
|
|
4
11
|
|
|
5
12
|
### Cambiado
|
package/README.en.md
CHANGED
|
@@ -130,7 +130,7 @@ It always starts at `~`. Recently used folders appear on top (`↻ recent`).
|
|
|
130
130
|
|
|
131
131
|
![Floating box with the image when hovering [Image #1]](docs/screenshots/04-hover-imagen.svg)
|
|
132
132
|
|
|
133
|
-
- If a chat shows `[Image #3]` (an image you already sent), **hover it** and a
|
|
133
|
+
- If a chat shows `[Image #3]` (an image you already sent), **hover it** and a quick preview appears without covering the rest of the chat. A terminal can only draw a small version (two pixels per character), so a screenshot with text is not legible: **click the marker** and it opens full size, at its real resolution, in your system's image viewer.
|
|
134
134
|
- `i` / `F7` opens a **gallery** with all the conversation's images (`← →` navigate, `o` opens it in the system viewer, `Esc` closes).
|
|
135
135
|
- An image you just pasted and have not sent yet **cannot** be shown: it is not in the history yet.
|
|
136
136
|
|
|
@@ -180,6 +180,7 @@ You almost never need to change anything. The most useful options:
|
|
|
180
180
|
|---|---|
|
|
181
181
|
| `HOPDECK_LANG` | `es` or `en` (default: system language) |
|
|
182
182
|
| `HOPDECK_THEME` | `light` for light backgrounds |
|
|
183
|
+
| `HOPDECK_SIXEL` | `1` forces the real image when hovering `[Image #N]`, `0` always uses blocks (auto-detected by default) |
|
|
183
184
|
| `NO_COLOR` | Disable colors |
|
|
184
185
|
| `CLAUDE_CONFIG_DIR` | Claude Code folder, if it is not `~/.claude` |
|
|
185
186
|
| `HOPDECK_SKIP=1` | Skip Hopdeck once: `HOPDECK_SKIP=1 claude` |
|
package/README.md
CHANGED
|
@@ -130,7 +130,7 @@ Empieza siempre en `~`. Las carpetas que usaste hace poco aparecen arriba (`↻
|
|
|
130
130
|
|
|
131
131
|
![Cuadro flotante con la imagen al pasar el cursor por [Image #1]](docs/screenshots/04-hover-imagen.svg)
|
|
132
132
|
|
|
133
|
-
- Si en un chat ves `[Image #3]` (una imagen que ya enviaste), **pasa el cursor por encima** y aparece
|
|
133
|
+
- Si en un chat ves `[Image #3]` (una imagen que ya enviaste), **pasa el cursor por encima** y aparece una vista rápida, sin tapar el resto del chat. En un terminal solo se puede dibujar una versión pequeña (dos píxeles por carácter), así que una captura con texto no se lee: **haz clic sobre la marca** y se abre en grande, a su tamaño real, en el visor de imágenes de tu sistema.
|
|
134
134
|
- `i` / `F7` abre una **galería** con todas las imágenes de la conversación (`← →` navegan, `o` la abre en el visor del sistema, `Esc` cierra).
|
|
135
135
|
- Una imagen recién pegada y aún sin enviar **no** se puede mostrar: todavía no está en el historial.
|
|
136
136
|
|
|
@@ -180,6 +180,7 @@ Casi nunca hace falta tocar nada. Lo más útil:
|
|
|
180
180
|
|---|---|
|
|
181
181
|
| `HOPDECK_LANG` | `es` o `en` (por defecto, el idioma del sistema) |
|
|
182
182
|
| `HOPDECK_THEME` | `light` para fondos claros |
|
|
183
|
+
| `HOPDECK_SIXEL` | `1` fuerza la imagen real al pasar el cursor por `[Image #N]`, `0` usa siempre bloques (por defecto se detecta) |
|
|
183
184
|
| `NO_COLOR` | Quita los colores |
|
|
184
185
|
| `CLAUDE_CONFIG_DIR` | Carpeta de Claude Code, si no es `~/.claude` |
|
|
185
186
|
| `HOPDECK_SKIP=1` | Salta Hopdeck una vez: `HOPDECK_SKIP=1 claude` |
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -11,6 +11,10 @@ y cada una conserva su propia licencia.
|
|
|
11
11
|
|
|
12
12
|
Ninguna dependencia ejecuta scripts de instalación (`npm audit`: 0 vulnerabilidades conocidas a la fecha de la versión 1.2.0).
|
|
13
13
|
|
|
14
|
+
## Tipografía del logotipo
|
|
15
|
+
|
|
16
|
+
El texto de `docs/logo-*.svg` y `docs/logo-*.png` está convertido a trazados a partir de la fuente [Inter](https://rsms.me/inter/) (peso 800), con licencia SIL Open Font License 1.1, que permite este uso. No se distribuye la fuente.
|
|
17
|
+
|
|
14
18
|
## Marcas
|
|
15
19
|
|
|
16
20
|
"Claude" y "Claude Code" son marcas de Anthropic, PBC. Este proyecto es independiente: **no está afiliado, respaldado ni patrocinado por Anthropic**.
|
package/bin/hopdeck.js
CHANGED
|
@@ -17,6 +17,7 @@ const { baseName, tidy, home, shortPath, fuzzy, wrapText } = require('../lib/tex
|
|
|
17
17
|
const hist = require('../lib/history');
|
|
18
18
|
const { CONFIG_DIR, CACHE_FILE, textOf, isType, cacheLoad, cacheSave, readSession, decodeDir, projectDirs, buildProject, beginScan, endScan } = hist;
|
|
19
19
|
const images = require('../lib/images');
|
|
20
|
+
const { encodeSixel } = require('../lib/sixel');
|
|
20
21
|
const { collectImages, decodePNG, decodeImage, scaleBox, fitSize, halfBlocks } = images;
|
|
21
22
|
const { parseKeys, KEYMAP, printable, editBuf, normalizeKeys } = require('../lib/keys');
|
|
22
23
|
const { stripJsonc, wtCtrlV, wtSettingsFile } = require('../lib/windows-terminal');
|
|
@@ -126,7 +127,7 @@ function ago(ms) {
|
|
|
126
127
|
const S = { qpos: 0, pc: 0, fb: null, confirmMk: null, confirmClose: null, more: new Set(), qs: null, promptKind: 'folder', renameTarget: null, deep: false, deepHits: null, showHidden: false, prompt: null, help: false, loading: false, projects: [], pi: 0, si: 0, focus: 0, query: '', searching: false, poff: 0, soff: 0, flash: '', c: 0, coff: 0, open: null, live: new Set(), liveKey: '' };
|
|
127
128
|
const SIDEBAR = process.argv.includes('--sidebar');
|
|
128
129
|
let EMBED = false; // vista dividida con terminal embebido (Windows / sin tmux)
|
|
129
|
-
const E = { sessions: new Map(), shown: null, focus: 'left', pend: null, deps: null, mouse: CFG.mouse !== false, hideSide: false, note: null, sel: null, gallery: null, hover: null };
|
|
130
|
+
const E = { sessions: new Map(), shown: null, focus: 'left', pend: null, deps: null, mouse: CFG.mouse !== false, hideSide: false, note: null, sel: null, gallery: null, hover: null, sixelDetected: false, cell: { w: 10, h: 20 }, sixelKey: null, sixelAt: 0, sixelStale: false, sixelRetry: null };
|
|
130
131
|
const SPIN = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
131
132
|
let spinT = null, frameN = 0, reloading = false;
|
|
132
133
|
const needsSpin = () => S.loading || (E.gallery && (E.gallery.loading || E.gallery.pending)) || (E.hover && E.hover.g.pending) || [...E.sessions.values()].some((x) => x.working || (!x.ready && x === E.sessions.get(E.shown)));
|
|
@@ -906,6 +907,7 @@ async function imagesOf(x) {
|
|
|
906
907
|
|
|
907
908
|
/** Abre un archivo o carpeta con el programa por defecto del sistema. */
|
|
908
909
|
function openExternal(target) {
|
|
910
|
+
if (process.env.HOPDECK_OPEN_LOG) { try { fs.appendFileSync(process.env.HOPDECK_OPEN_LOG, target + '\n'); } catch { /* */ } return; } // pruebas: no se abre ningún visor
|
|
909
911
|
const quiet = (cmd, args) => { try { const c = cp.spawn(cmd, args, { stdio: 'ignore', detached: true, windowsHide: true }); c.on('error', () => {}); c.unref(); } catch { /* */ } };
|
|
910
912
|
if (WIN) quiet('cmd', ['/c', 'start', '', target]);
|
|
911
913
|
else if (process.platform === 'darwin') quiet('open', [target]);
|
|
@@ -960,6 +962,26 @@ async function shownSession(x) {
|
|
|
960
962
|
return sess;
|
|
961
963
|
}
|
|
962
964
|
|
|
965
|
+
// ── Imágenes reales (Sixel): se usan si el terminal las admite; si no, la vista rápida con medios bloques ──
|
|
966
|
+
/** HOPDECK_SIXEL=1 las fuerza, =0 las apaga; sin definir, se usan si el terminal dijo que las admite (consulta DA1 al arrancar). */
|
|
967
|
+
const sixelOn = () => process.env.HOPDECK_SIXEL === '1' || (process.env.HOPDECK_SIXEL !== '0' && E.sixelDetected);
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* Quita de la entrada las respuestas del terminal a nuestras consultas y las guarda en `st`:
|
|
971
|
+
* DA1 (ESC [ ? 61;4;… c): el atributo 4 significa que admite Sixel; y el tamaño en píxeles de una celda (ESC [ 6 ; alto ; ancho t).
|
|
972
|
+
*/
|
|
973
|
+
function parseTermReplies(s, st) {
|
|
974
|
+
return s
|
|
975
|
+
.replace(/\x1b\[\?([0-9;]*)c/g, (m, attrs) => { st.sixelDetected = attrs.split(';').includes('4'); return ''; })
|
|
976
|
+
.replace(/\x1b\[6;(\d+);(\d+)t/g, (m, hh, ww) => { const h = +hh, w = +ww; if (h >= 4 && h <= 200 && w >= 2 && w <= 100) st.cell = { w, h }; return ''; });
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
/** Secuencia que coloca el cursor y dibuja la imagen. Con HOPDECK_SIXEL_LOG (pruebas) la ruta y los datos se anotan en un archivo y no se escribe nada. */
|
|
980
|
+
function emitSixel(row, col, data) {
|
|
981
|
+
if (process.env.HOPDECK_SIXEL_LOG) { try { fs.appendFileSync(process.env.HOPDECK_SIXEL_LOG, JSON.stringify({ row, col, data }) + '\n'); } catch { /* */ } return ''; }
|
|
982
|
+
return `\x1b[${row};${col}H` + data;
|
|
983
|
+
}
|
|
984
|
+
|
|
963
985
|
/** Texto de una fila del terminal virtual y la columna de cada carácter (los de ancho 2 ocupan dos celdas). */
|
|
964
986
|
function rowChars(term, y) {
|
|
965
987
|
const b = term.buffer.active, line = b.getLine(b.viewportY + y), cols = []; let text = '';
|
|
@@ -1001,9 +1023,16 @@ function hoverPopup(hv, rw, th) {
|
|
|
1001
1023
|
setImmediate(() => { let d = false; try { d = decodeImage(img) || false; } catch { d = false; } g.dec.set(0, d); g.pending = false; if (active) render(); });
|
|
1002
1024
|
}
|
|
1003
1025
|
const d = g.dec.get(0), lab = ` [Image #${hv.n}] `;
|
|
1004
|
-
let rows, tw;
|
|
1005
|
-
if (d && d.rgba) {
|
|
1006
|
-
const
|
|
1026
|
+
let rows, tw, sx = null;
|
|
1027
|
+
if (d && d.rgba && sixelOn()) { // imagen real: se deja un hueco en blanco del tamaño de la imagen y se dibuja encima con Sixel
|
|
1028
|
+
const cw = E.cell.w, ch = E.cell.h, maxCols = Math.max(8, Math.min(rw - 6, 140)), maxRows = Math.max(2, th - 5);
|
|
1029
|
+
const k = Math.min((maxCols * cw) / d.w, (maxRows * ch) / d.h, 3);
|
|
1030
|
+
const iw = Math.max(1, Math.min(maxCols, Math.round((d.w * k) / cw))), ih = Math.max(1, Math.min(maxRows, Math.round((d.h * k) / ch))), key = `sx:${iw}x${ih}`;
|
|
1031
|
+
let data = g.cache.get(key);
|
|
1032
|
+
if (!data) { data = encodeSixel(scaleBox(d.rgba, d.w, d.h, iw * cw, ih * ch), iw * cw, ih * ch); g.cache.clear(); g.cache.set(key, data); }
|
|
1033
|
+
sx = { data, iw, ih, key }; tw = iw; rows = Array.from({ length: ih }, () => ' '.repeat(iw));
|
|
1034
|
+
} else if (d && d.rgba) {
|
|
1035
|
+
const sz = fitSize(d.w, d.h, Math.max(8, Math.min(rw - 6, 96)), Math.max(2, Math.min(th - 6, 18)) * 2), key = `${sz.tw}x${sz.th}`;
|
|
1007
1036
|
let hb = g.cache.get(key);
|
|
1008
1037
|
if (!hb) { hb = halfBlocks(scaleBox(d.rgba, d.w, d.h, sz.tw, sz.th), sz.tw, sz.th); g.cache.clear(); g.cache.set(key, hb); }
|
|
1009
1038
|
rows = hb; tw = sz.tw;
|
|
@@ -1014,12 +1043,39 @@ function hoverPopup(hv, rw, th) {
|
|
|
1014
1043
|
}
|
|
1015
1044
|
const label = strW(lab) <= tw - 1 ? lab : '', b = C.accent;
|
|
1016
1045
|
const box = [b + '╭─' + label + '─'.repeat(Math.max(0, tw - 1 - strW(label))) + '╮' + R,
|
|
1017
|
-
...rows.map((r) => b + '│' + R + r + b + '│' + R),
|
|
1046
|
+
...rows.map((r) => b + '│' + R + r + b + '│' + R),
|
|
1047
|
+
(() => { const h = ` ${T.imgClickHint} `; return strW(h) <= tw - 1 ? b + '╰─' + C.dim + h + b + '─'.repeat(tw - 1 - strW(h)) + '╯' + R : b + '╰' + '─'.repeat(tw) + '╯' + R; })()];
|
|
1018
1048
|
const bw = tw + 2, bh = box.length, left = clamp(hv.at.x, 0, Math.max(0, rw - bw));
|
|
1019
1049
|
let top = hv.at.y + 1; // debajo de la marca; si no cabe, encima; si tampoco, pegado al borde
|
|
1020
1050
|
if (top + bh > th) top = hv.at.y - bh;
|
|
1021
1051
|
if (top < 0) top = Math.max(0, th - bh);
|
|
1022
|
-
return { left, top, bw, rows: box };
|
|
1052
|
+
return { left, top, bw, rows: box, sixel: sx ? { ...sx, key: `${hv.k}|${sx.key}|${left},${top}` } : null };
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
/** La imagen que corresponde a "[Image #n]" en la conversación de este chat, o null si aún no está en el historial. */
|
|
1056
|
+
async function imageForMarker(sh, n) {
|
|
1057
|
+
try {
|
|
1058
|
+
const sess = await shownSession(sh);
|
|
1059
|
+
if (!sess) return null;
|
|
1060
|
+
const imgs = await imagesOf(sess);
|
|
1061
|
+
let img = imgs.find((im) => im.n === n) || (imgs.some((im) => im.n) ? null : imgs[n - 1]) || null;
|
|
1062
|
+
if (!img && imgs.length >= maxImages()) img = await images.findImageByNumber(sess.file, n); // pasó el límite de la galería: se busca en todo el archivo
|
|
1063
|
+
return img;
|
|
1064
|
+
} catch { return null; }
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
/**
|
|
1068
|
+
* Clic en un "[Image #N]": abre esa imagen en el visor del sistema, a su tamaño real. En el terminal solo se puede dibujar una
|
|
1069
|
+
* vista rápida (dos píxeles por carácter): una captura de pantalla con texto de 1917 px de ancho queda en unos 50 y no se lee.
|
|
1070
|
+
*/
|
|
1071
|
+
async function openMarkerImage(sh, n) {
|
|
1072
|
+
const img = await imageForMarker(sh, n);
|
|
1073
|
+
const note = (t) => { E.note = { t, until: Date.now() + 2500 }; scheduleRender(); };
|
|
1074
|
+
if (!img) return note(T.hoverMiss(n));
|
|
1075
|
+
const { files } = exportImages([img]);
|
|
1076
|
+
if (!files[0]) return note(T.imgNoPrev); // no es una imagen reconocible: no se abre
|
|
1077
|
+
openExternal(files[0]);
|
|
1078
|
+
note(T.imgOpened(n));
|
|
1023
1079
|
}
|
|
1024
1080
|
|
|
1025
1081
|
function hoverChat(sh, x, y) {
|
|
@@ -1035,15 +1091,7 @@ function hoverChat(sh, x, y) {
|
|
|
1035
1091
|
const hv = { n, k, at, g: { project: sh.project, title: sh.title, images: [], i: 0, loading: true, pending: false, dec: new Map(), cache: new Map() } };
|
|
1036
1092
|
E.hover = hv; scheduleRender();
|
|
1037
1093
|
(async () => {
|
|
1038
|
-
|
|
1039
|
-
try {
|
|
1040
|
-
const sess = await shownSession(sh);
|
|
1041
|
-
if (sess) {
|
|
1042
|
-
const imgs = await imagesOf(sess);
|
|
1043
|
-
img = imgs.find((im) => im.n === n) || (imgs.some((im) => im.n) ? null : imgs[n - 1]) || null;
|
|
1044
|
-
if (!img && imgs.length >= maxImages()) img = await images.findImageByNumber(sess.file, n); // pasó el límite de la galería: se busca en todo el archivo
|
|
1045
|
-
}
|
|
1046
|
-
} catch { img = null; }
|
|
1094
|
+
const img = await imageForMarker(sh, n);
|
|
1047
1095
|
if (E.hover !== hv) return; // el cursor ya se fue
|
|
1048
1096
|
if (!img) { hv.g.loading = false; E.note = { t: T.hoverMiss(n), until: Date.now() + 2000 }; return scheduleRender(); }
|
|
1049
1097
|
hv.g.images = [img]; hv.g.loading = false; scheduleRender();
|
|
@@ -1179,12 +1227,22 @@ function renderEmbed() {
|
|
|
1179
1227
|
...k('F1', T.bar1), ...k('F2', T.bar2), ...k('F3', E.mouse ? T.bar4 : T.bar5), ...k('F4', E.hideSide ? T.bar7 : T.bar6),
|
|
1180
1228
|
[live ? '● ' + live : '', C.ok]], W));
|
|
1181
1229
|
const changes = diffRows(rowsOut);
|
|
1230
|
+
// imagen real (Sixel) sobre el hueco del cuadro: se dibuja al aparecer y se repite si algo reescribe esas filas (con un mínimo de 150 ms entre dibujos)
|
|
1231
|
+
let sx = '';
|
|
1232
|
+
if (pop && pop.sixel) {
|
|
1233
|
+
const top = pop.top + 3, touched = lastChanged.some((y) => y >= top && y < top + pop.sixel.ih);
|
|
1234
|
+
if (E.sixelKey !== pop.sixel.key || touched || E.sixelStale) {
|
|
1235
|
+
const now = Date.now();
|
|
1236
|
+
if (E.sixelKey === pop.sixel.key && now - E.sixelAt < 150) { E.sixelStale = true; if (!E.sixelRetry) E.sixelRetry = setTimeout(() => { E.sixelRetry = null; scheduleRender(); }, 160); }
|
|
1237
|
+
else { sx = emitSixel(pop.top + 4, (SW ? SW + 2 : 1) + pop.left + 1, pop.sixel.data); E.sixelKey = pop.sixel.key; E.sixelAt = now; E.sixelStale = false; }
|
|
1238
|
+
}
|
|
1239
|
+
} else if (E.sixelKey) { E.sixelKey = null; E.sixelStale = false; } // al quitar el cuadro, las filas que cubría ya se reescriben solas con el texto del chat
|
|
1182
1240
|
let cur = '';
|
|
1183
1241
|
if (sh && sh.ready && E.focus === 'right' && !sh.cursorHidden && back === 0) {
|
|
1184
1242
|
const b = sh.term.buffer.active;
|
|
1185
1243
|
cur = `\x1b[${Math.min(th, b.cursorY + 1) + 2};${(SW ? SW + 1 : 0) + 1 + Math.min(rw - 1, b.cursorX)}H\x1b[?25h`;
|
|
1186
1244
|
}
|
|
1187
|
-
process.stdout.write((changes ? '\x1b[?2026h\x1b[?25l' + changes : '\x1b[?25l') + cur + (changes ? '\x1b[?2026l' : ''));
|
|
1245
|
+
process.stdout.write((changes || sx ? '\x1b[?2026h\x1b[?25l' + changes + sx : '\x1b[?25l') + cur + (changes || sx ? '\x1b[?2026l' : ''));
|
|
1188
1246
|
}
|
|
1189
1247
|
|
|
1190
1248
|
function scheduleRender() {
|
|
@@ -1340,6 +1398,10 @@ function onMouse(b, x, y, type) {
|
|
|
1340
1398
|
if ((b & 32) && (b & 3) === 0) { if (E.sel && E.sel.down) { E.sel.b = cell(); render(); } return; } // arrastre
|
|
1341
1399
|
if (type === 'm') { // soltar: copiar la selección
|
|
1342
1400
|
const sl = E.sel; E.sel = null;
|
|
1401
|
+
if (sl && sl.down && sl.a.x === sl.b.x && sl.a.y === sl.b.y && sh && sh.ready) { // un clic sin arrastrar: si es sobre un [Image #N], se abre la imagen
|
|
1402
|
+
const hit = imageMarkerAt(sh.term, sl.a.y, sl.a.x);
|
|
1403
|
+
if (hit) openMarkerImage(sh, hit.n);
|
|
1404
|
+
}
|
|
1343
1405
|
if (sl && sl.down && (sl.a.x !== sl.b.x || sl.a.y !== sl.b.y) && sh) {
|
|
1344
1406
|
const t = selText(sh, sl);
|
|
1345
1407
|
if (t) { copyText(t); E.note = { t: T.copied(t.length), until: Date.now() + 3000 }; }
|
|
@@ -1457,10 +1519,11 @@ function embedKillAll() { for (const sess of E.sessions.values()) { try { sess.p
|
|
|
1457
1519
|
// Redibujado diferencial: solo se reescriben las filas que cambiaron desde el último cuadro.
|
|
1458
1520
|
let lastRows = [], forceFull = true;
|
|
1459
1521
|
const invalidate = () => { forceFull = true; };
|
|
1522
|
+
let lastChanged = []; // índices de las filas que reescribió el último diffRows (si pisan una imagen Sixel hay que volver a dibujarla)
|
|
1460
1523
|
function diffRows(rows) {
|
|
1461
|
-
let out = '';
|
|
1524
|
+
let out = ''; lastChanged = [];
|
|
1462
1525
|
for (let i = 0; i < rows.length; i++) {
|
|
1463
|
-
if (forceFull || lastRows[i] !== rows[i]) out += `\x1b[${i + 1};1H` + rows[i];
|
|
1526
|
+
if (forceFull || lastRows[i] !== rows[i]) { out += `\x1b[${i + 1};1H` + rows[i]; lastChanged.push(i); }
|
|
1464
1527
|
}
|
|
1465
1528
|
lastRows = rows.slice(); forceFull = false;
|
|
1466
1529
|
return out;
|
|
@@ -1480,7 +1543,7 @@ function render() {
|
|
|
1480
1543
|
let active = false;
|
|
1481
1544
|
function enter() {
|
|
1482
1545
|
if (active) return; active = true; invalidate();
|
|
1483
|
-
process.stdout.write('\x1b[?1049h\x1b[?25l\x1b[2J' + ((EMBED || SIDEBAR) && E.mouse ? mouseModes(true) : ''));
|
|
1546
|
+
process.stdout.write('\x1b[?1049h\x1b[?25l\x1b[2J' + ((EMBED || SIDEBAR) && E.mouse ? mouseModes(true) : '') + (EMBED && process.env.HOPDECK_SIXEL !== '0' ? '\x1b[c\x1b[16t' : '')); // consulta: ¿admite imágenes (Sixel)? ¿qué tamaño tiene una celda?
|
|
1484
1547
|
process.stdin.setRawMode(true); process.stdin.resume();
|
|
1485
1548
|
}
|
|
1486
1549
|
function leave() {
|
|
@@ -1653,6 +1716,7 @@ async function run() {
|
|
|
1653
1716
|
process.stdin.on('data', (buf) => {
|
|
1654
1717
|
if (!active) return;
|
|
1655
1718
|
let s = normalizeKeys(buf.toString('utf8'));
|
|
1719
|
+
if (EMBED) { s = parseTermReplies(s, E); if (!s) return; } // respuestas del terminal a las consultas del arranque
|
|
1656
1720
|
if (EMBED) {
|
|
1657
1721
|
s = s.replace(/\x1b\[<(\d+);(\d+);(\d+)([Mm])/g, (m, b, x, y, t) => { onMouse(+b, +x, +y, t); return ''; });
|
|
1658
1722
|
if (!s) return;
|
|
@@ -1992,7 +2056,7 @@ else {
|
|
|
1992
2056
|
module.exports = {
|
|
1993
2057
|
cw, strW, fit, clean, imageExt, exportImages, safeId, findClaude, install, backupProfile, ago, tidy, fuzzy, wrapText, parseKeys, KEYMAP, isType, T, S, CFG, E,
|
|
1994
2058
|
readSession, buildProject, scan, scanAsync, finishScan, sortProjects, projectDirs,
|
|
1995
|
-
view, flatList, stripBlock, offerShortcut, uninstallAll, commandName, suggestCommand, SNIP, MARK_A, MARK_B, toggleProject, cacheLoad, selNorm,
|
|
2059
|
+
view, flatList, stripBlock, offerShortcut, uninstallAll, commandName, suggestCommand, parseTermReplies, sixelOn, SNIP, MARK_A, MARK_B, toggleProject, cacheLoad, selNorm,
|
|
1996
2060
|
decodePNG, decodeImage, scaleBox, fitSize, halfBlocks, collectImages, extractImages,
|
|
1997
2061
|
editBuf, normalizeKeys, stripJsonc, wtCtrlV, fbNames, fbOpen, fbRows, sidebarMouse, gitBranch, imageMarkerAt, shownSession, linkChats, findImageByNumber: images.findImageByNumber,
|
|
1998
2062
|
};
|
package/lib/i18n.js
CHANGED
|
@@ -20,6 +20,7 @@ const T = {
|
|
|
20
20
|
copied: (n) => `Copiado (${n} caracteres)`, archMsg: 'Archivada (H para verlas)', unarchMsg: 'Desarchivada', qsHint: 'saltar a cualquier conversación',
|
|
21
21
|
prevHint: '⏎ reanudar esta conversación', noPrev: 'Sin mensajes para mostrar',
|
|
22
22
|
bar6: 'ocultar lista', bar7: 'mostrar lista', deep: 'contenido', pathPrompt: 'nombre de la nueva carpeta', mkIn: 'se crea en', fbTitle: 'Elegir carpeta', fbHere: 'Abrir chat aquí', fbNew: 'Nueva carpeta aquí…', fbUp: 'Subir un nivel', fbProj: 'proyecto', fbHint: '⏎ entrar · ␣ abrir · / buscar · . ocultas', fbDrives: 'Este equipo', fbRecent: 'reciente', hoverMiss: (n) => `[Image #${n}]: aún no está en el historial`, fbEmpty: 'Sin subcarpetas', badId: 'Identificador de sesión no válido',
|
|
23
|
+
imgClickHint: 'clic: abrir en grande', imgOpened: (n) => `[Image #${n}] abierta en el visor de imágenes`,
|
|
23
24
|
unknownCmd: (c) => `Comando desconocido: "${c}"`, didYouMean: (s) => `¿Quisiste decir "${s}"?`, cmdList: 'Comandos: hopdeck shortcut on|off · uninstall · doctor · help (y --list, --version).\nLas opciones de claude (por ejemplo --model opus) se pasan tal cual: hopdeck --model opus',
|
|
24
25
|
shortcutUsage: 'Uso: hopdeck shortcut on (instalar el atajo de claude) · hopdeck shortcut off (quitarlo)',
|
|
25
26
|
unQ: '¿Desinstalar Hopdeck por completo?', unInfo: 'Se quitará el atajo de tu perfil de shell, tus preferencias y la caché de Hopdeck, y el programa (npm uninstall -g hopdeck). Tu historial de Claude Code no se toca.', unKeys: '[s] Sí, desinstalar [Enter] No', unCancel: 'Cancelado: no se ha quitado nada.', unNeedYes: 'Sin terminal no puedo preguntar. Para desinstalar sin preguntar: hopdeck uninstall --yes',
|
|
@@ -59,6 +60,7 @@ const T = {
|
|
|
59
60
|
copied: (n) => `Copied (${n} chars)`, archMsg: 'Archived (H to show)', unarchMsg: 'Unarchived', qsHint: 'jump to any conversation',
|
|
60
61
|
prevHint: '⏎ resume this conversation', noPrev: 'No messages to show',
|
|
61
62
|
bar6: 'hide list', bar7: 'show list', deep: 'content', pathPrompt: 'new folder name', mkIn: 'created in', fbTitle: 'Pick a folder', fbHere: 'Open chat here', fbNew: 'New folder here…', fbUp: 'Go up', fbProj: 'project', fbHint: '⏎ enter · ␣ open · / find · . hidden', fbDrives: 'This PC', fbRecent: 'recent', hoverMiss: (n) => `[Image #${n}]: not in the history yet`, fbEmpty: 'No subfolders', badId: 'Invalid session id',
|
|
63
|
+
imgClickHint: 'click: open full size', imgOpened: (n) => `[Image #${n}] opened in the image viewer`,
|
|
62
64
|
unknownCmd: (c) => `Unknown command: "${c}"`, didYouMean: (s) => `Did you mean "${s}"?`, cmdList: 'Commands: hopdeck shortcut on|off · uninstall · doctor · help (and --list, --version).\nclaude options (for example --model opus) are passed through as they are: hopdeck --model opus',
|
|
63
65
|
shortcutUsage: 'Usage: hopdeck shortcut on (install the claude shortcut) · hopdeck shortcut off (remove it)',
|
|
64
66
|
unQ: 'Uninstall Hopdeck completely?', unInfo: 'This removes the shortcut from your shell profile, Hopdeck\'s preferences and cache, and the program itself (npm uninstall -g hopdeck). Your Claude Code history is not touched.', unKeys: '[y] Yes, uninstall [Enter] No', unCancel: 'Cancelled: nothing was removed.', unNeedYes: 'Without a terminal I cannot ask. To uninstall without asking: hopdeck uninstall --yes',
|
package/lib/sixel.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Codificador Sixel: convierte una imagen RGB en la secuencia que dibuja una imagen real (con todos sus píxeles) en terminales
|
|
3
|
+
// que la admiten (Windows Terminal 1.22+, iTerm2, WezTerm, foot, mlterm, Konsole…). Sin dependencias.
|
|
4
|
+
//
|
|
5
|
+
// Formato: DCS "P0;0;0q" + atributos del ráster ("1;1;ancho;alto) + paleta (#n;2;r;g;b, en 0-100) + datos por bandas de
|
|
6
|
+
// 6 píxeles de alto (un carácter por columna y color: 63 + máscara de bits), con "!n" para repeticiones, "$" para volver al
|
|
7
|
+
// principio de la banda, "-" para la banda siguiente, y ST (ESC \) para terminar.
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Reduce la imagen a como mucho `maxColors` colores. Si ya tiene pocos colores (capturas de pantalla, interfaces) se conservan
|
|
11
|
+
* exactos; si no, se aplica "median cut" sobre un histograma de 5 bits por canal.
|
|
12
|
+
* Devuelve { palette: [[r,g,b]…], index: Uint8Array(w*h) }.
|
|
13
|
+
*/
|
|
14
|
+
function quantize(rgb, w, h, maxColors = 256) {
|
|
15
|
+
const n = w * h, index = new Uint8Array(n);
|
|
16
|
+
// 1) ¿hay pocos colores distintos? entonces la paleta es exacta
|
|
17
|
+
const exact = new Map();
|
|
18
|
+
for (let i = 0; i < n && exact.size <= maxColors; i++) {
|
|
19
|
+
const k = (rgb[i * 3] << 16) | (rgb[i * 3 + 1] << 8) | rgb[i * 3 + 2];
|
|
20
|
+
if (!exact.has(k)) exact.set(k, exact.size);
|
|
21
|
+
}
|
|
22
|
+
if (exact.size <= maxColors) {
|
|
23
|
+
for (let i = 0; i < n; i++) index[i] = exact.get((rgb[i * 3] << 16) | (rgb[i * 3 + 1] << 8) | rgb[i * 3 + 2]);
|
|
24
|
+
const palette = []; for (const [k] of exact) palette.push([(k >> 16) & 255, (k >> 8) & 255, k & 255]);
|
|
25
|
+
return { palette, index };
|
|
26
|
+
}
|
|
27
|
+
// 2) histograma de 5 bits por canal + median cut
|
|
28
|
+
const hist = new Uint32Array(32768);
|
|
29
|
+
for (let i = 0; i < n; i++) hist[((rgb[i * 3] >> 3) << 10) | ((rgb[i * 3 + 1] >> 3) << 5) | (rgb[i * 3 + 2] >> 3)]++;
|
|
30
|
+
const bins = [];
|
|
31
|
+
for (let b = 0; b < 32768; b++) if (hist[b]) bins.push({ r: ((b >> 10) << 3) + 4, g: (((b >> 5) & 31) << 3) + 4, b: ((b & 31) << 3) + 4, c: hist[b], id: b });
|
|
32
|
+
let boxes = [bins];
|
|
33
|
+
while (boxes.length < maxColors) {
|
|
34
|
+
// se parte la caja con más rango (ponderado por su número de píxeles) por su canal más largo, en la mediana
|
|
35
|
+
let bi = -1, best = -1, bch = 'r';
|
|
36
|
+
boxes.forEach((bx, i) => {
|
|
37
|
+
if (bx.length < 2) return;
|
|
38
|
+
let lo = { r: 255, g: 255, b: 255 }, hi = { r: 0, g: 0, b: 0 }, cnt = 0;
|
|
39
|
+
for (const p of bx) { cnt += p.c; for (const ch of ['r', 'g', 'b']) { if (p[ch] < lo[ch]) lo[ch] = p[ch]; if (p[ch] > hi[ch]) hi[ch] = p[ch]; } }
|
|
40
|
+
for (const ch of ['r', 'g', 'b']) { const score = (hi[ch] - lo[ch]) * Math.sqrt(cnt); if (score > best) { best = score; bi = i; bch = ch; } }
|
|
41
|
+
});
|
|
42
|
+
if (bi < 0) break;
|
|
43
|
+
const bx = boxes[bi].slice().sort((p, q) => p[bch] - q[bch]);
|
|
44
|
+
const half = bx.reduce((s, p) => s + p.c, 0) / 2; let acc = 0, cut = 1;
|
|
45
|
+
for (let i = 0; i < bx.length - 1; i++) { acc += bx[i].c; cut = i + 1; if (acc >= half) break; }
|
|
46
|
+
boxes.splice(bi, 1, bx.slice(0, cut), bx.slice(cut));
|
|
47
|
+
}
|
|
48
|
+
const palette = boxes.map((bx) => { let r = 0, g = 0, b = 0, c = 0; for (const p of bx) { r += p.r * p.c; g += p.g * p.c; b += p.b * p.c; c += p.c; } return [Math.round(r / c), Math.round(g / c), Math.round(b / c)]; });
|
|
49
|
+
const map = new Int16Array(32768).fill(-1); // cada color de 5 bits → su caja
|
|
50
|
+
boxes.forEach((bx, i) => { for (const p of bx) map[p.id] = i; });
|
|
51
|
+
for (let i = 0; i < n; i++) index[i] = map[((rgb[i * 3] >> 3) << 10) | ((rgb[i * 3 + 1] >> 3) << 5) | (rgb[i * 3 + 2] >> 3)];
|
|
52
|
+
return { palette, index };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Una fila de máscaras de una banda como cadena sixel, con repeticiones "!n" y sin el relleno vacío del final. */
|
|
56
|
+
function rle(masks) {
|
|
57
|
+
let end = masks.length; while (end > 0 && masks[end - 1] === 0) end--; // los "?" finales no hacen falta
|
|
58
|
+
let out = '';
|
|
59
|
+
for (let x = 0; x < end;) {
|
|
60
|
+
let run = 1; while (x + run < end && masks[x + run] === masks[x]) run++;
|
|
61
|
+
const ch = String.fromCharCode(63 + masks[x]);
|
|
62
|
+
out += run > 3 ? `!${run}${ch}` : ch.repeat(run);
|
|
63
|
+
x += run;
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Imagen RGB (3 bytes por píxel) → secuencia Sixel completa lista para escribir en el terminal. */
|
|
69
|
+
function encodeSixel(rgb, w, h, { maxColors = 256 } = {}) {
|
|
70
|
+
const { palette, index } = quantize(rgb, w, h, maxColors);
|
|
71
|
+
let out = `\x1bP0;0;0q"1;1;${w};${h}`;
|
|
72
|
+
palette.forEach(([r, g, b], i) => { out += `#${i};2;${Math.round((r * 100) / 255)};${Math.round((g * 100) / 255)};${Math.round((b * 100) / 255)}`; });
|
|
73
|
+
for (let y0 = 0; y0 < h; y0 += 6) {
|
|
74
|
+
const bandH = Math.min(6, h - y0), cols = new Map();
|
|
75
|
+
for (let dy = 0; dy < bandH; dy++) {
|
|
76
|
+
const row = (y0 + dy) * w;
|
|
77
|
+
for (let x = 0; x < w; x++) {
|
|
78
|
+
const c = index[row + x]; let a = cols.get(c);
|
|
79
|
+
if (!a) { a = new Uint8Array(w); cols.set(c, a); }
|
|
80
|
+
a[x] |= 1 << dy;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
let first = true;
|
|
84
|
+
for (const [c, a] of cols) { out += (first ? '' : '$') + '#' + c + rle(a); first = false; }
|
|
85
|
+
if (y0 + 6 < h) out += '-';
|
|
86
|
+
}
|
|
87
|
+
return out + '\x1b\\';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
module.exports = { encodeSixel, quantize };
|
package/package.json
CHANGED