summaryrefslogtreecommitdiff
path: root/frontend/src/plugin.ts
blob: f2b99f7154ef30a32c834958155aaf438ba408e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import type { JSX } from 'react';
export enum PluginLoadType {
  LEGACY_EVAL_IIFE = 0, // legacy, uses legacy serverAPI
  ESMODULE_V1 = 1, // esmodule loading with modern @decky/backend apis
}

export interface Plugin {
  name: string;
  version?: string;
  loadType?: PluginLoadType;
  icon: JSX.Element;
  content?: JSX.Element;
  onDismount?(): void;
  alwaysRender?: boolean;
  titleView?: JSX.Element;
}

export enum InstallType {
  INSTALL,
  REINSTALL,
  UPDATE,
  DOWNGRADE,
  OVERWRITE,
}

// values are the JSON keys used in the translation file
// IMPORTANT! keep in sync with `t(...)` comments where this is used
export const InstallTypeTranslationMapping = {
  [InstallType.INSTALL]: 'install',
  [InstallType.REINSTALL]: 'reinstall',
  [InstallType.UPDATE]: 'update',
  [InstallType.DOWNGRADE]: 'downgrade',
  [InstallType.OVERWRITE]: 'overwrite',
} as const satisfies Record<InstallType, string>;

type installPluginArgs = [
  artifact: string,
  name?: string,
  version?: string,
  hash?: string | boolean,
  installType?: InstallType,
];

export let installPlugin = DeckyBackend.callable<installPluginArgs>('utilities/install_plugin');

type installPluginsArgs = [
  requests: {
    artifact: string;
    name?: string;
    version?: string;
    hash?: string | boolean;
    installType?: InstallType;
  }[],
];

export let installPlugins = DeckyBackend.callable<installPluginsArgs>('utilities/install_plugins');

export let uninstallPlugin = DeckyBackend.callable<[name: string]>('utilities/uninstall_plugin');