|
28 | 28 | #info { |
29 | 29 | padding-top: 20px; |
30 | 30 | } |
| 31 | + .error { |
| 32 | + border: 1px solid red; |
| 33 | + background-color: #ffd9d9; |
| 34 | + padding: 5px; |
| 35 | + margin-top: 20px; |
| 36 | + } |
31 | 37 | .button-container { |
32 | 38 | display: flex; |
33 | 39 | justify-content: end; |
|
633 | 639 | </script> |
634 | 640 | </head> |
635 | 641 | <body> |
636 | | - <h1>Simple REPL for Python WASM</h1> |
637 | | - <div id="editor">print('Welcome to WASM!')</div> |
638 | | - <div class="button-container"> |
639 | | - <button id="run" disabled>Run code</button> |
640 | | - <button id="repl" disabled>Start REPL</button> |
641 | | - <button id="stop" disabled>Stop</button> |
642 | | - <button id="clear" disabled>Clear</button> |
| 642 | + <div id="repldemo"> |
| 643 | + <h1>Simple REPL for Python WASM</h1> |
| 644 | + <div id="editor">print('Welcome to WASM!')</div> |
| 645 | + <div class="button-container"> |
| 646 | + <button id="run" disabled>Run code</button> |
| 647 | + <button id="repl" disabled>Start REPL</button> |
| 648 | + <button id="stop" disabled>Stop</button> |
| 649 | + <button id="clear" disabled>Clear</button> |
| 650 | + </div> |
| 651 | + <div id="terminal"></div> |
| 652 | + <div id="info"> |
| 653 | + The simple REPL provides a limited Python experience in the |
| 654 | + browser. |
| 655 | + <a |
| 656 | + href="https://github.com/python/cpython/blob/main/Tools/wasm/README.md" |
| 657 | + > |
| 658 | + Tools/wasm/README.md |
| 659 | + </a> |
| 660 | + contains a list of known limitations and issues. Networking, |
| 661 | + subprocesses, and threading are not available. |
| 662 | + </div> |
643 | 663 | </div> |
644 | | - <div id="terminal"></div> |
645 | | - <div id="info"> |
646 | | - The simple REPL provides a limited Python experience in the browser. |
647 | | - <a |
648 | | - href="https://github.com/python/cpython/blob/main/Tools/wasm/README.md" |
649 | | - > |
650 | | - Tools/wasm/README.md |
651 | | - </a> |
652 | | - contains a list of known limitations and issues. Networking, |
653 | | - subprocesses, and threading are not available. |
| 664 | + <div id="buffererror" class="error" style="display: none"> |
| 665 | + <p> |
| 666 | + <code>SharedArrayBuffer</code>, which is required for this demo, |
| 667 | + is not available in your browser environment. One common cause |
| 668 | + of this failure is loading <code>index.html</code> directly in |
| 669 | + your browser instead of using <code>server.py</code> as |
| 670 | + described in |
| 671 | + <a |
| 672 | + href="https://github.com/python/cpython/blob/main/Tools/wasm/README.md#the-web-example" |
| 673 | + > |
| 674 | + Tools/wasm/README.md |
| 675 | + </a>. |
| 676 | + </p> |
| 677 | + <p> |
| 678 | + For more details about security requirements for |
| 679 | + <code>SharedArrayBuffer</code>, see |
| 680 | + <a |
| 681 | + href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements" |
| 682 | + >this MDN page</a |
| 683 | + >. |
| 684 | + </p> |
| 685 | + <script> |
| 686 | + if (typeof SharedArrayBuffer === 'undefined') { |
| 687 | + document.getElementById('repldemo').style.display = 'none'; |
| 688 | + document.getElementById('buffererror').style.display = 'block'; |
| 689 | + } |
| 690 | + </script> |
654 | 691 | </div> |
655 | 692 | </body> |
656 | 693 | </html> |
0 commit comments