Skip to content

Commit eac2e17

Browse files
feat(Sky): Add missing Electron API stubs and folder URL parameter support
Add three improvements to the Electron workbench: 1. queryLocalFonts stub: VS Code's fonts.js calls mainWindow.queryLocalFonts() to enumerate system fonts. Without this stub, the extension host throws errors. Returns empty array so VS Code falls back to defaults. 2. __name stub: esbuild's keepNames helper used inside VS Code blob workers. Without this, extension host blob workers throw "Can't find variable: __name". 3. folderUri injection: Inline script in Mountain.astro and index.astro parses ?folder= URL parameter and injects it into the workbench configuration, enabling users to open a specific folder on startup. 4. LAND_DEV_LOG initialization: WindPreload now reads LAND_DEV_LOG from localStorage or URL (?devlog=...) parameter to enable selective debug logging.
1 parent 5e41fb7 commit eac2e17

4 files changed

Lines changed: 71 additions & 7 deletions

File tree

Source/Workbench/Electron/WindPreload.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@
77

88
import Install from "@codeeditorland/wind/Target/Function/Install";
99

10+
// Initialize LAND_DEV_LOG from localStorage (persistent) or URL param (?devlog=config,vfs)
11+
// Can also be set at runtime: window.__LAND_DEV_LOG = "all"
12+
{
13+
const Stored = localStorage.getItem("LAND_DEV_LOG");
14+
const UrlParam = new URLSearchParams(window.location.search).get("devlog");
15+
const Value = UrlParam ?? Stored ?? "";
16+
if (Value) {
17+
(window as any).__LAND_DEV_LOG = Value;
18+
console.log(
19+
`[DevLog] Enabled tags: ${Value} (source: ${UrlParam ? "url" : "localStorage"})`,
20+
);
21+
}
22+
}
23+
1024
console.log("[Electron] ===== Starting Wind preload installation =====");
1125

1226
console.log("[Electron] Workbench: Electron (A3)");

Source/Workbench/Electron/Workbench.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,25 @@ console.log(
6262
(window as any).vscode?.process?.env?.VSCODE_DEV,
6363
);
6464

65+
// Stubs for APIs that VS Code uses but don't exist in Tauri's WKWebView.
66+
// queryLocalFonts: VS Code's fonts.js calls mainWindow.queryLocalFonts() to
67+
// enumerate system fonts. Returns empty array = VS Code falls back to defaults.
68+
if (typeof (window as any).queryLocalFonts !== "function") {
69+
(window as any).queryLocalFonts = () => Promise.resolve([]);
70+
}
71+
72+
// __name: esbuild keepNames helper used inside VS Code blob workers.
73+
// Without this, the extension host blob throws "Can't find variable: __name".
74+
if (typeof (globalThis as any).__name !== "function") {
75+
(globalThis as any).__name = (Target: any, Value: string) => {
76+
Object.defineProperty(Target, "name", {
77+
value: Value,
78+
configurable: true,
79+
});
80+
return Target;
81+
};
82+
}
83+
6584
try {
6685
const WorkbenchUrl =
6786
"/Static/Application/vs/code/electron-browser/workbench/workbench.js";

Source/pages/Mountain.astro

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,21 @@ const Worker = `/Worker.js?BASE_REMOTE=${encodeURIComponent(Astro.url.origin)}`;
161161
slot="Meta"
162162
/>
163163

164+
<!-- Inject folderUri from URL into workbench config (must run before module scripts) -->
165+
<script is:inline slot="Meta">
166+
(function() {
167+
var FolderParam = new URLSearchParams(window.location.search).get("folder");
168+
if (FolderParam) {
169+
var Element = document.getElementById("vscode-workbench-web-configuration");
170+
if (Element) {
171+
var Settings = JSON.parse(Element.getAttribute("data-settings") || "{}");
172+
Settings.folderUri = { scheme: "file", path: FolderParam, authority: "" };
173+
Element.setAttribute("data-settings", JSON.stringify(Settings));
174+
}
175+
}
176+
})();
177+
</script>
178+
164179
<!-- VSCode Auth Session -->
165180
<meta
166181
id="vscode-workbench-auth-session"

Source/pages/index.astro

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,17 @@ const Electron = process.env["Electron"] === "true";
3232
const BrowserProxy = process.env["BrowserProxy"] === "true";
3333
3434
// Determine workbench type (default to Browser if nothing specified)
35-
const WorkbenchType = Electron
35+
// Mountain uses the Electron workbench — it has the full IPC chain
36+
// (TauriMainProcessService → Mountain WindServiceHandlers → tokio::fs)
37+
// for real filesystem access. The browser workbench uses IndexedDB.
38+
const WorkbenchType = Electron || Mountain
3639
? "Electron"
37-
: Mountain
38-
? "Mountain"
39-
: BrowserProxy
40-
? "BrowserProxy"
41-
: "Browser"; // Default, not null
40+
: BrowserProxy
41+
? "BrowserProxy"
42+
: "Browser"; // Default, not null
4243
4344
// Determine embedder identifier
44-
const EmbedderId = Electron ? "desktop" : "browser";
45+
const EmbedderId = Electron || Mountain ? "desktop" : "browser";
4546
4647
const Worker = `/Worker.js?BASE_REMOTE=${encodeURIComponent(Astro.url.origin)}`;
4748
---
@@ -195,6 +196,21 @@ const Worker = `/Worker.js?BASE_REMOTE=${encodeURIComponent(Astro.url.origin)}`;
195196
slot="Meta"
196197
/>
197198

199+
<!-- Inject folderUri from URL into workbench config (must run before module scripts) -->
200+
<script is:inline slot="Meta">
201+
(function() {
202+
var FolderParam = new URLSearchParams(window.location.search).get("folder");
203+
if (FolderParam) {
204+
var Element = document.getElementById("vscode-workbench-web-configuration");
205+
if (Element) {
206+
var Settings = JSON.parse(Element.getAttribute("data-settings") || "{}");
207+
Settings.folderUri = { scheme: "file", path: FolderParam, authority: "" };
208+
Element.setAttribute("data-settings", JSON.stringify(Settings));
209+
}
210+
}
211+
})();
212+
</script>
213+
198214
<!-- VSCode Auth Session -->
199215
<meta
200216
id="vscode-workbench-auth-session"

0 commit comments

Comments
 (0)