_external.ts 501 B

1234567891011121314
  1. setup.externalCodeURLs ??= {};
  2. setup.externalCodePromises ??= {};
  3. setup.externalCodePromise = (promiseID: string)=>{
  4. if(!setup.externalCodeURLs[promiseID])
  5. return Promise.resolve();
  6. setup.externalCodePromises[promiseID] ??= Promise.all(
  7. [
  8. importScripts(setup.externalCodeURLs[promiseID].code as unknown as string), // Casting to unknown because of a weird bug in the types
  9. importStyles(...setup.externalCodeURLs[promiseID].style),
  10. ]
  11. );
  12. return setup.externalCodePromises[promiseID];
  13. }