@unbound-app/api 0.3.0 → 0.4.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unbound-app/api",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "author": {
5
5
  "name": "Mario P.",
6
6
  "email": "contact@marioparaschiv.com",
@@ -138,7 +138,7 @@ export interface DesignModule {
138
138
  showConfirmModal: Fn;
139
139
  showSimpleActionSheet: Fn;
140
140
  hideContextMenu: Fn<void>;
141
- useNavigation: <T = any>() => Navigation$1<T>;
141
+ useNavigation: <T = any>() => Navigation<T>;
142
142
  setColorOpacity: (color: string, opacity: number) => string;
143
143
  darkenColor: (color: string, amount: number) => string;
144
144
  brightenColor: (color: string, amount: number) => string;
@@ -188,6 +188,15 @@ export interface InternalToastOptions extends ToastOptions {
188
188
  closing?: boolean;
189
189
  date?: number;
190
190
  }
191
+ export interface Navigation<T = any> {
192
+ push: (route: string, params?: T) => void;
193
+ pop: () => void;
194
+ navigate: (route: string, params?: T) => void;
195
+ goBack: () => void;
196
+ setOptions: (options: Record<string, any>) => void;
197
+ addListener: (event: string, callback: Fn) => Fn<void>;
198
+ [key: string]: any;
199
+ }
191
200
  export interface RowButtonProps {
192
201
  label?: ReactNode;
193
202
  icon?: ReactNode;
@@ -264,6 +273,12 @@ export interface StackProps extends ViewProps {
264
273
  justify?: 'start' | 'center' | 'end' | 'between' | 'around';
265
274
  children?: ReactNode;
266
275
  }
276
+ export interface SwitchProps {
277
+ value: boolean;
278
+ disabled?: boolean;
279
+ accessibilityLabel?: string;
280
+ onValueChange: (value: boolean) => void;
281
+ }
267
282
  export interface TableCheckboxRowProps {
268
283
  label?: ReactNode;
269
284
  subLabel?: ReactNode;
@@ -604,15 +619,6 @@ export type UnboundAsset = DiscordAsset & {
604
619
  iconPackScale?: number;
605
620
  };
606
621
 
607
- interface Navigation$1<T = any> {
608
- push: (route: string, params?: T) => void;
609
- pop: () => void;
610
- navigate: (route: string, params?: T) => void;
611
- goBack: () => void;
612
- setOptions: (options: Record<string, any>) => void;
613
- addListener: (event: string, callback: Fn) => Fn<void>;
614
- [key: string]: any;
615
- }
616
622
  /** The lifecycle and settings contract implemented by a plugin. */
617
623
  interface Plugin$1 {
618
624
  start?(): void;
@@ -620,4 +626,4 @@ interface Plugin$1 {
620
626
  getSettingsPanel?(): ReactNode;
621
627
  }
622
628
 
623
- export { Navigation$1 as Navigation, Plugin$1 as Plugin };
629
+ export { Plugin$1 as Plugin };
package/src/global.d.ts CHANGED
@@ -41,6 +41,7 @@ export type {
41
41
  StackProps,
42
42
  StyleSheetSpec,
43
43
  StyleSheetSpecOrFactory,
44
+ SwitchProps,
44
45
  TableCheckboxRowProps,
45
46
  TableRadioRowProps,
46
47
  TableRowComponent,
@@ -69,49 +70,117 @@ export type {
69
70
  } from './_internal';
70
71
  import type { ColorString } from './utils';
71
72
  declare global {
72
- /** The raw `UnboundNative` JSI bridge the tweak installs directly on the JS global. */
73
- type UnboundNativeModule = {
74
- // Utilities
75
- getDeviceModel(): string;
73
+ /** A feature name published by the native module's capability table. */
74
+ type UnboundNativeFeature =
75
+ | 'device.info'
76
+ | 'device.entitlements'
77
+ | 'app.source'
78
+ | 'notifications'
79
+ | 'pip.video'
80
+ | 'chat.avatar'
81
+ | 'chat.messageBubbles'
82
+ | 'toolbox.menu'
83
+ | 'native.evaluateBytecode';
84
+ /**
85
+ * The lifecycle status of a native feature on the running build. `unknown` and `unavailable`
86
+ * both mean "do not call"; only `supported` and `deprecated` are safe.
87
+ */
88
+ type UnboundNativeFeatureStatus =
89
+ | 'unknown'
90
+ | 'removed'
91
+ | 'deprecated'
92
+ | 'supported'
93
+ | 'unavailable';
94
+ /**
95
+ * The full metadata record for a native feature. Everything but `name` and `known` is absent
96
+ * when the feature is not in this build's table.
97
+ */
98
+ type UnboundNativeFeatureInfo = {
99
+ name: string;
100
+ known: boolean;
101
+ status: UnboundNativeFeatureStatus;
102
+ supported?: boolean;
103
+ introducedIn?: string;
104
+ deprecatedIn?: string;
105
+ removedIn?: string;
106
+ replacement?: UnboundNativeFeature;
107
+ };
108
+ /** Hardware, OS, and install-integrity details for the device Unbound is running on. */
109
+ type UnboundNativeDevice = {
110
+ getModel(): string;
76
111
  getiOSVersionString(): string;
77
112
  isJailbroken(): boolean;
78
- isSystemApp(): Promise<boolean>;
113
+ isSystemApp(): boolean;
79
114
  isVerifiedBuild(): boolean;
80
- isAppStoreApp(): boolean;
81
- isTestFlightApp(): boolean;
82
- isTrollStoreApp(): boolean;
83
- isLiveContainerApp(): boolean;
84
- getTrollStoreVariant(): string;
85
- getApplicationEntitlements(): unknown;
86
- getAppSource(): string;
115
+ getEntitlements(): Record<string, any>;
87
116
  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;
117
+ };
118
+ /** How this copy of the app was installed. */
119
+ type UnboundNativeApp = {
120
+ getSource(): string;
121
+ };
122
+ /** Local notification scheduling. */
123
+ type UnboundNativeNotifications = {
124
+ show(
125
+ title?: string,
126
+ body?: string,
127
+ timeDelay?: number,
128
+ soundEnabled?: boolean,
129
+ identifier?: string,
130
+ ): string;
131
+ };
132
+ /** Picture-in-picture video playback. */
133
+ type UnboundNativePiP = {
134
+ playVideo(url: string): string | null;
135
+ };
136
+ /**
137
+ * Native chat appearance controls. The getters read synchronously; every setter hops to the
138
+ * main queue and returns immediately, so a value read back on the next line may still be stale.
139
+ */
140
+ type UnboundNativeChat = {
101
141
  getAvatarCornerRadius(): number;
102
- setMessageBubblesEnabled(
103
- enabled: boolean,
104
- lightColor: ColorString | null,
105
- darkColor: ColorString | null,
106
- ): void;
107
- setMessageBubbleColors(lightColor: ColorString, darkColor: ColorString): void;
142
+ setAvatarCornerRadius(radius?: number): void;
143
+ resetAvatarCornerRadius(): void;
144
+ getMessageBubblesEnabled(): boolean;
108
145
  getMessageBubbleLightColor(): ColorString;
109
146
  getMessageBubbleDarkColor(): ColorString;
110
- getMessageBubblesEnabled(): boolean;
111
147
  getMessageBubbleCornerRadius(): number;
112
- setMessageBubbleCornerRadius(radius: number): void;
148
+ setMessageBubblesEnabled(
149
+ enabled: boolean,
150
+ lightColor?: ColorString,
151
+ darkColor?: ColorString,
152
+ ): void;
153
+ setMessageBubbleColors(lightColor?: ColorString, darkColor?: ColorString): void;
154
+ setMessageBubbleCornerRadius(radius?: number): void;
113
155
  resetMessageBubbles(): void;
114
156
  };
157
+ /** The native toolbox menu, drawn natively so it survives a broken JS bundle. */
158
+ type UnboundNativeToolbox = {
159
+ showMenu(): void;
160
+ };
161
+ /** The raw `UnboundNative` JSI bridge the tweak installs directly on the JS global. */
162
+ type UnboundNativeModule = {
163
+ getNativeModuleVersion(): string;
164
+ supportsFeature(name: UnboundNativeFeature): boolean;
165
+ getFeatureInfo(name: UnboundNativeFeature): UnboundNativeFeatureInfo;
166
+ isFeatureDeprecated(name: UnboundNativeFeature): boolean;
167
+ isFeatureRemoved(name: UnboundNativeFeature): boolean;
168
+ getSupportedFeatures(): UnboundNativeFeature[];
169
+ getDeprecatedFeatures(): UnboundNativeFeature[];
170
+ getRemovedFeatures(): UnboundNativeFeature[];
171
+ /**
172
+ * Runs Hermes bytecode in the app's JS runtime and returns whatever it evaluates to.
173
+ * Throws when the buffer is not an `ArrayBuffer`, is empty, or is not Hermes bytecode;
174
+ * anything the bytecode itself throws propagates too.
175
+ */
176
+ evaluateBytecode(bytecode: ArrayBuffer, tag?: string): any;
177
+ device: UnboundNativeDevice;
178
+ app: UnboundNativeApp;
179
+ notifications: UnboundNativeNotifications;
180
+ pip: UnboundNativePiP;
181
+ chat: UnboundNativeChat;
182
+ toolbox: UnboundNativeToolbox;
183
+ };
115
184
  /**
116
185
  * Build-time token, replaced with a boolean literal by the build's `transform.define`. Folds at
117
186
  * the module-graph level so `if ($$DEV$$)` branches (and any imports inside them) are dead-code
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by generate-plugin-sdk.ts - DO NOT EDIT
2
2
 
3
- export type { DesignModule } from '../_internal';
3
+ export type { DesignModule, SwitchProps } from '../_internal';
4
4
  import {
5
5
  ImageStyle,
6
6
  StyleProp,
@@ -11,7 +11,7 @@ import {
11
11
  } from 'react-native';
12
12
  import { ComponentType, ReactNode } from 'react';
13
13
 
14
- import type { DesignModule } from '../_internal';
14
+ import type { DesignModule, SwitchProps } from '../_internal';
15
15
  export declare const BackdropFilters: any;
16
16
  export declare const Discord: DesignModule;
17
17
  export declare const FlashList: any;
@@ -20,3 +20,4 @@ export declare const HelpMessage: any;
20
20
  export declare const Media: any;
21
21
  export declare const Portal: any;
22
22
  export declare const SafeArea: any;
23
+ export declare const Switch: ComponentType<SwitchProps>;