@lethevimlet/sshift 1.4.1 → 1.4.3
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/package.json +1 -1
- package/src/webapp/js/app.js +81 -3
package/package.json
CHANGED
package/src/webapp/js/app.js
CHANGED
|
@@ -995,6 +995,36 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
|
|
|
995
995
|
session.terminal.refresh(0, session.terminal.rows - 1);
|
|
996
996
|
}
|
|
997
997
|
|
|
998
|
+
// Snap cell width to an integer number of device pixels by adjusting
|
|
999
|
+
// letterSpacing. When the CSS cell width × devicePixelRatio is fractional,
|
|
1000
|
+
// adjacent cells alternate between N and N+1 device pixels, leaving 1px
|
|
1001
|
+
// vertical seams in block/box-drawing characters. Adding a tiny
|
|
1002
|
+
// letterSpacing pad rounds the device-pixel width up to a whole number,
|
|
1003
|
+
// eliminating seams regardless of zoom level or DPR.
|
|
1004
|
+
_snapCellWidth(session) {
|
|
1005
|
+
if (!session || !session.terminal || !session.fitAddon) return;
|
|
1006
|
+
const term = session.terminal;
|
|
1007
|
+
const core = term._core;
|
|
1008
|
+
if (!core?._renderService?.dimensions?.css?.cell) return;
|
|
1009
|
+
|
|
1010
|
+
const cellCssW = core._renderService.dimensions.css.cell.width;
|
|
1011
|
+
if (!cellCssW || cellCssW <= 0) return;
|
|
1012
|
+
|
|
1013
|
+
const dpr = window.devicePixelRatio || 1;
|
|
1014
|
+
const deviceW = cellCssW * dpr;
|
|
1015
|
+
const fraction = deviceW - Math.floor(deviceW);
|
|
1016
|
+
|
|
1017
|
+
if (fraction > 0.01) {
|
|
1018
|
+
// Pad up to the next whole device pixel, converted back to CSS px.
|
|
1019
|
+
const padCss = (1 - fraction) / dpr;
|
|
1020
|
+
// Clamp to avoid excessive spacing — 0.5 CSS px is generous.
|
|
1021
|
+
const clampedPad = Math.min(padCss, 0.5);
|
|
1022
|
+
term.options.letterSpacing = clampedPad;
|
|
1023
|
+
} else {
|
|
1024
|
+
term.options.letterSpacing = 0;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
|
|
998
1028
|
// Initialize (or re-initialize) the WebGL renderer addon for a session.
|
|
999
1029
|
// Handles context-loss tracking with a retry cap: after 3 losses the session
|
|
1000
1030
|
// permanently falls back to the canvas renderer so we don't loop endlessly.
|
|
@@ -1083,6 +1113,7 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
|
|
|
1083
1113
|
if (session.webglAddon) {
|
|
1084
1114
|
try { session.webglAddon.clearTextureAtlas(); } catch (_) {}
|
|
1085
1115
|
}
|
|
1116
|
+
this._snapCellWidth(session);
|
|
1086
1117
|
if (session.terminal) {
|
|
1087
1118
|
session.terminal.refresh(0, session.terminal.rows - 1);
|
|
1088
1119
|
}
|
|
@@ -1135,6 +1166,9 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
|
|
|
1135
1166
|
// Watch for devicePixelRatio changes (zoom, monitor move, DPI switch).
|
|
1136
1167
|
// When DPR changes the WebGL glyph atlas is built for the old pixel ratio
|
|
1137
1168
|
// and every glyph becomes mis-scaled; clearing the atlas forces a rebuild.
|
|
1169
|
+
// We also refit and re-snap letterSpacing so cells remain integer-width
|
|
1170
|
+
// in device pixels at the new DPR, eliminating seams on fractional-DPR
|
|
1171
|
+
// displays.
|
|
1138
1172
|
_setupDPRListener() {
|
|
1139
1173
|
let currentDPR = window.devicePixelRatio;
|
|
1140
1174
|
const query = matchMedia(`(resolution: ${currentDPR}dppx)`);
|
|
@@ -1143,8 +1177,21 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
|
|
|
1143
1177
|
if (newDPR !== currentDPR) {
|
|
1144
1178
|
console.log('[SSHIFT] devicePixelRatio changed from', currentDPR, 'to', newDPR);
|
|
1145
1179
|
currentDPR = newDPR;
|
|
1146
|
-
this.sessions.forEach(session =>
|
|
1147
|
-
|
|
1180
|
+
this.sessions.forEach(session => {
|
|
1181
|
+
this._resetWebGLAtlas(session);
|
|
1182
|
+
this._snapCellWidth(session);
|
|
1183
|
+
if (session.fitAddon && session.terminal && session.isController) {
|
|
1184
|
+
const wrapper = document.getElementById(`terminal-wrapper-${session.id}`);
|
|
1185
|
+
if (wrapper && wrapper.classList.contains('active')) {
|
|
1186
|
+
this._fitTerminal(session);
|
|
1187
|
+
} else if (wrapper) {
|
|
1188
|
+
session.needsResize = true;
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
});
|
|
1192
|
+
this.sftpSessions.forEach(session => {
|
|
1193
|
+
this._resetWebGLAtlas(session);
|
|
1194
|
+
});
|
|
1148
1195
|
}
|
|
1149
1196
|
// Re-register for the new DPR value
|
|
1150
1197
|
this._setupDPRListener();
|
|
@@ -1217,6 +1264,22 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
|
|
|
1217
1264
|
}
|
|
1218
1265
|
}
|
|
1219
1266
|
|
|
1267
|
+
// Snap cell width to an integer number of device pixels so block/box
|
|
1268
|
+
// drawing characters tile without 1px seams on fractional-DPR displays.
|
|
1269
|
+
// This MUST be followed by a refit because letterSpacing changes the
|
|
1270
|
+
// cell width, which changes how many columns fit in the container.
|
|
1271
|
+
const letterSpacingBefore = terminal.options.letterSpacing || 0;
|
|
1272
|
+
this._snapCellWidth(session);
|
|
1273
|
+
const letterSpacingAfter = terminal.options.letterSpacing || 0;
|
|
1274
|
+
|
|
1275
|
+
// If letterSpacing changed, refit so xterm recalculates column count
|
|
1276
|
+
// with the new (snapped) cell width.
|
|
1277
|
+
if (letterSpacingAfter !== letterSpacingBefore) {
|
|
1278
|
+
try {
|
|
1279
|
+
session.fitAddon.fit();
|
|
1280
|
+
} catch (_) {}
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1220
1283
|
console.log('[SSHIFT] Terminal fitted, cols:', terminal.cols, 'rows:', terminal.rows);
|
|
1221
1284
|
|
|
1222
1285
|
// Resize changes cell metrics; clear the WebGL atlas so glyphs are
|
|
@@ -7200,6 +7263,7 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
|
|
|
7200
7263
|
fontFamily: "'JetBrains Mono', 'Fira Code', 'Consolas', 'Courier New', monospace",
|
|
7201
7264
|
fontSize: this.terminalFontSize,
|
|
7202
7265
|
lineHeight: 1.0,
|
|
7266
|
+
letterSpacing: 0,
|
|
7203
7267
|
cursorBlink: false,
|
|
7204
7268
|
cursorStyle: 'block',
|
|
7205
7269
|
scrollback: this.scrollback || 10000,
|
|
@@ -7211,7 +7275,8 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
|
|
|
7211
7275
|
fastScrollModifier: 'alt',
|
|
7212
7276
|
fastScrollSensitivity: 5,
|
|
7213
7277
|
smoothScrollDuration: 80,
|
|
7214
|
-
overviewRuler: { width: 14 }
|
|
7278
|
+
overviewRuler: { width: 14 },
|
|
7279
|
+
customGlyphs: true
|
|
7215
7280
|
});
|
|
7216
7281
|
|
|
7217
7282
|
// Set wrapper background color
|
|
@@ -8836,6 +8901,19 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
|
|
|
8836
8901
|
setTimeout(retryFit, 50);
|
|
8837
8902
|
}
|
|
8838
8903
|
|
|
8904
|
+
// Safety net: always schedule a delayed refit after tab switch.
|
|
8905
|
+
// Sometimes the initial fit succeeds at a small intermediate size
|
|
8906
|
+
// (e.g. 100×100px) because the browser hasn't fully committed the
|
|
8907
|
+
// display:none → display:flex layout change. A delayed refit
|
|
8908
|
+
// corrects this once the layout has settled.
|
|
8909
|
+
setTimeout(() => {
|
|
8910
|
+
if (!session.terminal || !session.fitAddon || !session.isController) return;
|
|
8911
|
+
const wrapper = document.getElementById(`terminal-wrapper-${session.id}`);
|
|
8912
|
+
if (wrapper && wrapper.classList.contains('active')) {
|
|
8913
|
+
this._fitTerminal(session);
|
|
8914
|
+
}
|
|
8915
|
+
}, 150);
|
|
8916
|
+
|
|
8839
8917
|
// Focus the terminal so user can type
|
|
8840
8918
|
if (session.terminal) {
|
|
8841
8919
|
if (this.isMobile && session.mobileHandler && session.mobileHandler.hiddenTextarea) {
|