@ethora/chat-component 26.5.12 → 26.6.1

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.
Files changed (31) hide show
  1. package/dist/VideoCallOverlay-6PVJgibC.js +23647 -0
  2. package/dist/VideoCallOverlay-6PVJgibC.js.map +1 -0
  3. package/dist/assets/icons.d.ts +4 -0
  4. package/dist/components/MainComponents/LanguageSelectorModal.d.ts +13 -0
  5. package/dist/components/MessageBubble/MessageTranslate.d.ts +21 -0
  6. package/dist/components/MessageBubble/TranslatedMessageBody.d.ts +14 -0
  7. package/dist/components/RoomComponents/ChatRoomItem.d.ts +2 -2
  8. package/dist/components/RoomComponents/OnlineUsersPopover.d.ts +11 -0
  9. package/dist/helpers/isLikelyMucJid.d.ts +1 -0
  10. package/dist/helpers/scheduleAckCatchup.d.ts +27 -0
  11. package/dist/helpers/storeConsole.d.ts +2 -2
  12. package/dist/hooks/useChatWrapperInit.d.ts +2 -1
  13. package/dist/hooks/useIsMobileViewport.d.ts +1 -0
  14. package/dist/hooks/useMessageTranslation.d.ts +25 -0
  15. package/dist/hooks/useRoomState.d.ts +1 -1
  16. package/dist/i18n/strings.d.ts +15 -0
  17. package/dist/i18n/useT.d.ts +13 -0
  18. package/dist/main-L70Zd5ai.js +54215 -0
  19. package/dist/main-L70Zd5ai.js.map +1 -0
  20. package/dist/main.js +19 -77032
  21. package/dist/main.js.map +1 -1
  22. package/dist/networking/api-requests/translate.api.d.ts +9 -0
  23. package/dist/networking/xmppClient.d.ts +2 -0
  24. package/dist/roomStore/Middleware/unreadMidlleware.d.ts +1 -0
  25. package/dist/roomStore/index.d.ts +21 -9
  26. package/dist/roomStore/storage.d.ts +3 -0
  27. package/dist/types/models/config.model.d.ts +62 -0
  28. package/dist/types/models/language.model.d.ts +1 -1
  29. package/dist/version.d.ts +1 -1
  30. package/package.json +1 -1
  31. package/dist/components/MessageBubble/MessageTranslations.d.ts +0 -10
@@ -1,3 +1,7 @@
1
+ export declare const GlobeIcon: ({ color, ...props }: {
2
+ [x: string]: any;
3
+ color?: string;
4
+ }) => import("react/jsx-runtime").JSX.Element;
1
5
  export declare const AddNewIcon: ({ color, ...props }: {
2
6
  [x: string]: any;
3
7
  color?: string;
@@ -0,0 +1,13 @@
1
+ import { default as React } from 'react';
2
+ /**
3
+ * Globe-icon button for the chat header that opens a language picker modal.
4
+ * Picking a language dispatches `setLangSource`, which drives both:
5
+ * - the reader's translation target (Message.tsx falls back to it when
6
+ * `config.translates.readerLocale` / `config.i18n.locale` aren't set),
7
+ * - the source language declared on the reader's own outgoing messages.
8
+ *
9
+ * `langSource` lives in `chatSettingStore`, which redux-persist already
10
+ * persists (see roomStore/index.ts) - no separate storage needed here.
11
+ */
12
+ export declare const LanguageSelectorButton: React.FC;
13
+ export default LanguageSelectorButton;
@@ -0,0 +1,21 @@
1
+ import { FC } from 'react';
2
+ import { IConfig, IMessage } from '../../types/types';
3
+ interface MessageTranslateProps {
4
+ message: IMessage;
5
+ isUser: boolean;
6
+ config?: IConfig;
7
+ }
8
+ /**
9
+ * On-demand message translation (LinkedIn-style). Renders a "Translate" link
10
+ * under an incoming message; on click it calls `config.translates.onTranslate`
11
+ * (host endpoint) - or falls back to a server-provided translation already on
12
+ * the message - and shows the result inline with a "Show original" toggle.
13
+ *
14
+ * Visibility: `config.translates.showTranslateForMessage(message)` if the host
15
+ * supplies it (they keep the locale logic and just tell us yes/no); otherwise
16
+ * we compare the message's source base-language with the reader's base-language
17
+ * (region ignored, so en-US vs en-CA shows nothing). The reader's FULL locale
18
+ * (fr-CA vs fr-FR) is still forwarded to `onTranslate` as `targetLocale`.
19
+ */
20
+ declare const MessageTranslate: FC<MessageTranslateProps>;
21
+ export default MessageTranslate;
@@ -0,0 +1,14 @@
1
+ import { default as React, ReactNode } from 'react';
2
+ interface TranslatedMessageBodyProps {
3
+ /** Text as sent, in the sender's language. */
4
+ originalText: string;
5
+ accentColor?: string;
6
+ /** Renders the translated text (markdown pipeline, mentions, etc). */
7
+ children: ReactNode;
8
+ }
9
+ /**
10
+ * A message body that is showing a translation: the translated text reads
11
+ * as the primary content, with the original quoted above it for reference.
12
+ */
13
+ export declare const TranslatedMessageBody: React.FC<TranslatedMessageBodyProps>;
14
+ export default TranslatedMessageBody;
@@ -7,5 +7,5 @@ interface ChatRoomItemProps {
7
7
  performClick: (chat: IRoom) => void;
8
8
  config: IConfig;
9
9
  }
10
- declare const ChatRoomItem: React.FC<ChatRoomItemProps>;
11
- export default ChatRoomItem;
10
+ declare const _default: React.NamedExoticComponent<ChatRoomItemProps>;
11
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+ import { RoomMember } from '../../types/types';
3
+ interface OnlineUsersPopoverProps {
4
+ /** xmppUsernames currently online in this room (from useRoomPresence). */
5
+ onlineUsernames: string[];
6
+ members?: RoomMember[];
7
+ myXmppUsername: string;
8
+ isChatActive?: boolean;
9
+ }
10
+ declare const OnlineUsersPopover: React.FC<OnlineUsersPopoverProps>;
11
+ export default OnlineUsersPopover;
@@ -0,0 +1 @@
1
+ export declare const isLikelyMucJid: (jid: unknown) => jid is string;
@@ -0,0 +1,27 @@
1
+ import { default as XmppClient } from '../networking/xmppClient';
2
+ /**
3
+ * How long to wait for the MUC to reflect our own message back before
4
+ * assuming it never will. A MUC echo normally lands in ~100-300ms - far
5
+ * faster than a MAM round trip could answer anyway - so this only has to
6
+ * be generous enough not to fire during a slow-but-healthy send.
7
+ */
8
+ export declare const ACK_CATCHUP_DELAY_MS = 2500;
9
+ /** The echo is what flips `pending` to false (see addRoomMessage). */
10
+ export declare const hasEchoLanded: (roomJID: string, messageId: string) => boolean;
11
+ /**
12
+ * Safety net for a send whose MUC echo never arrives (e.g. our presence
13
+ * silently dropped): re-assert presence and pull history - ONCE, and only
14
+ * if the echo really is missing.
15
+ *
16
+ * It must stay a safety net. This used to be a poll: an immediate fetch on
17
+ * every send plus a retry loop re-arming every 700ms for 5s until the echo
18
+ * landed. Every getHistoryStanza makes the server re-send the room's last
19
+ * 10-20 archived messages down the socket, so one send produced ~6 MAM
20
+ * replies (9 worst case) - the "I get my message back 4 times" seen in the
21
+ * WS frames. It was self-amplifying too: a slower echo fired more history
22
+ * storms, and each storm's stanzas fed the reducer/persist churn that was
23
+ * slowing the echo down in the first place.
24
+ *
25
+ * @returns the timer, so the caller can cancel it on unmount.
26
+ */
27
+ export declare const scheduleAckCatchup: (client: XmppClient, roomJID: string, messageId: string, onSettled?: () => void) => ReturnType<typeof setTimeout>;
@@ -1,6 +1,6 @@
1
1
  export declare const useStoreConsole: () => {
2
- chatSettingStore: any;
3
- rooms: any;
2
+ chatSettingStore: Record<string, any> & import('redux-persist/es/persistReducer').PersistPartial;
3
+ rooms: Record<string, any> & import('redux-persist/es/persistReducer').PersistPartial;
4
4
  roomHeapSlice: import('../roomStore/roomHeapSlice').roomHeapSliceState;
5
5
  call: import('immer').WritableDraft<import('../roomStore/callSlice').CallState>;
6
6
  };
@@ -1,4 +1,4 @@
1
- import { IConfig } from '../types/types';
1
+ import { IConfig, Iso639_1Codes } from '../types/types';
2
2
  import { default as XmppClient } from '../networking/xmppClient';
3
3
  interface useChatWrapperInitProps {
4
4
  roomJID: string | null | undefined;
@@ -15,5 +15,6 @@ interface useChatWrapperInitResult {
15
15
  setClient: React.Dispatch<React.SetStateAction<XmppClient | null>>;
16
16
  isConnectionLost: boolean;
17
17
  }
18
+ export declare const resolveLegacyTranslatesLangSource: (translatesConfig?: IConfig["translates"]) => Iso639_1Codes | undefined;
18
19
  declare const useChatWrapperInit: ({ roomJID, wasAutoSelected, config, }: useChatWrapperInitProps) => useChatWrapperInitResult;
19
20
  export default useChatWrapperInit;
@@ -0,0 +1 @@
1
+ export declare const useIsMobileViewport: (breakpoint?: number) => boolean;
@@ -0,0 +1,25 @@
1
+ import { IMessage } from '../types/types';
2
+ export interface MessageTranslationState {
3
+ /** False when the message is already in the reader's language, or no
4
+ * translation is available (yet) - render the plain body, no quote. */
5
+ hasTranslation: boolean;
6
+ originalText: string;
7
+ /** Translation when hasTranslation, else the original - always safe to
8
+ * render directly. */
9
+ displayText: string;
10
+ }
11
+ /** Test-only: the cache is module state and would leak between cases. */
12
+ export declare const resetMessageTranslationCacheForTests: () => void;
13
+ /**
14
+ * Translation for ONE message, into the reader's language only.
15
+ *
16
+ * The sender doesn't pre-translate (that put an HTTP round trip in front of
17
+ * every send, translating into languages nobody may read). Instead each
18
+ * reader translates what they actually look at, into the one language they
19
+ * actually read - so cost scales with what's on screen, and the result is
20
+ * cached across renders/remounts.
21
+ *
22
+ * Server-attached translations (`message.translations`, from a
23
+ * pre-translating sender or a legacy stanza) win and skip the request.
24
+ */
25
+ export declare const useMessageTranslation: (message: Pick<IMessage, "body" | "langSource" | "translations">, readerLocale?: string, enabled?: boolean) => MessageTranslationState;
@@ -1,7 +1,7 @@
1
1
  export declare const useRoomState: (roomJID?: string) => {
2
2
  room: any;
3
3
  roomsList: any;
4
- activeRoomJID: any;
4
+ activeRoomJID: string;
5
5
  editAction: any;
6
6
  globalLoading: any;
7
7
  loadingText: any;
@@ -0,0 +1,15 @@
1
+ export type UiStringTable = Record<string, string>;
2
+ export declare const BUILTIN_STRINGS: Record<string, UiStringTable>;
3
+ export declare const DEFAULT_UI_LANGUAGE = "en";
4
+ /** Reduce a BCP-47 locale ("fr-CA") to its base language ("fr"), lowercased. */
5
+ export declare const toBaseLanguage: (locale?: string | null) => string;
6
+ /**
7
+ * Build the effective string table for a locale: the built-in table for that
8
+ * base language (falling back to English for any missing key), with host
9
+ * overrides from `config.i18n.strings` merged on top.
10
+ */
11
+ export declare const resolveStringTable: (locale?: string | null, overrides?: UiStringTable | null) => UiStringTable;
12
+ /** Replace `{name}` placeholders with values from `vars`. */
13
+ export declare const interpolate: (template: string, vars?: Record<string, string | number>) => string;
14
+ /** One-shot translate for non-React code (helpers). */
15
+ export declare const translateKey: (key: string, locale?: string | null, overrides?: UiStringTable | null, vars?: Record<string, string | number>) => string;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * UI translation hook. Reads the active locale + host overrides from
3
+ * `config.i18n` and returns a `t(key, vars?)` function.
4
+ *
5
+ * const t = useT();
6
+ * <SearchInput placeholder={t('search.placeholder')} />
7
+ * <span>{t('presence.onlineCount', { count })}</span>
8
+ *
9
+ * Locale resolves to the base language for captions (region is only used for
10
+ * message translation). Missing keys fall back to English, then to the raw
11
+ * key, so nothing ever renders blank.
12
+ */
13
+ export declare const useT: () => (key: string, vars?: Record<string, string | number>) => string;