@brndts/brndts-ads 1.0.1 → 1.1.1
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 +544 -169
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +546 -170
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -1
package/dist/index.js
CHANGED
@@ -18598,14 +18598,13 @@ var Reporter = /*#__PURE__*/ function() {
|
|
18598
18598
|
replaysOnErrorSampleRate: 1
|
18599
18599
|
});
|
18600
18600
|
this.scope = new Scope();
|
18601
|
-
this.scope.setClient(this.client);
|
18602
18601
|
this.client.init();
|
18603
18602
|
}
|
18604
18603
|
_create_class(Reporter, [
|
18605
18604
|
{
|
18606
18605
|
key: "capture",
|
18607
18606
|
value: function capture(error) {
|
18608
|
-
return this.
|
18607
|
+
return this.client.captureException(error, {}, this.scope);
|
18609
18608
|
}
|
18610
18609
|
}
|
18611
18610
|
]);
|
@@ -18713,6 +18712,35 @@ function _getGeneralInfo() {
|
|
18713
18712
|
});
|
18714
18713
|
return _getGeneralInfo.apply(this, arguments);
|
18715
18714
|
}
|
18715
|
+
// src/Common/utils/Changeable.ts
|
18716
|
+
var Changeable = /*#__PURE__*/ function() {
|
18717
|
+
function Changeable(value2) {
|
18718
|
+
_class_call_check(this, Changeable);
|
18719
|
+
this.listeners = [];
|
18720
|
+
this._value = value2;
|
18721
|
+
}
|
18722
|
+
_create_class(Changeable, [
|
18723
|
+
{
|
18724
|
+
key: "value",
|
18725
|
+
get: function get() {
|
18726
|
+
return this._value;
|
18727
|
+
},
|
18728
|
+
set: function set(value2) {
|
18729
|
+
this._value = value2;
|
18730
|
+
for(var index = 0; index < this.listeners.length; index++){
|
18731
|
+
this.listeners[index](this._value);
|
18732
|
+
}
|
18733
|
+
}
|
18734
|
+
},
|
18735
|
+
{
|
18736
|
+
key: "onUpdate",
|
18737
|
+
value: function onUpdate(listener3) {
|
18738
|
+
this.listeners.push(listener3);
|
18739
|
+
}
|
18740
|
+
}
|
18741
|
+
]);
|
18742
|
+
return Changeable;
|
18743
|
+
}();
|
18716
18744
|
// src/Common/utils/is.ts
|
18717
18745
|
var getConstructor = function(input) {
|
18718
18746
|
return input !== null && typeof input !== "undefined" ? input.constructor : null;
|
@@ -18845,7 +18873,7 @@ var defaults = {
|
|
18845
18873
|
host: "http://localhost:8001"
|
18846
18874
|
},
|
18847
18875
|
controls: {
|
18848
|
-
default: "
|
18876
|
+
default: "brndts_fs"
|
18849
18877
|
},
|
18850
18878
|
playback: {},
|
18851
18879
|
volume: {
|
@@ -18855,8 +18883,8 @@ var defaults = {
|
|
18855
18883
|
enabled: true,
|
18856
18884
|
useLocalCache: false,
|
18857
18885
|
presentation: {
|
18858
|
-
duration:
|
18859
|
-
cooldown:
|
18886
|
+
duration: 2,
|
18887
|
+
cooldown: 10
|
18860
18888
|
},
|
18861
18889
|
regions: {
|
18862
18890
|
useCache: true,
|
@@ -19062,7 +19090,7 @@ var Logger = /*#__PURE__*/ function() {
|
|
19062
19090
|
{
|
19063
19091
|
key: "error",
|
19064
19092
|
get: function get() {
|
19065
|
-
return
|
19093
|
+
return Function.prototype.bind.call(console.error, console);
|
19066
19094
|
}
|
19067
19095
|
}
|
19068
19096
|
]);
|
@@ -19101,7 +19129,7 @@ var VideoRegionsDataCollection = /*#__PURE__*/ function() {
|
|
19101
19129
|
var nextFrameInfo;
|
19102
19130
|
var missingIntervals = {};
|
19103
19131
|
if (this.timestampList.length === 0) {
|
19104
|
-
missingIntervals[0] = {
|
19132
|
+
missingIntervals["0"] = {
|
19105
19133
|
timestamp_start: 0,
|
19106
19134
|
timestamp_end: this.totalLengthSeconds
|
19107
19135
|
};
|
@@ -19172,9 +19200,6 @@ var VideoRegionsDataCollection = /*#__PURE__*/ function() {
|
|
19172
19200
|
{
|
19173
19201
|
key: "isValidRegionForTimestamp",
|
19174
19202
|
value: function isValidRegionForTimestamp(region, timestamp) {
|
19175
|
-
if (!region) {
|
19176
|
-
return false;
|
19177
|
-
}
|
19178
19203
|
if (region.timestamp_start < timestamp && region.timestamp_end > timestamp) {
|
19179
19204
|
return true;
|
19180
19205
|
}
|
@@ -19213,14 +19238,6 @@ var VideoRegionsDataCollection = /*#__PURE__*/ function() {
|
|
19213
19238
|
right = mid - 1;
|
19214
19239
|
}
|
19215
19240
|
}
|
19216
|
-
leftInterval = this.frameInfo[this.timestampList[left]];
|
19217
|
-
rightInterval = this.frameInfo[this.timestampList[right]];
|
19218
|
-
if (this.isValidRegionForTimestamp(leftInterval, target)) {
|
19219
|
-
return leftInterval;
|
19220
|
-
}
|
19221
|
-
if (this.isValidRegionForTimestamp(rightInterval, target)) {
|
19222
|
-
return rightInterval;
|
19223
|
-
}
|
19224
19241
|
return null;
|
19225
19242
|
}
|
19226
19243
|
},
|
@@ -19364,7 +19381,11 @@ var VideoRegionsDataManager = /*#__PURE__*/ function() {
|
|
19364
19381
|
},
|
19365
19382
|
{
|
19366
19383
|
key: "destroy",
|
19367
|
-
value: function destroy() {
|
19384
|
+
value: function destroy() {
|
19385
|
+
this.service.removeListener("result", this.handlePredictionResult);
|
19386
|
+
this.service.removeListener("completed", this.handlePredictionConpleted);
|
19387
|
+
this.service.removeListener("aborted", this.handlePredictionAborted);
|
19388
|
+
}
|
19368
19389
|
}
|
19369
19390
|
]);
|
19370
19391
|
return VideoRegionsDataManager;
|
@@ -19549,6 +19570,7 @@ var RegionBox = /*#__PURE__*/ function() {
|
|
19549
19570
|
}();
|
19550
19571
|
var Region = /*#__PURE__*/ function() {
|
19551
19572
|
function Region(id, regionDescriptor, planeDescriptor, deps) {
|
19573
|
+
var _this = this;
|
19552
19574
|
_class_call_check(this, Region);
|
19553
19575
|
this.visible = false;
|
19554
19576
|
this.id = id;
|
@@ -19574,6 +19596,16 @@ var Region = /*#__PURE__*/ function() {
|
|
19574
19596
|
this.container.addEventListener("click", this.handleClick);
|
19575
19597
|
this.container.addEventListener("mouseenter", this.handleMouseEnter);
|
19576
19598
|
this.container.addEventListener("mouseleave", this.handleMouseLeave);
|
19599
|
+
if (this.deps.provider) {
|
19600
|
+
this.deps.provider.onRefreshContents(function(contents) {
|
19601
|
+
var _this_deps_recorder;
|
19602
|
+
_this.boxView.innerHTML = "";
|
19603
|
+
for(var index = 0; index < contents.length; index++){
|
19604
|
+
_this.boxView.appendChild(contents[index]);
|
19605
|
+
}
|
19606
|
+
(_this_deps_recorder = _this.deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.presentationStateChanged(_this);
|
19607
|
+
});
|
19608
|
+
}
|
19577
19609
|
this.render(regionDescriptor.contours, regionDescriptor.box);
|
19578
19610
|
if (this.boxArea > 0) {
|
19579
19611
|
this.requestContent();
|
@@ -19583,19 +19615,7 @@ var Region = /*#__PURE__*/ function() {
|
|
19583
19615
|
{
|
19584
19616
|
key: "requestContent",
|
19585
19617
|
value: function requestContent() {
|
19586
|
-
|
19587
|
-
var _this_deps;
|
19588
|
-
if ((_this_deps = this.deps) === null || _this_deps === void 0 ? void 0 : _this_deps.provider) {
|
19589
|
-
this.deps.provider.onRefreshContents(function(contents) {
|
19590
|
-
_this.boxView.innerHTML = "";
|
19591
|
-
for(var index = 0; index < contents.length; index++){
|
19592
|
-
_this.boxView.appendChild(contents[index]);
|
19593
|
-
}
|
19594
|
-
});
|
19595
|
-
var content = this.deps.provider.contents();
|
19596
|
-
for(var index = 0; index < content.length; index++){
|
19597
|
-
this.boxView.appendChild(content[index]);
|
19598
|
-
}
|
19618
|
+
if (this.deps.provider) {
|
19599
19619
|
this.deps.provider.request({
|
19600
19620
|
size: {
|
19601
19621
|
width: this.boxWidth,
|
@@ -19611,22 +19631,22 @@ var Region = /*#__PURE__*/ function() {
|
|
19611
19631
|
{
|
19612
19632
|
key: "handleClick",
|
19613
19633
|
value: function handleClick() {
|
19614
|
-
var _this_deps_recorder
|
19615
|
-
this.isPresented && ((
|
19634
|
+
var _this_deps_recorder;
|
19635
|
+
this.isPresented && ((_this_deps_recorder = this.deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.mouseClick(this));
|
19616
19636
|
}
|
19617
19637
|
},
|
19618
19638
|
{
|
19619
19639
|
key: "handleMouseEnter",
|
19620
19640
|
value: function handleMouseEnter() {
|
19621
|
-
var _this_deps_recorder
|
19622
|
-
this.isPresented && ((
|
19641
|
+
var _this_deps_recorder;
|
19642
|
+
this.isPresented && ((_this_deps_recorder = this.deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.mouseEnter(this));
|
19623
19643
|
}
|
19624
19644
|
},
|
19625
19645
|
{
|
19626
19646
|
key: "handleMouseLeave",
|
19627
19647
|
value: function handleMouseLeave() {
|
19628
|
-
var _this_deps_recorder
|
19629
|
-
this.isPresented && ((
|
19648
|
+
var _this_deps_recorder;
|
19649
|
+
this.isPresented && ((_this_deps_recorder = this.deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.mouseLeave(this));
|
19630
19650
|
}
|
19631
19651
|
},
|
19632
19652
|
{
|
@@ -19726,20 +19746,26 @@ var Region = /*#__PURE__*/ function() {
|
|
19726
19746
|
return this.visible;
|
19727
19747
|
}
|
19728
19748
|
},
|
19749
|
+
{
|
19750
|
+
key: "hasContent",
|
19751
|
+
get: function get() {
|
19752
|
+
return this.boxView.children.length > 0;
|
19753
|
+
}
|
19754
|
+
},
|
19729
19755
|
{
|
19730
19756
|
key: "updateVisibility",
|
19731
19757
|
value: function updateVisibility(value2) {
|
19732
|
-
var _this_deps_recorder
|
19758
|
+
var _this_deps_recorder;
|
19733
19759
|
this.visible = value2;
|
19734
|
-
(
|
19760
|
+
(_this_deps_recorder = this.deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.displayStateChanged(this);
|
19735
19761
|
}
|
19736
19762
|
},
|
19737
19763
|
{
|
19738
19764
|
key: "render",
|
19739
19765
|
value: function render(contours, box) {
|
19740
19766
|
var _this = this;
|
19741
|
-
var _this_deps_recorder
|
19742
|
-
this.contours = contours
|
19767
|
+
var _this_deps_recorder;
|
19768
|
+
this.contours = contours;
|
19743
19769
|
var newBox = new RegionBox(box);
|
19744
19770
|
if (!this.box.isEqual(newBox.coords) && newBox.area(this.plane.size) > 0) {
|
19745
19771
|
this.box = newBox;
|
@@ -19753,7 +19779,6 @@ var Region = /*#__PURE__*/ function() {
|
|
19753
19779
|
this.boxView.style.width = "".concat(Math.floor(this.boxWidth), "px");
|
19754
19780
|
this.boxView.style.height = "".concat(Math.floor(this.boxHeight), "px");
|
19755
19781
|
if (this.maskLayer) {
|
19756
|
-
var _this_maskLayer;
|
19757
19782
|
this.maskLayer.width = this.boxWidth;
|
19758
19783
|
this.maskLayer.style.width = "".concat(this.boxWidth, "px");
|
19759
19784
|
this.maskLayer.height = this.boxHeight;
|
@@ -19781,12 +19806,12 @@ var Region = /*#__PURE__*/ function() {
|
|
19781
19806
|
ctx.fillStyle = "black";
|
19782
19807
|
ctx.fill();
|
19783
19808
|
}
|
19784
|
-
var maskUrl = "url(" +
|
19809
|
+
var maskUrl = "url(" + this.maskLayer.toDataURL() + ")";
|
19785
19810
|
if (this.boxView) {
|
19786
19811
|
this.boxView.style.maskImage = maskUrl;
|
19787
19812
|
}
|
19788
19813
|
}
|
19789
|
-
(
|
19814
|
+
(_this_deps_recorder = this.deps.recorder) === null || _this_deps_recorder === void 0 ? void 0 : _this_deps_recorder.presentationStateChanged(this);
|
19790
19815
|
}
|
19791
19816
|
},
|
19792
19817
|
{
|
@@ -20330,7 +20355,7 @@ var ContentProvider = /*#__PURE__*/ function() {
|
|
20330
20355
|
]);
|
20331
20356
|
return ContentProvider;
|
20332
20357
|
}();
|
20333
|
-
// src/Ads/Providers/AdsTerraProvider.ts
|
20358
|
+
// src/Ads/Providers/AdsTerra/AdsTerraProvider.ts
|
20334
20359
|
var ADSTERRA_BANNER_KEY = "f5024dbe632a4ccafec26462f39acaf8";
|
20335
20360
|
var AdsTerraProvider = /*#__PURE__*/ function(ContentProvider) {
|
20336
20361
|
_inherits(AdsTerraProvider, ContentProvider);
|
@@ -20349,7 +20374,7 @@ var AdsTerraProvider = /*#__PURE__*/ function(ContentProvider) {
|
|
20349
20374
|
var conf = document.createElement("script");
|
20350
20375
|
var script = document.createElement("script");
|
20351
20376
|
script.type = "text/javascript";
|
20352
|
-
script.src = "
|
20377
|
+
script.src = "http://www.highperformancedformats.com/".concat(atOptions.key, "/invoke.js");
|
20353
20378
|
conf.innerHTML = "atOptions = ".concat(JSON.stringify(atOptions));
|
20354
20379
|
_this.content.push(conf);
|
20355
20380
|
_this.content.push(script);
|
@@ -20416,7 +20441,7 @@ var BRNDTSDefaultProvider = /*#__PURE__*/ function(ContentProvider) {
|
|
20416
20441
|
]);
|
20417
20442
|
return BRNDTSDefaultProvider;
|
20418
20443
|
}(ContentProvider);
|
20419
|
-
// src/Ads/Providers/
|
20444
|
+
// src/Ads/Providers/Kevel/KevelSDK.ts
|
20420
20445
|
var KevelSDK = /*#__PURE__*/ function() {
|
20421
20446
|
function KevelSDK(networkId, siteId) {
|
20422
20447
|
_class_call_check(this, KevelSDK);
|
@@ -20469,6 +20494,7 @@ var KevelSDK = /*#__PURE__*/ function() {
|
|
20469
20494
|
]);
|
20470
20495
|
return KevelSDK;
|
20471
20496
|
}();
|
20497
|
+
// src/Ads/Providers/Kevel/KevelProvider.ts
|
20472
20498
|
var KevelProvider = /*#__PURE__*/ function(ContentProvider) {
|
20473
20499
|
_inherits(KevelProvider, ContentProvider);
|
20474
20500
|
var _super = _create_super(KevelProvider);
|
@@ -20537,51 +20563,151 @@ var KevelProvider = /*#__PURE__*/ function(ContentProvider) {
|
|
20537
20563
|
return KevelProvider;
|
20538
20564
|
}(ContentProvider);
|
20539
20565
|
// src/Ads/Providers/SmartyAds/SmartyAdsSDK.ts
|
20566
|
+
var import_core12 = require("@iabtcf/core");
|
20567
|
+
import_core12.GVL.baseUrl = "https://vendor-list.consensu.org/v3/";
|
20568
|
+
var PARAMS = [
|
20569
|
+
"res",
|
20570
|
+
"m",
|
20571
|
+
"ua",
|
20572
|
+
"ip",
|
20573
|
+
"w",
|
20574
|
+
"h",
|
20575
|
+
"gdpr",
|
20576
|
+
"gdpr_consent",
|
20577
|
+
"gpp",
|
20578
|
+
"gpp_sid",
|
20579
|
+
"coppa",
|
20580
|
+
"page",
|
20581
|
+
"domain",
|
20582
|
+
"secure",
|
20583
|
+
"lmt",
|
20584
|
+
"dnt",
|
20585
|
+
"ad_width",
|
20586
|
+
"ad_height",
|
20587
|
+
"language",
|
20588
|
+
"cattax",
|
20589
|
+
"keywords",
|
20590
|
+
"placementId"
|
20591
|
+
];
|
20540
20592
|
var SmartyadsSDK = /*#__PURE__*/ function() {
|
20541
20593
|
function SmartyadsSDK() {
|
20542
20594
|
_class_call_check(this, SmartyadsSDK);
|
20543
20595
|
}
|
20544
20596
|
_create_class(SmartyadsSDK, [
|
20545
20597
|
{
|
20546
|
-
|
20598
|
+
key: "generateTCString",
|
20599
|
+
value: function generateTCString() {
|
20600
|
+
var _this = this;
|
20601
|
+
return _async_to_generator(function() {
|
20602
|
+
var tcModel;
|
20603
|
+
return _ts_generator(this, function(_state) {
|
20604
|
+
switch(_state.label){
|
20605
|
+
case 0:
|
20606
|
+
if (!!_this.gdprConsent) return [
|
20607
|
+
3,
|
20608
|
+
2
|
20609
|
+
];
|
20610
|
+
tcModel = new import_core12.TCModel(new import_core12.GVL());
|
20611
|
+
tcModel.vendorConsents.set(534);
|
20612
|
+
return [
|
20613
|
+
4,
|
20614
|
+
tcModel.gvl.readyPromise
|
20615
|
+
];
|
20616
|
+
case 1:
|
20617
|
+
_state.sent();
|
20618
|
+
_this.gdprConsent = import_core12.TCString.encode(tcModel);
|
20619
|
+
console.log(_this.gdprConsent);
|
20620
|
+
_state.label = 2;
|
20621
|
+
case 2:
|
20622
|
+
return [
|
20623
|
+
2,
|
20624
|
+
_this.gdprConsent
|
20625
|
+
];
|
20626
|
+
}
|
20627
|
+
});
|
20628
|
+
})();
|
20629
|
+
}
|
20630
|
+
},
|
20631
|
+
{
|
20632
|
+
key: "buildQueryParams",
|
20633
|
+
value: /**
|
20547
20634
|
* Converts an object into a URL query string.
|
20548
20635
|
*
|
20549
20636
|
* @param params - The object to be converted into query parameters.
|
20550
20637
|
* @returns The query string with URL encoding.
|
20551
|
-
*/
|
20552
|
-
|
20553
|
-
|
20554
|
-
|
20555
|
-
|
20556
|
-
|
20557
|
-
|
20558
|
-
|
20559
|
-
|
20560
|
-
|
20561
|
-
|
20562
|
-
|
20563
|
-
|
20564
|
-
|
20565
|
-
|
20566
|
-
|
20567
|
-
|
20568
|
-
|
20638
|
+
*/ function buildQueryParams(params) {
|
20639
|
+
var _this = this;
|
20640
|
+
return _async_to_generator(function() {
|
20641
|
+
var queryString;
|
20642
|
+
return _ts_generator(this, function(_state) {
|
20643
|
+
switch(_state.label){
|
20644
|
+
case 0:
|
20645
|
+
if (!(params.gdpr === void 0)) return [
|
20646
|
+
3,
|
20647
|
+
2
|
20648
|
+
];
|
20649
|
+
params.gdpr = 1;
|
20650
|
+
return [
|
20651
|
+
4,
|
20652
|
+
_this.generateTCString()
|
20653
|
+
];
|
20654
|
+
case 1:
|
20655
|
+
params.gdpr_consent = _state.sent();
|
20656
|
+
_state.label = 2;
|
20657
|
+
case 2:
|
20658
|
+
queryString = PARAMS.map(function(key) {
|
20659
|
+
var value2 = params[key];
|
20660
|
+
if (value2 === null || value2 === void 0) {
|
20661
|
+
return "";
|
20662
|
+
}
|
20663
|
+
return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value2));
|
20664
|
+
}).filter(function(part) {
|
20665
|
+
return part.length > 0;
|
20666
|
+
}).join("&");
|
20667
|
+
return [
|
20668
|
+
2,
|
20669
|
+
queryString
|
20670
|
+
];
|
20671
|
+
}
|
20672
|
+
});
|
20673
|
+
})();
|
20569
20674
|
}
|
20570
20675
|
},
|
20571
20676
|
{
|
20572
20677
|
key: "request",
|
20573
20678
|
value: function request(params) {
|
20574
|
-
var
|
20575
|
-
return
|
20576
|
-
|
20577
|
-
|
20578
|
-
|
20579
|
-
|
20580
|
-
|
20581
|
-
|
20582
|
-
|
20583
|
-
|
20584
|
-
|
20679
|
+
var _this = this;
|
20680
|
+
return _async_to_generator(function() {
|
20681
|
+
var _, _1;
|
20682
|
+
return _ts_generator(this, function(_state) {
|
20683
|
+
switch(_state.label){
|
20684
|
+
case 0:
|
20685
|
+
_1 = (_ = "https://n1.smartyads.com/?c=b&").concat;
|
20686
|
+
return [
|
20687
|
+
4,
|
20688
|
+
_this.buildQueryParams(params)
|
20689
|
+
];
|
20690
|
+
case 1:
|
20691
|
+
return [
|
20692
|
+
2,
|
20693
|
+
fetch.apply(void 0, [
|
20694
|
+
_1.apply(_, [
|
20695
|
+
_state.sent()
|
20696
|
+
])
|
20697
|
+
]).then(function(response) {
|
20698
|
+
if (!response.ok) {
|
20699
|
+
throw new InternalError("Network response was not ok");
|
20700
|
+
}
|
20701
|
+
return response.json();
|
20702
|
+
}).then(function(data) {
|
20703
|
+
return data;
|
20704
|
+
}).catch(function(error) {
|
20705
|
+
throw error;
|
20706
|
+
})
|
20707
|
+
];
|
20708
|
+
}
|
20709
|
+
});
|
20710
|
+
})();
|
20585
20711
|
}
|
20586
20712
|
}
|
20587
20713
|
]);
|
@@ -20595,7 +20721,7 @@ var SmartyadsProvider = /*#__PURE__*/ function(ContentProvider) {
|
|
20595
20721
|
_class_call_check(this, SmartyadsProvider);
|
20596
20722
|
var _this;
|
20597
20723
|
_this = _super.call(this, context, options);
|
20598
|
-
_this.placements = options.placements;
|
20724
|
+
_this.placements = options.placements || {};
|
20599
20725
|
_this.smartyads = new SmartyadsSDK();
|
20600
20726
|
return _this;
|
20601
20727
|
}
|
@@ -20604,13 +20730,21 @@ var SmartyadsProvider = /*#__PURE__*/ function(ContentProvider) {
|
|
20604
20730
|
key: "getPlacement",
|
20605
20731
|
value: function getPlacement(regionId) {
|
20606
20732
|
var availablePlacements = Object.keys(this.placements).map(parseInt);
|
20607
|
-
if (!availablePlacements) {
|
20733
|
+
if (!availablePlacements.length) {
|
20608
20734
|
throw new Error("No available placements!");
|
20609
20735
|
}
|
20736
|
+
var foundPlacement;
|
20610
20737
|
if (!regionId) {
|
20611
|
-
|
20738
|
+
foundPlacement = this.placements[availablePlacements[0]];
|
20739
|
+
} else {
|
20740
|
+
foundPlacement = this.placements[regionId];
|
20612
20741
|
}
|
20613
|
-
|
20742
|
+
if (typeof foundPlacement === "number") {
|
20743
|
+
return {
|
20744
|
+
id: foundPlacement
|
20745
|
+
};
|
20746
|
+
}
|
20747
|
+
return foundPlacement;
|
20614
20748
|
}
|
20615
20749
|
},
|
20616
20750
|
{
|
@@ -20618,18 +20752,19 @@ var SmartyadsProvider = /*#__PURE__*/ function(ContentProvider) {
|
|
20618
20752
|
value: function request(params) {
|
20619
20753
|
var _this = this;
|
20620
20754
|
return _async_to_generator(function() {
|
20621
|
-
var _params_params, smartyadsContent, div, index;
|
20755
|
+
var _params_params, placementInfo, smartyadsContent, div, index;
|
20622
20756
|
return _ts_generator(this, function(_state) {
|
20623
20757
|
switch(_state.label){
|
20624
20758
|
case 0:
|
20625
20759
|
if (!params || params.size.width === void 0 || params.size.width === 0 || params.size.height === void 0 || params.size.height === 0) {
|
20626
20760
|
throw new InternalError("No Params!");
|
20627
20761
|
}
|
20762
|
+
placementInfo = _this.getPlacement((_params_params = params.params) === null || _params_params === void 0 ? void 0 : _params_params.regionId);
|
20628
20763
|
return [
|
20629
20764
|
4,
|
20630
20765
|
_this.smartyads.request(_object_spread_props(_object_spread({}, _this.options), {
|
20631
|
-
ad_width: params.size.width,
|
20632
|
-
ad_height: params.size.height,
|
20766
|
+
ad_width: placementInfo.w || params.size.width,
|
20767
|
+
ad_height: placementInfo.h || params.size.height,
|
20633
20768
|
m: "api",
|
20634
20769
|
ua: _this.context.info.ua || navigator.userAgent,
|
20635
20770
|
w: window.innerWidth,
|
@@ -20637,7 +20772,7 @@ var SmartyadsProvider = /*#__PURE__*/ function(ContentProvider) {
|
|
20637
20772
|
domain: _this.context.info.domain || window.location.hostname,
|
20638
20773
|
page: window.location.href,
|
20639
20774
|
ip: _this.context.info.ip,
|
20640
|
-
placementId:
|
20775
|
+
placementId: placementInfo.id
|
20641
20776
|
}))
|
20642
20777
|
];
|
20643
20778
|
case 1:
|
@@ -20699,6 +20834,146 @@ var StaticImageProvider = /*#__PURE__*/ function(ContentProvider) {
|
|
20699
20834
|
]);
|
20700
20835
|
return StaticImageProvider;
|
20701
20836
|
}(ContentProvider);
|
20837
|
+
// src/Ads/Providers/Prebidjs/PrebidjsProvider.ts
|
20838
|
+
var PrebidjsProvider = /*#__PURE__*/ function(ContentProvider) {
|
20839
|
+
_inherits(PrebidjsProvider, ContentProvider);
|
20840
|
+
var _super = _create_super(PrebidjsProvider);
|
20841
|
+
function PrebidjsProvider(context, options) {
|
20842
|
+
_class_call_check(this, PrebidjsProvider);
|
20843
|
+
var _this;
|
20844
|
+
_this = _super.call(this, context, options);
|
20845
|
+
_this.ready = false;
|
20846
|
+
_this.processBids = _this.processBids.bind(_assert_this_initialized(_this));
|
20847
|
+
_this.loadPrebidJS().then(function() {
|
20848
|
+
_this.configurePrebidJS();
|
20849
|
+
_this.defineAdUnits();
|
20850
|
+
});
|
20851
|
+
return _this;
|
20852
|
+
}
|
20853
|
+
_create_class(PrebidjsProvider, [
|
20854
|
+
{
|
20855
|
+
key: "loadPrebidJS",
|
20856
|
+
value: function loadPrebidJS() {
|
20857
|
+
var _this = this;
|
20858
|
+
return new Promise(function(resolve, reject) {
|
20859
|
+
if (window.pbjs) {
|
20860
|
+
_this.ready = true;
|
20861
|
+
_this.prebidjs = window.pbjs;
|
20862
|
+
_this.context.logger.log("Prebid.js already loaded!");
|
20863
|
+
resolve();
|
20864
|
+
return;
|
20865
|
+
}
|
20866
|
+
var script = document.createElement("script");
|
20867
|
+
script.src = "https://cdn.jsdelivr.net/npm/prebid.js@latest/dist/not-for-prod/prebid.js";
|
20868
|
+
script.onload = function() {
|
20869
|
+
_this.ready = true;
|
20870
|
+
_this.prebidjs = window.pbjs;
|
20871
|
+
_this.context.logger.log("Prebid.js loaded!");
|
20872
|
+
resolve();
|
20873
|
+
};
|
20874
|
+
script.onerror = function() {
|
20875
|
+
reject(new Error("Failed to load Prebid.js"));
|
20876
|
+
};
|
20877
|
+
document.head.appendChild(script);
|
20878
|
+
});
|
20879
|
+
}
|
20880
|
+
},
|
20881
|
+
{
|
20882
|
+
key: "configurePrebidJS",
|
20883
|
+
value: function configurePrebidJS() {
|
20884
|
+
var _this = this;
|
20885
|
+
if (!this.prebidjs) {
|
20886
|
+
return;
|
20887
|
+
}
|
20888
|
+
this.prebidjs.que.push(function() {
|
20889
|
+
if (_this.prebidjs) {
|
20890
|
+
_this.prebidjs.setConfig({
|
20891
|
+
debug: true,
|
20892
|
+
priceGranularity: "high",
|
20893
|
+
enableSendAllBids: true
|
20894
|
+
});
|
20895
|
+
}
|
20896
|
+
});
|
20897
|
+
}
|
20898
|
+
},
|
20899
|
+
{
|
20900
|
+
key: "defineAdUnits",
|
20901
|
+
value: function defineAdUnits() {
|
20902
|
+
var _this = this;
|
20903
|
+
if (!this.ready) {
|
20904
|
+
throw new Error("Prebid.js is not loaded");
|
20905
|
+
}
|
20906
|
+
if (!this.prebidjs) {
|
20907
|
+
return;
|
20908
|
+
}
|
20909
|
+
this.prebidjs.que.push(function() {
|
20910
|
+
if (_this.prebidjs) {
|
20911
|
+
_this.prebidjs.addAdUnits(_this.options.units);
|
20912
|
+
}
|
20913
|
+
});
|
20914
|
+
}
|
20915
|
+
},
|
20916
|
+
{
|
20917
|
+
key: "processBid",
|
20918
|
+
value: function processBid(bid) {
|
20919
|
+
var _iframe_sandbox, _iframe_contentWindow;
|
20920
|
+
var iframe = document.createElement("iframe");
|
20921
|
+
iframe.name = "prebid_ads_iframe_".concat(bid.adUnitCode);
|
20922
|
+
iframe.title = "3rd party ad content";
|
20923
|
+
(_iframe_sandbox = iframe.sandbox) === null || _iframe_sandbox === void 0 ? void 0 : _iframe_sandbox.add("allow-forms", "allow-popups", "allow-popups-to-escape-sandbox", "allow-same-origin", "allow-scripts", "allow-top-navigation-by-user-activation");
|
20924
|
+
iframe.setAttribute("aria-label", "Advertisment");
|
20925
|
+
iframe.style.setProperty("border", "0");
|
20926
|
+
iframe.style.setProperty("margin", "0");
|
20927
|
+
iframe.style.setProperty("overflow", "hidden");
|
20928
|
+
var iframeDoc = (_iframe_contentWindow = iframe.contentWindow) === null || _iframe_contentWindow === void 0 ? void 0 : _iframe_contentWindow.document;
|
20929
|
+
if (!iframeDoc) {
|
20930
|
+
return;
|
20931
|
+
}
|
20932
|
+
if (this.prebidjs) {
|
20933
|
+
this.prebidjs.renderAd(iframeDoc, bid.adId);
|
20934
|
+
}
|
20935
|
+
var normalizeCss = "/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */button,hr,input{overflow:visible}progress,sub,sup{vertical-align:baseline}[type=checkbox],[type=radio],legend{box-sizing:border-box;padding:0}html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}details,main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:ButtonText dotted 1px}fieldset{padding:.35em .75em .625em}legend{color:inherit;display:table;max-width:100%;white-space:normal}textarea{overflow:auto}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}[hidden],template{display:none}";
|
20936
|
+
var iframeStyle = iframeDoc.createElement("style");
|
20937
|
+
iframeStyle.appendChild(iframeDoc.createTextNode(normalizeCss));
|
20938
|
+
iframeDoc.head.appendChild(iframeStyle);
|
20939
|
+
this.content = [
|
20940
|
+
iframe
|
20941
|
+
];
|
20942
|
+
this.notify();
|
20943
|
+
}
|
20944
|
+
},
|
20945
|
+
{
|
20946
|
+
key: "processBids",
|
20947
|
+
value: function processBids(bids, timedOut, auctionId) {
|
20948
|
+
var _this_prebidjs;
|
20949
|
+
this.context.logger.log("Bids:", bids);
|
20950
|
+
var winners = ((_this_prebidjs = this.prebidjs) === null || _this_prebidjs === void 0 ? void 0 : _this_prebidjs.getHighestCpmBids()) || [];
|
20951
|
+
for(var i2 = 0; i2 < winners.length; i2++){
|
20952
|
+
this.processBid(winners[i2]);
|
20953
|
+
}
|
20954
|
+
}
|
20955
|
+
},
|
20956
|
+
{
|
20957
|
+
key: "request",
|
20958
|
+
value: function request(params) {
|
20959
|
+
var _this = this;
|
20960
|
+
if (!this.prebidjs) {
|
20961
|
+
return Promise.resolve();
|
20962
|
+
}
|
20963
|
+
this.prebidjs.que.push(function() {
|
20964
|
+
if (_this.prebidjs) {
|
20965
|
+
_this.prebidjs.requestBids({
|
20966
|
+
timeout: 1e3,
|
20967
|
+
bidsBackHandler: _this.processBids
|
20968
|
+
});
|
20969
|
+
}
|
20970
|
+
});
|
20971
|
+
return Promise.resolve();
|
20972
|
+
}
|
20973
|
+
}
|
20974
|
+
]);
|
20975
|
+
return PrebidjsProvider;
|
20976
|
+
}(ContentProvider);
|
20702
20977
|
// src/Ads/Providers/ProviderFactory.ts
|
20703
20978
|
var ContentProviderFactory = /*#__PURE__*/ function() {
|
20704
20979
|
function ContentProviderFactory() {
|
@@ -20723,8 +20998,11 @@ var ContentProviderFactory = /*#__PURE__*/ function() {
|
|
20723
20998
|
if (options.params.code === "smartyads") {
|
20724
20999
|
return new SmartyadsProvider(context, options.params);
|
20725
21000
|
}
|
21001
|
+
if (options.params.code === "prebid") {
|
21002
|
+
return new PrebidjsProvider(context, options.params);
|
21003
|
+
}
|
20726
21004
|
}
|
20727
|
-
throw new InternalError("No provider found for type");
|
21005
|
+
throw new InternalError("No provider found for type: ".concat(options.type));
|
20728
21006
|
}
|
20729
21007
|
}
|
20730
21008
|
]);
|
@@ -20831,16 +21109,29 @@ var Ads = /*#__PURE__*/ function() {
|
|
20831
21109
|
key: "mediaIsReady",
|
20832
21110
|
value: function mediaIsReady() {
|
20833
21111
|
this.videoRegions.fetch();
|
21112
|
+
console.log("media is ready");
|
20834
21113
|
if (this.regionsRenderer) {
|
20835
21114
|
return;
|
20836
21115
|
}
|
20837
|
-
|
20838
|
-
|
20839
|
-
|
20840
|
-
|
20841
|
-
|
21116
|
+
console.log("creating regions renderer");
|
21117
|
+
try {
|
21118
|
+
this.regionsRenderer = new RegionRenderer(this.context.media.viewWidth, this.context.media.viewHeight, {
|
21119
|
+
debug: this.context.config.get("debug"),
|
21120
|
+
recorder: this.context.recorder,
|
21121
|
+
provider: ContentProviderFactory.getProvider(this.context, this.context.config.get("ads").provider)
|
21122
|
+
});
|
21123
|
+
} catch (e2) {
|
21124
|
+
if (_instanceof(e2, Error)) {
|
21125
|
+
var error = new InternalError(e2.message);
|
21126
|
+
error.stack = e2.stack;
|
21127
|
+
this.context.logger.error(e2);
|
21128
|
+
ErrorHandler.handle(error);
|
21129
|
+
}
|
21130
|
+
}
|
21131
|
+
console.log("attaching regions renderer", this.context.elements.container);
|
20842
21132
|
if (this.context.elements.container) {
|
20843
|
-
|
21133
|
+
var _this_regionsRenderer;
|
21134
|
+
(_this_regionsRenderer = this.regionsRenderer) === null || _this_regionsRenderer === void 0 ? void 0 : _this_regionsRenderer.attach(this.context.elements.container);
|
20844
21135
|
}
|
20845
21136
|
}
|
20846
21137
|
},
|
@@ -20848,6 +21139,7 @@ var Ads = /*#__PURE__*/ function() {
|
|
20848
21139
|
key: "handleState",
|
20849
21140
|
value: function handleState() {
|
20850
21141
|
var state = this.context.store.getState();
|
21142
|
+
console.log("state", state);
|
20851
21143
|
if (state.ready) {
|
20852
21144
|
this.mediaIsReady();
|
20853
21145
|
}
|
@@ -20903,6 +21195,7 @@ var Ads = /*#__PURE__*/ function() {
|
|
20903
21195
|
(_this_context_media = this.context.media) === null || _this_context_media === void 0 ? void 0 : _this_context_media.on("SEEKED", function() {
|
20904
21196
|
_this.videoRegions.seek(_this.context.media.currentTime);
|
20905
21197
|
});
|
21198
|
+
console.log("ads started");
|
20906
21199
|
this.handleState();
|
20907
21200
|
}
|
20908
21201
|
},
|
@@ -24425,6 +24718,7 @@ var ImpressionModel = /*#__PURE__*/ function() {
|
|
24425
24718
|
_class_call_check(this, ImpressionModel);
|
24426
24719
|
this.service = service;
|
24427
24720
|
this.currentImpression = {
|
24721
|
+
datetime: /* @__PURE__ */ new Date().toISOString(),
|
24428
24722
|
type: "impression",
|
24429
24723
|
session: sessionInfo,
|
24430
24724
|
video: video,
|
@@ -24439,11 +24733,10 @@ var ImpressionModel = /*#__PURE__*/ function() {
|
|
24439
24733
|
value: function insertNewHit(newHit) {
|
24440
24734
|
var _this = this;
|
24441
24735
|
return _async_to_generator(function() {
|
24442
|
-
var
|
24736
|
+
var result;
|
24443
24737
|
return _ts_generator(this, function(_state) {
|
24444
24738
|
if (_this.currentImpression.type === "impression") {
|
24445
|
-
;
|
24446
|
-
(_this_currentImpression_extra = _this.currentImpression.extra) === null || _this_currentImpression_extra === void 0 ? void 0 : _this_currentImpression_extra.hits.push(newHit);
|
24739
|
+
_this.currentImpression.extra.hits.push(newHit);
|
24447
24740
|
if (!_this.currentImpression.id) {
|
24448
24741
|
if (_this.currentImpression.video) {
|
24449
24742
|
_this.currentImpression.video.ts = newHit.start;
|
@@ -24465,41 +24758,59 @@ var ImpressionModel = /*#__PURE__*/ function() {
|
|
24465
24758
|
})();
|
24466
24759
|
}
|
24467
24760
|
},
|
24761
|
+
{
|
24762
|
+
key: "startNewImpressionHit",
|
24763
|
+
value: function startNewImpressionHit(region, ts) {
|
24764
|
+
this.inProgressHit = {
|
24765
|
+
ts_start: ts,
|
24766
|
+
dt_start: /* @__PURE__ */ new Date(),
|
24767
|
+
totalDisplayingTime: 0,
|
24768
|
+
area: region.polygonArea
|
24769
|
+
};
|
24770
|
+
if (region.isVisible) {
|
24771
|
+
this.inProgressHit.displayingStart = this.inProgressHit.dt_start;
|
24772
|
+
}
|
24773
|
+
}
|
24774
|
+
},
|
24775
|
+
{
|
24776
|
+
key: "finishInProgressHit",
|
24777
|
+
value: function finishInProgressHit(ts) {
|
24778
|
+
if (!this.inProgressHit) {
|
24779
|
+
return;
|
24780
|
+
}
|
24781
|
+
this.inProgressHit.ts_end = ts;
|
24782
|
+
this.inProgressHit.dt_end = /* @__PURE__ */ new Date();
|
24783
|
+
if (this.inProgressHit.displayingStart !== void 0) {
|
24784
|
+
this.inProgressHit.displayingEnd = /* @__PURE__ */ new Date();
|
24785
|
+
this.inProgressHit.totalDisplayingTime += (this.inProgressHit.displayingEnd.getTime() - this.inProgressHit.displayingStart.getTime()) / 1e3;
|
24786
|
+
this.inProgressHit.displayingStart = void 0;
|
24787
|
+
this.inProgressHit.displayingEnd = void 0;
|
24788
|
+
}
|
24789
|
+
var inProgress = this.inProgressHit;
|
24790
|
+
var presentationTime = // @ts-expect-error
|
24791
|
+
(inProgress.dt_end.getTime() - inProgress.dt_start.getTime()) / 1e3;
|
24792
|
+
this.inProgressHit = void 0;
|
24793
|
+
this.insertNewHit({
|
24794
|
+
presentation_time: presentationTime,
|
24795
|
+
display_time: inProgress.totalDisplayingTime,
|
24796
|
+
start: inProgress.ts_start,
|
24797
|
+
// @ts-expect-error
|
24798
|
+
end: inProgress.ts_end,
|
24799
|
+
area: inProgress.area || 0
|
24800
|
+
});
|
24801
|
+
}
|
24802
|
+
},
|
24468
24803
|
{
|
24469
24804
|
key: "presentationChanged",
|
24470
24805
|
value: function presentationChanged(region, ts) {
|
24471
|
-
if (
|
24472
|
-
|
24473
|
-
|
24474
|
-
this.inProgressHit = {
|
24475
|
-
ts_start: ts,
|
24476
|
-
dt_start: /* @__PURE__ */ new Date(),
|
24477
|
-
totalDisplayingTime: 0,
|
24478
|
-
area: region.polygonArea
|
24479
|
-
};
|
24480
|
-
if (region.isVisible) {
|
24481
|
-
this.inProgressHit.displayingStart = this.inProgressHit.dt_start;
|
24806
|
+
if (!this.inProgressHit) {
|
24807
|
+
if (region.isPresented && region.hasContent) {
|
24808
|
+
this.startNewImpressionHit(region, ts);
|
24482
24809
|
}
|
24483
|
-
} else
|
24484
|
-
|
24485
|
-
|
24486
|
-
this.inProgressHit.dt_end = /* @__PURE__ */ new Date();
|
24487
|
-
if (this.inProgressHit.displayingStart !== void 0) {
|
24488
|
-
this.inProgressHit.displayingEnd = /* @__PURE__ */ new Date();
|
24489
|
-
this.inProgressHit.totalDisplayingTime += (this.inProgressHit.displayingEnd.getTime() - this.inProgressHit.displayingStart.getTime()) / 1e3;
|
24490
|
-
this.inProgressHit.displayingStart = void 0;
|
24491
|
-
this.inProgressHit.displayingEnd = void 0;
|
24810
|
+
} else {
|
24811
|
+
if (!region.isPresented || !region.hasContent) {
|
24812
|
+
this.finishInProgressHit(ts);
|
24492
24813
|
}
|
24493
|
-
var inProgress = this.inProgressHit;
|
24494
|
-
var presentationTime = ((((_inProgress_dt_end = inProgress.dt_end) === null || _inProgress_dt_end === void 0 ? void 0 : _inProgress_dt_end.getTime()) || 0) - inProgress.dt_start.getTime()) / 1e3;
|
24495
|
-
this.inProgressHit = void 0;
|
24496
|
-
this.insertNewHit({
|
24497
|
-
presentation_time: presentationTime,
|
24498
|
-
display_time: inProgress.totalDisplayingTime,
|
24499
|
-
start: inProgress.ts_start,
|
24500
|
-
end: inProgress.ts_end || inProgress.ts_start,
|
24501
|
-
area: inProgress.area || 0
|
24502
|
-
});
|
24503
24814
|
}
|
24504
24815
|
}
|
24505
24816
|
},
|
@@ -24525,7 +24836,6 @@ var ImpressionModel = /*#__PURE__*/ function() {
|
|
24525
24836
|
key: "destroy",
|
24526
24837
|
value: function destroy() {
|
24527
24838
|
if (this.inProgressHit) {
|
24528
|
-
var _inProgress_dt_end;
|
24529
24839
|
this.inProgressHit.dt_end = /* @__PURE__ */ new Date();
|
24530
24840
|
if (this.inProgressHit.displayingStart !== void 0) {
|
24531
24841
|
this.inProgressHit.displayingEnd = /* @__PURE__ */ new Date();
|
@@ -24534,7 +24844,8 @@ var ImpressionModel = /*#__PURE__*/ function() {
|
|
24534
24844
|
this.inProgressHit.displayingEnd = void 0;
|
24535
24845
|
}
|
24536
24846
|
var inProgress = this.inProgressHit;
|
24537
|
-
var presentationTime =
|
24847
|
+
var presentationTime = // @ts-expect-error
|
24848
|
+
(inProgress.dt_end.getTime() - inProgress.dt_start.getTime()) / 1e3;
|
24538
24849
|
this.inProgressHit = void 0;
|
24539
24850
|
this.insertNewHit({
|
24540
24851
|
presentation_time: presentationTime,
|
@@ -28563,34 +28874,6 @@ Object.assign(lookup2, {
|
|
28563
28874
|
connect: lookup2
|
28564
28875
|
});
|
28565
28876
|
// src/BRNDTSService.ts
|
28566
|
-
var Changeable = /*#__PURE__*/ function() {
|
28567
|
-
function Changeable(value2) {
|
28568
|
-
_class_call_check(this, Changeable);
|
28569
|
-
this.listeners = [];
|
28570
|
-
this._value = value2;
|
28571
|
-
}
|
28572
|
-
_create_class(Changeable, [
|
28573
|
-
{
|
28574
|
-
key: "value",
|
28575
|
-
get: function get() {
|
28576
|
-
return this._value;
|
28577
|
-
},
|
28578
|
-
set: function set(value2) {
|
28579
|
-
this._value = value2;
|
28580
|
-
for(var index = 0; index < this.listeners.length; index++){
|
28581
|
-
this.listeners[index](this._value);
|
28582
|
-
}
|
28583
|
-
}
|
28584
|
-
},
|
28585
|
-
{
|
28586
|
-
key: "onUpdate",
|
28587
|
-
value: function onUpdate(listener3) {
|
28588
|
-
this.listeners.push(listener3);
|
28589
|
-
}
|
28590
|
-
}
|
28591
|
-
]);
|
28592
|
-
return Changeable;
|
28593
|
-
}();
|
28594
28877
|
var BRNDTSService = /*#__PURE__*/ function(_import_events4_default) {
|
28595
28878
|
_inherits(BRNDTSService, _import_events4_default);
|
28596
28879
|
var _super = _create_super(BRNDTSService);
|
@@ -28657,8 +28940,7 @@ var BRNDTSService = /*#__PURE__*/ function(_import_events4_default) {
|
|
28657
28940
|
payload[_key - 1] = arguments[_key];
|
28658
28941
|
}
|
28659
28942
|
var _this_socket;
|
28660
|
-
|
28661
|
-
return (_this_socket1 = this.socket) === null || _this_socket1 === void 0 ? void 0 : (_this_socket = _this_socket1).emit.apply(_this_socket, [
|
28943
|
+
return (_this_socket = this.socket).emit.apply(_this_socket, [
|
28662
28944
|
event
|
28663
28945
|
].concat(_to_consumable_array(payload)));
|
28664
28946
|
}
|
@@ -28666,16 +28948,14 @@ var BRNDTSService = /*#__PURE__*/ function(_import_events4_default) {
|
|
28666
28948
|
{
|
28667
28949
|
key: "handle",
|
28668
28950
|
value: function handle(event, handler) {
|
28669
|
-
|
28670
|
-
return (_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.on(event, handler);
|
28951
|
+
return this.socket.on(event, handler);
|
28671
28952
|
}
|
28672
28953
|
},
|
28673
28954
|
{
|
28674
28955
|
key: "destroy",
|
28675
28956
|
value: function destroy() {
|
28676
|
-
|
28677
|
-
|
28678
|
-
(_this_socket1 = this.socket) === null || _this_socket1 === void 0 ? void 0 : _this_socket1.close();
|
28957
|
+
this.socket.emit("stop");
|
28958
|
+
this.socket.close();
|
28679
28959
|
}
|
28680
28960
|
}
|
28681
28961
|
]);
|
@@ -29045,6 +29325,7 @@ var YoutubeMediaElement = /*#__PURE__*/ function(GenericMediaElement1) {
|
|
29045
29325
|
var container = elements_default.createElement("div", {
|
29046
29326
|
id: id
|
29047
29327
|
});
|
29328
|
+
this.context.elements.original = media;
|
29048
29329
|
media = elements_default.replaceElement(container, media);
|
29049
29330
|
var ytPlayer = new window.YT.Player(media, {
|
29050
29331
|
videoId: videoId || void 0,
|
@@ -29208,13 +29489,13 @@ var YoutubeMediaElement = /*#__PURE__*/ function(GenericMediaElement1) {
|
|
29208
29489
|
{
|
29209
29490
|
key: "disableNativeControls",
|
29210
29491
|
value: function disableNativeControls() {
|
29211
|
-
|
29492
|
+
this.context.logger.log("Disabling native controls");
|
29212
29493
|
}
|
29213
29494
|
},
|
29214
29495
|
{
|
29215
29496
|
key: "enableNativeControls",
|
29216
29497
|
value: function enableNativeControls() {
|
29217
|
-
|
29498
|
+
this.context.logger.log("Enabling native controls");
|
29218
29499
|
}
|
29219
29500
|
},
|
29220
29501
|
{
|
@@ -29294,6 +29575,85 @@ var YoutubeMediaElement = /*#__PURE__*/ function(GenericMediaElement1) {
|
|
29294
29575
|
]);
|
29295
29576
|
return YoutubeMediaElement;
|
29296
29577
|
}(GenericMediaElement);
|
29578
|
+
// src/Common/utils/videoColor.ts
|
29579
|
+
function getAverageRGB(imgEl, block) {
|
29580
|
+
var blockSize = block;
|
29581
|
+
var defaultRGB = {
|
29582
|
+
r: 0,
|
29583
|
+
g: 0,
|
29584
|
+
b: 0
|
29585
|
+
};
|
29586
|
+
var canvas = document.createElement("canvas");
|
29587
|
+
var context = canvas.getContext && canvas.getContext("2d");
|
29588
|
+
var data;
|
29589
|
+
var width;
|
29590
|
+
var height;
|
29591
|
+
var i2 = -4;
|
29592
|
+
var length2;
|
29593
|
+
var rgb = {
|
29594
|
+
r: 0,
|
29595
|
+
g: 0,
|
29596
|
+
b: 0
|
29597
|
+
};
|
29598
|
+
var count = 0;
|
29599
|
+
if (!block) {
|
29600
|
+
blockSize = 5;
|
29601
|
+
}
|
29602
|
+
if (!context) {
|
29603
|
+
return defaultRGB;
|
29604
|
+
}
|
29605
|
+
height = canvas.height = imgEl.offsetHeight || imgEl.height;
|
29606
|
+
width = canvas.width = imgEl.offsetWidth || imgEl.width;
|
29607
|
+
context.drawImage(imgEl, 0, 0);
|
29608
|
+
try {
|
29609
|
+
data = context.getImageData(0, 0, width, height);
|
29610
|
+
} catch (e2) {
|
29611
|
+
return defaultRGB;
|
29612
|
+
}
|
29613
|
+
length2 = data.data.length;
|
29614
|
+
while((i2 += blockSize * 4) < length2){
|
29615
|
+
++count;
|
29616
|
+
rgb.r += data.data[i2];
|
29617
|
+
rgb.g += data.data[i2 + 1];
|
29618
|
+
rgb.b += data.data[i2 + 2];
|
29619
|
+
}
|
29620
|
+
rgb.r = ~~(rgb.r / count);
|
29621
|
+
rgb.g = ~~(rgb.g / count);
|
29622
|
+
rgb.b = ~~(rgb.b / count);
|
29623
|
+
return rgb;
|
29624
|
+
}
|
29625
|
+
function getVideoAverageColor(video) {
|
29626
|
+
var defaultRGB = {
|
29627
|
+
r: 0,
|
29628
|
+
g: 0,
|
29629
|
+
b: 0
|
29630
|
+
};
|
29631
|
+
var canvas = document.createElement("canvas");
|
29632
|
+
canvas.width = video.offsetWidth;
|
29633
|
+
canvas.height = video.offsetHeight;
|
29634
|
+
var context = canvas.getContext("2d");
|
29635
|
+
if (!context) {
|
29636
|
+
return defaultRGB;
|
29637
|
+
}
|
29638
|
+
context.drawImage(video, 0, 0, canvas.width, canvas.height);
|
29639
|
+
return getAverageRGB(canvas, 5);
|
29640
|
+
}
|
29641
|
+
function getVideoDominantColor(video) {
|
29642
|
+
var defaultRGB = {
|
29643
|
+
r: 0,
|
29644
|
+
g: 0,
|
29645
|
+
b: 0
|
29646
|
+
};
|
29647
|
+
var canvas = document.createElement("canvas");
|
29648
|
+
canvas.width = 1;
|
29649
|
+
canvas.height = 1;
|
29650
|
+
var context = canvas.getContext("2d");
|
29651
|
+
if (!context) {
|
29652
|
+
return defaultRGB;
|
29653
|
+
}
|
29654
|
+
context.drawImage(video, 0, 0, 1, 1);
|
29655
|
+
return getAverageRGB(canvas, 1);
|
29656
|
+
}
|
29297
29657
|
// src/Media/NativeMediaElement.ts
|
29298
29658
|
var DEFAULT_SEEK_INTERVAL2 = 10;
|
29299
29659
|
var EVENT_LIST_TO_HANDLE = [
|
@@ -29646,6 +30006,18 @@ var NativeMediaElement = /*#__PURE__*/ function(GenericMediaElement1) {
|
|
29646
30006
|
value: function resetSize() {
|
29647
30007
|
return this.setSize(this.context.dimensions.w, this.context.dimensions.h);
|
29648
30008
|
}
|
30009
|
+
},
|
30010
|
+
{
|
30011
|
+
key: "getAverageColor",
|
30012
|
+
value: function getAverageColor() {
|
30013
|
+
return getVideoAverageColor(this.media);
|
30014
|
+
}
|
30015
|
+
},
|
30016
|
+
{
|
30017
|
+
key: "getVideoDominantColor",
|
30018
|
+
value: function getVideoDominantColor1() {
|
30019
|
+
return getVideoDominantColor(this.media);
|
30020
|
+
}
|
29649
30021
|
}
|
29650
30022
|
]);
|
29651
30023
|
return NativeMediaElement;
|
@@ -29784,6 +30156,10 @@ var BrndtsAds = /*#__PURE__*/ function() {
|
|
29784
30156
|
}
|
29785
30157
|
};
|
29786
30158
|
try {
|
30159
|
+
if (!this.context.config.get("enabled")) {
|
30160
|
+
this.context.logger.error("Setup failed: disabled by config");
|
30161
|
+
return;
|
30162
|
+
}
|
29787
30163
|
this.context.media = MediaElementFactory.getMediaElement(this.context);
|
29788
30164
|
this.context.media.on("ERROR", function(error) {
|
29789
30165
|
ErrorHandler.handle(error);
|
@@ -29806,16 +30182,13 @@ var BrndtsAds = /*#__PURE__*/ function() {
|
|
29806
30182
|
key: "initialize",
|
29807
30183
|
value: function initialize() {
|
29808
30184
|
var _this = this;
|
30185
|
+
console.log("initialize");
|
29809
30186
|
try {
|
29810
30187
|
this.context.recorder = new InteractionLog(this.context);
|
29811
30188
|
this.context.media.on("RESIZED", function() {
|
29812
30189
|
var _this_context_ads;
|
29813
30190
|
(_this_context_ads = _this.context.ads) === null || _this_context_ads === void 0 ? void 0 : _this_context_ads.updateSize();
|
29814
30191
|
});
|
29815
|
-
if (!this.context.config.get("enabled")) {
|
29816
|
-
this.context.logger.error("Setup failed: disabled by config");
|
29817
|
-
return;
|
29818
|
-
}
|
29819
30192
|
this.context.interface = new Interface(this.context);
|
29820
30193
|
if (this.context.media.view.brndts) {
|
29821
30194
|
this.context.logger.error("Setup failed: target already setup");
|
@@ -29829,6 +30202,7 @@ var BrndtsAds = /*#__PURE__*/ function() {
|
|
29829
30202
|
if (this.context.config.get("debug")) {
|
29830
30203
|
window.brndts = this;
|
29831
30204
|
}
|
30205
|
+
console.log("start ads", this.context.config.get("ads"));
|
29832
30206
|
if (this.context.config.get("ads").enabled) {
|
29833
30207
|
this.context.ads = new Ads_default(this.context);
|
29834
30208
|
this.context.ads.start();
|
@@ -29865,6 +30239,7 @@ var BrndtsAds = /*#__PURE__*/ function() {
|
|
29865
30239
|
});
|
29866
30240
|
});
|
29867
30241
|
this.context.service.handle("info", function(data) {
|
30242
|
+
console.log("info", data);
|
29868
30243
|
if (!data.video) {
|
29869
30244
|
ErrorHandler.handle(new InternalError("Setup failed: no video identifier"));
|
29870
30245
|
return;
|