@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/main.js CHANGED
@@ -1,4 +1,4 @@
1
- import { k as e, R as o, C as t, M as p, l as r, X as u, m as n, n as d, o as h, p as i, q as y, t as I, v as l, w as T, x as g, y as C, z as c, D as m } from "./main-zYB-p6qE.js";
1
+ import { m as e, R as o, C as t, M as p, n as r, X as u, o as n, p as d, q as h, t as i, v as y, w as I, x as T, y as g, z as l, D as C, E as c, F as m } from "./main-L70Zd5ai.js";
2
2
  export {
3
3
  e as AuthTestIds,
4
4
  o as Chat,
@@ -12,9 +12,9 @@ export {
12
12
  i as logoutService,
13
13
  y as resendMessage,
14
14
  I as useInAppNotifications,
15
- l as useIsUserOnline,
16
- T as usePushNotifications,
17
- g as useQRCodeChat,
15
+ T as useIsUserOnline,
16
+ g as usePushNotifications,
17
+ l as useQRCodeChat,
18
18
  C as useRoomPresence,
19
19
  c as useTypography,
20
20
  m as useUnread
@@ -0,0 +1,9 @@
1
+ export interface TranslateEntry {
2
+ /** the reader's locale, verbatim (e.g. "fr-CA") - used as the lookup key */
3
+ language: string;
4
+ languageName: string;
5
+ translatedText: string;
6
+ }
7
+ /** Test-only escape hatch for the module-level 404 negative-cache. */
8
+ export declare const resetTranslateEndpointAvailabilityForTests: () => void;
9
+ export declare const fetchMessageTranslations: (text: string, source: string, targets: string[]) => Promise<TranslateEntry[]>;
@@ -1,27 +1,39 @@
1
1
  import { Reducer, AnyAction } from '@reduxjs/toolkit';
2
- import { IRoom } from '../types/types';
2
+ import { IMessage, IRoom } from '../types/types';
3
+ export declare const sanitizeRoomsMap: (roomsMap: Record<string, any>) => Record<string, IRoom>;
4
+ export declare const MAX_MESSAGES_PER_ROOM = 100;
5
+ export declare const MAX_PERSISTED_ROOMS = 100;
6
+ export declare const PERSISTED_ROOMS_CHAR_BUDGET = 1000000;
7
+ /** ~1.4x: AES + base64 overhead the encrypt transform adds on top. */
8
+ export declare const ENCRYPTION_INFLATION_FACTOR = 1.4;
9
+ export declare const getRoomActivityTimestamp: (room: IRoom) => number;
10
+ export declare const compactMessageForPersist: (message: IMessage) => IMessage;
11
+ export declare const optimizePersistedRooms: (rooms: Record<string, IRoom>, charBudget?: number) => Record<string, IRoom>;
12
+ export declare const limitMessagesTransform: import('redux-persist').Transform<any, any, Record<string, any>, Record<string, any>>;
13
+ export declare const scrubSensitiveChatStateTransform: import('redux-persist').Transform<any, any, Record<string, any>, Record<string, any>>;
14
+ export declare const sanitizeRoomsStateTransform: import('redux-persist').Transform<any, any, Record<string, any>, Record<string, any>>;
3
15
  declare const rootReducer: Reducer<{
4
- chatSettingStore: any;
5
- rooms: any;
16
+ chatSettingStore: Record<string, any> & import('redux-persist/es/persistReducer').PersistPartial;
17
+ rooms: Record<string, any> & import('redux-persist/es/persistReducer').PersistPartial;
6
18
  roomHeapSlice: import('./roomHeapSlice').roomHeapSliceState;
7
19
  call: import('immer').WritableDraft<import('./callSlice').CallState>;
8
20
  }, import('redux').UnknownAction, Partial<{
9
- chatSettingStore: any;
10
- rooms: any;
21
+ chatSettingStore: Record<string, any> & import('redux-persist/es/persistReducer').PersistPartial;
22
+ rooms: Record<string, any> & import('redux-persist/es/persistReducer').PersistPartial;
11
23
  roomHeapSlice: import('./roomHeapSlice').roomHeapSliceState;
12
24
  call: import('immer').WritableDraft<import('./callSlice').CallState>;
13
25
  }>>;
14
26
  export type RootState = ReturnType<typeof rootReducer>;
15
27
  export declare const getActiveRoom: (state: RootState) => IRoom | null;
16
28
  export declare const store: import('@reduxjs/toolkit').EnhancedStore<{
17
- chatSettingStore: any;
18
- rooms: any;
29
+ chatSettingStore: Record<string, any> & import('redux-persist/es/persistReducer').PersistPartial;
30
+ rooms: Record<string, any> & import('redux-persist/es/persistReducer').PersistPartial;
19
31
  roomHeapSlice: import('./roomHeapSlice').roomHeapSliceState;
20
32
  call: import('immer').WritableDraft<import('./callSlice').CallState>;
21
33
  }, AnyAction, import('@reduxjs/toolkit').Tuple<[import('redux').StoreEnhancer<{
22
34
  dispatch: import('redux-thunk').ThunkDispatch<{
23
- chatSettingStore: any;
24
- rooms: any;
35
+ chatSettingStore: Record<string, any> & import('redux-persist/es/persistReducer').PersistPartial;
36
+ rooms: Record<string, any> & import('redux-persist/es/persistReducer').PersistPartial;
25
37
  roomHeapSlice: import('./roomHeapSlice').roomHeapSliceState;
26
38
  call: import('immer').WritableDraft<import('./callSlice').CallState>;
27
39
  }, undefined, import('redux').UnknownAction>;
@@ -1,3 +1,6 @@
1
+ import { default as createWebStorage } from 'redux-persist/lib/storage/createWebStorage';
2
+ export declare const isQuotaExceededError: (error: unknown) => boolean;
3
+ export declare const withQuotaHandling: (engine: ReturnType<typeof createWebStorage>) => ReturnType<typeof createWebStorage>;
1
4
  declare const storage: {
2
5
  getItem(_key: string): Promise<any>;
3
6
  setItem(_key: string, value: any): Promise<any>;
@@ -222,6 +222,68 @@ export interface IConfig {
222
222
  translates?: {
223
223
  enabled: boolean;
224
224
  translations?: Iso639_1Codes;
225
+ /**
226
+ * 'auto' shows the translation inline automatically (legacy behaviour).
227
+ * 'on-demand' shows a "Translate" link the reader clicks (LinkedIn-style),
228
+ * then renders the result inline with a "Show original" toggle. Default 'auto'.
229
+ */
230
+ mode?: 'auto' | 'on-demand';
231
+ /**
232
+ * Locales a message is pre-translated into BEFORE it is sent (e.g.
233
+ * ["en-CA", "fr-CA", "es-US"]). The sender calls the translation service
234
+ * (see `endpoint`) and embeds the result in the stanza as
235
+ * `<translations value='...'/>`, so every recipient receives the message
236
+ * already translated and renders it with the existing parser - no
237
+ * ejabberd module needed.
238
+ *
239
+ * Keep this to the locales actually present in the room: every extra target
240
+ * is one more translation shipped per message. Leave empty to disable
241
+ * pre-translation (the on-demand `onTranslate` path still works).
242
+ */
243
+ targets?: string[];
244
+ /**
245
+ * Translation service URL for pre-translation (GET ?source=&text=,
246
+ * responding `{translates:[{translatedText, language, languageName}]}`).
247
+ * Defaults to Ethora's hosted service; point it at your own deployment
248
+ * for self-hosted setups.
249
+ */
250
+ endpoint?: string;
251
+ /**
252
+ * Reader's full locale (BCP-47, e.g. "fr-CA"). Falls back to
253
+ * `config.i18n.locale`. The region is passed through to `onTranslate` so
254
+ * the service can distinguish fr-CA vs fr-FR; the Translate button
255
+ * visibility comparison ignores the region (en-US vs en-CA => no button).
256
+ */
257
+ readerLocale?: string;
258
+ /**
259
+ * Host-provided translation function. When set, the Translate action calls
260
+ * this - wire it to your own endpoint (or Google / OpenAI). When omitted,
261
+ * the component falls back to server-provided translations parsed onto the
262
+ * message (`message.translations`).
263
+ */
264
+ onTranslate?: (text: string, ctx: {
265
+ sourceLocale?: string;
266
+ targetLocale: string;
267
+ message: IMessage;
268
+ }) => Promise<string>;
269
+ /**
270
+ * Host predicate deciding whether to show the Translate action for a given
271
+ * message. When omitted, the component compares base languages (message
272
+ * source vs reader, region ignored) and shows the action when they differ.
273
+ */
274
+ showTranslateForMessage?: (message: IMessage) => boolean;
275
+ };
276
+ /**
277
+ * Static UI i18n (interface captions like "Search...", "Type message").
278
+ * `locale` is a BCP-47 tag the host passes from the device/user (e.g. "en",
279
+ * "fr-CA", "es-US"); captions resolve to its base language. `strings`
280
+ * overrides or extends any built-in caption by key (see src/i18n/strings.ts).
281
+ * Built-in languages: en, fr, es. Independent from `translates` (dynamic
282
+ * per-message translation).
283
+ */
284
+ i18n?: {
285
+ locale?: string;
286
+ strings?: Record<string, string>;
225
287
  };
226
288
  disableRoomConfig?: boolean;
227
289
  disableProfilesInteractions?: boolean;
@@ -1,4 +1,4 @@
1
- export type Iso639_1Codes = 'en' | 'es' | 'pt' | 'ht' | 'zh';
1
+ export type Iso639_1Codes = 'en' | 'es' | 'pt' | 'ht' | 'fr' | 'zh';
2
2
  export interface Language {
3
3
  iso639_1: Iso639_1Codes;
4
4
  name: string;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const ETHORA_CHAT_COMPONENT_VERSION = "26.5.11";
1
+ export declare const ETHORA_CHAT_COMPONENT_VERSION = "26.6.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethora/chat-component",
3
- "version": "26.5.13",
3
+ "version": "26.6.1",
4
4
  "type": "module",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",
@@ -1,10 +0,0 @@
1
- import { FC } from 'react';
2
- import { IConfig, IMessage } from '../../types/types';
3
- interface MessageTranslationsProps {
4
- message: IMessage;
5
- langSource?: string;
6
- isUser: boolean;
7
- config?: IConfig;
8
- }
9
- declare const MessageTranslations: FC<MessageTranslationsProps>;
10
- export default MessageTranslations;