@unbound-app/api 2.2.0 → 3.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 +2 -2
- package/src/_conventions/addon-assets.ts +59 -0
- package/src/_conventions/addon-locales.ts +50 -0
- package/{testing → src/_conventions}/icu-parse.ts +2 -0
- package/src/_conventions/metro.ts +37 -0
- package/src/_conventions/walk-tree.ts +88 -0
- package/src/_internal.d.ts +210 -126
- package/src/builtins.d.ts +4 -2
- package/src/global.d.ts +24 -19
- package/src/marketplace.d.ts +1 -1
- package/src/metro/index.d.ts +18 -16
- package/src/native.d.ts +34 -22
- package/src/plugins.d.ts +9 -3
- package/src/storage.d.ts +7 -3
- package/src/sync.d.ts +3 -3
- package/testing/fake-feedback.ts +1 -1
- package/testing/fake-java.ts +41 -2
- package/testing/fake-locales.ts +1 -3
- package/testing/fake-metro.ts +53 -45
- package/testing/fake-native.ts +44 -30
- package/testing/fake-plugins.ts +4 -4
- package/testing/fake-react-native-modules.ts +0 -1
- package/testing/fake-utils.ts +3 -59
- package/testing/fakes.ts +8 -0
- package/testing/icu-format.ts +7 -2
- package/testing/index.ts +13 -26
- package/testing/install-addon-globals.ts +12 -2
- package/testing/plugin-files.ts +11 -3
- package/testing/preset.ts +9 -8
- package/testing/recorders.ts +17 -4
- package/testing/session.ts +2 -2
package/src/_internal.d.ts
CHANGED
|
@@ -35,8 +35,8 @@ export declare const ADDON_SCOPE_GLOBALS: readonly [
|
|
|
35
35
|
'clearInterval',
|
|
36
36
|
'commands',
|
|
37
37
|
];
|
|
38
|
-
/** The core
|
|
39
|
-
export declare const
|
|
38
|
+
/** The core Bucket; each addon's Bucket is named after the addon id. */
|
|
39
|
+
export declare const CORE_BUCKET = 'unbound';
|
|
40
40
|
/** The components of Discord's design module, each of which Unbound can stand in for when Discord drops it. */
|
|
41
41
|
export declare const DESIGN_COMPONENTS: readonly [
|
|
42
42
|
'SearchBar',
|
|
@@ -78,7 +78,7 @@ export declare const DESIGN_COMPONENTS: readonly [
|
|
|
78
78
|
'ContextMenu',
|
|
79
79
|
];
|
|
80
80
|
/** Every capability name a manifest may declare; an unknown name fails manifest validation. */
|
|
81
|
-
export declare const
|
|
81
|
+
export declare const NATIVE_BRIDGE_CAPABILITIES: readonly [
|
|
82
82
|
'native.objc.classes',
|
|
83
83
|
'native.objc.invoke',
|
|
84
84
|
'native.objc.invokeAsync',
|
|
@@ -103,8 +103,11 @@ export declare const NATIVE_PLUGIN_CAPABILITIES: readonly [
|
|
|
103
103
|
'native.debug.evaluations',
|
|
104
104
|
'native.debug.environment',
|
|
105
105
|
];
|
|
106
|
-
/**
|
|
107
|
-
|
|
106
|
+
/**
|
|
107
|
+
* The Capability each native bridge method needs; the source of every Capability name. Edit it, then run
|
|
108
|
+
* `bun run generate-native-capabilities` to regenerate the client's and the loader's Capability lists.
|
|
109
|
+
*/
|
|
110
|
+
export declare const NATIVE_BRIDGE_METHOD_CAPABILITIES: {
|
|
108
111
|
readonly 'objc.getClass': 'native.objc.classes';
|
|
109
112
|
readonly 'objc.alloc': 'native.objc.classes';
|
|
110
113
|
readonly 'objc.create': 'native.objc.invoke';
|
|
@@ -145,6 +148,7 @@ export declare const NATIVE_PLUGIN_METHOD_CAPABILITIES: {
|
|
|
145
148
|
readonly 'fabric.updateAsync': 'native.fabric.async';
|
|
146
149
|
readonly 'fabric.setSizeAsync': 'native.fabric.async';
|
|
147
150
|
readonly 'fabric.setFrameAsync': 'native.fabric.async';
|
|
151
|
+
readonly 'fabric.batchAsync': 'native.fabric.async';
|
|
148
152
|
readonly 'fabric.measureAsync': 'native.fabric.async';
|
|
149
153
|
readonly 'fabric.unmountAsync': 'native.fabric.async';
|
|
150
154
|
readonly 'fabric.releaseIdleAsync': 'native.fabric.async';
|
|
@@ -176,43 +180,44 @@ export declare const NATIVE_PLUGIN_METHOD_CAPABILITIES: {
|
|
|
176
180
|
readonly 'hooks.removeReturnValue': 'native.java.hooks';
|
|
177
181
|
readonly 'hooks.clearReturnValues': 'native.java.hooks';
|
|
178
182
|
readonly 'hooks.remove': 'native.java.hooks';
|
|
183
|
+
readonly 'hooks.proxy': 'native.java.hooks';
|
|
179
184
|
};
|
|
180
185
|
/** The host platforms a native bridge runs on. */
|
|
181
|
-
export declare const
|
|
186
|
+
export declare const NATIVE_BRIDGE_PLATFORMS: readonly ['ios', 'android'];
|
|
182
187
|
/** The capabilities each platform's loader offers; Objective-C ones are iOS only and Java ones Android only. */
|
|
183
|
-
export declare const
|
|
188
|
+
export declare const NATIVE_BRIDGE_PLATFORM_CAPABILITIES: {
|
|
189
|
+
readonly ios: readonly [
|
|
190
|
+
'native.objc.classes',
|
|
191
|
+
'native.objc.invoke',
|
|
192
|
+
'native.objc.invokeAsync',
|
|
193
|
+
'native.objc.batch',
|
|
194
|
+
'native.objc.snapshot',
|
|
195
|
+
'native.objc.ivars',
|
|
196
|
+
'native.objc.associations',
|
|
197
|
+
'native.objc.hooks',
|
|
198
|
+
'native.ffi.symbols',
|
|
199
|
+
'native.ffi.call',
|
|
200
|
+
'native.fabric.mount',
|
|
201
|
+
'native.fabric.async',
|
|
202
|
+
'native.runtime.events',
|
|
203
|
+
'native.debug.evaluations',
|
|
204
|
+
'native.debug.environment',
|
|
205
|
+
];
|
|
184
206
|
readonly android: readonly [
|
|
207
|
+
'native.ffi.symbols',
|
|
208
|
+
'native.ffi.call',
|
|
209
|
+
'native.fabric.async',
|
|
210
|
+
'native.runtime.events',
|
|
185
211
|
'native.java.classes',
|
|
186
212
|
'native.java.construct',
|
|
187
213
|
'native.java.fields',
|
|
188
214
|
'native.java.invoke',
|
|
189
|
-
'native.fabric.async',
|
|
190
|
-
'native.ffi.call',
|
|
191
|
-
'native.ffi.symbols',
|
|
192
|
-
'native.java.associations',
|
|
193
|
-
'native.java.batch',
|
|
194
|
-
'native.java.hooks',
|
|
195
215
|
'native.java.invokeAsync',
|
|
196
|
-
'native.
|
|
197
|
-
'native.
|
|
216
|
+
'native.java.hooks',
|
|
217
|
+
'native.java.batch',
|
|
218
|
+
'native.java.associations',
|
|
198
219
|
'native.debug.evaluations',
|
|
199
|
-
];
|
|
200
|
-
readonly ios: readonly [
|
|
201
|
-
'native.fabric.async',
|
|
202
|
-
'native.fabric.mount',
|
|
203
|
-
'native.ffi.call',
|
|
204
|
-
'native.ffi.symbols',
|
|
205
|
-
'native.objc.associations',
|
|
206
|
-
'native.objc.batch',
|
|
207
|
-
'native.objc.classes',
|
|
208
|
-
'native.objc.hooks',
|
|
209
|
-
'native.objc.invoke',
|
|
210
|
-
'native.objc.invokeAsync',
|
|
211
|
-
'native.objc.ivars',
|
|
212
|
-
'native.objc.snapshot',
|
|
213
220
|
'native.debug.environment',
|
|
214
|
-
'native.debug.evaluations',
|
|
215
|
-
'native.runtime.events',
|
|
216
221
|
];
|
|
217
222
|
};
|
|
218
223
|
/** The design components Discord added after the build the generated types describe; see {@link NewerDesignComponents}. */
|
|
@@ -470,8 +475,12 @@ export type AddonLogger = Record<
|
|
|
470
475
|
'log' | 'info' | 'success' | 'warn' | 'error' | 'debug',
|
|
471
476
|
(...args: unknown[]) => void
|
|
472
477
|
>;
|
|
473
|
-
/** A loaded addon's manifest: the {@link AuthoredAddonManifest} plus what the loader and installer record. */
|
|
478
|
+
/** A loaded addon's manifest: the {@link AuthoredAddonManifest} plus what `ubd build`, the loader and installer record. */
|
|
474
479
|
export type AddonManifest = AuthoredAddonManifest & {
|
|
480
|
+
/** Written by `ubd build` from the native calls in the code: the platforms the addon runs on, each with the capabilities it needs there; absent means every platform. */
|
|
481
|
+
platforms?: AddonPlatforms;
|
|
482
|
+
/** Legacy: capabilities needed on every platform, from a manifest that declares them by hand; `ubd build` writes `platforms` instead. */
|
|
483
|
+
capabilities?: NativeBridgeCapability[];
|
|
475
484
|
/** Set by the loader for an addon it read from disk: the addon's folder name. */
|
|
476
485
|
folder?: string;
|
|
477
486
|
/** Set by the loader for an addon it read from disk: the addon's absolute directory. */
|
|
@@ -480,13 +489,13 @@ export type AddonManifest = AuthoredAddonManifest & {
|
|
|
480
489
|
trust?: AddonTrust;
|
|
481
490
|
};
|
|
482
491
|
/** What an addon declares for one platform it runs on: the capabilities that platform provides which it needs. */
|
|
483
|
-
export type AddonPlatform<P extends
|
|
492
|
+
export type AddonPlatform<P extends NativeBridgePlatform = NativeBridgePlatform> = {
|
|
484
493
|
/** Capabilities needed on this platform only, added to the manifest's top-level `capabilities`. */
|
|
485
|
-
capabilities?:
|
|
494
|
+
capabilities?: NativeBridgePlatformCapability<P>[];
|
|
486
495
|
};
|
|
487
496
|
/** The platforms an addon runs on, keyed by platform. */
|
|
488
497
|
export type AddonPlatforms = {
|
|
489
|
-
[P in
|
|
498
|
+
[P in NativeBridgePlatform]?: AddonPlatform<P>;
|
|
490
499
|
};
|
|
491
500
|
/** Whether an addon's bundle carries a valid Unbound signature. */
|
|
492
501
|
export type AddonTrust = 'signed' | 'unsigned';
|
|
@@ -564,12 +573,8 @@ export type AuthoredAddonManifest = {
|
|
|
564
573
|
main: string;
|
|
565
574
|
/** The addon's version, in strict SemVer 2.0.0 with no `v` prefix. */
|
|
566
575
|
version: string;
|
|
567
|
-
/** The
|
|
568
|
-
|
|
569
|
-
/** Capabilities the addon needs on every platform it runs on. */
|
|
570
|
-
capabilities?: NativePluginCapability[];
|
|
571
|
-
/** The lowest native plugin API version the addon supports; an older native bridge fails its start. */
|
|
572
|
-
minNativePluginApi?: string;
|
|
576
|
+
/** The lowest native bridge API version the addon supports; an older native bridge fails its start. */
|
|
577
|
+
minNativeBridgeApi?: string;
|
|
573
578
|
/** The Ed25519 signature the Unbound team's publish pipeline puts on first-party plugins. */
|
|
574
579
|
signature?: {
|
|
575
580
|
version: 1;
|
|
@@ -3085,8 +3090,8 @@ export type FloatingActionButtonProps = Omit<
|
|
|
3085
3090
|
/** @default 16 */
|
|
3086
3091
|
positionRight?: number;
|
|
3087
3092
|
};
|
|
3088
|
-
/**
|
|
3089
|
-
export type
|
|
3093
|
+
/** An installed font, as `UnboundNative.fonts.list()` returns it. */
|
|
3094
|
+
export type Font = UnboundInstalledFont;
|
|
3090
3095
|
/**
|
|
3091
3096
|
* Props of `FormLabel` (function). Exports: default.
|
|
3092
3097
|
* @see design/void/Form/native/FormLabel.tsx
|
|
@@ -3401,6 +3406,15 @@ export type LayerScopeProps = {
|
|
|
3401
3406
|
children?: React$1.ReactNode;
|
|
3402
3407
|
zIndex?: number;
|
|
3403
3408
|
};
|
|
3409
|
+
/** The raw bridge the loader publishes as `globalThis.NativePlugin`; `objc` exists only on iOS, `java` and `hooks` only on Android. */
|
|
3410
|
+
export type LoaderNativeBridge = Pick<
|
|
3411
|
+
NativeBridge,
|
|
3412
|
+
'apiVersion' | 'abiVersion' | 'capabilities' | 'ffi' | 'fabric' | 'debug'
|
|
3413
|
+
> &
|
|
3414
|
+
Partial<Pick<NativeBridge, 'hooks'>> & {
|
|
3415
|
+
readonly objc?: LoaderObjCBridge;
|
|
3416
|
+
readonly java?: NativeJavaBridge & NativeUIScopeFactory;
|
|
3417
|
+
};
|
|
3404
3418
|
/** The `objc` namespace the loader publishes, before the client adds `create` and scopes it to a plugin. */
|
|
3405
3419
|
export type LoaderObjCBridge = Omit<NativeObjCBridge, 'create'> & NativeUIScopeFactory;
|
|
3406
3420
|
/**
|
|
@@ -3784,6 +3798,65 @@ export type NativeBatchStep = {
|
|
|
3784
3798
|
/** The call's arguments, at most 16; each may be an earlier step's result. */
|
|
3785
3799
|
args: unknown[];
|
|
3786
3800
|
};
|
|
3801
|
+
/** The native bridge a plugin reaches through `context.native`, gated by the capabilities it declares. */
|
|
3802
|
+
export type NativeBridge = {
|
|
3803
|
+
/** The version of the JavaScript API plugins use, compared with a manifest's `minNativeBridgeApi`. */
|
|
3804
|
+
readonly apiVersion: string;
|
|
3805
|
+
/** The version of the native ABI the loader implements. */
|
|
3806
|
+
readonly abiVersion: string;
|
|
3807
|
+
/** Every capability this loader build provides, not only the ones the plugin declares. */
|
|
3808
|
+
readonly capabilities: readonly NativeBridgeCapability[];
|
|
3809
|
+
/** The Objective-C runtime; iOS only. */
|
|
3810
|
+
readonly objc: NativeObjCBridge;
|
|
3811
|
+
/** Raw calls to C functions. */
|
|
3812
|
+
readonly ffi: NativeFFIBridge;
|
|
3813
|
+
/** React Native surfaces mounted in native views. */
|
|
3814
|
+
readonly fabric: NativeFabricBridge;
|
|
3815
|
+
/** Subscriptions to Discord activity. */
|
|
3816
|
+
readonly runtime: NativeRuntimeBridge;
|
|
3817
|
+
/** Java reflection; Android only. */
|
|
3818
|
+
readonly java: NativeJavaBridge;
|
|
3819
|
+
/** Java method hooks; Android only. */
|
|
3820
|
+
readonly hooks: NativeJavaHooksBridge;
|
|
3821
|
+
/** Debugger support. */
|
|
3822
|
+
readonly debug: NativeDebugBridge;
|
|
3823
|
+
/** Worklets on the UI runtime. */
|
|
3824
|
+
readonly ui: NativeUIBridge;
|
|
3825
|
+
};
|
|
3826
|
+
/** A named permission to use one part of the native bridge, declared in an addon's manifest. */
|
|
3827
|
+
export type NativeBridgeCapability = (typeof NATIVE_BRIDGE_METHOD_CAPABILITIES)[NativeBridgeMethod];
|
|
3828
|
+
/** The shape of an error the native bridge or its plugin scope throws. */
|
|
3829
|
+
export type NativeBridgeError = {
|
|
3830
|
+
/** Which failure it is; native failures without their own code use `NATIVE_BRIDGE_ERROR`. */
|
|
3831
|
+
code: NativeBridgeErrorCode;
|
|
3832
|
+
/** A human-readable description. */
|
|
3833
|
+
message: string;
|
|
3834
|
+
/** The capability the plugin lacks, for `NATIVE_PLUGIN_CAPABILITY_DENIED`. */
|
|
3835
|
+
capability?: NativeBridgeCapability;
|
|
3836
|
+
};
|
|
3837
|
+
/** The stable `code` on an error the native bridge or its plugin scope throws. */
|
|
3838
|
+
export type NativeBridgeErrorCode =
|
|
3839
|
+
| 'NATIVE_BRIDGE_ERROR'
|
|
3840
|
+
| 'NATIVE_PLUGIN_API_VERSION_UNSUPPORTED'
|
|
3841
|
+
| 'NATIVE_PLUGIN_CALL_CANCELLED'
|
|
3842
|
+
| 'NATIVE_PLUGIN_CALL_TIMEOUT'
|
|
3843
|
+
| 'NATIVE_PLUGIN_CAPABILITY_DENIED'
|
|
3844
|
+
| 'NATIVE_PLUGIN_SCOPE_DISPOSED'
|
|
3845
|
+
| 'NATIVE_PLUGIN_UNAVAILABLE';
|
|
3846
|
+
/** A native bridge method by the path a plugin calls it through, such as `objc.invoke`. */
|
|
3847
|
+
export type NativeBridgeMethod = {
|
|
3848
|
+
[N in NativeBridgeNamespace]: `${N}.${keyof NativeBridge[N] & string}`;
|
|
3849
|
+
}[NativeBridgeNamespace];
|
|
3850
|
+
/** A {@link NativeBridge} namespace whose methods a plugin calls, such as `objc` or `java`. */
|
|
3851
|
+
export type NativeBridgeNamespace = Exclude<
|
|
3852
|
+
keyof NativeBridge,
|
|
3853
|
+
'apiVersion' | 'abiVersion' | 'capabilities' | 'ui'
|
|
3854
|
+
>;
|
|
3855
|
+
/** A host platform the loader reports, `ios` or `android`. */
|
|
3856
|
+
export type NativeBridgePlatform = (typeof NATIVE_BRIDGE_PLATFORMS)[number];
|
|
3857
|
+
/** A capability the native bridge on platform `P` provides. */
|
|
3858
|
+
export type NativeBridgePlatformCapability<P extends NativeBridgePlatform> =
|
|
3859
|
+
(typeof NATIVE_BRIDGE_PLATFORM_CAPABILITIES)[P][number];
|
|
3787
3860
|
/** Options for a synchronous Objective-C call. */
|
|
3788
3861
|
export type NativeCallOptions = {
|
|
3789
3862
|
/** The thread to run on. Defaults to `current`. */
|
|
@@ -3898,6 +3971,20 @@ export type NativeFFITypeName =
|
|
|
3898
3971
|
| 'object'
|
|
3899
3972
|
| 'class'
|
|
3900
3973
|
| 'selector';
|
|
3974
|
+
/** One surface's changes in a `batchAsync` call, applied as properties, then size, then frame. */
|
|
3975
|
+
export type NativeFabricBatchMutation = {
|
|
3976
|
+
/** The surface these changes apply to. */
|
|
3977
|
+
surface: NativeFabricSurface;
|
|
3978
|
+
/** New properties, as `update` sends them. */
|
|
3979
|
+
properties?: NativeSerializableObject;
|
|
3980
|
+
/** The view's frame, as `setFrame` sets it. */
|
|
3981
|
+
frame?: NativeFabricFrame;
|
|
3982
|
+
/** The layout bounds, as `setSize` sets them. */
|
|
3983
|
+
size?: {
|
|
3984
|
+
minimum: NativeFabricSize;
|
|
3985
|
+
maximum: NativeFabricSize;
|
|
3986
|
+
};
|
|
3987
|
+
};
|
|
3901
3988
|
/** Mounts registered React Native components inside existing native views. Sync methods are iOS only. */
|
|
3902
3989
|
export type NativeFabricBridge = {
|
|
3903
3990
|
/** Starts a surface for a registered component inside a container view. Needs `native.fabric.mount`. */
|
|
@@ -3940,6 +4027,8 @@ export type NativeFabricBridge = {
|
|
|
3940
4027
|
surface: NativeFabricSurface,
|
|
3941
4028
|
frame: NativeFabricFrame,
|
|
3942
4029
|
): NativeCancelablePromise<void>;
|
|
4030
|
+
/** Applies every mutation in order on the main thread's next display frame, skipping stopped surfaces. Needs `native.fabric.async`. */
|
|
4031
|
+
batchAsync(mutations: NativeFabricBatchMutation[]): NativeCancelablePromise<void>;
|
|
3943
4032
|
/** Reads a view's frame. */
|
|
3944
4033
|
measure(view: NativeObjectHandle): NativeFabricFrame;
|
|
3945
4034
|
/** Like `measure`, on the main thread. */
|
|
@@ -4213,9 +4302,16 @@ export type NativeJavaHookOptions<Receiver extends boolean = boolean> = {
|
|
|
4213
4302
|
replace?: boolean;
|
|
4214
4303
|
/** Whether the listener hears calls: before the method by default, `after` once it has run, `false` never. */
|
|
4215
4304
|
notify?: boolean | 'after';
|
|
4305
|
+
/** Lets a `before` listener hooked from a UI scope return `{ arguments }` to run the method with them instead. */
|
|
4306
|
+
rewriteArguments?: boolean;
|
|
4216
4307
|
/** Trims the receiver, arguments and phase each event sends, to cut crossing cost on hot methods. */
|
|
4217
4308
|
payload?: NativeHookPayload<Receiver>;
|
|
4218
4309
|
};
|
|
4310
|
+
/** What a `rewriteArguments` listener returns to run the hooked method with other arguments, one per parameter. */
|
|
4311
|
+
export type NativeJavaHookRewrite = {
|
|
4312
|
+
/** The arguments to run the method with, in parameter order. */
|
|
4313
|
+
arguments: NativeJavaArgument[];
|
|
4314
|
+
};
|
|
4219
4315
|
/** An installed Java hook; the plugin scope removes it on dispose. */
|
|
4220
4316
|
export type NativeJavaHookToken = {
|
|
4221
4317
|
/** The id the loader issued, such as `hook-1`. */
|
|
@@ -4229,7 +4325,7 @@ export type NativeJavaHooksBridge = {
|
|
|
4229
4325
|
methodName: string,
|
|
4230
4326
|
parameterTypes: string[],
|
|
4231
4327
|
options?: NativeJavaHookOptions<Receiver>,
|
|
4232
|
-
listener?: (event: NativeJavaHookEvent<Receiver>) => void,
|
|
4328
|
+
listener?: (event: NativeJavaHookEvent<Receiver>) => NativeJavaHookRewrite | void,
|
|
4233
4329
|
): NativeJavaHookToken;
|
|
4234
4330
|
/** Sets the result a `replace` hook returns for calls with this receiver and these arguments. */
|
|
4235
4331
|
setReturnValue(
|
|
@@ -4246,8 +4342,16 @@ export type NativeJavaHooksBridge = {
|
|
|
4246
4342
|
): void;
|
|
4247
4343
|
/** Removes every result set on a hook. */
|
|
4248
4344
|
clearReturnValues(token: NativeJavaHookToken): void;
|
|
4249
|
-
/** Removes a hook. */
|
|
4345
|
+
/** Removes a hook or a proxy. */
|
|
4250
4346
|
remove(token: NativeJavaHookToken): void;
|
|
4347
|
+
/**
|
|
4348
|
+
* Creates a Java object implementing `interfaces`, from a UI scope only. Calls on the main thread run `handler`
|
|
4349
|
+
* inline and return its value; calls on other threads reach it later and return the type's default.
|
|
4350
|
+
*/
|
|
4351
|
+
proxy(
|
|
4352
|
+
interfaces: string[],
|
|
4353
|
+
handler: (call: NativeJavaProxyCall) => NativeJavaArgument | void,
|
|
4354
|
+
): NativeJavaProxy;
|
|
4251
4355
|
};
|
|
4252
4356
|
/** One method a Java class declares, from `java.describe`. */
|
|
4253
4357
|
export type NativeJavaMethodDescription = {
|
|
@@ -4260,6 +4364,20 @@ export type NativeJavaMethodDescription = {
|
|
|
4260
4364
|
/** Whether the method is static. */
|
|
4261
4365
|
static: boolean;
|
|
4262
4366
|
};
|
|
4367
|
+
/** A Java object implementing interfaces through a handler; remove its token to stop it answering. */
|
|
4368
|
+
export type NativeJavaProxy = {
|
|
4369
|
+
/** Removes the proxy with `hooks.remove`; the UI scope removes it on dispose. */
|
|
4370
|
+
token: NativeJavaHookToken;
|
|
4371
|
+
/** The object to pass wherever Java expects one of the interfaces. */
|
|
4372
|
+
object: NativeJavaHandle;
|
|
4373
|
+
};
|
|
4374
|
+
/** What a proxy handler receives for one call of an interface method. */
|
|
4375
|
+
export type NativeJavaProxyCall = {
|
|
4376
|
+
/** The interface method's name, such as `onPreDraw`. */
|
|
4377
|
+
method: string;
|
|
4378
|
+
/** The call's arguments. */
|
|
4379
|
+
args: NativeJavaValue[];
|
|
4380
|
+
};
|
|
4263
4381
|
/** A Java object, as a handle or as a tagged handle value from a result. */
|
|
4264
4382
|
export type NativeJavaReference = NativeJavaHandle | NativeJavaHandleValue;
|
|
4265
4383
|
/** A Java value tagged with its type, as the Java bridge returns and accepts it. */
|
|
@@ -4489,6 +4607,8 @@ export type NativePlatformAndroidInstaller = {
|
|
|
4489
4607
|
export type NativePlatformApp = {
|
|
4490
4608
|
/** Where Discord was installed from, such as `App Store` or `Google Play`. */
|
|
4491
4609
|
getAppSource(): string;
|
|
4610
|
+
/** How an iOS install was signed: certificate kind, team, profile expiry, sideload tool marker and entitlement source. */
|
|
4611
|
+
getInstallDetails?(): string;
|
|
4492
4612
|
/** The framework that injected the loader, such as Vector or LSPosed on Android and ElleKit on iOS, or an empty string. */
|
|
4493
4613
|
getFramework(): string;
|
|
4494
4614
|
/** Whether the loader's embedded attestation verified against Unbound's pinned key. False for development builds. */
|
|
@@ -4499,7 +4619,7 @@ export type NativePlatformApp = {
|
|
|
4499
4619
|
/** Platform-wide helpers the loader publishes as `globalThis.NativePlatform`, not scoped to a plugin. */
|
|
4500
4620
|
export type NativePlatformBridge = {
|
|
4501
4621
|
/** The host platform. */
|
|
4502
|
-
readonly platform:
|
|
4622
|
+
readonly platform: NativeBridgePlatform;
|
|
4503
4623
|
/** Evaluates Hermes bytecode in the current runtime; `tag` names it in errors. Throws on invalid bytecode. */
|
|
4504
4624
|
evaluateBytecode(bytecode: ArrayBuffer, tag?: string): unknown;
|
|
4505
4625
|
/** Facts about the device. */
|
|
@@ -4539,7 +4659,7 @@ export type NativePlatformCrashGuard = {
|
|
|
4539
4659
|
/** Facts about the device Discord runs on. */
|
|
4540
4660
|
export type NativePlatformDevice = {
|
|
4541
4661
|
/** The host platform. */
|
|
4542
|
-
readonly platform:
|
|
4662
|
+
readonly platform: NativeBridgePlatform;
|
|
4543
4663
|
/** The device's model name. */
|
|
4544
4664
|
getDeviceModel(): string;
|
|
4545
4665
|
/** The operating system's version. */
|
|
@@ -4592,74 +4712,6 @@ export type NativePlatformSettings = {
|
|
|
4592
4712
|
/** Reads every Bucket with no arguments, one Bucket with `store`, or one dot-path `key`; `undefined` when unset. */
|
|
4593
4713
|
get(store?: string, key?: string): NativeSerializable | undefined;
|
|
4594
4714
|
};
|
|
4595
|
-
/** The native bridge a plugin reaches through `context.native`, gated by the capabilities it declares. */
|
|
4596
|
-
export type NativePluginBridge = {
|
|
4597
|
-
/** The version of the JavaScript API plugins use, compared with a manifest's `minNativePluginApi`. */
|
|
4598
|
-
readonly apiVersion: string;
|
|
4599
|
-
/** The version of the native ABI the loader implements. */
|
|
4600
|
-
readonly abiVersion: string;
|
|
4601
|
-
/** Every capability this loader build provides, not only the ones the plugin declares. */
|
|
4602
|
-
readonly capabilities: readonly NativePluginCapability[];
|
|
4603
|
-
/** The Objective-C runtime; iOS only. */
|
|
4604
|
-
readonly objc: NativeObjCBridge;
|
|
4605
|
-
/** Raw calls to C functions. */
|
|
4606
|
-
readonly ffi: NativeFFIBridge;
|
|
4607
|
-
/** React Native surfaces mounted in native views. */
|
|
4608
|
-
readonly fabric: NativeFabricBridge;
|
|
4609
|
-
/** Subscriptions to Discord activity. */
|
|
4610
|
-
readonly runtime: NativeRuntimeBridge;
|
|
4611
|
-
/** Java reflection; Android only. */
|
|
4612
|
-
readonly java: NativeJavaBridge;
|
|
4613
|
-
/** Java method hooks; Android only. */
|
|
4614
|
-
readonly hooks: NativeJavaHooksBridge;
|
|
4615
|
-
/** Debugger support. */
|
|
4616
|
-
readonly debug: NativeDebugBridge;
|
|
4617
|
-
/** Worklets on the UI runtime. */
|
|
4618
|
-
readonly ui: NativeUIBridge;
|
|
4619
|
-
};
|
|
4620
|
-
/** A named permission to use one part of the native bridge, declared in an addon's manifest. */
|
|
4621
|
-
export type NativePluginCapability = (typeof NATIVE_PLUGIN_CAPABILITIES)[number];
|
|
4622
|
-
/** The shape of an error the native bridge or its plugin scope throws. */
|
|
4623
|
-
export type NativePluginError = {
|
|
4624
|
-
/** Which failure it is; native failures without their own code use `NATIVE_BRIDGE_ERROR`. */
|
|
4625
|
-
code: NativePluginErrorCode;
|
|
4626
|
-
/** A human-readable description. */
|
|
4627
|
-
message: string;
|
|
4628
|
-
/** The capability the plugin lacks, for `NATIVE_PLUGIN_CAPABILITY_DENIED`. */
|
|
4629
|
-
capability?: NativePluginCapability;
|
|
4630
|
-
};
|
|
4631
|
-
/** The stable `code` on an error the native bridge or its plugin scope throws. */
|
|
4632
|
-
export type NativePluginErrorCode =
|
|
4633
|
-
| 'NATIVE_BRIDGE_ERROR'
|
|
4634
|
-
| 'NATIVE_PLUGIN_API_VERSION_UNSUPPORTED'
|
|
4635
|
-
| 'NATIVE_PLUGIN_CALL_CANCELLED'
|
|
4636
|
-
| 'NATIVE_PLUGIN_CALL_TIMEOUT'
|
|
4637
|
-
| 'NATIVE_PLUGIN_CAPABILITY_DENIED'
|
|
4638
|
-
| 'NATIVE_PLUGIN_SCOPE_DISPOSED'
|
|
4639
|
-
| 'NATIVE_PLUGIN_UNAVAILABLE';
|
|
4640
|
-
/** A native bridge method by the path a plugin calls it through, such as `objc.invoke`. */
|
|
4641
|
-
export type NativePluginMethod = {
|
|
4642
|
-
[N in NativePluginNamespace]: `${N}.${keyof NativePluginBridge[N] & string}`;
|
|
4643
|
-
}[NativePluginNamespace];
|
|
4644
|
-
/** A {@link NativePluginBridge} namespace whose methods a plugin calls, such as `objc` or `java`. */
|
|
4645
|
-
export type NativePluginNamespace = Exclude<
|
|
4646
|
-
keyof NativePluginBridge,
|
|
4647
|
-
'apiVersion' | 'abiVersion' | 'capabilities' | 'ui'
|
|
4648
|
-
>;
|
|
4649
|
-
/** A host platform the loader reports, `ios` or `android`. */
|
|
4650
|
-
export type NativePluginPlatform = (typeof NATIVE_PLUGIN_PLATFORMS)[number];
|
|
4651
|
-
/** A capability the native bridge on platform `P` provides. */
|
|
4652
|
-
export type NativePluginPlatformCapability<P extends NativePluginPlatform> =
|
|
4653
|
-
(typeof NATIVE_PLUGIN_PLATFORM_CAPABILITIES)[P][number];
|
|
4654
|
-
/** The raw bridge the loader publishes as `globalThis.NativePlugin`; `objc` exists only on iOS, `java` and `hooks` only on Android. */
|
|
4655
|
-
export type NativePluginRuntimeBridge = Pick<
|
|
4656
|
-
NativePluginBridge,
|
|
4657
|
-
'apiVersion' | 'abiVersion' | 'capabilities' | 'ffi' | 'fabric' | 'debug'
|
|
4658
|
-
> &
|
|
4659
|
-
Partial<Pick<NativePluginBridge, 'hooks'>> & {
|
|
4660
|
-
readonly objc?: LoaderObjCBridge;
|
|
4661
|
-
readonly java?: NativeJavaBridge & NativeUIScopeFactory;
|
|
4662
|
-
};
|
|
4663
4715
|
/** A handle to a native symbol's address, from `ffi.symbol`; `ffi.call` accepts only these. */
|
|
4664
4716
|
export type NativePointer = NativeHandle;
|
|
4665
4717
|
/** How many native resources the loader holds across every plugin. */
|
|
@@ -5148,21 +5200,34 @@ export type PluginContext = {
|
|
|
5148
5200
|
/** The plugin's id, from its manifest. */
|
|
5149
5201
|
readonly id: string;
|
|
5150
5202
|
/** The host platform, or `undefined` when the loader reports none. */
|
|
5151
|
-
readonly platform?:
|
|
5203
|
+
readonly platform?: NativeBridgePlatform;
|
|
5152
5204
|
/** The capabilities the manifest declares for this platform; `native` allows only these. */
|
|
5153
|
-
readonly capabilities: readonly
|
|
5205
|
+
readonly capabilities: readonly NativeBridgeCapability[];
|
|
5154
5206
|
/** The native bridge, scoped to the plugin's capabilities. */
|
|
5155
|
-
readonly native:
|
|
5207
|
+
readonly native: NativeBridge;
|
|
5156
5208
|
/** Releases the plugin's hooks, surfaces, handles and subscriptions; the addon manager calls it on stop, unload, reload or a failed start. */
|
|
5157
5209
|
dispose(): void;
|
|
5158
5210
|
};
|
|
5159
5211
|
/** What a plugin's self-test found: whether the plugin works on this device, and why. */
|
|
5160
|
-
export type PluginSelfTestResult =
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5212
|
+
export type PluginSelfTestResult =
|
|
5213
|
+
| {
|
|
5214
|
+
/** The plugin works on this device. */
|
|
5215
|
+
ok: true;
|
|
5216
|
+
/** A human-readable reason for the result. */
|
|
5217
|
+
detail: string;
|
|
5218
|
+
/** Set when the plugin works but has nothing on screen to draw, which says where the chat is rather than that drawing is wrong. */
|
|
5219
|
+
nothingDrawn?: boolean;
|
|
5220
|
+
/** Set while the plugin is still drawing what is on screen, so the device matrix waits before timing or judging it. */
|
|
5221
|
+
settling?: boolean;
|
|
5222
|
+
}
|
|
5223
|
+
| {
|
|
5224
|
+
/** The plugin does not work on this device. */
|
|
5225
|
+
ok: false;
|
|
5226
|
+
/** A human-readable reason for the result. */
|
|
5227
|
+
detail: string;
|
|
5228
|
+
/** Set when the plugin failed only because it has nothing on screen to draw. */
|
|
5229
|
+
nothingDrawn?: boolean;
|
|
5230
|
+
};
|
|
5166
5231
|
/**
|
|
5167
5232
|
* Props of `PostponeRender` (function). Exports: PostponeRender.
|
|
5168
5233
|
* @see design/components/Navigator/native/PostponeRender.native.tsx
|
|
@@ -5531,7 +5596,7 @@ export type SettingsGroupSchema = SettingCommon & {
|
|
|
5531
5596
|
displayAs: 'group' | 'collapsible';
|
|
5532
5597
|
properties: Record<string, SettingSchema | StorelessSchema>;
|
|
5533
5598
|
};
|
|
5534
|
-
/** A
|
|
5599
|
+
/** A Bucket, or a nested group of settings within one. */
|
|
5535
5600
|
export type SettingsObject = {
|
|
5536
5601
|
[key: string]: SettingsValue;
|
|
5537
5602
|
};
|
|
@@ -5551,7 +5616,7 @@ export type SettingsScreen = {
|
|
|
5551
5616
|
/** Discord's navigator renders the screen with its own route props, so any component fits. */
|
|
5552
5617
|
getComponent: () => React$1.ComponentType<never>;
|
|
5553
5618
|
};
|
|
5554
|
-
/** A JSON value held in a
|
|
5619
|
+
/** A JSON value held in a Bucket. */
|
|
5555
5620
|
export type SettingsValue = string | number | boolean | null | SettingsValue[] | SettingsObject;
|
|
5556
5621
|
export type SheetBottomSheetComponent = React$1.ComponentType<
|
|
5557
5622
|
SheetBottomSheetProps & Record<string, unknown>
|
|
@@ -6483,6 +6548,21 @@ export type UnboundAsset = DiscordAsset & {
|
|
|
6483
6548
|
/** The URI of a registered plugin asset at each scale; set while it is registered. */
|
|
6484
6549
|
unboundSources?: Record<number, string>;
|
|
6485
6550
|
};
|
|
6551
|
+
/** One design axis of a variable font, such as `wght` from 100 to 900. */
|
|
6552
|
+
export type UnboundFontAxis = {
|
|
6553
|
+
/** The four-letter tag, such as `wght`, `wdth` or `slnt`. */
|
|
6554
|
+
tag: string;
|
|
6555
|
+
/** The name the font gives it, such as `Weight`. */
|
|
6556
|
+
name: string;
|
|
6557
|
+
/** The lowest value the axis accepts. */
|
|
6558
|
+
min: number;
|
|
6559
|
+
/** The value a face draws at when the axis is not set. */
|
|
6560
|
+
default: number;
|
|
6561
|
+
/** The highest value the axis accepts. */
|
|
6562
|
+
max: number;
|
|
6563
|
+
/** The font asks apps not to offer it. */
|
|
6564
|
+
hidden: boolean;
|
|
6565
|
+
};
|
|
6486
6566
|
/**
|
|
6487
6567
|
* One installed face in the loader's font store.
|
|
6488
6568
|
* @internal
|
|
@@ -6500,6 +6580,10 @@ type UnboundInstalledFont = {
|
|
|
6500
6580
|
/** The file's absolute path; `list()` adds it. */
|
|
6501
6581
|
path?: string;
|
|
6502
6582
|
source: UnboundFontSource;
|
|
6583
|
+
/** A variable font's design axes; absent for a static face. */
|
|
6584
|
+
axes?: UnboundFontAxis[];
|
|
6585
|
+
/** The coordinate on each axis this face draws at, such as `{ wght: 650 }`; absent for a static face. */
|
|
6586
|
+
variations?: Record<string, number>;
|
|
6503
6587
|
};
|
|
6504
6588
|
/** A value the generator could not type with confidence, so a loose prop accepts anything for it. */
|
|
6505
6589
|
export type UncertainValue = any;
|
package/src/builtins.d.ts
CHANGED
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
export declare const register: (name: string, builtin: BuiltIn) => void;
|
|
5
5
|
/** Stops the built-in feature registered under a name. */
|
|
6
6
|
export declare const unregister: (name: string) => void;
|
|
7
|
-
/** A built-in feature exposing optional `start`/`stop` lifecycle hooks. */
|
|
7
|
+
/** A built-in feature exposing optional `start`/`afterAddons`/`stop` lifecycle hooks. */
|
|
8
8
|
export type BuiltIn = {
|
|
9
|
-
/** Runs when the built-in is registered; if it throws, the built-in is logged and left inactive. */
|
|
9
|
+
/** Runs when the built-in is registered, before the addon managers load; if it throws, the built-in is logged and left inactive. */
|
|
10
10
|
start?: () => void;
|
|
11
|
+
/** Runs once the addon managers have loaded their addons, for work that reads them. */
|
|
12
|
+
afterAddons?: () => void;
|
|
11
13
|
/** Runs when the built-in is unregistered or the built-ins shut down, in reverse start order. */
|
|
12
14
|
stop?: () => void;
|
|
13
15
|
/** Checked once at initialisation; returning `false` skips registering the built-in. */
|
package/src/global.d.ts
CHANGED
|
@@ -90,7 +90,7 @@ export type {
|
|
|
90
90
|
ButtonPillProps,
|
|
91
91
|
ButtonSchema,
|
|
92
92
|
ButtonShineProps,
|
|
93
|
-
|
|
93
|
+
CORE_BUCKET,
|
|
94
94
|
Callback,
|
|
95
95
|
CameraLottieComponent,
|
|
96
96
|
CameraLottieProps,
|
|
@@ -145,7 +145,7 @@ export type {
|
|
|
145
145
|
FauxHeaderProps,
|
|
146
146
|
FloatingActionButtonComponent,
|
|
147
147
|
FloatingActionButtonProps,
|
|
148
|
-
|
|
148
|
+
Font,
|
|
149
149
|
FormLabelProps,
|
|
150
150
|
FormRowProps,
|
|
151
151
|
FormSubLabelProps,
|
|
@@ -181,6 +181,7 @@ export type {
|
|
|
181
181
|
InternalToastOptions,
|
|
182
182
|
LayerScopeComponent,
|
|
183
183
|
LayerScopeProps,
|
|
184
|
+
LoaderNativeBridge,
|
|
184
185
|
LoaderObjCBridge,
|
|
185
186
|
LoadingButtonPillProps,
|
|
186
187
|
LooseComponent,
|
|
@@ -228,10 +229,10 @@ export type {
|
|
|
228
229
|
ModalScreenProps,
|
|
229
230
|
ModalStepIndicatorComponent,
|
|
230
231
|
ModalStepIndicatorProps,
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
232
|
+
NATIVE_BRIDGE_CAPABILITIES,
|
|
233
|
+
NATIVE_BRIDGE_METHOD_CAPABILITIES,
|
|
234
|
+
NATIVE_BRIDGE_PLATFORMS,
|
|
235
|
+
NATIVE_BRIDGE_PLATFORM_CAPABILITIES,
|
|
235
236
|
NEWER_DESIGN_COMPONENTS,
|
|
236
237
|
NativeAddonVerification,
|
|
237
238
|
NativeAndroidInstallPhase,
|
|
@@ -242,6 +243,14 @@ export type {
|
|
|
242
243
|
NativeAssociationKey,
|
|
243
244
|
NativeBatchReference,
|
|
244
245
|
NativeBatchStep,
|
|
246
|
+
NativeBridge,
|
|
247
|
+
NativeBridgeCapability,
|
|
248
|
+
NativeBridgeError,
|
|
249
|
+
NativeBridgeErrorCode,
|
|
250
|
+
NativeBridgeMethod,
|
|
251
|
+
NativeBridgeNamespace,
|
|
252
|
+
NativeBridgePlatform,
|
|
253
|
+
NativeBridgePlatformCapability,
|
|
245
254
|
NativeCallOptions,
|
|
246
255
|
NativeCancelablePromise,
|
|
247
256
|
NativeClassHandle,
|
|
@@ -257,6 +266,7 @@ export type {
|
|
|
257
266
|
NativeFFISignature,
|
|
258
267
|
NativeFFIType,
|
|
259
268
|
NativeFFITypeName,
|
|
269
|
+
NativeFabricBatchMutation,
|
|
260
270
|
NativeFabricBridge,
|
|
261
271
|
NativeFabricFrame,
|
|
262
272
|
NativeFabricMountOptions,
|
|
@@ -282,9 +292,12 @@ export type {
|
|
|
282
292
|
NativeJavaHandleValue,
|
|
283
293
|
NativeJavaHookEvent,
|
|
284
294
|
NativeJavaHookOptions,
|
|
295
|
+
NativeJavaHookRewrite,
|
|
285
296
|
NativeJavaHookToken,
|
|
286
297
|
NativeJavaHooksBridge,
|
|
287
298
|
NativeJavaMethodDescription,
|
|
299
|
+
NativeJavaProxy,
|
|
300
|
+
NativeJavaProxyCall,
|
|
288
301
|
NativeJavaReference,
|
|
289
302
|
NativeJavaValue,
|
|
290
303
|
NativeMainWaitCounts,
|
|
@@ -305,15 +318,6 @@ export type {
|
|
|
305
318
|
NativePlatformIOSBridge,
|
|
306
319
|
NativePlatformProfiler,
|
|
307
320
|
NativePlatformSettings,
|
|
308
|
-
NativePluginBridge,
|
|
309
|
-
NativePluginCapability,
|
|
310
|
-
NativePluginError,
|
|
311
|
-
NativePluginErrorCode,
|
|
312
|
-
NativePluginMethod,
|
|
313
|
-
NativePluginNamespace,
|
|
314
|
-
NativePluginPlatform,
|
|
315
|
-
NativePluginPlatformCapability,
|
|
316
|
-
NativePluginRuntimeBridge,
|
|
317
321
|
NativePointer,
|
|
318
322
|
NativeResourceCounts,
|
|
319
323
|
NativeRuntimeBridge,
|
|
@@ -512,6 +516,7 @@ export type {
|
|
|
512
516
|
TransitionState,
|
|
513
517
|
UnboundAppIcon,
|
|
514
518
|
UnboundAsset,
|
|
519
|
+
UnboundFontAxis,
|
|
515
520
|
UncertainValue,
|
|
516
521
|
VisualEffectViewProps,
|
|
517
522
|
VoidIconProps,
|
|
@@ -563,13 +568,13 @@ export type AddonScope = {
|
|
|
563
568
|
/** The lifecycle entry points, all the global `unbound` object keeps after {@link shutdown}. */
|
|
564
569
|
export interface UnboundLifecycle {
|
|
565
570
|
/**
|
|
566
|
-
* @description Brings up the client,
|
|
567
|
-
* {@link shutdown}.
|
|
571
|
+
* @description Brings up the client: registers the addon managers, starts the built-ins, loads each kind's addons,
|
|
572
|
+
* then runs the built-ins' `afterAddons` hooks. Twin of {@link shutdown}.
|
|
568
573
|
*/
|
|
569
574
|
initialize(): void;
|
|
570
575
|
/**
|
|
571
|
-
* @description Tears the client back down
|
|
572
|
-
*
|
|
576
|
+
* @description Tears the client back down: stops the built-ins, shuts down each kind's manager, persists settings,
|
|
577
|
+
* unregisters the managers and clears the global down to the lifecycle entry points. Twin of {@link initialize}.
|
|
573
578
|
* @returns A promise that resolves once settings have been persisted and shutdown is complete.
|
|
574
579
|
*/
|
|
575
580
|
shutdown(): Promise<void>;
|