@mpgd/adapter-ait 0.5.0 → 0.5.2

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 (2) hide show
  1. package/dist/host.js +20 -8
  2. package/package.json +3 -3
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.loadFullScreenAd.isSupported()
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.loadFullScreenAd.isSupported()
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.loadFullScreenAd.isSupported()
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);
@@ -604,7 +601,22 @@ function toAitDeepLink(input, appName) {
604
601
  }
605
602
  }
606
603
  function isGameCenterSupported(dependencies) {
607
- return dependencies.isMinVersionSupported({ android: '5.221.0', ios: '5.221.0' });
604
+ return isCapabilitySupported(() => dependencies.isMinVersionSupported({
605
+ android: '5.221.0',
606
+ ios: '5.221.0',
607
+ }));
608
+ }
609
+ function areFullScreenAdsSupported(dependencies) {
610
+ return isCapabilitySupported(() => dependencies.loadFullScreenAd.isSupported())
611
+ && isCapabilitySupported(() => dependencies.showFullScreenAd.isSupported());
612
+ }
613
+ function isCapabilitySupported(check) {
614
+ try {
615
+ return check() === true;
616
+ }
617
+ catch (error) {
618
+ return false;
619
+ }
608
620
  }
609
621
  function normalizeAdGroupIds(input) {
610
622
  return new Map(Object.entries(input ?? {})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpgd/adapter-ait",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Apps in Toss WebView platform adapter for mpgd games.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -47,8 +47,8 @@
47
47
  "dist"
48
48
  ],
49
49
  "dependencies": {
50
- "@mpgd/bridge": "0.6.1",
51
- "@mpgd/platform": "0.7.0"
50
+ "@mpgd/platform": "0.7.0",
51
+ "@mpgd/bridge": "0.6.1"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@apps-in-toss/web-framework": ">=2.10.4 <3"