From c3857bf9fb4ba963c50ef32cd03bf9c70f1da70e Mon Sep 17 00:00:00 2001 From: William Wong Date: Tue, 26 Nov 2024 10:46:17 -0800 Subject: [PATCH] Bump web-speech-cognitive-services@8.0.0 (#5385) * Bump web-speech-cognitive-services@8.0.0 * Update PR number * Fix mock module name * Fix unit test --- CHANGELOG.md | 6 +- package-lock.json | 102 +++++------------- packages/bundle/package.json | 2 +- ...vicesSpeechServicesPonyfillFactory.spec.js | 18 ++-- ...veServicesSpeechServicesPonyfillFactory.ts | 29 ++--- packages/directlinespeech/package.json | 2 +- .../src/createWebSpeechPonyfillFactory.js | 2 +- 7 files changed, 57 insertions(+), 104 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b70e146b4..5541621d68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 + - [`web-speech-cognitive-services@8.0.0`](https://npmjs.com/package/web-speech-cognitive-services) ### Fixed @@ -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 diff --git a/package-lock.json b/package-lock.json index f205976b87..5b1e3f0ba3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17750,10 +17750,13 @@ } }, "node_modules/on-error-resume-next": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/on-error-resume-next/-/on-error-resume-next-1.1.0.tgz", - "integrity": "sha512-XhWMbmKV0+W95yLJjT1Z9zdkKiPUjDn63YYsji1pdvKqaa7pq4coeHaHEXPsa36SFlffOyOlPK/0rn6Njfb+LA==", - "license": "MIT" + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/on-error-resume-next/-/on-error-resume-next-2.0.1.tgz", + "integrity": "sha512-TWop/Bivr/7/JC0zLlYqqfGTiMnsRYHCIPdZuwWvMbHQtphW0x2PJ5WeAKleji64jXlOKUOpDsniXJkghH1nXA==", + "license": "MIT", + "dependencies": { + "on-error-resume-next": "^2.0.1" + } }, "node_modules/on-finished": { "version": "2.4.1", @@ -17833,40 +17836,6 @@ "node": ">= 0.8.0" } }, - "node_modules/p-defer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-4.0.1.tgz", - "integrity": "sha512-Mr5KC5efvAK5VUptYEIopP1bakB85k2IWXaRC0rsh1uwn1L6M0LVml8OIQ4Gudg4oyZakf7FmeRLkMMtZW1i5A==", - "peer": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/p-defer-es5": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/p-defer-es5/-/p-defer-es5-2.0.1.tgz", - "integrity": "sha512-6T4aY4IRUS30wcFwZBrNNLKqiVX9O0Fa3LWpr0I8ZnaRvlrXXZ0J3lhhcNSFWce2FjMtY543TG6Rlv//yJaVAw==", - "hasInstallScript": true, - "dependencies": { - "@babel/cli": "^7.17.6", - "@babel/core": "^7.17.5", - "@babel/plugin-transform-runtime": "^7.17.0", - "@babel/preset-env": "^7.16.11", - "@babel/runtime-corejs3": "^7.17.2", - "esbuild": "^0.14.23", - "mkdirp": "^1.0.4", - "read-pkg-up": "^9.1.0" - }, - "engines": { - "node": ">= 12.2.0" - }, - "peerDependencies": { - "p-defer": ">= 4.0.0" - } - }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -23366,35 +23335,30 @@ } }, "node_modules/web-speech-cognitive-services": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/web-speech-cognitive-services/-/web-speech-cognitive-services-7.1.3.tgz", - "integrity": "sha512-/3BY9b8kMjT3GFz38WqtZDwVEVsgMEjBWa+AHqWjCO2C1voySngqcgQC66ItIDPpKjS1HsoH016fmu/L4fYxpA==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/web-speech-cognitive-services/-/web-speech-cognitive-services-8.0.0.tgz", + "integrity": "sha512-TMlcC3K/c3pcWv+UFXO3bsO71BU8xyu7dwNaYoAAnVK3iyaKSXNE/vUxZrO7v3t73N84AvgNofbbU6kA/nkHng==", "license": "MIT", "dependencies": { - "@babel/runtime": "7.19.0", - "base64-arraybuffer": "1.0.2", - "event-as-promise": "1.0.5", - "event-target-shim": "6.0.2", - "memoize-one": "6.0.0", - "on-error-resume-next": "1.1.0", - "p-defer": "4.0.0", - "p-defer-es5": "2.0.1", - "simple-update-in": "2.2.0" + "base64-arraybuffer": "^1.0.2", + "event-as-promise": "^2.0.0", + "event-target-shim": "^6.0.2", + "memoize-one": "^6.0.0", + "on-error-resume-next": "^2.0.1", + "simple-update-in": "^2.2.0", + "web-speech-cognitive-services": "^8.0.0" }, "peerDependencies": { "microsoft-cognitiveservices-speech-sdk": "^1.17.0" } }, - "node_modules/web-speech-cognitive-services/node_modules/@babel/runtime": { - "version": "7.19.0", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.19.0.tgz", - "integrity": "sha512-eR8Lo9hnDS7tqkO7NsV+mKvCmv5boaXFSZ70DnfhcgiEne8hv9oCEd36Klw74EtizEqLsy4YnW8UWwpBVolHZA==", + "node_modules/web-speech-cognitive-services/node_modules/event-as-promise": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/event-as-promise/-/event-as-promise-2.0.0.tgz", + "integrity": "sha512-veBES20Er4NLmbcpvTJxmdSeQt1YP+NmK/6CKlx2kkkitCZ0gRYi/Q6iwx5iwBBeHdGcD4W4uHxitv6oPB2X3A==", "license": "MIT", "dependencies": { - "regenerator-runtime": "^0.13.4" - }, - "engines": { - "node": ">=6.9.0" + "event-as-promise": "^2.0.0" } }, "node_modules/web-speech-cognitive-services/node_modules/event-target-shim": { @@ -23409,24 +23373,6 @@ "url": "https://github.com/sponsors/mysticatea" } }, - "node_modules/web-speech-cognitive-services/node_modules/p-defer": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-4.0.0.tgz", - "integrity": "sha512-Vb3QRvQ0Y5XnF40ZUWW7JfLogicVh/EnA5gBIvKDJoYpeI82+1E3AlB9yOcKFS0AhHrWVnAQO39fbR0G99IVEQ==", - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/web-speech-cognitive-services/node_modules/regenerator-runtime": { - "version": "0.13.11", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", - "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", - "license": "MIT" - }, "node_modules/webidl-conversions": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", @@ -24338,7 +24284,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": { @@ -24660,7 +24606,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" }, "devDependencies": { "@babel/cli": "^7.18.10", diff --git a/packages/bundle/package.json b/packages/bundle/package.json index 5ec5f367b0..5f85de5abc 100644 --- a/packages/bundle/package.json +++ b/packages/bundle/package.json @@ -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": { diff --git a/packages/bundle/src/createCognitiveServicesSpeechServicesPonyfillFactory.spec.js b/packages/bundle/src/createCognitiveServicesSpeechServicesPonyfillFactory.spec.js index 8f170207a1..7e9fc4819b 100644 --- a/packages/bundle/src/createCognitiveServicesSpeechServicesPonyfillFactory.spec.js +++ b/packages/bundle/src/createCognitiveServicesSpeechServicesPonyfillFactory.spec.js @@ -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 { @@ -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; @@ -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']); }); @@ -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([]); }); @@ -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( @@ -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', () => { @@ -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); }); diff --git a/packages/bundle/src/createCognitiveServicesSpeechServicesPonyfillFactory.ts b/packages/bundle/src/createCognitiveServicesSpeechServicesPonyfillFactory.ts index ff72c4441c..5f29646e33 100644 --- a/packages/bundle/src/createCognitiveServicesSpeechServicesPonyfillFactory.ts +++ b/packages/bundle/src/createCognitiveServicesSpeechServicesPonyfillFactory.ts @@ -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, @@ -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(), diff --git a/packages/directlinespeech/package.json b/packages/directlinespeech/package.json index 5c5dc74eb3..18653f2024 100644 --- a/packages/directlinespeech/package.json +++ b/packages/directlinespeech/package.json @@ -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" diff --git a/packages/directlinespeech/src/createWebSpeechPonyfillFactory.js b/packages/directlinespeech/src/createWebSpeechPonyfillFactory.js index 5408dbfb1f..345660f33b 100644 --- a/packages/directlinespeech/src/createWebSpeechPonyfillFactory.js +++ b/packages/directlinespeech/src/createWebSpeechPonyfillFactory.js @@ -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';