From a13b6e210cdfe8128a0a7206fefd134aeb7f14af Mon Sep 17 00:00:00 2001 From: Jack Matthews Date: Fri, 17 Feb 2023 01:21:56 -0500 Subject: [PATCH] [Plugins] Give plugins their own logger --- src/def.d.ts | 1 + src/lib/plugins.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/def.d.ts b/src/def.d.ts index ce63dd2..f499d8e 100644 --- a/src/def.d.ts +++ b/src/def.d.ts @@ -375,6 +375,7 @@ interface VendettaObject { interface VendettaPluginObject { manifest: PluginManifest; storage: Indexable; + logger: Logger; } declare global { diff --git a/src/lib/plugins.ts b/src/lib/plugins.ts index 3c0eddf..78a69e3 100644 --- a/src/lib/plugins.ts +++ b/src/lib/plugins.ts @@ -1,8 +1,11 @@ import { Indexable, PluginManifest, Plugin } from "@types"; import { awaitSyncWrapper, createMMKVBackend, createStorage, wrapSync } from "@lib/storage"; +import { findByProps } from "@metro/filters"; import safeFetch from "@utils/safeFetch"; import logger from "@lib/logger"; +const logModule = findByProps("setLogFn").default; + type EvaledPlugin = { onLoad?(): void; onUnload(): void; @@ -60,6 +63,7 @@ export async function evalPlugin(plugin: Plugin) { manifest: plugin.manifest, // Wrapping this with wrapSync is NOT an option. storage: await createStorage>(createMMKVBackend(plugin.id)), + logger: new logModule(plugin.manifest.name), } }; const pluginString = `vendetta=>{return ${plugin.js}}\n//# sourceURL=${plugin.id}`;