refactor(plugins): update dist fetch directory
This commit is contained in:
parent
131c119619
commit
b37ff5bce8
8 changed files with 30 additions and 43 deletions
|
|
@ -19,7 +19,7 @@ async function arrayFromAsync<T>(iterableOrArrayLike: AsyncIterable<T>): Promise
|
|||
}
|
||||
|
||||
async function fetchManifest(repoURL: string, id: string) {
|
||||
const url = new URL(`plugins/${id}/manifest.json`, repoURL);
|
||||
const url = new URL(`builds/${id}/manifest.json`, repoURL);
|
||||
const data = await safeFetch(url).then(d => d.json());
|
||||
|
||||
queryClient.setQueryData(["plugin-manifest-dist", { id }], data);
|
||||
|
|
@ -93,10 +93,10 @@ function PluginCard(props: { repoUrl: string, id: string, manifest: BunnyPluginM
|
|||
<View style={{ flexDirection: "row", justifyContent: "space-between", alignItems: "center" }}>
|
||||
<View style={{ flexShrink: 1 }}>
|
||||
<Text numberOfLines={1} variant="heading-lg/semibold">
|
||||
{plugin.name}
|
||||
{plugin.display.name}
|
||||
</Text>
|
||||
<Text variant="text-md/semibold" color="text-muted">
|
||||
by {plugin.authors.map(a => typeof a === "string" ? a : a.name).join(", ")}
|
||||
by {plugin.display.authors?.map(a => typeof a === "string" ? a : a.name).join(", ") ?? "Unknown"}
|
||||
</Text>
|
||||
</View>
|
||||
<View>
|
||||
|
|
@ -104,7 +104,7 @@ function PluginCard(props: { repoUrl: string, id: string, manifest: BunnyPluginM
|
|||
</View>
|
||||
</View>
|
||||
<Text variant="text-md/medium">
|
||||
{plugin.description}
|
||||
{plugin.display.description}
|
||||
</Text>
|
||||
</Stack>}
|
||||
</Card>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { disablePlugin, enablePlugin, getId, getPluginSettingsComponent, isPluginEnabled, pluginSettings } from "@lib/addons/plugins";
|
||||
import { disablePlugin, enablePlugin, getPluginSettingsComponent, isPluginEnabled, pluginSettings } from "@lib/addons/plugins";
|
||||
import { BunnyPluginManifest } from "@lib/addons/plugins/types";
|
||||
import { useObservable } from "@lib/api/storage";
|
||||
|
||||
|
|
@ -7,24 +7,24 @@ import { UnifiedPluginModel } from "..";
|
|||
export default function unifyBunnyPlugin(manifest: BunnyPluginManifest): UnifiedPluginModel {
|
||||
return {
|
||||
id: manifest.id,
|
||||
name: manifest.name,
|
||||
description: manifest.description,
|
||||
authors: manifest.authors,
|
||||
isEnabled: () => isPluginEnabled(getId(manifest)),
|
||||
name: manifest.display.name,
|
||||
description: manifest.display.description,
|
||||
authors: manifest.display.authors,
|
||||
isEnabled: () => isPluginEnabled(manifest.id),
|
||||
isInstalled: () => manifest.id in pluginSettings,
|
||||
usePluginState() {
|
||||
useObservable([pluginSettings]);
|
||||
},
|
||||
toggle(start: boolean) {
|
||||
start
|
||||
? enablePlugin(getId(manifest), true)
|
||||
: disablePlugin(getId(manifest));
|
||||
? enablePlugin(manifest.id, true)
|
||||
: disablePlugin(manifest.id);
|
||||
},
|
||||
resolveSheetComponent() {
|
||||
return import("../sheets/PluginInfoActionSheet");
|
||||
},
|
||||
getPluginSettingsComponent() {
|
||||
return getPluginSettingsComponent(getId(manifest));
|
||||
return getPluginSettingsComponent(manifest.id);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ export default function PluginInfoActionSheet({ plugin, navigation }: PluginInfo
|
|||
</View>
|
||||
</View>
|
||||
<View style={{ flexDirection: "row", justifyContent: "center", alignContent: "center" }}>
|
||||
<Text variant="text-lg/medium">
|
||||
{/* <Text variant="text-lg/medium">
|
||||
Oops, you shouldn't see this!
|
||||
</Text>
|
||||
</Text> */}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</ActionSheet>;
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@ export const apiObjects = new Map<string, ReturnType<typeof createBunnyPluginAPI
|
|||
export const pluginRepositories = createStorage<t.PluginRepoStorage>("plugins/repositories.json");
|
||||
export const pluginSettings = createStorage<t.PluginSettingsStorage>("plugins/settings.json");
|
||||
|
||||
const manifestToId = new WeakMap<t.BunnyPluginManifest, string>();
|
||||
|
||||
const _fetch = (repoUrl: string, path: string) => safeFetch(new URL(path, repoUrl), { cache: "no-store" });
|
||||
const fetchJS = (repoUrl: string, path: string) => _fetch(repoUrl, path).then(r => r.text());
|
||||
const fetchJSON = (repoUrl: string, path: string) => _fetch(repoUrl, path).then(r => r.json());
|
||||
|
|
@ -55,12 +53,6 @@ export function isCorePlugin(id: string) {
|
|||
return corePluginInstances.has(id);
|
||||
}
|
||||
|
||||
export function getId<T extends t.BunnyPluginManifest>(manifest: T): string {
|
||||
const id = manifestToId.get(manifest);
|
||||
assert(id, manifest?.name ?? "unknown", "getting ID from an unregistered/invalid manifest");
|
||||
return id;
|
||||
}
|
||||
|
||||
export function getPluginSettingsComponent(id: string): React.ComponentType<any> | null {
|
||||
const instance = pluginInstances.get(id);
|
||||
if (!instance) return null;
|
||||
|
|
@ -126,7 +118,6 @@ export async function refreshPlugin(id: string, repoUrl?: string) {
|
|||
|
||||
registeredPlugins.delete(id);
|
||||
registeredPlugins.set(id, manifest);
|
||||
manifestToId.set(manifest, id);
|
||||
|
||||
await startPlugin(id);
|
||||
}
|
||||
|
|
@ -186,7 +177,6 @@ export async function updateRepository(repoUrl: string) {
|
|||
}
|
||||
|
||||
registeredPlugins.set(id, manifest);
|
||||
manifestToId.set(manifest, id);
|
||||
}
|
||||
|
||||
return updated;
|
||||
|
|
@ -382,7 +372,6 @@ export async function updatePlugins() {
|
|||
};
|
||||
|
||||
registeredPlugins.set(id, instance.manifest);
|
||||
manifestToId.set(instance.manifest, id);
|
||||
corePluginInstances.set(id, instance);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { createStorage } from "@core/vendetta/storage";
|
||||
import { Author } from "@lib/addons/types";
|
||||
import { BunnyManifest } from "@lib/addons/types";
|
||||
import { Logger } from "@lib/utils/logger";
|
||||
|
||||
export interface PluginRepo {
|
||||
|
|
@ -21,12 +21,8 @@ export interface PluginSettingsStorage {
|
|||
};
|
||||
}
|
||||
|
||||
export interface BunnyPluginManifest {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly description: string;
|
||||
readonly version: string;
|
||||
readonly authors: Author[];
|
||||
export interface BunnyPluginManifest extends BunnyManifest {
|
||||
readonly main: string;
|
||||
}
|
||||
|
||||
export interface BunnyPluginManifestInternal extends BunnyPluginManifest {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
export type Author = { name: string, id?: `${bigint}`; };
|
||||
|
||||
export interface BunnyManifest {
|
||||
id: string;
|
||||
display: {
|
||||
name: string;
|
||||
description?: string;
|
||||
authors?: Author[];
|
||||
readonly id: string;
|
||||
readonly version: string;
|
||||
readonly type: string;
|
||||
readonly display: {
|
||||
readonly name: string;
|
||||
readonly description?: string;
|
||||
readonly authors?: Author[];
|
||||
};
|
||||
extras?: {
|
||||
[key: string]: any;
|
||||
readonly extras?: {
|
||||
readonly [key: string]: any;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Theme } from "@lib/addons/themes";
|
||||
import { VdThemeInfo } from "@lib/addons/themes";
|
||||
|
||||
// @ts-ignore
|
||||
const pyonLoaderIdentity = globalThis.__PYON_LOADER__;
|
||||
|
|
@ -124,7 +124,7 @@ export function isThemeSupported() {
|
|||
return false;
|
||||
}
|
||||
|
||||
export function getStoredTheme(): Theme | null {
|
||||
export function getStoredTheme(): VdThemeInfo | null {
|
||||
if (isPyonLoader()) {
|
||||
return pyonLoaderIdentity.storedTheme;
|
||||
} else if (isVendettaLoader()) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { lazyDestructure, proxyLazy } from "@lib/utils/lazy";
|
||||
import { findByProps, findByPropsLazy } from "@metro/wrappers";
|
||||
import { isSemanticColor, resolveSemanticColor } from "@ui/color";
|
||||
import { DiscordTextStyles } from "@ui/types";
|
||||
import { TextStyles } from "@ui/types";
|
||||
import { ImageStyle, StyleSheet, TextStyle, ViewStyle } from "react-native";
|
||||
|
||||
type NamedStyles<T> = { [P in keyof T]: ViewStyle | TextStyle | ImageStyle };
|
||||
|
|
@ -10,7 +10,7 @@ const Styles = findByPropsLazy("createStyles");
|
|||
|
||||
export const { ThemeContext } = lazyDestructure(() => findByProps("ThemeContext"), { hint: "object" });
|
||||
export const { TextStyleSheet } = lazyDestructure(() => findByProps("TextStyleSheet")) as unknown as {
|
||||
TextStyleSheet: Record<DiscordTextStyles, TextStyle>;
|
||||
TextStyleSheet: Record<TextStyles, TextStyle>;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue