@unbound-app/api 0.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/package.json +51 -0
- package/src/_internal.d.ts +622 -0
- package/src/assets.d.ts +49 -0
- package/src/fs.d.ts +52 -0
- package/src/global.d.ts +147 -0
- package/src/i18n.d.ts +42 -0
- package/src/index.d.ts +11 -0
- package/src/metro/api.d.ts +7 -0
- package/src/metro/common.d.ts +23 -0
- package/src/metro/components.d.ts +22 -0
- package/src/metro/filters.d.ts +55 -0
- package/src/metro/index.d.ts +228 -0
- package/src/metro/stores.d.ts +4 -0
- package/src/native.d.ts +95 -0
- package/src/patcher.d.ts +92 -0
- package/src/settings.d.ts +28 -0
- package/src/storage.d.ts +155 -0
- package/src/toasts.d.ts +18 -0
- package/src/tseep.d.ts +175 -0
- package/src/utils.d.ts +35 -0
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@unbound-app/api",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"author": {
|
|
5
|
+
"name": "Mario P.",
|
|
6
|
+
"email": "contact@marioparaschiv.com",
|
|
7
|
+
"url": "https://github.com/marioparaschiv"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
12
|
+
"types": "./src/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": "./src/index.d.ts",
|
|
15
|
+
"./assets": "./src/assets.d.ts",
|
|
16
|
+
"./fs": "./src/fs.d.ts",
|
|
17
|
+
"./global": "./src/global.d.ts",
|
|
18
|
+
"./i18n": "./src/i18n.d.ts",
|
|
19
|
+
"./metro": "./src/metro/index.d.ts",
|
|
20
|
+
"./metro/api": "./src/metro/api.d.ts",
|
|
21
|
+
"./metro/common": "./src/metro/common.d.ts",
|
|
22
|
+
"./metro/components": "./src/metro/components.d.ts",
|
|
23
|
+
"./metro/filters": "./src/metro/filters.d.ts",
|
|
24
|
+
"./metro/stores": "./src/metro/stores.d.ts",
|
|
25
|
+
"./native": "./src/native.d.ts",
|
|
26
|
+
"./patcher": "./src/patcher.d.ts",
|
|
27
|
+
"./settings": "./src/settings.d.ts",
|
|
28
|
+
"./storage": "./src/storage.d.ts",
|
|
29
|
+
"./toasts": "./src/toasts.d.ts"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@types/react": "^19.2.7",
|
|
33
|
+
"react": "^19.2.3",
|
|
34
|
+
"react-native": "^0.83.0",
|
|
35
|
+
"typescript": "^5.9.3"
|
|
36
|
+
},
|
|
37
|
+
"peerDependenciesMeta": {
|
|
38
|
+
"react": {
|
|
39
|
+
"optional": false
|
|
40
|
+
},
|
|
41
|
+
"@types/react": {
|
|
42
|
+
"optional": false
|
|
43
|
+
},
|
|
44
|
+
"react-native": {
|
|
45
|
+
"optional": false
|
|
46
|
+
},
|
|
47
|
+
"typescript": {
|
|
48
|
+
"optional": false
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,622 @@
|
|
|
1
|
+
// Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ImageSourcePropType,
|
|
5
|
+
ImageStyle,
|
|
6
|
+
StyleProp,
|
|
7
|
+
TextInputProps as RNTextInputProps,
|
|
8
|
+
TextStyle,
|
|
9
|
+
ViewProps,
|
|
10
|
+
ViewStyle,
|
|
11
|
+
} from 'react-native';
|
|
12
|
+
import { ComponentType, ReactNode } from 'react';
|
|
13
|
+
|
|
14
|
+
import type { Fn, LiteralUnion } from './utils';
|
|
15
|
+
|
|
16
|
+
declare const THEME_FLAG_KEYS: readonly [
|
|
17
|
+
'MOBILE_DARK_GRADIENT_THEME_ENABLED',
|
|
18
|
+
'MOBILE_LIGHT_GRADIENT_THEME_ENABLED',
|
|
19
|
+
'REDUCED_CONTRAST_ENABLED',
|
|
20
|
+
'INCREASED_CONTRAST_ENABLED',
|
|
21
|
+
'REDUCE_SATURATION_ENABLED',
|
|
22
|
+
];
|
|
23
|
+
declare const TRANSITION_STATE_KEYS: readonly ['MOUNTED', 'ENTERED', 'YEETED'];
|
|
24
|
+
|
|
25
|
+
/** A loaded addon entity: its runtime state, instance, source bundle, and {@link AddonManifest}. */
|
|
26
|
+
export interface Addon {
|
|
27
|
+
started: boolean;
|
|
28
|
+
instance: any;
|
|
29
|
+
id: string;
|
|
30
|
+
failed: boolean;
|
|
31
|
+
data: AddonManifest;
|
|
32
|
+
bundle: string;
|
|
33
|
+
}
|
|
34
|
+
/** The manifest describing an addon's metadata, entry point, and source. */
|
|
35
|
+
export interface AddonManifest {
|
|
36
|
+
id: string;
|
|
37
|
+
/** The addon kind this manifest describes; used to validate installs. */
|
|
38
|
+
type?: 'plugin' | 'theme' | 'icon-pack' | 'font';
|
|
39
|
+
name: string;
|
|
40
|
+
description: string;
|
|
41
|
+
authors: AddonAuthor[];
|
|
42
|
+
icon:
|
|
43
|
+
| (string & {})
|
|
44
|
+
| {
|
|
45
|
+
uri: string;
|
|
46
|
+
};
|
|
47
|
+
updates: string;
|
|
48
|
+
main: string;
|
|
49
|
+
version: string;
|
|
50
|
+
folder: string;
|
|
51
|
+
path: string;
|
|
52
|
+
url: string;
|
|
53
|
+
}
|
|
54
|
+
/** The native module used to register and resolve {@link DiscordAsset}s by id. */
|
|
55
|
+
export interface AssetsModule {
|
|
56
|
+
registerAsset: (asset: DiscordAsset) => number;
|
|
57
|
+
getAssetByID: (id: number) => DiscordAsset | null;
|
|
58
|
+
[key: PropertyKey]: any;
|
|
59
|
+
}
|
|
60
|
+
export interface ButtonProps {
|
|
61
|
+
text?: string;
|
|
62
|
+
textElement?: ReactNode;
|
|
63
|
+
variant?: ButtonVariant;
|
|
64
|
+
size?: ButtonSize;
|
|
65
|
+
loading?: boolean;
|
|
66
|
+
disabled?: boolean;
|
|
67
|
+
icon?: ReactNode | number;
|
|
68
|
+
iconPosition?: 'start' | 'end';
|
|
69
|
+
grow?: boolean;
|
|
70
|
+
shrink?: boolean;
|
|
71
|
+
shiny?: boolean;
|
|
72
|
+
textVariant?: TextVariant;
|
|
73
|
+
style?: StyleProp<ViewStyle>;
|
|
74
|
+
accessibilityLabel?: string;
|
|
75
|
+
onPress?: Fn<void>;
|
|
76
|
+
onPressIn?: Fn<void>;
|
|
77
|
+
onPressOut?: Fn<void>;
|
|
78
|
+
}
|
|
79
|
+
export interface CardProps extends ViewProps {
|
|
80
|
+
variant?: LiteralUnion<'primary' | 'secondary' | 'muted' | 'transparent'>;
|
|
81
|
+
border?: LiteralUnion<'none' | 'subtle' | 'strong'>;
|
|
82
|
+
shadow?: LiteralUnion<'none' | 'low' | 'medium' | 'high' | 'border'>;
|
|
83
|
+
radius?: number;
|
|
84
|
+
start?: boolean;
|
|
85
|
+
end?: boolean;
|
|
86
|
+
children?: ReactNode;
|
|
87
|
+
}
|
|
88
|
+
export interface CheckboxProps {
|
|
89
|
+
label?: ReactNode;
|
|
90
|
+
description?: ReactNode;
|
|
91
|
+
checked: boolean;
|
|
92
|
+
required?: boolean;
|
|
93
|
+
accessibilityRole?: string;
|
|
94
|
+
accessibilityState?: Record<string, any>;
|
|
95
|
+
onToggle: Fn<void>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The Discord mobile design system. This is the single metro module keyed by
|
|
99
|
+
* `createStyles` / `dismissAlerts` / `ContextMenu` (aliased `Design` on the v3 branch). It is
|
|
100
|
+
* intentionally left open: every listed member is precisely typed, and the index signature keeps
|
|
101
|
+
* the rest (and anything Discord adds in a future build) accessible as `any` without a change here.
|
|
102
|
+
*
|
|
103
|
+
* See `DESIGN.md` at the repo root for the full catalogue.
|
|
104
|
+
*/
|
|
105
|
+
export interface DesignModule {
|
|
106
|
+
createStyles: CreateStyles;
|
|
107
|
+
TextStyleSheet: Record<TextVariant, TextStyle>;
|
|
108
|
+
Text: ComponentType<TextProps>;
|
|
109
|
+
Heading: ComponentType<TextProps>;
|
|
110
|
+
TableRow: TableRowComponent;
|
|
111
|
+
TableSwitchRow: ComponentType<TableSwitchRowProps>;
|
|
112
|
+
TableCheckboxRow: ComponentType<TableCheckboxRowProps>;
|
|
113
|
+
TableRadioRow: ComponentType<TableRadioRowProps>;
|
|
114
|
+
TableRowGroup: ComponentType<TableRowGroupProps>;
|
|
115
|
+
TableRowGroupTitle: ComponentType<TableRowGroupTitleProps>;
|
|
116
|
+
TableRowIcon: ComponentType<TableRowIconProps>;
|
|
117
|
+
RowButton: ComponentType<RowButtonProps>;
|
|
118
|
+
RowGroup: ComponentType<ViewProps>;
|
|
119
|
+
Button: ButtonComponent;
|
|
120
|
+
IconButton: ComponentType<IconButtonProps>;
|
|
121
|
+
ImageButton: ComponentType<ViewProps>;
|
|
122
|
+
FloatingActionButton: ComponentType<FloatingActionButtonProps>;
|
|
123
|
+
TextInput: ComponentType<TextInputProps>;
|
|
124
|
+
TextField: ComponentType<TextFieldProps>;
|
|
125
|
+
TextArea: ComponentType<TextAreaProps>;
|
|
126
|
+
TextAreaField: ComponentType<TextAreaProps>;
|
|
127
|
+
SearchField: ComponentType<Omit<TextFieldProps, 'leadingIcon'>>;
|
|
128
|
+
GhostInput: ComponentType<GhostInputProps>;
|
|
129
|
+
SplitTextInput: ComponentType<SplitTextInputProps>;
|
|
130
|
+
Slider: ComponentType<SliderProps>;
|
|
131
|
+
Checkbox: ComponentType<CheckboxProps>;
|
|
132
|
+
SegmentedControl: ComponentType<SegmentedControlProps>;
|
|
133
|
+
Stack: ComponentType<StackProps>;
|
|
134
|
+
Card: ComponentType<CardProps>;
|
|
135
|
+
openAlert: Fn<void>;
|
|
136
|
+
dismissAlert: (key: string) => void;
|
|
137
|
+
dismissAlerts: Fn<void>;
|
|
138
|
+
showConfirmModal: Fn;
|
|
139
|
+
showSimpleActionSheet: Fn;
|
|
140
|
+
hideContextMenu: Fn<void>;
|
|
141
|
+
useNavigation: <T = any>() => Navigation$1<T>;
|
|
142
|
+
setColorOpacity: (color: string, opacity: number) => string;
|
|
143
|
+
darkenColor: (color: string, amount: number) => string;
|
|
144
|
+
brightenColor: (color: string, amount: number) => string;
|
|
145
|
+
getContrastingColor: (color: string) => string;
|
|
146
|
+
TransitionStates: EnumLike<typeof TRANSITION_STATE_KEYS>;
|
|
147
|
+
ThemeContextFlags: EnumLike<typeof THEME_FLAG_KEYS>;
|
|
148
|
+
WCAGContrastRatios: Record<'NonText' | 'Text' | 'HighContrastText', number>;
|
|
149
|
+
[key: PropertyKey]: any;
|
|
150
|
+
}
|
|
151
|
+
/** An asset registered with Discord's packager (its metadata and dimensions). */
|
|
152
|
+
export interface DiscordAsset {
|
|
153
|
+
__packager_asset?: boolean;
|
|
154
|
+
name: string;
|
|
155
|
+
httpServerLocation?: string;
|
|
156
|
+
width: number;
|
|
157
|
+
height: number;
|
|
158
|
+
scales: number[];
|
|
159
|
+
hash: string;
|
|
160
|
+
type: string;
|
|
161
|
+
[key: PropertyKey]: any;
|
|
162
|
+
}
|
|
163
|
+
/** `FloatingActionButton`: a single-icon FAB, typically pinned to a screen corner. */
|
|
164
|
+
export interface FloatingActionButtonProps {
|
|
165
|
+
icon?: ReactNode | number;
|
|
166
|
+
style?: StyleProp<ViewStyle>;
|
|
167
|
+
onPress?: Fn<void>;
|
|
168
|
+
}
|
|
169
|
+
/** `GhostInput`: a borderless field bridging to the `useTextField` hook. */
|
|
170
|
+
export interface GhostInputProps extends TextFieldProps {
|
|
171
|
+
isCentered?: boolean;
|
|
172
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
173
|
+
}
|
|
174
|
+
export interface IconButtonProps {
|
|
175
|
+
icon?: ReactNode | number;
|
|
176
|
+
variant?: ButtonVariant;
|
|
177
|
+
size?: ButtonSize;
|
|
178
|
+
loading?: boolean;
|
|
179
|
+
disabled?: boolean;
|
|
180
|
+
label?: string;
|
|
181
|
+
accessibilityLabel?: string;
|
|
182
|
+
style?: StyleProp<ViewStyle>;
|
|
183
|
+
onPress?: Fn<void>;
|
|
184
|
+
}
|
|
185
|
+
/** {@link ToastOptions} enriched with the fields the store tracks internally. */
|
|
186
|
+
export interface InternalToastOptions extends ToastOptions {
|
|
187
|
+
id: string;
|
|
188
|
+
closing?: boolean;
|
|
189
|
+
date?: number;
|
|
190
|
+
}
|
|
191
|
+
export interface RowButtonProps {
|
|
192
|
+
label?: ReactNode;
|
|
193
|
+
icon?: ReactNode;
|
|
194
|
+
arrow?: boolean;
|
|
195
|
+
disabled?: boolean;
|
|
196
|
+
variant?: LiteralUnion<'primary' | 'secondary'>;
|
|
197
|
+
onPress?: Fn<void>;
|
|
198
|
+
}
|
|
199
|
+
export interface SegmentedControlProps {
|
|
200
|
+
/** The controller returned by `useSegmentedControlState`. */
|
|
201
|
+
state: SegmentedControlState;
|
|
202
|
+
/** @default 'default' */
|
|
203
|
+
variant?: LiteralUnion<'default'>;
|
|
204
|
+
keyboardShouldPersistTaps?: boolean | 'always' | 'never' | 'handled';
|
|
205
|
+
}
|
|
206
|
+
/** The state controller a `SegmentedControl` is driven by. */
|
|
207
|
+
export interface SegmentedControlState {
|
|
208
|
+
activeIndex: number;
|
|
209
|
+
items: any[];
|
|
210
|
+
setActiveIndex: (index: number) => void;
|
|
211
|
+
}
|
|
212
|
+
/** A registered Unbound settings entry, mirroring Discord's `SETTING_RENDERER_CONFIG` route shape. */
|
|
213
|
+
export interface SettingsEntry {
|
|
214
|
+
type: 'route';
|
|
215
|
+
key: string;
|
|
216
|
+
useTitle: () => string;
|
|
217
|
+
parent: string | null;
|
|
218
|
+
section?: string;
|
|
219
|
+
excludeFromDisplay?: boolean;
|
|
220
|
+
IconComponent?: ComponentType<any>;
|
|
221
|
+
screen: SettingsScreen;
|
|
222
|
+
}
|
|
223
|
+
/** The screen descriptor a settings route entry renders. */
|
|
224
|
+
export interface SettingsScreen {
|
|
225
|
+
route: string;
|
|
226
|
+
getComponent: () => ComponentType<any>;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* The DS `Slider`. It reads only `startIcon` / `endIcon` / `style` / `onValueChange` / `step`; the
|
|
230
|
+
* remaining slider props (`value`, bounds, tint colours) are spread onto the underlying RN slider.
|
|
231
|
+
*/
|
|
232
|
+
export interface SliderProps {
|
|
233
|
+
value?: number;
|
|
234
|
+
defaultValue?: number;
|
|
235
|
+
minimumValue?: number;
|
|
236
|
+
maximumValue?: number;
|
|
237
|
+
step?: number;
|
|
238
|
+
disabled?: boolean;
|
|
239
|
+
inverted?: boolean;
|
|
240
|
+
tapToSeek?: boolean;
|
|
241
|
+
lowerLimit?: number;
|
|
242
|
+
upperLimit?: number;
|
|
243
|
+
startIcon?: ReactNode;
|
|
244
|
+
endIcon?: ReactNode;
|
|
245
|
+
valueLabel?: ReactNode;
|
|
246
|
+
minimumTrackTintColor?: string;
|
|
247
|
+
maximumTrackTintColor?: string;
|
|
248
|
+
style?: StyleProp<ViewStyle>;
|
|
249
|
+
onValueChange?: (value: number) => void;
|
|
250
|
+
onSlidingStart?: (value: number) => void;
|
|
251
|
+
onSlidingComplete?: (value: number) => void;
|
|
252
|
+
}
|
|
253
|
+
/** `SplitTextInput` / `SplitTextField`: a segmented input (e.g. verification codes). */
|
|
254
|
+
export interface SplitTextInputProps extends TextFieldProps {
|
|
255
|
+
isRound?: boolean;
|
|
256
|
+
leadingText?: string;
|
|
257
|
+
leadingPressableProps?: Record<string, any>;
|
|
258
|
+
}
|
|
259
|
+
export interface StackProps extends ViewProps {
|
|
260
|
+
spacing?: number;
|
|
261
|
+
direction?: 'horizontal' | 'vertical';
|
|
262
|
+
align?: 'start' | 'center' | 'end' | 'stretch';
|
|
263
|
+
justify?: 'start' | 'center' | 'end' | 'between' | 'around';
|
|
264
|
+
children?: ReactNode;
|
|
265
|
+
}
|
|
266
|
+
export interface TableCheckboxRowProps {
|
|
267
|
+
label?: ReactNode;
|
|
268
|
+
subLabel?: ReactNode;
|
|
269
|
+
checked: boolean;
|
|
270
|
+
disabled?: boolean;
|
|
271
|
+
accessibilityHint?: string;
|
|
272
|
+
onPress: Fn<void>;
|
|
273
|
+
}
|
|
274
|
+
export interface TableRadioRowProps {
|
|
275
|
+
label?: ReactNode;
|
|
276
|
+
subLabel?: ReactNode;
|
|
277
|
+
value: any;
|
|
278
|
+
disabled?: boolean;
|
|
279
|
+
accessibilityHint?: string;
|
|
280
|
+
legacyCompat?: boolean;
|
|
281
|
+
}
|
|
282
|
+
export interface TableRowGroupProps {
|
|
283
|
+
title?: string;
|
|
284
|
+
description?: string;
|
|
285
|
+
helperText?: string;
|
|
286
|
+
hasIcons?: boolean;
|
|
287
|
+
hasTrailingText?: boolean;
|
|
288
|
+
accessibilityRole?: string;
|
|
289
|
+
accessibilityLabel?: string;
|
|
290
|
+
children?: ReactNode;
|
|
291
|
+
}
|
|
292
|
+
export interface TableRowGroupTitleProps {
|
|
293
|
+
title: string;
|
|
294
|
+
}
|
|
295
|
+
export interface TableRowIconProps {
|
|
296
|
+
source?: number;
|
|
297
|
+
IconComponent?: ComponentType<any>;
|
|
298
|
+
variant?: LiteralUnion<'default' | 'danger' | 'blurple'>;
|
|
299
|
+
}
|
|
300
|
+
export interface TableRowProps {
|
|
301
|
+
label?: ReactNode;
|
|
302
|
+
subLabel?: ReactNode;
|
|
303
|
+
icon?: ReactNode;
|
|
304
|
+
trailing?: ReactNode;
|
|
305
|
+
arrow?: boolean;
|
|
306
|
+
disabled?: boolean;
|
|
307
|
+
/** Rounds the top corners; set on the first row of a manually laid-out group. */
|
|
308
|
+
start?: boolean;
|
|
309
|
+
/** Rounds the bottom corners; set on the last row of a manually laid-out group. */
|
|
310
|
+
end?: boolean;
|
|
311
|
+
labelLineClamp?: number;
|
|
312
|
+
subLabelLineClamp?: number;
|
|
313
|
+
variant?: LiteralUnion<'default' | 'danger'>;
|
|
314
|
+
draggable?: boolean;
|
|
315
|
+
onPress?: Fn<void>;
|
|
316
|
+
children?: ReactNode;
|
|
317
|
+
}
|
|
318
|
+
export interface TableSwitchRowProps {
|
|
319
|
+
label?: ReactNode;
|
|
320
|
+
subLabel?: ReactNode;
|
|
321
|
+
icon?: ReactNode;
|
|
322
|
+
trailing?: ReactNode;
|
|
323
|
+
value: boolean;
|
|
324
|
+
disabled?: boolean;
|
|
325
|
+
accessibilityHint?: string;
|
|
326
|
+
variant?: LiteralUnion<'default'>;
|
|
327
|
+
onValueChange: (value: boolean) => void;
|
|
328
|
+
}
|
|
329
|
+
/** `TextArea` extends the field family with a character limit. */
|
|
330
|
+
export interface TextAreaProps extends TextFieldProps {
|
|
331
|
+
maxLength?: number;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* The redesign `TextField` and its siblings (`TextArea`, `SearchField`, `GhostInput`,
|
|
335
|
+
* `SplitTextInput`). This is where the `size` / `status` / `isClearable` / `leadingIcon` chrome
|
|
336
|
+
* actually lives, unlike {@link TextInputProps}. `onChange` receives the string value.
|
|
337
|
+
*/
|
|
338
|
+
export interface TextFieldProps {
|
|
339
|
+
value?: string;
|
|
340
|
+
defaultValue?: string;
|
|
341
|
+
placeholder?: string;
|
|
342
|
+
autoFocus?: boolean;
|
|
343
|
+
size?: InputSize;
|
|
344
|
+
/** @default 'default' */
|
|
345
|
+
status?: InputStatus;
|
|
346
|
+
isClearable?: boolean;
|
|
347
|
+
isDisabled?: boolean;
|
|
348
|
+
isRound?: boolean;
|
|
349
|
+
grow?: boolean;
|
|
350
|
+
leadingIcon?: IconSlot;
|
|
351
|
+
trailingIcon?: IconSlot;
|
|
352
|
+
leadingText?: string;
|
|
353
|
+
trailingText?: string;
|
|
354
|
+
leadingPressableProps?: Record<string, any>;
|
|
355
|
+
trailingPressableProps?: Record<string, any>;
|
|
356
|
+
secureTextEntry?: boolean;
|
|
357
|
+
keyboardType?: RNTextInputProps['keyboardType'];
|
|
358
|
+
autoComplete?: RNTextInputProps['autoComplete'];
|
|
359
|
+
returnKeyType?: RNTextInputProps['returnKeyType'];
|
|
360
|
+
maxLength?: number;
|
|
361
|
+
enableAndroidSanitizedInputWorkaround?: boolean;
|
|
362
|
+
style?: StyleProp<ViewStyle>;
|
|
363
|
+
inputStyle?: StyleProp<TextStyle>;
|
|
364
|
+
children?: ReactNode;
|
|
365
|
+
onChange?: (value: string) => void;
|
|
366
|
+
onClear?: Fn<void>;
|
|
367
|
+
onFocus?: RNTextInputProps['onFocus'];
|
|
368
|
+
onBlur?: RNTextInputProps['onBlur'];
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Discord's own form-style `TextInput` (`TextInput.native`), not React Native's. Its `onChange`
|
|
372
|
+
* receives the raw string value, not an event. These are the props it reads verbatim off its props
|
|
373
|
+
* object; every other prop is collected and spread onto the underlying native input via
|
|
374
|
+
* {@link TextInputPassthrough}.
|
|
375
|
+
*/
|
|
376
|
+
export interface TextInputProps extends TextInputPassthrough {
|
|
377
|
+
value?: string;
|
|
378
|
+
/** @default '' */
|
|
379
|
+
placeholder?: string;
|
|
380
|
+
/** Field label rendered above the input. @default '' */
|
|
381
|
+
title?: string;
|
|
382
|
+
/** @default '' */
|
|
383
|
+
helpText?: string;
|
|
384
|
+
/** Error message, or `true` to show the error state without text. */
|
|
385
|
+
error?: string | boolean;
|
|
386
|
+
/** @default false */
|
|
387
|
+
disabled?: boolean;
|
|
388
|
+
/** @default false */
|
|
389
|
+
multiline?: boolean;
|
|
390
|
+
/** @default 1 */
|
|
391
|
+
numberOfLines?: number;
|
|
392
|
+
/** @default false */
|
|
393
|
+
autoFocus?: boolean;
|
|
394
|
+
/** @default false */
|
|
395
|
+
secureTextEntry?: boolean;
|
|
396
|
+
keyboardType?: RNTextInputProps['keyboardType'];
|
|
397
|
+
keyboardAppearance?: RNTextInputProps['keyboardAppearance'];
|
|
398
|
+
autoCapitalize?: RNTextInputProps['autoCapitalize'];
|
|
399
|
+
autoCorrect?: boolean;
|
|
400
|
+
/** iOS clear-button mode; forwarded to the native input. */
|
|
401
|
+
clearButtonVisibility?: LiteralUnion<'never' | 'always' | 'unless-editing' | 'while-editing'>;
|
|
402
|
+
showBorder?: boolean;
|
|
403
|
+
/** @default false */
|
|
404
|
+
showCharactersRemaining?: boolean;
|
|
405
|
+
inputTextStyle?: StyleProp<TextStyle>;
|
|
406
|
+
style?: StyleProp<ViewStyle>;
|
|
407
|
+
/** @default false */
|
|
408
|
+
enableAndroidSanitizedInputWorkaround?: boolean;
|
|
409
|
+
/** Switches between the legacy and redesign render paths. @default true */
|
|
410
|
+
allowRedesignTextInput?: boolean;
|
|
411
|
+
onChange?: (value: string) => void;
|
|
412
|
+
}
|
|
413
|
+
export interface TextProps extends ViewProps {
|
|
414
|
+
children?: ReactNode;
|
|
415
|
+
variant?: TextVariant;
|
|
416
|
+
color?: LiteralUnion<'text-normal' | 'text-muted' | 'header-primary' | 'header-secondary'>;
|
|
417
|
+
style?: StyleProp<TextStyle>;
|
|
418
|
+
lineClamp?: number;
|
|
419
|
+
ellipsizeMode?: 'head' | 'middle' | 'tail' | 'clip';
|
|
420
|
+
tabularNumbers?: boolean;
|
|
421
|
+
animated?: boolean;
|
|
422
|
+
numberOfLines?: number;
|
|
423
|
+
allowFontScaling?: boolean;
|
|
424
|
+
}
|
|
425
|
+
/** A theme's semantic and raw colour definitions plus optional background. */
|
|
426
|
+
export interface Theme {
|
|
427
|
+
semantic: Record<PropertyKey, ThemeSemanticColor>;
|
|
428
|
+
raw: Record<PropertyKey, string>;
|
|
429
|
+
type: 'midnight' | 'darker' | 'light';
|
|
430
|
+
background?: {
|
|
431
|
+
blur?: number;
|
|
432
|
+
opacity?: number;
|
|
433
|
+
url: string;
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
/** A button rendered inside a toast. */
|
|
437
|
+
export interface ToastButton {
|
|
438
|
+
variant?: 'primary' | 'secondary' | 'tertiary';
|
|
439
|
+
size?: 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
440
|
+
iconPosition?: 'start' | 'end';
|
|
441
|
+
content: string;
|
|
442
|
+
icon?: number;
|
|
443
|
+
onPress: Fn;
|
|
444
|
+
}
|
|
445
|
+
/** A handle returned when showing a toast, used to update or close it. */
|
|
446
|
+
export interface ToastHandle {
|
|
447
|
+
update: (options: Partial<ToastOptions>) => void;
|
|
448
|
+
close: () => void;
|
|
449
|
+
}
|
|
450
|
+
/** Options accepted when showing a toast. */
|
|
451
|
+
export interface ToastOptions {
|
|
452
|
+
title?: string | ComponentType;
|
|
453
|
+
content?: string;
|
|
454
|
+
duration?: number;
|
|
455
|
+
onTimeout?: Fn;
|
|
456
|
+
icon?: string | number | ImageSourcePropType;
|
|
457
|
+
id?: string;
|
|
458
|
+
buttons?: ToastButton[];
|
|
459
|
+
tintedIcon?: boolean;
|
|
460
|
+
}
|
|
461
|
+
/** State and actions of the toast store. */
|
|
462
|
+
export interface ToastStoreState {
|
|
463
|
+
toasts: Record<string, InternalToastOptions>;
|
|
464
|
+
addToast: (options: InternalToastOptions) => ToastHandle;
|
|
465
|
+
updateToastWithOptions: (id: string, options: Partial<InternalToastOptions>) => void;
|
|
466
|
+
}
|
|
467
|
+
export interface TrailingTextProps {
|
|
468
|
+
text: string;
|
|
469
|
+
}
|
|
470
|
+
/** The author of an addon: a display name and a numeric user id. */
|
|
471
|
+
export type AddonAuthor = {
|
|
472
|
+
name: string;
|
|
473
|
+
id: `${number}`;
|
|
474
|
+
};
|
|
475
|
+
/** An addon referenced either by its id string or the {@link Addon} entity itself. */
|
|
476
|
+
export type AddonResolveable = string | Addon;
|
|
477
|
+
/** `Button` with its attached `Icon` static. */
|
|
478
|
+
export type ButtonComponent = ComponentType<ButtonProps> & {
|
|
479
|
+
Icon: ComponentType<TableRowIconProps>;
|
|
480
|
+
};
|
|
481
|
+
export type ButtonSize = LiteralUnion<'sm' | 'md' | 'lg'>;
|
|
482
|
+
export type ButtonVariant = LiteralUnion<
|
|
483
|
+
'primary' | 'secondary' | 'tertiary' | 'destructive' | 'active' | 'expressive'
|
|
484
|
+
>;
|
|
485
|
+
/**
|
|
486
|
+
* The style factory. Accepts a spec object (or a function returning one) and returns a hook. The
|
|
487
|
+
* hook subscribes to the theme context and lazily resolves each key on access, so it must be called
|
|
488
|
+
* inside a component body: `const styles = useStyles();`.
|
|
489
|
+
*/
|
|
490
|
+
export type CreateStyles = <T extends StyleSheetSpec>(
|
|
491
|
+
styles: StyleSheetSpecOrFactory<T>,
|
|
492
|
+
) => Fn<ResolvedStyles<T>>;
|
|
493
|
+
/** Discord ships numeric enums as bidirectional maps; this models both directions. */
|
|
494
|
+
export type EnumLike<K extends readonly string[]> = {
|
|
495
|
+
[P in K[number]]: number;
|
|
496
|
+
} & {
|
|
497
|
+
[n: number]: K[number];
|
|
498
|
+
};
|
|
499
|
+
/** A custom font the native loader has registered, as injected on `window.UNBOUND_FONTS`. */
|
|
500
|
+
export type FontDescriptor = {
|
|
501
|
+
name: string;
|
|
502
|
+
file: string;
|
|
503
|
+
path: string;
|
|
504
|
+
};
|
|
505
|
+
/** A font managed by the Fonts manager: currently identical to its {@link FontDescriptor}. */
|
|
506
|
+
export type FontEntity = FontDescriptor;
|
|
507
|
+
/** A loaded icon pack: its bundle marker and {@link IconPackManifest}. */
|
|
508
|
+
export type IconPack = {
|
|
509
|
+
bundle: string;
|
|
510
|
+
manifest: IconPackManifest;
|
|
511
|
+
};
|
|
512
|
+
/** An icon pack's manifest: an {@link AddonManifest} tagged with its source kind. */
|
|
513
|
+
export type IconPackManifest = AddonManifest & {
|
|
514
|
+
type: 'icon-pack';
|
|
515
|
+
source: 'github' | 'other';
|
|
516
|
+
};
|
|
517
|
+
/** Icon slot: a rendered node, a component, or a render function. */
|
|
518
|
+
export type IconSlot = ReactNode | ComponentType<any> | Fn<ReactNode>;
|
|
519
|
+
/** Input sizing, shared by the whole `TextField`/`Input` family. */
|
|
520
|
+
export type InputSize = LiteralUnion<'sm' | 'md' | 'lg'>;
|
|
521
|
+
/** Input status. `focused` is an internal state and is not user-settable. */
|
|
522
|
+
export type InputStatus = LiteralUnion<'default' | 'error'>;
|
|
523
|
+
/** An {@link Addon} whose instance is a {@link Plugin}. */
|
|
524
|
+
export type PluginEntity = Addon & {
|
|
525
|
+
instance: Plugin$1 | null;
|
|
526
|
+
};
|
|
527
|
+
/** Resolves each key of a {@link StyleSheetSpec} to the concrete RN style type it produced. */
|
|
528
|
+
export type ResolvedStyles<T extends StyleSheetSpec> = {
|
|
529
|
+
[K in keyof T]: T[K] extends ImageStyle
|
|
530
|
+
? ImageStyle
|
|
531
|
+
: T[K] extends TextStyle
|
|
532
|
+
? TextStyle
|
|
533
|
+
: ViewStyle;
|
|
534
|
+
};
|
|
535
|
+
/** A stylesheet spec: each key maps to a view, text, or image style. */
|
|
536
|
+
export type StyleSheetSpec = Record<
|
|
537
|
+
string,
|
|
538
|
+
ViewStyle | TextStyle | ImageStyle | Record<PropertyKey, any>
|
|
539
|
+
>;
|
|
540
|
+
/** A stylesheet spec, or a function producing one (Discord accepts both forms). */
|
|
541
|
+
export type StyleSheetSpecOrFactory<T extends StyleSheetSpec> = T | ((...args: any[]) => T);
|
|
542
|
+
/** `TableRow` with its attached statics (`Icon`, `Arrow`, `TrailingText`). */
|
|
543
|
+
export type TableRowComponent = ComponentType<TableRowProps> & {
|
|
544
|
+
Icon: ComponentType<TableRowIconProps>;
|
|
545
|
+
Arrow: ComponentType<ViewProps>;
|
|
546
|
+
TrailingText: ComponentType<TrailingTextProps>;
|
|
547
|
+
};
|
|
548
|
+
/**
|
|
549
|
+
* Native `TextInput` props forwarded through `TextInput`. Everything the DS component does not read
|
|
550
|
+
* itself (`maxLength`, `selectionColor`, `onFocus`, …) is spread onto the underlying native input,
|
|
551
|
+
* so it accepts the RN surface too, minus the members `TextInput` overrides with its own semantics.
|
|
552
|
+
*/
|
|
553
|
+
export type TextInputPassthrough = Omit<
|
|
554
|
+
RNTextInputProps,
|
|
555
|
+
| 'value'
|
|
556
|
+
| 'placeholder'
|
|
557
|
+
| 'multiline'
|
|
558
|
+
| 'numberOfLines'
|
|
559
|
+
| 'autoFocus'
|
|
560
|
+
| 'secureTextEntry'
|
|
561
|
+
| 'keyboardType'
|
|
562
|
+
| 'keyboardAppearance'
|
|
563
|
+
| 'autoCapitalize'
|
|
564
|
+
| 'autoCorrect'
|
|
565
|
+
| 'style'
|
|
566
|
+
| 'onChange'
|
|
567
|
+
>;
|
|
568
|
+
/** Every typography variant Discord ships in `TextStyleSheet`, kept open for new ones. */
|
|
569
|
+
export type TextVariant = LiteralUnion<
|
|
570
|
+
| `heading-${'sm' | 'md' | 'lg' | 'xl' | 'xxl'}/${TextWeight | 'extrabold'}`
|
|
571
|
+
| `experimental/heading-${'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'}/${'semibold' | 'bold'}`
|
|
572
|
+
| `heading-deprecated-12/${TextWeight | 'extrabold'}`
|
|
573
|
+
| `redesign/heading-18/${'medium' | 'semibold' | 'bold'}`
|
|
574
|
+
| `text-${'xxs' | 'xs' | 'sm' | 'md' | 'lg'}/${TextWeight}`
|
|
575
|
+
| `redesign/message-preview/${TextWeight}`
|
|
576
|
+
| `redesign/channel-title/${TextWeight}`
|
|
577
|
+
| `experimental/body-${'xs' | 'sm' | 'md' | 'lg'}/${'normal' | 'medium'}`
|
|
578
|
+
| `experimental/meta/${'normal' | 'medium'}`
|
|
579
|
+
| `experimental/label-${'xs' | 'sm' | 'md' | 'lg'}/${'medium' | 'semibold'}`
|
|
580
|
+
| `experimental/mono-${'sm' | 'md'}/${'normal' | 'bold'}`
|
|
581
|
+
| `display-${'sm' | 'md' | 'lg'}`
|
|
582
|
+
| `experimental/display-${'xs' | 'sm' | 'md' | 'lg'}`
|
|
583
|
+
| 'eyebrow'
|
|
584
|
+
>;
|
|
585
|
+
/** The four common font weights used across typography variants. */
|
|
586
|
+
export type TextWeight = 'normal' | 'medium' | 'semibold' | 'bold';
|
|
587
|
+
/** An {@link Addon} whose instance is a {@link Theme}, tracking its registration state. */
|
|
588
|
+
export type ThemeEntity = Addon & {
|
|
589
|
+
registered: boolean;
|
|
590
|
+
instance: Theme | null;
|
|
591
|
+
};
|
|
592
|
+
/** A single semantic colour definition in a {@link Theme}. */
|
|
593
|
+
export type ThemeSemanticColor = {
|
|
594
|
+
type: 'color' | 'raw';
|
|
595
|
+
value: string;
|
|
596
|
+
opacity?: number;
|
|
597
|
+
};
|
|
598
|
+
/** `TransitionStates`: MOUNTED = 0, ENTERED = 1, YEETED = 2. */
|
|
599
|
+
export type TransitionState = 'MOUNTED' | 'ENTERED' | 'YEETED';
|
|
600
|
+
/** A {@link DiscordAsset} extended with Unbound's icon-pack overrides. */
|
|
601
|
+
export type UnboundAsset = DiscordAsset & {
|
|
602
|
+
iconPackPath?: string;
|
|
603
|
+
iconPackScale?: number;
|
|
604
|
+
};
|
|
605
|
+
|
|
606
|
+
interface Navigation$1<T = any> {
|
|
607
|
+
push: (route: string, params?: T) => void;
|
|
608
|
+
pop: () => void;
|
|
609
|
+
navigate: (route: string, params?: T) => void;
|
|
610
|
+
goBack: () => void;
|
|
611
|
+
setOptions: (options: Record<string, any>) => void;
|
|
612
|
+
addListener: (event: string, callback: Fn) => Fn<void>;
|
|
613
|
+
[key: string]: any;
|
|
614
|
+
}
|
|
615
|
+
/** The lifecycle and settings contract implemented by a plugin. */
|
|
616
|
+
interface Plugin$1 {
|
|
617
|
+
start?(): void;
|
|
618
|
+
stop?(): void;
|
|
619
|
+
getSettingsPanel?(): ReactNode;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
export { Navigation$1 as Navigation, Plugin$1 as Plugin };
|