Coder Social home page Coder Social logo

undecaf / barcode-detector-polyfill Goto Github PK

View Code? Open in Web Editor NEW
91.0 91.0 12.0 535 KB

A WebAssembly polyfill for the Barcode Detection API

License: MIT License

JavaScript 69.07% TypeScript 30.93%
barcode-scanner barcodedetector polyfill qrcode-scanner wasm webasssembly zbar

barcode-detector-polyfill's People

Contributors

ibobik avatar mfulton26 avatar thaina avatar undecaf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

barcode-detector-polyfill's Issues

About avoids the LGPL license issue?

LGPL license ask for used code open-source or dynamic import;
i think user don't need use dynamic import zbar.wasm, because this library is open-source.

Do i have a misunderstand about LGPL license ?

reference: GNU_Lesser_General_Public_License
Related Description: A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License.
Essentially, if it is a "work that uses the library", then it must be possible for the software to be linked with a newer version of the LGPL-covered program. The most commonly used method for doing so is to use "a suitable shared library mechanism for linking". Alternatively, a statically linked library is allowed if either source code or linkable object files are provided.[3]

Error when using the polyfill

My project is a Nuxt 2 (Vue 2) project and I am trying to use the @undecaf/vue-barcode-scanner on my page (Vue SFC). I installed the @undecaf/barcode-detector-polyfill package as a dependency of my project using npm.

  • I have imported the polyfill
import { BarcodeDetectorPolyfill } from '@undecaf/barcode-detector-polyfill'
  • And, I am applying the polyfill in my mounted hook:
mounted(){
  window.BarcodeDetector = BarcodeDetectorPolyfill
}

However, I am receiving the following error:

in ./node_modules/@undecaf/barcode-detector-polyfill/dist/main.js
Module not found: Error: Can't resolve 'https://cdn.jsdelivr.net/npm/@undecaf/[email protected]/dist/main.js' in '/ptda/node_modules/@undecaf/barcode-detector-polyfill/dist'
  1. Why am I receiving this error?
  2. I see that @undecaf/zbar-wasm is a dependency of the polyfill and installed in my node_modules, so why is it not retrieved locally?

I appreciate any help on this matter!

Issues loading @undecaf/zbar-wasm

First of all thanks for your work - seems to be a well performing barcode scanning solution.
I'm using npm to install it in an Angular/TypeScript project. But compilation fails because it can't resolve the CDN import of @undecaf/zbar-wasm.

It seems like this way of importing is not supported by the version I'm using.
Any help on how to properly load the library at runtime with the provided npm package would be appreciated.

[BUG] Source map not found

Describe the bug

The final build does not publish a valid source map, but the main script file references it:

//# sourceMappingURL=index.js.map

To Reproduce

N/A

Expected behavior

Should be produced/published a valid source map file (index.js.map) or the reference for the file should be removed from the main script file.

Edit: this applies to @undecaf/zbar-wasm package also.

Barcode detector polyfill can not detect code_128 format on Safari.

I used this library to recognize qr_code and barcode with format code_128.
It works for qr_code but failed to recognize barcode with format code_128 it on Safari.

this is my code:

// BarcodeReader.tsx
import { BarcodeDetectorPolyfill } from "@undecaf/barcode-detector-polyfill";
import { useEffect } from "react";

const BarcodeReader = () => {
      function readBarcode() {
            if (!window["BarcodeDetector"]) {
	            window["BarcodeDetector"] = BarcodeDetectorPolyfill;
            }
            navigator
            .mediaDevices
	    .getUserMedia({
		    video: true,
		    audio: false,
	    })
	    .then((stream) => {
            if ("BarcodeDetector" in window) {
	          const videoEl = document.querySelector("video") as HTMLVideoElement;
	          videoEl.srcObject = stream;
	          videoEl.play();
          
	          const barcodeDetector = new window.BarcodeDetector({
		          formats: ["code_128"],
	          });
                   const barcodes = await barcodeDetector.detect(videoEl);
	           console.log(barcodes); // print empty array for code_128 but work for qr_code on Safari!
	    })
	    .catch(console.log);
       }
       useEffect(() => {
	    readBarcode();
	}, []);
       return (
          <div>
              <video height={220} width={300} />
          </div>
	);
}
export default BarcodeReader;

Is there a way to detect code_128 barcode on Safari?

Error when Loading

This lib seems to work great, but I get:

Uncaught (in promise) TypeError: URL constructor: zbar.wasm is not a valid URL.

when loading it.

The same error happens when using your port of zbar.wasm directly

Missing dependencie on offline computer[BUG]

I develop and run a website on a complete offline network. I want to use the scanner there. So normally I install all needed packages with npm on an online pc, zip the folder and transfer it back to the offline pc.

I installed the lib with npm, zipped the project and transferd it but I get the following error on my offline pc:

This dependency was not found:      

* https://cdn.jsdelivr.net/npm/@undecaf/[email protected]/dist/main.js in ./node_modules/@undecaf/barcode-detector-polyfill/dist/main.js  

I don't get that error on my online pc, since it's probably just downloads the file.

Chrome: Failed to execute 'getImageData' on 'OffscreenCanvasRenderingContext2D'

I got this error in Chrome for image from remote server

Uncaught (in promise) DOMException: Failed to execute 'getImageData' on 'OffscreenCanvasRenderingContext2D': The canvas has been tainted by cross-origin data.
    at t2 (http://localhost:3000/node_modules/.vite/deps/@undecaf_barcode-detector-polyfill.js?v=0927827e:104:41)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.