-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
92 lines (80 loc) · 3.84 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>JS w/o React</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script>
'use strict';
var numError = 0;
// IE11: Show error in alert dialog.
~window.navigator.userAgent.indexOf('Trident/7.0') &&
window.addEventListener('error', function (event) {
numError++ < 5 && event.error && alert(event.error + '\n\n' + event.error.stack);
});
</script>
<script crossorigin="anonymous" src="https://unpkg.com/babel-standalone@6/babel.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/runtime.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/markdown-it/dist/markdown-it.min.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/whatwg-fetch"></script>
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react.development.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react-dom.development.js"></script>
<link href="../common/cheatSheet.css" rel="stylesheet" />
<link href="../common/markdown.css" rel="stylesheet" />
<link href="../common/webchat.css" rel="stylesheet" />
<script data-presets="es2015,stage-3" src="../common/createDirectLineWithTranscript.js" type="text/babel"></script>
<script data-presets="es2015,stage-3" src="../common/createFetchTokens.js" type="text/babel"></script>
<script data-presets="es2015,stage-3" src="../common/loadCustomization.js" type="text/babel"></script>
<script data-presets="es2015,stage-3" src="../common/renderCheatSheet.js" type="text/babel"></script>
<script src="../drops/webchat-es5.js"></script>
<!--
<script
crossorigin="anonymous"
integrity="sha384-"
src="https://cdn.botframework.com/botframework-webchat/latest/webchat-es5.js"
></script>
-->
</head>
<body>
<div id="webchat" role="main"></div>
<script type="text/babel" data-presets="es2015,react,stage-3">
const { fetchDirectLineToken, fetchSpeechServicesCredentials } = window.createFetchTokens();
const {
WebChat: { createCognitiveServicesSpeechServicesPonyfillFactory, createDirectLine, createStore, renderWebChat }
} = window;
async function main() {
await window.WebChat.loadCustomization();
await window.WebChat.renderCheatSheet();
const { createDirectLineMiddleware, patchProps } = window.WebChat.customizations;
const directLine = (createDirectLineMiddleware
? createDirectLineMiddleware()(createDirectLine)
: createDirectLine)({ token: await fetchDirectLineToken() });
const store = (window.webChatStore = createStore());
// Create Web Speech ponyfill if the browser support WebRTC
const webSpeechPonyfillFactory =
window.navigator.mediaDevices &&
(await createCognitiveServicesSpeechServicesPonyfillFactory({
credentials: fetchSpeechServicesCredentials
}));
// We want to make sure we didn't break React hooks in hosting apps
const ActivityContainer = ({ children }) => {
React.useEffect(() => {});
return children;
};
renderWebChat(
await patchProps({
activityMiddleware: () => next => card => children => (
<ActivityContainer>{next(card)(children)}</ActivityContainer>
),
directLine,
// Firefox default language to "en", which is not supported by Cognitive Services, we need to specify it as "en-US"
locale: 'en-US',
store,
webSpeechPonyfillFactory
}),
document.getElementById('webchat')
);
}
main().catch(err => console.error(err));
</script>
</body>
</html>