forked from Demon/demoncord
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.6 KiB
54 lines
1.6 KiB
// @flow
|
|
import Patcher from "simian";
|
|
import webpack from "./api/webpack";
|
|
import common from "./api/common";
|
|
import commands from "./api/commands";
|
|
import plugins from "./api/plugins";
|
|
import settingsInj from "./api/settingsInj";
|
|
|
|
async function init(obj: Object): Promise<void> {
|
|
const patcher = new Patcher();
|
|
obj.demon = {
|
|
patcher: {
|
|
monkeyPatch: function (
|
|
name: string,
|
|
parentObj: Object,
|
|
patches: Object
|
|
): () => void {
|
|
let [upb, upi, upa] = [() => {}, () => {}, () => {}];
|
|
if (patches.before !== undefined)
|
|
upb = patcher.before(name, parentObj, patches.before);
|
|
if (patches.instead !== undefined)
|
|
upb = patcher.instead(name, parentObj, patches.instead);
|
|
if (patches.after !== undefined)
|
|
upb = patcher.after(name, parentObj, patches.after);
|
|
return () => {
|
|
upb();
|
|
upi();
|
|
upa();
|
|
};
|
|
},
|
|
before: patcher.before,
|
|
instead: patcher.instead,
|
|
after: patcher.after,
|
|
},
|
|
webpack,
|
|
common,
|
|
commands: {
|
|
add: commands.add,
|
|
},
|
|
__DO_NOT_USE_OR_YOU_WILL_BE_FIRED_UNTO_THE_DEPTHS_OF_HELL: {
|
|
plugins,
|
|
},
|
|
settings: {
|
|
register: settingsInj.registerSettingsEntry,
|
|
unregister: settingsInj.unregisterSettingsEntry,
|
|
},
|
|
};
|
|
commands.init(obj);
|
|
settingsInj.init();
|
|
plugins.init(obj);
|
|
}
|
|
|
|
export default init;
|