@unbound-app/api 0.9.0 → 0.11.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/package.json +4 -2
- package/src/_internal.d.ts +3463 -447
- package/src/commands.d.ts +255 -0
- package/src/dialogs.d.ts +69 -0
- package/src/fs.d.ts +3 -4
- package/src/global.d.ts +341 -20
- package/src/index.d.ts +2 -0
- package/src/metro/api.d.ts +2 -0
- package/src/metro/components.d.ts +91 -16
- package/src/metro/index.d.ts +32 -13
- package/src/native.d.ts +51 -3
- package/src/settings.d.ts +1 -1
- package/src/storage.d.ts +4 -3
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
// Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
declare const _default: {
|
|
4
|
+
createCommands: typeof createCommands;
|
|
5
|
+
option: OptionBuilders;
|
|
6
|
+
};
|
|
7
|
+
declare const valueType: unique symbol;
|
|
8
|
+
/** Option builders, one per kind: `option.string({ required: true })`, `option.user()`, `option.choice([...])`. */
|
|
9
|
+
export declare const option: OptionBuilders;
|
|
10
|
+
/**
|
|
11
|
+
* @description Creates the commands handle for one owner, like `createPatcher` does for patches. A plugin passes
|
|
12
|
+
* its manifest id, so its commands are removed when it stops; a built-in passes `'unbound'`.
|
|
13
|
+
* @param owner The plugin id, or `'unbound'` for a built-in.
|
|
14
|
+
* @param options The owner's own picker section; omitted, the shared Unbound section.
|
|
15
|
+
* @returns The handle.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createCommands(owner: string, options?: CommandsOptions): CommandsHandle;
|
|
18
|
+
/** Suggests values for an option while the user types. At most 25 are shown. */
|
|
19
|
+
export type Autocomplete<V extends string | number> = (
|
|
20
|
+
query: string,
|
|
21
|
+
context: AutocompleteContext,
|
|
22
|
+
) => Awaitable<readonly Choice<V>[]>;
|
|
23
|
+
/** What autocomplete sees: where it runs and the raw values of the other options filled in so far. */
|
|
24
|
+
export type AutocompleteContext = CommandContext & {
|
|
25
|
+
values: Readonly<Record<string, RawOptionValue>>;
|
|
26
|
+
};
|
|
27
|
+
/** A value, or a promise of one. */
|
|
28
|
+
export type Awaitable<T> = T | Promise<T>;
|
|
29
|
+
/** Settings every builder accepts. */
|
|
30
|
+
export type BuilderInput<K extends OptionKind, R extends boolean> = OptionSettings<K> & {
|
|
31
|
+
description?: string;
|
|
32
|
+
required?: R;
|
|
33
|
+
};
|
|
34
|
+
/** Settings of `option.channel`. */
|
|
35
|
+
export type ChannelOptionSettings = {
|
|
36
|
+
/** Discord channel types the picker offers. */
|
|
37
|
+
channelTypes?: readonly number[];
|
|
38
|
+
};
|
|
39
|
+
/** A choice or suggestion: a bare value, shown as itself, or a value with a label. */
|
|
40
|
+
export type Choice<V extends string | number> = V | ChoiceWithLabel<V>;
|
|
41
|
+
/** Settings `option.choice` accepts. */
|
|
42
|
+
export type ChoiceInput<R extends boolean> = {
|
|
43
|
+
description?: string;
|
|
44
|
+
required?: R;
|
|
45
|
+
};
|
|
46
|
+
/** The kind a choice list maps to: strings are a string option, numbers an integer or number option. */
|
|
47
|
+
export type ChoiceKind<V extends string | number> = V extends string
|
|
48
|
+
? 'string'
|
|
49
|
+
: 'integer' | 'number';
|
|
50
|
+
/** A value with the label the picker shows for it. */
|
|
51
|
+
export type ChoiceWithLabel<V extends string | number> = {
|
|
52
|
+
label: string;
|
|
53
|
+
value: V;
|
|
54
|
+
};
|
|
55
|
+
/** A Discord channel, as the channel store returns it. */
|
|
56
|
+
export type CommandChannel = {
|
|
57
|
+
id: string;
|
|
58
|
+
type: number;
|
|
59
|
+
name?: string;
|
|
60
|
+
guild_id?: string | null;
|
|
61
|
+
};
|
|
62
|
+
/** Where a command runs. Discord never runs a command without a channel. */
|
|
63
|
+
export type CommandContext = {
|
|
64
|
+
channel: CommandChannel;
|
|
65
|
+
guild: CommandGuild | undefined;
|
|
66
|
+
};
|
|
67
|
+
/** A command that only groups subcommands: `/root sub` or `/root group sub`. */
|
|
68
|
+
export type CommandGroup<S> = {
|
|
69
|
+
description: string;
|
|
70
|
+
subcommands: CommandTree<S>;
|
|
71
|
+
options?: never;
|
|
72
|
+
execute?: never;
|
|
73
|
+
};
|
|
74
|
+
/** A Discord guild. */
|
|
75
|
+
export type CommandGuild = {
|
|
76
|
+
id: string;
|
|
77
|
+
name: string;
|
|
78
|
+
};
|
|
79
|
+
/** A leaf or a group. */
|
|
80
|
+
export type CommandNode<T> = LeafCommand<T> | CommandGroup<T>;
|
|
81
|
+
/** A Discord guild role. */
|
|
82
|
+
export type CommandRole = {
|
|
83
|
+
id: string;
|
|
84
|
+
name: string;
|
|
85
|
+
color?: number;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Commands keyed by name, at every level. TypeScript infers `T` per key by reversing this mapped type,
|
|
89
|
+
* from `options` on a leaf and from `subcommands` on a group. A conditional type here breaks inference.
|
|
90
|
+
*/
|
|
91
|
+
export type CommandTree<T> = {
|
|
92
|
+
[K in keyof T]: CommandNode<T[K]>;
|
|
93
|
+
};
|
|
94
|
+
/** A Discord user, as the user store returns it. Only the fields commands rely on. */
|
|
95
|
+
export type CommandUser = {
|
|
96
|
+
id: string;
|
|
97
|
+
username: string;
|
|
98
|
+
globalName?: string | null;
|
|
99
|
+
bot?: boolean;
|
|
100
|
+
};
|
|
101
|
+
/** The handle `createCommands` returns, scoped to one owner. */
|
|
102
|
+
export type CommandsHandle = {
|
|
103
|
+
/**
|
|
104
|
+
* Adds commands. Registering a root name this owner already has replaces that whole command.
|
|
105
|
+
* Returns a function that removes this call's commands; it is safe to call twice or after a sweep.
|
|
106
|
+
*/
|
|
107
|
+
register<T>(commands: CommandTree<T>): () => void;
|
|
108
|
+
/** Removes every command of this owner. */
|
|
109
|
+
unregisterAll(): void;
|
|
110
|
+
};
|
|
111
|
+
/** Options of `createCommands`. */
|
|
112
|
+
export type CommandsOptions = {
|
|
113
|
+
/** The owner's own picker section. Omitted, commands go in the shared Unbound section. */
|
|
114
|
+
section?: SectionInput;
|
|
115
|
+
};
|
|
116
|
+
/** Shown only to the user, as a bot message. */
|
|
117
|
+
export type EphemeralReply = {
|
|
118
|
+
ephemeral: true;
|
|
119
|
+
content?: string;
|
|
120
|
+
embeds?: readonly ReplyEmbed[];
|
|
121
|
+
};
|
|
122
|
+
/** An asset id from `assets.Icons`, or a `data:` or `https:` uri. */
|
|
123
|
+
export type IconSource = number | string;
|
|
124
|
+
/**
|
|
125
|
+
* A command that runs. `O` is inferred from `options` and types `execute`'s args.
|
|
126
|
+
* `execute` uses method syntax so its parameter stays bivariant and the registry can hold it erased.
|
|
127
|
+
*/
|
|
128
|
+
export type LeafCommand<O> = {
|
|
129
|
+
description: string;
|
|
130
|
+
options?: O;
|
|
131
|
+
execute(args: OptionArgs<O>, context: CommandContext): Awaitable<Reply>;
|
|
132
|
+
subcommands?: never;
|
|
133
|
+
};
|
|
134
|
+
export type NoSettings = Record<never, never>;
|
|
135
|
+
/** Settings of `option.integer` and `option.number`. */
|
|
136
|
+
export type NumberOptionSettings = {
|
|
137
|
+
minValue?: number;
|
|
138
|
+
maxValue?: number;
|
|
139
|
+
autocomplete?: Autocomplete<number>;
|
|
140
|
+
};
|
|
141
|
+
/** A handler's args, derived from its options: a required option is `V`, an optional one `V | undefined`. */
|
|
142
|
+
export type OptionArgs<O> = {
|
|
143
|
+
[K in keyof O]: O[K] extends OptionSpec<OptionKind, infer R, infer V>
|
|
144
|
+
? R extends true
|
|
145
|
+
? V
|
|
146
|
+
: V | undefined
|
|
147
|
+
: never;
|
|
148
|
+
};
|
|
149
|
+
/** One kind's builder. */
|
|
150
|
+
export type OptionBuilder<K extends OptionKind> = <const R extends boolean = false>(
|
|
151
|
+
settings?: BuilderInput<K, R>,
|
|
152
|
+
) => OptionSpec<K, R>;
|
|
153
|
+
/** The `option` builders: one per kind, plus `choice`. */
|
|
154
|
+
export type OptionBuilders = {
|
|
155
|
+
[K in OptionKind]: OptionBuilder<K>;
|
|
156
|
+
} & {
|
|
157
|
+
/**
|
|
158
|
+
* Restricts an option to listed values; the handler gets their literal union.
|
|
159
|
+
* @param choices Values, or `{ label, value }` pairs. 1 to 25, with unique labels.
|
|
160
|
+
* @param settings The option's description and whether it is required.
|
|
161
|
+
*/
|
|
162
|
+
choice<const V extends string | number, const R extends boolean = false>(
|
|
163
|
+
choices: readonly Choice<V>[],
|
|
164
|
+
settings?: ChoiceInput<R>,
|
|
165
|
+
): OptionSpec<ChoiceKind<V>, R, V>;
|
|
166
|
+
};
|
|
167
|
+
/** The option kinds: one builder each on `option`. */
|
|
168
|
+
export type OptionKind = keyof OptionKindTypes;
|
|
169
|
+
/** Each option kind's handler value and builder settings. The client's kind table implements every key. */
|
|
170
|
+
export type OptionKindTypes = {
|
|
171
|
+
string: {
|
|
172
|
+
value: string;
|
|
173
|
+
settings: StringOptionSettings;
|
|
174
|
+
};
|
|
175
|
+
integer: {
|
|
176
|
+
value: number;
|
|
177
|
+
settings: NumberOptionSettings;
|
|
178
|
+
};
|
|
179
|
+
number: {
|
|
180
|
+
value: number;
|
|
181
|
+
settings: NumberOptionSettings;
|
|
182
|
+
};
|
|
183
|
+
boolean: {
|
|
184
|
+
value: boolean;
|
|
185
|
+
settings: NoSettings;
|
|
186
|
+
};
|
|
187
|
+
user: {
|
|
188
|
+
value: CommandUser;
|
|
189
|
+
settings: NoSettings;
|
|
190
|
+
};
|
|
191
|
+
channel: {
|
|
192
|
+
value: CommandChannel;
|
|
193
|
+
settings: ChannelOptionSettings;
|
|
194
|
+
};
|
|
195
|
+
role: {
|
|
196
|
+
value: CommandRole;
|
|
197
|
+
settings: NoSettings;
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
/** The settings a kind's builder accepts beyond `description` and `required`. */
|
|
201
|
+
export type OptionSettings<K extends OptionKind> = OptionKindTypes[K]['settings'];
|
|
202
|
+
/** One declared option, made by an `option` builder. */
|
|
203
|
+
export type OptionSpec<
|
|
204
|
+
K extends OptionKind = OptionKind,
|
|
205
|
+
R extends boolean = boolean,
|
|
206
|
+
V = OptionValue<K>,
|
|
207
|
+
> = {
|
|
208
|
+
readonly kind: K;
|
|
209
|
+
readonly required: R;
|
|
210
|
+
readonly description: string | undefined;
|
|
211
|
+
readonly settings: OptionSettings<K>;
|
|
212
|
+
readonly choices: readonly Choice<string | number>[] | undefined;
|
|
213
|
+
readonly [valueType]?: V;
|
|
214
|
+
};
|
|
215
|
+
/** The value a handler receives for a kind. */
|
|
216
|
+
export type OptionValue<K extends OptionKind> = OptionKindTypes[K]['value'];
|
|
217
|
+
/** Sent by Discord as a normal message from the user. */
|
|
218
|
+
export type PublicReply = {
|
|
219
|
+
content: string;
|
|
220
|
+
tts?: boolean;
|
|
221
|
+
ephemeral?: false;
|
|
222
|
+
};
|
|
223
|
+
/** An option value as Discord passes it. User, channel and role options arrive as id strings. */
|
|
224
|
+
export type RawOptionValue = string | number | boolean;
|
|
225
|
+
/** What `execute` returns. A string is shorthand for `{ content }`; nothing means the command did its own work. */
|
|
226
|
+
export type Reply = string | PublicReply | EphemeralReply | undefined | void;
|
|
227
|
+
/** An embed in an ephemeral reply. */
|
|
228
|
+
export type ReplyEmbed = {
|
|
229
|
+
title?: string;
|
|
230
|
+
description?: string;
|
|
231
|
+
url?: string;
|
|
232
|
+
color?: number;
|
|
233
|
+
fields?: readonly ReplyEmbedField[];
|
|
234
|
+
};
|
|
235
|
+
/** A field of an embed in an ephemeral reply. */
|
|
236
|
+
export type ReplyEmbedField = {
|
|
237
|
+
name: string;
|
|
238
|
+
value: string;
|
|
239
|
+
inline?: boolean;
|
|
240
|
+
};
|
|
241
|
+
/** A section of the `/` picker owned by one owner. */
|
|
242
|
+
export type SectionInput = {
|
|
243
|
+
name: string;
|
|
244
|
+
icon?: IconSource;
|
|
245
|
+
};
|
|
246
|
+
/** Settings of `option.string`. */
|
|
247
|
+
export type StringOptionSettings = {
|
|
248
|
+
minLength?: number;
|
|
249
|
+
maxLength?: number;
|
|
250
|
+
autocomplete?: Autocomplete<string>;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
export { _default as default };
|
|
254
|
+
|
|
255
|
+
export {};
|
package/src/dialogs.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
import * as React$1 from 'react';
|
|
4
|
+
import { ComponentType } from 'react';
|
|
5
|
+
|
|
6
|
+
declare const _default: {
|
|
7
|
+
showDialog: typeof showDialog;
|
|
8
|
+
confirm: typeof confirm$1;
|
|
9
|
+
dismissAll: typeof dismissAll;
|
|
10
|
+
start: typeof start;
|
|
11
|
+
stop: typeof stop$1;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* @description Asks a yes-or-no question with a confirm and a cancel button.
|
|
15
|
+
* @param options The question and the confirm button's label.
|
|
16
|
+
* @returns Whether the user confirmed; closing the dialog any other way counts as no.
|
|
17
|
+
*/
|
|
18
|
+
declare function confirm$1(options: ConfirmOptions): Promise<boolean>;
|
|
19
|
+
/** Closes any dialog still open. */
|
|
20
|
+
declare function stop$1(): void;
|
|
21
|
+
/**
|
|
22
|
+
* @description Closes every dialog this API opened.
|
|
23
|
+
*/
|
|
24
|
+
export declare function dismissAll(): void;
|
|
25
|
+
/**
|
|
26
|
+
* @description Opens a dialog with Discord's own alert: a title, an optional body and custom component,
|
|
27
|
+
* and action buttons, each of which closes the dialog before running its handler. On a Discord build
|
|
28
|
+
* without the alert it falls back to the system alert, which shows the title, body and buttons only.
|
|
29
|
+
* @param options The dialog's content and buttons.
|
|
30
|
+
* @returns The dialog's key and a function that closes it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function showDialog(options: AlertDialogProps): DialogHandle;
|
|
33
|
+
/** Starts the dialogs API; it keeps no state until a dialog opens. */
|
|
34
|
+
export declare function start(): void;
|
|
35
|
+
export type AlertDialogProps = {
|
|
36
|
+
title: string;
|
|
37
|
+
body?: string;
|
|
38
|
+
/** A component rendered below the body, given a way to close the dialog. */
|
|
39
|
+
content?: React$1.ComponentType<DialogContentProps>;
|
|
40
|
+
buttons?: DialogButton[];
|
|
41
|
+
/** Adds a cancel button last; a string sets its label. */
|
|
42
|
+
cancel?: boolean | string;
|
|
43
|
+
/** Runs when the cancel button closes the dialog. */
|
|
44
|
+
onCancel?: () => void;
|
|
45
|
+
};
|
|
46
|
+
export type ConfirmOptions = {
|
|
47
|
+
title: string;
|
|
48
|
+
body?: string;
|
|
49
|
+
confirmLabel: string;
|
|
50
|
+
cancelLabel?: string;
|
|
51
|
+
destructive?: boolean;
|
|
52
|
+
};
|
|
53
|
+
export type DialogButton = {
|
|
54
|
+
label: string;
|
|
55
|
+
variant?: DialogButtonVariant;
|
|
56
|
+
onPress?: () => void;
|
|
57
|
+
};
|
|
58
|
+
export type DialogButtonVariant = 'primary' | 'secondary' | 'destructive';
|
|
59
|
+
export type DialogContentProps = {
|
|
60
|
+
dismiss: () => void;
|
|
61
|
+
};
|
|
62
|
+
export type DialogHandle = {
|
|
63
|
+
key: string;
|
|
64
|
+
dismiss: () => void;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export { _default as default, confirm$1 as confirm, stop$1 as stop };
|
|
68
|
+
|
|
69
|
+
export {};
|
package/src/fs.d.ts
CHANGED
|
@@ -29,9 +29,9 @@ export declare function read(
|
|
|
29
29
|
inDocuments?: boolean,
|
|
30
30
|
): Promise<string>;
|
|
31
31
|
/**
|
|
32
|
-
* @description Removes a file within {@link Documents}.
|
|
33
|
-
* @param path The
|
|
34
|
-
* @returns A promise resolving to whether
|
|
32
|
+
* @description Removes a file or a whole folder within {@link Documents}.
|
|
33
|
+
* @param path The path to remove, relative to {@link Documents}.
|
|
34
|
+
* @returns A promise resolving to whether anything was removed.
|
|
35
35
|
*/
|
|
36
36
|
export declare function rm(path: string): Promise<boolean>;
|
|
37
37
|
/**
|
|
@@ -46,7 +46,6 @@ export declare function write(
|
|
|
46
46
|
content: string,
|
|
47
47
|
encoding?: DCDFileManagerEncoding,
|
|
48
48
|
): Promise<string>;
|
|
49
|
-
/** The text encodings accepted by the native `DCDFileManager` read/write operations. */
|
|
50
49
|
export type DCDFileManagerEncoding = 'utf-8' | 'utf8' | 'base64';
|
|
51
50
|
|
|
52
51
|
export { _default as default };
|