@lethevimlet/sshift 1.4.5 → 1.4.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lethevimlet/sshift",
3
- "version": "1.4.5",
3
+ "version": "1.4.6",
4
4
  "description": "Web-based SSH + SFTP terminal client with tabs and bookmarks",
5
5
  "main": "src/server/index.js",
6
6
  "bin": {
@@ -995,41 +995,17 @@ 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 cellWidth × DPR is fractional, adjacent cells
1000
- // land on sub-pixel boundaries, causing 1px vertical seams in block
1001
- // characters. Adding a tiny letterSpacing rounds the device-pixel cell
1002
- // width up to a whole number, eliminating seams.
1003
- //
1004
- // Only applies when the needed padding is <= 0.15 CSS px — larger
1005
- // padding is visually noticeable as extra character spacing, so we
1006
- // skip it and accept the occasional 1px seam instead.
1007
- _snapCellWidth(session) {
1008
- if (!session || !session.terminal || !session.fitAddon) return;
1009
- const term = session.terminal;
1010
- const core = term._core;
1011
- if (!core?._renderService?.dimensions?.css?.cell) return;
1012
-
1013
- const cellCssW = core._renderService.dimensions.css.cell.width;
1014
- if (!cellCssW || cellCssW <= 0) return;
1015
-
1016
- const dpr = window.devicePixelRatio || 1;
1017
- const deviceW = cellCssW * dpr;
1018
- const fraction = deviceW - Math.floor(deviceW);
1019
-
1020
- if (fraction > 0.01 && fraction < 0.99) {
1021
- const padCss = (1 - fraction) / dpr;
1022
- // Only snap if the padding needed is tiny (imperceptible).
1023
- // Larger padding creates visible gaps between characters.
1024
- if (padCss <= 0.15) {
1025
- term.options.letterSpacing = padCss;
1026
- } else {
1027
- term.options.letterSpacing = 0;
1028
- }
1029
- } else {
1030
- term.options.letterSpacing = 0;
1031
- }
1032
- }
998
+ // Sub-pixel seam mitigation is handled by canvas/WebGL renderer +
999
+ // customGlyphs: true, which draws block/box characters as vector fills
1000
+ // that meet exactly. letterSpacing nudging doesn't work because xterm.js
1001
+ // only accepts integer letterSpacing values. Origin-snapping transforms
1002
+ // are also unnecessary because the canvas/WebGL renderer paints the cell
1003
+ // grid in its own coordinate system. The remaining mitigation is:
1004
+ // - customGlyphs: true (set in Terminal options)
1005
+ // - canvas or WebGL renderer as default (not DOM)
1006
+ // - clearTextureAtlas() on DPR change (handled by _setupDPRListener)
1007
+ // - clean base metrics: letterSpacing: 0, lineHeight: 1.0 in _fitTerminal
1008
+ _snapCellWidth() { /* no-op: see comment above */ }
1033
1009
 
1034
1010
  // Initialize (or re-initialize) the WebGL renderer addon for a session.
1035
1011
  // Handles context-loss tracking with a retry cap: after 3 losses the session
@@ -1119,7 +1095,6 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
1119
1095
  if (session.webglAddon) {
1120
1096
  try { session.webglAddon.clearTextureAtlas(); } catch (_) {}
1121
1097
  }
1122
- this._snapCellWidth(session);
1123
1098
  if (session.terminal) {
1124
1099
  session.terminal.refresh(0, session.terminal.rows - 1);
1125
1100
  }
@@ -1183,7 +1158,6 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
1183
1158
  currentDPR = newDPR;
1184
1159
  this.sessions.forEach(session => {
1185
1160
  this._resetWebGLAtlas(session);
1186
- this._snapCellWidth(session);
1187
1161
  if (session.fitAddon && session.terminal && session.isController) {
1188
1162
  const wrapper = document.getElementById(`terminal-wrapper-${session.id}`);
1189
1163
  if (wrapper && wrapper.classList.contains('active')) {
@@ -1241,6 +1215,13 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
1241
1215
  return false;
1242
1216
  }
1243
1217
 
1218
+ // Reset letterSpacing and lineHeight to base values before fitting so
1219
+ // alignToDeviceGrid measures from clean metrics rather than accumulated
1220
+ // nudges from a previous invocation.
1221
+ const term = session.terminal;
1222
+ term.options.letterSpacing = 0;
1223
+ term.options.lineHeight = 1;
1224
+
1244
1225
  void container.offsetHeight;
1245
1226
  void wrapper.offsetHeight;
1246
1227
 
@@ -1268,22 +1249,6 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
1268
1249
  }
1269
1250
  }
1270
1251
 
1271
- // Snap cell width to an integer number of device pixels so block/box
1272
- // drawing characters tile without 1px seams on fractional-DPR displays.
1273
- // This MUST be followed by a refit because letterSpacing changes the
1274
- // cell width, which changes how many columns fit in the container.
1275
- const letterSpacingBefore = terminal.options.letterSpacing || 0;
1276
- this._snapCellWidth(session);
1277
- const letterSpacingAfter = terminal.options.letterSpacing || 0;
1278
-
1279
- // If letterSpacing changed, refit so xterm recalculates column count
1280
- // with the new (snapped) cell width.
1281
- if (letterSpacingAfter !== letterSpacingBefore) {
1282
- try {
1283
- session.fitAddon.fit();
1284
- } catch (_) {}
1285
- }
1286
-
1287
1252
  console.log('[SSHIFT] Terminal fitted, cols:', terminal.cols, 'rows:', terminal.rows);
1288
1253
 
1289
1254
  // Resize changes cell metrics; clear the WebGL atlas so glyphs are