@@ -52,40 +52,36 @@ app.whenReady().then(() => {
5252
5353 // Register the custom protocol to serve Monaco Editor worker files locally
5454 protocol . handle ( "monaco-editor" , ( request ) => {
55- const url = request . url . substr ( "monaco-editor://" . length ) ; // e.g., "vs/editor/editor.main.js" or "ts.worker.js"
55+ const url = request . url . substr ( "monaco-editor://" . length ) ;
5656
5757 let monacoBasePath ;
5858 if ( is . dev ) {
59- // In development, node_modules is usually outside the bundled app path
60- // __dirname in main.ts is like dist-electron, so ../../node_modules
59+ // Adjust this path based on your dev setup relative to dist-electron/main/index.js
6160 monacoBasePath = join ( __dirname , "../../node_modules/monaco-editor/min" ) ;
6261 } else {
63- // In a packaged app, node_modules content is often copied to a resources folder
64- // or directly into the app.asar. Adjust this path based on your build script.
65- // A common pattern is to copy 'node_modules/monaco-editor/min' to 'resources/app.asar/monaco-editor-min'
66- // or similar. For simplicity, let's assume it's directly accessible relative to app.getAppPath().
67- // If it's copied directly into the root of your packaged app:
62+ // Adjust this path based on where 'monaco-editor/min' is copied in your packaged app.
63+ // Common paths:
64+ // If monaco-editor/min is copied to the root of your packaged app:
6865 monacoBasePath = join ( app . getAppPath ( ) , "node_modules/monaco-editor/min" ) ;
69- // Or if your build copies it to a specific subfolder like 'assets/monaco':
66+ // If it's copied to a specific asset folder like 'assets/monaco':
7067 // monacoBasePath = join(app.getAppPath(), 'assets', 'monaco');
7168 }
7269
7370 const filePath = join ( monacoBasePath , url ) ;
74- console . log ( "Serving monaco-editor:// file:" , filePath ) ; // Log for debugging
71+ console . log ( "Serving monaco-editor:// file:" , filePath ) ; // Keep this for debugging!
7572
7673 if ( existsSync ( filePath ) ) {
7774 return new Response ( readFileSync ( filePath ) ) ;
7875 } else {
79- console . error ( "Monaco Editor worker/script file not found:" , filePath ) ;
76+ console . error ( "Monaco Editor file not found:" , filePath ) ;
77+ // It's crucial to return a proper 404 or an empty response for missing files.
78+ // Returning a null or undefined can cause issues.
8079 return new Response ( "File not found" , { status : 404 } ) ;
8180 }
8281 } ) ;
8382 // Set app user model id for windows
8483 electronApp . setAppUserModelId ( "com.executeme" ) ;
8584
86- // Default open or close DevTools by F12 in development
87- // and ignore CommandOrControl + R in production.
88- // see https://github.com/alex8088/electron-toolkit/tree/master/packages/utils
8985 app . on ( "browser-window-created" , ( _ , window ) => {
9086 optimizer . watchWindowShortcuts ( window ) ;
9187 } ) ;
@@ -96,15 +92,10 @@ app.whenReady().then(() => {
9692 createWindow ( ) ;
9793
9894 app . on ( "activate" , function ( ) {
99- // On macOS it's common to re-create a window in the app when the
100- // dock icon is clicked and there are no other windows open.
10195 if ( BrowserWindow . getAllWindows ( ) . length === 0 ) createWindow ( ) ;
10296 } ) ;
10397} ) ;
10498
105- // Quit when all windows are closed, except on macOS. There, it's common
106- // for applications and their menu bar to stay active until the user quits
107- // explicitly with Cmd + Q.
10899app . on ( "window-all-closed" , ( ) => {
109100 if ( process . platform !== "darwin" ) {
110101 app . quit ( ) ;
0 commit comments