()
| 223 | }); |
| 224 | |
| 225 | const _launchApp = async () => { |
| 226 | await _trackStats(); |
| 227 | let window: BrowserWindow; |
| 228 | // Handle URLs sent via command line args |
| 229 | ipcMainOnce('halfSecondAfterAppStart', () => { |
| 230 | console.log('[main] Window ready, handling command line arguments', process.argv); |
| 231 | const args = process.argv.slice(1).filter(a => a !== '.'); |
| 232 | console.log('[main] Check args and create windows', args); |
| 233 | if (args.length) { |
| 234 | window = windowUtils.createWindowsAndReturnMain(); |
| 235 | window.webContents.send('shell:open', args.join(',')); |
| 236 | } |
| 237 | }); |
| 238 | // Disable deep linking in playwright e2e tests in order to run multiple tests in parallel |
| 239 | if (!process.env.PLAYWRIGHT_TEST) { |
| 240 | // Deep linking logic - https://www.electronjs.org/docs/latest/tutorial/launch-app-from-url-in-another-app |
| 241 | const gotTheLock = app.requestSingleInstanceLock(); |
| 242 | if (!gotTheLock) { |
| 243 | console.error('[app] Failed to get instance lock'); |
| 244 | app.quit(); |
| 245 | } else { |
| 246 | // Called when second instance launched with args (Windows/Linux) |
| 247 | app.on('second-instance', (_1, args) => { |
| 248 | console.log('[main] Second instance listener received:', args.join('||')); |
| 249 | window = windowUtils.createWindowsAndReturnMain(); |
| 250 | if (window) { |
| 251 | if (window.isMinimized()) { |
| 252 | window.restore(); |
| 253 | } |
| 254 | window.focus(); |
| 255 | } |
| 256 | const lastArg = args.slice(-1).join(','); |
| 257 | console.log('[main] Open Deep Link URL sent from second instance', lastArg); |
| 258 | window.webContents.send('shell:open', lastArg); |
| 259 | }); |
| 260 | window = windowUtils.createWindowsAndReturnMain(); |
| 261 | |
| 262 | openDeepLinkUrl = async (url: string) => { |
| 263 | console.log('[main] Open Deep Link URL', url); |
| 264 | window = windowUtils.createWindowsAndReturnMain(); |
| 265 | if (window) { |
| 266 | if (window.isMinimized()) { |
| 267 | window.restore(); |
| 268 | } |
| 269 | window.focus(); |
| 270 | } else { |
| 271 | window = windowUtils.createWindowsAndReturnMain(); |
| 272 | } |
| 273 | return window.webContents.send('shell:open', url); |
| 274 | }; |
| 275 | |
| 276 | app.on('open-url', (_event, url) => { |
| 277 | openDeepLinkUrl(url); |
| 278 | }); |
| 279 | ipcMainOn('openDeepLink', (_event, url) => { |
| 280 | openDeepLinkUrl(url); |
| 281 | }); |
| 282 | } |
no test coverage detected