gruhn / vue-qrcode-reader

A set of Vue.js components for detecting and decoding QR codes.
https://gruhn.github.io/vue-qrcode-reader
MIT License
2.03k stars 330 forks source link

structured-clone is not defined #401

Closed ketao4869 closed 6 months ago

ketao4869 commented 6 months ago

https://ask.dcloud.net.cn/question/147298

https://github.com/search?q=repo%3Agruhn%2Fvue-qrcode-reader+structured-clone&type=code

ketao4869 commented 6 months ago

The reason is that the browser environment is too old and there is no structured-clone API yet.

I see structured-clone in the dependency package, but I don’t know where to use it.

Sec-ant commented 6 months ago

Ah, another issue caused by my careless introduction of new features🤦.

This problem lies in the the dependency zxing-wasm.

structuredClone is used here: https://github.com/Sec-ant/zxing-wasm/blob/9fcd626d57cd48b1b60c5fd095ef3b61f695b257/src/bindings/exposedReaderBindings.ts#L2

The reason is that I want to expose the default options (for users to play with) while in the meantime I do not want it to be mutated.

Good news is that it doesn't affect the core function of the package. So a simple workaround would be polyfilling a dummy structuredClone function in the global before you importing this package:

globalThis.structuredClone = _ => _;
import { QrcodeStream } from "vue-qrcode-reader";
...

I'll push a fix to remove the using of structuredClone shortly after.

Thanks for bring this issue up.

github-actions[bot] commented 6 months ago

:tada: This issue has been resolved in version 5.5.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: