css-houdini-drafts
css-houdini-drafts copied to clipboard
[css-typed-om-2] Need an array-buffer custom property type.
To elaborate: previously we thought we might add a "worklet cache" that was some global dict of structured-clonable values, and worklets could list keys from the cache that they depend on and get updated on change, just like they can with custom properties. It was intended that you use this for things like images, fonts, etc.
In general, this doesn't offer anything that just using a custom property does - just set the custom prop on the root element, give it the value you want, and make your worklet depend on that prop. Custom props are better in some ways, too, as they're not required to be global - you can change the value being passed in for different subtrees if necessary.
The cache did have the advantage that it fairly naturally supported various types of binary data, like images. But we're adding image and font objects to the Typed OM, and they're allowed in the custom property grammar, so you can just pipe those through that way. One big unfilled hole is arbitrary binary data, like a big list of vertexes you want to use in a PaintWorklet. The cache object could just take an ArrayBuffer, but you can't put that into a custom prop right now.
So, we need to introduce some Typed OM value that wraps an array buffer. This is intended to be set and read via the Typed OM, so it doesn't necessarily need a serialization, but it might be nice to provide such - I suggest an arraybuffer() function that takes the type of the buffer, and a base-64-encoded string for the data.
This can be very handy in Flutter for web. We need an efficient way of passing paint instructions to the paintlet. The paint instructions are typically more than images. In our current Houdini proof of concept we encode these instructions as JSON, but that's inefficient.