feat: code splitting (#3593)

Co-authored-by: Angelos Bouklis <me@arjix.dev>
This commit is contained in:
JellyBrick
2025-07-12 00:00:03 +09:00
committed by GitHub
parent c04dc92d39
commit b53ece5836
15 changed files with 189 additions and 120 deletions

View File

@ -45,7 +45,7 @@ export const onPlayerApiReady = async (
}, 2500);
/** Restore saved volume and setup tooltip */
function firstRun() {
async function firstRun() {
if (typeof options.savedVolume === 'number') {
// Set saved volume as tooltip
setTooltip(options.savedVolume);
@ -66,7 +66,7 @@ export const onPlayerApiReady = async (
injectVolumeHud(noVid);
if (!noVid) {
setupVideoPlayerOnwheel();
if (!window.mainConfig.plugins.isEnabled('video-toggle')) {
if (!await window.mainConfig.plugins.isEnabled('video-toggle')) {
// Video-toggle handles hud positioning on its own
const videoMode = () =>
api.getPlayerResponse().videoDetails?.musicVideoType !==
@ -280,7 +280,7 @@ export const onPlayerApiReady = async (
);
context.ipc.on('setVolume', (value: number) => setVolume(value));
firstRun();
await firstRun();
};
export const onConfigChange = (config: PreciseVolumePluginConfig) => {

View File

@ -309,8 +309,8 @@ function registerMPRIS(win: BrowserWindow) {
player.volume = Number.parseFloat((newVol / 100).toFixed(2));
});
player.on('volume', (newVolume: number) => {
if (config.plugins.isEnabled('precise-volume')) {
player.on('volume', async (newVolume: number) => {
if (await config.plugins.isEnabled('precise-volume')) {
// With precise volume we can set the volume to the exact value.
win.webContents.send('setVolume', ~~(newVolume * 100));
} else {

View File

@ -159,9 +159,9 @@ export default createPlugin({
const config = await getConfig();
this.config = config;
const moveVolumeHud = window.mainConfig.plugins.isEnabled(
const moveVolumeHud = (await window.mainConfig.plugins.isEnabled(
'precise-volume',
)
))
? (preciseVolumeMoveVolumeHud as (_: boolean) => void)
: () => {};