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