Skip to content

Commit be93a3d

Browse files
feat: Implement bundled workbench structure for Browser, Electron, Sessions, and base Workbench
- Introduced new entry and layout files for bundled Browser, Electron, Sessions, and base Workbench. - Refactored existing Bootstrap and ServicesProxy files to streamline error handling. - Enhanced performance measurement for various components during the bootstrapping process. - Updated astro.config.ts to support bundled workbench inputs and outputs, ensuring compatibility with existing build profiles. - Improved error handling and logging throughout the Electron and WindPreload modules. - Added new routes for bundled Browser, Electron, Sessions, and Workbench in the Astro pages. Signed-off-by: Nikola Hristov <Nikola@PlayForm.Cloud>
1 parent 5b3e6c0 commit be93a3d

23 files changed

Lines changed: 624 additions & 153 deletions

Source/Function/SkyBridge.ts

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2304,8 +2304,8 @@ export async function InstallSkyBridge(): Promise<void> {
23042304
new CustomEvent("cel:webview:set-html", { detail: Payload }),
23052305
);
23062306
if (!ViewId) return;
2307-
const Registry: Map<string, any> | undefined =
2308-
(globalThis as any).__CEL_WEBVIEW_VIEWS__;
2307+
const Registry: Map<string, any> | undefined = (globalThis as any)
2308+
.__CEL_WEBVIEW_VIEWS__;
23092309
const ParkedView = Registry?.get(ViewId);
23102310
if (!ParkedView?.webview) return;
23112311
try {
@@ -2328,12 +2328,13 @@ export async function InstallSkyBridge(): Promise<void> {
23282328
new CustomEvent("cel:webview:updateView", { detail: Payload }),
23292329
);
23302330
if (!ViewId) return;
2331-
const Registry: Map<string, any> | undefined =
2332-
(globalThis as any).__CEL_WEBVIEW_VIEWS__;
2331+
const Registry: Map<string, any> | undefined = (globalThis as any)
2332+
.__CEL_WEBVIEW_VIEWS__;
23332333
const ParkedView = Registry?.get(ViewId);
23342334
if (!ParkedView) return;
23352335
try {
2336-
if (Payload?.title != null) ParkedView.title = String(Payload.title);
2336+
if (Payload?.title != null)
2337+
ParkedView.title = String(Payload.title);
23372338
if (Payload?.description != null)
23382339
ParkedView.description = String(Payload.description);
23392340
if (Payload?.badge != null) ParkedView.badge = Payload.badge;
@@ -2357,8 +2358,8 @@ export async function InstallSkyBridge(): Promise<void> {
23572358
}),
23582359
);
23592360
if (!ViewId) return;
2360-
const Registry: Map<string, any> | undefined =
2361-
(globalThis as any).__CEL_WEBVIEW_VIEWS__;
2361+
const Registry: Map<string, any> | undefined = (globalThis as any)
2362+
.__CEL_WEBVIEW_VIEWS__;
23622363
const ParkedView = Registry?.get(ViewId);
23632364
if (!ParkedView?.webview?.postMessage) return;
23642365
try {
@@ -2451,16 +2452,13 @@ export async function InstallSkyBridge(): Promise<void> {
24512452
},
24522453
);
24532454

2454-
await Register(
2455-
"sky://webview/post-message",
2456-
({ handle, message }: any) => {
2457-
document.dispatchEvent(
2458-
new CustomEvent("cel:webview:post-message", {
2459-
detail: { handle, message },
2460-
}),
2461-
);
2462-
},
2463-
);
2455+
await Register("sky://webview/post-message", ({ handle, message }: any) => {
2456+
document.dispatchEvent(
2457+
new CustomEvent("cel:webview:post-message", {
2458+
detail: { handle, message },
2459+
}),
2460+
);
2461+
});
24642462

24652463
await Register("sky://webview/dispose", ({ panelId }: any) => {
24662464
document.dispatchEvent(
@@ -2515,9 +2513,9 @@ export async function InstallSkyBridge(): Promise<void> {
25152513
// forwards to `sky://webview/set-html` - a listener
25162514
// downstream applies the html to this parked view.
25172515
try {
2518-
const Registry: Map<string, any> =
2519-
((globalThis as any).__CEL_WEBVIEW_VIEWS__ ??=
2520-
new Map());
2516+
const Registry: Map<string, any> = ((
2517+
globalThis as any
2518+
).__CEL_WEBVIEW_VIEWS__ ??= new Map());
25212519
Registry.set(ViewId, WebviewView);
25222520
} catch (_e) {
25232521
/* ignore */
@@ -2573,8 +2571,9 @@ export async function InstallSkyBridge(): Promise<void> {
25732571
handle: Handle,
25742572
viewId: ViewId,
25752573
});
2576-
const Registry: Map<string, any> | undefined =
2577-
(globalThis as any).__CEL_WEBVIEW_VIEWS__;
2574+
const Registry: Map<string, any> | undefined = (
2575+
globalThis as any
2576+
).__CEL_WEBVIEW_VIEWS__;
25782577
Registry?.delete(ViewId);
25792578
});
25802579
} catch (_e) {

Source/Workbench/BrowserProxy/Bootstrap.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,12 @@ try {
2929
});
3030

3131
if (bootstrapResult.success) {
32-
3332
// Log individual stage results
3433
bootstrapResult.stages.forEach(function (stage: BootstrapStage) {
3534
const status = stage.success ? "✓" : "✗";
3635
});
3736
} else {
3837
}
39-
} catch (error: unknown) {
40-
}
38+
} catch (error: unknown) {}
4139

4240
export default {};

Source/Workbench/BrowserProxy/ServicesProxy.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
try {
1010
// The services proxy will intercept window.vscode API calls
1111
// and forward them to Mountain services via IPC
12-
} catch (error: unknown) {
13-
}
12+
} catch (error: unknown) {}
1413

1514
export default {};

Source/Workbench/BrowserProxy/Workbench.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ try {
2121
"__MOUNTAIN_PROXY__"
2222
];
2323
}, 2000);
24-
} catch (error: unknown) {
25-
}
24+
} catch (error: unknown) {}
2625

2726
export default {};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Bundled Browser workbench entry - Rollup graph root.
3+
*
4+
* Counterpart to Bundled/Electron/Entry.ts targeting VS Code's
5+
* `vs/code/browser/workbench/workbench.js`. See that file's header
6+
* for the shared bundled-pipeline contract.
7+
*/
8+
9+
if (typeof (globalThis as never as { __name?: unknown }).__name !== "function") {
10+
(globalThis as never as { __name: unknown }).__name = (
11+
Target: object,
12+
Value: string,
13+
) => {
14+
Object.defineProperty(Target, "name", {
15+
value: Value,
16+
configurable: true,
17+
});
18+
return Target;
19+
};
20+
}
21+
22+
(globalThis as never as { _VSCODE_FILE_ROOT?: string })._VSCODE_FILE_ROOT ??=
23+
new URL("./", import.meta.url).href;
24+
25+
(globalThis as never as { _VSCODE_PRODUCT_JSON?: object })._VSCODE_PRODUCT_JSON ??=
26+
{};
27+
28+
performance.mark("land:bundled:browser:start");
29+
30+
await import(
31+
"@codeeditorland/output/vs/code/browser/workbench/workbench"
32+
);
33+
34+
performance.mark("land:bundled:browser:imported");
35+
performance.measure(
36+
"land:bundled:browser:import",
37+
"land:bundled:browser:start",
38+
"land:bundled:browser:imported",
39+
);
40+
41+
export default {};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
/**
3+
* Bundled Browser Workbench Layout.
4+
* Counterpart to Bundled/Electron/Layout.astro - see header there.
5+
*/
6+
7+
import NLS from "../../NLS.astro";
8+
import TelemetryBridge from "../../TelemetryBridge.astro";
9+
---
10+
11+
<Fragment>
12+
<NLS />
13+
<TelemetryBridge />
14+
15+
<script>
16+
import "./Entry";
17+
</script>
18+
</Fragment>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/**
2+
* Bundled Electron workbench entry - Rollup graph root.
3+
*
4+
* Sky's astro.config.ts maps `BUNDLED_WORKBENCHES` (set by the
5+
* release-electron-bundled / debug-electron-bundled profile) to a
6+
* `vite.build.rollupOptions.input` entry pointing at this file. Rollup
7+
* follows the static `import` below and pulls every transitive `.js` /
8+
* `.css` through Vite's native pipeline - tree-shake, chunk dedup,
9+
* CSS extraction with hashed filenames, the lot.
10+
*
11+
* Import target:
12+
* `@codeeditorland/output/vs/code/electron-browser/workbench/workbench`
13+
*
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
18+
* Rollup sees real files when it walks the module graph.
19+
*
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+
*
25+
* Globals required by VS Code before workbench.js loads:
26+
* - `_VSCODE_FILE_ROOT` - origin/path the desktop loader dereferences
27+
* - `_VSCODE_PRODUCT_JSON` - product metadata (defaulted empty)
28+
* - `__name` - esbuild's name-shim (set by the existing Blob patch
29+
* on the non-bundled path; reproduced here for parity)
30+
*
31+
* Diagnostic timing marks share the `land:bundled:*` namespace so the
32+
* benchmarking pass can subtract them from `land:wb:*` for the
33+
* non-bundled comparison.
34+
*/
35+
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+
49+
(globalThis as never as { _VSCODE_FILE_ROOT?: string })._VSCODE_FILE_ROOT ??=
50+
new URL("./", import.meta.url).href;
51+
52+
(globalThis as never as { _VSCODE_PRODUCT_JSON?: object })._VSCODE_PRODUCT_JSON ??=
53+
{};
54+
55+
performance.mark("land:bundled:electron:start");
56+
57+
await import(
58+
"@codeeditorland/output/vs/code/electron-browser/workbench/workbench"
59+
);
60+
61+
performance.mark("land:bundled:electron:imported");
62+
performance.measure(
63+
"land:bundled:electron:import",
64+
"land:bundled:electron:start",
65+
"land:bundled:electron:imported",
66+
);
67+
68+
export default {};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
/**
3+
* Bundled Electron Workbench Layout.
4+
*
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/.
8+
*
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" .
16+
*/
17+
18+
import NLS from "../../NLS.astro";
19+
import TelemetryBridge from "../../TelemetryBridge.astro";
20+
---
21+
22+
<Fragment>
23+
<NLS />
24+
<TelemetryBridge />
25+
26+
<script>
27+
import "./Entry";
28+
</script>
29+
</Fragment>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Bundled Sessions workbench entry - Rollup graph root.
3+
*
4+
* Counterpart to Bundled/Electron/Entry.ts targeting the Sessions
5+
* workbench shape at `vs/sessions/browser/workbench.js`. The Sessions
6+
* tree is Land-specific (not present in stock VS Code's `out-build`);
7+
* adjust the import target if the on-disk path differs.
8+
*/
9+
10+
if (typeof (globalThis as never as { __name?: unknown }).__name !== "function") {
11+
(globalThis as never as { __name: unknown }).__name = (
12+
Target: object,
13+
Value: string,
14+
) => {
15+
Object.defineProperty(Target, "name", {
16+
value: Value,
17+
configurable: true,
18+
});
19+
return Target;
20+
};
21+
}
22+
23+
(globalThis as never as { _VSCODE_FILE_ROOT?: string })._VSCODE_FILE_ROOT ??=
24+
new URL("./", import.meta.url).href;
25+
26+
(globalThis as never as { _VSCODE_PRODUCT_JSON?: object })._VSCODE_PRODUCT_JSON ??=
27+
{};
28+
29+
performance.mark("land:bundled:sessions:start");
30+
31+
await import(
32+
"@codeeditorland/output/vs/sessions/browser/workbench"
33+
);
34+
35+
performance.mark("land:bundled:sessions:imported");
36+
performance.measure(
37+
"land:bundled:sessions:import",
38+
"land:bundled:sessions:start",
39+
"land:bundled:sessions:imported",
40+
);
41+
42+
export default {};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
/**
3+
* Bundled Sessions Workbench Layout.
4+
* Counterpart to Bundled/Electron/Layout.astro - see header there.
5+
*/
6+
7+
import NLS from "../../NLS.astro";
8+
import TelemetryBridge from "../../TelemetryBridge.astro";
9+
---
10+
11+
<Fragment>
12+
<NLS />
13+
<TelemetryBridge />
14+
15+
<script>
16+
import "./Entry";
17+
</script>
18+
</Fragment>

0 commit comments

Comments
 (0)