Compare commits

...

29 Commits

Author SHA1 Message Date
Lexi Sother f39dab4f40
Added clap PC module 2021-04-05 19:00:18 +00:00
Keanu Timmermans 2161ca7851
Renamed PCPlugins store. 2021-04-05 16:03:02 +02:00
Ducko db3fda3dd6
[PCPlugin] Rewrite original JS code and use relative path 2021-04-05 15:52:16 +02:00
Ducko d075c67250
[PCCompat > Entities] Plugin: fix handlers not being binded to this correctly 2021-04-05 15:52:09 +02:00
Ducko 36f2c81c89
[PCCompat > Util] Export GM reactUtils 2021-04-05 15:52:03 +02:00
Ducko aca4547d96
[PCCompat > Util] Initial Add 2021-04-05 15:51:57 +02:00
Ducko 0ba227267a
[PCCompat > Global] api.commands.registerCommand: custom sendMessage impl. (no return) 2021-04-05 15:51:46 +02:00
Ducko b658064804
[PCCompat > Global] api.commands.registerCommand: await executor incase async 2021-04-05 15:51:37 +02:00
Ducko 5b1f81ae60
[PCCompat > Global] api.commands.registerCommand: redo result implementation 2021-04-05 15:51:25 +02:00
Ducko d94d7bfc42
[PCCompat] Use powercord import instead of window global 2021-04-05 15:51:06 +02:00
Ducko ac3778e574
[Repos > PCPlugins] Add commit freeze 2021-04-05 15:50:56 +02:00
Ducko 7e8d5c4533
[Add Plugin (PCPlugin)] RazerMoon/muteNewGuild 2021-04-05 15:50:49 +02:00
Ducko 5f5b84588b
[PCCompat > Webpack] Fix retry not using async 2021-04-05 15:49:14 +02:00
Ducko 9ae7e3260f
[PCPlugin] Replace exports and add new 2021-04-05 15:49:08 +02:00
Ducko 3f46914b3f
[PCCompat > Global] api.commands.registerCommand: fix destructuring error 2021-04-05 15:49:01 +02:00
Ducko 958c1129b7
[Repos > PCPlugins] Empty repo 2021-04-05 15:48:35 +02:00
Ducko 87b84d23e5
[PCCompat > Global] api.commands.registerCommand: add alias TODO 2021-04-05 15:48:27 +02:00
Keanu Timmermans 31dea36c77
[Repos] Add PC Plugins repo 2021-04-05 15:48:01 +02:00
Ducko 2c48e7fd6f
[PCPlugin] Add preprocessor 2021-04-05 15:45:59 +02:00
Ducko c58dbac469
[PCCompat > Entities] Global: Add api.notices.sendToast 2021-04-05 15:45:41 +02:00
Ducko 86a2e3b7cb
[PCCompat > Entities] Global: Add api.commands.unregisterCommand 2021-04-05 15:45:35 +02:00
Ducko d95f20db3f
[PCCompat > Entities] Global: Add api.commands.registerCommand 2021-04-05 15:45:26 +02:00
Ducko a597534581
[PCCompat > Entities] Plugin: Add goosemodHandlers object prox 2021-04-05 15:45:20 +02:00
Ducko c4dcbb69ce
[PCCompat > Entities] Basic Plugin 2021-04-05 15:45:02 +02:00
Ducko bec46ebb8f
[PCCompat > Injector] Initial impl. 2021-04-05 15:44:52 +02:00
Ducko fe3e55f022
[PCCompat > Webpack] Initial impl. 2021-04-05 15:44:47 +02:00
Ducko 39ca4f77ec
[Package] Finish initial PC aliases and make JS files for them 2021-04-05 15:44:00 +02:00
Ducko 7b2d2def8a
[Package] Move GooseMod module wrappers to subdir, add some PC aliases 2021-04-05 15:43:43 +02:00
Lexi Sother 8afaa882bd
[Vercel] please shut up 2021-04-05 15:42:48 +02:00
15 changed files with 161 additions and 6 deletions

View File

@ -0,0 +1,64 @@
// Also set Powercord global var stuff here since entities import is needed to use Plugin (which every PC plugin uses)
const sendMessage = goosemodScope.webpackModules.findByProps('sendMessage', 'receiveMessage').sendMessage;
const getChannelId = goosemod.webpackModules.findByProps('getChannelId').getChannelId;
export const powercord = {
api: {
commands: {
registerCommand: ({ command, alias, description, usage, executor }) => {
// TODO: implement alias
goosemodScope.patcher.commands.add(command, description,
async ( { args: [ { text } ] } ) => {
const out = await executor(text.split(' ')); // Run original executor func (await incase it's an async function)
console.log(out);
if (!out.send) {
goosemodScope.patcher.internalMessage(out.result); // PC impl. sends internal message when out.send === false, so we also do the same via our previous Patcher API function
return;
}
// When send is true, we send it as a message via sendMessage
sendMessage(getChannelId(), {
content: out.result,
tts: false,
invalidEmojis: [],
validNonShortcutEmojis: []
});
}, [
{ type: 3, required: false, name: 'args', description: 'Arguments for PC command' } // Argument for any string for compat. with PC's classical commands
]);
},
unregisterCommand: (command) => {
goosemodScope.patcher.commands.remove(command);
}
},
notices: {
sendToast: (_id, { header, content, type, buttons }) => {
// TODO: implement full toast in future instead of just small current GM toast
goosemodScope.showToast(content);
}
}
}
};
export class Plugin {
constructor() {
}
get goosemodHandlers() {
return {
onImport: this.startPlugin.bind(this),
onRemove: this.pluginWillUnload.bind(this)
};
}
}

View File

@ -0,0 +1 @@
module.exports = goosemodScope.patcher; // GM's Patcher main functions (inject, uninject) have very similar syntax to PC's Injector as it was initially based on PC's design (however was later changed to use patch func)

View File

@ -0,0 +1,3 @@
module.exports = {
...goosemodScope.reactUtils // Export GooseMod React utils
};

View File

@ -0,0 +1,34 @@
const makeFinalFilter = (filter) => {
if (Array.isArray(filter)) {
const subs = filter;
filter = (mod) => subs.every((s) => mod[s] || (mod.__proto__ && mod.__proto__[s]));
}
return filter;
};
module.exports = {
getModule: (filter, retry, _forever) => { // Ignoring retry and forever arguments for basic implementation
filter = makeFinalFilter(filter);
const result = goosemodScope.webpackModules.find(filter);
if (!retry) { // retry = false: sync, retry = true: async (returns Promise)
return result;
}
return new Promise((res) => res(result));
},
getAllModules: (filter) => {
filter = makeFinalFilter(filter);
return goosemodScope.webpackModules.findAll(filter);
},
getModuleByDisplayName: (displayName) => {
return goosemodScope.webpackModules.findByDisplayName(displayName);
},
...goosemodScope.webpackModules.common // Export common modules (eg: React)
};

View File

@ -22,12 +22,16 @@
"parcel-bundler": "^1.12.4"
},
"alias": {
"@goosemod/patcher": "./moduleWrappers/patcher.js",
"@goosemod/webpack": "./moduleWrappers/webpack.js",
"@goosemod/logger": "./moduleWrappers/logger.js",
"@goosemod/reactUtils": "./moduleWrappers/reactUtils.js",
"@goosemod/toast": "./moduleWrappers/toast.js",
"@goosemod/settings": "./moduleWrappers/settings.js"
"@goosemod/patcher": "./moduleWrappers/goosemod/patcher.js",
"@goosemod/webpack": "./moduleWrappers/goosemod/webpack.js",
"@goosemod/logger": "./moduleWrappers/goosemod/logger.js",
"@goosemod/reactUtils": "./moduleWrappers/goosemod/reactUtils.js",
"@goosemod/toast": "./moduleWrappers/goosemod/toast.js",
"@goosemod/settings": "./moduleWrappers/goosemod/settings.js",
"powercord/entities": "./moduleWrappers/powercord/entities.js",
"powercord/injector": "./moduleWrappers/powercord/injector.js",
"powercord/webpack": "./moduleWrappers/powercord/webpack.js",
"powercord/util": "./moduleWrappers/powercord/util.js"
},
"type": "module"
}

View File

@ -1,5 +1,7 @@
import nova from './nova.js';
import pcPlugins from './ports/plugins/pcPlugins.js';
export default [
{
meta: {
@ -9,4 +11,12 @@ export default [
filename: 'nova',
modules: nova,
},
{
meta: {
name: 'Nova - PC Plugins',
description: 'Powercord plugins ported by NovaGM.',
},
filename: 'pcplugins',
modules: pcPlugins,
},
];

View File

@ -0,0 +1,8 @@
export default [
['RazerMoon/muteNewGuild', 'a8ea528e67089ea00a457623cebbef6a670127fc', '/manifest.json', 'pcPlugin', {
authors: ['162970149857656832'],
}],
['keanuplayz/PC-Clap', 'master', '/manifest.json', 'pcPlugin', {
authors: ['717352467280691331'],
}],
];

View File

@ -0,0 +1,26 @@
import { readFileSync, writeFileSync, mkdirSync, rmSync } from 'fs';
export default (manifestPath, repo) => {
const pcManifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
let manifest = {
main: '../index.js',
tags: ['port'],
name: pcManifest.name,
description: pcManifest.description,
version: pcManifest.version,
authors: [ pcManifest.author ]
};
rmSync(manifestPath);
mkdirSync(manifestPath);
const content = readFileSync(pcManifest.main || 'index.js', 'utf8');//.replace(/\\/g, '\\\\').replace(/`/g, '\\`');
const jsCode = content.replace(`module.exports = class`, `export default new class`).replace(/{ *Plugin *}/, `{ Plugin, powercord }`);
writeFileSync(`${manifestPath}/goosemodModule.json`, JSON.stringify(manifest));
writeFileSync(`${manifestPath}/../index.js`, jsCode);
};

5
vercel.json Normal file
View File

@ -0,0 +1,5 @@
{
"github": {
"silent": true
}
}