@apps-in-toss/native-modules 1.1.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,20 +1,9 @@
1
1
  // src/AppsInTossModule/native-event-emitter/appsInTossEvent.ts
2
2
  import { GraniteEvent } from "@granite-js/react-native";
3
3
 
4
- // src/AppsInTossModule/native-event-emitter/event-plugins/BackButtonClickHandleEvent.ts
5
- import { GraniteEventDefinition } from "@granite-js/react-native";
6
- var BackButtonClickHandleEvent = class extends GraniteEventDefinition {
7
- name = "backButtonClickEvent";
8
- remove() {
9
- }
10
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
- listener(_) {
12
- }
13
- };
14
-
15
4
  // src/AppsInTossModule/native-event-emitter/event-plugins/EntryMessageExitedEvent.ts
16
- import { GraniteEventDefinition as GraniteEventDefinition2 } from "@granite-js/react-native";
17
- var EntryMessageExitedEvent = class extends GraniteEventDefinition2 {
5
+ import { GraniteEventDefinition } from "@granite-js/react-native";
6
+ var EntryMessageExitedEvent = class extends GraniteEventDefinition {
18
7
  name = "entryMessageExited";
19
8
  remove() {
20
9
  }
@@ -23,20 +12,9 @@ var EntryMessageExitedEvent = class extends GraniteEventDefinition2 {
23
12
  }
24
13
  };
25
14
 
26
- // src/AppsInTossModule/native-event-emitter/event-plugins/HomeIconButtonClickHandleEvent.ts
27
- import { GraniteEventDefinition as GraniteEventDefinition3 } from "@granite-js/react-native";
28
- var HomeIconButtonClickHandleEvent = class extends GraniteEventDefinition3 {
29
- name = "homeIconButtonClickEvent";
30
- remove() {
31
- }
32
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
- listener(_) {
34
- }
35
- };
36
-
37
15
  // src/AppsInTossModule/native-event-emitter/event-plugins/UpdateLocationEvent.ts
38
16
  import { GetCurrentLocationPermissionError } from "@apps-in-toss/types";
39
- import { GraniteEventDefinition as GraniteEventDefinition4 } from "@granite-js/react-native";
17
+ import { GraniteEventDefinition as GraniteEventDefinition2 } from "@granite-js/react-native";
40
18
 
41
19
  // src/AppsInTossModule/native-modules/AppsInTossModule.ts
42
20
  import { TurboModuleRegistry } from "react-native";
@@ -71,7 +49,7 @@ import { NativeEventEmitter } from "react-native";
71
49
  var nativeEventEmitter = new NativeEventEmitter(AppsInTossModuleInstance);
72
50
 
73
51
  // src/AppsInTossModule/native-event-emitter/event-plugins/UpdateLocationEvent.ts
74
- var UpdateLocationEvent = class extends GraniteEventDefinition4 {
52
+ var UpdateLocationEvent = class extends GraniteEventDefinition2 {
75
53
  name = "updateLocationEvent";
76
54
  subscriptionCount = 0;
77
55
  ref = {
@@ -101,7 +79,7 @@ var UpdateLocationEvent = class extends GraniteEventDefinition4 {
101
79
  };
102
80
 
103
81
  // src/AppsInTossModule/native-event-emitter/internal/AppBridgeCallbackEvent.ts
104
- import { GraniteEventDefinition as GraniteEventDefinition5 } from "@granite-js/react-native";
82
+ import { GraniteEventDefinition as GraniteEventDefinition3 } from "@granite-js/react-native";
105
83
 
106
84
  // src/utils/generateUUID.ts
107
85
  function generateUUID(placeholder) {
@@ -163,7 +141,7 @@ var INTERNAL__appBridgeHandler = {
163
141
 
164
142
  // src/AppsInTossModule/native-event-emitter/internal/AppBridgeCallbackEvent.ts
165
143
  var UNSAFE__nativeEventEmitter = nativeEventEmitter;
166
- var AppBridgeCallbackEvent = class _AppBridgeCallbackEvent extends GraniteEventDefinition5 {
144
+ var AppBridgeCallbackEvent = class _AppBridgeCallbackEvent extends GraniteEventDefinition3 {
167
145
  static INTERNAL__appBridgeSubscription;
168
146
  name = "appBridgeCallbackEvent";
169
147
  constructor() {
@@ -193,8 +171,8 @@ var AppBridgeCallbackEvent = class _AppBridgeCallbackEvent extends GraniteEventD
193
171
  };
194
172
 
195
173
  // src/AppsInTossModule/native-event-emitter/internal/VisibilityChangedByTransparentServiceWebEvent.ts
196
- import { GraniteEventDefinition as GraniteEventDefinition6 } from "@granite-js/react-native";
197
- var VisibilityChangedByTransparentServiceWebEvent = class extends GraniteEventDefinition6 {
174
+ import { GraniteEventDefinition as GraniteEventDefinition4 } from "@granite-js/react-native";
175
+ var VisibilityChangedByTransparentServiceWebEvent = class extends GraniteEventDefinition4 {
198
176
  name = "onVisibilityChangedByTransparentServiceWeb";
199
177
  subscription = null;
200
178
  remove() {
@@ -222,9 +200,6 @@ var VisibilityChangedByTransparentServiceWebEvent = class extends GraniteEventDe
222
200
  var appsInTossEvent = new GraniteEvent([
223
201
  new UpdateLocationEvent(),
224
202
  new EntryMessageExitedEvent(),
225
- // Navigation Bar events
226
- new HomeIconButtonClickHandleEvent(),
227
- new BackButtonClickHandleEvent(),
228
203
  // Internal events
229
204
  new AppBridgeCallbackEvent(),
230
205
  new VisibilityChangedByTransparentServiceWebEvent()
@@ -433,16 +408,33 @@ showAdMobRewardedAd.isSupported = createIsSupported();
433
408
 
434
409
  // src/AppsInTossModule/native-modules/ads/googleAdMobV2.ts
435
410
  import { noop as noop2 } from "es-toolkit";
411
+
412
+ // src/utils/getReferrer.ts
413
+ import { getSchemeUri } from "@granite-js/react-native";
414
+ function getReferrer() {
415
+ try {
416
+ return new URL(getSchemeUri()).searchParams.get("referrer");
417
+ } catch {
418
+ return null;
419
+ }
420
+ }
421
+
422
+ // src/AppsInTossModule/native-modules/ads/googleAdMobV2.ts
436
423
  function loadAppsInTossAdMob(params) {
437
424
  if (!loadAppsInTossAdMob.isSupported()) {
438
425
  params.onError(new Error(UNSUPPORTED_ERROR_MESSAGE2));
439
426
  return noop2;
440
427
  }
441
428
  const { onEvent, onError, options } = params;
442
- const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("loadAppsInTossAdmob", options, {
443
- onSuccess: (result) => onEvent({ type: "loaded", data: result }),
444
- onError
445
- });
429
+ const referrer = getReferrer();
430
+ const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod(
431
+ "loadAppsInTossAdmob",
432
+ { ...options, referrer },
433
+ {
434
+ onSuccess: (result) => onEvent({ type: "loaded", data: result }),
435
+ onError
436
+ }
437
+ );
446
438
  return unregisterCallbacks;
447
439
  }
448
440
  function showAppsInTossAdMob(params) {
@@ -451,28 +443,33 @@ function showAppsInTossAdMob(params) {
451
443
  return noop2;
452
444
  }
453
445
  const { onEvent, onError, options } = params;
454
- const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod("showAppsInTossAdmob", options, {
455
- onAdClicked: () => {
456
- onEvent({ type: "clicked" });
457
- },
458
- onAdDismissed: () => {
459
- onEvent({ type: "dismissed" });
460
- },
461
- onAdFailedToShow: () => {
462
- onEvent({ type: "failedToShow" });
463
- },
464
- onAdImpression: () => {
465
- onEvent({ type: "impression" });
466
- },
467
- onAdShow: () => {
468
- onEvent({ type: "show" });
469
- },
470
- onUserEarnedReward: (data) => {
471
- onEvent({ type: "userEarnedReward", data });
472
- },
473
- onSuccess: () => onEvent({ type: "requested" }),
474
- onError
475
- });
446
+ const referrer = getReferrer();
447
+ const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod(
448
+ "showAppsInTossAdmob",
449
+ { ...options, referrer },
450
+ {
451
+ onAdClicked: () => {
452
+ onEvent({ type: "clicked" });
453
+ },
454
+ onAdDismissed: () => {
455
+ onEvent({ type: "dismissed" });
456
+ },
457
+ onAdFailedToShow: () => {
458
+ onEvent({ type: "failedToShow" });
459
+ },
460
+ onAdImpression: () => {
461
+ onEvent({ type: "impression" });
462
+ },
463
+ onAdShow: () => {
464
+ onEvent({ type: "show" });
465
+ },
466
+ onUserEarnedReward: (data) => {
467
+ onEvent({ type: "userEarnedReward", data });
468
+ },
469
+ onSuccess: () => onEvent({ type: "requested" }),
470
+ onError
471
+ }
472
+ );
476
473
  return unregisterCallbacks;
477
474
  }
478
475
  var ANDROID_GOOGLE_AD_MOB_SUPPORTED_VERSION2 = "5.227.0";
@@ -665,15 +662,80 @@ async function getTossShareLink(path) {
665
662
  }
666
663
 
667
664
  // src/AppsInTossModule/native-modules/iap.ts
668
- async function createOneTimePurchaseOrder(params) {
669
- const isSupported = isMinVersionSupported({
665
+ import { noop as noop3 } from "es-toolkit";
666
+ function iapCreateOneTimePurchaseOrder(params) {
667
+ const sku = params.sku ?? params.productId;
668
+ return AppsInTossModule.iapCreateOneTimePurchaseOrder({ productId: sku });
669
+ }
670
+ function processProductGrant(params) {
671
+ return AppsInTossModule.processProductGrant({ orderId: params.orderId, isProductGranted: params.isProductGranted });
672
+ }
673
+ function requestOneTimePurchase(params) {
674
+ const { options, onEvent, onError } = params;
675
+ const sku = options.sku ?? options.productId;
676
+ const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod(
677
+ "requestOneTimePurchase",
678
+ { sku },
679
+ {
680
+ onPurchased: (params2) => {
681
+ onEvent({ type: "purchased", data: params2 });
682
+ },
683
+ onSuccess: (result) => {
684
+ onEvent({ type: "success", data: result });
685
+ },
686
+ onError: (error) => {
687
+ onError(error);
688
+ }
689
+ }
690
+ );
691
+ return unregisterCallbacks;
692
+ }
693
+ function createOneTimePurchaseOrder(params) {
694
+ const isIAPSupported = isMinVersionSupported({
670
695
  android: "5.219.0",
671
696
  ios: "5.219.0"
672
697
  });
673
- if (!isSupported) {
674
- return;
698
+ if (!isIAPSupported) {
699
+ return noop3;
675
700
  }
676
- return AppsInTossModule.iapCreateOneTimePurchaseOrder(params);
701
+ const isProcessProductGrantSupported = isMinVersionSupported({
702
+ android: "5.231.1",
703
+ ios: "5.230.0"
704
+ });
705
+ const { options, onEvent, onError } = params;
706
+ const sku = options.sku ?? options.productId;
707
+ if (!isProcessProductGrantSupported) {
708
+ const v1 = () => {
709
+ AppsInTossModule.iapCreateOneTimePurchaseOrder({ productId: sku }).then((response) => {
710
+ Promise.resolve(options.processProductGrant({ orderId: response.orderId })).then(() => {
711
+ onEvent({ type: "success", data: response });
712
+ }).catch((error) => {
713
+ onError(error);
714
+ });
715
+ }).catch((error) => {
716
+ onError(error);
717
+ });
718
+ return noop3;
719
+ };
720
+ return v1();
721
+ }
722
+ const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod(
723
+ "requestOneTimePurchase",
724
+ { sku },
725
+ {
726
+ onPurchased: async (params2) => {
727
+ const isProductGranted = await options.processProductGrant(params2);
728
+ await AppsInTossModule.processProductGrant({ orderId: params2.orderId, isProductGranted });
729
+ },
730
+ onSuccess: (result) => {
731
+ onEvent({ type: "success", data: result });
732
+ },
733
+ onError: (error) => {
734
+ onError(error);
735
+ }
736
+ }
737
+ );
738
+ return unregisterCallbacks;
677
739
  }
678
740
  async function getProductItemList() {
679
741
  const isSupported = isMinVersionSupported({
@@ -685,9 +747,31 @@ async function getProductItemList() {
685
747
  }
686
748
  return AppsInTossModule.iapGetProductItemList({});
687
749
  }
750
+ async function getPendingOrders() {
751
+ const isSupported = isMinVersionSupported({
752
+ android: "5.231.0",
753
+ ios: "5.231.0"
754
+ });
755
+ if (!isSupported) {
756
+ return;
757
+ }
758
+ return AppsInTossModule.getPendingOrders({});
759
+ }
760
+ async function getCompletedOrRefundedOrders(params) {
761
+ const isSupported = isMinVersionSupported({
762
+ android: "5.231.0",
763
+ ios: "5.231.0"
764
+ });
765
+ if (!isSupported) {
766
+ return;
767
+ }
768
+ return AppsInTossModule.getCompletedOrRefundedOrders(params ?? { key: null });
769
+ }
688
770
  var IAP = {
689
771
  createOneTimePurchaseOrder,
690
- getProductItemList
772
+ getProductItemList,
773
+ getPendingOrders,
774
+ getCompletedOrRefundedOrders
691
775
  };
692
776
 
693
777
  // src/AppsInTossModule/native-modules/saveBase64Data.ts
@@ -854,7 +938,7 @@ function replaceUnderbarToHypen(locale) {
854
938
  }
855
939
 
856
940
  // src/BedrockModule/native-modules/natives/getSchemeUri.ts
857
- function getSchemeUri() {
941
+ function getSchemeUri2() {
858
942
  return BedrockModule.schemeUri;
859
943
  }
860
944
 
@@ -957,14 +1041,17 @@ export {
957
1041
  getNetworkStatus,
958
1042
  getOperationalEnvironment,
959
1043
  getPlatformOS,
960
- getSchemeUri,
1044
+ getSchemeUri2 as getSchemeUri,
961
1045
  getTossAppVersion,
962
1046
  getTossShareLink,
1047
+ iapCreateOneTimePurchaseOrder,
963
1048
  isMinVersionSupported,
964
1049
  onVisibilityChangedByTransparentServiceWeb,
965
1050
  openCamera,
966
1051
  openGameCenterLeaderboard,
967
1052
  openURL2 as openURL,
1053
+ processProductGrant,
1054
+ requestOneTimePurchase,
968
1055
  saveBase64Data,
969
1056
  setClipboardText,
970
1057
  setDeviceOrientation,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@apps-in-toss/native-modules",
3
3
  "type": "module",
4
- "version": "1.1.2",
4
+ "version": "1.2.0",
5
5
  "description": "Native Modules for Apps In Toss",
6
6
  "scripts": {
7
7
  "prepack": "yarn build",
@@ -43,7 +43,7 @@
43
43
  "vitest": "^3.2.4"
44
44
  },
45
45
  "dependencies": {
46
- "@apps-in-toss/types": "^1.1.2",
46
+ "@apps-in-toss/types": "^1.2.0",
47
47
  "es-toolkit": "^1.39.3"
48
48
  },
49
49
  "peerDependencies": {
@@ -54,5 +54,5 @@
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  },
57
- "gitHead": "7b3c5e53a3ed0ffef8af2690a5ab92e8dfb0213b"
57
+ "gitHead": "f567520ba5a18de1fcddb329fb70d432cf10af85"
58
58
  }
@@ -1,7 +1,5 @@
1
1
  import { GraniteEvent } from '@granite-js/react-native';
2
- import { BackButtonClickHandleEvent } from './event-plugins/BackButtonClickHandleEvent';
3
2
  import { EntryMessageExitedEvent } from './event-plugins/EntryMessageExitedEvent';
4
- import { HomeIconButtonClickHandleEvent } from './event-plugins/HomeIconButtonClickHandleEvent';
5
3
  import { UpdateLocationEvent } from './event-plugins/UpdateLocationEvent';
6
4
  import { AppBridgeCallbackEvent } from './internal/AppBridgeCallbackEvent';
7
5
  import { VisibilityChangedByTransparentServiceWebEvent } from './internal/VisibilityChangedByTransparentServiceWebEvent';
@@ -10,10 +8,6 @@ export const appsInTossEvent = new GraniteEvent([
10
8
  new UpdateLocationEvent(),
11
9
  new EntryMessageExitedEvent(),
12
10
 
13
- // Navigation Bar events
14
- new HomeIconButtonClickHandleEvent(),
15
- new BackButtonClickHandleEvent(),
16
-
17
11
  // Internal events
18
12
  new AppBridgeCallbackEvent(),
19
13
  new VisibilityChangedByTransparentServiceWebEvent(),
@@ -15,11 +15,7 @@ import type {
15
15
  import { TurboModuleRegistry, type TurboModule as __TurboModule } from 'react-native';
16
16
  import type { CheckoutPaymentOptions, CheckoutPaymentResult } from './checkoutPayment';
17
17
  import type { GameCenterGameProfileResponse } from './getGameCenterGameProfile';
18
- import type {
19
- IapCreateOneTimePurchaseOrderOptions,
20
- IapCreateOneTimePurchaseOrderResult,
21
- IapProductListItem,
22
- } from './iap';
18
+ import { IapCreateOneTimePurchaseOrderResult, IapProductListItem, CompletedOrRefundedOrdersResult } from './iap';
23
19
  import type { SaveBase64DataParams } from './saveBase64Data';
24
20
  import type { SubmitGameCenterLeaderBoardScoreResponse } from './submitGameCenterLeaderBoardScore';
25
21
  import type { ContactsViralParams } from '../native-event-emitter/contactsViral';
@@ -68,10 +64,17 @@ interface Spec extends __TurboModule {
68
64
  saveBase64Data: (params: SaveBase64DataParams) => Promise<void>;
69
65
 
70
66
  /** IAP */
71
- iapCreateOneTimePurchaseOrder: (
72
- params: IapCreateOneTimePurchaseOrderOptions
73
- ) => Promise<IapCreateOneTimePurchaseOrderResult>;
74
67
  iapGetProductItemList: (arg: CompatiblePlaceholderArgument) => Promise<{ products: IapProductListItem[] }>;
68
+ /** @deprecated `requestOneTimePurchase`를 사용해주세요. */
69
+ iapCreateOneTimePurchaseOrder: (params: { productId: string }) => Promise<IapCreateOneTimePurchaseOrderResult>;
70
+ requestOneTimePurchase: (
71
+ params: { sku: string },
72
+ fallbacks: { onPurchased: (params: { orderId: string }) => void }
73
+ ) => () => void;
74
+ processProductGrant: (params: { orderId: string; isProductGranted: boolean }) => Promise<void>;
75
+ getPendingOrders: (params: CompatiblePlaceholderArgument) => Promise<{ orderIds: string[] }>;
76
+ getCompletedOrRefundedOrders: (params: { key?: string | null }) => Promise<CompletedOrRefundedOrdersResult>;
77
+
75
78
  getGameCenterGameProfile: (params: CompatiblePlaceholderArgument) => Promise<GameCenterGameProfileResponse>;
76
79
  submitGameCenterLeaderBoardScore: (params: { score: string }) => Promise<SubmitGameCenterLeaderBoardScoreResponse>;
77
80
 
@@ -1,5 +1,6 @@
1
1
  import { noop } from 'es-toolkit';
2
2
  import type { AdMobFullScreenEvent, AdMobHandlerParams, AdMobLoadResult, AdUserEarnedReward } from './types';
3
+ import { getReferrer } from '../../../utils/getReferrer';
3
4
  import { INTERNAL__appBridgeHandler } from '../../native-event-emitter/internal/appBridge';
4
5
  import { getOperationalEnvironment } from '../getOperationalEnvironment';
5
6
  import { isMinVersionSupported } from '../isMinVersionSupported';
@@ -155,11 +156,16 @@ export function loadAppsInTossAdMob(params: LoadAdMobParams) {
155
156
  }
156
157
 
157
158
  const { onEvent, onError, options } = params;
159
+ const referrer = getReferrer();
158
160
 
159
- const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod('loadAppsInTossAdmob', options, {
160
- onSuccess: (result) => onEvent({ type: 'loaded', data: result }),
161
- onError,
162
- });
161
+ const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod(
162
+ 'loadAppsInTossAdmob',
163
+ { ...options, referrer },
164
+ {
165
+ onSuccess: (result) => onEvent({ type: 'loaded', data: result }),
166
+ onError,
167
+ }
168
+ );
163
169
 
164
170
  return unregisterCallbacks;
165
171
  }
@@ -312,29 +318,34 @@ export function showAppsInTossAdMob(params: ShowAdMobParams) {
312
318
  }
313
319
 
314
320
  const { onEvent, onError, options } = params;
321
+ const referrer = getReferrer();
315
322
 
316
- const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod('showAppsInTossAdmob', options, {
317
- onAdClicked: () => {
318
- onEvent({ type: 'clicked' });
319
- },
320
- onAdDismissed: () => {
321
- onEvent({ type: 'dismissed' });
322
- },
323
- onAdFailedToShow: () => {
324
- onEvent({ type: 'failedToShow' });
325
- },
326
- onAdImpression: () => {
327
- onEvent({ type: 'impression' });
328
- },
329
- onAdShow: () => {
330
- onEvent({ type: 'show' });
331
- },
332
- onUserEarnedReward: (data: { unitType: string; unitAmount: number }) => {
333
- onEvent({ type: 'userEarnedReward', data });
334
- },
335
- onSuccess: () => onEvent({ type: 'requested' }),
336
- onError,
337
- });
323
+ const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod(
324
+ 'showAppsInTossAdmob',
325
+ { ...options, referrer },
326
+ {
327
+ onAdClicked: () => {
328
+ onEvent({ type: 'clicked' });
329
+ },
330
+ onAdDismissed: () => {
331
+ onEvent({ type: 'dismissed' });
332
+ },
333
+ onAdFailedToShow: () => {
334
+ onEvent({ type: 'failedToShow' });
335
+ },
336
+ onAdImpression: () => {
337
+ onEvent({ type: 'impression' });
338
+ },
339
+ onAdShow: () => {
340
+ onEvent({ type: 'show' });
341
+ },
342
+ onUserEarnedReward: (data: { unitType: string; unitAmount: number }) => {
343
+ onEvent({ type: 'userEarnedReward', data });
344
+ },
345
+ onSuccess: () => onEvent({ type: 'requested' }),
346
+ onError,
347
+ }
348
+ );
338
349
 
339
350
  return unregisterCallbacks;
340
351
  }