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
Add support for other workers/worklets #54
Add support for other workers/worklets #54
Conversation
- additionally, rename a function for easier debugging
|
Nice! I am super excited about this PR! |
|
Awesome, great to hear! Any thoughts as to the above questions? Also I noticed that #49 is open and adds another worker that I had missed on my list. Shall we add that to the major release? |
animationworklet and layout worklet don't have implementations in any browsers yet so I'll suggest that we add them as a feature once that happens.
| @@ -0,0 +1,6 @@ | |||
| export function createURLPaintWorkletFactory(url) { | |||
| return async function PaintWorkletFactory(options) { | |||
| return await CSS.paintWorklet.addModule(url, options); | |||
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.
So there's a minor issue here. paintWorklet isn't necessarily supported in all browsers, and as such, CSS.paintWorklet may not be defined. We have a few options.
- Leave code as-is to throw the referenceerror. Pros: we don't have to take an error handling stance. Cons: it might not be clear to the developer what's happening.
- Catch the error and throw a more explanatory error
- In the case that it fails, return some other object from the function. Pros: we won't throw runtime exceptions. Cons: it might be unclear to the developer when their paint call in CSS just doesn't work.
- Log a debug statement rather than throw an error?
Let me know what approach you'd like me to take here.
|
Ok I think we're close to there, certainly ready for a review. The outstanding questions are:
Let me know if anything else is unclear, of course happy to answer any questions or make any changes. |
47e50c0
to
638fe78
Compare
Co-Authored-By: Hugh Rawlinson <hughr2005@gmail.com>
638fe78
to
de76260
Compare
|
This is so awesome, I'm so sorry it took this long to get to it, life stuff and all that. Thank you so much for all this work! |
|
Let me know if you'd be interested on maintaining this project, unfortunately, my current situation will not allow me to continue with development. :( |
|
Thanks @darionco! I would certainly consider that 😄 Would you be able to publish a new version of the package with this change? |
|
@hughrawlinson I have invited you as a collaborator for this project, if you give me your npm username I'll add you as collaborator there as well so you can publish new versions of the package. |
|
Thanks! Same username as here - https://www.npmjs.com/~hughrawlinson 😄 |
|
Done, thank you for your contributions! Let me know if I can help in any other way! |

Sorry for the delay - here's the beginnings of a PR to address #52.
It works just fine in my own test. But right now it only supports Base64 Audio Worklets. The other things that need support are:
Animation WorkletLayout WorkletAnimation WorkletLayout WorkletAnimation WorkletLayout WorkletGiven how much there is to add support for, I wonder if it's worth changing the structure of the helper directory a little so that there isn't so much riding on the filenames?
A problem that cropped up is that AudioWorklet doesn't exist in Node. I have the helper method throwing an error, but would love to hear your take on what should be done about that. Would it be better to fail during compile time based on the target?
It's also not clear that Paint Worklet and Animation Worklet are widely supported. I'll speak to some people and try to figure out the utility at this point. Once AudioWorklet is in, adding the others should be fairly straightforward based on that example. Web Audio API finally made it to Recommendation status at the W3C last week.
Good news is that I don't think this patch will require a major version bump - I was able to keep the original 'pattern' option around, so that this isn't a breaking change.
I plan to continue working on adding support for the other Worklets in the matrix above - although depending on what you think it might make sense to split this work out into multiple PRs rather than have all in one - and maybe first focus on AudioWorklet?
Also, is there a testing strategy? I would love to provide some tests for this if that's useful - just not really sure how to.
Thanks!