[TS] Completely remove Indexable from Vendetta

This commit is contained in:
Beef 2023-04-15 03:04:48 +01:00
parent 32b3a0295c
commit b271240f76
5 changed files with 18 additions and 21 deletions

View file

@ -1,4 +1,4 @@
import { Indexable, PluginManifest, Plugin } from "@types";
import { PluginManifest, Plugin } from "@types";
import { awaitSyncWrapper, createMMKVBackend, createStorage, wrapSync } from "@lib/storage";
import { MMKVManager } from "@lib/native";
import settings from "@lib/settings";
@ -11,8 +11,8 @@ type EvaledPlugin = {
settings: JSX.Element;
};
export const plugins = wrapSync(createStorage<Indexable<Plugin>>(createMMKVBackend("VENDETTA_PLUGINS")));
const loadedPlugins: Indexable<EvaledPlugin> = {};
export const plugins = wrapSync(createStorage<Record<string, Plugin>>(createMMKVBackend("VENDETTA_PLUGINS")));
const loadedPlugins: Record<string, EvaledPlugin> = {};
export async function fetchPlugin(id: string) {
if (!id.endsWith("/")) id += "/";
@ -60,7 +60,7 @@ export async function evalPlugin(plugin: Plugin) {
id: plugin.id,
manifest: plugin.manifest,
// Wrapping this with wrapSync is NOT an option.
storage: await createStorage<Indexable<any>>(createMMKVBackend(plugin.id)),
storage: await createStorage<Record<string, any>>(createMMKVBackend(plugin.id)),
},
logger: new logModule(`Vendetta » ${plugin.manifest.name}`),
};

View file

@ -1,4 +1,4 @@
import { Indexable, Theme, ThemeData } from "@types";
import { Theme, ThemeData } from "@types";
import { findByProps } from "@metro/filters";
import { ReactNative, chroma } from "@metro/common";
import { instead } from "@lib/patcher";
@ -9,7 +9,7 @@ import { safeFetch } from "@utils";
// Somehow, this is late enough, though?
export const color = findByProps("SemanticColor");
export const themes = wrapSync(createStorage<Indexable<Theme>>(createMMKVBackend("VENDETTA_THEMES")));
export const themes = wrapSync(createStorage<Record<string, Theme>>(createMMKVBackend("VENDETTA_THEMES")));
async function writeTheme(theme: Theme | {}) {
if (typeof theme !== "object") throw new Error("Theme must be an object");