From ddca0f3038dfd5b1495ee1337212634598a5b751 Mon Sep 17 00:00:00 2001 From: MotorTruck1221 Date: Sun, 12 Jan 2025 02:00:11 -0700 Subject: [PATCH] InstalledPlugins --- server/dbSetup.ts | 11 ++ src/components/catalog/InstalledPlugins.astro | 134 +++++++++--------- src/utils/marketplace.ts | 10 +- 3 files changed, 84 insertions(+), 71 deletions(-) diff --git a/server/dbSetup.ts b/server/dbSetup.ts index 7e63d3d..bff6154 100644 --- a/server/dbSetup.ts +++ b/server/dbSetup.ts @@ -73,6 +73,17 @@ async function setupDB(db: ModelStatic) { tags: ["Theme", "Simple", "Dark", "Retro"], payload: "retro.css", type: "theme" + }, + { + package_name: 'gyatt', + title: 'gyatt', + image: 'gyatt', + author: "nebuka", + version: "2", + description: "e", + tags: [ "e" ], + payload: "gyatt.js", + type: "plugin-page" } //To add plugins: plugin types consist of plugin-sw (workerware) & plugin-page (uv.config.inject) ]; diff --git a/src/components/catalog/InstalledPlugins.astro b/src/components/catalog/InstalledPlugins.astro index 273e414..e3eaa32 100644 --- a/src/components/catalog/InstalledPlugins.astro +++ b/src/components/catalog/InstalledPlugins.astro @@ -2,10 +2,11 @@ diff --git a/src/utils/marketplace.ts b/src/utils/marketplace.ts index ad72889..715310d 100644 --- a/src/utils/marketplace.ts +++ b/src/utils/marketplace.ts @@ -157,7 +157,7 @@ class Marketplace { async uninstallPlugin(plug: Omit) { const items = JSON.parse(this.#storage.getVal(SettingsVals.marketPlace.plugins)) || []; - const plugin = items.find(({ name }: { name: string }) => name === plug.name.toLowerCase()); + const plugin = items.find(({ name }: { name: string }) => name === plug.name); if (!plugin) return log({ type: 'error', bg: false, prefix: false, throw: true }, `Plugin: ${plug.name} is not installed!`); plugin.remove = true; this.#storage.setVal(SettingsVals.marketPlace.plugins, JSON.stringify(items)); @@ -170,7 +170,7 @@ class Marketplace { if (plugins.length === 0) return log({ type: 'info', bg: false, prefix: true }, 'No plugins to add! Exiting.'); plugins.map(async (plugin: Plug) => { if (plugin.type === "page") { - const script = await fetch(`/packages/${plugin.name.toLowerCase()}/${plugin.src}`); + const script = await fetch(`/packages/${plugin.name}/${plugin.src}`); const scriptRes = await script.text(); const evaledScript = eval(scriptRes); const inject = (await evaledScript()) as unknown as SWPagePlugin; @@ -183,7 +183,7 @@ class Marketplace { }); } else { - plugins = plugins.filter(({ name }: { name: string }) => name !== plugin.name.toLowerCase()); + plugins = plugins.filter(({ name }: { name: string }) => name !== plugin.name); pagePlugins.push({ remove: true, host: inject.host, @@ -196,7 +196,7 @@ class Marketplace { } if (plugin.type === "serviceWorker") { - const s = await fetch(`/packages/${plugin.name.toLowerCase()}/${plugin.src}`); + const s = await fetch(`/packages/${plugin.name}/${plugin.src}`); const sRes = await s.text(); const eScript = eval(sRes); const inject = (await eScript()) as unknown as SWPlugin; @@ -209,7 +209,7 @@ class Marketplace { }); } else { - plugins = plugins.filter(({ name }: { name: string }) => name !== plugin.name.toLowerCase()); + plugins = plugins.filter(({ name }: { name: string }) => name !== plugin.name); swPlugins.push({ remove: true, function: inject.function.toString(),