@chipmobilesdk/rn-ads 0.7.0 → 0.8.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 (319) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/lib/commonjs/config/resolveAdUnit.js +80 -0
  3. package/lib/commonjs/config/resolveAdUnit.js.map +1 -0
  4. package/lib/commonjs/config/types.js +138 -0
  5. package/lib/commonjs/config/types.js.map +1 -0
  6. package/lib/commonjs/config/validate.js +150 -0
  7. package/lib/commonjs/config/validate.js.map +1 -0
  8. package/lib/commonjs/core/adOriginatedReturn.js +119 -0
  9. package/lib/commonjs/core/adOriginatedReturn.js.map +1 -0
  10. package/lib/commonjs/core/adsInstance.js +129 -0
  11. package/lib/commonjs/core/adsInstance.js.map +1 -0
  12. package/lib/commonjs/core/consentFlow.js +154 -0
  13. package/lib/commonjs/core/consentFlow.js.map +1 -0
  14. package/lib/commonjs/core/enablement.js +64 -0
  15. package/lib/commonjs/core/enablement.js.map +1 -0
  16. package/lib/commonjs/core/fullScreenLock.js +48 -0
  17. package/lib/commonjs/core/fullScreenLock.js.map +1 -0
  18. package/lib/commonjs/core/gates.js +95 -0
  19. package/lib/commonjs/core/gates.js.map +1 -0
  20. package/lib/commonjs/core/initMachine.js +159 -0
  21. package/lib/commonjs/core/initMachine.js.map +1 -0
  22. package/lib/commonjs/core/instance/consent.js +155 -0
  23. package/lib/commonjs/core/instance/consent.js.map +1 -0
  24. package/lib/commonjs/core/instance/context.js +217 -0
  25. package/lib/commonjs/core/instance/context.js.map +1 -0
  26. package/lib/commonjs/core/instance/gate.js +194 -0
  27. package/lib/commonjs/core/instance/gate.js.map +1 -0
  28. package/lib/commonjs/core/instance/init.js +326 -0
  29. package/lib/commonjs/core/instance/init.js.map +1 -0
  30. package/lib/commonjs/core/instance/internals.js +115 -0
  31. package/lib/commonjs/core/instance/internals.js.map +1 -0
  32. package/lib/commonjs/core/instance/load.js +458 -0
  33. package/lib/commonjs/core/instance/load.js.map +1 -0
  34. package/lib/commonjs/core/instance/show.js +243 -0
  35. package/lib/commonjs/core/instance/show.js.map +1 -0
  36. package/lib/commonjs/core/instance/types.js +6 -0
  37. package/lib/commonjs/core/instance/types.js.map +1 -0
  38. package/lib/commonjs/core/placementMachine.js +116 -0
  39. package/lib/commonjs/core/placementMachine.js.map +1 -0
  40. package/lib/commonjs/core/privacyGate.js +93 -0
  41. package/lib/commonjs/core/privacyGate.js.map +1 -0
  42. package/lib/commonjs/core/requestThrottle.js +152 -0
  43. package/lib/commonjs/core/requestThrottle.js.map +1 -0
  44. package/lib/commonjs/core/retryPolicy.js +120 -0
  45. package/lib/commonjs/core/retryPolicy.js.map +1 -0
  46. package/lib/commonjs/core/rewardedSession.js +65 -0
  47. package/lib/commonjs/core/rewardedSession.js.map +1 -0
  48. package/lib/commonjs/core/timers.js +162 -0
  49. package/lib/commonjs/core/timers.js.map +1 -0
  50. package/lib/commonjs/diagnostics/correlation.js +33 -0
  51. package/lib/commonjs/diagnostics/correlation.js.map +1 -0
  52. package/lib/commonjs/diagnostics/errors.js +152 -0
  53. package/lib/commonjs/diagnostics/errors.js.map +1 -0
  54. package/lib/commonjs/diagnostics/events.js +132 -0
  55. package/lib/commonjs/diagnostics/events.js.map +1 -0
  56. package/lib/commonjs/engine/admobBanner.js +58 -0
  57. package/lib/commonjs/engine/admobBanner.js.map +1 -0
  58. package/lib/commonjs/engine/admobEngine.js +343 -0
  59. package/lib/commonjs/engine/admobEngine.js.map +1 -0
  60. package/lib/commonjs/engine/admobErrors.js +45 -0
  61. package/lib/commonjs/engine/admobErrors.js.map +1 -0
  62. package/lib/commonjs/engine/port.js +6 -0
  63. package/lib/commonjs/engine/port.js.map +1 -0
  64. package/lib/commonjs/engine/testAdUnits.js +61 -0
  65. package/lib/commonjs/engine/testAdUnits.js.map +1 -0
  66. package/lib/commonjs/index.js +218 -0
  67. package/lib/commonjs/index.js.map +1 -0
  68. package/lib/commonjs/package.json +1 -0
  69. package/lib/commonjs/react/AdsBanner.js +317 -0
  70. package/lib/commonjs/react/AdsBanner.js.map +1 -0
  71. package/lib/commonjs/react/AdsProvider.js +54 -0
  72. package/lib/commonjs/react/AdsProvider.js.map +1 -0
  73. package/lib/commonjs/react/hooks.js +63 -0
  74. package/lib/commonjs/react/hooks.js.map +1 -0
  75. package/lib/commonjs/testing/clock.js +76 -0
  76. package/lib/commonjs/testing/clock.js.map +1 -0
  77. package/lib/commonjs/testing/conformance.js +99 -0
  78. package/lib/commonjs/testing/conformance.js.map +1 -0
  79. package/lib/commonjs/testing/index.js +389 -0
  80. package/lib/commonjs/testing/index.js.map +1 -0
  81. package/lib/module/config/resolveAdUnit.js +75 -0
  82. package/lib/module/config/resolveAdUnit.js.map +1 -0
  83. package/lib/module/config/types.js +134 -0
  84. package/lib/module/config/types.js.map +1 -0
  85. package/lib/module/config/validate.js +146 -0
  86. package/lib/module/config/validate.js.map +1 -0
  87. package/lib/module/core/adOriginatedReturn.js +115 -0
  88. package/lib/module/core/adOriginatedReturn.js.map +1 -0
  89. package/lib/module/core/adsInstance.js +121 -0
  90. package/lib/module/core/adsInstance.js.map +1 -0
  91. package/lib/module/core/consentFlow.js +143 -0
  92. package/lib/module/core/consentFlow.js.map +1 -0
  93. package/lib/module/core/enablement.js +58 -0
  94. package/lib/module/core/enablement.js.map +1 -0
  95. package/lib/module/core/fullScreenLock.js +44 -0
  96. package/lib/module/core/fullScreenLock.js.map +1 -0
  97. package/lib/module/core/gates.js +91 -0
  98. package/lib/module/core/gates.js.map +1 -0
  99. package/lib/module/core/initMachine.js +152 -0
  100. package/lib/module/core/initMachine.js.map +1 -0
  101. package/lib/module/core/instance/consent.js +151 -0
  102. package/lib/module/core/instance/consent.js.map +1 -0
  103. package/lib/module/core/instance/context.js +212 -0
  104. package/lib/module/core/instance/context.js.map +1 -0
  105. package/lib/module/core/instance/gate.js +183 -0
  106. package/lib/module/core/instance/gate.js.map +1 -0
  107. package/lib/module/core/instance/init.js +321 -0
  108. package/lib/module/core/instance/init.js.map +1 -0
  109. package/lib/module/core/instance/internals.js +109 -0
  110. package/lib/module/core/instance/internals.js.map +1 -0
  111. package/lib/module/core/instance/load.js +452 -0
  112. package/lib/module/core/instance/load.js.map +1 -0
  113. package/lib/module/core/instance/show.js +238 -0
  114. package/lib/module/core/instance/show.js.map +1 -0
  115. package/lib/module/core/instance/types.js +4 -0
  116. package/lib/module/core/instance/types.js.map +1 -0
  117. package/lib/module/core/placementMachine.js +109 -0
  118. package/lib/module/core/placementMachine.js.map +1 -0
  119. package/lib/module/core/privacyGate.js +86 -0
  120. package/lib/module/core/privacyGate.js.map +1 -0
  121. package/lib/module/core/requestThrottle.js +146 -0
  122. package/lib/module/core/requestThrottle.js.map +1 -0
  123. package/lib/module/core/retryPolicy.js +113 -0
  124. package/lib/module/core/retryPolicy.js.map +1 -0
  125. package/lib/module/core/rewardedSession.js +61 -0
  126. package/lib/module/core/rewardedSession.js.map +1 -0
  127. package/lib/module/core/timers.js +150 -0
  128. package/lib/module/core/timers.js.map +1 -0
  129. package/lib/module/diagnostics/correlation.js +29 -0
  130. package/lib/module/diagnostics/correlation.js.map +1 -0
  131. package/lib/module/diagnostics/errors.js +143 -0
  132. package/lib/module/diagnostics/errors.js.map +1 -0
  133. package/lib/module/diagnostics/events.js +128 -0
  134. package/lib/module/diagnostics/events.js.map +1 -0
  135. package/lib/module/engine/admobBanner.js +52 -0
  136. package/lib/module/engine/admobBanner.js.map +1 -0
  137. package/lib/module/engine/admobEngine.js +334 -0
  138. package/lib/module/engine/admobEngine.js.map +1 -0
  139. package/lib/module/engine/admobErrors.js +41 -0
  140. package/lib/module/engine/admobErrors.js.map +1 -0
  141. package/lib/module/engine/port.js +4 -0
  142. package/lib/module/engine/port.js.map +1 -0
  143. package/lib/module/engine/testAdUnits.js +56 -0
  144. package/lib/module/engine/testAdUnits.js.map +1 -0
  145. package/lib/module/index.js +59 -0
  146. package/lib/module/index.js.map +1 -0
  147. package/lib/module/package.json +1 -0
  148. package/lib/module/react/AdsBanner.js +312 -0
  149. package/lib/module/react/AdsBanner.js.map +1 -0
  150. package/lib/module/react/AdsProvider.js +48 -0
  151. package/lib/module/react/AdsProvider.js.map +1 -0
  152. package/lib/module/react/hooks.js +58 -0
  153. package/lib/module/react/hooks.js.map +1 -0
  154. package/lib/module/testing/clock.js +72 -0
  155. package/lib/module/testing/clock.js.map +1 -0
  156. package/lib/module/testing/conformance.js +93 -0
  157. package/lib/module/testing/conformance.js.map +1 -0
  158. package/lib/module/testing/index.js +366 -0
  159. package/lib/module/testing/index.js.map +1 -0
  160. package/lib/typescript/commonjs/config/resolveAdUnit.d.ts +43 -0
  161. package/lib/typescript/commonjs/config/resolveAdUnit.d.ts.map +1 -0
  162. package/lib/typescript/commonjs/config/types.d.ts +280 -0
  163. package/lib/typescript/commonjs/config/types.d.ts.map +1 -0
  164. package/lib/typescript/commonjs/config/validate.d.ts +49 -0
  165. package/lib/typescript/commonjs/config/validate.d.ts.map +1 -0
  166. package/lib/typescript/commonjs/core/adOriginatedReturn.d.ts +61 -0
  167. package/lib/typescript/commonjs/core/adOriginatedReturn.d.ts.map +1 -0
  168. package/lib/typescript/commonjs/core/adsInstance.d.ts +33 -0
  169. package/lib/typescript/commonjs/core/adsInstance.d.ts.map +1 -0
  170. package/lib/typescript/commonjs/core/consentFlow.d.ts +84 -0
  171. package/lib/typescript/commonjs/core/consentFlow.d.ts.map +1 -0
  172. package/lib/typescript/commonjs/core/enablement.d.ts +74 -0
  173. package/lib/typescript/commonjs/core/enablement.d.ts.map +1 -0
  174. package/lib/typescript/commonjs/core/fullScreenLock.d.ts +25 -0
  175. package/lib/typescript/commonjs/core/fullScreenLock.d.ts.map +1 -0
  176. package/lib/typescript/commonjs/core/gates.d.ts +76 -0
  177. package/lib/typescript/commonjs/core/gates.d.ts.map +1 -0
  178. package/lib/typescript/commonjs/core/initMachine.d.ts +66 -0
  179. package/lib/typescript/commonjs/core/initMachine.d.ts.map +1 -0
  180. package/lib/typescript/commonjs/core/instance/consent.d.ts +4 -0
  181. package/lib/typescript/commonjs/core/instance/consent.d.ts.map +1 -0
  182. package/lib/typescript/commonjs/core/instance/context.d.ts +118 -0
  183. package/lib/typescript/commonjs/core/instance/context.d.ts.map +1 -0
  184. package/lib/typescript/commonjs/core/instance/gate.d.ts +38 -0
  185. package/lib/typescript/commonjs/core/instance/gate.d.ts.map +1 -0
  186. package/lib/typescript/commonjs/core/instance/init.d.ts +13 -0
  187. package/lib/typescript/commonjs/core/instance/init.d.ts.map +1 -0
  188. package/lib/typescript/commonjs/core/instance/internals.d.ts +60 -0
  189. package/lib/typescript/commonjs/core/instance/internals.d.ts.map +1 -0
  190. package/lib/typescript/commonjs/core/instance/load.d.ts +9 -0
  191. package/lib/typescript/commonjs/core/instance/load.d.ts.map +1 -0
  192. package/lib/typescript/commonjs/core/instance/show.d.ts +7 -0
  193. package/lib/typescript/commonjs/core/instance/show.d.ts.map +1 -0
  194. package/lib/typescript/commonjs/core/instance/types.d.ts +240 -0
  195. package/lib/typescript/commonjs/core/instance/types.d.ts.map +1 -0
  196. package/lib/typescript/commonjs/core/placementMachine.d.ts +55 -0
  197. package/lib/typescript/commonjs/core/placementMachine.d.ts.map +1 -0
  198. package/lib/typescript/commonjs/core/privacyGate.d.ts +40 -0
  199. package/lib/typescript/commonjs/core/privacyGate.d.ts.map +1 -0
  200. package/lib/typescript/commonjs/core/requestThrottle.d.ts +99 -0
  201. package/lib/typescript/commonjs/core/requestThrottle.d.ts.map +1 -0
  202. package/lib/typescript/commonjs/core/retryPolicy.d.ts +66 -0
  203. package/lib/typescript/commonjs/core/retryPolicy.d.ts.map +1 -0
  204. package/lib/typescript/commonjs/core/rewardedSession.d.ts +37 -0
  205. package/lib/typescript/commonjs/core/rewardedSession.d.ts.map +1 -0
  206. package/lib/typescript/commonjs/core/timers.d.ts +135 -0
  207. package/lib/typescript/commonjs/core/timers.d.ts.map +1 -0
  208. package/lib/typescript/commonjs/diagnostics/correlation.d.ts +18 -0
  209. package/lib/typescript/commonjs/diagnostics/correlation.d.ts.map +1 -0
  210. package/lib/typescript/commonjs/diagnostics/errors.d.ts +59 -0
  211. package/lib/typescript/commonjs/diagnostics/errors.d.ts.map +1 -0
  212. package/lib/typescript/commonjs/diagnostics/events.d.ts +126 -0
  213. package/lib/typescript/commonjs/diagnostics/events.d.ts.map +1 -0
  214. package/lib/typescript/commonjs/engine/admobBanner.d.ts +10 -0
  215. package/lib/typescript/commonjs/engine/admobBanner.d.ts.map +1 -0
  216. package/lib/typescript/commonjs/engine/admobEngine.d.ts +71 -0
  217. package/lib/typescript/commonjs/engine/admobEngine.d.ts.map +1 -0
  218. package/lib/typescript/commonjs/engine/admobErrors.d.ts +9 -0
  219. package/lib/typescript/commonjs/engine/admobErrors.d.ts.map +1 -0
  220. package/lib/typescript/commonjs/engine/port.d.ts +171 -0
  221. package/lib/typescript/commonjs/engine/port.d.ts.map +1 -0
  222. package/lib/typescript/commonjs/engine/testAdUnits.d.ts +33 -0
  223. package/lib/typescript/commonjs/engine/testAdUnits.d.ts.map +1 -0
  224. package/lib/typescript/commonjs/index.d.ts +42 -0
  225. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  226. package/lib/typescript/commonjs/package.json +1 -0
  227. package/lib/typescript/commonjs/react/AdsBanner.d.ts +29 -0
  228. package/lib/typescript/commonjs/react/AdsBanner.d.ts.map +1 -0
  229. package/lib/typescript/commonjs/react/AdsProvider.d.ts +36 -0
  230. package/lib/typescript/commonjs/react/AdsProvider.d.ts.map +1 -0
  231. package/lib/typescript/commonjs/react/hooks.d.ts +27 -0
  232. package/lib/typescript/commonjs/react/hooks.d.ts.map +1 -0
  233. package/lib/typescript/commonjs/testing/clock.d.ts +29 -0
  234. package/lib/typescript/commonjs/testing/clock.d.ts.map +1 -0
  235. package/lib/typescript/commonjs/testing/conformance.d.ts +26 -0
  236. package/lib/typescript/commonjs/testing/conformance.d.ts.map +1 -0
  237. package/lib/typescript/commonjs/testing/index.d.ts +133 -0
  238. package/lib/typescript/commonjs/testing/index.d.ts.map +1 -0
  239. package/lib/typescript/module/config/resolveAdUnit.d.ts +43 -0
  240. package/lib/typescript/module/config/resolveAdUnit.d.ts.map +1 -0
  241. package/lib/typescript/module/config/types.d.ts +280 -0
  242. package/lib/typescript/module/config/types.d.ts.map +1 -0
  243. package/lib/typescript/module/config/validate.d.ts +49 -0
  244. package/lib/typescript/module/config/validate.d.ts.map +1 -0
  245. package/lib/typescript/module/core/adOriginatedReturn.d.ts +61 -0
  246. package/lib/typescript/module/core/adOriginatedReturn.d.ts.map +1 -0
  247. package/lib/typescript/module/core/adsInstance.d.ts +33 -0
  248. package/lib/typescript/module/core/adsInstance.d.ts.map +1 -0
  249. package/lib/typescript/module/core/consentFlow.d.ts +84 -0
  250. package/lib/typescript/module/core/consentFlow.d.ts.map +1 -0
  251. package/lib/typescript/module/core/enablement.d.ts +74 -0
  252. package/lib/typescript/module/core/enablement.d.ts.map +1 -0
  253. package/lib/typescript/module/core/fullScreenLock.d.ts +25 -0
  254. package/lib/typescript/module/core/fullScreenLock.d.ts.map +1 -0
  255. package/lib/typescript/module/core/gates.d.ts +76 -0
  256. package/lib/typescript/module/core/gates.d.ts.map +1 -0
  257. package/lib/typescript/module/core/initMachine.d.ts +66 -0
  258. package/lib/typescript/module/core/initMachine.d.ts.map +1 -0
  259. package/lib/typescript/module/core/instance/consent.d.ts +4 -0
  260. package/lib/typescript/module/core/instance/consent.d.ts.map +1 -0
  261. package/lib/typescript/module/core/instance/context.d.ts +118 -0
  262. package/lib/typescript/module/core/instance/context.d.ts.map +1 -0
  263. package/lib/typescript/module/core/instance/gate.d.ts +38 -0
  264. package/lib/typescript/module/core/instance/gate.d.ts.map +1 -0
  265. package/lib/typescript/module/core/instance/init.d.ts +13 -0
  266. package/lib/typescript/module/core/instance/init.d.ts.map +1 -0
  267. package/lib/typescript/module/core/instance/internals.d.ts +60 -0
  268. package/lib/typescript/module/core/instance/internals.d.ts.map +1 -0
  269. package/lib/typescript/module/core/instance/load.d.ts +9 -0
  270. package/lib/typescript/module/core/instance/load.d.ts.map +1 -0
  271. package/lib/typescript/module/core/instance/show.d.ts +7 -0
  272. package/lib/typescript/module/core/instance/show.d.ts.map +1 -0
  273. package/lib/typescript/module/core/instance/types.d.ts +240 -0
  274. package/lib/typescript/module/core/instance/types.d.ts.map +1 -0
  275. package/lib/typescript/module/core/placementMachine.d.ts +55 -0
  276. package/lib/typescript/module/core/placementMachine.d.ts.map +1 -0
  277. package/lib/typescript/module/core/privacyGate.d.ts +40 -0
  278. package/lib/typescript/module/core/privacyGate.d.ts.map +1 -0
  279. package/lib/typescript/module/core/requestThrottle.d.ts +99 -0
  280. package/lib/typescript/module/core/requestThrottle.d.ts.map +1 -0
  281. package/lib/typescript/module/core/retryPolicy.d.ts +66 -0
  282. package/lib/typescript/module/core/retryPolicy.d.ts.map +1 -0
  283. package/lib/typescript/module/core/rewardedSession.d.ts +37 -0
  284. package/lib/typescript/module/core/rewardedSession.d.ts.map +1 -0
  285. package/lib/typescript/module/core/timers.d.ts +135 -0
  286. package/lib/typescript/module/core/timers.d.ts.map +1 -0
  287. package/lib/typescript/module/diagnostics/correlation.d.ts +18 -0
  288. package/lib/typescript/module/diagnostics/correlation.d.ts.map +1 -0
  289. package/lib/typescript/module/diagnostics/errors.d.ts +59 -0
  290. package/lib/typescript/module/diagnostics/errors.d.ts.map +1 -0
  291. package/lib/typescript/module/diagnostics/events.d.ts +126 -0
  292. package/lib/typescript/module/diagnostics/events.d.ts.map +1 -0
  293. package/lib/typescript/module/engine/admobBanner.d.ts +10 -0
  294. package/lib/typescript/module/engine/admobBanner.d.ts.map +1 -0
  295. package/lib/typescript/module/engine/admobEngine.d.ts +71 -0
  296. package/lib/typescript/module/engine/admobEngine.d.ts.map +1 -0
  297. package/lib/typescript/module/engine/admobErrors.d.ts +9 -0
  298. package/lib/typescript/module/engine/admobErrors.d.ts.map +1 -0
  299. package/lib/typescript/module/engine/port.d.ts +171 -0
  300. package/lib/typescript/module/engine/port.d.ts.map +1 -0
  301. package/lib/typescript/module/engine/testAdUnits.d.ts +33 -0
  302. package/lib/typescript/module/engine/testAdUnits.d.ts.map +1 -0
  303. package/lib/typescript/module/index.d.ts +42 -0
  304. package/lib/typescript/module/index.d.ts.map +1 -0
  305. package/lib/typescript/module/package.json +1 -0
  306. package/lib/typescript/module/react/AdsBanner.d.ts +29 -0
  307. package/lib/typescript/module/react/AdsBanner.d.ts.map +1 -0
  308. package/lib/typescript/module/react/AdsProvider.d.ts +36 -0
  309. package/lib/typescript/module/react/AdsProvider.d.ts.map +1 -0
  310. package/lib/typescript/module/react/hooks.d.ts +27 -0
  311. package/lib/typescript/module/react/hooks.d.ts.map +1 -0
  312. package/lib/typescript/module/testing/clock.d.ts +29 -0
  313. package/lib/typescript/module/testing/clock.d.ts.map +1 -0
  314. package/lib/typescript/module/testing/conformance.d.ts +26 -0
  315. package/lib/typescript/module/testing/conformance.d.ts.map +1 -0
  316. package/lib/typescript/module/testing/index.d.ts +133 -0
  317. package/lib/typescript/module/testing/index.d.ts.map +1 -0
  318. package/package.json +48 -12
  319. package/src/testing/index.ts +17 -3
@@ -0,0 +1,243 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createShower = createShower;
7
+ var _types = require("../../config/types.js");
8
+ var _errors = require("../../diagnostics/errors.js");
9
+ var _placementMachine = require("../placementMachine.js");
10
+ var _rewardedSession = require("../rewardedSession.js");
11
+ var _timers = require("../timers.js");
12
+ var _context = require("./context.js");
13
+ var _gate = require("./gate.js");
14
+ var _load = require("./load.js");
15
+ /**
16
+ * Showing full-screen ads (FR-028, FR-030, FR-034, FR-128) and the foreground
17
+ * re-evaluation of what was loaded.
18
+ */
19
+
20
+ function createShower(context) {
21
+ const {
22
+ state,
23
+ engine,
24
+ events,
25
+ timers,
26
+ resolved,
27
+ lock,
28
+ adReturn,
29
+ now
30
+ } = context;
31
+
32
+ /** Releases and expires a `ready` ad that outlived its validity (FR-034). */
33
+ function expireIfStale(key, at) {
34
+ const found = context.placement(key);
35
+ if (!found) {
36
+ return false;
37
+ }
38
+ const {
39
+ snapshot
40
+ } = found.runtime;
41
+ if (snapshot.state !== 'ready' || snapshot.loadedAtMs === null || !(0, _timers.isStale)(snapshot.loadedAtMs, at, (0, _context.validityFor)(context, found.definition.format))) {
42
+ return false;
43
+ }
44
+ context.releasePlacementResources(key);
45
+ context.dispatchPlacement(key, {
46
+ type: 'EXPIRE'
47
+ });
48
+ return true;
49
+ }
50
+ return {
51
+ async show(placementKey) {
52
+ if (state.disposed) {
53
+ return {
54
+ status: 'unavailable',
55
+ reason: 'provider_missing'
56
+ };
57
+ }
58
+ const found = context.placement(placementKey);
59
+ if (!found) {
60
+ return (0, _load.unknownPlacement)(context, placementKey, 'show');
61
+ }
62
+ const {
63
+ runtime,
64
+ definition
65
+ } = found;
66
+ if (!(0, _types.isFullScreenFormat)(definition.format)) {
67
+ return {
68
+ status: 'failed',
69
+ error: new _errors.AdsError('format_mismatch', {
70
+ operation: 'show',
71
+ placementKey,
72
+ format: definition.format,
73
+ message: `"${placementKey}" is a banner; banners are rendered, not shown`
74
+ })
75
+ };
76
+ }
77
+ const refusal = (0, _gate.gateRefusal)(context);
78
+ if (refusal) {
79
+ context.emitRefusal('show', refusal, placementKey, definition.format);
80
+ return refusal;
81
+ }
82
+ // FR-028: never open an ad while the app is not in front of the user.
83
+ if (!state.appActive) {
84
+ return {
85
+ status: 'app_inactive'
86
+ };
87
+ }
88
+ // FR-128. Only app-open is refused: it is the format that would fire on
89
+ // the return from an ad. An interstitial at the same moment is the app's
90
+ // own choice, and refusing it would be policy rather than capability.
91
+ if (definition.format === 'app_open' && adReturn.isRefusing(now())) {
92
+ return {
93
+ status: 'ad_originated_return'
94
+ };
95
+ }
96
+ if (runtime.snapshot.state === 'consumed') {
97
+ return {
98
+ status: 'consumed'
99
+ };
100
+ }
101
+ // FR-034: a stale ad is not shown and is not reported ready.
102
+ if (expireIfStale(placementKey, now())) {
103
+ return {
104
+ status: 'not_ready'
105
+ };
106
+ }
107
+ const handle = runtime.handle;
108
+ if (!(0, _placementMachine.canShow)(runtime.snapshot.state) || !handle) {
109
+ return {
110
+ status: 'not_ready'
111
+ };
112
+ }
113
+ // FR-030. Never queued: a refused show is refused now, not deferred to a
114
+ // moment the app never chose.
115
+ if (!lock.acquire(placementKey)) {
116
+ return {
117
+ status: 'busy'
118
+ };
119
+ }
120
+ const correlationId = runtime.correlationId ?? context.correlation.next();
121
+ runtime.rewarded = definition.format === 'rewarded' ? (0, _rewardedSession.createRewardedSession)() : null;
122
+ context.dispatchPlacement(placementKey, {
123
+ type: 'SHOW'
124
+ });
125
+ const failShow = error => {
126
+ lock.release(placementKey);
127
+ events.emit({
128
+ type: 'display_failed',
129
+ timestamp: now(),
130
+ placementKey,
131
+ format: definition.format,
132
+ correlationId,
133
+ error
134
+ });
135
+ context.dispatchPlacement(placementKey, {
136
+ type: 'SHOW_FAILED',
137
+ error
138
+ });
139
+ context.releasePlacementResources(placementKey);
140
+ };
141
+
142
+ // ADS-09. Whichever of the provider's answer and the timeout comes first
143
+ // decides the result; the other must not act on it a second time.
144
+ let settled = false;
145
+ const showTimeout = new Promise(resolve => {
146
+ runtime.cancelShowTimer = timers.after(resolved.timeouts.show, () => {
147
+ runtime.cancelShowTimer = null;
148
+ if (settled) {
149
+ return;
150
+ }
151
+ settled = true;
152
+ // The provider may still open the ad. Its handle and listener stay, so
153
+ // a late open, reward or dismissal is still heard and the reward is not
154
+ // lost (FR-049); they go with the next load or with dispose. The lock is
155
+ // released now and taken back if the ad does open.
156
+ lock.release(placementKey);
157
+ const error = new _errors.AdsError('show_timeout', {
158
+ operation: 'show',
159
+ placementKey,
160
+ format: definition.format,
161
+ message: `show timed out after ${resolved.timeouts.show}ms`
162
+ });
163
+ events.emit({
164
+ type: 'display_failed',
165
+ timestamp: now(),
166
+ placementKey,
167
+ format: definition.format,
168
+ correlationId,
169
+ error
170
+ });
171
+ context.dispatchPlacement(placementKey, {
172
+ type: 'SHOW_FAILED',
173
+ error
174
+ });
175
+ resolve({
176
+ status: 'timeout'
177
+ });
178
+ });
179
+ });
180
+ const attempt = engine.show(handle).then(() => {
181
+ if (settled) {
182
+ // Opened after the timeout was reported. It is on screen now, so it
183
+ // holds the one full-screen lock until it is dismissed (FR-030).
184
+ lock.acquire(placementKey);
185
+ return {
186
+ status: 'timeout'
187
+ };
188
+ }
189
+ settled = true;
190
+ runtime.cancelShowTimer?.();
191
+ runtime.cancelShowTimer = null;
192
+ return {
193
+ status: 'shown',
194
+ correlationId
195
+ };
196
+ }).catch(error => {
197
+ if (settled) {
198
+ // Failed after the timeout already said so: nothing new to report,
199
+ // and nothing will show, so its resources can go.
200
+ context.releasePlacementResources(placementKey);
201
+ return {
202
+ status: 'timeout'
203
+ };
204
+ }
205
+ settled = true;
206
+ runtime.cancelShowTimer?.();
207
+ runtime.cancelShowTimer = null;
208
+ const normalized = (0, _errors.normalizeProviderError)(error, {
209
+ operation: 'show',
210
+ placementKey,
211
+ format: definition.format
212
+ });
213
+ failShow(normalized);
214
+ return {
215
+ status: 'failed',
216
+ error: normalized
217
+ };
218
+ });
219
+ return Promise.race([attempt, showTimeout]);
220
+ },
221
+ setAppActive(active) {
222
+ if (state.disposed) {
223
+ return;
224
+ }
225
+ state.appActive = active;
226
+ if (!active) {
227
+ // Arming happens when the provider reports an ad opened; this event can
228
+ // arrive after the ad is gone. All it adds is the browser case, a
229
+ // background closely following a click (FR-128).
230
+ adReturn.noteBackground(now());
231
+ return;
232
+ }
233
+ adReturn.noteForeground(now());
234
+ // FR-034: an ad that went stale while the app was away stops reporting
235
+ // `ready` before the app offers a button that would fail on tap.
236
+ const current = now();
237
+ for (const key of context.placements.keys()) {
238
+ expireIfStale(key, current);
239
+ }
240
+ }
241
+ };
242
+ }
243
+ //# sourceMappingURL=show.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_types","require","_errors","_placementMachine","_rewardedSession","_timers","_context","_gate","_load","createShower","context","state","engine","events","timers","resolved","lock","adReturn","now","expireIfStale","key","at","found","placement","snapshot","runtime","loadedAtMs","isStale","validityFor","definition","format","releasePlacementResources","dispatchPlacement","type","show","placementKey","disposed","status","reason","unknownPlacement","isFullScreenFormat","error","AdsError","operation","message","refusal","gateRefusal","emitRefusal","appActive","isRefusing","handle","canShow","acquire","correlationId","correlation","next","rewarded","createRewardedSession","failShow","release","emit","timestamp","settled","showTimeout","Promise","resolve","cancelShowTimer","after","timeouts","attempt","then","catch","normalized","normalizeProviderError","race","setAppActive","active","noteBackground","noteForeground","current","placements","keys"],"sourceRoot":"../../../../src","sources":["core/instance/show.ts"],"mappings":";;;;;;AAIA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AAXA;AACA;AACA;AACA;;AAWO,SAASQ,YAAYA,CAACC,OAAwB,EAGnD;EACD,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,QAAQ;IAAEC;EAAI,CAAC,GAAGR,OAAO;;EAEhF;EACA,SAASS,aAAaA,CAACC,GAAW,EAAEC,EAAU,EAAW;IACxD,MAAMC,KAAK,GAAGZ,OAAO,CAACa,SAAS,CAACH,GAAG,CAAC;IACpC,IAAI,CAACE,KAAK,EAAE;MACX,OAAO,KAAK;IACb;IACA,MAAM;MAAEE;IAAS,CAAC,GAAGF,KAAK,CAACG,OAAO;IAClC,IACCD,QAAQ,CAACb,KAAK,KAAK,OAAO,IAC1Ba,QAAQ,CAACE,UAAU,KAAK,IAAI,IAC5B,CAAC,IAAAC,eAAO,EAACH,QAAQ,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,MAAM;MACxB,IAAI,CAACA,MAAM,EAAE;QACZ;QACA;QACA;QACA3D,QAAQ,CAAC4D,cAAc,CAAC3D,GAAG,CAAC,CAAC,CAAC;QAC9B;MACD;MACAD,QAAQ,CAAC6D,cAAc,CAAC5D,GAAG,CAAC,CAAC,CAAC;MAC9B;MACA;MACA,MAAM6D,OAAO,GAAG7D,GAAG,CAAC,CAAC;MACrB,KAAK,MAAME,GAAG,IAAIV,OAAO,CAACsE,UAAU,CAACC,IAAI,CAAC,CAAC,EAAE;QAC5C9D,aAAa,CAACC,GAAG,EAAE2D,OAAO,CAAC;MAC5B;IACD;EACD,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["core/instance/types.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.canLoad = canLoad;
7
+ exports.canShow = canShow;
8
+ exports.initialPlacement = void 0;
9
+ exports.placementReducer = placementReducer;
10
+ /**
11
+ * Per-placement lifecycle (FR-026 – FR-031, FR-034).
12
+ *
13
+ * Pure and synchronous, per data-model.md §3.2. Two variants share one reducer:
14
+ *
15
+ * full-screen — load, show once, become `consumed`, reload before the next show
16
+ * banner — continuous; it renders and may refresh, and never reaches
17
+ * `consumed`, because a banner is not a single-use resource
18
+ *
19
+ * Staleness is handled here rather than at the show site so that a stale ad can
20
+ * never be *reported* ready either — a consumer that renders a "Watch ad" button
21
+ * from `state === 'ready'` would otherwise offer a button that fails on tap.
22
+ */
23
+
24
+ const initialPlacement = exports.initialPlacement = {
25
+ state: 'idle',
26
+ loadedAtMs: null,
27
+ error: null,
28
+ correlationId: null
29
+ };
30
+
31
+ /**
32
+ * A load is only legal from a settled state; `loading` is where FR-029 bites.
33
+ * `throttled` is settled too: it records that the last request was refused, and
34
+ * the throttle itself decides whether the next one may proceed.
35
+ */
36
+ function canLoad(state) {
37
+ return state === 'idle' || state === 'failed' || state === 'consumed' || state === 'ready' || state === 'throttled';
38
+ }
39
+
40
+ /** Only a ready ad may be shown. Everything else is a determinate refusal (FR-028). */
41
+ function canShow(state) {
42
+ return state === 'ready';
43
+ }
44
+ function placementReducer(state, event, format) {
45
+ switch (event.type) {
46
+ case 'LOAD':
47
+ // FR-029: a load while already loading is absorbed. The instance
48
+ // returns the in-flight promise; the state does not restart.
49
+ if (state.state === 'loading' || state.state === 'showing') {
50
+ return state;
51
+ }
52
+ if (state.state === 'unavailable') {
53
+ return state;
54
+ }
55
+ return {
56
+ ...initialPlacement,
57
+ state: 'loading'
58
+ };
59
+ case 'LOADED':
60
+ return state.state === 'loading' ? {
61
+ ...state,
62
+ state: 'ready',
63
+ loadedAtMs: event.atMs,
64
+ error: null
65
+ } : state;
66
+ case 'LOAD_FAILED':
67
+ return state.state === 'loading' ? {
68
+ ...initialPlacement,
69
+ state: 'failed',
70
+ error: event.error
71
+ } : state;
72
+ case 'SHOW':
73
+ return state.state === 'ready' ? {
74
+ ...state,
75
+ state: 'showing'
76
+ } : state;
77
+ case 'SHOW_FAILED':
78
+ // A failed presentation consumes the ad regardless: the provider has
79
+ // taken it, and re-showing the same object is what FR-031 forbids.
80
+ return state.state === 'showing' ? {
81
+ ...initialPlacement,
82
+ state: 'failed',
83
+ error: event.error
84
+ } : state;
85
+ case 'DISMISSED':
86
+ if (state.state !== 'showing') {
87
+ return state;
88
+ }
89
+ // A banner is continuous — dismissal is not part of its life. A
90
+ // full-screen ad is spent, and must be reloaded before the next show.
91
+ return format === 'banner' ? {
92
+ ...initialPlacement,
93
+ state: 'idle'
94
+ } : {
95
+ ...initialPlacement,
96
+ state: 'consumed'
97
+ };
98
+ case 'EXPIRE':
99
+ // FR-034. Only a ready-and-waiting ad can go stale; one being shown is
100
+ // already in the user's hands.
101
+ return state.state === 'ready' ? {
102
+ ...initialPlacement,
103
+ state: 'idle'
104
+ } : state;
105
+ case 'UNAVAILABLE':
106
+ return {
107
+ ...initialPlacement,
108
+ state: 'unavailable'
109
+ };
110
+ case 'RESET':
111
+ return initialPlacement;
112
+ default:
113
+ return state;
114
+ }
115
+ }
116
+ //# sourceMappingURL=placementMachine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["initialPlacement","exports","state","loadedAtMs","error","correlationId","canLoad","canShow","placementReducer","event","format","type","atMs"],"sourceRoot":"../../../src","sources":["core/placementMachine.ts"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuBO,MAAMA,gBAAmC,GAAAC,OAAA,CAAAD,gBAAA,GAAG;EAClDE,KAAK,EAAE,MAAM;EACbC,UAAU,EAAE,IAAI;EAChBC,KAAK,EAAE,IAAI;EACXC,aAAa,EAAE;AAChB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACO,SAASC,OAAOA,CAACJ,KAAqB,EAAW;EACvD,OACCA,KAAK,KAAK,MAAM,IAChBA,KAAK,KAAK,QAAQ,IAClBA,KAAK,KAAK,UAAU,IACpBA,KAAK,KAAK,OAAO,IACjBA,KAAK,KAAK,WAAW;AAEvB;;AAEA;AACO,SAASK,OAAOA,CAACL,KAAqB,EAAW;EACvD,OAAOA,KAAK,KAAK,OAAO;AACzB;AAEO,SAASM,gBAAgBA,CAC/BN,KAAwB,EACxBO,KAAqB,EACrBC,MAAgB,EACI;EACpB,QAAQD,KAAK,CAACE,IAAI;IACjB,KAAK,MAAM;MACV;MACA;MACA,IAAIT,KAAK,CAACA,KAAK,KAAK,SAAS,IAAIA,KAAK,CAACA,KAAK,KAAK,SAAS,EAAE;QAC3D,OAAOA,KAAK;MACb;MACA,IAAIA,KAAK,CAACA,KAAK,KAAK,aAAa,EAAE;QAClC,OAAOA,KAAK;MACb;MACA,OAAO;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AAO;MACX,OAAOF,gBAAgB;IAExB;MACC,OAAOE,KAAK;EACd;AACD","ignoreList":[]}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.evaluateGate = evaluateGate;
7
+ exports.requiresReinitialization = requiresReinitialization;
8
+ exports.toEnginePrivacy = toEnginePrivacy;
9
+ exports.toEngineRequest = toEngineRequest;
10
+ /**
11
+ * The privacy gate (FR-016 – FR-021).
12
+ *
13
+ * The package enforces ordering; the app owns policy. It renders no consent UI,
14
+ * writes no legal copy, and decides nothing about a jurisdiction — it accepts a
15
+ * gate outcome and refuses to let any request precede it.
16
+ *
17
+ * That refusal is the whole value. Consent ordering is easy to get wrong by
18
+ * accident, and the failure is invisible: an ad request that should not have
19
+ * happened looks exactly like one that should. A package that enforces the order
20
+ * is worth more than documentation that describes it.
21
+ *
22
+ * Pure — no provider, no React, no I/O. The engine adapter translates the
23
+ * outcome into provider configuration.
24
+ */
25
+
26
+ function evaluateGate(privacy) {
27
+ if (!privacy) {
28
+ return {
29
+ allowed: false,
30
+ reason: 'consent_required'
31
+ };
32
+ }
33
+ if (privacy.canRequestAds) {
34
+ return {
35
+ allowed: true
36
+ };
37
+ }
38
+ // Distinguishing "not asked yet" from "asked and refused" matters: the first
39
+ // is a prompt the app still owes the user, the second is a settled answer.
40
+ // Collapsing them would leave the app unable to tell which (FR-018).
41
+ return {
42
+ allowed: false,
43
+ reason: privacy.consentUndetermined ? 'consent_undetermined' : 'consent_required'
44
+ };
45
+ }
46
+
47
+ /**
48
+ * Flags the provider only honors at initialization time.
49
+ *
50
+ * Changing one of these after `initialize()` cannot take effect, which is why
51
+ * `updatePrivacy` reports `requires_reinitialization` instead of accepting the
52
+ * change and leaving the package in a state that is half old and half new
53
+ * (FR-020).
54
+ *
55
+ * `canRequestAds` is absent on purpose: resolving the gate after being blocked
56
+ * is the normal, supported flow, not a reinitialization (FR-019).
57
+ */
58
+ const INIT_TIME_ONLY = ['childDirected', 'underAgeOfConsent', 'maxAdContentRating'];
59
+ function requiresReinitialization(applied, next) {
60
+ if (!applied) {
61
+ return false;
62
+ }
63
+ return INIT_TIME_ONLY.some(field => applied[field] !== next[field]);
64
+ }
65
+
66
+ /**
67
+ * Projects consumer privacy options onto what the engine needs.
68
+ *
69
+ * `personalizedAds` is carried through rather than inverted here; the adapter
70
+ * owns the translation to the provider's `requestNonPersonalizedAdsOnly`, so
71
+ * the polarity flip lives next to the API that requires it.
72
+ */
73
+ function toEnginePrivacy(privacy, testDeviceIds) {
74
+ return {
75
+ childDirected: privacy.childDirected,
76
+ underAgeOfConsent: privacy.underAgeOfConsent,
77
+ maxAdContentRating: privacy.maxAdContentRating,
78
+ personalizedAds: privacy.personalizedAds,
79
+ testDeviceIds
80
+ };
81
+ }
82
+
83
+ /**
84
+ * What every ad request carries. Unset means personalized, matching the
85
+ * documented default of `PrivacyOptions.personalizedAds`; only an explicit
86
+ * `false` opts out.
87
+ */
88
+ function toEngineRequest(privacy) {
89
+ return {
90
+ personalizedAds: privacy?.personalizedAds !== false
91
+ };
92
+ }
93
+ //# sourceMappingURL=privacyGate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["evaluateGate","privacy","allowed","reason","canRequestAds","consentUndetermined","INIT_TIME_ONLY","requiresReinitialization","applied","next","some","field","toEnginePrivacy","testDeviceIds","childDirected","underAgeOfConsent","maxAdContentRating","personalizedAds","toEngineRequest"],"sourceRoot":"../../../src","sources":["core/privacyGate.ts"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQO,SAASA,YAAYA,CAACC,OAA8B,EAAgB;EAC1E,IAAI,CAACA,OAAO,EAAE;IACb,OAAO;MAAEC,OAAO,EAAE,KAAK;MAAEC,MAAM,EAAE;IAAmB,CAAC;EACtD;EACA,IAAIF,OAAO,CAACG,aAAa,EAAE;IAC1B,OAAO;MAAEF,OAAO,EAAE;IAAK,CAAC;EACzB;EACA;EACA;EACA;EACA,OAAO;IACNA,OAAO,EAAE,KAAK;IACdC,MAAM,EAAEF,OAAO,CAACI,mBAAmB,GAAG,sBAAsB,GAAG;EAChE,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAAG,CACtB,eAAe,EACf,mBAAmB,EACnB,oBAAoB,CACiC;AAE/C,SAASC,wBAAwBA,CACvCC,OAA8B,EAC9BC,IAAoB,EACV;EACV,IAAI,CAACD,OAAO,EAAE;IACb,OAAO,KAAK;EACb;EACA,OAAOF,cAAc,CAACI,IAAI,CAACC,KAAK,IAAIH,OAAO,CAACG,KAAK,CAAC,KAAKF,IAAI,CAACE,KAAK,CAAC,CAAC;AACpE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAC9BX,OAAuB,EACvBY,aAAgC,EAChB;EAChB,OAAO;IACNC,aAAa,EAAEb,OAAO,CAACa,aAAa;IACpCC,iBAAiB,EAAEd,OAAO,CAACc,iBAAiB;IAC5CC,kBAAkB,EAAEf,OAAO,CAACe,kBAAkB;IAC9CC,eAAe,EAAEhB,OAAO,CAACgB,eAAe;IACxCJ;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASK,eAAeA,CAACjB,OAA8B,EAAwB;EACrF,OAAO;IAAEgB,eAAe,EAAEhB,OAAO,EAAEgB,eAAe,KAAK;EAAM,CAAC;AAC/D","ignoreList":[]}
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MIN_REQUEST_INTERVAL_BOUNDS = exports.DEFAULT_FULL_SCREEN_MIN_REQUEST_INTERVAL_MS = exports.DEFAULT_BANNER_MIN_REQUEST_INTERVAL_MS = void 0;
7
+ exports.createRequestThrottle = createRequestThrottle;
8
+ exports.defaultMinRequestIntervalMs = defaultMinRequestIntervalMs;
9
+ /**
10
+ * Per-placement request throttle (FR-140).
11
+ *
12
+ * This exists to protect the **ad account**, not to shape product behaviour, and
13
+ * that distinction is the whole reason it lives in the package:
14
+ *
15
+ * | Decision | Owner |
16
+ * |---|---|
17
+ * | How often to *show* an interstitial | the app — product policy |
18
+ * | How often the same placement may *request* | the package — account safety |
19
+ *
20
+ * Rapid repeat requests for one placement are read by ad networks as invalid
21
+ * traffic, and the penalty is account-level and not recoverable by shipping a
22
+ * fix. That puts it in the same class as the test-ad substitution the package
23
+ * already enforces: a safety property the library guarantees rather than
24
+ * documents and hopes each app remembers.
25
+ *
26
+ * ## The pattern it is built for
27
+ *
28
+ * A banner mounted inside a view the user navigates between — a day in a
29
+ * calendar, a tab, a row in a list — is unmounted and remounted by React on every
30
+ * navigation. Each remount is a fresh provider request. A user swiping quickly
31
+ * through ten days produces ten requests in a few seconds, and nothing about that
32
+ * is the app author doing something wrong.
33
+ *
34
+ * Full-screen formats do not have this problem: they are loaded by an explicit
35
+ * call, not mounted by a renderer. That asymmetry is why the default differs by
36
+ * format — see `defaultMinRequestIntervalMs`.
37
+ *
38
+ * The better *architectural* answer is to keep the banner outside the subtree that
39
+ * remounts. This throttle is the safety net for when that is not possible, not a
40
+ * licence to ignore the problem; the README says so where an app author will read
41
+ * it.
42
+ */
43
+
44
+ /**
45
+ * AdMob's own documented floor for banner auto-refresh is 60 seconds, so
46
+ * requesting the same banner placement more often than that is, by the provider's
47
+ * own standard, more often than it considers reasonable. Taking the provider's
48
+ * number rather than inventing one means the default is defensible rather than
49
+ * arbitrary.
50
+ */
51
+ const DEFAULT_BANNER_MIN_REQUEST_INTERVAL_MS = exports.DEFAULT_BANNER_MIN_REQUEST_INTERVAL_MS = 60_000;
52
+
53
+ /**
54
+ * Off by default for full-screen formats.
55
+ *
56
+ * `load` → `show` → `load` is the normal, healthy cycle for an interstitial, and
57
+ * an app that sells three things in two minutes legitimately loads three times.
58
+ * Throttling that by default would break correct apps to solve a problem those
59
+ * formats do not have. An app that wants a floor here can set one.
60
+ */
61
+ const DEFAULT_FULL_SCREEN_MIN_REQUEST_INTERVAL_MS = exports.DEFAULT_FULL_SCREEN_MIN_REQUEST_INTERVAL_MS = 0;
62
+ const MIN_REQUEST_INTERVAL_BOUNDS = exports.MIN_REQUEST_INTERVAL_BOUNDS = {
63
+ min: 0,
64
+ max: 600_000
65
+ };
66
+
67
+ /** The format-aware default, applied when a placement configures nothing. */
68
+ function defaultMinRequestIntervalMs(format) {
69
+ return format === 'banner' ? DEFAULT_BANNER_MIN_REQUEST_INTERVAL_MS : DEFAULT_FULL_SCREEN_MIN_REQUEST_INTERVAL_MS;
70
+ }
71
+ function createRequestThrottle(now) {
72
+ const lastAt = new Map();
73
+ /** The token and verdict of the most recent acquisition, for idempotency. */
74
+ const lastToken = new Map();
75
+ const decide = (key, minIntervalMs) => {
76
+ // Zero is the documented way to turn the throttle off, so it must never
77
+ // consult the clock — an app that sets 0 should behave exactly as it did
78
+ // before this feature existed.
79
+ if (minIntervalMs <= 0) {
80
+ return {
81
+ allowed: true
82
+ };
83
+ }
84
+ const previous = lastAt.get(key);
85
+ if (previous === undefined) {
86
+ return {
87
+ allowed: true
88
+ };
89
+ }
90
+ const elapsed = now() - previous;
91
+ // A clock that moved backwards — a manual time change, or an NTP
92
+ // correction — must not lock a placement out until the clock catches up.
93
+ // Treating it as "enough time passed" fails open, which is right: the
94
+ // throttle protects against bursts, and a backwards clock is not a burst.
95
+ if (elapsed < 0) {
96
+ return {
97
+ allowed: true
98
+ };
99
+ }
100
+ if (elapsed >= minIntervalMs) {
101
+ return {
102
+ allowed: true
103
+ };
104
+ }
105
+ return {
106
+ allowed: false,
107
+ retryAfterMs: minIntervalMs - elapsed
108
+ };
109
+ };
110
+ return {
111
+ waitFor(key, minIntervalMs) {
112
+ const decision = decide(key, minIntervalMs);
113
+ return decision.allowed ? 0 : decision.retryAfterMs;
114
+ },
115
+ tryAcquire(key, minIntervalMs, token) {
116
+ if (token !== undefined) {
117
+ const previous = lastToken.get(key);
118
+ if (previous?.token === token) {
119
+ // Same cycle asking again. Replaying the stored verdict keeps a
120
+ // double-invoked render from charging twice, and keeps a refused
121
+ // cycle refused rather than letting a retry slip through.
122
+ return previous.decision;
123
+ }
124
+ }
125
+
126
+ // Nothing is recorded when the throttle is off for this placement.
127
+ // Recording would be dead work, and it would also mean that turning the
128
+ // throttle on later immediately compared against a stale timestamp.
129
+ if (minIntervalMs <= 0) {
130
+ return {
131
+ allowed: true
132
+ };
133
+ }
134
+ const decision = decide(key, minIntervalMs);
135
+ if (decision.allowed) {
136
+ lastAt.set(key, now());
137
+ }
138
+ if (token !== undefined) {
139
+ lastToken.set(key, {
140
+ token,
141
+ decision
142
+ });
143
+ }
144
+ return decision;
145
+ },
146
+ clear() {
147
+ lastAt.clear();
148
+ lastToken.clear();
149
+ }
150
+ };
151
+ }
152
+ //# sourceMappingURL=requestThrottle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DEFAULT_BANNER_MIN_REQUEST_INTERVAL_MS","exports","DEFAULT_FULL_SCREEN_MIN_REQUEST_INTERVAL_MS","MIN_REQUEST_INTERVAL_BOUNDS","min","max","defaultMinRequestIntervalMs","format","createRequestThrottle","now","lastAt","Map","lastToken","decide","key","minIntervalMs","allowed","previous","get","undefined","elapsed","retryAfterMs","waitFor","decision","tryAcquire","token","set","clear"],"sourceRoot":"../../../src","sources":["core/requestThrottle.ts"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,sCAAsC,GAAAC,OAAA,CAAAD,sCAAA,GAAG,MAAM;;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,2CAA2C,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