This commit is contained in:
TheGiddyLimit
2024-05-21 22:49:09 +01:00
parent 9c8ae15ff7
commit d2f2daa34e
58 changed files with 44706 additions and 397 deletions

View File

@@ -189,10 +189,12 @@ class UtilClassesPage {
];
}
return {
type: "gallery",
images: [...images],
};
return [
{
type: "gallery",
images: [...images],
},
];
}
}

View File

@@ -225,9 +225,15 @@ class ItemParser extends BaseParser {
const isGenericWeaponArmor = this._setCleanTaglineInfo_mutIsGenericWeaponArmor({stats, part, partLower, options});
if (isGenericWeaponArmor) continue;
const mBaseWeapon = /^(?<ptPre>weapon|staff) \((?<ptParens>[^)]+)\)$/i.exec(part);
const mBaseWeapon = /^(?<ptPre>weapon|staff|rod) \((?<ptParens>[^)]+)\)$/i.exec(part);
if (mBaseWeapon) {
if (mBaseWeapon.groups.ptPre.toLowerCase() === "staff") stats.staff = true;
if (mBaseWeapon.groups.ptPre.toLowerCase() === "rod") {
if (stats.type) {
throw new Error(`Multiple types! "${stats.type}" -> "${mBaseWeapon.groups.ptParens}"`);
}
stats.type = "RD";
}
if (mBaseWeapon.groups.ptParens === "spear or javelin") {
(stats.requires ||= []).push(...this._setCleanTaglineInfo_getGenericRequires({stats, str: "spear", options}));

View File

@@ -373,7 +373,7 @@ class RenderMap {
`);
});
const $wrpCvs = $$`<div class="w-100 h-100 ve-overflow-x-scroll ve-overflow-y-scroll rd__scroller-viewer">
const $wrpCvs = $$`<div class="w-100 h-100 ve-overflow-x-scroll ve-overflow-y-scroll rd__scroller-viewer ${mapData.expectsLightBackground ? "rd__scroller-viewer--bg-light" : mapData.expectsDarkBackground ? "rd__scroller-viewer--bg-dark" : ""}">
${$cvs}
</div>`
.on("mousewheel DOMMouseScroll", evt => {

View File

@@ -581,6 +581,11 @@ globalThis.Renderer = function () {
page: entry.page,
source: entry.source,
hash: entry.hash,
...entry.expectsLightBackground
? {expectsLightBackground: true}
: entry.expectsDarkBackground
? {expectsDarkBackground: true}
: {},
};
};
@@ -591,6 +596,8 @@ globalThis.Renderer = function () {
this._renderImage_getWrapperClasses = function (entry) {
const out = ["rd__wrp-image", "relative"];
if (entry.expectsLightBackground) out.push("rd__wrp-image--bg", "rd__wrp-image--bg-light");
else if (entry.expectsDarkBackground) out.push("rd__wrp-image--bg", "rd__wrp-image--bg-dark");
if (entry.style) {
switch (entry.style) {
case "comic-speaker-left": out.push("rd__comic-img-speaker", "rd__comic-img-speaker--left"); break;
@@ -10138,12 +10145,21 @@ Renderer.vehicle = class {
static getVehicleInfwarRenderableEntriesMeta (ent) {
const dexMod = Parser.getAbilityModNumber(ent.dex);
const ptDtMt = [
ent.hp.dt != null ? `damage threshold ${ent.hp.dt}` : null,
ent.hp.mt != null ? `ishap threshold ${ent.hp.mt}` : null,
]
.filter(Boolean)
.join(", ");
const ptAc = ent.ac ?? dexMod === 0 ? `19` : `${19 + dexMod} (19 while motionless)`;
return {
entrySizeWeight: `{@i ${Parser.sizeAbvToFull(ent.size)} vehicle (${ent.weight.toLocaleString()} lb.)}`,
entryCreatureCapacity: `{@b Creature Capacity} ${Renderer.vehicle.getInfwarCreatureCapacity(ent)}`,
entryCargoCapacity: `{@b Cargo Capacity} ${Parser.weightToFull(ent.capCargo)}`,
entryArmorClass: `{@b Armor Class} ${dexMod === 0 ? `19` : `${19 + dexMod} (19 while motionless)`}`,
entryHitPoints: `{@b Hit Points} ${ent.hp.hp} (damage threshold ${ent.hp.dt}, mishap threshold ${ent.hp.mt})`,
entryArmorClass: `{@b Armor Class} ${ptAc}`,
entryHitPoints: `{@b Hit Points} ${ent.hp.hp}${ptDtMt ? ` (${ptDtMt})` : ""}`,
entrySpeed: `{@b Speed} ${ent.speed} ft.`,
entrySpeedNote: `[{@b Travel Pace} ${Math.floor(ent.speed / 10)} miles per hour (${Math.floor(ent.speed * 24 / 10)} miles per day)]`,
entrySpeedNoteTitle: `Based on "Special Travel Pace," DMG p242`,

View File

@@ -420,6 +420,7 @@ PropOrder._GENERIC_FLUFF = [
];
PropOrder._SPELL = [
"name",
"alias",
"source",
"page",
@@ -536,6 +537,7 @@ PropOrder._SPELL_LIST = [
];
PropOrder._ACTION = [
"name",
"alias",
"source",
"page",
@@ -608,6 +610,7 @@ PropOrder._BOOK_DATA = [
];
PropOrder._BACKGROUND = [
"name",
"alias",
"source",
"page",
@@ -662,6 +665,8 @@ PropOrder._BACKGROUND__COPY_MOD = [
];
PropOrder._LEGENDARY_GROUP = [
"name",
"alias",
"source",
"page",
@@ -680,6 +685,7 @@ PropOrder._LEGENDARY_GROUP__COPY_MOD = [
];
PropOrder._CLASS = [
"name",
"alias",
"source",
"page",
@@ -853,6 +859,7 @@ PropOrder._ENTRY_DATA_OBJECT = [
];
PropOrder._CLASS_FEATURE = [
"name",
"alias",
"source",
"page",
@@ -881,6 +888,7 @@ PropOrder._CLASS_FEATURE = [
];
PropOrder._SUBCLASS_FEATURE = [
"name",
"alias",
"source",
"page",
@@ -973,6 +981,8 @@ PropOrder._FOUNDRY_SUBCLASS_FEATURE = [
];
PropOrder._LANGUAGE = [
"name",
"alias",
"dialects",
"source",
@@ -1013,6 +1023,7 @@ PropOrder._NAME = [
];
PropOrder._CONDITION = [
"name",
"alias",
"source",
"page",
@@ -1031,6 +1042,7 @@ PropOrder._CONDITION = [
];
PropOrder._DISEASE = [
"name",
"alias",
"source",
"page",
@@ -1048,6 +1060,7 @@ PropOrder._DISEASE = [
];
PropOrder._STATUS = [
"name",
"alias",
"source",
"page",
@@ -1060,6 +1073,7 @@ PropOrder._STATUS = [
];
PropOrder._CULT = [
"name",
"alias",
"source",
"page",
@@ -1079,6 +1093,7 @@ PropOrder._CULT = [
];
PropOrder._BOON = [
"name",
"alias",
"source",
"page",
@@ -1100,6 +1115,7 @@ PropOrder._BOON = [
];
PropOrder._DEITY = [
"name",
"alias",
"reprintAlias",
"altNames",
@@ -1153,6 +1169,7 @@ PropOrder._DEITY__COPY_MOD = [
];
PropOrder._FEAT = [
"name",
"alias",
"source",
"page",
@@ -1206,6 +1223,7 @@ PropOrder._FEAT__COPY_MOD = [
];
PropOrder._VEHICLE = [
"name",
"alias",
"source",
"page",
@@ -1279,6 +1297,7 @@ PropOrder._VEHICLE = [
];
PropOrder._VEHICLE_UPGRADE = [
"name",
"alias",
"source",
"page",
@@ -1513,6 +1532,7 @@ PropOrder._ITEM_MASTERY = [
];
PropOrder._OBJECT = [
"name",
"alias",
"isNpc",
@@ -1560,6 +1580,7 @@ PropOrder._OBJECT = [
];
PropOrder._OPTIONALFEATURE = [
"name",
"alias",
"source",
"page",
@@ -1613,6 +1634,7 @@ PropOrder._OPTIONALFEATURE__COPY_MOD = [
];
PropOrder._PSIONIC = [
"name",
"alias",
"source",
"page",
@@ -1627,6 +1649,7 @@ PropOrder._PSIONIC = [
];
PropOrder._REWARD = [
"name",
"alias",
"source",
"page",
@@ -1646,6 +1669,7 @@ PropOrder._REWARD = [
];
PropOrder._VARIANTRULE = [
"name",
"alias",
"source",
"page",
@@ -1782,6 +1806,7 @@ PropOrder._FOUNDRY_RACE_FEATURE__COPY_MOD = [
];
PropOrder._TABLE = [
"name",
"alias",
"source",
"page",
@@ -1812,6 +1837,7 @@ PropOrder._TABLE = [
];
PropOrder._TRAP = [
"name",
"alias",
"source",
"page",
@@ -1845,6 +1871,7 @@ PropOrder._TRAP = [
];
PropOrder._HAZARD = [
"name",
"alias",
"source",
"page",
@@ -1897,6 +1924,7 @@ PropOrder._RECIPE = [
];
PropOrder._CHAROPTION = [
"name",
"alias",
"source",
"page",
@@ -1916,6 +1944,7 @@ PropOrder._CHAROPTION = [
];
PropOrder._SKILL = [
"name",
"alias",
"source",
"page",
@@ -1926,6 +1955,7 @@ PropOrder._SKILL = [
];
PropOrder._SENSE = [
"name",
"alias",
"source",
"page",
@@ -1936,6 +1966,7 @@ PropOrder._SENSE = [
];
PropOrder._DECK = [
"name",
"alias",
"source",
"page",
@@ -2010,6 +2041,15 @@ PropOrder._CITATION = [
"entries",
];
PropOrder._FOUNDRY_MAP = [
"name",
"source",
"lights",
"walls",
];
PropOrder._PROP_TO_LIST = {
"_meta": PropOrder._META,
"monster": PropOrder._MONSTER,
@@ -2099,6 +2139,7 @@ PropOrder._PROP_TO_LIST = {
"card": PropOrder._CARD,
"encounter": PropOrder._ENCOUNTER,
"citation": PropOrder._CITATION,
"foundryMap": PropOrder._FOUNDRY_MAP,
};
globalThis.PropOrder = PropOrder;

View File

@@ -5088,17 +5088,33 @@ class ComponentUiUtil {
* @param [opts.isDisabled] If the selector should be display-only
* @return {jQuery}
*/
static $getSelSearchable (comp, prop, opts) {
opts = opts || {};
static $getSelSearchable (
comp,
prop,
{
values,
isHiddenPerValue,
$ele,
html,
isAllowNull,
fnDisplay,
displayNullAs,
fnGetAdditionalStyleClasses,
asMeta,
isDisabled,
propProxy = "state",
} = {},
) {
const _propProxy = `_${propProxy}`;
const $iptDisplay = (opts.$ele || $(opts.html || `<input class="form-control input-xs form-control--minimal">`))
const $iptDisplay = ($ele || $(html || `<input class="form-control input-xs form-control--minimal">`))
.addClass("ui-sel2__ipt-display")
.attr("tabindex", "-1")
.click(() => {
if (opts.isDisabled) return;
if (isDisabled) return;
$iptSearch.focus().select();
})
.prop("disabled", !!opts.isDisabled)
.prop("disabled", !!isDisabled)
.disableSpellcheck();
const handleSearchChange = () => {
@@ -5110,10 +5126,10 @@ class ComponentUiUtil {
};
const handleSearchChangeDebounced = MiscUtil.debounce(handleSearchChange, 30);
const $iptSearch = (opts.$ele || $(opts.html || `<input class="form-control input-xs form-control--minimal">`))
const $iptSearch = ($ele || $(html || `<input class="form-control input-xs form-control--minimal">`))
.addClass("absolute ui-sel2__ipt-search")
.keydown(evt => {
if (opts.isDisabled) return;
if (isDisabled) return;
switch (evt.key) {
case "Escape": evt.stopPropagation(); return $iptSearch.blur();
@@ -5140,10 +5156,10 @@ class ComponentUiUtil {
})
.change(() => handleSearchChangeDebounced())
.click(() => {
if (opts.isDisabled) return;
if (isDisabled) return;
$iptSearch.focus().select();
})
.prop("disabled", !!opts.isDisabled)
.prop("disabled", !!isDisabled)
.disableSpellcheck();
const $wrpChoices = $(`<div class="absolute ui-sel2__wrp-options ve-overflow-y-scroll"></div>`);
@@ -5155,74 +5171,112 @@ class ComponentUiUtil {
<div class="ui-sel2__disp-arrow absolute no-events bold"><span class="glyphicon glyphicon-menu-down"></span></div>
</div>`;
const procValues = opts.isAllowNull ? [null, ...opts.values] : opts.values;
const metaOptions = procValues.map((v, i) => {
const display = v == null ? (opts.displayNullAs || "\u2014") : opts.fnDisplay ? opts.fnDisplay(v) : v;
const additionalStyleClasses = opts.fnGetAdditionalStyleClasses ? opts.fnGetAdditionalStyleClasses(v) : null;
let metaOptions = [];
const $ele = $(`<div class="ve-flex-v-center py-1 px-1 clickable ui-sel2__disp-option ${v == null ? `italic` : ""} ${additionalStyleClasses ? additionalStyleClasses.join(" ") : ""}" tabindex="0">${display}</div>`)
.click(() => {
if (opts.isDisabled) return;
const hk = () => {
if (comp._state[prop] == null) $iptDisplay.addClass("italic").addClass("ve-muted").val(displayNullAs || "\u2014");
else $iptDisplay.removeClass("italic").removeClass("ve-muted").val(fnDisplay ? fnDisplay(comp._state[prop]) : comp._state[prop]);
comp._state[prop] = v;
$(document.activeElement).blur();
// Temporarily remove pointer events from the dropdown, so it collapses thanks to its :hover CSS
$wrp.addClass("no-events");
setTimeout(() => $wrp.removeClass("no-events"), 50);
})
.keydown(evt => {
if (opts.isDisabled) return;
metaOptions.forEach(it => it.$ele.removeClass("active"));
const metaActive = metaOptions.find(it => it.value == null ? comp._state[prop] == null : it.value === comp._state[prop]);
if (metaActive) metaActive.$ele.addClass("active");
};
comp._addHookBase(prop, hk);
switch (evt.key) {
case "Escape": evt.stopPropagation(); return $ele.blur();
let values_;
const setValues = (nxtValues, {isResetOnMissing = false, isForce = false} = {}) => {
if (!isForce && CollectionUtil.deepEquals(values_, nxtValues)) return;
values_ = nxtValues;
case "ArrowDown": {
evt.preventDefault();
const visibleMetaOptions = metaOptions.filter(it => it.isVisible && !it.isForceHidden);
if (!visibleMetaOptions.length) return;
const ixCur = visibleMetaOptions.indexOf(out);
const nxt = visibleMetaOptions[ixCur + 1];
if (nxt) nxt.$ele.focus();
break;
}
metaOptions
.forEach(metaOption => {
metaOption.$ele.remove();
});
case "ArrowUp": {
evt.preventDefault();
const visibleMetaOptions = metaOptions.filter(it => it.isVisible && !it.isForceHidden);
if (!visibleMetaOptions.length) return;
const ixCur = visibleMetaOptions.indexOf(out);
const prev = visibleMetaOptions[ixCur - 1];
if (prev) return prev.$ele.focus();
$iptSearch.focus();
break;
}
const procValues = isAllowNull ? [null, ...nxtValues] : nxtValues;
metaOptions = procValues
.map((v, i) => {
const display = v == null ? (displayNullAs || "\u2014") : fnDisplay ? fnDisplay(v) : v;
const additionalStyleClasses = fnGetAdditionalStyleClasses ? fnGetAdditionalStyleClasses(v) : null;
const $ele = $(`<div class="ve-flex-v-center py-1 px-1 clickable ui-sel2__disp-option ${v == null ? `italic` : ""} ${additionalStyleClasses ? additionalStyleClasses.join(" ") : ""}" tabindex="0">${display}</div>`)
.on("click", () => {
if (isDisabled) return;
case "Enter": {
comp._state[prop] = v;
$ele.blur();
break;
}
}
})
.appendTo($wrpChoices);
$(document.activeElement).blur();
// Temporarily remove pointer events from the dropdown, so it collapses thanks to its :hover CSS
$wrp.addClass("no-events");
setTimeout(() => $wrp.removeClass("no-events"), 50);
})
.on("keydown", evt => {
if (isDisabled) return;
const isForceHidden = opts.isHiddenPerValue && !!(opts.isAllowNull ? opts.isHiddenPerValue[i - 1] : opts.isHiddenPerValue[i]);
if (isForceHidden) $ele.hideVe();
switch (evt.key) {
case "Escape": evt.stopPropagation(); return $ele.blur();
const out = {
value: v,
isVisible: true,
isForceHidden,
searchTerm: this._$getSelSearchable_getSearchString(display),
$ele,
};
return out;
});
case "ArrowDown": {
evt.preventDefault();
const visibleMetaOptions = metaOptions.filter(it => it.isVisible && !it.isForceHidden);
if (!visibleMetaOptions.length) return;
const ixCur = visibleMetaOptions.indexOf(out);
const nxt = visibleMetaOptions[ixCur + 1];
if (nxt) nxt.$ele.focus();
break;
}
case "ArrowUp": {
evt.preventDefault();
const visibleMetaOptions = metaOptions.filter(it => it.isVisible && !it.isForceHidden);
if (!visibleMetaOptions.length) return;
const ixCur = visibleMetaOptions.indexOf(out);
const prev = visibleMetaOptions[ixCur - 1];
if (prev) return prev.$ele.focus();
$iptSearch.focus();
break;
}
case "Enter": {
comp._state[prop] = v;
$ele.blur();
break;
}
}
})
.appendTo($wrpChoices);
const isForceHidden = isHiddenPerValue && !!(isAllowNull ? isHiddenPerValue[i - 1] : isHiddenPerValue[i]);
if (isForceHidden) $ele.hideVe();
const out = {
value: v,
isVisible: true,
isForceHidden,
searchTerm: this._$getSelSearchable_getSearchString(display),
$ele,
};
return out;
});
this._$getSel_setValues_handleResetOnMissing({
component: comp,
_propProxy,
prop,
isResetOnMissing,
nxtValues,
isAllowNull,
});
hk();
};
setValues(values);
const fnUpdateHidden = (isHiddenPerValue, isHideNull = false) => {
let metaOptions_ = metaOptions;
if (opts.isAllowNull) {
if (isAllowNull) {
metaOptions_[0].isForceHidden = isHideNull;
metaOptions_ = metaOptions_.slice(1);
}
@@ -5231,24 +5285,14 @@ class ComponentUiUtil {
handleSearchChange();
};
const hk = () => {
if (comp._state[prop] == null) $iptDisplay.addClass("italic").addClass("ve-muted").val(opts.displayNullAs || "\u2014");
else $iptDisplay.removeClass("italic").removeClass("ve-muted").val(opts.fnDisplay ? opts.fnDisplay(comp._state[prop]) : comp._state[prop]);
metaOptions.forEach(it => it.$ele.removeClass("active"));
const metaActive = metaOptions.find(it => it.value == null ? comp._state[prop] == null : it.value === comp._state[prop]);
if (metaActive) metaActive.$ele.addClass("active");
};
comp._addHookBase(prop, hk);
hk();
return opts.asMeta
return asMeta
? ({
$wrp,
unhook: () => comp._removeHookBase(prop, hk),
$iptDisplay,
$iptSearch,
fnUpdateHidden,
setValues,
})
: $wrp;
}
@@ -5258,6 +5302,37 @@ class ComponentUiUtil {
return CleanUtil.getCleanString(str.trim().toLowerCase().replace(/\s+/g, " "));
}
// If the new value list doesn't contain our current value, reset our current value
static _$getSel_setValues_handleResetOnMissing (
{
component,
_propProxy,
prop,
isResetOnMissing,
nxtValues,
isSetIndexes,
isAllowNull,
},
) {
if (!isResetOnMissing) return;
if (component[_propProxy][prop] == null) return;
if (isSetIndexes) {
if (component[_propProxy][prop] >= 0 && component[_propProxy][prop] < nxtValues.length) {
if (isAllowNull) return component[_propProxy][prop] = null;
return component[_propProxy][prop] = 0;
}
return;
}
if (!nxtValues.includes(component[_propProxy][prop])) {
if (isAllowNull) return component[_propProxy][prop] = null;
return component[_propProxy][prop] = nxtValues[0];
}
}
/**
* @param component An instance of a class which extends BaseComponent.
* @param prop Component to hook on.
@@ -5272,7 +5347,21 @@ class ComponentUiUtil {
* @param [opts.propProxy] Proxy prop.
* @param [opts.isSetIndexes] If the index of the selected item should be set as state, rather than the item itself.
*/
static $getSelEnum (component, prop, {values, $ele, html, isAllowNull, fnDisplay, displayNullAs, asMeta, propProxy = "state", isSetIndexes = false} = {}) {
static $getSelEnum (
component,
prop,
{
values,
$ele,
html,
isAllowNull,
fnDisplay,
displayNullAs,
asMeta,
propProxy = "state",
isSetIndexes = false,
} = {},
) {
const _propProxy = `_${propProxy}`;
let values_;
@@ -5289,27 +5378,6 @@ class ComponentUiUtil {
component[_propProxy][prop] = isSetIndexes ? 0 : values_[0];
});
// If the new value list doesn't contain our current value, reset our current value
const setValues_handleResetOnMissing = ({isResetOnMissing, nxtValues}) => {
if (!isResetOnMissing) return;
if (component[_propProxy][prop] == null) return;
if (isSetIndexes) {
if (component[_propProxy][prop] >= 0 && component[_propProxy][prop] < nxtValues.length) {
if (isAllowNull) return component[_propProxy][prop] = null;
return component[_propProxy][prop] = 0;
}
return;
}
if (!nxtValues.includes(component[_propProxy][prop])) {
if (isAllowNull) return component[_propProxy][prop] = null;
return component[_propProxy][prop] = nxtValues[0];
}
};
const setValues = (nxtValues, {isResetOnMissing = false, isForce = false} = {}) => {
if (!isForce && CollectionUtil.deepEquals(values_, nxtValues)) return;
values_ = nxtValues;
@@ -5318,7 +5386,15 @@ class ComponentUiUtil {
if (isAllowNull) { const opt = document.createElement("option"); opt.value = "-1"; opt.text = displayNullAs || "\u2014"; $sel.append(opt); }
values_.forEach((it, i) => { const opt = document.createElement("option"); opt.value = `${i}`; opt.text = fnDisplay ? fnDisplay(it) : it; $sel.append(opt); });
setValues_handleResetOnMissing({isResetOnMissing, nxtValues});
this._$getSel_setValues_handleResetOnMissing({
component,
_propProxy,
prop,
isResetOnMissing,
nxtValues,
isSetIndexes,
isAllowNull,
});
hook();
};

View File

@@ -2,7 +2,7 @@
// in deployment, `IS_DEPLOYED = "<version number>";` should be set below.
globalThis.IS_DEPLOYED = undefined;
globalThis.VERSION_NUMBER = /* 5ETOOLS_VERSION__OPEN */"1.206.1"/* 5ETOOLS_VERSION__CLOSE */;
globalThis.VERSION_NUMBER = /* 5ETOOLS_VERSION__OPEN */"1.207.0"/* 5ETOOLS_VERSION__CLOSE */;
globalThis.DEPLOYED_IMG_ROOT = undefined;
// for the roll20 script to set
globalThis.IS_VTT = false;
@@ -4945,7 +4945,16 @@ globalThis.DataUtil = {
return DataUtil.generic._getVersions_basic({ver});
})
.flat()
.map(ver => DataUtil.generic._getVersion({parentEntity: parent, version: ver, impl, isExternalApplicationIdentityOnly}));
.map(ver => DataUtil.generic._getVersion({parentEntity: parent, version: ver, impl, isExternalApplicationIdentityOnly}))
.filter(ver => {
if (!UrlUtil.URL_TO_HASH_BUILDER[ver.__prop]) throw new Error(`Unhandled version prop "${ver.__prop}"!`);
return !ExcludeUtil.isExcluded(
UrlUtil.URL_TO_HASH_BUILDER[ver.__prop](ver),
ver.__prop,
SourceUtil.getEntitySource(ver),
{isNoCount: true},
);
});
},
_getVersions_template ({ver}) {
@@ -4997,6 +5006,7 @@ globalThis.DataUtil = {
_versionBase_hasToken: parentEntity.hasToken,
_versionBase_hasFluff: parentEntity.hasFluff,
_versionBase_hasFluffImages: parentEntity.hasFluffImages,
__prop: parentEntity.__prop,
};
const cpyParentEntity = MiscUtil.copyFast(parentEntity);
@@ -5005,6 +5015,12 @@ globalThis.DataUtil = {
delete cpyParentEntity.hasFluff;
delete cpyParentEntity.hasFluffImages;
["additionalSources", "otherSources"]
.forEach(prop => {
if (cpyParentEntity[prop]?.length) cpyParentEntity[prop] = cpyParentEntity[prop].filter(srcMeta => srcMeta.source !== version.source);
if (!cpyParentEntity[prop]?.length) delete cpyParentEntity[prop];
});
DataUtil.generic.copyApplier.getCopy(
impl,
cpyParentEntity,
@@ -7495,15 +7511,15 @@ globalThis.ExcludeUtil = {
};
// EXTENSIONS ==========================================================================================================
globalThis.ExtensionUtil = {
ACTIVE: false,
globalThis.ExtensionUtil = class {
static ACTIVE = false;
_doSend (type, data) {
static _doSend (type, data) {
const detail = MiscUtil.copy({type, data}); // Note that this needs to include `JSON.parse` to function
window.dispatchEvent(new CustomEvent("rivet.send", {detail}));
},
}
async pDoSendStats (evt, ele) {
static async pDoSendStats (evt, ele) {
const {page, source, hash, extensionData} = ExtensionUtil._getElementData({ele});
if (page && source && hash) {
@@ -7522,9 +7538,9 @@ globalThis.ExtensionUtil = {
ExtensionUtil._doSend("entity", {page, entity: toSend, isTemp: !!evt.shiftKey});
}
},
}
async doDragStart (evt, ele) {
static async doDragStart (evt, ele) {
const {page, source, hash} = ExtensionUtil._getElementData({ele});
const meta = {
type: VeCt.DRAG_TYPE_IMPORT,
@@ -7533,9 +7549,9 @@ globalThis.ExtensionUtil = {
hash,
};
evt.dataTransfer.setData("application/json", JSON.stringify(meta));
},
}
_getElementData ({ele}) {
static _getElementData ({ele}) {
const $parent = $(ele).closest(`[data-page]`);
const page = $parent.attr("data-page");
const source = $parent.attr("data-source");
@@ -7544,31 +7560,31 @@ globalThis.ExtensionUtil = {
const extensionData = rawExtensionData ? JSON.parse(rawExtensionData) : null;
return {page, source, hash, extensionData};
},
}
pDoSendStatsPreloaded ({page, entity, isTemp, options}) {
static pDoSendStatsPreloaded ({page, entity, isTemp, options}) {
ExtensionUtil._doSend("entity", {page, entity, isTemp, options});
},
}
pDoSendCurrency ({currency}) {
static pDoSendCurrency ({currency}) {
ExtensionUtil._doSend("currency", {currency});
},
}
doSendRoll (data) { ExtensionUtil._doSend("roll", data); },
static doSendRoll (data) { ExtensionUtil._doSend("roll", data); }
pDoSend ({type, data}) { ExtensionUtil._doSend(type, data); },
static pDoSend ({type, data}) { ExtensionUtil._doSend(type, data); }
/* -------------------------------------------- */
_CACHE_EMBEDDED_STATS: {},
static _CACHE_EMBEDDED_STATS = {};
addEmbeddedToCache (page, source, hash, ent) {
static addEmbeddedToCache (page, source, hash, ent) {
MiscUtil.set(ExtensionUtil._CACHE_EMBEDDED_STATS, page.toLowerCase(), source.toLowerCase(), hash.toLowerCase(), MiscUtil.copyFast(ent));
},
}
_getEmbeddedFromCache (page, source, hash) {
static _getEmbeddedFromCache (page, source, hash) {
return MiscUtil.get(ExtensionUtil._CACHE_EMBEDDED_STATS, page.toLowerCase(), source.toLowerCase(), hash.toLowerCase());
},
}
/* -------------------------------------------- */
};