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

+65
View File
@@ -0,0 +1,65 @@
// Metro module 5200 (f5201).
import URLUtils from "../../utils/URLUtils";
let c3141_2 = {
"image/avif": "avif",
"image/gif": "gif",
"image/heic": "heic",
"image/jpeg": "jpg",
"image/png": "png",
"image/webp": "webp",
"video/mp4": "mp4",
"video/quicktime": "mov",
"video/webm": "webm"
};
export function decideFileExtension(a0, a1, r6 = false) {
let r4 = void 0;
if (r6) {
const r15 = URLUtils.toURLSafe(a0);
const r3 = r15 == null;
let r9 = void 0;
if (!r3) {
const r18 = r15.searchParams.get("format");
r9 = r18 == null ? void 0 : r18.toLowerCase();
}
r4 = r9 != null ? r9 !== "" ? r9 !== "jpeg" ? r9 : "jpg" : void 0 : void 0;
}
if (r4 == null) {
const r28 = a1 != null;
let r29 = void 0;
if (r28) {
const r31 = a1.toLowerCase();
const r34 = /^(image|video)\//.test(r31);
r29 = void 0;
if (r34) {
r29 = c3141_2[r31];
if (r29 == null) {
const r39 = r31.split("/")[1];
r29 = r39 !== "jpeg" ? r39 ?? void 0 : "jpg";
}
}
}
r4 = r29;
}
if (r4 == null) {
const r49 = URLUtils.toURLSafe(a0);
const r50 = r49 != null;
let r51 = void 0;
if (r50) {
const pathname = r49.pathname;
const r53 = pathname == null;
let r54 = void 0;
if (!r53) {
const r57 = pathname.split(".");
const r58 = r57 == null;
r54 = void 0;
if (!r58) {
const r60 = r57.pop();
r54 = r60 == null ? void 0 : r60.toLowerCase();
}
}
r51 = r54 != null ? r54.length <= 5 ? r54 : void 0 : void 0;
}
r4 = r51;
}
return r4;
}
+40
View File
@@ -0,0 +1,40 @@
// Metro module 11065 (f11066).
import { AnalyticEvents } from "../../Constants";
import AnalyticsUtils from "../../utils/AnalyticsUtils";
export function logMediaAttachmentPlaybackStarted(a0, a1, a2, a3, a4, a5) {
let r10 = a2;
const MEDIA_ATTACHMENT_PLAYBACK_STARTED = AnalyticEvents.MEDIA_ATTACHMENT_PLAYBACK_STARTED;
const r24 = Math;
if (a2 == null) {
r10 = a4;
}
AnalyticsUtils.track(MEDIA_ATTACHMENT_PLAYBACK_STARTED, {
guild_id: a0.guild_id,
channel_id: a0.id,
channel_type: a0.type,
type: a1.content_type,
flags: a1.flags,
size: a1.size,
duration: a2,
message_id: a3,
attachment_id: a1.id,
start_duration_secs: r24.min(r10, a4),
sender_user_id: a5
});
}
export function logMediaAttachmentPlaybackEnded(a0, a1, a2, a3, a4, a5) {
let r12 = a1;
const MEDIA_ATTACHMENT_PLAYBACK_ENDED = AnalyticEvents.MEDIA_ATTACHMENT_PLAYBACK_ENDED;
const r10 = Math;
if (a1 == null) {
r12 = a2;
}
AnalyticsUtils.track(MEDIA_ATTACHMENT_PLAYBACK_ENDED, {
message_id: a0,
total_duration_secs: a1,
end_duration_secs: r10.min(r12, a2),
sender_user_id: a3,
duration_listening_secs: a4,
type: a5.content_type
});
}
+149
View File
@@ -0,0 +1,149 @@
// Metro module 4416 (f4417).
import { MessageAttachmentFlags } from "../../Constants";
import { hasFlag } from "../../_bundle/Module1384";
import { UnfurledMediaLoadingState } from "../../flow/Server";
import { isImageContentType, isVideoContentType, isImageFile, isVideoFile } from "../messages/MediaFormatTesters";
import URLUtils from "../../utils/URLUtils";
let c2643_4, c2643_5;
const messageAttachmentToUnfurledMediaItem = function messageAttachmentToUnfurledMediaItem(a0) {
let flags = a0.flags;
if (flags == null) {
flags = 0;
}
const flags3 = hasFlag(flags, MessageAttachmentFlags.CONTAINS_EXPLICIT_MEDIA) ? c2643_4.EXPLICIT | 0 : 0;
let flags2 = a0.flags;
if (flags2 == null) {
flags2 = 0;
}
return {
url: a0.url,
proxyUrl: a0.proxy_url,
height: a0.height,
width: a0.width,
contentType: a0.content_type,
originalContentType: a0.original_content_type,
placeholder: a0.placeholder,
placeholderVersion: a0.placeholder_version,
loadingState: UnfurledMediaLoadingState.LOADED_SUCCESS,
contentScanMetadata: a0.content_scan_version == null ? void 0 : {
version: a0.content_scan_version,
flags: flags3
},
flags: hasFlag(flags2, MessageAttachmentFlags.IS_ANIMATED) ? c2643_5.IS_ANIMATED | 0 : 0
};
};
c2643_4 = {
EXPLICIT: 1,
1: "EXPLICIT",
GORE: 2,
2: "GORE",
SELF_HARM: 4,
4: "SELF_HARM"
};
const r23 = {
NATIVE: "native",
JPEGLI: "jpegli",
JPEG_IOS: "jpeg_ios",
PASSTHROUGH: "passthrough"
};
c2643_5 = {
IS_ANIMATED: 1,
1: "IS_ANIMATED"
};
export { c2643_4 as ContentScanFlags };
export { r23 as ImageEncoder };
export function toContentScanMetadata(a0) {
return {
version: a0.version,
flags: a0.flags
};
}
export { c2643_5 as UnfurledMediaItemFlags };
export function toUnfurledMediaItem(a0) {
const r2 = a0.content_scan_metadata != null;
let contentScanMetadata = void 0;
if (r2) {
const content_scan_metadata = a0.content_scan_metadata;
contentScanMetadata = {
version: content_scan_metadata.version,
flags: content_scan_metadata.flags
};
}
let flags = a0.flags;
if (flags == null) {
flags = 0;
}
return {
url: a0.url,
proxyUrl: a0.proxy_url,
height: a0.height,
width: a0.width,
placeholder: a0.placeholder,
placeholderVersion: a0.placeholder_version,
contentType: a0.content_type,
originalContentType: a0.original_content_type,
loadingState: a0.loading_state,
contentScanMetadata,
flags
};
}
export { messageAttachmentToUnfurledMediaItem };
export function getUnfurledMediaItemType(a0) {
return isImageContentType(a0.contentType) ? "IMAGE" : isVideoContentType(a0.contentType) ? a0.proxyUrl != null ? URLUtils.toURLSafe(a0.proxyUrl) != null ? "VIDEO" : "INVALID" : "INVALID" : "INVALID";
}
export function messageAttachmentToMediaItem(a0, a1) {
return {
...messageAttachmentToUnfurledMediaItem(a0),
type: isImageFile(a0.filename) ? "IMAGE" : isVideoFile(a0.filename) ? "VIDEO" : "INVALID",
alt: a0.description,
sourceMetadata: {
message: a1,
identifier: {
type: "attachment",
attachmentId: a0.id,
filename: a0.filename,
title: a0.title,
size: a0.size
}
}
};
}
export function embedMediaToMediaItem(a0, a1, a2) {
return {
type: a2,
url: a0.url,
proxyUrl: a0.proxyURL,
width: a0.width,
height: a0.height,
placeholder: a0.placeholder,
placeholderVersion: a0.placeholderVersion,
sourceMetadata: a1,
contentType: a0.contentType
};
}
export function isVisualUnfurledMediaItem(a0) {
return a0.width != null && a0.width > 0 && a0.height != null && a0.height > 0;
}
export function getMediaItemDisplayUrl(a0) {
if (a0 == null) {
return null;
}
if (a0.type === "VIDEO" && a0.proxyUrl != null) {
const r17 = URLUtils.toURLSafe(a0.proxyUrl);
const r18 = r17 == null;
let r19 = null;
if (!r18) {
r17.searchParams.append("format", "webp");
r19 = r17.toString();
}
return r19;
}
let proxyUrl = a0.proxyUrl;
if (proxyUrl == null) {
proxyUrl = a0.url;
}
if (proxyUrl == null) {
proxyUrl = null;
}
return proxyUrl;
}
+10
View File
@@ -0,0 +1,10 @@
// Metro module 15830 (f15831).
import Dispatcher from "../../Dispatcher";
export function updateVideoSize(a0, a1, a2) {
Dispatcher.dispatch({
type: "VIDEO_SIZE_UPDATE",
streamId: a0,
dimensions: a1,
zoom: a2
});
}
+182
View File
@@ -0,0 +1,182 @@
// Metro module 9854 (f9855).
import { useMemo, memo } from "react";
import { Image as Image2, View } from "react-native";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import Module9855 from "../../../_bundle/Module9855";
import Module9856 from "../../../_bundle/Module9856";
import Module9857 from "../../../_bundle/Module9857";
import Module9858 from "../../../_bundle/Module9858";
import Module9859 from "../../../_bundle/Module9859";
import Module9860 from "../../../_bundle/Module9860";
import Module9861 from "../../../_bundle/Module9861";
import Module9862 from "../../../_bundle/Module9862";
import Module9863 from "../../../_bundle/Module9863";
import Module9864 from "../../../_bundle/Module9864";
import Module9865 from "../../../_bundle/Module9865";
import Module9866 from "../../../_bundle/Module9866";
import Module9867 from "../../../_bundle/Module9867";
import Module9868 from "../../../_bundle/Module9868";
import { classifyFileName } from "../../../utils/FileUtils";
import { Text } from "../../../design/components/Text/native/Text";
import * as _PlatformUtils from "../../../utils/PlatformUtils";
import { isAndroid } from "../../../utils/PlatformUtils";
import FastImage from "../../../components_native/common/FastImage";
import { ThumbnailImage } from "../../../design/void/native";
import { CirclePlayIcon } from "../../../design/components/Icon/native/redesign/generated/CirclePlayIcon";
import { VideoComponent } from "../../../components_native/common/Video";
let useStyles, c6543_9, FilenameText, DefaultAttachmentPreview, Component;
const AttachmentIcon = function AttachmentIcon(props) {
const fileName = props.fileName;
return <Image2 style={useStyles().attachmentFileIcon} source={useMemo(() => {
let r9 = fileName;
if (fileName == null) {
r9 = "";
}
let r12 = c6543_9[classifyFileName(r9)];
if (r12 == null) {
r12 = Module9866;
}
return r12;
}, [fileName])} />;
};
FilenameText = function FilenameText(props) {
const fileName2 = props.fileName;
const styles = useStyles();
const r5 = /(?:\.([^.]+))?$/;
let r15 = fileName2;
if (r15 == null) {
r15 = "";
}
const r16 = r5.exec(r15);
return <View>
{fileName2 != null && fileName2 !== "" && <Text style={styles.attachmentFileName} ellipsizeMode="middle" lineClamp={1} variant="text-xs/medium" color="mobile-text-heading-primary">{fileName2}</Text>}
<Text style={styles.attachmentFileName} lineClamp={1} variant="text-xs/medium" color="text-muted">
{r16 != null ? r16[1] != null ? r16[1].toUpperCase() : "UNKNOWN" : "UNKNOWN"}
</Text>
</View>;
};
DefaultAttachmentPreview = function DefaultAttachmentPreview(props) {
const { fileName: fileName2, maxFileWidth, borderRadius } = props;
return <View style={[useStyles().fileInfoAttachmentPreviewFile, {
maxWidth: maxFileWidth,
borderRadius
}]}>
<AttachmentIcon fileName={fileName2} />
<FilenameText fileName={fileName2} />
</View>;
};
useStyles = createStyles({
fileInfoAttachmentPreviewFile: {
flexDirection: "row",
alignItems: "center",
overflow: "hidden",
borderRadius: Module712.radii.sm,
height: 75,
padding: 12,
flex: 1,
gap: Module712.space.PX_8
},
attachmentFileIcon: {
height: 32,
width: 24
},
attachmentFileName: {
paddingRight: 4,
paddingLeft: 4,
maxWidth: 136
},
videoIcon: {
position: "absolute",
top: 0,
left: 0,
right: 0,
bottom: 0,
alignItems: "center",
justifyContent: "center"
}
});
c6543_9 = {
archive: Module9855,
acrobat: Module9856,
ae: Module9857,
ai: Module9858,
audio: Module9859,
code: Module9860,
document: Module9861,
image: Module9862,
photoshop: Module9863,
sketch: Module9864,
spreadsheet: Module9865,
unknown: Module9866,
video: Module9867,
webcode: Module9868
};
Component = memo(function({ uri, width, height, borderRadius, style, fileName: fileName2 }) {
let props;
const source = {
uri,
width,
height
};
const r10 = {
width,
height,
borderRadius
};
const r13 = fileName2 != null && fileName2 !== "" && /\.gif$/i.test(fileName2) && (_PlatformUtils.isIOS() && uri.startsWith("ph://") || isAndroid() && uri.startsWith("content://"));
const r34 = {
style: [r10, style, {
overflow: "hidden"
}],
children: null
};
if (r13) {
r34.children = <FastImage style={[r10, style]} source={source} resizeMode="cover" enableAnimation />;
props = r34;
} else {
r34.children = <ThumbnailImage style={[r10, style]} source={source} localImageSource={source} />;
props = r34;
}
return <View {...props} />;
});
export default function AttachmentPreview(props) {
let r44;
const { uri, isImage, isVideo, width = 75, height = 75, maxFileWidth, fileName: fileName2, borderRadius = Module712.radii.sm, showPlayOnVideoPreview = false, defaultPreview = <DefaultAttachmentPreview fileName={fileName2} maxFileWidth={maxFileWidth} borderRadius={borderRadius} /> } = props;
L25: {
const style = props.style;
const styles = useStyles();
if (isImage) {
r44 = <Component uri={uri} width={width} height={height} borderRadius={borderRadius} style={style} fileName={fileName2} />;
} else {
if (!(isVideo && isAndroid()) && !(_PlatformUtils.isIOS() && uri.startsWith("ph://"))) {
r44 = defaultPreview;
if (!isVideo) {
break L25;
}
const isIOS = _PlatformUtils.isIOS();
r44 = defaultPreview;
if (!isIOS) {
break L25;
}
r44 = <View style={style}>
<VideoComponent style={{
height,
width
}} source={{
uri
}} muted paused resizeMode="cover" preventsDisplaySleepDuringVideoPlayback={false} />
</View>;
break L25;
}
r44 = showPlayOnVideoPreview ? <View style={style}>
<Component uri={uri} width={width} height={height} borderRadius={borderRadius} style={style} fileName={fileName2} />
<View style={styles.videoIcon}>
<CirclePlayIcon size="md" color="white" secondaryColor="black" />
</View>
</View> : <Component uri={uri} width={width} height={height} borderRadius={borderRadius} style={style} fileName={fileName2} />;
}
}
return r44;
};
export { AttachmentIcon };
+30
View File
@@ -0,0 +1,30 @@
// Metro module 8103 (f8104).
import { View } from "react-native";
import { Fonts } from "../../../Constants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { hexWithOpacity } from "../../../utils/ColorUtils";
import { LegacyText } from "../../../design/void/native";
const useStyles = createStyles({
captionText: {
fontFamily: Fonts.PRIMARY_BOLD,
color: Module712.colors.WHITE,
fontSize: 12
},
labelContainer: {
backgroundColor: hexWithOpacity(Module712.unsafe_rawColors.PRIMARY_700, 0.5),
borderRadius: Module712.radii.xs,
paddingHorizontal: 8,
paddingVertical: 2,
position: "absolute",
right: 6,
bottom: 6
}
});
export function Caption(props) {
const { label, style, textStyle } = props;
const styles = useStyles();
return <View style={[styles.labelContainer, style]}>
<LegacyText style={[styles.captionText, textStyle]}>{label}</LegacyText>
</View>;
}
@@ -0,0 +1,74 @@
// Metro module 4753 (f4754).
import { NativeModules } from "react-native";
import Logger from "../../debug/Logger";
import LifecycleManager from "../../../lib/LifecycleManager";
let c2906_2 = new Logger("IosImageTypesManager");
let supportedImageTypes = null;
let c2906_4 = null;
let c2906_5 = null;
let c2906_6 = null;
class IosImageTypesManager extends LifecycleManager {
_initialize() {
this.initializeSupportedImageTypes();
}
_terminate() {}
initializeSupportedImageTypes() {
if (supportedImageTypes === null) {
try {
const supportedImageTypes2 = NativeModules.MediaManager.getSupportedImageTypes();
supportedImageTypes = supportedImageTypes2;
const set = new Set();
const set2 = new Set();
const set3 = new Set();
for (const item of Object.entries(supportedImageTypes2)) {
const [, r55] = item;
const { extension, mimeType } = r55;
if (extension != null && extension !== "") {
set.add(extension);
}
if (mimeType != null && mimeType !== "") {
set2.add(mimeType);
}
}
set.add("jpg");
set3.add("gif");
set3.add("webp");
c2906_4 = set;
c2906_5 = set2;
c2906_6 = set3;
} catch ($e) {
c2906_2.warn("Failed to get iOS supported image types:", $e);
supportedImageTypes = {};
c2906_4 = new Set();
c2906_5 = new Set();
c2906_6 = new Set();
}
}
}
getSupportedImageTypes() {
return supportedImageTypes;
}
isImageTypeSupported(a0) {
return supportedImageTypes !== null && a0 in supportedImageTypes;
}
getSupportedExtensions() {
return c2906_4;
}
getSupportedMimeTypes() {
return c2906_5;
}
getAnimatedExtensions() {
return c2906_6;
}
isExtensionSupported(a0) {
return c2906_4 !== null && c2906_4.has(a0);
}
isMimeTypeSupported(a0) {
return c2906_5 !== null && c2906_5.has(a0);
}
isExtensionAnimated(a0) {
return c2906_6 !== null && c2906_6.has(a0);
}
}
const iosImageTypesManager = new IosImageTypesManager();
export default iosImageTypesManager;
+407
View File
@@ -0,0 +1,407 @@
// Metro module 13590 (f13591).
import { NativeEventEmitter, NativeModules } from "react-native";
import EmbeddedActivitiesStore from "../../activities/EmbeddedActivitiesStore";
import VoicePanelStore from "../../voice_panel/VoicePanelStore";
import ChannelStore from "../../../stores/ChannelStore";
import MessageStore from "../../../stores/MessageStore";
import PermissionStore from "../../../stores/PermissionStore";
import AppStateStore from "../../../stores/native/AppStateStore";
import { AppStates } from "../../../Constants";
import { ActivityPanelModes } from "../../activities/panel/ActivityPanelConstants";
import { PLAYBACK_COMPLETION_DETECTION_TOLERANCE, PLAYBACK_PROGRESS_UPDATE_INTERVAL } from "../../media_panel/native/MediaPlaybackPanelConstants";
import { Permissions } from "../../../_bundle/Module505";
import Logger from "../../debug/Logger";
import { create } from "../../../_bundle/Module644";
import { batchUpdates } from "../../../_bundle/Module705";
import LifecycleManager from "../../../lib/LifecycleManager";
import { getRootNavigationRef } from "../../main_tabs_v2/RootNavigationRef.native";
import Dispatcher from "../../../Dispatcher";
import { isIOS } from "../../../utils/PlatformUtils";
import shallowEqual from "../../../_bundle/shallowEqual";
import MessageActionCreators from "../../../actions/MessageActionCreators";
import { getFocusedChannelId } from "../../panels/isChannelFocused.native";
import { $callWithNewTarget } from "../../../_hermes/prelude";
let c9437_16 = new Logger("MediaPlayerManager");
let c9437_17 = create((c20557_0) => ({
activeMediaPlayerSource: void 0,
mediaSourceMessage: void 0,
canAccessMedia: true,
isPlaying: false,
wasPipClosedByUser: false,
progress: void 0,
rate: 0,
showPip: false,
closePip: () => {
batchUpdates(() => c20557_0({
showPip: false
}));
},
displayedMediaItemIdsPerChannel: {},
currentlyDisplayedChannelId: void 0
}));
class MediaPlayerManager extends LifecycleManager {
subscriptions = [];
voicePanelStoreUnsubscribe = void 0;
showPipUnsubscribe = void 0;
pauseAndClosePip = this.pauseAndClosePip.bind(this);
handleVoicePanelStateUpdated = this.handleVoicePanelStateUpdated.bind(this);
handleEmbeddedActivitiesUpdated = this.handleEmbeddedActivitiesUpdated.bind(this);
handleMediaPlayerPlaybackRateChanged = this.handleMediaPlayerPlaybackRateChanged.bind(this);
handleMediaPlayerPlaybackSourceChanged = this.handleMediaPlayerPlaybackSourceChanged.bind(this);
handleMediaPlayerViewWillAppear = this.handleMediaPlayerViewWillAppear.bind(this);
handleMediaPlayerViewDidDisappear = this.handleMediaPlayerViewDidDisappear.bind(this);
updateDisplayState = this.updateDisplayState.bind(this);
updateMediaPermissions = this.updateMediaPermissions.bind(this);
constructor() {
super();
}
_initialize() {
const nativeEventEmitter = new NativeEventEmitter(NativeModules.MediaPlayerManager);
this.subscriptions = [nativeEventEmitter.addListener("MediaPlayerPlaybackSourceChanged", this.handleMediaPlayerPlaybackSourceChanged), nativeEventEmitter.addListener("MediaPlayerPlaybackProgressUpdated", this.handleMediaPlayerPlaybackProgressUpdated), nativeEventEmitter.addListener("MediaPlayerPlaybackRateChanged", this.handleMediaPlayerPlaybackRateChanged), nativeEventEmitter.addListener("MediaPlayerViewWillAppear", this.handleMediaPlayerViewWillAppear), nativeEventEmitter.addListener("MediaPlayerViewDidDisappear", this.handleMediaPlayerViewDidDisappear)];
NativeModules.MediaPlayerManager.subscribeToPlaybackEvents();
const rootNavigationRef = getRootNavigationRef();
if (rootNavigationRef != null) {
rootNavigationRef.addListener("state", this.updateDisplayState);
}
this.voicePanelStoreUnsubscribe = VoicePanelStore.subscribe(this.handleVoicePanelStateUpdated);
EmbeddedActivitiesStore.addChangeListener(this.handleEmbeddedActivitiesUpdated);
ChannelStore.addChangeListener(this.updateMediaPermissions);
PermissionStore.addChangeListener(this.updateMediaPermissions);
Dispatcher.subscribe("LOGOUT", this.userDidClosePip);
if (isIOS()) {
this.showPipUnsubscribe = c9437_17.subscribe((a0, a1) => {
if (a1.showPip && !a0.showPip) {
NativeModules.MediaPlayerManager.clearNowPlayingInfo();
} else if (a1.rate !== 0 && a0.rate === 0 && !a0.showPip && AppStateStore.getState() === AppStates.ACTIVE) {
NativeModules.MediaPlayerManager.clearNowPlayingInfo();
}
});
}
c9437_16.verbose("Initialized and subscribed to playback events");
}
updateMediaPermissions() {
batchUpdates(() => {
let r10 = c9437_17.getState().activeMediaPlayerSource?.channelId;
if (r10 == null) {
r10 = null;
}
const channel = ChannelStore.getChannel(r10);
if (channel != null && (!channel.isPrivate() && !PermissionStore.can(Permissions.VIEW_CHANNEL, channel))) {
c9437_17.setState({
canAccessMedia: false
});
this.pauseCurrentPlayer();
} else {
c9437_17.setState({
canAccessMedia: true
});
}
});
}
_terminate() {
this.subscriptions.forEach((subscription) => subscription.remove());
this.subscriptions = [];
const rootNavigationRef = getRootNavigationRef();
if (rootNavigationRef != null) {
rootNavigationRef.removeListener("state", this.updateDisplayState);
}
const voicePanelStoreUnsubscribe = this.voicePanelStoreUnsubscribe;
if (voicePanelStoreUnsubscribe != null) {
voicePanelStoreUnsubscribe.call(this);
}
const showPipUnsubscribe = this.showPipUnsubscribe;
if (showPipUnsubscribe != null) {
showPipUnsubscribe.call(this);
}
EmbeddedActivitiesStore.removeChangeListener(this.handleEmbeddedActivitiesUpdated);
ChannelStore.removeChangeListener(this.updateMediaPermissions);
PermissionStore.removeChangeListener(this.updateMediaPermissions);
Dispatcher.unsubscribe("LOGOUT", this.userDidClosePip);
}
pauseCurrentPlayer() {
NativeModules.MediaPlayerManager.pauseCurrentPlayer();
}
playCurrentPlayer() {
NativeModules.MediaPlayerManager.playCurrentPlayer();
}
userDidClosePip() {
batchUpdates(() => c9437_17.setState({
wasPipClosedByUser: true,
showPip: false
}));
}
pauseAndClosePip() {
batchUpdates(() => {
this.pauseCurrentPlayer();
c9437_17.setState({
wasPipClosedByUser: true,
showPip: false
});
});
}
handleVoicePanelStateUpdated() {
const state = VoicePanelStore.getState();
if (state.isVoicePanelFullscreen() || state.voicePanelsPIP.size > 0) {
this.pauseAndClosePip();
}
}
handleEmbeddedActivitiesUpdated() {
if (EmbeddedActivitiesStore.getActivityPanelMode() === ActivityPanelModes.PIP) {
this.pauseAndClosePip();
}
}
handleMediaPlayerPlaybackRateChanged({ source, rate }) {
batchUpdates(() => {
if (source == null) {
c9437_17.setState({
rate: 0,
isPlaying: false
});
}
c9437_16.verbose(`Playback rate changed to ${rate}: ${source?.id}`);
const state = c9437_17.getState();
const { activeMediaPlayerSource, isPlaying, wasPipClosedByUser } = state;
if (shallowEqual(activeMediaPlayerSource, source == null ? void 0 : source)) {
const r48 = isPlaying === false && rate > 0;
c9437_17.setState({
rate,
isPlaying: rate !== 0,
wasPipClosedByUser: r48 ? !r48 : wasPipClosedByUser
});
this.updateDisplayState();
return void 0;
}
this.handleMediaPlayerPlaybackSourceChanged({
source
});
this.handleMediaPlayerPlaybackRateChanged({
source,
rate
});
});
}
handleMediaPlayerPlaybackProgressUpdated({ source: source2, time, duration }) {
batchUpdates(() => {
const state = c9437_17.getState();
const activeMediaPlayerSource = state.activeMediaPlayerSource;
const r16 = source2 == null ? void 0 : source2;
L22: {
if (shallowEqual(activeMediaPlayerSource, r16)) {
const currentlyDisplayedChannelId = state.currentlyDisplayedChannelId;
if (!state.showPip) {
if (currentlyDisplayedChannelId == null) {
break L22;
}
if (currentlyDisplayedChannelId !== source2?.channelId) {
break L22;
}
}
const r22 = duration > 0;
let progress2 = void 0;
if (r22) {
let isCompleted = duration <= 0 ? void 0 : duration - time <= PLAYBACK_COMPLETION_DETECTION_TOLERANCE;
if (isCompleted == null) {
isCompleted = false;
}
progress2 = {
time,
duration,
isCompleted
};
}
const progress = state.progress;
if (!(progress != null && progress2 != null && Math.abs(progress2.time - progress.time) < PLAYBACK_PROGRESS_UPDATE_INTERVAL && progress2.time !== progress2.duration)) {
c9437_17.setState({
progress: progress2
});
}
}
}
});
}
handleMediaPlayerPlaybackSourceChanged({ source: source3 }) {
batchUpdates(() => {
const state = c9437_17.getState();
c9437_16.verbose(`Playback source changed: ${source3?.id}`);
let activeMediaPlayerSource = state.activeMediaPlayerSource;
if (activeMediaPlayerSource == null) {
activeMediaPlayerSource = void 0;
}
if (!shallowEqual(activeMediaPlayerSource, source3 == null ? void 0 : source3)) {
c9437_17.setState({
activeMediaPlayerSource: source3 == null ? void 0 : source3,
mediaSourceMessage: source3 != null ? this.getOrFetchMediaSourceMessage(source3) : void 0,
progress: void 0,
rate: 0,
isPlaying: false,
wasPipClosedByUser: false
});
this.updateMediaPermissions();
this.updateDisplayState();
}
});
}
getOrFetchMediaSourceMessage({ channelId: channelId3, messageId, assetUrl }) {
if (messageId != null && channelId3 != null) {
const message = MessageStore.getMessage(channelId3, messageId);
if (message != null) {
return message;
}
if (assetUrl != null) {
const r17 = MessageStore.getMessages(channelId3).toArray().find((item) => {
const contentMessage = item.getContentMessage();
const r2 = contentMessage == null;
let r8 = void 0;
if (!r2) {
const attachments = contentMessage.attachments;
r8 = attachments == null ? void 0 : attachments.some((attachment) => attachment.url === assetUrl);
}
return r8;
});
if (r17 != null) {
return r17;
}
}
MessageActionCreators.fetchMessage({
channelId: channelId3,
messageId
}).then((result) => {
if (result != null) {
this.handleMediaSourceMessageUpdated(result);
}
});
}
}
handleMediaSourceMessageUpdated(mediaSourceMessage) {
batchUpdates(() => {
if (c9437_17.getState().activeMediaPlayerSource?.messageId === mediaSourceMessage.id) {
c9437_17.setState({
mediaSourceMessage
});
}
});
}
handleMediaPlayerViewWillAppear({ mediaItemIds, channelId }) {
batchUpdates(() => {
const displayedMediaItemIdsPerChannel = c9437_17.getState().displayedMediaItemIdsPerChannel;
let r7 = displayedMediaItemIdsPerChannel[channelId];
if (r7 == null) {
r7 = [];
}
displayedMediaItemIdsPerChannel[channelId] = new Set([...r7, ...mediaItemIds]);
c9437_17.setState({
displayedMediaItemIdsPerChannel
});
this.updateDisplayState();
});
}
handleMediaPlayerViewDidDisappear({ mediaItemIds: mediaItemIds2, channelId: channelId2 }) {
batchUpdates(() => {
const displayedMediaItemIdsPerChannel = c9437_17.getState().displayedMediaItemIdsPerChannel;
const r9 = Set;
let r5 = displayedMediaItemIdsPerChannel[channelId2];
if (r5 == null) {
r5 = new Set();
}
const r27 = new r9([...r5].filter((item) => !mediaItemIds2.includes(item)));
if (r27.size === 0) {
delete displayedMediaItemIdsPerChannel[channelId2];
} else {
displayedMediaItemIdsPerChannel[channelId2] = r27;
}
c9437_17.setState({
displayedMediaItemIdsPerChannel
});
this.updateDisplayState();
});
}
updateDisplayState() {
batchUpdates(() => {
const state = c9437_17.getState();
const { displayedMediaItemIdsPerChannel, currentlyDisplayedChannelId, activeMediaPlayerSource = {} } = state;
L27: {
const id = activeMediaPlayerSource.id;
const { wasPipClosedByUser, progress } = state;
let isPlaying = state.isPlaying;
const showPip = state.showPip;
if (wasPipClosedByUser) {
c9437_17.setState({
showPip: false
});
} else {
if (!isPlaying && !showPip) {
break L27;
}
if (!isPlaying) {
isPlaying = progress != null && !(progress.duration <= 0 ? void 0 : progress.duration - progress.time <= PLAYBACK_COMPLETION_DETECTION_TOLERANCE);
}
const focusedChannelId = getFocusedChannelId();
if (focusedChannelId != null && currentlyDisplayedChannelId !== focusedChannelId) {
for (const key in displayedMediaItemIdsPerChannel) {
if (key !== focusedChannelId) {
delete displayedMediaItemIdsPerChannel[key];
}
}
}
if (id != null) {
if (focusedChannelId != null) {
const r45 = displayedMediaItemIdsPerChannel[focusedChannelId];
if (r45 != null) {
if (isPlaying) {
isPlaying = !r45.has(id);
}
c9437_17.setState({
showPip: isPlaying,
currentlyDisplayedChannelId: focusedChannelId,
displayedMediaItemIdsPerChannel
});
} else {
c9437_17.setState({
showPip: isPlaying,
currentlyDisplayedChannelId: focusedChannelId,
displayedMediaItemIdsPerChannel
});
}
} else {
c9437_17.setState({
showPip: isPlaying,
currentlyDisplayedChannelId: focusedChannelId,
displayedMediaItemIdsPerChannel
});
}
} else {
c9437_17.setState({
showPip: isPlaying,
currentlyDisplayedChannelId: focusedChannelId,
displayedMediaItemIdsPerChannel
});
}
}
}
});
}
}
const prototypeOf = Object.getPrototypeOf(MediaPlayerManager);
const r95 = Object.create(MediaPlayerManager.prototype);
const r97 = $callWithNewTarget(prototypeOf, r95, MediaPlayerManager);
const r98 = r97 instanceof Object ? r97 : r95;
r98.subscriptions = [];
r98.voicePanelStoreUnsubscribe = void 0;
r98.showPipUnsubscribe = void 0;
r98.pauseAndClosePip = r98.pauseAndClosePip.bind(r98);
r98.handleVoicePanelStateUpdated = r98.handleVoicePanelStateUpdated.bind(r98);
r98.handleEmbeddedActivitiesUpdated = r98.handleEmbeddedActivitiesUpdated.bind(r98);
r98.handleMediaPlayerPlaybackRateChanged = r98.handleMediaPlayerPlaybackRateChanged.bind(r98);
r98.handleMediaPlayerPlaybackSourceChanged = r98.handleMediaPlayerPlaybackSourceChanged.bind(r98);
r98.handleMediaPlayerViewWillAppear = r98.handleMediaPlayerViewWillAppear.bind(r98);
r98.handleMediaPlayerViewDidDisappear = r98.handleMediaPlayerViewDidDisappear.bind(r98);
r98.updateDisplayState = r98.updateDisplayState.bind(r98);
r98.updateMediaPermissions = r98.updateMediaPermissions.bind(r98);
export default r98;
export { c9437_17 as useMediaPlayerManagerStore };
export function isPlaybackComplete(a0) {
if (a0.duration <= 0) {
return void 0;
}
return a0.duration - a0.time <= PLAYBACK_COMPLETION_DETECTION_TOLERANCE;
}
@@ -0,0 +1,13 @@
// Metro module 4771 (f4772).
import { detectFile } from "../../../../_bundle/Module4772";
import { DiscordImagePng } from "./DiscordImagePng";
export class DiscordImageFactory {
constructor() {
return {
__proto__: new.target.prototype
};
}
static create(a0) {
return detectFile(new Uint8Array(a0, 0, Math.min(64, a0.byteLength)))?.mimeType === "image/png" ? DiscordImagePng.create(a0) : null;
}
}
+131
View File
@@ -0,0 +1,131 @@
// Metro module 4799 (f4800).
import decodeImage from "../../../../_bundle/decodeImage";
import { load } from "../../../../_bundle/loadView";
class DiscordImagePng {
constructor(a0, a1) {
this.img = a0;
this.originalBuffer = a1;
}
static create(a0) {
let discordImagePng;
try {
discordImagePng = new DiscordImagePng(decodeImage.decode(a0), a0);
} catch ($e) {}
return discordImagePng;
}
hasTransparency() {
if (this.img.ctype !== 4 && this.img.ctype !== 6) {
return false;
}
const uint8Array = new Uint8Array(decodeImage.toRGBA8(this.img)[0]);
const length = uint8Array.length;
let r0 = 3;
if (3 < length) {
do {
const r28 = uint8Array[r0];
const r1 = r0;
if (r28 < 255) {
return true;
}
r0 = r1 + 4;
} while (r0 < uint8Array.length);
}
return false;
}
isAnimated() {
return this.img.tabs.acTL != null;
}
isPng8() {
return this.img.ctype === 3 && this.img.depth <= 8;
}
async hasSrgbIccProfile() {
let r34, r110;
const _this = this;
let c25297_0, c25297_1, c25297_4;
let c25297_5 = 0;
let c29441_0, c29441_1, c29441_2, c29441_3;
L22: {
L21: {
try {
c29441_0 = void 0;
c29441_1 = void 0;
c29441_2 = void 0;
c29441_3 = void 0;
c29441_0 = await load(_this.originalBuffer, {
async: true,
expanded: true,
includeUnknown: true
});
if (c29441_0.icc == null) {
break L22;
}
c29441_1 = c29441_0.icc;
c29441_2 = Object.keys(c29441_1);
const r81 = c29441_2;
c25297_1 = r81;
const r83 = r81[Symbol.iterator]();
c25297_1 = r83.next;
c25297_0 = r83;
while (true) {
const r85 = c25297_1;
let r86 = c25297_0;
const r87 = r86 === void 0 ? void 0 : (r34 = r85.call(r86)).done ? r86 = void 0 : r34.value;
c25297_0 = r86;
if (r86 === void 0) {
break L21;
}
c25297_5 = 1;
c29441_3 = r87;
if (c29441_3 === "ICC Description") {
if (c29441_1[c29441_3]?.description != null) {
if (c29441_1[c29441_3].description !== "") {
r110 = !c29441_1[c29441_3].description.toLowerCase().includes("srgb");
c25297_5 = 0;
const r111 = c25297_0;
if (r111 !== void 0 && typeof r111.return === "function") {
r111.return();
}
break;
}
}
}
c25297_5 = 0;
}
} catch ($e) {
const r40 = $e;
let r8 = r40;
c25297_4 = r40;
if (c25297_5 !== 0) {
while (true) {
try {
const r119 = c25297_4;
c25297_5 = 0;
const r121 = c25297_0;
if (r121 !== void 0 && typeof r121.return === "function") {
try {
r121.return();
} catch {}
}
throw r119;
} catch (r117) {
r8 = r117;
c25297_4 = r117;
if (c25297_5 === 0) {
break;
}
}
}
}
throw r8;
}
return !r110;
}
return false;
}
return true;
}
getBuffer() {
return this.originalBuffer;
}
}
export { DiscordImagePng };