@linxin666/dsh-ssh 0.4.11 → 0.4.13
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/README.i18n.yaml +2 -2
- package/README.md +2 -2
- package/README.zh.md +2 -2
- package/lib/client.js +740 -162
- package/lib/client.js.map +1 -1
- package/lib/types/client/api.d.ts +21 -0
- package/lib/types/client/locales.d.ts +7 -0
- package/lib/types/client/panel/TerminalTab.d.ts +12 -7
- package/lib/types/client/panel/controller.d.ts +185 -21
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +5 -2
- package/src/client/api.ts +70 -0
- package/src/client/locales.ts +14 -0
- package/src/client/panel/SshPanel.tsx +7 -15
- package/src/client/panel/TerminalTab.tsx +371 -151
- package/src/client/panel/controller.ts +370 -30
- package/src/client/panel/panel.module.css +102 -0
package/lib/client.js
CHANGED
|
@@ -125,6 +125,13 @@ window.__ModuleLoader__.load({
|
|
|
125
125
|
"terminal.auth.cancel": "取消",
|
|
126
126
|
"terminal.auth.placeholder": "请输入验证码或口令",
|
|
127
127
|
"terminal.auth.hint": "服务器请求进行交互式二次验证(输入仅本次生效,不落盘):",
|
|
128
|
+
"terminal.tabs": "终端标签",
|
|
129
|
+
"terminal.newTab": "按当前主机新开标签",
|
|
130
|
+
"terminal.closeTab": "关闭标签",
|
|
131
|
+
"terminal.authPending": "待验证",
|
|
132
|
+
"terminal.tabExited": "已退出",
|
|
133
|
+
"terminal.tabError": "出错",
|
|
134
|
+
"terminal.closeFailed": "无法确认该标签已关闭:关闭帧未送达宿主。标签已保留——可重试,或切到该标签前台,用它自己的连接关闭。",
|
|
128
135
|
"transfer.selectHost": "选择主机",
|
|
129
136
|
"transfer.remotePath": "远程路径",
|
|
130
137
|
"transfer.remotePathHint": "如 /tmp/ 或 /home/user/app.tar.gz",
|
|
@@ -285,6 +292,13 @@ window.__ModuleLoader__.load({
|
|
|
285
292
|
"terminal.auth.cancel": "Cancel",
|
|
286
293
|
"terminal.auth.placeholder": "Enter code or passphrase",
|
|
287
294
|
"terminal.auth.hint": "The server requested interactive 2FA (session only, never saved):",
|
|
295
|
+
"terminal.tabs": "Terminal tabs",
|
|
296
|
+
"terminal.newTab": "New tab on the current host",
|
|
297
|
+
"terminal.closeTab": "Close tab",
|
|
298
|
+
"terminal.authPending": "2FA pending",
|
|
299
|
+
"terminal.tabExited": "exited",
|
|
300
|
+
"terminal.tabError": "error",
|
|
301
|
+
"terminal.closeFailed": "Could not confirm the tab closed: the close never reached the host, so the tab was kept. Retry, or bring the tab to the front and close it over its own connection.",
|
|
288
302
|
"transfer.selectHost": "Select host",
|
|
289
303
|
"transfer.remotePath": "Remote path",
|
|
290
304
|
"transfer.remotePathHint": "e.g. /tmp/ or /home/user/app.tar.gz",
|
|
@@ -787,6 +801,78 @@ window.__ModuleLoader__.load({
|
|
|
787
801
|
rows
|
|
788
802
|
}));
|
|
789
803
|
}
|
|
804
|
+
/**
|
|
805
|
+
* End a host session this view is not attached to (closing a background
|
|
806
|
+
* tab). The session has no other handle from the browser: giving it a
|
|
807
|
+
* dedicated HTTP route would widen the host's surface for one frame, so this
|
|
808
|
+
* opens one short-lived attach instead and sends the close frame as soon as
|
|
809
|
+
* the socket is open.
|
|
810
|
+
*
|
|
811
|
+
* The answer is "is this session no longer running", which has three
|
|
812
|
+
* truthful answers and one lie to avoid:
|
|
813
|
+
* - the frame went out on an open socket: the host ends the session;
|
|
814
|
+
* - the host answered with an exit frame: an unknown id is reported as
|
|
815
|
+
* `terminal session expired` and an ended shell also exits, and in both
|
|
816
|
+
* cases nothing is running, so the tab really is closed;
|
|
817
|
+
* - the socket errored, closed before opening, or never settled inside
|
|
818
|
+
* `timeoutMs`: delivery is unproven, so the session may still be alive and
|
|
819
|
+
* the caller must keep the tab instead of claiming it closed.
|
|
820
|
+
* @param sessionId - the session id the host reported on its ready frame.
|
|
821
|
+
* @param timeoutMs - bounded wait for the delivery signal (default 5000).
|
|
822
|
+
* @returns true when the session is known to be gone.
|
|
823
|
+
*/
|
|
824
|
+
closeTerminalSession(sessionId, timeoutMs = 5e3) {
|
|
825
|
+
const target = terminalSocketUrl(window.location, query({
|
|
826
|
+
session: sessionId,
|
|
827
|
+
cols: 2,
|
|
828
|
+
rows: 1
|
|
829
|
+
}), transportStreamBaseUrl());
|
|
830
|
+
if (target === void 0) return Promise.resolve(false);
|
|
831
|
+
let socket;
|
|
832
|
+
try {
|
|
833
|
+
socket = new WebSocket(target);
|
|
834
|
+
} catch {
|
|
835
|
+
return Promise.resolve(false);
|
|
836
|
+
}
|
|
837
|
+
return new Promise((resolve) => {
|
|
838
|
+
let settled = false;
|
|
839
|
+
let timer;
|
|
840
|
+
const finish = (gone) => {
|
|
841
|
+
if (settled) return;
|
|
842
|
+
settled = true;
|
|
843
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
844
|
+
try {
|
|
845
|
+
socket.close();
|
|
846
|
+
} catch {}
|
|
847
|
+
resolve(gone);
|
|
848
|
+
};
|
|
849
|
+
timer = setTimeout(() => {
|
|
850
|
+
finish(false);
|
|
851
|
+
}, timeoutMs);
|
|
852
|
+
socket.onopen = () => {
|
|
853
|
+
const closeFrame = { type: "close" };
|
|
854
|
+
try {
|
|
855
|
+
socket.send(JSON.stringify(closeFrame));
|
|
856
|
+
finish(true);
|
|
857
|
+
} catch {}
|
|
858
|
+
};
|
|
859
|
+
socket.onmessage = (event) => {
|
|
860
|
+
let frame;
|
|
861
|
+
try {
|
|
862
|
+
frame = JSON.parse(event.data);
|
|
863
|
+
} catch {
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
if (frame.type === "exit") finish(true);
|
|
867
|
+
};
|
|
868
|
+
socket.onerror = () => {
|
|
869
|
+
finish(false);
|
|
870
|
+
};
|
|
871
|
+
socket.onclose = () => {
|
|
872
|
+
finish(false);
|
|
873
|
+
};
|
|
874
|
+
});
|
|
875
|
+
}
|
|
790
876
|
/** One terminal socket over either an alias (open) or a session id (attach). */
|
|
791
877
|
terminalSocket(search) {
|
|
792
878
|
const target = terminalSocketUrl(window.location, search, transportStreamBaseUrl());
|
|
@@ -861,20 +947,51 @@ window.__ModuleLoader__.load({
|
|
|
861
947
|
return connection;
|
|
862
948
|
}
|
|
863
949
|
};
|
|
950
|
+
/** Byte cap for the retained screen of one tab (the host buffers 256 KiB too). */
|
|
951
|
+
const MAX_RETAINED_BYTES = 256 * 1024;
|
|
952
|
+
/**
|
|
953
|
+
* UTF-8 byte length of one chunk, without node's Buffer (this half is bundled
|
|
954
|
+
* for the browser). Surrogate pairs count as the four bytes they encode to.
|
|
955
|
+
* @param text - the output chunk.
|
|
956
|
+
* @returns its UTF-8 byte length.
|
|
957
|
+
*/
|
|
958
|
+
function utf8Bytes(text) {
|
|
959
|
+
let bytes = 0;
|
|
960
|
+
for (const char of text) {
|
|
961
|
+
const code = char.codePointAt(0) ?? 0;
|
|
962
|
+
bytes += code < 128 ? 1 : code < 2048 ? 2 : code < 65536 ? 3 : 4;
|
|
963
|
+
}
|
|
964
|
+
return bytes;
|
|
965
|
+
}
|
|
864
966
|
/** The panel state owner the sidebar row and the view both read. */
|
|
865
967
|
var PanelController = class {
|
|
866
968
|
deps;
|
|
867
969
|
panelOpen = false;
|
|
868
970
|
activeTab = "hosts";
|
|
869
|
-
|
|
870
|
-
|
|
971
|
+
terminalTabs = [];
|
|
972
|
+
activeTerminalTabId;
|
|
973
|
+
draftAlias = "";
|
|
974
|
+
nextTerminalTabSeq = 0;
|
|
871
975
|
listeners = /* @__PURE__ */ new Set();
|
|
976
|
+
/**
|
|
977
|
+
* Last screen of each tab, kept outside the snapshot: terminal output must
|
|
978
|
+
* not re-render the panel on every chunk, and only the terminal view reads
|
|
979
|
+
* this (when a tab has no session left to replay from).
|
|
980
|
+
*/
|
|
981
|
+
retainedScreens = /* @__PURE__ */ new Map();
|
|
982
|
+
/**
|
|
983
|
+
* Sockets that outlived their view while still connecting. Their session id
|
|
984
|
+
* is unknown, so they cannot be detached yet; keeping them here is what
|
|
985
|
+
* prevents a host PTY with no owner.
|
|
986
|
+
*/
|
|
987
|
+
adoptedLinks = /* @__PURE__ */ new Map();
|
|
872
988
|
/** Cached so getSnapshot is referentially stable between changes. */
|
|
873
989
|
snapshot = {
|
|
874
990
|
panelOpen: false,
|
|
875
991
|
activeTab: "hosts",
|
|
876
|
-
|
|
877
|
-
|
|
992
|
+
terminalTabs: [],
|
|
993
|
+
activeTerminalTabId: void 0,
|
|
994
|
+
draftAlias: ""
|
|
878
995
|
};
|
|
879
996
|
constructor(deps = {}) {
|
|
880
997
|
this.deps = deps;
|
|
@@ -928,33 +1045,274 @@ window.__ModuleLoader__.load({
|
|
|
928
1045
|
this.activeTab = tab;
|
|
929
1046
|
this.commit();
|
|
930
1047
|
}
|
|
931
|
-
/**
|
|
1048
|
+
/**
|
|
1049
|
+
* Hand the terminal tab a host to connect to (the hosts-tab "connect"
|
|
1050
|
+
* action): the tab exists before the view does, so a panel switch during the
|
|
1051
|
+
* handshake still shows the connecting tab and adopts its socket.
|
|
1052
|
+
* @param alias - the configured host alias.
|
|
1053
|
+
*/
|
|
932
1054
|
requestConnect(alias) {
|
|
933
|
-
this.connectRequest = {
|
|
934
|
-
alias,
|
|
935
|
-
nonce: Date.now()
|
|
936
|
-
};
|
|
937
1055
|
this.activeTab = "terminal";
|
|
1056
|
+
this.openTerminalTab(alias);
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Add a terminal tab on the alias and make it the shown one. Several tabs
|
|
1060
|
+
* may target one alias on purpose: each owns its own host PTY.
|
|
1061
|
+
* @param alias - the configured host alias.
|
|
1062
|
+
* @returns the new tab id.
|
|
1063
|
+
*/
|
|
1064
|
+
openTerminalTab(alias) {
|
|
1065
|
+
this.nextTerminalTabSeq += 1;
|
|
1066
|
+
const id = "tab-" + String(this.nextTerminalTabSeq);
|
|
1067
|
+
this.terminalTabs = [...this.terminalTabs, {
|
|
1068
|
+
id,
|
|
1069
|
+
alias,
|
|
1070
|
+
status: "connecting"
|
|
1071
|
+
}];
|
|
1072
|
+
this.activeTerminalTabId = id;
|
|
1073
|
+
this.draftAlias = alias;
|
|
1074
|
+
this.retainedScreens.delete(id);
|
|
1075
|
+
this.commit();
|
|
1076
|
+
return id;
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* Show an existing tab and make the toolbar follow its host, so a new tab
|
|
1080
|
+
* opens on the host the user is looking at.
|
|
1081
|
+
* @param id - the tab id.
|
|
1082
|
+
*/
|
|
1083
|
+
setActiveTerminalTab(id) {
|
|
1084
|
+
if (this.activeTerminalTabId === id) return;
|
|
1085
|
+
const tab = this.terminalTab(id);
|
|
1086
|
+
if (tab === void 0) return;
|
|
1087
|
+
this.activeTerminalTabId = id;
|
|
1088
|
+
this.draftAlias = tab.alias;
|
|
938
1089
|
this.commit();
|
|
939
1090
|
}
|
|
940
|
-
/**
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
1091
|
+
/**
|
|
1092
|
+
* Remove one tab and forget its screen. When the shown tab closes, the
|
|
1093
|
+
* neighbours decide what the xterm shows next: the tab that took its place,
|
|
1094
|
+
* else the one before it, else nothing.
|
|
1095
|
+
* @param id - the tab id.
|
|
1096
|
+
*/
|
|
1097
|
+
closeTerminalTab(id) {
|
|
1098
|
+
const index = this.terminalTabs.findIndex((tab) => tab.id === id);
|
|
1099
|
+
this.retainedScreens.delete(id);
|
|
1100
|
+
const adopted = this.adoptedLinks.get(id);
|
|
1101
|
+
if (adopted !== void 0) adopted.intent = "close";
|
|
1102
|
+
if (index < 0) return;
|
|
1103
|
+
const wasActive = this.activeTerminalTabId === id;
|
|
1104
|
+
this.terminalTabs = this.terminalTabs.filter((tab) => tab.id !== id);
|
|
1105
|
+
if (wasActive) {
|
|
1106
|
+
const neighbour = this.terminalTabs[index] ?? this.terminalTabs[index - 1];
|
|
1107
|
+
this.activeTerminalTabId = neighbour?.id;
|
|
1108
|
+
if (neighbour !== void 0) this.draftAlias = neighbour.alias;
|
|
1109
|
+
}
|
|
944
1110
|
this.commit();
|
|
945
1111
|
}
|
|
946
|
-
/**
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
1112
|
+
/** The tab record with this id, or undefined when it no longer exists. */
|
|
1113
|
+
terminalTab(id) {
|
|
1114
|
+
return this.terminalTabs.find((tab) => tab.id === id);
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Apply a partial update to one tab; a tab that was closed in the meantime
|
|
1118
|
+
* is left alone rather than resurrected.
|
|
1119
|
+
* @param id - the tab id.
|
|
1120
|
+
* @param patch - the fields to change.
|
|
1121
|
+
*/
|
|
1122
|
+
patchTerminalTab(id, patch) {
|
|
1123
|
+
let found = false;
|
|
1124
|
+
const next = this.terminalTabs.map((tab) => {
|
|
1125
|
+
if (tab.id !== id) return tab;
|
|
1126
|
+
found = true;
|
|
1127
|
+
return {
|
|
1128
|
+
...tab,
|
|
1129
|
+
...patch
|
|
1130
|
+
};
|
|
1131
|
+
});
|
|
1132
|
+
if (!found) return;
|
|
1133
|
+
this.terminalTabs = next;
|
|
950
1134
|
this.commit();
|
|
951
1135
|
}
|
|
1136
|
+
/**
|
|
1137
|
+
* Record the host session of a ready tab and clear the challenge it carried.
|
|
1138
|
+
* @param id - the tab id.
|
|
1139
|
+
* @param sessionId - the id the host reported on its ready frame.
|
|
1140
|
+
*/
|
|
1141
|
+
readyTerminalTab(id, sessionId) {
|
|
1142
|
+
this.patchTerminalTab(id, {
|
|
1143
|
+
status: "connected",
|
|
1144
|
+
sessionId,
|
|
1145
|
+
detail: void 0,
|
|
1146
|
+
closeError: void 0,
|
|
1147
|
+
authPrompt: void 0,
|
|
1148
|
+
authAnswers: void 0
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
/**
|
|
1152
|
+
* The remote shell ended: the tab keeps its screen and its place, and the
|
|
1153
|
+
* dead session id is dropped so nothing tries to reattach to it.
|
|
1154
|
+
* @param id - the tab id.
|
|
1155
|
+
* @param detail - why it ended, when the transport said.
|
|
1156
|
+
*/
|
|
1157
|
+
exitTerminalTab(id, detail) {
|
|
1158
|
+
this.patchTerminalTab(id, {
|
|
1159
|
+
status: "exited",
|
|
1160
|
+
sessionId: void 0,
|
|
1161
|
+
detail,
|
|
1162
|
+
authPrompt: void 0,
|
|
1163
|
+
authAnswers: void 0,
|
|
1164
|
+
closeError: void 0
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
/**
|
|
1168
|
+
* The connection failed. The tab stays with the reason so the user can read
|
|
1169
|
+
* it and close the tab themselves.
|
|
1170
|
+
* @param id - the tab id.
|
|
1171
|
+
* @param detail - the failure text.
|
|
1172
|
+
*/
|
|
1173
|
+
failTerminalTab(id, detail) {
|
|
1174
|
+
this.patchTerminalTab(id, {
|
|
1175
|
+
status: "error",
|
|
1176
|
+
sessionId: void 0,
|
|
1177
|
+
detail,
|
|
1178
|
+
authPrompt: void 0,
|
|
1179
|
+
authAnswers: void 0,
|
|
1180
|
+
closeError: void 0
|
|
1181
|
+
});
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
* A background close never reached the host. The tab keeps its live session
|
|
1185
|
+
* id (so a retry can still end it) and says so instead of vanishing.
|
|
1186
|
+
* @param id - the tab id.
|
|
1187
|
+
* @param reason - the reason code shown by the view.
|
|
1188
|
+
*/
|
|
1189
|
+
markTerminalCloseFailed(id, reason) {
|
|
1190
|
+
this.patchTerminalTab(id, { closeError: reason });
|
|
1191
|
+
}
|
|
1192
|
+
/**
|
|
1193
|
+
* Store the keyboard-interactive challenge this tab has to answer, with a
|
|
1194
|
+
* blank answer of this challenge's own length. A prompt on another tab never
|
|
1195
|
+
* touches this record, which is what keeps two challenges from sharing input.
|
|
1196
|
+
* @param id - the tab id.
|
|
1197
|
+
* @param prompt - the challenge the host asked for.
|
|
1198
|
+
*/
|
|
1199
|
+
setTerminalAuthPrompt(id, prompt) {
|
|
1200
|
+
this.patchTerminalTab(id, {
|
|
1201
|
+
authPrompt: prompt,
|
|
1202
|
+
authAnswers: prompt.prompts.map(() => "")
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
/**
|
|
1206
|
+
* Record one character typed for this tab's challenge.
|
|
1207
|
+
* @param id - the tab id.
|
|
1208
|
+
* @param index - which prompt of the challenge.
|
|
1209
|
+
* @param value - the field's current text.
|
|
1210
|
+
*/
|
|
1211
|
+
setTerminalAuthAnswer(id, index, value) {
|
|
1212
|
+
const tab = this.terminalTab(id);
|
|
1213
|
+
if (tab === void 0 || tab.authPrompt === void 0) return;
|
|
1214
|
+
const answers = [...tab.authAnswers ?? tab.authPrompt.prompts.map(() => "")];
|
|
1215
|
+
answers[index] = value;
|
|
1216
|
+
this.patchTerminalTab(id, { authAnswers: answers });
|
|
1217
|
+
}
|
|
1218
|
+
/** Drop the challenge once it was answered, cancelled, or could not apply. */
|
|
1219
|
+
clearTerminalAuthPrompt(id) {
|
|
1220
|
+
if (this.terminalTab(id)?.authPrompt === void 0) return;
|
|
1221
|
+
this.patchTerminalTab(id, {
|
|
1222
|
+
authPrompt: void 0,
|
|
1223
|
+
authAnswers: void 0
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1226
|
+
/** Choose the alias the next terminal tab opens on. */
|
|
1227
|
+
setDraftAlias(alias) {
|
|
1228
|
+
if (this.draftAlias === alias) return;
|
|
1229
|
+
this.draftAlias = alias;
|
|
1230
|
+
this.commit();
|
|
1231
|
+
}
|
|
1232
|
+
/** Append one output chunk to the retained screen of a tab. */
|
|
1233
|
+
appendTerminalOutput(id, chunk) {
|
|
1234
|
+
const screen = this.retainedScreens.get(id) ?? {
|
|
1235
|
+
chunks: [],
|
|
1236
|
+
bytes: 0
|
|
1237
|
+
};
|
|
1238
|
+
screen.chunks.push(chunk);
|
|
1239
|
+
screen.bytes += utf8Bytes(chunk);
|
|
1240
|
+
while (screen.bytes > MAX_RETAINED_BYTES && screen.chunks.length > 1) {
|
|
1241
|
+
const dropped = screen.chunks.shift() ?? "";
|
|
1242
|
+
screen.bytes -= utf8Bytes(dropped);
|
|
1243
|
+
}
|
|
1244
|
+
this.retainedScreens.set(id, screen);
|
|
1245
|
+
}
|
|
1246
|
+
/** The retained screen of a tab, concatenated for a redraw. */
|
|
1247
|
+
readTerminalOutput(id) {
|
|
1248
|
+
return (this.retainedScreens.get(id)?.chunks ?? []).join("");
|
|
1249
|
+
}
|
|
1250
|
+
/** Forget the retained screen (a fresh replay from the host replaces it). */
|
|
1251
|
+
clearTerminalOutput(id) {
|
|
1252
|
+
this.retainedScreens.delete(id);
|
|
1253
|
+
}
|
|
1254
|
+
/**
|
|
1255
|
+
* Keep a still-connecting socket alive after its view went away. The socket
|
|
1256
|
+
* cannot be detached yet (no session id), so the intent is applied when the
|
|
1257
|
+
* host reports it: `detach` leaves the shell for a later reattach, `close`
|
|
1258
|
+
* ends the session of a tab the user closed.
|
|
1259
|
+
* @param tabId - the tab the socket belongs to.
|
|
1260
|
+
* @param connection - the live connection.
|
|
1261
|
+
* @param intent - what to do once the session id arrives.
|
|
1262
|
+
*/
|
|
1263
|
+
adoptTerminalLink(tabId, connection, intent) {
|
|
1264
|
+
const entry = {
|
|
1265
|
+
connection,
|
|
1266
|
+
intent
|
|
1267
|
+
};
|
|
1268
|
+
this.adoptedLinks.set(tabId, entry);
|
|
1269
|
+
connection.onOutput = (data) => {
|
|
1270
|
+
if (this.terminalTab(tabId) === void 0) return;
|
|
1271
|
+
this.appendTerminalOutput(tabId, data);
|
|
1272
|
+
};
|
|
1273
|
+
connection.onAuthPrompt = (name, instructions, prompts) => {
|
|
1274
|
+
if (this.terminalTab(tabId) === void 0) return;
|
|
1275
|
+
this.setTerminalAuthPrompt(tabId, {
|
|
1276
|
+
name,
|
|
1277
|
+
instructions,
|
|
1278
|
+
prompts
|
|
1279
|
+
});
|
|
1280
|
+
};
|
|
1281
|
+
connection.onReady = (sessionId) => {
|
|
1282
|
+
const decided = this.adoptedLinks.get(tabId)?.intent ?? entry.intent;
|
|
1283
|
+
this.adoptedLinks.delete(tabId);
|
|
1284
|
+
this.readyTerminalTab(tabId, sessionId);
|
|
1285
|
+
if (decided === "close") connection.close();
|
|
1286
|
+
else connection.detach();
|
|
1287
|
+
};
|
|
1288
|
+
connection.onExit = (_code, error) => {
|
|
1289
|
+
this.adoptedLinks.delete(tabId);
|
|
1290
|
+
this.failTerminalTab(tabId, error ?? "connection closed");
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
/**
|
|
1294
|
+
* Take an adopted socket back when its tab is shown again, so the host never
|
|
1295
|
+
* opens a second PTY for the same tab.
|
|
1296
|
+
* @param tabId - the tab id.
|
|
1297
|
+
* @returns the connection, or undefined when nothing was adopted.
|
|
1298
|
+
*/
|
|
1299
|
+
reclaimTerminalLink(tabId) {
|
|
1300
|
+
const adopted = this.adoptedLinks.get(tabId);
|
|
1301
|
+
if (adopted === void 0) return void 0;
|
|
1302
|
+
if (adopted.intent === "close") return void 0;
|
|
1303
|
+
this.adoptedLinks.delete(tabId);
|
|
1304
|
+
adopted.connection.onReady = void 0;
|
|
1305
|
+
adopted.connection.onExit = void 0;
|
|
1306
|
+
adopted.connection.onAuthPrompt = void 0;
|
|
1307
|
+
return adopted.connection;
|
|
1308
|
+
}
|
|
952
1309
|
commit() {
|
|
953
1310
|
this.snapshot = {
|
|
954
1311
|
panelOpen: this.panelOpen,
|
|
955
1312
|
activeTab: this.activeTab,
|
|
956
|
-
|
|
957
|
-
|
|
1313
|
+
terminalTabs: this.terminalTabs,
|
|
1314
|
+
activeTerminalTabId: this.activeTerminalTabId,
|
|
1315
|
+
draftAlias: this.draftAlias
|
|
958
1316
|
};
|
|
959
1317
|
for (const fn of [...this.listeners]) fn();
|
|
960
1318
|
}
|
|
@@ -967,7 +1325,7 @@ window.__ModuleLoader__.load({
|
|
|
967
1325
|
};
|
|
968
1326
|
//#endregion
|
|
969
1327
|
//#region \0dsh-css:packages/dsh-ssh/src/client/panel/panel.module.css.mjs
|
|
970
|
-
const css = ".mL8Uca_view{height:100%;min-height:0;overflow:hidden}.mL8Uca_panel{background:var(--dsw-alias-bg-base);min-width:0;height:100%;min-height:0;color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family);flex-direction:column;gap:10px;padding:14px 16px 16px;display:flex}.mL8Uca_panelHeader{flex:none;align-items:center;gap:10px;display:flex}.mL8Uca_panelTitle{color:var(--dsw-alias-label-primary);white-space:nowrap;flex:1;margin:0;font-size:16px;font-weight:700}.mL8Uca_backButton{align-items:center;gap:4px;display:inline-flex}.mL8Uca_tabBar{border-bottom:1px solid var(--dsw-alias-border-l1);flex:none;gap:2px;display:flex}.mL8Uca_tab{color:var(--dsw-alias-label-secondary);cursor:pointer;white-space:nowrap;background:0 0;border:none;border-bottom:2px solid #0000;border-radius:6px 6px 0 0;padding:7px 14px;font-size:13px}.mL8Uca_tab:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}.mL8Uca_tab[data-active]{color:var(--dsw-alias-label-primary);border-bottom-color:var(--dsw-alias-state-business-primary);font-weight:600}.mL8Uca_panelContent{flex-direction:column;flex:1;min-height:0;display:flex;overflow:hidden}.mL8Uca_tabBody{flex-direction:column;flex:1;gap:10px;min-height:0;display:flex;overflow-y:auto}.mL8Uca_fillBody{flex-direction:column;flex:1;gap:10px;min-height:0;display:flex;overflow:hidden}.mL8Uca_toolbar,.mL8Uca_controls{flex-wrap:wrap;flex:none;align-items:center;gap:8px;display:flex}.mL8Uca_controls .mL8Uca_input{flex:0 260px;min-width:150px}.mL8Uca_toolbarSpacer{flex:1}.mL8Uca_search{min-width:120px;color:var(--dsw-alias-label-primary);background:var(--dsw-specific-input-major);border:1px solid var(--dsw-alias-border-l2);border-radius:8px;outline:none;flex:0 260px;padding:6px 10px;font-size:13px}.mL8Uca_search::placeholder{color:var(--dsw-alias-label-tertiary)}.mL8Uca_groupBySelect{color:var(--dsw-alias-label-primary);background:var(--dsw-specific-input-major);border:1px solid var(--dsw-alias-border-l2);border-radius:8px;outline:none;padding:6px 8px;font-size:13px}.mL8Uca_groupSection+.mL8Uca_groupSection{border-top:1px solid var(--dsw-alias-border-l1)}.mL8Uca_groupHeader{background:var(--dsw-alias-bg-base,var(--dsw-specific-input-major));align-items:center;gap:8px;padding:4px 8px;display:flex;position:sticky;top:0}.mL8Uca_groupToggle{min-width:0;color:var(--dsw-alias-label-primary);cursor:pointer;text-align:left;background:0 0;border:none;border-radius:6px;flex:1;align-items:center;gap:6px;padding:4px 6px;font-size:12.5px;font-weight:500;display:flex}.mL8Uca_groupToggle:hover{background:var(--dsw-alias-interactive-bg-hover)}.mL8Uca_groupChevron{border-right:1.5px solid var(--dsw-alias-label-tertiary);border-bottom:1.5px solid var(--dsw-alias-label-tertiary);flex:none;width:7px;height:7px;margin-bottom:2px;transition:transform .12s;transform:rotate(45deg)}.mL8Uca_groupChevron[data-collapsed]{margin-bottom:0;transform:rotate(-45deg)}.mL8Uca_groupName{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.mL8Uca_groupCount{color:var(--dsw-alias-label-tertiary);flex:none;font-weight:400}.mL8Uca_tableWrap{border:1px solid var(--dsw-alias-border-l1);border-radius:10px;flex:1;min-height:0;overflow:auto}.mL8Uca_table{border-collapse:collapse;width:100%;font-size:12.5px}.mL8Uca_table th{z-index:1;text-align:left;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap;padding:8px 10px;font-weight:600;position:sticky;top:0}.mL8Uca_table td{border-bottom:1px solid var(--dsw-alias-separator-primary);vertical-align:top;padding:7px 10px}.mL8Uca_table tbody tr:last-child td{border-bottom:none}.mL8Uca_table tbody tr:hover td{background:var(--dsw-alias-interactive-bg-hover)}.mL8Uca_mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.mL8Uca_cellMuted{color:var(--dsw-alias-label-tertiary)}.mL8Uca_actions{white-space:nowrap;align-items:center;gap:8px;display:flex}.mL8Uca_inlineTest{color:var(--dsw-alias-label-secondary);align-items:center;gap:6px;font-size:11.5px;display:inline-flex}.mL8Uca_inlineTest[data-status=ok]{color:var(--dsw-alias-state-success-primary)}.mL8Uca_inlineTest[data-status=fail]{color:var(--dsw-alias-state-error-primary)}.mL8Uca_badge{border:1px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);white-space:nowrap;border-radius:999px;padding:1px 8px;font-size:11px;line-height:1.6;display:inline-block}.mL8Uca_badge[data-kind=key]{color:var(--dsw-alias-state-business-primary);border-color:var(--dsw-alias-state-business-primary)}.mL8Uca_badge[data-kind=password]{color:var(--dsw-alias-state-warn-primary);border-color:var(--dsw-alias-state-warn-primary)}.mL8Uca_badge[data-kind=agent]{color:var(--dsw-alias-state-success-primary);border-color:var(--dsw-alias-state-success-primary)}.mL8Uca_badge[data-kind=proxy]{color:var(--dsw-alias-state-business-primary);border-color:var(--dsw-alias-state-business-primary);margin-left:6px}.mL8Uca_badge[data-kind=forward-agent]{color:var(--dsw-alias-state-warn-primary);border-color:var(--dsw-alias-state-warn-primary);margin-left:6px}.mL8Uca_badge[data-status=ok]{color:var(--dsw-alias-state-success-primary);border-color:var(--dsw-alias-state-success-primary)}.mL8Uca_badge[data-status=fail]{color:var(--dsw-alias-state-error-primary);border-color:var(--dsw-alias-state-error-primary)}.mL8Uca_badge[data-status=timeout]{color:var(--dsw-alias-state-warn-primary);border-color:var(--dsw-alias-state-warn-primary)}.mL8Uca_primaryButton{color:var(--dsw-alias-label-primary-foreground);background:var(--dsw-alias-button-info-fill);cursor:pointer;white-space:nowrap;border:none;border-radius:8px;padding:6px 14px;font-size:13px;font-weight:600}.mL8Uca_primaryButton:hover:not(:disabled){background:var(--dsw-alias-button-info-hover)}.mL8Uca_primaryButton:disabled{opacity:.5;cursor:default}.mL8Uca_ghostButton{color:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l2);cursor:pointer;white-space:nowrap;background:0 0;border-radius:8px;padding:5px 12px;font-size:12px}.mL8Uca_ghostButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.mL8Uca_ghostButton:disabled{opacity:.45;cursor:default}.mL8Uca_iconButton{width:26px;height:26px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;padding:0;font-size:13px;display:inline-flex}.mL8Uca_iconButton:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.mL8Uca_linkButton{color:var(--dsw-alias-state-business-primary);cursor:pointer;white-space:nowrap;background:0 0;border:none;padding:0;font-size:12px}.mL8Uca_linkButton:hover:not(:disabled){text-decoration:underline}.mL8Uca_linkButton:disabled{opacity:.45;cursor:default}.mL8Uca_linkButton[data-danger]{color:var(--dsw-alias-state-error-primary)}.mL8Uca_spinner{border:2px solid var(--dsw-alias-state-business-primary);vertical-align:-1px;border-top-color:#0000;border-radius:50%;flex:none;width:11px;height:11px;animation:.8s linear infinite mL8Uca_dshSshSpin;display:inline-block}@keyframes mL8Uca_dshSshSpin{to{transform:rotate(360deg)}}.mL8Uca_banner{border:1px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere;border-radius:8px;padding:8px 12px;font-size:12.5px;line-height:1.5}.mL8Uca_importSkips{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-2);border-radius:8px;flex-direction:column;gap:4px;margin:6px 0 0;padding:8px 12px;list-style:none;display:flex}.mL8Uca_importSkipRow{justify-content:space-between;align-items:baseline;gap:12px;font-size:12px;display:flex}.mL8Uca_banner[data-kind=ok]{color:var(--dsw-alias-state-success-primary);border-color:var(--dsw-alias-state-success-primary)}.mL8Uca_banner[data-kind=error]{color:var(--dsw-alias-state-error-primary);border-color:var(--dsw-alias-state-error-primary)}.mL8Uca_banner[data-kind=info]{color:var(--dsw-alias-state-business-primary);border-color:var(--dsw-alias-state-business-primary)}.mL8Uca_empty,.mL8Uca_loading{text-align:center;color:var(--dsw-alias-label-tertiary);padding:28px 12px;font-size:12.5px}.mL8Uca_modalBackdrop{z-index:40;background:var(--dsw-alias-bg-mask-1);justify-content:center;align-items:center;display:flex;position:fixed;inset:0}.mL8Uca_modal{background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l2);width:min(560px,100vw - 48px);max-height:calc(100vh - 96px);box-shadow:var(--dsw-shadow-lv3);color:var(--dsw-alias-label-primary);border-radius:14px;flex-direction:column;gap:12px;padding:18px;display:flex;overflow-y:auto}.mL8Uca_modalTitle{margin:0;font-size:15px;font-weight:700}.mL8Uca_modalFooter{justify-content:flex-end;gap:10px;margin-top:4px;display:flex}.mL8Uca_formError{color:var(--dsw-alias-state-error-primary);margin:0;font-size:12px}.mL8Uca_hint{color:var(--dsw-alias-label-tertiary);font-size:11.5px}.mL8Uca_field{flex-direction:column;gap:5px;display:flex}.mL8Uca_fieldLabel{color:var(--dsw-alias-label-secondary);font-size:12px;font-weight:600}.mL8Uca_input{color:var(--dsw-alias-label-primary);background:var(--dsw-specific-input-major);border:1px solid var(--dsw-alias-border-l2);resize:vertical;border-radius:8px;outline:none;padding:7px 10px;font-family:inherit;font-size:13px}.mL8Uca_input:focus{border-color:var(--dsw-alias-state-business-primary)}.mL8Uca_input::placeholder{color:var(--dsw-alias-label-tertiary)}.mL8Uca_input:disabled{opacity:.55}.mL8Uca_formRow{grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:10px 12px;display:grid}.mL8Uca_radioRow{align-items:center;gap:16px;display:flex}.mL8Uca_radioLabel{color:var(--dsw-alias-label-primary);cursor:pointer;align-items:center;gap:6px;font-size:13px;display:inline-flex}.mL8Uca_termBody{flex-direction:column;flex:1;gap:8px;min-height:0;display:flex;overflow:hidden}.mL8Uca_termWrap{border:1px solid var(--dsw-alias-border-l1);background:#0b0e14;border-radius:10px;flex:1;min-height:0;position:relative;overflow:hidden}.mL8Uca_termContainer{position:absolute;inset:8px 10px}.mL8Uca_termPlaceholder{z-index:2;text-align:center;color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-base);justify-content:center;align-items:center;padding:0 24px;font-size:12.5px;display:flex;position:absolute;inset:0}.mL8Uca_hiddenFile{display:none}.mL8Uca_browsePanel{border:1px solid var(--dsw-alias-border-l1);border-radius:10px;flex-direction:column;flex:none;display:flex;overflow:hidden}.mL8Uca_browseHeader{background:var(--dsw-alias-bg-layer-2);border-bottom:1px solid var(--dsw-alias-border-l1);align-items:center;gap:8px;padding:8px 10px;display:flex}.mL8Uca_browsePath{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--dsw-alias-label-secondary);flex:1;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12px;overflow:hidden}.mL8Uca_browseList{max-height:240px;overflow-y:auto}.mL8Uca_dirRow{text-align:left;width:100%;font:inherit;color:var(--dsw-alias-label-primary);border:none;border-bottom:1px solid var(--dsw-alias-separator-primary);cursor:pointer;background:0 0;grid-template-columns:minmax(0,1fr) auto auto;gap:12px;padding:5px 10px;font-size:12.5px;display:grid}.mL8Uca_dirRow:hover{background:var(--dsw-alias-interactive-bg-hover)}.mL8Uca_dirRow[data-type=dir] .mL8Uca_dirName{color:var(--dsw-alias-state-business-primary)}.mL8Uca_dirRow[data-up]{color:var(--dsw-alias-label-secondary)}.mL8Uca_dirName{text-overflow:ellipsis;white-space:nowrap;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;overflow:hidden}.mL8Uca_dirType{color:var(--dsw-alias-label-tertiary);white-space:nowrap}.mL8Uca_dirSize{color:var(--dsw-alias-label-tertiary);white-space:nowrap;text-align:right}.mL8Uca_transferBlock{flex-direction:column;flex:none;gap:6px;display:flex}.mL8Uca_progressMeta{color:var(--dsw-alias-label-secondary);flex-wrap:wrap;gap:12px;font-size:12px;display:flex}.mL8Uca_progressTrack{background:var(--dsw-alias-interactive-bg-hover);border-radius:999px;height:8px;overflow:hidden}.mL8Uca_progressBar{background:var(--dsw-alias-state-business-primary);border-radius:999px;height:100%;transition:width .12s linear}.mL8Uca_tunnelList{flex-direction:column;flex:none;gap:8px;display:flex}.mL8Uca_tunnelRow{background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:10px;align-items:center;gap:10px;padding:8px 12px;display:flex}.mL8Uca_tunnelRow[data-state=forwarding]{border-color:var(--dsw-alias-state-success-primary)}.mL8Uca_tunnelRow[data-state=connecting]{border-color:var(--dsw-alias-state-warn-primary)}.mL8Uca_tunnelRow[data-state=failed]{border-color:var(--dsw-alias-state-error-primary)}.mL8Uca_tunnelLabel{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12.5px;overflow:hidden}.mL8Uca_formCard{background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l1);border-radius:10px;flex-direction:column;flex:none;gap:10px;padding:12px;display:flex}.mL8Uca_clusterForm{flex-direction:column;flex:none;gap:8px;display:flex}.mL8Uca_clusterFilters{grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:10px;display:grid}.mL8Uca_commandInput{min-height:96px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.mL8Uca_cellDetails summary{cursor:pointer;color:var(--dsw-alias-label-secondary);font-size:12px}.mL8Uca_cellPre{background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);white-space:pre-wrap;word-break:break-all;border-radius:6px;max-height:180px;margin:4px 0 0;padding:6px 8px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:11.5px;overflow:auto}";
|
|
1328
|
+
const css = ".mL8Uca_view{height:100%;min-height:0;overflow:hidden}.mL8Uca_panel{background:var(--dsw-alias-bg-base);min-width:0;height:100%;min-height:0;color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family);flex-direction:column;gap:10px;padding:14px 16px 16px;display:flex}.mL8Uca_panelHeader{flex:none;align-items:center;gap:10px;display:flex}.mL8Uca_panelTitle{color:var(--dsw-alias-label-primary);white-space:nowrap;flex:1;margin:0;font-size:16px;font-weight:700}.mL8Uca_backButton{align-items:center;gap:4px;display:inline-flex}.mL8Uca_tabBar{border-bottom:1px solid var(--dsw-alias-border-l1);flex:none;gap:2px;display:flex}.mL8Uca_tab{color:var(--dsw-alias-label-secondary);cursor:pointer;white-space:nowrap;background:0 0;border:none;border-bottom:2px solid #0000;border-radius:6px 6px 0 0;padding:7px 14px;font-size:13px}.mL8Uca_tab:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}.mL8Uca_tab[data-active]{color:var(--dsw-alias-label-primary);border-bottom-color:var(--dsw-alias-state-business-primary);font-weight:600}.mL8Uca_panelContent{flex-direction:column;flex:1;min-height:0;display:flex;overflow:hidden}.mL8Uca_tabBody{flex-direction:column;flex:1;gap:10px;min-height:0;display:flex;overflow-y:auto}.mL8Uca_fillBody{flex-direction:column;flex:1;gap:10px;min-height:0;display:flex;overflow:hidden}.mL8Uca_toolbar,.mL8Uca_controls{flex-wrap:wrap;flex:none;align-items:center;gap:8px;display:flex}.mL8Uca_controls .mL8Uca_input{flex:0 260px;min-width:150px}.mL8Uca_toolbarSpacer{flex:1}.mL8Uca_search{min-width:120px;color:var(--dsw-alias-label-primary);background:var(--dsw-specific-input-major);border:1px solid var(--dsw-alias-border-l2);border-radius:8px;outline:none;flex:0 260px;padding:6px 10px;font-size:13px}.mL8Uca_search::placeholder{color:var(--dsw-alias-label-tertiary)}.mL8Uca_groupBySelect{color:var(--dsw-alias-label-primary);background:var(--dsw-specific-input-major);border:1px solid var(--dsw-alias-border-l2);border-radius:8px;outline:none;padding:6px 8px;font-size:13px}.mL8Uca_groupSection+.mL8Uca_groupSection{border-top:1px solid var(--dsw-alias-border-l1)}.mL8Uca_groupHeader{background:var(--dsw-alias-bg-base,var(--dsw-specific-input-major));align-items:center;gap:8px;padding:4px 8px;display:flex;position:sticky;top:0}.mL8Uca_groupToggle{min-width:0;color:var(--dsw-alias-label-primary);cursor:pointer;text-align:left;background:0 0;border:none;border-radius:6px;flex:1;align-items:center;gap:6px;padding:4px 6px;font-size:12.5px;font-weight:500;display:flex}.mL8Uca_groupToggle:hover{background:var(--dsw-alias-interactive-bg-hover)}.mL8Uca_groupChevron{border-right:1.5px solid var(--dsw-alias-label-tertiary);border-bottom:1.5px solid var(--dsw-alias-label-tertiary);flex:none;width:7px;height:7px;margin-bottom:2px;transition:transform .12s;transform:rotate(45deg)}.mL8Uca_groupChevron[data-collapsed]{margin-bottom:0;transform:rotate(-45deg)}.mL8Uca_groupName{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.mL8Uca_groupCount{color:var(--dsw-alias-label-tertiary);flex:none;font-weight:400}.mL8Uca_tableWrap{border:1px solid var(--dsw-alias-border-l1);border-radius:10px;flex:1;min-height:0;overflow:auto}.mL8Uca_table{border-collapse:collapse;width:100%;font-size:12.5px}.mL8Uca_table th{z-index:1;text-align:left;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap;padding:8px 10px;font-weight:600;position:sticky;top:0}.mL8Uca_table td{border-bottom:1px solid var(--dsw-alias-separator-primary);vertical-align:top;padding:7px 10px}.mL8Uca_table tbody tr:last-child td{border-bottom:none}.mL8Uca_table tbody tr:hover td{background:var(--dsw-alias-interactive-bg-hover)}.mL8Uca_mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.mL8Uca_cellMuted{color:var(--dsw-alias-label-tertiary)}.mL8Uca_actions{white-space:nowrap;align-items:center;gap:8px;display:flex}.mL8Uca_inlineTest{color:var(--dsw-alias-label-secondary);align-items:center;gap:6px;font-size:11.5px;display:inline-flex}.mL8Uca_inlineTest[data-status=ok]{color:var(--dsw-alias-state-success-primary)}.mL8Uca_inlineTest[data-status=fail]{color:var(--dsw-alias-state-error-primary)}.mL8Uca_badge{border:1px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);white-space:nowrap;border-radius:999px;padding:1px 8px;font-size:11px;line-height:1.6;display:inline-block}.mL8Uca_badge[data-kind=key]{color:var(--dsw-alias-state-business-primary);border-color:var(--dsw-alias-state-business-primary)}.mL8Uca_badge[data-kind=password]{color:var(--dsw-alias-state-warn-primary);border-color:var(--dsw-alias-state-warn-primary)}.mL8Uca_badge[data-kind=agent]{color:var(--dsw-alias-state-success-primary);border-color:var(--dsw-alias-state-success-primary)}.mL8Uca_badge[data-kind=proxy]{color:var(--dsw-alias-state-business-primary);border-color:var(--dsw-alias-state-business-primary);margin-left:6px}.mL8Uca_badge[data-kind=forward-agent]{color:var(--dsw-alias-state-warn-primary);border-color:var(--dsw-alias-state-warn-primary);margin-left:6px}.mL8Uca_badge[data-status=ok]{color:var(--dsw-alias-state-success-primary);border-color:var(--dsw-alias-state-success-primary)}.mL8Uca_badge[data-status=fail]{color:var(--dsw-alias-state-error-primary);border-color:var(--dsw-alias-state-error-primary)}.mL8Uca_badge[data-status=timeout]{color:var(--dsw-alias-state-warn-primary);border-color:var(--dsw-alias-state-warn-primary)}.mL8Uca_primaryButton{color:var(--dsw-alias-label-primary-foreground);background:var(--dsw-alias-button-info-fill);cursor:pointer;white-space:nowrap;border:none;border-radius:8px;padding:6px 14px;font-size:13px;font-weight:600}.mL8Uca_primaryButton:hover:not(:disabled){background:var(--dsw-alias-button-info-hover)}.mL8Uca_primaryButton:disabled{opacity:.5;cursor:default}.mL8Uca_ghostButton{color:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l2);cursor:pointer;white-space:nowrap;background:0 0;border-radius:8px;padding:5px 12px;font-size:12px}.mL8Uca_ghostButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.mL8Uca_ghostButton:disabled{opacity:.45;cursor:default}.mL8Uca_iconButton{width:26px;height:26px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;padding:0;font-size:13px;display:inline-flex}.mL8Uca_iconButton:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.mL8Uca_linkButton{color:var(--dsw-alias-state-business-primary);cursor:pointer;white-space:nowrap;background:0 0;border:none;padding:0;font-size:12px}.mL8Uca_linkButton:hover:not(:disabled){text-decoration:underline}.mL8Uca_linkButton:disabled{opacity:.45;cursor:default}.mL8Uca_linkButton[data-danger]{color:var(--dsw-alias-state-error-primary)}.mL8Uca_spinner{border:2px solid var(--dsw-alias-state-business-primary);vertical-align:-1px;border-top-color:#0000;border-radius:50%;flex:none;width:11px;height:11px;animation:.8s linear infinite mL8Uca_dshSshSpin;display:inline-block}@keyframes mL8Uca_dshSshSpin{to{transform:rotate(360deg)}}.mL8Uca_banner{border:1px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere;border-radius:8px;padding:8px 12px;font-size:12.5px;line-height:1.5}.mL8Uca_importSkips{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-2);border-radius:8px;flex-direction:column;gap:4px;margin:6px 0 0;padding:8px 12px;list-style:none;display:flex}.mL8Uca_importSkipRow{justify-content:space-between;align-items:baseline;gap:12px;font-size:12px;display:flex}.mL8Uca_banner[data-kind=ok]{color:var(--dsw-alias-state-success-primary);border-color:var(--dsw-alias-state-success-primary)}.mL8Uca_banner[data-kind=error]{color:var(--dsw-alias-state-error-primary);border-color:var(--dsw-alias-state-error-primary)}.mL8Uca_banner[data-kind=info]{color:var(--dsw-alias-state-business-primary);border-color:var(--dsw-alias-state-business-primary)}.mL8Uca_empty,.mL8Uca_loading{text-align:center;color:var(--dsw-alias-label-tertiary);padding:28px 12px;font-size:12.5px}.mL8Uca_modalBackdrop{z-index:40;background:var(--dsw-alias-bg-mask-1);justify-content:center;align-items:center;display:flex;position:fixed;inset:0}.mL8Uca_modal{background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l2);width:min(560px,100vw - 48px);max-height:calc(100vh - 96px);box-shadow:var(--dsw-shadow-lv3);color:var(--dsw-alias-label-primary);border-radius:14px;flex-direction:column;gap:12px;padding:18px;display:flex;overflow-y:auto}.mL8Uca_modalTitle{margin:0;font-size:15px;font-weight:700}.mL8Uca_modalFooter{justify-content:flex-end;gap:10px;margin-top:4px;display:flex}.mL8Uca_formError{color:var(--dsw-alias-state-error-primary);margin:0;font-size:12px}.mL8Uca_hint{color:var(--dsw-alias-label-tertiary);font-size:11.5px}.mL8Uca_field{flex-direction:column;gap:5px;display:flex}.mL8Uca_fieldLabel{color:var(--dsw-alias-label-secondary);font-size:12px;font-weight:600}.mL8Uca_input{color:var(--dsw-alias-label-primary);background:var(--dsw-specific-input-major);border:1px solid var(--dsw-alias-border-l2);resize:vertical;border-radius:8px;outline:none;padding:7px 10px;font-family:inherit;font-size:13px}.mL8Uca_input:focus{border-color:var(--dsw-alias-state-business-primary)}.mL8Uca_input::placeholder{color:var(--dsw-alias-label-tertiary)}.mL8Uca_input:disabled{opacity:.55}.mL8Uca_formRow{grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:10px 12px;display:grid}.mL8Uca_radioRow{align-items:center;gap:16px;display:flex}.mL8Uca_radioLabel{color:var(--dsw-alias-label-primary);cursor:pointer;align-items:center;gap:6px;font-size:13px;display:inline-flex}.mL8Uca_termBody{flex-direction:column;flex:1;gap:8px;min-height:0;display:flex;overflow:hidden}.mL8Uca_termTabs{scrollbar-width:thin;border-bottom:1px solid var(--dsw-alias-border-l1);flex:none;align-items:stretch;gap:2px;display:flex;overflow-x:auto}.mL8Uca_termTab{border-bottom:2px solid #0000;border-radius:6px 6px 0 0;flex:none;align-items:center;max-width:200px;display:inline-flex}.mL8Uca_termTab[data-active]{background:var(--dsw-alias-bg-layer-2);border-bottom-color:var(--dsw-alias-state-business-primary)}.mL8Uca_termTabLabel{min-width:0;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;align-items:baseline;gap:6px;padding:5px 4px 5px 10px;font-size:12.5px;display:inline-flex}.mL8Uca_termTab[data-active] .mL8Uca_termTabLabel{color:var(--dsw-alias-label-primary);font-weight:600}.mL8Uca_termTabAlias{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.mL8Uca_termTabState{color:var(--dsw-alias-label-tertiary);flex:none;font-size:11px;font-weight:400}.mL8Uca_termTabState[data-state=error]{color:var(--dsw-alias-state-error-primary)}.mL8Uca_termTabState[data-state=exited]{color:var(--dsw-alias-label-secondary)}.mL8Uca_termTabClose,.mL8Uca_termTabNew{width:20px;height:20px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;border-radius:5px;flex:none;justify-content:center;align-items:center;margin-right:4px;padding:0;font-size:13px;line-height:1;display:inline-flex}.mL8Uca_termTabNew{width:24px;margin:2px 0 2px 4px;font-size:15px}.mL8Uca_termTabClose:hover,.mL8Uca_termTabNew:hover:not(:disabled){color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}.mL8Uca_termTabNew:disabled{opacity:.45;cursor:default}.mL8Uca_termWrap{border:1px solid var(--dsw-alias-border-l1);background:#0b0e14;border-radius:10px;flex:1;min-height:0;position:relative;overflow:hidden}.mL8Uca_termContainer{position:absolute;inset:8px 10px}.mL8Uca_termPlaceholder{z-index:2;text-align:center;color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-base);justify-content:center;align-items:center;padding:0 24px;font-size:12.5px;display:flex;position:absolute;inset:0}.mL8Uca_hiddenFile{display:none}.mL8Uca_browsePanel{border:1px solid var(--dsw-alias-border-l1);border-radius:10px;flex-direction:column;flex:none;display:flex;overflow:hidden}.mL8Uca_browseHeader{background:var(--dsw-alias-bg-layer-2);border-bottom:1px solid var(--dsw-alias-border-l1);align-items:center;gap:8px;padding:8px 10px;display:flex}.mL8Uca_browsePath{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--dsw-alias-label-secondary);flex:1;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12px;overflow:hidden}.mL8Uca_browseList{max-height:240px;overflow-y:auto}.mL8Uca_dirRow{text-align:left;width:100%;font:inherit;color:var(--dsw-alias-label-primary);border:none;border-bottom:1px solid var(--dsw-alias-separator-primary);cursor:pointer;background:0 0;grid-template-columns:minmax(0,1fr) auto auto;gap:12px;padding:5px 10px;font-size:12.5px;display:grid}.mL8Uca_dirRow:hover{background:var(--dsw-alias-interactive-bg-hover)}.mL8Uca_dirRow[data-type=dir] .mL8Uca_dirName{color:var(--dsw-alias-state-business-primary)}.mL8Uca_dirRow[data-up]{color:var(--dsw-alias-label-secondary)}.mL8Uca_dirName{text-overflow:ellipsis;white-space:nowrap;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;overflow:hidden}.mL8Uca_dirType{color:var(--dsw-alias-label-tertiary);white-space:nowrap}.mL8Uca_dirSize{color:var(--dsw-alias-label-tertiary);white-space:nowrap;text-align:right}.mL8Uca_transferBlock{flex-direction:column;flex:none;gap:6px;display:flex}.mL8Uca_progressMeta{color:var(--dsw-alias-label-secondary);flex-wrap:wrap;gap:12px;font-size:12px;display:flex}.mL8Uca_progressTrack{background:var(--dsw-alias-interactive-bg-hover);border-radius:999px;height:8px;overflow:hidden}.mL8Uca_progressBar{background:var(--dsw-alias-state-business-primary);border-radius:999px;height:100%;transition:width .12s linear}.mL8Uca_tunnelList{flex-direction:column;flex:none;gap:8px;display:flex}.mL8Uca_tunnelRow{background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:10px;align-items:center;gap:10px;padding:8px 12px;display:flex}.mL8Uca_tunnelRow[data-state=forwarding]{border-color:var(--dsw-alias-state-success-primary)}.mL8Uca_tunnelRow[data-state=connecting]{border-color:var(--dsw-alias-state-warn-primary)}.mL8Uca_tunnelRow[data-state=failed]{border-color:var(--dsw-alias-state-error-primary)}.mL8Uca_tunnelLabel{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12.5px;overflow:hidden}.mL8Uca_formCard{background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l1);border-radius:10px;flex-direction:column;flex:none;gap:10px;padding:12px;display:flex}.mL8Uca_clusterForm{flex-direction:column;flex:none;gap:8px;display:flex}.mL8Uca_clusterFilters{grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:10px;display:grid}.mL8Uca_commandInput{min-height:96px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.mL8Uca_cellDetails summary{cursor:pointer;color:var(--dsw-alias-label-secondary);font-size:12px}.mL8Uca_cellPre{background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);white-space:pre-wrap;word-break:break-all;border-radius:6px;max-height:180px;margin:4px 0 0;padding:6px 8px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:11.5px;overflow:auto}";
|
|
971
1329
|
const tagId = "@linxin666/dsh-ssh/packages/dsh-ssh/src/client/panel/panel.module.css";
|
|
972
1330
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
973
1331
|
const tag = document.createElement("style");
|
|
@@ -1046,6 +1404,13 @@ window.__ModuleLoader__.load({
|
|
|
1046
1404
|
"termBody": "mL8Uca_termBody",
|
|
1047
1405
|
"termContainer": "mL8Uca_termContainer",
|
|
1048
1406
|
"termPlaceholder": "mL8Uca_termPlaceholder",
|
|
1407
|
+
"termTab": "mL8Uca_termTab",
|
|
1408
|
+
"termTabAlias": "mL8Uca_termTabAlias",
|
|
1409
|
+
"termTabClose": "mL8Uca_termTabClose",
|
|
1410
|
+
"termTabLabel": "mL8Uca_termTabLabel",
|
|
1411
|
+
"termTabNew": "mL8Uca_termTabNew",
|
|
1412
|
+
"termTabState": "mL8Uca_termTabState",
|
|
1413
|
+
"termTabs": "mL8Uca_termTabs",
|
|
1049
1414
|
"termWrap": "mL8Uca_termWrap",
|
|
1050
1415
|
"toolbar": "mL8Uca_toolbar",
|
|
1051
1416
|
"toolbarSpacer": "mL8Uca_toolbarSpacer",
|
|
@@ -15157,11 +15522,22 @@ window.__ModuleLoader__.load({
|
|
|
15157
15522
|
//#endregion
|
|
15158
15523
|
//#region src/client/panel/TerminalTab.tsx
|
|
15159
15524
|
/**
|
|
15160
|
-
* Terminal tab:
|
|
15161
|
-
*
|
|
15162
|
-
*
|
|
15163
|
-
*
|
|
15164
|
-
*
|
|
15525
|
+
* Terminal tab: ONE xterm.js view over the host's WebSocket terminal route,
|
|
15526
|
+
* with a tab strip over host-side PTY sessions.
|
|
15527
|
+
*
|
|
15528
|
+
* Session ownership stays on the Host (\`src/engine/terminal-sessions.ts\`): a
|
|
15529
|
+
* view that is not showing a session detaches its socket, and the host keeps
|
|
15530
|
+
* the shell alive plus a bounded scrollback that a reattach replays. That is
|
|
15531
|
+
* what lets the panel hold several tabs while this component keeps a single
|
|
15532
|
+
* xterm instance: switching a tab rebinds the one terminal instead of stacking
|
|
15533
|
+
* terminals, and every tab's alias, host session id, status and pending
|
|
15534
|
+
* keyboard-interactive challenge lives in the panel controller because the
|
|
15535
|
+
* layout unmounts this page whenever another panel is selected.
|
|
15536
|
+
*
|
|
15537
|
+
* A tab that has NOT reported its session id yet cannot be detached (there is
|
|
15538
|
+
* no id to reattach with), so switching away or unmounting hands the socket to
|
|
15539
|
+
* the controller, which applies "detach" or "close" the moment the id arrives.
|
|
15540
|
+
* That is the orphan-free rule: no host PTY is ever left without an owner.
|
|
15165
15541
|
*/
|
|
15166
15542
|
/** Injected-once guard for the xterm stylesheet (one tag per page load). */
|
|
15167
15543
|
let xtermCssInjected = false;
|
|
@@ -15179,20 +15555,48 @@ window.__ModuleLoader__.load({
|
|
|
15179
15555
|
get: () => void 0,
|
|
15180
15556
|
subscribe: () => () => void 0
|
|
15181
15557
|
};
|
|
15182
|
-
/**
|
|
15183
|
-
|
|
15558
|
+
/**
|
|
15559
|
+
* The state word a tab shows in the strip, or undefined when it is simply up.
|
|
15560
|
+
* A pending challenge wins over the lifecycle word: it is the one state the
|
|
15561
|
+
* user has to act on.
|
|
15562
|
+
* @param tab - the tab record.
|
|
15563
|
+
* @returns the short label, or undefined for a connected tab.
|
|
15564
|
+
*/
|
|
15565
|
+
function tabStateLabel(tab) {
|
|
15566
|
+
if (tab.authPrompt !== void 0) return tt("terminal.authPending");
|
|
15567
|
+
if (tab.status === "connecting") return tt("terminal.connecting");
|
|
15568
|
+
if (tab.status === "exited") return tt("terminal.tabExited");
|
|
15569
|
+
if (tab.closeError !== void 0) return tt("terminal.tabError");
|
|
15570
|
+
if (tab.status === "error") return tt("terminal.tabError");
|
|
15571
|
+
}
|
|
15572
|
+
/**
|
|
15573
|
+
* Whether the visible challenge form may answer on the bound socket: the form
|
|
15574
|
+
* and the socket must belong to the same tab. Both are read at submit time, and
|
|
15575
|
+
* the window between a tab switch's commit and the effect that rebinds the
|
|
15576
|
+
* socket is exactly when they can disagree.
|
|
15577
|
+
* @param linkTabId - the tab the bound socket belongs to.
|
|
15578
|
+
* @param formTabId - the tab whose challenge form is on screen.
|
|
15579
|
+
*/
|
|
15580
|
+
function challengeBelongsToLink(linkTabId, formTabId) {
|
|
15581
|
+
return linkTabId !== void 0 && linkTabId === formTabId;
|
|
15582
|
+
}
|
|
15583
|
+
/** The terminal view with its tab strip. */
|
|
15584
|
+
function TerminalTab({ api, controller, presetAlias, terminalFont }) {
|
|
15585
|
+
const { terminalTabs, activeTerminalTabId, draftAlias } = (0, react.useSyncExternalStore)((0, react.useCallback)((listener) => controller.subscribe(listener), [controller]), (0, react.useCallback)(() => controller.getSnapshot(), [controller]));
|
|
15184
15586
|
const [hosts, setHosts] = (0, react.useState)([]);
|
|
15185
|
-
const [
|
|
15186
|
-
const [status, setStatus] = (0, react.useState)({ kind: "idle" });
|
|
15187
|
-
const [authPrompt, setAuthPrompt] = (0, react.useState)(void 0);
|
|
15188
|
-
const [authInputs, setAuthInputs] = (0, react.useState)([]);
|
|
15587
|
+
const [listError, setListError] = (0, react.useState)(void 0);
|
|
15189
15588
|
const containerRef = (0, react.useRef)(null);
|
|
15190
15589
|
const termRef = (0, react.useRef)(null);
|
|
15191
15590
|
const fitRef = (0, react.useRef)(null);
|
|
15192
|
-
const
|
|
15591
|
+
const linkRef = (0, react.useRef)(null);
|
|
15193
15592
|
const dataSubRef = (0, react.useRef)(null);
|
|
15593
|
+
/** Tab whose screen the terminal currently holds. */
|
|
15594
|
+
const renderedRef = (0, react.useRef)(void 0);
|
|
15595
|
+
/** Tabs with a background close in flight, so one click cannot open two. */
|
|
15596
|
+
const closingRef = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
15194
15597
|
const fontSource = terminalFont ?? NO_FONT_SOURCE;
|
|
15195
15598
|
const fontOverride = (0, react.useSyncExternalStore)(fontSource.subscribe, fontSource.get);
|
|
15599
|
+
const activeTab = terminalTabs.find((tab) => tab.id === activeTerminalTabId);
|
|
15196
15600
|
(0, react.useEffect)(() => {
|
|
15197
15601
|
ensureXtermCss();
|
|
15198
15602
|
}, []);
|
|
@@ -15203,7 +15607,8 @@ window.__ModuleLoader__.load({
|
|
|
15203
15607
|
if (term.options.fontFamily === next) return;
|
|
15204
15608
|
term.options.fontFamily = next;
|
|
15205
15609
|
fitRef.current?.fit();
|
|
15206
|
-
|
|
15610
|
+
const link = linkRef.current;
|
|
15611
|
+
if (link !== null) link.connection.resize(term.cols, term.rows);
|
|
15207
15612
|
}, [fontOverride]);
|
|
15208
15613
|
(0, react.useEffect)(() => {
|
|
15209
15614
|
let disposed = false;
|
|
@@ -15212,10 +15617,7 @@ window.__ModuleLoader__.load({
|
|
|
15212
15617
|
const list = await api.listHosts();
|
|
15213
15618
|
if (!disposed) setHosts(list);
|
|
15214
15619
|
} catch (cause) {
|
|
15215
|
-
if (!disposed)
|
|
15216
|
-
kind: "error",
|
|
15217
|
-
detail: errorMessage(cause)
|
|
15218
|
-
});
|
|
15620
|
+
if (!disposed) setListError(errorMessage(cause));
|
|
15219
15621
|
}
|
|
15220
15622
|
})();
|
|
15221
15623
|
return () => {
|
|
@@ -15223,35 +15625,9 @@ window.__ModuleLoader__.load({
|
|
|
15223
15625
|
};
|
|
15224
15626
|
}, [api]);
|
|
15225
15627
|
(0, react.useEffect)(() => {
|
|
15226
|
-
if (presetAlias
|
|
15227
|
-
|
|
15228
|
-
|
|
15229
|
-
* Tear the view down.
|
|
15230
|
-
* @param leave - `detach` leaves the host session alive for a reattach
|
|
15231
|
-
* (panel switch, unmount); `close` ends it (the disconnect control).
|
|
15232
|
-
*/
|
|
15233
|
-
const teardown = (leave) => {
|
|
15234
|
-
setAuthPrompt(void 0);
|
|
15235
|
-
setAuthInputs([]);
|
|
15236
|
-
const connection = connRef.current;
|
|
15237
|
-
connRef.current = null;
|
|
15238
|
-
if (connection !== null) {
|
|
15239
|
-
connection.onReady = void 0;
|
|
15240
|
-
connection.onOutput = void 0;
|
|
15241
|
-
connection.onExit = void 0;
|
|
15242
|
-
connection.onAuthPrompt = void 0;
|
|
15243
|
-
if (leave === "detach") connection.detach();
|
|
15244
|
-
else connection.close();
|
|
15245
|
-
}
|
|
15246
|
-
dataSubRef.current?.dispose();
|
|
15247
|
-
dataSubRef.current = null;
|
|
15248
|
-
termRef.current?.dispose();
|
|
15249
|
-
termRef.current = null;
|
|
15250
|
-
fitRef.current = null;
|
|
15251
|
-
};
|
|
15252
|
-
(0, react.useEffect)(() => () => {
|
|
15253
|
-
teardown("detach");
|
|
15254
|
-
}, []);
|
|
15628
|
+
if (presetAlias === void 0 || presetAlias === "") return;
|
|
15629
|
+
controller.setDraftAlias(presetAlias);
|
|
15630
|
+
}, [presetAlias, controller]);
|
|
15255
15631
|
(0, react.useEffect)(() => {
|
|
15256
15632
|
let lastCols = -1;
|
|
15257
15633
|
let lastRows = -1;
|
|
@@ -15260,11 +15636,11 @@ window.__ModuleLoader__.load({
|
|
|
15260
15636
|
const fit = fitRef.current;
|
|
15261
15637
|
if (term === null || fit === null) return;
|
|
15262
15638
|
fit.fit();
|
|
15263
|
-
const
|
|
15264
|
-
if (
|
|
15639
|
+
const link = linkRef.current;
|
|
15640
|
+
if (link !== null && (term.cols !== lastCols || term.rows !== lastRows)) {
|
|
15265
15641
|
lastCols = term.cols;
|
|
15266
15642
|
lastRows = term.rows;
|
|
15267
|
-
|
|
15643
|
+
link.connection.resize(term.cols, term.rows);
|
|
15268
15644
|
}
|
|
15269
15645
|
};
|
|
15270
15646
|
window.addEventListener("resize", sync);
|
|
@@ -15281,16 +15657,16 @@ window.__ModuleLoader__.load({
|
|
|
15281
15657
|
window.removeEventListener("resize", sync);
|
|
15282
15658
|
};
|
|
15283
15659
|
}, []);
|
|
15284
|
-
/**
|
|
15285
|
-
|
|
15286
|
-
|
|
15287
|
-
|
|
15288
|
-
|
|
15660
|
+
/** Build the one xterm instance and its input subscription, once. */
|
|
15661
|
+
const ensureTerm = () => {
|
|
15662
|
+
const openTerm = termRef.current;
|
|
15663
|
+
const openFit = fitRef.current;
|
|
15664
|
+
if (openTerm !== null && openFit !== null) return {
|
|
15665
|
+
term: openTerm,
|
|
15666
|
+
fit: openFit
|
|
15667
|
+
};
|
|
15289
15668
|
const container = containerRef.current;
|
|
15290
|
-
if (container === null) return;
|
|
15291
|
-
if (status.kind === "connecting" || status.kind === "connected") return;
|
|
15292
|
-
teardown("detach");
|
|
15293
|
-
setStatus({ kind: "connecting" });
|
|
15669
|
+
if (container === null) return void 0;
|
|
15294
15670
|
const term = new import_xterm.Terminal({
|
|
15295
15671
|
convertEol: false,
|
|
15296
15672
|
cursorBlink: true,
|
|
@@ -15306,88 +15682,282 @@ window.__ModuleLoader__.load({
|
|
|
15306
15682
|
term.loadAddon(fit);
|
|
15307
15683
|
term.open(container);
|
|
15308
15684
|
fit.fit();
|
|
15309
|
-
const connection = open(term.cols, term.rows);
|
|
15310
15685
|
termRef.current = term;
|
|
15311
15686
|
fitRef.current = fit;
|
|
15312
|
-
connRef.current = connection;
|
|
15313
|
-
let settled = false;
|
|
15314
|
-
let connectedAlias = "";
|
|
15315
15687
|
dataSubRef.current = term.onData((data) => {
|
|
15316
|
-
connection.send(data);
|
|
15688
|
+
linkRef.current?.connection.send(data);
|
|
15317
15689
|
});
|
|
15690
|
+
return {
|
|
15691
|
+
term,
|
|
15692
|
+
fit
|
|
15693
|
+
};
|
|
15694
|
+
};
|
|
15695
|
+
/** Dispose the xterm and its subscription (no tabs left, or unmount). */
|
|
15696
|
+
const disposeTerm = () => {
|
|
15697
|
+
dataSubRef.current?.dispose();
|
|
15698
|
+
dataSubRef.current = null;
|
|
15699
|
+
termRef.current?.dispose();
|
|
15700
|
+
termRef.current = null;
|
|
15701
|
+
fitRef.current = null;
|
|
15702
|
+
renderedRef.current = void 0;
|
|
15703
|
+
};
|
|
15704
|
+
/** Release the bound socket: detach it, or adopt it while it connects. */
|
|
15705
|
+
const releaseLink = () => {
|
|
15706
|
+
const link = linkRef.current;
|
|
15707
|
+
linkRef.current = null;
|
|
15708
|
+
if (link === null) return;
|
|
15709
|
+
const connection = link.connection;
|
|
15710
|
+
connection.onReady = void 0;
|
|
15711
|
+
connection.onOutput = void 0;
|
|
15712
|
+
connection.onExit = void 0;
|
|
15713
|
+
connection.onAuthPrompt = void 0;
|
|
15714
|
+
const tab = controller.terminalTab(link.tabId);
|
|
15715
|
+
if (tab === void 0) {
|
|
15716
|
+
controller.adoptTerminalLink(link.tabId, connection, "close");
|
|
15717
|
+
return;
|
|
15718
|
+
}
|
|
15719
|
+
if (tab.status === "connecting") {
|
|
15720
|
+
controller.adoptTerminalLink(link.tabId, connection, "detach");
|
|
15721
|
+
return;
|
|
15722
|
+
}
|
|
15723
|
+
connection.detach();
|
|
15724
|
+
};
|
|
15725
|
+
/**
|
|
15726
|
+
* Whether the single terminal still shows another tab. A terminal that was
|
|
15727
|
+
* just created (or disposed) holds nothing, so it needs no clear; every other
|
|
15728
|
+
* rebind must start from a blank screen or the previous tab's output and
|
|
15729
|
+
* cursor stay on it.
|
|
15730
|
+
* @param tabId - the tab about to be bound.
|
|
15731
|
+
*/
|
|
15732
|
+
const needsScreenClear = (tabId) => {
|
|
15733
|
+
const rendered = renderedRef.current;
|
|
15734
|
+
return rendered !== void 0 && rendered !== tabId;
|
|
15735
|
+
};
|
|
15736
|
+
/**
|
|
15737
|
+
* Draw a retained screen the host cannot replay (adopted output, or a tab
|
|
15738
|
+
* whose session is gone) and mark the terminal as this tab's.
|
|
15739
|
+
* @param term - the single terminal.
|
|
15740
|
+
* @param tabId - the tab that owns the text.
|
|
15741
|
+
* @param retained - the text to draw; empty leaves a blank screen.
|
|
15742
|
+
*/
|
|
15743
|
+
const drawRetained = (term, tabId, retained) => {
|
|
15744
|
+
if (needsScreenClear(tabId)) term.reset();
|
|
15745
|
+
if (retained !== "") term.write(retained);
|
|
15746
|
+
renderedRef.current = tabId;
|
|
15747
|
+
};
|
|
15748
|
+
/** Bind one connection's frames onto the single terminal. */
|
|
15749
|
+
const bindConnection = (tab, connection) => {
|
|
15750
|
+
const view = ensureTerm();
|
|
15751
|
+
if (view === void 0) return;
|
|
15752
|
+
linkRef.current = {
|
|
15753
|
+
tabId: tab.id,
|
|
15754
|
+
connection
|
|
15755
|
+
};
|
|
15756
|
+
renderedRef.current = tab.id;
|
|
15757
|
+
view.term.options.disableStdin = false;
|
|
15758
|
+
connection.onReady = (sessionId) => {
|
|
15759
|
+
controller.clearTerminalAuthPrompt(tab.id);
|
|
15760
|
+
controller.readyTerminalTab(tab.id, sessionId);
|
|
15761
|
+
};
|
|
15762
|
+
connection.onOutput = (data) => {
|
|
15763
|
+
view.term.write(data);
|
|
15764
|
+
controller.appendTerminalOutput(tab.id, data);
|
|
15765
|
+
};
|
|
15318
15766
|
connection.onAuthPrompt = (name, instructions, prompts) => {
|
|
15319
|
-
|
|
15767
|
+
controller.setTerminalAuthPrompt(tab.id, {
|
|
15320
15768
|
name,
|
|
15321
15769
|
instructions,
|
|
15322
15770
|
prompts
|
|
15323
15771
|
});
|
|
15324
|
-
setAuthInputs(prompts.map(() => ""));
|
|
15325
|
-
};
|
|
15326
|
-
connection.onReady = (id, readyAlias) => {
|
|
15327
|
-
connectedAlias = readyAlias;
|
|
15328
|
-
controller.setTerminalSession(id);
|
|
15329
|
-
setAuthPrompt(void 0);
|
|
15330
|
-
setAuthInputs([]);
|
|
15331
|
-
setStatus({
|
|
15332
|
-
kind: "connected",
|
|
15333
|
-
alias: readyAlias
|
|
15334
|
-
});
|
|
15335
|
-
};
|
|
15336
|
-
connection.onOutput = (data) => {
|
|
15337
|
-
term.write(data);
|
|
15338
15772
|
};
|
|
15339
15773
|
connection.onExit = (_code, error) => {
|
|
15340
|
-
|
|
15341
|
-
|
|
15342
|
-
|
|
15343
|
-
|
|
15344
|
-
|
|
15345
|
-
|
|
15346
|
-
|
|
15347
|
-
|
|
15348
|
-
|
|
15349
|
-
|
|
15350
|
-
kind: "exited",
|
|
15351
|
-
alias: connectedAlias !== "" ? connectedAlias : alias,
|
|
15352
|
-
detail: error
|
|
15353
|
-
});
|
|
15774
|
+
const bound = linkRef.current;
|
|
15775
|
+
const wasBound = bound !== null && bound.connection === connection;
|
|
15776
|
+
if (wasBound) linkRef.current = null;
|
|
15777
|
+
connection.onReady = void 0;
|
|
15778
|
+
connection.onOutput = void 0;
|
|
15779
|
+
connection.onAuthPrompt = void 0;
|
|
15780
|
+
connection.onExit = void 0;
|
|
15781
|
+
view.term.options.disableStdin = true;
|
|
15782
|
+
if (!wasBound) return;
|
|
15783
|
+
controller.exitTerminalTab(tab.id, error);
|
|
15354
15784
|
};
|
|
15355
15785
|
};
|
|
15786
|
+
/** Bind the tab the controller says is current, without opening a second PTY. */
|
|
15787
|
+
const bindTab = (tab) => {
|
|
15788
|
+
const view = ensureTerm();
|
|
15789
|
+
if (view === void 0) return;
|
|
15790
|
+
if (tab.status === "connecting" || tab.status === "connected" && tab.sessionId !== void 0) {
|
|
15791
|
+
const adopted = controller.reclaimTerminalLink(tab.id);
|
|
15792
|
+
if (adopted !== void 0) {
|
|
15793
|
+
drawRetained(view.term, tab.id, controller.readTerminalOutput(tab.id));
|
|
15794
|
+
bindConnection(tab, adopted);
|
|
15795
|
+
return;
|
|
15796
|
+
}
|
|
15797
|
+
}
|
|
15798
|
+
if (tab.status === "connecting") {
|
|
15799
|
+
drawRetained(view.term, tab.id, "");
|
|
15800
|
+
controller.clearTerminalOutput(tab.id);
|
|
15801
|
+
bindConnection(tab, api.openTerminal(tab.alias, view.term.cols, view.term.rows));
|
|
15802
|
+
return;
|
|
15803
|
+
}
|
|
15804
|
+
if (tab.status === "connected" && tab.sessionId !== void 0) {
|
|
15805
|
+
const sessionId = tab.sessionId;
|
|
15806
|
+
if (needsScreenClear(tab.id)) {
|
|
15807
|
+
view.term.reset();
|
|
15808
|
+
controller.clearTerminalOutput(tab.id);
|
|
15809
|
+
renderedRef.current = tab.id;
|
|
15810
|
+
}
|
|
15811
|
+
bindConnection(tab, api.attachTerminal(sessionId, view.term.cols, view.term.rows));
|
|
15812
|
+
return;
|
|
15813
|
+
}
|
|
15814
|
+
view.term.options.disableStdin = true;
|
|
15815
|
+
if (renderedRef.current === tab.id) return;
|
|
15816
|
+
drawRetained(view.term, tab.id, controller.readTerminalOutput(tab.id));
|
|
15817
|
+
};
|
|
15818
|
+
(0, react.useEffect)(() => {
|
|
15819
|
+
const bound = linkRef.current;
|
|
15820
|
+
if (bound !== null && bound.tabId === activeTerminalTabId) return;
|
|
15821
|
+
releaseLink();
|
|
15822
|
+
if (activeTerminalTabId === void 0) {
|
|
15823
|
+
disposeTerm();
|
|
15824
|
+
return;
|
|
15825
|
+
}
|
|
15826
|
+
const tab = controller.terminalTab(activeTerminalTabId);
|
|
15827
|
+
if (tab === void 0) return;
|
|
15828
|
+
bindTab(tab);
|
|
15829
|
+
}, [
|
|
15830
|
+
activeTerminalTabId,
|
|
15831
|
+
activeTab?.status,
|
|
15832
|
+
activeTab?.sessionId
|
|
15833
|
+
]);
|
|
15834
|
+
(0, react.useEffect)(() => () => {
|
|
15835
|
+
releaseLink();
|
|
15836
|
+
disposeTerm();
|
|
15837
|
+
}, []);
|
|
15838
|
+
/** Open a tab on the toolbar's host (the "+"/Connect control). */
|
|
15356
15839
|
const connect = () => {
|
|
15357
|
-
const target =
|
|
15840
|
+
const target = draftAlias;
|
|
15358
15841
|
if (target === "") return;
|
|
15359
|
-
|
|
15842
|
+
controller.openTerminalTab(target);
|
|
15360
15843
|
};
|
|
15361
|
-
|
|
15362
|
-
|
|
15363
|
-
|
|
15364
|
-
|
|
15365
|
-
|
|
15366
|
-
|
|
15367
|
-
|
|
15368
|
-
|
|
15369
|
-
|
|
15370
|
-
|
|
15371
|
-
|
|
15844
|
+
/**
|
|
15845
|
+
* Close one tab. The shown one ends its session over its own socket; a
|
|
15846
|
+
* background tab is ended through one short-lived attach, and a close that
|
|
15847
|
+
* cannot be delivered keeps the tab instead of pretending it is gone.
|
|
15848
|
+
* @param tabId - the tab to close.
|
|
15849
|
+
*/
|
|
15850
|
+
const closeTab = (tabId) => {
|
|
15851
|
+
const tab = controller.terminalTab(tabId);
|
|
15852
|
+
if (tab === void 0) return;
|
|
15853
|
+
const bound = linkRef.current;
|
|
15854
|
+
if (bound !== null && bound.tabId === tabId) {
|
|
15855
|
+
linkRef.current = null;
|
|
15856
|
+
const connection = bound.connection;
|
|
15857
|
+
connection.onReady = void 0;
|
|
15858
|
+
connection.onOutput = void 0;
|
|
15859
|
+
connection.onExit = void 0;
|
|
15860
|
+
connection.onAuthPrompt = void 0;
|
|
15861
|
+
if (tab.status === "connecting") controller.adoptTerminalLink(tabId, connection, "close");
|
|
15862
|
+
else connection.close();
|
|
15863
|
+
controller.closeTerminalTab(tabId);
|
|
15864
|
+
return;
|
|
15865
|
+
}
|
|
15866
|
+
if (tab.status === "connected" && tab.sessionId !== void 0) {
|
|
15867
|
+
if (closingRef.current.has(tabId)) return;
|
|
15868
|
+
closingRef.current.add(tabId);
|
|
15869
|
+
const sessionId = tab.sessionId;
|
|
15870
|
+
(async () => {
|
|
15871
|
+
try {
|
|
15872
|
+
if (await api.closeTerminalSession(sessionId)) {
|
|
15873
|
+
controller.closeTerminalTab(tabId);
|
|
15874
|
+
return;
|
|
15875
|
+
}
|
|
15876
|
+
controller.markTerminalCloseFailed(tabId, "undelivered");
|
|
15877
|
+
} finally {
|
|
15878
|
+
closingRef.current.delete(tabId);
|
|
15879
|
+
}
|
|
15880
|
+
})();
|
|
15881
|
+
return;
|
|
15882
|
+
}
|
|
15883
|
+
controller.closeTerminalTab(tabId);
|
|
15372
15884
|
};
|
|
15373
15885
|
const submitAuth = (e) => {
|
|
15374
15886
|
e?.preventDefault();
|
|
15375
|
-
|
|
15376
|
-
|
|
15377
|
-
|
|
15887
|
+
const link = linkRef.current;
|
|
15888
|
+
const tab = activeTab;
|
|
15889
|
+
if (link === null || tab === void 0 || tab.authPrompt === void 0) return;
|
|
15890
|
+
if (!challengeBelongsToLink(link.tabId, tab.id)) return;
|
|
15891
|
+
link.connection.sendAuthResponse(tab.authAnswers ?? []);
|
|
15892
|
+
controller.clearTerminalAuthPrompt(tab.id);
|
|
15378
15893
|
};
|
|
15379
|
-
const
|
|
15894
|
+
const stateLabel = activeTab === void 0 ? void 0 : tabStateLabel(activeTab);
|
|
15380
15895
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
15381
15896
|
className: panel_module_css_default.termBody,
|
|
15382
15897
|
children: [
|
|
15898
|
+
terminalTabs.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
15899
|
+
className: panel_module_css_default.termTabs,
|
|
15900
|
+
role: "tablist",
|
|
15901
|
+
"aria-label": tt("terminal.tabs"),
|
|
15902
|
+
"data-dsh-part": "tab-bar",
|
|
15903
|
+
children: [terminalTabs.map((tab) => {
|
|
15904
|
+
const label = tabStateLabel(tab);
|
|
15905
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
15906
|
+
className: panel_module_css_default.termTab,
|
|
15907
|
+
"data-active": tab.id === activeTab?.id ? "" : void 0,
|
|
15908
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
15909
|
+
type: "button",
|
|
15910
|
+
role: "tab",
|
|
15911
|
+
className: panel_module_css_default.termTabLabel,
|
|
15912
|
+
"aria-selected": tab.id === activeTab?.id,
|
|
15913
|
+
"data-dsh-part": "tab",
|
|
15914
|
+
title: tab.alias,
|
|
15915
|
+
onClick: () => {
|
|
15916
|
+
controller.setActiveTerminalTab(tab.id);
|
|
15917
|
+
},
|
|
15918
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
15919
|
+
className: panel_module_css_default.termTabAlias,
|
|
15920
|
+
children: tab.alias
|
|
15921
|
+
}), label !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
15922
|
+
className: panel_module_css_default.termTabState,
|
|
15923
|
+
"data-state": tab.status,
|
|
15924
|
+
children: label
|
|
15925
|
+
})]
|
|
15926
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
15927
|
+
type: "button",
|
|
15928
|
+
className: panel_module_css_default.termTabClose,
|
|
15929
|
+
"aria-label": tt("terminal.closeTab"),
|
|
15930
|
+
title: tt("terminal.closeTab"),
|
|
15931
|
+
onClick: () => {
|
|
15932
|
+
closeTab(tab.id);
|
|
15933
|
+
},
|
|
15934
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
15935
|
+
"aria-hidden": "true",
|
|
15936
|
+
children: "×"
|
|
15937
|
+
})
|
|
15938
|
+
})]
|
|
15939
|
+
}, tab.id);
|
|
15940
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
15941
|
+
type: "button",
|
|
15942
|
+
className: panel_module_css_default.termTabNew,
|
|
15943
|
+
"aria-label": tt("terminal.newTab"),
|
|
15944
|
+
title: tt("terminal.newTab"),
|
|
15945
|
+
disabled: draftAlias === "",
|
|
15946
|
+
onClick: connect,
|
|
15947
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
15948
|
+
"aria-hidden": "true",
|
|
15949
|
+
children: "+"
|
|
15950
|
+
})
|
|
15951
|
+
})]
|
|
15952
|
+
}),
|
|
15383
15953
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
15384
15954
|
className: panel_module_css_default.controls,
|
|
15385
15955
|
children: [
|
|
15386
15956
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
15387
15957
|
className: panel_module_css_default.input,
|
|
15388
|
-
value:
|
|
15958
|
+
value: draftAlias,
|
|
15389
15959
|
onChange: (event) => {
|
|
15390
|
-
|
|
15960
|
+
controller.setDraftAlias(event.target.value);
|
|
15391
15961
|
},
|
|
15392
15962
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
15393
15963
|
value: "",
|
|
@@ -15405,38 +15975,50 @@ window.__ModuleLoader__.load({
|
|
|
15405
15975
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
15406
15976
|
type: "button",
|
|
15407
15977
|
className: panel_module_css_default.primaryButton,
|
|
15408
|
-
disabled:
|
|
15978
|
+
disabled: draftAlias === "",
|
|
15409
15979
|
onClick: connect,
|
|
15410
15980
|
children: tt("terminal.connect")
|
|
15411
15981
|
}),
|
|
15412
15982
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
15413
15983
|
type: "button",
|
|
15414
15984
|
className: panel_module_css_default.ghostButton,
|
|
15415
|
-
disabled:
|
|
15416
|
-
onClick:
|
|
15985
|
+
disabled: activeTab === void 0,
|
|
15986
|
+
onClick: () => {
|
|
15987
|
+
if (activeTab !== void 0) closeTab(activeTab.id);
|
|
15988
|
+
},
|
|
15417
15989
|
children: tt("terminal.disconnect")
|
|
15418
15990
|
})
|
|
15419
15991
|
]
|
|
15420
15992
|
}),
|
|
15421
|
-
status
|
|
15993
|
+
activeTab?.status === "connecting" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
15422
15994
|
className: panel_module_css_default.banner,
|
|
15423
15995
|
"data-kind": "info",
|
|
15424
15996
|
children: tt("terminal.connecting")
|
|
15425
15997
|
}),
|
|
15426
|
-
status
|
|
15998
|
+
activeTab?.status === "connected" && stateLabel === void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
15427
15999
|
className: panel_module_css_default.banner,
|
|
15428
16000
|
"data-kind": "ok",
|
|
15429
|
-
children: tt("terminal.ready", { alias:
|
|
16001
|
+
children: tt("terminal.ready", { alias: activeTab.alias })
|
|
15430
16002
|
}),
|
|
15431
|
-
status
|
|
16003
|
+
activeTab?.status === "exited" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
15432
16004
|
className: panel_module_css_default.banner,
|
|
15433
16005
|
"data-kind": "info",
|
|
15434
|
-
children: [tt("terminal.exited", { alias:
|
|
16006
|
+
children: [tt("terminal.exited", { alias: activeTab.alias }), activeTab.detail !== void 0 ? " (" + activeTab.detail + ")" : ""]
|
|
15435
16007
|
}),
|
|
15436
|
-
status
|
|
16008
|
+
activeTab?.status === "error" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
15437
16009
|
className: panel_module_css_default.banner,
|
|
15438
16010
|
"data-kind": "error",
|
|
15439
|
-
children: tt("terminal.error", { error:
|
|
16011
|
+
children: tt("terminal.error", { error: activeTab.detail ?? "" })
|
|
16012
|
+
}),
|
|
16013
|
+
activeTab?.closeError !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
16014
|
+
className: panel_module_css_default.banner,
|
|
16015
|
+
"data-kind": "error",
|
|
16016
|
+
children: tt("terminal.closeFailed")
|
|
16017
|
+
}),
|
|
16018
|
+
listError !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
16019
|
+
className: panel_module_css_default.banner,
|
|
16020
|
+
"data-kind": "error",
|
|
16021
|
+
children: tt("terminal.error", { error: listError })
|
|
15440
16022
|
}),
|
|
15441
16023
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
15442
16024
|
className: panel_module_css_default.termWrap,
|
|
@@ -15446,11 +16028,11 @@ window.__ModuleLoader__.load({
|
|
|
15446
16028
|
className: panel_module_css_default.termContainer,
|
|
15447
16029
|
"data-dsh-part": "terminal"
|
|
15448
16030
|
}),
|
|
15449
|
-
|
|
16031
|
+
terminalTabs.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
15450
16032
|
className: panel_module_css_default.termPlaceholder,
|
|
15451
16033
|
children: hosts.length === 0 ? tt("hosts.empty") : tt("terminal.placeholder")
|
|
15452
16034
|
}),
|
|
15453
|
-
authPrompt !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
16035
|
+
activeTab?.authPrompt !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
15454
16036
|
className: panel_module_css_default.modalBackdrop,
|
|
15455
16037
|
style: {
|
|
15456
16038
|
position: "absolute",
|
|
@@ -15465,14 +16047,14 @@ window.__ModuleLoader__.load({
|
|
|
15465
16047
|
className: panel_module_css_default.modalHeader,
|
|
15466
16048
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
15467
16049
|
className: panel_module_css_default.modalTitle,
|
|
15468
|
-
children: authPrompt.name || tt("terminal.auth.title")
|
|
16050
|
+
children: activeTab.authPrompt.name || tt("terminal.auth.title")
|
|
15469
16051
|
})
|
|
15470
16052
|
}),
|
|
15471
16053
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
15472
16054
|
className: panel_module_css_default.hint,
|
|
15473
|
-
children: authPrompt.instructions || tt("terminal.auth.hint")
|
|
16055
|
+
children: activeTab.authPrompt.instructions || tt("terminal.auth.hint")
|
|
15474
16056
|
}),
|
|
15475
|
-
authPrompt.prompts.map((p, idx) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
16057
|
+
activeTab.authPrompt.prompts.map((p, idx) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
15476
16058
|
className: panel_module_css_default.field,
|
|
15477
16059
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
15478
16060
|
className: panel_module_css_default.fieldLabel,
|
|
@@ -15482,11 +16064,9 @@ window.__ModuleLoader__.load({
|
|
|
15482
16064
|
className: panel_module_css_default.input,
|
|
15483
16065
|
type: p.echo ? "text" : "password",
|
|
15484
16066
|
placeholder: tt("terminal.auth.placeholder"),
|
|
15485
|
-
value:
|
|
16067
|
+
value: activeTab.authAnswers?.[idx] ?? "",
|
|
15486
16068
|
onChange: (event) => {
|
|
15487
|
-
|
|
15488
|
-
next[idx] = event.target.value;
|
|
15489
|
-
setAuthInputs(next);
|
|
16069
|
+
controller.setTerminalAuthAnswer(activeTab.id, idx, event.target.value);
|
|
15490
16070
|
}
|
|
15491
16071
|
})]
|
|
15492
16072
|
}, idx)),
|
|
@@ -15495,7 +16075,9 @@ window.__ModuleLoader__.load({
|
|
|
15495
16075
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
15496
16076
|
type: "button",
|
|
15497
16077
|
className: panel_module_css_default.ghostButton,
|
|
15498
|
-
onClick:
|
|
16078
|
+
onClick: () => {
|
|
16079
|
+
if (activeTab !== void 0) closeTab(activeTab.id);
|
|
16080
|
+
},
|
|
15499
16081
|
children: tt("terminal.auth.cancel")
|
|
15500
16082
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
15501
16083
|
type: "submit",
|
|
@@ -16145,12 +16727,11 @@ window.__ModuleLoader__.load({
|
|
|
16145
16727
|
* The SSH operations panel shell: a header with a close control, a five-tab
|
|
16146
16728
|
* bar, and the active tab's content.
|
|
16147
16729
|
*
|
|
16148
|
-
* The active tab
|
|
16149
|
-
*
|
|
16150
|
-
*
|
|
16151
|
-
*
|
|
16152
|
-
*
|
|
16153
|
-
* on activation.
|
|
16730
|
+
* The active tab and the terminal tabs live in the controller, not in
|
|
16731
|
+
* component state: the layout mounts this page only while the panel is
|
|
16732
|
+
* selected, so local state would reset the tab on every panel switch and lose
|
|
16733
|
+
* the ids the terminal tab needs to reattach its host-side sessions. Inactive
|
|
16734
|
+
* tabs unmount, so each tab fetches its own data on activation.
|
|
16154
16735
|
*/
|
|
16155
16736
|
/** The tab bar definition (labels resolved at render time). */
|
|
16156
16737
|
const TABS = [
|
|
@@ -16177,7 +16758,7 @@ window.__ModuleLoader__.load({
|
|
|
16177
16758
|
];
|
|
16178
16759
|
/** The tabbed SSH panel. */
|
|
16179
16760
|
function SshPanel({ controller, api, terminalFont }) {
|
|
16180
|
-
const { panelOpen, activeTab
|
|
16761
|
+
const { panelOpen, activeTab } = (0, react.useSyncExternalStore)((0, react.useCallback)((listener) => controller.subscribe(listener), [controller]), (0, react.useCallback)(() => controller.getSnapshot(), [controller]));
|
|
16181
16762
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
16182
16763
|
className: panel_module_css_default.panel,
|
|
16183
16764
|
"data-dsh-plugin": "ssh",
|
|
@@ -16230,9 +16811,6 @@ window.__ModuleLoader__.load({
|
|
|
16230
16811
|
activeTab === "terminal" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TerminalTab, {
|
|
16231
16812
|
api,
|
|
16232
16813
|
controller,
|
|
16233
|
-
presetAlias: connectRequest?.alias,
|
|
16234
|
-
requestId: connectRequest?.nonce,
|
|
16235
|
-
sessionId: terminalSessionId,
|
|
16236
16814
|
terminalFont
|
|
16237
16815
|
}),
|
|
16238
16816
|
activeTab === "transfer" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TransferTab, { api }),
|
|
@@ -16452,7 +17030,7 @@ window.__ModuleLoader__.load({
|
|
|
16452
17030
|
/** The building package's version, when the bundle carries it. */
|
|
16453
17031
|
function bakedVersion() {
|
|
16454
17032
|
try {
|
|
16455
|
-
return "0.4.
|
|
17033
|
+
return "0.4.13";
|
|
16456
17034
|
} catch {
|
|
16457
17035
|
return;
|
|
16458
17036
|
}
|