[Plugin] Basic, non-functional implementation
This commit is contained in:
parent
d0f4e87475
commit
7465e42354
6 changed files with 157 additions and 0 deletions
24
src/lib/plugins.ts
Normal file
24
src/lib/plugins.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { Indexable, PluginManifest, Plugin } from "@types";
|
||||
|
||||
export const plugins: Indexable<Plugin> = {};
|
||||
|
||||
export async function fetchPlugin(url: string) {
|
||||
if (!url.endsWith("/")) url += "/";
|
||||
|
||||
if (plugins[url]) throw new Error(`That plugin is already installed!`);
|
||||
|
||||
let pluginManifest: PluginManifest;
|
||||
|
||||
try {
|
||||
pluginManifest = await (await fetch(new URL("manifest.json", url), { cache: "no-store" })).json();
|
||||
} catch {
|
||||
throw new Error(`Failed to fetch manifest for ${url}`);
|
||||
}
|
||||
|
||||
plugins[url] = {
|
||||
id: url.split("://")[1],
|
||||
manifest: pluginManifest,
|
||||
enabled: true,
|
||||
js: "",
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue