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,10 @@
// Metro module 5680 (f5681).
import Dispatcher from "../../Dispatcher";
export function startDiceRoll(a0, a1, a2) {
Dispatcher.dispatch({
type: "DICE_ROLL_START",
channelId: a0,
diceCount: a1,
diceSides: a2
});
}
+10
View File
@@ -0,0 +1,10 @@
// Metro module 5711 (f5712).
const r14 = [4, 6, 8, 10, 12, 20];
const set = new Set(r14);
export const ROLL_DURATION_MS = 1500;
export const AFTER_ROLL_DELAY_MS = 2000;
export const DISMISS_DELAY_MS = 300;
export const MAX_DICE_COUNT = 10;
export { r14 as ALLOWED_DICE_SIDES };
export { set as ALLOWED_DICE_SIDES_SET };
export const DEFAULT_DICE_SIDES = 6;
+15
View File
@@ -0,0 +1,15 @@
// Metro module 12611 (f12612).
import { createApexExperiment } from "../experiments/apex/index";
const apexExperiment = createApexExperiment({
kind: "user",
name: "2026-05-dice-roll-slash-command",
defaultConfig: {
enabled: false
},
variations: {
1: {
enabled: true
}
}
});
export default apexExperiment;
@@ -0,0 +1,115 @@
// Metro module 16158 (f16159).
import ChannelStore from "../../stores/ChannelStore";
import SelectedChannelStore from "../../stores/SelectedChannelStore";
import DiceRollStore, { INITIAL_STATE } from "./DiceRollStore";
import { AFTER_ROLL_DELAY_MS, ALLOWED_DICE_SIDES_SET, DEFAULT_DICE_SIDES, DISMISS_DELAY_MS, MAX_DICE_COUNT, ROLL_DURATION_MS } from "./DiceRollConstants";
import { MessageSendLocation } from "../messages/MessageConstants";
import AutomaticLifecycleManager from "../../lib/AutomaticLifecycleManager";
import { intl, t } from "../../intl/index.native";
import MessageActionCreators from "../../actions/MessageActionCreators";
import MessageParser from "../messages/MessageParser";
class DiceRollLifecycleManager extends AutomaticLifecycleManager {
actions = {
CHANNEL_SELECT: (a0) => this.handleChannelSelect(a0),
DICE_ROLL_START: (a0) => this.handleStartRoll(a0)
};
rollTimer = null;
postRollDismissTimer = null;
collapseTimer = null;
handleChannelSelect = ({ channelId: channelId2 }) => {
const state = DiceRollStore.getState();
if (state.channelId != null && state.channelId !== channelId2) {
this.clearTimers();
this.dismiss();
}
};
handleStartRoll = ({ channelId, diceCount = 1, diceSides = DEFAULT_DICE_SIDES }) => {
let c28246_1, DEFAULT_DICE_SIDES2, c28246_3;
c28246_1 = void 0;
DEFAULT_DICE_SIDES2 = void 0;
c28246_3 = void 0;
if (SelectedChannelStore.getChannelId() === channelId && DiceRollStore.getState().channelId == null) {
const diceCount2 = diceCount !== 42 ? Math.min(Math.max(diceCount, 1), MAX_DICE_COUNT) : 42;
c28246_1 = diceCount2;
DEFAULT_DICE_SIDES2 = ALLOWED_DICE_SIDES_SET.has(diceSides) ? diceSides : DEFAULT_DICE_SIDES;
DiceRollStore.setState({
channelId,
rolling: true,
diceCount: diceCount2,
diceSides: DEFAULT_DICE_SIDES2,
results: null
});
const r34 = [];
c28246_3 = r34;
let r0 = 0;
while (r0 < diceCount2) {
r34.push(Math.floor(Math.random() * DEFAULT_DICE_SIDES2) + 1);
r0 = r0 + 1;
}
this.rollTimer = setTimeout(() => {
this.rollTimer = null;
this.finishRoll(channelId, c28246_1, DEFAULT_DICE_SIDES2, c28246_3);
}, ROLL_DURATION_MS);
}
};
finishRoll(a0, a1, a2, a3) {
DiceRollStore.setState({
rolling: false,
results: a3
});
this.postRollDismissTimer = setTimeout(() => {
this.postRollDismissTimer = null;
this.dismiss();
}, AFTER_ROLL_DELAY_MS);
this.sendMessage(a0, a1, a2, a3);
}
sendMessage(a0, a1, a2, a3) {
const channel = ChannelStore.getChannel(a0);
if (channel != null) {
let r17 = channel.getGuildId();
if (r17 == null) {
r17 = "@me";
}
const r35 = `${location.protocol}${window.GLOBAL_ENV.WEBAPP_ENDPOINT}/channels/${r17}/${a0}/roll-dice/${a1}d${a2}`;
const r50 = `[\`${intl.formatToPlainString(t.uV5JaG, {
count: a1,
sides: a2
})}\`](${r35})`;
const r62 = intl.formatToMarkdownString(t.tmSbYW, {
total: a3.reduce((acc, item) => acc + item, 0),
count: a1,
sides: a2
});
const r72 = `-# ${a3.map((item) => `:game_die: ${item.toString()}`).join(" ")}`;
MessageActionCreators.sendMessage(a0, MessageParser.parse(channel, a1 === 1 ? `### ${r62} ${r50}` : `### ${r62} ${r50}
${r72}`), true, {
location: MessageSendLocation.CHAT_INPUT
});
}
}
dismiss() {
DiceRollStore.setState({
dismissing: true
});
this.collapseTimer = setTimeout(() => {
this.collapseTimer = null;
DiceRollStore.setState(INITIAL_STATE);
}, DISMISS_DELAY_MS);
}
clearTimers() {
if (this.rollTimer != null) {
clearTimeout(this.rollTimer);
this.rollTimer = null;
}
if (this.postRollDismissTimer != null) {
clearTimeout(this.postRollDismissTimer);
this.postRollDismissTimer = null;
}
if (this.collapseTimer != null) {
clearTimeout(this.collapseTimer);
this.collapseTimer = null;
}
}
}
const diceRollLifecycleManager = new DiceRollLifecycleManager();
export default diceRollLifecycleManager;
+16
View File
@@ -0,0 +1,16 @@
// Metro module 11152 (f11153).
import { create } from "../../_bundle/Module644";
let c7538_0 = {
channelId: null,
rolling: false,
dismissing: false,
diceCount: 1,
diceSides: 6,
results: null
};
let c7538_1 = create(() => c7538_0);
export default c7538_1;
export { c7538_0 as INITIAL_STATE };
export function useDiceRollState(c18565_0) {
return c7538_1((a0) => a0.channelId === c18565_0 ? a0 : null);
}
+7
View File
@@ -0,0 +1,7 @@
// Metro module 11483 (f11484).
import { intl, t } from "../../intl/index.native";
export function getBarText(a0, a1) {
return a0 ? intl.string(t["x/FIRX"]) : a1 == null ? "" : intl.formatToPlainString(t.xU4pF1, {
total: a1.reduce((acc, item) => acc + item, 0)
});
}
+129
View File
@@ -0,0 +1,129 @@
// Metro module 11482 (f11483).
import { useEffect } from "react";
import { View } from "react-native";
import AccessibilityStore from "../../a11y/AccessibilityStore";
import { useDiceRollState } from "../DiceRollStore";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { useStateFromStores } from "../../../_bundle/Module589";
import ReanimatedRexport, { useSharedValue, withRepeat, Easing, useAnimatedStyle } from "../../reanimated/ReanimatedRexport";
import * as _timing from "../../../design/animation/reanimated/timing/timing";
import * as _native from "../../../design/void/native";
import { getBarText } from "../DiceRollUtils";
import { DiceIcon } from "../../../design/components/Icon/native/redesign/generated/DiceIcon";
import { Text } from "../../../design/components/Text/native/Text";
const useStyles = createStyles({
animatedContainer: {
overflow: "hidden"
},
container: {
flexDirection: "row",
alignItems: "center",
paddingHorizontal: 16,
paddingVertical: 8,
gap: 12,
borderTopWidth: 1,
borderColor: Module712.colors.BORDER_SUBTLE,
backgroundColor: Module712.colors.BACKGROUND_SURFACE_HIGH
}
});
const __initData = {
code: "function DiceRollBarTsx1(){const{useReducedMotion,height,opacity,withTiming,ANIMATION_DURATION_MS,DECELERATED_EASING}=this.__closure;if(useReducedMotion){return{height:height.get(),opacity:opacity.get()};}return{height:withTiming(height.get(),{duration:ANIMATION_DURATION_MS,easing:DECELERATED_EASING}),opacity:withTiming(opacity.get(),{duration:ANIMATION_DURATION_MS,easing:DECELERATED_EASING})};}"
};
const __initData2 = {
code: "function DiceRollBarTsx2(){const{rotation}=this.__closure;return{transform:[{rotate:rotation.get()+\"deg\"}]};}"
};
export default function DiceRollBar(props) {
let sharedValue, sharedValue2, sharedValue3, c18885_4, c18885_5;
const channelId = props.channelId;
sharedValue = void 0;
sharedValue2 = void 0;
sharedValue3 = void 0;
c18885_4 = void 0;
c18885_5 = void 0;
const styles = useStyles();
const diceRollState = useDiceRollState(channelId);
const stateFromStores = useStateFromStores([AccessibilityStore], () => AccessibilityStore.useReducedMotion);
sharedValue = useSharedValue(0);
sharedValue2 = useSharedValue(0);
sharedValue3 = useSharedValue(0);
const r2 = diceRollState != null && !diceRollState.dismissing;
c18885_4 = r2;
let r36 = diceRollState?.rolling;
if (r36 == null) {
r36 = false;
}
c18885_5 = r36;
useEffect(() => {
sharedValue.set(c18885_4 ? 56 : 0);
sharedValue2.set(c18885_4 ? 1 : 0);
}, [r2, sharedValue, sharedValue2]);
useEffect(() => {
if (c18885_5 && !stateFromStores) {
sharedValue3.set(withRepeat(_timing.withTiming(360, {
duration: 800,
easing: Easing.linear
}), -1, false));
} else {
sharedValue3.set(0);
}
}, [r36, stateFromStores, sharedValue3]);
const w = function w() {
let r29;
const r2 = {
height: null,
opacity: null
};
if (stateFromStores) {
r2.height = sharedValue.get();
r2.opacity = sharedValue2.get();
r29 = r2;
} else {
r2.height = _timing.withTiming(sharedValue.get(), {
duration: 300,
easing: _native.DECELERATED_EASING
});
r2.opacity = _timing.withTiming(sharedValue2.get(), {
duration: 300,
easing: _native.DECELERATED_EASING
});
r29 = r2;
}
return r29;
};
w.__closure = {
useReducedMotion: stateFromStores,
height: sharedValue,
opacity: sharedValue2,
withTiming: _timing.withTiming,
ANIMATION_DURATION_MS: 300,
DECELERATED_EASING: _native.DECELERATED_EASING
};
w.__workletHash = 2405066513233;
w.__initData = __initData;
const animatedStyle = useAnimatedStyle(w);
const r62 = () => ({
transform: [{
rotate: `${sharedValue3.get()}deg`
}]
});
r62.__closure = {
rotation: sharedValue3
};
r62.__workletHash = 12265072947874;
r62.__initData = __initData2;
const animatedStyle2 = useAnimatedStyle(r62);
if (diceRollState == null) {
return null;
}
return <ReanimatedRexport.View style={[animatedStyle, styles.animatedContainer]}>
<View style={styles.container}>
<ReanimatedRexport.View style={animatedStyle2}>
<DiceIcon size="md" />
</ReanimatedRexport.View>
<Text variant="text-sm/normal" color="text-default">
{getBarText(r36, diceRollState.results)}
</Text>
</View>
</ReanimatedRexport.View>;
};