dsh-vscode-mode 0.1.53 → 0.1.54

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/index.js CHANGED
@@ -556,6 +556,7 @@ function inDshRange(version, range) {
556
556
  function familyLabel(input) {
557
557
  const version = parseDshVersion(input);
558
558
  if (!version) return "未知";
559
+ if (inDshRange(version, { from: "0.1.3-alpha.1" })) return "0.1.3-alpha 及更新(对话文件链接=remote.session.openWorkspacePath)";
559
560
  if (inDshRange(version, { from: "0.1.2-alpha.1" })) return "0.1.2-alpha 及更新(设置 API=settings.installSection)";
560
561
  return "0.1.0/0.1.1 rc 线(设置 API=installSettingsSection)";
561
562
  }
@@ -586,6 +587,34 @@ function detectDshVersion() {
586
587
  //#region src/shared/rpc.ts
587
588
  /** webServer 精确路由。 */
588
589
  const RPC_PATH = "/edrv/rpc";
590
+ /**
591
+ * 图片扩展名(小写、无点)→ MIME。edrv.read base64 响应与 client 图片预览共用,
592
+ * 收敛在此避免 host/client 两处漂移。
593
+ * @author ddj 2026年09月08号
594
+ */
595
+ const IMAGE_MIME = {
596
+ png: "image/png",
597
+ jpg: "image/jpeg",
598
+ jpeg: "image/jpeg",
599
+ gif: "image/gif",
600
+ webp: "image/webp",
601
+ bmp: "image/bmp",
602
+ ico: "image/x-icon",
603
+ avif: "image/avif",
604
+ svg: "image/svg+xml"
605
+ };
606
+ /**
607
+ * 路径 → 图片 MIME:按 basename 扩展名小写查 {@link IMAGE_MIME},未命中回退 application/octet-stream。
608
+ * @author ddj 2026年09月08号
609
+ * @param path 文件路径(`/` 或 `\` 分隔均可)
610
+ * @returns MIME 字符串
611
+ */
612
+ function imageMimeOf(path) {
613
+ const base = String(path || "").split(/[\\/]/).pop() || "";
614
+ const dot = base.lastIndexOf(".");
615
+ const ext = dot > 0 ? base.slice(dot + 1).toLowerCase() : "";
616
+ return IMAGE_MIME[ext] ?? "application/octet-stream";
617
+ }
589
618
  //#endregion
590
619
  //#region src/paths.ts
591
620
  /**
@@ -959,7 +988,7 @@ function detectGuards(ctx) {
959
988
  }];
960
989
  }
961
990
  /** 已实测覆盖的最高 DSH 版本(适配矩阵上界,超过则提示,见 buildReport)。 */
962
- const TESTED_DSH_MAX = "0.1.2-alpha.4";
991
+ const TESTED_DSH_MAX = "0.1.3-alpha.2";
963
992
  /** 版本适配机制状态行:DSH 版本探测 + 设置 section 安装策略。 */
964
993
  function versionAdapters(dshVersion) {
965
994
  const adapters = [];
@@ -1005,7 +1034,7 @@ async function buildReport(ctx, options) {
1005
1034
  if (settingsInstallStrategy() === "none") warnings.push("设置 section 安装不可用:" + settingsInstallNote());
1006
1035
  const parsed = parseDshVersion(dshVersion);
1007
1036
  const testedMax = parseDshVersion(TESTED_DSH_MAX);
1008
- if (parsed && testedMax && compareDshVersions(parsed, testedMax) > 0) warnings.push("DSH " + dshVersion + " 高于已实测版本(0.1.2-alpha.4):设置 API 按能力探测运行,异常时请回报适配矩阵");
1037
+ if (parsed && testedMax && compareDshVersions(parsed, testedMax) > 0) warnings.push("DSH " + dshVersion + " 高于已实测版本(0.1.3-alpha.2):设置 API 按能力探测运行,异常时请回报适配矩阵");
1009
1038
  for (const guard of guards) if (!guard.active && guard.note) warnings.push(guard.note);
1010
1039
  return {
1011
1040
  pluginVersion: options?.version ?? pluginVersionOf(),
@@ -1569,6 +1598,9 @@ function archiveEntryFor(recs, cwd, reason) {
1569
1598
  }))
1570
1599
  };
1571
1600
  }
1601
+ //#endregion
1602
+ //#region src/store.ts
1603
+ const READ_CAP = 8388608;
1572
1604
  /** 会话沙箱策略(policyOf):可能不存在,调用方需容忍 undefined。 */
1573
1605
  function policyOf(ctx, session) {
1574
1606
  const svc = ctx.get("sandboxPolicy");
@@ -6059,6 +6091,16 @@ function buildHandlers(ctx, registry, searcher = newSearcher(ctx), contentSearch
6059
6091
  ok: false,
6060
6092
  error: "文件过大(>8MB),不支持整文件预览"
6061
6093
  };
6094
+ if (args.encoding === "base64") {
6095
+ const bytes = await fs.readBytes(target, void 0, READ_CAP);
6096
+ return {
6097
+ ok: true,
6098
+ content: Buffer.from(bytes).toString("base64"),
6099
+ size: bytes.byteLength,
6100
+ encoding: "base64",
6101
+ mime: imageMimeOf(args.path)
6102
+ };
6103
+ }
6062
6104
  const content = await fs.readText(target);
6063
6105
  return {
6064
6106
  ok: true,