dsh-vscode-mode 0.1.23 → 0.1.26
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.md +8 -5
- package/lib/client.js +409 -30
- package/lib/client.js.map +1 -1
- package/lib/index.js +23 -2
- package/lib/index.js.map +1 -1
- package/package.json +4 -1
- package/src/client/monaco/diffRender.ts +3 -0
- package/src/client/sidebar/panels/FileExplorer.ts +42 -2
- package/src/client/state/explorerCache.ts +112 -0
- package/src/client/state/viewStateCache.ts +119 -0
- package/src/client/styles/editor.css +1 -0
- package/src/client/ui/ContextMenu.ts +37 -12
- package/src/client/ui/EditorView.ts +88 -4
- package/src/client/ui/menuPosition.ts +63 -0
- package/src/routes.ts +18 -2
- package/src/rpc.ts +7 -1
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { readFile, stat } from "node:fs/promises";
|
|
3
3
|
import { dirname, extname, join, normalize, resolve, sep } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { existsSync, readFileSync, readdirSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
@@ -613,10 +613,28 @@ function registerRoutes(ctx, config, handleRpc, onWarning) {
|
|
|
613
613
|
res.end();
|
|
614
614
|
return;
|
|
615
615
|
}
|
|
616
|
+
const info = await stat(target).catch(() => null);
|
|
617
|
+
if (!info || !info.isFile()) {
|
|
618
|
+
res.statusCode = 404;
|
|
619
|
+
res.end();
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
const etag = "W/\"" + info.mtimeMs.toString(16) + "-" + info.size.toString(16) + "\"";
|
|
623
|
+
if ((() => {
|
|
624
|
+
const raw = req.headers?.["if-none-match"];
|
|
625
|
+
if (Array.isArray(raw)) return raw[0];
|
|
626
|
+
return raw;
|
|
627
|
+
})() === etag) {
|
|
628
|
+
res.statusCode = 304;
|
|
629
|
+
res.setHeader("etag", etag);
|
|
630
|
+
res.end();
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
616
633
|
const body = await readFile(target);
|
|
617
634
|
res.statusCode = 200;
|
|
618
635
|
res.setHeader("content-type", VENDOR_MIME[extname(target)] ?? "application/octet-stream");
|
|
619
636
|
res.setHeader("cache-control", "public, max-age=3600");
|
|
637
|
+
res.setHeader("etag", etag);
|
|
620
638
|
res.end(body);
|
|
621
639
|
} catch (error) {
|
|
622
640
|
res.statusCode = 404;
|
|
@@ -2527,6 +2545,8 @@ async function revealInExplorer(ctx, absPath, isDir) {
|
|
|
2527
2545
|
//#region src/rpc.ts
|
|
2528
2546
|
/** cwd → Promise 链:串行化 debug 日志追加(fs read+write 非原子,避免并发丢行)。 */
|
|
2529
2547
|
const debugWriteQueues = /* @__PURE__ */ new Map();
|
|
2548
|
+
/** debug 日志单文件上限:超限截断保留尾部,防文件无限增长拖慢每次追加。 */
|
|
2549
|
+
const DEBUG_LOG_CAP = 524288;
|
|
2530
2550
|
/** 记录 → 客户端视图(不含 before 全文,仅长度)。 */
|
|
2531
2551
|
function recView(record) {
|
|
2532
2552
|
return {
|
|
@@ -2930,7 +2950,8 @@ function buildHandlers(ctx, registry, searcher = newSearcher(ctx)) {
|
|
|
2930
2950
|
const target = await fs.resolve(".dsh-edit-review-debug.log", { cwd: sc.cwd });
|
|
2931
2951
|
const old = await fs.readText(target).catch(() => "");
|
|
2932
2952
|
const line = (/* @__PURE__ */ new Date()).toISOString() + " " + text + "\n";
|
|
2933
|
-
|
|
2953
|
+
const next = old.length + line.length > DEBUG_LOG_CAP ? old.slice(-Math.floor(DEBUG_LOG_CAP / 2)) + line : old + line;
|
|
2954
|
+
await fs.writeText(target, next, void 0, void 0, policyOf(ctx, sc.session));
|
|
2934
2955
|
} catch (e) {}
|
|
2935
2956
|
});
|
|
2936
2957
|
debugWriteQueues.set(sc.cwd, task);
|