fix(plugins): filter out internal fields when loading plugins
This commit is contained in:
parent
795639a13d
commit
e141a62dd0
3 changed files with 19 additions and 6 deletions
|
|
@ -16,9 +16,14 @@ export default function unifyBunnyPlugin(manifest: BunnyPluginManifest): Unified
|
|||
useObservable([pluginSettings]);
|
||||
},
|
||||
toggle(start: boolean) {
|
||||
start
|
||||
? enablePlugin(manifest.id, true)
|
||||
: disablePlugin(manifest.id);
|
||||
try {
|
||||
start
|
||||
? enablePlugin(manifest.id, true)
|
||||
: disablePlugin(manifest.id);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
// showToast("Failed to toggle plugin " + e, findAssetId("Small"));
|
||||
}
|
||||
},
|
||||
resolveSheetComponent() {
|
||||
return import("../sheets/PluginInfoActionSheet");
|
||||
|
|
|
|||
|
|
@ -8,11 +8,18 @@ import { BunnyPluginObject } from "./types";
|
|||
|
||||
type DisposableFn = (...props: any[]) => () => unknown;
|
||||
function shimDisposableFn<F extends DisposableFn>(unpatches: (() => void)[], f: F): F {
|
||||
return ((...props: Parameters<F>) => {
|
||||
const dummy = ((...props: Parameters<F>) => {
|
||||
const up = f(...props);
|
||||
unpatches.push(up);
|
||||
return up;
|
||||
}) as F;
|
||||
|
||||
for (const key in f) if (typeof f[key] === "function") {
|
||||
// @ts-ignore
|
||||
dummy[key] = shimDisposableFn(unpatches, f[key] as DisposableFn);
|
||||
}
|
||||
|
||||
return dummy;
|
||||
}
|
||||
|
||||
export function createBunnyPluginApi(id: string) {
|
||||
|
|
|
|||
|
|
@ -152,7 +152,8 @@ export async function updateRepository(repoUrl: string) {
|
|||
}
|
||||
}
|
||||
|
||||
await Promise.all(Object.keys(repo).map(async pluginId => {
|
||||
const pluginIds = Object.keys(repo).filter(id => !id.startsWith("$"));
|
||||
await Promise.all(pluginIds.map(async pluginId => {
|
||||
if (!storedRepo || !storedRepo[pluginId] || repo[pluginId].alwaysFetch || isGreaterVersion(repo[pluginId].version, storedRepo[pluginId].version)) {
|
||||
updated = true;
|
||||
pluginRepositories[repoUrl][pluginId] = repo[pluginId];
|
||||
|
|
@ -166,7 +167,7 @@ export async function updateRepository(repoUrl: string) {
|
|||
}));
|
||||
|
||||
// Register plugins in this repository
|
||||
for (const id in repo) {
|
||||
for (const id of pluginIds) {
|
||||
const manifest = getPreloadedStorage<t.BunnyPluginManifest>(`plugins/manifests/${id}.json`);
|
||||
if (manifest === undefined) continue; // shouldn't happen, but just incase if it does
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue