Improving reliability of threaded rendering, separating JS Utils into separate files.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
49e94317d4
commit
687b14429a
18 changed files with 285 additions and 197 deletions
|
@ -18,7 +18,7 @@
|
|||
|
||||
import { Module } from "./common.mjs"
|
||||
import { CanvasInterface, DialogInterface } from "./interface.mjs"
|
||||
import { textsup } from "../utils.mjs"
|
||||
import { textsup } from "../utils/index.mjs"
|
||||
import { Expression } from "../math/index.mjs"
|
||||
import Latex from "./latex.mjs"
|
||||
import Objects from "./objects.mjs"
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
import { Module } from "./common.mjs"
|
||||
import { textsub } from "../utils.mjs"
|
||||
import { textsub } from "../utils/index.mjs"
|
||||
|
||||
class ObjectsAPI extends Module {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue