From 13491aa7df0f763ce24b8863077db14cf612e83d Mon Sep 17 00:00:00 2001 From: Rachel <508861+Ryex@users.noreply.github.com> Date: Mon, 18 Mar 2024 18:47:45 -0700 Subject: [PATCH] Fix async stream iteration on chromium Signed-off-by: Rachel <508861+Ryex@users.noreply.github.com> --- www/css/dark.css | 24 ++----- www/index.html | 113 +++++++++++++++++--------------- www/src/ic10_highlight_rules.js | 2 +- www/src/index.js | 25 +++++-- 4 files changed, 90 insertions(+), 74 deletions(-) diff --git a/www/css/dark.css b/www/css/dark.css index e1094b0..aa1df3e 100644 --- a/www/css/dark.css +++ b/www/css/dark.css @@ -42,13 +42,12 @@ code { } .navbar-brand { float: left; - height: 20px; padding: 5px 5px; font-size: 18px; - line-height: 20px; } .navbar-default .navbar-brand { color: #fff; + text-wrap: nowrap; } .navbar-brand a { @@ -59,6 +58,7 @@ code { padding-left: 0; margin-bottom: 0; list-style: none; + flex-wrap: nowrap; } ol, ul { @@ -74,24 +74,12 @@ ol, ul { } .navbar-default .navbar-text { color: #fff; + text-wrap: nowrap; } .navbar-text { - margin-top: 5px; - margin-bottom: 5px; padding: 0; position: relative; } -@media (min-width: 768px) { - .navbar-right { - float: right !important; - margin-right: -15px; - } -} -@media (min-width: 768px) { - .navbar-nav > li { - float: left; - } -} .navbar-nav { margin: 7.5px -15px; display: block; @@ -133,7 +121,9 @@ ol, ul { @media (min-width: 768px) { .navbar-text { float: left; - margin-right: 15px; - margin-left: 15px; } } +.navbar-nav > p { + margin-bottom: 0; + display: inline-block; +} diff --git a/www/index.html b/www/index.html index 174a2af..87fcd28 100644 --- a/www/index.html +++ b/www/index.html @@ -30,7 +30,7 @@ #editor { position: relative; width: 100%; - height: calc(100vh - 70px) ; + height: calc(100vh - 70px); top: 0; right: 0; bottom: 0; @@ -44,59 +44,68 @@
diff --git a/www/src/ic10_highlight_rules.js b/www/src/ic10_highlight_rules.js index c762599..193f353 100644 --- a/www/src/ic10_highlight_rules.js +++ b/www/src/ic10_highlight_rules.js @@ -296,7 +296,7 @@ var IC10HighlightRules = function() { token: ["support.function", "paren.lparen", "string.quoted", "paren.rparen"], regex: /\b(HASH)(\()(\".*\")(\))/, }, { - token: "variable.other", + token: "entity.name", regex: /\b[a-zA-Z_.][a-zA-Z0-9_.]*\b/, }] }; diff --git a/www/src/index.js b/www/src/index.js index e650ccb..4e24220 100644 --- a/www/src/index.js +++ b/www/src/index.js @@ -154,13 +154,30 @@ async function concatUintArrays(arrays) { return new Uint8Array(buffer); } +async function* streamAsyncIterator(stream) { + // Get a lock on the stream + const reader = stream.getReader(); + + try { + while (true) { + // Read from the stream + const {done, value} = await reader.read(); + if (done) return; + yield value; + } + } + finally { + reader.releaseLock(); + } +} + async function compress(bytes) { const s = new Blob([bytes]).stream(); const cs = s.pipeThrough( - new CompressionStream('gzip') + new CompressionStream('deflate-raw') ); const chunks = []; - for await (const chunk of cs) { + for await (const chunk of streamAsyncIterator(cs)) { chunks.push(chunk); } return await concatUintArrays(chunks); @@ -169,10 +186,10 @@ async function compress(bytes) { async function decompress(bytes) { const s = new Blob([bytes]).stream(); const ds = s.pipeThrough( - new DecompressionStream('gzip') + new DecompressionStream('deflate-raw') ); const chunks = []; - for await (const chunk of ds) { + for await (const chunk of streamAsyncIterator(ds)) { chunks.push(chunk); } return await concatUintArrays(chunks);