react-native-google-mobile-ads 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +32 -0
- package/README.md +65 -0
- package/RNGoogleMobileAds.podspec +42 -0
- package/__tests__/consent.test.ts +25 -0
- package/__tests__/googleMobileAds.test.ts +63 -0
- package/__tests__/interstitial.test.ts +53 -0
- package/__tests__/requestOptions.test.tsx +4 -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 +98 -0
- package/android/lint.xml +5 -0
- package/android/settings.gradle +1 -0
- package/android/src/main/AndroidManifest.xml +17 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeAppModule.java +169 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsAppOpenModule.java +161 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsBannerAdViewManager.java +209 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsCommon.java +256 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsConsentModule.java +226 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsEvent.java +72 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsInterstitialModule.java +159 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsModule.java +143 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsPackage.java +48 -0
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsRewardedModule.java +177 -0
- package/android/src/main/java/io/invertase/googlemobileads/common/RCTConvert.java +111 -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 +427 -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/babel.config.js +18 -0
- package/docs/displaying-ads.mdx +319 -0
- package/docs/european-user-consent.mdx +258 -0
- package/docs/img/logo_admob_192px.svg +19 -0
- package/docs/index.mdx +168 -0
- package/docs.json +9 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.h +29 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.m +98 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerViewManager.h +23 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerViewManager.m +153 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.h +60 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m +201 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.h +26 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.m +179 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.h +32 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.m +57 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.h +25 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.m +124 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsModule.h +24 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsModule.m +104 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedModule.h +25 -0
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedModule.m +173 -0
- package/ios/RNGoogleMobileAds/common/RNAppModule.h +24 -0
- package/ios/RNGoogleMobileAds/common/RNAppModule.m +158 -0
- package/ios/RNGoogleMobileAds/common/RNJSON.h +34 -0
- package/ios/RNGoogleMobileAds/common/RNJSON.m +93 -0
- package/ios/RNGoogleMobileAds/common/RNMeta.h +30 -0
- package/ios/RNGoogleMobileAds/common/RNMeta.m +61 -0
- package/ios/RNGoogleMobileAds/common/RNPreferences.h +44 -0
- package/ios/RNGoogleMobileAds/common/RNPreferences.m +94 -0
- package/ios/RNGoogleMobileAds/common/RNRCTEventEmitter.h +73 -0
- package/ios/RNGoogleMobileAds/common/RNRCTEventEmitter.m +150 -0
- package/ios/RNGoogleMobileAds/common/RNSharedUtils.h +48 -0
- package/ios/RNGoogleMobileAds/common/RNSharedUtils.m +56 -0
- package/ios/RNGoogleMobileAds.xcodeproj/project.pbxproj +377 -0
- package/ios/RNGoogleMobileAds.xcodeproj/xcshareddata/IDETemplateMacros.plist +24 -0
- package/ios_config.sh +140 -0
- package/jest.config.js +6 -0
- package/jest.setup.ts +29 -0
- package/lib/commonjs/AdEventType.js +34 -0
- package/lib/commonjs/AdEventType.js.map +1 -0
- package/lib/commonjs/AdsConsent.js +160 -0
- package/lib/commonjs/AdsConsent.js.map +1 -0
- package/lib/commonjs/AdsConsentDebugGeography.js +38 -0
- package/lib/commonjs/AdsConsentDebugGeography.js.map +1 -0
- package/lib/commonjs/AdsConsentStatus.js +36 -0
- package/lib/commonjs/AdsConsentStatus.js.map +1 -0
- package/lib/commonjs/BannerAdSize.js +38 -0
- package/lib/commonjs/BannerAdSize.js.map +1 -0
- package/lib/commonjs/MaxAdContentRating.js +33 -0
- package/lib/commonjs/MaxAdContentRating.js.map +1 -0
- package/lib/commonjs/MobileAds.js +67 -0
- package/lib/commonjs/MobileAds.js.map +1 -0
- package/lib/commonjs/RewardedAdEventType.js +31 -0
- package/lib/commonjs/RewardedAdEventType.js.map +1 -0
- package/lib/commonjs/TestIds.js +47 -0
- package/lib/commonjs/TestIds.js.map +1 -0
- package/lib/commonjs/ads/AppOpenAd.js +96 -0
- package/lib/commonjs/ads/AppOpenAd.js.map +1 -0
- package/lib/commonjs/ads/BannerAd.js +128 -0
- package/lib/commonjs/ads/BannerAd.js.map +1 -0
- package/lib/commonjs/ads/InterstitialAd.js +163 -0
- package/lib/commonjs/ads/InterstitialAd.js.map +1 -0
- package/lib/commonjs/ads/MobileAd.js +90 -0
- package/lib/commonjs/ads/MobileAd.js.map +1 -0
- package/lib/commonjs/ads/RewardedAd.js +169 -0
- package/lib/commonjs/ads/RewardedAd.js.map +1 -0
- package/lib/commonjs/common/Base64.js +121 -0
- package/lib/commonjs/common/Base64.js.map +1 -0
- package/lib/commonjs/common/MutatableParams.js +46 -0
- package/lib/commonjs/common/MutatableParams.js.map +1 -0
- package/lib/commonjs/common/ReferenceBase.js +59 -0
- package/lib/commonjs/common/ReferenceBase.js.map +1 -0
- package/lib/commonjs/common/deeps.js +101 -0
- package/lib/commonjs/common/deeps.js.map +1 -0
- package/lib/commonjs/common/id.js +82 -0
- package/lib/commonjs/common/id.js.map +1 -0
- package/lib/commonjs/common/index.js +212 -0
- package/lib/commonjs/common/index.js.map +1 -0
- package/lib/commonjs/common/path.js +144 -0
- package/lib/commonjs/common/path.js.map +1 -0
- package/lib/commonjs/common/promise.js +70 -0
- package/lib/commonjs/common/promise.js.map +1 -0
- package/lib/commonjs/common/serialize.js +52 -0
- package/lib/commonjs/common/serialize.js.map +1 -0
- package/lib/commonjs/common/validate.js +239 -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/index.js +143 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/internal/GoogleMobileAdsNativeEventEmitter.js +76 -0
- package/lib/commonjs/internal/GoogleMobileAdsNativeEventEmitter.js.map +1 -0
- package/lib/commonjs/internal/Module.js +60 -0
- package/lib/commonjs/internal/Module.js.map +1 -0
- package/lib/commonjs/internal/NativeError.js +70 -0
- package/lib/commonjs/internal/NativeError.js.map +1 -0
- package/lib/commonjs/internal/SharedEventEmitter.js +31 -0
- package/lib/commonjs/internal/SharedEventEmitter.js.map +1 -0
- package/lib/commonjs/internal/constants.js +30 -0
- package/lib/commonjs/internal/constants.js.map +1 -0
- package/lib/commonjs/internal/index.js +49 -0
- package/lib/commonjs/internal/index.js.map +1 -0
- package/lib/commonjs/internal/registry/nativeModule.js +231 -0
- package/lib/commonjs/internal/registry/nativeModule.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/AdShowOptions.js +2 -0
- package/lib/commonjs/types/AdShowOptions.js.map +1 -0
- package/lib/commonjs/types/AdapterStatus.js +18 -0
- package/lib/commonjs/types/AdapterStatus.js.map +1 -0
- package/lib/commonjs/types/AdsConsent.interface.js +6 -0
- package/lib/commonjs/types/AdsConsent.interface.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/GoogleMobileAdsNativeModule.js +6 -0
- package/lib/commonjs/types/GoogleMobileAdsNativeModule.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/Module.interface.js +2 -0
- package/lib/commonjs/types/Module.interface.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/validateAdRequestConfiguration.js +69 -0
- package/lib/commonjs/validateAdRequestConfiguration.js.map +1 -0
- package/lib/commonjs/validateAdRequestOptions.js +158 -0
- package/lib/commonjs/validateAdRequestOptions.js.map +1 -0
- package/lib/commonjs/validateAdShowOptions.js +47 -0
- package/lib/commonjs/validateAdShowOptions.js.map +1 -0
- package/lib/commonjs/version.js +10 -0
- package/lib/commonjs/version.js.map +1 -0
- package/lib/module/AdEventType.js +26 -0
- package/lib/module/AdEventType.js.map +1 -0
- package/lib/module/AdsConsent.js +148 -0
- package/lib/module/AdsConsent.js.map +1 -0
- package/lib/module/AdsConsentDebugGeography.js +30 -0
- package/lib/module/AdsConsentDebugGeography.js.map +1 -0
- package/lib/module/AdsConsentStatus.js +28 -0
- package/lib/module/AdsConsentStatus.js.map +1 -0
- package/lib/module/BannerAdSize.js +30 -0
- package/lib/module/BannerAdSize.js.map +1 -0
- package/lib/module/MaxAdContentRating.js +25 -0
- package/lib/module/MaxAdContentRating.js.map +1 -0
- package/lib/module/MobileAds.js +53 -0
- package/lib/module/MobileAds.js.map +1 -0
- package/lib/module/RewardedAdEventType.js +23 -0
- package/lib/module/RewardedAdEventType.js.map +1 -0
- package/lib/module/TestIds.js +38 -0
- package/lib/module/TestIds.js.map +1 -0
- package/lib/module/ads/AppOpenAd.js +81 -0
- package/lib/module/ads/AppOpenAd.js.map +1 -0
- package/lib/module/ads/BannerAd.js +108 -0
- package/lib/module/ads/BannerAd.js.map +1 -0
- package/lib/module/ads/InterstitialAd.js +149 -0
- package/lib/module/ads/InterstitialAd.js.map +1 -0
- package/lib/module/ads/MobileAd.js +94 -0
- package/lib/module/ads/MobileAd.js.map +1 -0
- package/lib/module/ads/RewardedAd.js +155 -0
- package/lib/module/ads/RewardedAd.js.map +1 -0
- package/lib/module/common/Base64.js +106 -0
- package/lib/module/common/Base64.js.map +1 -0
- package/lib/module/common/MutatableParams.js +52 -0
- package/lib/module/common/MutatableParams.js.map +1 -0
- package/lib/module/common/ReferenceBase.js +50 -0
- package/lib/module/common/ReferenceBase.js.map +1 -0
- package/lib/module/common/deeps.js +91 -0
- package/lib/module/common/deeps.js.map +1 -0
- package/lib/module/common/id.js +74 -0
- package/lib/module/common/id.js.map +1 -0
- package/lib/module/common/index.js +109 -0
- package/lib/module/common/index.js.map +1 -0
- package/lib/module/common/path.js +120 -0
- package/lib/module/common/path.js.map +1 -0
- package/lib/module/common/promise.js +60 -0
- package/lib/module/common/promise.js.map +1 -0
- package/lib/module/common/serialize.js +41 -0
- package/lib/module/common/serialize.js.map +1 -0
- package/lib/module/common/validate.js +197 -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/index.js +33 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/internal/GoogleMobileAdsNativeEventEmitter.js +83 -0
- package/lib/module/internal/GoogleMobileAdsNativeEventEmitter.js.map +1 -0
- package/lib/module/internal/Module.js +64 -0
- package/lib/module/internal/Module.js.map +1 -0
- package/lib/module/internal/NativeError.js +61 -0
- package/lib/module/internal/NativeError.js.map +1 -0
- package/lib/module/internal/SharedEventEmitter.js +20 -0
- package/lib/module/internal/SharedEventEmitter.js.map +1 -0
- package/lib/module/internal/constants.js +20 -0
- package/lib/module/internal/constants.js.map +1 -0
- package/lib/module/internal/index.js +21 -0
- package/lib/module/internal/index.js.map +1 -0
- package/lib/module/internal/registry/nativeModule.js +215 -0
- package/lib/module/internal/registry/nativeModule.js.map +1 -0
- package/lib/module/types/AdEventListener.js +2 -0
- package/lib/module/types/AdEventListener.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/AdapterStatus.js +10 -0
- package/lib/module/types/AdapterStatus.js.map +1 -0
- package/lib/module/types/AdsConsent.interface.js +2 -0
- package/lib/module/types/AdsConsent.interface.js.map +1 -0
- package/lib/module/types/BannerAdProps.js +2 -0
- package/lib/module/types/BannerAdProps.js.map +1 -0
- package/lib/module/types/GoogleMobileAdsNativeModule.js +2 -0
- package/lib/module/types/GoogleMobileAdsNativeModule.js.map +1 -0
- package/lib/module/types/MobileAd.interface.js +2 -0
- package/lib/module/types/MobileAd.interface.js.map +1 -0
- package/lib/module/types/MobileAdsModule.interface.js +2 -0
- package/lib/module/types/MobileAdsModule.interface.js.map +1 -0
- package/lib/module/types/Module.interface.js +2 -0
- package/lib/module/types/Module.interface.js.map +1 -0
- package/lib/module/types/RequestConfiguration.js +2 -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/validateAdRequestConfiguration.js +60 -0
- package/lib/module/validateAdRequestConfiguration.js.map +1 -0
- package/lib/module/validateAdRequestOptions.js +150 -0
- package/lib/module/validateAdRequestOptions.js.map +1 -0
- package/lib/module/validateAdShowOptions.js +39 -0
- package/lib/module/validateAdShowOptions.js.map +1 -0
- package/lib/module/version.js +3 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/AdEventType.d.ts +47 -0
- package/lib/typescript/AdsConsent.d.ts +2 -0
- package/lib/typescript/AdsConsentDebugGeography.d.ts +19 -0
- package/lib/typescript/AdsConsentStatus.d.ts +17 -0
- package/lib/typescript/BannerAdSize.d.ts +34 -0
- package/lib/typescript/MaxAdContentRating.d.ts +18 -0
- package/lib/typescript/MobileAds.d.ts +11 -0
- package/lib/typescript/RewardedAdEventType.d.ts +46 -0
- package/lib/typescript/TestIds.d.ts +6 -0
- package/lib/typescript/ads/AppOpenAd.d.ts +11 -0
- package/lib/typescript/ads/BannerAd.d.ts +3 -0
- package/lib/typescript/ads/InterstitialAd.d.ts +78 -0
- package/lib/typescript/ads/MobileAd.d.ts +32 -0
- package/lib/typescript/ads/RewardedAd.d.ts +84 -0
- package/lib/typescript/common/Base64.d.ts +14 -0
- package/lib/typescript/common/MutatableParams.d.ts +9 -0
- package/lib/typescript/common/ReferenceBase.d.ts +11 -0
- package/lib/typescript/common/deeps.d.ts +18 -0
- package/lib/typescript/common/id.d.ts +11 -0
- package/lib/typescript/common/index.d.ts +28 -0
- package/lib/typescript/common/path.d.ts +43 -0
- package/lib/typescript/common/promise.d.ts +13 -0
- package/lib/typescript/common/serialize.d.ts +5 -0
- package/lib/typescript/common/validate.d.ts +90 -0
- package/lib/typescript/index.d.ts +14 -0
- package/lib/typescript/internal/GoogleMobileAdsNativeEventEmitter.d.ts +12 -0
- package/lib/typescript/internal/Module.d.ts +13 -0
- package/lib/typescript/internal/NativeError.d.ts +26 -0
- package/lib/typescript/internal/SharedEventEmitter.d.ts +2 -0
- package/lib/typescript/internal/constants.d.ts +3 -0
- package/lib/typescript/internal/index.d.ts +4 -0
- package/lib/typescript/internal/registry/nativeModule.d.ts +15 -0
- package/lib/typescript/types/AdEventListener.d.ts +11 -0
- package/lib/typescript/types/AdShowOptions.d.ts +12 -0
- package/lib/typescript/types/AdapterStatus.d.ts +18 -0
- package/lib/typescript/types/AdsConsent.interface.d.ts +286 -0
- package/lib/typescript/types/BannerAdProps.d.ts +66 -0
- package/lib/typescript/types/GoogleMobileAdsNativeModule.d.ts +14 -0
- package/lib/typescript/types/MobileAd.interface.d.ts +64 -0
- package/lib/typescript/types/MobileAdsModule.interface.d.ts +38 -0
- package/lib/typescript/types/Module.interface.d.ts +14 -0
- package/lib/typescript/types/RequestConfiguration.d.ts +36 -0
- package/lib/typescript/types/RequestOptions.d.ts +106 -0
- package/lib/typescript/types/RewardedAdReward.d.ts +13 -0
- package/lib/typescript/validateAdRequestConfiguration.d.ts +2 -0
- package/lib/typescript/validateAdRequestOptions.d.ts +2 -0
- package/lib/typescript/validateAdShowOptions.d.ts +2 -0
- package/lib/typescript/version.d.ts +1 -0
- package/package.json +143 -0
- package/react-native.config.js +19 -0
- package/src/AdEventType.ts +68 -0
- package/src/AdsConsent.ts +191 -0
- package/src/AdsConsentDebugGeography.ts +38 -0
- package/src/AdsConsentStatus.ts +36 -0
- package/src/BannerAdSize.ts +59 -0
- package/src/MaxAdContentRating.ts +38 -0
- package/src/MobileAds.ts +84 -0
- package/src/RewardedAdEventType.ts +64 -0
- package/src/TestIds.ts +39 -0
- package/src/ads/AppOpenAd.ts +85 -0
- package/src/ads/BannerAd.tsx +126 -0
- package/src/ads/InterstitialAd.ts +156 -0
- package/src/ads/MobileAd.ts +101 -0
- package/src/ads/RewardedAd.ts +161 -0
- package/src/common/Base64.ts +114 -0
- package/src/common/MutatableParams.ts +50 -0
- package/src/common/ReferenceBase.ts +45 -0
- package/src/common/deeps.ts +88 -0
- package/src/common/id.ts +74 -0
- package/src/common/index.ts +103 -0
- package/src/common/path.ts +114 -0
- package/src/common/promise.ts +66 -0
- package/src/common/serialize.ts +43 -0
- package/src/common/validate.ts +205 -0
- package/src/declarations.d.ts +3 -0
- package/src/index.ts +35 -0
- package/src/internal/GoogleMobileAdsNativeEventEmitter.ts +81 -0
- package/src/internal/Module.ts +58 -0
- package/src/internal/NativeError.ts +56 -0
- package/src/internal/SharedEventEmitter.ts +22 -0
- package/src/internal/constants.ts +43 -0
- package/src/internal/index.ts +21 -0
- package/src/internal/registry/nativeModule.ts +226 -0
- package/src/types/AdEventListener.ts +16 -0
- package/src/types/AdShowOptions.ts +12 -0
- package/src/types/AdapterStatus.ts +20 -0
- package/src/types/AdsConsent.interface.ts +306 -0
- package/src/types/BannerAdProps.ts +73 -0
- package/src/types/GoogleMobileAdsNativeModule.ts +15 -0
- package/src/types/MobileAd.interface.ts +69 -0
- package/src/types/MobileAdsModule.interface.ts +43 -0
- package/src/types/Module.interface.ts +16 -0
- package/src/types/RequestConfiguration.ts +40 -0
- package/src/types/RequestOptions.ts +113 -0
- package/src/types/RewardedAdReward.ts +14 -0
- package/src/validateAdRequestConfiguration.ts +71 -0
- package/src/validateAdRequestOptions.ts +168 -0
- package/src/validateAdShowOptions.ts +41 -0
- package/src/version.ts +2 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this library except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
import { NativeEventEmitter, NativeModules } from 'react-native';
|
|
20
|
+
const {
|
|
21
|
+
RNAppModule
|
|
22
|
+
} = NativeModules;
|
|
23
|
+
|
|
24
|
+
class GANativeEventEmitter extends NativeEventEmitter {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(RNAppModule);
|
|
27
|
+
|
|
28
|
+
_defineProperty(this, "ready", void 0);
|
|
29
|
+
|
|
30
|
+
this.ready = false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
addListener(eventType, listener, context) {
|
|
34
|
+
if (!this.ready) {
|
|
35
|
+
RNAppModule.eventsNotifyReady(true);
|
|
36
|
+
this.ready = true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
RNAppModule.eventsAddListener(eventType);
|
|
40
|
+
const subscription = super.addListener(`rnapp_${eventType}`, listener, context); // React Native 0.65+ altered EventEmitter:
|
|
41
|
+
// - removeSubscription is gone
|
|
42
|
+
// - addListener returns an unsubscriber instead of a more complex object with eventType etc
|
|
43
|
+
// make sure eventType for backwards compatibility just in case
|
|
44
|
+
|
|
45
|
+
subscription.eventType = `rnapp_${eventType}`; // New style is to return a remove function on the object, just in csae people call that,
|
|
46
|
+
// we will modify it to do our native unsubscription then call the original
|
|
47
|
+
|
|
48
|
+
const originalRemove = subscription.remove;
|
|
49
|
+
|
|
50
|
+
const newRemove = () => {
|
|
51
|
+
RNAppModule.eventsRemoveListener(eventType, false);
|
|
52
|
+
|
|
53
|
+
if (super.removeSubscription != null) {
|
|
54
|
+
// This is for RN <= 0.64 - 65 and greater no longer have removeSubscription
|
|
55
|
+
super.removeSubscription(subscription);
|
|
56
|
+
} else if (originalRemove != null) {
|
|
57
|
+
// This is for RN >= 0.65
|
|
58
|
+
originalRemove();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
subscription.remove = newRemove;
|
|
63
|
+
return subscription;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
removeAllListeners(eventType) {
|
|
67
|
+
RNAppModule.eventsRemoveListener(eventType, true);
|
|
68
|
+
super.removeAllListeners(`rnapp_${eventType}`);
|
|
69
|
+
} // This is likely no longer ever called, but it is here for backwards compatibility with RN <= 0.64
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
removeSubscription(subscription) {
|
|
73
|
+
RNAppModule.eventsRemoveListener(subscription.eventType.replace('rnapp_', ''), false);
|
|
74
|
+
|
|
75
|
+
if (super.removeSubscription != null) {
|
|
76
|
+
super.removeSubscription(subscription);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const GoogleMobileAdsNativeEventEmitter = new GANativeEventEmitter();
|
|
83
|
+
//# sourceMappingURL=GoogleMobileAdsNativeEventEmitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["GoogleMobileAdsNativeEventEmitter.ts"],"names":["NativeEventEmitter","NativeModules","RNAppModule","GANativeEventEmitter","constructor","ready","addListener","eventType","listener","context","eventsNotifyReady","eventsAddListener","subscription","originalRemove","remove","newRemove","eventsRemoveListener","removeSubscription","removeAllListeners","replace","GoogleMobileAdsNativeEventEmitter"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,kBAAT,EAA6BC,aAA7B,QAAuE,cAAvE;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAkBD,aAAxB;;AAEA,MAAME,oBAAN,SAAmCH,kBAAnC,CAAsD;AAGpDI,EAAAA,WAAW,GAAG;AACZ,UAAMF,WAAN;;AADY;;AAEZ,SAAKG,KAAL,GAAa,KAAb;AACD;;AAEDC,EAAAA,WAAW,CACTC,SADS,EAETC,QAFS,EAGTC,OAHS,EAIT;AACA,QAAI,CAAC,KAAKJ,KAAV,EAAiB;AACfH,MAAAA,WAAW,CAACQ,iBAAZ,CAA8B,IAA9B;AACA,WAAKL,KAAL,GAAa,IAAb;AACD;;AACDH,IAAAA,WAAW,CAACS,iBAAZ,CAA8BJ,SAA9B;AAEA,UAAMK,YAAY,GAAG,MAAMN,WAAN,CAAmB,SAAQC,SAAU,EAArC,EAAwCC,QAAxC,EAAkDC,OAAlD,CAArB,CAPA,CASA;AACA;AACA;AAEA;;AACAG,IAAAA,YAAY,CAACL,SAAb,GAA0B,SAAQA,SAAU,EAA5C,CAdA,CAgBA;AACA;;AACA,UAAMM,cAAc,GAAGD,YAAY,CAACE,MAApC;;AACA,UAAMC,SAAS,GAAG,MAAM;AACtBb,MAAAA,WAAW,CAACc,oBAAZ,CAAiCT,SAAjC,EAA4C,KAA5C;;AACA,UAAI,MAAMU,kBAAN,IAA4B,IAAhC,EAAsC;AACpC;AACA,cAAMA,kBAAN,CAAyBL,YAAzB;AACD,OAHD,MAGO,IAAIC,cAAc,IAAI,IAAtB,EAA4B;AACjC;AACAA,QAAAA,cAAc;AACf;AACF,KATD;;AAUAD,IAAAA,YAAY,CAACE,MAAb,GAAsBC,SAAtB;AACA,WAAOH,YAAP;AACD;;AAEDM,EAAAA,kBAAkB,CAACX,SAAD,EAAoB;AACpCL,IAAAA,WAAW,CAACc,oBAAZ,CAAiCT,SAAjC,EAA4C,IAA5C;AACA,UAAMW,kBAAN,CAA0B,SAAQX,SAAU,EAA5C;AACD,GAhDmD,CAkDpD;;;AACAU,EAAAA,kBAAkB,CAACL,YAAD,EAAoC;AACpDV,IAAAA,WAAW,CAACc,oBAAZ,CAAiCJ,YAAY,CAACL,SAAb,CAAuBY,OAAvB,CAA+B,QAA/B,EAAyC,EAAzC,CAAjC,EAA+E,KAA/E;;AACA,QAAI,MAAMF,kBAAN,IAA4B,IAAhC,EAAsC;AACpC,YAAMA,kBAAN,CAAyBL,YAAzB;AACD;AACF;;AAxDmD;;AA2DtD,OAAO,MAAMQ,iCAAiC,GAAG,IAAIjB,oBAAJ,EAA1C","sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport { NativeEventEmitter, NativeModules, EmitterSubscription } from 'react-native';\n\nconst { RNAppModule } = NativeModules;\n\nclass GANativeEventEmitter extends NativeEventEmitter {\n ready: boolean;\n\n constructor() {\n super(RNAppModule);\n this.ready = false;\n }\n\n addListener(\n eventType: string,\n listener: (event: { appName?: string }) => void,\n context?: Record<string, unknown>,\n ) {\n if (!this.ready) {\n RNAppModule.eventsNotifyReady(true);\n this.ready = true;\n }\n RNAppModule.eventsAddListener(eventType);\n\n const subscription = super.addListener(`rnapp_${eventType}`, listener, context);\n\n // React Native 0.65+ altered EventEmitter:\n // - removeSubscription is gone\n // - addListener returns an unsubscriber instead of a more complex object with eventType etc\n\n // make sure eventType for backwards compatibility just in case\n subscription.eventType = `rnapp_${eventType}`;\n\n // New style is to return a remove function on the object, just in csae people call that,\n // we will modify it to do our native unsubscription then call the original\n const originalRemove = subscription.remove;\n const newRemove = () => {\n RNAppModule.eventsRemoveListener(eventType, false);\n if (super.removeSubscription != null) {\n // This is for RN <= 0.64 - 65 and greater no longer have removeSubscription\n super.removeSubscription(subscription);\n } else if (originalRemove != null) {\n // This is for RN >= 0.65\n originalRemove();\n }\n };\n subscription.remove = newRemove;\n return subscription;\n }\n\n removeAllListeners(eventType: string) {\n RNAppModule.eventsRemoveListener(eventType, true);\n super.removeAllListeners(`rnapp_${eventType}`);\n }\n\n // This is likely no longer ever called, but it is here for backwards compatibility with RN <= 0.64\n removeSubscription(subscription: EmitterSubscription) {\n RNAppModule.eventsRemoveListener(subscription.eventType.replace('rnapp_', ''), false);\n if (super.removeSubscription != null) {\n super.removeSubscription(subscription);\n }\n }\n}\n\nexport const GoogleMobileAdsNativeEventEmitter = new GANativeEventEmitter();\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this library except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
import { getNativeModule } from './registry/nativeModule';
|
|
20
|
+
import { SharedEventEmitter } from './SharedEventEmitter';
|
|
21
|
+
export class AppModule {
|
|
22
|
+
constructor(app, config) {
|
|
23
|
+
_defineProperty(this, "_app", void 0);
|
|
24
|
+
|
|
25
|
+
_defineProperty(this, "_nativeModule", void 0);
|
|
26
|
+
|
|
27
|
+
_defineProperty(this, "_config", void 0);
|
|
28
|
+
|
|
29
|
+
this._app = app;
|
|
30
|
+
this._nativeModule = null;
|
|
31
|
+
this._config = Object.assign({}, config);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get app() {
|
|
35
|
+
return this._app;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get emitter() {
|
|
39
|
+
return SharedEventEmitter;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
eventNameForApp() {
|
|
43
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
44
|
+
args[_key] = arguments[_key];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return `${this.app.name}-${args.join('-')}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
get native() {
|
|
51
|
+
if (this._nativeModule) {
|
|
52
|
+
return this._nativeModule;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
this._nativeModule = getNativeModule(this);
|
|
56
|
+
return this._nativeModule;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
} // Instance of checks don't work once compiled
|
|
60
|
+
|
|
61
|
+
_defineProperty(AppModule, "__extended__", {});
|
|
62
|
+
|
|
63
|
+
AppModule.__extended__ = {};
|
|
64
|
+
//# sourceMappingURL=Module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["Module.ts"],"names":["getNativeModule","SharedEventEmitter","AppModule","constructor","app","config","_app","_nativeModule","_config","Object","assign","emitter","eventNameForApp","args","name","join","native","__extended__"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,eAAT,QAAgC,yBAAhC;AACA,SAASC,kBAAT,QAAmC,sBAAnC;AAIA,OAAO,MAAMC,SAAN,CAAgB;AAOrBC,EAAAA,WAAW,CAACC,GAAD,EAAWC,MAAX,EAA2B;AAAA;;AAAA;;AAAA;;AACpC,SAAKC,IAAL,GAAYF,GAAZ;AACA,SAAKG,aAAL,GAAqB,IAArB;AACA,SAAKC,OAAL,GAAeC,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBL,MAAlB,CAAf;AACD;;AAEM,MAAHD,GAAG,GAAG;AACR,WAAO,KAAKE,IAAZ;AACD;;AAEU,MAAPK,OAAO,GAAG;AACZ,WAAOV,kBAAP;AACD;;AAEDW,EAAAA,eAAe,GAAoB;AAAA,sCAAhBC,IAAgB;AAAhBA,MAAAA,IAAgB;AAAA;;AACjC,WAAQ,GAAE,KAAKT,GAAL,CAASU,IAAK,IAAGD,IAAI,CAACE,IAAL,CAAU,GAAV,CAAe,EAA1C;AACD;;AAES,MAANC,MAAM,GAAG;AACX,QAAI,KAAKT,aAAT,EAAwB;AACtB,aAAO,KAAKA,aAAZ;AACD;;AACD,SAAKA,aAAL,GAAqBP,eAAe,CAAC,IAAD,CAApC;AACA,WAAO,KAAKO,aAAZ;AACD;;AA/BoB,C,CAkCvB;;gBAlCaL,S,kBAKW,E;;AA8BxBA,SAAS,CAACe,YAAV,GAAyB,EAAzB","sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport { getNativeModule } from './registry/nativeModule';\nimport { SharedEventEmitter } from './SharedEventEmitter';\nimport { App, Config } from '../types/Module.interface';\nimport { GoogleMobileAdsNativeModule } from '../types/GoogleMobileAdsNativeModule';\n\nexport class AppModule {\n _app: App;\n _nativeModule: unknown;\n _config: Config;\n\n static __extended__ = {};\n\n constructor(app: App, config: Config) {\n this._app = app;\n this._nativeModule = null;\n this._config = Object.assign({}, config);\n }\n\n get app() {\n return this._app;\n }\n\n get emitter() {\n return SharedEventEmitter;\n }\n\n eventNameForApp(...args: string[]) {\n return `${this.app.name}-${args.join('-')}`;\n }\n\n get native() {\n if (this._nativeModule) {\n return this._nativeModule as GoogleMobileAdsNativeModule;\n }\n this._nativeModule = getNativeModule(this);\n return this._nativeModule as GoogleMobileAdsNativeModule;\n }\n}\n\n// Instance of checks don't work once compiled\nAppModule.__extended__ = {};\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this library except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
export class NativeError extends Error {
|
|
20
|
+
static fromEvent(errorEvent, namespace, stack) {
|
|
21
|
+
return new NativeError({
|
|
22
|
+
userInfo: errorEvent
|
|
23
|
+
}, stack || new Error().stack || '', namespace);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
constructor(nativeError, jsStack, namespace) {
|
|
27
|
+
super();
|
|
28
|
+
|
|
29
|
+
_defineProperty(this, "namespace", void 0);
|
|
30
|
+
|
|
31
|
+
_defineProperty(this, "code", void 0);
|
|
32
|
+
|
|
33
|
+
_defineProperty(this, "message", void 0);
|
|
34
|
+
|
|
35
|
+
_defineProperty(this, "jsStack", void 0);
|
|
36
|
+
|
|
37
|
+
_defineProperty(this, "userInfo", void 0);
|
|
38
|
+
|
|
39
|
+
const {
|
|
40
|
+
userInfo
|
|
41
|
+
} = nativeError;
|
|
42
|
+
this.namespace = namespace;
|
|
43
|
+
this.code = `${this.namespace}/${userInfo.code || 'unknown'}`;
|
|
44
|
+
this.message = `[${this.code}] ${userInfo.message}`;
|
|
45
|
+
this.jsStack = jsStack;
|
|
46
|
+
this.userInfo = userInfo;
|
|
47
|
+
this.stack = NativeError.getStackWithMessage(`NativeError: ${this.message}`, this.jsStack);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Build a stack trace that includes JS stack prior to calling the native method.
|
|
51
|
+
*
|
|
52
|
+
* @returns {string}
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
static getStackWithMessage(message, jsStack) {
|
|
57
|
+
return [message, ...jsStack.split('\n').slice(2, 13)].join('\n');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=NativeError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["NativeError.ts"],"names":["NativeError","Error","fromEvent","errorEvent","namespace","stack","userInfo","constructor","nativeError","jsStack","code","message","getStackWithMessage","split","slice","join"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAO,MAAMA,WAAN,SAA0BC,KAA1B,CAAgC;AAOrB,SAATC,SAAS,CACdC,UADc,EAEdC,SAFc,EAGdC,KAHc,EAId;AACA,WAAO,IAAIL,WAAJ,CAAgB;AAAEM,MAAAA,QAAQ,EAAEH;AAAZ,KAAhB,EAA0CE,KAAK,IAAI,IAAIJ,KAAJ,GAAYI,KAArB,IAA8B,EAAxE,EAA4ED,SAA5E,CAAP;AACD;;AAEDG,EAAAA,WAAW,CACTC,WADS,EAETC,OAFS,EAGTL,SAHS,EAIT;AACA;;AADA;;AAAA;;AAAA;;AAAA;;AAAA;;AAEA,UAAM;AAAEE,MAAAA;AAAF,QAAeE,WAArB;AACA,SAAKJ,SAAL,GAAiBA,SAAjB;AACA,SAAKM,IAAL,GAAa,GAAE,KAAKN,SAAU,IAAGE,QAAQ,CAACI,IAAT,IAAiB,SAAU,EAA5D;AACA,SAAKC,OAAL,GAAgB,IAAG,KAAKD,IAAK,KAAIJ,QAAQ,CAACK,OAAQ,EAAlD;AACA,SAAKF,OAAL,GAAeA,OAAf;AACA,SAAKH,QAAL,GAAgBA,QAAhB;AACA,SAAKD,KAAL,GAAaL,WAAW,CAACY,mBAAZ,CAAiC,gBAAe,KAAKD,OAAQ,EAA7D,EAAgE,KAAKF,OAArE,CAAb;AACD;AAED;AACF;AACA;AACA;AACA;;;AAC4B,SAAnBG,mBAAmB,CAACD,OAAD,EAAkBF,OAAlB,EAAmC;AAC3D,WAAO,CAACE,OAAD,EAAU,GAAGF,OAAO,CAACI,KAAR,CAAc,IAAd,EAAoBC,KAApB,CAA0B,CAA1B,EAA6B,EAA7B,CAAb,EAA+CC,IAA/C,CAAoD,IAApD,CAAP;AACD;;AArCoC","sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nexport class NativeError extends Error {\n namespace: string;\n code: string;\n message: string;\n jsStack: string;\n userInfo: { code: string; message: string };\n\n static fromEvent(\n errorEvent: { code: string; message: string },\n namespace: string,\n stack?: string,\n ) {\n return new NativeError({ userInfo: errorEvent }, stack || new Error().stack || '', namespace);\n }\n\n constructor(\n nativeError: { userInfo: { code: string; message: string } },\n jsStack: string,\n namespace: string,\n ) {\n super();\n const { userInfo } = nativeError;\n this.namespace = namespace;\n this.code = `${this.namespace}/${userInfo.code || 'unknown'}`;\n this.message = `[${this.code}] ${userInfo.message}`;\n this.jsStack = jsStack;\n this.userInfo = userInfo;\n this.stack = NativeError.getStackWithMessage(`NativeError: ${this.message}`, this.jsStack);\n }\n\n /**\n * Build a stack trace that includes JS stack prior to calling the native method.\n *\n * @returns {string}\n */\n static getStackWithMessage(message: string, jsStack: string) {\n return [message, ...jsStack.split('\\n').slice(2, 13)].join('\\n');\n }\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
// @ts-ignore: Could not find a declaration file
|
|
18
|
+
import Emitter from 'react-native/Libraries/vendor/emitter/EventEmitter';
|
|
19
|
+
export const SharedEventEmitter = new Emitter();
|
|
20
|
+
//# sourceMappingURL=SharedEventEmitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["SharedEventEmitter.ts"],"names":["Emitter","SharedEventEmitter"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA,OAAOA,OAAP,MAAoB,oDAApB;AAGA,OAAO,MAAMC,kBAAgC,GAAG,IAAID,OAAJ,EAAzC","sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\n// @ts-ignore: Could not find a declaration file\nimport Emitter from 'react-native/Libraries/vendor/emitter/EventEmitter';\nimport { EventEmitter } from 'react-native';\n\nexport const SharedEventEmitter: EventEmitter = new Emitter();\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
export const APP_NATIVE_MODULE = 'RNFBAppModule';
|
|
18
|
+
export const DEFAULT_APP_NAME = '[DEFAULT]';
|
|
19
|
+
export const KNOWN_NAMESPACES = ['appCheck', 'appDistribution', 'auth', 'analytics', 'remoteConfig', 'crashlytics', 'database', 'inAppMessaging', 'installations', 'firestore', 'functions', 'indexing', 'storage', 'dynamicLinks', 'messaging', 'naturalLanguage', 'ml', 'notifications', 'perf', 'utils'];
|
|
20
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["constants.ts"],"names":["APP_NATIVE_MODULE","DEFAULT_APP_NAME","KNOWN_NAMESPACES"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAO,MAAMA,iBAAiB,GAAG,eAA1B;AAEP,OAAO,MAAMC,gBAAgB,GAAG,WAAzB;AAEP,OAAO,MAAMC,gBAAgB,GAAG,CAC9B,UAD8B,EAE9B,iBAF8B,EAG9B,MAH8B,EAI9B,WAJ8B,EAK9B,cAL8B,EAM9B,aAN8B,EAO9B,UAP8B,EAQ9B,gBAR8B,EAS9B,eAT8B,EAU9B,WAV8B,EAW9B,WAX8B,EAY9B,UAZ8B,EAa9B,SAb8B,EAc9B,cAd8B,EAe9B,WAf8B,EAgB9B,iBAhB8B,EAiB9B,IAjB8B,EAkB9B,eAlB8B,EAmB9B,MAnB8B,EAoB9B,OApB8B,CAAzB","sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nexport const APP_NATIVE_MODULE = 'RNFBAppModule';\n\nexport const DEFAULT_APP_NAME = '[DEFAULT]';\n\nexport const KNOWN_NAMESPACES = [\n 'appCheck',\n 'appDistribution',\n 'auth',\n 'analytics',\n 'remoteConfig',\n 'crashlytics',\n 'database',\n 'inAppMessaging',\n 'installations',\n 'firestore',\n 'functions',\n 'indexing',\n 'storage',\n 'dynamicLinks',\n 'messaging',\n 'naturalLanguage',\n 'ml',\n 'notifications',\n 'perf',\n 'utils',\n];\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
export { AppModule as Module } from './Module';
|
|
18
|
+
export { NativeError } from './NativeError';
|
|
19
|
+
export * from './registry/nativeModule';
|
|
20
|
+
export { SharedEventEmitter } from './SharedEventEmitter';
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["AppModule","Module","NativeError","SharedEventEmitter"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,SAAS,IAAIC,MAAtB,QAAoC,UAApC;AACA,SAASC,WAAT,QAA4B,eAA5B;AACA,cAAc,yBAAd;AACA,SAASC,kBAAT,QAAmC,sBAAnC","sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nexport { AppModule as Module } from './Module';\nexport { NativeError } from './NativeError';\nexport * from './registry/nativeModule';\nexport { SharedEventEmitter } from './SharedEventEmitter';\n"]}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
import { NativeModules, Platform } from 'react-native';
|
|
18
|
+
import { APP_NATIVE_MODULE } from '../constants';
|
|
19
|
+
import { NativeError } from '../NativeError';
|
|
20
|
+
import { GoogleMobileAdsNativeEventEmitter } from '../GoogleMobileAdsNativeEventEmitter';
|
|
21
|
+
import { SharedEventEmitter } from '../SharedEventEmitter';
|
|
22
|
+
import { isFunction } from '../../common';
|
|
23
|
+
const NATIVE_MODULE_REGISTRY = {};
|
|
24
|
+
const NATIVE_MODULE_EVENT_SUBSCRIPTIONS = {};
|
|
25
|
+
|
|
26
|
+
function nativeModuleKey(module) {
|
|
27
|
+
return `${module._customUrlOrRegion || ''}:${module.app.name}:${module._config.namespace}`;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Wraps a native module method to provide
|
|
31
|
+
* auto prepended args and custom Error classes.
|
|
32
|
+
*
|
|
33
|
+
* @param namespace
|
|
34
|
+
* @param method
|
|
35
|
+
* @param argToPrepend
|
|
36
|
+
* @returns {Function}
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
function nativeModuleMethodWrapped(namespace, method, argToPrepend) {
|
|
41
|
+
return function () {
|
|
42
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
43
|
+
args[_key] = arguments[_key];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const possiblePromise = method(...[...argToPrepend, ...args]);
|
|
47
|
+
|
|
48
|
+
if (possiblePromise && possiblePromise.then) {
|
|
49
|
+
const jsStack = new Error().stack || '';
|
|
50
|
+
return possiblePromise.catch(nativeError => Promise.reject(new NativeError(nativeError, jsStack, namespace)));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return possiblePromise;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Prepends all arguments in prependArgs to all native method calls
|
|
58
|
+
*
|
|
59
|
+
* @param namespace
|
|
60
|
+
* @param NativeModule
|
|
61
|
+
* @param argToPrepend
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
function nativeModuleWrapped(namespace, NativeModule, argToPrepend) {
|
|
66
|
+
const native = {};
|
|
67
|
+
|
|
68
|
+
if (!NativeModule) {
|
|
69
|
+
return NativeModule;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const properties = Object.keys(NativeModule);
|
|
73
|
+
|
|
74
|
+
for (let i = 0, len = properties.length; i < len; i++) {
|
|
75
|
+
const property = properties[i];
|
|
76
|
+
|
|
77
|
+
if (isFunction(NativeModule[property])) {
|
|
78
|
+
native[property] = nativeModuleMethodWrapped(namespace, NativeModule[property], argToPrepend);
|
|
79
|
+
} else {
|
|
80
|
+
native[property] = NativeModule[property];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return native;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Initialises and wraps all the native module methods.
|
|
88
|
+
*
|
|
89
|
+
* @param module
|
|
90
|
+
* @returns {*}
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
function initialiseNativeModule(module) {
|
|
95
|
+
const config = module._config;
|
|
96
|
+
const key = nativeModuleKey(module);
|
|
97
|
+
const {
|
|
98
|
+
namespace,
|
|
99
|
+
nativeEvents,
|
|
100
|
+
nativeModuleName
|
|
101
|
+
} = config;
|
|
102
|
+
const multiModuleRoot = {};
|
|
103
|
+
const multiModule = Array.isArray(nativeModuleName);
|
|
104
|
+
const nativeModuleNames = multiModule ? nativeModuleName : [nativeModuleName];
|
|
105
|
+
|
|
106
|
+
for (let i = 0; i < nativeModuleNames.length; i++) {
|
|
107
|
+
const nativeModule = NativeModules[nativeModuleNames[i]]; // only error if there's a single native module
|
|
108
|
+
// as multi modules can mean some are optional
|
|
109
|
+
|
|
110
|
+
if (!multiModule && !nativeModule) {
|
|
111
|
+
throw new Error(getMissingModuleHelpText(namespace));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (multiModule) {
|
|
115
|
+
multiModuleRoot[nativeModuleNames[i]] = !!nativeModule;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
Object.assign(multiModuleRoot, nativeModuleWrapped(namespace, nativeModule, []));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (nativeEvents && nativeEvents.length) {
|
|
122
|
+
for (let i = 0, len = nativeEvents.length; i < len; i++) {
|
|
123
|
+
subscribeToNativeModuleEvent(nativeEvents[i]);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
Object.freeze(multiModuleRoot);
|
|
128
|
+
NATIVE_MODULE_REGISTRY[key] = multiModuleRoot;
|
|
129
|
+
return NATIVE_MODULE_REGISTRY[key];
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Subscribe to a native event for js side distribution by appName
|
|
133
|
+
* React Native events are hard set at compile - cant do dynamic event names
|
|
134
|
+
* so we use a single event send it to js and js then internally can prefix it
|
|
135
|
+
* and distribute dynamically.
|
|
136
|
+
*
|
|
137
|
+
* @param eventName
|
|
138
|
+
* @private
|
|
139
|
+
*/
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
function subscribeToNativeModuleEvent(eventName) {
|
|
143
|
+
if (!NATIVE_MODULE_EVENT_SUBSCRIPTIONS[eventName]) {
|
|
144
|
+
GoogleMobileAdsNativeEventEmitter.addListener(eventName, event => {
|
|
145
|
+
if (event.appName) {
|
|
146
|
+
// native event has an appName property - auto prefix and internally emit
|
|
147
|
+
SharedEventEmitter.emit(`${event.appName}-${eventName}`, event);
|
|
148
|
+
} else {
|
|
149
|
+
// standard event - no need to prefix
|
|
150
|
+
SharedEventEmitter.emit(eventName, event);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
NATIVE_MODULE_EVENT_SUBSCRIPTIONS[eventName] = true;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Help text for integrating the native counter parts for each module.
|
|
158
|
+
*
|
|
159
|
+
* @param namespace
|
|
160
|
+
* @returns {string}
|
|
161
|
+
*/
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
function getMissingModuleHelpText(namespace) {
|
|
165
|
+
const snippet = `${namespace}()`;
|
|
166
|
+
const nativeModule = namespace.charAt(0).toUpperCase() + namespace.slice(1);
|
|
167
|
+
|
|
168
|
+
if (Platform.OS === 'ios') {
|
|
169
|
+
return `You attempted to use a module that's not installed natively on your iOS project by calling ${snippet}.` + '\r\n\r\nEnsure you have either linked the module or added it to your projects Podfile.' + '\r\n\r\nSee http://invertase.link/ios for full setup instructions.';
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const rnPackage = `'io.invertase.${namespace}.ReactNative${nativeModule}Package'`;
|
|
173
|
+
const newInstance = `'new ReactNative${nativeModule}Package()'`;
|
|
174
|
+
return `You attempted to use a module that's not installed on your Android project by calling ${snippet}.` + `\r\n\r\nEnsure you have:\r\n\r\n1) imported the ${rnPackage} module in your 'MainApplication.java' file.\r\n\r\n2) Added the ` + `${newInstance} line inside of the RN 'getPackages()' method list.` + '\r\n\r\nSee http://invertase.link/android for full setup instructions.';
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Gets a wrapped native module instance for the provided module.
|
|
178
|
+
* Will attempt to create a new instance if non previously created.
|
|
179
|
+
*
|
|
180
|
+
* @param module
|
|
181
|
+
* @returns {*}
|
|
182
|
+
*/
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
export function getNativeModule(module) {
|
|
186
|
+
const key = nativeModuleKey(module);
|
|
187
|
+
|
|
188
|
+
if (NATIVE_MODULE_REGISTRY[key]) {
|
|
189
|
+
return NATIVE_MODULE_REGISTRY[key];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return initialiseNativeModule(module);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Custom wrapped app module as it does not have it's own FirebaseModule based class.
|
|
196
|
+
*
|
|
197
|
+
* @returns {*}
|
|
198
|
+
*/
|
|
199
|
+
|
|
200
|
+
export function getAppModule() {
|
|
201
|
+
if (NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE]) {
|
|
202
|
+
return NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const namespace = 'app';
|
|
206
|
+
const nativeModule = NativeModules[APP_NATIVE_MODULE];
|
|
207
|
+
|
|
208
|
+
if (!nativeModule) {
|
|
209
|
+
throw new Error(getMissingModuleHelpText(namespace));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE] = nativeModuleWrapped(namespace, nativeModule, []);
|
|
213
|
+
return NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE];
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=nativeModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["nativeModule.ts"],"names":["NativeModules","Platform","APP_NATIVE_MODULE","NativeError","GoogleMobileAdsNativeEventEmitter","SharedEventEmitter","isFunction","NATIVE_MODULE_REGISTRY","NATIVE_MODULE_EVENT_SUBSCRIPTIONS","nativeModuleKey","module","_customUrlOrRegion","app","name","_config","namespace","nativeModuleMethodWrapped","method","argToPrepend","args","possiblePromise","then","jsStack","Error","stack","catch","nativeError","Promise","reject","nativeModuleWrapped","NativeModule","native","properties","Object","keys","i","len","length","property","initialiseNativeModule","config","key","nativeEvents","nativeModuleName","multiModuleRoot","multiModule","Array","isArray","nativeModuleNames","nativeModule","getMissingModuleHelpText","assign","subscribeToNativeModuleEvent","freeze","eventName","addListener","event","appName","emit","snippet","charAt","toUpperCase","slice","OS","rnPackage","newInstance","getNativeModule","getAppModule"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,aAAT,EAAwBC,QAAxB,QAAwC,cAAxC;AACA,SAASC,iBAAT,QAAkC,cAAlC;AACA,SAASC,WAAT,QAA4B,gBAA5B;AACA,SAASC,iCAAT,QAAkD,sCAAlD;AACA,SAASC,kBAAT,QAAmC,uBAAnC;AACA,SAASC,UAAT,QAA2B,cAA3B;AAGA,MAAMC,sBAA+C,GAAG,EAAxD;AACA,MAAMC,iCAA0D,GAAG,EAAnE;;AAEA,SAASC,eAAT,CAAyBC,MAAzB,EAAkD;AAChD,SAAQ,GAAEA,MAAM,CAACC,kBAAP,IAA6B,EAAG,IAAGD,MAAM,CAACE,GAAP,CAAWC,IAAK,IAAGH,MAAM,CAACI,OAAP,CAAeC,SAAU,EAAzF;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,yBAAT,CACED,SADF,EAEEE,MAFF,EAGEC,YAHF,EAIE;AACA,SAAO,YAAiB;AAAA,sCAAbC,IAAa;AAAbA,MAAAA,IAAa;AAAA;;AACtB,UAAMC,eAAe,GAAGH,MAAM,CAAC,GAAG,CAAC,GAAGC,YAAJ,EAAkB,GAAGC,IAArB,CAAJ,CAA9B;;AAEA,QAAIC,eAAe,IAAIA,eAAe,CAACC,IAAvC,EAA6C;AAC3C,YAAMC,OAAO,GAAG,IAAIC,KAAJ,GAAYC,KAAZ,IAAqB,EAArC;AACA,aAAOJ,eAAe,CAACK,KAAhB,CAAsBC,WAAW,IACtCC,OAAO,CAACC,MAAR,CAAe,IAAIzB,WAAJ,CAAgBuB,WAAhB,EAA6BJ,OAA7B,EAAsCP,SAAtC,CAAf,CADK,CAAP;AAGD;;AAED,WAAOK,eAAP;AACD,GAXD;AAYD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASS,mBAAT,CACEd,SADF,EAEEe,YAFF,EAGEZ,YAHF,EAIE;AACA,QAAMa,MAA+B,GAAG,EAAxC;;AACA,MAAI,CAACD,YAAL,EAAmB;AACjB,WAAOA,YAAP;AACD;;AAED,QAAME,UAAU,GAAGC,MAAM,CAACC,IAAP,CAAYJ,YAAZ,CAAnB;;AAEA,OAAK,IAAIK,CAAC,GAAG,CAAR,EAAWC,GAAG,GAAGJ,UAAU,CAACK,MAAjC,EAAyCF,CAAC,GAAGC,GAA7C,EAAkDD,CAAC,EAAnD,EAAuD;AACrD,UAAMG,QAAQ,GAAGN,UAAU,CAACG,CAAD,CAA3B;;AACA,QAAI7B,UAAU,CAACwB,YAAY,CAACQ,QAAD,CAAb,CAAd,EAAwC;AACtCP,MAAAA,MAAM,CAACO,QAAD,CAAN,GAAmBtB,yBAAyB,CAACD,SAAD,EAAYe,YAAY,CAACQ,QAAD,CAAxB,EAAoCpB,YAApC,CAA5C;AACD,KAFD,MAEO;AACLa,MAAAA,MAAM,CAACO,QAAD,CAAN,GAAmBR,YAAY,CAACQ,QAAD,CAA/B;AACD;AACF;;AAED,SAAOP,MAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASQ,sBAAT,CAAgC7B,MAAhC,EAAyD;AACvD,QAAM8B,MAAM,GAAG9B,MAAM,CAACI,OAAtB;AACA,QAAM2B,GAAG,GAAGhC,eAAe,CAACC,MAAD,CAA3B;AACA,QAAM;AAAEK,IAAAA,SAAF;AAAa2B,IAAAA,YAAb;AAA2BC,IAAAA;AAA3B,MAAgDH,MAAtD;AACA,QAAMI,eAAwC,GAAG,EAAjD;AACA,QAAMC,WAAW,GAAGC,KAAK,CAACC,OAAN,CAAcJ,gBAAd,CAApB;AACA,QAAMK,iBAAiB,GAAGH,WAAW,GAAGF,gBAAH,GAAsB,CAACA,gBAAD,CAA3D;;AAEA,OAAK,IAAIR,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGa,iBAAiB,CAACX,MAAtC,EAA8CF,CAAC,EAA/C,EAAmD;AACjD,UAAMc,YAAY,GAAGjD,aAAa,CAACgD,iBAAiB,CAACb,CAAD,CAAlB,CAAlC,CADiD,CAGjD;AACA;;AACA,QAAI,CAACU,WAAD,IAAgB,CAACI,YAArB,EAAmC;AACjC,YAAM,IAAI1B,KAAJ,CAAU2B,wBAAwB,CAACnC,SAAD,CAAlC,CAAN;AACD;;AAED,QAAI8B,WAAJ,EAAiB;AACfD,MAAAA,eAAe,CAACI,iBAAiB,CAACb,CAAD,CAAlB,CAAf,GAAwC,CAAC,CAACc,YAA1C;AACD;;AAEDhB,IAAAA,MAAM,CAACkB,MAAP,CAAcP,eAAd,EAA+Bf,mBAAmB,CAACd,SAAD,EAAYkC,YAAZ,EAA0B,EAA1B,CAAlD;AACD;;AAED,MAAIP,YAAY,IAAIA,YAAY,CAACL,MAAjC,EAAyC;AACvC,SAAK,IAAIF,CAAC,GAAG,CAAR,EAAWC,GAAG,GAAGM,YAAY,CAACL,MAAnC,EAA2CF,CAAC,GAAGC,GAA/C,EAAoDD,CAAC,EAArD,EAAyD;AACvDiB,MAAAA,4BAA4B,CAACV,YAAY,CAACP,CAAD,CAAb,CAA5B;AACD;AACF;;AAEDF,EAAAA,MAAM,CAACoB,MAAP,CAAcT,eAAd;AAEArC,EAAAA,sBAAsB,CAACkC,GAAD,CAAtB,GAA8BG,eAA9B;AAEA,SAAOrC,sBAAsB,CAACkC,GAAD,CAA7B;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASW,4BAAT,CAAsCE,SAAtC,EAAyD;AACvD,MAAI,CAAC9C,iCAAiC,CAAC8C,SAAD,CAAtC,EAAmD;AACjDlD,IAAAA,iCAAiC,CAACmD,WAAlC,CAA8CD,SAA9C,EAAyDE,KAAK,IAAI;AAChE,UAAIA,KAAK,CAACC,OAAV,EAAmB;AACjB;AACApD,QAAAA,kBAAkB,CAACqD,IAAnB,CAAyB,GAAEF,KAAK,CAACC,OAAQ,IAAGH,SAAU,EAAtD,EAAyDE,KAAzD;AACD,OAHD,MAGO;AACL;AACAnD,QAAAA,kBAAkB,CAACqD,IAAnB,CAAwBJ,SAAxB,EAAmCE,KAAnC;AACD;AACF,KARD;AAUAhD,IAAAA,iCAAiC,CAAC8C,SAAD,CAAjC,GAA+C,IAA/C;AACD;AACF;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASJ,wBAAT,CAAkCnC,SAAlC,EAAqD;AACnD,QAAM4C,OAAO,GAAI,GAAE5C,SAAU,IAA7B;AACA,QAAMkC,YAAY,GAAGlC,SAAS,CAAC6C,MAAV,CAAiB,CAAjB,EAAoBC,WAApB,KAAoC9C,SAAS,CAAC+C,KAAV,CAAgB,CAAhB,CAAzD;;AAEA,MAAI7D,QAAQ,CAAC8D,EAAT,KAAgB,KAApB,EAA2B;AACzB,WACG,8FAA6FJ,OAAQ,GAAtG,GACA,wFADA,GAEA,oEAHF;AAKD;;AAED,QAAMK,SAAS,GAAI,iBAAgBjD,SAAU,eAAckC,YAAa,UAAxE;AACA,QAAMgB,WAAW,GAAI,mBAAkBhB,YAAa,YAApD;AAEA,SACG,yFAAwFU,OAAQ,GAAjG,GACC,mDAAkDK,SAAU,mEAD7D,GAEC,GAAEC,WAAY,qDAFf,GAGA,wEAJF;AAMD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASC,eAAT,CAAyBxD,MAAzB,EAAkD;AACvD,QAAM+B,GAAG,GAAGhC,eAAe,CAACC,MAAD,CAA3B;;AAEA,MAAIH,sBAAsB,CAACkC,GAAD,CAA1B,EAAiC;AAC/B,WAAOlC,sBAAsB,CAACkC,GAAD,CAA7B;AACD;;AAED,SAAOF,sBAAsB,CAAC7B,MAAD,CAA7B;AACD;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASyD,YAAT,GAAwB;AAC7B,MAAI5D,sBAAsB,CAACL,iBAAD,CAA1B,EAA+C;AAC7C,WAAOK,sBAAsB,CAACL,iBAAD,CAA7B;AACD;;AAED,QAAMa,SAAS,GAAG,KAAlB;AACA,QAAMkC,YAAY,GAAGjD,aAAa,CAACE,iBAAD,CAAlC;;AAEA,MAAI,CAAC+C,YAAL,EAAmB;AACjB,UAAM,IAAI1B,KAAJ,CAAU2B,wBAAwB,CAACnC,SAAD,CAAlC,CAAN;AACD;;AAEDR,EAAAA,sBAAsB,CAACL,iBAAD,CAAtB,GAA4C2B,mBAAmB,CAACd,SAAD,EAAYkC,YAAZ,EAA0B,EAA1B,CAA/D;AAEA,SAAO1C,sBAAsB,CAACL,iBAAD,CAA7B;AACD","sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport { NativeModules, Platform } from 'react-native';\nimport { APP_NATIVE_MODULE } from '../constants';\nimport { NativeError } from '../NativeError';\nimport { GoogleMobileAdsNativeEventEmitter } from '../GoogleMobileAdsNativeEventEmitter';\nimport { SharedEventEmitter } from '../SharedEventEmitter';\nimport { isFunction } from '../../common';\nimport { ModuleInterface } from '../../types/Module.interface';\n\nconst NATIVE_MODULE_REGISTRY: Record<string, unknown> = {};\nconst NATIVE_MODULE_EVENT_SUBSCRIPTIONS: Record<string, unknown> = {};\n\nfunction nativeModuleKey(module: ModuleInterface) {\n return `${module._customUrlOrRegion || ''}:${module.app.name}:${module._config.namespace}`;\n}\n\n/**\n * Wraps a native module method to provide\n * auto prepended args and custom Error classes.\n *\n * @param namespace\n * @param method\n * @param argToPrepend\n * @returns {Function}\n */\nfunction nativeModuleMethodWrapped(\n namespace: string,\n method: (...args: unknown[]) => Promise<unknown> | void,\n argToPrepend: [],\n) {\n return (...args: []) => {\n const possiblePromise = method(...[...argToPrepend, ...args]);\n\n if (possiblePromise && possiblePromise.then) {\n const jsStack = new Error().stack || '';\n return possiblePromise.catch(nativeError =>\n Promise.reject(new NativeError(nativeError, jsStack, namespace)),\n );\n }\n\n return possiblePromise;\n };\n}\n\n/**\n * Prepends all arguments in prependArgs to all native method calls\n *\n * @param namespace\n * @param NativeModule\n * @param argToPrepend\n */\nfunction nativeModuleWrapped(\n namespace: string,\n NativeModule: Record<string, (...args: unknown[]) => Promise<unknown> | void>,\n argToPrepend: [],\n) {\n const native: Record<string, unknown> = {};\n if (!NativeModule) {\n return NativeModule;\n }\n\n const properties = Object.keys(NativeModule);\n\n for (let i = 0, len = properties.length; i < len; i++) {\n const property = properties[i];\n if (isFunction(NativeModule[property])) {\n native[property] = nativeModuleMethodWrapped(namespace, NativeModule[property], argToPrepend);\n } else {\n native[property] = NativeModule[property];\n }\n }\n\n return native;\n}\n\n/**\n * Initialises and wraps all the native module methods.\n *\n * @param module\n * @returns {*}\n */\nfunction initialiseNativeModule(module: ModuleInterface) {\n const config = module._config;\n const key = nativeModuleKey(module);\n const { namespace, nativeEvents, nativeModuleName } = config;\n const multiModuleRoot: Record<string, unknown> = {};\n const multiModule = Array.isArray(nativeModuleName);\n const nativeModuleNames = multiModule ? nativeModuleName : [nativeModuleName];\n\n for (let i = 0; i < nativeModuleNames.length; i++) {\n const nativeModule = NativeModules[nativeModuleNames[i]];\n\n // only error if there's a single native module\n // as multi modules can mean some are optional\n if (!multiModule && !nativeModule) {\n throw new Error(getMissingModuleHelpText(namespace));\n }\n\n if (multiModule) {\n multiModuleRoot[nativeModuleNames[i]] = !!nativeModule;\n }\n\n Object.assign(multiModuleRoot, nativeModuleWrapped(namespace, nativeModule, []));\n }\n\n if (nativeEvents && nativeEvents.length) {\n for (let i = 0, len = nativeEvents.length; i < len; i++) {\n subscribeToNativeModuleEvent(nativeEvents[i]);\n }\n }\n\n Object.freeze(multiModuleRoot);\n\n NATIVE_MODULE_REGISTRY[key] = multiModuleRoot;\n\n return NATIVE_MODULE_REGISTRY[key];\n}\n\n/**\n * Subscribe to a native event for js side distribution by appName\n * React Native events are hard set at compile - cant do dynamic event names\n * so we use a single event send it to js and js then internally can prefix it\n * and distribute dynamically.\n *\n * @param eventName\n * @private\n */\nfunction subscribeToNativeModuleEvent(eventName: string) {\n if (!NATIVE_MODULE_EVENT_SUBSCRIPTIONS[eventName]) {\n GoogleMobileAdsNativeEventEmitter.addListener(eventName, event => {\n if (event.appName) {\n // native event has an appName property - auto prefix and internally emit\n SharedEventEmitter.emit(`${event.appName}-${eventName}`, event);\n } else {\n // standard event - no need to prefix\n SharedEventEmitter.emit(eventName, event);\n }\n });\n\n NATIVE_MODULE_EVENT_SUBSCRIPTIONS[eventName] = true;\n }\n}\n\n/**\n * Help text for integrating the native counter parts for each module.\n *\n * @param namespace\n * @returns {string}\n */\nfunction getMissingModuleHelpText(namespace: string) {\n const snippet = `${namespace}()`;\n const nativeModule = namespace.charAt(0).toUpperCase() + namespace.slice(1);\n\n if (Platform.OS === 'ios') {\n return (\n `You attempted to use a module that's not installed natively on your iOS project by calling ${snippet}.` +\n '\\r\\n\\r\\nEnsure you have either linked the module or added it to your projects Podfile.' +\n '\\r\\n\\r\\nSee http://invertase.link/ios for full setup instructions.'\n );\n }\n\n const rnPackage = `'io.invertase.${namespace}.ReactNative${nativeModule}Package'`;\n const newInstance = `'new ReactNative${nativeModule}Package()'`;\n\n return (\n `You attempted to use a module that's not installed on your Android project by calling ${snippet}.` +\n `\\r\\n\\r\\nEnsure you have:\\r\\n\\r\\n1) imported the ${rnPackage} module in your 'MainApplication.java' file.\\r\\n\\r\\n2) Added the ` +\n `${newInstance} line inside of the RN 'getPackages()' method list.` +\n '\\r\\n\\r\\nSee http://invertase.link/android for full setup instructions.'\n );\n}\n\n/**\n * Gets a wrapped native module instance for the provided module.\n * Will attempt to create a new instance if non previously created.\n *\n * @param module\n * @returns {*}\n */\nexport function getNativeModule(module: ModuleInterface) {\n const key = nativeModuleKey(module);\n\n if (NATIVE_MODULE_REGISTRY[key]) {\n return NATIVE_MODULE_REGISTRY[key];\n }\n\n return initialiseNativeModule(module);\n}\n\n/**\n * Custom wrapped app module as it does not have it's own FirebaseModule based class.\n *\n * @returns {*}\n */\nexport function getAppModule() {\n if (NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE]) {\n return NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE];\n }\n\n const namespace = 'app';\n const nativeModule = NativeModules[APP_NATIVE_MODULE];\n\n if (!nativeModule) {\n throw new Error(getMissingModuleHelpText(namespace));\n }\n\n NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE] = nativeModuleWrapped(namespace, nativeModule, []);\n\n return NATIVE_MODULE_REGISTRY[APP_NATIVE_MODULE];\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export let InitializationState;
|
|
2
|
+
/**
|
|
3
|
+
* An immutable snapshot of a mediation adapter's initialization status.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
(function (InitializationState) {
|
|
7
|
+
InitializationState[InitializationState["AdapterInitializationStateNotReady"] = 0] = "AdapterInitializationStateNotReady";
|
|
8
|
+
InitializationState[InitializationState["AdapterInitializationStateReady"] = 1] = "AdapterInitializationStateReady";
|
|
9
|
+
})(InitializationState || (InitializationState = {}));
|
|
10
|
+
//# sourceMappingURL=AdapterStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["AdapterStatus.ts"],"names":["InitializationState"],"mappings":"AAAA,WAAYA,mBAAZ;AAYA;AACA;AACA;;WAdYA,mB;AAAAA,EAAAA,mB,CAAAA,mB;AAAAA,EAAAA,mB,CAAAA,mB;GAAAA,mB,KAAAA,mB","sourcesContent":["export enum InitializationState {\n /**\n * The mediation adapter is less likely to fill ad requests.\n */\n AdapterInitializationStateNotReady = 0,\n\n /**\n * The mediation adapter is ready to service ad requests.\n */\n AdapterInitializationStateReady = 1,\n}\n\n/**\n * An immutable snapshot of a mediation adapter's initialization status.\n */\nexport type AdapterStatus = {\n name: string;\n description: string;\n status: InitializationState;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|