|
2 | 2 | <html lang="en-US"> |
3 | 3 | <head> |
4 | 4 | <link href="/assets/index.css" rel="stylesheet" type="text/css" /> |
5 | | - <script crossorigin="anonymous" src="https://unpkg.com/@babel/standalone@7.8.7/babel.min.js"></script> |
6 | | - <script crossorigin="anonymous" src="https://unpkg.com/react@16.8.6/umd/react.production.min.js"></script> |
7 | | - <script crossorigin="anonymous" src="https://unpkg.com/react-dom@16.8.6/umd/react-dom.production.min.js"></script> |
| 5 | + <script type="importmap"> |
| 6 | + { |
| 7 | + "imports": { |
| 8 | + "react": "https://esm.sh/react@18.3.1", |
| 9 | + "react-dom": "https://esm.sh/react-dom@18.3.1", |
| 10 | + "react-dom/": "https://esm.sh/react-dom@18.3.1/" |
| 11 | + } |
| 12 | + } |
| 13 | + </script> |
8 | 14 | <script crossorigin="anonymous" src="/test-harness.js"></script> |
9 | 15 | <script crossorigin="anonymous" src="/test-page-object.js"></script> |
10 | | - <script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> |
11 | | - <script crossorigin="anonymous" src="/__dist__/botframework-webchat-fluent-theme.production.min.js"></script> |
| 16 | + <script type="module"> |
| 17 | + import React from 'react'; |
| 18 | + window.React = React; |
| 19 | + </script> |
| 20 | + <script defer crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> |
| 21 | + <script defer crossorigin="anonymous" src="/__dist__/botframework-webchat-fluent-theme.production.min.js"></script> |
12 | 22 | <style> |
13 | 23 | webchat-element { |
14 | 24 | display: contents; |
|
18 | 28 | <body> |
19 | 29 | <webchat-element></webchat-element> |
20 | 30 |
|
21 | | - <script type="text/babel"> |
22 | | - const { |
23 | | - React, |
24 | | - ReactDOM: { render }, |
25 | | - WebChat: { FluentThemeProvider, ReactWebChat } |
26 | | - } = window; // Imports in UMD fashion. |
| 31 | + <script type="module"> |
| 32 | + import React from 'react'; |
| 33 | + import { createRoot } from 'react-dom/client'; |
| 34 | + |
| 35 | + run(async function () { |
| 36 | + const { |
| 37 | + WebChat: { FluentThemeProvider, ReactWebChat } |
| 38 | + } = window; // Imports in UMD fashion. |
27 | 39 |
|
28 | | - class WebChatElement extends HTMLElement { |
29 | | - constructor() { |
30 | | - super(); |
| 40 | + class WebChatElement extends HTMLElement { |
| 41 | + constructor() { |
| 42 | + super(); |
31 | 43 |
|
32 | | - this.attachShadow({ mode: 'open' }); |
33 | | - } |
| 44 | + this.attachShadow({ mode: 'open' }); |
| 45 | + } |
| 46 | + |
| 47 | + connectedCallback() { |
| 48 | + const container = document.createElement('main'); |
34 | 49 |
|
35 | | - connectedCallback() { |
36 | | - const container = document.createElement('main'); |
| 50 | + container.id = 'webchat'; |
37 | 51 |
|
38 | | - container.id = 'webchat'; |
| 52 | + this.shadowRoot.appendChild(container); |
| 53 | + this.shadowRoot.appendChild(document.head.querySelector('link').cloneNode()); |
39 | 54 |
|
40 | | - this.shadowRoot.appendChild(container); |
41 | | - this.shadowRoot.appendChild(document.head.querySelector('link').cloneNode()); |
| 55 | + const directLine = testHelpers.createDirectLineWithTranscript( |
| 56 | + testHelpers.transcriptNavigation.generateTranscript() |
| 57 | + ); |
42 | 58 |
|
43 | | - const directLine = testHelpers.createDirectLineWithTranscript( |
44 | | - testHelpers.transcriptNavigation.generateTranscript() |
45 | | - ); |
| 59 | + const store = testHelpers.createStore(); |
46 | 60 |
|
47 | | - const store = testHelpers.createStore(); |
| 61 | + const App = () => React.createElement( |
| 62 | + ReactWebChat, |
| 63 | + { |
| 64 | + directLine: directLine, |
| 65 | + nonce: "test", |
| 66 | + store: store, |
| 67 | + styleOptions: { stylesRoot: this.shadowRoot } |
| 68 | + } |
| 69 | + ); |
48 | 70 |
|
49 | | - const App = () => ( |
50 | | - <ReactWebChat |
51 | | - directLine={directLine} |
52 | | - nonce="test" |
53 | | - store={store} |
54 | | - styleOptions={{ stylesRoot: this.shadowRoot }} |
55 | | - /> |
56 | | - ); |
| 71 | + const root = createRoot(container); |
57 | 72 |
|
58 | | - render( |
59 | | - <FluentThemeProvider> |
60 | | - <App /> |
61 | | - </FluentThemeProvider>, |
62 | | - container |
63 | | - ); |
| 73 | + root.render( |
| 74 | + React.createElement(FluentThemeProvider, null, |
| 75 | + React.createElement(App) |
| 76 | + ) |
| 77 | + ); |
| 78 | + } |
64 | 79 | } |
65 | | - } |
66 | 80 |
|
67 | | - run(async function () { |
68 | 81 | customElements.define('webchat-element', WebChatElement); |
69 | 82 |
|
70 | 83 | pageElements.root(document.querySelector('webchat-element').shadowRoot); |
|
0 commit comments