145 lines
3.1 kB
1
export type Config = {
2
extensions: ConfigExtensions;
3
repositories: string[];
4
devSearchPaths?: string[];
5
loggerLevel?: string;
6
patchAll?: boolean;
7
};
8
9
export type ConfigExtensions = { [key: string]: boolean } | { [key: string]: ConfigExtension };
10
11
export type ConfigExtension = {
12
enabled: boolean;
13
config?: Record<string, any>;
14
};
15
16
export enum ExtensionSettingType {
17
Boolean = "boolean",
18
Number = "number",
19
String = "string",
20
MultilineString = "multilinestring",
21
Select = "select",
22
MultiSelect = "multiselect",
23
List = "list",
24
Dictionary = "dictionary",
25
Custom = "custom"
26
}
27
28
export type SelectOption =
29
| string
30
| {
31
value: string;
32
label: string;
33
};
34
35
export type BooleanSettingType = {
36
/**
37
* Displays as a simple switch.
38
*/
39
type: ExtensionSettingType.Boolean;
40
default?: boolean;
41
};
42
43
export type NumberSettingType = {
44
/**
45
* Displays as a simple slider.
46
*/
47
type: ExtensionSettingType.Number;
48
default?: number;
49
min?: number;
50
max?: number;
51
};
52
53
export type StringSettingType = {
54
/**
55
* Displays as a single line string input.
56
*/
57
type: ExtensionSettingType.String;
58
default?: string;
59
};
60
61
export type MultilineTextInputSettingType = {
62
/**
63
* Displays as a multiple line string input.
64
*/
65
type: ExtensionSettingType.MultilineString;
66
default?: string;
67
};
68
69
export type SelectSettingType = {
70
/**
71
* A dropdown to pick between one of many values.
72
*/
73
type: ExtensionSettingType.Select;
74
options: SelectOption[];
75
default?: string;
76
};
77
78
export type MultiSelectSettingType = {
79
/**
80
* A dropdown to pick multiple values.
81
*/
82
type: ExtensionSettingType.MultiSelect;
83
options: string[];
84
default?: string[];
85
};
86
87
export type ListSettingType = {
88
/**
89
* A list of strings that the user can add or remove from.
90
*/
91
type: ExtensionSettingType.List;
92
default?: string[];
93
};
94
95
export type DictionarySettingType = {
96
/**
97
* A dictionary (key-value pair) that the user can add or remove from.
98
*/
99
type: ExtensionSettingType.Dictionary;
100
default?: Record<string, string>;
101
};
102
103
export type CustomSettingType = {
104
/**
105
* A custom component.
106
* You can use the registerConfigComponent function in the Moonbase API to register a React component to render here.
107
*/
108
type: ExtensionSettingType.Custom;
109
default?: any;
110
};
111
112
export enum ExtensionSettingsAdvice {
113
None = "none",
114
Reload = "reload",
115
Restart = "restart"
116
}
117
118
export type ExtensionSettingsManifest = {
119
/**
120
* A human friendly name for the setting.
121
*/
122
displayName?: string;
123
124
/**
125
* A longer description for the setting.
126
* Markdown is not supported.
127
*/
128
description?: string;
129
130
/**
131
* The "advice" to give upon changing this setting.
132
* Can be configured to reload the client, restart the client, or do nothing.
133
*/
134
advice?: ExtensionSettingsAdvice;
135
} & (
136
| BooleanSettingType
137
| NumberSettingType
138
| StringSettingType
139
| MultilineTextInputSettingType
140
| SelectSettingType
141
| MultiSelectSettingType
142
| ListSettingType
143
| DictionarySettingType
144
| CustomSettingType
145
);
146