@unbound-app/api 2.2.0 → 3.0.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 +157 -124
- package/src/builtins.d.ts +4 -2
- package/src/global.d.ts +20 -19
- package/src/marketplace.d.ts +1 -1
- package/src/metro/index.d.ts +18 -16
- package/src/native.d.ts +31 -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-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';
|
|
@@ -178,41 +182,41 @@ export declare const NATIVE_PLUGIN_METHOD_CAPABILITIES: {
|
|
|
178
182
|
readonly 'hooks.remove': 'native.java.hooks';
|
|
179
183
|
};
|
|
180
184
|
/** The host platforms a native bridge runs on. */
|
|
181
|
-
export declare const
|
|
185
|
+
export declare const NATIVE_BRIDGE_PLATFORMS: readonly ['ios', 'android'];
|
|
182
186
|
/** The capabilities each platform's loader offers; Objective-C ones are iOS only and Java ones Android only. */
|
|
183
|
-
export declare const
|
|
187
|
+
export declare const NATIVE_BRIDGE_PLATFORM_CAPABILITIES: {
|
|
188
|
+
readonly ios: readonly [
|
|
189
|
+
'native.objc.classes',
|
|
190
|
+
'native.objc.invoke',
|
|
191
|
+
'native.objc.invokeAsync',
|
|
192
|
+
'native.objc.batch',
|
|
193
|
+
'native.objc.snapshot',
|
|
194
|
+
'native.objc.ivars',
|
|
195
|
+
'native.objc.associations',
|
|
196
|
+
'native.objc.hooks',
|
|
197
|
+
'native.ffi.symbols',
|
|
198
|
+
'native.ffi.call',
|
|
199
|
+
'native.fabric.mount',
|
|
200
|
+
'native.fabric.async',
|
|
201
|
+
'native.runtime.events',
|
|
202
|
+
'native.debug.evaluations',
|
|
203
|
+
'native.debug.environment',
|
|
204
|
+
];
|
|
184
205
|
readonly android: readonly [
|
|
206
|
+
'native.ffi.symbols',
|
|
207
|
+
'native.ffi.call',
|
|
208
|
+
'native.fabric.async',
|
|
209
|
+
'native.runtime.events',
|
|
185
210
|
'native.java.classes',
|
|
186
211
|
'native.java.construct',
|
|
187
212
|
'native.java.fields',
|
|
188
213
|
'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
214
|
'native.java.invokeAsync',
|
|
196
|
-
'native.
|
|
197
|
-
'native.
|
|
215
|
+
'native.java.hooks',
|
|
216
|
+
'native.java.batch',
|
|
217
|
+
'native.java.associations',
|
|
198
218
|
'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
219
|
'native.debug.environment',
|
|
214
|
-
'native.debug.evaluations',
|
|
215
|
-
'native.runtime.events',
|
|
216
220
|
];
|
|
217
221
|
};
|
|
218
222
|
/** The design components Discord added after the build the generated types describe; see {@link NewerDesignComponents}. */
|
|
@@ -470,8 +474,12 @@ export type AddonLogger = Record<
|
|
|
470
474
|
'log' | 'info' | 'success' | 'warn' | 'error' | 'debug',
|
|
471
475
|
(...args: unknown[]) => void
|
|
472
476
|
>;
|
|
473
|
-
/** A loaded addon's manifest: the {@link AuthoredAddonManifest} plus what the loader and installer record. */
|
|
477
|
+
/** A loaded addon's manifest: the {@link AuthoredAddonManifest} plus what `ubd build`, the loader and installer record. */
|
|
474
478
|
export type AddonManifest = AuthoredAddonManifest & {
|
|
479
|
+
/** 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. */
|
|
480
|
+
platforms?: AddonPlatforms;
|
|
481
|
+
/** Legacy: capabilities needed on every platform, from a manifest that declares them by hand; `ubd build` writes `platforms` instead. */
|
|
482
|
+
capabilities?: NativeBridgeCapability[];
|
|
475
483
|
/** Set by the loader for an addon it read from disk: the addon's folder name. */
|
|
476
484
|
folder?: string;
|
|
477
485
|
/** Set by the loader for an addon it read from disk: the addon's absolute directory. */
|
|
@@ -480,13 +488,13 @@ export type AddonManifest = AuthoredAddonManifest & {
|
|
|
480
488
|
trust?: AddonTrust;
|
|
481
489
|
};
|
|
482
490
|
/** What an addon declares for one platform it runs on: the capabilities that platform provides which it needs. */
|
|
483
|
-
export type AddonPlatform<P extends
|
|
491
|
+
export type AddonPlatform<P extends NativeBridgePlatform = NativeBridgePlatform> = {
|
|
484
492
|
/** Capabilities needed on this platform only, added to the manifest's top-level `capabilities`. */
|
|
485
|
-
capabilities?:
|
|
493
|
+
capabilities?: NativeBridgePlatformCapability<P>[];
|
|
486
494
|
};
|
|
487
495
|
/** The platforms an addon runs on, keyed by platform. */
|
|
488
496
|
export type AddonPlatforms = {
|
|
489
|
-
[P in
|
|
497
|
+
[P in NativeBridgePlatform]?: AddonPlatform<P>;
|
|
490
498
|
};
|
|
491
499
|
/** Whether an addon's bundle carries a valid Unbound signature. */
|
|
492
500
|
export type AddonTrust = 'signed' | 'unsigned';
|
|
@@ -564,12 +572,8 @@ export type AuthoredAddonManifest = {
|
|
|
564
572
|
main: string;
|
|
565
573
|
/** The addon's version, in strict SemVer 2.0.0 with no `v` prefix. */
|
|
566
574
|
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;
|
|
575
|
+
/** The lowest native bridge API version the addon supports; an older native bridge fails its start. */
|
|
576
|
+
minNativeBridgeApi?: string;
|
|
573
577
|
/** The Ed25519 signature the Unbound team's publish pipeline puts on first-party plugins. */
|
|
574
578
|
signature?: {
|
|
575
579
|
version: 1;
|
|
@@ -3085,8 +3089,8 @@ export type FloatingActionButtonProps = Omit<
|
|
|
3085
3089
|
/** @default 16 */
|
|
3086
3090
|
positionRight?: number;
|
|
3087
3091
|
};
|
|
3088
|
-
/**
|
|
3089
|
-
export type
|
|
3092
|
+
/** An installed font, as `UnboundNative.fonts.list()` returns it. */
|
|
3093
|
+
export type Font = UnboundInstalledFont;
|
|
3090
3094
|
/**
|
|
3091
3095
|
* Props of `FormLabel` (function). Exports: default.
|
|
3092
3096
|
* @see design/void/Form/native/FormLabel.tsx
|
|
@@ -3401,6 +3405,15 @@ export type LayerScopeProps = {
|
|
|
3401
3405
|
children?: React$1.ReactNode;
|
|
3402
3406
|
zIndex?: number;
|
|
3403
3407
|
};
|
|
3408
|
+
/** The raw bridge the loader publishes as `globalThis.NativePlugin`; `objc` exists only on iOS, `java` and `hooks` only on Android. */
|
|
3409
|
+
export type LoaderNativeBridge = Pick<
|
|
3410
|
+
NativeBridge,
|
|
3411
|
+
'apiVersion' | 'abiVersion' | 'capabilities' | 'ffi' | 'fabric' | 'debug'
|
|
3412
|
+
> &
|
|
3413
|
+
Partial<Pick<NativeBridge, 'hooks'>> & {
|
|
3414
|
+
readonly objc?: LoaderObjCBridge;
|
|
3415
|
+
readonly java?: NativeJavaBridge & NativeUIScopeFactory;
|
|
3416
|
+
};
|
|
3404
3417
|
/** The `objc` namespace the loader publishes, before the client adds `create` and scopes it to a plugin. */
|
|
3405
3418
|
export type LoaderObjCBridge = Omit<NativeObjCBridge, 'create'> & NativeUIScopeFactory;
|
|
3406
3419
|
/**
|
|
@@ -3784,6 +3797,65 @@ export type NativeBatchStep = {
|
|
|
3784
3797
|
/** The call's arguments, at most 16; each may be an earlier step's result. */
|
|
3785
3798
|
args: unknown[];
|
|
3786
3799
|
};
|
|
3800
|
+
/** The native bridge a plugin reaches through `context.native`, gated by the capabilities it declares. */
|
|
3801
|
+
export type NativeBridge = {
|
|
3802
|
+
/** The version of the JavaScript API plugins use, compared with a manifest's `minNativeBridgeApi`. */
|
|
3803
|
+
readonly apiVersion: string;
|
|
3804
|
+
/** The version of the native ABI the loader implements. */
|
|
3805
|
+
readonly abiVersion: string;
|
|
3806
|
+
/** Every capability this loader build provides, not only the ones the plugin declares. */
|
|
3807
|
+
readonly capabilities: readonly NativeBridgeCapability[];
|
|
3808
|
+
/** The Objective-C runtime; iOS only. */
|
|
3809
|
+
readonly objc: NativeObjCBridge;
|
|
3810
|
+
/** Raw calls to C functions. */
|
|
3811
|
+
readonly ffi: NativeFFIBridge;
|
|
3812
|
+
/** React Native surfaces mounted in native views. */
|
|
3813
|
+
readonly fabric: NativeFabricBridge;
|
|
3814
|
+
/** Subscriptions to Discord activity. */
|
|
3815
|
+
readonly runtime: NativeRuntimeBridge;
|
|
3816
|
+
/** Java reflection; Android only. */
|
|
3817
|
+
readonly java: NativeJavaBridge;
|
|
3818
|
+
/** Java method hooks; Android only. */
|
|
3819
|
+
readonly hooks: NativeJavaHooksBridge;
|
|
3820
|
+
/** Debugger support. */
|
|
3821
|
+
readonly debug: NativeDebugBridge;
|
|
3822
|
+
/** Worklets on the UI runtime. */
|
|
3823
|
+
readonly ui: NativeUIBridge;
|
|
3824
|
+
};
|
|
3825
|
+
/** A named permission to use one part of the native bridge, declared in an addon's manifest. */
|
|
3826
|
+
export type NativeBridgeCapability = (typeof NATIVE_BRIDGE_METHOD_CAPABILITIES)[NativeBridgeMethod];
|
|
3827
|
+
/** The shape of an error the native bridge or its plugin scope throws. */
|
|
3828
|
+
export type NativeBridgeError = {
|
|
3829
|
+
/** Which failure it is; native failures without their own code use `NATIVE_BRIDGE_ERROR`. */
|
|
3830
|
+
code: NativeBridgeErrorCode;
|
|
3831
|
+
/** A human-readable description. */
|
|
3832
|
+
message: string;
|
|
3833
|
+
/** The capability the plugin lacks, for `NATIVE_PLUGIN_CAPABILITY_DENIED`. */
|
|
3834
|
+
capability?: NativeBridgeCapability;
|
|
3835
|
+
};
|
|
3836
|
+
/** The stable `code` on an error the native bridge or its plugin scope throws. */
|
|
3837
|
+
export type NativeBridgeErrorCode =
|
|
3838
|
+
| 'NATIVE_BRIDGE_ERROR'
|
|
3839
|
+
| 'NATIVE_PLUGIN_API_VERSION_UNSUPPORTED'
|
|
3840
|
+
| 'NATIVE_PLUGIN_CALL_CANCELLED'
|
|
3841
|
+
| 'NATIVE_PLUGIN_CALL_TIMEOUT'
|
|
3842
|
+
| 'NATIVE_PLUGIN_CAPABILITY_DENIED'
|
|
3843
|
+
| 'NATIVE_PLUGIN_SCOPE_DISPOSED'
|
|
3844
|
+
| 'NATIVE_PLUGIN_UNAVAILABLE';
|
|
3845
|
+
/** A native bridge method by the path a plugin calls it through, such as `objc.invoke`. */
|
|
3846
|
+
export type NativeBridgeMethod = {
|
|
3847
|
+
[N in NativeBridgeNamespace]: `${N}.${keyof NativeBridge[N] & string}`;
|
|
3848
|
+
}[NativeBridgeNamespace];
|
|
3849
|
+
/** A {@link NativeBridge} namespace whose methods a plugin calls, such as `objc` or `java`. */
|
|
3850
|
+
export type NativeBridgeNamespace = Exclude<
|
|
3851
|
+
keyof NativeBridge,
|
|
3852
|
+
'apiVersion' | 'abiVersion' | 'capabilities' | 'ui'
|
|
3853
|
+
>;
|
|
3854
|
+
/** A host platform the loader reports, `ios` or `android`. */
|
|
3855
|
+
export type NativeBridgePlatform = (typeof NATIVE_BRIDGE_PLATFORMS)[number];
|
|
3856
|
+
/** A capability the native bridge on platform `P` provides. */
|
|
3857
|
+
export type NativeBridgePlatformCapability<P extends NativeBridgePlatform> =
|
|
3858
|
+
(typeof NATIVE_BRIDGE_PLATFORM_CAPABILITIES)[P][number];
|
|
3787
3859
|
/** Options for a synchronous Objective-C call. */
|
|
3788
3860
|
export type NativeCallOptions = {
|
|
3789
3861
|
/** The thread to run on. Defaults to `current`. */
|
|
@@ -3898,6 +3970,20 @@ export type NativeFFITypeName =
|
|
|
3898
3970
|
| 'object'
|
|
3899
3971
|
| 'class'
|
|
3900
3972
|
| 'selector';
|
|
3973
|
+
/** One surface's changes in a `batchAsync` call, applied as properties, then size, then frame. */
|
|
3974
|
+
export type NativeFabricBatchMutation = {
|
|
3975
|
+
/** The surface these changes apply to. */
|
|
3976
|
+
surface: NativeFabricSurface;
|
|
3977
|
+
/** New properties, as `update` sends them. */
|
|
3978
|
+
properties?: NativeSerializableObject;
|
|
3979
|
+
/** The view's frame, as `setFrame` sets it. */
|
|
3980
|
+
frame?: NativeFabricFrame;
|
|
3981
|
+
/** The layout bounds, as `setSize` sets them. */
|
|
3982
|
+
size?: {
|
|
3983
|
+
minimum: NativeFabricSize;
|
|
3984
|
+
maximum: NativeFabricSize;
|
|
3985
|
+
};
|
|
3986
|
+
};
|
|
3901
3987
|
/** Mounts registered React Native components inside existing native views. Sync methods are iOS only. */
|
|
3902
3988
|
export type NativeFabricBridge = {
|
|
3903
3989
|
/** Starts a surface for a registered component inside a container view. Needs `native.fabric.mount`. */
|
|
@@ -3940,6 +4026,8 @@ export type NativeFabricBridge = {
|
|
|
3940
4026
|
surface: NativeFabricSurface,
|
|
3941
4027
|
frame: NativeFabricFrame,
|
|
3942
4028
|
): NativeCancelablePromise<void>;
|
|
4029
|
+
/** Applies every mutation in order on the main thread's next display frame, skipping stopped surfaces. Needs `native.fabric.async`. */
|
|
4030
|
+
batchAsync(mutations: NativeFabricBatchMutation[]): NativeCancelablePromise<void>;
|
|
3943
4031
|
/** Reads a view's frame. */
|
|
3944
4032
|
measure(view: NativeObjectHandle): NativeFabricFrame;
|
|
3945
4033
|
/** Like `measure`, on the main thread. */
|
|
@@ -4499,7 +4587,7 @@ export type NativePlatformApp = {
|
|
|
4499
4587
|
/** Platform-wide helpers the loader publishes as `globalThis.NativePlatform`, not scoped to a plugin. */
|
|
4500
4588
|
export type NativePlatformBridge = {
|
|
4501
4589
|
/** The host platform. */
|
|
4502
|
-
readonly platform:
|
|
4590
|
+
readonly platform: NativeBridgePlatform;
|
|
4503
4591
|
/** Evaluates Hermes bytecode in the current runtime; `tag` names it in errors. Throws on invalid bytecode. */
|
|
4504
4592
|
evaluateBytecode(bytecode: ArrayBuffer, tag?: string): unknown;
|
|
4505
4593
|
/** Facts about the device. */
|
|
@@ -4539,7 +4627,7 @@ export type NativePlatformCrashGuard = {
|
|
|
4539
4627
|
/** Facts about the device Discord runs on. */
|
|
4540
4628
|
export type NativePlatformDevice = {
|
|
4541
4629
|
/** The host platform. */
|
|
4542
|
-
readonly platform:
|
|
4630
|
+
readonly platform: NativeBridgePlatform;
|
|
4543
4631
|
/** The device's model name. */
|
|
4544
4632
|
getDeviceModel(): string;
|
|
4545
4633
|
/** The operating system's version. */
|
|
@@ -4592,74 +4680,6 @@ export type NativePlatformSettings = {
|
|
|
4592
4680
|
/** Reads every Bucket with no arguments, one Bucket with `store`, or one dot-path `key`; `undefined` when unset. */
|
|
4593
4681
|
get(store?: string, key?: string): NativeSerializable | undefined;
|
|
4594
4682
|
};
|
|
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
4683
|
/** A handle to a native symbol's address, from `ffi.symbol`; `ffi.call` accepts only these. */
|
|
4664
4684
|
export type NativePointer = NativeHandle;
|
|
4665
4685
|
/** How many native resources the loader holds across every plugin. */
|
|
@@ -5148,21 +5168,34 @@ export type PluginContext = {
|
|
|
5148
5168
|
/** The plugin's id, from its manifest. */
|
|
5149
5169
|
readonly id: string;
|
|
5150
5170
|
/** The host platform, or `undefined` when the loader reports none. */
|
|
5151
|
-
readonly platform?:
|
|
5171
|
+
readonly platform?: NativeBridgePlatform;
|
|
5152
5172
|
/** The capabilities the manifest declares for this platform; `native` allows only these. */
|
|
5153
|
-
readonly capabilities: readonly
|
|
5173
|
+
readonly capabilities: readonly NativeBridgeCapability[];
|
|
5154
5174
|
/** The native bridge, scoped to the plugin's capabilities. */
|
|
5155
|
-
readonly native:
|
|
5175
|
+
readonly native: NativeBridge;
|
|
5156
5176
|
/** Releases the plugin's hooks, surfaces, handles and subscriptions; the addon manager calls it on stop, unload, reload or a failed start. */
|
|
5157
5177
|
dispose(): void;
|
|
5158
5178
|
};
|
|
5159
5179
|
/** 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
|
-
|
|
5180
|
+
export type PluginSelfTestResult =
|
|
5181
|
+
| {
|
|
5182
|
+
/** The plugin works on this device. */
|
|
5183
|
+
ok: true;
|
|
5184
|
+
/** A human-readable reason for the result. */
|
|
5185
|
+
detail: string;
|
|
5186
|
+
/** Set when the plugin works but has nothing on screen to draw, which says where the chat is rather than that drawing is wrong. */
|
|
5187
|
+
nothingDrawn?: boolean;
|
|
5188
|
+
/** Set while the plugin is still drawing what is on screen, so the device matrix waits before timing or judging it. */
|
|
5189
|
+
settling?: boolean;
|
|
5190
|
+
}
|
|
5191
|
+
| {
|
|
5192
|
+
/** The plugin does not work on this device. */
|
|
5193
|
+
ok: false;
|
|
5194
|
+
/** A human-readable reason for the result. */
|
|
5195
|
+
detail: string;
|
|
5196
|
+
/** Set when the plugin failed only because it has nothing on screen to draw. */
|
|
5197
|
+
nothingDrawn?: boolean;
|
|
5198
|
+
};
|
|
5166
5199
|
/**
|
|
5167
5200
|
* Props of `PostponeRender` (function). Exports: PostponeRender.
|
|
5168
5201
|
* @see design/components/Navigator/native/PostponeRender.native.tsx
|
|
@@ -5531,7 +5564,7 @@ export type SettingsGroupSchema = SettingCommon & {
|
|
|
5531
5564
|
displayAs: 'group' | 'collapsible';
|
|
5532
5565
|
properties: Record<string, SettingSchema | StorelessSchema>;
|
|
5533
5566
|
};
|
|
5534
|
-
/** A
|
|
5567
|
+
/** A Bucket, or a nested group of settings within one. */
|
|
5535
5568
|
export type SettingsObject = {
|
|
5536
5569
|
[key: string]: SettingsValue;
|
|
5537
5570
|
};
|
|
@@ -5551,7 +5584,7 @@ export type SettingsScreen = {
|
|
|
5551
5584
|
/** Discord's navigator renders the screen with its own route props, so any component fits. */
|
|
5552
5585
|
getComponent: () => React$1.ComponentType<never>;
|
|
5553
5586
|
};
|
|
5554
|
-
/** A JSON value held in a
|
|
5587
|
+
/** A JSON value held in a Bucket. */
|
|
5555
5588
|
export type SettingsValue = string | number | boolean | null | SettingsValue[] | SettingsObject;
|
|
5556
5589
|
export type SheetBottomSheetComponent = React$1.ComponentType<
|
|
5557
5590
|
SheetBottomSheetProps & Record<string, unknown>
|
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,
|
|
@@ -305,15 +315,6 @@ export type {
|
|
|
305
315
|
NativePlatformIOSBridge,
|
|
306
316
|
NativePlatformProfiler,
|
|
307
317
|
NativePlatformSettings,
|
|
308
|
-
NativePluginBridge,
|
|
309
|
-
NativePluginCapability,
|
|
310
|
-
NativePluginError,
|
|
311
|
-
NativePluginErrorCode,
|
|
312
|
-
NativePluginMethod,
|
|
313
|
-
NativePluginNamespace,
|
|
314
|
-
NativePluginPlatform,
|
|
315
|
-
NativePluginPlatformCapability,
|
|
316
|
-
NativePluginRuntimeBridge,
|
|
317
318
|
NativePointer,
|
|
318
319
|
NativeResourceCounts,
|
|
319
320
|
NativeRuntimeBridge,
|
|
@@ -563,13 +564,13 @@ export type AddonScope = {
|
|
|
563
564
|
/** The lifecycle entry points, all the global `unbound` object keeps after {@link shutdown}. */
|
|
564
565
|
export interface UnboundLifecycle {
|
|
565
566
|
/**
|
|
566
|
-
* @description Brings up the client,
|
|
567
|
-
* {@link shutdown}.
|
|
567
|
+
* @description Brings up the client: registers the addon managers, starts the built-ins, loads each kind's addons,
|
|
568
|
+
* then runs the built-ins' `afterAddons` hooks. Twin of {@link shutdown}.
|
|
568
569
|
*/
|
|
569
570
|
initialize(): void;
|
|
570
571
|
/**
|
|
571
|
-
* @description Tears the client back down
|
|
572
|
-
*
|
|
572
|
+
* @description Tears the client back down: stops the built-ins, shuts down each kind's manager, persists settings,
|
|
573
|
+
* unregisters the managers and clears the global down to the lifecycle entry points. Twin of {@link initialize}.
|
|
573
574
|
* @returns A promise that resolves once settings have been persisted and shutdown is complete.
|
|
574
575
|
*/
|
|
575
576
|
shutdown(): Promise<void>;
|
package/src/marketplace.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import type { AddonAuthor, AddonKind } from './_internal';
|
|
4
4
|
/**
|
|
5
|
-
* @description Installs the
|
|
5
|
+
* @description Installs the newest version of a marketplace addon this client runs, with the plugins it depends on once the user agrees.
|
|
6
6
|
* @param id The addon's id in the catalog.
|
|
7
7
|
* @returns Whether the addon now runs that version.
|
|
8
8
|
*/
|