Skip to content

Commit bbff41c

Browse files
chore(Build/Sky): conditionally load environment-specific workbench bundles
- Updated environment variable checks for `Bundle` and introduced `Browser` flag to distinguish between browser-based and Electron-sandbox environments - Modified script imports in Application.astro to load browser workbench when `Browser=true`, else load Electron-sandbox workbench with bootstrap initialization - Adjusted Vite external dependencies configuration to exclude Electron-specific workbench bundle in browser mode - Added cache-busting logic for static resource paths in both environments This change supports Land's dual-environment strategy for Sky frontend: 1. Enables lightweight browser-based development/testing of VS Code UI components 2. Maintains Electron-sandbox compatibility during Tauri integration phase 3. Prepares for gradual migration from Electron-specific APIs to Tauri-native equivalents Refs #127 (Environment configuration standardization)
1 parent e396123 commit bbff41c

6 files changed

Lines changed: 71 additions & 18 deletions

File tree

Source/pages/Application.astro

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ const Default = {
151151
const Bust = (Base: string): string =>
152152
`${Base}${Base.includes("?") ? "&" : "?"}Time=${encodeURIComponent(Date.now())}`;
153153
154-
const Bundle = typeof process.env["Bundle"] !== "undefined";
154+
const Bundle = process.env["Bundle"] === "true";
155+
156+
const Browser = process.env["Browser"] === "true";
155157
---
156158

157159
<Layout>
@@ -183,9 +185,28 @@ const Bundle = typeof process.env["Bundle"] !== "undefined";
183185
import "@codeeditorland/Worker/Target/Worker/CSS/Load.js";
184186
import "@codeeditorland/Worker/Target/Worker/Policy.js";
185187
import "@codeeditorland/Worker/Target/Worker/Register.js";
186-
import
187-
"@codeeditorland/output/Target/Microsoft/VSCode/vs/code/browser/workbench/workbench.js";
188188
</script>
189+
190+
{Browser ? (
191+
<script>
192+
import
193+
"@codeeditorland/output/Target/Microsoft/VSCode/vs/code/browser/workbench/workbench.js";
194+
</script>
195+
) : (
196+
<Fragment>
197+
{On ? (
198+
<script>
199+
import
200+
"@codeeditorland/output/Target/Microsoft/VSCode/bootstrap-window.js";
201+
</script>
202+
) : null}
203+
204+
<script>
205+
import
206+
"@codeeditorland/output/Target/Microsoft/VSCode/vs/code/electron-sandbox/workbench/workbench.js";
207+
</script>
208+
</Fragment>
209+
)}
189210
</Fragment>
190211
) : (
191212
<Fragment>
@@ -212,14 +233,37 @@ const Bundle = typeof process.env["Bundle"] !== "undefined";
212233
defer
213234
/>
214235

215-
<script
216-
is:inline
217-
type="module"
218-
src={Bust(
219-
"/Static/Application/vs/code/browser/workbench/workbench.js",
220-
)}
221-
defer
222-
/>
236+
{Browser ? (
237+
<script
238+
is:inline
239+
type="module"
240+
src={Bust(
241+
"/Static/Application/vs/code/browser/workbench/workbench.js",
242+
)}
243+
defer
244+
/>
245+
) : (
246+
<Fragment>
247+
{On ? (
248+
<script
249+
is:inline
250+
type="module"
251+
src={Bust(
252+
"/Static/Application/bootstrap-window.js",
253+
)}
254+
/>
255+
) : null}
256+
257+
<script
258+
is:inline
259+
type="module"
260+
src={Bust(
261+
"/Static/Application/vs/code/electron-sandbox/workbench/workbench.js",
262+
)}
263+
defer
264+
/>
265+
</Fragment>
266+
)}
223267
</Fragment>
224268
)
225269
}

Target/Application/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!DOCTYPE html><html class=no-js data-beasties-container dir=ltr lang=en><head><script type=module>document.documentElement.classList.remove("no-js"),document.documentElement.classList.add("js")</script><title></title><meta charset=utf-8><meta content name=description><meta content="width=device-width,initial-scale=1" name=viewport><meta content=#ffffff name=theme-color><meta content="telephone=no" name=format-detection><meta content=on name=twitter:dnt><meta data-settings={&#34;remoteAuthority&#34;:&#34;&#34;,&#34;serverBasePath&#34;:&#34;/&#34;,&#34;connectionToken&#34;:&#34;&#34;,&#34;enableWorkspaceTrust&#34;:true,&#34;settingsSyncOptions&#34;:{&#34;enabled&#34;:false},&#34;productConfiguration&#34;:{&#34;embedderIdentifier&#34;:&#34;desktop&#34;,&#34;nameShort&#34;:&#34;FIDDEE&#34;,&#34;nameLong&#34;:&#34;FIDDEE&#34;,&#34;applicationName&#34;:&#34;fiddee&#34;},&#34;developmentOptions&#34;:{&#34;logLevel&#34;:0,&#34;enableSmokeTestDriver&#34;:false}} id=vscode-workbench-web-configuration><link href=/Manifest.json rel=manifest crossorigin=use-credentials><script type=module>const Site="https://tauri.localhost/";globalThis._VSCODE_FILE_ROOT=`${Site}/Static/Application/`</script><script type=module>const Worker="/Worker.js?BASE_REMOTE=https%3A%2F%2Ftauri.localhost%2F&Time=1746434949419";window._WORKER=Worker</script><style>:root{--vscode-sash-size:4px;--vscode-sash-hover-size:4px}@property --chat-editing-last-edit-shift{syntax:"<percentage>";initial-value:100%;inherits:false}@property --inline-chat-frame-progress{syntax:"<percentage>";initial-value:0%;inherits:false}body{height:100%;width:100%;margin:0;padding:0;overflow:hidden;font-size:11px;user-select:none;-webkit-user-select:none}</style><link href=/_astro/Application.CRM72xFj.css rel=stylesheet media=print onload="this.media=&#34;all&#34;"><noscript><link href=/_astro/Application.CRM72xFj.css rel=stylesheet></noscript></head><body aria-label><script type=module src=/_astro/Application.astro_astro_type_script_index_0_lang.D_QlNiAb.js></script></body></html>
1+
<!DOCTYPE html><html class=no-js data-beasties-container dir=ltr lang=en><head><script type=module>document.documentElement.classList.remove("no-js"),document.documentElement.classList.add("js")</script><title></title><meta charset=utf-8><meta content name=description><meta content="width=device-width,initial-scale=1" name=viewport><meta content=#ffffff name=theme-color><meta content="telephone=no" name=format-detection><meta content=on name=twitter:dnt><meta data-settings={&#34;remoteAuthority&#34;:&#34;&#34;,&#34;serverBasePath&#34;:&#34;/&#34;,&#34;connectionToken&#34;:&#34;&#34;,&#34;enableWorkspaceTrust&#34;:true,&#34;settingsSyncOptions&#34;:{&#34;enabled&#34;:false},&#34;productConfiguration&#34;:{&#34;embedderIdentifier&#34;:&#34;desktop&#34;,&#34;nameShort&#34;:&#34;FIDDEE&#34;,&#34;nameLong&#34;:&#34;FIDDEE&#34;,&#34;applicationName&#34;:&#34;fiddee&#34;},&#34;developmentOptions&#34;:{&#34;logLevel&#34;:0,&#34;enableSmokeTestDriver&#34;:false}} id=vscode-workbench-web-configuration><link href=/Manifest.json rel=manifest crossorigin=use-credentials><script type=module>const Site="https://tauri.localhost/";globalThis._VSCODE_FILE_ROOT=`${Site}/Static/Application/`</script><script type=module>const Worker="/Worker.js?BASE_REMOTE=https%3A%2F%2Ftauri.localhost%2F&Time=1746448530537";window._WORKER=Worker</script><style>:root{--vscode-sash-size:4px;--vscode-sash-hover-size:4px}@property --chat-editing-last-edit-shift{syntax:"<percentage>";initial-value:100%;inherits:false}@property --inline-chat-frame-progress{syntax:"<percentage>";initial-value:0%;inherits:false}body{height:100%;width:100%;margin:0;padding:0;overflow:hidden;font-size:11px;user-select:none;-webkit-user-select:none}</style><link href=/_astro/Application.CRM72xFj.css rel=stylesheet media=print onload="this.media=&#34;all&#34;"><noscript><link href=/_astro/Application.CRM72xFj.css rel=stylesheet></noscript></head><body aria-label><script type=module src=/_astro/Application.astro_astro_type_script_index_0_lang.B5_-wFAE.js></script><script type=module>!function(){const e=window.vscode,o=e.process;globalThis.MonacoBootstrapWindow={load:async function(n,t){const r=await async function(){const o=setTimeout((()=>{}),1e4);performance.mark("code/willWaitForWindowConfig");const n=await e.context.resolveConfiguration();return performance.mark("code/didWaitForWindowConfig"),clearTimeout(o),n}();t?.beforeImport?.(r);const{enableDeveloperKeybindings:i,removeDeveloperKeybindingsAfterLoad:s,developerDeveloperKeybindingsDisposable:c,forceDisableShowDevtoolsOnError:a}=function(n,t){const{forceEnableDeveloperKeybindings:r,disallowReloadKeybinding:i,removeDeveloperKeybindingsAfterLoad:s,forceDisableShowDevtoolsOnError:c}="function"==typeof t?.configureDeveloperSettings?t.configureDeveloperSettings(n):{forceEnableDeveloperKeybindings:!1,disallowReloadKeybinding:!1,removeDeveloperKeybindingsAfterLoad:!1,forceDisableShowDevtoolsOnError:!1},a=!(!o.env.VSCODE_DEV&&!r);let l;return a&&(l=function(n){const t=e.ipcRenderer,r="darwin"===o.platform?"meta-alt-73":"ctrl-shift-73",i="darwin"===o.platform?"meta-82":"ctrl-82";let s=function(e){const o=function(e){return[e.ctrlKey?"ctrl-":"",e.metaKey?"meta-":"",e.altKey?"alt-":"",e.shiftKey?"shift-":"",e.keyCode].join("")}(e);o===r||"123"===o?t.send("vscode:toggleDevTools"):o===i&&!n&&t.send("vscode:reloadWindow")};return window.addEventListener("keydown",s),function(){s&&(window.removeEventListener("keydown",s),s=void 0)}}(i)),{enableDeveloperKeybindings:a,removeDeveloperKeybindingsAfterLoad:s,developerDeveloperKeybindingsDisposable:l,forceDisableShowDevtoolsOnError:c}}(r,t);!function(e){globalThis._VSCODE_NLS_MESSAGES=e.nls.messages,globalThis._VSCODE_NLS_LANGUAGE=e.nls.language;let o=e.nls.language||"en";"zh-tw"===o?o="zh-Hant":"zh-cn"===o&&(o="zh-Hans"),window.document.documentElement.setAttribute("lang",o)}(r);const l=new URL(`${function(e,o){let n,t=e.replace(/\\/g,"/");return t.length>0&&"/"!==t.charAt(0)&&(t=`/${t}`),n=o.isWindows&&t.startsWith("//")?encodeURI(`${o.scheme||"file"}:${t}`):encodeURI(`${o.scheme||"file"}://${o.fallbackAuthority||""}${t}`),n.replace(/#/g,"%23")}(r.appRoot,{isWindows:"win32"===o.platform,scheme:"vscode-file",fallbackAuthority:"vscode-app"})}/out/`);globalThis._VSCODE_FILE_ROOT=l.toString(),function(e,o){if(Array.isArray(e.cssModules)&&e.cssModules.length>0){performance.mark("code/willAddCssLoader");const n=document.createElement("style");n.type="text/css",n.media="screen",n.id="vscode-css-loading",document.head.appendChild(n),globalThis._VSCODE_CSS_LOAD=function(e){n.textContent+=`@import url(${e});\n`};const t={imports:{}};for(const n of e.cssModules){const e=new URL(n,o).href,r=new Blob([`globalThis._VSCODE_CSS_LOAD('${e}');\n`],{type:"application/javascript"});t.imports[e]=URL.createObjectURL(r)}const r=window.trustedTypes?.createPolicy("vscode-bootstrapImportMap",{createScript:e=>e}),i=JSON.stringify(t,void 0,2),s=document.createElement("script");s.type="importmap",s.setAttribute("nonce","0c6a828f1297"),s.textContent=r?.createScript(i)??i,document.head.appendChild(s),performance.mark("code/didAddCssLoader")}}(r,l);try{const e=await import(new URL(`${n}.js`,l).href);return c&&s&&c(),{result:e,configuration:r}}catch(o){throw function(o,n){n&&e.ipcRenderer.send("vscode:openDevTools"),o&&"string"!=typeof o&&o.stack}(o,i&&!a),o}}}}()</script></body></html>

Target/Worker.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import"@codeeditorland/output/Target/Microsoft/VSCode/vs/code/electron-sandbox/workbench/workbench.js";

Target/_astro/Application.astro_astro_type_script_index_0_lang.D_QlNiAb.js renamed to Target/_astro/Application.astro_astro_type_script_index_2_lang.6Wq4vJ4r.js

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

astro.config.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import type { ViteDevServer } from "vite";
44

55
export const { readFile } = await import("fs/promises");
66

7-
export const Bundle = typeof process.env["Bundle"] !== "undefined";
7+
export const Bundle = process.env["Bundle"] === "true";
8+
9+
export const Browser = process.env["Browser"] === "true";
810

911
export const Tauri = typeof process.env["TAURI_ENV_ARCH"] !== "undefined";
1012

@@ -110,7 +112,13 @@ export default defineConfig({
110112

111113
build: {
112114
rollupOptions: {
113-
external: ["@microsoft/1ds-core-js", "@microsoft/1ds-post-js"],
115+
external: [
116+
"@microsoft/1ds-core-js",
117+
"@microsoft/1ds-post-js",
118+
Browser
119+
? "@codeeditorland/output/Target/Microsoft/VSCode/vs/code/electron-sandbox/workbench/workbench.js"
120+
: "",
121+
],
114122
},
115123

116124
sourcemap: On,

0 commit comments

Comments
 (0)