Constructs a new canvas worker.
The ID of the worker.
The code that the worker should run. It's common to use a hybrid code module
for as the sandbox application. This means the code of the host and the workers is identical,
they just construct different code path on load/init. In such case, the source can simply be
new URL(import.meta.url).
The canvas element to draw to.
The application options.
The canvas element that this worker should handle. This is purely for informational purposes on the host side.
The offscreen canvas that we created for this worker.
The ID of this worker.
ReadonlyoptionsThe application options for the worker.
These are usually very similar, if not identical, to the host application options. Workers just usually get a different viewport assigned to them, correlating with the canvas element in the DOM that they draw to.
ReadonlyworkerThe web worker instance itself.
The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
Optionaloptions: boolean | AddEventListenerOptionsThe dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.
Posts a message to the worker.
As messages to workers are posted instead of sent, there is no delivery feedback.
The message to post.
Optionaltransfer: Transferable[]The transferables to transfer to the worker with this message.
The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.
Optionaloptions: boolean | EventListenerOptions
The canvas worker handles a web worker instance in the canvas sandbox host.
It provides a thin abstraction over the web worker IPC messaging.