@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,119 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createAdOriginatedTracker = createAdOriginatedTracker;
7
+ var _timers = require("./timers.js");
8
+ /**
9
+ * Ad-originated return detection (FR-128).
10
+ *
11
+ * This is the reason app-open belongs in the package rather than in the app.
12
+ * Every other app-open rule — when to show one, how often, on which screens — is
13
+ * policy the app owns. This one is not policy; it is a fact only the package
14
+ * holds. When a user dismisses a full-screen ad, or comes back from a browser an
15
+ * ad opened, the app sees an ordinary return to the foreground and has no way to
16
+ * tell it apart from any other. Showing an app-open ad on that return means
17
+ * showing an ad immediately after an ad, which is both a poor experience and the
18
+ * kind of thing store review notices.
19
+ *
20
+ * The package knows, because it holds the full-screen lock and it sees the click
21
+ * events. So it refuses, with a reason distinct from `busy` and `not_ready` so
22
+ * the app can tell what happened.
23
+ *
24
+ * **Bounded on both sides, deliberately.** Arming has to be tied to something
25
+ * that actually happened, and it has to expire:
26
+ *
27
+ * - Armed when the provider reports a full-screen ad opened, or on a click —
28
+ * that second case is a browser the ad opened, which is the only signal the
29
+ * provider gives for it. Arming is deliberately not tied to the app
30
+ * reporting that it went to the background; see `noteFullScreenShown`.
31
+ * - Disarmed without firing if the app was away longer than
32
+ * `AD_RETURN_MAX_AWAY_MS`. Someone who left, did something else, and came
33
+ * back an hour later is not returning from an ad, and treating them as if
34
+ * they were would refuse a legitimate show.
35
+ * - Refusals last `AD_RETURN_GRACE_MS` after the return, then stop. The window
36
+ * only needs to cover the moment right after the return, where an app-open
37
+ * show would otherwise fire. A window that outlived that moment would start
38
+ * refusing shows that have nothing to do with the ad.
39
+ *
40
+ * Three limits are worth stating plainly, because they are limits rather than
41
+ * defects and the documentation must not imply otherwise:
42
+ *
43
+ * 1. It cannot survive process death. If the OS kills the app while an ad is
44
+ * on screen, the return is a cold start and nothing links it to the ad.
45
+ * 2. It depends on the app reporting `setAppActive` faithfully — an obligation
46
+ * 0.1.0 already imposes for staleness re-evaluation, not a new one.
47
+ * 3. A browser opened by an ad without a preceding click event is undetectable.
48
+ *
49
+ * Pure state. No listener, no timer — it is driven entirely by transitions the
50
+ * package already observes, which is why `dispose()` has nothing extra to
51
+ * release for it.
52
+ */
53
+
54
+ function createAdOriginatedTracker() {
55
+ let lastClickAtMs = null;
56
+ let armedAtMs = null;
57
+ let refusalUntilMs = null;
58
+ return {
59
+ /**
60
+ * Arming happens here — when the provider says an ad is on screen — and
61
+ * deliberately **not** when the app reports going to the background.
62
+ *
63
+ * That was the first design and it does not survive a real device. React
64
+ * Native delivers app-state changes over the bridge, and while the app is
65
+ * backgrounded its JS thread is throttled, so the `background` event is
66
+ * routinely processed only once the app is already returning. By then the
67
+ * ad has been dismissed and the full-screen lock released, so sampling the
68
+ * lock at that moment reports "no ad was showing" and the return is let
69
+ * through — the exact case FR-128 exists to catch. Arming on a fact the
70
+ * provider reports, rather than on the timeliness of an event, removes the
71
+ * race entirely.
72
+ */
73
+ noteFullScreenShown(nowMs) {
74
+ armedAtMs = nowMs;
75
+ },
76
+ noteClick(nowMs) {
77
+ lastClickAtMs = nowMs;
78
+ // A click is itself grounds to arm: the ad may be opening a browser,
79
+ // and if it is, no `opened` callback will follow.
80
+ armedAtMs = nowMs;
81
+ },
82
+ noteBackground(nowMs) {
83
+ // Only meaningful for the browser case, and only as a refinement: a
84
+ // background that closely follows a click is that browser opening.
85
+ if (lastClickAtMs !== null && nowMs - lastClickAtMs <= _timers.AD_CLICK_WINDOW_MS) {
86
+ armedAtMs = nowMs;
87
+ }
88
+ },
89
+ noteForeground(nowMs) {
90
+ if (armedAtMs === null) {
91
+ return;
92
+ }
93
+ const away = nowMs - armedAtMs;
94
+ armedAtMs = null;
95
+ lastClickAtMs = null;
96
+ if (away > _timers.AD_RETURN_MAX_AWAY_MS) {
97
+ // Too long to still be attributable to the ad. Not a refusal.
98
+ return;
99
+ }
100
+ refusalUntilMs = nowMs + _timers.AD_RETURN_GRACE_MS;
101
+ },
102
+ isRefusing(nowMs) {
103
+ if (refusalUntilMs === null) {
104
+ return false;
105
+ }
106
+ if (nowMs >= refusalUntilMs) {
107
+ refusalUntilMs = null;
108
+ return false;
109
+ }
110
+ return true;
111
+ },
112
+ reset() {
113
+ lastClickAtMs = null;
114
+ armedAtMs = null;
115
+ refusalUntilMs = null;
116
+ }
117
+ };
118
+ }
119
+ //# sourceMappingURL=adOriginatedReturn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_timers","require","createAdOriginatedTracker","lastClickAtMs","armedAtMs","refusalUntilMs","noteFullScreenShown","nowMs","noteClick","noteBackground","AD_CLICK_WINDOW_MS","noteForeground","away","AD_RETURN_MAX_AWAY_MS","AD_RETURN_GRACE_MS","isRefusing","reset"],"sourceRoot":"../../../src","sources":["core/adOriginatedReturn.ts"],"mappings":";;;;;;AA8CA,IAAAA,OAAA,GAAAC,OAAA;AA9CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBO,SAASC,yBAAyBA,CAAA,EAAwB;EAChE,IAAIC,aAA4B,GAAG,IAAI;EACvC,IAAIC,SAAwB,GAAG,IAAI;EACnC,IAAIC,cAA6B,GAAG,IAAI;EAExC,OAAO;IACN;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACEC,mBAAmBA,CAACC,KAAK,EAAE;MAC1BH,SAAS,GAAGG,KAAK;IAClB,CAAC;IAEDC,SAASA,CAACD,KAAK,EAAE;MAChBJ,aAAa,GAAGI,KAAK;MACrB;MACA;MACAH,SAAS,GAAGG,KAAK;IAClB,CAAC;IAEDE,cAAcA,CAACF,KAAK,EAAE;MACrB;MACA;MACA,IAAIJ,aAAa,KAAK,IAAI,IAAII,KAAK,GAAGJ,aAAa,IAAIO,0BAAkB,EAAE;QAC1EN,SAAS,GAAGG,KAAK;MAClB;IACD,CAAC;IAEDI,cAAcA,CAACJ,KAAK,EAAE;MACrB,IAAIH,SAAS,KAAK,IAAI,EAAE;QACvB;MACD;MACA,MAAMQ,IAAI,GAAGL,KAAK,GAAGH,SAAS;MAC9BA,SAAS,GAAG,IAAI;MAChBD,aAAa,GAAG,IAAI;MACpB,IAAIS,IAAI,GAAGC,6BAAqB,EAAE;QACjC;QACA;MACD;MACAR,cAAc,GAAGE,KAAK,GAAGO,0BAAkB;IAC5C,CAAC;IAEDC,UAAUA,CAACR,KAAK,EAAE;MACjB,IAAIF,cAAc,KAAK,IAAI,EAAE;QAC5B,OAAO,KAAK;MACb;MACA,IAAIE,KAAK,IAAIF,cAAc,EAAE;QAC5BA,cAAc,GAAG,IAAI;QACrB,OAAO,KAAK;MACb;MACA,OAAO,IAAI;IACZ,CAAC;IAEDW,KAAKA,CAAA,EAAG;MACPb,aAAa,GAAG,IAAI;MACpBC,SAAS,GAAG,IAAI;MAChBC,cAAc,GAAG,IAAI;IACtB;EACD,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createAds = createAds;
7
+ Object.defineProperty(exports, "getInternals", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _internals.getInternals;
11
+ }
12
+ });
13
+ var _consent = require("./instance/consent.js");
14
+ var _context = require("./instance/context.js");
15
+ var _gate = require("./instance/gate.js");
16
+ var _init = require("./instance/init.js");
17
+ var _internals = require("./instance/internals.js");
18
+ var _load = require("./instance/load.js");
19
+ var _show = require("./instance/show.js");
20
+ /**
21
+ * The ads instance — the public contract's implementation.
22
+ *
23
+ * Every guarantee the specification treats as a rule rather than a convention
24
+ * converges here, and none of it needs a device to prove:
25
+ *
26
+ * FR-022 one native initialization, however many callers race
27
+ * FR-017 no request before the privacy gate permits one
28
+ * FR-011 no production ad unit outside production
29
+ * FR-029 one in-flight provider request per placement
30
+ * FR-030 exactly one full-screen ad, never a queue
31
+ * FR-031 a consumed ad is never reused
32
+ * FR-035 after dispose, a late callback updates nothing and emits nothing
33
+ *
34
+ * This file only composes. Each responsibility lives in `core/instance/` and
35
+ * takes the shared context (ADS-10): the gate, initialization and enablement,
36
+ * full-screen load, show, consent, and the banner host's internals.
37
+ *
38
+ * Nothing here imports the provider. It talks to the engine port, which the
39
+ * caller injects — the AdMob adapter in production, the fake in tests.
40
+ */
41
+
42
+ /**
43
+ * The instance itself. The public `createAds` (src/index.ts) passes the AdMob
44
+ * adapter as `defaultEngine`: core/ never loads an adapter, so it stays testable
45
+ * in Node and the provider stays replaceable (ADS-14).
46
+ */
47
+ function createAds(config, options = {}, defaultEngine = noDefaultEngine) {
48
+ // Throws on a structural fault or the FR-012 fail-closed case, before
49
+ // anything else exists.
50
+ const context = (0, _context.createInstanceContext)(config, options, defaultEngine);
51
+ const {
52
+ state,
53
+ engine,
54
+ resolved,
55
+ events
56
+ } = context;
57
+ const init = (0, _init.createInitController)(context);
58
+ const loader = (0, _load.createLoader)(context);
59
+ const shower = (0, _show.createShower)(context);
60
+ const instance = {
61
+ initialize: privacy => init.initialize(privacy),
62
+ updatePrivacy: privacy => init.updatePrivacy(privacy),
63
+ setEnabled: enabled => init.setEnablement(enabled ? 'enabled' : 'disabled'),
64
+ setEnablement: next => init.setEnablement(next),
65
+ setAppActive: active => shower.setAppActive(active),
66
+ consent: (0, _consent.createConsentApi)(context, () => init.reevaluateAfterConsent()),
67
+ getStatus: () => state.init.status,
68
+ subscribeStatus: listener => context.statusListeners.add(listener),
69
+ load: placementKey => loader.load(placementKey),
70
+ show: placementKey => shower.show(placementKey),
71
+ getPlacementState(placementKey) {
72
+ if (!resolved.placements.has(placementKey)) {
73
+ return 'unavailable';
74
+ }
75
+ if (!engine.isAvailable() || state.enablement === 'disabled') {
76
+ return 'unavailable';
77
+ }
78
+ // Reported distinctly from `unavailable` so the app can choose to hold
79
+ // the banner's space rather than reclaim it (FR-116).
80
+ if (state.enablement === 'undecided') {
81
+ return 'undecided';
82
+ }
83
+ return context.placements.get(placementKey)?.snapshot.state ?? 'idle';
84
+ },
85
+ subscribePlacement(key, listener) {
86
+ return context.placements.get(key)?.listeners.add(listener) ?? (() => undefined);
87
+ },
88
+ subscribeEvents: listener => events.subscribe(listener),
89
+ /** FR-011a — substitution is observable state, not only a log line. */
90
+ getSubstitutedPlacements: () => resolved.catalog.substitutedKeys,
91
+ /** FR-113 — the same treatment for consent tools dropped in production. */
92
+ getIgnoredConsentTools: () => resolved.ignoredConsentTools,
93
+ dispose() {
94
+ // FR-005: idempotent. A second call is a no-op, not an error.
95
+ if (state.disposed) {
96
+ return;
97
+ }
98
+ state.disposed = true;
99
+ (0, _gate.cancelAllRetries)(context);
100
+ (0, _gate.disarmUndecidedWarning)(context);
101
+ for (const [key, runtime] of context.placements) {
102
+ const abort = runtime.abortLoad;
103
+ context.releasePlacementResources(key);
104
+ runtime.listeners.clear();
105
+ // Settled rather than left hanging, with the answer a `load` after
106
+ // dispose gets (FR-159). No refusal event: nothing is emitted after
107
+ // dispose (FR-035).
108
+ abort?.({
109
+ status: 'unavailable',
110
+ reason: 'provider_missing'
111
+ });
112
+ }
113
+ context.timers.clearAll();
114
+ context.requestThrottle.clear();
115
+ context.lock.reset();
116
+ context.adReturn.reset();
117
+ context.statusListeners.clear();
118
+ context.consentListeners.clear();
119
+ events.dispose();
120
+ state.inFlightInit = null;
121
+ }
122
+ };
123
+ (0, _internals.attachInternals)(instance, (0, _internals.createInternals)(context));
124
+ return instance;
125
+ }
126
+ function noDefaultEngine() {
127
+ throw new Error('core/createAds was called without an engine; production code uses createAds from the package entrypoint.');
128
+ }
129
+ //# sourceMappingURL=adsInstance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_consent","require","_context","_gate","_init","_internals","_load","_show","createAds","config","options","defaultEngine","noDefaultEngine","context","createInstanceContext","state","engine","resolved","events","init","createInitController","loader","createLoader","shower","createShower","instance","initialize","privacy","updatePrivacy","setEnabled","enabled","setEnablement","next","setAppActive","active","consent","createConsentApi","reevaluateAfterConsent","getStatus","status","subscribeStatus","listener","statusListeners","add","load","placementKey","show","getPlacementState","placements","has","isAvailable","enablement","get","snapshot","subscribePlacement","key","listeners","undefined","subscribeEvents","subscribe","getSubstitutedPlacements","catalog","substitutedKeys","getIgnoredConsentTools","ignoredConsentTools","dispose","disposed","cancelAllRetries","disarmUndecidedWarning","runtime","abort","abortLoad","releasePlacementResources","clear","reason","timers","clearAll","requestThrottle","lock","reset","adReturn","consentListeners","inFlightInit","attachInternals","createInternals","Error"],"sourceRoot":"../../../src","sources":["core/adsInstance.ts"],"mappings":";;;;;;;;;;;;AAuBA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AA7BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA0BA;AACA;AACA;AACA;AACA;AACO,SAASO,SAASA,CACxBC,MAAiB,EACjBC,OAAyB,GAAG,CAAC,CAAC,EAC9BC,aAA8B,GAAGC,eAAe,EAClC;EACd;EACA;EACA,MAAMC,OAAO,GAAG,IAAAC,8BAAqB,EAACL,MAAM,EAAEC,OAAO,EAAEC,aAAa,CAAC;EACrE,MAAM;IAAEI,KAAK;IAAEC,MAAM;IAAEC,QAAQ;IAAEC;EAAO,CAAC,GAAGL,OAAO;EAEnD,MAAMM,IAAI,GAAG,IAAAC,0BAAoB,EAACP,OAAO,CAAC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D,OAAO,CAACiE,IAAI,CAACC,KAAK,CAAC,CAAC;MACpBlE,OAAO,CAACmE,QAAQ,CAACD,KAAK,CAAC,CAAC;MACxBlE,OAAO,CAAC6B,eAAe,CAAC+B,KAAK,CAAC,CAAC;MAC/B5D,OAAO,CAACoE,gBAAgB,CAACR,KAAK,CAAC,CAAC;MAChCvD,MAAM,CAAC+C,OAAO,CAAC,CAAC;MAChBlD,KAAK,CAACmE,YAAY,GAAG,IAAI;IAC1B;EACD,CAAC;EAED,IAAAC,0BAAe,EAAC1D,QAAQ,EAAE,IAAA2D,0BAAe,EAACvE,OAAO,CAAC,CAAC;EACnD,OAAOY,QAAQ;AAChB;AAEA,SAASb,eAAeA,CAAA,EAAc;EACrC,MAAM,IAAIyE,KAAK,CACd,0GACD,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.INITIAL_CONSENT = void 0;
7
+ exports.buildConsentOptions = buildConsentOptions;
8
+ exports.consentFailure = consentFailure;
9
+ exports.needsForm = needsForm;
10
+ exports.normalizeConsent = normalizeConsent;
11
+ exports.runConsentStep = runConsentStep;
12
+ exports.toConsentError = toConsentError;
13
+ exports.toGateInput = toGateInput;
14
+ var _errors = require("../diagnostics/errors.js");
15
+ /**
16
+ * Consent orchestration and normalization (FR-101 – FR-110).
17
+ *
18
+ * This closes the most serious gap in 0.1.0. The package *consumed* a consent
19
+ * decision but nothing *produced* one, and the flow that produces it lives
20
+ * inside the very provider library the package promised an app would never have
21
+ * to import. So any app shipping to a consent-required region had to import the
22
+ * provider directly — breaking the package's central promise at exactly the
23
+ * point where it mattered most — and hand-write the same order-sensitive
24
+ * orchestration every other such app was also writing.
25
+ *
26
+ * What this module does **not** do is as load-bearing as what it does:
27
+ *
28
+ * - It renders no consent UI. The form is the provider's (FR-103).
29
+ * - It decides nothing about jurisdictions. Which regions require consent is
30
+ * the provider's answer and the publisher's console configuration; the
31
+ * package forwards it (FR-107).
32
+ * - It never infers consent. An error, a cancellation, a dismissed form, a
33
+ * network failure — all of them land on `error`, and `error` never carries
34
+ * permission (FR-106). This is the invariant the whole module exists to
35
+ * protect, because the failure it prevents is invisible: a request that
36
+ * should not have happened looks exactly like one that should.
37
+ *
38
+ * Pure apart from the port calls it awaits. No React, no provider type crossing
39
+ * outward.
40
+ */
41
+
42
+ const INITIAL_CONSENT = exports.INITIAL_CONSENT = {
43
+ state: 'undetermined',
44
+ canRequestAds: false,
45
+ isFormAvailable: false,
46
+ privacyOptionsRequirement: 'unknown',
47
+ error: null
48
+ };
49
+
50
+ /**
51
+ * Maps the engine's status onto the published one.
52
+ *
53
+ * `canRequestAds` is taken from the provider rather than derived from the
54
+ * status. The two are not the same question — a region can be `not_required`
55
+ * while the provider still withholds permission — and inventing the second
56
+ * answer from the first is how a package ends up requesting ads it should not.
57
+ */
58
+ function normalizeConsent(info) {
59
+ const state = info.status === 'obtained' ? 'obtained' : info.status === 'required' ? 'required' : info.status === 'not_required' ? 'not_required' : 'undetermined';
60
+ return {
61
+ state,
62
+ canRequestAds: info.canRequestAds === true,
63
+ isFormAvailable: info.isFormAvailable === true,
64
+ privacyOptionsRequirement: info.privacyOptions,
65
+ error: null
66
+ };
67
+ }
68
+
69
+ /**
70
+ * The snapshot for a failed flow.
71
+ *
72
+ * `canRequestAds` is hard-coded false rather than carried through from anywhere.
73
+ * There is no failure mode in which "the flow broke" should mean "go ahead", and
74
+ * making that structural rather than conditional means no future edit can
75
+ * accidentally reintroduce the inference.
76
+ *
77
+ * The privacy-options requirement is `unknown` for the same reason: a broken
78
+ * flow has no provider verdict to forward, and reporting `not_required` would be
79
+ * the package deciding the user has no right to change their mind (FR-150).
80
+ */
81
+ function consentFailure(error) {
82
+ return {
83
+ state: 'error',
84
+ canRequestAds: false,
85
+ isFormAvailable: false,
86
+ privacyOptionsRequirement: 'unknown',
87
+ error
88
+ };
89
+ }
90
+ function toConsentError(cause, message) {
91
+ return new _errors.AdsError('consent_flow_failed', {
92
+ message,
93
+ operation: 'configure',
94
+ cause
95
+ });
96
+ }
97
+
98
+ /**
99
+ * Projects a snapshot onto the consent gate's second input.
100
+ *
101
+ * Only `obtained` and `not_required` open it. `undetermined` and `required` are
102
+ * both "we do not have permission yet" and are reported as
103
+ * `consent_flow_required`; `error` gets its own reason so an app can tell a
104
+ * user who has not answered from a flow that broke.
105
+ */
106
+ function toGateInput(snapshot) {
107
+ if (snapshot.canRequestAds && (snapshot.state === 'obtained' || snapshot.state === 'not_required')) {
108
+ return {
109
+ permitted: true
110
+ };
111
+ }
112
+ return {
113
+ permitted: false,
114
+ reason: snapshot.state === 'error' ? 'consent_flow_error' : 'consent_flow_required'
115
+ };
116
+ }
117
+
118
+ /**
119
+ * Builds the options for a consent information update.
120
+ *
121
+ * `testing` has already been stripped by config validation when the environment
122
+ * is production, so this function does not re-check. That is deliberate: the
123
+ * guarantee lives at one point rather than being re-asserted at each call site,
124
+ * which is the same reason the ad-unit substitution guarantee is provable
125
+ * (FR-113).
126
+ */
127
+ function buildConsentOptions(testing, underAgeOfConsent, testDeviceIds) {
128
+ return {
129
+ debugGeography: testing?.debugGeography,
130
+ underAgeOfConsent,
131
+ testDeviceIds
132
+ };
133
+ }
134
+
135
+ /**
136
+ * One consent operation, with the never-infer rule applied to every exit.
137
+ *
138
+ * Every path out of here is either a normalized snapshot or a normalized error
139
+ * snapshot. Nothing throws, because a consent failure must not be able to block
140
+ * app startup or crash the host (FR-108).
141
+ */
142
+ async function runConsentStep(step, failureMessage) {
143
+ try {
144
+ return normalizeConsent(await step());
145
+ } catch (cause) {
146
+ return consentFailure(toConsentError(cause, failureMessage));
147
+ }
148
+ }
149
+
150
+ /** Whether a form should be presented, per the provider's own report. */
151
+ function needsForm(snapshot) {
152
+ return snapshot.isFormAvailable && (snapshot.state === 'required' || snapshot.state === 'undetermined');
153
+ }
154
+ //# sourceMappingURL=consentFlow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_errors","require","INITIAL_CONSENT","exports","state","canRequestAds","isFormAvailable","privacyOptionsRequirement","error","normalizeConsent","info","status","privacyOptions","consentFailure","toConsentError","cause","message","AdsError","operation","toGateInput","snapshot","permitted","reason","buildConsentOptions","testing","underAgeOfConsent","testDeviceIds","debugGeography","runConsentStep","step","failureMessage","needsForm"],"sourceRoot":"../../../src","sources":["core/consentFlow.ts"],"mappings":";;;;;;;;;;;;;AA4BA,IAAAA,OAAA,GAAAC,OAAA;AA5BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOO,MAAMC,eAAgC,GAAAC,OAAA,CAAAD,eAAA,GAAG;EAC/CE,KAAK,EAAE,cAAc;EACrBC,aAAa,EAAE,KAAK;EACpBC,eAAe,EAAE,KAAK;EACtBC,yBAAyB,EAAE,SAAS;EACpCC,KAAK,EAAE;AACR,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAACC,IAAuB,EAAmB;EAC1E,MAAMN,KAAmB,GACxBM,IAAI,CAACC,MAAM,KAAK,UAAU,GACvB,UAAU,GACVD,IAAI,CAACC,MAAM,KAAK,UAAU,GACzB,UAAU,GACVD,IAAI,CAACC,MAAM,KAAK,cAAc,GAC7B,cAAc,GACd,cAAc;EAEpB,OAAO;IACNP,KAAK;IACLC,aAAa,EAAEK,IAAI,CAACL,aAAa,KAAK,IAAI;IAC1CC,eAAe,EAAEI,IAAI,CAACJ,eAAe,KAAK,IAAI;IAC9CC,yBAAyB,EAAEG,IAAI,CAACE,cAAc;IAC9CJ,KAAK,EAAE;EACR,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,cAAcA,CAACL,KAAe,EAAmB;EAChE,OAAO;IACNJ,KAAK,EAAE,OAAO;IACdC,aAA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UAAU,IAAIgB,QAAQ,CAAChB,KAAK,KAAK,cAAc,CAAC;AAElG","ignoreList":[]}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.canResume = canResume;
7
+ exports.permitsRequests = permitsRequests;
8
+ exports.toEnablement = toEnablement;
9
+ /**
10
+ * Three-state enablement and the typed result of changing it (FR-114 – FR-125).
11
+ *
12
+ * 0.1.0 had a boolean, which forced an app selling an ad-removal tier to lie at
13
+ * startup. It does not yet know whether this user has paid — that answer arrives
14
+ * after a store sync — and both available answers are wrong: `true` flashes ads
15
+ * at someone who paid to never see them, `false` delays ads for everyone else
16
+ * and then runs into the silent re-enable trap below. The missing third state
17
+ * was a hole in the contract, not an omission in the app.
18
+ *
19
+ * The package still knows nothing about payments, entitlements, or why the app
20
+ * decided anything (FR-120). It only stops insisting the decision already exists
21
+ * at construction time.
22
+ *
23
+ * Pure — no provider, no React, no I/O.
24
+ */
25
+
26
+ /**
27
+ * Normalizes the configured value. `true`/`false` keep their exact 0.1.0
28
+ * meaning, which is what makes the widened config type additive (BC-003).
29
+ */
30
+ function toEnablement(value) {
31
+ if (value === 'undecided') {
32
+ return 'undecided';
33
+ }
34
+ return value ? 'enabled' : 'disabled';
35
+ }
36
+
37
+ /** Neither `disabled` nor `undecided` may reach the provider (FR-115). */
38
+ function permitsRequests(enablement) {
39
+ return enablement === 'enabled';
40
+ }
41
+
42
+ /**
43
+ * The outcome of an enablement change.
44
+ *
45
+ * 0.1.0 returned `void`, which is the defect FR-122 supersedes. Re-enabling
46
+ * after a disable sent the init status back to `not_started`, so the app *had*
47
+ * to call `initialize()` again or every later load and show was refused — and
48
+ * nothing said so. Not the result, not the status, not the documentation. An app
49
+ * whose user's subscription lapsed would turn ads back on and silently show
50
+ * none.
51
+ */
52
+
53
+ /**
54
+ * Whether re-enabling can resume, given what the instance was doing when it was
55
+ * turned off.
56
+ *
57
+ * Only `ready` resumes. Everything else — never started, still initializing,
58
+ * blocked, failed — has no completed initialization to return to, so claiming a
59
+ * resume would put the instance in a state it never actually reached.
60
+ */
61
+ function canResume(resumeTo) {
62
+ return resumeTo === 'ready';
63
+ }
64
+ //# sourceMappingURL=enablement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["toEnablement","value","permitsRequests","enablement","canResume","resumeTo"],"sourceRoot":"../../../src","sources":["core/enablement.ts"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACO,SAASA,YAAYA,CAACC,KAA4B,EAAc;EACtE,IAAIA,KAAK,KAAK,WAAW,EAAE;IAC1B,OAAO,WAAW;EACnB;EACA,OAAOA,KAAK,GAAG,SAAS,GAAG,UAAU;AACtC;;AAEA;AACO,SAASC,eAAeA,CAACC,UAAsB,EAAW;EAChE,OAAOA,UAAU,KAAK,SAAS;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,SAASA,CAACC,QAA2B,EAAuB;EAC3E,OAAOA,QAAQ,KAAK,OAAO;AAC5B","ignoreList":[]}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createFullScreenLock = createFullScreenLock;
7
+ /**
8
+ * The single full-screen lock (FR-030).
9
+ *
10
+ * One token per instance, not per placement, because the constraint is about the
11
+ * screen rather than about any particular ad: two full-screen ads stacked on top
12
+ * of each other is a broken app regardless of which placements produced them.
13
+ *
14
+ * **There is no queue.** A refused show is refused, and the caller is told so
15
+ * immediately. Queueing would mean an ad opening at a moment the app never
16
+ * chose — seconds later, on a different screen, after the user moved on — which
17
+ * is exactly the behavior FR-045 forbids the package from deciding on its own.
18
+ */
19
+
20
+ function createFullScreenLock() {
21
+ let held = null;
22
+ return {
23
+ acquire(placementKey) {
24
+ if (held !== null) {
25
+ return false;
26
+ }
27
+ held = placementKey;
28
+ return true;
29
+ },
30
+ release(placementKey) {
31
+ // Guarded so a late dismissal from an earlier ad cannot release the
32
+ // lock out from under the ad currently on screen.
33
+ if (held === placementKey) {
34
+ held = null;
35
+ }
36
+ },
37
+ holder() {
38
+ return held;
39
+ },
40
+ isHeld() {
41
+ return held !== null;
42
+ },
43
+ reset() {
44
+ held = null;
45
+ }
46
+ };
47
+ }
48
+ //# sourceMappingURL=fullScreenLock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createFullScreenLock","held","acquire","placementKey","release","holder","isHeld","reset"],"sourceRoot":"../../../src","sources":["core/fullScreenLock.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcO,SAASA,oBAAoBA,CAAA,EAAmB;EACtD,IAAIC,IAAmB,GAAG,IAAI;EAE9B,OAAO;IACNC,OAAOA,CAACC,YAAY,EAAE;MACrB,IAAIF,IAAI,KAAK,IAAI,EAAE;QAClB,OAAO,KAAK;MACb;MACAA,IAAI,GAAGE,YAAY;MACnB,OAAO,IAAI;IACZ,CAAC;IACDC,OAAOA,CAACD,YAAY,EAAE;MACrB;MACA;MACA,IAAIF,IAAI,KAAKE,YAAY,EAAE;QAC1BF,IAAI,GAAG,IAAI;MACZ;IACD,CAAC;IACDI,MAAMA,CAAA,EAAG;MACR,OAAOJ,IAAI;IACZ,CAAC;IACDK,MAAMA,CAAA,EAAG;MACR,OAAOL,IAAI,KAAK,IAAI;IACrB,CAAC;IACDM,KAAKA,CAAA,EAAG;MACPN,IAAI,GAAG,IAAI;IACZ;EACD,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.evaluateGates = evaluateGates;
7
+ /**
8
+ * The one place that decides why a request was refused (FR-140, FR-141).
9
+ *
10
+ * After 0.2.0 there are three independent ways to be blocked — platform
11
+ * availability, the app's three-state enable flag, and consent — and they can be
12
+ * closed in any combination. A precedence spread across four call sites is not a
13
+ * precedence; it is four coincidences that currently agree. So every refusal
14
+ * path in the package routes through `evaluateGates` and nothing else compares
15
+ * gate state.
16
+ *
17
+ * **The order is availability, then enablement, then consent — most immovable
18
+ * first.** Two reasons, and they agree:
19
+ *
20
+ * 1. It is what 0.1.0 already did. `initMachine`'s BLOCK transition is refused
21
+ * outright when the status is `disabled` or `unavailable`, so consent was
22
+ * already the weakest of the three. Any other order would change observable
23
+ * behavior for a consumer who configured nothing new.
24
+ * 2. It is the most useful order for whoever is debugging. An unsupported
25
+ * platform makes the other two unfixable, so reporting "consent required" on
26
+ * a platform that can never serve an ad sends a developer off to build a flow
27
+ * that will never help. Reporting `unavailable` to an app that has also
28
+ * disabled ads costs nothing — that app was not going to show an ad either
29
+ * way.
30
+ *
31
+ * The accepted cost is that an app which *deliberately* disabled ads on an
32
+ * unsupported platform is told about the platform rather than about its own
33
+ * switch. That is fine: neither answer changes what the app does next.
34
+ *
35
+ * Pure. No provider, no React, no I/O — which is what lets the full combination
36
+ * table be a unit test rather than an integration one.
37
+ */
38
+
39
+ /** What the consent flow contributes, or `null` when the app never opted in. */
40
+
41
+ function evaluateGates(input) {
42
+ // 1. Availability. Nothing downstream can be fixed while this is closed.
43
+ if (!input.available.ok) {
44
+ return {
45
+ allowed: false,
46
+ kind: 'unavailable',
47
+ reason: input.available.reason
48
+ };
49
+ }
50
+
51
+ // 2. Enablement. `undecided` is reported separately from `disabled` because
52
+ // that distinction is the entire reason the third state exists (FR-116).
53
+ if (input.enablement === 'disabled') {
54
+ return {
55
+ allowed: false,
56
+ kind: 'disabled'
57
+ };
58
+ }
59
+ if (input.enablement === 'undecided') {
60
+ return {
61
+ allowed: false,
62
+ kind: 'undecided'
63
+ };
64
+ }
65
+
66
+ // 3. Consent, whose two inputs combine as most-restrictive-wins (FR-105a).
67
+ //
68
+ // Requesting is permitted only when both permit it, and neither can widen
69
+ // what the other allows. The case this protects is an app that obtained
70
+ // consent successfully but independently blocked ads for a reason of its own
71
+ // — a reason FR-120 forbids the package from knowing, and therefore one it
72
+ // must never overrule.
73
+ //
74
+ // When both are closed the app's own gate is reported: it is the input the
75
+ // app controls directly, and the flow's state is separately readable through
76
+ // `consent.getState()` at any time.
77
+ if (!input.appGate.permitted) {
78
+ return {
79
+ allowed: false,
80
+ kind: 'blocked',
81
+ reason: input.appGate.reason
82
+ };
83
+ }
84
+ if (input.consentGate && !input.consentGate.permitted) {
85
+ return {
86
+ allowed: false,
87
+ kind: 'blocked',
88
+ reason: input.consentGate.reason
89
+ };
90
+ }
91
+ return {
92
+ allowed: true
93
+ };
94
+ }
95
+ //# sourceMappingURL=gates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["evaluateGates","input","available","ok","allowed","kind","reason","enablement","appGate","permitted","consentGate"],"sourceRoot":"../../../src","sources":["core/gates.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;;AAyBO,SAASA,aAAaA,CAACC,KAAgB,EAAgB;EAC7D;EACA,IAAI,CAACA,KAAK,CAACC,SAAS,CAACC,EAAE,EAAE;IACxB,OAAO;MAAEC,OAAO,EAAE,KAAK;MAAEC,IAAI,EAAE,aAAa;MAAEC,MAAM,EAAEL,KAAK,CAACC,SAAS,CAACI;IAAO,CAAC;EAC/E;;EAEA;EACA;EACA,IAAIL,KAAK,CAACM,UAAU,KAAK,UAAU,EAAE;IACpC,OAAO;MAAEH,OAAO,EAAE,KAAK;MAAEC,IAAI,EAAE;IAAW,CAAC;EAC5C;EACA,IAAIJ,KAAK,CAACM,UAAU,KAAK,WAAW,EAAE;IACrC,OAAO;MAAEH,OAAO,EAAE,KAAK;MAAEC,IAAI,EAAE;IAAY,CAAC;EAC7C;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,IAAI,CAACJ,KAAK,CAACO,OAAO,CAACC,SAAS,EAAE;IAC7B,OAAO;MAAEL,OAAO,EAAE,KAAK;MAAEC,IAAI,EAAE,SAAS;MAAEC,MAAM,EAAEL,KAAK,CAACO,OAAO,CAACF;IAAO,CAAC;EACzE;EACA,IAAIL,KAAK,CAACS,WAAW,IAAI,CAACT,KAAK,CAACS,WAAW,CAACD,SAAS,EAAE;IACtD,OAAO;MAAEL,OAAO,EAAE,KAAK;MAAEC,IAAI,EAAE,SAAS;MAAEC,MAAM,EAAEL,KAAK,CAACS,WAAW,CAACJ;IAAO,CAAC;EAC7E;EAEA,OAAO;IAAEF,OAAO,EAAE;EAAK,CAAC;AACzB","ignoreList":[]}