Thibaut Boustany
6 years ago
No known key found for this signature in database
GPG Key ID: 32475B11A2B13EEC
3 changed files with
12 additions and
13 deletions
-
package.json
-
src/components/QRCodeCameraPickerCanvas.js
-
yarn.lock
|
|
@ -61,12 +61,12 @@ |
|
|
|
"i18next": "^11.2.2", |
|
|
|
"i18next-node-fs-backend": "^1.0.0", |
|
|
|
"invariant": "^2.2.4", |
|
|
|
"jsqr": "^1.1.1", |
|
|
|
"lodash": "^4.17.5", |
|
|
|
"lru-cache": "^4.1.3", |
|
|
|
"measure-scrollbar": "^1.1.0", |
|
|
|
"moment": "^2.22.2", |
|
|
|
"qrcode": "^1.2.0", |
|
|
|
"qrcode-reader": "^1.0.4", |
|
|
|
"qs": "^6.5.1", |
|
|
|
"raven": "^2.5.0", |
|
|
|
"raven-js": "^3.24.2", |
|
|
|
|
|
@ -1,7 +1,7 @@ |
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React, { Component } from 'react' |
|
|
|
import QrCode from 'qrcode-reader' |
|
|
|
import jsQR from 'jsqr' |
|
|
|
import logger from 'logger' |
|
|
|
|
|
|
|
export default class QRCodeCameraPickerCanvas extends Component< |
|
|
@ -60,12 +60,6 @@ export default class QRCodeCameraPickerCanvas extends Component< |
|
|
|
if (!getUserMedia) { |
|
|
|
this.setState({ message: 'Incompatible browser' }) // eslint-disable-line
|
|
|
|
} else { |
|
|
|
const qr = new QrCode() |
|
|
|
qr.callback = (err, value) => { |
|
|
|
if (!err) { |
|
|
|
this.props.onPick(value.result) |
|
|
|
} |
|
|
|
} |
|
|
|
getUserMedia({ |
|
|
|
video: { facingMode: 'environment' }, |
|
|
|
}) |
|
|
@ -146,7 +140,12 @@ export default class QRCodeCameraPickerCanvas extends Component< |
|
|
|
|
|
|
|
if (t - lastCheck >= intervalCheck) { |
|
|
|
lastCheck = t |
|
|
|
qr.decode(ctxMain.getImageData(0, 0, width, height)) |
|
|
|
const imageData = ctxMain.getImageData(0, 0, width, height) |
|
|
|
const code = jsQR(imageData.data, width, height) |
|
|
|
|
|
|
|
if (code && code.data) { |
|
|
|
this.props.onPick(code.data) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
raf = requestAnimationFrame(loop) |
|
|
|
|
|
@ -8992,6 +8992,10 @@ jsprim@^1.2.2: |
|
|
|
json-schema "0.2.3" |
|
|
|
verror "1.10.0" |
|
|
|
|
|
|
|
jsqr@^1.1.1: |
|
|
|
version "1.1.1" |
|
|
|
resolved "https://registry.yarnpkg.com/jsqr/-/jsqr-1.1.1.tgz#a0d7f95e6c3b0bec913dfef2ca64a877f28ed05f" |
|
|
|
|
|
|
|
jsx-ast-utils@^2.0.0, jsx-ast-utils@^2.0.1: |
|
|
|
version "2.0.1" |
|
|
|
resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-2.0.1.tgz#e801b1b39985e20fffc87b40e3748080e2dcac7f" |
|
|
@ -11565,10 +11569,6 @@ q@^1.1.2: |
|
|
|
version "1.5.1" |
|
|
|
resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" |
|
|
|
|
|
|
|
qrcode-reader@^1.0.4: |
|
|
|
version "1.0.4" |
|
|
|
resolved "https://registry.yarnpkg.com/qrcode-reader/-/qrcode-reader-1.0.4.tgz#95d9bb9e8130800361a96cb5a43124ad1d9e06b8" |
|
|
|
|
|
|
|
qrcode-terminal@^0.12.0: |
|
|
|
version "0.12.0" |
|
|
|
resolved "https://registry.yarnpkg.com/qrcode-terminal/-/qrcode-terminal-0.12.0.tgz#bb5b699ef7f9f0505092a3748be4464fe71b5819" |
|
|
|