dsh-bash-terminal-ts 0.9.8 → 0.10.0-rc.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.
@@ -6182,6 +6182,8 @@ var zh = {
6182
6182
  "tab.title": "\u7EC8\u7AEF\uFF08\u591A shell\uFF09",
6183
6183
  "tab.description": "\u5728\u672C\u63D2\u4EF6\u7684 PTY \u540E\u7AEF\u4E0A\u6253\u5F00 Git Bash / MSYS2 / WSL / PowerShell\uFF0C\u4E0E\u5B98\u65B9\u7EC8\u7AEF\u5E76\u5B58",
6184
6184
  "tab.new": "\u65B0\u5EFA",
6185
+ "tab.limit": "\u5DF2\u8FBE\u7EC8\u7AEF\u914D\u989D\u4E0A\u9650\uFF086 \u4E2A\uFF09",
6186
+ "tab.closeSlot": "\u5173\u95ED\u6B64\u7EC8\u7AEF",
6185
6187
  "tab.noShell": "\u65E0\u53EF\u7528 shell\uFF08\u8BF7\u5728\u8BBE\u7F6E\u91CC\u6FC0\u6D3B\uFF09",
6186
6188
  "tab.phase.allocating": "\u6B63\u5728\u5206\u914D",
6187
6189
  "tab.phase.connecting": "\u6B63\u5728\u8FDE\u63A5",
@@ -6233,6 +6235,8 @@ var en = {
6233
6235
  "tab.title": "Terminal (multi-shell)",
6234
6236
  "tab.description": "Opens Git Bash / MSYS2 / WSL / PowerShell over this plugin's PTY backend, alongside the official terminal",
6235
6237
  "tab.new": "New",
6238
+ "tab.limit": "Terminal limit reached (6)",
6239
+ "tab.closeSlot": "Close this terminal",
6236
6240
  "tab.noShell": "No shell available (enable one in settings)",
6237
6241
  "tab.phase.allocating": "allocating",
6238
6242
  "tab.phase.connecting": "connecting",
@@ -6284,6 +6288,8 @@ var ja = {
6284
6288
  "tab.title": "\u30BF\u30FC\u30DF\u30CA\u30EB\uFF08\u8907\u6570 shell\uFF09",
6285
6289
  "tab.description": "\u672C\u30D7\u30E9\u30B0\u30A4\u30F3\u306E PTY \u30D0\u30C3\u30AF\u30A8\u30F3\u30C9\u3067 Git Bash / MSYS2 / WSL / PowerShell \u3092\u958B\u304D\u307E\u3059\u3002\u516C\u5F0F\u30BF\u30FC\u30DF\u30CA\u30EB\u3068\u4F75\u5B58\u3057\u307E\u3059",
6286
6290
  "tab.new": "\u65B0\u898F",
6291
+ "tab.limit": "\u30BF\u30FC\u30DF\u30CA\u30EB\u4E0A\u9650\uFF086\uFF09\u306B\u5230\u9054",
6292
+ "tab.closeSlot": "\u3053\u306E\u30BF\u30FC\u30DF\u30CA\u30EB\u3092\u9589\u3058\u308B",
6287
6293
  "tab.noShell": "\u5229\u7528\u53EF\u80FD\u306A shell \u304C\u3042\u308A\u307E\u305B\u3093\uFF08\u8A2D\u5B9A\u3067\u6709\u52B9\u5316\uFF09",
6288
6294
  "tab.phase.allocating": "\u5272\u308A\u5F53\u3066\u4E2D",
6289
6295
  "tab.phase.connecting": "\u63A5\u7D9A\u4E2D",
@@ -6335,6 +6341,8 @@ var ko = {
6335
6341
  "tab.title": "\uD130\uBBF8\uB110(\uB2E4\uC911 shell)",
6336
6342
  "tab.description": "\uC774 \uD50C\uB7EC\uADF8\uC778\uC758 PTY \uBC31\uC5D4\uB4DC\uB85C Git Bash / MSYS2 / WSL / PowerShell \uC744 \uC5FD\uB2C8\uB2E4. \uACF5\uC2DD \uD130\uBBF8\uB110\uACFC \uD568\uAED8 \uC874\uC7AC\uD569\uB2C8\uB2E4",
6337
6343
  "tab.new": "\uC0C8\uB85C \uB9CC\uB4E4\uAE30",
6344
+ "tab.limit": "\uD130\uBBF8\uB110 \uD55C\uB3C4(6) \uB3C4\uB2EC",
6345
+ "tab.closeSlot": "\uC774 \uD130\uBBF8\uB110 \uB2EB\uAE30",
6338
6346
  "tab.noShell": "\uC0AC\uC6A9 \uAC00\uB2A5\uD55C shell \uC5C6\uC74C(\uC124\uC815\uC5D0\uC11C \uD65C\uC131\uD654)",
6339
6347
  "tab.phase.allocating": "\uD560\uB2F9 \uC911",
6340
6348
  "tab.phase.connecting": "\uC5F0\uACB0 \uC911",
@@ -6386,6 +6394,8 @@ var fr = {
6386
6394
  "tab.title": "Terminal (multi-shell)",
6387
6395
  "tab.description": "Ouvre Git Bash / MSYS2 / WSL / PowerShell sur le backend PTY de ce plugin, \xE0 c\xF4t\xE9 du terminal officiel",
6388
6396
  "tab.new": "Nouveau",
6397
+ "tab.limit": "Limite de terminaux atteinte (6)",
6398
+ "tab.closeSlot": "Fermer ce terminal",
6389
6399
  "tab.noShell": "Aucun shell disponible (activez-en un dans les param\xE8tres)",
6390
6400
  "tab.phase.allocating": "allocation",
6391
6401
  "tab.phase.connecting": "connexion",
@@ -6437,6 +6447,8 @@ var de = {
6437
6447
  "tab.title": "Terminal (mehrere Shells)",
6438
6448
  "tab.description": "\xD6ffnet Git Bash / MSYS2 / WSL / PowerShell \xFCber das PTY-Backend dieses Plugins, neben dem offiziellen Terminal",
6439
6449
  "tab.new": "Neu",
6450
+ "tab.limit": "Terminallimit erreicht (6)",
6451
+ "tab.closeSlot": "Dieses Terminal schlie\xDFen",
6440
6452
  "tab.noShell": "Kein Shell verf\xFCgbar (bitte in den Einstellungen aktivieren)",
6441
6453
  "tab.phase.allocating": "Zuteilung",
6442
6454
  "tab.phase.connecting": "Verbindung",
@@ -6488,6 +6500,8 @@ var it = {
6488
6500
  "tab.title": "Terminale (pi\xF9 shell)",
6489
6501
  "tab.description": "Apre Git Bash / MSYS2 / WSL / PowerShell sul backend PTY di questo plugin, accanto al terminale ufficiale",
6490
6502
  "tab.new": "Nuovo",
6503
+ "tab.limit": "Limite terminali raggiunto (6)",
6504
+ "tab.closeSlot": "Chiudi questo terminale",
6491
6505
  "tab.noShell": "Nessuna shell disponibile (attivarne una nelle impostazioni)",
6492
6506
  "tab.phase.allocating": "allocazione",
6493
6507
  "tab.phase.connecting": "connessione",
@@ -6539,6 +6553,8 @@ var ru = {
6539
6553
  "tab.title": "\u0422\u0435\u0440\u043C\u0438\u043D\u0430\u043B (\u043D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u043E \u043E\u0431\u043E\u043B\u043E\u0447\u0435\u043A)",
6540
6554
  "tab.description": "\u041E\u0442\u043A\u0440\u044B\u0432\u0430\u0435\u0442 Git Bash / MSYS2 / WSL / PowerShell \u043F\u043E\u0432\u0435\u0440\u0445 PTY-\u0431\u044D\u043A\u0435\u043D\u0434\u0430 \u044D\u0442\u043E\u0433\u043E \u043F\u043B\u0430\u0433\u0438\u043D\u0430, \u0440\u044F\u0434\u043E\u043C \u0441 \u043E\u0444\u0438\u0446\u0438\u0430\u043B\u044C\u043D\u044B\u043C \u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B\u043E\u043C",
6541
6555
  "tab.new": "\u0421\u043E\u0437\u0434\u0430\u0442\u044C",
6556
+ "tab.limit": "\u041B\u0438\u043C\u0438\u0442 \u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B\u043E\u0432 \u0434\u043E\u0441\u0442\u0438\u0433\u043D\u0443\u0442 (6)",
6557
+ "tab.closeSlot": "\u0417\u0430\u043A\u0440\u044B\u0442\u044C \u044D\u0442\u043E\u0442 \u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B",
6542
6558
  "tab.noShell": "\u041D\u0435\u0442 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E\u0439 \u043E\u0431\u043E\u043B\u043E\u0447\u043A\u0438 (\u0432\u043A\u043B\u044E\u0447\u0438\u0442\u0435 \u0432 \u043D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0430\u0445)",
6543
6559
  "tab.phase.allocating": "\u0432\u044B\u0434\u0435\u043B\u0435\u043D\u0438\u0435",
6544
6560
  "tab.phase.connecting": "\u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0435",
@@ -6590,6 +6606,8 @@ var es = {
6590
6606
  "tab.title": "Terminal (multi-shell)",
6591
6607
  "tab.description": "Abre Git Bash / MSYS2 / WSL / PowerShell sobre el backend PTY de este plugin, junto al terminal oficial",
6592
6608
  "tab.new": "Nuevo",
6609
+ "tab.limit": "L\xEDmite de terminales alcanzado (6)",
6610
+ "tab.closeSlot": "Cerrar este terminal",
6593
6611
  "tab.noShell": "Ninguna shell disponible (activa una en ajustes)",
6594
6612
  "tab.phase.allocating": "asignando",
6595
6613
  "tab.phase.connecting": "conectando",
@@ -6641,6 +6659,8 @@ var pt = {
6641
6659
  "tab.title": "Terminal (multi-shell)",
6642
6660
  "tab.description": "Abre Git Bash / MSYS2 / WSL / PowerShell sobre o backend PTY deste plugin, ao lado do terminal oficial",
6643
6661
  "tab.new": "Novo",
6662
+ "tab.limit": "Limite de terminais atingido (6)",
6663
+ "tab.closeSlot": "Fechar este terminal",
6644
6664
  "tab.noShell": "Nenhuma shell dispon\xEDvel (ative uma nos ajustes)",
6645
6665
  "tab.phase.allocating": "alocando",
6646
6666
  "tab.phase.connecting": "conectando",
@@ -7678,6 +7698,7 @@ function ShellPicker(props) {
7678
7698
 
7679
7699
  // src/webterminals/browser/tab.tsx
7680
7700
  var import_jsx_runtime2 = require("react/jsx-runtime");
7701
+ var MAX_SLOTS = 6;
7681
7702
  var PHASE_KEYS = {
7682
7703
  allocating: "tab.phase.allocating",
7683
7704
  connecting: "tab.phase.connecting",
@@ -7687,20 +7708,20 @@ var PHASE_KEYS = {
7687
7708
  };
7688
7709
  function MultiShellTerminal(props) {
7689
7710
  const sessionId = props.scope?.sessionId;
7690
- const hostRef = (0, import_react2.useRef)(null);
7691
- const controllerRef = (0, import_react2.useRef)(null);
7711
+ const [slots, setSlots] = (0, import_react2.useState)([]);
7712
+ const [activeIdx, setActiveIdx] = (0, import_react2.useState)(0);
7692
7713
  const [rows, setRows] = (0, import_react2.useState)([]);
7693
7714
  const [shell, setShell] = (0, import_react2.useState)("");
7694
- const [phase, setPhase] = (0, import_react2.useState)("allocating");
7695
- const [detail, setDetail] = (0, import_react2.useState)("");
7696
- const [title, setTitle] = (0, import_react2.useState)("");
7697
- const [generation, setGeneration] = (0, import_react2.useState)(0);
7715
+ const hostRefs = (0, import_react2.useRef)(/* @__PURE__ */ new Map());
7716
+ const creatingRef = (0, import_react2.useRef)(false);
7698
7717
  const reload = (0, import_react2.useCallback)(() => {
7699
7718
  readConfig().then(
7700
7719
  (snapshot) => {
7701
7720
  const pickable = pickableRows(snapshot);
7702
7721
  setRows(pickable);
7703
- setShell((current2) => pickable.some((row) => row.id === current2) ? current2 : pickable[0]?.id ?? "");
7722
+ setShell(
7723
+ (current2) => pickable.some((row) => row.id === current2) ? current2 : pickable[0]?.id ?? ""
7724
+ );
7704
7725
  },
7705
7726
  () => {
7706
7727
  }
@@ -7710,39 +7731,125 @@ function MultiShellTerminal(props) {
7710
7731
  reload();
7711
7732
  }, [reload]);
7712
7733
  (0, import_react2.useEffect)(() => {
7713
- const host = hostRef.current;
7714
- if (host === null || sessionId === void 0 || shell === "") return;
7715
- let cancelled = false;
7716
- void EmbeddedTerminal.create(host, sessionId, shell, {
7734
+ if (sessionId === void 0 || shell === "" || slots.length > 0 || creatingRef.current) return;
7735
+ void createSlot(shell);
7736
+ }, [sessionId, shell]);
7737
+ async function createSlot(shellId) {
7738
+ if (sessionId === void 0 || creatingRef.current) return;
7739
+ creatingRef.current = true;
7740
+ const slotKey = `slot-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
7741
+ const newSlot = {
7742
+ slotKey,
7743
+ terminalId: "",
7744
+ shell: shellId,
7745
+ phase: "allocating",
7746
+ detail: "",
7747
+ title: "",
7748
+ controller: null
7749
+ };
7750
+ setSlots((prev) => [...prev, newSlot]);
7751
+ setActiveIdx(slots.length);
7752
+ await new Promise((r) => {
7753
+ requestAnimationFrame(() => r());
7754
+ });
7755
+ const host = hostRefs.current.get(slotKey);
7756
+ if (host === null || host === void 0) {
7757
+ creatingRef.current = false;
7758
+ setSlots((prev) => prev.filter((s) => s.slotKey !== slotKey));
7759
+ return;
7760
+ }
7761
+ const result = await EmbeddedTerminal.create(host, sessionId, shellId, {
7717
7762
  onPhase: (next, reason) => {
7718
- if (cancelled) return;
7719
- setPhase(next);
7720
- setDetail(reason ?? "");
7763
+ setSlots((prev) => prev.map(
7764
+ (s) => s.slotKey === slotKey ? { ...s, phase: next, detail: reason ?? "" } : s
7765
+ ));
7721
7766
  },
7722
7767
  onTitle: (text) => {
7723
- if (!cancelled) setTitle(text);
7724
- }
7725
- }).then((result) => {
7726
- if (result instanceof EmbeddedTerminal) {
7727
- if (cancelled) {
7728
- result.dispose();
7729
- return;
7730
- }
7731
- controllerRef.current = result;
7732
- return;
7733
- }
7734
- if (!cancelled) {
7735
- setPhase("failed");
7736
- setDetail(result.message);
7768
+ setSlots((prev) => prev.map(
7769
+ (s) => s.slotKey === slotKey ? { ...s, title: text } : s
7770
+ ));
7737
7771
  }
7738
7772
  });
7773
+ if (result instanceof EmbeddedTerminal) {
7774
+ setSlots((prev) => prev.map(
7775
+ (s) => s.slotKey === slotKey ? { ...s, terminalId: result.id, controller: result } : s
7776
+ ));
7777
+ } else {
7778
+ setSlots((prev) => prev.filter((s) => s.slotKey !== slotKey));
7779
+ }
7780
+ creatingRef.current = false;
7781
+ }
7782
+ function closeSlot(idx) {
7783
+ const slot = slots[idx];
7784
+ if (slot === void 0) return;
7785
+ slot.controller?.dispose();
7786
+ if (slot.terminalId !== "") {
7787
+ void closeTerminal(slot.terminalId).catch(() => {
7788
+ });
7789
+ }
7790
+ hostRefs.current.delete(slot.slotKey);
7791
+ setSlots((prev) => {
7792
+ const next = prev.filter((_, i) => i !== idx);
7793
+ if (activeIdx >= next.length) setActiveIdx(Math.max(0, next.length - 1));
7794
+ return next;
7795
+ });
7796
+ }
7797
+ (0, import_react2.useEffect)(() => {
7739
7798
  return () => {
7740
- cancelled = true;
7741
- controllerRef.current?.dispose();
7742
- controllerRef.current = null;
7799
+ for (const slot of slots) {
7800
+ slot.controller?.dispose();
7801
+ }
7743
7802
  };
7744
- }, [sessionId, shell, generation]);
7803
+ }, []);
7804
+ const activeSlot = slots[activeIdx];
7745
7805
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0 }, children: [
7806
+ slots.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "btSubTabBar", style: { display: "flex", alignItems: "center", gap: 0, borderBottom: "1px solid var(--dsw-alias-border-l2, #333)", flex: "none" }, children: slots.map((slot, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
7807
+ "div",
7808
+ {
7809
+ className: "btSubTab" + (i === activeIdx ? " btSubTabActive" : ""),
7810
+ style: {
7811
+ display: "flex",
7812
+ alignItems: "center",
7813
+ gap: 4,
7814
+ padding: "4px 10px",
7815
+ cursor: "pointer",
7816
+ fontSize: 12,
7817
+ borderBottom: i === activeIdx ? "2px solid var(--dsw-alias-bg-brand, #4a9eff)" : "2px solid transparent",
7818
+ opacity: i === activeIdx ? 1 : 0.7
7819
+ },
7820
+ onClick: () => setActiveIdx(i),
7821
+ children: [
7822
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
7823
+ "span",
7824
+ {
7825
+ className: "btSubTabDot",
7826
+ "data-phase": slot.phase,
7827
+ style: {
7828
+ width: 6,
7829
+ height: 6,
7830
+ borderRadius: "50%",
7831
+ background: slot.phase === "running" ? "#30d158" : slot.phase === "failed" ? "#ff453a" : "#8e8e93"
7832
+ }
7833
+ }
7834
+ ),
7835
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { maxWidth: 100, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: slot.title || slot.shell }),
7836
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
7837
+ "button",
7838
+ {
7839
+ type: "button",
7840
+ style: { border: "none", background: "none", cursor: "pointer", fontSize: 14, lineHeight: 1, padding: "0 2px", color: "inherit" },
7841
+ title: tr("tab.closeSlot"),
7842
+ onClick: (e) => {
7843
+ e.stopPropagation();
7844
+ closeSlot(i);
7845
+ },
7846
+ children: "\xD7"
7847
+ }
7848
+ )
7849
+ ]
7850
+ },
7851
+ slot.slotKey
7852
+ )) }) : null,
7746
7853
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "6px 10px", flex: "none" }, children: [
7747
7854
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
7748
7855
  ShellPicker,
@@ -7759,21 +7866,34 @@ function MultiShellTerminal(props) {
7759
7866
  type: "button",
7760
7867
  className: "btSelector",
7761
7868
  style: { height: 28, fontSize: 12 },
7762
- disabled: shell === "",
7763
- onClick: () => {
7764
- setGeneration((n) => n + 1);
7765
- reload();
7766
- },
7869
+ disabled: shell === "" || slots.length >= MAX_SLOTS,
7870
+ title: slots.length >= MAX_SLOTS ? tr("tab.limit") : void 0,
7871
+ onClick: () => void createSlot(shell),
7767
7872
  children: tr("tab.new")
7768
7873
  }
7769
7874
  ),
7770
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "btBadge" + (phase === "running" ? " btBadgeOk" : ""), children: [
7771
- tr(PHASE_KEYS[phase]),
7772
- detail === "" ? "" : ` \xB7 ${detail}`
7773
- ] }),
7774
- title === "" ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "btDesc", style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: title })
7875
+ activeSlot !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "btBadge" + (activeSlot.phase === "running" ? " btBadgeOk" : ""), children: [
7876
+ tr(PHASE_KEYS[activeSlot.phase]),
7877
+ activeSlot.detail === "" ? "" : ` \xB7 ${activeSlot.detail}`
7878
+ ] }) : null
7775
7879
  ] }),
7776
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: hostRef, style: { flex: 1, minHeight: 0, padding: "0 10px 10px", outline: "none" } })
7880
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { position: "relative", flex: 1, minHeight: 0 }, children: slots.map((slot, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
7881
+ "div",
7882
+ {
7883
+ ref: (el) => {
7884
+ if (el !== null) hostRefs.current.set(slot.slotKey, el);
7885
+ else hostRefs.current.delete(slot.slotKey);
7886
+ },
7887
+ style: {
7888
+ position: "absolute",
7889
+ inset: 0,
7890
+ padding: "0 10px 10px",
7891
+ outline: "none",
7892
+ display: i === activeIdx ? "block" : "none"
7893
+ }
7894
+ },
7895
+ slot.slotKey
7896
+ )) })
7777
7897
  ] });
7778
7898
  }
7779
7899
 
package/dist/client.js CHANGED
@@ -6187,6 +6187,8 @@ var zh = {
6187
6187
  "tab.title": "\u7EC8\u7AEF\uFF08\u591A shell\uFF09",
6188
6188
  "tab.description": "\u5728\u672C\u63D2\u4EF6\u7684 PTY \u540E\u7AEF\u4E0A\u6253\u5F00 Git Bash / MSYS2 / WSL / PowerShell\uFF0C\u4E0E\u5B98\u65B9\u7EC8\u7AEF\u5E76\u5B58",
6189
6189
  "tab.new": "\u65B0\u5EFA",
6190
+ "tab.limit": "\u5DF2\u8FBE\u7EC8\u7AEF\u914D\u989D\u4E0A\u9650\uFF086 \u4E2A\uFF09",
6191
+ "tab.closeSlot": "\u5173\u95ED\u6B64\u7EC8\u7AEF",
6190
6192
  "tab.noShell": "\u65E0\u53EF\u7528 shell\uFF08\u8BF7\u5728\u8BBE\u7F6E\u91CC\u6FC0\u6D3B\uFF09",
6191
6193
  "tab.phase.allocating": "\u6B63\u5728\u5206\u914D",
6192
6194
  "tab.phase.connecting": "\u6B63\u5728\u8FDE\u63A5",
@@ -6238,6 +6240,8 @@ var en = {
6238
6240
  "tab.title": "Terminal (multi-shell)",
6239
6241
  "tab.description": "Opens Git Bash / MSYS2 / WSL / PowerShell over this plugin's PTY backend, alongside the official terminal",
6240
6242
  "tab.new": "New",
6243
+ "tab.limit": "Terminal limit reached (6)",
6244
+ "tab.closeSlot": "Close this terminal",
6241
6245
  "tab.noShell": "No shell available (enable one in settings)",
6242
6246
  "tab.phase.allocating": "allocating",
6243
6247
  "tab.phase.connecting": "connecting",
@@ -6289,6 +6293,8 @@ var ja = {
6289
6293
  "tab.title": "\u30BF\u30FC\u30DF\u30CA\u30EB\uFF08\u8907\u6570 shell\uFF09",
6290
6294
  "tab.description": "\u672C\u30D7\u30E9\u30B0\u30A4\u30F3\u306E PTY \u30D0\u30C3\u30AF\u30A8\u30F3\u30C9\u3067 Git Bash / MSYS2 / WSL / PowerShell \u3092\u958B\u304D\u307E\u3059\u3002\u516C\u5F0F\u30BF\u30FC\u30DF\u30CA\u30EB\u3068\u4F75\u5B58\u3057\u307E\u3059",
6291
6295
  "tab.new": "\u65B0\u898F",
6296
+ "tab.limit": "\u30BF\u30FC\u30DF\u30CA\u30EB\u4E0A\u9650\uFF086\uFF09\u306B\u5230\u9054",
6297
+ "tab.closeSlot": "\u3053\u306E\u30BF\u30FC\u30DF\u30CA\u30EB\u3092\u9589\u3058\u308B",
6292
6298
  "tab.noShell": "\u5229\u7528\u53EF\u80FD\u306A shell \u304C\u3042\u308A\u307E\u305B\u3093\uFF08\u8A2D\u5B9A\u3067\u6709\u52B9\u5316\uFF09",
6293
6299
  "tab.phase.allocating": "\u5272\u308A\u5F53\u3066\u4E2D",
6294
6300
  "tab.phase.connecting": "\u63A5\u7D9A\u4E2D",
@@ -6340,6 +6346,8 @@ var ko = {
6340
6346
  "tab.title": "\uD130\uBBF8\uB110(\uB2E4\uC911 shell)",
6341
6347
  "tab.description": "\uC774 \uD50C\uB7EC\uADF8\uC778\uC758 PTY \uBC31\uC5D4\uB4DC\uB85C Git Bash / MSYS2 / WSL / PowerShell \uC744 \uC5FD\uB2C8\uB2E4. \uACF5\uC2DD \uD130\uBBF8\uB110\uACFC \uD568\uAED8 \uC874\uC7AC\uD569\uB2C8\uB2E4",
6342
6348
  "tab.new": "\uC0C8\uB85C \uB9CC\uB4E4\uAE30",
6349
+ "tab.limit": "\uD130\uBBF8\uB110 \uD55C\uB3C4(6) \uB3C4\uB2EC",
6350
+ "tab.closeSlot": "\uC774 \uD130\uBBF8\uB110 \uB2EB\uAE30",
6343
6351
  "tab.noShell": "\uC0AC\uC6A9 \uAC00\uB2A5\uD55C shell \uC5C6\uC74C(\uC124\uC815\uC5D0\uC11C \uD65C\uC131\uD654)",
6344
6352
  "tab.phase.allocating": "\uD560\uB2F9 \uC911",
6345
6353
  "tab.phase.connecting": "\uC5F0\uACB0 \uC911",
@@ -6391,6 +6399,8 @@ var fr = {
6391
6399
  "tab.title": "Terminal (multi-shell)",
6392
6400
  "tab.description": "Ouvre Git Bash / MSYS2 / WSL / PowerShell sur le backend PTY de ce plugin, \xE0 c\xF4t\xE9 du terminal officiel",
6393
6401
  "tab.new": "Nouveau",
6402
+ "tab.limit": "Limite de terminaux atteinte (6)",
6403
+ "tab.closeSlot": "Fermer ce terminal",
6394
6404
  "tab.noShell": "Aucun shell disponible (activez-en un dans les param\xE8tres)",
6395
6405
  "tab.phase.allocating": "allocation",
6396
6406
  "tab.phase.connecting": "connexion",
@@ -6442,6 +6452,8 @@ var de = {
6442
6452
  "tab.title": "Terminal (mehrere Shells)",
6443
6453
  "tab.description": "\xD6ffnet Git Bash / MSYS2 / WSL / PowerShell \xFCber das PTY-Backend dieses Plugins, neben dem offiziellen Terminal",
6444
6454
  "tab.new": "Neu",
6455
+ "tab.limit": "Terminallimit erreicht (6)",
6456
+ "tab.closeSlot": "Dieses Terminal schlie\xDFen",
6445
6457
  "tab.noShell": "Kein Shell verf\xFCgbar (bitte in den Einstellungen aktivieren)",
6446
6458
  "tab.phase.allocating": "Zuteilung",
6447
6459
  "tab.phase.connecting": "Verbindung",
@@ -6493,6 +6505,8 @@ var it = {
6493
6505
  "tab.title": "Terminale (pi\xF9 shell)",
6494
6506
  "tab.description": "Apre Git Bash / MSYS2 / WSL / PowerShell sul backend PTY di questo plugin, accanto al terminale ufficiale",
6495
6507
  "tab.new": "Nuovo",
6508
+ "tab.limit": "Limite terminali raggiunto (6)",
6509
+ "tab.closeSlot": "Chiudi questo terminale",
6496
6510
  "tab.noShell": "Nessuna shell disponibile (attivarne una nelle impostazioni)",
6497
6511
  "tab.phase.allocating": "allocazione",
6498
6512
  "tab.phase.connecting": "connessione",
@@ -6544,6 +6558,8 @@ var ru = {
6544
6558
  "tab.title": "\u0422\u0435\u0440\u043C\u0438\u043D\u0430\u043B (\u043D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u043E \u043E\u0431\u043E\u043B\u043E\u0447\u0435\u043A)",
6545
6559
  "tab.description": "\u041E\u0442\u043A\u0440\u044B\u0432\u0430\u0435\u0442 Git Bash / MSYS2 / WSL / PowerShell \u043F\u043E\u0432\u0435\u0440\u0445 PTY-\u0431\u044D\u043A\u0435\u043D\u0434\u0430 \u044D\u0442\u043E\u0433\u043E \u043F\u043B\u0430\u0433\u0438\u043D\u0430, \u0440\u044F\u0434\u043E\u043C \u0441 \u043E\u0444\u0438\u0446\u0438\u0430\u043B\u044C\u043D\u044B\u043C \u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B\u043E\u043C",
6546
6560
  "tab.new": "\u0421\u043E\u0437\u0434\u0430\u0442\u044C",
6561
+ "tab.limit": "\u041B\u0438\u043C\u0438\u0442 \u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B\u043E\u0432 \u0434\u043E\u0441\u0442\u0438\u0433\u043D\u0443\u0442 (6)",
6562
+ "tab.closeSlot": "\u0417\u0430\u043A\u0440\u044B\u0442\u044C \u044D\u0442\u043E\u0442 \u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B",
6547
6563
  "tab.noShell": "\u041D\u0435\u0442 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E\u0439 \u043E\u0431\u043E\u043B\u043E\u0447\u043A\u0438 (\u0432\u043A\u043B\u044E\u0447\u0438\u0442\u0435 \u0432 \u043D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0430\u0445)",
6548
6564
  "tab.phase.allocating": "\u0432\u044B\u0434\u0435\u043B\u0435\u043D\u0438\u0435",
6549
6565
  "tab.phase.connecting": "\u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0435",
@@ -6595,6 +6611,8 @@ var es = {
6595
6611
  "tab.title": "Terminal (multi-shell)",
6596
6612
  "tab.description": "Abre Git Bash / MSYS2 / WSL / PowerShell sobre el backend PTY de este plugin, junto al terminal oficial",
6597
6613
  "tab.new": "Nuevo",
6614
+ "tab.limit": "L\xEDmite de terminales alcanzado (6)",
6615
+ "tab.closeSlot": "Cerrar este terminal",
6598
6616
  "tab.noShell": "Ninguna shell disponible (activa una en ajustes)",
6599
6617
  "tab.phase.allocating": "asignando",
6600
6618
  "tab.phase.connecting": "conectando",
@@ -6646,6 +6664,8 @@ var pt = {
6646
6664
  "tab.title": "Terminal (multi-shell)",
6647
6665
  "tab.description": "Abre Git Bash / MSYS2 / WSL / PowerShell sobre o backend PTY deste plugin, ao lado do terminal oficial",
6648
6666
  "tab.new": "Novo",
6667
+ "tab.limit": "Limite de terminais atingido (6)",
6668
+ "tab.closeSlot": "Fechar este terminal",
6649
6669
  "tab.noShell": "Nenhuma shell dispon\xEDvel (ative uma nos ajustes)",
6650
6670
  "tab.phase.allocating": "alocando",
6651
6671
  "tab.phase.connecting": "conectando",
@@ -7683,6 +7703,7 @@ function ShellPicker(props) {
7683
7703
 
7684
7704
  // src/webterminals/browser/tab.tsx
7685
7705
  var import_jsx_runtime2 = require("react/jsx-runtime");
7706
+ var MAX_SLOTS = 6;
7686
7707
  var PHASE_KEYS = {
7687
7708
  allocating: "tab.phase.allocating",
7688
7709
  connecting: "tab.phase.connecting",
@@ -7692,20 +7713,20 @@ var PHASE_KEYS = {
7692
7713
  };
7693
7714
  function MultiShellTerminal(props) {
7694
7715
  const sessionId = props.scope?.sessionId;
7695
- const hostRef = (0, import_react2.useRef)(null);
7696
- const controllerRef = (0, import_react2.useRef)(null);
7716
+ const [slots, setSlots] = (0, import_react2.useState)([]);
7717
+ const [activeIdx, setActiveIdx] = (0, import_react2.useState)(0);
7697
7718
  const [rows, setRows] = (0, import_react2.useState)([]);
7698
7719
  const [shell, setShell] = (0, import_react2.useState)("");
7699
- const [phase, setPhase] = (0, import_react2.useState)("allocating");
7700
- const [detail, setDetail] = (0, import_react2.useState)("");
7701
- const [title, setTitle] = (0, import_react2.useState)("");
7702
- const [generation, setGeneration] = (0, import_react2.useState)(0);
7720
+ const hostRefs = (0, import_react2.useRef)(/* @__PURE__ */ new Map());
7721
+ const creatingRef = (0, import_react2.useRef)(false);
7703
7722
  const reload = (0, import_react2.useCallback)(() => {
7704
7723
  readConfig().then(
7705
7724
  (snapshot) => {
7706
7725
  const pickable = pickableRows(snapshot);
7707
7726
  setRows(pickable);
7708
- setShell((current2) => pickable.some((row) => row.id === current2) ? current2 : pickable[0]?.id ?? "");
7727
+ setShell(
7728
+ (current2) => pickable.some((row) => row.id === current2) ? current2 : pickable[0]?.id ?? ""
7729
+ );
7709
7730
  },
7710
7731
  () => {
7711
7732
  }
@@ -7715,39 +7736,125 @@ function MultiShellTerminal(props) {
7715
7736
  reload();
7716
7737
  }, [reload]);
7717
7738
  (0, import_react2.useEffect)(() => {
7718
- const host = hostRef.current;
7719
- if (host === null || sessionId === void 0 || shell === "") return;
7720
- let cancelled = false;
7721
- void EmbeddedTerminal.create(host, sessionId, shell, {
7739
+ if (sessionId === void 0 || shell === "" || slots.length > 0 || creatingRef.current) return;
7740
+ void createSlot(shell);
7741
+ }, [sessionId, shell]);
7742
+ async function createSlot(shellId) {
7743
+ if (sessionId === void 0 || creatingRef.current) return;
7744
+ creatingRef.current = true;
7745
+ const slotKey = `slot-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
7746
+ const newSlot = {
7747
+ slotKey,
7748
+ terminalId: "",
7749
+ shell: shellId,
7750
+ phase: "allocating",
7751
+ detail: "",
7752
+ title: "",
7753
+ controller: null
7754
+ };
7755
+ setSlots((prev) => [...prev, newSlot]);
7756
+ setActiveIdx(slots.length);
7757
+ await new Promise((r) => {
7758
+ requestAnimationFrame(() => r());
7759
+ });
7760
+ const host = hostRefs.current.get(slotKey);
7761
+ if (host === null || host === void 0) {
7762
+ creatingRef.current = false;
7763
+ setSlots((prev) => prev.filter((s) => s.slotKey !== slotKey));
7764
+ return;
7765
+ }
7766
+ const result = await EmbeddedTerminal.create(host, sessionId, shellId, {
7722
7767
  onPhase: (next, reason) => {
7723
- if (cancelled) return;
7724
- setPhase(next);
7725
- setDetail(reason ?? "");
7768
+ setSlots((prev) => prev.map(
7769
+ (s) => s.slotKey === slotKey ? { ...s, phase: next, detail: reason ?? "" } : s
7770
+ ));
7726
7771
  },
7727
7772
  onTitle: (text) => {
7728
- if (!cancelled) setTitle(text);
7729
- }
7730
- }).then((result) => {
7731
- if (result instanceof EmbeddedTerminal) {
7732
- if (cancelled) {
7733
- result.dispose();
7734
- return;
7735
- }
7736
- controllerRef.current = result;
7737
- return;
7738
- }
7739
- if (!cancelled) {
7740
- setPhase("failed");
7741
- setDetail(result.message);
7773
+ setSlots((prev) => prev.map(
7774
+ (s) => s.slotKey === slotKey ? { ...s, title: text } : s
7775
+ ));
7742
7776
  }
7743
7777
  });
7778
+ if (result instanceof EmbeddedTerminal) {
7779
+ setSlots((prev) => prev.map(
7780
+ (s) => s.slotKey === slotKey ? { ...s, terminalId: result.id, controller: result } : s
7781
+ ));
7782
+ } else {
7783
+ setSlots((prev) => prev.filter((s) => s.slotKey !== slotKey));
7784
+ }
7785
+ creatingRef.current = false;
7786
+ }
7787
+ function closeSlot(idx) {
7788
+ const slot = slots[idx];
7789
+ if (slot === void 0) return;
7790
+ slot.controller?.dispose();
7791
+ if (slot.terminalId !== "") {
7792
+ void closeTerminal(slot.terminalId).catch(() => {
7793
+ });
7794
+ }
7795
+ hostRefs.current.delete(slot.slotKey);
7796
+ setSlots((prev) => {
7797
+ const next = prev.filter((_, i) => i !== idx);
7798
+ if (activeIdx >= next.length) setActiveIdx(Math.max(0, next.length - 1));
7799
+ return next;
7800
+ });
7801
+ }
7802
+ (0, import_react2.useEffect)(() => {
7744
7803
  return () => {
7745
- cancelled = true;
7746
- controllerRef.current?.dispose();
7747
- controllerRef.current = null;
7804
+ for (const slot of slots) {
7805
+ slot.controller?.dispose();
7806
+ }
7748
7807
  };
7749
- }, [sessionId, shell, generation]);
7808
+ }, []);
7809
+ const activeSlot = slots[activeIdx];
7750
7810
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0 }, children: [
7811
+ slots.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "btSubTabBar", style: { display: "flex", alignItems: "center", gap: 0, borderBottom: "1px solid var(--dsw-alias-border-l2, #333)", flex: "none" }, children: slots.map((slot, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
7812
+ "div",
7813
+ {
7814
+ className: "btSubTab" + (i === activeIdx ? " btSubTabActive" : ""),
7815
+ style: {
7816
+ display: "flex",
7817
+ alignItems: "center",
7818
+ gap: 4,
7819
+ padding: "4px 10px",
7820
+ cursor: "pointer",
7821
+ fontSize: 12,
7822
+ borderBottom: i === activeIdx ? "2px solid var(--dsw-alias-bg-brand, #4a9eff)" : "2px solid transparent",
7823
+ opacity: i === activeIdx ? 1 : 0.7
7824
+ },
7825
+ onClick: () => setActiveIdx(i),
7826
+ children: [
7827
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
7828
+ "span",
7829
+ {
7830
+ className: "btSubTabDot",
7831
+ "data-phase": slot.phase,
7832
+ style: {
7833
+ width: 6,
7834
+ height: 6,
7835
+ borderRadius: "50%",
7836
+ background: slot.phase === "running" ? "#30d158" : slot.phase === "failed" ? "#ff453a" : "#8e8e93"
7837
+ }
7838
+ }
7839
+ ),
7840
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { maxWidth: 100, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: slot.title || slot.shell }),
7841
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
7842
+ "button",
7843
+ {
7844
+ type: "button",
7845
+ style: { border: "none", background: "none", cursor: "pointer", fontSize: 14, lineHeight: 1, padding: "0 2px", color: "inherit" },
7846
+ title: tr("tab.closeSlot"),
7847
+ onClick: (e) => {
7848
+ e.stopPropagation();
7849
+ closeSlot(i);
7850
+ },
7851
+ children: "\xD7"
7852
+ }
7853
+ )
7854
+ ]
7855
+ },
7856
+ slot.slotKey
7857
+ )) }) : null,
7751
7858
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "6px 10px", flex: "none" }, children: [
7752
7859
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
7753
7860
  ShellPicker,
@@ -7764,21 +7871,34 @@ function MultiShellTerminal(props) {
7764
7871
  type: "button",
7765
7872
  className: "btSelector",
7766
7873
  style: { height: 28, fontSize: 12 },
7767
- disabled: shell === "",
7768
- onClick: () => {
7769
- setGeneration((n) => n + 1);
7770
- reload();
7771
- },
7874
+ disabled: shell === "" || slots.length >= MAX_SLOTS,
7875
+ title: slots.length >= MAX_SLOTS ? tr("tab.limit") : void 0,
7876
+ onClick: () => void createSlot(shell),
7772
7877
  children: tr("tab.new")
7773
7878
  }
7774
7879
  ),
7775
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "btBadge" + (phase === "running" ? " btBadgeOk" : ""), children: [
7776
- tr(PHASE_KEYS[phase]),
7777
- detail === "" ? "" : ` \xB7 ${detail}`
7778
- ] }),
7779
- title === "" ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "btDesc", style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: title })
7880
+ activeSlot !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "btBadge" + (activeSlot.phase === "running" ? " btBadgeOk" : ""), children: [
7881
+ tr(PHASE_KEYS[activeSlot.phase]),
7882
+ activeSlot.detail === "" ? "" : ` \xB7 ${activeSlot.detail}`
7883
+ ] }) : null
7780
7884
  ] }),
7781
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: hostRef, style: { flex: 1, minHeight: 0, padding: "0 10px 10px", outline: "none" } })
7885
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { position: "relative", flex: 1, minHeight: 0 }, children: slots.map((slot, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
7886
+ "div",
7887
+ {
7888
+ ref: (el) => {
7889
+ if (el !== null) hostRefs.current.set(slot.slotKey, el);
7890
+ else hostRefs.current.delete(slot.slotKey);
7891
+ },
7892
+ style: {
7893
+ position: "absolute",
7894
+ inset: 0,
7895
+ padding: "0 10px 10px",
7896
+ outline: "none",
7897
+ display: i === activeIdx ? "block" : "none"
7898
+ }
7899
+ },
7900
+ slot.slotKey
7901
+ )) })
7782
7902
  ] });
7783
7903
  }
7784
7904
 
package/dsh.plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "dsh-bash-terminal-ts",
3
3
  "name": "dsh-bash-terminal-ts",
4
- "version": "0.9.8",
4
+ "version": "0.10.0-rc.2",
5
5
  "description": {
6
6
  "en": "One shell tool that runs commands through PowerShell, Git Bash, MSYS2, WSL or Niubash on Windows, plus an embedded terminal for the bottom dock with per-shell activation switches and a default-shell fallback chain.",
7
7
  "zh": "一个 shell 工具,可在 Windows 上通过 PowerShell / Git Bash / MSYS2 / WSL / Niubash 执行命令;另提供底部工作台的内嵌终端,支持按 shell 激活开关与默认 shell 回落链。",