1// Stub polyfill for TextDecoder and TextEncoder based on: 2// https://github.com/wasm-bindgen/wasm-bindgen/pull/3017/files 3// 4// According to docs this shouldn't be necessary in the latest version of wasm-bindgen, but at least on 5// wasm-bindgen v0.2.104 the audio worklet fails to initialize without this polyfill. 6 7if (!globalThis.TextDecoder) { 8 globalThis.TextDecoder = class TextDecoder { 9 decode(arg) { 10 if (typeof arg !== "undefined") { 11 throw Error("TextDecoder stub called"); 12 } else { 13 return ""; 14 } 15 } 16 }; 17} 18 19if (!globalThis.TextEncoder) { 20 globalThis.TextEncoder = class TextEncoder { 21 encode(arg) { 22 if (typeof arg !== "undefined") { 23 throw Error("TextEncoder stub called"); 24 } else { 25 return new Uint8Array(0); 26 } 27 } 28 }; 29} 30 31export function run_polyfill() {}