@brndts/brndts-ads 1.10.0 → 1.10.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
@@ -67634,6 +67634,7 @@ var Config = /*#__PURE__*/ function() {
67634
67634
  function Config(providedConfigs) {
67635
67635
  _class_call_check(this, Config);
67636
67636
  var _providedConfigs_auth;
67637
+ this.strategies = [];
67637
67638
  if (!((_providedConfigs_auth = providedConfigs.auth) === null || _providedConfigs_auth === void 0 ? void 0 : _providedConfigs_auth.host)) {
67638
67639
  throw new InternalError("No authority configuration provided!");
67639
67640
  }
@@ -67673,12 +67674,85 @@ var Config = /*#__PURE__*/ function() {
67673
67674
  {
67674
67675
  key: "fetch",
67675
67676
  value: function fetch1() {
67676
- var _this = this;
67677
- return fetch("".concat(this.configs.auth.host, "/authority/tenant/bap/").concat(this.configs.key, "/configs")).then(function(response) {
67678
- return response.json();
67679
- }).then(function(data) {
67680
- _this.remote = data;
67681
- _this.merge();
67677
+ return _async_to_generator(function() {
67678
+ var _this;
67679
+ return _ts_generator(this, function(_state) {
67680
+ switch(_state.label){
67681
+ case 0:
67682
+ _this = this;
67683
+ return [
67684
+ 4,
67685
+ fetch("".concat(this.configs.auth.host, "/authority/tenant/bap/").concat(this.configs.key, "/configs")).then(function(response) {
67686
+ return response.json();
67687
+ }).then(function(data) {
67688
+ _this.remote = data;
67689
+ _this.merge();
67690
+ }).then(function() {
67691
+ return fetch("".concat(_this.configs.auth.host, "/authority/ad-strategies"), {
67692
+ headers: {
67693
+ "Content-Type": "application/json",
67694
+ "x-tenant": window.location.hostname
67695
+ }
67696
+ });
67697
+ }).then(function(response) {
67698
+ return response.json();
67699
+ }).then(function(data) {
67700
+ _this.strategies = data.map(function(strategy) {
67701
+ var settings = {};
67702
+ var settingsKeys = Object.keys(strategy.settings);
67703
+ for(var i = 0; i < settingsKeys.length; i++){
67704
+ var key = settingsKeys[i];
67705
+ var setting = strategy.settings[key];
67706
+ if (typeof setting === "number") {
67707
+ settings[key] = {
67708
+ value: setting,
67709
+ setting: {
67710
+ code: key,
67711
+ name: key,
67712
+ description: "",
67713
+ type: "number",
67714
+ constraints: {
67715
+ min: 0
67716
+ }
67717
+ }
67718
+ };
67719
+ } else {
67720
+ settings[key] = setting;
67721
+ }
67722
+ }
67723
+ return _object_spread_props(_object_spread({}, strategy), {
67724
+ settings: settings
67725
+ });
67726
+ });
67727
+ })
67728
+ ];
67729
+ case 1:
67730
+ _state.sent();
67731
+ return [
67732
+ 2
67733
+ ];
67734
+ }
67735
+ });
67736
+ }).call(this);
67737
+ }
67738
+ },
67739
+ {
67740
+ key: "getStrategyConfigs",
67741
+ value: function getStrategyConfigs(strategy) {
67742
+ var strategyConfig = this.strategies.find(function(s2) {
67743
+ return s2.code === strategy;
67744
+ });
67745
+ if (!strategyConfig) {
67746
+ return this.configs;
67747
+ }
67748
+ return _object_spread_props(_object_spread({}, this.configs), {
67749
+ ads: _object_spread_props(_object_spread({}, this.configs.ads), {
67750
+ presentation: _object_spread_props(_object_spread({}, this.configs.ads.presentation), {
67751
+ duration: strategyConfig.settings.visibility_duration.value,
67752
+ minDuration: strategyConfig.settings.minimum_display_time.value,
67753
+ cooldown: strategyConfig.settings.cooldown_time.value
67754
+ })
67755
+ })
67682
67756
  });
67683
67757
  }
67684
67758
  },
@@ -79971,7 +80045,7 @@ var VideoAd = /*#__PURE__*/ function() {
79971
80045
  ErrorHandler.handle(new InternalError("Setup failed: no video identifier"));
79972
80046
  return;
79973
80047
  }
79974
- var adsPresentation = this.videoAdContext.config.get("ads").presentation;
80048
+ var adsPresentation = this.videoAdContext.config.getStrategyConfigs(this.videoAdContext.config.get("ads").regions.strategy).ads.presentation;
79975
80049
  var videoRegions = new VideoRegionsDataManager({
79976
80050
  useLocalCache: this.videoAdContext.config.get("ads").useLocalCache,
79977
80051
  useRemoteCache: this.videoAdContext.config.get("ads").regions.useCache,
@@ -80089,7 +80163,7 @@ var VideoAd = /*#__PURE__*/ function() {
80089
80163
  source: _this.videoAdContext.media.source
80090
80164
  }
80091
80165
  });
80092
- var adsPresentation = _this.videoAdContext.config.get("ads").presentation;
80166
+ var adsPresentation = _this.videoAdContext.config.getStrategyConfigs(_this.videoAdContext.config.get("ads").regions.strategy).ads.presentation;
80093
80167
  _this.videoRegions = VideoRegionsDecoratorFactory.decorate(videoRegions, adsPresentation);
80094
80168
  _this.videoAdContext.data = _this.videoRegions;
80095
80169
  _this.videoAdContext.recorder = _this.recorderFactory.create(_this.videoAdContext.media, {