Skip to content

Update weborker code to work with te CDN #1285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open

Conversation

dpvc
Copy link
Member

@dpvc dpvc commented Jun 22, 2025

This PR resolves the problems we are having with using the worker code from the CDN. It rurns out that jsdelivr won't serve the HTML file for the worker pool (it wraps it in al in a

), so it doesn't run the code that starts the worker.  That ends up being a pretty big problem.

I will write more about it tomorrow, but for now, the big change is to remove the worker pool entirely and have the WebWorker.ts file create the worker itself and communicate directly with it. The trick is to make a dynamically created blob object that imports the needed CDN file after a bit of setup. Because the CDN has access-control headers that allow that, it works. It also works if you host it on your own server, as there is no cross-origin issue.

This is a cleaner solution than our original, which is nice. I was able to remove a lot of hacky code from the liteDOM, for example.

There is still an issue with the clearspeak menu, but I wanted to give you a chance to try it out and see what you think.

You will need to rebuild everything, including running the lab:sre script.

@dpvc dpvc requested a review from zorkow June 22, 2025 23:15
@dpvc dpvc added this to the v4.0 milestone Jun 22, 2025
Copy link

codecov bot commented Jun 22, 2025

Codecov Report

Attention: Patch coverage is 50.52632% with 47 lines in your changes missing coverage. Please review.

Project coverage is 86.72%. Comparing base (62226e2) to head (81c1fa5).

Files with missing lines Patch % Lines
ts/adaptors/liteAdaptor.ts 39.02% 25 Missing ⚠️
ts/adaptors/HTMLAdaptor.ts 18.51% 22 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1285      +/-   ##
===========================================
+ Coverage    86.69%   86.72%   +0.02%     
===========================================
  Files          337      337              
  Lines        84107    83955     -152     
  Branches      3126     4750    +1624     
===========================================
- Hits         72919    72812     -107     
+ Misses       11188    11120      -68     
- Partials         0       23      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@zorkow zorkow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment.
Otherwise this looks great. I particularly like that the LiteAdaptor, in particular LiteElement, is no longer dependent on mathjax at all.

const file = self.SREfeature.json + '/' + locale + '.json';
return fetch(file).then((data) => data.json()).catch((err) => console.log(err));
}
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this happen in a separate method, as this is the only part that depends on the shape of the SRE configuration object, so it is clear where it needs to be changed in case that is changed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've move the SREfeature changes to within the speech-worker.ts file, so all the SRE-related stuff is there. Does that resolve this issue for you?

@dpvc
Copy link
Member Author

dpvc commented Jun 24, 2025

I particularly like that the LiteAdaptor, in particular LiteElement, is no longer dependent on mathjax at all.

Yes, I am glad to be able to remove that code as well. It was never ideal, but worked for what we needed. This is much cleaner, so for that reason, I'm glad we ran into the problem and were able to fix it in a better way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants