diff --git a/README.md b/README.md index aff6c93..4cfdbf5 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,12 @@ file is only valid for the non-uglified version `quagga.js` because the minified version is altered after compression and does not align with the map file any more. +### Node + +The code in the `dist` folder is only targeted to the browser and won't work in +node due to the dependency on the DOM. For the use in node, the `build` command +also creates a `quagga.js` file in the `lib` folder. + ## API You can check out the [examples][github_examples] to get an idea of how to @@ -545,6 +551,13 @@ on the ``singleChannel`` flag in the configuration when using ``decodeSingle``. ## Changelog +### 2016-02-18 + +- Internal Changes + - Restructuring into meaningful folders + - Removing debug-code in production build + + ### 2016-02-15 Take a look at the release-notes ([0.9.0] (https://github.com/serratus/quaggaJS/releases/tag/v0.9.0)) diff --git a/src/decoder/barcode_decoder.js b/src/decoder/barcode_decoder.js index 1583072..11a32a2 100644 --- a/src/decoder/barcode_decoder.js +++ b/src/decoder/barcode_decoder.js @@ -82,12 +82,16 @@ export default { } else if (typeof readerConfig === 'string') { reader = readerConfig; } - console.log("Before registering reader: ", reader); + if (ENV.development) { + console.log("Before registering reader: ", reader); + } _barcodeReaders.push(new READERS[reader](configuration)); }); - console.log("Registered Readers: " + _barcodeReaders - .map((reader) => JSON.stringify({format: reader.FORMAT, config: reader.config})) - .join(', ')); + if (ENV.development) { + console.log("Registered Readers: " + _barcodeReaders + .map((reader) => JSON.stringify({format: reader.FORMAT, config: reader.config})) + .join(', ')); + } } function initConfig() { diff --git a/src/input/camera_access.js b/src/input/camera_access.js index addcb7d..ed741b1 100644 --- a/src/input/camera_access.js +++ b/src/input/camera_access.js @@ -27,7 +27,9 @@ function loadedData(video, callback) { function checkVideo() { if (attempts > 0) { if (video.videoWidth > 0 && video.videoHeight > 0) { - console.log(video.videoWidth + "px x " + video.videoHeight + "px"); + if (ENV.development) { + console.log(video.videoWidth + "px x " + video.videoHeight + "px"); + } callback(); } else { window.setTimeout(checkVideo, 500); diff --git a/src/input/frame_grabber.js b/src/input/frame_grabber.js index 41dbedb..12441bc 100644 --- a/src/input/frame_grabber.js +++ b/src/input/frame_grabber.js @@ -20,12 +20,14 @@ FrameGrabber.create = function(inputStream, canvas) { _canvas.height = _canvasSize.y; _ctx = _canvas.getContext("2d"); _data = new Uint8Array(_size.x * _size.y); - console.log("FrameGrabber", JSON.stringify({ - size: _size, - topRight: topRight, - videoSize: _video_size, - canvasSize: _canvasSize - })); + if (ENV.development) { + console.log("FrameGrabber", JSON.stringify({ + size: _size, + topRight: topRight, + videoSize: _video_size, + canvasSize: _canvasSize + })); + } /** * Uses the given array as frame-buffer diff --git a/src/input/image_loader.js b/src/input/image_loader.js index 83dc980..3e3af90 100644 --- a/src/input/image_loader.js +++ b/src/input/image_loader.js @@ -34,7 +34,9 @@ ImageLoader.load = function(directory, callback, offset, size, sequence) { } } if (notloadedImgs.length === 0) { - console.log("Images loaded"); + if (ENV.development) { + console.log("Images loaded"); + } callback.apply(null, [htmlImagesArray]); } }; diff --git a/src/locator/barcode_locator.js b/src/locator/barcode_locator.js index db0cd4a..ae1fa99 100644 --- a/src/locator/barcode_locator.js +++ b/src/locator/barcode_locator.js @@ -570,7 +570,9 @@ export default { }; patchSize = CVUtils.calculatePatchSize(config.patchSize, size); - console.log("Patch-Size: " + JSON.stringify(patchSize)); + if (ENV.development) { + console.log("Patch-Size: " + JSON.stringify(patchSize)); + } inputStream.setWidth(Math.floor(Math.floor(size.x / patchSize.x) * (1 / halfSample) * patchSize.x)); inputStream.setHeight(Math.floor(Math.floor(size.y / patchSize.y) * (1 / halfSample) * patchSize.y)); diff --git a/src/quagga.js b/src/quagga.js index f59b08c..1be061a 100644 --- a/src/quagga.js +++ b/src/quagga.js @@ -90,7 +90,9 @@ function canRecord(cb) { if (_config.numOfWorkers > 0) { initWorkers(function() { - console.log("Workers created"); + if (ENV.development) { + console.log("Workers created"); + } ready(cb); }); } else { @@ -148,7 +150,9 @@ function initBuffers(imageWrapper) { }); } - console.log(_inputImageWrapper.size); + if (ENV.development) { + console.log(_inputImageWrapper.size); + } _boxSize = [ vec2.clone([0, 0]), vec2.clone([0, _inputImageWrapper.size.y]), @@ -341,14 +345,18 @@ function initWorker(cb) { URL.revokeObjectURL(blobURL); workerThread.busy = false; workerThread.imageData = new Uint8Array(e.data.imageData); - console.log("Worker initialized"); + if (ENV.development) { + console.log("Worker initialized"); + } return cb(workerThread); } else if (e.data.event === 'processed') { workerThread.imageData = new Uint8Array(e.data.imageData); workerThread.busy = false; publishResult(e.data.result, workerThread.imageData); } else if (e.data.event === 'error') { - console.log("Worker error: " + e.data.message); + if (ENV.development) { + console.log("Worker error: " + e.data.message); + } } }; @@ -449,7 +457,9 @@ export default { _stopped = true; _workerPool.forEach(function(workerThread) { workerThread.worker.terminate(); - console.log("Worker terminated!"); + if (ENV.development) { + console.log("Worker terminated!"); + } }); _workerPool.length = 0; if (_config.inputStream.type === "LiveStream") { @@ -489,7 +499,7 @@ export default { size: 800, src: config.src }, - numOfWorkers: ENV.development ? 0 : 1, + numOfWorkers: (ENV.development && config.debug) ? 0 : 1, locator: { halfSample: false } diff --git a/src/reader/code_39_vin_reader.js b/src/reader/code_39_vin_reader.js index ae61bd6..8d7dd4f 100644 --- a/src/reader/code_39_vin_reader.js +++ b/src/reader/code_39_vin_reader.js @@ -29,7 +29,9 @@ Code39VINReader.prototype._decode = function() { code = code.replace(patterns.IOQ, ''); if (!code.match(patterns.AZ09)) { - console.log('Failed AZ09 pattern code:', code); + if (ENV.development) { + console.log('Failed AZ09 pattern code:', code); + } return null; }