dsh-vscode-mode 0.4.4 → 0.4.6
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 +553 -407
- package/lib/client.js +56 -16
- package/lib/client.js.map +1 -1
- package/package.json +1 -1
- package/src/client/monaco/loader.ts +55 -9
- package/src/client/monaco/lsp/lspClient.ts +5 -1
- package/src/client/sidebar/panels/FileExplorer.ts +0 -2
- package/src/client/ui/EditorView.ts +4 -1
- package/src/client/ui/OfficialSideTab.ts +1 -1
package/lib/client.js
CHANGED
|
@@ -1529,7 +1529,7 @@ window.__ModuleLoader__.load({
|
|
|
1529
1529
|
}
|
|
1530
1530
|
/**
|
|
1531
1531
|
* 加载 Monaco Editor(AMD 构建,随插件包离线分发):注入 loader.js → require.config → editor.main。
|
|
1532
|
-
* @author ddj 2026年08月20号
|
|
1532
|
+
* @author ddj 2026年08月20号 / 2026年09月22号
|
|
1533
1533
|
* @returns Promise<object> window.monaco
|
|
1534
1534
|
*/
|
|
1535
1535
|
function loadMonaco(onProgress) {
|
|
@@ -1537,13 +1537,58 @@ window.__ModuleLoader__.load({
|
|
|
1537
1537
|
if (!monacoPromise) {
|
|
1538
1538
|
publishStage("loader", MONACO_STAGES.loader.progress, MONACO_STAGES.loader.message);
|
|
1539
1539
|
monacoPromise = new Promise((resolve, reject) => {
|
|
1540
|
+
const hasModule = Object.prototype.hasOwnProperty.call(globalThis, "module");
|
|
1541
|
+
const hasExports = Object.prototype.hasOwnProperty.call(globalThis, "exports");
|
|
1542
|
+
const savedModule = globalThis.module;
|
|
1543
|
+
const savedExports = globalThis.exports;
|
|
1544
|
+
const hideNodeGlobals = () => {
|
|
1545
|
+
try {
|
|
1546
|
+
delete globalThis.module;
|
|
1547
|
+
} catch (error) {}
|
|
1548
|
+
try {
|
|
1549
|
+
delete globalThis.exports;
|
|
1550
|
+
} catch (error) {}
|
|
1551
|
+
};
|
|
1552
|
+
const restoreNodeGlobals = () => {
|
|
1553
|
+
if (hasModule) globalThis.module = savedModule;
|
|
1554
|
+
else try {
|
|
1555
|
+
delete globalThis.module;
|
|
1556
|
+
} catch (error) {}
|
|
1557
|
+
if (hasExports) globalThis.exports = savedExports;
|
|
1558
|
+
else try {
|
|
1559
|
+
delete globalThis.exports;
|
|
1560
|
+
} catch (error) {}
|
|
1561
|
+
};
|
|
1562
|
+
const removeLoaderTag = () => {
|
|
1563
|
+
const existing = document.querySelector("script[data-edrv-monaco-loader]");
|
|
1564
|
+
if (existing?.parentNode) existing.parentNode.removeChild(existing);
|
|
1565
|
+
};
|
|
1540
1566
|
const fail = (error) => {
|
|
1541
1567
|
monacoPromise = null;
|
|
1568
|
+
removeLoaderTag();
|
|
1569
|
+
restoreNodeGlobals();
|
|
1542
1570
|
publishStage("error", MONACO_STAGES.error.progress, MONACO_STAGES.error.message);
|
|
1543
1571
|
reject(error);
|
|
1544
1572
|
};
|
|
1573
|
+
const inject = () => {
|
|
1574
|
+
const s = document.createElement("script");
|
|
1575
|
+
s.src = MONACO_BASE + "/loader.js";
|
|
1576
|
+
s.dataset.edrvMonacoLoader = "1";
|
|
1577
|
+
s.onload = boot;
|
|
1578
|
+
s.onerror = (event) => {
|
|
1579
|
+
const hint = event && event.type ? "(" + event.type + ")" : "";
|
|
1580
|
+
fail(/* @__PURE__ */ new Error("Monaco loader 加载失败" + hint));
|
|
1581
|
+
};
|
|
1582
|
+
hideNodeGlobals();
|
|
1583
|
+
document.head.appendChild(s);
|
|
1584
|
+
};
|
|
1545
1585
|
const boot = () => {
|
|
1586
|
+
restoreNodeGlobals();
|
|
1546
1587
|
try {
|
|
1588
|
+
if (typeof window.require !== "function" || typeof window.require.config !== "function") {
|
|
1589
|
+
fail(/* @__PURE__ */ new Error("Monaco loader 未挂载 window.require(可能被其他脚本注入的全局 module 干扰)"));
|
|
1590
|
+
return;
|
|
1591
|
+
}
|
|
1547
1592
|
window.require.config({ paths: { vs: MONACO_BASE } });
|
|
1548
1593
|
publishStage("core", MONACO_STAGES.core.progress, MONACO_STAGES.core.message);
|
|
1549
1594
|
window.require(["vs/editor/editor.main"], () => {
|
|
@@ -1558,15 +1603,12 @@ window.__ModuleLoader__.load({
|
|
|
1558
1603
|
fail(error);
|
|
1559
1604
|
}
|
|
1560
1605
|
};
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
s.onerror = () => fail(/* @__PURE__ */ new Error("Monaco loader 加载失败"));
|
|
1568
|
-
document.head.appendChild(s);
|
|
1569
|
-
}
|
|
1606
|
+
const existing = document.querySelector("script[data-edrv-monaco-loader]");
|
|
1607
|
+
if (existing && typeof window.require === "function" && typeof window.require.config === "function") boot();
|
|
1608
|
+
else if (existing) {
|
|
1609
|
+
removeLoaderTag();
|
|
1610
|
+
inject();
|
|
1611
|
+
} else inject();
|
|
1570
1612
|
});
|
|
1571
1613
|
}
|
|
1572
1614
|
return monacoPromise.finally(unsubscribe);
|
|
@@ -5720,7 +5762,7 @@ window.__ModuleLoader__.load({
|
|
|
5720
5762
|
if (!uri) return "";
|
|
5721
5763
|
if (uri.startsWith("edrv://")) return uri;
|
|
5722
5764
|
const path = relativeLspPath(uri, root);
|
|
5723
|
-
return "edrv:///" + encodeURI(path);
|
|
5765
|
+
return "edrv:///" + encodeURI(String(path ?? "").replace(/^\/+/, ""));
|
|
5724
5766
|
}
|
|
5725
5767
|
/**
|
|
5726
5768
|
* 归一化 Location 的 uri → 工作区路径(剥离 scheme,不补盘符)。
|
|
@@ -8619,7 +8661,7 @@ window.__ModuleLoader__.load({
|
|
|
8619
8661
|
const cache = modelsRef.current;
|
|
8620
8662
|
let model = cache.get(path);
|
|
8621
8663
|
if (!model) {
|
|
8622
|
-
const uri = window.monaco.Uri.parse("edrv:///" + encodeURI(path));
|
|
8664
|
+
const uri = window.monaco.Uri.parse("edrv:///" + encodeURI(String(path ?? "").replace(/^\/+/, "")));
|
|
8623
8665
|
model = window.monaco.editor.getModel(uri) || window.monaco.editor.createModel(text ?? "", langOf(path), uri);
|
|
8624
8666
|
rememberModel(cache, path, model);
|
|
8625
8667
|
} else if (text !== void 0 && model.getValue() !== text) {
|
|
@@ -10878,14 +10920,14 @@ window.__ModuleLoader__.load({
|
|
|
10878
10920
|
*/
|
|
10879
10921
|
function markEditorMounted() {
|
|
10880
10922
|
mountEpoch += 1;
|
|
10881
|
-
markEditorActive
|
|
10923
|
+
markEditorActive(true);
|
|
10882
10924
|
}
|
|
10883
10925
|
/**
|
|
10884
10926
|
* 直接设置激活标记(正文卸载延迟判定用;测试 also 用作状态编排入口)。
|
|
10885
10927
|
* @author ddj 2026年09月09号
|
|
10886
10928
|
* @param active 是否激活
|
|
10887
10929
|
*/
|
|
10888
|
-
function markEditorActive
|
|
10930
|
+
function markEditorActive(active) {
|
|
10889
10931
|
editorTabActive = active;
|
|
10890
10932
|
}
|
|
10891
10933
|
/**
|
|
@@ -14283,8 +14325,6 @@ window.__ModuleLoader__.load({
|
|
|
14283
14325
|
const reloadDirRef = react.default.useRef(null);
|
|
14284
14326
|
const changedTimerRef = react.default.useRef(null);
|
|
14285
14327
|
const changedRelRef = react.default.useRef(/* @__PURE__ */ new Set());
|
|
14286
|
-
const dirsMapRef = react.default.useRef(null);
|
|
14287
|
-
dirsMapRef.current = loadDir;
|
|
14288
14328
|
/** 渲染取数:内存态 → 本地条目缓存 → null(显示加载态)。 */
|
|
14289
14329
|
const entriesOf = (rel) => dirsRef.current[rel] ?? entriesCacheGet(scope, rel) ?? null;
|
|
14290
14330
|
/** 预取子目录:≤4 个、排除重型目录、缓存新鲜跳过、已加载跳过、不级联。 */
|