diff options
Diffstat (limited to 'packages/main/src/index.ts')
-rw-r--r-- | packages/main/src/index.ts | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/packages/main/src/index.ts b/packages/main/src/index.ts index ff14332..7c6bfd5 100644 --- a/packages/main/src/index.ts +++ b/packages/main/src/index.ts | |||
@@ -42,6 +42,7 @@ import { URL } from 'url'; | |||
42 | 42 | ||
43 | import { init } from './compositionRoot.js'; | 43 | import { init } from './compositionRoot.js'; |
44 | import { | 44 | import { |
45 | DEVMODE_ALLOWED_URL_PREFIXES, | ||
45 | installDevToolsExtensions, | 46 | installDevToolsExtensions, |
46 | openDevToolsWhenReady, | 47 | openDevToolsWhenReady, |
47 | } from './devTools.js'; | 48 | } from './devTools.js'; |
@@ -73,14 +74,6 @@ app.commandLine.appendSwitch( | |||
73 | 'HardwareMediaKeyHandling,MediaSessionService', | 74 | 'HardwareMediaKeyHandling,MediaSessionService', |
74 | ); | 75 | ); |
75 | 76 | ||
76 | // It doesn't seem to cause a race condition to start installing the extensions this early. | ||
77 | if (isDevelopment) { | ||
78 | app.whenReady().then(installDevToolsExtensions).catch((err) => { | ||
79 | console.error('Failed to install devtools extensions', err); | ||
80 | process.exit(1); | ||
81 | }); | ||
82 | } | ||
83 | |||
84 | // Remove sophie and electron from the user-agent string to avoid detection. | 77 | // Remove sophie and electron from the user-agent string to avoid detection. |
85 | const originalUserAgent = app.userAgentFallback; | 78 | const originalUserAgent = app.userAgentFallback; |
86 | const userAgent = originalUserAgent.replaceAll(/\s(sophie|Electron)\/\S+/g, ''); | 79 | const userAgent = originalUserAgent.replaceAll(/\s(sophie|Electron)\/\S+/g, ''); |
@@ -127,7 +120,7 @@ function shouldCancelMainWindowRequest(url: string, method: string): boolean { | |||
127 | return true; | 120 | return true; |
128 | } | 121 | } |
129 | if (isDevelopment) { | 122 | if (isDevelopment) { |
130 | if (normalizedUrl.startsWith('devtools:') || normalizedUrl.startsWith('chrome-extension:')) { | 123 | if (DEVMODE_ALLOWED_URL_PREFIXES.some((prefix) => normalizedUrl.startsWith(prefix))) { |
131 | return false; | 124 | return false; |
132 | } | 125 | } |
133 | if (import.meta.env.VITE_DEV_SERVER_URL !== undefined) { | 126 | if (import.meta.env.VITE_DEV_SERVER_URL !== undefined) { |
@@ -315,7 +308,17 @@ app.on('window-all-closed', () => { | |||
315 | } | 308 | } |
316 | }); | 309 | }); |
317 | 310 | ||
318 | app.whenReady().then(createWindow).catch((err) => { | 311 | app.whenReady().then(async () => { |
312 | if (isDevelopment) { | ||
313 | try { | ||
314 | await installDevToolsExtensions(); | ||
315 | } catch (err) { | ||
316 | console.error('Failed to install devtools extensions', err); | ||
317 | } | ||
318 | } | ||
319 | |||
320 | return createWindow(); | ||
321 | }).catch((err) => { | ||
319 | console.error('Failed to create window', err); | 322 | console.error('Failed to create window', err); |
320 | process.exit(1); | 323 | process.exit(1); |
321 | }); | 324 | }); |