@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.js
CHANGED
@@ -69370,13 +69370,63 @@ var AffiliateProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
69370
69370
|
},
|
69371
69371
|
{
|
69372
69372
|
key: "getAffiliate",
|
69373
|
-
value: function getAffiliate(regionId, size) {
|
69373
|
+
value: function getAffiliate(regionId, size, adType, regionName) {
|
69374
69374
|
var _this = this;
|
69375
69375
|
if (!regionId) {
|
69376
|
+
if (adType && regionName) {
|
69377
|
+
var sizes = ContentProvider.adSizes[adType];
|
69378
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
69379
|
+
try {
|
69380
|
+
var _this1, _loop = function() {
|
69381
|
+
var _step_value = _sliced_to_array(_step.value, 2), width = _step_value[0], height = _step_value[1];
|
69382
|
+
var identifier = "".concat(width, "x").concat(height);
|
69383
|
+
var aff2 = _this1.manifest.filter(function(a) {
|
69384
|
+
return a.size.w === width && a.size.h === height;
|
69385
|
+
});
|
69386
|
+
if (!aff2.length) {
|
69387
|
+
return "continue";
|
69388
|
+
}
|
69389
|
+
if (!_this1.useByRegion[identifier]) {
|
69390
|
+
_this1.useByRegion[identifier] = /* @__PURE__ */ new Set();
|
69391
|
+
}
|
69392
|
+
if (_this1.useByRegion[identifier].size === aff2.length) {
|
69393
|
+
_this1.useByRegion[identifier].clear();
|
69394
|
+
}
|
69395
|
+
var unused2 = aff2.filter(function(a) {
|
69396
|
+
return !_this.useByRegion[identifier].has(a.id);
|
69397
|
+
});
|
69398
|
+
if (unused2.length) {
|
69399
|
+
var randomIndex2 = Math.floor(Math.random() * unused2.length);
|
69400
|
+
var selected = unused2[randomIndex2];
|
69401
|
+
_this1.useByRegion[identifier].add(selected.id);
|
69402
|
+
return {
|
69403
|
+
v: selected
|
69404
|
+
};
|
69405
|
+
}
|
69406
|
+
};
|
69407
|
+
for(var _iterator = sizes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
69408
|
+
var _ret = (_this1 = this, _loop());
|
69409
|
+
if (_type_of(_ret) === "object") return _ret.v;
|
69410
|
+
}
|
69411
|
+
} catch (err) {
|
69412
|
+
_didIteratorError = true;
|
69413
|
+
_iteratorError = err;
|
69414
|
+
} finally{
|
69415
|
+
try {
|
69416
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
69417
|
+
_iterator.return();
|
69418
|
+
}
|
69419
|
+
} finally{
|
69420
|
+
if (_didIteratorError) {
|
69421
|
+
throw _iteratorError;
|
69422
|
+
}
|
69423
|
+
}
|
69424
|
+
}
|
69425
|
+
}
|
69376
69426
|
if ((size === null || size === void 0 ? void 0 : size.width) && (size === null || size === void 0 ? void 0 : size.height)) {
|
69377
69427
|
var identifier = "".concat(size.width, "x").concat(size.height);
|
69378
69428
|
var aff2 = this.manifest.filter(function(a) {
|
69379
|
-
return a.size.w === size.width && a.size.h === size.height;
|
69429
|
+
return a.size.w === (size === null || size === void 0 ? void 0 : size.width) && a.size.h === size.height;
|
69380
69430
|
});
|
69381
69431
|
if (!aff2.length) {
|
69382
69432
|
return null;
|
@@ -69431,7 +69481,10 @@ var AffiliateProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
69431
69481
|
case 1:
|
69432
69482
|
_state.sent();
|
69433
69483
|
affiliate = null;
|
69434
|
-
if (params.params.
|
69484
|
+
if (!affiliate && params.params.adType && params.params.regionName) {
|
69485
|
+
affiliate = this.getAffiliate(void 0, params.size, params.params.adType, params.params.regionName);
|
69486
|
+
}
|
69487
|
+
if (!affiliate && params.params.useRatio) {
|
69435
69488
|
regionInfo = ContentProvider.approxRegionByRatio(params.size.width, params.size.height);
|
69436
69489
|
if (regionInfo) {
|
69437
69490
|
affiliate = this.getAffiliate("".concat(regionInfo.id), {
|
@@ -69684,15 +69737,22 @@ var PrebidJS = /*#__PURE__*/ function() {
|
|
69684
69737
|
},
|
69685
69738
|
{
|
69686
69739
|
key: "defineSlot",
|
69687
|
-
value: function defineSlot(options, slotId, containerId) {
|
69740
|
+
value: function defineSlot(options, slotId, containerId, adType) {
|
69688
69741
|
var _window_pbjs;
|
69689
69742
|
var unitDefinition = options.units.find(function(unit) {
|
69690
69743
|
return unit.code === "".concat(slotId);
|
69691
69744
|
});
|
69745
|
+
var sizes = [];
|
69692
69746
|
if (!unitDefinition) {
|
69693
69747
|
console.error("No unit definition found for slotId: ".concat(slotId));
|
69694
69748
|
return;
|
69695
69749
|
}
|
69750
|
+
if (adType) {
|
69751
|
+
sizes = ContentProvider.adSizes[adType];
|
69752
|
+
} else {
|
69753
|
+
var _unitDefinition_mediaTypes_banner;
|
69754
|
+
sizes = ((_unitDefinition_mediaTypes_banner = unitDefinition.mediaTypes.banner) === null || _unitDefinition_mediaTypes_banner === void 0 ? void 0 : _unitDefinition_mediaTypes_banner.sizes) || [];
|
69755
|
+
}
|
69696
69756
|
if (!((_window_pbjs = window.pbjs) === null || _window_pbjs === void 0 ? void 0 : _window_pbjs.adUnits.some(function(defUnit) {
|
69697
69757
|
return containerId === defUnit.code;
|
69698
69758
|
}))) {
|
@@ -69702,6 +69762,11 @@ var PrebidJS = /*#__PURE__*/ function() {
|
|
69702
69762
|
if ((_window_pbjs = window.pbjs) === null || _window_pbjs === void 0 ? void 0 : _window_pbjs.addAdUnits) {
|
69703
69763
|
window.pbjs.addAdUnits([
|
69704
69764
|
_object_spread_props(_object_spread({}, unitDefinition), {
|
69765
|
+
mediaTypes: _object_spread_props(_object_spread({}, unitDefinition.mediaTypes || {}), {
|
69766
|
+
banner: _object_spread_props(_object_spread({}, unitDefinition.mediaTypes.banner || {}), {
|
69767
|
+
sizes: sizes
|
69768
|
+
})
|
69769
|
+
}),
|
69705
69770
|
code: containerId
|
69706
69771
|
})
|
69707
69772
|
]);
|
@@ -69869,7 +69934,7 @@ var PrebidjsProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
69869
69934
|
key: "request",
|
69870
69935
|
value: function request(params) {
|
69871
69936
|
return _async_to_generator(function() {
|
69872
|
-
var _this, regionId, regionInfo, regionInfo1;
|
69937
|
+
var _this, adType, regionId, regionInfo, regionInfo1;
|
69873
69938
|
return _ts_generator(this, function(_state) {
|
69874
69939
|
switch(_state.label){
|
69875
69940
|
case 0:
|
@@ -69880,6 +69945,7 @@ var PrebidjsProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
69880
69945
|
];
|
69881
69946
|
case 1:
|
69882
69947
|
_state.sent();
|
69948
|
+
adType = params.params.adType;
|
69883
69949
|
regionId = params.params.regionId;
|
69884
69950
|
if (params.params.useRatio) {
|
69885
69951
|
regionInfo = ContentProvider.approxRegionByRatio(params.size.width, params.size.height);
|
@@ -69904,7 +69970,7 @@ var PrebidjsProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
69904
69970
|
];
|
69905
69971
|
case 2:
|
69906
69972
|
_state.sent();
|
69907
|
-
PrebidJS.defineSlot(this.options, regionId, params.params.regionId);
|
69973
|
+
PrebidJS.defineSlot(this.options, regionId, params.params.regionId, adType);
|
69908
69974
|
PrebidJS.request(regionId, params.params.regionId, function(bids) {
|
69909
69975
|
return _this.processBids(params, bids);
|
69910
69976
|
});
|
@@ -70174,18 +70240,25 @@ var PrebidGAM = /*#__PURE__*/ function() {
|
|
70174
70240
|
},
|
70175
70241
|
{
|
70176
70242
|
key: "defineSlot",
|
70177
|
-
value: function defineSlot(options, slotId, containerId) {
|
70178
|
-
var
|
70243
|
+
value: function defineSlot(options, slotId, containerId, adType) {
|
70244
|
+
var adName = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : "banner";
|
70245
|
+
var _window_pbjs;
|
70179
70246
|
var gamNetworkId = _PrebidGAM.getProperGAMNetworkId(options);
|
70180
70247
|
var unitDefinition = options.units.find(function(unit) {
|
70181
70248
|
return unit.code === "".concat(slotId);
|
70182
70249
|
});
|
70250
|
+
var sizes = [];
|
70183
70251
|
if (!unitDefinition) {
|
70184
70252
|
console.error("No unit definition found for slotId: ".concat(slotId));
|
70185
70253
|
return;
|
70186
70254
|
}
|
70187
|
-
|
70188
|
-
|
70255
|
+
if (adType) {
|
70256
|
+
sizes = ContentProvider.adSizes[adType];
|
70257
|
+
} else {
|
70258
|
+
var _unitDefinition_mediaTypes_banner;
|
70259
|
+
sizes = ((_unitDefinition_mediaTypes_banner = unitDefinition.mediaTypes.banner) === null || _unitDefinition_mediaTypes_banner === void 0 ? void 0 : _unitDefinition_mediaTypes_banner.sizes) || [];
|
70260
|
+
}
|
70261
|
+
GPT.defineSlot("/".concat(gamNetworkId, "/").concat(adName), sizes, "".concat(containerId));
|
70189
70262
|
if (!((_window_pbjs = window.pbjs) === null || _window_pbjs === void 0 ? void 0 : _window_pbjs.adUnits.some(function(defUnit) {
|
70190
70263
|
return "".concat(containerId) === "".concat(defUnit.code);
|
70191
70264
|
}))) {
|
@@ -70195,6 +70268,11 @@ var PrebidGAM = /*#__PURE__*/ function() {
|
|
70195
70268
|
if ((_window_pbjs = window.pbjs) === null || _window_pbjs === void 0 ? void 0 : _window_pbjs.addAdUnits) {
|
70196
70269
|
window.pbjs.addAdUnits([
|
70197
70270
|
_object_spread_props(_object_spread({}, unitDefinition), {
|
70271
|
+
mediaTypes: _object_spread_props(_object_spread({}, unitDefinition.mediaTypes || {}), {
|
70272
|
+
banner: _object_spread_props(_object_spread({}, unitDefinition.mediaTypes.banner || {}), {
|
70273
|
+
sizes: sizes
|
70274
|
+
})
|
70275
|
+
}),
|
70198
70276
|
code: "".concat(containerId)
|
70199
70277
|
})
|
70200
70278
|
]);
|
@@ -70284,6 +70362,7 @@ var PrebidGAMProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
70284
70362
|
PrebidGAMEventsInstance.onSlotRenderEnd(function(event) {
|
70285
70363
|
var slot = event.slot;
|
70286
70364
|
if ("".concat(_this.workingSlotId) === event.slot.getSlotElementId()) {
|
70365
|
+
var _this_content_extra_sz, _this_content_extra_sz1;
|
70287
70366
|
if (!_this.content.extra) {
|
70288
70367
|
_this.content.extra = {};
|
70289
70368
|
}
|
@@ -70293,6 +70372,10 @@ var PrebidGAMProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
70293
70372
|
if (slot.getTargeting("hb_bidder").length) {
|
70294
70373
|
_this.content.extra.bidder = slot.getTargeting("hb_bidder")[0];
|
70295
70374
|
}
|
70375
|
+
_this.content.extra.sz = {
|
70376
|
+
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,
|
70377
|
+
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
|
70378
|
+
};
|
70296
70379
|
_this.content.pending = false;
|
70297
70380
|
_this.fullfill();
|
70298
70381
|
}
|
@@ -70304,7 +70387,7 @@ var PrebidGAMProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
70304
70387
|
key: "request",
|
70305
70388
|
value: function request(params) {
|
70306
70389
|
return _async_to_generator(function() {
|
70307
|
-
var _this, regionId, regionInfo;
|
70390
|
+
var _this, adType, adName, regionId, regionInfo;
|
70308
70391
|
return _ts_generator(this, function(_state) {
|
70309
70392
|
switch(_state.label){
|
70310
70393
|
case 0:
|
@@ -70315,6 +70398,8 @@ var PrebidGAMProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
70315
70398
|
];
|
70316
70399
|
case 1:
|
70317
70400
|
_state.sent();
|
70401
|
+
adType = params.params.adType;
|
70402
|
+
adName = params.params.regionName;
|
70318
70403
|
regionId = params.params.regionId;
|
70319
70404
|
if (params.params.useRatio) {
|
70320
70405
|
regionInfo = ContentProvider.approxRegionByRatio(params.size.width, params.size.height);
|
@@ -70342,7 +70427,7 @@ var PrebidGAMProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
70342
70427
|
];
|
70343
70428
|
case 2:
|
70344
70429
|
_state.sent();
|
70345
|
-
PrebidGAM.defineSlot(this.options, regionId, this.workingSlotId);
|
70430
|
+
PrebidGAM.defineSlot(this.options, regionId, this.workingSlotId, adType, adName);
|
70346
70431
|
PrebidGAM.request(regionId, this.workingSlotId, function(content) {
|
70347
70432
|
content.style.width = "".concat(regionInfo === null || regionInfo === void 0 ? void 0 : regionInfo.w, "px");
|
70348
70433
|
content.style.height = "".concat(regionInfo === null || regionInfo === void 0 ? void 0 : regionInfo.h, "px");
|
@@ -71031,20 +71116,26 @@ var RegionBorderPlugin = /*#__PURE__*/ function() {
|
|
71031
71116
|
{
|
71032
71117
|
key: "afterShow",
|
71033
71118
|
value: function afterShow(region) {
|
71119
|
+
var styles2 = window.getComputedStyle(region.content.view);
|
71120
|
+
var width = parseFloat(styles2.width);
|
71121
|
+
var height = parseFloat(styles2.height);
|
71034
71122
|
region.view.style.width = "".concat(region.boxWidth + 4, "px");
|
71035
71123
|
region.view.style.height = "".concat(region.boxHeight + 4, "px");
|
71036
|
-
region.content.view.style.width = "".concat(
|
71037
|
-
region.content.view.style.height = "".concat(
|
71124
|
+
region.content.view.style.width = "".concat(width + 4, "px");
|
71125
|
+
region.content.view.style.height = "".concat(height + 4, "px");
|
71038
71126
|
return Promise.resolve();
|
71039
71127
|
}
|
71040
71128
|
},
|
71041
71129
|
{
|
71042
71130
|
key: "reRender",
|
71043
71131
|
value: function reRender(region) {
|
71132
|
+
var styles2 = window.getComputedStyle(region.content.view);
|
71133
|
+
var width = parseFloat(styles2.width);
|
71134
|
+
var height = parseFloat(styles2.height);
|
71044
71135
|
region.view.style.width = "".concat(region.boxWidth + 4, "px");
|
71045
71136
|
region.view.style.height = "".concat(region.boxHeight + 4, "px");
|
71046
|
-
region.content.view.style.width = "".concat(
|
71047
|
-
region.content.view.style.height = "".concat(
|
71137
|
+
region.content.view.style.width = "".concat(width + 4, "px");
|
71138
|
+
region.content.view.style.height = "".concat(height + 4, "px");
|
71048
71139
|
return Promise.resolve();
|
71049
71140
|
}
|
71050
71141
|
},
|
@@ -71127,7 +71218,7 @@ var RegionDebugPlugin = /*#__PURE__*/ function() {
|
|
71127
71218
|
}();
|
71128
71219
|
// src/Ads/Regions/Region.ts
|
71129
71220
|
var Region = /*#__PURE__*/ function() {
|
71130
|
-
function Region(id, regionDescriptor, planeDescriptor, deps) {
|
71221
|
+
function Region(id, regionDescriptor, planeDescriptor, options, deps) {
|
71131
71222
|
var _this = this;
|
71132
71223
|
_class_call_check(this, Region);
|
71133
71224
|
this.onScreen = false;
|
@@ -71135,6 +71226,7 @@ var Region = /*#__PURE__*/ function() {
|
|
71135
71226
|
this.plugins = [];
|
71136
71227
|
this.id = id;
|
71137
71228
|
this.regionDescriptor = regionDescriptor;
|
71229
|
+
this.options = options;
|
71138
71230
|
this.contours = new RegionContours(regionDescriptor.contours);
|
71139
71231
|
this.box = new RegionBox(regionDescriptor.box);
|
71140
71232
|
this.plane = new Plane(planeDescriptor);
|
@@ -71574,9 +71666,41 @@ var Region = /*#__PURE__*/ function() {
|
|
71574
71666
|
return Region;
|
71575
71667
|
}();
|
71576
71668
|
// src/Ads/Regions/StaticAdRegion.ts
|
71669
|
+
var StaticRegionContent = /*#__PURE__*/ function(RegionContent) {
|
71670
|
+
_inherits(StaticRegionContent, RegionContent);
|
71671
|
+
function StaticRegionContent(id, plane, box, ctx) {
|
71672
|
+
_class_call_check(this, StaticRegionContent);
|
71673
|
+
var _this;
|
71674
|
+
_this = _call_super(this, StaticRegionContent, [
|
71675
|
+
id,
|
71676
|
+
plane,
|
71677
|
+
box,
|
71678
|
+
ctx
|
71679
|
+
]);
|
71680
|
+
_this.container.style.left = "50%";
|
71681
|
+
_this.container.style.top = "50%";
|
71682
|
+
_this.container.style.transform = "translate(-50%, -50%)";
|
71683
|
+
return _this;
|
71684
|
+
}
|
71685
|
+
_create_class(StaticRegionContent, [
|
71686
|
+
{
|
71687
|
+
key: "render",
|
71688
|
+
value: function render(force) {
|
71689
|
+
var _this_content, _this_content_extra_sz, _this_content_extra, _this_content1, _this_content_extra_sz1, _this_content_extra1, _this_content2;
|
71690
|
+
if ((_this_content = this.content) === null || _this_content === void 0 ? void 0 : _this_content.pending) {
|
71691
|
+
return;
|
71692
|
+
}
|
71693
|
+
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");
|
71694
|
+
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");
|
71695
|
+
this.container.dataset.state = this.box.area(this.plane.size) > 0 ? "visible" : "hidden";
|
71696
|
+
}
|
71697
|
+
}
|
71698
|
+
]);
|
71699
|
+
return StaticRegionContent;
|
71700
|
+
}(RegionContent);
|
71577
71701
|
var StaticAdRegion = /*#__PURE__*/ function(Region) {
|
71578
71702
|
_inherits(StaticAdRegion, Region);
|
71579
|
-
function StaticAdRegion(id, planeDescriptor, deps) {
|
71703
|
+
function StaticAdRegion(id, planeDescriptor, options, deps) {
|
71580
71704
|
_class_call_check(this, StaticAdRegion);
|
71581
71705
|
var _this;
|
71582
71706
|
_this = _call_super(this, StaticAdRegion, [
|
@@ -71592,9 +71716,13 @@ var StaticAdRegion = /*#__PURE__*/ function(Region) {
|
|
71592
71716
|
}
|
71593
71717
|
},
|
71594
71718
|
planeDescriptor,
|
71719
|
+
options,
|
71595
71720
|
deps
|
71596
71721
|
]);
|
71597
71722
|
_this.requestWithSize = true;
|
71723
|
+
_this.content.view.remove();
|
71724
|
+
_this.content = new StaticRegionContent(_this.id, _this.plane, _this.box, _this.deps.debug ? _this.regionDescriptor.ctx : void 0);
|
71725
|
+
_this.container.appendChild(_this.content.view);
|
71598
71726
|
return _this;
|
71599
71727
|
}
|
71600
71728
|
_create_class(StaticAdRegion, [
|
@@ -71609,12 +71737,15 @@ var StaticAdRegion = /*#__PURE__*/ function(Region) {
|
|
71609
71737
|
value: function requestContent() {
|
71610
71738
|
var box = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.box;
|
71611
71739
|
if (this.deps.provider) {
|
71740
|
+
var _this_options_ad, _this_options, _this_options_ad1, _this_options1;
|
71612
71741
|
this.deps.provider.request({
|
71613
71742
|
size: {
|
71614
71743
|
width: box.width(this.plane.size),
|
71615
71744
|
height: box.height(this.plane.size)
|
71616
71745
|
},
|
71617
71746
|
params: {
|
71747
|
+
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,
|
71748
|
+
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,
|
71618
71749
|
useSize: true,
|
71619
71750
|
regionId: this.id
|
71620
71751
|
}
|
@@ -71700,25 +71831,57 @@ var StaticAdRegion = /*#__PURE__*/ function(Region) {
|
|
71700
71831
|
return StaticAdRegion;
|
71701
71832
|
}(Region);
|
71702
71833
|
// src/Ads/StaticAds/StaticAds.ts
|
71834
|
+
function debounce2(func) {
|
71835
|
+
var timeout = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 100;
|
71836
|
+
var timer;
|
71837
|
+
return function() {
|
71838
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
71839
|
+
args[_key] = arguments[_key];
|
71840
|
+
}
|
71841
|
+
clearTimeout(timer);
|
71842
|
+
timer = setTimeout(function() {
|
71843
|
+
func.apply(void 0, _to_consumable_array(args));
|
71844
|
+
}, timeout);
|
71845
|
+
};
|
71846
|
+
}
|
71847
|
+
function isElementVisible(element) {
|
71848
|
+
if (!element) return false;
|
71849
|
+
if (!document.contains(element)) return false;
|
71850
|
+
var style = window.getComputedStyle(element);
|
71851
|
+
if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0") {
|
71852
|
+
return false;
|
71853
|
+
}
|
71854
|
+
return true;
|
71855
|
+
}
|
71703
71856
|
var StaticAds = /*#__PURE__*/ function() {
|
71704
71857
|
function StaticAds(context) {
|
71705
71858
|
_class_call_check(this, StaticAds);
|
71706
71859
|
this.regions = [];
|
71860
|
+
this.handlePageMutation = this.handlePageMutation.bind(this);
|
71707
71861
|
this.context = context;
|
71708
71862
|
this.recorderFactory = new RecorderFactory(this.context);
|
71863
|
+
this.observer = new MutationObserver(debounce2(this.handlePageMutation));
|
71709
71864
|
}
|
71710
71865
|
_create_class(StaticAds, [
|
71711
71866
|
{
|
71712
|
-
key: "
|
71713
|
-
value: function
|
71867
|
+
key: "handlePageMutation",
|
71868
|
+
value: function handlePageMutation() {
|
71869
|
+
this.handleRegions();
|
71870
|
+
}
|
71871
|
+
},
|
71872
|
+
{
|
71873
|
+
key: "handleRegions",
|
71874
|
+
value: function handleRegions() {
|
71714
71875
|
var _this, _loop = function(index) {
|
71715
71876
|
var element = elements2[index];
|
71716
71877
|
var previousContent = _to_consumable_array(element.childNodes);
|
71717
71878
|
var id = 500 + index;
|
71718
71879
|
var size = null;
|
71880
|
+
var adType = void 0;
|
71881
|
+
var regionName = void 0;
|
71719
71882
|
if (element.hasAttribute("data-b-t") && element.hasAttribute("data-b-n")) {
|
71720
|
-
|
71721
|
-
|
71883
|
+
adType = element.getAttribute("data-b-t");
|
71884
|
+
regionName = element.getAttribute("data-b-n") || void 0;
|
71722
71885
|
var sizes = ContentProvider.adSizes[adType];
|
71723
71886
|
if (sizes && sizes.length > 0) {
|
71724
71887
|
var _sizes_ = _sliced_to_array(sizes[0], 2), w2 = _sizes_[0], h = _sizes_[1];
|
@@ -71729,12 +71892,6 @@ var StaticAds = /*#__PURE__*/ function() {
|
|
71729
71892
|
} else {
|
71730
71893
|
_this.context.logger.error("Invalid attribute or no sizes found for adType: ".concat(adType, " and regionName: ").concat(regionName));
|
71731
71894
|
}
|
71732
|
-
} else if (element.hasAttribute("data-b-w") && element.hasAttribute("data-b-h")) {
|
71733
|
-
size = {
|
71734
|
-
width: Number(element.getAttribute("data-b-w")),
|
71735
|
-
height: Number(element.getAttribute("data-b-h"))
|
71736
|
-
};
|
71737
|
-
_this.context.logger.warn("Using deprecated attributes data-b-w and data-b-h for element: ".concat(element.getAttribute("data-b-n")));
|
71738
71895
|
}
|
71739
71896
|
if (!size) {
|
71740
71897
|
return "continue";
|
@@ -71777,6 +71934,11 @@ var StaticAds = /*#__PURE__*/ function() {
|
|
71777
71934
|
}
|
71778
71935
|
];
|
71779
71936
|
var newRegion = new StaticAdRegion(id, size, {
|
71937
|
+
ad: {
|
71938
|
+
type: adType,
|
71939
|
+
name: regionName
|
71940
|
+
}
|
71941
|
+
}, {
|
71780
71942
|
provider: provider,
|
71781
71943
|
plugins: plugins2,
|
71782
71944
|
recorder: _this.recorderFactory.create()
|
@@ -71785,20 +71947,31 @@ var StaticAds = /*#__PURE__*/ function() {
|
|
71785
71947
|
element.appendChild(newRegion.view);
|
71786
71948
|
_this.regions.push(newRegion);
|
71787
71949
|
};
|
71788
|
-
this.context.logger.log("starting static ads");
|
71789
71950
|
var selector = this.context.config.get("staticRegionsSelector");
|
71790
71951
|
if (!selector) {
|
71791
71952
|
return;
|
71792
71953
|
}
|
71793
71954
|
var elements2 = Array.from(document.querySelectorAll(selector)).filter(function(e2) {
|
71794
|
-
return _instanceof(e2, HTMLElement) &&
|
71955
|
+
return _instanceof(e2, HTMLElement) && e2.hasAttribute("data-b-t") && e2.hasAttribute("data-b-n") && e2.querySelector('[class="BRNDTS_R"]') === null && isElementVisible(e2);
|
71795
71956
|
});
|
71796
71957
|
for(var index = 0; index < elements2.length; index++)_this = this, _loop(index);
|
71797
71958
|
}
|
71798
71959
|
},
|
71960
|
+
{
|
71961
|
+
key: "start",
|
71962
|
+
value: function start() {
|
71963
|
+
this.context.logger.log("starting static ads");
|
71964
|
+
this.handleRegions();
|
71965
|
+
this.observer.observe(document.body, {
|
71966
|
+
childList: true,
|
71967
|
+
subtree: true
|
71968
|
+
});
|
71969
|
+
}
|
71970
|
+
},
|
71799
71971
|
{
|
71800
71972
|
key: "destroy",
|
71801
71973
|
value: function destroy() {
|
71974
|
+
this.observer.disconnect();
|
71802
71975
|
this.context.logger.log("destroying static ads");
|
71803
71976
|
this.regions.forEach(function(region) {
|
71804
71977
|
region.destroy();
|
@@ -74607,12 +74780,13 @@ var MappedCollection = /*#__PURE__*/ function() {
|
|
74607
74780
|
// src/Ads/Regions/AdRegion.ts
|
74608
74781
|
var AdRegion = /*#__PURE__*/ function(Region) {
|
74609
74782
|
_inherits(AdRegion, Region);
|
74610
|
-
function AdRegion(regionDescriptor, planeDescriptor, deps) {
|
74783
|
+
function AdRegion(regionDescriptor, planeDescriptor, options, deps) {
|
74611
74784
|
_class_call_check(this, AdRegion);
|
74612
74785
|
return _call_super(this, AdRegion, [
|
74613
74786
|
"".concat(regionDescriptor.id),
|
74614
74787
|
regionDescriptor,
|
74615
74788
|
planeDescriptor,
|
74789
|
+
options,
|
74616
74790
|
deps
|
74617
74791
|
]);
|
74618
74792
|
}
|
@@ -74635,12 +74809,13 @@ var AdRegion = /*#__PURE__*/ function(Region) {
|
|
74635
74809
|
// src/Ads/Regions/AuxRegion.ts
|
74636
74810
|
var AuxRegion = /*#__PURE__*/ function(Region) {
|
74637
74811
|
_inherits(AuxRegion, Region);
|
74638
|
-
function AuxRegion(regionDescriptor, planeDescriptor, deps) {
|
74812
|
+
function AuxRegion(regionDescriptor, planeDescriptor, options, deps) {
|
74639
74813
|
_class_call_check(this, AuxRegion);
|
74640
74814
|
return _call_super(this, AuxRegion, [
|
74641
74815
|
"".concat(regionDescriptor.id),
|
74642
74816
|
regionDescriptor,
|
74643
74817
|
planeDescriptor,
|
74818
|
+
options,
|
74644
74819
|
_object_spread({}, deps)
|
74645
74820
|
]);
|
74646
74821
|
}
|
@@ -74704,15 +74879,15 @@ var RegionFactory = /*#__PURE__*/ function() {
|
|
74704
74879
|
},
|
74705
74880
|
{
|
74706
74881
|
key: "get",
|
74707
|
-
value: function get(regionDescriptor, planeDescriptor, deps) {
|
74882
|
+
value: function get(regionDescriptor, planeDescriptor, options, deps) {
|
74708
74883
|
if (regionDescriptor && planeDescriptor) {
|
74709
74884
|
var _this_deps;
|
74710
74885
|
if ((_this_deps = this.deps) === null || _this_deps === void 0 ? void 0 : _this_deps.debug) {
|
74711
|
-
return new AuxRegion(regionDescriptor, planeDescriptor, _object_spread_props(_object_spread({}, this.deps || {}, deps || {}), {
|
74886
|
+
return new AuxRegion(regionDescriptor, planeDescriptor, options || {}, _object_spread_props(_object_spread({}, this.deps || {}, deps || {}), {
|
74712
74887
|
plugins: this.getPluginForStrategy()
|
74713
74888
|
}));
|
74714
74889
|
} else {
|
74715
|
-
return new AdRegion(regionDescriptor, planeDescriptor, _object_spread_props(_object_spread({}, this.deps || {}, deps || {}), {
|
74890
|
+
return new AdRegion(regionDescriptor, planeDescriptor, options || {}, _object_spread_props(_object_spread({}, this.deps || {}, deps || {}), {
|
74716
74891
|
plugins: this.getPluginForStrategy()
|
74717
74892
|
}));
|
74718
74893
|
}
|
@@ -74880,7 +75055,7 @@ var RegionRenderer = /*#__PURE__*/ function() {
|
|
74880
75055
|
}, {
|
74881
75056
|
width: this.regionsContainerView.width,
|
74882
75057
|
height: this.regionsContainerView.height
|
74883
|
-
}, {
|
75058
|
+
}, {}, {
|
74884
75059
|
provider: ContentProviderFactory.getProvider(this.context, this.context.config.get("ads").provider)
|
74885
75060
|
});
|
74886
75061
|
this.regionsData.push({
|
@@ -74957,7 +75132,7 @@ var RegionRenderer = /*#__PURE__*/ function() {
|
|
74957
75132
|
var newRegion = this.regionFactory.get(diffRight[index1], {
|
74958
75133
|
width: this.regionsContainerView.width,
|
74959
75134
|
height: this.regionsContainerView.height
|
74960
|
-
}, {
|
75135
|
+
}, {}, {
|
74961
75136
|
provider: ContentProviderFactory.getProvider(this.context, this.context.config.get("ads").provider)
|
74962
75137
|
});
|
74963
75138
|
this.regionsObjects.push(newRegion);
|
@@ -79788,7 +79963,7 @@ var AuxElementsRenderer = /*#__PURE__*/ function() {
|
|
79788
79963
|
}, {
|
79789
79964
|
width: this.regionsContainerView.width,
|
79790
79965
|
height: this.regionsContainerView.height
|
79791
|
-
}, {
|
79966
|
+
}, {}, {
|
79792
79967
|
provider: ContentProviderFactory.getProvider(this.context, this.context.config.get("ads").provider)
|
79793
79968
|
});
|
79794
79969
|
this.auxElementsData.push({
|
@@ -79850,7 +80025,7 @@ var AuxElementsRenderer = /*#__PURE__*/ function() {
|
|
79850
80025
|
}), {
|
79851
80026
|
width: this.regionsContainerView.width,
|
79852
80027
|
height: this.regionsContainerView.height
|
79853
|
-
}, {});
|
80028
|
+
}, {}, {});
|
79854
80029
|
this.regionsObjects.push(oldRegion);
|
79855
80030
|
this.regionsContainerView.append(oldRegion.view);
|
79856
80031
|
}
|
@@ -80142,11 +80317,11 @@ var VideoAd = /*#__PURE__*/ function() {
|
|
80142
80317
|
{
|
80143
80318
|
key: "destroy",
|
80144
80319
|
value: function destroy() {
|
80145
|
-
var _this_adPresentationStrategy, _this_regionsRenderer, _this_videoRegions, _this_videoAdContext_interface;
|
80320
|
+
var _this_adPresentationStrategy, _this_regionsRenderer, _this_videoRegions, _this_videoAdContext_recorder, _this_videoAdContext_interface;
|
80146
80321
|
(_this_adPresentationStrategy = this.adPresentationStrategy) === null || _this_adPresentationStrategy === void 0 ? void 0 : _this_adPresentationStrategy.destroy();
|
80147
80322
|
(_this_regionsRenderer = this.regionsRenderer) === null || _this_regionsRenderer === void 0 ? void 0 : _this_regionsRenderer.destroy();
|
80148
80323
|
(_this_videoRegions = this.videoRegions) === null || _this_videoRegions === void 0 ? void 0 : _this_videoRegions.destroy();
|
80149
|
-
this.videoAdContext.recorder.destroy();
|
80324
|
+
(_this_videoAdContext_recorder = this.videoAdContext.recorder) === null || _this_videoAdContext_recorder === void 0 ? void 0 : _this_videoAdContext_recorder.destroy();
|
80150
80325
|
(_this_videoAdContext_interface = this.videoAdContext.interface) === null || _this_videoAdContext_interface === void 0 ? void 0 : _this_videoAdContext_interface.destroy();
|
80151
80326
|
}
|
80152
80327
|
}
|