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.

35 lines
731 B

// @flow
import init from "./init.js";
import settingsInj from "./api/settings/settingsInj";
import commands from "./api/commands";
const obj = {};
init(obj);
window.demon = {};
function isAllowed(mod: String): boolean {
//TODO: permissions checking
return true;
}
window.demon.require = (mod: String): Object => {
if (!isAllowed(mod)) {
throw new Error("Not allowed!"); //TODO: make this not irrepairably error out
}
const mods = mod.split("/");
let res = obj.demon;
mods.forEach((m) => {
if (m in res) {
res = res[m];
} else {
throw new Error("Module does not exist!");
}
});
return res;
};
settingsInj.init();
commands.init(obj);