@brndts/brndts-ads 1.13.6 → 1.13.7
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 +51 -64
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -64
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -72250,19 +72250,6 @@ var StaticAdRegion = /*#__PURE__*/ function(Region) {
|
|
72250
72250
|
return StaticAdRegion;
|
72251
72251
|
}(Region);
|
72252
72252
|
// src/Ads/StaticAds/StaticAds.ts
|
72253
|
-
function debounce3(func) {
|
72254
|
-
var timeout = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 100;
|
72255
|
-
var timer;
|
72256
|
-
return function() {
|
72257
|
-
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
72258
|
-
args[_key] = arguments[_key];
|
72259
|
-
}
|
72260
|
-
clearTimeout(timer);
|
72261
|
-
timer = setTimeout(function() {
|
72262
|
-
func.apply(void 0, _to_consumable_array(args));
|
72263
|
-
}, timeout);
|
72264
|
-
};
|
72265
|
-
}
|
72266
72253
|
function isElementVisible(element) {
|
72267
72254
|
if (!element) return false;
|
72268
72255
|
if (!document.contains(element)) return false;
|
@@ -72280,7 +72267,6 @@ var StaticAds = /*#__PURE__*/ function() {
|
|
72280
72267
|
this.handlePageMutation = this.handlePageMutation.bind(this);
|
72281
72268
|
this.context = context;
|
72282
72269
|
this.recorderFactory = new RecorderFactory(this.context);
|
72283
|
-
this.observer = new MutationObserver(debounce3(this.handlePageMutation));
|
72284
72270
|
}
|
72285
72271
|
_create_class(StaticAds, [
|
72286
72272
|
{
|
@@ -72382,16 +72368,11 @@ var StaticAds = /*#__PURE__*/ function() {
|
|
72382
72368
|
value: function start() {
|
72383
72369
|
this.context.logger.log("starting static ads");
|
72384
72370
|
this.handleRegions();
|
72385
|
-
this.observer.observe(document.body, {
|
72386
|
-
childList: true,
|
72387
|
-
subtree: true
|
72388
|
-
});
|
72389
72371
|
}
|
72390
72372
|
},
|
72391
72373
|
{
|
72392
72374
|
key: "destroy",
|
72393
72375
|
value: function destroy() {
|
72394
|
-
this.observer.disconnect();
|
72395
72376
|
this.context.logger.log("destroying static ads");
|
72396
72377
|
this.regions.forEach(function(region) {
|
72397
72378
|
region.destroy();
|
@@ -81408,41 +81389,6 @@ var MediaElementSizeController = /*#__PURE__*/ function(_import_events9_default)
|
|
81408
81389
|
return updated;
|
81409
81390
|
}
|
81410
81391
|
},
|
81411
|
-
{
|
81412
|
-
key: "recalculate",
|
81413
|
-
value: function recalculate() {
|
81414
|
-
if (!this.isResized) {
|
81415
|
-
return this.restore();
|
81416
|
-
}
|
81417
|
-
var updated = false;
|
81418
|
-
if (this.context.media.view) {
|
81419
|
-
var _this_context_elements_container, _this_context_elements_container1, _this_context_elements_container2, _this_context_elements_container3;
|
81420
|
-
var size = adjustSizeWithAspectRatio((((_this_context_elements_container = this.context.elements.container) === null || _this_context_elements_container === void 0 ? void 0 : _this_context_elements_container.getBoundingClientRect().width) || 0) * (this.sizePercentage / 100), (((_this_context_elements_container1 = this.context.elements.container) === null || _this_context_elements_container1 === void 0 ? void 0 : _this_context_elements_container1.getBoundingClientRect().height) || 0) * (this.sizePercentage / 100), this.context.media.aspectRatio);
|
81421
|
-
if (size.width !== this.size.width || size.height !== this.size.height) {
|
81422
|
-
this.size = size;
|
81423
|
-
this.context.media.view.style.width = "".concat(this.size.width, "px");
|
81424
|
-
this.context.media.view.style.height = "".concat(this.size.height, "px");
|
81425
|
-
this.context.media.setSize(this.size.width, this.size.height);
|
81426
|
-
updated = true;
|
81427
|
-
}
|
81428
|
-
var adjustedPosition = adjustSizeWithAspectRatio((((_this_context_elements_container2 = this.context.elements.container) === null || _this_context_elements_container2 === void 0 ? void 0 : _this_context_elements_container2.getBoundingClientRect().width) || 0) * (this.positionOffset / 100), (((_this_context_elements_container3 = this.context.elements.container) === null || _this_context_elements_container3 === void 0 ? void 0 : _this_context_elements_container3.getBoundingClientRect().height) || 0) * (this.positionOffset / 100), this.context.media.aspectRatio);
|
81429
|
-
var marginValue = Math.min(adjustedPosition.width, adjustedPosition.height);
|
81430
|
-
if (this.position.x !== marginValue || this.position.y !== marginValue) {
|
81431
|
-
var _this_context_interface;
|
81432
|
-
this.position.x = marginValue;
|
81433
|
-
this.position.y = marginValue;
|
81434
|
-
this.context.media.view.style.left = "".concat(this.position.x, "px");
|
81435
|
-
this.context.media.view.style.top = "".concat(this.position.y, "px");
|
81436
|
-
(_this_context_interface = this.context.interface) === null || _this_context_interface === void 0 ? void 0 : _this_context_interface.updatePosition(marginValue, marginValue);
|
81437
|
-
updated = true;
|
81438
|
-
}
|
81439
|
-
}
|
81440
|
-
if (updated) {
|
81441
|
-
this.emit("UPDATED");
|
81442
|
-
}
|
81443
|
-
return updated;
|
81444
|
-
}
|
81445
|
-
},
|
81446
81392
|
{
|
81447
81393
|
key: "update",
|
81448
81394
|
value: function update(percentage) {
|
@@ -81530,8 +81476,6 @@ var BasicPresentationMode = /*#__PURE__*/ function() {
|
|
81530
81476
|
this.context = context;
|
81531
81477
|
this.mediaElementSizeController = new MediaElementSizeController(context);
|
81532
81478
|
this.packer = new RegionPacker(this.context);
|
81533
|
-
this.mediaElementSizeController.on("UPDATED", function() {});
|
81534
|
-
this.packer.on("PACKED", function() {});
|
81535
81479
|
}
|
81536
81480
|
_create_class(BasicPresentationMode, [
|
81537
81481
|
{
|
@@ -81633,11 +81577,15 @@ var BasicPresentationMode = /*#__PURE__*/ function() {
|
|
81633
81577
|
width: ((_this_mediaElementSizeController3 = this.mediaElementSizeController) === null || _this_mediaElementSizeController3 === void 0 ? void 0 : _this_mediaElementSizeController3.size.width) || 0,
|
81634
81578
|
height: ((_this_mediaElementSizeController4 = this.mediaElementSizeController) === null || _this_mediaElementSizeController4 === void 0 ? void 0 : _this_mediaElementSizeController4.size.height) || 0
|
81635
81579
|
}, fullscreen ? "fullscreen" : "default");
|
81636
|
-
|
81637
|
-
if (
|
81580
|
+
this.packer.repack();
|
81581
|
+
if (this.packer.packed.length > 0) {
|
81638
81582
|
var _this_regionsRenderer1, _this_regionsRenderer2;
|
81639
81583
|
(_this_regionsRenderer1 = this.regionsRenderer) === null || _this_regionsRenderer1 === void 0 ? void 0 : _this_regionsRenderer1.addAreas(this.packer.areas);
|
81640
81584
|
(_this_regionsRenderer2 = this.regionsRenderer) === null || _this_regionsRenderer2 === void 0 ? void 0 : _this_regionsRenderer2.render(this.packer.packed);
|
81585
|
+
} else {
|
81586
|
+
var _this_regionsRenderer3, _this_mediaElementSizeController5;
|
81587
|
+
(_this_regionsRenderer3 = this.regionsRenderer) === null || _this_regionsRenderer3 === void 0 ? void 0 : _this_regionsRenderer3.clear();
|
81588
|
+
(_this_mediaElementSizeController5 = this.mediaElementSizeController) === null || _this_mediaElementSizeController5 === void 0 ? void 0 : _this_mediaElementSizeController5.restore();
|
81641
81589
|
}
|
81642
81590
|
}
|
81643
81591
|
}
|
@@ -82680,22 +82628,32 @@ var VideoAds = /*#__PURE__*/ function() {
|
|
82680
82628
|
function VideoAds(context) {
|
82681
82629
|
_class_call_check(this, VideoAds);
|
82682
82630
|
this.videoAdElements = [];
|
82631
|
+
this.handlePageMutation = this.handlePageMutation.bind(this);
|
82683
82632
|
this.context = context;
|
82684
82633
|
}
|
82685
82634
|
_create_class(VideoAds, [
|
82686
82635
|
{
|
82687
|
-
key: "
|
82688
|
-
value: function
|
82689
|
-
if (!this.context.supports.api) {
|
82690
|
-
this.context.logger.error("Setup failed: no support");
|
82691
|
-
return;
|
82692
|
-
}
|
82636
|
+
key: "handleMedias",
|
82637
|
+
value: function handleMedias() {
|
82693
82638
|
try {
|
82639
|
+
var elements2 = [];
|
82640
|
+
for(var index = 0; index < this.videoAdElements.length; index++){
|
82641
|
+
var element = this.videoAdElements[index];
|
82642
|
+
if (element.media.view && document.body.contains(element.media.view)) {
|
82643
|
+
elements2.push(element);
|
82644
|
+
} else {
|
82645
|
+
element.destroy();
|
82646
|
+
}
|
82647
|
+
}
|
82648
|
+
this.videoAdElements = elements2;
|
82694
82649
|
var medias = MediaElementFactory.getElements(this.context.selectors.targets);
|
82695
82650
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
82696
82651
|
try {
|
82697
82652
|
for(var _iterator = medias[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
82698
82653
|
var media = _step.value;
|
82654
|
+
if (!media || media.closest("#BRNDTS_R") || media.querySelector("#BRNDTS_R")) {
|
82655
|
+
continue;
|
82656
|
+
}
|
82699
82657
|
var videoAd = new VideoAd(this.context, media);
|
82700
82658
|
this.videoAdElements.push(videoAd);
|
82701
82659
|
videoAd.start();
|
@@ -82721,6 +82679,22 @@ var VideoAds = /*#__PURE__*/ function() {
|
|
82721
82679
|
}
|
82722
82680
|
}
|
82723
82681
|
},
|
82682
|
+
{
|
82683
|
+
key: "start",
|
82684
|
+
value: function start() {
|
82685
|
+
if (!this.context.supports.api) {
|
82686
|
+
this.context.logger.error("Setup failed: no support");
|
82687
|
+
return;
|
82688
|
+
}
|
82689
|
+
this.handleMedias();
|
82690
|
+
}
|
82691
|
+
},
|
82692
|
+
{
|
82693
|
+
key: "handlePageMutation",
|
82694
|
+
value: function handlePageMutation() {
|
82695
|
+
this.handleMedias();
|
82696
|
+
}
|
82697
|
+
},
|
82724
82698
|
{
|
82725
82699
|
key: "updateSize",
|
82726
82700
|
value: function updateSize() {
|
@@ -82774,16 +82748,28 @@ var Ads = /*#__PURE__*/ function() {
|
|
82774
82748
|
"use strict";
|
82775
82749
|
function Ads(context) {
|
82776
82750
|
_class_call_check(this, Ads);
|
82751
|
+
this.handlePageMutation = functions_default.debounce(this.handlePageMutation.bind(this), 100);
|
82777
82752
|
this.context = context;
|
82778
82753
|
this.videoAds = new VideoAds(this.context);
|
82779
82754
|
this.staticAds = new StaticAds(this.context);
|
82755
|
+
this.observer = new MutationObserver(this.handlePageMutation);
|
82780
82756
|
}
|
82781
82757
|
_create_class(Ads, [
|
82758
|
+
{
|
82759
|
+
key: "handlePageMutation",
|
82760
|
+
value: function handlePageMutation() {
|
82761
|
+
this.videoAds.handlePageMutation();
|
82762
|
+
this.staticAds.handlePageMutation();
|
82763
|
+
}
|
82764
|
+
},
|
82782
82765
|
{
|
82783
82766
|
key: "start",
|
82784
82767
|
value: function start() {
|
82785
82768
|
this.videoAds.start();
|
82786
82769
|
this.staticAds.start();
|
82770
|
+
this.observer.observe(document.body, {
|
82771
|
+
childList: true
|
82772
|
+
});
|
82787
82773
|
}
|
82788
82774
|
},
|
82789
82775
|
{
|
@@ -82796,6 +82782,7 @@ var Ads = /*#__PURE__*/ function() {
|
|
82796
82782
|
key: "destroy",
|
82797
82783
|
value: function destroy() {
|
82798
82784
|
var _GooglePublisherTag_get;
|
82785
|
+
this.observer.disconnect();
|
82799
82786
|
this.videoAds.destroy();
|
82800
82787
|
this.staticAds.destroy();
|
82801
82788
|
(_GooglePublisherTag_get = GooglePublisherTag.get()) === null || _GooglePublisherTag_get === void 0 ? void 0 : _GooglePublisherTag_get.destroy();
|