From 55440b277647c17369b751058cc468b832d7d740 Mon Sep 17 00:00:00 2001 From: Ruthenic Date: Sun, 11 Sep 2022 13:37:40 -0400 Subject: [PATCH] introduce method to add custom metadata to plugins --- src/api/plugin.ts | 3 ++- src/global.d.ts | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/api/plugin.ts b/src/api/plugin.ts index 4f5625e..f7c6436 100644 --- a/src/api/plugin.ts +++ b/src/api/plugin.ts @@ -51,7 +51,7 @@ async function init() { }); } -function add(iife: string) { +function add(iife: string, customMeta: UnknownObject = {}) { const exports = pluginEval(iife); logger.debug(["Plugins"], `Adding ${exports.meta.name}`); pluginNest.store.plugins[exports.meta.name] = { @@ -59,6 +59,7 @@ function add(iife: string) { enabled: false, desc: exports.meta.desc }; + Object.assign(pluginNest.store.plugins[exports.meta.name], customMeta) } function del(name: string) { diff --git a/src/global.d.ts b/src/global.d.ts index b0d4f10..8c4c4e1 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -18,6 +18,11 @@ interface Nest { emit: any } +//we could just use `{}` for this but that's jank if we want to assign a new key/val to it +type UnknownObject = { + [prop: string]: any +} + type DemonGlobal = { summon: (mod: string) => any }