Stream: jco

Topic: ReadableStream to InputStream


view this post on Zulip Colin D Murphy (Jan 17 2025 at 22:20):

@Guy Bedford I've been working on a series of examples of using a component for the Coalition for Content Provenance and Authenticity (C2PA). I have both web and nodeJS examples working.
For the transpiled JS for browsers, it would be nice if we had a utility to convert a https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream to an InputStream (or 0.3 Stream). Is that covered in the issue Jco transpile: implementation of wasi-io for Web?

My examples: https://github.com/cdmurph32/c2pa-component/tree/v24

The ReadableStream interface of the Streams API represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object.
Tasks streams.read streams.blocking-read streams.skip streams.blocking-skip streams.subscribe-to-input-stream streams.drop-input-stream streams.check-write streams.write streams.blocking-write-and-...
WASI P2 component for C2PA. Contribute to cdmurph32/c2pa-component development by creating an account on GitHub.

view this post on Zulip Guy Bedford (Jan 21 2025 at 16:48):

Thanks for sharing, this looks great! For Preview2 you would need to write an adapter to convert from the preview2 polling IO into a readable stream. We do something similar for the Node.js WASI implementation already in the preview2-shims project, but don't have anything existing for the browser currently.

@Calvin Prewitt is working on a PR (https://github.com/bytecodealliance/jco/pull/518) to support async bindings for preview2-shims, which could then in theory support a preview2 web streams adapter.

Looking forward, Preview3 streams will embed async and support web streams from the start.

If you're interested in more of the details happy to discuss further as well.

Adds options to jco transpile and jco types: .addOption(new Option('--async-mode [mode]', 'use async imports and exports').choices(['sync', 'jspi', 'asyncify&#39...

view this post on Zulip Colin D Murphy (Jan 21 2025 at 17:36):

That's great about Preview 3. That should probably be good enough. Will it likely land in the first half of the year?

view this post on Zulip Guy Bedford (Jan 21 2025 at 17:40):

Good to hear. I can't give really give an estimate right now unfortunately. But in terms of unblocking the workflow today it might well be worth trying to use PR 518 and writing a web streams adapter against it similarly to our Node.js stream wrapper approach, as that PR is ready for testing. Happy to talk this through more if you're interested.

view this post on Zulip Colin D Murphy (Jan 21 2025 at 17:41):

OK. I'll give that a shot.


Last updated: Jan 24 2025 at 00:11 UTC