ericblade / quagga2-reader-qr

Quagga2 sample external reader for QR codes
32 stars 10 forks source link

Where from can I download a pure JS version of this module? #177

Open ghevge opened 10 months ago

ghevge commented 10 months ago

Hi,

Where from can I download a pure JS version of this module?

I'm not seeing any dist folder in this repo, not I was able to locate any pege on the internet where from I can download the QR code module for quagga2.

@ericblade/quagga2-reader-qr on npmjs is not available either.

I need a version that will work in a pure javascript app. No react, jquery and/or any other lib dependency of this kind and no TS either.

Thanks

ghevge commented 10 months ago

I've converted the index.ts under src into the js code below and imported the jsQR lib (https://github.com/cozmo/jsQR/tree/master/dist) and then I was able to set up the QR reader in quaqa and read qr codes.

Maybe you should publish the JS component too. Not everyon is using TS in their projects.

var QrCodeReader = /** @class */ (function () {
    function QrCodeReader(config, supplements) {
        this._row = [];
        this.config = config || {};
        this.supplements = supplements;
        this.FORMAT = {
            value: 'qr_code',
            writeable: false,
        };
        return this;
    }
    QrCodeReader.prototype.decodeImage = function (inputImageWrapper) {
        var data = inputImageWrapper.getAsRGBA();
        var result = jsQR(data, inputImageWrapper.size.x, inputImageWrapper.size.y);
        if (result === null) {
            return null;
        }
        // TODO: translate result.location into same values as box/boxes from other readers?
        return {
            codeResult: {
                code: result.data,
                format: this.FORMAT.value,
            },
            ...result,
        };
    }
    // eslint-disable-next-line class-methods-use-this,@typescript-eslint/no-unused-vars
    QrCodeReader.prototype.decodePattern = function (pattern) {
        // STUB, this is probably meaningless to QR, but needs to be implemented for Quagga, in case
        // it thinks there's a potential barcode in the image
        return null;
    };
    return QrCodeReader;
}());

In my js app code , i've added: Quagga.registerReader('qrcode', QrCodeReader);

and in the readers list added: "qrcode"

ericblade commented 9 months ago

hmm. well, yeah, I don't recall that I ever intended this to be anything more than a test case / dev for the external reader package functionality, but.. sure .. It does work as far as I'm aware, so I don't see any reason why not to spend a few minutes putting it together all the way.

I'm going to put this on my todo list to get this in a npm repo by the 29th, let's see if that happens :-) Thanks for your incredible patience with me, my sometimes quite busy life, and continuing to help!

ericblade commented 9 months ago

lol ok while cleaning up i just read #54 so yeah, I guess I do need to get that done... ::checks notes:: 3 years later

ericblade commented 8 months ago

Had things to deal with over the weekend. Will try to find the time during the week to do this