@brndts/brndts-ads 1.13.5 → 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.css +0 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +263 -212
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +263 -212
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -67434,6 +67434,17 @@ var Awaitable = /*#__PURE__*/ function() {
|
|
67434
67434
|
});
|
67435
67435
|
}
|
67436
67436
|
_create_class(Awaitable, [
|
67437
|
+
{
|
67438
|
+
key: "reset",
|
67439
|
+
value: function reset(value2) {
|
67440
|
+
var _this = this;
|
67441
|
+
this._value = value2;
|
67442
|
+
this._promise = new Promise(function(resolve, reject) {
|
67443
|
+
_this._resolve = resolve;
|
67444
|
+
_this._reject = reject;
|
67445
|
+
});
|
67446
|
+
}
|
67447
|
+
},
|
67437
67448
|
{
|
67438
67449
|
key: "value",
|
67439
67450
|
get: function get() {
|
@@ -69775,6 +69786,7 @@ var AffiliateProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
69775
69786
|
image.style.height = affiliate.size.h + "px";
|
69776
69787
|
image.style.maxWidth = affiliate.size.w + "px";
|
69777
69788
|
image.style.maxHeight = affiliate.size.h + "px";
|
69789
|
+
image.style.display = "block";
|
69778
69790
|
image.setAttribute("src", affiliate.img);
|
69779
69791
|
if (affiliate.url) {
|
69780
69792
|
image.addEventListener("click", function() {
|
@@ -71232,10 +71244,16 @@ var RegionContent = /*#__PURE__*/ function() {
|
|
71232
71244
|
this.container.dataset.state = this.box.area(this.plane.size) > 0 ? "visible" : "hidden";
|
71233
71245
|
}
|
71234
71246
|
},
|
71247
|
+
{
|
71248
|
+
key: "hide",
|
71249
|
+
value: function hide() {
|
71250
|
+
this.container.dataset.state = "hidden";
|
71251
|
+
}
|
71252
|
+
},
|
71235
71253
|
{
|
71236
71254
|
key: "clear",
|
71237
71255
|
value: function clear() {
|
71238
|
-
this.
|
71256
|
+
this.hide();
|
71239
71257
|
this.content = void 0;
|
71240
71258
|
this.scale = null;
|
71241
71259
|
}
|
@@ -71536,6 +71554,7 @@ var Region = /*#__PURE__*/ function() {
|
|
71536
71554
|
this.onScreen = false;
|
71537
71555
|
this.visible = false;
|
71538
71556
|
this.plugins = [];
|
71557
|
+
this.hidden = new Awaitable(false);
|
71539
71558
|
this.id = id;
|
71540
71559
|
this.regionDescriptor = regionDescriptor;
|
71541
71560
|
this.options = options;
|
@@ -72161,19 +72180,6 @@ var StaticAdRegion = /*#__PURE__*/ function(Region) {
|
|
72161
72180
|
return StaticAdRegion;
|
72162
72181
|
}(Region);
|
72163
72182
|
// src/Ads/StaticAds/StaticAds.ts
|
72164
|
-
function debounce3(func) {
|
72165
|
-
var timeout = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 100;
|
72166
|
-
var timer;
|
72167
|
-
return function() {
|
72168
|
-
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
72169
|
-
args[_key] = arguments[_key];
|
72170
|
-
}
|
72171
|
-
clearTimeout(timer);
|
72172
|
-
timer = setTimeout(function() {
|
72173
|
-
func.apply(void 0, _to_consumable_array(args));
|
72174
|
-
}, timeout);
|
72175
|
-
};
|
72176
|
-
}
|
72177
72183
|
function isElementVisible(element) {
|
72178
72184
|
if (!element) return false;
|
72179
72185
|
if (!document.contains(element)) return false;
|
@@ -72190,7 +72196,6 @@ var StaticAds = /*#__PURE__*/ function() {
|
|
72190
72196
|
this.handlePageMutation = this.handlePageMutation.bind(this);
|
72191
72197
|
this.context = context;
|
72192
72198
|
this.recorderFactory = new RecorderFactory(this.context);
|
72193
|
-
this.observer = new MutationObserver(debounce3(this.handlePageMutation));
|
72194
72199
|
}
|
72195
72200
|
_create_class(StaticAds, [
|
72196
72201
|
{
|
@@ -72292,16 +72297,11 @@ var StaticAds = /*#__PURE__*/ function() {
|
|
72292
72297
|
value: function start() {
|
72293
72298
|
this.context.logger.log("starting static ads");
|
72294
72299
|
this.handleRegions();
|
72295
|
-
this.observer.observe(document.body, {
|
72296
|
-
childList: true,
|
72297
|
-
subtree: true
|
72298
|
-
});
|
72299
72300
|
}
|
72300
72301
|
},
|
72301
72302
|
{
|
72302
72303
|
key: "destroy",
|
72303
72304
|
value: function destroy() {
|
72304
|
-
this.observer.disconnect();
|
72305
72305
|
this.context.logger.log("destroying static ads");
|
72306
72306
|
this.regions.forEach(function(region) {
|
72307
72307
|
region.destroy();
|
@@ -80174,20 +80174,52 @@ var TYPES = {
|
|
80174
80174
|
var DefaultTemplate = /*#__PURE__*/ function() {
|
80175
80175
|
function DefaultTemplate() {
|
80176
80176
|
_class_call_check(this, DefaultTemplate);
|
80177
|
+
this.margin = {
|
80178
|
+
t: 0,
|
80179
|
+
r: 0,
|
80180
|
+
b: 64,
|
80181
|
+
l: 0
|
80182
|
+
};
|
80177
80183
|
}
|
80178
80184
|
_create_class(DefaultTemplate, [
|
80179
80185
|
{
|
80186
|
+
// get(plane: Plane.Descriptor, cutout: Cutout): PackingRegion[] {
|
80187
|
+
// const areas = [];
|
80188
|
+
// // Region A: Right strip (cutout height)
|
80189
|
+
// if (plane.width - (cutout.x + cutout.width) > 0) {
|
80190
|
+
// areas.push({
|
80191
|
+
// dimensions: new Dimensions(
|
80192
|
+
// { x: this.margin.l + cutout.x + cutout.width, y: this.margin.t + 0 },
|
80193
|
+
// { width: plane.width - (this.margin.l+this.margin.r) - (cutout.x + cutout.width), height: cutout.y + cutout.height }
|
80194
|
+
// ),
|
80195
|
+
// name: 'A',
|
80196
|
+
// maxSlots: 3, // Maximum slots for this region
|
80197
|
+
// });
|
80198
|
+
// }
|
80199
|
+
// // Region B: bottom-left strip (excluding cutout)
|
80200
|
+
// if (plane.height - (cutout.y + cutout.height) > 0) {
|
80201
|
+
// areas.push({
|
80202
|
+
// dimensions: new Dimensions(
|
80203
|
+
// { x: this.margin.l + 0, y: cutout.y + cutout.height },
|
80204
|
+
// { width: plane.width - (this.margin.l + this.margin.r), height: plane.height - (this.margin.t + this.margin.b) - (cutout.y + cutout.height) }
|
80205
|
+
// ),
|
80206
|
+
// name: 'B',
|
80207
|
+
// maxSlots: 1, // Maximum slots for this region
|
80208
|
+
// });
|
80209
|
+
// }
|
80210
|
+
// return areas;
|
80211
|
+
// }
|
80180
80212
|
key: "get",
|
80181
80213
|
value: function get(plane, cutout) {
|
80182
80214
|
var areas = [];
|
80183
80215
|
if (plane.width - (cutout.x + cutout.width) > 0) {
|
80184
80216
|
areas.push({
|
80185
80217
|
dimensions: new Dimensions({
|
80186
|
-
x: cutout.x + cutout.width,
|
80187
|
-
y: 0
|
80218
|
+
x: this.margin.l + cutout.x + cutout.width,
|
80219
|
+
y: this.margin.t + 0
|
80188
80220
|
}, {
|
80189
80221
|
width: plane.width - (cutout.x + cutout.width),
|
80190
|
-
height:
|
80222
|
+
height: plane.height - (this.margin.t + this.margin.b)
|
80191
80223
|
}),
|
80192
80224
|
name: "A",
|
80193
80225
|
maxSlots: 3
|
@@ -80196,12 +80228,14 @@ var DefaultTemplate = /*#__PURE__*/ function() {
|
|
80196
80228
|
if (plane.height - (cutout.y + cutout.height) > 0) {
|
80197
80229
|
areas.push({
|
80198
80230
|
dimensions: new Dimensions({
|
80199
|
-
x: 0,
|
80200
|
-
y: cutout.y + cutout.height
|
80231
|
+
x: this.margin.l + 0,
|
80232
|
+
y: this.margin.t + cutout.y + cutout.height
|
80201
80233
|
}, {
|
80202
|
-
width:
|
80203
|
-
height: plane.height - (cutout.y + cutout.height)
|
80234
|
+
width: cutout.x + cutout.width,
|
80235
|
+
height: plane.height - (this.margin.t + this.margin.b) - (cutout.y + cutout.height)
|
80204
80236
|
}),
|
80237
|
+
available: {
|
80238
|
+
},
|
80205
80239
|
name: "B",
|
80206
80240
|
maxSlots: 1
|
80207
80241
|
});
|
@@ -80215,6 +80249,12 @@ var DefaultTemplate = /*#__PURE__*/ function() {
|
|
80215
80249
|
var FullscreenTemplate = /*#__PURE__*/ function() {
|
80216
80250
|
function FullscreenTemplate() {
|
80217
80251
|
_class_call_check(this, FullscreenTemplate);
|
80252
|
+
this.margin = {
|
80253
|
+
t: 0,
|
80254
|
+
r: 0,
|
80255
|
+
b: 64,
|
80256
|
+
l: 0
|
80257
|
+
};
|
80218
80258
|
}
|
80219
80259
|
_create_class(FullscreenTemplate, [
|
80220
80260
|
{
|
@@ -80224,11 +80264,11 @@ var FullscreenTemplate = /*#__PURE__*/ function() {
|
|
80224
80264
|
if (plane.width - (cutout.x + cutout.width) > 0) {
|
80225
80265
|
areas.push({
|
80226
80266
|
dimensions: new Dimensions({
|
80227
|
-
x: cutout.x + cutout.width,
|
80228
|
-
y: 0
|
80267
|
+
x: this.margin.l + cutout.x + cutout.width,
|
80268
|
+
y: this.margin.t + 0
|
80229
80269
|
}, {
|
80230
80270
|
width: plane.width - (cutout.x + cutout.width),
|
80231
|
-
height: plane.height
|
80271
|
+
height: plane.height - (this.margin.t + this.margin.b)
|
80232
80272
|
}),
|
80233
80273
|
name: "A",
|
80234
80274
|
maxSlots: 3
|
@@ -80237,11 +80277,11 @@ var FullscreenTemplate = /*#__PURE__*/ function() {
|
|
80237
80277
|
if (plane.height - (cutout.y + cutout.height) > 0) {
|
80238
80278
|
areas.push({
|
80239
80279
|
dimensions: new Dimensions({
|
80240
|
-
x: 0,
|
80241
|
-
y: cutout.y + cutout.height
|
80280
|
+
x: this.margin.l + 0,
|
80281
|
+
y: this.margin.t + cutout.y + cutout.height
|
80242
80282
|
}, {
|
80243
80283
|
width: cutout.x + cutout.width,
|
80244
|
-
height: plane.height - (cutout.y + cutout.height)
|
80284
|
+
height: plane.height - (this.margin.t + this.margin.b) - (cutout.y + cutout.height)
|
80245
80285
|
}),
|
80246
80286
|
available: {
|
80247
80287
|
w: 0.7
|
@@ -80614,10 +80654,11 @@ var BasicAdRegion = /*#__PURE__*/ function(Region) {
|
|
80614
80654
|
key: "hideRegion",
|
80615
80655
|
value: function hideRegion() {
|
80616
80656
|
return _async_to_generator(function() {
|
80617
|
-
var _this_deps_recorder;
|
80618
80657
|
return _ts_generator(this, function(_state) {
|
80619
80658
|
switch(_state.label){
|
80620
80659
|
case 0:
|
80660
|
+
this.hidden.reset(false);
|
80661
|
+
this.content.hide();
|
80621
80662
|
return [
|
80622
80663
|
4,
|
80623
80664
|
this.applyPlugins("beforeHide")
|
@@ -80630,7 +80671,7 @@ var BasicAdRegion = /*#__PURE__*/ function(Region) {
|
|
80630
80671
|
this.content.clear();
|
80631
80672
|
this.applyPlugins("afterHide");
|
80632
80673
|
this.visible = false;
|
80633
|
-
|
80674
|
+
this.hidden.resolve(true);
|
80634
80675
|
return [
|
80635
80676
|
2
|
80636
80677
|
];
|
@@ -80639,30 +80680,40 @@ var BasicAdRegion = /*#__PURE__*/ function(Region) {
|
|
80639
80680
|
}).call(this);
|
80640
80681
|
}
|
80641
80682
|
},
|
80683
|
+
{
|
80684
|
+
key: "showRegion",
|
80685
|
+
value: function showRegion() {
|
80686
|
+
return _async_to_generator(function() {
|
80687
|
+
var _this_deps_recorder;
|
80688
|
+
return _ts_generator(this, function(_state) {
|
80689
|
+
this.applyPlugins("beforeShow");
|
80690
|
+
this.container.style.display = "block";
|
80691
|
+
this.container.style.position = "relative";
|
80692
|
+
this.container.style.width = "".concat(this.box.width(this.plane.size), "px");
|
80693
|
+
this.container.style.height = "".concat(this.box.height(this.plane.size), "px");
|
80694
|
+
this.content.render();
|
80695
|
+
this.applyPlugins("afterShow");
|
80696
|
+
this.visible = true;
|
80697
|
+
(_this_deps_recorder = this.deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.presentationStateChanged(this, true);
|
80698
|
+
return [
|
80699
|
+
2
|
80700
|
+
];
|
80701
|
+
});
|
80702
|
+
}).call(this);
|
80703
|
+
}
|
80704
|
+
},
|
80642
80705
|
{
|
80643
80706
|
key: "render",
|
80644
80707
|
value: function render(contours, box) {
|
80645
80708
|
return _async_to_generator(function() {
|
80646
|
-
var _this_deps_recorder;
|
80647
80709
|
return _ts_generator(this, function(_state) {
|
80648
80710
|
this.applyPlugins("beforeRender");
|
80649
80711
|
if (this.shouldPresent()) {
|
80650
|
-
;
|
80651
|
-
this.applyPlugins("beforeShow");
|
80652
|
-
this.container.style.display = "block";
|
80653
|
-
this.container.style.position = "relative";
|
80654
|
-
this.container.style.width = "".concat(this.box.width(this.plane.size), "px");
|
80655
|
-
this.container.style.height = "".concat(this.box.height(this.plane.size), "px");
|
80656
|
-
this.content.render();
|
80657
|
-
this.applyPlugins("afterShow");
|
80658
|
-
this.visible = true;
|
80659
|
-
(_this_deps_recorder = this.deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.presentationStateChanged(this, true);
|
80712
|
+
this.showRegion();
|
80660
80713
|
} else if (this.shouldHide()) {
|
80661
80714
|
this.hideRegion();
|
80662
80715
|
} else {
|
80663
80716
|
if (this.visible) {
|
80664
|
-
this.container.style.width = "".concat(this.box.width(this.plane.size), "px");
|
80665
|
-
this.container.style.height = "".concat(this.box.height(this.plane.size), "px");
|
80666
80717
|
this.applyPlugins("reRender");
|
80667
80718
|
}
|
80668
80719
|
}
|
@@ -80674,48 +80725,6 @@ var BasicAdRegion = /*#__PURE__*/ function(Region) {
|
|
80674
80725
|
}).call(this);
|
80675
80726
|
}
|
80676
80727
|
},
|
80677
|
-
{
|
80678
|
-
key: "shouldRequestContent",
|
80679
|
-
value: function shouldRequestContent(newBox) {
|
80680
|
-
if (this.box.area({
|
80681
|
-
width: 1,
|
80682
|
-
height: 1
|
80683
|
-
}) <= 0 && newBox.area({
|
80684
|
-
width: 1,
|
80685
|
-
height: 1
|
80686
|
-
}) > 0) {
|
80687
|
-
return true;
|
80688
|
-
}
|
80689
|
-
if (this.box.isEqual(newBox.coords)) {
|
80690
|
-
return false;
|
80691
|
-
}
|
80692
|
-
if (newBox.area(this.plane.size) <= 0) {
|
80693
|
-
return false;
|
80694
|
-
}
|
80695
|
-
if (newBox.area(this.plane.size) === this.box.area(this.plane.size)) {
|
80696
|
-
return false;
|
80697
|
-
}
|
80698
|
-
if (Math.abs(newBox.area({
|
80699
|
-
width: 1,
|
80700
|
-
height: 1
|
80701
|
-
}) - this.box.area({
|
80702
|
-
width: 1,
|
80703
|
-
height: 1
|
80704
|
-
})) < 0.05) {
|
80705
|
-
return false;
|
80706
|
-
}
|
80707
|
-
if (Math.abs(newBox.aspectRatio({
|
80708
|
-
width: 1,
|
80709
|
-
height: 1
|
80710
|
-
}) - this.box.aspectRatio({
|
80711
|
-
width: 1,
|
80712
|
-
height: 1
|
80713
|
-
})) > 0.05) {
|
80714
|
-
return false;
|
80715
|
-
}
|
80716
|
-
return true;
|
80717
|
-
}
|
80718
|
-
},
|
80719
80728
|
{
|
80720
80729
|
key: "updateSize",
|
80721
80730
|
value: function updateSize(width, height) {
|
@@ -80745,7 +80754,10 @@ var BasicAdRegion = /*#__PURE__*/ function(Region) {
|
|
80745
80754
|
value: function clear() {
|
80746
80755
|
var _this = this;
|
80747
80756
|
this.hideRegion().then(function() {
|
80748
|
-
_this.
|
80757
|
+
_this.plane.update({
|
80758
|
+
width: 0,
|
80759
|
+
height: 0
|
80760
|
+
});
|
80749
80761
|
});
|
80750
80762
|
}
|
80751
80763
|
}
|
@@ -80935,83 +80947,116 @@ var AdRegionsArea = /*#__PURE__*/ function() {
|
|
80935
80947
|
{
|
80936
80948
|
key: "render",
|
80937
80949
|
value: function render(regions2) {
|
80938
|
-
|
80939
|
-
|
80940
|
-
return
|
80941
|
-
|
80942
|
-
|
80943
|
-
|
80944
|
-
|
80945
|
-
|
80946
|
-
|
80947
|
-
|
80948
|
-
for(var index = 0; index < diffLeft.length; index++){
|
80949
|
-
var existingObject = this.regionsObjects.getById(diffLeft[index].id);
|
80950
|
-
if (existingObject) {
|
80951
|
-
existingObject.clear();
|
80952
|
-
}
|
80953
|
-
}
|
80954
|
-
if (common.length) {
|
80955
|
-
for(var index1 = 0; index1 < common.length; index1++){
|
80956
|
-
if (index1 < this.maxRegions) {
|
80957
|
-
var pack = mapped.getById(common[index1].id);
|
80958
|
-
if (pack) {
|
80959
|
-
common[index1].updateSize(pack.width, pack.height);
|
80960
|
-
}
|
80961
|
-
} else {
|
80962
|
-
common[index1].clear();
|
80963
|
-
}
|
80964
|
-
}
|
80965
|
-
} else {
|
80966
|
-
for(var index2 = 0; index2 < diffRight.length && index2 < this.maxRegions; index2++){
|
80967
|
-
var existingObject1 = this.regionsObjects.getById(diffRight[index2].id);
|
80968
|
-
if (existingObject1) {
|
80969
|
-
var pack1 = mapped.getById(diffRight[index2].id);
|
80970
|
-
if (pack1) {
|
80971
|
-
existingObject1.updateSize(pack1.width, pack1.height);
|
80972
|
-
}
|
80973
|
-
} else {
|
80974
|
-
var region = diffRight[index2];
|
80975
|
-
var provider = ContentProviderFactory.getProvider(this.context, this.context.config.get("ads").provider);
|
80976
|
-
var plugins2 = [
|
80977
|
-
// new RegionBorderPlugin(),
|
80978
|
-
new RegionAnimationPlugin("OPACITY")
|
80979
|
-
];
|
80980
|
-
var newRegion = new BasicAdRegion(region.id, {
|
80981
|
-
width: region.width,
|
80982
|
-
height: region.height
|
80983
|
-
}, {
|
80984
|
-
ad: {
|
80985
|
-
type: region.type,
|
80986
|
-
name: region.region
|
80950
|
+
return _async_to_generator(function() {
|
80951
|
+
var mapped, visibleRegions, diffLeft, diffRight, pending, common, index, existingObject2, index1, pack, index2, existingObject21, pack1, region, provider, plugins2, newRegion;
|
80952
|
+
return _ts_generator(this, function(_state) {
|
80953
|
+
switch(_state.label){
|
80954
|
+
case 0:
|
80955
|
+
if (!regions2 || !regions2.length) {
|
80956
|
+
this.clear();
|
80957
|
+
return [
|
80958
|
+
2
|
80959
|
+
];
|
80987
80960
|
}
|
80988
|
-
|
80989
|
-
|
80990
|
-
|
80991
|
-
|
80992
|
-
|
80993
|
-
|
80994
|
-
|
80995
|
-
|
80961
|
+
mapped = new MappedCollection();
|
80962
|
+
mapped.load(regions2);
|
80963
|
+
visibleRegions = this.regionsObjects.getVisible();
|
80964
|
+
diffLeft = getDifferenceLeft(visibleRegions, regions2);
|
80965
|
+
diffRight = getDifferenceRight(visibleRegions, regions2);
|
80966
|
+
pending = [];
|
80967
|
+
common = getIntersection(visibleRegions, regions2);
|
80968
|
+
for(index = 0; index < diffLeft.length; index++){
|
80969
|
+
existingObject2 = this.regionsObjects.getById(diffLeft[index].id);
|
80970
|
+
if (existingObject2) {
|
80971
|
+
existingObject2.updateSize(0, 0);
|
80972
|
+
pending.push(existingObject2.hidden.promise);
|
80973
|
+
}
|
80974
|
+
}
|
80975
|
+
if (!common.length) return [
|
80976
|
+
3,
|
80977
|
+
1
|
80978
|
+
];
|
80979
|
+
for(index1 = 0; index1 < common.length; index1++){
|
80980
|
+
if (index1 < this.maxRegions) {
|
80981
|
+
pack = mapped.getById(common[index1].id);
|
80982
|
+
if (pack) {
|
80983
|
+
common[index1].updateSize(pack.width, pack.height);
|
80984
|
+
}
|
80985
|
+
} else {
|
80986
|
+
common[index1].updateSize(0, 0);
|
80987
|
+
pending.push(existingObject.hidden.promise);
|
80988
|
+
}
|
80989
|
+
}
|
80990
|
+
return [
|
80991
|
+
3,
|
80992
|
+
3
|
80993
|
+
];
|
80994
|
+
case 1:
|
80995
|
+
return [
|
80996
|
+
4,
|
80997
|
+
Promise.all(pending)
|
80998
|
+
];
|
80999
|
+
case 2:
|
81000
|
+
_state.sent();
|
81001
|
+
for(index2 = 0; index2 < diffRight.length && index2 < this.maxRegions; index2++){
|
81002
|
+
existingObject21 = this.regionsObjects.getById(diffRight[index2].id);
|
81003
|
+
if (existingObject21) {
|
81004
|
+
pack1 = mapped.getById(diffRight[index2].id);
|
81005
|
+
if (pack1) {
|
81006
|
+
existingObject21.updateSize(pack1.width, pack1.height);
|
81007
|
+
}
|
81008
|
+
} else {
|
81009
|
+
region = diffRight[index2];
|
81010
|
+
provider = ContentProviderFactory.getProvider(this.context, this.context.config.get("ads").provider);
|
81011
|
+
plugins2 = [
|
81012
|
+
new RegionBorderPlugin(),
|
81013
|
+
new RegionAnimationPlugin("OPACITY")
|
81014
|
+
];
|
81015
|
+
newRegion = new BasicAdRegion(region.id, {
|
81016
|
+
width: region.width,
|
81017
|
+
height: region.height
|
81018
|
+
}, {
|
81019
|
+
ad: {
|
81020
|
+
type: region.type,
|
81021
|
+
name: region.region
|
81022
|
+
}
|
81023
|
+
}, {
|
81024
|
+
provider: provider,
|
81025
|
+
plugins: plugins2,
|
81026
|
+
recorder: this.context.recorder
|
81027
|
+
});
|
81028
|
+
this.regionsObjects.push(newRegion);
|
81029
|
+
this.regionsContainerView.append(newRegion.view);
|
81030
|
+
this.intersectionObserver.observe(newRegion.view);
|
81031
|
+
}
|
81032
|
+
}
|
81033
|
+
_state.label = 3;
|
81034
|
+
case 3:
|
81035
|
+
return [
|
81036
|
+
2
|
81037
|
+
];
|
80996
81038
|
}
|
80997
|
-
}
|
80998
|
-
}
|
81039
|
+
});
|
81040
|
+
}).call(this);
|
80999
81041
|
}
|
81000
81042
|
},
|
81001
81043
|
{
|
81002
81044
|
key: "clear",
|
81003
81045
|
value: function clear() {
|
81004
|
-
this
|
81005
|
-
width: 0,
|
81006
|
-
height: 0
|
81007
|
-
}, this.context.media.aspectRatio);
|
81008
|
-
this.updatePosition({
|
81009
|
-
x: 0,
|
81010
|
-
y: 0
|
81011
|
-
});
|
81046
|
+
var _this = this;
|
81012
81047
|
this.regionsObjects.forEach(function(region) {
|
81013
81048
|
region.clear();
|
81014
81049
|
});
|
81050
|
+
setTimeout(function() {
|
81051
|
+
_this.updateSize({
|
81052
|
+
width: 0,
|
81053
|
+
height: 0
|
81054
|
+
}, _this.context.media.aspectRatio);
|
81055
|
+
_this.updatePosition({
|
81056
|
+
x: 0,
|
81057
|
+
y: 0
|
81058
|
+
});
|
81059
|
+
}, 500);
|
81015
81060
|
}
|
81016
81061
|
},
|
81017
81062
|
{
|
@@ -81109,9 +81154,9 @@ var RegionRenderer = /*#__PURE__*/ function() {
|
|
81109
81154
|
{
|
81110
81155
|
key: "clear",
|
81111
81156
|
value: function clear() {
|
81112
|
-
var
|
81113
|
-
for(var index = 0; index <
|
81114
|
-
|
81157
|
+
var areas = Object.values(this.regionAreas);
|
81158
|
+
for(var index = 0; index < areas.length; index++){
|
81159
|
+
areas[index].clear();
|
81115
81160
|
}
|
81116
81161
|
}
|
81117
81162
|
},
|
@@ -81228,41 +81273,6 @@ var MediaElementSizeController = /*#__PURE__*/ function(_import_events9_default)
|
|
81228
81273
|
return updated;
|
81229
81274
|
}
|
81230
81275
|
},
|
81231
|
-
{
|
81232
|
-
key: "recalculate",
|
81233
|
-
value: function recalculate() {
|
81234
|
-
if (!this.isResized) {
|
81235
|
-
return this.restore();
|
81236
|
-
}
|
81237
|
-
var updated = false;
|
81238
|
-
if (this.context.media.view) {
|
81239
|
-
var _this_context_elements_container, _this_context_elements_container1, _this_context_elements_container2, _this_context_elements_container3;
|
81240
|
-
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);
|
81241
|
-
if (size.width !== this.size.width || size.height !== this.size.height) {
|
81242
|
-
this.size = size;
|
81243
|
-
this.context.media.view.style.width = "".concat(this.size.width, "px");
|
81244
|
-
this.context.media.view.style.height = "".concat(this.size.height, "px");
|
81245
|
-
this.context.media.setSize(this.size.width, this.size.height);
|
81246
|
-
updated = true;
|
81247
|
-
}
|
81248
|
-
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);
|
81249
|
-
var marginValue = Math.min(adjustedPosition.width, adjustedPosition.height);
|
81250
|
-
if (this.position.x !== marginValue || this.position.y !== marginValue) {
|
81251
|
-
var _this_context_interface;
|
81252
|
-
this.position.x = marginValue;
|
81253
|
-
this.position.y = marginValue;
|
81254
|
-
this.context.media.view.style.left = "".concat(this.position.x, "px");
|
81255
|
-
this.context.media.view.style.top = "".concat(this.position.y, "px");
|
81256
|
-
(_this_context_interface = this.context.interface) === null || _this_context_interface === void 0 ? void 0 : _this_context_interface.updatePosition(marginValue, marginValue);
|
81257
|
-
updated = true;
|
81258
|
-
}
|
81259
|
-
}
|
81260
|
-
if (updated) {
|
81261
|
-
this.emit("UPDATED");
|
81262
|
-
}
|
81263
|
-
return updated;
|
81264
|
-
}
|
81265
|
-
},
|
81266
81276
|
{
|
81267
81277
|
key: "update",
|
81268
81278
|
value: function update(percentage) {
|
@@ -81349,8 +81359,6 @@ var BasicPresentationMode = /*#__PURE__*/ function() {
|
|
81349
81359
|
this.context = context;
|
81350
81360
|
this.mediaElementSizeController = new MediaElementSizeController(context);
|
81351
81361
|
this.packer = new RegionPacker(this.context);
|
81352
|
-
this.mediaElementSizeController.on("UPDATED", function() {});
|
81353
|
-
this.packer.on("PACKED", function() {});
|
81354
81362
|
}
|
81355
81363
|
_create_class(BasicPresentationMode, [
|
81356
81364
|
{
|
@@ -81452,11 +81460,15 @@ var BasicPresentationMode = /*#__PURE__*/ function() {
|
|
81452
81460
|
width: ((_this_mediaElementSizeController3 = this.mediaElementSizeController) === null || _this_mediaElementSizeController3 === void 0 ? void 0 : _this_mediaElementSizeController3.size.width) || 0,
|
81453
81461
|
height: ((_this_mediaElementSizeController4 = this.mediaElementSizeController) === null || _this_mediaElementSizeController4 === void 0 ? void 0 : _this_mediaElementSizeController4.size.height) || 0
|
81454
81462
|
}, fullscreen ? "fullscreen" : "default");
|
81455
|
-
|
81456
|
-
if (
|
81463
|
+
this.packer.repack();
|
81464
|
+
if (this.packer.packed.length > 0) {
|
81457
81465
|
var _this_regionsRenderer1, _this_regionsRenderer2;
|
81458
81466
|
(_this_regionsRenderer1 = this.regionsRenderer) === null || _this_regionsRenderer1 === void 0 ? void 0 : _this_regionsRenderer1.addAreas(this.packer.areas);
|
81459
81467
|
(_this_regionsRenderer2 = this.regionsRenderer) === null || _this_regionsRenderer2 === void 0 ? void 0 : _this_regionsRenderer2.render(this.packer.packed);
|
81468
|
+
} else {
|
81469
|
+
var _this_regionsRenderer3, _this_mediaElementSizeController5;
|
81470
|
+
(_this_regionsRenderer3 = this.regionsRenderer) === null || _this_regionsRenderer3 === void 0 ? void 0 : _this_regionsRenderer3.clear();
|
81471
|
+
(_this_mediaElementSizeController5 = this.mediaElementSizeController) === null || _this_mediaElementSizeController5 === void 0 ? void 0 : _this_mediaElementSizeController5.restore();
|
81460
81472
|
}
|
81461
81473
|
}
|
81462
81474
|
}
|
@@ -82079,9 +82091,9 @@ var RegionRenderer2 = /*#__PURE__*/ function() {
|
|
82079
82091
|
}
|
82080
82092
|
} else {
|
82081
82093
|
for(var index1 = 0; index1 < diffRight.length && index1 < this.maxRegions; index1++){
|
82082
|
-
var
|
82083
|
-
if (
|
82084
|
-
|
82094
|
+
var existingObject2 = this.regionsObjects.getById(diffRight[index1].id);
|
82095
|
+
if (existingObject2) {
|
82096
|
+
existingObject2.updateRegion(mapped.getById(diffRight[index1].id));
|
82085
82097
|
} else {
|
82086
82098
|
var newRegion = this.regionFactory.get(diffRight[index1], {
|
82087
82099
|
width: this.regionsContainerView.width,
|
@@ -82096,9 +82108,9 @@ var RegionRenderer2 = /*#__PURE__*/ function() {
|
|
82096
82108
|
}
|
82097
82109
|
}
|
82098
82110
|
for(var index2 = 0; index2 < diffLeft.length; index2++){
|
82099
|
-
var
|
82100
|
-
if (
|
82101
|
-
|
82111
|
+
var existingObject21 = this.regionsObjects.getById(diffLeft[index2].id);
|
82112
|
+
if (existingObject21) {
|
82113
|
+
existingObject21.clear();
|
82102
82114
|
}
|
82103
82115
|
}
|
82104
82116
|
this.regionsData = regions2;
|
@@ -82486,22 +82498,32 @@ var VideoAds = /*#__PURE__*/ function() {
|
|
82486
82498
|
function VideoAds(context) {
|
82487
82499
|
_class_call_check(this, VideoAds);
|
82488
82500
|
this.videoAdElements = [];
|
82501
|
+
this.handlePageMutation = this.handlePageMutation.bind(this);
|
82489
82502
|
this.context = context;
|
82490
82503
|
}
|
82491
82504
|
_create_class(VideoAds, [
|
82492
82505
|
{
|
82493
|
-
key: "
|
82494
|
-
value: function
|
82495
|
-
if (!this.context.supports.api) {
|
82496
|
-
this.context.logger.error("Setup failed: no support");
|
82497
|
-
return;
|
82498
|
-
}
|
82506
|
+
key: "handleMedias",
|
82507
|
+
value: function handleMedias() {
|
82499
82508
|
try {
|
82509
|
+
var elements2 = [];
|
82510
|
+
for(var index = 0; index < this.videoAdElements.length; index++){
|
82511
|
+
var element = this.videoAdElements[index];
|
82512
|
+
if (element.media.view && document.body.contains(element.media.view)) {
|
82513
|
+
elements2.push(element);
|
82514
|
+
} else {
|
82515
|
+
element.destroy();
|
82516
|
+
}
|
82517
|
+
}
|
82518
|
+
this.videoAdElements = elements2;
|
82500
82519
|
var medias = MediaElementFactory.getElements(this.context.selectors.targets);
|
82501
82520
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
82502
82521
|
try {
|
82503
82522
|
for(var _iterator = medias[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
82504
82523
|
var media = _step.value;
|
82524
|
+
if (!media || media.closest("#BRNDTS_R") || media.querySelector("#BRNDTS_R")) {
|
82525
|
+
continue;
|
82526
|
+
}
|
82505
82527
|
var videoAd = new VideoAd(this.context, media);
|
82506
82528
|
this.videoAdElements.push(videoAd);
|
82507
82529
|
videoAd.start();
|
@@ -82527,6 +82549,22 @@ var VideoAds = /*#__PURE__*/ function() {
|
|
82527
82549
|
}
|
82528
82550
|
}
|
82529
82551
|
},
|
82552
|
+
{
|
82553
|
+
key: "start",
|
82554
|
+
value: function start() {
|
82555
|
+
if (!this.context.supports.api) {
|
82556
|
+
this.context.logger.error("Setup failed: no support");
|
82557
|
+
return;
|
82558
|
+
}
|
82559
|
+
this.handleMedias();
|
82560
|
+
}
|
82561
|
+
},
|
82562
|
+
{
|
82563
|
+
key: "handlePageMutation",
|
82564
|
+
value: function handlePageMutation() {
|
82565
|
+
this.handleMedias();
|
82566
|
+
}
|
82567
|
+
},
|
82530
82568
|
{
|
82531
82569
|
key: "updateSize",
|
82532
82570
|
value: function updateSize() {
|
@@ -82579,16 +82617,28 @@ var VideoAds = /*#__PURE__*/ function() {
|
|
82579
82617
|
var Ads = /*#__PURE__*/ function() {
|
82580
82618
|
function Ads(context) {
|
82581
82619
|
_class_call_check(this, Ads);
|
82620
|
+
this.handlePageMutation = functions_default.debounce(this.handlePageMutation.bind(this), 100);
|
82582
82621
|
this.context = context;
|
82583
82622
|
this.videoAds = new VideoAds(this.context);
|
82584
82623
|
this.staticAds = new StaticAds(this.context);
|
82624
|
+
this.observer = new MutationObserver(this.handlePageMutation);
|
82585
82625
|
}
|
82586
82626
|
_create_class(Ads, [
|
82627
|
+
{
|
82628
|
+
key: "handlePageMutation",
|
82629
|
+
value: function handlePageMutation() {
|
82630
|
+
this.videoAds.handlePageMutation();
|
82631
|
+
this.staticAds.handlePageMutation();
|
82632
|
+
}
|
82633
|
+
},
|
82587
82634
|
{
|
82588
82635
|
key: "start",
|
82589
82636
|
value: function start() {
|
82590
82637
|
this.videoAds.start();
|
82591
82638
|
this.staticAds.start();
|
82639
|
+
this.observer.observe(document.body, {
|
82640
|
+
childList: true
|
82641
|
+
});
|
82592
82642
|
}
|
82593
82643
|
},
|
82594
82644
|
{
|
@@ -82601,6 +82651,7 @@ var Ads = /*#__PURE__*/ function() {
|
|
82601
82651
|
key: "destroy",
|
82602
82652
|
value: function destroy() {
|
82603
82653
|
var _GooglePublisherTag_get;
|
82654
|
+
this.observer.disconnect();
|
82604
82655
|
this.videoAds.destroy();
|
82605
82656
|
this.staticAds.destroy();
|
82606
82657
|
(_GooglePublisherTag_get = GooglePublisherTag.get()) === null || _GooglePublisherTag_get === void 0 ? void 0 : _GooglePublisherTag_get.destroy();
|