@ethora/chat-component 26.5.13 → 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.
- package/dist/{VideoCallOverlay-BmJrOxV-.js → VideoCallOverlay-6PVJgibC.js} +2108 -2070
- package/dist/{VideoCallOverlay-BmJrOxV-.js.map → VideoCallOverlay-6PVJgibC.js.map} +1 -1
- package/dist/assets/icons.d.ts +4 -0
- package/dist/components/MainComponents/LanguageSelectorModal.d.ts +13 -0
- package/dist/components/MessageBubble/MessageTranslate.d.ts +21 -0
- package/dist/components/MessageBubble/TranslatedMessageBody.d.ts +14 -0
- package/dist/helpers/scheduleAckCatchup.d.ts +27 -0
- package/dist/helpers/storeConsole.d.ts +2 -2
- package/dist/hooks/useChatWrapperInit.d.ts +2 -1
- package/dist/hooks/useIsMobileViewport.d.ts +1 -0
- package/dist/hooks/useMessageTranslation.d.ts +25 -0
- package/dist/hooks/useRoomState.d.ts +1 -1
- package/dist/i18n/strings.d.ts +15 -0
- package/dist/i18n/useT.d.ts +13 -0
- package/dist/{main-zYB-p6qE.js → main-L70Zd5ai.js} +11684 -11209
- package/dist/main-L70Zd5ai.js.map +1 -0
- package/dist/main.js +4 -4
- package/dist/networking/api-requests/translate.api.d.ts +9 -0
- package/dist/roomStore/index.d.ts +21 -9
- package/dist/roomStore/storage.d.ts +3 -0
- package/dist/types/models/config.model.d.ts +62 -0
- package/dist/types/models/language.model.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/components/MessageBubble/MessageTranslations.d.ts +0 -10
- package/dist/main-zYB-p6qE.js.map +0 -1
package/dist/assets/icons.d.ts
CHANGED
|
@@ -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;
|
|
@@ -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;
|
|
@@ -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;
|