@webitel/ui-sdk 24.10.25 → 24.10.27
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/img/sprite/arrange.svg +7 -0
- package/dist/img/sprite/index.js +1 -0
- package/dist/ui-sdk.js +549 -548
- package/dist/ui-sdk.umd.cjs +2 -2
- package/package.json +1 -1
- package/src/modules/Notifications/assets/audio/triggerSound.js +40 -9
- package/src/modules/Notifications/store/NotificationsStoreModule.js +2 -4
package/package.json
CHANGED
|
@@ -1,23 +1,54 @@
|
|
|
1
|
-
function triggerSound(soundVolume =
|
|
2
|
-
// Initialize the AudioContext if it hasn't been created yet
|
|
1
|
+
function triggerSound(soundVolume = 0.6, soundDuration = 0.2) {
|
|
3
2
|
let audioContext;
|
|
3
|
+
|
|
4
4
|
if (!audioContext) {
|
|
5
5
|
audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
const gainNode = audioContext.createGain();
|
|
8
8
|
const oscillator = audioContext.createOscillator();
|
|
9
9
|
|
|
10
|
-
oscillator.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
gainNode.gain.value = soundVolume; // Set the ringtoneVolume based on the selected value
|
|
10
|
+
oscillator.type = 'sine';
|
|
11
|
+
oscillator.frequency.setValueAtTime(440, audioContext.currentTime); // Set frequency to A4
|
|
12
|
+
gainNode.gain.value = soundVolume;
|
|
14
13
|
|
|
15
14
|
oscillator.connect(gainNode);
|
|
16
15
|
gainNode.connect(audioContext.destination);
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
let isPlaying = false;
|
|
18
|
+
const events = {};
|
|
19
|
+
|
|
20
|
+
// Create a custom audio-like object
|
|
21
|
+
const audio = {
|
|
22
|
+
play: () => {
|
|
23
|
+
isPlaying = true;
|
|
24
|
+
try {
|
|
25
|
+
oscillator.start();
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.error('Error starting oscillator:', error);
|
|
28
|
+
}
|
|
29
|
+
setTimeout(() => {
|
|
30
|
+
oscillator.stop();
|
|
31
|
+
oscillator.disconnect();
|
|
32
|
+
gainNode.disconnect();
|
|
33
|
+
audio.dispatchEvent(new Event('ended'));
|
|
34
|
+
}, soundDuration * 1000);
|
|
35
|
+
},
|
|
36
|
+
pause: () => {
|
|
37
|
+
if (isPlaying) {
|
|
38
|
+
oscillator.stop();
|
|
39
|
+
isPlaying = false;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
addEventListener: (type, listener) => {
|
|
43
|
+
events[type] = listener;
|
|
44
|
+
},
|
|
45
|
+
dispatchEvent: (event) => {
|
|
46
|
+
if (events[event.type]) events[event.type](event);
|
|
47
|
+
},
|
|
48
|
+
volume: gainNode.gain.value,
|
|
49
|
+
};
|
|
19
50
|
|
|
20
|
-
|
|
51
|
+
return audio;
|
|
21
52
|
}
|
|
22
53
|
|
|
23
54
|
export default triggerSound;
|
|
@@ -114,11 +114,9 @@ export default class NotificationsStoreModule extends BaseStoreModule {
|
|
|
114
114
|
context.dispatch('_REMOVE_CURRENT_TAB_ID'),
|
|
115
115
|
]),
|
|
116
116
|
|
|
117
|
-
PLAY_SOUND: (context, { action, sound = getNotificationSound(action), volume = 1.0 }) => {
|
|
117
|
+
PLAY_SOUND: async (context, { action, sound = getNotificationSound(action), volume = 1.0 }) => {
|
|
118
118
|
if (context.getters.IS_SOUND_ALLOWED && !localStorage.getItem('wtIsPlaying')) {
|
|
119
|
-
const audio = sound instanceof Audio ? sound : new Audio(sound);
|
|
120
|
-
|
|
121
|
-
// Set the volume of the audio
|
|
119
|
+
const audio = sound instanceof Audio || sound.play ? sound : new Audio(sound);
|
|
122
120
|
audio.volume = volume;
|
|
123
121
|
|
|
124
122
|
audio.addEventListener(
|