Skip to content

Commit 7210878

Browse files
refactor(Sky): Revert to /Static/Application/ paths with build-time asset consolidation
Revert the /vs/ URL prefix approach from the previous commit. Instead: - Revert _VSCODE_FILE_ROOT to /Static/Application/ in all page templates (Base, BrowserProxy, Electron, Mountain) - Delete Public/vs symlink (no longer needed) - Enhance astro.config.ts build hook to: 1. Copy ESBuild-processed files from Output/vs to Static/Application/vs/ 2. Supplement missing files from Dependency/Editor/out/vs (e.g., workbench.web.main.js) 3. Copy Worker.js from node_modules to Target/Worker.js 4. Strip CSS imports from VS Code JS files for Tauri WKWebView (which lacks service worker interception). Replaced with _LOAD_CSS_WORKER calls to inject <link> elements. - Add __name esbuild helper polyfill in Base.astro for extension host worker contexts - Add ipc: to CSP connect-src and chatDebugTokenizer to worker allowlist This approach consolidates VS Code assets at /Static/Application/vs/ with a two-source strategy (Output primary, Dependency for gaps), ensuring all required files are present while maintaining Tauri compatibility.
1 parent 99caf06 commit 7210878

11 files changed

Lines changed: 155 additions & 22 deletions

File tree

Public/vs

Lines changed: 0 additions & 1 deletion
This file was deleted.

Source/Function/Markup/Base.astro

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,20 @@ import Meta from "../Meta.astro";
2323

2424
<!-- Global VSCode File Root - Must execute before module scripts -->
2525
<script is:inline>
26-
globalThis._VSCODE_FILE_ROOT = `${window.location.origin}/`;
26+
globalThis._VSCODE_FILE_ROOT = `${window.location.origin}/Static/Application/`;
27+
// esbuild __name helper — required by Dependency/out/ files loaded in
28+
// extension host worker contexts that don't have their own __name definition.
29+
if (typeof globalThis.__name === "undefined") {
30+
Object.defineProperty(globalThis, "__name", {
31+
value: (Target, Value) =>
32+
Object.defineProperty(Target, "name", {
33+
value: Value,
34+
configurable: true,
35+
}),
36+
configurable: true,
37+
writable: true,
38+
});
39+
}
2740
</script>
2841

2942
<slot name="Head" />

Source/Workbench/Browser.astro

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import NLS from "./NLS.astro";
1212
try {
1313
await import("/vs/code/browser/workbench/workbench.js");
1414
} catch (error) {
15-
console.error("[Browser] Failed to load VS Code browser workbench:", error);
15+
console.error(
16+
"[Browser] Failed to load VS Code browser workbench:",
17+
error,
18+
);
1619
}
1720
</script>
1821
</Fragment>

Source/Workbench/BrowserTest.astro

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,17 @@ import NLS from "./NLS.astro";
7777
<script is:inline type="module">
7878
try {
7979
await import("/vs/code/browser/workbench/workbench.js");
80-
console.log("[BrowserTest] ===== Loading browser VSCode workbench =====");
81-
console.log("[BrowserTest] ✓ Browser workbench script loaded successfully");
80+
console.log(
81+
"[BrowserTest] ===== Loading browser VSCode workbench =====",
82+
);
83+
console.log(
84+
"[BrowserTest] ✓ Browser workbench script loaded successfully",
85+
);
8286
} catch (error) {
83-
console.error("[BrowserTest] Failed to load VS Code browser workbench:", error);
87+
console.error(
88+
"[BrowserTest] Failed to load VS Code browser workbench:",
89+
error,
90+
);
8491
}
8592
console.log("[BrowserTest] ===== Workbench load attempted =====");
8693
</script>

Source/Workbench/Mountain.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ import NLS from "./NLS.astro";
194194
try {
195195
// Variable URL: Rollup only analyzes string literals — an identifier
196196
// reference is treated as truly dynamic and never resolved at build time.
197-
const WorkbenchUrl = "/vs/code/browser/workbench/workbench.js";
197+
const WorkbenchUrl =
198+
"/Static/Application/vs/code/browser/workbench/workbench.js";
198199
await import(WorkbenchUrl);
199200

200201
console.log(

Source/Workbench/NLS.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ import { Bust, On } from "../Function/Shared";
66
is:inline
77
type="module"
88
src={Bust(
9-
`${On ? "/vs/nls.js" : "/Static/Application/nls.messages.js"}`,
9+
`/Static/Application/${On ? "vs/" : ""}${On ? "nls.js" : "nls.messages.js"}`,
1010
)}></script>

Source/pages/BrowserProxy.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ const Worker = `/Worker.js?BASE_REMOTE=${encodeURIComponent(Astro.url.origin)}`;
170170

171171
<!-- Global VSCode File Root -->
172172
<script is:inline slot="Head">
173-
globalThis._VSCODE_FILE_ROOT = `${window.location.origin}/`;
173+
globalThis._VSCODE_FILE_ROOT = `${window.location.origin}/Static/Application/`;
174174
</script>
175175

176176
<!-- Worker Configuration -->

Source/pages/Electron.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ const Worker = `/Worker.js?BASE_REMOTE=${encodeURIComponent(Astro.url.origin)}`;
170170

171171
<!-- Global VSCode File Root -->
172172
<script is:inline slot="Head">
173-
globalThis._VSCODE_FILE_ROOT = `${window.location.origin}/`;
173+
globalThis._VSCODE_FILE_ROOT = `${window.location.origin}/Static/Application/`;
174174
</script>
175175

176176
<!-- Worker Configuration -->

Source/pages/Mountain.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ const Worker = `/Worker.js?BASE_REMOTE=${encodeURIComponent(Astro.url.origin)}`;
170170

171171
<!-- Global VSCode File Root -->
172172
<script is:inline slot="Head">
173-
globalThis._VSCODE_FILE_ROOT = `${window.location.origin}/`;
173+
globalThis._VSCODE_FILE_ROOT = `${window.location.origin}/Static/Application/`;
174174
</script>
175175

176176
<!-- Worker Configuration -->

Source/pages/index.astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ const Worker = `/Worker.js?BASE_REMOTE=${encodeURIComponent(Astro.url.origin)}`;
102102
],
103103
"connect-src": [
104104
"'self'",
105+
"ipc:",
105106
"http://localhost:*",
106107
"https://tauri.localhost",
107108
"wss://tauri.localhost",
@@ -119,6 +120,7 @@ const Worker = `/Worker.js?BASE_REMOTE=${encodeURIComponent(Astro.url.origin)}`;
119120
"WorkerApplication",
120121
"amdLoader",
121122
"cellRendererEditorText",
123+
"chatDebugTokenizer",
122124
"defaultWorkerFactory",
123125
"diffEditorWidget",
124126
"diffReview",

0 commit comments

Comments
 (0)