// @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 { 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, } }; commands.init(obj); settingsInj.init(); plugins.init(obj); } export default init;