@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.js
CHANGED
@@ -70462,10 +70462,11 @@ var PrebidjsProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
70462
70462
|
key: "request",
|
70463
70463
|
value: function request(params) {
|
70464
70464
|
return _async_to_generator(function() {
|
70465
|
-
var adType, adName, regionId, regionInfo;
|
70465
|
+
var _this, adType, adName, regionId, regionInfo;
|
70466
70466
|
return _ts_generator(this, function(_state) {
|
70467
70467
|
switch(_state.label){
|
70468
70468
|
case 0:
|
70469
|
+
_this = this;
|
70469
70470
|
return [
|
70470
70471
|
4,
|
70471
70472
|
this.ready.promise
|
@@ -70504,6 +70505,10 @@ var PrebidjsProvider = /*#__PURE__*/ function(ContentProvider1) {
|
|
70504
70505
|
case 2:
|
70505
70506
|
_state.sent();
|
70506
70507
|
this.processBids(params, {});
|
70508
|
+
PrebidJS.defineSlot(this.options, regionId, params.params.regionId, adType);
|
70509
|
+
PrebidJS.request(regionId, params.params.regionId, function(bids) {
|
70510
|
+
return _this.processBids(params, bids);
|
70511
|
+
});
|
70507
70512
|
return [
|
70508
70513
|
2,
|
70509
70514
|
Promise.resolve()
|
@@ -75150,9 +75155,6 @@ function getProviderByUrl(url2) {
|
|
75150
75155
|
if (/^(https?:\/\/)?(www\.)?(youtube\.com|youtube-nocookie\.com|youtu\.?be)\/.+$/.test(url2)) {
|
75151
75156
|
return "YOUTUBE";
|
75152
75157
|
}
|
75153
|
-
if (/^https?:\/\/player.vimeo.com\/video\/\d{0,9}(?=\b|\/)/.test(url2)) {
|
75154
|
-
return "VIMEO";
|
75155
|
-
}
|
75156
75158
|
if (/^https:\/\/geo\.dailymotion\.com\/player(?:\/[a-zA-Z0-9]+)?\.html\?video=([a-zA-Z0-9]+)/.test(url2)) {
|
75157
75159
|
return "DAILYMOTION";
|
75158
75160
|
}
|
@@ -75197,7 +75199,7 @@ var MediaElementFactory = /*#__PURE__*/ function() {
|
|
75197
75199
|
if (hasSrc) {
|
75198
75200
|
var _hasSrc = _sliced_to_array(hasSrc, 2), el = _hasSrc[0], value2 = _hasSrc[1];
|
75199
75201
|
var provider2 = getProviderByUrl(value2);
|
75200
|
-
if (provider2
|
75202
|
+
if (provider2) {
|
75201
75203
|
return el;
|
75202
75204
|
}
|
75203
75205
|
}
|
@@ -75276,15 +75278,17 @@ var VideoRegionsDataCollection = /*#__PURE__*/ function() {
|
|
75276
75278
|
this.timestampList = [];
|
75277
75279
|
this.totalLengthSeconds = 0;
|
75278
75280
|
this.missingInfo = {};
|
75279
|
-
this.missingInfo = {};
|
75280
75281
|
this.totalLengthSeconds = totalLengthSeconds;
|
75281
75282
|
if (frameInfo) {
|
75282
|
-
this.frameInfo
|
75283
|
-
|
75284
|
-
|
75285
|
-
|
75283
|
+
this.load(frameInfo);
|
75284
|
+
} else {
|
75285
|
+
this.missingInfo = {
|
75286
|
+
"0": {
|
75287
|
+
timestamp_start: 0,
|
75288
|
+
timestamp_end: totalLengthSeconds
|
75289
|
+
}
|
75290
|
+
};
|
75286
75291
|
}
|
75287
|
-
this.preProcessResults();
|
75288
75292
|
}
|
75289
75293
|
_create_class(VideoRegionsDataCollection, [
|
75290
75294
|
{
|
@@ -75300,11 +75304,16 @@ var VideoRegionsDataCollection = /*#__PURE__*/ function() {
|
|
75300
75304
|
}
|
75301
75305
|
},
|
75302
75306
|
{
|
75303
|
-
key: "
|
75304
|
-
value: function
|
75305
|
-
|
75306
|
-
|
75307
|
-
|
75307
|
+
key: "sortTimestamps",
|
75308
|
+
value: function sortTimestamps() {
|
75309
|
+
this.timestampList = Object.keys(this.frameInfo).sort(function(a, b) {
|
75310
|
+
return parseFloat(a) - parseFloat(b);
|
75311
|
+
});
|
75312
|
+
}
|
75313
|
+
},
|
75314
|
+
{
|
75315
|
+
key: "computeMissingIntervals",
|
75316
|
+
value: function computeMissingIntervals() {
|
75308
75317
|
var missingIntervals = {};
|
75309
75318
|
if (this.timestampList.length === 0) {
|
75310
75319
|
missingIntervals["0"] = {
|
@@ -75314,103 +75323,68 @@ var VideoRegionsDataCollection = /*#__PURE__*/ function() {
|
|
75314
75323
|
this.missingInfo = missingIntervals;
|
75315
75324
|
return;
|
75316
75325
|
}
|
75317
|
-
|
75318
|
-
|
75319
|
-
|
75320
|
-
|
75321
|
-
|
75322
|
-
|
75323
|
-
|
75324
|
-
|
75325
|
-
|
75326
|
-
|
75327
|
-
|
75328
|
-
|
75329
|
-
|
75330
|
-
|
75331
|
-
|
75332
|
-
|
75333
|
-
};
|
75334
|
-
} else {
|
75335
|
-
missingIntervals[frameInfo.timestamp_start] = {
|
75336
|
-
timestamp_start: frameInfo.timestamp_start,
|
75337
|
-
timestamp_end: this.totalLengthSeconds
|
75338
|
-
};
|
75339
|
-
}
|
75340
|
-
}
|
75341
|
-
} else if (index === 0) {
|
75342
|
-
if (frameInfo.timestamp_start !== 0) {
|
75343
|
-
missingIntervals[0] = {
|
75344
|
-
timestamp_start: 0,
|
75345
|
-
timestamp_end: frameInfo.timestamp_start
|
75346
|
-
};
|
75347
|
-
}
|
75348
|
-
} else if (index === this.timestampList.length - 1) {
|
75349
|
-
if (frameInfo.timestamp_end !== this.totalLengthSeconds) {
|
75350
|
-
if (frameInfo.timestamp_start !== this.totalLengthSeconds) {
|
75351
|
-
if (frameInfo.timestamp_end == null) {
|
75352
|
-
missingIntervals[frameInfo.timestamp_start] = {
|
75353
|
-
timestamp_start: frameInfo.timestamp_start,
|
75354
|
-
timestamp_end: this.totalLengthSeconds
|
75355
|
-
};
|
75356
|
-
} else {
|
75357
|
-
missingIntervals[frameInfo.timestamp_end] = {
|
75358
|
-
timestamp_start: frameInfo.timestamp_end,
|
75359
|
-
timestamp_end: this.totalLengthSeconds
|
75360
|
-
};
|
75361
|
-
}
|
75362
|
-
}
|
75363
|
-
}
|
75364
|
-
}
|
75365
|
-
if (nextFrameInfo) {
|
75366
|
-
if (frameInfo.timestamp_end !== nextFrameInfo.timestamp_start) {
|
75367
|
-
missingIntervals[frameInfo.timestamp_end] = {
|
75368
|
-
timestamp_start: frameInfo.timestamp_end,
|
75369
|
-
timestamp_end: nextFrameInfo.timestamp_start
|
75370
|
-
};
|
75371
|
-
}
|
75326
|
+
var first = this.frameInfo[this.timestampList[0]];
|
75327
|
+
var last = this.frameInfo[this.timestampList[this.timestampList.length - 1]];
|
75328
|
+
if (first.timestamp_start > 0) {
|
75329
|
+
missingIntervals["0"] = {
|
75330
|
+
timestamp_start: 0,
|
75331
|
+
timestamp_end: first.timestamp_start
|
75332
|
+
};
|
75333
|
+
}
|
75334
|
+
for(var i = 0; i < this.timestampList.length - 1; i++){
|
75335
|
+
var current = this.frameInfo[this.timestampList[i]];
|
75336
|
+
var next = this.frameInfo[this.timestampList[i + 1]];
|
75337
|
+
if (current.timestamp_end !== next.timestamp_start) {
|
75338
|
+
missingIntervals[String(current.timestamp_end)] = {
|
75339
|
+
timestamp_start: current.timestamp_end,
|
75340
|
+
timestamp_end: next.timestamp_start
|
75341
|
+
};
|
75372
75342
|
}
|
75373
75343
|
}
|
75344
|
+
if (last.timestamp_end == null) {
|
75345
|
+
missingIntervals[String(last.timestamp_start)] = {
|
75346
|
+
timestamp_start: last.timestamp_start,
|
75347
|
+
timestamp_end: this.totalLengthSeconds
|
75348
|
+
};
|
75349
|
+
} else if (last.timestamp_end < this.totalLengthSeconds) {
|
75350
|
+
missingIntervals[String(last.timestamp_end)] = {
|
75351
|
+
timestamp_start: last.timestamp_end,
|
75352
|
+
timestamp_end: this.totalLengthSeconds
|
75353
|
+
};
|
75354
|
+
}
|
75374
75355
|
this.missingInfo = missingIntervals;
|
75375
|
-
return;
|
75376
75356
|
}
|
75377
75357
|
},
|
75378
75358
|
{
|
75379
75359
|
key: "isValidRegionForTimestamp",
|
75380
75360
|
value: function isValidRegionForTimestamp(region, timestamp) {
|
75381
|
-
|
75382
|
-
return true;
|
75383
|
-
}
|
75384
|
-
if (region.timestamp_start === timestamp || region.timestamp_end === timestamp) {
|
75385
|
-
return true;
|
75386
|
-
}
|
75387
|
-
return false;
|
75361
|
+
return timestamp >= region.timestamp_start && (region.timestamp_end == null || timestamp <= region.timestamp_end);
|
75388
75362
|
}
|
75389
75363
|
},
|
75390
75364
|
{
|
75391
75365
|
key: "findFrame",
|
75392
|
-
value: function findFrame(
|
75366
|
+
value: function findFrame(timestamp) {
|
75367
|
+
if (this.timestampList.length === 0) return null;
|
75393
75368
|
var left = 0;
|
75394
|
-
if (this.timestampList.length === 0) {
|
75395
|
-
return null;
|
75396
|
-
}
|
75397
75369
|
var right = this.timestampList.length - 1;
|
75398
|
-
var
|
75399
|
-
var
|
75400
|
-
|
75401
|
-
|
75370
|
+
var leftRegion = this.frameInfo[this.timestampList[left]];
|
75371
|
+
var rightRegion = this.frameInfo[this.timestampList[right]];
|
75372
|
+
while(rightRegion.timestamp_end == null){
|
75373
|
+
right--;
|
75374
|
+
if (right < 0) {
|
75375
|
+
return null;
|
75376
|
+
}
|
75377
|
+
rightRegion = this.frameInfo[this.timestampList[right]];
|
75402
75378
|
}
|
75403
|
-
if (
|
75404
|
-
return null;
|
75405
|
-
} else if (target > rightInterval.timestamp_end) {
|
75379
|
+
if (timestamp < leftRegion.timestamp_start || timestamp > rightRegion.timestamp_end) {
|
75406
75380
|
return null;
|
75407
75381
|
}
|
75408
75382
|
while(left <= right){
|
75409
75383
|
var mid = Math.floor((left + right) / 2);
|
75410
|
-
var
|
75411
|
-
if (this.isValidRegionForTimestamp(
|
75412
|
-
return
|
75413
|
-
} else if (
|
75384
|
+
var region = this.frameInfo[this.timestampList[mid]];
|
75385
|
+
if (this.isValidRegionForTimestamp(region, timestamp)) {
|
75386
|
+
return region;
|
75387
|
+
} else if (region.timestamp_end != null && region.timestamp_end < timestamp) {
|
75414
75388
|
left = mid + 1;
|
75415
75389
|
} else {
|
75416
75390
|
right = mid - 1;
|
@@ -75422,23 +75396,17 @@ var VideoRegionsDataCollection = /*#__PURE__*/ function() {
|
|
75422
75396
|
{
|
75423
75397
|
key: "load",
|
75424
75398
|
value: function load(frameInfo) {
|
75425
|
-
|
75426
|
-
|
75427
|
-
|
75428
|
-
return parseFloat(a) - parseFloat(b);
|
75429
|
-
});
|
75430
|
-
}
|
75431
|
-
this.preProcessResults();
|
75399
|
+
this.frameInfo = _object_spread({}, frameInfo);
|
75400
|
+
this.sortTimestamps();
|
75401
|
+
this.computeMissingIntervals();
|
75432
75402
|
}
|
75433
75403
|
},
|
75434
75404
|
{
|
75435
75405
|
key: "append",
|
75436
75406
|
value: function append(frameInfo) {
|
75437
75407
|
this.frameInfo = _object_spread({}, this.frameInfo, frameInfo);
|
75438
|
-
this.
|
75439
|
-
|
75440
|
-
});
|
75441
|
-
this.preProcessResults();
|
75408
|
+
this.sortTimestamps();
|
75409
|
+
this.computeMissingIntervals();
|
75442
75410
|
}
|
75443
75411
|
},
|
75444
75412
|
{
|
@@ -75449,21 +75417,30 @@ var VideoRegionsDataCollection = /*#__PURE__*/ function() {
|
|
75449
75417
|
},
|
75450
75418
|
{
|
75451
75419
|
key: "getRange",
|
75452
|
-
value: function getRange(
|
75453
|
-
|
75454
|
-
return this.frameInfo;
|
75455
|
-
}
|
75456
|
-
if (!from) {
|
75457
|
-
from = 0;
|
75458
|
-
}
|
75459
|
-
if (!to) {
|
75460
|
-
to = this.totalLengthSeconds;
|
75461
|
-
}
|
75420
|
+
value: function getRange() {
|
75421
|
+
var from = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0, to = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : this.totalLengthSeconds;
|
75462
75422
|
var result = {};
|
75463
|
-
|
75464
|
-
|
75465
|
-
|
75466
|
-
|
75423
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
75424
|
+
try {
|
75425
|
+
for(var _iterator = this.timestampList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
75426
|
+
var key = _step.value;
|
75427
|
+
var ts = parseFloat(key);
|
75428
|
+
if (ts >= from && ts <= to) {
|
75429
|
+
result[key] = this.frameInfo[key];
|
75430
|
+
}
|
75431
|
+
}
|
75432
|
+
} catch (err) {
|
75433
|
+
_didIteratorError = true;
|
75434
|
+
_iteratorError = err;
|
75435
|
+
} finally{
|
75436
|
+
try {
|
75437
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
75438
|
+
_iterator.return();
|
75439
|
+
}
|
75440
|
+
} finally{
|
75441
|
+
if (_didIteratorError) {
|
75442
|
+
throw _iteratorError;
|
75443
|
+
}
|
75467
75444
|
}
|
75468
75445
|
}
|
75469
75446
|
return result;
|
@@ -75473,17 +75450,28 @@ var VideoRegionsDataCollection = /*#__PURE__*/ function() {
|
|
75473
75450
|
key: "getNextMissingDataInterval",
|
75474
75451
|
value: function getNextMissingDataInterval(referenceTimestamp) {
|
75475
75452
|
var keys = Object.keys(this.missingInfo);
|
75476
|
-
if (
|
75477
|
-
|
75478
|
-
|
75479
|
-
|
75480
|
-
|
75481
|
-
|
75482
|
-
|
75483
|
-
|
75453
|
+
if (keys.length === 0) return void 0;
|
75454
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
75455
|
+
try {
|
75456
|
+
for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
75457
|
+
var key = _step.value;
|
75458
|
+
var interval = this.missingInfo[key];
|
75459
|
+
if (!referenceTimestamp || interval.timestamp_start >= referenceTimestamp) {
|
75460
|
+
return interval;
|
75461
|
+
}
|
75484
75462
|
}
|
75485
|
-
|
75486
|
-
|
75463
|
+
} catch (err) {
|
75464
|
+
_didIteratorError = true;
|
75465
|
+
_iteratorError = err;
|
75466
|
+
} finally{
|
75467
|
+
try {
|
75468
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
75469
|
+
_iterator.return();
|
75470
|
+
}
|
75471
|
+
} finally{
|
75472
|
+
if (_didIteratorError) {
|
75473
|
+
throw _iteratorError;
|
75474
|
+
}
|
75487
75475
|
}
|
75488
75476
|
}
|
75489
75477
|
return this.missingInfo[keys[keys.length - 1]];
|
@@ -75503,12 +75491,12 @@ var VideoRegionsDataManager = /*#__PURE__*/ function(_import_events4_EventEmitte
|
|
75503
75491
|
_this.options = options;
|
75504
75492
|
_this.logger = deps.logger;
|
75505
75493
|
_this.service = deps.service;
|
75494
|
+
_this.regionsData = new VideoRegionsDataCollection(_this.options.video.duration_s);
|
75506
75495
|
_this.handlePredictionResult = _this.handlePredictionResult.bind(_this);
|
75507
|
-
_this.
|
75496
|
+
_this.handlePredictionCompleted = _this.handlePredictionCompleted.bind(_this);
|
75508
75497
|
_this.handlePredictionAborted = _this.handlePredictionAborted.bind(_this);
|
75509
|
-
_this.regionsData = new VideoRegionsDataCollection(_this.options.video.duration_s);
|
75510
75498
|
_this.service.handle("result", _this.handlePredictionResult);
|
75511
|
-
_this.service.handle("completed", _this.
|
75499
|
+
_this.service.handle("completed", _this.handlePredictionCompleted);
|
75512
75500
|
_this.service.handle("aborted", _this.handlePredictionAborted);
|
75513
75501
|
return _this;
|
75514
75502
|
}
|
@@ -75522,8 +75510,8 @@ var VideoRegionsDataManager = /*#__PURE__*/ function(_import_events4_EventEmitte
|
|
75522
75510
|
}
|
75523
75511
|
},
|
75524
75512
|
{
|
75525
|
-
key: "
|
75526
|
-
value: function
|
75513
|
+
key: "handlePredictionCompleted",
|
75514
|
+
value: function handlePredictionCompleted() {
|
75527
75515
|
var _this_logger;
|
75528
75516
|
(_this_logger = this.logger) === null || _this_logger === void 0 ? void 0 : _this_logger.log("Prediction completed!");
|
75529
75517
|
}
|
@@ -75561,25 +75549,22 @@ var VideoRegionsDataManager = /*#__PURE__*/ function(_import_events4_EventEmitte
|
|
75561
75549
|
return;
|
75562
75550
|
}
|
75563
75551
|
(_this_logger1 = this.logger) === null || _this_logger1 === void 0 ? void 0 : _this_logger1.log("Collection is incomplete.");
|
75564
|
-
(_this_logger2 = this.logger) === null || _this_logger2 === void 0 ? void 0 : _this_logger2.log("Getting next missing data interval near
|
75552
|
+
(_this_logger2 = this.logger) === null || _this_logger2 === void 0 ? void 0 : _this_logger2.log("Getting next missing data interval near:", timestamp);
|
75565
75553
|
var interval = this.regionsData.getNextMissingDataInterval(timestamp);
|
75566
75554
|
if (interval) {
|
75567
|
-
var _this_logger6;
|
75568
|
-
(_this_logger6 = this.logger) === null || _this_logger6 === void 0 ? void 0 : _this_logger6.log("Found interval
|
75569
|
-
var timestampToAdjust;
|
75570
|
-
if (interval.timestamp_start
|
75571
|
-
var _this_logger7;
|
75572
|
-
timestampToAdjust = timestamp;
|
75573
|
-
(_this_logger7 = this.logger) === null || _this_logger7 === void 0 ? void 0 : _this_logger7.log("Adjusting frame to : ", timestampToAdjust);
|
75574
|
-
this.service.send("adjust", {
|
75575
|
-
timestamp: timestampToAdjust
|
75576
|
-
});
|
75577
|
-
} else {
|
75555
|
+
var _this_logger6, _this_logger7;
|
75556
|
+
(_this_logger6 = this.logger) === null || _this_logger6 === void 0 ? void 0 : _this_logger6.log("Found interval:", interval);
|
75557
|
+
var timestampToAdjust = timestamp;
|
75558
|
+
if (interval.timestamp_start >= timestamp) {
|
75578
75559
|
timestampToAdjust = interval.timestamp_start;
|
75579
75560
|
}
|
75561
|
+
(_this_logger7 = this.logger) === null || _this_logger7 === void 0 ? void 0 : _this_logger7.log("Adjusting frame to:", timestampToAdjust);
|
75562
|
+
this.service.send("adjust", {
|
75563
|
+
timestamp: timestampToAdjust
|
75564
|
+
});
|
75580
75565
|
} else {
|
75581
75566
|
var _this_logger8;
|
75582
|
-
(_this_logger8 = this.logger) === null || _this_logger8 === void 0 ? void 0 : _this_logger8.log("
|
75567
|
+
(_this_logger8 = this.logger) === null || _this_logger8 === void 0 ? void 0 : _this_logger8.log("No interval found.");
|
75583
75568
|
}
|
75584
75569
|
(_this_logger3 = this.logger) === null || _this_logger3 === void 0 ? void 0 : _this_logger3.groupEnd("[REGIONS DATA] : SEEK");
|
75585
75570
|
}
|
@@ -75601,12 +75586,12 @@ var VideoRegionsDataManager = /*#__PURE__*/ function(_import_events4_EventEmitte
|
|
75601
75586
|
value: function dumps(from, to) {
|
75602
75587
|
var a = document.createElement("a");
|
75603
75588
|
var file = new Blob([
|
75604
|
-
JSON.stringify(this.regionsData.getRange(from, to))
|
75589
|
+
JSON.stringify(this.regionsData.getRange(from, to), null, 2)
|
75605
75590
|
], {
|
75606
|
-
type: "
|
75591
|
+
type: "application/json"
|
75607
75592
|
});
|
75608
75593
|
a.href = URL.createObjectURL(file);
|
75609
|
-
var name = "dumps_".concat(/* @__PURE__ */ new Date().toISOString()).concat(from !== void 0 ? "_s="
|
75594
|
+
var name = "dumps_".concat(/* @__PURE__ */ new Date().toISOString()).concat(from !== void 0 ? "_s=".concat(from) : "").concat(to !== void 0 ? "_e=".concat(to) : "", ".json");
|
75610
75595
|
a.download = name;
|
75611
75596
|
a.click();
|
75612
75597
|
URL.revokeObjectURL(a.href);
|
@@ -75622,24 +75607,36 @@ var VideoRegionsDataManager = /*#__PURE__*/ function(_import_events4_EventEmitte
|
|
75622
75607
|
this.service.destroy();
|
75623
75608
|
this.regionsData.load(data);
|
75624
75609
|
}
|
75610
|
+
if (typeof window === "undefined") {
|
75611
|
+
var _this_logger;
|
75612
|
+
(_this_logger = this.logger) === null || _this_logger === void 0 ? void 0 : _this_logger.error("File input not supported in this environment.");
|
75613
|
+
return;
|
75614
|
+
}
|
75625
75615
|
var input = document.createElement("input");
|
75626
75616
|
input.type = "file";
|
75627
|
-
input
|
75617
|
+
input.addEventListener("change", function() {
|
75628
75618
|
var _input_files;
|
75629
|
-
var file =
|
75619
|
+
var file = (_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files[0];
|
75630
75620
|
if (!file) {
|
75631
|
-
|
75621
|
+
var _this_logger;
|
75622
|
+
(_this_logger = _this.logger) === null || _this_logger === void 0 ? void 0 : _this_logger.log("No file selected.");
|
75632
75623
|
return;
|
75633
75624
|
}
|
75634
75625
|
var reader = new FileReader();
|
75635
|
-
reader.onload = function(
|
75636
|
-
|
75637
|
-
|
75638
|
-
|
75639
|
-
|
75626
|
+
reader.onload = function(event) {
|
75627
|
+
try {
|
75628
|
+
var _event_target;
|
75629
|
+
var fileContent = event === null || event === void 0 ? void 0 : (_event_target = event.target) === null || _event_target === void 0 ? void 0 : _event_target.result;
|
75630
|
+
if (!fileContent || typeof fileContent !== "string") {
|
75631
|
+
throw new Error("Invalid file content.");
|
75632
|
+
}
|
75633
|
+
var parsed = JSON.parse(fileContent);
|
75640
75634
|
_this.service.send("stop");
|
75641
75635
|
_this.service.destroy();
|
75642
|
-
_this.regionsData.load(
|
75636
|
+
_this.regionsData.load(parsed);
|
75637
|
+
} catch (err) {
|
75638
|
+
var _this_logger;
|
75639
|
+
(_this_logger = _this.logger) === null || _this_logger === void 0 ? void 0 : _this_logger.error("Failed to load data:", err);
|
75643
75640
|
}
|
75644
75641
|
};
|
75645
75642
|
reader.readAsText(file);
|
@@ -75663,34 +75660,32 @@ var VideoRegionsDataManager = /*#__PURE__*/ function(_import_events4_EventEmitte
|
|
75663
75660
|
}).sort(function(a, b) {
|
75664
75661
|
return a.start - b.start;
|
75665
75662
|
});
|
75666
|
-
if (appearanceTimestamps.length === 0) {
|
75667
|
-
return [];
|
75668
|
-
}
|
75669
75663
|
var validPeriods = [];
|
75670
|
-
|
75671
|
-
var
|
75664
|
+
if (appearanceTimestamps.length === 0) return validPeriods;
|
75665
|
+
var currentStart = appearanceTimestamps[0].start;
|
75666
|
+
var currentEnd = appearanceTimestamps[0].end;
|
75672
75667
|
for(var i = 1; i < appearanceTimestamps.length; i++){
|
75673
|
-
var
|
75674
|
-
if (
|
75675
|
-
|
75668
|
+
var _appearanceTimestamps_i = appearanceTimestamps[i], start = _appearanceTimestamps_i.start, end2 = _appearanceTimestamps_i.end;
|
75669
|
+
if (start <= currentEnd) {
|
75670
|
+
currentEnd = Math.max(currentEnd, end2);
|
75676
75671
|
} else {
|
75677
|
-
var duration =
|
75672
|
+
var duration = currentEnd - currentStart;
|
75678
75673
|
if (duration >= minDurationSeconds) {
|
75679
75674
|
validPeriods.push({
|
75680
|
-
start:
|
75681
|
-
end:
|
75675
|
+
start: currentStart,
|
75676
|
+
end: currentEnd,
|
75682
75677
|
duration: duration
|
75683
75678
|
});
|
75684
75679
|
}
|
75685
|
-
|
75686
|
-
|
75680
|
+
currentStart = start;
|
75681
|
+
currentEnd = end2;
|
75687
75682
|
}
|
75688
75683
|
}
|
75689
|
-
var finalDuration =
|
75684
|
+
var finalDuration = currentEnd - currentStart;
|
75690
75685
|
if (finalDuration >= minDurationSeconds) {
|
75691
75686
|
validPeriods.push({
|
75692
|
-
start:
|
75693
|
-
end:
|
75687
|
+
start: currentStart,
|
75688
|
+
end: currentEnd,
|
75694
75689
|
duration: finalDuration
|
75695
75690
|
});
|
75696
75691
|
}
|
@@ -75700,10 +75695,10 @@ var VideoRegionsDataManager = /*#__PURE__*/ function(_import_events4_EventEmitte
|
|
75700
75695
|
{
|
75701
75696
|
key: "destroy",
|
75702
75697
|
value: function destroy() {
|
75703
|
-
var
|
75704
|
-
|
75705
|
-
|
75706
|
-
|
75698
|
+
var socket = this.service.socket;
|
75699
|
+
socket === null || socket === void 0 ? void 0 : socket.off("result", this.handlePredictionResult);
|
75700
|
+
socket === null || socket === void 0 ? void 0 : socket.off("completed", this.handlePredictionCompleted);
|
75701
|
+
socket === null || socket === void 0 ? void 0 : socket.off("aborted", this.handlePredictionAborted);
|
75707
75702
|
this.service.destroy();
|
75708
75703
|
}
|
75709
75704
|
}
|
@@ -82538,47 +82533,62 @@ var VideoRegionsDurationDecorator = /*#__PURE__*/ function(VideoRegionsDataManag
|
|
82538
82533
|
{
|
82539
82534
|
key: "check",
|
82540
82535
|
value: function check(timestamp) {
|
82541
|
-
var
|
82542
|
-
var
|
82543
|
-
var
|
82544
|
-
var
|
82545
|
-
while(
|
82546
|
-
var
|
82547
|
-
if (!
|
82536
|
+
var accumulatedDuration = 0;
|
82537
|
+
var persistentRegionIds = null;
|
82538
|
+
var currentTimestamp = timestamp;
|
82539
|
+
var collectedRegions = /* @__PURE__ */ new Map();
|
82540
|
+
while(accumulatedDuration < this.params.duration){
|
82541
|
+
var frame = this.component.check(currentTimestamp);
|
82542
|
+
if (!frame || !frame.regions || frame.timestamp_end == null) {
|
82548
82543
|
return null;
|
82549
82544
|
}
|
82550
|
-
|
82551
|
-
|
82552
|
-
return r3.id;
|
82553
|
-
});
|
82554
|
-
result = _to_consumable_array(regions2.regions);
|
82555
|
-
}
|
82556
|
-
var validRegions = regions2.regions.filter(function(reg) {
|
82557
|
-
return last === null || last === void 0 ? void 0 : last.includes(reg.id);
|
82545
|
+
var regionIds = frame.regions.map(function(r3) {
|
82546
|
+
return r3.id;
|
82558
82547
|
});
|
82559
|
-
if (
|
82560
|
-
|
82561
|
-
|
82562
|
-
|
82563
|
-
|
82564
|
-
|
82548
|
+
if (persistentRegionIds === null) {
|
82549
|
+
persistentRegionIds = new Set(regionIds);
|
82550
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
82551
|
+
try {
|
82552
|
+
for(var _iterator = frame.regions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
82553
|
+
var r3 = _step.value;
|
82554
|
+
collectedRegions.set(r3.id, r3);
|
82555
|
+
}
|
82556
|
+
} catch (err) {
|
82557
|
+
_didIteratorError = true;
|
82558
|
+
_iteratorError = err;
|
82559
|
+
} finally{
|
82560
|
+
try {
|
82561
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
82562
|
+
_iterator.return();
|
82563
|
+
}
|
82564
|
+
} finally{
|
82565
|
+
if (_didIteratorError) {
|
82566
|
+
throw _iteratorError;
|
82567
|
+
}
|
82568
|
+
}
|
82569
|
+
}
|
82570
|
+
;
|
82565
82571
|
} else {
|
82566
|
-
|
82572
|
+
persistentRegionIds = new Set(regionIds.filter(function(id) {
|
82573
|
+
return persistentRegionIds.has(id);
|
82574
|
+
}));
|
82567
82575
|
}
|
82568
|
-
|
82569
|
-
|
82570
|
-
|
82571
|
-
|
82572
|
-
|
82573
|
-
|
82574
|
-
}
|
82575
|
-
if (!result) {
|
82576
|
-
return null;
|
82576
|
+
if (persistentRegionIds.size === 0) {
|
82577
|
+
return null;
|
82578
|
+
}
|
82579
|
+
var duration = frame.timestamp_end - frame.timestamp_start;
|
82580
|
+
accumulatedDuration += duration;
|
82581
|
+
currentTimestamp = frame.timestamp_end + 0.01;
|
82577
82582
|
}
|
82583
|
+
var regionsToReturn = Array.from(persistentRegionIds || []).map(function(id) {
|
82584
|
+
return collectedRegions.get(id);
|
82585
|
+
}).filter(function(r3) {
|
82586
|
+
return !!r3;
|
82587
|
+
});
|
82578
82588
|
return {
|
82579
82589
|
timestamp_start: timestamp,
|
82580
|
-
timestamp_end: timestamp +
|
82581
|
-
regions:
|
82590
|
+
timestamp_end: timestamp + accumulatedDuration,
|
82591
|
+
regions: regionsToReturn
|
82582
82592
|
};
|
82583
82593
|
}
|
82584
82594
|
}
|
@@ -82600,47 +82610,63 @@ var VideoRegionsMaxDurationDecorator = /*#__PURE__*/ function(VideoRegionsDataMa
|
|
82600
82610
|
{
|
82601
82611
|
key: "check",
|
82602
82612
|
value: function check(timestamp) {
|
82603
|
-
var
|
82604
|
-
var
|
82605
|
-
var
|
82606
|
-
var
|
82607
|
-
|
82608
|
-
var
|
82609
|
-
if (!
|
82613
|
+
var accumulatedDuration = 0;
|
82614
|
+
var currentTimestamp = timestamp;
|
82615
|
+
var persistentRegionIds = null;
|
82616
|
+
var collectedRegions = /* @__PURE__ */ new Map();
|
82617
|
+
while(true){
|
82618
|
+
var frame = this.component.check(currentTimestamp);
|
82619
|
+
if (!frame || !frame.regions || frame.timestamp_end == null) {
|
82610
82620
|
break;
|
82611
82621
|
}
|
82612
|
-
|
82613
|
-
|
82614
|
-
return r3.id;
|
82615
|
-
});
|
82616
|
-
result = _to_consumable_array(regions2.regions);
|
82617
|
-
}
|
82618
|
-
var validRegions = regions2.regions.filter(function(reg) {
|
82619
|
-
return last === null || last === void 0 ? void 0 : last.includes(reg.id);
|
82622
|
+
var regionIds = frame.regions.map(function(r3) {
|
82623
|
+
return r3.id;
|
82620
82624
|
});
|
82621
|
-
if (
|
82622
|
-
|
82623
|
-
|
82624
|
-
|
82625
|
-
|
82626
|
-
|
82625
|
+
if (persistentRegionIds === null) {
|
82626
|
+
persistentRegionIds = new Set(regionIds);
|
82627
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
82628
|
+
try {
|
82629
|
+
for(var _iterator = frame.regions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
82630
|
+
var region = _step.value;
|
82631
|
+
collectedRegions.set(region.id, region);
|
82632
|
+
}
|
82633
|
+
} catch (err) {
|
82634
|
+
_didIteratorError = true;
|
82635
|
+
_iteratorError = err;
|
82636
|
+
} finally{
|
82637
|
+
try {
|
82638
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
82639
|
+
_iterator.return();
|
82640
|
+
}
|
82641
|
+
} finally{
|
82642
|
+
if (_didIteratorError) {
|
82643
|
+
throw _iteratorError;
|
82644
|
+
}
|
82645
|
+
}
|
82646
|
+
}
|
82627
82647
|
} else {
|
82628
|
-
|
82648
|
+
persistentRegionIds = new Set(regionIds.filter(function(id) {
|
82649
|
+
return persistentRegionIds.has(id);
|
82650
|
+
}));
|
82629
82651
|
}
|
82630
|
-
|
82631
|
-
|
82632
|
-
|
82633
|
-
|
82634
|
-
|
82635
|
-
|
82636
|
-
|
82637
|
-
if (!result || totalDuration < this.params.minDuration) {
|
82652
|
+
if (persistentRegionIds.size === 0) {
|
82653
|
+
break;
|
82654
|
+
}
|
82655
|
+
accumulatedDuration += frame.timestamp_end - frame.timestamp_start;
|
82656
|
+
currentTimestamp = frame.timestamp_end + 1e-3;
|
82657
|
+
}
|
82658
|
+
if (!persistentRegionIds || persistentRegionIds.size === 0 || accumulatedDuration < this.params.minDuration) {
|
82638
82659
|
return null;
|
82639
82660
|
}
|
82661
|
+
var regionsToReturn = Array.from(persistentRegionIds).map(function(id) {
|
82662
|
+
return collectedRegions.get(id);
|
82663
|
+
}).filter(function(r3) {
|
82664
|
+
return !!r3;
|
82665
|
+
});
|
82640
82666
|
return {
|
82641
82667
|
timestamp_start: timestamp,
|
82642
|
-
timestamp_end: timestamp +
|
82643
|
-
regions:
|
82668
|
+
timestamp_end: timestamp + accumulatedDuration,
|
82669
|
+
regions: regionsToReturn
|
82644
82670
|
};
|
82645
82671
|
}
|
82646
82672
|
}
|