Improving reliability of threaded rendering, separating JS Utils into separate files.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Adsooi 2024-10-28 18:45:34 +01:00
parent 49e94317d4
commit 687b14429a
Signed by: Ad5001
GPG key ID: EF45F9C6AFE20160
18 changed files with 285 additions and 197 deletions

View file

@ -97,6 +97,7 @@ class LatexAPI extends Module {
* true if latex has been enabled by the user, false otherwise.
*/
this.enabled = false
this.promises = new Set()
}
/**
@ -139,9 +140,12 @@ class LatexAPI extends Module {
if(!this.initialized) throw new Error("Attempting requestAsyncRender before initialize!")
let render
if(this.#latex.supportsAsyncRender) {
console.trace()
this.emit(new AsyncRenderStartedEvent(markup, fontSize, color))
render = await this.#latex.renderAsync(markup, fontSize, color)
// Storing promise so that it does not get dereferenced.
const promise = this.#latex.renderAsync(markup, fontSize, color)
this.promises.add(promise)
render = await promise
this.promises.delete(promise)
this.emit(new AsyncRenderFinishedEvent(markup, fontSize, color))
} else {
render = this.#latex.renderSync(markup, fontSize, color)