Skip to content

Commit a3104fd

Browse files
committed
feat: run prettier
1 parent 44c4231 commit a3104fd

File tree

116 files changed

+2933
-1259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+2933
-1259
lines changed

src/config/defaults.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ export interface DefaultConfig {
3232
startingPage: string;
3333
overrideUserAgent: boolean;
3434
themes: string[];
35-
},
36-
plugins: Record<string, unknown>,
35+
};
36+
plugins: Record<string, unknown>;
3737
}
3838

3939
const defaultConfig: DefaultConfig = {

src/config/plugins.ts

+14-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ export function getPlugins() {
1212
}
1313

1414
export function isEnabled(plugin: string) {
15-
const pluginConfig = deepmerge(allPlugins[plugin].config ?? { enabled: false }, (store.get('plugins') as Record<string, PluginConfig>)[plugin] ?? {});
15+
const pluginConfig = deepmerge(
16+
allPlugins[plugin].config ?? { enabled: false },
17+
(store.get('plugins') as Record<string, PluginConfig>)[plugin] ?? {},
18+
);
1619
return pluginConfig !== undefined && pluginConfig.enabled;
1720
}
1821

@@ -22,7 +25,11 @@ export function isEnabled(plugin: string) {
2225
* @param options Options to set
2326
* @param exclude Options to exclude from the options object
2427
*/
25-
export function setOptions<T>(plugin: string, options: T, exclude: string[] = ['enabled']) {
28+
export function setOptions<T>(
29+
plugin: string,
30+
options: T,
31+
exclude: string[] = ['enabled'],
32+
) {
2633
const plugins = store.get('plugins') as Record<string, T>;
2734
// HACK: This is a workaround for preventing changed options from being overwritten
2835
exclude.forEach((key) => {
@@ -39,7 +46,11 @@ export function setOptions<T>(plugin: string, options: T, exclude: string[] = ['
3946
});
4047
}
4148

42-
export function setMenuOptions<T>(plugin: string, options: T, exclude: string[] = ['enabled']) {
49+
export function setMenuOptions<T>(
50+
plugin: string,
51+
options: T,
52+
exclude: string[] = ['enabled'],
53+
) {
4354
setOptions(plugin, options, exclude);
4455
if (store.get('options.restartOnConfigChanges')) {
4556
restart();

src/config/store.ts

+24-12
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,17 @@ import { DefaultPresetList, type Preset } from '@/plugins/downloader/types';
77

88
const migrations = {
99
'>=3.0.0'(store: Conf<Record<string, unknown>>) {
10-
const discordConfig = store.get('plugins.discord') as Record<string, unknown>;
10+
const discordConfig = store.get('plugins.discord') as Record<
11+
string,
12+
unknown
13+
>;
1114
if (discordConfig) {
12-
const oldActivityTimoutEnabled = store.get('plugins.discord.activityTimoutEnabled') as boolean | undefined;
13-
const oldActivityTimoutTime = store.get('plugins.discord.activityTimoutTime') as number | undefined;
15+
const oldActivityTimoutEnabled = store.get(
16+
'plugins.discord.activityTimoutEnabled',
17+
) as boolean | undefined;
18+
const oldActivityTimoutTime = store.get(
19+
'plugins.discord.activityTimoutTime',
20+
) as number | undefined;
1421
if (oldActivityTimoutEnabled !== undefined) {
1522
discordConfig.activityTimeoutEnabled = oldActivityTimoutEnabled;
1623
store.set('plugins.discord', discordConfig);
@@ -93,18 +100,23 @@ const migrations = {
93100
}
94101
},
95102
'>=1.12.0'(store: Conf<Record<string, unknown>>) {
96-
const options = store.get('plugins.shortcuts') as Record<
97-
string,
98-
| {
99-
action: string;
100-
shortcut: unknown;
101-
}[]
102-
| Record<string, unknown>
103-
> | undefined;
103+
const options = store.get('plugins.shortcuts') as
104+
| Record<
105+
string,
106+
| {
107+
action: string;
108+
shortcut: unknown;
109+
}[]
110+
| Record<string, unknown>
111+
>
112+
| undefined;
104113
if (options) {
105114
let updated = false;
106115
for (const optionType of ['global', 'local']) {
107-
if (Object.hasOwn(options, optionType) && Array.isArray(options[optionType])) {
116+
if (
117+
Object.hasOwn(options, optionType) &&
118+
Array.isArray(options[optionType])
119+
) {
108120
const optionsArray = options[optionType] as {
109121
action: string;
110122
shortcut: unknown;

src/custom-electron-prompt.d.ts

+31-19
Original file line numberDiff line numberDiff line change
@@ -53,33 +53,45 @@ declare module 'custom-electron-prompt' {
5353
export interface CounterPromptOptions extends BasePromptOptions<'counter'> {
5454
counterOptions: CounterOptions;
5555
}
56-
export interface MultiInputPromptOptions extends BasePromptOptions<'multiInput'> {
56+
export interface MultiInputPromptOptions
57+
extends BasePromptOptions<'multiInput'> {
5758
multiInputOptions: InputOptions[];
5859
}
5960
export interface KeybindPromptOptions extends BasePromptOptions<'keybind'> {
6061
keybindOptions: KeybindOptions[];
6162
}
6263

63-
export type PromptOptions<T extends string> = (
64-
T extends 'input' ? InputPromptOptions :
65-
T extends 'select' ? SelectPromptOptions :
66-
T extends 'counter' ? CounterPromptOptions :
67-
T extends 'keybind' ? KeybindPromptOptions :
68-
T extends 'multiInput' ? MultiInputPromptOptions :
69-
never
70-
);
64+
export type PromptOptions<T extends string> = T extends 'input'
65+
? InputPromptOptions
66+
: T extends 'select'
67+
? SelectPromptOptions
68+
: T extends 'counter'
69+
? CounterPromptOptions
70+
: T extends 'keybind'
71+
? KeybindPromptOptions
72+
: T extends 'multiInput'
73+
? MultiInputPromptOptions
74+
: never;
7175

72-
type PromptResult<T extends string> = T extends 'input' ? string :
73-
T extends 'select' ? string :
74-
T extends 'counter' ? number :
75-
T extends 'keybind' ? {
76-
value: string;
77-
accelerator: string
78-
}[] :
79-
T extends 'multiInput' ? string[] :
80-
never;
76+
type PromptResult<T extends string> = T extends 'input'
77+
? string
78+
: T extends 'select'
79+
? string
80+
: T extends 'counter'
81+
? number
82+
: T extends 'keybind'
83+
? {
84+
value: string;
85+
accelerator: string;
86+
}[]
87+
: T extends 'multiInput'
88+
? string[]
89+
: never;
8190

82-
const prompt: <T extends Type>(options?: PromptOptions<T> & { type: T }, parent?: BrowserWindow) => Promise<PromptResult<T> | null>;
91+
const prompt: <T extends Type>(
92+
options?: PromptOptions<T> & { type: T },
93+
parent?: BrowserWindow,
94+
) => Promise<PromptResult<T> | null>;
8395

8496
export default prompt;
8597
}

src/error.html

+42-42
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html>
3-
<head>
4-
<meta charset="utf-8"/>
3+
<head>
4+
<meta charset="utf-8" />
55
<title>Cannot load YouTube Music</title>
66
<style>
7-
body {
8-
background: #000;
9-
}
7+
body {
8+
background: #000;
9+
}
1010

11-
.container {
12-
margin: 0;
13-
font-family: Roboto, Arial, sans-serif;
14-
font-size: 20px;
15-
font-weight: 500;
16-
color: rgba(255, 255, 255, 0.5);
17-
position: absolute;
18-
top: 50%;
19-
left: 50%;
20-
margin-right: -50%;
21-
transform: translate(-50%, -50%);
22-
text-align: center;
23-
}
11+
.container {
12+
margin: 0;
13+
font-family: Roboto, Arial, sans-serif;
14+
font-size: 20px;
15+
font-weight: 500;
16+
color: rgba(255, 255, 255, 0.5);
17+
position: absolute;
18+
top: 50%;
19+
left: 50%;
20+
margin-right: -50%;
21+
transform: translate(-50%, -50%);
22+
text-align: center;
23+
}
2424

25-
.button {
26-
background: #065fd4;
27-
overflow: hidden;
28-
text-overflow: ellipsis;
29-
white-space: nowrap;
30-
color: white;
31-
font: inherit;
32-
text-transform: uppercase;
33-
text-decoration: none;
34-
border-radius: 2px;
35-
font-size: 16px;
36-
font-weight: normal;
37-
text-align: center;
38-
padding: 8px 22px;
39-
display: inline-block;
40-
}
25+
.button {
26+
background: #065fd4;
27+
overflow: hidden;
28+
text-overflow: ellipsis;
29+
white-space: nowrap;
30+
color: white;
31+
font: inherit;
32+
text-transform: uppercase;
33+
text-decoration: none;
34+
border-radius: 2px;
35+
font-size: 16px;
36+
font-weight: normal;
37+
text-align: center;
38+
padding: 8px 22px;
39+
display: inline-block;
40+
}
4141
</style>
42-
</head>
42+
</head>
4343

44-
<body>
45-
<div class="container">
46-
<p>Cannot load YouTube Music… Internet disconnected?</p>
47-
<a class="button" href="#" onclick="reload()">Retry</a>
48-
</div>
49-
</body>
44+
<body>
45+
<div class="container">
46+
<p>Cannot load YouTube Music… Internet disconnected?</p>
47+
<a class="button" href="#" onclick="reload()">Retry</a>
48+
</div>
49+
</body>
5050
</html>

src/index.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,10 @@ const initHook = (win: BrowserWindow) => {
165165
const mainPlugin = getAllLoadedMainPlugins()[id];
166166
if (mainPlugin) {
167167
if (config.enabled && typeof mainPlugin.backend !== 'function') {
168-
mainPlugin.backend?.onConfigChange?.call(mainPlugin.backend, config);
168+
mainPlugin.backend?.onConfigChange?.call(
169+
mainPlugin.backend,
170+
config,
171+
);
169172
}
170173
}
171174

@@ -282,7 +285,6 @@ async function createMainWindow() {
282285

283286
await loadAllMainPlugins(win);
284287

285-
286288
if (windowPosition) {
287289
const { x: windowX, y: windowY } = windowPosition;
288290
const winSize = win.getSize();
@@ -317,7 +319,6 @@ async function createMainWindow() {
317319
}
318320
}
319321

320-
321322
if (windowMaximized) {
322323
win.maximize();
323324
}

src/loader/main.ts

+20-20
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ import { LoggerPrefix, startPlugin, stopPlugin } from '@/utils';
99
import type { PluginConfig, PluginDef } from '@/types/plugins';
1010
import type { BackendContext } from '@/types/contexts';
1111

12-
const loadedPluginMap: Record<string, PluginDef<unknown, unknown, unknown>> = {};
12+
const loadedPluginMap: Record<
13+
string,
14+
PluginDef<unknown, unknown, unknown>
15+
> = {};
1316

14-
const createContext = (id: string, win: BrowserWindow): BackendContext<PluginConfig> => ({
17+
const createContext = (
18+
id: string,
19+
win: BrowserWindow,
20+
): BackendContext<PluginConfig> => ({
1521
getConfig: () =>
1622
deepmerge(
1723
allPlugins[id].config ?? { enabled: false },
@@ -36,7 +42,7 @@ const createContext = (id: string, win: BrowserWindow): BackendContext<PluginCon
3642
},
3743
removeHandler: (event: string) => {
3844
ipcMain.removeHandler(event);
39-
}
45+
},
4046
},
4147

4248
window: win,
@@ -56,19 +62,15 @@ export const forceUnloadMainPlugin = async (
5662
});
5763
if (
5864
hasStopped ||
59-
(
60-
hasStopped === null &&
61-
typeof plugin.backend !== 'function' && plugin.backend
62-
)
65+
(hasStopped === null &&
66+
typeof plugin.backend !== 'function' &&
67+
plugin.backend)
6368
) {
6469
delete loadedPluginMap[id];
6570
console.log(LoggerPrefix, `"${id}" plugin is unloaded`);
6671
return;
6772
} else {
68-
console.log(
69-
LoggerPrefix,
70-
`Cannot unload "${id}" plugin`,
71-
);
73+
console.log(LoggerPrefix, `Cannot unload "${id}" plugin`);
7274
return Promise.reject();
7375
}
7476
} catch (err) {
@@ -92,21 +94,17 @@ export const forceLoadMainPlugin = async (
9294
});
9395
if (
9496
hasStarted ||
95-
(
96-
hasStarted === null &&
97-
typeof plugin.backend !== 'function' && plugin.backend
98-
)
97+
(hasStarted === null &&
98+
typeof plugin.backend !== 'function' &&
99+
plugin.backend)
99100
) {
100101
loadedPluginMap[id] = plugin;
101102
} else {
102103
console.log(LoggerPrefix, `Cannot load "${id}" plugin`);
103104
return Promise.reject();
104105
}
105106
} catch (err) {
106-
console.error(
107-
LoggerPrefix,
108-
`Cannot initialize "${id}" plugin: `,
109-
);
107+
console.error(LoggerPrefix, `Cannot initialize "${id}" plugin: `);
110108
console.trace(err);
111109
return Promise.reject(err);
112110
}
@@ -135,7 +133,9 @@ export const unloadAllMainPlugins = async (win: BrowserWindow) => {
135133
}
136134
};
137135

138-
export const getLoadedMainPlugin = (id: string): PluginDef<unknown, unknown, unknown> | undefined => {
136+
export const getLoadedMainPlugin = (
137+
id: string,
138+
): PluginDef<unknown, unknown, unknown> | undefined => {
139139
return loadedPluginMap[id];
140140
};
141141

0 commit comments

Comments
 (0)