319 lines
15 KiB
TypeScript
319 lines
15 KiB
TypeScript
/* Metro module 4643; source: modules/stickers/StickersUtils.tsx; dependencies: [1348, 1867, 4644, 4784, 3832, 661, 4785, 1423, 1853, 477, 1457, 4787, 2] */
|
|
function _fun39922(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#39922, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4821:6, offset: 0x010f00f8, size: 776 bytes, params: 8, frame: 34
|
|
let env0_0 = require;
|
|
const closure = getFavoriteStickerIds;
|
|
let Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const userSettingsProtoStore = importDefault(1348) /* metro dependency 1348: UserSettingsProtoStore */;
|
|
const guildStore = importDefault(1867) /* metro dependency 1867: GuildStore */;
|
|
const uploadAttachmentStore = importDefault(4644) /* metro dependency 4644: UploadAttachmentStore */;
|
|
const stickerMessagePreviewStore = importDefault(4784) /* metro dependency 4784: StickerMessagePreviewStore */;
|
|
let value = require(3832) /* metro dependency 3832: StickersConstants */;
|
|
const env0_6 = value.DEFAULT_STICKER_DIMENSIONS;
|
|
const env0_7 = value.STICKER_APPLICATION_ID;
|
|
const env0_8 = value.StickerAnimationSettings;
|
|
const Endpoints = (require(661) /* metro dependency 661: Constants */).Endpoints;
|
|
const GLOBAL_ENV = global.window.GLOBAL_ENV;
|
|
const API_ENDPOINT = GLOBAL_ENV.API_ENDPOINT;
|
|
const MEDIA_PROXY_ENDPOINT = GLOBAL_ENV.MEDIA_PROXY_ENDPOINT;
|
|
const env0_12 = GLOBAL_ENV.PROJECT_ENV;
|
|
const ASSET_ENDPOINT = GLOBAL_ENV.ASSET_ENDPOINT;
|
|
const env0_14 = GLOBAL_ENV.CDN_HOST;
|
|
Object = global.Object;
|
|
const values = Object.values;
|
|
const StickerExtensions = (require(4785) /* metro dependency 4785: StickersTypes */).StickerExtensions;
|
|
value = Reflect.apply(values, Object, [StickerExtensions]);
|
|
const decodeURIComponent = global.decodeURIComponent;
|
|
const STICKER_ASSET = Endpoints.STICKER_ASSET;
|
|
value = value.join('|');
|
|
value = '(' + value + ')';
|
|
value = decodeURIComponent(Reflect.apply(STICKER_ASSET, Endpoints, ['[\\d]+', value]));
|
|
let RegExp = global.RegExp;
|
|
let regExp = new RegExp('(' + global.location.protocol + ASSET_ENDPOINT + '|' + global.location.protocol + MEDIA_PROXY_ENDPOINT + ')(' + value + ')',
|
|
'ig');
|
|
RegExp = global.RegExp;
|
|
value = '' + global.location.protocol + API_ENDPOINT + '(' + value + ')';
|
|
regExp = new RegExp(value, 'ig');
|
|
const closure2 = function(a0) {
|
|
var env0_0 = a0;
|
|
if (a0.cover_sticker_id != null) {
|
|
var value = a0.stickers.find(_fun39925);
|
|
if (value != null) {
|
|
return value;
|
|
}
|
|
}
|
|
return a0.stickers[0];
|
|
};
|
|
const closure3 = getStickerExtensionFromFormatType;
|
|
const env0_19 = [];
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/stickers/StickersUtils.tsx');
|
|
exports.getStickerPackPreviewSticker = closure2;
|
|
exports.getStickerExtensionFromFormatType = closure3;
|
|
exports.getStickerFormatTypeFromFileType = getStickerFormatTypeFromFileType;
|
|
exports.getFilenameForSticker = getFilenameForSticker;
|
|
exports.getStickerAssetUrl = getStickerAssetUrl;
|
|
exports.getStickerPackBannerAssetUrl = getStickerPackBannerAssetUrl;
|
|
exports.isStickerAssetUrl = isStickerAssetUrl;
|
|
exports.isStickerPackAnimated = function({stickers}) {
|
|
return stickers.some(_fun39933);
|
|
};
|
|
exports.createStickerPackCategory = function(a0) {
|
|
var object = {};
|
|
object.type = require(dependencyMap[6]).StickerCategoryTypes.PACK;
|
|
object.id = a0.id;
|
|
object.name = a0.name;
|
|
object.stickers = a0.stickers;
|
|
object.previewSticker = getStickerPackPreviewSticker(a0);
|
|
return object;
|
|
};
|
|
exports.shouldAnimateSticker = function(a0, a1) {
|
|
return a0 === StickerAnimationSettings.ANIMATE_ON_INTERACTION ? a1 : a0 !== StickerAnimationSettings.NEVER_ANIMATE;
|
|
};
|
|
exports.shouldAttachSticker = shouldAttachSticker;
|
|
exports.isGuildSticker = function({type}) {
|
|
return type === require(dependencyMap[6]).MetaStickerType.GUILD;
|
|
};
|
|
exports.isStandardSticker = function({type}) {
|
|
return type === require(dependencyMap[6]).MetaStickerType.STANDARD;
|
|
};
|
|
exports.getMessageStickers = function(a0) {
|
|
return a0.stickerItems.length > 0 ? a0.stickerItems : a0.stickers.length > 0 ? a0.stickers : [];
|
|
};
|
|
exports.isAvailableGuildSticker = isAvailableGuildSticker;
|
|
exports.getFavoriteStickerIds = closure;
|
|
exports.isFavoriteSticker = isFavoriteSticker;
|
|
}
|
|
|
|
function getFavoriteStickerIds() { // fn#39923, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4821:1206, offset: 0x010f0400, size: 46 bytes, params: 1, frame: 5
|
|
return UserSettingsProtoStore.frecencyWithoutFetchingLatest.favoriteStickers?.stickerIds ?? env0_19;
|
|
}
|
|
|
|
function getStickerPackPreviewSticker(a0) { // fn#39924, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4821:633, offset: 0x010f042e, size: 63 bytes, params: 2, frame: 13
|
|
const env0_0 = a0;
|
|
if (a0.cover_sticker_id != null) {
|
|
var value = a0.stickers.find(_fun39925);
|
|
if (value != null) {
|
|
return value;
|
|
}
|
|
}
|
|
return a0.stickers[0];
|
|
}
|
|
|
|
function getStickerExtensionFromFormatType(a0) { // fn#39926, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4821:796, offset: 0x010f0488, size: 362 bytes, params: 2, frame: 15
|
|
const StickerExtensions = (require(4785) /* metro dependency 4785: StickersTypes */).StickerExtensions;
|
|
const StickerFormat = (require(4785) /* metro dependency 4785: StickersTypes */).StickerFormat;
|
|
const PNG = StickerFormat.PNG;
|
|
if (PNG === a0) {
|
|
return (require(1423) /* metro dependency 1423: AvatarUtils */).SUPPORTS_WEBP ? StickerExtensions.WEBP : StickerExtensions.PNG;
|
|
}
|
|
const APNG = StickerFormat.APNG;
|
|
if (APNG === a0) {
|
|
return StickerExtensions.APNG;
|
|
}
|
|
const LOTTIE = StickerFormat.LOTTIE;
|
|
if (LOTTIE === a0) {
|
|
return StickerExtensions.LOTTIE;
|
|
}
|
|
const GIF = StickerFormat.GIF;
|
|
if (GIF === a0) {
|
|
return StickerExtensions.GIF;
|
|
}
|
|
const Error = global.Error;
|
|
const value = 'Unexpected format type: ' + a0;
|
|
const value2 = Object.create(Error.prototype, {constructor: {value: Error}});
|
|
const error = new Error();
|
|
throw error instanceof Object ? error : value2;
|
|
}
|
|
|
|
function getStickerFormatTypeFromFileType(a0) { // fn#39927, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4821:1581, offset: 0x010f05f2, size: 265 bytes, params: 2, frame: 12
|
|
const StickerFormat = (require(4785) /* metro dependency 4785: StickersTypes */).StickerFormat;
|
|
if (a0 === 'application/json') {
|
|
return StickerFormat.LOTTIE;
|
|
}
|
|
if (a0 === 'image/apng') {
|
|
return StickerFormat.APNG;
|
|
}
|
|
if (a0 === 'image/png') {
|
|
return StickerFormat.PNG;
|
|
}
|
|
if (a0 === 'image/webp') {
|
|
return StickerFormat.PNG;
|
|
}
|
|
if (a0 === 'image/gif') {
|
|
return StickerFormat.GIF;
|
|
}
|
|
const Error = global.Error;
|
|
const value = 'Unexpected file type: ' + a0;
|
|
const value2 = Object.create(Error.prototype, {constructor: {value: Error}});
|
|
const error = new Error();
|
|
throw error instanceof Object ? error : value2;
|
|
}
|
|
|
|
function getFilenameForSticker(a0) { // fn#39928, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4821:1900, offset: 0x010f06fb, size: 67 bytes, params: 2, frame: 16
|
|
var r0;
|
|
var name;
|
|
let value = null;
|
|
if (value == a0) {
|
|
r0 = value;
|
|
} else {
|
|
name = a0.name;
|
|
value = getStickerExtensionFromFormatType(a0.format_type);
|
|
value = '' + name + '.' + value;
|
|
r0 = value;
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function getStickerAssetUrl(a0) { // fn#39929, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4821:2001, offset: 0x010f073e, size: 729 bytes, params: 2, frame: 33
|
|
var enabled;
|
|
var r12;
|
|
var property;
|
|
var moduleValue;
|
|
var getForceSdrEmojisStickersConfig;
|
|
var forceSdrEmojisStickersConfig;
|
|
var error;
|
|
var protocol;
|
|
var moduleValue2;
|
|
var Math;
|
|
var value12;
|
|
let value = a1;
|
|
let r0 = value !== undefined ? value : {};
|
|
let isPreview = r0.isPreview;
|
|
isPreview = !(isPreview === undefined) && isPreview;
|
|
const size = r0.size;
|
|
r0 = size !== undefined ? size : DEFAULT_STICKER_DIMENSIONS;
|
|
let format_type = a0.format_type;
|
|
if (format_type == null) {
|
|
return null;
|
|
}
|
|
format_type = a0.format_type;
|
|
const format_type2 = a0.format_type;
|
|
const StickerFormat = require(dependencyMap[6]).StickerFormat;
|
|
const GIF = StickerFormat.GIF;
|
|
let r13 = format_type2 === GIF && isPreview;
|
|
const stickerExtensionFromFormatType = getStickerExtensionFromFormatType(r13 ? StickerFormat.PNG : format_type);
|
|
const value4 = Endpoints.STICKER_ASSET(a0.id, stickerExtensionFromFormatType);
|
|
try {
|
|
property = dependencyMap[8];
|
|
moduleValue = require(property);
|
|
getForceSdrEmojisStickersConfig = moduleValue.getForceSdrEmojisStickersConfig;
|
|
forceSdrEmojisStickersConfig = getForceSdrEmojisStickersConfig({location: 'sticker_url'});
|
|
enabled = forceSdrEmojisStickersConfig.enabled;
|
|
} catch (error) {
|
|
enabled = false;
|
|
}
|
|
const value7 = '';
|
|
r13 = enabled ? '&force_sdr=true' : value7;
|
|
const StickerExtensions = require(dependencyMap[6]).StickerExtensions;
|
|
const WEBP = StickerExtensions.WEBP;
|
|
if (PROJECT_ENV !== 'development') {
|
|
format_type = a0.format_type;
|
|
if (format_type === StickerFormat.LOTTIE) {
|
|
return value7 + global.location.protocol + ASSET_ENDPOINT + value4;
|
|
}
|
|
format_type = a0.format_type;
|
|
if (format_type !== StickerFormat.APNG) {
|
|
r12 = value7;
|
|
} else if (isPreview) {
|
|
moduleValue2 = require(dependencyMap[9]);
|
|
r12 = moduleValue2.isAndroid() ? value7 : '&passthrough=false';
|
|
} else {
|
|
r12 = value7;
|
|
}
|
|
Math = global.Math;
|
|
value12 = Math.min(2, require(dependencyMap[10]).getDevicePixelRatio());
|
|
protocol = global.location.protocol;
|
|
value = require(dependencyMap[10]);
|
|
value = value.getBestMediaProxySize(r0 * value12);
|
|
return value7 + protocol + MEDIA_PROXY_ENDPOINT + value4 + '?size=' + value + r12 + (stickerExtensionFromFormatType !== WEBP ? value7 : '&quality=lossless') + r13;
|
|
}
|
|
value = value7 + global.location.protocol + MEDIA_PROXY_ENDPOINT + value4;
|
|
return enabled ? value7 + value + '?force_sdr=true' : value;
|
|
}
|
|
|
|
function getStickerPackBannerAssetUrl({banner_asset_id}, a1) { // fn#39930, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4821:2869, offset: 0x010f0a17, size: 261 bytes, params: 3, frame: 28
|
|
var r1;
|
|
if (banner_asset_id == null) {
|
|
return null;
|
|
}
|
|
var value;
|
|
const SUPPORTS_WEBP = (require(1423) /* metro dependency 1423: AvatarUtils */).SUPPORTS_WEBP;
|
|
const r12 = SUPPORTS_WEBP ? 'webp' : 'png';
|
|
const r3 = CDN_HOST != null ? 'https://' + CDN_HOST + '/app-assets/' + STICKER_APPLICATION_ID + '/store/' + banner_asset_id + '.' + r12 : '' + global.location.protocol + API_ENDPOINT + Endpoints.STORE_ASSET(STICKER_APPLICATION_ID,
|
|
banner_asset_id, r12);
|
|
if (a1 == null) {
|
|
r1 = r3;
|
|
} else {
|
|
value = require(1457) /* metro dependency 1457: ImageLoaderUtils */;
|
|
value = value.getBestMediaProxySize(a1);
|
|
value = r3 + ('?size=' + value);
|
|
r1 = value;
|
|
}
|
|
return r1;
|
|
}
|
|
|
|
function isStickerAssetUrl(a0) { // fn#39931, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4821:3163, offset: 0x010f0b1c, size: 49 bytes, params: 2, frame: 13
|
|
return a0.match(PROJECT_ENV !== 'development' ? env0_15 : env0_16) != null;
|
|
}
|
|
|
|
function isStickerPackAnimated({stickers}) { // fn#39932, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4821:3227, offset: 0x010f0b4d, size: 29 bytes, params: 2, frame: 11
|
|
return stickers.some(_fun39933);
|
|
}
|
|
|
|
function shouldAttachSticker(a0, a1, a2, a3) { // fn#39936, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4821:3628, offset: 0x010f0c68, size: 253 bytes, params: 5, frame: 17
|
|
const StickerSelectLocation = (require(4785) /* metro dependency 4785: StickersTypes */).StickerSelectLocation;
|
|
var value;
|
|
if (UploadAttachmentStore.getUploadCount(a2, a3) > 0) {
|
|
return true;
|
|
}
|
|
const stickerPreview = StickerMessagePreviewStore.getStickerPreview(a2, a3);
|
|
if (stickerPreview == null) {
|
|
if (StickerSelectLocation.STICKER_PICKER === a0) {
|
|
return a1.trim() !== '';
|
|
}
|
|
if (StickerSelectLocation.AUTOCOMPLETE === a0) {
|
|
value = require(4787) /* metro dependency 4787: StickersSuggestionUtils */;
|
|
return value.getQueriesFromUserInput(a1).length > 1;
|
|
}
|
|
StickerSelectLocation.BUILT_IN_INTEGRATION;
|
|
} else {
|
|
if (stickerPreview.length > 0) {
|
|
return true;
|
|
}
|
|
if (StickerSelectLocation.STICKER_PICKER === a0) {
|
|
return a1.trim() !== '';
|
|
}
|
|
if (StickerSelectLocation.AUTOCOMPLETE === a0) {
|
|
value = require(4787) /* metro dependency 4787: StickersSuggestionUtils */;
|
|
return value.getQueriesFromUserInput(a1).length > 1;
|
|
}
|
|
StickerSelectLocation.BUILT_IN_INTEGRATION;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function isAvailableGuildSticker(a0) { // fn#39940, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4821:4241, offset: 0x010f0e04, size: 44 bytes, params: 2, frame: 11
|
|
if (a0 === null) {
|
|
return false;
|
|
}
|
|
return GuildStore.getGuild(a0.guild_id) !== undefined;
|
|
}
|
|
|
|
function isFavoriteSticker(a0) { // fn#39941, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4821:4380, offset: 0x010f0e30, size: 28 bytes, params: 2, frame: 11
|
|
return getFavoriteStickerIds().includes(a0);
|
|
}
|
|
|
|
function _fun39925({id}) { // fn#39925, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4821:689, offset: 0x010f046d, size: 27 bytes, params: 2, frame: 2
|
|
return id === env0_0.cover_sticker_id;
|
|
}
|
|
|
|
function _fun39933({format_type}) { // fn#39933, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4821:3247, offset: 0x010f0b6a, size: 124 bytes, params: 2, frame: 15
|
|
const value = environment.__proto__;
|
|
const StickerFormat = (require(4785) /* metro dependency 4785: StickersTypes */).StickerFormat;
|
|
const APNG = StickerFormat.APNG;
|
|
let r0 = format_type === APNG || format_type === StickerFormat.LOTTIE;
|
|
r0 = !r0 ? format_type === StickerFormat.GIF : r0;
|
|
return r0;
|
|
}
|
|
|