[Plugins] Give plugins their own logger
This commit is contained in:
parent
c9aeefe419
commit
a13b6e210c
2 changed files with 5 additions and 0 deletions
1
src/def.d.ts
vendored
1
src/def.d.ts
vendored
|
@ -375,6 +375,7 @@ interface VendettaObject {
|
|||
interface VendettaPluginObject {
|
||||
manifest: PluginManifest;
|
||||
storage: Indexable<any>;
|
||||
logger: Logger;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
|
|
@ -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}`;
|
||||
|
|
Loading…
Reference in a new issue