This commit is contained in:
Mirco Wittrien 2022-09-27 11:53:04 +02:00
parent fb82b04e19
commit 2efb3ed07f
14 changed files with 42 additions and 30 deletions

View File

@ -1239,9 +1239,15 @@ module.exports = (_ => {
const found = [];
if (!onlySearchUnloaded) for (let i in req.c) if (req.c.hasOwnProperty(i)) {
let m = req.c[i].exports, r = null;
if (m && (typeof m == "object" || typeof m == "function") && !!(r = filter(m))) {
if (all) found.push(defaultExport ? r : req.c[i]);
else return defaultExport ? r : req.c[i];
if (m && (typeof m == "object" || typeof m == "function")) {
if (!!(r = filter(m))) {
if (all) found.push(defaultExport ? r : req.c[i]);
else return defaultExport ? r : req.c[i];
}
else for (let key of Object.keys(m)) if (key.length < 3 && m[key] && !!(r = filter(m[key]))) {
if (all) found.push(defaultExport ? r : req.c[i]);
else return defaultExport ? r : req.c[i];
}
}
if (m && m.__esModule && m.default && (typeof m.default == "object" || typeof m.default == "function")) {
if (!!(r = filter(m.default))) {
@ -2149,7 +2155,7 @@ module.exports = (_ => {
Internal.initiateProcess = function (plugin, type, e) {
plugin = plugin == BDFDB && Internal || plugin;
if (BDFDB.ObjectUtils.is(plugin) && !plugin.stopping && e.instance) {
type = Internal.LibraryModules.StringUtils.upperCaseFirstChar(type.split(" _ _ ")[1] || type).replace(/[^A-z0-9]|_/g, "");
type = BDFDB.StringUtils.upperCaseFirstChar(type.split(" _ _ ")[1] || type).replace(/[^A-z0-9]|_/g, "");
if (typeof plugin[`process${type}`] == "function") {
if (typeof e.methodname == "string" && (e.methodname.indexOf("componentDid") == 0 || e.methodname.indexOf("componentWill") == 0)) {
e.node = BDFDB.ReactUtils.findDOMNode(e.instance);
@ -2567,7 +2573,7 @@ module.exports = (_ => {
BDFDB.LibraryRequires = Internal.LibraryRequires;
LibraryModules = {};
LibraryModules.LanguageStore = BDFDB.ModuleUtils.find(m => (m.Messages && m.Messages.IMAGE || m.IMAGE && m.CHANGE_LOG) && m);
LibraryModules.LanguageStore = BDFDB.ModuleUtils.find(m => m.Messages && m.Messages.IMAGE && m);
LibraryModules.React = BDFDB.ModuleUtils.findByProperties("createElement", "cloneElement");
LibraryModules.ReactDOM = BDFDB.ModuleUtils.findByProperties("render", "findDOMNode");
Internal.LibraryModules = new Proxy(LibraryModules, {
@ -4166,6 +4172,10 @@ module.exports = (_ => {
};
BDFDB.StringUtils = {};
BDFDB.StringUtils.upperCaseFirstChar = function (string) {
if (typeof string != "string") return "";
else return string.slice(0, 1).toUpperCase() + string.slice(1);
};
BDFDB.StringUtils.htmlEscape = function (string) {
let ele = document.createElement("div");
ele.innerText = string;
@ -4361,7 +4371,7 @@ module.exports = (_ => {
}
};
BDFDB.DiscordUtils.getLanguage = function () {
return Internal.LibraryModules.LanguageStore && (Internal.LibraryModules.LanguageStore.chosenLocale || Internal.LibraryModules.LanguageStore._chosenLocale) || document.querySelector("html[lang]").getAttribute("lang") || BDFDB.DicordUtils.getSettings("locale");
return Internal.LibraryModules.LanguageStore && (Internal.LibraryModules.LanguageStore.chosenLocale || Internal.LibraryModules.LanguageStore._chosenLocale) || document.querySelector("html[lang]").getAttribute("lang");
};
BDFDB.DiscordUtils.getBuild = function () {
if (BDFDB.DiscordUtils.getBuild.build) return BDFDB.DiscordUtils.getBuild.build;
@ -8441,8 +8451,8 @@ module.exports = (_ => {
const getProps = (props, keys) => {
let newProps = Object.assign({}, BDFDB.ObjectUtils.is(props) ? props : typeof props == "string" ? {id: props} : {});
for (const key of [keys].flat(10).filter(n => n)) {
const store = `${Internal.LibraryModules.StringUtils.upperCaseFirstChar(key)}Store`;
const getter = `get${Internal.LibraryModules.StringUtils.upperCaseFirstChar(key)}`;
const store = `${BDFDB.StringUtils.upperCaseFirstChar(key)}Store`;
const getter = `get${BDFDB.StringUtils.upperCaseFirstChar(key)}`;
const value = props && props[key] || Internal.LibraryModules[store] && typeof Internal.LibraryModules[store][getter] == "function" && Internal.LibraryModules[store][getter](props && props.id || props);
if (value) {
newProps = Object.assign(newProps, {[key]: value});
@ -8853,7 +8863,7 @@ module.exports = (_ => {
if (!lang) {
let formatTranslation = (l, s, i) => {
l = l == "en" ? "default" : l;
return config.cached && config.cached[l] && config.cached[l][stringKeys[i]] || (translations[language][i][0] == translations[language][i][0].toUpperCase() ? Internal.LibraryModules.StringUtils.upperCaseFirstChar(s) : s);
return config.cached && config.cached[l] && config.cached[l][stringKeys[i]] || (translations[language][i][0] == translations[language][i][0].toUpperCase() ? BDFDB.StringUtils.upperCaseFirstChar(s) : s);
};
let format = config.asObject ? ((l, isNotFirst) => {
return `${isNotFirst ? "," : ""}\n\t\t"${l == "en" ? "default" : l}": {${translations[l].map((s, i) => `\n\t\t\t"${stringKeys[i]}": "${formatTranslation(l, s, i)}"`).join(",")}\n\t\t}`;
@ -8963,7 +8973,7 @@ module.exports = (_ => {
getSettingsPanel (collapseStates = {}) {
let settingsPanel;
let getString = (type, key, property) => {
return BDFDB.LanguageUtils.LibraryStringsCheck[`settings_${key}_${property}`] ? BDFDB.LanguageUtils.LibraryStringsFormat(`settings_${key}_${property}`, BDFDB.BDUtils.getSettingsProperty("name", BDFDB.BDUtils.settingsIds[key]) || Internal.LibraryModules.StringUtils.upperCaseFirstChar(key.replace(/([A-Z])/g, " $1"))) : Internal.defaults[type][key][property];
return BDFDB.LanguageUtils.LibraryStringsCheck[`settings_${key}_${property}`] ? BDFDB.LanguageUtils.LibraryStringsFormat(`settings_${key}_${property}`, BDFDB.BDUtils.getSettingsProperty("name", BDFDB.BDUtils.settingsIds[key]) || BDFDB.StringUtils.upperCaseFirstChar(key.replace(/([A-Z])/g, " $1"))) : Internal.defaults[type][key][property];
};
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(BDFDB, {
collapseStates: collapseStates,

View File

@ -16,6 +16,9 @@
"Timestamp": {"props": ["add", "dayOfYear", "hasAlignedHourOffset"]},
"User": {"strings": ["UserFlags", "hasFlag", "deserialize"]}
},
"DiscordConstants": {
"Colors": ["SPOTIFY", "STATUS_RED"]
},
"LibraryModules": {
"AckUtils": {"props": ["localAck", "bulkAck"]},
"ActivityUtils": {"props": ["sendActivityInvite", "updateActivity"]},
@ -142,7 +145,6 @@
"StoreChangeUtils": {"props": ["get", "set", "clear", "remove"]},
"StreamerModeStore": {"strings": ["StreamerModeStore", "hidePersonalInformation", "disableSounds"], "value": "default"},
"StreamUtils": {"props": ["getActiveStreamForUser", "getAllApplicationStreams"]},
"StringUtils": {"props": ["cssValueToNumber", "upperCaseFirstChar"]},
"TimestampUtils": {"props": ["fromTimestamp", "extractTimestamp"]},
"TimeUtils": {"props": ["calendarFormat", "dateFormat"]},
"ThemeSettingsStore": {"props": ["theme"]},

View File

@ -179,7 +179,7 @@ module.exports = (_ => {
title: `Added ${rType} Words`,
collapseStates: collapseStates,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsList, {
settings: Object.keys(configs).filter(n => !configs[n]["no" + BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(rType)]),
settings: Object.keys(configs).filter(n => !configs[n]["no" + BDFDB.StringUtils.upperCaseFirstChar(rType)]),
data: Object.keys(words[rType]).map(wordValue => Object.assign({}, words[rType][wordValue], {
key: wordValue,
label: wordValue

View File

@ -250,7 +250,7 @@ module.exports = (_ => {
}
formatTimestamp (format, date) {
return BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(BDFDB.LibraryComponents.DateInput.format(format, date));
return BDFDB.StringUtils.upperCaseFirstChar(BDFDB.LibraryComponents.DateInput.format(format, date));
}
setMaxWidth (timestamp, compact) {

View File

@ -400,7 +400,7 @@ module.exports = (_ => {
let newGuildObject = {}, nativeObject = new BDFDB.DiscordObjects.Guild(guild);
for (let key in nativeObject) newGuildObject[key] = nativeObject[key];
newGuildObject.name = data.name || nativeObject.name;
newGuildObject.acronym = data.shortName && data.shortName.replace(/\s/g, "") || BDFDB.LibraryModules.StringUtils.getAcronym(!data.ignoreCustomName && data.name || nativeObject.name);
newGuildObject.acronym = data.shortName && data.shortName.replace(/\s/g, "") || BDFDB.StringUtils.getAcronym(!data.ignoreCustomName && data.name || nativeObject.name);
if (data.removeIcon) {
newGuildObject.icon = null;
newGuildObject.getIconURL = _ => {return null;};
@ -457,7 +457,7 @@ module.exports = (_ => {
onChange: value => {
newData.name = value;
if (!newData.ignoreCustomName) {
acronymInput.props.placeholder = value && BDFDB.LibraryModules.StringUtils.getAcronym(value) || guild.acronym;
acronymInput.props.placeholder = value && BDFDB.StringUtils.getAcronym(value) || guild.acronym;
BDFDB.ReactUtils.forceUpdate(acronymInput);
}
}
@ -470,7 +470,7 @@ module.exports = (_ => {
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
value: data.shortName,
ref: instance => {if (instance) acronymInput = instance;},
placeholder: !data.ignoreCustomName && data.name && BDFDB.LibraryModules.StringUtils.getAcronym(data.name) || guild.acronym,
placeholder: !data.ignoreCustomName && data.name && BDFDB.StringUtils.getAcronym(data.name) || guild.acronym,
onChange: value => {newData.shortName = value;}
})
}),
@ -482,7 +482,7 @@ module.exports = (_ => {
value: data.ignoreCustomName,
onChange: value => {
newData.ignoreCustomName = value;
acronymInput.props.placeholder = !value && newData.name && BDFDB.LibraryModules.StringUtils.getAcronym(newData.name) || guild.acronym;
acronymInput.props.placeholder = !value && newData.name && BDFDB.StringUtils.getAcronym(newData.name) || guild.acronym;
BDFDB.ReactUtils.forceUpdate(acronymInput);
}
}),

View File

@ -537,7 +537,7 @@ module.exports = (_ => {
collapseStates: collapseStates,
children: ["disabled"].concat(Object.keys(defaultSettings)).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Switch",
label: BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(key),
label: BDFDB.StringUtils.upperCaseFirstChar(key),
value: !!defaultSettings[key],
onChange: value => {
defaultSettings[key] = !!statuses[key] ? notificationTypes[value ? "TOAST" : "DISABLED"].value : value;
@ -627,7 +627,7 @@ module.exports = (_ => {
plugin: this,
keys: ["notificationStrings", key],
placeholder: this.defaults.notificationStrings[key].value,
label: BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(key),
label: BDFDB.StringUtils.upperCaseFirstChar(key),
basis: "80%",
value: this.settings.notificationStrings[key]
})))
@ -646,7 +646,7 @@ module.exports = (_ => {
direction: BDFDB.LibraryComponents.Flex.Direction.HORIZONTAL,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsLabel, {
label: `${key.split(/(desktop)|(toast)/).filter(n => n).map(n => BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(n)).join("-")} Notification Sound`,
label: `${key.split(/(desktop)|(toast)/).filter(n => n).map(n => BDFDB.StringUtils.upperCaseFirstChar(n)).join("-")} Notification Sound`,
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Switch",

View File

@ -166,7 +166,7 @@ module.exports = (_ => {
keys: ["selections", key],
label: this.defaults.selections[key].description,
basis: "50%",
options: sounds.map(o => ({value: o, label: o.split(/[-_]/g).map(BDFDB.LibraryModules.StringUtils.upperCaseFirstChar).join(" ")})),
options: sounds.map(o => ({value: o, label: o.split(/[-_]/g).map(BDFDB.StringUtils.upperCaseFirstChar).join(" ")})),
value: this.settings.selections[key],
onChange: value => BDFDB.LibraryModules.SoundUtils.playSound(value, 0.4)
}));

View File

@ -161,12 +161,12 @@ module.exports = (_ => {
const soundKeys = BDFDB.LibraryModules.SoundParser.keys();
for (let key of soundKeys) {
const id = key.replace("./", "").replace(".mp3", "");
const name = id == "reconnect" ? "Invited To Speak" : id.replace("ddr-", "HotKeys_").replace("ptt_", "Push2Talk_").split("_").map(BDFDB.LibraryModules.StringUtils.upperCaseFirstChar).join(" ").replace(/1$/g, "");
const name = id == "reconnect" ? "Invited To Speak" : id.replace("ddr-", "HotKeys_").replace("ptt_", "Push2Talk_").split("_").map(BDFDB.StringUtils.upperCaseFirstChar).join(" ").replace(/1$/g, "");
const src = BDFDB.LibraryModules.SoundParser(key);
let soundPackName = id.split("_")[0];
if (soundPackName != id && soundKeys.filter(n => n.indexOf(`./${soundPackName}`) > -1).length > 10) {
soundPackName = BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(soundPackName);
soundPackName = BDFDB.StringUtils.upperCaseFirstChar(soundPackName);
if (!defaultAudios[soundPackName]) defaultAudios[soundPackName] = {};
defaultAudios[soundPackName][name.replace(new RegExp(`${soundPackName} `, "i"), "").replace(/bootup/i, "Discodo")] = src;
}

View File

@ -72,7 +72,7 @@ module.exports = (_ => {
onStop () {}
openIn (e, key, url) {
let platform = BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(key);
let platform = BDFDB.StringUtils.upperCaseFirstChar(key);
if (url && !url.startsWith("https://images-ext-1.discord") && !url.startsWith("https://images-ext-2.discord") && typeof this[`openIn${platform}`] == "function") {
BDFDB.ListenerUtils.stopEvent(e);
this[`openIn${platform}`](url);

View File

@ -830,7 +830,7 @@ module.exports = (_ => {
delete plugin.thumbnail_url;
BDFDB.LibraryRequires.request(plugin.rawSourceUrl, (error, response, body) => {
if (body && body.indexOf("404: Not Found") != 0 && response.statusCode == 200) {
plugin.name = BDFDB.LibraryModules.StringUtils.upperCaseFirstChar((/@name\s+([^\t^\r^\n]+)|\/\/\**META.*["']name["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1] || plugin.name || "");
plugin.name = BDFDB.StringUtils.upperCaseFirstChar((/@name\s+([^\t^\r^\n]+)|\/\/\**META.*["']name["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1] || plugin.name || "");
plugin.authorname = (/@author\s+(.+)|\/\/\**META.*["']author["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1] || plugin.author.display_name || plugin.author;
const version = (/@version\s+(.+)|\/\/\**META.*["']version["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1];
if (version) {

View File

@ -143,7 +143,7 @@ module.exports = (_ => {
children: this.props.string
})
] : BDFDB.ReactUtils.createElement("div", {
children: `${BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(this.props.prefix)}: ${this.props.string}`
children: `${BDFDB.StringUtils.upperCaseFirstChar(this.props.prefix)}: ${this.props.string}`
});
}
};

View File

@ -252,7 +252,7 @@ module.exports = (_ => {
BDFDB.ReactUtils.forceUpdate(instance);
this.SettingsUpdated = true;
},
children: cardData.key.split("_").map(n => BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(n.toLowerCase())).join(" ")
children: cardData.key.split("_").map(n => BDFDB.StringUtils.upperCaseFirstChar(n.toLowerCase())).join(" ")
})
}),
this.createSettingsBadges(cardData.key)

View File

@ -319,7 +319,7 @@ module.exports = (_ => {
mode: childMode,
filter: childType == "file" && "image"
},
label: varName.split("-").map(BDFDB.LibraryModules.StringUtils.upperCaseFirstChar).join(" "),
label: varName.split("-").map(BDFDB.StringUtils.upperCaseFirstChar).join(" "),
note: varDescription && varDescription.indexOf("*") == 0 ? varDescription.slice(1) : varDescription,
basis: "70%",
value: oldValue,
@ -994,7 +994,7 @@ module.exports = (_ => {
delete theme.thumbnail_url;
BDFDB.LibraryRequires.request(theme.rawSourceUrl, (error, response, body) => {
if (body && body.indexOf("404: Not Found") != 0 && response.statusCode == 200) {
theme.name = BDFDB.LibraryModules.StringUtils.upperCaseFirstChar((/@name\s+([^\t^\r^\n]+)|\/\/\**META.*["']name["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1] || theme.name || "");
theme.name = BDFDB.StringUtils.upperCaseFirstChar((/@name\s+([^\t^\r^\n]+)|\/\/\**META.*["']name["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1] || theme.name || "");
theme.authorname = (/@author\s+(.+)|\/\/\**META.*["']author["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1] || theme.author.display_name || theme.author;
const version = (/@version\s+(.+)|\/\/\**META.*["']version["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1];
if (version) theme.version = version;

View File

@ -168,7 +168,7 @@ module.exports = (_ => {
filter: childType == "file" && "image",
ref: instance => {if (instance) inputInstances[i] = instance;}
},
label: varName.split("-").map(BDFDB.LibraryModules.StringUtils.upperCaseFirstChar).join(" "),
label: varName.split("-").map(BDFDB.StringUtils.upperCaseFirstChar).join(" "),
note: varDescription && varDescription.indexOf("*") == 0 ? varDescription.slice(1) : varDescription,
basis: "70%",
name: varName,