395 lines
13 KiB
TypeScript
395 lines
13 KiB
TypeScript
// Module ID: 9312
|
|
// Function ID: 9313
|
|
// Name: applyBackgroundOption
|
|
// Dependencies: [5, 1377, 9313, 6484, 1085, 9314, 4945, 9318, 1402, 9323, 9317, 9316, 9324, 2]
|
|
// Exports: applyBackgroundOptionPreview, applyInitialVideoBackgroundOption
|
|
|
|
// Module 9312 (applyBackgroundOption)
|
|
import Constants from "Constants" /* 1085 */;
|
|
import AvatarUtils from "AvatarUtils" /* 1402 */;
|
|
import BaseConnectionEvent from "BaseConnectionEvent" /* 4945 */;
|
|
import VideoBackgroundActionCreators from "VideoBackgroundActionCreators" /* 9314 */;
|
|
import LastUsedVideoBackgroundOption from "LastUsedVideoBackgroundOption" /* 9316 */;
|
|
import getDefaultBackgroundDataDefault from "getDefaultBackgroundData" /* 9318 */;
|
|
import getFilterImageDefault from "getFilterImage" /* 9323 */;
|
|
import isVideoBackgroundEnabledDefault from "isVideoBackgroundEnabled" /* 9324 */;
|
|
import _asyncToGenerator from "_asyncToGenerator" /* 5 */;
|
|
import UserStore from "UserStore" /* 1377 */;
|
|
import VideoBackgroundStore from "VideoBackgroundStore" /* 9313 */;
|
|
import VideoBackgroundConstants from "VideoBackgroundConstants" /* 6484 */;
|
|
import size from "module_2" /* 2 */;
|
|
|
|
let c8, c9;
|
|
|
|
let metroImportDefault;
|
|
let metroRequire;
|
|
let obj = function _getFilterBlob() {
|
|
obj = _asyncToGenerator(async function(arg0) {
|
|
let c3;
|
|
let c4;
|
|
let closure_2;
|
|
let closure_0 = arg0;
|
|
const _fetch = fetch;
|
|
closure_0 = await fetch(closure_0);
|
|
await closure_0.blob();
|
|
const _Uint8ClampedArray = Uint8ClampedArray;
|
|
await _Uint8ClampedArray.arrayBuffer();
|
|
const self = this;
|
|
const self2 = this;
|
|
const tmp6 = new Uint8ClampedArray(arg1);
|
|
return tmp6;
|
|
});
|
|
return obj(...arguments);
|
|
};
|
|
function applyBackgroundMediaFilterSettings(arg0, target, graph, image, blob) {
|
|
obj = VideoBackgroundActionCreators;
|
|
const obj2 = { graph, target, image, blob };
|
|
const result = obj.applyMediaFilterSettings({ [arg0]: obj2 });
|
|
}
|
|
function applyBackgroundOption() {
|
|
return obj(...arguments);
|
|
}
|
|
obj = function _applyBackgroundOption() {
|
|
let styles;
|
|
obj = _asyncToGenerator(async (arg0, value, arg2) => {
|
|
let tmp29;
|
|
let tmp5;
|
|
let tmp6;
|
|
function getFilterBlob() {
|
|
return closure_1_9(...arguments);
|
|
}
|
|
let closure_0 = arg0;
|
|
let closure_1 = value;
|
|
let closure_2 = arg2;
|
|
if (c9 === 2) {
|
|
c9 = 3;
|
|
throw new TypeError("Generator functions may not be called on executing generators");
|
|
} else if (tmp3 === 3) {
|
|
if (arg0 === 1) {
|
|
throw value;
|
|
} else if (arg0 === 2) {
|
|
const obj2 = { value, done: true };
|
|
return obj2;
|
|
} else {
|
|
return { value: "IconComponent", done: null };
|
|
}
|
|
} else {
|
|
let c7;
|
|
try {
|
|
c9 = 2;
|
|
if (0 === c8) {
|
|
if (arg0 === 1) {
|
|
c9 = 3;
|
|
throw value;
|
|
} else if (arg0 === 2) {
|
|
c9 = 3;
|
|
const obj7 = { value, done: true };
|
|
return obj7;
|
|
} else {
|
|
let closure_5 = tmp;
|
|
let closure_4 = tmp29;
|
|
let source;
|
|
let c4;
|
|
let c5;
|
|
let closure_3 = false;
|
|
if (null == closure_2) {
|
|
applyBackgroundMediaFilterSettings(closure_0, closure_1, BaseConnectionEvent.FilterSettingsGraph.NONE);
|
|
c9 = 3;
|
|
return { value: "IconComponent", done: null };
|
|
} else if (closure_2 === metroImportDefault) {
|
|
applyBackgroundMediaFilterSettings(closure_0, closure_1, BaseConnectionEvent.FilterSettingsGraph.BACKGROUND_BLUR);
|
|
c9 = 3;
|
|
return { value: "IconComponent", done: null };
|
|
} else {
|
|
if (typeof closure_2 !== "string") {
|
|
let isAnimatedIconHashResult;
|
|
let videoFilterAssetURL;
|
|
if (typeof closure_2 !== "number") {
|
|
const asset = tmp56.asset;
|
|
const obj11 = AvatarUtils;
|
|
isAnimatedIconHashResult = obj11.isAnimatedIconHash(asset);
|
|
if (!isAnimatedIconHashResult) {
|
|
const obj4 = AvatarUtils;
|
|
isAnimatedIconHashResult = obj4.isVideoAssetHash(asset);
|
|
}
|
|
closure_3 = isAnimatedIconHashResult;
|
|
const obj8 = { userId: null, assetId: null, assetHash: asset, size: styles.width };
|
|
({ user_id: obj6.userId, id: obj6.assetId } = closure_2);
|
|
const obj5 = AvatarUtils;
|
|
videoFilterAssetURL = obj5.getVideoFilterAssetURL(obj8);
|
|
source = videoFilterAssetURL;
|
|
}
|
|
if (null != videoFilterAssetURL) {
|
|
c7 = 1;
|
|
if (isAnimatedIconHashResult) {
|
|
c4 = tmp6;
|
|
if (closure_3) {
|
|
c8 = 3;
|
|
c9 = 1;
|
|
const obj9 = { value: getFilterBlob(source), done: false };
|
|
return obj9;
|
|
} else {
|
|
c5 = tmp5;
|
|
closure_133_10(closure_0, closure_1, closure_133_0(closure_133_2[6]).FilterSettingsGraph.BACKGROUND_REPLACEMENT, c4, c5);
|
|
c7 = 0;
|
|
tmp29 = closure_133_10;
|
|
}
|
|
} else {
|
|
c8 = 2;
|
|
c9 = 1;
|
|
const obj10 = { value: getFilterImageDefault(videoFilterAssetURL), done: false };
|
|
return obj10;
|
|
}
|
|
}
|
|
}
|
|
const tmp21 = getDefaultBackgroundDataDefault()[closure_2];
|
|
const isVideo = tmp21.isVideo;
|
|
let c3 = isVideo;
|
|
if (isVideo == null) {
|
|
c3 = false;
|
|
}
|
|
closure_3 = c3;
|
|
source = tmp21.source;
|
|
isAnimatedIconHashResult = c3;
|
|
videoFilterAssetURL = source;
|
|
}
|
|
}
|
|
} else if (1 === c8) {
|
|
c7 = 0;
|
|
const obj3 = closure_133_0(closure_133_2[5]);
|
|
const result = obj3.errorApplyingMediaFilterSettings();
|
|
} else if (2 === c8) {
|
|
if (arg0 === 1) {
|
|
c9 = 3;
|
|
throw value;
|
|
} else {
|
|
tmp6 = value;
|
|
if (arg0 === 2) {
|
|
c7 = 0;
|
|
c9 = 3;
|
|
const obj17 = { value, done: true };
|
|
return obj17;
|
|
}
|
|
}
|
|
} else if (arg0 === 1) {
|
|
c9 = 3;
|
|
throw value;
|
|
} else {
|
|
tmp5 = value;
|
|
if (arg0 === 2) {
|
|
c7 = 0;
|
|
c9 = 3;
|
|
obj = { value, done: true };
|
|
return obj;
|
|
}
|
|
}
|
|
c9 = 3;
|
|
return { value: "IconComponent", done: null };
|
|
} catch (tmp47) {
|
|
let closure_6 = tmp47;
|
|
if (0 === c7) {
|
|
c9 = 3;
|
|
throw tmp47;
|
|
} else {
|
|
c8 = 1;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
return obj(...arguments);
|
|
};
|
|
function applyBackgroundOptionLive() {
|
|
return obj(...arguments);
|
|
}
|
|
obj = function _applyBackgroundOptionLive() {
|
|
obj = _asyncToGenerator(async (arg0, arg1) => {
|
|
let closure_0 = arg0;
|
|
const track = arg1;
|
|
let c4 = 0;
|
|
let c5 = 0;
|
|
const iter = (async (arg0, value) => {
|
|
if (c5 === 2) {
|
|
c5 = 3;
|
|
throw new TypeError("Generator functions may not be called on executing generators");
|
|
} else if (tmp3 === 3) {
|
|
if (arg0 === 1) {
|
|
throw value;
|
|
} else if (arg0 === 2) {
|
|
return { value, done: true };
|
|
} else {
|
|
return { value: "IconComponent", done: null };
|
|
}
|
|
} else {
|
|
try {
|
|
let location;
|
|
let flag;
|
|
c5 = 2;
|
|
if (0 === c4) {
|
|
if (arg0 === 1) {
|
|
c5 = 3;
|
|
throw value;
|
|
} else if (arg0 === 2) {
|
|
c5 = 3;
|
|
return { value, done: true };
|
|
} else {
|
|
closure_3 = tmp4;
|
|
closure_2 = tmp;
|
|
location = undefined;
|
|
flag = track.track;
|
|
const tmp14 = track;
|
|
if (flag === undefined) {
|
|
flag = true;
|
|
}
|
|
location = tmp14.location;
|
|
c4 = 1;
|
|
c5 = 1;
|
|
return { value: "Reflect", done: null };
|
|
}
|
|
} else if (1 === c4) {
|
|
if (arg0 === 1) {
|
|
c5 = 3;
|
|
throw value;
|
|
} else if (arg0 === 2) {
|
|
c5 = 3;
|
|
return { value, done: true };
|
|
} else {
|
|
const obj5 = { type: closure_131_0(closure_131_2[6]).FilterTargetType.INPUT_DEVICE };
|
|
const CAMERA_BACKGROUND_LIVE = closure_131_0(closure_131_2[6]).FilterSettingsKey.CAMERA_BACKGROUND_LIVE;
|
|
c4 = 2;
|
|
c5 = 1;
|
|
const obj6 = { value: closure_131_11(CAMERA_BACKGROUND_LIVE, obj5, closure_0), done: false };
|
|
return obj6;
|
|
}
|
|
} else if (arg0 === 1) {
|
|
c5 = 3;
|
|
throw value;
|
|
} else if (arg0 === 2) {
|
|
c5 = 3;
|
|
return { value, done: true };
|
|
} else {
|
|
const tmp6 = flag;
|
|
if (tmp6) {
|
|
obj = closure_131_0(closure_131_2[10]);
|
|
const result = obj.trackBackgroundOptionUpdated(closure_0, location, "Enabled");
|
|
}
|
|
c5 = 3;
|
|
return { value: "IconComponent", done: null };
|
|
}
|
|
} catch (tmp15) {
|
|
c5 = 3;
|
|
throw tmp15;
|
|
}
|
|
}
|
|
})();
|
|
iter.next();
|
|
return iter;
|
|
});
|
|
return obj(...arguments);
|
|
};
|
|
obj = function _applyBackgroundOptionPreview() {
|
|
obj = _asyncToGenerator(async (arg0, streamId, arg2) => {
|
|
let closure_0 = arg0;
|
|
const track = arg2;
|
|
let c5 = 0;
|
|
let c6 = 0;
|
|
const iter = (async (arg0, value, arg2) => {
|
|
if (c6 === 2) {
|
|
c6 = 3;
|
|
throw new TypeError("Generator functions may not be called on executing generators");
|
|
} else if (tmp3 === 3) {
|
|
if (arg0 === 1) {
|
|
throw value;
|
|
} else if (arg0 === 2) {
|
|
return { value, done: true };
|
|
} else {
|
|
return { value: "IconComponent", done: null };
|
|
}
|
|
} else {
|
|
try {
|
|
let location;
|
|
let flag;
|
|
c6 = 2;
|
|
if (0 === c5) {
|
|
if (arg0 === 1) {
|
|
c6 = 3;
|
|
throw value;
|
|
} else if (arg0 === 2) {
|
|
c6 = 3;
|
|
return { value, done: true };
|
|
} else {
|
|
closure_4 = tmp4;
|
|
closure_3 = tmp;
|
|
location = undefined;
|
|
flag = track.track;
|
|
const tmp15 = track;
|
|
if (flag === undefined) {
|
|
flag = true;
|
|
}
|
|
location = tmp15.location;
|
|
c5 = 1;
|
|
c6 = 1;
|
|
return { value: "Reflect", done: null };
|
|
}
|
|
} else if (1 === c5) {
|
|
if (arg0 === 1) {
|
|
c6 = 3;
|
|
throw value;
|
|
} else if (arg0 === 2) {
|
|
c6 = 3;
|
|
return { value, done: true };
|
|
} else {
|
|
const obj7 = closure_132_0(closure_132_2[5]);
|
|
const result = obj7.startApplyMediaFilterSettings();
|
|
const obj5 = { type: closure_132_0(closure_132_2[6]).FilterTargetType.STREAM, streamId };
|
|
const CAMERA_BACKGROUND_PREVIEW = closure_132_0(closure_132_2[6]).FilterSettingsKey.CAMERA_BACKGROUND_PREVIEW;
|
|
c5 = 2;
|
|
c6 = 1;
|
|
const obj6 = { value: closure_132_11(CAMERA_BACKGROUND_PREVIEW, obj5, closure_0), done: false };
|
|
return obj6;
|
|
}
|
|
} else if (arg0 === 1) {
|
|
c6 = 3;
|
|
throw value;
|
|
} else if (arg0 === 2) {
|
|
c6 = 3;
|
|
return { value, done: true };
|
|
} else {
|
|
const tmp6 = flag;
|
|
if (tmp6) {
|
|
obj = closure_132_0(closure_132_2[10]);
|
|
const result1 = obj.trackBackgroundOptionUpdated(closure_0, location, "Preview");
|
|
}
|
|
c6 = 3;
|
|
return { value: "IconComponent", done: null };
|
|
}
|
|
} catch (tmp16) {
|
|
c6 = 3;
|
|
throw tmp16;
|
|
}
|
|
}
|
|
})();
|
|
iter.next();
|
|
return iter;
|
|
});
|
|
return obj(...arguments);
|
|
};
|
|
({ BACKGROUND_REPLACEMENT_SIZE: metroRequire, BLUR_BACKGROUND_OPTION: metroImportDefault } = VideoBackgroundConstants);
|
|
const NOOP = Constants.NOOP;
|
|
let result = size.fileFinishedImporting("modules/video_backgrounds/applyBackgroundOption.tsx");
|
|
|
|
export { applyBackgroundOptionLive };
|
|
export const applyBackgroundOptionPreview = function applyBackgroundOptionPreview() {
|
|
return obj(...arguments);
|
|
};
|
|
export const applyInitialVideoBackgroundOption = function applyInitialVideoBackgroundOption() {
|
|
const currentUser = UserStore.getCurrentUser();
|
|
if (null != currentUser) {
|
|
obj = LastUsedVideoBackgroundOption;
|
|
const lastUsedVideoBackgroundOption = obj.getLastUsedVideoBackgroundOption(currentUser);
|
|
const tmp6 = isVideoBackgroundEnabledDefault("applyBackgroundOption") && !VideoBackgroundStore.hasBeenApplied && null != lastUsedVideoBackgroundOption;
|
|
if (tmp6) {
|
|
const promise = applyBackgroundOptionLive(lastUsedVideoBackgroundOption, { track: false });
|
|
promise.catch(NOOP);
|
|
}
|
|
}
|
|
};
|