@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,120 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.canRetry = canRetry;
7
+ exports.delayForAttempt = delayForAttempt;
8
+ exports.resolveEffectiveRetry = resolveEffectiveRetry;
9
+ exports.resolveRetryPolicy = resolveRetryPolicy;
10
+ var _rnCore = require("@chipmobilesdk/rn-core");
11
+ var _errors = require("../diagnostics/errors.js");
12
+ var _timers = require("./timers.js");
13
+ /**
14
+ * Bounded, opt-in retry for failed loads (FR-134 – FR-139).
15
+ *
16
+ * 0.1.0 shipped no retry on purpose, and the reason was sound: every retry is a
17
+ * billable request, and only the app knows what that costs. But the practical
18
+ * result was that every app rewrote the same backoff loop, and the cost of
19
+ * writing it wrong landed on a bill. This ships the loop once, keeps it **off by
20
+ * default**, and makes every attempt visible.
21
+ *
22
+ * Three properties do the work:
23
+ *
24
+ * - Off unless configured, so upgrading from 0.1.0 issues not one extra
25
+ * request (FR-134, and the compat test proves it rather than asserting it).
26
+ * - Only `retryable` errors. Configuration and consent errors, an unsupported
27
+ * platform, and a disabled or undecided instance are states another attempt
28
+ * cannot change, so retrying them would spend money on a certainty (FR-135).
29
+ * - Every attempt is an event carrying the load cycle's correlation id, so a
30
+ * bill can be reconciled against the event stream alone (FR-138).
31
+ *
32
+ * Pure — the schedule is computed here, the waiting happens in the instance's
33
+ * TimerSet so `dispose()` can prove it released everything.
34
+ */
35
+
36
+ /**
37
+ * Validates one policy against the bounds.
38
+ *
39
+ * Out-of-range values **throw** rather than being clamped, matching the rule
40
+ * `timers.ts` already follows: silently clamping a request for ten retries down
41
+ * to five tells the app it configured something it did not, and the discrepancy
42
+ * only surfaces later as a bill that does not match the code.
43
+ *
44
+ * `label` names the offending field precisely — an error that says only
45
+ * "invalid retry policy" makes an integrator hunt through a catalog by hand.
46
+ */
47
+ function resolveRetryPolicy(policy, label) {
48
+ const maxRetries = (0, _timers.checkBand)(`${label}.maxRetries`, policy.maxRetries ?? _timers.DEFAULT_RETRY_POLICY.maxRetries, _timers.RETRY_BOUNDS.maxRetries, 'retry_out_of_bounds', '');
49
+ const initialDelayMs = (0, _timers.checkBand)(`${label}.initialDelayMs`, policy.initialDelayMs ?? _timers.DEFAULT_RETRY_POLICY.initialDelayMs, _timers.RETRY_BOUNDS.initialDelayMs, 'retry_out_of_bounds');
50
+ const maxDelayMs = (0, _timers.checkBand)(`${label}.maxDelayMs`, policy.maxDelayMs ?? _timers.DEFAULT_RETRY_POLICY.maxDelayMs, _timers.RETRY_BOUNDS.maxDelayMs, 'retry_out_of_bounds');
51
+ if (!Number.isInteger(maxRetries)) {
52
+ throw new _errors.AdsConfigError('retry_out_of_bounds', {
53
+ message: `${label}.maxRetries must be a whole number; received ${maxRetries}`
54
+ });
55
+ }
56
+ if (initialDelayMs > maxDelayMs) {
57
+ throw new _errors.AdsConfigError('retry_out_of_bounds', {
58
+ message: `${label}.initialDelayMs (${initialDelayMs}ms) exceeds ${label}.maxDelayMs (${maxDelayMs}ms); the first retry would already be past the ceiling`
59
+ });
60
+ }
61
+ return {
62
+ maxRetries,
63
+ initialDelayMs,
64
+ maxDelayMs
65
+ };
66
+ }
67
+
68
+ /**
69
+ * Resolves the effective policy for one placement.
70
+ *
71
+ * An override **replaces** the instance-wide policy rather than merging into it.
72
+ * Merging would mean the effective policy for a placement could not be read off
73
+ * the configuration — you would have to simulate the merge to know what it was —
74
+ * and a per-field merge makes "this placement retries twice" quietly depend on a
75
+ * value written somewhere else.
76
+ *
77
+ * Both are validated against the same bounds, so an override narrows behavior
78
+ * but can never exceed a ceiling (FR-136a).
79
+ */
80
+ function resolveEffectiveRetry(instancePolicy, placementPolicy, placementKey) {
81
+ if (placementPolicy === false) {
82
+ // Explicit opt-out for this placement alone. A banner retry is cheap and
83
+ // invisible; a rewarded retry happens with a user waiting on the other
84
+ // side of it. An app may reasonably want one and not the other.
85
+ return null;
86
+ }
87
+ if (placementPolicy) {
88
+ return resolveRetryPolicy(placementPolicy, `placements.${placementKey}.retry`);
89
+ }
90
+ if (instancePolicy) {
91
+ return resolveRetryPolicy(instancePolicy, 'retry');
92
+ }
93
+ // Nothing configured anywhere: retry is entirely off, which is the default
94
+ // and the only behavior a 0.1.0 consumer can observe (FR-134).
95
+ return null;
96
+ }
97
+
98
+ /**
99
+ * Delay before the given attempt. `attempt` is 1-based — the first retry is 1.
100
+ *
101
+ * Exponential with a fixed x2 multiplier and **no jitter**. Jitter exists to
102
+ * desynchronize a fleet of clients hitting one server; a single device retrying
103
+ * its own load has no herd to avoid. Leaving it out keeps "two retries, 2s then
104
+ * 4s" an exact assertion instead of a statistical one, which matters more here
105
+ * than a property that does not apply.
106
+ */
107
+ function delayForAttempt(policy, attempt) {
108
+ return (0, _rnCore.computeBackoff)(attempt, {
109
+ initialDelayMs: policy.initialDelayMs,
110
+ maxDelayMs: policy.maxDelayMs,
111
+ factor: 2,
112
+ jitter: 'none'
113
+ });
114
+ }
115
+
116
+ /** Whether another attempt is permitted. `attemptsMade` counts retries only. */
117
+ function canRetry(policy, attemptsMade) {
118
+ return policy !== null && attemptsMade < policy.maxRetries;
119
+ }
120
+ //# sourceMappingURL=retryPolicy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_rnCore","require","_errors","_timers","resolveRetryPolicy","policy","label","maxRetries","checkBand","DEFAULT_RETRY_POLICY","RETRY_BOUNDS","initialDelayMs","maxDelayMs","Number","isInteger","AdsConfigError","message","resolveEffectiveRetry","instancePolicy","placementPolicy","placementKey","delayForAttempt","attempt","computeBackoff","factor","jitter","canRetry","attemptsMade"],"sourceRoot":"../../../src","sources":["core/retryPolicy.ts"],"mappings":";;;;;;;;;AAuBA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AA1BA;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;AACO,SAASG,kBAAkBA,CAACC,MAAmB,EAAEC,KAAa,EAAuB;EAC3F,MAAMC,UAAU,GAAG,IAAAC,iBAAS,EAC3B,GAAGF,KAAK,aAAa,EACrBD,MAAM,CAACE,UAAU,IAAIE,4BAAoB,CAACF,UAAU,EACpDG,oBAAY,CAACH,UAAU,EACvB,qBAAqB,EACrB,EACD,CAAC;EACD,MAAMI,cAAc,GAAG,IAAAH,iBAAS,EAC/B,GAAGF,KAAK,iBAAiB,EACzBD,MAAM,CAACM,cAAc,IAAIF,4BAAoB,CAACE,cAAc,EAC5DD,oBAAY,CAACC,cAAc,EAC3B,qBACD,CAAC;EACD,MAAMC,UAAU,GAAG,IAAAJ,iBAAS,EAC3B,GAAGF,KAAK,aAAa,EACrBD,MAAM,CA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,QAAQA,CAACrB,MAAkC,EAAEsB,YAAoB,EAAW;EAC3F,OAAOtB,MAAM,KAAK,IAAI,IAAIsB,YAAY,GAAGtB,MAAM,CAACE,UAAU;AAC3D","ignoreList":[]}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createRewardedSession = createRewardedSession;
7
+ /**
8
+ * Rewarded session bookkeeping (FR-046 – FR-049).
9
+ *
10
+ * Two independent booleans, never derived from one another:
11
+ *
12
+ * rewardConfirmed=false rewardConfirmed=true
13
+ * dismissed=false in progress reward emitted, awaiting dismissal
14
+ * dismissed=true dismissed_no_reward earned
15
+ *
16
+ * The defect this exists to prevent is inferring "earned" from dismissal. It is
17
+ * the most common way rewarded integrations go wrong, and it is a direct revenue
18
+ * and fairness fault: a user who closed the ad after two seconds gets the prize,
19
+ * and the publisher is billed for nothing.
20
+ *
21
+ * Tracking two flags and deriving the outcome makes both callback orderings
22
+ * produce the same result *by construction* rather than by the provider
23
+ * happening to fire in a convenient order (SC-007).
24
+ */
25
+
26
+ function createRewardedSession() {
27
+ let confirmed = false;
28
+ let dismissed = false;
29
+ let earnedReward = null;
30
+ return {
31
+ confirmReward(reward) {
32
+ if (confirmed) {
33
+ return null;
34
+ }
35
+ confirmed = true;
36
+ earnedReward = reward;
37
+ return reward;
38
+ },
39
+ dismiss() {
40
+ if (dismissed) {
41
+ return false;
42
+ }
43
+ dismissed = true;
44
+ return true;
45
+ },
46
+ outcome() {
47
+ if (!dismissed) {
48
+ return 'in_progress';
49
+ }
50
+ // Read at dismissal time, so a reward that arrived first is honored and
51
+ // one that never arrives is not invented.
52
+ return confirmed ? 'earned' : 'dismissed_without_reward';
53
+ },
54
+ get rewardEarned() {
55
+ return confirmed;
56
+ },
57
+ get dismissed() {
58
+ return dismissed;
59
+ },
60
+ reward() {
61
+ return earnedReward;
62
+ }
63
+ };
64
+ }
65
+ //# sourceMappingURL=rewardedSession.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createRewardedSession","confirmed","dismissed","earnedReward","confirmReward","reward","dismiss","outcome","rewardEarned"],"sourceRoot":"../../../src","sources":["core/rewardedSession.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAsBO,SAASA,qBAAqBA,CAAA,EAAoB;EACxD,IAAIC,SAAS,GAAG,KAAK;EACrB,IAAIC,SAAS,GAAG,KAAK;EACrB,IAAIC,YAA2B,GAAG,IAAI;EAEtC,OAAO;IACNC,aAAaA,CAACC,MAAM,EAAE;MACrB,IAAIJ,SAAS,EAAE;QACd,OAAO,IAAI;MACZ;MACAA,SAAS,GAAG,IAAI;MAChBE,YAAY,GAAGE,MAAM;MACrB,OAAOA,MAAM;IACd,CAAC;IAEDC,OAAOA,CAAA,EAAG;MACT,IAAIJ,SAAS,EAAE;QACd,OAAO,KAAK;MACb;MACAA,SAAS,GAAG,IAAI;MAChB,OAAO,IAAI;IACZ,CAAC;IAEDK,OAAOA,CAAA,EAAG;MACT,IAAI,CAACL,SAAS,EAAE;QACf,OAAO,aAAa;MACrB;MACA;MACA;MACA,OAAOD,SAAS,GAAG,QAAQ,GAAG,0BAA0B;IACzD,CAAC;IAED,IAAIO,YAAYA,CAAA,EAAG;MAClB,OAAOP,SAAS;IACjB,CAAC;IAED,IAAIC,SAASA,CAAA,EAAG;MACf,OAAOA,SAAS;IACjB,CAAC;IAEDG,MAAMA,CAAA,EAAG;MACR,OAAOF,YAAY;IACpB;EACD,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UNDECIDED_WARNING_BOUNDS = exports.SHOW_TIMEOUT_BOUNDS = exports.RETRY_BOUNDS = exports.LOAD_TIMEOUT_BOUNDS = exports.DEFAULT_UNDECIDED_WARNING_MS = exports.DEFAULT_SHOW_TIMEOUT_MS = exports.DEFAULT_RETRY_POLICY = exports.DEFAULT_LOAD_TIMEOUT_MS = exports.DEFAULT_APP_OPEN_VALIDITY_MS = exports.DEFAULT_AD_VALIDITY_MS = exports.APP_OPEN_VALIDITY_BOUNDS = exports.AD_VALIDITY_BOUNDS = exports.AD_RETURN_MAX_AWAY_MS = exports.AD_RETURN_GRACE_MS = exports.AD_CLICK_WINDOW_MS = void 0;
7
+ exports.checkBand = checkBand;
8
+ Object.defineProperty(exports, "createTimerSet", {
9
+ enumerable: true,
10
+ get: function () {
11
+ return _rnCore.createTimerSet;
12
+ }
13
+ });
14
+ exports.isStale = isStale;
15
+ exports.resolveTimeouts = resolveTimeouts;
16
+ var _rnCore = require("@chipmobilesdk/rn-core");
17
+ var _errors = require("../diagnostics/errors.js");
18
+ /**
19
+ * Timeout and staleness policy (FR-032, FR-034).
20
+ *
21
+ * Defaults and bounds live here rather than at each call site so there is one
22
+ * place to read what the package will wait for. Values outside a band are a
23
+ * configuration error rather than being silently clamped: silently clamping a
24
+ * one-second load timeout to five would mean the app is told it configured
25
+ * something it did not (FR-008).
26
+ */
27
+
28
+ /** Comfortably longer than a normal fill on a slow mobile network, still bounded. */
29
+ const DEFAULT_LOAD_TIMEOUT_MS = exports.DEFAULT_LOAD_TIMEOUT_MS = 30_000;
30
+ /** Generous for what is essentially a local presentation. */
31
+ const DEFAULT_SHOW_TIMEOUT_MS = exports.DEFAULT_SHOW_TIMEOUT_MS = 10_000;
32
+ /**
33
+ * Google documents that a loaded ad object expires about an hour after load.
34
+ * Sixty minutes is the provider's own number; choosing anything else would be
35
+ * inventing a constraint (R7).
36
+ */
37
+ const DEFAULT_AD_VALIDITY_MS = exports.DEFAULT_AD_VALIDITY_MS = 3_600_000;
38
+
39
+ /**
40
+ * App-open's own window, deliberately shorter than the hour the other
41
+ * full-screen formats get (FR-130).
42
+ *
43
+ * Worth being explicit about why: Google expires app-open ads after **four
44
+ * hours**, which is *longer* than DEFAULT_AD_VALIDITY_MS, so the provider does
45
+ * not constrain this at all. The shorter window is a product decision. An
46
+ * app-open ad shows at the most prominent moment the app has, and a creative
47
+ * cached for an hour is stale by then; thirty minutes still spares a returning
48
+ * user the spinner of a cold load, which is both the worst app-open experience
49
+ * and the specific behavior store policy penalizes.
50
+ */
51
+ const DEFAULT_APP_OPEN_VALIDITY_MS = exports.DEFAULT_APP_OPEN_VALIDITY_MS = 1_800_000;
52
+
53
+ /**
54
+ * How long `enabled: 'undecided'` may go unresolved before one warning fires.
55
+ *
56
+ * Ten seconds is several times a realistic worst case for the round trip this
57
+ * state exists to cover — asking a store whether the user owns an ad-removal
58
+ * entitlement — so an app doing the right thing essentially never trips it,
59
+ * while an app that forgot to resolve trips it inside a single QA session,
60
+ * which is where it needs to be caught (FR-119).
61
+ */
62
+ const DEFAULT_UNDECIDED_WARNING_MS = exports.DEFAULT_UNDECIDED_WARNING_MS = 10_000;
63
+ const LOAD_TIMEOUT_BOUNDS = exports.LOAD_TIMEOUT_BOUNDS = {
64
+ min: 5_000,
65
+ max: 120_000
66
+ };
67
+ const SHOW_TIMEOUT_BOUNDS = exports.SHOW_TIMEOUT_BOUNDS = {
68
+ min: 5_000,
69
+ max: 30_000
70
+ };
71
+ const AD_VALIDITY_BOUNDS = exports.AD_VALIDITY_BOUNDS = {
72
+ min: 60_000,
73
+ max: 3_600_000
74
+ };
75
+ /** Ceiling is one hour so app-open can never outlive the general window. */
76
+ const APP_OPEN_VALIDITY_BOUNDS = exports.APP_OPEN_VALIDITY_BOUNDS = {
77
+ min: 60_000,
78
+ max: 3_600_000
79
+ };
80
+ const UNDECIDED_WARNING_BOUNDS = exports.UNDECIDED_WARNING_BOUNDS = {
81
+ min: 1_000,
82
+ max: 120_000
83
+ };
84
+
85
+ /**
86
+ * Retry defaults (FR-136).
87
+ *
88
+ * Two retries rather than more: each one is a billable request, and two covers
89
+ * the transient network failure and the momentary no-fill — the cases where
90
+ * trying again plausibly helps. A third mostly pays for a failure that was not
91
+ * transient. 2s then 4s keeps both inside a window the user still associates
92
+ * with the action that triggered the load.
93
+ */
94
+ const DEFAULT_RETRY_POLICY = exports.DEFAULT_RETRY_POLICY = {
95
+ maxRetries: 2,
96
+ initialDelayMs: 2_000,
97
+ maxDelayMs: 30_000
98
+ };
99
+ const RETRY_BOUNDS = exports.RETRY_BOUNDS = {
100
+ maxRetries: {
101
+ min: 1,
102
+ max: 5
103
+ },
104
+ initialDelayMs: {
105
+ min: 500,
106
+ max: 30_000
107
+ },
108
+ maxDelayMs: {
109
+ min: 1_000,
110
+ max: 60_000
111
+ }
112
+ };
113
+
114
+ /**
115
+ * Ad-originated return detection (FR-128).
116
+ *
117
+ * A background transition within CLICK_WINDOW of a click is attributed to a
118
+ * browser the ad opened. An absence longer than MAX_AWAY is no longer
119
+ * attributable to the ad — the user did something else in between. GRACE covers
120
+ * the moment right after the return, where an app-open show would otherwise
121
+ * fire, without outliving it and refusing a genuinely later show.
122
+ */
123
+ const AD_CLICK_WINDOW_MS = exports.AD_CLICK_WINDOW_MS = 2_000;
124
+ const AD_RETURN_MAX_AWAY_MS = exports.AD_RETURN_MAX_AWAY_MS = 300_000;
125
+ const AD_RETURN_GRACE_MS = exports.AD_RETURN_GRACE_MS = 10_000;
126
+ /**
127
+ * `value` when it is inside `bounds`, else an `AdsConfigError` with `code`: each
128
+ * field reports the code its documentation names, so a retry policy out of bounds
129
+ * is `retry_out_of_bounds`, not a timeout's code (CORE-04, ADS-16).
130
+ */
131
+ function checkBand(label, value, bounds, code = 'timeout_out_of_bounds', unit = 'ms') {
132
+ return (0, _rnCore.checkRange)(label, value, bounds, message => new _errors.AdsConfigError(code, {
133
+ message
134
+ }), unit);
135
+ }
136
+ function resolveTimeouts(input) {
137
+ const {
138
+ timeouts,
139
+ adValidityMs,
140
+ appOpenValidityMs,
141
+ undecidedWarningMs
142
+ } = input;
143
+ return {
144
+ load: checkBand('timeouts.load', timeouts?.load ?? DEFAULT_LOAD_TIMEOUT_MS, LOAD_TIMEOUT_BOUNDS),
145
+ show: checkBand('timeouts.show', timeouts?.show ?? DEFAULT_SHOW_TIMEOUT_MS, SHOW_TIMEOUT_BOUNDS),
146
+ adValidity: checkBand('adValidityMs', adValidityMs ?? DEFAULT_AD_VALIDITY_MS, AD_VALIDITY_BOUNDS),
147
+ appOpenValidity: checkBand('appOpenValidityMs', appOpenValidityMs ?? DEFAULT_APP_OPEN_VALIDITY_MS, APP_OPEN_VALIDITY_BOUNDS),
148
+ undecidedWarning: checkBand('undecidedWarningMs', undecidedWarningMs ?? DEFAULT_UNDECIDED_WARNING_MS, UNDECIDED_WARNING_BOUNDS)
149
+ };
150
+ }
151
+
152
+ /**
153
+ * How timers are scheduled, and the set that tracks them so `dispose()` can prove
154
+ * it released every one (SC-008): rn-core's, injectable so a test drives retry
155
+ * backoff, app-open expiry and the undecided warning by moving a clock.
156
+ */
157
+
158
+ /** A loaded ad past its validity window must never be reported ready (FR-034). */
159
+ function isStale(loadedAtMs, nowMs, adValidityMs) {
160
+ return nowMs - loadedAtMs >= adValidityMs;
161
+ }
162
+ //# sourceMappingURL=timers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_rnCore","require","_errors","DEFAULT_LOAD_TIMEOUT_MS","exports","DEFAULT_SHOW_TIMEOUT_MS","DEFAULT_AD_VALIDITY_MS","DEFAULT_APP_OPEN_VALIDITY_MS","DEFAULT_UNDECIDED_WARNING_MS","LOAD_TIMEOUT_BOUNDS","min","max","SHOW_TIMEOUT_BOUNDS","AD_VALIDITY_BOUNDS","APP_OPEN_VALIDITY_BOUNDS","UNDECIDED_WARNING_BOUNDS","DEFAULT_RETRY_POLICY","maxRetries","initialDelayMs","maxDelayMs","RETRY_BOUNDS","AD_CLICK_WINDOW_MS","AD_RETURN_MAX_AWAY_MS","AD_RETURN_GRACE_MS","checkBand","label","value","bounds","code","unit","checkRange","message","AdsConfigError","resolveTimeouts","input","timeouts","adValidityMs","appOpenValidityMs","undecidedWarningMs","load","show","adValidity","appOpenValidity","undecidedWarning","isStale","loadedAtMs","nowMs"],"sourceRoot":"../../../src","sources":["core/timers.ts"],"mappings":";;;;;;;;;;;;;;;AAUA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACO,MAAME,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,MAAM;AAC7C;AACO,MAAME,uBAAuB,GAAAD,OAAA,CAAAC,uBAAA,GAAG,MAAM;AAC7C;AACA;AACA;AACA;AACA;AACO,MAAMC,sBAAsB,GAAAF,OAAA,CAAAE,sBAAA,GAAG,SAAS;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,4BAA4B,GAAAH,OAAA,CAAAG,4BAAA,GAAG,SAAS;;AAErD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,4BAA4B,GAAAJ,OAAA,CAAAI,4BAAA,GAAG,MAAM;AAE3C,MAAMC,mBAAmB,GAAAL,OAAA,CAAAK,mBAAA,GAAG;EAAEC,GAAG,EAAE,KAAK;EAAEC,GAAG,EAAE;AAAQ,CAAU;AACjE,MAAMC,mBAAmB,GAAAR,OAAA,CAAAQ,mBAAA,GAAG;EAAEF,GAAG,EAAE,KAAK;EAAEC,GAAG,EAAE;AAAO,CAAU;AAChE,MAAME,kBAAkB,GAAAT,OAAA,CAAAS,kBAAA,GAAG;EAAEH,GAAG,EAAE,MAAM;EAAEC,GAAG,EAAE;AAAU,CAAU;AAC1E;AACO,MAAMG,wBAAwB,GAAAV,OAAA,CAAAU,wBAAA,GAAG;EAAEJ,GAAG,EAAE,MAAM;EAAEC,GAAG,EAAE;AAAU,CAAU;AACzE,MAAMI,wBAAwB,GAAAX,OAAA,CAAAW,wBAAA,GAAG;EAAEL,GAAG,EAAE,KAAK;EAAEC,GAAG,EAAE;AAAQ,CAAU;;AAE7E;A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,mBACD,CAAC;IACD+B,IAAI,EAAEhB,SAAS,CACd,eAAe,EACfW,QAAQ,EAAEK,IAAI,IAAInC,uBAAuB,EACzCO,mBACD,CAAC;IACD6B,UAAU,EAAEjB,SAAS,CACpB,cAAc,EACdY,YAAY,IAAI9B,sBAAsB,EACtCO,kBACD,CAAC;IACD6B,eAAe,EAAElB,SAAS,CACzB,mBAAmB,EACnBa,iBAAiB,IAAI9B,4BAA4B,EACjDO,wBACD,CAAC;IACD6B,gBAAgB,EAAEnB,SAAS,CAC1B,oBAAoB,EACpBc,kBAAkB,IAAI9B,4BAA4B,EAClDO,wBACD;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;;AAGA;AACO,SAAS6B,OAAOA,CAACC,UAAkB,EAAEC,KAAa,EAAEV,YAAoB,EAAW;EACzF,OAAOU,KAAK,GAAGD,UAAU,IAAIT,YAAY;AAC1C","ignoreList":[]}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createCorrelationIssuer = createCorrelationIssuer;
7
+ /**
8
+ * Correlation identifiers (FR-052).
9
+ *
10
+ * One value is minted when a load begins and carried by every event of that
11
+ * load/show cycle through its terminal event. It is what lets a consumer
12
+ * reconstruct a single ad's life from an event stream alone (SC-009) without the
13
+ * package having to store any history of its own.
14
+ *
15
+ * Opaque and monotonic per instance. Not a UUID, and deliberately not derived
16
+ * from anything about the device or the user — it exists to group events, and
17
+ * anything with more meaning than that would be a payload the package has
18
+ * promised not to carry (FR-021).
19
+ */
20
+
21
+ function createCorrelationIssuer(prefix = 'ad') {
22
+ let counter = 0;
23
+ // Distinguishes cycles from two instances in one process, which otherwise
24
+ // both start at 1 and would collide in a merged log.
25
+ const instance = Math.random().toString(36).slice(2, 8);
26
+ return {
27
+ next() {
28
+ counter += 1;
29
+ return `${prefix}-${instance}-${counter}`;
30
+ }
31
+ };
32
+ }
33
+ //# sourceMappingURL=correlation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createCorrelationIssuer","prefix","counter","instance","Math","random","toString","slice","next"],"sourceRoot":"../../../src","sources":["diagnostics/correlation.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMO,SAASA,uBAAuBA,CAACC,MAAM,GAAG,IAAI,EAAqB;EACzE,IAAIC,OAAO,GAAG,CAAC;EACf;EACA;EACA,MAAMC,QAAQ,GAAGC,IAAI,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;EAEvD,OAAO;IACNC,IAAIA,CAAA,EAAG;MACNN,OAAO,IAAI,CAAC;MACZ,OAAO,GAAGD,MAAM,IAAIE,QAAQ,IAAID,OAAO,EAAE;IAC1C;EACD,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AdsError = exports.AdsConfigError = void 0;
7
+ exports.isAdsError = isAdsError;
8
+ exports.normalizeProviderError = normalizeProviderError;
9
+ exports.redact = redact;
10
+ var _rnCore = require("@chipmobilesdk/rn-core");
11
+ /**
12
+ * Normalized error model (FR-053) and redaction (NFR-006).
13
+ *
14
+ * Codes are stable public API: renaming one is a breaking change under LIB-008.
15
+ * They exist so a consuming app branches on `code` and `retryable` rather than
16
+ * string-matching a provider message that may change under it.
17
+ *
18
+ * `cause` is a redacted string, never the provider's error object. A provider
19
+ * object reaching a consumer would be a contract leak (FR-002) and a potential
20
+ * carrier for identifiers the package promises never to emit (FR-021).
21
+ */
22
+
23
+ /**
24
+ * "Retrying this operation could plausibly succeed" — not "retry immediately".
25
+ *
26
+ * 0.2.0 added an opt-in retry policy, and this set is what it is allowed to act
27
+ * on. Everything outside it is excluded deliberately: configuration and consent
28
+ * errors, an unsupported platform, and a disabled or undecided instance are all
29
+ * states another attempt cannot change, so retrying them would spend a billable
30
+ * request on a certainty (FR-135).
31
+ */
32
+ const RETRYABLE = new Set(['no_fill', 'network_error', 'load_timeout', 'show_timeout', 'ad_expired', 'not_ready', 'busy', 'consumed', 'app_inactive', 'provider_error']);
33
+ /** The package's error; an `SdkError` (`@chipmobilesdk/rn-core`) with `pkg: 'rn-ads'`. */
34
+ class AdsError extends _rnCore.SdkError {
35
+ /** Redacted provider detail. Never a provider object. */
36
+
37
+ constructor(code, options = {}) {
38
+ const cause = options.cause === undefined ? undefined : redact(options.cause);
39
+ super('rn-ads', code, {
40
+ message: options.message,
41
+ retryable: RETRYABLE.has(code),
42
+ redactedCause: cause
43
+ });
44
+ this.name = 'AdsError';
45
+ this.operation = options.operation;
46
+ this.placementKey = options.placementKey;
47
+ this.format = options.format;
48
+ this.cause = cause;
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Configuration faults are thrown rather than returned, because they mean the
54
+ * app is wired wrong and no runtime result could describe a usable outcome.
55
+ * Every other failure in the package is a typed result (FR-004).
56
+ */
57
+ exports.AdsError = AdsError;
58
+ class AdsConfigError extends AdsError {
59
+ constructor(code, options = {}) {
60
+ super(code, {
61
+ ...options,
62
+ operation: options.operation ?? 'configure'
63
+ });
64
+ this.name = 'AdsConfigError';
65
+ }
66
+ }
67
+ exports.AdsConfigError = AdsConfigError;
68
+ function isAdsError(value) {
69
+ return value instanceof AdsError;
70
+ }
71
+
72
+ /** An AdMob unit or app id. Redacted so a log never carries a live identifier. */
73
+ const AD_UNIT_PATTERN = /ca-app-pub-\d+[~/]\d+/g;
74
+
75
+ /**
76
+ * Keys dropped wholesale rather than pattern-matched, because their values are
77
+ * sensitive regardless of shape — a bare advertising id has no separator for a
78
+ * pattern to catch.
79
+ */
80
+ const SENSITIVE_KEYS = ['adid', 'adUnitId', 'advertisingId', 'consent', 'consentString', 'gaid', 'idfa', 'tcString', 'token', 'userId'];
81
+
82
+ /**
83
+ * rn-core's pattern redaction (URLs, JWTs, e-mail addresses, UUIDs, payload-sized
84
+ * runs) plus ad unit ids, with the keys above dropped. Provider messages are kept
85
+ * readable: they describe the failure, and every identifier in them is shaped.
86
+ */
87
+ const redactor = (0, _rnCore.createRedactor)({
88
+ text: 'patterns',
89
+ patterns: [AD_UNIT_PATTERN],
90
+ dropKeys: SENSITIVE_KEYS,
91
+ maxDepth: 2
92
+ });
93
+
94
+ /**
95
+ * Reduces an arbitrary provider value to a safe string (FR-053, NFR-006).
96
+ *
97
+ * Returns a string rather than a structure on purpose: a redacted object still
98
+ * hands the consumer a reference into provider-owned memory, and the contract
99
+ * promises no provider object crosses the boundary. An `AdsError` reduces to its
100
+ * code.
101
+ */
102
+ function redact(value) {
103
+ return redactor.text(value);
104
+ }
105
+
106
+ /**
107
+ * Maps a provider failure onto the normalized taxonomy.
108
+ *
109
+ * The adapter's classification wins when it gave one (ADS-08). Otherwise the
110
+ * match is on substrings that have been stable across provider releases, and
111
+ * anything unrecognized becomes a retryable `provider_error` rather than being
112
+ * reshaped into a code that means something specific.
113
+ */
114
+ function normalizeProviderError(value, options = {}, kind) {
115
+ switch (kind) {
116
+ case 'no_fill':
117
+ return new AdsError('no_fill', {
118
+ ...options,
119
+ cause: value
120
+ });
121
+ case 'network':
122
+ return new AdsError('network_error', {
123
+ ...options,
124
+ cause: value
125
+ });
126
+ case 'rejected':
127
+ return new AdsError('provider_rejected', {
128
+ ...options,
129
+ cause: value
130
+ });
131
+ default:
132
+ }
133
+ const text = value instanceof Error ? value.message : String(value ?? '');
134
+ const lowered = text.toLowerCase();
135
+ if (lowered.includes('no-fill') || lowered.includes('no fill')) {
136
+ return new AdsError('no_fill', {
137
+ ...options,
138
+ cause: value
139
+ });
140
+ }
141
+ if (lowered.includes('network')) {
142
+ return new AdsError('network_error', {
143
+ ...options,
144
+ cause: value
145
+ });
146
+ }
147
+ return new AdsError('provider_error', {
148
+ ...options,
149
+ cause: value
150
+ });
151
+ }
152
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_rnCore","require","RETRYABLE","Set","AdsError","SdkError","constructor","code","options","cause","undefined","redact","message","retryable","has","redactedCause","name","operation","placementKey","format","exports","AdsConfigError","isAdsError","value","AD_UNIT_PATTERN","SENSITIVE_KEYS","redactor","createRedactor","text","patterns","dropKeys","maxDepth","normalizeProviderError","kind","Error","String","lowered","toLowerCase","includes"],"sourceRoot":"../../../src","sources":["diagnostics/errors.ts"],"mappings":";;;;;;;;;AAYA,IAAAA,OAAA,GAAAC,OAAA;AAZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA8DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,SAAoC,GAAG,IAAIC,GAAG,CAAe,CAClE,SAAS,EACT,eAAe,EACf,cAAc,EACd,cAAc,EACd,YAAY,EACZ,WAAW,EACX,MAAM,EACN,UAAU,EACV,cAAc,EACd,gBAAgB,CAChB,CAAC;AAUF;AACO,MAAMC,QAAQ,SAASC,gBAAQ,CAAe;EAIpD;;EAGAC,WAAWA,CAACC,IAAkB,EAAEC,OAAwB,GAAG,CAAC,CAAC,EAAE;IAC9D,MAAMC,KAAK,GAAGD,OAAO,CAACC,KAAK,KAAKC,SAAS,GAAGA,SAAS,GAAGC,MAAM,CAACH,OAAO,CAACC,KAAK,CAAC;IAC7E,KAAK,CAAC,QAAQ,EAAEF,IAAI,EAAE;MACrBK,OAAO,EAAEJ,OAAO,CAACI,OAAO;MACxBC,SAAS,EAAEX,SAAS,CAACY,GAAG,CAACP,IAAI,CAAC;MAC9BQ,aAAa,EAAEN;IAChB,CAAC,CAAC;IACF,IAAI,CAACO,IAAI,GAAG,UAAU;IACtB,IAAI,CAACC,SAAS,GAAGT,OAAO,CAACS,SAAS;IAClC,IAAI,CAACC,YAAY,GAAGV,OAAO,CAACU,YAAY;IACxC,IAAI,CAACC,MAAM,GAAGX,OAAO,CAACW,MAAM;IAC5B,IAAI,CAACV,KAAK,GAAGA,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