File size: 1,280 Bytes
369fac9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import type { App } from './api/index.js';
export interface PluginDescriptor {
    id: string;
    label: string;
    app: App;
    packageName?: string;
    homepage?: string;
    componentStateTypes?: string[];
    logo?: string;
    disableAppScope?: boolean;
    disablePluginScope?: boolean;
    /**
     * Run the plugin setup and expose the api even if the devtools is not opened yet.
     * Useful to record timeline events early.
     */
    enableEarlyProxy?: boolean;
    settings?: Record<string, PluginSettingsItem>;
}
export type PluginSettingsItem = {
    label: string;
    description?: string;
} & ({
    type: 'boolean';
    defaultValue: boolean;
} | {
    type: 'choice';
    defaultValue: string | number;
    options: {
        value: string | number;
        label: string;
    }[];
    component?: 'select' | 'button-group';
} | {
    type: 'text';
    defaultValue: string;
});
type InferSettingsType<T extends PluginSettingsItem> = [T] extends [{
    type: 'boolean';
}] ? boolean : [T] extends [{
    type: 'choice';
}] ? T['options'][number]['value'] : [T] extends [{
    type: 'text';
}] ? string : unknown;
export type ExtractSettingsTypes<O extends Record<string, PluginSettingsItem>> = {
    [K in keyof O]: InferSettingsType<O[K]>;
};
export {};