11/**
22 * @module Function/Install/Function/Install
3- * @description
4- * Main entry point for Wind polyfill installation.
5- * Creates and attaches Electron API shims to window.vscode that Electron workbench expects.
63 *
7- * @responsibilities
8- * - Validates window context and prevents double initialization
9- * - Creates VSCode-compatible globals with proper typing
10- * - Handles Mountain backend communication with graceful degradation
11- * - Implements Electron-like IPC subsystem with Tauri
12- * - Provides comprehensive error handling and cleanup
4+ * Main entry point for Wind polyfill installation.
5+ * Creates and attaches Electron API shims to window.vscode.
136 *
14- * @see {@link Function/Install/Function/ResolveConfiguration } Configuration resolver
15- * @see {@link Function/Install/Function/CreateIPCRenderer } IPC renderer factory
16- * @see {@link Function/Install/Function/CreateProcess } Process factory
17- * @category Function
7+ * Zero console.* output. Dev tracing via performance.mark().
188 */
199
2010import type { IMainWindowSandboxGlobals } from "@codeeditorland/output/vs/base/parts/sandbox/electron-browser/globals" ;
@@ -24,21 +14,14 @@ import { CreateProcess } from "./CreateProcess.js";
2414import { Fallback } from "./Fallback.js" ;
2515import { ResolveConfiguration } from "./ResolveConfiguration.js" ;
2616
27- /**
28- * Main Wind preload installation function
29- */
17+ const _Trace = ( Message : string ) : void => {
18+ try { performance . mark ( `land:install:${ Message } ` ) ; } catch { }
19+ } ;
20+
3021export default async function Install ( ) : Promise < void > {
3122 try {
32- // Validate window context
33- if ( typeof window === "undefined" ) {
34- const error = new Error (
35- "Cannot install Wind polyfill: window is not defined" ,
36- ) ;
37- console . error ( error ) ;
38- return ;
39- }
23+ if ( typeof window === "undefined" ) return ;
4024
41- // Prevent double initialization
4225 if (
4326 ( window as unknown as { polyfillInstalled ?: boolean } )
4427 . polyfillInstalled
@@ -49,25 +32,20 @@ export default async function Install(): Promise<void> {
4932 window as unknown as { polyfillInstalled : boolean }
5033 ) . polyfillInstalled = true ;
5134
52- console . log ( "[Wind] Starting Wind preload installation... ") ;
35+ _Trace ( "start ") ;
5336
54- // Initialize core components
5537 const Configuration = await ResolveConfiguration ( ) ;
5638 const IPCRenderer = CreateIPCRenderer ( ) ;
5739 const Process = CreateProcess ( Configuration ) ;
5840
59- // Create preload globals object that will be enhanced by Effect-TS
6041 const preloadGlobals = {
6142 ipcRenderer : IPCRenderer ,
6243 process : Process ,
6344 configuration : Configuration ,
6445 } ;
6546
66- // Attach preloadGlobals to window for Effect-TS services to access
6747 ( window as any ) . preloadGlobals = preloadGlobals ;
68- console . log ( "[Wind] preloadGlobals attached to window" ) ;
6948
70- // Construct compliant VSCode API object
7149 const Globals : IMainWindowSandboxGlobals = {
7250 ipcRenderer : IPCRenderer ,
7351 process : Process ,
@@ -79,13 +57,8 @@ export default async function Install(): Promise<void> {
7957 webUtils : { getPathForFile : ( file : File ) => file . name } ,
8058 ipcMessagePort : {
8159 acquire : ( ResponseChannel : string , Nonce : string ) => {
82- console . log (
83- `[Wind] MessagePort acquire: ${ ResponseChannel } , nonce=${ Nonce } ` ,
84- ) ;
60+ _Trace ( `acquire:${ ResponseChannel } ` ) ;
8561
86- // Only do the extension host handshake for the ext host channel.
87- // Other acquires (utility process workers, file watchers) get a
88- // port but no protocol — their stubs never resolve, so no crash.
8962 const IsExtensionHost = ResponseChannel . includes (
9063 "startExtensionHostMessagePortResult" ,
9164 ) ;
@@ -107,34 +80,23 @@ export default async function Install(): Promise<void> {
10780 : 0 ;
10881 if ( Length > 1 ) {
10982 Done = true ;
110- console . log (
111- "[Wind] Extension host: received init data, sending Initialized" ,
112- ) ;
11383 port1 . postMessage ( new Uint8Array ( [ 1 ] ) ) ;
11484 }
11585 } ;
11686 setTimeout ( ( ) => {
117- console . log (
118- "[Wind] Extension host: sending Ready" ,
119- ) ;
12087 port1 . postMessage ( new Uint8Array ( [ 2 ] ) ) ;
12188 } , 50 ) ;
12289 }
12390 } ,
12491 } ,
12592 } ;
12693
127- // Attach to window
12894 ( window as any ) . vscode = Globals ;
129- console . info (
130- "[Wind] Successfully installed Electron API polyfill for workbench." ,
131- ) ;
132-
133- // Signal that preload is ready for Effect-TS bootstrap
13495 ( window as any ) . __WIND_PRELOAD_READY__ = true ;
135- console . log ( "[Wind] Preload ready, Effect-TS bootstrap can proceed" ) ;
96+
97+ _Trace ( "done" ) ;
13698 } catch ( error : unknown ) {
137- console . error ( `[Wind] Install error:` , error ) ;
99+ try { performance . mark ( `land:install: error` ) ; } catch { }
138100 Fallback ( ) ;
139101 }
140102}
0 commit comments