mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
feat: run prettier
This commit is contained in:
@ -8,11 +8,11 @@ export const loadI18n = async () =>
|
||||
lng: 'en',
|
||||
fallbackLng: 'en',
|
||||
interpolation: {
|
||||
escapeValue: false
|
||||
}
|
||||
escapeValue: false,
|
||||
},
|
||||
});
|
||||
|
||||
export const setLanguage = async (language: string) => await changeLanguage(language);
|
||||
export const setLanguage = async (language: string) =>
|
||||
await changeLanguage(language);
|
||||
|
||||
export const t = i18t.bind(i18next);
|
||||
|
||||
|
||||
@ -322,7 +322,8 @@ async function createMainWindow() {
|
||||
winSize: String(winSize),
|
||||
displaySize: String(display.bounds),
|
||||
windowPosition: String(windowPosition),
|
||||
}));
|
||||
}),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
win.setSize(scaledWidth, scaledHeight);
|
||||
@ -640,7 +641,10 @@ app.whenReady().then(async () => {
|
||||
const lastIndex = protocolArgv.endsWith('/') ? -1 : undefined;
|
||||
const command = protocolArgv.slice(uri.length, lastIndex);
|
||||
if (is.dev()) {
|
||||
console.debug(LoggerPrefix, t('main.console.second-instance.receive-command', { command }));
|
||||
console.debug(
|
||||
LoggerPrefix,
|
||||
t('main.console.second-instance.receive-command', { command }),
|
||||
);
|
||||
}
|
||||
|
||||
handleProtocol(command);
|
||||
|
||||
@ -69,10 +69,10 @@ export const forceUnloadMainPlugin = async (
|
||||
plugin.backend)
|
||||
) {
|
||||
delete loadedPluginMap[id];
|
||||
console.log(LoggerPrefix, t(
|
||||
'common.console.plugins.unloaded',
|
||||
{ pluginName: id },
|
||||
));
|
||||
console.log(
|
||||
LoggerPrefix,
|
||||
t('common.console.plugins.unloaded', { pluginName: id }),
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
console.log(
|
||||
|
||||
@ -52,12 +52,14 @@ export const forceLoadMenuPlugin = async (id: string, win: BrowserWindow) => {
|
||||
|
||||
console.log(
|
||||
LoggerPrefix,
|
||||
t('common.console.plugins.loaded', { pluginName: `${id}::menu` })
|
||||
t('common.console.plugins.loaded', { pluginName: `${id}::menu` }),
|
||||
);
|
||||
} catch (err) {
|
||||
console.error(
|
||||
LoggerPrefix,
|
||||
t('common.console.plugins.initialize-failed', { pluginName: `${id}::menu` }),
|
||||
t('common.console.plugins.initialize-failed', {
|
||||
pluginName: `${id}::menu`,
|
||||
}),
|
||||
);
|
||||
console.trace(err);
|
||||
}
|
||||
|
||||
@ -39,7 +39,10 @@ export const forceUnloadPreloadPlugin = async (id: string) => {
|
||||
);
|
||||
delete loadedPluginMap[id];
|
||||
} else {
|
||||
console.error(LoggerPrefix, t('common.console.plugins.unload-failed', { pluginName: id }));
|
||||
console.error(
|
||||
LoggerPrefix,
|
||||
t('common.console.plugins.unload-failed', { pluginName: id }),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -62,9 +65,15 @@ export const forceLoadPreloadPlugin = async (id: string) => {
|
||||
loadedPluginMap[id] = plugin;
|
||||
}
|
||||
|
||||
console.log(LoggerPrefix, t('common.console.plugins.loaded', { pluginName: id }));
|
||||
console.log(
|
||||
LoggerPrefix,
|
||||
t('common.console.plugins.loaded', { pluginName: id }),
|
||||
);
|
||||
} catch (err) {
|
||||
console.error(LoggerPrefix, t('common.console.plugins.initialize-failed', { pluginName: id }));
|
||||
console.error(
|
||||
LoggerPrefix,
|
||||
t('common.console.plugins.initialize-failed', { pluginName: id }),
|
||||
);
|
||||
console.trace(err);
|
||||
}
|
||||
};
|
||||
|
||||
@ -4,9 +4,10 @@ import { rendererPlugins } from 'virtual:plugins';
|
||||
|
||||
import { LoggerPrefix, startPlugin, stopPlugin } from '@/utils';
|
||||
|
||||
import { t } from '@/i18n';
|
||||
|
||||
import type { RendererContext } from '@/types/contexts';
|
||||
import type { PluginConfig, PluginDef } from '@/types/plugins';
|
||||
import { t } from '@/i18n';
|
||||
|
||||
const unregisterStyleMap: Record<string, (() => void)[]> = {};
|
||||
const loadedPluginMap: Record<
|
||||
@ -55,9 +56,15 @@ export const forceUnloadRendererPlugin = async (id: string) => {
|
||||
document.querySelector(`style#plugin-${id}`)?.remove();
|
||||
}
|
||||
if (hasStopped || (hasStopped === null && plugin?.renderer)) {
|
||||
console.log(LoggerPrefix, t('common.console.plugins.unloaded', { pluginName: id }));
|
||||
console.log(
|
||||
LoggerPrefix,
|
||||
t('common.console.plugins.unloaded', { pluginName: id }),
|
||||
);
|
||||
} else {
|
||||
console.error(LoggerPrefix, t('common.console.plugins.unload-failed', { pluginName: id }));
|
||||
console.error(
|
||||
LoggerPrefix,
|
||||
t('common.console.plugins.unload-failed', { pluginName: id }),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -93,9 +100,15 @@ export const forceLoadRendererPlugin = async (id: string) => {
|
||||
];
|
||||
}
|
||||
|
||||
console.log(LoggerPrefix, t('common.console.plugins.loaded', { pluginName: id }));
|
||||
console.log(
|
||||
LoggerPrefix,
|
||||
t('common.console.plugins.loaded', { pluginName: id }),
|
||||
);
|
||||
} else {
|
||||
console.log(LoggerPrefix, t('common.console.plugins.initialize-failed', { pluginName: id }));
|
||||
console.log(
|
||||
LoggerPrefix,
|
||||
t('common.console.plugins.initialize-failed', { pluginName: id }),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
141
src/menu.ts
141
src/menu.ts
@ -24,7 +24,6 @@ import promptOptions from './providers/prompt-options';
|
||||
import { getAllMenuTemplate, loadAllMenuPlugins } from './loader/menu';
|
||||
import { setLanguage, t } from '@/i18n';
|
||||
|
||||
|
||||
export type MenuTemplate = Electron.MenuItemConstructorOptions[];
|
||||
|
||||
// True only if in-app-menu was loaded on launch
|
||||
@ -82,7 +81,12 @@ export const mainMenuTemplate = async (
|
||||
{
|
||||
label: pluginLabel,
|
||||
submenu: [
|
||||
pluginEnabledMenu(id, t('main.menu.plugins.enabled'), true, innerRefreshMenu),
|
||||
pluginEnabledMenu(
|
||||
id,
|
||||
t('main.menu.plugins.enabled'),
|
||||
true,
|
||||
innerRefreshMenu,
|
||||
),
|
||||
{ type: 'separator' },
|
||||
...template,
|
||||
],
|
||||
@ -161,7 +165,9 @@ export const mainMenuTemplate = async (
|
||||
label: t('main.menu.options.submenu.visual-tweaks.label'),
|
||||
submenu: [
|
||||
{
|
||||
label: t('main.menu.options.submenu.visual-tweaks.submenu.remove-upgrade-button'),
|
||||
label: t(
|
||||
'main.menu.options.submenu.visual-tweaks.submenu.remove-upgrade-button',
|
||||
),
|
||||
type: 'checkbox',
|
||||
checked: config.get('options.removeUpgradeButton'),
|
||||
click(item: MenuItem) {
|
||||
@ -172,10 +178,14 @@ export const mainMenuTemplate = async (
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('main.menu.options.submenu.visual-tweaks.submenu.like-buttons.label'),
|
||||
label: t(
|
||||
'main.menu.options.submenu.visual-tweaks.submenu.like-buttons.label',
|
||||
),
|
||||
submenu: [
|
||||
{
|
||||
label: t('main.menu.options.submenu.visual-tweaks.submenu.like-buttons.default'),
|
||||
label: t(
|
||||
'main.menu.options.submenu.visual-tweaks.submenu.like-buttons.default',
|
||||
),
|
||||
type: 'radio',
|
||||
checked: !config.get('options.likeButtons'),
|
||||
click() {
|
||||
@ -183,7 +193,9 @@ export const mainMenuTemplate = async (
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('main.menu.options.submenu.visual-tweaks.submenu.like-buttons.force-show'),
|
||||
label: t(
|
||||
'main.menu.options.submenu.visual-tweaks.submenu.like-buttons.force-show',
|
||||
),
|
||||
type: 'radio',
|
||||
checked: config.get('options.likeButtons') === 'force',
|
||||
click() {
|
||||
@ -191,7 +203,9 @@ export const mainMenuTemplate = async (
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('main.menu.options.submenu.visual-tweaks.submenu.like-buttons.hide'),
|
||||
label: t(
|
||||
'main.menu.options.submenu.visual-tweaks.submenu.like-buttons.hide',
|
||||
),
|
||||
type: 'radio',
|
||||
checked: config.get('options.likeButtons') === 'hide',
|
||||
click() {
|
||||
@ -201,10 +215,14 @@ export const mainMenuTemplate = async (
|
||||
],
|
||||
},
|
||||
{
|
||||
label: t('main.menu.options.submenu.visual-tweaks.submenu.theme.label'),
|
||||
label: t(
|
||||
'main.menu.options.submenu.visual-tweaks.submenu.theme.label',
|
||||
),
|
||||
submenu: [
|
||||
{
|
||||
label: t('main.menu.options.submenu.visual-tweaks.submenu.theme.submenu.no-theme'),
|
||||
label: t(
|
||||
'main.menu.options.submenu.visual-tweaks.submenu.theme.submenu.no-theme',
|
||||
),
|
||||
type: 'radio',
|
||||
checked: config.get('options.themes')?.length === 0, // Todo rename "themes"
|
||||
click() {
|
||||
@ -213,7 +231,9 @@ export const mainMenuTemplate = async (
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: t('main.menu.options.submenu.visual-tweaks.submenu.theme.submenu.import-css-file'),
|
||||
label: t(
|
||||
'main.menu.options.submenu.visual-tweaks.submenu.theme.submenu.import-css-file',
|
||||
),
|
||||
type: 'normal',
|
||||
async click() {
|
||||
const { filePaths } = await dialog.showOpenDialog({
|
||||
@ -261,8 +281,12 @@ export const mainMenuTemplate = async (
|
||||
if (item.checked && !config.get('options.hideMenuWarned')) {
|
||||
dialog.showMessageBox(win, {
|
||||
type: 'info',
|
||||
title: t('main.menu.options.submenu.hide-menu.dialog.title'),
|
||||
message: t('main.menu.options.submenu.hide-menu.dialog.message'),
|
||||
title: t(
|
||||
'main.menu.options.submenu.hide-menu.dialog.title',
|
||||
),
|
||||
message: t(
|
||||
'main.menu.options.submenu.hide-menu.dialog.message',
|
||||
),
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -296,7 +320,9 @@ export const mainMenuTemplate = async (
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('main.menu.options.submenu.tray.submenu.enabled-and-show-app'),
|
||||
label: t(
|
||||
'main.menu.options.submenu.tray.submenu.enabled-and-show-app',
|
||||
),
|
||||
type: 'radio',
|
||||
checked:
|
||||
config.get('options.tray') && config.get('options.appVisible'),
|
||||
@ -306,7 +332,9 @@ export const mainMenuTemplate = async (
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('main.menu.options.submenu.tray.submenu.enabled-and-hide-app'),
|
||||
label: t(
|
||||
'main.menu.options.submenu.tray.submenu.enabled-and-hide-app',
|
||||
),
|
||||
type: 'radio',
|
||||
checked:
|
||||
config.get('options.tray') && !config.get('options.appVisible'),
|
||||
@ -317,7 +345,9 @@ export const mainMenuTemplate = async (
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: t('main.menu.options.submenu.tray.submenu.play-pause-on-click'),
|
||||
label: t(
|
||||
'main.menu.options.submenu.tray.submenu.play-pause-on-click',
|
||||
),
|
||||
type: 'checkbox',
|
||||
checked: config.get('options.trayClickPlayPause'),
|
||||
click(item: MenuItem) {
|
||||
@ -331,37 +361,42 @@ export const mainMenuTemplate = async (
|
||||
},
|
||||
{
|
||||
label: t('main.menu.options.submenu.language.label'),
|
||||
submenu: availableLanguages.map((lang): Electron.MenuItemConstructorOptions => ({
|
||||
label: `${languageResources[lang].translation.language.name} (${languageResources[lang].translation.language['local-name']})`,
|
||||
type: 'checkbox',
|
||||
checked: config.get('options.language') === lang,
|
||||
click() {
|
||||
config.setMenuOption('options.language', lang);
|
||||
refreshMenu(win);
|
||||
setLanguage(lang);
|
||||
dialog.showMessageBox(
|
||||
win,
|
||||
{
|
||||
submenu: availableLanguages.map(
|
||||
(lang): Electron.MenuItemConstructorOptions => ({
|
||||
label: `${languageResources[lang].translation.language.name} (${languageResources[lang].translation.language['local-name']})`,
|
||||
type: 'checkbox',
|
||||
checked: config.get('options.language') === lang,
|
||||
click() {
|
||||
config.setMenuOption('options.language', lang);
|
||||
refreshMenu(win);
|
||||
setLanguage(lang);
|
||||
dialog.showMessageBox(win, {
|
||||
title: t('main.menu.options.submenu.language.dialog.title'),
|
||||
message: t('main.menu.options.submenu.language.dialog.message'),
|
||||
}
|
||||
);
|
||||
},
|
||||
})),
|
||||
message: t(
|
||||
'main.menu.options.submenu.language.dialog.message',
|
||||
),
|
||||
});
|
||||
},
|
||||
}),
|
||||
),
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: t('main.menu.options.submenu.advanced-options.label'),
|
||||
submenu: [
|
||||
{
|
||||
label: t('main.menu.options.submenu.advanced-options.submenu.set-proxy.label'),
|
||||
label: t(
|
||||
'main.menu.options.submenu.advanced-options.submenu.set-proxy.label',
|
||||
),
|
||||
type: 'normal',
|
||||
async click(item: MenuItem) {
|
||||
await setProxy(item, win);
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('main.menu.options.submenu.advanced-options.submenu.override-user-agent'),
|
||||
label: t(
|
||||
'main.menu.options.submenu.advanced-options.submenu.override-user-agent',
|
||||
),
|
||||
type: 'checkbox',
|
||||
checked: config.get('options.overrideUserAgent'),
|
||||
click(item: MenuItem) {
|
||||
@ -369,7 +404,9 @@ export const mainMenuTemplate = async (
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('main.menu.options.submenu.advanced-options.submenu.disable-hardware-acceleration'),
|
||||
label: t(
|
||||
'main.menu.options.submenu.advanced-options.submenu.disable-hardware-acceleration',
|
||||
),
|
||||
type: 'checkbox',
|
||||
checked: config.get('options.disableHardwareAcceleration'),
|
||||
click(item: MenuItem) {
|
||||
@ -380,7 +417,9 @@ export const mainMenuTemplate = async (
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('main.menu.options.submenu.advanced-options.submenu.restart-on-config-changes'),
|
||||
label: t(
|
||||
'main.menu.options.submenu.advanced-options.submenu.restart-on-config-changes',
|
||||
),
|
||||
type: 'checkbox',
|
||||
checked: config.get('options.restartOnConfigChanges'),
|
||||
click(item: MenuItem) {
|
||||
@ -391,7 +430,9 @@ export const mainMenuTemplate = async (
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('main.menu.options.submenu.advanced-options.submenu.auto-reset-app-cache'),
|
||||
label: t(
|
||||
'main.menu.options.submenu.advanced-options.submenu.auto-reset-app-cache',
|
||||
),
|
||||
type: 'checkbox',
|
||||
checked: config.get('options.autoResetAppCache'),
|
||||
click(item: MenuItem) {
|
||||
@ -401,7 +442,9 @@ export const mainMenuTemplate = async (
|
||||
{ type: 'separator' },
|
||||
is.macOS()
|
||||
? {
|
||||
label: t('main.menu.options.submenu.advanced-options.submenu.toggle-dev-tools'),
|
||||
label: t(
|
||||
'main.menu.options.submenu.advanced-options.submenu.toggle-dev-tools',
|
||||
),
|
||||
// Cannot use "toggleDevTools" role in macOS
|
||||
click() {
|
||||
const { webContents } = win;
|
||||
@ -413,11 +456,15 @@ export const mainMenuTemplate = async (
|
||||
},
|
||||
}
|
||||
: {
|
||||
label: t('main.menu.options.submenu.advanced-options.submenu.toggle-dev-tools'),
|
||||
role: 'toggleDevTools'
|
||||
},
|
||||
label: t(
|
||||
'main.menu.options.submenu.advanced-options.submenu.toggle-dev-tools',
|
||||
),
|
||||
role: 'toggleDevTools',
|
||||
},
|
||||
{
|
||||
label: t('main.menu.options.submenu.advanced-options.submenu.edit-config-json'),
|
||||
label: t(
|
||||
'main.menu.options.submenu.advanced-options.submenu.edit-config-json',
|
||||
),
|
||||
click() {
|
||||
config.edit();
|
||||
},
|
||||
@ -533,13 +580,19 @@ export const setApplicationMenu = async (win: Electron.BrowserWindow) => {
|
||||
async function setProxy(item: Electron.MenuItem, win: BrowserWindow) {
|
||||
const output = await prompt(
|
||||
{
|
||||
title: t('main.menu.options.submenu.advanced-options.submenu.set-proxy.prompt.title'),
|
||||
label: t('main.menu.options.submenu.advanced-options.submenu.set-proxy.prompt.label'),
|
||||
title: t(
|
||||
'main.menu.options.submenu.advanced-options.submenu.set-proxy.prompt.title',
|
||||
),
|
||||
label: t(
|
||||
'main.menu.options.submenu.advanced-options.submenu.set-proxy.prompt.label',
|
||||
),
|
||||
value: config.get('options.proxy'),
|
||||
type: 'input',
|
||||
inputAttrs: {
|
||||
type: 'url',
|
||||
placeholder: t('main.menu.options.submenu.advanced-options.submenu.set-proxy.prompt.placeholder'),
|
||||
placeholder: t(
|
||||
'main.menu.options.submenu.advanced-options.submenu.set-proxy.prompt.placeholder',
|
||||
),
|
||||
},
|
||||
width: 450,
|
||||
...promptOptions(),
|
||||
|
||||
@ -44,9 +44,12 @@ export default createPlugin({
|
||||
{
|
||||
label: t('plugins.ambient-mode.menu.smoothness-transition.label'),
|
||||
submenu: interpolationTimeList.map((interpolationTime) => ({
|
||||
label: t('plugins.ambient-mode.menu.smoothness-transition.submenu.during', {
|
||||
interpolationTime: interpolationTime / 1000,
|
||||
}),
|
||||
label: t(
|
||||
'plugins.ambient-mode.menu.smoothness-transition.submenu.during',
|
||||
{
|
||||
interpolationTime: interpolationTime / 1000,
|
||||
},
|
||||
),
|
||||
type: 'radio',
|
||||
checked: config.interpolationTime === interpolationTime,
|
||||
click() {
|
||||
@ -57,7 +60,9 @@ export default createPlugin({
|
||||
{
|
||||
label: t('plugins.ambient-mode.menu.quality.label'),
|
||||
submenu: qualityList.map((quality) => ({
|
||||
label: t('plugins.ambient-mode.menu.quality.submenu.pixels', { quality }),
|
||||
label: t('plugins.ambient-mode.menu.quality.submenu.pixels', {
|
||||
quality,
|
||||
}),
|
||||
type: 'radio',
|
||||
checked: config.quality === quality,
|
||||
click() {
|
||||
@ -79,7 +84,9 @@ export default createPlugin({
|
||||
{
|
||||
label: t('plugins.ambient-mode.menu.buffer.label'),
|
||||
submenu: bufferList.map((buffer) => ({
|
||||
label: t('plugins.ambient-mode.menu.buffer.submenu.buffer', { buffer }),
|
||||
label: t('plugins.ambient-mode.menu.buffer.submenu.buffer', {
|
||||
buffer,
|
||||
}),
|
||||
type: 'radio',
|
||||
checked: config.buffer === buffer,
|
||||
click() {
|
||||
@ -90,7 +97,9 @@ export default createPlugin({
|
||||
{
|
||||
label: t('plugins.ambient-mode.menu.opacity.label'),
|
||||
submenu: opacityList.map((opacity) => ({
|
||||
label: t('plugins.ambient-mode.menu.opacity.submenu.percent', { opacity: opacity * 100 }),
|
||||
label: t('plugins.ambient-mode.menu.opacity.submenu.percent', {
|
||||
opacity: opacity * 100,
|
||||
}),
|
||||
type: 'radio',
|
||||
checked: config.opacity === opacity,
|
||||
click() {
|
||||
@ -101,7 +110,9 @@ export default createPlugin({
|
||||
{
|
||||
label: t('plugins.ambient-mode.menu.blur-amount.label'),
|
||||
submenu: blurAmountList.map((blur) => ({
|
||||
label: t('plugins.ambient-mode.menu.blur-amount.submenu.pixels', { blurAmount: blur }),
|
||||
label: t('plugins.ambient-mode.menu.blur-amount.submenu.pixels', {
|
||||
blurAmount: blur,
|
||||
}),
|
||||
type: 'radio',
|
||||
checked: config.blur === blur,
|
||||
click() {
|
||||
|
||||
@ -13,7 +13,9 @@ export default createBackend({
|
||||
{
|
||||
title: t('plugins.captions-selector.prompt.selector.title'),
|
||||
label: t('plugins.captions-selector.prompt.selector.label', {
|
||||
language: captionLabels[currentIndex] || t('plugins.captions-selector.prompt.selector.none'),
|
||||
language:
|
||||
captionLabels[currentIndex] ||
|
||||
t('plugins.captions-selector.prompt.selector.none'),
|
||||
}),
|
||||
type: 'select',
|
||||
value: currentIndex,
|
||||
|
||||
@ -10,9 +10,10 @@ import { getNetFetchAsFetch } from '@/plugins/utils/main';
|
||||
import { createPlugin } from '@/utils';
|
||||
import { VolumeFader } from './fader';
|
||||
|
||||
import type { RendererContext } from '@/types/contexts';
|
||||
import { t } from '@/i18n';
|
||||
|
||||
import type { RendererContext } from '@/types/contexts';
|
||||
|
||||
export type CrossfadePluginConfig = {
|
||||
enabled: boolean;
|
||||
fadeInDuration: number;
|
||||
@ -72,7 +73,9 @@ export default createPlugin<
|
||||
type: 'multiInput',
|
||||
multiInputOptions: [
|
||||
{
|
||||
label: t('plugins.crossfade.prompt.options.multi-input.fade-in-duration'),
|
||||
label: t(
|
||||
'plugins.crossfade.prompt.options.multi-input.fade-in-duration',
|
||||
),
|
||||
value: options.fadeInDuration,
|
||||
inputAttrs: {
|
||||
type: 'number',
|
||||
@ -82,7 +85,9 @@ export default createPlugin<
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('plugins.crossfade.prompt.options.multi-input.fade-out-duration'),
|
||||
label: t(
|
||||
'plugins.crossfade.prompt.options.multi-input.fade-out-duration',
|
||||
),
|
||||
value: options.fadeOutDuration,
|
||||
inputAttrs: {
|
||||
type: 'number',
|
||||
@ -92,7 +97,9 @@ export default createPlugin<
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('plugins.crossfade.prompt.options.multi-input.seconds-before-end'),
|
||||
label: t(
|
||||
'plugins.crossfade.prompt.options.multi-input.seconds-before-end',
|
||||
),
|
||||
value: options.secondsBeforeEnd,
|
||||
inputAttrs: {
|
||||
type: 'number',
|
||||
@ -101,10 +108,16 @@ export default createPlugin<
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('plugins.crossfade.prompt.options.multi-input.fade-scaling.label'),
|
||||
label: t(
|
||||
'plugins.crossfade.prompt.options.multi-input.fade-scaling.label',
|
||||
),
|
||||
selectOptions: {
|
||||
linear: t('plugins.crossfade.prompt.options.multi-input.fade-scaling.linear'),
|
||||
logarithmic: t('plugins.crossfade.prompt.options.multi-input.fade-scaling.logarithmic'),
|
||||
linear: t(
|
||||
'plugins.crossfade.prompt.options.multi-input.fade-scaling.linear',
|
||||
),
|
||||
logarithmic: t(
|
||||
'plugins.crossfade.prompt.options.multi-input.fade-scaling.logarithmic',
|
||||
),
|
||||
},
|
||||
value: options.fadeScaling,
|
||||
},
|
||||
|
||||
@ -40,10 +40,7 @@ const resetInfo = () => {
|
||||
info.ready = false;
|
||||
clearTimeout(clearActivity);
|
||||
if (dev()) {
|
||||
console.log(
|
||||
LoggerPrefix,
|
||||
t('plugins.discord.backend.disconnected')
|
||||
);
|
||||
console.log(LoggerPrefix, t('plugins.discord.backend.disconnected'));
|
||||
}
|
||||
|
||||
for (const cb of refreshCallbacks) {
|
||||
@ -73,10 +70,7 @@ let window: Electron.BrowserWindow;
|
||||
export const connect = (showError = false) => {
|
||||
if (info.rpc.isConnected) {
|
||||
if (dev()) {
|
||||
console.log(
|
||||
LoggerPrefix,
|
||||
t('plugins.discord.backend.already-connected')
|
||||
);
|
||||
console.log(LoggerPrefix, t('plugins.discord.backend.already-connected'));
|
||||
}
|
||||
|
||||
return;
|
||||
@ -214,10 +208,7 @@ export const backend = createBackend<
|
||||
|
||||
info.rpc.on('connected', () => {
|
||||
if (dev()) {
|
||||
console.log(
|
||||
LoggerPrefix,
|
||||
t('plugins.discord.backend.connected')
|
||||
);
|
||||
console.log(LoggerPrefix, t('plugins.discord.backend.connected'));
|
||||
}
|
||||
|
||||
for (const cb of refreshCallbacks) {
|
||||
|
||||
@ -28,7 +28,9 @@ export const onMenu = async ({
|
||||
|
||||
return [
|
||||
{
|
||||
label: isConnected() ? t('plugins.discord.menu.connected') : t('plugins.discord.menu.disconnected'),
|
||||
label: isConnected()
|
||||
? t('plugins.discord.menu.connected')
|
||||
: t('plugins.discord.menu.disconnected'),
|
||||
enabled: !isConnected(),
|
||||
click: () => connect(),
|
||||
},
|
||||
|
||||
@ -181,19 +181,17 @@ async function downloadSongUnsafe(
|
||||
}
|
||||
};
|
||||
|
||||
sendFeedback(
|
||||
t('plugins.downloader.backend.feedback.downloading'),
|
||||
2,
|
||||
);
|
||||
sendFeedback(t('plugins.downloader.backend.feedback.downloading'), 2);
|
||||
|
||||
let id: string | null;
|
||||
if (isId) {
|
||||
id = idOrUrl;
|
||||
} else {
|
||||
id = getVideoId(idOrUrl);
|
||||
if (typeof id !== 'string') throw new Error(
|
||||
t('plugins.downloader.backend.feedback.video-id-not-found'),
|
||||
);
|
||||
if (typeof id !== 'string')
|
||||
throw new Error(
|
||||
t('plugins.downloader.backend.feedback.video-id-not-found'),
|
||||
);
|
||||
}
|
||||
|
||||
let info: TrackInfo | VideoInfo = await yt.music.getInfo(id);
|
||||
@ -325,9 +323,11 @@ async function downloadSongUnsafe(
|
||||
}
|
||||
|
||||
sendFeedback(null, -1);
|
||||
console.info(t('plugins.downloader.backend.feedback.done', {
|
||||
filePath,
|
||||
}));
|
||||
console.info(
|
||||
t('plugins.downloader.backend.feedback.done', {
|
||||
filePath,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
async function iterableStreamToTargetFile(
|
||||
@ -357,10 +357,7 @@ async function iterableStreamToTargetFile(
|
||||
increasePlaylistProgress(ratio * 0.15);
|
||||
}
|
||||
|
||||
sendFeedback(
|
||||
t('plugins.downloader.backend.feedback.loading'),
|
||||
2,
|
||||
); // Indefinite progress bar after download
|
||||
sendFeedback(t('plugins.downloader.backend.feedback.loading'), 2); // Indefinite progress bar after download
|
||||
|
||||
const buffer = Buffer.concat(chunks);
|
||||
const safeVideoName = randomBytes(32).toString('hex');
|
||||
@ -399,9 +396,7 @@ async function iterableStreamToTargetFile(
|
||||
ffmpeg.FS('unlink', safeVideoName);
|
||||
}
|
||||
|
||||
sendFeedback(
|
||||
t('plugins.downloader.backend.feedback.saving'),
|
||||
);
|
||||
sendFeedback(t('plugins.downloader.backend.feedback.saving'));
|
||||
|
||||
try {
|
||||
return ffmpeg.FS('readFile', safeVideoNameWithExtension);
|
||||
@ -427,9 +422,7 @@ async function writeID3(
|
||||
sendFeedback: (str: string, value?: number) => void,
|
||||
) {
|
||||
try {
|
||||
sendFeedback(
|
||||
t('plugins.downloader.backend.feedback.writing-id3'),
|
||||
);
|
||||
sendFeedback(t('plugins.downloader.backend.feedback.writing-id3'));
|
||||
const tags: NodeID3.Tags = {};
|
||||
|
||||
// Create the metadata tags
|
||||
@ -484,9 +477,9 @@ export async function downloadPlaylist(givenUrl?: string | URL) {
|
||||
getPlaylistID(givenUrl) || getPlaylistID(new URL(playingUrl));
|
||||
|
||||
if (!playlistId) {
|
||||
sendError(new Error(
|
||||
t('plugins.downloader.backend.feedback.playlist-id-not-found'),
|
||||
));
|
||||
sendError(
|
||||
new Error(t('plugins.downloader.backend.feedback.playlist-id-not-found')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -497,9 +490,7 @@ export async function downloadPlaylist(givenUrl?: string | URL) {
|
||||
playlistId,
|
||||
}),
|
||||
);
|
||||
sendFeedback(
|
||||
t('plugins.downloader.backend.feedback.getting-playlist-info'),
|
||||
);
|
||||
sendFeedback(t('plugins.downloader.backend.feedback.getting-playlist-info'));
|
||||
let playlist: Playlist;
|
||||
const items: YTNodes.MusicResponsiveListItem[] = [];
|
||||
try {
|
||||
@ -519,9 +510,9 @@ export async function downloadPlaylist(givenUrl?: string | URL) {
|
||||
}
|
||||
|
||||
if (!playlist || !playlist.items || playlist.items.length === 0) {
|
||||
sendError(new Error(
|
||||
t('plugins.downloader.backend.feedback.playlist-is-empty'),
|
||||
));
|
||||
sendError(
|
||||
new Error(t('plugins.downloader.backend.feedback.playlist-is-empty')),
|
||||
);
|
||||
}
|
||||
|
||||
const normalPlaylistTitle = playlist.header?.title?.text;
|
||||
@ -558,11 +549,13 @@ export async function downloadPlaylist(givenUrl?: string | URL) {
|
||||
const playlistFolder = join(folder, safePlaylistTitle);
|
||||
if (existsSync(playlistFolder)) {
|
||||
if (!config.skipExisting) {
|
||||
sendError(new Error(
|
||||
t('plugins.downloader.backend.feedback.folder-already-exists', {
|
||||
playlistFolder,
|
||||
})
|
||||
));
|
||||
sendError(
|
||||
new Error(
|
||||
t('plugins.downloader.backend.feedback.folder-already-exists', {
|
||||
playlistFolder,
|
||||
}),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@ -571,14 +564,22 @@ export async function downloadPlaylist(givenUrl?: string | URL) {
|
||||
|
||||
dialog.showMessageBox(win, {
|
||||
type: 'info',
|
||||
buttons: [t('plugins.downloader.backend.dialog.start-download-playlist.buttons.ok')],
|
||||
buttons: [
|
||||
t('plugins.downloader.backend.dialog.start-download-playlist.buttons.ok'),
|
||||
],
|
||||
title: t('plugins.downloader.backend.dialog.start-download-playlist.title'),
|
||||
message: t('plugins.downloader.backend.dialog.start-download-playlist.message', {
|
||||
playlistTitle,
|
||||
}),
|
||||
detail: t('plugins.downloader.backend.dialog.start-download-playlist.detail', {
|
||||
playlistSize: items.length,
|
||||
}),
|
||||
message: t(
|
||||
'plugins.downloader.backend.dialog.start-download-playlist.message',
|
||||
{
|
||||
playlistTitle,
|
||||
},
|
||||
),
|
||||
detail: t(
|
||||
'plugins.downloader.backend.dialog.start-download-playlist.detail',
|
||||
{
|
||||
playlistSize: items.length,
|
||||
},
|
||||
),
|
||||
});
|
||||
|
||||
if (is.dev()) {
|
||||
@ -611,7 +612,7 @@ export async function downloadPlaylist(givenUrl?: string | URL) {
|
||||
t('plugins.downloader.backend.feedback.downloading-counter', {
|
||||
current: counter,
|
||||
total: items.length,
|
||||
})
|
||||
}),
|
||||
);
|
||||
const trackId = isAlbum ? counter : undefined;
|
||||
await downloadSongFromId(
|
||||
|
||||
@ -4,11 +4,12 @@ import { downloadPlaylist } from './main';
|
||||
import { defaultMenuDownloadLabel, getFolder } from './main/utils';
|
||||
import { DefaultPresetList } from './types';
|
||||
|
||||
import { t } from '@/i18n';
|
||||
|
||||
import type { MenuContext } from '@/types/contexts';
|
||||
import type { MenuTemplate } from '@/menu';
|
||||
|
||||
import type { DownloaderPluginConfig } from './index';
|
||||
import { t } from '@/i18n';
|
||||
|
||||
export const onMenu = async ({
|
||||
getConfig,
|
||||
|
||||
@ -6,12 +6,13 @@ import { getSongInfo } from '@/providers/song-info-front';
|
||||
|
||||
import { LoggerPrefix } from '@/utils';
|
||||
|
||||
import { t } from '@/i18n';
|
||||
|
||||
import { ElementFromHtml } from '../utils/renderer';
|
||||
|
||||
import type { RendererContext } from '@/types/contexts';
|
||||
|
||||
import type { DownloaderPluginConfig } from './index';
|
||||
import { t } from '@/i18n';
|
||||
|
||||
let menu: Element | null = null;
|
||||
let progress: Element | null = null;
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
import { LoggerPrefix } from '@/utils';
|
||||
|
||||
import { t } from '@/i18n';
|
||||
|
||||
import type { SongInfo } from '@/providers/song-info';
|
||||
import type { RendererContext } from '@/types/contexts';
|
||||
import type { LyricsGeniusPluginConfig } from '@/plugins/lyrics-genius/index';
|
||||
import { t } from '@/i18n';
|
||||
|
||||
export const onRendererLoad = ({
|
||||
ipc: { invoke, on },
|
||||
|
||||
@ -59,21 +59,27 @@ export const onMenu = async ({
|
||||
label: t('plugins.notifications.menu.interactive-settings.label'),
|
||||
submenu: [
|
||||
{
|
||||
label: t('plugins.notifications.menu.interactive-settings.submenu.tray-controls'),
|
||||
label: t(
|
||||
'plugins.notifications.menu.interactive-settings.submenu.tray-controls',
|
||||
),
|
||||
type: 'checkbox',
|
||||
checked: config.trayControls,
|
||||
click: (item: MenuItem) =>
|
||||
setConfig({ trayControls: item.checked }),
|
||||
},
|
||||
{
|
||||
label: t('plugins.notifications.menu.interactive-settings.submenu.hide-button-text'),
|
||||
label: t(
|
||||
'plugins.notifications.menu.interactive-settings.submenu.hide-button-text',
|
||||
),
|
||||
type: 'checkbox',
|
||||
checked: config.hideButtonText,
|
||||
click: (item: MenuItem) =>
|
||||
setConfig({ hideButtonText: item.checked }),
|
||||
},
|
||||
{
|
||||
label: t('plugins.notifications.menu.interactive-settings.submenu.refresh-on-play-pause'),
|
||||
label: t(
|
||||
'plugins.notifications.menu.interactive-settings.submenu.refresh-on-play-pause',
|
||||
),
|
||||
type: 'checkbox',
|
||||
checked: config.refreshOnPlayPause,
|
||||
click: (item: MenuItem) =>
|
||||
|
||||
@ -55,7 +55,9 @@ export const onMenu = async ({
|
||||
keybindOptions: [
|
||||
{
|
||||
value: 'hotkey',
|
||||
label: t('plugins.picture-in-picture.menu.prompt.keybind-options.hotkey'),
|
||||
label: t(
|
||||
'plugins.picture-in-picture.menu.prompt.keybind-options.hotkey',
|
||||
),
|
||||
default: config.hotkey,
|
||||
},
|
||||
],
|
||||
|
||||
@ -44,7 +44,9 @@
|
||||
class="text style-scope ytmusic-menu-navigation-item-renderer"
|
||||
id="ytmcustom-pip"
|
||||
>
|
||||
<ytmd-trans key="plugins.picture-in-picture.templates.button"></ytmd-trans>
|
||||
<ytmd-trans
|
||||
key="plugins.picture-in-picture.templates.button"
|
||||
></ytmd-trans>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -83,7 +83,8 @@
|
||||
class="text style-scope ytmusic-menu-navigation-item-renderer"
|
||||
id="ytmcustom-playback-speed"
|
||||
>
|
||||
<ytmd-trans key="plugins.playback-speed.templates.button"></ytmd-trans> (<span id="playback-speed-value">1</span>)
|
||||
<ytmd-trans key="plugins.playback-speed.templates.button"></ytmd-trans>
|
||||
(<span id="playback-speed-value">1</span>)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -103,12 +103,16 @@ export default createPlugin({
|
||||
type: 'keybind',
|
||||
keybindOptions: [
|
||||
kb(
|
||||
t('plugins.precise-volume.prompt.global-shortcuts.keybind-options.increase'),
|
||||
t(
|
||||
'plugins.precise-volume.prompt.global-shortcuts.keybind-options.increase',
|
||||
),
|
||||
'volumeUp',
|
||||
options.globalShortcuts?.volumeUp,
|
||||
),
|
||||
kb(
|
||||
t('plugins.precise-volume.prompt.global-shortcuts.keybind-options.decrease'),
|
||||
t(
|
||||
'plugins.precise-volume.prompt.global-shortcuts.keybind-options.decrease',
|
||||
),
|
||||
'volumeDown',
|
||||
options.globalShortcuts?.volumeDown,
|
||||
),
|
||||
|
||||
@ -24,11 +24,18 @@ export default createPlugin({
|
||||
type: 'question',
|
||||
buttons: qualityLabels,
|
||||
defaultId: currentIndex,
|
||||
title: t('plugins.quality-changer.backend.dialog.quality-changer.title'),
|
||||
message: t('plugins.quality-changer.backend.dialog.quality-changer.message'),
|
||||
detail: t('plugins.quality-changer.backend.dialog.quality-changer.detail', {
|
||||
quality: qualityLabels[currentIndex],
|
||||
}),
|
||||
title: t(
|
||||
'plugins.quality-changer.backend.dialog.quality-changer.title',
|
||||
),
|
||||
message: t(
|
||||
'plugins.quality-changer.backend.dialog.quality-changer.message',
|
||||
),
|
||||
detail: t(
|
||||
'plugins.quality-changer.backend.dialog.quality-changer.detail',
|
||||
{
|
||||
quality: qualityLabels[currentIndex],
|
||||
},
|
||||
),
|
||||
cancelId: -1,
|
||||
}),
|
||||
);
|
||||
|
||||
@ -36,9 +36,21 @@ export const onMenu = async ({
|
||||
type: 'keybind',
|
||||
keybindOptions: [
|
||||
// If default=undefined then no default is used
|
||||
kb(t('plugins.shortcuts.prompt.keybind.keybind-options.previous'), 'previous', config.global?.previous),
|
||||
kb(t('plugins.shortcuts.prompt.keybind.keybind-options.play-pause'), 'playPause', config.global?.playPause),
|
||||
kb(t('plugins.shortcuts.prompt.keybind.keybind-options.next'), 'next', config.global?.next),
|
||||
kb(
|
||||
t('plugins.shortcuts.prompt.keybind.keybind-options.previous'),
|
||||
'previous',
|
||||
config.global?.previous,
|
||||
),
|
||||
kb(
|
||||
t('plugins.shortcuts.prompt.keybind.keybind-options.play-pause'),
|
||||
'playPause',
|
||||
config.global?.playPause,
|
||||
),
|
||||
kb(
|
||||
t('plugins.shortcuts.prompt.keybind.keybind-options.next'),
|
||||
'next',
|
||||
config.global?.next,
|
||||
),
|
||||
],
|
||||
height: 270,
|
||||
...promptOptions(),
|
||||
|
||||
@ -114,12 +114,16 @@ export default (api: YoutubePlayer) => {
|
||||
pause: (e: Event) => playPausedHandler(e, 'pause'),
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/require-await
|
||||
const videoEventDispatcher = async (name: string, videoData: VideoDataChangeValue) => document.dispatchEvent(
|
||||
new CustomEvent<VideoDataChanged>('videodatachange', {
|
||||
detail: { name, videoData },
|
||||
}),
|
||||
);
|
||||
const videoEventDispatcher = async (
|
||||
name: string,
|
||||
videoData: VideoDataChangeValue,
|
||||
// eslint-disable-next-line @typescript-eslint/require-await
|
||||
) =>
|
||||
document.dispatchEvent(
|
||||
new CustomEvent<VideoDataChanged>('videodatachange', {
|
||||
detail: { name, videoData },
|
||||
}),
|
||||
);
|
||||
|
||||
const waitingEvent = new Set<string>();
|
||||
// Name = "dataloaded" and abit later "dataupdated"
|
||||
|
||||
@ -159,18 +159,21 @@ async function onApiLoaded() {
|
||||
* YouTube Music still using ES5, so we need to define custom elements using ES5 style
|
||||
*/
|
||||
const defineYTMDTransElements = () => {
|
||||
const YTMDTrans = function() {};
|
||||
const YTMDTrans = function () {};
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
YTMDTrans.prototype = Object.create(HTMLElement.prototype);
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
YTMDTrans.prototype.connectedCallback = function() {
|
||||
const that = (this as HTMLElement);
|
||||
YTMDTrans.prototype.connectedCallback = function () {
|
||||
const that = this as HTMLElement;
|
||||
const key = that.getAttribute('key');
|
||||
if (key) {
|
||||
that.innerHTML = i18t(key);
|
||||
}
|
||||
};
|
||||
customElements.define('ytmd-trans', YTMDTrans as unknown as CustomElementConstructor);
|
||||
customElements.define(
|
||||
'ytmd-trans',
|
||||
YTMDTrans as unknown as CustomElementConstructor,
|
||||
);
|
||||
};
|
||||
|
||||
(async () => {
|
||||
|
||||
4
src/reset.d.ts
vendored
4
src/reset.d.ts
vendored
@ -32,8 +32,8 @@ declare global {
|
||||
togglePictureInPicture: () => void;
|
||||
reload: () => void;
|
||||
i18n: {
|
||||
t: typeof t,
|
||||
}
|
||||
t: typeof t;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -119,13 +119,10 @@ export const startPlugin = async <Config extends PluginConfig>(
|
||||
} catch (err) {
|
||||
console.error(
|
||||
LoggerPrefix,
|
||||
t(
|
||||
'common.console.plugins.execute-failed',
|
||||
{
|
||||
pluginName: id,
|
||||
contextName: options.ctx,
|
||||
},
|
||||
),
|
||||
t('common.console.plugins.execute-failed', {
|
||||
pluginName: id,
|
||||
contextName: options.ctx,
|
||||
}),
|
||||
);
|
||||
console.trace(err);
|
||||
return false;
|
||||
@ -166,13 +163,10 @@ export const stopPlugin = async <Config extends PluginConfig>(
|
||||
} catch (err) {
|
||||
console.error(
|
||||
LoggerPrefix,
|
||||
t(
|
||||
'common.console.plugins.execute-failed',
|
||||
{
|
||||
pluginName: id,
|
||||
contextName: options.ctx,
|
||||
},
|
||||
),
|
||||
t('common.console.plugins.execute-failed', {
|
||||
pluginName: id,
|
||||
contextName: options.ctx,
|
||||
}),
|
||||
);
|
||||
console.trace(err);
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user