Merge branch 'main' into github
This commit is contained in:
commit
1375b3617d
13 changed files with 80 additions and 84 deletions
|
|
@ -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: |
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ const config = {
|
|||
constModules: {
|
||||
globals: {
|
||||
"bunny-build-info": {
|
||||
version: `"1.3.0"`
|
||||
version: `"v1.3.4"`
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ interface CorePlugin {
|
|||
|
||||
// Called from @lib/plugins
|
||||
export const getCorePlugins = (): Record<string, CorePlugin> => ({
|
||||
"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"),
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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<UnifiedPluginModel>) {
|
||||
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 (
|
||||
<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 />
|
||||
<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>
|
||||
);
|
||||
}
|
||||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
19
src/index.ts
19
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!");
|
||||
};
|
||||
|
|
@ -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)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue