@rn-bridge-tools/expo 0.0.3 → 0.0.5

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.js CHANGED
@@ -1,12 +1,56 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ WebViewBridge: () => WebViewBridge,
24
+ authHandlers: () => authHandlers,
25
+ browserHandlers: () => browserHandlers,
26
+ cameraHandlers: () => cameraHandlers,
27
+ clipboardHandlers: () => clipboardHandlers,
28
+ createDefaultHandlers: () => createDefaultHandlers,
29
+ deviceHandlers: () => deviceHandlers,
30
+ fileHandlers: () => fileHandlers,
31
+ hapticHandlers: () => hapticHandlers,
32
+ iapHandlers: () => iapHandlers,
33
+ keyboardHandlers: () => keyboardHandlers,
34
+ locationHandlers: () => locationHandlers,
35
+ navigationHandlers: () => navigationHandlers,
36
+ permissionHandlers: () => permissionHandlers,
37
+ preferenceHandlers: () => preferenceHandlers,
38
+ pushHandlers: () => pushHandlers,
39
+ scannerHandlers: () => scannerHandlers,
40
+ shareHandlers: () => shareHandlers,
41
+ statusbarHandlers: () => statusbarHandlers
42
+ });
43
+ module.exports = __toCommonJS(index_exports);
44
+
1
45
  // src/WebViewBridge.tsx
2
- import { forwardRef, useImperativeHandle, useMemo, useRef } from "react";
3
- import { bridge, createWebView } from "@webview-bridge/react-native";
4
- import { jsx } from "react/jsx-runtime";
5
- var WebViewBridge = forwardRef(
46
+ var import_react = require("react");
47
+ var import_react_native = require("@webview-bridge/react-native");
48
+ var import_jsx_runtime = require("react/jsx-runtime");
49
+ var WebViewBridge = (0, import_react.forwardRef)(
6
50
  function WebViewBridge2({ handlers, customHandlers, ...webViewProps }, ref) {
7
- const handlersRef = useRef(handlers);
8
- const customRef = useRef(customHandlers);
9
- const { InternalWebView, postMessage } = useMemo(() => {
51
+ const handlersRef = (0, import_react.useRef)(handlers);
52
+ const customRef = (0, import_react.useRef)(customHandlers);
53
+ const { InternalWebView, postMessage } = (0, import_react.useMemo)(() => {
10
54
  const allHandlers = {};
11
55
  const mergedHandlers = { ...handlersRef.current, ...customRef.current };
12
56
  for (const [key, handler] of Object.entries(mergedHandlers)) {
@@ -17,14 +61,14 @@ var WebViewBridge = forwardRef(
17
61
  };
18
62
  }
19
63
  }
20
- const appBridge = bridge(allHandlers);
21
- const result = createWebView({
64
+ const appBridge = (0, import_react_native.bridge)(allHandlers);
65
+ const result = (0, import_react_native.createWebView)({
22
66
  bridge: appBridge,
23
67
  debug: __DEV__ ?? false
24
68
  });
25
69
  return { InternalWebView: result.WebView, postMessage: result.postMessage };
26
70
  }, []);
27
- useImperativeHandle(
71
+ (0, import_react.useImperativeHandle)(
28
72
  ref,
29
73
  () => ({
30
74
  emit: (event, data) => {
@@ -33,16 +77,19 @@ var WebViewBridge = forwardRef(
33
77
  }),
34
78
  [postMessage]
35
79
  );
36
- return /* @__PURE__ */ jsx(InternalWebView, { ...webViewProps });
80
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InternalWebView, { ...webViewProps });
37
81
  }
38
82
  );
39
83
 
40
84
  // src/handlers/camera.ts
41
- import { moduleNotInstalledError, tryImport } from "@rn-bridge-tools/core";
42
85
  var cameraHandlers = {
43
86
  "camera.take": async (payload) => {
44
- const ImagePicker = await tryImport("expo-image-picker");
45
- if (!ImagePicker) return moduleNotInstalledError("expo-image-picker");
87
+ let ImagePicker = null;
88
+ try {
89
+ ImagePicker = require("expo-image-picker");
90
+ } catch {
91
+ }
92
+ if (!ImagePicker) return { success: false, error: "MODULE_NOT_INSTALLED: expo-image-picker" };
46
93
  const result = await ImagePicker.launchCameraAsync({
47
94
  quality: payload.quality ?? 0.8,
48
95
  cameraType: payload.facing === "front" ? ImagePicker.CameraType.front : ImagePicker.CameraType.back,
@@ -62,8 +109,12 @@ var cameraHandlers = {
62
109
  };
63
110
  },
64
111
  "camera.pickImage": async (payload) => {
65
- const ImagePicker = await tryImport("expo-image-picker");
66
- if (!ImagePicker) return moduleNotInstalledError("expo-image-picker");
112
+ let ImagePicker = null;
113
+ try {
114
+ ImagePicker = require("expo-image-picker");
115
+ } catch {
116
+ }
117
+ if (!ImagePicker) return { success: false, error: "MODULE_NOT_INSTALLED: expo-image-picker" };
67
118
  const result = await ImagePicker.launchImageLibraryAsync({
68
119
  allowsMultipleSelection: payload.allowsMultipleSelection ?? false,
69
120
  quality: payload.quality ?? 0.8,
@@ -86,13 +137,16 @@ var cameraHandlers = {
86
137
  };
87
138
 
88
139
  // src/handlers/location.ts
89
- import { moduleNotInstalledError as moduleNotInstalledError2, tryImport as tryImport2 } from "@rn-bridge-tools/core";
90
140
  var watchSubscriptions = /* @__PURE__ */ new Map();
91
141
  var watchCounter = 0;
92
142
  var locationHandlers = {
93
143
  "location.getCurrent": async (payload) => {
94
- const Location = await tryImport2("expo-location");
95
- if (!Location) return moduleNotInstalledError2("expo-location");
144
+ let Location = null;
145
+ try {
146
+ Location = require("expo-location");
147
+ } catch {
148
+ }
149
+ if (!Location) return { success: false, error: "MODULE_NOT_INSTALLED: expo-location" };
96
150
  const accuracyMap = {
97
151
  lowest: Location.Accuracy.Lowest,
98
152
  low: Location.Accuracy.Low,
@@ -112,8 +166,12 @@ var locationHandlers = {
112
166
  };
113
167
  },
114
168
  "location.watchStart": async (payload) => {
115
- const Location = await tryImport2("expo-location");
116
- if (!Location) return moduleNotInstalledError2("expo-location");
169
+ let Location = null;
170
+ try {
171
+ Location = require("expo-location");
172
+ } catch {
173
+ }
174
+ if (!Location) return { success: false, error: "MODULE_NOT_INSTALLED: expo-location" };
117
175
  watchCounter += 1;
118
176
  const watchId = `watch_${watchCounter}`;
119
177
  const accuracyMap = {
@@ -145,11 +203,14 @@ var locationHandlers = {
145
203
  };
146
204
 
147
205
  // src/handlers/file.ts
148
- import { moduleNotInstalledError as moduleNotInstalledError3, tryImport as tryImport3 } from "@rn-bridge-tools/core";
149
206
  var fileHandlers = {
150
207
  "file.download": async (payload) => {
151
- const FS = await tryImport3("expo-file-system");
152
- if (!FS) return moduleNotInstalledError3("expo-file-system");
208
+ let FS = null;
209
+ try {
210
+ FS = require("expo-file-system");
211
+ } catch {
212
+ }
213
+ if (!FS) return { success: false, error: "MODULE_NOT_INSTALLED: expo-file-system" };
153
214
  try {
154
215
  const response = await fetch(payload.url);
155
216
  const text = await response.text();
@@ -161,8 +222,12 @@ var fileHandlers = {
161
222
  }
162
223
  },
163
224
  "file.read": async (payload) => {
164
- const FS = await tryImport3("expo-file-system");
165
- if (!FS) return moduleNotInstalledError3("expo-file-system");
225
+ let FS = null;
226
+ try {
227
+ FS = require("expo-file-system");
228
+ } catch {
229
+ }
230
+ if (!FS) return { success: false, error: "MODULE_NOT_INSTALLED: expo-file-system" };
166
231
  try {
167
232
  const file = new FS.File(payload.uri);
168
233
  const content = await file.text();
@@ -172,8 +237,12 @@ var fileHandlers = {
172
237
  }
173
238
  },
174
239
  "file.write": async (payload) => {
175
- const FS = await tryImport3("expo-file-system");
176
- if (!FS) return moduleNotInstalledError3("expo-file-system");
240
+ let FS = null;
241
+ try {
242
+ FS = require("expo-file-system");
243
+ } catch {
244
+ }
245
+ if (!FS) return { success: false, error: "MODULE_NOT_INSTALLED: expo-file-system" };
177
246
  try {
178
247
  const dirMap = {
179
248
  document: FS.Paths.document,
@@ -189,8 +258,12 @@ var fileHandlers = {
189
258
  }
190
259
  },
191
260
  "file.pick": async (payload) => {
192
- const DocumentPicker = await tryImport3("expo-document-picker");
193
- if (!DocumentPicker) return moduleNotInstalledError3("expo-document-picker");
261
+ let DocumentPicker = null;
262
+ try {
263
+ DocumentPicker = require("expo-document-picker");
264
+ } catch {
265
+ }
266
+ if (!DocumentPicker) return { success: false, error: "MODULE_NOT_INSTALLED: expo-document-picker" };
194
267
  try {
195
268
  const result = await DocumentPicker.getDocumentAsync({
196
269
  type: payload.type ?? ["*/*"],
@@ -215,11 +288,14 @@ var fileHandlers = {
215
288
  };
216
289
 
217
290
  // src/handlers/share.ts
218
- import { moduleNotInstalledError as moduleNotInstalledError4, tryImport as tryImport4 } from "@rn-bridge-tools/core";
219
291
  var shareHandlers = {
220
292
  "share.open": async (payload) => {
221
- const Sharing = await tryImport4("expo-sharing");
222
- if (!Sharing) return moduleNotInstalledError4("expo-sharing");
293
+ let Sharing = null;
294
+ try {
295
+ Sharing = require("expo-sharing");
296
+ } catch {
297
+ }
298
+ if (!Sharing) return { success: false, error: "MODULE_NOT_INSTALLED: expo-sharing" };
223
299
  try {
224
300
  const isAvailable = await Sharing.isAvailableAsync();
225
301
  if (!isAvailable) {
@@ -236,15 +312,18 @@ var shareHandlers = {
236
312
  };
237
313
 
238
314
  // src/handlers/device.ts
239
- import { moduleNotInstalledError as moduleNotInstalledError5, tryImport as tryImport5 } from "@rn-bridge-tools/core";
240
- import { Platform } from "react-native";
315
+ var import_react_native2 = require("react-native");
241
316
  var deviceHandlers = {
242
317
  "device.getInfo": async (_payload) => {
243
- const Device = await tryImport5("expo-device");
244
- if (!Device) return moduleNotInstalledError5("expo-device");
318
+ let Device = null;
319
+ try {
320
+ Device = require("expo-device");
321
+ } catch {
322
+ }
323
+ if (!Device) return { success: false, error: "MODULE_NOT_INSTALLED: expo-device" };
245
324
  return {
246
- os: Platform.OS,
247
- osVersion: Platform.Version?.toString() ?? "",
325
+ os: import_react_native2.Platform.OS,
326
+ osVersion: import_react_native2.Platform.Version?.toString() ?? "",
248
327
  model: Device.modelName ?? "",
249
328
  brand: Device.brand ?? "",
250
329
  isTablet: Device.deviceType === Device.DeviceType.TABLET,
@@ -255,7 +334,11 @@ var deviceHandlers = {
255
334
  },
256
335
  "device.getBattery": async (_payload) => {
257
336
  try {
258
- const Battery = await tryImport5("expo-battery");
337
+ let Battery = null;
338
+ try {
339
+ Battery = require("expo-battery");
340
+ } catch {
341
+ }
259
342
  if (!Battery) {
260
343
  return { level: -1, isCharging: false };
261
344
  }
@@ -271,7 +354,11 @@ var deviceHandlers = {
271
354
  },
272
355
  "device.getNetwork": async (_payload) => {
273
356
  try {
274
- const NetInfo = await tryImport5("@react-native-community/netinfo");
357
+ let NetInfo = null;
358
+ try {
359
+ NetInfo = require("@react-native-community/netinfo");
360
+ } catch {
361
+ }
275
362
  if (!NetInfo) {
276
363
  return { type: "unknown", isConnected: true };
277
364
  }
@@ -287,7 +374,7 @@ var deviceHandlers = {
287
374
  };
288
375
 
289
376
  // src/handlers/statusbar.ts
290
- import { StatusBar } from "react-native";
377
+ var import_react_native3 = require("react-native");
291
378
  var statusbarHandlers = {
292
379
  "statusbar.setStyle": async (payload) => {
293
380
  const styleMap = {
@@ -295,11 +382,11 @@ var statusbarHandlers = {
295
382
  dark: "dark-content",
296
383
  auto: "default"
297
384
  };
298
- StatusBar.setBarStyle(styleMap[payload.style] ?? "default");
385
+ import_react_native3.StatusBar.setBarStyle(styleMap[payload.style] ?? "default");
299
386
  return { success: true };
300
387
  },
301
388
  "statusbar.setBackgroundColor": async (payload) => {
302
- StatusBar.setBackgroundColor(payload.color, payload.animated ?? false);
389
+ import_react_native3.StatusBar.setBackgroundColor(payload.color, payload.animated ?? false);
303
390
  return { success: true };
304
391
  },
305
392
  "statusbar.setHidden": async (payload) => {
@@ -308,16 +395,16 @@ var statusbarHandlers = {
308
395
  slide: "slide",
309
396
  none: "none"
310
397
  };
311
- StatusBar.setHidden(payload.hidden, animationMap[payload.animation ?? "none"]);
398
+ import_react_native3.StatusBar.setHidden(payload.hidden, animationMap[payload.animation ?? "none"]);
312
399
  return { success: true };
313
400
  }
314
401
  };
315
402
 
316
403
  // src/handlers/keyboard.ts
317
- import { Keyboard } from "react-native";
404
+ var import_react_native4 = require("react-native");
318
405
  var keyboardHandlers = {
319
406
  "keyboard.dismiss": async (_payload) => {
320
- Keyboard.dismiss();
407
+ import_react_native4.Keyboard.dismiss();
321
408
  return { success: true };
322
409
  },
323
410
  "keyboard.getState": async (_payload) => {
@@ -329,12 +416,14 @@ var keyboardHandlers = {
329
416
  };
330
417
 
331
418
  // src/handlers/haptic.ts
332
- import { moduleNotInstalledError as moduleNotInstalledError6, tryImport as tryImport6 } from "@rn-bridge-tools/core";
333
419
  var hapticHandlers = {
334
420
  "haptic.impact": async (payload) => {
335
- const Haptics = await tryImport6("expo-haptics");
421
+ let Haptics = null;
422
+ try {
423
+ Haptics = require("expo-haptics");
424
+ } catch {
425
+ }
336
426
  if (!Haptics) {
337
- moduleNotInstalledError6("expo-haptics");
338
427
  return;
339
428
  }
340
429
  const styleMap = {
@@ -345,9 +434,12 @@ var hapticHandlers = {
345
434
  await Haptics.impactAsync(styleMap[payload.style]);
346
435
  },
347
436
  "haptic.notification": async (payload) => {
348
- const Haptics = await tryImport6("expo-haptics");
437
+ let Haptics = null;
438
+ try {
439
+ Haptics = require("expo-haptics");
440
+ } catch {
441
+ }
349
442
  if (!Haptics) {
350
- moduleNotInstalledError6("expo-haptics");
351
443
  return;
352
444
  }
353
445
  const typeMap = {
@@ -358,9 +450,12 @@ var hapticHandlers = {
358
450
  await Haptics.notificationAsync(typeMap[payload.type]);
359
451
  },
360
452
  "haptic.selection": async () => {
361
- const Haptics = await tryImport6("expo-haptics");
453
+ let Haptics = null;
454
+ try {
455
+ Haptics = require("expo-haptics");
456
+ } catch {
457
+ }
362
458
  if (!Haptics) {
363
- moduleNotInstalledError6("expo-haptics");
364
459
  return;
365
460
  }
366
461
  await Haptics.selectionAsync();
@@ -368,28 +463,38 @@ var hapticHandlers = {
368
463
  };
369
464
 
370
465
  // src/handlers/clipboard.ts
371
- import { moduleNotInstalledError as moduleNotInstalledError7, tryImport as tryImport7 } from "@rn-bridge-tools/core";
372
466
  var clipboardHandlers = {
373
467
  "clipboard.copy": async (payload) => {
374
- const Clipboard = await tryImport7("expo-clipboard");
375
- if (!Clipboard) return moduleNotInstalledError7("expo-clipboard");
468
+ let Clipboard = null;
469
+ try {
470
+ Clipboard = require("expo-clipboard");
471
+ } catch {
472
+ }
473
+ if (!Clipboard) return { success: false, error: "MODULE_NOT_INSTALLED: expo-clipboard" };
376
474
  await Clipboard.setStringAsync(payload.text);
377
475
  return { success: true };
378
476
  },
379
477
  "clipboard.paste": async (_payload) => {
380
- const Clipboard = await tryImport7("expo-clipboard");
381
- if (!Clipboard) return moduleNotInstalledError7("expo-clipboard");
478
+ let Clipboard = null;
479
+ try {
480
+ Clipboard = require("expo-clipboard");
481
+ } catch {
482
+ }
483
+ if (!Clipboard) return { success: false, error: "MODULE_NOT_INSTALLED: expo-clipboard" };
382
484
  const text = await Clipboard.getStringAsync();
383
485
  return { text, hasContent: text.length > 0 };
384
486
  }
385
487
  };
386
488
 
387
489
  // src/handlers/scanner.ts
388
- import { moduleNotInstalledError as moduleNotInstalledError8, tryImport as tryImport8 } from "@rn-bridge-tools/core";
389
490
  var scannerHandlers = {
390
491
  "scanner.scanQR": async (_payload) => {
391
- const Camera = await tryImport8("expo-camera");
392
- if (!Camera) return moduleNotInstalledError8("expo-camera");
492
+ let Camera = null;
493
+ try {
494
+ Camera = require("expo-camera");
495
+ } catch {
496
+ }
497
+ if (!Camera) return { success: false, error: "MODULE_NOT_INSTALLED: expo-camera" };
393
498
  try {
394
499
  const { status } = await Camera.Camera.requestCameraPermissionsAsync();
395
500
  if (status !== "granted") {
@@ -403,11 +508,14 @@ var scannerHandlers = {
403
508
  };
404
509
 
405
510
  // src/handlers/auth.ts
406
- import { moduleNotInstalledError as moduleNotInstalledError9, tryImport as tryImport9 } from "@rn-bridge-tools/core";
407
511
  var authHandlers = {
408
512
  "auth.biometric": async (payload) => {
409
- const LocalAuth = await tryImport9("expo-local-authentication");
410
- if (!LocalAuth) return moduleNotInstalledError9("expo-local-authentication");
513
+ let LocalAuth = null;
514
+ try {
515
+ LocalAuth = require("expo-local-authentication");
516
+ } catch {
517
+ }
518
+ if (!LocalAuth) return { success: false, error: "MODULE_NOT_INSTALLED: expo-local-authentication" };
411
519
  try {
412
520
  const result = await LocalAuth.authenticateAsync({
413
521
  promptMessage: payload.promptMessage ?? "Authenticate",
@@ -423,8 +531,12 @@ var authHandlers = {
423
531
  }
424
532
  },
425
533
  "auth.isBiometricAvailable": async (_payload) => {
426
- const LocalAuth = await tryImport9("expo-local-authentication");
427
- if (!LocalAuth) return moduleNotInstalledError9("expo-local-authentication");
534
+ let LocalAuth = null;
535
+ try {
536
+ LocalAuth = require("expo-local-authentication");
537
+ } catch {
538
+ }
539
+ if (!LocalAuth) return { success: false, error: "MODULE_NOT_INSTALLED: expo-local-authentication" };
428
540
  try {
429
541
  const available = await LocalAuth.hasHardwareAsync();
430
542
  const types = await LocalAuth.supportedAuthenticationTypesAsync();
@@ -457,25 +569,32 @@ var iapHandlers = {
457
569
  };
458
570
 
459
571
  // src/handlers/push.ts
460
- import { moduleNotInstalledError as moduleNotInstalledError10, tryImport as tryImport10 } from "@rn-bridge-tools/core";
461
- import { Platform as Platform2 } from "react-native";
572
+ var import_react_native5 = require("react-native");
462
573
  var pushHandlers = {
463
574
  "push.getToken": async (_payload) => {
464
- const Notifications = await tryImport10("expo-notifications");
465
- if (!Notifications) return moduleNotInstalledError10("expo-notifications");
575
+ let Notifications = null;
576
+ try {
577
+ Notifications = require("expo-notifications");
578
+ } catch {
579
+ }
580
+ if (!Notifications) return { success: false, error: "MODULE_NOT_INSTALLED: expo-notifications" };
466
581
  try {
467
582
  const token = await Notifications.getExpoPushTokenAsync();
468
583
  return {
469
584
  token: token.data,
470
- platform: Platform2.OS === "ios" ? "apns" : "fcm"
585
+ platform: import_react_native5.Platform.OS === "ios" ? "apns" : "fcm"
471
586
  };
472
587
  } catch {
473
- return { token: "", platform: Platform2.OS === "ios" ? "apns" : "fcm" };
588
+ return { token: "", platform: import_react_native5.Platform.OS === "ios" ? "apns" : "fcm" };
474
589
  }
475
590
  },
476
591
  "push.requestPermission": async (_payload) => {
477
- const Notifications = await tryImport10("expo-notifications");
478
- if (!Notifications) return moduleNotInstalledError10("expo-notifications");
592
+ let Notifications = null;
593
+ try {
594
+ Notifications = require("expo-notifications");
595
+ } catch {
596
+ }
597
+ if (!Notifications) return { success: false, error: "MODULE_NOT_INSTALLED: expo-notifications" };
479
598
  try {
480
599
  const { status } = await Notifications.requestPermissionsAsync();
481
600
  return {
@@ -489,26 +608,37 @@ var pushHandlers = {
489
608
  };
490
609
 
491
610
  // src/handlers/permission.ts
492
- import { Linking } from "react-native";
493
- import { tryImport as tryImport11 } from "@rn-bridge-tools/core";
494
- async function getPermissionModule(permission) {
611
+ var import_react_native6 = require("react-native");
612
+ function getPermissionModule(permission) {
495
613
  switch (permission) {
496
614
  case "camera": {
497
- const mod = await tryImport11("expo-camera");
615
+ let mod = null;
616
+ try {
617
+ mod = require("expo-camera");
618
+ } catch {
619
+ }
498
620
  return mod ? {
499
621
  check: () => mod.Camera.getCameraPermissionsAsync(),
500
622
  request: () => mod.Camera.requestCameraPermissionsAsync()
501
623
  } : null;
502
624
  }
503
625
  case "location": {
504
- const mod = await tryImport11("expo-location");
626
+ let mod = null;
627
+ try {
628
+ mod = require("expo-location");
629
+ } catch {
630
+ }
505
631
  return mod ? {
506
632
  check: () => mod.getForegroundPermissionsAsync(),
507
633
  request: () => mod.requestForegroundPermissionsAsync()
508
634
  } : null;
509
635
  }
510
636
  case "notifications": {
511
- const mod = await tryImport11("expo-notifications");
637
+ let mod = null;
638
+ try {
639
+ mod = require("expo-notifications");
640
+ } catch {
641
+ }
512
642
  return mod ? {
513
643
  check: () => mod.getPermissionsAsync(),
514
644
  request: () => mod.requestPermissionsAsync()
@@ -520,7 +650,7 @@ async function getPermissionModule(permission) {
520
650
  }
521
651
  var permissionHandlers = {
522
652
  "permission.check": async (payload) => {
523
- const mod = await getPermissionModule(payload.permission);
653
+ const mod = getPermissionModule(payload.permission);
524
654
  if (!mod) {
525
655
  return { status: "undetermined", canAskAgain: true };
526
656
  }
@@ -535,7 +665,7 @@ var permissionHandlers = {
535
665
  }
536
666
  },
537
667
  "permission.request": async (payload) => {
538
- const mod = await getPermissionModule(payload.permission);
668
+ const mod = getPermissionModule(payload.permission);
539
669
  if (!mod) {
540
670
  return { status: "undetermined", canAskAgain: true };
541
671
  }
@@ -551,7 +681,7 @@ var permissionHandlers = {
551
681
  },
552
682
  "permission.openSettings": async (_payload) => {
553
683
  try {
554
- await Linking.openSettings();
684
+ await import_react_native6.Linking.openSettings();
555
685
  return { success: true };
556
686
  } catch {
557
687
  return { success: false };
@@ -560,28 +690,43 @@ var permissionHandlers = {
560
690
  };
561
691
 
562
692
  // src/handlers/preference.ts
563
- import { tryImport as tryImport12 } from "@rn-bridge-tools/core";
564
693
  var preferenceHandlers = {
565
694
  "preference.get": async (payload) => {
566
- const mod = await tryImport12("@react-native-async-storage/async-storage");
695
+ let mod = null;
696
+ try {
697
+ mod = require("@react-native-async-storage/async-storage");
698
+ } catch {
699
+ }
567
700
  if (!mod) return { value: null };
568
701
  const value = await mod.default.getItem(payload.key);
569
702
  return { value };
570
703
  },
571
704
  "preference.set": async (payload) => {
572
- const mod = await tryImport12("@react-native-async-storage/async-storage");
705
+ let mod = null;
706
+ try {
707
+ mod = require("@react-native-async-storage/async-storage");
708
+ } catch {
709
+ }
573
710
  if (!mod) return { success: false };
574
711
  await mod.default.setItem(payload.key, payload.value);
575
712
  return { success: true };
576
713
  },
577
714
  "preference.remove": async (payload) => {
578
- const mod = await tryImport12("@react-native-async-storage/async-storage");
715
+ let mod = null;
716
+ try {
717
+ mod = require("@react-native-async-storage/async-storage");
718
+ } catch {
719
+ }
579
720
  if (!mod) return { success: false };
580
721
  await mod.default.removeItem(payload.key);
581
722
  return { success: true };
582
723
  },
583
724
  "preference.clear": async (_payload) => {
584
- const mod = await tryImport12("@react-native-async-storage/async-storage");
725
+ let mod = null;
726
+ try {
727
+ mod = require("@react-native-async-storage/async-storage");
728
+ } catch {
729
+ }
585
730
  if (!mod) return { success: false };
586
731
  await mod.default.clear();
587
732
  return { success: true };
@@ -605,20 +750,23 @@ var navigationHandlers = {
605
750
  };
606
751
 
607
752
  // src/handlers/browser.ts
608
- import { moduleNotInstalledError as moduleNotInstalledError11, tryImport as tryImport13 } from "@rn-bridge-tools/core";
609
- import { Linking as Linking2 } from "react-native";
753
+ var import_react_native7 = require("react-native");
610
754
  var browserHandlers = {
611
755
  "browser.openExternal": async (payload) => {
612
756
  try {
613
- await Linking2.openURL(payload.url);
757
+ await import_react_native7.Linking.openURL(payload.url);
614
758
  return { success: true };
615
759
  } catch {
616
760
  return { success: false };
617
761
  }
618
762
  },
619
763
  "browser.openInternal": async (payload) => {
620
- const WebBrowser = await tryImport13("expo-web-browser");
621
- if (!WebBrowser) return moduleNotInstalledError11("expo-web-browser");
764
+ let WebBrowser = null;
765
+ try {
766
+ WebBrowser = require("expo-web-browser");
767
+ } catch {
768
+ }
769
+ if (!WebBrowser) return { success: false, error: "MODULE_NOT_INSTALLED: expo-web-browser" };
622
770
  try {
623
771
  await WebBrowser.openBrowserAsync(payload.url, {
624
772
  showTitle: payload.showTitle,
@@ -672,7 +820,8 @@ function createDefaultHandlers(options = {}) {
672
820
  }
673
821
  return result;
674
822
  }
675
- export {
823
+ // Annotate the CommonJS export names for ESM import in node:
824
+ 0 && (module.exports = {
676
825
  WebViewBridge,
677
826
  authHandlers,
678
827
  browserHandlers,
@@ -692,5 +841,5 @@ export {
692
841
  scannerHandlers,
693
842
  shareHandlers,
694
843
  statusbarHandlers
695
- };
844
+ });
696
845
  //# sourceMappingURL=index.js.map