dsh-vscode-workbench 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +3 -1
- package/README.md +3 -1
- package/lib/client.js +68 -28
- package/lib/client.js.map +1 -1
- package/lib/types/client/Workbench.d.ts +9 -3
- package/lib/types/client/shortcuts.d.ts +3 -0
- package/package.json +1 -1
- package/src/client/Workbench.tsx +34 -17
- package/src/client/index.tsx +2 -0
- package/src/client/shortcuts.ts +17 -0
package/README.en.md
CHANGED
|
@@ -48,8 +48,10 @@ dsh plugin --profile web add dsh-vscode-workbench
|
|
|
48
48
|
| `Ctrl+Shift+G` | Open Source Control |
|
|
49
49
|
| `Ctrl+S` | Save the active file |
|
|
50
50
|
| `Ctrl+Alt+B` | Toggle the DSH conversation panel |
|
|
51
|
+
| `Ctrl+\`` | Toggle the registered terminal panel |
|
|
52
|
+
| `Ctrl+Shift+\`` | Create a terminal and show its panel |
|
|
51
53
|
|
|
52
|
-
|
|
54
|
+
The terminal remains an independent plugin. This workbench only owns the shortcuts and invokes it through `registerBottomPanel()` and the `terminal.new` command.
|
|
53
55
|
|
|
54
56
|
|
|
55
57
|
## Security
|
package/README.md
CHANGED
|
@@ -46,8 +46,10 @@ dsh plugin --profile web add dsh-vscode-workbench
|
|
|
46
46
|
| `Ctrl+Shift+G` | 打开源代码管理 |
|
|
47
47
|
| `Ctrl+S` | 保存当前文件 |
|
|
48
48
|
| `Ctrl+Alt+B` | 显示或隐藏 DSH 对话栏 |
|
|
49
|
+
| `Ctrl+\`` | 显示或隐藏已注册的终端面板 |
|
|
50
|
+
| `Ctrl+Shift+\`` | 新建终端并显示终端面板 |
|
|
49
51
|
|
|
50
|
-
|
|
52
|
+
终端仍由独立插件提供;本工作台只注册快捷键,并通过 `registerBottomPanel()` 和 `terminal.new` 命令调用它。
|
|
51
53
|
|
|
52
54
|
|
|
53
55
|
## 安全
|
package/lib/client.js
CHANGED
|
@@ -4794,20 +4794,33 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
4794
4794
|
}
|
|
4795
4795
|
function graphRows(commits) {
|
|
4796
4796
|
const visible = new Set(commits.map((commit) => commit.hash));
|
|
4797
|
-
let
|
|
4797
|
+
let nextColor = 0;
|
|
4798
|
+
let lanes = commits[0] ? [{
|
|
4799
|
+
hash: commits[0].hash,
|
|
4800
|
+
color: nextColor++
|
|
4801
|
+
}] : [];
|
|
4798
4802
|
return commits.map((commit) => {
|
|
4799
|
-
let lane = lanes.
|
|
4803
|
+
let lane = lanes.findIndex((track) => track.hash === commit.hash);
|
|
4800
4804
|
if (lane < 0) {
|
|
4801
|
-
lanes = [
|
|
4805
|
+
lanes = [{
|
|
4806
|
+
hash: commit.hash,
|
|
4807
|
+
color: nextColor++
|
|
4808
|
+
}, ...lanes];
|
|
4802
4809
|
lane = 0;
|
|
4803
4810
|
}
|
|
4804
4811
|
const before = [...lanes];
|
|
4805
|
-
const
|
|
4812
|
+
const current = before[lane];
|
|
4813
|
+
const after = before.filter((track) => track.hash !== commit.hash);
|
|
4806
4814
|
const parents = commit.parents.filter((parent) => visible.has(parent));
|
|
4807
4815
|
parents.forEach((parent, index) => {
|
|
4808
|
-
if (
|
|
4816
|
+
if (after.some((track) => track.hash === parent)) return;
|
|
4817
|
+
const color = index === 0 ? current.color : nextColor++;
|
|
4818
|
+
after.splice(Math.min(lane + index, after.length), 0, {
|
|
4819
|
+
hash: parent,
|
|
4820
|
+
color
|
|
4821
|
+
});
|
|
4809
4822
|
});
|
|
4810
|
-
const parentLanes = parents.map((parent) => after.
|
|
4823
|
+
const parentLanes = parents.map((parent) => after.findIndex((track) => track.hash === parent)).filter((index) => index >= 0);
|
|
4811
4824
|
lanes = after;
|
|
4812
4825
|
return {
|
|
4813
4826
|
commit,
|
|
@@ -4825,15 +4838,23 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
4825
4838
|
"#d9a441",
|
|
4826
4839
|
"#9b7bea"
|
|
4827
4840
|
];
|
|
4828
|
-
function graphColor(
|
|
4829
|
-
return GRAPH_COLORS[
|
|
4841
|
+
function graphColor(color) {
|
|
4842
|
+
return GRAPH_COLORS[color % GRAPH_COLORS.length];
|
|
4830
4843
|
}
|
|
4831
4844
|
function graphWidth(row) {
|
|
4832
4845
|
return Math.max(row.before.length, row.after.length, row.lane + 1, 1) * 14 + 8;
|
|
4833
4846
|
}
|
|
4847
|
+
/** Draw a fixed-radius, orthogonal transition between two graph lanes. */
|
|
4848
|
+
function graphTrackPath(from, to, startY, endY, bendY) {
|
|
4849
|
+
if (from === to) return `M ${from} ${startY} V ${endY}`;
|
|
4850
|
+
const direction = Math.sign(to - from);
|
|
4851
|
+
const radius = Math.min(5, Math.abs(to - from) / 2, Math.abs(bendY - startY), Math.abs(endY - bendY));
|
|
4852
|
+
return `M ${from} ${startY} V ${bendY - radius} Q ${from} ${bendY} ${from + direction * radius} ${bendY} H ${to - direction * radius} Q ${to} ${bendY} ${to} ${bendY + radius} V ${endY}`;
|
|
4853
|
+
}
|
|
4834
4854
|
function GraphTracks({ row }) {
|
|
4835
4855
|
const width = graphWidth(row);
|
|
4836
4856
|
const x = row.lane * 14 + 8;
|
|
4857
|
+
const current = row.before[row.lane];
|
|
4837
4858
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
4838
4859
|
className: "dvw-graph-svg",
|
|
4839
4860
|
width,
|
|
@@ -4841,41 +4862,44 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
4841
4862
|
viewBox: `0 0 ${width} 38`,
|
|
4842
4863
|
"aria-hidden": "true",
|
|
4843
4864
|
children: [
|
|
4844
|
-
row.before.map((
|
|
4845
|
-
if (hash === row.commit.hash) return null;
|
|
4846
|
-
const target = row.after.
|
|
4865
|
+
row.before.map((track, lane) => {
|
|
4866
|
+
if (track.hash === row.commit.hash) return null;
|
|
4867
|
+
const target = row.after.findIndex((next) => next.hash === track.hash);
|
|
4847
4868
|
const nextLane = target >= 0 ? target : lane;
|
|
4848
|
-
const next = nextLane * 14 + 8;
|
|
4849
|
-
const start = lane * 14 + 8;
|
|
4850
4869
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
4851
|
-
d:
|
|
4870
|
+
d: graphTrackPath(lane * 14 + 8, nextLane * 14 + 8, 0, 38, 19),
|
|
4852
4871
|
fill: "none",
|
|
4853
|
-
stroke: graphColor(
|
|
4854
|
-
strokeWidth: "2"
|
|
4855
|
-
|
|
4872
|
+
stroke: graphColor(track.color),
|
|
4873
|
+
strokeWidth: "2",
|
|
4874
|
+
vectorEffect: "non-scaling-stroke"
|
|
4875
|
+
}, `continue-${track.hash}`);
|
|
4856
4876
|
}),
|
|
4857
4877
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
4858
4878
|
d: `M ${x} 0 V 19`,
|
|
4859
4879
|
fill: "none",
|
|
4860
|
-
stroke: graphColor(
|
|
4861
|
-
strokeWidth: "2"
|
|
4880
|
+
stroke: graphColor(current.color),
|
|
4881
|
+
strokeWidth: "2",
|
|
4882
|
+
vectorEffect: "non-scaling-stroke"
|
|
4862
4883
|
}),
|
|
4863
4884
|
row.parentLanes.map((parent, index) => {
|
|
4864
4885
|
const target = parent * 14 + 8;
|
|
4886
|
+
const track = row.after[parent];
|
|
4865
4887
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
4866
|
-
d:
|
|
4888
|
+
d: graphTrackPath(x, target, 19, 38, 29),
|
|
4867
4889
|
fill: "none",
|
|
4868
|
-
stroke: graphColor(
|
|
4869
|
-
strokeWidth: "2"
|
|
4870
|
-
|
|
4890
|
+
stroke: graphColor(track.color),
|
|
4891
|
+
strokeWidth: "2",
|
|
4892
|
+
vectorEffect: "non-scaling-stroke"
|
|
4893
|
+
}, `parent-${track.hash}-${index}`);
|
|
4871
4894
|
}),
|
|
4872
4895
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
4873
4896
|
cx: x,
|
|
4874
4897
|
cy: "19",
|
|
4875
4898
|
r: "5",
|
|
4876
4899
|
fill: "var(--dvw-surface-1)",
|
|
4877
|
-
stroke: graphColor(
|
|
4878
|
-
strokeWidth: "2"
|
|
4900
|
+
stroke: graphColor(current.color),
|
|
4901
|
+
strokeWidth: "2",
|
|
4902
|
+
vectorEffect: "non-scaling-stroke"
|
|
4879
4903
|
})
|
|
4880
4904
|
]
|
|
4881
4905
|
});
|
|
@@ -4889,15 +4913,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
4889
4913
|
viewBox: `0 0 ${width} 100`,
|
|
4890
4914
|
preserveAspectRatio: "none",
|
|
4891
4915
|
"aria-hidden": "true",
|
|
4892
|
-
children: row.after.map((
|
|
4916
|
+
children: row.after.map((track, lane) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
|
|
4893
4917
|
x1: lane * 14 + 8,
|
|
4894
4918
|
y1: "0",
|
|
4895
4919
|
x2: lane * 14 + 8,
|
|
4896
4920
|
y2: "100",
|
|
4897
|
-
stroke: graphColor(
|
|
4921
|
+
stroke: graphColor(track.color),
|
|
4898
4922
|
strokeWidth: "2",
|
|
4899
4923
|
vectorEffect: "non-scaling-stroke"
|
|
4900
|
-
}, hash))
|
|
4924
|
+
}, track.hash))
|
|
4901
4925
|
});
|
|
4902
4926
|
}
|
|
4903
4927
|
function CommitGraph({ commits, expanded, files, onToggle, onOpenFile }) {
|
|
@@ -6028,6 +6052,21 @@ body[data-ds-dark-theme] .dvw-overlay,.dvw-overlay[data-dvw-theme=dark]{color-sc
|
|
|
6028
6052
|
};
|
|
6029
6053
|
}
|
|
6030
6054
|
//#endregion
|
|
6055
|
+
//#region src/client/shortcuts.ts
|
|
6056
|
+
/** Handle terminal shortcuts through contributions registered by a terminal adapter. */
|
|
6057
|
+
function handleTerminalShortcut(event, workbench) {
|
|
6058
|
+
if (event.isComposing || !event.ctrlKey || event.altKey || event.code !== "Backquote") return false;
|
|
6059
|
+
if (!workbench.getPanels().some((panel) => panel.id === "terminal")) return false;
|
|
6060
|
+
event.preventDefault();
|
|
6061
|
+
event.stopImmediatePropagation();
|
|
6062
|
+
workbench.show();
|
|
6063
|
+
if (event.shiftKey) {
|
|
6064
|
+
if (workbench.getSnapshot().bottomPanel !== "terminal") workbench.toggleBottomPanel("terminal");
|
|
6065
|
+
queueMicrotask(() => workbench.runCommand("terminal.new"));
|
|
6066
|
+
} else workbench.toggleBottomPanel("terminal");
|
|
6067
|
+
return true;
|
|
6068
|
+
}
|
|
6069
|
+
//#endregion
|
|
6031
6070
|
//#region src/client/index.tsx
|
|
6032
6071
|
const Overlay = ({ service, useSessions }) => {
|
|
6033
6072
|
const sessionId = useSessions((state) => state.current);
|
|
@@ -6086,6 +6125,7 @@ body[data-ds-dark-theme] .dvw-overlay,.dvw-overlay[data-dvw-theme=dark]{color-sc
|
|
|
6086
6125
|
}, Overlay));
|
|
6087
6126
|
ctx.effect(() => {
|
|
6088
6127
|
const onKey = (event) => {
|
|
6128
|
+
if (handleTerminalShortcut(event, service)) return;
|
|
6089
6129
|
if (event.isComposing || !event.ctrlKey || event.altKey) return;
|
|
6090
6130
|
const view = event.shiftKey && event.code === "KeyE" ? "explorer" : event.shiftKey && event.code === "KeyF" ? "search" : event.shiftKey && event.code === "KeyG" ? "git" : void 0;
|
|
6091
6131
|
if (view !== void 0) {
|