minecraft characters.

This commit is contained in:
2026-08-28 19:30:47 +08:00
parent 9422bdc5c8
commit 9d695e704e
16 changed files with 964 additions and 52 deletions
+7
View File
@@ -59,6 +59,9 @@ async sendImageBytes(recipientId: string, bytes: number[]) : Promise<null> {
async sendInteraction(recipientId: string, content: InteractionContent) : Promise<null> {
return await TAURI_INVOKE("send_interaction", { recipientId, content });
},
async listPuppetStates() : Promise<PuppetState[]> {
return await TAURI_INVOKE("list_puppet_states");
},
async openActionWindow(name: string, title: string, pageUrl: string) : Promise<null> {
return await TAURI_INVOKE("open_action_window", { name, title, pageUrl });
},
@@ -79,6 +82,7 @@ friendStatusesChanged: FriendStatusesChanged,
friendsChanged: FriendsChanged,
networkStatusChanged: NetworkStatusChanged,
profileChanged: ProfileChanged,
puppetStatesChanged: PuppetStatesChanged,
remotesChanged: RemotesChanged
}>({
cursorPositionChanged: "cursor-position-changed",
@@ -89,6 +93,7 @@ friendStatusesChanged: "friend-statuses-changed",
friendsChanged: "friends-changed",
networkStatusChanged: "network-status-changed",
profileChanged: "profile-changed",
puppetStatesChanged: "puppet-states-changed",
remotesChanged: "remotes-changed"
})
@@ -128,6 +133,8 @@ export type FriendsChanged = { friends: Friend[] }
export type InteractionContent = { type: "text"; text: string } | { type: "wave" } | { type: "image"; mediaType: string; data: string }
export type NetworkStatusChanged = { statuses: ConnectionStatus[] }
export type ProfileChanged = { profile: User }
export type PuppetState = { id: string; position: CursorPosition; isMoving: boolean }
export type PuppetStatesChanged = { puppets: PuppetState[] }
export type Remote = { id: string; address: string; name: string | null; port: number | null }
export type RemoteInput = { address: string; name: string | null; port: number | null }
export type RemotesChanged = { remotes: Remote[] }
+2
View File
@@ -4,6 +4,7 @@ import { initFriendsListener } from "./friends";
import { initInteractionListener } from "./interactions";
import { initLiveMetadataListeners } from "./live-metadata";
import { initProfileListener } from "./profile";
import { initPuppetStatesListener } from "./puppets";
import { initRemotesListener } from "./remotes";
type Unlisten = () => void;
@@ -20,6 +21,7 @@ export function initAppListeners(): Unlisten {
initFriendStatusesListener(),
initLiveMetadataListeners(),
initInteractionListener(),
initPuppetStatesListener(),
])
.then((results) => {
const listeners = results.flatMap((result) =>
+19
View File
@@ -0,0 +1,19 @@
import { writable } from "svelte/store";
import { commands, events, type PuppetState } from "$lib/bindings";
export const puppetStates = writable<PuppetState[]>([]);
export const puppetStatesListenerError = writable("");
export async function initPuppetStatesListener() {
const unlisten = await events.puppetStatesChanged.listen((event) => {
puppetStates.set(event.payload.puppets);
});
try {
puppetStates.set(await commands.listPuppetStates());
} catch (error) {
puppetStatesListenerError.set(String(error));
}
return unlisten;
}