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.

48 lines
1.4 KiB

// @flow
import Patcher from "simian";
import webpack from "./api/webpack";
import common from "./api/common";
import plugins from "./api/plugins";
import settings from "./api/settings/settings";
import css from "./api/css";
import commands from "./api/commands";
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
},
plugins
};
plugins.init(obj);
css.init(obj);
}
export default init;