|
|
|
@ -4,7 +4,12 @@ import webpack from "./webpack";
|
|
|
|
|
|
|
|
|
|
const settingsSym = Symbol("__settings");
|
|
|
|
|
|
|
|
|
|
const settingsView = webpack.find(m => m.default && m.default.displayName === "SettingsView");
|
|
|
|
|
// super secret value that shouldnt be exposed, used internally to avoid section conflicts and the like
|
|
|
|
|
const ovrwrtSctnSym: symbol = Symbol("__overwriteSection");
|
|
|
|
|
|
|
|
|
|
const settingsView = webpack.find(
|
|
|
|
|
(m) => m.default && m.default.displayName === "SettingsView"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
type getPredicateSectionsEntry =
|
|
|
|
|
| {
|
|
|
|
@ -22,7 +27,7 @@ type getPredicateSectionsEntry =
|
|
|
|
|
|
|
|
|
|
function patch(args: mixed, ret: getPredicateSectionsEntry[]) {
|
|
|
|
|
const processedEntries = window.demon[settingsSym].entries.map((e) => ({
|
|
|
|
|
section: "DEMON_SETTINGS_LOADER_" + e.name,
|
|
|
|
|
section: e[ovrwrtSctnSym] ?? "DEMON_SETTINGS_LOADER_" + e.name,
|
|
|
|
|
label: e.name,
|
|
|
|
|
element: e.component,
|
|
|
|
|
}));
|
|
|
|
@ -63,9 +68,18 @@ function unregisterSettingsEntry(name: string) {
|
|
|
|
|
s.entries = s.entries.filter((e) => e.name !== name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function registerSettingsEntry(name: string, component: Function): () => void {
|
|
|
|
|
window.demon[settingsSym].entries.push({ name, component });
|
|
|
|
|
function registerSettingsEntry(name: string, section: string, component: Function): () => void {
|
|
|
|
|
let entry = { name, component };
|
|
|
|
|
if (section)
|
|
|
|
|
entry[ovrwrtSctnSym] = section;
|
|
|
|
|
window.demon[settingsSym].entries.push(entry);
|
|
|
|
|
return () => unregisterSettingsEntry(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default { init, unInit, registerSettingsEntry, unregisterSettingsEntry };
|
|
|
|
|
export default {
|
|
|
|
|
init,
|
|
|
|
|
unInit,
|
|
|
|
|
registerSettingsEntry,
|
|
|
|
|
unregisterSettingsEntry,
|
|
|
|
|
ovrwrtSctnSymm: ovrwrtSctnSym,
|
|
|
|
|
};
|
|
|
|
|