SWC-ify and use classes
This commit is contained in:
parent
557e073a9c
commit
404f917e60
7 changed files with 43 additions and 35 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -2,4 +2,5 @@ node_modules/
|
|||
dist/
|
||||
pnpm-lock.yaml
|
||||
yarn.lock
|
||||
package-lock.json
|
||||
package-lock.json
|
||||
RichPresence
|
||||
|
|
|
|||
16
build.mjs
16
build.mjs
|
|
@ -5,7 +5,7 @@ import { createHash } from "crypto";
|
|||
import { readdirSync, readFileSync, writeFileSync } from "fs";
|
||||
import { argv } from "process";
|
||||
import { rollup, watch } from "rollup";
|
||||
import esbuild from "rollup-plugin-esbuild";
|
||||
import { swc } from "rollup-plugin-swc3";
|
||||
|
||||
const args = argv.slice(2);
|
||||
console.clear();
|
||||
|
|
@ -69,12 +69,14 @@ async function buildPlugin(plugin) {
|
|||
plugins: [
|
||||
nodeResolve(),
|
||||
commonjs(),
|
||||
esbuild({
|
||||
target: "esnext",
|
||||
supported: {
|
||||
"arrow": false, // arrows are supported but not with async await
|
||||
"class": false,
|
||||
"bigint": false,
|
||||
swc({
|
||||
env: {
|
||||
targets: "defaults",
|
||||
include: [
|
||||
"transform-classes",
|
||||
"transform-arrow-functions",
|
||||
],
|
||||
minify: {}
|
||||
},
|
||||
minify: true,
|
||||
})
|
||||
|
|
|
|||
14
package.json
14
package.json
|
|
@ -6,16 +6,16 @@
|
|||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^24.0.1",
|
||||
"@rollup/plugin-node-resolve": "^15.0.1",
|
||||
"@swc/core": "^1.3.36",
|
||||
"@types/react": "^18.0.28",
|
||||
"@types/react-native": "^0.70.11",
|
||||
"@typescript-eslint/eslint-plugin": "^5.52.0",
|
||||
"@typescript-eslint/parser": "^5.52.0",
|
||||
"esbuild": "^0.16.17",
|
||||
"eslint": "^8.34.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.53.0",
|
||||
"@typescript-eslint/parser": "^5.53.0",
|
||||
"eslint": "^8.35.0",
|
||||
"eslint-plugin-react": "^7.32.2",
|
||||
"rollup": "^3.15.0",
|
||||
"rollup-plugin-esbuild": "^5.0.0",
|
||||
"rollup": "^3.17.3",
|
||||
"rollup-plugin-swc3": "^0.8.0",
|
||||
"typescript": "^4.9.5",
|
||||
"vendetta-types": "^2.3.6"
|
||||
"vendetta-types": "^2.3.16"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,14 +4,15 @@ import { findByDisplayName } from "@vendetta/metro";
|
|||
let origState: boolean;
|
||||
const ChatInput = findByDisplayName("ChatInput");
|
||||
|
||||
export default {
|
||||
onLoad: () => {
|
||||
export default class HideGiftButton {
|
||||
onLoad() {
|
||||
logger.log("Starting HideGiftButton...");
|
||||
origState = ChatInput.defaultProps.hideGiftButton;
|
||||
ChatInput.defaultProps.hideGiftButton = true;
|
||||
},
|
||||
onUnload: () => {
|
||||
}
|
||||
onUnload() {
|
||||
logger.log("Unloading HideGiftButton..");
|
||||
ChatInput.defaultProps.hideGiftButton = origState;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ export const SET_ACTIVITY = findByProps("SET_ACTIVITY").SET_ACTIVITY;
|
|||
export const verboseLog = (...message: any) => currentSettings.verboseLogging && console.log(...message);
|
||||
|
||||
// Plugin entry point
|
||||
export default {
|
||||
onLoad: () => {
|
||||
export default class LastFM {
|
||||
onLoad() {
|
||||
console.log("Starting last.fm plugin..");
|
||||
global.pluginStopped = false;
|
||||
|
||||
|
|
@ -34,12 +34,15 @@ export default {
|
|||
FluxDispatcher.subscribe("CONNECTION_OPEN", () => {
|
||||
initialize().catch(console.error);
|
||||
});
|
||||
},
|
||||
onUnload: () => {
|
||||
}
|
||||
|
||||
onUnload() {
|
||||
console.log("Stopping last.fm...");
|
||||
global.pluginStopped = true;
|
||||
|
||||
flush();
|
||||
},
|
||||
settings: Settings
|
||||
};
|
||||
}
|
||||
|
||||
settings = Settings;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ import { findByProps } from "@vendetta/metro";
|
|||
const dialog = findByProps("show", "confirm", "close");
|
||||
const CallManager = findByProps("handleStartCall");
|
||||
|
||||
export default {
|
||||
onLoad: () => {
|
||||
export default class MoreConfirm {
|
||||
onLoad() {
|
||||
// Patch voice/video calls
|
||||
logger.log("MoreConfirm: patching calls...");
|
||||
|
||||
|
|
@ -49,4 +49,4 @@ export default {
|
|||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ import { FluxDispatcher } from "@vendetta/metro/common";
|
|||
|
||||
let unpatch: () => void;
|
||||
|
||||
export default {
|
||||
onLoad: () => {
|
||||
export default class NoIdle {
|
||||
onLoad() {
|
||||
logger.log("Starting NoIdle...");
|
||||
|
||||
unpatch = patcher.before("dispatch", FluxDispatcher, ([{ type }]) => {
|
||||
|
|
@ -12,9 +12,10 @@ export default {
|
|||
|
||||
return [{ type: "IDLE", idle: false }];
|
||||
});
|
||||
},
|
||||
onUnload: () => {
|
||||
}
|
||||
onUnload() {
|
||||
logger.log("Disabling NoIdle..");
|
||||
unpatch?.();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue