messages, wavings and images

This commit is contained in:
2026-08-26 00:59:31 +08:00
parent 5d7d294a80
commit 74a5268420
22 changed files with 1779 additions and 89 deletions
+13
View File
@@ -44,6 +44,15 @@ async getPublicKey() : Promise<string> {
async listStatuses() : Promise<ConnectionStatus[]> {
return await TAURI_INVOKE("list_statuses");
},
async pickAndSendImage(recipientId: string) : Promise<boolean> {
return await TAURI_INVOKE("pick_and_send_image", { recipientId });
},
async sendImageBytes(recipientId: string, bytes: number[]) : Promise<null> {
return await TAURI_INVOKE("send_image_bytes", { recipientId, bytes });
},
async sendInteraction(recipientId: string, content: InteractionContent) : Promise<null> {
return await TAURI_INVOKE("send_interaction", { recipientId, content });
},
async updateSceneHitboxes(hitboxes: SceneHitbox[]) : Promise<null> {
return await TAURI_INVOKE("update_scene_hitboxes", { hitboxes });
}
@@ -56,6 +65,7 @@ export const events = __makeEvents__<{
cursorPositionChanged: CursorPositionChanged,
foregroundAppChanged: ForegroundAppChanged,
friendForegroundAppChanged: FriendForegroundAppChanged,
friendInteractionReceived: FriendInteractionReceived,
friendsChanged: FriendsChanged,
networkStatusChanged: NetworkStatusChanged,
profileChanged: ProfileChanged,
@@ -64,6 +74,7 @@ remotesChanged: RemotesChanged
cursorPositionChanged: "cursor-position-changed",
foregroundAppChanged: "foreground-app-changed",
friendForegroundAppChanged: "friend-foreground-app-changed",
friendInteractionReceived: "friend-interaction-received",
friendsChanged: "friends-changed",
networkStatusChanged: "network-status-changed",
profileChanged: "profile-changed",
@@ -95,7 +106,9 @@ raw: CursorPosition;
mapped: CursorPosition }
export type ForegroundAppChanged = { meta: AppMeta }
export type FriendForegroundAppChanged = { friendId: string; meta: AppMeta }
export type FriendInteractionReceived = { interactionId: string; friendId: string; content: InteractionContent }
export type FriendsChanged = { friends: User[] }
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 Remote = { id: string; address: string; name: string | null; port: number | null }
+9 -1
View File
@@ -15,6 +15,9 @@
triggerClass?: string;
panelClass?: string;
panelStyle?: string;
closeOnOutsidePointer?: boolean;
closeOnWindowBlur?: boolean;
closeOnFocusOut?: boolean;
};
let {
@@ -29,6 +32,9 @@
triggerClass = "",
panelClass = "",
panelStyle,
closeOnOutsidePointer: dismissOnOutsidePointer = true,
closeOnWindowBlur: dismissOnWindowBlur = true,
closeOnFocusOut: dismissOnFocusOut = true,
}: Props = $props();
let root = $state<HTMLDivElement>();
@@ -57,6 +63,7 @@
function closeOnOutsidePointer(event: PointerEvent) {
if (
open &&
dismissOnOutsidePointer &&
root &&
event.target instanceof Node &&
!root.contains(event.target)
@@ -68,6 +75,7 @@
function closeOnFocusOut(event: FocusEvent) {
if (
open &&
dismissOnFocusOut &&
root &&
(!(event.relatedTarget instanceof Node) ||
!root.contains(event.relatedTarget))
@@ -77,7 +85,7 @@
}
function closeOnWindowBlur() {
if (open) setOpen(false);
if (open && dismissOnWindowBlur) setOpen(false);
}
</script>
+2
View File
@@ -1,5 +1,6 @@
import { initConnectionStatusesListener } from "./connection-status";
import { initFriendsListener } from "./friends";
import { initInteractionListener } from "./interactions";
import { initLiveMetadataListeners } from "./live-metadata";
import { initProfileListener } from "./profile";
import { initRemotesListener } from "./remotes";
@@ -16,6 +17,7 @@ export function initAppListeners(): Unlisten {
initProfileListener(),
initConnectionStatusesListener(),
initLiveMetadataListeners(),
initInteractionListener(),
])
.then((results) => {
const listeners = results.flatMap((result) =>
+12
View File
@@ -0,0 +1,12 @@
import { writable } from "svelte/store";
import { events, type FriendInteractionReceived } from "$lib/bindings";
export const incomingInteraction = writable<FriendInteractionReceived | null>(
null,
);
export async function initInteractionListener() {
return events.friendInteractionReceived.listen((event) => {
incomingInteraction.set(event.payload);
});
}