Previously, RenderingContext and OffscreenRenderingContext were enums, which required the (only) module containing these enum declarations to know all possible context types upfront. When these types are declared as protocols, separate modules can add new types and add conformances to this protocol on case-by-case basis.
In a future PR this allows us to split Canvas, WebGL1, WebGL2, and WebGPU APIs into separate modules.
I've also made getContext calls type safe, where users now pass the type of desired context instead of their IDs.
Previously,
RenderingContext
andOffscreenRenderingContext
were enums, which required the (only) module containing these enum declarations to know all possible context types upfront. When these types are declared as protocols, separate modules can add new types and add conformances to this protocol on case-by-case basis.In a future PR this allows us to split Canvas, WebGL1, WebGL2, and WebGPU APIs into separate modules.
I've also made
getContext
calls type safe, where users now pass the type of desired context instead of their IDs.