dsh-vscode-mode 0.1.29 → 0.1.30
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/lib/client.js +32 -3
- package/lib/client.js.map +1 -1
- package/lib/index.js +72 -14
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client/monaco/diffRender.ts +7 -0
- package/src/client/rpc.ts +13 -2
- package/src/client/ui/EditorView.ts +11 -3
- package/src/rpc.ts +79 -19
package/lib/client.js
CHANGED
|
@@ -50,6 +50,19 @@ window.__ModuleLoader__.load({
|
|
|
50
50
|
* 迁移自原 src/client/index.ts 的 rpc/dbg,语义不改。
|
|
51
51
|
* 作者 ddj 2026-08-20
|
|
52
52
|
*/
|
|
53
|
+
/**
|
|
54
|
+
* 诊断日志开关(默认关):diff 渲染热路径每条日志 = 1 次 RPC 往返 +
|
|
55
|
+
* host 端 debug 文件全量读改写(上限 512KB),高频渲染下开销可观。
|
|
56
|
+
* 排查问题时在浏览器控制台执行 localStorage.setItem('edrv.debug','1') 后刷新开启。
|
|
57
|
+
* @author ddj 2026年08月26号
|
|
58
|
+
*/
|
|
59
|
+
const DEBUG = (() => {
|
|
60
|
+
try {
|
|
61
|
+
return localStorage.getItem("edrv.debug") === "1";
|
|
62
|
+
} catch (e) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
})();
|
|
53
66
|
/** 同源 RPC 调用(host /edrv/rpc 精确路由)。 */
|
|
54
67
|
function rpc(method, args) {
|
|
55
68
|
return fetch(RPC_PATH, {
|
|
@@ -62,12 +75,13 @@ window.__ModuleLoader__.load({
|
|
|
62
75
|
}).then((res) => res.json());
|
|
63
76
|
}
|
|
64
77
|
/**
|
|
65
|
-
*
|
|
66
|
-
* @author ddj 2026年08月
|
|
78
|
+
* 诊断日志:开关关闭时直接返回(零 RPC 零落盘);开启时走 host edrv.debug 落盘。
|
|
79
|
+
* @author ddj 2026年08月26号
|
|
67
80
|
* @param sessionId 会话 id
|
|
68
81
|
* @param text 日志文本
|
|
69
82
|
*/
|
|
70
83
|
function dbg(sessionId, text) {
|
|
84
|
+
if (!DEBUG) return;
|
|
71
85
|
try {
|
|
72
86
|
rpc("edrv.debug", {
|
|
73
87
|
sessionId,
|
|
@@ -555,6 +569,8 @@ window.__ModuleLoader__.load({
|
|
|
555
569
|
function createDiffRenderer(log) {
|
|
556
570
|
let viewZoneIds = [];
|
|
557
571
|
let decorations = [];
|
|
572
|
+
/** 上次已渲染的差异指纹(callId:idx@start-end:oldLen/newLen 串):内容未变时跳过重建。 */
|
|
573
|
+
let lastKey = null;
|
|
558
574
|
/**
|
|
559
575
|
* 渲染当前 pending 差异:绿底 decoration + 删除块 view zones + '-' 号 overlay(滚动同步)。
|
|
560
576
|
* @param monaco window.monaco
|
|
@@ -566,6 +582,9 @@ window.__ModuleLoader__.load({
|
|
|
566
582
|
if (!pendingRegions.length && viewZoneIds.length === 0 && decorations.length === 0) return;
|
|
567
583
|
const renderT0 = Date.now();
|
|
568
584
|
const callIdAttr = (callId, idx) => String(callId) + ":" + String(idx);
|
|
585
|
+
const key = pendingRegions.map((r) => callIdAttr(r.callId, r.idx) + "@" + (r.start ?? "?") + "-" + (r.end ?? "?") + ":" + (r.oldLines ? r.oldLines.length : 0) + "/" + (r.newLines ? r.newLines.length : 0)).join("|");
|
|
586
|
+
if (key === lastKey) return;
|
|
587
|
+
lastKey = key;
|
|
569
588
|
log(sessionId, "[diff-render] begin regs=" + pendingRegions.length + " " + pendingRegions.map((r) => callIdAttr(r.callId, r.idx) + "@" + (r.start ?? "?") + "-" + (r.end ?? "?") + "(-" + (r.oldLines ? r.oldLines.length : 0) + "/+" + (r.newLines ? r.newLines.length : 0) + ")").join("|"));
|
|
570
589
|
const decos = [];
|
|
571
590
|
for (const r of pendingRegions) {
|
|
@@ -2790,7 +2809,7 @@ window.__ModuleLoader__.load({
|
|
|
2790
2809
|
ok++;
|
|
2791
2810
|
if (item.record) next[item.callId] = item.record;
|
|
2792
2811
|
} else fail++;
|
|
2793
|
-
setRecords((prev) => Object.assign({}, prev, next));
|
|
2812
|
+
if (Object.keys(next).length) setRecords((prev) => Object.assign({}, prev, next));
|
|
2794
2813
|
return {
|
|
2795
2814
|
ok,
|
|
2796
2815
|
fail
|
|
@@ -2817,19 +2836,29 @@ window.__ModuleLoader__.load({
|
|
|
2817
2836
|
decision: reject ? "rejected" : "accepted"
|
|
2818
2837
|
});
|
|
2819
2838
|
const acceptFile = () => {
|
|
2839
|
+
if (batchBusyRef.current || !pendingRegions.length) return;
|
|
2840
|
+
batchBusyRef.current = true;
|
|
2820
2841
|
actMany(pendingRegions.map((r) => itemOf(r, false))).then(({ ok, fail }) => {
|
|
2842
|
+
batchBusyRef.current = false;
|
|
2821
2843
|
reloadFile(true);
|
|
2822
2844
|
emitRefresh();
|
|
2823
2845
|
setStatus("已采纳 " + ok + " 处差异" + (fail ? "," + fail + " 处失败" : ""));
|
|
2824
2846
|
if (fail) setError(fail + " 处差异处理失败(可能已被后续修改影响),可刷新后重试");
|
|
2847
|
+
}).catch(() => {
|
|
2848
|
+
batchBusyRef.current = false;
|
|
2825
2849
|
});
|
|
2826
2850
|
};
|
|
2827
2851
|
const undoFile = () => {
|
|
2852
|
+
if (batchBusyRef.current || !pendingRegions.length) return;
|
|
2853
|
+
batchBusyRef.current = true;
|
|
2828
2854
|
actMany([...pendingRegions].reverse().map((r) => itemOf(r, true))).then(({ ok, fail }) => {
|
|
2855
|
+
batchBusyRef.current = false;
|
|
2829
2856
|
reloadFile(true);
|
|
2830
2857
|
emitRefresh();
|
|
2831
2858
|
setStatus("已不采纳 " + ok + " 处差异" + (fail ? "," + fail + " 处失败" : ""));
|
|
2832
2859
|
if (fail) setError(fail + " 处差异处理失败(可能已被后续修改影响),可刷新后重试");
|
|
2860
|
+
}).catch(() => {
|
|
2861
|
+
batchBusyRef.current = false;
|
|
2833
2862
|
});
|
|
2834
2863
|
};
|
|
2835
2864
|
const allPending = react.default.useMemo(() => {
|