This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,69 @@
// Metro module 1848 (f1849).
let c1559_0 = [128, 192, 256, 320, 384, 512, 640, 768, 1024, 1280, 1536, 2048, 3072, 4096];
export { c1559_0 as ATTACHMENT_LADDER };
export function snapAttachmentDimensions({ targetWidth, targetHeight, sourceWidth, sourceHeight, maxUpscale }) {
let r28;
let r8 = void 0;
const r30 = Math.max(targetWidth, targetHeight);
let c13260_0 = r30;
if (r30 <= 0) {
return {
width: targetWidth,
height: targetHeight
};
}
let r10 = c1559_0.find((item) => c13260_0 <= item);
if (r10 == null) {
r10 = c1559_0[c1559_0.length - 1];
}
let r38 = r10;
if (maxUpscale != null) {
r38 = r10;
if (maxUpscale > 1) {
let r11 = c1559_0[Symbol.iterator]();
const next = r11.next;
while (true) {
const r43 = r11 === void 0 ? void 0 : (r28 = next.call(r11)).done ? r11 = void 0 : r28.value;
if (r11 !== void 0) {
try {
if (r43 <= r30) {
r8 = r43;
continue;
}
} catch (r46) {
if (r11 !== void 0 && typeof r11.return === "function") {
try {
r11.return();
} catch {}
}
throw r46;
}
const r45 = r11;
if (r45 !== void 0 && typeof r45.return === "function") {
r45.return();
}
}
const r48 = r8 != null && r30 <= r8 * maxUpscale;
r38 = r10;
if (!r48) {
break;
}
r38 = r8;
break;
}
}
}
if (sourceWidth != null && sourceHeight != null && Math.max(sourceWidth, sourceHeight) <= r38) {
return {
width: sourceWidth,
height: sourceHeight
};
}
const r54 = r38 / r30;
const r62 = Math.max(1, Math.round(targetWidth * r54));
const r69 = Math.max(1, Math.round(targetHeight * r54));
return {
width: sourceWidth != null ? Math.min(r62, sourceWidth) : r62,
height: sourceHeight != null ? Math.min(r69, sourceHeight) : r69
};
}
@@ -0,0 +1,23 @@
// Metro module 1451 (f1452).
import { createApexExperiment } from "../experiments/apex/index";
const apexExperiment = createApexExperiment({
name: "2026-07-attachment-image-ladder",
kind: "user",
defaultConfig: {
enabled: false
},
variations: {
0: {
enabled: false
},
1: {
enabled: true
}
}
});
export default apexExperiment;
export function getAttachmentImageLadderConfig(a0) {
return apexExperiment.getConfig({
location: a0.location
});
}
@@ -0,0 +1,22 @@
// Metro module 1850 (f1851).
import { createApexExperiment } from "../experiments/apex/index";
const apexExperiment = createApexExperiment({
kind: "user",
name: "2025-10-force-sdr-emojis-stickers",
defaultConfig: {
enabled: false
},
variations: {
0: {
enabled: false
},
1: {
enabled: true
}
}
});
export function getForceSdrEmojisStickersConfig(a0) {
return apexExperiment.getConfig({
location: a0.location
});
}
+331
View File
@@ -0,0 +1,331 @@
// Metro module 1450 (f1451).
import _slicedToArray from "../../_bundle/_slicedToArray";
import { MEDIA_PROXY_MAX_TARGET_RESOLUTION, NOOP } from "../../Constants";
import { getAttachmentImageLadderConfig } from "./AttachmentImageLadderExperiment";
import LRUCache from "../../_bundle/LRUCache";
import Backoff from "../../_bundle/Backoff";
import NetworkUtils from "../../utils/NetworkUtils";
import Module1464 from "../../_bundle/Module1464";
import URLUtils from "../../utils/URLUtils";
import { fit } from "../../utils/ImageUtils";
import * as _AttachmentImageLadder from "./AttachmentImageLadder";
import Module12 from "../../_bundle/Module12";
import getDevicePixelRatio_native from "../../utils/getDevicePixelRatio.native";
function $mk69196($env) {
return () => {
const r2 = $env;
const r5 = r2[0];
const backoff = r5.backoff;
if (backoff != null) {
backoff.succeed();
}
let env24405;
const r9 = r2[1];
const r10 = env24405 = {};
env24405[0] = false;
env24405[1] = r5;
const { callbacks, url: url2 } = r5;
const r6 = {
url: url2,
loaded: true,
width: r9.width,
height: r9.height
};
env24405[1] = r6;
$env.$parent[11].set(url2, r6);
if (callbacks != null) {
callbacks.forEach($mk69197(r10));
}
};
}
function $mk69197($env) {
return (a0) => {
const r2 = $env;
return a0(r2[0], r2[1]);
};
}
function $mk102182($env) {
return async () => {
let env28884 = {
$parent: $env
};
env28884[2] = 0;
env28884[3] = 0;
const r8 = env28884.$parent;
env28884[1] = r8;
env28884[0] = r8;
const r23 = r8.$parent;
await (0, r23[1])(r23[2][6]).isOnline();
if (env28884[1][2].fails < 5) {
env28884[1][2].fail($mk117672(env28884[0]));
} else {
const r52 = env28884[1];
(0, r52.$parent[12])(true, r52[0], r52[1]);
}
};
}
function $mk117672($env) {
return () => {
let env31890;
let env31891;
const r6 = $env.$parent;
const r11 = $env[0];
const r4 = env31890 = {
$parent: r6
};
env31890[0] = r11;
const image = new Image();
env31890[1] = image;
const r15 = env31891 = {
$parent: r6
};
env31891[0] = r11;
env31891[1] = image;
env31891[2] = void 0;
if (r11.backoff == null) {
r11.backoff = new ((0, r6[1])(r6[2][5]))();
}
env31891[2] = r11.backoff;
image.onerror = (0, r6[4])($mk102182(r15));
image.onload = $mk69196(r4);
image.src = r11.url;
};
}
let handleImageLoad, getSrcWithWidthAndHeight, c1174_8, c1174_9, c1174_10, c1174_11;
let env1174 = {};
const isAttachmentLadderEnabled = function isAttachmentLadderEnabled(a0) {
let enabled;
try {
enabled = (0, getAttachmentImageLadderConfig)({
location: a0
}).enabled;
} catch ($e) {
return false;
}
return enabled === true;
};
handleImageLoad = function handleImageLoad(a0, a1, a2) {
let env13032;
const r1 = env13032 = {};
env13032[0] = true;
env13032[1] = a1;
const callbacks = a1.callbacks;
c1174_11.del(a1.url);
if (callbacks != null) {
callbacks.forEach($mk69197(r1));
}
};
getSrcWithWidthAndHeight = function getSrcWithWidthAndHeight(a0) {
const { src, sourceWidth, sourceHeight, targetWidth, targetHeight, format = null, quality = null } = a0;
let animated = a0.animated;
if (animated === void 0) {
animated = false;
}
let srcIsAnimated = a0.srcIsAnimated;
if (srcIsAnimated === void 0) {
srcIsAnimated = false;
}
if (!src.startsWith("data:image")) {
if (!URLUtils.isDiscordCdnUrl(src)) {
const r31 = _slicedToArray(src.split("?"), 2);
const [r37, r38] = [r31[0], Module1464.parse(r31[1])];
if (format != null) {
r38.format = format;
}
if (quality != null) {
r38.quality = quality;
}
if (animated) {
animated = srcIsAnimated;
}
if (animated) {
animated = c1174_8.test(src) || c1174_9.test(src);
}
if (animated) {
r38.animated = true;
}
if (c1174_9.test(src)) {
r38.format = "webp";
}
const r55 = fit({
width: targetWidth,
height: targetHeight,
maxWidth: MEDIA_PROXY_MAX_TARGET_RESOLUTION,
maxHeight: MEDIA_PROXY_MAX_TARGET_RESOLUTION
});
const { width, height } = r55;
if (!(width === sourceWidth && height === sourceHeight)) {
const r62 = isAttachmentLadderEnabled("ImageLoaderUtils.getSrcWithWidthAndHeight") ? _AttachmentImageLadder.snapAttachmentDimensions({
targetWidth: width,
targetHeight: height,
sourceWidth,
sourceHeight,
maxUpscale: 1.1
}) : {
width,
height
};
if (!(r62.width === sourceWidth && r62.height === sourceHeight)) {
r38.width = r62.width | 0;
r38.height = r62.height | 0;
}
}
return Module12.isEmpty(r38) ? r37 : r37 + ("?" + Module1464.stringify(r38));
}
}
return src;
};
c1174_8 = /\.webp($|\?|#)/i;
c1174_9 = /\.avif($|\?|#)/i;
c1174_10 = [16, 20, 22, 24, 28, 32, 40, 44, 48, 56, 60, 64, 80, 96, 100, 128, 160, 240, 256, 300, 320, 480, 512, 600, 640, 1024, 1280, 1536, 2048, 3072, 4096];
c1174_11 = new LRUCache({
max: 1000
});
export { getDevicePixelRatio_native as getDevicePixelRatio };
export const ATTACHMENT_LADDER = _AttachmentImageLadder.ATTACHMENT_LADDER;
export const snapAttachmentDimensions = _AttachmentImageLadder.snapAttachmentDimensions;
export function isImageLoaded(a0) {
const r5 = c1174_11.get(a0);
return r5 != null && r5.loaded;
}
export function loadImage(a0, a1) {
let NOOP2;
let c13033_1;
const url = a0;
let r15 = c1174_11.get(a0);
let c13033_2 = r15;
if (r15 != null && r15.loaded) {
if (a1 != null) {
NetworkUtils.awaitOnline().then(() => {
if (c13033_2 != null && c13033_2.callbacks != null) {
c13033_2.callbacks.forEach((callback) => {
if (c13033_2 != null) {
callback(false, c13033_2);
} else {
callback(true, {
url,
loaded: true
});
}
});
}
});
}
NOOP2 = NOOP;
} else {
if (r15 == null) {
let env13034;
let env13035;
const r16 = {
url: a0,
loaded: false
};
c13033_2 = r16;
c1174_11.set(a0, r16);
const r18 = env13034 = {
$parent: env1174
};
env13034[0] = r16;
env13034[1] = void 0;
const image = new Image();
env13034[1] = image;
const r24 = env13035 = {
$parent: env1174
};
env13035[0] = r16;
env13035[1] = image;
env13035[2] = void 0;
if (r16.backoff == null) {
r16.backoff = new Backoff();
}
env13035[2] = r16.backoff;
image.onerror = $mk102182(r24);
image.onload = $mk69196(r18);
image.src = r16.url;
r15 = r16;
}
if (a1 != null) {
const r39 = a1.bind(null);
c13033_1 = r39;
if (r15.callbacks == null) {
r15.callbacks = new Set();
}
r15.callbacks.add(r39);
}
NOOP2 = () => {
if (c13033_1 != null && c13033_2 != null) {
if (c13033_2.callbacks != null) {
c13033_2.callbacks.delete(c13033_1);
}
if (c13033_2.backoff != null) {
c13033_2.backoff.cancel();
}
}
};
}
return NOOP2;
}
export function getBestMediaProxySize(a0) {
let r2 = arguments[1];
if (r2 === void 0) {
r2 = false;
}
if (r2) {
const r11 = c1174_10.filter((item) => item <= a0).pop();
if (r11 != null && a0 / r11 <= 1.25) {
return r11;
}
}
let r17 = c1174_10.find((item) => a0 <= item);
if (r17 == null) {
r17 = c1174_10[c1174_10.length - 1];
}
return r17;
}
export { getSrcWithWidthAndHeight };
export function getSizedImageSrc(a0, a1, a2, format = "webp") {
const devicePixelRatio_native = getDevicePixelRatio_native();
const targetWidth = Math.ceil(a1 * devicePixelRatio_native);
const targetHeight = Math.ceil(a2 * devicePixelRatio_native);
const isAttachmentLadderEnabled2 = isAttachmentLadderEnabled("ImageLoaderUtils.getSizedImageSrc");
let r26 = targetHeight;
let r27 = targetWidth;
if (isAttachmentLadderEnabled2) {
const r33 = _AttachmentImageLadder.snapAttachmentDimensions({
targetWidth,
targetHeight
});
r27 = r33.width;
r26 = r33.height;
}
const r40 = _slicedToArray(a0.split("?"), 2);
const r48 = _slicedToArray([r40[0], Module1464.parse(r40[1])], 2);
return `${r48[0]}?${Module1464.stringify({
...r48[1],
width: r27 | 0,
height: r26 | 0,
format
})}`;
}
export function getImageSrc({ src, width, height, maxWidth, maxHeight, ratio = 1, format = null, quality = null, animated = false, srcIsAnimated = false }) {
let r9 = height;
let r10 = width;
if (ratio < 1) {
r10 = Math.round(width * ratio);
r9 = Math.round(height * ratio);
}
const r23 = maxWidth != null ? Math.min(r10, maxWidth) : r10;
const r27 = maxHeight != null ? Math.min(r9, maxHeight) : r9;
const devicePixelRatio_native = getDevicePixelRatio_native();
return getSrcWithWidthAndHeight({
src,
sourceWidth: width,
sourceHeight: height,
targetWidth: r23 * devicePixelRatio_native,
targetHeight: r27 * devicePixelRatio_native,
format,
quality,
animated,
srcIsAnimated
});
}
@@ -0,0 +1,22 @@
// Metro module 4757 (f4758).
import { createApexExperiment } from "../experiments/apex/index";
const apexExperiment = createApexExperiment({
kind: "user",
name: "2025-12-mobile-lossless-image-upload-v2",
defaultConfig: {
enabled: false
},
variations: {
0: {
enabled: false
},
1: {
enabled: true
}
}
});
export function useMobileLosslessImageUploadV2Experiment(a0) {
return apexExperiment.getConfig({
location: a0.location
});
}
@@ -0,0 +1,108 @@
// Metro module 9847 (f9848).
import { useState, useRef, useEffect } from "react";
import { Image as Image2, ScrollView, View } from "react-native";
import { DraftType } from "../../../stores/DraftStore";
import UploadAttachmentStore from "../../../stores/UploadAttachmentStore";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { useStateFromStores } from "../../../_bundle/Module589";
import useWindowDimensions_native from "../../screen/useWindowDimensions.native";
import { useNavigation } from "../../../design/components/Navigator/native/useNavigation.native";
import useSafeAreaInsetsKeyboardAware_native from "../../safe_area/useSafeAreaInsetsKeyboardAware.native";
import useSafeAreaAvoidingInputs_native from "../../safe_area/useSafeAreaAvoidingInputs.native";
import { getRenderHeaderTextButton } from "../../main_tabs_v2/native/shared_components/HeaderShared";
import { intl, t } from "../../../intl/index.native";
import UploadAttachmentActionCreators from "../../../actions/UploadAttachmentActionCreators";
import AddImageDescriptionModalActionCreators from "./AddImageDescriptionModalActionCreators";
import { TextArea } from "../../../design/components/TextInput/native/TextArea.native";
import ModalStackNavigator from "../../main_tabs_v2/native/utils/ModalStackNavigator";
let useStyles;
const AddDescription = function AddDescription(props) {
let state, ref, navigation;
const { source: source2, channelId, id } = props;
state = void 0;
ref = void 0;
navigation = void 0;
const styles = useStyles();
const stateFromStores = useStateFromStores([UploadAttachmentStore], () => UploadAttachmentStore.getUpload(channelId, id, DraftType.ChannelMessage));
const windowDimensions_native = useWindowDimensions_native({
ignoreKeyboard: true
});
const { width, height } = source2;
const aspectRatio = width != null ? height != null ? width !== 0 ? height !== 0 ? width / height : 1 : 1 : 1 : 1;
let r40 = stateFromStores?.description;
if (r40 == null) {
r40 = "";
}
let onChange;
[state, onChange] = useState(r40);
ref = useRef(state);
const ref2 = useRef(null);
const ref3 = useRef(null);
navigation = useNavigation();
const insets = useSafeAreaInsetsKeyboardAware_native({
includeKeyboardHeight: true
}).insets;
useSafeAreaAvoidingInputs_native({
insets,
inputs: [{
ref: ref2,
offset: {
type: "toBottom"
}
}],
scrollViewRef: ref3
});
useEffect(() => {
ref.current = state;
}, [state]);
useEffect(() => {
navigation.setOptions({
headerRight: (a0) => getRenderHeaderTextButton(intl.string(t["R3BPH+"]), () => {
UploadAttachmentActionCreators.update(channelId, id, DraftType.ChannelMessage, {
...stateFromStores,
description: ref.current
});
AddImageDescriptionModalActionCreators.close();
})({
...a0
})
});
}, [channelId, id, stateFromStores, navigation]);
return <ScrollView ref={ref3} style={styles.contentContainer} contentContainerStyle={{
padding: Module712.space.PX_16,
paddingBottom: insets.bottom + Module712.space.PX_16
}}>
<View style={styles.imageContainer}>
<Image2 style={[styles.image, {
aspectRatio,
maxHeight: windowDimensions_native.height / 2
}]} source={source2} />
</View>
<TextArea ref={ref2} containerStyle={{
paddingTop: Module712.space.PX_16
}} label={intl.string(t.eOB2eR)} placeholder={intl.string(t.RNH1jn)} value={state} onChange={onChange} placeholderTextColor={styles.placeholderText.color} maxLength={1000} autoFocus />
</ScrollView>;
};
useStyles = createStyles({
contentContainer: {
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW
},
imageContainer: {
alignItems: "center",
borderRadius: Module712.radii.sm
},
image: {
width: "100%",
resizeMode: "contain",
height: void 0,
borderRadius: Module712.radii.sm
},
placeholderText: {
color: Module712.colors.TEXT_MUTED
}
});
export default function AddImageDescriptionModal(props) {
const { source, channelId: channelId2, id: id2 } = props;
return <ModalStackNavigator screenKey="addImageDescriptionModal" title={intl.string(t["5S2AK+"])} render={() => <AddDescription source={source} channelId={channelId2} id={id2} />} />;
};
@@ -0,0 +1,14 @@
// Metro module 9846 (f9847).
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
import ModalActionCreators from "../../../actions/ModalActionCreators";
let c6538_3 = "ADD_IMAGE_DESCRIPTION_MODAL_KEY";
const r15 = {
open: (a0) => {
ActionSheetActionCreators.hideActionSheet();
ModalActionCreators.pushLazy(import("./AddImageDescriptionModal"), a0, c6538_3);
},
close: () => {
ModalActionCreators.popWithKey(c6538_3);
}
};
export default r15;