CI / quality (push) Failing after 6m22s
Implements Max_Code_Quality_CICD_Production.md: TypeScript strict mode, ESLint flat config with type-checking and security plugin, Prettier, Husky + lint-staged, Vitest with 80%+ coverage (473 tests), Playwright e2e, Electron security hardening (contextIsolation, CSP, IPC validation), electron-builder + electron-updater, Dockerfile, Gitea Actions CI/release workflows, and SonarQube docker-compose setup. Also fixes two real bugs found while writing tests: unawaited clipboard promises and a mermaid container ref timing issue in CoachDrawingView. Fixes lint-staged on Windows/Node 24 by invoking eslint/prettier via `node <bin>.js` instead of their .cmd shims, which Node's child_process now refuses to spawn without shell:true. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
59 lines
1.7 KiB
TypeScript
59 lines
1.7 KiB
TypeScript
import { BrowserWindow } from 'electron'
|
|
import { join } from 'path'
|
|
import { is } from '@electron-toolkit/utils'
|
|
import { SECURE_WEB_PREFERENCES, blockExternalNavigation } from '../utils/windowSecurity'
|
|
|
|
let win: BrowserWindow | null = null
|
|
|
|
export interface ModuleTarget {
|
|
subject: string
|
|
module: string
|
|
}
|
|
|
|
function sendNavigateToModule(window: BrowserWindow, target: ModuleTarget): void {
|
|
const send = (): void => window.webContents.send('navigate-to-module', target)
|
|
if (window.webContents.isLoading()) {
|
|
window.webContents.once('did-finish-load', send)
|
|
} else {
|
|
send()
|
|
}
|
|
}
|
|
|
|
// Fenetre normale et independante de l'avatar (qui continue de s'afficher a cote, inchange) :
|
|
// meme principe singleton que src/main/browser/browserWindow.ts, mais charge le renderer compile
|
|
// de l'app avec un hash different plutot qu'une URL externe.
|
|
export function openCoachProgressWindow(navigateTo?: ModuleTarget): void {
|
|
if (win && !win.isDestroyed()) {
|
|
win.show()
|
|
win.moveTop()
|
|
win.focus()
|
|
if (navigateTo) sendNavigateToModule(win, navigateTo)
|
|
return
|
|
}
|
|
|
|
win = new BrowserWindow({
|
|
width: 480,
|
|
height: 640,
|
|
title: "Max — courbe d'apprentissage",
|
|
alwaysOnTop: true,
|
|
webPreferences: {
|
|
preload: join(__dirname, '../preload/index.js'),
|
|
...SECURE_WEB_PREFERENCES
|
|
}
|
|
})
|
|
blockExternalNavigation(win)
|
|
win.setAlwaysOnTop(true, 'floating')
|
|
win.maximize()
|
|
win.on('closed', () => {
|
|
win = null
|
|
})
|
|
|
|
if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
|
|
void win.loadURL(`${process.env['ELECTRON_RENDERER_URL']}#coach-progress`)
|
|
} else {
|
|
void win.loadFile(join(__dirname, '../renderer/index.html'), { hash: 'coach-progress' })
|
|
}
|
|
|
|
if (navigateTo) sendNavigateToModule(win, navigateTo)
|
|
}
|