@ethora/chat-component-rn 26.5.18 → 26.5.20

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 (85) hide show
  1. package/lib/commonjs/components/MainComponents/ChatHeader.js +2 -0
  2. package/lib/commonjs/components/MainComponents/ChatHeader.js.map +1 -1
  3. package/lib/commonjs/components/MessageBubble/Message.js +24 -6
  4. package/lib/commonjs/components/MessageBubble/Message.js.map +1 -1
  5. package/lib/commonjs/components/Modals/AttachSheet/AttachSheet.js +9 -3
  6. package/lib/commonjs/components/Modals/AttachSheet/AttachSheet.js.map +1 -1
  7. package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js +5 -2
  8. package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
  9. package/lib/commonjs/components/Modals/styledModalComponents.js +6 -2
  10. package/lib/commonjs/components/Modals/styledModalComponents.js.map +1 -1
  11. package/lib/commonjs/components/styled/SendInput.js +6 -4
  12. package/lib/commonjs/components/styled/SendInput.js.map +1 -1
  13. package/lib/commonjs/components/styled/StyledComponents.js +6 -2
  14. package/lib/commonjs/components/styled/StyledComponents.js.map +1 -1
  15. package/lib/commonjs/components/styled/StyledInputComponents/StyledInputComponents.js +6 -1
  16. package/lib/commonjs/components/styled/StyledInputComponents/StyledInputComponents.js.map +1 -1
  17. package/lib/commonjs/helpers/parseMessageBody.js +12 -5
  18. package/lib/commonjs/helpers/parseMessageBody.js.map +1 -1
  19. package/lib/commonjs/helpers/typography.js +28 -0
  20. package/lib/commonjs/helpers/typography.js.map +1 -0
  21. package/lib/commonjs/hooks/useChatFonts.js +91 -7
  22. package/lib/commonjs/hooks/useChatFonts.js.map +1 -1
  23. package/lib/commonjs/hooks/useSendMessage.js +6 -6
  24. package/lib/commonjs/networking/outboundQueue.js +1 -1
  25. package/lib/module/components/MainComponents/ChatHeader.js +2 -0
  26. package/lib/module/components/MainComponents/ChatHeader.js.map +1 -1
  27. package/lib/module/components/MessageBubble/Message.js +24 -6
  28. package/lib/module/components/MessageBubble/Message.js.map +1 -1
  29. package/lib/module/components/Modals/AttachSheet/AttachSheet.js +9 -3
  30. package/lib/module/components/Modals/AttachSheet/AttachSheet.js.map +1 -1
  31. package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js +5 -2
  32. package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
  33. package/lib/module/components/Modals/styledModalComponents.js +6 -2
  34. package/lib/module/components/Modals/styledModalComponents.js.map +1 -1
  35. package/lib/module/components/styled/SendInput.js +6 -4
  36. package/lib/module/components/styled/SendInput.js.map +1 -1
  37. package/lib/module/components/styled/StyledComponents.js +6 -2
  38. package/lib/module/components/styled/StyledComponents.js.map +1 -1
  39. package/lib/module/components/styled/StyledInputComponents/StyledInputComponents.js +6 -1
  40. package/lib/module/components/styled/StyledInputComponents/StyledInputComponents.js.map +1 -1
  41. package/lib/module/helpers/parseMessageBody.js +12 -5
  42. package/lib/module/helpers/parseMessageBody.js.map +1 -1
  43. package/lib/module/helpers/typography.js +23 -0
  44. package/lib/module/helpers/typography.js.map +1 -0
  45. package/lib/module/hooks/useChatFonts.js +92 -8
  46. package/lib/module/hooks/useChatFonts.js.map +1 -1
  47. package/lib/module/hooks/useSendMessage.js +6 -6
  48. package/lib/module/networking/outboundQueue.js +1 -1
  49. package/lib/typescript/components/MainComponents/ChatHeader.d.ts.map +1 -1
  50. package/lib/typescript/components/MessageBubble/Message.d.ts.map +1 -1
  51. package/lib/typescript/components/Modals/AttachSheet/AttachSheet.d.ts.map +1 -1
  52. package/lib/typescript/components/Modals/ChatProfileModal/ChatProfileModal.d.ts.map +1 -1
  53. package/lib/typescript/components/Modals/styledModalComponents.d.ts +7 -1
  54. package/lib/typescript/components/Modals/styledModalComponents.d.ts.map +1 -1
  55. package/lib/typescript/components/styled/SendInput.d.ts.map +1 -1
  56. package/lib/typescript/components/styled/StyledComponents.d.ts +7 -1
  57. package/lib/typescript/components/styled/StyledComponents.d.ts.map +1 -1
  58. package/lib/typescript/components/styled/StyledInputComponents/StyledInputComponents.d.ts +6 -2
  59. package/lib/typescript/components/styled/StyledInputComponents/StyledInputComponents.d.ts.map +1 -1
  60. package/lib/typescript/helpers/parseMessageBody.d.ts +2 -1
  61. package/lib/typescript/helpers/parseMessageBody.d.ts.map +1 -1
  62. package/lib/typescript/helpers/typography.d.ts +14 -0
  63. package/lib/typescript/helpers/typography.d.ts.map +1 -0
  64. package/lib/typescript/hooks/useChatFonts.d.ts.map +1 -1
  65. package/lib/typescript/main.d.ts +1 -1
  66. package/lib/typescript/main.d.ts.map +1 -1
  67. package/lib/typescript/networking/outboundQueue.d.ts +2 -2
  68. package/lib/typescript/types/types.d.ts +53 -2
  69. package/lib/typescript/types/types.d.ts.map +1 -1
  70. package/package.json +1 -1
  71. package/src/components/MainComponents/ChatHeader.tsx +6 -1
  72. package/src/components/MessageBubble/Message.tsx +30 -8
  73. package/src/components/Modals/AttachSheet/AttachSheet.tsx +9 -3
  74. package/src/components/Modals/ChatProfileModal/ChatProfileModal.tsx +13 -2
  75. package/src/components/Modals/styledModalComponents.tsx +6 -3
  76. package/src/components/styled/SendInput.tsx +6 -4
  77. package/src/components/styled/StyledComponents.ts +6 -3
  78. package/src/components/styled/StyledInputComponents/StyledInputComponents.tsx +4 -1
  79. package/src/helpers/parseMessageBody.tsx +13 -4
  80. package/src/helpers/typography.ts +19 -0
  81. package/src/hooks/useChatFonts.ts +69 -11
  82. package/src/hooks/useSendMessage.tsx +6 -6
  83. package/src/main.ts +1 -0
  84. package/src/networking/outboundQueue.ts +2 -2
  85. package/src/types/types.ts +56 -2
@@ -22,21 +22,21 @@ import type { IConfig, IMessage } from '../types/types';
22
22
  // case (e.g. device offline before the message ever made it to the
23
23
  // XMPP socket) — bug #18.
24
24
  //
25
- // 5s window: a brief network blip that reconnects inside this window
25
+ // 10s window: a brief network blip that reconnects inside this window
26
26
  // still resolves on its own — the offline send is buffered in the
27
27
  // outbound queue (OUTBOUND_QUEUE_TTL_MS, kept in lockstep) and replayed
28
28
  // the moment the stream comes back, so the server echo flips the bubble
29
- // to delivered. Only a drop that outlasts 5s flips it to "Failed → tap
29
+ // to delivered. Only a drop that outlasts 10s flips it to "Failed → tap
30
30
  // to retry". If a slow send completes just after the window, the
31
31
  // delivery clears the failed flag (see newMessageMidlleware) so it
32
32
  // doesn't get stuck showing "Failed".
33
- const PENDING_WATCHDOG_MS = 30_000;
33
+ const PENDING_WATCHDOG_MS = 10_000;
34
34
 
35
35
  // Media gets a longer window than text: the optimistic bubble appears before
36
36
  // the file upload even starts, and a large file (up to the 50MB cap) over a
37
- // slow link can legitimately take far longer than 5s to upload + send. Failing
38
- // it at 5s mid-upload would flash a wrong "Failed" and let the user kick off a
39
- // duplicate upload. The text watchdog stays at 5s per product spec.
37
+ // slow link can legitimately take far longer than 10s to upload + send. Failing
38
+ // it at 10s mid-upload would flash a wrong "Failed" and let the user kick off a
39
+ // duplicate upload.
40
40
  const MEDIA_PENDING_WATCHDOG_MS = 30_000;
41
41
 
42
42
  // Monotonic counter for stanza ids. Bumped on each send within a single
package/src/main.ts CHANGED
@@ -47,4 +47,5 @@ export type {
47
47
  MessageProps,
48
48
  TypographyConfig,
49
49
  RNFontSource,
50
+ ChatTextStyle,
50
51
  } from './types/types';
@@ -41,7 +41,7 @@ export interface QueuedSend {
41
41
  * Per-item replay window. Kept in lockstep with the matching send
42
42
  * watchdog so a reconnect inside the window replays the buffered send,
43
43
  * while a longer drop lets the watchdog own the failure (no duplicate).
44
- * Text uses 5s, media 30s (large uploads need longer). Falls back to
44
+ * Text uses 10s, media 30s (large uploads need longer). Falls back to
45
45
  * OUTBOUND_QUEUE_TTL_MS when omitted.
46
46
  */
47
47
  ttlMs?: number;
@@ -51,7 +51,7 @@ export interface QueuedSend {
51
51
 
52
52
  // Default replay window (text). Mirrors PENDING_WATCHDOG_MS in useSendMessage.
53
53
  // Media enqueues a longer per-item ttlMs (see QueuedSend.ttlMs).
54
- export const OUTBOUND_QUEUE_TTL_MS = 30_000;
54
+ export const OUTBOUND_QUEUE_TTL_MS = 10_000;
55
55
 
56
56
  let queue: QueuedSend[] = [];
57
57
 
@@ -1,4 +1,4 @@
1
- import type { ViewStyle, ImageSourcePropType } from 'react-native';
1
+ import type { ViewStyle, ImageSourcePropType, TextStyle } from 'react-native';
2
2
  import type { Iso639_1Codes } from './models/language.model';
3
3
  import type { IMessage, IReply } from './models/message.model';
4
4
  import type { RoomMember } from './models/room.model';
@@ -248,10 +248,31 @@ export interface RNFontSource {
248
248
  * itself (e.g. via `@expo-google-fonts/*` or its own `useFonts`), pass only
249
249
  * `fontFamily` and leave `fonts` empty.
250
250
  */
251
+ /**
252
+ * Per-element font size / weight override.
253
+ *
254
+ * `fontWeight` is honoured even with a custom `fontFamily`: when
255
+ * `weightFamilies` is configured, the chat maps the requested weight to the
256
+ * matching family variant at render time (a single font file can't synthesise
257
+ * 500/600 — only fake-bold ~700 — so the variant family is what actually
258
+ * renders medium/semibold). Omit a field to keep the component default.
259
+ */
260
+ export interface ChatTextStyle {
261
+ /** Point size. */
262
+ fontSize?: number;
263
+ /** '400' | '500' | '600' | '700' | 'normal' | 'bold' | number. */
264
+ fontWeight?: TextStyle['fontWeight'];
265
+ }
266
+
251
267
  export interface TypographyConfig {
252
268
  /** Family applied across the chat UI. Must be loaded (via `fonts` or by the host). */
253
269
  fontFamily?: string;
254
- /** Optional per-weight families, used where the chat renders bolder text. */
270
+ /**
271
+ * Optional per-weight families. REQUIRED for `fontWeight` overrides to take
272
+ * visible effect when a custom `fontFamily` is set — RN can't synthesise
273
+ * intermediate weights from one font file, so each weight needs its own
274
+ * loaded family (and a matching entry in `fonts`).
275
+ */
255
276
  weightFamilies?: {
256
277
  regular?: string;
257
278
  medium?: string;
@@ -260,6 +281,39 @@ export interface TypographyConfig {
260
281
  };
261
282
  /** Fonts for the SDK to load with expo-font before applying `fontFamily`. */
262
283
  fonts?: RNFontSource[];
284
+
285
+ // ----- per-element size / weight overrides -----
286
+ /** Message body text inside chat bubbles. Default 16. */
287
+ messageText?: ChatTextStyle;
288
+ /** Sender name shown above incoming messages. Default 14 / "500". */
289
+ senderName?: ChatTextStyle;
290
+ /** Room title in the chat header. Default 16 / "600". */
291
+ headerTitle?: ChatTextStyle;
292
+ /** Message composer: the input/placeholder text plus its layout sizing. */
293
+ input?: ChatTextStyle & {
294
+ /** Min height of the input box in px. Default 40. */
295
+ minHeight?: number;
296
+ /** Max height before the input scrolls in px. Default 120. */
297
+ maxHeight?: number;
298
+ /** Width & height of the round send button in px. Default 40. */
299
+ sendButtonSize?: number;
300
+ };
301
+ /** Chat profile screen (opens when tapping the room name in the header). */
302
+ profile?: {
303
+ /** Big room-name title at the top of the profile screen. Default 24 / "400". */
304
+ title?: ChatTextStyle;
305
+ /** Member name rows. Default 16 / "600". */
306
+ memberName?: ChatTextStyle;
307
+ };
308
+ /** Attach (photo/document picker) bottom sheet. */
309
+ attachSheet?: {
310
+ /** "Attach" header label. Default 13 / "600". */
311
+ title?: ChatTextStyle;
312
+ /** Row labels (Camera / Gallery / Document). Default 16 / "500". */
313
+ rowLabel?: ChatTextStyle;
314
+ /** Cancel button. Default 16 / "600". */
315
+ cancelButton?: ChatTextStyle;
316
+ };
263
317
  }
264
318
 
265
319
  export interface IConfig {