feat: remove unnecessary export default for better tree-shaking

This commit is contained in:
JellyBrick
2025-09-06 22:31:02 +09:00
parent 26fa1f85b2
commit c1a06ab955
29 changed files with 53 additions and 81 deletions

View File

@ -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);
};