├── .babelrc
├── .gitignore
├── .npmignore
├── README.md
├── docs
├── 5adc6a6833404f43b4fc.worker.js
├── 5adc6a6833404f43b4fc.worker.js.map
├── asset-manifest.json
├── build
│ ├── 5adc6a6833404f43b4fc.worker.js
│ ├── 5adc6a6833404f43b4fc.worker.js.map
│ ├── asset-manifest.json
│ ├── favicon.ico
│ ├── index.html
│ ├── logo192.png
│ ├── logo512.png
│ ├── manifest.json
│ ├── precache-manifest.66d346db6de698601a39ed8a709e2767.js
│ ├── precache-manifest.b2f3c5cb9416dc728ef8643b529823ad.js
│ ├── robots.txt
│ ├── service-worker.js
│ └── static
│ │ ├── css
│ │ ├── main.5f361e03.chunk.css
│ │ └── main.5f361e03.chunk.css.map
│ │ ├── js
│ │ ├── 2.81f07a75.chunk.js
│ │ ├── 2.81f07a75.chunk.js.LICENSE.txt
│ │ ├── 2.81f07a75.chunk.js.map
│ │ ├── main.6eb7939b.chunk.js
│ │ ├── main.6eb7939b.chunk.js.map
│ │ ├── runtime-main.429db5b2.js
│ │ └── runtime-main.429db5b2.js.map
│ │ └── media
│ │ └── zbar.wasm.b946c8e6.bin
├── favicon.ico
├── index.html
├── logo192.png
├── logo512.png
├── manifest.json
├── precache-manifest.0a252a7546d76ced201dbda56f06b4ef.js
├── robots.txt
├── service-worker.js
└── static
│ ├── css
│ ├── main.5f361e03.chunk.css
│ └── main.5f361e03.chunk.css.map
│ ├── js
│ ├── 2.81f07a75.chunk.js
│ ├── 2.81f07a75.chunk.js.LICENSE.txt
│ ├── 2.81f07a75.chunk.js.map
│ ├── main.e6fe3195.chunk.js
│ ├── main.e6fe3195.chunk.js.map
│ ├── runtime-main.429db5b2.js
│ └── runtime-main.429db5b2.js.map
│ └── media
│ └── zbar.wasm.b946c8e6.bin
├── package-lock.json
├── package.json
├── src
├── CodeScanner.jsx
└── code-scanner.worker.js
└── webpack.config.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | "react",
4 | "env",
5 | "stage-0"
6 | ]
7 | }
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | lib/
3 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | src
2 | docs
3 | .babelrc
4 | webpack.config.js
5 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # React Code Scanner
2 |
3 | A react component to scan bar codes and qr codes, it uses the zbar.wasm library in a web worker.
4 |
5 | This uses hooks, so needs React >= 16.8
6 |
7 | ## Install
8 |
9 | `npm i react-code-scanner`
10 |
11 | ## Usage
12 |
13 | ```jsx
14 | const [result, setResult] = useState('');
15 | const [facingMode, setFacingMode] = useState('environment');
16 |
17 | return (
18 |
19 |
Code Scanner
20 |
Result: {result}
21 |
22 |
23 |
24 |
25 |
32 |
33 |
setResult(res.map(({ value }) => value).join(', '))}
35 | onError={setResult}
36 | facingMode={facingMode}
37 | />
38 |
39 | );
40 | ```
41 |
42 | ## Props
43 |
44 | | name | default | meaning |
45 | |------|---------|---------|
46 | | width | 400 | the width in px of the camera view |
47 | | height | 300 | the heigth in px of the camera view |
48 | | onResult | console.log | the callback that is invoked when a code is decoded |
49 | | onError | console.error | the callback that is invoked when an error occours |
50 | | maxVideoWidth | 640 | the width in px of the image taken from the camera and passed to the scanner |
51 | | maxVideoHeight | 640 | the width in px of the image taken from the camera and passed to the scanner |
52 | | facingMode | 'environment' | this prop is used by devices with a back and a front camera and takes 2 values: 'environment' to use the back camera and 'user' to use the front camera |
53 | | codeOverlayColor | '#00ff00' | the color of the code overlay that is dispalyed when a code is recognized |
54 | | codeIndexColor | '#ff0000' | the color of the progressivo code id that is dispalyed when a code is recognized |
55 | | mirrorUserImage | true | if true the component will mirror the image when using the front camera |
56 |
--------------------------------------------------------------------------------
/docs/5adc6a6833404f43b4fc.worker.js:
--------------------------------------------------------------------------------
1 | !function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="/",r(r.s=23)}([function(t,e,r){t.exports=r(12)},function(t,e){function r(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(s){return void r(s)}u.done?e(c):Promise.resolve(c).then(n,o)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function u(t){r(a,o,i,u,c,"next",t)}function c(t){r(a,o,i,u,c,"throw",t)}u(void 0)}))}}},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function r(t,e){for(var r=0;r>2,this.buf=r,this.HEAP8=new Int8Array(r),this.HEAPU32=new Uint32Array(r),this.HEAP32=new Int32Array(r)},s=function(t){o(r,t);var e=i(r);function r(){return a(this,r),e.apply(this,arguments)}return n(r,[{key:"type",get:function(){return this.HEAPU32[this.ptr32]}},{key:"data",get:function(){var t=this.HEAPU32[this.ptr32+2],e=this.HEAPU32[this.ptr32+3];return Int8Array.from(this.HEAP8.subarray(e,e+t))}},{key:"points",get:function(){for(var t=this.HEAPU32[this.ptr32+5],e=this.HEAPU32[this.ptr32+6]>>2,r=[],n=0;n3&&void 0!==h[3]?h[3]:0,t.next=3,l.getInstance();case 3:if(a=t.sent,u=new Uint8Array(a.memory.buffer),c=new Uint8Array(o),(s=e*r)===c.byteLength){t.next=9;break}throw Error("dataBuf does not match width and height");case 9:return f=a.malloc(s),u.set(c,f),p=a.Image_create(e,r,808466521,f,s,i),t.abrupt("return",new this(p,a));case 13:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}()},{key:"createFromRGBABuffer",value:function(){var t=o(n.mark((function t(e,r,o){var i,a,u,c,s,f,p,h,y,v,d,m=arguments;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=m.length>3&&void 0!==m[3]?m[3]:0,t.next=3,l.getInstance();case 3:if(a=t.sent,u=new Uint8Array(a.memory.buffer),c=new Uint8Array(o),4*(s=e*r)===c.byteLength){t.next=9;break}throw Error("dataBuf does not match width and height");case 9:for(f=a.malloc(s),p=0;p>16;return d=a.Image_create(e,r,808466521,f,s,i),t.abrupt("return",new this(d,a));case 13:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}()}]),r}(s.CppObject);e.Image=p},function(t,e,r){"use strict";var n=r(2),o=r(3);Object.defineProperty(e,"__esModule",{value:!0}),e.CppObject=void 0;var i=function(){function t(e,r){n(this,t),this.ptr=e,this.inst=r}return o(t,[{key:"checkAlive",value:function(){if(!this.ptr)throw Error("Call after destroyed")}},{key:"getPointer",value:function(){return this.checkAlive(),this.ptr}}]),t}();e.CppObject=i},function(t,e,r){"use strict";var n=r(0),o=r(1);Object.defineProperty(e,"__esModule",{value:!0}),e.getMemoryGrowTimestamp=e.getInstance=void 0;var i=r(20),a=null,u=new Int32Array,c=0,s=function(t){c&&console.info("zbar.wasm: Memory Grow: ",a.memory.buffer.byteLength),c=Date.now(),u=new Int32Array(a.memory.buffer)},f={env:{clock_gettime:function(t,e){var r=Date.now();return u[e>>2]=r/1e3|0,u[e+4>>2]=r%1e3*1e3*1e3|0,0},emscripten_notify_memory_growth:s}},l=o(n.mark((function t(){var e;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i.loadWasmInstance(f);case 2:if(e=t.sent){t.next=5;break}throw Error("WASM was not loaded");case 5:return a=e.exports,s(),t.abrupt("return",a);case 8:case"end":return t.stop()}}),t)})))();e.getInstance=o(n.mark((function t(){return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,l;case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),e.getMemoryGrowTimestamp=function(){return c}},function(t,e,r){"use strict";var n=r(0),o=r(1),i=r(2),a=r(3),u=r(4),c=r(5);Object.defineProperty(e,"__esModule",{value:!0}),e.ImageScanner=void 0;var s=r(8),f=r(9),l=r(6),p=function(t){u(r,t);var e=c(r);function r(){return i(this,r),e.apply(this,arguments)}return a(r,[{key:"destroy",value:function(){this.checkAlive(),this.inst.ImageScanner_destory(this.ptr),this.ptr=0}},{key:"setConfig",value:function(t,e,r){return this.checkAlive(),this.inst.ImageScanner_set_config(this.ptr,t,e,r)}},{key:"enableCache",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.checkAlive(),this.inst.ImageScanner_enable_cache(this.ptr,t)}},{key:"recycleImage",value:function(t){this.checkAlive(),this.inst.ImageScanner_recycle_image(this.ptr,t.getPointer())}},{key:"getResults",value:function(){this.checkAlive();var t=this.inst.ImageScanner_get_results(this.ptr);return l.Symbol.createSymbolsFromPtr(t,this.inst.memory.buffer)}},{key:"scan",value:function(t){return this.checkAlive(),this.inst.ImageScanner_scan(this.ptr,t.getPointer())}}],[{key:"create",value:function(){var t=o(n.mark((function t(){var e,r;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,f.getInstance();case 2:return e=t.sent,r=e.ImageScanner_create(),t.abrupt("return",new this(r,e));case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}()}]),r}(s.CppObject);e.ImageScanner=p},function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||e.hasOwnProperty(r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),o(r(7),e),o(r(10),e),o(r(22),e),o(r(6),e)},function(t,e,r){var n=function(t){"use strict";var e=Object.prototype,r=e.hasOwnProperty,n="function"===typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(S){u=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof l?e:l,i=Object.create(o.prototype),a=new x(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return B()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=_(a,r);if(u){if(u===f)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=s(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(S){return{type:"throw",arg:S}}}t.wrap=c;var f={};function l(){}function p(){}function h(){}var y={};y[o]=function(){return this};var v=Object.getPrototypeOf,d=v&&v(v(E([])));d&&d!==e&&r.call(d,o)&&(y=d);var m=h.prototype=l.prototype=Object.create(y);function b(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function g(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,u){var c=s(t[o],t,i);if("throw"!==c.type){var f=c.arg,l=f.value;return l&&"object"===typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(l).then((function(t){f.value=t,a(f)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function A(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"===typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),A(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;A(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=n}catch(o){Function("r","regeneratorRuntime = r")(n)}},function(t,e){function r(e,n){return t.exports=r=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},r(e,n)}t.exports=r},function(t,e){function r(e){return t.exports=r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},r(e)}t.exports=r},function(t,e){t.exports=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}},function(t,e,r){var n=r(17),o=r(18);t.exports=function(t,e){return!e||"object"!==n(e)&&"function"!==typeof e?o(t):e}},function(t,e){function r(e){return"function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?t.exports=r=function(t){return typeof t}:t.exports=r=function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(e)}t.exports=r},function(t,e){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ZBarConfigType=e.ZBarSymbolType=void 0,function(t){t[t.ZBAR_NONE=0]="ZBAR_NONE",t[t.ZBAR_PARTIAL=1]="ZBAR_PARTIAL",t[t.ZBAR_EAN8=8]="ZBAR_EAN8",t[t.ZBAR_UPCE=9]="ZBAR_UPCE",t[t.ZBAR_ISBN10=10]="ZBAR_ISBN10",t[t.ZBAR_UPCA=12]="ZBAR_UPCA",t[t.ZBAR_EAN13=13]="ZBAR_EAN13",t[t.ZBAR_ISBN13=14]="ZBAR_ISBN13",t[t.ZBAR_I25=25]="ZBAR_I25",t[t.ZBAR_CODE39=39]="ZBAR_CODE39",t[t.ZBAR_PDF417=57]="ZBAR_PDF417",t[t.ZBAR_QRCODE=64]="ZBAR_QRCODE",t[t.ZBAR_CODE128=128]="ZBAR_CODE128",t[t.ZBAR_SYMBOL=255]="ZBAR_SYMBOL",t[t.ZBAR_ADDON2=512]="ZBAR_ADDON2",t[t.ZBAR_ADDON5=1280]="ZBAR_ADDON5",t[t.ZBAR_ADDON=1792]="ZBAR_ADDON"}(e.ZBarSymbolType||(e.ZBarSymbolType={})),function(t){t[t.ZBAR_CFG_ENABLE=0]="ZBAR_CFG_ENABLE",t[t.ZBAR_CFG_ADD_CHECK=1]="ZBAR_CFG_ADD_CHECK",t[t.ZBAR_CFG_EMIT_CHECK=2]="ZBAR_CFG_EMIT_CHECK",t[t.ZBAR_CFG_ASCII=3]="ZBAR_CFG_ASCII",t[t.ZBAR_CFG_NUM=4]="ZBAR_CFG_NUM",t[t.ZBAR_CFG_MIN_LEN=32]="ZBAR_CFG_MIN_LEN",t[t.ZBAR_CFG_MAX_LEN=33]="ZBAR_CFG_MAX_LEN",t[t.ZBAR_CFG_UNCERTAINTY=64]="ZBAR_CFG_UNCERTAINTY",t[t.ZBAR_CFG_POSITION=128]="ZBAR_CFG_POSITION",t[t.ZBAR_CFG_X_DENSITY=256]="ZBAR_CFG_X_DENSITY",t[t.ZBAR_CFG_Y_DENSITY=257]="ZBAR_CFG_Y_DENSITY"}(e.ZBarConfigType||(e.ZBarConfigType={}))},function(t,e,r){"use strict";var n=r(0),o=r(1),i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.loadWasmInstance=void 0;var a=i(r(21));e.loadWasmInstance=function(){var t=o(n.mark((function t(e){var r,o,i;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch(a.default);case 2:if((r=t.sent).ok){t.next=6;break}return console.error("Failed to load wasm binary file at "+a.default),t.abrupt("return",null);case 6:return t.next=8,r.arrayBuffer();case 8:return o=t.sent,t.next=11,WebAssembly.instantiate(o,e);case 11:return i=t.sent,t.abrupt("return",i.instance);case 13:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},function(t,e,r){t.exports=r.p+"static/media/zbar.wasm.b946c8e6.bin"},function(t,e,r){"use strict";var n=r(0),o=r(1);Object.defineProperty(e,"__esModule",{value:!0}),e.scanImageData=e.scanRGBABuffer=e.scanGrayBuffer=e.getDefaultScanner=void 0;var i=r(7),a=r(10).ImageScanner.create();e.getDefaultScanner=o(n.mark((function t(){return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a;case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));var u=function(){var t=o(n.mark((function t(e,r){var o;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0!==r){t.next=4;break}return t.next=3,a;case 3:r=t.sent;case 4:if(!((o=r.scan(e))<0)){t.next=7;break}throw Error("Scan Failed");case 7:if(0!==o){t.next=9;break}return t.abrupt("return",[]);case 9:return t.abrupt("return",e.getSymbols());case 10:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}();e.scanGrayBuffer=function(){var t=o(n.mark((function t(e,r,o,a){var c,s;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i.Image.createFromGrayBuffer(r,o,e);case 2:return c=t.sent,t.next=5,u(c,a);case 5:return s=t.sent,c.destroy(),t.abrupt("return",s);case 8:case"end":return t.stop()}}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),e.scanRGBABuffer=function(){var t=o(n.mark((function t(e,r,o,a){var c,s;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i.Image.createFromRGBABuffer(r,o,e);case 2:return c=t.sent,t.next=5,u(c,a);case 5:return s=t.sent,c.destroy(),t.abrupt("return",s);case 8:case"end":return t.stop()}}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),e.scanImageData=function(){var t=o(n.mark((function t(r,o){return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.scanRGBABuffer(r.data.buffer,r.width,r.height,o);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()},function(t,e,r){"use strict";function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},o=!1,a=new Proxy(n,{get:function(n,i){if(g(o),i===h)return function(){return S(e,{type:5,path:r.map((function(t){return t.toString()}))}).then((function(){b(e),o=!0}))};if("then"===i){if(0===r.length)return{then:function(){return a}};var u=S(e,{type:0,path:r.map((function(t){return t.toString()}))}).then(B);return u.then.bind(u)}return t(e,[].concat(f(r),[i]))},set:function(t,n,a){g(o);var u=i(E(a),2),c=u[0],s=u[1];return S(e,{type:1,path:[].concat(f(r),[n]).map((function(t){return t.toString()})),value:c},s).then(B)},apply:function(n,a,u){g(o);var c=r[r.length-1];if(c===p)return S(e,{type:4}).then(B);if("bind"===c)return t(e,r.slice(0,-1));var s=i(_(u),2),f=s[0],l=s[1];return S(e,{type:2,path:r.map((function(t){return t.toString()})),argumentList:f},l).then(B)},construct:function(t,n){g(o);var a=i(_(n),2),u=a[0],c=a[1];return S(e,{type:3,path:r.map((function(t){return t.toString()})),argumentList:u},c).then(B)}});return a}(t,[],e);var e}}],["throw",{canHandle:function(t){return v(t)&&y in t},serialize:function(t){var e=t.value;return[e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[]]},deserialize:function(t){if(t.isError)throw Object.assign(new Error(t.value.message),t.value);throw t.value}}]]);function m(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:self;e.addEventListener("message",(function r(n){if(n&&n.data){var o,u=Object.assign({path:[]},n.data),c=u.id,l=u.type,p=u.path,h=(n.data.argumentList||[]).map(B);try{var v=p.slice(0,-1).reduce((function(t,e){return t[e]}),t),d=p.reduce((function(t,e){return t[e]}),t);switch(l){case 0:o=d;break;case 1:v[p.slice(-1)[0]]=B(n.data.value),o=!0;break;case 2:o=d.apply(v,h);break;case 3:var g;o=x(s(d,f(h)));break;case 4:var _=new MessageChannel,w=_.port1,S=_.port2;m(t,S),o=A(w,[w]);break;case 5:o=void 0}}catch(g){o=a({value:g},y,0)}Promise.resolve(o).catch((function(t){return a({value:t},y,0)})).then((function(t){var n=i(E(t),2),o=n[0],a=n[1];e.postMessage(Object.assign(Object.assign({},o),{id:c}),a),5===l&&(e.removeEventListener("message",r),b(e))}))}})),e.start&&e.start()}function b(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function g(t){if(t)throw new Error("Proxy has been released and is not useable")}function _(t){var e,r=t.map(E);return[r.map((function(t){return t[0]})),(e=r.map((function(t){return t[1]})),Array.prototype.concat.apply([],e))]}var w=new WeakMap;function A(t,e){return w.set(t,e),t}function x(t){return Object.assign(t,a({},l,!0))}function E(t){var e,r=function(t){if("undefined"===typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(t=o(t))){var e=0,r=function(){};return{s:r,n:function(){return e>=t.length?{done:!0}:{done:!1,value:t[e++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,i,a=!0,u=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}(d);try{for(r.s();!(e=r.n()).done;){var n=i(e.value,2),a=n[0],u=n[1];if(u.canHandle(t)){var c=i(u.serialize(t),2);return[{type:3,name:a,value:c[0]},c[1]]}}}catch(s){r.e(s)}finally{r.f()}return[{type:0,value:t},w.get(t)||[]]}function B(t){switch(t.type){case 3:return d.get(t.name).deserialize(t.value);case 0:return t.value}}function S(t,e,r){return new Promise((function(n){var o=new Array(4).fill(0).map((function(){return Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)})).join("-");t.addEventListener("message",(function e(r){r.data&&r.data.id&&r.data.id===o&&(t.removeEventListener("message",e),n(r.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:o},e),r)}))}var R=r(0),O=r.n(R);function k(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(s){return void r(s)}u.done?e(c):Promise.resolve(c).then(n,o)}var I=r(11),P=function(){var t,e=(t=O.a.mark((function t(e){var r;return O.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(I.scanImageData)(e);case 2:return r=t.sent,t.abrupt("return",r.map((function(t,e){return{index:e,type:t.typeName,value:t.decode(),points:t.points}})));case 4:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){k(i,n,o,a,u,"next",t)}function u(t){k(i,n,o,a,u,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}();m(Object.keys(e).reduce((function(t,r){return"__esModule"==r||(t[r]=e[r]),t}),{}))}]);
2 | //# sourceMappingURL=5adc6a6833404f43b4fc.worker.js.map
--------------------------------------------------------------------------------
/docs/asset-manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "files": {
3 | "main.css": "/static/css/main.5f361e03.chunk.css",
4 | "main.js": "/static/js/main.e6fe3195.chunk.js",
5 | "main.js.map": "/static/js/main.e6fe3195.chunk.js.map",
6 | "runtime-main.js": "/static/js/runtime-main.429db5b2.js",
7 | "runtime-main.js.map": "/static/js/runtime-main.429db5b2.js.map",
8 | "static/js/2.81f07a75.chunk.js": "/static/js/2.81f07a75.chunk.js",
9 | "static/js/2.81f07a75.chunk.js.map": "/static/js/2.81f07a75.chunk.js.map",
10 | "5adc6a6833404f43b4fc.worker.js": "/5adc6a6833404f43b4fc.worker.js",
11 | "5adc6a6833404f43b4fc.worker.js.map": "/5adc6a6833404f43b4fc.worker.js.map",
12 | "index.html": "/index.html",
13 | "precache-manifest.0a252a7546d76ced201dbda56f06b4ef.js": "/precache-manifest.0a252a7546d76ced201dbda56f06b4ef.js",
14 | "service-worker.js": "/service-worker.js",
15 | "static/css/main.5f361e03.chunk.css.map": "/static/css/main.5f361e03.chunk.css.map",
16 | "static/js/2.81f07a75.chunk.js.LICENSE.txt": "/static/js/2.81f07a75.chunk.js.LICENSE.txt",
17 | "static/media/zbar.wasm.bin": "/static/media/zbar.wasm.b946c8e6.bin"
18 | },
19 | "entrypoints": [
20 | "static/js/runtime-main.429db5b2.js",
21 | "static/js/2.81f07a75.chunk.js",
22 | "static/css/main.5f361e03.chunk.css",
23 | "static/js/main.e6fe3195.chunk.js"
24 | ]
25 | }
--------------------------------------------------------------------------------
/docs/build/5adc6a6833404f43b4fc.worker.js:
--------------------------------------------------------------------------------
1 | !function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="/",r(r.s=23)}([function(t,e,r){t.exports=r(12)},function(t,e){function r(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(s){return void r(s)}u.done?e(c):Promise.resolve(c).then(n,o)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function u(t){r(a,o,i,u,c,"next",t)}function c(t){r(a,o,i,u,c,"throw",t)}u(void 0)}))}}},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function r(t,e){for(var r=0;r>2,this.buf=r,this.HEAP8=new Int8Array(r),this.HEAPU32=new Uint32Array(r),this.HEAP32=new Int32Array(r)},s=function(t){o(r,t);var e=i(r);function r(){return a(this,r),e.apply(this,arguments)}return n(r,[{key:"type",get:function(){return this.HEAPU32[this.ptr32]}},{key:"data",get:function(){var t=this.HEAPU32[this.ptr32+2],e=this.HEAPU32[this.ptr32+3];return Int8Array.from(this.HEAP8.subarray(e,e+t))}},{key:"points",get:function(){for(var t=this.HEAPU32[this.ptr32+5],e=this.HEAPU32[this.ptr32+6]>>2,r=[],n=0;n3&&void 0!==h[3]?h[3]:0,t.next=3,l.getInstance();case 3:if(a=t.sent,u=new Uint8Array(a.memory.buffer),c=new Uint8Array(o),(s=e*r)===c.byteLength){t.next=9;break}throw Error("dataBuf does not match width and height");case 9:return f=a.malloc(s),u.set(c,f),p=a.Image_create(e,r,808466521,f,s,i),t.abrupt("return",new this(p,a));case 13:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}()},{key:"createFromRGBABuffer",value:function(){var t=o(n.mark((function t(e,r,o){var i,a,u,c,s,f,p,h,y,v,d,m=arguments;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=m.length>3&&void 0!==m[3]?m[3]:0,t.next=3,l.getInstance();case 3:if(a=t.sent,u=new Uint8Array(a.memory.buffer),c=new Uint8Array(o),4*(s=e*r)===c.byteLength){t.next=9;break}throw Error("dataBuf does not match width and height");case 9:for(f=a.malloc(s),p=0;p>16;return d=a.Image_create(e,r,808466521,f,s,i),t.abrupt("return",new this(d,a));case 13:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}()}]),r}(s.CppObject);e.Image=p},function(t,e,r){"use strict";var n=r(2),o=r(3);Object.defineProperty(e,"__esModule",{value:!0}),e.CppObject=void 0;var i=function(){function t(e,r){n(this,t),this.ptr=e,this.inst=r}return o(t,[{key:"checkAlive",value:function(){if(!this.ptr)throw Error("Call after destroyed")}},{key:"getPointer",value:function(){return this.checkAlive(),this.ptr}}]),t}();e.CppObject=i},function(t,e,r){"use strict";var n=r(0),o=r(1);Object.defineProperty(e,"__esModule",{value:!0}),e.getMemoryGrowTimestamp=e.getInstance=void 0;var i=r(20),a=null,u=new Int32Array,c=0,s=function(t){c&&console.info("zbar.wasm: Memory Grow: ",a.memory.buffer.byteLength),c=Date.now(),u=new Int32Array(a.memory.buffer)},f={env:{clock_gettime:function(t,e){var r=Date.now();return u[e>>2]=r/1e3|0,u[e+4>>2]=r%1e3*1e3*1e3|0,0},emscripten_notify_memory_growth:s}},l=o(n.mark((function t(){var e;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i.loadWasmInstance(f);case 2:if(e=t.sent){t.next=5;break}throw Error("WASM was not loaded");case 5:return a=e.exports,s(),t.abrupt("return",a);case 8:case"end":return t.stop()}}),t)})))();e.getInstance=o(n.mark((function t(){return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,l;case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),e.getMemoryGrowTimestamp=function(){return c}},function(t,e,r){"use strict";var n=r(0),o=r(1),i=r(2),a=r(3),u=r(4),c=r(5);Object.defineProperty(e,"__esModule",{value:!0}),e.ImageScanner=void 0;var s=r(8),f=r(9),l=r(6),p=function(t){u(r,t);var e=c(r);function r(){return i(this,r),e.apply(this,arguments)}return a(r,[{key:"destroy",value:function(){this.checkAlive(),this.inst.ImageScanner_destory(this.ptr),this.ptr=0}},{key:"setConfig",value:function(t,e,r){return this.checkAlive(),this.inst.ImageScanner_set_config(this.ptr,t,e,r)}},{key:"enableCache",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.checkAlive(),this.inst.ImageScanner_enable_cache(this.ptr,t)}},{key:"recycleImage",value:function(t){this.checkAlive(),this.inst.ImageScanner_recycle_image(this.ptr,t.getPointer())}},{key:"getResults",value:function(){this.checkAlive();var t=this.inst.ImageScanner_get_results(this.ptr);return l.Symbol.createSymbolsFromPtr(t,this.inst.memory.buffer)}},{key:"scan",value:function(t){return this.checkAlive(),this.inst.ImageScanner_scan(this.ptr,t.getPointer())}}],[{key:"create",value:function(){var t=o(n.mark((function t(){var e,r;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,f.getInstance();case 2:return e=t.sent,r=e.ImageScanner_create(),t.abrupt("return",new this(r,e));case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}()}]),r}(s.CppObject);e.ImageScanner=p},function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||e.hasOwnProperty(r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),o(r(7),e),o(r(10),e),o(r(22),e),o(r(6),e)},function(t,e,r){var n=function(t){"use strict";var e=Object.prototype,r=e.hasOwnProperty,n="function"===typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(S){u=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof l?e:l,i=Object.create(o.prototype),a=new x(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return B()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=_(a,r);if(u){if(u===f)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=s(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(S){return{type:"throw",arg:S}}}t.wrap=c;var f={};function l(){}function p(){}function h(){}var y={};y[o]=function(){return this};var v=Object.getPrototypeOf,d=v&&v(v(E([])));d&&d!==e&&r.call(d,o)&&(y=d);var m=h.prototype=l.prototype=Object.create(y);function b(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function g(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,u){var c=s(t[o],t,i);if("throw"!==c.type){var f=c.arg,l=f.value;return l&&"object"===typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(l).then((function(t){f.value=t,a(f)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function A(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"===typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),A(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;A(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=n}catch(o){Function("r","regeneratorRuntime = r")(n)}},function(t,e){function r(e,n){return t.exports=r=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},r(e,n)}t.exports=r},function(t,e){function r(e){return t.exports=r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},r(e)}t.exports=r},function(t,e){t.exports=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}},function(t,e,r){var n=r(17),o=r(18);t.exports=function(t,e){return!e||"object"!==n(e)&&"function"!==typeof e?o(t):e}},function(t,e){function r(e){return"function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?t.exports=r=function(t){return typeof t}:t.exports=r=function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(e)}t.exports=r},function(t,e){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ZBarConfigType=e.ZBarSymbolType=void 0,function(t){t[t.ZBAR_NONE=0]="ZBAR_NONE",t[t.ZBAR_PARTIAL=1]="ZBAR_PARTIAL",t[t.ZBAR_EAN8=8]="ZBAR_EAN8",t[t.ZBAR_UPCE=9]="ZBAR_UPCE",t[t.ZBAR_ISBN10=10]="ZBAR_ISBN10",t[t.ZBAR_UPCA=12]="ZBAR_UPCA",t[t.ZBAR_EAN13=13]="ZBAR_EAN13",t[t.ZBAR_ISBN13=14]="ZBAR_ISBN13",t[t.ZBAR_I25=25]="ZBAR_I25",t[t.ZBAR_CODE39=39]="ZBAR_CODE39",t[t.ZBAR_PDF417=57]="ZBAR_PDF417",t[t.ZBAR_QRCODE=64]="ZBAR_QRCODE",t[t.ZBAR_CODE128=128]="ZBAR_CODE128",t[t.ZBAR_SYMBOL=255]="ZBAR_SYMBOL",t[t.ZBAR_ADDON2=512]="ZBAR_ADDON2",t[t.ZBAR_ADDON5=1280]="ZBAR_ADDON5",t[t.ZBAR_ADDON=1792]="ZBAR_ADDON"}(e.ZBarSymbolType||(e.ZBarSymbolType={})),function(t){t[t.ZBAR_CFG_ENABLE=0]="ZBAR_CFG_ENABLE",t[t.ZBAR_CFG_ADD_CHECK=1]="ZBAR_CFG_ADD_CHECK",t[t.ZBAR_CFG_EMIT_CHECK=2]="ZBAR_CFG_EMIT_CHECK",t[t.ZBAR_CFG_ASCII=3]="ZBAR_CFG_ASCII",t[t.ZBAR_CFG_NUM=4]="ZBAR_CFG_NUM",t[t.ZBAR_CFG_MIN_LEN=32]="ZBAR_CFG_MIN_LEN",t[t.ZBAR_CFG_MAX_LEN=33]="ZBAR_CFG_MAX_LEN",t[t.ZBAR_CFG_UNCERTAINTY=64]="ZBAR_CFG_UNCERTAINTY",t[t.ZBAR_CFG_POSITION=128]="ZBAR_CFG_POSITION",t[t.ZBAR_CFG_X_DENSITY=256]="ZBAR_CFG_X_DENSITY",t[t.ZBAR_CFG_Y_DENSITY=257]="ZBAR_CFG_Y_DENSITY"}(e.ZBarConfigType||(e.ZBarConfigType={}))},function(t,e,r){"use strict";var n=r(0),o=r(1),i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.loadWasmInstance=void 0;var a=i(r(21));e.loadWasmInstance=function(){var t=o(n.mark((function t(e){var r,o,i;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch(a.default);case 2:if((r=t.sent).ok){t.next=6;break}return console.error("Failed to load wasm binary file at "+a.default),t.abrupt("return",null);case 6:return t.next=8,r.arrayBuffer();case 8:return o=t.sent,t.next=11,WebAssembly.instantiate(o,e);case 11:return i=t.sent,t.abrupt("return",i.instance);case 13:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},function(t,e,r){t.exports=r.p+"static/media/zbar.wasm.b946c8e6.bin"},function(t,e,r){"use strict";var n=r(0),o=r(1);Object.defineProperty(e,"__esModule",{value:!0}),e.scanImageData=e.scanRGBABuffer=e.scanGrayBuffer=e.getDefaultScanner=void 0;var i=r(7),a=r(10).ImageScanner.create();e.getDefaultScanner=o(n.mark((function t(){return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a;case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));var u=function(){var t=o(n.mark((function t(e,r){var o;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0!==r){t.next=4;break}return t.next=3,a;case 3:r=t.sent;case 4:if(!((o=r.scan(e))<0)){t.next=7;break}throw Error("Scan Failed");case 7:if(0!==o){t.next=9;break}return t.abrupt("return",[]);case 9:return t.abrupt("return",e.getSymbols());case 10:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}();e.scanGrayBuffer=function(){var t=o(n.mark((function t(e,r,o,a){var c,s;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i.Image.createFromGrayBuffer(r,o,e);case 2:return c=t.sent,t.next=5,u(c,a);case 5:return s=t.sent,c.destroy(),t.abrupt("return",s);case 8:case"end":return t.stop()}}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),e.scanRGBABuffer=function(){var t=o(n.mark((function t(e,r,o,a){var c,s;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i.Image.createFromRGBABuffer(r,o,e);case 2:return c=t.sent,t.next=5,u(c,a);case 5:return s=t.sent,c.destroy(),t.abrupt("return",s);case 8:case"end":return t.stop()}}),t)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),e.scanImageData=function(){var t=o(n.mark((function t(r,o){return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.scanRGBABuffer(r.data.buffer,r.width,r.height,o);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()},function(t,e,r){"use strict";function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},o=!1,a=new Proxy(n,{get:function(n,i){if(g(o),i===h)return function(){return S(e,{type:5,path:r.map((function(t){return t.toString()}))}).then((function(){b(e),o=!0}))};if("then"===i){if(0===r.length)return{then:function(){return a}};var u=S(e,{type:0,path:r.map((function(t){return t.toString()}))}).then(B);return u.then.bind(u)}return t(e,[].concat(f(r),[i]))},set:function(t,n,a){g(o);var u=i(E(a),2),c=u[0],s=u[1];return S(e,{type:1,path:[].concat(f(r),[n]).map((function(t){return t.toString()})),value:c},s).then(B)},apply:function(n,a,u){g(o);var c=r[r.length-1];if(c===p)return S(e,{type:4}).then(B);if("bind"===c)return t(e,r.slice(0,-1));var s=i(_(u),2),f=s[0],l=s[1];return S(e,{type:2,path:r.map((function(t){return t.toString()})),argumentList:f},l).then(B)},construct:function(t,n){g(o);var a=i(_(n),2),u=a[0],c=a[1];return S(e,{type:3,path:r.map((function(t){return t.toString()})),argumentList:u},c).then(B)}});return a}(t,[],e);var e}}],["throw",{canHandle:function(t){return v(t)&&y in t},serialize:function(t){var e=t.value;return[e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[]]},deserialize:function(t){if(t.isError)throw Object.assign(new Error(t.value.message),t.value);throw t.value}}]]);function m(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:self;e.addEventListener("message",(function r(n){if(n&&n.data){var o,u=Object.assign({path:[]},n.data),c=u.id,l=u.type,p=u.path,h=(n.data.argumentList||[]).map(B);try{var v=p.slice(0,-1).reduce((function(t,e){return t[e]}),t),d=p.reduce((function(t,e){return t[e]}),t);switch(l){case 0:o=d;break;case 1:v[p.slice(-1)[0]]=B(n.data.value),o=!0;break;case 2:o=d.apply(v,h);break;case 3:var g;o=x(s(d,f(h)));break;case 4:var _=new MessageChannel,w=_.port1,S=_.port2;m(t,S),o=A(w,[w]);break;case 5:o=void 0}}catch(g){o=a({value:g},y,0)}Promise.resolve(o).catch((function(t){return a({value:t},y,0)})).then((function(t){var n=i(E(t),2),o=n[0],a=n[1];e.postMessage(Object.assign(Object.assign({},o),{id:c}),a),5===l&&(e.removeEventListener("message",r),b(e))}))}})),e.start&&e.start()}function b(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function g(t){if(t)throw new Error("Proxy has been released and is not useable")}function _(t){var e,r=t.map(E);return[r.map((function(t){return t[0]})),(e=r.map((function(t){return t[1]})),Array.prototype.concat.apply([],e))]}var w=new WeakMap;function A(t,e){return w.set(t,e),t}function x(t){return Object.assign(t,a({},l,!0))}function E(t){var e,r=function(t){if("undefined"===typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(t=o(t))){var e=0,r=function(){};return{s:r,n:function(){return e>=t.length?{done:!0}:{done:!1,value:t[e++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,i,a=!0,u=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}(d);try{for(r.s();!(e=r.n()).done;){var n=i(e.value,2),a=n[0],u=n[1];if(u.canHandle(t)){var c=i(u.serialize(t),2);return[{type:3,name:a,value:c[0]},c[1]]}}}catch(s){r.e(s)}finally{r.f()}return[{type:0,value:t},w.get(t)||[]]}function B(t){switch(t.type){case 3:return d.get(t.name).deserialize(t.value);case 0:return t.value}}function S(t,e,r){return new Promise((function(n){var o=new Array(4).fill(0).map((function(){return Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)})).join("-");t.addEventListener("message",(function e(r){r.data&&r.data.id&&r.data.id===o&&(t.removeEventListener("message",e),n(r.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:o},e),r)}))}var R=r(0),O=r.n(R);function k(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(s){return void r(s)}u.done?e(c):Promise.resolve(c).then(n,o)}var I=r(11),P=function(){var t,e=(t=O.a.mark((function t(e){var r;return O.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(I.scanImageData)(e);case 2:return r=t.sent,t.abrupt("return",r.map((function(t,e){return{index:e,type:t.typeName,value:t.decode(),points:t.points}})));case 4:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){k(i,n,o,a,u,"next",t)}function u(t){k(i,n,o,a,u,"throw",t)}a(void 0)}))});return function(t){return e.apply(this,arguments)}}();m(Object.keys(e).reduce((function(t,r){return"__esModule"==r||(t[r]=e[r]),t}),{}))}]);
2 | //# sourceMappingURL=5adc6a6833404f43b4fc.worker.js.map
--------------------------------------------------------------------------------
/docs/build/asset-manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "files": {
3 | "main.css": "/static/css/main.5f361e03.chunk.css",
4 | "main.js": "/static/js/main.6eb7939b.chunk.js",
5 | "main.js.map": "/static/js/main.6eb7939b.chunk.js.map",
6 | "runtime-main.js": "/static/js/runtime-main.429db5b2.js",
7 | "runtime-main.js.map": "/static/js/runtime-main.429db5b2.js.map",
8 | "static/js/2.81f07a75.chunk.js": "/static/js/2.81f07a75.chunk.js",
9 | "static/js/2.81f07a75.chunk.js.map": "/static/js/2.81f07a75.chunk.js.map",
10 | "5adc6a6833404f43b4fc.worker.js": "/5adc6a6833404f43b4fc.worker.js",
11 | "5adc6a6833404f43b4fc.worker.js.map": "/5adc6a6833404f43b4fc.worker.js.map",
12 | "index.html": "/index.html",
13 | "precache-manifest.66d346db6de698601a39ed8a709e2767.js": "/precache-manifest.66d346db6de698601a39ed8a709e2767.js",
14 | "service-worker.js": "/service-worker.js",
15 | "static/css/main.5f361e03.chunk.css.map": "/static/css/main.5f361e03.chunk.css.map",
16 | "static/js/2.81f07a75.chunk.js.LICENSE.txt": "/static/js/2.81f07a75.chunk.js.LICENSE.txt",
17 | "static/media/zbar.wasm.bin": "/static/media/zbar.wasm.b946c8e6.bin"
18 | },
19 | "entrypoints": [
20 | "static/js/runtime-main.429db5b2.js",
21 | "static/js/2.81f07a75.chunk.js",
22 | "static/css/main.5f361e03.chunk.css",
23 | "static/js/main.6eb7939b.chunk.js"
24 | ]
25 | }
--------------------------------------------------------------------------------
/docs/build/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fbedussi/react-code-scanner/fa93184bd3a4b6d394f57af69cff1ead8ae9965a/docs/build/favicon.ico
--------------------------------------------------------------------------------
/docs/build/index.html:
--------------------------------------------------------------------------------
1 | React Code Scanner
--------------------------------------------------------------------------------
/docs/build/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fbedussi/react-code-scanner/fa93184bd3a4b6d394f57af69cff1ead8ae9965a/docs/build/logo192.png
--------------------------------------------------------------------------------
/docs/build/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fbedussi/react-code-scanner/fa93184bd3a4b6d394f57af69cff1ead8ae9965a/docs/build/logo512.png
--------------------------------------------------------------------------------
/docs/build/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/docs/build/precache-manifest.66d346db6de698601a39ed8a709e2767.js:
--------------------------------------------------------------------------------
1 | self.__precacheManifest = (self.__precacheManifest || []).concat([
2 | {
3 | "revision": "4d558512867c1e5f376518f489970284",
4 | "url": "/5adc6a6833404f43b4fc.worker.js"
5 | },
6 | {
7 | "revision": "ac6188281c0dcfeae1b253c1ea418bc2",
8 | "url": "/index.html"
9 | },
10 | {
11 | "revision": "80e1ccb4c565d929adf4",
12 | "url": "/static/css/main.5f361e03.chunk.css"
13 | },
14 | {
15 | "revision": "592ac75ea7704b5a554d",
16 | "url": "/static/js/2.81f07a75.chunk.js"
17 | },
18 | {
19 | "revision": "e88a3e95b5364d46e95b35ae8c0dc27d",
20 | "url": "/static/js/2.81f07a75.chunk.js.LICENSE.txt"
21 | },
22 | {
23 | "revision": "80e1ccb4c565d929adf4",
24 | "url": "/static/js/main.6eb7939b.chunk.js"
25 | },
26 | {
27 | "revision": "de5510aa175980a3d98e",
28 | "url": "/static/js/runtime-main.429db5b2.js"
29 | },
30 | {
31 | "revision": "b946c8e627a45da7bbf33016aedb1ade",
32 | "url": "/static/media/zbar.wasm.b946c8e6.bin"
33 | }
34 | ]);
--------------------------------------------------------------------------------
/docs/build/precache-manifest.b2f3c5cb9416dc728ef8643b529823ad.js:
--------------------------------------------------------------------------------
1 | self.__precacheManifest = (self.__precacheManifest || []).concat([
2 | {
3 | "revision": "4d558512867c1e5f376518f489970284",
4 | "url": "/5adc6a6833404f43b4fc.worker.js"
5 | },
6 | {
7 | "revision": "d527d3ff5485aece87e00bb1f0a8900d",
8 | "url": "/index.html"
9 | },
10 | {
11 | "revision": "80e1ccb4c565d929adf4",
12 | "url": "/static/css/main.5f361e03.chunk.css"
13 | },
14 | {
15 | "revision": "592ac75ea7704b5a554d",
16 | "url": "/static/js/2.81f07a75.chunk.js"
17 | },
18 | {
19 | "revision": "e88a3e95b5364d46e95b35ae8c0dc27d",
20 | "url": "/static/js/2.81f07a75.chunk.js.LICENSE.txt"
21 | },
22 | {
23 | "revision": "80e1ccb4c565d929adf4",
24 | "url": "/static/js/main.6eb7939b.chunk.js"
25 | },
26 | {
27 | "revision": "de5510aa175980a3d98e",
28 | "url": "/static/js/runtime-main.429db5b2.js"
29 | },
30 | {
31 | "revision": "b946c8e627a45da7bbf33016aedb1ade",
32 | "url": "/static/media/zbar.wasm.b946c8e6.bin"
33 | }
34 | ]);
--------------------------------------------------------------------------------
/docs/build/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/docs/build/service-worker.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Welcome to your Workbox-powered service worker!
3 | *
4 | * You'll need to register this file in your web app and you should
5 | * disable HTTP caching for this file too.
6 | * See https://goo.gl/nhQhGp
7 | *
8 | * The rest of the code is auto-generated. Please don't update this file
9 | * directly; instead, make changes to your Workbox build configuration
10 | * and re-run your build process.
11 | * See https://goo.gl/2aRDsh
12 | */
13 |
14 | importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
15 |
16 | importScripts(
17 | "/precache-manifest.66d346db6de698601a39ed8a709e2767.js"
18 | );
19 |
20 | self.addEventListener('message', (event) => {
21 | if (event.data && event.data.type === 'SKIP_WAITING') {
22 | self.skipWaiting();
23 | }
24 | });
25 |
26 | workbox.core.clientsClaim();
27 |
28 | /**
29 | * The workboxSW.precacheAndRoute() method efficiently caches and responds to
30 | * requests for URLs in the manifest.
31 | * See https://goo.gl/S9QRab
32 | */
33 | self.__precacheManifest = [].concat(self.__precacheManifest || []);
34 | workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
35 |
36 | workbox.routing.registerNavigationRoute(workbox.precaching.getCacheKeyForURL("/index.html"), {
37 |
38 | blacklist: [/^\/_/,/\/[^\/?]+\.[^\/]+$/],
39 | });
40 |
--------------------------------------------------------------------------------
/docs/build/static/css/main.5f361e03.chunk.css:
--------------------------------------------------------------------------------
1 | body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}code{font-family:source-code-pro,Menlo,Monaco,Consolas,"Courier New",monospace}.App{text-align:center}.App-logo{height:40vmin;pointer-events:none}@media (prefers-reduced-motion:no-preference){.App-logo{-webkit-animation:App-logo-spin 20s linear infinite;animation:App-logo-spin 20s linear infinite}}.App-header{background-color:#282c34;min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;font-size:calc(10px + 2vmin);color:#fff}.App-link{color:#61dafb}@-webkit-keyframes App-logo-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@keyframes App-logo-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}
2 | /*# sourceMappingURL=main.5f361e03.chunk.css.map */
--------------------------------------------------------------------------------
/docs/build/static/css/main.5f361e03.chunk.css.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":["index.css","App.css"],"names":[],"mappings":"AAAA,KACE,QAAS,CACT,mJAEY,CACZ,kCAAmC,CACnC,iCACF,CAEA,KACE,yEAEF,CCZA,KACE,iBACF,CAEA,UACE,aAAc,CACd,mBACF,CAEA,8CACE,UACE,mDAA4C,CAA5C,2CACF,CACF,CAEA,YACE,wBAAyB,CACzB,gBAAiB,CACjB,YAAa,CACb,qBAAsB,CACtB,kBAAmB,CACnB,sBAAuB,CACvB,4BAA6B,CAC7B,UACF,CAEA,UACE,aACF,CAEA,iCACE,GACE,sBACF,CACA,GACE,uBACF,CACF,CAPA,yBACE,GACE,sBACF,CACA,GACE,uBACF,CACF","file":"main.5f361e03.chunk.css","sourcesContent":["body {\n margin: 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',\n monospace;\n}\n",".App {\n text-align: center;\n}\n\n.App-logo {\n height: 40vmin;\n pointer-events: none;\n}\n\n@media (prefers-reduced-motion: no-preference) {\n .App-logo {\n animation: App-logo-spin infinite 20s linear;\n }\n}\n\n.App-header {\n background-color: #282c34;\n min-height: 100vh;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n font-size: calc(10px + 2vmin);\n color: white;\n}\n\n.App-link {\n color: #61dafb;\n}\n\n@keyframes App-logo-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n"]}
--------------------------------------------------------------------------------
/docs/build/static/js/2.81f07a75.chunk.js.LICENSE.txt:
--------------------------------------------------------------------------------
1 | /*
2 | object-assign
3 | (c) Sindre Sorhus
4 | @license MIT
5 | */
6 |
7 | /** @license React v0.19.1
8 | * scheduler.production.min.js
9 | *
10 | * Copyright (c) Facebook, Inc. and its affiliates.
11 | *
12 | * This source code is licensed under the MIT license found in the
13 | * LICENSE file in the root directory of this source tree.
14 | */
15 |
16 | /** @license React v16.13.1
17 | * react-dom.production.min.js
18 | *
19 | * Copyright (c) Facebook, Inc. and its affiliates.
20 | *
21 | * This source code is licensed under the MIT license found in the
22 | * LICENSE file in the root directory of this source tree.
23 | */
24 |
25 | /** @license React v16.13.1
26 | * react.production.min.js
27 | *
28 | * Copyright (c) Facebook, Inc. and its affiliates.
29 | *
30 | * This source code is licensed under the MIT license found in the
31 | * LICENSE file in the root directory of this source tree.
32 | */
33 |
--------------------------------------------------------------------------------
/docs/build/static/js/main.6eb7939b.chunk.js:
--------------------------------------------------------------------------------
1 | (this["webpackJsonpcode-scanner"]=this["webpackJsonpcode-scanner"]||[]).push([[0],[,,,,,,,,,,function(e,t,n){var r,o=n(20).wrap,a=n(19);e.exports=function e(){return this instanceof e?o(a()):r||(r=o(a()))}},function(e,t,n){e.exports=n(21)},,,,,function(e,t,n){},function(e,t,n){},,function(e,t,n){e.exports=function(){return new Worker(n.p+"5adc6a6833404f43b4fc.worker.js")}},,function(e,t,n){"use strict";n.r(t);var r=n(0),o=n.n(r),a=n(9),c=n.n(a),i=(n(16),n(1)),s=(n(17),n(6)),d=n(2),u=n.n(d),l=n(7),f=n(10),m=new(0,n.n(f).a),h=function(){var e=Object(l.a)(u.a.mark((function e(t){var n,r,o,a,c;return u.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.video,r=t.maxVideoWidth,o=t.maxVideoHeight,a=t.facingMode,e.next=3,navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:a,width:{max:r},height:{max:o}}});case 3:return c=e.sent,n.srcObject=c,n.play(),e.next=8,new Promise((function(e){n.onloadedmetadata=e}));case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),v=function(e){var t=e.canvas,n=e.codes,r=e.facingMode,o=e.codeOverlayColor,a=e.codeIndexColor,c=e.mirrorUserImage,i=t.getContext("2d"),s=t.width,d=t.height;i.clearRect(0,0,s,d),i.font="20px serif",i.strokeStyle=o,i.fillStyle=a,i.lineWidth=6,n.forEach((function(e,t){var n=e.points;i.beginPath();for(var o=0;o {\n const mediaStream = await navigator.mediaDevices.getUserMedia({\n audio: false,\n video: {\n facingMode,\n width: { max: maxVideoWidth },\n height: { max: maxVideoHeight },\n },\n });\n video.srcObject = mediaStream;\n video.play();\n await new Promise(r => {\n video.onloadedmetadata = r;\n });\n};\n\nconst renderOverlay = ({\n canvas,\n codes,\n facingMode,\n codeOverlayColor,\n codeIndexColor,\n mirrorUserImage,\n}) => {\n const ctx = canvas.getContext('2d');\n const width = canvas.width;\n const height = canvas.height;\n ctx.clearRect(0, 0, width, height);\n ctx.font = '20px serif';\n ctx.strokeStyle = codeOverlayColor;\n ctx.fillStyle = codeIndexColor;\n ctx.lineWidth = 6;\n codes.forEach((sym, i) => {\n const points = sym.points;\n ctx.beginPath();\n for (let j = 0; j < points.length; ++j) {\n const { x, y } = points[j];\n if (j === 0) {\n ctx.moveTo(x, y);\n } else {\n ctx.lineTo(x, y);\n }\n }\n ctx.closePath();\n\n ctx.stroke();\n ctx.scale(getScaleX(mirrorUserImage, facingMode), 1);\n ctx.fillText('#' + i, points[0].x, points[0].y - 10);\n ctx.scale(1, 1);\n });\n};\n\nconst processImage = async ({\n video,\n canvas,\n onResult,\n facingMode,\n codeOverlayColor,\n codeIndexColor,\n mirrorUserImage,\n}) => {\n const width = video.videoWidth;\n const height = video.videoHeight;\n canvas.width = width;\n canvas.height = height;\n if (!width || !height) {\n return;\n }\n\n const ctx = canvas.getContext('2d');\n ctx.drawImage(video, 0, 0, width, height);\n const imgData = ctx.getImageData(0, 0, width, height);\n const codes = await scannerWorker.scanImageData(imgData);\n renderOverlay({\n canvas,\n codes,\n facingMode,\n codeOverlayColor,\n codeIndexColor,\n mirrorUserImage,\n });\n if (codes.length) {\n onResult(codes);\n }\n};\n\nconst sleep = ms =>\n new Promise(r => {\n setTimeout(r, ms);\n });\n\nconst main = async ({\n video,\n canvas,\n onResult,\n onError,\n maxVideoWidth,\n maxVideoHeight,\n facingMode,\n codeOverlayColor,\n codeIndexColor,\n mirrorUserImage,\n}) => {\n try {\n await init({ video, maxVideoWidth, maxVideoHeight, facingMode });\n\n while (true) {\n await processImage({\n video,\n canvas,\n onResult,\n facingMode,\n codeOverlayColor,\n codeIndexColor,\n mirrorUserImage,\n });\n await sleep(SCAN_PROID_MS);\n }\n } catch (err) {\n onError(err.message);\n }\n};\n\nconst getScaleX = (mirrorUserImage, facingMode) =>\n mirrorUserImage && facingMode === 'user' ? -1 : 1;\n\nconst CodeScanner = parentProps => {\n const defaultOptions = {\n width: 400,\n height: 300,\n onResult: console.log,\n onError: console.error,\n maxVideoWidth: 640,\n maxVideoHeight: 640,\n facingMode: 'environment',\n codeOverlayColor: '#00ff00',\n codeIndexColor: '#ff0000',\n mirrorUserImage: true,\n };\n const options = {\n ...defaultOptions,\n ...parentProps,\n };\n const {\n width,\n height,\n onResult,\n onError,\n maxVideoWidth,\n maxVideoHeight,\n facingMode,\n codeOverlayColor,\n codeIndexColor,\n mirrorUserImage,\n } = options;\n\n const videoRef = useRef(null);\n const canvasRef = useRef(null);\n\n useEffect(() => {\n if (videoRef.current && canvasRef.current) {\n main({\n video: videoRef.current,\n canvas: canvasRef.current,\n onResult,\n onError,\n maxVideoWidth,\n maxVideoHeight,\n facingMode,\n codeOverlayColor,\n codeIndexColor,\n mirrorUserImage,\n });\n }\n }, [\n videoRef,\n canvasRef,\n onResult,\n onError,\n maxVideoWidth,\n maxVideoHeight,\n facingMode,\n codeOverlayColor,\n codeIndexColor,\n mirrorUserImage,\n ]);\n\n const style = {\n position: 'absolute',\n top: 0,\n left: 0,\n width: `${width}px`,\n height: `${height}px`,\n };\n return (\n \n \n \n
\n );\n};\n\nexport default CodeScanner;\n","// eslint-disable-next-line\nimport Worker from 'comlink-loader!./worker'; // inline loader\n\nexport default Worker;\n","import React, { useState } from 'react';\nimport './App.css';\nimport CodeScanner from './CodeScanner';\n\nfunction App() {\n const [result, setResult] = useState('');\n const [facingMode, setFacingMode] = useState('environment');\n\n return (\n \n
React Code Scanner
\n
Result: {result}
\n
\n \n
\n
\n \n
\n
setResult(res.map(({ value }) => value).join(', '))}\n onError={setResult}\n facingMode={facingMode}\n />\n \n );\n}\n\nexport default App;\n","// This optional code is used to register a service worker.\n// register() is not called by default.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on subsequent visits to a page, after all the\n// existing tabs open on the page have been closed, since previously cached\n// resources are updated in the background.\n\n// To learn more about the benefits of this model and instructions on how to\n// opt-in, read https://bit.ly/CRA-PWA\n\nconst isLocalhost = Boolean(\n window.location.hostname === 'localhost' ||\n // [::1] is the IPv6 localhost address.\n window.location.hostname === '[::1]' ||\n // 127.0.0.0/8 are considered localhost for IPv4.\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\n\nexport function register(config) {\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\n // The URL constructor is available in all browsers that support SW.\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\n if (publicUrl.origin !== window.location.origin) {\n // Our service worker won't work if PUBLIC_URL is on a different origin\n // from what our page is served on. This might happen if a CDN is used to\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\n return;\n }\n\n window.addEventListener('load', () => {\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\n\n if (isLocalhost) {\n // This is running on localhost. Let's check if a service worker still exists or not.\n checkValidServiceWorker(swUrl, config);\n\n // Add some additional logging to localhost, pointing developers to the\n // service worker/PWA documentation.\n navigator.serviceWorker.ready.then(() => {\n console.log(\n 'This web app is being served cache-first by a service ' +\n 'worker. To learn more, visit https://bit.ly/CRA-PWA'\n );\n });\n } else {\n // Is not localhost. Just register service worker\n registerValidSW(swUrl, config);\n }\n });\n }\n}\n\nfunction registerValidSW(swUrl, config) {\n navigator.serviceWorker\n .register(swUrl)\n .then(registration => {\n registration.onupdatefound = () => {\n const installingWorker = registration.installing;\n if (installingWorker == null) {\n return;\n }\n installingWorker.onstatechange = () => {\n if (installingWorker.state === 'installed') {\n if (navigator.serviceWorker.controller) {\n // At this point, the updated precached content has been fetched,\n // but the previous service worker will still serve the older\n // content until all client tabs are closed.\n console.log(\n 'New content is available and will be used when all ' +\n 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'\n );\n\n // Execute callback\n if (config && config.onUpdate) {\n config.onUpdate(registration);\n }\n } else {\n // At this point, everything has been precached.\n // It's the perfect time to display a\n // \"Content is cached for offline use.\" message.\n console.log('Content is cached for offline use.');\n\n // Execute callback\n if (config && config.onSuccess) {\n config.onSuccess(registration);\n }\n }\n }\n };\n };\n })\n .catch(error => {\n console.error('Error during service worker registration:', error);\n });\n}\n\nfunction checkValidServiceWorker(swUrl, config) {\n // Check if the service worker can be found. If it can't reload the page.\n fetch(swUrl, {\n headers: { 'Service-Worker': 'script' },\n })\n .then(response => {\n // Ensure service worker exists, and that we really are getting a JS file.\n const contentType = response.headers.get('content-type');\n if (\n response.status === 404 ||\n (contentType != null && contentType.indexOf('javascript') === -1)\n ) {\n // No service worker found. Probably a different app. Reload the page.\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister().then(() => {\n window.location.reload();\n });\n });\n } else {\n // Service worker found. Proceed as normal.\n registerValidSW(swUrl, config);\n }\n })\n .catch(() => {\n console.log(\n 'No internet connection found. App is running in offline mode.'\n );\n });\n}\n\nexport function unregister() {\n if ('serviceWorker' in navigator) {\n navigator.serviceWorker.ready\n .then(registration => {\n registration.unregister();\n })\n .catch(error => {\n console.error(error.message);\n });\n }\n}\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport './index.css';\nimport App from './App';\nimport * as serviceWorker from './serviceWorker';\n\nReactDOM.render(\n \n \n ,\n document.getElementById('root')\n);\n\n// If you want your app to work offline and load faster, you can change\n// unregister() to register() below. Note this comes with some pitfalls.\n// Learn more about service workers: https://bit.ly/CRA-PWA\nserviceWorker.unregister();\n"],"sourceRoot":""}
--------------------------------------------------------------------------------
/docs/build/static/js/runtime-main.429db5b2.js:
--------------------------------------------------------------------------------
1 | !function(e){function r(r){for(var n,l,a=r[0],c=r[1],f=r[2],p=0,s=[];pReact Code Scanner
2 |
--------------------------------------------------------------------------------
/docs/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fbedussi/react-code-scanner/fa93184bd3a4b6d394f57af69cff1ead8ae9965a/docs/logo192.png
--------------------------------------------------------------------------------
/docs/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fbedussi/react-code-scanner/fa93184bd3a4b6d394f57af69cff1ead8ae9965a/docs/logo512.png
--------------------------------------------------------------------------------
/docs/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/docs/precache-manifest.0a252a7546d76ced201dbda56f06b4ef.js:
--------------------------------------------------------------------------------
1 | self.__precacheManifest = (self.__precacheManifest || []).concat([
2 | {
3 | "revision": "4d558512867c1e5f376518f489970284",
4 | "url": "/5adc6a6833404f43b4fc.worker.js"
5 | },
6 | {
7 | "revision": "05ff9b6cc784e38988bfbaf309410fe7",
8 | "url": "/index.html"
9 | },
10 | {
11 | "revision": "823fbed51b1d89ede98b",
12 | "url": "/static/css/main.5f361e03.chunk.css"
13 | },
14 | {
15 | "revision": "592ac75ea7704b5a554d",
16 | "url": "/static/js/2.81f07a75.chunk.js"
17 | },
18 | {
19 | "revision": "e88a3e95b5364d46e95b35ae8c0dc27d",
20 | "url": "/static/js/2.81f07a75.chunk.js.LICENSE.txt"
21 | },
22 | {
23 | "revision": "823fbed51b1d89ede98b",
24 | "url": "/static/js/main.e6fe3195.chunk.js"
25 | },
26 | {
27 | "revision": "de5510aa175980a3d98e",
28 | "url": "/static/js/runtime-main.429db5b2.js"
29 | },
30 | {
31 | "revision": "b946c8e627a45da7bbf33016aedb1ade",
32 | "url": "/static/media/zbar.wasm.b946c8e6.bin"
33 | }
34 | ]);
--------------------------------------------------------------------------------
/docs/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/docs/service-worker.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Welcome to your Workbox-powered service worker!
3 | *
4 | * You'll need to register this file in your web app and you should
5 | * disable HTTP caching for this file too.
6 | * See https://goo.gl/nhQhGp
7 | *
8 | * The rest of the code is auto-generated. Please don't update this file
9 | * directly; instead, make changes to your Workbox build configuration
10 | * and re-run your build process.
11 | * See https://goo.gl/2aRDsh
12 | */
13 |
14 | importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
15 |
16 | importScripts(
17 | "/precache-manifest.0a252a7546d76ced201dbda56f06b4ef.js"
18 | );
19 |
20 | self.addEventListener('message', (event) => {
21 | if (event.data && event.data.type === 'SKIP_WAITING') {
22 | self.skipWaiting();
23 | }
24 | });
25 |
26 | workbox.core.clientsClaim();
27 |
28 | /**
29 | * The workboxSW.precacheAndRoute() method efficiently caches and responds to
30 | * requests for URLs in the manifest.
31 | * See https://goo.gl/S9QRab
32 | */
33 | self.__precacheManifest = [].concat(self.__precacheManifest || []);
34 | workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
35 |
36 | workbox.routing.registerNavigationRoute(workbox.precaching.getCacheKeyForURL("/index.html"), {
37 |
38 | blacklist: [/^\/_/,/\/[^\/?]+\.[^\/]+$/],
39 | });
40 |
--------------------------------------------------------------------------------
/docs/static/css/main.5f361e03.chunk.css:
--------------------------------------------------------------------------------
1 | body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}code{font-family:source-code-pro,Menlo,Monaco,Consolas,"Courier New",monospace}.App{text-align:center}.App-logo{height:40vmin;pointer-events:none}@media (prefers-reduced-motion:no-preference){.App-logo{-webkit-animation:App-logo-spin 20s linear infinite;animation:App-logo-spin 20s linear infinite}}.App-header{background-color:#282c34;min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;font-size:calc(10px + 2vmin);color:#fff}.App-link{color:#61dafb}@-webkit-keyframes App-logo-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@keyframes App-logo-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}
2 | /*# sourceMappingURL=main.5f361e03.chunk.css.map */
--------------------------------------------------------------------------------
/docs/static/css/main.5f361e03.chunk.css.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":["index.css","App.css"],"names":[],"mappings":"AAAA,KACE,QAAS,CACT,mJAEY,CACZ,kCAAmC,CACnC,iCACF,CAEA,KACE,yEAEF,CCZA,KACE,iBACF,CAEA,UACE,aAAc,CACd,mBACF,CAEA,8CACE,UACE,mDAA4C,CAA5C,2CACF,CACF,CAEA,YACE,wBAAyB,CACzB,gBAAiB,CACjB,YAAa,CACb,qBAAsB,CACtB,kBAAmB,CACnB,sBAAuB,CACvB,4BAA6B,CAC7B,UACF,CAEA,UACE,aACF,CAEA,iCACE,GACE,sBACF,CACA,GACE,uBACF,CACF,CAPA,yBACE,GACE,sBACF,CACA,GACE,uBACF,CACF","file":"main.5f361e03.chunk.css","sourcesContent":["body {\n margin: 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',\n monospace;\n}\n",".App {\n text-align: center;\n}\n\n.App-logo {\n height: 40vmin;\n pointer-events: none;\n}\n\n@media (prefers-reduced-motion: no-preference) {\n .App-logo {\n animation: App-logo-spin infinite 20s linear;\n }\n}\n\n.App-header {\n background-color: #282c34;\n min-height: 100vh;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n font-size: calc(10px + 2vmin);\n color: white;\n}\n\n.App-link {\n color: #61dafb;\n}\n\n@keyframes App-logo-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n"]}
--------------------------------------------------------------------------------
/docs/static/js/2.81f07a75.chunk.js.LICENSE.txt:
--------------------------------------------------------------------------------
1 | /*
2 | object-assign
3 | (c) Sindre Sorhus
4 | @license MIT
5 | */
6 |
7 | /** @license React v0.19.1
8 | * scheduler.production.min.js
9 | *
10 | * Copyright (c) Facebook, Inc. and its affiliates.
11 | *
12 | * This source code is licensed under the MIT license found in the
13 | * LICENSE file in the root directory of this source tree.
14 | */
15 |
16 | /** @license React v16.13.1
17 | * react-dom.production.min.js
18 | *
19 | * Copyright (c) Facebook, Inc. and its affiliates.
20 | *
21 | * This source code is licensed under the MIT license found in the
22 | * LICENSE file in the root directory of this source tree.
23 | */
24 |
25 | /** @license React v16.13.1
26 | * react.production.min.js
27 | *
28 | * Copyright (c) Facebook, Inc. and its affiliates.
29 | *
30 | * This source code is licensed under the MIT license found in the
31 | * LICENSE file in the root directory of this source tree.
32 | */
33 |
--------------------------------------------------------------------------------
/docs/static/js/main.e6fe3195.chunk.js:
--------------------------------------------------------------------------------
1 | (this["webpackJsonpcode-scanner"]=this["webpackJsonpcode-scanner"]||[]).push([[0],[,,,,,,,,,,function(e,t,n){var r,o=n(20).wrap,a=n(19);e.exports=function e(){return this instanceof e?o(a()):r||(r=o(a()))}},function(e,t,n){e.exports=n(21)},,,,,function(e,t,n){},function(e,t,n){},,function(e,t,n){e.exports=function(){return new Worker(n.p+"5adc6a6833404f43b4fc.worker.js")}},,function(e,t,n){"use strict";n.r(t);var r=n(0),o=n.n(r),a=n(9),c=n.n(a),i=(n(16),n(1)),s=(n(17),n(6)),d=n(2),u=n.n(d),l=n(7),f=n(10),m=new(0,n.n(f).a),h=function(){var e=Object(l.a)(u.a.mark((function e(t){var n,r,o,a,c;return u.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.video,r=t.maxVideoWidth,o=t.maxVideoHeight,a=t.facingMode,e.next=3,navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:a,width:{max:r},height:{max:o}}});case 3:return c=e.sent,n.srcObject=c,n.play(),e.next=8,new Promise((function(e){n.onloadedmetadata=e}));case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),v=function(e){var t=e.canvas,n=e.codes,r=e.facingMode,o=e.codeOverlayColor,a=e.codeIndexColor,c=e.mirrorUserImage,i=t.getContext("2d"),s=t.width,d=t.height;i.clearRect(0,0,s,d),i.font="20px serif",i.strokeStyle=o,i.fillStyle=a,i.lineWidth=6,n.forEach((function(e,t){var n=e.points;i.beginPath();for(var o=0;o {\n const mediaStream = await navigator.mediaDevices.getUserMedia({\n audio: false,\n video: {\n facingMode,\n width: { max: maxVideoWidth },\n height: { max: maxVideoHeight },\n },\n });\n video.srcObject = mediaStream;\n video.play();\n await new Promise(r => {\n video.onloadedmetadata = r;\n });\n};\n\nconst renderOverlay = ({\n canvas,\n codes,\n facingMode,\n codeOverlayColor,\n codeIndexColor,\n mirrorUserImage,\n}) => {\n const ctx = canvas.getContext('2d');\n const width = canvas.width;\n const height = canvas.height;\n ctx.clearRect(0, 0, width, height);\n ctx.font = '20px serif';\n ctx.strokeStyle = codeOverlayColor;\n ctx.fillStyle = codeIndexColor;\n ctx.lineWidth = 6;\n codes.forEach((sym, i) => {\n const points = sym.points;\n ctx.beginPath();\n for (let j = 0; j < points.length; ++j) {\n const { x, y } = points[j];\n if (j === 0) {\n ctx.moveTo(x, y);\n } else {\n ctx.lineTo(x, y);\n }\n }\n ctx.closePath();\n\n ctx.stroke();\n ctx.scale(getScaleX(mirrorUserImage, facingMode), 1);\n ctx.fillText('#' + i, points[0].x, points[0].y - 10);\n ctx.scale(1, 1);\n });\n};\n\nconst processImage = async ({\n video,\n canvas,\n onResult,\n facingMode,\n codeOverlayColor,\n codeIndexColor,\n mirrorUserImage,\n}) => {\n const width = video.videoWidth;\n const height = video.videoHeight;\n canvas.width = width;\n canvas.height = height;\n if (!width || !height) {\n return;\n }\n\n const ctx = canvas.getContext('2d');\n ctx.drawImage(video, 0, 0, width, height);\n const imgData = ctx.getImageData(0, 0, width, height);\n const codes = await scannerWorker.scanImageData(imgData);\n renderOverlay({\n canvas,\n codes,\n facingMode,\n codeOverlayColor,\n codeIndexColor,\n mirrorUserImage,\n });\n if (codes.length) {\n onResult(codes);\n }\n};\n\nconst sleep = ms =>\n new Promise(r => {\n setTimeout(r, ms);\n });\n\nconst main = async ({\n video,\n canvas,\n onResult,\n onError,\n maxVideoWidth,\n maxVideoHeight,\n facingMode,\n codeOverlayColor,\n codeIndexColor,\n mirrorUserImage,\n}) => {\n try {\n await init({ video, maxVideoWidth, maxVideoHeight, facingMode });\n\n while (true) {\n await processImage({\n video,\n canvas,\n onResult,\n facingMode,\n codeOverlayColor,\n codeIndexColor,\n mirrorUserImage,\n });\n await sleep(SCAN_PROID_MS);\n }\n } catch (err) {\n onError(err.message);\n }\n};\n\nconst getScaleX = (mirrorUserImage, facingMode) =>\n mirrorUserImage && facingMode === 'user' ? -1 : 1;\n\nconst CodeScanner = parentProps => {\n const defaultOptions = {\n width: 400,\n height: 300,\n onResult: console.log,\n onError: console.error,\n maxVideoWidth: 640,\n maxVideoHeight: 640,\n facingMode: 'environment',\n codeOverlayColor: '#00ff00',\n codeIndexColor: '#ff0000',\n mirrorUserImage: true,\n };\n const options = {\n ...defaultOptions,\n ...parentProps,\n };\n const {\n width,\n height,\n onResult,\n onError,\n maxVideoWidth,\n maxVideoHeight,\n facingMode,\n codeOverlayColor,\n codeIndexColor,\n mirrorUserImage,\n } = options;\n\n const videoRef = useRef(null);\n const canvasRef = useRef(null);\n\n useEffect(() => {\n if (videoRef.current && canvasRef.current) {\n main({\n video: videoRef.current,\n canvas: canvasRef.current,\n onResult,\n onError,\n maxVideoWidth,\n maxVideoHeight,\n facingMode,\n codeOverlayColor,\n codeIndexColor,\n mirrorUserImage,\n });\n }\n }, [\n videoRef,\n canvasRef,\n onResult,\n onError,\n maxVideoWidth,\n maxVideoHeight,\n facingMode,\n codeOverlayColor,\n codeIndexColor,\n mirrorUserImage,\n ]);\n\n const style = {\n position: 'absolute',\n top: 0,\n left: 0,\n width: `${width}px`,\n height: `${height}px`,\n };\n return (\n \n \n \n
\n );\n};\n\nexport default CodeScanner;\n","// eslint-disable-next-line\nimport Worker from 'comlink-loader!./worker'; // inline loader\n\nexport default Worker;\n","import React, { useState } from 'react';\nimport './App.css';\nimport CodeScanner from './CodeScanner';\n\nfunction App() {\n const [result, setResult] = useState('');\n const [facingMode, setFacingMode] = useState('environment');\n\n return (\n \n
Code Scanner
\n
Result: {result}
\n
\n \n
\n
\n \n
\n
setResult(res.map(({ value }) => value).join(', '))}\n onError={setResult}\n facingMode={facingMode}\n />\n \n );\n}\n\nexport default App;\n","// This optional code is used to register a service worker.\n// register() is not called by default.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on subsequent visits to a page, after all the\n// existing tabs open on the page have been closed, since previously cached\n// resources are updated in the background.\n\n// To learn more about the benefits of this model and instructions on how to\n// opt-in, read https://bit.ly/CRA-PWA\n\nconst isLocalhost = Boolean(\n window.location.hostname === 'localhost' ||\n // [::1] is the IPv6 localhost address.\n window.location.hostname === '[::1]' ||\n // 127.0.0.0/8 are considered localhost for IPv4.\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\n\nexport function register(config) {\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\n // The URL constructor is available in all browsers that support SW.\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\n if (publicUrl.origin !== window.location.origin) {\n // Our service worker won't work if PUBLIC_URL is on a different origin\n // from what our page is served on. This might happen if a CDN is used to\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\n return;\n }\n\n window.addEventListener('load', () => {\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\n\n if (isLocalhost) {\n // This is running on localhost. Let's check if a service worker still exists or not.\n checkValidServiceWorker(swUrl, config);\n\n // Add some additional logging to localhost, pointing developers to the\n // service worker/PWA documentation.\n navigator.serviceWorker.ready.then(() => {\n console.log(\n 'This web app is being served cache-first by a service ' +\n 'worker. To learn more, visit https://bit.ly/CRA-PWA'\n );\n });\n } else {\n // Is not localhost. Just register service worker\n registerValidSW(swUrl, config);\n }\n });\n }\n}\n\nfunction registerValidSW(swUrl, config) {\n navigator.serviceWorker\n .register(swUrl)\n .then(registration => {\n registration.onupdatefound = () => {\n const installingWorker = registration.installing;\n if (installingWorker == null) {\n return;\n }\n installingWorker.onstatechange = () => {\n if (installingWorker.state === 'installed') {\n if (navigator.serviceWorker.controller) {\n // At this point, the updated precached content has been fetched,\n // but the previous service worker will still serve the older\n // content until all client tabs are closed.\n console.log(\n 'New content is available and will be used when all ' +\n 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'\n );\n\n // Execute callback\n if (config && config.onUpdate) {\n config.onUpdate(registration);\n }\n } else {\n // At this point, everything has been precached.\n // It's the perfect time to display a\n // \"Content is cached for offline use.\" message.\n console.log('Content is cached for offline use.');\n\n // Execute callback\n if (config && config.onSuccess) {\n config.onSuccess(registration);\n }\n }\n }\n };\n };\n })\n .catch(error => {\n console.error('Error during service worker registration:', error);\n });\n}\n\nfunction checkValidServiceWorker(swUrl, config) {\n // Check if the service worker can be found. If it can't reload the page.\n fetch(swUrl, {\n headers: { 'Service-Worker': 'script' },\n })\n .then(response => {\n // Ensure service worker exists, and that we really are getting a JS file.\n const contentType = response.headers.get('content-type');\n if (\n response.status === 404 ||\n (contentType != null && contentType.indexOf('javascript') === -1)\n ) {\n // No service worker found. Probably a different app. Reload the page.\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister().then(() => {\n window.location.reload();\n });\n });\n } else {\n // Service worker found. Proceed as normal.\n registerValidSW(swUrl, config);\n }\n })\n .catch(() => {\n console.log(\n 'No internet connection found. App is running in offline mode.'\n );\n });\n}\n\nexport function unregister() {\n if ('serviceWorker' in navigator) {\n navigator.serviceWorker.ready\n .then(registration => {\n registration.unregister();\n })\n .catch(error => {\n console.error(error.message);\n });\n }\n}\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport './index.css';\nimport App from './App';\nimport * as serviceWorker from './serviceWorker';\n\nReactDOM.render(\n \n \n ,\n document.getElementById('root')\n);\n\n// If you want your app to work offline and load faster, you can change\n// unregister() to register() below. Note this comes with some pitfalls.\n// Learn more about service workers: https://bit.ly/CRA-PWA\nserviceWorker.unregister();\n"],"sourceRoot":""}
--------------------------------------------------------------------------------
/docs/static/js/runtime-main.429db5b2.js:
--------------------------------------------------------------------------------
1 | !function(e){function r(r){for(var n,l,a=r[0],c=r[1],f=r[2],p=0,s=[];p {
9 | return new Promise(res => {
10 | const cb = e => {
11 | res(e.data.response);
12 | };
13 | scannerWorker.addEventListener('message', cb);
14 | scannerWorker.postMessage({
15 | imageData,
16 | });
17 | });
18 | };
19 |
20 | const init = async ({ video, maxVideoWidth, maxVideoHeight, facingMode }) => {
21 | const mediaStream = await navigator.mediaDevices.getUserMedia({
22 | audio: false,
23 | video: {
24 | facingMode,
25 | width: { max: maxVideoWidth },
26 | height: { max: maxVideoHeight },
27 | },
28 | });
29 | video.srcObject = mediaStream;
30 | video.play();
31 | await new Promise(r => {
32 | video.onloadedmetadata = r;
33 | });
34 | };
35 |
36 | const renderOverlay = ({
37 | canvas,
38 | codes,
39 | facingMode,
40 | codeOverlayColor,
41 | codeIndexColor,
42 | mirrorUserImage,
43 | }) => {
44 | const ctx = canvas.getContext('2d');
45 | const width = canvas.width;
46 | const height = canvas.height;
47 | ctx.clearRect(0, 0, width, height);
48 | ctx.font = '20px serif';
49 | ctx.strokeStyle = codeOverlayColor;
50 | ctx.fillStyle = codeIndexColor;
51 | ctx.lineWidth = 6;
52 | codes.forEach((sym, i) => {
53 | const points = sym.points;
54 | ctx.beginPath();
55 | for (let j = 0; j < points.length; ++j) {
56 | const { x, y } = points[j];
57 | if (j === 0) {
58 | ctx.moveTo(x, y);
59 | } else {
60 | ctx.lineTo(x, y);
61 | }
62 | }
63 | ctx.closePath();
64 |
65 | ctx.stroke();
66 | ctx.scale(getScaleX(mirrorUserImage, facingMode), 1);
67 | ctx.fillText('#' + i, points[0].x, points[0].y - 10);
68 | ctx.scale(1, 1);
69 | });
70 | };
71 |
72 | const processImage = async ({
73 | video,
74 | canvas,
75 | onResult,
76 | facingMode,
77 | codeOverlayColor,
78 | codeIndexColor,
79 | mirrorUserImage,
80 | }) => {
81 | const width = video.videoWidth;
82 | const height = video.videoHeight;
83 | canvas.width = width;
84 | canvas.height = height;
85 | if (!width || !height) {
86 | return;
87 | }
88 |
89 | const ctx = canvas.getContext('2d');
90 | ctx.drawImage(video, 0, 0, width, height);
91 | const imgData = ctx.getImageData(0, 0, width, height);
92 | const codes = await scanImageData(imgData);
93 | renderOverlay({
94 | canvas,
95 | codes,
96 | facingMode,
97 | codeOverlayColor,
98 | codeIndexColor,
99 | mirrorUserImage,
100 | });
101 | if (codes.length) {
102 | onResult(codes);
103 | }
104 | };
105 |
106 | const sleep = ms =>
107 | new Promise(r => {
108 | setTimeout(r, ms);
109 | });
110 |
111 | const main = async ({
112 | video,
113 | canvas,
114 | onResult,
115 | onError,
116 | maxVideoWidth,
117 | maxVideoHeight,
118 | facingMode,
119 | codeOverlayColor,
120 | codeIndexColor,
121 | mirrorUserImage,
122 | }) => {
123 | try {
124 | await init({ video, maxVideoWidth, maxVideoHeight, facingMode });
125 |
126 | while (true) {
127 | await processImage({
128 | video,
129 | canvas,
130 | onResult,
131 | facingMode,
132 | codeOverlayColor,
133 | codeIndexColor,
134 | mirrorUserImage,
135 | });
136 | await sleep(SCAN_PROID_MS);
137 | }
138 | } catch (err) {
139 | onError(err.message);
140 | }
141 | };
142 |
143 | const getScaleX = (mirrorUserImage, facingMode) =>
144 | mirrorUserImage && facingMode === 'user' ? -1 : 1;
145 |
146 | const CodeScanner = parentProps => {
147 | const defaultOptions = {
148 | width: 400,
149 | height: 300,
150 | onResult: console.log,
151 | onError: console.error,
152 | maxVideoWidth: 640,
153 | maxVideoHeight: 640,
154 | facingMode: 'environment',
155 | codeOverlayColor: '#00ff00',
156 | codeIndexColor: '#ff0000',
157 | mirrorUserImage: true,
158 | };
159 | const options = {
160 | ...defaultOptions,
161 | ...parentProps,
162 | };
163 | const {
164 | width,
165 | height,
166 | onResult,
167 | onError,
168 | maxVideoWidth,
169 | maxVideoHeight,
170 | facingMode,
171 | codeOverlayColor,
172 | codeIndexColor,
173 | mirrorUserImage,
174 | } = options;
175 |
176 | const videoRef = useRef(null);
177 | const canvasRef = useRef(null);
178 |
179 | useEffect(() => {
180 | if (videoRef.current && canvasRef.current) {
181 | main({
182 | video: videoRef.current,
183 | canvas: canvasRef.current,
184 | onResult,
185 | onError,
186 | maxVideoWidth,
187 | maxVideoHeight,
188 | facingMode,
189 | codeOverlayColor,
190 | codeIndexColor,
191 | mirrorUserImage,
192 | });
193 | }
194 | }, [
195 | videoRef,
196 | canvasRef,
197 | onResult,
198 | onError,
199 | maxVideoWidth,
200 | maxVideoHeight,
201 | facingMode,
202 | codeOverlayColor,
203 | codeIndexColor,
204 | mirrorUserImage,
205 | ]);
206 |
207 | const style = {
208 | position: 'absolute',
209 | top: 0,
210 | left: 0,
211 | width: `${width}px`,
212 | height: `${height}px`,
213 | };
214 | return (
215 |
222 |
223 |
224 |
225 | );
226 | };
227 |
228 | export default CodeScanner;
229 |
--------------------------------------------------------------------------------
/src/code-scanner.worker.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-restricted-globals */
2 | import { scanImageData } from 'zbar.wasm';
3 |
4 | self.addEventListener('message', async e => {
5 | const symbols = await scanImageData(e.data.imageData);
6 | const response = symbols.map((sym, i) => ({
7 | index: i,
8 | type: sym.typeName,
9 | value: sym.decode(),
10 | points: sym.points,
11 | }));
12 | self.postMessage({ response });
13 | });
14 |
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | var path = require('path');
2 |
3 | module.exports = {
4 | mode: 'production',
5 | entry: './src/CodeScanner.jsx',
6 | output: {
7 | path: path.resolve('lib'),
8 | filename: 'CodeScanner.js',
9 | libraryTarget: 'commonjs2'
10 | },
11 | module: {
12 | rules: [
13 | {
14 | test: /\.wasm(.bin)?$/,
15 | use: ['wasm-loader']
16 | },
17 | {
18 | test: /\.worker\.js$/,
19 | use: {
20 | loader: 'worker-loader',
21 | },
22 | },
23 | {
24 | test: /\.jsx?$/,
25 | exclude: /(node_modules)/,
26 | use: 'babel-loader'
27 | }
28 | ]
29 | }
30 | }
31 |
--------------------------------------------------------------------------------