Grabbed dndbeyond's source code

```
~/go/bin/sourcemapper -output ddb -jsurl https://media.dndbeyond.com/character-app/static/js/main.90aa78c5.js
```
This commit is contained in:
2025-05-28 11:50:03 -07:00
commit 8df9031d27
3592 changed files with 319051 additions and 0 deletions
@@ -0,0 +1,78 @@
import {
CharClass,
ClassUtils,
Extra,
ExtraUtils,
Item,
ItemUtils,
Spell,
SpellUtils,
} from "@dndbeyond/character-rules-engine/es";
import { AppNotificationUtils } from "../../utils";
export function handleItemAddAccepted(item: Item, amount: number): void {
if (ItemUtils.isPack(item)) {
AppNotificationUtils.dispatchSuccess(
"Equipment Pack Added",
`${ItemUtils.getName(item)} items added to your inventory`
);
} else {
if (amount >= 1) {
let itemName = ItemUtils.getDefinitionName(item);
let displayName = itemName ? `"${itemName}"` : "unknown";
let toastMessage = `Added ${displayName} item`;
if (amount > 1) {
toastMessage = `Added ${amount} ${displayName} items`;
}
AppNotificationUtils.dispatchSuccess("Equipment Added", toastMessage);
}
}
}
export function handleItemAddRejected(item: Item, amount: number): void {
AppNotificationUtils.dispatchError(
"Equipment Not Added",
`${ItemUtils.getName(item)} could not be added to your inventory`
);
}
export function handleStartingEquipmentAccepted(): void {
AppNotificationUtils.dispatchSuccess(
"Equipment Chosen",
"Starting Equipment Added to Inventory"
);
}
export function handleStartingEquipmentRejected(): void {
AppNotificationUtils.dispatchSuccess(
"Starting Equipment Skipped",
"No items added to inventory"
);
}
export function handleStartingGoldAccepted(): void {
AppNotificationUtils.dispatchSuccess(
"Gold Added",
"Starting Gold Added to Currencies Section"
);
}
export function handleSpellCreateAccepted(
spell: Spell,
charClass: CharClass
): void {
AppNotificationUtils.dispatchSuccess(
"Spell Added",
`Added ${SpellUtils.getName(spell)} spell to your ${ClassUtils.getName(
charClass
)}`
);
}
//TODO Extras - move into manager somehow?
export function handleExtraCreateAccepted(extra: Extra): void {
AppNotificationUtils.dispatchSuccess(
`${ExtraUtils.getExtraType(extra)} Added`,
`Added "${ExtraUtils.getName(extra)}"`
);
}
@@ -0,0 +1,52 @@
import { Constants } from "@dndbeyond/character-rules-engine/es";
import { toastMessageActions } from "../../actions/toastMessage";
import { StateStoreUtils } from "../../stores";
/**
*
* @param title
* @param message
* @param notificationType
*/
export function dispatchNotification(
title: string,
message: string,
notificationType: Constants.NotificationTypeEnum
): void {
const store = StateStoreUtils.getAppStore();
if (store) {
switch (notificationType) {
case Constants.NotificationTypeEnum.ERROR:
case Constants.NotificationTypeEnum.CRITICAL:
store.dispatch(toastMessageActions.toastError(title, message));
break;
default:
store.dispatch(toastMessageActions.toastSuccess(title, message));
}
}
}
/**
*
* @param title
* @param message
*/
export function dispatchSuccess(title: string, message: string): void {
const store = StateStoreUtils.getAppStore();
if (store) {
store.dispatch(toastMessageActions.toastSuccess(title, message));
}
}
/**
*
* @param title
* @param message
*/
export function dispatchError(title: string, message: string): void {
const store = StateStoreUtils.getAppStore();
if (store) {
store.dispatch(toastMessageActions.toastError(title, message));
}
}