// @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 { 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;