decord/source/5655_ViewabilityHelper.js

188 lines
5.9 KiB
JavaScript
Raw Normal View History

2026-08-08 06:10:11 +00:00
// Module ID: 5655
// Function ID: 5656
2026-07-20 16:05:17 +00:00
// Name: ViewabilityHelper
2026-08-08 06:10:11 +00:00
// Dependencies: [5638, 5639, 5626]
2026-07-20 16:05:17 +00:00
2026-08-08 06:10:11 +00:00
// Module 5655 (ViewabilityHelper)
2026-07-23 10:11:24 +00:00
import _classCallCheck from "_classCallCheck";
2026-07-29 08:29:29 +00:00
import _createClass from "_createClass";
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
const ViewabilityHelper = arg1;
class ViewabilityHelper {
constructor(arg0, arg1) {
tmp = outer1_2(this, ViewabilityHelper);
this.possiblyViewableIndices = [];
this.hasInteracted = false;
this.viewableIndices = [];
this.lastReportedViewableIndices = [];
set = new Set();
this.timers = set;
this.viewabilityConfig = global;
this.viewableIndicesChanged = arg1;
return;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}
const items = [
{
2026-07-20 16:05:17 +00:00
key: "dispose",
value: function dispose() {
const timers = this.timers;
const item = timers.forEach(clearTimeout);
}
2026-07-29 08:29:29 +00:00
},
{
2026-07-20 16:05:17 +00:00
key: "updateViewableItems",
value: function updateViewableItems(arg0, arg1, arg2, arg3, arg4, possiblyViewableIndices) {
let self = this;
self = this;
2026-07-29 08:29:29 +00:00
const dependencyMap = arg0;
let _classCallCheck = arg1;
let closure_3 = arg2;
let closure_4 = arg3;
let closure_5 = arg4;
2026-07-20 16:05:17 +00:00
if (undefined !== possiblyViewableIndices) {
self.possiblyViewableIndices = possiblyViewableIndices;
}
2026-07-23 10:11:24 +00:00
let viewabilityConfig = self.viewabilityConfig;
2026-07-20 16:05:17 +00:00
let prop;
2026-07-29 08:29:29 +00:00
if (viewabilityConfig != null) {
2026-07-20 16:05:17 +00:00
prop = viewabilityConfig.itemVisiblePercentThreshold;
}
if (null !== prop) {
2026-07-23 10:11:24 +00:00
let viewabilityConfig2 = self.viewabilityConfig;
2026-07-20 16:05:17 +00:00
let prop1;
2026-07-29 08:29:29 +00:00
if (viewabilityConfig2 != null) {
2026-07-20 16:05:17 +00:00
prop1 = viewabilityConfig2.itemVisiblePercentThreshold;
}
if (undefined !== prop1) {
const viewabilityConfig3 = self.viewabilityConfig;
let prop2;
2026-07-29 08:29:29 +00:00
if (viewabilityConfig3 != null) {
2026-07-20 16:05:17 +00:00
prop2 = viewabilityConfig3.viewAreaCoveragePercentThreshold;
}
if (null !== prop2) {
const viewabilityConfig4 = self.viewabilityConfig;
let prop3;
2026-07-29 08:29:29 +00:00
if (viewabilityConfig4 != null) {
2026-07-20 16:05:17 +00:00
prop3 = viewabilityConfig4.viewAreaCoveragePercentThreshold;
}
if (undefined !== prop3) {
const _Error = Error;
2026-08-08 06:10:11 +00:00
const error = new Error(timerId(5626).ErrorMessages.multipleViewabilityThresholdTypesNotSupported);
2026-07-20 16:05:17 +00:00
throw error;
}
}
}
}
const viewabilityConfig5 = self.viewabilityConfig;
let waitForInteraction;
2026-07-29 08:29:29 +00:00
if (viewabilityConfig5 != null) {
2026-07-20 16:05:17 +00:00
waitForInteraction = viewabilityConfig5.waitForInteraction;
}
2026-07-29 08:29:29 +00:00
if (!waitForInteraction) {
const prop4 = self.possiblyViewableIndices;
const found = prop4.filter((arg0) => {
const viewabilityConfig = self.viewabilityConfig;
let prop;
if (viewabilityConfig != null) {
prop = viewabilityConfig.viewAreaCoveragePercentThreshold;
}
const viewabilityConfig2 = self.viewabilityConfig;
let prop1;
if (viewabilityConfig2 != null) {
prop1 = viewabilityConfig2.itemVisiblePercentThreshold;
}
return self.isItemViewable(arg0, closure_1, _classCallCheck, closure_3, closure_4, prop, prop1, closure_5);
});
self.viewableIndices = found;
const viewabilityConfig6 = self.viewabilityConfig;
let num;
if (viewabilityConfig6 != null) {
num = viewabilityConfig6.minimumViewTime;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (num == null) {
num = 250;
}
if (num > 0) {
const _setTimeout = setTimeout;
timerId = setTimeout(() => {
const timers = self.timers;
timers.delete(timerId);
const result = self.checkViewableIndicesChanges(found);
}, num);
let timers = self.timers;
timers.add(timerId);
} else {
let result = self.checkViewableIndicesChanges(found);
2026-07-20 16:05:17 +00:00
}
}
}
2026-07-29 08:29:29 +00:00
},
{
2026-07-20 16:05:17 +00:00
key: "checkViewableIndicesChanges",
value: function checkViewableIndicesChanges(found) {
2026-07-23 10:11:24 +00:00
let self = this;
self = this;
2026-07-20 16:05:17 +00:00
found = found.filter((arg0) => {
const viewableIndices = self.viewableIndices;
return viewableIndices.includes(arg0);
});
const found1 = found.filter((arg0) => {
const lastReportedViewableIndices = self.lastReportedViewableIndices;
return !lastReportedViewableIndices.includes(arg0);
});
const prop = this.lastReportedViewableIndices;
const found2 = prop.filter((arg0) => !found.includes(arg0));
if (tmp) {
self.lastReportedViewableIndices = found;
const result = self.viewableIndicesChanged(found, found1, found2);
}
}
2026-07-29 08:29:29 +00:00
},
{
2026-07-20 16:05:17 +00:00
key: "clearLastReportedViewableIndices",
value: function clearLastReportedViewableIndices() {
this.lastReportedViewableIndices = [];
}
2026-07-29 08:29:29 +00:00
},
{
2026-07-20 16:05:17 +00:00
key: "isItemViewable",
2026-07-29 08:29:29 +00:00
value: function isItemViewable(arg0, arg1, arg2, arg3, width, prop, prop1, closure_5) {
const size = closure_5(arg0);
2026-07-20 16:05:17 +00:00
if (undefined === size) {
return false;
} else {
2026-07-23 10:11:24 +00:00
const diff = (arg1 ? size.x : size.y) - arg2;
2026-07-20 16:05:17 +00:00
const tmp3 = arg1 ? size.width : size.height;
if (arg1) {
width = width.width;
} else {
width = width.height - arg3;
}
const _Math = Math;
const _Math2 = Math;
const bound = Math.min(diff + tmp3, width);
const diff1 = bound - Math.max(diff, 0);
if (diff1 === tmp3) {
return true;
} else if (0 === diff1) {
return false;
} else {
if (null != prop) {
let result = 0.01 * prop;
} else {
2026-07-29 08:29:29 +00:00
let num2 = prop1;
if (prop1 == null) {
num2 = 0;
2026-07-20 16:05:17 +00:00
}
result = 0.01 * num2;
}
2026-07-23 10:11:24 +00:00
return (null != prop ? diff1 / width : diff1 / tmp3) >= result;
2026-07-20 16:05:17 +00:00
}
}
}
2026-07-29 08:29:29 +00:00
}
];
export default _createClass(ViewabilityHelper, items);