Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(barcode-scanning): support the Web platform #20

Open
piotr-cz opened this issue Mar 13, 2023 · 12 comments · May be fixed by #52
Open

feat(barcode-scanning): support the Web platform #20

piotr-cz opened this issue Mar 13, 2023 · 12 comments · May be fixed by #52

Comments

@piotr-cz
Copy link

Is your feature request related to a problem? Please describe:

N/A

Describe the solution you'd like:

As in description.

Documentation: mdn > Barcode Detection API
Demo: https://whatpwacando.today/barcode

Describe alternatives you've considered:

N/A

Additional context:

N/A

@thegnuu
Copy link

thegnuu commented Jun 12, 2023

@robingenz I can have a look at this if you want :) As you mentioned in our discussion you already have a standalone component relying on BarcodeDetector, unfortunately, support of BarcodeDetector is not optimal at the moment (https://caniuse.com/?search=BarcodeDetector).

My idea would be to use https://github.com/undecaf/barcode-detector-polyfill, I was already in contact with the guys over there to allow bundling of zbar-wasm which is possible now, and I think using a polyfill for not supported browsers would be a good idea at the current stage, what do you think about this? This might be a bit of an overhead but it should allow better and broader usage of this implementation and reduce "web platform usage" issues.

@robingenz
Copy link
Member

@thegnuu That sounds like a great idea. What about the license? As far as I can see https://github.com/mchehab/zbar is licensed under LGPL-2.1 and therefore not compatible with Apache-2.0.

@thegnuu
Copy link

thegnuu commented Jun 13, 2023

@robingenz I am not entirely sure, to be honest. There was an issue over there undecaf/barcode-detector-polyfill#2 and I think we should be able to use the plugin and bundle it according to this, but I am by far no license expert ;)

@robingenz
Copy link
Member

robingenz commented Jun 13, 2023

@thegnuu Unfortunately, I am not an expert either. As far as I understand it, it gets complicated as soon as the LGPL source code is linked statically (see https://stackoverflow.com/a/10179181/6731412), which should be the case since the library is compiled into the app as part of the build process.

For example, another plugin author recently switched to the MPL license as there were concerns (see Cap-go/capacitor-updater#7 (comment)).

@robingenz
Copy link
Member

For example, another plugin author recently switched to the MPL license as there were concerns (see Cap-go/capacitor-updater#7 (comment)).

@thegnuu I just read about the MPL license and see problems there as well:

3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:

such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must > inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and

You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients’ rights in the Source Code Form under this License.

Source

@thegnuu
Copy link

thegnuu commented Jun 14, 2023

I see, I see. Another idea would be to just implement BarcodeDetector within this plugin and properly document it like this. If someone needs to use it in a not supported browser, they can implement the initialization of the polyfill on their end. Since there are multiple polyfills for BarcodeDetector (e.g. https://github.com/xulihang/barcode-detector-polyfill) this would allow each dev to choose the version they want.

It's a more generic approach of course and might not work out of the box on each browser, but it would get us around the "license struggles" and add more flexibility for the devs. Adding a polyfill depending on zxing like the example in this comment seems not to be the best idea IMHO.

@robingenz
Copy link
Member

I see, I see. Another idea would be to just implement BarcodeDetector within this plugin and properly document it like this. If someone needs to use it in a not supported browser, they can implement the initialization of the polyfill on their end. Since there are multiple polyfills for BarcodeDetector (e.g. xulihang/barcode-detector-polyfill) this would allow each dev to choose the version they want.

Yes, i think this is the best solution atm. Any PR is welcome. Otherwise, I would put it on my todo list next month.

@piotr-cz
Copy link
Author

piotr-cz commented Jun 15, 2023

My feature request was initially about adding just native Barcode Detection API for web platform (even with support only on Chromium browsers).
Adding a note in docs about polyfills is definitely good idea.

@thegnuu
Copy link

thegnuu commented Jun 20, 2023

I think this makes sense yes, unfortunately I have a really busy week, but maybe I will find some time to start the implementation.

@robingenz robingenz linked a pull request Jun 21, 2023 that will close this issue
2 tasks
@robingenz
Copy link
Member

@thegnuu I had some time on the train today and started with the implementation, see #52.

@maelp
Copy link

maelp commented Nov 1, 2023

Perhaps this code could be useful? It handles Datamatrix https://github.com/rxing-core/rxing-wasm/tree/main

@robingenz robingenz changed the title feat: Barcode scanning for Web platform feat(barcode-scanning): support the Web platform Dec 8, 2023
@iBobik
Copy link

iBobik commented Nov 24, 2024

Hi, I’ve just published my PR for this: #211

It also works well with the https://www.npmjs.com/package/barcode-detector polyfill which I choose for it’s easy usage event with offline capability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants