@lethevimlet/sshift 1.4.1 → 1.4.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/package.json +1 -1
- package/src/webapp/js/app.js +69 -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();
|
|
@@ -1219,6 +1266,10 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
|
|
|
1219
1266
|
|
|
1220
1267
|
console.log('[SSHIFT] Terminal fitted, cols:', terminal.cols, 'rows:', terminal.rows);
|
|
1221
1268
|
|
|
1269
|
+
// Snap cell width to an integer number of device pixels so block/box
|
|
1270
|
+
// drawing characters tile without 1px seams on fractional-DPR displays.
|
|
1271
|
+
this._snapCellWidth(session);
|
|
1272
|
+
|
|
1222
1273
|
// Resize changes cell metrics; clear the WebGL atlas so glyphs are
|
|
1223
1274
|
// re-rasterised at the new size rather than stretched from the old cache.
|
|
1224
1275
|
this._resetWebGLAtlas(session);
|
|
@@ -7200,6 +7251,7 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
|
|
|
7200
7251
|
fontFamily: "'JetBrains Mono', 'Fira Code', 'Consolas', 'Courier New', monospace",
|
|
7201
7252
|
fontSize: this.terminalFontSize,
|
|
7202
7253
|
lineHeight: 1.0,
|
|
7254
|
+
letterSpacing: 0,
|
|
7203
7255
|
cursorBlink: false,
|
|
7204
7256
|
cursorStyle: 'block',
|
|
7205
7257
|
scrollback: this.scrollback || 10000,
|
|
@@ -7211,7 +7263,8 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
|
|
|
7211
7263
|
fastScrollModifier: 'alt',
|
|
7212
7264
|
fastScrollSensitivity: 5,
|
|
7213
7265
|
smoothScrollDuration: 80,
|
|
7214
|
-
overviewRuler: { width: 14 }
|
|
7266
|
+
overviewRuler: { width: 14 },
|
|
7267
|
+
customGlyphs: true
|
|
7215
7268
|
});
|
|
7216
7269
|
|
|
7217
7270
|
// Set wrapper background color
|
|
@@ -8836,6 +8889,19 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
|
|
|
8836
8889
|
setTimeout(retryFit, 50);
|
|
8837
8890
|
}
|
|
8838
8891
|
|
|
8892
|
+
// Safety net: always schedule a delayed refit after tab switch.
|
|
8893
|
+
// Sometimes the initial fit succeeds at a small intermediate size
|
|
8894
|
+
// (e.g. 100×100px) because the browser hasn't fully committed the
|
|
8895
|
+
// display:none → display:flex layout change. A delayed refit
|
|
8896
|
+
// corrects this once the layout has settled.
|
|
8897
|
+
setTimeout(() => {
|
|
8898
|
+
if (!session.terminal || !session.fitAddon || !session.isController) return;
|
|
8899
|
+
const wrapper = document.getElementById(`terminal-wrapper-${session.id}`);
|
|
8900
|
+
if (wrapper && wrapper.classList.contains('active')) {
|
|
8901
|
+
this._fitTerminal(session);
|
|
8902
|
+
}
|
|
8903
|
+
}, 150);
|
|
8904
|
+
|
|
8839
8905
|
// Focus the terminal so user can type
|
|
8840
8906
|
if (session.terminal) {
|
|
8841
8907
|
if (this.isMobile && session.mobileHandler && session.mobileHandler.hiddenTextarea) {
|