-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
help wanted: Web APIs' implementation #1047
Comments
I'd like to help! Are there other examples of specs that have been implemented so far to use as a reference point for these? I'd be interested to tackle the event or URL ones. |
I believe that the MDN docs and the WHATWG ones should suffice, they're also available in any modern browser so we can play around with those APIs. There was a version of URL in the golang version but it was removed in the rust rewrite. I'm currently working on URLSearchParams and later URL, but we can try to cooperate if you want 👍 |
Perfect! I can take a look at Events then, although I will say this is pretty intimidating, that Golang spec is almost 700 lines |
I am working on |
A good example of Web APIs implemented in plain JavaScript is jsdom. Most of the APIs we are talking about have interfaces in TypeScript which we should follow. For example |
I'm glad to know it helped you! I'll possibly leave URL for somebody else, it's far more complex than URLSearchParams and my free time is currently lacking. Feel free to pick it up after Event 👍 |
@kyranet I couldn't comment on the merged PR but shouldn't the constructor for the URL search params be |
I'm willing to give a shot at implementing the URL spec, if that's ok with everyone. I'll probably start by inspiring and / or porting the golang implementation. |
It's actually optional, Line 5 in c4bddc4
From WHATWG: https://url.spec.whatwg.org/#interface-urlsearchparams |
Use node poly fill modules where possible - no need to reinvent the wheel. With URL there is already a node module. |
For everyone here if you're confused by the interface definitions within the WhatWG, check out this doc on the official Interface Document Language :) |
@acconrad Sorry for my delay PR. Github still is down, I will do it next day. |
@ztplz don't worry, I'm not in a rush, I still need to do a final draft of the We will need to coordinate implementations though because I have flags within |
I'll grab |
@ry deno's philosophy of following browser APIs has a lot going for it, and I've been keen to see this play out in the development. One question I have is how rigidly are we following this model? a few points:
So I guess my question is does it make sense to replicate APIs that are really suffering from poor design? I understand the tradeoffs, I'd like to understand this project's philosophies. |
@mreinstein I agree that not all web APIs are created equal. For example, I do not consider the stream APIs sufficient for general purpose high concurrency servers - thus we are providing the lower-level deno.Reader/deno.Writer interfaces. Another example, the web "File" API does not sufficiently cover the myriad of posix File I/O - we provide a lower-level version of this. In both cases, I think Deno will provide the web APIs but implement them in terms of the lower-level, more generalized APIs. I don't know anything about the Audio API - it seems that's something very far off for us to consider at the moment... |
@mreinstein @ry would be good to know what level of compliance you are looking for as it relates to the Web IDL standard I referenced. For example,
And to be truly compliant, you have to use |
@kyranet :
Yeah that's just one example, I know someone else claimed |
@ry Do we need to add more type declarations for web APIs? |
@acconrad Regarding level of compliance - I don't have any particular opinions on this. Web scripts should run on Deno if they are using APIs we support - with little or no modification - that's all I care about. If you feel strongly about how this should be done, perhaps add some text to the contributing guide? @ztplz Let's add them as necessary to support specific functionality that you need. I don't want to add a bunch of interfaces for APIs that are not usable. That goes for these above APIs here - I'm fine adding EventTarget - if it's needed for some specific functionality - but let's not add abstract utilities that are not used anywhere. There are many many web APIs - we are not trying to reimplement a complete headless chrome - so please add interfaces lazily. |
@kyranet For URL, I used https://github.com/denoland/deno/blob/golang/url.js in the prototype. |
That URL implementation is clean and modern JavaScript. My feeling is something like that could be included cleanly in Deno. Some of the other polyfills aren't written as cleanly or have a lot of code to support older browsers, or rely on Node.js APIs, etc. It is a fine balance between less maintaining of code and not dragging in a whole load of stuff and keeping type safety. |
I should also point out that there is already a free test suite out there for reaching Web API compliance: https://github.com/web-platform-tests/wpt We should try to leverage these with each of the interfaces we are implementing |
We have a pretty clean URL implementation we can do a PR for if you all want. The URL polyfills have been a headache for us over the last 8 mo: https://github.com/superfly/fly.rs/blob/master/v8env/src/url.ts |
@mrkurt that would be appreciated - code looks good |
@ztplz any updates on |
To follow URL spec in WHATWG, this one would be one of the ideal packages to put :) |
Is the Web Crypto API on the list of Web APIs we want to implement? There are excellent user space JS alternatives for most of endpoints in this API, but we need some cryptographically secure random source which cannot be done in user space. |
Most likely, yes @ruphin, cryptography is pretty important and I think we should support it. |
I need a secure random source for something I'm working on. I can take a stab at implementing |
Ideally webcrypto can be added to the build, rather than adding functionality ad hoc |
@watilde the jsdom whatwg-url package leaks memory like a fiend (to the point where we were blowing up isolates with 256MB of RAM allocated trying to use it). |
@kyranet you can update this. @kitsonk added URL and I added in Event and EventTarget. I'm going to next work on improving the EventTarget implementation and then move onto CustomEvent after that. After that I think only WebWorker and WebSocket are left - what's the plan after these are all implemented? |
@acconrad Ryan is working on workers alongside with native ES module (since the TS compiler would be soon moved to a worker). |
@acconrad and websockets are in deno_std now denoland/std#84 |
@hayd I think we could possibly move client side |
Nice! So really events are the last of it this sounds like! I'll be sure to follow-up with EventTarget (finalized) and CustomEvent asap! |
Just to update - everything here is done except for |
Updated! Let me know if I'm missing any other, I'm happy to update the list 😄 |
This seems finished by #2377 |
can confirm i added the last of the Web API implementations as @kt3k pointed out, this should be all set! |
Awesome! Done a last edit to link the last PR ❤️ |
did anyone already try to enable WebAudio in deno as mentioned at the top of this historic issue? utilizing servo-media, which is written in rust like deno itself, it should be perhaps possible to add this feature by experienced deno developers with acceptable efforts. |
Previously discussed in #82, this is a meta issue to help contributors (and future ones) track some of the Web APIs in deno.
Additionally, we could later implement the Web Audio API for audio processing, and the HTML Canvas 2D Context API for image processing/generation, too.
The text was updated successfully, but these errors were encountered: