@chat21/chat21-web-widget 5.0.83-rc.4 → 5.0.83

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 (24) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/deploy_amazon_beta.sh +5 -8
  3. package/deploy_amazon_prod.sh +3 -10
  4. package/package.json +1 -1
  5. package/src/app/app.module.ts +2 -5
  6. package/src/app/component/conversation-detail/conversation/conversation.component.ts +1 -0
  7. package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.html +3 -14
  8. package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.scss +10 -26
  9. package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.ts +49 -131
  10. package/src/app/component/message/audio/audio.component.html +20 -0
  11. package/src/app/component/message/audio/audio.component.scss +122 -0
  12. package/src/app/component/message/{audio-track/audio-track.component.spec.ts → audio/audio.component.spec.ts} +6 -6
  13. package/src/app/component/message/audio/audio.component.ts +122 -0
  14. package/src/app/component/message/bubble-message/bubble-message.component.html +5 -30
  15. package/src/app/component/message/bubble-message/bubble-message.component.scss +0 -7
  16. package/src/app/component/message/bubble-message/bubble-message.component.ts +0 -1
  17. package/src/app/utils/globals.ts +1 -1
  18. package/src/app/component/conversation-detail/conversation-audio-recorder/conversation-audio-recorder.component.html +0 -29
  19. package/src/app/component/conversation-detail/conversation-audio-recorder/conversation-audio-recorder.component.scss +0 -103
  20. package/src/app/component/conversation-detail/conversation-audio-recorder/conversation-audio-recorder.component.spec.ts +0 -23
  21. package/src/app/component/conversation-detail/conversation-audio-recorder/conversation-audio-recorder.component.ts +0 -96
  22. package/src/app/component/message/audio-track/audio-track.component.html +0 -32
  23. package/src/app/component/message/audio-track/audio-track.component.scss +0 -107
  24. package/src/app/component/message/audio-track/audio-track.component.ts +0 -147
@@ -1,107 +0,0 @@
1
-
2
- :host {
3
- --backgroundColor: #{var(--blue)};
4
- --textColor: #{var(--bck-msg-sent)};
5
- --hoverBackgroundColor: #{var(--bck-msg-sent)};
6
- --hoverTextColor: #{var(--blue)};
7
- --max-width: #{var(--button-in-msg-max-width)};
8
- }
9
-
10
- .audio-container{
11
- position: relative;
12
- display: inline-flex;
13
- width: 100%;
14
- padding: 0px 12px;
15
- margin: 6px 0px;
16
- }
17
-
18
- audio {
19
- width: 272px;
20
- height: 30px;
21
- margin: 0;
22
- padding: 10px;
23
- }
24
-
25
- .audio-recorder {
26
- text-align: center;
27
- margin: 0px;
28
- display: inline-flex;
29
- align-items: center;
30
- justify-content: center;
31
- height: 100%;
32
- width: 100%;
33
- float: left;
34
- }
35
-
36
- button {
37
- margin: 0px;
38
- padding: 0px;
39
- font-size: 16px;
40
- border: none;
41
- background-color: transparent;
42
- color: var(--icon-fill-color);
43
- fill: var(--icon-fill-color);
44
- }
45
-
46
- .waveformCanvas {
47
- width: 100%;
48
- height: 28px;
49
- z-index: 1;
50
- padding: 0px;
51
- margin: 0%;
52
- }
53
-
54
- .audio-track {
55
- // width: 247px;//272px;
56
- // height: 30px;
57
- position: relative;
58
- display: flex;
59
- align-items: center;
60
- // margin: 0 13px;
61
- margin: 0px;
62
- .play-pause {
63
- font-size: 20px;
64
- width: 30px;
65
- background-color: transparent;
66
- border-radius: 50%;
67
- height: 30px;
68
- margin: 0px;
69
- transition: background-color 0.5s ease;
70
-
71
- }
72
- .play-pause:hover {
73
- // background-color: #ddd;
74
- // background-color: rgb(82, 160, 252);
75
- background-color: #fff;
76
- svg{
77
- //fill:#fff;
78
- fill: rgb(82, 160, 252);
79
- }
80
- }
81
- .duration {
82
- padding: 0 3px;
83
- }
84
- }
85
-
86
- .audio-player-custom {
87
- // width: 200px;
88
- // height: 32px;
89
- // margin-left: 75px;
90
- // position: absolute;
91
- // overflow: hidden;
92
- // z-index: 1;
93
- // display: flex;
94
- // align-items: center;
95
-
96
- // width: calc(100% - 75px);
97
- // height: 32px;
98
- // margin-left: 65px;
99
- // position: absolute;
100
- overflow: hidden;
101
- z-index: 1;
102
- display: flex;
103
- align-items: center;
104
- width: 100%;
105
- }
106
-
107
-
@@ -1,147 +0,0 @@
1
- import { Component, ElementRef, AfterViewInit, Input, ViewChild } from '@angular/core';
2
- import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
3
- import { convertColorToRGBA } from 'src/chat21-core/utils/utils';
4
-
5
- @Component({
6
- selector: 'chat-audio-track',
7
- templateUrl: './audio-track.component.html',
8
- styleUrls: ['./audio-track.component.scss']
9
- })
10
- export class AudioTrackComponent implements AfterViewInit {
11
-
12
- @ViewChild('audioElement', { static: true }) audioElement!: ElementRef<HTMLAudioElement>;
13
- @ViewChild('canvasElement', { static: true }) waveformCanvas!: ElementRef<HTMLCanvasElement>;
14
-
15
- @Input() audioBlob: Blob | null = null;
16
- @Input() metadata: any | null = null;
17
- @Input() color: string;
18
- @Input() fontSize: string;
19
- @Input() stylesMap: Map<string, string>;
20
-
21
- audioUrl: SafeUrl | null = null;
22
- rawAudioUrl: string | null = null;
23
- audioContext!: AudioContext;
24
- audioBuffer!: AudioBuffer;
25
- audioDuration: number | null = null;
26
- currentTime: number = 0;
27
- isPlaying: boolean = false;
28
-
29
- constructor(private sanitizer: DomSanitizer) {}
30
-
31
- ngAfterViewInit() {
32
- console.log('stylesssss', this.stylesMap)
33
- if (this.audioBlob) {
34
- this.rawAudioUrl = URL.createObjectURL(this.audioBlob);
35
- this.audioUrl = this.sanitizer.bypassSecurityTrustUrl(this.rawAudioUrl);
36
- this.setupAudioContext();
37
- } else {
38
- this.rawAudioUrl = this.metadata.src;
39
- this.audioUrl = this.sanitizer.bypassSecurityTrustUrl(this.rawAudioUrl);
40
- this.setupAudioContext();
41
- }
42
- }
43
-
44
- async setupAudioContext() {
45
- this.audioContext = new AudioContext();
46
- if (this.rawAudioUrl) {
47
- const response = await fetch(this.rawAudioUrl);
48
- const audioData = await response.arrayBuffer();
49
- this.audioBuffer = await this.audioContext.decodeAudioData(audioData);
50
- this.getAudioDuration();
51
- this.drawWaveform(this.audioBuffer);
52
- }
53
- }
54
-
55
- drawWaveform(audioBuffer: AudioBuffer) {
56
- const canvas = this.waveformCanvas.nativeElement;
57
- const canvasCtx = canvas.getContext('2d');
58
- if (!canvasCtx) return;
59
- const width = canvas.width;
60
- const height = canvas.height;
61
- const rawData = audioBuffer.getChannelData(0);
62
-
63
- const samples = 60;
64
- const blockSize = Math.floor(rawData.length / samples);
65
- const waveform = new Float32Array(samples);
66
-
67
- for (let i = 0; i < samples; i++) {
68
- let sum = 0;
69
- for (let j = 0; j < blockSize; j++) {
70
- sum += Math.abs(rawData[i * blockSize + j]);
71
- }
72
- waveform[i] = sum / blockSize;
73
- }
74
-
75
- canvasCtx.clearRect(0, 0, width, height);
76
- const padding = 1;
77
- const barWidth = (width / samples) - padding * 2;
78
- const audio = this.audioElement.nativeElement;
79
- const playedPercent = audio.currentTime / this.audioDuration;
80
- // console.log('playedPercent: ', audio.currentTime, this.audioDuration);
81
-
82
- for (let i = 0; i < samples; i++) {
83
- var barHeight = waveform[i] * height * 4;
84
- if (barHeight < 4) barHeight = 4;
85
- const x = i * (barWidth + padding * 2) + padding;
86
-
87
- if (i / samples < playedPercent) {
88
- canvasCtx.fillStyle = this.color;
89
- } else {
90
- canvasCtx.fillStyle = convertColorToRGBA(this.color, 50);;
91
- }
92
- canvasCtx.fillRect(x, height / 2 - barHeight, barWidth, barHeight);
93
- canvasCtx.fillRect(x, height / 2, barWidth, barHeight);
94
- }
95
- }
96
-
97
- playPauseAudio() {
98
- const audio = this.audioElement.nativeElement;
99
- if (audio.paused) {
100
- this.isPlaying = true;
101
- this.updateWaveform();
102
- audio.play();
103
- this.audioContext.resume();
104
- } else {
105
- audio.pause();
106
- this.isPlaying = false;
107
- }
108
- audio.ontimeupdate = () => {
109
- this.currentTime = audio.currentTime;
110
- this.updateWaveform();
111
- };
112
- audio.onended = () => {
113
- this.isPlaying = false;
114
- };
115
- }
116
-
117
-
118
- updateWaveform() {
119
- this.drawWaveform(this.audioBuffer);
120
- if (this.isPlaying) {
121
- requestAnimationFrame(() => this.updateWaveform());
122
- }
123
- }
124
-
125
- formatTime(seconds: number): string {
126
- const minutes = Math.floor(seconds / 60);
127
- const sec = Math.floor(seconds % 60);
128
- return `${minutes}:${sec < 10 ? '0' + sec : sec}`;
129
- }
130
-
131
- getAudioDuration() {
132
- const audio = new Audio();
133
- audio.src = this.rawAudioUrl!;
134
- audio.addEventListener('loadedmetadata', () => {
135
- if (audio.duration === Infinity) {
136
- audio.currentTime = Number.MAX_SAFE_INTEGER;
137
- audio.ontimeupdate = () => {
138
- audio.ontimeupdate = null;
139
- audio.currentTime = 0;
140
- this.audioDuration = audio.duration;
141
- };
142
- } else {
143
- this.audioDuration = audio.duration;
144
- }
145
- });
146
- }
147
- }