mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
fix: plugin config default value
This commit is contained in:
@ -140,7 +140,7 @@
|
||||
"async-mutex": "0.4.0",
|
||||
"butterchurn": "3.0.0-beta.4",
|
||||
"butterchurn-presets": "3.0.0-beta.4",
|
||||
"conf": "12.0.0",
|
||||
"conf": "10.2.0",
|
||||
"custom-electron-prompt": "1.5.7",
|
||||
"dbus-next": "0.10.2",
|
||||
"deepmerge-ts": "5.1.0",
|
||||
|
||||
68
pnpm-lock.yaml
generated
68
pnpm-lock.yaml
generated
@ -53,8 +53,8 @@ dependencies:
|
||||
specifier: 3.0.0-beta.4
|
||||
version: 3.0.0-beta.4
|
||||
conf:
|
||||
specifier: 12.0.0
|
||||
version: 12.0.0
|
||||
specifier: 10.2.0
|
||||
version: 10.2.0
|
||||
custom-electron-prompt:
|
||||
specifier: 1.5.7
|
||||
version: 1.5.7(electron@27.1.2)
|
||||
@ -1820,13 +1820,6 @@ packages:
|
||||
engines: {node: '>=10.12.0'}
|
||||
dev: false
|
||||
|
||||
/atomically@2.0.2:
|
||||
resolution: {integrity: sha512-Xfmb4q5QV7uqTlVdMSTtO5eF4DCHfNOdaPyKlbFShkzeNP+3lj3yjjcbdjSmEY4+pDBKJ9g26aP+ImTe88UHoQ==}
|
||||
dependencies:
|
||||
stubborn-fs: 1.2.5
|
||||
when-exit: 2.1.1
|
||||
dev: false
|
||||
|
||||
/available-typed-arrays@1.0.5:
|
||||
resolution: {integrity: sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@ -2267,21 +2260,6 @@ packages:
|
||||
semver: 7.5.4
|
||||
dev: false
|
||||
|
||||
/conf@12.0.0:
|
||||
resolution: {integrity: sha512-fIWyWUXrJ45cHCIQX+Ck1hrZDIf/9DR0P0Zewn3uNht28hbt5OfGUq8rRWsxi96pZWPyBEd0eY9ama01JTaknA==}
|
||||
engines: {node: '>=18'}
|
||||
dependencies:
|
||||
ajv: 8.12.0
|
||||
ajv-formats: 2.1.1(ajv@8.12.0)
|
||||
atomically: 2.0.2
|
||||
debounce-fn: 5.1.2
|
||||
dot-prop: 8.0.2
|
||||
env-paths: 3.0.0
|
||||
json-schema-typed: 8.0.1
|
||||
semver: 7.5.4
|
||||
uint8array-extras: 0.3.0
|
||||
dev: false
|
||||
|
||||
/config-file-ts@0.2.4:
|
||||
resolution: {integrity: sha512-cKSW0BfrSaAUnxpgvpXPLaaW/umg4bqg4k3GO1JqlRfpx+d5W0GDXznCMkWotJQek5Mmz1MJVChQnz3IVaeMZQ==}
|
||||
dependencies:
|
||||
@ -2383,13 +2361,6 @@ packages:
|
||||
mimic-fn: 3.1.0
|
||||
dev: false
|
||||
|
||||
/debounce-fn@5.1.2:
|
||||
resolution: {integrity: sha512-Sr4SdOZ4vw6eQDvPYNxHogvrxmCIld/VenC5JbNrFwMiwd7lY/Z18ZFfo+EWNG4DD9nFlAujWAo/wGuOPHmy5A==}
|
||||
engines: {node: '>=12'}
|
||||
dependencies:
|
||||
mimic-fn: 4.0.0
|
||||
dev: false
|
||||
|
||||
/debug@2.6.9:
|
||||
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
|
||||
peerDependencies:
|
||||
@ -2659,13 +2630,6 @@ packages:
|
||||
is-obj: 2.0.0
|
||||
dev: false
|
||||
|
||||
/dot-prop@8.0.2:
|
||||
resolution: {integrity: sha512-xaBe6ZT4DHPkg0k4Ytbvn5xoxgpG0jOS1dYxSOwAHPuNLjP3/OzN0gH55SrLqpx8cBfSaVt91lXYkApjb+nYdQ==}
|
||||
engines: {node: '>=16'}
|
||||
dependencies:
|
||||
type-fest: 3.13.1
|
||||
dev: false
|
||||
|
||||
/dotenv-expand@5.1.0:
|
||||
resolution: {integrity: sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==}
|
||||
dev: true
|
||||
@ -2894,11 +2858,6 @@ packages:
|
||||
resolution: {integrity: sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
/env-paths@3.0.0:
|
||||
resolution: {integrity: sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==}
|
||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||
dev: false
|
||||
|
||||
/err-code@2.0.3:
|
||||
resolution: {integrity: sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==}
|
||||
|
||||
@ -4281,10 +4240,6 @@ packages:
|
||||
resolution: {integrity: sha512-7DE8mpG+/fVw+dTpjbxnx47TaMnDfOI1jwft9g1VybltZCduyRQPJPvc+zzKY9WPHxhPWczyFuYa6I8Mw4iU5A==}
|
||||
dev: false
|
||||
|
||||
/json-schema-typed@8.0.1:
|
||||
resolution: {integrity: sha512-XQmWYj2Sm4kn4WeTYvmpKEbyPsL7nBsb647c7pMe6l02/yx2+Jfc4dT6UZkEXnIUb5LhD55r2HPsJ1milQ4rDg==}
|
||||
dev: false
|
||||
|
||||
/json-stable-stringify-without-jsonify@1.0.1:
|
||||
resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==}
|
||||
dev: true
|
||||
@ -4553,6 +4508,7 @@ packages:
|
||||
/mimic-fn@4.0.0:
|
||||
resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==}
|
||||
engines: {node: '>=12'}
|
||||
dev: true
|
||||
|
||||
/mimic-response@1.0.1:
|
||||
resolution: {integrity: sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==}
|
||||
@ -5732,10 +5688,6 @@ packages:
|
||||
engines: {node: '>=8'}
|
||||
dev: true
|
||||
|
||||
/stubborn-fs@1.2.5:
|
||||
resolution: {integrity: sha512-H2N9c26eXjzL/S/K+i/RHHcFanE74dptvvjM8iwzwbVcWY/zjBbgRqF3K0DY4+OD+uTTASTBvDoxPDaPN02D7g==}
|
||||
dev: false
|
||||
|
||||
/sumchecker@3.0.1:
|
||||
resolution: {integrity: sha512-MvjXzkz/BOfyVDkG0oFOtBxHX2u3gKbMHIF/dXblZsgD3BWOFLmHovIpZY7BykJdAjcqRCBi1WYBNdEC9yI7vg==}
|
||||
engines: {node: '>= 8.0'}
|
||||
@ -5915,11 +5867,6 @@ packages:
|
||||
engines: {node: '>=12.20'}
|
||||
dev: false
|
||||
|
||||
/type-fest@3.13.1:
|
||||
resolution: {integrity: sha512-tLq3bSNx+xSpwvAJnzrK0Ep5CLNWjvFTOp71URMaAEWBfRb9nnJiBoUe0tF8bI4ZFO3omgBR6NvnbzVUT3Ly4g==}
|
||||
engines: {node: '>=14.16'}
|
||||
dev: false
|
||||
|
||||
/typed-array-buffer@1.0.0:
|
||||
resolution: {integrity: sha512-Y8KTSIglk9OZEr8zywiIHG/kmQ7KWyjseXs1CbSo8vC42w7hg2HgYTxSWwP0+is7bWDc1H+Fo026CpHFwm8tkw==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@ -5970,11 +5917,6 @@ packages:
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
||||
/uint8array-extras@0.3.0:
|
||||
resolution: {integrity: sha512-erJsJwQ0tKdwuqI0359U8ijkFmfiTcq25JvvzRVc1VP+2son1NJRXhxcAKJmAW3ajM8JSGAfsAXye8g4s+znxA==}
|
||||
engines: {node: '>=18'}
|
||||
dev: false
|
||||
|
||||
/unbox-primitive@1.0.2:
|
||||
resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==}
|
||||
dependencies:
|
||||
@ -6181,10 +6123,6 @@ packages:
|
||||
engines: {node: '>= 8'}
|
||||
dev: false
|
||||
|
||||
/when-exit@2.1.1:
|
||||
resolution: {integrity: sha512-XLipGldz/UcleuGaoQjbYuWwD+ICRnzIjlldtwTaTWr7aZz8yQW49rXk6MHQnh+KxOiWiJpM1vIyaxprOnlW4g==}
|
||||
dev: false
|
||||
|
||||
/which-boxed-primitive@1.0.2:
|
||||
resolution: {integrity: sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==}
|
||||
dependencies:
|
||||
|
||||
@ -11,8 +11,8 @@ import { restart } from '@/providers/app-controls';
|
||||
const set = (key: string, value: unknown) => {
|
||||
store.set(key, value);
|
||||
};
|
||||
const setPartial = (key: string, value: object) => {
|
||||
const newValue = deepmerge(store.get(key) ?? {}, value);
|
||||
const setPartial = (key: string, value: object, defaultValue?: object) => {
|
||||
const newValue = deepmerge(defaultValue ?? {}, store.get(key) ?? {}, value);
|
||||
store.set(key, newValue);
|
||||
};
|
||||
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import { deepmerge } from 'deepmerge-ts';
|
||||
import { allPlugins } from 'virtual:plugins';
|
||||
|
||||
import store from './store';
|
||||
|
||||
@ -10,7 +12,7 @@ export function getPlugins() {
|
||||
}
|
||||
|
||||
export function isEnabled(plugin: string) {
|
||||
const pluginConfig = (store.get('plugins') as Record<string, PluginConfig>)[plugin];
|
||||
const pluginConfig = deepmerge(allPlugins[plugin].config ?? { enabled: false }, (store.get('plugins') as Record<string, PluginConfig>)[plugin] ?? {});
|
||||
return pluginConfig !== undefined && pluginConfig.enabled;
|
||||
}
|
||||
|
||||
|
||||
@ -116,12 +116,12 @@ const initHook = (win: BrowserWindow) => {
|
||||
'get-config',
|
||||
(_, id: string) =>
|
||||
deepmerge(
|
||||
allPlugins[id].config,
|
||||
allPlugins[id].config ?? { enabled: false },
|
||||
config.get(`plugins.${id}`) ?? {},
|
||||
) as PluginConfig,
|
||||
);
|
||||
ipcMain.handle('set-config', (_, name: string, obj: object) =>
|
||||
config.setPartial(`plugins.${name}`, obj),
|
||||
config.setPartial(`plugins.${name}`, obj, allPlugins[name].config),
|
||||
);
|
||||
|
||||
config.watch((newValue, oldValue) => {
|
||||
@ -140,8 +140,8 @@ const initHook = (win: BrowserWindow) => {
|
||||
if (!isEqual) {
|
||||
const oldConfig = oldPluginConfigList[id] as PluginConfig;
|
||||
const config = deepmerge(
|
||||
allPlugins[id].config,
|
||||
newPluginConfig,
|
||||
allPlugins[id].config ?? { enabled: false },
|
||||
newPluginConfig ?? {},
|
||||
) as PluginConfig;
|
||||
|
||||
if (config.enabled !== oldConfig?.enabled) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { BrowserWindow, ipcMain } from 'electron';
|
||||
|
||||
import { deepmerge } from 'deepmerge-ts';
|
||||
import { mainPlugins } from 'virtual:plugins';
|
||||
import { allPlugins, mainPlugins } from 'virtual:plugins';
|
||||
|
||||
import config from '@/config';
|
||||
import { startPlugin, stopPlugin } from '@/utils';
|
||||
@ -14,11 +14,11 @@ const loadedPluginMap: Record<string, PluginDef<unknown, unknown, unknown>> = {}
|
||||
const createContext = (id: string, win: BrowserWindow): BackendContext<PluginConfig> => ({
|
||||
getConfig: () =>
|
||||
deepmerge(
|
||||
mainPlugins[id].config,
|
||||
config.get(`plugins.${id}`) ?? { enabled: false },
|
||||
allPlugins[id].config ?? { enabled: false },
|
||||
config.get(`plugins.${id}`) ?? {},
|
||||
) as PluginConfig,
|
||||
setConfig: (newConfig) => {
|
||||
config.setPartial(`plugins.${id}`, newConfig);
|
||||
config.setPartial(`plugins.${id}`, newConfig, allPlugins[id].config);
|
||||
},
|
||||
|
||||
ipc: {
|
||||
@ -102,11 +102,10 @@ export const forceLoadMainPlugin = async (
|
||||
) {
|
||||
loadedPluginMap[id] = plugin;
|
||||
resolve();
|
||||
} else {
|
||||
console.log('[YTMusic]', `Cannot load "${id}" plugin`);
|
||||
reject();
|
||||
}
|
||||
|
||||
console.log('[YTMusic]', `Cannot load "${id}" plugin`);
|
||||
reject();
|
||||
return;
|
||||
} catch (err) {
|
||||
console.error(
|
||||
'[YTMusic]',
|
||||
|
||||
@ -10,9 +10,13 @@ import type { PluginConfig } from '@/types/plugins';
|
||||
|
||||
const menuTemplateMap: Record<string, MenuItemConstructorOptions[]> = {};
|
||||
const createContext = (id: string, win: BrowserWindow): MenuContext<PluginConfig> => ({
|
||||
getConfig: () => config.plugins.getOptions(id),
|
||||
getConfig: () =>
|
||||
deepmerge(
|
||||
allPlugins[id].config ?? { enabled: false },
|
||||
config.get(`plugins.${id}`) ?? {},
|
||||
) as PluginConfig,
|
||||
setConfig: (newConfig) => {
|
||||
config.setPartial(`plugins.${id}`, newConfig);
|
||||
config.setPartial(`plugins.${id}`, newConfig, allPlugins[id].config);
|
||||
},
|
||||
window: win,
|
||||
refresh: () => {
|
||||
@ -44,7 +48,7 @@ export const loadAllMenuPlugins = (win: BrowserWindow) => {
|
||||
const pluginConfigs = config.plugins.getPlugins();
|
||||
|
||||
for (const [pluginId, pluginDef] of Object.entries(allPlugins)) {
|
||||
const config = deepmerge(pluginDef.config, pluginConfigs[pluginId] ?? {});
|
||||
const config = deepmerge(pluginDef.config ?? { enabled: false }, pluginConfigs[pluginId] ?? {});
|
||||
|
||||
if (config.enabled) {
|
||||
forceLoadMenuPlugin(pluginId, win);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { deepmerge } from 'deepmerge-ts';
|
||||
import { preloadPlugins } from 'virtual:plugins';
|
||||
import { allPlugins, preloadPlugins } from 'virtual:plugins';
|
||||
|
||||
import { startPlugin, stopPlugin } from '@/utils';
|
||||
|
||||
@ -10,9 +10,13 @@ import type { PluginConfig, PluginDef } from '@/types/plugins';
|
||||
|
||||
const loadedPluginMap: Record<string, PluginDef<unknown, unknown, unknown>> = {};
|
||||
const createContext = (id: string): PreloadContext<PluginConfig> => ({
|
||||
getConfig: () => config.plugins.getOptions(id),
|
||||
getConfig: () =>
|
||||
deepmerge(
|
||||
allPlugins[id].config ?? { enabled: false },
|
||||
config.get(`plugins.${id}`) ?? {},
|
||||
) as PluginConfig,
|
||||
setConfig: (newConfig) => {
|
||||
config.setPartial(`plugins.${id}`, newConfig);
|
||||
config.setPartial(`plugins.${id}`, newConfig, allPlugins[id].config);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -84,7 +84,6 @@ export default createPlugin({
|
||||
}
|
||||
},
|
||||
async onConfigChange(newConfig) {
|
||||
console.log('Adblocker config changed', newConfig);
|
||||
if (this.mainWindow) {
|
||||
if (newConfig.blocker === blockers.WithBlocklists && !isBlockerEnabled(this.mainWindow.webContents.session)) {
|
||||
await loadAdBlockerEngine(
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { createPlugin } from '@/utils';
|
||||
import {YoutubePlayer} from "@/types/youtube-player";
|
||||
|
||||
import type { YoutubePlayer } from '@/types/youtube-player';
|
||||
|
||||
export type DisableAutoPlayPluginConfig = {
|
||||
enabled: boolean;
|
||||
|
||||
@ -13,7 +13,13 @@ export default createPlugin({
|
||||
name: 'In-App Menu',
|
||||
restartNeeded: true,
|
||||
config: {
|
||||
enabled: false,
|
||||
enabled: (
|
||||
typeof window !== 'undefined' &&
|
||||
!window.navigator?.userAgent?.includes('mac')
|
||||
) || (
|
||||
typeof global !== 'undefined' &&
|
||||
global.process?.platform !== 'darwin'
|
||||
),
|
||||
hideDOMWindowControls: false,
|
||||
} as InAppMenuConfig,
|
||||
stylesheets: [titlebarStyle],
|
||||
|
||||
@ -9,7 +9,7 @@ export default createPlugin({
|
||||
name: 'Navigation',
|
||||
restartNeeded: true,
|
||||
config: {
|
||||
enabled: false,
|
||||
enabled: true,
|
||||
},
|
||||
stylesheets: [style],
|
||||
renderer() {
|
||||
|
||||
Reference in New Issue
Block a user