feat(refactor): PluginDefinition::platform (#3665)

This commit is contained in:
Angelos Bouklis
2025-09-05 09:28:17 +03:00
committed by GitHub
parent d329076b52
commit dcc611c7d0
9 changed files with 72 additions and 13 deletions

View File

@ -59,14 +59,7 @@ import ErrorHtmlAsset from '@assets/error.html?asset';
import { defaultAuthProxyConfig } from '@/plugins/auth-proxy-adapter/config';
import type { PluginConfig } from '@/types/plugins';
if (!is.macOS()) {
delete (await allPlugins())['touchbar'];
}
if (!is.windows()) {
delete (await allPlugins())['taskbar-mediacontrol'];
}
import { type PluginConfig } from '@/types/plugins';
// Catch errors and log them
unhandled({

View File

@ -14,11 +14,13 @@ import registerCallback, {
} from '@/providers/song-info';
import { mediaIcons } from '@/types/media-icons';
import { t } from '@/i18n';
import { Platform } from '@/types/plugins';
export default createPlugin({
name: () => t('plugins.taskbar-mediacontrol.name'),
description: () => t('plugins.taskbar-mediacontrol.description'),
restartNeeded: true,
platform: Platform.Windows,
config: {
enabled: false,
},

View File

@ -6,11 +6,13 @@ import registerCallback, { SongInfoEvent } from '@/providers/song-info';
import { t } from '@/i18n';
import youtubeMusicIcon from '@assets/youtube-music.png?asset&asarUnpack';
import { Platform } from '@/types/plugins';
export default createPlugin({
name: () => t('plugins.touchbar.name'),
description: () => t('plugins.touchbar.description'),
restartNeeded: true,
platform: Platform.macOS,
config: {
enabled: false,
},

2
src/reset.d.ts vendored
View File

@ -19,6 +19,8 @@ declare global {
'videodatachange': CustomEvent<VideoDataChanged>;
}
declare var electronIs: typeof import('electron-is')
interface Window {
trustedTypes?: typeof trustedTypes;
ipcRenderer: typeof electronIpcRenderer;

View File

@ -38,6 +38,13 @@ export type RendererPluginLifecycle<Config, Context, This> =
| PluginLifecycleSimple<Context, This>
| RendererPluginLifecycleExtra<Config, Context, This>;
export enum Platform {
Windows = 1 << 0,
macOS = 1 << 1,
Linux = 1 << 2,
Freebsd = 1 << 3
}
export interface PluginDef<
BackendProperties,
PreloadProperties,
@ -49,6 +56,7 @@ export interface PluginDef<
description?: () => string;
addedVersion?: string;
config?: Config;
platform?: Platform;
menu?: (
ctx: MenuContext<Config>,