#web workflow with code.cp.org
1 messages ยท Page 1 of 1 (latest)
1 may be less code to host though
though the js could be hosted from cp.org too
web workflow with code.cp.org
How is the host page option different than the way it works now?
Are you thinking more of a non-hidden iframe?
Yeah, the proxying option is what I was thinking you meant.
are you thinking an iframe is better?
or we could have js that structures an html skeleton to fit what we have now (in html)
I'm kind of thinking with having multiple workflows the iframe is the option that makes the most sense.
I believe so
and that page would do the postmessage stuff
That's what I was going to try first.
Getting the serial messages back and forth is the tricky bit.
kk, want me to make an html stub that loads some js for the device side?
Let me try some stuff for a few hours first. I want to experiment with what's possible before we start making changes.
I'm on a clock so please let me know when you know what you need from me.
Yeah, the main issue is I don't know what I need from you at this point.
Sounds good
Ok, figured something out that isn't working. it's still blocking loading http into the iframe when the page is https because of mixed content.
kk, so only the reverse works
Right
anything I can add for you to test with?
I'm thinking we could do circuitpython.local/code/
Yeah, that will work. Something that responds to messages, but it should load a js file from code.circuitpython.org.
I figured out how to fix the https auto forwarding. I went to chrome://net-internals/#hsts and entered code.circuitpython.org into the Delete domain security policies section.
Ok, maybe just a very minimal static page like and then I can get it to dynamically load stuff in with JavaScript:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Code Editor Message Handler</title>
</head>
<body>
<script type="module" src="https://code.circuitpython.org/assets/js/device.js"></script>
</body>
</html>
I just created an empty device.js file.
@flat grotto ^^
kk, what device do you need a build for? want one that loads the device.js locally?
Yeah. The thought is that device.js bootstraps it, loads in any content and js that it needs to "run" on the device and it makes use of the existing web workflow framework to get the data.
No, I think that will automatically be triggered when it tries to access fs
kk
I might change my mind in the future, but it's static and it doesn't have anything sensitive in the file.
thanks
what board do you need it for?
Adafruit ESP32-S3 TFT
is it supposed to load device.js ok?
Currently device.js is empty, but yes.
Oof. Can we pass a header that tells CORS that it's ok?
Let me try putting some javascript in it and see if it stops coming back as text/html
Oh, hmm. Ok, let me fix that first.
I mean it's there: https://github.com/circuitpython/web-editor/blob/main/assets/js/device.js
It's jsut not available as a page
is snowpack optimizing it away?
could be
Cool. I'm seeing if adding something to the file fixes it.
Sure, I was trying to keep it minimal to keep the size down
Ok, device.js no longer 404s
you should be able to test with the above build
Yep. It even runs the javascript
do you think we should have the existing /edit/ upgrade or just have a separate /code/ ?
This will likely take longer than we have before Friday to get fully functioning, but maybe I can get something very basic working as a proof of concept before then.
ya, np
I can at least hook up the html and you can tweak it
the js name should probably have a version number too
For now, let's leave it separate and once it works, we can make it more automatic.
๐
For the version number, how did we want to handle that since it's hard coded on the device?
k, will make a PR
I think we just have device-8.js on code.cp.org
and ensure it works with all versions of 8
the css does this now too
Oh, for the CP version. Ok
ya, have multiple versions on the online site in the future
I should be able to get it to query the device and handle it automatically, but as a fallback we can do that.
ah, true. I just want us to have a way to keep older versions working
I understand. It could end up being a juggling act if we have multiple versions of the same file. We'll see what ends up working first before we get too far ahead of ourselves.
Ok, I finally have a test message working when page is loaded via http. Tomorrow I'll up the security and see what needs to be done to get around that.
Ok, so the http->https autoforward issue keeps reasserting itself, so before I get too far, I'm going to try the microbit approach and bootstrap load the editor into the cpy-XXXXXX.local/code/ space.
what were you trying with the iframe?
I was trying to have it proxy the websocket and http calls.
It fixes the private network issue, but the https autoforwarding issue is too big to ignore.
It will make it awkward when dealing with changing connection methods, but maybe not as much as I was thinking.
it autoforwards the iframe contents?
No, the approach I was taking is the iframe would establish the websocket and local file system calls and then use postmessage to transfer the info back and forth to the main editor.
That approach would work fine for the private network issue, but because now I realize it would require people to fix the https autoforward issue every time they went to the website
At least if they use chrome
right because code.cp.org would need to be http to load the hidden http device page
๐
Ok, basic bootstrapping is working which was the tricky bit. If you go to /code/ on the device it should load the full code editor, though you can't do much with it yet since I need to rework the web workflow calls.
I gotta grab some lunch, head to the office, prep for S&T, and then I might have a bit more time to work on this before the meeting.
great! I'll try it out
looks good! It got me excited for it to work.
๐
I tried to add the # bits but it still didn't work
the original html page should probably have a "uh oh, it looks like you are offline"
Right, I'm going to just have it grab the host from the url and assume web workflow
Yeah, I thought of that. I was thinking we could display a link to the offline version. I also want to fix the favicon
๐
Ok, I fixed it so it's now loading with the # bits. Basically, the window load event wasn't being triggered and I had to add that after all the scripts had loaded. I still need to rework it so those bits aren't even necessary. However, it appears to be 100% functional now.