Skip to content

Commit 08d44f8

Browse files
fix(Wind): Enable WKWebView compatibility with relative imports
Set VSCODE_DEV: "true" in both Install.ts userEnv and ProcessPolyfill default config. This tells the Electron workbench to use relative imports instead of vscode-file:// URLs, resolving the WKWebView (macOS) limitation where custom URL schemes cannot be used with import(). Also fix potential null reference in ProcessPolyfill by deferring hrtimeStart initialization. The previous code called process.hrtime() at module evaluation time, but Wind sets window.vscode.process after Install.ts runs, not globalThis.process. Initialize to [0, 0] and let the actual timer start lazily. These changes enable the VS Code workbench to render properly in the Tauri webview on macOS.
1 parent d3b21da commit 08d44f8

4 files changed

Lines changed: 34 additions & 13 deletions

File tree

Source/Function/Install.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,16 @@ export async function ResolveConfiguration(): Promise<ISandboxConfiguration> {
169169

170170
return {
171171
windowId: 1,
172-
// Electron workbench computes baseUrl from appRoot:
173-
// new URL(`${fileUriFromPath(appRoot, {scheme:'vscode-file'})}/out/`)
174-
// We override _VSCODE_FILE_ROOT after load, but appRoot is still
175-
// read for path construction. Point it at the embedded assets root.
176172
appRoot: FileRoot,
177-
userEnv: { PATH: "/usr/bin:/bin", HOME: "/" },
173+
userEnv: {
174+
PATH: "/usr/bin:/bin",
175+
HOME: "/",
176+
// Tells the Electron workbench to use relative imports
177+
// instead of vscode-file:// URLs. WKWebView (macOS) doesn't
178+
// support import() from custom schemes, so relative paths
179+
// resolve against the module's http://localhost URL.
180+
VSCODE_DEV: "true",
181+
},
178182

179183
// INativeWindowConfiguration fields for Electron workbench
180184
mainPid: 0,

Source/Polyfills/ProcessPolyfill.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ const DEFAULT_PROCESS_CONFIG: ProcessConfig = {
155155
TMP: "/tmp",
156156
TEMP: "/tmp",
157157
NODE_ENV: "production",
158+
// Tells the Electron workbench to use relative imports
159+
// instead of vscode-file:// URLs (WKWebView can't import()
160+
// from custom schemes). Paired with _VSCODE_USE_RELATIVE_IMPORTS
161+
// set in Base.astro.
162+
VSCODE_DEV: "true",
158163
},
159164
platform: "darwin",
160165
arch: "arm64",
@@ -239,7 +244,10 @@ function createVersions(): ProcessVersions {
239244
/**
240245
* High-resolution timer state
241246
*/
242-
let hrtimeStart = process.hrtime();
247+
// Defer — process may not exist at module evaluation time.
248+
// Wind Install.ts sets window.vscode.process but not globalThis.process;
249+
// that happens later when installProcessPolyfill() runs.
250+
let hrtimeStart: [number, number] = [0, 0];
243251

244252
/**
245253
* Get high-resolution time in [seconds, nanoseconds]

Target/Function/Install.js

Lines changed: 9 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Target/Polyfills/ProcessPolyfill.js

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)