Build the wasm pack move the pkg to the public folder and add global text decoder in .js file of wasm_client.
wasm-pack build --target web --release
if (typeof TextDecoder === 'undefined') {
globalThis.TextDecoder = class TextDecoder {
decode(buffer) {
return String.fromCharCode.apply(null, new Uint8Array(buffer));
}
};
}
if (typeof TextEncoder === 'undefined') {
globalThis.TextEncoder = class TextEncoder {
encode(str) {
const arr = new Uint8Array(str.length);
for (let i = 0; i < str.length; i++) arr[i] = str.charCodeAt(i);
return arr;
}
};
}