@linxin666/dsh-ssh 0.4.20 → 0.4.21
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/lib/client.js +259 -98
- package/lib/client.js.map +1 -1
- package/lib/index.js +648 -243
- package/lib/types/engine/cluster.d.ts +7 -2
- package/lib/types/engine/connection-pool.d.ts +11 -2
- package/lib/types/engine/sftp.d.ts +5 -0
- package/lib/types/engine/terminal-sessions.d.ts +5 -3
- package/lib/types/store.d.ts +0 -1
- package/package.json +1 -1
- package/src/client/api.ts +106 -52
- package/src/client/panel/HostFormDialog.tsx +5 -3
- package/src/client/panel/HostsTab.tsx +41 -16
- package/src/client/panel/TerminalTab.tsx +14 -9
- package/src/client/panel/TunnelsTab.tsx +24 -7
- package/src/client/panel/controller.ts +76 -11
- package/src/engine/cluster.ts +45 -13
- package/src/engine/connection-pool.ts +141 -15
- package/src/engine/proxy-command.ts +27 -10
- package/src/engine/sftp.ts +69 -35
- package/src/engine/terminal-sessions.ts +110 -35
- package/src/engine/tunnel.ts +20 -2
- package/src/engine.ts +4 -0
- package/src/index.ts +50 -42
- package/src/routes.ts +51 -13
- package/src/store.ts +227 -123
- package/src/tools.ts +3 -5
package/lib/client.js
CHANGED
|
@@ -761,27 +761,43 @@ window.__ModuleLoader__.load({
|
|
|
761
761
|
let finalError;
|
|
762
762
|
let sawResult = false;
|
|
763
763
|
let transferredBytes = 0;
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
if (
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
764
|
+
let doneReading = false;
|
|
765
|
+
const processLine = (line) => {
|
|
766
|
+
if (line.trim() === "") return;
|
|
767
|
+
let parsed;
|
|
768
|
+
try {
|
|
769
|
+
parsed = JSON.parse(line);
|
|
770
|
+
} catch {
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
if (parsed.type === "progress") onProgress?.(parsed.progress);
|
|
774
|
+
else if (parsed.type === "result") {
|
|
775
|
+
sawResult = true;
|
|
776
|
+
if (parsed.ok) transferredBytes = parsed.transferredBytes ?? 0;
|
|
777
|
+
finalError = parsed.ok ? void 0 : parsed.error ?? "upload failed";
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
try {
|
|
781
|
+
for (;;) {
|
|
782
|
+
const { done, value } = await reader.read();
|
|
783
|
+
if (done) {
|
|
784
|
+
doneReading = true;
|
|
785
|
+
break;
|
|
786
|
+
}
|
|
787
|
+
buffer += decoder.decode(value, { stream: true });
|
|
788
|
+
const lines = buffer.split("\n");
|
|
789
|
+
buffer = lines.pop() ?? "";
|
|
790
|
+
for (const line of lines) processLine(line);
|
|
784
791
|
}
|
|
792
|
+
buffer += decoder.decode();
|
|
793
|
+
if (buffer !== "") for (const line of buffer.split("\n")) processLine(line);
|
|
794
|
+
} finally {
|
|
795
|
+
if (!doneReading) try {
|
|
796
|
+
await reader.cancel();
|
|
797
|
+
} catch {}
|
|
798
|
+
try {
|
|
799
|
+
reader.releaseLock();
|
|
800
|
+
} catch {}
|
|
785
801
|
}
|
|
786
802
|
if (finalError !== void 0) throw new SshApiError(finalError);
|
|
787
803
|
if (!sawResult) throw new SshApiError("upload ended without a result frame — the transfer did not complete");
|
|
@@ -807,8 +823,14 @@ window.__ModuleLoader__.load({
|
|
|
807
823
|
let writable;
|
|
808
824
|
const chunks = [];
|
|
809
825
|
let received = 0;
|
|
810
|
-
|
|
811
|
-
|
|
826
|
+
let lastProgressAt = -Infinity;
|
|
827
|
+
const PROGRESS_THROTTLE_MS = 100;
|
|
828
|
+
const emitProgress = (force = false) => {
|
|
829
|
+
if (onProgress === void 0) return;
|
|
830
|
+
const now = Date.now();
|
|
831
|
+
if (!force && now - lastProgressAt < PROGRESS_THROTTLE_MS) return;
|
|
832
|
+
lastProgressAt = now;
|
|
833
|
+
onProgress({
|
|
812
834
|
phase: "transferring",
|
|
813
835
|
file: remotePath,
|
|
814
836
|
transferred: received,
|
|
@@ -816,34 +838,53 @@ window.__ModuleLoader__.load({
|
|
|
816
838
|
percent: total > 0 ? Math.round(received / total * 1e3) / 10 : 0
|
|
817
839
|
});
|
|
818
840
|
};
|
|
841
|
+
let doneReading = false;
|
|
842
|
+
let completed = false;
|
|
819
843
|
try {
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
844
|
+
try {
|
|
845
|
+
if (picker !== void 0) {
|
|
846
|
+
writable = await (await picker.call(window, { suggestedName: filename })).createWritable();
|
|
847
|
+
streamed = true;
|
|
848
|
+
}
|
|
849
|
+
} catch {}
|
|
850
|
+
for (;;) {
|
|
851
|
+
const { done, value } = await reader.read();
|
|
852
|
+
if (done) {
|
|
853
|
+
doneReading = true;
|
|
854
|
+
break;
|
|
855
|
+
}
|
|
856
|
+
if (writable !== void 0) await writable.write(value);
|
|
857
|
+
else chunks.push(value);
|
|
858
|
+
received += value.length;
|
|
859
|
+
emitProgress(lastProgressAt < 0);
|
|
823
860
|
}
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
861
|
+
if (writable !== void 0) await writable.close();
|
|
862
|
+
completed = true;
|
|
863
|
+
onProgress?.({
|
|
864
|
+
phase: "done",
|
|
865
|
+
file: remotePath,
|
|
866
|
+
transferred: received,
|
|
867
|
+
total: received > 0 ? received : total,
|
|
868
|
+
percent: 100
|
|
869
|
+
});
|
|
870
|
+
return {
|
|
871
|
+
blob: streamed ? void 0 : new Blob(chunks),
|
|
872
|
+
filename,
|
|
873
|
+
streamed,
|
|
874
|
+
bytes: received
|
|
875
|
+
};
|
|
876
|
+
} finally {
|
|
877
|
+
if (!completed && writable !== void 0) try {
|
|
878
|
+
if (writable.abort !== void 0) await writable.abort();
|
|
879
|
+
else await writable.close();
|
|
880
|
+
} catch {}
|
|
881
|
+
if (!doneReading) try {
|
|
882
|
+
await reader.cancel();
|
|
883
|
+
} catch {}
|
|
884
|
+
try {
|
|
885
|
+
reader.releaseLock();
|
|
886
|
+
} catch {}
|
|
832
887
|
}
|
|
833
|
-
if (writable !== void 0) await writable.close();
|
|
834
|
-
onProgress?.({
|
|
835
|
-
phase: "done",
|
|
836
|
-
file: remotePath,
|
|
837
|
-
transferred: received,
|
|
838
|
-
total: received > 0 ? received : total,
|
|
839
|
-
percent: 100
|
|
840
|
-
});
|
|
841
|
-
return {
|
|
842
|
-
blob: streamed ? void 0 : new Blob(chunks),
|
|
843
|
-
filename,
|
|
844
|
-
streamed,
|
|
845
|
-
bytes: received
|
|
846
|
-
};
|
|
847
888
|
}
|
|
848
889
|
/**
|
|
849
890
|
* Open a new host terminal session for the alias.
|
|
@@ -957,6 +998,12 @@ window.__ModuleLoader__.load({
|
|
|
957
998
|
return failedTerminal(error instanceof Error ? error.message : String(error));
|
|
958
999
|
}
|
|
959
1000
|
let leaving = false;
|
|
1001
|
+
let exited = false;
|
|
1002
|
+
const notifyExit = (code, error) => {
|
|
1003
|
+
if (exited) return;
|
|
1004
|
+
exited = true;
|
|
1005
|
+
connection.onExit?.(code, error);
|
|
1006
|
+
};
|
|
960
1007
|
const sendFrame = (frame) => {
|
|
961
1008
|
if (socket.readyState === WebSocket.OPEN) socket.send(JSON.stringify(frame));
|
|
962
1009
|
};
|
|
@@ -1008,14 +1055,14 @@ window.__ModuleLoader__.load({
|
|
|
1008
1055
|
}
|
|
1009
1056
|
if (frame.type === "ready") connection.onReady?.(frame.sessionId, frame.alias);
|
|
1010
1057
|
else if (frame.type === "output") connection.onOutput?.(frame.data);
|
|
1011
|
-
else if (frame.type === "exit")
|
|
1058
|
+
else if (frame.type === "exit") notifyExit(frame.code, frame.error);
|
|
1012
1059
|
else if (frame.type === "auth_prompt") connection.onAuthPrompt?.(frame.name, frame.instructions, frame.prompts);
|
|
1013
1060
|
};
|
|
1014
1061
|
socket.onclose = () => {
|
|
1015
|
-
if (!leaving)
|
|
1062
|
+
if (!leaving) notifyExit(null, "connection closed");
|
|
1016
1063
|
};
|
|
1017
1064
|
socket.onerror = () => {
|
|
1018
|
-
if (!leaving)
|
|
1065
|
+
if (!leaving) notifyExit(null, "connection error");
|
|
1019
1066
|
};
|
|
1020
1067
|
return connection;
|
|
1021
1068
|
}
|
|
@@ -1030,12 +1077,45 @@ window.__ModuleLoader__.load({
|
|
|
1030
1077
|
*/
|
|
1031
1078
|
function utf8Bytes(text) {
|
|
1032
1079
|
let bytes = 0;
|
|
1033
|
-
for (
|
|
1034
|
-
const code =
|
|
1035
|
-
|
|
1080
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
1081
|
+
const code = text.charCodeAt(i);
|
|
1082
|
+
if (code >= 55296 && code <= 56319 && i + 1 < text.length) {
|
|
1083
|
+
const low = text.charCodeAt(i + 1);
|
|
1084
|
+
if (low >= 56320 && low <= 57343) {
|
|
1085
|
+
bytes += 4;
|
|
1086
|
+
i += 1;
|
|
1087
|
+
continue;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
bytes += code < 128 ? 1 : code < 2048 ? 2 : 3;
|
|
1036
1091
|
}
|
|
1037
1092
|
return bytes;
|
|
1038
1093
|
}
|
|
1094
|
+
/** Trim leading code units from an oversized chunk so its tail fits maxBytes without splitting surrogate pairs. */
|
|
1095
|
+
function trimTrailingUtf8(text, maxBytes) {
|
|
1096
|
+
let bytes = 0;
|
|
1097
|
+
let start = text.length;
|
|
1098
|
+
for (let i = text.length - 1; i >= 0; i -= 1) {
|
|
1099
|
+
const code = text.charCodeAt(i);
|
|
1100
|
+
let charBytes;
|
|
1101
|
+
let stepStart = i;
|
|
1102
|
+
if (code >= 56320 && code <= 57343 && i > 0) {
|
|
1103
|
+
const high = text.charCodeAt(i - 1);
|
|
1104
|
+
if (high >= 55296 && high <= 56319) {
|
|
1105
|
+
charBytes = 4;
|
|
1106
|
+
stepStart = i - 1;
|
|
1107
|
+
} else charBytes = 3;
|
|
1108
|
+
} else charBytes = code < 128 ? 1 : code < 2048 ? 2 : 3;
|
|
1109
|
+
if (bytes + charBytes > maxBytes) break;
|
|
1110
|
+
bytes += charBytes;
|
|
1111
|
+
start = stepStart;
|
|
1112
|
+
i = stepStart;
|
|
1113
|
+
}
|
|
1114
|
+
return {
|
|
1115
|
+
text: start === 0 ? text : text.slice(start),
|
|
1116
|
+
bytes
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1039
1119
|
/** The panel state owner the sidebar row and the view both read. */
|
|
1040
1120
|
var PanelController = class {
|
|
1041
1121
|
deps;
|
|
@@ -1304,21 +1384,46 @@ window.__ModuleLoader__.load({
|
|
|
1304
1384
|
}
|
|
1305
1385
|
/** Append one output chunk to the retained screen of a tab. */
|
|
1306
1386
|
appendTerminalOutput(id, chunk) {
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1387
|
+
if (chunk === "") return;
|
|
1388
|
+
const size = utf8Bytes(chunk);
|
|
1389
|
+
if (size > MAX_RETAINED_BYTES) {
|
|
1390
|
+
const trimmed = trimTrailingUtf8(chunk, MAX_RETAINED_BYTES);
|
|
1391
|
+
this.retainedScreens.set(id, {
|
|
1392
|
+
chunks: trimmed.text === "" ? [] : [trimmed.text],
|
|
1393
|
+
chunkBytes: trimmed.text === "" ? [] : [trimmed.bytes],
|
|
1394
|
+
head: 0,
|
|
1395
|
+
bytes: trimmed.bytes
|
|
1396
|
+
});
|
|
1397
|
+
return;
|
|
1398
|
+
}
|
|
1399
|
+
let screen = this.retainedScreens.get(id);
|
|
1400
|
+
if (screen === void 0) {
|
|
1401
|
+
this.retainedScreens.set(id, {
|
|
1402
|
+
chunks: [chunk],
|
|
1403
|
+
chunkBytes: [size],
|
|
1404
|
+
head: 0,
|
|
1405
|
+
bytes: size
|
|
1406
|
+
});
|
|
1407
|
+
return;
|
|
1408
|
+
}
|
|
1311
1409
|
screen.chunks.push(chunk);
|
|
1312
|
-
screen.
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
screen.bytes -=
|
|
1410
|
+
screen.chunkBytes.push(size);
|
|
1411
|
+
screen.bytes += size;
|
|
1412
|
+
while (screen.bytes > MAX_RETAINED_BYTES && screen.chunks.length - screen.head > 1) {
|
|
1413
|
+
screen.bytes -= screen.chunkBytes[screen.head];
|
|
1414
|
+
screen.head += 1;
|
|
1415
|
+
}
|
|
1416
|
+
if (screen.head >= 256 && screen.head * 2 >= screen.chunks.length) {
|
|
1417
|
+
screen.chunks = screen.chunks.slice(screen.head);
|
|
1418
|
+
screen.chunkBytes = screen.chunkBytes.slice(screen.head);
|
|
1419
|
+
screen.head = 0;
|
|
1316
1420
|
}
|
|
1317
|
-
this.retainedScreens.set(id, screen);
|
|
1318
1421
|
}
|
|
1319
1422
|
/** The retained screen of a tab, concatenated for a redraw. */
|
|
1320
1423
|
readTerminalOutput(id) {
|
|
1321
|
-
|
|
1424
|
+
const screen = this.retainedScreens.get(id);
|
|
1425
|
+
if (screen === void 0) return "";
|
|
1426
|
+
return screen.head === 0 ? screen.chunks.join("") : screen.chunks.slice(screen.head).join("");
|
|
1322
1427
|
}
|
|
1323
1428
|
/** Forget the retained screen (a fresh replay from the host replaces it). */
|
|
1324
1429
|
clearTerminalOutput(id) {
|
|
@@ -1793,10 +1898,10 @@ window.__ModuleLoader__.load({
|
|
|
1793
1898
|
proxyJump: splitList(form.proxyJump),
|
|
1794
1899
|
proxyCommand: form.proxyCommand.trim(),
|
|
1795
1900
|
forwardAgent: form.forwardAgent,
|
|
1796
|
-
description: form.description.trim()
|
|
1797
|
-
environment: form.environment.trim()
|
|
1901
|
+
description: form.description.trim(),
|
|
1902
|
+
environment: form.environment.trim(),
|
|
1798
1903
|
tags: splitList(form.tags),
|
|
1799
|
-
location: form.location.trim()
|
|
1904
|
+
location: form.location.trim()
|
|
1800
1905
|
};
|
|
1801
1906
|
setSaving(true);
|
|
1802
1907
|
setError(null);
|
|
@@ -2253,7 +2358,7 @@ window.__ModuleLoader__.load({
|
|
|
2253
2358
|
const [hosts, setHosts] = (0, react.useState)(null);
|
|
2254
2359
|
const [error, setError] = (0, react.useState)(null);
|
|
2255
2360
|
const [search, setSearch] = (0, react.useState)("");
|
|
2256
|
-
const [
|
|
2361
|
+
const [testingAliases, setTestingAliases] = (0, react.useState)(() => /* @__PURE__ */ new Set());
|
|
2257
2362
|
const [testResults, setTestResults] = (0, react.useState)({});
|
|
2258
2363
|
const [importing, setImporting] = (0, react.useState)(false);
|
|
2259
2364
|
const [notice, setNotice] = (0, react.useState)(null);
|
|
@@ -2265,8 +2370,11 @@ window.__ModuleLoader__.load({
|
|
|
2265
2370
|
const [testingGroup, setTestingGroup] = (0, react.useState)(null);
|
|
2266
2371
|
const seqRef = (0, react.useRef)(0);
|
|
2267
2372
|
const mountedRef = (0, react.useRef)(true);
|
|
2268
|
-
(0, react.useEffect)(() =>
|
|
2269
|
-
mountedRef.current =
|
|
2373
|
+
(0, react.useEffect)(() => {
|
|
2374
|
+
mountedRef.current = true;
|
|
2375
|
+
return () => {
|
|
2376
|
+
mountedRef.current = false;
|
|
2377
|
+
};
|
|
2270
2378
|
}, []);
|
|
2271
2379
|
const load = (0, react.useCallback)(async (query) => {
|
|
2272
2380
|
const seq = ++seqRef.current;
|
|
@@ -2280,21 +2388,37 @@ window.__ModuleLoader__.load({
|
|
|
2280
2388
|
setError(errorMessage(cause));
|
|
2281
2389
|
}
|
|
2282
2390
|
}, [api]);
|
|
2391
|
+
const loadedApiRef = (0, react.useRef)(null);
|
|
2283
2392
|
(0, react.useEffect)(() => {
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2393
|
+
const query = search.trim();
|
|
2394
|
+
const normalized = query === "" ? void 0 : query;
|
|
2395
|
+
if (loadedApiRef.current !== api) {
|
|
2396
|
+
loadedApiRef.current = api;
|
|
2397
|
+
load(normalized);
|
|
2398
|
+
return;
|
|
2399
|
+
}
|
|
2287
2400
|
const timer = setTimeout(() => {
|
|
2288
|
-
|
|
2289
|
-
load(query === "" ? void 0 : query);
|
|
2401
|
+
load(normalized);
|
|
2290
2402
|
}, 300);
|
|
2291
2403
|
return () => {
|
|
2292
2404
|
clearTimeout(timer);
|
|
2293
2405
|
};
|
|
2294
|
-
}, [
|
|
2406
|
+
}, [
|
|
2407
|
+
api,
|
|
2408
|
+
search,
|
|
2409
|
+
load
|
|
2410
|
+
]);
|
|
2411
|
+
const reloadCurrent = () => {
|
|
2412
|
+
const query = search.trim();
|
|
2413
|
+
load(query === "" ? void 0 : query);
|
|
2414
|
+
};
|
|
2295
2415
|
const runTest = async (alias) => {
|
|
2296
2416
|
if (!mountedRef.current) return;
|
|
2297
|
-
|
|
2417
|
+
setTestingAliases((prev) => {
|
|
2418
|
+
const next = new Set(prev);
|
|
2419
|
+
next.add(alias);
|
|
2420
|
+
return next;
|
|
2421
|
+
});
|
|
2298
2422
|
try {
|
|
2299
2423
|
const result = await api.testHost(alias);
|
|
2300
2424
|
if (!mountedRef.current) return;
|
|
@@ -2312,7 +2436,12 @@ window.__ModuleLoader__.load({
|
|
|
2312
2436
|
}
|
|
2313
2437
|
}));
|
|
2314
2438
|
} finally {
|
|
2315
|
-
if (mountedRef.current)
|
|
2439
|
+
if (mountedRef.current) setTestingAliases((prev) => {
|
|
2440
|
+
if (!prev.has(alias)) return prev;
|
|
2441
|
+
const next = new Set(prev);
|
|
2442
|
+
next.delete(alias);
|
|
2443
|
+
return next;
|
|
2444
|
+
});
|
|
2316
2445
|
}
|
|
2317
2446
|
};
|
|
2318
2447
|
const deleteHost = async (alias) => {
|
|
@@ -2320,7 +2449,7 @@ window.__ModuleLoader__.load({
|
|
|
2320
2449
|
try {
|
|
2321
2450
|
await api.deleteHost(alias);
|
|
2322
2451
|
if (!mountedRef.current) return;
|
|
2323
|
-
|
|
2452
|
+
reloadCurrent();
|
|
2324
2453
|
} catch (cause) {
|
|
2325
2454
|
if (!mountedRef.current) return;
|
|
2326
2455
|
setError(errorMessage(cause));
|
|
@@ -2347,7 +2476,7 @@ window.__ModuleLoader__.load({
|
|
|
2347
2476
|
skipped: result.skipped
|
|
2348
2477
|
}));
|
|
2349
2478
|
setImportSkips(result.skippedBlocks);
|
|
2350
|
-
|
|
2479
|
+
reloadCurrent();
|
|
2351
2480
|
} catch (cause) {
|
|
2352
2481
|
if (!mountedRef.current) return;
|
|
2353
2482
|
setError(errorMessage(cause));
|
|
@@ -2357,6 +2486,7 @@ window.__ModuleLoader__.load({
|
|
|
2357
2486
|
};
|
|
2358
2487
|
const renderHostRow = (host) => {
|
|
2359
2488
|
const test = testResults[host.alias];
|
|
2489
|
+
const testing = testingAliases.has(host.alias);
|
|
2360
2490
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
2361
2491
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
2362
2492
|
className: panel_module_css_default.mono,
|
|
@@ -2406,13 +2536,13 @@ window.__ModuleLoader__.load({
|
|
|
2406
2536
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2407
2537
|
type: "button",
|
|
2408
2538
|
className: panel_module_css_default.linkButton,
|
|
2409
|
-
disabled:
|
|
2539
|
+
disabled: testing,
|
|
2410
2540
|
onClick: () => {
|
|
2411
2541
|
runTest(host.alias);
|
|
2412
2542
|
},
|
|
2413
|
-
children:
|
|
2543
|
+
children: testing ? tt("hosts.testing") : tt("hosts.test")
|
|
2414
2544
|
}),
|
|
2415
|
-
|
|
2545
|
+
testing && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2416
2546
|
className: panel_module_css_default.spinner,
|
|
2417
2547
|
"aria-hidden": "true"
|
|
2418
2548
|
}),
|
|
@@ -2620,7 +2750,7 @@ window.__ModuleLoader__.load({
|
|
|
2620
2750
|
},
|
|
2621
2751
|
onSaved: () => {
|
|
2622
2752
|
setDialog(null);
|
|
2623
|
-
|
|
2753
|
+
reloadCurrent();
|
|
2624
2754
|
}
|
|
2625
2755
|
})
|
|
2626
2756
|
]
|
|
@@ -16043,6 +16173,8 @@ window.__ModuleLoader__.load({
|
|
|
16043
16173
|
const dataSubRef = (0, react.useRef)(null);
|
|
16044
16174
|
/** Tab whose screen the terminal currently holds. */
|
|
16045
16175
|
const renderedRef = (0, react.useRef)(void 0);
|
|
16176
|
+
/** Last geometry pushed to the active socket to skip duplicate resizes. */
|
|
16177
|
+
const lastSentSizeRef = (0, react.useRef)(null);
|
|
16046
16178
|
/** Tabs with a background close in flight, so one click cannot open two. */
|
|
16047
16179
|
const closingRef = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
16048
16180
|
const fontSource = terminalFont ?? NO_FONT_SOURCE;
|
|
@@ -16059,7 +16191,14 @@ window.__ModuleLoader__.load({
|
|
|
16059
16191
|
term.options.fontFamily = next;
|
|
16060
16192
|
fitRef.current?.fit();
|
|
16061
16193
|
const link = linkRef.current;
|
|
16062
|
-
if (link !== null)
|
|
16194
|
+
if (link !== null) {
|
|
16195
|
+
link.connection.resize(term.cols, term.rows);
|
|
16196
|
+
lastSentSizeRef.current = {
|
|
16197
|
+
connection: link.connection,
|
|
16198
|
+
cols: term.cols,
|
|
16199
|
+
rows: term.rows
|
|
16200
|
+
};
|
|
16201
|
+
}
|
|
16063
16202
|
}, [fontOverride]);
|
|
16064
16203
|
(0, react.useEffect)(() => {
|
|
16065
16204
|
let disposed = false;
|
|
@@ -16080,17 +16219,20 @@ window.__ModuleLoader__.load({
|
|
|
16080
16219
|
controller.setDraftAlias(presetAlias);
|
|
16081
16220
|
}, [presetAlias, controller]);
|
|
16082
16221
|
(0, react.useEffect)(() => {
|
|
16083
|
-
let lastCols = -1;
|
|
16084
|
-
let lastRows = -1;
|
|
16085
16222
|
const sync = () => {
|
|
16086
16223
|
const term = termRef.current;
|
|
16087
16224
|
const fit = fitRef.current;
|
|
16088
16225
|
if (term === null || fit === null) return;
|
|
16089
16226
|
fit.fit();
|
|
16090
16227
|
const link = linkRef.current;
|
|
16091
|
-
if (link
|
|
16092
|
-
|
|
16093
|
-
|
|
16228
|
+
if (link === null) return;
|
|
16229
|
+
const last = lastSentSizeRef.current;
|
|
16230
|
+
if (last === null || last.connection !== link.connection || term.cols !== last.cols || term.rows !== last.rows) {
|
|
16231
|
+
lastSentSizeRef.current = {
|
|
16232
|
+
connection: link.connection,
|
|
16233
|
+
cols: term.cols,
|
|
16234
|
+
rows: term.rows
|
|
16235
|
+
};
|
|
16094
16236
|
link.connection.resize(term.cols, term.rows);
|
|
16095
16237
|
}
|
|
16096
16238
|
};
|
|
@@ -16254,9 +16396,9 @@ window.__ModuleLoader__.load({
|
|
|
16254
16396
|
}
|
|
16255
16397
|
if (tab.status === "connected" && tab.sessionId !== void 0) {
|
|
16256
16398
|
const sessionId = tab.sessionId;
|
|
16399
|
+
controller.clearTerminalOutput(tab.id);
|
|
16257
16400
|
if (needsScreenClear(tab.id)) {
|
|
16258
16401
|
view.term.reset();
|
|
16259
|
-
controller.clearTerminalOutput(tab.id);
|
|
16260
16402
|
renderedRef.current = tab.id;
|
|
16261
16403
|
}
|
|
16262
16404
|
bindConnection(tab, api.attachTerminal(sessionId, view.term.cols, view.term.rows));
|
|
@@ -16908,6 +17050,13 @@ window.__ModuleLoader__.load({
|
|
|
16908
17050
|
};
|
|
16909
17051
|
}, [api]);
|
|
16910
17052
|
const seqRef = (0, react.useRef)(0);
|
|
17053
|
+
const mountedRef = (0, react.useRef)(true);
|
|
17054
|
+
(0, react.useEffect)(() => {
|
|
17055
|
+
mountedRef.current = true;
|
|
17056
|
+
return () => {
|
|
17057
|
+
mountedRef.current = false;
|
|
17058
|
+
};
|
|
17059
|
+
}, []);
|
|
16911
17060
|
const automaticRead = (0, react.useRef)({ running: false });
|
|
16912
17061
|
(0, react.useEffect)(() => {
|
|
16913
17062
|
if (!active) return;
|
|
@@ -16963,23 +17112,25 @@ window.__ModuleLoader__.load({
|
|
|
16963
17112
|
document.removeEventListener("visibilitychange", onVisibility);
|
|
16964
17113
|
};
|
|
16965
17114
|
}, [api, active]);
|
|
16966
|
-
const refresh = async () => {
|
|
17115
|
+
const refresh = async (preserveError = false) => {
|
|
16967
17116
|
const seq = ++seqRef.current;
|
|
16968
17117
|
try {
|
|
16969
17118
|
const list = await api.listTunnels();
|
|
16970
|
-
if (seq !== seqRef.current) return;
|
|
17119
|
+
if (!mountedRef.current || seq !== seqRef.current) return;
|
|
16971
17120
|
setTunnels(list);
|
|
16972
|
-
setError(null);
|
|
17121
|
+
if (!preserveError) setError(null);
|
|
16973
17122
|
} catch (cause) {
|
|
16974
|
-
if (seq !== seqRef.current) return;
|
|
16975
|
-
setError(errorMessage(cause));
|
|
17123
|
+
if (!mountedRef.current || seq !== seqRef.current) return;
|
|
17124
|
+
if (!preserveError) setError(errorMessage(cause));
|
|
16976
17125
|
}
|
|
16977
17126
|
};
|
|
16978
17127
|
const stopTunnel = async (tunnelId) => {
|
|
16979
17128
|
try {
|
|
16980
17129
|
await api.stopTunnel(tunnelId);
|
|
17130
|
+
if (!mountedRef.current) return;
|
|
16981
17131
|
await refresh();
|
|
16982
17132
|
} catch (cause) {
|
|
17133
|
+
if (!mountedRef.current) return;
|
|
16983
17134
|
setError(errorMessage(cause));
|
|
16984
17135
|
}
|
|
16985
17136
|
};
|
|
@@ -16988,11 +17139,13 @@ window.__ModuleLoader__.load({
|
|
|
16988
17139
|
setBusy(true);
|
|
16989
17140
|
try {
|
|
16990
17141
|
await api.stopAllTunnels(alias === "" ? void 0 : alias);
|
|
17142
|
+
if (!mountedRef.current) return;
|
|
16991
17143
|
await refresh();
|
|
16992
17144
|
} catch (cause) {
|
|
17145
|
+
if (!mountedRef.current) return;
|
|
16993
17146
|
setError(errorMessage(cause));
|
|
16994
17147
|
} finally {
|
|
16995
|
-
setBusy(false);
|
|
17148
|
+
if (mountedRef.current) setBusy(false);
|
|
16996
17149
|
}
|
|
16997
17150
|
};
|
|
16998
17151
|
const start = async () => {
|
|
@@ -17008,6 +17161,7 @@ window.__ModuleLoader__.load({
|
|
|
17008
17161
|
return;
|
|
17009
17162
|
}
|
|
17010
17163
|
setBusy(true);
|
|
17164
|
+
setError(null);
|
|
17011
17165
|
setNotice(null);
|
|
17012
17166
|
try {
|
|
17013
17167
|
const tunnel = await api.startTunnel({
|
|
@@ -17016,15 +17170,22 @@ window.__ModuleLoader__.load({
|
|
|
17016
17170
|
remoteHost: remoteHost.trim() === "" ? void 0 : remoteHost.trim(),
|
|
17017
17171
|
localPort: localPortNumber
|
|
17018
17172
|
});
|
|
17173
|
+
if (!mountedRef.current) return;
|
|
17174
|
+
if (tunnel.state === "failed") {
|
|
17175
|
+
setError(tt("tunnel.failed", { error: tunnel.error ?? "unknown error" }));
|
|
17176
|
+
await refresh(true);
|
|
17177
|
+
return;
|
|
17178
|
+
}
|
|
17019
17179
|
setNotice(tt("tunnel.started", { localPort: tunnel.localPort }));
|
|
17020
17180
|
setRemotePort("");
|
|
17021
17181
|
setRemoteHost("");
|
|
17022
17182
|
setLocalPort("");
|
|
17023
17183
|
await refresh();
|
|
17024
17184
|
} catch (cause) {
|
|
17185
|
+
if (!mountedRef.current) return;
|
|
17025
17186
|
setError(tt("tunnel.failed", { error: errorMessage(cause) }));
|
|
17026
17187
|
} finally {
|
|
17027
|
-
setBusy(false);
|
|
17188
|
+
if (mountedRef.current) setBusy(false);
|
|
17028
17189
|
}
|
|
17029
17190
|
};
|
|
17030
17191
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -17486,7 +17647,7 @@ window.__ModuleLoader__.load({
|
|
|
17486
17647
|
/** The building package's version, when the bundle carries it. */
|
|
17487
17648
|
function bakedVersion() {
|
|
17488
17649
|
try {
|
|
17489
|
-
return "0.4.
|
|
17650
|
+
return "0.4.21";
|
|
17490
17651
|
} catch {
|
|
17491
17652
|
return;
|
|
17492
17653
|
}
|