@rn-bridge-tools/react 0.0.1
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/dist/index.cjs +490 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +311 -0
- package/dist/index.d.ts +311 -0
- package/dist/index.js +438 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import * as _rn_bridge_tools_core from '@rn-bridge-tools/core';
|
|
4
|
+
import { BridgeToolsAction, BridgeToolsSchema, BridgeToolsEvent, BridgeToolsEvents, CameraNamespace, LocationNamespace, LocationEvents, FileNamespace, ShareNamespace, StatusBarNamespace, HapticNamespace, ClipboardNamespace, ScannerNamespace, AuthNamespace, IAPNamespace, PermissionNamespace, PreferenceNamespace, NavigationNamespace, BrowserNamespace } from '@rn-bridge-tools/core';
|
|
5
|
+
|
|
6
|
+
type SendFn = <K extends BridgeToolsAction>(action: K, payload: BridgeToolsSchema[K]['request']) => Promise<BridgeToolsSchema[K]['response']>;
|
|
7
|
+
type OnFn = <E extends BridgeToolsEvent>(event: E, callback: (data: BridgeToolsEvents[E]) => void) => () => void;
|
|
8
|
+
interface BridgeContextValue {
|
|
9
|
+
send: SendFn;
|
|
10
|
+
on: OnFn;
|
|
11
|
+
isAvailable: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface BridgeProviderProps {
|
|
14
|
+
children?: React.ReactNode | undefined;
|
|
15
|
+
timeout?: number;
|
|
16
|
+
debug?: boolean;
|
|
17
|
+
onReady?: () => void;
|
|
18
|
+
}
|
|
19
|
+
declare function BridgeProvider({ children, timeout, debug, onReady }: BridgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
20
|
+
declare function useBridge(): BridgeContextValue;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Lightweight external store compatible with useSyncExternalStore.
|
|
24
|
+
* Used for bridge event subscriptions (keyboard, location, push, etc.)
|
|
25
|
+
*/
|
|
26
|
+
declare function createBridgeStore<T>(initialState: T): {
|
|
27
|
+
getSnapshot(): T;
|
|
28
|
+
getServerSnapshot(): T;
|
|
29
|
+
subscribe(listener: () => void): () => void;
|
|
30
|
+
setState(next: T | ((prev: T) => T)): void;
|
|
31
|
+
destroy(): void;
|
|
32
|
+
};
|
|
33
|
+
type BridgeStore<T> = ReturnType<typeof createBridgeStore<T>>;
|
|
34
|
+
/**
|
|
35
|
+
* Hook that subscribes to a BridgeStore using useSyncExternalStore.
|
|
36
|
+
* Concurrent Mode safe — no tearing.
|
|
37
|
+
*/
|
|
38
|
+
declare function useBridgeStore<T>(store: BridgeStore<T>): T;
|
|
39
|
+
/**
|
|
40
|
+
* Hook that subscribes to a BridgeStore with a selector.
|
|
41
|
+
* Only re-renders when the selected value changes.
|
|
42
|
+
*/
|
|
43
|
+
declare function useBridgeStoreSelector<T, S>(store: BridgeStore<T>, selector: (state: T) => S): S;
|
|
44
|
+
/**
|
|
45
|
+
* Subscribe to a single bridge event and sync to a store.
|
|
46
|
+
* Returns the current snapshot via useSyncExternalStore.
|
|
47
|
+
*/
|
|
48
|
+
declare function useBridgeEvent<T, E extends BridgeToolsEvent>(on: BridgeContextValue['on'], event: E, initialState: T, updater: (prev: T, data: BridgeToolsEvents[E]) => T): T;
|
|
49
|
+
type EventBinding<T> = {
|
|
50
|
+
event: BridgeToolsEvent;
|
|
51
|
+
updater: (prev: T, data: never) => T;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Subscribe to multiple bridge events and sync to a single store.
|
|
55
|
+
* Returns the current snapshot via useSyncExternalStore.
|
|
56
|
+
*/
|
|
57
|
+
declare function useBridgeEvents<T>(on: BridgeContextValue['on'], initialState: T, bindings: EventBinding<T>[]): T;
|
|
58
|
+
|
|
59
|
+
declare function useCamera(): {
|
|
60
|
+
take: (opts?: CameraNamespace["camera.take"]["request"]) => Promise<{
|
|
61
|
+
success: boolean;
|
|
62
|
+
uri?: string;
|
|
63
|
+
width?: number;
|
|
64
|
+
height?: number;
|
|
65
|
+
fileSize?: number;
|
|
66
|
+
mimeType?: string;
|
|
67
|
+
base64?: string;
|
|
68
|
+
}>;
|
|
69
|
+
pickImage: (opts?: CameraNamespace["camera.pickImage"]["request"]) => Promise<{
|
|
70
|
+
success: boolean;
|
|
71
|
+
assets: Array<{
|
|
72
|
+
uri: string;
|
|
73
|
+
width: number;
|
|
74
|
+
height: number;
|
|
75
|
+
fileSize?: number;
|
|
76
|
+
mimeType?: string;
|
|
77
|
+
}>;
|
|
78
|
+
}>;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
declare function useLocation(): {
|
|
82
|
+
getCurrent: (opts?: LocationNamespace["location.getCurrent"]["request"]) => Promise<{
|
|
83
|
+
lat: number;
|
|
84
|
+
lng: number;
|
|
85
|
+
altitude?: number;
|
|
86
|
+
accuracy?: number;
|
|
87
|
+
timestamp: number;
|
|
88
|
+
}>;
|
|
89
|
+
watchStart: (opts?: LocationNamespace["location.watchStart"]["request"]) => Promise<{
|
|
90
|
+
watchId: string;
|
|
91
|
+
}>;
|
|
92
|
+
watchStop: (opts: LocationNamespace["location.watchStop"]["request"]) => Promise<{
|
|
93
|
+
success: boolean;
|
|
94
|
+
}>;
|
|
95
|
+
};
|
|
96
|
+
type LocationUpdate = LocationEvents['location.update'] | null;
|
|
97
|
+
declare function useLocationWatch(opts?: LocationNamespace['location.watchStart']['request']): LocationUpdate;
|
|
98
|
+
|
|
99
|
+
declare function useFile(): {
|
|
100
|
+
download: (opts: FileNamespace["file.download"]["request"]) => Promise<{
|
|
101
|
+
success: boolean;
|
|
102
|
+
localUri?: string;
|
|
103
|
+
error?: string;
|
|
104
|
+
}>;
|
|
105
|
+
read: (opts: FileNamespace["file.read"]["request"]) => Promise<{
|
|
106
|
+
success: boolean;
|
|
107
|
+
content?: string;
|
|
108
|
+
error?: string;
|
|
109
|
+
}>;
|
|
110
|
+
write: (opts: FileNamespace["file.write"]["request"]) => Promise<{
|
|
111
|
+
success: boolean;
|
|
112
|
+
uri?: string;
|
|
113
|
+
error?: string;
|
|
114
|
+
}>;
|
|
115
|
+
pick: (opts?: FileNamespace["file.pick"]["request"]) => Promise<{
|
|
116
|
+
success: boolean;
|
|
117
|
+
files: Array<{
|
|
118
|
+
uri: string;
|
|
119
|
+
name: string;
|
|
120
|
+
size: number;
|
|
121
|
+
mimeType: string;
|
|
122
|
+
}>;
|
|
123
|
+
}>;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
declare function useShare(): {
|
|
127
|
+
open: (opts?: ShareNamespace["share.open"]["request"]) => Promise<{
|
|
128
|
+
success: boolean;
|
|
129
|
+
activityType?: string;
|
|
130
|
+
}>;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
declare function useDevice(): {
|
|
134
|
+
getInfo: () => Promise<{
|
|
135
|
+
os: "ios" | "android";
|
|
136
|
+
osVersion: string;
|
|
137
|
+
model: string;
|
|
138
|
+
brand: string;
|
|
139
|
+
isTablet: boolean;
|
|
140
|
+
appVersion: string;
|
|
141
|
+
buildNumber: string;
|
|
142
|
+
bundleId: string;
|
|
143
|
+
}>;
|
|
144
|
+
getBattery: () => Promise<{
|
|
145
|
+
level: number;
|
|
146
|
+
isCharging: boolean;
|
|
147
|
+
}>;
|
|
148
|
+
getNetwork: () => Promise<{
|
|
149
|
+
type: "wifi" | "cellular" | "none" | "unknown";
|
|
150
|
+
isConnected: boolean;
|
|
151
|
+
}>;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
declare function useStatusBar(): {
|
|
155
|
+
setStyle: (opts: StatusBarNamespace["statusbar.setStyle"]["request"]) => Promise<{
|
|
156
|
+
success: boolean;
|
|
157
|
+
}>;
|
|
158
|
+
setBackgroundColor: (opts: StatusBarNamespace["statusbar.setBackgroundColor"]["request"]) => Promise<{
|
|
159
|
+
success: boolean;
|
|
160
|
+
}>;
|
|
161
|
+
setHidden: (opts: StatusBarNamespace["statusbar.setHidden"]["request"]) => Promise<{
|
|
162
|
+
success: boolean;
|
|
163
|
+
}>;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
declare function useKeyboard(): {
|
|
167
|
+
visible: boolean;
|
|
168
|
+
height: number;
|
|
169
|
+
dismiss: () => Promise<{
|
|
170
|
+
success: boolean;
|
|
171
|
+
}>;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
declare function useHaptic(): {
|
|
175
|
+
impact: (opts: HapticNamespace["haptic.impact"]["request"]) => Promise<void>;
|
|
176
|
+
notification: (opts: HapticNamespace["haptic.notification"]["request"]) => Promise<void>;
|
|
177
|
+
selection: () => Promise<void>;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
declare function useClipboard(): {
|
|
181
|
+
copy: (opts: ClipboardNamespace["clipboard.copy"]["request"]) => Promise<{
|
|
182
|
+
success: boolean;
|
|
183
|
+
}>;
|
|
184
|
+
paste: () => Promise<{
|
|
185
|
+
text: string;
|
|
186
|
+
hasContent: boolean;
|
|
187
|
+
}>;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
declare function useScanner(): {
|
|
191
|
+
scanQR: (opts?: ScannerNamespace["scanner.scanQR"]["request"]) => Promise<{
|
|
192
|
+
success: boolean;
|
|
193
|
+
data?: string;
|
|
194
|
+
type?: string;
|
|
195
|
+
cancelled?: boolean;
|
|
196
|
+
}>;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
declare function useAuth(): {
|
|
200
|
+
biometric: (opts?: AuthNamespace["auth.biometric"]["request"]) => Promise<{
|
|
201
|
+
success: boolean;
|
|
202
|
+
error?: string;
|
|
203
|
+
biometryType?: "fingerprint" | "facial" | "iris";
|
|
204
|
+
}>;
|
|
205
|
+
isBiometricAvailable: () => Promise<{
|
|
206
|
+
available: boolean;
|
|
207
|
+
biometryType?: "fingerprint" | "facial" | "iris";
|
|
208
|
+
}>;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
declare function useIAP(): {
|
|
212
|
+
getProducts: (opts: IAPNamespace["iap.getProducts"]["request"]) => Promise<{
|
|
213
|
+
products: Array<{
|
|
214
|
+
id: string;
|
|
215
|
+
title: string;
|
|
216
|
+
description: string;
|
|
217
|
+
price: string;
|
|
218
|
+
currency: string;
|
|
219
|
+
}>;
|
|
220
|
+
}>;
|
|
221
|
+
purchase: (opts: IAPNamespace["iap.purchase"]["request"]) => Promise<{
|
|
222
|
+
success: boolean;
|
|
223
|
+
transactionId?: string;
|
|
224
|
+
receipt?: string;
|
|
225
|
+
error?: string;
|
|
226
|
+
}>;
|
|
227
|
+
restore: () => Promise<{
|
|
228
|
+
purchases: Array<{
|
|
229
|
+
productId: string;
|
|
230
|
+
transactionId: string;
|
|
231
|
+
}>;
|
|
232
|
+
}>;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
declare function usePush(): {
|
|
236
|
+
getToken: () => Promise<{
|
|
237
|
+
token: string;
|
|
238
|
+
platform: "apns" | "fcm";
|
|
239
|
+
}>;
|
|
240
|
+
requestPermission: () => Promise<{
|
|
241
|
+
granted: boolean;
|
|
242
|
+
status: "granted" | "denied" | "undetermined";
|
|
243
|
+
}>;
|
|
244
|
+
};
|
|
245
|
+
declare function usePushNotification(): {
|
|
246
|
+
lastReceived: {
|
|
247
|
+
title?: string;
|
|
248
|
+
body?: string;
|
|
249
|
+
data?: Record<string, unknown>;
|
|
250
|
+
} | null;
|
|
251
|
+
lastTapped: {
|
|
252
|
+
title?: string;
|
|
253
|
+
body?: string;
|
|
254
|
+
data?: Record<string, unknown>;
|
|
255
|
+
} | null;
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
declare function usePermission(): {
|
|
259
|
+
check: (opts: PermissionNamespace["permission.check"]["request"]) => Promise<{
|
|
260
|
+
status: _rn_bridge_tools_core.PermissionStatus;
|
|
261
|
+
canAskAgain: boolean;
|
|
262
|
+
}>;
|
|
263
|
+
request: (opts: PermissionNamespace["permission.request"]["request"]) => Promise<{
|
|
264
|
+
status: _rn_bridge_tools_core.PermissionStatus;
|
|
265
|
+
canAskAgain: boolean;
|
|
266
|
+
}>;
|
|
267
|
+
openSettings: () => Promise<{
|
|
268
|
+
success: boolean;
|
|
269
|
+
}>;
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
declare function usePreference(): {
|
|
273
|
+
get: (opts: PreferenceNamespace["preference.get"]["request"]) => Promise<{
|
|
274
|
+
value: string | null;
|
|
275
|
+
}>;
|
|
276
|
+
set: (opts: PreferenceNamespace["preference.set"]["request"]) => Promise<{
|
|
277
|
+
success: boolean;
|
|
278
|
+
}>;
|
|
279
|
+
remove: (opts: PreferenceNamespace["preference.remove"]["request"]) => Promise<{
|
|
280
|
+
success: boolean;
|
|
281
|
+
}>;
|
|
282
|
+
clear: () => Promise<{
|
|
283
|
+
success: boolean;
|
|
284
|
+
}>;
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
declare function useNavigation(): {
|
|
288
|
+
goBack: () => Promise<{
|
|
289
|
+
success: boolean;
|
|
290
|
+
}>;
|
|
291
|
+
push: (opts: NavigationNamespace["navigation.push"]["request"]) => Promise<{
|
|
292
|
+
success: boolean;
|
|
293
|
+
}>;
|
|
294
|
+
close: () => Promise<{
|
|
295
|
+
success: boolean;
|
|
296
|
+
}>;
|
|
297
|
+
setSwipeBack: (opts: NavigationNamespace["navigation.setSwipeBack"]["request"]) => Promise<{
|
|
298
|
+
success: boolean;
|
|
299
|
+
}>;
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
declare function useBrowser(): {
|
|
303
|
+
openExternal: (opts: BrowserNamespace["browser.openExternal"]["request"]) => Promise<{
|
|
304
|
+
success: boolean;
|
|
305
|
+
}>;
|
|
306
|
+
openInternal: (opts: BrowserNamespace["browser.openInternal"]["request"]) => Promise<{
|
|
307
|
+
success: boolean;
|
|
308
|
+
}>;
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
export { type BridgeContextValue, BridgeProvider, type BridgeProviderProps, type BridgeStore, createBridgeStore, useAuth, useBridge, useBridgeEvent, useBridgeEvents, useBridgeStore, useBridgeStoreSelector, useBrowser, useCamera, useClipboard, useDevice, useFile, useHaptic, useIAP, useKeyboard, useLocation, useLocationWatch, useNavigation, usePermission, usePreference, usePush, usePushNotification, useScanner, useShare, useStatusBar };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import * as _rn_bridge_tools_core from '@rn-bridge-tools/core';
|
|
4
|
+
import { BridgeToolsAction, BridgeToolsSchema, BridgeToolsEvent, BridgeToolsEvents, CameraNamespace, LocationNamespace, LocationEvents, FileNamespace, ShareNamespace, StatusBarNamespace, HapticNamespace, ClipboardNamespace, ScannerNamespace, AuthNamespace, IAPNamespace, PermissionNamespace, PreferenceNamespace, NavigationNamespace, BrowserNamespace } from '@rn-bridge-tools/core';
|
|
5
|
+
|
|
6
|
+
type SendFn = <K extends BridgeToolsAction>(action: K, payload: BridgeToolsSchema[K]['request']) => Promise<BridgeToolsSchema[K]['response']>;
|
|
7
|
+
type OnFn = <E extends BridgeToolsEvent>(event: E, callback: (data: BridgeToolsEvents[E]) => void) => () => void;
|
|
8
|
+
interface BridgeContextValue {
|
|
9
|
+
send: SendFn;
|
|
10
|
+
on: OnFn;
|
|
11
|
+
isAvailable: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface BridgeProviderProps {
|
|
14
|
+
children?: React.ReactNode | undefined;
|
|
15
|
+
timeout?: number;
|
|
16
|
+
debug?: boolean;
|
|
17
|
+
onReady?: () => void;
|
|
18
|
+
}
|
|
19
|
+
declare function BridgeProvider({ children, timeout, debug, onReady }: BridgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
20
|
+
declare function useBridge(): BridgeContextValue;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Lightweight external store compatible with useSyncExternalStore.
|
|
24
|
+
* Used for bridge event subscriptions (keyboard, location, push, etc.)
|
|
25
|
+
*/
|
|
26
|
+
declare function createBridgeStore<T>(initialState: T): {
|
|
27
|
+
getSnapshot(): T;
|
|
28
|
+
getServerSnapshot(): T;
|
|
29
|
+
subscribe(listener: () => void): () => void;
|
|
30
|
+
setState(next: T | ((prev: T) => T)): void;
|
|
31
|
+
destroy(): void;
|
|
32
|
+
};
|
|
33
|
+
type BridgeStore<T> = ReturnType<typeof createBridgeStore<T>>;
|
|
34
|
+
/**
|
|
35
|
+
* Hook that subscribes to a BridgeStore using useSyncExternalStore.
|
|
36
|
+
* Concurrent Mode safe — no tearing.
|
|
37
|
+
*/
|
|
38
|
+
declare function useBridgeStore<T>(store: BridgeStore<T>): T;
|
|
39
|
+
/**
|
|
40
|
+
* Hook that subscribes to a BridgeStore with a selector.
|
|
41
|
+
* Only re-renders when the selected value changes.
|
|
42
|
+
*/
|
|
43
|
+
declare function useBridgeStoreSelector<T, S>(store: BridgeStore<T>, selector: (state: T) => S): S;
|
|
44
|
+
/**
|
|
45
|
+
* Subscribe to a single bridge event and sync to a store.
|
|
46
|
+
* Returns the current snapshot via useSyncExternalStore.
|
|
47
|
+
*/
|
|
48
|
+
declare function useBridgeEvent<T, E extends BridgeToolsEvent>(on: BridgeContextValue['on'], event: E, initialState: T, updater: (prev: T, data: BridgeToolsEvents[E]) => T): T;
|
|
49
|
+
type EventBinding<T> = {
|
|
50
|
+
event: BridgeToolsEvent;
|
|
51
|
+
updater: (prev: T, data: never) => T;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Subscribe to multiple bridge events and sync to a single store.
|
|
55
|
+
* Returns the current snapshot via useSyncExternalStore.
|
|
56
|
+
*/
|
|
57
|
+
declare function useBridgeEvents<T>(on: BridgeContextValue['on'], initialState: T, bindings: EventBinding<T>[]): T;
|
|
58
|
+
|
|
59
|
+
declare function useCamera(): {
|
|
60
|
+
take: (opts?: CameraNamespace["camera.take"]["request"]) => Promise<{
|
|
61
|
+
success: boolean;
|
|
62
|
+
uri?: string;
|
|
63
|
+
width?: number;
|
|
64
|
+
height?: number;
|
|
65
|
+
fileSize?: number;
|
|
66
|
+
mimeType?: string;
|
|
67
|
+
base64?: string;
|
|
68
|
+
}>;
|
|
69
|
+
pickImage: (opts?: CameraNamespace["camera.pickImage"]["request"]) => Promise<{
|
|
70
|
+
success: boolean;
|
|
71
|
+
assets: Array<{
|
|
72
|
+
uri: string;
|
|
73
|
+
width: number;
|
|
74
|
+
height: number;
|
|
75
|
+
fileSize?: number;
|
|
76
|
+
mimeType?: string;
|
|
77
|
+
}>;
|
|
78
|
+
}>;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
declare function useLocation(): {
|
|
82
|
+
getCurrent: (opts?: LocationNamespace["location.getCurrent"]["request"]) => Promise<{
|
|
83
|
+
lat: number;
|
|
84
|
+
lng: number;
|
|
85
|
+
altitude?: number;
|
|
86
|
+
accuracy?: number;
|
|
87
|
+
timestamp: number;
|
|
88
|
+
}>;
|
|
89
|
+
watchStart: (opts?: LocationNamespace["location.watchStart"]["request"]) => Promise<{
|
|
90
|
+
watchId: string;
|
|
91
|
+
}>;
|
|
92
|
+
watchStop: (opts: LocationNamespace["location.watchStop"]["request"]) => Promise<{
|
|
93
|
+
success: boolean;
|
|
94
|
+
}>;
|
|
95
|
+
};
|
|
96
|
+
type LocationUpdate = LocationEvents['location.update'] | null;
|
|
97
|
+
declare function useLocationWatch(opts?: LocationNamespace['location.watchStart']['request']): LocationUpdate;
|
|
98
|
+
|
|
99
|
+
declare function useFile(): {
|
|
100
|
+
download: (opts: FileNamespace["file.download"]["request"]) => Promise<{
|
|
101
|
+
success: boolean;
|
|
102
|
+
localUri?: string;
|
|
103
|
+
error?: string;
|
|
104
|
+
}>;
|
|
105
|
+
read: (opts: FileNamespace["file.read"]["request"]) => Promise<{
|
|
106
|
+
success: boolean;
|
|
107
|
+
content?: string;
|
|
108
|
+
error?: string;
|
|
109
|
+
}>;
|
|
110
|
+
write: (opts: FileNamespace["file.write"]["request"]) => Promise<{
|
|
111
|
+
success: boolean;
|
|
112
|
+
uri?: string;
|
|
113
|
+
error?: string;
|
|
114
|
+
}>;
|
|
115
|
+
pick: (opts?: FileNamespace["file.pick"]["request"]) => Promise<{
|
|
116
|
+
success: boolean;
|
|
117
|
+
files: Array<{
|
|
118
|
+
uri: string;
|
|
119
|
+
name: string;
|
|
120
|
+
size: number;
|
|
121
|
+
mimeType: string;
|
|
122
|
+
}>;
|
|
123
|
+
}>;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
declare function useShare(): {
|
|
127
|
+
open: (opts?: ShareNamespace["share.open"]["request"]) => Promise<{
|
|
128
|
+
success: boolean;
|
|
129
|
+
activityType?: string;
|
|
130
|
+
}>;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
declare function useDevice(): {
|
|
134
|
+
getInfo: () => Promise<{
|
|
135
|
+
os: "ios" | "android";
|
|
136
|
+
osVersion: string;
|
|
137
|
+
model: string;
|
|
138
|
+
brand: string;
|
|
139
|
+
isTablet: boolean;
|
|
140
|
+
appVersion: string;
|
|
141
|
+
buildNumber: string;
|
|
142
|
+
bundleId: string;
|
|
143
|
+
}>;
|
|
144
|
+
getBattery: () => Promise<{
|
|
145
|
+
level: number;
|
|
146
|
+
isCharging: boolean;
|
|
147
|
+
}>;
|
|
148
|
+
getNetwork: () => Promise<{
|
|
149
|
+
type: "wifi" | "cellular" | "none" | "unknown";
|
|
150
|
+
isConnected: boolean;
|
|
151
|
+
}>;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
declare function useStatusBar(): {
|
|
155
|
+
setStyle: (opts: StatusBarNamespace["statusbar.setStyle"]["request"]) => Promise<{
|
|
156
|
+
success: boolean;
|
|
157
|
+
}>;
|
|
158
|
+
setBackgroundColor: (opts: StatusBarNamespace["statusbar.setBackgroundColor"]["request"]) => Promise<{
|
|
159
|
+
success: boolean;
|
|
160
|
+
}>;
|
|
161
|
+
setHidden: (opts: StatusBarNamespace["statusbar.setHidden"]["request"]) => Promise<{
|
|
162
|
+
success: boolean;
|
|
163
|
+
}>;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
declare function useKeyboard(): {
|
|
167
|
+
visible: boolean;
|
|
168
|
+
height: number;
|
|
169
|
+
dismiss: () => Promise<{
|
|
170
|
+
success: boolean;
|
|
171
|
+
}>;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
declare function useHaptic(): {
|
|
175
|
+
impact: (opts: HapticNamespace["haptic.impact"]["request"]) => Promise<void>;
|
|
176
|
+
notification: (opts: HapticNamespace["haptic.notification"]["request"]) => Promise<void>;
|
|
177
|
+
selection: () => Promise<void>;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
declare function useClipboard(): {
|
|
181
|
+
copy: (opts: ClipboardNamespace["clipboard.copy"]["request"]) => Promise<{
|
|
182
|
+
success: boolean;
|
|
183
|
+
}>;
|
|
184
|
+
paste: () => Promise<{
|
|
185
|
+
text: string;
|
|
186
|
+
hasContent: boolean;
|
|
187
|
+
}>;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
declare function useScanner(): {
|
|
191
|
+
scanQR: (opts?: ScannerNamespace["scanner.scanQR"]["request"]) => Promise<{
|
|
192
|
+
success: boolean;
|
|
193
|
+
data?: string;
|
|
194
|
+
type?: string;
|
|
195
|
+
cancelled?: boolean;
|
|
196
|
+
}>;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
declare function useAuth(): {
|
|
200
|
+
biometric: (opts?: AuthNamespace["auth.biometric"]["request"]) => Promise<{
|
|
201
|
+
success: boolean;
|
|
202
|
+
error?: string;
|
|
203
|
+
biometryType?: "fingerprint" | "facial" | "iris";
|
|
204
|
+
}>;
|
|
205
|
+
isBiometricAvailable: () => Promise<{
|
|
206
|
+
available: boolean;
|
|
207
|
+
biometryType?: "fingerprint" | "facial" | "iris";
|
|
208
|
+
}>;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
declare function useIAP(): {
|
|
212
|
+
getProducts: (opts: IAPNamespace["iap.getProducts"]["request"]) => Promise<{
|
|
213
|
+
products: Array<{
|
|
214
|
+
id: string;
|
|
215
|
+
title: string;
|
|
216
|
+
description: string;
|
|
217
|
+
price: string;
|
|
218
|
+
currency: string;
|
|
219
|
+
}>;
|
|
220
|
+
}>;
|
|
221
|
+
purchase: (opts: IAPNamespace["iap.purchase"]["request"]) => Promise<{
|
|
222
|
+
success: boolean;
|
|
223
|
+
transactionId?: string;
|
|
224
|
+
receipt?: string;
|
|
225
|
+
error?: string;
|
|
226
|
+
}>;
|
|
227
|
+
restore: () => Promise<{
|
|
228
|
+
purchases: Array<{
|
|
229
|
+
productId: string;
|
|
230
|
+
transactionId: string;
|
|
231
|
+
}>;
|
|
232
|
+
}>;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
declare function usePush(): {
|
|
236
|
+
getToken: () => Promise<{
|
|
237
|
+
token: string;
|
|
238
|
+
platform: "apns" | "fcm";
|
|
239
|
+
}>;
|
|
240
|
+
requestPermission: () => Promise<{
|
|
241
|
+
granted: boolean;
|
|
242
|
+
status: "granted" | "denied" | "undetermined";
|
|
243
|
+
}>;
|
|
244
|
+
};
|
|
245
|
+
declare function usePushNotification(): {
|
|
246
|
+
lastReceived: {
|
|
247
|
+
title?: string;
|
|
248
|
+
body?: string;
|
|
249
|
+
data?: Record<string, unknown>;
|
|
250
|
+
} | null;
|
|
251
|
+
lastTapped: {
|
|
252
|
+
title?: string;
|
|
253
|
+
body?: string;
|
|
254
|
+
data?: Record<string, unknown>;
|
|
255
|
+
} | null;
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
declare function usePermission(): {
|
|
259
|
+
check: (opts: PermissionNamespace["permission.check"]["request"]) => Promise<{
|
|
260
|
+
status: _rn_bridge_tools_core.PermissionStatus;
|
|
261
|
+
canAskAgain: boolean;
|
|
262
|
+
}>;
|
|
263
|
+
request: (opts: PermissionNamespace["permission.request"]["request"]) => Promise<{
|
|
264
|
+
status: _rn_bridge_tools_core.PermissionStatus;
|
|
265
|
+
canAskAgain: boolean;
|
|
266
|
+
}>;
|
|
267
|
+
openSettings: () => Promise<{
|
|
268
|
+
success: boolean;
|
|
269
|
+
}>;
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
declare function usePreference(): {
|
|
273
|
+
get: (opts: PreferenceNamespace["preference.get"]["request"]) => Promise<{
|
|
274
|
+
value: string | null;
|
|
275
|
+
}>;
|
|
276
|
+
set: (opts: PreferenceNamespace["preference.set"]["request"]) => Promise<{
|
|
277
|
+
success: boolean;
|
|
278
|
+
}>;
|
|
279
|
+
remove: (opts: PreferenceNamespace["preference.remove"]["request"]) => Promise<{
|
|
280
|
+
success: boolean;
|
|
281
|
+
}>;
|
|
282
|
+
clear: () => Promise<{
|
|
283
|
+
success: boolean;
|
|
284
|
+
}>;
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
declare function useNavigation(): {
|
|
288
|
+
goBack: () => Promise<{
|
|
289
|
+
success: boolean;
|
|
290
|
+
}>;
|
|
291
|
+
push: (opts: NavigationNamespace["navigation.push"]["request"]) => Promise<{
|
|
292
|
+
success: boolean;
|
|
293
|
+
}>;
|
|
294
|
+
close: () => Promise<{
|
|
295
|
+
success: boolean;
|
|
296
|
+
}>;
|
|
297
|
+
setSwipeBack: (opts: NavigationNamespace["navigation.setSwipeBack"]["request"]) => Promise<{
|
|
298
|
+
success: boolean;
|
|
299
|
+
}>;
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
declare function useBrowser(): {
|
|
303
|
+
openExternal: (opts: BrowserNamespace["browser.openExternal"]["request"]) => Promise<{
|
|
304
|
+
success: boolean;
|
|
305
|
+
}>;
|
|
306
|
+
openInternal: (opts: BrowserNamespace["browser.openInternal"]["request"]) => Promise<{
|
|
307
|
+
success: boolean;
|
|
308
|
+
}>;
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
export { type BridgeContextValue, BridgeProvider, type BridgeProviderProps, type BridgeStore, createBridgeStore, useAuth, useBridge, useBridgeEvent, useBridgeEvents, useBridgeStore, useBridgeStoreSelector, useBrowser, useCamera, useClipboard, useDevice, useFile, useHaptic, useIAP, useKeyboard, useLocation, useLocationWatch, useNavigation, usePermission, usePreference, usePush, usePushNotification, useScanner, useShare, useStatusBar };
|