botframework-webchat 4.13.0 → 4.14.2
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/.eslintignore +1 -9
- package/.eslintrc.yml +5 -0
- 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 +77 -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 +4 -4
- 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 +11 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardRenderer.d.ts.map +1 -0
- package/lib/adaptiveCards/Attachment/AdaptiveCardRenderer.js +210 -49
- 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 +56 -0
- package/lib/adaptiveCards/Styles/StyleSet/AdaptiveCardRenderer.d.ts.map +1 -0
- package/lib/adaptiveCards/Styles/StyleSet/AdaptiveCardRenderer.js +1 -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 +29 -39
- 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 +1106 -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 +24 -20
- package/lib/index-es5.d.ts.map +1 -1
- package/lib/index-es5.js +2 -2
- package/lib/index-minimal.d.ts +9 -6
- package/lib/index-minimal.d.ts.map +1 -1
- package/lib/index-minimal.js +8 -4
- package/lib/index.d.ts +154 -18
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +11 -7
- package/lib/renderMarkdown.d.ts +6 -0
- package/lib/renderMarkdown.d.ts.map +1 -0
- package/lib/renderMarkdown.js +5 -2
- 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 +416 -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 +84 -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 +51 -46
- package/src/AddFullBundle.tsx +94 -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 +21 -15
- package/src/adaptiveCards/Attachment/{AdaptiveCardContent.js → AdaptiveCardContent.tsx} +8 -2
- package/src/adaptiveCards/Attachment/{AdaptiveCardRenderer.js → AdaptiveCardRenderer.tsx} +228 -46
- 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 +1 -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 +45 -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 +37 -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 +0 -2
- package/src/index-minimal.ts +3 -2
- package/src/index.ts +22 -10
- package/src/{renderMarkdown.js → renderMarkdown.ts} +8 -1
- package/src/renderWebChat.tsx +6 -0
- package/src/speech/CustomAudioInputStream.ts +325 -0
- package/src/speech/bytesPerSample.ts +4 -0
- package/src/speech/createAudioConfig.spec.js +23 -0
- package/src/speech/createAudioConfig.ts +70 -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/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/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/renderWebChat.js +0 -6
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
/* eslint react/no-array-index-key: "off" */
|
|
2
2
|
|
|
3
|
+
import { DirectLineVideoCard } from 'botframework-webchat-core';
|
|
3
4
|
import { Components, hooks } from 'botframework-webchat-component';
|
|
4
5
|
import PropTypes from 'prop-types';
|
|
5
|
-
import React from 'react';
|
|
6
|
+
import React, { FC } from 'react';
|
|
6
7
|
|
|
7
8
|
import CommonCard from './CommonCard';
|
|
8
9
|
|
|
9
10
|
const { useStyleSet } = hooks;
|
|
10
11
|
const { VideoContent } = Components;
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
type VideoCardContentProps = {
|
|
14
|
+
actionPerformedClassName?: string;
|
|
15
|
+
content: DirectLineVideoCard & {
|
|
16
|
+
autoloop?: boolean;
|
|
17
|
+
autostart?: boolean;
|
|
18
|
+
image?: { url?: string };
|
|
19
|
+
media?: { profile?: string; url?: string }[];
|
|
20
|
+
};
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const VideoCardContent: FC<VideoCardContentProps> = ({ actionPerformedClassName, content, disabled }) => {
|
|
25
|
+
const { autoloop, autostart, image: { url: imageURL } = { url: undefined }, media } = content;
|
|
14
26
|
const [{ audioCardAttachment: audioCardAttachmentStyleSet }] = useStyleSet();
|
|
15
27
|
|
|
16
28
|
return (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { normalizeStyleOptions } from 'botframework-webchat-api';
|
|
2
2
|
|
|
3
|
-
import FullBundleStyleOptions from '../../FullBundleStyleOptions';
|
|
3
|
+
import FullBundleStyleOptions from '../../types/FullBundleStyleOptions';
|
|
4
4
|
import normalizeAdaptiveCardsStyleOptions from '../normalizeStyleOptions';
|
|
5
5
|
|
|
6
6
|
// https://docs.microsoft.com/en-us/adaptive-cards/rendering-cards/host-config
|
|
@@ -21,7 +21,27 @@ export default function createAdaptiveCardsHostConfig(styleOptions: FullBundleSt
|
|
|
21
21
|
},
|
|
22
22
|
accent: {
|
|
23
23
|
default: accent,
|
|
24
|
-
subtle:
|
|
24
|
+
subtle: '#0078D4'
|
|
25
|
+
},
|
|
26
|
+
attention: {
|
|
27
|
+
default: '#D13438',
|
|
28
|
+
subtle: '#A4262C'
|
|
29
|
+
},
|
|
30
|
+
dark: {
|
|
31
|
+
default: '#000000',
|
|
32
|
+
subtle: '#646464'
|
|
33
|
+
},
|
|
34
|
+
good: {
|
|
35
|
+
default: '#0B6A0B',
|
|
36
|
+
subtle: '#028A02'
|
|
37
|
+
},
|
|
38
|
+
light: {
|
|
39
|
+
default: '#FFFFFF',
|
|
40
|
+
subtle
|
|
41
|
+
},
|
|
42
|
+
warning: {
|
|
43
|
+
default: '#B75C00',
|
|
44
|
+
subtle: '#986F0B'
|
|
25
45
|
}
|
|
26
46
|
}
|
|
27
47
|
},
|
|
@@ -29,8 +49,8 @@ export default function createAdaptiveCardsHostConfig(styleOptions: FullBundleSt
|
|
|
29
49
|
backgroundColor: cardEmphasisBackgroundColor,
|
|
30
50
|
foregroundColors: {
|
|
31
51
|
default: {
|
|
32
|
-
default:
|
|
33
|
-
subtle
|
|
52
|
+
default: '#000000',
|
|
53
|
+
subtle: '#484644'
|
|
34
54
|
}
|
|
35
55
|
}
|
|
36
56
|
},
|
|
@@ -39,7 +59,7 @@ export default function createAdaptiveCardsHostConfig(styleOptions: FullBundleSt
|
|
|
39
59
|
foregroundColors: {
|
|
40
60
|
default: {
|
|
41
61
|
default: '#333333',
|
|
42
|
-
subtle: '#
|
|
62
|
+
subtle: '#484644'
|
|
43
63
|
}
|
|
44
64
|
}
|
|
45
65
|
},
|
|
@@ -48,7 +68,7 @@ export default function createAdaptiveCardsHostConfig(styleOptions: FullBundleSt
|
|
|
48
68
|
foregroundColors: {
|
|
49
69
|
default: {
|
|
50
70
|
default: '#333333',
|
|
51
|
-
subtle: '#
|
|
71
|
+
subtle: '#484644'
|
|
52
72
|
}
|
|
53
73
|
}
|
|
54
74
|
},
|
|
@@ -57,7 +77,7 @@ export default function createAdaptiveCardsHostConfig(styleOptions: FullBundleSt
|
|
|
57
77
|
foregroundColors: {
|
|
58
78
|
default: {
|
|
59
79
|
default: '#333333',
|
|
60
|
-
subtle: '#
|
|
80
|
+
subtle: '#484644'
|
|
61
81
|
}
|
|
62
82
|
}
|
|
63
83
|
},
|
|
@@ -66,7 +86,7 @@ export default function createAdaptiveCardsHostConfig(styleOptions: FullBundleSt
|
|
|
66
86
|
foregroundColors: {
|
|
67
87
|
default: {
|
|
68
88
|
default: '#333333',
|
|
69
|
-
subtle: '#
|
|
89
|
+
subtle: '#484644'
|
|
70
90
|
}
|
|
71
91
|
}
|
|
72
92
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { normalizeStyleOptions, StyleOptions } from 'botframework-webchat-api';
|
|
1
|
+
import { normalizeStyleOptions, StrictStyleOptions, StyleOptions } from 'botframework-webchat-api';
|
|
2
2
|
|
|
3
|
-
import AdaptiveCardsStyleOptions from '../AdaptiveCardsStyleOptions';
|
|
3
|
+
import AdaptiveCardsStyleOptions, { StrictAdaptiveCardsStyleOptions } from '../AdaptiveCardsStyleOptions';
|
|
4
|
+
import AdaptiveCardsStyleSet from '../AdaptiveCardsStyleSet';
|
|
4
5
|
import createAdaptiveCardRendererStyle from './StyleSet/AdaptiveCardRenderer';
|
|
5
6
|
import createAnimationCardAttachmentStyle from './StyleSet/AnimationCardAttachment';
|
|
6
7
|
import createAudioCardAttachmentStyle from './StyleSet/AudioCardAttachment';
|
|
@@ -10,8 +11,10 @@ import normalizeAdaptiveCardsStyleOptions from '../normalizeStyleOptions';
|
|
|
10
11
|
// "styleSet" is actually CSS stylesheet and it is based on the DOM tree.
|
|
11
12
|
// DOM tree may change from time to time, thus, maintaining "styleSet" becomes a constant effort.
|
|
12
13
|
|
|
13
|
-
export default function createAdaptiveCardsStyleSet(
|
|
14
|
-
|
|
14
|
+
export default function createAdaptiveCardsStyleSet(
|
|
15
|
+
options: StyleOptions & AdaptiveCardsStyleOptions
|
|
16
|
+
): AdaptiveCardsStyleSet {
|
|
17
|
+
const strictOptions: StrictStyleOptions & StrictAdaptiveCardsStyleOptions = {
|
|
15
18
|
...normalizeStyleOptions(options),
|
|
16
19
|
...normalizeAdaptiveCardsStyleOptions(options)
|
|
17
20
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AttachmentForScreenReaderMiddleware } from 'botframework-webchat-api';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
|
|
3
4
|
import AdaptiveCardAttachment from './AttachmentForScreenReader/AdaptiveCardAttachment';
|
|
@@ -14,20 +15,20 @@ const RICH_CARD_CONTENT_TYPES = [
|
|
|
14
15
|
'application/vnd.microsoft.card.video'
|
|
15
16
|
];
|
|
16
17
|
|
|
17
|
-
export default function createAdaptiveCardsAttachmentMiddleware() {
|
|
18
|
-
return () =>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
export default function createAdaptiveCardsAttachmentMiddleware(): AttachmentForScreenReaderMiddleware {
|
|
19
|
+
return () =>
|
|
20
|
+
next =>
|
|
21
|
+
(...args) => {
|
|
22
|
+
const [
|
|
23
|
+
{
|
|
24
|
+
attachment: { content, contentType }
|
|
25
|
+
}
|
|
26
|
+
] = args;
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
return content && RICH_CARD_CONTENT_TYPES.includes(contentType)
|
|
29
|
+
? () => <RichCardAttachment content={content} />
|
|
30
|
+
: content && contentType === 'application/vnd.microsoft.card.adaptive'
|
|
31
|
+
? () => <AdaptiveCardAttachment content={content} />
|
|
32
|
+
: next(...args);
|
|
33
|
+
};
|
|
33
34
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { AttachmentMiddleware } from 'botframework-webchat-api';
|
|
4
|
+
|
|
5
|
+
import AdaptiveCardAttachment from './Attachment/AdaptiveCardAttachment';
|
|
6
|
+
import AnimationCardAttachment from './Attachment/AnimationCardAttachment';
|
|
7
|
+
import AudioCardAttachment from './Attachment/AudioCardAttachment';
|
|
8
|
+
import HeroCardAttachment from './Attachment/HeroCardAttachment';
|
|
9
|
+
import OAuthCardAttachment from './Attachment/OAuthCardAttachment';
|
|
10
|
+
import ReceiptCardAttachment from './Attachment/ReceiptCardAttachment';
|
|
11
|
+
import SignInCardAttachment from './Attachment/SignInCardAttachment';
|
|
12
|
+
import ThumbnailCardAttachment from './Attachment/ThumbnailCardAttachment';
|
|
13
|
+
import VideoCardAttachment from './Attachment/VideoCardAttachment';
|
|
14
|
+
|
|
15
|
+
export default function createAdaptiveCardsAttachmentMiddleware(): AttachmentMiddleware {
|
|
16
|
+
// This is not returning a React component, but a render function.
|
|
17
|
+
return () =>
|
|
18
|
+
next =>
|
|
19
|
+
/* eslint-disable-next-line react/display-name */
|
|
20
|
+
(...args) => {
|
|
21
|
+
const [{ attachment }] = args;
|
|
22
|
+
|
|
23
|
+
return attachment.contentType === 'application/vnd.microsoft.card.hero' ? (
|
|
24
|
+
<HeroCardAttachment attachment={attachment} />
|
|
25
|
+
) : attachment.contentType === 'application/vnd.microsoft.card.adaptive' ? (
|
|
26
|
+
<AdaptiveCardAttachment attachment={attachment} />
|
|
27
|
+
) : attachment.contentType === 'application/vnd.microsoft.card.animation' ? (
|
|
28
|
+
<AnimationCardAttachment attachment={attachment} />
|
|
29
|
+
) : attachment.contentType === 'application/vnd.microsoft.card.audio' ? (
|
|
30
|
+
<AudioCardAttachment attachment={attachment} />
|
|
31
|
+
) : attachment.contentType === 'application/vnd.microsoft.card.oauth' ? (
|
|
32
|
+
<OAuthCardAttachment attachment={attachment} />
|
|
33
|
+
) : attachment.contentType === 'application/vnd.microsoft.card.receipt' ? (
|
|
34
|
+
<ReceiptCardAttachment attachment={attachment} />
|
|
35
|
+
) : attachment.contentType === 'application/vnd.microsoft.card.signin' ? (
|
|
36
|
+
<SignInCardAttachment attachment={attachment} />
|
|
37
|
+
) : attachment.contentType === 'application/vnd.microsoft.card.thumbnail' ? (
|
|
38
|
+
<ThumbnailCardAttachment attachment={attachment} />
|
|
39
|
+
) : attachment.contentType === 'application/vnd.microsoft.card.video' ? (
|
|
40
|
+
<VideoCardAttachment attachment={attachment} />
|
|
41
|
+
) : (
|
|
42
|
+
next(...args)
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import AdaptiveCardsStyleOptions from './AdaptiveCardsStyleOptions';
|
|
2
2
|
|
|
3
3
|
const ADAPTIVE_CARDS_DEFAULT_STYLE_OPTIONS: Required<AdaptiveCardsStyleOptions> = {
|
|
4
|
+
adaptiveCardsParserMaxVersion: undefined,
|
|
4
5
|
cardEmphasisBackgroundColor: '#F0F0F0',
|
|
5
6
|
cardPushButtonBackgroundColor: '#0063B1',
|
|
6
|
-
cardPushButtonTextColor: '
|
|
7
|
+
cardPushButtonTextColor: 'White',
|
|
7
8
|
richCardWrapTitle: false
|
|
8
9
|
};
|
|
9
10
|
|
package/src/adaptiveCards/hooks/internal/{useAdaptiveCardsContext.js → useAdaptiveCardsContext.ts}
RENAMED
|
@@ -2,7 +2,7 @@ import { useContext } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import AdaptiveCardsContext from '../../AdaptiveCardsContext';
|
|
4
4
|
|
|
5
|
-
export default function useAdaptiveCardsContext() {
|
|
5
|
+
export default function useAdaptiveCardsContext(): AdaptiveCardsContext {
|
|
6
6
|
const context = useContext(AdaptiveCardsContext);
|
|
7
7
|
|
|
8
8
|
if (!context) {
|
package/src/adaptiveCards/hooks/internal/{useParseAdaptiveCardJSON.js → useParseAdaptiveCardJSON.ts}
RENAMED
|
@@ -2,8 +2,9 @@ import { hooks } from 'botframework-webchat-component';
|
|
|
2
2
|
import { useCallback, useMemo } from 'react';
|
|
3
3
|
|
|
4
4
|
import useAdaptiveCardsPackage from '../useAdaptiveCardsPackage';
|
|
5
|
+
import useStyleOptions from '../../../hooks/useStyleOptions';
|
|
5
6
|
|
|
6
|
-
const { useDirection
|
|
7
|
+
const { useDirection } = hooks;
|
|
7
8
|
|
|
8
9
|
function updateRTLInline(element, rtl, adaptiveCardsPackage) {
|
|
9
10
|
if (element instanceof adaptiveCardsPackage.Container) {
|
|
@@ -33,7 +34,9 @@ export default function useParseAdaptiveCardJSON() {
|
|
|
33
34
|
const maxVersion = Version.parse(adaptiveCardsParserMaxVersion, new SerializationContext());
|
|
34
35
|
|
|
35
36
|
if (maxVersion && !maxVersion.isValid) {
|
|
36
|
-
|
|
37
|
+
console.warn('botframework-webchat: "adaptiveCardsParserMaxVersion" specified is not a valid version.');
|
|
38
|
+
|
|
39
|
+
return;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
return maxVersion;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import random from 'math-random';
|
|
5
5
|
|
|
6
|
-
export default function useUniqueId(prefix) {
|
|
6
|
+
export default function useUniqueId(prefix?: string): string {
|
|
7
7
|
const id = useMemo(() => random().toString(36).substr(2, 5), []);
|
|
8
8
|
|
|
9
9
|
prefix = prefix ? `${prefix}--` : '';
|
package/src/adaptiveCards/hooks/{useAdaptiveCardsHostConfig.js → useAdaptiveCardsHostConfig.ts}
RENAMED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import { hooks } from 'botframework-webchat-component';
|
|
2
1
|
import { useMemo } from 'react';
|
|
3
2
|
|
|
4
3
|
import createDefaultAdaptiveCardHostConfig from '../Styles/adaptiveCardHostConfig';
|
|
5
4
|
import useAdaptiveCardsContext from './internal/useAdaptiveCardsContext';
|
|
5
|
+
import useStyleOptions from '../../hooks/useStyleOptions';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export default function useAdaptiveCardsHostConfig() {
|
|
7
|
+
export default function useAdaptiveCardsHostConfig(): [any] {
|
|
10
8
|
const { hostConfigFromProps } = useAdaptiveCardsContext();
|
|
11
9
|
const [styleOptions] = useStyleOptions();
|
|
12
10
|
|
|
13
|
-
const patchedHostConfig = useMemo(
|
|
14
|
-
hostConfigFromProps,
|
|
15
|
-
styleOptions
|
|
16
|
-
|
|
11
|
+
const patchedHostConfig = useMemo(
|
|
12
|
+
() => hostConfigFromProps || createDefaultAdaptiveCardHostConfig(styleOptions),
|
|
13
|
+
[hostConfigFromProps, styleOptions]
|
|
14
|
+
);
|
|
17
15
|
|
|
18
16
|
return [patchedHostConfig];
|
|
19
17
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import AdaptiveCardsPackage from '../../types/AdaptiveCardsPackage';
|
|
1
2
|
import useAdaptiveCardsContext from './internal/useAdaptiveCardsContext';
|
|
2
3
|
|
|
3
|
-
export default function useAdaptiveCardsPackage() {
|
|
4
|
+
export default function useAdaptiveCardsPackage(): [AdaptiveCardsPackage] {
|
|
4
5
|
const { adaptiveCardsPackage } = useAdaptiveCardsContext();
|
|
5
6
|
|
|
6
7
|
return [adaptiveCardsPackage];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { WebSpeechPonyfill } from 'botframework-webchat-api';
|
|
2
|
+
|
|
3
|
+
export default function createBrowserWebSpeechPonyfillFactory(): () => WebSpeechPonyfill {
|
|
4
|
+
// eslint-disable-next-line dot-notation
|
|
5
|
+
if (!window.SpeechRecognition && !window['webkitSpeechRecognition']) {
|
|
6
|
+
console.warn('Web Chat: This browser does not support Web Speech API Speech Recognition.');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (!window.speechSynthesis) {
|
|
10
|
+
console.warn('Web Chat: This browser does not support Web Speech API Speech Synthesis.');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return () => ({
|
|
14
|
+
// eslint-disable-next-line dot-notation
|
|
15
|
+
SpeechGrammarList: window.SpeechGrammarList || window['webkitSpeechGrammarList'],
|
|
16
|
+
// eslint-disable-next-line dot-notation
|
|
17
|
+
SpeechRecognition: window.SpeechRecognition || window['webkitSpeechRecognition'],
|
|
18
|
+
speechSynthesis: window.speechSynthesis,
|
|
19
|
+
SpeechSynthesisUtterance: window.SpeechSynthesisUtterance
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @jest-environment jsdom */
|
|
1
2
|
/* eslint-disable prefer-destructuring */
|
|
2
3
|
/* eslint-disable no-global-assign */
|
|
3
4
|
let consoleWarns;
|
|
@@ -17,11 +18,29 @@ beforeEach(() => {
|
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
createPonyfill = require('web-speech-cognitive-services/lib/SpeechServices');
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.default;
|
|
21
|
+
createCognitiveServicesSpeechServicesPonyfillFactory =
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
23
|
+
require('./createCognitiveServicesSpeechServicesPonyfillFactory').default;
|
|
24
|
+
|
|
25
|
+
window.AudioContext = class MockAudioContext {
|
|
26
|
+
// eslint-disable-next-line class-methods-use-this
|
|
27
|
+
createMediaStreamSource() {
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
29
|
+
return { connect: () => {} };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// eslint-disable-next-line class-methods-use-this
|
|
33
|
+
createScriptProcessor() {
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
35
|
+
return { connect: () => {} };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
23
38
|
|
|
24
|
-
window.navigator.mediaDevices = {
|
|
39
|
+
window.navigator.mediaDevices = {
|
|
40
|
+
getUserMedia: jest.fn(() => ({
|
|
41
|
+
getAudioTracks: () => ['mock-media-stream-track']
|
|
42
|
+
}))
|
|
43
|
+
};
|
|
25
44
|
});
|
|
26
45
|
|
|
27
46
|
afterEach(() => {
|
|
@@ -60,7 +79,8 @@ test('not providing reference grammar ID', () => {
|
|
|
60
79
|
expect(referenceGrammars).toEqual([]);
|
|
61
80
|
});
|
|
62
81
|
|
|
63
|
-
test('supplying audioInputDeviceId', () => {
|
|
82
|
+
test('supplying audioInputDeviceId', async () => {
|
|
83
|
+
// GIVEN: Set up Web Speech with "audioInputDeviceId" of "audio-input-device-1".
|
|
64
84
|
const ponyfillFactory = createCognitiveServicesSpeechServicesPonyfillFactory({
|
|
65
85
|
audioInputDeviceId: 'audio-input-device-1',
|
|
66
86
|
credentials: {
|
|
@@ -69,9 +89,20 @@ test('supplying audioInputDeviceId', () => {
|
|
|
69
89
|
}
|
|
70
90
|
});
|
|
71
91
|
|
|
92
|
+
// WHEN: Polyfill is created.
|
|
72
93
|
ponyfillFactory({});
|
|
73
94
|
|
|
74
|
-
|
|
95
|
+
// WHEN: Audio source is attached and audio device is opened.
|
|
96
|
+
await createPonyfill.mock.calls[0][0].audioConfig.privSource.attach();
|
|
97
|
+
|
|
98
|
+
// THEN: It should call getUserMedia() with "audio" constraints of { deviceId: 'audio-input-device-1' }.
|
|
99
|
+
expect(window.navigator.mediaDevices.getUserMedia.mock.calls[0][0]).toHaveProperty(
|
|
100
|
+
'audio.deviceId',
|
|
101
|
+
'audio-input-device-1'
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
// THEN: It should call getUserMedia() with "video" constraint of false.
|
|
105
|
+
expect(window.navigator.mediaDevices.getUserMedia.mock.calls[0][0]).toHaveProperty('video', false);
|
|
75
106
|
});
|
|
76
107
|
|
|
77
108
|
test('supplying both audioConfig and audioInputDeviceId', () => {
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { AudioConfig } from 'microsoft-cognitiveservices-speech-sdk';
|
|
2
|
+
import { WebSpeechPonyfillFactory } from 'botframework-webchat-api';
|
|
3
|
+
import createPonyfill from 'web-speech-cognitive-services/lib/SpeechServices';
|
|
4
|
+
|
|
5
|
+
import CognitiveServicesAudioOutputFormat from './types/CognitiveServicesAudioOutputFormat';
|
|
6
|
+
import CognitiveServicesCredentials from './types/CognitiveServicesCredentials';
|
|
7
|
+
import CognitiveServicesTextNormalization from './types/CognitiveServicesTextNormalization';
|
|
8
|
+
import createMicrophoneAudioConfigAndAudioContext from './speech/createMicrophoneAudioConfigAndAudioContext';
|
|
9
|
+
|
|
10
|
+
export default function createCognitiveServicesSpeechServicesPonyfillFactory({
|
|
11
|
+
audioConfig,
|
|
12
|
+
audioContext,
|
|
13
|
+
audioInputDeviceId,
|
|
14
|
+
credentials,
|
|
15
|
+
enableTelemetry,
|
|
16
|
+
speechRecognitionEndpointId,
|
|
17
|
+
speechSynthesisDeploymentId,
|
|
18
|
+
speechSynthesisOutputFormat,
|
|
19
|
+
textNormalization
|
|
20
|
+
}: {
|
|
21
|
+
audioConfig?: AudioConfig;
|
|
22
|
+
audioContext?: AudioContext;
|
|
23
|
+
audioInputDeviceId?: string;
|
|
24
|
+
credentials: CognitiveServicesCredentials;
|
|
25
|
+
enableTelemetry?: true;
|
|
26
|
+
speechRecognitionEndpointId?: string;
|
|
27
|
+
speechSynthesisDeploymentId?: string;
|
|
28
|
+
speechSynthesisOutputFormat?: CognitiveServicesAudioOutputFormat;
|
|
29
|
+
textNormalization?: CognitiveServicesTextNormalization;
|
|
30
|
+
}): WebSpeechPonyfillFactory {
|
|
31
|
+
if (!window.navigator.mediaDevices && !audioConfig) {
|
|
32
|
+
console.warn(
|
|
33
|
+
'botframework-webchat: Your browser does not support Web Audio or the page is not loaded via HTTPS or localhost. Cognitive Services Speech Services is disabled. However, you may pass a custom AudioConfig to enable speech in this environment.'
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return () => ({});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (audioConfig) {
|
|
40
|
+
audioInputDeviceId &&
|
|
41
|
+
console.warn(
|
|
42
|
+
'botframework-webchat: "audioConfig" and "audioInputDeviceId" cannot be set at the same time; ignoring "audioInputDeviceId".'
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
audioContext &&
|
|
46
|
+
console.warn(
|
|
47
|
+
'botframework-webchat: "audioConfig" and "audioContext" cannot be set at the same time; ignoring "audioContext" for speech recognition.'
|
|
48
|
+
);
|
|
49
|
+
} else {
|
|
50
|
+
({ audioConfig, audioContext } = createMicrophoneAudioConfigAndAudioContext({
|
|
51
|
+
audioContext,
|
|
52
|
+
audioInputDeviceId,
|
|
53
|
+
enableTelemetry
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return ({ referenceGrammarID } = {}) => {
|
|
58
|
+
const { SpeechGrammarList, SpeechRecognition, speechSynthesis, SpeechSynthesisUtterance } = createPonyfill({
|
|
59
|
+
audioConfig,
|
|
60
|
+
audioContext,
|
|
61
|
+
credentials,
|
|
62
|
+
enableTelemetry,
|
|
63
|
+
referenceGrammars: referenceGrammarID ? [`luis/${referenceGrammarID}-PRODUCTION`] : [],
|
|
64
|
+
speechRecognitionEndpointId,
|
|
65
|
+
speechSynthesisDeploymentId,
|
|
66
|
+
speechSynthesisOutputFormat,
|
|
67
|
+
textNormalization
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
resumeAudioContext: () => audioContext && audioContext.state === 'suspended' && audioContext.resume(),
|
|
72
|
+
SpeechGrammarList,
|
|
73
|
+
SpeechRecognition,
|
|
74
|
+
speechSynthesis,
|
|
75
|
+
SpeechSynthesisUtterance
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { DirectLine } from 'botframework-directlinejs';
|
|
2
|
+
|
|
3
|
+
type CreateDirectLineOptions = {
|
|
4
|
+
botAgent?: string;
|
|
5
|
+
conversationId?: string;
|
|
6
|
+
conversationStartProperties?: any;
|
|
7
|
+
domain?: string;
|
|
8
|
+
fetch?: typeof window.fetch;
|
|
9
|
+
pollingInterval?: number;
|
|
10
|
+
secret?: string;
|
|
11
|
+
streamUrl?: string;
|
|
12
|
+
token?: string;
|
|
13
|
+
watermark?: string;
|
|
14
|
+
webSocket?: typeof WebSocket;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default function createDirectLine({
|
|
18
|
+
botAgent,
|
|
19
|
+
conversationId,
|
|
20
|
+
conversationStartProperties,
|
|
21
|
+
domain,
|
|
22
|
+
fetch,
|
|
23
|
+
pollingInterval,
|
|
24
|
+
secret,
|
|
25
|
+
streamUrl,
|
|
26
|
+
token,
|
|
27
|
+
watermark,
|
|
28
|
+
webSocket
|
|
29
|
+
}: CreateDirectLineOptions) {
|
|
30
|
+
// TODO: [P3] Checks if DLJS supports ponyfilling fetch.
|
|
31
|
+
return new DirectLine({
|
|
32
|
+
botAgent,
|
|
33
|
+
conversationId,
|
|
34
|
+
conversationStartProperties,
|
|
35
|
+
domain,
|
|
36
|
+
fetch,
|
|
37
|
+
pollingInterval,
|
|
38
|
+
secret,
|
|
39
|
+
streamUrl,
|
|
40
|
+
token,
|
|
41
|
+
watermark,
|
|
42
|
+
webSocket,
|
|
43
|
+
createFormData: attachments => {
|
|
44
|
+
const formData = new FormData();
|
|
45
|
+
|
|
46
|
+
attachments.forEach(
|
|
47
|
+
({
|
|
48
|
+
contentType,
|
|
49
|
+
data,
|
|
50
|
+
filename,
|
|
51
|
+
name
|
|
52
|
+
}: {
|
|
53
|
+
contentType?: string;
|
|
54
|
+
data: BlobPart[];
|
|
55
|
+
filename?: string;
|
|
56
|
+
name?: string;
|
|
57
|
+
}) => {
|
|
58
|
+
formData.append(name, new Blob(data, { type: contentType }), filename);
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
return formData;
|
|
63
|
+
}
|
|
64
|
+
} as any);
|
|
65
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DirectLineStreaming } from 'botframework-directlinejs';
|
|
2
|
+
|
|
3
|
+
export default function createDirectLineAppServiceExtension({
|
|
4
|
+
botAgent,
|
|
5
|
+
conversationId,
|
|
6
|
+
domain,
|
|
7
|
+
token
|
|
8
|
+
}: {
|
|
9
|
+
botAgent?: string;
|
|
10
|
+
conversationId?: string;
|
|
11
|
+
domain?: string;
|
|
12
|
+
token: string;
|
|
13
|
+
}): Promise<any> {
|
|
14
|
+
return Promise.resolve(
|
|
15
|
+
new DirectLineStreaming({
|
|
16
|
+
botAgent,
|
|
17
|
+
conversationId,
|
|
18
|
+
domain,
|
|
19
|
+
token
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
}
|