@linktr.ee/messaging-react 4.4.7 → 4.5.0-rc-1788297811
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/assets/index.css +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +58 -43
- package/dist/index.js +1167 -1033
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/AttachmentCard/MediaPlayer.test.tsx +9 -5
- package/src/components/AttachmentCard/Thumbnail.test.tsx +4 -0
- package/src/components/ChannelActionsMenu/ChannelActionsMenu.test.tsx +18 -10
- package/src/components/ChannelList/ChannelListContext.test.tsx +7 -5
- package/src/components/ChannelList/CustomChannelPreview.test.tsx +7 -5
- package/src/components/ChannelList/index.test.tsx +1 -0
- package/src/components/ChannelView.test.tsx +20 -13
- package/src/components/CustomLinkPreviewList/CustomLinkPreviewList.test.tsx +4 -3
- package/src/components/CustomMessage/CustomMessage.test.tsx +6 -5
- package/src/components/CustomMessage/MessageTag.test.tsx +6 -0
- package/src/components/CustomMessage/SentMessageDeliveryStatus.test.tsx +19 -9
- package/src/components/CustomMessage/StreamAttachmentMessage.test.tsx +45 -5
- package/src/components/CustomMessage/StreamAttachmentMessage.tsx +6 -0
- package/src/components/CustomMessage/TipMessage/TipMessage.test.tsx +3 -0
- package/src/components/CustomMessageInput/CustomMessageInput.test.tsx +16 -7
- package/src/components/FaqList/FaqList.test.tsx +20 -12
- package/src/components/LinkAttachment/LinkAttachment.test.tsx +27 -14
- package/src/components/LinkAttachment/components/_shared/BubbleTail.test.tsx +1 -0
- package/src/components/LinkAttachment/components/_shared/CardBody.test.tsx +6 -6
- package/src/components/LinkAttachment/components/_shared/CardCta.test.tsx +8 -5
- package/src/components/LinkAttachment/components/_shared/CardShell.test.tsx +7 -5
- package/src/components/LinkAttachment/components/_shared/CardThumbnail.test.tsx +3 -8
- package/src/components/MessageAttachment/Audio/AudioAttachment.stories.tsx +165 -58
- package/src/components/MessageAttachment/Audio/WaveformAudioRow.test.tsx +155 -0
- package/src/components/MessageAttachment/Audio/WaveformAudioRow.tsx +455 -0
- package/src/components/MessageAttachment/Audio/audioRowRequester.test.ts +24 -0
- package/src/components/MessageAttachment/Audio/audioRowRequester.ts +16 -0
- package/src/components/MessageAttachment/Audio/index.tsx +83 -79
- package/src/components/MessageAttachment/MessageAttachment.behavior.test.tsx +22 -15
- package/src/components/MessageAttachment/MessageAttachment.test.tsx +279 -134
- package/src/components/MessageAttachment/_shared/Bubble.test.tsx +2 -0
- package/src/components/MessageAttachment/_shared/CarouselNav.test.tsx +5 -4
- package/src/components/MessageAttachment/_shared/CompactDocumentRow.test.tsx +4 -3
- package/src/components/MessageAttachment/_shared/DismissButton.test.tsx +4 -3
- package/src/components/MessageAttachment/_shared/DownloadAction.test.tsx +8 -5
- package/src/components/MessageAttachment/_shared/ImageViewer.test.tsx +6 -3
- package/src/components/MessageAttachment/_shared/MediaStackGrid.test.tsx +11 -4
- package/src/components/MessageAttachment/_shared/PdfViewer.test.tsx +5 -3
- package/src/components/MessageAttachment/_shared/VideoViewer.test.tsx +12 -3
- package/src/components/MessageAttachment/_shared/ViewerShell.test.tsx +13 -6
- package/src/components/MessageAttachment/_shared/useCarousel.test.tsx +10 -4
- package/src/components/MessageAttachment/_shared/useIsClient.ts +23 -0
- package/src/components/MessageAttachment/index.tsx +25 -9
- package/src/components/MessageAttachment/types.ts +19 -9
- package/src/components/MessageBubble/MessageBubble.test.tsx +8 -0
- package/src/components/RichCard/RichCard.test.tsx +10 -2
- package/src/styles.css +120 -0
package/dist/index.d.ts
CHANGED
|
@@ -37,37 +37,24 @@ export declare type AttachmentSourceType = 'image' | 'audio' | 'video' | 'docume
|
|
|
37
37
|
declare interface AudioAttachmentSharedProps extends MessageAttachmentBaseProps {
|
|
38
38
|
/** Audio source URL (`mp3`, `aac`, `wav`, …). */
|
|
39
39
|
src?: string;
|
|
40
|
-
/** MIME type hint —
|
|
40
|
+
/** MIME type hint — gates playability via the player's `canPlayType` probe. */
|
|
41
41
|
mimeType?: string;
|
|
42
42
|
/**
|
|
43
|
-
* Filename —
|
|
44
|
-
*
|
|
45
|
-
* expose a built-in title slot, so we don't render the filename
|
|
46
|
-
* inside the bubble itself.
|
|
43
|
+
* Filename — the download default name for the trailing action, and
|
|
44
|
+
* part of each control's accessible name.
|
|
47
45
|
*/
|
|
48
46
|
filename?: string;
|
|
49
47
|
/**
|
|
50
48
|
* Stacked audio. Takes precedence over `src` when set. Each item
|
|
51
|
-
* renders its own
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* attachment at a time.
|
|
49
|
+
* renders its own waveform row, vertically stacked inside the same
|
|
50
|
+
* bubble with an 8px gap. Sent + Received only — the composer surface
|
|
51
|
+
* accepts a single attachment at a time.
|
|
55
52
|
*/
|
|
56
53
|
items?: MessageAttachmentAudioItem[];
|
|
57
|
-
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
* - Single audio (no `items`, or `items.length === 1`) →
|
|
62
|
-
* `'metadata'` so the native player surfaces duration
|
|
63
|
-
* immediately.
|
|
64
|
-
* - Stacked audio (`items.length > 1`) → `'none'` so a thread
|
|
65
|
-
* of voice memos doesn't fan out N parallel metadata requests
|
|
66
|
-
* on first paint.
|
|
67
|
-
*
|
|
68
|
-
* Per-track overrides live on `AudioItem.preload`.
|
|
69
|
-
*/
|
|
70
|
-
preload?: MediaPreloadMode;
|
|
54
|
+
/** See `AudioItem.durationSeconds`. Applies to the single-`src` shape. */
|
|
55
|
+
durationSeconds?: number;
|
|
56
|
+
/** See `AudioItem.waveformData`. Applies to the single-`src` shape. */
|
|
57
|
+
waveformData?: number[];
|
|
71
58
|
}
|
|
72
59
|
|
|
73
60
|
/**
|
|
@@ -985,7 +972,7 @@ declare type MediaPreloadMode = 'none' | 'metadata' | 'auto';
|
|
|
985
972
|
* - Pdf / Audio / File render their compact rows / players in a
|
|
986
973
|
* vertical stack with an 8px gap between rows. Each row keeps
|
|
987
974
|
* its own activation target — Pdf opens the carousel-aware
|
|
988
|
-
* `PdfViewer` at that index, Audio gets its own
|
|
975
|
+
* `PdfViewer` at that index, Audio gets its own waveform player,
|
|
989
976
|
* and File downloads the asset for that row.
|
|
990
977
|
*
|
|
991
978
|
* The Composer surface accepts only a single attachment at a time,
|
|
@@ -1003,12 +990,29 @@ declare type MediaPreloadMode = 'none' | 'metadata' | 'auto';
|
|
|
1003
990
|
* download button to the chrome; the Video viewer relies on the
|
|
1004
991
|
* native `<video controls>` download menu, and the Pdf viewer
|
|
1005
992
|
* inherits the browser's built-in PDF download. Sibling-row Download
|
|
1006
|
-
* buttons on Pdf / File and the
|
|
993
|
+
* buttons on Pdf / File and the Audio card's trailing action expose
|
|
1007
994
|
* downloads outside the viewer too. The lightbox chrome is styled
|
|
1008
995
|
* with plain CSS (`.mes-media-viewer*`) so the package's shipped
|
|
1009
996
|
* stylesheet is enough to render the viewer correctly without a
|
|
1010
997
|
* Tailwind dependency in the consumer.
|
|
1011
998
|
*
|
|
999
|
+
* # Audio requires a `<Channel>` ancestor
|
|
1000
|
+
*
|
|
1001
|
+
* `MessageAttachment.Audio.*` renders the waveform player card —
|
|
1002
|
+
* a 32px play toggle, a 35-bar waveform with a progress fill and a
|
|
1003
|
+
* native seek control, the duration, and a 32px trailing action
|
|
1004
|
+
* (Remove in the composer, Download once sent). Playback is
|
|
1005
|
+
* `stream-chat-react`'s pooled `AudioPlayer`, which is what supplies
|
|
1006
|
+
* single-player-at-a-time across a thread, pause-on-navigation and
|
|
1007
|
+
* saved-position restore across virtualized remounts.
|
|
1008
|
+
*
|
|
1009
|
+
* That pool is provided by `<Channel>`. Rendered outside one the card
|
|
1010
|
+
* still draws in full, but its play and seek controls are disabled —
|
|
1011
|
+
* so a story or a new consumer surface must mount `<Channel>` (or
|
|
1012
|
+
* `stream-chat-react`'s `WithAudioPlayback`) for the card to be
|
|
1013
|
+
* playable. The waveform bars themselves are styled with plain CSS
|
|
1014
|
+
* (`.mes-audio-wave*`), so the shipped stylesheet is enough.
|
|
1015
|
+
*
|
|
1012
1016
|
* # Lazy-loading defaults
|
|
1013
1017
|
*
|
|
1014
1018
|
* Media attachments bake in network-friendly defaults for long chat
|
|
@@ -1029,13 +1033,12 @@ declare type MediaPreloadMode = 'none' | 'metadata' | 'auto';
|
|
|
1029
1033
|
* `VideoItem.preload` per item). Once the viewer is open the
|
|
1030
1034
|
* active item bumps to `preload="metadata"` so duration / the
|
|
1031
1035
|
* first frame appear immediately.
|
|
1032
|
-
* - **Audio** —
|
|
1033
|
-
* `
|
|
1034
|
-
*
|
|
1035
|
-
*
|
|
1036
|
-
*
|
|
1037
|
-
*
|
|
1038
|
-
* (or `AudioItem.preload` per track).
|
|
1036
|
+
* - **Audio** — no audio bytes are fetched until the user presses
|
|
1037
|
+
* play: the pooled `AudioPlayer` acquires the shared `<audio>`
|
|
1038
|
+
* element lazily. A card whose `durationSeconds` is unknown makes
|
|
1039
|
+
* one `preload="metadata"` header request to fill the duration
|
|
1040
|
+
* slot; supplying `durationSeconds` (which `StreamAttachmentMessage`
|
|
1041
|
+
* maps from the attachment's persisted `duration`) avoids even that.
|
|
1039
1042
|
* - **Pdf** / **File** — no inline media element to throttle; the
|
|
1040
1043
|
* bubble renders compact rows that download / open lazily on
|
|
1041
1044
|
* activation. No `loading` / `preload` props on these surfaces.
|
|
@@ -1080,28 +1083,40 @@ export declare interface MessageAttachmentAudioComposerProps extends ComposerExt
|
|
|
1080
1083
|
src?: string;
|
|
1081
1084
|
mimeType?: string;
|
|
1082
1085
|
filename?: string;
|
|
1083
|
-
/** See `
|
|
1084
|
-
|
|
1086
|
+
/** See `AudioItem.durationSeconds`. */
|
|
1087
|
+
durationSeconds?: number;
|
|
1088
|
+
/** See `AudioItem.waveformData`. */
|
|
1089
|
+
waveformData?: number[];
|
|
1085
1090
|
}
|
|
1086
1091
|
|
|
1087
1092
|
/** A single audio file inside an Audio attachment (single or stacked). */
|
|
1088
1093
|
export declare interface MessageAttachmentAudioItem {
|
|
1089
1094
|
src: string;
|
|
1090
|
-
/** MIME type hint —
|
|
1095
|
+
/** MIME type hint — gates playability via the player's `canPlayType` probe. */
|
|
1091
1096
|
mimeType?: string;
|
|
1092
1097
|
/**
|
|
1093
|
-
* Filename —
|
|
1094
|
-
*
|
|
1098
|
+
* Filename — the download default name for the card's trailing
|
|
1099
|
+
* action, and part of the card's accessible name.
|
|
1095
1100
|
*/
|
|
1096
1101
|
filename?: string;
|
|
1097
1102
|
/**
|
|
1098
|
-
*
|
|
1099
|
-
* the
|
|
1100
|
-
*
|
|
1101
|
-
*
|
|
1102
|
-
*
|
|
1103
|
+
* Track length in seconds. Rendered as `MM:SS` before playback
|
|
1104
|
+
* starts, so the duration is correct on first paint with no network
|
|
1105
|
+
* request. Sourced from the Stream attachment's `duration` field,
|
|
1106
|
+
* which the composer writes at send time. When omitted the card
|
|
1107
|
+
* shows `--:--` until a one-shot `loadedmetadata` probe resolves.
|
|
1103
1108
|
*/
|
|
1104
|
-
|
|
1109
|
+
durationSeconds?: number;
|
|
1110
|
+
/**
|
|
1111
|
+
* Waveform amplitudes, each `0..1`, in track order. Resampled to the
|
|
1112
|
+
* rendered bar count, so any length is accepted. Sourced from the
|
|
1113
|
+
* Stream attachment's `waveform_data`, which the composer computes
|
|
1114
|
+
* from the local file and writes at send time.
|
|
1115
|
+
*
|
|
1116
|
+
* When omitted, the card renders a flat placeholder row: every bar at
|
|
1117
|
+
* the minimum height, with the progress fill still tracking playback.
|
|
1118
|
+
*/
|
|
1119
|
+
waveformData?: number[];
|
|
1105
1120
|
}
|
|
1106
1121
|
|
|
1107
1122
|
export declare type MessageAttachmentAudioReceivedProps = AudioAttachmentSharedProps;
|