@mpgd/adapter-ait 0.5.0 → 0.5.1
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/dist/host.js +16 -7
- package/package.json +1 -1
package/dist/host.js
CHANGED
|
@@ -62,8 +62,7 @@ export function createAitHostBridge(options = {}) {
|
|
|
62
62
|
async function handleRequest(request) {
|
|
63
63
|
switch (request.method) {
|
|
64
64
|
case 'runtime.getCapabilities': {
|
|
65
|
-
const adsSupported = dependencies
|
|
66
|
-
&& dependencies.showFullScreenAd.isSupported();
|
|
65
|
+
const adsSupported = areFullScreenAdsSupported(dependencies);
|
|
67
66
|
const rewardedAds = adsSupported
|
|
68
67
|
&& hasConfiguredAdType(adGroupIds, adPlacementTypes, 'rewarded');
|
|
69
68
|
const interstitialAds = adsSupported
|
|
@@ -131,7 +130,7 @@ export function createAitHostBridge(options = {}) {
|
|
|
131
130
|
if (adGroupId === undefined || placementType === undefined) {
|
|
132
131
|
return createBridgeError(request.id, 'AIT_AD_UNAVAILABLE', `AIT ad placement is unavailable: ${placementId}`);
|
|
133
132
|
}
|
|
134
|
-
if (!dependencies.loadFullScreenAd.isSupported()) {
|
|
133
|
+
if (!isCapabilitySupported(() => dependencies.loadFullScreenAd.isSupported())) {
|
|
135
134
|
if (!warnedUnsupportedAdPreload) {
|
|
136
135
|
warnedUnsupportedAdPreload = true;
|
|
137
136
|
console.warn('AIT full-screen ads are not supported; configured preload is a no-op.', placementId);
|
|
@@ -146,8 +145,7 @@ export function createAitHostBridge(options = {}) {
|
|
|
146
145
|
const adGroupId = adGroupIds.get(placementId);
|
|
147
146
|
if (adGroupId === undefined
|
|
148
147
|
|| adPlacementTypes.get(placementId) !== 'rewarded'
|
|
149
|
-
|| !dependencies
|
|
150
|
-
|| !dependencies.showFullScreenAd.isSupported()) {
|
|
148
|
+
|| !areFullScreenAdsSupported(dependencies)) {
|
|
151
149
|
return ok(request, { status: 'unavailable', rewardGranted: false });
|
|
152
150
|
}
|
|
153
151
|
const shown = await withLoadedAdSlot(dependencies, adGroupId, loadedAdGroupIds, loadingAdGroups, adLoadCoordinator, activeAdGroupIds, adTimeoutMs, 'rewarded', async () => {
|
|
@@ -180,8 +178,7 @@ export function createAitHostBridge(options = {}) {
|
|
|
180
178
|
const adGroupId = adGroupIds.get(placementId);
|
|
181
179
|
if (adGroupId === undefined
|
|
182
180
|
|| adPlacementTypes.get(placementId) !== 'interstitial'
|
|
183
|
-
|| !dependencies
|
|
184
|
-
|| !dependencies.showFullScreenAd.isSupported()) {
|
|
181
|
+
|| !areFullScreenAdsSupported(dependencies)) {
|
|
185
182
|
return ok(request, { status: 'unavailable' });
|
|
186
183
|
}
|
|
187
184
|
const showInterstitial = () => showInterstitialAd(dependencies, adGroupId, adTimeoutMs, adDisplayStartTimeoutMs, adMaximumDisplayMs);
|
|
@@ -606,6 +603,18 @@ function toAitDeepLink(input, appName) {
|
|
|
606
603
|
function isGameCenterSupported(dependencies) {
|
|
607
604
|
return dependencies.isMinVersionSupported({ android: '5.221.0', ios: '5.221.0' });
|
|
608
605
|
}
|
|
606
|
+
function areFullScreenAdsSupported(dependencies) {
|
|
607
|
+
return isCapabilitySupported(() => dependencies.loadFullScreenAd.isSupported())
|
|
608
|
+
&& isCapabilitySupported(() => dependencies.showFullScreenAd.isSupported());
|
|
609
|
+
}
|
|
610
|
+
function isCapabilitySupported(check) {
|
|
611
|
+
try {
|
|
612
|
+
return check() === true;
|
|
613
|
+
}
|
|
614
|
+
catch (error) {
|
|
615
|
+
return false;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
609
618
|
function normalizeAdGroupIds(input) {
|
|
610
619
|
return new Map(Object.entries(input ?? {})
|
|
611
620
|
.map(([placementId, adGroupId]) => [placementId.trim(), adGroupId.trim()])
|