[plugins] read plugin metadata from its exports.

pull/3/head
Drake 2 years ago
parent 8dbed1dd82
commit 72606d3813

@ -22,8 +22,10 @@ async function init(obj: Object): Promise<boolean> {
return true;
}
async function addPlugin(iife: string, metadata: Object): Promise<boolean> {
async function addPlugin(iife: string): Promise<boolean> {
// expected metadata: {name: "name", desc: "description", author: "author"}
const exports: Object = (0, eval)(iife);
const metadata: Object = exports.metadata;
const obj: Object = {
// whether the plugin is started or stopped isn't going to be stored in the iDB, so it can be accessed more easily by all components
metadata: metadata,
@ -67,6 +69,9 @@ async function startPlugin(name: string): Promise<boolean> {
const exports: Object = (0, eval)(plug.iife);
const onStart: (ctx: Object) => void = exports.onStart;
let ctx = {}; // ctx is how you're going to store things that need to be accessed in both onStart and onStop. dumb, i know
if (plug.metadata.cumcord) {
ctx.cumcord = window.demon //TODO: explicit cumcord compat layer.
}
onStart(ctx);
if (exports.settings)
settingsInj.registerSettingsEntry(

@ -34,6 +34,9 @@ function patch(args: mixed, ret: getPredicateSectionsEntry[]) {
element: e.component,
}));
processedEntries.map((e) => {console.log(e)})
const injectionIndex =
2 + ret.findIndex((section) => section.section === "Game Activity");
ret.splice(

Loading…
Cancel
Save