web/webcodecs: instantiate polyfill once per lifetime

This commit is contained in:
dumbmoron 2024-09-03 18:19:46 +00:00
parent 5da28b3f22
commit 452d0e037c
No known key found for this signature in database

View file

@ -6,12 +6,12 @@ const has = <T extends object>(obj: T, key: string) => {
}
export default class WebCodecsWrapper {
#ready?: Promise<void>;
static #ready?: Promise<void>;
async load() {
LibAV.base = '/_libav';
if (typeof this.#ready === 'undefined') {
this.#ready = LibAVPolyfill.load({
if (typeof WebCodecsWrapper.#ready === 'undefined') {
WebCodecsWrapper.#ready = LibAVPolyfill.load({
polyfill: true,
LibAV,
libavOptions: {
@ -21,7 +21,7 @@ export default class WebCodecsWrapper {
});
}
await this.#ready;
await WebCodecsWrapper.#ready;
}
// FIXME: save me generics. generics save me