@cardsjd/portal 0.1.8 → 0.1.9
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/AdMobPortal.js +1 -3
- package/lib/BasePortal.js +2 -4
- package/lib/CrazyGamesPortal.js +1 -3
- package/lib/FacebookPortal.js +3 -1
- package/lib/GameDistributionPortal.js +3 -1
- package/lib/PokiPortal.js +2 -0
- package/lib/WebPortal.js +45 -36
- package/package.json +21 -20
package/lib/AdMobPortal.js
CHANGED
package/lib/BasePortal.js
CHANGED
|
@@ -51,8 +51,7 @@ export class BasePortal {
|
|
|
51
51
|
createShortCut() { }
|
|
52
52
|
|
|
53
53
|
async tryShowInterstitialAd(options) {
|
|
54
|
-
|
|
55
|
-
if (this.isSetup === false) { return; }
|
|
54
|
+
await this.setupAds();
|
|
56
55
|
|
|
57
56
|
const config = this.config || {};
|
|
58
57
|
const offsetStartdelay = options?.offsetStartdelay || config.offsetStartdelay || 120; //start with 1 min passed to get the first ad to show faster
|
|
@@ -98,8 +97,7 @@ export class BasePortal {
|
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
99
|
async showAppOpenAdWithMaxDelay(maxDelay) {
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
await this.setupAds();
|
|
103
101
|
|
|
104
102
|
if (!maxDelay) {
|
|
105
103
|
maxDelay = 4000;
|
package/lib/CrazyGamesPortal.js
CHANGED
package/lib/FacebookPortal.js
CHANGED
|
@@ -407,9 +407,11 @@ export class FacebookPortal extends BasePortal {
|
|
|
407
407
|
|
|
408
408
|
}
|
|
409
409
|
|
|
410
|
-
showRewardedAd() {
|
|
410
|
+
async showRewardedAd() {
|
|
411
411
|
console.log('FB_Ads.ShowRewardedAd');
|
|
412
412
|
|
|
413
|
+
await this.setupAds();
|
|
414
|
+
|
|
413
415
|
if (this.isErrorState()) {
|
|
414
416
|
console.log('FBInstant.ShowRewardedAd() - isErrorState = true');
|
|
415
417
|
return true;
|
|
@@ -97,11 +97,13 @@ export class GameDistribution extends BasePortal {
|
|
|
97
97
|
})();
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
showRewardedAd() {
|
|
100
|
+
async showRewardedAd() {
|
|
101
101
|
if (!this.isReady()) {
|
|
102
102
|
return false;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
await this.setupAds();
|
|
106
|
+
|
|
105
107
|
return globalThis.gdsdk.showAd(AdType.Rewarded);
|
|
106
108
|
}
|
|
107
109
|
}
|
package/lib/PokiPortal.js
CHANGED
package/lib/WebPortal.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BasePortal } from './BasePortal';
|
|
1
|
+
import { BasePortal } from './BasePortal.js';
|
|
2
2
|
|
|
3
3
|
export class WebPortal extends BasePortal {
|
|
4
4
|
name = 'WebPortal';
|
|
@@ -16,9 +16,10 @@ export class WebPortal extends BasePortal {
|
|
|
16
16
|
this.onAdRewarded = null;
|
|
17
17
|
|
|
18
18
|
this.page_url = 'cardsjd.com';
|
|
19
|
-
this.adProviderName = 'GoogleH5';
|
|
20
|
-
this.isSetup = false;
|
|
21
|
-
this.isSetupLoading = false;
|
|
19
|
+
this.adProviderName = 'GoogleH5';
|
|
20
|
+
this.isSetup = false;
|
|
21
|
+
this.isSetupLoading = false;
|
|
22
|
+
this.setupPromise = null;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
async init() {
|
|
@@ -47,28 +48,34 @@ export class WebPortal extends BasePortal {
|
|
|
47
48
|
|
|
48
49
|
// ----- Ad methods -----
|
|
49
50
|
|
|
50
|
-
async setupAds() {
|
|
51
|
-
if (this.isSetup) {
|
|
52
|
-
console.log('GoogleH5.isSetup is already done');
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
51
|
+
async setupAds() {
|
|
52
|
+
if (this.isSetup) {
|
|
53
|
+
console.log('GoogleH5.isSetup is already done');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (this.setupPromise) {
|
|
58
|
+
return this.setupPromise;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
this.isSetupLoading = true;
|
|
62
|
+
this.setupPromise = this.setupAdsOnce();
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
return await this.setupPromise;
|
|
66
|
+
} finally {
|
|
67
|
+
this.isSetupLoading = false;
|
|
68
|
+
this.setupPromise = null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async setupAdsOnce() {
|
|
73
|
+
await this.loadScript();
|
|
74
|
+
console.log('adsbygoogle loaded');
|
|
75
|
+
|
|
76
|
+
if (typeof globalThis.adConfig === 'undefined') {
|
|
77
|
+
console.log('GoogleH5 adBreak plugin not ready');
|
|
78
|
+
throw Error('GoogleH5 adBreak plugin not ready');
|
|
72
79
|
}
|
|
73
80
|
|
|
74
81
|
globalThis.adConfig({
|
|
@@ -77,10 +84,9 @@ export class WebPortal extends BasePortal {
|
|
|
77
84
|
onReady: () => {
|
|
78
85
|
console.log('GoogleH5.isSetup is ready');
|
|
79
86
|
},
|
|
80
|
-
});
|
|
81
|
-
this.isSetup = true;
|
|
82
|
-
|
|
83
|
-
}
|
|
87
|
+
});
|
|
88
|
+
this.isSetup = true;
|
|
89
|
+
}
|
|
84
90
|
|
|
85
91
|
async loadScript() {
|
|
86
92
|
return new Promise((resolve, reject) => {
|
|
@@ -114,10 +120,11 @@ export class WebPortal extends BasePortal {
|
|
|
114
120
|
});
|
|
115
121
|
}
|
|
116
122
|
|
|
117
|
-
loadInterstitialAd() {
|
|
118
|
-
console.log('GoogleH5.loadAd');
|
|
119
|
-
}
|
|
120
|
-
|
|
123
|
+
loadInterstitialAd() {
|
|
124
|
+
console.log('GoogleH5.loadAd');
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
showInterstitialAd() {
|
|
121
128
|
console.log('GoogleH5.showAd');
|
|
122
129
|
|
|
123
130
|
if (typeof adBreak === 'undefined' || !globalThis.adBreak) {
|
|
@@ -162,9 +169,11 @@ export class WebPortal extends BasePortal {
|
|
|
162
169
|
return true;
|
|
163
170
|
}
|
|
164
171
|
|
|
165
|
-
showRewardedAd() {
|
|
172
|
+
async showRewardedAd() {
|
|
166
173
|
console.log('GoogleH5.ShowRewardedAd');
|
|
167
174
|
|
|
175
|
+
await this.setupAds();
|
|
176
|
+
|
|
168
177
|
if (typeof globalThis.adBreak === 'undefined' || !globalThis.adBreak) {
|
|
169
178
|
console.log('GoogleH5 adBreak plugin not ready'); return;
|
|
170
179
|
}
|
|
@@ -253,4 +262,4 @@ export class WebPortal extends BasePortal {
|
|
|
253
262
|
return adStatus;
|
|
254
263
|
}
|
|
255
264
|
|
|
256
|
-
}
|
|
265
|
+
}
|
package/package.json
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cardsjd/portal",
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.1.9",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"lib"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"test": "node --test",
|
|
15
|
+
"lint": "eslint lib --report-unused-disable-directives --max-warnings 0",
|
|
16
|
+
"lint:fix": "npm run lint -- --fix"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@capacitor-community/admob": "^7.0.3",
|
|
21
|
+
"@discord/embedded-app-sdk": "^2.4.0"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {}
|
|
23
24
|
}
|