@brndts/brndts-ads 1.14.17 → 1.14.19

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
@@ -69797,6 +69797,250 @@ var TYPE_AND_DIMENSIONS = {
69797
69797
  ]
69798
69798
  ]
69799
69799
  };
69800
+ var BREAKPOINTS = {
69801
+ "large-desktop": 1280,
69802
+ "desktop": 1024,
69803
+ "tablet": 768,
69804
+ "mobile": 0
69805
+ };
69806
+ var RULES = {
69807
+ "billboard": {
69808
+ "large-desktop": [
69809
+ [
69810
+ 970,
69811
+ 250
69812
+ ],
69813
+ [
69814
+ 970,
69815
+ 90
69816
+ ]
69817
+ ],
69818
+ // allow billboard + super lb
69819
+ "desktop": [
69820
+ [
69821
+ 970,
69822
+ 250
69823
+ ],
69824
+ [
69825
+ 970,
69826
+ 90
69827
+ ]
69828
+ ],
69829
+ // drop 970x250, still wide
69830
+ "tablet": [
69831
+ [
69832
+ 728,
69833
+ 90
69834
+ ],
69835
+ [
69836
+ 468,
69837
+ 60
69838
+ ]
69839
+ ]
69840
+ },
69841
+ "leaderboard": {
69842
+ "large-desktop": [
69843
+ [
69844
+ 728,
69845
+ 90
69846
+ ]
69847
+ ],
69848
+ "desktop": [
69849
+ [
69850
+ 728,
69851
+ 90
69852
+ ],
69853
+ [
69854
+ 468,
69855
+ 60
69856
+ ]
69857
+ ],
69858
+ "tablet": [
69859
+ [
69860
+ 728,
69861
+ 90
69862
+ ],
69863
+ [
69864
+ 468,
69865
+ 60
69866
+ ]
69867
+ ],
69868
+ "mobile": [
69869
+ [
69870
+ 728,
69871
+ 90
69872
+ ],
69873
+ [
69874
+ 468,
69875
+ 60
69876
+ ],
69877
+ [
69878
+ 320,
69879
+ 50
69880
+ ],
69881
+ [
69882
+ 300,
69883
+ 50
69884
+ ]
69885
+ ]
69886
+ },
69887
+ "large-rectangle": {
69888
+ "large-desktop": [
69889
+ [
69890
+ 300,
69891
+ 600
69892
+ ],
69893
+ [
69894
+ 160,
69895
+ 600
69896
+ ]
69897
+ ],
69898
+ "desktop": [
69899
+ [
69900
+ 300,
69901
+ 600
69902
+ ],
69903
+ [
69904
+ 160,
69905
+ 600
69906
+ ]
69907
+ ],
69908
+ "tablet": [
69909
+ [
69910
+ 160,
69911
+ 600
69912
+ ],
69913
+ [
69914
+ 120,
69915
+ 600
69916
+ ]
69917
+ ]
69918
+ },
69919
+ "medium-rectangle": {
69920
+ "large-desktop": [
69921
+ [
69922
+ 300,
69923
+ 250
69924
+ ],
69925
+ [
69926
+ 250,
69927
+ 250
69928
+ ],
69929
+ [
69930
+ 200,
69931
+ 200
69932
+ ]
69933
+ ],
69934
+ "desktop": [
69935
+ [
69936
+ 300,
69937
+ 250
69938
+ ],
69939
+ [
69940
+ 250,
69941
+ 250
69942
+ ],
69943
+ [
69944
+ 200,
69945
+ 200
69946
+ ]
69947
+ ],
69948
+ "tablet": [
69949
+ [
69950
+ 300,
69951
+ 250
69952
+ ],
69953
+ [
69954
+ 250,
69955
+ 250
69956
+ ],
69957
+ [
69958
+ 200,
69959
+ 200
69960
+ ],
69961
+ [
69962
+ 180,
69963
+ 150
69964
+ ]
69965
+ ],
69966
+ "mobile": [
69967
+ [
69968
+ 300,
69969
+ 250
69970
+ ],
69971
+ [
69972
+ 250,
69973
+ 250
69974
+ ],
69975
+ [
69976
+ 180,
69977
+ 150
69978
+ ],
69979
+ [
69980
+ 150,
69981
+ 150
69982
+ ]
69983
+ ]
69984
+ },
69985
+ "smartphone-banner": {
69986
+ "large-desktop": [
69987
+ [
69988
+ 320,
69989
+ 50
69990
+ ],
69991
+ [
69992
+ 300,
69993
+ 50
69994
+ ],
69995
+ [
69996
+ 320,
69997
+ 100
69998
+ ]
69999
+ ],
70000
+ "desktop": [
70001
+ [
70002
+ 320,
70003
+ 50
70004
+ ],
70005
+ [
70006
+ 300,
70007
+ 50
70008
+ ],
70009
+ [
70010
+ 320,
70011
+ 100
70012
+ ]
70013
+ ],
70014
+ "tablet": [
70015
+ [
70016
+ 320,
70017
+ 50
70018
+ ],
70019
+ [
70020
+ 300,
70021
+ 50
70022
+ ],
70023
+ [
70024
+ 320,
70025
+ 100
70026
+ ]
70027
+ ],
70028
+ "mobile": [
70029
+ [
70030
+ 320,
70031
+ 50
70032
+ ],
70033
+ [
70034
+ 300,
70035
+ 50
70036
+ ],
70037
+ [
70038
+ 320,
70039
+ 100
70040
+ ]
70041
+ ]
70042
+ }
70043
+ };
69800
70044
  var REGIONS = [
69801
70045
  {
69802
70046
  id: 1,
@@ -70131,6 +70375,30 @@ var RegionDefinitions = /*#__PURE__*/ function() {
70131
70375
  return REGIONS;
70132
70376
  }
70133
70377
  },
70378
+ {
70379
+ key: "BREAKPOINTS",
70380
+ get: function get() {
70381
+ return BREAKPOINTS;
70382
+ }
70383
+ },
70384
+ {
70385
+ key: "RULES",
70386
+ get: function get() {
70387
+ return RULES;
70388
+ }
70389
+ },
70390
+ {
70391
+ key: "mapping",
70392
+ value: function mapping(type) {
70393
+ return RULES[type];
70394
+ }
70395
+ },
70396
+ {
70397
+ key: "getBreakpointsSize",
70398
+ value: function getBreakpointsSize(breakpointLabel) {
70399
+ return BREAKPOINTS[breakpointLabel];
70400
+ }
70401
+ },
70134
70402
  {
70135
70403
  key: "approxRegionByRatio",
70136
70404
  value: function approxRegionByRatio(w2, h) {
@@ -71610,6 +71878,13 @@ var PrebidConfigBuilder = /*#__PURE__*/ function() {
71610
71878
  return this;
71611
71879
  }
71612
71880
  },
71881
+ {
71882
+ key: "setSizeConfiguration",
71883
+ value: function setSizeConfiguration(config2) {
71884
+ this.config.sizeConfig = config2;
71885
+ return this;
71886
+ }
71887
+ },
71613
71888
  {
71614
71889
  key: "addConsent",
71615
71890
  value: function addConsent(consent) {
@@ -72127,6 +72402,49 @@ var Prebid = /*#__PURE__*/ function() {
72127
72402
  }();
72128
72403
  // src/Ads/Providers/Prebidjs/PrebidGAMProvider.ts
72129
72404
  var FALLBACK_GAM_NETWORK_ID = "23256716895";
72405
+ function toMediaQuery(minWidth) {
72406
+ return "(min-width: ".concat(minWidth, "px)");
72407
+ }
72408
+ function buildPrebidSizeConfig(rules) {
72409
+ var byBp = {
72410
+ "large-desktop": /* @__PURE__ */ new Set(),
72411
+ "desktop": /* @__PURE__ */ new Set(),
72412
+ "tablet": /* @__PURE__ */ new Set(),
72413
+ "mobile": /* @__PURE__ */ new Set()
72414
+ };
72415
+ Object.values(rules).forEach(function(perType) {
72416
+ Object.keys(perType).forEach(function(bp) {
72417
+ var _perType_bp;
72418
+ (_perType_bp = perType[bp]) === null || _perType_bp === void 0 ? void 0 : _perType_bp.forEach(function(param) {
72419
+ var _param = _sliced_to_array(param, 2), w2 = _param[0], h = _param[1];
72420
+ return byBp[bp].add("".concat(w2, "x").concat(h));
72421
+ });
72422
+ });
72423
+ });
72424
+ var toSizes = function(set) {
72425
+ return Array.from(set).map(function(s2) {
72426
+ return s2.split("x").map(Number);
72427
+ });
72428
+ };
72429
+ var ordered = [
72430
+ "large-desktop",
72431
+ "desktop",
72432
+ "tablet",
72433
+ "mobile"
72434
+ ];
72435
+ return ordered.filter(function(bp) {
72436
+ return byBp[bp].size > 0;
72437
+ }).map(function(bp) {
72438
+ return {
72439
+ // @ts-expect-error
72440
+ mediaQuery: toMediaQuery(RegionDefinitions.BREAKPOINTS[bp]),
72441
+ sizesSupported: toSizes(byBp[bp]),
72442
+ labels: [
72443
+ bp
72444
+ ]
72445
+ };
72446
+ });
72447
+ }
72130
72448
  var PrebidGAMEvents = /*#__PURE__*/ function() {
72131
72449
  function PrebidGAMEvents() {
72132
72450
  _class_call_check(this, PrebidGAMEvents);
@@ -72179,38 +72497,6 @@ var GPT = /*#__PURE__*/ function() {
72179
72497
  });
72180
72498
  }
72181
72499
  },
72182
- {
72183
- key: "defineSlot",
72184
- value: function defineSlot(slotId, size, containerId, targeting) {
72185
- window.googletag.cmd.push(function() {
72186
- if (window.googletag.pubads().getSlots().some(function(slot) {
72187
- return slot.getSlotElementId() === containerId;
72188
- })) {
72189
- return;
72190
- }
72191
- var mrec1 = window.googletag.defineSlot(slotId, size, "".concat(containerId)).addService(window.googletag.pubads());
72192
- var mrecmapping = window.googletag.sizeMapping().addSize([
72193
- 1024,
72194
- 0
72195
- ], size).addSize([
72196
- 728,
72197
- 0
72198
- ], size).addSize([
72199
- 320,
72200
- 0
72201
- ], size).addSize([
72202
- 0,
72203
- 0
72204
- ], []).build();
72205
- mrec1 === null || mrec1 === void 0 ? void 0 : mrec1.defineSizeMapping(mrecmapping);
72206
- if (targeting) {
72207
- mrec1.setConfig({
72208
- targeting: targeting
72209
- });
72210
- }
72211
- });
72212
- }
72213
- },
72214
72500
  {
72215
72501
  key: "start",
72216
72502
  value: function start() {
@@ -72228,6 +72514,70 @@ var GPT = /*#__PURE__*/ function() {
72228
72514
  });
72229
72515
  }
72230
72516
  },
72517
+ {
72518
+ key: "defineSlot",
72519
+ value: function defineSlot(slotId, size, containerId, opts) {
72520
+ window.googletag.cmd.push(function() {
72521
+ if (window.googletag.pubads().getSlots().some(function(slot) {
72522
+ return slot.getSlotElementId() === containerId;
72523
+ })) {
72524
+ return;
72525
+ }
72526
+ var mrec1 = window.googletag.defineSlot(slotId, size, "".concat(containerId)).addService(window.googletag.pubads());
72527
+ var mrecmapping;
72528
+ if (opts === null || opts === void 0 ? void 0 : opts.mapping) {
72529
+ mrecmapping = window.googletag.sizeMapping();
72530
+ var sortedBreakpoints = Object.keys(opts.mapping).sort(function(a, b) {
72531
+ return parseInt(RegionDefinitions.BREAKPOINTS[b], 10) - parseInt(RegionDefinitions.BREAKPOINTS[a], 10);
72532
+ });
72533
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
72534
+ try {
72535
+ for(var _iterator = sortedBreakpoints[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
72536
+ var bp = _step.value;
72537
+ mrecmapping = mrecmapping.addSize([
72538
+ RegionDefinitions.BREAKPOINTS[bp],
72539
+ 0
72540
+ ], opts.mapping[bp]);
72541
+ }
72542
+ } catch (err) {
72543
+ _didIteratorError = true;
72544
+ _iteratorError = err;
72545
+ } finally{
72546
+ try {
72547
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
72548
+ _iterator.return();
72549
+ }
72550
+ } finally{
72551
+ if (_didIteratorError) {
72552
+ throw _iteratorError;
72553
+ }
72554
+ }
72555
+ }
72556
+ mrecmapping = mrecmapping.build();
72557
+ } else {
72558
+ window.googletag.sizeMapping().addSize([
72559
+ 1024,
72560
+ 0
72561
+ ], size).addSize([
72562
+ 728,
72563
+ 0
72564
+ ], size).addSize([
72565
+ 320,
72566
+ 0
72567
+ ], size).addSize([
72568
+ 0,
72569
+ 0
72570
+ ], []).build();
72571
+ }
72572
+ mrec1 === null || mrec1 === void 0 ? void 0 : mrec1.defineSizeMapping(mrecmapping);
72573
+ if (opts === null || opts === void 0 ? void 0 : opts.targeting) {
72574
+ mrec1.setConfig({
72575
+ targeting: opts === null || opts === void 0 ? void 0 : opts.targeting
72576
+ });
72577
+ }
72578
+ });
72579
+ }
72580
+ },
72231
72581
  {
72232
72582
  key: "queue",
72233
72583
  value: function queue(callback) {
@@ -72288,7 +72638,7 @@ var PrebidGAM = /*#__PURE__*/ function() {
72288
72638
  params: {}
72289
72639
  }
72290
72640
  ]
72291
- }).addConsent(context.consent);
72641
+ }).setSizeConfiguration(buildPrebidSizeConfig(RegionDefinitions.RULES)).addConsent(context.consent);
72292
72642
  (_window_pbjs = window.pbjs) === null || _window_pbjs === void 0 ? void 0 : _window_pbjs.setConfig(configBuilder.build());
72293
72643
  (_window_pbjs1 = window.pbjs) === null || _window_pbjs1 === void 0 ? void 0 : _window_pbjs1.enableAnalytics({
72294
72644
  provider: "smartyads"
@@ -72335,31 +72685,6 @@ var PrebidGAM = /*#__PURE__*/ function() {
72335
72685
  return gamNetworkId;
72336
72686
  }
72337
72687
  },
72338
- {
72339
- key: "defineSlots",
72340
- value: function defineSlots(options) {
72341
- var _window_pbjs_que, _window_pbjs;
72342
- var gamNetwork = _PrebidGAM.getProperGAMNetworkId(options);
72343
- options.units.forEach(function(unit) {
72344
- var _unit_mediaTypes_banner;
72345
- var sizes = ((_unit_mediaTypes_banner = unit.mediaTypes.banner) === null || _unit_mediaTypes_banner === void 0 ? void 0 : _unit_mediaTypes_banner.sizes) || [];
72346
- GPT.defineSlot("/".concat(gamNetwork, "/banner"), sizes, unit.code);
72347
- });
72348
- (_window_pbjs = window.pbjs) === null || _window_pbjs === void 0 ? void 0 : (_window_pbjs_que = _window_pbjs.que) === null || _window_pbjs_que === void 0 ? void 0 : _window_pbjs_que.push(function() {
72349
- var _window_pbjs;
72350
- if ((_window_pbjs = window.pbjs) === null || _window_pbjs === void 0 ? void 0 : _window_pbjs.addAdUnits) {
72351
- window.pbjs.addAdUnits(options.units.filter(function(unit) {
72352
- var _window_pbjs;
72353
- return !((_window_pbjs = window.pbjs) === null || _window_pbjs === void 0 ? void 0 : _window_pbjs.adUnits.some(function(defUnit) {
72354
- return "".concat(unit.code) === "".concat(defUnit.code);
72355
- }));
72356
- }));
72357
- } else {
72358
- console.error("addAdUnits is not a function.");
72359
- }
72360
- });
72361
- }
72362
- },
72363
72688
  {
72364
72689
  key: "defineSlot",
72365
72690
  value: function defineSlot(options, slotId, containerId, adType) {
@@ -72370,12 +72695,14 @@ var PrebidGAM = /*#__PURE__*/ function() {
72370
72695
  return unit.code === "".concat(slotId);
72371
72696
  });
72372
72697
  var sizes = [];
72698
+ var mapping = void 0;
72373
72699
  if (!unitDefinition) {
72374
72700
  console.error("No unit definition found for slotId: ".concat(slotId));
72375
72701
  return;
72376
72702
  }
72377
72703
  if (adType) {
72378
72704
  sizes = RegionDefinitions.TYPE_AND_DIMENSIONS[adType];
72705
+ mapping = RegionDefinitions.mapping(adType);
72379
72706
  } else {
72380
72707
  var _unitDefinition_mediaTypes_banner;
72381
72708
  sizes = ((_unitDefinition_mediaTypes_banner = unitDefinition.mediaTypes.banner) === null || _unitDefinition_mediaTypes_banner === void 0 ? void 0 : _unitDefinition_mediaTypes_banner.sizes) || [];
@@ -72387,7 +72714,10 @@ var PrebidGAM = /*#__PURE__*/ function() {
72387
72714
  brndts_zid: unitDefinition.zoneId
72388
72715
  };
72389
72716
  }
72390
- GPT.defineSlot("/".concat(gamNetworkId, "/").concat(adName), sizes, "".concat(containerId), targeting);
72717
+ GPT.defineSlot("/".concat(gamNetworkId, "/").concat(adName), sizes, "".concat(containerId), {
72718
+ targeting: targeting,
72719
+ mapping: mapping
72720
+ });
72391
72721
  if (!((_window_pbjs = window.pbjs) === null || _window_pbjs === void 0 ? void 0 : _window_pbjs.adUnits.some(function(defUnit) {
72392
72722
  return "".concat(containerId) === "".concat(defUnit.code);
72393
72723
  }))) {
@@ -72395,15 +72725,51 @@ var PrebidGAM = /*#__PURE__*/ function() {
72395
72725
  (_window_pbjs1 = window.pbjs) === null || _window_pbjs1 === void 0 ? void 0 : (_window_pbjs_que = _window_pbjs1.que) === null || _window_pbjs_que === void 0 ? void 0 : _window_pbjs_que.push(function() {
72396
72726
  var _window_pbjs;
72397
72727
  if ((_window_pbjs = window.pbjs) === null || _window_pbjs === void 0 ? void 0 : _window_pbjs.addAdUnits) {
72728
+ var adUnit = _object_spread_props(_object_spread({}, unitDefinition), {
72729
+ mediaTypes: _object_spread_props(_object_spread({}, unitDefinition.mediaTypes || {}), {
72730
+ banner: _object_spread_props(_object_spread({}, unitDefinition.mediaTypes.banner || {}), {
72731
+ sizes: sizes
72732
+ })
72733
+ }),
72734
+ code: "".concat(containerId)
72735
+ });
72736
+ if (mapping) {
72737
+ var mappedSizes = [];
72738
+ var sortedBreakpoints = Object.keys(mapping).sort(function(a, b) {
72739
+ return parseInt(RegionDefinitions.BREAKPOINTS[b], 10) - parseInt(RegionDefinitions.BREAKPOINTS[a], 10);
72740
+ });
72741
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
72742
+ try {
72743
+ for(var _iterator = sortedBreakpoints[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
72744
+ var bp = _step.value;
72745
+ mappedSizes.push({
72746
+ minViewPort: [
72747
+ RegionDefinitions.BREAKPOINTS[bp],
72748
+ 0
72749
+ ],
72750
+ sizes: mapping[bp]
72751
+ });
72752
+ }
72753
+ } catch (err) {
72754
+ _didIteratorError = true;
72755
+ _iteratorError = err;
72756
+ } finally{
72757
+ try {
72758
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
72759
+ _iterator.return();
72760
+ }
72761
+ } finally{
72762
+ if (_didIteratorError) {
72763
+ throw _iteratorError;
72764
+ }
72765
+ }
72766
+ }
72767
+ adUnit.mediaTypes.banner.sizeConfig = mappedSizes;
72768
+ } else {
72769
+ adUnit.mediaTypes.banner.sizes = sizes;
72770
+ }
72398
72771
  window.pbjs.addAdUnits([
72399
- _object_spread_props(_object_spread({}, unitDefinition), {
72400
- mediaTypes: _object_spread_props(_object_spread({}, unitDefinition.mediaTypes || {}), {
72401
- banner: _object_spread_props(_object_spread({}, unitDefinition.mediaTypes.banner || {}), {
72402
- sizes: sizes
72403
- })
72404
- }),
72405
- code: "".concat(containerId)
72406
- })
72772
+ adUnit
72407
72773
  ]);
72408
72774
  } else {
72409
72775
  console.error("addAdUnits is not a function.");