@unbound-app/api 0.11.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ambient/image-modules.d.ts +58 -0
- package/package.json +27 -4
- package/src/_internal.d.ts +2771 -139
- package/src/{utils.d.ts → _types.d.ts} +10 -0
- package/src/assets.d.ts +64 -26
- package/src/builtins.d.ts +17 -0
- package/src/commands.d.ts +101 -25
- package/src/dialogs.d.ts +90 -25
- package/src/flux.d.ts +317 -0
- package/src/fonts.d.ts +51 -0
- package/src/fs.d.ts +15 -24
- package/src/global.d.ts +173 -11
- package/src/i18n.d.ts +33 -31
- package/src/iconPacks.d.ts +43 -0
- package/src/index.d.ts +14 -0
- package/src/marketplace.d.ts +50 -0
- package/src/metro/api.d.ts +8 -0
- package/src/metro/common.d.ts +34 -5
- package/src/metro/components.d.ts +34 -25
- package/src/metro/filters.d.ts +31 -16
- package/src/metro/index.d.ts +26079 -83
- package/src/metro/stores.d.ts +5 -0
- package/src/native.d.ts +77 -5
- package/src/patcher.d.ts +214 -57
- package/src/plugins.d.ts +55 -0
- package/src/settings.d.ts +8 -16
- package/src/shims.d.ts +5 -0
- package/src/storage.d.ts +80 -224
- package/src/sync.d.ts +51 -0
- package/src/themes.d.ts +43 -0
- package/src/toasts.d.ts +62 -9
- package/src/ui.d.ts +650 -0
- package/src/updates.d.ts +25 -0
- package/src/utils/index.d.ts +53 -0
- package/src/utils/react/index.d.ts +82 -0
- package/testing/fake-api.ts +256 -0
- package/testing/fake-components.ts +183 -0
- package/testing/fake-feedback.ts +258 -0
- package/testing/fake-fs.ts +54 -0
- package/testing/fake-java.ts +513 -0
- package/testing/fake-locales.ts +85 -0
- package/testing/fake-metro.ts +346 -0
- package/testing/fake-native-bridge.ts +98 -0
- package/testing/fake-native.ts +211 -0
- package/testing/fake-objc.ts +388 -0
- package/testing/fake-plugins.ts +176 -0
- package/testing/fake-react-native-modules.ts +362 -0
- package/testing/fake-react-native.ts +180 -0
- package/testing/fake-react.ts +54 -0
- package/testing/fake-settings-panel.ts +173 -0
- package/testing/fake-settings.ts +428 -0
- package/testing/fake-timers.ts +74 -0
- package/testing/fake-utils.ts +216 -0
- package/testing/icu-format.ts +132 -0
- package/testing/icu-parse.ts +277 -0
- package/testing/index.ts +42 -0
- package/testing/install-addon-globals.ts +260 -0
- package/testing/listener-registry.ts +39 -0
- package/testing/memory-storage.ts +149 -0
- package/testing/plugin-files.ts +155 -0
- package/testing/plugin-lifecycle.ts +149 -0
- package/testing/plugin-types.ts +34 -0
- package/testing/preset.ts +263 -0
- package/testing/react-patcher.ts +154 -0
- package/testing/react-value.ts +3 -0
- package/testing/recorders.ts +183 -0
- package/testing/recording-patcher.ts +173 -0
- package/testing/render.ts +84 -0
- package/testing/session.ts +77 -0
- package/testing/test-node.ts +163 -0
- package/testing/test-renderer.ts +753 -0
- package/testing/unfrozen-elements.ts +49 -0
package/src/ui.d.ts
ADDED
|
@@ -0,0 +1,650 @@
|
|
|
1
|
+
// Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
DesignModule,
|
|
5
|
+
DurationUnit,
|
|
6
|
+
EntityDisplay,
|
|
7
|
+
IconInput,
|
|
8
|
+
SettingValue,
|
|
9
|
+
SettingsSchema,
|
|
10
|
+
} from './_internal';
|
|
11
|
+
import type { Without } from './_types';
|
|
12
|
+
import * as React$1 from 'react';
|
|
13
|
+
import { ComponentProps, ComponentType, FunctionComponent, ReactElement, ReactNode } from 'react';
|
|
14
|
+
import * as RN from 'react-native';
|
|
15
|
+
import { ImageStyle, TextStyle, ViewStyle } from 'react-native';
|
|
16
|
+
/**
|
|
17
|
+
* @description Discord's full-width Row Button, which runs something when pressed and asks first when `confirmation` is set;
|
|
18
|
+
* `danger` leads with a red trash icon.
|
|
19
|
+
* @param props The row's label, variant, confirmation and press handler.
|
|
20
|
+
* @returns The row.
|
|
21
|
+
*/
|
|
22
|
+
export declare function ButtonRow({
|
|
23
|
+
label,
|
|
24
|
+
subLabel,
|
|
25
|
+
variant,
|
|
26
|
+
confirmation,
|
|
27
|
+
disabled,
|
|
28
|
+
onPress,
|
|
29
|
+
}: ButtonRowProps): React$1.ReactElement;
|
|
30
|
+
/**
|
|
31
|
+
* @description A settings row with a checkbox, Discord's `TableCheckboxRow`.
|
|
32
|
+
* @param props The row's label, state and change handler.
|
|
33
|
+
* @returns The row.
|
|
34
|
+
*/
|
|
35
|
+
export declare function CheckboxRow({
|
|
36
|
+
label,
|
|
37
|
+
subLabel,
|
|
38
|
+
value,
|
|
39
|
+
disabled,
|
|
40
|
+
onValueChange,
|
|
41
|
+
}: CheckboxRowProps): React$1.ReactElement;
|
|
42
|
+
/**
|
|
43
|
+
* @description A titled group of checkbox rows, one per option, for picking several.
|
|
44
|
+
* @param props The group's title, checked values, options and change handler.
|
|
45
|
+
* @returns The group.
|
|
46
|
+
*/
|
|
47
|
+
export declare function ChecklistRow({
|
|
48
|
+
title,
|
|
49
|
+
description,
|
|
50
|
+
value,
|
|
51
|
+
options,
|
|
52
|
+
maxItems,
|
|
53
|
+
disabled,
|
|
54
|
+
onChange,
|
|
55
|
+
}: ChecklistRowProps): React$1.ReactElement;
|
|
56
|
+
/**
|
|
57
|
+
* @description A settings row that shows a color swatch, opens Discord's color picker when pressed, takes a typed hex code and offers a reset back to the default. A typed code is saved even when it matches the default, which the picker cannot do: Discord's picker reports its current color when it is dismissed, so a pick that matches the color already shown is ignored.
|
|
58
|
+
* @param props The row's label, chosen color, the default it falls back to and the change handler.
|
|
59
|
+
* @returns The row.
|
|
60
|
+
*/
|
|
61
|
+
export declare function ColorRow({
|
|
62
|
+
label,
|
|
63
|
+
color,
|
|
64
|
+
fallbackColor,
|
|
65
|
+
fallbackLabel,
|
|
66
|
+
onChange,
|
|
67
|
+
}: ColorRowProps): React$1.ReactElement;
|
|
68
|
+
/**
|
|
69
|
+
* @description A settings input for a duration: an amount, and the unit it is in. The duration saves in milliseconds.
|
|
70
|
+
* @param props The row's label, saved duration, range, units and change handler.
|
|
71
|
+
* @returns The row.
|
|
72
|
+
*/
|
|
73
|
+
export declare function DurationRow({
|
|
74
|
+
label,
|
|
75
|
+
subLabel,
|
|
76
|
+
value,
|
|
77
|
+
minimum,
|
|
78
|
+
maximum,
|
|
79
|
+
units,
|
|
80
|
+
disabled,
|
|
81
|
+
onChange,
|
|
82
|
+
}: DurationRowProps): React$1.ReactElement;
|
|
83
|
+
/**
|
|
84
|
+
* @description A settings input for a Discord id, showing the name the client's stores hold for it. It takes an id typed or pasted; it has no search.
|
|
85
|
+
* @param props The row's entity, label, saved id and change handler.
|
|
86
|
+
* @returns The input.
|
|
87
|
+
*/
|
|
88
|
+
export declare function EntityRow({
|
|
89
|
+
entity,
|
|
90
|
+
label,
|
|
91
|
+
value,
|
|
92
|
+
disabled,
|
|
93
|
+
onChange,
|
|
94
|
+
}: EntityRowProps): React$1.ReactElement;
|
|
95
|
+
/**
|
|
96
|
+
* @description A settings row, Discord's way: the label, and the saved text trailing (masked when secret). Pressing
|
|
97
|
+
* it opens Discord's titled action sheet with the input, its description and error, which saves only on Save.
|
|
98
|
+
* @param props The row's label, saved text, variant, validation and change handler.
|
|
99
|
+
* @returns The row.
|
|
100
|
+
*/
|
|
101
|
+
export declare function InputRow({
|
|
102
|
+
label,
|
|
103
|
+
subLabel,
|
|
104
|
+
value,
|
|
105
|
+
placeholder,
|
|
106
|
+
variant,
|
|
107
|
+
keyboardType,
|
|
108
|
+
maxLength,
|
|
109
|
+
disabled,
|
|
110
|
+
validate,
|
|
111
|
+
onChange,
|
|
112
|
+
}: InputRowProps): React$1.ReactElement;
|
|
113
|
+
/**
|
|
114
|
+
* @description A titled, editable list of strings: each row moves up or down or is removed, and an input adds one.
|
|
115
|
+
* @param props The group's title, saved strings, limit, validation and change handler.
|
|
116
|
+
* @returns The group.
|
|
117
|
+
*/
|
|
118
|
+
export declare function ListRow({
|
|
119
|
+
title,
|
|
120
|
+
description,
|
|
121
|
+
value,
|
|
122
|
+
maxItems,
|
|
123
|
+
validate,
|
|
124
|
+
disabled,
|
|
125
|
+
onChange,
|
|
126
|
+
}: ListRowProps): React$1.ReactElement;
|
|
127
|
+
/**
|
|
128
|
+
* @description A settings text input that grows with its text, Discord's `TextArea`.
|
|
129
|
+
* @param props The input's label, saved text, validation and change handler.
|
|
130
|
+
* @returns The input.
|
|
131
|
+
*/
|
|
132
|
+
export declare function MultilineRow(props: MultilineRowProps): React$1.ReactElement;
|
|
133
|
+
/**
|
|
134
|
+
* @description A settings input for a number with no slider range, checked against whether it must be whole, its range and its step before it saves.
|
|
135
|
+
* @param props The input's label, saved number, constraints and change handler.
|
|
136
|
+
* @returns The input.
|
|
137
|
+
*/
|
|
138
|
+
export declare function NumberRow({
|
|
139
|
+
label,
|
|
140
|
+
subLabel,
|
|
141
|
+
value,
|
|
142
|
+
disabled,
|
|
143
|
+
onChange,
|
|
144
|
+
...constraints
|
|
145
|
+
}: NumberRowProps): React$1.ReactElement;
|
|
146
|
+
/**
|
|
147
|
+
* @description The standard settings page wrapper. A scroll view padded to 16 with a bottom safe-area
|
|
148
|
+
* inset and a 24px gap between form groups, matching how Discord lays out its own settings screens. Use
|
|
149
|
+
* it as the root of every settings page.
|
|
150
|
+
*/
|
|
151
|
+
export declare function Page({ children }: PageProps): React$1.ReactElement;
|
|
152
|
+
/**
|
|
153
|
+
* @description A settings row with a grid of color swatches, the picked one ringed, for a fixed set of colors.
|
|
154
|
+
* @param props The row's label, picked color, colors and change handler.
|
|
155
|
+
* @returns The row.
|
|
156
|
+
*/
|
|
157
|
+
export declare function PaletteRow({
|
|
158
|
+
label,
|
|
159
|
+
subLabel,
|
|
160
|
+
value,
|
|
161
|
+
presets,
|
|
162
|
+
disabled,
|
|
163
|
+
onChange,
|
|
164
|
+
}: PaletteRowProps): React$1.ReactElement;
|
|
165
|
+
/**
|
|
166
|
+
* @description A row showing the picked option that opens Discord's action sheet listing every option, for choices too many for a radio group.
|
|
167
|
+
* @param props The row's label, picked value, options and change handler.
|
|
168
|
+
* @returns The row.
|
|
169
|
+
*/
|
|
170
|
+
export declare function PickerRow({
|
|
171
|
+
label,
|
|
172
|
+
value,
|
|
173
|
+
options,
|
|
174
|
+
disabled,
|
|
175
|
+
onChange,
|
|
176
|
+
}: PickerRowProps): React$1.ReactElement;
|
|
177
|
+
/**
|
|
178
|
+
* @description A titled group of radio rows, one per option with its sub-label, Discord's `TableRadioGroup` as its appearance settings use it.
|
|
179
|
+
* @param props The group's title, picked value, options and change handler.
|
|
180
|
+
* @returns The group.
|
|
181
|
+
*/
|
|
182
|
+
export declare function RadioRow({
|
|
183
|
+
title,
|
|
184
|
+
description,
|
|
185
|
+
value,
|
|
186
|
+
options,
|
|
187
|
+
disabled,
|
|
188
|
+
onChange,
|
|
189
|
+
}: RadioRowProps): React$1.ReactElement;
|
|
190
|
+
/**
|
|
191
|
+
* @description A settings group with one row that puts every setting on the page back to its default.
|
|
192
|
+
* @param props The row's label, "Reset all to defaults" unless given, and what resetting does.
|
|
193
|
+
* @returns The group.
|
|
194
|
+
*/
|
|
195
|
+
export declare function ResetRow({ label, onReset }: ResetRowProps): React$1.ReactElement;
|
|
196
|
+
/**
|
|
197
|
+
* @description A card saying a change applies after Discord restarts, with a full-width button that restarts it now.
|
|
198
|
+
* @returns The card.
|
|
199
|
+
*/
|
|
200
|
+
export declare function RestartRow(): React$1.ReactElement;
|
|
201
|
+
/**
|
|
202
|
+
* @description One settings row, Discord's `TableRow`.
|
|
203
|
+
* @param props The row's label, sub-label, icon, trailing content and press handler.
|
|
204
|
+
* @returns The row.
|
|
205
|
+
*/
|
|
206
|
+
export declare function Row({ icon, ...props }: RowProps): React$1.ReactElement;
|
|
207
|
+
/**
|
|
208
|
+
* @description The settings panel generated from a plugin's settings schema: a row per setting, a section per
|
|
209
|
+
* `setting.section`, a restart hint once a `requiresRestart` setting changes, and a reset row.
|
|
210
|
+
* @param props The plugin's settings, messages, predicates and actions.
|
|
211
|
+
* @returns The page.
|
|
212
|
+
*/
|
|
213
|
+
export declare function SchemaPanel({
|
|
214
|
+
settings,
|
|
215
|
+
messages,
|
|
216
|
+
useMessages,
|
|
217
|
+
predicates,
|
|
218
|
+
actions,
|
|
219
|
+
pluginId,
|
|
220
|
+
}: SchemaPanelProps): React$1.ReactElement;
|
|
221
|
+
/**
|
|
222
|
+
* @description A settings text input that hides what is typed, for tokens and passwords. A snapshot of the settings masks its value.
|
|
223
|
+
* @param props The input's label, saved text and change handler.
|
|
224
|
+
* @returns The input.
|
|
225
|
+
*/
|
|
226
|
+
export declare function SecretRow(props: SecretRowProps): React$1.ReactElement;
|
|
227
|
+
/**
|
|
228
|
+
* @description A titled group of settings rows, Discord's `TableRowGroup`.
|
|
229
|
+
* @param props The group's title and rows.
|
|
230
|
+
* @returns The group.
|
|
231
|
+
*/
|
|
232
|
+
export declare function Section(props: SectionProps): React$1.ReactElement;
|
|
233
|
+
/**
|
|
234
|
+
* @description A settings row with Discord's `SegmentedControl` under its label, as Discord's own settings draw one,
|
|
235
|
+
* for two to four short options. A value changed elsewhere moves the control along with it.
|
|
236
|
+
* @param props The row's label, picked value, options and change handler.
|
|
237
|
+
* @returns The row.
|
|
238
|
+
*/
|
|
239
|
+
export declare function SegmentedRow({
|
|
240
|
+
label,
|
|
241
|
+
subLabel,
|
|
242
|
+
value,
|
|
243
|
+
options,
|
|
244
|
+
disabled,
|
|
245
|
+
onChange,
|
|
246
|
+
}: SegmentedRowProps): React$1.ReactElement;
|
|
247
|
+
/**
|
|
248
|
+
* @description A settings row with Discord's form slider, as its own settings draw one: the label, then the slider
|
|
249
|
+
* with its value label and default mark. The value updates while dragging and is saved when the drag ends; Android's
|
|
250
|
+
* slider and iOS's take differently named props, so it passes both.
|
|
251
|
+
* @param props The row's label, value, default, range and change handler.
|
|
252
|
+
* @returns The row, or `null` when Discord's slider is unavailable.
|
|
253
|
+
*/
|
|
254
|
+
export declare function SliderRow({
|
|
255
|
+
label,
|
|
256
|
+
subLabel,
|
|
257
|
+
value,
|
|
258
|
+
defaultValue,
|
|
259
|
+
minimum,
|
|
260
|
+
maximum,
|
|
261
|
+
step,
|
|
262
|
+
unit,
|
|
263
|
+
format,
|
|
264
|
+
onChange,
|
|
265
|
+
}: SliderRowProps): React$1.ReactElement | null;
|
|
266
|
+
/**
|
|
267
|
+
* @description A settings row with minus and plus buttons around the current number, each press moving it one step within its range.
|
|
268
|
+
* @param props The row's label, value, range, step and change handler.
|
|
269
|
+
* @returns The row.
|
|
270
|
+
*/
|
|
271
|
+
export declare function StepperRow({
|
|
272
|
+
label,
|
|
273
|
+
subLabel,
|
|
274
|
+
value,
|
|
275
|
+
minimum,
|
|
276
|
+
maximum,
|
|
277
|
+
step,
|
|
278
|
+
disabled,
|
|
279
|
+
onChange,
|
|
280
|
+
}: StepperRowProps): React$1.ReactElement;
|
|
281
|
+
/**
|
|
282
|
+
* @description A settings row with a switch, Discord's `TableSwitchRow`.
|
|
283
|
+
* @param props The row's label, value, change handler and icon.
|
|
284
|
+
* @returns The row.
|
|
285
|
+
*/
|
|
286
|
+
export declare function SwitchRow({ icon, ...props }: SwitchRowProps): React$1.ReactElement;
|
|
287
|
+
/**
|
|
288
|
+
* @description A settings input for an http or https URL, which saves only a URL or nothing.
|
|
289
|
+
* @param props The input's label, saved URL and change handler.
|
|
290
|
+
* @returns The input.
|
|
291
|
+
*/
|
|
292
|
+
export declare function UrlRow(props: UrlRowProps): React$1.ReactElement;
|
|
293
|
+
/** Props for `ButtonRow`. */
|
|
294
|
+
export type ButtonRowProps = {
|
|
295
|
+
/** The row's label. */
|
|
296
|
+
label: string;
|
|
297
|
+
/** Text shown under the label; none when omitted. */
|
|
298
|
+
subLabel?: string;
|
|
299
|
+
/** `danger` draws the row red, for something that cannot be undone. */
|
|
300
|
+
variant?: 'button' | 'danger';
|
|
301
|
+
/** A question asked before `onPress` runs; none when omitted. */
|
|
302
|
+
confirmation?: string;
|
|
303
|
+
/** Dims the row and ignores input. Defaults to false. */
|
|
304
|
+
disabled?: boolean;
|
|
305
|
+
/** Called when the row is pressed, after the user confirms. */
|
|
306
|
+
onPress: () => void;
|
|
307
|
+
};
|
|
308
|
+
/** Props for `CheckboxRow`. */
|
|
309
|
+
export type CheckboxRowProps = {
|
|
310
|
+
/** The row's label. */
|
|
311
|
+
label: string;
|
|
312
|
+
/** Text shown under the label; none when omitted. */
|
|
313
|
+
subLabel?: string;
|
|
314
|
+
/** Whether the box is checked. */
|
|
315
|
+
value: boolean;
|
|
316
|
+
/** Dims the row and ignores input. Defaults to false. */
|
|
317
|
+
disabled?: boolean;
|
|
318
|
+
/** Called with the new state when the row is pressed. */
|
|
319
|
+
onValueChange: (value: boolean) => void;
|
|
320
|
+
};
|
|
321
|
+
/** Props for `ChecklistRow`. */
|
|
322
|
+
export type ChecklistRowProps = {
|
|
323
|
+
/** The group's title. */
|
|
324
|
+
title: string;
|
|
325
|
+
/** Text shown under the group; none when omitted. */
|
|
326
|
+
description?: string;
|
|
327
|
+
/** The checked values. */
|
|
328
|
+
value: string[];
|
|
329
|
+
/** The options, in order. */
|
|
330
|
+
options: ChoiceOption[];
|
|
331
|
+
/** The most options that can be checked; none when omitted. */
|
|
332
|
+
maxItems?: number;
|
|
333
|
+
/** Dims the row and ignores input. Defaults to false. */
|
|
334
|
+
disabled?: boolean;
|
|
335
|
+
/** Called with the checked values, in the options' order, after each press. */
|
|
336
|
+
onChange: (value: string[]) => void;
|
|
337
|
+
};
|
|
338
|
+
/** One option of a choice row. */
|
|
339
|
+
export type ChoiceOption = {
|
|
340
|
+
/** The value saved when the option is picked. */
|
|
341
|
+
value: string;
|
|
342
|
+
/** The option's label. */
|
|
343
|
+
label: string;
|
|
344
|
+
/** Text shown under the label; only `RadioRow` draws it. */
|
|
345
|
+
subLabel?: string;
|
|
346
|
+
};
|
|
347
|
+
/** Props for `ColorRow`. */
|
|
348
|
+
export type ColorRowProps = {
|
|
349
|
+
/** The row's title. */
|
|
350
|
+
label: string;
|
|
351
|
+
/** The chosen color as a `#RRGGBB` hex code, or `undefined` when the default applies. */
|
|
352
|
+
color: string | undefined;
|
|
353
|
+
/** The default color, swatched while `color` is unset and used as the hex input's placeholder. */
|
|
354
|
+
fallbackColor: string;
|
|
355
|
+
/** The text shown under the label while `color` is unset, in place of the hex code. */
|
|
356
|
+
fallbackLabel: string;
|
|
357
|
+
/** Called with the new `#RRGGBB` hex code, or `undefined` when the user resets or clears it. */
|
|
358
|
+
onChange: (color: string | undefined) => void;
|
|
359
|
+
};
|
|
360
|
+
/** What `storage.define` returns: a schema's settings, bound to one Bucket. */
|
|
361
|
+
export type DefinedSettings = {
|
|
362
|
+
/** The schema the settings were defined with. */
|
|
363
|
+
schema: SettingsSchema;
|
|
364
|
+
/** The settings as an object; assign a property, a section's too, to save it. */
|
|
365
|
+
values: SettingsValues;
|
|
366
|
+
/** Reads a setting by its dot-separated key; a stored value the schema rejects is logged, removed and read as the default. */
|
|
367
|
+
get: (key: string) => SettingValue;
|
|
368
|
+
/** Saves a setting by its dot-separated key; throws when the schema rejects the value. */
|
|
369
|
+
set: (key: string, value: SettingValue) => void;
|
|
370
|
+
/** Puts every setting back to its default, leaving other keys of the Bucket alone. */
|
|
371
|
+
reset: () => void;
|
|
372
|
+
/** React hook that reads a setting, or a section as an object, and re-renders when it changes. */
|
|
373
|
+
useSetting: (key: string) => SettingValue | SettingsValues;
|
|
374
|
+
/** React hook that re-renders on any change to the settings while `enabled`, and returns a number that changes with them. */
|
|
375
|
+
useVersion: (enabled?: boolean) => number;
|
|
376
|
+
};
|
|
377
|
+
/** Props for `DurationRow`. */
|
|
378
|
+
export type DurationRowProps = {
|
|
379
|
+
/** The row's label. */
|
|
380
|
+
label: string;
|
|
381
|
+
/** Text shown under the input; none when omitted. */
|
|
382
|
+
subLabel?: string;
|
|
383
|
+
/** The saved duration, in milliseconds. */
|
|
384
|
+
value: number;
|
|
385
|
+
/** The shortest duration, in milliseconds; none when omitted. */
|
|
386
|
+
minimum?: number;
|
|
387
|
+
/** The longest duration, in milliseconds; none when omitted. */
|
|
388
|
+
maximum?: number;
|
|
389
|
+
/** The units offered, smallest first; seconds, minutes and hours when omitted. */
|
|
390
|
+
units?: DurationUnit[];
|
|
391
|
+
/** Dims the row and ignores input. Defaults to false. */
|
|
392
|
+
disabled?: boolean;
|
|
393
|
+
/** Called with the new duration, in milliseconds. */
|
|
394
|
+
onChange: (value: number) => void;
|
|
395
|
+
};
|
|
396
|
+
/** Props for `EntityRow`. */
|
|
397
|
+
export type EntityRowProps = {
|
|
398
|
+
/** What the id names. */
|
|
399
|
+
entity: EntityDisplay;
|
|
400
|
+
/** The input's label. */
|
|
401
|
+
label: string;
|
|
402
|
+
/** The saved id; empty for none. */
|
|
403
|
+
value: string;
|
|
404
|
+
/** Dims the row and ignores input. Defaults to false. */
|
|
405
|
+
disabled?: boolean;
|
|
406
|
+
/** Called with a typed id, or an empty string to clear it. */
|
|
407
|
+
onChange: (value: string) => void;
|
|
408
|
+
};
|
|
409
|
+
/** The keyboard an input opens. */
|
|
410
|
+
export type InputKeyboard =
|
|
411
|
+
| 'default'
|
|
412
|
+
| 'number-pad'
|
|
413
|
+
| 'decimal-pad'
|
|
414
|
+
| 'numbers-and-punctuation'
|
|
415
|
+
| 'url';
|
|
416
|
+
/** Props for `InputRow`. */
|
|
417
|
+
export type InputRowProps = {
|
|
418
|
+
/** The input's label. */
|
|
419
|
+
label: string;
|
|
420
|
+
/** Text shown under the input; none when omitted. */
|
|
421
|
+
subLabel?: string;
|
|
422
|
+
/** The saved text; the input follows it whenever it changes. */
|
|
423
|
+
value: string;
|
|
424
|
+
/** Text shown while the input is empty. */
|
|
425
|
+
placeholder?: string;
|
|
426
|
+
/** `text` is one line, `multiline` grows with its text, `secret` hides what is typed. */
|
|
427
|
+
variant?: InputVariant;
|
|
428
|
+
/** The keyboard the input opens; `default` when omitted. */
|
|
429
|
+
keyboardType?: InputKeyboard;
|
|
430
|
+
/** The most characters the input takes. */
|
|
431
|
+
maxLength?: number;
|
|
432
|
+
/** Draws the input greyed out and ignores typing. */
|
|
433
|
+
disabled?: boolean;
|
|
434
|
+
/** Returns why the typed text cannot be saved, or `undefined` when it can. */
|
|
435
|
+
validate?: (text: string) => string | undefined;
|
|
436
|
+
/** Called with the typed text when editing ends and `validate` accepts it. */
|
|
437
|
+
onChange: (text: string) => void;
|
|
438
|
+
};
|
|
439
|
+
/** How an input shows its text. */
|
|
440
|
+
export type InputVariant = 'text' | 'multiline' | 'secret';
|
|
441
|
+
/** Props for `ListRow`. */
|
|
442
|
+
export type ListRowProps = {
|
|
443
|
+
/** The group's title. */
|
|
444
|
+
title: string;
|
|
445
|
+
/** Text shown under the group; none when omitted. */
|
|
446
|
+
description?: string;
|
|
447
|
+
/** The saved strings, in order. */
|
|
448
|
+
value: string[];
|
|
449
|
+
/** The most strings the list holds; none when omitted. */
|
|
450
|
+
maxItems?: number;
|
|
451
|
+
/** Returns why a string cannot be added, or `undefined` when it can. */
|
|
452
|
+
validate?: (text: string) => string | undefined;
|
|
453
|
+
/** Dims the row and ignores input. Defaults to false. */
|
|
454
|
+
disabled?: boolean;
|
|
455
|
+
/** Called with the new list after each add, remove or move. */
|
|
456
|
+
onChange: (value: string[]) => void;
|
|
457
|
+
};
|
|
458
|
+
/** Props for `MultilineRow`: an `InputRow`'s, without its variant. */
|
|
459
|
+
export type MultilineRowProps = Omit<InputRowProps, 'variant' | 'keyboardType'>;
|
|
460
|
+
/** The constraints a numeric input checks typed text against. */
|
|
461
|
+
export type NumberConstraints = {
|
|
462
|
+
/** Rejects text with a fractional part. Defaults to false. */
|
|
463
|
+
integer?: boolean;
|
|
464
|
+
/** The smallest accepted value. */
|
|
465
|
+
minimum?: number;
|
|
466
|
+
/** The largest accepted value. */
|
|
467
|
+
maximum?: number;
|
|
468
|
+
/** Accepts only whole multiples of this. */
|
|
469
|
+
step?: number;
|
|
470
|
+
};
|
|
471
|
+
/** Props for `NumberRow`. */
|
|
472
|
+
export type NumberRowProps = NumberConstraints & {
|
|
473
|
+
/** The input's label. */
|
|
474
|
+
label: string;
|
|
475
|
+
/** Text shown under the input; none when omitted. */
|
|
476
|
+
subLabel?: string;
|
|
477
|
+
/** The saved number. */
|
|
478
|
+
value: number;
|
|
479
|
+
disabled?: boolean;
|
|
480
|
+
/** Called with the typed number when editing ends and it meets the constraints. */
|
|
481
|
+
onChange: (value: number) => void;
|
|
482
|
+
};
|
|
483
|
+
/** The props of {@link Page}. */
|
|
484
|
+
export type PageProps = {
|
|
485
|
+
/** The page's form groups, laid out top to bottom with a 24px gap. */
|
|
486
|
+
children: React$1.ReactNode;
|
|
487
|
+
};
|
|
488
|
+
/** Props for `PaletteRow`. */
|
|
489
|
+
export type PaletteRowProps = {
|
|
490
|
+
/** The row's label. */
|
|
491
|
+
label: string;
|
|
492
|
+
/** Text shown under the label; none when omitted. */
|
|
493
|
+
subLabel?: string;
|
|
494
|
+
/** The picked color, `#RRGGBB`. */
|
|
495
|
+
value: string;
|
|
496
|
+
/** The colors offered, `#RRGGBB`. */
|
|
497
|
+
presets: string[];
|
|
498
|
+
/** Dims the row and ignores input. Defaults to false. */
|
|
499
|
+
disabled?: boolean;
|
|
500
|
+
/** Called with the color the user presses. */
|
|
501
|
+
onChange: (color: string) => void;
|
|
502
|
+
};
|
|
503
|
+
/** Props for `PickerRow`. */
|
|
504
|
+
export type PickerRowProps = {
|
|
505
|
+
/** The row's label. */
|
|
506
|
+
label: string;
|
|
507
|
+
/** The picked value. */
|
|
508
|
+
value: string;
|
|
509
|
+
/** The options, in order; their sub-labels are not drawn. */
|
|
510
|
+
options: ChoiceOption[];
|
|
511
|
+
/** Dims the row and ignores input. Defaults to false. */
|
|
512
|
+
disabled?: boolean;
|
|
513
|
+
/** Called with the value of the option the user picks. */
|
|
514
|
+
onChange: (value: string) => void;
|
|
515
|
+
};
|
|
516
|
+
/** Props for `RadioRow`. */
|
|
517
|
+
export type RadioRowProps = {
|
|
518
|
+
/** The group's title. */
|
|
519
|
+
title: string;
|
|
520
|
+
/** Text shown under the group; none when omitted. */
|
|
521
|
+
description?: string;
|
|
522
|
+
/** The picked value. */
|
|
523
|
+
value: string;
|
|
524
|
+
/** The options, in order. */
|
|
525
|
+
options: ChoiceOption[];
|
|
526
|
+
/** Draws the options greyed out and ignores presses. */
|
|
527
|
+
disabled?: boolean;
|
|
528
|
+
/** Called with the value of the option the user picks. */
|
|
529
|
+
onChange: (value: string) => void;
|
|
530
|
+
};
|
|
531
|
+
/** Props for `ResetRow`. */
|
|
532
|
+
export type ResetRowProps = {
|
|
533
|
+
/** The row's text; the localised "Reset all to defaults" when omitted. */
|
|
534
|
+
label?: string;
|
|
535
|
+
/** Called when the row is pressed; it should put the page's settings back to their defaults. */
|
|
536
|
+
onReset: () => void;
|
|
537
|
+
};
|
|
538
|
+
/** Props of {@link Row}: Discord's `TableRow` props, such as `label`, `subLabel` and `onPress`, and an {@link IconInput} `icon`. */
|
|
539
|
+
export type RowProps = Without<React$1.ComponentProps<DesignModule['TableRow']>, 'icon'> & {
|
|
540
|
+
/** An asset id, an element such as `<Star />`, or an icon component such as `Star`. */
|
|
541
|
+
icon?: IconInput;
|
|
542
|
+
};
|
|
543
|
+
/** Props for `SchemaPanel`. */
|
|
544
|
+
export type SchemaPanelProps = {
|
|
545
|
+
/** The plugin's settings, from `storage.define`. */
|
|
546
|
+
settings: DefinedSettings;
|
|
547
|
+
/** The plugin's messages in the user's locale; every title, subtitle and option label is a key of them. */
|
|
548
|
+
messages: Readonly<Record<string, string>>;
|
|
549
|
+
/** The plugin's `useMessages` hook, which re-renders the panel when the user's locale changes. */
|
|
550
|
+
useMessages: () => string;
|
|
551
|
+
/** The `visibleWhen` and `disabledWhen` predicates the build lifted out of settings.ts, by setting key. */
|
|
552
|
+
predicates?: SettingPredicates;
|
|
553
|
+
/** The exports of the plugin's src/actions.ts, which `setting.button` rows run. */
|
|
554
|
+
actions?: SettingActions;
|
|
555
|
+
/** The plugin's id, which names it when an action fails. */
|
|
556
|
+
pluginId?: string;
|
|
557
|
+
};
|
|
558
|
+
/** Props for `SecretRow`: an `InputRow`'s, without its variant. */
|
|
559
|
+
export type SecretRowProps = Omit<InputRowProps, 'variant' | 'keyboardType'>;
|
|
560
|
+
/** Props of {@link Section}: Discord's `TableRowGroup` props, such as `title`. */
|
|
561
|
+
export type SectionProps = React$1.ComponentProps<DesignModule['TableRowGroup']>;
|
|
562
|
+
/** Props for `SegmentedRow`. */
|
|
563
|
+
export type SegmentedRowProps = {
|
|
564
|
+
/** The row's label. */
|
|
565
|
+
label: string;
|
|
566
|
+
/** Text shown under the label; none when omitted. */
|
|
567
|
+
subLabel?: string;
|
|
568
|
+
/** The picked value. */
|
|
569
|
+
value: string;
|
|
570
|
+
/** Up to four options; their sub-labels are not drawn. */
|
|
571
|
+
options: ChoiceOption[];
|
|
572
|
+
/** Dims the row and ignores input. Defaults to false. */
|
|
573
|
+
disabled?: boolean;
|
|
574
|
+
/** Called with the value of the segment the user presses. */
|
|
575
|
+
onChange: (value: string) => void;
|
|
576
|
+
};
|
|
577
|
+
/** One export of `src/actions.ts`: it takes nothing, and may be async. */
|
|
578
|
+
export type SettingAction = () => void | Promise<void>;
|
|
579
|
+
/** The functions a plugin's `src/actions.ts` exports, which its `setting.button` rows run, by name. */
|
|
580
|
+
export type SettingActions = Record<string, SettingAction | undefined>;
|
|
581
|
+
/** One setting's lifted predicates. */
|
|
582
|
+
export type SettingConditions = {
|
|
583
|
+
/** Draws the row only while this returns true. */
|
|
584
|
+
visibleWhen?: SettingPredicate;
|
|
585
|
+
/** Draws the row disabled while this returns true. */
|
|
586
|
+
disabledWhen?: SettingPredicate;
|
|
587
|
+
};
|
|
588
|
+
/** A predicate the build lifted out of settings.ts: it reads every setting and returns whether its row shows or is enabled. */
|
|
589
|
+
export type SettingPredicate = (settings: SettingsValues) => boolean;
|
|
590
|
+
/** Each setting's lifted predicates, by its dot-separated key. */
|
|
591
|
+
export type SettingPredicates = Record<string, SettingConditions>;
|
|
592
|
+
/** A plugin's settings as an object: reads apply defaults, writes are validated and saved. Sections are nested objects. */
|
|
593
|
+
export type SettingsValues = {
|
|
594
|
+
[key: string]: SettingValue | SettingsValues;
|
|
595
|
+
};
|
|
596
|
+
/** Props for `SliderRow`. */
|
|
597
|
+
export type SliderRowProps = {
|
|
598
|
+
/** The row's title, shown left of the current value. */
|
|
599
|
+
label: string;
|
|
600
|
+
/** Text shown above the slider; none when omitted. */
|
|
601
|
+
subLabel?: string;
|
|
602
|
+
/** The saved value; the slider follows it whenever it changes. */
|
|
603
|
+
value: number;
|
|
604
|
+
/** The default, which Discord's slider marks on its track; the section's reset row restores it. */
|
|
605
|
+
defaultValue: number;
|
|
606
|
+
/** The lowest value the slider reaches. */
|
|
607
|
+
minimum: number;
|
|
608
|
+
/** The highest value the slider reaches. */
|
|
609
|
+
maximum: number;
|
|
610
|
+
/** The increment values snap to; `1` when omitted. */
|
|
611
|
+
step?: number;
|
|
612
|
+
/** Text appended to the shown value, such as `px` or `%`; none when omitted. */
|
|
613
|
+
unit?: string;
|
|
614
|
+
/** Formats the shown value, such as a fraction as a percentage; replaces `unit` when given. */
|
|
615
|
+
format?: (value: number) => string;
|
|
616
|
+
/** Called with the snapped value when a drag ends, not during the drag. */
|
|
617
|
+
onChange: (value: number) => void;
|
|
618
|
+
};
|
|
619
|
+
/** Props for `StepperRow`. */
|
|
620
|
+
export type StepperRowProps = {
|
|
621
|
+
/** The row's label. */
|
|
622
|
+
label: string;
|
|
623
|
+
/** Text shown under the label; none when omitted. */
|
|
624
|
+
subLabel?: string;
|
|
625
|
+
/** The saved number. */
|
|
626
|
+
value: number;
|
|
627
|
+
/** The lowest value; none when omitted. */
|
|
628
|
+
minimum?: number;
|
|
629
|
+
/** The highest value; none when omitted. */
|
|
630
|
+
maximum?: number;
|
|
631
|
+
/** How much each press adds or takes away; `1` when omitted. */
|
|
632
|
+
step?: number;
|
|
633
|
+
/** Dims the row and ignores input. Defaults to false. */
|
|
634
|
+
disabled?: boolean;
|
|
635
|
+
/** Called with the new number on each press. */
|
|
636
|
+
onChange: (value: number) => void;
|
|
637
|
+
};
|
|
638
|
+
/** Props of {@link SwitchRow}: Discord's `TableSwitchRow` props, such as `label`, `value` and `onValueChange`, and an {@link IconInput} `icon`. */
|
|
639
|
+
export type SwitchRowProps = Without<
|
|
640
|
+
React$1.ComponentProps<DesignModule['TableSwitchRow']>,
|
|
641
|
+
'icon'
|
|
642
|
+
> & {
|
|
643
|
+
/** An asset id, an element such as `<Star />`, or an icon component such as `Star`. */
|
|
644
|
+
icon?: IconInput;
|
|
645
|
+
};
|
|
646
|
+
/** Props for `UrlRow`: an `InputRow`'s, without its variant and validation. */
|
|
647
|
+
export type UrlRowProps = Omit<InputRowProps, 'variant' | 'keyboardType' | 'validate'>;
|
|
648
|
+
type DurationUnit$1 = 'ms' | 's' | 'm' | 'h' | 'd';
|
|
649
|
+
|
|
650
|
+
export {};
|
package/src/updates.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description Applies the pending update of one addon found by the last {@link check}.
|
|
5
|
+
* @param id The addon's id.
|
|
6
|
+
* @returns Whether the addon now runs the new version.
|
|
7
|
+
*/
|
|
8
|
+
export declare function apply(id: string): Promise<boolean>;
|
|
9
|
+
/**
|
|
10
|
+
* @description Applies every pending update except newer versions of addons held on a version.
|
|
11
|
+
* @returns A promise that settles once every update was applied or failed.
|
|
12
|
+
*/
|
|
13
|
+
export declare function applyAll(): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* @description Checks every installed addon and the loader for updates. Concurrent calls share one check.
|
|
16
|
+
* @returns A promise that settles once the check finished.
|
|
17
|
+
*/
|
|
18
|
+
export declare function check(): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* @description Asks the update server whether a newer loader is available for this device.
|
|
21
|
+
* @returns The newer loader's version, or `null` when there is none or the check failed.
|
|
22
|
+
*/
|
|
23
|
+
export declare function checkLoader(): Promise<string | null>;
|
|
24
|
+
|
|
25
|
+
export {};
|