Remove __vendettaVersion and use constModules

This commit is contained in:
amsyarasyiq 2024-02-23 21:39:57 +08:00
parent 6e4c6df1e5
commit 98ca1305ce
7 changed files with 22 additions and 14 deletions

View file

@ -70,11 +70,10 @@ try {
jsc: {
externalHelpers: true,
transform: {
optimizer: {
constModules: {
globals: {
vars: {
__vendettaIsDev: `${!isRelease}`,
__vendettaVersion: `"${isRelease ? commitHash : timeString}"`,
"bunny-build": {
version: `"${isRelease ? commitHash : timeString}"`
}
}
}
@ -86,6 +85,9 @@ try {
"transform-classes",
"transform-arrow-functions",
"transform-block-scoping"
],
exclude: [
"transform-parameters"
]
},
});

View file

@ -1,4 +1,5 @@
import { instead } from "spitroast";
import { version } from "bunny-build";
// @ts-ignore - shut up fr
globalThis.window = globalThis;
@ -18,9 +19,9 @@ const init = (async () => {
console.log(stack ?? e?.toString?.() ?? e);
alert([
"Failed to load Vendetta!\n",
"Failed to load Bunny!\n",
`Build Number: ${ClientInfoManager.Build}`,
`Vendetta: ${__vendettaVersion}`,
`Bunny: ${version}`,
stack || e?.toString?.(),
].join("\n"));
}

1
src/global.d.ts vendored
View file

@ -3,7 +3,6 @@ import { BunnyObject } from "@lib/windowObject";
declare global {
type React = typeof import("react");
const __vendettaVersion: string;
interface Window {
[key: string]: any;

View file

@ -8,6 +8,7 @@ import settings from "@lib/settings";
import logger from "@lib/logger";
import { getLoaderName, isThemeSupported } from "./loader";
import type { PlatformConstants } from "react-native";
import { version } from "bunny-build";
export let socket: WebSocket;
export interface RNConstants extends PlatformConstants {
@ -78,7 +79,7 @@ export function patchLogHook() {
}
}
export const versionHash: string = __vendettaVersion;
export const versionHash: string = version;
export function getDebugInfo() {
// Hermes

View file

@ -1,18 +1,20 @@
import { instead } from "@lib/patcher";
export type MetroModules = { [id: number]: any };
type MetroModulesIndex = `${number}` | number;
export type MetroModules = { [id: MetroModulesIndex]: any };
export type PropIntellisense<P extends string | symbol> = Record<P, any> & Record<PropertyKey, any>;
export type PropsFinder = <T extends string | symbol>(...props: T[]) => PropIntellisense<T>;
export type PropsFinderAll = <T extends string | symbol>(...props: T[]) => PropIntellisense<T>[];
// Metro require
declare const __r: (moduleId: number) => any;
declare const __r: (moduleId: MetroModulesIndex) => any;
// Internal Metro error reporting logic
const originalHandler = window.ErrorUtils.getGlobalHandler();
// Function to blacklist a module, preventing it from being searched again
const blacklist = (id: number) => Object.defineProperty(window.modules, id, {
const blacklist = (id: MetroModulesIndex) => Object.defineProperty(window.modules, id, {
value: window.modules[id],
enumerable: false,
configurable: true,
@ -21,7 +23,7 @@ const blacklist = (id: number) => Object.defineProperty(window.modules, id, {
// Blacklist any "bad-actor" modules, e.g. the dreaded null proxy, the window itself, or undefined modules
for (const key in window.modules) {
const id = Number(key);
const id = key as MetroModulesIndex;
const module = window.modules[id]?.publicModule?.exports;
if (!module || module === window || module["proxygone"] === null) {
@ -51,7 +53,7 @@ const filterModules = (modules: MetroModules, single = false) => (filter: (m: an
const found = [];
for (const key in modules) {
const id = Number(key);
const id = key as MetroModulesIndex;
const module = modules[id]?.publicModule?.exports;
if (!modules[id].isInitialized) try {

View file

@ -42,7 +42,7 @@ function createBunnyObject(unloads: any[]) {
storage: { ...storage },
settings: settings,
loader: {
identity: window.__vendetta_loader,
identity: null,
config: loaderConfig,
},
logger: { ...logger },

3
src/modules.d.ts vendored Normal file
View file

@ -0,0 +1,3 @@
declare module "bunny-build" {
const version: string;
}