Skip to content

Commit 8963447

Browse files
refactor(Sky): Update Output import paths and rename environment variables
Restructure Output package imports to use explicit `Target/Microsoft/VSCode` paths instead of the legacy `@codeeditorland/output/vs/**` alias. This enables Vite/Rollup to follow the static import graph for bundled workbenches and eliminates the package-exports-map indirection. Additionally rename environment variables from `LAND_*` and compound names to PascalCase identifiers matching the CLAUDE.md convention: - `LAND_DEV_LOG` → `Trace` - `LAND_ENABLE_WIND` → `Render` - `LAND_POSTHOG_*` → `Authorize`, `Beam`, `Report`, `Throttle`, `Buffer`, `Batch`, `Replay`, `Ask`, `Brand` - `BUNDLED_WORKBENCHES` → `Pack` - `LAND_BUNDLED_BOOT` → `Boot` - `LAND_SKIP_BUILTIN_EXTENSIONS` → `Skip` - `LAND_AUTO_INSTALL_EXTENSION_DEPS` → `Install` - `LAND_WARN_MISSING_BROWSER_BUNDLES` → `Warn` - `__LAND_CEL_TRACK__` → `__Track` - `_LAND_ERROR_HOOK` → `_Catch` The bundled Electron layout now includes the full Preload → Polyfills → Bootstrap chain (previously omitted), and SkyBridge is wired after the bundled workbench import to ensure event consumers attach before workbench starts.
1 parent 51e34d3 commit 8963447

16 files changed

Lines changed: 198 additions & 119 deletions

File tree

Source/Function/Debug.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const Host =
2727
// Used in optimizeDeps.exclude
2828
export const Link = [
2929
"@codeeditorland/output",
30-
"@codeeditorland/output/vs",
30+
"@codeeditorland/output/Target/Microsoft/VSCode/vs",
3131
"monaco-editor",
3232
];
3333

Source/Function/SkyBridge.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const _HasDOM =
6363
typeof globalThis !== "undefined" &&
6464
typeof (globalThis as any).document !== "undefined";
6565
let _CelTrackingActive = false;
66-
if (_HasDOM && !(globalThis as any).__LAND_CEL_TRACK__) {
66+
if (_HasDOM && !(globalThis as any).__Track) {
6767
try {
6868
const TargetDocument = (globalThis as any).document as Document;
6969
const OriginalAdd =
@@ -87,7 +87,7 @@ if (_HasDOM && !(globalThis as any).__LAND_CEL_TRACK__) {
8787
return OriginalAdd(Type, Listener as EventListener, Options);
8888
},
8989
});
90-
(globalThis as any).__LAND_CEL_TRACK__ = true;
90+
(globalThis as any).__Track = true;
9191
_CelTrackingActive = true;
9292
} catch {
9393
_CelTrackingActive = false;
@@ -1467,12 +1467,12 @@ export async function InstallSkyBridge(): Promise<void> {
14671467
// failed to resolve). Silently fall back to the
14681468
// CustomEvent path - any Sky-side component listening on
14691469
// `cel:scm:register` still gets the data. The
1470-
// `LAND_DEV_LOG=cel-scm` gate surfaces the underlying
1470+
// `Trace=cel-scm` gate surfaces the underlying
14711471
// reason without spamming the renderer console on every
14721472
// register.
14731473
try {
14741474
const W = globalThis as any;
1475-
if (W?.process?.env?.LAND_DEV_LOG?.includes?.("cel-scm")) {
1475+
if (W?.process?.env?.Trace?.includes?.("cel-scm")) {
14761476
(W.console || console).warn(
14771477
`[Sky:CEL-SCM] registerSCMProvider failed for "${ScmId}": ${
14781478
(Error as { message?: string })?.message ??
@@ -1615,7 +1615,7 @@ export async function InstallSkyBridge(): Promise<void> {
16151615
} catch (Error) {
16161616
try {
16171617
const W = globalThis as any;
1618-
if (W?.process?.env?.LAND_DEV_LOG?.includes?.("cel-scm")) {
1618+
if (W?.process?.env?.Trace?.includes?.("cel-scm")) {
16191619
(W.console || console).warn(
16201620
`[Sky:CEL-SCM] registerGroup failed for "${GroupId}": ${
16211621
(Error as { message?: string })?.message ??
@@ -2664,7 +2664,7 @@ export async function InstallSkyBridge(): Promise<void> {
26642664
try {
26652665
const W = globalThis as any;
26662666
if (
2667-
W?.process?.env?.LAND_DEV_LOG?.includes?.(
2667+
W?.process?.env?.Trace?.includes?.(
26682668
"cel-customeditor",
26692669
)
26702670
) {

Source/Workbench/Bundled/Browser/Entry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if (typeof (globalThis as never as { __name?: unknown }).__name !== "function")
2828
performance.mark("land:bundled:browser:start");
2929

3030
await import(
31-
"@codeeditorland/output/vs/code/browser/workbench/workbench"
31+
"@codeeditorland/output/Target/Microsoft/VSCode/vs/code/browser/workbench/workbench.js"
3232
);
3333

3434
performance.mark("land:bundled:browser:imported");

Source/Workbench/Bundled/Electron/Entry.ts

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,16 @@
99
* CSS extraction with hashed filenames, the lot.
1010
*
1111
* Import target:
12-
* `@codeeditorland/output/vs/code/electron-browser/workbench/workbench`
12+
* `@codeeditorland/output/Target/Microsoft/VSCode/vs/code/
13+
* electron-browser/workbench/workbench.js`
1314
*
14-
* The Output package's `exports` map (`"./*"` ->
15-
* `./Target/Microsoft/VSCode/*.js`) resolves this through
16-
* `node_modules/@codeeditorland/output/Target/...`. Output's own
17-
* prepublishOnly populates that tree before Sky's Vite step runs, so
15+
* No package-exports-map indirection: the path is the on-disk path
16+
* inside the Output package. The same shape works locally
17+
* (`../../../../../Output/Target/Microsoft/VSCode/vs/.../workbench.js`)
18+
* once the monorepo waterfall populates Output's Target. Output's
19+
* prepublishOnly runs before Sky's Vite step (Turbo task graph), so
1820
* Rollup sees real files when it walks the module graph.
1921
*
20-
* Using the package specifier (not a relative path into Dependency/)
21-
* means the existing `Static/Application/` pipeline is untouched -
22-
* Sky's `astro:build:done` still copies + transforms the same files
23-
* for the non-bundled boot path.
24-
*
2522
* Globals required by VS Code before workbench.js loads:
2623
* - `_VSCODE_FILE_ROOT` - origin/path the desktop loader dereferences
2724
* - `_VSCODE_PRODUCT_JSON` - product metadata (defaulted empty)
@@ -33,29 +30,55 @@
3330
* non-bundled comparison.
3431
*/
3532

36-
if (typeof (globalThis as never as { __name?: unknown }).__name !== "function") {
37-
(globalThis as never as { __name: unknown }).__name = (
38-
Target: object,
39-
Value: string,
40-
) => {
41-
Object.defineProperty(Target, "name", {
42-
value: Value,
43-
configurable: true,
44-
});
45-
return Target;
46-
};
47-
}
48-
33+
// `__name` shim, WKWebView polyfills (requestIdleCallback, cancelIdle
34+
// Callback, queryLocalFonts), and Blob worker URL rewrite are now
35+
// injected directly into VS Code's `vs/code/electron-browser/workbench
36+
// /workbench.js` by Output's `InjectWebViewPolyfills` transform plugin
37+
// (runs at Output's prepublishOnly tail). Both Sky paths consume the
38+
// same pre-shimmed file, so this Entry only needs to set the VS Code
39+
// loader globals before kicking off the workbench import.
40+
//
41+
// `_VSCODE_FILE_ROOT` is the base URL the workbench bootstrap uses to
42+
// resolve runtime `await import(computedURL)` chains - e.g.
43+
// `vs/workbench/workbench.desktop.main.js`. Vite/Rollup cannot follow
44+
// computed-string dynamic imports, so those land at runtime regardless
45+
// of the bundled chunk. Pin to `/Static/Application/` (Sky's existing
46+
// pipeline still produces this tree even in bundled profiles) so
47+
// runtime resolutions hit real files instead of `_astro/vs/...` 404s.
4948
(globalThis as never as { _VSCODE_FILE_ROOT?: string })._VSCODE_FILE_ROOT ??=
50-
new URL("./", import.meta.url).href;
49+
`${window.location.origin}/Static/Application/`;
5150

5251
(globalThis as never as { _VSCODE_PRODUCT_JSON?: object })._VSCODE_PRODUCT_JSON ??=
5352
{};
5453

5554
performance.mark("land:bundled:electron:start");
5655

56+
// Pre-import the workbench's desktop entry shim with a LITERAL string so
57+
// Vite/Rollup follows desktop.main.js's static import graph (~1500
58+
// modules: contrib/*, services/*, platform/*, base/*, editor/*) and
59+
// pulls them into the bundled chunk. Without this, only workbench.js
60+
// + its small synchronous graph land in the bundle (~26 MB), and the
61+
// workbench loader's runtime `await import(computedURL)` resolves
62+
// against `/Static/Application/` - re-fetching ~1500 separate files
63+
// from disk every cold boot.
64+
//
65+
// The browser's module cache deduplicates: when workbench.js later
66+
// runs `await import("vs/workbench/workbench.desktop.main.js")` the
67+
// resolved URL hits the same cache entry as the static import here,
68+
// so order-of-execution is preserved (desktop.main.js side-effects
69+
// happen first, registering DI services; workbench.js then runs
70+
// `result.main(configuration)` against the registered surface).
71+
//
72+
// `workbench.web.main.internal.js` is statically imported by
73+
// `workbench.web.main.js`, which `workbench.desktop.main.js` shares
74+
// many modules with - Rollup chunk-deduplicates so we're not paying
75+
// the import twice.
76+
await import(
77+
"@codeeditorland/output/Target/Microsoft/VSCode/vs/workbench/workbench.desktop.main.js"
78+
);
79+
5780
await import(
58-
"@codeeditorland/output/vs/code/electron-browser/workbench/workbench"
81+
"@codeeditorland/output/Target/Microsoft/VSCode/vs/code/electron-browser/workbench/workbench.js"
5982
);
6083

6184
performance.mark("land:bundled:electron:imported");

Source/Workbench/Bundled/Electron/Layout.astro

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22
/**
33
* Bundled Electron Workbench Layout.
44
*
5-
* Loads the Vite/Astro-bundled entry. Vite resolves
6-
* `./Entry.ts` through Rollup, hashes the output, and emits the
7-
* resulting JS / CSS under Sky/Target/Static/Bundled/Electron/.
5+
* Loads the Vite/Astro-bundled entry. Vite resolves `./Entry.ts`
6+
* through Rollup, hashes the output, and the resulting JS / CSS
7+
* land under Sky/Target/_astro/workbench-[hash].{js,css}.
88
*
9-
* Unlike the non-bundled `Workbench/Electron/Layout.astro`, this layout
10-
* does NOT chain Wind Preload / Polyfills / Bootstrap / Workbench /
11-
* SkyBridge - the bundled entry is a single Rollup graph root, and
12-
* the auxiliary preload chain is not required for the load-time
13-
* benchmark this profile targets. Re-introduce them once the bundled
14-
* tree is functional and we move from "measure cold load" to "wire up
15-
* the runtime" .
9+
* Same Preload -> Polyfills -> Bootstrap chain as the non-bundled
10+
* ../Electron/Layout.astro, only the workbench step is bundled. The
11+
* chain is required because VS Code's workbench module reads
12+
* globalThis.process / window.vscode / etc. before its own module
13+
* code runs - without the polyfills it crashes with
14+
* `TypeError: undefined is not an object (evaluating 'p.process')`.
15+
*
16+
* SkyBridge is wired after the bundled workbench import resolves so
17+
* its Tauri event consumers attach before the workbench starts
18+
* pumping events.
1619
*/
1720
1821
import NLS from "../../NLS.astro";
@@ -23,7 +26,23 @@ import TelemetryBridge from "../../TelemetryBridge.astro";
2326
<NLS />
2427
<TelemetryBridge />
2528

26-
<script>
27-
import "./Entry";
29+
<!-- Sequential: Preload -> Polyfills -> Bootstrap -> Entry (bundled workbench) -> SkyBridge -->
30+
<script type="module">
31+
await import("../../Electron/WindPreload.js");
32+
await import("../../Electron/Polyfills.js");
33+
await import("../../Electron/Bootstrap.js");
34+
await import("./Entry.js");
35+
36+
try {
37+
const { InstallSkyBridge } = await import(
38+
"@codeeditorland/sky/Source/Function/SkyBridge"
39+
);
40+
await InstallSkyBridge();
41+
performance.mark("land:bundled:electron:skybridge:installed");
42+
} catch (Error) {
43+
performance.mark("land:bundled:electron:skybridge:error");
44+
// eslint-disable-next-line no-console
45+
console.warn("[Bundled/Electron/Layout.astro] InstallSkyBridge failed:", Error);
46+
}
2847
</script>
2948
</Fragment>

Source/Workbench/Bundled/Sessions/Entry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if (typeof (globalThis as never as { __name?: unknown }).__name !== "function")
2929
performance.mark("land:bundled:sessions:start");
3030

3131
await import(
32-
"@codeeditorland/output/vs/sessions/browser/workbench"
32+
"@codeeditorland/output/Target/Microsoft/VSCode/vs/sessions/browser/workbench.js"
3333
);
3434

3535
performance.mark("land:bundled:sessions:imported");

Source/Workbench/Bundled/Workbench/Entry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if (typeof (globalThis as never as { __name?: unknown }).__name !== "function")
2929
performance.mark("land:bundled:workbench:start");
3030

3131
await import(
32-
"@codeeditorland/output/vs/workbench/browser/workbench"
32+
"@codeeditorland/output/Target/Microsoft/VSCode/vs/workbench/browser/workbench.js"
3333
);
3434

3535
performance.mark("land:bundled:workbench:imported");

Source/Workbench/Electron/Bootstrap.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
* Effect-TS bootstrap for Electron workbench (A3).
33
* Zero console.* output. Results captured via performance.mark().
44
*
5-
* Atom N2: when `LAND_ENABLE_WIND` is false at build time, the Wind
5+
* Atom N2: when `Render` is false at build time, the Wind
66
* bootstrap is replaced with a single performance-mark so the workbench
77
* loads the native VS Code stack with no Effect-TS service layer on top.
88
* Useful for "Mountain + bare workbench" integration tests and for the
99
* smallest shippable surface where gRPC/Tauri IPC isn't desired.
1010
*
11-
* Vite inlines `import.meta.env.LAND_ENABLE_WIND` at build time - the
11+
* Vite inlines `import.meta.env.Render` at build time - the
1212
* inline comparison drops the entire import chain when the flag is
1313
* `"false"`, so tree-shaking removes the Wind bundle from production.
1414
*/
@@ -26,7 +26,7 @@ interface BootstrapResult {
2626
error?: unknown;
2727
}
2828

29-
if (import.meta.env["LAND_ENABLE_WIND"] === "false") {
29+
if (import.meta.env["Render"] === "false") {
3030
performance.mark("land:bootstrap:skipped-wind-disabled");
3131
} else {
3232
try {

Source/Workbench/Electron/ExtensionChangeSubscriber.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* when available. The hook isn't always present (browser / kernel
1919
* profiles omit it); when missing we just log and move on.
2020
*
21-
* No-op when `LAND_ENABLE_WIND === "false"` - if the Wind runtime is
21+
* No-op when `Render === "false"` - if the Wind runtime is
2222
* not loaded there's no IPC to subscribe to.
2323
*/
2424

@@ -60,7 +60,7 @@ const TryRefreshWorkbench = (Change: ExtensionChangeBase): void => {
6060
};
6161

6262
export default async (): Promise<void> => {
63-
if (import.meta.env["LAND_ENABLE_WIND"] === "false") {
63+
if (import.meta.env["Render"] === "false") {
6464
performance.mark("land:extensions:subscriber:skipped-wind-disabled");
6565
return;
6666
}

Source/Workbench/Electron/OTELBridge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Build-baked OTEL bridge.
33
*
44
* Guarded by import.meta.env.DEV - Vite dead-code-eliminates in production.
5-
* No runtime SDK, no window.__LAND_DEV_LOG checks.
5+
* No runtime SDK, no window.__Trace checks.
66
*
77
* How it works:
88
* 1. PerformanceObserver watches all `land:*` marks and measures

0 commit comments

Comments
 (0)