@javascriptcommon/react-native-google-mobile-ads 16.3.3
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/LICENSE +32 -0
- package/README.md +181 -0
- package/RNGoogleMobileAds.podspec +74 -0
- package/__tests__/banner.test.tsx +53 -0
- package/__tests__/consent.test.ts +33 -0
- package/__tests__/googleMobileAds.test.ts +108 -0
- package/__tests__/interstitial.test.ts +140 -0
- package/__tests__/nativeEventEmitter.test.ts +72 -0
- package/__tests__/requestOptions.test.tsx +82 -0
- package/__tests__/rewarded.test.tsx +4 -0
- package/__tests__/showOptions.test.tsx +4 -0
- package/android/.editorconfig +10 -0
- package/android/app-json.gradle +69 -0
- package/android/build.gradle +149 -0
- package/android/lint.xml +5 -0
- package/android/settings.gradle +1 -0
- package/android/src/main/AndroidManifest.xml +23 -0
- package/android/src/main/java/io/invertase/googlemobileads/OnNativeEvent.kt +23 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeAppModule.java +152 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsAppOpenModule.kt +92 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsBannerAdViewManager.java +303 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsCommon.java +277 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsConsentModule.java +293 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsEvent.java +76 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsFullScreenAdModule.kt +201 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsInterstitialModule.kt +92 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsMediaViewManager.java +79 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsModule.kt +178 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsNativeAdViewManager.java +164 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsNativeModule.kt +172 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsPackage.kt +113 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsRewardedInterstitialModule.kt +127 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsRewardedModule.kt +121 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/RCTConvert.java +111 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeAdView.java +128 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeApp.java +34 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeEvent.java +41 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeEventEmitter.java +150 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeInitProvider.java +77 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeJSON.java +107 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeMeta.java +92 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeModule.java +96 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativePreferences.java +86 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/SharedUtils.java +429 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/TaskExecutorService.java +124 -0
- package/android/src/main/java/io/invertase/googlemobileads/interfaces/ContextProvider.java +30 -0
- package/android/src/main/java/io/invertase/googlemobileads/interfaces/NativeError.java +28 -0
- package/android/src/main/java/io/invertase/googlemobileads/interfaces/NativeEvent.java +26 -0
- package/android/src/oldarch/com/facebook/react/viewmanagers/RNGoogleMobileAdsMediaViewManagerDelegate.java +32 -0
- package/android/src/oldarch/com/facebook/react/viewmanagers/RNGoogleMobileAdsMediaViewManagerInterface.java +10 -0
- package/android/src/oldarch/com/facebook/react/viewmanagers/RNGoogleMobileAdsNativeViewManagerDelegate.java +36 -0
- package/android/src/oldarch/com/facebook/react/viewmanagers/RNGoogleMobileAdsNativeViewManagerInterface.java +10 -0
- package/android/src/oldarch/io/invertase/googlemobileads/NativeGoogleMobileAdsNativeModuleSpec.kt +18 -0
- package/app.plugin.js +1 -0
- package/babel.config.js +8 -0
- package/docs/ad-inspector.mdx +47 -0
- package/docs/common-reasons-for-ads-not-showing.mdx +111 -0
- package/docs/displaying-ads-hook.mdx +103 -0
- package/docs/displaying-ads.mdx +512 -0
- package/docs/european-user-consent.mdx +315 -0
- package/docs/img/logo_admob_192px.svg +19 -0
- package/docs/impression-level-ad-revenue.mdx +41 -0
- package/docs/index.mdx +508 -0
- package/docs/mediation.mdx +323 -0
- package/docs/migrating-to-v15.mdx +7 -0
- package/docs/migrating-to-v5.mdx +63 -0
- package/docs/migrating-to-v6.mdx +111 -0
- package/docs/native-ads.mdx +385 -0
- package/docs/testing.mdx +17 -0
- package/docs/video-ad_volume-control.mdx +49 -0
- package/docs.json +36 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAds-Bridging-Header.h +5 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.h +36 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.mm +104 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerComponent.h +44 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerComponent.m +221 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerView.h +34 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerView.mm +282 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerViewManager.mm +87 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.h +72 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.mm +248 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.h +36 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.mm +356 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenAd.h +53 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenAd.mm +220 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.h +36 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.mm +80 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.h +36 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.mm +106 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsMediaView.h +52 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsMediaView.mm +155 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsModule.h +32 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsModule.mm +180 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsNativeModule.h +35 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsNativeModule.mm +321 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsNativeView.h +51 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsNativeView.mm +251 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedInterstitialModule.h +37 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedInterstitialModule.mm +106 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedModule.h +36 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedModule.mm +104 -0
- package/ios/RNGoogleMobileAds/common/RNAppModule.h +24 -0
- package/ios/RNGoogleMobileAds/common/RNAppModule.mm +95 -0
- package/ios/RNGoogleMobileAds/common/RNRCTEventEmitter.h +73 -0
- package/ios/RNGoogleMobileAds/common/RNRCTEventEmitter.mm +150 -0
- package/ios/RNGoogleMobileAds/common/RNSharedUtils.h +43 -0
- package/ios/RNGoogleMobileAds/common/RNSharedUtils.mm +34 -0
- package/ios/RNGoogleMobileAds.xcodeproj/project.pbxproj +377 -0
- package/ios/RNGoogleMobileAds.xcodeproj/xcshareddata/IDETemplateMacros.plist +24 -0
- package/ios_config.sh +192 -0
- package/jest.config.js +7 -0
- package/jest.setup.ts +92 -0
- package/lib/commonjs/AdEventType.js +72 -0
- package/lib/commonjs/AdEventType.js.map +1 -0
- package/lib/commonjs/AdsConsent.js +117 -0
- package/lib/commonjs/AdsConsent.js.map +1 -0
- package/lib/commonjs/AdsConsentPurposes.js +180 -0
- package/lib/commonjs/AdsConsentPurposes.js.map +1 -0
- package/lib/commonjs/AdsConsentSpecialFeatures.js +54 -0
- package/lib/commonjs/AdsConsentSpecialFeatures.js.map +1 -0
- package/lib/commonjs/BannerAdSize.js +75 -0
- package/lib/commonjs/BannerAdSize.js.map +1 -0
- package/lib/commonjs/GAMAdEventType.js +44 -0
- package/lib/commonjs/GAMAdEventType.js.map +1 -0
- package/lib/commonjs/MaxAdContentRating.js +42 -0
- package/lib/commonjs/MaxAdContentRating.js.map +1 -0
- package/lib/commonjs/MobileAds.js +63 -0
- package/lib/commonjs/MobileAds.js.map +1 -0
- package/lib/commonjs/NativeAdEventType.js +50 -0
- package/lib/commonjs/NativeAdEventType.js.map +1 -0
- package/lib/commonjs/RewardedAdEventType.js +66 -0
- package/lib/commonjs/RewardedAdEventType.js.map +1 -0
- package/lib/commonjs/TestIds.js +66 -0
- package/lib/commonjs/TestIds.js.map +1 -0
- package/lib/commonjs/ads/AppOpenAd.js +54 -0
- package/lib/commonjs/ads/AppOpenAd.js.map +1 -0
- package/lib/commonjs/ads/BannerAd.js +45 -0
- package/lib/commonjs/ads/BannerAd.js.map +1 -0
- package/lib/commonjs/ads/BaseAd.js +155 -0
- package/lib/commonjs/ads/BaseAd.js.map +1 -0
- package/lib/commonjs/ads/GAMBannerAd.js +49 -0
- package/lib/commonjs/ads/GAMBannerAd.js.map +1 -0
- package/lib/commonjs/ads/GAMInterstitialAd.js +42 -0
- package/lib/commonjs/ads/GAMInterstitialAd.js.map +1 -0
- package/lib/commonjs/ads/InterstitialAd.js +115 -0
- package/lib/commonjs/ads/InterstitialAd.js.map +1 -0
- package/lib/commonjs/ads/MobileAd.js +153 -0
- package/lib/commonjs/ads/MobileAd.js.map +1 -0
- package/lib/commonjs/ads/RewardedAd.js +128 -0
- package/lib/commonjs/ads/RewardedAd.js.map +1 -0
- package/lib/commonjs/ads/RewardedInterstitialAd.js +128 -0
- package/lib/commonjs/ads/RewardedInterstitialAd.js.map +1 -0
- package/lib/commonjs/ads/native-ad/NativeAd.js +123 -0
- package/lib/commonjs/ads/native-ad/NativeAd.js.map +1 -0
- package/lib/commonjs/ads/native-ad/NativeAdContext.js +26 -0
- package/lib/commonjs/ads/native-ad/NativeAdContext.js.map +1 -0
- package/lib/commonjs/ads/native-ad/NativeAdView.js +52 -0
- package/lib/commonjs/ads/native-ad/NativeAdView.js.map +1 -0
- package/lib/commonjs/ads/native-ad/NativeAsset.js +70 -0
- package/lib/commonjs/ads/native-ad/NativeAsset.js.map +1 -0
- package/lib/commonjs/ads/native-ad/NativeMediaView.js +61 -0
- package/lib/commonjs/ads/native-ad/NativeMediaView.js.map +1 -0
- package/lib/commonjs/common/constants.js +17 -0
- package/lib/commonjs/common/constants.js.map +1 -0
- package/lib/commonjs/common/debounce.js +18 -0
- package/lib/commonjs/common/debounce.js.map +1 -0
- package/lib/commonjs/common/index.js +47 -0
- package/lib/commonjs/common/index.js.map +1 -0
- package/lib/commonjs/common/ref.js +46 -0
- package/lib/commonjs/common/ref.js.map +1 -0
- package/lib/commonjs/common/validate.js +132 -0
- package/lib/commonjs/common/validate.js.map +1 -0
- package/lib/commonjs/declarations.d.js +2 -0
- package/lib/commonjs/declarations.d.js.map +1 -0
- package/lib/commonjs/hooks/useAppOpenAd.js +44 -0
- package/lib/commonjs/hooks/useAppOpenAd.js.map +1 -0
- package/lib/commonjs/hooks/useForeground.js +45 -0
- package/lib/commonjs/hooks/useForeground.js.map +1 -0
- package/lib/commonjs/hooks/useFullScreenAd.js +121 -0
- package/lib/commonjs/hooks/useFullScreenAd.js.map +1 -0
- package/lib/commonjs/hooks/useInterstitialAd.js +44 -0
- package/lib/commonjs/hooks/useInterstitialAd.js.map +1 -0
- package/lib/commonjs/hooks/useRewardedAd.js +44 -0
- package/lib/commonjs/hooks/useRewardedAd.js.map +1 -0
- package/lib/commonjs/hooks/useRewardedInterstitialAd.js +44 -0
- package/lib/commonjs/hooks/useRewardedInterstitialAd.js.map +1 -0
- package/lib/commonjs/index.js +337 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/internal/GoogleMobileAdsNativeEventEmitter.js +54 -0
- package/lib/commonjs/internal/GoogleMobileAdsNativeEventEmitter.js.map +1 -0
- package/lib/commonjs/internal/NativeError.js +53 -0
- package/lib/commonjs/internal/NativeError.js.map +1 -0
- package/lib/commonjs/internal/SharedEventEmitter.js +27 -0
- package/lib/commonjs/internal/SharedEventEmitter.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/specs/components/GoogleMobileAdsBannerViewNativeComponent.ts +62 -0
- package/lib/commonjs/specs/components/GoogleMobileAdsMediaViewNativeComponent.ts +30 -0
- package/lib/commonjs/specs/components/GoogleMobileAdsNativeViewNativeComponent.ts +45 -0
- package/lib/commonjs/specs/modules/NativeAppModule.js +24 -0
- package/lib/commonjs/specs/modules/NativeAppModule.js.map +1 -0
- package/lib/commonjs/specs/modules/NativeAppOpenModule.js +25 -0
- package/lib/commonjs/specs/modules/NativeAppOpenModule.js.map +1 -0
- package/lib/commonjs/specs/modules/NativeConsentModule.js +105 -0
- package/lib/commonjs/specs/modules/NativeConsentModule.js.map +1 -0
- package/lib/commonjs/specs/modules/NativeGoogleMobileAdsModule.js +25 -0
- package/lib/commonjs/specs/modules/NativeGoogleMobileAdsModule.js.map +1 -0
- package/lib/commonjs/specs/modules/NativeGoogleMobileAdsNativeModule.js +25 -0
- package/lib/commonjs/specs/modules/NativeGoogleMobileAdsNativeModule.js.map +1 -0
- package/lib/commonjs/specs/modules/NativeInterstitialModule.js +25 -0
- package/lib/commonjs/specs/modules/NativeInterstitialModule.js.map +1 -0
- package/lib/commonjs/specs/modules/NativeRewardedInterstitialModule.js +25 -0
- package/lib/commonjs/specs/modules/NativeRewardedInterstitialModule.js.map +1 -0
- package/lib/commonjs/specs/modules/NativeRewardedModule.js +25 -0
- package/lib/commonjs/specs/modules/NativeRewardedModule.js.map +1 -0
- package/lib/commonjs/types/AdEventListener.js +6 -0
- package/lib/commonjs/types/AdEventListener.js.map +1 -0
- package/lib/commonjs/types/AdEventsListener.js +6 -0
- package/lib/commonjs/types/AdEventsListener.js.map +1 -0
- package/lib/commonjs/types/AdShowOptions.js +2 -0
- package/lib/commonjs/types/AdShowOptions.js.map +1 -0
- package/lib/commonjs/types/AdStates.js +6 -0
- package/lib/commonjs/types/AdStates.js.map +1 -0
- package/lib/commonjs/types/AdapterStatus.js +21 -0
- package/lib/commonjs/types/AdapterStatus.js.map +1 -0
- package/lib/commonjs/types/AppEvent.js +2 -0
- package/lib/commonjs/types/AppEvent.js.map +1 -0
- package/lib/commonjs/types/BannerAdProps.js +6 -0
- package/lib/commonjs/types/BannerAdProps.js.map +1 -0
- package/lib/commonjs/types/MobileAd.interface.js +6 -0
- package/lib/commonjs/types/MobileAd.interface.js.map +1 -0
- package/lib/commonjs/types/MobileAdsModule.interface.js +6 -0
- package/lib/commonjs/types/MobileAdsModule.interface.js.map +1 -0
- package/lib/commonjs/types/NativeAdRequestOptions.js +37 -0
- package/lib/commonjs/types/NativeAdRequestOptions.js.map +1 -0
- package/lib/commonjs/types/PaidEventListener.js +6 -0
- package/lib/commonjs/types/PaidEventListener.js.map +1 -0
- package/lib/commonjs/types/RequestConfiguration.js +6 -0
- package/lib/commonjs/types/RequestConfiguration.js.map +1 -0
- package/lib/commonjs/types/RequestOptions.js +2 -0
- package/lib/commonjs/types/RequestOptions.js.map +1 -0
- package/lib/commonjs/types/RewardedAdReward.js +2 -0
- package/lib/commonjs/types/RewardedAdReward.js.map +1 -0
- package/lib/commonjs/types/index.js +138 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/validateAdRequestConfiguration.js +57 -0
- package/lib/commonjs/validateAdRequestConfiguration.js.map +1 -0
- package/lib/commonjs/validateAdRequestOptions.js +121 -0
- package/lib/commonjs/validateAdRequestOptions.js.map +1 -0
- package/lib/commonjs/validateAdShowOptions.js +41 -0
- package/lib/commonjs/validateAdShowOptions.js.map +1 -0
- package/lib/commonjs/validateNativeAdRequestOptions.js +51 -0
- package/lib/commonjs/validateNativeAdRequestOptions.js.map +1 -0
- package/lib/commonjs/version.js +9 -0
- package/lib/commonjs/version.js.map +1 -0
- package/lib/module/AdEventType.js +69 -0
- package/lib/module/AdEventType.js.map +1 -0
- package/lib/module/AdsConsent.js +113 -0
- package/lib/module/AdsConsent.js.map +1 -0
- package/lib/module/AdsConsentPurposes.js +177 -0
- package/lib/module/AdsConsentPurposes.js.map +1 -0
- package/lib/module/AdsConsentSpecialFeatures.js +51 -0
- package/lib/module/AdsConsentSpecialFeatures.js.map +1 -0
- package/lib/module/BannerAdSize.js +72 -0
- package/lib/module/BannerAdSize.js.map +1 -0
- package/lib/module/GAMAdEventType.js +41 -0
- package/lib/module/GAMAdEventType.js.map +1 -0
- package/lib/module/MaxAdContentRating.js +39 -0
- package/lib/module/MaxAdContentRating.js.map +1 -0
- package/lib/module/MobileAds.js +57 -0
- package/lib/module/MobileAds.js.map +1 -0
- package/lib/module/NativeAdEventType.js +46 -0
- package/lib/module/NativeAdEventType.js.map +1 -0
- package/lib/module/RewardedAdEventType.js +63 -0
- package/lib/module/RewardedAdEventType.js.map +1 -0
- package/lib/module/TestIds.js +62 -0
- package/lib/module/TestIds.js.map +1 -0
- package/lib/module/ads/AppOpenAd.js +48 -0
- package/lib/module/ads/AppOpenAd.js.map +1 -0
- package/lib/module/ads/BannerAd.js +39 -0
- package/lib/module/ads/BannerAd.js.map +1 -0
- package/lib/module/ads/BaseAd.js +149 -0
- package/lib/module/ads/BaseAd.js.map +1 -0
- package/lib/module/ads/GAMBannerAd.js +43 -0
- package/lib/module/ads/GAMBannerAd.js.map +1 -0
- package/lib/module/ads/GAMInterstitialAd.js +37 -0
- package/lib/module/ads/GAMInterstitialAd.js.map +1 -0
- package/lib/module/ads/InterstitialAd.js +110 -0
- package/lib/module/ads/InterstitialAd.js.map +1 -0
- package/lib/module/ads/MobileAd.js +148 -0
- package/lib/module/ads/MobileAd.js.map +1 -0
- package/lib/module/ads/RewardedAd.js +123 -0
- package/lib/module/ads/RewardedAd.js.map +1 -0
- package/lib/module/ads/RewardedInterstitialAd.js +123 -0
- package/lib/module/ads/RewardedInterstitialAd.js.map +1 -0
- package/lib/module/ads/native-ad/NativeAd.js +117 -0
- package/lib/module/ads/native-ad/NativeAd.js.map +1 -0
- package/lib/module/ads/native-ad/NativeAdContext.js +22 -0
- package/lib/module/ads/native-ad/NativeAdContext.js.map +1 -0
- package/lib/module/ads/native-ad/NativeAdView.js +45 -0
- package/lib/module/ads/native-ad/NativeAdView.js.map +1 -0
- package/lib/module/ads/native-ad/NativeAsset.js +65 -0
- package/lib/module/ads/native-ad/NativeAsset.js.map +1 -0
- package/lib/module/ads/native-ad/NativeMediaView.js +54 -0
- package/lib/module/ads/native-ad/NativeMediaView.js.map +1 -0
- package/lib/module/common/constants.js +13 -0
- package/lib/module/common/constants.js.map +1 -0
- package/lib/module/common/debounce.js +13 -0
- package/lib/module/common/debounce.js.map +1 -0
- package/lib/module/common/index.js +28 -0
- package/lib/module/common/index.js.map +1 -0
- package/lib/module/common/ref.js +41 -0
- package/lib/module/common/ref.js.map +1 -0
- package/lib/module/common/validate.js +119 -0
- package/lib/module/common/validate.js.map +1 -0
- package/lib/module/declarations.d.js +2 -0
- package/lib/module/declarations.d.js.map +1 -0
- package/lib/module/hooks/useAppOpenAd.js +40 -0
- package/lib/module/hooks/useAppOpenAd.js.map +1 -0
- package/lib/module/hooks/useForeground.js +42 -0
- package/lib/module/hooks/useForeground.js.map +1 -0
- package/lib/module/hooks/useFullScreenAd.js +117 -0
- package/lib/module/hooks/useFullScreenAd.js.map +1 -0
- package/lib/module/hooks/useInterstitialAd.js +40 -0
- package/lib/module/hooks/useInterstitialAd.js.map +1 -0
- package/lib/module/hooks/useRewardedAd.js +40 -0
- package/lib/module/hooks/useRewardedAd.js.map +1 -0
- package/lib/module/hooks/useRewardedInterstitialAd.js +40 -0
- package/lib/module/hooks/useRewardedInterstitialAd.js.map +1 -0
- package/lib/module/index.js +54 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/internal/GoogleMobileAdsNativeEventEmitter.js +49 -0
- package/lib/module/internal/GoogleMobileAdsNativeEventEmitter.js.map +1 -0
- package/lib/module/internal/NativeError.js +48 -0
- package/lib/module/internal/NativeError.js.map +1 -0
- package/lib/module/internal/SharedEventEmitter.js +22 -0
- package/lib/module/internal/SharedEventEmitter.js.map +1 -0
- package/lib/module/specs/components/GoogleMobileAdsBannerViewNativeComponent.ts +62 -0
- package/lib/module/specs/components/GoogleMobileAdsMediaViewNativeComponent.ts +30 -0
- package/lib/module/specs/components/GoogleMobileAdsNativeViewNativeComponent.ts +45 -0
- package/lib/module/specs/modules/NativeAppModule.js +21 -0
- package/lib/module/specs/modules/NativeAppModule.js.map +1 -0
- package/lib/module/specs/modules/NativeAppOpenModule.js +22 -0
- package/lib/module/specs/modules/NativeAppOpenModule.js.map +1 -0
- package/lib/module/specs/modules/NativeConsentModule.js +108 -0
- package/lib/module/specs/modules/NativeConsentModule.js.map +1 -0
- package/lib/module/specs/modules/NativeGoogleMobileAdsModule.js +22 -0
- package/lib/module/specs/modules/NativeGoogleMobileAdsModule.js.map +1 -0
- package/lib/module/specs/modules/NativeGoogleMobileAdsNativeModule.js +22 -0
- package/lib/module/specs/modules/NativeGoogleMobileAdsNativeModule.js.map +1 -0
- package/lib/module/specs/modules/NativeInterstitialModule.js +22 -0
- package/lib/module/specs/modules/NativeInterstitialModule.js.map +1 -0
- package/lib/module/specs/modules/NativeRewardedInterstitialModule.js +22 -0
- package/lib/module/specs/modules/NativeRewardedInterstitialModule.js.map +1 -0
- package/lib/module/specs/modules/NativeRewardedModule.js +22 -0
- package/lib/module/specs/modules/NativeRewardedModule.js.map +1 -0
- package/lib/module/types/AdEventListener.js +4 -0
- package/lib/module/types/AdEventListener.js.map +1 -0
- package/lib/module/types/AdEventsListener.js +4 -0
- package/lib/module/types/AdEventsListener.js.map +1 -0
- package/lib/module/types/AdShowOptions.js +2 -0
- package/lib/module/types/AdShowOptions.js.map +1 -0
- package/lib/module/types/AdStates.js +4 -0
- package/lib/module/types/AdStates.js.map +1 -0
- package/lib/module/types/AdapterStatus.js +18 -0
- package/lib/module/types/AdapterStatus.js.map +1 -0
- package/lib/module/types/AppEvent.js +2 -0
- package/lib/module/types/AppEvent.js.map +1 -0
- package/lib/module/types/BannerAdProps.js +4 -0
- package/lib/module/types/BannerAdProps.js.map +1 -0
- package/lib/module/types/MobileAd.interface.js +4 -0
- package/lib/module/types/MobileAd.interface.js.map +1 -0
- package/lib/module/types/MobileAdsModule.interface.js +4 -0
- package/lib/module/types/MobileAdsModule.interface.js.map +1 -0
- package/lib/module/types/NativeAdRequestOptions.js +34 -0
- package/lib/module/types/NativeAdRequestOptions.js.map +1 -0
- package/lib/module/types/PaidEventListener.js +4 -0
- package/lib/module/types/PaidEventListener.js.map +1 -0
- package/lib/module/types/RequestConfiguration.js +4 -0
- package/lib/module/types/RequestConfiguration.js.map +1 -0
- package/lib/module/types/RequestOptions.js +2 -0
- package/lib/module/types/RequestOptions.js.map +1 -0
- package/lib/module/types/RewardedAdReward.js +2 -0
- package/lib/module/types/RewardedAdReward.js.map +1 -0
- package/lib/module/types/index.js +32 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/validateAdRequestConfiguration.js +53 -0
- package/lib/module/validateAdRequestConfiguration.js.map +1 -0
- package/lib/module/validateAdRequestOptions.js +117 -0
- package/lib/module/validateAdRequestOptions.js.map +1 -0
- package/lib/module/validateAdShowOptions.js +37 -0
- package/lib/module/validateAdShowOptions.js.map +1 -0
- package/lib/module/validateNativeAdRequestOptions.js +47 -0
- package/lib/module/validateNativeAdRequestOptions.js.map +1 -0
- package/lib/module/version.js +5 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/AdEventType.d.ts +49 -0
- package/lib/typescript/AdEventType.d.ts.map +1 -0
- package/lib/typescript/AdsConsent.d.ts +3 -0
- package/lib/typescript/AdsConsent.d.ts.map +1 -0
- package/lib/typescript/AdsConsentPurposes.d.ts +149 -0
- package/lib/typescript/AdsConsentPurposes.d.ts.map +1 -0
- package/lib/typescript/AdsConsentSpecialFeatures.d.ts +23 -0
- package/lib/typescript/AdsConsentSpecialFeatures.d.ts.map +1 -0
- package/lib/typescript/BannerAdSize.d.ts +91 -0
- package/lib/typescript/BannerAdSize.d.ts.map +1 -0
- package/lib/typescript/GAMAdEventType.d.ts +21 -0
- package/lib/typescript/GAMAdEventType.d.ts.map +1 -0
- package/lib/typescript/MaxAdContentRating.d.ts +19 -0
- package/lib/typescript/MaxAdContentRating.d.ts.map +1 -0
- package/lib/typescript/MobileAds.d.ts +15 -0
- package/lib/typescript/MobileAds.d.ts.map +1 -0
- package/lib/typescript/NativeAdEventType.d.ts +43 -0
- package/lib/typescript/NativeAdEventType.d.ts.map +1 -0
- package/lib/typescript/RewardedAdEventType.d.ts +43 -0
- package/lib/typescript/RewardedAdEventType.d.ts.map +1 -0
- package/lib/typescript/TestIds.d.ts +19 -0
- package/lib/typescript/TestIds.d.ts.map +1 -0
- package/lib/typescript/ads/AppOpenAd.d.ts +12 -0
- package/lib/typescript/ads/AppOpenAd.d.ts.map +1 -0
- package/lib/typescript/ads/BannerAd.d.ts +8 -0
- package/lib/typescript/ads/BannerAd.d.ts.map +1 -0
- package/lib/typescript/ads/BaseAd.d.ts +4 -0
- package/lib/typescript/ads/BaseAd.d.ts.map +1 -0
- package/lib/typescript/ads/GAMBannerAd.d.ts +9 -0
- package/lib/typescript/ads/GAMBannerAd.d.ts.map +1 -0
- package/lib/typescript/ads/GAMInterstitialAd.d.ts +34 -0
- package/lib/typescript/ads/GAMInterstitialAd.d.ts.map +1 -0
- package/lib/typescript/ads/InterstitialAd.d.ts +73 -0
- package/lib/typescript/ads/InterstitialAd.d.ts.map +1 -0
- package/lib/typescript/ads/MobileAd.d.ts +54 -0
- package/lib/typescript/ads/MobileAd.d.ts.map +1 -0
- package/lib/typescript/ads/RewardedAd.d.ts +83 -0
- package/lib/typescript/ads/RewardedAd.d.ts.map +1 -0
- package/lib/typescript/ads/RewardedInterstitialAd.d.ts +83 -0
- package/lib/typescript/ads/RewardedInterstitialAd.d.ts.map +1 -0
- package/lib/typescript/ads/native-ad/NativeAd.d.ts +48 -0
- package/lib/typescript/ads/native-ad/NativeAd.d.ts.map +1 -0
- package/lib/typescript/ads/native-ad/NativeAdContext.d.ts +10 -0
- package/lib/typescript/ads/native-ad/NativeAdContext.d.ts.map +1 -0
- package/lib/typescript/ads/native-ad/NativeAdView.d.ts +8 -0
- package/lib/typescript/ads/native-ad/NativeAdView.d.ts.map +1 -0
- package/lib/typescript/ads/native-ad/NativeAsset.d.ts +18 -0
- package/lib/typescript/ads/native-ad/NativeAsset.d.ts.map +1 -0
- package/lib/typescript/ads/native-ad/NativeMediaView.d.ts +7 -0
- package/lib/typescript/ads/native-ad/NativeMediaView.d.ts.map +1 -0
- package/lib/typescript/common/constants.d.ts +7 -0
- package/lib/typescript/common/constants.d.ts.map +1 -0
- package/lib/typescript/common/debounce.d.ts +2 -0
- package/lib/typescript/common/debounce.d.ts.map +1 -0
- package/lib/typescript/common/index.d.ts +4 -0
- package/lib/typescript/common/index.d.ts.map +1 -0
- package/lib/typescript/common/ref.d.ts +13 -0
- package/lib/typescript/common/ref.d.ts.map +1 -0
- package/lib/typescript/common/validate.d.ts +62 -0
- package/lib/typescript/common/validate.d.ts.map +1 -0
- package/lib/typescript/hooks/useAppOpenAd.d.ts +10 -0
- package/lib/typescript/hooks/useAppOpenAd.d.ts.map +1 -0
- package/lib/typescript/hooks/useForeground.d.ts +7 -0
- package/lib/typescript/hooks/useForeground.d.ts.map +1 -0
- package/lib/typescript/hooks/useFullScreenAd.d.ts +7 -0
- package/lib/typescript/hooks/useFullScreenAd.d.ts.map +1 -0
- package/lib/typescript/hooks/useInterstitialAd.d.ts +10 -0
- package/lib/typescript/hooks/useInterstitialAd.d.ts.map +1 -0
- package/lib/typescript/hooks/useRewardedAd.d.ts +10 -0
- package/lib/typescript/hooks/useRewardedAd.d.ts.map +1 -0
- package/lib/typescript/hooks/useRewardedInterstitialAd.d.ts +10 -0
- package/lib/typescript/hooks/useRewardedInterstitialAd.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +32 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/internal/GoogleMobileAdsNativeEventEmitter.d.ts +13 -0
- package/lib/typescript/internal/GoogleMobileAdsNativeEventEmitter.d.ts.map +1 -0
- package/lib/typescript/internal/NativeError.d.ts +27 -0
- package/lib/typescript/internal/NativeError.d.ts.map +1 -0
- package/lib/typescript/internal/SharedEventEmitter.d.ts +3 -0
- package/lib/typescript/internal/SharedEventEmitter.d.ts.map +1 -0
- package/lib/typescript/specs/components/GoogleMobileAdsBannerViewNativeComponent.d.ts +35 -0
- package/lib/typescript/specs/components/GoogleMobileAdsBannerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/specs/components/GoogleMobileAdsMediaViewNativeComponent.d.ts +9 -0
- package/lib/typescript/specs/components/GoogleMobileAdsMediaViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/specs/components/GoogleMobileAdsNativeViewNativeComponent.d.ts +14 -0
- package/lib/typescript/specs/components/GoogleMobileAdsNativeViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/specs/modules/NativeAppModule.d.ts +23 -0
- package/lib/typescript/specs/modules/NativeAppModule.d.ts.map +1 -0
- package/lib/typescript/specs/modules/NativeAppOpenModule.d.ts +25 -0
- package/lib/typescript/specs/modules/NativeAppOpenModule.d.ts.map +1 -0
- package/lib/typescript/specs/modules/NativeConsentModule.d.ts +498 -0
- package/lib/typescript/specs/modules/NativeConsentModule.d.ts.map +1 -0
- package/lib/typescript/specs/modules/NativeGoogleMobileAdsModule.d.ts +14 -0
- package/lib/typescript/specs/modules/NativeGoogleMobileAdsModule.d.ts.map +1 -0
- package/lib/typescript/specs/modules/NativeGoogleMobileAdsNativeModule.d.ts +42 -0
- package/lib/typescript/specs/modules/NativeGoogleMobileAdsNativeModule.d.ts.map +1 -0
- package/lib/typescript/specs/modules/NativeInterstitialModule.d.ts +25 -0
- package/lib/typescript/specs/modules/NativeInterstitialModule.d.ts.map +1 -0
- package/lib/typescript/specs/modules/NativeRewardedInterstitialModule.d.ts +25 -0
- package/lib/typescript/specs/modules/NativeRewardedInterstitialModule.d.ts.map +1 -0
- package/lib/typescript/specs/modules/NativeRewardedModule.d.ts +25 -0
- package/lib/typescript/specs/modules/NativeRewardedModule.d.ts.map +1 -0
- package/lib/typescript/types/AdEventListener.d.ts +8 -0
- package/lib/typescript/types/AdEventListener.d.ts.map +1 -0
- package/lib/typescript/types/AdEventsListener.d.ts +9 -0
- package/lib/typescript/types/AdEventsListener.d.ts.map +1 -0
- package/lib/typescript/types/AdShowOptions.d.ts +13 -0
- package/lib/typescript/types/AdShowOptions.d.ts.map +1 -0
- package/lib/typescript/types/AdStates.d.ts +91 -0
- package/lib/typescript/types/AdStates.d.ts.map +1 -0
- package/lib/typescript/types/AdapterStatus.d.ts +19 -0
- package/lib/typescript/types/AdapterStatus.d.ts.map +1 -0
- package/lib/typescript/types/AppEvent.d.ts +14 -0
- package/lib/typescript/types/AppEvent.d.ts.map +1 -0
- package/lib/typescript/types/BannerAdProps.d.ts +175 -0
- package/lib/typescript/types/BannerAdProps.d.ts.map +1 -0
- package/lib/typescript/types/MobileAd.interface.d.ts +90 -0
- package/lib/typescript/types/MobileAd.interface.d.ts.map +1 -0
- package/lib/typescript/types/MobileAdsModule.interface.d.ts +75 -0
- package/lib/typescript/types/MobileAdsModule.interface.d.ts.map +1 -0
- package/lib/typescript/types/NativeAdRequestOptions.d.ts +36 -0
- package/lib/typescript/types/NativeAdRequestOptions.d.ts.map +1 -0
- package/lib/typescript/types/PaidEventListener.d.ts +8 -0
- package/lib/typescript/types/PaidEventListener.d.ts.map +1 -0
- package/lib/typescript/types/RequestConfiguration.d.ts +37 -0
- package/lib/typescript/types/RequestConfiguration.d.ts.map +1 -0
- package/lib/typescript/types/RequestOptions.d.ts +133 -0
- package/lib/typescript/types/RequestOptions.d.ts.map +1 -0
- package/lib/typescript/types/RewardedAdReward.d.ts +14 -0
- package/lib/typescript/types/RewardedAdReward.d.ts.map +1 -0
- package/lib/typescript/types/index.d.ts +13 -0
- package/lib/typescript/types/index.d.ts.map +1 -0
- package/lib/typescript/validateAdRequestConfiguration.d.ts +3 -0
- package/lib/typescript/validateAdRequestConfiguration.d.ts.map +1 -0
- package/lib/typescript/validateAdRequestOptions.d.ts +3 -0
- package/lib/typescript/validateAdRequestOptions.d.ts.map +1 -0
- package/lib/typescript/validateAdShowOptions.d.ts +3 -0
- package/lib/typescript/validateAdShowOptions.d.ts.map +1 -0
- package/lib/typescript/validateNativeAdRequestOptions.d.ts +3 -0
- package/lib/typescript/validateNativeAdRequestOptions.d.ts.map +1 -0
- package/lib/typescript/version.d.ts +2 -0
- package/lib/typescript/version.d.ts.map +1 -0
- package/package.json +176 -0
- package/plugin/__tests__/__snapshots__/plugin.test.ts.snap +739 -0
- package/plugin/__tests__/fixtures/app.config.js +24 -0
- package/plugin/__tests__/fixtures/app.config.ts +24 -0
- package/plugin/__tests__/fixtures/app.json +24 -0
- package/plugin/__tests__/fixtures/package.json +19 -0
- package/plugin/__tests__/fixtures/without-params/app.config.js +11 -0
- package/plugin/__tests__/fixtures/without-params/app.config.ts +11 -0
- package/plugin/__tests__/fixtures/without-params/app.json +11 -0
- package/plugin/__tests__/plugin.test.ts +115 -0
- package/plugin/build/index.d.ts +12 -0
- package/plugin/build/index.js +109 -0
- package/plugin/jest.config.js +1 -0
- package/plugin/src/index.ts +205 -0
- package/plugin/tsconfig.json +9 -0
- package/plugin/tsconfig.tsbuildinfo +1 -0
- package/react-native.config.js +19 -0
- package/src/AdEventType.ts +70 -0
- package/src/AdsConsent.ts +170 -0
- package/src/AdsConsentPurposes.ts +182 -0
- package/src/AdsConsentSpecialFeatures.ts +48 -0
- package/src/BannerAdSize.ts +78 -0
- package/src/GAMAdEventType.ts +37 -0
- package/src/MaxAdContentRating.ts +38 -0
- package/src/MobileAds.ts +77 -0
- package/src/NativeAdEventType.ts +51 -0
- package/src/RewardedAdEventType.ts +60 -0
- package/src/TestIds.ts +60 -0
- package/src/ads/AppOpenAd.ts +62 -0
- package/src/ads/BannerAd.tsx +37 -0
- package/src/ads/BaseAd.tsx +185 -0
- package/src/ads/GAMBannerAd.tsx +43 -0
- package/src/ads/GAMInterstitialAd.ts +45 -0
- package/src/ads/InterstitialAd.ts +122 -0
- package/src/ads/MobileAd.ts +227 -0
- package/src/ads/RewardedAd.ts +142 -0
- package/src/ads/RewardedInterstitialAd.ts +144 -0
- package/src/ads/native-ad/NativeAd.ts +159 -0
- package/src/ads/native-ad/NativeAdContext.ts +26 -0
- package/src/ads/native-ad/NativeAdView.tsx +43 -0
- package/src/ads/native-ad/NativeAsset.tsx +66 -0
- package/src/ads/native-ad/NativeMediaView.tsx +44 -0
- package/src/common/constants.ts +9 -0
- package/src/common/debounce.ts +15 -0
- package/src/common/index.ts +30 -0
- package/src/common/ref.ts +46 -0
- package/src/common/validate.ts +116 -0
- package/src/declarations.d.ts +3 -0
- package/src/hooks/useAppOpenAd.ts +46 -0
- package/src/hooks/useForeground.ts +41 -0
- package/src/hooks/useFullScreenAd.ts +112 -0
- package/src/hooks/useInterstitialAd.ts +46 -0
- package/src/hooks/useRewardedAd.ts +46 -0
- package/src/hooks/useRewardedInterstitialAd.ts +47 -0
- package/src/index.ts +60 -0
- package/src/internal/GoogleMobileAdsNativeEventEmitter.ts +58 -0
- package/src/internal/NativeError.ts +56 -0
- package/src/internal/SharedEventEmitter.ts +20 -0
- package/src/specs/components/GoogleMobileAdsBannerViewNativeComponent.ts +62 -0
- package/src/specs/components/GoogleMobileAdsMediaViewNativeComponent.ts +30 -0
- package/src/specs/components/GoogleMobileAdsNativeViewNativeComponent.ts +45 -0
- package/src/specs/modules/NativeAppModule.ts +57 -0
- package/src/specs/modules/NativeAppOpenModule.ts +26 -0
- package/src/specs/modules/NativeConsentModule.ts +532 -0
- package/src/specs/modules/NativeGoogleMobileAdsModule.ts +33 -0
- package/src/specs/modules/NativeGoogleMobileAdsNativeModule.ts +70 -0
- package/src/specs/modules/NativeInterstitialModule.ts +26 -0
- package/src/specs/modules/NativeRewardedInterstitialModule.ts +32 -0
- package/src/specs/modules/NativeRewardedModule.ts +26 -0
- package/src/types/AdEventListener.ts +34 -0
- package/src/types/AdEventsListener.ts +24 -0
- package/src/types/AdShowOptions.ts +12 -0
- package/src/types/AdStates.ts +92 -0
- package/src/types/AdapterStatus.ts +20 -0
- package/src/types/AppEvent.ts +14 -0
- package/src/types/BannerAdProps.ts +184 -0
- package/src/types/MobileAd.interface.ts +113 -0
- package/src/types/MobileAdsModule.interface.ts +80 -0
- package/src/types/NativeAdRequestOptions.ts +55 -0
- package/src/types/PaidEventListener.ts +9 -0
- package/src/types/RequestConfiguration.ts +40 -0
- package/src/types/RequestOptions.ts +137 -0
- package/src/types/RewardedAdReward.ts +14 -0
- package/src/types/index.ts +29 -0
- package/src/validateAdRequestConfiguration.ts +66 -0
- package/src/validateAdRequestOptions.ts +154 -0
- package/src/validateAdShowOptions.ts +41 -0
- package/src/validateNativeAdRequestOptions.ts +50 -0
- package/src/version.ts +2 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MobileAd = void 0;
|
|
7
|
+
var _common = require("../common");
|
|
8
|
+
var _NativeError = require("../internal/NativeError");
|
|
9
|
+
var _AdEventType = require("../AdEventType");
|
|
10
|
+
var _RewardedAdEventType = require("../RewardedAdEventType");
|
|
11
|
+
var _SharedEventEmitter = require("../internal/SharedEventEmitter");
|
|
12
|
+
var _GAMAdEventType = require("../GAMAdEventType");
|
|
13
|
+
var _validateAdShowOptions = require("../validateAdShowOptions");
|
|
14
|
+
/*
|
|
15
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
16
|
+
*
|
|
17
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
18
|
+
* you may not use this library except in compliance with the License.
|
|
19
|
+
* You may obtain a copy of the License at
|
|
20
|
+
*
|
|
21
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
22
|
+
*
|
|
23
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
24
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
25
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
26
|
+
* See the License for the specific language governing permissions and
|
|
27
|
+
* limitations under the License.
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
class MobileAd {
|
|
32
|
+
constructor(type, requestId, adUnitId, adLoadFunction, adShowFunction, requestOptions) {
|
|
33
|
+
this._type = type;
|
|
34
|
+
this._requestId = requestId;
|
|
35
|
+
this._adUnitId = adUnitId;
|
|
36
|
+
this._adLoadFunction = adLoadFunction;
|
|
37
|
+
this._adShowFunction = adShowFunction;
|
|
38
|
+
this._requestOptions = requestOptions;
|
|
39
|
+
this._loaded = false;
|
|
40
|
+
this._isLoadCalled = false;
|
|
41
|
+
this._adEventsListeners = new Map();
|
|
42
|
+
this._adEventListenersMap = new Map();
|
|
43
|
+
Object.values({
|
|
44
|
+
..._AdEventType.AdEventType,
|
|
45
|
+
..._RewardedAdEventType.RewardedAdEventType,
|
|
46
|
+
..._GAMAdEventType.GAMAdEventType,
|
|
47
|
+
_: _AdEventType.AdEventType.LOADED // since AdEventType.LOADED is overwritten by RewardedAdEventType.LOADED
|
|
48
|
+
}).forEach(type => {
|
|
49
|
+
this._adEventListenersMap.set(type, new Map());
|
|
50
|
+
});
|
|
51
|
+
this._adEventListenerId = 0;
|
|
52
|
+
this._adEventsListenerId = 0;
|
|
53
|
+
this._nativeListener = _SharedEventEmitter.SharedEventEmitter.addListener(`google_mobile_ads_${type}_event:${adUnitId}:${requestId}`, this._handleAdEvent.bind(this));
|
|
54
|
+
}
|
|
55
|
+
_handleAdEvent(event) {
|
|
56
|
+
const {
|
|
57
|
+
type,
|
|
58
|
+
error,
|
|
59
|
+
data
|
|
60
|
+
} = event.body;
|
|
61
|
+
if (type === _AdEventType.AdEventType.LOADED || type === _RewardedAdEventType.RewardedAdEventType.LOADED) {
|
|
62
|
+
this._loaded = true;
|
|
63
|
+
}
|
|
64
|
+
if (type === _AdEventType.AdEventType.CLOSED) {
|
|
65
|
+
this._loaded = false;
|
|
66
|
+
this._isLoadCalled = false;
|
|
67
|
+
}
|
|
68
|
+
if (type === _AdEventType.AdEventType.ERROR) {
|
|
69
|
+
this._loaded = false;
|
|
70
|
+
this._isLoadCalled = false;
|
|
71
|
+
}
|
|
72
|
+
let payload = data;
|
|
73
|
+
if (error) {
|
|
74
|
+
payload = _NativeError.NativeError.fromEvent(error, 'googleMobileAds');
|
|
75
|
+
}
|
|
76
|
+
this._adEventsListeners.forEach(listener => {
|
|
77
|
+
listener({
|
|
78
|
+
type,
|
|
79
|
+
payload
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
this._getAdEventListeners(type).forEach(listener => {
|
|
83
|
+
listener(payload);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
_addAdEventsListener(listener) {
|
|
87
|
+
if (!(0, _common.isFunction)(listener)) {
|
|
88
|
+
throw new Error(`${this._className}.addAdEventsListener(*) 'listener' expected a function.`);
|
|
89
|
+
}
|
|
90
|
+
const id = this._adEventsListenerId++;
|
|
91
|
+
this._adEventsListeners.set(id, listener);
|
|
92
|
+
return () => {
|
|
93
|
+
this._adEventsListeners.delete(id);
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
_addAdEventListener(type, listener) {
|
|
97
|
+
if (!((0, _common.isOneOf)(type, Object.values(_AdEventType.AdEventType)) || (0, _common.isOneOf)(type, Object.values(_GAMAdEventType.GAMAdEventType)) || (0, _common.isOneOf)(type, Object.values(_RewardedAdEventType.RewardedAdEventType)) && (this._type === 'rewarded' || this._type === 'rewarded_interstitial'))) {
|
|
98
|
+
throw new Error(`${this._className}.addAdEventListener(*) 'type' expected a valid event type value.`);
|
|
99
|
+
}
|
|
100
|
+
if (!(0, _common.isFunction)(listener)) {
|
|
101
|
+
throw new Error(`${this._className}.addAdEventListener(_, *) 'listener' expected a function.`);
|
|
102
|
+
}
|
|
103
|
+
const id = this._adEventListenerId++;
|
|
104
|
+
this._getAdEventListeners(type).set(id, listener);
|
|
105
|
+
return () => {
|
|
106
|
+
this._getAdEventListeners(type).delete(id);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
_getAdEventListeners(type) {
|
|
110
|
+
return this._adEventListenersMap.get(type);
|
|
111
|
+
}
|
|
112
|
+
get _className() {
|
|
113
|
+
return this.constructor.name;
|
|
114
|
+
}
|
|
115
|
+
load() {
|
|
116
|
+
// Prevent multiple load calls
|
|
117
|
+
if (this._loaded || this._isLoadCalled) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
this._isLoadCalled = true;
|
|
121
|
+
this._adLoadFunction(this._requestId, this._adUnitId, this._requestOptions);
|
|
122
|
+
}
|
|
123
|
+
show(showOptions) {
|
|
124
|
+
if (!this._loaded) {
|
|
125
|
+
throw new Error(`${this._className}.show() The requested ${this._className} has not loaded and could not be shown.`);
|
|
126
|
+
}
|
|
127
|
+
let options;
|
|
128
|
+
try {
|
|
129
|
+
options = (0, _validateAdShowOptions.validateAdShowOptions)(showOptions);
|
|
130
|
+
} catch (e) {
|
|
131
|
+
if (e instanceof Error) {
|
|
132
|
+
throw new Error(`${this._className}.show(*) ${e.message}.`);
|
|
133
|
+
} else {
|
|
134
|
+
throw e;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return this._adShowFunction(this._requestId, this._adUnitId, options);
|
|
138
|
+
}
|
|
139
|
+
removeAllListeners() {
|
|
140
|
+
this._adEventsListeners.clear();
|
|
141
|
+
this._adEventListenersMap.forEach((_, type, map) => {
|
|
142
|
+
map.set(type, new Map());
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
get adUnitId() {
|
|
146
|
+
return this._adUnitId;
|
|
147
|
+
}
|
|
148
|
+
get loaded() {
|
|
149
|
+
return this._loaded;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.MobileAd = MobileAd;
|
|
153
|
+
//# sourceMappingURL=MobileAd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_common","require","_NativeError","_AdEventType","_RewardedAdEventType","_SharedEventEmitter","_GAMAdEventType","_validateAdShowOptions","MobileAd","constructor","type","requestId","adUnitId","adLoadFunction","adShowFunction","requestOptions","_type","_requestId","_adUnitId","_adLoadFunction","_adShowFunction","_requestOptions","_loaded","_isLoadCalled","_adEventsListeners","Map","_adEventListenersMap","Object","values","AdEventType","RewardedAdEventType","GAMAdEventType","_","LOADED","forEach","set","_adEventListenerId","_adEventsListenerId","_nativeListener","SharedEventEmitter","addListener","_handleAdEvent","bind","event","error","data","body","CLOSED","ERROR","payload","NativeError","fromEvent","listener","_getAdEventListeners","_addAdEventsListener","isFunction","Error","_className","id","delete","_addAdEventListener","isOneOf","get","name","load","show","showOptions","options","validateAdShowOptions","e","message","removeAllListeners","clear","map","loaded","exports"],"sourceRoot":"../../../src","sources":["ads/MobileAd.ts"],"mappings":";;;;;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AC;EACJ;EAEA,IAAWb,QAAQA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACM,SAAS;EACvB;EAEA,IAAWwD,MAAMA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACpD,OAAO;EACrB;AACF;AAACqD,OAAA,CAAAnE,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RewardedAd = void 0;
|
|
7
|
+
var _common = require("../common");
|
|
8
|
+
var _validateAdRequestOptions = require("../validateAdRequestOptions");
|
|
9
|
+
var _MobileAd = require("./MobileAd");
|
|
10
|
+
var _AdEventType = require("../AdEventType");
|
|
11
|
+
var _NativeRewardedModule = _interopRequireDefault(require("../specs/modules/NativeRewardedModule"));
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
/*
|
|
14
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
15
|
+
*
|
|
16
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
17
|
+
* you may not use this library except in compliance with the License.
|
|
18
|
+
* You may obtain a copy of the License at
|
|
19
|
+
*
|
|
20
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
21
|
+
*
|
|
22
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
23
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
24
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
25
|
+
* See the License for the specific language governing permissions and
|
|
26
|
+
* limitations under the License.
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A class for interacting and showing Rewarded Ads.
|
|
32
|
+
*
|
|
33
|
+
* An Rewarded advert can be pre-loaded and shown at a suitable point in your apps flow, such as at the end of a level
|
|
34
|
+
* in a game. The content of a rewarded advert can be controlled via your Google Mobile Ads dashboard. Typically users are rewarded
|
|
35
|
+
* after completing a specific advert action (e.g. watching a video or submitting an option via an interactive form).
|
|
36
|
+
* Events (such as the user earning a reward or closing a rewarded advert early) are sent back for you to handle accordingly
|
|
37
|
+
* within your application.
|
|
38
|
+
*
|
|
39
|
+
* #### Example
|
|
40
|
+
*
|
|
41
|
+
* First create a new Rewarded instance, passing in your Ad Unit ID from the Google Mobile Ads configuration console, and any additional
|
|
42
|
+
* request options. The example below will present a test advert, and only request a non-personalized ad.
|
|
43
|
+
*
|
|
44
|
+
* ```js
|
|
45
|
+
* import { RewardedAd, TestIds } from 'react-native-google-mobile-ads';
|
|
46
|
+
*
|
|
47
|
+
* const rewarded = RewardedAd.createForAdRequest(TestIds.REWARDED, {
|
|
48
|
+
* requestNonPersonalizedAdsOnly: true,
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* Each advert needs to be loaded from Google Mobile Ads before being shown. It is recommended this is performed before the user
|
|
53
|
+
* reaches the checkpoint to show the advert, so it's ready to go. Before loading the advert, we need to setup
|
|
54
|
+
* event listeners to listen for updates from Google Mobile Ads, such as advert loaded or failed to load.
|
|
55
|
+
*
|
|
56
|
+
* Event types match the `AdEventType` or `RewardedAdEventType` interface. The potential user reward for rewarded
|
|
57
|
+
* adverts are passed back to the event handler on advert load and when the user earns the reward.
|
|
58
|
+
*
|
|
59
|
+
* ```js
|
|
60
|
+
* import { RewardedAdEventType } from 'react-native-google-mobile-ads';
|
|
61
|
+
*
|
|
62
|
+
* rewarded.addAdEventListener(RewardedAdEventType.LOADED. () => {
|
|
63
|
+
* rewarded.show();
|
|
64
|
+
* });
|
|
65
|
+
* rewarded.addAdEventListener(RewardedAdEventType.EARNED_REWARD. (reward) => {
|
|
66
|
+
* console.log('User earned reward of ', reward);
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* rewarded.load();
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* The rewarded advert will be presented to the user, and several more events can be triggered such as the user clicking the
|
|
73
|
+
* advert, closing it or completing the action.
|
|
74
|
+
*/
|
|
75
|
+
class RewardedAd extends _MobileAd.MobileAd {
|
|
76
|
+
static _rewardedRequest = 0;
|
|
77
|
+
/**
|
|
78
|
+
* Creates a new RewardedAd instance.
|
|
79
|
+
*
|
|
80
|
+
* #### Example
|
|
81
|
+
*
|
|
82
|
+
* ```js
|
|
83
|
+
* import { RewardedAd, RewardedAdEventType, TestIds } from 'react-native-google-mobile-ads';
|
|
84
|
+
*
|
|
85
|
+
* const rewardedAd = await RewardedAd.createForAdRequest(TestIds.REWARDED, {
|
|
86
|
+
* requestAgent: 'CoolAds',
|
|
87
|
+
* });
|
|
88
|
+
*
|
|
89
|
+
* rewarded.addAdEventListener(RewardedAdEventType.LOADED. () => {
|
|
90
|
+
* rewarded.show();
|
|
91
|
+
* });
|
|
92
|
+
* rewarded.addAdEventListener(RewardedAdEventType.EARNED_REWARD. (reward) => {
|
|
93
|
+
* console.log('User earned reward of ', reward);
|
|
94
|
+
* });
|
|
95
|
+
*
|
|
96
|
+
* rewardedAd.load();
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @param adUnitId The Ad Unit ID for the Rewarded Ad. You can find this on your Google Mobile Ads dashboard.
|
|
100
|
+
* @param requestOptions Optional RequestOptions used to load the ad.
|
|
101
|
+
*/
|
|
102
|
+
static createForAdRequest(adUnitId, requestOptions) {
|
|
103
|
+
if (!(0, _common.isString)(adUnitId)) {
|
|
104
|
+
throw new Error("RewardedAd.createForAdRequest(*) 'adUnitId' expected an string value.");
|
|
105
|
+
}
|
|
106
|
+
let options = {};
|
|
107
|
+
try {
|
|
108
|
+
options = (0, _validateAdRequestOptions.validateAdRequestOptions)(requestOptions);
|
|
109
|
+
} catch (e) {
|
|
110
|
+
if (e instanceof Error) {
|
|
111
|
+
throw new Error(`RewardedAd.createForAdRequest(_, *) ${e.message}.`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const requestId = RewardedAd._rewardedRequest++;
|
|
115
|
+
return new RewardedAd('rewarded', requestId, adUnitId, _NativeRewardedModule.default.rewardedLoad.bind(this), _NativeRewardedModule.default.rewardedShow.bind(this), options);
|
|
116
|
+
}
|
|
117
|
+
addAdEventsListener(listener) {
|
|
118
|
+
return this._addAdEventsListener(listener);
|
|
119
|
+
}
|
|
120
|
+
addAdEventListener(type, listener) {
|
|
121
|
+
if (type === _AdEventType.AdEventType.LOADED) {
|
|
122
|
+
throw new Error('RewardedAd.addAdEventListener(*) use RewardedAdEventType.LOADED instead of AdEventType.LOADED.');
|
|
123
|
+
}
|
|
124
|
+
return this._addAdEventListener(type, listener);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.RewardedAd = RewardedAd;
|
|
128
|
+
//# sourceMappingURL=RewardedAd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_common","require","_validateAdRequestOptions","_MobileAd","_AdEventType","_NativeRewardedModule","_interopRequireDefault","e","__esModule","default","RewardedAd","MobileAd","_rewardedRequest","createForAdRequest","adUnitId","requestOptions","isString","Error","options","validateAdRequestOptions","message","requestId","NativeRewardedModule","rewardedLoad","bind","rewardedShow","addAdEventsListener","listener","_addAdEventsListener","addAdEventListener","type","AdEventType","LOADED","_addAdEventListener","exports"],"sourceRoot":"../../../src","sources":["ads/RewardedAd.ts"],"mappings":";;;;;;AAiBA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,yBAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAKA,IAAAI,qBAAA,GAAAC,sBAAA,CAAAL,OAAA;AAAyE,SAAAK,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAzBzE;AACA;AACA;AACA;AACA;AACA;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AAC;EAC5C;EAEAE,kBAAkBA,CAChBC,IAAO,EACPH,QAA4B,EAC5B;IACA,IAAIG,IAAI,KAAKC,wBAAW,CAACC,MAAM,EAAE;MAC/B,MAAM,IAAIf,KAAK,CACb,gGACF,CAAC;IACH;IACA,OAAO,IAAI,CAACgB,mBAAmB,CAACH,IAAI,EAAEH,QAAQ,CAAC;EACjD;AACF;AAACO,OAAA,CAAAxB,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RewardedInterstitialAd = void 0;
|
|
7
|
+
var _common = require("../common");
|
|
8
|
+
var _validateAdRequestOptions = require("../validateAdRequestOptions");
|
|
9
|
+
var _MobileAd = require("./MobileAd");
|
|
10
|
+
var _AdEventType = require("../AdEventType");
|
|
11
|
+
var _NativeRewardedInterstitialModule = _interopRequireDefault(require("../specs/modules/NativeRewardedInterstitialModule"));
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
/*
|
|
14
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
15
|
+
*
|
|
16
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
17
|
+
* you may not use this library except in compliance with the License.
|
|
18
|
+
* You may obtain a copy of the License at
|
|
19
|
+
*
|
|
20
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
21
|
+
*
|
|
22
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
23
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
24
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
25
|
+
* See the License for the specific language governing permissions and
|
|
26
|
+
* limitations under the License.
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A class for interacting and showing Rewarded Interstitial Ads.
|
|
32
|
+
*
|
|
33
|
+
* An Rewarded Interstitial advert can be pre-loaded and shown at a suitable point in your apps flow, such as at the end of a level
|
|
34
|
+
* in a game. The content of a rewarded interstital advert can be controlled via your Google Mobile Ads dashboard. Typically users are rewarded
|
|
35
|
+
* after completing a specific advert action (e.g. watching a video or submitting an option via an interactive form).
|
|
36
|
+
* Events (such as the user earning a reward or closing a rewarded interstital advert early) are sent back for you to handle accordingly
|
|
37
|
+
* within your application.
|
|
38
|
+
*
|
|
39
|
+
* #### Example
|
|
40
|
+
*
|
|
41
|
+
* First create a new Rewarded Interstitial instance, passing in your Ad Unit ID from the Google Mobile Ads configuration console, and any additional
|
|
42
|
+
* request options. The example below will present a test advert, and only request a non-personalized ad.
|
|
43
|
+
*
|
|
44
|
+
* ```js
|
|
45
|
+
* import { RewardedInterstitialAd, TestIds } from 'react-native-google-mobile-ads';
|
|
46
|
+
*
|
|
47
|
+
* const rewardedInterstitial = RewardedInterstitialAd.createForAdRequest(TestIds.REWARDED_INTERSTITIAL, {
|
|
48
|
+
* requestNonPersonalizedAdsOnly: true,
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* Each advert needs to be loaded from Google Mobile Ads before being shown. It is recommended this is performed before the user
|
|
53
|
+
* reaches the checkpoint to show the advert, so it's ready to go. Before loading the advert, we need to setup
|
|
54
|
+
* event listeners to listen for updates from Google Mobile Ads, such as advert loaded or failed to load.
|
|
55
|
+
*
|
|
56
|
+
* Event types match the `AdEventType` or `RewardedAdEventType` interface. The potential user reward for rewarded interstitial
|
|
57
|
+
* adverts are passed back to the event handler on advert load and when the user earns the reward.
|
|
58
|
+
*
|
|
59
|
+
* ```js
|
|
60
|
+
* import { RewardedAdEventType } from 'react-native-google-mobile-ads';
|
|
61
|
+
*
|
|
62
|
+
* rewardedInterstitial.addAdEventListener(RewardedAdEventType.LOADED. () => {
|
|
63
|
+
* rewarded.show();
|
|
64
|
+
* });
|
|
65
|
+
* rewardedInterstitial.addAdEventListener(RewardedAdEventType.EARNED_REWARD. (reward) => {
|
|
66
|
+
* console.log('User earned reward of ', reward);
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* rewardedInterstitial.load();
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* The rewarded interstitial advert will be presented to the user, and several more events can be triggered such as the user clicking the
|
|
73
|
+
* advert, closing it or completing the action.
|
|
74
|
+
*/
|
|
75
|
+
class RewardedInterstitialAd extends _MobileAd.MobileAd {
|
|
76
|
+
static _rewardedInterstitialRequest = 0;
|
|
77
|
+
/**
|
|
78
|
+
* Creates a new RewardedInterstitialAd instance.
|
|
79
|
+
*
|
|
80
|
+
* #### Example
|
|
81
|
+
*
|
|
82
|
+
* ```js
|
|
83
|
+
* import { RewardedInterstitialAd, RewardedAdEventType, TestIds } from 'react-native-google-mobile-ads';
|
|
84
|
+
*
|
|
85
|
+
* const rewardedInterstitialAd = await RewardedInterstitialAd.createForAdRequest(TestIds.REWARDED_INTERSTITIAL, {
|
|
86
|
+
* requestAgent: 'CoolAds',
|
|
87
|
+
* });
|
|
88
|
+
*
|
|
89
|
+
* rewardedInterstitialAd.addAdEventListener(RewardedAdEventType.LOADED. () => {
|
|
90
|
+
* rewardedInterstitialAd.show();
|
|
91
|
+
* });
|
|
92
|
+
* rewardedInterstitialAd.addAdEventListener(RewardedAdEventType.EARNED_REWARD. (reward) => {
|
|
93
|
+
* console.log('User earned reward of ', reward);
|
|
94
|
+
* });
|
|
95
|
+
*
|
|
96
|
+
* rewardedInterstitialAd.load();
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @param adUnitId The Ad Unit ID for the Rewarded Interstitial Ad. You can find this on your Google Mobile Ads dashboard.
|
|
100
|
+
* @param requestOptions Optional RequestOptions used to load the ad.
|
|
101
|
+
*/
|
|
102
|
+
static createForAdRequest(adUnitId, requestOptions) {
|
|
103
|
+
if (!(0, _common.isString)(adUnitId)) {
|
|
104
|
+
throw new Error("RewardedInterstitialAd.createForAdRequest(*) 'adUnitId' expected an string value.");
|
|
105
|
+
}
|
|
106
|
+
let options = {};
|
|
107
|
+
try {
|
|
108
|
+
options = (0, _validateAdRequestOptions.validateAdRequestOptions)(requestOptions);
|
|
109
|
+
} catch (e) {
|
|
110
|
+
if (e instanceof Error) {
|
|
111
|
+
throw new Error(`RewardedInterstitialAd.createForAdRequest(_, *) ${e.message}.`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const requestId = RewardedInterstitialAd._rewardedInterstitialRequest++;
|
|
115
|
+
return new RewardedInterstitialAd('rewarded_interstitial', requestId, adUnitId, _NativeRewardedInterstitialModule.default.rewardedInterstitialLoad.bind(this), _NativeRewardedInterstitialModule.default.rewardedInterstitialShow.bind(this), options);
|
|
116
|
+
}
|
|
117
|
+
addAdEventsListener(listener) {
|
|
118
|
+
return this._addAdEventsListener(listener);
|
|
119
|
+
}
|
|
120
|
+
addAdEventListener(type, listener) {
|
|
121
|
+
if (type === _AdEventType.AdEventType.LOADED) {
|
|
122
|
+
throw new Error('RewardedInterstitialAd.addAdEventListener(*) use RewardedAdEventType.LOADED instead of AdEventType.LOADED.');
|
|
123
|
+
}
|
|
124
|
+
return this._addAdEventListener(type, listener);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.RewardedInterstitialAd = RewardedInterstitialAd;
|
|
128
|
+
//# sourceMappingURL=RewardedInterstitialAd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_common","require","_validateAdRequestOptions","_MobileAd","_AdEventType","_NativeRewardedInterstitialModule","_interopRequireDefault","e","__esModule","default","RewardedInterstitialAd","MobileAd","_rewardedInterstitialRequest","createForAdRequest","adUnitId","requestOptions","isString","Error","options","validateAdRequestOptions","message","requestId","NativeRewardedInterstitialModule","rewardedInterstitialLoad","bind","rewardedInterstitialShow","addAdEventsListener","listener","_addAdEventsListener","addAdEventListener","type","AdEventType","LOADED","_addAdEventListener","exports"],"sourceRoot":"../../../src","sources":["ads/RewardedInterstitialAd.ts"],"mappings":";;;;;;AAiBA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,yBAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAKA,IAAAI,iCAAA,GAAAC,sBAAA,CAAAL,OAAA;AAAiG,SAAAK,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAzBjG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,sBAAsB,SAASC,kBAAQ,CAAC;EACnD,OAAiBC,4BAA4B,GAAG,CAAC;EACjD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAOC,kBAAkBA,CAACC,QAAgB,EAAEC,cAA+B,EAAE;IAC3E,IAAI,CAAC,IAAAC,gBAAQ,EAACF,QAAQ,CAAC,EAAE;MACvB,MAAM,IAAIG,KAAK,CACb,mFACF,CAAC;IACH;IAEA,IAAIC,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI;MACFA,OAAO,GAAG,IAAAC,kDAAwB,EAACJ,cAAc,CAAC;IACpD,CAAC,CAAC,OAAOR,CAAC,EAAE;MACV,IAAIA,CAAC,YAAYU,KAAK,EAAE;QACtB,MAAM,IAAIA,KAAK,CAAC,mDAAmDV,CAAC,CAACa,OAAO,GAAG,CAAC;MAClF;IACF;IAEA,MAAMC,SAAS,GAAGX,sBAAsB,CAACE,4BAA4B,EAAE;IACvE,OAAO,IAAIF,sBAAsB,CAC/B,uBAAuB,EACvBW,SAAS,EACTP,QAAQ,EACRQ,yCAAgC,CAACC,wBAAwB,CAACC,IAAI,CAAC,IAAI,CAAC,EACpEF,yCAAgC,CAACG,wBAAwB,CAACD,IAAI,CAAC,IAAI,CAAC,EACpEN,OACF,CAAC;EACH;EAEAQ,mBAAmBA,CACjBC,QAA6B,EACjB;IACZ,OAAO,IAAI,CAACC,oBAAoB,CAACD,QAAQ,CAAC;EAC5C;EAEAE,kBAAkBA,CAChBC,IAAO,EACPH,QAA4B,EAC5B;IACA,IAAIG,IAAI,KAAKC,wBAAW,CAACC,MAAM,EAAE;MAC/B,MAAM,IAAIf,KAAK,CACb,4GACF,CAAC;IACH;IACA,OAAO,IAAI,CAACgB,mBAAmB,CAACH,IAAI,EAAEH,QAAQ,CAAC;EACjD;AACF;AAACO,OAAA,CAAAxB,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NativeAd = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
var _EventEmitter = _interopRequireDefault(require("react-native/Libraries/vendor/emitter/EventEmitter"));
|
|
9
|
+
var _NativeAdEventType = require("../../NativeAdEventType");
|
|
10
|
+
var _common = require("../../common");
|
|
11
|
+
var _NativeGoogleMobileAdsNativeModule = _interopRequireDefault(require("../../specs/modules/NativeGoogleMobileAdsNativeModule"));
|
|
12
|
+
var _validateNativeAdRequestOptions = require("../../validateNativeAdRequestOptions");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
/*
|
|
15
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
16
|
+
*
|
|
17
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
18
|
+
* you may not use this library except in compliance with the License.
|
|
19
|
+
* You may obtain a copy of the License at
|
|
20
|
+
*
|
|
21
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
22
|
+
*
|
|
23
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
24
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
25
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
26
|
+
* See the License for the specific language governing permissions and
|
|
27
|
+
* limitations under the License.
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A class for loading Native Ads.
|
|
33
|
+
*/
|
|
34
|
+
class NativeAd {
|
|
35
|
+
constructor(adUnitId, props) {
|
|
36
|
+
this.adUnitId = adUnitId;
|
|
37
|
+
this.responseId = props.responseId;
|
|
38
|
+
this.advertiser = props.advertiser;
|
|
39
|
+
this.body = props.body;
|
|
40
|
+
this.callToAction = props.callToAction;
|
|
41
|
+
this.headline = props.headline;
|
|
42
|
+
this.price = props.price;
|
|
43
|
+
this.store = props.store;
|
|
44
|
+
this.starRating = props.starRating;
|
|
45
|
+
this.icon = props.icon;
|
|
46
|
+
this.images = props.images;
|
|
47
|
+
this.mediaContent = props.mediaContent;
|
|
48
|
+
this.extras = props.extras;
|
|
49
|
+
if ('onAdEvent' in _NativeGoogleMobileAdsNativeModule.default) {
|
|
50
|
+
this.nativeEventSubscription = _NativeGoogleMobileAdsNativeModule.default.onAdEvent(this.onNativeAdEvent.bind(this));
|
|
51
|
+
} else {
|
|
52
|
+
let eventEmitter;
|
|
53
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
54
|
+
eventEmitter = new _reactNative.NativeEventEmitter(_NativeGoogleMobileAdsNativeModule.default);
|
|
55
|
+
} else {
|
|
56
|
+
eventEmitter = new _reactNative.NativeEventEmitter();
|
|
57
|
+
}
|
|
58
|
+
this.nativeEventSubscription = eventEmitter.addListener('RNGMANativeAdEvent', this.onNativeAdEvent.bind(this));
|
|
59
|
+
}
|
|
60
|
+
this.eventEmitter = new _EventEmitter.default();
|
|
61
|
+
}
|
|
62
|
+
onNativeAdEvent({
|
|
63
|
+
responseId,
|
|
64
|
+
type,
|
|
65
|
+
...data
|
|
66
|
+
}) {
|
|
67
|
+
if (this.responseId !== responseId) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
this.eventEmitter.emit(type, data);
|
|
71
|
+
}
|
|
72
|
+
addAdEventListener(type, listener) {
|
|
73
|
+
if (!(0, _common.isOneOf)(type, Object.values(_NativeAdEventType.NativeAdEventType))) {
|
|
74
|
+
throw new Error(`NativeAd.addAdEventListener(*) 'type' expected a valid event type value.`);
|
|
75
|
+
}
|
|
76
|
+
if (!(0, _common.isFunction)(listener)) {
|
|
77
|
+
throw new Error(`NativeAd.addAdEventListener(_, *) 'listener' expected a function.`);
|
|
78
|
+
}
|
|
79
|
+
return this.eventEmitter.addListener(type, listener);
|
|
80
|
+
}
|
|
81
|
+
removeAllAdEventListeners() {
|
|
82
|
+
this.eventEmitter.removeAllListeners();
|
|
83
|
+
}
|
|
84
|
+
destroy() {
|
|
85
|
+
_NativeGoogleMobileAdsNativeModule.default.destroy(this.responseId);
|
|
86
|
+
this.nativeEventSubscription.remove();
|
|
87
|
+
this.removeAllAdEventListeners();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Creates a new NativeAd instance.
|
|
92
|
+
*
|
|
93
|
+
* #### Example
|
|
94
|
+
*
|
|
95
|
+
* ```js
|
|
96
|
+
* import { NativeAd, AdEventType, TestIds } from 'react-native-google-mobile-ads';
|
|
97
|
+
*
|
|
98
|
+
* const nativeAd = await NativeAd.createForAdRequest(TestIds.NATIVE, {
|
|
99
|
+
* requestAgent: 'CoolAds',
|
|
100
|
+
* });
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* @param adUnitId The Ad Unit ID for the Native Ad. You can find this on your Google Mobile Ads dashboard.
|
|
104
|
+
* @param requestOptions Optional RequestOptions used to load the ad.
|
|
105
|
+
*/
|
|
106
|
+
static async createForAdRequest(adUnitId, requestOptions) {
|
|
107
|
+
if (!(0, _common.isString)(adUnitId)) {
|
|
108
|
+
throw new Error("NativeAd.createForAdRequest(*) 'adUnitId' expected an string value.");
|
|
109
|
+
}
|
|
110
|
+
let options = {};
|
|
111
|
+
try {
|
|
112
|
+
options = (0, _validateNativeAdRequestOptions.validateNativeAdRequestOptions)(requestOptions);
|
|
113
|
+
} catch (e) {
|
|
114
|
+
if (e instanceof Error) {
|
|
115
|
+
throw new Error(`NativeAd.createForAdRequest(_, *) ${e.message}.`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const props = await _NativeGoogleMobileAdsNativeModule.default.load(adUnitId, options);
|
|
119
|
+
return new NativeAd(adUnitId, props);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.NativeAd = NativeAd;
|
|
123
|
+
//# sourceMappingURL=NativeAd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_EventEmitter","_interopRequireDefault","_NativeAdEventType","_common","_NativeGoogleMobileAdsNativeModule","_validateNativeAdRequestOptions","e","__esModule","default","NativeAd","constructor","adUnitId","props","responseId","advertiser","body","callToAction","headline","price","store","starRating","icon","images","mediaContent","extras","NativeGoogleMobileAdsNativeModule","nativeEventSubscription","onAdEvent","onNativeAdEvent","bind","eventEmitter","Platform","OS","NativeEventEmitter","addListener","EventEmitter","type","data","emit","addAdEventListener","listener","isOneOf","Object","values","NativeAdEventType","Error","isFunction","removeAllAdEventListeners","removeAllListeners","destroy","remove","createForAdRequest","requestOptions","isString","options","validateNativeAdRequestOptions","message","load","exports"],"sourceRoot":"../../../../src","sources":["ads/native-ad/NativeAd.ts"],"mappings":";;;;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,CAAC,IAAI,CAACpC,UAAU,CAAC;IAC1D,IAAI,CAACa,uBAAuB,CAACwB,MAAM,CAAC,CAAC;IACrC,IAAI,CAACH,yBAAyB,CAAC,CAAC;EAClC;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,aAAaI,kBAAkBA,CAC7BxC,QAAgB,EAChByC,cAAuC,EACpB;IACnB,IAAI,CAAC,IAAAC,gBAAQ,EAAC1C,QAAQ,CAAC,EAAE;MACvB,MAAM,IAAIkC,KAAK,CAAC,qEAAqE,CAAC;IACxF;IAEA,IAAIS,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI;MACFA,OAAO,GAAG,IAAAC,8DAA8B,EAACH,cAAc,CAAC;IAC1D,CAAC,CAAC,OAAO9C,CAAC,EAAE;MACV,IAAIA,CAAC,YAAYuC,KAAK,EAAE;QACtB,MAAM,IAAIA,KAAK,CAAC,qCAAqCvC,CAAC,CAACkD,OAAO,GAAG,CAAC;MACpE;IACF;IAEA,MAAM5C,KAAK,GAAG,MAAMa,0CAAiC,CAACgC,IAAI,CAAC9C,QAAQ,EAAE2C,OAAO,CAAC;IAE7E,OAAO,IAAI7C,QAAQ,CAACE,QAAQ,EAAEC,KAAK,CAAC;EACtC;AACF;AAAC8C,OAAA,CAAAjD,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NativeAdContext = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
/*
|
|
9
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this library except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const NativeAdContext = exports.NativeAdContext = /*#__PURE__*/(0, _react.createContext)({});
|
|
26
|
+
//# sourceMappingURL=NativeAdContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","NativeAdContext","exports","createContext"],"sourceRoot":"../../../../src","sources":["ads/native-ad/NativeAdContext.ts"],"mappings":";;;;;;AAkBA,IAAAA,MAAA,GAAAC,OAAA;AAlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUO,MAAMC,eAAe,GAAAC,OAAA,CAAAD,eAAA,gBAAG,IAAAE,oBAAa,EAAsB,CAAC,CAAwB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NativeAdView = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _NativeAdContext = require("./NativeAdContext");
|
|
9
|
+
var _GoogleMobileAdsNativeViewNativeComponent = _interopRequireDefault(require("../../specs/components/GoogleMobileAdsNativeViewNativeComponent"));
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
+
/*
|
|
14
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
15
|
+
*
|
|
16
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
17
|
+
* you may not use this library except in compliance with the License.
|
|
18
|
+
* You may obtain a copy of the License at
|
|
19
|
+
*
|
|
20
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
21
|
+
*
|
|
22
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
23
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
24
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
25
|
+
* See the License for the specific language governing permissions and
|
|
26
|
+
* limitations under the License.
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
const NativeAdView = props => {
|
|
31
|
+
const {
|
|
32
|
+
nativeAd,
|
|
33
|
+
children,
|
|
34
|
+
...viewProps
|
|
35
|
+
} = props;
|
|
36
|
+
const ref = (0, _react.useRef)(null);
|
|
37
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GoogleMobileAdsNativeViewNativeComponent.default, {
|
|
38
|
+
...viewProps,
|
|
39
|
+
ref: ref,
|
|
40
|
+
responseId: nativeAd.responseId,
|
|
41
|
+
removeClippedSubviews: false,
|
|
42
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_NativeAdContext.NativeAdContext.Provider, {
|
|
43
|
+
value: {
|
|
44
|
+
nativeAd,
|
|
45
|
+
viewRef: ref
|
|
46
|
+
},
|
|
47
|
+
children: children
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
exports.NativeAdView = NativeAdView;
|
|
52
|
+
//# sourceMappingURL=NativeAdView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_NativeAdContext","_GoogleMobileAdsNativeViewNativeComponent","_interopRequireDefault","_jsxRuntime","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","NativeAdView","props","nativeAd","children","viewProps","ref","useRef","jsx","responseId","removeClippedSubviews","NativeAdContext","Provider","value","viewRef","exports"],"sourceRoot":"../../../../src","sources":["ads/native-ad/NativeAdView.tsx"],"mappings":";;;;;;AAiBA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,yCAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAwG,IAAAI,WAAA,GAAAJ,OAAA;AAAA,SAAAG,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAV,uBAAA,YAAAA,CAAAM,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAE,CAAA,CAAAI,GAAA,CAAAX,CAAA,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