@chipmobilesdk/rn-ads 0.6.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 (340) hide show
  1. package/CHANGELOG.md +139 -0
  2. package/README.md +4 -2
  3. package/lib/commonjs/config/resolveAdUnit.js +80 -0
  4. package/lib/commonjs/config/resolveAdUnit.js.map +1 -0
  5. package/lib/commonjs/config/types.js +138 -0
  6. package/lib/commonjs/config/types.js.map +1 -0
  7. package/lib/commonjs/config/validate.js +150 -0
  8. package/lib/commonjs/config/validate.js.map +1 -0
  9. package/lib/commonjs/core/adOriginatedReturn.js +119 -0
  10. package/lib/commonjs/core/adOriginatedReturn.js.map +1 -0
  11. package/lib/commonjs/core/adsInstance.js +129 -0
  12. package/lib/commonjs/core/adsInstance.js.map +1 -0
  13. package/lib/commonjs/core/consentFlow.js +154 -0
  14. package/lib/commonjs/core/consentFlow.js.map +1 -0
  15. package/lib/commonjs/core/enablement.js +64 -0
  16. package/lib/commonjs/core/enablement.js.map +1 -0
  17. package/lib/commonjs/core/fullScreenLock.js +48 -0
  18. package/lib/commonjs/core/fullScreenLock.js.map +1 -0
  19. package/lib/commonjs/core/gates.js +95 -0
  20. package/lib/commonjs/core/gates.js.map +1 -0
  21. package/lib/commonjs/core/initMachine.js +159 -0
  22. package/lib/commonjs/core/initMachine.js.map +1 -0
  23. package/lib/commonjs/core/instance/consent.js +155 -0
  24. package/lib/commonjs/core/instance/consent.js.map +1 -0
  25. package/lib/commonjs/core/instance/context.js +217 -0
  26. package/lib/commonjs/core/instance/context.js.map +1 -0
  27. package/lib/commonjs/core/instance/gate.js +194 -0
  28. package/lib/commonjs/core/instance/gate.js.map +1 -0
  29. package/lib/commonjs/core/instance/init.js +326 -0
  30. package/lib/commonjs/core/instance/init.js.map +1 -0
  31. package/lib/commonjs/core/instance/internals.js +115 -0
  32. package/lib/commonjs/core/instance/internals.js.map +1 -0
  33. package/lib/commonjs/core/instance/load.js +458 -0
  34. package/lib/commonjs/core/instance/load.js.map +1 -0
  35. package/lib/commonjs/core/instance/show.js +243 -0
  36. package/lib/commonjs/core/instance/show.js.map +1 -0
  37. package/lib/commonjs/core/instance/types.js +6 -0
  38. package/lib/commonjs/core/instance/types.js.map +1 -0
  39. package/lib/commonjs/core/placementMachine.js +116 -0
  40. package/lib/commonjs/core/placementMachine.js.map +1 -0
  41. package/lib/commonjs/core/privacyGate.js +93 -0
  42. package/lib/commonjs/core/privacyGate.js.map +1 -0
  43. package/lib/commonjs/core/requestThrottle.js +152 -0
  44. package/lib/commonjs/core/requestThrottle.js.map +1 -0
  45. package/lib/commonjs/core/retryPolicy.js +120 -0
  46. package/lib/commonjs/core/retryPolicy.js.map +1 -0
  47. package/lib/commonjs/core/rewardedSession.js +65 -0
  48. package/lib/commonjs/core/rewardedSession.js.map +1 -0
  49. package/lib/commonjs/core/timers.js +162 -0
  50. package/lib/commonjs/core/timers.js.map +1 -0
  51. package/lib/commonjs/diagnostics/correlation.js +33 -0
  52. package/lib/commonjs/diagnostics/correlation.js.map +1 -0
  53. package/lib/commonjs/diagnostics/errors.js +152 -0
  54. package/lib/commonjs/diagnostics/errors.js.map +1 -0
  55. package/lib/commonjs/diagnostics/events.js +132 -0
  56. package/lib/commonjs/diagnostics/events.js.map +1 -0
  57. package/lib/commonjs/engine/admobBanner.js +58 -0
  58. package/lib/commonjs/engine/admobBanner.js.map +1 -0
  59. package/lib/commonjs/engine/admobEngine.js +343 -0
  60. package/lib/commonjs/engine/admobEngine.js.map +1 -0
  61. package/lib/commonjs/engine/admobErrors.js +45 -0
  62. package/lib/commonjs/engine/admobErrors.js.map +1 -0
  63. package/lib/commonjs/engine/port.js +6 -0
  64. package/lib/commonjs/engine/port.js.map +1 -0
  65. package/lib/commonjs/engine/testAdUnits.js +61 -0
  66. package/lib/commonjs/engine/testAdUnits.js.map +1 -0
  67. package/lib/commonjs/index.js +218 -0
  68. package/lib/commonjs/index.js.map +1 -0
  69. package/lib/commonjs/package.json +1 -0
  70. package/lib/commonjs/react/AdsBanner.js +317 -0
  71. package/lib/commonjs/react/AdsBanner.js.map +1 -0
  72. package/lib/commonjs/react/AdsProvider.js +54 -0
  73. package/lib/commonjs/react/AdsProvider.js.map +1 -0
  74. package/lib/commonjs/react/hooks.js +63 -0
  75. package/lib/commonjs/react/hooks.js.map +1 -0
  76. package/lib/commonjs/testing/clock.js +76 -0
  77. package/lib/commonjs/testing/clock.js.map +1 -0
  78. package/lib/commonjs/testing/conformance.js +99 -0
  79. package/lib/commonjs/testing/conformance.js.map +1 -0
  80. package/lib/commonjs/testing/index.js +389 -0
  81. package/lib/commonjs/testing/index.js.map +1 -0
  82. package/lib/module/config/resolveAdUnit.js +75 -0
  83. package/lib/module/config/resolveAdUnit.js.map +1 -0
  84. package/lib/module/config/types.js +134 -0
  85. package/lib/module/config/types.js.map +1 -0
  86. package/lib/module/config/validate.js +146 -0
  87. package/lib/module/config/validate.js.map +1 -0
  88. package/lib/module/core/adOriginatedReturn.js +115 -0
  89. package/lib/module/core/adOriginatedReturn.js.map +1 -0
  90. package/lib/module/core/adsInstance.js +121 -0
  91. package/lib/module/core/adsInstance.js.map +1 -0
  92. package/lib/module/core/consentFlow.js +143 -0
  93. package/lib/module/core/consentFlow.js.map +1 -0
  94. package/lib/module/core/enablement.js +58 -0
  95. package/lib/module/core/enablement.js.map +1 -0
  96. package/lib/module/core/fullScreenLock.js +44 -0
  97. package/lib/module/core/fullScreenLock.js.map +1 -0
  98. package/lib/module/core/gates.js +91 -0
  99. package/lib/module/core/gates.js.map +1 -0
  100. package/lib/module/core/initMachine.js +152 -0
  101. package/lib/module/core/initMachine.js.map +1 -0
  102. package/lib/module/core/instance/consent.js +151 -0
  103. package/lib/module/core/instance/consent.js.map +1 -0
  104. package/lib/module/core/instance/context.js +212 -0
  105. package/lib/module/core/instance/context.js.map +1 -0
  106. package/lib/module/core/instance/gate.js +183 -0
  107. package/lib/module/core/instance/gate.js.map +1 -0
  108. package/lib/module/core/instance/init.js +321 -0
  109. package/lib/module/core/instance/init.js.map +1 -0
  110. package/lib/module/core/instance/internals.js +109 -0
  111. package/lib/module/core/instance/internals.js.map +1 -0
  112. package/lib/module/core/instance/load.js +452 -0
  113. package/lib/module/core/instance/load.js.map +1 -0
  114. package/lib/module/core/instance/show.js +238 -0
  115. package/lib/module/core/instance/show.js.map +1 -0
  116. package/lib/module/core/instance/types.js +4 -0
  117. package/lib/module/core/instance/types.js.map +1 -0
  118. package/lib/module/core/placementMachine.js +109 -0
  119. package/lib/module/core/placementMachine.js.map +1 -0
  120. package/lib/module/core/privacyGate.js +86 -0
  121. package/lib/module/core/privacyGate.js.map +1 -0
  122. package/lib/module/core/requestThrottle.js +146 -0
  123. package/lib/module/core/requestThrottle.js.map +1 -0
  124. package/lib/module/core/retryPolicy.js +113 -0
  125. package/lib/module/core/retryPolicy.js.map +1 -0
  126. package/lib/module/core/rewardedSession.js +61 -0
  127. package/lib/module/core/rewardedSession.js.map +1 -0
  128. package/lib/module/core/timers.js +150 -0
  129. package/lib/module/core/timers.js.map +1 -0
  130. package/lib/module/diagnostics/correlation.js +29 -0
  131. package/lib/module/diagnostics/correlation.js.map +1 -0
  132. package/lib/module/diagnostics/errors.js +143 -0
  133. package/lib/module/diagnostics/errors.js.map +1 -0
  134. package/lib/module/diagnostics/events.js +128 -0
  135. package/lib/module/diagnostics/events.js.map +1 -0
  136. package/lib/module/engine/admobBanner.js +52 -0
  137. package/lib/module/engine/admobBanner.js.map +1 -0
  138. package/lib/module/engine/admobEngine.js +334 -0
  139. package/lib/module/engine/admobEngine.js.map +1 -0
  140. package/lib/module/engine/admobErrors.js +41 -0
  141. package/lib/module/engine/admobErrors.js.map +1 -0
  142. package/lib/module/engine/port.js +4 -0
  143. package/lib/module/engine/port.js.map +1 -0
  144. package/lib/module/engine/testAdUnits.js +56 -0
  145. package/lib/module/engine/testAdUnits.js.map +1 -0
  146. package/lib/module/index.js +59 -0
  147. package/lib/module/index.js.map +1 -0
  148. package/lib/module/package.json +1 -0
  149. package/lib/module/react/AdsBanner.js +312 -0
  150. package/lib/module/react/AdsBanner.js.map +1 -0
  151. package/lib/module/react/AdsProvider.js +48 -0
  152. package/lib/module/react/AdsProvider.js.map +1 -0
  153. package/lib/module/react/hooks.js +58 -0
  154. package/lib/module/react/hooks.js.map +1 -0
  155. package/lib/module/testing/clock.js +72 -0
  156. package/lib/module/testing/clock.js.map +1 -0
  157. package/lib/module/testing/conformance.js +93 -0
  158. package/lib/module/testing/conformance.js.map +1 -0
  159. package/lib/module/testing/index.js +366 -0
  160. package/lib/module/testing/index.js.map +1 -0
  161. package/lib/typescript/commonjs/config/resolveAdUnit.d.ts +43 -0
  162. package/lib/typescript/commonjs/config/resolveAdUnit.d.ts.map +1 -0
  163. package/lib/typescript/commonjs/config/types.d.ts +280 -0
  164. package/lib/typescript/commonjs/config/types.d.ts.map +1 -0
  165. package/lib/typescript/commonjs/config/validate.d.ts +49 -0
  166. package/lib/typescript/commonjs/config/validate.d.ts.map +1 -0
  167. package/lib/typescript/commonjs/core/adOriginatedReturn.d.ts +61 -0
  168. package/lib/typescript/commonjs/core/adOriginatedReturn.d.ts.map +1 -0
  169. package/lib/typescript/commonjs/core/adsInstance.d.ts +33 -0
  170. package/lib/typescript/commonjs/core/adsInstance.d.ts.map +1 -0
  171. package/lib/typescript/commonjs/core/consentFlow.d.ts +84 -0
  172. package/lib/typescript/commonjs/core/consentFlow.d.ts.map +1 -0
  173. package/lib/typescript/commonjs/core/enablement.d.ts +74 -0
  174. package/lib/typescript/commonjs/core/enablement.d.ts.map +1 -0
  175. package/lib/typescript/commonjs/core/fullScreenLock.d.ts +25 -0
  176. package/lib/typescript/commonjs/core/fullScreenLock.d.ts.map +1 -0
  177. package/lib/typescript/commonjs/core/gates.d.ts +76 -0
  178. package/lib/typescript/commonjs/core/gates.d.ts.map +1 -0
  179. package/lib/typescript/commonjs/core/initMachine.d.ts +66 -0
  180. package/lib/typescript/commonjs/core/initMachine.d.ts.map +1 -0
  181. package/lib/typescript/commonjs/core/instance/consent.d.ts +4 -0
  182. package/lib/typescript/commonjs/core/instance/consent.d.ts.map +1 -0
  183. package/lib/typescript/commonjs/core/instance/context.d.ts +118 -0
  184. package/lib/typescript/commonjs/core/instance/context.d.ts.map +1 -0
  185. package/lib/typescript/commonjs/core/instance/gate.d.ts +38 -0
  186. package/lib/typescript/commonjs/core/instance/gate.d.ts.map +1 -0
  187. package/lib/typescript/commonjs/core/instance/init.d.ts +13 -0
  188. package/lib/typescript/commonjs/core/instance/init.d.ts.map +1 -0
  189. package/lib/typescript/commonjs/core/instance/internals.d.ts +60 -0
  190. package/lib/typescript/commonjs/core/instance/internals.d.ts.map +1 -0
  191. package/lib/typescript/commonjs/core/instance/load.d.ts +9 -0
  192. package/lib/typescript/commonjs/core/instance/load.d.ts.map +1 -0
  193. package/lib/typescript/commonjs/core/instance/show.d.ts +7 -0
  194. package/lib/typescript/commonjs/core/instance/show.d.ts.map +1 -0
  195. package/lib/typescript/commonjs/core/instance/types.d.ts +240 -0
  196. package/lib/typescript/commonjs/core/instance/types.d.ts.map +1 -0
  197. package/lib/typescript/commonjs/core/placementMachine.d.ts +55 -0
  198. package/lib/typescript/commonjs/core/placementMachine.d.ts.map +1 -0
  199. package/lib/typescript/commonjs/core/privacyGate.d.ts +40 -0
  200. package/lib/typescript/commonjs/core/privacyGate.d.ts.map +1 -0
  201. package/lib/typescript/commonjs/core/requestThrottle.d.ts +99 -0
  202. package/lib/typescript/commonjs/core/requestThrottle.d.ts.map +1 -0
  203. package/lib/typescript/commonjs/core/retryPolicy.d.ts +66 -0
  204. package/lib/typescript/commonjs/core/retryPolicy.d.ts.map +1 -0
  205. package/lib/typescript/commonjs/core/rewardedSession.d.ts +37 -0
  206. package/lib/typescript/commonjs/core/rewardedSession.d.ts.map +1 -0
  207. package/lib/typescript/commonjs/core/timers.d.ts +135 -0
  208. package/lib/typescript/commonjs/core/timers.d.ts.map +1 -0
  209. package/lib/typescript/commonjs/diagnostics/correlation.d.ts +18 -0
  210. package/lib/typescript/commonjs/diagnostics/correlation.d.ts.map +1 -0
  211. package/lib/typescript/commonjs/diagnostics/errors.d.ts +59 -0
  212. package/lib/typescript/commonjs/diagnostics/errors.d.ts.map +1 -0
  213. package/lib/typescript/commonjs/diagnostics/events.d.ts +126 -0
  214. package/lib/typescript/commonjs/diagnostics/events.d.ts.map +1 -0
  215. package/lib/typescript/commonjs/engine/admobBanner.d.ts +10 -0
  216. package/lib/typescript/commonjs/engine/admobBanner.d.ts.map +1 -0
  217. package/lib/typescript/commonjs/engine/admobEngine.d.ts +71 -0
  218. package/lib/typescript/commonjs/engine/admobEngine.d.ts.map +1 -0
  219. package/lib/typescript/commonjs/engine/admobErrors.d.ts +9 -0
  220. package/lib/typescript/commonjs/engine/admobErrors.d.ts.map +1 -0
  221. package/lib/typescript/commonjs/engine/port.d.ts +171 -0
  222. package/lib/typescript/commonjs/engine/port.d.ts.map +1 -0
  223. package/lib/typescript/commonjs/engine/testAdUnits.d.ts +33 -0
  224. package/lib/typescript/commonjs/engine/testAdUnits.d.ts.map +1 -0
  225. package/lib/typescript/commonjs/index.d.ts +42 -0
  226. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  227. package/lib/typescript/commonjs/package.json +1 -0
  228. package/lib/typescript/commonjs/react/AdsBanner.d.ts +29 -0
  229. package/lib/typescript/commonjs/react/AdsBanner.d.ts.map +1 -0
  230. package/lib/typescript/commonjs/react/AdsProvider.d.ts +36 -0
  231. package/lib/typescript/commonjs/react/AdsProvider.d.ts.map +1 -0
  232. package/lib/typescript/commonjs/react/hooks.d.ts +27 -0
  233. package/lib/typescript/commonjs/react/hooks.d.ts.map +1 -0
  234. package/lib/typescript/commonjs/testing/clock.d.ts +29 -0
  235. package/lib/typescript/commonjs/testing/clock.d.ts.map +1 -0
  236. package/lib/typescript/commonjs/testing/conformance.d.ts +26 -0
  237. package/lib/typescript/commonjs/testing/conformance.d.ts.map +1 -0
  238. package/lib/typescript/commonjs/testing/index.d.ts +133 -0
  239. package/lib/typescript/commonjs/testing/index.d.ts.map +1 -0
  240. package/lib/typescript/module/config/resolveAdUnit.d.ts +43 -0
  241. package/lib/typescript/module/config/resolveAdUnit.d.ts.map +1 -0
  242. package/lib/typescript/module/config/types.d.ts +280 -0
  243. package/lib/typescript/module/config/types.d.ts.map +1 -0
  244. package/lib/typescript/module/config/validate.d.ts +49 -0
  245. package/lib/typescript/module/config/validate.d.ts.map +1 -0
  246. package/lib/typescript/module/core/adOriginatedReturn.d.ts +61 -0
  247. package/lib/typescript/module/core/adOriginatedReturn.d.ts.map +1 -0
  248. package/lib/typescript/module/core/adsInstance.d.ts +33 -0
  249. package/lib/typescript/module/core/adsInstance.d.ts.map +1 -0
  250. package/lib/typescript/module/core/consentFlow.d.ts +84 -0
  251. package/lib/typescript/module/core/consentFlow.d.ts.map +1 -0
  252. package/lib/typescript/module/core/enablement.d.ts +74 -0
  253. package/lib/typescript/module/core/enablement.d.ts.map +1 -0
  254. package/lib/typescript/module/core/fullScreenLock.d.ts +25 -0
  255. package/lib/typescript/module/core/fullScreenLock.d.ts.map +1 -0
  256. package/lib/typescript/module/core/gates.d.ts +76 -0
  257. package/lib/typescript/module/core/gates.d.ts.map +1 -0
  258. package/lib/typescript/module/core/initMachine.d.ts +66 -0
  259. package/lib/typescript/module/core/initMachine.d.ts.map +1 -0
  260. package/lib/typescript/module/core/instance/consent.d.ts +4 -0
  261. package/lib/typescript/module/core/instance/consent.d.ts.map +1 -0
  262. package/lib/typescript/module/core/instance/context.d.ts +118 -0
  263. package/lib/typescript/module/core/instance/context.d.ts.map +1 -0
  264. package/lib/typescript/module/core/instance/gate.d.ts +38 -0
  265. package/lib/typescript/module/core/instance/gate.d.ts.map +1 -0
  266. package/lib/typescript/module/core/instance/init.d.ts +13 -0
  267. package/lib/typescript/module/core/instance/init.d.ts.map +1 -0
  268. package/lib/typescript/module/core/instance/internals.d.ts +60 -0
  269. package/lib/typescript/module/core/instance/internals.d.ts.map +1 -0
  270. package/lib/typescript/module/core/instance/load.d.ts +9 -0
  271. package/lib/typescript/module/core/instance/load.d.ts.map +1 -0
  272. package/lib/typescript/module/core/instance/show.d.ts +7 -0
  273. package/lib/typescript/module/core/instance/show.d.ts.map +1 -0
  274. package/lib/typescript/module/core/instance/types.d.ts +240 -0
  275. package/lib/typescript/module/core/instance/types.d.ts.map +1 -0
  276. package/lib/typescript/module/core/placementMachine.d.ts +55 -0
  277. package/lib/typescript/module/core/placementMachine.d.ts.map +1 -0
  278. package/lib/typescript/module/core/privacyGate.d.ts +40 -0
  279. package/lib/typescript/module/core/privacyGate.d.ts.map +1 -0
  280. package/lib/typescript/module/core/requestThrottle.d.ts +99 -0
  281. package/lib/typescript/module/core/requestThrottle.d.ts.map +1 -0
  282. package/lib/typescript/module/core/retryPolicy.d.ts +66 -0
  283. package/lib/typescript/module/core/retryPolicy.d.ts.map +1 -0
  284. package/lib/typescript/module/core/rewardedSession.d.ts +37 -0
  285. package/lib/typescript/module/core/rewardedSession.d.ts.map +1 -0
  286. package/lib/typescript/module/core/timers.d.ts +135 -0
  287. package/lib/typescript/module/core/timers.d.ts.map +1 -0
  288. package/lib/typescript/module/diagnostics/correlation.d.ts +18 -0
  289. package/lib/typescript/module/diagnostics/correlation.d.ts.map +1 -0
  290. package/lib/typescript/module/diagnostics/errors.d.ts +59 -0
  291. package/lib/typescript/module/diagnostics/errors.d.ts.map +1 -0
  292. package/lib/typescript/module/diagnostics/events.d.ts +126 -0
  293. package/lib/typescript/module/diagnostics/events.d.ts.map +1 -0
  294. package/lib/typescript/module/engine/admobBanner.d.ts +10 -0
  295. package/lib/typescript/module/engine/admobBanner.d.ts.map +1 -0
  296. package/lib/typescript/module/engine/admobEngine.d.ts +71 -0
  297. package/lib/typescript/module/engine/admobEngine.d.ts.map +1 -0
  298. package/lib/typescript/module/engine/admobErrors.d.ts +9 -0
  299. package/lib/typescript/module/engine/admobErrors.d.ts.map +1 -0
  300. package/lib/typescript/module/engine/port.d.ts +171 -0
  301. package/lib/typescript/module/engine/port.d.ts.map +1 -0
  302. package/lib/typescript/module/engine/testAdUnits.d.ts +33 -0
  303. package/lib/typescript/module/engine/testAdUnits.d.ts.map +1 -0
  304. package/lib/typescript/module/index.d.ts +42 -0
  305. package/lib/typescript/module/index.d.ts.map +1 -0
  306. package/lib/typescript/module/package.json +1 -0
  307. package/lib/typescript/module/react/AdsBanner.d.ts +29 -0
  308. package/lib/typescript/module/react/AdsBanner.d.ts.map +1 -0
  309. package/lib/typescript/module/react/AdsProvider.d.ts +36 -0
  310. package/lib/typescript/module/react/AdsProvider.d.ts.map +1 -0
  311. package/lib/typescript/module/react/hooks.d.ts +27 -0
  312. package/lib/typescript/module/react/hooks.d.ts.map +1 -0
  313. package/lib/typescript/module/testing/clock.d.ts +29 -0
  314. package/lib/typescript/module/testing/clock.d.ts.map +1 -0
  315. package/lib/typescript/module/testing/conformance.d.ts +26 -0
  316. package/lib/typescript/module/testing/conformance.d.ts.map +1 -0
  317. package/lib/typescript/module/testing/index.d.ts +133 -0
  318. package/lib/typescript/module/testing/index.d.ts.map +1 -0
  319. package/package.json +48 -12
  320. package/skills/sdk-rn-ads/SKILL.md +2 -1
  321. package/src/core/adsInstance.ts +72 -1829
  322. package/src/core/consentFlow.ts +1 -20
  323. package/src/core/instance/consent.ts +162 -0
  324. package/src/core/instance/context.ts +328 -0
  325. package/src/core/instance/gate.ts +147 -0
  326. package/src/core/instance/init.ts +262 -0
  327. package/src/core/instance/internals.ts +138 -0
  328. package/src/core/instance/load.ts +426 -0
  329. package/src/core/instance/show.ts +202 -0
  330. package/src/core/instance/types.ts +198 -0
  331. package/src/core/requestThrottle.ts +11 -17
  332. package/src/diagnostics/errors.ts +24 -5
  333. package/src/engine/admobBanner.tsx +55 -0
  334. package/src/engine/admobEngine.ts +21 -12
  335. package/src/engine/admobErrors.ts +44 -0
  336. package/src/engine/port.ts +46 -1
  337. package/src/engine/testAdUnits.ts +0 -5
  338. package/src/react/AdsBanner.tsx +81 -80
  339. package/src/testing/clock.ts +75 -0
  340. package/src/testing/index.ts +43 -68
package/CHANGELOG.md CHANGED
@@ -1,5 +1,144 @@
1
1
  # @chipmobilesdk/rn-ads
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Every package now ships built JavaScript with declaration files, instead of asking the
8
+ app to compile its TypeScript. ([#22](https://github.com/operationd8979/chip-mobile-sdk/pull/22))
9
+
10
+ Each tarball carries `lib/commonjs`, `lib/module` and `lib/typescript` (built with
11
+ `react-native-builder-bob`), and `src/` alongside them. What that changes for a
12
+ consumer:
13
+
14
+ - **Nothing to add to `transformIgnorePatterns`.** `require` resolves to the CommonJS
15
+ build, so an app's Jest loads this package without being told to transform it. That
16
+ was the one thing every consuming app had to know about us (DEP-04).
17
+ - **Typechecking reads our `.d.ts`** rather than compiling our source under our
18
+ `tsconfig`. A consumer's stricter — or looser — settings no longer meet our code.
19
+ - **`import` resolves to ESM**, so a bundler can tree-shake what it does not use.
20
+
21
+ No exported name changed, and no subpath moved: `.`, `./testing`, `./push`,
22
+ `./advanced`, `./app-auth`, `./keychain` and rn-core's twelve subpaths resolve exactly
23
+ as before, each now with its own declarations for both module systems. publint and
24
+ `attw --profile node16` pass on all twelve packages, which they could not before.
25
+
26
+ Inside the monorepo nothing changed either, and that is deliberate: every subpath also
27
+ declares a private `chipmobilesdk-source` condition pointing at its TypeScript, and
28
+ Metro, Jest and `tsc` here ask for that condition first. The demo app bundles 371
29
+ modules straight from `packages/*/src`, so editing a package still changes the app with
30
+ no build step, and coverage is still measured on the source. The condition is named for
31
+ this organization rather than using the conventional `source` because third-party
32
+ packages declare that one too — `@dr.pogodin/react-native-fs` does — and asking for it
33
+ pulled their sources into our stricter compile.
34
+
35
+ `npm run build:packages` builds everything, `prepack` rebuilds before any `npm pack`,
36
+ and `lib/` is git-ignored: the published bytes are produced by the release, never
37
+ committed. `npm run check:manifests` now fails a package whose `main`, `module`,
38
+ `types`, `source` condition, `files`, build script or `prepack` do not match this shape.
39
+
40
+ - The fake engine's banner now renders a host view instead of nothing, so a test can find
41
+ it with the testing library. ([#24](https://github.com/operationd8979/chip-mobile-sdk/pull/24))
42
+
43
+ `createFakeAdsEngine().banner.Component` rendered `null`, which left the props the
44
+ package handed it — `adUnitId`, `personalizedAds`, `onLoaded`, `onFailed`, `onImpression`,
45
+ `onClicked` — reachable only on the component instance in the rendered tree. Nothing a
46
+ consumer writes with `@testing-library/react-native` can see that: its queries, like the
47
+ renderer underneath them, return host elements. The fake now renders a `View` carrying
48
+ those props under the testID exported as `FAKE_BANNER_TEST_ID` (`'ads-fake-banner'`):
49
+
50
+ ```ts
51
+ import { FAKE_BANNER_TEST_ID } from '@chipmobilesdk/rn-ads/testing';
52
+
53
+ const banner = screen.getByTestId(FAKE_BANNER_TEST_ID);
54
+ expect(banner.props.adUnitId).toBe(/* the test unit, not yours */);
55
+ banner.props.onLoaded();
56
+ ```
57
+
58
+ A test that searched the tree for a component instance with an `adUnitId` prop needs this
59
+ change; one driven through `engine.adUnitIds()` and the recorded call log does not. The
60
+ banner still draws nothing and measures nothing, so a layout assertion is unaffected.
61
+
62
+ ### Patch Changes
63
+
64
+ - Each package's public API and its weight are now recorded in the repository, so a change
65
+ to either is reviewed rather than discovered. ([#23](https://github.com/operationd8979/chip-mobile-sdk/pull/23))
66
+
67
+ `packages/<pkg>/etc/*.api.md` is an api-extractor report per entrypoint — twenty-seven
68
+ of them, generated from the declarations the package publishes and committed. A renamed
69
+ type, a widened union, one more optional field: all of it shows up in a pull request's
70
+ diff. `npm run check:api` fails when a report is out of date and `npm run api:update`
71
+ rewrites them.
72
+
73
+ A report that moves now needs a **minor or major** changeset for that package.
74
+ `check:changesets` enforces it, because the report is generated from what the package
75
+ publishes, and a patch release that moves the public surface is how a consumer's build
76
+ breaks on `npm update`. A report added for the first time is a baseline, not a change.
77
+ `./testing` deliberately has no report: test doubles are not a surface a release is
78
+ gated on.
79
+
80
+ `npm run check:size` holds every entrypoint to a budget in `.size-limit.json`, measured
81
+ on the ESM build with peers and rn-core treated as external — they are what an app
82
+ installs beside us, not our weight. Each budget started at today's measurement plus five
83
+ per cent, so growth becomes a decision someone makes instead of a drift nobody sees. The
84
+ current figures run from 500 B (`rn-core/lazy`) to 19 kB (rn-notification).
85
+
86
+ No behaviour or API changed in this release; the entry is here so the changelog records
87
+ when the reports and the budgets began.
88
+ - Updated dependencies ([#22](https://github.com/operationd8979/chip-mobile-sdk/pull/22), [#23](https://github.com/operationd8979/chip-mobile-sdk/pull/23)):
89
+ - @chipmobilesdk/rn-core@0.2.0
90
+
91
+ ## 0.7.0
92
+
93
+ ### Minor Changes
94
+
95
+ - The ads instance is split by responsibility, and the banner host's wiring is off the
96
+ public type. ([#19](https://github.com/operationd8979/chip-mobile-sdk/pull/19))
97
+
98
+ - `AdsInstance` no longer has an `internals` field. It was undocumented, but any
99
+ consumer could use it to emit `impression` or `reward_earned` into the event stream
100
+ used for revenue reconciliation. `AdsBanner` now reaches an instance's wiring through
101
+ a private registry, so a banner given an instance the app wrote by hand renders
102
+ nothing instead of throwing.
103
+ - Banner events carry the instance's clock (`createAds({ now })`), like full-screen
104
+ events, and resolving a banner during render no longer mints a correlation id.
105
+ - `allTestAdUnits()` moved from the engine module to `@chipmobilesdk/rn-ads/testing`.
106
+ - Rewards from AdMob go through the one `normalizeReward`; an unused consent port guard
107
+ and the throttle's unused `reset`/`lastRequestAt` are gone.
108
+ - Internally, `createAds` is now a 142-line composition root over `core/instance/`
109
+ (gate, init, load, show, consent, internals), down from one 1,899-line closure. Every
110
+ path that closes the request gate goes through one teardown.
111
+
112
+ - Four fixes to how ads behave around throttling, retries and show timeouts. ([#19](https://github.com/operationd8979/chip-mobile-sdk/pull/19))
113
+
114
+ - A banner refused by the request throttle now tries again by itself once the window
115
+ passes. Before, it stayed empty until it was remounted, so a banner on a screen the
116
+ user returned to within a minute never filled.
117
+ - A load retry waits at least as long as the placement's `minRequestIntervalMs`
118
+ requires, so a retry policy cannot request faster than the floor allows. The
119
+ `retry_scheduled` event reports the wait actually used.
120
+ - A request AdMob refuses outright (an invalid request or ad unit, a missing app id)
121
+ is the new non-retryable `provider_rejected` code instead of a retryable
122
+ `provider_error`, so a retry policy no longer spends billable requests on it. Engines
123
+ may classify a failure with the new optional `kind` on the `failed` event.
124
+ - A show that times out and then opens anyway is reported once, not twice. The late
125
+ ad holds the full-screen lock until it is dismissed, and its reward and dismissal
126
+ still reach the app.
127
+
128
+ - The banner renders through the engine port. `AdsEngine` has an optional `banner`
129
+ capability (`isAvailable()` and a `Component` with neutral props: `adUnitId`,
130
+ `personalizedAds`, `onLoaded`, `onFailed`, `onImpression`, `onClicked`), and the AdMob
131
+ adapter supplies the adaptive `BannerAd` there. `AdsBanner` no longer loads the AdMob
132
+ bridge itself, so a custom or future iOS engine provides its own banner, and the fake
133
+ engine from `./testing` renders one in tests without a mocked native module. An engine
134
+ without `banner` keeps working; its banners report `unavailable`. ([#19](https://github.com/operationd8979/chip-mobile-sdk/pull/19))
135
+
136
+ ### Patch Changes
137
+
138
+ - Internal: no module in these packages is over 500 lines any more. The camera controller's session I/O moved to `sessionRuntime` and its contract to `contract.ts`; the Play adapter's shape translation to `iapShapes`; the purchase flow's failure mapping and its receipt-validation hook to modules of their own; the AI client's quota request to `quotaRequest`; the in-memory adapter's attachments and the fake ads engine's clock likewise. Behaviour is unchanged — the splits are by responsibility, and every package's suite passes as it stood. ([#19](https://github.com/operationd8979/chip-mobile-sdk/pull/19))
139
+
140
+ The repository also measures what it promised: `npm run perf` prints the median of nine runs of the deterministic hot paths against written budgets (recurrence expansion, theme construction, translation lookup, chart geometry, filter compilation), the demo app has a Performance screen reporting startup phases, time to interactive and the same benchmarks on Hermes, and `npm run check:file-size` keeps the limit from drifting. The budgets and the measured figures are recorded in `docs/standards.md` §VI.
141
+
3
142
  ## 0.6.0
4
143
 
5
144
  ### Minor Changes
package/README.md CHANGED
@@ -273,7 +273,9 @@ ads.subscribeEvents(event => {
273
273
  A config value outside its band names its own field and code: a timeout or validity window is `timeout_out_of_bounds`, a retry policy `retry_out_of_bounds`, a placement's `minRequestIntervalMs` `invalid_config`.
274
274
 
275
275
  Retryable: `no_fill` `network_error` `load_timeout` `show_timeout` `ad_expired` `not_ready` `busy` `consumed` `app_inactive` `provider_error`
276
- Not retryable: `invalid_config` `duplicate_placement_key` `missing_ad_unit_id` `format_mismatch` `placement_not_found` `production_in_dev_build` `timeout_out_of_bounds` `retry_out_of_bounds` `unsupported_platform` `provider_missing` `disabled` `consent_required` `consent_undetermined` `requires_reinitialization` `internal_error`
276
+ Not retryable: `invalid_config` `duplicate_placement_key` `missing_ad_unit_id` `format_mismatch` `placement_not_found` `production_in_dev_build` `timeout_out_of_bounds` `retry_out_of_bounds` `unsupported_platform` `provider_missing` `disabled` `consent_required` `consent_undetermined` `requires_reinitialization` `provider_rejected` `internal_error`
277
+
278
+ `provider_rejected` (0.7.0) means AdMob refused the request itself — an invalid request or ad unit, a missing app id — so a retry policy does not spend more requests on it. Before, those were `provider_error` and were retried.
277
279
 
278
280
  Attach any logger or analytics you already use. The package depends on none:
279
281
 
@@ -804,7 +806,7 @@ On device, verify with Google's official test ads only. `npm run android`, then
804
806
  Adding iOS contributes exactly three things and changes **nothing** you have already written:
805
807
 
806
808
  1. **`PlacementDefinition.iosAdUnitId`** — the optional field already exists in v1's type, so existing Android-only catalogs stay valid.
807
- 2. **A second engine adapter** behind the existing `AdsEngine` port. The port names no platform and no provider; that is what makes this additive.
809
+ 2. **A second engine adapter** behind the existing `AdsEngine` port. The port names no platform and no provider; that is what makes this additive. The banner is part of the port too (`AdsEngine.banner`, since 0.7.0): an adapter supplies its own banner component, which receives neutral props (`adUnitId`, `personalizedAds`, `onLoaded`, `onFailed`, `onImpression`, `onClicked`), and `AdsBanner` renders whatever the engine offers.
808
810
  3. **iOS entries in the private test-ad-unit table.**
809
811
 
810
812
  Your `createAds`, `initialize`, `load`, `show`, `AdsBanner`, and every subscription keep their current signatures. The exported state, event, and error models do not change.
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.resolveAdUnit = resolveAdUnit;
7
+ exports.resolvePlacementAdUnits = resolvePlacementAdUnits;
8
+ var _testAdUnits = require("../engine/testAdUnits.js");
9
+ /**
10
+ * The production-traffic guarantee (FR-011, FR-011a).
11
+ *
12
+ * A pure function, deliberately. This is the single point where a production ad
13
+ * unit can be replaced by an official test one, which is what makes SC-002
14
+ * provable rather than merely intended: a guarantee enforced in one place can be
15
+ * asserted; one spread across three call sites is a hope.
16
+ *
17
+ * The rule, from the 2026-09-02 clarification session:
18
+ *
19
+ * production -> use what the app configured, always, no exceptions
20
+ * development / test -> if it is not one of our own official test units,
21
+ * replace it and say so, loudly, naming the key
22
+ *
23
+ * Substitution rather than rejection is a deliberate trade. Rejecting would
24
+ * block a developer whose only mistake was pulling a teammate's environment
25
+ * file, and turn a configuration smell into a broken integration at every
26
+ * startup. Substituting keeps the app working — which is what a non-production
27
+ * build is for — and reports the problem as a first-class signal. The accepted
28
+ * cost is that a warning can be ignored; it is bounded because production never
29
+ * substitutes, so the misconfiguration surfaces there as ordinary behavior
30
+ * rather than as hidden state.
31
+ */
32
+
33
+ function resolveAdUnit(placement, environment) {
34
+ const configured = placement.androidAdUnitId;
35
+
36
+ // Production is the one environment where the package must not second-guess
37
+ // the app. Substituting here would silently rewrite configuration that was
38
+ // asked for on purpose, and would cost the publisher live revenue.
39
+ if (environment === 'production') {
40
+ return {
41
+ effectiveAdUnitId: configured,
42
+ substituted: false
43
+ };
44
+ }
45
+
46
+ // Structural detection: anything that is not a known official test unit is
47
+ // treated as production-owned. Not a parse of AdMob's publisher-id format —
48
+ // see the note in engine/testAdUnits.ts on why that rule would be a liability.
49
+ if ((0, _testAdUnits.isOfficialTestAdUnit)(configured)) {
50
+ return {
51
+ effectiveAdUnitId: configured,
52
+ substituted: false
53
+ };
54
+ }
55
+ return {
56
+ effectiveAdUnitId: (0, _testAdUnits.testAdUnitFor)(placement.format),
57
+ substituted: true
58
+ };
59
+ }
60
+ /**
61
+ * Resolves a whole catalog at once, so the warning can name every affected
62
+ * placement in a single event rather than trickling one out per load — an
63
+ * integrator wants to fix the whole file, not discover it a placement at a time.
64
+ */
65
+ function resolvePlacementAdUnits(placements, environment) {
66
+ const byKey = new Map();
67
+ const substitutedKeys = [];
68
+ for (const placement of placements) {
69
+ const resolved = resolveAdUnit(placement, environment);
70
+ byKey.set(placement.key, resolved.effectiveAdUnitId);
71
+ if (resolved.substituted) {
72
+ substitutedKeys.push(placement.key);
73
+ }
74
+ }
75
+ return {
76
+ byKey,
77
+ substitutedKeys
78
+ };
79
+ }
80
+ //# sourceMappingURL=resolveAdUnit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_testAdUnits","require","resolveAdUnit","placement","environment","configured","androidAdUnitId","effectiveAdUnitId","substituted","isOfficialTestAdUnit","testAdUnitFor","format","resolvePlacementAdUnits","placements","byKey","Map","substitutedKeys","resolved","set","key","push"],"sourceRoot":"../../../src","sources":["config/resolveAdUnit.ts"],"mappings":";;;;;;;AAyBA,IAAAA,YAAA,GAAAC,OAAA;AAzBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWO,SAASC,aAAaA,CAC5BC,SAA8B,EAC9BC,WAAwB,EACP;EACjB,MAAMC,UAAU,GAAGF,SAAS,CAACG,eAAe;;EAE5C;EACA;EACA;EACA,IAAIF,WAAW,KAAK,YAAY,EAAE;IACjC,OAAO;MAAEG,iBAAiB,EAAEF,UAAU;MAAEG,WAAW,EAAE;IAAM,CAAC;EAC7D;;EAEA;EACA;EACA;EACA,IAAI,IAAAC,iCAAoB,EAACJ,UAAU,CAAC,EAAE;IACrC,OAAO;MAAEE,iBAAiB,EAAEF,UAAU;MAAEG,WAAW,EAAE;IAAM,CAAC;EAC7D;EAEA,OAAO;IAAED,iBAAiB,EAAE,IAAAG,0BAAa,EAACP,SAAS,CAACQ,MAAM,CAAC;IAAEH,WAAW,EAAE;EAAK,CAAC;AACjF;AASA;AACA;AACA;AACA;AACA;AACO,SAASI,uBAAuBA,CACtCC,UAA0C,EAC1CT,WAAwB,EACN;EAClB,MAAMU,KAAK,GAAG,IAAIC,GAAG,CAAiB,CAAC;EACvC,MAAMC,eAAyB,GAAG,EAAE;EAEpC,KAAK,MAAMb,SAAS,IAAIU,UAAU,EAAE;IACnC,MAAMI,QAAQ,GAAGf,aAAa,CAACC,SAAS,EAAEC,WAAW,CAAC;IACtDU,KAAK,CAACI,GAAG,CAACf,SAAS,CAACgB,GAAG,EAAEF,QAAQ,CAACV,iBAAiB,CAAC;IACpD,IAAIU,QAAQ,CAACT,WAAW,EAAE;MACzBQ,eAAe,CAACI,IAAI,CAACjB,SAAS,CAACgB,GAAG,CAAC;IACpC;EACD;EAEA,OAAO;IAAEL,KAAK;IAAEE;EAAgB,CAAC;AAClC","ignoreList":[]}
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isFullScreenFormat = isFullScreenFormat;
7
+ /**
8
+ * Public configuration and state types (FR-001, FR-003, FR-004).
9
+ *
10
+ * Nothing here names a platform or an ad provider. That is the whole point:
11
+ * adding an iOS adapter later contributes an optional `iosAdUnitId` and a second
12
+ * engine implementation, and changes nothing a consumer already wrote (FR-006).
13
+ *
14
+ * The package persists none of this. Every value below lives for the lifetime of
15
+ * one instance and is released by `dispose()`.
16
+ */
17
+
18
+ /**
19
+ * Supported formats. Native and rewarded-interstitial remain deferred.
20
+ *
21
+ * `app_open` joined in 0.2.0. It is a member of this union rather than a
22
+ * separate concept because FR-132 forbids a parallel vocabulary: app-open uses
23
+ * the same placement states, events, and error codes as everything else. The
24
+ * cost is that a consumer's exhaustive `switch` over this union stops compiling
25
+ * — the one required migration step, documented in the 0.2.0 release notes.
26
+ */
27
+
28
+ /**
29
+ * Formats that take over the screen, and so contend for the single-show lock.
30
+ * App-open is included deliberately: two full-screen ads at once is a broken
31
+ * app regardless of which formats produced them (FR-129).
32
+ */
33
+
34
+ function isFullScreenFormat(format) {
35
+ return format === 'interstitial' || format === 'rewarded' || format === 'app_open';
36
+ }
37
+
38
+ /**
39
+ * Declared by the app, because the package cannot depend on any particular
40
+ * configuration mechanism (FR-015). Cross-checked against the runtime dev flag
41
+ * so a debug build claiming `production` is caught rather than trusted (FR-012).
42
+ */
43
+
44
+ /**
45
+ * One logical ad slot. `key` is the app's own stable name — `home_footer`, not
46
+ * an AdMob unit. Provider identifiers appear here in configuration and nowhere
47
+ * else in consumer code (FR-003, FR-007).
48
+ */
49
+
50
+ /**
51
+ * Bounded retry for failed loads. Off unless `AdsConfig.retry` is supplied —
52
+ * upgrading from 0.1.0 without configuring this issues not one extra request
53
+ * (FR-134).
54
+ *
55
+ * Only errors already flagged `retryable` are retried. Configuration errors,
56
+ * consent errors, an unsupported platform, and a disabled or undecided instance
57
+ * never are (FR-135).
58
+ *
59
+ * Backoff is exponential with a fixed x2 multiplier and no jitter. Jitter exists
60
+ * to desynchronize a fleet hitting one server; a single device retrying its own
61
+ * load has no herd to avoid, and omitting it keeps the attempt count an exact
62
+ * assertion rather than a statistical one.
63
+ */
64
+
65
+ /**
66
+ * Whether the app wants ads, including the case where it does not know yet.
67
+ *
68
+ * The package never resolves `undecided` on the app's behalf and never learns
69
+ * why the app chose what it chose — no entitlement, no receipt, no reason
70
+ * (FR-119, FR-120).
71
+ */
72
+
73
+ /**
74
+ * Tools for exercising the consent flow from a device outside a
75
+ * consent-required region.
76
+ *
77
+ * **Stripped entirely when `environment` is `production`.** That is enforced at
78
+ * configuration validation rather than at each call site, so no path through the
79
+ * consent module can forget it, and the fact that they were ignored is
80
+ * observable through a `config_warning` event and `getIgnoredConsentTools()` —
81
+ * not merely documented (FR-113).
82
+ */
83
+
84
+ /**
85
+ * Consent status, normalized. Carries no provider type and no payload (FR-104).
86
+ *
87
+ * Shaped so an iOS adapter can later express both a consent flow and the
88
+ * platform's tracking-permission mechanism, plus the ordering between them,
89
+ * without changing shape.
90
+ */
91
+
92
+ /**
93
+ * Whether the user must be offered a way to change their consent choice
94
+ * (FR-150), added in 0.4.0.
95
+ *
96
+ * The provider's verdict, forwarded — never the package's judgement about a
97
+ * region, exactly as `not_required` in `ConsentState` is not. `required` is the
98
+ * app's cue to show its own "Privacy options" entry; where that entry lives and
99
+ * what it says stay the app's.
100
+ *
101
+ * `unknown` before the first successful `requestInfoUpdate()`, after `reset()`,
102
+ * after a failed update, and on a platform with no adapter. It is not `not_required`:
103
+ * an app that hides the entry on `unknown` is right to, but it must not conclude
104
+ * the user has no right to one.
105
+ */
106
+
107
+ /** Bounds exist because an unbounded timeout is the same defect as no timeout. */
108
+
109
+ /** Content ratings, normalized. Maps onto the provider's own rating scale. */
110
+
111
+ /**
112
+ * Supplied before initialization (FR-016). Never logged, never persisted
113
+ * (FR-021). Everything except `canRequestAds` must reach the provider before it
114
+ * initializes, which is why changing one afterwards reports
115
+ * `requires_reinitialization` rather than pretending it applied (FR-020).
116
+ */
117
+
118
+ /**
119
+ * Why the consent gate is closed.
120
+ *
121
+ * The two original members keep their exact v1 meaning — the app's own gate —
122
+ * so no existing consumer's interpretation changes. The two added in 0.2.0 name
123
+ * the package's consent flow instead. The split exists because the gate has two
124
+ * independent inputs that combine as most-restrictive-wins, and a refusal has to
125
+ * say *which* of them is blocking or the app cannot act on it (FR-105a).
126
+ */
127
+
128
+ /** FR-023. One per instance, observable without holding a provider object. */
129
+
130
+ /**
131
+ * FR-026. One per placement. Banners never reach `consumed` — they are
132
+ * continuous, not single-use.
133
+ */
134
+
135
+ /** FR-047. The provider's reward descriptor, normalized. */
136
+
137
+ /** FR-005. Returned by every subscription; safe to call more than once. */
138
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isFullScreenFormat","format"],"sourceRoot":"../../../src","sources":["config/types.ts"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAGO,SAASA,kBAAkBA,CAACC,MAAgB,EAA8B;EAChF,OAAOA,MAAM,KAAK,cAAc,IAAIA,MAAM,KAAK,UAAU,IAAIA,MAAM,KAAK,UAAU;AACnF;;AAEA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAmCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA;;AAkDA;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;;AAqBA;AACA;AACA;AACA;;AAsBA;;AAMA","ignoreList":[]}
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.validateConfig = validateConfig;
7
+ var _errors = require("../diagnostics/errors.js");
8
+ var _resolveAdUnit = require("./resolveAdUnit.js");
9
+ var _timers = require("../core/timers.js");
10
+ var _requestThrottle = require("../core/requestThrottle.js");
11
+ var _enablement = require("../core/enablement.js");
12
+ var _retryPolicy = require("../core/retryPolicy.js");
13
+ /**
14
+ * Catalog and configuration validation (FR-008), plus the fail-closed check
15
+ * that substitution cannot cover (FR-012).
16
+ *
17
+ * Configuration faults throw rather than returning a result. They mean the app
18
+ * is wired wrong, and no runtime status could describe a usable outcome — every
19
+ * other failure in this package is a typed result instead.
20
+ *
21
+ * Every message names the offending placement key. An error that says only
22
+ * "invalid configuration" makes the integrator hunt through a catalog by hand.
23
+ */
24
+
25
+ const FORMATS = new Set(['banner', 'interstitial', 'rewarded', 'app_open']);
26
+ function validateConfig(config, options) {
27
+ // FR-012. Substitution deliberately does not apply in production, so a debug
28
+ // build declaring `production` is the one case it cannot make safe: it would
29
+ // send real requests from a build that should never generate traffic. Fail
30
+ // closed rather than continue.
31
+ if (config.environment === 'production' && options.isDevBuild) {
32
+ throw new _errors.AdsConfigError('production_in_dev_build', {
33
+ message: 'environment is "production" but this is a development build. ' + 'Non-production builds must declare "development" or "test" so the package can ' + 'substitute official Google test ad units and keep production traffic impossible.'
34
+ });
35
+ }
36
+ if (!Array.isArray(config.placements) || config.placements.length === 0) {
37
+ throw new _errors.AdsConfigError('invalid_config', {
38
+ message: 'placements must be a non-empty array; the package can show nothing without one'
39
+ });
40
+ }
41
+ const byKey = new Map();
42
+ for (const placement of config.placements) {
43
+ const key = typeof placement?.key === 'string' ? placement.key.trim() : '';
44
+ if (!key) {
45
+ throw new _errors.AdsConfigError('invalid_config', {
46
+ message: 'every placement needs a non-empty key'
47
+ });
48
+ }
49
+ if (byKey.has(key)) {
50
+ // Rejecting the whole catalog rather than picking a winner: a repeated
51
+ // key means the app's own naming produced two placements for one slot,
52
+ // and the package has no basis to guess which was meant.
53
+ throw new _errors.AdsConfigError('duplicate_placement_key', {
54
+ message: `duplicate placement key "${key}"`,
55
+ placementKey: key
56
+ });
57
+ }
58
+ if (!FORMATS.has(placement.format)) {
59
+ throw new _errors.AdsConfigError('invalid_config', {
60
+ message: `placement "${key}" has unsupported format "${String(placement.format)}"; supported formats are banner, interstitial, rewarded, and app_open`,
61
+ placementKey: key
62
+ });
63
+ }
64
+ if (!placement.androidAdUnitId || !placement.androidAdUnitId.trim()) {
65
+ throw new _errors.AdsConfigError('missing_ad_unit_id', {
66
+ message: `placement "${key}" is missing androidAdUnitId`,
67
+ placementKey: key,
68
+ format: placement.format
69
+ });
70
+ }
71
+ byKey.set(key, {
72
+ ...placement,
73
+ key
74
+ });
75
+ }
76
+ const timeouts = (0, _timers.resolveTimeouts)({
77
+ timeouts: config.timeouts,
78
+ adValidityMs: config.adValidityMs,
79
+ appOpenValidityMs: config.appOpenValidityMs,
80
+ undecidedWarningMs: config.undecidedWarningMs
81
+ });
82
+ const catalog = (0, _resolveAdUnit.resolvePlacementAdUnits)(Array.from(byKey.values()), config.environment);
83
+
84
+ // Resolved eagerly, for every placement, so an out-of-bounds override fails
85
+ // at construction rather than on the first failed load in production — which
86
+ // is the one moment nobody is watching for a configuration error.
87
+ const retryByKey = new Map();
88
+ // Resolved in the same loop and for the same reason: an out-of-bounds floor
89
+ // must fail at construction, not silently refuse every request in production.
90
+ const minRequestIntervalByKey = new Map();
91
+ for (const [key, placement] of byKey) {
92
+ retryByKey.set(key, (0, _retryPolicy.resolveEffectiveRetry)(config.retry, placement.retry, key));
93
+ minRequestIntervalByKey.set(key, placement.minRequestIntervalMs === undefined ? (0, _requestThrottle.defaultMinRequestIntervalMs)(placement.format) :
94
+ // A request floor, not a timeout: its own code (ADS-16).
95
+ (0, _timers.checkBand)(`placements["${key}"].minRequestIntervalMs`, placement.minRequestIntervalMs, _requestThrottle.MIN_REQUEST_INTERVAL_BOUNDS, 'invalid_config'));
96
+ }
97
+ const isProduction = config.environment === 'production';
98
+ const {
99
+ consentTesting,
100
+ ignoredConsentTools
101
+ } = resolveConsentTesting(config.consentTesting, isProduction);
102
+ return {
103
+ enablement: (0, _enablement.toEnablement)(config.enabled),
104
+ environment: config.environment,
105
+ placements: byKey,
106
+ catalog,
107
+ timeouts,
108
+ // FR-014: debug and test-device settings must not be able to alter
109
+ // production behavior, so they are dropped rather than carried and
110
+ // conditionally ignored somewhere further down.
111
+ testDeviceIds: isProduction ? [] : [...(config.testDeviceIds ?? [])],
112
+ retryByKey,
113
+ minRequestIntervalByKey,
114
+ consentTesting,
115
+ ignoredConsentTools
116
+ };
117
+ }
118
+
119
+ /**
120
+ * Neutralizes the consent testing tools in production (FR-113).
121
+ *
122
+ * Dropped here, at the single validation point, rather than checked wherever
123
+ * they are used. That is what makes the guarantee provable: a rule enforced in
124
+ * one place can be asserted by a test, while one spread across the consent
125
+ * module's call sites is a hope. It is the same reasoning that makes the ad-unit
126
+ * substitution guarantee hold, and it is why both are enforced identically.
127
+ *
128
+ * The names of what was dropped are returned rather than only logged, so an
129
+ * automated test — and the demo app's diagnostics screen — can see it.
130
+ */
131
+ function resolveConsentTesting(testing, isProduction) {
132
+ if (!testing || !isProduction) {
133
+ return {
134
+ consentTesting: testing,
135
+ ignoredConsentTools: []
136
+ };
137
+ }
138
+ const ignored = [];
139
+ if (testing.debugGeography !== undefined && testing.debugGeography !== 'disabled') {
140
+ ignored.push('debugGeography');
141
+ }
142
+ if (testing.resetOnStart === true) {
143
+ ignored.push('resetOnStart');
144
+ }
145
+ return {
146
+ consentTesting: undefined,
147
+ ignoredConsentTools: ignored
148
+ };
149
+ }
150
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_errors","require","_resolveAdUnit","_timers","_requestThrottle","_enablement","_retryPolicy","FORMATS","Set","validateConfig","config","options","environment","isDevBuild","AdsConfigError","message","Array","isArray","placements","length","byKey","Map","placement","key","trim","has","placementKey","format","String","androidAdUnitId","set","timeouts","resolveTimeouts","adValidityMs","appOpenValidityMs","undecidedWarningMs","catalog","resolvePlacementAdUnits","from","values","retryByKey","minRequestIntervalByKey","resolveEffectiveRetry","retry","minRequestIntervalMs","undefined","defaultMinRequestIntervalMs","checkBand","MIN_REQUEST_INTERVAL_BOUNDS","isProduction","consentTesting","ignoredConsentTools","resolveConsentTesting","enablement","toEnablement","enabled","testDeviceIds","testing","ignored","debugGeography","push","resetOnStart"],"sourceRoot":"../../../src","sources":["config/validate.ts"],"mappings":";;;;;;AAYA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAA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