stream-chat-angular 5.3.2 → 5.4.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 (90) hide show
  1. package/assets/i18n/en.d.ts +4 -0
  2. package/assets/version.d.ts +1 -1
  3. package/esm2020/assets/i18n/en.mjs +5 -1
  4. package/esm2020/assets/version.mjs +2 -2
  5. package/esm2020/lib/attachment-list/attachment-list.component.mjs +4 -4
  6. package/esm2020/lib/attachment-preview-list/attachment-preview-list.component.mjs +5 -5
  7. package/esm2020/lib/attachment.service.mjs +60 -10
  8. package/esm2020/lib/channel-list/channel-list.component.mjs +3 -3
  9. package/esm2020/lib/channel-preview/channel-preview.component.mjs +1 -1
  10. package/esm2020/lib/file-utils.mjs +35 -0
  11. package/esm2020/lib/format-duration.mjs +16 -0
  12. package/esm2020/lib/icon/icon-placeholder/icon-placeholder.component.mjs +28 -0
  13. package/esm2020/lib/icon/icon.component.mjs +1 -1
  14. package/esm2020/lib/icon/icon.module.mjs +37 -0
  15. package/esm2020/lib/{loading-indicator → icon/loading-indicator}/loading-indicator.component.mjs +1 -1
  16. package/esm2020/lib/{loading-indicator-placeholder → icon/loading-indicator-placeholder}/loading-indicator-placeholder.component.mjs +2 -2
  17. package/esm2020/lib/is-safari.mjs +2 -0
  18. package/esm2020/lib/message/message.component.mjs +6 -6
  19. package/esm2020/lib/message-input/message-input-config.service.mjs +6 -1
  20. package/esm2020/lib/message-input/message-input.component.mjs +57 -14
  21. package/esm2020/lib/message-input/voice-recorder.service.mjs +27 -0
  22. package/esm2020/lib/message-list/message-list.component.mjs +9 -9
  23. package/esm2020/lib/modal/modal.component.mjs +1 -1
  24. package/esm2020/lib/paginated-list/paginated-list.component.mjs +1 -1
  25. package/esm2020/lib/stream-chat.module.mjs +21 -35
  26. package/esm2020/lib/thread/thread.component.mjs +1 -1
  27. package/esm2020/lib/types.mjs +1 -1
  28. package/esm2020/lib/voice-recorder/amplitude-recorder.service.mjs +119 -0
  29. package/esm2020/lib/voice-recorder/audio-recorder.service.mjs +79 -0
  30. package/esm2020/lib/voice-recorder/media-recorder.mjs +190 -0
  31. package/esm2020/lib/voice-recorder/mp3-transcoder.mjs +61 -0
  32. package/esm2020/lib/voice-recorder/transcoder.service.mjs +121 -0
  33. package/esm2020/lib/voice-recorder/voice-recorder-wavebar/voice-recorder-wavebar.component.mjs +35 -0
  34. package/esm2020/lib/voice-recorder/voice-recorder.component.mjs +80 -0
  35. package/esm2020/lib/voice-recorder/voice-recorder.module.mjs +34 -0
  36. package/esm2020/lib/voice-recording/voice-recording-wavebar/voice-recording-wavebar.component.mjs +4 -75
  37. package/esm2020/lib/voice-recording/voice-recording.component.mjs +4 -15
  38. package/esm2020/lib/voice-recording/voice-recording.module.mjs +21 -0
  39. package/esm2020/lib/wave-form-sampler.mjs +72 -0
  40. package/esm2020/public-api.mjs +18 -5
  41. package/fesm2015/stream-chat-angular.mjs +1055 -145
  42. package/fesm2015/stream-chat-angular.mjs.map +1 -1
  43. package/fesm2020/stream-chat-angular.mjs +1006 -140
  44. package/fesm2020/stream-chat-angular.mjs.map +1 -1
  45. package/lib/attachment.service.d.ts +7 -1
  46. package/lib/file-utils.d.ts +9 -0
  47. package/lib/format-duration.d.ts +1 -0
  48. package/lib/{icon-placeholder → icon/icon-placeholder}/icon-placeholder.component.d.ts +3 -3
  49. package/lib/icon/icon.component.d.ts +1 -1
  50. package/lib/icon/icon.module.d.ts +11 -0
  51. package/lib/{loading-indicator-placeholder → icon/loading-indicator-placeholder}/loading-indicator-placeholder.component.d.ts +1 -1
  52. package/lib/is-safari.d.ts +1 -0
  53. package/lib/message-input/message-input-config.service.d.ts +5 -0
  54. package/lib/message-input/message-input.component.d.ts +19 -5
  55. package/lib/message-input/voice-recorder.service.d.ts +19 -0
  56. package/lib/message-list/message-list.component.d.ts +0 -1
  57. package/lib/stream-chat.module.d.ts +20 -24
  58. package/lib/types.d.ts +11 -1
  59. package/lib/voice-recorder/amplitude-recorder.service.d.ts +71 -0
  60. package/lib/voice-recorder/audio-recorder.service.d.ts +46 -0
  61. package/lib/voice-recorder/media-recorder.d.ts +46 -0
  62. package/lib/voice-recorder/mp3-transcoder.d.ts +1 -0
  63. package/lib/voice-recorder/transcoder.service.d.ts +40 -0
  64. package/lib/voice-recorder/voice-recorder-wavebar/voice-recorder-wavebar.component.d.ts +21 -0
  65. package/lib/voice-recorder/voice-recorder.component.d.ts +30 -0
  66. package/lib/voice-recorder/voice-recorder.module.d.ts +12 -0
  67. package/lib/voice-recording/voice-recording-wavebar/voice-recording-wavebar.component.d.ts +0 -7
  68. package/lib/voice-recording/voice-recording.component.d.ts +0 -1
  69. package/lib/voice-recording/voice-recording.module.d.ts +11 -0
  70. package/lib/wave-form-sampler.d.ts +1 -0
  71. package/package.json +8 -1
  72. package/public-api.d.ts +17 -4
  73. package/src/assets/assets/icons/stream-chat-icons.eot +0 -0
  74. package/src/assets/assets/icons/stream-chat-icons.svg +4 -0
  75. package/src/assets/assets/icons/stream-chat-icons.ttf +0 -0
  76. package/src/assets/assets/icons/stream-chat-icons.woff +0 -0
  77. package/src/assets/assets/icons/stream-chat-icons.woff2 +0 -0
  78. package/src/assets/i18n/en.ts +6 -0
  79. package/src/assets/styles/css/index.css +1 -1
  80. package/src/assets/styles/css/index.layout.css +1 -1
  81. package/src/assets/styles/scss/AudioRecorder/AudioRecorder-layout.scss +64 -14
  82. package/src/assets/styles/scss/AudioRecorder/AudioRecorder-theme.scss +11 -1
  83. package/src/assets/styles/scss/Icon/Icon-layout.scss +6 -1
  84. package/src/assets/styles/scss/MessageInput/MessageInput-layout.scss +1 -0
  85. package/src/assets/styles/scss/MessageInput/MessageInput-theme.scss +1 -0
  86. package/src/assets/version.ts +1 -1
  87. package/esm2020/lib/icon-placeholder/icon-placeholder.component.mjs +0 -28
  88. package/esm2020/lib/is-image-file.mjs +0 -5
  89. package/lib/is-image-file.d.ts +0 -1
  90. /package/lib/{loading-indicator → icon/loading-indicator}/loading-indicator.component.d.ts +0 -0
@@ -2,7 +2,7 @@ import { Observable } from 'rxjs';
2
2
  import { Attachment } from 'stream-chat';
3
3
  import { ChannelService } from './channel.service';
4
4
  import { NotificationService } from './notification.service';
5
- import { AttachmentUpload, DefaultStreamChatGenerics } from './types';
5
+ import { AttachmentUpload, AudioRecording, DefaultStreamChatGenerics } from './types';
6
6
  import { ChatClientService } from './chat-client.service';
7
7
  import * as i0 from "@angular/core";
8
8
  /**
@@ -30,6 +30,12 @@ export declare class AttachmentService<T extends DefaultStreamChatGenerics = Def
30
30
  * Resets the attachments uploads (for example after the message with the attachments sent successfully)
31
31
  */
32
32
  resetAttachmentUploads(): void;
33
+ /**
34
+ * Upload a voice recording
35
+ * @param audioRecording
36
+ * @returns A promise with true or false. If false is returned the upload was canceled because of a client side error. The error is emitted via the `NotificationService`.
37
+ */
38
+ uploadVoiceRecording(audioRecording: AudioRecording): Promise<boolean>;
33
39
  /**
34
40
  * Uploads the selected files, and creates preview for image files. The result is propagated throught the `attachmentUploads$` stream.
35
41
  * @param fileList The files selected by the user, if you have Blobs instead of Files, you can convert them with this method: https://developer.mozilla.org/en-US/docs/Web/API/File/File
@@ -0,0 +1,9 @@
1
+ export declare const isImageFile: (file: File) => boolean;
2
+ export declare const readBlobAsArrayBuffer: (blob: Blob) => Promise<ArrayBuffer>;
3
+ export declare const createFileFromBlobs: ({ blobsArray, fileName, mimeType, }: {
4
+ blobsArray: Blob[];
5
+ fileName: string;
6
+ mimeType: string;
7
+ }) => File;
8
+ export declare const getExtensionFromMimeType: (mimeType: string) => string | null;
9
+ export declare const createUriFromBlob: (blob: Blob) => Promise<string | ArrayBuffer | undefined>;
@@ -0,0 +1 @@
1
+ export declare const formatDuration: (durationInSeconds?: number) => string;
@@ -1,7 +1,7 @@
1
1
  import { OnChanges } from '@angular/core';
2
- import { CustomTemplatesService } from '../custom-templates.service';
3
- import { Icon } from '../icon/icon.component';
4
- import { IconContext } from '../types';
2
+ import { Icon } from '../icon.component';
3
+ import { IconContext } from '../../types';
4
+ import { CustomTemplatesService } from '../../custom-templates.service';
5
5
  import * as i0 from "@angular/core";
6
6
  /**
7
7
  * The `IconPlaceholder` component displays the [default icons](./IconComponent.mdx) unless a [custom template](../services/CustomTemplatesService.mdx) is provided. This component is used by the SDK internally, you likely won't need to use it.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from "@angular/core";
2
- export declare type Icon = 'action' | 'delivered' | 'read' | 'reaction' | 'send' | 'retry' | 'close' | 'audio-file' | 'reply-in-thread' | 'arrow-left' | 'arrow-up' | 'arrow-down' | 'arrow-right' | 'chat-bubble' | 'attach' | 'unspecified-filetype' | 'download' | 'error' | 'play' | 'pause';
2
+ export declare type Icon = 'action' | 'delivered' | 'read' | 'reaction' | 'send' | 'retry' | 'close' | 'audio-file' | 'reply-in-thread' | 'arrow-left' | 'arrow-up' | 'arrow-down' | 'arrow-right' | 'chat-bubble' | 'attach' | 'unspecified-filetype' | 'download' | 'error' | 'play' | 'pause' | 'mic' | 'bin';
3
3
  /**
4
4
  * The `Icon` component can be used to display different icons (i. e. message delivered icon).
5
5
  */
@@ -0,0 +1,11 @@
1
+ import * as i0 from "@angular/core";
2
+ import * as i1 from "./icon.component";
3
+ import * as i2 from "./icon-placeholder/icon-placeholder.component";
4
+ import * as i3 from "./loading-indicator/loading-indicator.component";
5
+ import * as i4 from "./loading-indicator-placeholder/loading-indicator-placeholder.component";
6
+ import * as i5 from "@angular/common";
7
+ export declare class IconModule {
8
+ static ɵfac: i0.ɵɵFactoryDeclaration<IconModule, never>;
9
+ static ɵmod: i0.ɵɵNgModuleDeclaration<IconModule, [typeof i1.IconComponent, typeof i2.IconPlaceholderComponent, typeof i3.LoadingIndicatorComponent, typeof i4.LoadingIndicatorPlaceholderComponent], [typeof i5.CommonModule], [typeof i1.IconComponent, typeof i2.IconPlaceholderComponent, typeof i3.LoadingIndicatorComponent, typeof i4.LoadingIndicatorPlaceholderComponent]>;
10
+ static ɵinj: i0.ɵɵInjectorDeclaration<IconModule>;
11
+ }
@@ -1,4 +1,4 @@
1
- import { CustomTemplatesService } from '../custom-templates.service';
1
+ import { CustomTemplatesService } from '../../custom-templates.service';
2
2
  import * as i0 from "@angular/core";
3
3
  /**
4
4
  * The `LoadingInficatorPlaceholder` component displays the [default loading indicator](./LoadingIndicatorComponent.mdx) unless a [custom template](../services/CustomTemplatesService.mdx) is provided. This component is used by the SDK internally, you likely won't need to use it.
@@ -0,0 +1 @@
1
+ export declare const isSafari: boolean;
@@ -23,6 +23,11 @@ export declare class MessageInputConfigService {
23
23
  * In `desktop` mode the `Enter` key will trigger message sending, in `mobile` mode the `Enter` key will insert a new line to the message input.
24
24
  */
25
25
  inputMode: 'desktop' | 'mobile';
26
+ /**
27
+ * If `true` the recording will be sent as a message immediately after the recording is completed.
28
+ * If `false`, the recording will added to the attachment preview, and users can continue composing the message.
29
+ */
30
+ sendVoiceRecordingImmediately: boolean;
26
31
  constructor();
27
32
  static ɵfac: i0.ɵɵFactoryDeclaration<MessageInputConfigService, never>;
28
33
  static ɵprov: i0.ɵɵInjectableDeclaration<MessageInputConfigService>;
@@ -4,12 +4,14 @@ import { UserResponse } from 'stream-chat';
4
4
  import { AttachmentService } from '../attachment.service';
5
5
  import { ChannelService } from '../channel.service';
6
6
  import { NotificationService } from '../notification.service';
7
- import { AttachmentPreviewListContext, AttachmentUpload, CustomAttachmentUploadContext, DefaultStreamChatGenerics, EmojiPickerContext, StreamMessage } from '../types';
7
+ import { AttachmentPreviewListContext, AttachmentUpload, AudioRecording, CustomAttachmentUploadContext, DefaultStreamChatGenerics, EmojiPickerContext, StreamMessage } from '../types';
8
8
  import { MessageInputConfigService } from './message-input-config.service';
9
9
  import { TextareaInterface } from './textarea.interface';
10
10
  import { EmojiInputService } from './emoji-input.service';
11
11
  import { CustomTemplatesService } from '../custom-templates.service';
12
12
  import { MessageActionsService } from '../message-actions.service';
13
+ import { VoiceRecorderService } from './voice-recorder.service';
14
+ import { AudioRecorderService } from '../voice-recorder/audio-recorder.service';
13
15
  import * as i0 from "@angular/core";
14
16
  /**
15
17
  * The `MessageInput` component displays an input where users can type their messages and upload files, and sends the message to the active channel. The component can be used to compose new messages or update existing ones. To send messages, the chat user needs to have the necessary [channel capability](https://getstream.io/chat/docs/javascript/channel_capabilities/?language=javascript).
@@ -17,7 +19,7 @@ import * as i0 from "@angular/core";
17
19
  export declare class MessageInputComponent implements OnInit, OnChanges, OnDestroy, AfterViewInit {
18
20
  private channelService;
19
21
  private notificationService;
20
- private attachmentService;
22
+ readonly attachmentService: AttachmentService;
21
23
  private configService;
22
24
  private textareaType;
23
25
  private componentFactoryResolver;
@@ -25,6 +27,8 @@ export declare class MessageInputComponent implements OnInit, OnChanges, OnDestr
25
27
  private emojiInputService;
26
28
  private customTemplatesService;
27
29
  private messageActionsService;
30
+ readonly voiceRecorderService: VoiceRecorderService;
31
+ audioRecorder?: AudioRecorderService | undefined;
28
32
  /**
29
33
  * If file upload is enabled, the user can open a file selector from the input. Please note that the user also needs to have the necessary [channel capability](https://getstream.io/chat/docs/javascript/channel_capabilities/?language=javascript). If no value is provided, it is set from the [`MessageInputConfigService`](../services/MessageInputConfigService.mdx).
30
34
  */
@@ -71,13 +75,21 @@ export declare class MessageInputComponent implements OnInit, OnChanges, OnDestr
71
75
  * Use this input to control wether a send button is rendered or not. If you don't render a send button, you can still trigger message send using the `sendMessage$` input.
72
76
  */
73
77
  displaySendButton: boolean;
78
+ /**
79
+ * You can enable/disable voice recordings with this input
80
+ */
81
+ displayVoiceRecordingButton: boolean;
74
82
  /**
75
83
  * Emits when a message was successfuly sent or updated
76
84
  */
77
85
  readonly messageUpdate: EventEmitter<{
78
86
  message: StreamMessage;
79
87
  }>;
88
+ voiceRecorderRef: TemplateRef<{
89
+ service: VoiceRecorderService;
90
+ }> | undefined;
80
91
  class: string;
92
+ isVoiceRecording: boolean;
81
93
  isFileUploadAuthorized: boolean | undefined;
82
94
  canSendLinks: boolean | undefined;
83
95
  canSendMessages: boolean | undefined;
@@ -105,7 +117,7 @@ export declare class MessageInputComponent implements OnInit, OnChanges, OnDestr
105
117
  private readonly defaultTextareaPlaceholder;
106
118
  private readonly slowModeTextareaPlaceholder;
107
119
  private messageToEdit?;
108
- constructor(channelService: ChannelService, notificationService: NotificationService, attachmentService: AttachmentService, configService: MessageInputConfigService, textareaType: Type<TextareaInterface>, componentFactoryResolver: ComponentFactoryResolver, cdRef: ChangeDetectorRef, emojiInputService: EmojiInputService, customTemplatesService: CustomTemplatesService, messageActionsService: MessageActionsService);
120
+ constructor(channelService: ChannelService, notificationService: NotificationService, attachmentService: AttachmentService, configService: MessageInputConfigService, textareaType: Type<TextareaInterface>, componentFactoryResolver: ComponentFactoryResolver, cdRef: ChangeDetectorRef, emojiInputService: EmojiInputService, customTemplatesService: CustomTemplatesService, messageActionsService: MessageActionsService, voiceRecorderService: VoiceRecorderService, audioRecorder?: AudioRecorderService | undefined);
109
121
  ngOnInit(): void;
110
122
  ngAfterViewInit(): void;
111
123
  ngOnChanges(changes: SimpleChanges): void;
@@ -142,6 +154,8 @@ export declare class MessageInputComponent implements OnInit, OnChanges, OnDestr
142
154
  getEmojiPickerContext(): EmojiPickerContext;
143
155
  getAttachmentPreviewListContext(): AttachmentPreviewListContext;
144
156
  getAttachmentUploadContext(): CustomAttachmentUploadContext;
157
+ startVoiceRecording(): Promise<void>;
158
+ voiceRecordingReady(recording: AudioRecording): Promise<void>;
145
159
  get isUpdate(): boolean;
146
160
  private deleteUpload;
147
161
  private retryUpload;
@@ -153,6 +167,6 @@ export declare class MessageInputComponent implements OnInit, OnChanges, OnDestr
153
167
  private stopCooldown;
154
168
  private checkIfInEditMode;
155
169
  private messageToUpdateChanged;
156
- static ɵfac: i0.ɵɵFactoryDeclaration<MessageInputComponent, never>;
157
- static ɵcmp: i0.ɵɵComponentDeclaration<MessageInputComponent, "stream-message-input", never, { "isFileUploadEnabled": "isFileUploadEnabled"; "areMentionsEnabled": "areMentionsEnabled"; "mentionScope": "mentionScope"; "mode": "mode"; "isMultipleFileUploadEnabled": "isMultipleFileUploadEnabled"; "message": "message"; "sendMessage$": "sendMessage$"; "inputMode": "inputMode"; "autoFocus": "autoFocus"; "watchForMessageToEdit": "watchForMessageToEdit"; "displaySendButton": "displaySendButton"; }, { "messageUpdate": "messageUpdate"; }, never, never, false, never>;
170
+ static ɵfac: i0.ɵɵFactoryDeclaration<MessageInputComponent, [null, null, null, null, null, null, null, null, null, null, null, { optional: true; }]>;
171
+ static ɵcmp: i0.ɵɵComponentDeclaration<MessageInputComponent, "stream-message-input", never, { "isFileUploadEnabled": "isFileUploadEnabled"; "areMentionsEnabled": "areMentionsEnabled"; "mentionScope": "mentionScope"; "mode": "mode"; "isMultipleFileUploadEnabled": "isMultipleFileUploadEnabled"; "message": "message"; "sendMessage$": "sendMessage$"; "inputMode": "inputMode"; "autoFocus": "autoFocus"; "watchForMessageToEdit": "watchForMessageToEdit"; "displaySendButton": "displaySendButton"; "displayVoiceRecordingButton": "displayVoiceRecordingButton"; }, { "messageUpdate": "messageUpdate"; }, ["voiceRecorderRef"], ["[message-input-start]", "[message-input-end]"], false, never>;
158
172
  }
@@ -0,0 +1,19 @@
1
+ import { BehaviorSubject } from 'rxjs';
2
+ import { AudioRecording } from '../types';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * The `VoiceRecorderService` provides a commincation outlet between the message input and voice recorder components.
6
+ */
7
+ export declare class VoiceRecorderService {
8
+ /**
9
+ * Use this property to get/set if the recording component should be visible
10
+ */
11
+ isRecorderVisible$: BehaviorSubject<boolean>;
12
+ /**
13
+ * The audio recording that was created
14
+ */
15
+ recording$: BehaviorSubject<AudioRecording | undefined>;
16
+ constructor();
17
+ static ɵfac: i0.ɵɵFactoryDeclaration<VoiceRecorderService, never>;
18
+ static ɵprov: i0.ɵɵInjectableDeclaration<VoiceRecorderService>;
19
+ }
@@ -97,7 +97,6 @@ export declare class MessageListComponent implements AfterViewChecked, OnChanges
97
97
  private isViewInited;
98
98
  private checkIfUnreadNotificationIsVisibleTimeout?;
99
99
  private jumpToLatestButtonVisibilityTimeout?;
100
- private isSafari;
101
100
  private forceRepaintSubject;
102
101
  private messageIdToAnchorTo?;
103
102
  private anchorMessageTopOffset?;
@@ -6,31 +6,27 @@ import * as i4 from "./channel-preview/channel-preview.component";
6
6
  import * as i5 from "./message/message.component";
7
7
  import * as i6 from "./message-input/message-input.component";
8
8
  import * as i7 from "./message-list/message-list.component";
9
- import * as i8 from "./loading-indicator/loading-indicator.component";
10
- import * as i9 from "./icon/icon.component";
11
- import * as i10 from "./message-actions-box/message-actions-box.component";
12
- import * as i11 from "./attachment-list/attachment-list.component";
13
- import * as i12 from "./message-reactions/message-reactions.component";
14
- import * as i13 from "./notification/notification.component";
15
- import * as i14 from "./notification-list/notification-list.component";
16
- import * as i15 from "./attachment-preview-list/attachment-preview-list.component";
17
- import * as i16 from "./modal/modal.component";
18
- import * as i17 from "./message-input/textarea.directive";
19
- import * as i18 from "./thread/thread.component";
20
- import * as i19 from "./icon-placeholder/icon-placeholder.component";
21
- import * as i20 from "./loading-indicator-placeholder/loading-indicator-placeholder.component";
22
- import * as i21 from "./message-bounce-prompt/message-bounce-prompt.component";
23
- import * as i22 from "./voice-recording/voice-recording.component";
24
- import * as i23 from "./voice-recording/voice-recording-wavebar/voice-recording-wavebar.component";
25
- import * as i24 from "./message-reactions-selector/message-reactions-selector.component";
26
- import * as i25 from "./user-list/user-list.component";
27
- import * as i26 from "./paginated-list/paginated-list.component";
28
- import * as i27 from "@angular/common";
29
- import * as i28 from "ngx-float-ui";
30
- import * as i29 from "./stream-avatar.module";
31
- import * as i30 from "@ngx-translate/core";
9
+ import * as i8 from "./message-actions-box/message-actions-box.component";
10
+ import * as i9 from "./attachment-list/attachment-list.component";
11
+ import * as i10 from "./message-reactions/message-reactions.component";
12
+ import * as i11 from "./notification/notification.component";
13
+ import * as i12 from "./notification-list/notification-list.component";
14
+ import * as i13 from "./attachment-preview-list/attachment-preview-list.component";
15
+ import * as i14 from "./modal/modal.component";
16
+ import * as i15 from "./message-input/textarea.directive";
17
+ import * as i16 from "./thread/thread.component";
18
+ import * as i17 from "./message-bounce-prompt/message-bounce-prompt.component";
19
+ import * as i18 from "./message-reactions-selector/message-reactions-selector.component";
20
+ import * as i19 from "./user-list/user-list.component";
21
+ import * as i20 from "./paginated-list/paginated-list.component";
22
+ import * as i21 from "@angular/common";
23
+ import * as i22 from "ngx-float-ui";
24
+ import * as i23 from "./stream-avatar.module";
25
+ import * as i24 from "@ngx-translate/core";
26
+ import * as i25 from "./voice-recording/voice-recording.module";
27
+ import * as i26 from "./icon/icon.module";
32
28
  export declare class StreamChatModule {
33
29
  static ɵfac: i0.ɵɵFactoryDeclaration<StreamChatModule, never>;
34
- static ɵmod: i0.ɵɵNgModuleDeclaration<StreamChatModule, [typeof i1.ChannelComponent, typeof i2.ChannelHeaderComponent, typeof i3.ChannelListComponent, typeof i4.ChannelPreviewComponent, typeof i5.MessageComponent, typeof i6.MessageInputComponent, typeof i7.MessageListComponent, typeof i8.LoadingIndicatorComponent, typeof i9.IconComponent, typeof i10.MessageActionsBoxComponent, typeof i11.AttachmentListComponent, typeof i12.MessageReactionsComponent, typeof i13.NotificationComponent, typeof i14.NotificationListComponent, typeof i15.AttachmentPreviewListComponent, typeof i16.ModalComponent, typeof i17.TextareaDirective, typeof i18.ThreadComponent, typeof i19.IconPlaceholderComponent, typeof i20.LoadingIndicatorPlaceholderComponent, typeof i21.MessageBouncePromptComponent, typeof i22.VoiceRecordingComponent, typeof i23.VoiceRecordingWavebarComponent, typeof i24.MessageReactionsSelectorComponent, typeof i25.UserListComponent, typeof i26.PaginatedListComponent], [typeof i27.CommonModule, typeof i28.NgxFloatUiModule, typeof i29.StreamAvatarModule, typeof i30.TranslateModule], [typeof i1.ChannelComponent, typeof i2.ChannelHeaderComponent, typeof i3.ChannelListComponent, typeof i4.ChannelPreviewComponent, typeof i5.MessageComponent, typeof i6.MessageInputComponent, typeof i7.MessageListComponent, typeof i8.LoadingIndicatorComponent, typeof i9.IconComponent, typeof i10.MessageActionsBoxComponent, typeof i11.AttachmentListComponent, typeof i12.MessageReactionsComponent, typeof i13.NotificationComponent, typeof i14.NotificationListComponent, typeof i15.AttachmentPreviewListComponent, typeof i16.ModalComponent, typeof i29.StreamAvatarModule, typeof i18.ThreadComponent, typeof i19.IconPlaceholderComponent, typeof i20.LoadingIndicatorPlaceholderComponent, typeof i21.MessageBouncePromptComponent, typeof i22.VoiceRecordingComponent, typeof i23.VoiceRecordingWavebarComponent, typeof i24.MessageReactionsSelectorComponent, typeof i25.UserListComponent, typeof i26.PaginatedListComponent]>;
30
+ static ɵmod: i0.ɵɵNgModuleDeclaration<StreamChatModule, [typeof i1.ChannelComponent, typeof i2.ChannelHeaderComponent, typeof i3.ChannelListComponent, typeof i4.ChannelPreviewComponent, typeof i5.MessageComponent, typeof i6.MessageInputComponent, typeof i7.MessageListComponent, typeof i8.MessageActionsBoxComponent, typeof i9.AttachmentListComponent, typeof i10.MessageReactionsComponent, typeof i11.NotificationComponent, typeof i12.NotificationListComponent, typeof i13.AttachmentPreviewListComponent, typeof i14.ModalComponent, typeof i15.TextareaDirective, typeof i16.ThreadComponent, typeof i17.MessageBouncePromptComponent, typeof i18.MessageReactionsSelectorComponent, typeof i19.UserListComponent, typeof i20.PaginatedListComponent], [typeof i21.CommonModule, typeof i22.NgxFloatUiModule, typeof i23.StreamAvatarModule, typeof i24.TranslateModule, typeof i25.VoiceRecordingModule, typeof i26.IconModule], [typeof i1.ChannelComponent, typeof i2.ChannelHeaderComponent, typeof i3.ChannelListComponent, typeof i4.ChannelPreviewComponent, typeof i5.MessageComponent, typeof i6.MessageInputComponent, typeof i7.MessageListComponent, typeof i8.MessageActionsBoxComponent, typeof i9.AttachmentListComponent, typeof i10.MessageReactionsComponent, typeof i11.NotificationComponent, typeof i12.NotificationListComponent, typeof i13.AttachmentPreviewListComponent, typeof i14.ModalComponent, typeof i23.StreamAvatarModule, typeof i16.ThreadComponent, typeof i17.MessageBouncePromptComponent, typeof i25.VoiceRecordingModule, typeof i18.MessageReactionsSelectorComponent, typeof i19.UserListComponent, typeof i20.PaginatedListComponent, typeof i26.IconModule]>;
35
31
  static ɵinj: i0.ɵɵInjectorDeclaration<StreamChatModule>;
36
32
  }
package/lib/types.d.ts CHANGED
@@ -59,9 +59,10 @@ export declare type AttachmentUpload<T extends DefaultStreamChatGenerics = Defau
59
59
  param: string;
60
60
  }[];
61
61
  url?: string;
62
- type: 'image' | 'file' | 'video';
62
+ type: 'image' | 'file' | 'video' | 'voiceRecording';
63
63
  previewUri?: string | ArrayBuffer;
64
64
  thumb_url?: string;
65
+ extraData?: Partial<Attachment<T>>;
65
66
  fromAttachment?: Attachment<T>;
66
67
  };
67
68
  export declare type MentionAutcompleteListItemContext = {
@@ -319,4 +320,13 @@ export declare type VirtualizedListQueryState = {
319
320
  };
320
321
  export declare type VirtualizedListQueryDirection = 'top' | 'bottom';
321
322
  export declare type VirtualizedListVerticalItemPosition = 'top' | 'bottom' | 'middle';
323
+ export declare type AudioRecording = MediaRecording & {
324
+ waveform_data: number[];
325
+ };
326
+ export declare type MediaRecording = {
327
+ recording: File;
328
+ duration: number;
329
+ mime_type: string;
330
+ asset_url: string | ArrayBuffer | undefined;
331
+ };
322
332
  export {};
@@ -0,0 +1,71 @@
1
+ import { Observable } from 'rxjs';
2
+ import { ChatClientService } from '../chat-client.service';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * fftSize
6
+ * An unsigned integer, representing the window size of the FFT, given in number of samples.
7
+ * A higher value will result in more details in the frequency domain but fewer details
8
+ * in the amplitude domain.
9
+ *
10
+ * Must be a power of 2 between 2^5 and 2^15, so one of: 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, and 32768.
11
+ * Defaults to 32.
12
+ *
13
+ * maxDecibels
14
+ * A double, representing the maximum decibel value for scaling the FFT analysis data,
15
+ * where 0 dB is the loudest possible sound, -10 dB is a 10th of that, etc.
16
+ * The default value is -30 dB.
17
+ *
18
+ * minDecibels
19
+ * A double, representing the minimum decibel value for scaling the FFT analysis data,
20
+ * where 0 dB is the loudest possible sound, -10 dB is a 10th of that, etc.
21
+ * The default value is -100 dB.
22
+ */
23
+ export declare type AmplitudeAnalyserConfig = Pick<AnalyserNode, 'fftSize' | 'maxDecibels' | 'minDecibels'>;
24
+ export declare type AmplitudeRecorderConfig = {
25
+ analyserConfig: AmplitudeAnalyserConfig;
26
+ sampleCount: number;
27
+ samplingFrequencyMs: number;
28
+ };
29
+ export declare const DEFAULT_AMPLITUDE_RECORDER_CONFIG: AmplitudeRecorderConfig;
30
+ /**
31
+ * The `AmplitudeRecorderService` is a utility service used to create amplitude values for voice recordings, making it possible to display a wave bar
32
+ */
33
+ export declare class AmplitudeRecorderService {
34
+ private chatService;
35
+ config: AmplitudeRecorderConfig;
36
+ amplitudes$: Observable<number[]>;
37
+ error$: Observable<Error | undefined>;
38
+ private amplitudesSubject;
39
+ private errorSubject;
40
+ private audioContext;
41
+ private analyserNode;
42
+ private microphone;
43
+ private stream;
44
+ private amplitudeSamplingInterval;
45
+ constructor(chatService: ChatClientService);
46
+ /**
47
+ * The recorded amplitudes
48
+ */
49
+ get amplitudes(): number[];
50
+ /**
51
+ * Start amplitude recording for the given media stream
52
+ * @param stream
53
+ */
54
+ start: (stream: MediaStream) => void;
55
+ /**
56
+ * Temporarily pause amplitude recording, recording can be resumed with `resume`
57
+ */
58
+ pause(): void;
59
+ /**
60
+ * Resume amplited recording after it was pasued
61
+ */
62
+ resume(): void;
63
+ /**
64
+ * Stop the amplitude recording and frees up used resources
65
+ */
66
+ stop(): void;
67
+ private init;
68
+ private logError;
69
+ static ɵfac: i0.ɵɵFactoryDeclaration<AmplitudeRecorderService, never>;
70
+ static ɵprov: i0.ɵɵInjectableDeclaration<AmplitudeRecorderService>;
71
+ }
@@ -0,0 +1,46 @@
1
+ import { AmplitudeRecorderService } from './amplitude-recorder.service';
2
+ import { MediaRecorderConfig, MultimediaRecorder } from './media-recorder';
3
+ import { NotificationService } from '../notification.service';
4
+ import { ChatClientService } from '../chat-client.service';
5
+ import { TranscoderService } from './transcoder.service';
6
+ import { AudioRecording, MediaRecording } from '../types';
7
+ import * as i0 from "@angular/core";
8
+ /**
9
+ * The `AudioRecorderService` can record an audio file, the SDK uses this to record a voice message
10
+ */
11
+ export declare class AudioRecorderService extends MultimediaRecorder<Omit<AudioRecording, keyof MediaRecording>> {
12
+ private amplitudeRecorder;
13
+ /**
14
+ * Due to browser restrictions the following config is used:
15
+ * - In Safari we record in audio/mp4
16
+ * - For all other browsers we use audio/webm (which is then transcoded to wav)
17
+ */
18
+ config: MediaRecorderConfig;
19
+ constructor(notificationService: NotificationService, chatService: ChatClientService, transcoder: TranscoderService, amplitudeRecorder: AmplitudeRecorderService);
20
+ protected enrichWithExtraData(): {
21
+ waveform_data: number[];
22
+ };
23
+ /**
24
+ * Start audio recording
25
+ */
26
+ start(): Promise<void>;
27
+ /**
28
+ * Pause audio recording, it can be restarted using `resume`
29
+ */
30
+ pause(): void;
31
+ /**
32
+ * Resume a previously paused recording
33
+ */
34
+ resume(): void;
35
+ /**
36
+ * Stop the recording and free up used resources
37
+ * @param options
38
+ * @param options.cancel if this is `true` no recording will be created, but resources will be freed
39
+ * @returns the recording
40
+ */
41
+ stop(options?: {
42
+ cancel: boolean;
43
+ }): Promise<MediaRecording & Omit<AudioRecording, keyof MediaRecording>>;
44
+ static ɵfac: i0.ɵɵFactoryDeclaration<AudioRecorderService, never>;
45
+ static ɵprov: i0.ɵɵInjectableDeclaration<AudioRecorderService>;
46
+ }
@@ -0,0 +1,46 @@
1
+ import { BehaviorSubject, Observable } from 'rxjs';
2
+ import { NotificationService } from '../notification.service';
3
+ import { ChatClientService } from '../chat-client.service';
4
+ import { TranscoderService } from './transcoder.service';
5
+ import { MediaRecording } from '../types';
6
+ export declare type MediaRecorderConfig = Omit<MediaRecorderOptions, 'mimeType'> & Required<Pick<MediaRecorderOptions, 'mimeType'>>;
7
+ export declare enum MediaRecordingState {
8
+ PAUSED = "paused",
9
+ RECORDING = "recording",
10
+ STOPPED = "stopped",
11
+ ERROR = "error"
12
+ }
13
+ export declare type MediaRecordingTitleOptions = {
14
+ mimeType: string;
15
+ };
16
+ export declare abstract class MultimediaRecorder<T = null> {
17
+ protected notificationService: NotificationService;
18
+ protected chatService: ChatClientService;
19
+ private transcoder;
20
+ abstract config: MediaRecorderConfig;
21
+ customGenerateRecordingTitle: ((options: MediaRecordingTitleOptions) => string) | undefined;
22
+ recordingState$: Observable<MediaRecordingState>;
23
+ recording$: Observable<(MediaRecording & T) | undefined>;
24
+ protected recordingSubject: BehaviorSubject<(MediaRecording & T) | undefined>;
25
+ protected mediaRecorder: MediaRecorder | undefined;
26
+ protected startTime: number | undefined;
27
+ protected recordedChunkDurations: number[];
28
+ private recordingStateSubject;
29
+ constructor(notificationService: NotificationService, chatService: ChatClientService, transcoder: TranscoderService);
30
+ get durationMs(): number;
31
+ get mediaType(): string;
32
+ get isRecording(): boolean;
33
+ generateRecordingTitle: (mimeType: string) => string;
34
+ makeRecording(blob: Blob): Promise<File | undefined>;
35
+ handleErrorEvent: (e: Event) => void;
36
+ handleDataavailableEvent: (e: BlobEvent) => void;
37
+ get recordingState(): MediaRecordingState;
38
+ start(): Promise<void>;
39
+ pause(): void;
40
+ resume(): void;
41
+ stop(options?: {
42
+ cancel: boolean;
43
+ }): Promise<MediaRecording & T>;
44
+ protected abstract enrichWithExtraData(): T;
45
+ protected logError(error: Error): void;
46
+ }
@@ -0,0 +1 @@
1
+ export declare function encodeWebmToMp3(blob: Blob, lameJs: any): Promise<Blob>;
@@ -0,0 +1,40 @@
1
+ import * as i0 from "@angular/core";
2
+ export declare type TranscoderConfig = {
3
+ sampleRate: number;
4
+ };
5
+ export declare type TranscodeParams = TranscoderConfig & {
6
+ blob: Blob;
7
+ };
8
+ declare type WriteWaveHeaderParams = {
9
+ arrayBuffer: ArrayBuffer;
10
+ channelCount: number;
11
+ sampleRate: number;
12
+ };
13
+ declare type WriteAudioDataParams = {
14
+ arrayBuffer: ArrayBuffer;
15
+ dataByChannel: Float32Array[];
16
+ };
17
+ /**
18
+ * The `TranscoderService` is used to transcibe audio recording to a format that's supported by all major browsers. The SDK uses this to create voice messages.
19
+ *
20
+ * If you want to use your own transcoder you can provide a `customTranscoder`.
21
+ */
22
+ export declare class TranscoderService {
23
+ config: TranscoderConfig;
24
+ customTranscoder?: (blob: Blob) => Blob | Promise<Blob>;
25
+ constructor();
26
+ /**
27
+ * The default transcoder will leave audio/mp4 files as is, and transcode webm files to wav. If you want to customize this, you can provide your own transcoder using the `customTranscoder` field
28
+ * @param blob
29
+ * @returns the transcoded file
30
+ */
31
+ transcode(blob: Blob): Promise<Blob>;
32
+ protected renderAudio(audioBuffer: AudioBuffer, sampleRate: number): Promise<AudioBuffer>;
33
+ protected toAudioBuffer(blob: Blob): Promise<AudioBuffer>;
34
+ protected writeWavAudioData({ arrayBuffer, dataByChannel, }: WriteAudioDataParams): void;
35
+ protected writeWavHeader({ arrayBuffer, channelCount, sampleRate, }: WriteWaveHeaderParams): void;
36
+ protected splitDataByChannel: (audioBuffer: AudioBuffer) => Float32Array[];
37
+ static ɵfac: i0.ɵɵFactoryDeclaration<TranscoderService, never>;
38
+ static ɵprov: i0.ɵɵInjectableDeclaration<TranscoderService>;
39
+ }
40
+ export {};
@@ -0,0 +1,21 @@
1
+ import { OnDestroy } from '@angular/core';
2
+ import { AmplitudeRecorderService } from '../amplitude-recorder.service';
3
+ import { Observable } from 'rxjs';
4
+ import { AudioRecorderService } from '../audio-recorder.service';
5
+ import * as i0 from "@angular/core";
6
+ /**
7
+ * The `VoiceRecorderWavebarComponent` displays the amplitudes of the recording while the recoding is in progress
8
+ */
9
+ export declare class VoiceRecorderWavebarComponent implements OnDestroy {
10
+ private amplitudeRecorder;
11
+ private audioRecorder;
12
+ amplitudes$: Observable<number[]>;
13
+ formattedDuration: string;
14
+ durationComputeInterval: ReturnType<typeof setInterval>;
15
+ isLongerThanOneHour: boolean;
16
+ constructor(amplitudeRecorder: AmplitudeRecorderService, audioRecorder: AudioRecorderService);
17
+ trackByIndex(i: number): number;
18
+ ngOnDestroy(): void;
19
+ static ɵfac: i0.ɵɵFactoryDeclaration<VoiceRecorderWavebarComponent, never>;
20
+ static ɵcmp: i0.ɵɵComponentDeclaration<VoiceRecorderWavebarComponent, "stream-voice-recorder-wavebar", never, {}, {}, never, never, false, never>;
21
+ }
@@ -0,0 +1,30 @@
1
+ import { OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
2
+ import { AudioRecorderService } from './audio-recorder.service';
3
+ import { MediaRecordingState } from './media-recorder';
4
+ import { AudioRecording } from '../types';
5
+ import { VoiceRecorderService } from '../message-input/voice-recorder.service';
6
+ import * as i0 from "@angular/core";
7
+ /**
8
+ * The `VoiceRecorderComponent` makes it possible to record audio, and then upload it as a voice recording attachment
9
+ */
10
+ export declare class VoiceRecorderComponent implements OnInit, OnDestroy, OnChanges {
11
+ readonly recorder: AudioRecorderService;
12
+ voiceRecorderService?: VoiceRecorderService;
13
+ recordState: MediaRecordingState;
14
+ isLoading: boolean;
15
+ recording?: AudioRecording;
16
+ readonly MediaRecordingState: typeof MediaRecordingState;
17
+ private subscriptions;
18
+ private isVisibleSubscription?;
19
+ constructor(recorder: AudioRecorderService);
20
+ ngOnInit(): void;
21
+ ngOnChanges(changes: SimpleChanges): void;
22
+ ngOnDestroy(): void;
23
+ cancel(): void;
24
+ stop(): Promise<void>;
25
+ pause(): void;
26
+ resume(): void;
27
+ uploadRecording(): void;
28
+ static ɵfac: i0.ɵɵFactoryDeclaration<VoiceRecorderComponent, never>;
29
+ static ɵcmp: i0.ɵɵComponentDeclaration<VoiceRecorderComponent, "stream-voice-recorder", never, { "voiceRecorderService": "voiceRecorderService"; }, {}, never, never, false, never>;
30
+ }
@@ -0,0 +1,12 @@
1
+ import * as i0 from "@angular/core";
2
+ import * as i1 from "./voice-recorder.component";
3
+ import * as i2 from "./voice-recorder-wavebar/voice-recorder-wavebar.component";
4
+ import * as i3 from "@angular/common";
5
+ import * as i4 from "../voice-recording/voice-recording.module";
6
+ import * as i5 from "../icon/icon.module";
7
+ import * as i6 from "@ngx-translate/core";
8
+ export declare class VoiceRecorderModule {
9
+ static ɵfac: i0.ɵɵFactoryDeclaration<VoiceRecorderModule, never>;
10
+ static ɵmod: i0.ɵɵNgModuleDeclaration<VoiceRecorderModule, [typeof i1.VoiceRecorderComponent, typeof i2.VoiceRecorderWavebarComponent], [typeof i3.CommonModule, typeof i4.VoiceRecordingModule, typeof i5.IconModule, typeof i6.TranslateModule], [typeof i1.VoiceRecorderComponent, typeof i2.VoiceRecorderWavebarComponent]>;
11
+ static ɵinj: i0.ɵɵInjectorDeclaration<VoiceRecorderModule>;
12
+ }
@@ -31,13 +31,6 @@ export declare class VoiceRecordingWavebarComponent implements OnInit, OnChanges
31
31
  seek(event: MouseEvent): void;
32
32
  trackByIndex(index: number): number;
33
33
  private containerSizeChanged;
34
- private downsample;
35
- private upsample;
36
- private getNextBucketMean;
37
- private mean;
38
- private triangleAreaHeron;
39
- private triangleBase;
40
- private divMod;
41
34
  static ɵfac: i0.ɵɵFactoryDeclaration<VoiceRecordingWavebarComponent, never>;
42
35
  static ɵcmp: i0.ɵɵComponentDeclaration<VoiceRecordingWavebarComponent, "stream-voice-recording-wavebar", never, { "audioElement": "audioElement"; "waveFormData": "waveFormData"; "duration": "duration"; }, {}, never, never, false, never>;
43
36
  }
@@ -25,7 +25,6 @@ export declare class VoiceRecordingComponent implements OnChanges, AfterViewInit
25
25
  setPlaybackRate(): void;
26
26
  private getFormattedDuration;
27
27
  private getFileSize;
28
- private divMod;
29
28
  static ɵfac: i0.ɵɵFactoryDeclaration<VoiceRecordingComponent, never>;
30
29
  static ɵcmp: i0.ɵɵComponentDeclaration<VoiceRecordingComponent, "stream-voice-recording", never, { "attachment": "attachment"; }, {}, never, never, false, never>;
31
30
  }
@@ -0,0 +1,11 @@
1
+ import * as i0 from "@angular/core";
2
+ import * as i1 from "./voice-recording.component";
3
+ import * as i2 from "./voice-recording-wavebar/voice-recording-wavebar.component";
4
+ import * as i3 from "@angular/common";
5
+ import * as i4 from "../icon/icon.module";
6
+ import * as i5 from "@ngx-translate/core";
7
+ export declare class VoiceRecordingModule {
8
+ static ɵfac: i0.ɵɵFactoryDeclaration<VoiceRecordingModule, never>;
9
+ static ɵmod: i0.ɵɵNgModuleDeclaration<VoiceRecordingModule, [typeof i1.VoiceRecordingComponent, typeof i2.VoiceRecordingWavebarComponent], [typeof i3.CommonModule, typeof i4.IconModule, typeof i5.TranslateModule], [typeof i1.VoiceRecordingComponent, typeof i2.VoiceRecordingWavebarComponent]>;
10
+ static ɵinj: i0.ɵɵInjectorDeclaration<VoiceRecordingModule>;
11
+ }
@@ -0,0 +1 @@
1
+ export declare const resampleWaveForm: (waveFormData: number[], sampleSize: number) => number[];