decord/alpha/source/modules/clips/clipPayloadUtils.tsx

221 lines
8 KiB
TypeScript
Raw Normal View History

2026-10-09 10:00:15 +00:00
// Module ID: 7743
// Function ID: 7744
// Name: clipPayloadUtils
2026-10-09 10:00:15 +00:00
// Dependencies: [32, 7744, 1085, 5116, 7745, 1265, 2]
2026-08-28 06:19:39 +00:00
// Exports: getClipCreatedAt, getClipEventsTimeline, getClipParticipantIds, getClipSyncTimestamp
2026-07-20 16:05:17 +00:00
2026-10-09 10:00:15 +00:00
// Module 7743 (clipPayloadUtils)
2026-10-03 08:58:59 +00:00
import Constants from "Constants" /* 1085 */;
2026-10-09 10:00:15 +00:00
import AnalyticsUtilsDefault from "AnalyticsUtils" /* 1265 */;
import Constants2 from "Constants" /* 5116 */;
2026-10-03 08:58:59 +00:00
import _slicedToArray from "_slicedToArray" /* 32 */;
2026-10-09 10:00:15 +00:00
import ClipsConstants from "ClipsConstants" /* 7744 */;
2026-10-03 08:58:59 +00:00
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
const require = globalThis.__r;
2026-10-03 08:58:59 +00:00
let _require, importDefault, map, map1;
2026-10-03 08:58:59 +00:00
let closure_4;
let hasOwnProperty;
let metroImportAll;
let metroImportDefault;
let metroRequire;
({ CLIPS_MAX_PARTICIPANTS: closure_4, CLIPS_MAX_TIMELINE_EVENTS: hasOwnProperty, ClipSignalTypes: metroRequire, GameEventType: metroImportDefault, CLIP_RUNTIME: metroImportAll } = ClipsConstants);
const AnalyticEvents = Constants.AnalyticEvents;
const SpeakingFlags = Constants2.SpeakingFlags;
const ServerClipGameEventType = { UNKNOWN: 0, [0]: "UNKNOWN", KILL: 1, [1]: "KILL", MULTIKILL: 2, [2]: "MULTIKILL", DEATH: 3, [3]: "DEATH" };
let result = size.fileFinishedImporting("modules/clips/clipPayloadUtils.tsx");
2026-07-20 16:05:17 +00:00
export const getClipCreatedAt = function getClipCreatedAt(createdAt) {
2026-10-03 08:58:59 +00:00
const date = new Date(createdAt);
return date.toISOString();
2026-07-20 16:05:17 +00:00
};
2026-08-28 06:19:39 +00:00
export const getClipSyncTimestamp = function getClipSyncTimestamp(clip) {
if (null != clip.syncTimestamp) {
2026-10-03 08:58:59 +00:00
let length;
2026-08-28 06:19:39 +00:00
const editMetadata = clip.editMetadata;
let end;
if (editMetadata != null) {
end = editMetadata.end;
}
if (null != end) {
2026-10-03 08:58:59 +00:00
length = 1000 * clip.editMetadata.end;
2026-08-28 06:19:39 +00:00
} else {
length = clip.length;
}
const _Date = Date;
2026-10-03 08:58:59 +00:00
const self = this;
const self2 = this;
2026-08-28 06:19:39 +00:00
const date = new Date(clip.syncTimestamp - (clip.length - length));
return date.toISOString();
}
};
2026-07-20 16:05:17 +00:00
export const getClipParticipantIds = function getClipParticipantIds(users) {
2026-10-03 08:58:59 +00:00
return users.slice(0, React3);
2026-07-20 16:05:17 +00:00
};
export { ServerClipGameEventType };
2026-07-20 16:05:17 +00:00
export const getClipEventsTimeline = function getClipEventsTimeline(clip) {
2026-10-03 08:58:59 +00:00
let closure_1;
_require = clip;
2026-07-20 16:05:17 +00:00
const timeline = clip.timeline;
2026-07-29 08:29:29 +00:00
let num;
if (timeline != null) {
num = timeline.length;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (num == null) {
num = 0;
2026-07-20 16:05:17 +00:00
}
if (0 !== num) {
const decision = clip.decision;
let timestamp;
2026-07-29 08:29:29 +00:00
if (decision != null) {
2026-07-20 16:05:17 +00:00
timestamp = decision.timestamp;
}
if (null != timestamp) {
2026-10-03 08:58:59 +00:00
let obj;
2026-07-20 16:05:17 +00:00
let editMetadata = clip.editMetadata;
2026-07-29 08:29:29 +00:00
if (editMetadata == null) {
2026-10-03 08:58:59 +00:00
obj = { start: 0, end: clip.length / 1000 };
2026-07-20 16:05:17 +00:00
editMetadata = obj;
}
const diff = clip.decision.timestamp - clip.length;
2026-10-03 08:58:59 +00:00
const sum = diff + 1000 * editMetadata.start;
const sum1 = diff + 1000 * editMetadata.end;
const obj2 = require("GameEventsOnPlayerExperiment");
importDefault = obj2.isGameEventsOnPlayerEnabled("getClipEventsTimeline");
2026-07-20 16:05:17 +00:00
const timeline1 = clip.timeline;
const found = timeline1.filter((signal) => {
2026-10-03 08:58:59 +00:00
const editMetadata = clip.editMetadata;
2026-07-20 16:05:17 +00:00
let voiceAudio;
2026-07-29 08:29:29 +00:00
if (editMetadata != null) {
2026-07-20 16:05:17 +00:00
voiceAudio = editMetadata.voiceAudio;
}
2026-10-03 08:58:59 +00:00
let tmp2 = false !== voiceAudio && signal.signal.type === metroRequire.SPEAKING;
2026-07-20 16:05:17 +00:00
if (!tmp2) {
2026-10-03 08:58:59 +00:00
tmp2 = closure_1 && signal.signal.type === metroRequire.GAME_EVENT;
const tmp4 = closure_1 && signal.signal.type === metroRequire.GAME_EVENT;
2026-07-20 16:05:17 +00:00
}
return tmp2;
});
const sorted = found.sort((timestamp, timestamp2) => timestamp.timestamp - timestamp2.timestamp);
if (0 !== sorted.length) {
const _Map = Map;
2026-10-03 08:58:59 +00:00
const self = this;
const self2 = this;
map = new Map();
2026-07-20 16:05:17 +00:00
const items = [];
const _Map2 = Map;
2026-10-03 08:58:59 +00:00
const self3 = this;
const self4 = this;
map1 = new Map();
2026-08-04 08:36:32 +00:00
for (const item10061 of sorted) {
2026-10-03 08:58:59 +00:00
let tmp12 = item10061;
2026-08-04 08:36:32 +00:00
if (item10061.signal.type !== constants.SPEAKING) {
2026-07-29 08:29:29 +00:00
continue;
} else {
2026-10-03 08:58:59 +00:00
if (tmp12.timestamp >= sum) {
obj6.return();
2026-07-20 16:05:17 +00:00
break;
} else {
2026-10-03 08:58:59 +00:00
let result = map.set(tmp12.signal.userId, (tmp12.signal.speakingFlags & SpeakingFlags.VOICE) === SpeakingFlags.VOICE);
2026-07-20 16:05:17 +00:00
}
break;
}
2026-10-03 08:58:59 +00:00
let tmp21 = tmp8[Symbol.iterator]();
while (tmp21 !== undefined) {
let tmp26 = _slicedToArray(tmp23, 2);
let first = tmp26[0];
if (tmp26[1]) {
let obj3 = { timestamp_ms: 0, speaking: obj4 };
let obj4 = { user_id: first, speaking_flags: SpeakingFlags.VOICE };
let arr = items.push(obj3);
}
continue;
}
for (const item10106 of sorted) {
let tmp33 = item10106;
if (item10106.signal.type === constants.SPEAKING) {
if (tmp33.timestamp < sum) {
continue;
} else {
if (tmp33.timestamp > sum1) {
obj9.return();
break;
} else {
let tmp73 = (tmp33.signal.speakingFlags & SpeakingFlags.VOICE) === SpeakingFlags.VOICE;
let flag = map.get(tmp33.signal.userId) ?? false;
if (flag === tmp73) {
continue;
} else {
let result1 = map.set(tmp33.signal.userId, tmp73);
let obj5 = { timestamp_ms: Math.round(tmp33.timestamp - sum), speaking: obj7 };
let _Math2 = Math;
let push = items.push;
let obj7 = { user_id: tmp33.signal.userId, speaking_flags: tmp33.signal.speakingFlags };
let arr2 = push(obj5);
}
}
break;
}
let substr = items.slice(0, closure_5);
if (substr.length !== items.length) {
let obj13 = AnalyticsUtilsDefault;
let obj8 = { clip_uuid: clip.id, clip_event_timeline_size: items.length, clip_runtime };
let trackResult = obj13.track(AnalyticEvents.CLIP_TIMELINE_TRIMMED, obj8);
}
let tmp58;
if (substr.length > 0) {
tmp58 = substr;
}
return tmp58;
} else {
if (tmp33.signal.type === tmp35.GAME_EVENT) {
if (tmp33.timestamp < sum) {
continue;
} else {
if (tmp33.timestamp > sum1) {
obj9.return();
break;
} else {
let KILL;
let eventType = tmp33.signal.eventType;
if (constants2.KILL === eventType) {
KILL = obj.KILL;
} else if (tmp64.MULTIKILL === eventType) {
KILL = obj.MULTIKILL;
}
if (null == KILL) {
continue;
} else {
let _Math = Math;
let rounded = Math.round(tmp33.timestamp - sum);
let tmp67 = rounded;
let value = map1.get(rounded);
if (null != value) {
if (KILL === obj.MULTIKILL) {
let obj10 = { type: KILL };
items[tmp69].game = obj10;
}
continue;
} else {
let result2 = map1.set(tmp67, items.length);
let obj11 = { timestamp_ms: tmp67, game: obj12 };
let obj12 = { type: KILL };
let arr3 = items.push(obj11);
}
}
}
break;
}
break;
}
continue;
}
continue;
}
2026-07-20 16:05:17 +00:00
}
}
}
}
};