Wire validated core bridge, migrate daemon to it, verify live
This commit is contained in:
@@ -9,6 +9,7 @@ import "./ipcCommands";
|
||||
import "./appBadge";
|
||||
import "./fixes";
|
||||
import "./arrpc";
|
||||
import "./puppet";
|
||||
import "__patches__"; // auto generated by the build script
|
||||
|
||||
export * as Components from "./components";
|
||||
|
||||
@@ -8,6 +8,7 @@ import { SettingsRouter } from "@vencord/types/webpack/common";
|
||||
import { IpcCommands } from "shared/IpcEvents";
|
||||
|
||||
import { openScreenSharePicker } from "./components/ScreenSharePicker";
|
||||
import { handlePuppetAction } from "./puppet";
|
||||
|
||||
type IpcCommandHandler = (data: any) => any;
|
||||
|
||||
@@ -52,3 +53,5 @@ onIpcCommand(IpcCommands.NAVIGATE_SETTINGS, () => {
|
||||
onIpcCommand(IpcCommands.GET_LANGUAGES, () => navigator.languages);
|
||||
|
||||
onIpcCommand(IpcCommands.SCREEN_SHARE_PICKER, data => openScreenSharePicker(data.screens, data.skipPicker));
|
||||
|
||||
onIpcCommand(IpcCommands.PUPPET_COMMAND, data => handlePuppetAction(data.action, data.params));
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Veskslop core events — normalize client events and push them to main.
|
||||
*
|
||||
* The subscription starts only after Vencord registers the flux dispatcher.
|
||||
* A startup crash here would break the whole renderer bundle, so every step
|
||||
* is guarded.
|
||||
*/
|
||||
|
||||
import { ChannelStore } from "@vencord/types/webpack/common";
|
||||
import { filters, waitFor } from "@vencord/types/webpack";
|
||||
import type { PuppetEvent } from "shared/puppetProtocol";
|
||||
|
||||
function normalizeMessage(event: any): PuppetEvent | undefined {
|
||||
const message = event?.message;
|
||||
if (!message?.author) return undefined;
|
||||
|
||||
return {
|
||||
type: "MESSAGE_CREATE",
|
||||
id: message.id,
|
||||
channelId: event.channelId,
|
||||
guildId: event.guildId ?? null,
|
||||
channelType: ChannelStore.getChannel(event.channelId)?.type ?? null,
|
||||
author: {
|
||||
id: message.author.id,
|
||||
username: message.author.username,
|
||||
bot: !!message.author.bot
|
||||
},
|
||||
content: message.content ?? "",
|
||||
mentions: [
|
||||
...(message.mentions ?? []).map((user: any) => user.id),
|
||||
...(message.mentionIds ?? [])
|
||||
],
|
||||
timestamp: message.timestamp ?? new Date().toISOString()
|
||||
};
|
||||
}
|
||||
|
||||
let installed = false;
|
||||
|
||||
export function initPuppetEvents() {
|
||||
waitFor(filters.byProps("dispatch", "subscribe"), dispatcher => {
|
||||
if (installed) return;
|
||||
installed = true;
|
||||
|
||||
dispatcher.subscribe("MESSAGE_CREATE", (event: any) => {
|
||||
try {
|
||||
const normalized = normalizeMessage(event);
|
||||
if (normalized) VesktopNative.puppet.emit(normalized);
|
||||
} catch (error) {
|
||||
console.error("[puppet] event normalization failed:", error);
|
||||
}
|
||||
});
|
||||
|
||||
console.log("[veskslop] puppet events active");
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Veskslop core entry — starts the event push and exports the action handler.
|
||||
*/
|
||||
|
||||
import { initPuppetEvents } from "./events";
|
||||
|
||||
export { handlePuppetAction } from "./actions";
|
||||
|
||||
initPuppetEvents();
|
||||
Reference in New Issue
Block a user