Merge branch 'master' into patch-1

pull/132/head
Nicolas HENRY 8 years ago committed by GitHub
commit e5ec07687e

@ -1,7 +1,7 @@
quaggaJS quaggaJS
======== ========
- [Changelog](#changelog) (2016-10-03) - [Changelog](#changelog) (2017-01-08)
- [Browser Support](#browser-support) - [Browser Support](#browser-support)
- [Installing](#installing) - [Installing](#installing)
- [Getting Started](#gettingstarted) - [Getting Started](#gettingstarted)
@ -67,10 +67,11 @@ hostnames need to be served via `https://`. You can find more information in the
### Feature-detection of getUserMedia ### Feature-detection of getUserMedia
QuaggaJS has a hard dependency on Every browser seems to differently implement the `mediaDevices.getUserMedia`
[webrtc-adapter](https://github.com/webrtc/adapter) which makes access to API. Therefore it's highly recommended to include
`getUserMedia` consistent throughout all browsers. Use this to test your [webrtc-adapter](https://github.com/webrtc/adapter) in your project.
browser's capabilities:
Here's how you can test your browser's capabilities:
```javascript ```javascript
if (navigator.mediaDevices && typeof navigator.mediaDevices.getUserMedia === 'function') { if (navigator.mediaDevices && typeof navigator.mediaDevices.getUserMedia === 'function') {
@ -664,6 +665,13 @@ on the ``singleChannel`` flag in the configuration when using ``decodeSingle``.
## <a name="changelog">Changelog</a> ## <a name="changelog">Changelog</a>
### 2017-01-08
- Improvements
- Exposing `CameraAccess` module to get access to methods like
`enumerateVideoDevices` and `getActiveStreamLabel`
(see `example/live_w_locator`)
- Update to webpack 2.2 (API is still unstable)
### 2016-10-03 ### 2016-10-03
- Fixes - Fixes
- Fixed `facingMode` issue with Chrome >= 53 (see [#128](https://github.com/serratus/quaggaJS/issues/128)) - Fixed `facingMode` issue with Chrome >= 53 (see [#128](https://github.com/serratus/quaggaJS/issues/128))

9682
dist/quagga.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1 +1 @@
@import url("http://fonts.googleapis.com/css?family=Ubuntu:400,700|Cabin+Condensed:400,600"); @import url("https://fonts.googleapis.com/css?family=Ubuntu:400,700|Cabin+Condensed:400,600");

@ -15,7 +15,7 @@
/* Main Secondary color (2) */ /* Main Secondary color (2) */
/* Generated by Paletton.com ├é┬® 2002-2014 */ /* Generated by Paletton.com ├é┬® 2002-2014 */
/* http://paletton.com */ /* http://paletton.com */
@import url("http://fonts.googleapis.com/css?family=Ubuntu:400,700|Cabin+Condensed:400,600"); @import url("https://fonts.googleapis.com/css?family=Ubuntu:400,700|Cabin+Condensed:400,600");
/* line 1, ../sass/_viewport.scss */ /* line 1, ../sass/_viewport.scss */
#interactive.viewport { #interactive.viewport {
width: 640px; width: 640px;

@ -81,6 +81,11 @@
<option value="8">8</option> <option value="8">8</option>
</select> </select>
</label> </label>
<label>
<span>Camera</span>
<select name="input-stream_constraints" id="deviceSelection">
</select>
</label>
</fieldset> </fieldset>
</div> </div>
<div id="result_strip"> <div id="result_strip">
@ -91,11 +96,12 @@
</section> </section>
<footer> <footer>
<p> <p>
&copy; Copyright by Christoph Oberhofer &copy; Made with ❤️ by Christoph Oberhofer
</p> </p>
</footer> </footer>
<script src="vendor/jquery-1.9.0.min.js" type="text/javascript"></script> <script src="vendor/jquery-1.9.0.min.js" type="text/javascript"></script>
<script src="//webrtc.github.io/adapter/adapter-latest.js" type="text/javascript"></script>
<script src="../dist/quagga.js" type="text/javascript"></script> <script src="../dist/quagga.js" type="text/javascript"></script>
<script src="live_w_locator.js" type="text/javascript"></script> <script src="live_w_locator.js" type="text/javascript"></script>
</body> </body>

@ -10,14 +10,14 @@ $(function() {
} }
}); });
var App = { var App = {
init : function() { init: function() {
var self = this; var self = this;
Quagga.init(this.state, function(err) { Quagga.init(this.state, function(err) {
if (err) { if (err) {
return self.handleError(err); return self.handleError(err);
} }
Quagga.registerResultCollector(resultCollector); //Quagga.registerResultCollector(resultCollector);
App.attachListeners(); App.attachListeners();
Quagga.start(); Quagga.start();
}); });
@ -25,9 +25,31 @@ $(function() {
handleError: function(err) { handleError: function(err) {
console.log(err); console.log(err);
}, },
initCameraSelection: function(){
var streamLabel = Quagga.CameraAccess.getActiveStreamLabel();
return Quagga.CameraAccess.enumerateVideoDevices()
.then(function(devices) {
function pruneText(text) {
return text.length > 30 ? text.substr(0, 30) : text;
}
var $deviceSelection = document.getElementById("deviceSelection");
while ($deviceSelection.firstChild) {
$deviceSelection.removeChild($deviceSelection.firstChild);
}
devices.forEach(function(device) {
var $option = document.createElement("option");
$option.value = device.deviceId || device.id;
$option.appendChild(document.createTextNode(pruneText(device.label || device.deviceId || device.id)));
$option.selected = streamLabel === device.label;
$deviceSelection.appendChild($option);
});
});
},
attachListeners: function() { attachListeners: function() {
var self = this; var self = this;
self.initCameraSelection();
$(".controls").on("click", "button.stop", function(e) { $(".controls").on("click", "button.stop", function(e) {
e.preventDefault(); e.preventDefault();
Quagga.stop(); Quagga.stop();
@ -64,8 +86,12 @@ $(function() {
return parts.reduce(function(o, key, i) { return parts.reduce(function(o, key, i) {
if (setter && (i + 1) === depth) { if (setter && (i + 1) === depth) {
if (typeof o[key] === "object" && typeof val === "object") {
Object.assign(o[key], val);
} else {
o[key] = val; o[key] = val;
} }
}
return key in o ? o[key] : {}; return key in o ? o[key] : {};
}, obj); }, obj);
}, },
@ -95,12 +121,17 @@ $(function() {
inputMapper: { inputMapper: {
inputStream: { inputStream: {
constraints: function(value){ constraints: function(value){
if (/^(\d+)x(\d+)$/.test(value)) {
var values = value.split('x'); var values = value.split('x');
return { return {
width: {min: parseInt(values[0])}, width: {min: parseInt(values[0])},
height: {min: parseInt(values[1])} height: {min: parseInt(values[1])}
}; };
} }
return {
deviceId: value
};
}
}, },
numOfWorkers: function(value) { numOfWorkers: function(value) {
return parseInt(value); return parseInt(value);

@ -37,7 +37,6 @@ module.exports = function(config) {
plugins: [ plugins: [
'karma-chrome-launcher', 'karma-chrome-launcher',
'karma-mocha', 'karma-mocha',
'karma-requirejs',
'karma-chai', 'karma-chai',
'karma-sinon', 'karma-sinon',
'karma-sinon-chai', 'karma-sinon-chai',

@ -23,7 +23,7 @@ module.exports = function(config) {
}, { }, {
test: /\.js$/, test: /\.js$/,
include: path.resolve('src'), include: path.resolve('src'),
loader: 'babel-istanbul' loader: 'babel-istanbul-loader'
}] }]
}, },
resolve: { resolve: {

File diff suppressed because one or more lines are too long

@ -1,22 +1,23 @@
{ {
"name": "quagga", "name": "quagga",
"version": "0.11.5", "version": "0.11.6",
"description": "An advanced barcode-scanner written in JavaScript", "description": "An advanced barcode-scanner written in JavaScript",
"main": "lib/quagga.js", "main": "lib/quagga.js",
"browser": "dist/quagga.min.js", "browser": "dist/quagga.min.js",
"devDependencies": { "devDependencies": {
"async": "^1.4.2", "async": "^1.4.2",
"babel-cli": "^6.5.1", "babel-cli": "^6.5.1",
"babel-core": "^6.7.4", "babel-core": "^6.21.0",
"babel-eslint": "^6.0.0", "babel-eslint": "^7.1.1",
"babel-istanbul": "^0.8.0",
"babel-istanbul-loader": "^0.1.0", "babel-istanbul-loader": "^0.1.0",
"babel-loader": "^6.2.4", "babel-loader": "^6.2.10",
"babel-plugin-add-module-exports": "^0.1.2", "babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-check-es2015-constants": "^6.3.13", "babel-plugin-check-es2015-constants": "^6.3.13",
"babel-plugin-lodash": "^2.2.1", "babel-plugin-lodash": "^3.2.11",
"babel-plugin-transform-es2015-arrow-functions": "^6.3.13", "babel-plugin-transform-es2015-arrow-functions": "^6.3.13",
"babel-plugin-transform-es2015-block-scoped-functions": "^6.3.13", "babel-plugin-transform-es2015-block-scoped-functions": "^6.3.13",
"babel-plugin-transform-es2015-block-scoping": "^6.3.13", "babel-plugin-transform-es2015-block-scoping": "^6.21.0",
"babel-plugin-transform-es2015-classes": "^6.3.13", "babel-plugin-transform-es2015-classes": "^6.3.13",
"babel-plugin-transform-es2015-computed-properties": "^6.3.13", "babel-plugin-transform-es2015-computed-properties": "^6.3.13",
"babel-plugin-transform-es2015-destructuring": "^6.3.13", "babel-plugin-transform-es2015-destructuring": "^6.3.13",
@ -25,7 +26,7 @@
"babel-plugin-transform-es2015-literals": "^6.3.13", "babel-plugin-transform-es2015-literals": "^6.3.13",
"babel-plugin-transform-es2015-modules-commonjs": "^6.3.13", "babel-plugin-transform-es2015-modules-commonjs": "^6.3.13",
"babel-plugin-transform-es2015-object-super": "^6.3.13", "babel-plugin-transform-es2015-object-super": "^6.3.13",
"babel-plugin-transform-es2015-parameters": "^6.3.13", "babel-plugin-transform-es2015-parameters": "^6.21.0",
"babel-plugin-transform-es2015-shorthand-properties": "^6.3.13", "babel-plugin-transform-es2015-shorthand-properties": "^6.3.13",
"babel-plugin-transform-es2015-spread": "^6.3.13", "babel-plugin-transform-es2015-spread": "^6.3.13",
"babel-plugin-transform-es2015-sticky-regex": "^6.3.13", "babel-plugin-transform-es2015-sticky-regex": "^6.3.13",
@ -33,34 +34,34 @@
"babel-plugin-transform-es2015-typeof-symbol": "^6.3.13", "babel-plugin-transform-es2015-typeof-symbol": "^6.3.13",
"babel-plugin-transform-es2015-unicode-regex": "^6.3.13", "babel-plugin-transform-es2015-unicode-regex": "^6.3.13",
"babel-plugin-transform-object-rest-spread": "^6.5.0", "babel-plugin-transform-object-rest-spread": "^6.5.0",
"babel-plugin-transform-regenerator": "^6.3.13", "babel-plugin-transform-regenerator": "^6.21.0",
"chai": "^3.4.1", "chai": "^3.4.1",
"core-js": "^1.2.1", "core-js": "^2.4.1",
"cross-env": "^1.0.7", "cross-env": "^3.1.4",
"eslint": "^1.10.3", "eslint": "^1.10.3",
"grunt": "^0.4.5", "grunt": "^0.4.5",
"grunt-cli": "^0.1.13", "grunt-cli": "^0.1.13",
"grunt-contrib-nodeunit": "^0.4.1", "grunt-contrib-nodeunit": "^0.4.1",
"grunt-karma": "^0.12.1", "grunt-karma": "^2.0.0",
"isparta-loader": "^2.0.0", "isparta-loader": "^2.0.0",
"karma": "^0.13.9", "karma": "^1.3.0",
"karma-chai": "0.1.0", "karma-chai": "0.1.0",
"karma-chrome-launcher": "^0.2.0", "karma-chrome-launcher": "^2.0.0",
"karma-coverage": "^0.5.2", "karma-coverage": "^1.1.1",
"karma-firefox-launcher": "^0.1.7", "karma-firefox-launcher": "^0.1.7",
"karma-mocha": "~0.2.0", "karma-mocha": "~0.2.0",
"karma-phantomjs-launcher": "^0.2.1", "karma-phantomjs-launcher": "^0.2.1",
"karma-sinon": "^1.0.4", "karma-sinon": "^1.0.4",
"karma-sinon-chai": "^1.1.0", "karma-sinon-chai": "^1.1.0",
"karma-source-map-support": "^1.1.0", "karma-source-map-support": "^1.1.0",
"karma-webpack": "^1.7.0", "karma-webpack": "^1.8.1",
"lolex": "^1.4.0", "lolex": "^1.4.0",
"mocha": "^2.3.2", "mocha": "^2.3.2",
"phantomjs": "^1.9.18", "phantomjs": "^1.9.18",
"sinon": "^1.16.1", "sinon": "^1.17.7",
"sinon-chai": "^2.8.0", "sinon-chai": "^2.8.0",
"webpack": "^2.1.0-beta.4", "webpack": "^2.2.1",
"webpack-sources": "^0.1.1" "webpack-sources": "^0.1.4"
}, },
"directories": { "directories": {
"doc": "doc" "doc": "doc"
@ -105,10 +106,9 @@
"gl-mat2": "^1.0.0", "gl-mat2": "^1.0.0",
"gl-vec2": "^1.0.0", "gl-vec2": "^1.0.0",
"gl-vec3": "^1.0.3", "gl-vec3": "^1.0.3",
"lodash": "^4.6.1", "lodash": "^4.17.4",
"ndarray": "^1.0.18", "ndarray": "^1.0.18",
"ndarray-linear-interpolate": "^1.0.0", "ndarray-linear-interpolate": "^1.0.0"
"webrtc-adapter": "^2.0.2"
}, },
"types": "type-definitions/quagga.d.ts" "types": "type-definitions/quagga.d.ts"
} }

@ -0,0 +1,33 @@
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQC9ORap3LvRegtrhRc8dLdH9Bp2QokcKEsWbtvyhtjisRRm2slK
A6Q11McB/YTb7oImFfNaCX+7vdM1oVXVLJ0ekQaNljXG5Dy7DXEcT1V6gpN4xmZJ
8f/KZ45VBINN0Ha74L7nS4kgImh5yvNolNr4IdlSjGf09kciFy8S3kPlGQIDAQAB
AoGAYDlaxBCC1liY3Bl3IoA7//QrTL4zGUWIQaUoZmGag1UHifJycBf/9nv4o5N3
b5wPRSzebofsE93JPTmI+3nPf62k5rS2xOo8swwOZc+f5/v0EnUNixD7P0jBiLVR
B8kbMvNdNn33HuynW1/MSBFE0cfeDH2i8SVl+Z+fHYIUW10CQQD0yWB8xeM8AxYB
/ZZWClem6gf1lQAYLzid3x51pkLqRFpX+rG251cSBUouE+kVO14j2xrBqCyyOwNu
17eazy3DAkEAxeQdWP9b11ihKOf/kjXiczltLnBsotn6K9EEAe0QuH/6iXLm86mL
ZiQe+TrY1GWbK3ns0sfXgNJ2aeaRkeZn8wJAWF5WedTKisCmckOEwTzslbJI+0w2
A4UQkFWa3mgOIhpY7wfunhP35+aG+AlyDJspChKwHxdCQ3lwbNRtUPLYFwJBAK8G
9QIbUbLlPB1/HOfH6xM4rp3NZ/idzQxmISJG+GwHHaPmUekfgyEDP7X2W4N4nsbU
XyeLA8t32q4N9aDS5gsCQDHqhsXqnY6e4IEZrvf90l2V1PpnTKfEl/F5wye3g69G
JN57scVUBHP/KKoyfge0fytWiQN/56KvWH+G5+N/JyA=
-----END RSA PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
MIIC2zCCAkSgAwIBAgIJALUDN95Or7XlMA0GCSqGSIb3DQEBBQUAMFMxCzAJBgNV
BAYTAkFUMQ8wDQYDVQQIEwZTdHlyaWExDTALBgNVBAcTBEdyYXoxETAPBgNVBAoT
CFF1YWdnYUpTMREwDwYDVQQDEwhxdWFnZ2FqczAeFw0xNzAxMDgxNjI5MjhaFw0x
ODAxMDgxNjI5MjhaMFMxCzAJBgNVBAYTAkFUMQ8wDQYDVQQIEwZTdHlyaWExDTAL
BgNVBAcTBEdyYXoxETAPBgNVBAoTCFF1YWdnYUpTMREwDwYDVQQDEwhxdWFnZ2Fq
czCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAvTkWqdy70XoLa4UXPHS3R/Qa
dkKJHChLFm7b8obY4rEUZtrJSgOkNdTHAf2E2+6CJhXzWgl/u73TNaFV1SydHpEG
jZY1xuQ8uw1xHE9VeoKTeMZmSfH/ymeOVQSDTdB2u+C+50uJICJoecrzaJTa+CHZ
Uoxn9PZHIhcvEt5D5RkCAwEAAaOBtjCBszAdBgNVHQ4EFgQUYm5+uJVOOGiYa+Vx
2o++VHyWkwIwgYMGA1UdIwR8MHqAFGJufriVTjhomGvlcdqPvlR8lpMCoVekVTBT
MQswCQYDVQQGEwJBVDEPMA0GA1UECBMGU3R5cmlhMQ0wCwYDVQQHEwRHcmF6MREw
DwYDVQQKEwhRdWFnZ2FKUzERMA8GA1UEAxMIcXVhZ2dhanOCCQC1AzfeTq+15TAM
BgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBACyzC/CKL1mgTuNgFDuUf6u+
YMnqlc9wcnEaFuvXnkSh6fT+qMZm188C/tlZwcWTrGmoCM0K6mX1TpHOjm8vbeXZ
diezAVGIVN3VoHqm6yJldI2rgFI9r5BfwAWYC8XNjqnT3U6cm4k8iC7jmLC+dT9r
Ysx2ucAF6lNHayekRmNq
-----END CERTIFICATE-----

@ -0,0 +1,30 @@
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/
# generate server.xml with the following command:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# run as follows:
# python simple-https-server.py
# then in your browser, visit:
# https://localhost:4443
import BaseHTTPServer, SimpleHTTPServer
import ssl
import sys, getopt
host = 'localhost'
port = 4443
try:
opts, args = getopt.getopt(sys.argv[1:],"",["host=", "port="])
except getopt.GetoptError:
print 'simple-https-server.py --host <host> --port <port>'
sys.exit(2)
for opt, arg in opts:
if opt in ("--host"):
host = arg
elif opt in ("--port"):
port = int(arg)
print 'host is ', host
print 'port is ', port
httpd = BaseHTTPServer.HTTPServer((host, port), SimpleHTTPServer.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, certfile='./server.pem', server_side=True)
httpd.serve_forever()

@ -24,3 +24,28 @@ Math.imul = Math.imul || function(a, b) {
// the final |0 converts the unsigned value into a signed value // the final |0 converts the unsigned value into a signed value
return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0) | 0); return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0) | 0);
}; };
if (typeof Object.assign !== 'function') {
Object.assign = function(target) { // .length of function is 2
'use strict';
if (target === null) { // TypeError if undefined or null
throw new TypeError('Cannot convert undefined or null to object');
}
var to = Object(target);
for (var index = 1; index < arguments.length; index++) {
var nextSource = arguments[index];
if (nextSource !== null) { // Skip over if undefined or null
for (var nextKey in nextSource) {
// Avoid bugs when hasOwnProperty is shadowed
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
to[nextKey] = nextSource[nextKey];
}
}
}
}
return to;
};
}

@ -69,46 +69,24 @@ function deprecatedConstraints(videoConstraints) {
return normalized; return normalized;
} }
function pickDevice(constraints) {
const desiredFacing = constraints.video.facingMode,
facingMatch = facingMatching[desiredFacing];
if (!facingMatch) {
return Promise.resolve(constraints);
}
return enumerateDevices()
.then(devices => {
const selectedDeviceId = devices
.filter(device => device.kind === 'videoinput' && facingMatch.test(device.label))
.map(facingDevice => facingDevice.deviceId)[0];
if (selectedDeviceId) {
constraints = {
...constraints,
video: {
...omit(constraints.video, ["facingMode"]),
deviceId: selectedDeviceId,
}
};
}
return Promise.resolve(constraints);
});
}
export function pickConstraints(videoConstraints) { export function pickConstraints(videoConstraints) {
const normalizedConstraints = { const normalizedConstraints = {
audio: false, audio: false,
video: deprecatedConstraints(videoConstraints) video: deprecatedConstraints(videoConstraints)
}; };
if (!normalizedConstraints.video.deviceId) { if (normalizedConstraints.video.deviceId
if (typeof normalizedConstraints.video.facingMode === 'string' && normalizedConstraints.video.facingMode) {
&& normalizedConstraints.video.facingMode.length > 0) { delete normalizedConstraints.video.facingMode;
return pickDevice(normalizedConstraints);
}
} }
return Promise.resolve(normalizedConstraints); return Promise.resolve(normalizedConstraints);
} }
function enumerateVideoDevices() {
return enumerateDevices()
.then(devices => devices.filter(device => device.kind === 'videoinput'));
}
export default { export default {
request: function(video, videoConstraints) { request: function(video, videoConstraints) {
return pickConstraints(videoConstraints) return pickConstraints(videoConstraints)
@ -120,5 +98,14 @@ export default {
tracks[0].stop(); tracks[0].stop();
} }
streamRef = null; streamRef = null;
},
enumerateVideoDevices,
getActiveStreamLabel: function() {
if (streamRef) {
const tracks = streamRef.getVideoTracks();
if (tracks && tracks.length) {
return tracks[0].label;
}
}
} }
}; };

@ -1,5 +1,4 @@
import TypeDefs from './common/typedefs'; // eslint-disable-line no-unused-vars import TypeDefs from './common/typedefs'; // eslint-disable-line no-unused-vars
import WebrtcAdapter from 'webrtc-adapter'; // eslint-disable-line no-unused-vars
import ImageWrapper from './common/image_wrapper'; import ImageWrapper from './common/image_wrapper';
import BarcodeLocator from './locator/barcode_locator'; import BarcodeLocator from './locator/barcode_locator';
import BarcodeDecoder from './decoder/barcode_decoder'; import BarcodeDecoder from './decoder/barcode_decoder';
@ -539,5 +538,6 @@ export default {
}, },
ImageWrapper: ImageWrapper, ImageWrapper: ImageWrapper,
ImageDebug: ImageDebug, ImageDebug: ImageDebug,
ResultCollector: ResultCollector ResultCollector: ResultCollector,
CameraAccess: CameraAccess,
}; };

@ -10,9 +10,9 @@ module.exports = function(grunt) {
grunt.registerTask('uglyasm', function() { grunt.registerTask('uglyasm', function() {
var code = fs.readFileSync('dist/quagga.js', 'utf-8'), var code = fs.readFileSync('dist/quagga.js', 'utf-8'),
minifiedCode = fs.readFileSync('dist/quagga.min.js', 'utf-8'), minifiedCode = fs.readFileSync('dist/quagga.min.js', 'utf-8'),
commentEnd = '/* @preserve ASM END */', commentEnd = '@preserve ASM END',
moduleFunctionRegex = /function\s*\((\w+,\s*\w+,\s*\w+)\)\s*\{\s*\/\* \@preserve ASM BEGIN \*\//, moduleFunctionRegex = /function\s*\((\w+,\s*\w+,\s*\w+)\)\s*\{(\n?\s*\"use strict\";?)*\n?\/\*\s*\@preserve ASM BEGIN/,
commentStartIdx = code.indexOf("/* @preserve ASM BEGIN */"), commentStartIdx = code.indexOf("@preserve ASM BEGIN"),
asmEndIdxTmp = code.indexOf(commentEnd), asmEndIdxTmp = code.indexOf(commentEnd),
asmEndIdx = code.indexOf("}", asmEndIdxTmp), asmEndIdx = code.indexOf("}", asmEndIdxTmp),
asmCodeTmp = code.substring(commentStartIdx - Math.min(500, commentStartIdx), asmCodeTmp = code.substring(commentStartIdx - Math.min(500, commentStartIdx),
@ -30,8 +30,6 @@ module.exports = function(grunt) {
.replace(/ ([+=^|&]|>+|<+) /g, '$1') // remove spaces around operators .replace(/ ([+=^|&]|>+|<+) /g, '$1') // remove spaces around operators
.replace(/[\r\n/]/g, ''); // remove new lines .replace(/[\r\n/]/g, ''); // remove new lines
grunt.log.debug(asmCodeMinified);
asmModule = moduleFunctionRegex.exec(asmCode); asmModule = moduleFunctionRegex.exec(asmCode);
if (!asmModule) { if (!asmModule) {
grunt.log.error("No ASM module found"); grunt.log.error("No ASM module found");

@ -10,14 +10,11 @@ module.exports.plugins = module.exports.plugins.concat([
compress: { compress: {
warnings: false warnings: false
}, },
output: {
comments: /@preserve/
},
sourceMap: false sourceMap: false
}), }),
]); ]);
module.exports.output.filename = 'quagga.min.js'; module.exports.output.filename = 'quagga.min.js';
module.exports.output.sourceMapFilename = null; module.exports.output.sourceMapFilename = '';
module.exports.devtool = null; module.exports.devtool = false;

Loading…
Cancel
Save