@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.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.container.dataset.state = "hidden";
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;
@@ -80174,20 +80193,52 @@ var TYPES = {
80174
80193
  var DefaultTemplate = /*#__PURE__*/ function() {
80175
80194
  function DefaultTemplate() {
80176
80195
  _class_call_check(this, DefaultTemplate);
80196
+ this.margin = {
80197
+ t: 0,
80198
+ r: 0,
80199
+ b: 64,
80200
+ l: 0
80201
+ };
80177
80202
  }
80178
80203
  _create_class(DefaultTemplate, [
80179
80204
  {
80205
+ // get(plane: Plane.Descriptor, cutout: Cutout): PackingRegion[] {
80206
+ // const areas = [];
80207
+ // // Region A: Right strip (cutout height)
80208
+ // if (plane.width - (cutout.x + cutout.width) > 0) {
80209
+ // areas.push({
80210
+ // dimensions: new Dimensions(
80211
+ // { x: this.margin.l + cutout.x + cutout.width, y: this.margin.t + 0 },
80212
+ // { width: plane.width - (this.margin.l+this.margin.r) - (cutout.x + cutout.width), height: cutout.y + cutout.height }
80213
+ // ),
80214
+ // name: 'A',
80215
+ // maxSlots: 3, // Maximum slots for this region
80216
+ // });
80217
+ // }
80218
+ // // Region B: bottom-left strip (excluding cutout)
80219
+ // if (plane.height - (cutout.y + cutout.height) > 0) {
80220
+ // areas.push({
80221
+ // dimensions: new Dimensions(
80222
+ // { x: this.margin.l + 0, y: cutout.y + cutout.height },
80223
+ // { width: plane.width - (this.margin.l + this.margin.r), height: plane.height - (this.margin.t + this.margin.b) - (cutout.y + cutout.height) }
80224
+ // ),
80225
+ // name: 'B',
80226
+ // maxSlots: 1, // Maximum slots for this region
80227
+ // });
80228
+ // }
80229
+ // return areas;
80230
+ // }
80180
80231
  key: "get",
80181
80232
  value: function get(plane, cutout) {
80182
80233
  var areas = [];
80183
80234
  if (plane.width - (cutout.x + cutout.width) > 0) {
80184
80235
  areas.push({
80185
80236
  dimensions: new Dimensions({
80186
- x: cutout.x + cutout.width,
80187
- y: 0
80237
+ x: this.margin.l + cutout.x + cutout.width,
80238
+ y: this.margin.t + 0
80188
80239
  }, {
80189
80240
  width: plane.width - (cutout.x + cutout.width),
80190
- height: cutout.y + cutout.height
80241
+ height: plane.height - (this.margin.t + this.margin.b)
80191
80242
  }),
80192
80243
  name: "A",
80193
80244
  maxSlots: 3
@@ -80196,12 +80247,14 @@ var DefaultTemplate = /*#__PURE__*/ function() {
80196
80247
  if (plane.height - (cutout.y + cutout.height) > 0) {
80197
80248
  areas.push({
80198
80249
  dimensions: new Dimensions({
80199
- x: 0,
80200
- y: cutout.y + cutout.height
80250
+ x: this.margin.l + 0,
80251
+ y: this.margin.t + cutout.y + cutout.height
80201
80252
  }, {
80202
- width: plane.width,
80203
- height: plane.height - (cutout.y + cutout.height)
80253
+ width: cutout.x + cutout.width,
80254
+ height: plane.height - (this.margin.t + this.margin.b) - (cutout.y + cutout.height)
80204
80255
  }),
80256
+ available: {
80257
+ },
80205
80258
  name: "B",
80206
80259
  maxSlots: 1
80207
80260
  });
@@ -80215,6 +80268,12 @@ var DefaultTemplate = /*#__PURE__*/ function() {
80215
80268
  var FullscreenTemplate = /*#__PURE__*/ function() {
80216
80269
  function FullscreenTemplate() {
80217
80270
  _class_call_check(this, FullscreenTemplate);
80271
+ this.margin = {
80272
+ t: 0,
80273
+ r: 0,
80274
+ b: 64,
80275
+ l: 0
80276
+ };
80218
80277
  }
80219
80278
  _create_class(FullscreenTemplate, [
80220
80279
  {
@@ -80224,11 +80283,11 @@ var FullscreenTemplate = /*#__PURE__*/ function() {
80224
80283
  if (plane.width - (cutout.x + cutout.width) > 0) {
80225
80284
  areas.push({
80226
80285
  dimensions: new Dimensions({
80227
- x: cutout.x + cutout.width,
80228
- y: 0
80286
+ x: this.margin.l + cutout.x + cutout.width,
80287
+ y: this.margin.t + 0
80229
80288
  }, {
80230
80289
  width: plane.width - (cutout.x + cutout.width),
80231
- height: plane.height
80290
+ height: plane.height - (this.margin.t + this.margin.b)
80232
80291
  }),
80233
80292
  name: "A",
80234
80293
  maxSlots: 3
@@ -80237,11 +80296,11 @@ var FullscreenTemplate = /*#__PURE__*/ function() {
80237
80296
  if (plane.height - (cutout.y + cutout.height) > 0) {
80238
80297
  areas.push({
80239
80298
  dimensions: new Dimensions({
80240
- x: 0,
80241
- y: cutout.y + cutout.height
80299
+ x: this.margin.l + 0,
80300
+ y: this.margin.t + cutout.y + cutout.height
80242
80301
  }, {
80243
80302
  width: cutout.x + cutout.width,
80244
- height: plane.height - (cutout.y + cutout.height)
80303
+ height: plane.height - (this.margin.t + this.margin.b) - (cutout.y + cutout.height)
80245
80304
  }),
80246
80305
  available: {
80247
80306
  w: 0.7
@@ -80614,10 +80673,11 @@ var BasicAdRegion = /*#__PURE__*/ function(Region) {
80614
80673
  key: "hideRegion",
80615
80674
  value: function hideRegion() {
80616
80675
  return _async_to_generator(function() {
80617
- var _this_deps_recorder;
80618
80676
  return _ts_generator(this, function(_state) {
80619
80677
  switch(_state.label){
80620
80678
  case 0:
80679
+ this.hidden.reset(false);
80680
+ this.content.hide();
80621
80681
  return [
80622
80682
  4,
80623
80683
  this.applyPlugins("beforeHide")
@@ -80630,7 +80690,7 @@ var BasicAdRegion = /*#__PURE__*/ function(Region) {
80630
80690
  this.content.clear();
80631
80691
  this.applyPlugins("afterHide");
80632
80692
  this.visible = false;
80633
- (_this_deps_recorder = this.deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.presentationStateChanged(this, true);
80693
+ this.hidden.resolve(true);
80634
80694
  return [
80635
80695
  2
80636
80696
  ];
@@ -80639,30 +80699,40 @@ var BasicAdRegion = /*#__PURE__*/ function(Region) {
80639
80699
  }).call(this);
80640
80700
  }
80641
80701
  },
80702
+ {
80703
+ key: "showRegion",
80704
+ value: function showRegion() {
80705
+ return _async_to_generator(function() {
80706
+ var _this_deps_recorder;
80707
+ return _ts_generator(this, function(_state) {
80708
+ this.applyPlugins("beforeShow");
80709
+ this.container.style.display = "block";
80710
+ this.container.style.position = "relative";
80711
+ this.container.style.width = "".concat(this.box.width(this.plane.size), "px");
80712
+ this.container.style.height = "".concat(this.box.height(this.plane.size), "px");
80713
+ this.content.render();
80714
+ this.applyPlugins("afterShow");
80715
+ this.visible = true;
80716
+ (_this_deps_recorder = this.deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.presentationStateChanged(this, true);
80717
+ return [
80718
+ 2
80719
+ ];
80720
+ });
80721
+ }).call(this);
80722
+ }
80723
+ },
80642
80724
  {
80643
80725
  key: "render",
80644
80726
  value: function render(contours, box) {
80645
80727
  return _async_to_generator(function() {
80646
- var _this_deps_recorder;
80647
80728
  return _ts_generator(this, function(_state) {
80648
80729
  this.applyPlugins("beforeRender");
80649
80730
  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);
80731
+ this.showRegion();
80660
80732
  } else if (this.shouldHide()) {
80661
80733
  this.hideRegion();
80662
80734
  } else {
80663
80735
  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
80736
  this.applyPlugins("reRender");
80667
80737
  }
80668
80738
  }
@@ -80674,48 +80744,6 @@ var BasicAdRegion = /*#__PURE__*/ function(Region) {
80674
80744
  }).call(this);
80675
80745
  }
80676
80746
  },
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
80747
  {
80720
80748
  key: "updateSize",
80721
80749
  value: function updateSize(width, height) {
@@ -80745,7 +80773,10 @@ var BasicAdRegion = /*#__PURE__*/ function(Region) {
80745
80773
  value: function clear() {
80746
80774
  var _this = this;
80747
80775
  this.hideRegion().then(function() {
80748
- _this.updateSize(0, 0);
80776
+ _this.plane.update({
80777
+ width: 0,
80778
+ height: 0
80779
+ });
80749
80780
  });
80750
80781
  }
80751
80782
  }
@@ -80935,83 +80966,116 @@ var AdRegionsArea = /*#__PURE__*/ function() {
80935
80966
  {
80936
80967
  key: "render",
80937
80968
  value: function render(regions2) {
80938
- if (!regions2 || !regions2.length) {
80939
- this.clear();
80940
- return;
80941
- }
80942
- var mapped = new MappedCollection();
80943
- mapped.load(regions2);
80944
- var visibleRegions = this.regionsObjects.getVisible();
80945
- var diffLeft = getDifferenceLeft(visibleRegions, regions2);
80946
- var diffRight = getDifferenceRight(visibleRegions, regions2);
80947
- var common = getIntersection(visibleRegions, regions2);
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
80969
+ return _async_to_generator(function() {
80970
+ var mapped, visibleRegions, diffLeft, diffRight, pending, common, index, existingObject2, index1, pack, index2, existingObject21, pack1, region, provider, plugins2, newRegion;
80971
+ return _ts_generator(this, function(_state) {
80972
+ switch(_state.label){
80973
+ case 0:
80974
+ if (!regions2 || !regions2.length) {
80975
+ this.clear();
80976
+ return [
80977
+ 2
80978
+ ];
80987
80979
  }
80988
- }, {
80989
- provider: provider,
80990
- plugins: plugins2,
80991
- recorder: this.context.recorder
80992
- });
80993
- this.regionsObjects.push(newRegion);
80994
- this.regionsContainerView.append(newRegion.view);
80995
- this.intersectionObserver.observe(newRegion.view);
80980
+ mapped = new MappedCollection();
80981
+ mapped.load(regions2);
80982
+ visibleRegions = this.regionsObjects.getVisible();
80983
+ diffLeft = getDifferenceLeft(visibleRegions, regions2);
80984
+ diffRight = getDifferenceRight(visibleRegions, regions2);
80985
+ pending = [];
80986
+ common = getIntersection(visibleRegions, regions2);
80987
+ for(index = 0; index < diffLeft.length; index++){
80988
+ existingObject2 = this.regionsObjects.getById(diffLeft[index].id);
80989
+ if (existingObject2) {
80990
+ existingObject2.updateSize(0, 0);
80991
+ pending.push(existingObject2.hidden.promise);
80992
+ }
80993
+ }
80994
+ if (!common.length) return [
80995
+ 3,
80996
+ 1
80997
+ ];
80998
+ for(index1 = 0; index1 < common.length; index1++){
80999
+ if (index1 < this.maxRegions) {
81000
+ pack = mapped.getById(common[index1].id);
81001
+ if (pack) {
81002
+ common[index1].updateSize(pack.width, pack.height);
81003
+ }
81004
+ } else {
81005
+ common[index1].updateSize(0, 0);
81006
+ pending.push(existingObject.hidden.promise);
81007
+ }
81008
+ }
81009
+ return [
81010
+ 3,
81011
+ 3
81012
+ ];
81013
+ case 1:
81014
+ return [
81015
+ 4,
81016
+ Promise.all(pending)
81017
+ ];
81018
+ case 2:
81019
+ _state.sent();
81020
+ for(index2 = 0; index2 < diffRight.length && index2 < this.maxRegions; index2++){
81021
+ existingObject21 = this.regionsObjects.getById(diffRight[index2].id);
81022
+ if (existingObject21) {
81023
+ pack1 = mapped.getById(diffRight[index2].id);
81024
+ if (pack1) {
81025
+ existingObject21.updateSize(pack1.width, pack1.height);
81026
+ }
81027
+ } else {
81028
+ region = diffRight[index2];
81029
+ provider = ContentProviderFactory.getProvider(this.context, this.context.config.get("ads").provider);
81030
+ plugins2 = [
81031
+ new RegionBorderPlugin(),
81032
+ new RegionAnimationPlugin("OPACITY")
81033
+ ];
81034
+ newRegion = new BasicAdRegion(region.id, {
81035
+ width: region.width,
81036
+ height: region.height
81037
+ }, {
81038
+ ad: {
81039
+ type: region.type,
81040
+ name: region.region
81041
+ }
81042
+ }, {
81043
+ provider: provider,
81044
+ plugins: plugins2,
81045
+ recorder: this.context.recorder
81046
+ });
81047
+ this.regionsObjects.push(newRegion);
81048
+ this.regionsContainerView.append(newRegion.view);
81049
+ this.intersectionObserver.observe(newRegion.view);
81050
+ }
81051
+ }
81052
+ _state.label = 3;
81053
+ case 3:
81054
+ return [
81055
+ 2
81056
+ ];
80996
81057
  }
80997
- }
80998
- }
81058
+ });
81059
+ }).call(this);
80999
81060
  }
81000
81061
  },
81001
81062
  {
81002
81063
  key: "clear",
81003
81064
  value: function clear() {
81004
- this.updateSize({
81005
- width: 0,
81006
- height: 0
81007
- }, this.context.media.aspectRatio);
81008
- this.updatePosition({
81009
- x: 0,
81010
- y: 0
81011
- });
81065
+ var _this = this;
81012
81066
  this.regionsObjects.forEach(function(region) {
81013
81067
  region.clear();
81014
81068
  });
81069
+ setTimeout(function() {
81070
+ _this.updateSize({
81071
+ width: 0,
81072
+ height: 0
81073
+ }, _this.context.media.aspectRatio);
81074
+ _this.updatePosition({
81075
+ x: 0,
81076
+ y: 0
81077
+ });
81078
+ }, 500);
81015
81079
  }
81016
81080
  },
81017
81081
  {
@@ -81109,9 +81173,9 @@ var RegionRenderer = /*#__PURE__*/ function() {
81109
81173
  {
81110
81174
  key: "clear",
81111
81175
  value: function clear() {
81112
- var regions2 = Object.values(this.regionAreas);
81113
- for(var index = 0; index < regions2.length; index++){
81114
- regions2[index].clear();
81176
+ var areas = Object.values(this.regionAreas);
81177
+ for(var index = 0; index < areas.length; index++){
81178
+ areas[index].clear();
81115
81179
  }
81116
81180
  }
81117
81181
  },
@@ -82079,9 +82143,9 @@ var RegionRenderer2 = /*#__PURE__*/ function() {
82079
82143
  }
82080
82144
  } else {
82081
82145
  for(var index1 = 0; index1 < diffRight.length && index1 < this.maxRegions; index1++){
82082
- var existingObject = this.regionsObjects.getById(diffRight[index1].id);
82083
- if (existingObject) {
82084
- existingObject.updateRegion(mapped.getById(diffRight[index1].id));
82146
+ var existingObject2 = this.regionsObjects.getById(diffRight[index1].id);
82147
+ if (existingObject2) {
82148
+ existingObject2.updateRegion(mapped.getById(diffRight[index1].id));
82085
82149
  } else {
82086
82150
  var newRegion = this.regionFactory.get(diffRight[index1], {
82087
82151
  width: this.regionsContainerView.width,
@@ -82096,9 +82160,9 @@ var RegionRenderer2 = /*#__PURE__*/ function() {
82096
82160
  }
82097
82161
  }
82098
82162
  for(var index2 = 0; index2 < diffLeft.length; index2++){
82099
- var existingObject1 = this.regionsObjects.getById(diffLeft[index2].id);
82100
- if (existingObject1) {
82101
- existingObject1.clear();
82163
+ var existingObject21 = this.regionsObjects.getById(diffLeft[index2].id);
82164
+ if (existingObject21) {
82165
+ existingObject21.clear();
82102
82166
  }
82103
82167
  }
82104
82168
  this.regionsData = regions2;