~bptato/chawan#11: 
Plans for XHR?

I was wondering if there is any plan to support XHR in the mid term.

I have no numbers, but I guess adding XHR support would dramatically increase the number of sites that become functional enough with Chawan.

Status
RESOLVED CLOSED
Submitter
~ancorgs
Assigned to
No-one
Submitted
1 year, 3 days ago
Updated
2 months ago
Labels
No labels applied.

~bptato 1 year, 3 days ago

I have no numbers, but I guess adding XHR support would dramatically increase the number of sites that become functional enough with Chawan.

I wonder about that ;)

But yes, it is in the todo file, and if you look closely there is even a half-implementation at src/html/xmlhttprequest.nim. I just never got around to finishing it, so it's quite useless in its current form.

(IIRC the problem I ran into back then was that our JS callback wrapper generator could not deal with XHR callbacks. Since then, I've realized that automatic callback wrapper generators are a waste of time, now I would just do it manually with JSValues.

Though I'm more interested in cleaning up fetch() first, the XHR standard builds on top of that anyway.)

~ancorgs 11 months ago

Now that we released a new version, I can confess my secret goal was to at least pass the login screen of Agama. https://yast.opensuse.org/blog/2024-05-17/agama-8

~ancorgs 7 months ago

So let's say this page renders nothing at Chawan. https://agama-online-demo.surge.sh

How can I gather logs to make sure the lack of XHR is to blame?

bptato 7 months ago · edit

~ancorgs wrote:

So let's say this page renders nothing at Chawan. https://agama-online-demo.surge.sh

How can I gather logs to make sure the lack of XHR is to blame?

It's unlikely, because we now have XHR :P

(Though it's still not 100% complete, and very sparsely tested, so I've kept this ticket open.)

Anyway, to answer your question:

  1. check if you have scripting enabled (duh)
  2. check if you have module script tags - we don't support those yet.
  3. open the page, and check the console with M-c M-c. if you see an exception, good - you've found the issue. (I think it should even show the column number, thanks to qjs-ng.)
  4. otherwise, we're stuck with the Universal Debugger...

Let me know how it goes :)

~ancorgs 7 months ago

Yes to number 2. The page includes the javascript using this tag:

<script type="module" src="./index.js"></script>

~ancorgs 7 months ago

Which leads me to the next question regarding the sentence "we don't support those yet". How far in the roadmap is that?

bptato 7 months ago · edit

~ancorgs wrote:

Which leads me to the next question regarding the sentence "we don't support those yet". How far in the roadmap is that?

Modules are in a similar state as XHR was when you opened this ticket: I've added some basic scaffolding, and got to a point where they get compiled. However, the recursive import fetching and evaluation logic is still missing.

I do hope to get it finished eventually, but again, it's relatively low priority. Patches welcome :P

~bptato 3 months ago

Module scripts are now supported, although I took some artistic liberties. (In particular, the standard wants us to fetch dependencies in parallel, but QJS can't, so I just did it serially.)

Well, it loads modules on a single web app I was interested in (even if nothing else works...) Let me know if it's still broken on yours.

~ancorgs 3 months ago*

It certainly went way further now. It loaded the Javascript code!

I'm getting a Javascript error now, but I'm happy to have some tangible Javascript to debug. :-)

Great job!

bptato 3 months ago · edit

Nice. Feel free to report missing/broken APIs.

(Also, tip: press : (colon) to linkify URLs from error messages. Makes debugging slightly more pleasant.)

~bptato REPORTED CLOSED 2 months ago

XHR is adequately tested now, so I'll close this.

Register here or Log in to comment, or comment via email.