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.
Files changed (373) hide show
  1. package/LICENSE +32 -0
  2. package/README.md +65 -0
  3. package/RNGoogleMobileAds.podspec +42 -0
  4. package/__tests__/consent.test.ts +25 -0
  5. package/__tests__/googleMobileAds.test.ts +63 -0
  6. package/__tests__/interstitial.test.ts +53 -0
  7. package/__tests__/requestOptions.test.tsx +4 -0
  8. package/__tests__/rewarded.test.tsx +4 -0
  9. package/__tests__/showOptions.test.tsx +4 -0
  10. package/android/.editorconfig +10 -0
  11. package/android/app-json.gradle +69 -0
  12. package/android/build.gradle +98 -0
  13. package/android/lint.xml +5 -0
  14. package/android/settings.gradle +1 -0
  15. package/android/src/main/AndroidManifest.xml +17 -0
  16. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeAppModule.java +169 -0
  17. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsAppOpenModule.java +161 -0
  18. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsBannerAdViewManager.java +209 -0
  19. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsCommon.java +256 -0
  20. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsConsentModule.java +226 -0
  21. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsEvent.java +72 -0
  22. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsInterstitialModule.java +159 -0
  23. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsModule.java +143 -0
  24. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsPackage.java +48 -0
  25. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsRewardedModule.java +177 -0
  26. package/android/src/main/java/io/invertase/googlemobileads/common/RCTConvert.java +111 -0
  27. package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeApp.java +34 -0
  28. package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeEvent.java +41 -0
  29. package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeEventEmitter.java +150 -0
  30. package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeInitProvider.java +77 -0
  31. package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeJSON.java +107 -0
  32. package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeMeta.java +92 -0
  33. package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativeModule.java +96 -0
  34. package/android/src/main/java/io/invertase/googlemobileads/common/ReactNativePreferences.java +86 -0
  35. package/android/src/main/java/io/invertase/googlemobileads/common/SharedUtils.java +427 -0
  36. package/android/src/main/java/io/invertase/googlemobileads/common/TaskExecutorService.java +124 -0
  37. package/android/src/main/java/io/invertase/googlemobileads/interfaces/ContextProvider.java +30 -0
  38. package/android/src/main/java/io/invertase/googlemobileads/interfaces/NativeError.java +28 -0
  39. package/android/src/main/java/io/invertase/googlemobileads/interfaces/NativeEvent.java +26 -0
  40. package/babel.config.js +18 -0
  41. package/docs/displaying-ads.mdx +319 -0
  42. package/docs/european-user-consent.mdx +258 -0
  43. package/docs/img/logo_admob_192px.svg +19 -0
  44. package/docs/index.mdx +168 -0
  45. package/docs.json +9 -0
  46. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.h +29 -0
  47. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.m +98 -0
  48. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerViewManager.h +23 -0
  49. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerViewManager.m +153 -0
  50. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.h +60 -0
  51. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m +201 -0
  52. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.h +26 -0
  53. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.m +179 -0
  54. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.h +32 -0
  55. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenContentDelegate.m +57 -0
  56. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.h +25 -0
  57. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.m +124 -0
  58. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsModule.h +24 -0
  59. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsModule.m +104 -0
  60. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedModule.h +25 -0
  61. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedModule.m +173 -0
  62. package/ios/RNGoogleMobileAds/common/RNAppModule.h +24 -0
  63. package/ios/RNGoogleMobileAds/common/RNAppModule.m +158 -0
  64. package/ios/RNGoogleMobileAds/common/RNJSON.h +34 -0
  65. package/ios/RNGoogleMobileAds/common/RNJSON.m +93 -0
  66. package/ios/RNGoogleMobileAds/common/RNMeta.h +30 -0
  67. package/ios/RNGoogleMobileAds/common/RNMeta.m +61 -0
  68. package/ios/RNGoogleMobileAds/common/RNPreferences.h +44 -0
  69. package/ios/RNGoogleMobileAds/common/RNPreferences.m +94 -0
  70. package/ios/RNGoogleMobileAds/common/RNRCTEventEmitter.h +73 -0
  71. package/ios/RNGoogleMobileAds/common/RNRCTEventEmitter.m +150 -0
  72. package/ios/RNGoogleMobileAds/common/RNSharedUtils.h +48 -0
  73. package/ios/RNGoogleMobileAds/common/RNSharedUtils.m +56 -0
  74. package/ios/RNGoogleMobileAds.xcodeproj/project.pbxproj +377 -0
  75. package/ios/RNGoogleMobileAds.xcodeproj/xcshareddata/IDETemplateMacros.plist +24 -0
  76. package/ios_config.sh +140 -0
  77. package/jest.config.js +6 -0
  78. package/jest.setup.ts +29 -0
  79. package/lib/commonjs/AdEventType.js +34 -0
  80. package/lib/commonjs/AdEventType.js.map +1 -0
  81. package/lib/commonjs/AdsConsent.js +160 -0
  82. package/lib/commonjs/AdsConsent.js.map +1 -0
  83. package/lib/commonjs/AdsConsentDebugGeography.js +38 -0
  84. package/lib/commonjs/AdsConsentDebugGeography.js.map +1 -0
  85. package/lib/commonjs/AdsConsentStatus.js +36 -0
  86. package/lib/commonjs/AdsConsentStatus.js.map +1 -0
  87. package/lib/commonjs/BannerAdSize.js +38 -0
  88. package/lib/commonjs/BannerAdSize.js.map +1 -0
  89. package/lib/commonjs/MaxAdContentRating.js +33 -0
  90. package/lib/commonjs/MaxAdContentRating.js.map +1 -0
  91. package/lib/commonjs/MobileAds.js +67 -0
  92. package/lib/commonjs/MobileAds.js.map +1 -0
  93. package/lib/commonjs/RewardedAdEventType.js +31 -0
  94. package/lib/commonjs/RewardedAdEventType.js.map +1 -0
  95. package/lib/commonjs/TestIds.js +47 -0
  96. package/lib/commonjs/TestIds.js.map +1 -0
  97. package/lib/commonjs/ads/AppOpenAd.js +96 -0
  98. package/lib/commonjs/ads/AppOpenAd.js.map +1 -0
  99. package/lib/commonjs/ads/BannerAd.js +128 -0
  100. package/lib/commonjs/ads/BannerAd.js.map +1 -0
  101. package/lib/commonjs/ads/InterstitialAd.js +163 -0
  102. package/lib/commonjs/ads/InterstitialAd.js.map +1 -0
  103. package/lib/commonjs/ads/MobileAd.js +90 -0
  104. package/lib/commonjs/ads/MobileAd.js.map +1 -0
  105. package/lib/commonjs/ads/RewardedAd.js +169 -0
  106. package/lib/commonjs/ads/RewardedAd.js.map +1 -0
  107. package/lib/commonjs/common/Base64.js +121 -0
  108. package/lib/commonjs/common/Base64.js.map +1 -0
  109. package/lib/commonjs/common/MutatableParams.js +46 -0
  110. package/lib/commonjs/common/MutatableParams.js.map +1 -0
  111. package/lib/commonjs/common/ReferenceBase.js +59 -0
  112. package/lib/commonjs/common/ReferenceBase.js.map +1 -0
  113. package/lib/commonjs/common/deeps.js +101 -0
  114. package/lib/commonjs/common/deeps.js.map +1 -0
  115. package/lib/commonjs/common/id.js +82 -0
  116. package/lib/commonjs/common/id.js.map +1 -0
  117. package/lib/commonjs/common/index.js +212 -0
  118. package/lib/commonjs/common/index.js.map +1 -0
  119. package/lib/commonjs/common/path.js +144 -0
  120. package/lib/commonjs/common/path.js.map +1 -0
  121. package/lib/commonjs/common/promise.js +70 -0
  122. package/lib/commonjs/common/promise.js.map +1 -0
  123. package/lib/commonjs/common/serialize.js +52 -0
  124. package/lib/commonjs/common/serialize.js.map +1 -0
  125. package/lib/commonjs/common/validate.js +239 -0
  126. package/lib/commonjs/common/validate.js.map +1 -0
  127. package/lib/commonjs/declarations.d.js +2 -0
  128. package/lib/commonjs/declarations.d.js.map +1 -0
  129. package/lib/commonjs/index.js +143 -0
  130. package/lib/commonjs/index.js.map +1 -0
  131. package/lib/commonjs/internal/GoogleMobileAdsNativeEventEmitter.js +76 -0
  132. package/lib/commonjs/internal/GoogleMobileAdsNativeEventEmitter.js.map +1 -0
  133. package/lib/commonjs/internal/Module.js +60 -0
  134. package/lib/commonjs/internal/Module.js.map +1 -0
  135. package/lib/commonjs/internal/NativeError.js +70 -0
  136. package/lib/commonjs/internal/NativeError.js.map +1 -0
  137. package/lib/commonjs/internal/SharedEventEmitter.js +31 -0
  138. package/lib/commonjs/internal/SharedEventEmitter.js.map +1 -0
  139. package/lib/commonjs/internal/constants.js +30 -0
  140. package/lib/commonjs/internal/constants.js.map +1 -0
  141. package/lib/commonjs/internal/index.js +49 -0
  142. package/lib/commonjs/internal/index.js.map +1 -0
  143. package/lib/commonjs/internal/registry/nativeModule.js +231 -0
  144. package/lib/commonjs/internal/registry/nativeModule.js.map +1 -0
  145. package/lib/commonjs/types/AdEventListener.js +6 -0
  146. package/lib/commonjs/types/AdEventListener.js.map +1 -0
  147. package/lib/commonjs/types/AdShowOptions.js +2 -0
  148. package/lib/commonjs/types/AdShowOptions.js.map +1 -0
  149. package/lib/commonjs/types/AdapterStatus.js +18 -0
  150. package/lib/commonjs/types/AdapterStatus.js.map +1 -0
  151. package/lib/commonjs/types/AdsConsent.interface.js +6 -0
  152. package/lib/commonjs/types/AdsConsent.interface.js.map +1 -0
  153. package/lib/commonjs/types/BannerAdProps.js +6 -0
  154. package/lib/commonjs/types/BannerAdProps.js.map +1 -0
  155. package/lib/commonjs/types/GoogleMobileAdsNativeModule.js +6 -0
  156. package/lib/commonjs/types/GoogleMobileAdsNativeModule.js.map +1 -0
  157. package/lib/commonjs/types/MobileAd.interface.js +6 -0
  158. package/lib/commonjs/types/MobileAd.interface.js.map +1 -0
  159. package/lib/commonjs/types/MobileAdsModule.interface.js +6 -0
  160. package/lib/commonjs/types/MobileAdsModule.interface.js.map +1 -0
  161. package/lib/commonjs/types/Module.interface.js +2 -0
  162. package/lib/commonjs/types/Module.interface.js.map +1 -0
  163. package/lib/commonjs/types/RequestConfiguration.js +6 -0
  164. package/lib/commonjs/types/RequestConfiguration.js.map +1 -0
  165. package/lib/commonjs/types/RequestOptions.js +2 -0
  166. package/lib/commonjs/types/RequestOptions.js.map +1 -0
  167. package/lib/commonjs/types/RewardedAdReward.js +2 -0
  168. package/lib/commonjs/types/RewardedAdReward.js.map +1 -0
  169. package/lib/commonjs/validateAdRequestConfiguration.js +69 -0
  170. package/lib/commonjs/validateAdRequestConfiguration.js.map +1 -0
  171. package/lib/commonjs/validateAdRequestOptions.js +158 -0
  172. package/lib/commonjs/validateAdRequestOptions.js.map +1 -0
  173. package/lib/commonjs/validateAdShowOptions.js +47 -0
  174. package/lib/commonjs/validateAdShowOptions.js.map +1 -0
  175. package/lib/commonjs/version.js +10 -0
  176. package/lib/commonjs/version.js.map +1 -0
  177. package/lib/module/AdEventType.js +26 -0
  178. package/lib/module/AdEventType.js.map +1 -0
  179. package/lib/module/AdsConsent.js +148 -0
  180. package/lib/module/AdsConsent.js.map +1 -0
  181. package/lib/module/AdsConsentDebugGeography.js +30 -0
  182. package/lib/module/AdsConsentDebugGeography.js.map +1 -0
  183. package/lib/module/AdsConsentStatus.js +28 -0
  184. package/lib/module/AdsConsentStatus.js.map +1 -0
  185. package/lib/module/BannerAdSize.js +30 -0
  186. package/lib/module/BannerAdSize.js.map +1 -0
  187. package/lib/module/MaxAdContentRating.js +25 -0
  188. package/lib/module/MaxAdContentRating.js.map +1 -0
  189. package/lib/module/MobileAds.js +53 -0
  190. package/lib/module/MobileAds.js.map +1 -0
  191. package/lib/module/RewardedAdEventType.js +23 -0
  192. package/lib/module/RewardedAdEventType.js.map +1 -0
  193. package/lib/module/TestIds.js +38 -0
  194. package/lib/module/TestIds.js.map +1 -0
  195. package/lib/module/ads/AppOpenAd.js +81 -0
  196. package/lib/module/ads/AppOpenAd.js.map +1 -0
  197. package/lib/module/ads/BannerAd.js +108 -0
  198. package/lib/module/ads/BannerAd.js.map +1 -0
  199. package/lib/module/ads/InterstitialAd.js +149 -0
  200. package/lib/module/ads/InterstitialAd.js.map +1 -0
  201. package/lib/module/ads/MobileAd.js +94 -0
  202. package/lib/module/ads/MobileAd.js.map +1 -0
  203. package/lib/module/ads/RewardedAd.js +155 -0
  204. package/lib/module/ads/RewardedAd.js.map +1 -0
  205. package/lib/module/common/Base64.js +106 -0
  206. package/lib/module/common/Base64.js.map +1 -0
  207. package/lib/module/common/MutatableParams.js +52 -0
  208. package/lib/module/common/MutatableParams.js.map +1 -0
  209. package/lib/module/common/ReferenceBase.js +50 -0
  210. package/lib/module/common/ReferenceBase.js.map +1 -0
  211. package/lib/module/common/deeps.js +91 -0
  212. package/lib/module/common/deeps.js.map +1 -0
  213. package/lib/module/common/id.js +74 -0
  214. package/lib/module/common/id.js.map +1 -0
  215. package/lib/module/common/index.js +109 -0
  216. package/lib/module/common/index.js.map +1 -0
  217. package/lib/module/common/path.js +120 -0
  218. package/lib/module/common/path.js.map +1 -0
  219. package/lib/module/common/promise.js +60 -0
  220. package/lib/module/common/promise.js.map +1 -0
  221. package/lib/module/common/serialize.js +41 -0
  222. package/lib/module/common/serialize.js.map +1 -0
  223. package/lib/module/common/validate.js +197 -0
  224. package/lib/module/common/validate.js.map +1 -0
  225. package/lib/module/declarations.d.js +2 -0
  226. package/lib/module/declarations.d.js.map +1 -0
  227. package/lib/module/index.js +33 -0
  228. package/lib/module/index.js.map +1 -0
  229. package/lib/module/internal/GoogleMobileAdsNativeEventEmitter.js +83 -0
  230. package/lib/module/internal/GoogleMobileAdsNativeEventEmitter.js.map +1 -0
  231. package/lib/module/internal/Module.js +64 -0
  232. package/lib/module/internal/Module.js.map +1 -0
  233. package/lib/module/internal/NativeError.js +61 -0
  234. package/lib/module/internal/NativeError.js.map +1 -0
  235. package/lib/module/internal/SharedEventEmitter.js +20 -0
  236. package/lib/module/internal/SharedEventEmitter.js.map +1 -0
  237. package/lib/module/internal/constants.js +20 -0
  238. package/lib/module/internal/constants.js.map +1 -0
  239. package/lib/module/internal/index.js +21 -0
  240. package/lib/module/internal/index.js.map +1 -0
  241. package/lib/module/internal/registry/nativeModule.js +215 -0
  242. package/lib/module/internal/registry/nativeModule.js.map +1 -0
  243. package/lib/module/types/AdEventListener.js +2 -0
  244. package/lib/module/types/AdEventListener.js.map +1 -0
  245. package/lib/module/types/AdShowOptions.js +2 -0
  246. package/lib/module/types/AdShowOptions.js.map +1 -0
  247. package/lib/module/types/AdapterStatus.js +10 -0
  248. package/lib/module/types/AdapterStatus.js.map +1 -0
  249. package/lib/module/types/AdsConsent.interface.js +2 -0
  250. package/lib/module/types/AdsConsent.interface.js.map +1 -0
  251. package/lib/module/types/BannerAdProps.js +2 -0
  252. package/lib/module/types/BannerAdProps.js.map +1 -0
  253. package/lib/module/types/GoogleMobileAdsNativeModule.js +2 -0
  254. package/lib/module/types/GoogleMobileAdsNativeModule.js.map +1 -0
  255. package/lib/module/types/MobileAd.interface.js +2 -0
  256. package/lib/module/types/MobileAd.interface.js.map +1 -0
  257. package/lib/module/types/MobileAdsModule.interface.js +2 -0
  258. package/lib/module/types/MobileAdsModule.interface.js.map +1 -0
  259. package/lib/module/types/Module.interface.js +2 -0
  260. package/lib/module/types/Module.interface.js.map +1 -0
  261. package/lib/module/types/RequestConfiguration.js +2 -0
  262. package/lib/module/types/RequestConfiguration.js.map +1 -0
  263. package/lib/module/types/RequestOptions.js +2 -0
  264. package/lib/module/types/RequestOptions.js.map +1 -0
  265. package/lib/module/types/RewardedAdReward.js +2 -0
  266. package/lib/module/types/RewardedAdReward.js.map +1 -0
  267. package/lib/module/validateAdRequestConfiguration.js +60 -0
  268. package/lib/module/validateAdRequestConfiguration.js.map +1 -0
  269. package/lib/module/validateAdRequestOptions.js +150 -0
  270. package/lib/module/validateAdRequestOptions.js.map +1 -0
  271. package/lib/module/validateAdShowOptions.js +39 -0
  272. package/lib/module/validateAdShowOptions.js.map +1 -0
  273. package/lib/module/version.js +3 -0
  274. package/lib/module/version.js.map +1 -0
  275. package/lib/typescript/AdEventType.d.ts +47 -0
  276. package/lib/typescript/AdsConsent.d.ts +2 -0
  277. package/lib/typescript/AdsConsentDebugGeography.d.ts +19 -0
  278. package/lib/typescript/AdsConsentStatus.d.ts +17 -0
  279. package/lib/typescript/BannerAdSize.d.ts +34 -0
  280. package/lib/typescript/MaxAdContentRating.d.ts +18 -0
  281. package/lib/typescript/MobileAds.d.ts +11 -0
  282. package/lib/typescript/RewardedAdEventType.d.ts +46 -0
  283. package/lib/typescript/TestIds.d.ts +6 -0
  284. package/lib/typescript/ads/AppOpenAd.d.ts +11 -0
  285. package/lib/typescript/ads/BannerAd.d.ts +3 -0
  286. package/lib/typescript/ads/InterstitialAd.d.ts +78 -0
  287. package/lib/typescript/ads/MobileAd.d.ts +32 -0
  288. package/lib/typescript/ads/RewardedAd.d.ts +84 -0
  289. package/lib/typescript/common/Base64.d.ts +14 -0
  290. package/lib/typescript/common/MutatableParams.d.ts +9 -0
  291. package/lib/typescript/common/ReferenceBase.d.ts +11 -0
  292. package/lib/typescript/common/deeps.d.ts +18 -0
  293. package/lib/typescript/common/id.d.ts +11 -0
  294. package/lib/typescript/common/index.d.ts +28 -0
  295. package/lib/typescript/common/path.d.ts +43 -0
  296. package/lib/typescript/common/promise.d.ts +13 -0
  297. package/lib/typescript/common/serialize.d.ts +5 -0
  298. package/lib/typescript/common/validate.d.ts +90 -0
  299. package/lib/typescript/index.d.ts +14 -0
  300. package/lib/typescript/internal/GoogleMobileAdsNativeEventEmitter.d.ts +12 -0
  301. package/lib/typescript/internal/Module.d.ts +13 -0
  302. package/lib/typescript/internal/NativeError.d.ts +26 -0
  303. package/lib/typescript/internal/SharedEventEmitter.d.ts +2 -0
  304. package/lib/typescript/internal/constants.d.ts +3 -0
  305. package/lib/typescript/internal/index.d.ts +4 -0
  306. package/lib/typescript/internal/registry/nativeModule.d.ts +15 -0
  307. package/lib/typescript/types/AdEventListener.d.ts +11 -0
  308. package/lib/typescript/types/AdShowOptions.d.ts +12 -0
  309. package/lib/typescript/types/AdapterStatus.d.ts +18 -0
  310. package/lib/typescript/types/AdsConsent.interface.d.ts +286 -0
  311. package/lib/typescript/types/BannerAdProps.d.ts +66 -0
  312. package/lib/typescript/types/GoogleMobileAdsNativeModule.d.ts +14 -0
  313. package/lib/typescript/types/MobileAd.interface.d.ts +64 -0
  314. package/lib/typescript/types/MobileAdsModule.interface.d.ts +38 -0
  315. package/lib/typescript/types/Module.interface.d.ts +14 -0
  316. package/lib/typescript/types/RequestConfiguration.d.ts +36 -0
  317. package/lib/typescript/types/RequestOptions.d.ts +106 -0
  318. package/lib/typescript/types/RewardedAdReward.d.ts +13 -0
  319. package/lib/typescript/validateAdRequestConfiguration.d.ts +2 -0
  320. package/lib/typescript/validateAdRequestOptions.d.ts +2 -0
  321. package/lib/typescript/validateAdShowOptions.d.ts +2 -0
  322. package/lib/typescript/version.d.ts +1 -0
  323. package/package.json +143 -0
  324. package/react-native.config.js +19 -0
  325. package/src/AdEventType.ts +68 -0
  326. package/src/AdsConsent.ts +191 -0
  327. package/src/AdsConsentDebugGeography.ts +38 -0
  328. package/src/AdsConsentStatus.ts +36 -0
  329. package/src/BannerAdSize.ts +59 -0
  330. package/src/MaxAdContentRating.ts +38 -0
  331. package/src/MobileAds.ts +84 -0
  332. package/src/RewardedAdEventType.ts +64 -0
  333. package/src/TestIds.ts +39 -0
  334. package/src/ads/AppOpenAd.ts +85 -0
  335. package/src/ads/BannerAd.tsx +126 -0
  336. package/src/ads/InterstitialAd.ts +156 -0
  337. package/src/ads/MobileAd.ts +101 -0
  338. package/src/ads/RewardedAd.ts +161 -0
  339. package/src/common/Base64.ts +114 -0
  340. package/src/common/MutatableParams.ts +50 -0
  341. package/src/common/ReferenceBase.ts +45 -0
  342. package/src/common/deeps.ts +88 -0
  343. package/src/common/id.ts +74 -0
  344. package/src/common/index.ts +103 -0
  345. package/src/common/path.ts +114 -0
  346. package/src/common/promise.ts +66 -0
  347. package/src/common/serialize.ts +43 -0
  348. package/src/common/validate.ts +205 -0
  349. package/src/declarations.d.ts +3 -0
  350. package/src/index.ts +35 -0
  351. package/src/internal/GoogleMobileAdsNativeEventEmitter.ts +81 -0
  352. package/src/internal/Module.ts +58 -0
  353. package/src/internal/NativeError.ts +56 -0
  354. package/src/internal/SharedEventEmitter.ts +22 -0
  355. package/src/internal/constants.ts +43 -0
  356. package/src/internal/index.ts +21 -0
  357. package/src/internal/registry/nativeModule.ts +226 -0
  358. package/src/types/AdEventListener.ts +16 -0
  359. package/src/types/AdShowOptions.ts +12 -0
  360. package/src/types/AdapterStatus.ts +20 -0
  361. package/src/types/AdsConsent.interface.ts +306 -0
  362. package/src/types/BannerAdProps.ts +73 -0
  363. package/src/types/GoogleMobileAdsNativeModule.ts +15 -0
  364. package/src/types/MobileAd.interface.ts +69 -0
  365. package/src/types/MobileAdsModule.interface.ts +43 -0
  366. package/src/types/Module.interface.ts +16 -0
  367. package/src/types/RequestConfiguration.ts +40 -0
  368. package/src/types/RequestOptions.ts +113 -0
  369. package/src/types/RewardedAdReward.ts +14 -0
  370. package/src/validateAdRequestConfiguration.ts +71 -0
  371. package/src/validateAdRequestOptions.ts +168 -0
  372. package/src/validateAdShowOptions.ts +41 -0
  373. package/src/version.ts +2 -0
@@ -0,0 +1,212 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ getDataUrlParts: true,
8
+ once: true,
9
+ isError: true,
10
+ hasOwnProperty: true,
11
+ stripTrailingSlash: true,
12
+ isIOS: true,
13
+ isAndroid: true,
14
+ tryJSONParse: true,
15
+ tryJSONStringify: true,
16
+ Base64: true,
17
+ ReferenceBase: true
18
+ };
19
+ exports.Base64 = void 0;
20
+ Object.defineProperty(exports, "ReferenceBase", {
21
+ enumerable: true,
22
+ get: function () {
23
+ return _ReferenceBase.ReferenceBase;
24
+ }
25
+ });
26
+ exports.getDataUrlParts = getDataUrlParts;
27
+ exports.hasOwnProperty = hasOwnProperty;
28
+ exports.isAndroid = void 0;
29
+ exports.isError = isError;
30
+ exports.isIOS = void 0;
31
+ exports.once = once;
32
+ exports.stripTrailingSlash = stripTrailingSlash;
33
+ exports.tryJSONParse = tryJSONParse;
34
+ exports.tryJSONStringify = tryJSONStringify;
35
+
36
+ var _reactNative = require("react-native");
37
+
38
+ var Base64 = _interopRequireWildcard(require("./Base64"));
39
+
40
+ exports.Base64 = Base64;
41
+
42
+ var _validate = require("./validate");
43
+
44
+ Object.keys(_validate).forEach(function (key) {
45
+ if (key === "default" || key === "__esModule") return;
46
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
47
+ if (key in exports && exports[key] === _validate[key]) return;
48
+ Object.defineProperty(exports, key, {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _validate[key];
52
+ }
53
+ });
54
+ });
55
+
56
+ var _id = require("./id");
57
+
58
+ Object.keys(_id).forEach(function (key) {
59
+ if (key === "default" || key === "__esModule") return;
60
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
61
+ if (key in exports && exports[key] === _id[key]) return;
62
+ Object.defineProperty(exports, key, {
63
+ enumerable: true,
64
+ get: function () {
65
+ return _id[key];
66
+ }
67
+ });
68
+ });
69
+
70
+ var _path = require("./path");
71
+
72
+ Object.keys(_path).forEach(function (key) {
73
+ if (key === "default" || key === "__esModule") return;
74
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
75
+ if (key in exports && exports[key] === _path[key]) return;
76
+ Object.defineProperty(exports, key, {
77
+ enumerable: true,
78
+ get: function () {
79
+ return _path[key];
80
+ }
81
+ });
82
+ });
83
+
84
+ var _promise = require("./promise");
85
+
86
+ Object.keys(_promise).forEach(function (key) {
87
+ if (key === "default" || key === "__esModule") return;
88
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
89
+ if (key in exports && exports[key] === _promise[key]) return;
90
+ Object.defineProperty(exports, key, {
91
+ enumerable: true,
92
+ get: function () {
93
+ return _promise[key];
94
+ }
95
+ });
96
+ });
97
+
98
+ var _ReferenceBase = require("./ReferenceBase");
99
+
100
+ 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); }
101
+
102
+ 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; }
103
+
104
+ /*
105
+ * Copyright (c) 2016-present Invertase Limited & Contributors
106
+ *
107
+ * Licensed under the Apache License, Version 2.0 (the "License");
108
+ * you may not use this library except in compliance with the License.
109
+ * You may obtain a copy of the License at
110
+ *
111
+ * http://www.apache.org/licenses/LICENSE-2.0
112
+ *
113
+ * Unless required by applicable law or agreed to in writing, software
114
+ * distributed under the License is distributed on an "AS IS" BASIS,
115
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
116
+ * See the License for the specific language governing permissions and
117
+ * limitations under the License.
118
+ *
119
+ */
120
+ function getDataUrlParts(dataUrlString) {
121
+ const isBase64 = dataUrlString.includes(';base64');
122
+ let [mediaType, base64String] = dataUrlString.split(',');
123
+
124
+ if (!mediaType || !base64String) {
125
+ return {
126
+ base64String: undefined,
127
+ mediaType: undefined
128
+ };
129
+ }
130
+
131
+ mediaType = mediaType.replace('data:', '').replace(';base64', '');
132
+
133
+ if (base64String && base64String.includes('%')) {
134
+ base64String = decodeURIComponent(base64String);
135
+ }
136
+
137
+ if (!isBase64) {
138
+ base64String = Base64.btoa(base64String);
139
+ }
140
+
141
+ return {
142
+ base64String,
143
+ mediaType
144
+ };
145
+ }
146
+
147
+ function once(fn, context) {
148
+ let onceResult;
149
+ let ranOnce = false;
150
+ return function onceInner() {
151
+ if (!ranOnce) {
152
+ ranOnce = true;
153
+
154
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
155
+ args[_key] = arguments[_key];
156
+ }
157
+
158
+ onceResult = fn.apply(context || this, args);
159
+ }
160
+
161
+ return onceResult;
162
+ };
163
+ }
164
+
165
+ function isError(value) {
166
+ if (Object.prototype.toString.call(value) === '[object Error]') {
167
+ return true;
168
+ }
169
+
170
+ return value instanceof Error;
171
+ }
172
+
173
+ function hasOwnProperty(target, property) {
174
+ return Object.hasOwnProperty.call(target, property);
175
+ }
176
+ /**
177
+ * Remove a trailing forward slash from a string if it exists
178
+ *
179
+ * @param string
180
+ * @returns {*}
181
+ */
182
+
183
+
184
+ function stripTrailingSlash(string) {
185
+ if (!(0, _validate.isString)(string)) {
186
+ return string;
187
+ }
188
+
189
+ return string.endsWith('/') ? string.slice(0, -1) : string;
190
+ }
191
+
192
+ const isIOS = _reactNative.Platform.OS === 'ios';
193
+ exports.isIOS = isIOS;
194
+ const isAndroid = _reactNative.Platform.OS === 'android';
195
+ exports.isAndroid = isAndroid;
196
+
197
+ function tryJSONParse(string) {
198
+ try {
199
+ return string && JSON.parse(string);
200
+ } catch (jsonError) {
201
+ return string;
202
+ }
203
+ }
204
+
205
+ function tryJSONStringify(data) {
206
+ try {
207
+ return JSON.stringify(data);
208
+ } catch (jsonError) {
209
+ return null;
210
+ }
211
+ }
212
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":["getDataUrlParts","dataUrlString","isBase64","includes","mediaType","base64String","split","undefined","replace","decodeURIComponent","Base64","btoa","once","fn","context","onceResult","ranOnce","onceInner","args","apply","isError","value","Object","prototype","toString","call","Error","hasOwnProperty","target","property","stripTrailingSlash","string","endsWith","slice","isIOS","Platform","OS","isAndroid","tryJSONParse","JSON","parse","jsonError","tryJSONStringify","data","stringify"],"mappings":"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","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';\nimport * as Base64 from './Base64';\nimport { isString } from './validate';\n\nexport * from './id';\nexport * from './path';\nexport * from './promise';\nexport * from './validate';\n\nexport { Base64 };\nexport { ReferenceBase } from './ReferenceBase';\n\nexport function getDataUrlParts(dataUrlString: string) {\n const isBase64 = dataUrlString.includes(';base64');\n let [mediaType, base64String] = dataUrlString.split(',');\n if (!mediaType || !base64String) {\n return { base64String: undefined, mediaType: undefined };\n }\n mediaType = mediaType.replace('data:', '').replace(';base64', '');\n if (base64String && base64String.includes('%')) {\n base64String = decodeURIComponent(base64String);\n }\n if (!isBase64) {\n base64String = Base64.btoa(base64String);\n }\n return { base64String, mediaType };\n}\n\nexport function once<T>(fn: () => void, context: unknown): (this: T, ...args: []) => void {\n let onceResult: unknown;\n let ranOnce = false;\n\n return function onceInner(...args: []) {\n if (!ranOnce) {\n ranOnce = true;\n onceResult = fn.apply(context || this, args);\n }\n\n return onceResult;\n };\n}\n\nexport function isError(value: unknown) {\n if (Object.prototype.toString.call(value) === '[object Error]') {\n return true;\n }\n\n return value instanceof Error;\n}\n\nexport function hasOwnProperty(target: unknown, property: PropertyKey) {\n return Object.hasOwnProperty.call(target, property);\n}\n\n/**\n * Remove a trailing forward slash from a string if it exists\n *\n * @param string\n * @returns {*}\n */\nexport function stripTrailingSlash(string: string) {\n if (!isString(string)) {\n return string;\n }\n return string.endsWith('/') ? string.slice(0, -1) : string;\n}\n\nexport const isIOS = Platform.OS === 'ios';\n\nexport const isAndroid = Platform.OS === 'android';\n\nexport function tryJSONParse(string: string) {\n try {\n return string && JSON.parse(string);\n } catch (jsonError) {\n return string;\n }\n}\n\nexport function tryJSONStringify(data: unknown) {\n try {\n return JSON.stringify(data);\n } catch (jsonError) {\n return null;\n }\n}\n"]}
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.INVALID_PATH_REGEX = void 0;
7
+ exports.isValidPath = isValidPath;
8
+ exports.pathChild = pathChild;
9
+ exports.pathIsEmpty = pathIsEmpty;
10
+ exports.pathLastComponent = pathLastComponent;
11
+ exports.pathParent = pathParent;
12
+ exports.pathPieces = pathPieces;
13
+ exports.pathToUrlEncodedString = pathToUrlEncodedString;
14
+ exports.toFilePath = toFilePath;
15
+
16
+ /*
17
+ * Copyright (c) 2016-present Invertase Limited & Contributors
18
+ *
19
+ * Licensed under the Apache License, Version 2.0 (the "License");
20
+ * you may not use this library except in compliance with the License.
21
+ * You may obtain a copy of the License at
22
+ *
23
+ * http://www.apache.org/licenses/LICENSE-2.0
24
+ *
25
+ * Unless required by applicable law or agreed to in writing, software
26
+ * distributed under the License is distributed on an "AS IS" BASIS,
27
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28
+ * See the License for the specific language governing permissions and
29
+ * limitations under the License.
30
+ *
31
+ */
32
+
33
+ /**
34
+ * Returns the next parent of the path e.g. /foo/bar/car -> /foo/bar
35
+ */
36
+ function pathParent(path) {
37
+ if (path.length === 0) {
38
+ return null;
39
+ }
40
+
41
+ const index = path.lastIndexOf('/');
42
+
43
+ if (index <= 0) {
44
+ return null;
45
+ }
46
+
47
+ return path.slice(0, index);
48
+ }
49
+ /**
50
+ * Joins a parent and a child path
51
+ */
52
+
53
+
54
+ function pathChild(path, childPath) {
55
+ const canonicalChildPath = pathPieces(childPath).join('/');
56
+
57
+ if (path.length === 0) {
58
+ return canonicalChildPath;
59
+ }
60
+
61
+ return `${path}/${canonicalChildPath}`;
62
+ }
63
+ /**
64
+ * Returns the last component of a path, e.g /foo/bar.jpeg -> bar.jpeg
65
+ */
66
+
67
+
68
+ function pathLastComponent(path) {
69
+ const index = path.lastIndexOf('/', path.length - 2);
70
+
71
+ if (index === -1) {
72
+ return path;
73
+ }
74
+
75
+ return path.slice(index + 1);
76
+ }
77
+ /**
78
+ * Returns all none empty pieces of the path
79
+ * @param path
80
+ * @returns {*}
81
+ */
82
+
83
+
84
+ function pathPieces(path) {
85
+ return path.split('/').filter($ => $.length > 0);
86
+ }
87
+ /**
88
+ * Returns whether a given path is empty
89
+ * @param path
90
+ * @returns {boolean}
91
+ */
92
+
93
+
94
+ function pathIsEmpty(path) {
95
+ return !pathPieces(path).length;
96
+ }
97
+ /**
98
+ * Converts a given path to a URL encoded string
99
+ * @param path
100
+ * @returns {string|string}
101
+ */
102
+
103
+
104
+ function pathToUrlEncodedString(path) {
105
+ const pieces = pathPieces(path);
106
+ let pathString = '';
107
+
108
+ for (let i = 0; i < pieces.length; i++) {
109
+ pathString += `/${encodeURIComponent(String(pieces[i]))}`;
110
+ }
111
+
112
+ return pathString || '/';
113
+ } // eslint-disable-next-line no-control-regex
114
+
115
+
116
+ const INVALID_PATH_REGEX = /[[\].#$\u0000-\u001F\u007F]/;
117
+ /**
118
+ * Ensures a given path is a valid Firebase path
119
+ * @param path
120
+ * @returns {boolean}
121
+ */
122
+
123
+ exports.INVALID_PATH_REGEX = INVALID_PATH_REGEX;
124
+
125
+ function isValidPath(path) {
126
+ return typeof path === 'string' && path.length !== 0 && !INVALID_PATH_REGEX.test(path);
127
+ }
128
+ /**
129
+ * Converts a file path to a standardized string path
130
+ * @param path
131
+ * @returns {*}
132
+ */
133
+
134
+
135
+ function toFilePath(path) {
136
+ let _filePath = path.replace('file://', '');
137
+
138
+ if (_filePath.includes('%')) {
139
+ _filePath = decodeURIComponent(_filePath);
140
+ }
141
+
142
+ return _filePath;
143
+ }
144
+ //# sourceMappingURL=path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["path.ts"],"names":["pathParent","path","length","index","lastIndexOf","slice","pathChild","childPath","canonicalChildPath","pathPieces","join","pathLastComponent","split","filter","$","pathIsEmpty","pathToUrlEncodedString","pieces","pathString","i","encodeURIComponent","String","INVALID_PATH_REGEX","isValidPath","test","toFilePath","_filePath","replace","includes","decodeURIComponent"],"mappings":"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","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/**\n * Returns the next parent of the path e.g. /foo/bar/car -> /foo/bar\n */\nexport function pathParent(path: string) {\n if (path.length === 0) {\n return null;\n }\n\n const index = path.lastIndexOf('/');\n if (index <= 0) {\n return null;\n }\n\n return path.slice(0, index);\n}\n\n/**\n * Joins a parent and a child path\n */\nexport function pathChild(path: string, childPath: string) {\n const canonicalChildPath = pathPieces(childPath).join('/');\n\n if (path.length === 0) {\n return canonicalChildPath;\n }\n\n return `${path}/${canonicalChildPath}`;\n}\n\n/**\n * Returns the last component of a path, e.g /foo/bar.jpeg -> bar.jpeg\n */\nexport function pathLastComponent(path: string) {\n const index = path.lastIndexOf('/', path.length - 2);\n if (index === -1) {\n return path;\n }\n\n return path.slice(index + 1);\n}\n\n/**\n * Returns all none empty pieces of the path\n * @param path\n * @returns {*}\n */\nexport function pathPieces(path: string) {\n return path.split('/').filter($ => $.length > 0);\n}\n\n/**\n * Returns whether a given path is empty\n * @param path\n * @returns {boolean}\n */\nexport function pathIsEmpty(path: string) {\n return !pathPieces(path).length;\n}\n\n/**\n * Converts a given path to a URL encoded string\n * @param path\n * @returns {string|string}\n */\nexport function pathToUrlEncodedString(path: string) {\n const pieces = pathPieces(path);\n let pathString = '';\n for (let i = 0; i < pieces.length; i++) {\n pathString += `/${encodeURIComponent(String(pieces[i]))}`;\n }\n return pathString || '/';\n}\n\n// eslint-disable-next-line no-control-regex\nexport const INVALID_PATH_REGEX = /[[\\].#$\\u0000-\\u001F\\u007F]/;\n\n/**\n * Ensures a given path is a valid Firebase path\n * @param path\n * @returns {boolean}\n */\nexport function isValidPath(path: unknown) {\n return typeof path === 'string' && path.length !== 0 && !INVALID_PATH_REGEX.test(path);\n}\n\n/**\n * Converts a file path to a standardized string path\n * @param path\n * @returns {*}\n */\nexport function toFilePath(path: string) {\n let _filePath = path.replace('file://', '');\n if (_filePath.includes('%')) {\n _filePath = decodeURIComponent(_filePath);\n }\n return _filePath;\n}\n"]}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.promiseDefer = promiseDefer;
7
+ exports.promiseWithOptionalCallback = promiseWithOptionalCallback;
8
+
9
+ var _validate = require("./validate");
10
+
11
+ /*
12
+ * Copyright (c) 2016-present Invertase Limited & Contributors
13
+ *
14
+ * Licensed under the Apache License, Version 2.0 (the "License");
15
+ * you may not use this library except in compliance with the License.
16
+ * You may obtain a copy of the License at
17
+ *
18
+ * http://www.apache.org/licenses/LICENSE-2.0
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software
21
+ * distributed under the License is distributed on an "AS IS" BASIS,
22
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
+ * See the License for the specific language governing permissions and
24
+ * limitations under the License.
25
+ *
26
+ */
27
+
28
+ /**
29
+ *
30
+ */
31
+ function promiseDefer() {
32
+ const deferred = {
33
+ promise: null,
34
+ resolve: () => {},
35
+ reject: () => {}
36
+ };
37
+ deferred.promise = new Promise((resolve, reject) => {
38
+ deferred.resolve = resolve;
39
+ deferred.reject = reject;
40
+ });
41
+ return deferred;
42
+ }
43
+ /**
44
+ * @param promise
45
+ * @param callback
46
+ */
47
+
48
+
49
+ function promiseWithOptionalCallback(promise, callback) {
50
+ if (!(0, _validate.isFunction)(callback)) {
51
+ return promise;
52
+ }
53
+
54
+ return promise.then(result => {
55
+ if (callback && callback.length === 1) {
56
+ callback(null);
57
+ } else if (callback) {
58
+ callback(null, result);
59
+ }
60
+
61
+ return result;
62
+ }).catch(error => {
63
+ if (callback) {
64
+ callback(error);
65
+ }
66
+
67
+ return Promise.reject(error);
68
+ });
69
+ }
70
+ //# sourceMappingURL=promise.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["promise.ts"],"names":["promiseDefer","deferred","promise","resolve","reject","Promise","promiseWithOptionalCallback","callback","then","result","length","catch","error"],"mappings":";;;;;;;;AAiBA;;AAjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACO,SAASA,YAAT,GAAwB;AAC7B,QAAMC,QAIL,GAAG;AAAEC,IAAAA,OAAO,EAAE,IAAX;AAAiBC,IAAAA,OAAO,EAAE,MAAM,CAAE,CAAlC;AAAoCC,IAAAA,MAAM,EAAE,MAAM,CAAE;AAApD,GAJJ;AAMAH,EAAAA,QAAQ,CAACC,OAAT,GAAmB,IAAIG,OAAJ,CAAY,CAACF,OAAD,EAAUC,MAAV,KAAqB;AAClDH,IAAAA,QAAQ,CAACE,OAAT,GAAmBA,OAAnB;AACAF,IAAAA,QAAQ,CAACG,MAAT,GAAkBA,MAAlB;AACD,GAHkB,CAAnB;AAKA,SAAOH,QAAP;AACD;AAED;AACA;AACA;AACA;;;AACO,SAASK,2BAAT,CACLJ,OADK,EAELK,QAFK,EAGL;AACA,MAAI,CAAC,0BAAWA,QAAX,CAAL,EAA2B;AACzB,WAAOL,OAAP;AACD;;AAED,SAAOA,OAAO,CACXM,IADI,CACCC,MAAM,IAAI;AACd,QAAIF,QAAQ,IAAIA,QAAQ,CAACG,MAAT,KAAoB,CAApC,EAAuC;AACrCH,MAAAA,QAAQ,CAAC,IAAD,CAAR;AACD,KAFD,MAEO,IAAIA,QAAJ,EAAc;AACnBA,MAAAA,QAAQ,CAAC,IAAD,EAAOE,MAAP,CAAR;AACD;;AAED,WAAOA,MAAP;AACD,GATI,EAUJE,KAVI,CAUEC,KAAK,IAAI;AACd,QAAIL,QAAJ,EAAc;AACZA,MAAAA,QAAQ,CAACK,KAAD,CAAR;AACD;;AACD,WAAOP,OAAO,CAACD,MAAR,CAAeQ,KAAf,CAAP;AACD,GAfI,CAAP;AAgBD","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 } from './validate';\n\n/**\n *\n */\nexport function promiseDefer() {\n const deferred: {\n promise: Promise<unknown> | null;\n resolve: (value: unknown) => void;\n reject: (value: unknown) => void;\n } = { promise: null, resolve: () => {}, reject: () => {} };\n\n deferred.promise = new Promise((resolve, reject) => {\n deferred.resolve = resolve;\n deferred.reject = reject;\n });\n\n return deferred;\n}\n\n/**\n * @param promise\n * @param callback\n */\nexport function promiseWithOptionalCallback(\n promise: Promise<unknown>,\n callback: (a: unknown, b?: unknown) => void,\n) {\n if (!isFunction(callback)) {\n return promise;\n }\n\n return promise\n .then(result => {\n if (callback && callback.length === 1) {\n callback(null);\n } else if (callback) {\n callback(null, result);\n }\n\n return result;\n })\n .catch(error => {\n if (callback) {\n callback(error);\n }\n return Promise.reject(error);\n });\n}\n"]}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.serializeObject = serializeObject;
7
+ exports.serializeType = serializeType;
8
+
9
+ var _index = require("./index");
10
+
11
+ var _validate = require("./validate");
12
+
13
+ /*
14
+ * Copyright (c) 2016-present Invertase Limited & Contributors
15
+ *
16
+ * Licensed under the Apache License, Version 2.0 (the "License");
17
+ * you may not use this library except in compliance with the License.
18
+ * You may obtain a copy of the License at
19
+ *
20
+ * http://www.apache.org/licenses/LICENSE-2.0
21
+ *
22
+ * Unless required by applicable law or agreed to in writing, software
23
+ * distributed under the License is distributed on an "AS IS" BASIS,
24
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
+ * See the License for the specific language governing permissions and
26
+ * limitations under the License.
27
+ *
28
+ */
29
+ function serializeType(value) {
30
+ if ((0, _validate.isObject)(value)) {
31
+ return {
32
+ type: 'object',
33
+ value: serializeObject(value)
34
+ };
35
+ }
36
+
37
+ return {
38
+ type: typeof value,
39
+ value
40
+ };
41
+ }
42
+
43
+ function serializeObject(object) {
44
+ if (!(0, _validate.isObject)(object)) {
45
+ return object;
46
+ } // json stringify then parse it calls toString on Objects / Classes
47
+ // that support it i.e new Date() becomes a ISO string.
48
+
49
+
50
+ return (0, _index.tryJSONParse)((0, _index.tryJSONStringify)(object) || '');
51
+ }
52
+ //# sourceMappingURL=serialize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["serialize.ts"],"names":["serializeType","value","type","serializeObject","object"],"mappings":";;;;;;;;AAiBA;;AACA;;AAlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKO,SAASA,aAAT,CAAuBC,KAAvB,EAAuC;AAC5C,MAAI,wBAASA,KAAT,CAAJ,EAAqB;AACnB,WAAO;AACLC,MAAAA,IAAI,EAAE,QADD;AAELD,MAAAA,KAAK,EAAEE,eAAe,CAACF,KAAD;AAFjB,KAAP;AAID;;AAED,SAAO;AACLC,IAAAA,IAAI,EAAE,OAAOD,KADR;AAELA,IAAAA;AAFK,GAAP;AAID;;AAEM,SAASE,eAAT,CAAyBC,MAAzB,EAA0C;AAC/C,MAAI,CAAC,wBAASA,MAAT,CAAL,EAAuB;AACrB,WAAOA,MAAP;AACD,GAH8C,CAK/C;AACA;;;AACA,SAAO,yBAAa,6BAAiBA,MAAjB,KAA4B,EAAzC,CAAP;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 { tryJSONParse, tryJSONStringify } from './index';\nimport { isObject } from './validate';\n\nexport function serializeType(value: unknown) {\n if (isObject(value)) {\n return {\n type: 'object',\n value: serializeObject(value),\n };\n }\n\n return {\n type: typeof value,\n value,\n };\n}\n\nexport function serializeObject(object: unknown) {\n if (!isObject(object)) {\n return object;\n }\n\n // json stringify then parse it calls toString on Objects / Classes\n // that support it i.e new Date() becomes a ISO string.\n return tryJSONParse(tryJSONStringify(object) || '');\n}\n"]}