mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-15 12:21:47 +00:00
feat: remove unnecessary export default for better tree-shaking
This commit is contained in:
@ -1,30 +1,36 @@
|
||||
import { deepmergeCustom } from 'deepmerge-ts';
|
||||
|
||||
import defaultConfig from './defaults';
|
||||
|
||||
import store, { type IStore } from './store';
|
||||
import plugins from './plugins';
|
||||
|
||||
import { store, type IStore } from './store';
|
||||
import { restart } from '@/providers/app-controls';
|
||||
|
||||
import type { defaultConfig } from './defaults';
|
||||
|
||||
const deepmerge = deepmergeCustom({
|
||||
mergeArrays: false,
|
||||
});
|
||||
|
||||
const set = (key: string, value: unknown) => {
|
||||
export { defaultConfig } from './defaults';
|
||||
export * as plugins from './plugins';
|
||||
|
||||
export const set = (key: string, value: unknown) => {
|
||||
store.set(key, value);
|
||||
};
|
||||
const setPartial = (key: string, value: object, defaultValue?: object) => {
|
||||
|
||||
export const setPartial = (
|
||||
key: string,
|
||||
value: object,
|
||||
defaultValue?: object,
|
||||
) => {
|
||||
const newValue = deepmerge(defaultValue ?? {}, store.get(key) ?? {}, value);
|
||||
store.set(key, newValue);
|
||||
};
|
||||
|
||||
function setMenuOption(key: string, value: unknown) {
|
||||
export const setMenuOption = (key: string, value: unknown) => {
|
||||
set(key, value);
|
||||
if (store.get('options.restartOnConfigChanges')) {
|
||||
restart();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// MAGIC OF TYPESCRIPT
|
||||
|
||||
@ -74,18 +80,11 @@ type PathValue<T, K extends string> =
|
||||
? PathValue<T[A], B>
|
||||
: T;
|
||||
|
||||
const get = <Key extends Paths<typeof defaultConfig>>(key: Key) =>
|
||||
export const get = <Key extends Paths<typeof defaultConfig>>(key: Key) =>
|
||||
store.get(key) as PathValue<typeof defaultConfig, typeof key>;
|
||||
|
||||
export default {
|
||||
defaultConfig,
|
||||
get,
|
||||
set,
|
||||
setPartial,
|
||||
setMenuOption,
|
||||
edit: () => store.openInEditor(),
|
||||
watch(cb: Parameters<IStore['onDidAnyChange']>[0]) {
|
||||
store.onDidAnyChange(cb);
|
||||
},
|
||||
plugins,
|
||||
export const edit = () => store.openInEditor();
|
||||
|
||||
export const watch = (cb: Parameters<IStore['onDidAnyChange']>[0]) => {
|
||||
store.onDidAnyChange(cb);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user