@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
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Google's official test ad units (FR-013).
3
+ *
4
+ * PRIVATE. Never exported from `src/index.ts`.
5
+ *
6
+ * FR-013 forbids the package from carrying production identifiers, credentials,
7
+ * or host-app rules, and explicitly permits official test identifiers provided
8
+ * they are documented as such — this file is that documentation.
9
+ *
10
+ * They are hard-coded rather than read from configuration on purpose: FR-011's
11
+ * substitution guarantee must hold even when the app's configuration is the
12
+ * thing that is wrong, so it cannot depend on the app supplying anything. They
13
+ * are also not re-exported from the provider bridge's own `TestIds`, because
14
+ * that would put a provider symbol on this package's dependency path for a
15
+ * value that is really just four documented constants (FR-002).
16
+ *
17
+ * Source: Google Mobile Ads "Test ads" documentation, cross-checked against the
18
+ * bridge's `src/TestIds.ts` at version 16.0.3. These identifiers are public,
19
+ * are the same for every publisher, and always fill.
20
+ */
21
+ import type { AdFormat } from '../config/types';
22
+ export declare function testAdUnitFor(format: AdFormat): string;
23
+ /**
24
+ * Whether an identifier is one of ours.
25
+ *
26
+ * This is the structural test that drives substitution: anything that is not a
27
+ * known official test unit is treated as production-owned. Deliberately not a
28
+ * parse of AdMob's publisher-id format — a rule like that becomes wrong the day
29
+ * Google changes the format, and being wrong here means either sending a
30
+ * production request or blocking a legitimate one.
31
+ */
32
+ export declare function isOfficialTestAdUnit(adUnitId: string): boolean;
33
+ //# sourceMappingURL=testAdUnits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testAdUnits.d.ts","sourceRoot":"","sources":["../../../../src/engine/testAdUnits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAchD,wBAAgB,aAAa,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,CAEtD;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAO9D"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @chipmobilesdk/rn-ads — reusable advertising capability for
3
+ * ChipMobileSdk-family React Native apps.
4
+ *
5
+ * This is the public entrypoint (LIB-003). Modules under `config/`, `core/`,
6
+ * `engine/`, `react/`, and `diagnostics/` are private; import them only through
7
+ * this file. The fake engine lives behind `@chipmobilesdk/rn-ads/testing` so
8
+ * test doubles cannot reach a production bundle.
9
+ *
10
+ * Nothing exported here names Google, AdMob, or any provider type (FR-002).
11
+ * `src/__tests__/public-api.test.ts` asserts that mechanically.
12
+ *
13
+ * The package owns capability: a safe, consistent way to request and present
14
+ * ads. The consuming app owns policy — where ads appear, when, how often, under
15
+ * what consent, and whether they appear at all. There is no placement rule, no
16
+ * frequency cap, and no screen name in this package (FR-045).
17
+ */
18
+ import type { AdsConfig } from './config/types';
19
+ import { type AdsInstance, type CreateAdsOptions } from './core/adsInstance';
20
+ export type { AdContentRating, AdFormat, AdsConfig, ConsentSnapshot, ConsentState, ConsentTestingOptions, Enablement, Environment, FullScreenFormat, InitStatus, PlacementDefinition, PlacementState, PrivacyBlockReason, PrivacyOptions, PrivacyOptionsRequirement, RetryPolicy, Reward, TimeoutConfig, UnavailableReason, Unsubscribe, } from './config/types';
21
+ export { isFullScreenFormat } from './config/types';
22
+ export { AD_VALIDITY_BOUNDS, APP_OPEN_VALIDITY_BOUNDS, DEFAULT_AD_VALIDITY_MS, DEFAULT_APP_OPEN_VALIDITY_MS, DEFAULT_LOAD_TIMEOUT_MS, DEFAULT_RETRY_POLICY, DEFAULT_SHOW_TIMEOUT_MS, DEFAULT_UNDECIDED_WARNING_MS, LOAD_TIMEOUT_BOUNDS, RETRY_BOUNDS, SHOW_TIMEOUT_BOUNDS, UNDECIDED_WARNING_BOUNDS, } from './core/timers';
23
+ export { DEFAULT_BANNER_MIN_REQUEST_INTERVAL_MS, DEFAULT_FULL_SCREEN_MIN_REQUEST_INTERVAL_MS, MIN_REQUEST_INTERVAL_BOUNDS, defaultMinRequestIntervalMs, } from './core/requestThrottle';
24
+ export type { EnablementResult } from './core/enablement';
25
+ /**
26
+ * Creates an ads instance. This is the composition root: core's instance with
27
+ * the AdMob adapter as its default engine, so core/ itself never loads an
28
+ * adapter (ADS-14). The adapter resolves the provider bridge only on first use,
29
+ * so importing the package where there is no adapter, or no bridge, costs
30
+ * nothing and crashes nothing (FR-025, SC-004).
31
+ */
32
+ export declare function createAds(config: AdsConfig, options?: CreateAdsOptions): AdsInstance;
33
+ export type { AdsInstance, ConsentApi, InitResult, LoadResult, PrivacyOptionsFormResult, PrivacyUpdateResult, ShowResult, } from './core/adsInstance';
34
+ export { AdsBanner } from './react/AdsBanner';
35
+ export type { AdsBannerProps } from './react/AdsBanner';
36
+ export { AdsProvider, useAds } from './react/AdsProvider';
37
+ export type { AdsProviderProps } from './react/AdsProvider';
38
+ export { useAdsEvents, useAdsStatus, usePlacementState } from './react/hooks';
39
+ export { AdsConfigError, AdsError, isAdsError } from './diagnostics/errors';
40
+ export type { AdsErrorCode, AdsOperation } from './diagnostics/errors';
41
+ export type { AdEvent, AdEventListener, AdEventType, ConfigWarning, ImpressionSource, } from './diagnostics/events';
42
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAEN,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,MAAM,oBAAoB,CAAC;AAI5B,YAAY,EACX,eAAe,EACf,QAAQ,EACR,SAAS,EACT,eAAe,EACf,YAAY,EACZ,qBAAqB,EACrB,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,yBAAyB,EACzB,WAAW,EACX,MAAM,EAC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"}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Adaptive banner host (FR-038 – FR-042).
3
+ *
4
+ * The app puts this where it wants a banner. The component never inserts itself
5
+ * into the tree, never overlays app content, and ships no placeholder — the
6
+ * surrounding layout, and any loading or fallback presentation, belong to the
7
+ * app and its theme (FR-040, UX-001).
8
+ *
9
+ * When ads are disabled or unavailable it renders `null` rather than a
10
+ * zero-height view. That is not a micro-optimization: a rendered empty view
11
+ * still sits in the accessibility tree and can take screen-reader focus ahead of
12
+ * real content. `null` leaves the tree entirely (UX-003).
13
+ *
14
+ * The provider owns the banner's whole lifecycle through its own component, so
15
+ * this adapts those callbacks into the normalized event model instead of routing
16
+ * a banner through the load/show handle model, which does not fit it.
17
+ */
18
+ import React from 'react';
19
+ import { type ViewStyle } from 'react-native';
20
+ import type { PlacementState } from '../config/types';
21
+ export interface AdsBannerProps {
22
+ readonly placementKey: string;
23
+ /** Called on every state change so the app can hold or reclaim the space. */
24
+ readonly onStateChange?: (state: PlacementState) => void;
25
+ /** Applied to the container only. Never to ad content, which is not ours. */
26
+ readonly style?: ViewStyle;
27
+ }
28
+ export declare function AdsBanner({ placementKey, onStateChange, style }: AdsBannerProps): React.JSX.Element | null;
29
+ //# sourceMappingURL=AdsBanner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdsBanner.d.ts","sourceRoot":"","sources":["../../../../src/react/AdsBanner.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAmE,MAAM,OAAO,CAAC;AACxF,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAE5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAQtD,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,6EAA6E;IAC7E,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IACzD,6EAA6E;IAC7E,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;CAC3B;AAED,wBAAgB,SAAS,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE,cAAc,4BA0T/E"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Instance context (US1).
3
+ *
4
+ * Supplies one `AdsInstance` to the tree so `AdsBanner` and the hooks can reach
5
+ * it without every screen threading it through props.
6
+ *
7
+ * The provider does not create the instance. The app does, and passes it in —
8
+ * because `createAds` throws on a misconfigured catalog (FR-008, FR-012), and a
9
+ * throw during render is a far worse place to discover that than a throw at
10
+ * startup where the app can decide what to do about it.
11
+ */
12
+ import React, { type ReactNode } from 'react';
13
+ import type { AdsInstance } from '../core/adsInstance';
14
+ export interface AdsProviderProps {
15
+ readonly instance: AdsInstance;
16
+ /**
17
+ * Whether the provider forwards foreground/background transitions to the
18
+ * instance. On by default: FR-034's "never show while inactive" and
19
+ * "re-evaluate a stale ad on return" both depend on the instance being told.
20
+ * Turn it off only when the app already drives `setAppActive` itself. The
21
+ * transitions come from rn-core's shared `appLifecycle()`; `inactive` counts as
22
+ * not active.
23
+ */
24
+ readonly trackAppState?: boolean;
25
+ readonly children: ReactNode;
26
+ }
27
+ export declare function AdsProvider({ instance, trackAppState, children }: AdsProviderProps): React.JSX.Element;
28
+ /**
29
+ * Returns the instance, or null outside a provider.
30
+ *
31
+ * Null rather than a throw on purpose: a screen that renders a banner should
32
+ * degrade to rendering nothing when ads are not wired up, not take the screen
33
+ * down with it (NFR-005).
34
+ */
35
+ export declare function useAds(): AdsInstance | null;
36
+ //# sourceMappingURL=AdsProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdsProvider.d.ts","sourceRoot":"","sources":["../../../../src/react/AdsProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,EAAwC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEpF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvD,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B;;;;;;;OAOG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;CAC7B;AAED,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,aAAoB,EAAE,QAAQ,EAAE,EAAE,gBAAgB,qBAWzF;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,IAAI,WAAW,GAAG,IAAI,CAE3C"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * React bindings (US1, FR-027).
3
+ *
4
+ * Each hook subscribes to exactly what it reads. `usePlacementState` subscribes
5
+ * to one placement rather than to the whole event stream, which is what keeps a
6
+ * banner from re-rendering because an unrelated interstitial was clicked —
7
+ * PERF-002's bounded re-render assertion depends on it.
8
+ *
9
+ * None of these hand back an ad object. A consumer queries and subscribes to
10
+ * state; it never holds provider-owned memory (FR-027).
11
+ */
12
+ import type { InitStatus, PlacementState } from '../config/types';
13
+ import type { AdEventListener } from '../diagnostics/events';
14
+ /** Live state for one placement. `unavailable` outside a provider. */
15
+ export declare function usePlacementState(placementKey: string): PlacementState;
16
+ /** Live initialization status. `unavailable` outside a provider. */
17
+ export declare function useAdsStatus(): InitStatus;
18
+ /**
19
+ * Forwards every event to a listener without causing a render.
20
+ *
21
+ * Deliberately does not accumulate events into state: a package that kept an
22
+ * event log would be persisting exactly the kind of history it promises not to
23
+ * (FR-021), and re-rendering on every impression would defeat PERF-002. A screen
24
+ * that wants a visible log keeps its own.
25
+ */
26
+ export declare function useAdsEvents(listener: AdEventListener): void;
27
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG7D,sEAAsE;AACtE,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,cAAc,CActE;AAED,oEAAoE;AACpE,wBAAgB,YAAY,IAAI,UAAU,CAQzC;AAID;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAY5D"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * A clock the test drives (ADS-11).
3
+ *
4
+ * Every bounded wait in this package — retry backoff, the request throttle, a
5
+ * consent form that never answers — is measured against a clock. Injecting this
6
+ * one is what lets a suite assert the behaviour at the boundary instead of
7
+ * sleeping and hoping.
8
+ */
9
+ import type { Scheduler } from '../core/timers';
10
+ /**
11
+ * A clock a test can move by hand.
12
+ *
13
+ * Retry backoff, app-open expiry, the undecided-state warning, and the
14
+ * ad-originated-return windows are all time-dependent, and all four must be
15
+ * assertable exactly rather than approximately. Advancing a clock makes "two
16
+ * retries, 2s then 4s" a precise assertion; sleeping would make it a flaky one.
17
+ *
18
+ * Callbacks fire in due order, and a callback scheduled *during* an advance is
19
+ * honored within the same advance if its deadline has also passed — matching how
20
+ * real timers behave when work chains.
21
+ */
22
+ export interface TestClock {
23
+ now(): number;
24
+ advance(ms: number): void;
25
+ readonly scheduler: Scheduler;
26
+ pending(): number;
27
+ }
28
+ export declare function createTestClock(startMs?: number): TestClock;
29
+ //# sourceMappingURL=clock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clock.d.ts","sourceRoot":"","sources":["../../../../src/testing/clock.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,SAAS;IACzB,GAAG,IAAI,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,OAAO,IAAI,MAAM,CAAC;CAClB;AAED,wBAAgB,eAAe,CAAC,OAAO,SAAY,GAAG,SAAS,CA6C9D"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * What any `AdsEngine` must do (IOS-12, ADS-13).
3
+ *
4
+ * The same checks run against the fake engine and against the AdMob adapter over
5
+ * the provider mock (or the real provider, from a demo screen on a device), so a
6
+ * test that drives the fake proves something about the device path. The subject
7
+ * says how the provider delivers its callbacks; the checks only use the port.
8
+ */
9
+ import { type Check, type ConformanceReport } from '@chipmobilesdk/rn-core/testing';
10
+ import type { Reward } from '../config/types';
11
+ import type { AdsEngine, EngineAdHandle } from '../engine/port';
12
+ export interface AdsEngineSubject {
13
+ readonly engine: AdsEngine;
14
+ /** The provider finishes loading the ad behind `handle`. */
15
+ deliverLoad(handle: EngineAdHandle): void;
16
+ /** The provider grants a reward for the ad behind `handle`. */
17
+ deliverReward(handle: EngineAdHandle, reward: Reward): void;
18
+ /** The user closes the ad behind `handle`. */
19
+ deliverDismiss(handle: EngineAdHandle): void;
20
+ }
21
+ export interface AdsEngineHarness {
22
+ create(): AdsEngineSubject;
23
+ }
24
+ export declare const adsEngineChecks: readonly Check<AdsEngineHarness>[];
25
+ export declare function runAdsEngineConformance(harness: AdsEngineHarness): Promise<ConformanceReport>;
26
+ //# sourceMappingURL=conformance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conformance.d.ts","sourceRoot":"","sources":["../../../../src/testing/conformance.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAGN,KAAK,KAAK,EACV,KAAK,iBAAiB,EACtB,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAiB,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE/E,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,4DAA4D;IAC5D,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC1C,+DAA+D;IAC/D,aAAa,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5D,8CAA8C;IAC9C,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;CAC7C;AAED,MAAM,WAAW,gBAAgB;IAChC,MAAM,IAAI,gBAAgB,CAAC;CAC3B;AASD,eAAO,MAAM,eAAe,EAAE,SAAS,KAAK,CAAC,gBAAgB,CAAC,EAoE7D,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAE7F"}
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Deterministic in-memory ads engine for tests (SC-012).
3
+ *
4
+ * This is a real implementation of the same `AdsEngine` port the AdMob adapter
5
+ * implements, not a parallel mock — so a contract change breaks it at compile
6
+ * time and it cannot drift. Nothing here touches a native module or a network.
7
+ *
8
+ * It exists to make the package's guarantees provable. The recorded call log is
9
+ * what SC-002 asserts against ("zero production identifiers reached the
10
+ * adapter") and what SC-003 asserts against ("zero calls before consent").
11
+ * Callback emission is fully caller-driven, which is what lets a test run the
12
+ * reward-before-dismiss and dismiss-before-reward orderings and demand the same
13
+ * outcome from both (SC-007).
14
+ *
15
+ * Exported from `@chipmobilesdk/rn-ads/testing`, never from the main entrypoint,
16
+ * so test doubles cannot reach a production bundle.
17
+ */
18
+ import type { AdFormat, FullScreenFormat, Reward } from '../config/types';
19
+ export { createTestClock, type TestClock } from './clock';
20
+ import { type TestClock } from './clock';
21
+ import type { AdsEngine, EngineAdEvent, EngineConsentInfo, EngineConsentOptions, EnginePrivacy, EngineRequestOptions } from '../engine/port';
22
+ export type FakeConsentCall = {
23
+ readonly kind: 'requestInfoUpdate';
24
+ readonly options: EngineConsentOptions;
25
+ } | {
26
+ readonly kind: 'showFormIfRequired';
27
+ } | {
28
+ readonly kind: 'showPrivacyOptionsForm';
29
+ } | {
30
+ readonly kind: 'getInfo';
31
+ } | {
32
+ readonly kind: 'reset';
33
+ };
34
+ /**
35
+ * A privacy options form the test is holding open (0.4.0).
36
+ *
37
+ * Settle it whenever the test chooses, which is what lets `busy`, a second
38
+ * call, a consent update, and `dispose()` all be exercised *while* the form is
39
+ * on screen — in any order, rather than only the one a resolved promise allows.
40
+ */
41
+ export interface HeldPrivacyOptionsForm {
42
+ /**
43
+ * The user closes the form. `info` is what the provider reports afterwards,
44
+ * merged over the current information; omit it for a user who changed nothing.
45
+ */
46
+ close(info?: Partial<EngineConsentInfo>): void;
47
+ /** The form fails while open. */
48
+ fail(cause?: unknown): void;
49
+ }
50
+ export type FakeEngineCall = {
51
+ readonly kind: 'initialize';
52
+ readonly privacy: EnginePrivacy;
53
+ } | {
54
+ readonly kind: 'createFullScreen';
55
+ readonly format: FullScreenFormat;
56
+ readonly adUnitId: string;
57
+ readonly handleId: string;
58
+ /** Per-request privacy as the package sent it (FR-017's personalization half). */
59
+ readonly request?: EngineRequestOptions;
60
+ } | {
61
+ readonly kind: 'show';
62
+ readonly handleId: string;
63
+ } | {
64
+ readonly kind: 'dispose';
65
+ readonly handleId: string;
66
+ };
67
+ export interface FakeEngineOptions {
68
+ /** Simulates an unsupported platform or a missing bridge (FR-025). */
69
+ readonly available?: boolean;
70
+ /** Rejects `initialize`, for the failed-initialization path (FR-024). */
71
+ readonly failInitialize?: unknown;
72
+ /**
73
+ * Withholds the `loaded` callback so a load runs to its timeout. This is how
74
+ * FR-032's timeout behavior is tested without waiting on a real network.
75
+ */
76
+ readonly neverCallBack?: boolean;
77
+ /** Rejects `show`, for the display-failure path (FR-044). */
78
+ readonly failShow?: unknown;
79
+ /** Initial consent information. Defaults to the not-required, allowed case. */
80
+ readonly consentInfo?: Partial<EngineConsentInfo>;
81
+ /** Drives time for retry, expiry, and the undecided warning. */
82
+ readonly clock?: TestClock;
83
+ }
84
+ export interface FakeAdsEngine extends AdsEngine {
85
+ /** Every call the package made, in order. */
86
+ readonly calls: readonly FakeEngineCall[];
87
+ /** Ad unit ids passed to `createFullScreen`, in order — the SC-002 assertion. */
88
+ adUnitIds(): readonly string[];
89
+ /** Handle ids currently alive; non-empty after dispose means a leak. */
90
+ liveHandles(): readonly string[];
91
+ /** Emits a provider callback for one handle. The caller controls ordering. */
92
+ emit(handleId: string, event: EngineAdEvent): void;
93
+ /** Convenience for the common `loaded` case. */
94
+ completeLoad(handleId: string): void;
95
+ /** Emits a reward with a normalized payload. */
96
+ emitReward(handleId: string, reward?: Reward): void;
97
+ /** How many listeners are attached; must reach zero after cleanup (SC-008). */
98
+ listenerCount(): number;
99
+ /** Drops every recorded call, for tests that assert on a later window only. */
100
+ reset(): void;
101
+ /** The clock driving this engine's timers. Wire it into `createAds`. */
102
+ readonly clock: TestClock;
103
+ /** Moves the clock and fires anything due. */
104
+ advance(ms: number): void;
105
+ /** Every consent call the package made, in order (FR-113's assertion surface). */
106
+ readonly consentCalls: readonly FakeConsentCall[];
107
+ /** Sets what the consent platform will report from now on. */
108
+ setConsentInfo(info: Partial<EngineConsentInfo>): void;
109
+ /** Makes `requestInfoUpdate` reject — the flow must yield `error`, never granted. */
110
+ failConsentRequest(cause?: unknown): void;
111
+ /** Makes `showFormIfRequired` reject — dismissal is not consent (FR-106). */
112
+ failConsentForm(cause?: unknown): void;
113
+ /**
114
+ * What the privacy options form reports when the user closes it, merged over
115
+ * the current information. Unset, the form closes with nothing changed — the
116
+ * same as a user who opens it and backs out.
117
+ */
118
+ setPrivacyOptionsFormResult(info: Partial<EngineConsentInfo>): void;
119
+ /** Makes `showPrivacyOptionsForm` reject — a failure is never consent (FR-106). */
120
+ failPrivacyOptionsForm(cause?: unknown): void;
121
+ /** Holds the next privacy options form open until the test settles it. */
122
+ holdPrivacyOptionsForm(): HeldPrivacyOptionsForm;
123
+ /** Makes `getInfo` reject, for the case where even the re-read after a failed form fails. */
124
+ failConsentInfoRead(cause?: unknown): void;
125
+ }
126
+ /** The testID the fake banner renders under, for a test to find it by. */
127
+ export declare const FAKE_BANNER_TEST_ID = "ads-fake-banner";
128
+ export declare function createFakeAdsEngine(options?: FakeEngineOptions): FakeAdsEngine;
129
+ export { adsEngineChecks, runAdsEngineConformance } from './conformance';
130
+ export type { AdsEngineHarness, AdsEngineSubject } from './conformance';
131
+ /** Google's official test ad unit for each format, as the package substitutes them (FR-011). */
132
+ export declare function allTestAdUnits(): Readonly<Record<AdFormat, string>>;
133
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAe,MAAM,iBAAiB,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAG1D,OAAO,KAAK,EACX,SAAS,EAET,aAAa,EAGb,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,oBAAoB,EACpB,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,eAAe,GACxB;IAAE,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAA;CAAE,GAC9E;IAAE,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAA;CAAE,GACvC;IAAE,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAA;CAAE,GAC3C;IAAE,QAAQ,CAAC,IAAI,EAA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IACnF,sBAAsB,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9C,0EAA0E;IAC1E,sBAAsB,IAAI,sBAAsB,CAAC;IACjD,6FAA6F;IAC7F,mBAAmB,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC3C;AAWD,0EAA0E;AAC1E,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAerD,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,iBAAsB,GAAG,aAAa,CAyQlF;AAED,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACzE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAExE,gGAAgG;AAChG,wBAAgB,cAAc,IAAI,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAOnE"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The production-traffic guarantee (FR-011, FR-011a).
3
+ *
4
+ * A pure function, deliberately. This is the single point where a production ad
5
+ * unit can be replaced by an official test one, which is what makes SC-002
6
+ * provable rather than merely intended: a guarantee enforced in one place can be
7
+ * asserted; one spread across three call sites is a hope.
8
+ *
9
+ * The rule, from the 2026-09-02 clarification session:
10
+ *
11
+ * production -> use what the app configured, always, no exceptions
12
+ * development / test -> if it is not one of our own official test units,
13
+ * replace it and say so, loudly, naming the key
14
+ *
15
+ * Substitution rather than rejection is a deliberate trade. Rejecting would
16
+ * block a developer whose only mistake was pulling a teammate's environment
17
+ * file, and turn a configuration smell into a broken integration at every
18
+ * startup. Substituting keeps the app working — which is what a non-production
19
+ * build is for — and reports the problem as a first-class signal. The accepted
20
+ * cost is that a warning can be ignored; it is bounded because production never
21
+ * substitutes, so the misconfiguration surfaces there as ordinary behavior
22
+ * rather than as hidden state.
23
+ */
24
+ import type { Environment, PlacementDefinition } from './types.js';
25
+ export interface ResolvedAdUnit {
26
+ readonly effectiveAdUnitId: string;
27
+ /** True when the configured identifier was replaced. Drives FR-011a's warning. */
28
+ readonly substituted: boolean;
29
+ }
30
+ export declare function resolveAdUnit(placement: PlacementDefinition, environment: Environment): ResolvedAdUnit;
31
+ export interface ResolvedCatalog {
32
+ /** Placement key to the ad unit that will actually be requested. */
33
+ readonly byKey: ReadonlyMap<string, string>;
34
+ /** Every key whose identifier was replaced, in catalog order (FR-011a). */
35
+ readonly substitutedKeys: readonly string[];
36
+ }
37
+ /**
38
+ * Resolves a whole catalog at once, so the warning can name every affected
39
+ * placement in a single event rather than trickling one out per load — an
40
+ * integrator wants to fix the whole file, not discover it a placement at a time.
41
+ */
42
+ export declare function resolvePlacementAdUnits(placements: readonly PlacementDefinition[], environment: Environment): ResolvedCatalog;
43
+ //# sourceMappingURL=resolveAdUnit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveAdUnit.d.ts","sourceRoot":"","sources":["../../../../src/config/resolveAdUnit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAS,CAAC;AAGhE,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,kFAAkF;IAClF,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC9B;AAED,wBAAgB,aAAa,CAC5B,SAAS,EAAE,mBAAmB,EAC9B,WAAW,EAAE,WAAW,GACtB,cAAc,CAkBhB;AAED,MAAM,WAAW,eAAe;IAC/B,oEAAoE;IACpE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,2EAA2E;IAC3E,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5C;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACtC,UAAU,EAAE,SAAS,mBAAmB,EAAE,EAC1C,WAAW,EAAE,WAAW,GACtB,eAAe,CAajB"}