@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.mjs CHANGED
@@ -69843,6 +69843,250 @@ var TYPE_AND_DIMENSIONS = {
69843
69843
  ]
69844
69844
  ]
69845
69845
  };
69846
+ var BREAKPOINTS = {
69847
+ "large-desktop": 1280,
69848
+ "desktop": 1024,
69849
+ "tablet": 768,
69850
+ "mobile": 0
69851
+ };
69852
+ var RULES = {
69853
+ "billboard": {
69854
+ "large-desktop": [
69855
+ [
69856
+ 970,
69857
+ 250
69858
+ ],
69859
+ [
69860
+ 970,
69861
+ 90
69862
+ ]
69863
+ ],
69864
+ // allow billboard + super lb
69865
+ "desktop": [
69866
+ [
69867
+ 970,
69868
+ 250
69869
+ ],
69870
+ [
69871
+ 970,
69872
+ 90
69873
+ ]
69874
+ ],
69875
+ // drop 970x250, still wide
69876
+ "tablet": [
69877
+ [
69878
+ 728,
69879
+ 90
69880
+ ],
69881
+ [
69882
+ 468,
69883
+ 60
69884
+ ]
69885
+ ]
69886
+ },
69887
+ "leaderboard": {
69888
+ "large-desktop": [
69889
+ [
69890
+ 728,
69891
+ 90
69892
+ ]
69893
+ ],
69894
+ "desktop": [
69895
+ [
69896
+ 728,
69897
+ 90
69898
+ ],
69899
+ [
69900
+ 468,
69901
+ 60
69902
+ ]
69903
+ ],
69904
+ "tablet": [
69905
+ [
69906
+ 728,
69907
+ 90
69908
+ ],
69909
+ [
69910
+ 468,
69911
+ 60
69912
+ ]
69913
+ ],
69914
+ "mobile": [
69915
+ [
69916
+ 728,
69917
+ 90
69918
+ ],
69919
+ [
69920
+ 468,
69921
+ 60
69922
+ ],
69923
+ [
69924
+ 320,
69925
+ 50
69926
+ ],
69927
+ [
69928
+ 300,
69929
+ 50
69930
+ ]
69931
+ ]
69932
+ },
69933
+ "large-rectangle": {
69934
+ "large-desktop": [
69935
+ [
69936
+ 300,
69937
+ 600
69938
+ ],
69939
+ [
69940
+ 160,
69941
+ 600
69942
+ ]
69943
+ ],
69944
+ "desktop": [
69945
+ [
69946
+ 300,
69947
+ 600
69948
+ ],
69949
+ [
69950
+ 160,
69951
+ 600
69952
+ ]
69953
+ ],
69954
+ "tablet": [
69955
+ [
69956
+ 160,
69957
+ 600
69958
+ ],
69959
+ [
69960
+ 120,
69961
+ 600
69962
+ ]
69963
+ ]
69964
+ },
69965
+ "medium-rectangle": {
69966
+ "large-desktop": [
69967
+ [
69968
+ 300,
69969
+ 250
69970
+ ],
69971
+ [
69972
+ 250,
69973
+ 250
69974
+ ],
69975
+ [
69976
+ 200,
69977
+ 200
69978
+ ]
69979
+ ],
69980
+ "desktop": [
69981
+ [
69982
+ 300,
69983
+ 250
69984
+ ],
69985
+ [
69986
+ 250,
69987
+ 250
69988
+ ],
69989
+ [
69990
+ 200,
69991
+ 200
69992
+ ]
69993
+ ],
69994
+ "tablet": [
69995
+ [
69996
+ 300,
69997
+ 250
69998
+ ],
69999
+ [
70000
+ 250,
70001
+ 250
70002
+ ],
70003
+ [
70004
+ 200,
70005
+ 200
70006
+ ],
70007
+ [
70008
+ 180,
70009
+ 150
70010
+ ]
70011
+ ],
70012
+ "mobile": [
70013
+ [
70014
+ 300,
70015
+ 250
70016
+ ],
70017
+ [
70018
+ 250,
70019
+ 250
70020
+ ],
70021
+ [
70022
+ 180,
70023
+ 150
70024
+ ],
70025
+ [
70026
+ 150,
70027
+ 150
70028
+ ]
70029
+ ]
70030
+ },
70031
+ "smartphone-banner": {
70032
+ "large-desktop": [
70033
+ [
70034
+ 320,
70035
+ 50
70036
+ ],
70037
+ [
70038
+ 300,
70039
+ 50
70040
+ ],
70041
+ [
70042
+ 320,
70043
+ 100
70044
+ ]
70045
+ ],
70046
+ "desktop": [
70047
+ [
70048
+ 320,
70049
+ 50
70050
+ ],
70051
+ [
70052
+ 300,
70053
+ 50
70054
+ ],
70055
+ [
70056
+ 320,
70057
+ 100
70058
+ ]
70059
+ ],
70060
+ "tablet": [
70061
+ [
70062
+ 320,
70063
+ 50
70064
+ ],
70065
+ [
70066
+ 300,
70067
+ 50
70068
+ ],
70069
+ [
70070
+ 320,
70071
+ 100
70072
+ ]
70073
+ ],
70074
+ "mobile": [
70075
+ [
70076
+ 320,
70077
+ 50
70078
+ ],
70079
+ [
70080
+ 300,
70081
+ 50
70082
+ ],
70083
+ [
70084
+ 320,
70085
+ 100
70086
+ ]
70087
+ ]
70088
+ }
70089
+ };
69846
70090
  var REGIONS = [
69847
70091
  {
69848
70092
  id: 1,
@@ -70178,6 +70422,30 @@ var RegionDefinitions = /*#__PURE__*/ function() {
70178
70422
  return REGIONS;
70179
70423
  }
70180
70424
  },
70425
+ {
70426
+ key: "BREAKPOINTS",
70427
+ get: function get() {
70428
+ return BREAKPOINTS;
70429
+ }
70430
+ },
70431
+ {
70432
+ key: "RULES",
70433
+ get: function get() {
70434
+ return RULES;
70435
+ }
70436
+ },
70437
+ {
70438
+ key: "mapping",
70439
+ value: function mapping(type) {
70440
+ return RULES[type];
70441
+ }
70442
+ },
70443
+ {
70444
+ key: "getBreakpointsSize",
70445
+ value: function getBreakpointsSize(breakpointLabel) {
70446
+ return BREAKPOINTS[breakpointLabel];
70447
+ }
70448
+ },
70181
70449
  {
70182
70450
  key: "approxRegionByRatio",
70183
70451
  value: function approxRegionByRatio(w2, h) {
@@ -71675,6 +71943,13 @@ var PrebidConfigBuilder = /*#__PURE__*/ function() {
71675
71943
  return this;
71676
71944
  }
71677
71945
  },
71946
+ {
71947
+ key: "setSizeConfiguration",
71948
+ value: function setSizeConfiguration(config2) {
71949
+ this.config.sizeConfig = config2;
71950
+ return this;
71951
+ }
71952
+ },
71678
71953
  {
71679
71954
  key: "addConsent",
71680
71955
  value: function addConsent(consent) {
@@ -72195,6 +72470,49 @@ var Prebid = /*#__PURE__*/ function() {
72195
72470
  }();
72196
72471
  // src/Ads/Providers/Prebidjs/PrebidGAMProvider.ts
72197
72472
  var FALLBACK_GAM_NETWORK_ID = "23256716895";
72473
+ function toMediaQuery(minWidth) {
72474
+ return "(min-width: ".concat(minWidth, "px)");
72475
+ }
72476
+ function buildPrebidSizeConfig(rules) {
72477
+ var byBp = {
72478
+ "large-desktop": /* @__PURE__ */ new Set(),
72479
+ "desktop": /* @__PURE__ */ new Set(),
72480
+ "tablet": /* @__PURE__ */ new Set(),
72481
+ "mobile": /* @__PURE__ */ new Set()
72482
+ };
72483
+ Object.values(rules).forEach(function(perType) {
72484
+ Object.keys(perType).forEach(function(bp) {
72485
+ var _perType_bp;
72486
+ (_perType_bp = perType[bp]) === null || _perType_bp === void 0 ? void 0 : _perType_bp.forEach(function(param) {
72487
+ var _param = _sliced_to_array(param, 2), w2 = _param[0], h = _param[1];
72488
+ return byBp[bp].add("".concat(w2, "x").concat(h));
72489
+ });
72490
+ });
72491
+ });
72492
+ var toSizes = function(set) {
72493
+ return Array.from(set).map(function(s2) {
72494
+ return s2.split("x").map(Number);
72495
+ });
72496
+ };
72497
+ var ordered = [
72498
+ "large-desktop",
72499
+ "desktop",
72500
+ "tablet",
72501
+ "mobile"
72502
+ ];
72503
+ return ordered.filter(function(bp) {
72504
+ return byBp[bp].size > 0;
72505
+ }).map(function(bp) {
72506
+ return {
72507
+ // @ts-expect-error
72508
+ mediaQuery: toMediaQuery(RegionDefinitions.BREAKPOINTS[bp]),
72509
+ sizesSupported: toSizes(byBp[bp]),
72510
+ labels: [
72511
+ bp
72512
+ ]
72513
+ };
72514
+ });
72515
+ }
72198
72516
  var PrebidGAMEvents = /*#__PURE__*/ function() {
72199
72517
  "use strict";
72200
72518
  function PrebidGAMEvents() {
@@ -72249,38 +72567,6 @@ var GPT = /*#__PURE__*/ function() {
72249
72567
  });
72250
72568
  }
72251
72569
  },
72252
- {
72253
- key: "defineSlot",
72254
- value: function defineSlot(slotId, size, containerId, targeting) {
72255
- window.googletag.cmd.push(function() {
72256
- if (window.googletag.pubads().getSlots().some(function(slot) {
72257
- return slot.getSlotElementId() === containerId;
72258
- })) {
72259
- return;
72260
- }
72261
- var mrec1 = window.googletag.defineSlot(slotId, size, "".concat(containerId)).addService(window.googletag.pubads());
72262
- var mrecmapping = window.googletag.sizeMapping().addSize([
72263
- 1024,
72264
- 0
72265
- ], size).addSize([
72266
- 728,
72267
- 0
72268
- ], size).addSize([
72269
- 320,
72270
- 0
72271
- ], size).addSize([
72272
- 0,
72273
- 0
72274
- ], []).build();
72275
- mrec1 === null || mrec1 === void 0 ? void 0 : mrec1.defineSizeMapping(mrecmapping);
72276
- if (targeting) {
72277
- mrec1.setConfig({
72278
- targeting: targeting
72279
- });
72280
- }
72281
- });
72282
- }
72283
- },
72284
72570
  {
72285
72571
  key: "start",
72286
72572
  value: function start() {
@@ -72298,6 +72584,70 @@ var GPT = /*#__PURE__*/ function() {
72298
72584
  });
72299
72585
  }
72300
72586
  },
72587
+ {
72588
+ key: "defineSlot",
72589
+ value: function defineSlot(slotId, size, containerId, opts) {
72590
+ window.googletag.cmd.push(function() {
72591
+ if (window.googletag.pubads().getSlots().some(function(slot) {
72592
+ return slot.getSlotElementId() === containerId;
72593
+ })) {
72594
+ return;
72595
+ }
72596
+ var mrec1 = window.googletag.defineSlot(slotId, size, "".concat(containerId)).addService(window.googletag.pubads());
72597
+ var mrecmapping;
72598
+ if (opts === null || opts === void 0 ? void 0 : opts.mapping) {
72599
+ mrecmapping = window.googletag.sizeMapping();
72600
+ var sortedBreakpoints = Object.keys(opts.mapping).sort(function(a, b) {
72601
+ return parseInt(RegionDefinitions.BREAKPOINTS[b], 10) - parseInt(RegionDefinitions.BREAKPOINTS[a], 10);
72602
+ });
72603
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
72604
+ try {
72605
+ for(var _iterator = sortedBreakpoints[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
72606
+ var bp = _step.value;
72607
+ mrecmapping = mrecmapping.addSize([
72608
+ RegionDefinitions.BREAKPOINTS[bp],
72609
+ 0
72610
+ ], opts.mapping[bp]);
72611
+ }
72612
+ } catch (err) {
72613
+ _didIteratorError = true;
72614
+ _iteratorError = err;
72615
+ } finally{
72616
+ try {
72617
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
72618
+ _iterator.return();
72619
+ }
72620
+ } finally{
72621
+ if (_didIteratorError) {
72622
+ throw _iteratorError;
72623
+ }
72624
+ }
72625
+ }
72626
+ mrecmapping = mrecmapping.build();
72627
+ } else {
72628
+ window.googletag.sizeMapping().addSize([
72629
+ 1024,
72630
+ 0
72631
+ ], size).addSize([
72632
+ 728,
72633
+ 0
72634
+ ], size).addSize([
72635
+ 320,
72636
+ 0
72637
+ ], size).addSize([
72638
+ 0,
72639
+ 0
72640
+ ], []).build();
72641
+ }
72642
+ mrec1 === null || mrec1 === void 0 ? void 0 : mrec1.defineSizeMapping(mrecmapping);
72643
+ if (opts === null || opts === void 0 ? void 0 : opts.targeting) {
72644
+ mrec1.setConfig({
72645
+ targeting: opts === null || opts === void 0 ? void 0 : opts.targeting
72646
+ });
72647
+ }
72648
+ });
72649
+ }
72650
+ },
72301
72651
  {
72302
72652
  key: "queue",
72303
72653
  value: function queue(callback) {
@@ -72359,7 +72709,7 @@ var PrebidGAM = /*#__PURE__*/ function() {
72359
72709
  params: {}
72360
72710
  }
72361
72711
  ]
72362
- }).addConsent(context.consent);
72712
+ }).setSizeConfiguration(buildPrebidSizeConfig(RegionDefinitions.RULES)).addConsent(context.consent);
72363
72713
  (_window_pbjs = window.pbjs) === null || _window_pbjs === void 0 ? void 0 : _window_pbjs.setConfig(configBuilder.build());
72364
72714
  (_window_pbjs1 = window.pbjs) === null || _window_pbjs1 === void 0 ? void 0 : _window_pbjs1.enableAnalytics({
72365
72715
  provider: "smartyads"
@@ -72406,31 +72756,6 @@ var PrebidGAM = /*#__PURE__*/ function() {
72406
72756
  return gamNetworkId;
72407
72757
  }
72408
72758
  },
72409
- {
72410
- key: "defineSlots",
72411
- value: function defineSlots(options) {
72412
- var _window_pbjs_que, _window_pbjs;
72413
- var gamNetwork = _PrebidGAM.getProperGAMNetworkId(options);
72414
- options.units.forEach(function(unit) {
72415
- var _unit_mediaTypes_banner;
72416
- var sizes = ((_unit_mediaTypes_banner = unit.mediaTypes.banner) === null || _unit_mediaTypes_banner === void 0 ? void 0 : _unit_mediaTypes_banner.sizes) || [];
72417
- GPT.defineSlot("/".concat(gamNetwork, "/banner"), sizes, unit.code);
72418
- });
72419
- (_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() {
72420
- var _window_pbjs;
72421
- if ((_window_pbjs = window.pbjs) === null || _window_pbjs === void 0 ? void 0 : _window_pbjs.addAdUnits) {
72422
- window.pbjs.addAdUnits(options.units.filter(function(unit) {
72423
- var _window_pbjs;
72424
- return !((_window_pbjs = window.pbjs) === null || _window_pbjs === void 0 ? void 0 : _window_pbjs.adUnits.some(function(defUnit) {
72425
- return "".concat(unit.code) === "".concat(defUnit.code);
72426
- }));
72427
- }));
72428
- } else {
72429
- console.error("addAdUnits is not a function.");
72430
- }
72431
- });
72432
- }
72433
- },
72434
72759
  {
72435
72760
  key: "defineSlot",
72436
72761
  value: function defineSlot(options, slotId, containerId, adType) {
@@ -72441,12 +72766,14 @@ var PrebidGAM = /*#__PURE__*/ function() {
72441
72766
  return unit.code === "".concat(slotId);
72442
72767
  });
72443
72768
  var sizes = [];
72769
+ var mapping = void 0;
72444
72770
  if (!unitDefinition) {
72445
72771
  console.error("No unit definition found for slotId: ".concat(slotId));
72446
72772
  return;
72447
72773
  }
72448
72774
  if (adType) {
72449
72775
  sizes = RegionDefinitions.TYPE_AND_DIMENSIONS[adType];
72776
+ mapping = RegionDefinitions.mapping(adType);
72450
72777
  } else {
72451
72778
  var _unitDefinition_mediaTypes_banner;
72452
72779
  sizes = ((_unitDefinition_mediaTypes_banner = unitDefinition.mediaTypes.banner) === null || _unitDefinition_mediaTypes_banner === void 0 ? void 0 : _unitDefinition_mediaTypes_banner.sizes) || [];
@@ -72458,7 +72785,10 @@ var PrebidGAM = /*#__PURE__*/ function() {
72458
72785
  brndts_zid: unitDefinition.zoneId
72459
72786
  };
72460
72787
  }
72461
- GPT.defineSlot("/".concat(gamNetworkId, "/").concat(adName), sizes, "".concat(containerId), targeting);
72788
+ GPT.defineSlot("/".concat(gamNetworkId, "/").concat(adName), sizes, "".concat(containerId), {
72789
+ targeting: targeting,
72790
+ mapping: mapping
72791
+ });
72462
72792
  if (!((_window_pbjs = window.pbjs) === null || _window_pbjs === void 0 ? void 0 : _window_pbjs.adUnits.some(function(defUnit) {
72463
72793
  return "".concat(containerId) === "".concat(defUnit.code);
72464
72794
  }))) {
@@ -72466,15 +72796,51 @@ var PrebidGAM = /*#__PURE__*/ function() {
72466
72796
  (_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() {
72467
72797
  var _window_pbjs;
72468
72798
  if ((_window_pbjs = window.pbjs) === null || _window_pbjs === void 0 ? void 0 : _window_pbjs.addAdUnits) {
72799
+ var adUnit = _object_spread_props(_object_spread({}, unitDefinition), {
72800
+ mediaTypes: _object_spread_props(_object_spread({}, unitDefinition.mediaTypes || {}), {
72801
+ banner: _object_spread_props(_object_spread({}, unitDefinition.mediaTypes.banner || {}), {
72802
+ sizes: sizes
72803
+ })
72804
+ }),
72805
+ code: "".concat(containerId)
72806
+ });
72807
+ if (mapping) {
72808
+ var mappedSizes = [];
72809
+ var sortedBreakpoints = Object.keys(mapping).sort(function(a, b) {
72810
+ return parseInt(RegionDefinitions.BREAKPOINTS[b], 10) - parseInt(RegionDefinitions.BREAKPOINTS[a], 10);
72811
+ });
72812
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
72813
+ try {
72814
+ for(var _iterator = sortedBreakpoints[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
72815
+ var bp = _step.value;
72816
+ mappedSizes.push({
72817
+ minViewPort: [
72818
+ RegionDefinitions.BREAKPOINTS[bp],
72819
+ 0
72820
+ ],
72821
+ sizes: mapping[bp]
72822
+ });
72823
+ }
72824
+ } catch (err) {
72825
+ _didIteratorError = true;
72826
+ _iteratorError = err;
72827
+ } finally{
72828
+ try {
72829
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
72830
+ _iterator.return();
72831
+ }
72832
+ } finally{
72833
+ if (_didIteratorError) {
72834
+ throw _iteratorError;
72835
+ }
72836
+ }
72837
+ }
72838
+ adUnit.mediaTypes.banner.sizeConfig = mappedSizes;
72839
+ } else {
72840
+ adUnit.mediaTypes.banner.sizes = sizes;
72841
+ }
72469
72842
  window.pbjs.addAdUnits([
72470
- _object_spread_props(_object_spread({}, unitDefinition), {
72471
- mediaTypes: _object_spread_props(_object_spread({}, unitDefinition.mediaTypes || {}), {
72472
- banner: _object_spread_props(_object_spread({}, unitDefinition.mediaTypes.banner || {}), {
72473
- sizes: sizes
72474
- })
72475
- }),
72476
- code: "".concat(containerId)
72477
- })
72843
+ adUnit
72478
72844
  ]);
72479
72845
  } else {
72480
72846
  console.error("addAdUnits is not a function.");