UNPKG

@codesaursx/react-scanner

Version:

A React component to read QR and Barcodes in web-applications.

3 lines (2 loc) 976 B
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("react"),n=e(r),t=e(require("react-webcam")),o=require("@zxing/browser");exports.Scanner=function(e){var i=e.onUpdate,a=e.onError,u=e.width,c=void 0===u?"100%":u,l=e.height,d=void 0===l?"100%":l,s=e.facingMode,f=void 0===s?"environment":s,v=e.delay,h=void 0===v?500:v,g=e.videoConstraints,m=r.useRef(null),p=r.useCallback((function(){var e,r=new o.BrowserMultiFormatReader,n=null==m||null==(e=m.current)?void 0:e.getScreenshot();n&&r.decodeFromImageUrl(n).then((function(e){i(null,e)})).catch((function(e){i(e)}))}),[i]);return r.useEffect((function(){var e=setInterval(p,h);return function(){clearInterval(e)}}),[]),n.createElement(t,{width:c,height:d,ref:m,screenshotFormat:"image/jpeg",videoConstraints:null!=g?g:{facingMode:f},audio:!1,onUserMediaError:a})}; //# sourceMappingURL=react-scanner.cjs.production.min.js.map