1// Single shared instance of the qhull-wasm module.
2//
3// In a Vite bundle the .wasm cannot be located next to the glue at runtime, so
4// we resolve its URL via Vite's `?url` import and feed it to Emscripten's
5// `locateFile`.
6import { loadQhull, type Qhull } from 'qhull-wasm'
7import wasmUrl from 'qhull-wasm/dist/qhull.wasm?url'
9let qhullPromise: Promise<Qhull> | null = null
11export function getQhull(): Promise<Qhull> {
12 if (!qhullPromise) {
13 qhullPromise = loadQhull({ locateFile: () => wasmUrl })
14 }
15 return qhullPromise
16}
18export type { Qhull }