2024-01-13 16:07:33 -05:00
|
|
|
import App from 'resource:///com/github/Aylur/ags/app.js';
|
|
|
|
import { execAsync, monitorFile } from 'resource:///com/github/Aylur/ags/utils.js';
|
|
|
|
|
|
|
|
|
2024-01-17 19:18:41 -05:00
|
|
|
/** @param {string} host */
|
|
|
|
const watchAndCompileSass = (host) => {
|
2024-01-13 16:07:33 -05:00
|
|
|
const reloadCss = () => {
|
2024-01-17 19:18:41 -05:00
|
|
|
const scss = `${App.configDir}/scss/${host}.scss`;
|
2024-01-13 16:07:33 -05:00
|
|
|
const css = '/tmp/ags/style.css';
|
|
|
|
|
|
|
|
execAsync(`sassc ${scss} ${css}`).then(() => {
|
|
|
|
App.resetCss();
|
|
|
|
App.applyCss(css);
|
2024-01-13 23:38:31 -05:00
|
|
|
}).catch(print);
|
2024-01-13 16:07:33 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
monitorFile(
|
|
|
|
`${App.configDir}/scss`,
|
|
|
|
reloadCss,
|
|
|
|
'directory',
|
|
|
|
);
|
|
|
|
reloadCss();
|
|
|
|
};
|
|
|
|
|
2024-01-17 19:18:41 -05:00
|
|
|
/** @param {string} host */
|
|
|
|
export const transpileTypeScript = async(host) => {
|
2024-01-13 23:38:31 -05:00
|
|
|
await execAsync([
|
2024-01-17 19:18:41 -05:00
|
|
|
'bun', 'build', `${App.configDir}/${host}.ts`,
|
2024-01-13 23:38:31 -05:00
|
|
|
'--outdir', '/tmp/ags',
|
|
|
|
'--external', 'resource:///*',
|
|
|
|
'--external', 'gi://*',
|
|
|
|
'--external', 'cairo',
|
|
|
|
'--external', '*/fzf.es.js',
|
|
|
|
]).catch(print);
|
|
|
|
|
2024-01-17 19:18:41 -05:00
|
|
|
watchAndCompileSass(host);
|
2024-01-13 23:38:31 -05:00
|
|
|
|
|
|
|
// The file is going to be there after transpilation
|
|
|
|
// @ts-ignore
|
|
|
|
return await import('file:///tmp/ags/main.js');
|
2024-01-13 16:07:33 -05:00
|
|
|
};
|