@lethevimlet/sshift 0.3.1 → 0.5.0

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.
@@ -140,6 +140,8 @@ class MobileTerminalHandler {
140
140
  cellHeight,
141
141
  contentLeft,
142
142
  contentTop,
143
+ contentWidth,
144
+ contentHeight,
143
145
  offsetX: contentLeft - containerRect.left,
144
146
  offsetY: contentTop - containerRect.top,
145
147
  cols,
@@ -161,6 +163,8 @@ class MobileTerminalHandler {
161
163
  cellHeight,
162
164
  contentLeft: containerRect.left,
163
165
  contentTop: containerRect.top,
166
+ contentWidth: containerRect.width,
167
+ contentHeight: containerRect.height,
164
168
  offsetX: 0,
165
169
  offsetY: 0,
166
170
  cols,
@@ -254,18 +258,12 @@ class MobileTerminalHandler {
254
258
  const coords = this._screenToTerminalCoords(touch.clientX, touch.clientY);
255
259
 
256
260
  if (coords) {
257
- // Update the appropriate handle position
258
261
  if (type === 'start') {
259
- // When dragging start handle, update start position
260
262
  this.selection.start = coords;
261
263
  } else {
262
- // When dragging end handle, update end position
263
264
  this.selection.end = coords;
264
265
  }
265
266
 
266
- // Ensure start is always before end in buffer order
267
- // This prevents selection from inverting
268
- this._normalizeSelection();
269
267
  this._updateSelection();
270
268
  }
271
269
  }, { passive: false });
@@ -650,14 +648,17 @@ class MobileTerminalHandler {
650
648
  }
651
649
  }
652
650
 
653
- // Handle selection dragging
654
651
  if (this.selection.active && this.touchState.isDragging) {
655
652
  e.preventDefault();
656
653
  const touch = e.touches[0];
657
654
  const coords = this._screenToTerminalCoords(touch.clientX, touch.clientY);
658
655
 
659
656
  if (coords) {
660
- this.selection.end = coords;
657
+ if (this.touchState.dragHandle === 'start') {
658
+ this.selection.start = coords;
659
+ } else {
660
+ this.selection.end = coords;
661
+ }
661
662
  this._updateSelection();
662
663
  }
663
664
  }
@@ -925,33 +926,42 @@ class MobileTerminalHandler {
925
926
  * @private
926
927
  */
927
928
  _updateSelectionOverlay(start, end) {
928
- const startPos = this._terminalToScreenCoords(start.x, start.y);
929
- const endPos = this._terminalToScreenCoords(end.x, end.y);
930
-
931
- if (!startPos || !endPos) return;
929
+ const metrics = this._getTerminalMetrics();
930
+ if (!metrics) return;
932
931
 
933
932
  const startY = Math.min(start.y, end.y);
934
933
  const endY = Math.max(start.y, end.y);
935
934
 
935
+ const textBeginX = (start.y < end.y || (start.y === end.y && start.x <= end.x)) ? start.x : end.x;
936
+ const textEndX = (start.y < end.y || (start.y === end.y && start.x <= end.x)) ? end.x : start.x;
937
+
936
938
  this.selectionOverlay.innerHTML = '';
937
939
 
938
940
  for (let y = startY; y <= endY; y++) {
939
- const lineStartX = (y === startY) ? Math.min(start.x, end.x) : 0;
940
- const lineEndX = (y === endY) ? Math.max(start.x, end.x) : this.terminal.cols - 1;
941
+ const lineStartX = (y === startY) ? textBeginX : 0;
942
+ const lineEndX = (y === endY) ? textEndX : metrics.cols - 1;
943
+ const extendsToRight = (lineEndX === metrics.cols - 1);
941
944
 
942
945
  const lineStartPos = this._terminalToScreenCoords(lineStartX, y);
943
- const lineEndPos = this._terminalToScreenCoords(lineEndX, y);
944
946
 
945
- if (lineStartPos && lineEndPos) {
946
- const rect = document.createElement('div');
947
- rect.className = 'mobile-selection-rect';
948
- rect.style.position = 'absolute';
949
- rect.style.left = `${lineStartPos.x}px`;
950
- rect.style.top = `${lineStartPos.y}px`;
951
- rect.style.width = `${lineEndPos.x - lineStartPos.x + lineEndPos.width}px`;
952
- rect.style.height = `${lineStartPos.height}px`;
953
- this.selectionOverlay.appendChild(rect);
947
+ if (!lineStartPos) continue;
948
+
949
+ const rect = document.createElement('div');
950
+ rect.className = 'mobile-selection-rect';
951
+ rect.style.position = 'absolute';
952
+ rect.style.left = `${lineStartPos.x}px`;
953
+ rect.style.top = `${lineStartPos.y}px`;
954
+ rect.style.height = `${lineStartPos.height}px`;
955
+
956
+ if (extendsToRight) {
957
+ rect.style.right = '0px';
958
+ } else {
959
+ const lineEndPos = this._terminalToScreenCoords(lineEndX, y);
960
+ if (!lineEndPos) continue;
961
+ rect.style.width = `${Math.ceil(lineEndPos.x - lineStartPos.x + lineEndPos.width)}px`;
954
962
  }
963
+
964
+ this.selectionOverlay.appendChild(rect);
955
965
  }
956
966
 
957
967
  this.selectionOverlay.style.display = 'block';
@@ -962,23 +972,42 @@ class MobileTerminalHandler {
962
972
  * @private
963
973
  */
964
974
  _updateHandles(start, end) {
965
- const isStartFirst = (start.y < end.y) || (start.y === end.y && start.x <= end.x);
966
-
967
- const actualStart = isStartFirst ? start : end;
968
- const actualEnd = isStartFirst ? end : start;
975
+ const startPos = start.y * this.terminal.cols + start.x;
976
+ const endPos = end.y * this.terminal.cols + end.x;
977
+ const isInverted = startPos > endPos;
969
978
 
970
- const startPos = this._terminalToScreenCoords(actualStart.x, actualStart.y);
971
- if (startPos) {
979
+ const startCoords = this._terminalToScreenCoords(start.x, start.y);
980
+ if (startCoords) {
972
981
  this.startHandle.style.display = 'block';
973
- this.startHandle.style.left = `${startPos.x}px`;
974
- this.startHandle.style.top = `${startPos.y + startPos.height}px`;
982
+ if (isInverted) {
983
+ this.startHandle.style.left = `${startCoords.x + startCoords.width}px`;
984
+ } else {
985
+ this.startHandle.style.left = `${startCoords.x}px`;
986
+ }
987
+ this.startHandle.style.top = `${startCoords.y + startCoords.height}px`;
975
988
  }
976
989
 
977
- const endPos = this._terminalToScreenCoords(actualEnd.x, actualEnd.y);
978
- if (endPos) {
990
+ const endCoords = this._terminalToScreenCoords(end.x, end.y);
991
+ if (endCoords) {
979
992
  this.endHandle.style.display = 'block';
980
- this.endHandle.style.left = `${endPos.x + endPos.width}px`;
981
- this.endHandle.style.top = `${endPos.y + endPos.height}px`;
993
+ if (isInverted) {
994
+ this.endHandle.style.left = `${endCoords.x}px`;
995
+ } else {
996
+ this.endHandle.style.left = `${endCoords.x + endCoords.width}px`;
997
+ }
998
+ this.endHandle.style.top = `${endCoords.y + endCoords.height}px`;
999
+ }
1000
+
1001
+ if (isInverted) {
1002
+ this.startHandle.classList.add('mobile-selection-handle-end');
1003
+ this.startHandle.classList.remove('mobile-selection-handle-start');
1004
+ this.endHandle.classList.add('mobile-selection-handle-start');
1005
+ this.endHandle.classList.remove('mobile-selection-handle-end');
1006
+ } else {
1007
+ this.startHandle.classList.add('mobile-selection-handle-start');
1008
+ this.startHandle.classList.remove('mobile-selection-handle-end');
1009
+ this.endHandle.classList.add('mobile-selection-handle-end');
1010
+ this.endHandle.classList.remove('mobile-selection-handle-start');
982
1011
  }
983
1012
  }
984
1013
 
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "SSHIFT - SSH & SFTP Terminal Client",
3
+ "short_name": "SSHIFT",
4
+ "description": "Web-based SSH + SFTP terminal client with tabs and bookmarks",
5
+ "start_url": "/",
6
+ "display": "standalone",
7
+ "background_color": "#1a1b26",
8
+ "theme_color": "#1a1b26",
9
+ "orientation": "any",
10
+ "scope": "/",
11
+ "icons": [
12
+ {
13
+ "src": "/icons/icon-72x72.png",
14
+ "sizes": "72x72",
15
+ "type": "image/png"
16
+ },
17
+ {
18
+ "src": "/icons/icon-96x96.png",
19
+ "sizes": "96x96",
20
+ "type": "image/png"
21
+ },
22
+ {
23
+ "src": "/icons/icon-128x128.png",
24
+ "sizes": "128x128",
25
+ "type": "image/png"
26
+ },
27
+ {
28
+ "src": "/icons/icon-144x144.png",
29
+ "sizes": "144x144",
30
+ "type": "image/png"
31
+ },
32
+ {
33
+ "src": "/icons/icon-152x152.png",
34
+ "sizes": "152x152",
35
+ "type": "image/png"
36
+ },
37
+ {
38
+ "src": "/icons/icon-192x192.png",
39
+ "sizes": "192x192",
40
+ "type": "image/png"
41
+ },
42
+ {
43
+ "src": "/icons/icon-384x384.png",
44
+ "sizes": "384x384",
45
+ "type": "image/png"
46
+ },
47
+ {
48
+ "src": "/icons/icon-512x512.png",
49
+ "sizes": "512x512",
50
+ "type": "image/png",
51
+ "purpose": "any maskable"
52
+ }
53
+ ]
54
+ }
@@ -0,0 +1,55 @@
1
+ const CACHE_NAME = 'sshift-v1';
2
+
3
+ const PRECACHE_URLS = [
4
+ '/',
5
+ '/index.html',
6
+ '/css/style.css',
7
+ '/libs/xterm/xterm.css',
8
+ '/libs/font-awesome/css/all.min.css',
9
+ '/libs/lucide/lucide.min.js',
10
+ '/manifest.json'
11
+ };
12
+
13
+ self.addEventListener('install', (event) => {
14
+ event.waitUntil(
15
+ caches.open(CACHE_NAME).then((cache) => cache.addAll(PRECACHE_URLS))
16
+ );
17
+ self.skipWaiting();
18
+ });
19
+
20
+ self.addEventListener('activate', (event) => {
21
+ event.waitUntil(
22
+ caches.keys().then((cacheNames) =>
23
+ Promise.all(
24
+ cacheNames
25
+ .filter((name) => name !== CACHE_NAME)
26
+ .map((name) => caches.delete(name))
27
+ )
28
+ )
29
+ );
30
+ self.clients.claim();
31
+ });
32
+
33
+ self.addEventListener('fetch', (event) => {
34
+ if (event.request.method !== 'GET') return;
35
+
36
+ const url = new URL(event.request.url);
37
+
38
+ if (url.protocol === 'http:' || url.protocol === 'https:') {
39
+ if (url.pathname.startsWith('/socket.io/')) return;
40
+ }
41
+
42
+ event.respondWith(
43
+ caches.match(event.request).then((cached) => {
44
+ const fetched = fetch(event.request).then((response) => {
45
+ if (response && response.status === 200 && response.type === 'basic') {
46
+ const clone = response.clone();
47
+ caches.open(CACHE_NAME).then((cache) => cache.put(event.request, clone));
48
+ }
49
+ return response;
50
+ }).catch(() => cached);
51
+
52
+ return cached || fetched;
53
+ })
54
+ );
55
+ });