@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/src/assets.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
export type { UnboundAsset } from './_internal';
|
|
4
|
+
import type { UnboundAsset } from './_internal';
|
|
5
|
+
declare const _default: {
|
|
6
|
+
assets: Map<number, UnboundAsset>;
|
|
7
|
+
find: typeof find;
|
|
8
|
+
getByName: typeof getByName;
|
|
9
|
+
getByID: typeof getByID;
|
|
10
|
+
getIDByName: typeof getIDByName;
|
|
11
|
+
getAll: typeof getAll;
|
|
12
|
+
Icons: Record<string, number | undefined>;
|
|
13
|
+
};
|
|
14
|
+
/** Proxy resolving any property name to its asset id via {@link getIDByName}. */
|
|
15
|
+
export declare const Icons: Record<string, number | undefined>;
|
|
16
|
+
/** Map of discovered asset ids to their resolved {@link UnboundAsset} record. */
|
|
17
|
+
export declare const assets: Map<number, UnboundAsset>;
|
|
18
|
+
/**
|
|
19
|
+
* @description Finds the first known asset matching the given predicate.
|
|
20
|
+
* @param filter Predicate run against each asset.
|
|
21
|
+
* @returns The matched {@link UnboundAsset}, or `undefined` if none match.
|
|
22
|
+
*/
|
|
23
|
+
export declare function find(filter: (asset: UnboundAsset) => boolean): UnboundAsset | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* @description Returns every known asset.
|
|
26
|
+
* @returns An array of all registered {@link UnboundAsset} records.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getAll(): UnboundAsset[];
|
|
29
|
+
/**
|
|
30
|
+
* @description Looks up a known asset by its id.
|
|
31
|
+
* @param id The asset id to look up.
|
|
32
|
+
* @returns The matched {@link UnboundAsset}, or `undefined` if none is registered for that id.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getByID(id: number): UnboundAsset | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* @description Finds a known asset by its name and type.
|
|
37
|
+
* @param name The asset name to match.
|
|
38
|
+
* @param type The asset type to match.
|
|
39
|
+
* @returns The matched {@link UnboundAsset}, or `undefined` if none match.
|
|
40
|
+
*/
|
|
41
|
+
export declare function getByName(name: string, type?: 'svg' | 'png'): UnboundAsset | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* @description Looks up a known asset's id by its name and type.
|
|
44
|
+
* @param name The asset name to match.
|
|
45
|
+
* @param type The asset type to match.
|
|
46
|
+
* @returns The matched asset's id, or `undefined` if none match.
|
|
47
|
+
*/
|
|
48
|
+
export declare function getIDByName(name: string, type?: 'svg' | 'png'): number | undefined;
|
|
49
|
+
export { _default as default };
|
package/src/fs.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
declare const _default: {
|
|
4
|
+
Documents: string;
|
|
5
|
+
read: typeof read;
|
|
6
|
+
write: typeof write;
|
|
7
|
+
rm: typeof rm;
|
|
8
|
+
exists: typeof exists;
|
|
9
|
+
};
|
|
10
|
+
/** Absolute path to the platform's documents directory. */
|
|
11
|
+
export declare const Documents: string;
|
|
12
|
+
/**
|
|
13
|
+
* @description Checks whether a file exists, resolving relative paths against {@link Documents}.
|
|
14
|
+
* @param path The file path to check, relative to {@link Documents} unless `inDocuments` is `false`.
|
|
15
|
+
* @param inDocuments Whether to resolve `path` relative to {@link Documents}.
|
|
16
|
+
* @returns A promise resolving to whether the file exists.
|
|
17
|
+
*/
|
|
18
|
+
export declare function exists(path: string, inDocuments?: boolean): Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* @description Reads a file's contents, resolving relative paths against {@link Documents}.
|
|
21
|
+
* @param path The file path to read, relative to {@link Documents} unless `inDocuments` is `false`.
|
|
22
|
+
* @param encoding The encoding to read the file with.
|
|
23
|
+
* @param inDocuments Whether to resolve `path` relative to {@link Documents}.
|
|
24
|
+
* @returns A promise resolving to the file's contents.
|
|
25
|
+
*/
|
|
26
|
+
export declare function read(
|
|
27
|
+
path: string,
|
|
28
|
+
encoding?: DCDFileManagerEncoding,
|
|
29
|
+
inDocuments?: boolean,
|
|
30
|
+
): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* @description Removes a file within {@link Documents}.
|
|
33
|
+
* @param path The file path to remove, relative to {@link Documents}.
|
|
34
|
+
* @returns A promise resolving to whether the file was removed.
|
|
35
|
+
*/
|
|
36
|
+
export declare function rm(path: string): Promise<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* @description Writes content to a file within {@link Documents}.
|
|
39
|
+
* @param path The file path to write to, relative to {@link Documents}.
|
|
40
|
+
* @param content The content to write.
|
|
41
|
+
* @param encoding The encoding to write the file with.
|
|
42
|
+
* @returns A promise resolving once the file is written.
|
|
43
|
+
*/
|
|
44
|
+
export declare function write(
|
|
45
|
+
path: string,
|
|
46
|
+
content: string,
|
|
47
|
+
encoding?: DCDFileManagerEncoding,
|
|
48
|
+
): Promise<string>;
|
|
49
|
+
/** The text encodings accepted by the native `DCDFileManager` read/write operations. */
|
|
50
|
+
export type DCDFileManagerEncoding = 'utf-8' | 'utf8' | 'base64';
|
|
51
|
+
|
|
52
|
+
export { _default as default };
|
package/src/global.d.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
export type {
|
|
4
|
+
Addon,
|
|
5
|
+
AddonAuthor,
|
|
6
|
+
AddonManifest,
|
|
7
|
+
AddonResolveable,
|
|
8
|
+
AssetsModule,
|
|
9
|
+
ButtonComponent,
|
|
10
|
+
ButtonProps,
|
|
11
|
+
ButtonSize,
|
|
12
|
+
ButtonVariant,
|
|
13
|
+
CardProps,
|
|
14
|
+
CheckboxProps,
|
|
15
|
+
CreateStyles,
|
|
16
|
+
DesignModule,
|
|
17
|
+
DiscordAsset,
|
|
18
|
+
EnumLike,
|
|
19
|
+
FloatingActionButtonProps,
|
|
20
|
+
FontDescriptor,
|
|
21
|
+
FontEntity,
|
|
22
|
+
GhostInputProps,
|
|
23
|
+
IconButtonProps,
|
|
24
|
+
IconPack,
|
|
25
|
+
IconPackManifest,
|
|
26
|
+
IconSlot,
|
|
27
|
+
InputSize,
|
|
28
|
+
InputStatus,
|
|
29
|
+
InternalToastOptions,
|
|
30
|
+
Navigation,
|
|
31
|
+
Plugin,
|
|
32
|
+
PluginEntity,
|
|
33
|
+
ResolvedStyles,
|
|
34
|
+
RowButtonProps,
|
|
35
|
+
SegmentedControlProps,
|
|
36
|
+
SegmentedControlState,
|
|
37
|
+
SettingsEntry,
|
|
38
|
+
SettingsScreen,
|
|
39
|
+
SliderProps,
|
|
40
|
+
SplitTextInputProps,
|
|
41
|
+
StackProps,
|
|
42
|
+
StyleSheetSpec,
|
|
43
|
+
StyleSheetSpecOrFactory,
|
|
44
|
+
TableCheckboxRowProps,
|
|
45
|
+
TableRadioRowProps,
|
|
46
|
+
TableRowComponent,
|
|
47
|
+
TableRowGroupProps,
|
|
48
|
+
TableRowGroupTitleProps,
|
|
49
|
+
TableRowIconProps,
|
|
50
|
+
TableRowProps,
|
|
51
|
+
TableSwitchRowProps,
|
|
52
|
+
TextAreaProps,
|
|
53
|
+
TextFieldProps,
|
|
54
|
+
TextInputPassthrough,
|
|
55
|
+
TextInputProps,
|
|
56
|
+
TextProps,
|
|
57
|
+
TextVariant,
|
|
58
|
+
TextWeight,
|
|
59
|
+
Theme,
|
|
60
|
+
ThemeEntity,
|
|
61
|
+
ThemeSemanticColor,
|
|
62
|
+
ToastButton,
|
|
63
|
+
ToastHandle,
|
|
64
|
+
ToastOptions,
|
|
65
|
+
ToastStoreState,
|
|
66
|
+
TrailingTextProps,
|
|
67
|
+
TransitionState,
|
|
68
|
+
UnboundAsset,
|
|
69
|
+
} from './_internal';
|
|
70
|
+
import type { ColorString } from './utils';
|
|
71
|
+
declare global {
|
|
72
|
+
/** The raw `UnboundNative` JSI bridge the tweak installs directly on the JS global. */
|
|
73
|
+
type UnboundNativeModule = {
|
|
74
|
+
// Utilities
|
|
75
|
+
getDeviceModel(): string;
|
|
76
|
+
getiOSVersionString(): string;
|
|
77
|
+
isJailbroken(): boolean;
|
|
78
|
+
isSystemApp(): Promise<boolean>;
|
|
79
|
+
isVerifiedBuild(): boolean;
|
|
80
|
+
isAppStoreApp(): boolean;
|
|
81
|
+
isTestFlightApp(): boolean;
|
|
82
|
+
isTrollStoreApp(): boolean;
|
|
83
|
+
isLiveContainerApp(): boolean;
|
|
84
|
+
getTrollStoreVariant(): string;
|
|
85
|
+
getApplicationEntitlements(): unknown;
|
|
86
|
+
getAppSource(): string;
|
|
87
|
+
getEntitlementsAsPlist(): string;
|
|
88
|
+
showToolboxMenu(): void;
|
|
89
|
+
// Plugin API
|
|
90
|
+
showNotification(
|
|
91
|
+
title: string,
|
|
92
|
+
content: string,
|
|
93
|
+
scheduledTime: number,
|
|
94
|
+
sound: boolean,
|
|
95
|
+
notificationId: string,
|
|
96
|
+
): void;
|
|
97
|
+
playPiPVideo(videoURL: string): void;
|
|
98
|
+
// Chat UI
|
|
99
|
+
setAvatarCornerRadius(radius: number): void;
|
|
100
|
+
resetAvatarCornerRadius(): void;
|
|
101
|
+
getAvatarCornerRadius(): number;
|
|
102
|
+
setMessageBubblesEnabled(
|
|
103
|
+
enabled: boolean,
|
|
104
|
+
lightColor: ColorString | null,
|
|
105
|
+
darkColor: ColorString | null,
|
|
106
|
+
): void;
|
|
107
|
+
setMessageBubbleColors(lightColor: ColorString, darkColor: ColorString): void;
|
|
108
|
+
getMessageBubbleLightColor(): ColorString;
|
|
109
|
+
getMessageBubbleDarkColor(): ColorString;
|
|
110
|
+
getMessageBubblesEnabled(): boolean;
|
|
111
|
+
getMessageBubbleCornerRadius(): number;
|
|
112
|
+
setMessageBubbleCornerRadius(radius: number): void;
|
|
113
|
+
resetMessageBubbles(): void;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Build-time token, replaced with a boolean literal by the build's `transform.define`. Folds at
|
|
117
|
+
* the module-graph level so `if ($$DEV$$)` branches (and any imports inside them) are dead-code
|
|
118
|
+
* eliminated from production bundles entirely. Use it (not a runtime check) to gate dev-only code.
|
|
119
|
+
*/
|
|
120
|
+
var $$DEV$$: boolean;
|
|
121
|
+
/** The raw `UnboundNative` JSI bridge, installed on the global by the platform loader. */
|
|
122
|
+
var UnboundNative: UnboundNativeModule | undefined;
|
|
123
|
+
var React: typeof import('react');
|
|
124
|
+
var ReactNative: typeof import('react-native');
|
|
125
|
+
|
|
126
|
+
interface Window {}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface UnboundGlobal {
|
|
130
|
+
assets: typeof import('./assets.d.ts');
|
|
131
|
+
fs: typeof import('./fs.d.ts');
|
|
132
|
+
i18n: typeof import('./i18n.d.ts');
|
|
133
|
+
metro: typeof import('./metro/index.d.ts');
|
|
134
|
+
native: typeof import('./native.d.ts');
|
|
135
|
+
patcher: typeof import('./patcher.d.ts');
|
|
136
|
+
settings: typeof import('./settings.d.ts');
|
|
137
|
+
storage: typeof import('./storage.d.ts');
|
|
138
|
+
toasts: typeof import('./toasts.d.ts');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
declare global {
|
|
142
|
+
interface Window {
|
|
143
|
+
unbound: UnboundGlobal;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const unbound: Window['unbound'];
|
|
147
|
+
}
|
package/src/i18n.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
declare const _default: {
|
|
4
|
+
Messages: Record<string, string>;
|
|
5
|
+
format: typeof format;
|
|
6
|
+
defineLocalizations: typeof defineLocalizations;
|
|
7
|
+
init: typeof init;
|
|
8
|
+
destroy: typeof destroy;
|
|
9
|
+
};
|
|
10
|
+
/** The core `Messages` proxy, resolving Unbound's own UI strings against the active Discord locale. */
|
|
11
|
+
export declare const Messages: Record<string, string>;
|
|
12
|
+
/**
|
|
13
|
+
* @description Creates an isolated, in-memory `Messages`/`format` pair over an addon-supplied string table, sharing the active locale with core.
|
|
14
|
+
* @param table The addon's string store, keyed by locale then message key.
|
|
15
|
+
* @returns A `Messages` proxy and `format` function scoped to the supplied table.
|
|
16
|
+
*/
|
|
17
|
+
export declare function defineLocalizations(table: StringStore): Localizations;
|
|
18
|
+
/**
|
|
19
|
+
* @description Drains every active locale-change subscription. Idempotent. Twin of {@link init}.
|
|
20
|
+
*/
|
|
21
|
+
export declare function destroy(): void;
|
|
22
|
+
/**
|
|
23
|
+
* @description Formats a localized string, interpolating ICU `MessageFormat` placeholders.
|
|
24
|
+
* @param key The message key to resolve and format.
|
|
25
|
+
* @param vars The variables to interpolate into the message.
|
|
26
|
+
* @returns The formatted string.
|
|
27
|
+
*/
|
|
28
|
+
export declare function format(key: string, vars?: FormatVars): string;
|
|
29
|
+
/**
|
|
30
|
+
* @description Loads the fallback and active locales, then subscribes to Discord locale changes. Fire-and-forget; never blocks startup. Twin of {@link destroy}.
|
|
31
|
+
* @returns A promise that resolves once the initial locales have been ensured and the subscription is wired.
|
|
32
|
+
*/
|
|
33
|
+
export declare function init(): Promise<void>;
|
|
34
|
+
export type FormatVars = Record<string, unknown>;
|
|
35
|
+
export type LocaleStrings = Record<string, string>;
|
|
36
|
+
export type Localizations = {
|
|
37
|
+
Messages: Record<string, string>;
|
|
38
|
+
format: (key: string, vars?: FormatVars) => string;
|
|
39
|
+
};
|
|
40
|
+
export type StringStore = Record<string, LocaleStrings>;
|
|
41
|
+
|
|
42
|
+
export { _default as default };
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
export * as metro from './metro/index';
|
|
4
|
+
export * as settings from './settings';
|
|
5
|
+
export * as patcher from './patcher';
|
|
6
|
+
export * as storage from './storage';
|
|
7
|
+
export * as assets from './assets';
|
|
8
|
+
export * as native from './native';
|
|
9
|
+
export * as toasts from './toasts';
|
|
10
|
+
export * as i18n from './i18n';
|
|
11
|
+
export * as fs from './fs';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
declare const Clipboard$1: any;
|
|
4
|
+
declare const React$1: typeof import('react');
|
|
5
|
+
declare const ReactNative$1: typeof import('react-native');
|
|
6
|
+
export declare const Assets: any;
|
|
7
|
+
export declare const Clyde: any;
|
|
8
|
+
export declare const Commands: any;
|
|
9
|
+
export declare const Constants: any;
|
|
10
|
+
export declare const Dispatcher: any;
|
|
11
|
+
export declare const Flux: any;
|
|
12
|
+
export declare const Gestures: any;
|
|
13
|
+
export declare const MarkdownParser: any;
|
|
14
|
+
export declare const Moment: any;
|
|
15
|
+
export declare const REST: any;
|
|
16
|
+
export declare const Radius: any;
|
|
17
|
+
export declare const Reanimated: any;
|
|
18
|
+
export declare const SVG: any;
|
|
19
|
+
export declare const Screens: any;
|
|
20
|
+
export declare const Util: any;
|
|
21
|
+
export declare const i18n: any;
|
|
22
|
+
|
|
23
|
+
export { Clipboard$1 as Clipboard, React$1 as React, ReactNative$1 as ReactNative };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
export type { DesignModule } from '../_internal';
|
|
4
|
+
import {
|
|
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 { DesignModule } from '../_internal';
|
|
15
|
+
export declare const BackdropFilters: any;
|
|
16
|
+
export declare const Discord: DesignModule;
|
|
17
|
+
export declare const FlashList: any;
|
|
18
|
+
export declare const Forms: any;
|
|
19
|
+
export declare const HelpMessage: any;
|
|
20
|
+
export declare const Media: any;
|
|
21
|
+
export declare const Portal: any;
|
|
22
|
+
export declare const SafeArea: any;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
import type { PredicateResult } from '../utils';
|
|
4
|
+
declare const CACHE_KEY: unique symbol;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
byProps: typeof byProps;
|
|
7
|
+
byDisplayName: typeof byDisplayName;
|
|
8
|
+
byPrototypes: typeof byPrototypes;
|
|
9
|
+
byName: typeof byName;
|
|
10
|
+
byStore: typeof byStore;
|
|
11
|
+
byFilePath: typeof byFilePath;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* @description Builds a filter matching a module whose `displayName` equals the given name.
|
|
15
|
+
* @param name The `displayName` the module must have.
|
|
16
|
+
* @returns A {@link MetroFilter} matching the module with that `displayName`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function byDisplayName(name: string): MetroFilter;
|
|
19
|
+
/**
|
|
20
|
+
* @description Builds a filter matching a module whose tracked file path equals the given path.
|
|
21
|
+
* @param path The file path the module must have been imported from.
|
|
22
|
+
* @returns A {@link MetroFilter} matching the module loaded from that file path.
|
|
23
|
+
*/
|
|
24
|
+
export declare function byFilePath(path: string[]): MetroFilter;
|
|
25
|
+
/**
|
|
26
|
+
* @description Builds a filter matching a module whose `name` equals the given name.
|
|
27
|
+
* @param name The `name` the module must have.
|
|
28
|
+
* @returns A {@link MetroFilter} matching the module with that `name`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function byName(name: string): MetroFilter;
|
|
31
|
+
/**
|
|
32
|
+
* @description Builds a filter matching a module that exposes all of the given property names.
|
|
33
|
+
* @param props The property names the module must expose.
|
|
34
|
+
* @returns A {@link MetroFilter} matching modules that expose every given property.
|
|
35
|
+
*/
|
|
36
|
+
export declare function byProps(...props: string[]): MetroFilter;
|
|
37
|
+
/**
|
|
38
|
+
* @description Builds a filter matching a module whose prototype exposes all of the given method names.
|
|
39
|
+
* @param prototypes The prototype method names the module's prototype must expose.
|
|
40
|
+
* @returns A {@link MetroFilter} matching modules whose prototype exposes every given method.
|
|
41
|
+
*/
|
|
42
|
+
export declare function byPrototypes(...prototypes: string[]): MetroFilter;
|
|
43
|
+
/**
|
|
44
|
+
* @description Builds a filter matching a flux store by name, appending `Store` when `short` is set.
|
|
45
|
+
* @param name The store name to match against.
|
|
46
|
+
* @param short Whether to append `Store` to `name` before matching.
|
|
47
|
+
* @returns A {@link MetroFilter} matching the flux store with that name.
|
|
48
|
+
*/
|
|
49
|
+
export declare function byStore(name: string, short?: boolean): MetroFilter;
|
|
50
|
+
/** A module predicate, carrying its cache key and a `raw` flag, produced by every `by*` helper. */
|
|
51
|
+
export type MetroFilter = ((mdl: any, id: number | string) => PredicateResult) & {
|
|
52
|
+
[CACHE_KEY]?: string;
|
|
53
|
+
isRaw?: boolean;
|
|
54
|
+
};
|
|
55
|
+
export { _default as default };
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
// Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ImageStyle,
|
|
5
|
+
StyleProp,
|
|
6
|
+
TextInputProps as RNTextInputProps,
|
|
7
|
+
TextStyle,
|
|
8
|
+
ViewProps,
|
|
9
|
+
ViewStyle,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
import { ComponentType, ReactNode } from 'react';
|
|
12
|
+
|
|
13
|
+
import type { AnyProps, Fn, PredicateResult } from '../utils';
|
|
14
|
+
/** @internal */
|
|
15
|
+
declare const CACHE_KEY: unique symbol;
|
|
16
|
+
export declare const off: typeof removeListener;
|
|
17
|
+
export declare const on: typeof addListener;
|
|
18
|
+
/**
|
|
19
|
+
* @description Registers a listener invoked with every module as it is required.
|
|
20
|
+
* @param listener Callback receiving the module exports and its id.
|
|
21
|
+
* @returns A function that removes the listener.
|
|
22
|
+
*/
|
|
23
|
+
export declare function addListener(listener: (mdl: any, id: string) => void): () => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* @description Runs several filters in a single registry pass, returning one result per item.
|
|
26
|
+
* @param items The filters to resolve, each with its own per-item options.
|
|
27
|
+
* @returns An array of matches positionally aligned with `items`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function bulk(...items: MetroBulkItem[]): any[];
|
|
30
|
+
/**
|
|
31
|
+
* @description Core synchronous module search. Tries the per-key cache fast-path first, then falls
|
|
32
|
+
* back to scanning the registry, degrading gracefully if the supplied filter throws.
|
|
33
|
+
* @param filter The filter to match modules against.
|
|
34
|
+
* @param options Search options controlling interop, caching, esModule unwrapping, and `all`.
|
|
35
|
+
* @returns The first matching module, an array of matches when `all` is set, or `null`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function find(filter: MetroFilter, options?: MetroSearchOptions): any;
|
|
38
|
+
/**
|
|
39
|
+
* @description Finds a module by a segment of its file path.
|
|
40
|
+
* @template U The union of requested path segments.
|
|
41
|
+
* @template T The argument tuple, optionally ending in search options or a bulk marker.
|
|
42
|
+
* @param args The file path segment(s) to search for, optionally followed by options.
|
|
43
|
+
* @returns The matched module.
|
|
44
|
+
*/
|
|
45
|
+
export declare function findByFilePath<
|
|
46
|
+
U extends string,
|
|
47
|
+
T extends U[] | MetroStringFindWithOptions<U> | MetroBulkFind<U>,
|
|
48
|
+
>(...args: T): AnyProps;
|
|
49
|
+
/**
|
|
50
|
+
* @description Finds a module by the name of its default export.
|
|
51
|
+
* @template U The union of requested names.
|
|
52
|
+
* @template T The argument tuple, optionally ending in search options or a bulk marker.
|
|
53
|
+
* @param args The name(s) to search for, optionally followed by options.
|
|
54
|
+
* @returns The matched function (or matches, for a bulk/`all` search).
|
|
55
|
+
*/
|
|
56
|
+
export declare function findByName<
|
|
57
|
+
U extends string,
|
|
58
|
+
T extends U[] | MetroStringFindWithOptions<U> | MetroBulkFind<U>,
|
|
59
|
+
>(...args: T): MetroFunctionSignatureOrArray<T, U>;
|
|
60
|
+
/**
|
|
61
|
+
* @description Finds a module exposing all of the given property names.
|
|
62
|
+
* @template U The union of requested property names.
|
|
63
|
+
* @template T The argument tuple, optionally ending in search options or a bulk marker.
|
|
64
|
+
* @param args The property names to search for, optionally followed by options.
|
|
65
|
+
* @returns The matched module (or matches, for a bulk/`all` search).
|
|
66
|
+
*/
|
|
67
|
+
export declare function findByProps<
|
|
68
|
+
U extends string,
|
|
69
|
+
T extends U[] | MetroStringFindWithOptions<U> | MetroBulkFind<U>,
|
|
70
|
+
>(...args: T): MetroPropertyRecordOrArray<T, U> & {};
|
|
71
|
+
/**
|
|
72
|
+
* @description Finds a module whose prototype exposes all of the given method names.
|
|
73
|
+
* @template U The union of requested prototype method names.
|
|
74
|
+
* @template T The argument tuple, optionally ending in search options or a bulk marker.
|
|
75
|
+
* @param args The prototype method names to search for, optionally followed by options.
|
|
76
|
+
* @returns The matched module.
|
|
77
|
+
*/
|
|
78
|
+
export declare function findByPrototypes<
|
|
79
|
+
U extends string,
|
|
80
|
+
T extends U[] | MetroStringFindWithOptions<U> | MetroBulkFind<U>,
|
|
81
|
+
>(...args: T): AnyProps;
|
|
82
|
+
/**
|
|
83
|
+
* @description Resolves a module matching `filter`, waiting for it to load if it is not yet present.
|
|
84
|
+
* @param filter The filter to match against.
|
|
85
|
+
* @param options Search options, excluding `lazy` and `all`, plus an optional `signal` to abort the wait.
|
|
86
|
+
* @returns The matched module, or a promise that resolves once a matching module is required, or
|
|
87
|
+
* `undefined` if the supplied signal aborts first.
|
|
88
|
+
*/
|
|
89
|
+
export declare function findLazy(filter: MetroFilter, options?: MetroLazySearchOptions): any;
|
|
90
|
+
/**
|
|
91
|
+
* @description Finds a flux store by name.
|
|
92
|
+
* @template U The union of requested store names.
|
|
93
|
+
* @template T The argument tuple, optionally ending in store search options.
|
|
94
|
+
* @param args The store name(s) to search for, optionally followed by options (`short` defaults to `true`).
|
|
95
|
+
* @returns The matched store.
|
|
96
|
+
*/
|
|
97
|
+
export declare function findStore<
|
|
98
|
+
U extends string,
|
|
99
|
+
T extends U[] | MetroStringFindWithOptions<U, MetroStoreOptions>,
|
|
100
|
+
>(...args: T): AnyProps;
|
|
101
|
+
/**
|
|
102
|
+
* @description Forces a module to initialise via metro's `__r`, blacklisting it if it throws.
|
|
103
|
+
* @param id The id of the module to initialise.
|
|
104
|
+
* @returns `true` if the module is initialised, `false` if it was blacklisted.
|
|
105
|
+
*/
|
|
106
|
+
export declare function initializeModule(id: number): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* @description Removes a previously registered module listener.
|
|
109
|
+
* @param listener The listener to remove.
|
|
110
|
+
*/
|
|
111
|
+
export declare function removeListener(listener: (mdl: any, id: string) => void): void;
|
|
112
|
+
|
|
113
|
+
/** A single entry in a {@link bulk} search: a filter plus its per-item options. */
|
|
114
|
+
export interface MetroBulkItem extends Omit<MetroSearchOptions, 'initial' | 'cache'> {
|
|
115
|
+
filter: MetroFilter;
|
|
116
|
+
}
|
|
117
|
+
/** Search options for {@link findLazy}, adding a `signal` that abandons the wait when aborted. */
|
|
118
|
+
export interface MetroLazySearchOptions extends Omit<MetroSearchOptions, 'lazy' | 'all'> {
|
|
119
|
+
signal?: AbortSignal;
|
|
120
|
+
}
|
|
121
|
+
/** Search options for {@link findStore}, adding the `short` name-matching toggle. */
|
|
122
|
+
export interface MetroStoreOptions extends MetroSearchOptions {
|
|
123
|
+
short?: boolean;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Widens a single result to an array when the search was made with `all: true`. */
|
|
127
|
+
export type MetroAllValues<T extends Record<PropertyKey, any>, U extends unknown> = T extends {
|
|
128
|
+
all: true;
|
|
129
|
+
}
|
|
130
|
+
? U[]
|
|
131
|
+
: U;
|
|
132
|
+
/** Tuple of param bags followed by a `{ bulk: true }` marker, describing a bulk find. */
|
|
133
|
+
export type MetroBulkFind<T extends string> = [
|
|
134
|
+
...AnyProps<MetroParamsBag<T>>[],
|
|
135
|
+
AnyProps<MetroBulkMarker>,
|
|
136
|
+
];
|
|
137
|
+
/** The marker object distinguishing a bulk find from a single one. */
|
|
138
|
+
export type MetroBulkMarker = {
|
|
139
|
+
bulk: true;
|
|
140
|
+
};
|
|
141
|
+
/** Result shape of a bulk by-name search, one function per requested item. */
|
|
142
|
+
export type MetroBulkModuleByName<T extends any[]> = {
|
|
143
|
+
[K in keyof T]: T[K] extends {
|
|
144
|
+
interop: false;
|
|
145
|
+
}
|
|
146
|
+
? {
|
|
147
|
+
default: Fn;
|
|
148
|
+
}
|
|
149
|
+
: Fn;
|
|
150
|
+
};
|
|
151
|
+
/** Result shape of a bulk by-property search, one record per requested item. */
|
|
152
|
+
export type MetroBulkModuleByProperty<T extends any[]> = {
|
|
153
|
+
[K in keyof T]: AnyProps<MetroParamsRecord<T[K]['params']>>;
|
|
154
|
+
};
|
|
155
|
+
/** A module predicate, carrying its cache key and a `raw` flag, produced by every `by*` helper. */
|
|
156
|
+
export type MetroFilter = ((mdl: any, id: number | string) => PredicateResult) & {
|
|
157
|
+
[CACHE_KEY]?: string;
|
|
158
|
+
isRaw?: boolean;
|
|
159
|
+
};
|
|
160
|
+
/** Dispatches to the bulk or single by-name result shape based on the argument tuple. */
|
|
161
|
+
export type MetroFunctionSignatureOrArray<T extends any[], U extends string> =
|
|
162
|
+
T extends MetroBulkFind<U> ? MetroBulkModuleByName<T> : MetroSingleModuleByName<T>;
|
|
163
|
+
/** Options that control internal search behaviour shared across every `findBy*` helper. */
|
|
164
|
+
export type MetroInternalOptions = {
|
|
165
|
+
bulk?: boolean;
|
|
166
|
+
lazy?: boolean;
|
|
167
|
+
};
|
|
168
|
+
/** Convenience alias for a by-property result derived from a union of prop names. */
|
|
169
|
+
export type MetroModule<TProps extends string> = MetroPropertyRecordOrArray<TProps[], TProps>;
|
|
170
|
+
/** A bag carrying a `params` array of prop names. */
|
|
171
|
+
export type MetroParamsBag<T extends string> = {
|
|
172
|
+
params: T[];
|
|
173
|
+
};
|
|
174
|
+
/** A record keyed by the prop names listed in a single bulk item's `params`. */
|
|
175
|
+
export type MetroParamsRecord<Params extends PropertyKey[]> = {
|
|
176
|
+
[P in Params[number]]: any;
|
|
177
|
+
};
|
|
178
|
+
/** Dispatches to the bulk or single by-property result shape based on the argument tuple. */
|
|
179
|
+
export type MetroPropertyRecordOrArray<T extends any[], U extends string> =
|
|
180
|
+
T extends MetroBulkFind<U> ? MetroBulkModuleByProperty<T> : MetroSingleModuleByProperty<T>;
|
|
181
|
+
/** A record keyed by the non-options entries of a find argument tuple. */
|
|
182
|
+
export type MetroPropsRecord<T extends any[]> = {
|
|
183
|
+
[k in Exclude<T[number], Record<PropertyKey, any>>]: any;
|
|
184
|
+
};
|
|
185
|
+
/** Public options accepted by {@link find} and the `findBy*` family. */
|
|
186
|
+
export type MetroSearchOptions = {
|
|
187
|
+
esModules?: boolean;
|
|
188
|
+
interop?: boolean;
|
|
189
|
+
initial?: any[];
|
|
190
|
+
cache?: boolean;
|
|
191
|
+
lazy?: boolean;
|
|
192
|
+
raw?: boolean;
|
|
193
|
+
all?: boolean;
|
|
194
|
+
initialize?: boolean;
|
|
195
|
+
};
|
|
196
|
+
/** Result shape of a by-name search: the matched function (or its default export). */
|
|
197
|
+
export type MetroSingleModuleByName<T extends any[]> = T extends [
|
|
198
|
+
...any,
|
|
199
|
+
infer O extends MetroSearchOptions,
|
|
200
|
+
]
|
|
201
|
+
? MetroAllValues<
|
|
202
|
+
O,
|
|
203
|
+
O extends {
|
|
204
|
+
interop: false;
|
|
205
|
+
}
|
|
206
|
+
? {
|
|
207
|
+
default: Fn;
|
|
208
|
+
}
|
|
209
|
+
: Fn
|
|
210
|
+
>
|
|
211
|
+
: Fn;
|
|
212
|
+
/** Result shape of a by-property search: a record keyed by the requested props. */
|
|
213
|
+
export type MetroSingleModuleByProperty<T extends any[]> = T extends [
|
|
214
|
+
...any,
|
|
215
|
+
infer O extends MetroSearchOptions,
|
|
216
|
+
]
|
|
217
|
+
? MetroAllValues<O, AnyProps<MetroPropsRecord<T>>>
|
|
218
|
+
: AnyProps<MetroPropsRecord<T>>;
|
|
219
|
+
/** Tuple of search terms followed by a trailing options object. */
|
|
220
|
+
export type MetroStringFindWithOptions<T extends string, Options = MetroSearchOptions> = [
|
|
221
|
+
...T[],
|
|
222
|
+
Options,
|
|
223
|
+
];
|
|
224
|
+
export * as components from './components';
|
|
225
|
+
export * as filters from './filters';
|
|
226
|
+
export * as common from './common';
|
|
227
|
+
export * as stores from './stores';
|
|
228
|
+
export * as api from './api';
|