@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.js
ADDED
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
// src/provider.tsx
|
|
2
|
+
import { createContext, useContext, useRef, useCallback, useMemo } from "react";
|
|
3
|
+
import { linkBridge } from "@webview-bridge/web";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
var BridgeContext = createContext(null);
|
|
6
|
+
function BridgeProvider({ children, timeout, debug, onReady }) {
|
|
7
|
+
const bridgeRef = useRef(null);
|
|
8
|
+
const onReadyRef = useRef(onReady);
|
|
9
|
+
onReadyRef.current = onReady;
|
|
10
|
+
if (bridgeRef.current === null) {
|
|
11
|
+
bridgeRef.current = linkBridge({
|
|
12
|
+
timeout: timeout ?? 5e3,
|
|
13
|
+
debug: debug ?? false,
|
|
14
|
+
throwOnError: false,
|
|
15
|
+
onReady: () => {
|
|
16
|
+
onReadyRef.current?.();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const send = useCallback(
|
|
21
|
+
async (action, payload) => {
|
|
22
|
+
const bridge = bridgeRef.current;
|
|
23
|
+
if (!bridge) {
|
|
24
|
+
throw new Error("Bridge not initialized");
|
|
25
|
+
}
|
|
26
|
+
const method = bridge[action];
|
|
27
|
+
if (typeof method !== "function") {
|
|
28
|
+
throw new Error(`Bridge method "${action}" is not available`);
|
|
29
|
+
}
|
|
30
|
+
return method(payload);
|
|
31
|
+
},
|
|
32
|
+
[]
|
|
33
|
+
);
|
|
34
|
+
const on = useCallback(
|
|
35
|
+
(event, callback) => {
|
|
36
|
+
const bridge = bridgeRef.current;
|
|
37
|
+
if (!bridge) {
|
|
38
|
+
return () => {
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return bridge.addEventListener(event, callback);
|
|
42
|
+
},
|
|
43
|
+
[]
|
|
44
|
+
);
|
|
45
|
+
const value = useMemo(
|
|
46
|
+
() => ({
|
|
47
|
+
send,
|
|
48
|
+
on,
|
|
49
|
+
isAvailable: bridgeRef.current?.isWebViewBridgeAvailable ?? false
|
|
50
|
+
}),
|
|
51
|
+
[send, on]
|
|
52
|
+
);
|
|
53
|
+
return /* @__PURE__ */ jsx(BridgeContext.Provider, { value, children });
|
|
54
|
+
}
|
|
55
|
+
function useBridge() {
|
|
56
|
+
const context = useContext(BridgeContext);
|
|
57
|
+
if (!context) {
|
|
58
|
+
throw new Error("useBridge must be used within a BridgeProvider");
|
|
59
|
+
}
|
|
60
|
+
return context;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// src/store.ts
|
|
64
|
+
import { useEffect, useRef as useRef2, useSyncExternalStore } from "react";
|
|
65
|
+
function createBridgeStore(initialState) {
|
|
66
|
+
let state = initialState;
|
|
67
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
68
|
+
return {
|
|
69
|
+
getSnapshot() {
|
|
70
|
+
return state;
|
|
71
|
+
},
|
|
72
|
+
getServerSnapshot() {
|
|
73
|
+
return initialState;
|
|
74
|
+
},
|
|
75
|
+
subscribe(listener) {
|
|
76
|
+
listeners.add(listener);
|
|
77
|
+
return () => listeners.delete(listener);
|
|
78
|
+
},
|
|
79
|
+
setState(next) {
|
|
80
|
+
const nextState = typeof next === "function" ? next(state) : next;
|
|
81
|
+
if (Object.is(state, nextState)) return;
|
|
82
|
+
state = nextState;
|
|
83
|
+
listeners.forEach((l) => l(state));
|
|
84
|
+
},
|
|
85
|
+
destroy() {
|
|
86
|
+
listeners.clear();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function useBridgeStore(store) {
|
|
91
|
+
return useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
|
|
92
|
+
}
|
|
93
|
+
function useBridgeStoreSelector(store, selector) {
|
|
94
|
+
return useSyncExternalStore(
|
|
95
|
+
store.subscribe,
|
|
96
|
+
() => selector(store.getSnapshot()),
|
|
97
|
+
() => selector(store.getServerSnapshot())
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
function useBridgeEvent(on, event, initialState, updater2) {
|
|
101
|
+
const storeRef = useRef2(null);
|
|
102
|
+
if (!storeRef.current) {
|
|
103
|
+
storeRef.current = createBridgeStore(initialState);
|
|
104
|
+
}
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
const store = storeRef.current;
|
|
107
|
+
const unsubscribe = on(event, (data) => {
|
|
108
|
+
store.setState((prev) => updater2(prev, data));
|
|
109
|
+
});
|
|
110
|
+
return unsubscribe;
|
|
111
|
+
}, [on, event, updater2]);
|
|
112
|
+
return useBridgeStore(storeRef.current);
|
|
113
|
+
}
|
|
114
|
+
function useBridgeEvents(on, initialState, bindings) {
|
|
115
|
+
const storeRef = useRef2(null);
|
|
116
|
+
if (!storeRef.current) {
|
|
117
|
+
storeRef.current = createBridgeStore(initialState);
|
|
118
|
+
}
|
|
119
|
+
const bindingsRef = useRef2(bindings);
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
const store = storeRef.current;
|
|
122
|
+
const unsubs = bindingsRef.current.map(
|
|
123
|
+
({ event, updater: updater2 }) => on(event, ((data) => {
|
|
124
|
+
store.setState((prev) => updater2(prev, data));
|
|
125
|
+
}))
|
|
126
|
+
);
|
|
127
|
+
return () => unsubs.forEach((u) => u());
|
|
128
|
+
}, [on]);
|
|
129
|
+
return useBridgeStore(storeRef.current);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/namespaces/useCamera.ts
|
|
133
|
+
import { useMemo as useMemo2 } from "react";
|
|
134
|
+
function useCamera() {
|
|
135
|
+
const { send } = useBridge();
|
|
136
|
+
return useMemo2(
|
|
137
|
+
() => ({
|
|
138
|
+
take: (opts) => send("camera.take", opts ?? {}),
|
|
139
|
+
pickImage: (opts) => send("camera.pickImage", opts ?? {})
|
|
140
|
+
}),
|
|
141
|
+
[send]
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// src/namespaces/useLocation.ts
|
|
146
|
+
import { useEffect as useEffect2, useMemo as useMemo3, useRef as useRef3 } from "react";
|
|
147
|
+
function useLocation() {
|
|
148
|
+
const { send } = useBridge();
|
|
149
|
+
return useMemo3(
|
|
150
|
+
() => ({
|
|
151
|
+
getCurrent: (opts) => send("location.getCurrent", opts ?? {}),
|
|
152
|
+
watchStart: (opts) => send("location.watchStart", opts ?? {}),
|
|
153
|
+
watchStop: (opts) => send("location.watchStop", opts)
|
|
154
|
+
}),
|
|
155
|
+
[send]
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
var updater = (_prev, data) => data;
|
|
159
|
+
function useLocationWatch(opts) {
|
|
160
|
+
const { send, on } = useBridge();
|
|
161
|
+
const watchIdRef = useRef3(null);
|
|
162
|
+
const location = useBridgeEvent(
|
|
163
|
+
on,
|
|
164
|
+
"location.update",
|
|
165
|
+
null,
|
|
166
|
+
updater
|
|
167
|
+
);
|
|
168
|
+
useEffect2(() => {
|
|
169
|
+
send("location.watchStart", opts ?? {}).then((res) => {
|
|
170
|
+
watchIdRef.current = res.watchId;
|
|
171
|
+
});
|
|
172
|
+
return () => {
|
|
173
|
+
if (watchIdRef.current) {
|
|
174
|
+
send("location.watchStop", { watchId: watchIdRef.current });
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
}, [send, opts]);
|
|
178
|
+
return location;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// src/namespaces/useFile.ts
|
|
182
|
+
import { useMemo as useMemo4 } from "react";
|
|
183
|
+
function useFile() {
|
|
184
|
+
const { send } = useBridge();
|
|
185
|
+
return useMemo4(
|
|
186
|
+
() => ({
|
|
187
|
+
download: (opts) => send("file.download", opts),
|
|
188
|
+
read: (opts) => send("file.read", opts),
|
|
189
|
+
write: (opts) => send("file.write", opts),
|
|
190
|
+
pick: (opts) => send("file.pick", opts ?? {})
|
|
191
|
+
}),
|
|
192
|
+
[send]
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// src/namespaces/useShare.ts
|
|
197
|
+
import { useMemo as useMemo5 } from "react";
|
|
198
|
+
function useShare() {
|
|
199
|
+
const { send } = useBridge();
|
|
200
|
+
return useMemo5(
|
|
201
|
+
() => ({
|
|
202
|
+
open: (opts) => send("share.open", opts ?? {})
|
|
203
|
+
}),
|
|
204
|
+
[send]
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// src/namespaces/useDevice.ts
|
|
209
|
+
import { useMemo as useMemo6 } from "react";
|
|
210
|
+
function useDevice() {
|
|
211
|
+
const { send } = useBridge();
|
|
212
|
+
return useMemo6(
|
|
213
|
+
() => ({
|
|
214
|
+
getInfo: () => send("device.getInfo", {}),
|
|
215
|
+
getBattery: () => send("device.getBattery", {}),
|
|
216
|
+
getNetwork: () => send("device.getNetwork", {})
|
|
217
|
+
}),
|
|
218
|
+
[send]
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// src/namespaces/useStatusBar.ts
|
|
223
|
+
import { useMemo as useMemo7 } from "react";
|
|
224
|
+
function useStatusBar() {
|
|
225
|
+
const { send } = useBridge();
|
|
226
|
+
return useMemo7(
|
|
227
|
+
() => ({
|
|
228
|
+
setStyle: (opts) => send("statusbar.setStyle", opts),
|
|
229
|
+
setBackgroundColor: (opts) => send("statusbar.setBackgroundColor", opts),
|
|
230
|
+
setHidden: (opts) => send("statusbar.setHidden", opts)
|
|
231
|
+
}),
|
|
232
|
+
[send]
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// src/namespaces/useKeyboard.ts
|
|
237
|
+
import { useCallback as useCallback2, useMemo as useMemo8 } from "react";
|
|
238
|
+
var INITIAL = { visible: false, height: 0 };
|
|
239
|
+
function useKeyboard() {
|
|
240
|
+
const { send, on } = useBridge();
|
|
241
|
+
const updater2 = useCallback2(
|
|
242
|
+
(_prev, data) => ({
|
|
243
|
+
visible: data.visible,
|
|
244
|
+
height: data.height
|
|
245
|
+
}),
|
|
246
|
+
[]
|
|
247
|
+
);
|
|
248
|
+
const state = useBridgeEvent(on, "keyboard.change", INITIAL, updater2);
|
|
249
|
+
const dismiss = useMemo8(() => () => send("keyboard.dismiss", {}), [send]);
|
|
250
|
+
return { visible: state.visible, height: state.height, dismiss };
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// src/namespaces/useHaptic.ts
|
|
254
|
+
import { useMemo as useMemo9 } from "react";
|
|
255
|
+
function useHaptic() {
|
|
256
|
+
const { send } = useBridge();
|
|
257
|
+
return useMemo9(
|
|
258
|
+
() => ({
|
|
259
|
+
impact: (opts) => send("haptic.impact", opts),
|
|
260
|
+
notification: (opts) => send("haptic.notification", opts),
|
|
261
|
+
selection: () => send("haptic.selection", {})
|
|
262
|
+
}),
|
|
263
|
+
[send]
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// src/namespaces/useClipboard.ts
|
|
268
|
+
import { useMemo as useMemo10 } from "react";
|
|
269
|
+
function useClipboard() {
|
|
270
|
+
const { send } = useBridge();
|
|
271
|
+
return useMemo10(
|
|
272
|
+
() => ({
|
|
273
|
+
copy: (opts) => send("clipboard.copy", opts),
|
|
274
|
+
paste: () => send("clipboard.paste", {})
|
|
275
|
+
}),
|
|
276
|
+
[send]
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// src/namespaces/useScanner.ts
|
|
281
|
+
import { useMemo as useMemo11 } from "react";
|
|
282
|
+
function useScanner() {
|
|
283
|
+
const { send } = useBridge();
|
|
284
|
+
return useMemo11(
|
|
285
|
+
() => ({
|
|
286
|
+
scanQR: (opts) => send("scanner.scanQR", opts ?? {})
|
|
287
|
+
}),
|
|
288
|
+
[send]
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// src/namespaces/useAuth.ts
|
|
293
|
+
import { useMemo as useMemo12 } from "react";
|
|
294
|
+
function useAuth() {
|
|
295
|
+
const { send } = useBridge();
|
|
296
|
+
return useMemo12(
|
|
297
|
+
() => ({
|
|
298
|
+
biometric: (opts) => send("auth.biometric", opts ?? {}),
|
|
299
|
+
isBiometricAvailable: () => send("auth.isBiometricAvailable", {})
|
|
300
|
+
}),
|
|
301
|
+
[send]
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// src/namespaces/useIAP.ts
|
|
306
|
+
import { useMemo as useMemo13 } from "react";
|
|
307
|
+
function useIAP() {
|
|
308
|
+
const { send } = useBridge();
|
|
309
|
+
return useMemo13(
|
|
310
|
+
() => ({
|
|
311
|
+
getProducts: (opts) => send("iap.getProducts", opts),
|
|
312
|
+
purchase: (opts) => send("iap.purchase", opts),
|
|
313
|
+
restore: () => send("iap.restore", {})
|
|
314
|
+
}),
|
|
315
|
+
[send]
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// src/namespaces/usePush.ts
|
|
320
|
+
import { useMemo as useMemo14 } from "react";
|
|
321
|
+
function usePush() {
|
|
322
|
+
const { send } = useBridge();
|
|
323
|
+
return useMemo14(
|
|
324
|
+
() => ({
|
|
325
|
+
getToken: () => send("push.getToken", {}),
|
|
326
|
+
requestPermission: () => send("push.requestPermission", {})
|
|
327
|
+
}),
|
|
328
|
+
[send]
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
var INITIAL2 = { lastReceived: null, lastTapped: null };
|
|
332
|
+
var BINDINGS = [
|
|
333
|
+
{
|
|
334
|
+
event: "push.received",
|
|
335
|
+
updater: (prev, data) => ({
|
|
336
|
+
...prev,
|
|
337
|
+
lastReceived: data
|
|
338
|
+
})
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
event: "push.tapped",
|
|
342
|
+
updater: (prev, data) => ({
|
|
343
|
+
...prev,
|
|
344
|
+
lastTapped: data
|
|
345
|
+
})
|
|
346
|
+
}
|
|
347
|
+
];
|
|
348
|
+
function usePushNotification() {
|
|
349
|
+
const { on } = useBridge();
|
|
350
|
+
const state = useBridgeEvents(on, INITIAL2, BINDINGS);
|
|
351
|
+
return { lastReceived: state.lastReceived, lastTapped: state.lastTapped };
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// src/namespaces/usePermission.ts
|
|
355
|
+
import { useMemo as useMemo15 } from "react";
|
|
356
|
+
function usePermission() {
|
|
357
|
+
const { send } = useBridge();
|
|
358
|
+
return useMemo15(
|
|
359
|
+
() => ({
|
|
360
|
+
check: (opts) => send("permission.check", opts),
|
|
361
|
+
request: (opts) => send("permission.request", opts),
|
|
362
|
+
openSettings: () => send("permission.openSettings", {})
|
|
363
|
+
}),
|
|
364
|
+
[send]
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// src/namespaces/usePreference.ts
|
|
369
|
+
import { useMemo as useMemo16 } from "react";
|
|
370
|
+
function usePreference() {
|
|
371
|
+
const { send } = useBridge();
|
|
372
|
+
return useMemo16(
|
|
373
|
+
() => ({
|
|
374
|
+
get: (opts) => send("preference.get", opts),
|
|
375
|
+
set: (opts) => send("preference.set", opts),
|
|
376
|
+
remove: (opts) => send("preference.remove", opts),
|
|
377
|
+
clear: () => send("preference.clear", {})
|
|
378
|
+
}),
|
|
379
|
+
[send]
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// src/namespaces/useNavigation.ts
|
|
384
|
+
import { useMemo as useMemo17 } from "react";
|
|
385
|
+
function useNavigation() {
|
|
386
|
+
const { send } = useBridge();
|
|
387
|
+
return useMemo17(
|
|
388
|
+
() => ({
|
|
389
|
+
goBack: () => send("navigation.goBack", {}),
|
|
390
|
+
push: (opts) => send("navigation.push", opts),
|
|
391
|
+
close: () => send("navigation.close", {}),
|
|
392
|
+
setSwipeBack: (opts) => send("navigation.setSwipeBack", opts)
|
|
393
|
+
}),
|
|
394
|
+
[send]
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// src/namespaces/useBrowser.ts
|
|
399
|
+
import { useMemo as useMemo18 } from "react";
|
|
400
|
+
function useBrowser() {
|
|
401
|
+
const { send } = useBridge();
|
|
402
|
+
return useMemo18(
|
|
403
|
+
() => ({
|
|
404
|
+
openExternal: (opts) => send("browser.openExternal", opts),
|
|
405
|
+
openInternal: (opts) => send("browser.openInternal", opts)
|
|
406
|
+
}),
|
|
407
|
+
[send]
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
export {
|
|
411
|
+
BridgeProvider,
|
|
412
|
+
createBridgeStore,
|
|
413
|
+
useAuth,
|
|
414
|
+
useBridge,
|
|
415
|
+
useBridgeEvent,
|
|
416
|
+
useBridgeEvents,
|
|
417
|
+
useBridgeStore,
|
|
418
|
+
useBridgeStoreSelector,
|
|
419
|
+
useBrowser,
|
|
420
|
+
useCamera,
|
|
421
|
+
useClipboard,
|
|
422
|
+
useDevice,
|
|
423
|
+
useFile,
|
|
424
|
+
useHaptic,
|
|
425
|
+
useIAP,
|
|
426
|
+
useKeyboard,
|
|
427
|
+
useLocation,
|
|
428
|
+
useLocationWatch,
|
|
429
|
+
useNavigation,
|
|
430
|
+
usePermission,
|
|
431
|
+
usePreference,
|
|
432
|
+
usePush,
|
|
433
|
+
usePushNotification,
|
|
434
|
+
useScanner,
|
|
435
|
+
useShare,
|
|
436
|
+
useStatusBar
|
|
437
|
+
};
|
|
438
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/provider.tsx","../src/store.ts","../src/namespaces/useCamera.ts","../src/namespaces/useLocation.ts","../src/namespaces/useFile.ts","../src/namespaces/useShare.ts","../src/namespaces/useDevice.ts","../src/namespaces/useStatusBar.ts","../src/namespaces/useKeyboard.ts","../src/namespaces/useHaptic.ts","../src/namespaces/useClipboard.ts","../src/namespaces/useScanner.ts","../src/namespaces/useAuth.ts","../src/namespaces/useIAP.ts","../src/namespaces/usePush.ts","../src/namespaces/usePermission.ts","../src/namespaces/usePreference.ts","../src/namespaces/useNavigation.ts","../src/namespaces/useBrowser.ts"],"sourcesContent":["import React, { createContext, useContext, useRef, useCallback, useMemo } from 'react';\nimport { linkBridge } from '@webview-bridge/web';\nimport type {\n BridgeToolsSchema,\n BridgeToolsAction,\n BridgeToolsEvents,\n BridgeToolsEvent,\n} from '@rn-bridge-tools/core';\n\ntype SendFn = <K extends BridgeToolsAction>(\n action: K,\n payload: BridgeToolsSchema[K]['request'],\n) => Promise<BridgeToolsSchema[K]['response']>;\n\ntype OnFn = <E extends BridgeToolsEvent>(\n event: E,\n callback: (data: BridgeToolsEvents[E]) => void,\n) => () => void;\n\nexport interface BridgeContextValue {\n send: SendFn;\n on: OnFn;\n isAvailable: boolean;\n}\n\nconst BridgeContext = createContext<BridgeContextValue | null>(null);\n\nexport interface BridgeProviderProps {\n children?: React.ReactNode | undefined;\n timeout?: number;\n debug?: boolean;\n onReady?: () => void;\n}\n\nexport function BridgeProvider({ children, timeout, debug, onReady }: BridgeProviderProps) {\n const bridgeRef = useRef<ReturnType<typeof linkBridge> | null>(null);\n const onReadyRef = useRef(onReady);\n onReadyRef.current = onReady;\n\n if (bridgeRef.current === null) {\n bridgeRef.current = linkBridge({\n timeout: timeout ?? 5000,\n debug: debug ?? false,\n throwOnError: false,\n onReady: () => {\n onReadyRef.current?.();\n },\n });\n }\n\n const send: SendFn = useCallback(\n async <K extends BridgeToolsAction>(\n action: K,\n payload: BridgeToolsSchema[K]['request'],\n ): Promise<BridgeToolsSchema[K]['response']> => {\n const bridge = bridgeRef.current;\n if (!bridge) {\n throw new Error('Bridge not initialized');\n }\n const method = (bridge as Record<string, (...args: unknown[]) => Promise<unknown>>)[action];\n if (typeof method !== 'function') {\n throw new Error(`Bridge method \"${action}\" is not available`);\n }\n return method(payload) as Promise<BridgeToolsSchema[K]['response']>;\n },\n [],\n );\n\n const on: OnFn = useCallback(\n <E extends BridgeToolsEvent>(\n event: E,\n callback: (data: BridgeToolsEvents[E]) => void,\n ): (() => void) => {\n const bridge = bridgeRef.current;\n if (!bridge) {\n return () => {};\n }\n return bridge.addEventListener(event, callback as (data: unknown) => void);\n },\n [],\n );\n\n const value = useMemo<BridgeContextValue>(\n () => ({\n send,\n on,\n isAvailable: bridgeRef.current?.isWebViewBridgeAvailable ?? false,\n }),\n [send, on],\n );\n\n return <BridgeContext.Provider value={value}>{children}</BridgeContext.Provider>;\n}\n\nexport function useBridge(): BridgeContextValue {\n const context = useContext(BridgeContext);\n if (!context) {\n throw new Error('useBridge must be used within a BridgeProvider');\n }\n return context;\n}\n","import { useEffect, useRef, useSyncExternalStore } from 'react';\nimport type { BridgeToolsEvents, BridgeToolsEvent } from '@rn-bridge-tools/core';\nimport type { BridgeContextValue } from './provider.js';\n\ntype Listener<T> = (state: T) => void;\n\n/**\n * Lightweight external store compatible with useSyncExternalStore.\n * Used for bridge event subscriptions (keyboard, location, push, etc.)\n */\nexport function createBridgeStore<T>(initialState: T) {\n let state = initialState;\n const listeners = new Set<Listener<T>>();\n\n return {\n getSnapshot(): T {\n return state;\n },\n getServerSnapshot(): T {\n return initialState;\n },\n subscribe(listener: () => void): () => void {\n listeners.add(listener as Listener<T>);\n return () => listeners.delete(listener as Listener<T>);\n },\n setState(next: T | ((prev: T) => T)): void {\n const nextState = typeof next === 'function' ? (next as (prev: T) => T)(state) : next;\n if (Object.is(state, nextState)) return;\n state = nextState;\n listeners.forEach((l) => l(state));\n },\n destroy(): void {\n listeners.clear();\n },\n };\n}\n\nexport type BridgeStore<T> = ReturnType<typeof createBridgeStore<T>>;\n\n/**\n * Hook that subscribes to a BridgeStore using useSyncExternalStore.\n * Concurrent Mode safe — no tearing.\n */\nexport function useBridgeStore<T>(store: BridgeStore<T>): T {\n return useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);\n}\n\n/**\n * Hook that subscribes to a BridgeStore with a selector.\n * Only re-renders when the selected value changes.\n */\nexport function useBridgeStoreSelector<T, S>(store: BridgeStore<T>, selector: (state: T) => S): S {\n return useSyncExternalStore(\n store.subscribe,\n () => selector(store.getSnapshot()),\n () => selector(store.getServerSnapshot()),\n );\n}\n\n/**\n * Subscribe to a single bridge event and sync to a store.\n * Returns the current snapshot via useSyncExternalStore.\n */\nexport function useBridgeEvent<T, E extends BridgeToolsEvent>(\n on: BridgeContextValue['on'],\n event: E,\n initialState: T,\n updater: (prev: T, data: BridgeToolsEvents[E]) => T,\n): T {\n const storeRef = useRef<BridgeStore<T> | null>(null);\n if (!storeRef.current) {\n storeRef.current = createBridgeStore<T>(initialState);\n }\n\n useEffect(() => {\n const store = storeRef.current!;\n const unsubscribe = on(event, (data) => {\n store.setState((prev) => updater(prev, data));\n });\n return unsubscribe;\n }, [on, event, updater]);\n\n return useBridgeStore(storeRef.current!);\n}\n\ntype EventBinding<T> = {\n event: BridgeToolsEvent;\n updater: (prev: T, data: never) => T;\n};\n\n/**\n * Subscribe to multiple bridge events and sync to a single store.\n * Returns the current snapshot via useSyncExternalStore.\n */\nexport function useBridgeEvents<T>(\n on: BridgeContextValue['on'],\n initialState: T,\n bindings: EventBinding<T>[],\n): T {\n const storeRef = useRef<BridgeStore<T> | null>(null);\n if (!storeRef.current) {\n storeRef.current = createBridgeStore<T>(initialState);\n }\n const bindingsRef = useRef(bindings);\n\n useEffect(() => {\n const store = storeRef.current!;\n const unsubs = bindingsRef.current.map(({ event, updater }) =>\n on(event as BridgeToolsEvent, ((data: never) => {\n store.setState((prev) => updater(prev, data));\n }) as (data: BridgeToolsEvents[typeof event]) => void),\n );\n return () => unsubs.forEach((u) => u());\n }, [on]);\n\n return useBridgeStore(storeRef.current!);\n}\n","import { useMemo } from 'react';\nimport type { CameraNamespace } from '@rn-bridge-tools/core';\nimport { useBridge } from '../provider.js';\n\nexport function useCamera() {\n const { send } = useBridge();\n return useMemo(\n () => ({\n take: (opts?: CameraNamespace['camera.take']['request']) =>\n send('camera.take', opts ?? {}),\n pickImage: (opts?: CameraNamespace['camera.pickImage']['request']) =>\n send('camera.pickImage', opts ?? {}),\n }),\n [send],\n );\n}\n","import { useEffect, useMemo, useRef } from 'react';\nimport type { LocationNamespace, LocationEvents } from '@rn-bridge-tools/core';\nimport { useBridge } from '../provider.js';\nimport { useBridgeEvent } from '../store.js';\n\nexport function useLocation() {\n const { send } = useBridge();\n return useMemo(\n () => ({\n getCurrent: (opts?: LocationNamespace['location.getCurrent']['request']) =>\n send('location.getCurrent', opts ?? {}),\n watchStart: (opts?: LocationNamespace['location.watchStart']['request']) =>\n send('location.watchStart', opts ?? {}),\n watchStop: (opts: LocationNamespace['location.watchStop']['request']) =>\n send('location.watchStop', opts),\n }),\n [send],\n );\n}\n\ntype LocationUpdate = LocationEvents['location.update'] | null;\n\nconst updater = (_prev: LocationUpdate, data: LocationEvents['location.update']): LocationUpdate =>\n data;\n\nexport function useLocationWatch(opts?: LocationNamespace['location.watchStart']['request']) {\n const { send, on } = useBridge();\n const watchIdRef = useRef<string | null>(null);\n\n const location = useBridgeEvent<LocationUpdate, 'location.update'>(\n on,\n 'location.update',\n null,\n updater,\n );\n\n useEffect(() => {\n send('location.watchStart', opts ?? {}).then((res) => {\n watchIdRef.current = res.watchId;\n });\n return () => {\n if (watchIdRef.current) {\n send('location.watchStop', { watchId: watchIdRef.current });\n }\n };\n }, [send, opts]);\n\n return location;\n}\n","import { useMemo } from 'react';\nimport type { FileNamespace } from '@rn-bridge-tools/core';\nimport { useBridge } from '../provider.js';\n\nexport function useFile() {\n const { send } = useBridge();\n return useMemo(\n () => ({\n download: (opts: FileNamespace['file.download']['request']) =>\n send('file.download', opts),\n read: (opts: FileNamespace['file.read']['request']) =>\n send('file.read', opts),\n write: (opts: FileNamespace['file.write']['request']) =>\n send('file.write', opts),\n pick: (opts?: FileNamespace['file.pick']['request']) =>\n send('file.pick', opts ?? {}),\n }),\n [send],\n );\n}\n","import { useMemo } from 'react';\nimport type { ShareNamespace } from '@rn-bridge-tools/core';\nimport { useBridge } from '../provider.js';\n\nexport function useShare() {\n const { send } = useBridge();\n return useMemo(\n () => ({\n open: (opts?: ShareNamespace['share.open']['request']) =>\n send('share.open', opts ?? {}),\n }),\n [send],\n );\n}\n","import { useMemo } from 'react';\nimport { useBridge } from '../provider.js';\n\nexport function useDevice() {\n const { send } = useBridge();\n return useMemo(\n () => ({\n getInfo: () => send('device.getInfo', {}),\n getBattery: () => send('device.getBattery', {}),\n getNetwork: () => send('device.getNetwork', {}),\n }),\n [send],\n );\n}\n","import { useMemo } from 'react';\nimport type { StatusBarNamespace } from '@rn-bridge-tools/core';\nimport { useBridge } from '../provider.js';\n\nexport function useStatusBar() {\n const { send } = useBridge();\n return useMemo(\n () => ({\n setStyle: (opts: StatusBarNamespace['statusbar.setStyle']['request']) =>\n send('statusbar.setStyle', opts),\n setBackgroundColor: (opts: StatusBarNamespace['statusbar.setBackgroundColor']['request']) =>\n send('statusbar.setBackgroundColor', opts),\n setHidden: (opts: StatusBarNamespace['statusbar.setHidden']['request']) =>\n send('statusbar.setHidden', opts),\n }),\n [send],\n );\n}\n","import { useCallback, useMemo } from 'react';\nimport { useBridge } from '../provider.js';\nimport { useBridgeEvent } from '../store.js';\n\ninterface KeyboardState {\n visible: boolean;\n height: number;\n}\n\nconst INITIAL: KeyboardState = { visible: false, height: 0 };\n\nexport function useKeyboard() {\n const { send, on } = useBridge();\n\n const updater = useCallback(\n (_prev: KeyboardState, data: { visible: boolean; height: number }) => ({\n visible: data.visible,\n height: data.height,\n }),\n [],\n );\n\n const state = useBridgeEvent(on, 'keyboard.change', INITIAL, updater);\n\n const dismiss = useMemo(() => () => send('keyboard.dismiss', {}), [send]);\n\n return { visible: state.visible, height: state.height, dismiss };\n}\n","import { useMemo } from 'react';\nimport type { HapticNamespace } from '@rn-bridge-tools/core';\nimport { useBridge } from '../provider.js';\n\nexport function useHaptic() {\n const { send } = useBridge();\n return useMemo(\n () => ({\n impact: (opts: HapticNamespace['haptic.impact']['request']) =>\n send('haptic.impact', opts),\n notification: (opts: HapticNamespace['haptic.notification']['request']) =>\n send('haptic.notification', opts),\n selection: () => send('haptic.selection', {}),\n }),\n [send],\n );\n}\n","import { useMemo } from 'react';\nimport type { ClipboardNamespace } from '@rn-bridge-tools/core';\nimport { useBridge } from '../provider.js';\n\nexport function useClipboard() {\n const { send } = useBridge();\n return useMemo(\n () => ({\n copy: (opts: ClipboardNamespace['clipboard.copy']['request']) =>\n send('clipboard.copy', opts),\n paste: () => send('clipboard.paste', {}),\n }),\n [send],\n );\n}\n","import { useMemo } from 'react';\nimport type { ScannerNamespace } from '@rn-bridge-tools/core';\nimport { useBridge } from '../provider.js';\n\nexport function useScanner() {\n const { send } = useBridge();\n return useMemo(\n () => ({\n scanQR: (opts?: ScannerNamespace['scanner.scanQR']['request']) =>\n send('scanner.scanQR', opts ?? {}),\n }),\n [send],\n );\n}\n","import { useMemo } from 'react';\nimport type { AuthNamespace } from '@rn-bridge-tools/core';\nimport { useBridge } from '../provider.js';\n\nexport function useAuth() {\n const { send } = useBridge();\n return useMemo(\n () => ({\n biometric: (opts?: AuthNamespace['auth.biometric']['request']) =>\n send('auth.biometric', opts ?? {}),\n isBiometricAvailable: () => send('auth.isBiometricAvailable', {}),\n }),\n [send],\n );\n}\n","import { useMemo } from 'react';\nimport type { IAPNamespace } from '@rn-bridge-tools/core';\nimport { useBridge } from '../provider.js';\n\nexport function useIAP() {\n const { send } = useBridge();\n return useMemo(\n () => ({\n getProducts: (opts: IAPNamespace['iap.getProducts']['request']) =>\n send('iap.getProducts', opts),\n purchase: (opts: IAPNamespace['iap.purchase']['request']) =>\n send('iap.purchase', opts),\n restore: () => send('iap.restore', {}),\n }),\n [send],\n );\n}\n","import { useMemo } from 'react';\nimport type { PushEvents } from '@rn-bridge-tools/core';\nimport { useBridge } from '../provider.js';\nimport { useBridgeEvents } from '../store.js';\n\nexport function usePush() {\n const { send } = useBridge();\n return useMemo(\n () => ({\n getToken: () => send('push.getToken', {}),\n requestPermission: () => send('push.requestPermission', {}),\n }),\n [send],\n );\n}\n\ninterface PushNotificationState {\n lastReceived: PushEvents['push.received'] | null;\n lastTapped: PushEvents['push.tapped'] | null;\n}\n\nconst INITIAL: PushNotificationState = { lastReceived: null, lastTapped: null };\n\nconst BINDINGS = [\n {\n event: 'push.received' as const,\n updater: (prev: PushNotificationState, data: PushEvents['push.received']) => ({\n ...prev,\n lastReceived: data,\n }),\n },\n {\n event: 'push.tapped' as const,\n updater: (prev: PushNotificationState, data: PushEvents['push.tapped']) => ({\n ...prev,\n lastTapped: data,\n }),\n },\n];\n\nexport function usePushNotification() {\n const { on } = useBridge();\n const state = useBridgeEvents(on, INITIAL, BINDINGS);\n return { lastReceived: state.lastReceived, lastTapped: state.lastTapped };\n}\n","import { useMemo } from 'react';\nimport type { PermissionNamespace } from '@rn-bridge-tools/core';\nimport { useBridge } from '../provider.js';\n\nexport function usePermission() {\n const { send } = useBridge();\n return useMemo(\n () => ({\n check: (opts: PermissionNamespace['permission.check']['request']) =>\n send('permission.check', opts),\n request: (opts: PermissionNamespace['permission.request']['request']) =>\n send('permission.request', opts),\n openSettings: () => send('permission.openSettings', {}),\n }),\n [send],\n );\n}\n","import { useMemo } from 'react';\nimport type { PreferenceNamespace } from '@rn-bridge-tools/core';\nimport { useBridge } from '../provider.js';\n\nexport function usePreference() {\n const { send } = useBridge();\n return useMemo(\n () => ({\n get: (opts: PreferenceNamespace['preference.get']['request']) =>\n send('preference.get', opts),\n set: (opts: PreferenceNamespace['preference.set']['request']) =>\n send('preference.set', opts),\n remove: (opts: PreferenceNamespace['preference.remove']['request']) =>\n send('preference.remove', opts),\n clear: () => send('preference.clear', {}),\n }),\n [send],\n );\n}\n","import { useMemo } from 'react';\nimport type { NavigationNamespace } from '@rn-bridge-tools/core';\nimport { useBridge } from '../provider.js';\n\nexport function useNavigation() {\n const { send } = useBridge();\n return useMemo(\n () => ({\n goBack: () => send('navigation.goBack', {}),\n push: (opts: NavigationNamespace['navigation.push']['request']) =>\n send('navigation.push', opts),\n close: () => send('navigation.close', {}),\n setSwipeBack: (opts: NavigationNamespace['navigation.setSwipeBack']['request']) =>\n send('navigation.setSwipeBack', opts),\n }),\n [send],\n );\n}\n","import { useMemo } from 'react';\nimport type { BrowserNamespace } from '@rn-bridge-tools/core';\nimport { useBridge } from '../provider.js';\n\nexport function useBrowser() {\n const { send } = useBridge();\n return useMemo(\n () => ({\n openExternal: (opts: BrowserNamespace['browser.openExternal']['request']) =>\n send('browser.openExternal', opts),\n openInternal: (opts: BrowserNamespace['browser.openInternal']['request']) =>\n send('browser.openInternal', opts),\n }),\n [send],\n );\n}\n"],"mappings":";AAAA,SAAgB,eAAe,YAAY,QAAQ,aAAa,eAAe;AAC/E,SAAS,kBAAkB;AA0FlB;AAlET,IAAM,gBAAgB,cAAyC,IAAI;AAS5D,SAAS,eAAe,EAAE,UAAU,SAAS,OAAO,QAAQ,GAAwB;AACzF,QAAM,YAAY,OAA6C,IAAI;AACnE,QAAM,aAAa,OAAO,OAAO;AACjC,aAAW,UAAU;AAErB,MAAI,UAAU,YAAY,MAAM;AAC9B,cAAU,UAAU,WAAW;AAAA,MAC7B,SAAS,WAAW;AAAA,MACpB,OAAO,SAAS;AAAA,MAChB,cAAc;AAAA,MACd,SAAS,MAAM;AACb,mBAAW,UAAU;AAAA,MACvB;AAAA,IACF,CAAC;AAAA,EACH;AAEA,QAAM,OAAe;AAAA,IACnB,OACE,QACA,YAC8C;AAC9C,YAAM,SAAS,UAAU;AACzB,UAAI,CAAC,QAAQ;AACX,cAAM,IAAI,MAAM,wBAAwB;AAAA,MAC1C;AACA,YAAM,SAAU,OAAoE,MAAM;AAC1F,UAAI,OAAO,WAAW,YAAY;AAChC,cAAM,IAAI,MAAM,kBAAkB,MAAM,oBAAoB;AAAA,MAC9D;AACA,aAAO,OAAO,OAAO;AAAA,IACvB;AA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OAAO;AAAA,MACL,cAAc,CAAC,SACb,KAAK,wBAAwB,IAAI;AAAA,MACnC,cAAc,CAAC,SACb,KAAK,wBAAwB,IAAI;AAAA,IACrC;AAAA,IACA,CAAC,IAAI;AAAA,EACP;AACF;","names":["useRef","updater","useMemo","useMemo","useEffect","useMemo","useRef","useMemo","useRef","useEffect","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useCallback","useMemo","updater","useCallback","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","INITIAL","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rn-bridge-tools/react",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "React hooks and provider for bridge-tools WebView communication",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.cts",
|
|
17
|
+
"default": "./dist/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"dev": "tsup --watch",
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"lint": "eslint src/",
|
|
29
|
+
"typecheck": "tsc --noEmit",
|
|
30
|
+
"clean": "rm -rf dist"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@rn-bridge-tools/core": "workspace:*"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@webview-bridge/web": ">=1.0.0",
|
|
37
|
+
"react": ">=18.0.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/react": "^18.3.0",
|
|
41
|
+
"@webview-bridge/web": "^1.7.0",
|
|
42
|
+
"eslint": "^9.0.0",
|
|
43
|
+
"react": "^18.3.0",
|
|
44
|
+
"tsup": "^8.3.0",
|
|
45
|
+
"typescript": "^5.7.0",
|
|
46
|
+
"vitest": "^2.1.0"
|
|
47
|
+
}
|
|
48
|
+
}
|