decord/source/modules/message_previews/native/MessagePreviewMarkup.tsx

108 lines
4.7 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 10092
// Function ID: 10093
2026-07-29 08:29:29 +00:00
// Name: getOrParseMessagePreviewMarkupAST
2026-08-24 06:08:38 +00:00
// Dependencies: [6845, 6846, 10093, 4095, 6844, 4074, 1405, 2]
2026-07-29 08:29:29 +00:00
// Exports: getMessagePreviewASTParser, renderASTToReact, renderMessagePreviewMarkup
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
// Module 10092 (getOrParseMessagePreviewMarkupAST)
import privDefault from "priv" /* 1405 */;
import ChannelListLayoutTypes from "ChannelListLayoutTypes" /* 4074 */;
import tDefault from "t" /* 4095 */;
import get_defaultRulesDefault from "get defaultRules" /* 6844 */;
import combineMarkupRulesDefault from "combineMarkupRules" /* 6845 */;
import parseLinkDefault from "parseLink" /* 6846 */;
import defaultReactFnDefault from "defaultReactFn" /* 10093 */;
require = arg1;
2026-07-20 16:05:17 +00:00
function getOrParseMessagePreviewMarkupAST(arg0) {
2026-07-29 08:29:29 +00:00
({ content, layout, color, initialParserState, postProcessor, fontScale, maxFontSizeMultiplier } = arg0);
2026-08-24 06:08:38 +00:00
const value = closure_3.get(content);
2026-07-20 16:05:17 +00:00
if (null != value) {
return value;
} else {
2026-08-24 06:08:38 +00:00
const items = [parseLinkDefault.RULES, defaultReactFnDefault(layout, color, fontScale, maxFontSizeMultiplier)];
const tmp11 = combineMarkupRulesDefault;
const tmp11Result = combineMarkupRulesDefault(items);
const obj3 = get_defaultRulesDefault;
2026-07-20 16:05:17 +00:00
let startsWithResult = content.startsWith("```");
let tmp3;
if (!startsWithResult) {
const first = content.split("\n")[0];
startsWithResult = first.includes("||");
tmp3 = first;
}
if (startsWithResult) {
tmp3 = content;
}
2026-08-24 06:08:38 +00:00
const astParserForResultResult = get_defaultRulesDefault.astParserFor(tmp11Result)(tmp3, true, initialParserState, postProcessor);
2026-07-29 08:29:29 +00:00
const result = obj.set(content, astParserForResultResult);
return astParserForResultResult;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
obj = closure_3;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
const tmp2 = new privDefault({ max: 2000 });
let closure_3 = tmp2;
let result = require("set").fileFinishedImporting("modules/message_previews/native/MessagePreviewMarkup.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export const renderASTToReact = function renderASTToReact(layout) {
({ tree, initialParserState, color, fontScale, maxFontSizeMultiplier } = layout);
2026-08-24 06:08:38 +00:00
const items = [parseLinkDefault.RULES, defaultReactFnDefault(layout.layout, color, fontScale, maxFontSizeMultiplier)];
const tmp = combineMarkupRulesDefault;
const tmpResult = combineMarkupRulesDefault(items);
const obj = tDefault;
return obj.reactFor(tDefault.ruleOutput(tmpResult, "react"))(tree, initialParserState);
2026-07-29 08:29:29 +00:00
};
export const getMessagePreviewASTParser = function getMessagePreviewASTParser(layout) {
({ color, fontScale, maxFontSizeMultiplier } = layout);
2026-08-24 06:08:38 +00:00
const items = [parseLinkDefault.RULES, defaultReactFnDefault(layout.layout, color, fontScale, maxFontSizeMultiplier)];
const tmp = combineMarkupRulesDefault;
const tmpResult = combineMarkupRulesDefault(items);
return get_defaultRulesDefault.astParserFor(tmpResult);
2026-07-29 08:29:29 +00:00
};
2026-07-20 16:05:17 +00:00
export const renderMessagePreviewMarkup = function renderMessagePreviewMarkup(fontScale) {
({ content, muted, layout } = fontScale);
({ guildId, channelId } = fontScale);
if (layout === undefined) {
2026-08-24 06:08:38 +00:00
layout = ChannelListLayoutTypes.ChannelListLayoutTypes.COMPACT;
2026-07-20 16:05:17 +00:00
}
({ color, disableAnimatedEmoji, postProcessor } = fontScale);
if (disableAnimatedEmoji === undefined) {
disableAnimatedEmoji = true;
}
2026-07-29 08:29:29 +00:00
let num = fontScale.fontScale;
if (num === undefined) {
num = 1;
2026-07-20 16:05:17 +00:00
}
const maxFontSizeMultiplier = fontScale.maxFontSizeMultiplier;
if ("" === content) {
return null;
} else {
2026-08-06 08:05:19 +00:00
let obj = { allowLinks: true, allowDevLinks: false, allowEmojiLinks: false, allowGameMentions: false, mentionChannels: null, soundboardSounds: null, formatInline: true, noStyleAndInteraction: true, allowHeading: true, allowList: true, disableAutoBlockNewlines: true, previewLinkTarget: false, disableAnimatedEmoji: null, unknownUserMentionPlaceholder: true, guildId: null, channelId: null, muted: null };
2026-07-29 08:29:29 +00:00
obj[4] = [];
2026-08-06 08:05:19 +00:00
obj[5] = [];
obj[12] = disableAnimatedEmoji;
obj[14] = guildId;
obj[15] = channelId;
2026-07-29 08:29:29 +00:00
if (muted == null) {
muted = false;
}
2026-08-06 08:05:19 +00:00
obj[16] = muted;
2026-07-29 08:29:29 +00:00
obj = { content: null, layout: null, color: null, initialParserState: null, fontScale: null, maxFontSizeMultiplier: null, postProcessor: null };
obj[0] = content;
obj[1] = layout;
obj[2] = color;
obj[3] = obj;
obj[4] = num;
obj[5] = maxFontSizeMultiplier;
obj[6] = postProcessor;
const tmp4 = getOrParseMessagePreviewMarkupAST(obj);
2026-08-24 06:08:38 +00:00
const items = [parseLinkDefault.RULES, defaultReactFnDefault(layout, color, num, maxFontSizeMultiplier)];
const tmp7 = combineMarkupRulesDefault;
const tmp7Result = combineMarkupRulesDefault(items);
const obj2 = tDefault;
return obj2.reactFor(tDefault.ruleOutput(tmp7Result, "react"))(tmp4, obj);
2026-07-20 16:05:17 +00:00
}
};
2026-07-29 08:29:29 +00:00
export const messagePreviewASTCache = tmp2;
2026-07-20 16:05:17 +00:00
export { getOrParseMessagePreviewMarkupAST };