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.
demoncord-rewrite/src/index.js

49 lines
966 B

import webpack from "./api/webpack.js"
import common from "./api/common.js"
import utils from "./api/utils/index.js"
import plugins from "./api/plugin.js"
import settings from "./api/ui/settings/settings.js"
if (!window.DiscordNative) {
throw new Error("Sorry, Demoncord cannot be used on web!")
}
const demon = {
modules: {
webpack,
common
},
utils,
plugins,
internal: {
nest: common.nests.make()
}
}
function isAllowed(mod) {
//TODO: actually implement permissions
return true
}
function require(mod) {
if (!isAllowed(mod)) {
throw new Error("Not allowed!"); //TODO: make this not irrepairably error out
}
const mods = mod.split("/");
let res = demon;
mods.forEach((m) => {
if (m in res) {
res = res[m];
} else {
throw new Error("Module does not exist!");
}
});
return res;
}
window.demon = {
require
}
plugins.init()
settings.init()