dsh-bash-terminal-ts 0.7.1 → 0.7.2-compat.2

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.
@@ -19,18 +19,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/client.tsx
20
20
  var client_exports = {};
21
21
  __export(client_exports, {
22
- apply: () => apply,
23
- inject: () => inject
22
+ apply: () => apply
24
23
  });
25
24
  module.exports = __toCommonJS(client_exports);
26
25
  var import_react = require("react");
27
- var import_dsh_client_store = require("@deepseek-ai/dsh-client-store");
28
- var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
29
26
  var import_jsx_runtime = require("react/jsx-runtime");
30
27
  var SETTINGS_NS = "settings.bash-terminal";
31
- var ENTRY_ID = "tool-bash-terminal";
32
28
  var SHELLS = ["powershell", "gitbash", "msys2", "wsl"];
33
- var ROW_CSS = ".btRow{border-bottom:1px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.btRowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.btTitle{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.btDesc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.btSelector{background:var(--dsw-alias-bg-module-platform);height:36px;font:inherit;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;border-radius:18px;align-items:center;gap:12px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.btSelector:hover{background:var(--dsw-alias-interactive-bg-hover)}.btChevron{flex:none}";
29
+ var ROW_CSS = ".btRow{border-bottom:1px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.btRowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.btTitle{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.btDesc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.btSelector{background:var(--dsw-alias-bg-module-platform);height:36px;font:inherit;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;border-radius:18px;align-items:center;gap:12px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.btSelector:hover{background:var(--dsw-alias-interactive-bg-hover)}.btGear{position:fixed;right:16px;bottom:110px;z-index:10000;width:40px;height:40px;border-radius:50%;border:1px solid rgba(127,127,127,.4);background:rgba(30,30,32,.85);color:inherit;cursor:pointer;font-size:17px;box-shadow:0 4px 16px rgba(0,0,0,.35)}.btOverlay{position:fixed;inset:0;z-index:10000;background:rgba(0,0,0,.45)}.btPanel{position:fixed;top:6vh;left:50%;transform:translateX(-50%);width:min(760px,92vw);max-height:84vh;overflow-y:auto;z-index:10001;background:var(--dsw-alias-bg-module-platform,rgba(30,30,32,.92));border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.3));border-radius:14px;padding:20px;color:var(--dsw-alias-label-primary)}";
34
30
  if (typeof document !== "undefined" && document.querySelector('style[data-plugin-css="bash-terminal-row"]') === null) {
35
31
  const tag = document.createElement("style");
36
32
  tag.dataset.plugin = "dsh-bash-terminal-ts";
@@ -45,7 +41,7 @@ var zh = {
45
41
  "shell.gitbash": "Git Bash",
46
42
  "shell.msys2": "MSYS2",
47
43
  "shell.wsl": "WSL",
48
- "shell.unavailable": "\u8BBE\u7F6E\u9762\u4E0D\u53EF\u7528\uFF1A\u5BBF\u4E3B\u672A\u63D0\u4F9B\u672C\u63D2\u4EF6\u7684 configForms \u6761\u76EE\uFF08\u68C0\u67E5 cordis.patch.yml \u7684 entry id\uFF09"
44
+ "shell.unavailable": "\u8BBE\u7F6E\u9762\u4E0D\u53EF\u7528:\u5BBF\u4E3B\u914D\u7F6E\u6865\u672A\u54CD\u5E94(\u68C0\u67E5\u5BBF\u4E3B\u662F\u5426\u4E3A compat \u7248)"
49
45
  };
50
46
  var en = {
51
47
  "shell.title": "Default terminal",
@@ -54,7 +50,7 @@ var en = {
54
50
  "shell.gitbash": "Git Bash",
55
51
  "shell.msys2": "MSYS2",
56
52
  "shell.wsl": "WSL",
57
- "shell.unavailable": "Settings unavailable: the host exposes no configForms entry for this plugin (check the cordis.patch.yml entry id)"
53
+ "shell.unavailable": "Settings unavailable: the host config bridge did not respond (is the host a compat build?)"
58
54
  };
59
55
  var fr = {
60
56
  "shell.title": "Terminal par d\xE9faut",
@@ -63,134 +59,170 @@ var fr = {
63
59
  "shell.gitbash": "Git Bash",
64
60
  "shell.msys2": "MSYS2",
65
61
  "shell.wsl": "WSL",
66
- "shell.unavailable": "Param\xE8tres indisponibles : l'h\xF4te n'expose aucune entr\xE9e configForms pour ce plugin (v\xE9rifiez l'entry id du cordis.patch.yml)"
62
+ "shell.unavailable": "Param\xE8tres indisponibles: le pont de configuration de l'h\xF4te n'a pas r\xE9pondu"
67
63
  };
68
64
  var de = {
69
- "shell.title": "Standard-Terminal",
70
- "shell.description": "Terminal, das vom Shell-Tool verwendet wird",
65
+ "shell.title": "Standardterminal",
66
+ "shell.description": "Terminal f\xFCr den Shell-Befehl",
71
67
  "shell.powershell": "PowerShell",
72
68
  "shell.gitbash": "Git Bash",
73
69
  "shell.msys2": "MSYS2",
74
70
  "shell.wsl": "WSL",
75
- "shell.unavailable": "Einstellungen nicht verf\xFCgbar: Der Host stellt keinen configForms-Eintrag f\xFCr dieses Plugin bereit (Entry-ID in cordis.patch.yml pr\xFCfen)"
71
+ "shell.unavailable": "Einstellungen nicht verf\xFCgbar: Die Konfigurationsbr\xFCcke des Hosts hat nicht geantwortet"
76
72
  };
77
73
  var it = {
78
74
  "shell.title": "Terminale predefinito",
79
- "shell.description": "Terminale usato dallo strumento shell",
75
+ "shell.description": "Terminale usato dal comando shell",
80
76
  "shell.powershell": "PowerShell",
81
77
  "shell.gitbash": "Git Bash",
82
78
  "shell.msys2": "MSYS2",
83
79
  "shell.wsl": "WSL",
84
- "shell.unavailable": "Impostazioni non disponibili: l'host non espone alcuna voce configForms per questo plugin (verifica l'entry id in cordis.patch.yml)"
80
+ "shell.unavailable": "Impostazioni non disponibili: il bridge di configurazione dell'host non ha risposto"
85
81
  };
86
82
  var ru = {
87
83
  "shell.title": "\u0422\u0435\u0440\u043C\u0438\u043D\u0430\u043B \u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E",
88
- "shell.description": "\u0422\u0435\u0440\u043C\u0438\u043D\u0430\u043B, \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0435\u043C\u044B\u0439 \u0438\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u043E\u043C shell",
84
+ "shell.description": "\u0422\u0435\u0440\u043C\u0438\u043D\u0430\u043B \u0434\u043B\u044F \u043A\u043E\u043C\u0430\u043D\u0434 \u043E\u0431\u043E\u043B\u043E\u0447\u043A\u0438",
89
85
  "shell.powershell": "PowerShell",
90
86
  "shell.gitbash": "Git Bash",
91
87
  "shell.msys2": "MSYS2",
92
88
  "shell.wsl": "WSL",
93
- "shell.unavailable": "\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B: \u0445\u043E\u0441\u0442 \u043D\u0435 \u043F\u0440\u0435\u0434\u043E\u0441\u0442\u0430\u0432\u043B\u044F\u0435\u0442 \u0437\u0430\u043F\u0438\u0441\u044C configForms \u0434\u043B\u044F \u044D\u0442\u043E\u0433\u043E \u043F\u043B\u0430\u0433\u0438\u043D\u0430 (\u043F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435 entry id \u0432 cordis.patch.yml)"
89
+ "shell.unavailable": "\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B: \u043C\u043E\u0441\u0442 \u043A\u043E\u043D\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0445\u043E\u0441\u0442\u0430 \u043D\u0435 \u043E\u0442\u0432\u0435\u0442\u0438\u043B"
94
90
  };
95
91
  var es = {
96
- "shell.title": "Terminal predeterminado",
97
- "shell.description": "Terminal que usa la herramienta shell",
92
+ "shell.title": "Terminal predeterminada",
93
+ "shell.description": "Terminal usada por el comando shell",
98
94
  "shell.powershell": "PowerShell",
99
95
  "shell.gitbash": "Git Bash",
100
96
  "shell.msys2": "MSYS2",
101
97
  "shell.wsl": "WSL",
102
- "shell.unavailable": "Configuraci\xF3n no disponible: el host no expone ninguna entrada configForms para este plugin (comprueba el entry id de cordis.patch.yml)"
98
+ "shell.unavailable": "Configuraci\xF3n no disponible: el puente de configuraci\xF3n del host no respondi\xF3"
103
99
  };
104
- var inject = ["slots", "locale", "configForms"];
105
- function ShellPreferenceRow({ t, useStore, setShell }) {
106
- const shell = useStore((s) => s.shell);
107
- const writable = useStore((s) => s.writable);
108
- const status = useStore((s) => s.status);
109
- const [open, setOpen] = (0, import_react.useState)(false);
110
- const items = SHELLS.map((id) => ({ id, label: t("shell." + id) }));
100
+ var zhDictTitle = () => zh["shell.title"] ?? "Terminal";
101
+ async function bridgeConfig() {
102
+ try {
103
+ const r = await fetch("/api/bash-terminal/config", {
104
+ method: "POST",
105
+ headers: { "content-type": "application/json" },
106
+ body: "{}"
107
+ });
108
+ const d = await r.json();
109
+ return d && d.ok ? d.value : null;
110
+ } catch {
111
+ return null;
112
+ }
113
+ }
114
+ async function bridgeWrite(value) {
115
+ try {
116
+ const r = await fetch("/api/bash-terminal/config", {
117
+ method: "POST",
118
+ headers: { "content-type": "application/json" },
119
+ body: JSON.stringify({ defaultShell: value })
120
+ });
121
+ const d = await r.json();
122
+ return !!(d && d.ok);
123
+ } catch {
124
+ return false;
125
+ }
126
+ }
127
+ function ShellPreferenceRow() {
128
+ const [shell, setShell] = (0, import_react.useState)("powershell");
129
+ const [status, setStatus] = (0, import_react.useState)("loading");
130
+ (0, import_react.useEffect)(() => {
131
+ let alive = true;
132
+ bridgeConfig().then((v) => {
133
+ if (!alive) return;
134
+ if (v && v.defaultShell) {
135
+ setShell(v.defaultShell);
136
+ setStatus("ready");
137
+ } else {
138
+ setStatus("unavailable");
139
+ }
140
+ });
141
+ return () => {
142
+ alive = false;
143
+ };
144
+ }, []);
145
+ const change = (value) => {
146
+ setShell(value);
147
+ void bridgeWrite(value);
148
+ };
111
149
  if (status === "unavailable") {
112
150
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btRow", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "btRowText", children: [
113
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btTitle", children: t("shell.title") }),
114
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btDesc", children: t("shell.unavailable") })
151
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btTitle", children: zh["shell.title"] }),
152
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btDesc", children: zh["shell.unavailable"] })
115
153
  ] }) });
116
154
  }
117
155
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "btRow", children: [
118
156
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "btRowText", children: [
119
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btTitle", children: t("shell.title") }),
120
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btDesc", children: t("shell.description") })
157
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btTitle", children: zh["shell.title"] }),
158
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btDesc", children: zh["shell.description"] })
121
159
  ] }),
122
160
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
123
- import_dsh_client_ui_primitives.Menu,
161
+ "select",
124
162
  {
125
- open,
126
- onClose: () => setOpen(false),
127
- items,
128
- selectedId: shell,
129
- onSelect: (id) => {
130
- setOpen(false);
131
- setShell(id);
132
- },
133
- align: "end",
134
- portal: true,
135
- anchor: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
136
- "button",
137
- {
138
- type: "button",
139
- className: "btSelector",
140
- "aria-haspopup": "menu",
141
- "aria-expanded": open,
142
- disabled: !writable,
143
- onClick: () => setOpen(!open),
144
- style: !writable ? { opacity: 0.5, cursor: "not-allowed" } : void 0,
145
- children: [
146
- t("shell." + shell),
147
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconChevronDownOutlineMedium, { className: "btChevron" })
148
- ]
149
- }
150
- )
163
+ className: "btSelector",
164
+ value: shell,
165
+ onChange: (e) => change(e.target.value),
166
+ children: SHELLS.map((id) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: id, children: zh["shell." + id] ?? id }, id))
151
167
  }
152
168
  )
153
169
  ] });
154
170
  }
155
- var zhDictTitle = () => zh["shell.title"] ?? "\u7EC8\u7AEF";
171
+ function SettingsOverlayEntry() {
172
+ const [open, setOpen] = (0, import_react.useState)(false);
173
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { position: "fixed", right: "16px", bottom: "110px", zIndex: 1e4 }, children: [
174
+ open ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btOverlay", onClick: () => setOpen(false) }) : null,
175
+ open ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "btPanel", children: [
176
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
177
+ "button",
178
+ {
179
+ type: "button",
180
+ className: "btSelector",
181
+ style: { float: "right", height: "30px", fontSize: "12px", marginBottom: "8px" },
182
+ onClick: () => setOpen(false),
183
+ children: "\u2715"
184
+ }
185
+ ),
186
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ShellPreferenceRow, {})
187
+ ] }) : null,
188
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "btGear", title: zhDictTitle(), onClick: () => setOpen(!open), children: "\u2699" })
189
+ ] });
190
+ }
156
191
  function apply(ctx) {
157
- ctx.effect(() => ctx.locale.register(SETTINGS_NS, { zh, en, fr, de, it, ru, es }), "bash-terminal: settings dictionaries");
158
- const scope = ctx.configForms.get(ENTRY_ID);
159
- const store = (0, import_dsh_client_store.defineStore)({
160
- init: () => ({ shell: "powershell", revision: -1, writable: false, status: "loading" }),
161
- actions: {
162
- sync: (d, shell, revision, writable, status) => {
163
- if (revision !== void 0 && revision <= d.revision) return;
164
- if (shell !== void 0) d.shell = shell;
165
- if (revision !== void 0) d.revision = revision;
166
- if (writable !== void 0) d.writable = writable;
167
- if (status !== void 0) d.status = status;
168
- }
192
+ const safe = (tag, fn) => {
193
+ try {
194
+ fn();
195
+ } catch (e) {
196
+ console.warn(`[dsh-bash-terminal-ts] client surface '${tag}' failed:`, e);
169
197
  }
170
- });
171
- let bound;
172
- const push = (snap) => {
173
- bound?.sync(snap.value?.defaultShell, snap.revision, snap.writable, snap.status);
174
198
  };
175
- ctx.slots.inject(
176
- "dsh-family.tab",
177
- () => ctx.slots.register(
178
- {
179
- name: "dsh-family.tab",
180
- id: "bash-terminal-shell",
181
- order: 60,
182
- label: () => zhDictTitle(),
183
- store,
184
- locale: SETTINGS_NS,
185
- inject: (actions) => {
186
- bound = actions;
187
- push(scope.getSnapshot());
188
- return { setShell: (value) => void scope.set("defaultShell", value) };
189
- }
190
- },
191
- ShellPreferenceRow
192
- ),
193
- "bash-terminal: settings row"
194
- );
195
- ctx.effect(() => scope.subscribe(() => push(scope.getSnapshot())), "bash-terminal: settings watch");
199
+ safe("locale", () => {
200
+ ctx.effect(
201
+ () => ctx.locale.register(SETTINGS_NS, { zh, en, fr, de, it, ru, es }),
202
+ "bash-terminal: settings dictionaries"
203
+ );
204
+ });
205
+ safe("dsh-family.tab", () => {
206
+ ctx.slots.inject(
207
+ "dsh-family.tab",
208
+ () => ctx.slots.register(
209
+ {
210
+ name: "dsh-family.tab",
211
+ id: "bash-terminal-shell",
212
+ order: 60,
213
+ label: zhDictTitle,
214
+ locale: SETTINGS_NS,
215
+ inject: () => ({})
216
+ },
217
+ () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ShellPreferenceRow, {})
218
+ ),
219
+ "bash-terminal: settings row"
220
+ );
221
+ });
222
+ safe("shell.overlay", () => {
223
+ ctx.slots.inject(
224
+ "shell.overlay",
225
+ () => ctx.slots.register({ name: "shell.overlay", id: "bash-terminal-settings" }, () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SettingsOverlayEntry, {}))
226
+ );
227
+ });
196
228
  }
package/dist/client.js CHANGED
@@ -24,18 +24,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
24
24
  // src/client.tsx
25
25
  var client_exports = {};
26
26
  __export(client_exports, {
27
- apply: () => apply,
28
- inject: () => inject
27
+ apply: () => apply
29
28
  });
30
29
  module.exports = __toCommonJS(client_exports);
31
30
  var import_react = require("react");
32
- var import_dsh_client_store = require("@deepseek-ai/dsh-client-store");
33
- var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
34
31
  var import_jsx_runtime = require("react/jsx-runtime");
35
32
  var SETTINGS_NS = "settings.bash-terminal";
36
- var ENTRY_ID = "tool-bash-terminal";
37
33
  var SHELLS = ["powershell", "gitbash", "msys2", "wsl"];
38
- var ROW_CSS = ".btRow{border-bottom:1px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.btRowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.btTitle{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.btDesc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.btSelector{background:var(--dsw-alias-bg-module-platform);height:36px;font:inherit;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;border-radius:18px;align-items:center;gap:12px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.btSelector:hover{background:var(--dsw-alias-interactive-bg-hover)}.btChevron{flex:none}";
34
+ var ROW_CSS = ".btRow{border-bottom:1px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.btRowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.btTitle{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.btDesc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.btSelector{background:var(--dsw-alias-bg-module-platform);height:36px;font:inherit;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;border-radius:18px;align-items:center;gap:12px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.btSelector:hover{background:var(--dsw-alias-interactive-bg-hover)}.btGear{position:fixed;right:16px;bottom:110px;z-index:10000;width:40px;height:40px;border-radius:50%;border:1px solid rgba(127,127,127,.4);background:rgba(30,30,32,.85);color:inherit;cursor:pointer;font-size:17px;box-shadow:0 4px 16px rgba(0,0,0,.35)}.btOverlay{position:fixed;inset:0;z-index:10000;background:rgba(0,0,0,.45)}.btPanel{position:fixed;top:6vh;left:50%;transform:translateX(-50%);width:min(760px,92vw);max-height:84vh;overflow-y:auto;z-index:10001;background:var(--dsw-alias-bg-module-platform,rgba(30,30,32,.92));border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.3));border-radius:14px;padding:20px;color:var(--dsw-alias-label-primary)}";
39
35
  if (typeof document !== "undefined" && document.querySelector('style[data-plugin-css="bash-terminal-row"]') === null) {
40
36
  const tag = document.createElement("style");
41
37
  tag.dataset.plugin = "dsh-bash-terminal-ts";
@@ -50,7 +46,7 @@ var zh = {
50
46
  "shell.gitbash": "Git Bash",
51
47
  "shell.msys2": "MSYS2",
52
48
  "shell.wsl": "WSL",
53
- "shell.unavailable": "\u8BBE\u7F6E\u9762\u4E0D\u53EF\u7528\uFF1A\u5BBF\u4E3B\u672A\u63D0\u4F9B\u672C\u63D2\u4EF6\u7684 configForms \u6761\u76EE\uFF08\u68C0\u67E5 cordis.patch.yml \u7684 entry id\uFF09"
49
+ "shell.unavailable": "\u8BBE\u7F6E\u9762\u4E0D\u53EF\u7528:\u5BBF\u4E3B\u914D\u7F6E\u6865\u672A\u54CD\u5E94(\u68C0\u67E5\u5BBF\u4E3B\u662F\u5426\u4E3A compat \u7248)"
54
50
  };
55
51
  var en = {
56
52
  "shell.title": "Default terminal",
@@ -59,7 +55,7 @@ var en = {
59
55
  "shell.gitbash": "Git Bash",
60
56
  "shell.msys2": "MSYS2",
61
57
  "shell.wsl": "WSL",
62
- "shell.unavailable": "Settings unavailable: the host exposes no configForms entry for this plugin (check the cordis.patch.yml entry id)"
58
+ "shell.unavailable": "Settings unavailable: the host config bridge did not respond (is the host a compat build?)"
63
59
  };
64
60
  var fr = {
65
61
  "shell.title": "Terminal par d\xE9faut",
@@ -68,136 +64,172 @@ var fr = {
68
64
  "shell.gitbash": "Git Bash",
69
65
  "shell.msys2": "MSYS2",
70
66
  "shell.wsl": "WSL",
71
- "shell.unavailable": "Param\xE8tres indisponibles : l'h\xF4te n'expose aucune entr\xE9e configForms pour ce plugin (v\xE9rifiez l'entry id du cordis.patch.yml)"
67
+ "shell.unavailable": "Param\xE8tres indisponibles: le pont de configuration de l'h\xF4te n'a pas r\xE9pondu"
72
68
  };
73
69
  var de = {
74
- "shell.title": "Standard-Terminal",
75
- "shell.description": "Terminal, das vom Shell-Tool verwendet wird",
70
+ "shell.title": "Standardterminal",
71
+ "shell.description": "Terminal f\xFCr den Shell-Befehl",
76
72
  "shell.powershell": "PowerShell",
77
73
  "shell.gitbash": "Git Bash",
78
74
  "shell.msys2": "MSYS2",
79
75
  "shell.wsl": "WSL",
80
- "shell.unavailable": "Einstellungen nicht verf\xFCgbar: Der Host stellt keinen configForms-Eintrag f\xFCr dieses Plugin bereit (Entry-ID in cordis.patch.yml pr\xFCfen)"
76
+ "shell.unavailable": "Einstellungen nicht verf\xFCgbar: Die Konfigurationsbr\xFCcke des Hosts hat nicht geantwortet"
81
77
  };
82
78
  var it = {
83
79
  "shell.title": "Terminale predefinito",
84
- "shell.description": "Terminale usato dallo strumento shell",
80
+ "shell.description": "Terminale usato dal comando shell",
85
81
  "shell.powershell": "PowerShell",
86
82
  "shell.gitbash": "Git Bash",
87
83
  "shell.msys2": "MSYS2",
88
84
  "shell.wsl": "WSL",
89
- "shell.unavailable": "Impostazioni non disponibili: l'host non espone alcuna voce configForms per questo plugin (verifica l'entry id in cordis.patch.yml)"
85
+ "shell.unavailable": "Impostazioni non disponibili: il bridge di configurazione dell'host non ha risposto"
90
86
  };
91
87
  var ru = {
92
88
  "shell.title": "\u0422\u0435\u0440\u043C\u0438\u043D\u0430\u043B \u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E",
93
- "shell.description": "\u0422\u0435\u0440\u043C\u0438\u043D\u0430\u043B, \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0435\u043C\u044B\u0439 \u0438\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u043E\u043C shell",
89
+ "shell.description": "\u0422\u0435\u0440\u043C\u0438\u043D\u0430\u043B \u0434\u043B\u044F \u043A\u043E\u043C\u0430\u043D\u0434 \u043E\u0431\u043E\u043B\u043E\u0447\u043A\u0438",
94
90
  "shell.powershell": "PowerShell",
95
91
  "shell.gitbash": "Git Bash",
96
92
  "shell.msys2": "MSYS2",
97
93
  "shell.wsl": "WSL",
98
- "shell.unavailable": "\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B: \u0445\u043E\u0441\u0442 \u043D\u0435 \u043F\u0440\u0435\u0434\u043E\u0441\u0442\u0430\u0432\u043B\u044F\u0435\u0442 \u0437\u0430\u043F\u0438\u0441\u044C configForms \u0434\u043B\u044F \u044D\u0442\u043E\u0433\u043E \u043F\u043B\u0430\u0433\u0438\u043D\u0430 (\u043F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435 entry id \u0432 cordis.patch.yml)"
94
+ "shell.unavailable": "\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B: \u043C\u043E\u0441\u0442 \u043A\u043E\u043D\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0445\u043E\u0441\u0442\u0430 \u043D\u0435 \u043E\u0442\u0432\u0435\u0442\u0438\u043B"
99
95
  };
100
96
  var es = {
101
- "shell.title": "Terminal predeterminado",
102
- "shell.description": "Terminal que usa la herramienta shell",
97
+ "shell.title": "Terminal predeterminada",
98
+ "shell.description": "Terminal usada por el comando shell",
103
99
  "shell.powershell": "PowerShell",
104
100
  "shell.gitbash": "Git Bash",
105
101
  "shell.msys2": "MSYS2",
106
102
  "shell.wsl": "WSL",
107
- "shell.unavailable": "Configuraci\xF3n no disponible: el host no expone ninguna entrada configForms para este plugin (comprueba el entry id de cordis.patch.yml)"
103
+ "shell.unavailable": "Configuraci\xF3n no disponible: el puente de configuraci\xF3n del host no respondi\xF3"
108
104
  };
109
- var inject = ["slots", "locale", "configForms"];
110
- function ShellPreferenceRow({ t, useStore, setShell }) {
111
- const shell = useStore((s) => s.shell);
112
- const writable = useStore((s) => s.writable);
113
- const status = useStore((s) => s.status);
114
- const [open, setOpen] = (0, import_react.useState)(false);
115
- const items = SHELLS.map((id) => ({ id, label: t("shell." + id) }));
105
+ var zhDictTitle = () => zh["shell.title"] ?? "Terminal";
106
+ async function bridgeConfig() {
107
+ try {
108
+ const r = await fetch("/api/bash-terminal/config", {
109
+ method: "POST",
110
+ headers: { "content-type": "application/json" },
111
+ body: "{}"
112
+ });
113
+ const d = await r.json();
114
+ return d && d.ok ? d.value : null;
115
+ } catch {
116
+ return null;
117
+ }
118
+ }
119
+ async function bridgeWrite(value) {
120
+ try {
121
+ const r = await fetch("/api/bash-terminal/config", {
122
+ method: "POST",
123
+ headers: { "content-type": "application/json" },
124
+ body: JSON.stringify({ defaultShell: value })
125
+ });
126
+ const d = await r.json();
127
+ return !!(d && d.ok);
128
+ } catch {
129
+ return false;
130
+ }
131
+ }
132
+ function ShellPreferenceRow() {
133
+ const [shell, setShell] = (0, import_react.useState)("powershell");
134
+ const [status, setStatus] = (0, import_react.useState)("loading");
135
+ (0, import_react.useEffect)(() => {
136
+ let alive = true;
137
+ bridgeConfig().then((v) => {
138
+ if (!alive) return;
139
+ if (v && v.defaultShell) {
140
+ setShell(v.defaultShell);
141
+ setStatus("ready");
142
+ } else {
143
+ setStatus("unavailable");
144
+ }
145
+ });
146
+ return () => {
147
+ alive = false;
148
+ };
149
+ }, []);
150
+ const change = (value) => {
151
+ setShell(value);
152
+ void bridgeWrite(value);
153
+ };
116
154
  if (status === "unavailable") {
117
155
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btRow", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "btRowText", children: [
118
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btTitle", children: t("shell.title") }),
119
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btDesc", children: t("shell.unavailable") })
156
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btTitle", children: zh["shell.title"] }),
157
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btDesc", children: zh["shell.unavailable"] })
120
158
  ] }) });
121
159
  }
122
160
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "btRow", children: [
123
161
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "btRowText", children: [
124
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btTitle", children: t("shell.title") }),
125
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btDesc", children: t("shell.description") })
162
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btTitle", children: zh["shell.title"] }),
163
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btDesc", children: zh["shell.description"] })
126
164
  ] }),
127
165
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
128
- import_dsh_client_ui_primitives.Menu,
166
+ "select",
129
167
  {
130
- open,
131
- onClose: () => setOpen(false),
132
- items,
133
- selectedId: shell,
134
- onSelect: (id) => {
135
- setOpen(false);
136
- setShell(id);
137
- },
138
- align: "end",
139
- portal: true,
140
- anchor: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
141
- "button",
142
- {
143
- type: "button",
144
- className: "btSelector",
145
- "aria-haspopup": "menu",
146
- "aria-expanded": open,
147
- disabled: !writable,
148
- onClick: () => setOpen(!open),
149
- style: !writable ? { opacity: 0.5, cursor: "not-allowed" } : void 0,
150
- children: [
151
- t("shell." + shell),
152
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconChevronDownOutlineMedium, { className: "btChevron" })
153
- ]
154
- }
155
- )
168
+ className: "btSelector",
169
+ value: shell,
170
+ onChange: (e) => change(e.target.value),
171
+ children: SHELLS.map((id) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: id, children: zh["shell." + id] ?? id }, id))
156
172
  }
157
173
  )
158
174
  ] });
159
175
  }
160
- var zhDictTitle = () => zh["shell.title"] ?? "\u7EC8\u7AEF";
176
+ function SettingsOverlayEntry() {
177
+ const [open, setOpen] = (0, import_react.useState)(false);
178
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { position: "fixed", right: "16px", bottom: "110px", zIndex: 1e4 }, children: [
179
+ open ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btOverlay", onClick: () => setOpen(false) }) : null,
180
+ open ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "btPanel", children: [
181
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
182
+ "button",
183
+ {
184
+ type: "button",
185
+ className: "btSelector",
186
+ style: { float: "right", height: "30px", fontSize: "12px", marginBottom: "8px" },
187
+ onClick: () => setOpen(false),
188
+ children: "\u2715"
189
+ }
190
+ ),
191
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ShellPreferenceRow, {})
192
+ ] }) : null,
193
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "btGear", title: zhDictTitle(), onClick: () => setOpen(!open), children: "\u2699" })
194
+ ] });
195
+ }
161
196
  function apply(ctx) {
162
- ctx.effect(() => ctx.locale.register(SETTINGS_NS, { zh, en, fr, de, it, ru, es }), "bash-terminal: settings dictionaries");
163
- const scope = ctx.configForms.get(ENTRY_ID);
164
- const store = (0, import_dsh_client_store.defineStore)({
165
- init: () => ({ shell: "powershell", revision: -1, writable: false, status: "loading" }),
166
- actions: {
167
- sync: (d, shell, revision, writable, status) => {
168
- if (revision !== void 0 && revision <= d.revision) return;
169
- if (shell !== void 0) d.shell = shell;
170
- if (revision !== void 0) d.revision = revision;
171
- if (writable !== void 0) d.writable = writable;
172
- if (status !== void 0) d.status = status;
173
- }
197
+ const safe = (tag, fn) => {
198
+ try {
199
+ fn();
200
+ } catch (e) {
201
+ console.warn(`[dsh-bash-terminal-ts] client surface '${tag}' failed:`, e);
174
202
  }
175
- });
176
- let bound;
177
- const push = (snap) => {
178
- bound?.sync(snap.value?.defaultShell, snap.revision, snap.writable, snap.status);
179
203
  };
180
- ctx.slots.inject(
181
- "dsh-family.tab",
182
- () => ctx.slots.register(
183
- {
184
- name: "dsh-family.tab",
185
- id: "bash-terminal-shell",
186
- order: 60,
187
- label: () => zhDictTitle(),
188
- store,
189
- locale: SETTINGS_NS,
190
- inject: (actions) => {
191
- bound = actions;
192
- push(scope.getSnapshot());
193
- return { setShell: (value) => void scope.set("defaultShell", value) };
194
- }
195
- },
196
- ShellPreferenceRow
197
- ),
198
- "bash-terminal: settings row"
199
- );
200
- ctx.effect(() => scope.subscribe(() => push(scope.getSnapshot())), "bash-terminal: settings watch");
204
+ safe("locale", () => {
205
+ ctx.effect(
206
+ () => ctx.locale.register(SETTINGS_NS, { zh, en, fr, de, it, ru, es }),
207
+ "bash-terminal: settings dictionaries"
208
+ );
209
+ });
210
+ safe("dsh-family.tab", () => {
211
+ ctx.slots.inject(
212
+ "dsh-family.tab",
213
+ () => ctx.slots.register(
214
+ {
215
+ name: "dsh-family.tab",
216
+ id: "bash-terminal-shell",
217
+ order: 60,
218
+ label: zhDictTitle,
219
+ locale: SETTINGS_NS,
220
+ inject: () => ({})
221
+ },
222
+ () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ShellPreferenceRow, {})
223
+ ),
224
+ "bash-terminal: settings row"
225
+ );
226
+ });
227
+ safe("shell.overlay", () => {
228
+ ctx.slots.inject(
229
+ "shell.overlay",
230
+ () => ctx.slots.register({ name: "shell.overlay", id: "bash-terminal-settings" }, () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SettingsOverlayEntry, {}))
231
+ );
232
+ });
201
233
  }
202
234
 
203
235
  return module.exports;