@brndts/brndts-ads 0.0.2 → 1.0.0
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/README.md +5 -1
- package/dist/index.css +8 -5
- package/dist/index.css.map +1 -1
- package/dist/index.js +69 -69
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -69
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
@@ -18670,7 +18670,6 @@ var ErrorHandler = /*#__PURE__*/ function() {
|
|
18670
18670
|
key: "handle",
|
18671
18671
|
value: function handle(error) {
|
18672
18672
|
Reporter_default.capture(error);
|
18673
|
-
console.error(error);
|
18674
18673
|
if (_instanceof(error, GenericError)) {
|
18675
18674
|
if (error.fatal) {
|
18676
18675
|
throw error;
|
@@ -18870,8 +18869,7 @@ var defaults = {
|
|
18870
18869
|
},
|
18871
18870
|
playback: {},
|
18872
18871
|
volume: {
|
18873
|
-
mute: false
|
18874
|
-
defaultVolume: 20
|
18872
|
+
mute: false
|
18875
18873
|
},
|
18876
18874
|
ads: {
|
18877
18875
|
enabled: true,
|
@@ -18882,7 +18880,7 @@ var defaults = {
|
|
18882
18880
|
},
|
18883
18881
|
regions: {
|
18884
18882
|
useCache: true,
|
18885
|
-
strategy: "
|
18883
|
+
strategy: "bannerv2"
|
18886
18884
|
},
|
18887
18885
|
provider: {
|
18888
18886
|
type: "brndts_placeholder",
|
@@ -18932,7 +18930,6 @@ var Config = /*#__PURE__*/ function() {
|
|
18932
18930
|
return fetch("".concat(this.configs.auth.host, "/authority/tenant/bap/").concat(this.configs.key, "/configs")).then(function(response) {
|
18933
18931
|
return response.json();
|
18934
18932
|
}).then(function(data) {
|
18935
|
-
console.log("Loaded remote configuration", data);
|
18936
18933
|
_this.remote = data;
|
18937
18934
|
_this.merge();
|
18938
18935
|
});
|
@@ -19942,6 +19939,11 @@ var RegionsContainerView = /*#__PURE__*/ function() {
|
|
19942
19939
|
} else {
|
19943
19940
|
this.contentLayer.style.top = "0px";
|
19944
19941
|
}
|
19942
|
+
if (width - newDimensions.width > 0) {
|
19943
|
+
this.contentLayer.style.left = "".concat((width - newDimensions.width) / 2, "px");
|
19944
|
+
} else {
|
19945
|
+
this.contentLayer.style.left = "0px";
|
19946
|
+
}
|
19945
19947
|
}
|
19946
19948
|
},
|
19947
19949
|
{
|
@@ -20481,7 +20483,6 @@ var KevelSDK = /*#__PURE__*/ function() {
|
|
20481
20483
|
};
|
20482
20484
|
}
|
20483
20485
|
}).catch(function(error) {
|
20484
|
-
console.error("There was a problem with the fetch operation:", error);
|
20485
20486
|
throw error;
|
20486
20487
|
});
|
20487
20488
|
}
|
@@ -20593,9 +20594,7 @@ var SmartyadsSDK = /*#__PURE__*/ function() {
|
|
20593
20594
|
key: "request",
|
20594
20595
|
value: function request(params) {
|
20595
20596
|
var url2 = "https://n1.smartyads.com/?c=b&".concat(this.buildQueryParams(params));
|
20596
|
-
console.log("requesting : ", url2);
|
20597
20597
|
return fetch("https://n1.smartyads.com/?c=b&".concat(this.buildQueryParams(params))).then(function(response) {
|
20598
|
-
console.log("response", response);
|
20599
20598
|
if (!response.ok) {
|
20600
20599
|
throw new InternalError("Network response was not ok");
|
20601
20600
|
}
|
@@ -20603,7 +20602,6 @@ var SmartyadsSDK = /*#__PURE__*/ function() {
|
|
20603
20602
|
}).then(function(data) {
|
20604
20603
|
return data;
|
20605
20604
|
}).catch(function(error) {
|
20606
|
-
console.error("There was a problem with the fetch operation:", error);
|
20607
20605
|
throw error;
|
20608
20606
|
});
|
20609
20607
|
}
|
@@ -20778,47 +20776,43 @@ var VideoRegionsDurationDecorator = /*#__PURE__*/ function(VideoRegionsDataManag
|
|
20778
20776
|
var last;
|
20779
20777
|
var result;
|
20780
20778
|
var workingTimestamp = timestamp;
|
20781
|
-
|
20782
|
-
|
20783
|
-
|
20784
|
-
|
20785
|
-
|
20779
|
+
while(totalDuration < this.params.duration){
|
20780
|
+
var regions = this.component.get(workingTimestamp);
|
20781
|
+
if (!regions || !regions.regions) {
|
20782
|
+
return null;
|
20783
|
+
}
|
20784
|
+
var validRegions = regions.regions.filter(function(reg, _, array) {
|
20785
|
+
if (!last) {
|
20786
|
+
last = array.map(function(r2) {
|
20787
|
+
return r2.id;
|
20788
|
+
});
|
20789
|
+
result = _to_consumable_array(array);
|
20786
20790
|
}
|
20787
|
-
|
20788
|
-
if (
|
20789
|
-
|
20790
|
-
return r2.id;
|
20791
|
-
});
|
20792
|
-
result = _to_consumable_array(array);
|
20791
|
+
if (reg.iou <= _this.iou) {
|
20792
|
+
if (last.includes(reg.id)) {
|
20793
|
+
return true;
|
20793
20794
|
}
|
20794
|
-
|
20795
|
-
if (last.includes(reg.id)) {
|
20796
|
-
return true;
|
20797
|
-
}
|
20798
|
-
return false;
|
20799
|
-
} else {
|
20800
|
-
if (last.includes(reg.id)) {
|
20801
|
-
var foundIndex = last.indexOf(reg.id);
|
20802
|
-
last.splice(foundIndex, 1);
|
20803
|
-
result === null || result === void 0 ? void 0 : result.splice(foundIndex, 1);
|
20804
|
-
}
|
20805
|
-
return false;
|
20806
|
-
}
|
20807
|
-
});
|
20808
|
-
if (validRegions.length <= 0) {
|
20809
|
-
return null;
|
20810
|
-
}
|
20811
|
-
var duration = 0;
|
20812
|
-
if (regions.timestamp_start < workingTimestamp) {
|
20813
|
-
duration = regions.timestamp_end - workingTimestamp;
|
20795
|
+
return false;
|
20814
20796
|
} else {
|
20815
|
-
|
20797
|
+
if (last.includes(reg.id)) {
|
20798
|
+
var foundIndex = last.indexOf(reg.id);
|
20799
|
+
last.splice(foundIndex, 1);
|
20800
|
+
result === null || result === void 0 ? void 0 : result.splice(foundIndex, 1);
|
20801
|
+
}
|
20802
|
+
return false;
|
20816
20803
|
}
|
20817
|
-
|
20818
|
-
|
20804
|
+
});
|
20805
|
+
if (validRegions.length <= 0) {
|
20806
|
+
return null;
|
20819
20807
|
}
|
20820
|
-
|
20821
|
-
|
20808
|
+
var duration = 0;
|
20809
|
+
if (regions.timestamp_start < workingTimestamp) {
|
20810
|
+
duration = regions.timestamp_end - workingTimestamp;
|
20811
|
+
} else {
|
20812
|
+
duration = regions.timestamp_end - regions.timestamp_start;
|
20813
|
+
}
|
20814
|
+
totalDuration += duration;
|
20815
|
+
workingTimestamp = regions.timestamp_end + 1e-3;
|
20822
20816
|
}
|
20823
20817
|
if (!result) {
|
20824
20818
|
return null;
|
@@ -20898,10 +20892,11 @@ var Ads = /*#__PURE__*/ function() {
|
|
20898
20892
|
this.context.store.subscribe(function(newState, oldState) {
|
20899
20893
|
if (oldState.status !== newState.status) {
|
20900
20894
|
if (newState.status === "playing") {
|
20901
|
-
console.log("ads state changed");
|
20902
20895
|
_this.adPresentationStrategy.start();
|
20903
20896
|
} else {
|
20897
|
+
var _this_regionsRenderer;
|
20904
20898
|
_this.adPresentationStrategy.stop();
|
20899
|
+
(_this_regionsRenderer = _this.regionsRenderer) === null || _this_regionsRenderer === void 0 ? void 0 : _this_regionsRenderer.clear();
|
20905
20900
|
}
|
20906
20901
|
}
|
20907
20902
|
if (oldState.ready !== newState.ready) {
|
@@ -20911,11 +20906,20 @@ var Ads = /*#__PURE__*/ function() {
|
|
20911
20906
|
}
|
20912
20907
|
});
|
20913
20908
|
this.adPresentationStrategy.on("presentation", function() {
|
20914
|
-
|
20915
|
-
|
20916
|
-
|
20917
|
-
|
20918
|
-
|
20909
|
+
try {
|
20910
|
+
var regions = _this.videoRegions.get(_this.context.media.currentTime);
|
20911
|
+
if (regions === null || regions === void 0 ? void 0 : regions.regions) {
|
20912
|
+
var _this_regionsRenderer;
|
20913
|
+
_this.adPresentationStrategy.startedPresentation();
|
20914
|
+
(_this_regionsRenderer = _this.regionsRenderer) === null || _this_regionsRenderer === void 0 ? void 0 : _this_regionsRenderer.render(regions.regions);
|
20915
|
+
}
|
20916
|
+
} catch (e2) {
|
20917
|
+
if (_instanceof(e2, Error)) {
|
20918
|
+
var error = new InternalError(e2.message);
|
20919
|
+
error.stack = e2.stack;
|
20920
|
+
_this.context.logger.error(e2);
|
20921
|
+
ErrorHandler.handle(error);
|
20922
|
+
}
|
20919
20923
|
}
|
20920
20924
|
}).on("cooldown", function() {
|
20921
20925
|
var _this_regionsRenderer;
|
@@ -20924,7 +20928,6 @@ var Ads = /*#__PURE__*/ function() {
|
|
20924
20928
|
});
|
20925
20929
|
(_this_context_media = this.context.media) === null || _this_context_media === void 0 ? void 0 : _this_context_media.on("SEEKED", function() {
|
20926
20930
|
_this.videoRegions.seek(_this.context.media.currentTime);
|
20927
|
-
_this.adPresentationStrategy.start();
|
20928
20931
|
});
|
20929
20932
|
this.handleState();
|
20930
20933
|
}
|
@@ -24216,10 +24219,9 @@ var Interface = /*#__PURE__*/ function(_import_events3_default) {
|
|
24216
24219
|
}
|
24217
24220
|
_this.media = _this.context.media;
|
24218
24221
|
_this.container = document.createElement("div");
|
24219
|
-
_this.container.id = "
|
24222
|
+
_this.container.id = "BRNDTS";
|
24220
24223
|
_this.setDebug(_this.context.config.get("debug"));
|
24221
24224
|
_this.wrapMedia();
|
24222
|
-
_this.migrateStyles();
|
24223
24225
|
_this.setupControls();
|
24224
24226
|
return _this;
|
24225
24227
|
}
|
@@ -24228,7 +24230,7 @@ var Interface = /*#__PURE__*/ function(_import_events3_default) {
|
|
24228
24230
|
key: "wrapMedia",
|
24229
24231
|
value: function wrapMedia() {
|
24230
24232
|
var _this_media_view_parentElement, _this_media_view;
|
24231
|
-
if (((_this_media_view = this.media.view) === null || _this_media_view === void 0 ? void 0 : (_this_media_view_parentElement = _this_media_view.parentElement) === null || _this_media_view_parentElement === void 0 ? void 0 : _this_media_view_parentElement.id) === "
|
24233
|
+
if (((_this_media_view = this.media.view) === null || _this_media_view === void 0 ? void 0 : (_this_media_view_parentElement = _this_media_view.parentElement) === null || _this_media_view_parentElement === void 0 ? void 0 : _this_media_view_parentElement.id) === "BRNDTS") {
|
24232
24234
|
this.context.elements.container = this.media.view.parentElement;
|
24233
24235
|
}
|
24234
24236
|
if (!is_default.element(this.context.elements.container)) {
|
@@ -24237,9 +24239,11 @@ var Interface = /*#__PURE__*/ function(_import_events3_default) {
|
|
24237
24239
|
} else if (this.context.elements.container) {
|
24238
24240
|
this.container = this.context.elements.container;
|
24239
24241
|
}
|
24240
|
-
this.
|
24241
|
-
this.container.style.height = "".concat(this.media.viewHeight, "px");
|
24242
|
+
this.migrateStyles();
|
24242
24243
|
if (this.media.view) {
|
24244
|
+
this.media.view.style.position = "absolute";
|
24245
|
+
this.media.view.style.top = "0";
|
24246
|
+
this.media.view.style.left = "0";
|
24243
24247
|
this.media.view.style.width = "100%";
|
24244
24248
|
this.media.view.style.height = "100%";
|
24245
24249
|
}
|
@@ -24252,7 +24256,7 @@ var Interface = /*#__PURE__*/ function(_import_events3_default) {
|
|
24252
24256
|
var _this_media_view;
|
24253
24257
|
Object.values(_object_spread({}, ((_this_media_view = this.media.view) === null || _this_media_view === void 0 ? void 0 : _this_media_view.style) || {})).filter(//@ts-expect-error
|
24254
24258
|
function(key) {
|
24255
|
-
return !is_default.empty(key) && is_default.string(key)
|
24259
|
+
return !is_default.empty(key) && is_default.string(key);
|
24256
24260
|
}).forEach(function(key) {
|
24257
24261
|
_this.container.style.setProperty(//@ts-expect-error
|
24258
24262
|
key, //@ts-expect-error
|
@@ -28926,9 +28930,9 @@ var YoutubeMediaElement = /*#__PURE__*/ function(GenericMediaElement1) {
|
|
28926
28930
|
key: "setMediaElement",
|
28927
28931
|
value: function setMediaElement() {
|
28928
28932
|
var _this = this;
|
28929
|
-
|
28933
|
+
this.context.logger.log("Checking YT API");
|
28930
28934
|
if (is_default.object(window.YT) && is_default.function(window.YT.Player)) {
|
28931
|
-
|
28935
|
+
this.context.logger.log("YT API is already loaded");
|
28932
28936
|
this.YTAPIReady();
|
28933
28937
|
} else {
|
28934
28938
|
var callback = window.onYouTubeIframeAPIReady;
|
@@ -28936,12 +28940,12 @@ var YoutubeMediaElement = /*#__PURE__*/ function(GenericMediaElement1) {
|
|
28936
28940
|
if (callback && is_default.function(callback)) {
|
28937
28941
|
callback();
|
28938
28942
|
}
|
28939
|
-
|
28943
|
+
_this.context.logger.log("YT API is loaded");
|
28940
28944
|
_this.YTAPIReady();
|
28941
28945
|
};
|
28942
|
-
|
28946
|
+
this.context.logger.log("YT API is not loaded");
|
28943
28947
|
loadScript("https://www.youtube.com/iframe_api").catch(function(error) {
|
28944
|
-
|
28948
|
+
_this.context.logger.warn("YouTube API failed to load", error);
|
28945
28949
|
});
|
28946
28950
|
}
|
28947
28951
|
}
|
@@ -29000,7 +29004,7 @@ var YoutubeMediaElement = /*#__PURE__*/ function(GenericMediaElement1) {
|
|
29000
29004
|
value: function handleYTPlayerReady(event) {
|
29001
29005
|
var _this = this;
|
29002
29006
|
if (this.instance) {
|
29003
|
-
|
29007
|
+
this.context.logger.warn("Instance already found!");
|
29004
29008
|
return;
|
29005
29009
|
}
|
29006
29010
|
this.instance = event.target;
|
@@ -29025,7 +29029,6 @@ var YoutubeMediaElement = /*#__PURE__*/ function(GenericMediaElement1) {
|
|
29025
29029
|
key: "handlePlayerStateChange",
|
29026
29030
|
value: function handlePlayerStateChange(newState) {
|
29027
29031
|
var _this_media;
|
29028
|
-
console.log("player state changed", newState);
|
29029
29032
|
var seeked = ((_this_media = this.media) === null || _this_media === void 0 ? void 0 : _this_media.seeking) && [
|
29030
29033
|
1,
|
29031
29034
|
2
|
@@ -29090,7 +29093,6 @@ var YoutubeMediaElement = /*#__PURE__*/ function(GenericMediaElement1) {
|
|
29090
29093
|
id: id
|
29091
29094
|
});
|
29092
29095
|
media = elements_default.replaceElement(container, media);
|
29093
|
-
console.log("Setting media for video with id : ", media, videoId);
|
29094
29096
|
var ytPlayer = new window.YT.Player(media, {
|
29095
29097
|
videoId: videoId || void 0,
|
29096
29098
|
host: getHost(config2),
|
@@ -29323,7 +29325,6 @@ var YoutubeMediaElement = /*#__PURE__*/ function(GenericMediaElement1) {
|
|
29323
29325
|
width: width,
|
29324
29326
|
height: height
|
29325
29327
|
};
|
29326
|
-
console.log("adjusted dimensions!", adjustedDimensions);
|
29327
29328
|
if (preserveAspectRatio) {
|
29328
29329
|
adjustedDimensions = this.adjustSizeWithAspectRatio(width, height, this.aspectRatio);
|
29329
29330
|
}
|
@@ -29389,7 +29390,6 @@ var NativeMediaElement = /*#__PURE__*/ function(GenericMediaElement1) {
|
|
29389
29390
|
}
|
29390
29391
|
}
|
29391
29392
|
if (this.media && this.media.readyState >= HTMLMediaElement.HAVE_METADATA) {
|
29392
|
-
console.log("Metadata is already loaded.");
|
29393
29393
|
this.mediaIsReady();
|
29394
29394
|
}
|
29395
29395
|
}
|
@@ -29839,7 +29839,7 @@ var BrndtsAds = /*#__PURE__*/ function() {
|
|
29839
29839
|
ErrorHandler.handle(error);
|
29840
29840
|
});
|
29841
29841
|
this.context.media.on("READY", function() {
|
29842
|
-
|
29842
|
+
_this.context.logger.log("Media is Ready!");
|
29843
29843
|
_this.mediaIsReady();
|
29844
29844
|
});
|
29845
29845
|
if (this.context.media.isReady) {
|