Comments (18)
I've started work on ReadableStream
in https://github.com/Redfire75369/spiderfire/tree/feature/readable-stream.
It will take a while, but it should be compliant with the WHATWG Streams spec.
from spiderfire.
Deno's implementation is written in JS. (https://github.com/denoland/deno/blob/d1f4d81dcf6a03463d82a89d058337acecca0588/ext/web/06_streams.js)
from spiderfire.
from spiderfire.
streams are the only thing keeping me from using this in prod btw, so implement streams and I'll help you END the V8 monopoly 😎
from spiderfire.
As of Bug 1795914, the Streams implementation in SpiderMonkey has been removed. Since streams are a relatively complex spec, this means they will delayed for now, while more important features are implemented.
from spiderfire.
Streams API (ReadableStream
, WritableStream
, TransformStream
, ReadableStreamBYOBReader
, ReadableStreamBYOBRequest
) are implemented on Mozilla Firefox 116.0a1 20230703204942. It looks like WHATWG Streams are implemented in DOM: Streams https://bugzilla.mozilla.org/buglist.cgi?product=Core&component=DOM%3A%20Streams.
from spiderfire.
@Redfire75369 Rather than reimplement the streams spec from scratch, which will take considerable time, Spiderfire could use this fork of mozjs (which we're currently using for WinterJS): https://github.com/wasmerio/mozjs/tree/wasi-gecko
The fork uses this version of SpiderMonkey that has implementations for both readable and writable streams.
We also have an implementation for TransformStream
(missing back-pressure ATM), TextEncoderStream
and TextDecoderStream
in WinterJS that could end up being useful to have in Spiderfire.
from spiderfire.
Although this is certainly an option, I have chosen not to go with that approach, since even if the relevant patches are reverted, the implementation is still unmaintained and may lead to issues when upgrading to more recent mozjs versions.
Also, last I checked, they never completed the WritableStream
implementation.
from spiderfire.
It would be interesting if servo and spiderfire could share streams impl (at least part of it).
from spiderfire.
Isn't this all implemented using Rust? Deno's WHATWG Streams implementation works as expected. Just use what Deno uses?
from spiderfire.
Use that? Complie to WASM if necessary? Here's txiki.js' implementation in C https://github.com/saghul/txiki.js/blob/9cad93b8299cb61b6bcff081ac5a83b97c9d2404/src/streams.c.
from spiderfire.
The issue is not the implementation being written in JS per se. The issue is that its difficult to interface with streams and to have things like native sources through the Rust code.
from spiderfire.
I thought Rust was very flexible at JavaScript/WASM <=> Rust interface?
Anyway, you'll figure it out eventually.
from spiderfire.
@guest271314 you're probably thinking of wasm_bindgen, which is an entirely different story.
from spiderfire.
What I'm saying is various JavaScript runtimes have figured out how to implement WHATWG Streams. You any means necessary. wasm_bindgen, whatever. Just make sure the streams are transferable, the same as they are in the browser.
from spiderfire.
Additionally, make sure the streams actually stream. Bun had an issue with the ReadableStream
implementation where in the server would read the entire stream before serving the data to the client. CloudFlare's Workerd implementation does not allow, by deliberate decision of the maintainers, an uploaded stream to be served to a subsequent request. Don't do that. That is one way we can implement close to full-duplex streaming in the browser https://gist.github.com/guest271314/4847c70be203ee7cd4c8a6d6a9bca1d3, save for the edge case of between a ServiceWorker
and a WindowClient
on Chromium, as WHATWG Fetch still has not spelled out the mechanics of full-duplex streaming in the browser, while deno
and node
both support full-duplex streaming using fetch()
https://github.com/guest271314/telnet-client.
from spiderfire.
Pardon, the telnet-client repository is a different experiment, is one way I implement full-duplex streaming from the browser
- https://github.com/guest271314/native-messaging-deno/tree/fetch-duplex
- https://github.com/guest271314/native-messaging-nodejs/tree/full-duplex
from spiderfire.
I'll be checking back here periodically. FWIW just added spiderfire to this list https://gist.github.com/guest271314/bd292fc33e1b30dede0643a283fadc6a. Good luck!
from spiderfire.
Related Issues (20)
- JavaScript API Documentation
- URLSearchParams in URL Module HOT 1
- TextDecoder and TextEncoder APIs HOT 1
- Improve Console Implementation HOT 1
- Dropping a context segfaults when native async functions have run HOT 10
- Is it possible to create child classes via #[js_class]? HOT 6
- Looping over response headers with `for... of` results in a segfault HOT 2
- Error when Values are concurrently rooted HOT 37
- Adding Docker build step to Spiderfire.
- Macro parsing succeeds on invalid input HOT 4
- Race condition in the event loop? HOT 8
- Native inheritance/prototype chaining is not working correctly HOT 1
- Panic when printing a prototype HOT 1
- Using clearInterval from inside the setInterval callback does not clear the interval
- Converting an object with a bad toString implementation to a string crashes SpiderFire HOT 1
- Objects with getters that fail do not trigger an error HOT 1
- Strings with invalid UTF-16 codepoints cause SpiderFire to crash HOT 1
- Opt<T> does not respect passing undefined explicitly HOT 4
- get_private and get_mut_private don't work with subclasses HOT 2
- The event loop doesn't play nice with other async code
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spiderfire.