forked from Ittai/ittai
clientmod-specific and builder fixes
parent
e516d572a3
commit
fda0793414
|
@ -81,7 +81,8 @@ function build(argv, forceNoWatch = false) {
|
|||
exportNamespaceFrom: false,
|
||||
decorators: false,
|
||||
decoratorsBeforeExport: false,
|
||||
importMeta: false
|
||||
importMeta: false,
|
||||
topLevelAwait: true
|
||||
},
|
||||
transform: {
|
||||
react: {
|
||||
|
@ -100,7 +101,8 @@ function build(argv, forceNoWatch = false) {
|
|||
syntax: "typescript",
|
||||
tsx: true,
|
||||
dynamicImport: false,
|
||||
decorators: false
|
||||
decorators: false,
|
||||
topLevelAwait: true
|
||||
},
|
||||
transform: {
|
||||
react: {
|
||||
|
@ -143,6 +145,9 @@ function build(argv, forceNoWatch = false) {
|
|||
'/',
|
||||
)}`,
|
||||
},
|
||||
experiments: {
|
||||
topLevelAwait: true
|
||||
},
|
||||
watch: forceNoWatch ? false : argv.watch,
|
||||
watchOptions: {
|
||||
followSymlinks: true,
|
||||
|
@ -370,19 +375,20 @@ function build(argv, forceNoWatch = false) {
|
|||
const outputPath = path.join(path.resolve("./temp"), "index.js");
|
||||
let builtCode = fs.readFileSync(outputPath, "utf-8");
|
||||
|
||||
if (argv.production) builtCode = builtCode.replace(
|
||||
"sourceMappingURL=",
|
||||
"sourceMappingURL=http://localhost:3000/"
|
||||
);
|
||||
if (!builtCode.endsWith("})();")) {
|
||||
if (argv.production) builtCode = builtCode.replace(
|
||||
"sourceMappingURL=",
|
||||
"sourceMappingURL=http://localhost:3000/"
|
||||
);
|
||||
|
||||
builtCode = "(()=>{let hasModule;try {module; hasModule = true;}catch(e) {hasModule = false;}" + builtCode + "\nplugin = plugin.default;let wrappedPlugin = plugin.__ittaiWrap(plugin);if (hasModule) module.exports = wrappedPlugin;return wrappedPlugin;})();";
|
||||
|
||||
// Add clientmod-specific code.
|
||||
if (argv.powercordv2) builtCode = require("./powercordv2")(builtCode);
|
||||
if (argv.betterdiscord)
|
||||
builtCode = require("./betterdiscord")(builtCode, argv.plugin);
|
||||
if (argv.goosemod) builtCode = require("./goosemod")(builtCode);
|
||||
builtCode = "(()=>{let hasModule;try {module; hasModule = true;}catch(e) {hasModule = false;}" + builtCode + "\nplugin = plugin.default;let wrappedPlugin = plugin.__ittaiWrap(plugin);if (hasModule) module.exports = wrappedPlugin;return wrappedPlugin;})();";
|
||||
|
||||
// Add clientmod-specific code.
|
||||
if (argv.powercordv2) builtCode = require("./powercordv2")(builtCode);
|
||||
if (argv.betterdiscord)
|
||||
builtCode = require("./betterdiscord")(builtCode, argv.plugin);
|
||||
if (argv.goosemod) builtCode = require("./goosemod")(builtCode);
|
||||
}
|
||||
// builtCode = beautify(builtCode, {
|
||||
// indent_with_tabs: true,
|
||||
// });
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
module.exports = function (code) {
|
||||
return code.replace(
|
||||
"export default ___CSS_LOADER_EXPORT___;",
|
||||
`let element;
|
||||
export default {add: () => {
|
||||
element = document.createElement("style");
|
||||
element.textContent = ___CSS_LOADER_EXPORT___;
|
||||
document.head.appendChild(element);
|
||||
}, remove: () => {
|
||||
if (!element) return;
|
||||
element.remove();
|
||||
element = null;
|
||||
}}`
|
||||
);
|
||||
};
|
|
@ -9,7 +9,7 @@ const AccessibilityProvider = findByProps(
|
|||
const layerClass = findByProps("LayerClassName").LayerClassName;
|
||||
|
||||
/**
|
||||
* Wrap a component renderer out-of-tree in Discord.s providers
|
||||
* Wrap a component rendered out-of-tree in Discord's providers
|
||||
* @name DiscordProviders
|
||||
* @memberof module:components
|
||||
* @example
|
||||
|
|
|
@ -13,14 +13,14 @@ export default class BDPlugin {
|
|||
globalThis.BdApi.saveData(
|
||||
this.constructor.name,
|
||||
"settings",
|
||||
Object.assign(this.settings.all(), newSettings)
|
||||
Object.assign(this.__ittaiInternals.getAllSettings(), newSettings)
|
||||
);
|
||||
},
|
||||
setSetting: (key, value) => {
|
||||
globalThis.BdApi.saveData(
|
||||
this.constructor.name,
|
||||
"settings",
|
||||
Object.assign(this.settings.all(), {[key]: value})
|
||||
Object.assign(this.__ittaiInternals.getAllSettings(), {[key]: value})
|
||||
);
|
||||
},
|
||||
setSettingsPanel: (component) => {
|
||||
|
|
|
@ -27,10 +27,12 @@ if (getClientMod() === "powercordv2") {
|
|||
},
|
||||
|
||||
setSettingsPanel: (component) => {
|
||||
// if (typeof component === "function")
|
||||
// component = React.createElement(component);
|
||||
powercord.api.settings.registerSettings(this.entityID, {
|
||||
category: this.entityID,
|
||||
label: this.friendlyName,
|
||||
render: () => (typeof component === "function") ? React.createElement(component) : component,
|
||||
render: component
|
||||
});
|
||||
},
|
||||
removeSettingsPanel: () => {
|
||||
|
|
|
@ -23,7 +23,10 @@ export function find(filter) {
|
|||
case "goosemod":
|
||||
return clientWebpack.find(filter);
|
||||
case "powercordv2":
|
||||
return clientWebpack.getModule(x => x?.default && filter(x.default), false) || clientWebpack.getModule(filter, false);
|
||||
let isDefault = false;
|
||||
const mod = clientWebpack.getModule(x => x?.default && filter(x.default) && (isDefault = true), false) || clientWebpack.getModule(filter, false);
|
||||
|
||||
return isDefault ? mod.default : mod;
|
||||
case "betterdiscord":
|
||||
return clientWebpack.findModule(filter);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
{
|
||||
"name": "Ittai Example",
|
||||
"name": "Example Plugin",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"source": "https://bruh/moment",
|
||||
"updateUrl": "https://bruh/moment",
|
||||
"main": "index.js"
|
||||
"main": "index.js",
|
||||
"author": "AA",
|
||||
"description": "bruh"
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"path": "example"
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
}
|
Loading…
Reference in New Issue