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