2024-01-30 11:29:07 -05:00
|
|
|
const { execAsync, monitorFile } = Utils;
|
2024-01-13 16:07:33 -05:00
|
|
|
|
|
|
|
|
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-02-06 12:59:55 -05:00
|
|
|
const css = `/tmp/ags-${host}/style.css`;
|
2024-01-13 16:07:33 -05:00
|
|
|
|
2024-03-06 15:44:25 -05:00
|
|
|
execAsync(`sass ${scss} ${css}`).then(() => {
|
2024-01-13 16:07:33 -05:00
|
|
|
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,
|
|
|
|
);
|
|
|
|
reloadCss();
|
|
|
|
};
|
|
|
|
|
2024-01-17 19:18:41 -05:00
|
|
|
/** @param {string} host */
|
|
|
|
export const transpileTypeScript = async(host) => {
|
2024-02-06 12:59:55 -05:00
|
|
|
const outPath = `/tmp/ags-${host}/index.js`;
|
|
|
|
|
2024-01-13 23:38:31 -05:00
|
|
|
await execAsync([
|
2024-02-06 12:59:55 -05:00
|
|
|
'bash', '-c',
|
|
|
|
// Create the dir if it doesn't exist
|
|
|
|
`mkdir -p /tmp/ags-${host}; ` +
|
|
|
|
|
2024-03-19 15:10:18 -04:00
|
|
|
// Let bun see tsconfig.json
|
|
|
|
`cd ${App.configDir};` +
|
|
|
|
|
2024-07-19 20:15:04 -04:00
|
|
|
`bun build ${App.configDir}/${host === 'lockscreen' ? 'ts/lockscreen/main' : host}.ts ` +
|
2024-02-06 12:59:55 -05:00
|
|
|
'--external resource:///* ' +
|
|
|
|
'--external gi://* ' +
|
|
|
|
'--external cairo ' +
|
|
|
|
|
2024-03-19 15:10:18 -04:00
|
|
|
// Since bun wants to write in cwd, we just redirect stdin instead
|
2024-02-06 12:59:55 -05:00
|
|
|
`> ${outPath}`,
|
2024-01-13 23:38:31 -05:00
|
|
|
]).catch(print);
|
|
|
|
|
2024-03-24 13:54:33 -04:00
|
|
|
watchAndCompileSass(host);
|
2024-01-13 23:38:31 -05:00
|
|
|
|
2024-02-06 12:59:55 -05:00
|
|
|
return await import(`file://${outPath}`);
|
2024-01-13 16:07:33 -05:00
|
|
|
};
|