@brndts/brndts-ads 1.10.4 → 1.11.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/dist/index.js +216 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +217 -41
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -69413,13 +69413,63 @@ var AffiliateProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
69413
69413
|
},
|
69414
69414
|
{
|
69415
69415
|
key: "getAffiliate",
|
69416
|
-
value: function getAffiliate(regionId, size) {
|
69416
|
+
value: function getAffiliate(regionId, size, adType, regionName) {
|
69417
69417
|
var _this = this;
|
69418
69418
|
if (!regionId) {
|
69419
|
+
if (adType && regionName) {
|
69420
|
+
var sizes = ContentProvider.adSizes[adType];
|
69421
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
69422
|
+
try {
|
69423
|
+
var _this1, _loop = function() {
|
69424
|
+
var _step_value = _sliced_to_array(_step.value, 2), width = _step_value[0], height = _step_value[1];
|
69425
|
+
var identifier = "".concat(width, "x").concat(height);
|
69426
|
+
var aff2 = _this1.manifest.filter(function(a) {
|
69427
|
+
return a.size.w === width && a.size.h === height;
|
69428
|
+
});
|
69429
|
+
if (!aff2.length) {
|
69430
|
+
return "continue";
|
69431
|
+
}
|
69432
|
+
if (!_this1.useByRegion[identifier]) {
|
69433
|
+
_this1.useByRegion[identifier] = /* @__PURE__ */ new Set();
|
69434
|
+
}
|
69435
|
+
if (_this1.useByRegion[identifier].size === aff2.length) {
|
69436
|
+
_this1.useByRegion[identifier].clear();
|
69437
|
+
}
|
69438
|
+
var unused2 = aff2.filter(function(a) {
|
69439
|
+
return !_this.useByRegion[identifier].has(a.id);
|
69440
|
+
});
|
69441
|
+
if (unused2.length) {
|
69442
|
+
var randomIndex2 = Math.floor(Math.random() * unused2.length);
|
69443
|
+
var selected = unused2[randomIndex2];
|
69444
|
+
_this1.useByRegion[identifier].add(selected.id);
|
69445
|
+
return {
|
69446
|
+
v: selected
|
69447
|
+
};
|
69448
|
+
}
|
69449
|
+
};
|
69450
|
+
for(var _iterator = sizes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
69451
|
+
var _ret = (_this1 = this, _loop());
|
69452
|
+
if (_type_of(_ret) === "object") return _ret.v;
|
69453
|
+
}
|
69454
|
+
} catch (err) {
|
69455
|
+
_didIteratorError = true;
|
69456
|
+
_iteratorError = err;
|
69457
|
+
} finally{
|
69458
|
+
try {
|
69459
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
69460
|
+
_iterator.return();
|
69461
|
+
}
|
69462
|
+
} finally{
|
69463
|
+
if (_didIteratorError) {
|
69464
|
+
throw _iteratorError;
|
69465
|
+
}
|
69466
|
+
}
|
69467
|
+
}
|
69468
|
+
}
|
69419
69469
|
if ((size === null || size === void 0 ? void 0 : size.width) && (size === null || size === void 0 ? void 0 : size.height)) {
|
69420
69470
|
var identifier = "".concat(size.width, "x").concat(size.height);
|
69421
69471
|
var aff2 = this.manifest.filter(function(a) {
|
69422
|
-
return a.size.w === size.width && a.size.h === size.height;
|
69472
|
+
return a.size.w === (size === null || size === void 0 ? void 0 : size.width) && a.size.h === size.height;
|
69423
69473
|
});
|
69424
69474
|
if (!aff2.length) {
|
69425
69475
|
return null;
|
@@ -69474,7 +69524,10 @@ var AffiliateProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
69474
69524
|
case 1:
|
69475
69525
|
_state.sent();
|
69476
69526
|
affiliate = null;
|
69477
|
-
if (params.params.
|
69527
|
+
if (!affiliate && params.params.adType && params.params.regionName) {
|
69528
|
+
affiliate = this.getAffiliate(void 0, params.size, params.params.adType, params.params.regionName);
|
69529
|
+
}
|
69530
|
+
if (!affiliate && params.params.useRatio) {
|
69478
69531
|
regionInfo = ContentProvider.approxRegionByRatio(params.size.width, params.size.height);
|
69479
69532
|
if (regionInfo) {
|
69480
69533
|
affiliate = this.getAffiliate("".concat(regionInfo.id), {
|
@@ -69729,15 +69782,22 @@ var PrebidJS = /*#__PURE__*/ function() {
|
|
69729
69782
|
},
|
69730
69783
|
{
|
69731
69784
|
key: "defineSlot",
|
69732
|
-
value: function defineSlot(options, slotId, containerId) {
|
69785
|
+
value: function defineSlot(options, slotId, containerId, adType) {
|
69733
69786
|
var _window_pbjs;
|
69734
69787
|
var unitDefinition = options.units.find(function(unit) {
|
69735
69788
|
return unit.code === "".concat(slotId);
|
69736
69789
|
});
|
69790
|
+
var sizes = [];
|
69737
69791
|
if (!unitDefinition) {
|
69738
69792
|
console.error("No unit definition found for slotId: ".concat(slotId));
|
69739
69793
|
return;
|
69740
69794
|
}
|
69795
|
+
if (adType) {
|
69796
|
+
sizes = ContentProvider.adSizes[adType];
|
69797
|
+
} else {
|
69798
|
+
var _unitDefinition_mediaTypes_banner;
|
69799
|
+
sizes = ((_unitDefinition_mediaTypes_banner = unitDefinition.mediaTypes.banner) === null || _unitDefinition_mediaTypes_banner === void 0 ? void 0 : _unitDefinition_mediaTypes_banner.sizes) || [];
|
69800
|
+
}
|
69741
69801
|
if (!((_window_pbjs = window.pbjs) === null || _window_pbjs === void 0 ? void 0 : _window_pbjs.adUnits.some(function(defUnit) {
|
69742
69802
|
return containerId === defUnit.code;
|
69743
69803
|
}))) {
|
@@ -69747,6 +69807,11 @@ var PrebidJS = /*#__PURE__*/ function() {
|
|
69747
69807
|
if ((_window_pbjs = window.pbjs) === null || _window_pbjs === void 0 ? void 0 : _window_pbjs.addAdUnits) {
|
69748
69808
|
window.pbjs.addAdUnits([
|
69749
69809
|
_object_spread_props(_object_spread({}, unitDefinition), {
|
69810
|
+
mediaTypes: _object_spread_props(_object_spread({}, unitDefinition.mediaTypes || {}), {
|
69811
|
+
banner: _object_spread_props(_object_spread({}, unitDefinition.mediaTypes.banner || {}), {
|
69812
|
+
sizes: sizes
|
69813
|
+
})
|
69814
|
+
}),
|
69750
69815
|
code: containerId
|
69751
69816
|
})
|
69752
69817
|
]);
|
@@ -69915,7 +69980,7 @@ var PrebidjsProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
69915
69980
|
key: "request",
|
69916
69981
|
value: function request(params) {
|
69917
69982
|
return _async_to_generator(function() {
|
69918
|
-
var _this, regionId, regionInfo, regionInfo1;
|
69983
|
+
var _this, adType, regionId, regionInfo, regionInfo1;
|
69919
69984
|
return _ts_generator(this, function(_state) {
|
69920
69985
|
switch(_state.label){
|
69921
69986
|
case 0:
|
@@ -69926,6 +69991,7 @@ var PrebidjsProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
69926
69991
|
];
|
69927
69992
|
case 1:
|
69928
69993
|
_state.sent();
|
69994
|
+
adType = params.params.adType;
|
69929
69995
|
regionId = params.params.regionId;
|
69930
69996
|
if (params.params.useRatio) {
|
69931
69997
|
regionInfo = ContentProvider.approxRegionByRatio(params.size.width, params.size.height);
|
@@ -69950,7 +70016,7 @@ var PrebidjsProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
69950
70016
|
];
|
69951
70017
|
case 2:
|
69952
70018
|
_state.sent();
|
69953
|
-
PrebidJS.defineSlot(this.options, regionId, params.params.regionId);
|
70019
|
+
PrebidJS.defineSlot(this.options, regionId, params.params.regionId, adType);
|
69954
70020
|
PrebidJS.request(regionId, params.params.regionId, function(bids) {
|
69955
70021
|
return _this.processBids(params, bids);
|
69956
70022
|
});
|
@@ -70224,18 +70290,25 @@ var PrebidGAM = /*#__PURE__*/ function() {
|
|
70224
70290
|
},
|
70225
70291
|
{
|
70226
70292
|
key: "defineSlot",
|
70227
|
-
value: function defineSlot(options, slotId, containerId) {
|
70228
|
-
var
|
70293
|
+
value: function defineSlot(options, slotId, containerId, adType) {
|
70294
|
+
var adName = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : "banner";
|
70295
|
+
var _window_pbjs;
|
70229
70296
|
var gamNetworkId = _PrebidGAM.getProperGAMNetworkId(options);
|
70230
70297
|
var unitDefinition = options.units.find(function(unit) {
|
70231
70298
|
return unit.code === "".concat(slotId);
|
70232
70299
|
});
|
70300
|
+
var sizes = [];
|
70233
70301
|
if (!unitDefinition) {
|
70234
70302
|
console.error("No unit definition found for slotId: ".concat(slotId));
|
70235
70303
|
return;
|
70236
70304
|
}
|
70237
|
-
|
70238
|
-
|
70305
|
+
if (adType) {
|
70306
|
+
sizes = ContentProvider.adSizes[adType];
|
70307
|
+
} else {
|
70308
|
+
var _unitDefinition_mediaTypes_banner;
|
70309
|
+
sizes = ((_unitDefinition_mediaTypes_banner = unitDefinition.mediaTypes.banner) === null || _unitDefinition_mediaTypes_banner === void 0 ? void 0 : _unitDefinition_mediaTypes_banner.sizes) || [];
|
70310
|
+
}
|
70311
|
+
GPT.defineSlot("/".concat(gamNetworkId, "/").concat(adName), sizes, "".concat(containerId));
|
70239
70312
|
if (!((_window_pbjs = window.pbjs) === null || _window_pbjs === void 0 ? void 0 : _window_pbjs.adUnits.some(function(defUnit) {
|
70240
70313
|
return "".concat(containerId) === "".concat(defUnit.code);
|
70241
70314
|
}))) {
|
@@ -70245,6 +70318,11 @@ var PrebidGAM = /*#__PURE__*/ function() {
|
|
70245
70318
|
if ((_window_pbjs = window.pbjs) === null || _window_pbjs === void 0 ? void 0 : _window_pbjs.addAdUnits) {
|
70246
70319
|
window.pbjs.addAdUnits([
|
70247
70320
|
_object_spread_props(_object_spread({}, unitDefinition), {
|
70321
|
+
mediaTypes: _object_spread_props(_object_spread({}, unitDefinition.mediaTypes || {}), {
|
70322
|
+
banner: _object_spread_props(_object_spread({}, unitDefinition.mediaTypes.banner || {}), {
|
70323
|
+
sizes: sizes
|
70324
|
+
})
|
70325
|
+
}),
|
70248
70326
|
code: "".concat(containerId)
|
70249
70327
|
})
|
70250
70328
|
]);
|
@@ -70335,6 +70413,7 @@ var PrebidGAMProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
70335
70413
|
PrebidGAMEventsInstance.onSlotRenderEnd(function(event) {
|
70336
70414
|
var slot = event.slot;
|
70337
70415
|
if ("".concat(_this.workingSlotId) === event.slot.getSlotElementId()) {
|
70416
|
+
var _this_content_extra_sz, _this_content_extra_sz1;
|
70338
70417
|
if (!_this.content.extra) {
|
70339
70418
|
_this.content.extra = {};
|
70340
70419
|
}
|
@@ -70344,6 +70423,10 @@ var PrebidGAMProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
70344
70423
|
if (slot.getTargeting("hb_bidder").length) {
|
70345
70424
|
_this.content.extra.bidder = slot.getTargeting("hb_bidder")[0];
|
70346
70425
|
}
|
70426
|
+
_this.content.extra.sz = {
|
70427
|
+
w: event.size[0] || ((_this_content_extra_sz = _this.content.extra.sz) === null || _this_content_extra_sz === void 0 ? void 0 : _this_content_extra_sz.w) || 0,
|
70428
|
+
h: event.size[1] || ((_this_content_extra_sz1 = _this.content.extra.sz) === null || _this_content_extra_sz1 === void 0 ? void 0 : _this_content_extra_sz1.h) || 0
|
70429
|
+
};
|
70347
70430
|
_this.content.pending = false;
|
70348
70431
|
_this.fullfill();
|
70349
70432
|
}
|
@@ -70355,7 +70438,7 @@ var PrebidGAMProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
70355
70438
|
key: "request",
|
70356
70439
|
value: function request(params) {
|
70357
70440
|
return _async_to_generator(function() {
|
70358
|
-
var _this, regionId, regionInfo;
|
70441
|
+
var _this, adType, adName, regionId, regionInfo;
|
70359
70442
|
return _ts_generator(this, function(_state) {
|
70360
70443
|
switch(_state.label){
|
70361
70444
|
case 0:
|
@@ -70366,6 +70449,8 @@ var PrebidGAMProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
70366
70449
|
];
|
70367
70450
|
case 1:
|
70368
70451
|
_state.sent();
|
70452
|
+
adType = params.params.adType;
|
70453
|
+
adName = params.params.regionName;
|
70369
70454
|
regionId = params.params.regionId;
|
70370
70455
|
if (params.params.useRatio) {
|
70371
70456
|
regionInfo = ContentProvider.approxRegionByRatio(params.size.width, params.size.height);
|
@@ -70393,7 +70478,7 @@ var PrebidGAMProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
70393
70478
|
];
|
70394
70479
|
case 2:
|
70395
70480
|
_state.sent();
|
70396
|
-
PrebidGAM.defineSlot(this.options, regionId, this.workingSlotId);
|
70481
|
+
PrebidGAM.defineSlot(this.options, regionId, this.workingSlotId, adType, adName);
|
70397
70482
|
PrebidGAM.request(regionId, this.workingSlotId, function(content) {
|
70398
70483
|
content.style.width = "".concat(regionInfo === null || regionInfo === void 0 ? void 0 : regionInfo.w, "px");
|
70399
70484
|
content.style.height = "".concat(regionInfo === null || regionInfo === void 0 ? void 0 : regionInfo.h, "px");
|
@@ -71093,20 +71178,26 @@ var RegionBorderPlugin = /*#__PURE__*/ function() {
|
|
71093
71178
|
{
|
71094
71179
|
key: "afterShow",
|
71095
71180
|
value: function afterShow(region) {
|
71181
|
+
var styles2 = window.getComputedStyle(region.content.view);
|
71182
|
+
var width = parseFloat(styles2.width);
|
71183
|
+
var height = parseFloat(styles2.height);
|
71096
71184
|
region.view.style.width = "".concat(region.boxWidth + 4, "px");
|
71097
71185
|
region.view.style.height = "".concat(region.boxHeight + 4, "px");
|
71098
|
-
region.content.view.style.width = "".concat(
|
71099
|
-
region.content.view.style.height = "".concat(
|
71186
|
+
region.content.view.style.width = "".concat(width + 4, "px");
|
71187
|
+
region.content.view.style.height = "".concat(height + 4, "px");
|
71100
71188
|
return Promise.resolve();
|
71101
71189
|
}
|
71102
71190
|
},
|
71103
71191
|
{
|
71104
71192
|
key: "reRender",
|
71105
71193
|
value: function reRender(region) {
|
71194
|
+
var styles2 = window.getComputedStyle(region.content.view);
|
71195
|
+
var width = parseFloat(styles2.width);
|
71196
|
+
var height = parseFloat(styles2.height);
|
71106
71197
|
region.view.style.width = "".concat(region.boxWidth + 4, "px");
|
71107
71198
|
region.view.style.height = "".concat(region.boxHeight + 4, "px");
|
71108
|
-
region.content.view.style.width = "".concat(
|
71109
|
-
region.content.view.style.height = "".concat(
|
71199
|
+
region.content.view.style.width = "".concat(width + 4, "px");
|
71200
|
+
region.content.view.style.height = "".concat(height + 4, "px");
|
71110
71201
|
return Promise.resolve();
|
71111
71202
|
}
|
71112
71203
|
},
|
@@ -71191,7 +71282,7 @@ var RegionDebugPlugin = /*#__PURE__*/ function() {
|
|
71191
71282
|
// src/Ads/Regions/Region.ts
|
71192
71283
|
var Region = /*#__PURE__*/ function() {
|
71193
71284
|
"use strict";
|
71194
|
-
function Region(id, regionDescriptor, planeDescriptor, deps) {
|
71285
|
+
function Region(id, regionDescriptor, planeDescriptor, options, deps) {
|
71195
71286
|
var _this = this;
|
71196
71287
|
_class_call_check(this, Region);
|
71197
71288
|
this.onScreen = false;
|
@@ -71199,6 +71290,7 @@ var Region = /*#__PURE__*/ function() {
|
|
71199
71290
|
this.plugins = [];
|
71200
71291
|
this.id = id;
|
71201
71292
|
this.regionDescriptor = regionDescriptor;
|
71293
|
+
this.options = options;
|
71202
71294
|
this.contours = new RegionContours(regionDescriptor.contours);
|
71203
71295
|
this.box = new RegionBox(regionDescriptor.box);
|
71204
71296
|
this.plane = new Plane(planeDescriptor);
|
@@ -71638,10 +71730,43 @@ var Region = /*#__PURE__*/ function() {
|
|
71638
71730
|
return Region;
|
71639
71731
|
}();
|
71640
71732
|
// src/Ads/Regions/StaticAdRegion.ts
|
71733
|
+
var StaticRegionContent = /*#__PURE__*/ function(RegionContent) {
|
71734
|
+
"use strict";
|
71735
|
+
_inherits(StaticRegionContent, RegionContent);
|
71736
|
+
function StaticRegionContent(id, plane, box, ctx) {
|
71737
|
+
_class_call_check(this, StaticRegionContent);
|
71738
|
+
var _this;
|
71739
|
+
_this = _call_super(this, StaticRegionContent, [
|
71740
|
+
id,
|
71741
|
+
plane,
|
71742
|
+
box,
|
71743
|
+
ctx
|
71744
|
+
]);
|
71745
|
+
_this.container.style.left = "50%";
|
71746
|
+
_this.container.style.top = "50%";
|
71747
|
+
_this.container.style.transform = "translate(-50%, -50%)";
|
71748
|
+
return _this;
|
71749
|
+
}
|
71750
|
+
_create_class(StaticRegionContent, [
|
71751
|
+
{
|
71752
|
+
key: "render",
|
71753
|
+
value: function render(force) {
|
71754
|
+
var _this_content, _this_content_extra_sz, _this_content_extra, _this_content1, _this_content_extra_sz1, _this_content_extra1, _this_content2;
|
71755
|
+
if ((_this_content = this.content) === null || _this_content === void 0 ? void 0 : _this_content.pending) {
|
71756
|
+
return;
|
71757
|
+
}
|
71758
|
+
this.container.style.width = "".concat((_this_content1 = this.content) === null || _this_content1 === void 0 ? void 0 : (_this_content_extra = _this_content1.extra) === null || _this_content_extra === void 0 ? void 0 : (_this_content_extra_sz = _this_content_extra.sz) === null || _this_content_extra_sz === void 0 ? void 0 : _this_content_extra_sz.w, "px");
|
71759
|
+
this.container.style.height = "".concat((_this_content2 = this.content) === null || _this_content2 === void 0 ? void 0 : (_this_content_extra1 = _this_content2.extra) === null || _this_content_extra1 === void 0 ? void 0 : (_this_content_extra_sz1 = _this_content_extra1.sz) === null || _this_content_extra_sz1 === void 0 ? void 0 : _this_content_extra_sz1.h, "px");
|
71760
|
+
this.container.dataset.state = this.box.area(this.plane.size) > 0 ? "visible" : "hidden";
|
71761
|
+
}
|
71762
|
+
}
|
71763
|
+
]);
|
71764
|
+
return StaticRegionContent;
|
71765
|
+
}(RegionContent);
|
71641
71766
|
var StaticAdRegion = /*#__PURE__*/ function(Region) {
|
71642
71767
|
"use strict";
|
71643
71768
|
_inherits(StaticAdRegion, Region);
|
71644
|
-
function StaticAdRegion(id, planeDescriptor, deps) {
|
71769
|
+
function StaticAdRegion(id, planeDescriptor, options, deps) {
|
71645
71770
|
_class_call_check(this, StaticAdRegion);
|
71646
71771
|
var _this;
|
71647
71772
|
_this = _call_super(this, StaticAdRegion, [
|
@@ -71657,9 +71782,13 @@ var StaticAdRegion = /*#__PURE__*/ function(Region) {
|
|
71657
71782
|
}
|
71658
71783
|
},
|
71659
71784
|
planeDescriptor,
|
71785
|
+
options,
|
71660
71786
|
deps
|
71661
71787
|
]);
|
71662
71788
|
_this.requestWithSize = true;
|
71789
|
+
_this.content.view.remove();
|
71790
|
+
_this.content = new StaticRegionContent(_this.id, _this.plane, _this.box, _this.deps.debug ? _this.regionDescriptor.ctx : void 0);
|
71791
|
+
_this.container.appendChild(_this.content.view);
|
71663
71792
|
return _this;
|
71664
71793
|
}
|
71665
71794
|
_create_class(StaticAdRegion, [
|
@@ -71674,12 +71803,15 @@ var StaticAdRegion = /*#__PURE__*/ function(Region) {
|
|
71674
71803
|
value: function requestContent() {
|
71675
71804
|
var box = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.box;
|
71676
71805
|
if (this.deps.provider) {
|
71806
|
+
var _this_options_ad, _this_options, _this_options_ad1, _this_options1;
|
71677
71807
|
this.deps.provider.request({
|
71678
71808
|
size: {
|
71679
71809
|
width: box.width(this.plane.size),
|
71680
71810
|
height: box.height(this.plane.size)
|
71681
71811
|
},
|
71682
71812
|
params: {
|
71813
|
+
adType: (_this_options = this.options) === null || _this_options === void 0 ? void 0 : (_this_options_ad = _this_options.ad) === null || _this_options_ad === void 0 ? void 0 : _this_options_ad.type,
|
71814
|
+
regionName: (_this_options1 = this.options) === null || _this_options1 === void 0 ? void 0 : (_this_options_ad1 = _this_options1.ad) === null || _this_options_ad1 === void 0 ? void 0 : _this_options_ad1.name,
|
71683
71815
|
useSize: true,
|
71684
71816
|
regionId: this.id
|
71685
71817
|
}
|
@@ -71765,26 +71897,58 @@ var StaticAdRegion = /*#__PURE__*/ function(Region) {
|
|
71765
71897
|
return StaticAdRegion;
|
71766
71898
|
}(Region);
|
71767
71899
|
// src/Ads/StaticAds/StaticAds.ts
|
71900
|
+
function debounce2(func) {
|
71901
|
+
var timeout = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 100;
|
71902
|
+
var timer;
|
71903
|
+
return function() {
|
71904
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
71905
|
+
args[_key] = arguments[_key];
|
71906
|
+
}
|
71907
|
+
clearTimeout(timer);
|
71908
|
+
timer = setTimeout(function() {
|
71909
|
+
func.apply(void 0, _to_consumable_array(args));
|
71910
|
+
}, timeout);
|
71911
|
+
};
|
71912
|
+
}
|
71913
|
+
function isElementVisible(element) {
|
71914
|
+
if (!element) return false;
|
71915
|
+
if (!document.contains(element)) return false;
|
71916
|
+
var style = window.getComputedStyle(element);
|
71917
|
+
if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0") {
|
71918
|
+
return false;
|
71919
|
+
}
|
71920
|
+
return true;
|
71921
|
+
}
|
71768
71922
|
var StaticAds = /*#__PURE__*/ function() {
|
71769
71923
|
"use strict";
|
71770
71924
|
function StaticAds(context) {
|
71771
71925
|
_class_call_check(this, StaticAds);
|
71772
71926
|
this.regions = [];
|
71927
|
+
this.handlePageMutation = this.handlePageMutation.bind(this);
|
71773
71928
|
this.context = context;
|
71774
71929
|
this.recorderFactory = new RecorderFactory(this.context);
|
71930
|
+
this.observer = new MutationObserver(debounce2(this.handlePageMutation));
|
71775
71931
|
}
|
71776
71932
|
_create_class(StaticAds, [
|
71777
71933
|
{
|
71778
|
-
key: "
|
71779
|
-
value: function
|
71934
|
+
key: "handlePageMutation",
|
71935
|
+
value: function handlePageMutation() {
|
71936
|
+
this.handleRegions();
|
71937
|
+
}
|
71938
|
+
},
|
71939
|
+
{
|
71940
|
+
key: "handleRegions",
|
71941
|
+
value: function handleRegions() {
|
71780
71942
|
var _this, _loop = function(index) {
|
71781
71943
|
var element = elements2[index];
|
71782
71944
|
var previousContent = _to_consumable_array(element.childNodes);
|
71783
71945
|
var id = 500 + index;
|
71784
71946
|
var size = null;
|
71947
|
+
var adType = void 0;
|
71948
|
+
var regionName = void 0;
|
71785
71949
|
if (element.hasAttribute("data-b-t") && element.hasAttribute("data-b-n")) {
|
71786
|
-
|
71787
|
-
|
71950
|
+
adType = element.getAttribute("data-b-t");
|
71951
|
+
regionName = element.getAttribute("data-b-n") || void 0;
|
71788
71952
|
var sizes = ContentProvider.adSizes[adType];
|
71789
71953
|
if (sizes && sizes.length > 0) {
|
71790
71954
|
var _sizes_ = _sliced_to_array(sizes[0], 2), w2 = _sizes_[0], h = _sizes_[1];
|
@@ -71795,12 +71959,6 @@ var StaticAds = /*#__PURE__*/ function() {
|
|
71795
71959
|
} else {
|
71796
71960
|
_this.context.logger.error("Invalid attribute or no sizes found for adType: ".concat(adType, " and regionName: ").concat(regionName));
|
71797
71961
|
}
|
71798
|
-
} else if (element.hasAttribute("data-b-w") && element.hasAttribute("data-b-h")) {
|
71799
|
-
size = {
|
71800
|
-
width: Number(element.getAttribute("data-b-w")),
|
71801
|
-
height: Number(element.getAttribute("data-b-h"))
|
71802
|
-
};
|
71803
|
-
_this.context.logger.warn("Using deprecated attributes data-b-w and data-b-h for element: ".concat(element.getAttribute("data-b-n")));
|
71804
71962
|
}
|
71805
71963
|
if (!size) {
|
71806
71964
|
return "continue";
|
@@ -71843,6 +72001,11 @@ var StaticAds = /*#__PURE__*/ function() {
|
|
71843
72001
|
}
|
71844
72002
|
];
|
71845
72003
|
var newRegion = new StaticAdRegion(id, size, {
|
72004
|
+
ad: {
|
72005
|
+
type: adType,
|
72006
|
+
name: regionName
|
72007
|
+
}
|
72008
|
+
}, {
|
71846
72009
|
provider: provider,
|
71847
72010
|
plugins: plugins2,
|
71848
72011
|
recorder: _this.recorderFactory.create()
|
@@ -71851,20 +72014,31 @@ var StaticAds = /*#__PURE__*/ function() {
|
|
71851
72014
|
element.appendChild(newRegion.view);
|
71852
72015
|
_this.regions.push(newRegion);
|
71853
72016
|
};
|
71854
|
-
this.context.logger.log("starting static ads");
|
71855
72017
|
var selector = this.context.config.get("staticRegionsSelector");
|
71856
72018
|
if (!selector) {
|
71857
72019
|
return;
|
71858
72020
|
}
|
71859
72021
|
var elements2 = Array.from(document.querySelectorAll(selector)).filter(function(e2) {
|
71860
|
-
return _instanceof(e2, HTMLElement) &&
|
72022
|
+
return _instanceof(e2, HTMLElement) && e2.hasAttribute("data-b-t") && e2.hasAttribute("data-b-n") && e2.querySelector('[class="BRNDTS_R"]') === null && isElementVisible(e2);
|
71861
72023
|
});
|
71862
72024
|
for(var index = 0; index < elements2.length; index++)_this = this, _loop(index);
|
71863
72025
|
}
|
71864
72026
|
},
|
72027
|
+
{
|
72028
|
+
key: "start",
|
72029
|
+
value: function start() {
|
72030
|
+
this.context.logger.log("starting static ads");
|
72031
|
+
this.handleRegions();
|
72032
|
+
this.observer.observe(document.body, {
|
72033
|
+
childList: true,
|
72034
|
+
subtree: true
|
72035
|
+
});
|
72036
|
+
}
|
72037
|
+
},
|
71865
72038
|
{
|
71866
72039
|
key: "destroy",
|
71867
72040
|
value: function destroy() {
|
72041
|
+
this.observer.disconnect();
|
71868
72042
|
this.context.logger.log("destroying static ads");
|
71869
72043
|
this.regions.forEach(function(region) {
|
71870
72044
|
region.destroy();
|
@@ -74684,12 +74858,13 @@ var MappedCollection = /*#__PURE__*/ function() {
|
|
74684
74858
|
var AdRegion = /*#__PURE__*/ function(Region) {
|
74685
74859
|
"use strict";
|
74686
74860
|
_inherits(AdRegion, Region);
|
74687
|
-
function AdRegion(regionDescriptor, planeDescriptor, deps) {
|
74861
|
+
function AdRegion(regionDescriptor, planeDescriptor, options, deps) {
|
74688
74862
|
_class_call_check(this, AdRegion);
|
74689
74863
|
return _call_super(this, AdRegion, [
|
74690
74864
|
"".concat(regionDescriptor.id),
|
74691
74865
|
regionDescriptor,
|
74692
74866
|
planeDescriptor,
|
74867
|
+
options,
|
74693
74868
|
deps
|
74694
74869
|
]);
|
74695
74870
|
}
|
@@ -74713,12 +74888,13 @@ var AdRegion = /*#__PURE__*/ function(Region) {
|
|
74713
74888
|
var AuxRegion = /*#__PURE__*/ function(Region) {
|
74714
74889
|
"use strict";
|
74715
74890
|
_inherits(AuxRegion, Region);
|
74716
|
-
function AuxRegion(regionDescriptor, planeDescriptor, deps) {
|
74891
|
+
function AuxRegion(regionDescriptor, planeDescriptor, options, deps) {
|
74717
74892
|
_class_call_check(this, AuxRegion);
|
74718
74893
|
return _call_super(this, AuxRegion, [
|
74719
74894
|
"".concat(regionDescriptor.id),
|
74720
74895
|
regionDescriptor,
|
74721
74896
|
planeDescriptor,
|
74897
|
+
options,
|
74722
74898
|
_object_spread({}, deps)
|
74723
74899
|
]);
|
74724
74900
|
}
|
@@ -74783,15 +74959,15 @@ var RegionFactory = /*#__PURE__*/ function() {
|
|
74783
74959
|
},
|
74784
74960
|
{
|
74785
74961
|
key: "get",
|
74786
|
-
value: function get(regionDescriptor, planeDescriptor, deps) {
|
74962
|
+
value: function get(regionDescriptor, planeDescriptor, options, deps) {
|
74787
74963
|
if (regionDescriptor && planeDescriptor) {
|
74788
74964
|
var _this_deps;
|
74789
74965
|
if ((_this_deps = this.deps) === null || _this_deps === void 0 ? void 0 : _this_deps.debug) {
|
74790
|
-
return new AuxRegion(regionDescriptor, planeDescriptor, _object_spread_props(_object_spread({}, this.deps || {}, deps || {}), {
|
74966
|
+
return new AuxRegion(regionDescriptor, planeDescriptor, options || {}, _object_spread_props(_object_spread({}, this.deps || {}, deps || {}), {
|
74791
74967
|
plugins: this.getPluginForStrategy()
|
74792
74968
|
}));
|
74793
74969
|
} else {
|
74794
|
-
return new AdRegion(regionDescriptor, planeDescriptor, _object_spread_props(_object_spread({}, this.deps || {}, deps || {}), {
|
74970
|
+
return new AdRegion(regionDescriptor, planeDescriptor, options || {}, _object_spread_props(_object_spread({}, this.deps || {}, deps || {}), {
|
74795
74971
|
plugins: this.getPluginForStrategy()
|
74796
74972
|
}));
|
74797
74973
|
}
|
@@ -74962,7 +75138,7 @@ var RegionRenderer = /*#__PURE__*/ function() {
|
|
74962
75138
|
}, {
|
74963
75139
|
width: this.regionsContainerView.width,
|
74964
75140
|
height: this.regionsContainerView.height
|
74965
|
-
}, {
|
75141
|
+
}, {}, {
|
74966
75142
|
provider: ContentProviderFactory.getProvider(this.context, this.context.config.get("ads").provider)
|
74967
75143
|
});
|
74968
75144
|
this.regionsData.push({
|
@@ -75039,7 +75215,7 @@ var RegionRenderer = /*#__PURE__*/ function() {
|
|
75039
75215
|
var newRegion = this.regionFactory.get(diffRight[index1], {
|
75040
75216
|
width: this.regionsContainerView.width,
|
75041
75217
|
height: this.regionsContainerView.height
|
75042
|
-
}, {
|
75218
|
+
}, {}, {
|
75043
75219
|
provider: ContentProviderFactory.getProvider(this.context, this.context.config.get("ads").provider)
|
75044
75220
|
});
|
75045
75221
|
this.regionsObjects.push(newRegion);
|
@@ -79896,7 +80072,7 @@ var AuxElementsRenderer = /*#__PURE__*/ function() {
|
|
79896
80072
|
}, {
|
79897
80073
|
width: this.regionsContainerView.width,
|
79898
80074
|
height: this.regionsContainerView.height
|
79899
|
-
}, {
|
80075
|
+
}, {}, {
|
79900
80076
|
provider: ContentProviderFactory.getProvider(this.context, this.context.config.get("ads").provider)
|
79901
80077
|
});
|
79902
80078
|
this.auxElementsData.push({
|
@@ -79958,7 +80134,7 @@ var AuxElementsRenderer = /*#__PURE__*/ function() {
|
|
79958
80134
|
}), {
|
79959
80135
|
width: this.regionsContainerView.width,
|
79960
80136
|
height: this.regionsContainerView.height
|
79961
|
-
}, {});
|
80137
|
+
}, {}, {});
|
79962
80138
|
this.regionsObjects.push(oldRegion);
|
79963
80139
|
this.regionsContainerView.append(oldRegion.view);
|
79964
80140
|
}
|
@@ -80251,11 +80427,11 @@ var VideoAd = /*#__PURE__*/ function() {
|
|
80251
80427
|
{
|
80252
80428
|
key: "destroy",
|
80253
80429
|
value: function destroy() {
|
80254
|
-
var _this_adPresentationStrategy, _this_regionsRenderer, _this_videoRegions, _this_videoAdContext_interface;
|
80430
|
+
var _this_adPresentationStrategy, _this_regionsRenderer, _this_videoRegions, _this_videoAdContext_recorder, _this_videoAdContext_interface;
|
80255
80431
|
(_this_adPresentationStrategy = this.adPresentationStrategy) === null || _this_adPresentationStrategy === void 0 ? void 0 : _this_adPresentationStrategy.destroy();
|
80256
80432
|
(_this_regionsRenderer = this.regionsRenderer) === null || _this_regionsRenderer === void 0 ? void 0 : _this_regionsRenderer.destroy();
|
80257
80433
|
(_this_videoRegions = this.videoRegions) === null || _this_videoRegions === void 0 ? void 0 : _this_videoRegions.destroy();
|
80258
|
-
this.videoAdContext.recorder.destroy();
|
80434
|
+
(_this_videoAdContext_recorder = this.videoAdContext.recorder) === null || _this_videoAdContext_recorder === void 0 ? void 0 : _this_videoAdContext_recorder.destroy();
|
80259
80435
|
(_this_videoAdContext_interface = this.videoAdContext.interface) === null || _this_videoAdContext_interface === void 0 ? void 0 : _this_videoAdContext_interface.destroy();
|
80260
80436
|
}
|
80261
80437
|
}
|