Files
discord-decomp/modules/messages/native/renderer/MarkupParsers.tsx
T
2026-11-01 12:12:55 +02:00

118 lines
3.4 KiB
TypeScript

// Metro module 7864 (f7865).
import { MessageTypes } from "../../../../Constants";
import Durations from "../../../../utils/Durations";
import LRUCache from "../../../../_bundle/LRUCache";
import MarkupUtils from "../../../markup/MarkupUtils";
import { changelogRules } from "../../../../components_native/ChangeLogStandardTemplate";
import { renderMessageMarkupToAST } from "../../renderMessageMarkup";
const r26 = {
max: Infinity,
maxAge: 15 * Durations.Millis.MINUTE,
updateAgeOnGet: true
};
let c4965_4 = new LRUCache(r26);
let c4965_5 = new LRUCache(r26);
let c4965_6 = new LRUCache({
...r26,
updateAgeOnGet: false
});
let c4965_7 = new LRUCache(r26);
export function parseEmbedTitleMarkup(a0, a1) {
const r5 = `${a0}-${a1}`;
let r13 = c4965_4.get(r5);
if (r13 == null) {
const r21 = MarkupUtils.parseEmbedTitleToAST(a0, true, {
channelId: a1
});
c4965_4.set(r5, r21);
r13 = r21;
}
return r13;
}
export function parseEmbedTitleMarkupWithoutLinks(a0, a1) {
const r15 = `${a0}-${a1}-nolinks`;
let r17 = c4965_5.get(r15);
if (r17 == null) {
const r24 = MarkupUtils.parseEmbedTitleWithoutLinksToAST(a0, true, {
channelId: a1
});
c4965_5.set(r15, r24);
r17 = r24;
}
return r17;
}
export function parseEmbedDescriptionMarkup({ description, channelId, isField, ignoreCache, replaceMap, showListsAndHeaders, showMaskedLinks }) {
let r18;
const r22 = `${description}-${channelId}`;
const r25 = c4965_6.get(r22);
if (r25 != null && !ignoreCache) {
return r25;
}
let r27 = description;
let r28 = r27;
for (const key in replaceMap) {
r18 = r27;
r28 = r18;
r27 = r18.replaceAll(key, replaceMap[key]);
}
r18 = r27;
r28 = r18;
const r39 = MarkupUtils.parseToAST(r28, true, {
channelId,
allowGameMentions: true,
allowLinks: true,
allowEmojiLinks: true,
allowHeading: isField ? !isField : showListsAndHeaders,
allowList: showListsAndHeaders,
previewLinkTarget: showMaskedLinks
});
c4965_6.set(r22, r39);
return r39;
}
export function parseMessageMarkup(a0, a1, a2, formatInline = false, allowList = false, r4 = false, allowLinks = false) {
let r29;
let r19 = c4965_7.get(a0);
if (!(r19 != null && r19.isInlineReplyPreview === formatInline)) {
if (a0.type === MessageTypes.CHANGELOG && a0.changelogId != null) {
const r45 = MarkupUtils.astParserFor(changelogRules(a0.changelogId, true));
const content = a0.content;
const allowHeading = allowList ? allowList : r4;
if (!allowList) {
allowList = r4;
}
const r51 = {
content: r45(content, false, {
hideSimpleEmbedContent: a2,
formatInline,
allowHeading,
allowList,
allowLinks,
previewLinkTarget: allowLinks
}),
isInlineReplyPreview: false,
hasSpoilerEmbeds: false,
hasBailedAst: false
};
c4965_7.set(a0, r51);
r29 = r51;
} else {
r29 = {
...renderMessageMarkupToAST(a0, {
contentMessage: a1,
hideSimpleEmbedContent: a2,
formatInline,
allowGameMentions: true,
allowHeading: allowList ? allowList : r4,
allowList: allowList ? allowList : r4,
allowLinks,
previewLinkTarget: allowLinks
}),
isInlineReplyPreview: formatInline
};
c4965_7.set(a0, r29);
}
r19 = r29;
}
return r19;
}