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.
53 lines
1.1 KiB
53 lines
1.1 KiB
// @flow
|
|
import Patcher from "simian"
|
|
import webpack from "./api/webpack.js"
|
|
import common from "./api/common.js"
|
|
import commands from "./api/commands.js"
|
|
import plugins from "./api/plugins.js"
|
|
|
|
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
|
|
}
|
|
}
|
|
commands.init(obj)
|
|
plugins.init(obj)
|
|
}
|
|
|
|
export default init;
|