Add HTML backend support to playground#439
Conversation
antocuni
left a comment
There was a problem hiding this comment.
thank you @aisipos.
I have few minor comments:
-
I think that
--spyast-js=relativeis good enough, but also including the js in the wheel it's a good idea, so we should keep both changes -
I think that "wasm backend" is misleading, because on the playground we never generate wasm (and even if we did, it would be through the "C" backend, we don't have any "wasm backend"). I think that the best is to label it as
--format(like the CLI option), and the options should be "default", "spy", "ast" and "html" (--format=spyis valid only for redshift, I think). -
I think that "HTML" should be the default format for
spy parsein the playground, but I'm happy to be convinced otherwise.
And one major comment: clicking on the HTML nodes doesn't seem to work.
If I click on any collapsible/expandable node, I get this in the console:
Uncaught SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL 'http://localhost:8000/#s0:4,6,9,11,14,17,18,20,22;s1:4,6,7,8,10,12,13,14,16,17,19,21' cannot be created in a document with origin 'http://localhost:8000' and URL 'about:srcdoc'.
at _writePageHash (about:srcdoc:205:13)
I think that replaceState is used by spyast.js to make it possible to use the "back" button. If we can keep that behavior it would be awesome, else we might decide to just turn it off for the playground case.
One fix for this is to use an object instead of an iframe: def _show_html_output(html_content: str) -> None:
ltk.find("#terminal").hide()
ltk.find("#html-output").show()
blob = ltk.window.Blob.new([html_content], ltk.to_js({"type" : 'text/html'}))
url = ltk.window.URL.createObjectURL(blob)
ltk.window.jQuery("#html-frame").prop("data", url) '<button class="maximize-btn">⤢</button>'
- '<iframe id="html-frame" style="width:100%;height:600px;border:none"></iframe>'
+ '<object id="html-frame" type="text/html" style="width:100%;height:600px;border:none"></object>'
"</div>"In theory creating a blob and url is redundant, since you could just insert the HTML content directly inside the |
I agree here from a UX perspective - the backend label is a little confusing. One neat option in the playground would be to always have it run and dispay the results of |
Fixes #425.
Add several features that allow for displaying the HTML backend output in the playground:
WASMandHTML:SpyTyper.spy_command. This was needed to know when the HTML output from the compiler was ready.<script src="spyast/spyast.js"></script>You can test this locally via: