@snapcall/stream-ui 1.28.1 → 1.29.0
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/stream-ui.esm.js +71 -30
- package/dist/stream-ui.js +71 -30
- package/dist/types.d.ts +5 -3
- package/package.json +1 -1
package/dist/stream-ui.esm.js
CHANGED
|
@@ -503,19 +503,17 @@ const $67e45b2e30dcc030$var$audioContextConstructor = window.AudioContext || win
|
|
|
503
503
|
const $67e45b2e30dcc030$var$AUDIO_MUTE_DETECTION_TIME = 2000;
|
|
504
504
|
const $67e45b2e30dcc030$var$START_SPEAK_DETECTION_TIME = 50;
|
|
505
505
|
const $67e45b2e30dcc030$var$STOP_SPEAK_DETECTION_TIME = 500;
|
|
506
|
+
const $67e45b2e30dcc030$var$AUDIO_DATA_RATE = 60;
|
|
506
507
|
class $67e45b2e30dcc030$export$ea669869acd8f177 {
|
|
507
508
|
constructor(stream, listener){
|
|
508
509
|
this.speakStartEventTime = 0;
|
|
509
510
|
this.speakStopEventTime = 0;
|
|
510
511
|
this.isSpeaking = false;
|
|
511
|
-
this.
|
|
512
|
-
this.audioLevelInterval = -1;
|
|
513
|
-
this.audioLevelAverageInterval = -1;
|
|
512
|
+
this.audioIntervals = {};
|
|
514
513
|
this.audioLevelAverage = {
|
|
515
514
|
count: 0,
|
|
516
515
|
average: 0
|
|
517
516
|
};
|
|
518
|
-
this.audioLevels = [];
|
|
519
517
|
this.id = stream.id;
|
|
520
518
|
this.listener = listener;
|
|
521
519
|
this.stream = stream;
|
|
@@ -532,15 +530,16 @@ class $67e45b2e30dcc030$export$ea669869acd8f177 {
|
|
|
532
530
|
this.analyser.minDecibels = -90;
|
|
533
531
|
this.analyser.maxDecibels = -10;
|
|
534
532
|
this.audioStreamSource.connect(this.analyser);
|
|
533
|
+
this.audioLevels = new Array(Math.round(1000 / $67e45b2e30dcc030$var$AUDIO_DATA_RATE)).fill(0);
|
|
535
534
|
}
|
|
536
535
|
/**
|
|
537
|
-
* return the
|
|
536
|
+
* return the average (mean) of the audio levels (AUDIO_DATA_RATE per second) for the
|
|
538
537
|
* current second
|
|
539
|
-
*/
|
|
538
|
+
*/ getRecentAudioLevelAverage() {
|
|
540
539
|
const { length: length } = this.audioLevels;
|
|
541
540
|
const audioLevelsSum = this.audioLevels.reduce((sum, level)=>sum + level, 0);
|
|
542
|
-
const
|
|
543
|
-
return
|
|
541
|
+
const audioLevelAverage = audioLevelsSum / length;
|
|
542
|
+
return audioLevelAverage;
|
|
544
543
|
}
|
|
545
544
|
getCurrentAudioLevel() {
|
|
546
545
|
const { length: length } = this.audioLevels;
|
|
@@ -548,8 +547,8 @@ class $67e45b2e30dcc030$export$ea669869acd8f177 {
|
|
|
548
547
|
return 0;
|
|
549
548
|
}
|
|
550
549
|
audioMuteDetection() {
|
|
551
|
-
const
|
|
552
|
-
if (
|
|
550
|
+
const audioLevelAverage = this.getRecentAudioLevelAverage();
|
|
551
|
+
if (audioLevelAverage === 0 && this.audioLevels.length > 0) this.listener?.onMuteDetection?.(this.id);
|
|
553
552
|
}
|
|
554
553
|
detectSpeakingChange(audioLevel) {
|
|
555
554
|
const threshold = 5;
|
|
@@ -588,24 +587,24 @@ class $67e45b2e30dcc030$export$ea669869acd8f177 {
|
|
|
588
587
|
}
|
|
589
588
|
loopCalcul() {
|
|
590
589
|
const audioLevel = this.getInstantAudioLevel();
|
|
591
|
-
this.audioLevels
|
|
592
|
-
this.detectSpeakingChange(audioLevel);
|
|
590
|
+
this.audioLevels.shift();
|
|
593
591
|
this.audioLevels.push(audioLevel);
|
|
592
|
+
this.detectSpeakingChange(audioLevel);
|
|
594
593
|
this.listener?.onAudioLevel?.(audioLevel, this.id);
|
|
595
594
|
}
|
|
596
595
|
analyse() {
|
|
597
|
-
this.
|
|
598
|
-
this.
|
|
596
|
+
this.audioIntervals.level = setInterval(()=>this.loopCalcul(), 1000 / $67e45b2e30dcc030$var$AUDIO_DATA_RATE);
|
|
597
|
+
this.audioIntervals.muteDetection = setInterval(()=>this.audioMuteDetection(), $67e45b2e30dcc030$var$AUDIO_MUTE_DETECTION_TIME);
|
|
599
598
|
}
|
|
600
599
|
startAverageAnalysis() {
|
|
601
600
|
this.audioLevelAverage = {
|
|
602
601
|
count: 0,
|
|
603
602
|
average: 0
|
|
604
603
|
};
|
|
605
|
-
clearInterval(this.
|
|
606
|
-
this.
|
|
604
|
+
clearInterval(this.audioIntervals.levelAverage);
|
|
605
|
+
this.audioIntervals.levelAverage = setInterval(()=>{
|
|
607
606
|
const { count: count, average: average } = this.audioLevelAverage;
|
|
608
|
-
const nextAverage = (average * count + this.
|
|
607
|
+
const nextAverage = (average * count + this.getRecentAudioLevelAverage()) / (count + 1);
|
|
609
608
|
this.audioLevelAverage = {
|
|
610
609
|
count: count + 1,
|
|
611
610
|
average: nextAverage
|
|
@@ -613,7 +612,8 @@ class $67e45b2e30dcc030$export$ea669869acd8f177 {
|
|
|
613
612
|
}, 1000);
|
|
614
613
|
}
|
|
615
614
|
stopAverageAnalysis() {
|
|
616
|
-
clearInterval(this.
|
|
615
|
+
clearInterval(this.audioIntervals.levelAverage);
|
|
616
|
+
delete this.audioIntervals.levelAverage;
|
|
617
617
|
return this.audioLevelAverage.average;
|
|
618
618
|
}
|
|
619
619
|
getFrequencyData() {
|
|
@@ -621,14 +621,18 @@ class $67e45b2e30dcc030$export$ea669869acd8f177 {
|
|
|
621
621
|
this.analyser.getByteFrequencyData(FFTDataArray);
|
|
622
622
|
return FFTDataArray;
|
|
623
623
|
}
|
|
624
|
-
|
|
625
|
-
clearInterval(this.
|
|
626
|
-
clearInterval(this.
|
|
627
|
-
this.
|
|
624
|
+
clearIntervals() {
|
|
625
|
+
clearInterval(this.audioIntervals.level);
|
|
626
|
+
clearInterval(this.audioIntervals.levelAverage);
|
|
627
|
+
clearInterval(this.audioIntervals.muteDetection);
|
|
628
|
+
delete this.audioIntervals.level;
|
|
629
|
+
delete this.audioIntervals.levelAverage;
|
|
630
|
+
delete this.audioIntervals.muteDetection;
|
|
631
|
+
this.audioLevels.fill(0);
|
|
628
632
|
}
|
|
629
633
|
release() {
|
|
630
634
|
this.listener = undefined;
|
|
631
|
-
this.
|
|
635
|
+
this.clearIntervals();
|
|
632
636
|
this.stream = undefined;
|
|
633
637
|
try {
|
|
634
638
|
this.audioStreamSource.disconnect(this.analyser);
|
|
@@ -982,8 +986,14 @@ class $ab40fd7a219a4259$export$2e2bcd8739ae039 {
|
|
|
982
986
|
let needToAskVideo = Boolean(constraints.video && (!this.video.stream || !this.video.track || this.video.track.readyState === 'ended'));
|
|
983
987
|
const audioDeviceId = $ab40fd7a219a4259$export$fceddabcb6d8e584(constraints.audio);
|
|
984
988
|
const videoDeviceId = $ab40fd7a219a4259$export$fceddabcb6d8e584(constraints.video);
|
|
985
|
-
|
|
986
|
-
|
|
989
|
+
const oldAudioDeviceId = this.audio.track?.getSettings().deviceId;
|
|
990
|
+
const oldVideoDeviceId = this.video.track?.getSettings().deviceId;
|
|
991
|
+
/*
|
|
992
|
+
If deviceId is 'default', we cant differentiate if it's the same device or not. https://issues.chromium.org/issues/40199570#comment23
|
|
993
|
+
A possible solution would be to compare the label of the track. There is no guarantee that it will be unique or match the deviceId.
|
|
994
|
+
ex track label: Default - Microphone (USB Audio Device) (046d:0992)
|
|
995
|
+
*/ if (audioDeviceId && (audioDeviceId === 'default' || audioDeviceId !== oldAudioDeviceId)) needToAskAudio = true;
|
|
996
|
+
if (videoDeviceId && (videoDeviceId === 'default' || videoDeviceId !== oldVideoDeviceId)) needToAskVideo = true;
|
|
987
997
|
if (typeof constraints.video === 'object' && constraints.video.facingMode && constraints.video.facingMode !== this.video.track?.getSettings().facingMode) needToAskVideo = true;
|
|
988
998
|
return {
|
|
989
999
|
needToAskAudio: needToAskAudio,
|
|
@@ -2072,6 +2082,7 @@ class $c31e3fb4360572af$export$2e2bcd8739ae039 extends $c31e3fb4360572af$var$Str
|
|
|
2072
2082
|
await this.micProducer?.replaceTrack({
|
|
2073
2083
|
track: track
|
|
2074
2084
|
});
|
|
2085
|
+
if (this.micProducer?.paused) track.enabled = false;
|
|
2075
2086
|
$c31e3fb4360572af$var$log.log('switchMicrophone', 'switched Microphone');
|
|
2076
2087
|
const trackSettings = track.getSettings();
|
|
2077
2088
|
const device = this.devicesList.find((it)=>it.deviceId === trackSettings.deviceId);
|
|
@@ -2621,6 +2632,7 @@ class $c31e3fb4360572af$export$2e2bcd8739ae039 extends $c31e3fb4360572af$var$Str
|
|
|
2621
2632
|
audio: false,
|
|
2622
2633
|
video: true
|
|
2623
2634
|
});
|
|
2635
|
+
this.webcam.device = null;
|
|
2624
2636
|
this.webcamProducer = null;
|
|
2625
2637
|
this.webcamTrack = null;
|
|
2626
2638
|
if (this.useVideoBackground) {
|
|
@@ -12129,14 +12141,14 @@ const $64dee502cbd6331e$export$1ea93f9eface5983 = ({ duration: duration = 0, ave
|
|
|
12129
12141
|
duotone: true
|
|
12130
12142
|
})
|
|
12131
12143
|
});
|
|
12132
|
-
if (averageAudioLevel <=
|
|
12144
|
+
if (averageAudioLevel <= 1) return /*#__PURE__*/ (0, $3Sbms$jsx)($64dee502cbd6331e$var$Notification, {
|
|
12133
12145
|
title: t('recorder.audioLevelNotification.spokenWordsWarning.title'),
|
|
12134
12146
|
description: t('recorder.audioLevelNotification.spokenWordsWarning.description'),
|
|
12135
12147
|
icon: /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$AlertTriangleIcon), {
|
|
12136
12148
|
duotone: true
|
|
12137
12149
|
})
|
|
12138
12150
|
});
|
|
12139
|
-
if (averageAudioLevel <=
|
|
12151
|
+
if (averageAudioLevel <= 3) return /*#__PURE__*/ (0, $3Sbms$jsx)($64dee502cbd6331e$var$Notification, {
|
|
12140
12152
|
title: t('recorder.audioLevelNotification.spokenWordsQuestion.title'),
|
|
12141
12153
|
description: t('recorder.audioLevelNotification.spokenWordsQuestion.description'),
|
|
12142
12154
|
icon: /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$InfoCircleIcon), {
|
|
@@ -12277,7 +12289,7 @@ const $a5dd8f67439dd9eb$var$getStoredAssets = async ()=>{
|
|
|
12277
12289
|
const storedAssets = JSON.parse(localStorage.getItem('snapcall_assets') || '[]');
|
|
12278
12290
|
const assets = await Promise.all(storedAssets.map(async (storedAsset)=>{
|
|
12279
12291
|
try {
|
|
12280
|
-
let { url: url, thumbnailUrl: thumbnailUrl } = await (0, $c9e496369b59be7a$export$2f377c2162fd02b2).readAsset(storedAsset.filename);
|
|
12292
|
+
let { url: url, thumbnailUrl: thumbnailUrl, error: error } = await (0, $c9e496369b59be7a$export$2f377c2162fd02b2).readAsset(storedAsset.filename);
|
|
12281
12293
|
if (url) {
|
|
12282
12294
|
if (storedAsset.mode === 'photo') thumbnailUrl = url;
|
|
12283
12295
|
return {
|
|
@@ -12285,7 +12297,7 @@ const $a5dd8f67439dd9eb$var$getStoredAssets = async ()=>{
|
|
|
12285
12297
|
url: url,
|
|
12286
12298
|
thumbnailUrl: thumbnailUrl
|
|
12287
12299
|
};
|
|
12288
|
-
}
|
|
12300
|
+
} else if (error) $a5dd8f67439dd9eb$export$df987b50509121ea(storedAsset.filename);
|
|
12289
12301
|
} catch (error) {
|
|
12290
12302
|
$a5dd8f67439dd9eb$export$df987b50509121ea(storedAsset.filename);
|
|
12291
12303
|
}
|
|
@@ -12331,6 +12343,31 @@ const $a5dd8f67439dd9eb$export$931d641a2a152cf = ()=>{
|
|
|
12331
12343
|
|
|
12332
12344
|
|
|
12333
12345
|
|
|
12346
|
+
|
|
12347
|
+
|
|
12348
|
+
const $7c2ec1087f88cbe4$export$f2bc44ad94513462 = ()=>{
|
|
12349
|
+
const { clientInitResult: clientInitResult } = (0, $3Sbms$useContext)((0, $5f30d8bf4f04621e$export$2e2bcd8739ae039));
|
|
12350
|
+
const flowSource = clientInitResult.flow?.steps?.[0].config?.source;
|
|
12351
|
+
const onRecorderEnd = ()=>{
|
|
12352
|
+
if (flowSource === 'smooch') // @ts-ignore
|
|
12353
|
+
window.WebviewSdk?.close?.();
|
|
12354
|
+
else if (flowSource === 'whatsapp') window.location.href = 'https://wa.me';
|
|
12355
|
+
};
|
|
12356
|
+
(0, $3Sbms$useEffect)(()=>{
|
|
12357
|
+
if (flowSource === 'smooch') {
|
|
12358
|
+
const smoochScript = document.createElement('script');
|
|
12359
|
+
smoochScript.src = 'https://cdn.smooch.io/webview-sdk.min.js';
|
|
12360
|
+
if (!document.body.contains(smoochScript)) document.body.appendChild(smoochScript);
|
|
12361
|
+
}
|
|
12362
|
+
}, [
|
|
12363
|
+
flowSource
|
|
12364
|
+
]);
|
|
12365
|
+
return {
|
|
12366
|
+
onRecorderEnd: onRecorderEnd
|
|
12367
|
+
};
|
|
12368
|
+
};
|
|
12369
|
+
|
|
12370
|
+
|
|
12334
12371
|
const $3ecacdd28d707ec1$var$eventTypes = {
|
|
12335
12372
|
screen: 'screenshare',
|
|
12336
12373
|
photo: 'image',
|
|
@@ -12340,6 +12377,7 @@ const $3ecacdd28d707ec1$var$eventTypes = {
|
|
|
12340
12377
|
const $3ecacdd28d707ec1$export$c01bb29adf88f117 = ({ state: state })=>{
|
|
12341
12378
|
const { t: t } = (0, $3Sbms$useTranslation)();
|
|
12342
12379
|
const { assets: assets, incomingAsset: incomingAsset } = (0, $75812785bb101fee$export$2174f25d572f9f31)();
|
|
12380
|
+
const flowSourceAction = (0, $7c2ec1087f88cbe4$export$f2bc44ad94513462)();
|
|
12343
12381
|
const sendMutation = (0, $3Sbms$useMutation)({
|
|
12344
12382
|
mutationFn: async ()=>{
|
|
12345
12383
|
try {
|
|
@@ -12364,7 +12402,6 @@ const $3ecacdd28d707ec1$export$c01bb29adf88f117 = ({ state: state })=>{
|
|
|
12364
12402
|
});
|
|
12365
12403
|
throw new Error('some media not saved');
|
|
12366
12404
|
}
|
|
12367
|
-
(0, $c9e496369b59be7a$export$2f377c2162fd02b2).release();
|
|
12368
12405
|
return results;
|
|
12369
12406
|
} catch (error) {
|
|
12370
12407
|
reportError({
|
|
@@ -12374,6 +12411,10 @@ const $3ecacdd28d707ec1$export$c01bb29adf88f117 = ({ state: state })=>{
|
|
|
12374
12411
|
console.log(error);
|
|
12375
12412
|
throw error;
|
|
12376
12413
|
}
|
|
12414
|
+
},
|
|
12415
|
+
onSuccess: ()=>{
|
|
12416
|
+
(0, $c9e496369b59be7a$export$2f377c2162fd02b2).release();
|
|
12417
|
+
flowSourceAction.onRecorderEnd();
|
|
12377
12418
|
}
|
|
12378
12419
|
});
|
|
12379
12420
|
const reportError = (0, $946223bbb2c552ef$export$5a5695b638d078e7)();
|
package/dist/stream-ui.js
CHANGED
|
@@ -509,19 +509,17 @@ const $6a90fae7e584afd4$var$audioContextConstructor = window.AudioContext || win
|
|
|
509
509
|
const $6a90fae7e584afd4$var$AUDIO_MUTE_DETECTION_TIME = 2000;
|
|
510
510
|
const $6a90fae7e584afd4$var$START_SPEAK_DETECTION_TIME = 50;
|
|
511
511
|
const $6a90fae7e584afd4$var$STOP_SPEAK_DETECTION_TIME = 500;
|
|
512
|
+
const $6a90fae7e584afd4$var$AUDIO_DATA_RATE = 60;
|
|
512
513
|
class $6a90fae7e584afd4$export$ea669869acd8f177 {
|
|
513
514
|
constructor(stream, listener){
|
|
514
515
|
this.speakStartEventTime = 0;
|
|
515
516
|
this.speakStopEventTime = 0;
|
|
516
517
|
this.isSpeaking = false;
|
|
517
|
-
this.
|
|
518
|
-
this.audioLevelInterval = -1;
|
|
519
|
-
this.audioLevelAverageInterval = -1;
|
|
518
|
+
this.audioIntervals = {};
|
|
520
519
|
this.audioLevelAverage = {
|
|
521
520
|
count: 0,
|
|
522
521
|
average: 0
|
|
523
522
|
};
|
|
524
|
-
this.audioLevels = [];
|
|
525
523
|
this.id = stream.id;
|
|
526
524
|
this.listener = listener;
|
|
527
525
|
this.stream = stream;
|
|
@@ -538,15 +536,16 @@ class $6a90fae7e584afd4$export$ea669869acd8f177 {
|
|
|
538
536
|
this.analyser.minDecibels = -90;
|
|
539
537
|
this.analyser.maxDecibels = -10;
|
|
540
538
|
this.audioStreamSource.connect(this.analyser);
|
|
539
|
+
this.audioLevels = new Array(Math.round(1000 / $6a90fae7e584afd4$var$AUDIO_DATA_RATE)).fill(0);
|
|
541
540
|
}
|
|
542
541
|
/**
|
|
543
|
-
* return the
|
|
542
|
+
* return the average (mean) of the audio levels (AUDIO_DATA_RATE per second) for the
|
|
544
543
|
* current second
|
|
545
|
-
*/
|
|
544
|
+
*/ getRecentAudioLevelAverage() {
|
|
546
545
|
const { length: length } = this.audioLevels;
|
|
547
546
|
const audioLevelsSum = this.audioLevels.reduce((sum, level)=>sum + level, 0);
|
|
548
|
-
const
|
|
549
|
-
return
|
|
547
|
+
const audioLevelAverage = audioLevelsSum / length;
|
|
548
|
+
return audioLevelAverage;
|
|
550
549
|
}
|
|
551
550
|
getCurrentAudioLevel() {
|
|
552
551
|
const { length: length } = this.audioLevels;
|
|
@@ -554,8 +553,8 @@ class $6a90fae7e584afd4$export$ea669869acd8f177 {
|
|
|
554
553
|
return 0;
|
|
555
554
|
}
|
|
556
555
|
audioMuteDetection() {
|
|
557
|
-
const
|
|
558
|
-
if (
|
|
556
|
+
const audioLevelAverage = this.getRecentAudioLevelAverage();
|
|
557
|
+
if (audioLevelAverage === 0 && this.audioLevels.length > 0) this.listener?.onMuteDetection?.(this.id);
|
|
559
558
|
}
|
|
560
559
|
detectSpeakingChange(audioLevel) {
|
|
561
560
|
const threshold = 5;
|
|
@@ -594,24 +593,24 @@ class $6a90fae7e584afd4$export$ea669869acd8f177 {
|
|
|
594
593
|
}
|
|
595
594
|
loopCalcul() {
|
|
596
595
|
const audioLevel = this.getInstantAudioLevel();
|
|
597
|
-
this.audioLevels
|
|
598
|
-
this.detectSpeakingChange(audioLevel);
|
|
596
|
+
this.audioLevels.shift();
|
|
599
597
|
this.audioLevels.push(audioLevel);
|
|
598
|
+
this.detectSpeakingChange(audioLevel);
|
|
600
599
|
this.listener?.onAudioLevel?.(audioLevel, this.id);
|
|
601
600
|
}
|
|
602
601
|
analyse() {
|
|
603
|
-
this.
|
|
604
|
-
this.
|
|
602
|
+
this.audioIntervals.level = setInterval(()=>this.loopCalcul(), 1000 / $6a90fae7e584afd4$var$AUDIO_DATA_RATE);
|
|
603
|
+
this.audioIntervals.muteDetection = setInterval(()=>this.audioMuteDetection(), $6a90fae7e584afd4$var$AUDIO_MUTE_DETECTION_TIME);
|
|
605
604
|
}
|
|
606
605
|
startAverageAnalysis() {
|
|
607
606
|
this.audioLevelAverage = {
|
|
608
607
|
count: 0,
|
|
609
608
|
average: 0
|
|
610
609
|
};
|
|
611
|
-
clearInterval(this.
|
|
612
|
-
this.
|
|
610
|
+
clearInterval(this.audioIntervals.levelAverage);
|
|
611
|
+
this.audioIntervals.levelAverage = setInterval(()=>{
|
|
613
612
|
const { count: count, average: average } = this.audioLevelAverage;
|
|
614
|
-
const nextAverage = (average * count + this.
|
|
613
|
+
const nextAverage = (average * count + this.getRecentAudioLevelAverage()) / (count + 1);
|
|
615
614
|
this.audioLevelAverage = {
|
|
616
615
|
count: count + 1,
|
|
617
616
|
average: nextAverage
|
|
@@ -619,7 +618,8 @@ class $6a90fae7e584afd4$export$ea669869acd8f177 {
|
|
|
619
618
|
}, 1000);
|
|
620
619
|
}
|
|
621
620
|
stopAverageAnalysis() {
|
|
622
|
-
clearInterval(this.
|
|
621
|
+
clearInterval(this.audioIntervals.levelAverage);
|
|
622
|
+
delete this.audioIntervals.levelAverage;
|
|
623
623
|
return this.audioLevelAverage.average;
|
|
624
624
|
}
|
|
625
625
|
getFrequencyData() {
|
|
@@ -627,14 +627,18 @@ class $6a90fae7e584afd4$export$ea669869acd8f177 {
|
|
|
627
627
|
this.analyser.getByteFrequencyData(FFTDataArray);
|
|
628
628
|
return FFTDataArray;
|
|
629
629
|
}
|
|
630
|
-
|
|
631
|
-
clearInterval(this.
|
|
632
|
-
clearInterval(this.
|
|
633
|
-
this.
|
|
630
|
+
clearIntervals() {
|
|
631
|
+
clearInterval(this.audioIntervals.level);
|
|
632
|
+
clearInterval(this.audioIntervals.levelAverage);
|
|
633
|
+
clearInterval(this.audioIntervals.muteDetection);
|
|
634
|
+
delete this.audioIntervals.level;
|
|
635
|
+
delete this.audioIntervals.levelAverage;
|
|
636
|
+
delete this.audioIntervals.muteDetection;
|
|
637
|
+
this.audioLevels.fill(0);
|
|
634
638
|
}
|
|
635
639
|
release() {
|
|
636
640
|
this.listener = undefined;
|
|
637
|
-
this.
|
|
641
|
+
this.clearIntervals();
|
|
638
642
|
this.stream = undefined;
|
|
639
643
|
try {
|
|
640
644
|
this.audioStreamSource.disconnect(this.analyser);
|
|
@@ -988,8 +992,14 @@ class $d582bbc5717818b4$export$2e2bcd8739ae039 {
|
|
|
988
992
|
let needToAskVideo = Boolean(constraints.video && (!this.video.stream || !this.video.track || this.video.track.readyState === 'ended'));
|
|
989
993
|
const audioDeviceId = $d582bbc5717818b4$export$fceddabcb6d8e584(constraints.audio);
|
|
990
994
|
const videoDeviceId = $d582bbc5717818b4$export$fceddabcb6d8e584(constraints.video);
|
|
991
|
-
|
|
992
|
-
|
|
995
|
+
const oldAudioDeviceId = this.audio.track?.getSettings().deviceId;
|
|
996
|
+
const oldVideoDeviceId = this.video.track?.getSettings().deviceId;
|
|
997
|
+
/*
|
|
998
|
+
If deviceId is 'default', we cant differentiate if it's the same device or not. https://issues.chromium.org/issues/40199570#comment23
|
|
999
|
+
A possible solution would be to compare the label of the track. There is no guarantee that it will be unique or match the deviceId.
|
|
1000
|
+
ex track label: Default - Microphone (USB Audio Device) (046d:0992)
|
|
1001
|
+
*/ if (audioDeviceId && (audioDeviceId === 'default' || audioDeviceId !== oldAudioDeviceId)) needToAskAudio = true;
|
|
1002
|
+
if (videoDeviceId && (videoDeviceId === 'default' || videoDeviceId !== oldVideoDeviceId)) needToAskVideo = true;
|
|
993
1003
|
if (typeof constraints.video === 'object' && constraints.video.facingMode && constraints.video.facingMode !== this.video.track?.getSettings().facingMode) needToAskVideo = true;
|
|
994
1004
|
return {
|
|
995
1005
|
needToAskAudio: needToAskAudio,
|
|
@@ -2078,6 +2088,7 @@ class $1dedebd5ff3002eb$export$2e2bcd8739ae039 extends $1dedebd5ff3002eb$var$Str
|
|
|
2078
2088
|
await this.micProducer?.replaceTrack({
|
|
2079
2089
|
track: track
|
|
2080
2090
|
});
|
|
2091
|
+
if (this.micProducer?.paused) track.enabled = false;
|
|
2081
2092
|
$1dedebd5ff3002eb$var$log.log('switchMicrophone', 'switched Microphone');
|
|
2082
2093
|
const trackSettings = track.getSettings();
|
|
2083
2094
|
const device = this.devicesList.find((it)=>it.deviceId === trackSettings.deviceId);
|
|
@@ -2627,6 +2638,7 @@ class $1dedebd5ff3002eb$export$2e2bcd8739ae039 extends $1dedebd5ff3002eb$var$Str
|
|
|
2627
2638
|
audio: false,
|
|
2628
2639
|
video: true
|
|
2629
2640
|
});
|
|
2641
|
+
this.webcam.device = null;
|
|
2630
2642
|
this.webcamProducer = null;
|
|
2631
2643
|
this.webcamTrack = null;
|
|
2632
2644
|
if (this.useVideoBackground) {
|
|
@@ -12135,14 +12147,14 @@ const $c42fbc742adf8306$export$1ea93f9eface5983 = ({ duration: duration = 0, ave
|
|
|
12135
12147
|
duotone: true
|
|
12136
12148
|
})
|
|
12137
12149
|
});
|
|
12138
|
-
if (averageAudioLevel <=
|
|
12150
|
+
if (averageAudioLevel <= 1) return /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)($c42fbc742adf8306$var$Notification, {
|
|
12139
12151
|
title: t('recorder.audioLevelNotification.spokenWordsWarning.title'),
|
|
12140
12152
|
description: t('recorder.audioLevelNotification.spokenWordsWarning.description'),
|
|
12141
12153
|
icon: /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)((0, $jQDcL$snapcalldesignsystemicons.AlertTriangleIcon), {
|
|
12142
12154
|
duotone: true
|
|
12143
12155
|
})
|
|
12144
12156
|
});
|
|
12145
|
-
if (averageAudioLevel <=
|
|
12157
|
+
if (averageAudioLevel <= 3) return /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)($c42fbc742adf8306$var$Notification, {
|
|
12146
12158
|
title: t('recorder.audioLevelNotification.spokenWordsQuestion.title'),
|
|
12147
12159
|
description: t('recorder.audioLevelNotification.spokenWordsQuestion.description'),
|
|
12148
12160
|
icon: /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)((0, $jQDcL$snapcalldesignsystemicons.InfoCircleIcon), {
|
|
@@ -12283,7 +12295,7 @@ const $8a7a24ac08dbc187$var$getStoredAssets = async ()=>{
|
|
|
12283
12295
|
const storedAssets = JSON.parse(localStorage.getItem('snapcall_assets') || '[]');
|
|
12284
12296
|
const assets = await Promise.all(storedAssets.map(async (storedAsset)=>{
|
|
12285
12297
|
try {
|
|
12286
|
-
let { url: url, thumbnailUrl: thumbnailUrl } = await (0, $c48c1ecc38fed4e9$export$2f377c2162fd02b2).readAsset(storedAsset.filename);
|
|
12298
|
+
let { url: url, thumbnailUrl: thumbnailUrl, error: error } = await (0, $c48c1ecc38fed4e9$export$2f377c2162fd02b2).readAsset(storedAsset.filename);
|
|
12287
12299
|
if (url) {
|
|
12288
12300
|
if (storedAsset.mode === 'photo') thumbnailUrl = url;
|
|
12289
12301
|
return {
|
|
@@ -12291,7 +12303,7 @@ const $8a7a24ac08dbc187$var$getStoredAssets = async ()=>{
|
|
|
12291
12303
|
url: url,
|
|
12292
12304
|
thumbnailUrl: thumbnailUrl
|
|
12293
12305
|
};
|
|
12294
|
-
}
|
|
12306
|
+
} else if (error) $8a7a24ac08dbc187$export$df987b50509121ea(storedAsset.filename);
|
|
12295
12307
|
} catch (error) {
|
|
12296
12308
|
$8a7a24ac08dbc187$export$df987b50509121ea(storedAsset.filename);
|
|
12297
12309
|
}
|
|
@@ -12337,6 +12349,31 @@ const $8a7a24ac08dbc187$export$931d641a2a152cf = ()=>{
|
|
|
12337
12349
|
|
|
12338
12350
|
|
|
12339
12351
|
|
|
12352
|
+
|
|
12353
|
+
|
|
12354
|
+
const $663f53e6b55f0d5a$export$f2bc44ad94513462 = ()=>{
|
|
12355
|
+
const { clientInitResult: clientInitResult } = (0, $jQDcL$react.useContext)((0, $8b39f32976a7698a$export$2e2bcd8739ae039));
|
|
12356
|
+
const flowSource = clientInitResult.flow?.steps?.[0].config?.source;
|
|
12357
|
+
const onRecorderEnd = ()=>{
|
|
12358
|
+
if (flowSource === 'smooch') // @ts-ignore
|
|
12359
|
+
window.WebviewSdk?.close?.();
|
|
12360
|
+
else if (flowSource === 'whatsapp') window.location.href = 'https://wa.me';
|
|
12361
|
+
};
|
|
12362
|
+
(0, $jQDcL$react.useEffect)(()=>{
|
|
12363
|
+
if (flowSource === 'smooch') {
|
|
12364
|
+
const smoochScript = document.createElement('script');
|
|
12365
|
+
smoochScript.src = 'https://cdn.smooch.io/webview-sdk.min.js';
|
|
12366
|
+
if (!document.body.contains(smoochScript)) document.body.appendChild(smoochScript);
|
|
12367
|
+
}
|
|
12368
|
+
}, [
|
|
12369
|
+
flowSource
|
|
12370
|
+
]);
|
|
12371
|
+
return {
|
|
12372
|
+
onRecorderEnd: onRecorderEnd
|
|
12373
|
+
};
|
|
12374
|
+
};
|
|
12375
|
+
|
|
12376
|
+
|
|
12340
12377
|
const $e399416dd32d3252$var$eventTypes = {
|
|
12341
12378
|
screen: 'screenshare',
|
|
12342
12379
|
photo: 'image',
|
|
@@ -12346,6 +12383,7 @@ const $e399416dd32d3252$var$eventTypes = {
|
|
|
12346
12383
|
const $e399416dd32d3252$export$c01bb29adf88f117 = ({ state: state })=>{
|
|
12347
12384
|
const { t: t } = (0, $jQDcL$reacti18next.useTranslation)();
|
|
12348
12385
|
const { assets: assets, incomingAsset: incomingAsset } = (0, $098350f721a0bb52$export$2174f25d572f9f31)();
|
|
12386
|
+
const flowSourceAction = (0, $663f53e6b55f0d5a$export$f2bc44ad94513462)();
|
|
12349
12387
|
const sendMutation = (0, $jQDcL$tanstackreactquery.useMutation)({
|
|
12350
12388
|
mutationFn: async ()=>{
|
|
12351
12389
|
try {
|
|
@@ -12370,7 +12408,6 @@ const $e399416dd32d3252$export$c01bb29adf88f117 = ({ state: state })=>{
|
|
|
12370
12408
|
});
|
|
12371
12409
|
throw new Error('some media not saved');
|
|
12372
12410
|
}
|
|
12373
|
-
(0, $c48c1ecc38fed4e9$export$2f377c2162fd02b2).release();
|
|
12374
12411
|
return results;
|
|
12375
12412
|
} catch (error) {
|
|
12376
12413
|
reportError({
|
|
@@ -12380,6 +12417,10 @@ const $e399416dd32d3252$export$c01bb29adf88f117 = ({ state: state })=>{
|
|
|
12380
12417
|
console.log(error);
|
|
12381
12418
|
throw error;
|
|
12382
12419
|
}
|
|
12420
|
+
},
|
|
12421
|
+
onSuccess: ()=>{
|
|
12422
|
+
(0, $c48c1ecc38fed4e9$export$2f377c2162fd02b2).release();
|
|
12423
|
+
flowSourceAction.onRecorderEnd();
|
|
12383
12424
|
}
|
|
12384
12425
|
});
|
|
12385
12426
|
const reportError = (0, $8dfcca373a03b9e8$export$5a5695b638d078e7)();
|
package/dist/types.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ interface Step {
|
|
|
18
18
|
config?: {
|
|
19
19
|
description: string;
|
|
20
20
|
image_url: string;
|
|
21
|
+
source?: string;
|
|
21
22
|
};
|
|
22
23
|
translation: {
|
|
23
24
|
title?: string;
|
|
@@ -192,16 +193,16 @@ declare class AudioLevel {
|
|
|
192
193
|
readonly id: string;
|
|
193
194
|
constructor(stream: MediaStream, listener?: AudioLevelListener);
|
|
194
195
|
/**
|
|
195
|
-
* return the
|
|
196
|
+
* return the average (mean) of the audio levels (AUDIO_DATA_RATE per second) for the
|
|
196
197
|
* current second
|
|
197
198
|
*/
|
|
198
|
-
|
|
199
|
+
getRecentAudioLevelAverage(): number;
|
|
199
200
|
getCurrentAudioLevel(): number;
|
|
200
201
|
analyse(): void;
|
|
201
202
|
startAverageAnalysis(): void;
|
|
202
203
|
stopAverageAnalysis(): number;
|
|
203
204
|
getFrequencyData(): Uint8Array;
|
|
204
|
-
|
|
205
|
+
clearIntervals(): void;
|
|
205
206
|
release(): void;
|
|
206
207
|
static isAPIAvailable(): boolean;
|
|
207
208
|
}
|
|
@@ -599,6 +600,7 @@ declare class StreamerClient extends StreamerEventTargetType implements AudioLev
|
|
|
599
600
|
readAsset(file: string): Promise<{
|
|
600
601
|
url: string;
|
|
601
602
|
thumbnailUrl?: string;
|
|
603
|
+
error?: string;
|
|
602
604
|
}>;
|
|
603
605
|
deleteAsset(file: string): Promise<{
|
|
604
606
|
status: boolean;
|