cordova-admob-tomitank 1.0.0

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 (114) hide show
  1. package/CHANGELOG.md +0 -0
  2. package/README.md +17 -0
  3. package/esm/admob.d.ts +3 -0
  4. package/esm/admob.js +22 -0
  5. package/esm/admob.js.map +1 -0
  6. package/esm/api.d.ts +61 -0
  7. package/esm/api.js +232 -0
  8. package/esm/api.js.map +1 -0
  9. package/esm/app-open.d.ts +17 -0
  10. package/esm/app-open.js +83 -0
  11. package/esm/app-open.js.map +1 -0
  12. package/esm/banner.d.ts +33 -0
  13. package/esm/banner.js +143 -0
  14. package/esm/banner.js.map +1 -0
  15. package/esm/generated.d.ts +77 -0
  16. package/esm/generated.js +104 -0
  17. package/esm/generated.js.map +1 -0
  18. package/esm/index.d.ts +31 -0
  19. package/esm/index.js +95 -0
  20. package/esm/index.js.map +1 -0
  21. package/esm/interstitial.d.ts +7 -0
  22. package/esm/interstitial.js +35 -0
  23. package/esm/interstitial.js.map +1 -0
  24. package/esm/native.d.ts +19 -0
  25. package/esm/native.js +134 -0
  26. package/esm/native.js.map +1 -0
  27. package/esm/rewarded-interstitial.d.ts +10 -0
  28. package/esm/rewarded-interstitial.js +35 -0
  29. package/esm/rewarded-interstitial.js.map +1 -0
  30. package/esm/rewarded.d.ts +14 -0
  31. package/esm/rewarded.js +35 -0
  32. package/esm/rewarded.js.map +1 -0
  33. package/esm/shared.d.ts +2 -0
  34. package/esm/shared.js +3 -0
  35. package/esm/shared.js.map +1 -0
  36. package/lib/admob.d.ts +3 -0
  37. package/lib/admob.js +50 -0
  38. package/lib/admob.js.map +1 -0
  39. package/lib/api.d.ts +61 -0
  40. package/lib/api.js +240 -0
  41. package/lib/api.js.map +1 -0
  42. package/lib/app-open.d.ts +17 -0
  43. package/lib/app-open.js +85 -0
  44. package/lib/app-open.js.map +1 -0
  45. package/lib/banner.d.ts +33 -0
  46. package/lib/banner.js +145 -0
  47. package/lib/banner.js.map +1 -0
  48. package/lib/generated.d.ts +77 -0
  49. package/lib/generated.js +110 -0
  50. package/lib/generated.js.map +1 -0
  51. package/lib/index.d.ts +31 -0
  52. package/lib/index.js +120 -0
  53. package/lib/index.js.map +1 -0
  54. package/lib/interstitial.d.ts +7 -0
  55. package/lib/interstitial.js +37 -0
  56. package/lib/interstitial.js.map +1 -0
  57. package/lib/native.d.ts +19 -0
  58. package/lib/native.js +136 -0
  59. package/lib/native.js.map +1 -0
  60. package/lib/rewarded-interstitial.d.ts +10 -0
  61. package/lib/rewarded-interstitial.js +37 -0
  62. package/lib/rewarded-interstitial.js.map +1 -0
  63. package/lib/rewarded.d.ts +14 -0
  64. package/lib/rewarded.js +37 -0
  65. package/lib/rewarded.js.map +1 -0
  66. package/lib/shared.d.ts +2 -0
  67. package/lib/shared.js +19 -0
  68. package/lib/shared.js.map +1 -0
  69. package/package.json +73 -0
  70. package/plugin.xml +333 -0
  71. package/scripts/iosNSAppTransportSecurity.js +29 -0
  72. package/scripts/iosNSAppTransportSecurity.ts +33 -0
  73. package/scripts/tsconfig.json +5 -0
  74. package/scripts/util.js +34 -0
  75. package/scripts/util.ts +44 -0
  76. package/src/android/cordova/AdMob.java +256 -0
  77. package/src/android/cordova/ExecuteContext.java +174 -0
  78. package/src/android/cordova/Generated.java +72 -0
  79. package/src/android/cordova/ads/AdBase.java +54 -0
  80. package/src/android/cordova/ads/AppOpen.java +98 -0
  81. package/src/android/cordova/ads/Banner.java +370 -0
  82. package/src/android/cordova/ads/Interstitial.java +101 -0
  83. package/src/android/cordova/ads/Native.java +162 -0
  84. package/src/android/cordova/ads/Rewarded.java +108 -0
  85. package/src/android/cordova/ads/RewardedInterstitial.java +108 -0
  86. package/src/android/core/Ad.java +73 -0
  87. package/src/android/core/Context.java +186 -0
  88. package/src/android/core/GenericAd.java +22 -0
  89. package/src/android/core/Helper.java +134 -0
  90. package/src/browser/AdMobProxy.js +33 -0
  91. package/src/ios/AMBAdBase.swift +72 -0
  92. package/src/ios/AMBAppOpenAd.swift +87 -0
  93. package/src/ios/AMBBanner.swift +294 -0
  94. package/src/ios/AMBContext.swift +166 -0
  95. package/src/ios/AMBCore.swift +232 -0
  96. package/src/ios/AMBGenerated.swift +45 -0
  97. package/src/ios/AMBInterstitial.swift +69 -0
  98. package/src/ios/AMBNativeAd.swift +128 -0
  99. package/src/ios/AMBPlugin.swift +198 -0
  100. package/src/ios/AMBRewarded.swift +72 -0
  101. package/src/ios/AMBRewardedInterstitial.swift +72 -0
  102. package/src/www/admob.ts +26 -0
  103. package/src/www/api.ts +156 -0
  104. package/src/www/app-open.ts +27 -0
  105. package/src/www/banner.ts +102 -0
  106. package/src/www/cordova.d.ts +9 -0
  107. package/src/www/generated.ts +125 -0
  108. package/src/www/index.ts +88 -0
  109. package/src/www/interstitial.ts +17 -0
  110. package/src/www/native.ts +54 -0
  111. package/src/www/rewarded-interstitial.ts +20 -0
  112. package/src/www/rewarded.ts +26 -0
  113. package/src/www/shared.ts +2 -0
  114. package/www/admob.js +675 -0
package/www/admob.js ADDED
@@ -0,0 +1,675 @@
1
+ 'use strict';
2
+
3
+ var cordova$1 = require('cordova');
4
+ var channel = require('cordova/channel');
5
+ var exec = require('cordova/exec');
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ function _interopNamespace(e) {
10
+ if (e && e.__esModule) return e;
11
+ var n = Object.create(null);
12
+ if (e) {
13
+ Object.keys(e).forEach(function (k) {
14
+ if (k !== 'default') {
15
+ var d = Object.getOwnPropertyDescriptor(e, k);
16
+ Object.defineProperty(n, k, d.get ? d : {
17
+ enumerable: true,
18
+ get: function () { return e[k]; }
19
+ });
20
+ }
21
+ });
22
+ }
23
+ n["default"] = e;
24
+ return Object.freeze(n);
25
+ }
26
+
27
+ var cordova__namespace = /*#__PURE__*/_interopNamespace(cordova$1);
28
+ var channel__default = /*#__PURE__*/_interopDefaultLegacy(channel);
29
+ var exec__default = /*#__PURE__*/_interopDefaultLegacy(exec);
30
+
31
+ /******************************************************************************
32
+ Copyright (c) Microsoft Corporation.
33
+
34
+ Permission to use, copy, modify, and/or distribute this software for any
35
+ purpose with or without fee is hereby granted.
36
+
37
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
38
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
39
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
40
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
41
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
42
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
43
+ PERFORMANCE OF THIS SOFTWARE.
44
+ ***************************************************************************** */
45
+ /* global Reflect, Promise */
46
+
47
+ var extendStatics = function(d, b) {
48
+ extendStatics = Object.setPrototypeOf ||
49
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
50
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
51
+ return extendStatics(d, b);
52
+ };
53
+
54
+ function __extends(d, b) {
55
+ if (typeof b !== "function" && b !== null)
56
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
57
+ extendStatics(d, b);
58
+ function __() { this.constructor = d; }
59
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
60
+ }
61
+
62
+ var __assign = function() {
63
+ __assign = Object.assign || function __assign(t) {
64
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
65
+ s = arguments[i];
66
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
67
+ }
68
+ return t;
69
+ };
70
+ return __assign.apply(this, arguments);
71
+ };
72
+
73
+ function __awaiter(thisArg, _arguments, P, generator) {
74
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
75
+ return new (P || (P = Promise))(function (resolve, reject) {
76
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
77
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
78
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
79
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
80
+ });
81
+ }
82
+
83
+ function __generator(thisArg, body) {
84
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
85
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
86
+ function verb(n) { return function (v) { return step([n, v]); }; }
87
+ function step(op) {
88
+ if (f) throw new TypeError("Generator is already executing.");
89
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
90
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
91
+ if (y = 0, t) op = [op[0] & 2, t.value];
92
+ switch (op[0]) {
93
+ case 0: case 1: t = op; break;
94
+ case 4: _.label++; return { value: op[1], done: false };
95
+ case 5: _.label++; y = op[1]; op = [0]; continue;
96
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
97
+ default:
98
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
99
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
100
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
101
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
102
+ if (t[2]) _.ops.pop();
103
+ _.trys.pop(); continue;
104
+ }
105
+ op = body.call(thisArg, _);
106
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
107
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
108
+ }
109
+ }
110
+
111
+ function __spreadArray(to, from, pack) {
112
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
113
+ if (ar || !(i in from)) {
114
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
115
+ ar[i] = from[i];
116
+ }
117
+ }
118
+ return to.concat(ar || Array.prototype.slice.call(from));
119
+ }
120
+
121
+ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
122
+ var NativeActions;
123
+ (function (NativeActions) {
124
+ NativeActions["adCreate"] = "adCreate";
125
+ NativeActions["adHide"] = "adHide";
126
+ NativeActions["adIsLoaded"] = "adIsLoaded";
127
+ NativeActions["adLoad"] = "adLoad";
128
+ NativeActions["adShow"] = "adShow";
129
+ NativeActions["bannerConfig"] = "bannerConfig";
130
+ NativeActions["bannerHide"] = "bannerHide";
131
+ NativeActions["bannerLoad"] = "bannerLoad";
132
+ NativeActions["bannerShow"] = "bannerShow";
133
+ NativeActions["configRequest"] = "configRequest";
134
+ NativeActions["configure"] = "configure";
135
+ NativeActions["interstitialIsLoaded"] = "interstitialIsLoaded";
136
+ NativeActions["interstitialLoad"] = "interstitialLoad";
137
+ NativeActions["interstitialShow"] = "interstitialShow";
138
+ NativeActions["ready"] = "ready";
139
+ NativeActions["requestTrackingAuthorization"] = "requestTrackingAuthorization";
140
+ NativeActions["rewardedInterstitialIsLoaded"] = "rewardedInterstitialIsLoaded";
141
+ NativeActions["rewardedInterstitialLoad"] = "rewardedInterstitialLoad";
142
+ NativeActions["rewardedInterstitialShow"] = "rewardedInterstitialShow";
143
+ NativeActions["rewardedIsLoaded"] = "rewardedIsLoaded";
144
+ NativeActions["rewardedLoad"] = "rewardedLoad";
145
+ NativeActions["rewardedShow"] = "rewardedShow";
146
+ NativeActions["setAppMuted"] = "setAppMuted";
147
+ NativeActions["setAppVolume"] = "setAppVolume";
148
+ NativeActions["start"] = "start";
149
+ })(NativeActions || (NativeActions = {}));
150
+ var Events;
151
+ (function (Events) {
152
+ Events["adClick"] = "admob.ad.click";
153
+ Events["adDismiss"] = "admob.ad.dismiss";
154
+ Events["adImpression"] = "admob.ad.impression";
155
+ Events["adLoad"] = "admob.ad.load";
156
+ Events["adLoadFail"] = "admob.ad.loadfail";
157
+ Events["adReward"] = "admob.ad.reward";
158
+ Events["adShow"] = "admob.ad.show";
159
+ Events["adShowFail"] = "admob.ad.showfail";
160
+ Events["bannerClick"] = "admob.banner.click";
161
+ Events["bannerClose"] = "admob.banner.close";
162
+ Events["bannerImpression"] = "admob.banner.impression";
163
+ Events["bannerLoad"] = "admob.banner.load";
164
+ Events["bannerLoadFail"] = "admob.banner.loadfail";
165
+ Events["bannerOpen"] = "admob.banner.open";
166
+ Events["bannerSize"] = "admob.banner.size";
167
+ Events["bannerSizeChange"] = "admob.banner.sizechange";
168
+ Events["interstitialDismiss"] = "admob.interstitial.dismiss";
169
+ Events["interstitialImpression"] = "admob.interstitial.impression";
170
+ Events["interstitialLoad"] = "admob.interstitial.load";
171
+ Events["interstitialLoadFail"] = "admob.interstitial.loadfail";
172
+ Events["interstitialShow"] = "admob.interstitial.show";
173
+ Events["interstitialShowFail"] = "admob.interstitial.showfail";
174
+ Events["ready"] = "admob.ready";
175
+ Events["rewardedDismiss"] = "admob.rewarded.dismiss";
176
+ Events["rewardedImpression"] = "admob.rewarded.impression";
177
+ Events["rewardedInterstitialDismiss"] = "admob.rewardedi.dismiss";
178
+ Events["rewardedInterstitialImpression"] = "admob.rewardedi.impression";
179
+ Events["rewardedInterstitialLoad"] = "admob.rewardedi.load";
180
+ Events["rewardedInterstitialLoadFail"] = "admob.rewardedi.loadfail";
181
+ Events["rewardedInterstitialReward"] = "admob.rewardedi.reward";
182
+ Events["rewardedInterstitialShow"] = "admob.rewardedi.show";
183
+ Events["rewardedInterstitialShowFail"] = "admob.rewardedi.showfail";
184
+ Events["rewardedLoad"] = "admob.rewarded.load";
185
+ Events["rewardedLoadFail"] = "admob.rewarded.loadfail";
186
+ Events["rewardedReward"] = "admob.rewarded.reward";
187
+ Events["rewardedShow"] = "admob.rewarded.show";
188
+ Events["rewardedShowFail"] = "admob.rewarded.showfail";
189
+ })(Events || (Events = {}));
190
+ var AdSizeType;
191
+ (function (AdSizeType) {
192
+ AdSizeType[AdSizeType["BANNER"] = 0] = "BANNER";
193
+ AdSizeType[AdSizeType["LARGE_BANNER"] = 1] = "LARGE_BANNER";
194
+ AdSizeType[AdSizeType["MEDIUM_RECTANGLE"] = 2] = "MEDIUM_RECTANGLE";
195
+ AdSizeType[AdSizeType["FULL_BANNER"] = 3] = "FULL_BANNER";
196
+ AdSizeType[AdSizeType["LEADERBOARD"] = 4] = "LEADERBOARD";
197
+ AdSizeType[AdSizeType["SMART_BANNER"] = 5] = "SMART_BANNER";
198
+ })(AdSizeType || (AdSizeType = {}));
199
+ var execAsync = function (action, args) {
200
+ return new Promise(function (resolve, reject) {
201
+ cordova.exec(resolve, reject, 'AdMob', action, args);
202
+ });
203
+ };
204
+
205
+ var started = false;
206
+ var startPromise = null;
207
+ /** @internal */
208
+ function start() {
209
+ return __awaiter(this, void 0, void 0, function () {
210
+ var result;
211
+ return __generator(this, function (_a) {
212
+ switch (_a.label) {
213
+ case 0:
214
+ startPromise = execAsync(NativeActions.start);
215
+ return [4 /*yield*/, startPromise];
216
+ case 1:
217
+ result = _a.sent();
218
+ started = true;
219
+ return [2 /*return*/, result];
220
+ }
221
+ });
222
+ });
223
+ }
224
+ /** @internal */
225
+ var MobileAd = /** @class */ (function () {
226
+ function MobileAd(opts) {
227
+ var _a;
228
+ this._created = false;
229
+ this._init = null;
230
+ this.opts = opts;
231
+ this.id = (_a = opts.id) !== null && _a !== void 0 ? _a : MobileAd.nextId();
232
+ MobileAd.allAds[this.id] = this;
233
+ }
234
+ MobileAd.getAdById = function (id) {
235
+ return this.allAds[id];
236
+ };
237
+ MobileAd.nextId = function () {
238
+ var storage = window.localStorage;
239
+ var key = 'admob-ad-id-counter';
240
+ var value = storage.getItem(key);
241
+ if (value !== null) {
242
+ MobileAd.idCounter = Number(value);
243
+ }
244
+ MobileAd.idCounter += 1;
245
+ storage.setItem(key, "".concat(MobileAd.idCounter));
246
+ return MobileAd.idCounter;
247
+ };
248
+ Object.defineProperty(MobileAd.prototype, "adUnitId", {
249
+ get: function () {
250
+ return this.opts.adUnitId;
251
+ },
252
+ enumerable: false,
253
+ configurable: true
254
+ });
255
+ MobileAd.prototype.on = function () {
256
+ var _this = this;
257
+ var args = [];
258
+ for (var _i = 0; _i < arguments.length; _i++) {
259
+ args[_i] = arguments[_i];
260
+ }
261
+ var eventName = args[0], cb = args[1], rest = args.slice(2);
262
+ var type = "admob.ad.".concat(eventName.toLowerCase());
263
+ var listener = function (evt) {
264
+ if (evt.ad === _this) {
265
+ cb(evt);
266
+ }
267
+ };
268
+ document.addEventListener.apply(document, __spreadArray([type, listener], rest, false));
269
+ return function () {
270
+ document.removeEventListener.apply(document, __spreadArray([type, listener], rest, false));
271
+ };
272
+ };
273
+ MobileAd.prototype.isLoaded = function () {
274
+ return __awaiter(this, void 0, void 0, function () {
275
+ return __generator(this, function (_a) {
276
+ switch (_a.label) {
277
+ case 0: return [4 /*yield*/, this.init()];
278
+ case 1:
279
+ _a.sent();
280
+ return [2 /*return*/, execAsync(NativeActions.adIsLoaded, [
281
+ { id: this.id },
282
+ ])];
283
+ }
284
+ });
285
+ });
286
+ };
287
+ MobileAd.prototype.load = function () {
288
+ return __awaiter(this, void 0, void 0, function () {
289
+ return __generator(this, function (_a) {
290
+ switch (_a.label) {
291
+ case 0: return [4 /*yield*/, this.init()
292
+ // TODO read `opts` in native code?
293
+ ];
294
+ case 1:
295
+ _a.sent();
296
+ // TODO read `opts` in native code?
297
+ return [4 /*yield*/, execAsync(NativeActions.adLoad, [__assign(__assign({}, this.opts), { id: this.id })])];
298
+ case 2:
299
+ // TODO read `opts` in native code?
300
+ _a.sent();
301
+ return [2 /*return*/];
302
+ }
303
+ });
304
+ });
305
+ };
306
+ MobileAd.prototype.show = function (opts) {
307
+ return __awaiter(this, void 0, void 0, function () {
308
+ return __generator(this, function (_a) {
309
+ switch (_a.label) {
310
+ case 0: return [4 /*yield*/, this.init()];
311
+ case 1:
312
+ _a.sent();
313
+ return [2 /*return*/, execAsync(NativeActions.adShow, [__assign(__assign({}, opts), { id: this.id })])];
314
+ }
315
+ });
316
+ });
317
+ };
318
+ MobileAd.prototype.hide = function () {
319
+ return __awaiter(this, void 0, void 0, function () {
320
+ return __generator(this, function (_a) {
321
+ return [2 /*return*/, execAsync(NativeActions.adHide, [{ id: this.id }])];
322
+ });
323
+ });
324
+ };
325
+ MobileAd.prototype.init = function () {
326
+ var _a;
327
+ return __awaiter(this, void 0, void 0, function () {
328
+ var cls;
329
+ return __generator(this, function (_b) {
330
+ switch (_b.label) {
331
+ case 0:
332
+ if (this._created)
333
+ return [2 /*return*/];
334
+ if (!!started) return [3 /*break*/, 2];
335
+ if (startPromise === null)
336
+ start();
337
+ return [4 /*yield*/, startPromise];
338
+ case 1:
339
+ _b.sent();
340
+ _b.label = 2;
341
+ case 2:
342
+ if (this._init === null) {
343
+ cls = (_a = this.constructor.cls) !== null && _a !== void 0 ? _a : this.constructor.name;
344
+ this._init = execAsync(NativeActions.adCreate, [
345
+ __assign(__assign({}, this.opts), { id: this.id, cls: cls }),
346
+ ]);
347
+ }
348
+ return [4 /*yield*/, this._init];
349
+ case 3:
350
+ _b.sent();
351
+ this._created = true;
352
+ return [2 /*return*/];
353
+ }
354
+ });
355
+ });
356
+ };
357
+ MobileAd.type = '';
358
+ MobileAd.allAds = {};
359
+ MobileAd.idCounter = 0;
360
+ return MobileAd;
361
+ }());
362
+ var MaxAdContentRating;
363
+ (function (MaxAdContentRating) {
364
+ MaxAdContentRating["G"] = "G";
365
+ MaxAdContentRating["MA"] = "MA";
366
+ MaxAdContentRating["PG"] = "PG";
367
+ MaxAdContentRating["T"] = "T";
368
+ MaxAdContentRating["UNSPECIFIED"] = "";
369
+ })(MaxAdContentRating || (MaxAdContentRating = {}));
370
+ var TrackingAuthorizationStatus;
371
+ (function (TrackingAuthorizationStatus) {
372
+ TrackingAuthorizationStatus[TrackingAuthorizationStatus["notDetermined"] = 0] = "notDetermined";
373
+ TrackingAuthorizationStatus[TrackingAuthorizationStatus["restricted"] = 1] = "restricted";
374
+ TrackingAuthorizationStatus[TrackingAuthorizationStatus["denied"] = 2] = "denied";
375
+ TrackingAuthorizationStatus[TrackingAuthorizationStatus["authorized"] = 3] = "authorized";
376
+ })(TrackingAuthorizationStatus || (TrackingAuthorizationStatus = {}));
377
+
378
+ var AppOpenAdOrientation;
379
+ (function (AppOpenAdOrientation) {
380
+ AppOpenAdOrientation[AppOpenAdOrientation["Portrait"] = 1] = "Portrait";
381
+ AppOpenAdOrientation[AppOpenAdOrientation["PortraitUpsideDown"] = 2] = "PortraitUpsideDown";
382
+ AppOpenAdOrientation[AppOpenAdOrientation["LandscapeRight"] = 3] = "LandscapeRight";
383
+ AppOpenAdOrientation[AppOpenAdOrientation["LandscapeLeft"] = 4] = "LandscapeLeft";
384
+ })(AppOpenAdOrientation || (AppOpenAdOrientation = {}));
385
+ var AppOpenAd = /** @class */ (function (_super) {
386
+ __extends(AppOpenAd, _super);
387
+ function AppOpenAd() {
388
+ return _super !== null && _super.apply(this, arguments) || this;
389
+ }
390
+ AppOpenAd.prototype.isLoaded = function () {
391
+ return _super.prototype.isLoaded.call(this);
392
+ };
393
+ AppOpenAd.prototype.load = function () {
394
+ return _super.prototype.load.call(this);
395
+ };
396
+ AppOpenAd.prototype.show = function () {
397
+ return __awaiter(this, void 0, void 0, function () {
398
+ return __generator(this, function (_a) {
399
+ return [2 /*return*/, _super.prototype.show.call(this)];
400
+ });
401
+ });
402
+ };
403
+ AppOpenAd.cls = 'AppOpenAd';
404
+ AppOpenAd.Orientation = AppOpenAdOrientation;
405
+ return AppOpenAd;
406
+ }(MobileAd));
407
+
408
+ var colorToRGBA = (function () {
409
+ var canvas = document.createElement('canvas');
410
+ canvas.width = canvas.height = 1;
411
+ var ctx = canvas.getContext('2d');
412
+ if (!ctx)
413
+ return function () { return undefined; };
414
+ return function (col) {
415
+ ctx.clearRect(0, 0, 1, 1);
416
+ // In order to detect invalid values,
417
+ // we can't rely on col being in the same format as what fillStyle is computed as,
418
+ // but we can ask it to implicitly compute a normalized value twice and compare.
419
+ ctx.fillStyle = '#000';
420
+ ctx.fillStyle = col;
421
+ var computed = ctx.fillStyle;
422
+ ctx.fillStyle = '#fff';
423
+ ctx.fillStyle = col;
424
+ if (computed !== ctx.fillStyle) {
425
+ return; // invalid color
426
+ }
427
+ ctx.fillRect(0, 0, 1, 1);
428
+ var data = ctx.getImageData(0, 0, 1, 1).data;
429
+ return { r: data[0], g: data[1], b: data[2], a: data[3] };
430
+ };
431
+ })();
432
+ var BannerAd = /** @class */ (function (_super) {
433
+ __extends(BannerAd, _super);
434
+ function BannerAd(opts) {
435
+ var _this = _super.call(this, __assign({ position: 'bottom', size: AdSizeType.SMART_BANNER }, opts)) || this;
436
+ _this._loaded = false;
437
+ return _this;
438
+ }
439
+ BannerAd.config = function (opts) {
440
+ if (cordova.platformId === "ios" /* Platforms.ios */) {
441
+ var bgColor = opts.backgroundColor;
442
+ return execAsync(NativeActions.bannerConfig, [
443
+ __assign(__assign({}, opts), { backgroundColor: bgColor ? colorToRGBA(bgColor) : bgColor }),
444
+ ]);
445
+ }
446
+ return false;
447
+ };
448
+ BannerAd.prototype.load = function () {
449
+ return __awaiter(this, void 0, void 0, function () {
450
+ return __generator(this, function (_a) {
451
+ switch (_a.label) {
452
+ case 0: return [4 /*yield*/, _super.prototype.load.call(this)];
453
+ case 1:
454
+ _a.sent();
455
+ this._loaded = true;
456
+ return [2 /*return*/];
457
+ }
458
+ });
459
+ });
460
+ };
461
+ BannerAd.prototype.show = function () {
462
+ return __awaiter(this, void 0, void 0, function () {
463
+ return __generator(this, function (_a) {
464
+ switch (_a.label) {
465
+ case 0:
466
+ if (!!this._loaded) return [3 /*break*/, 2];
467
+ return [4 /*yield*/, this.load()];
468
+ case 1:
469
+ _a.sent();
470
+ _a.label = 2;
471
+ case 2: return [2 /*return*/, _super.prototype.show.call(this)];
472
+ }
473
+ });
474
+ });
475
+ };
476
+ BannerAd.prototype.hide = function () {
477
+ return __awaiter(this, void 0, void 0, function () {
478
+ return __generator(this, function (_a) {
479
+ return [2 /*return*/, _super.prototype.hide.call(this)];
480
+ });
481
+ });
482
+ };
483
+ BannerAd.cls = 'BannerAd';
484
+ return BannerAd;
485
+ }(MobileAd));
486
+
487
+ var InterstitialAd = /** @class */ (function (_super) {
488
+ __extends(InterstitialAd, _super);
489
+ function InterstitialAd() {
490
+ return _super !== null && _super.apply(this, arguments) || this;
491
+ }
492
+ InterstitialAd.prototype.isLoaded = function () {
493
+ return _super.prototype.isLoaded.call(this);
494
+ };
495
+ InterstitialAd.prototype.load = function () {
496
+ return _super.prototype.load.call(this);
497
+ };
498
+ InterstitialAd.prototype.show = function () {
499
+ return _super.prototype.show.call(this);
500
+ };
501
+ InterstitialAd.cls = 'InterstitialAd';
502
+ return InterstitialAd;
503
+ }(MobileAd));
504
+
505
+ var NativeAd = /** @class */ (function (_super) {
506
+ __extends(NativeAd, _super);
507
+ function NativeAd() {
508
+ return _super !== null && _super.apply(this, arguments) || this;
509
+ }
510
+ NativeAd.prototype.isLoaded = function () {
511
+ return _super.prototype.isLoaded.call(this);
512
+ };
513
+ NativeAd.prototype.hide = function () {
514
+ return __awaiter(this, void 0, void 0, function () {
515
+ return __generator(this, function (_a) {
516
+ return [2 /*return*/, _super.prototype.hide.call(this)];
517
+ });
518
+ });
519
+ };
520
+ NativeAd.prototype.load = function () {
521
+ return _super.prototype.load.call(this);
522
+ };
523
+ NativeAd.prototype.show = function (opts) {
524
+ return __awaiter(this, void 0, void 0, function () {
525
+ return __generator(this, function (_a) {
526
+ return [2 /*return*/, _super.prototype.show.call(this, __assign({ x: 0, y: 0, width: 0, height: 0 }, opts))];
527
+ });
528
+ });
529
+ };
530
+ NativeAd.prototype.showWith = function (elm) {
531
+ return __awaiter(this, void 0, void 0, function () {
532
+ var update, observer;
533
+ var _this = this;
534
+ return __generator(this, function (_a) {
535
+ switch (_a.label) {
536
+ case 0:
537
+ update = function () { return __awaiter(_this, void 0, void 0, function () {
538
+ var r;
539
+ return __generator(this, function (_a) {
540
+ switch (_a.label) {
541
+ case 0:
542
+ r = elm.getBoundingClientRect();
543
+ return [4 /*yield*/, this.show({
544
+ x: r.x,
545
+ y: r.y,
546
+ width: r.width,
547
+ height: r.height,
548
+ })];
549
+ case 1:
550
+ _a.sent();
551
+ return [2 /*return*/];
552
+ }
553
+ });
554
+ }); };
555
+ observer = new MutationObserver(update);
556
+ observer.observe(document.body, {
557
+ attributes: true,
558
+ childList: true,
559
+ subtree: true,
560
+ });
561
+ document.addEventListener('scroll', update);
562
+ window.addEventListener('resize', update);
563
+ return [4 /*yield*/, update()];
564
+ case 1:
565
+ _a.sent();
566
+ return [2 /*return*/];
567
+ }
568
+ });
569
+ });
570
+ };
571
+ NativeAd.cls = 'NativeAd';
572
+ return NativeAd;
573
+ }(MobileAd));
574
+
575
+ var RewardedAd = /** @class */ (function (_super) {
576
+ __extends(RewardedAd, _super);
577
+ function RewardedAd() {
578
+ return _super !== null && _super.apply(this, arguments) || this;
579
+ }
580
+ RewardedAd.prototype.isLoaded = function () {
581
+ return _super.prototype.isLoaded.call(this);
582
+ };
583
+ RewardedAd.prototype.load = function () {
584
+ return _super.prototype.load.call(this);
585
+ };
586
+ RewardedAd.prototype.show = function () {
587
+ return _super.prototype.show.call(this);
588
+ };
589
+ RewardedAd.cls = 'RewardedAd';
590
+ return RewardedAd;
591
+ }(MobileAd));
592
+
593
+ var RewardedInterstitialAd = /** @class */ (function (_super) {
594
+ __extends(RewardedInterstitialAd, _super);
595
+ function RewardedInterstitialAd() {
596
+ return _super !== null && _super.apply(this, arguments) || this;
597
+ }
598
+ RewardedInterstitialAd.prototype.isLoaded = function () {
599
+ return _super.prototype.isLoaded.call(this);
600
+ };
601
+ RewardedInterstitialAd.prototype.load = function () {
602
+ return _super.prototype.load.call(this);
603
+ };
604
+ RewardedInterstitialAd.prototype.show = function () {
605
+ return _super.prototype.show.call(this);
606
+ };
607
+ RewardedInterstitialAd.cls = 'RewardedInterstitialAd';
608
+ return RewardedInterstitialAd;
609
+ }(MobileAd));
610
+
611
+ var AdMob = /** @class */ (function () {
612
+ function AdMob() {
613
+ this.AppOpenAd = AppOpenAd;
614
+ this.BannerAd = BannerAd;
615
+ this.InterstitialAd = InterstitialAd;
616
+ this.NativeAd = NativeAd;
617
+ this.RewardedAd = RewardedAd;
618
+ this.RewardedInterstitialAd = RewardedInterstitialAd;
619
+ this.Events = Events;
620
+ this.TrackingAuthorizationStatus = TrackingAuthorizationStatus;
621
+ }
622
+ AdMob.prototype.configure = function (config) {
623
+ return execAsync(NativeActions.configure, [config]);
624
+ };
625
+ AdMob.prototype.configRequest = function (requestConfig) {
626
+ return execAsync(NativeActions.configRequest, [requestConfig]);
627
+ };
628
+ AdMob.prototype.setAppMuted = function (value) {
629
+ return execAsync(NativeActions.setAppMuted, [value]);
630
+ };
631
+ AdMob.prototype.setAppVolume = function (value) {
632
+ return execAsync(NativeActions.setAppVolume, [value]);
633
+ };
634
+ AdMob.prototype.start = function () {
635
+ return start();
636
+ };
637
+ AdMob.prototype.requestTrackingAuthorization = function () {
638
+ return __awaiter(this, void 0, void 0, function () {
639
+ var n;
640
+ return __generator(this, function (_a) {
641
+ switch (_a.label) {
642
+ case 0:
643
+ if (!(cordova.platformId === "ios" /* Platforms.ios */)) return [3 /*break*/, 2];
644
+ return [4 /*yield*/, execAsync(NativeActions.requestTrackingAuthorization)];
645
+ case 1:
646
+ n = _a.sent();
647
+ if (n !== false) {
648
+ return [2 /*return*/, TrackingAuthorizationStatus[TrackingAuthorizationStatus[n]]];
649
+ }
650
+ _a.label = 2;
651
+ case 2: return [2 /*return*/, false];
652
+ }
653
+ });
654
+ });
655
+ };
656
+ return AdMob;
657
+ }());
658
+
659
+ var admob = new AdMob();
660
+ function onMessageFromNative(event) {
661
+ var data = event.data;
662
+ if (data && data.adId) {
663
+ data.ad = MobileAd.getAdById(data.adId);
664
+ }
665
+ cordova__namespace.fireDocumentEvent(event.type, data);
666
+ }
667
+ var feature = 'onAdMobPlusReady';
668
+ channel__default["default"].createSticky(feature);
669
+ channel__default["default"].waitForInitialization(feature);
670
+ channel__default["default"].onCordovaReady.subscribe(function () {
671
+ exec__default["default"](onMessageFromNative, console.error, 'AdMob', NativeActions.ready, []);
672
+ channel__default["default"].initializationComplete(feature);
673
+ });
674
+
675
+ module.exports = admob;