mathjax / MathJax-src

MathJax source code for version 3 and beyond
https://www.mathjax.org/
Apache License 2.0
2.05k stars 205 forks source link

Update the asyncLoad implementations to be more consistent, and update tests. #1109

Closed dpvc closed 3 months ago

dpvc commented 3 months ago

This PR makes the various asyncLoad implementations (node, esm, and system) operate more consistently, and updates their tests. In particular, relative file names are resolved using the root directory, while other names are used as is. That allows using package names like mathjax-full, for example (at least in the implementation where that is possible).

In addition, there is a new flag that indicates whether the asyncLoad command is synchronous, use by the font's dynamic file loading command loadDynamicFilesSync() to determine if it can work or not.

There is also a fix to FontData.js that resolves a problem with having removed the .js from file names, which are needed by asyncLoad().

The asyncLoad/node.js implementation is modified to be able to be used by both ESM and CJS modules (by calling on the #source/srouce.js file to obtain the __dirname value used to construct the root).

Finally, all the tests are updated to include tests for non-relative file names, and for the synchronous flag.