@cardsjd/portal 0.1.10 → 0.1.12

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.
@@ -20,6 +20,7 @@ export class NextGenAdMobPortal extends BasePortal {
20
20
  this.adProviderName = 'CapgoAdmob';
21
21
  this.isSetup = false;
22
22
  this.isSetupLoading = false;
23
+ this._setupPromise = null;
23
24
  this.isInterstitialAdReady = false;
24
25
  this._isRewardedAdLoaded = false;
25
26
  this._receivedReward = false;
@@ -45,14 +46,12 @@ export class NextGenAdMobPortal extends BasePortal {
45
46
  return this._adMobModule;
46
47
  }
47
48
 
48
- async getUmp() {
49
+ async loadUmp() {
49
50
  if (!this._umpModule) {
50
51
  // eslint-disable-next-line import/no-unresolved
51
52
  const { GoogleUmpConsent } = await import('@cardsjd/google-ump');
52
53
  this._umpModule = GoogleUmpConsent;
53
54
  }
54
-
55
- return this._umpModule;
56
55
  }
57
56
 
58
57
  async requestTrackingAuthorization(_consentInfo) {
@@ -84,23 +83,23 @@ export class NextGenAdMobPortal extends BasePortal {
84
83
  }
85
84
 
86
85
  async showPrivacyOptions() {
87
- const ump = await this.getUmp();
88
- const consentInfo = await ump.showPrivacyOptions();
86
+ await this.loadUmp();
87
+ const consentInfo = await this._umpModule.showPrivacyOptions();
89
88
  this.setConsentInfo(consentInfo);
90
89
  return consentInfo;
91
90
  }
92
91
 
93
92
  async updateConsentInfo() {
94
- const ump = await this.getUmp();
95
- const consentInfo = await ump.updateConsentInfo();
93
+ await this.loadUmp();
94
+ const consentInfo = await this._umpModule.updateConsentInfo();
96
95
  this._consentInfoUpdated = true;
97
96
  this.setConsentInfo(consentInfo);
98
97
  return consentInfo;
99
98
  }
100
99
 
101
100
  async gatherConsent() {
102
- const ump = await this.getUmp();
103
- const consentInfo = await ump.gatherConsent();
101
+ await this.loadUmp();
102
+ const consentInfo = await this._umpModule.gatherConsent();
104
103
  this._consentInfoUpdated = true;
105
104
  this._consentGathered = true;
106
105
  this.setConsentInfo(consentInfo);
@@ -118,18 +117,27 @@ export class NextGenAdMobPortal extends BasePortal {
118
117
  return;
119
118
  }
120
119
 
121
- if (this.isSetupLoading) {
122
- throw Error('Capgo AdMob setup is in progress already');
123
- }
120
+ if (!this._setupPromise) {
121
+ this._setupPromise = (async () => {
122
+ this.isSetupLoading = true;
124
123
 
125
- this.isSetupLoading = true;
124
+ try {
125
+ await this.updateConsentInfo();
126
+ } catch (error) {
127
+ console.error('Failed to update UMP consent info:', error);
128
+ } finally {
129
+ this.isSetupLoading = false;
130
+ }
131
+ })();
132
+ }
126
133
 
134
+ const setupPromise = this._setupPromise;
127
135
  try {
128
- await this.updateConsentInfo();
129
- } catch (error) {
130
- console.error('Failed to update UMP consent info:', error);
136
+ await setupPromise;
131
137
  } finally {
132
- this.isSetupLoading = false;
138
+ if (this._setupPromise === setupPromise) {
139
+ this._setupPromise = null;
140
+ }
133
141
  }
134
142
  }
135
143
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cardsjd/portal",
3
3
  "private": false,
4
- "version": "0.1.10",
4
+ "version": "0.1.12",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "publishConfig": {
@@ -20,21 +20,21 @@
20
20
  "@cardsjd/device": "^0.1.15",
21
21
  "@cardsjd/fbinstantgame": "^0.1.12",
22
22
  "@discord/embedded-app-sdk": "^2.4.0"
23
- },
24
- "peerDependencies": {
25
- "@capacitor-community/admob": ">=7 <9",
26
- "@capgo/capacitor-admob": ">=8 <9",
27
- "@cardsjd/google-ump": ">=0.0.1 <1"
28
- },
29
- "peerDependenciesMeta": {
30
- "@capacitor-community/admob": {
31
- "optional": true
32
- },
33
- "@capgo/capacitor-admob": {
34
- "optional": true
35
- },
36
- "@cardsjd/google-ump": {
37
- "optional": true
38
- }
39
- }
40
- }
23
+ },
24
+ "peerDependencies": {
25
+ "@capacitor-community/admob": ">=7 <9",
26
+ "@capgo/capacitor-admob": ">=8 <9",
27
+ "@cardsjd/google-ump": ">=0.0.1 <1"
28
+ },
29
+ "peerDependenciesMeta": {
30
+ "@capacitor-community/admob": {
31
+ "optional": true
32
+ },
33
+ "@capgo/capacitor-admob": {
34
+ "optional": true
35
+ },
36
+ "@cardsjd/google-ump": {
37
+ "optional": true
38
+ }
39
+ }
40
+ }