botframework-webchat 4.13.0 → 4.15.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/.eslintrc.yml +5 -104
- package/.prettierrc.yml +1 -1
- package/README.md +33 -36
- package/babel.config.json +2 -2
- package/babel.sanitize-html.config.json +10 -0
- package/lib/AddFullBundle.d.ts +30 -0
- package/lib/AddFullBundle.d.ts.map +1 -0
- package/lib/AddFullBundle.js +76 -0
- package/lib/FullComposer.d.ts +8 -0
- package/lib/FullComposer.d.ts.map +1 -0
- package/lib/FullComposer.js +6 -16
- package/lib/FullReactWebChat.d.ts +8 -0
- package/lib/FullReactWebChat.d.ts.map +1 -0
- package/lib/FullReactWebChat.js +8 -23
- package/lib/adaptiveCards/AdaptiveCardsComposer.d.ts +10 -0
- package/lib/adaptiveCards/AdaptiveCardsComposer.d.ts.map +1 -0
- package/lib/adaptiveCards/AdaptiveCardsComposer.js +6 -2
- package/lib/adaptiveCards/AdaptiveCardsContext.d.ts +8 -0
- package/lib/adaptiveCards/AdaptiveCardsContext.d.ts.map +1 -0
- package/lib/adaptiveCards/AdaptiveCardsContext.js +3 -3
- package/lib/adaptiveCards/AdaptiveCardsStyleOptions.d.ts +5 -3
- package/lib/adaptiveCards/AdaptiveCardsStyleOptions.d.ts.map +1 -1
- package/lib/adaptiveCards/AdaptiveCardsStyleSet.d.ts +7 -0
- package/lib/adaptiveCards/AdaptiveCardsStyleSet.d.ts.map +1 -0
- package/lib/{FullBundleStyleOptions.js → adaptiveCards/AdaptiveCardsStyleSet.js} +0 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardAttachment.d.ts +9 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardAttachment.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardAttachment.js +1 -1
- package/lib/adaptiveCards/Attachment/AdaptiveCardBuilder.d.ts +28 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardBuilder.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardBuilder.js +13 -6
- package/lib/adaptiveCards/Attachment/AdaptiveCardContent.d.ts +9 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardContent.js +8 -4
- package/lib/adaptiveCards/Attachment/AdaptiveCardRenderer.d.ts +12 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardRenderer.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardRenderer.js +310 -85
- package/lib/adaptiveCards/Attachment/AnimationCardContent.d.ts +10 -0
- package/lib/adaptiveCards/Attachment/AnimationCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/AnimationCardContent.js +1 -1
- package/lib/adaptiveCards/Attachment/AudioCardContent.d.ts +10 -0
- package/lib/adaptiveCards/Attachment/AudioCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/AudioCardContent.js +1 -1
- package/lib/adaptiveCards/Attachment/CommonCard.js +11 -6
- package/lib/adaptiveCards/Attachment/HeroCardContent.d.ts +10 -0
- package/lib/adaptiveCards/Attachment/HeroCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/HeroCardContent.js +11 -6
- package/lib/adaptiveCards/Attachment/OAuthCardContent.d.ts +10 -0
- package/lib/adaptiveCards/Attachment/OAuthCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/OAuthCardContent.js +11 -6
- package/lib/adaptiveCards/Attachment/ReceiptCardContent.d.ts +10 -0
- package/lib/adaptiveCards/Attachment/ReceiptCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/ReceiptCardContent.js +11 -6
- package/lib/adaptiveCards/Attachment/SignInCardContent.d.ts +10 -0
- package/lib/adaptiveCards/Attachment/SignInCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/SignInCardContent.js +1 -1
- package/lib/adaptiveCards/Attachment/ThumbnailCardContent.d.ts +10 -0
- package/lib/adaptiveCards/Attachment/ThumbnailCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/ThumbnailCardContent.js +11 -6
- package/lib/adaptiveCards/Attachment/VideoCardContent.d.ts +20 -0
- package/lib/adaptiveCards/Attachment/VideoCardContent.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/VideoCardContent.js +7 -5
- package/lib/adaptiveCards/AttachmentForScreenReader/AdaptiveCardAttachment.js +7 -3
- package/lib/adaptiveCards/AttachmentForScreenReader/RichCardAttachment.js +1 -1
- package/lib/adaptiveCards/Styles/StyleSet/AdaptiveCardRenderer.d.ts +59 -0
- package/lib/adaptiveCards/Styles/StyleSet/AdaptiveCardRenderer.d.ts.map +1 -0
- package/lib/adaptiveCards/Styles/StyleSet/AdaptiveCardRenderer.js +8 -1
- package/lib/adaptiveCards/Styles/adaptiveCardHostConfig.d.ts +126 -0
- package/lib/adaptiveCards/Styles/adaptiveCardHostConfig.d.ts.map +1 -0
- package/lib/adaptiveCards/Styles/adaptiveCardHostConfig.js +29 -9
- package/lib/adaptiveCards/Styles/createAdaptiveCardsStyleSet.d.ts +5 -0
- package/lib/adaptiveCards/Styles/createAdaptiveCardsStyleSet.d.ts.map +1 -0
- package/lib/adaptiveCards/Styles/createAdaptiveCardsStyleSet.js +2 -2
- package/lib/adaptiveCards/createAdaptiveCardsAttachmentForScreenReaderMiddleware.d.ts +3 -0
- package/lib/adaptiveCards/createAdaptiveCardsAttachmentForScreenReaderMiddleware.d.ts.map +1 -0
- package/lib/adaptiveCards/createAdaptiveCardsAttachmentForScreenReaderMiddleware.js +5 -11
- package/lib/adaptiveCards/createAdaptiveCardsAttachmentMiddleware.d.ts +3 -0
- package/lib/adaptiveCards/createAdaptiveCardsAttachmentMiddleware.d.ts.map +1 -0
- package/lib/adaptiveCards/createAdaptiveCardsAttachmentMiddleware.js +2 -15
- package/lib/adaptiveCards/defaultStyleOptions.d.ts +4 -0
- package/lib/adaptiveCards/defaultStyleOptions.d.ts.map +1 -0
- package/lib/adaptiveCards/defaultStyleOptions.js +3 -2
- package/lib/adaptiveCards/hooks/internal/useAdaptiveCardsContext.d.ts +3 -0
- package/lib/adaptiveCards/hooks/internal/useAdaptiveCardsContext.d.ts.map +1 -0
- package/lib/adaptiveCards/hooks/internal/useAdaptiveCardsContext.js +1 -1
- package/lib/adaptiveCards/hooks/internal/useParseAdaptiveCardJSON.d.ts +2 -0
- package/lib/adaptiveCards/hooks/internal/useParseAdaptiveCardJSON.d.ts.map +1 -0
- package/lib/adaptiveCards/hooks/internal/useParseAdaptiveCardJSON.js +7 -5
- package/lib/adaptiveCards/hooks/internal/useUniqueId.js +1 -1
- package/lib/adaptiveCards/hooks/useAdaptiveCardsHostConfig.d.ts +2 -0
- package/lib/adaptiveCards/hooks/useAdaptiveCardsHostConfig.d.ts.map +1 -0
- package/lib/adaptiveCards/hooks/useAdaptiveCardsHostConfig.js +3 -5
- package/lib/adaptiveCards/hooks/useAdaptiveCardsPackage.d.ts +3 -0
- package/lib/adaptiveCards/hooks/useAdaptiveCardsPackage.d.ts.map +1 -0
- package/lib/adaptiveCards/hooks/useAdaptiveCardsPackage.js +1 -1
- package/lib/adaptiveCards/normalizeStyleOptions.d.ts +3 -0
- package/lib/adaptiveCards/normalizeStyleOptions.d.ts.map +1 -0
- package/lib/adaptiveCards/normalizeStyleOptions.js +1 -1
- package/lib/addVersion.js +2 -2
- package/lib/createBrowserWebSpeechPonyfillFactory.d.ts +3 -0
- package/lib/createBrowserWebSpeechPonyfillFactory.d.ts.map +1 -0
- package/lib/createBrowserWebSpeechPonyfillFactory.js +7 -4
- package/lib/createCognitiveServicesSpeechServicesPonyfillFactory.d.ts +17 -0
- package/lib/createCognitiveServicesSpeechServicesPonyfillFactory.d.ts.map +1 -0
- package/lib/createCognitiveServicesSpeechServicesPonyfillFactory.js +17 -11
- package/lib/createDirectLine.d.ts +17 -0
- package/lib/createDirectLine.d.ts.map +1 -0
- package/lib/createDirectLine.js +3 -2
- package/lib/createDirectLineAppServiceExtension.d.ts +7 -0
- package/lib/createDirectLineAppServiceExtension.d.ts.map +1 -0
- package/lib/createDirectLineAppServiceExtension.js +1 -1
- package/lib/createDirectLineSpeechAdapters.d.ts +25 -0
- package/lib/createDirectLineSpeechAdapters.d.ts.map +1 -0
- package/lib/createDirectLineSpeechAdapters.js +57 -3
- package/lib/createFullStyleSet.d.ts +1375 -0
- package/lib/createFullStyleSet.d.ts.map +1 -0
- package/lib/createFullStyleSet.js +2 -2
- package/lib/fullBundleDefaultStyleOptions.js +4 -4
- package/lib/hooks/useStyleOptions.d.ts +3 -0
- package/lib/hooks/useStyleOptions.d.ts.map +1 -0
- package/lib/hooks/useStyleOptions.js +21 -0
- package/lib/index-es5.d.ts +4 -20
- package/lib/index-es5.d.ts.map +1 -1
- package/lib/index-es5.js +3 -43
- package/lib/index-minimal.d.ts +9 -6
- package/lib/index-minimal.d.ts.map +1 -1
- package/lib/index-minimal.js +27 -21
- package/lib/index.d.ts +164 -18
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +19 -12
- package/lib/polyfill.d.ts +23 -0
- package/lib/polyfill.d.ts.map +1 -0
- package/lib/polyfill.js +46 -0
- package/lib/renderMarkdown.d.ts +6 -0
- package/lib/renderMarkdown.d.ts.map +1 -0
- package/lib/renderMarkdown.js +36 -5
- package/lib/renderWebChat.d.ts +3 -0
- package/lib/renderWebChat.d.ts.map +1 -0
- package/lib/renderWebChat.js +1 -1
- package/lib/speech/CustomAudioInputStream.d.ts +94 -0
- package/lib/speech/CustomAudioInputStream.d.ts.map +1 -0
- package/lib/speech/CustomAudioInputStream.js +441 -0
- package/lib/speech/bytesPerSample.d.ts +2 -0
- package/lib/speech/bytesPerSample.d.ts.map +1 -0
- package/lib/speech/bytesPerSample.js +12 -0
- package/lib/speech/createAudioConfig.d.ts +23 -0
- package/lib/speech/createAudioConfig.d.ts.map +1 -0
- package/lib/speech/createAudioConfig.js +90 -0
- package/lib/speech/createAudioContext.d.ts +3 -0
- package/lib/speech/createAudioContext.d.ts.map +1 -0
- package/lib/speech/createAudioContext.js +22 -0
- package/lib/speech/createMicrophoneAudioConfigAndAudioContext.d.ts +9 -0
- package/lib/speech/createMicrophoneAudioConfigAndAudioContext.d.ts.map +1 -0
- package/lib/speech/createMicrophoneAudioConfigAndAudioContext.js +161 -0
- package/lib/speech/getUserMedia.d.ts +2 -0
- package/lib/speech/getUserMedia.d.ts.map +1 -0
- package/lib/speech/getUserMedia.js +25 -0
- package/lib/types/AdaptiveCardsPackage.d.ts +13 -0
- package/lib/types/AdaptiveCardsPackage.d.ts.map +1 -0
- package/lib/types/AdaptiveCardsPackage.js +2 -0
- package/lib/types/CognitiveServicesAudioOutputFormat.d.ts +3 -0
- package/lib/types/CognitiveServicesAudioOutputFormat.d.ts.map +1 -0
- package/lib/types/CognitiveServicesAudioOutputFormat.js +2 -0
- package/lib/types/CognitiveServicesCredentials.d.ts +18 -0
- package/lib/types/CognitiveServicesCredentials.d.ts.map +1 -0
- package/lib/types/CognitiveServicesCredentials.js +2 -0
- package/lib/types/CognitiveServicesTextNormalization.d.ts +3 -0
- package/lib/types/CognitiveServicesTextNormalization.d.ts.map +1 -0
- package/lib/types/CognitiveServicesTextNormalization.js +2 -0
- package/lib/{FullBundleStyleOptions.d.ts → types/FullBundleStyleOptions.d.ts} +1 -1
- package/lib/types/FullBundleStyleOptions.d.ts.map +1 -0
- package/lib/types/FullBundleStyleOptions.js +2 -0
- package/lib/useComposerProps.d.ts +22 -0
- package/lib/useComposerProps.d.ts.map +1 -0
- package/lib/useComposerProps.js +6 -8
- package/package.json +46 -48
- package/src/AddFullBundle.tsx +93 -0
- package/src/FullComposer.tsx +38 -0
- package/src/FullReactWebChat.tsx +32 -0
- package/src/__tests__/createDirectLine.spec.js +2 -0
- package/src/__tests__/renderMarkdown.spec.js +1 -1
- package/src/__tests__/versionTag.es5.spec.js +3 -0
- package/src/__tests__/versionTag.full.spec.js +3 -0
- package/src/__tests__/versionTag.minimal.spec.js +3 -0
- package/src/adaptiveCards/{AdaptiveCardsComposer.js → AdaptiveCardsComposer.tsx} +17 -5
- package/src/adaptiveCards/AdaptiveCardsContext.ts +12 -0
- package/src/adaptiveCards/AdaptiveCardsStyleOptions.ts +5 -3
- package/src/adaptiveCards/AdaptiveCardsStyleSet.ts +7 -0
- package/src/adaptiveCards/Attachment/{AdaptiveCardAttachment.js → AdaptiveCardAttachment.tsx} +8 -2
- package/src/adaptiveCards/Attachment/AdaptiveCardBuilder.ts +27 -17
- package/src/adaptiveCards/Attachment/{AdaptiveCardContent.js → AdaptiveCardContent.tsx} +8 -2
- package/src/adaptiveCards/Attachment/AdaptiveCardRenderer.tsx +768 -0
- package/src/adaptiveCards/Attachment/{AnimationCardContent.js → AnimationCardContent.tsx} +9 -2
- package/src/adaptiveCards/Attachment/{AudioCardContent.js → AudioCardContent.tsx} +9 -2
- package/src/adaptiveCards/Attachment/CommonCard.js +2 -1
- package/src/adaptiveCards/Attachment/{HeroCardContent.js → HeroCardContent.tsx} +12 -3
- package/src/adaptiveCards/Attachment/{OAuthCardContent.js → OAuthCardContent.tsx} +11 -3
- package/src/adaptiveCards/Attachment/{ReceiptCardContent.js → ReceiptCardContent.tsx} +58 -28
- package/src/adaptiveCards/Attachment/{SignInCardContent.js → SignInCardContent.tsx} +9 -2
- package/src/adaptiveCards/Attachment/{ThumbnailCardContent.js → ThumbnailCardContent.tsx} +12 -3
- package/src/adaptiveCards/Attachment/{VideoCardContent.js → VideoCardContent.tsx} +15 -3
- package/src/adaptiveCards/Styles/StyleSet/AdaptiveCardRenderer.ts +9 -1
- package/src/adaptiveCards/Styles/adaptiveCardHostConfig.ts +28 -8
- package/src/adaptiveCards/Styles/createAdaptiveCardsStyleSet.spec.js +2 -0
- package/src/adaptiveCards/Styles/createAdaptiveCardsStyleSet.ts +7 -4
- package/src/adaptiveCards/{createAdaptiveCardsAttachmentForScreenReaderMiddleware.js → createAdaptiveCardsAttachmentForScreenReaderMiddleware.tsx} +16 -15
- package/src/adaptiveCards/createAdaptiveCardsAttachmentMiddleware.tsx +44 -0
- package/src/adaptiveCards/defaultStyleOptions.ts +2 -1
- package/src/adaptiveCards/hooks/internal/{useAdaptiveCardsContext.js → useAdaptiveCardsContext.ts} +1 -1
- package/src/adaptiveCards/hooks/internal/{useParseAdaptiveCardJSON.js → useParseAdaptiveCardJSON.ts} +5 -2
- package/src/adaptiveCards/hooks/internal/{useUniqueId.js → useUniqueId.ts} +1 -1
- package/src/adaptiveCards/hooks/{useAdaptiveCardsHostConfig.js → useAdaptiveCardsHostConfig.ts} +6 -8
- package/src/adaptiveCards/hooks/{useAdaptiveCardsPackage.js → useAdaptiveCardsPackage.ts} +2 -1
- package/src/createBrowserWebSpeechPonyfillFactory.ts +21 -0
- package/src/createCognitiveServicesSpeechServicesPonyfillFactory.spec.js +36 -6
- package/src/createCognitiveServicesSpeechServicesPonyfillFactory.ts +78 -0
- package/src/createDirectLine.ts +65 -0
- package/src/createDirectLineAppServiceExtension.ts +22 -0
- package/src/createDirectLineSpeechAdapters.ts +84 -0
- package/src/createFullStyleSet.ts +2 -2
- package/src/fullBundleDefaultStyleOptions.ts +3 -3
- package/src/hooks/useStyleOptions.ts +9 -0
- package/src/index-es5.ts +3 -28
- package/src/index-minimal.ts +3 -2
- package/src/index.ts +22 -10
- package/src/polyfill.ts +29 -0
- package/src/renderMarkdown.ts +140 -0
- package/src/renderWebChat.tsx +6 -0
- package/src/speech/CustomAudioInputStream.ts +356 -0
- package/src/speech/bytesPerSample.ts +4 -0
- package/src/speech/createAudioConfig.spec.js +23 -0
- package/src/speech/createAudioConfig.ts +77 -0
- package/src/speech/createAudioContext.ts +16 -0
- package/src/speech/createMicrophoneAudioConfigAndAudioContext.ts +146 -0
- package/src/speech/getUserMedia.ts +14 -0
- package/src/tsconfig.json +1 -1
- package/src/types/AdaptiveCardsPackage.ts +23 -0
- package/src/types/CognitiveServicesAudioOutputFormat.ts +28 -0
- package/src/types/CognitiveServicesCredentials.ts +28 -0
- package/src/types/CognitiveServicesTextNormalization.ts +3 -0
- package/src/{FullBundleStyleOptions.ts → types/FullBundleStyleOptions.ts} +1 -1
- package/src/{useComposerProps.js → useComposerProps.ts} +21 -11
- package/webpack.config.js +46 -6
- package/.eslintignore +0 -9
- package/lib/FullBundleStyleOptions.d.ts.map +0 -1
- package/src/FullComposer.js +0 -40
- package/src/FullReactWebChat.js +0 -47
- package/src/adaptiveCards/AdaptiveCardsContext.js +0 -5
- package/src/adaptiveCards/Attachment/AdaptiveCardRenderer.js +0 -492
- package/src/adaptiveCards/createAdaptiveCardsAttachmentMiddleware.js +0 -41
- package/src/createBrowserWebSpeechPonyfillFactory.js +0 -16
- package/src/createCognitiveServicesSpeechServicesPonyfillFactory.js +0 -58
- package/src/createDirectLine.js +0 -38
- package/src/createDirectLineAppServiceExtension.js +0 -12
- package/src/createDirectLineSpeechAdapters.js +0 -5
- package/src/index-es5.tsx +0 -49
- package/src/index-minimal.tsx +0 -9
- package/src/index.tsx +0 -45
- package/src/renderMarkdown.js +0 -97
- package/src/renderWebChat.js +0 -6
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { ChunkedArrayBufferStream } from 'microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/Exports';
|
|
2
|
+
import { PcmRecorder } from 'microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/Exports';
|
|
3
|
+
|
|
4
|
+
import { AudioStreamNode, DeviceInfo, Format } from './CustomAudioInputStream';
|
|
5
|
+
import bytesPerSample from './bytesPerSample';
|
|
6
|
+
import createAudioConfig from './createAudioConfig';
|
|
7
|
+
import createAudioContext from './createAudioContext';
|
|
8
|
+
import getUserMedia from './getUserMedia';
|
|
9
|
+
|
|
10
|
+
// This is how often we are flushing audio buffer to the network. Modify this value will affect latency.
|
|
11
|
+
const DEFAULT_BUFFER_DURATION_IN_MS = 100;
|
|
12
|
+
|
|
13
|
+
// TODO: [P2] #3975 We should consider building our own PcmRecorder:
|
|
14
|
+
// - Use Audio Worklet via blob URL
|
|
15
|
+
// - Not hardcoding the sample rate or other values
|
|
16
|
+
// PcmRecorder always downscale to 16000 Hz. We cannot use the dynamic value from MediaConstraints or MediaTrackSettings.
|
|
17
|
+
const PCM_RECORDER_HARDCODED_SETTINGS: MediaTrackSettings = Object.freeze({
|
|
18
|
+
channelCount: 1,
|
|
19
|
+
sampleRate: 16000,
|
|
20
|
+
sampleSize: 16
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const PCM_RECORDER_HARDCODED_FORMAT: Format = Object.freeze({
|
|
24
|
+
bitsPerSample: PCM_RECORDER_HARDCODED_SETTINGS.sampleSize,
|
|
25
|
+
channels: PCM_RECORDER_HARDCODED_SETTINGS.channelCount,
|
|
26
|
+
samplesPerSec: PCM_RECORDER_HARDCODED_SETTINGS.sampleRate
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
type MicrophoneAudioInputStreamOptions = {
|
|
30
|
+
/** Specifies the constraints for selecting an audio device. */
|
|
31
|
+
audioConstraints?: true | MediaTrackConstraints;
|
|
32
|
+
|
|
33
|
+
/** Specifies the `AudioContext` to use. This object must be primed and ready to use. */
|
|
34
|
+
audioContext: AudioContext;
|
|
35
|
+
|
|
36
|
+
/** Specifies the buffering delay on how often to flush audio data to network. Increasing the value will increase audio latency. Default is 100 ms. */
|
|
37
|
+
bufferDurationInMS?: number;
|
|
38
|
+
|
|
39
|
+
/** Specifies whether to display diagnostic information. */
|
|
40
|
+
debug?: true;
|
|
41
|
+
|
|
42
|
+
/** Specifies if telemetry data should be sent. If not specified, telemetry data will NOT be sent. */
|
|
43
|
+
enableTelemetry?: true;
|
|
44
|
+
|
|
45
|
+
/** Specifies the `AudioWorklet` URL for `PcmRecorder`. If not specified, will use script processor on UI thread instead. */
|
|
46
|
+
pcmRecorderWorkletUrl?: string;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
function createMicrophoneAudioConfig(options: MicrophoneAudioInputStreamOptions) {
|
|
50
|
+
const { audioConstraints, audioContext, debug, enableTelemetry, pcmRecorderWorkletUrl } = options;
|
|
51
|
+
const bufferDurationInMS = options.bufferDurationInMS || DEFAULT_BUFFER_DURATION_IN_MS;
|
|
52
|
+
|
|
53
|
+
const pcmRecorder = new PcmRecorder();
|
|
54
|
+
|
|
55
|
+
pcmRecorderWorkletUrl && pcmRecorder.setWorkletUrl(pcmRecorderWorkletUrl);
|
|
56
|
+
|
|
57
|
+
return createAudioConfig({
|
|
58
|
+
async attach(audioNodeId: string): Promise<{
|
|
59
|
+
audioStreamNode: AudioStreamNode;
|
|
60
|
+
deviceInfo: DeviceInfo;
|
|
61
|
+
format: Format;
|
|
62
|
+
}> {
|
|
63
|
+
// We need to get new MediaStream on every attach().
|
|
64
|
+
// This is because PcmRecorder.releaseMediaResources() disconnected/stopped them.
|
|
65
|
+
const mediaStream = await getUserMedia({ audio: audioConstraints, video: false });
|
|
66
|
+
|
|
67
|
+
const [firstAudioTrack] = mediaStream.getAudioTracks();
|
|
68
|
+
|
|
69
|
+
if (!firstAudioTrack) {
|
|
70
|
+
throw new Error('No audio device is found.');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const outputStream = new ChunkedArrayBufferStream(
|
|
74
|
+
// Speech SDK quirks: PcmRecorder hardcoded sample rate of 16000 Hz.
|
|
75
|
+
bytesPerSample(PCM_RECORDER_HARDCODED_SETTINGS) *
|
|
76
|
+
// eslint-disable-next-line no-magic-numbers
|
|
77
|
+
((bufferDurationInMS || DEFAULT_BUFFER_DURATION_IN_MS) / 1000),
|
|
78
|
+
audioNodeId
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
pcmRecorder.record(audioContext, mediaStream, outputStream);
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
audioStreamNode: {
|
|
85
|
+
// Speech SDK quirks: In SDK's original MicAudioSource implementation, it call turnOff() during detach().
|
|
86
|
+
// That means, it call turnOff(), then detach(), then turnOff() again. Seems redundant.
|
|
87
|
+
// When using with Direct Line Speech, turnOff() is never called.
|
|
88
|
+
detach: (): Promise<void> => {
|
|
89
|
+
// Speech SDK quirks: In SDK, it call outputStream.close() in turnOff() before outputStream.readEnded() in detach().
|
|
90
|
+
// I think it make sense to call readEnded() before close().
|
|
91
|
+
outputStream.readEnded();
|
|
92
|
+
outputStream.close();
|
|
93
|
+
|
|
94
|
+
// PcmRecorder.releaseMediaResources() will disconnect/stop the MediaStream.
|
|
95
|
+
// We cannot use MediaStream again after turned off.
|
|
96
|
+
pcmRecorder.releaseMediaResources(audioContext);
|
|
97
|
+
|
|
98
|
+
// MediaStream will become inactive after all tracks are removed.
|
|
99
|
+
mediaStream.getTracks().forEach(track => mediaStream.removeTrack(track));
|
|
100
|
+
|
|
101
|
+
// ESLint: "return" is required by TypeScript
|
|
102
|
+
// eslint-disable-next-line no-useless-return
|
|
103
|
+
return;
|
|
104
|
+
},
|
|
105
|
+
id: () => audioNodeId,
|
|
106
|
+
read: () => outputStream.read()
|
|
107
|
+
},
|
|
108
|
+
deviceInfo: {
|
|
109
|
+
manufacturer: 'Bot Framework Web Chat',
|
|
110
|
+
model: enableTelemetry ? firstAudioTrack.label : '',
|
|
111
|
+
type: enableTelemetry ? 'Microphones' : 'Unknown'
|
|
112
|
+
},
|
|
113
|
+
// Speech SDK quirks: PcmRecorder hardcoded sample rate of 16000 Hz.
|
|
114
|
+
// We cannot obtain this number other than looking at their source code.
|
|
115
|
+
// I.e. no getter property.
|
|
116
|
+
// PcmRecorder always downscale to 16000 Hz. We cannot use the dynamic value from MediaConstraints or MediaTrackSettings.
|
|
117
|
+
format: PCM_RECORDER_HARDCODED_FORMAT
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
debug
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export default function createMicrophoneAudioConfigAndAudioContext({
|
|
125
|
+
audioContext,
|
|
126
|
+
audioInputDeviceId,
|
|
127
|
+
enableTelemetry
|
|
128
|
+
}: {
|
|
129
|
+
audioContext?: AudioContext;
|
|
130
|
+
audioInputDeviceId?: string;
|
|
131
|
+
enableTelemetry?: true;
|
|
132
|
+
}) {
|
|
133
|
+
// Web Chat has an implementation of AudioConfig for microphone that would enable better support on Safari:
|
|
134
|
+
// - Maintain same instance of `AudioContext` across recognitions;
|
|
135
|
+
// - Resume suspended `AudioContext` on user gestures.
|
|
136
|
+
audioContext || (audioContext = createAudioContext());
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
audioConfig: createMicrophoneAudioConfig({
|
|
140
|
+
audioConstraints: audioInputDeviceId ? { deviceId: audioInputDeviceId } : true,
|
|
141
|
+
audioContext,
|
|
142
|
+
enableTelemetry: enableTelemetry ? true : undefined
|
|
143
|
+
}),
|
|
144
|
+
audioContext
|
|
145
|
+
};
|
|
146
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default function getUserMedia(constraints: MediaStreamConstraints): Promise<MediaStream> {
|
|
2
|
+
const { navigator } = window;
|
|
3
|
+
|
|
4
|
+
if (typeof navigator.mediaDevices !== 'undefined') {
|
|
5
|
+
return navigator.mediaDevices.getUserMedia(constraints);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// Although getUserMedia has vendor prefix, they are only used in very old version of browsers.
|
|
9
|
+
if (typeof navigator.getUserMedia !== 'undefined') {
|
|
10
|
+
return new Promise((resolve, reject) => navigator.getUserMedia(constraints, resolve, reject));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
throw new Error('This browser does not support Web Audio API.');
|
|
14
|
+
}
|
package/src/tsconfig.json
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AdaptiveCard,
|
|
3
|
+
GlobalSettings,
|
|
4
|
+
HorizontalAlignment,
|
|
5
|
+
HostConfig,
|
|
6
|
+
TextSize,
|
|
7
|
+
TextWeight,
|
|
8
|
+
SerializationContext,
|
|
9
|
+
Version
|
|
10
|
+
} from 'adaptivecards';
|
|
11
|
+
|
|
12
|
+
type AdaptiveCardsPackage = {
|
|
13
|
+
AdaptiveCard: typeof AdaptiveCard;
|
|
14
|
+
GlobalSettings: typeof GlobalSettings;
|
|
15
|
+
HorizontalAlignment: typeof HorizontalAlignment;
|
|
16
|
+
HostConfig: typeof HostConfig;
|
|
17
|
+
TextSize: typeof TextSize;
|
|
18
|
+
TextWeight: typeof TextWeight;
|
|
19
|
+
SerializationContext: typeof SerializationContext;
|
|
20
|
+
Version: typeof Version;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default AdaptiveCardsPackage;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type CognitiveServicesAudioOutputFormat =
|
|
2
|
+
| 'audio-16khz-128kbitrate-mono-mp3'
|
|
3
|
+
| 'audio-16khz-32kbitrate-mono-mp3'
|
|
4
|
+
| 'audio-16khz-64kbitrate-mono-mp3'
|
|
5
|
+
| 'audio-24khz-160kbitrate-mono-mp3'
|
|
6
|
+
| 'audio-24khz-48kbitrate-mono-mp3'
|
|
7
|
+
| 'audio-24khz-96kbitrate-mono-mp3'
|
|
8
|
+
| 'audio-48khz-192kbitrate-mono-mp3'
|
|
9
|
+
| 'audio-48khz-96kbitrate-mono-mp3'
|
|
10
|
+
| 'ogg-16khz-16bit-mono-opus'
|
|
11
|
+
| 'ogg-24khz-16bit-mono-opus'
|
|
12
|
+
| 'ogg-48khz-16bit-mono-opus'
|
|
13
|
+
| 'raw-16khz-16bit-mono-pcm'
|
|
14
|
+
| 'raw-16khz-16bit-mono-truesilk'
|
|
15
|
+
| 'raw-24khz-16bit-mono-pcm'
|
|
16
|
+
| 'raw-24khz-16bit-mono-truesilk'
|
|
17
|
+
| 'raw-48khz-16bit-mono-pcm'
|
|
18
|
+
| 'raw-8khz-8bit-mono-alaw'
|
|
19
|
+
| 'raw-8khz-8bit-mono-mulaw'
|
|
20
|
+
| 'riff-16khz-16bit-mono-pcm'
|
|
21
|
+
| 'riff-24khz-16bit-mono-pcm'
|
|
22
|
+
| 'riff-48khz-16bit-mono-pcm'
|
|
23
|
+
| 'riff-8khz-8bit-mono-alaw'
|
|
24
|
+
| 'riff-8khz-8bit-mono-mulaw'
|
|
25
|
+
| 'webm-16khz-16bit-mono-opus'
|
|
26
|
+
| 'webm-24khz-16bit-mono-opus';
|
|
27
|
+
|
|
28
|
+
export default CognitiveServicesAudioOutputFormat;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type CognitiveServicesAuthorizationToken = {
|
|
2
|
+
authorizationToken: string;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
type CognitiveServicesSubscriptionKey = {
|
|
6
|
+
subscriptionKey: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type CognitiveServicesRegion = {
|
|
10
|
+
region: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type CognitiveServicesSovereignCloud = {
|
|
14
|
+
customVoiceHostname: string;
|
|
15
|
+
speechRecognitionHostname: string;
|
|
16
|
+
speechSynthesisHostname: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type CognitiveServicesBaseCredentials = (CognitiveServicesAuthorizationToken | CognitiveServicesSubscriptionKey) &
|
|
20
|
+
(CognitiveServicesRegion | CognitiveServicesSovereignCloud);
|
|
21
|
+
|
|
22
|
+
type CognitiveServicesCredentials =
|
|
23
|
+
| CognitiveServicesBaseCredentials
|
|
24
|
+
| Promise<CognitiveServicesBaseCredentials>
|
|
25
|
+
| (() => CognitiveServicesBaseCredentials)
|
|
26
|
+
| (() => Promise<CognitiveServicesBaseCredentials>);
|
|
27
|
+
|
|
28
|
+
export default CognitiveServicesCredentials;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StrictStyleOptions, StyleOptions } from 'botframework-webchat-api';
|
|
2
2
|
|
|
3
|
-
import AdaptiveCardStyleOptions, { StrictAdaptiveCardsStyleOptions } from '
|
|
3
|
+
import AdaptiveCardStyleOptions, { StrictAdaptiveCardsStyleOptions } from '../adaptiveCards/AdaptiveCardsStyleOptions';
|
|
4
4
|
|
|
5
5
|
type FullBundleStyleOptions = StyleOptions & AdaptiveCardStyleOptions;
|
|
6
6
|
type StrictFullBundleStyleOptions = StrictStyleOptions & StrictAdaptiveCardsStyleOptions;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AttachmentForScreenReaderMiddleware, AttachmentMiddleware } from 'botframework-webchat-api';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
|
|
4
4
|
import createAdaptiveCardsAttachmentForScreenReaderMiddleware from './adaptiveCards/createAdaptiveCardsAttachmentForScreenReaderMiddleware';
|
|
@@ -12,32 +12,42 @@ export default function useComposerProps({
|
|
|
12
12
|
renderMarkdown,
|
|
13
13
|
styleOptions,
|
|
14
14
|
styleSet
|
|
15
|
-
}
|
|
15
|
+
}: {
|
|
16
|
+
attachmentForScreenReaderMiddleware: AttachmentForScreenReaderMiddleware[];
|
|
17
|
+
attachmentMiddleware: AttachmentMiddleware[];
|
|
18
|
+
renderMarkdown?: (markdown: string, { markdownRespectCRLF: boolean }, { externalLinkAlt: string }) => string;
|
|
19
|
+
styleOptions: any;
|
|
20
|
+
styleSet: any;
|
|
21
|
+
}): {
|
|
22
|
+
attachmentForScreenReaderMiddleware: AttachmentForScreenReaderMiddleware[];
|
|
23
|
+
attachmentMiddleware: AttachmentMiddleware[];
|
|
24
|
+
renderMarkdown: (markdown: string, { markdownRespectCRLF: boolean }, { externalLinkAlt: string }) => string;
|
|
25
|
+
extraStyleSet: any;
|
|
26
|
+
} {
|
|
16
27
|
const patchedAttachmentMiddleware = useMemo(
|
|
17
|
-
() =>
|
|
28
|
+
() => [...attachmentMiddleware, createAdaptiveCardsAttachmentMiddleware()],
|
|
18
29
|
[attachmentMiddleware]
|
|
19
30
|
);
|
|
20
31
|
|
|
21
32
|
const patchedAttachmentForScreenReaderMiddleware = useMemo(
|
|
22
|
-
() =>
|
|
23
|
-
concatMiddleware(attachmentForScreenReaderMiddleware, createAdaptiveCardsAttachmentForScreenReaderMiddleware()),
|
|
33
|
+
() => [...attachmentForScreenReaderMiddleware, createAdaptiveCardsAttachmentForScreenReaderMiddleware()],
|
|
24
34
|
[attachmentForScreenReaderMiddleware]
|
|
25
35
|
);
|
|
26
36
|
|
|
27
37
|
// When styleSet is not specified, the styleOptions will be used to create Adaptive Cards styleSet and merged into useStyleSet.
|
|
28
|
-
const extraStyleSet = useMemo(
|
|
29
|
-
styleOptions,
|
|
30
|
-
styleSet
|
|
31
|
-
|
|
38
|
+
const extraStyleSet = useMemo(
|
|
39
|
+
() => (styleSet ? undefined : createAdaptiveCardsStyleSet(styleOptions)),
|
|
40
|
+
[styleOptions, styleSet]
|
|
41
|
+
);
|
|
32
42
|
|
|
33
43
|
const patchedRenderMarkdown = useMemo(
|
|
34
|
-
() => (typeof renderMarkdown === 'undefined' ?
|
|
44
|
+
() => (typeof renderMarkdown === 'undefined' ? defaultRenderMarkdown : renderMarkdown),
|
|
35
45
|
[renderMarkdown]
|
|
36
46
|
);
|
|
37
47
|
|
|
38
48
|
return {
|
|
39
|
-
attachmentMiddleware: patchedAttachmentMiddleware,
|
|
40
49
|
attachmentForScreenReaderMiddleware: patchedAttachmentForScreenReaderMiddleware,
|
|
50
|
+
attachmentMiddleware: patchedAttachmentMiddleware,
|
|
41
51
|
extraStyleSet,
|
|
42
52
|
renderMarkdown: patchedRenderMarkdown
|
|
43
53
|
};
|
package/webpack.config.js
CHANGED
|
@@ -14,6 +14,27 @@ let config = {
|
|
|
14
14
|
'webchat-minimal': './lib/index-minimal.js'
|
|
15
15
|
},
|
|
16
16
|
mode: 'production',
|
|
17
|
+
module: {
|
|
18
|
+
rules: [
|
|
19
|
+
{
|
|
20
|
+
// To speed up bundling, we are limiting Babel to a number of packages which does not publish ES5 bits.
|
|
21
|
+
test: /\/node_modules\/(botframework-streaming|buffer|nanoid|postcss|punycode|sanitize-html)\//iu,
|
|
22
|
+
use: {
|
|
23
|
+
loader: 'babel-loader',
|
|
24
|
+
options: {
|
|
25
|
+
presets: [
|
|
26
|
+
[
|
|
27
|
+
'@babel/preset-env',
|
|
28
|
+
{
|
|
29
|
+
modules: 'commonjs'
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
},
|
|
17
38
|
optimization: {
|
|
18
39
|
minimizer: [
|
|
19
40
|
// Webpack use terser for minification
|
|
@@ -30,9 +51,7 @@ let config = {
|
|
|
30
51
|
]
|
|
31
52
|
},
|
|
32
53
|
output: {
|
|
33
|
-
|
|
34
|
-
libraryTarget: 'umd',
|
|
35
|
-
path: resolve(__dirname, 'dist')
|
|
54
|
+
libraryTarget: 'umd'
|
|
36
55
|
},
|
|
37
56
|
plugins: [
|
|
38
57
|
new StatsWriterPlugin({
|
|
@@ -42,14 +61,34 @@ let config = {
|
|
|
42
61
|
],
|
|
43
62
|
resolve: {
|
|
44
63
|
alias: {
|
|
45
|
-
|
|
64
|
+
// TODO: [P1] #3914 It is smaller to use /lib/ instead of /es2015/ with Webpack.
|
|
65
|
+
// Verifies if /es2015/ is better when moving to esbuild.
|
|
66
|
+
'microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/Exports': resolve(
|
|
67
|
+
__dirname,
|
|
68
|
+
'node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/Exports.js'
|
|
69
|
+
),
|
|
70
|
+
'microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/Exports': resolve(
|
|
71
|
+
__dirname,
|
|
72
|
+
'node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/Exports.js'
|
|
73
|
+
),
|
|
74
|
+
'microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/Exports': resolve(
|
|
75
|
+
__dirname,
|
|
76
|
+
'node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/Exports.js'
|
|
77
|
+
),
|
|
78
|
+
'microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Audio/AudioStreamFormat': resolve(
|
|
46
79
|
__dirname,
|
|
47
|
-
'node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Audio/
|
|
80
|
+
'node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Audio/AudioStreamFormat.js'
|
|
81
|
+
),
|
|
82
|
+
'microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Exports': resolve(
|
|
83
|
+
__dirname,
|
|
84
|
+
'node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Exports.js'
|
|
48
85
|
),
|
|
49
86
|
'microsoft-cognitiveservices-speech-sdk/distrib/lib/microsoft.cognitiveservices.speech.sdk': resolve(
|
|
50
87
|
__dirname,
|
|
51
88
|
'node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/microsoft.cognitiveservices.speech.sdk.js'
|
|
52
89
|
),
|
|
90
|
+
|
|
91
|
+
// This line must be placed after other specific imports.
|
|
53
92
|
'microsoft-cognitiveservices-speech-sdk': resolve(
|
|
54
93
|
__dirname,
|
|
55
94
|
'node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/microsoft.cognitiveservices.speech.sdk.js'
|
|
@@ -57,7 +96,8 @@ let config = {
|
|
|
57
96
|
react: resolve(__dirname, 'node_modules/isomorphic-react/dist/react.js'),
|
|
58
97
|
'react-dom': resolve(__dirname, 'node_modules/isomorphic-react-dom/dist/react-dom.js')
|
|
59
98
|
}
|
|
60
|
-
}
|
|
99
|
+
},
|
|
100
|
+
target: ['web', 'es5']
|
|
61
101
|
};
|
|
62
102
|
|
|
63
103
|
// VSTS always emits uppercase environment variables.
|
package/.eslintignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FullBundleStyleOptions.d.ts","sourceRoot":"","sources":["../src/FullBundleStyleOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE5E,OAAO,wBAAwB,EAAE,EAAE,+BAA+B,EAAE,MAAM,2CAA2C,CAAC;AAEtH,aAAK,sBAAsB,GAAG,YAAY,GAAG,wBAAwB,CAAC;AACtE,aAAK,4BAA4B,GAAG,kBAAkB,GAAG,+BAA+B,CAAC;AAEzF,eAAe,sBAAsB,CAAC;AACtC,OAAO,EAAE,4BAA4B,EAAE,CAAC"}
|
package/src/FullComposer.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Components } from 'botframework-webchat-component';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
|
|
5
|
-
import AdaptiveCardsComposer from './adaptiveCards/AdaptiveCardsComposer';
|
|
6
|
-
import useComposerProps from './useComposerProps';
|
|
7
|
-
|
|
8
|
-
const { Composer } = Components;
|
|
9
|
-
|
|
10
|
-
const FullComposer = props => {
|
|
11
|
-
const { adaptiveCardsHostConfig, adaptiveCardsPackage, children, ...otherProps } = props;
|
|
12
|
-
const composerProps = useComposerProps(props);
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<AdaptiveCardsComposer
|
|
16
|
-
adaptiveCardsHostConfig={adaptiveCardsHostConfig}
|
|
17
|
-
adaptiveCardsPackage={adaptiveCardsPackage}
|
|
18
|
-
>
|
|
19
|
-
<Composer {...otherProps} {...composerProps}>
|
|
20
|
-
{children}
|
|
21
|
-
</Composer>
|
|
22
|
-
</AdaptiveCardsComposer>
|
|
23
|
-
);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
FullComposer.defaultProps = {
|
|
27
|
-
...Composer.defaultProps,
|
|
28
|
-
adaptiveCardsHostConfig: undefined,
|
|
29
|
-
adaptiveCardsPackage: undefined,
|
|
30
|
-
children: undefined
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
FullComposer.propTypes = {
|
|
34
|
-
...Composer.propTypes,
|
|
35
|
-
adaptiveCardsHostConfig: PropTypes.any,
|
|
36
|
-
adaptiveCardsPackage: PropTypes.any,
|
|
37
|
-
children: PropTypes.any
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export default FullComposer;
|
package/src/FullReactWebChat.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import BasicWebChat from 'botframework-webchat-component';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import React, { useEffect } from 'react';
|
|
4
|
-
|
|
5
|
-
import AdaptiveCardsComposer from './adaptiveCards/AdaptiveCardsComposer';
|
|
6
|
-
import useComposerProps from './useComposerProps';
|
|
7
|
-
|
|
8
|
-
// Add additional props to <WebChat>, so it support additional features
|
|
9
|
-
const FullReactWebChat = props => {
|
|
10
|
-
const { adaptiveCardHostConfig, adaptiveCardsHostConfig, adaptiveCardsPackage, ...otherProps } = props;
|
|
11
|
-
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
adaptiveCardHostConfig &&
|
|
14
|
-
console.warn(
|
|
15
|
-
'Web Chat: "adaptiveCardHostConfig" is deprecated. Please use "adaptiveCardsHostConfig" instead. "adaptiveCardHostConfig" will be removed on or after 2022-01-01.'
|
|
16
|
-
);
|
|
17
|
-
}, [adaptiveCardHostConfig]);
|
|
18
|
-
|
|
19
|
-
const composerProps = useComposerProps(props);
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<AdaptiveCardsComposer
|
|
23
|
-
adaptiveCardsHostConfig={adaptiveCardHostConfig || adaptiveCardsHostConfig}
|
|
24
|
-
adaptiveCardsPackage={adaptiveCardsPackage}
|
|
25
|
-
>
|
|
26
|
-
<BasicWebChat {...otherProps} {...composerProps} />
|
|
27
|
-
</AdaptiveCardsComposer>
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
FullReactWebChat.defaultProps = {
|
|
32
|
-
...BasicWebChat.defaultProps,
|
|
33
|
-
adaptiveCardHostConfig: undefined,
|
|
34
|
-
adaptiveCardsHostConfig: undefined,
|
|
35
|
-
adaptiveCardsPackage: undefined,
|
|
36
|
-
renderMarkdown: undefined
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
FullReactWebChat.propTypes = {
|
|
40
|
-
...BasicWebChat.propTypes,
|
|
41
|
-
adaptiveCardHostConfig: PropTypes.any,
|
|
42
|
-
adaptiveCardsHostConfig: PropTypes.any,
|
|
43
|
-
adaptiveCardsPackage: PropTypes.any,
|
|
44
|
-
renderMarkdown: PropTypes.func
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export default FullReactWebChat;
|