react-native-google-mobile-ads 5.1.0 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/RNGoogleMobileAds.podspec +1 -1
  2. package/__tests__/interstitial.test.ts +32 -5
  3. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsAppOpenModule.java +2 -1
  4. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsBannerAdViewManager.java +110 -68
  5. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsCommon.java +5 -11
  6. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsEvent.java +1 -0
  7. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsInterstitialModule.java +38 -20
  8. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsModule.java +45 -0
  9. package/docs/ad-inspector.mdx +39 -0
  10. package/docs/displaying-ads.mdx +46 -25
  11. package/docs/migrating-to-v6.mdx +111 -0
  12. package/docs.json +3 -1
  13. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.m +1 -0
  14. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerViewManager.m +63 -8
  15. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.h +3 -0
  16. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m +8 -7
  17. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.h +2 -1
  18. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.m +17 -2
  19. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.m +44 -30
  20. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsModule.m +19 -0
  21. package/lib/commonjs/AdEventType.js.map +1 -1
  22. package/lib/commonjs/GAMAdEventType.js +30 -0
  23. package/lib/commonjs/GAMAdEventType.js.map +1 -0
  24. package/lib/commonjs/MobileAds.js +4 -0
  25. package/lib/commonjs/MobileAds.js.map +1 -1
  26. package/lib/commonjs/RewardedAdEventType.js.map +1 -1
  27. package/lib/commonjs/TestIds.js +5 -0
  28. package/lib/commonjs/TestIds.js.map +1 -1
  29. package/lib/commonjs/ads/AppOpenAd.js +8 -53
  30. package/lib/commonjs/ads/AppOpenAd.js.map +1 -1
  31. package/lib/commonjs/ads/BannerAd.js +7 -110
  32. package/lib/commonjs/ads/BannerAd.js.map +1 -1
  33. package/lib/commonjs/ads/BaseAd.js +144 -0
  34. package/lib/commonjs/ads/BaseAd.js.map +1 -0
  35. package/lib/commonjs/ads/GAMBannerAd.js +42 -0
  36. package/lib/commonjs/ads/GAMBannerAd.js.map +1 -0
  37. package/lib/commonjs/ads/GAMInterstitialAd.js +48 -0
  38. package/lib/commonjs/ads/GAMInterstitialAd.js.map +1 -0
  39. package/lib/commonjs/ads/InterstitialAd.js +13 -64
  40. package/lib/commonjs/ads/InterstitialAd.js.map +1 -1
  41. package/lib/commonjs/ads/MobileAd.js +119 -12
  42. package/lib/commonjs/ads/MobileAd.js.map +1 -1
  43. package/lib/commonjs/ads/RewardedAd.js +23 -65
  44. package/lib/commonjs/ads/RewardedAd.js.map +1 -1
  45. package/lib/commonjs/hooks/useAppOpenAd.js.map +1 -1
  46. package/lib/commonjs/hooks/useFullScreenAd.js +9 -4
  47. package/lib/commonjs/hooks/useFullScreenAd.js.map +1 -1
  48. package/lib/commonjs/hooks/useInterstitialAd.js.map +1 -1
  49. package/lib/commonjs/index.js +62 -0
  50. package/lib/commonjs/index.js.map +1 -1
  51. package/lib/commonjs/types/AdEventsListener.js +6 -0
  52. package/lib/commonjs/types/AdEventsListener.js.map +1 -0
  53. package/lib/commonjs/types/AppEvent.js +2 -0
  54. package/lib/commonjs/types/AppEvent.js.map +1 -0
  55. package/lib/commonjs/types/index.js +149 -0
  56. package/lib/commonjs/types/index.js.map +1 -0
  57. package/lib/commonjs/validateAdRequestOptions.js +0 -38
  58. package/lib/commonjs/validateAdRequestOptions.js.map +1 -1
  59. package/lib/commonjs/version.js +2 -2
  60. package/lib/commonjs/version.js.map +1 -1
  61. package/lib/module/AdEventType.js.map +1 -1
  62. package/lib/module/GAMAdEventType.js +22 -0
  63. package/lib/module/GAMAdEventType.js.map +1 -0
  64. package/lib/module/MobileAds.js +4 -0
  65. package/lib/module/MobileAds.js.map +1 -1
  66. package/lib/module/RewardedAdEventType.js.map +1 -1
  67. package/lib/module/TestIds.js +5 -0
  68. package/lib/module/TestIds.js.map +1 -1
  69. package/lib/module/ads/AppOpenAd.js +10 -37
  70. package/lib/module/ads/AppOpenAd.js.map +1 -1
  71. package/lib/module/ads/BannerAd.js +7 -85
  72. package/lib/module/ads/BannerAd.js.map +1 -1
  73. package/lib/module/ads/BaseAd.js +124 -0
  74. package/lib/module/ads/BaseAd.js.map +1 -0
  75. package/lib/module/ads/GAMBannerAd.js +42 -0
  76. package/lib/module/ads/GAMBannerAd.js.map +1 -0
  77. package/lib/module/ads/GAMInterstitialAd.js +38 -0
  78. package/lib/module/ads/GAMInterstitialAd.js.map +1 -0
  79. package/lib/module/ads/InterstitialAd.js +15 -48
  80. package/lib/module/ads/InterstitialAd.js.map +1 -1
  81. package/lib/module/ads/MobileAd.js +116 -12
  82. package/lib/module/ads/MobileAd.js.map +1 -1
  83. package/lib/module/ads/RewardedAd.js +24 -49
  84. package/lib/module/ads/RewardedAd.js.map +1 -1
  85. package/lib/module/hooks/useAppOpenAd.js.map +1 -1
  86. package/lib/module/hooks/useFullScreenAd.js +9 -4
  87. package/lib/module/hooks/useFullScreenAd.js.map +1 -1
  88. package/lib/module/hooks/useInterstitialAd.js.map +1 -1
  89. package/lib/module/index.js +4 -0
  90. package/lib/module/index.js.map +1 -1
  91. package/lib/module/types/AdEventsListener.js +2 -0
  92. package/lib/module/types/AdEventsListener.js.map +1 -0
  93. package/lib/module/types/AppEvent.js +2 -0
  94. package/lib/module/types/AppEvent.js.map +1 -0
  95. package/lib/module/types/index.js +28 -0
  96. package/lib/module/types/index.js.map +1 -0
  97. package/lib/module/validateAdRequestOptions.js +1 -39
  98. package/lib/module/validateAdRequestOptions.js.map +1 -1
  99. package/lib/module/version.js +2 -2
  100. package/lib/module/version.js.map +1 -1
  101. package/lib/typescript/AdEventType.d.ts +4 -8
  102. package/lib/typescript/GAMAdEventType.d.ts +20 -0
  103. package/lib/typescript/MobileAds.d.ts +2 -1
  104. package/lib/typescript/RewardedAdEventType.d.ts +7 -11
  105. package/lib/typescript/TestIds.d.ts +5 -0
  106. package/lib/typescript/ads/AppOpenAd.d.ts +6 -6
  107. package/lib/typescript/ads/BannerAd.d.ts +1 -1
  108. package/lib/typescript/ads/BaseAd.d.ts +35 -0
  109. package/lib/typescript/ads/GAMBannerAd.d.ts +7 -0
  110. package/lib/typescript/ads/GAMInterstitialAd.d.ts +33 -0
  111. package/lib/typescript/ads/InterstitialAd.d.ts +10 -16
  112. package/lib/typescript/ads/MobileAd.d.ts +34 -16
  113. package/lib/typescript/ads/RewardedAd.d.ts +17 -19
  114. package/lib/typescript/hooks/useAppOpenAd.d.ts +1 -1
  115. package/lib/typescript/hooks/useInterstitialAd.d.ts +1 -1
  116. package/lib/typescript/index.d.ts +5 -1
  117. package/lib/typescript/types/AdEventListener.d.ts +5 -9
  118. package/lib/typescript/types/AdEventsListener.d.ts +8 -0
  119. package/lib/typescript/types/AppEvent.d.ts +13 -0
  120. package/lib/typescript/types/BannerAdProps.d.ts +81 -4
  121. package/lib/typescript/types/GoogleMobileAdsNativeModule.d.ts +3 -2
  122. package/lib/typescript/types/MobileAd.interface.d.ts +37 -12
  123. package/lib/typescript/types/MobileAdsModule.interface.d.ts +9 -0
  124. package/lib/typescript/types/RequestOptions.d.ts +0 -22
  125. package/lib/typescript/types/index.d.ts +11 -0
  126. package/lib/typescript/version.d.ts +1 -1
  127. package/package.json +50 -49
  128. package/src/AdEventType.ts +4 -8
  129. package/src/GAMAdEventType.ts +37 -0
  130. package/src/MobileAds.ts +4 -0
  131. package/src/RewardedAdEventType.ts +7 -11
  132. package/src/TestIds.ts +5 -0
  133. package/src/ads/AppOpenAd.ts +11 -41
  134. package/src/ads/BannerAd.tsx +4 -106
  135. package/src/ads/BaseAd.tsx +156 -0
  136. package/src/ads/GAMBannerAd.tsx +37 -0
  137. package/src/ads/GAMInterstitialAd.ts +45 -0
  138. package/src/ads/InterstitialAd.ts +15 -56
  139. package/src/ads/MobileAd.ts +142 -29
  140. package/src/ads/RewardedAd.ts +29 -55
  141. package/src/hooks/useAppOpenAd.ts +1 -1
  142. package/src/hooks/useFullScreenAd.ts +5 -4
  143. package/src/hooks/useInterstitialAd.ts +1 -1
  144. package/src/index.ts +4 -0
  145. package/src/types/AdEventListener.ts +31 -13
  146. package/src/types/AdEventsListener.ts +24 -0
  147. package/src/types/AppEvent.ts +14 -0
  148. package/src/types/BannerAdProps.ts +81 -4
  149. package/src/types/GoogleMobileAdsNativeModule.ts +3 -2
  150. package/src/types/MobileAd.interface.ts +56 -12
  151. package/src/types/MobileAdsModule.interface.ts +10 -0
  152. package/src/types/RequestOptions.ts +0 -24
  153. package/src/types/index.ts +28 -0
  154. package/src/validateAdRequestOptions.ts +0 -45
  155. package/src/version.ts +2 -2
@@ -46,6 +46,10 @@ class MobileAdsModule extends _internal.Module {
46
46
  return this.native.setRequestConfiguration(config);
47
47
  }
48
48
 
49
+ openAdInspector() {
50
+ return this.native.openAdInspector();
51
+ }
52
+
49
53
  }
50
54
 
51
55
  const MobileAdsInstance = new MobileAdsModule({
@@ -1 +1 @@
1
- {"version":3,"sources":["MobileAds.ts"],"names":["namespace","nativeModuleName","MobileAdsModule","Module","constructor","app","config","emitter","addListener","event","emit","adUnitId","requestId","initialize","native","setRequestConfiguration","requestConfiguration","e","Error","message","MobileAdsInstance","name","version","nativeEvents","MobileAds"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAKA,MAAMA,SAAS,GAAG,mBAAlB;AAEA,MAAMC,gBAAgB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AMc,iBAAiB,GAAG,IAAIlB,eAAJ,CACxB;AAAEmB,EAAAA,IAAI,EAAE;AAAR,CADwB,EAExB;AACEC,EAAAA,OAAO,EAAPA,gBADF;AAEEtB,EAAAA,SAFF;AAGEC,EAAAA,gBAHF;AAIEsB,EAAAA,YAAY,EAAE,CACZ,kCADY,EAEZ,sCAFY,EAGZ,kCAHY;AAJhB,CAFwB,CAA1B;;AAcO,MAAMC,SAAS,GAAG,MAAM;AAC7B,SAAOJ,iBAAP;AACD,CAFM;;;eAIQI,S","sourcesContent":["import { Module } from './internal';\nimport { validateAdRequestConfiguration } from './validateAdRequestConfiguration';\nimport { version } from './version';\nimport { MobileAdsModuleInterface } from './types/MobileAdsModule.interface';\nimport { RequestConfiguration } from './types/RequestConfiguration';\nimport { App, Config } from './types/Module.interface';\n\nconst namespace = 'google_mobile_ads';\n\nconst nativeModuleName = [\n 'RNGoogleMobileAdsModule',\n 'RNGoogleMobileAdsAppOpenModule',\n 'RNGoogleMobileAdsInterstitialModule',\n 'RNGoogleMobileAdsRewardedModule',\n];\n\ntype Event = {\n adUnitId: string;\n requestId: number;\n};\n\nclass MobileAdsModule extends Module implements MobileAdsModuleInterface {\n constructor(app: App, config: Config) {\n super(app, config);\n\n this.emitter.addListener('google_mobile_ads_app_open_event', (event: Event) => {\n this.emitter.emit(\n `google_mobile_ads_app_open_event:${event.adUnitId}:${event.requestId}`,\n event,\n );\n });\n\n this.emitter.addListener('google_mobile_ads_interstitial_event', (event: Event) => {\n this.emitter.emit(\n `google_mobile_ads_interstitial_event:${event.adUnitId}:${event.requestId}`,\n event,\n );\n });\n\n this.emitter.addListener('google_mobile_ads_rewarded_event', (event: Event) => {\n this.emitter.emit(\n `google_mobile_ads_rewarded_event:${event.adUnitId}:${event.requestId}`,\n event,\n );\n });\n }\n\n initialize() {\n return this.native.initialize();\n }\n\n setRequestConfiguration(requestConfiguration: RequestConfiguration) {\n let config;\n try {\n config = validateAdRequestConfiguration(requestConfiguration);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`googleMobileAds.setRequestConfiguration(*) ${e.message}`);\n }\n }\n\n return this.native.setRequestConfiguration(config);\n }\n}\n\nconst MobileAdsInstance = new MobileAdsModule(\n { name: 'AppName' },\n {\n version,\n namespace,\n nativeModuleName,\n nativeEvents: [\n 'google_mobile_ads_app_open_event',\n 'google_mobile_ads_interstitial_event',\n 'google_mobile_ads_rewarded_event',\n ],\n },\n);\n\nexport const MobileAds = () => {\n return MobileAdsInstance;\n};\n\nexport default MobileAds;\n"]}
1
+ {"version":3,"sources":["MobileAds.ts"],"names":["namespace","nativeModuleName","MobileAdsModule","Module","constructor","app","config","emitter","addListener","event","emit","adUnitId","requestId","initialize","native","setRequestConfiguration","requestConfiguration","e","Error","message","openAdInspector","MobileAdsInstance","name","version","nativeEvents","MobileAds"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAKA,MAAMA,SAAS,GAAG,mBAAlB;AAEA,MAAMC,gBAAgB,GAAG,CACvB,yBADuB,EAEvB,gCAFuB,EAGvB,qCAHuB,EAIvB,iCAJuB,CAAzB;;AAYA,MAAMC,eAAN,SAA8BC,gBAA9B,CAAyE;AACvEC,EAAAA,WAAW,CAACC,GAAD,EAAWC,MAAX,EAA2B;AACpC,UAAMD,GAAN,EAAWC,MAAX;AAEA,SAAKC,OAAL,CAAaC,WAAb,CAAyB,kCAAzB,EAA8DC,KAAD,IAAkB;AAC7E,WAAKF,OAAL,CAAaG,IAAb,CACG,oCAAmCD,KAAK,CAACE,QAAS,IAAGF,KAAK,CAACG,SAAU,EADxE,EAEEH,KAFF;AAID,KALD;AAOA,SAAKF,OAAL,CAAaC,WAAb,CAAyB,sCAAzB,EAAkEC,KAAD,IAAkB;AACjF,WAAKF,OAAL,CAAaG,IAAb,CACG,wCAAuCD,KAAK,CAACE,QAAS,IAAGF,KAAK,CAACG,SAAU,EAD5E,EAEEH,KAFF;AAID,KALD;AAOA,SAAKF,OAAL,CAAaC,WAAb,CAAyB,kCAAzB,EAA8DC,KAAD,IAAkB;AAC7E,WAAKF,OAAL,CAAaG,IAAb,CACG,oCAAmCD,KAAK,CAACE,QAAS,IAAGF,KAAK,CAACG,SAAU,EADxE,EAEEH,KAFF;AAID,KALD;AAMD;;AAEDI,EAAAA,UAAU,GAAG;AACX,WAAO,KAAKC,MAAL,CAAYD,UAAZ,EAAP;AACD;;AAEDE,EAAAA,uBAAuB,CAACC,oBAAD,EAA6C;AAClE,QAAIV,MAAJ;;AACA,QAAI;AACFA,MAAAA,MAAM,GAAG,oEAA+BU,oBAA/B,CAAT;AACD,KAFD,CAEE,OAAOC,CAAP,EAAU;AACV,UAAIA,CAAC,YAAYC,KAAjB,EAAwB;AACtB,cAAM,IAAIA,KAAJ,CAAW,8CAA6CD,CAAC,CAACE,OAAQ,EAAlE,CAAN;AACD;AACF;;AAED,WAAO,KAAKL,MAAL,CAAYC,uBAAZ,CAAoCT,MAApC,CAAP;AACD;;AAEDc,EAAAA,eAAe,GAAG;AAChB,WAAO,KAAKN,MAAL,CAAYM,eAAZ,EAAP;AACD;;AA7CsE;;AAgDzE,MAAMC,iBAAiB,GAAG,IAAInB,eAAJ,CACxB;AAAEoB,EAAAA,IAAI,EAAE;AAAR,CADwB,EAExB;AACEC,EAAAA,OAAO,EAAPA,gBADF;AAEEvB,EAAAA,SAFF;AAGEC,EAAAA,gBAHF;AAIEuB,EAAAA,YAAY,EAAE,CACZ,kCADY,EAEZ,sCAFY,EAGZ,kCAHY;AAJhB,CAFwB,CAA1B;;AAcO,MAAMC,SAAS,GAAG,MAAM;AAC7B,SAAOJ,iBAAP;AACD,CAFM;;;eAIQI,S","sourcesContent":["import { Module } from './internal';\nimport { validateAdRequestConfiguration } from './validateAdRequestConfiguration';\nimport { version } from './version';\nimport { MobileAdsModuleInterface } from './types/MobileAdsModule.interface';\nimport { RequestConfiguration } from './types/RequestConfiguration';\nimport { App, Config } from './types/Module.interface';\n\nconst namespace = 'google_mobile_ads';\n\nconst nativeModuleName = [\n 'RNGoogleMobileAdsModule',\n 'RNGoogleMobileAdsAppOpenModule',\n 'RNGoogleMobileAdsInterstitialModule',\n 'RNGoogleMobileAdsRewardedModule',\n];\n\ntype Event = {\n adUnitId: string;\n requestId: number;\n};\n\nclass MobileAdsModule extends Module implements MobileAdsModuleInterface {\n constructor(app: App, config: Config) {\n super(app, config);\n\n this.emitter.addListener('google_mobile_ads_app_open_event', (event: Event) => {\n this.emitter.emit(\n `google_mobile_ads_app_open_event:${event.adUnitId}:${event.requestId}`,\n event,\n );\n });\n\n this.emitter.addListener('google_mobile_ads_interstitial_event', (event: Event) => {\n this.emitter.emit(\n `google_mobile_ads_interstitial_event:${event.adUnitId}:${event.requestId}`,\n event,\n );\n });\n\n this.emitter.addListener('google_mobile_ads_rewarded_event', (event: Event) => {\n this.emitter.emit(\n `google_mobile_ads_rewarded_event:${event.adUnitId}:${event.requestId}`,\n event,\n );\n });\n }\n\n initialize() {\n return this.native.initialize();\n }\n\n setRequestConfiguration(requestConfiguration: RequestConfiguration) {\n let config;\n try {\n config = validateAdRequestConfiguration(requestConfiguration);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`googleMobileAds.setRequestConfiguration(*) ${e.message}`);\n }\n }\n\n return this.native.setRequestConfiguration(config);\n }\n\n openAdInspector() {\n return this.native.openAdInspector();\n }\n}\n\nconst MobileAdsInstance = new MobileAdsModule(\n { name: 'AppName' },\n {\n version,\n namespace,\n nativeModuleName,\n nativeEvents: [\n 'google_mobile_ads_app_open_event',\n 'google_mobile_ads_interstitial_event',\n 'google_mobile_ads_rewarded_event',\n ],\n },\n);\n\nexport const MobileAds = () => {\n return MobileAdsInstance;\n};\n\nexport default MobileAds;\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["RewardedAdEventType.ts"],"names":["RewardedAdEventType"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IAEYA,mB;;;WAAAA,mB;AAAAA,EAAAA,mB;AAAAA,EAAAA,mB;GAAAA,mB,mCAAAA,mB","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 enum RewardedAdEventType {\n /**\n * An event fired when a rewarded ad has loaded.\n *\n * This type differs from `AdEventType.LOADED` as when a rewarded ad is loaded,\n * an additional data payload is provided to the event handler containing the ad reward\n * (assuming the user earns the reward).\n *\n * The reward contains a `type` and `amount`.\n *\n * #### Example\n *\n * ```js\n * import { RewardedAdEventType } from 'react-native-google-mobile-ads';\n *\n * rewardedAd.onAdEvent((type, error, data) => {\n * if (type === RewardedAdEventType.LOADED) {\n * console.log(`Rewarded Ad loaded with ${data.amount} ${data.type} as reward`);\n * // E.g. \"Rewarded Ad loaded with 50 coins as reward\"\n * rewardedAd.show();\n * }\n * });\n * ```\n */\n LOADED = 'rewarded_loaded',\n\n /**\n * An event fired when the user earned the reward for the video. If the user does not earn a reward,\n * the `AdEventType.CLOSED` event will be fired with no rewarded event.\n *\n * The reward contains a `type` and `amount`.\n *\n * #### Example\n *\n * ```js\n * import { RewardedAdEventType } from 'react-native-google-mobile-ads';\n *\n * rewardedAd.onAdEvent((type, error, data) => {\n * if (type === RewardedAdEventType.EARNED_REWARD) {\n * console.log(`User earned ${data.amount} ${data.type}`);\n * // E.g. \"User earned 50 coins\"\n * }\n * });\n * ```\n */\n EARNED_REWARD = 'rewarded_earned_reward',\n}\n"]}
1
+ {"version":3,"sources":["RewardedAdEventType.ts"],"names":["RewardedAdEventType"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IAEYA,mB;;;WAAAA,mB;AAAAA,EAAAA,mB;AAAAA,EAAAA,mB;GAAAA,mB,mCAAAA,mB","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 enum RewardedAdEventType {\n /**\n * An event fired when a rewarded ad has loaded.\n *\n * This type differs from `AdEventType.LOADED` as when a rewarded ad is loaded,\n * an additional data payload is provided to the event handler containing the ad reward\n * (assuming the user earns the reward).\n *\n * The reward contains a `type` and `amount`.\n *\n * #### Example\n *\n * ```js\n * import { RewardedAdEventType } from 'react-native-google-mobile-ads';\n *\n * rewardedAd.addEventListener(RewardedAdEventType.LOADED, (reward) => {\n * console.log(`Rewarded Ad loaded with ${data.amount} ${data.type} as reward`);\n * // E.g. \"Rewarded Ad loaded with 50 coins as reward\"\n * rewardedAd.show();\n * });\n * ```\n */\n LOADED = 'rewarded_loaded',\n\n /**\n * An event fired when the user earned the reward for the video. If the user does not earn a reward,\n * the `AdEventType.CLOSED` event will be fired with no rewarded event.\n *\n * The reward contains a `type` and `amount`.\n *\n * #### Example\n *\n * ```js\n * import { RewardedAdEventType } from 'react-native-google-mobile-ads';\n *\n * rewardedAd.addEventListener(RewardedAdEventType.EARNED_REWARD, (reward) => {\n * console.log(`User earned ${data.amount} ${data.type}`);\n * // E.g. \"User earned 50 coins\"\n * });\n * ```\n */\n EARNED_REWARD = 'rewarded_earned_reward',\n}\n"]}
@@ -28,6 +28,11 @@ const TestIds = {
28
28
  BANNER: '',
29
29
  INTERSTITIAL: '',
30
30
  REWARDED: '',
31
+ GAM_APP_OPEN: '/6499/example/app-open',
32
+ GAM_BANNER: '/6499/example/banner',
33
+ GAM_INTERSTITIAL: '/6499/example/interstitial',
34
+ GAM_REWARDED: '/6499/example/rewarded',
35
+ GAM_NATIVE: '/6499/example/native',
31
36
  ..._reactNative.Platform.select({
32
37
  android: {
33
38
  APP_OPEN: 'ca-app-pub-3940256099942544/3419835294',
@@ -1 +1 @@
1
- {"version":3,"sources":["TestIds.ts"],"names":["TestIds","APP_OPEN","BANNER","INTERSTITIAL","REWARDED","Platform","select","android","ios"],"mappings":";;;;;;;AAiBA;;AAjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIO,MAAMA,OAAO,GAAG;AACrBC,EAAAA,QAAQ,EAAE,EADW;AAErBC,EAAAA,MAAM,EAAE,EAFa;AAGrBC,EAAAA,YAAY,EAAE,EAHO;AAIrBC,EAAAA,QAAQ,EAAE,EAJW;AAKrB,KAAGC,sBAASC,MAAT,CAAgB;AACjBC,IAAAA,OAAO,EAAE;AACPN,MAAAA,QAAQ,EAAE,wCADH;AAEPC,MAAAA,MAAM,EAAE,wCAFD;AAGPC,MAAAA,YAAY,EAAE,wCAHP;AAIPC,MAAAA,QAAQ,EAAE;AAJH,KADQ;AAOjBI,IAAAA,GAAG,EAAE;AACHP,MAAAA,QAAQ,EAAE,wCADP;AAEHC,MAAAA,MAAM,EAAE,wCAFL;AAGHC,MAAAA,YAAY,EAAE,wCAHX;AAIHC,MAAAA,QAAQ,EAAE;AAJP;AAPY,GAAhB;AALkB,CAAhB","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 { Platform } from 'react-native';\n\nexport const TestIds = {\n APP_OPEN: '',\n BANNER: '',\n INTERSTITIAL: '',\n REWARDED: '',\n ...Platform.select({\n android: {\n APP_OPEN: 'ca-app-pub-3940256099942544/3419835294',\n BANNER: 'ca-app-pub-3940256099942544/6300978111',\n INTERSTITIAL: 'ca-app-pub-3940256099942544/1033173712',\n REWARDED: 'ca-app-pub-3940256099942544/5224354917',\n },\n ios: {\n APP_OPEN: 'ca-app-pub-3940256099942544/5662855259',\n BANNER: 'ca-app-pub-3940256099942544/2934735716',\n INTERSTITIAL: 'ca-app-pub-3940256099942544/4411468910',\n REWARDED: 'ca-app-pub-3940256099942544/1712485313',\n },\n }),\n};\n"]}
1
+ {"version":3,"sources":["TestIds.ts"],"names":["TestIds","APP_OPEN","BANNER","INTERSTITIAL","REWARDED","GAM_APP_OPEN","GAM_BANNER","GAM_INTERSTITIAL","GAM_REWARDED","GAM_NATIVE","Platform","select","android","ios"],"mappings":";;;;;;;AAiBA;;AAjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIO,MAAMA,OAAO,GAAG;AACrBC,EAAAA,QAAQ,EAAE,EADW;AAErBC,EAAAA,MAAM,EAAE,EAFa;AAGrBC,EAAAA,YAAY,EAAE,EAHO;AAIrBC,EAAAA,QAAQ,EAAE,EAJW;AAKrBC,EAAAA,YAAY,EAAE,wBALO;AAMrBC,EAAAA,UAAU,EAAE,sBANS;AAOrBC,EAAAA,gBAAgB,EAAE,4BAPG;AAQrBC,EAAAA,YAAY,EAAE,wBARO;AASrBC,EAAAA,UAAU,EAAE,sBATS;AAUrB,KAAGC,sBAASC,MAAT,CAAgB;AACjBC,IAAAA,OAAO,EAAE;AACPX,MAAAA,QAAQ,EAAE,wCADH;AAEPC,MAAAA,MAAM,EAAE,wCAFD;AAGPC,MAAAA,YAAY,EAAE,wCAHP;AAIPC,MAAAA,QAAQ,EAAE;AAJH,KADQ;AAOjBS,IAAAA,GAAG,EAAE;AACHZ,MAAAA,QAAQ,EAAE,wCADP;AAEHC,MAAAA,MAAM,EAAE,wCAFL;AAGHC,MAAAA,YAAY,EAAE,wCAHX;AAIHC,MAAAA,QAAQ,EAAE;AAJP;AAPY,GAAhB;AAVkB,CAAhB","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 { Platform } from 'react-native';\n\nexport const TestIds = {\n APP_OPEN: '',\n BANNER: '',\n INTERSTITIAL: '',\n REWARDED: '',\n GAM_APP_OPEN: '/6499/example/app-open',\n GAM_BANNER: '/6499/example/banner',\n GAM_INTERSTITIAL: '/6499/example/interstitial',\n GAM_REWARDED: '/6499/example/rewarded',\n GAM_NATIVE: '/6499/example/native',\n ...Platform.select({\n android: {\n APP_OPEN: 'ca-app-pub-3940256099942544/3419835294',\n BANNER: 'ca-app-pub-3940256099942544/6300978111',\n INTERSTITIAL: 'ca-app-pub-3940256099942544/1033173712',\n REWARDED: 'ca-app-pub-3940256099942544/5224354917',\n },\n ios: {\n APP_OPEN: 'ca-app-pub-3940256099942544/5662855259',\n BANNER: 'ca-app-pub-3940256099942544/2934735716',\n INTERSTITIAL: 'ca-app-pub-3940256099942544/4411468910',\n REWARDED: 'ca-app-pub-3940256099942544/1712485313',\n },\n }),\n};\n"]}
@@ -11,27 +11,9 @@ var _MobileAds = require("../MobileAds");
11
11
 
12
12
  var _validateAdRequestOptions = require("../validateAdRequestOptions");
13
13
 
14
- var _validateAdShowOptions = require("../validateAdShowOptions");
15
-
16
14
  var _MobileAd = require("./MobileAd");
17
15
 
18
- /*
19
- * Copyright (c) 2016-present Invertase Limited & Contributors
20
- *
21
- * Licensed under the Apache License, Version 2.0 (the "License");
22
- * you may not use this library except in compliance with the License.
23
- * You may obtain a copy of the License at
24
- *
25
- * http://www.apache.org/licenses/LICENSE-2.0
26
- *
27
- * Unless required by applicable law or agreed to in writing, software
28
- * distributed under the License is distributed on an "AS IS" BASIS,
29
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30
- * See the License for the specific language governing permissions and
31
- * limitations under the License.
32
- *
33
- */
34
- let _appOpenRequest = 0;
16
+ 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; }
35
17
 
36
18
  class AppOpenAd extends _MobileAd.MobileAd {
37
19
  static createForAdRequest(adUnitId, requestOptions) {
@@ -49,48 +31,21 @@ class AppOpenAd extends _MobileAd.MobileAd {
49
31
  }
50
32
  }
51
33
 
52
- const requestId = _appOpenRequest++;
34
+ const requestId = AppOpenAd._appOpenRequest++;
53
35
  return new AppOpenAd('app_open', (0, _MobileAds.MobileAds)(), requestId, adUnitId, options);
54
36
  }
55
37
 
56
- load() {
57
- // Prevent multiple load calls
58
- if (this._loaded || this._isLoadCalled) {
59
- return;
60
- }
61
-
62
- this._isLoadCalled = true;
63
-
64
- this._googleMobileAds.native.appOpenLoad(this._requestId, this._adUnitId, this._requestOptions);
38
+ addAdEventsListener(listener) {
39
+ return this._addAdEventsListener(listener);
65
40
  }
66
41
 
67
- onAdEvent(handler) {
68
- if (!(0, _common.isFunction)(handler)) {
69
- throw new Error("AppOpenAd.onAdEvent(*) 'handler' expected a function.");
70
- }
71
-
72
- return this._setAdEventHandler(handler);
73
- }
74
-
75
- show(showOptions) {
76
- if (!this._loaded) {
77
- throw new Error('AppOpenAd.show() The requested AppOpenAd has not loaded and could not be shown.');
78
- }
79
-
80
- let options;
81
-
82
- try {
83
- options = (0, _validateAdShowOptions.validateAdShowOptions)(showOptions);
84
- } catch (e) {
85
- if (e instanceof Error) {
86
- throw new Error(`AppOpenAd.show(*) ${e.message}.`);
87
- }
88
- }
89
-
90
- return this._googleMobileAds.native.appOpenShow(this._requestId, options);
42
+ addAdEventListener(type, listener) {
43
+ return this._addAdEventListener(type, listener);
91
44
  }
92
45
 
93
46
  }
94
47
 
95
48
  exports.AppOpenAd = AppOpenAd;
49
+
50
+ _defineProperty(AppOpenAd, "_appOpenRequest", 0);
96
51
  //# sourceMappingURL=AppOpenAd.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["AppOpenAd.ts"],"names":["_appOpenRequest","AppOpenAd","MobileAd","createForAdRequest","adUnitId","requestOptions","Error","options","e","message","requestId","load","_loaded","_isLoadCalled","_googleMobileAds","native","appOpenLoad","_requestId","_adUnitId","_requestOptions","onAdEvent","handler","_setAdEventHandler","show","showOptions","appOpenShow"],"mappings":";;;;;;;AAiBA;;AACA;;AACA;;AACA;;AACA;;AArBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAYA,IAAIA,eAAe,GAAG,CAAtB;;AAEO,MAAMC,SAAN,SAAwBC,kBAAxB,CAA8D;AAC1C,SAAlBC,kBAAkB,CAACC,QAAD,EAAmBC,cAAnB,EAA+D;AACtF,QAAI,CAAC,sBAASD,QAAT,CAAL,EAAyB;AACvB,YAAM,IAAIE,KAAJ,CAAU,sEAAV,CAAN;AACD;;AAED,QAAIC,OAAO,GAAG,EAAd;;AACA,QAAI;AACFA,MAAAA,OAAO,GAAG,wDAAyBF,cAAzB,CAAV;AACD,KAFD,CAEE,OAAOG,CAAP,EAAU;AACV,UAAIA,CAAC,YAAYF,KAAjB,EAAwB;AACtB,cAAM,IAAIA,KAAJ,CAAW,sCAAqCE,CAAC,CAACC,OAAQ,GAA1D,CAAN;AACD;AACF;;AAED,UAAMC,SAAS,GAAGV,eAAe,EAAjC;AACA,WAAO,IAAIC,SAAJ,CAAc,UAAd,EAA0B,2BAA1B,EAAuCS,SAAvC,EAAkDN,QAAlD,EAA4DG,OAA5D,CAAP;AACD;;AAEDI,EAAAA,IAAI,GAAG;AACL;AACA,QAAI,KAAKC,OAAL,IAAgB,KAAKC,aAAzB,EAAwC;AACtC;AACD;;AAED,SAAKA,aAAL,GAAqB,IAArB;;AACA,SAAKC,gBAAL,CAAsBC,MAAtB,CAA6BC,WAA7B,CAAyC,KAAKC,UAA9C,EAA0D,KAAKC,SAA/D,EAA0E,KAAKC,eAA/E;AACD;;AAEDC,EAAAA,SAAS,CAACC,OAAD,EAA2B;AAClC,QAAI,CAAC,wBAAWA,OAAX,CAAL,EAA0B;AACxB,YAAM,IAAIf,KAAJ,CAAU,uDAAV,CAAN;AACD;;AAED,WAAO,KAAKgB,kBAAL,CAAwBD,OAAxB,CAAP;AACD;;AAEDE,EAAAA,IAAI,CAACC,WAAD,EAA8B;AAChC,QAAI,CAAC,KAAKZ,OAAV,EAAmB;AACjB,YAAM,IAAIN,KAAJ,CACJ,iFADI,CAAN;AAGD;;AAED,QAAIC,OAAJ;;AACA,QAAI;AACFA,MAAAA,OAAO,GAAG,kDAAsBiB,WAAtB,CAAV;AACD,KAFD,CAEE,OAAOhB,CAAP,EAAU;AACV,UAAIA,CAAC,YAAYF,KAAjB,EAAwB;AACtB,cAAM,IAAIA,KAAJ,CAAW,qBAAoBE,CAAC,CAACC,OAAQ,GAAzC,CAAN;AACD;AACF;;AAED,WAAO,KAAKK,gBAAL,CAAsBC,MAAtB,CAA6BU,WAA7B,CAAyC,KAAKR,UAA9C,EAA0DV,OAA1D,CAAP;AACD;;AAtDkE","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 { isFunction, isString } from '../common';\nimport { MobileAds } from '../MobileAds';\nimport { validateAdRequestOptions } from '../validateAdRequestOptions';\nimport { validateAdShowOptions } from '../validateAdShowOptions';\nimport { MobileAd } from './MobileAd';\nimport { AdEventListener } from '../types/AdEventListener';\nimport { AdShowOptions } from '../types/AdShowOptions';\nimport { RequestOptions } from '../types/RequestOptions';\nimport { MobileAdInterface } from '../types/MobileAd.interface';\n\nlet _appOpenRequest = 0;\n\nexport class AppOpenAd extends MobileAd implements MobileAdInterface {\n static createForAdRequest(adUnitId: string, requestOptions?: RequestOptions): AppOpenAd {\n if (!isString(adUnitId)) {\n throw new Error(\"AppOpenAd.createForAdRequest(*) 'adUnitId' expected an string value.\");\n }\n\n let options = {};\n try {\n options = validateAdRequestOptions(requestOptions);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`AppOpenAd.createForAdRequest(_, *) ${e.message}.`);\n }\n }\n\n const requestId = _appOpenRequest++;\n return new AppOpenAd('app_open', MobileAds(), requestId, adUnitId, options);\n }\n\n load() {\n // Prevent multiple load calls\n if (this._loaded || this._isLoadCalled) {\n return;\n }\n\n this._isLoadCalled = true;\n this._googleMobileAds.native.appOpenLoad(this._requestId, this._adUnitId, this._requestOptions);\n }\n\n onAdEvent(handler: AdEventListener) {\n if (!isFunction(handler)) {\n throw new Error(\"AppOpenAd.onAdEvent(*) 'handler' expected a function.\");\n }\n\n return this._setAdEventHandler(handler);\n }\n\n show(showOptions?: AdShowOptions) {\n if (!this._loaded) {\n throw new Error(\n 'AppOpenAd.show() The requested AppOpenAd has not loaded and could not be shown.',\n );\n }\n\n let options;\n try {\n options = validateAdShowOptions(showOptions);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`AppOpenAd.show(*) ${e.message}.`);\n }\n }\n\n return this._googleMobileAds.native.appOpenShow(this._requestId, options);\n }\n}\n"]}
1
+ {"version":3,"sources":["AppOpenAd.ts"],"names":["AppOpenAd","MobileAd","createForAdRequest","adUnitId","requestOptions","Error","options","e","message","requestId","_appOpenRequest","addAdEventsListener","listener","_addAdEventsListener","addAdEventListener","type","_addAdEventListener"],"mappings":";;;;;;;AAiBA;;AACA;;AACA;;AACA;;;;AAMO,MAAMA,SAAN,SAAwBC,kBAAxB,CAAiC;AAGb,SAAlBC,kBAAkB,CAACC,QAAD,EAAmBC,cAAnB,EAAoD;AAC3E,QAAI,CAAC,sBAASD,QAAT,CAAL,EAAyB;AACvB,YAAM,IAAIE,KAAJ,CAAU,sEAAV,CAAN;AACD;;AAED,QAAIC,OAAO,GAAG,EAAd;;AACA,QAAI;AACFA,MAAAA,OAAO,GAAG,wDAAyBF,cAAzB,CAAV;AACD,KAFD,CAEE,OAAOG,CAAP,EAAU;AACV,UAAIA,CAAC,YAAYF,KAAjB,EAAwB;AACtB,cAAM,IAAIA,KAAJ,CAAW,sCAAqCE,CAAC,CAACC,OAAQ,GAA1D,CAAN;AACD;AACF;;AAED,UAAMC,SAAS,GAAGT,SAAS,CAACU,eAAV,EAAlB;AACA,WAAO,IAAIV,SAAJ,CAAc,UAAd,EAA0B,2BAA1B,EAAuCS,SAAvC,EAAkDN,QAAlD,EAA4DG,OAA5D,CAAP;AACD;;AAEDK,EAAAA,mBAAmB,CAAwBC,QAAxB,EAAmE;AACpF,WAAO,KAAKC,oBAAL,CAA0BD,QAA1B,CAAP;AACD;;AAEDE,EAAAA,kBAAkB,CAAwBC,IAAxB,EAAiCH,QAAjC,EAA+D;AAC/E,WAAO,KAAKI,mBAAL,CAAyBD,IAAzB,EAA+BH,QAA/B,CAAP;AACD;;AA3BqC;;;;gBAA3BZ,S,qBACwB,C","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 { isString } from '../common';\nimport { MobileAds } from '../MobileAds';\nimport { validateAdRequestOptions } from '../validateAdRequestOptions';\nimport { MobileAd } from './MobileAd';\nimport { AdEventType } from '../AdEventType';\nimport { AdEventListener } from '../types/AdEventListener';\nimport { AdEventsListener } from '../types/AdEventsListener';\nimport { RequestOptions } from '../types/RequestOptions';\n\nexport class AppOpenAd extends MobileAd {\n protected static _appOpenRequest = 0;\n\n static createForAdRequest(adUnitId: string, requestOptions?: RequestOptions) {\n if (!isString(adUnitId)) {\n throw new Error(\"AppOpenAd.createForAdRequest(*) 'adUnitId' expected an string value.\");\n }\n\n let options = {};\n try {\n options = validateAdRequestOptions(requestOptions);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`AppOpenAd.createForAdRequest(_, *) ${e.message}.`);\n }\n }\n\n const requestId = AppOpenAd._appOpenRequest++;\n return new AppOpenAd('app_open', MobileAds(), requestId, adUnitId, options);\n }\n\n addAdEventsListener<T extends AdEventType>(listener: AdEventsListener<T>): () => void {\n return this._addAdEventsListener(listener);\n }\n\n addAdEventListener<T extends AdEventType>(type: T, listener: AdEventListener<T>) {\n return this._addAdEventListener(type, listener);\n }\n}\n"]}
@@ -5,124 +5,21 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.BannerAd = BannerAd;
7
7
 
8
- var _react = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
9
9
 
10
- var _reactNative = require("react-native");
10
+ var _BaseAd = require("./BaseAd");
11
11
 
12
- var _common = require("../common");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
14
- var _NativeError = require("../internal/NativeError");
15
-
16
- var _BannerAdSize = require("../BannerAdSize");
17
-
18
- var _validateAdRequestOptions = require("../validateAdRequestOptions");
19
-
20
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
-
22
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
-
24
- /*
25
- * Copyright (c) 2016-present Invertase Limited & Contributors
26
- *
27
- * Licensed under the Apache License, Version 2.0 (the "License");
28
- * you may not use this library except in compliance with the License.
29
- * You may obtain a copy of the License at
30
- *
31
- * http://www.apache.org/licenses/LICENSE-2.0
32
- *
33
- * Unless required by applicable law or agreed to in writing, software
34
- * distributed under the License is distributed on an "AS IS" BASIS,
35
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36
- * See the License for the specific language governing permissions and
37
- * limitations under the License.
38
- *
39
- */
40
- const initialState = [0, 0];
41
- const sizeRegex = /([0-9]+)x([0-9]+)/;
14
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
42
15
 
43
16
  function BannerAd(_ref) {
44
17
  let {
45
- unitId,
46
18
  size,
47
- requestOptions,
48
19
  ...props
49
20
  } = _ref;
50
- const [dimensions, setDimensions] = (0, _react.useState)(initialState);
51
- (0, _react.useEffect)(() => {
52
- if (!unitId) {
53
- throw new Error("BannerAd: 'unitId' expected a valid string unit ID.");
54
- }
55
- }, [unitId]);
56
- (0, _react.useEffect)(() => {
57
- if (!(size in _BannerAdSize.BannerAdSize) && !sizeRegex.test(size)) {
58
- throw new Error("BannerAd: 'size' expected a valid BannerAdSize or custom size string.");
59
- }
60
- }, [size]);
61
- (0, _react.useEffect)(() => {
62
- if (!(size in _BannerAdSize.BannerAdSize) && !sizeRegex.test(size)) {
63
- throw new Error("BannerAd: 'size' expected a valid BannerAdSize or custom size string.");
64
- }
65
- }, [size]);
66
- const parsedRequestOptions = JSON.stringify(requestOptions);
67
- (0, _react.useEffect)(() => {
68
- if (requestOptions) {
69
- try {
70
- (0, _validateAdRequestOptions.validateAdRequestOptions)(requestOptions);
71
- } catch (e) {
72
- if (e instanceof Error) {
73
- throw new Error(`BannerAd: ${e.message}`);
74
- }
75
- }
76
- }
77
- }, [parsedRequestOptions]);
78
-
79
- function onNativeEvent(_ref2) {
80
- let {
81
- nativeEvent
82
- } = _ref2;
83
- const {
84
- type
85
- } = nativeEvent;
86
-
87
- if (type !== 'onSizeChange' && (0, _common.isFunction)(props[type])) {
88
- let eventHandler;
89
-
90
- if (type === 'onAdFailedToLoad') {
91
- const eventPayload = _NativeError.NativeError.fromEvent(nativeEvent, 'googleMobileAds');
92
-
93
- if (eventHandler = props[type]) eventHandler(eventPayload);
94
- } else if (eventHandler = props[type]) eventHandler();
95
- }
96
-
97
- if ((type === 'onAdLoaded' || type === 'onSizeChange') && size !== 'FLUID') {
98
- const {
99
- width,
100
- height
101
- } = nativeEvent;
102
- if (width && height) setDimensions([width, height]);
103
- }
104
- }
105
-
106
- let style;
107
-
108
- if (size === 'FLUID') {
109
- // @ts-ignore: Property 'style' does not exist on type error
110
- style = props.style;
111
- } else {
112
- style = {
113
- width: dimensions[0],
114
- height: dimensions[1]
115
- };
116
- }
117
-
118
- return /*#__PURE__*/_react.default.createElement(GoogleMobileAdsBannerView, {
119
- size: size,
120
- style: style,
121
- unitId: unitId,
122
- request: (0, _validateAdRequestOptions.validateAdRequestOptions)(requestOptions),
123
- onNativeEvent: onNativeEvent
124
- });
21
+ return /*#__PURE__*/_react.default.createElement(_BaseAd.BaseAd, _extends({
22
+ sizes: [size]
23
+ }, props));
125
24
  }
126
-
127
- const GoogleMobileAdsBannerView = (0, _reactNative.requireNativeComponent)('RNGoogleMobileAdsBannerView');
128
25
  //# sourceMappingURL=BannerAd.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["BannerAd.tsx"],"names":["initialState","sizeRegex","BannerAd","unitId","size","requestOptions","props","dimensions","setDimensions","Error","BannerAdSize","test","parsedRequestOptions","JSON","stringify","e","message","onNativeEvent","nativeEvent","type","eventHandler","eventPayload","NativeError","fromEvent","width","height","style","GoogleMobileAdsBannerView"],"mappings":";;;;;;;AAiBA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAtBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAwBA,MAAMA,YAAY,GAAG,CAAC,CAAD,EAAI,CAAJ,CAArB;AACA,MAAMC,SAAS,GAAG,mBAAlB;;AAEO,SAASC,QAAT,OAA6E;AAAA,MAA3D;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,IAAV;AAAgBC,IAAAA,cAAhB;AAAgC,OAAGC;AAAnC,GAA2D;AAClF,QAAM,CAACC,UAAD,EAAaC,aAAb,IAA8B,qBAASR,YAAT,CAApC;AAEA,wBAAU,MAAM;AACd,QAAI,CAACG,MAAL,EAAa;AACX,YAAM,IAAIM,KAAJ,CAAU,qD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nC,OAHD,MAGO,IAAKD,YAAY,GAAGd,KAAK,CAACa,IAAD,CAAzB,EAAkCC,YAAY;AACtD;;AAED,QAAI,CAACD,IAAI,KAAK,YAAT,IAAyBA,IAAI,KAAK,cAAnC,KAAsDf,IAAI,KAAK,OAAnE,EAA4E;AAC1E,YAAM;AAAEoB,QAAAA,KAAF;AAASC,QAAAA;AAAT,UAAoBP,WAA1B;AACA,UAAIM,KAAK,IAAIC,MAAb,EAAqBjB,aAAa,CAAC,CAACgB,KAAD,EAAQC,MAAR,CAAD,CAAb;AACtB;AACF;;AAED,MAAIC,KAAJ;;AACA,MAAItB,IAAI,KAAK,OAAb,EAAsB;AACpB;AACAsB,IAAAA,KAAK,GAAGpB,KAAK,CAACoB,KAAd;AACD,GAHD,MAGO;AACLA,IAAAA,KAAK,GAAG;AACNF,MAAAA,KAAK,EAAEjB,UAAU,CAAC,CAAD,CADX;AAENkB,MAAAA,MAAM,EAAElB,UAAU,CAAC,CAAD;AAFZ,KAAR;AAID;;AAED,sBACE,6BAAC,yBAAD;AACE,IAAA,IAAI,EAAEH,IADR;AAEE,IAAA,KAAK,EAAEsB,KAFT;AAGE,IAAA,MAAM,EAAEvB,MAHV;AAIE,IAAA,OAAO,EAAE,wDAAyBE,cAAzB,CAJX;AAKE,IAAA,aAAa,EAAEY;AALjB,IADF;AASD;;AAED,MAAMU,yBASJ,GAAG,yCAAuB,6BAAvB,CATL","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 React, { useState, useEffect } from 'react';\nimport { HostComponent, requireNativeComponent } from 'react-native';\nimport { isFunction } from '../common';\nimport { NativeError } from '../internal/NativeError';\nimport { BannerAdSize } from '../BannerAdSize';\nimport { validateAdRequestOptions } from '../validateAdRequestOptions';\nimport { BannerAdProps } from '../types/BannerAdProps';\nimport { RequestOptions } from '../types/RequestOptions';\n\ntype NativeEvent =\n | {\n type: 'onAdLoaded' | 'onSizeChange';\n width: number;\n height: number;\n }\n | { type: 'onAdOpened' | 'onAdClosed' }\n | {\n type: 'onAdFailedToLoad';\n code: string;\n message: string;\n };\n\nconst initialState = [0, 0];\nconst sizeRegex = /([0-9]+)x([0-9]+)/;\n\nexport function BannerAd({ unitId, size, requestOptions, ...props }: BannerAdProps) {\n const [dimensions, setDimensions] = useState(initialState);\n\n useEffect(() => {\n if (!unitId) {\n throw new Error(\"BannerAd: 'unitId' expected a valid string unit ID.\");\n }\n }, [unitId]);\n\n useEffect(() => {\n if (!(size in BannerAdSize) && !sizeRegex.test(size)) {\n throw new Error(\"BannerAd: 'size' expected a valid BannerAdSize or custom size string.\");\n }\n }, [size]);\n\n useEffect(() => {\n if (!(size in BannerAdSize) && !sizeRegex.test(size)) {\n throw new Error(\"BannerAd: 'size' expected a valid BannerAdSize or custom size string.\");\n }\n }, [size]);\n\n const parsedRequestOptions = JSON.stringify(requestOptions);\n\n useEffect(() => {\n if (requestOptions) {\n try {\n validateAdRequestOptions(requestOptions);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`BannerAd: ${e.message}`);\n }\n }\n }\n }, [parsedRequestOptions]);\n\n function onNativeEvent({ nativeEvent }: { nativeEvent: NativeEvent }) {\n const { type } = nativeEvent;\n\n if (type !== 'onSizeChange' && isFunction(props[type])) {\n let eventHandler;\n if (type === 'onAdFailedToLoad') {\n const eventPayload = NativeError.fromEvent(nativeEvent, 'googleMobileAds');\n if ((eventHandler = props[type])) eventHandler(eventPayload);\n } else if ((eventHandler = props[type])) eventHandler();\n }\n\n if ((type === 'onAdLoaded' || type === 'onSizeChange') && size !== 'FLUID') {\n const { width, height } = nativeEvent;\n if (width && height) setDimensions([width, height]);\n }\n }\n\n let style;\n if (size === 'FLUID') {\n // @ts-ignore: Property 'style' does not exist on type error\n style = props.style;\n } else {\n style = {\n width: dimensions[0],\n height: dimensions[1],\n };\n }\n\n return (\n <GoogleMobileAdsBannerView\n size={size}\n style={style}\n unitId={unitId}\n request={validateAdRequestOptions(requestOptions)}\n onNativeEvent={onNativeEvent}\n />\n );\n}\n\nconst GoogleMobileAdsBannerView: HostComponent<{\n size: BannerAdProps['size'];\n style: {\n width: number;\n height: number;\n };\n unitId: string;\n request: RequestOptions;\n onNativeEvent: (event: { nativeEvent: NativeEvent }) => void;\n}> = requireNativeComponent('RNGoogleMobileAdsBannerView');\n"]}
1
+ {"version":3,"sources":["BannerAd.tsx"],"names":["BannerAd","size","props"],"mappings":";;;;;;;AAiBA;;AAEA;;;;;;AAEO,SAASA,QAAT,OAAqD;AAAA,MAAnC;AAAEC,IAAAA,IAAF;AAAQ,OAAGC;AAAX,GAAmC;AAC1D,sBAAO,6BAAC,cAAD;AAAQ,IAAA,KAAK,EAAE,CAACD,IAAD;AAAf,KAA2BC,KAA3B,EAAP;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 React from 'react';\nimport { BannerAdProps } from '../types/BannerAdProps';\nimport { BaseAd } from './BaseAd';\n\nexport function BannerAd({ size, ...props }: BannerAdProps) {\n return <BaseAd sizes={[size]} {...props} />;\n}\n"]}
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.BaseAd = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var _common = require("../common");
13
+
14
+ var _NativeError = require("../internal/NativeError");
15
+
16
+ var _BannerAdSize = require("../BannerAdSize");
17
+
18
+ var _validateAdRequestOptions = require("../validateAdRequestOptions");
19
+
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
+
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
+
24
+ /* eslint-disable react/prop-types */
25
+
26
+ /*
27
+ * Copyright (c) 2016-present Invertase Limited & Contributors
28
+ *
29
+ * Licensed under the Apache License, Version 2.0 (the "License");
30
+ * you may not use this library except in compliance with the License.
31
+ * You may obtain a copy of the License at
32
+ *
33
+ * http://www.apache.org/licenses/LICENSE-2.0
34
+ *
35
+ * Unless required by applicable law or agreed to in writing, software
36
+ * distributed under the License is distributed on an "AS IS" BASIS,
37
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
38
+ * See the License for the specific language governing permissions and
39
+ * limitations under the License.
40
+ *
41
+ */
42
+ const sizeRegex = /([0-9]+)x([0-9]+)/;
43
+
44
+ const BaseAd = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
45
+ let {
46
+ unitId,
47
+ sizes,
48
+ requestOptions,
49
+ manualImpressionsEnabled,
50
+ ...props
51
+ } = _ref;
52
+ const [dimensions, setDimensions] = (0, _react.useState)([0, 0]);
53
+ (0, _react.useEffect)(() => {
54
+ if (!unitId) {
55
+ throw new Error("BannerAd: 'unitId' expected a valid string unit ID.");
56
+ }
57
+ }, [unitId]);
58
+ (0, _react.useEffect)(() => {
59
+ if (sizes.length === 0 || !sizes.every(size => size in _BannerAdSize.BannerAdSize || sizeRegex.test(size))) {
60
+ throw new Error("BannerAd: 'size(s)' expected a valid BannerAdSize or custom size string.");
61
+ }
62
+ }, [sizes]);
63
+ const parsedRequestOptions = JSON.stringify(requestOptions);
64
+ (0, _react.useEffect)(() => {
65
+ if (requestOptions) {
66
+ try {
67
+ (0, _validateAdRequestOptions.validateAdRequestOptions)(requestOptions);
68
+ } catch (e) {
69
+ if (e instanceof Error) {
70
+ throw new Error(`BannerAd: ${e.message}`);
71
+ }
72
+ }
73
+ }
74
+ }, [parsedRequestOptions]);
75
+
76
+ function onNativeEvent(_ref2) {
77
+ let {
78
+ nativeEvent
79
+ } = _ref2;
80
+ const {
81
+ type
82
+ } = nativeEvent;
83
+
84
+ if (type !== 'onSizeChange' && (0, _common.isFunction)(props[type])) {
85
+ let eventHandler, eventPayload;
86
+
87
+ switch (type) {
88
+ case 'onAdLoaded':
89
+ eventPayload = {
90
+ width: nativeEvent.width,
91
+ height: nativeEvent.height
92
+ };
93
+ if (eventHandler = props[type]) eventHandler(eventPayload);
94
+ break;
95
+
96
+ case 'onAdFailedToLoad':
97
+ eventPayload = _NativeError.NativeError.fromEvent(nativeEvent, 'googleMobileAds');
98
+ if (eventHandler = props[type]) eventHandler(eventPayload);
99
+ break;
100
+
101
+ case 'onAppEvent':
102
+ eventPayload = {
103
+ name: nativeEvent.name,
104
+ data: nativeEvent.data
105
+ };
106
+ if (eventHandler = props[type]) eventHandler(eventPayload);
107
+ break;
108
+
109
+ default:
110
+ if (eventHandler = props[type]) eventHandler();
111
+ }
112
+ }
113
+
114
+ if (type === 'onAdLoaded' || type === 'onSizeChange') {
115
+ const {
116
+ width,
117
+ height
118
+ } = nativeEvent;
119
+ if (width && height) setDimensions([width, height]);
120
+ }
121
+ }
122
+
123
+ const style = sizes.includes(_BannerAdSize.BannerAdSize.FLUID) ? {
124
+ width: '100%',
125
+ height: dimensions[1]
126
+ } : {
127
+ width: dimensions[0],
128
+ height: dimensions[1]
129
+ };
130
+ return /*#__PURE__*/_react.default.createElement(GoogleMobileAdsBannerView, {
131
+ ref: ref,
132
+ sizes: sizes,
133
+ style: style,
134
+ unitId: unitId,
135
+ request: (0, _validateAdRequestOptions.validateAdRequestOptions)(requestOptions),
136
+ manualImpressionsEnabled: !!manualImpressionsEnabled,
137
+ onNativeEvent: onNativeEvent
138
+ });
139
+ });
140
+
141
+ exports.BaseAd = BaseAd;
142
+ BaseAd.displayName = 'BaseAd';
143
+ const GoogleMobileAdsBannerView = (0, _reactNative.requireNativeComponent)('RNGoogleMobileAdsBannerView');
144
+ //# sourceMappingURL=BaseAd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["BaseAd.tsx"],"names":["sizeRegex","BaseAd","React","forwardRef","ref","unitId","sizes","requestOptions","manualImpressionsEnabled","props","dimensions","setDimensions","Error","length","every","size","BannerAdSize","test","parsedRequestOptions","JSON","stringify","e","message","onNativeEvent","nativeEvent","type","eventHandler","eventPayload","width","height","NativeError","fromEvent","name","data","style","includes","FLUID","displayName","GoogleMobileAdsBannerView"],"mappings":";;;;;;;AAkBA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAvBA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA6BA,MAAMA,SAAS,GAAG,mBAAlB;;A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AAAA,KAAK,EAAElB,UAAU,CAAC,CAAD,CADnB;AAEEmB,IAAAA,MAAM,EAAEnB,UAAU,CAAC,CAAD;AAFpB,GALJ;AAUA,sBACE,6BAAC,yBAAD;AACE,IAAA,GAAG,EAAEN,GADP;AAEE,IAAA,KAAK,EAAEE,KAFT;AAGE,IAAA,KAAK,EAAE4B,KAHT;AAIE,IAAA,MAAM,EAAE7B,MAJV;AAKE,IAAA,OAAO,EAAE,wDAAyBE,cAAzB,CALX;AAME,IAAA,wBAAwB,EAAE,CAAC,CAACC,wBAN9B;AAOE,IAAA,aAAa,EAAEe;AAPjB,IADF;AAWD,CAzFmB,CAAf;;;AA2FPtB,MAAM,CAACoC,WAAP,GAAqB,QAArB;AAcA,MAAMC,yBAAyB,GAAG,yCAChC,6BADgC,CAAlC","sourcesContent":["/* eslint-disable react/prop-types */\n/*\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 React, { useState, useEffect } from 'react';\nimport { NativeMethods, requireNativeComponent } from 'react-native';\nimport { isFunction } from '../common';\nimport { NativeError } from '../internal/NativeError';\nimport { BannerAdSize } from '../BannerAdSize';\nimport { validateAdRequestOptions } from '../validateAdRequestOptions';\nimport { GAMBannerAdProps } from '../types/BannerAdProps';\nimport { RequestOptions } from '../types/RequestOptions';\n\ntype NativeEvent =\n | {\n type: 'onAdLoaded' | 'onSizeChange';\n width: number;\n height: number;\n }\n | { type: 'onAdOpened' | 'onAdClosed' }\n | {\n type: 'onAdFailedToLoad';\n code: string;\n message: string;\n }\n | {\n type: 'onAppEvent';\n name: string;\n data?: string;\n };\n\nconst sizeRegex = /([0-9]+)x([0-9]+)/;\n\nexport const BaseAd = React.forwardRef<GoogleMobileAdsBannerView, GAMBannerAdProps>(\n ({ unitId, sizes, requestOptions, manualImpressionsEnabled, ...props }, ref) => {\n const [dimensions, setDimensions] = useState<(number | string)[]>([0, 0]);\n\n useEffect(() => {\n if (!unitId) {\n throw new Error(\"BannerAd: 'unitId' expected a valid string unit ID.\");\n }\n }, [unitId]);\n\n useEffect(() => {\n if (\n sizes.length === 0 ||\n !sizes.every(size => size in BannerAdSize || sizeRegex.test(size))\n ) {\n throw new Error(\"BannerAd: 'size(s)' expected a valid BannerAdSize or custom size string.\");\n }\n }, [sizes]);\n\n const parsedRequestOptions = JSON.stringify(requestOptions);\n\n useEffect(() => {\n if (requestOptions) {\n try {\n validateAdRequestOptions(requestOptions);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`BannerAd: ${e.message}`);\n }\n }\n }\n }, [parsedRequestOptions]);\n\n function onNativeEvent({ nativeEvent }: { nativeEvent: NativeEvent }) {\n const { type } = nativeEvent;\n\n if (type !== 'onSizeChange' && isFunction(props[type])) {\n let eventHandler, eventPayload;\n switch (type) {\n case 'onAdLoaded':\n eventPayload = {\n width: nativeEvent.width,\n height: nativeEvent.height,\n };\n if ((eventHandler = props[type])) eventHandler(eventPayload);\n break;\n case 'onAdFailedToLoad':\n eventPayload = NativeError.fromEvent(nativeEvent, 'googleMobileAds');\n if ((eventHandler = props[type])) eventHandler(eventPayload);\n break;\n case 'onAppEvent':\n eventPayload = {\n name: nativeEvent.name,\n data: nativeEvent.data,\n };\n if ((eventHandler = props[type])) eventHandler(eventPayload);\n break;\n default:\n if ((eventHandler = props[type])) eventHandler();\n }\n }\n\n if (type === 'onAdLoaded' || type === 'onSizeChange') {\n const { width, height } = nativeEvent;\n if (width && height) setDimensions([width, height]);\n }\n }\n\n const style = sizes.includes(BannerAdSize.FLUID)\n ? {\n width: '100%',\n height: dimensions[1],\n }\n : {\n width: dimensions[0],\n height: dimensions[1],\n };\n\n return (\n <GoogleMobileAdsBannerView\n ref={ref}\n sizes={sizes}\n style={style}\n unitId={unitId}\n request={validateAdRequestOptions(requestOptions)}\n manualImpressionsEnabled={!!manualImpressionsEnabled}\n onNativeEvent={onNativeEvent}\n />\n );\n },\n);\nBaseAd.displayName = 'BaseAd';\n\ninterface NativeBannerProps {\n sizes: GAMBannerAdProps['sizes'];\n style: {\n width?: number | string;\n height?: number | string;\n };\n unitId: string;\n request: RequestOptions;\n manualImpressionsEnabled: boolean;\n onNativeEvent: (event: { nativeEvent: NativeEvent }) => void;\n}\n\nconst GoogleMobileAdsBannerView = requireNativeComponent<NativeBannerProps>(\n 'RNGoogleMobileAdsBannerView',\n);\nexport type GoogleMobileAdsBannerView = React.Component<NativeBannerProps> & NativeMethods;\n"]}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.GAMBannerAd = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var _BaseAd = require("./BaseAd");
13
+
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
+
16
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
+
18
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
19
+
20
+ 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; }
21
+
22
+ class GAMBannerAd extends _react.default.Component {
23
+ constructor() {
24
+ super(...arguments);
25
+
26
+ _defineProperty(this, "ref", /*#__PURE__*/(0, _react.createRef)());
27
+ }
28
+
29
+ recordManualImpression() {
30
+ _reactNative.UIManager.dispatchViewManagerCommand((0, _reactNative.findNodeHandle)(this.ref.current), 'recordManualImpression', undefined);
31
+ }
32
+
33
+ render() {
34
+ return /*#__PURE__*/_react.default.createElement(_BaseAd.BaseAd, _extends({
35
+ ref: this.ref
36
+ }, this.props));
37
+ }
38
+
39
+ }
40
+
41
+ exports.GAMBannerAd = GAMBannerAd;
42
+ //# sourceMappingURL=GAMBannerAd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["GAMBannerAd.tsx"],"names":["GAMBannerAd","React","Component","recordManualImpression","UIManager","dispatchViewManagerCommand","ref","current","undefined","render","props"],"mappings":";;;;;;;AAiBA;;AACA;;AAEA;;;;;;;;;;AAEO,MAAMA,WAAN,SAA0BC,eAAMC,SAAhC,CAA4D;AAAA;AAAA;;AAAA,8CACnD,uBADmD;AAAA;;AAGjEC,EAAAA,sBAAsB,GAAG;AACvBC,2BAAUC,0BAAV,CACE,iCAAe,KAAKC,GAAL,CAASC,OAAxB,CADF,EAEE,wBAFF,EAGEC,SAHF;AAKD;;AAEDC,EAAAA,MAAM,GAAG;AACP,wBAAO,6BAAC,cAAD;AAAQ,MAAA,GAAG,EAAE,KAAKH;AAAlB,OAA2B,KAAKI,KAAhC,EAAP;AACD;;AAbgE","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 React, { createRef } from 'react';\nimport { findNodeHandle, UIManager } from 'react-native';\nimport { GAMBannerAdProps } from '../types/BannerAdProps';\nimport { BaseAd, GoogleMobileAdsBannerView } from './BaseAd';\n\nexport class GAMBannerAd extends React.Component<GAMBannerAdProps> {\n private ref = createRef<GoogleMobileAdsBannerView>();\n\n recordManualImpression() {\n UIManager.dispatchViewManagerCommand(\n findNodeHandle(this.ref.current),\n 'recordManualImpression',\n undefined,\n );\n }\n\n render() {\n return <BaseAd ref={this.ref} {...this.props} />;\n }\n}\n"]}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.GAMInterstitialAd = void 0;
7
+
8
+ var _InterstitialAd = require("./InterstitialAd");
9
+
10
+ class GAMInterstitialAd extends _InterstitialAd.InterstitialAd {
11
+ /**
12
+ * Creates a new GAMInterstitialAd instance.
13
+ *
14
+ * #### Example
15
+ *
16
+ * ```js
17
+ * import { GAMInterstitialAd, AdEventType, TestIds } from 'react-native-google-mobile-ads';
18
+ *
19
+ * const interstitialAd = await GAMInterstitialAd.createForAdRequest(TestIds.GAM_INTERSTITIAL, {
20
+ * requestAgent: 'CoolAds',
21
+ * });
22
+ *
23
+ * interstitialAd.addAdEventListener(AdEventType.Loaded, () => {
24
+ * interstitialAd.show();
25
+ * });
26
+ *
27
+ * interstitialAd.load();
28
+ * ```
29
+ *
30
+ * @param adUnitId The Ad Unit ID for the Interstitial. You can find this on your Google Mobile Ads dashboard.
31
+ * @param requestOptions Optional RequestOptions used to load the ad.
32
+ */
33
+ static createForAdRequest(adUnitId, requestOptions) {
34
+ return super.createForAdRequest(adUnitId, requestOptions);
35
+ }
36
+
37
+ addAdEventsListener(listener) {
38
+ return this._addAdEventsListener(listener);
39
+ }
40
+
41
+ addAdEventListener(type, listener) {
42
+ return this._addAdEventListener(type, listener);
43
+ }
44
+
45
+ }
46
+
47
+ exports.GAMInterstitialAd = GAMInterstitialAd;
48
+ //# sourceMappingURL=GAMInterstitialAd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["GAMInterstitialAd.ts"],"names":["GAMInterstitialAd","InterstitialAd","createForAdRequest","adUnitId","requestOptions","addAdEventsListener","listener","_addAdEventsListener","addAdEventListener","type","_addAdEventListener"],"mappings":";;;;;;;AAKA;;AAEO,MAAMA,iBAAN,SAAgCC,8BAAhC,CAA+C;AACpD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC2B,SAAlBC,kBAAkB,CAACC,QAAD,EAAmBC,cAAnB,EAAoD;AAC3E,WAAO,MAAMF,kBAAN,CAAyBC,QAAzB,EAAmCC,cAAnC,CAAP;AACD;;AAEDC,EAAAA,mBAAmB,CAAyCC,QAAzC,EAAwE;AACzF,WAAO,KAAKC,oBAAL,CAA0BD,QAA1B,CAAP;AACD;;AAEDE,EAAAA,kBAAkB,CAChBC,IADgB,EAEhBH,QAFgB,EAGhB;AACA,WAAO,KAAKI,mBAAL,CAAyBD,IAAzB,EAA+BH,QAA/B,CAAP;AACD;;AApCmD","sourcesContent":["import { AdEventType } from '../AdEventType';\nimport { GAMAdEventType } from '../GAMAdEventType';\nimport { AdEventListener } from '../types/AdEventListener';\nimport { AdEventsListener } from '../types/AdEventsListener';\nimport { RequestOptions } from '../types/RequestOptions';\nimport { InterstitialAd } from './InterstitialAd';\n\nexport class GAMInterstitialAd extends InterstitialAd {\n /**\n * Creates a new GAMInterstitialAd instance.\n *\n * #### Example\n *\n * ```js\n * import { GAMInterstitialAd, AdEventType, TestIds } from 'react-native-google-mobile-ads';\n *\n * const interstitialAd = await GAMInterstitialAd.createForAdRequest(TestIds.GAM_INTERSTITIAL, {\n * requestAgent: 'CoolAds',\n * });\n *\n * interstitialAd.addAdEventListener(AdEventType.Loaded, () => {\n * interstitialAd.show();\n * });\n *\n * interstitialAd.load();\n * ```\n *\n * @param adUnitId The Ad Unit ID for the Interstitial. You can find this on your Google Mobile Ads dashboard.\n * @param requestOptions Optional RequestOptions used to load the ad.\n */\n static createForAdRequest(adUnitId: string, requestOptions?: RequestOptions) {\n return super.createForAdRequest(adUnitId, requestOptions) as GAMInterstitialAd;\n }\n\n addAdEventsListener<T extends AdEventType | GAMAdEventType>(listener: AdEventsListener<T>) {\n return this._addAdEventsListener(listener);\n }\n\n addAdEventListener<T extends AdEventType | GAMAdEventType>(\n type: T,\n listener: AdEventListener<T>,\n ) {\n return this._addAdEventListener(type, listener);\n }\n}\n"]}