From 5461065db87b640f75c367b3380890764d74e59a Mon Sep 17 00:00:00 2001 From: redstonekasi Date: Wed, 5 Apr 2023 22:18:22 +0200 Subject: [PATCH] [Global] Some changes and fixes --- src/def.d.ts | 14 +++++++------- src/entry.ts | 4 ++-- src/lib/storage/backends.ts | 5 ++--- src/lib/windowObject.ts | 4 ++-- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/def.d.ts b/src/def.d.ts index 9976131..d94d594 100644 --- a/src/def.d.ts +++ b/src/def.d.ts @@ -427,21 +427,21 @@ interface VendettaObject { }; plugins: { plugins: Indexable; - fetchPlugin: (id: string) => void; - installPlugin: (id: string, enabled?: boolean) => void; - evalPlugin: (plugin: Plugin) => void; + fetchPlugin: (id: string) => Promise; + installPlugin: (id: string, enabled?: boolean) => Promise; + startPlugin: (id: string) => Promise; stopPlugin: (id: string, disable?: boolean) => void; removePlugin: (id: string) => void; getSettings: (id: string) => JSX.Element; }; themes: { themes: Indexable; - fetchTheme: (id: string, selected?: boolean) => void; - installTheme: (id: string) => void; - selectTheme: (id: string) => void; + fetchTheme: (id: string, selected?: boolean) => Promise; + installTheme: (id: string) => Promise; + selectTheme: (id: string) => Promise; removeTheme: (id: string) => Promise; getCurrentTheme: () => Theme | null; - updateThemes: () => void; + updateThemes: () => Promise; }; commands: { registerCommand: (command: ApplicationCommand) => () => void; diff --git a/src/entry.ts b/src/entry.ts index 8568401..1725164 100644 --- a/src/entry.ts +++ b/src/entry.ts @@ -3,7 +3,7 @@ import { ClientInfoManager } from "@lib/native"; // This logs in the native logging implementation, e.g. logcat console.log("Hello from Vendetta!"); -(async () => (await import(".")).default().catch(e => { +import(".").then((m) => m.default()).catch((e) => { console.log(e?.stack ?? e.toString()); alert([ "Failed to load Vendetta!\n", @@ -12,4 +12,4 @@ console.log("Hello from Vendetta!"); `Vendetta: ${__vendettaVersion}`, e?.stack || e.toString(), ].join("\n")); -}))(); +}); diff --git a/src/lib/storage/backends.ts b/src/lib/storage/backends.ts index 500ad94..8e40ba3 100644 --- a/src/lib/storage/backends.ts +++ b/src/lib/storage/backends.ts @@ -8,7 +8,6 @@ export const createMMKVBackend = (store: string): StorageBackend => ({ }); export const createFileBackend = (file: string): StorageBackend => { - // TODO: Creating this function in every file backend probably isn't ideal. const filePathFixer: (file: string) => string = RN.Platform.select({ default: (f) => f, ios: (f) => `Documents/${f}`, @@ -21,6 +20,6 @@ export const createFileBackend = (file: string): StorageBackend => { if (!created && !(await FileManager.fileExists(path))) return (created = true), FileManager.writeFile("documents", filePathFixer(file), "{}", "utf8"); return JSON.parse(await FileManager.readFile(path, "utf8")); }, - set: (data) => void FileManager.writeFile("documents", filePathFixer(file), JSON.stringify(data), "utf8"), + set: async (data) => void await FileManager.writeFile("documents", filePathFixer(file), JSON.stringify(data), "utf8"), }; -}; \ No newline at end of file +}; diff --git a/src/lib/windowObject.ts b/src/lib/windowObject.ts index 340f939..dca7812 100644 --- a/src/lib/windowObject.ts +++ b/src/lib/windowObject.ts @@ -17,7 +17,7 @@ import * as assets from "@ui/assets"; import * as color from "@ui/color"; import * as utils from "@utils"; -function without>(object: T, ...keys: string[]) { +function without(object: O, ...keys: K): Omit { const cloned = { ...object }; keys.forEach((k) => delete cloned[k]); return cloned; @@ -36,7 +36,7 @@ export default async (unloads: any[]): Promise => ({ assets, ...color, }, - plugins: without(plugins, "initPlugins"), + plugins: without(plugins, "initPlugins", "evalPlugin"), themes: without(themes, "initThemes"), commands: without(commands, "patchCommands"), storage,