gh-84461: Improve WebAssembly in-browser demo (GH-91879)

* Buffer standard input line-by-line

* Add non-root .editorconfig for JS & HTML indent

* Add support for clearing REPL with CTRL+L

* Support unicode in stdout and stderr

* Remove \r\n normalization

* Note that local .editorconfig file extends root

* Only normalize lone \r characters (convert to \n)

* Skip non-printable characters in buffered input

* Fix Safari bug (regex lookbehind not supported)

Co-authored-by: Christian Heimes <christian@python.org>
(cherry picked from commit a8e333d79a)

Co-authored-by: Trey Hunner <trey@treyhunner.com>
This commit is contained in:
Miss Islington (bot) 2022-07-01 03:16:25 -07:00 committed by GitHub
parent 113b309f18
commit ca58ca8641
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 99 additions and 25 deletions

View file

@ -35,15 +35,11 @@ class StdinBuffer {
}
}
const stdoutBufSize = 128;
const stdoutBuf = new Int32Array()
let index = 0;
const stdout = (charCode) => {
if (charCode) {
postMessage({
type: 'stdout',
stdout: String.fromCharCode(charCode),
stdout: charCode,
})
} else {
console.log(typeof charCode, charCode)
@ -54,7 +50,7 @@ const stderr = (charCode) => {
if (charCode) {
postMessage({
type: 'stderr',
stderr: String.fromCharCode(charCode),
stderr: charCode,
})
} else {
console.log(typeof charCode, charCode)