An easy-to-use platform for EEG experimentation in the classroom
1/**
2 * Post-install patches for dependencies that have browser-incompatible code.
3 *
4 * NOTE: plotly.js was upgraded from v1 (bundled d3 v3) to v2 (d3 v6, pure ESM),
5 * so the previous `this.document` / `this.navigator` patches are no longer needed.
6 *
7 * This file is kept as a placeholder for any future dependency patches and is
8 * still wired into `postinstall` and `dev` npm scripts.
9 */
10
11import { existsSync, readFileSync, writeFileSync } from 'fs';
12import { dirname, join, resolve } from 'path';
13import { fileURLToPath } from 'url';
14
15const __dirname = dirname(fileURLToPath(import.meta.url));
16const root = resolve(__dirname, '../..');
17
18/**
19 * electron-builder install-app-deps (v26+) rewrites node_modules/electron/path.txt
20 * to a path without the `dist/` prefix. Fix it so electron-vite can find the binary.
21 */
22function fixElectronPathTxt() {
23 const pathTxt = join(root, 'node_modules/electron/path.txt');
24 if (!existsSync(pathTxt)) return;
25
26 const current = readFileSync(pathTxt, 'utf8').trim();
27 const correct = 'Electron.app/Contents/MacOS/Electron';
28 const binary = join(root, 'node_modules/electron', correct);
29
30 if (current !== correct && existsSync(binary)) {
31 writeFileSync(pathTxt, correct);
32 console.log('[patchDeps] Fixed electron path.txt:', correct);
33 }
34}
35
36fixElectronPathTxt();
37console.log('[patchDeps] Done.');