react-native-daro 1.0.13 → 1.0.16

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 (262) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +30 -30
  3. package/android/build.gradle +52 -59
  4. package/android/src/admob/java/com/daro/reactnative/DaroSdkBridge.kt +23 -0
  5. package/android/src/main/AndroidManifest.xml +1 -2
  6. package/android/src/main/java/com/{darom → daro/reactnative}/DaroMAdBannerViewManager.kt +38 -15
  7. package/android/src/main/java/com/daro/reactnative/DaroMAdNativeViewManager.kt +167 -0
  8. package/android/src/main/java/com/daro/reactnative/DaroMModule.kt +257 -0
  9. package/android/src/main/java/com/daro/reactnative/DaroMPackage.kt +45 -0
  10. package/android/src/main/java/com/daro/reactnative/DaroMediaViewManager.kt +25 -0
  11. package/android/src/main/java/com/{darom → daro/reactnative}/constants/InternalDaroMBannerSize.kt +1 -1
  12. package/android/src/main/java/com/{darom → daro/reactnative}/event/DaroMEvent.kt +19 -8
  13. package/android/src/main/java/com/{darom → daro/reactnative}/impl/DaroMBannerViewModuleImpl.kt +2 -2
  14. package/android/src/main/java/com/{darom → daro/reactnative}/impl/DaroMInterstitialModuleImpl.kt +26 -26
  15. package/android/src/main/java/com/{darom → daro/reactnative}/impl/DaroMLightPopupModuleImpl.kt +30 -29
  16. package/android/src/main/java/com/{darom → daro/reactnative}/impl/DaroMRewardedAdModuleImpl.kt +27 -27
  17. package/android/src/main/java/com/{darom → daro/reactnative}/util/AdInfoUtil.kt +25 -1
  18. package/android/src/main/java/com/daro/reactnative/util/EventEmitterUtil.kt +37 -0
  19. package/android/src/main/java/com/daro/reactnative/view/DaroMAdBannerViewContainer.kt +417 -0
  20. package/android/src/main/java/com/daro/reactnative/view/DaroMAdNativeViewContainer.kt +624 -0
  21. package/android/src/main/java/com/daro/reactnative/view/DaroMediaView.kt +123 -0
  22. package/android/src/newarch/java/com/daro/reactnative/DaroMModuleSpec.kt +6 -0
  23. package/android/src/oldarch/java/com/daro/reactnative/DaroMModuleSpec.kt +90 -0
  24. package/app.plugin.js +1 -0
  25. package/ios/DaroMModule+AppOpen.swift +38 -32
  26. package/ios/DaroMModule+Interstitial.swift +32 -26
  27. package/ios/DaroMModule+LightPopup.swift +43 -33
  28. package/ios/DaroMModule+Rewarded.swift +38 -27
  29. package/ios/DaroMModule.mm +45 -17
  30. package/ios/DaroMModule.swift +24 -17
  31. package/ios/Fabric/DaroMAdBannerComponentView.mm +207 -0
  32. package/ios/Fabric/DaroMFabricEventSink.mm +31 -0
  33. package/ios/Fabric/DaroMFabricPropApplier.mm +123 -0
  34. package/ios/Fabric/DaroMNativeAdComponentView.mm +294 -0
  35. package/ios/{DaroMAdBannerViewManager.m → Paper/DaroMAdBannerViewManager.m} +3 -1
  36. package/ios/Paper/DaroMAdBannerViewManager.swift +21 -0
  37. package/ios/{DaroMNativeAdViewManager.m → Paper/DaroMNativeAdViewManager.m} +2 -1
  38. package/ios/Paper/DaroMNativeAdViewManager.swift +22 -0
  39. package/ios/Shared/DaroMAdEventSink.swift +24 -0
  40. package/ios/Shared/DaroMBannerAdView.swift +188 -0
  41. package/ios/Shared/DaroMNativeAdLoadCoordinator.swift +49 -0
  42. package/ios/Shared/DaroMNativeAdView.swift +575 -0
  43. package/ios/Shared/DaroMNativeAssetResolver.swift +53 -0
  44. package/ios/mediation/admob/DaroMediationDebugger.swift +11 -0
  45. package/ios/mediation/admob/DaroMediationTypes.swift +23 -0
  46. package/lib/commonjs/AdBannerView.js +21 -35
  47. package/lib/commonjs/AdBannerView.js.map +1 -1
  48. package/lib/commonjs/AppOpenAd.js +80 -21
  49. package/lib/commonjs/AppOpenAd.js.map +1 -1
  50. package/lib/commonjs/DaroMAdBannerViewNativeComponent.ts +47 -0
  51. package/lib/commonjs/DaroMNativeAdViewNativeComponent.ts +62 -0
  52. package/lib/commonjs/DaroMediaViewNativeComponent.ts +9 -0
  53. package/lib/commonjs/ErrorCode.js.map +1 -1
  54. package/lib/commonjs/EventEmitter.js +4 -5
  55. package/lib/commonjs/EventEmitter.js.map +1 -1
  56. package/lib/commonjs/InterstitialAd.js +48 -22
  57. package/lib/commonjs/InterstitialAd.js.map +1 -1
  58. package/lib/commonjs/LightPopupAd.js +64 -46
  59. package/lib/commonjs/LightPopupAd.js.map +1 -1
  60. package/lib/commonjs/NativeDaroModule.js +9 -0
  61. package/lib/commonjs/NativeDaroModule.js.map +1 -0
  62. package/lib/commonjs/RewardedAd.js +47 -23
  63. package/lib/commonjs/RewardedAd.js.map +1 -1
  64. package/lib/commonjs/codegen-env.d.js +2 -0
  65. package/lib/commonjs/codegen-env.d.js.map +1 -0
  66. package/lib/commonjs/hooks/useInterstitialAd.js +110 -0
  67. package/lib/commonjs/hooks/useInterstitialAd.js.map +1 -0
  68. package/lib/commonjs/hooks/useLightPopupAd.js +114 -0
  69. package/lib/commonjs/hooks/useLightPopupAd.js.map +1 -0
  70. package/lib/commonjs/hooks/useRewardedAd.js +113 -0
  71. package/lib/commonjs/hooks/useRewardedAd.js.map +1 -0
  72. package/lib/commonjs/index.js +29 -13
  73. package/lib/commonjs/index.js.map +1 -1
  74. package/lib/commonjs/nativeAd/NativeAdView.js +23 -18
  75. package/lib/commonjs/nativeAd/NativeAdView.js.map +1 -1
  76. package/lib/commonjs/nativeAd/NativeAdViewComponents.js +43 -31
  77. package/lib/commonjs/nativeAd/NativeAdViewComponents.js.map +1 -1
  78. package/lib/commonjs/nativeAd/NativeAdViewProvider.js +34 -7
  79. package/lib/commonjs/nativeAd/NativeAdViewProvider.js.map +1 -1
  80. package/lib/commonjs/package.json +1 -0
  81. package/lib/module/AdBannerView.js +20 -36
  82. package/lib/module/AdBannerView.js.map +1 -1
  83. package/lib/module/AppOpenAd.js +80 -22
  84. package/lib/module/AppOpenAd.js.map +1 -1
  85. package/lib/module/DaroMAdBannerViewNativeComponent.ts +47 -0
  86. package/lib/module/DaroMNativeAdViewNativeComponent.ts +62 -0
  87. package/lib/module/DaroMediaViewNativeComponent.ts +9 -0
  88. package/lib/module/ErrorCode.js.map +1 -1
  89. package/lib/module/EventEmitter.js +4 -6
  90. package/lib/module/EventEmitter.js.map +1 -1
  91. package/lib/module/InterstitialAd.js +47 -22
  92. package/lib/module/InterstitialAd.js.map +1 -1
  93. package/lib/module/LightPopupAd.js +65 -47
  94. package/lib/module/LightPopupAd.js.map +1 -1
  95. package/lib/module/NativeDaroModule.js +5 -0
  96. package/lib/module/NativeDaroModule.js.map +1 -0
  97. package/lib/module/RewardedAd.js +46 -23
  98. package/lib/module/RewardedAd.js.map +1 -1
  99. package/lib/module/codegen-env.d.js +2 -0
  100. package/lib/module/codegen-env.d.js.map +1 -0
  101. package/lib/module/hooks/useInterstitialAd.js +106 -0
  102. package/lib/module/hooks/useInterstitialAd.js.map +1 -0
  103. package/lib/module/hooks/useLightPopupAd.js +110 -0
  104. package/lib/module/hooks/useLightPopupAd.js.map +1 -0
  105. package/lib/module/hooks/useRewardedAd.js +109 -0
  106. package/lib/module/hooks/useRewardedAd.js.map +1 -0
  107. package/lib/module/index.js +7 -13
  108. package/lib/module/index.js.map +1 -1
  109. package/lib/module/nativeAd/NativeAdView.js +22 -19
  110. package/lib/module/nativeAd/NativeAdView.js.map +1 -1
  111. package/lib/module/nativeAd/NativeAdViewComponents.js +45 -34
  112. package/lib/module/nativeAd/NativeAdViewComponents.js.map +1 -1
  113. package/lib/module/nativeAd/NativeAdViewProvider.js +35 -8
  114. package/lib/module/nativeAd/NativeAdViewProvider.js.map +1 -1
  115. package/lib/module/package.json +1 -0
  116. package/lib/typescript/commonjs/plugin/src/index.d.ts +19 -0
  117. package/lib/typescript/commonjs/plugin/src/index.d.ts.map +1 -0
  118. package/lib/typescript/commonjs/plugin/src/skAdNetworkIds.d.ts +6 -0
  119. package/lib/typescript/commonjs/plugin/src/skAdNetworkIds.d.ts.map +1 -0
  120. package/lib/typescript/commonjs/plugin/src/withAndroid.d.ts +8 -0
  121. package/lib/typescript/commonjs/plugin/src/withAndroid.d.ts.map +1 -0
  122. package/lib/typescript/commonjs/plugin/src/withIos.d.ts +8 -0
  123. package/lib/typescript/commonjs/plugin/src/withIos.d.ts.map +1 -0
  124. package/lib/typescript/commonjs/src/AdBannerView.d.ts +126 -4
  125. package/lib/typescript/commonjs/src/AdBannerView.d.ts.map +1 -1
  126. package/lib/typescript/commonjs/src/AppOpenAd.d.ts +6 -0
  127. package/lib/typescript/commonjs/src/AppOpenAd.d.ts.map +1 -1
  128. package/lib/typescript/commonjs/src/DaroMAdBannerViewNativeComponent.d.ts +32 -0
  129. package/lib/typescript/commonjs/src/DaroMAdBannerViewNativeComponent.d.ts.map +1 -0
  130. package/lib/typescript/commonjs/src/DaroMNativeAdViewNativeComponent.d.ts +42 -0
  131. package/lib/typescript/commonjs/src/DaroMNativeAdViewNativeComponent.d.ts.map +1 -0
  132. package/lib/typescript/commonjs/src/DaroMediaViewNativeComponent.d.ts +6 -0
  133. package/lib/typescript/commonjs/src/DaroMediaViewNativeComponent.d.ts.map +1 -0
  134. package/lib/typescript/commonjs/src/ErrorCode.d.ts.map +1 -1
  135. package/lib/typescript/commonjs/src/EventEmitter.d.ts.map +1 -1
  136. package/lib/typescript/commonjs/src/InterstitialAd.d.ts +6 -0
  137. package/lib/typescript/commonjs/src/InterstitialAd.d.ts.map +1 -1
  138. package/lib/typescript/commonjs/src/LightPopupAd.d.ts +6 -0
  139. package/lib/typescript/commonjs/src/LightPopupAd.d.ts.map +1 -1
  140. package/lib/typescript/commonjs/src/NativeDaroModule.d.ts +61 -0
  141. package/lib/typescript/commonjs/src/NativeDaroModule.d.ts.map +1 -0
  142. package/lib/typescript/commonjs/src/RewardedAd.d.ts +6 -0
  143. package/lib/typescript/commonjs/src/RewardedAd.d.ts.map +1 -1
  144. package/lib/typescript/commonjs/src/hooks/useInterstitialAd.d.ts +19 -0
  145. package/lib/typescript/commonjs/src/hooks/useInterstitialAd.d.ts.map +1 -0
  146. package/lib/typescript/commonjs/src/hooks/useLightPopupAd.d.ts +23 -0
  147. package/lib/typescript/commonjs/src/hooks/useLightPopupAd.d.ts.map +1 -0
  148. package/lib/typescript/commonjs/src/hooks/useRewardedAd.d.ts +20 -0
  149. package/lib/typescript/commonjs/src/hooks/useRewardedAd.d.ts.map +1 -0
  150. package/lib/typescript/commonjs/src/index.d.ts +7 -1
  151. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  152. package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts +125 -2
  153. package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts.map +1 -1
  154. package/lib/typescript/commonjs/src/nativeAd/NativeAdViewComponents.d.ts.map +1 -1
  155. package/lib/typescript/commonjs/src/nativeAd/NativeAdViewProvider.d.ts +11 -5
  156. package/lib/typescript/commonjs/src/nativeAd/NativeAdViewProvider.d.ts.map +1 -1
  157. package/lib/typescript/commonjs/src/types/AdBannerViewProps.d.ts +2 -2
  158. package/lib/typescript/commonjs/src/types/AdBannerViewProps.d.ts.map +1 -1
  159. package/lib/typescript/commonjs/src/types/AdInfo.d.ts.map +1 -1
  160. package/lib/typescript/commonjs/src/types/AdProps.d.ts +2 -2
  161. package/lib/typescript/commonjs/src/types/AdProps.d.ts.map +1 -1
  162. package/lib/typescript/commonjs/src/types/DaroMMobileAds.d.ts.map +1 -1
  163. package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts +2 -0
  164. package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts.map +1 -1
  165. package/lib/typescript/module/plugin/src/index.d.ts +19 -0
  166. package/lib/typescript/module/plugin/src/index.d.ts.map +1 -0
  167. package/lib/typescript/module/plugin/src/skAdNetworkIds.d.ts +6 -0
  168. package/lib/typescript/module/plugin/src/skAdNetworkIds.d.ts.map +1 -0
  169. package/lib/typescript/module/plugin/src/withAndroid.d.ts +8 -0
  170. package/lib/typescript/module/plugin/src/withAndroid.d.ts.map +1 -0
  171. package/lib/typescript/module/plugin/src/withIos.d.ts +8 -0
  172. package/lib/typescript/module/plugin/src/withIos.d.ts.map +1 -0
  173. package/lib/typescript/module/src/AdBannerView.d.ts +126 -4
  174. package/lib/typescript/module/src/AdBannerView.d.ts.map +1 -1
  175. package/lib/typescript/module/src/AppOpenAd.d.ts +6 -0
  176. package/lib/typescript/module/src/AppOpenAd.d.ts.map +1 -1
  177. package/lib/typescript/module/src/DaroMAdBannerViewNativeComponent.d.ts +32 -0
  178. package/lib/typescript/module/src/DaroMAdBannerViewNativeComponent.d.ts.map +1 -0
  179. package/lib/typescript/module/src/DaroMNativeAdViewNativeComponent.d.ts +42 -0
  180. package/lib/typescript/module/src/DaroMNativeAdViewNativeComponent.d.ts.map +1 -0
  181. package/lib/typescript/module/src/DaroMediaViewNativeComponent.d.ts +6 -0
  182. package/lib/typescript/module/src/DaroMediaViewNativeComponent.d.ts.map +1 -0
  183. package/lib/typescript/module/src/ErrorCode.d.ts.map +1 -1
  184. package/lib/typescript/module/src/EventEmitter.d.ts.map +1 -1
  185. package/lib/typescript/module/src/InterstitialAd.d.ts +6 -0
  186. package/lib/typescript/module/src/InterstitialAd.d.ts.map +1 -1
  187. package/lib/typescript/module/src/LightPopupAd.d.ts +6 -0
  188. package/lib/typescript/module/src/LightPopupAd.d.ts.map +1 -1
  189. package/lib/typescript/module/src/NativeDaroModule.d.ts +61 -0
  190. package/lib/typescript/module/src/NativeDaroModule.d.ts.map +1 -0
  191. package/lib/typescript/module/src/RewardedAd.d.ts +6 -0
  192. package/lib/typescript/module/src/RewardedAd.d.ts.map +1 -1
  193. package/lib/typescript/module/src/hooks/useInterstitialAd.d.ts +19 -0
  194. package/lib/typescript/module/src/hooks/useInterstitialAd.d.ts.map +1 -0
  195. package/lib/typescript/module/src/hooks/useLightPopupAd.d.ts +23 -0
  196. package/lib/typescript/module/src/hooks/useLightPopupAd.d.ts.map +1 -0
  197. package/lib/typescript/module/src/hooks/useRewardedAd.d.ts +20 -0
  198. package/lib/typescript/module/src/hooks/useRewardedAd.d.ts.map +1 -0
  199. package/lib/typescript/module/src/index.d.ts +7 -1
  200. package/lib/typescript/module/src/index.d.ts.map +1 -1
  201. package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts +125 -2
  202. package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts.map +1 -1
  203. package/lib/typescript/module/src/nativeAd/NativeAdViewComponents.d.ts.map +1 -1
  204. package/lib/typescript/module/src/nativeAd/NativeAdViewProvider.d.ts +11 -5
  205. package/lib/typescript/module/src/nativeAd/NativeAdViewProvider.d.ts.map +1 -1
  206. package/lib/typescript/module/src/types/AdBannerViewProps.d.ts +2 -2
  207. package/lib/typescript/module/src/types/AdBannerViewProps.d.ts.map +1 -1
  208. package/lib/typescript/module/src/types/AdInfo.d.ts.map +1 -1
  209. package/lib/typescript/module/src/types/AdProps.d.ts +2 -2
  210. package/lib/typescript/module/src/types/AdProps.d.ts.map +1 -1
  211. package/lib/typescript/module/src/types/DaroMMobileAds.d.ts.map +1 -1
  212. package/lib/typescript/module/src/types/NativeAdViewProps.d.ts +2 -0
  213. package/lib/typescript/module/src/types/NativeAdViewProps.d.ts.map +1 -1
  214. package/package.json +95 -105
  215. package/plugin/build/index.d.ts +18 -0
  216. package/plugin/build/index.js +71 -0
  217. package/plugin/build/skAdNetworkIds.d.ts +5 -0
  218. package/plugin/build/skAdNetworkIds.js +205 -0
  219. package/plugin/build/withAndroid.d.ts +7 -0
  220. package/plugin/build/withAndroid.js +222 -0
  221. package/plugin/build/withIos.d.ts +7 -0
  222. package/plugin/build/withIos.js +82 -0
  223. package/react-native-daro.podspec +28 -0
  224. package/src/AdBannerView.tsx +48 -48
  225. package/src/AppOpenAd.ts +101 -20
  226. package/src/DaroMAdBannerViewNativeComponent.ts +47 -0
  227. package/src/DaroMNativeAdViewNativeComponent.ts +62 -0
  228. package/src/DaroMediaViewNativeComponent.ts +9 -0
  229. package/src/ErrorCode.ts +1 -2
  230. package/src/EventEmitter.ts +9 -7
  231. package/src/InterstitialAd.ts +75 -21
  232. package/src/LightPopupAd.ts +90 -51
  233. package/src/NativeDaroModule.ts +91 -0
  234. package/src/RewardedAd.ts +72 -22
  235. package/src/codegen-env.d.ts +45 -0
  236. package/src/hooks/useInterstitialAd.ts +117 -0
  237. package/src/hooks/useLightPopupAd.ts +132 -0
  238. package/src/hooks/useRewardedAd.ts +122 -0
  239. package/src/index.tsx +21 -22
  240. package/src/nativeAd/NativeAdView.tsx +83 -45
  241. package/src/nativeAd/NativeAdViewComponents.tsx +129 -64
  242. package/src/nativeAd/NativeAdViewProvider.tsx +84 -16
  243. package/src/types/AdBannerViewProps.ts +11 -11
  244. package/src/types/AdInfo.ts +17 -17
  245. package/src/types/AdProps.ts +8 -9
  246. package/src/types/DaroMMobileAds.ts +3 -6
  247. package/src/types/NativeAdViewProps.ts +12 -5
  248. package/src/types/index.ts +1 -1
  249. package/android/gradle.properties +0 -5
  250. package/android/src/main/AndroidManifestNew.xml +0 -7
  251. package/android/src/main/java/com/darom/DaroMAdNativeViewManager.kt +0 -136
  252. package/android/src/main/java/com/darom/DaroMModule.kt +0 -203
  253. package/android/src/main/java/com/darom/DaroMPackage.kt +0 -21
  254. package/android/src/main/java/com/darom/util/EventEmitterUtil.kt +0 -24
  255. package/android/src/main/java/com/darom/view/DaroMAdBannerViewContainer.kt +0 -163
  256. package/android/src/main/java/com/darom/view/DaroMAdNativeViewContainer.kt +0 -375
  257. package/android/src/main/res/layout/layout_activity_transparent.xml +0 -7
  258. package/android/src/main/res/values/styles.xml +0 -11
  259. package/ios/DaroM-Bridging-Header.h +0 -6
  260. package/ios/DaroMAdBannerViewManager.swift +0 -91
  261. package/ios/DaroMNativeAdViewManager.swift +0 -291
  262. package/react-native-daro-m.podspec +0 -44
@@ -1,41 +1,49 @@
1
- import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
2
- import { findNodeHandle, NativeModules, requireNativeComponent, UIManager, View, type DimensionValue, type NativeMethods, type ViewProps } from 'react-native';
3
- import type { AdBannerViewHandler, AdBannerViewProps } from './types/AdBannerViewProps';
1
+ import {
2
+ forwardRef,
3
+ useCallback,
4
+ useEffect,
5
+ useImperativeHandle,
6
+ useRef,
7
+ useState,
8
+ type ElementRef,
9
+ } from 'react';
10
+ import { View, type ViewProps } from 'react-native';
11
+ import AdBannerViewNativeComponent, {
12
+ Commands,
13
+ } from './DaroMAdBannerViewNativeComponent';
14
+ import NativeDaroModule from './NativeDaroModule';
15
+ import type {
16
+ AdBannerViewHandler,
17
+ AdBannerViewProps,
18
+ } from './types/AdBannerViewProps';
4
19
  import type { AdNativeEvent } from './types/AdEvent';
5
20
  import type { AdInfo, AdLoadFailedInfo } from './types/AdInfo';
6
21
 
7
- const { DaroMModule } = NativeModules;
8
-
9
- const {
10
- BANNER_AD_FORMAT_LABEL,
11
- MREC_AD_FORMAT_LABEL,
12
- } = DaroMModule.getConstants();
22
+ const { BANNER_AD_FORMAT_LABEL, MREC_AD_FORMAT_LABEL } =
23
+ NativeDaroModule.getConstants();
13
24
 
14
25
  export enum AdFormat {
15
- BANNER = BANNER_AD_FORMAT_LABEL,
16
- MREC = MREC_AD_FORMAT_LABEL,
26
+ BANNER = 'BANNER',
27
+ MREC = 'MREC',
17
28
  }
18
29
 
19
- type AdViewNativeEvents = {
20
- onAdLoadedEvent(event: AdNativeEvent<AdInfo>): void;
21
- onAdLoadFailedEvent(event: AdNativeEvent<AdLoadFailedInfo>): void;
22
- onAdClickedEvent(event: AdNativeEvent<AdInfo>): void;
23
- onAdImpressionRecordedEvent(event: AdNativeEvent<AdInfo>): void;
30
+ const toNativeAdFormat = (adFormat: AdFormat | string): string => {
31
+ switch (adFormat) {
32
+ case AdFormat.BANNER:
33
+ return BANNER_AD_FORMAT_LABEL;
34
+ case AdFormat.MREC:
35
+ return MREC_AD_FORMAT_LABEL;
36
+ default:
37
+ return adFormat;
38
+ }
24
39
  };
25
40
 
26
- const ComponentName = 'DaroMAdBannerView';
27
- const AdViewComponent = requireNativeComponent<AdBannerViewProps & ViewProps & AdViewNativeEvents>(ComponentName);
28
- type AdViewType = React.Component<AdBannerViewProps> & NativeMethods;
29
-
30
- type SizeKey = 'width' | 'height';
31
- type SizeRecord = Partial<Record<SizeKey, DimensionValue>>;
32
-
33
- const ADVIEW_SIZE = {
34
- banner: { width: 320, height: 50 },
35
- mrec: { width: 300, height: 250 },
36
- };
41
+ type AdViewType = ElementRef<typeof AdBannerViewNativeComponent>;
37
42
 
38
- export const AdBannerView = forwardRef<AdBannerViewHandler, AdBannerViewProps & ViewProps>(function AdBannerView(
43
+ export const AdBannerView = forwardRef<
44
+ AdBannerViewHandler,
45
+ AdBannerViewProps & ViewProps
46
+ >(function AdBannerView(
39
47
  {
40
48
  adUnitId,
41
49
  adFormat,
@@ -51,19 +59,12 @@ export const AdBannerView = forwardRef<AdBannerViewHandler, AdBannerViewProps &
51
59
  },
52
60
  ref
53
61
  ) {
54
-
55
- const adFormatSize = useRef<SizeRecord>({});
56
62
  const adViewRef = useRef<AdViewType | null>(null);
57
63
  const [isInitialized, setIsInitialized] = useState<boolean>(false);
58
64
 
59
65
  const loadAd = useCallback(() => {
60
66
  if (adViewRef.current) {
61
- UIManager.dispatchViewManagerCommand(
62
- findNodeHandle(adViewRef.current),
63
- // @ts-ignore: Issue in RN ts defs
64
- UIManager.getViewManagerConfig(ComponentName).Commands.loadAd,
65
- [],
66
- );
67
+ Commands.loadAd(adViewRef.current);
67
68
  }
68
69
  }, []);
69
70
 
@@ -75,19 +76,16 @@ export const AdBannerView = forwardRef<AdBannerViewHandler, AdBannerViewProps &
75
76
 
76
77
  useEffect(() => {
77
78
  (async () => {
78
- if (adFormat === AdFormat.BANNER) {
79
- adFormatSize.current = { width: ADVIEW_SIZE.banner.width, height: ADVIEW_SIZE.banner.height };
80
- } else {
81
- adFormatSize.current = { width: ADVIEW_SIZE.mrec.width, height: ADVIEW_SIZE.mrec.height };
82
- }
83
- const initialized = await DaroMModule.isInitialized();
79
+ const initialized = await NativeDaroModule.isInitialized();
84
80
  setIsInitialized(initialized);
85
81
 
86
82
  if (!initialized) {
87
- console.warn('AdBannerView is mounted before the initialization of the DaroM React Native module');
83
+ console.warn(
84
+ 'AdBannerView is mounted before the initialization of the DaroM React Native module'
85
+ );
88
86
  }
89
87
  })();
90
- }, [adFormat]);
88
+ }, []);
91
89
 
92
90
  const onAdLoadedEvent = useCallback(
93
91
  (event: AdNativeEvent<AdInfo>) => {
@@ -124,17 +122,19 @@ export const AdBannerView = forwardRef<AdBannerViewHandler, AdBannerViewProps &
124
122
  }
125
123
 
126
124
  return (
127
- <AdViewComponent
125
+ <AdBannerViewNativeComponent
128
126
  style={style}
129
- adFormat={adFormat}
127
+ adFormat={toNativeAdFormat(adFormat)}
130
128
  ref={saveElement}
131
129
  adUnitId={adUnitId}
132
130
  placement={placement}
131
+ loadOnMount={loadOnMount}
133
132
  isVisible={isVisible}
134
133
  onAdLoadedEvent={onAdLoadedEvent}
135
134
  onAdLoadFailedEvent={onAdLoadFailedEvent}
136
135
  onAdClickedEvent={onAdClickedEvent}
137
136
  onAdImpressionRecordedEvent={onAdImpressionRecordedEvent}
138
- {...otherProps} />
137
+ {...otherProps}
138
+ />
139
139
  );
140
- });
140
+ });
package/src/AppOpenAd.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { NativeModules } from 'react-native';
1
+ import { Platform } from 'react-native';
2
2
  import {
3
3
  addEventListener,
4
4
  removeEventListener,
5
5
  AdEventEmitter,
6
6
  } from './EventEmitter';
7
+ import NativeDaroModule from './NativeDaroModule';
7
8
  import type {
8
9
  AdDisplayFailedInfo,
9
10
  AdInfo,
@@ -11,7 +12,11 @@ import type {
11
12
  } from './types/AdInfo';
12
13
  import { AdEventType, type AdEventPayloadMap } from './types/AdEvent';
13
14
 
14
- const { DaroMModule } = NativeModules;
15
+ const IS_SUPPORTED_PLATFORM = Platform.OS === 'ios';
16
+
17
+ const warnUnsupportedPlatform = () => {
18
+ console.warn('AppOpenAd is only supported on iOS.');
19
+ };
15
20
 
16
21
  const {
17
22
  ON_APPOPEN_AD_LOADED_EVENT,
@@ -21,7 +26,7 @@ const {
21
26
  ON_APPOPEN_AD_FAILED_TO_DISPLAY_EVENT,
22
27
  ON_APPOPEN_AD_HIDDEN_EVENT,
23
28
  ON_APPOPEN_AD_IMPRESSION_RECORDED,
24
- } = DaroMModule.getConstants();
29
+ } = NativeDaroModule.getConstants();
25
30
 
26
31
  const NATIVE_EVENT_BY_TYPE: Record<AdEventType, string> = {
27
32
  [AdEventType.LOADED]: ON_APPOPEN_AD_LOADED_EVENT,
@@ -34,24 +39,44 @@ const NATIVE_EVENT_BY_TYPE: Record<AdEventType, string> = {
34
39
  };
35
40
 
36
41
  export class AppOpenAd {
42
+ private static _nextRequestId = 1;
43
+ private static _legacyRequestIds = new Map<string, number>();
44
+ private static _legacyRequestIdSet = new Set<number>();
45
+
37
46
  private readonly eventEmitter = new AdEventEmitter();
38
47
 
39
- private constructor(private readonly adUnitId: string) {}
48
+ private constructor(
49
+ private readonly requestId: number,
50
+ private readonly adUnitId: string
51
+ ) {}
40
52
 
41
53
  static createForAdRequest(adUnitId: string): AppOpenAd {
42
- return new AppOpenAd(adUnitId);
54
+ const requestId = AppOpenAd._nextRequestId++;
55
+ return new AppOpenAd(requestId, adUnitId);
43
56
  }
44
57
 
45
58
  isAdReady(): Promise<boolean> {
46
- return DaroMModule.isAppOpenAdReady(this.adUnitId);
59
+ if (!IS_SUPPORTED_PLATFORM) {
60
+ return Promise.resolve(false);
61
+ }
62
+ return NativeDaroModule.isAppOpenAdReady(this.requestId, this.adUnitId);
47
63
  }
48
64
 
49
65
  load(): void {
50
- DaroMModule.loadAppOpenAd(this.adUnitId);
66
+ if (!IS_SUPPORTED_PLATFORM) {
67
+ warnUnsupportedPlatform();
68
+ return;
69
+ }
70
+ NativeDaroModule.loadAppOpenAd(this.requestId, this.adUnitId);
51
71
  }
52
72
 
53
73
  show(placement?: string | null, customData?: string | null): void {
54
- DaroMModule.showAppOpenAd(
74
+ if (!IS_SUPPORTED_PLATFORM) {
75
+ warnUnsupportedPlatform();
76
+ return;
77
+ }
78
+ NativeDaroModule.showAppOpenAd(
79
+ this.requestId,
55
80
  this.adUnitId,
56
81
  placement ?? undefined,
57
82
  customData ?? undefined
@@ -62,10 +87,15 @@ export class AppOpenAd {
62
87
  type: T,
63
88
  listener: (info: AdEventPayloadMap[T]) => void
64
89
  ): () => void {
90
+ if (!IS_SUPPORTED_PLATFORM) {
91
+ warnUnsupportedPlatform();
92
+ return () => {};
93
+ }
94
+
65
95
  const nativeEvent = NATIVE_EVENT_BY_TYPE[type];
66
- const adUnitId = this.adUnitId;
96
+ const requestId = this.requestId;
67
97
  return this.eventEmitter.addEventListener(nativeEvent, (payload: any) => {
68
- if (payload?.adUnitId !== undefined && payload.adUnitId !== adUnitId) {
98
+ if (payload?.requestId !== requestId) {
69
99
  return;
70
100
  }
71
101
  listener(payload);
@@ -78,14 +108,50 @@ export class AppOpenAd {
78
108
 
79
109
  // ---- Deprecated static API (backward compatibility) ----
80
110
 
111
+ private static _getLegacyRequestId(adUnitId: string): number {
112
+ let requestId = AppOpenAd._legacyRequestIds.get(adUnitId);
113
+ if (requestId === undefined) {
114
+ requestId = AppOpenAd._nextRequestId++;
115
+ AppOpenAd._legacyRequestIds.set(adUnitId, requestId);
116
+ AppOpenAd._legacyRequestIdSet.add(requestId);
117
+ }
118
+ return requestId;
119
+ }
120
+
121
+ private static _addLegacyEventListener<T>(
122
+ event: string,
123
+ listener: (info: T) => void
124
+ ): void {
125
+ if (!IS_SUPPORTED_PLATFORM) {
126
+ warnUnsupportedPlatform();
127
+ return;
128
+ }
129
+
130
+ addEventListener(event, (payload: any) => {
131
+ if (!AppOpenAd._legacyRequestIdSet.has(payload?.requestId)) {
132
+ return;
133
+ }
134
+ listener(payload);
135
+ });
136
+ }
137
+
81
138
  /** @deprecated `AppOpenAd.createForAdRequest(adUnitId)` 인스턴스의 `isAdReady()`를 사용하세요. */
82
139
  static isAdReady(adUnitId: string): Promise<boolean> {
83
- return DaroMModule.isAppOpenAdReady(adUnitId);
140
+ if (!IS_SUPPORTED_PLATFORM) {
141
+ return Promise.resolve(false);
142
+ }
143
+ const requestId = AppOpenAd._getLegacyRequestId(adUnitId);
144
+ return NativeDaroModule.isAppOpenAdReady(requestId, adUnitId);
84
145
  }
85
146
 
86
147
  /** @deprecated `AppOpenAd.createForAdRequest(adUnitId)` 인스턴스의 `load()`를 사용하세요. */
87
148
  static loadAd(adUnitId: string): void {
88
- DaroMModule.loadAppOpenAd(adUnitId);
149
+ if (!IS_SUPPORTED_PLATFORM) {
150
+ warnUnsupportedPlatform();
151
+ return;
152
+ }
153
+ const requestId = AppOpenAd._getLegacyRequestId(adUnitId);
154
+ NativeDaroModule.loadAppOpenAd(requestId, adUnitId);
89
155
  }
90
156
 
91
157
  /** @deprecated `AppOpenAd.createForAdRequest(adUnitId)` 인스턴스의 `show()`를 사용하세요. */
@@ -94,7 +160,13 @@ export class AppOpenAd {
94
160
  placement?: string | null,
95
161
  customData?: string | null
96
162
  ): void {
97
- DaroMModule.showAppOpenAd(
163
+ if (!IS_SUPPORTED_PLATFORM) {
164
+ warnUnsupportedPlatform();
165
+ return;
166
+ }
167
+ const requestId = AppOpenAd._getLegacyRequestId(adUnitId);
168
+ NativeDaroModule.showAppOpenAd(
169
+ requestId,
98
170
  adUnitId,
99
171
  placement ?? undefined,
100
172
  customData ?? undefined
@@ -103,7 +175,7 @@ export class AppOpenAd {
103
175
 
104
176
  /** @deprecated `addAdEventListener(AdEventType.LOADED, ...)`를 인스턴스에서 사용하세요. */
105
177
  static addAdLoadedEventListener(listener: (adInfo: AdInfo) => void): void {
106
- addEventListener(ON_APPOPEN_AD_LOADED_EVENT, listener);
178
+ AppOpenAd._addLegacyEventListener(ON_APPOPEN_AD_LOADED_EVENT, listener);
107
179
  }
108
180
 
109
181
  /** @deprecated 인스턴스의 `addAdEventListener` disposer를 사용하세요. */
@@ -115,7 +187,10 @@ export class AppOpenAd {
115
187
  static addAdLoadFailedEventListener(
116
188
  listener: (errorInfo: AdLoadFailedInfo) => void
117
189
  ): void {
118
- addEventListener(ON_APPOPEN_AD_LOAD_FAILED_EVENT, listener);
190
+ AppOpenAd._addLegacyEventListener(
191
+ ON_APPOPEN_AD_LOAD_FAILED_EVENT,
192
+ listener
193
+ );
119
194
  }
120
195
 
121
196
  /** @deprecated 인스턴스의 `addAdEventListener` disposer를 사용하세요. */
@@ -125,7 +200,7 @@ export class AppOpenAd {
125
200
 
126
201
  /** @deprecated `addAdEventListener(AdEventType.CLICKED, ...)`를 인스턴스에서 사용하세요. */
127
202
  static addAdClickedEventListener(listener: (adInfo: AdInfo) => void): void {
128
- addEventListener(ON_APPOPEN_AD_CLICKED_EVENT, listener);
203
+ AppOpenAd._addLegacyEventListener(ON_APPOPEN_AD_CLICKED_EVENT, listener);
129
204
  }
130
205
 
131
206
  /** @deprecated 인스턴스의 `addAdEventListener` disposer를 사용하세요. */
@@ -135,7 +210,7 @@ export class AppOpenAd {
135
210
 
136
211
  /** @deprecated `addAdEventListener(AdEventType.DISPLAYED, ...)`를 인스턴스에서 사용하세요. */
137
212
  static addAdDisplayedEventListener(listener: (adInfo: AdInfo) => void): void {
138
- addEventListener(ON_APPOPEN_AD_DISPLAYED_EVENT, listener);
213
+ AppOpenAd._addLegacyEventListener(ON_APPOPEN_AD_DISPLAYED_EVENT, listener);
139
214
  }
140
215
 
141
216
  /** @deprecated 인스턴스의 `addAdEventListener` disposer를 사용하세요. */
@@ -147,7 +222,10 @@ export class AppOpenAd {
147
222
  static addAdFailedToDisplayEventListener(
148
223
  listener: (errorInfo: AdDisplayFailedInfo) => void
149
224
  ): void {
150
- addEventListener(ON_APPOPEN_AD_FAILED_TO_DISPLAY_EVENT, listener);
225
+ AppOpenAd._addLegacyEventListener(
226
+ ON_APPOPEN_AD_FAILED_TO_DISPLAY_EVENT,
227
+ listener
228
+ );
151
229
  }
152
230
 
153
231
  /** @deprecated 인스턴스의 `addAdEventListener` disposer를 사용하세요. */
@@ -157,7 +235,7 @@ export class AppOpenAd {
157
235
 
158
236
  /** @deprecated `addAdEventListener(AdEventType.HIDDEN, ...)`를 인스턴스에서 사용하세요. */
159
237
  static addAdHiddenEventListener(listener: (adInfo: AdInfo) => void): void {
160
- addEventListener(ON_APPOPEN_AD_HIDDEN_EVENT, listener);
238
+ AppOpenAd._addLegacyEventListener(ON_APPOPEN_AD_HIDDEN_EVENT, listener);
161
239
  }
162
240
 
163
241
  /** @deprecated 인스턴스의 `addAdEventListener` disposer를 사용하세요. */
@@ -169,7 +247,10 @@ export class AppOpenAd {
169
247
  static addAdImpressionRecordedListener(
170
248
  listener: (adInfo: AdInfo) => void
171
249
  ): void {
172
- addEventListener(ON_APPOPEN_AD_IMPRESSION_RECORDED, listener);
250
+ AppOpenAd._addLegacyEventListener(
251
+ ON_APPOPEN_AD_IMPRESSION_RECORDED,
252
+ listener
253
+ );
173
254
  }
174
255
 
175
256
  /** @deprecated 인스턴스의 `addAdEventListener` disposer를 사용하세요. */
@@ -0,0 +1,47 @@
1
+ /* eslint-disable @react-native/no-deep-imports -- React Native 0.74 codegen parser compatibility requires these imports. */
2
+ import type * as React from 'react';
3
+ import type { HostComponent, ViewProps } from 'react-native';
4
+ import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
5
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
6
+ import type {
7
+ DirectEventHandler,
8
+ Double,
9
+ Int32,
10
+ WithDefault,
11
+ } from 'react-native/Libraries/Types/CodegenTypes';
12
+
13
+ type AdInfoPayload = {
14
+ adUnitId: string;
15
+ latencyMillis: Double;
16
+ };
17
+
18
+ type AdLoadFailedInfoPayload = {
19
+ adUnitId: string;
20
+ code: Int32;
21
+ message: string;
22
+ latencyMillis: Double;
23
+ };
24
+
25
+ export interface NativeProps extends ViewProps {
26
+ adUnitId: string;
27
+ adFormat: string;
28
+ placement?: string | null;
29
+ loadOnMount?: WithDefault<boolean, true>;
30
+ isVisible?: WithDefault<boolean, true>;
31
+ onAdLoadedEvent?: DirectEventHandler<AdInfoPayload>;
32
+ onAdLoadFailedEvent?: DirectEventHandler<AdLoadFailedInfoPayload>;
33
+ onAdClickedEvent?: DirectEventHandler<AdInfoPayload>;
34
+ onAdImpressionRecordedEvent?: DirectEventHandler<AdInfoPayload>;
35
+ }
36
+
37
+ type ComponentType = HostComponent<NativeProps>;
38
+
39
+ interface NativeCommands {
40
+ loadAd: (viewRef: React.ElementRef<ComponentType>) => void;
41
+ }
42
+
43
+ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
44
+ supportedCommands: ['loadAd'],
45
+ });
46
+
47
+ export default codegenNativeComponent<NativeProps>('DaroMAdBannerView');
@@ -0,0 +1,62 @@
1
+ /* eslint-disable @react-native/no-deep-imports -- React Native 0.74 codegen parser compatibility requires these imports. */
2
+ import type * as React from 'react';
3
+ import type { HostComponent, ViewProps } from 'react-native';
4
+ import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
5
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
6
+ import type {
7
+ DirectEventHandler,
8
+ Double,
9
+ Int32,
10
+ UnsafeMixed,
11
+ WithDefault,
12
+ } from 'react-native/Libraries/Types/CodegenTypes';
13
+
14
+ type AdInfoPayload = {
15
+ adUnitId: string;
16
+ latencyMillis: Double;
17
+ };
18
+
19
+ type AdLoadFailedInfoPayload = {
20
+ adUnitId: string;
21
+ code: Int32;
22
+ message: string;
23
+ latencyMillis: Double;
24
+ };
25
+
26
+ type AdChoicesPosition = 'topLeft' | 'topRight' | 'bottomRight' | 'bottomLeft';
27
+
28
+ export interface NativeProps extends ViewProps {
29
+ adUnitId: string;
30
+ placement?: string | null;
31
+ loadOnMount?: WithDefault<boolean, true>;
32
+ adChoicesPosition?: WithDefault<AdChoicesPosition, 'bottomRight'>;
33
+
34
+ titleView?: Int32;
35
+ bodyView?: Int32;
36
+ callToActionView?: Int32;
37
+ iconView?: Int32;
38
+ mediaView?: Int32;
39
+
40
+ titleViewStyleProps?: UnsafeMixed;
41
+ bodyViewStyleProps?: UnsafeMixed;
42
+ callToActionViewStyleProps?: UnsafeMixed;
43
+ iconViewStyleProps?: UnsafeMixed;
44
+ mediaViewStyleProps?: UnsafeMixed;
45
+
46
+ onAdLoadedEvent?: DirectEventHandler<AdInfoPayload>;
47
+ onAdLoadFailedEvent?: DirectEventHandler<AdLoadFailedInfoPayload>;
48
+ onAdClickedEvent?: DirectEventHandler<AdInfoPayload>;
49
+ onAdImpressionRecordedEvent?: DirectEventHandler<AdInfoPayload>;
50
+ }
51
+
52
+ type ComponentType = HostComponent<NativeProps>;
53
+
54
+ interface NativeCommands {
55
+ loadAd: (viewRef: React.ElementRef<ComponentType>) => void;
56
+ }
57
+
58
+ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
59
+ supportedCommands: ['loadAd'],
60
+ });
61
+
62
+ export default codegenNativeComponent<NativeProps>('DaroMNativeAdView');
@@ -0,0 +1,9 @@
1
+ /* eslint-disable @react-native/no-deep-imports -- React Native 0.74 codegen parser compatibility requires this import. */
2
+ import type { ViewProps } from 'react-native';
3
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
4
+
5
+ export interface NativeProps extends ViewProps {}
6
+
7
+ export default codegenNativeComponent<NativeProps>('DaroMediaView', {
8
+ excludedPlatforms: ['iOS'],
9
+ });
package/src/ErrorCode.ts CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  export enum ErrorCode {
3
- UNSPECIFIED = 0
2
+ UNSPECIFIED = 0,
4
3
  }
@@ -1,17 +1,19 @@
1
- import { NativeModules, NativeEventEmitter } from 'react-native';
1
+ import { NativeEventEmitter } from 'react-native';
2
2
  import type { EventSubscription } from 'react-native';
3
+ import NativeDaroModule from './NativeDaroModule';
3
4
  import type { AdEventObject, AdEventListener } from './types/AdEvent';
4
5
 
5
- const { DaroMModule } = NativeModules;
6
-
7
- const emitter = new NativeEventEmitter(DaroMModule);
6
+ const emitter = new NativeEventEmitter(NativeDaroModule);
8
7
  const subscriptions: Map<string, Set<EventSubscription>> = new Map();
9
8
 
10
9
  export const addEventListener = <T extends AdEventObject>(
11
10
  event: string,
12
11
  handler: AdEventListener<T>
13
12
  ): (() => void) => {
14
- const subscription: EventSubscription = emitter.addListener(event, handler);
13
+ const subscription: EventSubscription = emitter.addListener(
14
+ event,
15
+ handler as (...args: Object[]) => void
16
+ );
15
17
 
16
18
  if (!subscriptions.has(event)) {
17
19
  subscriptions.set(event, new Set());
@@ -34,7 +36,7 @@ export class AdEventEmitter {
34
36
  private subscriptions: Map<string, Set<EventSubscription>> = new Map();
35
37
 
36
38
  constructor() {
37
- this.emitter = new NativeEventEmitter(DaroMModule);
39
+ this.emitter = new NativeEventEmitter(NativeDaroModule);
38
40
  }
39
41
 
40
42
  addEventListener<T extends AdEventObject>(
@@ -43,7 +45,7 @@ export class AdEventEmitter {
43
45
  ): () => void {
44
46
  const subscription: EventSubscription = this.emitter.addListener(
45
47
  event,
46
- handler
48
+ handler as (...args: Object[]) => void
47
49
  );
48
50
 
49
51
  if (!this.subscriptions.has(event)) {