-
Notifications
You must be signed in to change notification settings - Fork 165
Add two demos using streams for PNG manipulation #911
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
Conversation
Great stuff!
As a general rule, any time you're using General comments:
const {value, done} = await reader.read(); inside a loop in an async function is much easier and cleaner that using a It took me a while to understand what "Unpack chunks of a PNG" was doing. It would probably benefit from a bit more documentation. |
I have seen TransformStream in the spec, but without the browser support I felt not encouraged enough to build the whole demo against it if I cannot test the result in at least Chrome. Is there some kind of shim I could use to patch TransformStreams to browsers which support ReadableStream and WritableStream? You could not make me happier with your statement about Should I make the code changes here in the spec's repository in the demo directory? I also just filed a PR against MDN's repository. I am not shure they support changes there. |
It's available in Chrome with the experimental web-platform-features flag enabled: chrome://flags/#enable-experimental-web-platform-features It will hopefully be turned on by default in version 67. https://streams.spec.whatwg.org/demos/transforms/transform-stream-polyfill.js is the outdated but mostly compatible polyfill used by the demos linked from the standard.
Hopefully you'll be able to use this sooner rather than later: #778
If we cannot find a compromise with MDN then that would be my preference, yes. |
Hey @ricea, the folks at MDN merged my updates now using TransformStreams! |
demos/index.html
Outdated
@@ -25,6 +25,12 @@ <h1>Streams Demos</h1> | |||
|
|||
<dt><a href="https://fetch-progress.anthum.com/">Progress indicators with Service Workers and Fetch</a> | <a href="https://github.com/AnthumChris/fetch-progress-indicators">(Source Code)</a> | |||
<dd>Streams intercept Service Worker <code>FetchEvent</code> and <code>fetch()</code> statements to show progress indicators. See <a href="https://github.com/AnthumChris/fetch-progress-indicators#browser-support">browser support</a> notes. | |||
|
|||
<dt><a href="http://mdn.github.io/dom-examples/streams/grayscale-png/">Grayscale a PNG</a> | <a href="https://github.com/mdn/dom-examples/tree/master/streams/grayscale-png">(Source Code)</a> | |||
<dd>A PNG gets fetched to receive a ReadableStream on it, than the PNG data is converted to black and white and enqueued into another ReadableStream. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you update this comment to indicate that it uses TransformStream?
Also, in the demo itself, it would nice if it displayed a message in the page when TransformStream is not defined, to avoid confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to block this on the changing http://mdn.github.io/dom-examples/streams/grayscale-png/. The MDN people might not agree to that anyway.
I added two demos I wrote for MDN to the list of your demos, if you'd like!