@capacitor-community/admob 8.2.0 → 8.2.1
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/CapacitorCommunityAdmob.podspec +1 -1
- package/Package.swift +1 -1
- package/README.md +8 -7
- package/android/src/main/java/com/getcapacitor/community/admob/AdMob.java +73 -0
- package/android/src/main/java/com/getcapacitor/community/admob/nativeads/NativeAdExecutor.kt +378 -0
- package/android/src/main/java/com/getcapacitor/community/admob/nativeads/NativeAdFeedSessions.kt +35 -0
- package/android/src/main/java/com/getcapacitor/community/admob/nativeads/NativeAdPlacementValue.kt +44 -0
- package/android/src/main/java/com/getcapacitor/community/admob/nativeads/NativeAdPluginEvents.kt +11 -0
- package/android/src/main/java/com/getcapacitor/community/admob/nativeads/PluginNativeAdView.kt +187 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +5 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/native-ads/index.d.ts +6 -0
- package/dist/esm/native-ads/index.js +4 -0
- package/dist/esm/native-ads/index.js.map +1 -0
- package/dist/esm/native-ads/native-ad-definitions.interface.d.ts +14 -0
- package/dist/esm/native-ads/native-ad-definitions.interface.js +2 -0
- package/dist/esm/native-ads/native-ad-definitions.interface.js.map +1 -0
- package/dist/esm/native-ads/native-ad-element.d.ts +9 -0
- package/dist/esm/native-ads/native-ad-element.js +53 -0
- package/dist/esm/native-ads/native-ad-element.js.map +1 -0
- package/dist/esm/native-ads/native-ad-event.interface.d.ts +5 -0
- package/dist/esm/native-ads/native-ad-event.interface.js +2 -0
- package/dist/esm/native-ads/native-ad-event.interface.js.map +1 -0
- package/dist/esm/native-ads/native-ad-feed.d.ts +72 -0
- package/dist/esm/native-ads/native-ad-feed.js +568 -0
- package/dist/esm/native-ads/native-ad-feed.js.map +1 -0
- package/dist/esm/native-ads/native-ad-geometry.d.ts +8 -0
- package/dist/esm/native-ads/native-ad-geometry.js +91 -0
- package/dist/esm/native-ads/native-ad-geometry.js.map +1 -0
- package/dist/esm/native-ads/native-ad-options.interface.d.ts +36 -0
- package/dist/esm/native-ads/native-ad-options.interface.js +2 -0
- package/dist/esm/native-ads/native-ad-options.interface.js.map +1 -0
- package/dist/esm/native-ads/native-ad-placement.interface.d.ts +26 -0
- package/dist/esm/native-ads/native-ad-placement.interface.js +2 -0
- package/dist/esm/native-ads/native-ad-placement.interface.js.map +1 -0
- package/dist/esm/native-ads/native-ad-plugin-events.enum.d.ts +9 -0
- package/dist/esm/native-ads/native-ad-plugin-events.enum.js +11 -0
- package/dist/esm/native-ads/native-ad-plugin-events.enum.js.map +1 -0
- package/dist/esm/native-ads/native-ad-style.interface.d.ts +30 -0
- package/dist/esm/native-ads/native-ad-style.interface.js +2 -0
- package/dist/esm/native-ads/native-ad-style.interface.js.map +1 -0
- package/dist/esm/native-ads/native-ad-template.enum.d.ts +11 -0
- package/dist/esm/native-ads/native-ad-template.enum.js +13 -0
- package/dist/esm/native-ads/native-ad-template.enum.js.map +1 -0
- package/dist/esm/web.d.ts +9 -1
- package/dist/esm/web.js +15 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +751 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +751 -1
- package/dist/plugin.js.map +1 -1
- package/docs/configuration.md +2 -2
- package/docs/consent.md +6 -6
- package/docs/events.md +3 -2
- package/docs/migration.md +22 -2
- package/docs/native-ads.md +161 -0
- package/docs/rewarded.md +13 -0
- package/ios/Sources/AdMobPlugin/AdMobPlugin.swift +103 -41
- package/ios/Sources/AdMobPlugin/Interstitial/AdInterstitialExecutor.swift +3 -0
- package/ios/Sources/AdMobPlugin/NativeAds/NativeAdExecutor.swift +354 -0
- package/ios/Sources/AdMobPlugin/NativeAds/NativeAdFeedSessions.swift +34 -0
- package/ios/Sources/AdMobPlugin/NativeAds/NativeAdPlacementValue.swift +50 -0
- package/ios/Sources/AdMobPlugin/NativeAds/NativeAdPluginEvents.swift +11 -0
- package/ios/Sources/AdMobPlugin/NativeAds/NativeAdScrollTracker.swift +66 -0
- package/ios/Sources/AdMobPlugin/NativeAds/NativeAdValues.swift +27 -0
- package/ios/Sources/AdMobPlugin/NativeAds/PluginNativeAdView.swift +187 -0
- package/ios/Sources/AdMobPlugin/Rewarded/AdRewardExecutor.swift +3 -0
- package/ios/Sources/AdMobPlugin/RewardedInterstitial/AdRewardInterstitialExecutor.swift +3 -0
- package/ios/Tests/AdMobPluginTests/AdMobPluginTests.swift +82 -10
- package/ios/Tests/AdMobPluginTests/NativeAdScrollTrackerTests.swift +47 -0
- package/package.json +2 -1
package/dist/plugin.js
CHANGED
|
@@ -1,6 +1,727 @@
|
|
|
1
1
|
var capacitorStripe = (function (exports, core) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
const NATIVE_AD_ELEMENT_NAME = 'capacitor-admob-native';
|
|
5
|
+
const defineNativeAdElement = (findFeed) => {
|
|
6
|
+
const runtime = globalThis;
|
|
7
|
+
runtime.__capacitorAdMobNativeFeedLookup = findFeed;
|
|
8
|
+
if (typeof customElements === 'undefined' || customElements.get(NATIVE_AD_ELEMENT_NAME)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
customElements.define(NATIVE_AD_ELEMENT_NAME, class extends HTMLElement {
|
|
12
|
+
static get observedAttributes() {
|
|
13
|
+
return ['feed-id', 'slot-key'];
|
|
14
|
+
}
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
this.connectToFeed();
|
|
17
|
+
}
|
|
18
|
+
disconnectedCallback() {
|
|
19
|
+
this.disconnectFromFeed();
|
|
20
|
+
}
|
|
21
|
+
attributeChangedCallback() {
|
|
22
|
+
if (!this.isConnected) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
this.disconnectFromFeed();
|
|
26
|
+
this.connectToFeed();
|
|
27
|
+
}
|
|
28
|
+
connectToFeed() {
|
|
29
|
+
var _a, _b, _c;
|
|
30
|
+
const feedId = (_a = this.getAttribute('feed-id')) === null || _a === void 0 ? void 0 : _a.trim();
|
|
31
|
+
const slotKey = (_b = this.getAttribute('slot-key')) === null || _b === void 0 ? void 0 : _b.trim();
|
|
32
|
+
const feed = feedId ? (_c = runtime.__capacitorAdMobNativeFeedLookup) === null || _c === void 0 ? void 0 : _c.call(runtime, feedId) : undefined;
|
|
33
|
+
if (!feed || !slotKey) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
feed.attach(slotKey, this);
|
|
38
|
+
this.attachedFeed = feed;
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
this.dispatchEvent(new CustomEvent('nativeAdError', { bubbles: true, detail: error }));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
disconnectFromFeed() {
|
|
45
|
+
var _a;
|
|
46
|
+
(_a = this.attachedFeed) === null || _a === void 0 ? void 0 : _a.detach(this);
|
|
47
|
+
this.attachedFeed = undefined;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
const connectNativeAdElements = () => {
|
|
52
|
+
document
|
|
53
|
+
.querySelectorAll(NATIVE_AD_ELEMENT_NAME)
|
|
54
|
+
.forEach((element) => { var _a, _b; return (_b = (_a = element).connectToFeed) === null || _b === void 0 ? void 0 : _b.call(_a); });
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const intersectRects = (left, right) => {
|
|
58
|
+
const x = Math.max(left.x, right.x);
|
|
59
|
+
const y = Math.max(left.y, right.y);
|
|
60
|
+
const maxX = Math.min(left.x + left.width, right.x + right.width);
|
|
61
|
+
const maxY = Math.min(left.y + left.height, right.y + right.height);
|
|
62
|
+
return {
|
|
63
|
+
x,
|
|
64
|
+
y,
|
|
65
|
+
width: Math.max(0, maxX - x),
|
|
66
|
+
height: Math.max(0, maxY - y),
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
const toNativeRect = (rect) => ({
|
|
70
|
+
x: rect.left,
|
|
71
|
+
y: rect.top,
|
|
72
|
+
width: rect.width,
|
|
73
|
+
height: rect.height,
|
|
74
|
+
});
|
|
75
|
+
const clipsDescendants = (element) => {
|
|
76
|
+
const style = window.getComputedStyle(element);
|
|
77
|
+
return [style.overflow, style.overflowX, style.overflowY].some((value) => ['auto', 'hidden', 'scroll', 'clip'].includes(value));
|
|
78
|
+
};
|
|
79
|
+
function* nativeAdAncestors(element) {
|
|
80
|
+
var _a, _b;
|
|
81
|
+
let current = element;
|
|
82
|
+
while (current) {
|
|
83
|
+
const root = current.getRootNode();
|
|
84
|
+
current =
|
|
85
|
+
(_b = (_a = current.assignedSlot) !== null && _a !== void 0 ? _a : current.parentElement) !== null && _b !== void 0 ? _b : (root instanceof ShadowRoot ? root.host : null);
|
|
86
|
+
if (current)
|
|
87
|
+
yield current;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const measureNativeAdSlot = (element, scrollElement) => {
|
|
91
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
92
|
+
const style = window.getComputedStyle(element);
|
|
93
|
+
const domRect = element.getBoundingClientRect();
|
|
94
|
+
if (!element.isConnected ||
|
|
95
|
+
style.display === 'none' ||
|
|
96
|
+
style.visibility === 'hidden' ||
|
|
97
|
+
Number.parseFloat(style.opacity || '1') === 0 ||
|
|
98
|
+
domRect.width <= 0 ||
|
|
99
|
+
domRect.height <= 0) {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
const rect = toNativeRect(domRect);
|
|
103
|
+
let clipRect = scrollElement
|
|
104
|
+
? rect
|
|
105
|
+
: {
|
|
106
|
+
x: (_b = (_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.offsetLeft) !== null && _b !== void 0 ? _b : 0,
|
|
107
|
+
y: (_d = (_c = window.visualViewport) === null || _c === void 0 ? void 0 : _c.offsetTop) !== null && _d !== void 0 ? _d : 0,
|
|
108
|
+
width: (_f = (_e = window.visualViewport) === null || _e === void 0 ? void 0 : _e.width) !== null && _f !== void 0 ? _f : window.innerWidth,
|
|
109
|
+
height: (_h = (_g = window.visualViewport) === null || _g === void 0 ? void 0 : _g.height) !== null && _h !== void 0 ? _h : window.innerHeight,
|
|
110
|
+
};
|
|
111
|
+
let foundScrollElement = !scrollElement;
|
|
112
|
+
for (const ancestor of nativeAdAncestors(element)) {
|
|
113
|
+
if (ancestor === scrollElement) {
|
|
114
|
+
foundScrollElement = true;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
if (clipsDescendants(ancestor)) {
|
|
118
|
+
clipRect = intersectRects(clipRect, toNativeRect(ancestor.getBoundingClientRect()));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
clipRect = intersectRects(rect, clipRect);
|
|
122
|
+
if (!foundScrollElement || clipRect.width <= 0 || clipRect.height <= 0)
|
|
123
|
+
return undefined;
|
|
124
|
+
if (scrollElement) {
|
|
125
|
+
const origin = scrollElement.getBoundingClientRect();
|
|
126
|
+
const translate = (value) => (Object.assign(Object.assign({}, value), { x: value.x - origin.left + scrollElement.scrollLeft, y: value.y - origin.top + scrollElement.scrollTop }));
|
|
127
|
+
return { rect: translate(rect), clipRect: translate(clipRect) };
|
|
128
|
+
}
|
|
129
|
+
return { rect, clipRect };
|
|
130
|
+
};
|
|
131
|
+
const measureNativeAdScrollContainer = (element) => {
|
|
132
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
133
|
+
const rect = toNativeRect(element.getBoundingClientRect());
|
|
134
|
+
let clipRect = intersectRects(rect, {
|
|
135
|
+
x: (_b = (_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.offsetLeft) !== null && _b !== void 0 ? _b : 0,
|
|
136
|
+
y: (_d = (_c = window.visualViewport) === null || _c === void 0 ? void 0 : _c.offsetTop) !== null && _d !== void 0 ? _d : 0,
|
|
137
|
+
width: (_f = (_e = window.visualViewport) === null || _e === void 0 ? void 0 : _e.width) !== null && _f !== void 0 ? _f : window.innerWidth,
|
|
138
|
+
height: (_h = (_g = window.visualViewport) === null || _g === void 0 ? void 0 : _g.height) !== null && _h !== void 0 ? _h : window.innerHeight,
|
|
139
|
+
});
|
|
140
|
+
for (const ancestor of nativeAdAncestors(element)) {
|
|
141
|
+
if (clipsDescendants(ancestor)) {
|
|
142
|
+
clipRect = intersectRects(clipRect, toNativeRect(ancestor.getBoundingClientRect()));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return { rect, clipRect, contentWidth: element.scrollWidth, contentHeight: element.scrollHeight };
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Layouts rendered by the native Google Mobile Ads SDK.
|
|
150
|
+
*
|
|
151
|
+
* The dimensions of a native ad slot must remain stable while it is used by a
|
|
152
|
+
* virtual scroller. `small` is intended for compact rows, while `medium`
|
|
153
|
+
* includes a larger media area.
|
|
154
|
+
*/
|
|
155
|
+
exports.NativeAdTemplate = void 0;
|
|
156
|
+
(function (NativeAdTemplate) {
|
|
157
|
+
NativeAdTemplate["Small"] = "small";
|
|
158
|
+
NativeAdTemplate["Medium"] = "medium";
|
|
159
|
+
})(exports.NativeAdTemplate || (exports.NativeAdTemplate = {}));
|
|
160
|
+
|
|
161
|
+
const SCROLL_SETTLE_MS = 120;
|
|
162
|
+
const MAX_NATIVE_ADS = 3;
|
|
163
|
+
const MAX_ACTIVE_FEEDS = 2;
|
|
164
|
+
const MIN_SMALL_SLOT_WIDTH = 120;
|
|
165
|
+
const MIN_MEDIUM_SLOT_WIDTH = 144;
|
|
166
|
+
const MIN_MEDIUM_SLOT_HEIGHT = 300;
|
|
167
|
+
const MIN_SMALL_SLOT_HEIGHT = 120;
|
|
168
|
+
const TEMPLATE_ATTRIBUTE = 'data-capacitor-admob-template';
|
|
169
|
+
const applySlotDefaults = (element, template) => {
|
|
170
|
+
const root = element.getRootNode();
|
|
171
|
+
const container = root instanceof ShadowRoot ? root : element.ownerDocument.head;
|
|
172
|
+
if (!container.querySelector('style[data-capacitor-admob-defaults]')) {
|
|
173
|
+
const style = element.ownerDocument.createElement('style');
|
|
174
|
+
style.setAttribute('data-capacitor-admob-defaults', '');
|
|
175
|
+
// Prefer the first cascade layer; older WebViews use zero-specificity rules.
|
|
176
|
+
const defaults = `
|
|
177
|
+
:where([${TEMPLATE_ATTRIBUTE}]) { display: block; height: 320px; }
|
|
178
|
+
:where([${TEMPLATE_ATTRIBUTE}="small"]) { height: 120px; }
|
|
179
|
+
`;
|
|
180
|
+
style.textContent =
|
|
181
|
+
'CSSLayerBlockRule' in globalThis ? `@layer capacitor-admob-defaults { ${defaults} }` : defaults;
|
|
182
|
+
container.prepend(style);
|
|
183
|
+
}
|
|
184
|
+
element.setAttribute(TEMPLATE_ATTRIBUTE, template);
|
|
185
|
+
};
|
|
186
|
+
let bridge;
|
|
187
|
+
let sessionSequence = 0;
|
|
188
|
+
const feeds = new Map();
|
|
189
|
+
const createSessionId = () => { var _a, _b, _c; return (_c = (_b = (_a = globalThis.crypto) === null || _a === void 0 ? void 0 : _a.randomUUID) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : `${Date.now()}-${++sessionSequence}-${Math.random().toString(36).slice(2)}`; };
|
|
190
|
+
/**
|
|
191
|
+
* Experimental manager for native-ad integration research.
|
|
192
|
+
*
|
|
193
|
+
* A stable `slotKey`, rather than the element or array index, owns the native
|
|
194
|
+
* ad lifecycle. Virtual-scroller compatibility has not yet been validated.
|
|
195
|
+
*
|
|
196
|
+
* @experimental Native overlay gesture routing is still being validated on devices.
|
|
197
|
+
*/
|
|
198
|
+
class NativeAdFeed {
|
|
199
|
+
constructor(options) {
|
|
200
|
+
var _a;
|
|
201
|
+
this.sessionId = createSessionId();
|
|
202
|
+
this.slots = new Map();
|
|
203
|
+
this.elementSlots = new Map();
|
|
204
|
+
this.scrollRoots = new Set();
|
|
205
|
+
this.destroyed = false;
|
|
206
|
+
this.nativeStarted = false;
|
|
207
|
+
this.paused = false;
|
|
208
|
+
this.layoutInvalidated = false;
|
|
209
|
+
this.lastPlacementWasDirect = false;
|
|
210
|
+
this.placementAcknowledgementRequired = false;
|
|
211
|
+
this.operationTask = Promise.resolve();
|
|
212
|
+
this.updateDirty = false;
|
|
213
|
+
this.placementSequence = 0;
|
|
214
|
+
this.listenerHandles = new Set();
|
|
215
|
+
this.handleViewportMotion = (event) => {
|
|
216
|
+
if (this.destroyed) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (!(this.nativeScrollElement &&
|
|
220
|
+
event instanceof Event &&
|
|
221
|
+
['scroll', 'touchmove', 'wheel'].includes(event.type))) {
|
|
222
|
+
this.schedulePlacementUpdate();
|
|
223
|
+
}
|
|
224
|
+
this.scheduleEvaluation();
|
|
225
|
+
};
|
|
226
|
+
this.handleVisibilityChange = () => {
|
|
227
|
+
if (this.destroyed) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
if (document.hidden) {
|
|
231
|
+
this.layoutInvalidated = true;
|
|
232
|
+
void this.requestPlacementUpdate();
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
this.scheduleEvaluation();
|
|
236
|
+
};
|
|
237
|
+
const id = options.feedId.trim();
|
|
238
|
+
if (!id) {
|
|
239
|
+
throw new Error('Native ad feed id must not be empty');
|
|
240
|
+
}
|
|
241
|
+
if (feeds.has(id)) {
|
|
242
|
+
throw new Error(`Native ad feed id already exists: ${id}`);
|
|
243
|
+
}
|
|
244
|
+
if (feeds.size >= MAX_ACTIVE_FEEDS) {
|
|
245
|
+
throw new Error(`At most ${MAX_ACTIVE_FEEDS} native ad feeds can be active`);
|
|
246
|
+
}
|
|
247
|
+
this.options = Object.assign(Object.assign({}, options), { feedId: id });
|
|
248
|
+
this.nativeScrollElement = core.Capacitor.getPlatform() === 'ios' ? options.scrollElement : undefined;
|
|
249
|
+
if (typeof IntersectionObserver !== 'undefined') {
|
|
250
|
+
this.intersectionObserver = new IntersectionObserver((entries) => {
|
|
251
|
+
for (const entry of entries) {
|
|
252
|
+
const slotKey = this.elementSlots.get(entry.target);
|
|
253
|
+
const state = slotKey ? this.slots.get(slotKey) : undefined;
|
|
254
|
+
if (state) {
|
|
255
|
+
state.intersecting = entry.isIntersecting;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
this.schedulePlacementUpdate();
|
|
259
|
+
this.scheduleEvaluation();
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
263
|
+
this.resizeObserver = new ResizeObserver(this.handleViewportMotion);
|
|
264
|
+
if (this.nativeScrollElement)
|
|
265
|
+
this.resizeObserver.observe(this.nativeScrollElement);
|
|
266
|
+
}
|
|
267
|
+
document.addEventListener('scroll', this.handleViewportMotion, true);
|
|
268
|
+
document.addEventListener('touchmove', this.handleViewportMotion, { capture: true, passive: true });
|
|
269
|
+
document.addEventListener('wheel', this.handleViewportMotion, { capture: true, passive: true });
|
|
270
|
+
window.addEventListener('resize', this.handleViewportMotion, { passive: true });
|
|
271
|
+
(_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.addEventListener('resize', this.handleViewportMotion, { passive: true });
|
|
272
|
+
document.addEventListener('visibilitychange', this.handleVisibilityChange);
|
|
273
|
+
document.addEventListener('load', this.handleViewportMotion, true);
|
|
274
|
+
feeds.set(id, this);
|
|
275
|
+
}
|
|
276
|
+
static async create(options) {
|
|
277
|
+
var _a;
|
|
278
|
+
if (!bridge) {
|
|
279
|
+
throw new Error('AdMob native ad bridge is not configured');
|
|
280
|
+
}
|
|
281
|
+
if (typeof document === 'undefined' || typeof window === 'undefined') {
|
|
282
|
+
throw new Error('NativeAdFeed can only be created in a browser environment');
|
|
283
|
+
}
|
|
284
|
+
if (options.isTesting !== true && !((_a = options.adId) === null || _a === void 0 ? void 0 : _a.trim())) {
|
|
285
|
+
throw new Error('adId is required unless isTesting is true');
|
|
286
|
+
}
|
|
287
|
+
const feed = new NativeAdFeed(options);
|
|
288
|
+
try {
|
|
289
|
+
await bridge.startNativeAdFeed({ feedId: feed.feedId, sessionId: feed.sessionId });
|
|
290
|
+
feed.nativeStarted = true;
|
|
291
|
+
defineNativeAdElement((feedId) => feeds.get(feedId));
|
|
292
|
+
connectNativeAdElements();
|
|
293
|
+
return feed;
|
|
294
|
+
}
|
|
295
|
+
catch (error) {
|
|
296
|
+
await feed.destroy();
|
|
297
|
+
throw error;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
get feedId() {
|
|
301
|
+
return this.options.feedId;
|
|
302
|
+
}
|
|
303
|
+
async addListener(eventName, listener) {
|
|
304
|
+
this.assertActive();
|
|
305
|
+
if (!bridge) {
|
|
306
|
+
throw new Error('AdMob native ad bridge is not configured');
|
|
307
|
+
}
|
|
308
|
+
const nativeHandle = await bridge.addListener(eventName, (event) => {
|
|
309
|
+
if (event.feedId === this.options.feedId && event.sessionId === this.sessionId) {
|
|
310
|
+
const filteredListener = listener;
|
|
311
|
+
filteredListener(event);
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
if (this.destroyed) {
|
|
315
|
+
await nativeHandle.remove();
|
|
316
|
+
this.assertActive();
|
|
317
|
+
}
|
|
318
|
+
let removed = false;
|
|
319
|
+
const handle = {
|
|
320
|
+
remove: async () => {
|
|
321
|
+
if (removed) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
removed = true;
|
|
325
|
+
this.listenerHandles.delete(handle);
|
|
326
|
+
await nativeHandle.remove();
|
|
327
|
+
},
|
|
328
|
+
};
|
|
329
|
+
this.listenerHandles.add(handle);
|
|
330
|
+
return handle;
|
|
331
|
+
}
|
|
332
|
+
attach(slotKey, element) {
|
|
333
|
+
var _a, _b, _c;
|
|
334
|
+
this.assertActive();
|
|
335
|
+
const normalizedKey = slotKey.trim();
|
|
336
|
+
if (!normalizedKey) {
|
|
337
|
+
throw new Error('Native ad slotKey must not be empty');
|
|
338
|
+
}
|
|
339
|
+
const previousKey = this.elementSlots.get(element);
|
|
340
|
+
if (previousKey === normalizedKey) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
if (previousKey && previousKey !== normalizedKey) {
|
|
344
|
+
this.detach(element);
|
|
345
|
+
}
|
|
346
|
+
const existing = this.slots.get(normalizedKey);
|
|
347
|
+
if ((existing === null || existing === void 0 ? void 0 : existing.element) && existing.element !== element) {
|
|
348
|
+
throw new Error(`Native ad slotKey is already attached: ${normalizedKey}`);
|
|
349
|
+
}
|
|
350
|
+
const state = existing !== null && existing !== void 0 ? existing : {
|
|
351
|
+
slotKey: normalizedKey,
|
|
352
|
+
generation: 0,
|
|
353
|
+
intersecting: !this.intersectionObserver,
|
|
354
|
+
status: 'idle',
|
|
355
|
+
lastUsed: Date.now(),
|
|
356
|
+
loadVersion: 0,
|
|
357
|
+
};
|
|
358
|
+
applySlotDefaults(element, (_a = this.options.template) !== null && _a !== void 0 ? _a : exports.NativeAdTemplate.Medium);
|
|
359
|
+
state.element = element;
|
|
360
|
+
state.generation += 1;
|
|
361
|
+
state.lastUsed = Date.now();
|
|
362
|
+
this.slots.set(normalizedKey, state);
|
|
363
|
+
this.elementSlots.set(element, normalizedKey);
|
|
364
|
+
this.updateScrollRoots();
|
|
365
|
+
(_b = this.intersectionObserver) === null || _b === void 0 ? void 0 : _b.observe(element);
|
|
366
|
+
(_c = this.resizeObserver) === null || _c === void 0 ? void 0 : _c.observe(element);
|
|
367
|
+
this.scheduleEvaluation();
|
|
368
|
+
}
|
|
369
|
+
detach(element) {
|
|
370
|
+
var _a, _b;
|
|
371
|
+
const slotKey = this.elementSlots.get(element);
|
|
372
|
+
if (!slotKey) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
const state = this.slots.get(slotKey);
|
|
376
|
+
if ((state === null || state === void 0 ? void 0 : state.element) === element) {
|
|
377
|
+
state.element = undefined;
|
|
378
|
+
state.intersecting = false;
|
|
379
|
+
state.generation += 1;
|
|
380
|
+
state.lastUsed = Date.now();
|
|
381
|
+
}
|
|
382
|
+
(_a = this.intersectionObserver) === null || _a === void 0 ? void 0 : _a.unobserve(element);
|
|
383
|
+
(_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.unobserve(element);
|
|
384
|
+
this.elementSlots.delete(element);
|
|
385
|
+
this.updateScrollRoots();
|
|
386
|
+
void this.requestPlacementUpdate();
|
|
387
|
+
this.scheduleEvaluation();
|
|
388
|
+
}
|
|
389
|
+
async reload(slotKey) {
|
|
390
|
+
this.assertActive();
|
|
391
|
+
const normalizedKey = slotKey.trim();
|
|
392
|
+
const state = this.slots.get(normalizedKey);
|
|
393
|
+
if (!state) {
|
|
394
|
+
throw new Error(`Native ad slotKey is not registered: ${normalizedKey}`);
|
|
395
|
+
}
|
|
396
|
+
await this.runOperation(async () => {
|
|
397
|
+
await this.removeStateAd(state);
|
|
398
|
+
const protectedStates = new Set(this.getVisibleStates());
|
|
399
|
+
protectedStates.add(state);
|
|
400
|
+
await this.evictUnusedAds(protectedStates);
|
|
401
|
+
if ([...this.slots.values()].filter((slot) => this.occupiesNativeAd(slot)).length >= MAX_NATIVE_ADS) {
|
|
402
|
+
throw new Error('Native ad capacity is currently in use by visible slots');
|
|
403
|
+
}
|
|
404
|
+
await this.loadState(state);
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
/** Immediately hides this feed's overlays until {@link resume} is called. */
|
|
408
|
+
async pause() {
|
|
409
|
+
this.assertActive();
|
|
410
|
+
this.paused = true;
|
|
411
|
+
this.layoutInvalidated = true;
|
|
412
|
+
if (!(await this.requestPlacementUpdate())) {
|
|
413
|
+
throw new Error('Failed to hide native ad placements');
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
/** Re-evaluates slots and restores eligible overlays after the viewport settles. */
|
|
417
|
+
resume() {
|
|
418
|
+
this.assertActive();
|
|
419
|
+
this.paused = false;
|
|
420
|
+
this.scheduleEvaluation();
|
|
421
|
+
}
|
|
422
|
+
/** Hides stale overlays and remeasures after an application-driven layout change. */
|
|
423
|
+
async invalidateLayout() {
|
|
424
|
+
this.assertActive();
|
|
425
|
+
this.layoutInvalidated = true;
|
|
426
|
+
this.scheduleEvaluation();
|
|
427
|
+
if (!(await this.requestPlacementUpdate())) {
|
|
428
|
+
throw new Error('Failed to hide native ad placements');
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
async destroy() {
|
|
432
|
+
var _a, _b, _c;
|
|
433
|
+
if (!this.destroyed) {
|
|
434
|
+
this.destroyed = true;
|
|
435
|
+
feeds.delete(this.options.feedId);
|
|
436
|
+
document.removeEventListener('scroll', this.handleViewportMotion, true);
|
|
437
|
+
for (const root of this.scrollRoots) {
|
|
438
|
+
root.removeEventListener('scroll', this.handleViewportMotion, true);
|
|
439
|
+
}
|
|
440
|
+
this.scrollRoots.clear();
|
|
441
|
+
document.removeEventListener('touchmove', this.handleViewportMotion, true);
|
|
442
|
+
document.removeEventListener('wheel', this.handleViewportMotion, true);
|
|
443
|
+
window.removeEventListener('resize', this.handleViewportMotion);
|
|
444
|
+
(_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.removeEventListener('resize', this.handleViewportMotion);
|
|
445
|
+
document.removeEventListener('visibilitychange', this.handleVisibilityChange);
|
|
446
|
+
document.removeEventListener('load', this.handleViewportMotion, true);
|
|
447
|
+
if (this.settleTimer) {
|
|
448
|
+
clearTimeout(this.settleTimer);
|
|
449
|
+
}
|
|
450
|
+
if (this.placementFrame !== undefined) {
|
|
451
|
+
cancelAnimationFrame(this.placementFrame);
|
|
452
|
+
this.placementFrame = undefined;
|
|
453
|
+
}
|
|
454
|
+
(_b = this.intersectionObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
|
|
455
|
+
(_c = this.resizeObserver) === null || _c === void 0 ? void 0 : _c.disconnect();
|
|
456
|
+
}
|
|
457
|
+
if (this.destroyTask) {
|
|
458
|
+
return this.destroyTask;
|
|
459
|
+
}
|
|
460
|
+
this.destroyTask = this.destroyResources();
|
|
461
|
+
try {
|
|
462
|
+
await this.destroyTask;
|
|
463
|
+
}
|
|
464
|
+
finally {
|
|
465
|
+
this.destroyTask = undefined;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
schedulePlacementUpdate() {
|
|
469
|
+
if (this.destroyed || this.placementFrame !== undefined) {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
this.placementFrame = requestAnimationFrame(() => {
|
|
473
|
+
this.placementFrame = undefined;
|
|
474
|
+
void this.requestPlacementUpdate(true);
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
updateScrollRoots() {
|
|
478
|
+
const roots = new Set();
|
|
479
|
+
for (const element of this.elementSlots.keys()) {
|
|
480
|
+
for (const ancestor of [element, ...nativeAdAncestors(element)]) {
|
|
481
|
+
const root = ancestor.getRootNode();
|
|
482
|
+
if (root instanceof ShadowRoot)
|
|
483
|
+
roots.add(root);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
for (const root of this.scrollRoots) {
|
|
487
|
+
if (!roots.has(root)) {
|
|
488
|
+
root.removeEventListener('scroll', this.handleViewportMotion, true);
|
|
489
|
+
this.scrollRoots.delete(root);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
for (const root of roots) {
|
|
493
|
+
if (!this.scrollRoots.has(root)) {
|
|
494
|
+
// Element scroll events do not cross a shadow boundary.
|
|
495
|
+
root.addEventListener('scroll', this.handleViewportMotion, true);
|
|
496
|
+
this.scrollRoots.add(root);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
scheduleEvaluation() {
|
|
501
|
+
if (this.destroyed) {
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
if (this.settleTimer) {
|
|
505
|
+
clearTimeout(this.settleTimer);
|
|
506
|
+
}
|
|
507
|
+
this.settleTimer = setTimeout(() => {
|
|
508
|
+
this.layoutInvalidated = false;
|
|
509
|
+
void this.runOperation(() => this.evaluate());
|
|
510
|
+
}, SCROLL_SETTLE_MS);
|
|
511
|
+
}
|
|
512
|
+
async evaluate() {
|
|
513
|
+
if (this.destroyed || this.paused || document.hidden) {
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
const visibleStates = this.getVisibleStates();
|
|
517
|
+
for (const state of visibleStates) {
|
|
518
|
+
state.lastUsed = Date.now();
|
|
519
|
+
}
|
|
520
|
+
await this.evictUnusedAds(new Set(visibleStates));
|
|
521
|
+
const occupied = [...this.slots.values()].filter((state) => this.occupiesNativeAd(state)).length;
|
|
522
|
+
const loadable = visibleStates
|
|
523
|
+
.filter((state) => state.status === 'idle')
|
|
524
|
+
.slice(0, Math.max(0, MAX_NATIVE_ADS - occupied));
|
|
525
|
+
await Promise.allSettled(loadable.map((state) => this.loadState(state)));
|
|
526
|
+
void this.requestPlacementUpdate();
|
|
527
|
+
}
|
|
528
|
+
async loadState(state) {
|
|
529
|
+
var _a;
|
|
530
|
+
if (state.status !== 'idle' || !bridge) {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
state.status = 'loading';
|
|
534
|
+
const loadVersion = ++state.loadVersion;
|
|
535
|
+
try {
|
|
536
|
+
await bridge.loadNativeAd({
|
|
537
|
+
feedId: this.options.feedId,
|
|
538
|
+
sessionId: this.sessionId,
|
|
539
|
+
slotKey: state.slotKey,
|
|
540
|
+
template: (_a = this.options.template) !== null && _a !== void 0 ? _a : exports.NativeAdTemplate.Medium,
|
|
541
|
+
style: this.options.style,
|
|
542
|
+
adId: this.options.adId,
|
|
543
|
+
isTesting: this.options.isTesting,
|
|
544
|
+
npa: this.options.npa,
|
|
545
|
+
});
|
|
546
|
+
if (state.loadVersion === loadVersion) {
|
|
547
|
+
state.status = 'loaded';
|
|
548
|
+
state.lastUsed = Date.now();
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
catch (error) {
|
|
552
|
+
if (state.loadVersion === loadVersion) {
|
|
553
|
+
state.status = 'failed';
|
|
554
|
+
}
|
|
555
|
+
throw error;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
async evictUnusedAds(visibleStates) {
|
|
559
|
+
const occupied = [...this.slots.values()].filter((state) => this.occupiesNativeAd(state));
|
|
560
|
+
const requestedLoads = [...visibleStates].filter((state) => state.status === 'idle').length;
|
|
561
|
+
const evictionCount = Math.max(0, occupied.length + Math.min(requestedLoads, MAX_NATIVE_ADS) - MAX_NATIVE_ADS);
|
|
562
|
+
const evicted = occupied
|
|
563
|
+
.filter((state) => !visibleStates.has(state))
|
|
564
|
+
.sort((left, right) => left.lastUsed - right.lastUsed)
|
|
565
|
+
.slice(0, evictionCount);
|
|
566
|
+
await Promise.allSettled(evicted.map((state) => this.removeStateAd(state)));
|
|
567
|
+
const detached = [...this.slots.values()]
|
|
568
|
+
.filter((state) => !state.element && !this.occupiesNativeAd(state))
|
|
569
|
+
.sort((left, right) => right.lastUsed - left.lastUsed);
|
|
570
|
+
for (const state of detached.slice(MAX_NATIVE_ADS)) {
|
|
571
|
+
this.slots.delete(state.slotKey);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
occupiesNativeAd(state) {
|
|
575
|
+
return ['loading', 'loaded', 'removing', 'removeFailed'].includes(state.status);
|
|
576
|
+
}
|
|
577
|
+
getVisibleStates() {
|
|
578
|
+
return [...this.slots.values()].filter((state) => {
|
|
579
|
+
const measured = state.element && state.intersecting ? measureNativeAdSlot(state.element) : undefined;
|
|
580
|
+
return Boolean(measured && this.isSupportedSize(measured));
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
isSupportedSize(measured) {
|
|
584
|
+
var _a, _b;
|
|
585
|
+
const minimumHeight = ((_a = this.options.template) !== null && _a !== void 0 ? _a : exports.NativeAdTemplate.Medium) === exports.NativeAdTemplate.Small
|
|
586
|
+
? MIN_SMALL_SLOT_HEIGHT
|
|
587
|
+
: MIN_MEDIUM_SLOT_HEIGHT;
|
|
588
|
+
const minimumWidth = ((_b = this.options.template) !== null && _b !== void 0 ? _b : exports.NativeAdTemplate.Medium) === exports.NativeAdTemplate.Small
|
|
589
|
+
? MIN_SMALL_SLOT_WIDTH
|
|
590
|
+
: MIN_MEDIUM_SLOT_WIDTH;
|
|
591
|
+
return measured.rect.width >= minimumWidth && measured.rect.height >= minimumHeight;
|
|
592
|
+
}
|
|
593
|
+
async removeStateAd(state) {
|
|
594
|
+
if (state.status === 'removing') {
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
if (!bridge || state.status === 'idle' || state.status === 'failed') {
|
|
598
|
+
state.status = 'idle';
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
state.status = 'removing';
|
|
602
|
+
const removeVersion = ++state.loadVersion;
|
|
603
|
+
await this.requestPlacementUpdate();
|
|
604
|
+
try {
|
|
605
|
+
await bridge.removeNativeAd({
|
|
606
|
+
feedId: this.options.feedId,
|
|
607
|
+
sessionId: this.sessionId,
|
|
608
|
+
slotKey: state.slotKey,
|
|
609
|
+
});
|
|
610
|
+
if (state.loadVersion === removeVersion) {
|
|
611
|
+
state.status = 'idle';
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
catch (error) {
|
|
615
|
+
if (state.loadVersion === removeVersion) {
|
|
616
|
+
state.status = 'removeFailed';
|
|
617
|
+
}
|
|
618
|
+
throw error;
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
runOperation(operation) {
|
|
622
|
+
const result = this.operationTask.then(operation);
|
|
623
|
+
this.operationTask = result.catch(() => undefined);
|
|
624
|
+
return result;
|
|
625
|
+
}
|
|
626
|
+
async destroyResources() {
|
|
627
|
+
await Promise.all([
|
|
628
|
+
...[...this.listenerHandles].map((handle) => handle.remove()),
|
|
629
|
+
...(this.nativeStarted && bridge
|
|
630
|
+
? [bridge.destroyNativeAdFeed({ feedId: this.options.feedId, sessionId: this.sessionId })]
|
|
631
|
+
: []),
|
|
632
|
+
]);
|
|
633
|
+
this.nativeStarted = false;
|
|
634
|
+
this.listenerHandles.clear();
|
|
635
|
+
this.slots.clear();
|
|
636
|
+
this.elementSlots.clear();
|
|
637
|
+
}
|
|
638
|
+
requestPlacementUpdate(allowDirect = false) {
|
|
639
|
+
this.updateDirty = true;
|
|
640
|
+
this.placementAcknowledgementRequired || (this.placementAcknowledgementRequired = !allowDirect);
|
|
641
|
+
if (!this.placementUpdateTask) {
|
|
642
|
+
this.placementUpdateTask = Promise.resolve().then(() => this.flushPlacementUpdates());
|
|
643
|
+
}
|
|
644
|
+
return this.placementUpdateTask;
|
|
645
|
+
}
|
|
646
|
+
async flushPlacementUpdates() {
|
|
647
|
+
if (!bridge || this.destroyed) {
|
|
648
|
+
return true;
|
|
649
|
+
}
|
|
650
|
+
try {
|
|
651
|
+
while (this.updateDirty && !this.destroyed) {
|
|
652
|
+
this.updateDirty = false;
|
|
653
|
+
const allowDirect = !this.placementAcknowledgementRequired;
|
|
654
|
+
this.placementAcknowledgementRequired = false;
|
|
655
|
+
const placements = [...this.slots.values()]
|
|
656
|
+
.filter((state) => state.status === 'loaded')
|
|
657
|
+
.map((state) => {
|
|
658
|
+
const measured = state.element ? measureNativeAdSlot(state.element, this.nativeScrollElement) : undefined;
|
|
659
|
+
const visible = Boolean(!this.paused && !this.layoutInvalidated && measured && this.isSupportedSize(measured) && !document.hidden);
|
|
660
|
+
return {
|
|
661
|
+
feedId: this.options.feedId,
|
|
662
|
+
slotKey: state.slotKey,
|
|
663
|
+
generation: state.generation,
|
|
664
|
+
visible,
|
|
665
|
+
rect: measured === null || measured === void 0 ? void 0 : measured.rect,
|
|
666
|
+
clipRect: measured === null || measured === void 0 ? void 0 : measured.clipRect,
|
|
667
|
+
};
|
|
668
|
+
});
|
|
669
|
+
const scrollContainer = this.nativeScrollElement
|
|
670
|
+
? measureNativeAdScrollContainer(this.nativeScrollElement)
|
|
671
|
+
: undefined;
|
|
672
|
+
const serializedPlacements = JSON.stringify({ placements, scrollContainer });
|
|
673
|
+
if (serializedPlacements === this.lastPlacements && (allowDirect || !this.lastPlacementWasDirect)) {
|
|
674
|
+
continue;
|
|
675
|
+
}
|
|
676
|
+
try {
|
|
677
|
+
const batch = Object.assign({ feedId: this.options.feedId, sessionId: this.sessionId, sequence: ++this.placementSequence, placements }, (scrollContainer ? { scrollContainer } : {}));
|
|
678
|
+
const channel = core.Capacitor.getPlatform() === 'android'
|
|
679
|
+
? window
|
|
680
|
+
.capacitorAdMobPlacements
|
|
681
|
+
: undefined;
|
|
682
|
+
let sentDirectly = false;
|
|
683
|
+
if (allowDirect && channel) {
|
|
684
|
+
try {
|
|
685
|
+
channel.postMessage(JSON.stringify(batch));
|
|
686
|
+
sentDirectly = true;
|
|
687
|
+
}
|
|
688
|
+
catch (_a) {
|
|
689
|
+
// Keep the acknowledged bridge available if the direct channel fails.
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
if (!sentDirectly)
|
|
693
|
+
await bridge.updateNativeAdPlacements(batch);
|
|
694
|
+
this.lastPlacementWasDirect = sentDirectly;
|
|
695
|
+
this.lastPlacements = serializedPlacements;
|
|
696
|
+
}
|
|
697
|
+
catch (_b) {
|
|
698
|
+
this.lastPlacements = undefined;
|
|
699
|
+
// Retry on the next scroll, resize, or lifecycle update without
|
|
700
|
+
// creating an unhandled rejection from this fire-and-forget task.
|
|
701
|
+
this.updateDirty = true;
|
|
702
|
+
return false;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
return true;
|
|
706
|
+
}
|
|
707
|
+
catch (_c) {
|
|
708
|
+
this.updateDirty = true;
|
|
709
|
+
return false;
|
|
710
|
+
}
|
|
711
|
+
finally {
|
|
712
|
+
this.placementUpdateTask = undefined;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
assertActive() {
|
|
716
|
+
if (this.destroyed) {
|
|
717
|
+
throw new Error(`Native ad feed has been destroyed: ${this.options.feedId}`);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
const configureNativeAdBridge = (adMobBridge) => {
|
|
722
|
+
bridge = adMobBridge;
|
|
723
|
+
};
|
|
724
|
+
|
|
4
725
|
exports.MaxAdContentRating = void 0;
|
|
5
726
|
(function (MaxAdContentRating) {
|
|
6
727
|
/**
|
|
@@ -329,9 +1050,22 @@ var capacitorStripe = (function (exports, core) {
|
|
|
329
1050
|
AppOpenAdPluginEvents["AdImpression"] = "appOpenAdImpression";
|
|
330
1051
|
})(exports.AppOpenAdPluginEvents || (exports.AppOpenAdPluginEvents = {}));
|
|
331
1052
|
|
|
332
|
-
|
|
1053
|
+
exports.NativeAdPluginEvents = void 0;
|
|
1054
|
+
(function (NativeAdPluginEvents) {
|
|
1055
|
+
NativeAdPluginEvents["Loaded"] = "nativeAdLoaded";
|
|
1056
|
+
NativeAdPluginEvents["FailedToLoad"] = "nativeAdFailedToLoad";
|
|
1057
|
+
NativeAdPluginEvents["Clicked"] = "nativeAdClicked";
|
|
1058
|
+
NativeAdPluginEvents["AdImpression"] = "nativeAdImpression";
|
|
1059
|
+
NativeAdPluginEvents["Opened"] = "nativeAdOpened";
|
|
1060
|
+
NativeAdPluginEvents["Closed"] = "nativeAdClosed";
|
|
1061
|
+
NativeAdPluginEvents["AdPaid"] = "nativeAdPaid";
|
|
1062
|
+
})(exports.NativeAdPluginEvents || (exports.NativeAdPluginEvents = {}));
|
|
1063
|
+
|
|
1064
|
+
const nativeAdBridge = core.registerPlugin('AdMob', {
|
|
333
1065
|
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.AdMobWeb()),
|
|
334
1066
|
});
|
|
1067
|
+
const AdMob = nativeAdBridge;
|
|
1068
|
+
configureNativeAdBridge(nativeAdBridge);
|
|
335
1069
|
|
|
336
1070
|
/**
|
|
337
1071
|
* For more information:
|
|
@@ -407,6 +1141,21 @@ var capacitorStripe = (function (exports, core) {
|
|
|
407
1141
|
async removeBanner() {
|
|
408
1142
|
console.log('removeBanner');
|
|
409
1143
|
}
|
|
1144
|
+
async startNativeAdFeed() {
|
|
1145
|
+
throw new Error('Native ads are only available on iOS and Android');
|
|
1146
|
+
}
|
|
1147
|
+
async destroyNativeAdFeed(options) {
|
|
1148
|
+
console.log('destroyNativeAdFeed', options);
|
|
1149
|
+
}
|
|
1150
|
+
async loadNativeAd() {
|
|
1151
|
+
throw new Error('Native ads are only available on iOS and Android');
|
|
1152
|
+
}
|
|
1153
|
+
async updateNativeAdPlacements(options) {
|
|
1154
|
+
console.log('updateNativeAdPlacements', options);
|
|
1155
|
+
}
|
|
1156
|
+
async removeNativeAd(options) {
|
|
1157
|
+
console.log('removeNativeAd', options);
|
|
1158
|
+
}
|
|
410
1159
|
async prepareInterstitial(options) {
|
|
411
1160
|
console.log('prepareInterstitial', options);
|
|
412
1161
|
return {
|
|
@@ -466,6 +1215,7 @@ var capacitorStripe = (function (exports, core) {
|
|
|
466
1215
|
});
|
|
467
1216
|
|
|
468
1217
|
exports.AdMob = AdMob;
|
|
1218
|
+
exports.NativeAdFeed = NativeAdFeed;
|
|
469
1219
|
|
|
470
1220
|
return exports;
|
|
471
1221
|
|