react-native-daro 2.0.7 → 2.0.9-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/README.md +2 -2
  2. package/android/build.gradle +3 -1
  3. package/android/src/main/java/com/daro/reactnative/DaroRNAdBannerViewManager.kt +8 -3
  4. package/android/src/main/java/com/daro/reactnative/DaroRNAdNativeViewManager.kt +8 -3
  5. package/android/src/main/java/com/daro/reactnative/DaroRNModule.kt +76 -34
  6. package/android/src/main/java/com/daro/reactnative/event/DaroRNEvent.kt +8 -0
  7. package/android/src/main/java/com/daro/reactnative/impl/DaroRNInterstitialModuleImpl.kt +13 -13
  8. package/android/src/main/java/com/daro/reactnative/impl/DaroRNLightPopupModuleImpl.kt +12 -12
  9. package/android/src/main/java/com/daro/reactnative/impl/DaroRNPreloadModuleImpl.kt +77 -0
  10. package/android/src/main/java/com/daro/reactnative/impl/DaroRNRewardedAdModuleImpl.kt +14 -14
  11. package/android/src/main/java/com/daro/reactnative/preload/DaroRNPreloadRegistry.kt +57 -0
  12. package/android/src/main/java/com/daro/reactnative/util/AdInfoUtil.kt +27 -16
  13. package/android/src/main/java/com/daro/reactnative/view/DaroMediaView.kt +3 -0
  14. package/android/src/main/java/com/daro/reactnative/view/DaroRNAdBannerViewContainer.kt +36 -15
  15. package/android/src/main/java/com/daro/reactnative/view/DaroRNAdNativeViewContainer.kt +36 -15
  16. package/android/src/oldarch/java/com/daro/reactnative/DaroRNModuleSpec.kt +28 -14
  17. package/android/src/test/java/com/daro/reactnative/preload/DaroRNPreloadRegistryTest.kt +65 -0
  18. package/android/src/test/java/com/daro/reactnative/view/DaroMediaViewTest.kt +45 -0
  19. package/android/src/test/java/com/daro/reactnative/view/DaroRNPreloadFirstLoadTest.kt +160 -0
  20. package/ios/DaroRNModule+AppOpen.swift +9 -9
  21. package/ios/DaroRNModule+Interstitial.swift +9 -9
  22. package/ios/DaroRNModule+LightPopup.swift +13 -13
  23. package/ios/DaroRNModule+Preload.swift +122 -0
  24. package/ios/DaroRNModule+Rewarded.swift +14 -14
  25. package/ios/DaroRNModule.mm +20 -14
  26. package/ios/DaroRNModule.swift +6 -1
  27. package/ios/Fabric/DaroRNAdBannerComponentView.mm +12 -7
  28. package/ios/Fabric/DaroRNNativeAdComponentView.mm +12 -7
  29. package/ios/Paper/DaroRNAdBannerViewManager.m +2 -1
  30. package/ios/Paper/DaroRNNativeAdViewManager.m +2 -1
  31. package/ios/Shared/DaroRNBannerAdView.swift +23 -9
  32. package/ios/Shared/DaroRNNativeAdView.swift +77 -46
  33. package/ios/Shared/DaroRNPreloadRegistry.swift +54 -0
  34. package/lib/commonjs/AdBannerView.js +4 -2
  35. package/lib/commonjs/AdBannerView.js.map +1 -1
  36. package/lib/commonjs/AdPreload.js +105 -0
  37. package/lib/commonjs/AdPreload.js.map +1 -0
  38. package/lib/commonjs/AppOpenAd.js +22 -22
  39. package/lib/commonjs/AppOpenAd.js.map +1 -1
  40. package/lib/commonjs/DaroRNAdBannerViewNativeComponent.ts +5 -3
  41. package/lib/commonjs/DaroRNNativeAdViewNativeComponent.ts +5 -3
  42. package/lib/commonjs/InterstitialAd.js +24 -24
  43. package/lib/commonjs/InterstitialAd.js.map +1 -1
  44. package/lib/commonjs/LightPopupAd.js +27 -27
  45. package/lib/commonjs/LightPopupAd.js.map +1 -1
  46. package/lib/commonjs/NativeDaroModule.js.map +1 -1
  47. package/lib/commonjs/RewardedAd.js +22 -22
  48. package/lib/commonjs/RewardedAd.js.map +1 -1
  49. package/lib/commonjs/hooks/useAdPreload.js +61 -0
  50. package/lib/commonjs/hooks/useAdPreload.js.map +1 -0
  51. package/lib/commonjs/hooks/useInterstitialAd.js +6 -6
  52. package/lib/commonjs/hooks/useInterstitialAd.js.map +1 -1
  53. package/lib/commonjs/hooks/useLightPopupAd.js +5 -5
  54. package/lib/commonjs/hooks/useLightPopupAd.js.map +1 -1
  55. package/lib/commonjs/hooks/useRewardedAd.js +6 -6
  56. package/lib/commonjs/hooks/useRewardedAd.js.map +1 -1
  57. package/lib/commonjs/index.js +37 -0
  58. package/lib/commonjs/index.js.map +1 -1
  59. package/lib/commonjs/nativeAd/NativeAdView.js +4 -2
  60. package/lib/commonjs/nativeAd/NativeAdView.js.map +1 -1
  61. package/lib/commonjs/types/NativeAdViewProps.js.map +1 -1
  62. package/lib/module/AdBannerView.js +4 -2
  63. package/lib/module/AdBannerView.js.map +1 -1
  64. package/lib/module/AdPreload.js +98 -0
  65. package/lib/module/AdPreload.js.map +1 -0
  66. package/lib/module/AppOpenAd.js +22 -22
  67. package/lib/module/AppOpenAd.js.map +1 -1
  68. package/lib/module/DaroRNAdBannerViewNativeComponent.ts +5 -3
  69. package/lib/module/DaroRNNativeAdViewNativeComponent.ts +5 -3
  70. package/lib/module/InterstitialAd.js +24 -24
  71. package/lib/module/InterstitialAd.js.map +1 -1
  72. package/lib/module/LightPopupAd.js +27 -27
  73. package/lib/module/LightPopupAd.js.map +1 -1
  74. package/lib/module/NativeDaroModule.js.map +1 -1
  75. package/lib/module/RewardedAd.js +22 -22
  76. package/lib/module/RewardedAd.js.map +1 -1
  77. package/lib/module/hooks/useAdPreload.js +56 -0
  78. package/lib/module/hooks/useAdPreload.js.map +1 -0
  79. package/lib/module/hooks/useInterstitialAd.js +6 -6
  80. package/lib/module/hooks/useInterstitialAd.js.map +1 -1
  81. package/lib/module/hooks/useLightPopupAd.js +5 -5
  82. package/lib/module/hooks/useLightPopupAd.js.map +1 -1
  83. package/lib/module/hooks/useRewardedAd.js +6 -6
  84. package/lib/module/hooks/useRewardedAd.js.map +1 -1
  85. package/lib/module/index.js +2 -0
  86. package/lib/module/index.js.map +1 -1
  87. package/lib/module/nativeAd/NativeAdView.js +4 -2
  88. package/lib/module/nativeAd/NativeAdView.js.map +1 -1
  89. package/lib/module/types/NativeAdViewProps.js.map +1 -1
  90. package/lib/typescript/commonjs/src/AdBannerView.d.ts +1 -0
  91. package/lib/typescript/commonjs/src/AdBannerView.d.ts.map +1 -1
  92. package/lib/typescript/commonjs/src/AdPreload.d.ts +62 -0
  93. package/lib/typescript/commonjs/src/AdPreload.d.ts.map +1 -0
  94. package/lib/typescript/commonjs/src/AppOpenAd.d.ts +8 -8
  95. package/lib/typescript/commonjs/src/AppOpenAd.d.ts.map +1 -1
  96. package/lib/typescript/commonjs/src/DaroRNAdBannerViewNativeComponent.d.ts +4 -3
  97. package/lib/typescript/commonjs/src/DaroRNAdBannerViewNativeComponent.d.ts.map +1 -1
  98. package/lib/typescript/commonjs/src/DaroRNNativeAdViewNativeComponent.d.ts +4 -3
  99. package/lib/typescript/commonjs/src/DaroRNNativeAdViewNativeComponent.d.ts.map +1 -1
  100. package/lib/typescript/commonjs/src/InterstitialAd.d.ts +8 -8
  101. package/lib/typescript/commonjs/src/InterstitialAd.d.ts.map +1 -1
  102. package/lib/typescript/commonjs/src/LightPopupAd.d.ts +9 -9
  103. package/lib/typescript/commonjs/src/LightPopupAd.d.ts.map +1 -1
  104. package/lib/typescript/commonjs/src/NativeDaroModule.d.ts +19 -14
  105. package/lib/typescript/commonjs/src/NativeDaroModule.d.ts.map +1 -1
  106. package/lib/typescript/commonjs/src/RewardedAd.d.ts +8 -8
  107. package/lib/typescript/commonjs/src/RewardedAd.d.ts.map +1 -1
  108. package/lib/typescript/commonjs/src/hooks/useAdPreload.d.ts +19 -0
  109. package/lib/typescript/commonjs/src/hooks/useAdPreload.d.ts.map +1 -0
  110. package/lib/typescript/commonjs/src/hooks/useInterstitialAd.d.ts +1 -1
  111. package/lib/typescript/commonjs/src/hooks/useInterstitialAd.d.ts.map +1 -1
  112. package/lib/typescript/commonjs/src/hooks/useLightPopupAd.d.ts +1 -1
  113. package/lib/typescript/commonjs/src/hooks/useLightPopupAd.d.ts.map +1 -1
  114. package/lib/typescript/commonjs/src/hooks/useRewardedAd.d.ts +1 -1
  115. package/lib/typescript/commonjs/src/hooks/useRewardedAd.d.ts.map +1 -1
  116. package/lib/typescript/commonjs/src/index.d.ts +4 -0
  117. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  118. package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts +1 -0
  119. package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts.map +1 -1
  120. package/lib/typescript/commonjs/src/types/AdBannerViewProps.d.ts +6 -0
  121. package/lib/typescript/commonjs/src/types/AdBannerViewProps.d.ts.map +1 -1
  122. package/lib/typescript/commonjs/src/types/AdInfo.d.ts +2 -2
  123. package/lib/typescript/commonjs/src/types/AdInfo.d.ts.map +1 -1
  124. package/lib/typescript/commonjs/src/types/AdProps.d.ts +1 -1
  125. package/lib/typescript/commonjs/src/types/AdProps.d.ts.map +1 -1
  126. package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts +6 -0
  127. package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts.map +1 -1
  128. package/lib/typescript/module/src/AdBannerView.d.ts +1 -0
  129. package/lib/typescript/module/src/AdBannerView.d.ts.map +1 -1
  130. package/lib/typescript/module/src/AdPreload.d.ts +62 -0
  131. package/lib/typescript/module/src/AdPreload.d.ts.map +1 -0
  132. package/lib/typescript/module/src/AppOpenAd.d.ts +8 -8
  133. package/lib/typescript/module/src/AppOpenAd.d.ts.map +1 -1
  134. package/lib/typescript/module/src/DaroRNAdBannerViewNativeComponent.d.ts +4 -3
  135. package/lib/typescript/module/src/DaroRNAdBannerViewNativeComponent.d.ts.map +1 -1
  136. package/lib/typescript/module/src/DaroRNNativeAdViewNativeComponent.d.ts +4 -3
  137. package/lib/typescript/module/src/DaroRNNativeAdViewNativeComponent.d.ts.map +1 -1
  138. package/lib/typescript/module/src/InterstitialAd.d.ts +8 -8
  139. package/lib/typescript/module/src/InterstitialAd.d.ts.map +1 -1
  140. package/lib/typescript/module/src/LightPopupAd.d.ts +9 -9
  141. package/lib/typescript/module/src/LightPopupAd.d.ts.map +1 -1
  142. package/lib/typescript/module/src/NativeDaroModule.d.ts +19 -14
  143. package/lib/typescript/module/src/NativeDaroModule.d.ts.map +1 -1
  144. package/lib/typescript/module/src/RewardedAd.d.ts +8 -8
  145. package/lib/typescript/module/src/RewardedAd.d.ts.map +1 -1
  146. package/lib/typescript/module/src/hooks/useAdPreload.d.ts +19 -0
  147. package/lib/typescript/module/src/hooks/useAdPreload.d.ts.map +1 -0
  148. package/lib/typescript/module/src/hooks/useInterstitialAd.d.ts +1 -1
  149. package/lib/typescript/module/src/hooks/useInterstitialAd.d.ts.map +1 -1
  150. package/lib/typescript/module/src/hooks/useLightPopupAd.d.ts +1 -1
  151. package/lib/typescript/module/src/hooks/useLightPopupAd.d.ts.map +1 -1
  152. package/lib/typescript/module/src/hooks/useRewardedAd.d.ts +1 -1
  153. package/lib/typescript/module/src/hooks/useRewardedAd.d.ts.map +1 -1
  154. package/lib/typescript/module/src/index.d.ts +4 -0
  155. package/lib/typescript/module/src/index.d.ts.map +1 -1
  156. package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts +1 -0
  157. package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts.map +1 -1
  158. package/lib/typescript/module/src/types/AdBannerViewProps.d.ts +6 -0
  159. package/lib/typescript/module/src/types/AdBannerViewProps.d.ts.map +1 -1
  160. package/lib/typescript/module/src/types/AdInfo.d.ts +2 -2
  161. package/lib/typescript/module/src/types/AdInfo.d.ts.map +1 -1
  162. package/lib/typescript/module/src/types/AdProps.d.ts +1 -1
  163. package/lib/typescript/module/src/types/AdProps.d.ts.map +1 -1
  164. package/lib/typescript/module/src/types/NativeAdViewProps.d.ts +6 -0
  165. package/lib/typescript/module/src/types/NativeAdViewProps.d.ts.map +1 -1
  166. package/package.json +1 -1
  167. package/plugin/build/withAndroid.js +2 -2
  168. package/react-native-daro.podspec +1 -1
  169. package/src/AdBannerView.tsx +4 -2
  170. package/src/AdPreload.ts +141 -0
  171. package/src/AppOpenAd.ts +21 -21
  172. package/src/DaroRNAdBannerViewNativeComponent.ts +5 -3
  173. package/src/DaroRNNativeAdViewNativeComponent.ts +5 -3
  174. package/src/InterstitialAd.ts +23 -23
  175. package/src/LightPopupAd.ts +26 -26
  176. package/src/NativeDaroModule.ts +31 -14
  177. package/src/RewardedAd.ts +21 -21
  178. package/src/hooks/useAdPreload.ts +82 -0
  179. package/src/hooks/useInterstitialAd.ts +6 -6
  180. package/src/hooks/useLightPopupAd.ts +5 -5
  181. package/src/hooks/useRewardedAd.ts +6 -6
  182. package/src/index.tsx +16 -0
  183. package/src/nativeAd/NativeAdView.tsx +4 -2
  184. package/src/types/AdBannerViewProps.ts +6 -0
  185. package/src/types/AdInfo.ts +2 -2
  186. package/src/types/AdProps.ts +1 -1
  187. package/src/types/NativeAdViewProps.ts +6 -0
@@ -45,10 +45,11 @@ export const AdBannerView = forwardRef<
45
45
  AdBannerViewProps & ViewProps
46
46
  >(function AdBannerView(
47
47
  {
48
- adUnitId,
48
+ adUnitKey,
49
49
  adFormat,
50
50
  loadOnMount = true,
51
51
  isVisible = true,
52
+ preload,
52
53
  onAdLoaded,
53
54
  onAdLoadFailed,
54
55
  onAdClicked,
@@ -125,8 +126,9 @@ export const AdBannerView = forwardRef<
125
126
  style={style}
126
127
  adFormat={toNativeAdFormat(adFormat)}
127
128
  ref={saveElement}
128
- adUnitId={adUnitId}
129
+ adUnitKey={adUnitKey}
129
130
  loadOnMount={loadOnMount}
131
+ preloadId={preload?.preloadId}
130
132
  isVisible={isVisible}
131
133
  onAdLoadedEvent={onAdLoadedEvent}
132
134
  onAdLoadFailedEvent={onAdLoadFailedEvent}
@@ -0,0 +1,141 @@
1
+ import { AdEventEmitter } from './EventEmitter';
2
+ import NativeDaroModule from './NativeDaroModule';
3
+ import type { AdFormat } from './AdBannerView';
4
+ import type { AdInfo, AdLoadFailedInfo } from './types/AdInfo';
5
+ import type { AdChoicesPosition } from './types/NativeAdViewProps';
6
+
7
+ const {
8
+ ON_AD_PRELOAD_SUCCESS_EVENT,
9
+ ON_AD_PRELOAD_FAILED_EVENT,
10
+ BANNER_AD_FORMAT_LABEL,
11
+ MREC_AD_FORMAT_LABEL,
12
+ } = NativeDaroModule.getConstants();
13
+
14
+ export enum AdPreloadEventType {
15
+ SUCCESS = 'SUCCESS',
16
+ FAIL = 'FAIL',
17
+ }
18
+
19
+ export interface AdPreloadEventPayloadMap {
20
+ [AdPreloadEventType.SUCCESS]: AdInfo;
21
+ [AdPreloadEventType.FAIL]: AdLoadFailedInfo;
22
+ }
23
+
24
+ const NATIVE_EVENT_BY_TYPE: Record<AdPreloadEventType, string> = {
25
+ [AdPreloadEventType.SUCCESS]: ON_AD_PRELOAD_SUCCESS_EVENT,
26
+ [AdPreloadEventType.FAIL]: ON_AD_PRELOAD_FAILED_EVENT,
27
+ };
28
+
29
+ let nextPreloadId = 1;
30
+
31
+ /**
32
+ * 뷰 광고 하나를 뷰 없이 미리 받아 두는 객체. 같은 화면의 `AdBannerView` / `NativeAdView` 에
33
+ * `preload` prop 으로 넘기면 마운트 때 받아 둔 광고를 쓴다.
34
+ *
35
+ * - 객체 하나에 광고 하나. 로딩 중이거나 유효한 광고가 있을 때의 {@link preload} 는 무시된다.
36
+ * - 받아 둔 광고는 한 번만 쓰인다. 마운트로 소비된 뒤 다시 받으려면 {@link preload} 를 다시 부른다.
37
+ * - 실패했거나 만료된 ( 10분 ) 광고를 넘겨받은 뷰는 일반 로드를 한다.
38
+ * - 쓰지 않은 광고는 화면을 떠날 때 {@link destroy} 로 정리한다.
39
+ */
40
+ abstract class AdPreload {
41
+ /** 뷰의 `preloadId` prop 으로 넘어가는 값. 직접 쓸 일은 없다. */
42
+ readonly preloadId = `daro-preload-${nextPreloadId++}`;
43
+
44
+ private readonly eventEmitter = new AdEventEmitter();
45
+ // destroy 뒤에 도착한 이전 요청의 결과를 버린다.
46
+ private active = false;
47
+
48
+ constructor(readonly adUnitKey: string) {}
49
+
50
+ protected abstract requestPreload(): Promise<void>;
51
+
52
+ /**
53
+ * 광고를 미리 받기 시작한다. Promise 는 네이티브가 요청을 받아 둔 시점에 끝난다 —
54
+ * 광고 수신 결과는 {@link addPreloadEventListener} 로 온다. 결과를 기다리지 않고 마운트해도 된다.
55
+ */
56
+ preload(): Promise<void> {
57
+ this.active = true;
58
+ return this.requestPreload();
59
+ }
60
+
61
+ addPreloadEventListener<T extends AdPreloadEventType>(
62
+ type: T,
63
+ listener: (info: AdPreloadEventPayloadMap[T]) => void
64
+ ): () => void {
65
+ const preloadId = this.preloadId;
66
+ return this.eventEmitter.addEventListener(
67
+ NATIVE_EVENT_BY_TYPE[type],
68
+ (payload: any) => {
69
+ if (!this.active || payload?.preloadId !== preloadId) {
70
+ return;
71
+ }
72
+ const info = { ...payload };
73
+ delete info.preloadId;
74
+ listener(info);
75
+ }
76
+ );
77
+ }
78
+
79
+ removeAllListeners(): void {
80
+ this.eventEmitter.removeAllListeners();
81
+ }
82
+
83
+ /**
84
+ * 쓰지 않은 광고를 정리한다. 여러 번 불러도 된다. 이미 뷰에 넘어간 광고는 그 뷰가 정리한다.
85
+ * 다시 {@link preload} 를 부르면 새로 받는다.
86
+ */
87
+ destroy(): void {
88
+ this.active = false;
89
+ NativeDaroModule.destroyAdPreload(this.preloadId);
90
+ }
91
+ }
92
+
93
+ export type BannerAdPreloadOptions = {
94
+ adUnitKey: string;
95
+ adFormat: AdFormat;
96
+ };
97
+
98
+ export class BannerAdPreload extends AdPreload {
99
+ readonly adFormat: AdFormat;
100
+
101
+ constructor({ adUnitKey, adFormat }: BannerAdPreloadOptions) {
102
+ super(adUnitKey);
103
+ this.adFormat = adFormat;
104
+ }
105
+
106
+ protected requestPreload(): Promise<void> {
107
+ return NativeDaroModule.preloadBannerAd(
108
+ this.preloadId,
109
+ this.adUnitKey,
110
+ (this.adFormat as string) === 'MREC'
111
+ ? MREC_AD_FORMAT_LABEL
112
+ : BANNER_AD_FORMAT_LABEL
113
+ );
114
+ }
115
+ }
116
+
117
+ export type NativeAdPreloadOptions = {
118
+ adUnitKey: string;
119
+ /** iOS 는 광고를 받을 때 정해진다. `NativeAdView` 의 `adChoicesPosition` 과 같은 값을 준다. */
120
+ adChoicesPosition?: AdChoicesPosition;
121
+ };
122
+
123
+ export class NativeAdPreload extends AdPreload {
124
+ readonly adChoicesPosition: AdChoicesPosition;
125
+
126
+ constructor({
127
+ adUnitKey,
128
+ adChoicesPosition = 'bottomRight',
129
+ }: NativeAdPreloadOptions) {
130
+ super(adUnitKey);
131
+ this.adChoicesPosition = adChoicesPosition;
132
+ }
133
+
134
+ protected requestPreload(): Promise<void> {
135
+ return NativeDaroModule.preloadNativeAd(
136
+ this.preloadId,
137
+ this.adUnitKey,
138
+ this.adChoicesPosition
139
+ );
140
+ }
141
+ }
package/src/AppOpenAd.ts CHANGED
@@ -47,19 +47,19 @@ export class AppOpenAd {
47
47
 
48
48
  private constructor(
49
49
  private readonly requestId: number,
50
- private readonly adUnitId: string
50
+ private readonly adUnitKey: string
51
51
  ) {}
52
52
 
53
- static createForAdRequest(adUnitId: string): AppOpenAd {
53
+ static createForAdRequest(adUnitKey: string): AppOpenAd {
54
54
  const requestId = AppOpenAd._nextRequestId++;
55
- return new AppOpenAd(requestId, adUnitId);
55
+ return new AppOpenAd(requestId, adUnitKey);
56
56
  }
57
57
 
58
58
  isAdReady(): Promise<boolean> {
59
59
  if (!IS_SUPPORTED_PLATFORM) {
60
60
  return Promise.resolve(false);
61
61
  }
62
- return NativeDaroModule.isAppOpenAdReady(this.requestId, this.adUnitId);
62
+ return NativeDaroModule.isAppOpenAdReady(this.requestId, this.adUnitKey);
63
63
  }
64
64
 
65
65
  load(): void {
@@ -67,7 +67,7 @@ export class AppOpenAd {
67
67
  warnUnsupportedPlatform();
68
68
  return;
69
69
  }
70
- NativeDaroModule.loadAppOpenAd(this.requestId, this.adUnitId);
70
+ NativeDaroModule.loadAppOpenAd(this.requestId, this.adUnitKey);
71
71
  }
72
72
 
73
73
  show(customData?: string | null): void {
@@ -77,7 +77,7 @@ export class AppOpenAd {
77
77
  }
78
78
  NativeDaroModule.showAppOpenAd(
79
79
  this.requestId,
80
- this.adUnitId,
80
+ this.adUnitKey,
81
81
  customData ?? undefined
82
82
  );
83
83
  }
@@ -107,11 +107,11 @@ export class AppOpenAd {
107
107
 
108
108
  // ---- Deprecated static API (backward compatibility) ----
109
109
 
110
- private static _getLegacyRequestId(adUnitId: string): number {
111
- let requestId = AppOpenAd._legacyRequestIds.get(adUnitId);
110
+ private static _getLegacyRequestId(adUnitKey: string): number {
111
+ let requestId = AppOpenAd._legacyRequestIds.get(adUnitKey);
112
112
  if (requestId === undefined) {
113
113
  requestId = AppOpenAd._nextRequestId++;
114
- AppOpenAd._legacyRequestIds.set(adUnitId, requestId);
114
+ AppOpenAd._legacyRequestIds.set(adUnitKey, requestId);
115
115
  AppOpenAd._legacyRequestIdSet.add(requestId);
116
116
  }
117
117
  return requestId;
@@ -134,35 +134,35 @@ export class AppOpenAd {
134
134
  });
135
135
  }
136
136
 
137
- /** @deprecated `AppOpenAd.createForAdRequest(adUnitId)` 인스턴스의 `isAdReady()`를 사용하세요. */
138
- static isAdReady(adUnitId: string): Promise<boolean> {
137
+ /** @deprecated `AppOpenAd.createForAdRequest(adUnitKey)` 인스턴스의 `isAdReady()`를 사용하세요. */
138
+ static isAdReady(adUnitKey: string): Promise<boolean> {
139
139
  if (!IS_SUPPORTED_PLATFORM) {
140
140
  return Promise.resolve(false);
141
141
  }
142
- const requestId = AppOpenAd._getLegacyRequestId(adUnitId);
143
- return NativeDaroModule.isAppOpenAdReady(requestId, adUnitId);
142
+ const requestId = AppOpenAd._getLegacyRequestId(adUnitKey);
143
+ return NativeDaroModule.isAppOpenAdReady(requestId, adUnitKey);
144
144
  }
145
145
 
146
- /** @deprecated `AppOpenAd.createForAdRequest(adUnitId)` 인스턴스의 `load()`를 사용하세요. */
147
- static loadAd(adUnitId: string): void {
146
+ /** @deprecated `AppOpenAd.createForAdRequest(adUnitKey)` 인스턴스의 `load()`를 사용하세요. */
147
+ static loadAd(adUnitKey: string): void {
148
148
  if (!IS_SUPPORTED_PLATFORM) {
149
149
  warnUnsupportedPlatform();
150
150
  return;
151
151
  }
152
- const requestId = AppOpenAd._getLegacyRequestId(adUnitId);
153
- NativeDaroModule.loadAppOpenAd(requestId, adUnitId);
152
+ const requestId = AppOpenAd._getLegacyRequestId(adUnitKey);
153
+ NativeDaroModule.loadAppOpenAd(requestId, adUnitKey);
154
154
  }
155
155
 
156
- /** @deprecated `AppOpenAd.createForAdRequest(adUnitId)` 인스턴스의 `show()`를 사용하세요. */
157
- static showAd(adUnitId: string, customData?: string | null): void {
156
+ /** @deprecated `AppOpenAd.createForAdRequest(adUnitKey)` 인스턴스의 `show()`를 사용하세요. */
157
+ static showAd(adUnitKey: string, customData?: string | null): void {
158
158
  if (!IS_SUPPORTED_PLATFORM) {
159
159
  warnUnsupportedPlatform();
160
160
  return;
161
161
  }
162
- const requestId = AppOpenAd._getLegacyRequestId(adUnitId);
162
+ const requestId = AppOpenAd._getLegacyRequestId(adUnitKey);
163
163
  NativeDaroModule.showAppOpenAd(
164
164
  requestId,
165
- adUnitId,
165
+ adUnitKey,
166
166
  customData ?? undefined
167
167
  );
168
168
  }
@@ -13,23 +13,25 @@ import type {
13
13
  // 필드 구성은 src/types/AdInfo.ts 의 AdInfo 와 같은 것을 뜻한다. 이쪽은 codegen 이
14
14
  // 읽는 선언이라 **여기 없으면 네이티브가 실어 보내도 Fabric 이 걸러낸다.**
15
15
  type AdInfoPayload = {
16
- adUnitId: string;
16
+ adUnitKey: string;
17
17
  latencyMillis: Double;
18
18
  mediationPlatform?: string;
19
19
  adNetwork?: string;
20
20
  };
21
21
 
22
22
  type AdLoadFailedInfoPayload = {
23
- adUnitId: string;
23
+ adUnitKey: string;
24
24
  code: Int32;
25
25
  message: string;
26
26
  latencyMillis: Double;
27
27
  };
28
28
 
29
29
  export interface NativeProps extends ViewProps {
30
- adUnitId: string;
30
+ adUnitKey: string;
31
31
  adFormat: string;
32
32
  loadOnMount?: WithDefault<boolean, true>;
33
+ // preload 로 받아 둔 광고의 id. 비어 있으면 일반 로드다.
34
+ preloadId?: string;
33
35
  isVisible?: WithDefault<boolean, true>;
34
36
  onAdLoadedEvent?: DirectEventHandler<AdInfoPayload>;
35
37
  onAdLoadFailedEvent?: DirectEventHandler<AdLoadFailedInfoPayload>;
@@ -14,14 +14,14 @@ import type {
14
14
  // 필드 구성은 src/types/AdInfo.ts 의 AdInfo 와 같은 것을 뜻한다. 이쪽은 codegen 이
15
15
  // 읽는 선언이라 **여기 없으면 네이티브가 실어 보내도 Fabric 이 걸러낸다.**
16
16
  type AdInfoPayload = {
17
- adUnitId: string;
17
+ adUnitKey: string;
18
18
  latencyMillis: Double;
19
19
  mediationPlatform?: string;
20
20
  adNetwork?: string;
21
21
  };
22
22
 
23
23
  type AdLoadFailedInfoPayload = {
24
- adUnitId: string;
24
+ adUnitKey: string;
25
25
  code: Int32;
26
26
  message: string;
27
27
  latencyMillis: Double;
@@ -30,8 +30,10 @@ type AdLoadFailedInfoPayload = {
30
30
  type AdChoicesPosition = 'topLeft' | 'topRight' | 'bottomRight' | 'bottomLeft';
31
31
 
32
32
  export interface NativeProps extends ViewProps {
33
- adUnitId: string;
33
+ adUnitKey: string;
34
34
  loadOnMount?: WithDefault<boolean, true>;
35
+ // preload 로 받아 둔 광고의 id. 비어 있으면 일반 로드다.
36
+ preloadId?: string;
35
37
  adChoicesPosition?: WithDefault<AdChoicesPosition, 'bottomRight'>;
36
38
 
37
39
  titleView?: Int32;
@@ -40,24 +40,24 @@ export class InterstitialAd {
40
40
 
41
41
  private constructor(
42
42
  private readonly requestId: number,
43
- private readonly adUnitId: string
43
+ private readonly adUnitKey: string
44
44
  ) {}
45
45
 
46
- static createForAdRequest(adUnitId: string): InterstitialAd {
46
+ static createForAdRequest(adUnitKey: string): InterstitialAd {
47
47
  const requestId = InterstitialAd._nextRequestId++;
48
- return new InterstitialAd(requestId, adUnitId);
48
+ return new InterstitialAd(requestId, adUnitKey);
49
49
  }
50
50
 
51
51
  isAdReady(): Promise<boolean> {
52
- return NativeDaroModule.isInterstitialReady(this.requestId, this.adUnitId);
52
+ return NativeDaroModule.isInterstitialReady(this.requestId, this.adUnitKey);
53
53
  }
54
54
 
55
55
  load(): void {
56
- NativeDaroModule.loadInterstitial(this.requestId, this.adUnitId);
56
+ NativeDaroModule.loadInterstitial(this.requestId, this.adUnitKey);
57
57
  }
58
58
 
59
59
  show(): void {
60
- NativeDaroModule.showInterstitial(this.requestId, this.adUnitId);
60
+ NativeDaroModule.showInterstitial(this.requestId, this.adUnitKey);
61
61
  }
62
62
 
63
63
  addAdEventListener<T extends AdEventType>(
@@ -79,14 +79,14 @@ export class InterstitialAd {
79
79
  }
80
80
 
81
81
  // ---- Deprecated static API (backward compatibility) ----
82
- // Static API allocates a stable requestId per adUnitId and reuses it.
83
- // Multiple static calls for the same adUnitId share the same native slot.
82
+ // Static API allocates a stable requestId per adUnitKey and reuses it.
83
+ // Multiple static calls for the same adUnitKey share the same native slot.
84
84
 
85
- private static _getLegacyRequestId(adUnitId: string): number {
86
- let requestId = InterstitialAd._legacyRequestIds.get(adUnitId);
85
+ private static _getLegacyRequestId(adUnitKey: string): number {
86
+ let requestId = InterstitialAd._legacyRequestIds.get(adUnitKey);
87
87
  if (requestId === undefined) {
88
88
  requestId = InterstitialAd._nextRequestId++;
89
- InterstitialAd._legacyRequestIds.set(adUnitId, requestId);
89
+ InterstitialAd._legacyRequestIds.set(adUnitKey, requestId);
90
90
  InterstitialAd._legacyRequestIdSet.add(requestId);
91
91
  }
92
92
  return requestId;
@@ -104,22 +104,22 @@ export class InterstitialAd {
104
104
  });
105
105
  }
106
106
 
107
- /** @deprecated `InterstitialAd.createForAdRequest(adUnitId)` 인스턴스의 `isAdReady()`를 사용하세요. */
108
- static isAdReady(adUnitId: string): Promise<boolean> {
109
- const requestId = InterstitialAd._getLegacyRequestId(adUnitId);
110
- return NativeDaroModule.isInterstitialReady(requestId, adUnitId);
107
+ /** @deprecated `InterstitialAd.createForAdRequest(adUnitKey)` 인스턴스의 `isAdReady()`를 사용하세요. */
108
+ static isAdReady(adUnitKey: string): Promise<boolean> {
109
+ const requestId = InterstitialAd._getLegacyRequestId(adUnitKey);
110
+ return NativeDaroModule.isInterstitialReady(requestId, adUnitKey);
111
111
  }
112
112
 
113
- /** @deprecated `InterstitialAd.createForAdRequest(adUnitId)` 인스턴스의 `load()`를 사용하세요. */
114
- static loadAd(adUnitId: string): void {
115
- const requestId = InterstitialAd._getLegacyRequestId(adUnitId);
116
- NativeDaroModule.loadInterstitial(requestId, adUnitId);
113
+ /** @deprecated `InterstitialAd.createForAdRequest(adUnitKey)` 인스턴스의 `load()`를 사용하세요. */
114
+ static loadAd(adUnitKey: string): void {
115
+ const requestId = InterstitialAd._getLegacyRequestId(adUnitKey);
116
+ NativeDaroModule.loadInterstitial(requestId, adUnitKey);
117
117
  }
118
118
 
119
- /** @deprecated `InterstitialAd.createForAdRequest(adUnitId)` 인스턴스의 `show()`를 사용하세요. */
120
- static showAd(adUnitId: string): void {
121
- const requestId = InterstitialAd._getLegacyRequestId(adUnitId);
122
- NativeDaroModule.showInterstitial(requestId, adUnitId);
119
+ /** @deprecated `InterstitialAd.createForAdRequest(adUnitKey)` 인스턴스의 `show()`를 사용하세요. */
120
+ static showAd(adUnitKey: string): void {
121
+ const requestId = InterstitialAd._getLegacyRequestId(adUnitKey);
122
+ NativeDaroModule.showInterstitial(requestId, adUnitKey);
123
123
  }
124
124
 
125
125
  /** @deprecated `addAdEventListener(AdEventType.LOADED, ...)`를 인스턴스에서 사용하세요. */
@@ -94,37 +94,37 @@ export class LightPopupAd {
94
94
 
95
95
  private constructor(
96
96
  private readonly requestId: number,
97
- private readonly adUnitId: string
97
+ private readonly adUnitKey: string
98
98
  ) {}
99
99
 
100
- static createForAdRequest(adUnitId: string): LightPopupAd {
100
+ static createForAdRequest(adUnitKey: string): LightPopupAd {
101
101
  const requestId = LightPopupAd._nextRequestId++;
102
- return new LightPopupAd(requestId, adUnitId);
102
+ return new LightPopupAd(requestId, adUnitKey);
103
103
  }
104
104
 
105
105
  isAdReady(): Promise<boolean> {
106
106
  if (this.destroyed) return Promise.resolve(false);
107
107
  return NativeDaroModule.isLightPopupReady(
108
108
  this.requestId,
109
- this.adUnitId
109
+ this.adUnitKey
110
110
  ).then((ready) => !this.destroyed && ready);
111
111
  }
112
112
 
113
113
  load(): void {
114
114
  if (this.destroyed) return;
115
- NativeDaroModule.loadLightPopup(this.requestId, this.adUnitId);
115
+ NativeDaroModule.loadLightPopup(this.requestId, this.adUnitKey);
116
116
  }
117
117
 
118
118
  show(): void {
119
119
  if (this.destroyed) return;
120
- NativeDaroModule.showLightPopup(this.requestId, this.adUnitId);
120
+ NativeDaroModule.showLightPopup(this.requestId, this.adUnitKey);
121
121
  }
122
122
 
123
123
  setConfiguration(configuration: LightPopupAdConfiguration): void {
124
124
  if (this.destroyed) return;
125
125
  NativeDaroModule.setLightPopupAdConfiguration(
126
126
  this.requestId,
127
- this.adUnitId,
127
+ this.adUnitKey,
128
128
  normalizeConfiguration(configuration)
129
129
  );
130
130
  }
@@ -153,16 +153,16 @@ export class LightPopupAd {
153
153
  if (this.destroyed) return;
154
154
  this.destroyed = true;
155
155
  this.removeAllListeners();
156
- NativeDaroModule.destroyLightPopup(this.requestId, this.adUnitId);
156
+ NativeDaroModule.destroyLightPopup(this.requestId, this.adUnitKey);
157
157
  }
158
158
 
159
159
  // ---- Deprecated static API (backward compatibility) ----
160
160
 
161
- private static _getLegacyRequestId(adUnitId: string): number {
162
- let requestId = LightPopupAd._legacyRequestIds.get(adUnitId);
161
+ private static _getLegacyRequestId(adUnitKey: string): number {
162
+ let requestId = LightPopupAd._legacyRequestIds.get(adUnitKey);
163
163
  if (requestId === undefined) {
164
164
  requestId = LightPopupAd._nextRequestId++;
165
- LightPopupAd._legacyRequestIds.set(adUnitId, requestId);
165
+ LightPopupAd._legacyRequestIds.set(adUnitKey, requestId);
166
166
  LightPopupAd._legacyRequestIdSet.add(requestId);
167
167
  }
168
168
  return requestId;
@@ -180,33 +180,33 @@ export class LightPopupAd {
180
180
  });
181
181
  }
182
182
 
183
- /** @deprecated `LightPopupAd.createForAdRequest(adUnitId)` 인스턴스의 `isAdReady()`를 사용하세요. */
184
- static isAdReady(adUnitId: string): Promise<boolean> {
185
- const requestId = LightPopupAd._getLegacyRequestId(adUnitId);
186
- return NativeDaroModule.isLightPopupReady(requestId, adUnitId);
183
+ /** @deprecated `LightPopupAd.createForAdRequest(adUnitKey)` 인스턴스의 `isAdReady()`를 사용하세요. */
184
+ static isAdReady(adUnitKey: string): Promise<boolean> {
185
+ const requestId = LightPopupAd._getLegacyRequestId(adUnitKey);
186
+ return NativeDaroModule.isLightPopupReady(requestId, adUnitKey);
187
187
  }
188
188
 
189
- /** @deprecated `LightPopupAd.createForAdRequest(adUnitId)` 인스턴스의 `load()`를 사용하세요. */
190
- static loadAd(adUnitId: string): void {
191
- const requestId = LightPopupAd._getLegacyRequestId(adUnitId);
192
- NativeDaroModule.loadLightPopup(requestId, adUnitId);
189
+ /** @deprecated `LightPopupAd.createForAdRequest(adUnitKey)` 인스턴스의 `load()`를 사용하세요. */
190
+ static loadAd(adUnitKey: string): void {
191
+ const requestId = LightPopupAd._getLegacyRequestId(adUnitKey);
192
+ NativeDaroModule.loadLightPopup(requestId, adUnitKey);
193
193
  }
194
194
 
195
- /** @deprecated `LightPopupAd.createForAdRequest(adUnitId)` 인스턴스의 `show()`를 사용하세요. */
196
- static showAd(adUnitId: string): void {
197
- const requestId = LightPopupAd._getLegacyRequestId(adUnitId);
198
- NativeDaroModule.showLightPopup(requestId, adUnitId);
195
+ /** @deprecated `LightPopupAd.createForAdRequest(adUnitKey)` 인스턴스의 `show()`를 사용하세요. */
196
+ static showAd(adUnitKey: string): void {
197
+ const requestId = LightPopupAd._getLegacyRequestId(adUnitKey);
198
+ NativeDaroModule.showLightPopup(requestId, adUnitKey);
199
199
  }
200
200
 
201
201
  /** @deprecated 인스턴스의 `setConfiguration()`을 사용하세요. */
202
202
  static setLightPopupAdConfiguration(
203
- adUnitId: string,
203
+ adUnitKey: string,
204
204
  configuration: LightPopupAdConfiguration
205
205
  ): void {
206
- const requestId = LightPopupAd._getLegacyRequestId(adUnitId);
206
+ const requestId = LightPopupAd._getLegacyRequestId(adUnitKey);
207
207
  NativeDaroModule.setLightPopupAdConfiguration(
208
208
  requestId,
209
- adUnitId,
209
+ adUnitKey,
210
210
  normalizeConfiguration(configuration)
211
211
  );
212
212
  }
@@ -39,6 +39,9 @@ export type DaroModuleConstants = {
39
39
  ON_LIGHTPOPUP_HIDDEN_EVENT: string;
40
40
  ON_LIGHTPOPUP_AD_IMPRESSION_RECORDED: string;
41
41
 
42
+ ON_AD_PRELOAD_SUCCESS_EVENT: string;
43
+ ON_AD_PRELOAD_FAILED_EVENT: string;
44
+
42
45
  BANNER_AD_FORMAT_LABEL: string;
43
46
  MREC_AD_FORMAT_LABEL: string;
44
47
  UNKNOWN_AD_FORMAT_LABEL?: string;
@@ -73,36 +76,50 @@ export interface Spec extends TurboModule {
73
76
 
74
77
  isInterstitialReady: (
75
78
  requestId: Double,
76
- adUnitId: string
79
+ adUnitKey: string
77
80
  ) => Promise<boolean>;
78
- loadInterstitial: (requestId: Double, adUnitId: string) => Promise<void>;
79
- showInterstitial: (requestId: Double, adUnitId: string) => Promise<void>;
81
+ loadInterstitial: (requestId: Double, adUnitKey: string) => Promise<void>;
82
+ showInterstitial: (requestId: Double, adUnitKey: string) => Promise<void>;
80
83
 
81
- isRewardedAdReady: (requestId: Double, adUnitId: string) => Promise<boolean>;
82
- loadRewardedAd: (requestId: Double, adUnitId: string) => Promise<void>;
84
+ isRewardedAdReady: (requestId: Double, adUnitKey: string) => Promise<boolean>;
85
+ loadRewardedAd: (requestId: Double, adUnitKey: string) => Promise<void>;
83
86
  showRewardedAd: (
84
87
  requestId: Double,
85
- adUnitId: string,
88
+ adUnitKey: string,
86
89
  customData?: string | null
87
90
  ) => Promise<void>;
88
91
 
89
- isAppOpenAdReady: (requestId: Double, adUnitId: string) => Promise<boolean>;
90
- loadAppOpenAd: (requestId: Double, adUnitId: string) => Promise<void>;
92
+ isAppOpenAdReady: (requestId: Double, adUnitKey: string) => Promise<boolean>;
93
+ loadAppOpenAd: (requestId: Double, adUnitKey: string) => Promise<void>;
91
94
  showAppOpenAd: (
92
95
  requestId: Double,
93
- adUnitId: string,
96
+ adUnitKey: string,
94
97
  customData?: string | null
95
98
  ) => Promise<void>;
96
99
 
97
- isLightPopupReady: (requestId: Double, adUnitId: string) => Promise<boolean>;
98
- loadLightPopup: (requestId: Double, adUnitId: string) => Promise<void>;
99
- destroyLightPopup: (requestId: Double, adUnitId: string) => void;
100
- showLightPopup: (requestId: Double, adUnitId: string) => Promise<void>;
100
+ isLightPopupReady: (requestId: Double, adUnitKey: string) => Promise<boolean>;
101
+ loadLightPopup: (requestId: Double, adUnitKey: string) => Promise<void>;
102
+ destroyLightPopup: (requestId: Double, adUnitKey: string) => void;
103
+ showLightPopup: (requestId: Double, adUnitKey: string) => Promise<void>;
101
104
  setLightPopupAdConfiguration: (
102
105
  requestId: Double,
103
- adUnitId: string,
106
+ adUnitKey: string,
104
107
  configuration: UnsafeObject
105
108
  ) => Promise<void>;
109
+
110
+ // 뷰 광고 preload. Promise 는 네이티브 보관 준비 완료이고, 광고 수신 결과는
111
+ // ON_AD_PRELOAD_*_EVENT 로 온다. `preloadId` 는 뷰의 `preloadId` prop 과 짝이다.
112
+ preloadBannerAd: (
113
+ preloadId: string,
114
+ adUnitKey: string,
115
+ adFormat: string
116
+ ) => Promise<void>;
117
+ preloadNativeAd: (
118
+ preloadId: string,
119
+ adUnitKey: string,
120
+ adChoicesPosition: string
121
+ ) => Promise<void>;
122
+ destroyAdPreload: (preloadId: string) => void;
106
123
  }
107
124
 
108
125
  export default TurboModuleRegistry.getEnforcing<Spec>('DaroRNModule');