mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-21 22:50:42 +08:00
style: lint and fmt code
This commit is contained in:
+15
-4
@@ -1,7 +1,17 @@
|
||||
import type { LinkItemType } from "fumadocs-ui/layouts/shared";
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { LanguageSwitcher } from "@/components/language-switcher";
|
||||
|
||||
type NavLabelKey = "MemShellGenerator" | "ProbeShellGenerator" | "documents" | "about";
|
||||
|
||||
function NavLabel({ translationKey }: { translationKey: NavLabelKey }) {
|
||||
const { t } = useTranslation("common");
|
||||
|
||||
return t(translationKey);
|
||||
}
|
||||
|
||||
export const siteConfig = {
|
||||
name: "MemShellParty",
|
||||
url: "https://party.memshell.news",
|
||||
@@ -13,19 +23,20 @@ export const siteConfig = {
|
||||
blog: "https://reajason.eu.org",
|
||||
navLinks: [
|
||||
{
|
||||
text: "MemShellGenerator",
|
||||
text: <NavLabel translationKey="MemShellGenerator" />,
|
||||
url: "/memshell",
|
||||
},
|
||||
{
|
||||
text: "ProbeShellGenerator",
|
||||
text: <NavLabel translationKey="ProbeShellGenerator" />,
|
||||
url: "/probeshell",
|
||||
},
|
||||
{
|
||||
text: "Documents",
|
||||
text: <NavLabel translationKey="documents" />,
|
||||
url: "/docs",
|
||||
external: true,
|
||||
},
|
||||
{
|
||||
text: "About",
|
||||
text: <NavLabel translationKey="about" />,
|
||||
url: "/about",
|
||||
},
|
||||
{
|
||||
|
||||
@@ -16,8 +16,8 @@ export interface DecompileRequest {
|
||||
id: number;
|
||||
shellClassName: string;
|
||||
shellBytesBase64: string;
|
||||
injectorClassName: string;
|
||||
injectorBytesBase64: string;
|
||||
injectorClassName?: string;
|
||||
injectorBytesBase64?: string;
|
||||
}
|
||||
|
||||
export interface DecompileResponse {
|
||||
@@ -95,10 +95,15 @@ self.onmessage = async (event: MessageEvent<DecompileRequest>) => {
|
||||
try {
|
||||
const classes = new Map<string, Uint8Array>([
|
||||
[toJvmClassName(shellClassName), base64ToBytes(shellBytesBase64)],
|
||||
[toJvmClassName(injectorClassName), base64ToBytes(injectorBytesBase64)],
|
||||
]);
|
||||
const hasInjector = injectorClassName && injectorBytesBase64;
|
||||
if (hasInjector) {
|
||||
classes.set(toJvmClassName(injectorClassName), base64ToBytes(injectorBytesBase64));
|
||||
}
|
||||
const shell = await decompileClass(toJvmClassName(shellClassName), classes);
|
||||
const injector = await decompileClass(toJvmClassName(injectorClassName), classes);
|
||||
const injector = hasInjector
|
||||
? await decompileClass(toJvmClassName(injectorClassName), classes)
|
||||
: undefined;
|
||||
self.postMessage({ id, shell, injector } satisfies DecompileResponse);
|
||||
} catch (error) {
|
||||
self.postMessage({
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
import type { DecompiledClass, DecompileRequest, DecompileResponse } from "./decompile.worker";
|
||||
import type { MemShellResult } from "@/types/memshell";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
/** Structural subset shared by MemShellResult and ProbeShellResult */
|
||||
export interface DecompileInput {
|
||||
shellClassName?: string;
|
||||
shellBytesBase64Str?: string;
|
||||
injectorClassName?: string;
|
||||
injectorBytesBase64Str?: string;
|
||||
}
|
||||
|
||||
export interface DecompiledSources {
|
||||
shell: DecompiledClass | null;
|
||||
injector: DecompiledClass | null;
|
||||
@@ -67,10 +74,10 @@ function getWorker() {
|
||||
const entry = pending.get(id);
|
||||
if (!entry) return;
|
||||
pending.delete(id);
|
||||
if (error || !shell || !injector) {
|
||||
if (error || !shell) {
|
||||
entry.reject(new Error(error ?? "decompile failed"));
|
||||
} else {
|
||||
entry.resolve({ shell, injector });
|
||||
entry.resolve({ shell, injector: injector ?? null });
|
||||
}
|
||||
};
|
||||
worker.onerror = (event) => {
|
||||
@@ -90,7 +97,7 @@ function decompileInWorker(request: Omit<DecompileRequest, "id">) {
|
||||
});
|
||||
}
|
||||
|
||||
export function useDecompiledSources(generateResult: MemShellResult | undefined) {
|
||||
export function useDecompiledSources(generateResult: DecompileInput | undefined) {
|
||||
const shellClassName = generateResult?.shellClassName;
|
||||
const shellBytesBase64 = generateResult?.shellBytesBase64Str;
|
||||
const injectorClassName = generateResult?.injectorClassName;
|
||||
@@ -99,12 +106,12 @@ export function useDecompiledSources(generateResult: MemShellResult | undefined)
|
||||
const [state, setState] = useState<DecompileState>(IDLE);
|
||||
|
||||
useEffect(() => {
|
||||
if (!shellClassName || !shellBytesBase64 || !injectorClassName || !injectorBytesBase64) {
|
||||
if (!shellClassName || !shellBytesBase64) {
|
||||
setState(IDLE);
|
||||
return;
|
||||
}
|
||||
|
||||
const key = cacheKey(shellBytesBase64, injectorBytesBase64);
|
||||
const key = cacheKey(shellBytesBase64, injectorBytesBase64 ?? "");
|
||||
const cached = cacheGet(key);
|
||||
if (cached) {
|
||||
setState({ sources: cached, isDecompiling: false, error: null });
|
||||
|
||||
@@ -16,11 +16,11 @@ export function downloadContent(content: Blob, fileName: string, fileExtension:
|
||||
|
||||
export function base64ToBytes(base64String: string) {
|
||||
const byteCharacters = atob(base64String);
|
||||
const byteNumbers = new Array(byteCharacters.length);
|
||||
const bytes = new Uint8Array(byteCharacters.length);
|
||||
for (let i = 0; i < byteCharacters.length; i++) {
|
||||
byteNumbers[i] = byteCharacters.charCodeAt(i);
|
||||
bytes[i] = byteCharacters.charCodeAt(i);
|
||||
}
|
||||
return new Uint8Array(byteNumbers);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
export function downloadBytes(base64String: string, className?: string, jarName?: string) {
|
||||
|
||||
Reference in New Issue
Block a user