@brndts/brndts-ads 1.13.1 → 1.13.2

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,89 @@ 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
+ });
80300
+ }
80301
+ if (plane.height - (cutout.y + cutout.height) > 0) {
80302
+ areas.push({
80303
+ dimensions: new Dimensions({
80304
+ x: 0,
80305
+ y: cutout.y + cutout.height
80306
+ }, {
80307
+ width: plane.width,
80308
+ height: plane.height - (cutout.y + cutout.height)
80309
+ }),
80310
+ name: "B"
80311
+ });
80312
+ }
80313
+ return areas;
80314
+ }
80315
+ }
80316
+ ]);
80317
+ return DefaultTemplate;
80318
+ }();
80319
+ var FullscreenTemplate = /*#__PURE__*/ function() {
80320
+ "use strict";
80321
+ function FullscreenTemplate() {
80322
+ _class_call_check(this, FullscreenTemplate);
80323
+ }
80324
+ _create_class(FullscreenTemplate, [
80325
+ {
80326
+ key: "get",
80327
+ value: function get(plane, cutout) {
80328
+ var areas = [];
80329
+ if (plane.width - (cutout.x + cutout.width) > 0) {
80330
+ areas.push({
80331
+ dimensions: new Dimensions({
80332
+ x: cutout.x + cutout.width,
80333
+ y: 0
80334
+ }, {
80335
+ width: plane.width - (cutout.x + cutout.width),
80336
+ height: plane.height
80337
+ }),
80338
+ name: "A"
80339
+ });
80340
+ }
80341
+ if (plane.height - (cutout.y + cutout.height) > 0) {
80342
+ areas.push({
80343
+ dimensions: new Dimensions({
80344
+ x: 0,
80345
+ y: cutout.y + cutout.height
80346
+ }, {
80347
+ width: cutout.x + cutout.width,
80348
+ height: plane.height - (cutout.y + cutout.height)
80349
+ }),
80350
+ available: {
80351
+ w: 0.7
80352
+ },
80353
+ name: "B"
80354
+ });
80355
+ }
80356
+ return areas;
80357
+ }
80358
+ }
80359
+ ]);
80360
+ return FullscreenTemplate;
80361
+ }();
80279
80362
  var RegionPacker = /*#__PURE__*/ function(_import_events8_default) {
80280
80363
  "use strict";
80281
80364
  _inherits(RegionPacker, _import_events8_default);
@@ -80289,6 +80372,7 @@ var RegionPacker = /*#__PURE__*/ function(_import_events8_default) {
80289
80372
  _this.mapped = [];
80290
80373
  _this.areas = [];
80291
80374
  _this.packed = [];
80375
+ _this.templates = {};
80292
80376
  _this.context = context;
80293
80377
  _this.plane = {
80294
80378
  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 +80381,17 @@ var RegionPacker = /*#__PURE__*/ function(_import_events8_default) {
80297
80381
  _this.mapped = transformData(TYPES).sort(function(a, b) {
80298
80382
  return b.area - a.area;
80299
80383
  });
80384
+ _this.templates = {
80385
+ "default": new DefaultTemplate(),
80386
+ "fullscreen": new FullscreenTemplate()
80387
+ };
80300
80388
  return _this;
80301
80389
  }
80302
80390
  _create_class(RegionPacker, [
80303
80391
  {
80304
80392
  key: "setCutout",
80305
80393
  value: function setCutout(cutout) {
80394
+ var template = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "default";
80306
80395
  var _this_context_elements_container, _this_context_elements_container1;
80307
80396
  this.cutout = cutout;
80308
80397
  this.areas = [];
@@ -80310,30 +80399,7 @@ var RegionPacker = /*#__PURE__*/ function(_import_events8_default) {
80310
80399
  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
80400
  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
80401
  };
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
- }
80402
+ this.areas = this.templates[template].get(this.plane, cutout);
80337
80403
  return this;
80338
80404
  }
80339
80405
  },
@@ -80356,9 +80422,10 @@ var RegionPacker = /*#__PURE__*/ function(_import_events8_default) {
80356
80422
  {
80357
80423
  key: "fillRegion",
80358
80424
  value: function fillRegion(region) {
80425
+ var _region_available, _region_available1, _region_available2, _region_available3;
80359
80426
  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;
80427
+ 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;
80428
+ 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
80429
  var regionX = region.dimensions.position.x;
80363
80430
  var regionY = region.dimensions.position.y;
80364
80431
  var usableTypes = this.mapped.filter(function(type) {
@@ -80989,27 +81056,33 @@ var AdRegionsArea = /*#__PURE__*/ function() {
80989
81056
  var diffLeft = getDifferenceLeft(visibleRegions, regions2);
80990
81057
  var diffRight = getDifferenceRight(visibleRegions, regions2);
80991
81058
  var common = getIntersection(visibleRegions, regions2);
81059
+ for(var index = 0; index < diffLeft.length; index++){
81060
+ var existingObject = this.regionsObjects.getById(diffLeft[index].id);
81061
+ if (existingObject) {
81062
+ existingObject.clear();
81063
+ }
81064
+ }
80992
81065
  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);
81066
+ for(var index1 = 0; index1 < common.length; index1++){
81067
+ if (index1 < this.maxRegions) {
81068
+ var pack = mapped.getById(common[index1].id);
80996
81069
  if (pack) {
80997
- common[index].updateSize(pack.width, pack.height);
81070
+ common[index1].updateSize(pack.width, pack.height);
80998
81071
  }
80999
81072
  } else {
81000
- common[index].clear();
81073
+ common[index1].clear();
81001
81074
  }
81002
81075
  }
81003
81076
  } 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);
81077
+ for(var index2 = 0; index2 < diffRight.length && index2 < this.maxRegions; index2++){
81078
+ var existingObject1 = this.regionsObjects.getById(diffRight[index2].id);
81079
+ if (existingObject1) {
81080
+ var pack1 = mapped.getById(diffRight[index2].id);
81008
81081
  if (pack1) {
81009
- existingObject.updateSize(pack1.width, pack1.height);
81082
+ existingObject1.updateSize(pack1.width, pack1.height);
81010
81083
  }
81011
81084
  } else {
81012
- var region = diffRight[index1];
81085
+ var region = diffRight[index2];
81013
81086
  var provider = ContentProviderFactory.getProvider(this.context, this.context.config.get("ads").provider);
81014
81087
  var plugins2 = [
81015
81088
  new RegionBorderPlugin(),
@@ -81034,18 +81107,21 @@ var AdRegionsArea = /*#__PURE__*/ function() {
81034
81107
  }
81035
81108
  }
81036
81109
  }
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
81110
  }
81044
81111
  },
81045
81112
  {
81046
81113
  key: "clear",
81047
81114
  value: function clear() {
81115
+ var _this = this;
81048
81116
  this.regionsObjects.forEach(function(region) {
81117
+ _this.updateSize({
81118
+ width: 0,
81119
+ height: 0
81120
+ }, _this.context.media.aspectRatio);
81121
+ _this.updatePosition({
81122
+ x: 0,
81123
+ y: 0
81124
+ });
81049
81125
  region.clear();
81050
81126
  });
81051
81127
  }
@@ -81438,7 +81514,7 @@ var BasicPresentationMode = /*#__PURE__*/ function() {
81438
81514
  y: (expected === null || expected === void 0 ? void 0 : expected.position.y) || 0,
81439
81515
  width: (expected === null || expected === void 0 ? void 0 : expected.size.width) || 0,
81440
81516
  height: (expected === null || expected === void 0 ? void 0 : expected.size.height) || 0
81441
- });
81517
+ }, _this.context.store.getState().fullscreen ? "fullscreen" : "default");
81442
81518
  _this.packer.pack();
81443
81519
  if (_this.packer.packed.length > 0) {
81444
81520
  var _this_adPresentationStrategy, _this_regionsRenderer, _this_regionsRenderer1, _this_mediaElementSizeController1;
@@ -81465,10 +81541,7 @@ var BasicPresentationMode = /*#__PURE__*/ function() {
81465
81541
  {
81466
81542
  key: "enteredFullscreen",
81467
81543
  value: function enteredFullscreen() {
81468
- var _this = this;
81469
- setTimeout(function() {
81470
- _this.updatedContainerSize(true);
81471
- }, 0);
81544
+ this.updatedContainerSize(true);
81472
81545
  }
81473
81546
  },
81474
81547
  {
@@ -81493,7 +81566,7 @@ var BasicPresentationMode = /*#__PURE__*/ function() {
81493
81566
  y: ((_this_mediaElementSizeController2 = this.mediaElementSizeController) === null || _this_mediaElementSizeController2 === void 0 ? void 0 : _this_mediaElementSizeController2.position.y) || 0,
81494
81567
  width: ((_this_mediaElementSizeController3 = this.mediaElementSizeController) === null || _this_mediaElementSizeController3 === void 0 ? void 0 : _this_mediaElementSizeController3.size.width) || 0,
81495
81568
  height: ((_this_mediaElementSizeController4 = this.mediaElementSizeController) === null || _this_mediaElementSizeController4 === void 0 ? void 0 : _this_mediaElementSizeController4.size.height) || 0
81496
- });
81569
+ }, fullscreen ? "fullscreen" : "default");
81497
81570
  var updated = this.packer.repack();
81498
81571
  if (updated) {
81499
81572
  var _this_regionsRenderer1, _this_regionsRenderer2;