@apps-in-toss/native-modules 1.0.2 → 1.1.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.
Files changed (42) hide show
  1. package/dist/VisibilityChangedByTransparentServiceWebEvent-D6XJvPVh.d.cts +20 -0
  2. package/dist/VisibilityChangedByTransparentServiceWebEvent-D6XJvPVh.d.ts +20 -0
  3. package/dist/bridges-meta.json +24 -12
  4. package/dist/chunk-YS54L7RG.js +209 -0
  5. package/dist/index.cjs +209 -150
  6. package/dist/index.d.cts +662 -592
  7. package/dist/index.d.ts +662 -592
  8. package/dist/index.js +186 -128
  9. package/dist/private.cjs +236 -0
  10. package/dist/private.d.cts +17 -0
  11. package/dist/private.d.ts +17 -0
  12. package/dist/private.js +11 -0
  13. package/package.json +3 -2
  14. package/src/AppsInTossModule/native-event-emitter/StartUpdateLocationPermissionError.ts +1 -0
  15. package/src/AppsInTossModule/native-event-emitter/appsInTossEvent.ts +2 -0
  16. package/src/AppsInTossModule/native-event-emitter/event-plugins/HomeIconButtonClickHandleEvent.ts +10 -0
  17. package/src/AppsInTossModule/native-event-emitter/event-plugins/UpdateLocationEvent.ts +3 -3
  18. package/src/AppsInTossModule/native-event-emitter/index.ts +2 -0
  19. package/src/AppsInTossModule/native-event-emitter/internal/appBridge.ts +7 -1
  20. package/src/AppsInTossModule/native-event-emitter/startUpdateLocation.ts +64 -44
  21. package/src/AppsInTossModule/native-modules/AppsInTossModule.ts +22 -27
  22. package/src/AppsInTossModule/native-modules/ads/googleAdMobV2.ts +3 -3
  23. package/src/AppsInTossModule/native-modules/ads/types.ts +1 -1
  24. package/src/AppsInTossModule/native-modules/getPermission.ts +1 -1
  25. package/src/AppsInTossModule/native-modules/index.ts +9 -6
  26. package/src/AppsInTossModule/native-modules/permissions/createPermissionFunction.ts +25 -0
  27. package/src/AppsInTossModule/native-modules/permissions/fetchAlbumPhotos/fetchAlbumPhotos.ts +109 -0
  28. package/src/AppsInTossModule/native-modules/{fetchContacts.ts → permissions/fetchContacts/fetchContacts.ts} +51 -40
  29. package/src/AppsInTossModule/native-modules/permissions/getClipboardText/getClipboardText.ts +87 -0
  30. package/src/AppsInTossModule/native-modules/permissions/getCurrentLocation/getCurrentLocation.ts +88 -0
  31. package/src/AppsInTossModule/native-modules/permissions/openCamera/openCamera.ts +99 -0
  32. package/src/AppsInTossModule/native-modules/{openPermissionDialog.ts → permissions/openPermissionDialog.ts} +3 -3
  33. package/src/AppsInTossModule/native-modules/{requestPermission.ts → permissions/requestPermission.ts} +2 -2
  34. package/src/AppsInTossModule/native-modules/permissions/setClipboardText/setClipboardText.ts +75 -0
  35. package/src/AppsInTossModule/native-modules/saveBase64Data.ts +1 -1
  36. package/src/async-bridges.ts +9 -6
  37. package/src/types.ts +0 -106
  38. package/src/AppsInTossModule/native-modules/fetchAlbumPhotos.ts +0 -88
  39. package/src/AppsInTossModule/native-modules/getClipboardText.ts +0 -47
  40. package/src/AppsInTossModule/native-modules/getCurrentLocation.ts +0 -65
  41. package/src/AppsInTossModule/native-modules/openCamera.ts +0 -81
  42. package/src/AppsInTossModule/native-modules/setClipboardText.ts +0 -39
package/dist/index.js CHANGED
@@ -12,8 +12,20 @@ var EntryMessageExitedEvent = class extends GraniteEventDefinition {
12
12
  }
13
13
  };
14
14
 
15
- // src/AppsInTossModule/native-event-emitter/event-plugins/UpdateLocationEvent.ts
15
+ // src/AppsInTossModule/native-event-emitter/event-plugins/HomeIconButtonClickHandleEvent.ts
16
16
  import { GraniteEventDefinition as GraniteEventDefinition2 } from "@granite-js/react-native";
17
+ var HomeIconButtonClickHandleEvent = class extends GraniteEventDefinition2 {
18
+ name = "homeIconButtonClickEvent";
19
+ remove() {
20
+ }
21
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
22
+ listener(_) {
23
+ }
24
+ };
25
+
26
+ // src/AppsInTossModule/native-event-emitter/event-plugins/UpdateLocationEvent.ts
27
+ import { GetCurrentLocationPermissionError } from "@apps-in-toss/types";
28
+ import { GraniteEventDefinition as GraniteEventDefinition3 } from "@granite-js/react-native";
17
29
 
18
30
  // src/AppsInTossModule/native-modules/AppsInTossModule.ts
19
31
  import { TurboModuleRegistry } from "react-native";
@@ -21,17 +33,17 @@ var Module = TurboModuleRegistry.getEnforcing("AppsInTossModule");
21
33
  var AppsInTossModuleInstance = Module;
22
34
  var AppsInTossModule = Module;
23
35
 
36
+ // src/AppsInTossModule/native-modules/permissions/openPermissionDialog.ts
37
+ function openPermissionDialog(permission) {
38
+ return AppsInTossModule.openPermissionDialog(permission);
39
+ }
40
+
24
41
  // src/AppsInTossModule/native-modules/getPermission.ts
25
42
  function getPermission(permission) {
26
43
  return AppsInTossModule.getPermission(permission);
27
44
  }
28
45
 
29
- // src/AppsInTossModule/native-modules/openPermissionDialog.ts
30
- function openPermissionDialog(permission) {
31
- return AppsInTossModule.openPermissionDialog(permission);
32
- }
33
-
34
- // src/AppsInTossModule/native-modules/requestPermission.ts
46
+ // src/AppsInTossModule/native-modules/permissions/requestPermission.ts
35
47
  async function requestPermission(permission) {
36
48
  const permissionStatus = await getPermission(permission);
37
49
  switch (permissionStatus) {
@@ -48,7 +60,7 @@ import { NativeEventEmitter } from "react-native";
48
60
  var nativeEventEmitter = new NativeEventEmitter(AppsInTossModuleInstance);
49
61
 
50
62
  // src/AppsInTossModule/native-event-emitter/event-plugins/UpdateLocationEvent.ts
51
- var UpdateLocationEvent = class extends GraniteEventDefinition2 {
63
+ var UpdateLocationEvent = class extends GraniteEventDefinition3 {
52
64
  name = "updateLocationEvent";
53
65
  subscriptionCount = 0;
54
66
  ref = {
@@ -64,7 +76,7 @@ var UpdateLocationEvent = class extends GraniteEventDefinition2 {
64
76
  listener(options, onEvent, onError) {
65
77
  requestPermission({ name: "geolocation", access: "access" }).then((permissionStatus) => {
66
78
  if (permissionStatus === "denied") {
67
- onError(new Error("\uC704\uCE58 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694."));
79
+ onError(new GetCurrentLocationPermissionError());
68
80
  return;
69
81
  }
70
82
  void AppsInTossModuleInstance.startUpdateLocation(options).catch(onError);
@@ -78,7 +90,7 @@ var UpdateLocationEvent = class extends GraniteEventDefinition2 {
78
90
  };
79
91
 
80
92
  // src/AppsInTossModule/native-event-emitter/internal/AppBridgeCallbackEvent.ts
81
- import { GraniteEventDefinition as GraniteEventDefinition3 } from "@granite-js/react-native";
93
+ import { GraniteEventDefinition as GraniteEventDefinition4 } from "@granite-js/react-native";
82
94
 
83
95
  // src/utils/generateUUID.ts
84
96
  function generateUUID(placeholder) {
@@ -95,7 +107,12 @@ function invokeAppBridgeCallback(id, ...args) {
95
107
  function invokeAppBridgeMethod(methodName, params, callbacks) {
96
108
  const { onSuccess, onError, ...appBridgeCallbacks } = callbacks;
97
109
  const { callbackMap, unregisterAll } = registerCallbacks(appBridgeCallbacks);
98
- const promise = AppsInTossModuleInstance[methodName]({
110
+ const method = AppsInTossModuleInstance[methodName];
111
+ if (method == null) {
112
+ onError(new Error(`'${methodName}' is not defined in AppsInTossModule`));
113
+ return unregisterAll;
114
+ }
115
+ const promise = method({
99
116
  params,
100
117
  callbacks: callbackMap
101
118
  });
@@ -135,7 +152,7 @@ var INTERNAL__appBridgeHandler = {
135
152
 
136
153
  // src/AppsInTossModule/native-event-emitter/internal/AppBridgeCallbackEvent.ts
137
154
  var UNSAFE__nativeEventEmitter = nativeEventEmitter;
138
- var AppBridgeCallbackEvent = class _AppBridgeCallbackEvent extends GraniteEventDefinition3 {
155
+ var AppBridgeCallbackEvent = class _AppBridgeCallbackEvent extends GraniteEventDefinition4 {
139
156
  static INTERNAL__appBridgeSubscription;
140
157
  name = "appBridgeCallbackEvent";
141
158
  constructor() {
@@ -165,8 +182,8 @@ var AppBridgeCallbackEvent = class _AppBridgeCallbackEvent extends GraniteEventD
165
182
  };
166
183
 
167
184
  // src/AppsInTossModule/native-event-emitter/internal/VisibilityChangedByTransparentServiceWebEvent.ts
168
- import { GraniteEventDefinition as GraniteEventDefinition4 } from "@granite-js/react-native";
169
- var VisibilityChangedByTransparentServiceWebEvent = class extends GraniteEventDefinition4 {
185
+ import { GraniteEventDefinition as GraniteEventDefinition5 } from "@granite-js/react-native";
186
+ var VisibilityChangedByTransparentServiceWebEvent = class extends GraniteEventDefinition5 {
170
187
  name = "onVisibilityChangedByTransparentServiceWeb";
171
188
  subscription = null;
172
189
  remove() {
@@ -194,14 +211,18 @@ var VisibilityChangedByTransparentServiceWebEvent = class extends GraniteEventDe
194
211
  var appsInTossEvent = new GraniteEvent([
195
212
  new UpdateLocationEvent(),
196
213
  new EntryMessageExitedEvent(),
214
+ new HomeIconButtonClickHandleEvent(),
197
215
  // Internal events
198
216
  new AppBridgeCallbackEvent(),
199
217
  new VisibilityChangedByTransparentServiceWebEvent()
200
218
  ]);
201
219
 
202
- // src/AppsInTossModule/native-event-emitter/startUpdateLocation.ts
203
- function startUpdateLocation(eventParams) {
204
- return appsInTossEvent.addEventListener("updateLocationEvent", eventParams);
220
+ // src/AppsInTossModule/native-modules/ads/googleAdMob.ts
221
+ import { noop } from "es-toolkit";
222
+
223
+ // src/AppsInTossModule/native-modules/getOperationalEnvironment.ts
224
+ function getOperationalEnvironment() {
225
+ return AppsInTossModule.operationalEnvironment;
205
226
  }
206
227
 
207
228
  // src/AppsInTossModule/native-modules/isMinVersionSupported.ts
@@ -295,42 +316,6 @@ function isMinVersionSupported(minVersions) {
295
316
  return compareVersions(currentVersion, minVersion) >= 0;
296
317
  }
297
318
 
298
- // src/AppsInTossModule/native-event-emitter/contactsViral.ts
299
- function contactsViral(params) {
300
- const isSupported = isMinVersionSupported({
301
- android: "5.223.0",
302
- ios: "5.223.0"
303
- });
304
- if (!isSupported) {
305
- return () => {
306
- };
307
- }
308
- const { onEvent, onError, options } = params;
309
- const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("contactsViral", options, {
310
- onRewardFromContactsViral: (result) => {
311
- onEvent({ type: "sendViral", data: result });
312
- },
313
- onSuccess: (result) => {
314
- onEvent({ type: "close", data: result });
315
- },
316
- onError
317
- });
318
- return unregisterCallbacks;
319
- }
320
-
321
- // src/AppsInTossModule/native-event-emitter/internal/onVisibilityChangedByTransparentServiceWeb.ts
322
- function onVisibilityChangedByTransparentServiceWeb(eventParams) {
323
- return appsInTossEvent.addEventListener("onVisibilityChangedByTransparentServiceWeb", eventParams);
324
- }
325
-
326
- // src/AppsInTossModule/native-modules/ads/googleAdMob.ts
327
- import { noop } from "es-toolkit";
328
-
329
- // src/AppsInTossModule/native-modules/getOperationalEnvironment.ts
330
- function getOperationalEnvironment() {
331
- return AppsInTossModule.operationalEnvironment;
332
- }
333
-
334
319
  // src/AppsInTossModule/native-modules/ads/googleAdMob.ts
335
320
  function loadAdMobInterstitialAd(params) {
336
321
  if (!loadAdMobInterstitialAd.isSupported()) {
@@ -534,54 +519,118 @@ async function eventLog(params) {
534
519
  });
535
520
  }
536
521
 
537
- // src/AppsInTossModule/native-modules/fetchAlbumPhotos.ts
538
- var DEFAULT_MAX_COUNT = 10;
539
- var DEFAULT_MAX_WIDTH = 1024;
540
- async function fetchAlbumPhotos(options) {
541
- const permissionStatus = await requestPermission({ name: "photos", access: "read" });
542
- if (permissionStatus === "denied") {
543
- throw new Error("\uC0AC\uC9C4\uCCA9 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
544
- }
545
- const albumPhotos = await AppsInTossModule.fetchAlbumPhotos({
546
- ...options,
547
- maxCount: options.maxCount ?? DEFAULT_MAX_COUNT,
548
- maxWidth: options.maxWidth ?? DEFAULT_MAX_WIDTH
549
- });
550
- return albumPhotos;
551
- }
522
+ // src/AppsInTossModule/native-modules/permissions/fetchAlbumPhotos/fetchAlbumPhotos.ts
523
+ import { FetchAlbumPhotosPermissionError } from "@apps-in-toss/types";
552
524
 
553
- // src/AppsInTossModule/native-modules/fetchContacts.ts
554
- async function fetchContacts(options) {
555
- const permissionStatus = await requestPermission({ name: "contacts", access: "read" });
556
- if (permissionStatus === "denied") {
557
- throw new Error("\uC5F0\uB77D\uCC98 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
558
- }
559
- const contacts = await AppsInTossModule.fetchContacts(options);
560
- return {
561
- result: contacts.result,
562
- nextOffset: contacts.nextOffset ?? null,
563
- done: contacts.done
525
+ // src/AppsInTossModule/native-modules/permissions/createPermissionFunction.ts
526
+ function createPermissionFunction({
527
+ handler,
528
+ permission,
529
+ error
530
+ }) {
531
+ const permissionFunction = async (...args) => {
532
+ const permissionStatus = await requestPermission(permission);
533
+ if (permissionStatus === "denied") {
534
+ throw new error();
535
+ }
536
+ return handler(...args);
564
537
  };
538
+ permissionFunction.getPermission = () => getPermission(permission);
539
+ permissionFunction.openPermissionDialog = () => openPermissionDialog(permission);
540
+ return permissionFunction;
565
541
  }
566
542
 
567
- // src/AppsInTossModule/native-modules/getClipboardText.ts
568
- async function getClipboardText() {
569
- const permissionStatus = await requestPermission({ name: "clipboard", access: "read" });
570
- if (permissionStatus === "denied") {
571
- throw new Error("\uD074\uB9BD\uBCF4\uB4DC \uC77D\uAE30 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
572
- }
573
- return AppsInTossModule.getClipboardText({});
574
- }
575
-
576
- // src/AppsInTossModule/native-modules/getCurrentLocation.ts
577
- async function getCurrentLocation(options) {
578
- const permissionStatus = await requestPermission({ name: "geolocation", access: "access" });
579
- if (permissionStatus === "denied") {
580
- throw new Error("\uC704\uCE58 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
581
- }
582
- const position = await AppsInTossModule.getCurrentLocation(options);
583
- return position;
584
- }
543
+ // src/AppsInTossModule/native-modules/permissions/fetchAlbumPhotos/fetchAlbumPhotos.ts
544
+ var DEFAULT_MAX_COUNT = 10;
545
+ var DEFAULT_MAX_WIDTH = 1024;
546
+ var fetchAlbumPhotos = createPermissionFunction({
547
+ handler: async (options) => {
548
+ return AppsInTossModule.fetchAlbumPhotos({
549
+ ...options,
550
+ maxCount: options?.maxCount ?? DEFAULT_MAX_COUNT,
551
+ maxWidth: options?.maxWidth ?? DEFAULT_MAX_WIDTH
552
+ });
553
+ },
554
+ permission: {
555
+ name: "photos",
556
+ access: "read"
557
+ },
558
+ error: FetchAlbumPhotosPermissionError
559
+ });
560
+
561
+ // src/AppsInTossModule/native-modules/permissions/fetchContacts/fetchContacts.ts
562
+ import { FetchContactsPermissionError } from "@apps-in-toss/types";
563
+ var fetchContacts = createPermissionFunction({
564
+ handler: async (options) => {
565
+ const contacts = await AppsInTossModule.fetchContacts(options);
566
+ return {
567
+ result: contacts.result,
568
+ nextOffset: contacts.nextOffset ?? null,
569
+ done: contacts.done
570
+ };
571
+ },
572
+ permission: {
573
+ name: "contacts",
574
+ access: "read"
575
+ },
576
+ error: FetchContactsPermissionError
577
+ });
578
+
579
+ // src/AppsInTossModule/native-modules/permissions/getClipboardText/getClipboardText.ts
580
+ import { GetClipboardTextPermissionError } from "@apps-in-toss/types";
581
+ var getClipboardText = createPermissionFunction({
582
+ handler: () => {
583
+ return AppsInTossModule.getClipboardText({});
584
+ },
585
+ permission: {
586
+ name: "clipboard",
587
+ access: "read"
588
+ },
589
+ error: GetClipboardTextPermissionError
590
+ });
591
+
592
+ // src/AppsInTossModule/native-modules/permissions/getCurrentLocation/getCurrentLocation.ts
593
+ import { GetCurrentLocationPermissionError as GetCurrentLocationPermissionError2 } from "@apps-in-toss/types";
594
+ var getCurrentLocation = createPermissionFunction({
595
+ handler: async (options) => {
596
+ return AppsInTossModule.getCurrentLocation(options);
597
+ },
598
+ permission: {
599
+ name: "geolocation",
600
+ access: "access"
601
+ },
602
+ error: GetCurrentLocationPermissionError2
603
+ });
604
+
605
+ // src/AppsInTossModule/native-modules/permissions/setClipboardText/setClipboardText.ts
606
+ import { SetClipboardTextPermissionError } from "@apps-in-toss/types";
607
+ var setClipboardText = createPermissionFunction({
608
+ handler: (text) => {
609
+ return AppsInTossModule.setClipboardText({ text });
610
+ },
611
+ permission: {
612
+ name: "clipboard",
613
+ access: "write"
614
+ },
615
+ error: SetClipboardTextPermissionError
616
+ });
617
+
618
+ // src/AppsInTossModule/native-modules/permissions/openCamera/openCamera.ts
619
+ import { OpenCameraPermissionError } from "@apps-in-toss/types";
620
+ var openCamera = createPermissionFunction({
621
+ handler: (options) => {
622
+ return AppsInTossModule.openCamera({
623
+ base64: false,
624
+ maxWidth: 1024,
625
+ ...options
626
+ });
627
+ },
628
+ permission: {
629
+ name: "camera",
630
+ access: "access"
631
+ },
632
+ error: OpenCameraPermissionError
633
+ });
585
634
 
586
635
  // src/AppsInTossModule/native-modules/getDeviceId.ts
587
636
  function getDeviceId() {
@@ -628,16 +677,6 @@ var IAP = {
628
677
  getProductItemList
629
678
  };
630
679
 
631
- // src/AppsInTossModule/native-modules/openCamera.ts
632
- async function openCamera(options) {
633
- const permissionStatus = await requestPermission({ name: "camera", access: "access" });
634
- if (permissionStatus === "denied") {
635
- throw new Error("\uCE74\uBA54\uB77C \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
636
- }
637
- const photo = await AppsInTossModule.openCamera({ base64: false, maxWidth: 1024, ...options });
638
- return photo;
639
- }
640
-
641
680
  // src/AppsInTossModule/native-modules/saveBase64Data.ts
642
681
  async function saveBase64Data(params) {
643
682
  const isSupported = isMinVersionSupported({
@@ -651,15 +690,6 @@ async function saveBase64Data(params) {
651
690
  await AppsInTossModule.saveBase64Data(params);
652
691
  }
653
692
 
654
- // src/AppsInTossModule/native-modules/setClipboardText.ts
655
- async function setClipboardText(text) {
656
- const permissionStatus = await requestPermission({ name: "clipboard", access: "write" });
657
- if (permissionStatus === "denied") {
658
- throw new Error("\uD074\uB9BD\uBCF4\uB4DC \uC4F0\uAE30 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
659
- }
660
- return AppsInTossModule.setClipboardText({ text });
661
- }
662
-
663
693
  // src/AppsInTossModule/native-modules/setDeviceOrientation.ts
664
694
  async function setDeviceOrientation(options) {
665
695
  const isSupported = isMinVersionSupported({
@@ -737,6 +767,29 @@ async function submitGameCenterLeaderBoardScore(params) {
737
767
  return AppsInTossModule.submitGameCenterLeaderBoardScore(params);
738
768
  }
739
769
 
770
+ // src/AppsInTossModule/native-event-emitter/contactsViral.ts
771
+ function contactsViral(params) {
772
+ const isSupported = isMinVersionSupported({
773
+ android: "5.223.0",
774
+ ios: "5.223.0"
775
+ });
776
+ if (!isSupported) {
777
+ return () => {
778
+ };
779
+ }
780
+ const { onEvent, onError, options } = params;
781
+ const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("contactsViral", options, {
782
+ onRewardFromContactsViral: (result) => {
783
+ onEvent({ type: "sendViral", data: result });
784
+ },
785
+ onSuccess: (result) => {
786
+ onEvent({ type: "close", data: result });
787
+ },
788
+ onError
789
+ });
790
+ return unregisterCallbacks;
791
+ }
792
+
740
793
  // src/AppsInTossModule/native-modules/index.ts
741
794
  var TossPay = {
742
795
  checkoutPayment
@@ -750,6 +803,21 @@ var GoogleAdMob = {
750
803
  showAppsInTossAdMob
751
804
  };
752
805
 
806
+ // src/AppsInTossModule/native-event-emitter/startUpdateLocation.ts
807
+ function startUpdateLocation(eventParams) {
808
+ return appsInTossEvent.addEventListener("updateLocationEvent", eventParams);
809
+ }
810
+ startUpdateLocation.openPermissionDialog = getCurrentLocation.openPermissionDialog;
811
+ startUpdateLocation.getPermission = getCurrentLocation.getPermission;
812
+
813
+ // src/AppsInTossModule/native-event-emitter/StartUpdateLocationPermissionError.ts
814
+ import { StartUpdateLocationPermissionError } from "@apps-in-toss/types";
815
+
816
+ // src/AppsInTossModule/native-event-emitter/internal/onVisibilityChangedByTransparentServiceWeb.ts
817
+ function onVisibilityChangedByTransparentServiceWeb(eventParams) {
818
+ return appsInTossEvent.addEventListener("onVisibilityChangedByTransparentServiceWeb", eventParams);
819
+ }
820
+
753
821
  // src/BedrockModule/native-modules/natives/BedrockModule.ts
754
822
  import { NativeModules } from "react-native";
755
823
  var BedrockModule = NativeModules.BedrockModule;
@@ -826,17 +894,6 @@ function getPlatformOS() {
826
894
  import { NativeModules as NativeModules2 } from "react-native";
827
895
  var BedrockCoreModule = NativeModules2.BedrockCoreModule;
828
896
 
829
- // src/types.ts
830
- var Accuracy = /* @__PURE__ */ ((Accuracy2) => {
831
- Accuracy2[Accuracy2["Lowest"] = 1] = "Lowest";
832
- Accuracy2[Accuracy2["Low"] = 2] = "Low";
833
- Accuracy2[Accuracy2["Balanced"] = 3] = "Balanced";
834
- Accuracy2[Accuracy2["High"] = 4] = "High";
835
- Accuracy2[Accuracy2["Highest"] = 5] = "Highest";
836
- Accuracy2[Accuracy2["BestForNavigation"] = 6] = "BestForNavigation";
837
- return Accuracy2;
838
- })(Accuracy || {});
839
-
840
897
  // src/AppsInTossModule/native-modules/tossCore.ts
841
898
  import { NativeModules as NativeModules3 } from "react-native";
842
899
  var TossCoreModule = NativeModules3.TossCoreModule;
@@ -860,14 +917,15 @@ var INTERNAL__module = {
860
917
  tossCoreEventLog
861
918
  };
862
919
  export {
863
- Accuracy,
864
920
  AppsInTossModule,
865
921
  BedrockCoreModule,
866
922
  BedrockModule,
867
923
  GoogleAdMob,
868
924
  IAP,
869
925
  AppsInTossModuleInstance as INTERNAL__AppsInTossModule,
926
+ INTERNAL__appBridgeHandler,
870
927
  INTERNAL__module,
928
+ StartUpdateLocationPermissionError,
871
929
  Storage,
872
930
  TossPay,
873
931
  appLogin,
@@ -0,0 +1,236 @@
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/private.ts
21
+ var private_exports = {};
22
+ __export(private_exports, {
23
+ onVisibilityChangedByTransparentServiceWeb: () => onVisibilityChangedByTransparentServiceWeb
24
+ });
25
+ module.exports = __toCommonJS(private_exports);
26
+
27
+ // src/AppsInTossModule/native-event-emitter/appsInTossEvent.ts
28
+ var import_react_native7 = require("@granite-js/react-native");
29
+
30
+ // src/AppsInTossModule/native-event-emitter/event-plugins/EntryMessageExitedEvent.ts
31
+ var import_react_native = require("@granite-js/react-native");
32
+ var EntryMessageExitedEvent = class extends import_react_native.GraniteEventDefinition {
33
+ name = "entryMessageExited";
34
+ remove() {
35
+ }
36
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
37
+ listener(_) {
38
+ }
39
+ };
40
+
41
+ // src/AppsInTossModule/native-event-emitter/event-plugins/UpdateLocationEvent.ts
42
+ var import_react_native4 = require("@granite-js/react-native");
43
+
44
+ // src/AppsInTossModule/native-modules/AppsInTossModule.ts
45
+ var import_react_native2 = require("react-native");
46
+ var Module = import_react_native2.TurboModuleRegistry.getEnforcing("AppsInTossModule");
47
+ var AppsInTossModuleInstance = Module;
48
+ var AppsInTossModule = Module;
49
+
50
+ // src/AppsInTossModule/native-modules/getPermission.ts
51
+ function getPermission(permission) {
52
+ return AppsInTossModule.getPermission(permission);
53
+ }
54
+
55
+ // src/AppsInTossModule/native-modules/openPermissionDialog.ts
56
+ function openPermissionDialog(permission) {
57
+ return AppsInTossModule.openPermissionDialog(permission);
58
+ }
59
+
60
+ // src/AppsInTossModule/native-modules/requestPermission.ts
61
+ async function requestPermission(permission) {
62
+ const permissionStatus = await getPermission(permission);
63
+ switch (permissionStatus) {
64
+ case "allowed":
65
+ case "denied":
66
+ return permissionStatus;
67
+ default:
68
+ return openPermissionDialog(permission);
69
+ }
70
+ }
71
+
72
+ // src/AppsInTossModule/native-event-emitter/nativeEventEmitter.ts
73
+ var import_react_native3 = require("react-native");
74
+ var nativeEventEmitter = new import_react_native3.NativeEventEmitter(AppsInTossModuleInstance);
75
+
76
+ // src/AppsInTossModule/native-event-emitter/event-plugins/UpdateLocationEvent.ts
77
+ var UpdateLocationEvent = class extends import_react_native4.GraniteEventDefinition {
78
+ name = "updateLocationEvent";
79
+ subscriptionCount = 0;
80
+ ref = {
81
+ remove: () => {
82
+ }
83
+ };
84
+ remove() {
85
+ if (--this.subscriptionCount === 0) {
86
+ AppsInTossModuleInstance.stopUpdateLocation({});
87
+ }
88
+ this.ref.remove();
89
+ }
90
+ listener(options, onEvent, onError) {
91
+ requestPermission({ name: "geolocation", access: "access" }).then((permissionStatus) => {
92
+ if (permissionStatus === "denied") {
93
+ onError(new Error("\uC704\uCE58 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694."));
94
+ return;
95
+ }
96
+ void AppsInTossModuleInstance.startUpdateLocation(options).catch(onError);
97
+ const subscription = nativeEventEmitter.addListener("updateLocation", onEvent);
98
+ this.ref = {
99
+ remove: () => subscription?.remove()
100
+ };
101
+ this.subscriptionCount++;
102
+ }).catch(onError);
103
+ }
104
+ };
105
+
106
+ // src/AppsInTossModule/native-event-emitter/internal/AppBridgeCallbackEvent.ts
107
+ var import_react_native5 = require("@granite-js/react-native");
108
+
109
+ // src/utils/generateUUID.ts
110
+ function generateUUID(placeholder) {
111
+ return placeholder ? (placeholder ^ Math.random() * 16 >> placeholder / 4).toString(16) : (String(1e7) + 1e3 + 4e3 + 8e3 + 1e11).replace(/[018]/g, generateUUID);
112
+ }
113
+
114
+ // src/AppsInTossModule/native-event-emitter/internal/appBridge.ts
115
+ var INTERNAL__callbacks = /* @__PURE__ */ new Map();
116
+ function invokeAppBridgeCallback(id, ...args) {
117
+ const callback = INTERNAL__callbacks.get(id);
118
+ callback?.call(null, ...args);
119
+ return Boolean(callback);
120
+ }
121
+ function invokeAppBridgeMethod(methodName, params, callbacks) {
122
+ const { onSuccess, onError, ...appBridgeCallbacks } = callbacks;
123
+ const { callbackMap, unregisterAll } = registerCallbacks(appBridgeCallbacks);
124
+ const promise = AppsInTossModuleInstance[methodName]({
125
+ params,
126
+ callbacks: callbackMap
127
+ });
128
+ void promise.then(onSuccess).catch(onError);
129
+ return unregisterAll;
130
+ }
131
+ function registerCallbacks(callbacks) {
132
+ const callbackMap = {};
133
+ for (const [callbackName, callback] of Object.entries(callbacks)) {
134
+ const id = registerCallback(callback, callbackName);
135
+ callbackMap[callbackName] = id;
136
+ }
137
+ const unregisterAll = () => {
138
+ Object.values(callbackMap).forEach(unregisterCallback);
139
+ };
140
+ return { callbackMap, unregisterAll };
141
+ }
142
+ function registerCallback(callback, name = "unnamed") {
143
+ const uniqueId = generateUUID();
144
+ const callbackId = `${uniqueId}__${name}`;
145
+ INTERNAL__callbacks.set(callbackId, callback);
146
+ return callbackId;
147
+ }
148
+ function unregisterCallback(id) {
149
+ INTERNAL__callbacks.delete(id);
150
+ }
151
+ function getCallbackIds() {
152
+ return Array.from(INTERNAL__callbacks.keys());
153
+ }
154
+ var INTERNAL__appBridgeHandler = {
155
+ invokeAppBridgeCallback,
156
+ invokeAppBridgeMethod,
157
+ registerCallback,
158
+ unregisterCallback,
159
+ getCallbackIds
160
+ };
161
+
162
+ // src/AppsInTossModule/native-event-emitter/internal/AppBridgeCallbackEvent.ts
163
+ var UNSAFE__nativeEventEmitter = nativeEventEmitter;
164
+ var AppBridgeCallbackEvent = class _AppBridgeCallbackEvent extends import_react_native5.GraniteEventDefinition {
165
+ static INTERNAL__appBridgeSubscription;
166
+ name = "appBridgeCallbackEvent";
167
+ constructor() {
168
+ super();
169
+ this.registerAppBridgeCallbackEventListener();
170
+ }
171
+ remove() {
172
+ }
173
+ listener() {
174
+ }
175
+ registerAppBridgeCallbackEventListener() {
176
+ if (_AppBridgeCallbackEvent.INTERNAL__appBridgeSubscription != null) {
177
+ return;
178
+ }
179
+ _AppBridgeCallbackEvent.INTERNAL__appBridgeSubscription = UNSAFE__nativeEventEmitter.addListener(
180
+ "appBridgeCallback",
181
+ this.ensureInvokeAppBridgeCallback
182
+ );
183
+ }
184
+ ensureInvokeAppBridgeCallback(result) {
185
+ if (typeof result === "object" && typeof result.name === "string") {
186
+ INTERNAL__appBridgeHandler.invokeAppBridgeCallback(result.name, result.params);
187
+ } else {
188
+ console.warn("Invalid app bridge callback result:", result);
189
+ }
190
+ }
191
+ };
192
+
193
+ // src/AppsInTossModule/native-event-emitter/internal/VisibilityChangedByTransparentServiceWebEvent.ts
194
+ var import_react_native6 = require("@granite-js/react-native");
195
+ var VisibilityChangedByTransparentServiceWebEvent = class extends import_react_native6.GraniteEventDefinition {
196
+ name = "onVisibilityChangedByTransparentServiceWeb";
197
+ subscription = null;
198
+ remove() {
199
+ this.subscription?.remove();
200
+ this.subscription = null;
201
+ }
202
+ listener(options, onEvent, onError) {
203
+ const subscription = nativeEventEmitter.addListener("visibilityChangedByTransparentServiceWeb", (params) => {
204
+ if (this.isVisibilityChangedByTransparentServiceWebResult(params)) {
205
+ if (params.callbackId === options.callbackId) {
206
+ onEvent(params.isVisible);
207
+ }
208
+ } else {
209
+ onError(new Error("Invalid visibility changed by transparent service web result"));
210
+ }
211
+ });
212
+ this.subscription = subscription;
213
+ }
214
+ isVisibilityChangedByTransparentServiceWebResult(params) {
215
+ return typeof params === "object" && typeof params.callbackId === "string" && typeof params.isVisible === "boolean";
216
+ }
217
+ };
218
+
219
+ // src/AppsInTossModule/native-event-emitter/appsInTossEvent.ts
220
+ var appsInTossEvent = new import_react_native7.GraniteEvent([
221
+ new AppBridgeCallbackEvent(),
222
+ new UpdateLocationEvent(),
223
+ new EntryMessageExitedEvent(),
224
+ // Internal events
225
+ new AppBridgeCallbackEvent(),
226
+ new VisibilityChangedByTransparentServiceWebEvent()
227
+ ]);
228
+
229
+ // src/AppsInTossModule/native-event-emitter/internal/onVisibilityChangedByTransparentServiceWeb.ts
230
+ function onVisibilityChangedByTransparentServiceWeb(eventParams) {
231
+ return appsInTossEvent.addEventListener("onVisibilityChangedByTransparentServiceWeb", eventParams);
232
+ }
233
+ // Annotate the CommonJS export names for ESM import in node:
234
+ 0 && (module.exports = {
235
+ onVisibilityChangedByTransparentServiceWeb
236
+ });