Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Bump [email protected]

* Update PR number

* Fix mock module name

* Fix unit test
  • Loading branch information
compulim authored Nov 26, 2024
1 parent 3d90e54 commit c3857bf
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 104 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ Notes: web developers are advised to use [`~` (tilde range)](https://github.com/
- Switched math block syntax from `$$` to Tex-style `\[ \]` and `\( \)` delimiters with improved rendering and error handling, in PR [#5353](https://github.com/microsoft/BotFramework-WebChat/pull/5353), by [@OEvgeny](https://github.com/OEvgeny)
- Improved avatar display and grouping behavior by fixing rendering issues and activity sender identification, in PR [#5346](https://github.com/microsoft/BotFramework-WebChat/pull/5346), by [@OEvgeny](https://github.com/OEvgeny)
- Activity "copy" button will use `outerHTML` and `textContent` for clipboard content, in PR [#5378](https://github.com/microsoft/BotFramework-WebChat/pull/5378), by [@compulim](https://github.com/compulim)
- Bumped dependencies to the latest versions, by [@compulim](https://github.com/compulim) in PR [#5385](https://github.com/microsoft/BotFramework-WebChat/pull/5385)
- Production dependencies
- [`[email protected]`](https://npmjs.com/package/web-speech-cognitive-services)

### Fixed

Expand All @@ -106,10 +109,11 @@ Notes: web developers are advised to use [`~` (tilde range)](https://github.com/
- Fixes [#5319](https://github.com/microsoft/BotFramework-WebChat/issues/5319). Some Markdown text are not rendered after HTML tags, in PR [#5320](https://github.com/microsoft/BotFramework-WebChat/pull/5320), by [@compulim](https://github.com/compulim)
- Fixes [#5323](https://github.com/microsoft/BotFramework-WebChat/issues/5323). Removed unused CSS class from carousel component, eliminating unintended styling, in PR [#5325](https://github.com/microsoft/BotFramework-WebChat/pull/5325), by [@OEvgeny](https://github.com/OEvgeny)
- Resolved CSS class name conflicts between component and fluent packages to prevent styling issues, in PR [#5326](https://github.com/microsoft/BotFramework-WebChat/pull/5326), in PR [#5327](https://github.com/microsoft/BotFramework-WebChat/pull/5327), by [@OEvgeny](https://github.com/OEvgeny)
- Fixed [#5350](https://github.com/microsoft/BotFramework-WebChat/issues/pull/5350). Bundled `shiki` in component package, in PR [#5349](https://github.com/microsoft/BotFramework-WebChat/pull5349), by [@compulim](https://github.com/compulim)
- Fixed [#5350](https://github.com/microsoft/BotFramework-WebChat/issues/5350). Bundled `shiki` in component package, in PR [#5349](https://github.com/microsoft/BotFramework-WebChat/pull/5349), by [@compulim](https://github.com/compulim)
- Fixed modal dialog rendering to prevent visual flicker and improve UX when opening code views, in PR [#5374](https://github.com/microsoft/BotFramework-WebChat/pull/5374), by [@OEvgeny](https://github.com/OEvgeny)
- Fixed math parsing that could cause Web Chat to hang when processing certain LaTeX expressions, in PR [#5377](https://github.com/microsoft/BotFramework-WebChat/pull/5377), by [@OEvgeny](https://github.com/OEvgeny)
- Fixed long math formula should be scrollable, in PR [#5380](https://github.com/microsoft/BotFramework-WebChat/pull/5380), by [@compulim](https://github.com/compulim)
- Fixed [#4948](https://github.com/microsoft/BotFramework-WebChat/issues/4948). Microphone should stop after initial silence, in PR [#5385](https://github.com/microsoft/BotFramework-WebChat/pull/5385)

# Removed

Expand Down
102 changes: 24 additions & 78 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"swiper": "8.4.7",
"url-search-params-polyfill": "8.2.5",
"uuid": "8.3.2",
"web-speech-cognitive-services": "7.1.3",
"web-speech-cognitive-services": "^8.0.0",
"whatwg-fetch": "3.6.20"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
/* eslint-disable no-global-assign */
let consoleWarns;
let createCognitiveServicesSpeechServicesPonyfillFactory;
let createPonyfill;
let createSpeechServicesPonyfill;
let originalConsole;

beforeEach(() => {
jest.mock('web-speech-cognitive-services/lib/SpeechServices', () => jest.fn(() => ({})));
jest.mock('web-speech-cognitive-services', () => ({
createSpeechServicesPonyfill: jest.fn(() => ({}))
}));
jest.mock('microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/Exports', () => ({
...jest.requireActual('microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/Exports'),
PcmRecorder: class MockPcmRecorder {
Expand All @@ -34,7 +36,7 @@ beforeEach(() => {
warn: text => consoleWarns.push(text)
};

createPonyfill = require('web-speech-cognitive-services/lib/SpeechServices');
createSpeechServicesPonyfill = require('web-speech-cognitive-services').createSpeechServicesPonyfill;
createCognitiveServicesSpeechServicesPonyfillFactory =
require('./createCognitiveServicesSpeechServicesPonyfillFactory').default;

Expand Down Expand Up @@ -75,7 +77,7 @@ test('providing reference grammar ID', () => {

ponyfillFactory({ referenceGrammarID: 'a1b2c3d' });

const { referenceGrammars } = createPonyfill.mock.calls[0][0];
const { referenceGrammars } = createSpeechServicesPonyfill.mock.calls[0][0];

expect(referenceGrammars).toEqual(['luis/a1b2c3d-PRODUCTION']);
});
Expand All @@ -90,7 +92,7 @@ test('not providing reference grammar ID', () => {

ponyfillFactory({});

const { referenceGrammars } = createPonyfill.mock.calls[0][0];
const { referenceGrammars } = createSpeechServicesPonyfill.mock.calls[0][0];

expect(referenceGrammars).toEqual([]);
});
Expand All @@ -109,7 +111,7 @@ test('supplying audioInputDeviceId', async () => {
ponyfillFactory({});

// WHEN: Audio source is attached and audio device is opened.
await createPonyfill.mock.calls[0][0].audioConfig.privSource.attach();
await createSpeechServicesPonyfill.mock.calls[0][0].audioConfig.privSource.attach();

// THEN: It should call getUserMedia() with "audio" constraints of { deviceId: 'audio-input-device-1' }.
expect(window.navigator.mediaDevices.getUserMedia.mock.calls[0][0]).toHaveProperty(
Expand Down Expand Up @@ -138,7 +140,7 @@ test('supplying both audioConfig and audioInputDeviceId', () => {
`"botframework-webchat: \\"audioConfig\\" and \\"audioInputDeviceId\\" cannot be set at the same time; ignoring \\"audioInputDeviceId\\"."`
);

expect(createPonyfill.mock.calls[0][0].audioConfig).toBe(audioConfig);
expect(createSpeechServicesPonyfill.mock.calls[0][0].audioConfig).toBe(audioConfig);
});

test('unsupported environment', () => {
Expand Down Expand Up @@ -176,5 +178,5 @@ test('unsupported environment with audioConfig', () => {
ponyfillFactory({});

expect(consoleWarns).toHaveProperty('length', 0);
expect(createPonyfill.mock.calls[0][0].audioConfig).toBe(audioConfig);
expect(createSpeechServicesPonyfill.mock.calls[0][0].audioConfig).toBe(audioConfig);
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { AudioConfig } from 'microsoft-cognitiveservices-speech-sdk';
import { WebSpeechPonyfillFactory } from 'botframework-webchat-api';
import createPonyfill from 'web-speech-cognitive-services/lib/SpeechServices';
import { AudioConfig } from 'microsoft-cognitiveservices-speech-sdk';
import { createSpeechServicesPonyfill } from 'web-speech-cognitive-services';

import createMicrophoneAudioConfigAndAudioContext from './speech/createMicrophoneAudioConfigAndAudioContext';
import CognitiveServicesAudioOutputFormat from './types/CognitiveServicesAudioOutputFormat';
import CognitiveServicesCredentials from './types/CognitiveServicesCredentials';
import CognitiveServicesTextNormalization from './types/CognitiveServicesTextNormalization';
import createMicrophoneAudioConfigAndAudioContext from './speech/createMicrophoneAudioConfigAndAudioContext';

export default function createCognitiveServicesSpeechServicesPonyfillFactory({
audioConfig,
Expand Down Expand Up @@ -55,17 +55,18 @@ export default function createCognitiveServicesSpeechServicesPonyfillFactory({
}

return ({ referenceGrammarID } = {}) => {
const { SpeechGrammarList, SpeechRecognition, speechSynthesis, SpeechSynthesisUtterance } = createPonyfill({
audioConfig,
audioContext,
credentials,
enableTelemetry,
referenceGrammars: referenceGrammarID ? [`luis/${referenceGrammarID}-PRODUCTION`] : [],
speechRecognitionEndpointId,
speechSynthesisDeploymentId,
speechSynthesisOutputFormat,
textNormalization
});
const { SpeechGrammarList, SpeechRecognition, speechSynthesis, SpeechSynthesisUtterance } =
createSpeechServicesPonyfill({
audioConfig,
audioContext,
credentials,
enableTelemetry,
referenceGrammars: referenceGrammarID ? [`luis/${referenceGrammarID}-PRODUCTION`] : [],
speechRecognitionEndpointId,
speechSynthesisDeploymentId,
speechSynthesisOutputFormat,
textNormalization
});

return {
resumeAudioContext: () => audioContext && audioContext.state === 'suspended' && audioContext.resume(),
Expand Down
2 changes: 1 addition & 1 deletion packages/directlinespeech/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"event-target-shim": "6.0.2",
"math-random": "2.0.1",
"microsoft-cognitiveservices-speech-sdk": "1.17.0",
"web-speech-cognitive-services": "7.1.3"
"web-speech-cognitive-services": "^8.0.0"
},
"engines": {
"node": ">= 10.14.2"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint class-methods-use-this: ["error", { "exceptMethods": ["cancel", "getVoices", "speak"] }] */

import { AbortController } from 'abort-controller-es5';
import { createSpeechRecognitionPonyfillFromRecognizer } from 'web-speech-cognitive-services/lib/SpeechServices/SpeechToText.js';
import { createSpeechRecognitionPonyfillFromRecognizer } from 'web-speech-cognitive-services';

import createTaskQueue from './createTaskQueue';
import EventTarget, { Event, getEventAttributeValue, setEventAttributeValue } from 'event-target-shim';
Expand Down

0 comments on commit c3857bf

Please sign in to comment.