@lethevimlet/sshift 1.5.0 → 1.5.1

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.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "Web-based SSH + SFTP terminal client with tabs and bookmarks",
5
5
  "main": "src/server/index.js",
6
6
  "bin": {
@@ -202,11 +202,24 @@ try {
202
202
  return;
203
203
  }
204
204
 
205
+ // Return the raw ssh2 Stats object so callers can use the
206
+ // standard `stats.isDirectory()` / `stats.isFile()` METHODS
207
+ // (not properties). The previous normalized return shape
208
+ // (`{ isDirectory: bool, isFile: bool }`) broke callers —
209
+ // notably `sftp-download` at src/server/endpoints/ws/sftp.js
210
+ // which calls `stats.isDirectory()` as a function and crashed
211
+ // with "stats.isDirectory is not a function" on every file
212
+ // download attempt. We add normalized properties as aliases
213
+ // so existing callers that read them as booleans still work.
205
214
  resolve({
215
+ // Raw ssh2 Stats methods (primary API).
216
+ isDirectory: () => stats.isDirectory(),
217
+ isFile: () => stats.isFile(),
218
+ // Aliased scalar fields for callers that read these as values.
206
219
  size: stats.size,
207
220
  modifyTime: stats.mtime * 1000,
208
- isDirectory: stats.isDirectory(),
209
- isFile: stats.isFile()
221
+ isDirectoryValue: stats.isDirectory(),
222
+ isFileValue: stats.isFile()
210
223
  });
211
224
  });
212
225
  });
@@ -4107,10 +4107,22 @@ const wheelHandler = (e) => {
4107
4107
  try {
4108
4108
  // Set resyncing flag BEFORE calling resize to prevent resize feedback loop
4109
4109
  session.isResyncing = true;
4110
-
4110
+
4111
4111
  session.terminal.resize(data.cols, data.rows);
4112
4112
  console.log('[SSHIFT] Terminal resized to match server dimensions:', data.cols, 'x', data.rows);
4113
-
4113
+
4114
+ // The serialized state was just written into a fresh
4115
+ // buffer + the terminal was just resized. The WebGL
4116
+ // renderer's glyph atlas still holds glyphs rasterised
4117
+ // at the pre-resize cell size — painting them now would
4118
+ // produce the "interlaced / every-other-row blank" bug
4119
+ // (visible after "Take Control" on a just-refreshed
4120
+ // browser tab; fixed when the user manually resizes the
4121
+ // window because that re-runs _fitTerminal → _resetWebGLAtlas).
4122
+ // Clear the atlas here so the renderer re-rasterises at
4123
+ // the post-sync cell dimensions.
4124
+ this._resetWebGLAtlas(session);
4125
+
4114
4126
  // Clear the resyncing flag after a short delay
4115
4127
  setTimeout(() => {
4116
4128
  session.isResyncing = false;
@@ -7831,6 +7843,41 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
7831
7843
  }
7832
7844
  });
7833
7845
 
7846
+ // Defensive activation on user interaction.
7847
+ // Backgrounded / throttled browser tabs can leave `isResyncing` set
7848
+ // (setTimeout was deferred by the browser's power saver) which
7849
+ // suppresses onResize emits. Some browsers also move focus to the
7850
+ // body when the tab is hidden, and xterm's mouse input + IME only
7851
+ // fire while the terminal's element / hidden textarea has focus.
7852
+ // Result: after a period of inactivity on a TUI app, mouse clicks
7853
+ // and scroll stop working until the user refreshes. Fix: on every
7854
+ // mouse / touch / wheel interaction with the terminal, re-focus
7855
+ // xterm and clear any stuck isResyncing flag so subsequent resize
7856
+ // events (and TUI mouse-tracking escape sequences) flow through.
7857
+ const activateSession = () => {
7858
+ if (!session) return;
7859
+ if (session.isResyncing) {
7860
+ // setTimeout was probably deferred by background throttling.
7861
+ // Releasing here lets the next user-initiated resize flow.
7862
+ session.isResyncing = false;
7863
+ }
7864
+ // Re-focus the terminal so xterm's mouse-service fires. Use
7865
+ // requestAnimationFrame to avoid stealing focus mid-click on
7866
+ // the active selection.
7867
+ requestAnimationFrame(() => {
7868
+ if (session.terminal) {
7869
+ if (this.isMobile && session.mobileHandler && session.mobileHandler.hiddenTextarea) {
7870
+ session.mobileHandler._focusHiddenTextarea();
7871
+ } else {
7872
+ try { session.terminal.focus(); } catch (_) {}
7873
+ }
7874
+ }
7875
+ });
7876
+ };
7877
+ container.addEventListener('mousedown', activateSession, true);
7878
+ container.addEventListener('touchstart', activateSession, true);
7879
+ container.addEventListener('wheel', activateSession, true);
7880
+
7834
7881
  session.terminal = terminal;
7835
7882
  session.fitAddon = fitAddon;
7836
7883