decord/source/modules/video_backgrounds/applyBackgroundOption.tsx

479 lines
16 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 9698
// Function ID: 9699
2026-07-20 16:05:17 +00:00
// Name: _getFilterBlob
2026-08-24 06:08:38 +00:00
// Dependencies: [5, 1922, 9699, 8420, 676, 38, 9701, 4574, 9704, 1435, 9700, 9703, 9705, 2]
2026-07-20 16:05:17 +00:00
// Exports: applyBackgroundOptionPreview, applyInitialVideoBackgroundOption
2026-08-24 06:08:38 +00:00
// Module 9698 (_getFilterBlob)
import _fetchVideoFilterAssets from "_fetchVideoFilterAssets" /* 9701 */;
import getLastUsedVideoBackgroundOption from "getLastUsedVideoBackgroundOption" /* 9703 */;
import isVideoBackgroundSupportedDefault from "isVideoBackgroundSupported" /* 9705 */;
import closure_3 from "asyncGeneratorStep" /* 5 */;
import closure_4 from "mergeGuildAvatar" /* 1922 */;
import closure_5 from "handleSyncedStoresUpdate" /* 9699 */;
import VideoFilterType from "VideoFilterType" /* 8420 */;
import { NOOP } from "ME" /* 676 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
2026-07-20 16:05:17 +00:00
function _getFilterBlob() {
2026-07-29 08:29:29 +00:00
const self = this;
const tmp = callback((arg0) => {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
c3 = 0;
c4 = 0;
2026-07-29 08:29:29 +00:00
return (function*(arg0) {
2026-08-04 21:03:28 +00:00
const _fetch = fetch;
closure_0 = yield fetch(closure_0);
const Uint8ClampedArray = yield closure_0.blob();
const _Uint8ClampedArray = Uint8ClampedArray;
yield Uint8ClampedArray.arrayBuffer();
const tmp9 = new Uint8ClampedArray(arg1);
return tmp9;
2026-07-29 08:29:29 +00:00
})();
});
2026-08-24 06:08:38 +00:00
closure_9 = tmp;
2026-07-29 08:29:29 +00:00
const apply = tmp.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
}
function applyBackgroundMediaFilterSettings(arg0, target, graph, image, blob) {
2026-08-24 06:08:38 +00:00
let obj = _fetchVideoFilterAssets;
2026-07-20 16:05:17 +00:00
obj = { graph, target, image, blob };
const result = obj.applyMediaFilterSettings({ [arg0]: obj });
}
function applyBackgroundOption() {
2026-07-29 08:29:29 +00:00
const self = this;
const apply = _applyBackgroundOption.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
}
function _applyBackgroundOption() {
2026-07-29 08:29:29 +00:00
let self = this;
const tmp = callback((arg0, arg1, arg2) => {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
closure_1 = arg1;
closure_2 = arg2;
c8 = 0;
c9 = 0;
c7 = 0;
2026-07-29 08:29:29 +00:00
return (function*(arg0, arg1, arg2) {
if (c9 === 2) {
c9 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp6 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} else {
try {
c9 = 2;
if (0 === c8) {
if (arg0 === 1) {
c9 = 3;
throw arg1;
} else if (arg0 === 2) {
c9 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
c5 = tmp3;
c4 = tmp30;
2026-07-29 08:29:29 +00:00
let source;
c4 = undefined;
c5 = undefined;
2026-08-24 06:08:38 +00:00
closure_3 = false;
2026-07-29 08:29:29 +00:00
if (null == source) {
2026-08-24 06:08:38 +00:00
closure_1_10(tmp57, tmp58, callback(4574).FilterSettingsGraph.NONE);
2026-07-29 08:29:29 +00:00
c9 = 3;
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
} else if (tmp59 === c7) {
2026-08-24 06:08:38 +00:00
closure_1_10(tmp57, tmp58, callback(4574).FilterSettingsGraph.BACKGROUND_BLUR);
2026-07-29 08:29:29 +00:00
c9 = 3;
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
} else {
2026-08-04 21:03:28 +00:00
if (typeof tmp59 !== "string") {
if (typeof tmp59 !== "number") {
2026-07-29 08:29:29 +00:00
const asset = tmp59.asset;
2026-08-11 06:20:06 +00:00
let isAnimatedIconHashResult = callback(1435).isAnimatedIconHash(asset);
2026-07-29 08:29:29 +00:00
if (!isAnimatedIconHashResult) {
2026-08-11 06:20:06 +00:00
let obj3 = callback(1435);
2026-07-29 08:29:29 +00:00
isAnimatedIconHashResult = obj3.isVideoAssetHash(asset);
}
2026-08-24 06:08:38 +00:00
closure_3 = isAnimatedIconHashResult;
2026-08-11 06:20:06 +00:00
let obj4 = callback(1435);
2026-08-24 06:08:38 +00:00
obj1 = { userId: null, assetId: null, assetHash: null, size: null };
2026-07-29 08:29:29 +00:00
({ user_id: obj6[0], id: obj6[1] } = tmp59);
obj1[2] = asset;
2026-08-24 06:08:38 +00:00
obj1[3] = closure_1_6.width;
2026-07-29 08:29:29 +00:00
let videoFilterAssetURL = obj4.getVideoFilterAssetURL(obj1);
source = videoFilterAssetURL;
2026-08-11 06:20:06 +00:00
const obj11 = callback(1435);
2026-07-29 08:29:29 +00:00
}
if (null != videoFilterAssetURL) {
c7 = 1;
if (isAnimatedIconHashResult) {
c4 = tmp9;
2026-08-24 06:08:38 +00:00
if (closure_3) {
2026-07-29 08:29:29 +00:00
c8 = 3;
c9 = 1;
let obj2 = { value: null, done: false };
obj2[0] = (function getFilterBlob(source) {
const self = this;
const apply = c9.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
})(source);
return obj2;
} else {
c5 = tmp8;
callback3(callback, callback2, callback(source[7]).FilterSettingsGraph.BACKGROUND_REPLACEMENT, c4, c5);
c7 = 0;
tmp30 = callback3;
}
} else {
c8 = 2;
c9 = 1;
obj3 = { value: null, done: false };
obj3[0] = (function getFilterImage(videoFilterAssetURL) {
2026-08-24 06:08:38 +00:00
closure_0 = videoFilterAssetURL;
2026-07-29 08:29:29 +00:00
return new Promise((arg0, arg1) => {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
closure_1 = arg1;
2026-07-29 08:29:29 +00:00
const image = new globalThis.Image();
image.crossOrigin = "anonymous";
image.onload = function onload() { ... };
image.onerror = function onerror() { ... };
image.src = closure_0;
});
})(videoFilterAssetURL);
return obj3;
}
}
}
2026-08-24 06:08:38 +00:00
const tmp24 = callback2(9704)()[tmp59];
2026-07-29 08:29:29 +00:00
const isVideo = tmp24.isVideo;
2026-08-24 06:08:38 +00:00
closure_3 = isVideo;
2026-07-29 08:29:29 +00:00
if (isVideo == null) {
2026-08-24 06:08:38 +00:00
closure_3 = false;
2026-07-29 08:29:29 +00:00
}
source = tmp24.source;
2026-08-24 06:08:38 +00:00
isAnimatedIconHashResult = closure_3;
2026-07-29 08:29:29 +00:00
videoFilterAssetURL = source;
}
}
} else if (1 === tmp7) {
c7 = 0;
obj2 = callback(source[6]);
let result = obj2.errorApplyingMediaFilterSettings();
} else if (2 === tmp7) {
if (arg0 === 1) {
c9 = 3;
throw arg1;
} else {
if (arg0 === 2) {
c7 = 0;
c9 = 3;
obj4 = { value: null, done: true };
obj4[0] = arg1;
return obj4;
}
tmp9 = arg1;
}
} else if (arg0 === 1) {
c9 = 3;
throw arg1;
} else {
if (arg0 === 2) {
c7 = 0;
c9 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
}
tmp8 = arg1;
}
c9 = 3;
} catch (tmp48) {
2026-08-24 06:08:38 +00:00
closure_6 = tmp48;
2026-07-29 08:29:29 +00:00
if (tmp4 === c7) {
c9 = tmp2;
throw tmp48;
} else {
c8 = tmp;
}
}
}
})();
});
2026-08-24 06:08:38 +00:00
closure_12 = tmp;
2026-07-29 08:29:29 +00:00
let apply = tmp.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
}
function applyBackgroundOptionLive(lastUsedVideoBackgroundOption, arg1) {
2026-07-29 08:29:29 +00:00
const self = this;
const apply = _applyBackgroundOptionLive.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
}
function _applyBackgroundOptionLive() {
2026-07-29 08:29:29 +00:00
const self = this;
const tmp = callback((arg0, arg1) => {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
closure_1 = arg1;
c4 = 0;
c5 = 0;
2026-07-29 08:29:29 +00:00
const iter = (function*(arg0, arg1) {
if (c5 === 2) {
c5 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp4 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} else {
try {
c5 = 2;
if (0 === c4) {
if (arg0 === 1) {
c5 = 3;
throw arg1;
} else if (arg0 === 2) {
c5 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
closure_3 = tmp5;
2026-07-29 08:29:29 +00:00
let location = tmp2;
let flag;
location = undefined;
flag = flag.track;
if (flag === undefined) {
flag = true;
}
location = flag.location;
c4 = 1;
c5 = 1;
2026-08-12 06:57:52 +00:00
return { value: "ct", done: true };
2026-07-29 08:29:29 +00:00
}
} else if (1 === tmp5) {
if (arg0 === 1) {
c5 = 3;
throw arg1;
} else if (arg0 === 2) {
c5 = 3;
2026-08-24 06:08:38 +00:00
obj1 = { value: null, done: true };
2026-07-29 08:29:29 +00:00
obj1[0] = arg1;
return obj1;
} else {
const obj2 = { type: null };
obj2[0] = callback(location[7]).FilterTargetType.INPUT_DEVICE;
c4 = 2;
c5 = 1;
const obj3 = { value: null, done: false };
obj3[0] = callback2(callback(location[7]).FilterSettingsKey.CAMERA_BACKGROUND_LIVE, obj2, callback);
return obj3;
}
} else if (arg0 === 1) {
c5 = 3;
throw arg1;
} else if (arg0 === 2) {
c5 = 3;
const obj4 = { value: null, done: true };
obj4[0] = arg1;
return obj4;
} else {
if (flag) {
obj = callback(location[10]);
const result = obj.trackBackgroundOptionUpdated(callback, location, "Enabled");
}
c5 = 3;
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
2026-08-24 06:08:38 +00:00
} catch (tmp24) {
2026-07-29 08:29:29 +00:00
c5 = tmp;
2026-08-24 06:08:38 +00:00
throw tmp24;
2026-07-29 08:29:29 +00:00
}
}
})();
iter.next();
return iter;
});
2026-08-24 06:08:38 +00:00
closure_14 = tmp;
2026-07-29 08:29:29 +00:00
const apply = tmp.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
}
function _applyBackgroundOptionPreview() {
2026-07-29 08:29:29 +00:00
const self = this;
const tmp = callback((arg0, arg1, arg2) => {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
closure_1 = arg1;
closure_2 = arg2;
c5 = 0;
c6 = 0;
2026-07-29 08:29:29 +00:00
const iter = (function*(arg0, arg1, arg2) {
if (c6 === 2) {
c6 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp4 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} else {
try {
c6 = 2;
if (0 === c5) {
if (arg0 === 1) {
c6 = 3;
throw arg1;
} else if (arg0 === 2) {
c6 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
closure_4 = tmp5;
2026-07-29 08:29:29 +00:00
let location = tmp2;
let flag;
location = undefined;
flag = flag.track;
if (flag === undefined) {
flag = true;
}
location = flag.location;
c5 = 1;
c6 = 1;
2026-08-12 06:57:52 +00:00
return { value: "ct", done: true };
2026-07-29 08:29:29 +00:00
}
} else if (1 === tmp5) {
if (arg0 === 1) {
c6 = 3;
throw arg1;
} else if (arg0 === 2) {
c6 = 3;
2026-08-24 06:08:38 +00:00
obj1 = { value: null, done: true };
2026-07-29 08:29:29 +00:00
obj1[0] = arg1;
return obj1;
} else {
const result = callback(flag[6]).startApplyMediaFilterSettings();
const obj2 = { type: null, streamId: null };
obj2[0] = callback(flag[7]).FilterTargetType.STREAM;
obj2[1] = closure_1;
c5 = 2;
c6 = 1;
const obj3 = { value: null, done: false };
obj3[0] = callback2(callback(flag[7]).FilterSettingsKey.CAMERA_BACKGROUND_PREVIEW, obj2, callback);
return obj3;
}
} else if (arg0 === 1) {
c6 = 3;
throw arg1;
} else if (arg0 === 2) {
c6 = 3;
const obj4 = { value: null, done: true };
obj4[0] = arg1;
return obj4;
} else {
if (flag) {
obj = callback(flag[10]);
const result1 = obj.trackBackgroundOptionUpdated(callback, location, "Preview");
}
c6 = 3;
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} catch (tmp17) {
c6 = tmp;
throw tmp17;
}
}
})();
iter.next();
return iter;
});
2026-08-24 06:08:38 +00:00
closure_15 = tmp;
2026-07-29 08:29:29 +00:00
const apply = tmp.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
({ BACKGROUND_REPLACEMENT_SIZE: closure_6, BLUR_BACKGROUND_OPTION: error } = VideoFilterType);
2026-08-24 06:08:38 +00:00
let result = require("set").fileFinishedImporting("modules/video_backgrounds/applyBackgroundOption.tsx");
2026-07-20 16:05:17 +00:00
export { applyBackgroundOptionLive };
export const applyBackgroundOptionPreview = function applyBackgroundOptionPreview() {
2026-07-29 08:29:29 +00:00
const self = this;
const apply = _applyBackgroundOptionPreview.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
};
export const applyInitialVideoBackgroundOption = function applyInitialVideoBackgroundOption() {
2026-07-23 10:11:24 +00:00
currentUser = currentUser.getCurrentUser();
2026-07-20 16:05:17 +00:00
if (null != currentUser) {
2026-08-24 06:08:38 +00:00
const lastUsedVideoBackgroundOption = getLastUsedVideoBackgroundOption.getLastUsedVideoBackgroundOption(currentUser);
let tmp6 = isVideoBackgroundSupportedDefault();
2026-07-20 16:05:17 +00:00
if (tmp6) {
tmp6 = !hasBeenApplied.hasBeenApplied;
}
if (tmp6) {
tmp6 = null != lastUsedVideoBackgroundOption;
}
if (tmp6) {
2026-07-29 08:29:29 +00:00
applyBackgroundOptionLive(lastUsedVideoBackgroundOption, { track: false }).catch(NOOP);
const promise = applyBackgroundOptionLive(lastUsedVideoBackgroundOption, { track: false });
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
const obj = getLastUsedVideoBackgroundOption;
2026-07-20 16:05:17 +00:00
}
};