@chipmobilesdk/rn-ads 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (319) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/lib/commonjs/config/resolveAdUnit.js +80 -0
  3. package/lib/commonjs/config/resolveAdUnit.js.map +1 -0
  4. package/lib/commonjs/config/types.js +138 -0
  5. package/lib/commonjs/config/types.js.map +1 -0
  6. package/lib/commonjs/config/validate.js +150 -0
  7. package/lib/commonjs/config/validate.js.map +1 -0
  8. package/lib/commonjs/core/adOriginatedReturn.js +119 -0
  9. package/lib/commonjs/core/adOriginatedReturn.js.map +1 -0
  10. package/lib/commonjs/core/adsInstance.js +129 -0
  11. package/lib/commonjs/core/adsInstance.js.map +1 -0
  12. package/lib/commonjs/core/consentFlow.js +154 -0
  13. package/lib/commonjs/core/consentFlow.js.map +1 -0
  14. package/lib/commonjs/core/enablement.js +64 -0
  15. package/lib/commonjs/core/enablement.js.map +1 -0
  16. package/lib/commonjs/core/fullScreenLock.js +48 -0
  17. package/lib/commonjs/core/fullScreenLock.js.map +1 -0
  18. package/lib/commonjs/core/gates.js +95 -0
  19. package/lib/commonjs/core/gates.js.map +1 -0
  20. package/lib/commonjs/core/initMachine.js +159 -0
  21. package/lib/commonjs/core/initMachine.js.map +1 -0
  22. package/lib/commonjs/core/instance/consent.js +155 -0
  23. package/lib/commonjs/core/instance/consent.js.map +1 -0
  24. package/lib/commonjs/core/instance/context.js +217 -0
  25. package/lib/commonjs/core/instance/context.js.map +1 -0
  26. package/lib/commonjs/core/instance/gate.js +194 -0
  27. package/lib/commonjs/core/instance/gate.js.map +1 -0
  28. package/lib/commonjs/core/instance/init.js +326 -0
  29. package/lib/commonjs/core/instance/init.js.map +1 -0
  30. package/lib/commonjs/core/instance/internals.js +115 -0
  31. package/lib/commonjs/core/instance/internals.js.map +1 -0
  32. package/lib/commonjs/core/instance/load.js +458 -0
  33. package/lib/commonjs/core/instance/load.js.map +1 -0
  34. package/lib/commonjs/core/instance/show.js +243 -0
  35. package/lib/commonjs/core/instance/show.js.map +1 -0
  36. package/lib/commonjs/core/instance/types.js +6 -0
  37. package/lib/commonjs/core/instance/types.js.map +1 -0
  38. package/lib/commonjs/core/placementMachine.js +116 -0
  39. package/lib/commonjs/core/placementMachine.js.map +1 -0
  40. package/lib/commonjs/core/privacyGate.js +93 -0
  41. package/lib/commonjs/core/privacyGate.js.map +1 -0
  42. package/lib/commonjs/core/requestThrottle.js +152 -0
  43. package/lib/commonjs/core/requestThrottle.js.map +1 -0
  44. package/lib/commonjs/core/retryPolicy.js +120 -0
  45. package/lib/commonjs/core/retryPolicy.js.map +1 -0
  46. package/lib/commonjs/core/rewardedSession.js +65 -0
  47. package/lib/commonjs/core/rewardedSession.js.map +1 -0
  48. package/lib/commonjs/core/timers.js +162 -0
  49. package/lib/commonjs/core/timers.js.map +1 -0
  50. package/lib/commonjs/diagnostics/correlation.js +33 -0
  51. package/lib/commonjs/diagnostics/correlation.js.map +1 -0
  52. package/lib/commonjs/diagnostics/errors.js +152 -0
  53. package/lib/commonjs/diagnostics/errors.js.map +1 -0
  54. package/lib/commonjs/diagnostics/events.js +132 -0
  55. package/lib/commonjs/diagnostics/events.js.map +1 -0
  56. package/lib/commonjs/engine/admobBanner.js +58 -0
  57. package/lib/commonjs/engine/admobBanner.js.map +1 -0
  58. package/lib/commonjs/engine/admobEngine.js +343 -0
  59. package/lib/commonjs/engine/admobEngine.js.map +1 -0
  60. package/lib/commonjs/engine/admobErrors.js +45 -0
  61. package/lib/commonjs/engine/admobErrors.js.map +1 -0
  62. package/lib/commonjs/engine/port.js +6 -0
  63. package/lib/commonjs/engine/port.js.map +1 -0
  64. package/lib/commonjs/engine/testAdUnits.js +61 -0
  65. package/lib/commonjs/engine/testAdUnits.js.map +1 -0
  66. package/lib/commonjs/index.js +218 -0
  67. package/lib/commonjs/index.js.map +1 -0
  68. package/lib/commonjs/package.json +1 -0
  69. package/lib/commonjs/react/AdsBanner.js +317 -0
  70. package/lib/commonjs/react/AdsBanner.js.map +1 -0
  71. package/lib/commonjs/react/AdsProvider.js +54 -0
  72. package/lib/commonjs/react/AdsProvider.js.map +1 -0
  73. package/lib/commonjs/react/hooks.js +63 -0
  74. package/lib/commonjs/react/hooks.js.map +1 -0
  75. package/lib/commonjs/testing/clock.js +76 -0
  76. package/lib/commonjs/testing/clock.js.map +1 -0
  77. package/lib/commonjs/testing/conformance.js +99 -0
  78. package/lib/commonjs/testing/conformance.js.map +1 -0
  79. package/lib/commonjs/testing/index.js +389 -0
  80. package/lib/commonjs/testing/index.js.map +1 -0
  81. package/lib/module/config/resolveAdUnit.js +75 -0
  82. package/lib/module/config/resolveAdUnit.js.map +1 -0
  83. package/lib/module/config/types.js +134 -0
  84. package/lib/module/config/types.js.map +1 -0
  85. package/lib/module/config/validate.js +146 -0
  86. package/lib/module/config/validate.js.map +1 -0
  87. package/lib/module/core/adOriginatedReturn.js +115 -0
  88. package/lib/module/core/adOriginatedReturn.js.map +1 -0
  89. package/lib/module/core/adsInstance.js +121 -0
  90. package/lib/module/core/adsInstance.js.map +1 -0
  91. package/lib/module/core/consentFlow.js +143 -0
  92. package/lib/module/core/consentFlow.js.map +1 -0
  93. package/lib/module/core/enablement.js +58 -0
  94. package/lib/module/core/enablement.js.map +1 -0
  95. package/lib/module/core/fullScreenLock.js +44 -0
  96. package/lib/module/core/fullScreenLock.js.map +1 -0
  97. package/lib/module/core/gates.js +91 -0
  98. package/lib/module/core/gates.js.map +1 -0
  99. package/lib/module/core/initMachine.js +152 -0
  100. package/lib/module/core/initMachine.js.map +1 -0
  101. package/lib/module/core/instance/consent.js +151 -0
  102. package/lib/module/core/instance/consent.js.map +1 -0
  103. package/lib/module/core/instance/context.js +212 -0
  104. package/lib/module/core/instance/context.js.map +1 -0
  105. package/lib/module/core/instance/gate.js +183 -0
  106. package/lib/module/core/instance/gate.js.map +1 -0
  107. package/lib/module/core/instance/init.js +321 -0
  108. package/lib/module/core/instance/init.js.map +1 -0
  109. package/lib/module/core/instance/internals.js +109 -0
  110. package/lib/module/core/instance/internals.js.map +1 -0
  111. package/lib/module/core/instance/load.js +452 -0
  112. package/lib/module/core/instance/load.js.map +1 -0
  113. package/lib/module/core/instance/show.js +238 -0
  114. package/lib/module/core/instance/show.js.map +1 -0
  115. package/lib/module/core/instance/types.js +4 -0
  116. package/lib/module/core/instance/types.js.map +1 -0
  117. package/lib/module/core/placementMachine.js +109 -0
  118. package/lib/module/core/placementMachine.js.map +1 -0
  119. package/lib/module/core/privacyGate.js +86 -0
  120. package/lib/module/core/privacyGate.js.map +1 -0
  121. package/lib/module/core/requestThrottle.js +146 -0
  122. package/lib/module/core/requestThrottle.js.map +1 -0
  123. package/lib/module/core/retryPolicy.js +113 -0
  124. package/lib/module/core/retryPolicy.js.map +1 -0
  125. package/lib/module/core/rewardedSession.js +61 -0
  126. package/lib/module/core/rewardedSession.js.map +1 -0
  127. package/lib/module/core/timers.js +150 -0
  128. package/lib/module/core/timers.js.map +1 -0
  129. package/lib/module/diagnostics/correlation.js +29 -0
  130. package/lib/module/diagnostics/correlation.js.map +1 -0
  131. package/lib/module/diagnostics/errors.js +143 -0
  132. package/lib/module/diagnostics/errors.js.map +1 -0
  133. package/lib/module/diagnostics/events.js +128 -0
  134. package/lib/module/diagnostics/events.js.map +1 -0
  135. package/lib/module/engine/admobBanner.js +52 -0
  136. package/lib/module/engine/admobBanner.js.map +1 -0
  137. package/lib/module/engine/admobEngine.js +334 -0
  138. package/lib/module/engine/admobEngine.js.map +1 -0
  139. package/lib/module/engine/admobErrors.js +41 -0
  140. package/lib/module/engine/admobErrors.js.map +1 -0
  141. package/lib/module/engine/port.js +4 -0
  142. package/lib/module/engine/port.js.map +1 -0
  143. package/lib/module/engine/testAdUnits.js +56 -0
  144. package/lib/module/engine/testAdUnits.js.map +1 -0
  145. package/lib/module/index.js +59 -0
  146. package/lib/module/index.js.map +1 -0
  147. package/lib/module/package.json +1 -0
  148. package/lib/module/react/AdsBanner.js +312 -0
  149. package/lib/module/react/AdsBanner.js.map +1 -0
  150. package/lib/module/react/AdsProvider.js +48 -0
  151. package/lib/module/react/AdsProvider.js.map +1 -0
  152. package/lib/module/react/hooks.js +58 -0
  153. package/lib/module/react/hooks.js.map +1 -0
  154. package/lib/module/testing/clock.js +72 -0
  155. package/lib/module/testing/clock.js.map +1 -0
  156. package/lib/module/testing/conformance.js +93 -0
  157. package/lib/module/testing/conformance.js.map +1 -0
  158. package/lib/module/testing/index.js +366 -0
  159. package/lib/module/testing/index.js.map +1 -0
  160. package/lib/typescript/commonjs/config/resolveAdUnit.d.ts +43 -0
  161. package/lib/typescript/commonjs/config/resolveAdUnit.d.ts.map +1 -0
  162. package/lib/typescript/commonjs/config/types.d.ts +280 -0
  163. package/lib/typescript/commonjs/config/types.d.ts.map +1 -0
  164. package/lib/typescript/commonjs/config/validate.d.ts +49 -0
  165. package/lib/typescript/commonjs/config/validate.d.ts.map +1 -0
  166. package/lib/typescript/commonjs/core/adOriginatedReturn.d.ts +61 -0
  167. package/lib/typescript/commonjs/core/adOriginatedReturn.d.ts.map +1 -0
  168. package/lib/typescript/commonjs/core/adsInstance.d.ts +33 -0
  169. package/lib/typescript/commonjs/core/adsInstance.d.ts.map +1 -0
  170. package/lib/typescript/commonjs/core/consentFlow.d.ts +84 -0
  171. package/lib/typescript/commonjs/core/consentFlow.d.ts.map +1 -0
  172. package/lib/typescript/commonjs/core/enablement.d.ts +74 -0
  173. package/lib/typescript/commonjs/core/enablement.d.ts.map +1 -0
  174. package/lib/typescript/commonjs/core/fullScreenLock.d.ts +25 -0
  175. package/lib/typescript/commonjs/core/fullScreenLock.d.ts.map +1 -0
  176. package/lib/typescript/commonjs/core/gates.d.ts +76 -0
  177. package/lib/typescript/commonjs/core/gates.d.ts.map +1 -0
  178. package/lib/typescript/commonjs/core/initMachine.d.ts +66 -0
  179. package/lib/typescript/commonjs/core/initMachine.d.ts.map +1 -0
  180. package/lib/typescript/commonjs/core/instance/consent.d.ts +4 -0
  181. package/lib/typescript/commonjs/core/instance/consent.d.ts.map +1 -0
  182. package/lib/typescript/commonjs/core/instance/context.d.ts +118 -0
  183. package/lib/typescript/commonjs/core/instance/context.d.ts.map +1 -0
  184. package/lib/typescript/commonjs/core/instance/gate.d.ts +38 -0
  185. package/lib/typescript/commonjs/core/instance/gate.d.ts.map +1 -0
  186. package/lib/typescript/commonjs/core/instance/init.d.ts +13 -0
  187. package/lib/typescript/commonjs/core/instance/init.d.ts.map +1 -0
  188. package/lib/typescript/commonjs/core/instance/internals.d.ts +60 -0
  189. package/lib/typescript/commonjs/core/instance/internals.d.ts.map +1 -0
  190. package/lib/typescript/commonjs/core/instance/load.d.ts +9 -0
  191. package/lib/typescript/commonjs/core/instance/load.d.ts.map +1 -0
  192. package/lib/typescript/commonjs/core/instance/show.d.ts +7 -0
  193. package/lib/typescript/commonjs/core/instance/show.d.ts.map +1 -0
  194. package/lib/typescript/commonjs/core/instance/types.d.ts +240 -0
  195. package/lib/typescript/commonjs/core/instance/types.d.ts.map +1 -0
  196. package/lib/typescript/commonjs/core/placementMachine.d.ts +55 -0
  197. package/lib/typescript/commonjs/core/placementMachine.d.ts.map +1 -0
  198. package/lib/typescript/commonjs/core/privacyGate.d.ts +40 -0
  199. package/lib/typescript/commonjs/core/privacyGate.d.ts.map +1 -0
  200. package/lib/typescript/commonjs/core/requestThrottle.d.ts +99 -0
  201. package/lib/typescript/commonjs/core/requestThrottle.d.ts.map +1 -0
  202. package/lib/typescript/commonjs/core/retryPolicy.d.ts +66 -0
  203. package/lib/typescript/commonjs/core/retryPolicy.d.ts.map +1 -0
  204. package/lib/typescript/commonjs/core/rewardedSession.d.ts +37 -0
  205. package/lib/typescript/commonjs/core/rewardedSession.d.ts.map +1 -0
  206. package/lib/typescript/commonjs/core/timers.d.ts +135 -0
  207. package/lib/typescript/commonjs/core/timers.d.ts.map +1 -0
  208. package/lib/typescript/commonjs/diagnostics/correlation.d.ts +18 -0
  209. package/lib/typescript/commonjs/diagnostics/correlation.d.ts.map +1 -0
  210. package/lib/typescript/commonjs/diagnostics/errors.d.ts +59 -0
  211. package/lib/typescript/commonjs/diagnostics/errors.d.ts.map +1 -0
  212. package/lib/typescript/commonjs/diagnostics/events.d.ts +126 -0
  213. package/lib/typescript/commonjs/diagnostics/events.d.ts.map +1 -0
  214. package/lib/typescript/commonjs/engine/admobBanner.d.ts +10 -0
  215. package/lib/typescript/commonjs/engine/admobBanner.d.ts.map +1 -0
  216. package/lib/typescript/commonjs/engine/admobEngine.d.ts +71 -0
  217. package/lib/typescript/commonjs/engine/admobEngine.d.ts.map +1 -0
  218. package/lib/typescript/commonjs/engine/admobErrors.d.ts +9 -0
  219. package/lib/typescript/commonjs/engine/admobErrors.d.ts.map +1 -0
  220. package/lib/typescript/commonjs/engine/port.d.ts +171 -0
  221. package/lib/typescript/commonjs/engine/port.d.ts.map +1 -0
  222. package/lib/typescript/commonjs/engine/testAdUnits.d.ts +33 -0
  223. package/lib/typescript/commonjs/engine/testAdUnits.d.ts.map +1 -0
  224. package/lib/typescript/commonjs/index.d.ts +42 -0
  225. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  226. package/lib/typescript/commonjs/package.json +1 -0
  227. package/lib/typescript/commonjs/react/AdsBanner.d.ts +29 -0
  228. package/lib/typescript/commonjs/react/AdsBanner.d.ts.map +1 -0
  229. package/lib/typescript/commonjs/react/AdsProvider.d.ts +36 -0
  230. package/lib/typescript/commonjs/react/AdsProvider.d.ts.map +1 -0
  231. package/lib/typescript/commonjs/react/hooks.d.ts +27 -0
  232. package/lib/typescript/commonjs/react/hooks.d.ts.map +1 -0
  233. package/lib/typescript/commonjs/testing/clock.d.ts +29 -0
  234. package/lib/typescript/commonjs/testing/clock.d.ts.map +1 -0
  235. package/lib/typescript/commonjs/testing/conformance.d.ts +26 -0
  236. package/lib/typescript/commonjs/testing/conformance.d.ts.map +1 -0
  237. package/lib/typescript/commonjs/testing/index.d.ts +133 -0
  238. package/lib/typescript/commonjs/testing/index.d.ts.map +1 -0
  239. package/lib/typescript/module/config/resolveAdUnit.d.ts +43 -0
  240. package/lib/typescript/module/config/resolveAdUnit.d.ts.map +1 -0
  241. package/lib/typescript/module/config/types.d.ts +280 -0
  242. package/lib/typescript/module/config/types.d.ts.map +1 -0
  243. package/lib/typescript/module/config/validate.d.ts +49 -0
  244. package/lib/typescript/module/config/validate.d.ts.map +1 -0
  245. package/lib/typescript/module/core/adOriginatedReturn.d.ts +61 -0
  246. package/lib/typescript/module/core/adOriginatedReturn.d.ts.map +1 -0
  247. package/lib/typescript/module/core/adsInstance.d.ts +33 -0
  248. package/lib/typescript/module/core/adsInstance.d.ts.map +1 -0
  249. package/lib/typescript/module/core/consentFlow.d.ts +84 -0
  250. package/lib/typescript/module/core/consentFlow.d.ts.map +1 -0
  251. package/lib/typescript/module/core/enablement.d.ts +74 -0
  252. package/lib/typescript/module/core/enablement.d.ts.map +1 -0
  253. package/lib/typescript/module/core/fullScreenLock.d.ts +25 -0
  254. package/lib/typescript/module/core/fullScreenLock.d.ts.map +1 -0
  255. package/lib/typescript/module/core/gates.d.ts +76 -0
  256. package/lib/typescript/module/core/gates.d.ts.map +1 -0
  257. package/lib/typescript/module/core/initMachine.d.ts +66 -0
  258. package/lib/typescript/module/core/initMachine.d.ts.map +1 -0
  259. package/lib/typescript/module/core/instance/consent.d.ts +4 -0
  260. package/lib/typescript/module/core/instance/consent.d.ts.map +1 -0
  261. package/lib/typescript/module/core/instance/context.d.ts +118 -0
  262. package/lib/typescript/module/core/instance/context.d.ts.map +1 -0
  263. package/lib/typescript/module/core/instance/gate.d.ts +38 -0
  264. package/lib/typescript/module/core/instance/gate.d.ts.map +1 -0
  265. package/lib/typescript/module/core/instance/init.d.ts +13 -0
  266. package/lib/typescript/module/core/instance/init.d.ts.map +1 -0
  267. package/lib/typescript/module/core/instance/internals.d.ts +60 -0
  268. package/lib/typescript/module/core/instance/internals.d.ts.map +1 -0
  269. package/lib/typescript/module/core/instance/load.d.ts +9 -0
  270. package/lib/typescript/module/core/instance/load.d.ts.map +1 -0
  271. package/lib/typescript/module/core/instance/show.d.ts +7 -0
  272. package/lib/typescript/module/core/instance/show.d.ts.map +1 -0
  273. package/lib/typescript/module/core/instance/types.d.ts +240 -0
  274. package/lib/typescript/module/core/instance/types.d.ts.map +1 -0
  275. package/lib/typescript/module/core/placementMachine.d.ts +55 -0
  276. package/lib/typescript/module/core/placementMachine.d.ts.map +1 -0
  277. package/lib/typescript/module/core/privacyGate.d.ts +40 -0
  278. package/lib/typescript/module/core/privacyGate.d.ts.map +1 -0
  279. package/lib/typescript/module/core/requestThrottle.d.ts +99 -0
  280. package/lib/typescript/module/core/requestThrottle.d.ts.map +1 -0
  281. package/lib/typescript/module/core/retryPolicy.d.ts +66 -0
  282. package/lib/typescript/module/core/retryPolicy.d.ts.map +1 -0
  283. package/lib/typescript/module/core/rewardedSession.d.ts +37 -0
  284. package/lib/typescript/module/core/rewardedSession.d.ts.map +1 -0
  285. package/lib/typescript/module/core/timers.d.ts +135 -0
  286. package/lib/typescript/module/core/timers.d.ts.map +1 -0
  287. package/lib/typescript/module/diagnostics/correlation.d.ts +18 -0
  288. package/lib/typescript/module/diagnostics/correlation.d.ts.map +1 -0
  289. package/lib/typescript/module/diagnostics/errors.d.ts +59 -0
  290. package/lib/typescript/module/diagnostics/errors.d.ts.map +1 -0
  291. package/lib/typescript/module/diagnostics/events.d.ts +126 -0
  292. package/lib/typescript/module/diagnostics/events.d.ts.map +1 -0
  293. package/lib/typescript/module/engine/admobBanner.d.ts +10 -0
  294. package/lib/typescript/module/engine/admobBanner.d.ts.map +1 -0
  295. package/lib/typescript/module/engine/admobEngine.d.ts +71 -0
  296. package/lib/typescript/module/engine/admobEngine.d.ts.map +1 -0
  297. package/lib/typescript/module/engine/admobErrors.d.ts +9 -0
  298. package/lib/typescript/module/engine/admobErrors.d.ts.map +1 -0
  299. package/lib/typescript/module/engine/port.d.ts +171 -0
  300. package/lib/typescript/module/engine/port.d.ts.map +1 -0
  301. package/lib/typescript/module/engine/testAdUnits.d.ts +33 -0
  302. package/lib/typescript/module/engine/testAdUnits.d.ts.map +1 -0
  303. package/lib/typescript/module/index.d.ts +42 -0
  304. package/lib/typescript/module/index.d.ts.map +1 -0
  305. package/lib/typescript/module/package.json +1 -0
  306. package/lib/typescript/module/react/AdsBanner.d.ts +29 -0
  307. package/lib/typescript/module/react/AdsBanner.d.ts.map +1 -0
  308. package/lib/typescript/module/react/AdsProvider.d.ts +36 -0
  309. package/lib/typescript/module/react/AdsProvider.d.ts.map +1 -0
  310. package/lib/typescript/module/react/hooks.d.ts +27 -0
  311. package/lib/typescript/module/react/hooks.d.ts.map +1 -0
  312. package/lib/typescript/module/testing/clock.d.ts +29 -0
  313. package/lib/typescript/module/testing/clock.d.ts.map +1 -0
  314. package/lib/typescript/module/testing/conformance.d.ts +26 -0
  315. package/lib/typescript/module/testing/conformance.d.ts.map +1 -0
  316. package/lib/typescript/module/testing/index.d.ts +133 -0
  317. package/lib/typescript/module/testing/index.d.ts.map +1 -0
  318. package/package.json +48 -12
  319. package/src/testing/index.ts +17 -3
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * The single full-screen lock (FR-030).
5
+ *
6
+ * One token per instance, not per placement, because the constraint is about the
7
+ * screen rather than about any particular ad: two full-screen ads stacked on top
8
+ * of each other is a broken app regardless of which placements produced them.
9
+ *
10
+ * **There is no queue.** A refused show is refused, and the caller is told so
11
+ * immediately. Queueing would mean an ad opening at a moment the app never
12
+ * chose — seconds later, on a different screen, after the user moved on — which
13
+ * is exactly the behavior FR-045 forbids the package from deciding on its own.
14
+ */
15
+
16
+ export function createFullScreenLock() {
17
+ let held = null;
18
+ return {
19
+ acquire(placementKey) {
20
+ if (held !== null) {
21
+ return false;
22
+ }
23
+ held = placementKey;
24
+ return true;
25
+ },
26
+ release(placementKey) {
27
+ // Guarded so a late dismissal from an earlier ad cannot release the
28
+ // lock out from under the ad currently on screen.
29
+ if (held === placementKey) {
30
+ held = null;
31
+ }
32
+ },
33
+ holder() {
34
+ return held;
35
+ },
36
+ isHeld() {
37
+ return held !== null;
38
+ },
39
+ reset() {
40
+ held = null;
41
+ }
42
+ };
43
+ }
44
+ //# 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;;AAcA,OAAO,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,91 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * The one place that decides why a request was refused (FR-140, FR-141).
5
+ *
6
+ * After 0.2.0 there are three independent ways to be blocked — platform
7
+ * availability, the app's three-state enable flag, and consent — and they can be
8
+ * closed in any combination. A precedence spread across four call sites is not a
9
+ * precedence; it is four coincidences that currently agree. So every refusal
10
+ * path in the package routes through `evaluateGates` and nothing else compares
11
+ * gate state.
12
+ *
13
+ * **The order is availability, then enablement, then consent — most immovable
14
+ * first.** Two reasons, and they agree:
15
+ *
16
+ * 1. It is what 0.1.0 already did. `initMachine`'s BLOCK transition is refused
17
+ * outright when the status is `disabled` or `unavailable`, so consent was
18
+ * already the weakest of the three. Any other order would change observable
19
+ * behavior for a consumer who configured nothing new.
20
+ * 2. It is the most useful order for whoever is debugging. An unsupported
21
+ * platform makes the other two unfixable, so reporting "consent required" on
22
+ * a platform that can never serve an ad sends a developer off to build a flow
23
+ * that will never help. Reporting `unavailable` to an app that has also
24
+ * disabled ads costs nothing — that app was not going to show an ad either
25
+ * way.
26
+ *
27
+ * The accepted cost is that an app which *deliberately* disabled ads on an
28
+ * unsupported platform is told about the platform rather than about its own
29
+ * switch. That is fine: neither answer changes what the app does next.
30
+ *
31
+ * Pure. No provider, no React, no I/O — which is what lets the full combination
32
+ * table be a unit test rather than an integration one.
33
+ */
34
+
35
+ /** What the consent flow contributes, or `null` when the app never opted in. */
36
+
37
+ export function evaluateGates(input) {
38
+ // 1. Availability. Nothing downstream can be fixed while this is closed.
39
+ if (!input.available.ok) {
40
+ return {
41
+ allowed: false,
42
+ kind: 'unavailable',
43
+ reason: input.available.reason
44
+ };
45
+ }
46
+
47
+ // 2. Enablement. `undecided` is reported separately from `disabled` because
48
+ // that distinction is the entire reason the third state exists (FR-116).
49
+ if (input.enablement === 'disabled') {
50
+ return {
51
+ allowed: false,
52
+ kind: 'disabled'
53
+ };
54
+ }
55
+ if (input.enablement === 'undecided') {
56
+ return {
57
+ allowed: false,
58
+ kind: 'undecided'
59
+ };
60
+ }
61
+
62
+ // 3. Consent, whose two inputs combine as most-restrictive-wins (FR-105a).
63
+ //
64
+ // Requesting is permitted only when both permit it, and neither can widen
65
+ // what the other allows. The case this protects is an app that obtained
66
+ // consent successfully but independently blocked ads for a reason of its own
67
+ // — a reason FR-120 forbids the package from knowing, and therefore one it
68
+ // must never overrule.
69
+ //
70
+ // When both are closed the app's own gate is reported: it is the input the
71
+ // app controls directly, and the flow's state is separately readable through
72
+ // `consent.getState()` at any time.
73
+ if (!input.appGate.permitted) {
74
+ return {
75
+ allowed: false,
76
+ kind: 'blocked',
77
+ reason: input.appGate.reason
78
+ };
79
+ }
80
+ if (input.consentGate && !input.consentGate.permitted) {
81
+ return {
82
+ allowed: false,
83
+ kind: 'blocked',
84
+ reason: input.consentGate.reason
85
+ };
86
+ }
87
+ return {
88
+ allowed: true
89
+ };
90
+ }
91
+ //# 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;;AAyBA,OAAO,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":[]}
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Initialization state machine (FR-022 – FR-025).
5
+ *
6
+ * Pure and synchronous: it decides what a transition means; the instance
7
+ * performs the I/O. That split is what makes every rule in data-model.md §3.1
8
+ * testable without a provider.
9
+ *
10
+ * The load-bearing invariant is idempotence. Three consumers calling
11
+ * `initialize()` at once must produce exactly one native initialization and
12
+ * three identical results (SC-005) — the instance holds one in-flight promise,
13
+ * and this machine refuses to leave `initializing` for anything but a terminal
14
+ * outcome.
15
+ */
16
+
17
+ export const initialInit = {
18
+ status: 'not_started',
19
+ blockReason: null,
20
+ unavailableReason: null,
21
+ error: null,
22
+ resumeTo: null
23
+ };
24
+ function at(status, patch = {}) {
25
+ return {
26
+ ...initialInit,
27
+ status,
28
+ ...patch
29
+ };
30
+ }
31
+
32
+ /**
33
+ * States that behave as "switched off" for everything downstream.
34
+ *
35
+ * `undecided` is grouped with `disabled` for request handling — neither may
36
+ * reach the provider — while staying a distinct reported status, which is the
37
+ * only reason the third state is worth having (FR-115, FR-116).
38
+ */
39
+ function isSwitchedOff(status) {
40
+ return status === 'disabled' || status === 'undecided';
41
+ }
42
+
43
+ /**
44
+ * States a fresh start may leave from.
45
+ *
46
+ * `blocked` is included because resolving consent and trying again is the
47
+ * documented, expected flow (FR-019). `initializing` is excluded because that is
48
+ * exactly the race idempotence exists to prevent. `ready` is excluded because
49
+ * re-initializing an initialized provider is what FR-022 forbids.
50
+ */
51
+ const STARTABLE = new Set(['not_started', 'blocked', 'failed']);
52
+ export function canStart(status) {
53
+ return STARTABLE.has(status);
54
+ }
55
+
56
+ /** Only `ready` may issue requests. Everything else is a refusal with a reason. */
57
+ export function canRequest(status) {
58
+ return status === 'ready';
59
+ }
60
+
61
+ /**
62
+ * What to remember when switching off.
63
+ *
64
+ * Only a completed initialization is worth keeping. A `blocked` or `failed`
65
+ * instance has nothing to resume to, and remembering `initializing` would mean
66
+ * resuming into a state whose in-flight operation was already abandoned.
67
+ */
68
+ function rememberFor(state) {
69
+ if (state.status === 'ready') {
70
+ return 'ready';
71
+ }
72
+ // Preserve an earlier memory across an off -> off transition, so
73
+ // disable -> undecided -> enable still resumes.
74
+ return isSwitchedOff(state.status) ? state.resumeTo : null;
75
+ }
76
+ export function initReducer(state, event) {
77
+ switch (event.type) {
78
+ case 'START':
79
+ // `disabled`, `undecided`, and `unavailable` all refuse a start:
80
+ // nothing may reach the provider while any of them holds.
81
+ if (isSwitchedOff(state.status) || state.status === 'unavailable') {
82
+ return state;
83
+ }
84
+ return canStart(state.status) ? at('initializing') : state;
85
+ case 'BLOCK':
86
+ // Consent is the weakest of the three gates, so it never overwrites a
87
+ // stronger one. This guard is the 0.1.0 behavior that settled the
88
+ // precedence question: availability and enablement already outranked
89
+ // consent, and FR-140 makes that explicit rather than inventing it.
90
+ if (isSwitchedOff(state.status) || state.status === 'unavailable') {
91
+ return state;
92
+ }
93
+ // A gate withdrawn after initialization does not un-initialize the
94
+ // provider — it stops requests. Reporting `blocked` is what the app
95
+ // acts on; the native SDK stays as it is.
96
+ return at('blocked', {
97
+ blockReason: event.reason
98
+ });
99
+ case 'UNAVAILABLE':
100
+ return at('unavailable', {
101
+ unavailableReason: event.reason
102
+ });
103
+ case 'DISABLE':
104
+ // Availability outranks enablement (FR-140a). 0.1.0 left these two
105
+ // unguarded against each other, so whichever arrived last won and the
106
+ // reported reason depended on timing — exactly the incidental ordering
107
+ // FR-140 forbids. Availability winning is deterministic and is the
108
+ // more useful answer: an unsupported platform cannot be fixed by
109
+ // turning ads back on.
110
+ if (state.status === 'unavailable') {
111
+ return state;
112
+ }
113
+ return at('disabled', {
114
+ resumeTo: rememberFor(state)
115
+ });
116
+ case 'UNDECIDE':
117
+ if (state.status === 'unavailable') {
118
+ return state;
119
+ }
120
+ return at('undecided', {
121
+ resumeTo: rememberFor(state)
122
+ });
123
+ case 'ENABLE':
124
+ {
125
+ if (!isSwitchedOff(state.status)) {
126
+ return state;
127
+ }
128
+ // Resume only from a completed initialization. Anything else has no
129
+ // ready state to return to, and claiming one would put the instance in
130
+ // a state it never actually reached — so the caller is told to
131
+ // initialize instead, explicitly (FR-121).
132
+ return state.resumeTo === 'ready' ? at('ready') : at('not_started');
133
+ }
134
+ case 'SUCCEED':
135
+ // Only a transition out of `initializing` counts. A `SUCCEED` arriving
136
+ // after a disable or a block is a late callback, and honoring it would
137
+ // resurrect a state the app deliberately left.
138
+ return state.status === 'initializing' ? at('ready') : state;
139
+ case 'RESUME':
140
+ // Same guard as START, for the same reason: `disabled`, `undecided` and
141
+ // `unavailable` are not left by a gate reopening. `canStart` excludes
142
+ // them, and `initializing`, whose own outcome is still on its way.
143
+ return canStart(state.status) ? at('ready') : state;
144
+ case 'FAIL':
145
+ return state.status === 'initializing' ? at('failed', {
146
+ error: event.error
147
+ }) : state;
148
+ default:
149
+ return state;
150
+ }
151
+ }
152
+ //# sourceMappingURL=initMachine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["initialInit","status","blockReason","unavailableReason","error","resumeTo","at","patch","isSwitchedOff","STARTABLE","Set","canStart","has","canRequest","rememberFor","state","initReducer","event","type","reason"],"sourceRoot":"../../../src","sources":["core/initMachine.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuCA,OAAO,MAAMA,WAAyB,GAAG;EACxCC,MAAM,EAAE,aAAa;EACrBC,WAAW,EAAE,IAAI;EACjBC,iBAAiB,EAAE,IAA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EAAE,CAAC,OAAO,CAAC,GAAGS,KAAK;IAEpD,KAAK,MAAM;MACV,OAAOA,KAAK,CAACd,MAAM,KAAK,cAAc,GAAGK,EAAE,CAAC,QAAQ,EAAE;QAAEF,KAAK,EAAEa,KAAK,CAACb;MAAM,CAAC,CAAC,GAAGW,KAAK;IAEtF;MACC,OAAOA,KAAK;EACd;AACD","ignoreList":[]}
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * The optional consent capability (FR-101 – FR-113, FR-150 – FR-157).
5
+ *
6
+ * Every outcome feeds the gate through `reevaluate`, so the app never wires
7
+ * consent to requests by hand (FR-105), and a failure is never a grant
8
+ * (FR-106).
9
+ */
10
+
11
+ import { buildConsentOptions, INITIAL_CONSENT, needsForm, normalizeConsent, runConsentStep, toConsentError } from "../consentFlow.js";
12
+ export function createConsentApi(context, reevaluate) {
13
+ const {
14
+ state,
15
+ engine,
16
+ resolved
17
+ } = context;
18
+
19
+ /** Applies an outcome unless the instance went away while it was pending. */
20
+ async function settle(next) {
21
+ if (state.disposed) {
22
+ return state.consent;
23
+ }
24
+ context.setConsent(next);
25
+ await reevaluate();
26
+ return next;
27
+ }
28
+ return {
29
+ async requestInfoUpdate() {
30
+ if (state.disposed) {
31
+ return state.consent;
32
+ }
33
+ // Marks the flow as in use. Until this is called the gate sees no consent
34
+ // input at all, which is how an app that supplies its own gate keeps
35
+ // 0.1.0 behavior without opting out of anything (FR-102).
36
+ state.consentStarted = true;
37
+ if (resolved.consentTesting?.resetOnStart) {
38
+ try {
39
+ engine.consent.reset();
40
+ } catch {
41
+ // A failed reset must not abort the update; the flow continues
42
+ // against whatever state is stored.
43
+ }
44
+ }
45
+ const next = await runConsentStep(() => engine.consent.requestInfoUpdate(buildConsentOptions(resolved.consentTesting, state.currentPrivacy?.underAgeOfConsent, resolved.testDeviceIds)), 'consent information update failed');
46
+ return settle(next);
47
+ },
48
+ async showFormIfRequired() {
49
+ if (state.disposed) {
50
+ return state.consent;
51
+ }
52
+ state.consentStarted = true;
53
+ // Nothing to present is not an error: a region that does not require
54
+ // consent is the normal case (FR-107). Nor is a privacy options form
55
+ // already on screen — one provider form at a time.
56
+ if (!needsForm(state.consent) || state.privacyOptionsFormOpen) {
57
+ return state.consent;
58
+ }
59
+ state.consentFormsOpen += 1;
60
+ let next;
61
+ try {
62
+ next = await runConsentStep(() => engine.consent.showFormIfRequired(), 'consent form failed');
63
+ } finally {
64
+ state.consentFormsOpen -= 1;
65
+ }
66
+ return settle(next);
67
+ },
68
+ async showPrivacyOptionsForm() {
69
+ // The refusals, most immovable first — the same reading order as the
70
+ // request gates, so the answer is the most useful one.
71
+ if (state.disposed) {
72
+ return {
73
+ status: 'unavailable',
74
+ reason: 'provider_missing'
75
+ };
76
+ }
77
+ if (!engine.isAvailable()) {
78
+ return {
79
+ status: 'unavailable',
80
+ reason: 'unsupported_platform'
81
+ };
82
+ }
83
+ if (state.privacyOptionsFormOpen || state.consentFormsOpen > 0) {
84
+ return {
85
+ status: 'busy'
86
+ };
87
+ }
88
+ if (state.consent.privacyOptionsRequirement === 'unknown') {
89
+ return {
90
+ status: 'info_update_required'
91
+ };
92
+ }
93
+ if (state.consent.privacyOptionsRequirement !== 'required') {
94
+ // The provider's verdict, not a region guess of ours (FR-150).
95
+ return {
96
+ status: 'not_required'
97
+ };
98
+ }
99
+ state.privacyOptionsFormOpen = true;
100
+ let next;
101
+ let failure = null;
102
+ try {
103
+ next = normalizeConsent(await engine.consent.showPrivacyOptionsForm());
104
+ } catch (cause) {
105
+ failure = toConsentError(cause, 'privacy options form failed');
106
+ // The form did not complete, so the stored decision is the provider's
107
+ // to report — ask rather than assume. Collapsing to `error` the way a
108
+ // failed first-time form does would revoke a consent the user never
109
+ // changed. If the provider cannot answer either, the gate closes: a
110
+ // failure is never consent (FR-106).
111
+ next = state.disposed ? state.consent : await runConsentStep(() => engine.consent.getInfo(), 'consent information could not be read after the privacy options form failed');
112
+ } finally {
113
+ state.privacyOptionsFormOpen = false;
114
+ }
115
+ // dispose() during the form: the form stays until the user closes it, but
116
+ // its outcome reaches nobody (FR-157).
117
+ if (state.disposed) {
118
+ return {
119
+ status: 'unavailable',
120
+ reason: 'provider_missing'
121
+ };
122
+ }
123
+ await settle(next);
124
+ return failure ? {
125
+ status: 'failed',
126
+ error: failure
127
+ } : {
128
+ status: 'shown',
129
+ consent: next
130
+ };
131
+ },
132
+ getState() {
133
+ return state.consent;
134
+ },
135
+ subscribe: listener => context.consentListeners.add(listener),
136
+ async reset() {
137
+ // Config validation strips the testing tools in production, so this is
138
+ // inert there without a check here (FR-113).
139
+ if (state.disposed || !resolved.consentTesting) {
140
+ return;
141
+ }
142
+ try {
143
+ engine.consent.reset();
144
+ } catch {
145
+ // The stored state is the provider's; a failed reset leaves it as it was.
146
+ }
147
+ context.setConsent(INITIAL_CONSENT);
148
+ }
149
+ };
150
+ }
151
+ //# sourceMappingURL=consent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["buildConsentOptions","INITIAL_CONSENT","needsForm","normalizeConsent","runConsentStep","toConsentError","createConsentApi","context","reevaluate","state","engine","resolved","settle","next","disposed","consent","setConsent","requestInfoUpdate","consentStarted","consentTesting","resetOnStart","reset","currentPrivacy","underAgeOfConsent","testDeviceIds","showFormIfRequired","privacyOptionsFormOpen","consentFormsOpen","showPrivacyOptionsForm","status","reason","isAvailable","privacyOptionsRequirement","failure","cause","getInfo","error","getState","subscribe","listener","consentListeners","add"],"sourceRoot":"../../../../src","sources":["core/instance/consent.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SACCA,mBAAmB,EACnBC,eAAe,EACfC,SAAS,EACTC,gBAAgB,EAChBC,cAAc,EACdC,cAAc,QACR,mBAAgB;AAIvB,OAAO,SAASC,gBAAgBA,CAC/BC,OAAwB,EACxBC,UAA+B,EAClB;EACb,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC;EAAS,CAAC,GAAGJ,OAAO;;EAE3C;EACA,eAAeK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Ac,CACpB,MAAMM,MAAM,CAACK,OAAO,CAACoB,OAAO,CAAC,CAAC,EAC9B,6EACD,CAAC;MACJ,CAAC,SAAS;QACT1B,KAAK,CAACiB,sBAAsB,GAAG,KAAK;MACrC;MACA;MACA;MACA,IAAIjB,KAAK,CAACK,QAAQ,EAAE;QACnB,OAAO;UAAEe,MAAM,EAAE,aAAa;UAAEC,MAAM,EAAE;QAAmB,CAAC;MAC7D;MACA,MAAMlB,MAAM,CAACC,IAAI,CAAC;MAClB,OAAOoB,OAAO,GAAG;QAAEJ,MAAM,EAAE,QAAQ;QAAEO,KAAK,EAAEH;MAAQ,CAAC,GAAG;QAAEJ,MAAM,EAAE,OAAO;QAAEd,OAAO,EAAEF;MAAK,CAAC;IAC3F,CAAC;IAEDwB,QAAQA,CAAA,EAAG;MACV,OAAO5B,KAAK,CAACM,OAAO;IACrB,CAAC;IAEDuB,SAAS,EAAEC,QAAQ,IAAIhC,OAAO,CAACiC,gBAAgB,CAACC,GAAG,CAACF,QAAQ,CAAC;IAE7D,MAAMlB,KAAKA,CAAA,EAAG;MACb;MACA;MACA,IAAIZ,KAAK,CAACK,QAAQ,IAAI,CAACH,QAAQ,CAACQ,cAAc,EAAE;QAC/C;MACD;MACA,IAAI;QACHT,MAAM,CAACK,OAAO,CAACM,KAAK,CAAC,CAAC;MACvB,CAAC,CAAC,MAAM;QACP;MAAA;MAEDd,OAAO,CAACS,UAAU,CAACf,eAAe,CAAC;IACpC;EACD,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,212 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * What every part of an ads instance shares (ADS-10).
5
+ *
6
+ * 0.5.0 kept all of this as `let` bindings inside one 1,500-line closure, and
7
+ * each path that closed a gate re-implemented its own teardown — which is how
8
+ * ADS-01, ADS-02 and ADS-04 happened. Here the state is one object, the
9
+ * placement runtimes are one map, and the helpers that change them are defined
10
+ * once. The controllers (gate, init, load, show, consent, banner) each take this
11
+ * context and nothing else.
12
+ */
13
+ import { createListenerSet, isDevBuild as detectDevBuild } from '@chipmobilesdk/rn-core';
14
+ import { validateConfig } from "../../config/validate.js";
15
+ import { createCorrelationIssuer } from "../../diagnostics/correlation.js";
16
+ import { AdsError } from "../../diagnostics/errors.js";
17
+ import { createEventEmitter } from "../../diagnostics/events.js";
18
+ import { createAdOriginatedTracker } from "../adOriginatedReturn.js";
19
+ import { INITIAL_CONSENT } from "../consentFlow.js";
20
+ import { createFullScreenLock } from "../fullScreenLock.js";
21
+ import { initialInit, initReducer } from "../initMachine.js";
22
+ import { initialPlacement, placementReducer } from "../placementMachine.js";
23
+ import { createRequestThrottle } from "../requestThrottle.js";
24
+ import { createTimerSet } from "../timers.js";
25
+
26
+ /** Everything about the instance that changes after creation. */
27
+
28
+ export function createInstanceContext(config, options, defaultEngine) {
29
+ const isDevBuild = options.isDevBuild ?? detectDevBuild();
30
+ const now = options.now ?? (() => Date.now());
31
+
32
+ // Throws on a structural fault or the FR-012 fail-closed case. Deliberately
33
+ // before anything else: a misconfigured instance should not exist at all.
34
+ const resolved = validateConfig(config, {
35
+ isDevBuild
36
+ });
37
+ const engine = options.engine ?? defaultEngine();
38
+ const events = createEventEmitter();
39
+
40
+ /**
41
+ * Status, consent and placement listeners are consumer code. A failure is
42
+ * isolated from the rest and reported the way an event listener's is: as an
43
+ * `internal_error` event (FR-056).
44
+ */
45
+ const listenerOptions = {
46
+ onListenerError(error) {
47
+ events.emit({
48
+ type: 'internal_error',
49
+ timestamp: now(),
50
+ error: new AdsError('internal_error', {
51
+ message: 'consumer listener threw',
52
+ cause: error
53
+ })
54
+ });
55
+ }
56
+ };
57
+ const placements = new Map();
58
+ for (const key of resolved.placements.keys()) {
59
+ placements.set(key, {
60
+ snapshot: initialPlacement,
61
+ correlationId: null,
62
+ dismissed: false,
63
+ handle: null,
64
+ unsubscribeEngine: null,
65
+ inFlightLoad: null,
66
+ abortLoad: null,
67
+ cancelLoadTimer: null,
68
+ cancelShowTimer: null,
69
+ rewarded: null,
70
+ listeners: createListenerSet(listenerOptions),
71
+ retryAttempts: 0,
72
+ cancelRetry: null
73
+ });
74
+ }
75
+ const state = {
76
+ /**
77
+ * An instance told it is `undecided` says so from the moment it exists, or
78
+ * it would report `not_started` until `initialize()` runs — which looks like
79
+ * a disabled instance at exactly the point an app decides whether to reserve
80
+ * the banner's space (FR-116). `disabled` keeps 0.1.0's `not_started`
81
+ * (BC-004).
82
+ */
83
+ init: resolved.enablement === 'undecided' ? initReducer(initialInit, {
84
+ type: 'UNDECIDE'
85
+ }) : initialInit,
86
+ enablement: resolved.enablement,
87
+ appActive: true,
88
+ consent: INITIAL_CONSENT,
89
+ consentStarted: false,
90
+ consentFormsOpen: 0,
91
+ privacyOptionsFormOpen: false,
92
+ providerInitialized: false,
93
+ undecidedWarned: false,
94
+ cancelUndecidedTimer: null,
95
+ appliedPrivacy: null,
96
+ currentPrivacy: null,
97
+ inFlightInit: null,
98
+ disposed: false,
99
+ warnedSubstitution: false
100
+ };
101
+ const statusListeners = createListenerSet(listenerOptions);
102
+ const consentListeners = createListenerSet(listenerOptions);
103
+ const context = {
104
+ resolved,
105
+ engine,
106
+ now,
107
+ events,
108
+ correlation: createCorrelationIssuer(),
109
+ requestThrottle: createRequestThrottle(now),
110
+ timers: createTimerSet(options.scheduler),
111
+ lock: createFullScreenLock(),
112
+ adReturn: createAdOriginatedTracker(),
113
+ state,
114
+ placements,
115
+ statusListeners,
116
+ consentListeners,
117
+ placement(key) {
118
+ const runtime = placements.get(key);
119
+ const definition = resolved.placements.get(key);
120
+ return runtime && definition ? {
121
+ runtime,
122
+ definition
123
+ } : null;
124
+ },
125
+ setInit(next) {
126
+ const previous = state.init;
127
+ state.init = next;
128
+ if (next === previous || next.status === previous.status) {
129
+ return;
130
+ }
131
+ events.emit({
132
+ type: 'initialization',
133
+ timestamp: now(),
134
+ status: next.status,
135
+ retryable: next.error?.retryable
136
+ });
137
+ statusListeners.notify(next.status);
138
+ },
139
+ setPlacement(key, next) {
140
+ const runtime = placements.get(key);
141
+ if (!runtime) {
142
+ return;
143
+ }
144
+ const changed = runtime.snapshot.state !== next.state;
145
+ runtime.snapshot = next;
146
+ if (changed) {
147
+ runtime.listeners.notify(next.state);
148
+ }
149
+ },
150
+ dispatchPlacement(key, event) {
151
+ const found = context.placement(key);
152
+ if (found) {
153
+ context.setPlacement(key, placementReducer(found.runtime.snapshot, event, found.definition.format));
154
+ }
155
+ },
156
+ setConsent(next) {
157
+ state.consent = next;
158
+ consentListeners.notify(next);
159
+ },
160
+ releasePlacementResources(key) {
161
+ const runtime = placements.get(key);
162
+ if (!runtime) {
163
+ return;
164
+ }
165
+ runtime.cancelLoadTimer?.();
166
+ runtime.cancelLoadTimer = null;
167
+ runtime.cancelShowTimer?.();
168
+ runtime.cancelShowTimer = null;
169
+ runtime.unsubscribeEngine?.();
170
+ runtime.unsubscribeEngine = null;
171
+ if (runtime.handle) {
172
+ engine.dispose(runtime.handle);
173
+ runtime.handle = null;
174
+ }
175
+ runtime.inFlightLoad = null;
176
+ runtime.abortLoad = null;
177
+ runtime.rewarded = null;
178
+ runtime.cancelRetry?.();
179
+ runtime.cancelRetry = null;
180
+ },
181
+ emitRefusal(operation, result, placementKey, format) {
182
+ if (result.status === 'disabled' || result.status === 'undecided') {
183
+ // `undecided` reuses the `disabled` event: for an observer of the
184
+ // stream the fact is the same — no request was made — and the
185
+ // distinction is carried by the typed result and the init status.
186
+ events.emit({
187
+ type: 'disabled',
188
+ timestamp: now(),
189
+ operation,
190
+ placementKey,
191
+ format
192
+ });
193
+ return;
194
+ }
195
+ events.emit({
196
+ type: 'unavailable',
197
+ timestamp: now(),
198
+ operation,
199
+ placementKey,
200
+ format,
201
+ reason: result.reason
202
+ });
203
+ }
204
+ };
205
+ return context;
206
+ }
207
+
208
+ /** App-open expires on its own, shorter window (FR-130). */
209
+ export function validityFor(context, format) {
210
+ return format === 'app_open' ? context.resolved.timeouts.appOpenValidity : context.resolved.timeouts.adValidity;
211
+ }
212
+ //# sourceMappingURL=context.js.map