testing
This commit is contained in:
40
assets/vencord/VencordNativeStub.ts
Normal file
40
assets/vencord/VencordNativeStub.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
let webclass;
|
||||
|
||||
const promise = new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
new QWebChannel(qt.webChannelTransport, function (channel) {
|
||||
webclass = channel.objects.webclass;
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
async function prepareWebclass() {
|
||||
if (!webclass) await promise;
|
||||
}
|
||||
|
||||
window.VencordNative = {
|
||||
getVersions: () => ({}),
|
||||
ipc: {
|
||||
send: async (event: string, ...args: any[]) => {
|
||||
await prepareWebclass();
|
||||
webclass.vencordSend(event, args);
|
||||
},
|
||||
sendSync: (event: string, ...args: any[]) => {
|
||||
if (event === "VencordGetSettings") return "{}";
|
||||
else throw new Error("Synchroneous IPC not implemented");
|
||||
},
|
||||
on(event: string, listener: () => {}) {
|
||||
// TODO quickCss
|
||||
},
|
||||
off(event: string, listener: () => {}) {
|
||||
// not used for now
|
||||
},
|
||||
invoke:
|
||||
(event: string, ...args: any[]) =>
|
||||
async () => {
|
||||
await prepareWebclass();
|
||||
return webclass.vencordSend(event, args);
|
||||
},
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user