@seniorsistemas/angular-components 17.26.9-bugfix-sds-309-cfd66723 → 17.26.9-bugfix-sds-307-c6084396
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/bundles/seniorsistemas-angular-components.umd.js +45 -68
- package/bundles/seniorsistemas-angular-components.umd.js.map +1 -1
- package/bundles/seniorsistemas-angular-components.umd.min.js +2 -2
- package/bundles/seniorsistemas-angular-components.umd.min.js.map +1 -1
- package/components/speech-recognition/speech-recognition.service.d.ts +2 -1
- package/esm2015/components/speech-recognition/speech-recognition/speech-recognition.component.js +1 -1
- package/esm2015/components/speech-recognition/speech-recognition.service.js +22 -36
- package/esm2015/components/tooltip/tooltip.component.js +1 -1
- package/esm5/components/speech-recognition/speech-recognition/speech-recognition.component.js +1 -1
- package/esm5/components/speech-recognition/speech-recognition.service.js +46 -69
- package/esm5/components/tooltip/tooltip.component.js +1 -1
- package/fesm2015/seniorsistemas-angular-components.js +21 -35
- package/fesm2015/seniorsistemas-angular-components.js.map +1 -1
- package/fesm5/seniorsistemas-angular-components.js +45 -68
- package/fesm5/seniorsistemas-angular-components.js.map +1 -1
- package/package.json +1 -1
- package/seniorsistemas-angular-components.metadata.json +1 -1
|
@@ -534,7 +534,7 @@
|
|
|
534
534
|
TooltipComponent = __decorate([
|
|
535
535
|
core.Component({
|
|
536
536
|
template: "<div\n id=\"tooltip\"\n class=\"tooltip\"\n [ngClass]=\"['tooltip--' + position]\"\n [class.tooltip--visible]=\"visible\"\n [ngStyle]=\"{\n 'left': left + 'px',\n 'top': top + 'px'\n }\">\n <ng-template\n *ngIf=\"escape;\n then escapeTemplate;\n else noEscapeTemplate\">\n </ng-template> \n</div>\n\n<ng-template #noEscapeTemplate>\n <span\n class=\"tooltip__content\"\n [innerHTML]=\"tooltip\">\n </span>\n</ng-template>\n\n<ng-template #escapeTemplate>\n <span class=\"tooltip__content\">\n {{ tooltip }}\n </span>\n</ng-template>",
|
|
537
|
-
styles: [".tooltip{background-color:#000;border-radius:2px;color:#fff;font-family:\"Open Sans\",sans-serif;font-size:14px;font-weight:400;line-height:21px;opacity:0;padding:8px;
|
|
537
|
+
styles: [".tooltip{background-color:#000;border-radius:2px;color:#fff;font-family:\"Open Sans\",sans-serif;font-size:14px;font-weight:400;line-height:21px;opacity:0;padding:8px;transform:translateX(-50%);text-align:center;max-width:220px;word-wrap:break-word;z-index:99999;position:absolute}.tooltip--visible{opacity:1;transition:opacity .3s}.tooltip::before{content:\"\";height:0;position:absolute;width:0}.tooltip--bottom{margin-top:5px;transform:translateX(-50%)}.tooltip--bottom::before{border:5px solid transparent;border-bottom:5px solid #000;left:calc(50% - 5px);top:-10px}.tooltip--top{margin-bottom:5px;transform:translate(-50%,-100%)}.tooltip--top::before{border:5px solid transparent;border-top:5px solid #000;left:calc(50% - 5px);bottom:-10px}.tooltip--left{margin-right:28px;transform:translate(calc(-100% - 7px),-50%)}.tooltip--left::before{border:5px solid transparent;border-left:5px solid #000;right:-10px;bottom:calc(50% - 5px)}.tooltip--right{margin-left:7px;transform:translateY(-50%)}.tooltip--right::before{border:5px solid transparent;border-right:5px solid #000;left:-10px;bottom:calc(50% - 5px)}"]
|
|
538
538
|
})
|
|
539
539
|
], TooltipComponent);
|
|
540
540
|
return TooltipComponent;
|
|
@@ -11504,7 +11504,9 @@
|
|
|
11504
11504
|
this.translateService = translateService;
|
|
11505
11505
|
this.hasSupportSpeechRecognition = false;
|
|
11506
11506
|
this.isListening = false;
|
|
11507
|
+
this.hasMicrophoneAccess = false;
|
|
11507
11508
|
this.TIMEOUT_NO_MESSAGE = 3000;
|
|
11509
|
+
this.verifyMicrophoneState();
|
|
11508
11510
|
this.setRecognition();
|
|
11509
11511
|
}
|
|
11510
11512
|
SpeechRecognitionService.prototype.listen = function () {
|
|
@@ -11513,70 +11515,82 @@
|
|
|
11513
11515
|
if (this.isListening) {
|
|
11514
11516
|
speechSubject.error('Already listening');
|
|
11515
11517
|
}
|
|
11516
|
-
this.hasMicrophoneAccess
|
|
11517
|
-
|
|
11518
|
-
|
|
11519
|
-
|
|
11520
|
-
|
|
11521
|
-
|
|
11522
|
-
|
|
11523
|
-
|
|
11524
|
-
|
|
11525
|
-
|
|
11526
|
-
var
|
|
11527
|
-
var
|
|
11528
|
-
if (
|
|
11529
|
-
clearTimeout(
|
|
11518
|
+
else if (!this.hasMicrophoneAccess) {
|
|
11519
|
+
this.isListening = false;
|
|
11520
|
+
this.toastService.show({ severity: 'error', text: this.translateService.instant('platform.angular_components.no_microphone_permission') });
|
|
11521
|
+
speechSubject.error('Microphone access is disabled');
|
|
11522
|
+
}
|
|
11523
|
+
else {
|
|
11524
|
+
this.isListening = true;
|
|
11525
|
+
this.recognition.continuous = true;
|
|
11526
|
+
this.recognition.interimResults = true;
|
|
11527
|
+
this.recognition.maxAlternatives = 1;
|
|
11528
|
+
var silenceTimer_1;
|
|
11529
|
+
var restartSilenceTimer_1 = function () {
|
|
11530
|
+
if (silenceTimer_1 !== undefined) {
|
|
11531
|
+
clearTimeout(silenceTimer_1);
|
|
11530
11532
|
}
|
|
11531
|
-
|
|
11533
|
+
silenceTimer_1 = setTimeout(function () {
|
|
11532
11534
|
_this.recognition.stop();
|
|
11533
11535
|
}, _this.TIMEOUT_NO_MESSAGE);
|
|
11534
11536
|
};
|
|
11535
|
-
var
|
|
11536
|
-
var
|
|
11537
|
-
|
|
11537
|
+
var fullTranscript_1 = '';
|
|
11538
|
+
var interimTranscript_1 = '';
|
|
11539
|
+
this.recognition.onresult = function (event) {
|
|
11538
11540
|
_this.ngZone.run(function () {
|
|
11539
|
-
|
|
11541
|
+
restartSilenceTimer_1();
|
|
11540
11542
|
var interimTranscript = '';
|
|
11541
11543
|
for (var i = event.resultIndex; i < event.results.length; ++i) {
|
|
11542
11544
|
var transcript = event.results[i][0].transcript;
|
|
11543
11545
|
if (event.results[i].isFinal) {
|
|
11544
|
-
|
|
11546
|
+
fullTranscript_1 += transcript + '\n';
|
|
11545
11547
|
}
|
|
11546
11548
|
else {
|
|
11547
11549
|
interimTranscript += transcript;
|
|
11548
11550
|
}
|
|
11549
11551
|
}
|
|
11550
11552
|
interimTranscript = interimTranscript;
|
|
11551
|
-
speechSubject.next({ text:
|
|
11553
|
+
speechSubject.next({ text: fullTranscript_1 + interimTranscript, isFinal: false });
|
|
11552
11554
|
});
|
|
11553
11555
|
};
|
|
11554
|
-
|
|
11556
|
+
this.recognition.onerror = function () {
|
|
11555
11557
|
_this.ngZone.run(function () {
|
|
11556
|
-
if (
|
|
11557
|
-
clearTimeout(
|
|
11558
|
+
if (silenceTimer_1 !== undefined) {
|
|
11559
|
+
clearTimeout(silenceTimer_1);
|
|
11558
11560
|
}
|
|
11559
11561
|
_this.isListening = false;
|
|
11560
11562
|
speechSubject.error('Speech recognition error');
|
|
11561
11563
|
});
|
|
11562
11564
|
};
|
|
11563
|
-
|
|
11565
|
+
this.recognition.onend = function () {
|
|
11564
11566
|
_this.ngZone.run(function () {
|
|
11565
|
-
if (
|
|
11566
|
-
clearTimeout(
|
|
11567
|
+
if (silenceTimer_1 !== undefined) {
|
|
11568
|
+
clearTimeout(silenceTimer_1);
|
|
11567
11569
|
}
|
|
11568
|
-
speechSubject.next({ text:
|
|
11570
|
+
speechSubject.next({ text: fullTranscript_1 + interimTranscript_1, isFinal: true });
|
|
11569
11571
|
_this.isListening = false;
|
|
11570
11572
|
speechSubject.complete();
|
|
11571
11573
|
});
|
|
11572
11574
|
};
|
|
11573
|
-
|
|
11574
|
-
}
|
|
11575
|
+
this.recognition.start();
|
|
11576
|
+
}
|
|
11575
11577
|
return speechSubject;
|
|
11576
11578
|
};
|
|
11577
11579
|
SpeechRecognitionService.prototype.stop = function () {
|
|
11578
11580
|
this.recognition.stop();
|
|
11579
11581
|
};
|
|
11582
|
+
SpeechRecognitionService.prototype.verifyMicrophoneState = function () {
|
|
11583
|
+
var _this = this;
|
|
11584
|
+
navigator.permissions.query({ name: 'microphone' }).then(function (result) {
|
|
11585
|
+
var microphoneResultState = result.state;
|
|
11586
|
+
_this.hasMicrophoneAccess = microphoneResultState === 'granted';
|
|
11587
|
+
result.onchange = function () {
|
|
11588
|
+
_this.ngZone.run(function () {
|
|
11589
|
+
_this.hasMicrophoneAccess = result.state === 'granted';
|
|
11590
|
+
});
|
|
11591
|
+
};
|
|
11592
|
+
});
|
|
11593
|
+
};
|
|
11580
11594
|
SpeechRecognitionService.prototype.setRecognition = function () {
|
|
11581
11595
|
var _this = this;
|
|
11582
11596
|
var _a;
|
|
@@ -11592,43 +11606,6 @@
|
|
|
11592
11606
|
this.recognition.maxAlternatives = 1;
|
|
11593
11607
|
this.localeService.getLocale().subscribe(function (locale) { return _this.recognition.lang = locale; });
|
|
11594
11608
|
};
|
|
11595
|
-
SpeechRecognitionService.prototype.hasMicrophoneAccess = function () {
|
|
11596
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
11597
|
-
var permission, stream, _a, _b;
|
|
11598
|
-
return __generator(this, function (_c) {
|
|
11599
|
-
switch (_c.label) {
|
|
11600
|
-
case 0:
|
|
11601
|
-
_c.trys.push([0, 6, , 7]);
|
|
11602
|
-
return [4 /*yield*/, navigator.permissions.query({ name: 'microphone' })];
|
|
11603
|
-
case 1:
|
|
11604
|
-
permission = _c.sent();
|
|
11605
|
-
if (permission.state === 'denied') {
|
|
11606
|
-
return [2 /*return*/, false];
|
|
11607
|
-
}
|
|
11608
|
-
if (permission.state === 'granted') {
|
|
11609
|
-
return [2 /*return*/, true];
|
|
11610
|
-
}
|
|
11611
|
-
if (!(permission.state === 'prompt')) return [3 /*break*/, 5];
|
|
11612
|
-
_c.label = 2;
|
|
11613
|
-
case 2:
|
|
11614
|
-
_c.trys.push([2, 4, , 5]);
|
|
11615
|
-
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({ audio: true })];
|
|
11616
|
-
case 3:
|
|
11617
|
-
stream = _c.sent();
|
|
11618
|
-
stream.getTracks().forEach(function (t) { return t.stop(); });
|
|
11619
|
-
return [2 /*return*/, true];
|
|
11620
|
-
case 4:
|
|
11621
|
-
_a = _c.sent();
|
|
11622
|
-
return [2 /*return*/, false];
|
|
11623
|
-
case 5: return [2 /*return*/, false];
|
|
11624
|
-
case 6:
|
|
11625
|
-
_b = _c.sent();
|
|
11626
|
-
return [2 /*return*/, false];
|
|
11627
|
-
case 7: return [2 /*return*/];
|
|
11628
|
-
}
|
|
11629
|
-
});
|
|
11630
|
-
});
|
|
11631
|
-
};
|
|
11632
11609
|
SpeechRecognitionService.ctorParameters = function () { return [
|
|
11633
11610
|
{ type: LocaleService },
|
|
11634
11611
|
{ type: core.NgZone },
|