This enables import maps inside workers, allowing us to dynamically enable RTI.js for a project even within a worker:
if (location.search.includes("rti")) {
imports['@xenova/transformers'] = "/transformer/transformers.js-rti/dist/transformers.rti.js";
}
If no rti is in the URL, types won't be checked. Now the main issue is that the entire lib may be executed in a Worker. Since there is no access to any DOM through a Worker, we have to send and receive messages.
This is something that also will help custom UI's like in PlayCanvas Examples browser where the RTI type checked engine is running in an <iframe> while the React UI is controlling the display of the catched errors - and not the little RTI UI, that just may not fit well into existing designs.
The main goal is to enable type checking inside workers. I spent some time working on https://github.com/kungfooman/worker-with-import-map
This enables import maps inside workers, allowing us to dynamically enable RTI.js for a project even within a worker:
If no
rti
is in the URL, types won't be checked. Now the main issue is that the entire lib may be executed in aWorker
. Since there is no access to any DOM through aWorker
, we have to send and receive messages.This is something that also will help custom UI's like in PlayCanvas Examples browser where the RTI type checked engine is running in an
<iframe>
while the React UI is controlling the display of the catched errors - and not the little RTI UI, that just may not fit well into existing designs.