diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 907ca99..af6c50c 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -2,54 +2,49 @@ name: Node.js CI / CD (Bun + Forgejo) on: push: - branches: [ "main" ] - + branches: [ "main", "dev" ] jobs: buildAndRelease: runs-on: codeberg-tiny - steps: - uses: actions/checkout@v3 - - name: Install Bun run: | curl -fsSL https://bun.sh/install | bash export BUN_INSTALL="$HOME/.bun" export PATH="$BUN_INSTALL/bin:$PATH" echo "$BUN_INSTALL/bin" >> $GITHUB_PATH - - name: Install dependencies run: | export BUN_INSTALL="$HOME/.bun" export PATH="$BUN_INSTALL/bin:$PATH" bun install - - name: Build project run: | export BUN_INSTALL="$HOME/.bun" export PATH="$BUN_INSTALL/bin:$PATH" bun run build --release-branch=${GITHUB_REF_NAME:-${CI_COMMIT_REF_NAME}} --build-minify - - name: Push JS files to dist branch run: | git config --local user.email "actions@forgejo.local" git config --local user.name "Forgejo Actions" - mkdir -p temp_dist find dist -name "*.js" -exec cp {} temp_dist/ \; - git checkout --orphan dist-temp git rm -rf --cached . - cp -r temp_dist/* . rm -rf temp_dist - git add *.js git commit -m "Update build $GITHUB_SHA" || exit 0 - git push -f origin HEAD:dist - + + if [ "${GITHUB_REF_NAME:-${CI_COMMIT_REF_NAME}}" = "dev" ]; then + TARGET_BRANCH="testing-dist" + else + TARGET_BRANCH="dist" + fi + + git push -f origin HEAD:$TARGET_BRANCH git checkout -f ${GITHUB_REF_NAME:-${CI_COMMIT_REF_NAME}} - - name: Merge main into github if: github.ref == 'refs/heads/main' run: | diff --git a/README.md b/README.md index c08655e..76ef8e4 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,6 @@ A mod for Discord on Android ### iOS - [BTLoader](https://github.com/CloudySn0w/BTLoader) -note: btloader is not developed by me and loads revenge by default - -## This is a mirror of the [codeberg repository](https://codeberg.org/cocobo1/Kettu), please make all commits and issues there - ## Building 1. Install a Kettu loader with loader config support (any mentioned in the [Installing](#installing) section). 1. Go to Settings > General and enable Developer Settings. diff --git a/scripts/build.mjs b/scripts/build.mjs index 75e3ffb..787124c 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -74,7 +74,7 @@ const config = { constModules: { globals: { "bunny-build-info": { - version: `"1.3.0"` + version: `"v1.3.4"` } } }, diff --git a/src/core/plugins/index.ts b/src/core/plugins/index.ts index 5bc2f76..3e1ed75 100644 --- a/src/core/plugins/index.ts +++ b/src/core/plugins/index.ts @@ -7,10 +7,10 @@ interface CorePlugin { // Called from @lib/plugins export const getCorePlugins = (): Record => ({ - "bunny.quickinstall": require("./quickinstall"), - "bunny.badges": require("./badges"), - "bunny.notrack": { ...require("./notrack"), preenabled: true }, - "bunny.messagefix": { default: require("./messagefix"), preenabled: true }, + "bunny.quickinstall": require("./quickinstall"), + "bunny.badges": require("./badges"), + "bunny.notrack": require("./notrack"), + "bunny.messagefix": require("./messagefix"), }); /** diff --git a/src/core/ui/settings/pages/Plugins/components/PluginCard.tsx b/src/core/ui/settings/pages/Plugins/components/PluginCard.tsx index 6ab8f1e..daf3bb1 100644 --- a/src/core/ui/settings/pages/Plugins/components/PluginCard.tsx +++ b/src/core/ui/settings/pages/Plugins/components/PluginCard.tsx @@ -14,6 +14,7 @@ import { showSheet } from "@ui/sheets"; import chroma from "chroma-js"; import { createContext, useContext, useMemo } from "react"; import { Image, View } from "react-native"; +import { isCorePlugin } from "@lib/addons/plugins"; const CardContext = createContext<{ plugin: UnifiedPluginModel; @@ -146,39 +147,41 @@ export default function PluginCard({ }: CardWrapper) { plugin.usePluginState(); - const [, forceUpdate] = React.useReducer(() => ({}), 0); - const cardContextValue = useMemo( - () => ({ plugin, result }), - [plugin, result], - ); + +const [, forceUpdate] = React.useReducer(() => ({}), 0); +const cardContextValue = useMemo(() => ({ plugin, result }), [plugin, result]); + const core = isCorePlugin(plugin.id); - return ( - - - - - - - <Authors /> - </View> - <View> - <Stack spacing={12} direction="horizontal"> - <Actions /> - <TableSwitch - value={plugin.isEnabled()} - onValueChange={(v: boolean) => { - plugin.toggle(v); - forceUpdate(); - }} - /> - </Stack> - </View> - </View> - <Description /> - </Stack> - </Card> - </CardContext.Provider> - ); -} + return ( + <CardContext.Provider value={cardContextValue}> + <Card> + <Stack spacing={16}> + <View style={{ flexDirection: "row", justifyContent: "space-between" }}> + <View style={{ flexShrink: 1 }}> + <Title /> + <Authors /> + </View> + <View> + <Stack spacing={12} direction="horizontal"> + <Actions /> + <View style={core ? { opacity: 0.5 } : undefined}> + <TableSwitch + value={core ? true : plugin.isEnabled()} + disabled={core} + onValueChange={(v: boolean) => { + if (!core) { + plugin.toggle(v); + forceUpdate(); + } + }} + /> + </View> + </Stack> + </View> + </View> + <Description /> + </Stack> + </Card> + </CardContext.Provider> + ); +} \ No newline at end of file diff --git a/src/core/ui/settings/pages/Plugins/index.tsx b/src/core/ui/settings/pages/Plugins/index.tsx index e03ca3d..6376e3b 100644 --- a/src/core/ui/settings/pages/Plugins/index.tsx +++ b/src/core/ui/settings/pages/Plugins/index.tsx @@ -76,14 +76,11 @@ export default function Plugins() { useProxy(VdPluginManager.plugins); useObservable([pluginSettings]); - const corePlugins = [...corePluginInstances.keys()] - .map((id) => registeredPlugins.get(id)) - .filter((manifest): manifest is BunnyPluginManifest => manifest !== undefined) - .map(unifyBunnyPlugin); + const corePlugins = [...registeredPlugins.values()].filter(p => isPluginInstalled(p.id) && isCorePlugin(p.id)).map(unifyBunnyPlugin); const vdPlugins = Object.values(VdPluginManager.plugins).map(unifyVdPlugin); const bnPlugins = [...registeredPlugins.values()].filter(p => isPluginInstalled(p.id) && !isCorePlugin(p.id)).map(unifyBunnyPlugin); - return [... corePlugins, ...vdPlugins, ...bnPlugins]; + return [...corePlugins, ...vdPlugins, ...bnPlugins]; }} ListHeaderComponent={() => { const unproxiedPlugins = Object.values(VdPluginManager.plugins).filter(p => !p.id.startsWith(VD_PROXY_PREFIX) && !p.id.startsWith(BUNNY_PROXY_PREFIX)); diff --git a/src/core/ui/settings/pages/Plugins/sheets/PluginInfoActionSheet.tsx b/src/core/ui/settings/pages/Plugins/sheets/PluginInfoActionSheet.tsx index e105640..670c0f7 100644 --- a/src/core/ui/settings/pages/Plugins/sheets/PluginInfoActionSheet.tsx +++ b/src/core/ui/settings/pages/Plugins/sheets/PluginInfoActionSheet.tsx @@ -151,7 +151,7 @@ export default function PluginInfoActionSheet({ justifyContent: "center", alignItems: "center", flexWrap: "wrap", - gap: 12, + gap: 22, paddingHorizontal: 4, }} > @@ -167,6 +167,7 @@ export default function PluginInfoActionSheet({ }); }} /> + {!isCorePlugin && ( <PluginInfoIconButton label="Refetch" variant="secondary" @@ -174,12 +175,15 @@ export default function PluginInfoActionSheet({ onPress={refetchPlugin} disabled={loading} /> + )} + {!isCorePlugin && ( <PluginInfoIconButton label="Copy URL" variant="secondary" icon={findAssetId("LinkIcon")} onPress={copyPluginUrl} /> + )} <PluginInfoIconButton label="Clear Data" variant="secondary" diff --git a/src/core/vendetta/plugins.ts b/src/core/vendetta/plugins.ts index 4026b36..e8c065c 100644 --- a/src/core/vendetta/plugins.ts +++ b/src/core/vendetta/plugins.ts @@ -169,7 +169,7 @@ export const VdPluginManager = { if (!settings.safeMode?.enabled) { // Loop over any plugin that is enabled, update it if allowed, then start it. - await Promise.allSettled(allIds.filter(pl => plugins[pl].enabled).map(async pl => (plugins[pl].update && await this.fetchPlugin(pl).catch((e: Error) => logger.error(e.message)), await this.startPlugin(pl)))); + Promise.allSettled(allIds.filter(pl => plugins[pl].enabled).map(async pl => (plugins[pl].update && await this.fetchPlugin(pl).catch((e: Error) => logger.error(e.message)), await this.startPlugin(pl)))); // Wait for the above to finish, then update all disabled plugins that are allowed to. allIds.filter(pl => !plugins[pl].enabled && plugins[pl].update).forEach(pl => this.fetchPlugin(pl)); } diff --git a/src/index.ts b/src/index.ts index 7a690c1..341b32f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,6 +18,9 @@ import * as lib from "./lib"; export default async () => { // Load everything in parallel + + updatePlugins(); + await Promise.all([ initThemes(), injectFluxInterceptor(), @@ -30,7 +33,10 @@ export default async () => { initSettings(), initFixes(), // patchErrorBoundary(), - updatePlugins() + updatePlugins(), + updateFonts(), + initPlugins(), + VdPluginManager.initPlugins(), ]).then( // Push them all to unloader u => u.forEach(f => f && lib.unload.push(f)) @@ -39,17 +45,6 @@ export default async () => { // Assign window object window.bunny = lib; - // Once done, load Vendetta plugins - VdPluginManager.initPlugins() - .then(u => lib.unload.push(u)) - .catch(() => alert("Failed to initialize Vendetta plugins")); - - // And then, load Kettu plugins - initPlugins(); - - // Update the fonts - updateFonts(); - // We good :) logger.log("Kettu is ready!"); }; \ No newline at end of file diff --git a/src/lib/addons/fonts/index.ts b/src/lib/addons/fonts/index.ts index 730ceb1..47fc4d4 100644 --- a/src/lib/addons/fonts/index.ts +++ b/src/lib/addons/fonts/index.ts @@ -109,7 +109,7 @@ export async function removeFont(name: string) { export async function updateFonts() { await awaitStorage(fonts); - await Promise.allSettled( + Promise.allSettled( Object.keys(fonts).map( name => saveFont(fonts[name], fonts.__selected === name) ) diff --git a/src/lib/addons/plugins/index.ts b/src/lib/addons/plugins/index.ts index 2d4e9c1..762e0d9 100644 --- a/src/lib/addons/plugins/index.ts +++ b/src/lib/addons/plugins/index.ts @@ -380,7 +380,7 @@ export async function updatePlugins() { corePluginInstances.set(id, instance); } - await updateAllRepository(); + updateAllRepository(); } /** @@ -390,9 +390,9 @@ export async function initPlugins() { await awaitStorage(pluginRepositories, pluginSettings); // Now, start all enabled plugins... - await Promise.allSettled([...registeredPlugins.keys()].map(async id => { + Promise.allSettled([...registeredPlugins.keys()].map(async id => { if (isPluginEnabled(id)) { - await startPlugin(id); + startPlugin(id); } })); } diff --git a/src/lib/addons/themes/colors/updater.ts b/src/lib/addons/themes/colors/updater.ts index 7721628..b7d0e3f 100644 --- a/src/lib/addons/themes/colors/updater.ts +++ b/src/lib/addons/themes/colors/updater.ts @@ -27,7 +27,7 @@ export const _colorRef: InternalColorRef = { lastSetDiscordTheme: "darker" }; -export function updateBunnyColor(colorManifest: ColorManifest | null, { update = true }) { +export function updateBunnyColor(colorManifest: ColorManifest | null, { update = true, startup = true } ) { if (settings.safeMode?.enabled) return; const internalDef = colorManifest ? parseColorManifest(colorManifest) : null; @@ -55,5 +55,11 @@ export function updateBunnyColor(colorManifest: ColorManifest | null, { update = AppearanceManager.setShouldSyncAppearanceSettings(false); AppearanceManager.updateTheme(internalDef != null ? ref.key : ref.lastSetDiscordTheme); } + + if (startup) { + // scuffed but it works + AppearanceManager.setShouldSyncAppearanceSettings(true); + AppearanceManager.updateTheme(internalDef != null ? ref.key : ref.lastSetDiscordTheme); + } } diff --git a/src/lib/addons/themes/index.ts b/src/lib/addons/themes/index.ts index 546c040..6efffa9 100644 --- a/src/lib/addons/themes/index.ts +++ b/src/lib/addons/themes/index.ts @@ -104,10 +104,10 @@ export function selectTheme(theme: VdThemeInfo | null, write = true) { ); if (theme == null && write) { - updateBunnyColor(null, { update: true }); + updateBunnyColor(null, { update: false, startup: true }); return writeThemeToNative({}); } else if (theme) { - updateBunnyColor(theme.data, { update: true }); + updateBunnyColor(theme.data, { update: true, startup: false }); return writeThemeToNative(theme); } }