@brndts/brndts-ads 1.13.1 → 1.13.3

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.mjs CHANGED
@@ -80276,6 +80276,93 @@ var TYPES = {
80276
80276
  ]
80277
80277
  ]
80278
80278
  };
80279
+ var DefaultTemplate = /*#__PURE__*/ function() {
80280
+ "use strict";
80281
+ function DefaultTemplate() {
80282
+ _class_call_check(this, DefaultTemplate);
80283
+ }
80284
+ _create_class(DefaultTemplate, [
80285
+ {
80286
+ key: "get",
80287
+ value: function get(plane, cutout) {
80288
+ var areas = [];
80289
+ if (plane.width - (cutout.x + cutout.width) > 0) {
80290
+ areas.push({
80291
+ dimensions: new Dimensions({
80292
+ x: cutout.x + cutout.width,
80293
+ y: 0
80294
+ }, {
80295
+ width: plane.width - (cutout.x + cutout.width),
80296
+ height: cutout.y + cutout.height
80297
+ }),
80298
+ name: "A",
80299
+ maxSlots: 3
80300
+ });
80301
+ }
80302
+ if (plane.height - (cutout.y + cutout.height) > 0) {
80303
+ areas.push({
80304
+ dimensions: new Dimensions({
80305
+ x: 0,
80306
+ y: cutout.y + cutout.height
80307
+ }, {
80308
+ width: plane.width,
80309
+ height: plane.height - (cutout.y + cutout.height)
80310
+ }),
80311
+ name: "B",
80312
+ maxSlots: 1
80313
+ });
80314
+ }
80315
+ return areas;
80316
+ }
80317
+ }
80318
+ ]);
80319
+ return DefaultTemplate;
80320
+ }();
80321
+ var FullscreenTemplate = /*#__PURE__*/ function() {
80322
+ "use strict";
80323
+ function FullscreenTemplate() {
80324
+ _class_call_check(this, FullscreenTemplate);
80325
+ }
80326
+ _create_class(FullscreenTemplate, [
80327
+ {
80328
+ key: "get",
80329
+ value: function get(plane, cutout) {
80330
+ var areas = [];
80331
+ if (plane.width - (cutout.x + cutout.width) > 0) {
80332
+ areas.push({
80333
+ dimensions: new Dimensions({
80334
+ x: cutout.x + cutout.width,
80335
+ y: 0
80336
+ }, {
80337
+ width: plane.width - (cutout.x + cutout.width),
80338
+ height: plane.height
80339
+ }),
80340
+ name: "A",
80341
+ maxSlots: 3
80342
+ });
80343
+ }
80344
+ if (plane.height - (cutout.y + cutout.height) > 0) {
80345
+ areas.push({
80346
+ dimensions: new Dimensions({
80347
+ x: 0,
80348
+ y: cutout.y + cutout.height
80349
+ }, {
80350
+ width: cutout.x + cutout.width,
80351
+ height: plane.height - (cutout.y + cutout.height)
80352
+ }),
80353
+ available: {
80354
+ w: 0.7
80355
+ },
80356
+ name: "B",
80357
+ maxSlots: 1
80358
+ });
80359
+ }
80360
+ return areas;
80361
+ }
80362
+ }
80363
+ ]);
80364
+ return FullscreenTemplate;
80365
+ }();
80279
80366
  var RegionPacker = /*#__PURE__*/ function(_import_events8_default) {
80280
80367
  "use strict";
80281
80368
  _inherits(RegionPacker, _import_events8_default);
@@ -80289,6 +80376,7 @@ var RegionPacker = /*#__PURE__*/ function(_import_events8_default) {
80289
80376
  _this.mapped = [];
80290
80377
  _this.areas = [];
80291
80378
  _this.packed = [];
80379
+ _this.templates = {};
80292
80380
  _this.context = context;
80293
80381
  _this.plane = {
80294
80382
  width: ((_this_context_elements_container = _this.context.elements.container) === null || _this_context_elements_container === void 0 ? void 0 : _this_context_elements_container.getBoundingClientRect().width) || 0,
@@ -80297,12 +80385,17 @@ var RegionPacker = /*#__PURE__*/ function(_import_events8_default) {
80297
80385
  _this.mapped = transformData(TYPES).sort(function(a, b) {
80298
80386
  return b.area - a.area;
80299
80387
  });
80388
+ _this.templates = {
80389
+ "default": new DefaultTemplate(),
80390
+ "fullscreen": new FullscreenTemplate()
80391
+ };
80300
80392
  return _this;
80301
80393
  }
80302
80394
  _create_class(RegionPacker, [
80303
80395
  {
80304
80396
  key: "setCutout",
80305
80397
  value: function setCutout(cutout) {
80398
+ var template = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "default";
80306
80399
  var _this_context_elements_container, _this_context_elements_container1;
80307
80400
  this.cutout = cutout;
80308
80401
  this.areas = [];
@@ -80310,30 +80403,7 @@ var RegionPacker = /*#__PURE__*/ function(_import_events8_default) {
80310
80403
  width: ((_this_context_elements_container = this.context.elements.container) === null || _this_context_elements_container === void 0 ? void 0 : _this_context_elements_container.getBoundingClientRect().width) || 0,
80311
80404
  height: ((_this_context_elements_container1 = this.context.elements.container) === null || _this_context_elements_container1 === void 0 ? void 0 : _this_context_elements_container1.getBoundingClientRect().height) || 0
80312
80405
  };
80313
- if (this.plane.width - (this.cutout.x + this.cutout.width) > 0) {
80314
- this.areas.push({
80315
- dimensions: new Dimensions({
80316
- x: this.cutout.x + this.cutout.width,
80317
- y: 0
80318
- }, {
80319
- width: this.plane.width - (this.cutout.x + this.cutout.width),
80320
- height: this.plane.height
80321
- }),
80322
- name: "A"
80323
- });
80324
- }
80325
- if (this.plane.height - (this.cutout.y + this.cutout.height) > 0) {
80326
- this.areas.push({
80327
- dimensions: new Dimensions({
80328
- x: 0,
80329
- y: this.cutout.y + this.cutout.height
80330
- }, {
80331
- width: this.cutout.x + this.cutout.width,
80332
- height: this.plane.height - (this.cutout.y + this.cutout.height)
80333
- }),
80334
- name: "B"
80335
- });
80336
- }
80406
+ this.areas = this.templates[template].get(this.plane, cutout);
80337
80407
  return this;
80338
80408
  }
80339
80409
  },
@@ -80356,9 +80426,10 @@ var RegionPacker = /*#__PURE__*/ function(_import_events8_default) {
80356
80426
  {
80357
80427
  key: "fillRegion",
80358
80428
  value: function fillRegion(region) {
80429
+ var _region_available, _region_available1, _region_available2, _region_available3;
80359
80430
  var result = [];
80360
- var availableWidth = region.name === "B" ? region.dimensions.size.width * 0.7 : region.dimensions.size.width;
80361
- var availableHeight = region.name === "A" ? region.dimensions.size.height * 0.7 : region.dimensions.size.height;
80431
+ var availableWidth = ((_region_available = region.available) === null || _region_available === void 0 ? void 0 : _region_available.w) ? region.dimensions.size.width * ((_region_available1 = region.available) === null || _region_available1 === void 0 ? void 0 : _region_available1.w) : region.dimensions.size.width;
80432
+ var availableHeight = ((_region_available2 = region.available) === null || _region_available2 === void 0 ? void 0 : _region_available2.h) ? region.dimensions.size.height * ((_region_available3 = region.available) === null || _region_available3 === void 0 ? void 0 : _region_available3.h) : region.dimensions.size.height;
80362
80433
  var regionX = region.dimensions.position.x;
80363
80434
  var regionY = region.dimensions.position.y;
80364
80435
  var usableTypes = this.mapped.filter(function(type) {
@@ -80392,6 +80463,9 @@ var RegionPacker = /*#__PURE__*/ function(_import_events8_default) {
80392
80463
  }
80393
80464
  index -= 1;
80394
80465
  }
80466
+ if (result.length >= region.maxSlots) {
80467
+ break;
80468
+ }
80395
80469
  }
80396
80470
  return result;
80397
80471
  }
@@ -80578,12 +80652,6 @@ var StaticRegionContent2 = /*#__PURE__*/ function(RegionContent) {
80578
80652
  this.container.style.width = "fit-content";
80579
80653
  this.container.style.height = "fit-content";
80580
80654
  this.container.dataset.state = this.box.area(this.plane.size) > 0 ? "visible" : "hidden";
80581
- this.container.childNodes.forEach(function(node) {
80582
- if (_instanceof(node, HTMLElement)) {
80583
- node.style.width = "fit-content";
80584
- node.style.height = "fit-content";
80585
- }
80586
- });
80587
80655
  }
80588
80656
  }
80589
80657
  ]);
@@ -80833,6 +80901,7 @@ var RegionsContainerView = /*#__PURE__*/ function() {
80833
80901
  }
80834
80902
  if (this.contentLayer) {
80835
80903
  this.contentLayer.style.position = "absolute";
80904
+ this.contentLayer.style.overflow = "hidden";
80836
80905
  this.contentLayer.style.top = "".concat(this.position.y, "px");
80837
80906
  this.contentLayer.style.left = "".concat(this.position.x, "px");
80838
80907
  this.contentLayer.style.width = "".concat(this.size.width, "px");
@@ -80989,27 +81058,33 @@ var AdRegionsArea = /*#__PURE__*/ function() {
80989
81058
  var diffLeft = getDifferenceLeft(visibleRegions, regions2);
80990
81059
  var diffRight = getDifferenceRight(visibleRegions, regions2);
80991
81060
  var common = getIntersection(visibleRegions, regions2);
81061
+ for(var index = 0; index < diffLeft.length; index++){
81062
+ var existingObject = this.regionsObjects.getById(diffLeft[index].id);
81063
+ if (existingObject) {
81064
+ existingObject.clear();
81065
+ }
81066
+ }
80992
81067
  if (common.length) {
80993
- for(var index = 0; index < common.length; index++){
80994
- if (index < this.maxRegions) {
80995
- var pack = mapped.getById(common[index].id);
81068
+ for(var index1 = 0; index1 < common.length; index1++){
81069
+ if (index1 < this.maxRegions) {
81070
+ var pack = mapped.getById(common[index1].id);
80996
81071
  if (pack) {
80997
- common[index].updateSize(pack.width, pack.height);
81072
+ common[index1].updateSize(pack.width, pack.height);
80998
81073
  }
80999
81074
  } else {
81000
- common[index].clear();
81075
+ common[index1].clear();
81001
81076
  }
81002
81077
  }
81003
81078
  } else {
81004
- for(var index1 = 0; index1 < diffRight.length && index1 < this.maxRegions; index1++){
81005
- var existingObject = this.regionsObjects.getById(diffRight[index1].id);
81006
- if (existingObject) {
81007
- var pack1 = mapped.getById(diffRight[index1].id);
81079
+ for(var index2 = 0; index2 < diffRight.length && index2 < this.maxRegions; index2++){
81080
+ var existingObject1 = this.regionsObjects.getById(diffRight[index2].id);
81081
+ if (existingObject1) {
81082
+ var pack1 = mapped.getById(diffRight[index2].id);
81008
81083
  if (pack1) {
81009
- existingObject.updateSize(pack1.width, pack1.height);
81084
+ existingObject1.updateSize(pack1.width, pack1.height);
81010
81085
  }
81011
81086
  } else {
81012
- var region = diffRight[index1];
81087
+ var region = diffRight[index2];
81013
81088
  var provider = ContentProviderFactory.getProvider(this.context, this.context.config.get("ads").provider);
81014
81089
  var plugins2 = [
81015
81090
  new RegionBorderPlugin(),
@@ -81034,17 +81109,19 @@ var AdRegionsArea = /*#__PURE__*/ function() {
81034
81109
  }
81035
81110
  }
81036
81111
  }
81037
- for(var index2 = 0; index2 < diffLeft.length; index2++){
81038
- var existingObject1 = this.regionsObjects.getById(diffLeft[index2].id);
81039
- if (existingObject1) {
81040
- existingObject1.clear();
81041
- }
81042
- }
81043
81112
  }
81044
81113
  },
81045
81114
  {
81046
81115
  key: "clear",
81047
81116
  value: function clear() {
81117
+ this.updateSize({
81118
+ width: 0,
81119
+ height: 0
81120
+ }, this.context.media.aspectRatio);
81121
+ this.updatePosition({
81122
+ x: 0,
81123
+ y: 0
81124
+ });
81048
81125
  this.regionsObjects.forEach(function(region) {
81049
81126
  region.clear();
81050
81127
  });
@@ -81438,7 +81515,7 @@ var BasicPresentationMode = /*#__PURE__*/ function() {
81438
81515
  y: (expected === null || expected === void 0 ? void 0 : expected.position.y) || 0,
81439
81516
  width: (expected === null || expected === void 0 ? void 0 : expected.size.width) || 0,
81440
81517
  height: (expected === null || expected === void 0 ? void 0 : expected.size.height) || 0
81441
- });
81518
+ }, _this.context.store.getState().fullscreen ? "fullscreen" : "default");
81442
81519
  _this.packer.pack();
81443
81520
  if (_this.packer.packed.length > 0) {
81444
81521
  var _this_adPresentationStrategy, _this_regionsRenderer, _this_regionsRenderer1, _this_mediaElementSizeController1;
@@ -81465,10 +81542,7 @@ var BasicPresentationMode = /*#__PURE__*/ function() {
81465
81542
  {
81466
81543
  key: "enteredFullscreen",
81467
81544
  value: function enteredFullscreen() {
81468
- var _this = this;
81469
- setTimeout(function() {
81470
- _this.updatedContainerSize(true);
81471
- }, 0);
81545
+ this.updatedContainerSize(true);
81472
81546
  }
81473
81547
  },
81474
81548
  {
@@ -81493,7 +81567,7 @@ var BasicPresentationMode = /*#__PURE__*/ function() {
81493
81567
  y: ((_this_mediaElementSizeController2 = this.mediaElementSizeController) === null || _this_mediaElementSizeController2 === void 0 ? void 0 : _this_mediaElementSizeController2.position.y) || 0,
81494
81568
  width: ((_this_mediaElementSizeController3 = this.mediaElementSizeController) === null || _this_mediaElementSizeController3 === void 0 ? void 0 : _this_mediaElementSizeController3.size.width) || 0,
81495
81569
  height: ((_this_mediaElementSizeController4 = this.mediaElementSizeController) === null || _this_mediaElementSizeController4 === void 0 ? void 0 : _this_mediaElementSizeController4.size.height) || 0
81496
- });
81570
+ }, fullscreen ? "fullscreen" : "default");
81497
81571
  var updated = this.packer.repack();
81498
81572
  if (updated) {
81499
81573
  var _this_regionsRenderer1, _this_regionsRenderer2;