@ethora/chat-component 26.5.6 → 26.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,47 @@
1
+ import { Element } from 'ltx';
2
+ import { IMessage } from '../types/models/message.model';
3
+ import { ReactionAction } from '../types/models/action.model';
4
+ /**
5
+ * A reaction restored from the MAM archive whose target message is NOT in the
6
+ * same history page. It is handed back to the caller so it can be dispatched to
7
+ * the store (where a target loaded by an earlier page or a live stanza lives).
8
+ */
9
+ export type DeferredReaction = ReactionAction;
10
+ /** Normalised view of a single `<reactions xmlns="urn:xmpp:reactions:0">` stanza. */
11
+ export interface ExtractedReaction {
12
+ /** Stanza id of the message the reaction targets (matches `IMessage.id`). */
13
+ messageId: string;
14
+ /** Full reactor JID, e.g. `<localpart>@xmpp.host/resource`. */
15
+ from: string;
16
+ /** Bare reactor id (`from` up to `@`); the key reactions are stored under. */
17
+ fromId: string;
18
+ /** Emoji shortcodes for this reactor; empty means the reactor cleared them. */
19
+ emoji: string[];
20
+ /** `<data senderFirstName=… senderLastName=…/>` attributes, if present. */
21
+ data: Record<string, string>;
22
+ /** Room JID derived from `<stanza-id by>` or the reactor JID. */
23
+ roomJID: string;
24
+ }
25
+ /**
26
+ * Pull the reaction details out of a forwarded MAM message that carries a
27
+ * `<reactions>` child. Returns null when the stanza is not a usable reaction
28
+ * (missing target id or reactor).
29
+ */
30
+ export declare const extractMamReaction: (msg: Element) => ExtractedReaction | null;
31
+ /**
32
+ * Apply MAM reaction stanzas to a freshly parsed history page.
33
+ *
34
+ * Reactions are archived in MAM as standalone `<reactions>` stanzas. The MAM
35
+ * fetch path bypasses the live `onReactionHistory` handler, so without this the
36
+ * reactions only ever existed for the live session and disappeared on refresh.
37
+ *
38
+ * Reactions whose target message is in this same page are merged directly onto
39
+ * the message object (so they are present the instant the page is stored).
40
+ * Reactions whose target is not in the page are returned as `deferred` for the
41
+ * caller to dispatch to the store (the target may live in an earlier page or
42
+ * have arrived live).
43
+ */
44
+ export declare const applyMamReactions: (messages: IMessage[], reactionStanzas: Element[]) => {
45
+ messages: IMessage[];
46
+ deferred: DeferredReaction[];
47
+ };