[Plugins] Give plugins their own logger

This commit is contained in:
Jack Matthews 2023-02-17 01:21:56 -05:00 committed by Beef
parent c9aeefe419
commit a13b6e210c
2 changed files with 5 additions and 0 deletions

1
src/def.d.ts vendored
View file

@ -375,6 +375,7 @@ interface VendettaObject {
interface VendettaPluginObject {
manifest: PluginManifest;
storage: Indexable<any>;
logger: Logger;
}
declare global {

View file

@ -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<Indexable<any>>(createMMKVBackend(plugin.id)),
logger: new logModule(plugin.manifest.name),
}
};
const pluginString = `vendetta=>{return ${plugin.js}}\n//# sourceURL=${plugin.id}`;