@brndts/brndts-ads 1.13.21 → 1.13.23
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 +270 -244
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +270 -244
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -70512,10 +70512,11 @@ var PrebidjsProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
70512
70512
|
key: "request",
|
70513
70513
|
value: function request(params) {
|
70514
70514
|
return _async_to_generator(function() {
|
70515
|
-
var adType, adName, regionId, regionInfo;
|
70515
|
+
var _this, adType, adName, regionId, regionInfo;
|
70516
70516
|
return _ts_generator(this, function(_state) {
|
70517
70517
|
switch(_state.label){
|
70518
70518
|
case 0:
|
70519
|
+
_this = this;
|
70519
70520
|
return [
|
70520
70521
|
4,
|
70521
70522
|
this.ready.promise
|
@@ -70554,6 +70555,10 @@ var PrebidjsProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
70554
70555
|
case 2:
|
70555
70556
|
_state.sent();
|
70556
70557
|
this.processBids(params, {});
|
70558
|
+
PrebidJS.defineSlot(this.options, regionId, params.params.regionId, adType);
|
70559
|
+
PrebidJS.request(regionId, params.params.regionId, function(bids) {
|
70560
|
+
return _this.processBids(params, bids);
|
70561
|
+
});
|
70557
70562
|
return [
|
70558
70563
|
2,
|
70559
70564
|
Promise.resolve()
|
@@ -75229,9 +75234,6 @@ function getProviderByUrl(url2) {
|
|
75229
75234
|
if (/^(https?:\/\/)?(www\.)?(youtube\.com|youtube-nocookie\.com|youtu\.?be)\/.+$/.test(url2)) {
|
75230
75235
|
return "YOUTUBE";
|
75231
75236
|
}
|
75232
|
-
if (/^https?:\/\/player.vimeo.com\/video\/\d{0,9}(?=\b|\/)/.test(url2)) {
|
75233
|
-
return "VIMEO";
|
75234
|
-
}
|
75235
75237
|
if (/^https:\/\/geo\.dailymotion\.com\/player(?:\/[a-zA-Z0-9]+)?\.html\?video=([a-zA-Z0-9]+)/.test(url2)) {
|
75236
75238
|
return "DAILYMOTION";
|
75237
75239
|
}
|
@@ -75277,7 +75279,7 @@ var MediaElementFactory = /*#__PURE__*/ function() {
|
|
75277
75279
|
if (hasSrc) {
|
75278
75280
|
var _hasSrc = _sliced_to_array(hasSrc, 2), el = _hasSrc[0], value2 = _hasSrc[1];
|
75279
75281
|
var provider2 = getProviderByUrl(value2);
|
75280
|
-
if (provider2
|
75282
|
+
if (provider2) {
|
75281
75283
|
return el;
|
75282
75284
|
}
|
75283
75285
|
}
|
@@ -75357,15 +75359,17 @@ var VideoRegionsDataCollection = /*#__PURE__*/ function() {
|
|
75357
75359
|
this.timestampList = [];
|
75358
75360
|
this.totalLengthSeconds = 0;
|
75359
75361
|
this.missingInfo = {};
|
75360
|
-
this.missingInfo = {};
|
75361
75362
|
this.totalLengthSeconds = totalLengthSeconds;
|
75362
75363
|
if (frameInfo) {
|
75363
|
-
this.frameInfo
|
75364
|
-
|
75365
|
-
|
75366
|
-
|
75364
|
+
this.load(frameInfo);
|
75365
|
+
} else {
|
75366
|
+
this.missingInfo = {
|
75367
|
+
"0": {
|
75368
|
+
timestamp_start: 0,
|
75369
|
+
timestamp_end: totalLengthSeconds
|
75370
|
+
}
|
75371
|
+
};
|
75367
75372
|
}
|
75368
|
-
this.preProcessResults();
|
75369
75373
|
}
|
75370
75374
|
_create_class(VideoRegionsDataCollection, [
|
75371
75375
|
{
|
@@ -75381,11 +75385,16 @@ var VideoRegionsDataCollection = /*#__PURE__*/ function() {
|
|
75381
75385
|
}
|
75382
75386
|
},
|
75383
75387
|
{
|
75384
|
-
key: "
|
75385
|
-
value: function
|
75386
|
-
|
75387
|
-
|
75388
|
-
|
75388
|
+
key: "sortTimestamps",
|
75389
|
+
value: function sortTimestamps() {
|
75390
|
+
this.timestampList = Object.keys(this.frameInfo).sort(function(a, b) {
|
75391
|
+
return parseFloat(a) - parseFloat(b);
|
75392
|
+
});
|
75393
|
+
}
|
75394
|
+
},
|
75395
|
+
{
|
75396
|
+
key: "computeMissingIntervals",
|
75397
|
+
value: function computeMissingIntervals() {
|
75389
75398
|
var missingIntervals = {};
|
75390
75399
|
if (this.timestampList.length === 0) {
|
75391
75400
|
missingIntervals["0"] = {
|
@@ -75395,103 +75404,68 @@ var VideoRegionsDataCollection = /*#__PURE__*/ function() {
|
|
75395
75404
|
this.missingInfo = missingIntervals;
|
75396
75405
|
return;
|
75397
75406
|
}
|
75398
|
-
|
75399
|
-
|
75400
|
-
|
75401
|
-
|
75402
|
-
|
75403
|
-
|
75404
|
-
|
75405
|
-
|
75406
|
-
|
75407
|
-
|
75408
|
-
|
75409
|
-
|
75410
|
-
|
75411
|
-
|
75412
|
-
|
75413
|
-
|
75414
|
-
};
|
75415
|
-
} else {
|
75416
|
-
missingIntervals[frameInfo.timestamp_start] = {
|
75417
|
-
timestamp_start: frameInfo.timestamp_start,
|
75418
|
-
timestamp_end: this.totalLengthSeconds
|
75419
|
-
};
|
75420
|
-
}
|
75421
|
-
}
|
75422
|
-
} else if (index === 0) {
|
75423
|
-
if (frameInfo.timestamp_start !== 0) {
|
75424
|
-
missingIntervals[0] = {
|
75425
|
-
timestamp_start: 0,
|
75426
|
-
timestamp_end: frameInfo.timestamp_start
|
75427
|
-
};
|
75428
|
-
}
|
75429
|
-
} else if (index === this.timestampList.length - 1) {
|
75430
|
-
if (frameInfo.timestamp_end !== this.totalLengthSeconds) {
|
75431
|
-
if (frameInfo.timestamp_start !== this.totalLengthSeconds) {
|
75432
|
-
if (frameInfo.timestamp_end == null) {
|
75433
|
-
missingIntervals[frameInfo.timestamp_start] = {
|
75434
|
-
timestamp_start: frameInfo.timestamp_start,
|
75435
|
-
timestamp_end: this.totalLengthSeconds
|
75436
|
-
};
|
75437
|
-
} else {
|
75438
|
-
missingIntervals[frameInfo.timestamp_end] = {
|
75439
|
-
timestamp_start: frameInfo.timestamp_end,
|
75440
|
-
timestamp_end: this.totalLengthSeconds
|
75441
|
-
};
|
75442
|
-
}
|
75443
|
-
}
|
75444
|
-
}
|
75445
|
-
}
|
75446
|
-
if (nextFrameInfo) {
|
75447
|
-
if (frameInfo.timestamp_end !== nextFrameInfo.timestamp_start) {
|
75448
|
-
missingIntervals[frameInfo.timestamp_end] = {
|
75449
|
-
timestamp_start: frameInfo.timestamp_end,
|
75450
|
-
timestamp_end: nextFrameInfo.timestamp_start
|
75451
|
-
};
|
75452
|
-
}
|
75407
|
+
var first = this.frameInfo[this.timestampList[0]];
|
75408
|
+
var last = this.frameInfo[this.timestampList[this.timestampList.length - 1]];
|
75409
|
+
if (first.timestamp_start > 0) {
|
75410
|
+
missingIntervals["0"] = {
|
75411
|
+
timestamp_start: 0,
|
75412
|
+
timestamp_end: first.timestamp_start
|
75413
|
+
};
|
75414
|
+
}
|
75415
|
+
for(var i = 0; i < this.timestampList.length - 1; i++){
|
75416
|
+
var current = this.frameInfo[this.timestampList[i]];
|
75417
|
+
var next = this.frameInfo[this.timestampList[i + 1]];
|
75418
|
+
if (current.timestamp_end !== next.timestamp_start) {
|
75419
|
+
missingIntervals[String(current.timestamp_end)] = {
|
75420
|
+
timestamp_start: current.timestamp_end,
|
75421
|
+
timestamp_end: next.timestamp_start
|
75422
|
+
};
|
75453
75423
|
}
|
75454
75424
|
}
|
75425
|
+
if (last.timestamp_end == null) {
|
75426
|
+
missingIntervals[String(last.timestamp_start)] = {
|
75427
|
+
timestamp_start: last.timestamp_start,
|
75428
|
+
timestamp_end: this.totalLengthSeconds
|
75429
|
+
};
|
75430
|
+
} else if (last.timestamp_end < this.totalLengthSeconds) {
|
75431
|
+
missingIntervals[String(last.timestamp_end)] = {
|
75432
|
+
timestamp_start: last.timestamp_end,
|
75433
|
+
timestamp_end: this.totalLengthSeconds
|
75434
|
+
};
|
75435
|
+
}
|
75455
75436
|
this.missingInfo = missingIntervals;
|
75456
|
-
return;
|
75457
75437
|
}
|
75458
75438
|
},
|
75459
75439
|
{
|
75460
75440
|
key: "isValidRegionForTimestamp",
|
75461
75441
|
value: function isValidRegionForTimestamp(region, timestamp) {
|
75462
|
-
|
75463
|
-
return true;
|
75464
|
-
}
|
75465
|
-
if (region.timestamp_start === timestamp || region.timestamp_end === timestamp) {
|
75466
|
-
return true;
|
75467
|
-
}
|
75468
|
-
return false;
|
75442
|
+
return timestamp >= region.timestamp_start && (region.timestamp_end == null || timestamp <= region.timestamp_end);
|
75469
75443
|
}
|
75470
75444
|
},
|
75471
75445
|
{
|
75472
75446
|
key: "findFrame",
|
75473
|
-
value: function findFrame(
|
75447
|
+
value: function findFrame(timestamp) {
|
75448
|
+
if (this.timestampList.length === 0) return null;
|
75474
75449
|
var left = 0;
|
75475
|
-
if (this.timestampList.length === 0) {
|
75476
|
-
return null;
|
75477
|
-
}
|
75478
75450
|
var right = this.timestampList.length - 1;
|
75479
|
-
var
|
75480
|
-
var
|
75481
|
-
|
75482
|
-
|
75451
|
+
var leftRegion = this.frameInfo[this.timestampList[left]];
|
75452
|
+
var rightRegion = this.frameInfo[this.timestampList[right]];
|
75453
|
+
while(rightRegion.timestamp_end == null){
|
75454
|
+
right--;
|
75455
|
+
if (right < 0) {
|
75456
|
+
return null;
|
75457
|
+
}
|
75458
|
+
rightRegion = this.frameInfo[this.timestampList[right]];
|
75483
75459
|
}
|
75484
|
-
if (
|
75485
|
-
return null;
|
75486
|
-
} else if (target > rightInterval.timestamp_end) {
|
75460
|
+
if (timestamp < leftRegion.timestamp_start || timestamp > rightRegion.timestamp_end) {
|
75487
75461
|
return null;
|
75488
75462
|
}
|
75489
75463
|
while(left <= right){
|
75490
75464
|
var mid = Math.floor((left + right) / 2);
|
75491
|
-
var
|
75492
|
-
if (this.isValidRegionForTimestamp(
|
75493
|
-
return
|
75494
|
-
} else if (
|
75465
|
+
var region = this.frameInfo[this.timestampList[mid]];
|
75466
|
+
if (this.isValidRegionForTimestamp(region, timestamp)) {
|
75467
|
+
return region;
|
75468
|
+
} else if (region.timestamp_end != null && region.timestamp_end < timestamp) {
|
75495
75469
|
left = mid + 1;
|
75496
75470
|
} else {
|
75497
75471
|
right = mid - 1;
|
@@ -75503,23 +75477,17 @@ var VideoRegionsDataCollection = /*#__PURE__*/ function() {
|
|
75503
75477
|
{
|
75504
75478
|
key: "load",
|
75505
75479
|
value: function load(frameInfo) {
|
75506
|
-
|
75507
|
-
|
75508
|
-
|
75509
|
-
return parseFloat(a) - parseFloat(b);
|
75510
|
-
});
|
75511
|
-
}
|
75512
|
-
this.preProcessResults();
|
75480
|
+
this.frameInfo = _object_spread({}, frameInfo);
|
75481
|
+
this.sortTimestamps();
|
75482
|
+
this.computeMissingIntervals();
|
75513
75483
|
}
|
75514
75484
|
},
|
75515
75485
|
{
|
75516
75486
|
key: "append",
|
75517
75487
|
value: function append(frameInfo) {
|
75518
75488
|
this.frameInfo = _object_spread({}, this.frameInfo, frameInfo);
|
75519
|
-
this.
|
75520
|
-
|
75521
|
-
});
|
75522
|
-
this.preProcessResults();
|
75489
|
+
this.sortTimestamps();
|
75490
|
+
this.computeMissingIntervals();
|
75523
75491
|
}
|
75524
75492
|
},
|
75525
75493
|
{
|
@@ -75530,21 +75498,30 @@ var VideoRegionsDataCollection = /*#__PURE__*/ function() {
|
|
75530
75498
|
},
|
75531
75499
|
{
|
75532
75500
|
key: "getRange",
|
75533
|
-
value: function getRange(
|
75534
|
-
|
75535
|
-
return this.frameInfo;
|
75536
|
-
}
|
75537
|
-
if (!from) {
|
75538
|
-
from = 0;
|
75539
|
-
}
|
75540
|
-
if (!to) {
|
75541
|
-
to = this.totalLengthSeconds;
|
75542
|
-
}
|
75501
|
+
value: function getRange() {
|
75502
|
+
var from = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0, to = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : this.totalLengthSeconds;
|
75543
75503
|
var result = {};
|
75544
|
-
|
75545
|
-
|
75546
|
-
|
75547
|
-
|
75504
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
75505
|
+
try {
|
75506
|
+
for(var _iterator = this.timestampList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
75507
|
+
var key = _step.value;
|
75508
|
+
var ts = parseFloat(key);
|
75509
|
+
if (ts >= from && ts <= to) {
|
75510
|
+
result[key] = this.frameInfo[key];
|
75511
|
+
}
|
75512
|
+
}
|
75513
|
+
} catch (err) {
|
75514
|
+
_didIteratorError = true;
|
75515
|
+
_iteratorError = err;
|
75516
|
+
} finally{
|
75517
|
+
try {
|
75518
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
75519
|
+
_iterator.return();
|
75520
|
+
}
|
75521
|
+
} finally{
|
75522
|
+
if (_didIteratorError) {
|
75523
|
+
throw _iteratorError;
|
75524
|
+
}
|
75548
75525
|
}
|
75549
75526
|
}
|
75550
75527
|
return result;
|
@@ -75554,17 +75531,28 @@ var VideoRegionsDataCollection = /*#__PURE__*/ function() {
|
|
75554
75531
|
key: "getNextMissingDataInterval",
|
75555
75532
|
value: function getNextMissingDataInterval(referenceTimestamp) {
|
75556
75533
|
var keys = Object.keys(this.missingInfo);
|
75557
|
-
if (
|
75558
|
-
|
75559
|
-
|
75560
|
-
|
75561
|
-
|
75562
|
-
|
75563
|
-
|
75564
|
-
|
75534
|
+
if (keys.length === 0) return void 0;
|
75535
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
75536
|
+
try {
|
75537
|
+
for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
75538
|
+
var key = _step.value;
|
75539
|
+
var interval = this.missingInfo[key];
|
75540
|
+
if (!referenceTimestamp || interval.timestamp_start >= referenceTimestamp) {
|
75541
|
+
return interval;
|
75542
|
+
}
|
75565
75543
|
}
|
75566
|
-
|
75567
|
-
|
75544
|
+
} catch (err) {
|
75545
|
+
_didIteratorError = true;
|
75546
|
+
_iteratorError = err;
|
75547
|
+
} finally{
|
75548
|
+
try {
|
75549
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
75550
|
+
_iterator.return();
|
75551
|
+
}
|
75552
|
+
} finally{
|
75553
|
+
if (_didIteratorError) {
|
75554
|
+
throw _iteratorError;
|
75555
|
+
}
|
75568
75556
|
}
|
75569
75557
|
}
|
75570
75558
|
return this.missingInfo[keys[keys.length - 1]];
|
@@ -75585,12 +75573,12 @@ var VideoRegionsDataManager = /*#__PURE__*/ function(_import_events4_EventEmitte
|
|
75585
75573
|
_this.options = options;
|
75586
75574
|
_this.logger = deps.logger;
|
75587
75575
|
_this.service = deps.service;
|
75576
|
+
_this.regionsData = new VideoRegionsDataCollection(_this.options.video.duration_s);
|
75588
75577
|
_this.handlePredictionResult = _this.handlePredictionResult.bind(_this);
|
75589
|
-
_this.
|
75578
|
+
_this.handlePredictionCompleted = _this.handlePredictionCompleted.bind(_this);
|
75590
75579
|
_this.handlePredictionAborted = _this.handlePredictionAborted.bind(_this);
|
75591
|
-
_this.regionsData = new VideoRegionsDataCollection(_this.options.video.duration_s);
|
75592
75580
|
_this.service.handle("result", _this.handlePredictionResult);
|
75593
|
-
_this.service.handle("completed", _this.
|
75581
|
+
_this.service.handle("completed", _this.handlePredictionCompleted);
|
75594
75582
|
_this.service.handle("aborted", _this.handlePredictionAborted);
|
75595
75583
|
return _this;
|
75596
75584
|
}
|
@@ -75604,8 +75592,8 @@ var VideoRegionsDataManager = /*#__PURE__*/ function(_import_events4_EventEmitte
|
|
75604
75592
|
}
|
75605
75593
|
},
|
75606
75594
|
{
|
75607
|
-
key: "
|
75608
|
-
value: function
|
75595
|
+
key: "handlePredictionCompleted",
|
75596
|
+
value: function handlePredictionCompleted() {
|
75609
75597
|
var _this_logger;
|
75610
75598
|
(_this_logger = this.logger) === null || _this_logger === void 0 ? void 0 : _this_logger.log("Prediction completed!");
|
75611
75599
|
}
|
@@ -75643,25 +75631,22 @@ var VideoRegionsDataManager = /*#__PURE__*/ function(_import_events4_EventEmitte
|
|
75643
75631
|
return;
|
75644
75632
|
}
|
75645
75633
|
(_this_logger1 = this.logger) === null || _this_logger1 === void 0 ? void 0 : _this_logger1.log("Collection is incomplete.");
|
75646
|
-
(_this_logger2 = this.logger) === null || _this_logger2 === void 0 ? void 0 : _this_logger2.log("Getting next missing data interval near
|
75634
|
+
(_this_logger2 = this.logger) === null || _this_logger2 === void 0 ? void 0 : _this_logger2.log("Getting next missing data interval near:", timestamp);
|
75647
75635
|
var interval = this.regionsData.getNextMissingDataInterval(timestamp);
|
75648
75636
|
if (interval) {
|
75649
|
-
var _this_logger6;
|
75650
|
-
(_this_logger6 = this.logger) === null || _this_logger6 === void 0 ? void 0 : _this_logger6.log("Found interval
|
75651
|
-
var timestampToAdjust;
|
75652
|
-
if (interval.timestamp_start
|
75653
|
-
var _this_logger7;
|
75654
|
-
timestampToAdjust = timestamp;
|
75655
|
-
(_this_logger7 = this.logger) === null || _this_logger7 === void 0 ? void 0 : _this_logger7.log("Adjusting frame to : ", timestampToAdjust);
|
75656
|
-
this.service.send("adjust", {
|
75657
|
-
timestamp: timestampToAdjust
|
75658
|
-
});
|
75659
|
-
} else {
|
75637
|
+
var _this_logger6, _this_logger7;
|
75638
|
+
(_this_logger6 = this.logger) === null || _this_logger6 === void 0 ? void 0 : _this_logger6.log("Found interval:", interval);
|
75639
|
+
var timestampToAdjust = timestamp;
|
75640
|
+
if (interval.timestamp_start >= timestamp) {
|
75660
75641
|
timestampToAdjust = interval.timestamp_start;
|
75661
75642
|
}
|
75643
|
+
(_this_logger7 = this.logger) === null || _this_logger7 === void 0 ? void 0 : _this_logger7.log("Adjusting frame to:", timestampToAdjust);
|
75644
|
+
this.service.send("adjust", {
|
75645
|
+
timestamp: timestampToAdjust
|
75646
|
+
});
|
75662
75647
|
} else {
|
75663
75648
|
var _this_logger8;
|
75664
|
-
(_this_logger8 = this.logger) === null || _this_logger8 === void 0 ? void 0 : _this_logger8.log("
|
75649
|
+
(_this_logger8 = this.logger) === null || _this_logger8 === void 0 ? void 0 : _this_logger8.log("No interval found.");
|
75665
75650
|
}
|
75666
75651
|
(_this_logger3 = this.logger) === null || _this_logger3 === void 0 ? void 0 : _this_logger3.groupEnd("[REGIONS DATA] : SEEK");
|
75667
75652
|
}
|
@@ -75683,12 +75668,12 @@ var VideoRegionsDataManager = /*#__PURE__*/ function(_import_events4_EventEmitte
|
|
75683
75668
|
value: function dumps(from, to) {
|
75684
75669
|
var a = document.createElement("a");
|
75685
75670
|
var file = new Blob([
|
75686
|
-
JSON.stringify(this.regionsData.getRange(from, to))
|
75671
|
+
JSON.stringify(this.regionsData.getRange(from, to), null, 2)
|
75687
75672
|
], {
|
75688
|
-
type: "
|
75673
|
+
type: "application/json"
|
75689
75674
|
});
|
75690
75675
|
a.href = URL.createObjectURL(file);
|
75691
|
-
var name = "dumps_".concat(/* @__PURE__ */ new Date().toISOString()).concat(from !== void 0 ? "_s="
|
75676
|
+
var name = "dumps_".concat(/* @__PURE__ */ new Date().toISOString()).concat(from !== void 0 ? "_s=".concat(from) : "").concat(to !== void 0 ? "_e=".concat(to) : "", ".json");
|
75692
75677
|
a.download = name;
|
75693
75678
|
a.click();
|
75694
75679
|
URL.revokeObjectURL(a.href);
|
@@ -75704,24 +75689,36 @@ var VideoRegionsDataManager = /*#__PURE__*/ function(_import_events4_EventEmitte
|
|
75704
75689
|
this.service.destroy();
|
75705
75690
|
this.regionsData.load(data);
|
75706
75691
|
}
|
75692
|
+
if (typeof window === "undefined") {
|
75693
|
+
var _this_logger;
|
75694
|
+
(_this_logger = this.logger) === null || _this_logger === void 0 ? void 0 : _this_logger.error("File input not supported in this environment.");
|
75695
|
+
return;
|
75696
|
+
}
|
75707
75697
|
var input = document.createElement("input");
|
75708
75698
|
input.type = "file";
|
75709
|
-
input
|
75699
|
+
input.addEventListener("change", function() {
|
75710
75700
|
var _input_files;
|
75711
|
-
var file =
|
75701
|
+
var file = (_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files[0];
|
75712
75702
|
if (!file) {
|
75713
|
-
|
75703
|
+
var _this_logger;
|
75704
|
+
(_this_logger = _this.logger) === null || _this_logger === void 0 ? void 0 : _this_logger.log("No file selected.");
|
75714
75705
|
return;
|
75715
75706
|
}
|
75716
75707
|
var reader = new FileReader();
|
75717
|
-
reader.onload = function(
|
75718
|
-
|
75719
|
-
|
75720
|
-
|
75721
|
-
|
75708
|
+
reader.onload = function(event) {
|
75709
|
+
try {
|
75710
|
+
var _event_target;
|
75711
|
+
var fileContent = event === null || event === void 0 ? void 0 : (_event_target = event.target) === null || _event_target === void 0 ? void 0 : _event_target.result;
|
75712
|
+
if (!fileContent || typeof fileContent !== "string") {
|
75713
|
+
throw new Error("Invalid file content.");
|
75714
|
+
}
|
75715
|
+
var parsed = JSON.parse(fileContent);
|
75722
75716
|
_this.service.send("stop");
|
75723
75717
|
_this.service.destroy();
|
75724
|
-
_this.regionsData.load(
|
75718
|
+
_this.regionsData.load(parsed);
|
75719
|
+
} catch (err) {
|
75720
|
+
var _this_logger;
|
75721
|
+
(_this_logger = _this.logger) === null || _this_logger === void 0 ? void 0 : _this_logger.error("Failed to load data:", err);
|
75725
75722
|
}
|
75726
75723
|
};
|
75727
75724
|
reader.readAsText(file);
|
@@ -75745,34 +75742,32 @@ var VideoRegionsDataManager = /*#__PURE__*/ function(_import_events4_EventEmitte
|
|
75745
75742
|
}).sort(function(a, b) {
|
75746
75743
|
return a.start - b.start;
|
75747
75744
|
});
|
75748
|
-
if (appearanceTimestamps.length === 0) {
|
75749
|
-
return [];
|
75750
|
-
}
|
75751
75745
|
var validPeriods = [];
|
75752
|
-
|
75753
|
-
var
|
75746
|
+
if (appearanceTimestamps.length === 0) return validPeriods;
|
75747
|
+
var currentStart = appearanceTimestamps[0].start;
|
75748
|
+
var currentEnd = appearanceTimestamps[0].end;
|
75754
75749
|
for(var i = 1; i < appearanceTimestamps.length; i++){
|
75755
|
-
var
|
75756
|
-
if (
|
75757
|
-
|
75750
|
+
var _appearanceTimestamps_i = appearanceTimestamps[i], start = _appearanceTimestamps_i.start, end2 = _appearanceTimestamps_i.end;
|
75751
|
+
if (start <= currentEnd) {
|
75752
|
+
currentEnd = Math.max(currentEnd, end2);
|
75758
75753
|
} else {
|
75759
|
-
var duration =
|
75754
|
+
var duration = currentEnd - currentStart;
|
75760
75755
|
if (duration >= minDurationSeconds) {
|
75761
75756
|
validPeriods.push({
|
75762
|
-
start:
|
75763
|
-
end:
|
75757
|
+
start: currentStart,
|
75758
|
+
end: currentEnd,
|
75764
75759
|
duration: duration
|
75765
75760
|
});
|
75766
75761
|
}
|
75767
|
-
|
75768
|
-
|
75762
|
+
currentStart = start;
|
75763
|
+
currentEnd = end2;
|
75769
75764
|
}
|
75770
75765
|
}
|
75771
|
-
var finalDuration =
|
75766
|
+
var finalDuration = currentEnd - currentStart;
|
75772
75767
|
if (finalDuration >= minDurationSeconds) {
|
75773
75768
|
validPeriods.push({
|
75774
|
-
start:
|
75775
|
-
end:
|
75769
|
+
start: currentStart,
|
75770
|
+
end: currentEnd,
|
75776
75771
|
duration: finalDuration
|
75777
75772
|
});
|
75778
75773
|
}
|
@@ -75782,10 +75777,10 @@ var VideoRegionsDataManager = /*#__PURE__*/ function(_import_events4_EventEmitte
|
|
75782
75777
|
{
|
75783
75778
|
key: "destroy",
|
75784
75779
|
value: function destroy() {
|
75785
|
-
var
|
75786
|
-
|
75787
|
-
|
75788
|
-
|
75780
|
+
var socket = this.service.socket;
|
75781
|
+
socket === null || socket === void 0 ? void 0 : socket.off("result", this.handlePredictionResult);
|
75782
|
+
socket === null || socket === void 0 ? void 0 : socket.off("completed", this.handlePredictionCompleted);
|
75783
|
+
socket === null || socket === void 0 ? void 0 : socket.off("aborted", this.handlePredictionAborted);
|
75789
75784
|
this.service.destroy();
|
75790
75785
|
}
|
75791
75786
|
}
|
@@ -82666,47 +82661,62 @@ var VideoRegionsDurationDecorator = /*#__PURE__*/ function(VideoRegionsDataManag
|
|
82666
82661
|
{
|
82667
82662
|
key: "check",
|
82668
82663
|
value: function check(timestamp) {
|
82669
|
-
var
|
82670
|
-
var
|
82671
|
-
var
|
82672
|
-
var
|
82673
|
-
while(
|
82674
|
-
var
|
82675
|
-
if (!
|
82664
|
+
var accumulatedDuration = 0;
|
82665
|
+
var persistentRegionIds = null;
|
82666
|
+
var currentTimestamp = timestamp;
|
82667
|
+
var collectedRegions = /* @__PURE__ */ new Map();
|
82668
|
+
while(accumulatedDuration < this.params.duration){
|
82669
|
+
var frame = this.component.check(currentTimestamp);
|
82670
|
+
if (!frame || !frame.regions || frame.timestamp_end == null) {
|
82676
82671
|
return null;
|
82677
82672
|
}
|
82678
|
-
|
82679
|
-
|
82680
|
-
return r3.id;
|
82681
|
-
});
|
82682
|
-
result = _to_consumable_array(regions2.regions);
|
82683
|
-
}
|
82684
|
-
var validRegions = regions2.regions.filter(function(reg) {
|
82685
|
-
return last === null || last === void 0 ? void 0 : last.includes(reg.id);
|
82673
|
+
var regionIds = frame.regions.map(function(r3) {
|
82674
|
+
return r3.id;
|
82686
82675
|
});
|
82687
|
-
if (
|
82688
|
-
|
82689
|
-
|
82690
|
-
|
82691
|
-
|
82692
|
-
|
82676
|
+
if (persistentRegionIds === null) {
|
82677
|
+
persistentRegionIds = new Set(regionIds);
|
82678
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
82679
|
+
try {
|
82680
|
+
for(var _iterator = frame.regions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
82681
|
+
var r3 = _step.value;
|
82682
|
+
collectedRegions.set(r3.id, r3);
|
82683
|
+
}
|
82684
|
+
} catch (err) {
|
82685
|
+
_didIteratorError = true;
|
82686
|
+
_iteratorError = err;
|
82687
|
+
} finally{
|
82688
|
+
try {
|
82689
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
82690
|
+
_iterator.return();
|
82691
|
+
}
|
82692
|
+
} finally{
|
82693
|
+
if (_didIteratorError) {
|
82694
|
+
throw _iteratorError;
|
82695
|
+
}
|
82696
|
+
}
|
82697
|
+
}
|
82698
|
+
;
|
82693
82699
|
} else {
|
82694
|
-
|
82700
|
+
persistentRegionIds = new Set(regionIds.filter(function(id) {
|
82701
|
+
return persistentRegionIds.has(id);
|
82702
|
+
}));
|
82695
82703
|
}
|
82696
|
-
|
82697
|
-
|
82698
|
-
|
82699
|
-
|
82700
|
-
|
82701
|
-
|
82702
|
-
}
|
82703
|
-
if (!result) {
|
82704
|
-
return null;
|
82704
|
+
if (persistentRegionIds.size === 0) {
|
82705
|
+
return null;
|
82706
|
+
}
|
82707
|
+
var duration = frame.timestamp_end - frame.timestamp_start;
|
82708
|
+
accumulatedDuration += duration;
|
82709
|
+
currentTimestamp = frame.timestamp_end + 0.01;
|
82705
82710
|
}
|
82711
|
+
var regionsToReturn = Array.from(persistentRegionIds || []).map(function(id) {
|
82712
|
+
return collectedRegions.get(id);
|
82713
|
+
}).filter(function(r3) {
|
82714
|
+
return !!r3;
|
82715
|
+
});
|
82706
82716
|
return {
|
82707
82717
|
timestamp_start: timestamp,
|
82708
|
-
timestamp_end: timestamp +
|
82709
|
-
regions:
|
82718
|
+
timestamp_end: timestamp + accumulatedDuration,
|
82719
|
+
regions: regionsToReturn
|
82710
82720
|
};
|
82711
82721
|
}
|
82712
82722
|
}
|
@@ -82729,47 +82739,63 @@ var VideoRegionsMaxDurationDecorator = /*#__PURE__*/ function(VideoRegionsDataMa
|
|
82729
82739
|
{
|
82730
82740
|
key: "check",
|
82731
82741
|
value: function check(timestamp) {
|
82732
|
-
var
|
82733
|
-
var
|
82734
|
-
var
|
82735
|
-
var
|
82736
|
-
|
82737
|
-
var
|
82738
|
-
if (!
|
82742
|
+
var accumulatedDuration = 0;
|
82743
|
+
var currentTimestamp = timestamp;
|
82744
|
+
var persistentRegionIds = null;
|
82745
|
+
var collectedRegions = /* @__PURE__ */ new Map();
|
82746
|
+
while(true){
|
82747
|
+
var frame = this.component.check(currentTimestamp);
|
82748
|
+
if (!frame || !frame.regions || frame.timestamp_end == null) {
|
82739
82749
|
break;
|
82740
82750
|
}
|
82741
|
-
|
82742
|
-
|
82743
|
-
return r3.id;
|
82744
|
-
});
|
82745
|
-
result = _to_consumable_array(regions2.regions);
|
82746
|
-
}
|
82747
|
-
var validRegions = regions2.regions.filter(function(reg) {
|
82748
|
-
return last === null || last === void 0 ? void 0 : last.includes(reg.id);
|
82751
|
+
var regionIds = frame.regions.map(function(r3) {
|
82752
|
+
return r3.id;
|
82749
82753
|
});
|
82750
|
-
if (
|
82751
|
-
|
82752
|
-
|
82753
|
-
|
82754
|
-
|
82755
|
-
|
82754
|
+
if (persistentRegionIds === null) {
|
82755
|
+
persistentRegionIds = new Set(regionIds);
|
82756
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
82757
|
+
try {
|
82758
|
+
for(var _iterator = frame.regions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
82759
|
+
var region = _step.value;
|
82760
|
+
collectedRegions.set(region.id, region);
|
82761
|
+
}
|
82762
|
+
} catch (err) {
|
82763
|
+
_didIteratorError = true;
|
82764
|
+
_iteratorError = err;
|
82765
|
+
} finally{
|
82766
|
+
try {
|
82767
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
82768
|
+
_iterator.return();
|
82769
|
+
}
|
82770
|
+
} finally{
|
82771
|
+
if (_didIteratorError) {
|
82772
|
+
throw _iteratorError;
|
82773
|
+
}
|
82774
|
+
}
|
82775
|
+
}
|
82756
82776
|
} else {
|
82757
|
-
|
82777
|
+
persistentRegionIds = new Set(regionIds.filter(function(id) {
|
82778
|
+
return persistentRegionIds.has(id);
|
82779
|
+
}));
|
82758
82780
|
}
|
82759
|
-
|
82760
|
-
|
82761
|
-
|
82762
|
-
|
82763
|
-
|
82764
|
-
|
82765
|
-
|
82766
|
-
if (!result || totalDuration < this.params.minDuration) {
|
82781
|
+
if (persistentRegionIds.size === 0) {
|
82782
|
+
break;
|
82783
|
+
}
|
82784
|
+
accumulatedDuration += frame.timestamp_end - frame.timestamp_start;
|
82785
|
+
currentTimestamp = frame.timestamp_end + 1e-3;
|
82786
|
+
}
|
82787
|
+
if (!persistentRegionIds || persistentRegionIds.size === 0 || accumulatedDuration < this.params.minDuration) {
|
82767
82788
|
return null;
|
82768
82789
|
}
|
82790
|
+
var regionsToReturn = Array.from(persistentRegionIds).map(function(id) {
|
82791
|
+
return collectedRegions.get(id);
|
82792
|
+
}).filter(function(r3) {
|
82793
|
+
return !!r3;
|
82794
|
+
});
|
82769
82795
|
return {
|
82770
82796
|
timestamp_start: timestamp,
|
82771
|
-
timestamp_end: timestamp +
|
82772
|
-
regions:
|
82797
|
+
timestamp_end: timestamp + accumulatedDuration,
|
82798
|
+
regions: regionsToReturn
|
82773
82799
|
};
|
82774
82800
|
}
|
82775
82801
|
}
|