@brndts/brndts-ads 1.13.5 → 1.13.6

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
@@ -67456,6 +67456,17 @@ var Awaitable = /*#__PURE__*/ function() {
67456
67456
  });
67457
67457
  }
67458
67458
  _create_class(Awaitable, [
67459
+ {
67460
+ key: "reset",
67461
+ value: function reset(value2) {
67462
+ var _this = this;
67463
+ this._value = value2;
67464
+ this._promise = new Promise(function(resolve, reject) {
67465
+ _this._resolve = resolve;
67466
+ _this._reject = reject;
67467
+ });
67468
+ }
67469
+ },
67459
67470
  {
67460
67471
  key: "value",
67461
67472
  get: function get() {
@@ -69821,6 +69832,7 @@ var AffiliateProvider = /*#__PURE__*/ function(ContentProvider1) {
69821
69832
  image.style.height = affiliate.size.h + "px";
69822
69833
  image.style.maxWidth = affiliate.size.w + "px";
69823
69834
  image.style.maxHeight = affiliate.size.h + "px";
69835
+ image.style.display = "block";
69824
69836
  image.setAttribute("src", affiliate.img);
69825
69837
  if (affiliate.url) {
69826
69838
  image.addEventListener("click", function() {
@@ -71293,10 +71305,16 @@ var RegionContent = /*#__PURE__*/ function() {
71293
71305
  this.container.dataset.state = this.box.area(this.plane.size) > 0 ? "visible" : "hidden";
71294
71306
  }
71295
71307
  },
71308
+ {
71309
+ key: "hide",
71310
+ value: function hide() {
71311
+ this.container.dataset.state = "hidden";
71312
+ }
71313
+ },
71296
71314
  {
71297
71315
  key: "clear",
71298
71316
  value: function clear() {
71299
- this.container.dataset.state = "hidden";
71317
+ this.hide();
71300
71318
  this.content = void 0;
71301
71319
  this.scale = null;
71302
71320
  }
@@ -71604,6 +71622,7 @@ var Region = /*#__PURE__*/ function() {
71604
71622
  this.onScreen = false;
71605
71623
  this.visible = false;
71606
71624
  this.plugins = [];
71625
+ this.hidden = new Awaitable(false);
71607
71626
  this.id = id;
71608
71627
  this.regionDescriptor = regionDescriptor;
71609
71628
  this.options = options;
@@ -80280,20 +80299,52 @@ var DefaultTemplate = /*#__PURE__*/ function() {
80280
80299
  "use strict";
80281
80300
  function DefaultTemplate() {
80282
80301
  _class_call_check(this, DefaultTemplate);
80302
+ this.margin = {
80303
+ t: 0,
80304
+ r: 0,
80305
+ b: 64,
80306
+ l: 0
80307
+ };
80283
80308
  }
80284
80309
  _create_class(DefaultTemplate, [
80285
80310
  {
80311
+ // get(plane: Plane.Descriptor, cutout: Cutout): PackingRegion[] {
80312
+ // const areas = [];
80313
+ // // Region A: Right strip (cutout height)
80314
+ // if (plane.width - (cutout.x + cutout.width) > 0) {
80315
+ // areas.push({
80316
+ // dimensions: new Dimensions(
80317
+ // { x: this.margin.l + cutout.x + cutout.width, y: this.margin.t + 0 },
80318
+ // { width: plane.width - (this.margin.l+this.margin.r) - (cutout.x + cutout.width), height: cutout.y + cutout.height }
80319
+ // ),
80320
+ // name: 'A',
80321
+ // maxSlots: 3, // Maximum slots for this region
80322
+ // });
80323
+ // }
80324
+ // // Region B: bottom-left strip (excluding cutout)
80325
+ // if (plane.height - (cutout.y + cutout.height) > 0) {
80326
+ // areas.push({
80327
+ // dimensions: new Dimensions(
80328
+ // { x: this.margin.l + 0, y: cutout.y + cutout.height },
80329
+ // { width: plane.width - (this.margin.l + this.margin.r), height: plane.height - (this.margin.t + this.margin.b) - (cutout.y + cutout.height) }
80330
+ // ),
80331
+ // name: 'B',
80332
+ // maxSlots: 1, // Maximum slots for this region
80333
+ // });
80334
+ // }
80335
+ // return areas;
80336
+ // }
80286
80337
  key: "get",
80287
80338
  value: function get(plane, cutout) {
80288
80339
  var areas = [];
80289
80340
  if (plane.width - (cutout.x + cutout.width) > 0) {
80290
80341
  areas.push({
80291
80342
  dimensions: new Dimensions({
80292
- x: cutout.x + cutout.width,
80293
- y: 0
80343
+ x: this.margin.l + cutout.x + cutout.width,
80344
+ y: this.margin.t + 0
80294
80345
  }, {
80295
80346
  width: plane.width - (cutout.x + cutout.width),
80296
- height: cutout.y + cutout.height
80347
+ height: plane.height - (this.margin.t + this.margin.b)
80297
80348
  }),
80298
80349
  name: "A",
80299
80350
  maxSlots: 3
@@ -80302,12 +80353,14 @@ var DefaultTemplate = /*#__PURE__*/ function() {
80302
80353
  if (plane.height - (cutout.y + cutout.height) > 0) {
80303
80354
  areas.push({
80304
80355
  dimensions: new Dimensions({
80305
- x: 0,
80306
- y: cutout.y + cutout.height
80356
+ x: this.margin.l + 0,
80357
+ y: this.margin.t + cutout.y + cutout.height
80307
80358
  }, {
80308
- width: plane.width,
80309
- height: plane.height - (cutout.y + cutout.height)
80359
+ width: cutout.x + cutout.width,
80360
+ height: plane.height - (this.margin.t + this.margin.b) - (cutout.y + cutout.height)
80310
80361
  }),
80362
+ available: {
80363
+ },
80311
80364
  name: "B",
80312
80365
  maxSlots: 1
80313
80366
  });
@@ -80322,6 +80375,12 @@ var FullscreenTemplate = /*#__PURE__*/ function() {
80322
80375
  "use strict";
80323
80376
  function FullscreenTemplate() {
80324
80377
  _class_call_check(this, FullscreenTemplate);
80378
+ this.margin = {
80379
+ t: 0,
80380
+ r: 0,
80381
+ b: 64,
80382
+ l: 0
80383
+ };
80325
80384
  }
80326
80385
  _create_class(FullscreenTemplate, [
80327
80386
  {
@@ -80331,11 +80390,11 @@ var FullscreenTemplate = /*#__PURE__*/ function() {
80331
80390
  if (plane.width - (cutout.x + cutout.width) > 0) {
80332
80391
  areas.push({
80333
80392
  dimensions: new Dimensions({
80334
- x: cutout.x + cutout.width,
80335
- y: 0
80393
+ x: this.margin.l + cutout.x + cutout.width,
80394
+ y: this.margin.t + 0
80336
80395
  }, {
80337
80396
  width: plane.width - (cutout.x + cutout.width),
80338
- height: plane.height
80397
+ height: plane.height - (this.margin.t + this.margin.b)
80339
80398
  }),
80340
80399
  name: "A",
80341
80400
  maxSlots: 3
@@ -80344,11 +80403,11 @@ var FullscreenTemplate = /*#__PURE__*/ function() {
80344
80403
  if (plane.height - (cutout.y + cutout.height) > 0) {
80345
80404
  areas.push({
80346
80405
  dimensions: new Dimensions({
80347
- x: 0,
80348
- y: cutout.y + cutout.height
80406
+ x: this.margin.l + 0,
80407
+ y: this.margin.t + cutout.y + cutout.height
80349
80408
  }, {
80350
80409
  width: cutout.x + cutout.width,
80351
- height: plane.height - (cutout.y + cutout.height)
80410
+ height: plane.height - (this.margin.t + this.margin.b) - (cutout.y + cutout.height)
80352
80411
  }),
80353
80412
  available: {
80354
80413
  w: 0.7
@@ -80725,10 +80784,11 @@ var BasicAdRegion = /*#__PURE__*/ function(Region) {
80725
80784
  key: "hideRegion",
80726
80785
  value: function hideRegion() {
80727
80786
  return _async_to_generator(function() {
80728
- var _this_deps_recorder;
80729
80787
  return _ts_generator(this, function(_state) {
80730
80788
  switch(_state.label){
80731
80789
  case 0:
80790
+ this.hidden.reset(false);
80791
+ this.content.hide();
80732
80792
  return [
80733
80793
  4,
80734
80794
  this.applyPlugins("beforeHide")
@@ -80741,7 +80801,7 @@ var BasicAdRegion = /*#__PURE__*/ function(Region) {
80741
80801
  this.content.clear();
80742
80802
  this.applyPlugins("afterHide");
80743
80803
  this.visible = false;
80744
- (_this_deps_recorder = this.deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.presentationStateChanged(this, true);
80804
+ this.hidden.resolve(true);
80745
80805
  return [
80746
80806
  2
80747
80807
  ];
@@ -80750,30 +80810,40 @@ var BasicAdRegion = /*#__PURE__*/ function(Region) {
80750
80810
  }).call(this);
80751
80811
  }
80752
80812
  },
80813
+ {
80814
+ key: "showRegion",
80815
+ value: function showRegion() {
80816
+ return _async_to_generator(function() {
80817
+ var _this_deps_recorder;
80818
+ return _ts_generator(this, function(_state) {
80819
+ this.applyPlugins("beforeShow");
80820
+ this.container.style.display = "block";
80821
+ this.container.style.position = "relative";
80822
+ this.container.style.width = "".concat(this.box.width(this.plane.size), "px");
80823
+ this.container.style.height = "".concat(this.box.height(this.plane.size), "px");
80824
+ this.content.render();
80825
+ this.applyPlugins("afterShow");
80826
+ this.visible = true;
80827
+ (_this_deps_recorder = this.deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.presentationStateChanged(this, true);
80828
+ return [
80829
+ 2
80830
+ ];
80831
+ });
80832
+ }).call(this);
80833
+ }
80834
+ },
80753
80835
  {
80754
80836
  key: "render",
80755
80837
  value: function render(contours, box) {
80756
80838
  return _async_to_generator(function() {
80757
- var _this_deps_recorder;
80758
80839
  return _ts_generator(this, function(_state) {
80759
80840
  this.applyPlugins("beforeRender");
80760
80841
  if (this.shouldPresent()) {
80761
- ;
80762
- this.applyPlugins("beforeShow");
80763
- this.container.style.display = "block";
80764
- this.container.style.position = "relative";
80765
- this.container.style.width = "".concat(this.box.width(this.plane.size), "px");
80766
- this.container.style.height = "".concat(this.box.height(this.plane.size), "px");
80767
- this.content.render();
80768
- this.applyPlugins("afterShow");
80769
- this.visible = true;
80770
- (_this_deps_recorder = this.deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.presentationStateChanged(this, true);
80842
+ this.showRegion();
80771
80843
  } else if (this.shouldHide()) {
80772
80844
  this.hideRegion();
80773
80845
  } else {
80774
80846
  if (this.visible) {
80775
- this.container.style.width = "".concat(this.box.width(this.plane.size), "px");
80776
- this.container.style.height = "".concat(this.box.height(this.plane.size), "px");
80777
80847
  this.applyPlugins("reRender");
80778
80848
  }
80779
80849
  }
@@ -80785,48 +80855,6 @@ var BasicAdRegion = /*#__PURE__*/ function(Region) {
80785
80855
  }).call(this);
80786
80856
  }
80787
80857
  },
80788
- {
80789
- key: "shouldRequestContent",
80790
- value: function shouldRequestContent(newBox) {
80791
- if (this.box.area({
80792
- width: 1,
80793
- height: 1
80794
- }) <= 0 && newBox.area({
80795
- width: 1,
80796
- height: 1
80797
- }) > 0) {
80798
- return true;
80799
- }
80800
- if (this.box.isEqual(newBox.coords)) {
80801
- return false;
80802
- }
80803
- if (newBox.area(this.plane.size) <= 0) {
80804
- return false;
80805
- }
80806
- if (newBox.area(this.plane.size) === this.box.area(this.plane.size)) {
80807
- return false;
80808
- }
80809
- if (Math.abs(newBox.area({
80810
- width: 1,
80811
- height: 1
80812
- }) - this.box.area({
80813
- width: 1,
80814
- height: 1
80815
- })) < 0.05) {
80816
- return false;
80817
- }
80818
- if (Math.abs(newBox.aspectRatio({
80819
- width: 1,
80820
- height: 1
80821
- }) - this.box.aspectRatio({
80822
- width: 1,
80823
- height: 1
80824
- })) > 0.05) {
80825
- return false;
80826
- }
80827
- return true;
80828
- }
80829
- },
80830
80858
  {
80831
80859
  key: "updateSize",
80832
80860
  value: function updateSize(width, height) {
@@ -80856,7 +80884,10 @@ var BasicAdRegion = /*#__PURE__*/ function(Region) {
80856
80884
  value: function clear() {
80857
80885
  var _this = this;
80858
80886
  this.hideRegion().then(function() {
80859
- _this.updateSize(0, 0);
80887
+ _this.plane.update({
80888
+ width: 0,
80889
+ height: 0
80890
+ });
80860
80891
  });
80861
80892
  }
80862
80893
  }
@@ -81049,83 +81080,116 @@ var AdRegionsArea = /*#__PURE__*/ function() {
81049
81080
  {
81050
81081
  key: "render",
81051
81082
  value: function render(regions2) {
81052
- if (!regions2 || !regions2.length) {
81053
- this.clear();
81054
- return;
81055
- }
81056
- var mapped = new MappedCollection();
81057
- mapped.load(regions2);
81058
- var visibleRegions = this.regionsObjects.getVisible();
81059
- var diffLeft = getDifferenceLeft(visibleRegions, regions2);
81060
- var diffRight = getDifferenceRight(visibleRegions, regions2);
81061
- var common = getIntersection(visibleRegions, regions2);
81062
- for(var index = 0; index < diffLeft.length; index++){
81063
- var existingObject = this.regionsObjects.getById(diffLeft[index].id);
81064
- if (existingObject) {
81065
- existingObject.clear();
81066
- }
81067
- }
81068
- if (common.length) {
81069
- for(var index1 = 0; index1 < common.length; index1++){
81070
- if (index1 < this.maxRegions) {
81071
- var pack = mapped.getById(common[index1].id);
81072
- if (pack) {
81073
- common[index1].updateSize(pack.width, pack.height);
81074
- }
81075
- } else {
81076
- common[index1].clear();
81077
- }
81078
- }
81079
- } else {
81080
- for(var index2 = 0; index2 < diffRight.length && index2 < this.maxRegions; index2++){
81081
- var existingObject1 = this.regionsObjects.getById(diffRight[index2].id);
81082
- if (existingObject1) {
81083
- var pack1 = mapped.getById(diffRight[index2].id);
81084
- if (pack1) {
81085
- existingObject1.updateSize(pack1.width, pack1.height);
81086
- }
81087
- } else {
81088
- var region = diffRight[index2];
81089
- var provider = ContentProviderFactory.getProvider(this.context, this.context.config.get("ads").provider);
81090
- var plugins2 = [
81091
- // new RegionBorderPlugin(),
81092
- new RegionAnimationPlugin("OPACITY")
81093
- ];
81094
- var newRegion = new BasicAdRegion(region.id, {
81095
- width: region.width,
81096
- height: region.height
81097
- }, {
81098
- ad: {
81099
- type: region.type,
81100
- name: region.region
81083
+ return _async_to_generator(function() {
81084
+ var mapped, visibleRegions, diffLeft, diffRight, pending, common, index, existingObject2, index1, pack, index2, existingObject21, pack1, region, provider, plugins2, newRegion;
81085
+ return _ts_generator(this, function(_state) {
81086
+ switch(_state.label){
81087
+ case 0:
81088
+ if (!regions2 || !regions2.length) {
81089
+ this.clear();
81090
+ return [
81091
+ 2
81092
+ ];
81101
81093
  }
81102
- }, {
81103
- provider: provider,
81104
- plugins: plugins2,
81105
- recorder: this.context.recorder
81106
- });
81107
- this.regionsObjects.push(newRegion);
81108
- this.regionsContainerView.append(newRegion.view);
81109
- this.intersectionObserver.observe(newRegion.view);
81094
+ mapped = new MappedCollection();
81095
+ mapped.load(regions2);
81096
+ visibleRegions = this.regionsObjects.getVisible();
81097
+ diffLeft = getDifferenceLeft(visibleRegions, regions2);
81098
+ diffRight = getDifferenceRight(visibleRegions, regions2);
81099
+ pending = [];
81100
+ common = getIntersection(visibleRegions, regions2);
81101
+ for(index = 0; index < diffLeft.length; index++){
81102
+ existingObject2 = this.regionsObjects.getById(diffLeft[index].id);
81103
+ if (existingObject2) {
81104
+ existingObject2.updateSize(0, 0);
81105
+ pending.push(existingObject2.hidden.promise);
81106
+ }
81107
+ }
81108
+ if (!common.length) return [
81109
+ 3,
81110
+ 1
81111
+ ];
81112
+ for(index1 = 0; index1 < common.length; index1++){
81113
+ if (index1 < this.maxRegions) {
81114
+ pack = mapped.getById(common[index1].id);
81115
+ if (pack) {
81116
+ common[index1].updateSize(pack.width, pack.height);
81117
+ }
81118
+ } else {
81119
+ common[index1].updateSize(0, 0);
81120
+ pending.push(existingObject.hidden.promise);
81121
+ }
81122
+ }
81123
+ return [
81124
+ 3,
81125
+ 3
81126
+ ];
81127
+ case 1:
81128
+ return [
81129
+ 4,
81130
+ Promise.all(pending)
81131
+ ];
81132
+ case 2:
81133
+ _state.sent();
81134
+ for(index2 = 0; index2 < diffRight.length && index2 < this.maxRegions; index2++){
81135
+ existingObject21 = this.regionsObjects.getById(diffRight[index2].id);
81136
+ if (existingObject21) {
81137
+ pack1 = mapped.getById(diffRight[index2].id);
81138
+ if (pack1) {
81139
+ existingObject21.updateSize(pack1.width, pack1.height);
81140
+ }
81141
+ } else {
81142
+ region = diffRight[index2];
81143
+ provider = ContentProviderFactory.getProvider(this.context, this.context.config.get("ads").provider);
81144
+ plugins2 = [
81145
+ new RegionBorderPlugin(),
81146
+ new RegionAnimationPlugin("OPACITY")
81147
+ ];
81148
+ newRegion = new BasicAdRegion(region.id, {
81149
+ width: region.width,
81150
+ height: region.height
81151
+ }, {
81152
+ ad: {
81153
+ type: region.type,
81154
+ name: region.region
81155
+ }
81156
+ }, {
81157
+ provider: provider,
81158
+ plugins: plugins2,
81159
+ recorder: this.context.recorder
81160
+ });
81161
+ this.regionsObjects.push(newRegion);
81162
+ this.regionsContainerView.append(newRegion.view);
81163
+ this.intersectionObserver.observe(newRegion.view);
81164
+ }
81165
+ }
81166
+ _state.label = 3;
81167
+ case 3:
81168
+ return [
81169
+ 2
81170
+ ];
81110
81171
  }
81111
- }
81112
- }
81172
+ });
81173
+ }).call(this);
81113
81174
  }
81114
81175
  },
81115
81176
  {
81116
81177
  key: "clear",
81117
81178
  value: function clear() {
81118
- this.updateSize({
81119
- width: 0,
81120
- height: 0
81121
- }, this.context.media.aspectRatio);
81122
- this.updatePosition({
81123
- x: 0,
81124
- y: 0
81125
- });
81179
+ var _this = this;
81126
81180
  this.regionsObjects.forEach(function(region) {
81127
81181
  region.clear();
81128
81182
  });
81183
+ setTimeout(function() {
81184
+ _this.updateSize({
81185
+ width: 0,
81186
+ height: 0
81187
+ }, _this.context.media.aspectRatio);
81188
+ _this.updatePosition({
81189
+ x: 0,
81190
+ y: 0
81191
+ });
81192
+ }, 500);
81129
81193
  }
81130
81194
  },
81131
81195
  {
@@ -81224,9 +81288,9 @@ var RegionRenderer = /*#__PURE__*/ function() {
81224
81288
  {
81225
81289
  key: "clear",
81226
81290
  value: function clear() {
81227
- var regions2 = Object.values(this.regionAreas);
81228
- for(var index = 0; index < regions2.length; index++){
81229
- regions2[index].clear();
81291
+ var areas = Object.values(this.regionAreas);
81292
+ for(var index = 0; index < areas.length; index++){
81293
+ areas[index].clear();
81230
81294
  }
81231
81295
  }
81232
81296
  },
@@ -82205,9 +82269,9 @@ var RegionRenderer2 = /*#__PURE__*/ function() {
82205
82269
  }
82206
82270
  } else {
82207
82271
  for(var index1 = 0; index1 < diffRight.length && index1 < this.maxRegions; index1++){
82208
- var existingObject = this.regionsObjects.getById(diffRight[index1].id);
82209
- if (existingObject) {
82210
- existingObject.updateRegion(mapped.getById(diffRight[index1].id));
82272
+ var existingObject2 = this.regionsObjects.getById(diffRight[index1].id);
82273
+ if (existingObject2) {
82274
+ existingObject2.updateRegion(mapped.getById(diffRight[index1].id));
82211
82275
  } else {
82212
82276
  var newRegion = this.regionFactory.get(diffRight[index1], {
82213
82277
  width: this.regionsContainerView.width,
@@ -82222,9 +82286,9 @@ var RegionRenderer2 = /*#__PURE__*/ function() {
82222
82286
  }
82223
82287
  }
82224
82288
  for(var index2 = 0; index2 < diffLeft.length; index2++){
82225
- var existingObject1 = this.regionsObjects.getById(diffLeft[index2].id);
82226
- if (existingObject1) {
82227
- existingObject1.clear();
82289
+ var existingObject21 = this.regionsObjects.getById(diffLeft[index2].id);
82290
+ if (existingObject21) {
82291
+ existingObject21.clear();
82228
82292
  }
82229
82293
  }
82230
82294
  this.regionsData = regions2;