@cardsjd/portal 0.1.17 → 0.1.19
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/lib/GameDistributionPortal.js +31 -2
- package/lib/NextGenAdMobPortal.js +12 -12
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BasePortal } from './BasePortal';
|
|
1
|
+
import { BasePortal } from './BasePortal.js';
|
|
2
2
|
|
|
3
3
|
const AdType = {
|
|
4
4
|
Rewarded: 'rewarded',
|
|
@@ -26,7 +26,36 @@ export class GameDistribution extends BasePortal {
|
|
|
26
26
|
this.isInterstitialAdReady = false;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
async init() {
|
|
30
|
+
if (typeof globalThis.gdsdk !== 'undefined' || !this.appConfig?.gameDistributionId) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!this.initPromise) {
|
|
35
|
+
globalThis.GD_OPTIONS = {
|
|
36
|
+
...globalThis.GD_OPTIONS,
|
|
37
|
+
gameId: this.appConfig.gameDistributionId,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
this.initPromise = this.loadScript().catch(error => {
|
|
41
|
+
console.warn('Failed to load GameDistribution SDK:', error);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
await this.initPromise;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async loadScript() {
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
const script = document.createElement('script');
|
|
51
|
+
script.src = 'https://html5.api.gamedistribution.com/main.min.js';
|
|
52
|
+
script.onload = () => resolve();
|
|
53
|
+
script.onerror = () => reject(new Error('Failed to load GameDistribution SDK script'));
|
|
54
|
+
document.head.appendChild(script);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
isReady() {
|
|
30
59
|
if (typeof globalThis.gdsdk === 'undefined') {
|
|
31
60
|
console.log('GameDistribution sdk not ready');
|
|
32
61
|
return false;
|
|
@@ -17,7 +17,7 @@ export class NextGenAdMobPortal extends BasePortal {
|
|
|
17
17
|
this.onBeforeTrackingAuthorization = null;
|
|
18
18
|
this.onPrivacyOptionsRequirementChanged = null;
|
|
19
19
|
|
|
20
|
-
this.adProviderName = '
|
|
20
|
+
this.adProviderName = 'Admob';
|
|
21
21
|
this.isSetup = false;
|
|
22
22
|
this.isSetupLoading = false;
|
|
23
23
|
this._setupPromise = null;
|
|
@@ -25,9 +25,9 @@ export class NextGenAdMobPortal extends BasePortal {
|
|
|
25
25
|
this._isRewardedAdLoaded = false;
|
|
26
26
|
this._receivedReward = false;
|
|
27
27
|
this._rewardInfo = null;
|
|
28
|
-
this._interstitialAd = null;
|
|
29
|
-
// Native show resolves on opening; keep this until dismissal or show failure.
|
|
30
|
-
this._showingAd = null;
|
|
28
|
+
this._interstitialAd = null;
|
|
29
|
+
// Native show resolves on opening; keep this until dismissal or show failure.
|
|
30
|
+
this._showingAd = null;
|
|
31
31
|
this._interstitialLoadPromise = null;
|
|
32
32
|
this._rewardedAd = null;
|
|
33
33
|
this._adMobModule = null;
|
|
@@ -270,7 +270,7 @@ export class NextGenAdMobPortal extends BasePortal {
|
|
|
270
270
|
if ((info.id ?? info.adId) === this._interstitialAd?.id) {
|
|
271
271
|
if (this._showingAd === this._interstitialAd) {
|
|
272
272
|
this._showingAd = null;
|
|
273
|
-
}
|
|
273
|
+
}
|
|
274
274
|
|
|
275
275
|
this.isInterstitialAdReady = false;
|
|
276
276
|
this._interstitialAd = null;
|
|
@@ -295,7 +295,7 @@ export class NextGenAdMobPortal extends BasePortal {
|
|
|
295
295
|
if ((info.id ?? info.adId) === this._interstitialAd?.id) {
|
|
296
296
|
if (this._showingAd === this._interstitialAd) {
|
|
297
297
|
this._showingAd = null;
|
|
298
|
-
}
|
|
298
|
+
}
|
|
299
299
|
|
|
300
300
|
this.isInterstitialAdReady = false;
|
|
301
301
|
this._interstitialAd = null;
|
|
@@ -308,7 +308,7 @@ export class NextGenAdMobPortal extends BasePortal {
|
|
|
308
308
|
if ((info.id ?? info.adId) === this._rewardedAd?.id) {
|
|
309
309
|
if (this._showingAd === this._rewardedAd) {
|
|
310
310
|
this._showingAd = null;
|
|
311
|
-
}
|
|
311
|
+
}
|
|
312
312
|
|
|
313
313
|
this._isRewardedAdLoaded = false;
|
|
314
314
|
this._rewardedAd = null;
|
|
@@ -337,7 +337,7 @@ export class NextGenAdMobPortal extends BasePortal {
|
|
|
337
337
|
if ((info.id ?? info.adId) === this._rewardedAd?.id) {
|
|
338
338
|
if (this._showingAd === this._rewardedAd) {
|
|
339
339
|
this._showingAd = null;
|
|
340
|
-
}
|
|
340
|
+
}
|
|
341
341
|
|
|
342
342
|
this._isRewardedAdLoaded = false;
|
|
343
343
|
this._rewardedAd = null;
|
|
@@ -381,7 +381,7 @@ export class NextGenAdMobPortal extends BasePortal {
|
|
|
381
381
|
const { InterstitialAd } = await this.getAdMob();
|
|
382
382
|
if (this._showingAd) {
|
|
383
383
|
return;
|
|
384
|
-
}
|
|
384
|
+
}
|
|
385
385
|
|
|
386
386
|
this._interstitialAd = new InterstitialAd({
|
|
387
387
|
adUnitId: this.appConfig?.interstitialAdId,
|
|
@@ -438,7 +438,7 @@ export class NextGenAdMobPortal extends BasePortal {
|
|
|
438
438
|
} catch (error) {
|
|
439
439
|
if (this._showingAd === ad) {
|
|
440
440
|
this._showingAd = null;
|
|
441
|
-
}
|
|
441
|
+
}
|
|
442
442
|
|
|
443
443
|
console.error('Interstitial ad failed to show', error);
|
|
444
444
|
}
|
|
@@ -462,7 +462,7 @@ export class NextGenAdMobPortal extends BasePortal {
|
|
|
462
462
|
const { RewardedAd } = await this.getAdMob();
|
|
463
463
|
if (this._showingAd) {
|
|
464
464
|
return;
|
|
465
|
-
}
|
|
465
|
+
}
|
|
466
466
|
|
|
467
467
|
this._rewardedAd = new RewardedAd({
|
|
468
468
|
adUnitId: this.appConfig?.rewardedAdId,
|
|
@@ -505,7 +505,7 @@ export class NextGenAdMobPortal extends BasePortal {
|
|
|
505
505
|
} catch (error) {
|
|
506
506
|
if (this._showingAd === ad) {
|
|
507
507
|
this._showingAd = null;
|
|
508
|
-
}
|
|
508
|
+
}
|
|
509
509
|
|
|
510
510
|
throw error;
|
|
511
511
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cardsjd/portal",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.19",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"publishConfig": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@cardsjd/device": "^0.1.
|
|
20
|
+
"@cardsjd/device": "^0.1.17",
|
|
21
21
|
"@cardsjd/fbinstantgame": "^0.1.12",
|
|
22
22
|
"@discord/embedded-app-sdk": "^2.4.0"
|
|
23
23
|
},
|