dsh-remote-local-plugin 0.0.0-stage → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +85 -2
- package/assets/dsh-remote-agent-0.2.1.tgz +0 -0
- package/cordis.patch.yml +50 -0
- package/lib/client.js +1511 -0
- package/lib/client.js.map +7 -0
- package/lib/index.js +4565 -0
- package/lib/types/config.d.ts +94 -0
- package/lib/types/credentials/proxy.d.ts +40 -0
- package/lib/types/errors.d.ts +23 -0
- package/lib/types/host-api/contract.d.ts +217 -0
- package/lib/types/host-api/handler.d.ts +15 -0
- package/lib/types/host-api/terminal.d.ts +15 -0
- package/lib/types/hosts/id.d.ts +16 -0
- package/lib/types/hosts/store.d.ts +34 -0
- package/lib/types/hosts/types.d.ts +85 -0
- package/lib/types/index.d.ts +19 -0
- package/lib/types/mirror/service.d.ts +87 -0
- package/lib/types/mirror/test-visibility.d.ts +23 -0
- package/lib/types/remote/directory.d.ts +19 -0
- package/lib/types/remote/files.d.ts +14 -0
- package/lib/types/remote/local-directory.d.ts +11 -0
- package/lib/types/remote/provisioner.d.ts +32 -0
- package/lib/types/remote/terminal.d.ts +55 -0
- package/lib/types/rpc/contract.d.ts +114 -0
- package/lib/types/rpc/handler.d.ts +12 -0
- package/lib/types/service.d.ts +92 -0
- package/lib/types/ssh/probe.d.ts +33 -0
- package/lib/types/ssh/target.d.ts +24 -0
- package/lib/types/ssh/tunnel.d.ts +50 -0
- package/lib/types/tools.d.ts +19 -0
- package/node_modules/dsh-remote-terminal-controller/README.md +9 -0
- package/node_modules/dsh-remote-terminal-controller/cordis.patch.yml +8 -0
- package/node_modules/dsh-remote-terminal-controller/lib/client.js +1367 -0
- package/node_modules/dsh-remote-terminal-controller/lib/client.js.map +7 -0
- package/node_modules/dsh-remote-terminal-controller/lib/index.js +3 -0
- package/node_modules/dsh-remote-terminal-controller/package.json +59 -0
- package/package.json +146 -4
package/lib/client.js
ADDED
|
@@ -0,0 +1,1511 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "dsh-remote-local-plugin",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
"use strict";
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
|
|
25
|
+
// src/client/index.tsx
|
|
26
|
+
var index_exports = {};
|
|
27
|
+
__export(index_exports, {
|
|
28
|
+
apply: () => apply,
|
|
29
|
+
inject: () => inject
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(index_exports);
|
|
32
|
+
|
|
33
|
+
// src/host-api/contract.ts
|
|
34
|
+
var HOST_API_PATH = "/api/dsh-remote";
|
|
35
|
+
|
|
36
|
+
// src/client/api.ts
|
|
37
|
+
var RemoteUiError = class extends Error {
|
|
38
|
+
code;
|
|
39
|
+
details;
|
|
40
|
+
constructor(code, message, details = {}) {
|
|
41
|
+
super(message);
|
|
42
|
+
this.name = "RemoteUiError";
|
|
43
|
+
this.code = code;
|
|
44
|
+
this.details = details;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
function createHostsApi(ctx) {
|
|
48
|
+
return {
|
|
49
|
+
state: () => call("state", void 0),
|
|
50
|
+
validateTarget: (sshTarget) => call("target/validate", { sshTarget }),
|
|
51
|
+
addHost: (input) => call("host/add", input),
|
|
52
|
+
removeHost: async (hostId) => {
|
|
53
|
+
await call("host/remove", { hostId });
|
|
54
|
+
},
|
|
55
|
+
connect: (hostId) => call("host/connect", { hostId }),
|
|
56
|
+
disconnect: (hostId) => call("host/disconnect", { hostId }),
|
|
57
|
+
refresh: (hostId) => call("host/refresh", { hostId }),
|
|
58
|
+
provision: (hostId) => call("host/provision", { hostId }),
|
|
59
|
+
workspaces: (hostId) => call("host/workspaces", { hostId }),
|
|
60
|
+
listDirectories: (hostId, path) => call("host/directory/list", { hostId, ...path === void 0 ? {} : { path } }),
|
|
61
|
+
listLocalDirectories: (path) => call("local/directory/list", { ...path === void 0 ? {} : { path } }),
|
|
62
|
+
createLocalWorkspace: (input) => call("local/workspace/create", input),
|
|
63
|
+
createWorkspace: (hostId, input) => call("host/workspace/create", { hostId, ...input }),
|
|
64
|
+
sessions: (hostId, workspaceId) => call("host/sessions", {
|
|
65
|
+
hostId,
|
|
66
|
+
...workspaceId === void 0 ? {} : { workspaceId }
|
|
67
|
+
}),
|
|
68
|
+
webUrl: (hostId) => call("host/web-url", { hostId }),
|
|
69
|
+
snapshot: (hostId, sessionId, limit) => call("host/session", {
|
|
70
|
+
hostId,
|
|
71
|
+
sessionId,
|
|
72
|
+
...limit === void 0 ? {} : { limit }
|
|
73
|
+
}),
|
|
74
|
+
createSession: (hostId, input) => call("host/session/create", { hostId, ...input }),
|
|
75
|
+
openSession: (sessionId) => {
|
|
76
|
+
ctx.uiWorkspace.openSession(sessionId);
|
|
77
|
+
},
|
|
78
|
+
fileList: (sessionId, path) => call("host/files/list", { sessionId, path }),
|
|
79
|
+
fileRead: (sessionId, path, offset, limit) => call("host/files/read", {
|
|
80
|
+
sessionId,
|
|
81
|
+
path,
|
|
82
|
+
...offset === void 0 ? {} : { offset },
|
|
83
|
+
...limit === void 0 ? {} : { limit }
|
|
84
|
+
}),
|
|
85
|
+
fileStat: (sessionId, path) => call("host/files/stat", { sessionId, path }),
|
|
86
|
+
fileBytes: (sessionId, path, offset, length) => call("host/files/bytes", {
|
|
87
|
+
sessionId,
|
|
88
|
+
path,
|
|
89
|
+
...offset === void 0 ? {} : { offset },
|
|
90
|
+
...length === void 0 ? {} : { length }
|
|
91
|
+
}),
|
|
92
|
+
prompt: (hostId, sessionId, text, mode, selection) => call("host/session/prompt", {
|
|
93
|
+
hostId,
|
|
94
|
+
sessionId,
|
|
95
|
+
text,
|
|
96
|
+
...mode === void 0 ? {} : { mode },
|
|
97
|
+
...selection === void 0 ? {} : selection
|
|
98
|
+
}),
|
|
99
|
+
cancel: (hostId, sessionId) => call("host/session/cancel", { hostId, sessionId })
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
async function call(endpoint, payload) {
|
|
103
|
+
const response = await fetch(HOST_API_PATH, {
|
|
104
|
+
method: "POST",
|
|
105
|
+
credentials: "same-origin",
|
|
106
|
+
headers: { "content-type": "application/json" },
|
|
107
|
+
body: JSON.stringify(payload === void 0 ? { endpoint } : { endpoint, payload })
|
|
108
|
+
});
|
|
109
|
+
if (!response.ok) {
|
|
110
|
+
throw new RemoteUiError("request/invalid", `host API returned HTTP ${response.status}`);
|
|
111
|
+
}
|
|
112
|
+
const result = await response.json();
|
|
113
|
+
if (!result.ok) {
|
|
114
|
+
throw new RemoteUiError(result.error.code, result.error.message, result.error.details ?? {});
|
|
115
|
+
}
|
|
116
|
+
return result.value;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/client/RemoteDevelopmentPanel.tsx
|
|
120
|
+
var import_react = require("react");
|
|
121
|
+
|
|
122
|
+
// src/client/panel.css
|
|
123
|
+
var panel_default = ".dshr-root {\n --dshr-accent: #4f7cff;\n --dshr-danger: #d24b4b;\n --dshr-success: #2f9e63;\n --dshr-warning: #c98417;\n --dshr-border: color-mix(in srgb, currentColor 14%, transparent);\n --dshr-soft: color-mix(in srgb, currentColor 4%, transparent);\n --dshr-softer: color-mix(in srgb, currentColor 2.5%, transparent);\n display: flex;\n flex-direction: column;\n gap: 16px;\n padding: 4px 2px 32px;\n font-size: 13px;\n line-height: 1.5;\n}\n\n.dshr-header {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: 16px;\n}\n\n.dshr-header h2 {\n margin: 0 0 4px;\n font-size: 17px;\n font-weight: 650;\n}\n\n.dshr-subtitle {\n max-width: 760px;\n margin: 0;\n opacity: 0.72;\n}\n\n.dshr-subtitle code,\n.dshr-host-title code,\n.dshr-workspace-head code,\n.dshr-session code {\n font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n font-size: 0.92em;\n}\n\n.dshr-card {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 16px;\n border: 1px solid var(--dshr-border);\n border-radius: 12px;\n background: var(--dshr-softer);\n}\n\n.dshr-card h3 {\n margin: 0;\n font-size: 14px;\n font-weight: 650;\n}\n\n.dshr-section-title {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 12px;\n}\n\n.dshr-form {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 12px;\n}\n\n.dshr-field {\n display: flex;\n flex-direction: column;\n gap: 5px;\n min-width: 0;\n}\n\n.dshr-field-wide {\n grid-column: 1 / -1;\n}\n\n.dshr-field > span {\n font-size: 12px;\n opacity: 0.72;\n}\n\n.dshr-field input {\n width: 100%;\n box-sizing: border-box;\n padding: 7px 9px;\n border: 1px solid var(--dshr-border);\n border-radius: 8px;\n background: var(--dshr-soft);\n color: inherit;\n font: inherit;\n outline: none;\n}\n\n.dshr-field input:focus {\n border-color: var(--dshr-accent);\n box-shadow: 0 0 0 2px color-mix(in srgb, var(--dshr-accent) 22%, transparent);\n}\n\n.dshr-check {\n display: flex;\n align-items: center;\n gap: 7px;\n font-size: 12px;\n}\n\n.dshr-form-actions {\n display: flex;\n grid-column: 1 / -1;\n align-items: center;\n gap: 12px;\n flex-wrap: wrap;\n}\n\n.dshr-button {\n padding: 6px 12px;\n border: 1px solid var(--dshr-border);\n border-radius: 8px;\n background: var(--dshr-soft);\n color: inherit;\n font: inherit;\n cursor: pointer;\n transition: background 120ms ease, border-color 120ms ease;\n}\n\n.dshr-button:hover:not(:disabled) {\n background: color-mix(in srgb, currentColor 8%, transparent);\n}\n\n.dshr-button:disabled {\n cursor: not-allowed;\n opacity: 0.45;\n}\n\n.dshr-button-primary {\n border-color: color-mix(in srgb, var(--dshr-accent) 65%, transparent);\n background: var(--dshr-accent);\n color: #fff;\n}\n\n.dshr-button-primary:hover:not(:disabled) {\n background: color-mix(in srgb, var(--dshr-accent) 84%, #000);\n}\n\n.dshr-button-danger {\n border-color: color-mix(in srgb, var(--dshr-danger) 45%, transparent);\n color: var(--dshr-danger);\n}\n\n.dshr-hint {\n font-size: 12px;\n opacity: 0.62;\n}\n\n.dshr-empty {\n margin: 0;\n padding: 10px 0;\n opacity: 0.62;\n}\n\n.dshr-banner {\n margin: 0;\n padding: 9px 12px;\n border-radius: 9px;\n border: 1px solid var(--dshr-border);\n}\n\n.dshr-banner-error {\n border-color: color-mix(in srgb, var(--dshr-danger) 45%, transparent);\n background: color-mix(in srgb, var(--dshr-danger) 10%, transparent);\n color: var(--dshr-danger);\n}\n\n.dshr-banner-info {\n border-color: color-mix(in srgb, var(--dshr-accent) 35%, transparent);\n background: color-mix(in srgb, var(--dshr-accent) 9%, transparent);\n}\n\n.dshr-hosts {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.dshr-host {\n display: flex;\n flex-direction: column;\n gap: 10px;\n padding: 12px;\n border: 1px solid var(--dshr-border);\n border-radius: 10px;\n background: var(--dshr-soft);\n}\n\n.dshr-host-head {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: 12px;\n}\n\n.dshr-host-title {\n display: flex;\n align-items: baseline;\n gap: 10px;\n flex-wrap: wrap;\n min-width: 0;\n}\n\n.dshr-host-title strong {\n font-size: 14px;\n}\n\n.dshr-phase {\n flex: none;\n padding: 1px 8px;\n border-radius: 999px;\n font-size: 11px;\n font-weight: 600;\n border: 1px solid currentColor;\n opacity: 0.9;\n}\n\n.dshr-phase-connected {\n color: var(--dshr-success);\n}\n\n.dshr-phase-discovering,\n.dshr-phase-connecting {\n color: var(--dshr-warning);\n}\n\n.dshr-phase-error {\n color: var(--dshr-danger);\n}\n\n.dshr-phase-idle,\n.dshr-phase-disconnected {\n opacity: 0.62;\n}\n\n.dshr-meta {\n display: flex;\n flex-wrap: wrap;\n gap: 6px 20px;\n margin: 0;\n font-size: 12px;\n}\n\n.dshr-meta > div {\n display: flex;\n gap: 5px;\n}\n\n.dshr-meta dt {\n opacity: 0.58;\n}\n\n.dshr-meta dd {\n margin: 0;\n font-variant-numeric: tabular-nums;\n}\n\n.dshr-host-error {\n margin: 0;\n color: var(--dshr-danger);\n font-size: 12px;\n overflow-wrap: anywhere;\n}\n\n.dshr-actions {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n}\n\n.dshr-workspaces {\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding-top: 4px;\n border-top: 1px dashed var(--dshr-border);\n}\n\n.dshr-workspace {\n border-radius: 8px;\n background: var(--dshr-softer);\n}\n\n.dshr-workspace-head {\n display: flex;\n align-items: baseline;\n gap: 8px;\n width: 100%;\n box-sizing: border-box;\n padding: 8px 10px;\n border: 0;\n border-radius: 8px;\n background: transparent;\n color: inherit;\n font: inherit;\n text-align: left;\n cursor: pointer;\n flex-wrap: wrap;\n}\n\n.dshr-workspace-head:hover {\n background: var(--dshr-soft);\n}\n\n.dshr-workspace-head code {\n opacity: 0.6;\n}\n\n.dshr-caret {\n width: 12px;\n opacity: 0.6;\n}\n\n.dshr-count {\n margin-left: auto;\n font-size: 11px;\n opacity: 0.55;\n white-space: nowrap;\n}\n\n.dshr-sessions {\n display: flex;\n flex-direction: column;\n gap: 2px;\n padding: 0 10px 8px 30px;\n}\n\n.dshr-session {\n display: flex;\n align-items: baseline;\n gap: 8px;\n padding: 3px 0;\n font-size: 12px;\n flex-wrap: wrap;\n}\n\n.dshr-session > span:not(.dshr-live):not(.dshr-idle) {\n opacity: 0.62;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.dshr-live,\n.dshr-idle {\n flex: none;\n width: 7px;\n height: 7px;\n border-radius: 50%;\n transform: translateY(-1px);\n}\n\n.dshr-live {\n background: var(--dshr-success);\n box-shadow: 0 0 0 2px color-mix(in srgb, var(--dshr-success) 20%, transparent);\n}\n\n.dshr-idle {\n background: color-mix(in srgb, currentColor 28%, transparent);\n}\n\n@media (max-width: 720px) {\n .dshr-form {\n grid-template-columns: minmax(0, 1fr);\n }\n\n .dshr-header {\n flex-direction: column;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .dshr-button {\n transition: none;\n }\n}\n\n.dshr-detail {\n margin: 0;\n font-size: 12px;\n color: var(--dshr-warning);\n}\n\n.dshr-workspace-row {\n display: flex;\n align-items: center;\n gap: 6px;\n padding-right: 6px;\n}\n\n.dshr-workspace-row .dshr-workspace-head {\n flex: 1;\n}\n\n.dshr-button-small {\n flex: none;\n padding: 3px 8px;\n font-size: 11px;\n}\n\n.dshr-workspace-add {\n display: flex;\n gap: 6px;\n padding: 4px 0 6px;\n}\n\n.dshr-workspace-add input {\n flex: 1;\n min-width: 0;\n padding: 5px 8px;\n border: 1px solid var(--dshr-border);\n border-radius: 7px;\n background: var(--dshr-soft);\n color: inherit;\n font: inherit;\n font-size: 12px;\n outline: none;\n}\n\n.dshr-workspace-add input:focus {\n border-color: var(--dshr-accent);\n}\n";
|
|
124
|
+
|
|
125
|
+
// src/client/RemoteDevelopmentPanel.tsx
|
|
126
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
127
|
+
function phaseLabel(t, phase) {
|
|
128
|
+
return t(`phase.${phase}`);
|
|
129
|
+
}
|
|
130
|
+
var DETAIL_KEYS = {
|
|
131
|
+
"\u6B63\u5728\u901A\u8FC7 SSH \u53D1\u73B0\u8FDC\u7AEF agent\u2026": "detail.discovering",
|
|
132
|
+
"\u6B63\u5728\u8FDC\u7AEF\u5B89\u88C5 DSH \u4E0E dsh-remote-agent\uFF0C\u9996\u6B21\u7EA6 1\u20133 \u5206\u949F\u2026": "detail.installing",
|
|
133
|
+
"\u6B63\u5728\u5EFA\u7ACB SSH \u96A7\u9053\u5E76\u6821\u9A8C\u8FDC\u7AEF agent\u2026": "detail.connecting",
|
|
134
|
+
"\u6B63\u5728\u91CD\u65B0\u5B89\u88C5\u8FDC\u7AEF agent\u2026": "detail.reprovisioning",
|
|
135
|
+
"SSH \u96A7\u9053\u65AD\u5F00\uFF0C\u7B49\u5F85\u91CD\u8FDE\u2026": "detail.reconnecting",
|
|
136
|
+
"\u5DF2\u8FDE\u63A5\uFF1B\u6A21\u578B\u8BF7\u6C42\u7ECF\u672C\u5730\u51ED\u636E\u4EE3\u7406\u8F6C\u53D1": "detail.connectedProxy",
|
|
137
|
+
"\u5DF2\u8FDE\u63A5\uFF1B\u6A21\u578B\u8BF7\u6C42\u7531\u8FDC\u7AEF\u76F4\u8FDE DeepSeek": "detail.connectedDirect",
|
|
138
|
+
"\u5DF2\u8FDE\u63A5\uFF1B\u8FDC\u7AEF\u4F7F\u7528\u81EA\u8EAB\u51ED\u636E\u6216\u672A\u914D\u7F6E\u6A21\u578B key": "detail.connectedRemote"
|
|
139
|
+
};
|
|
140
|
+
function detailLabel(t, detail) {
|
|
141
|
+
const key = DETAIL_KEYS[detail];
|
|
142
|
+
return key === void 0 ? detail : t(key);
|
|
143
|
+
}
|
|
144
|
+
var POLL_MS = 2500;
|
|
145
|
+
function RemoteDevelopmentPanel({ api, t }) {
|
|
146
|
+
const [state, setState] = (0, import_react.useState)(null);
|
|
147
|
+
const [error, setError] = (0, import_react.useState)(null);
|
|
148
|
+
const [notice, setNotice] = (0, import_react.useState)(null);
|
|
149
|
+
const [busy, setBusy] = (0, import_react.useState)(null);
|
|
150
|
+
const [expandedHost, setExpandedHost] = (0, import_react.useState)(null);
|
|
151
|
+
const [workspaces, setWorkspaces] = (0, import_react.useState)({});
|
|
152
|
+
const [openWorkspace, setOpenWorkspace] = (0, import_react.useState)({});
|
|
153
|
+
const [sessions, setSessions] = (0, import_react.useState)({});
|
|
154
|
+
const [workspaceDraft, setWorkspaceDraft] = (0, import_react.useState)("");
|
|
155
|
+
const [form, setForm] = (0, import_react.useState)({
|
|
156
|
+
sshTarget: "",
|
|
157
|
+
label: ""
|
|
158
|
+
});
|
|
159
|
+
useInjectedStyle(panel_default);
|
|
160
|
+
const hosts = (0, import_react.useMemo)(() => state?.hosts ?? [], [state]);
|
|
161
|
+
(0, import_react.useEffect)(() => {
|
|
162
|
+
let cancelled = false;
|
|
163
|
+
const load = async () => {
|
|
164
|
+
try {
|
|
165
|
+
const next = await api.state();
|
|
166
|
+
if (!cancelled) {
|
|
167
|
+
setState(next);
|
|
168
|
+
setError((current) => current === t("settings.unavailable") ? null : current);
|
|
169
|
+
}
|
|
170
|
+
} catch (failure) {
|
|
171
|
+
if (!cancelled) setError(messageOf(failure, t("settings.unavailable")));
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
void load();
|
|
175
|
+
const timer = window.setInterval(() => {
|
|
176
|
+
void load();
|
|
177
|
+
}, POLL_MS);
|
|
178
|
+
const onFocus = () => {
|
|
179
|
+
void load();
|
|
180
|
+
};
|
|
181
|
+
window.addEventListener("focus", onFocus);
|
|
182
|
+
return () => {
|
|
183
|
+
cancelled = true;
|
|
184
|
+
window.clearInterval(timer);
|
|
185
|
+
window.removeEventListener("focus", onFocus);
|
|
186
|
+
};
|
|
187
|
+
}, [api, t]);
|
|
188
|
+
(0, import_react.useEffect)(() => {
|
|
189
|
+
const host = hosts.find((item) => item.id === expandedHost);
|
|
190
|
+
if (host?.phase === "connected" && workspaces[host.id] === void 0) {
|
|
191
|
+
void loadWorkspaces(host.id);
|
|
192
|
+
}
|
|
193
|
+
}, [hosts, expandedHost, workspaces]);
|
|
194
|
+
async function refresh() {
|
|
195
|
+
setState(await api.state());
|
|
196
|
+
}
|
|
197
|
+
async function run(key, task) {
|
|
198
|
+
setBusy(key);
|
|
199
|
+
setError(null);
|
|
200
|
+
setNotice(null);
|
|
201
|
+
try {
|
|
202
|
+
await task();
|
|
203
|
+
await refresh();
|
|
204
|
+
} catch (failure) {
|
|
205
|
+
setError(messageOf(failure, t("settings.operationFailed")));
|
|
206
|
+
} finally {
|
|
207
|
+
setBusy(null);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
async function onAdd() {
|
|
211
|
+
const sshTarget = form.sshTarget.trim();
|
|
212
|
+
if (sshTarget === "") {
|
|
213
|
+
setError(t("settings.sshRequired"));
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
await run("add", async () => {
|
|
217
|
+
await api.validateTarget(sshTarget);
|
|
218
|
+
const host = await api.addHost({
|
|
219
|
+
sshTarget,
|
|
220
|
+
...form.label.trim() === "" ? {} : { label: form.label.trim() },
|
|
221
|
+
autoConnect: true
|
|
222
|
+
});
|
|
223
|
+
setForm({ sshTarget: "", label: "" });
|
|
224
|
+
setExpandedHost(host.id);
|
|
225
|
+
setNotice(t("settings.hostSaved"));
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
async function toggleHost(host) {
|
|
229
|
+
if (expandedHost === host.id) {
|
|
230
|
+
setExpandedHost(null);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
setExpandedHost(host.id);
|
|
234
|
+
await loadWorkspaces(host.id);
|
|
235
|
+
}
|
|
236
|
+
async function loadWorkspaces(hostId) {
|
|
237
|
+
setWorkspaces((current) => ({ ...current, [hostId]: void 0 }));
|
|
238
|
+
try {
|
|
239
|
+
const result = await api.workspaces(hostId);
|
|
240
|
+
setWorkspaces((current) => ({ ...current, [hostId]: [...result.workspaces] }));
|
|
241
|
+
} catch (failure) {
|
|
242
|
+
setWorkspaces((current) => ({ ...current, [hostId]: [] }));
|
|
243
|
+
setError(messageOf(failure, t("settings.readWorkspacesFailed")));
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
async function toggleWorkspace(hostId, workspaceId) {
|
|
247
|
+
const key = `${hostId}:${workspaceId}`;
|
|
248
|
+
const next = !(openWorkspace[key] ?? false);
|
|
249
|
+
setOpenWorkspace((current) => ({ ...current, [key]: next }));
|
|
250
|
+
if (!next || sessions[key] !== void 0) return;
|
|
251
|
+
setSessions((current) => ({ ...current, [key]: void 0 }));
|
|
252
|
+
try {
|
|
253
|
+
const result = await api.sessions(hostId, workspaceId);
|
|
254
|
+
setSessions((current) => ({ ...current, [key]: [...result.sessions] }));
|
|
255
|
+
} catch (failure) {
|
|
256
|
+
setSessions((current) => ({ ...current, [key]: [] }));
|
|
257
|
+
setError(messageOf(failure, t("settings.readSessionsFailed")));
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
async function addWorkspace(host) {
|
|
261
|
+
const path = workspaceDraft.trim();
|
|
262
|
+
if (path === "") {
|
|
263
|
+
setError(t("settings.pathRequired"));
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
setBusy(`workspace:${host.id}`);
|
|
267
|
+
setError(null);
|
|
268
|
+
try {
|
|
269
|
+
await api.createWorkspace(host.id, { path });
|
|
270
|
+
setWorkspaceDraft("");
|
|
271
|
+
await loadWorkspaces(host.id);
|
|
272
|
+
setExpandedHost(host.id);
|
|
273
|
+
} catch (failure) {
|
|
274
|
+
setError(messageOf(failure, t("settings.addWorkspaceFailed")));
|
|
275
|
+
} finally {
|
|
276
|
+
setBusy(null);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
async function newSession(host, workspaceId) {
|
|
280
|
+
setBusy(`create:${host.id}:${workspaceId}`);
|
|
281
|
+
setError(null);
|
|
282
|
+
try {
|
|
283
|
+
const created = await api.createSession(host.id, { workspaceId });
|
|
284
|
+
const key = `${host.id}:${workspaceId}`;
|
|
285
|
+
setOpenWorkspace((current) => ({ ...current, [key]: true }));
|
|
286
|
+
if (created.localSessionId !== void 0) {
|
|
287
|
+
api.openSession(created.localSessionId);
|
|
288
|
+
setNotice(t("settings.sessionOpening"));
|
|
289
|
+
window.setTimeout(() => {
|
|
290
|
+
document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }));
|
|
291
|
+
}, 80);
|
|
292
|
+
} else {
|
|
293
|
+
setNotice(t("settings.sessionSyncing"));
|
|
294
|
+
}
|
|
295
|
+
const result = await api.sessions(host.id, workspaceId);
|
|
296
|
+
setSessions((current) => ({ ...current, [key]: [...result.sessions] }));
|
|
297
|
+
const refreshed = await api.workspaces(host.id);
|
|
298
|
+
setWorkspaces((current) => ({ ...current, [host.id]: [...refreshed.workspaces] }));
|
|
299
|
+
} catch (failure) {
|
|
300
|
+
setError(messageOf(failure, t("settings.createSessionFailed")));
|
|
301
|
+
} finally {
|
|
302
|
+
setBusy(null);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
async function onRemove(host) {
|
|
306
|
+
if (!window.confirm(`${t("settings.confirmRemovePrefix")}${host.label}${t("settings.confirmRemoveSuffix")}`)) return;
|
|
307
|
+
await run(`remove:${host.id}`, async () => {
|
|
308
|
+
await api.removeHost(host.id);
|
|
309
|
+
if (expandedHost === host.id) setExpandedHost(null);
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshr-root", children: [
|
|
313
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { className: "dshr-header", children: [
|
|
314
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
315
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: t("settings.title") }),
|
|
316
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "dshr-subtitle", children: [
|
|
317
|
+
t("settings.subtitle.lead"),
|
|
318
|
+
" ",
|
|
319
|
+
t("settings.subtitle.body")
|
|
320
|
+
] })
|
|
321
|
+
] }),
|
|
322
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
323
|
+
"button",
|
|
324
|
+
{
|
|
325
|
+
type: "button",
|
|
326
|
+
className: "dshr-button",
|
|
327
|
+
onClick: () => {
|
|
328
|
+
void refresh().catch((failure) => setError(messageOf(failure, t("settings.refreshFailed"))));
|
|
329
|
+
},
|
|
330
|
+
disabled: busy !== null,
|
|
331
|
+
children: t("settings.refresh")
|
|
332
|
+
}
|
|
333
|
+
)
|
|
334
|
+
] }),
|
|
335
|
+
error !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshr-banner dshr-banner-error", role: "alert", children: error }),
|
|
336
|
+
notice !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshr-banner dshr-banner-info", role: "status", children: notice }),
|
|
337
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "dshr-card", children: [
|
|
338
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: t("settings.addHost") }),
|
|
339
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
340
|
+
"form",
|
|
341
|
+
{
|
|
342
|
+
className: "dshr-form",
|
|
343
|
+
onSubmit: (event) => {
|
|
344
|
+
event.preventDefault();
|
|
345
|
+
void onAdd();
|
|
346
|
+
},
|
|
347
|
+
children: [
|
|
348
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "dshr-field dshr-field-wide", children: [
|
|
349
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: t("settings.sshTarget") }),
|
|
350
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
351
|
+
"input",
|
|
352
|
+
{
|
|
353
|
+
value: form.sshTarget,
|
|
354
|
+
onChange: (event) => setForm((current) => ({ ...current, sshTarget: event.target.value })),
|
|
355
|
+
placeholder: t("settings.sshPlaceholder"),
|
|
356
|
+
autoComplete: "off",
|
|
357
|
+
spellCheck: false
|
|
358
|
+
}
|
|
359
|
+
)
|
|
360
|
+
] }),
|
|
361
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "dshr-field", children: [
|
|
362
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: t("settings.label") }),
|
|
363
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
364
|
+
"input",
|
|
365
|
+
{
|
|
366
|
+
value: form.label,
|
|
367
|
+
onChange: (event) => setForm((current) => ({ ...current, label: event.target.value })),
|
|
368
|
+
placeholder: t("settings.labelPlaceholder")
|
|
369
|
+
}
|
|
370
|
+
)
|
|
371
|
+
] }),
|
|
372
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshr-form-actions", children: [
|
|
373
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "submit", className: "dshr-button dshr-button-primary", disabled: busy !== null, children: busy === "add" ? t("settings.adding") : t("settings.saveConnect") }),
|
|
374
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshr-hint", children: t("settings.sshHint") })
|
|
375
|
+
] })
|
|
376
|
+
]
|
|
377
|
+
}
|
|
378
|
+
)
|
|
379
|
+
] }),
|
|
380
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "dshr-card", children: [
|
|
381
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshr-section-title", children: [
|
|
382
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: t("settings.hosts") }),
|
|
383
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dshr-hint", children: [
|
|
384
|
+
hosts.length,
|
|
385
|
+
" ",
|
|
386
|
+
t("settings.hostsUnit")
|
|
387
|
+
] })
|
|
388
|
+
] }),
|
|
389
|
+
hosts.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshr-empty", children: t("settings.noHosts") }),
|
|
390
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshr-hosts", children: hosts.map((host) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { className: "dshr-host", children: [
|
|
391
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { className: "dshr-host-head", children: [
|
|
392
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshr-host-title", children: [
|
|
393
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: host.label }),
|
|
394
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: host.sshTarget })
|
|
395
|
+
] }),
|
|
396
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `dshr-phase dshr-phase-${host.phase}`, children: phaseLabel(t, host.phase) })
|
|
397
|
+
] }),
|
|
398
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("dl", { className: "dshr-meta", children: [
|
|
399
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
400
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: t("settings.remotePort") }),
|
|
401
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: host.remoteAgentPort ?? "\u2014" })
|
|
402
|
+
] }),
|
|
403
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
404
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: t("settings.localTunnel") }),
|
|
405
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: host.localPort ?? "\u2014" })
|
|
406
|
+
] }),
|
|
407
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
408
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: t("settings.workspaces") }),
|
|
409
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: host.workspaceCount ?? "\u2014" })
|
|
410
|
+
] }),
|
|
411
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
412
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: "Agent" }),
|
|
413
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: host.hostInfo?.agentVersion ?? "\u2014" })
|
|
414
|
+
] }),
|
|
415
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
416
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: t("settings.token") }),
|
|
417
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: host.hasToken ? t("settings.saved") : t("settings.unsaved") })
|
|
418
|
+
] }),
|
|
419
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
420
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", { children: t("settings.modelProxy") }),
|
|
421
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { children: host.modelProxy ? t("settings.localProxy") : host.modelDirect ? t("settings.direct") : t("settings.remoteDefault") })
|
|
422
|
+
] })
|
|
423
|
+
] }),
|
|
424
|
+
host.detail !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshr-detail", children: detailLabel(t, host.detail) }),
|
|
425
|
+
host.error !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshr-host-error", role: "alert", children: host.error }),
|
|
426
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshr-actions", children: [
|
|
427
|
+
host.phase === "connected" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
428
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
429
|
+
"button",
|
|
430
|
+
{
|
|
431
|
+
type: "button",
|
|
432
|
+
className: "dshr-button",
|
|
433
|
+
disabled: busy !== null,
|
|
434
|
+
onClick: () => {
|
|
435
|
+
void toggleHost(host);
|
|
436
|
+
},
|
|
437
|
+
children: expandedHost === host.id ? t("settings.collapseWorkspaces") : t("settings.expandWorkspaces")
|
|
438
|
+
}
|
|
439
|
+
),
|
|
440
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
441
|
+
"button",
|
|
442
|
+
{
|
|
443
|
+
type: "button",
|
|
444
|
+
className: "dshr-button",
|
|
445
|
+
disabled: busy !== null,
|
|
446
|
+
onClick: () => {
|
|
447
|
+
void run(`refresh:${host.id}`, async () => {
|
|
448
|
+
await api.refresh(host.id);
|
|
449
|
+
});
|
|
450
|
+
},
|
|
451
|
+
children: t("settings.rediscover")
|
|
452
|
+
}
|
|
453
|
+
),
|
|
454
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
455
|
+
"button",
|
|
456
|
+
{
|
|
457
|
+
type: "button",
|
|
458
|
+
className: "dshr-button",
|
|
459
|
+
disabled: busy !== null,
|
|
460
|
+
onClick: () => {
|
|
461
|
+
void run(`disconnect:${host.id}`, async () => {
|
|
462
|
+
await api.disconnect(host.id);
|
|
463
|
+
});
|
|
464
|
+
},
|
|
465
|
+
children: t("settings.disconnect")
|
|
466
|
+
}
|
|
467
|
+
)
|
|
468
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
469
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
470
|
+
"button",
|
|
471
|
+
{
|
|
472
|
+
type: "button",
|
|
473
|
+
className: "dshr-button dshr-button-primary",
|
|
474
|
+
disabled: busy !== null || host.phase === "installing" || host.phase === "discovering" || host.phase === "connecting",
|
|
475
|
+
onClick: () => {
|
|
476
|
+
void run(`connect:${host.id}`, async () => {
|
|
477
|
+
await api.connect(host.id);
|
|
478
|
+
});
|
|
479
|
+
},
|
|
480
|
+
children: host.phase === "installing" ? t("settings.installing") : host.phase === "connecting" ? t("settings.connecting") : t("settings.connect")
|
|
481
|
+
}
|
|
482
|
+
),
|
|
483
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
484
|
+
"button",
|
|
485
|
+
{
|
|
486
|
+
type: "button",
|
|
487
|
+
className: "dshr-button",
|
|
488
|
+
disabled: busy !== null,
|
|
489
|
+
onClick: () => {
|
|
490
|
+
void run(`refresh:${host.id}`, async () => {
|
|
491
|
+
await api.refresh(host.id);
|
|
492
|
+
});
|
|
493
|
+
},
|
|
494
|
+
children: t("settings.rediscover")
|
|
495
|
+
}
|
|
496
|
+
)
|
|
497
|
+
] }),
|
|
498
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
499
|
+
"button",
|
|
500
|
+
{
|
|
501
|
+
type: "button",
|
|
502
|
+
className: "dshr-button",
|
|
503
|
+
disabled: busy !== null || host.phase === "installing",
|
|
504
|
+
onClick: () => {
|
|
505
|
+
void run(`provision:${host.id}`, async () => {
|
|
506
|
+
await api.provision(host.id);
|
|
507
|
+
});
|
|
508
|
+
},
|
|
509
|
+
children: t("settings.reprovision")
|
|
510
|
+
}
|
|
511
|
+
),
|
|
512
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
513
|
+
"button",
|
|
514
|
+
{
|
|
515
|
+
type: "button",
|
|
516
|
+
className: "dshr-button dshr-button-danger",
|
|
517
|
+
disabled: busy !== null,
|
|
518
|
+
onClick: () => {
|
|
519
|
+
void onRemove(host);
|
|
520
|
+
},
|
|
521
|
+
children: t("settings.remove")
|
|
522
|
+
}
|
|
523
|
+
)
|
|
524
|
+
] }),
|
|
525
|
+
expandedHost === host.id && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshr-workspaces", children: [
|
|
526
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshr-workspace-add", children: [
|
|
527
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
528
|
+
"input",
|
|
529
|
+
{
|
|
530
|
+
value: workspaceDraft,
|
|
531
|
+
onChange: (event) => setWorkspaceDraft(event.target.value),
|
|
532
|
+
placeholder: t("settings.workspacePathPlaceholder"),
|
|
533
|
+
spellCheck: false,
|
|
534
|
+
onKeyDown: (event) => {
|
|
535
|
+
if (event.key === "Enter") {
|
|
536
|
+
event.preventDefault();
|
|
537
|
+
void addWorkspace(host);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
),
|
|
542
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
543
|
+
"button",
|
|
544
|
+
{
|
|
545
|
+
type: "button",
|
|
546
|
+
className: "dshr-button dshr-button-small",
|
|
547
|
+
disabled: busy !== null,
|
|
548
|
+
onClick: () => {
|
|
549
|
+
void addWorkspace(host);
|
|
550
|
+
},
|
|
551
|
+
children: busy === `workspace:${host.id}` ? t("settings.addingWorkspace") : t("settings.addWorkspace")
|
|
552
|
+
}
|
|
553
|
+
)
|
|
554
|
+
] }),
|
|
555
|
+
workspaces[host.id] === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshr-empty", children: t("settings.readingWorkspaces") }) : workspaces[host.id]?.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshr-empty", children: t("settings.noWorkspaces") }) : workspaces[host.id]?.map((workspace) => {
|
|
556
|
+
const workspaceKey = `${host.id}:${workspace.workspaceId}`;
|
|
557
|
+
const open = openWorkspace[workspaceKey] ?? false;
|
|
558
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshr-workspace", children: [
|
|
559
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshr-workspace-row", children: [
|
|
560
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
561
|
+
"button",
|
|
562
|
+
{
|
|
563
|
+
type: "button",
|
|
564
|
+
className: "dshr-workspace-head",
|
|
565
|
+
"aria-expanded": open,
|
|
566
|
+
onClick: () => {
|
|
567
|
+
void toggleWorkspace(host.id, workspace.workspaceId);
|
|
568
|
+
},
|
|
569
|
+
children: [
|
|
570
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshr-caret", children: open ? "\u25BE" : "\u25B8" }),
|
|
571
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: workspace.title }),
|
|
572
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: workspace.path }),
|
|
573
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dshr-count", children: [
|
|
574
|
+
workspace.sessionIds.length,
|
|
575
|
+
" ",
|
|
576
|
+
t("settings.sessionsUnit")
|
|
577
|
+
] })
|
|
578
|
+
]
|
|
579
|
+
}
|
|
580
|
+
),
|
|
581
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
582
|
+
"button",
|
|
583
|
+
{
|
|
584
|
+
type: "button",
|
|
585
|
+
className: "dshr-button dshr-button-small",
|
|
586
|
+
disabled: busy !== null,
|
|
587
|
+
onClick: () => {
|
|
588
|
+
void newSession(host, workspace.workspaceId);
|
|
589
|
+
},
|
|
590
|
+
children: busy === `create:${host.id}:${workspace.workspaceId}` ? t("settings.creating") : t("settings.newSession")
|
|
591
|
+
}
|
|
592
|
+
)
|
|
593
|
+
] }),
|
|
594
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshr-sessions", children: sessions[workspaceKey] === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshr-empty", children: t("settings.readingSessions") }) : sessions[workspaceKey]?.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshr-empty", children: t("settings.noSessions") }) : sessions[workspaceKey]?.map((session) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshr-session", children: [
|
|
595
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: session.live ? "dshr-live" : "dshr-idle" }),
|
|
596
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: session.sessionId }),
|
|
597
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: session.cwd ?? "\u2014" }),
|
|
598
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dshr-count", children: [
|
|
599
|
+
session.eventCount ?? "\u2014",
|
|
600
|
+
" ",
|
|
601
|
+
t("settings.eventsUnit")
|
|
602
|
+
] })
|
|
603
|
+
] }, session.sessionId)) })
|
|
604
|
+
] }, workspace.workspaceId);
|
|
605
|
+
})
|
|
606
|
+
] })
|
|
607
|
+
] }, host.id)) })
|
|
608
|
+
] })
|
|
609
|
+
] });
|
|
610
|
+
}
|
|
611
|
+
function useInjectedStyle(css) {
|
|
612
|
+
(0, import_react.useEffect)(() => {
|
|
613
|
+
const tag = document.createElement("style");
|
|
614
|
+
tag.dataset.plugin = "dsh-remote-local";
|
|
615
|
+
tag.textContent = css;
|
|
616
|
+
document.head.appendChild(tag);
|
|
617
|
+
return () => {
|
|
618
|
+
tag.remove();
|
|
619
|
+
};
|
|
620
|
+
}, [css]);
|
|
621
|
+
}
|
|
622
|
+
function messageOf(value, fallback) {
|
|
623
|
+
return value instanceof Error && value.message !== "" ? value.message : fallback;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
// src/client/routing.ts
|
|
627
|
+
function installNativeWorkspaceRouting(ctx, api) {
|
|
628
|
+
const workspace = ctx.uiWorkspace;
|
|
629
|
+
if (workspace === void 0 || typeof workspace.startSession !== "function") return;
|
|
630
|
+
const original = workspace.startSession.bind(workspace);
|
|
631
|
+
workspace.startSession = (workspaceId, options) => {
|
|
632
|
+
if (workspaceId === void 0) {
|
|
633
|
+
original(workspaceId, options);
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
void route(api, String(workspaceId)).then((routed) => {
|
|
637
|
+
if (!routed) original(workspaceId, options);
|
|
638
|
+
}).catch(() => {
|
|
639
|
+
original(workspaceId, options);
|
|
640
|
+
});
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
async function route(api, localWorkspaceId) {
|
|
644
|
+
const state = await api.state();
|
|
645
|
+
for (const host of state.hosts) {
|
|
646
|
+
if (host.phase !== "connected") continue;
|
|
647
|
+
const result = await api.workspaces(host.id);
|
|
648
|
+
const workspace = result.workspaces.find((item) => item.localWorkspaceId === localWorkspaceId);
|
|
649
|
+
if (workspace === void 0) continue;
|
|
650
|
+
const created = await api.createSession(host.id, { workspaceId: workspace.workspaceId });
|
|
651
|
+
if (created.localSessionId !== void 0) {
|
|
652
|
+
api.openSession(created.localSessionId);
|
|
653
|
+
return true;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
return false;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// src/client/remote-files.ts
|
|
660
|
+
function installRemoteFiles(ctx, api) {
|
|
661
|
+
const remote = ctx.remote;
|
|
662
|
+
const face = remote?.workspaceFiles;
|
|
663
|
+
if (face === void 0) return;
|
|
664
|
+
const original = {
|
|
665
|
+
list: face.list.bind(face),
|
|
666
|
+
read: face.read.bind(face),
|
|
667
|
+
stat: face.stat.bind(face),
|
|
668
|
+
readBytes: face.readBytes.bind(face)
|
|
669
|
+
};
|
|
670
|
+
face.list = async (sessionId, path, signal) => {
|
|
671
|
+
const result = await api.fileList(sessionId, path);
|
|
672
|
+
return result.mirrored ? { ok: true, value: result.value } : original.list(sessionId, path, signal);
|
|
673
|
+
};
|
|
674
|
+
face.read = async (sessionId, path, range, signal) => {
|
|
675
|
+
const result = await api.fileRead(sessionId, path, range.offset, range.limit);
|
|
676
|
+
return result.mirrored ? { ok: true, value: result.value } : original.read(sessionId, path, range, signal);
|
|
677
|
+
};
|
|
678
|
+
face.stat = async (sessionId, path, signal) => {
|
|
679
|
+
const result = await api.fileStat(sessionId, path);
|
|
680
|
+
return result.mirrored ? { ok: true, value: result.value } : original.stat(sessionId, path, signal);
|
|
681
|
+
};
|
|
682
|
+
face.readBytes = async (sessionId, path, options, signal) => {
|
|
683
|
+
const result = await api.fileBytes(sessionId, path, options.range?.offset, options.range?.length);
|
|
684
|
+
return result.mirrored ? { ok: true, value: result.value } : original.readBytes(sessionId, path, options, signal);
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
// src/client/locale.ts
|
|
689
|
+
var NS = "dshRemote";
|
|
690
|
+
var zh = {
|
|
691
|
+
"settings.title": "\u8FDC\u7A0B\u5F00\u53D1",
|
|
692
|
+
"settings.subtitle.lead": "\u53EA\u9700\u586B\u5199 SSH \u76EE\u6807\u3002\u63D2\u4EF6\u4F1A\u81EA\u52A8\u5B89\u88C5\u5E76\u542F\u52A8\u8FDC\u7AEF agent\uFF0C\u5EFA\u7ACB\u96A7\u9053\u3002",
|
|
693
|
+
"settings.subtitle.body": "\u8FDE\u63A5\u540E\u8FDC\u7AEF\u5DE5\u4F5C\u533A\u548C\u4F1A\u8BDD\u4F1A\u540C\u6B65\u5230\u5DE6\u4FA7\uFF0C\u50CF\u672C\u5730\u4F1A\u8BDD\u4E00\u6837\u6253\u5F00\uFF1B\u6A21\u578B\u51ED\u636E\u9ED8\u8BA4\u5199\u5165\u8FDC\u7AEF\u670D\u52A1\u73AF\u5883\uFF1B\u4E5F\u53EF\u542F\u7528\u672C\u5730\u4EE3\u7406\u6A21\u5F0F\u3002",
|
|
694
|
+
"settings.refresh": "\u5237\u65B0",
|
|
695
|
+
"settings.addHost": "\u6DFB\u52A0\u4E3B\u673A",
|
|
696
|
+
"settings.sshTarget": "SSH \u76EE\u6807",
|
|
697
|
+
"settings.sshPlaceholder": "user@host \u6216 ssh://user@host:22",
|
|
698
|
+
"settings.label": "\u663E\u793A\u540D\u79F0\uFF08\u53EF\u9009\uFF09",
|
|
699
|
+
"settings.labelPlaceholder": "\u53EF\u9009\uFF0C\u4F8B\u5982 \u5F00\u53D1\u673A",
|
|
700
|
+
"settings.saveConnect": "\u4FDD\u5B58\u5E76\u8FDE\u63A5",
|
|
701
|
+
"settings.adding": "\u6DFB\u52A0\u4E2D\u2026",
|
|
702
|
+
"settings.sshHint": "\u9700\u8981\u5BC6\u94A5\u6216 ssh-agent \u514D\u4EA4\u4E92\u767B\u5F55\uFF1B\u9996\u6B21\u81EA\u52A8\u5B89\u88C5\u7EA6 1\u20133 \u5206\u949F\u3002",
|
|
703
|
+
"settings.hosts": "\u4E3B\u673A",
|
|
704
|
+
"settings.hostsUnit": "\u53F0",
|
|
705
|
+
"settings.noHosts": "\u8FD8\u6CA1\u6709\u8FDC\u7A0B\u4E3B\u673A\u3002\u5148\u5728\u4E0A\u65B9\u6DFB\u52A0\u4E00\u53F0\u3002",
|
|
706
|
+
"settings.refreshFailed": "\u5237\u65B0\u5931\u8D25",
|
|
707
|
+
"settings.unavailable": "\u65E0\u6CD5\u8FDE\u63A5\u672C\u5730\u8FDC\u7A0B\u5BBF\u4E3B\u670D\u52A1",
|
|
708
|
+
"settings.operationFailed": "\u64CD\u4F5C\u5931\u8D25",
|
|
709
|
+
"settings.sshRequired": "\u8BF7\u586B\u5199 SSH \u76EE\u6807\uFF0C\u4F8B\u5982 user@host \u6216 ssh://user@host:22",
|
|
710
|
+
"settings.hostSaved": "\u4E3B\u673A\u5DF2\u4FDD\u5B58\u3002\u63D2\u4EF6\u4F1A\u81EA\u52A8\u5B89\u88C5\u5E76\u542F\u52A8\u8FDC\u7AEF agent\uFF1B\u5B89\u88C5\u8FDB\u5EA6\u4F1A\u663E\u793A\u5728\u4E3B\u673A\u5361\u7247\u4E0A\u3002",
|
|
711
|
+
"settings.readWorkspacesFailed": "\u8BFB\u53D6\u8FDC\u7AEF\u5DE5\u4F5C\u533A\u5931\u8D25",
|
|
712
|
+
"settings.readSessionsFailed": "\u8BFB\u53D6\u8FDC\u7AEF\u4F1A\u8BDD\u5931\u8D25",
|
|
713
|
+
"settings.pathRequired": "\u8BF7\u586B\u5199\u8FDC\u7AEF\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u4F8B\u5982 /home/user/project",
|
|
714
|
+
"settings.addWorkspaceFailed": "\u6DFB\u52A0\u8FDC\u7AEF\u5DE5\u4F5C\u533A\u5931\u8D25",
|
|
715
|
+
"settings.sessionOpening": "\u8FDC\u7AEF\u4F1A\u8BDD\u5DF2\u521B\u5EFA\uFF0C\u6B63\u5728\u666E\u901A\u4F1A\u8BDD\u754C\u9762\u6253\u5F00\u2026",
|
|
716
|
+
"settings.sessionSyncing": "\u8FDC\u7AEF\u4F1A\u8BDD\u5DF2\u521B\u5EFA\uFF0C\u6B63\u5728\u540C\u6B65\u5230\u4FA7\u8FB9\u680F\u2026",
|
|
717
|
+
"settings.createSessionFailed": "\u521B\u5EFA\u8FDC\u7AEF\u4F1A\u8BDD\u5931\u8D25",
|
|
718
|
+
"settings.confirmRemovePrefix": "\u5220\u9664\u4E3B\u673A\u300C",
|
|
719
|
+
"settings.confirmRemoveSuffix": "\u300D\uFF1F\u8FDC\u7AEF\u6587\u4EF6\u4E0E\u4F1A\u8BDD\u4E0D\u4F1A\u88AB\u5220\u9664\u3002",
|
|
720
|
+
"settings.remotePort": "\u8FDC\u7AEF\u7AEF\u53E3",
|
|
721
|
+
"settings.localTunnel": "\u672C\u5730\u96A7\u9053",
|
|
722
|
+
"settings.workspaces": "\u5DE5\u4F5C\u533A",
|
|
723
|
+
"settings.token": "Token",
|
|
724
|
+
"settings.saved": "\u5DF2\u4FDD\u5B58",
|
|
725
|
+
"settings.unsaved": "\u672A\u4FDD\u5B58",
|
|
726
|
+
"settings.modelProxy": "\u6A21\u578B\u4EE3\u7406",
|
|
727
|
+
"settings.localProxy": "\u672C\u5730\u4EE3\u7406",
|
|
728
|
+
"settings.direct": "\u8FDC\u7AEF\u76F4\u8FDE",
|
|
729
|
+
"settings.remoteDefault": "\u8FDC\u7AEF\u9ED8\u8BA4",
|
|
730
|
+
"settings.collapseWorkspaces": "\u6536\u8D77\u5DE5\u4F5C\u533A",
|
|
731
|
+
"settings.expandWorkspaces": "\u5DE5\u4F5C\u533A",
|
|
732
|
+
"settings.rediscover": "\u91CD\u65B0\u53D1\u73B0",
|
|
733
|
+
"settings.disconnect": "\u65AD\u5F00",
|
|
734
|
+
"settings.connect": "\u8FDE\u63A5",
|
|
735
|
+
"settings.installing": "\u6B63\u5728\u5B89\u88C5\u2026",
|
|
736
|
+
"settings.connecting": "\u6B63\u5728\u8FDE\u63A5\u2026",
|
|
737
|
+
"settings.reprovision": "\u91CD\u65B0\u5B89\u88C5",
|
|
738
|
+
"settings.remove": "\u5220\u9664",
|
|
739
|
+
"settings.workspacePathPlaceholder": "\u8FDC\u7AEF\u76EE\u5F55\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u4F8B\u5982 /home/user/project",
|
|
740
|
+
"settings.addWorkspace": "\u6DFB\u52A0\u5DE5\u4F5C\u533A",
|
|
741
|
+
"settings.addingWorkspace": "\u6DFB\u52A0\u4E2D\u2026",
|
|
742
|
+
"settings.readingWorkspaces": "\u6B63\u5728\u8BFB\u53D6\u5DE5\u4F5C\u533A\u2026",
|
|
743
|
+
"settings.noWorkspaces": "\u8FDC\u7AEF\u8FD8\u6CA1\u6709\u6CE8\u518C\u5DE5\u4F5C\u533A\u3002\u53EF\u5728\u8FDC\u7AEF DSH \u91CC\u6DFB\u52A0\u76EE\u5F55\u540E\u5237\u65B0\u3002",
|
|
744
|
+
"settings.sessionsUnit": "\u4E2A\u4F1A\u8BDD",
|
|
745
|
+
"settings.newSession": "+ \u65B0\u4F1A\u8BDD",
|
|
746
|
+
"settings.creating": "\u521B\u5EFA\u4E2D\u2026",
|
|
747
|
+
"settings.readingSessions": "\u6B63\u5728\u8BFB\u53D6\u4F1A\u8BDD\u2026",
|
|
748
|
+
"settings.noSessions": "\u8BE5\u5DE5\u4F5C\u533A\u6682\u65E0\u4F1A\u8BDD\u3002\u70B9\u201C+ \u65B0\u4F1A\u8BDD\u201D\u5F00\u59CB\u3002",
|
|
749
|
+
"settings.eventsUnit": "\u4E8B\u4EF6",
|
|
750
|
+
"phase.idle": "\u672A\u8FDE\u63A5",
|
|
751
|
+
"phase.discovering": "\u53D1\u73B0\u4E2D",
|
|
752
|
+
"phase.installing": "\u5B89\u88C5\u4E2D",
|
|
753
|
+
"phase.connecting": "\u8FDE\u63A5\u4E2D",
|
|
754
|
+
"phase.connected": "\u5DF2\u8FDE\u63A5",
|
|
755
|
+
"phase.disconnected": "\u5DF2\u65AD\u5F00",
|
|
756
|
+
"phase.error": "\u5F02\u5E38",
|
|
757
|
+
"detail.discovering": "\u6B63\u5728\u901A\u8FC7 SSH \u53D1\u73B0\u8FDC\u7AEF agent\u2026",
|
|
758
|
+
"detail.installing": "\u6B63\u5728\u8FDC\u7AEF\u5B89\u88C5 DSH \u4E0E dsh-remote-agent\uFF0C\u9996\u6B21\u7EA6 1\u20133 \u5206\u949F\u2026",
|
|
759
|
+
"detail.connecting": "\u6B63\u5728\u5EFA\u7ACB SSH \u96A7\u9053\u5E76\u6821\u9A8C\u8FDC\u7AEF agent\u2026",
|
|
760
|
+
"detail.reprovisioning": "\u6B63\u5728\u91CD\u65B0\u5B89\u88C5\u8FDC\u7AEF agent\u2026",
|
|
761
|
+
"detail.reconnecting": "SSH \u96A7\u9053\u65AD\u5F00\uFF0C\u7B49\u5F85\u91CD\u8FDE\u2026",
|
|
762
|
+
"detail.connectedProxy": "\u5DF2\u8FDE\u63A5\uFF1B\u6A21\u578B\u8BF7\u6C42\u7ECF\u672C\u5730\u51ED\u636E\u4EE3\u7406\u8F6C\u53D1",
|
|
763
|
+
"detail.connectedDirect": "\u5DF2\u8FDE\u63A5\uFF1B\u6A21\u578B\u8BF7\u6C42\u7531\u8FDC\u7AEF\u76F4\u8FDE DeepSeek",
|
|
764
|
+
"detail.connectedRemote": "\u5DF2\u8FDE\u63A5\uFF1B\u8FDC\u7AEF\u4F7F\u7528\u81EA\u8EAB\u51ED\u636E\u6216\u672A\u914D\u7F6E\u6A21\u578B key",
|
|
765
|
+
"dialog.title": "\u65B0\u5EFA\u5DE5\u4F5C\u533A",
|
|
766
|
+
"dialog.close": "\u5173\u95ED",
|
|
767
|
+
"dialog.name": "\u5DE5\u4F5C\u533A\u540D\u79F0",
|
|
768
|
+
"dialog.namePlaceholder": "\u5DE5\u4F5C\u533A\u540D\u79F0\uFF08\u53EF\u9009\uFF09",
|
|
769
|
+
"dialog.source": "\u6E90\u76EE\u5F55",
|
|
770
|
+
"dialog.addToPrefix": "\u5C06\u76EE\u5F55\u6DFB\u52A0\u5230 ",
|
|
771
|
+
"dialog.addToSuffix": "",
|
|
772
|
+
"dialog.add": "\u6DFB\u52A0",
|
|
773
|
+
"dialog.local": "\u672C\u673A",
|
|
774
|
+
"dialog.remoteDevices": "\u8FDC\u7AEF\u8BBE\u5907",
|
|
775
|
+
"dialog.addRemote": "+ \u6DFB\u52A0\u8FDC\u7AEF\u2026",
|
|
776
|
+
"dialog.addRemoteHint": "\u8BF7\u5148\u5728 Settings \u2192 \u8FDC\u7A0B\u5F00\u53D1 \u6DFB\u52A0\u5E76\u8FDE\u63A5\u8FDC\u7AEF\u4E3B\u673A\u3002",
|
|
777
|
+
"dialog.cancel": "\u53D6\u6D88",
|
|
778
|
+
"dialog.create": "\u521B\u5EFA\u5DE5\u4F5C\u533A",
|
|
779
|
+
"dialog.creating": "\u521B\u5EFA\u4E2D\u2026",
|
|
780
|
+
"dialog.createFailed": "\u65B0\u5EFA\u5DE5\u4F5C\u533A\u5931\u8D25",
|
|
781
|
+
"dialog.removeFolder": "\u79FB\u9664\u76EE\u5F55",
|
|
782
|
+
"dialog.selectedFallback": "\u8FDC\u7AEF workspace \u5DF2\u521B\u5EFA\uFF0C\u4F46\u672C\u5730\u955C\u50CF\u8FD8\u6CA1\u6709\u540C\u6B65\u5B8C\u6210",
|
|
783
|
+
"dialog.folderTitle": "\u9009\u62E9\u6E90\u76EE\u5F55",
|
|
784
|
+
"dialog.up": "\u4E0A\u4E00\u7EA7",
|
|
785
|
+
"dialog.selectFolder": "\u9009\u62E9\u5F53\u524D\u76EE\u5F55",
|
|
786
|
+
"dialog.reading": "\u6B63\u5728\u8BFB\u53D6\u76EE\u5F55\u2026",
|
|
787
|
+
"dialog.emptyFolder": "\u6B64\u76EE\u5F55\u6CA1\u6709\u5B50\u76EE\u5F55",
|
|
788
|
+
"dialog.readFailed": "\u8BFB\u53D6\u76EE\u5F55\u5931\u8D25",
|
|
789
|
+
"dialog.nativePickerFailed": "\u65E0\u6CD5\u6253\u5F00\u7CFB\u7EDF\u76EE\u5F55\u9009\u62E9\u5668",
|
|
790
|
+
"dialog.useFolder": "\u4F7F\u7528\u6B64\u76EE\u5F55"
|
|
791
|
+
};
|
|
792
|
+
var en = {
|
|
793
|
+
"settings.title": "Remote development",
|
|
794
|
+
"settings.subtitle.lead": "Enter an SSH target. The plugin installs and starts the remote agent and opens a tunnel.",
|
|
795
|
+
"settings.subtitle.body": "Remote workspaces and sessions sync into the normal sidebar and open like local sessions. The model key is written into the remote service environment by default; local proxying remains optional.",
|
|
796
|
+
"settings.refresh": "Refresh",
|
|
797
|
+
"settings.addHost": "Add host",
|
|
798
|
+
"settings.sshTarget": "SSH target",
|
|
799
|
+
"settings.sshPlaceholder": "user@host or ssh://user@host:22",
|
|
800
|
+
"settings.label": "Display name (optional)",
|
|
801
|
+
"settings.labelPlaceholder": "Optional, e.g. dev box",
|
|
802
|
+
"settings.saveConnect": "Save and connect",
|
|
803
|
+
"settings.adding": "Adding\u2026",
|
|
804
|
+
"settings.sshHint": "Requires key or ssh-agent authentication. First install takes about 1\u20133 minutes.",
|
|
805
|
+
"settings.hosts": "Hosts",
|
|
806
|
+
"settings.hostsUnit": "",
|
|
807
|
+
"settings.noHosts": "No remote hosts yet. Add one above.",
|
|
808
|
+
"settings.refreshFailed": "Refresh failed",
|
|
809
|
+
"settings.unavailable": "Cannot reach the local remote-host service",
|
|
810
|
+
"settings.operationFailed": "Operation failed",
|
|
811
|
+
"settings.sshRequired": "Enter an SSH target, e.g. user@host or ssh://user@host:22",
|
|
812
|
+
"settings.hostSaved": "Host saved. The plugin will install and start the remote agent; progress appears on the host card.",
|
|
813
|
+
"settings.readWorkspacesFailed": "Could not read remote workspaces",
|
|
814
|
+
"settings.readSessionsFailed": "Could not read remote sessions",
|
|
815
|
+
"settings.pathRequired": "Enter an absolute remote directory, e.g. /home/user/project",
|
|
816
|
+
"settings.addWorkspaceFailed": "Could not add the remote workspace",
|
|
817
|
+
"settings.sessionOpening": "Remote session created; opening it in the conversation view\u2026",
|
|
818
|
+
"settings.sessionSyncing": "Remote session created; syncing it into the sidebar\u2026",
|
|
819
|
+
"settings.createSessionFailed": "Could not create the remote session",
|
|
820
|
+
"settings.confirmRemovePrefix": 'Remove host "',
|
|
821
|
+
"settings.confirmRemoveSuffix": '"? Remote files and sessions are not deleted.',
|
|
822
|
+
"settings.remotePort": "Remote port",
|
|
823
|
+
"settings.localTunnel": "Local tunnel",
|
|
824
|
+
"settings.workspaces": "Workspaces",
|
|
825
|
+
"settings.token": "Token",
|
|
826
|
+
"settings.saved": "Saved",
|
|
827
|
+
"settings.unsaved": "Not saved",
|
|
828
|
+
"settings.modelProxy": "Model credentials",
|
|
829
|
+
"settings.localProxy": "Local proxy",
|
|
830
|
+
"settings.direct": "Remote direct",
|
|
831
|
+
"settings.remoteDefault": "Remote default",
|
|
832
|
+
"settings.collapseWorkspaces": "Hide workspaces",
|
|
833
|
+
"settings.expandWorkspaces": "Workspaces",
|
|
834
|
+
"settings.rediscover": "Rediscover",
|
|
835
|
+
"settings.disconnect": "Disconnect",
|
|
836
|
+
"settings.connect": "Connect",
|
|
837
|
+
"settings.installing": "Installing\u2026",
|
|
838
|
+
"settings.connecting": "Connecting\u2026",
|
|
839
|
+
"settings.reprovision": "Reinstall",
|
|
840
|
+
"settings.remove": "Remove",
|
|
841
|
+
"settings.workspacePathPlaceholder": "Absolute remote path, e.g. /home/user/project",
|
|
842
|
+
"settings.addWorkspace": "Add workspace",
|
|
843
|
+
"settings.addingWorkspace": "Adding\u2026",
|
|
844
|
+
"settings.readingWorkspaces": "Reading workspaces\u2026",
|
|
845
|
+
"settings.noWorkspaces": "No remote workspaces registered yet. Add a directory in the remote DSH, then refresh.",
|
|
846
|
+
"settings.sessionsUnit": "sessions",
|
|
847
|
+
"settings.newSession": "+ New session",
|
|
848
|
+
"settings.creating": "Creating\u2026",
|
|
849
|
+
"settings.readingSessions": "Reading sessions\u2026",
|
|
850
|
+
"settings.noSessions": "No sessions in this workspace. Start one with \u201C+ New session\u201D.",
|
|
851
|
+
"settings.eventsUnit": "events",
|
|
852
|
+
"phase.idle": "Idle",
|
|
853
|
+
"phase.discovering": "Discovering",
|
|
854
|
+
"phase.installing": "Installing",
|
|
855
|
+
"phase.connecting": "Connecting",
|
|
856
|
+
"phase.connected": "Connected",
|
|
857
|
+
"phase.disconnected": "Disconnected",
|
|
858
|
+
"phase.error": "Error",
|
|
859
|
+
"detail.discovering": "Discovering the remote agent over SSH\u2026",
|
|
860
|
+
"detail.installing": "Installing DSH and dsh-remote-agent remotely; this takes about 1\u20133 minutes\u2026",
|
|
861
|
+
"detail.connecting": "Opening the SSH tunnel and checking the remote agent\u2026",
|
|
862
|
+
"detail.reprovisioning": "Reinstalling the remote agent\u2026",
|
|
863
|
+
"detail.reconnecting": "SSH tunnel closed; waiting to reconnect\u2026",
|
|
864
|
+
"detail.connectedProxy": "Connected; model requests go through the local credential proxy",
|
|
865
|
+
"detail.connectedDirect": "Connected; the remote host calls DeepSeek directly",
|
|
866
|
+
"detail.connectedRemote": "Connected; the remote host uses its own credentials or has no model key",
|
|
867
|
+
"dialog.title": "New workspace",
|
|
868
|
+
"dialog.close": "Close",
|
|
869
|
+
"dialog.name": "Workspace name",
|
|
870
|
+
"dialog.namePlaceholder": "Workspace name (optional)",
|
|
871
|
+
"dialog.source": "Source folder",
|
|
872
|
+
"dialog.addToPrefix": "Add a folder on ",
|
|
873
|
+
"dialog.addToSuffix": "",
|
|
874
|
+
"dialog.add": "Add",
|
|
875
|
+
"dialog.local": "This computer",
|
|
876
|
+
"dialog.remoteDevices": "Remote devices",
|
|
877
|
+
"dialog.addRemote": "+ Add remote\u2026",
|
|
878
|
+
"dialog.addRemoteHint": "Add and connect a remote host in Settings \u2192 Remote development first.",
|
|
879
|
+
"dialog.cancel": "Cancel",
|
|
880
|
+
"dialog.create": "Create workspace",
|
|
881
|
+
"dialog.creating": "Creating\u2026",
|
|
882
|
+
"dialog.createFailed": "Could not create the workspace",
|
|
883
|
+
"dialog.removeFolder": "Remove folder",
|
|
884
|
+
"dialog.selectedFallback": "The remote workspace was created, but the local mirror has not synced yet",
|
|
885
|
+
"dialog.folderTitle": "Choose a source folder",
|
|
886
|
+
"dialog.up": "Parent folder",
|
|
887
|
+
"dialog.selectFolder": "Select current folder",
|
|
888
|
+
"dialog.reading": "Reading folder\u2026",
|
|
889
|
+
"dialog.emptyFolder": "No subfolders here",
|
|
890
|
+
"dialog.readFailed": "Could not read the folder",
|
|
891
|
+
"dialog.nativePickerFailed": "Could not open the system folder picker",
|
|
892
|
+
"dialog.useFolder": "Use folder"
|
|
893
|
+
};
|
|
894
|
+
|
|
895
|
+
// src/client/workspace-add.ts
|
|
896
|
+
var ADD_LABELS = /* @__PURE__ */ new Set(["Add workspace", "\u6DFB\u52A0\u5DE5\u4F5C\u533A"]);
|
|
897
|
+
var NATIVE_CLICK_FLAG = "dshrNativeClick";
|
|
898
|
+
var DIALOG_CLASS = "dshr-workspace-add-dialog";
|
|
899
|
+
var closeDialog;
|
|
900
|
+
var closeBrowser;
|
|
901
|
+
var closeMenu;
|
|
902
|
+
async function pickLocalDirectory(ctx) {
|
|
903
|
+
const desktop = globalThis.__DSH_DIRECTORY_PICKER__;
|
|
904
|
+
if (desktop !== void 0) return desktop.pick();
|
|
905
|
+
const uiWorkspace = ctx.uiWorkspace;
|
|
906
|
+
if (uiWorkspace?.pickDirectory !== void 0) return uiWorkspace.pickDirectory();
|
|
907
|
+
const remote = ctx.remote;
|
|
908
|
+
if (remote?.directoryPicker === void 0) throw new Error("directory picker is unavailable");
|
|
909
|
+
const result = await remote.directoryPicker.pick();
|
|
910
|
+
if (!result.ok) throw new Error(result.error.message);
|
|
911
|
+
return result.value;
|
|
912
|
+
}
|
|
913
|
+
function installWorkspaceAddMenu(ctx, api, t) {
|
|
914
|
+
if (typeof document === "undefined") return;
|
|
915
|
+
ensureStyles();
|
|
916
|
+
ctx.effect(() => {
|
|
917
|
+
const onClick = (event) => {
|
|
918
|
+
const target = event.target;
|
|
919
|
+
if (!(target instanceof Element)) return;
|
|
920
|
+
const button = target.closest("button[aria-label]");
|
|
921
|
+
if (button === null) return;
|
|
922
|
+
const label = button.getAttribute("aria-label") ?? "";
|
|
923
|
+
if (!ADD_LABELS.has(label)) return;
|
|
924
|
+
if (button.closest('[class*="headerActions"]') === null) return;
|
|
925
|
+
if (button.dataset[NATIVE_CLICK_FLAG] === "1") {
|
|
926
|
+
delete button.dataset[NATIVE_CLICK_FLAG];
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
929
|
+
event.preventDefault();
|
|
930
|
+
event.stopImmediatePropagation();
|
|
931
|
+
void openCreateDialog({ ctx, api, t }, button);
|
|
932
|
+
};
|
|
933
|
+
document.addEventListener("click", onClick, true);
|
|
934
|
+
return () => {
|
|
935
|
+
document.removeEventListener("click", onClick, true);
|
|
936
|
+
closeTransient();
|
|
937
|
+
};
|
|
938
|
+
}, "dsh-remote: workspace add dialog");
|
|
939
|
+
}
|
|
940
|
+
async function openCreateDialog(flow, anchor) {
|
|
941
|
+
closeTransient();
|
|
942
|
+
const overlay = document.createElement("div");
|
|
943
|
+
overlay.className = `${DIALOG_CLASS}-overlay`;
|
|
944
|
+
overlay.setAttribute("role", "presentation");
|
|
945
|
+
const dialog = document.createElement("div");
|
|
946
|
+
dialog.className = DIALOG_CLASS;
|
|
947
|
+
dialog.setAttribute("role", "dialog");
|
|
948
|
+
dialog.setAttribute("aria-modal", "true");
|
|
949
|
+
dialog.setAttribute("aria-label", flow.t("dialog.title"));
|
|
950
|
+
const title = document.createElement("h2");
|
|
951
|
+
title.className = `${DIALOG_CLASS}-title`;
|
|
952
|
+
title.textContent = flow.t("dialog.title");
|
|
953
|
+
const header = document.createElement("div");
|
|
954
|
+
header.className = `${DIALOG_CLASS}-header`;
|
|
955
|
+
const closeButton = document.createElement("button");
|
|
956
|
+
closeButton.type = "button";
|
|
957
|
+
closeButton.className = `${DIALOG_CLASS}-close`;
|
|
958
|
+
closeButton.setAttribute("aria-label", flow.t("dialog.close"));
|
|
959
|
+
closeButton.textContent = "\xD7";
|
|
960
|
+
header.append(title, closeButton);
|
|
961
|
+
const nameLabel = document.createElement("label");
|
|
962
|
+
nameLabel.className = `${DIALOG_CLASS}-field`;
|
|
963
|
+
const nameText = document.createElement("span");
|
|
964
|
+
nameText.textContent = flow.t("dialog.name");
|
|
965
|
+
const nameRow = document.createElement("div");
|
|
966
|
+
nameRow.className = `${DIALOG_CLASS}-input-row`;
|
|
967
|
+
const nameIcon = document.createElement("span");
|
|
968
|
+
nameIcon.className = `${DIALOG_CLASS}-input-icon`;
|
|
969
|
+
setFolderIcon(nameIcon);
|
|
970
|
+
const nameInput = document.createElement("input");
|
|
971
|
+
nameInput.className = `${DIALOG_CLASS}-input`;
|
|
972
|
+
nameInput.placeholder = flow.t("dialog.namePlaceholder");
|
|
973
|
+
nameInput.autocomplete = "off";
|
|
974
|
+
nameRow.append(nameIcon, nameInput);
|
|
975
|
+
nameLabel.append(nameText, nameRow);
|
|
976
|
+
const sourceTitle = document.createElement("h3");
|
|
977
|
+
sourceTitle.className = `${DIALOG_CLASS}-section-title`;
|
|
978
|
+
sourceTitle.textContent = flow.t("dialog.source");
|
|
979
|
+
const sourceHeader = document.createElement("div");
|
|
980
|
+
sourceHeader.className = `${DIALOG_CLASS}-source-header`;
|
|
981
|
+
const hostIndicator = document.createElement("span");
|
|
982
|
+
hostIndicator.className = `${DIALOG_CLASS}-host-indicator`;
|
|
983
|
+
const hostIcon = document.createElement("span");
|
|
984
|
+
hostIcon.className = `${DIALOG_CLASS}-host-icon`;
|
|
985
|
+
setComputerIcon(hostIcon);
|
|
986
|
+
const hostLabelText = document.createElement("span");
|
|
987
|
+
hostIndicator.append(hostIcon, hostLabelText);
|
|
988
|
+
sourceHeader.append(sourceTitle, hostIndicator);
|
|
989
|
+
const sourceBox = document.createElement("div");
|
|
990
|
+
sourceBox.className = `${DIALOG_CLASS}-source-box`;
|
|
991
|
+
const sourceCenter = document.createElement("div");
|
|
992
|
+
sourceCenter.className = `${DIALOG_CLASS}-source-center`;
|
|
993
|
+
const sourceTrigger = document.createElement("button");
|
|
994
|
+
sourceTrigger.type = "button";
|
|
995
|
+
sourceTrigger.className = `${DIALOG_CLASS}-source-trigger`;
|
|
996
|
+
const sourceTriggerText = document.createElement("span");
|
|
997
|
+
const sourceChevron = document.createElement("span");
|
|
998
|
+
sourceChevron.className = `${DIALOG_CLASS}-chevron`;
|
|
999
|
+
sourceChevron.textContent = "\u2304";
|
|
1000
|
+
sourceTrigger.append(sourceTriggerText, sourceChevron);
|
|
1001
|
+
const addFolder = document.createElement("button");
|
|
1002
|
+
addFolder.type = "button";
|
|
1003
|
+
addFolder.className = `${DIALOG_CLASS}-add-folder`;
|
|
1004
|
+
const addFolderIcon = document.createElement("span");
|
|
1005
|
+
addFolderIcon.className = `${DIALOG_CLASS}-add-folder-icon`;
|
|
1006
|
+
const addFolderText = document.createElement("span");
|
|
1007
|
+
addFolderText.textContent = flow.t("dialog.add");
|
|
1008
|
+
addFolder.append(addFolderIcon, addFolderText);
|
|
1009
|
+
sourceCenter.append(sourceTrigger, addFolder);
|
|
1010
|
+
const selectedFolder = document.createElement("div");
|
|
1011
|
+
selectedFolder.className = `${DIALOG_CLASS}-selected-folder`;
|
|
1012
|
+
const selectedIcon = document.createElement("span");
|
|
1013
|
+
selectedIcon.textContent = "\u{1F4C1}";
|
|
1014
|
+
const selectedName = document.createElement("span");
|
|
1015
|
+
selectedName.className = `${DIALOG_CLASS}-selected-name`;
|
|
1016
|
+
const removeFolder = document.createElement("button");
|
|
1017
|
+
removeFolder.type = "button";
|
|
1018
|
+
removeFolder.className = `${DIALOG_CLASS}-remove-folder`;
|
|
1019
|
+
removeFolder.setAttribute("aria-label", flow.t("dialog.removeFolder"));
|
|
1020
|
+
removeFolder.textContent = "\xD7";
|
|
1021
|
+
selectedFolder.append(selectedIcon, selectedName, removeFolder);
|
|
1022
|
+
sourceBox.append(sourceCenter, selectedFolder);
|
|
1023
|
+
const error = document.createElement("p");
|
|
1024
|
+
error.className = `${DIALOG_CLASS}-error`;
|
|
1025
|
+
error.setAttribute("role", "alert");
|
|
1026
|
+
const actions = document.createElement("div");
|
|
1027
|
+
actions.className = `${DIALOG_CLASS}-actions`;
|
|
1028
|
+
const cancel = document.createElement("button");
|
|
1029
|
+
cancel.type = "button";
|
|
1030
|
+
cancel.className = `${DIALOG_CLASS}-button`;
|
|
1031
|
+
cancel.textContent = flow.t("dialog.cancel");
|
|
1032
|
+
const create = document.createElement("button");
|
|
1033
|
+
create.type = "button";
|
|
1034
|
+
create.className = `${DIALOG_CLASS}-button ${DIALOG_CLASS}-primary`;
|
|
1035
|
+
create.textContent = flow.t("dialog.create");
|
|
1036
|
+
actions.append(cancel, create);
|
|
1037
|
+
dialog.append(header, nameLabel, sourceHeader, sourceBox, error, actions);
|
|
1038
|
+
overlay.append(dialog);
|
|
1039
|
+
document.body.append(overlay);
|
|
1040
|
+
let hosts = [];
|
|
1041
|
+
let destination = { kind: "local" };
|
|
1042
|
+
let selectedPath = "";
|
|
1043
|
+
const update = () => {
|
|
1044
|
+
const label = destination.kind === "local" ? flow.t("dialog.local") : destination.host.label;
|
|
1045
|
+
sourceTriggerText.textContent = `${flow.t("dialog.addToPrefix")}${label}${flow.t("dialog.addToSuffix")}`;
|
|
1046
|
+
hostLabelText.textContent = label;
|
|
1047
|
+
addFolderIcon.textContent = "+ ";
|
|
1048
|
+
const hasFolder = selectedPath !== "";
|
|
1049
|
+
sourceCenter.style.display = hasFolder ? "none" : "flex";
|
|
1050
|
+
selectedFolder.style.display = hasFolder ? "flex" : "none";
|
|
1051
|
+
sourceBox.classList.toggle(`${DIALOG_CLASS}-source-box-selected`, hasFolder);
|
|
1052
|
+
selectedName.textContent = hasFolder ? folderName(selectedPath) : "";
|
|
1053
|
+
selectedFolder.title = hasFolder ? selectedPath : "";
|
|
1054
|
+
create.disabled = !hasFolder;
|
|
1055
|
+
};
|
|
1056
|
+
const close = () => {
|
|
1057
|
+
closeBrowser?.();
|
|
1058
|
+
closeMenu?.();
|
|
1059
|
+
overlay.remove();
|
|
1060
|
+
window.removeEventListener("keydown", keyHandler, true);
|
|
1061
|
+
overlay.removeEventListener("pointerdown", outside, true);
|
|
1062
|
+
if (closeDialog === close) closeDialog = void 0;
|
|
1063
|
+
};
|
|
1064
|
+
closeDialog = close;
|
|
1065
|
+
const keyHandler = (event) => {
|
|
1066
|
+
if (event.key === "Escape") close();
|
|
1067
|
+
};
|
|
1068
|
+
const outside = (event) => {
|
|
1069
|
+
if (event.target === overlay) close();
|
|
1070
|
+
};
|
|
1071
|
+
window.addEventListener("keydown", keyHandler, true);
|
|
1072
|
+
overlay.addEventListener("pointerdown", outside, true);
|
|
1073
|
+
cancel.addEventListener("click", close);
|
|
1074
|
+
closeButton.addEventListener("click", close);
|
|
1075
|
+
sourceTrigger.addEventListener("click", () => {
|
|
1076
|
+
openDestinationMenu(sourceTrigger, hosts, destination, flow.t, (next) => {
|
|
1077
|
+
destination = next;
|
|
1078
|
+
selectedPath = "";
|
|
1079
|
+
update();
|
|
1080
|
+
});
|
|
1081
|
+
});
|
|
1082
|
+
addFolder.addEventListener("click", () => {
|
|
1083
|
+
if (destination.kind === "local") {
|
|
1084
|
+
addFolder.disabled = true;
|
|
1085
|
+
void pickLocalDirectory(flow.ctx).then((path) => {
|
|
1086
|
+
if (path !== null) {
|
|
1087
|
+
selectedPath = path;
|
|
1088
|
+
update();
|
|
1089
|
+
}
|
|
1090
|
+
}).catch((failure) => {
|
|
1091
|
+
error.textContent = messageOf2(failure, flow.t("dialog.nativePickerFailed"));
|
|
1092
|
+
}).finally(() => {
|
|
1093
|
+
addFolder.disabled = false;
|
|
1094
|
+
});
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
const initial = destination.host.hostInfo?.home ?? "~";
|
|
1098
|
+
openDirectoryBrowser(flow, destination, initial, (path) => {
|
|
1099
|
+
selectedPath = path;
|
|
1100
|
+
update();
|
|
1101
|
+
});
|
|
1102
|
+
});
|
|
1103
|
+
removeFolder.addEventListener("click", () => {
|
|
1104
|
+
selectedPath = "";
|
|
1105
|
+
update();
|
|
1106
|
+
});
|
|
1107
|
+
nameInput.addEventListener("input", update);
|
|
1108
|
+
try {
|
|
1109
|
+
const state = await flow.api.state();
|
|
1110
|
+
hosts = state.hosts.filter((host) => host.phase === "connected");
|
|
1111
|
+
} catch {
|
|
1112
|
+
hosts = [];
|
|
1113
|
+
}
|
|
1114
|
+
update();
|
|
1115
|
+
create.addEventListener("click", () => {
|
|
1116
|
+
if (selectedPath === "") return;
|
|
1117
|
+
const title2 = nameInput.value.trim() || folderName(selectedPath);
|
|
1118
|
+
create.disabled = true;
|
|
1119
|
+
cancel.disabled = true;
|
|
1120
|
+
create.textContent = flow.t("dialog.creating");
|
|
1121
|
+
void (async () => {
|
|
1122
|
+
try {
|
|
1123
|
+
if (destination.kind === "local") {
|
|
1124
|
+
const local = await flow.api.createLocalWorkspace({ path: selectedPath, title: title2 });
|
|
1125
|
+
close();
|
|
1126
|
+
flow.ctx.uiWorkspace.startSession(local.workspaceId);
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
const workspace = await flow.api.createWorkspace(destination.host.id, {
|
|
1130
|
+
path: selectedPath,
|
|
1131
|
+
title: title2
|
|
1132
|
+
});
|
|
1133
|
+
const session = await flow.api.createSession(destination.host.id, {
|
|
1134
|
+
workspaceId: workspace.workspaceId
|
|
1135
|
+
});
|
|
1136
|
+
if (session.localSessionId !== void 0) {
|
|
1137
|
+
close();
|
|
1138
|
+
flow.api.openSession(session.localSessionId);
|
|
1139
|
+
return;
|
|
1140
|
+
}
|
|
1141
|
+
const localId = await waitForLocalWorkspace(flow.api, destination.host.id, workspace.workspaceId);
|
|
1142
|
+
if (localId === void 0) throw new Error(flow.t("dialog.selectedFallback"));
|
|
1143
|
+
close();
|
|
1144
|
+
flow.ctx.uiWorkspace.startSession(localId);
|
|
1145
|
+
} catch (failure) {
|
|
1146
|
+
error.textContent = messageOf2(failure, flow.t("dialog.createFailed"));
|
|
1147
|
+
create.disabled = false;
|
|
1148
|
+
cancel.disabled = false;
|
|
1149
|
+
create.textContent = flow.t("dialog.create");
|
|
1150
|
+
}
|
|
1151
|
+
})();
|
|
1152
|
+
});
|
|
1153
|
+
nameInput.focus();
|
|
1154
|
+
}
|
|
1155
|
+
function openDestinationMenu(anchor, hosts, current, t, onPick) {
|
|
1156
|
+
closeMenu?.();
|
|
1157
|
+
const menu = document.createElement("div");
|
|
1158
|
+
menu.className = `${DIALOG_CLASS}-destination-menu`;
|
|
1159
|
+
const add = (label, destination) => {
|
|
1160
|
+
const item = document.createElement("button");
|
|
1161
|
+
item.type = "button";
|
|
1162
|
+
item.className = `${DIALOG_CLASS}-destination-item`;
|
|
1163
|
+
const text = document.createElement("span");
|
|
1164
|
+
text.textContent = label;
|
|
1165
|
+
const check = document.createElement("span");
|
|
1166
|
+
check.className = `${DIALOG_CLASS}-destination-check`;
|
|
1167
|
+
const selected = current.kind === destination.kind && (destination.kind === "local" || current.kind === "remote" && current.host.id === destination.host.id);
|
|
1168
|
+
check.textContent = selected ? "\u2713" : "";
|
|
1169
|
+
item.append(text, check);
|
|
1170
|
+
item.addEventListener("click", () => {
|
|
1171
|
+
onPick(destination);
|
|
1172
|
+
close();
|
|
1173
|
+
});
|
|
1174
|
+
menu.append(item);
|
|
1175
|
+
};
|
|
1176
|
+
add(t("dialog.local"), { kind: "local" });
|
|
1177
|
+
if (hosts.length > 0) {
|
|
1178
|
+
const section = document.createElement("div");
|
|
1179
|
+
section.className = `${DIALOG_CLASS}-destination-section`;
|
|
1180
|
+
section.textContent = t("dialog.remoteDevices");
|
|
1181
|
+
menu.append(section);
|
|
1182
|
+
for (const host of hosts) add(host.label, { kind: "remote", host });
|
|
1183
|
+
}
|
|
1184
|
+
const addRemote = document.createElement("button");
|
|
1185
|
+
addRemote.type = "button";
|
|
1186
|
+
addRemote.className = `${DIALOG_CLASS}-destination-item ${DIALOG_CLASS}-destination-add`;
|
|
1187
|
+
addRemote.textContent = t("dialog.addRemote");
|
|
1188
|
+
addRemote.addEventListener("click", () => {
|
|
1189
|
+
close();
|
|
1190
|
+
const error = document.querySelector(`.${DIALOG_CLASS}-error`);
|
|
1191
|
+
if (error !== null) error.textContent = t("dialog.addRemoteHint");
|
|
1192
|
+
});
|
|
1193
|
+
menu.append(addRemote);
|
|
1194
|
+
document.body.append(menu);
|
|
1195
|
+
const rect = anchor.getBoundingClientRect();
|
|
1196
|
+
menu.style.left = `${Math.min(rect.left, window.innerWidth - 260)}px`;
|
|
1197
|
+
menu.style.top = `${rect.bottom + 6}px`;
|
|
1198
|
+
const close = () => {
|
|
1199
|
+
menu.remove();
|
|
1200
|
+
window.removeEventListener("pointerdown", dismiss, true);
|
|
1201
|
+
if (closeMenu === close) closeMenu = void 0;
|
|
1202
|
+
};
|
|
1203
|
+
closeMenu = close;
|
|
1204
|
+
const dismiss = (event) => {
|
|
1205
|
+
if (event.target instanceof Node && menu.contains(event.target)) return;
|
|
1206
|
+
close();
|
|
1207
|
+
};
|
|
1208
|
+
window.addEventListener("pointerdown", dismiss, true);
|
|
1209
|
+
}
|
|
1210
|
+
async function openDirectoryBrowser(flow, destination, initialPath, onPick) {
|
|
1211
|
+
closeBrowser?.();
|
|
1212
|
+
const overlay = document.createElement("div");
|
|
1213
|
+
overlay.className = `${DIALOG_CLASS}-browser-overlay`;
|
|
1214
|
+
overlay.setAttribute("role", "presentation");
|
|
1215
|
+
const dialog = document.createElement("div");
|
|
1216
|
+
dialog.className = `${DIALOG_CLASS} ${DIALOG_CLASS}-browser`;
|
|
1217
|
+
dialog.setAttribute("role", "dialog");
|
|
1218
|
+
dialog.setAttribute("aria-modal", "true");
|
|
1219
|
+
dialog.setAttribute("aria-label", flow.t("dialog.folderTitle"));
|
|
1220
|
+
const title = document.createElement("h2");
|
|
1221
|
+
title.className = `${DIALOG_CLASS}-browser-title`;
|
|
1222
|
+
title.textContent = flow.t("dialog.folderTitle");
|
|
1223
|
+
const browserHeader = document.createElement("div");
|
|
1224
|
+
browserHeader.className = `${DIALOG_CLASS}-browser-header`;
|
|
1225
|
+
const browserClose = document.createElement("button");
|
|
1226
|
+
browserClose.type = "button";
|
|
1227
|
+
browserClose.className = `${DIALOG_CLASS}-close`;
|
|
1228
|
+
browserClose.setAttribute("aria-label", flow.t("dialog.close"));
|
|
1229
|
+
browserClose.textContent = "\xD7";
|
|
1230
|
+
browserHeader.append(title, browserClose);
|
|
1231
|
+
const pathRow = document.createElement("div");
|
|
1232
|
+
pathRow.className = `${DIALOG_CLASS}-browser-path-row`;
|
|
1233
|
+
const up = document.createElement("button");
|
|
1234
|
+
up.type = "button";
|
|
1235
|
+
up.className = `${DIALOG_CLASS}-up`;
|
|
1236
|
+
up.textContent = "\u2191";
|
|
1237
|
+
up.setAttribute("aria-label", flow.t("dialog.up"));
|
|
1238
|
+
const pathInput = document.createElement("input");
|
|
1239
|
+
pathInput.className = `${DIALOG_CLASS}-browser-path`;
|
|
1240
|
+
pathInput.value = initialPath;
|
|
1241
|
+
pathInput.autocomplete = "off";
|
|
1242
|
+
pathRow.append(up, pathInput);
|
|
1243
|
+
const status = document.createElement("p");
|
|
1244
|
+
status.className = `${DIALOG_CLASS}-browser-status`;
|
|
1245
|
+
status.textContent = flow.t("dialog.selectFolder");
|
|
1246
|
+
const list = document.createElement("div");
|
|
1247
|
+
list.className = `${DIALOG_CLASS}-browser-list`;
|
|
1248
|
+
const actions = document.createElement("div");
|
|
1249
|
+
actions.className = `${DIALOG_CLASS}-actions`;
|
|
1250
|
+
const cancel = document.createElement("button");
|
|
1251
|
+
cancel.type = "button";
|
|
1252
|
+
cancel.className = `${DIALOG_CLASS}-button`;
|
|
1253
|
+
cancel.textContent = flow.t("dialog.cancel");
|
|
1254
|
+
const use = document.createElement("button");
|
|
1255
|
+
use.type = "button";
|
|
1256
|
+
use.className = `${DIALOG_CLASS}-button ${DIALOG_CLASS}-primary`;
|
|
1257
|
+
use.textContent = flow.t("dialog.useFolder");
|
|
1258
|
+
actions.append(cancel, use);
|
|
1259
|
+
dialog.append(browserHeader, pathRow, status, list, actions);
|
|
1260
|
+
overlay.append(dialog);
|
|
1261
|
+
document.body.append(overlay);
|
|
1262
|
+
let current = initialPath;
|
|
1263
|
+
let parent = initialPath;
|
|
1264
|
+
let currentEntries = [];
|
|
1265
|
+
let requestSeq = 0;
|
|
1266
|
+
let filterTimer;
|
|
1267
|
+
const fetchListing = async (path) => {
|
|
1268
|
+
const sequence = ++requestSeq;
|
|
1269
|
+
status.textContent = flow.t("dialog.reading");
|
|
1270
|
+
status.classList.remove(`${DIALOG_CLASS}-error-text`);
|
|
1271
|
+
try {
|
|
1272
|
+
const listing = destination.kind === "local" ? await flow.api.listLocalDirectories(path) : await flow.api.listDirectories(destination.host.id, path);
|
|
1273
|
+
if (sequence !== requestSeq) return void 0;
|
|
1274
|
+
return listing;
|
|
1275
|
+
} catch (failure) {
|
|
1276
|
+
if (sequence === requestSeq) {
|
|
1277
|
+
status.textContent = messageOf2(failure, flow.t("dialog.readFailed"));
|
|
1278
|
+
status.classList.add(`${DIALOG_CLASS}-error-text`);
|
|
1279
|
+
}
|
|
1280
|
+
return void 0;
|
|
1281
|
+
}
|
|
1282
|
+
};
|
|
1283
|
+
const render = (entries) => {
|
|
1284
|
+
list.replaceChildren();
|
|
1285
|
+
if (entries.length === 0) {
|
|
1286
|
+
const empty = document.createElement("p");
|
|
1287
|
+
empty.className = `${DIALOG_CLASS}-browser-empty`;
|
|
1288
|
+
empty.textContent = flow.t("dialog.emptyFolder");
|
|
1289
|
+
list.append(empty);
|
|
1290
|
+
return;
|
|
1291
|
+
}
|
|
1292
|
+
for (const entry of entries) {
|
|
1293
|
+
const item = document.createElement("button");
|
|
1294
|
+
item.type = "button";
|
|
1295
|
+
item.className = `${DIALOG_CLASS}-browser-entry`;
|
|
1296
|
+
const icon = document.createElement("span");
|
|
1297
|
+
icon.textContent = "\u{1F4C1}";
|
|
1298
|
+
const label = document.createElement("span");
|
|
1299
|
+
label.textContent = entry.name;
|
|
1300
|
+
item.append(icon, label);
|
|
1301
|
+
item.addEventListener("click", () => {
|
|
1302
|
+
void load(entry.path);
|
|
1303
|
+
});
|
|
1304
|
+
list.append(item);
|
|
1305
|
+
}
|
|
1306
|
+
};
|
|
1307
|
+
const load = async (path) => {
|
|
1308
|
+
const listing = await fetchListing(path);
|
|
1309
|
+
if (listing === void 0) return;
|
|
1310
|
+
current = listing.path;
|
|
1311
|
+
parent = listing.parent;
|
|
1312
|
+
currentEntries = listing.entries;
|
|
1313
|
+
pathInput.value = listing.path;
|
|
1314
|
+
status.textContent = flow.t("dialog.selectFolder");
|
|
1315
|
+
render(listing.entries);
|
|
1316
|
+
};
|
|
1317
|
+
const applyInputFilter = async (raw) => {
|
|
1318
|
+
if (raw === "") return;
|
|
1319
|
+
const slash = raw.lastIndexOf("/");
|
|
1320
|
+
const dir = slash < 0 ? current : raw.slice(0, slash + 1) || "/";
|
|
1321
|
+
const query = slash < 0 ? raw : raw.slice(slash + 1);
|
|
1322
|
+
if (query === "") {
|
|
1323
|
+
await load(raw);
|
|
1324
|
+
return;
|
|
1325
|
+
}
|
|
1326
|
+
const normalizedCurrent = current.replace(/\/+$/u, "") || "/";
|
|
1327
|
+
const normalizedDir = dir.replace(/\/+$/u, "") || "/";
|
|
1328
|
+
if (normalizedDir === normalizedCurrent) {
|
|
1329
|
+
const needle2 = query.toLocaleLowerCase();
|
|
1330
|
+
render(currentEntries.filter((entry) => entry.name.toLocaleLowerCase().startsWith(needle2)));
|
|
1331
|
+
status.textContent = flow.t("dialog.selectFolder");
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
const listing = await fetchListing(dir);
|
|
1335
|
+
if (listing === void 0) return;
|
|
1336
|
+
current = listing.path;
|
|
1337
|
+
parent = listing.parent;
|
|
1338
|
+
currentEntries = listing.entries;
|
|
1339
|
+
const needle = query.toLocaleLowerCase();
|
|
1340
|
+
render(listing.entries.filter((entry) => entry.name.toLocaleLowerCase().startsWith(needle)));
|
|
1341
|
+
status.textContent = flow.t("dialog.selectFolder");
|
|
1342
|
+
};
|
|
1343
|
+
const close = () => {
|
|
1344
|
+
overlay.remove();
|
|
1345
|
+
window.removeEventListener("keydown", keyHandler, true);
|
|
1346
|
+
overlay.removeEventListener("pointerdown", outside, true);
|
|
1347
|
+
if (closeBrowser === close) closeBrowser = void 0;
|
|
1348
|
+
};
|
|
1349
|
+
closeBrowser = close;
|
|
1350
|
+
const keyHandler = (event) => {
|
|
1351
|
+
if (event.key === "Escape") close();
|
|
1352
|
+
};
|
|
1353
|
+
const outside = (event) => {
|
|
1354
|
+
if (event.target === overlay) close();
|
|
1355
|
+
};
|
|
1356
|
+
window.addEventListener("keydown", keyHandler, true);
|
|
1357
|
+
overlay.addEventListener("pointerdown", outside, true);
|
|
1358
|
+
cancel.addEventListener("click", close);
|
|
1359
|
+
browserClose.addEventListener("click", close);
|
|
1360
|
+
use.addEventListener("click", () => {
|
|
1361
|
+
onPick(current);
|
|
1362
|
+
close();
|
|
1363
|
+
});
|
|
1364
|
+
up.addEventListener("click", () => {
|
|
1365
|
+
if (parent !== "" && parent !== current) void load(parent);
|
|
1366
|
+
});
|
|
1367
|
+
pathInput.addEventListener("input", () => {
|
|
1368
|
+
if (filterTimer !== void 0) window.clearTimeout(filterTimer);
|
|
1369
|
+
const value = pathInput.value;
|
|
1370
|
+
filterTimer = window.setTimeout(() => {
|
|
1371
|
+
void applyInputFilter(value);
|
|
1372
|
+
}, 140);
|
|
1373
|
+
});
|
|
1374
|
+
pathInput.addEventListener("keydown", (event) => {
|
|
1375
|
+
if (event.key !== "Enter") return;
|
|
1376
|
+
event.preventDefault();
|
|
1377
|
+
const value = pathInput.value.trim();
|
|
1378
|
+
if (value !== "") void applyInputFilter(value);
|
|
1379
|
+
});
|
|
1380
|
+
void load(initialPath);
|
|
1381
|
+
}
|
|
1382
|
+
async function waitForLocalWorkspace(api, hostId, workspaceId) {
|
|
1383
|
+
for (let attempt = 0; attempt < 40; attempt += 1) {
|
|
1384
|
+
const result = await api.workspaces(hostId);
|
|
1385
|
+
const workspace = result.workspaces.find((item) => item.workspaceId === workspaceId);
|
|
1386
|
+
if (workspace?.localWorkspaceId !== void 0) return workspace.localWorkspaceId;
|
|
1387
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
1388
|
+
}
|
|
1389
|
+
return void 0;
|
|
1390
|
+
}
|
|
1391
|
+
function closeTransient() {
|
|
1392
|
+
closeDialog?.();
|
|
1393
|
+
closeBrowser?.();
|
|
1394
|
+
closeMenu?.();
|
|
1395
|
+
}
|
|
1396
|
+
function messageOf2(failure, fallback) {
|
|
1397
|
+
if (failure instanceof Error && failure.message !== "") return failure.message;
|
|
1398
|
+
return fallback;
|
|
1399
|
+
}
|
|
1400
|
+
function setFolderIcon(icon) {
|
|
1401
|
+
icon.innerHTML = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M3.5 7.5A2.5 2.5 0 0 1 6 5h4l2 2h6a2.5 2.5 0 0 1 2.5 2.5v7A2.5 2.5 0 0 1 18 19H6a2.5 2.5 0 0 1-2.5-2.5v-9Z" stroke="currentColor" stroke-width="1.5"/></svg>';
|
|
1402
|
+
}
|
|
1403
|
+
function folderName(path) {
|
|
1404
|
+
const clean = path.replace(/[\\/]+$/u, "");
|
|
1405
|
+
const parts = clean.split(/[\\/]+/u);
|
|
1406
|
+
return parts[parts.length - 1] ?? clean;
|
|
1407
|
+
}
|
|
1408
|
+
function setComputerIcon(icon) {
|
|
1409
|
+
icon.innerHTML = '<svg width="17" height="17" viewBox="0 0 24 24" fill="none" aria-hidden="true"><rect x="3.5" y="5" width="17" height="12" rx="1.7" stroke="currentColor" stroke-width="1.5"/><path d="M8 20h8M12 17v3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>';
|
|
1410
|
+
}
|
|
1411
|
+
function ensureStyles() {
|
|
1412
|
+
const existing = document.getElementById("dshr-workspace-add-style");
|
|
1413
|
+
const style = existing instanceof HTMLStyleElement ? existing : document.createElement("style");
|
|
1414
|
+
style.id = "dshr-workspace-add-style";
|
|
1415
|
+
style.textContent = `
|
|
1416
|
+
.${DIALOG_CLASS}-overlay {
|
|
1417
|
+
position: fixed; inset: 0; z-index: 100001; display: grid; place-items: center;
|
|
1418
|
+
padding: 24px; background: rgba(0,0,0,.55);
|
|
1419
|
+
}
|
|
1420
|
+
.${DIALOG_CLASS} {
|
|
1421
|
+
width: min(632px, calc(100vw - 48px));
|
|
1422
|
+
box-sizing: border-box; padding: 26px; display: flex; flex-direction: column;
|
|
1423
|
+
border-radius: 14px; border: 1px solid rgba(255,255,255,.1);
|
|
1424
|
+
background: #242424; color: #f2f2f2; box-shadow: 0 28px 80px rgba(0,0,0,.65);
|
|
1425
|
+
font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
1426
|
+
}
|
|
1427
|
+
.${DIALOG_CLASS}-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
|
|
1428
|
+
.${DIALOG_CLASS}-title { margin: 0; font-size: 28px; line-height: 1.1; font-weight: 700; letter-spacing: -.02em; }
|
|
1429
|
+
.${DIALOG_CLASS}-close { border: 0; background: transparent; color: rgba(255,255,255,.75); font-size: 30px; line-height: 1; cursor: pointer; padding: 0 2px; }
|
|
1430
|
+
.${DIALOG_CLASS}-close:hover { color: #fff; }
|
|
1431
|
+
.${DIALOG_CLASS}-field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
|
|
1432
|
+
.${DIALOG_CLASS}-field > span { font-size: 13px; color: rgba(255,255,255,.72); }
|
|
1433
|
+
.${DIALOG_CLASS}-input-row { display: flex; align-items: center; gap: 10px; border: 1px solid rgba(255,255,255,.24); border-radius: 9px; padding: 0 12px; background: transparent; }
|
|
1434
|
+
.${DIALOG_CLASS}-input-icon { display: inline-flex; color: rgba(255,255,255,.7); }
|
|
1435
|
+
.${DIALOG_CLASS}-input { width: 100%; border: 0; outline: none; background: transparent; color: inherit; font: inherit; font-size: 14px; padding: 13px 0; }
|
|
1436
|
+
.${DIALOG_CLASS}-source-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 10px; }
|
|
1437
|
+
.${DIALOG_CLASS}-section-title { margin: 0; font-size: 17px; font-weight: 600; color: rgba(255,255,255,.92); }
|
|
1438
|
+
.${DIALOG_CLASS}-host-indicator { display: inline-flex; align-items: center; gap: 8px; color: rgba(255,255,255,.62); font-size: 15px; }
|
|
1439
|
+
.${DIALOG_CLASS}-host-icon { display: inline-flex; }
|
|
1440
|
+
.${DIALOG_CLASS}-source-box { position: relative; border: 1px solid rgba(255,255,255,.16); border-radius: 9px; padding: 24px 16px; min-height: 150px; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; }
|
|
1441
|
+
.${DIALOG_CLASS}-source-center { display: flex; flex-direction: column; align-items: center; gap: 16px; }
|
|
1442
|
+
.${DIALOG_CLASS}-source-trigger { display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent; color: rgba(255,255,255,.75); font: inherit; font-size: 15px; cursor: pointer; }
|
|
1443
|
+
.${DIALOG_CLASS}-source-trigger span:first-child { color: #fff; font-weight: 600; }
|
|
1444
|
+
.${DIALOG_CLASS}-chevron { font-size: 18px; line-height: 1; }
|
|
1445
|
+
.${DIALOG_CLASS}-add-folder { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 8px; padding: 8px 14px; background: rgba(255,255,255,.12); color: #fff; font: inherit; font-size: 14px; cursor: pointer; }
|
|
1446
|
+
.${DIALOG_CLASS}-add-folder:hover { background: rgba(255,255,255,.18); }
|
|
1447
|
+
.${DIALOG_CLASS}-add-folder-icon { font-size: 18px; line-height: 1; }
|
|
1448
|
+
.${DIALOG_CLASS}-source-box-selected { padding: 0; min-height: 0; flex: none; justify-content: flex-start; }
|
|
1449
|
+
.${DIALOG_CLASS}-selected-folder { display: none; align-items: center; gap: 12px; width: 100%; box-sizing: border-box; padding: 12px 14px; color: rgba(255,255,255,.92); font-size: 16px; }
|
|
1450
|
+
.${DIALOG_CLASS}-selected-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1451
|
+
.${DIALOG_CLASS}-remove-folder { flex: none; border: 0; background: transparent; color: rgba(255,255,255,.6); font-size: 24px; line-height: 1; cursor: pointer; padding: 0 2px; }
|
|
1452
|
+
.${DIALOG_CLASS}-remove-folder:hover { color: #fff; }
|
|
1453
|
+
.${DIALOG_CLASS}-error { margin: 6px 0 0; color: #ff8b8b; font-size: 12px; white-space: pre-wrap; }
|
|
1454
|
+
.${DIALOG_CLASS}-error:empty { display: none; }
|
|
1455
|
+
.${DIALOG_CLASS}-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
|
|
1456
|
+
.${DIALOG_CLASS}-button { padding: 11px 18px; border-radius: 8px; border: 1px solid rgba(255,255,255,.18); background: transparent; color: #eee; cursor: pointer; font: inherit; font-size: 15px; }
|
|
1457
|
+
.${DIALOG_CLASS}-button:disabled { opacity: .45; cursor: default; }
|
|
1458
|
+
.${DIALOG_CLASS}-primary { border-color: #bdbdbd; background: #bdbdbd; color: #1a1a1a; font-weight: 600; }
|
|
1459
|
+
.${DIALOG_CLASS}-primary:hover:not(:disabled) { background: #d0d0d0; }
|
|
1460
|
+
.${DIALOG_CLASS}-destination-menu {
|
|
1461
|
+
position: fixed; z-index: 100010; min-width: 250px; padding: 6px;
|
|
1462
|
+
border-radius: 12px; border: 1px solid rgba(255,255,255,.14); background: #2a2a2a; color: #eee;
|
|
1463
|
+
box-shadow: 0 18px 48px rgba(0,0,0,.55); font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
1464
|
+
}
|
|
1465
|
+
.${DIALOG_CLASS}-destination-item { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 10px 12px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; cursor: pointer; text-align: left; }
|
|
1466
|
+
.${DIALOG_CLASS}-destination-item:hover { background: rgba(255,255,255,.09); }
|
|
1467
|
+
.${DIALOG_CLASS}-destination-section { padding: 14px 12px 6px; color: rgba(255,255,255,.5); font-size: 13px; }
|
|
1468
|
+
.${DIALOG_CLASS}-destination-check { color: #bdbdbd; }
|
|
1469
|
+
.${DIALOG_CLASS}-destination-add { color: rgba(255,255,255,.75); }
|
|
1470
|
+
.${DIALOG_CLASS}-browser-overlay { position: fixed; inset: 0; z-index: 100002; display: grid; place-items: center; background: rgba(0,0,0,.6); padding: 24px; }
|
|
1471
|
+
.${DIALOG_CLASS}-browser { width: 640px; max-height: 86vh; display: flex; flex-direction: column; padding: 26px; }
|
|
1472
|
+
.${DIALOG_CLASS}-browser-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
|
|
1473
|
+
.${DIALOG_CLASS}-browser-title { margin: 0; font-size: 30px; line-height: 1.15; font-weight: 700; }
|
|
1474
|
+
.${DIALOG_CLASS}-browser-path-row { display: flex; align-items: center; gap: 8px; }
|
|
1475
|
+
.${DIALOG_CLASS}-up { flex: none; width: 34px; height: 34px; border: 0; background: transparent; color: rgba(255,255,255,.65); font-size: 22px; cursor: pointer; }
|
|
1476
|
+
.${DIALOG_CLASS}-browser-path { flex: 1; border: 1px solid rgba(255,255,255,.22); border-radius: 9px; background: transparent; color: #fff; font: inherit; font-size: 16px; padding: 12px 14px; outline: none; }
|
|
1477
|
+
.${DIALOG_CLASS}-browser-path:focus { border-color: #4f8cff; }
|
|
1478
|
+
.${DIALOG_CLASS}-browser-status { margin: 14px 0 8px; color: rgba(255,255,255,.55); font-size: 13px; }
|
|
1479
|
+
.${DIALOG_CLASS}-browser-list { flex: 1; min-height: 220px; max-height: 420px; overflow: auto; border: 1px solid rgba(255,255,255,.16); border-radius: 12px; padding: 6px; }
|
|
1480
|
+
.${DIALOG_CLASS}-browser-entry { display: flex; align-items: center; gap: 12px; width: 100%; box-sizing: border-box; padding: 11px 12px; border: 0; border-radius: 8px; background: transparent; color: #fff; font: inherit; font-size: 16px; text-align: left; cursor: pointer; }
|
|
1481
|
+
.${DIALOG_CLASS}-browser-entry:hover { background: rgba(255,255,255,.08); }
|
|
1482
|
+
.${DIALOG_CLASS}-browser-empty { margin: 16px 12px; color: rgba(255,255,255,.5); font-size: 13px; }
|
|
1483
|
+
`;
|
|
1484
|
+
if (existing === null) document.head.append(style);
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
// src/client/index.tsx
|
|
1488
|
+
var inject = ["slots", "uiWorkspace", "locale"];
|
|
1489
|
+
function apply(ctx) {
|
|
1490
|
+
const api = createHostsApi(ctx);
|
|
1491
|
+
const locale = ctx.locale;
|
|
1492
|
+
ctx.effect(() => locale.register(NS, { zh, en }), "dsh-remote: locale dictionaries");
|
|
1493
|
+
const t = locale.bind(NS);
|
|
1494
|
+
installNativeWorkspaceRouting(ctx, api);
|
|
1495
|
+
installWorkspaceAddMenu(ctx, api, t);
|
|
1496
|
+
ctx.inject(["remote.workspaceFiles"], (child) => {
|
|
1497
|
+
installRemoteFiles(child, api);
|
|
1498
|
+
});
|
|
1499
|
+
ctx.slots.inject("settings.section", () => ctx.slots.register({
|
|
1500
|
+
name: "settings.section",
|
|
1501
|
+
id: "remote-development",
|
|
1502
|
+
order: 76,
|
|
1503
|
+
label: () => t("settings.title"),
|
|
1504
|
+
locale: NS,
|
|
1505
|
+
inject: () => ({ api })
|
|
1506
|
+
}, RemoteDevelopmentPanel));
|
|
1507
|
+
}
|
|
1508
|
+
return module.exports;
|
|
1509
|
+
},
|
|
1510
|
+
});
|
|
1511
|
+
//# sourceMappingURL=client.js.map
|