diff --git a/README.md b/README.md index 2167328..4e65a47 100644 --- a/README.md +++ b/README.md @@ -567,7 +567,7 @@ that node does not support web-workers out of the box. Therefore the config property `numOfWorkers` must be explicitly set to `0`. ```javascript -var Quagga = require('quagga'); +var Quagga = require('quagga').default; Quagga.decodeSingle({ src: "image-abc-123.jpg", diff --git a/dist/quagga.js b/dist/quagga.js index 4b99eae..1409c9e 100644 --- a/dist/quagga.js +++ b/dist/quagga.js @@ -71,11 +71,26 @@ return /******/ (function(modules) { // webpackBootstrap /******/ __webpack_require__.p = "/"; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 209); +/******/ return __webpack_require__(__webpack_require__.s = 219); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ +/***/ (function(module, exports, __webpack_require__) { + +var freeGlobal = __webpack_require__(65); + +/** Detect free variable `self`. */ +var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + +/** Used as a reference to the global object. */ +var root = freeGlobal || freeSelf || Function('return this')(); + +module.exports = root; + + +/***/ }), +/* 1 */ /***/ (function(module, exports) { /** @@ -106,21 +121,6 @@ var isArray = Array.isArray; module.exports = isArray; -/***/ }), -/* 1 */ -/***/ (function(module, exports, __webpack_require__) { - -var freeGlobal = __webpack_require__(59); - -/** Detect free variable `self`. */ -var freeSelf = typeof self == 'object' && self && self.Object === Object && self; - -/** Used as a reference to the global object. */ -var root = freeGlobal || freeSelf || Function('return this')(); - -module.exports = root; - - /***/ }), /* 2 */ /***/ (function(module, exports) { @@ -160,766 +160,786 @@ module.exports = isObject; /***/ }), /* 3 */ -/***/ (function(module, exports, __webpack_require__) { - -var baseIsNative = __webpack_require__(124), - getValue = __webpack_require__(157); - -/** - * Gets the native function at `key` of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {string} key The key of the method to get. - * @returns {*} Returns the function if it's native, else `undefined`. - */ -function getNative(object, key) { - var value = getValue(object, key); - return baseIsNative(value) ? value : undefined; -} - -module.exports = getNative; - - -/***/ }), -/* 4 */ -/***/ (function(module, exports) { - -/** - * Checks if `value` is object-like. A value is object-like if it's not `null` - * and has a `typeof` result of "object". - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - * @example - * - * _.isObjectLike({}); - * // => true - * - * _.isObjectLike([1, 2, 3]); - * // => true - * - * _.isObjectLike(_.noop); - * // => false - * - * _.isObjectLike(null); - * // => false - */ -function isObjectLike(value) { - return value != null && typeof value == 'object'; -} - -module.exports = isObjectLike; - - -/***/ }), -/* 5 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_merge__ = __webpack_require__(15); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_merge___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash_merge__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__barcode_reader__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common_array_helper__ = __webpack_require__(6); -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; +function BarcodeReader(config, supplements) { + this._row = []; + this.config = config || {}; + this.supplements = supplements; + return this; +} +BarcodeReader.prototype._nextUnset = function (line, start) { + var i; + if (start === undefined) { + start = 0; + } + for (i = start; i < line.length; i++) { + if (!line[i]) { + return i; + } + } + return line.length; +}; +BarcodeReader.prototype._matchPattern = function (counter, code, maxSingleError) { + var i, + error = 0, + singleError = 0, + sum = 0, + modulo = 0, + barWidth, + count, + scaled; -function EANReader(opts, supplements) { - opts = __WEBPACK_IMPORTED_MODULE_0_lodash_merge___default()(getDefaulConfig(), opts); - __WEBPACK_IMPORTED_MODULE_1__barcode_reader__["a" /* default */].call(this, opts, supplements); -} + maxSingleError = maxSingleError || this.SINGLE_CODE_ERROR || 1; -function getDefaulConfig() { - var config = {}; + for (i = 0; i < counter.length; i++) { + sum += counter[i]; + modulo += code[i]; + } + if (sum < modulo) { + return Number.MAX_VALUE; + } + barWidth = sum / modulo; + maxSingleError *= barWidth; - Object.keys(EANReader.CONFIG_KEYS).forEach(function (key) { - config[key] = EANReader.CONFIG_KEYS[key].default; - }); - return config; -} + for (i = 0; i < counter.length; i++) { + count = counter[i]; + scaled = code[i] * barWidth; + singleError = Math.abs(count - scaled) / scaled; + if (singleError > maxSingleError) { + return Number.MAX_VALUE; + } + error += singleError; + } + return error / modulo; +}; -var properties = { - CODE_L_START: { value: 0 }, - CODE_G_START: { value: 10 }, - START_PATTERN: { value: [1, 1, 1] }, - STOP_PATTERN: { value: [1, 1, 1] }, - MIDDLE_PATTERN: { value: [1, 1, 1, 1, 1] }, - EXTENSION_START_PATTERN: { value: [1, 1, 2] }, - CODE_PATTERN: { value: [[3, 2, 1, 1], [2, 2, 2, 1], [2, 1, 2, 2], [1, 4, 1, 1], [1, 1, 3, 2], [1, 2, 3, 1], [1, 1, 1, 4], [1, 3, 1, 2], [1, 2, 1, 3], [3, 1, 1, 2], [1, 1, 2, 3], [1, 2, 2, 2], [2, 2, 1, 2], [1, 1, 4, 1], [2, 3, 1, 1], [1, 3, 2, 1], [4, 1, 1, 1], [2, 1, 3, 1], [3, 1, 2, 1], [2, 1, 1, 3]] }, - CODE_FREQUENCY: { value: [0, 11, 13, 14, 19, 25, 28, 21, 22, 26] }, - SINGLE_CODE_ERROR: { value: 0.70 }, - AVG_CODE_ERROR: { value: 0.48 }, - FORMAT: { value: "ean_13", writeable: false } +BarcodeReader.prototype._nextSet = function (line, offset) { + var i; + + offset = offset || 0; + for (i = offset; i < line.length; i++) { + if (line[i]) { + return i; + } + } + return line.length; }; -EANReader.prototype = Object.create(__WEBPACK_IMPORTED_MODULE_1__barcode_reader__["a" /* default */].prototype, properties); -EANReader.prototype.constructor = EANReader; +BarcodeReader.prototype._correctBars = function (counter, correction, indices) { + var length = indices.length, + tmp = 0; + while (length--) { + tmp = counter[indices[length]] * (1 - (1 - correction) / 2); + if (tmp > 1) { + counter[indices[length]] = tmp; + } + } +}; -EANReader.prototype._decodeCode = function (start, coderange) { - var counter = [0, 0, 0, 0], +BarcodeReader.prototype._matchTrace = function (cmpCounter, epsilon) { + var counter = [], i, self = this, - offset = start, + offset = self._nextSet(self._row), isWhite = !self._row[offset], counterPos = 0, bestMatch = { error: Number.MAX_VALUE, code: -1, - start: start, - end: start + start: 0 }, - code, error; - if (!coderange) { - coderange = self.CODE_PATTERN.length; - } + if (cmpCounter) { + for (i = 0; i < cmpCounter.length; i++) { + counter.push(0); + } + for (i = offset; i < self._row.length; i++) { + if (self._row[i] ^ isWhite) { + counter[counterPos]++; + } else { + if (counterPos === counter.length - 1) { + error = self._matchPattern(counter, cmpCounter); - for (i = offset; i < self._row.length; i++) { - if (self._row[i] ^ isWhite) { - counter[counterPos]++; - } else { - if (counterPos === counter.length - 1) { - for (code = 0; code < coderange; code++) { - error = self._matchPattern(counter, self.CODE_PATTERN[code]); - if (error < bestMatch.error) { - bestMatch.code = code; - bestMatch.error = error; + if (error < epsilon) { + bestMatch.start = i - offset; + bestMatch.end = i; + bestMatch.counter = counter; + return bestMatch; + } else { + return null; } + } else { + counterPos++; } - bestMatch.end = i; - if (bestMatch.error > self.AVG_CODE_ERROR) { - return null; - } - return bestMatch; + counter[counterPos] = 1; + isWhite = !isWhite; + } + } + } else { + counter.push(0); + for (i = offset; i < self._row.length; i++) { + if (self._row[i] ^ isWhite) { + counter[counterPos]++; } else { counterPos++; + counter.push(0); + counter[counterPos] = 1; + isWhite = !isWhite; } - counter[counterPos] = 1; - isWhite = !isWhite; } } - return null; + + // if cmpCounter was not given + bestMatch.start = offset; + bestMatch.end = self._row.length - 1; + bestMatch.counter = counter; + return bestMatch; }; -EANReader.prototype._findPattern = function (pattern, offset, isWhite, tryHarder, epsilon) { - var counter = [], - self = this, - i, - counterPos = 0, - bestMatch = { - error: Number.MAX_VALUE, - code: -1, - start: 0, - end: 0 - }, - error, - j, - sum; +BarcodeReader.prototype.decodePattern = function (pattern) { + var self = this, + result; - if (!offset) { - offset = self._nextSet(self._row); + self._row = pattern; + result = self._decode(); + if (result === null) { + self._row.reverse(); + result = self._decode(); + if (result) { + result.direction = BarcodeReader.DIRECTION.REVERSE; + result.start = self._row.length - result.start; + result.end = self._row.length - result.end; + } + } else { + result.direction = BarcodeReader.DIRECTION.FORWARD; } - - if (isWhite === undefined) { - isWhite = false; + if (result) { + result.format = self.FORMAT; } + return result; +}; - if (tryHarder === undefined) { - tryHarder = true; - } +BarcodeReader.prototype._matchRange = function (start, end, value) { + var i; - if (epsilon === undefined) { - epsilon = self.AVG_CODE_ERROR; + start = start < 0 ? 0 : start; + for (i = start; i < end; i++) { + if (this._row[i] !== value) { + return false; + } } + return true; +}; - for (i = 0; i < pattern.length; i++) { - counter[i] = 0; - } +BarcodeReader.prototype._fillCounters = function (offset, end, isWhite) { + var self = this, + counterPos = 0, + i, + counters = []; - for (i = offset; i < self._row.length; i++) { + isWhite = typeof isWhite !== 'undefined' ? isWhite : true; + offset = typeof offset !== 'undefined' ? offset : self._nextUnset(self._row); + end = end || self._row.length; + + counters[counterPos] = 0; + for (i = offset; i < end; i++) { if (self._row[i] ^ isWhite) { - counter[counterPos]++; + counters[counterPos]++; } else { - if (counterPos === counter.length - 1) { - sum = 0; - for (j = 0; j < counter.length; j++) { - sum += counter[j]; - } - error = self._matchPattern(counter, pattern); - - if (error < epsilon) { - bestMatch.error = error; - bestMatch.start = i - sum; - bestMatch.end = i; - return bestMatch; - } - if (tryHarder) { - for (j = 0; j < counter.length - 2; j++) { - counter[j] = counter[j + 2]; - } - counter[counter.length - 2] = 0; - counter[counter.length - 1] = 0; - counterPos--; - } else { - return null; - } - } else { - counterPos++; - } - counter[counterPos] = 1; + counterPos++; + counters[counterPos] = 1; isWhite = !isWhite; } } - return null; + return counters; }; -EANReader.prototype._findStart = function () { +BarcodeReader.prototype._toCounters = function (start, counter) { var self = this, - leadingWhitespaceStart, - offset = self._nextSet(self._row), - startInfo; + numCounters = counter.length, + end = self._row.length, + isWhite = !self._row[start], + i, + counterPos = 0; - while (!startInfo) { - startInfo = self._findPattern(self.START_PATTERN, offset); - if (!startInfo) { - return null; - } - leadingWhitespaceStart = startInfo.start - (startInfo.end - startInfo.start); - if (leadingWhitespaceStart >= 0) { - if (self._matchRange(leadingWhitespaceStart, startInfo.start, 0)) { - return startInfo; + __WEBPACK_IMPORTED_MODULE_0__common_array_helper__["a" /* default */].init(counter, 0); + + for (i = start; i < end; i++) { + if (self._row[i] ^ isWhite) { + counter[counterPos]++; + } else { + counterPos++; + if (counterPos === numCounters) { + break; + } else { + counter[counterPos] = 1; + isWhite = !isWhite; } } - offset = startInfo.end; - startInfo = null; } -}; - -EANReader.prototype._verifyTrailingWhitespace = function (endInfo) { - var self = this, - trailingWhitespaceEnd; - trailingWhitespaceEnd = endInfo.end + (endInfo.end - endInfo.start); - if (trailingWhitespaceEnd < self._row.length) { - if (self._matchRange(endInfo.end, trailingWhitespaceEnd, 0)) { - return endInfo; - } - } - return null; + return counter; }; -EANReader.prototype._findEnd = function (offset, isWhite) { - var self = this, - endInfo = self._findPattern(self.STOP_PATTERN, offset, isWhite, false); +Object.defineProperty(BarcodeReader.prototype, "FORMAT", { + value: 'unknown', + writeable: false +}); - return endInfo !== null ? self._verifyTrailingWhitespace(endInfo) : null; +BarcodeReader.DIRECTION = { + FORWARD: 1, + REVERSE: -1 }; -EANReader.prototype._calculateFirstDigit = function (codeFrequency) { - var i, - self = this; - - for (i = 0; i < self.CODE_FREQUENCY.length; i++) { - if (codeFrequency === self.CODE_FREQUENCY[i]) { - return i; - } - } - return null; +BarcodeReader.Exception = { + StartNotFoundException: "Start-Info was not found!", + CodeNotFoundException: "Code could not be found!", + PatternNotFoundException: "Pattern could not be found!" }; -EANReader.prototype._decodePayload = function (code, result, decodedCodes) { - var i, - self = this, - codeFrequency = 0x0, - firstDigit; - - for (i = 0; i < 6; i++) { - code = self._decodeCode(code.end); - if (!code) { - return null; - } - if (code.code >= self.CODE_G_START) { - code.code = code.code - self.CODE_G_START; - codeFrequency |= 1 << 5 - i; - } else { - codeFrequency |= 0 << 5 - i; - } - result.push(code.code); - decodedCodes.push(code); - } - - firstDigit = self._calculateFirstDigit(codeFrequency); - if (firstDigit === null) { - return null; - } - result.unshift(firstDigit); +BarcodeReader.CONFIG_KEYS = {}; - code = self._findPattern(self.MIDDLE_PATTERN, code.end, true, false); - if (code === null) { - return null; - } - decodedCodes.push(code); +/* harmony default export */ __webpack_exports__["a"] = BarcodeReader; - for (i = 0; i < 6; i++) { - code = self._decodeCode(code.end, self.CODE_G_START); - if (!code) { - return null; - } - decodedCodes.push(code); - result.push(code.code); - } +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { - return code; -}; +var baseIsNative = __webpack_require__(140), + getValue = __webpack_require__(170); -EANReader.prototype._decode = function () { - var startInfo, - self = this, - code, - result = [], - decodedCodes = [], - resultInfo = {}; +/** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ +function getNative(object, key) { + var value = getValue(object, key); + return baseIsNative(value) ? value : undefined; +} - startInfo = self._findStart(); - if (!startInfo) { - return null; - } - code = { - code: startInfo.code, - start: startInfo.start, - end: startInfo.end - }; - decodedCodes.push(code); - code = self._decodePayload(code, result, decodedCodes); - if (!code) { - return null; - } - code = self._findEnd(code.end, false); - if (!code) { - return null; - } +module.exports = getNative; - decodedCodes.push(code); - // Checksum - if (!self._checksum(result)) { - return null; - } +/***/ }), +/* 5 */ +/***/ (function(module, exports) { - if (this.supplements.length > 0) { - var ext = this._decodeExtensions(code.end); - if (!ext) { - return null; - } - var lastCode = ext.decodedCodes[ext.decodedCodes.length - 1], - endInfo = { - start: lastCode.start + ((lastCode.end - lastCode.start) / 2 | 0), - end: lastCode.end - }; - if (!self._verifyTrailingWhitespace(endInfo)) { - return null; +/** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ +function isObjectLike(value) { + return value != null && typeof value == 'object'; +} + +module.exports = isObjectLike; + + +/***/ }), +/* 6 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony default export */ __webpack_exports__["a"] = { + init: function init(arr, val) { + var l = arr.length; + while (l--) { + arr[l] = val; } - resultInfo = { - supplement: ext, - code: result.join("") + ext.code - }; - } + }, - return _extends({ - code: result.join(""), - start: startInfo.start, - end: code.end, - codeset: "", - startInfo: startInfo, - decodedCodes: decodedCodes - }, resultInfo); -}; + /** + * Shuffles the content of an array + * @return {Array} the array itself shuffled + */ + shuffle: function shuffle(arr) { + var i = arr.length - 1, + j, + x; + for (i; i >= 0; i--) { + j = Math.floor(Math.random() * i); + x = arr[i]; + arr[i] = arr[j]; + arr[j] = x; + } + return arr; + }, -EANReader.prototype._decodeExtensions = function (offset) { - var i, - start = this._nextSet(this._row, offset), - startInfo = this._findPattern(this.EXTENSION_START_PATTERN, start, false, false), - result; + toPointList: function toPointList(arr) { + var i, + j, + row = [], + rows = []; + for (i = 0; i < arr.length; i++) { + row = []; + for (j = 0; j < arr[i].length; j++) { + row[j] = arr[i][j]; + } + rows[i] = "[" + row.join(",") + "]"; + } + return "[" + rows.join(",\r\n") + "]"; + }, - if (startInfo === null) { - return null; - } + /** + * returns the elements which's score is bigger than the threshold + * @return {Array} the reduced array + */ + threshold: function threshold(arr, _threshold, scoreFunc) { + var i, + queue = []; + for (i = 0; i < arr.length; i++) { + if (scoreFunc.apply(arr, [arr[i]]) >= _threshold) { + queue.push(arr[i]); + } + } + return queue; + }, - for (i = 0; i < this.supplements.length; i++) { - result = this.supplements[i].decode(this._row, startInfo.end); - if (result !== null) { - return { - code: result.code, - start: start, - startInfo: startInfo, - end: result.end, - codeset: "", - decodedCodes: result.decodedCodes - }; + maxIndex: function maxIndex(arr) { + var i, + max = 0; + for (i = 0; i < arr.length; i++) { + if (arr[i] > arr[max]) { + max = i; + } } - } - return null; -}; + return max; + }, -EANReader.prototype._checksum = function (result) { - var sum = 0, - i; + max: function max(arr) { + var i, + max = 0; + for (i = 0; i < arr.length; i++) { + if (arr[i] > max) { + max = arr[i]; + } + } + return max; + }, - for (i = result.length - 2; i >= 0; i -= 2) { - sum += result[i]; - } - sum *= 3; - for (i = result.length - 1; i >= 0; i -= 2) { - sum += result[i]; - } - return sum % 10 === 0; -}; + sum: function sum(arr) { + var length = arr.length, + sum = 0; -EANReader.CONFIG_KEYS = { - supplements: { - 'type': 'arrayOf(string)', - 'default': [], - 'description': 'Allowed extensions to be decoded (2 and/or 5)' + while (length--) { + sum += arr[length]; + } + return sum; } }; -/* harmony default export */ __webpack_exports__["a"] = EANReader; - /***/ }), -/* 6 */ -/***/ (function(module, exports, __webpack_require__) { +/* 7 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { -var Symbol = __webpack_require__(10), - getRawTag = __webpack_require__(155), - objectToString = __webpack_require__(184); +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_merge__ = __webpack_require__(24); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_merge___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash_merge__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__barcode_reader__ = __webpack_require__(3); -/** `Object#toString` result references. */ -var nullTag = '[object Null]', - undefinedTag = '[object Undefined]'; -/** Built-in value references. */ -var symToStringTag = Symbol ? Symbol.toStringTag : undefined; -/** - * The base implementation of `getTag` without fallbacks for buggy environments. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the `toStringTag`. - */ -function baseGetTag(value) { - if (value == null) { - return value === undefined ? undefinedTag : nullTag; - } - return (symToStringTag && symToStringTag in Object(value)) - ? getRawTag(value) - : objectToString(value); + +function EANReader(opts, supplements) { + opts = __WEBPACK_IMPORTED_MODULE_0_lodash_merge___default()(getDefaulConfig(), opts); + __WEBPACK_IMPORTED_MODULE_1__barcode_reader__["a" /* default */].call(this, opts, supplements); } -module.exports = baseGetTag; +function getDefaulConfig() { + var config = {}; + + Object.keys(EANReader.CONFIG_KEYS).forEach(function (key) { + config[key] = EANReader.CONFIG_KEYS[key].default; + }); + return config; +} +var properties = { + CODE_L_START: { value: 0 }, + CODE_G_START: { value: 10 }, + START_PATTERN: { value: [1, 1, 1] }, + STOP_PATTERN: { value: [1, 1, 1] }, + MIDDLE_PATTERN: { value: [1, 1, 1, 1, 1] }, + EXTENSION_START_PATTERN: { value: [1, 1, 2] }, + CODE_PATTERN: { value: [[3, 2, 1, 1], [2, 2, 2, 1], [2, 1, 2, 2], [1, 4, 1, 1], [1, 1, 3, 2], [1, 2, 3, 1], [1, 1, 1, 4], [1, 3, 1, 2], [1, 2, 1, 3], [3, 1, 1, 2], [1, 1, 2, 3], [1, 2, 2, 2], [2, 2, 1, 2], [1, 1, 4, 1], [2, 3, 1, 1], [1, 3, 2, 1], [4, 1, 1, 1], [2, 1, 3, 1], [3, 1, 2, 1], [2, 1, 1, 3]] }, + CODE_FREQUENCY: { value: [0, 11, 13, 14, 19, 25, 28, 21, 22, 26] }, + SINGLE_CODE_ERROR: { value: 0.70 }, + AVG_CODE_ERROR: { value: 0.48 }, + FORMAT: { value: "ean_13", writeable: false } +}; -/***/ }), -/* 7 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +EANReader.prototype = Object.create(__WEBPACK_IMPORTED_MODULE_1__barcode_reader__["a" /* default */].prototype, properties); +EANReader.prototype.constructor = EANReader; -"use strict"; -/* harmony default export */ __webpack_exports__["a"] = { - drawRect: function drawRect(pos, size, ctx, style) { - ctx.strokeStyle = style.color; - ctx.fillStyle = style.color; - ctx.lineWidth = 1; - ctx.beginPath(); - ctx.strokeRect(pos.x, pos.y, size.x, size.y); +EANReader.prototype._decodeCode = function (start, coderange) { + var counter = [0, 0, 0, 0], + i, + self = this, + offset = start, + isWhite = !self._row[offset], + counterPos = 0, + bestMatch = { + error: Number.MAX_VALUE, + code: -1, + start: start, + end: start }, - drawPath: function drawPath(path, def, ctx, style) { - ctx.strokeStyle = style.color; - ctx.fillStyle = style.color; - ctx.lineWidth = style.lineWidth; - ctx.beginPath(); - ctx.moveTo(path[0][def.x], path[0][def.y]); - for (var j = 1; j < path.length; j++) { - ctx.lineTo(path[j][def.x], path[j][def.y]); + code, + error; + + if (!coderange) { + coderange = self.CODE_PATTERN.length; + } + + for (i = offset; i < self._row.length; i++) { + if (self._row[i] ^ isWhite) { + counter[counterPos]++; + } else { + if (counterPos === counter.length - 1) { + for (code = 0; code < coderange; code++) { + error = self._matchPattern(counter, self.CODE_PATTERN[code]); + if (error < bestMatch.error) { + bestMatch.code = code; + bestMatch.error = error; + } + } + bestMatch.end = i; + if (bestMatch.error > self.AVG_CODE_ERROR) { + return null; + } + return bestMatch; + } else { + counterPos++; + } + counter[counterPos] = 1; + isWhite = !isWhite; } - ctx.closePath(); - ctx.stroke(); + } + return null; +}; + +EANReader.prototype._findPattern = function (pattern, offset, isWhite, tryHarder, epsilon) { + var counter = [], + self = this, + i, + counterPos = 0, + bestMatch = { + error: Number.MAX_VALUE, + code: -1, + start: 0, + end: 0 }, - drawImage: function drawImage(imageData, size, ctx) { - var canvasData = ctx.getImageData(0, 0, size.x, size.y), - data = canvasData.data, - imageDataPos = imageData.length, - canvasDataPos = data.length, - value; + error, + j, + sum; - if (canvasDataPos / imageDataPos !== 4) { - return false; - } - while (imageDataPos--) { - value = imageData[imageDataPos]; - data[--canvasDataPos] = 255; - data[--canvasDataPos] = value; - data[--canvasDataPos] = value; - data[--canvasDataPos] = value; - } - ctx.putImageData(canvasData, 0, 0); - return true; + if (!offset) { + offset = self._nextSet(self._row); + } + + if (isWhite === undefined) { + isWhite = false; } -}; - -/***/ }), -/* 8 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { -"use strict"; -function BarcodeReader(config, supplements) { - this._row = []; - this.config = config || {}; - this.supplements = supplements; - return this; -} + if (tryHarder === undefined) { + tryHarder = true; + } -BarcodeReader.prototype._nextUnset = function (line, start) { - var i; + if (epsilon === undefined) { + epsilon = self.AVG_CODE_ERROR; + } - if (start === undefined) { - start = 0; + for (i = 0; i < pattern.length; i++) { + counter[i] = 0; } - for (i = start; i < line.length; i++) { - if (!line[i]) { - return i; + + for (i = offset; i < self._row.length; i++) { + if (self._row[i] ^ isWhite) { + counter[counterPos]++; + } else { + if (counterPos === counter.length - 1) { + sum = 0; + for (j = 0; j < counter.length; j++) { + sum += counter[j]; + } + error = self._matchPattern(counter, pattern); + + if (error < epsilon) { + bestMatch.error = error; + bestMatch.start = i - sum; + bestMatch.end = i; + return bestMatch; + } + if (tryHarder) { + for (j = 0; j < counter.length - 2; j++) { + counter[j] = counter[j + 2]; + } + counter[counter.length - 2] = 0; + counter[counter.length - 1] = 0; + counterPos--; + } else { + return null; + } + } else { + counterPos++; + } + counter[counterPos] = 1; + isWhite = !isWhite; } } - return line.length; + return null; }; -BarcodeReader.prototype._matchPattern = function (counter, code, maxSingleError) { - var i, - error = 0, - singleError = 0, - sum = 0, - modulo = 0, - barWidth, - count, - scaled; - - maxSingleError = maxSingleError || this.SINGLE_CODE_ERROR || 1; - - for (i = 0; i < counter.length; i++) { - sum += counter[i]; - modulo += code[i]; - } - if (sum < modulo) { - return Number.MAX_VALUE; - } - barWidth = sum / modulo; - maxSingleError *= barWidth; +EANReader.prototype._findStart = function () { + var self = this, + leadingWhitespaceStart, + offset = self._nextSet(self._row), + startInfo; - for (i = 0; i < counter.length; i++) { - count = counter[i]; - scaled = code[i] * barWidth; - singleError = Math.abs(count - scaled) / scaled; - if (singleError > maxSingleError) { - return Number.MAX_VALUE; + while (!startInfo) { + startInfo = self._findPattern(self.START_PATTERN, offset); + if (!startInfo) { + return null; } - error += singleError; + leadingWhitespaceStart = startInfo.start - (startInfo.end - startInfo.start); + if (leadingWhitespaceStart >= 0) { + if (self._matchRange(leadingWhitespaceStart, startInfo.start, 0)) { + return startInfo; + } + } + offset = startInfo.end; + startInfo = null; } - return error / modulo; }; -BarcodeReader.prototype._nextSet = function (line, offset) { - var i; +EANReader.prototype._verifyTrailingWhitespace = function (endInfo) { + var self = this, + trailingWhitespaceEnd; - offset = offset || 0; - for (i = offset; i < line.length; i++) { - if (line[i]) { - return i; + trailingWhitespaceEnd = endInfo.end + (endInfo.end - endInfo.start); + if (trailingWhitespaceEnd < self._row.length) { + if (self._matchRange(endInfo.end, trailingWhitespaceEnd, 0)) { + return endInfo; } } - return line.length; + return null; }; -BarcodeReader.prototype._correctBars = function (counter, correction, indices) { - var length = indices.length, - tmp = 0; - while (length--) { - tmp = counter[indices[length]] * (1 - (1 - correction) / 2); - if (tmp > 1) { - counter[indices[length]] = tmp; +EANReader.prototype._findEnd = function (offset, isWhite) { + var self = this, + endInfo = self._findPattern(self.STOP_PATTERN, offset, isWhite, false); + + return endInfo !== null ? self._verifyTrailingWhitespace(endInfo) : null; +}; + +EANReader.prototype._calculateFirstDigit = function (codeFrequency) { + var i, + self = this; + + for (i = 0; i < self.CODE_FREQUENCY.length; i++) { + if (codeFrequency === self.CODE_FREQUENCY[i]) { + return i; } } + return null; }; -BarcodeReader.prototype._matchTrace = function (cmpCounter, epsilon) { - var counter = [], - i, +EANReader.prototype._decodePayload = function (code, result, decodedCodes) { + var i, self = this, - offset = self._nextSet(self._row), - isWhite = !self._row[offset], - counterPos = 0, - bestMatch = { - error: Number.MAX_VALUE, - code: -1, - start: 0 - }, - error; - - if (cmpCounter) { - for (i = 0; i < cmpCounter.length; i++) { - counter.push(0); - } - for (i = offset; i < self._row.length; i++) { - if (self._row[i] ^ isWhite) { - counter[counterPos]++; - } else { - if (counterPos === counter.length - 1) { - error = self._matchPattern(counter, cmpCounter); + codeFrequency = 0x0, + firstDigit; - if (error < epsilon) { - bestMatch.start = i - offset; - bestMatch.end = i; - bestMatch.counter = counter; - return bestMatch; - } else { - return null; - } - } else { - counterPos++; - } - counter[counterPos] = 1; - isWhite = !isWhite; - } + for (i = 0; i < 6; i++) { + code = self._decodeCode(code.end); + if (!code) { + return null; } - } else { - counter.push(0); - for (i = offset; i < self._row.length; i++) { - if (self._row[i] ^ isWhite) { - counter[counterPos]++; - } else { - counterPos++; - counter.push(0); - counter[counterPos] = 1; - isWhite = !isWhite; - } + if (code.code >= self.CODE_G_START) { + code.code = code.code - self.CODE_G_START; + codeFrequency |= 1 << 5 - i; + } else { + codeFrequency |= 0 << 5 - i; } + result.push(code.code); + decodedCodes.push(code); } - // if cmpCounter was not given - bestMatch.start = offset; - bestMatch.end = self._row.length - 1; - bestMatch.counter = counter; - return bestMatch; -}; + firstDigit = self._calculateFirstDigit(codeFrequency); + if (firstDigit === null) { + return null; + } + result.unshift(firstDigit); -BarcodeReader.prototype.decodePattern = function (pattern) { - var self = this, - result; + code = self._findPattern(self.MIDDLE_PATTERN, code.end, true, false); + if (code === null) { + return null; + } + decodedCodes.push(code); - self._row = pattern; - result = self._decode(); - if (result === null) { - self._row.reverse(); - result = self._decode(); - if (result) { - result.direction = BarcodeReader.DIRECTION.REVERSE; - result.start = self._row.length - result.start; - result.end = self._row.length - result.end; + for (i = 0; i < 6; i++) { + code = self._decodeCode(code.end, self.CODE_G_START); + if (!code) { + return null; } - } else { - result.direction = BarcodeReader.DIRECTION.FORWARD; + decodedCodes.push(code); + result.push(code.code); + } + + return code; +}; + +EANReader.prototype._decode = function () { + var startInfo, + self = this, + code, + result = [], + decodedCodes = [], + resultInfo = {}; + + startInfo = self._findStart(); + if (!startInfo) { + return null; } - if (result) { - result.format = self.FORMAT; + code = { + code: startInfo.code, + start: startInfo.start, + end: startInfo.end + }; + decodedCodes.push(code); + code = self._decodePayload(code, result, decodedCodes); + if (!code) { + return null; + } + code = self._findEnd(code.end, false); + if (!code) { + return null; } - return result; -}; -BarcodeReader.prototype._matchRange = function (start, end, value) { - var i; + decodedCodes.push(code); - start = start < 0 ? 0 : start; - for (i = start; i < end; i++) { - if (this._row[i] !== value) { - return false; + // Checksum + if (!self._checksum(result)) { + return null; + } + + if (this.supplements.length > 0) { + var ext = this._decodeExtensions(code.end); + if (!ext) { + return null; + } + var lastCode = ext.decodedCodes[ext.decodedCodes.length - 1], + endInfo = { + start: lastCode.start + ((lastCode.end - lastCode.start) / 2 | 0), + end: lastCode.end + }; + if (!self._verifyTrailingWhitespace(endInfo)) { + return null; } + resultInfo = { + supplement: ext, + code: result.join("") + ext.code + }; } - return true; + + return Object.assign({ + code: result.join(""), + start: startInfo.start, + end: code.end, + codeset: "", + startInfo: startInfo, + decodedCodes: decodedCodes + }, resultInfo); }; -BarcodeReader.prototype._fillCounters = function (offset, end, isWhite) { - var self = this, - counterPos = 0, - i, - counters = []; +EANReader.prototype._decodeExtensions = function (offset) { + var i, + start = this._nextSet(this._row, offset), + startInfo = this._findPattern(this.EXTENSION_START_PATTERN, start, false, false), + result; - isWhite = typeof isWhite !== 'undefined' ? isWhite : true; - offset = typeof offset !== 'undefined' ? offset : self._nextUnset(self._row); - end = end || self._row.length; + if (startInfo === null) { + return null; + } - counters[counterPos] = 0; - for (i = offset; i < end; i++) { - if (self._row[i] ^ isWhite) { - counters[counterPos]++; - } else { - counterPos++; - counters[counterPos] = 1; - isWhite = !isWhite; + for (i = 0; i < this.supplements.length; i++) { + result = this.supplements[i].decode(this._row, startInfo.end); + if (result !== null) { + return { + code: result.code, + start: start, + startInfo: startInfo, + end: result.end, + codeset: "", + decodedCodes: result.decodedCodes + }; } } - return counters; + return null; }; -Object.defineProperty(BarcodeReader.prototype, "FORMAT", { - value: 'unknown', - writeable: false -}); +EANReader.prototype._checksum = function (result) { + var sum = 0, + i; -BarcodeReader.DIRECTION = { - FORWARD: 1, - REVERSE: -1 + for (i = result.length - 2; i >= 0; i -= 2) { + sum += result[i]; + } + sum *= 3; + for (i = result.length - 1; i >= 0; i -= 2) { + sum += result[i]; + } + return sum % 10 === 0; }; -BarcodeReader.Exception = { - StartNotFoundException: "Start-Info was not found!", - CodeNotFoundException: "Code could not be found!", - PatternNotFoundException: "Pattern could not be found!" +EANReader.CONFIG_KEYS = { + supplements: { + 'type': 'arrayOf(string)', + 'default': [], + 'description': 'Allowed extensions to be decoded (2 and/or 5)' + } }; -BarcodeReader.CONFIG_KEYS = {}; - -/* harmony default export */ __webpack_exports__["a"] = BarcodeReader; - -/***/ }), -/* 9 */ -/***/ (function(module, exports) { - -module.exports = clone - -/** - * Creates a new vec2 initialized with values from an existing vector - * - * @param {vec2} a vector to clone - * @returns {vec2} a new 2D vector - */ -function clone(a) { - var out = new Float32Array(2) - out[0] = a[0] - out[1] = a[1] - return out -} +/* harmony default export */ __webpack_exports__["a"] = EANReader; /***/ }), -/* 10 */ +/* 8 */ /***/ (function(module, exports, __webpack_require__) { -var root = __webpack_require__(1); +var root = __webpack_require__(0); /** Built-in value references. */ var Symbol = root.Symbol; @@ -928,303 +948,203 @@ module.exports = Symbol; /***/ }), -/* 11 */ +/* 9 */ /***/ (function(module, exports, __webpack_require__) { -var isSymbol = __webpack_require__(39); +var Symbol = __webpack_require__(8), + getRawTag = __webpack_require__(169), + objectToString = __webpack_require__(198); -/** Used as references for various `Number` constants. */ -var INFINITY = 1 / 0; +/** `Object#toString` result references. */ +var nullTag = '[object Null]', + undefinedTag = '[object Undefined]'; + +/** Built-in value references. */ +var symToStringTag = Symbol ? Symbol.toStringTag : undefined; /** - * Converts `value` to a string key if it's not a string or symbol. + * The base implementation of `getTag` without fallbacks for buggy environments. * * @private - * @param {*} value The value to inspect. - * @returns {string|symbol} Returns the key. + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. */ -function toKey(value) { - if (typeof value == 'string' || isSymbol(value)) { - return value; +function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; } - var result = (value + ''); - return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; + return (symToStringTag && symToStringTag in Object(value)) + ? getRawTag(value) + : objectToString(value); } -module.exports = toKey; +module.exports = baseGetTag; /***/ }), -/* 12 */ +/* 10 */ /***/ (function(module, exports) { +module.exports = clone + /** - * Performs a - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * comparison between two values to determine if they are equivalent. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'a': 1 }; - * var other = { 'a': 1 }; - * - * _.eq(object, object); - * // => true - * - * _.eq(object, other); - * // => false - * - * _.eq('a', 'a'); - * // => true - * - * _.eq('a', Object('a')); - * // => false + * Creates a new vec2 initialized with values from an existing vector * - * _.eq(NaN, NaN); - * // => true + * @param {vec2} a vector to clone + * @returns {vec2} a new 2D vector */ -function eq(value, other) { - return value === other || (value !== value && other !== other); +function clone(a) { + var out = new Float32Array(2) + out[0] = a[0] + out[1] = a[1] + return out } -module.exports = eq; - - /***/ }), -/* 13 */ +/* 11 */ /***/ (function(module, exports, __webpack_require__) { -var baseIsArguments = __webpack_require__(121), - isObjectLike = __webpack_require__(4); - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** Built-in value references. */ -var propertyIsEnumerable = objectProto.propertyIsEnumerable; +var assignValue = __webpack_require__(33), + baseAssignValue = __webpack_require__(34); /** - * Checks if `value` is likely an `arguments` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an `arguments` object, - * else `false`. - * @example - * - * _.isArguments(function() { return arguments; }()); - * // => true + * Copies properties of `source` to `object`. * - * _.isArguments([1, 2, 3]); - * // => false + * @private + * @param {Object} source The object to copy properties from. + * @param {Array} props The property identifiers to copy. + * @param {Object} [object={}] The object to copy properties to. + * @param {Function} [customizer] The function to customize copied values. + * @returns {Object} Returns `object`. */ -var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { - return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && - !propertyIsEnumerable.call(value, 'callee'); -}; +function copyObject(source, props, object, customizer) { + var isNew = !object; + object || (object = {}); -module.exports = isArguments; + var index = -1, + length = props.length; + while (++index < length) { + var key = props[index]; -/***/ }), -/* 14 */ -/***/ (function(module, exports, __webpack_require__) { + var newValue = customizer + ? customizer(object[key], source[key], key, object, source) + : undefined; + + if (newValue === undefined) { + newValue = source[key]; + } + if (isNew) { + baseAssignValue(object, key, newValue); + } else { + assignValue(object, key, newValue); + } + } + return object; +} + +module.exports = copyObject; -var isFunction = __webpack_require__(37), - isLength = __webpack_require__(38); + +/***/ }), +/* 12 */ +/***/ (function(module, exports) { /** - * Checks if `value` is array-like. A value is considered array-like if it's - * not a function and has a `value.length` that's an integer greater than or - * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * comparison between two values to determine if they are equivalent. * * @static * @memberOf _ * @since 4.0.0 * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is array-like, else `false`. + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. * @example * - * _.isArrayLike([1, 2, 3]); - * // => true - * - * _.isArrayLike(document.body.children); - * // => true + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; * - * _.isArrayLike('abc'); + * _.eq(object, object); * // => true * - * _.isArrayLike(_.noop); + * _.eq(object, other); * // => false - */ -function isArrayLike(value) { - return value != null && isLength(value.length) && !isFunction(value); -} - -module.exports = isArrayLike; - - -/***/ }), -/* 15 */ -/***/ (function(module, exports, __webpack_require__) { - -var baseMerge = __webpack_require__(129), - createAssigner = __webpack_require__(147); - -/** - * This method is like `_.assign` except that it recursively merges own and - * inherited enumerable string keyed properties of source objects into the - * destination object. Source properties that resolve to `undefined` are - * skipped if a destination value exists. Array and plain object properties - * are merged recursively. Other objects and value types are overridden by - * assignment. Source objects are applied from left to right. Subsequent - * sources overwrite property assignments of previous sources. - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 0.5.0 - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @example * - * var object = { - * 'a': [{ 'b': 2 }, { 'd': 4 }] - * }; + * _.eq('a', 'a'); + * // => true * - * var other = { - * 'a': [{ 'c': 3 }, { 'e': 5 }] - * }; + * _.eq('a', Object('a')); + * // => false * - * _.merge(object, other); - * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } + * _.eq(NaN, NaN); + * // => true */ -var merge = createAssigner(function(object, source, srcIndex) { - baseMerge(object, source, srcIndex); -}); +function eq(value, other) { + return value === other || (value !== value && other !== other); +} -module.exports = merge; +module.exports = eq; /***/ }), -/* 16 */ +/* 13 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony default export */ __webpack_exports__["a"] = { - init: function init(arr, val) { - var l = arr.length; - while (l--) { - arr[l] = val; - } - }, - - /** - * Shuffles the content of an array - * @return {Array} the array itself shuffled - */ - shuffle: function shuffle(arr) { - var i = arr.length - 1, - j, - x; - for (i; i >= 0; i--) { - j = Math.floor(Math.random() * i); - x = arr[i]; - arr[i] = arr[j]; - arr[j] = x; - } - return arr; - }, - - toPointList: function toPointList(arr) { - var i, - j, - row = [], - rows = []; - for (i = 0; i < arr.length; i++) { - row = []; - for (j = 0; j < arr[i].length; j++) { - row[j] = arr[i][j]; - } - rows[i] = "[" + row.join(",") + "]"; - } - return "[" + rows.join(",\r\n") + "]"; - }, - - /** - * returns the elements which's score is bigger than the threshold - * @return {Array} the reduced array - */ - threshold: function threshold(arr, _threshold, scoreFunc) { - var i, - queue = []; - for (i = 0; i < arr.length; i++) { - if (scoreFunc.apply(arr, [arr[i]]) >= _threshold) { - queue.push(arr[i]); - } - } - return queue; + drawRect: function drawRect(pos, size, ctx, style) { + ctx.strokeStyle = style.color; + ctx.fillStyle = style.color; + ctx.lineWidth = 1; + ctx.beginPath(); + ctx.strokeRect(pos.x, pos.y, size.x, size.y); }, - - maxIndex: function maxIndex(arr) { - var i, - max = 0; - for (i = 0; i < arr.length; i++) { - if (arr[i] > arr[max]) { - max = i; - } + drawPath: function drawPath(path, def, ctx, style) { + ctx.strokeStyle = style.color; + ctx.fillStyle = style.color; + ctx.lineWidth = style.lineWidth; + ctx.beginPath(); + ctx.moveTo(path[0][def.x], path[0][def.y]); + for (var j = 1; j < path.length; j++) { + ctx.lineTo(path[j][def.x], path[j][def.y]); } - return max; + ctx.closePath(); + ctx.stroke(); }, + drawImage: function drawImage(imageData, size, ctx) { + var canvasData = ctx.getImageData(0, 0, size.x, size.y), + data = canvasData.data, + imageDataPos = imageData.length, + canvasDataPos = data.length, + value; - max: function max(arr) { - var i, - max = 0; - for (i = 0; i < arr.length; i++) { - if (arr[i] > max) { - max = arr[i]; - } + if (canvasDataPos / imageDataPos !== 4) { + return false; } - return max; - }, - - sum: function sum(arr) { - var length = arr.length, - sum = 0; - - while (length--) { - sum += arr[length]; + while (imageDataPos--) { + value = imageData[imageDataPos]; + data[--canvasDataPos] = 255; + data[--canvasDataPos] = value; + data[--canvasDataPos] = value; + data[--canvasDataPos] = value; } - return sum; + ctx.putImageData(canvasData, 0, 0); + return true; } }; /***/ }), -/* 17 */ +/* 14 */ /***/ (function(module, exports, __webpack_require__) { -var listCacheClear = __webpack_require__(169), - listCacheDelete = __webpack_require__(170), - listCacheGet = __webpack_require__(171), - listCacheHas = __webpack_require__(172), - listCacheSet = __webpack_require__(173); +var listCacheClear = __webpack_require__(184), + listCacheDelete = __webpack_require__(185), + listCacheGet = __webpack_require__(186), + listCacheHas = __webpack_require__(187), + listCacheSet = __webpack_require__(188); /** * Creates an list cache object. @@ -1255,7 +1175,7 @@ module.exports = ListCache; /***/ }), -/* 18 */ +/* 15 */ /***/ (function(module, exports, __webpack_require__) { var eq = __webpack_require__(12); @@ -1282,13 +1202,13 @@ module.exports = assocIndexOf; /***/ }), -/* 19 */ +/* 16 */ /***/ (function(module, exports, __webpack_require__) { -var isArray = __webpack_require__(0), - isKey = __webpack_require__(35), - stringToPath = __webpack_require__(194), - toString = __webpack_require__(208); +var isArray = __webpack_require__(1), + isKey = __webpack_require__(181), + stringToPath = __webpack_require__(207), + toString = __webpack_require__(218); /** * Casts `value` to a path array if it's not one. @@ -1309,10 +1229,10 @@ module.exports = castPath; /***/ }), -/* 20 */ +/* 17 */ /***/ (function(module, exports, __webpack_require__) { -var isKeyable = __webpack_require__(167); +var isKeyable = __webpack_require__(182); /** * Gets the data for `map`. @@ -1333,7 +1253,7 @@ module.exports = getMapData; /***/ }), -/* 21 */ +/* 18 */ /***/ (function(module, exports) { /** Used as references for various `Number` constants. */ @@ -1361,47 +1281,104 @@ module.exports = isIndex; /***/ }), -/* 22 */ -/***/ (function(module, exports) { +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { + +var getNative = __webpack_require__(4); + +/* Built-in method references that are verified to be native. */ +var nativeCreate = getNative(Object, 'create'); + +module.exports = nativeCreate; + + +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { + +var baseIsArguments = __webpack_require__(137), + isObjectLike = __webpack_require__(5); + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; -/** Used for built-in method references. */ -var objectProto = Object.prototype; +/** Built-in value references. */ +var propertyIsEnumerable = objectProto.propertyIsEnumerable; /** - * Checks if `value` is likely a prototype object. + * Checks if `value` is likely an `arguments` object. * - * @private + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + * else `false`. + * @example + * + * _.isArguments(function() { return arguments; }()); + * // => true + * + * _.isArguments([1, 2, 3]); + * // => false */ -function isPrototype(value) { - var Ctor = value && value.constructor, - proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; - - return value === proto; -} +var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { + return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && + !propertyIsEnumerable.call(value, 'callee'); +}; -module.exports = isPrototype; +module.exports = isArguments; /***/ }), -/* 23 */ +/* 21 */ /***/ (function(module, exports, __webpack_require__) { -var getNative = __webpack_require__(3); +var isFunction = __webpack_require__(40), + isLength = __webpack_require__(41); -/* Built-in method references that are verified to be native. */ -var nativeCreate = getNative(Object, 'create'); +/** + * Checks if `value` is array-like. A value is considered array-like if it's + * not a function and has a `value.length` that's an integer greater than or + * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is array-like, else `false`. + * @example + * + * _.isArrayLike([1, 2, 3]); + * // => true + * + * _.isArrayLike(document.body.children); + * // => true + * + * _.isArrayLike('abc'); + * // => true + * + * _.isArrayLike(_.noop); + * // => false + */ +function isArrayLike(value) { + return value != null && isLength(value.length) && !isFunction(value); +} -module.exports = nativeCreate; +module.exports = isArrayLike; /***/ }), -/* 24 */ +/* 22 */ /***/ (function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(module) {var root = __webpack_require__(1), - stubFalse = __webpack_require__(206); +/* WEBPACK VAR INJECTION */(function(module) {var root = __webpack_require__(0), + stubFalse = __webpack_require__(216); /** Detect free variable `exports`. */ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; @@ -1439,58 +1416,108 @@ var isBuffer = nativeIsBuffer || stubFalse; module.exports = isBuffer; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(41)(module))) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(45)(module))) /***/ }), -/* 25 */ +/* 23 */ /***/ (function(module, exports, __webpack_require__) { -var baseIsTypedArray = __webpack_require__(125), - baseUnary = __webpack_require__(139), - nodeUtil = __webpack_require__(183); - -/* Node.js helper references. */ -var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; +var arrayLikeKeys = __webpack_require__(56), + baseKeysIn = __webpack_require__(143), + isArrayLike = __webpack_require__(21); /** - * Checks if `value` is classified as a typed array. + * Creates an array of the own and inherited enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. * * @static * @memberOf _ * @since 3.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. * @example * - * _.isTypedArray(new Uint8Array); - * // => true + * function Foo() { + * this.a = 1; + * this.b = 2; + * } * - * _.isTypedArray([]); - * // => false + * Foo.prototype.c = 3; + * + * _.keysIn(new Foo); + * // => ['a', 'b', 'c'] (iteration order is not guaranteed) */ -var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; +function keysIn(object) { + return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); +} -module.exports = isTypedArray; +module.exports = keysIn; /***/ }), -/* 26 */ +/* 24 */ +/***/ (function(module, exports, __webpack_require__) { + +var baseMerge = __webpack_require__(144), + createAssigner = __webpack_require__(163); + +/** + * This method is like `_.assign` except that it recursively merges own and + * inherited enumerable string keyed properties of source objects into the + * destination object. Source properties that resolve to `undefined` are + * skipped if a destination value exists. Array and plain object properties + * are merged recursively. Other objects and value types are overridden by + * assignment. Source objects are applied from left to right. Subsequent + * sources overwrite property assignments of previous sources. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 0.5.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @example + * + * var object = { + * 'a': [{ 'b': 2 }, { 'd': 4 }] + * }; + * + * var other = { + * 'a': [{ 'c': 3 }, { 'e': 5 }] + * }; + * + * _.merge(object, other); + * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } + */ +var merge = createAssigner(function(object, source, srcIndex) { + baseMerge(object, source, srcIndex); +}); + +module.exports = merge; + + +/***/ }), +/* 25 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__cluster__ = __webpack_require__(74); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__array_helper__ = __webpack_require__(16); -/* harmony export (immutable) */ __webpack_exports__["f"] = imageRef; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__cluster__ = __webpack_require__(82); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__array_helper__ = __webpack_require__(6); +/* harmony export (immutable) */ __webpack_exports__["g"] = imageRef; /* unused harmony export computeIntegralImage2 */ /* unused harmony export computeIntegralImage */ /* unused harmony export thresholdImage */ /* unused harmony export computeHistogram */ /* unused harmony export sharpenLine */ /* unused harmony export determineOtsuThreshold */ -/* harmony export (immutable) */ __webpack_exports__["c"] = otsuThreshold; +/* harmony export (immutable) */ __webpack_exports__["d"] = otsuThreshold; /* unused harmony export computeBinaryImage */ -/* harmony export (immutable) */ __webpack_exports__["d"] = cluster; +/* harmony export (immutable) */ __webpack_exports__["e"] = cluster; /* unused harmony export Tracer */ /* unused harmony export DILATE */ /* unused harmony export ERODE */ @@ -1499,26 +1526,26 @@ module.exports = isTypedArray; /* unused harmony export subtract */ /* unused harmony export bitwiseOr */ /* unused harmony export countNonZero */ -/* harmony export (immutable) */ __webpack_exports__["e"] = topGeneric; +/* harmony export (immutable) */ __webpack_exports__["f"] = topGeneric; /* unused harmony export grayArrayFromImage */ /* unused harmony export grayArrayFromContext */ -/* harmony export (immutable) */ __webpack_exports__["i"] = grayAndHalfSampleFromCanvasData; -/* harmony export (immutable) */ __webpack_exports__["j"] = computeGray; +/* unused harmony export grayAndHalfSampleFromCanvasData */ +/* harmony export (immutable) */ __webpack_exports__["b"] = computeGray; /* unused harmony export loadImageArray */ -/* harmony export (immutable) */ __webpack_exports__["g"] = halfSample; +/* harmony export (immutable) */ __webpack_exports__["h"] = halfSample; /* harmony export (immutable) */ __webpack_exports__["a"] = hsv2rgb; /* unused harmony export _computeDivisors */ -/* harmony export (immutable) */ __webpack_exports__["b"] = calculatePatchSize; +/* harmony export (immutable) */ __webpack_exports__["c"] = calculatePatchSize; /* unused harmony export _parseCSSDimensionValues */ /* unused harmony export _dimensionsConverters */ -/* harmony export (immutable) */ __webpack_exports__["h"] = computeImageArea; +/* harmony export (immutable) */ __webpack_exports__["i"] = computeImageArea; var vec2 = { - clone: __webpack_require__(9) + clone: __webpack_require__(10) }; var vec3 = { - clone: __webpack_require__(107) + clone: __webpack_require__(115) }; /** @@ -2043,7 +2070,7 @@ function grayAndHalfSampleFromCanvasData(canvasData, size, outArray) { while (bottomRowIdx < endIdx) { for (i = 0; i < outWidth; i++) { - outArray[outImgIdx] = Math.floor((0.299 * canvasData[topRowIdx * 4 + 0] + 0.587 * canvasData[topRowIdx * 4 + 1] + 0.114 * canvasData[topRowIdx * 4 + 2] + (0.299 * canvasData[(topRowIdx + 1) * 4 + 0] + 0.587 * canvasData[(topRowIdx + 1) * 4 + 1] + 0.114 * canvasData[(topRowIdx + 1) * 4 + 2]) + (0.299 * canvasData[bottomRowIdx * 4 + 0] + 0.587 * canvasData[bottomRowIdx * 4 + 1] + 0.114 * canvasData[bottomRowIdx * 4 + 2]) + (0.299 * canvasData[(bottomRowIdx + 1) * 4 + 0] + 0.587 * canvasData[(bottomRowIdx + 1) * 4 + 1] + 0.114 * canvasData[(bottomRowIdx + 1) * 4 + 2])) / 4); + outArray[outImgIdx] = (0.299 * canvasData[topRowIdx * 4 + 0] + 0.587 * canvasData[topRowIdx * 4 + 1] + 0.114 * canvasData[topRowIdx * 4 + 2] + (0.299 * canvasData[(topRowIdx + 1) * 4 + 0] + 0.587 * canvasData[(topRowIdx + 1) * 4 + 1] + 0.114 * canvasData[(topRowIdx + 1) * 4 + 2]) + (0.299 * canvasData[bottomRowIdx * 4 + 0] + 0.587 * canvasData[bottomRowIdx * 4 + 1] + 0.114 * canvasData[bottomRowIdx * 4 + 2]) + (0.299 * canvasData[(bottomRowIdx + 1) * 4 + 0] + 0.587 * canvasData[(bottomRowIdx + 1) * 4 + 1] + 0.114 * canvasData[(bottomRowIdx + 1) * 4 + 2])) / 4; outImgIdx++; topRowIdx = topRowIdx + 2; bottomRowIdx = bottomRowIdx + 2; @@ -2064,7 +2091,7 @@ function computeGray(imageData, outArray, config) { } } else { for (i = 0; i < l; i++) { - outArray[i] = Math.floor(0.299 * imageData[i * 4 + 0] + 0.587 * imageData[i * 4 + 1] + 0.114 * imageData[i * 4 + 2]); + outArray[i] = 0.299 * imageData[i * 4 + 0] + 0.587 * imageData[i * 4 + 1] + 0.114 * imageData[i * 4 + 2]; } } }; @@ -2291,18 +2318,18 @@ function computeImageArea(inputWidth, inputHeight, area) { }; /***/ }), -/* 27 */ +/* 26 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__subImage__ = __webpack_require__(78); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_cv_utils__ = __webpack_require__(26); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_array_helper__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__subImage__ = __webpack_require__(85); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_cv_utils__ = __webpack_require__(25); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_array_helper__ = __webpack_require__(6); var vec2 = { - clone: __webpack_require__(9) + clone: __webpack_require__(10) }; /** @@ -2651,12 +2678,47 @@ ImageWrapper.prototype.overlay = function (canvas, scale, from) { /* harmony default export */ __webpack_exports__["a"] = ImageWrapper; +/***/ }), +/* 27 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony export (immutable) */ __webpack_exports__["b"] = sleep; +/* harmony export (immutable) */ __webpack_exports__["a"] = getViewport; + +function sleep(millis) { + return new Promise(function (resolve) { + window.setTimeout(resolve, millis); + }); +} + +function getViewport(target) { + if (target && target.nodeName && target.nodeType === 1) { + return target; + } else { + // Use '#interactive.viewport' as a fallback selector (backwards compatibility) + var selector = typeof target === 'string' ? target : '#interactive.viewport'; + return document.querySelector(selector); + } +} + /***/ }), /* 28 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Scope; }); +var Scope = { + INTERNAL: "INTERNAL", + EXTERNAL: 'EXTERNAL' +}; + +/***/ }), +/* 29 */ /***/ (function(module, exports, __webpack_require__) { -var getNative = __webpack_require__(3), - root = __webpack_require__(1); +var getNative = __webpack_require__(4), + root = __webpack_require__(0); /* Built-in method references that are verified to be native. */ var Map = getNative(root, 'Map'); @@ -2665,14 +2727,14 @@ module.exports = Map; /***/ }), -/* 29 */ +/* 30 */ /***/ (function(module, exports, __webpack_require__) { -var mapCacheClear = __webpack_require__(174), - mapCacheDelete = __webpack_require__(175), - mapCacheGet = __webpack_require__(176), - mapCacheHas = __webpack_require__(177), - mapCacheSet = __webpack_require__(178); +var mapCacheClear = __webpack_require__(189), + mapCacheDelete = __webpack_require__(190), + mapCacheGet = __webpack_require__(191), + mapCacheHas = __webpack_require__(192), + mapCacheSet = __webpack_require__(193); /** * Creates a map cache object to store key-value pairs. @@ -2703,15 +2765,15 @@ module.exports = MapCache; /***/ }), -/* 30 */ +/* 31 */ /***/ (function(module, exports, __webpack_require__) { -var ListCache = __webpack_require__(17), - stackClear = __webpack_require__(189), - stackDelete = __webpack_require__(190), - stackGet = __webpack_require__(191), - stackHas = __webpack_require__(192), - stackSet = __webpack_require__(193); +var ListCache = __webpack_require__(14), + stackClear = __webpack_require__(202), + stackDelete = __webpack_require__(203), + stackGet = __webpack_require__(204), + stackHas = __webpack_require__(205), + stackSet = __webpack_require__(206); /** * Creates a stack cache object to store key-value pairs. @@ -2736,7 +2798,7 @@ module.exports = Stack; /***/ }), -/* 31 */ +/* 32 */ /***/ (function(module, exports) { /** @@ -2762,10 +2824,44 @@ module.exports = arrayPush; /***/ }), -/* 32 */ +/* 33 */ +/***/ (function(module, exports, __webpack_require__) { + +var baseAssignValue = __webpack_require__(34), + eq = __webpack_require__(12); + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Assigns `value` to `key` of `object` if the existing value is not equivalent + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ +function assignValue(object, key, value) { + var objValue = object[key]; + if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || + (value === undefined && !(key in object))) { + baseAssignValue(object, key, value); + } +} + +module.exports = assignValue; + + +/***/ }), +/* 34 */ /***/ (function(module, exports, __webpack_require__) { -var defineProperty = __webpack_require__(57); +var defineProperty = __webpack_require__(63); /** * The base implementation of `assignValue` and `assignMergeValue` without @@ -2793,114 +2889,131 @@ module.exports = baseAssignValue; /***/ }), -/* 33 */ +/* 35 */ /***/ (function(module, exports, __webpack_require__) { -var castPath = __webpack_require__(19), - toKey = __webpack_require__(11); +var Uint8Array = __webpack_require__(55); /** - * The base implementation of `_.get` without support for default values. + * Creates a clone of `arrayBuffer`. * * @private - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to get. - * @returns {*} Returns the resolved value. + * @param {ArrayBuffer} arrayBuffer The array buffer to clone. + * @returns {ArrayBuffer} Returns the cloned array buffer. */ -function baseGet(object, path) { - path = castPath(path, object); - - var index = 0, - length = path.length; - - while (object != null && index < length) { - object = object[toKey(path[index++])]; - } - return (index && index == length) ? object : undefined; +function cloneArrayBuffer(arrayBuffer) { + var result = new arrayBuffer.constructor(arrayBuffer.byteLength); + new Uint8Array(result).set(new Uint8Array(arrayBuffer)); + return result; } -module.exports = baseGet; +module.exports = cloneArrayBuffer; /***/ }), -/* 34 */ +/* 36 */ /***/ (function(module, exports, __webpack_require__) { -var overArg = __webpack_require__(64); +var overArg = __webpack_require__(71); /** Built-in value references. */ var getPrototype = overArg(Object.getPrototypeOf, Object); -module.exports = getPrototype; +module.exports = getPrototype; + + +/***/ }), +/* 37 */ +/***/ (function(module, exports, __webpack_require__) { + +var arrayFilter = __webpack_require__(126), + stubArray = __webpack_require__(78); + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Built-in value references. */ +var propertyIsEnumerable = objectProto.propertyIsEnumerable; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeGetSymbols = Object.getOwnPropertySymbols; + +/** + * Creates an array of the own enumerable symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. + */ +var getSymbols = !nativeGetSymbols ? stubArray : function(object) { + if (object == null) { + return []; + } + object = Object(object); + return arrayFilter(nativeGetSymbols(object), function(symbol) { + return propertyIsEnumerable.call(object, symbol); + }); +}; + +module.exports = getSymbols; /***/ }), -/* 35 */ -/***/ (function(module, exports, __webpack_require__) { - -var isArray = __webpack_require__(0), - isSymbol = __webpack_require__(39); +/* 38 */ +/***/ (function(module, exports) { -/** Used to match property names within property paths. */ -var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, - reIsPlainProp = /^\w*$/; +/** Used for built-in method references. */ +var objectProto = Object.prototype; /** - * Checks if `value` is a property name and not a property path. + * Checks if `value` is likely a prototype object. * * @private * @param {*} value The value to check. - * @param {Object} [object] The object to query keys on. - * @returns {boolean} Returns `true` if `value` is a property name, else `false`. + * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. */ -function isKey(value, object) { - if (isArray(value)) { - return false; - } - var type = typeof value; - if (type == 'number' || type == 'symbol' || type == 'boolean' || - value == null || isSymbol(value)) { - return true; - } - return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || - (object != null && value in Object(object)); +function isPrototype(value) { + var Ctor = value && value.constructor, + proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; + + return value === proto; } -module.exports = isKey; +module.exports = isPrototype; /***/ }), -/* 36 */ -/***/ (function(module, exports) { +/* 39 */ +/***/ (function(module, exports, __webpack_require__) { + +var isSymbol = __webpack_require__(42); + +/** Used as references for various `Number` constants. */ +var INFINITY = 1 / 0; /** - * This method returns the first argument it receives. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Util - * @param {*} value Any value. - * @returns {*} Returns `value`. - * @example - * - * var object = { 'a': 1 }; + * Converts `value` to a string key if it's not a string or symbol. * - * console.log(_.identity(object) === object); - * // => true + * @private + * @param {*} value The value to inspect. + * @returns {string|symbol} Returns the key. */ -function identity(value) { - return value; +function toKey(value) { + if (typeof value == 'string' || isSymbol(value)) { + return value; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; } -module.exports = identity; +module.exports = toKey; /***/ }), -/* 37 */ +/* 40 */ /***/ (function(module, exports, __webpack_require__) { -var baseGetTag = __webpack_require__(6), +var baseGetTag = __webpack_require__(9), isObject = __webpack_require__(2); /** `Object#toString` result references. */ @@ -2940,7 +3053,7 @@ module.exports = isFunction; /***/ }), -/* 38 */ +/* 41 */ /***/ (function(module, exports) { /** Used as references for various `Number` constants. */ @@ -2981,11 +3094,11 @@ module.exports = isLength; /***/ }), -/* 39 */ +/* 42 */ /***/ (function(module, exports, __webpack_require__) { -var baseGetTag = __webpack_require__(6), - isObjectLike = __webpack_require__(4); +var baseGetTag = __webpack_require__(9), + isObjectLike = __webpack_require__(5); /** `Object#toString` result references. */ var symbolTag = '[object Symbol]'; @@ -3016,21 +3129,56 @@ module.exports = isSymbol; /***/ }), -/* 40 */ +/* 43 */ /***/ (function(module, exports, __webpack_require__) { -var arrayLikeKeys = __webpack_require__(48), - baseKeysIn = __webpack_require__(126), - isArrayLike = __webpack_require__(14); +var baseIsTypedArray = __webpack_require__(141), + baseUnary = __webpack_require__(153), + nodeUtil = __webpack_require__(197); + +/* Node.js helper references. */ +var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; /** - * Creates an array of the own and inherited enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. + * Checks if `value` is classified as a typed array. * * @static * @memberOf _ * @since 3.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + * @example + * + * _.isTypedArray(new Uint8Array); + * // => true + * + * _.isTypedArray([]); + * // => false + */ +var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; + +module.exports = isTypedArray; + + +/***/ }), +/* 44 */ +/***/ (function(module, exports, __webpack_require__) { + +var arrayLikeKeys = __webpack_require__(56), + baseKeys = __webpack_require__(142), + isArrayLike = __webpack_require__(21); + +/** + * Creates an array of the own enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. See the + * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * for more details. + * + * @static + * @since 0.1.0 + * @memberOf _ * @category Object * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. @@ -3043,124 +3191,358 @@ var arrayLikeKeys = __webpack_require__(48), * * Foo.prototype.c = 3; * - * _.keysIn(new Foo); - * // => ['a', 'b', 'c'] (iteration order is not guaranteed) + * _.keys(new Foo); + * // => ['a', 'b'] (iteration order is not guaranteed) + * + * _.keys('hi'); + * // => ['0', '1'] */ -function keysIn(object) { - return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); +function keys(object) { + return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); +} + +module.exports = keys; + + +/***/ }), +/* 45 */ +/***/ (function(module, exports) { + +module.exports = function(module) { + if(!module.webpackPolyfill) { + module.deprecate = function() {}; + module.paths = []; + // module.parent = undefined by default + if(!module.children) module.children = []; + Object.defineProperty(module, "loaded", { + enumerable: true, + get: function() { + return module.l; + } + }); + Object.defineProperty(module, "id", { + enumerable: true, + get: function() { + return module.i; + } + }); + module.webpackPolyfill = 1; + } + return module; +}; + + +/***/ }), +/* 46 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__log__ = __webpack_require__(48); +/* harmony export (immutable) */ __webpack_exports__["a"] = aquire; +/* harmony export (immutable) */ __webpack_exports__["b"] = release; +/* harmony export (immutable) */ __webpack_exports__["c"] = releaseAll; + + +var debug = __WEBPACK_IMPORTED_MODULE_0__log__["a" /* log */].bind(null, __WEBPACK_IMPORTED_MODULE_0__log__["b" /* DEBUG */], "buffers.js"); +var buffers = []; + +function aquire(bytes) { + var allocation = findBySize(bytes); + if (allocation) { + debug("reusing " + bytes, debugSize); + return allocation; + } + debug("allocating " + bytes, debugSize); + var buffer = new ArrayBuffer(bytes); + return buffer; +} + +function release(buffer) { + if (!buffer) { + throw new Error("Buffer not defined"); + } + buffers.push(buffer); + debug('release', debugSize); +} + +function releaseAll() { + buffers = []; +} + +function debugSize() { + return "size: " + Object.keys(buffers).filter(function (key) { + return buffers[key] !== null; + }).length; +} + +function findBySize(bytes) { + for (var i = 0; i < buffers.length; i++) { + if (buffers[i].byteLength === bytes) { + var allocation = buffers[i]; + buffers.splice(i, 1); + return allocation; + } + } + return null; +} + +/***/ }), +/* 47 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return PORTRAIT; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return LANDSCAPE; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return SQUARE; }); +/* harmony export (immutable) */ __webpack_exports__["d"] = determineOrientation; +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var _matchingScreens; + +var PORTRAIT = "portrait"; +var LANDSCAPE = "landscape"; +var SQUARE = "square"; + +var matchingScreens = (_matchingScreens = {}, _matchingScreens[PORTRAIT] = /portrait/i, _matchingScreens[LANDSCAPE] = /landscape/i, _matchingScreens); + +function determineOrientation() { + var orientationType = screen.msOrientation || screen.mozOrientation; + if (typeof orientationType !== 'string') { + orientationType = screen.orientation; + if ((typeof orientationType === "undefined" ? "undefined" : _typeof(orientationType)) === 'object' && orientationType.type) { + orientationType = orientationType.type; + } + } + if (orientationType) { + return Object.keys(matchingScreens).filter(function (orientation) { + return matchingScreens[orientation].test(orientationType); + })[0]; + } + console.log("Failed to determine orientation, defaults to " + PORTRAIT); + return PORTRAIT; +} + +/***/ }), +/* 48 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return DEBUG; }); +/* harmony export (immutable) */ __webpack_exports__["a"] = log; +var DEBUG = "debug"; + +function log(level, scope) { + if (level !== DEBUG) { + for (var _len = arguments.length, rest = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + rest[_key - 2] = arguments[_key]; + } + + console.log(level + ': ' + scope + ' - ' + msg(rest)); + } +} + +function msg(args) { + return args.map(function (arg) { + if (typeof arg === 'function') { + return arg(); + } + return arg; + }).join(', '); +} + +/***/ }), +/* 49 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +var config = void 0; + +if (true) { + config = __webpack_require__(87); +} else if (ENV.node) { + config = require('./config.node.js'); +} else { + config = require('./config.prod.js'); } -module.exports = keysIn; +/* harmony default export */ __webpack_exports__["a"] = config; + +/***/ }), +/* 50 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return Source; }); +/* harmony export (immutable) */ __webpack_exports__["a"] = generateSourceInterface; +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var Source = function () { + function Source(type) { + _classCallCheck(this, Source); + + this.type = type; + } + + Source.prototype.getDimensions = function getDimensions() {}; + + Source.prototype.getConstraints = function getConstraints() {}; + + Source.prototype.getDrawable = function getDrawable() {}; + + Source.prototype.applyConstraints = function applyConstraints() {}; + Source.prototype.getLabel = function getLabel() {}; -/***/ }), -/* 41 */ -/***/ (function(module, exports) { + Source.prototype.stop = function stop() {}; -module.exports = function(module) { - if(!module.webpackPolyfill) { - module.deprecate = function() {}; - module.paths = []; - // module.parent = undefined by default - if(!module.children) module.children = []; - Object.defineProperty(module, "loaded", { - enumerable: true, - get: function() { - return module.l; - } - }); - Object.defineProperty(module, "id", { - enumerable: true, - get: function() { - return module.i; - } - }); - module.webpackPolyfill = 1; - } - return module; -}; + Source.prototype.getScope = function getScope() {}; + + Source.prototype.waitUntilReady = function waitUntilReady() { + return Promise.resolve(); + }; + return Source; +}(); + + + +function generateSourceInterface() { + return { + type: "INTERFACE", + getDimensions: function getDimensions() {}, + getConstraints: function getConstraints() {}, + getDrawable: function getDrawable() {}, + applyConstraints: function applyConstraints() {}, + getLabel: function getLabel() {}, + stop: function stop() {}, + getScope: function getScope() {}, + waitUntilReady: function waitUntilReady() { + return Promise.resolve(); + } + }; +}; /***/ }), -/* 42 */ +/* 51 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common_image_debug__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_pick__ = __webpack_require__(215); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_pick___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash_pick__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_mediaDevices__ = __webpack_require__(84); +/* unused harmony export pickConstraints */ -function contains(codeResult, list) { - if (list) { - return list.some(function (item) { - return Object.keys(item).every(function (key) { - return item[key] === codeResult[key]; - }); - }); - } - return false; -} -function passesFilter(codeResult, filter) { - if (typeof filter === 'function') { - return filter(codeResult); - } - return true; -} -/* harmony default export */ __webpack_exports__["a"] = { - create: function create(config) { - var canvas = document.createElement("canvas"), - ctx = canvas.getContext("2d"), - results = [], - capacity = config.capacity || 20, - capture = config.capture === true; +var facingMatching = { + "user": /front/i, + "environment": /back/i +}; - function matchesConstraints(codeResult) { - return capacity && codeResult && !contains(codeResult, config.blacklist) && passesFilter(codeResult, config.filter); - } +var streamRef; - return { - addResult: function addResult(data, imageSize, codeResult) { - var result = {}; +function waitForVideo(video, stream) { + return new Promise(function (resolve, reject) { + var attempts = 20; - if (matchesConstraints(codeResult)) { - capacity--; - result.codeResult = codeResult; - if (capture) { - canvas.width = imageSize.x; - canvas.height = imageSize.y; - __WEBPACK_IMPORTED_MODULE_0__common_image_debug__["a" /* default */].drawImage(data, imageSize, ctx); - result.frame = canvas.toDataURL(); + function checkVideo() { + if (attempts > 0) { + if (video.videoWidth > 10 && video.videoHeight > 10) { + if (true) { + console.log(video.videoWidth + "px x " + video.videoHeight + "px"); } - results.push(result); + resolve(stream); + } else { + window.setTimeout(checkVideo, 200); } - }, - getResults: function getResults() { - return results; + } else { + reject('Unable to play video stream. Is webcam working?'); } - }; + attempts--; + } + checkVideo(); + }); +} + +/** + * Tries to attach the camera-stream to a given video-element + * and calls the callback function when the content is ready + * @param {Object} constraints + * @param {Object} video + */ +function initCamera(video, constraints) { + return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mediaDevices__["a" /* getUserMedia */])(constraints).then(function (stream) { + return new Promise(function (resolve) { + streamRef = stream; + video.setAttribute("autoplay", 'true'); + video.srcObject = stream; + video.addEventListener('loadedmetadata', function () { + video.play(); + resolve(stream); + }); + }); + }).then(waitForVideo.bind(null, video)); +} + +function deprecatedConstraints(videoConstraints) { + var normalized = __WEBPACK_IMPORTED_MODULE_0_lodash_pick___default()(videoConstraints, ["width", "height", "facingMode", "aspectRatio", "deviceId"]); + + if (typeof videoConstraints.minAspectRatio !== 'undefined' && videoConstraints.minAspectRatio > 0) { + normalized.aspectRatio = videoConstraints.minAspectRatio; + console.log("WARNING: Constraint 'minAspectRatio' is deprecated; Use 'aspectRatio' instead"); } -}; + if (typeof videoConstraints.facing !== 'undefined') { + normalized.facingMode = videoConstraints.facing; + console.log("WARNING: Constraint 'facing' is deprecated. Use 'facingMode' instead'"); + } + return normalized; +} -/***/ }), -/* 43 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +function pickConstraints(videoConstraints) { + var normalizedConstraints = { + audio: false, + video: deprecatedConstraints(videoConstraints) + }; -"use strict"; -var config = void 0; + if (normalizedConstraints.video.deviceId && normalizedConstraints.video.facingMode) { + delete normalizedConstraints.video.facingMode; + } + return Promise.resolve(normalizedConstraints); +} -if (true) { - config = __webpack_require__(80); -} else if (ENV.node) { - config = require('./config.node.js'); -} else { - config = require('./config.prod.js'); +function enumerateVideoDevices() { + return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mediaDevices__["b" /* enumerateDevices */])().then(function (devices) { + return devices.filter(function (device) { + return device.kind === 'videoinput'; + }); + }); } -/* harmony default export */ __webpack_exports__["a"] = config; +/* harmony default export */ __webpack_exports__["a"] = { + request: function request(video, videoConstraints) { + return pickConstraints(videoConstraints).then(initCamera.bind(null, video)); + }, + release: function release() { + var tracks = streamRef && streamRef.getVideoTracks(); + if (tracks && tracks.length) { + tracks[0].stop(); + } + streamRef = null; + }, + enumerateVideoDevices: enumerateVideoDevices, + getActiveStreamLabel: function getActiveStreamLabel() { + if (streamRef) { + var tracks = streamRef.getVideoTracks(); + if (tracks && tracks.length) { + return tracks[0].label; + } + } + } +}; /***/ }), -/* 44 */ +/* 52 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -3265,12 +3647,12 @@ var Tracer = { /* harmony default export */ __webpack_exports__["a"] = Tracer; /***/ }), -/* 45 */ +/* 53 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__barcode_reader__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_array_helper__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__barcode_reader__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_array_helper__ = __webpack_require__(6); @@ -3289,33 +3671,6 @@ var properties = { Code39Reader.prototype = Object.create(__WEBPACK_IMPORTED_MODULE_0__barcode_reader__["a" /* default */].prototype, properties); Code39Reader.prototype.constructor = Code39Reader; -Code39Reader.prototype._toCounters = function (start, counter) { - var self = this, - numCounters = counter.length, - end = self._row.length, - isWhite = !self._row[start], - i, - counterPos = 0; - - __WEBPACK_IMPORTED_MODULE_1__common_array_helper__["a" /* default */].init(counter, 0); - - for (i = start; i < end; i++) { - if (self._row[i] ^ isWhite) { - counter[counterPos]++; - } else { - counterPos++; - if (counterPos === numCounters) { - break; - } else { - counter[counterPos] = 1; - isWhite = !isWhite; - } - } - } - - return counter; -}; - Code39Reader.prototype._decode = function () { var self = this, counters = [0, 0, 0, 0, 0, 0, 0, 0, 0], @@ -3484,7 +3839,7 @@ Code39Reader.prototype._findStart = function () { /* harmony default export */ __webpack_exports__["a"] = Code39Reader; /***/ }), -/* 46 */ +/* 54 */ /***/ (function(module, exports) { module.exports = dot @@ -3501,10 +3856,10 @@ function dot(a, b) { } /***/ }), -/* 47 */ +/* 55 */ /***/ (function(module, exports, __webpack_require__) { -var root = __webpack_require__(1); +var root = __webpack_require__(0); /** Built-in value references. */ var Uint8Array = root.Uint8Array; @@ -3513,15 +3868,15 @@ module.exports = Uint8Array; /***/ }), -/* 48 */ +/* 56 */ /***/ (function(module, exports, __webpack_require__) { -var baseTimes = __webpack_require__(137), - isArguments = __webpack_require__(13), - isArray = __webpack_require__(0), - isBuffer = __webpack_require__(24), - isIndex = __webpack_require__(21), - isTypedArray = __webpack_require__(25); +var baseTimes = __webpack_require__(151), + isArguments = __webpack_require__(20), + isArray = __webpack_require__(1), + isBuffer = __webpack_require__(22), + isIndex = __webpack_require__(18), + isTypedArray = __webpack_require__(43); /** Used for built-in method references. */ var objectProto = Object.prototype; @@ -3568,98 +3923,69 @@ module.exports = arrayLikeKeys; /***/ }), -/* 49 */ +/* 57 */ /***/ (function(module, exports) { /** - * A specialized version of `_.map` for arrays without support for iteratee - * shorthands. + * A specialized version of `_.reduce` for arrays without support for + * iteratee shorthands. * * @private * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the new mapped array. - */ -function arrayMap(array, iteratee) { - var index = -1, - length = array == null ? 0 : array.length, - result = Array(length); - - while (++index < length) { - result[index] = iteratee(array[index], index, array); - } - return result; -} - -module.exports = arrayMap; - - -/***/ }), -/* 50 */ -/***/ (function(module, exports, __webpack_require__) { - -var baseAssignValue = __webpack_require__(32), - eq = __webpack_require__(12); - -/** - * This function is like `assignValue` except that it doesn't assign - * `undefined` values. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ -function assignMergeValue(object, key, value) { - if ((value !== undefined && !eq(object[key], value)) || - (value === undefined && !(key in object))) { - baseAssignValue(object, key, value); + * @param {Function} iteratee The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @param {boolean} [initAccum] Specify using the first element of `array` as + * the initial value. + * @returns {*} Returns the accumulated value. + */ +function arrayReduce(array, iteratee, accumulator, initAccum) { + var index = -1, + length = array == null ? 0 : array.length; + + if (initAccum && length) { + accumulator = array[++index]; + } + while (++index < length) { + accumulator = iteratee(accumulator, array[index], index, array); } + return accumulator; } -module.exports = assignMergeValue; +module.exports = arrayReduce; /***/ }), -/* 51 */ +/* 58 */ /***/ (function(module, exports, __webpack_require__) { -var baseAssignValue = __webpack_require__(32), +var baseAssignValue = __webpack_require__(34), eq = __webpack_require__(12); -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - /** - * Assigns `value` to `key` of `object` if the existing value is not equivalent - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. + * This function is like `assignValue` except that it doesn't assign + * `undefined` values. * * @private * @param {Object} object The object to modify. * @param {string} key The key of the property to assign. * @param {*} value The value to assign. */ -function assignValue(object, key, value) { - var objValue = object[key]; - if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || +function assignMergeValue(object, key, value) { + if ((value !== undefined && !eq(object[key], value)) || (value === undefined && !(key in object))) { baseAssignValue(object, key, value); } } -module.exports = assignValue; +module.exports = assignMergeValue; /***/ }), -/* 52 */ +/* 59 */ /***/ (function(module, exports, __webpack_require__) { -var arrayPush = __webpack_require__(31), - isArray = __webpack_require__(0); +var arrayPush = __webpack_require__(32), + isArray = __webpack_require__(1); /** * The base implementation of `getAllKeys` and `getAllKeysIn` which uses @@ -3681,153 +4007,100 @@ module.exports = baseGetAllKeys; /***/ }), -/* 53 */ +/* 60 */ /***/ (function(module, exports, __webpack_require__) { -var baseIsEqualDeep = __webpack_require__(122), - isObjectLike = __webpack_require__(4); +/* WEBPACK VAR INJECTION */(function(module) {var root = __webpack_require__(0); -/** - * The base implementation of `_.isEqual` which supports partial comparisons - * and tracks traversed objects. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @param {boolean} bitmask The bitmask flags. - * 1 - Unordered comparison - * 2 - Partial comparison - * @param {Function} [customizer] The function to customize comparisons. - * @param {Object} [stack] Tracks traversed `value` and `other` objects. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - */ -function baseIsEqual(value, other, bitmask, customizer, stack) { - if (value === other) { - return true; - } - if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { - return value !== value && other !== other; - } - return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); -} - -module.exports = baseIsEqual; +/** Detect free variable `exports`. */ +var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; +/** Detect free variable `module`. */ +var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; -/***/ }), -/* 54 */ -/***/ (function(module, exports, __webpack_require__) { +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports = freeModule && freeModule.exports === freeExports; -var baseMatches = __webpack_require__(127), - baseMatchesProperty = __webpack_require__(128), - identity = __webpack_require__(36), - isArray = __webpack_require__(0), - property = __webpack_require__(205); +/** Built-in value references. */ +var Buffer = moduleExports ? root.Buffer : undefined, + allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined; /** - * The base implementation of `_.iteratee`. + * Creates a clone of `buffer`. * * @private - * @param {*} [value=_.identity] The value to convert to an iteratee. - * @returns {Function} Returns the iteratee. + * @param {Buffer} buffer The buffer to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Buffer} Returns the cloned buffer. */ -function baseIteratee(value) { - // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. - // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. - if (typeof value == 'function') { - return value; - } - if (value == null) { - return identity; - } - if (typeof value == 'object') { - return isArray(value) - ? baseMatchesProperty(value[0], value[1]) - : baseMatches(value); +function cloneBuffer(buffer, isDeep) { + if (isDeep) { + return buffer.slice(); } - return property(value); + var length = buffer.length, + result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); + + buffer.copy(result); + return result; } -module.exports = baseIteratee; +module.exports = cloneBuffer; +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(45)(module))) /***/ }), -/* 55 */ +/* 61 */ /***/ (function(module, exports, __webpack_require__) { -var isPrototype = __webpack_require__(22), - nativeKeys = __webpack_require__(181); - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; +var cloneArrayBuffer = __webpack_require__(35); /** - * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. + * Creates a clone of `typedArray`. * * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. + * @param {Object} typedArray The typed array to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned typed array. */ -function baseKeys(object) { - if (!isPrototype(object)) { - return nativeKeys(object); - } - var result = []; - for (var key in Object(object)) { - if (hasOwnProperty.call(object, key) && key != 'constructor') { - result.push(key); - } - } - return result; +function cloneTypedArray(typedArray, isDeep) { + var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; + return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); } -module.exports = baseKeys; +module.exports = cloneTypedArray; /***/ }), -/* 56 */ -/***/ (function(module, exports, __webpack_require__) { - -var baseGet = __webpack_require__(33), - baseSet = __webpack_require__(135), - castPath = __webpack_require__(19); +/* 62 */ +/***/ (function(module, exports) { /** - * The base implementation of `_.pickBy` without support for iteratee shorthands. + * Copies the values of `source` to `array`. * * @private - * @param {Object} object The source object. - * @param {string[]} paths The property paths to pick. - * @param {Function} predicate The function invoked per property. - * @returns {Object} Returns the new object. + * @param {Array} source The array to copy values from. + * @param {Array} [array=[]] The array to copy values to. + * @returns {Array} Returns `array`. */ -function basePickBy(object, paths, predicate) { +function copyArray(source, array) { var index = -1, - length = paths.length, - result = {}; + length = source.length; + array || (array = Array(length)); while (++index < length) { - var path = paths[index], - value = baseGet(object, path); - - if (predicate(value, path)) { - baseSet(result, castPath(path, object), value); - } + array[index] = source[index]; } - return result; + return array; } -module.exports = basePickBy; +module.exports = copyArray; /***/ }), -/* 57 */ +/* 63 */ /***/ (function(module, exports, __webpack_require__) { -var getNative = __webpack_require__(3); +var getNative = __webpack_require__(4); var defineProperty = (function() { try { @@ -3841,12 +4114,12 @@ module.exports = defineProperty; /***/ }), -/* 58 */ +/* 64 */ /***/ (function(module, exports, __webpack_require__) { -var SetCache = __webpack_require__(112), - arraySome = __webpack_require__(116), - cacheHas = __webpack_require__(140); +var SetCache = __webpack_require__(120), + arraySome = __webpack_require__(128), + cacheHas = __webpack_require__(154); /** Used to compose bitmasks for value comparisons. */ var COMPARE_PARTIAL_FLAG = 1, @@ -3930,7 +4203,7 @@ module.exports = equalArrays; /***/ }), -/* 59 */ +/* 65 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(global) {/** Detect free variable `global` from Node.js. */ @@ -3938,55 +4211,72 @@ var freeGlobal = typeof global == 'object' && global && global.Object === Object module.exports = freeGlobal; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(72))) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(79))) /***/ }), -/* 60 */ +/* 66 */ /***/ (function(module, exports, __webpack_require__) { -var arrayFilter = __webpack_require__(115), - stubArray = __webpack_require__(71); +var baseGetAllKeys = __webpack_require__(59), + getSymbols = __webpack_require__(37), + keys = __webpack_require__(44); -/** Used for built-in method references. */ -var objectProto = Object.prototype; +/** + * Creates an array of own enumerable property names and symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. + */ +function getAllKeys(object) { + return baseGetAllKeys(object, keys, getSymbols); +} -/** Built-in value references. */ -var propertyIsEnumerable = objectProto.propertyIsEnumerable; +module.exports = getAllKeys; + + +/***/ }), +/* 67 */ +/***/ (function(module, exports, __webpack_require__) { + +var arrayPush = __webpack_require__(32), + getPrototype = __webpack_require__(36), + getSymbols = __webpack_require__(37), + stubArray = __webpack_require__(78); /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeGetSymbols = Object.getOwnPropertySymbols; /** - * Creates an array of the own enumerable symbols of `object`. + * Creates an array of the own and inherited enumerable symbols of `object`. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of symbols. */ -var getSymbols = !nativeGetSymbols ? stubArray : function(object) { - if (object == null) { - return []; +var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { + var result = []; + while (object) { + arrayPush(result, getSymbols(object)); + object = getPrototype(object); } - object = Object(object); - return arrayFilter(nativeGetSymbols(object), function(symbol) { - return propertyIsEnumerable.call(object, symbol); - }); + return result; }; -module.exports = getSymbols; +module.exports = getSymbolsIn; /***/ }), -/* 61 */ +/* 68 */ /***/ (function(module, exports, __webpack_require__) { -var DataView = __webpack_require__(108), - Map = __webpack_require__(28), - Promise = __webpack_require__(110), - Set = __webpack_require__(111), - WeakMap = __webpack_require__(113), - baseGetTag = __webpack_require__(6), - toSource = __webpack_require__(67); +var DataView = __webpack_require__(116), + Map = __webpack_require__(29), + Promise = __webpack_require__(118), + Set = __webpack_require__(119), + WeakMap = __webpack_require__(121), + baseGetTag = __webpack_require__(9), + toSource = __webpack_require__(75); /** `Object#toString` result references. */ var mapTag = '[object Map]', @@ -4041,54 +4331,55 @@ module.exports = getTag; /***/ }), -/* 62 */ +/* 69 */ /***/ (function(module, exports, __webpack_require__) { -var isObject = __webpack_require__(2); +var baseCreate = __webpack_require__(132), + getPrototype = __webpack_require__(36), + isPrototype = __webpack_require__(38); /** - * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. + * Initializes an object clone. * * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` if suitable for strict - * equality comparisons, else `false`. + * @param {Object} object The object to clone. + * @returns {Object} Returns the initialized clone. */ -function isStrictComparable(value) { - return value === value && !isObject(value); +function initCloneObject(object) { + return (typeof object.constructor == 'function' && !isPrototype(object)) + ? baseCreate(getPrototype(object)) + : {}; } -module.exports = isStrictComparable; +module.exports = initCloneObject; /***/ }), -/* 63 */ +/* 70 */ /***/ (function(module, exports) { /** - * A specialized version of `matchesProperty` for source values suitable - * for strict equality comparisons, i.e. `===`. + * Converts `map` to its key-value pairs. * * @private - * @param {string} key The key of the property to get. - * @param {*} srcValue The value to match. - * @returns {Function} Returns the new spec function. + * @param {Object} map The map to convert. + * @returns {Array} Returns the key-value pairs. */ -function matchesStrictComparable(key, srcValue) { - return function(object) { - if (object == null) { - return false; - } - return object[key] === srcValue && - (srcValue !== undefined || (key in Object(object))); - }; +function mapToArray(map) { + var index = -1, + result = Array(map.size); + + map.forEach(function(value, key) { + result[++index] = [key, value]; + }); + return result; } -module.exports = matchesStrictComparable; +module.exports = mapToArray; /***/ }), -/* 64 */ +/* 71 */ /***/ (function(module, exports) { /** @@ -4109,10 +4400,10 @@ module.exports = overArg; /***/ }), -/* 65 */ +/* 72 */ /***/ (function(module, exports, __webpack_require__) { -var apply = __webpack_require__(114); +var apply = __webpack_require__(124); /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeMax = Math.max; @@ -4151,11 +4442,35 @@ module.exports = overRest; /***/ }), -/* 66 */ +/* 73 */ +/***/ (function(module, exports) { + +/** + * Converts `set` to an array of its values. + * + * @private + * @param {Object} set The set to convert. + * @returns {Array} Returns the values. + */ +function setToArray(set) { + var index = -1, + result = Array(set.size); + + set.forEach(function(value) { + result[++index] = value; + }); + return result; +} + +module.exports = setToArray; + + +/***/ }), +/* 74 */ /***/ (function(module, exports, __webpack_require__) { -var baseSetToString = __webpack_require__(136), - shortOut = __webpack_require__(188); +var baseSetToString = __webpack_require__(150), + shortOut = __webpack_require__(201); /** * Sets the `toString` method of `func` to return `string`. @@ -4171,7 +4486,7 @@ module.exports = setToString; /***/ }), -/* 67 */ +/* 75 */ /***/ (function(module, exports) { /** Used for built-in method references. */ @@ -4203,121 +4518,113 @@ module.exports = toSource; /***/ }), -/* 68 */ -/***/ (function(module, exports, __webpack_require__) { - -var baseHasIn = __webpack_require__(120), - hasPath = __webpack_require__(158); +/* 76 */ +/***/ (function(module, exports) { /** - * Checks if `path` is a direct or inherited property of `object`. + * This method returns the first argument it receives. * * @static + * @since 0.1.0 * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @returns {boolean} Returns `true` if `path` exists, else `false`. + * @category Util + * @param {*} value Any value. + * @returns {*} Returns `value`. * @example * - * var object = _.create({ 'a': _.create({ 'b': 2 }) }); - * - * _.hasIn(object, 'a'); - * // => true - * - * _.hasIn(object, 'a.b'); - * // => true + * var object = { 'a': 1 }; * - * _.hasIn(object, ['a', 'b']); + * console.log(_.identity(object) === object); * // => true - * - * _.hasIn(object, 'b'); - * // => false */ -function hasIn(object, path) { - return object != null && hasPath(object, path, baseHasIn); +function identity(value) { + return value; } -module.exports = hasIn; +module.exports = identity; /***/ }), -/* 69 */ +/* 77 */ /***/ (function(module, exports, __webpack_require__) { -var arrayLikeKeys = __webpack_require__(48), - baseKeys = __webpack_require__(55), - isArrayLike = __webpack_require__(14); +var MapCache = __webpack_require__(30); + +/** Error message constants. */ +var FUNC_ERROR_TEXT = 'Expected a function'; /** - * Creates an array of the own enumerable property names of `object`. + * Creates a function that memoizes the result of `func`. If `resolver` is + * provided, it determines the cache key for storing the result based on the + * arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is used as the map cache key. The `func` + * is invoked with the `this` binding of the memoized function. * - * **Note:** Non-object values are coerced to objects. See the - * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) - * for more details. + * **Note:** The cache is exposed as the `cache` property on the memoized + * function. Its creation may be customized by replacing the `_.memoize.Cache` + * constructor with one whose instances implement the + * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) + * method interface of `clear`, `delete`, `get`, `has`, and `set`. * * @static - * @since 0.1.0 * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. + * @since 0.1.0 + * @category Function + * @param {Function} func The function to have its output memoized. + * @param {Function} [resolver] The function to resolve the cache key. + * @returns {Function} Returns the new memoized function. * @example * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; + * var object = { 'a': 1, 'b': 2 }; + * var other = { 'c': 3, 'd': 4 }; * - * _.keys(new Foo); - * // => ['a', 'b'] (iteration order is not guaranteed) + * var values = _.memoize(_.values); + * values(object); + * // => [1, 2] * - * _.keys('hi'); - * // => ['0', '1'] - */ -function keys(object) { - return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); -} - -module.exports = keys; - - -/***/ }), -/* 70 */ -/***/ (function(module, exports, __webpack_require__) { - -var basePick = __webpack_require__(131), - flatRest = __webpack_require__(151); - -/** - * Creates an object composed of the picked `object` properties. + * values(other); + * // => [3, 4] * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The source object. - * @param {...(string|string[])} [paths] The property paths to pick. - * @returns {Object} Returns the new object. - * @example + * object.a = 2; + * values(object); + * // => [1, 2] * - * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * // Modify the result cache. + * values.cache.set(object, ['a', 'b']); + * values(object); + * // => ['a', 'b'] * - * _.pick(object, ['a', 'c']); - * // => { 'a': 1, 'c': 3 } + * // Replace `_.memoize.Cache`. + * _.memoize.Cache = WeakMap; */ -var pick = flatRest(function(object, paths) { - return object == null ? {} : basePick(object, paths); -}); +function memoize(func, resolver) { + if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { + throw new TypeError(FUNC_ERROR_TEXT); + } + var memoized = function() { + var args = arguments, + key = resolver ? resolver.apply(this, args) : args[0], + cache = memoized.cache; -module.exports = pick; + if (cache.has(key)) { + return cache.get(key); + } + var result = func.apply(this, args); + memoized.cache = cache.set(key, result) || cache; + return result; + }; + memoized.cache = new (memoize.Cache || MapCache); + return memoized; +} + +// Expose `MapCache`. +memoize.Cache = MapCache; + +module.exports = memoize; /***/ }), -/* 71 */ +/* 78 */ /***/ (function(module, exports) { /** @@ -4346,7 +4653,7 @@ module.exports = stubArray; /***/ }), -/* 72 */ +/* 79 */ /***/ (function(module, exports) { var g; @@ -4373,21 +4680,27 @@ module.exports = g; /***/ }), -/* 73 */ +/* 80 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_merge__ = __webpack_require__(15); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_merge___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash_merge__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_typedefs__ = __webpack_require__(79); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_typedefs___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__common_typedefs__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__scanner__ = __webpack_require__(101); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_image_wrapper__ = __webpack_require__(27); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_image_debug__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__analytics_result_collector__ = __webpack_require__(42); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__config_config__ = __webpack_require__(43); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__input_config_factory__ = __webpack_require__(84); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_isEqual__ = __webpack_require__(213); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_isEqual___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash_isEqual__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_lodash_merge__ = __webpack_require__(24); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_lodash_merge___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_lodash_merge__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_typedefs__ = __webpack_require__(86); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_typedefs___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2__common_typedefs__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__scanner__ = __webpack_require__(109); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_image_wrapper__ = __webpack_require__(26); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__common_image_debug__ = __webpack_require__(13); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__analytics_result_collector__ = __webpack_require__(81); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__config_config__ = __webpack_require__(49); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__input_camera_access__ = __webpack_require__(51); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__input_PixelCapture__ = __webpack_require__(92); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__input_Source__ = __webpack_require__(93); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__common_device__ = __webpack_require__(47); + @@ -4398,10 +4711,23 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -function _fromConfig(config) { - var scanner = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__scanner__["a" /* default */])(); + + + +function hasConfigChanged(currentConfig, newConfig, prop) { + if (!prop) { + return !__WEBPACK_IMPORTED_MODULE_0_lodash_isEqual___default()(currentConfig, newConfig); + } + return newConfig[prop] && !__WEBPACK_IMPORTED_MODULE_0_lodash_isEqual___default()(currentConfig[prop], newConfig[prop]); +} + +function fromConfig(pixelCapturer, config) { + var scanner = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__scanner__["a" /* default */])(pixelCapturer); + var source = pixelCapturer.getSource(); + var currentConfig = config; var pendingStart = null; var initialized = false; + var cancelRequested = false; return { addEventListener: function addEventListener(eventType, cb) { scanner.subscribe(eventType, cb); @@ -4422,119 +4748,122 @@ function _fromConfig(config) { scanner.start(); return Promise.resolve(true); } - pendingStart = new Promise(function (resolve, reject) { - scanner.init(config, function (error) { - if (error) { - console.log(error); - reject(error); - } - initialized = true; - scanner.start(); - resolve(); - pendingStart = null; - }); + pendingStart = scanner.init(currentConfig).then(function () { + initialized = true; + scanner.start(); + pendingStart = null; }); return pendingStart; }, stop: function stop() { + cancelRequested = true; scanner.stop(); initialized = false; return this; }, - toPromise: function toPromise() { - var _this = this; - - if (config.inputStream.type === 'LiveStream' || config.inputStream.type === 'VideoStream') { - var cancelRequested = false; - return { - cancel: function cancel() { - cancelRequested = true; - }, - - promise: new Promise(function (resolve, reject) { + detect: function detect() { + if (source.type === 'CAMERA' || source.type === 'VIDEO') { + cancelRequested = false; + return this.start().then(function () { + return new Promise(function (resolve, reject) { function onProcessed(result) { if (result && result.codeResult && result.codeResult.code) { scanner.stop(); scanner.unsubscribe("processed", onProcessed); + scanner.unsubscribe("stopped", onProcessed); resolve(result); } if (cancelRequested) { - scanner.stop(); scanner.unsubscribe("processed", onProcessed); + scanner.unsubscribe("stopped", onProcessed); reject("cancelled!"); } } scanner.subscribe("processed", onProcessed); - _this.start(); - }) - }; - } else { - return new Promise(function (resolve, reject) { - scanner.decodeSingle(config, function (result) { - if (result && result.codeResult && result.codeResult.code) { - return resolve(result); - } - return reject(result); + scanner.subscribe("stopped", onProcessed, true); }); }); + } else { + var pendingDecodeSingle = Promise.resolve(); + if (!initialized) { + pendingDecodeSingle = pendingDecodeSingle.then(scanner.init.bind(scanner, currentConfig)).then(function () { + initialized = true; + }); + } + return pendingDecodeSingle.then(scanner.decodeSingle.bind(scanner)); } }, registerResultCollector: function registerResultCollector(resultCollector) { scanner.registerResultCollector(resultCollector); }, getCanvas: function getCanvas() { - return scanner.canvas.dom.image; + return pixelCapturer.getCanvas(); + }, + applyConfig: function applyConfig(newConfig) { + var normalizedConfig = __WEBPACK_IMPORTED_MODULE_1_lodash_merge___default()({}, __WEBPACK_IMPORTED_MODULE_7__config_config__["a" /* default */], currentConfig, newConfig); + var wasRunning = scanner.isRunning(); + var promise = Promise.resolve(); + if (hasConfigChanged(currentConfig, normalizedConfig, "constraints")) { + console.log("constraints changed!", currentConfig.constraints, normalizedConfig.constraints); + promise = promise.then(function () { + scanner.pause(); + return source.applyConstraints(normalizedConfig.constraints); + }); + } + if (hasConfigChanged(currentConfig, normalizedConfig)) { + console.log("config changed!"); + promise = promise.then(function () { + return scanner.applyConfig(normalizedConfig); + }); + if (wasRunning) { + promise = promise.then(scanner.start.bind(scanner)); + } + } + currentConfig = normalizedConfig; + return promise; + }, + getSource: function getSource() { + return pixelCapturer.getSource(); } }; } function _fromSource(config, source) { - var inputConfig = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - - config = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_7__input_config_factory__["a" /* createConfigFromSource */])(config, inputConfig, source); - return _fromConfig(config); -} - -function setConfig() { - var configuration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - var _merge2; - - var key = arguments[1]; - var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - - var mergedConfig = __WEBPACK_IMPORTED_MODULE_0_lodash_merge___default()({}, configuration, (_merge2 = {}, _merge2[key] = config, _merge2)); - return createApi(mergedConfig); + var pixelCapturer = __WEBPACK_IMPORTED_MODULE_9__input_PixelCapture__["a" /* fromSource */](source, { target: config.target }); + return fromConfig(pixelCapturer, config); } function createApi() { - var configuration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : __WEBPACK_IMPORTED_MODULE_6__config_config__["a" /* default */]; - return { - fromSource: function fromSource(src, inputConfig) { - return _fromSource(configuration, src, inputConfig); + fromImage: function fromImage(options) { + var config = __WEBPACK_IMPORTED_MODULE_1_lodash_merge___default()({}, __WEBPACK_IMPORTED_MODULE_7__config_config__["a" /* default */], options); + return __WEBPACK_IMPORTED_MODULE_10__input_Source__["a" /* fromImage */](config.constraints, { + target: config.target, + scope: __WEBPACK_IMPORTED_MODULE_10__input_Source__["b" /* Scope */].INTERNAL + }).then(_fromSource.bind(null, config)); }, - fromConfig: function fromConfig(conf) { - return _fromConfig(__WEBPACK_IMPORTED_MODULE_0_lodash_merge___default()({}, configuration, conf)); + fromCamera: function fromCamera(options) { + var config = __WEBPACK_IMPORTED_MODULE_1_lodash_merge___default()({}, __WEBPACK_IMPORTED_MODULE_7__config_config__["a" /* default */], options); + return __WEBPACK_IMPORTED_MODULE_10__input_Source__["c" /* fromCamera */](config.constraints, { + target: config.target, + scope: __WEBPACK_IMPORTED_MODULE_10__input_Source__["b" /* Scope */].INTERNAL + }).then(_fromSource.bind(null, config)); }, - decoder: function decoder(conf) { - return setConfig(configuration, "decoder", conf); - }, - locator: function locator(conf) { - return setConfig(configuration, "locator", conf); - }, - throttle: function throttle(timeInMs) { - return setConfig(configuration, "frequency", 1000 / parseInt(timeInMs)); - }, - config: function config(conf) { - return createApi(__WEBPACK_IMPORTED_MODULE_0_lodash_merge___default()({}, configuration, conf)); + fromSource: function fromSource(src, inputConfig) { + return _fromSource(configuration, src, inputConfig); }, - ImageWrapper: __WEBPACK_IMPORTED_MODULE_3__common_image_wrapper__["a" /* default */], - ImageDebug: __WEBPACK_IMPORTED_MODULE_4__common_image_debug__["a" /* default */], - ResultCollector: __WEBPACK_IMPORTED_MODULE_5__analytics_result_collector__["a" /* default */], + CameraAccess: __WEBPACK_IMPORTED_MODULE_8__input_camera_access__["a" /* default */], + ImageWrapper: __WEBPACK_IMPORTED_MODULE_4__common_image_wrapper__["a" /* default */], + ImageDebug: __WEBPACK_IMPORTED_MODULE_5__common_image_debug__["a" /* default */], + ResultCollector: __WEBPACK_IMPORTED_MODULE_6__analytics_result_collector__["a" /* default */], _worker: { - createScanner: __WEBPACK_IMPORTED_MODULE_2__scanner__["a" /* default */] + createScanner: __WEBPACK_IMPORTED_MODULE_3__scanner__["a" /* default */] + }, + Orientation: { + PORTRAIT: __WEBPACK_IMPORTED_MODULE_11__common_device__["a" /* PORTRAIT */], + LANDSCAPE: __WEBPACK_IMPORTED_MODULE_11__common_device__["b" /* LANDSCAPE */], + SQUARE: __WEBPACK_IMPORTED_MODULE_11__common_device__["c" /* SQUARE */] } }; } @@ -4542,13 +4871,74 @@ function createApi() { /* harmony default export */ __webpack_exports__["default"] = createApi(); /***/ }), -/* 74 */ +/* 81 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common_image_debug__ = __webpack_require__(13); + + +function contains(codeResult, list) { + if (list) { + return list.some(function (item) { + return Object.keys(item).every(function (key) { + return item[key] === codeResult[key]; + }); + }); + } + return false; +} + +function passesFilter(codeResult, filter) { + if (typeof filter === 'function') { + return filter(codeResult); + } + return true; +} + +/* harmony default export */ __webpack_exports__["a"] = { + create: function create(config) { + var canvas = document.createElement("canvas"), + ctx = canvas.getContext("2d"), + results = [], + capacity = config.capacity || 20, + capture = config.capture === true; + + function matchesConstraints(codeResult) { + return capacity && codeResult && !contains(codeResult, config.blacklist) && passesFilter(codeResult, config.filter); + } + + return { + addResult: function addResult(data, imageSize, codeResult) { + var result = {}; + + if (matchesConstraints(codeResult)) { + capacity--; + result.codeResult = codeResult; + if (capture) { + canvas.width = imageSize.x; + canvas.height = imageSize.y; + __WEBPACK_IMPORTED_MODULE_0__common_image_debug__["a" /* default */].drawImage(data, imageSize, ctx); + result.frame = canvas.toDataURL(); + } + results.push(result); + } + }, + getResults: function getResults() { + return results; + } + }; + } +}; + +/***/ }), +/* 82 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; var vec2 = { - clone: __webpack_require__(9), - dot: __webpack_require__(46) + clone: __webpack_require__(10), + dot: __webpack_require__(54) }; /** @@ -4618,31 +5008,7 @@ var vec2 = { }; /***/ }), -/* 75 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -var hasWindow = typeof window !== 'undefined'; -var windowRef = hasWindow ? window : {}; - -var windowObjects = ["MediaStream", "HTMLImageElement", "HTMLVideoElement", "HTMLCanvasElement", "FileList", "File", "URL"]; - -var DOMHelper = windowObjects.reduce(function (result, obj) { - var _extends2; - - return _extends({}, result, (_extends2 = {}, _extends2[obj] = obj in windowRef ? windowRef[obj] : function () {}, _extends2)); -}, {}); - -DOMHelper.setObject = function (key, value) { - DOMHelper[key] = value; -}; - -/* harmony default export */ __webpack_exports__["a"] = DOMHelper; - -/***/ }), -/* 76 */ +/* 83 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -4743,7 +5109,7 @@ function createEventedElement() { }; /***/ }), -/* 77 */ +/* 84 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -4765,7 +5131,7 @@ function getUserMedia(constraints) { } /***/ }), -/* 78 */ +/* 85 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -4855,7 +5221,7 @@ SubImage.prototype.updateFrom = function (from) { /* harmony default export */ __webpack_exports__["a"] = SubImage; /***/ }), -/* 79 */ +/* 86 */ /***/ (function(module, exports) { /* @@ -4910,18 +5276,20 @@ if (typeof Object.assign !== 'function') { } /***/ }), -/* 80 */ +/* 87 */ /***/ (function(module, exports) { module.exports = { - inputStream: { - name: "Live", - type: "LiveStream", - constraints: { - width: 640, - height: 480, - // aspectRatio: 640/480, // optional - facingMode: "environment" }, + numOfWorkers: 2, + locate: true, + target: '#interactive.viewport', + frequency: 5, + constraints: { + width: 640, + height: 640, + // aspectRatio: 640/480, // optional + facingMode: "environment" }, + detector: { area: { top: "0%", right: "0%", @@ -4930,8 +5298,6 @@ module.exports = { }, singleChannel: false // true: only the red color-channel is read }, - locate: true, - numOfWorkers: 2, decoder: { readers: ['code_128_reader'], debug: { @@ -4962,23 +5328,25 @@ module.exports = { }; /***/ }), -/* 81 */ +/* 88 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__bresenham__ = __webpack_require__(82); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_image_debug__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__reader_code_128_reader__ = __webpack_require__(93); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__reader_ean_reader__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__reader_code_39_reader__ = __webpack_require__(45); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__reader_code_39_vin_reader__ = __webpack_require__(94); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__reader_codabar_reader__ = __webpack_require__(92); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__reader_upc_reader__ = __webpack_require__(100); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__reader_ean_8_reader__ = __webpack_require__(97); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__reader_ean_2_reader__ = __webpack_require__(95); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__reader_ean_5_reader__ = __webpack_require__(96); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__reader_upc_e_reader__ = __webpack_require__(99); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__reader_i2of5_reader__ = __webpack_require__(98); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__bresenham__ = __webpack_require__(89); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_image_debug__ = __webpack_require__(13); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__reader_code_128_reader__ = __webpack_require__(100); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__reader_ean_reader__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__reader_code_39_reader__ = __webpack_require__(53); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__reader_code_39_vin_reader__ = __webpack_require__(101); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__reader_codabar_reader__ = __webpack_require__(99); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__reader_upc_reader__ = __webpack_require__(108); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__reader_ean_8_reader__ = __webpack_require__(105); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__reader_ean_2_reader__ = __webpack_require__(103); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__reader_ean_5_reader__ = __webpack_require__(104); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__reader_upc_e_reader__ = __webpack_require__(107); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__reader_i2of5_reader__ = __webpack_require__(106); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__reader_2of5_reader__ = __webpack_require__(98); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__reader_code_93_reader__ = __webpack_require__(102); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; @@ -4995,6 +5363,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol + + var READERS = { code_128_reader: __WEBPACK_IMPORTED_MODULE_2__reader_code_128_reader__["a" /* default */], ean_reader: __WEBPACK_IMPORTED_MODULE_3__reader_ean_reader__["a" /* default */], @@ -5006,10 +5376,12 @@ var READERS = { codabar_reader: __WEBPACK_IMPORTED_MODULE_6__reader_codabar_reader__["a" /* default */], upc_reader: __WEBPACK_IMPORTED_MODULE_7__reader_upc_reader__["a" /* default */], upc_e_reader: __WEBPACK_IMPORTED_MODULE_11__reader_upc_e_reader__["a" /* default */], - i2of5_reader: __WEBPACK_IMPORTED_MODULE_12__reader_i2of5_reader__["a" /* default */] + i2of5_reader: __WEBPACK_IMPORTED_MODULE_12__reader_i2of5_reader__["a" /* default */], + '2of5_reader': __WEBPACK_IMPORTED_MODULE_13__reader_2of5_reader__["a" /* default */], + code_93_reader: __WEBPACK_IMPORTED_MODULE_14__reader_code_93_reader__["a" /* default */] }; /* harmony default export */ __webpack_exports__["a"] = { - create: function create(config, inputImageWrapper) { + create: function create(config) { var _canvas = { ctx: { frequency: null, @@ -5118,7 +5490,7 @@ var READERS = { * @param {Array} line * @param {Number} angle */ - function getExtendedLine(line, angle, ext) { + function getExtendedLine(inputImageWrapper, line, angle, ext) { function extendLine(amount) { var extension = { y: amount * Math.sin(angle), @@ -5150,7 +5522,7 @@ var READERS = { }]; } - function tryDecode(line) { + function tryDecode(inputImageWrapper, line) { var result = null, i, barcodeLine = __WEBPACK_IMPORTED_MODULE_0__bresenham__["a" /* default */].getBarcodeLine(inputImageWrapper, line[0], line[1]); @@ -5185,7 +5557,7 @@ var READERS = { * @param {Array} line * @param {Number} lineAngle */ - function tryDecodeBruteForce(box, line, lineAngle) { + function tryDecodeBruteForce(inputImageWrapper, box, line, lineAngle) { var sideLength = Math.sqrt(Math.pow(box[1][0] - box[0][0], 2) + Math.pow(box[1][1] - box[0][1], 2)), i, slices = 16, @@ -5207,7 +5579,7 @@ var READERS = { line[1].y += extension.x; line[1].x -= extension.y; - result = tryDecode(line); + result = tryDecode(inputImageWrapper, line); } return result; } @@ -5222,7 +5594,7 @@ var READERS = { * @param {Object} box The area to search in * @returns {Object} the result {codeResult, line, angle, pattern, threshold} */ - function _decodeFromBoundingBox(box) { + function decodeFromBoundingBox(inputImageWrapper, box) { var line, lineAngle, ctx = _canvas.ctx.overlay, @@ -5238,14 +5610,14 @@ var READERS = { line = getLine(box); lineLength = getLineLength(line); lineAngle = Math.atan2(line[1].y - line[0].y, line[1].x - line[0].x); - line = getExtendedLine(line, lineAngle, Math.floor(lineLength * 0.1)); + line = getExtendedLine(inputImageWrapper, line, lineAngle, Math.floor(lineLength * 0.1)); if (line === null) { return null; } - result = tryDecode(line); + result = tryDecode(inputImageWrapper, line); if (result === null) { - result = tryDecodeBruteForce(box, line, lineAngle); + result = tryDecodeBruteForce(inputImageWrapper, box, line, lineAngle); } if (result === null) { @@ -5266,10 +5638,7 @@ var READERS = { } return { - decodeFromBoundingBox: function decodeFromBoundingBox(box) { - return _decodeFromBoundingBox(box); - }, - decodeFromBoundingBoxes: function decodeFromBoundingBoxes(boxes) { + decodeFromBoundingBoxes: function decodeFromBoundingBoxes(inputImageWrapper, boxes) { var i, result, barcodes = [], @@ -5277,7 +5646,7 @@ var READERS = { for (i = 0; i < boxes.length; i++) { var box = boxes[i]; - result = _decodeFromBoundingBox(box) || {}; + result = decodeFromBoundingBox(inputImageWrapper, box) || {}; result.box = box; if (multiple) { @@ -5303,7 +5672,7 @@ var READERS = { }; /***/ }), -/* 82 */ +/* 89 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -5506,304 +5875,617 @@ Bresenham.debug = { /* harmony default export */ __webpack_exports__["a"] = Bresenham; /***/ }), -/* 83 */ +/* 90 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_pick__ = __webpack_require__(70); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_pick___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash_pick__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_mediaDevices__ = __webpack_require__(77); -/* unused harmony export pickConstraints */ - - - +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_clone__ = __webpack_require__(208); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_clone___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash_clone__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_device__ = __webpack_require__(47); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__camera_access__ = __webpack_require__(51); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_utils__ = __webpack_require__(27); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__SourceInterface__ = __webpack_require__(50); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__SourceScope__ = __webpack_require__(28); +/* harmony export (immutable) */ __webpack_exports__["a"] = fromCamera; + + + + + + + + +var ConstraintPresets = [{ + width: 720, + height: 1280 +}, { + width: 540, + height: 960 +}, { + width: 600, + height: 800 +}, { + width: 480, + height: 640 +}, { + width: 1280, + height: 720 +}, { + width: 960, + height: 540 +}, { + width: 800, + height: 600 +}, { + width: 640, + height: 480 +}, { + width: 1280, + height: 1280 +}, { + width: 1080, + height: 1080 +}, { + width: 960, + height: 960 +}, { + width: 800, + height: 800 +}, { + width: 640, + height: 640 +}].map(function (preset) { + return Object.assign({}, preset, { aspectRatio: preset.width / preset.height }); +}); -var facingMatching = { - "user": /front/i, - "environment": /back/i -}; +function getFilter(aspectRatio) { + if (aspectRatio === 1) { + return function (pre) { + return pre.aspectRatio === aspectRatio; + }; + } else if (aspectRatio > 1) { + return function (pre) { + return pre.aspectRatio > 1; + }; + } + return function (pre) { + return pre.aspectRatio < 1; + }; +} -var streamRef; +function resolveMinWidthToAdvanced(_ref) { + var aspectRatio = _ref.aspectRatio, + minPixels = _ref.minPixels; -function waitForVideo(video) { - return new Promise(function (resolve, reject) { - var attempts = 10; + return [].concat(ConstraintPresets).filter(getFilter(aspectRatio)).map(function (pre) { + return { + error: Math.abs(pre.width * pre.height - minPixels), + pre: pre + }; + }).sort(function (_ref2, _ref3) { + var errorA = _ref2.error; + var errorB = _ref3.error; - function checkVideo() { - if (attempts > 0) { - if (video.videoWidth > 0 && video.videoHeight > 0) { - if (true) { - console.log(video.videoWidth + "px x " + video.videoHeight + "px"); - } - resolve(); - } else { - window.setTimeout(checkVideo, 500); - } - } else { - reject('Unable to play video stream. Is webcam working?'); - } - attempts--; + if (errorB > errorA) { + return -1; } - checkVideo(); + if (errorB < errorA) { + return 1; + } + return 0; + }).map(function (_ref4) { + var pre = _ref4.pre; + return pre; }); } -/** - * Tries to attach the camera-stream to a given video-element - * and calls the callback function when the content is ready - * @param {Object} constraints - * @param {Object} video - */ -function initCamera(video, constraints) { - return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mediaDevices__["a" /* getUserMedia */])(constraints).then(function (stream) { - return new Promise(function (resolve) { - streamRef = stream; - video.setAttribute("autoplay", 'true'); - video.srcObject = stream; - video.addEventListener('loadedmetadata', function () { - video.play(); - resolve(); - }); - }); - }).then(waitForVideo.bind(null, video)); +function getOrCreateVideo(target) { + var $viewport = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__common_utils__["a" /* getViewport */])(target); + if ($viewport) { + var $video = $viewport.querySelector("video"); + if (!$video) { + $video = document.createElement("video"); + $viewport.appendChild($video); + } + return $video; + } + return document.createElement("video"); } -function deprecatedConstraints(videoConstraints) { - var normalized = __WEBPACK_IMPORTED_MODULE_0_lodash_pick___default()(videoConstraints, ["width", "height", "facingMode", "aspectRatio", "deviceId"]); +function constraintToNumber(constraint) { + if (!constraint) { + return null; + } + if (typeof constraint === 'number') { + return constraint; + } + var ideal = constraint.ideal, + exact = constraint.exact, + min = constraint.min, + max = constraint.max; - if (typeof videoConstraints.minAspectRatio !== 'undefined' && videoConstraints.minAspectRatio > 0) { - normalized.aspectRatio = videoConstraints.minAspectRatio; - console.log("WARNING: Constraint 'minAspectRatio' is deprecated; Use 'aspectRatio' instead"); + if (typeof exact !== 'undefined') { + return exact; } - if (typeof videoConstraints.facing !== 'undefined') { - normalized.facingMode = videoConstraints.facing; - console.log("WARNING: Constraint 'facing' is deprecated. Use 'facingMode' instead'"); + if (typeof ideal !== 'undefined') { + return ideal; } - return normalized; + if (typeof min !== 'undefined') { + return min; + } + if (typeof max !== 'undefined') { + return max; + } + + return null; } -function pickConstraints(videoConstraints) { - var normalizedConstraints = { - audio: false, - video: deprecatedConstraints(videoConstraints) - }; +function adjustWithZoom(videoConstraints) { + var constraints = __WEBPACK_IMPORTED_MODULE_0_lodash_clone___default()(videoConstraints); + var orientation = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__common_device__["d" /* determineOrientation */])(); - if (normalizedConstraints.video.deviceId && normalizedConstraints.video.facingMode) { - delete normalizedConstraints.video.facingMode; + var zoom = constraintToNumber(constraints.zoom) || 1, + width = constraintToNumber(constraints.width), + height = constraintToNumber(constraints.height), + aspectRatio = constraintToNumber(constraints.aspectRatio) || width / height; + + if (constraints[orientation]) { + zoom = constraintToNumber(constraints[orientation].zoom) || zoom; + width = constraintToNumber(constraints[orientation].width) || width; + height = constraintToNumber(constraints[orientation].height) || height; + aspectRatio = constraintToNumber(constraints[orientation].aspectRatio) || width / height; } - return Promise.resolve(normalizedConstraints); + + if (zoom > 1) { + width = Math.floor(width * zoom); + height = Math.floor(height * zoom); + } + + delete constraints.zoom; + delete constraints.orientation; + delete constraints.landscape; + delete constraints.portrait; + + var advanced = resolveMinWidthToAdvanced({ minPixels: width * height, aspectRatio: aspectRatio }); + return { + zoom: zoom, + video: Object.assign({}, constraints, { + width: { ideal: advanced[0].width }, + height: { ideal: advanced[0].height }, + aspectRatio: { exact: advanced[0].aspectRatio || aspectRatio }, + advanced: advanced + }) + }; } -function enumerateVideoDevices() { - return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_mediaDevices__["b" /* enumerateDevices */])().then(function (devices) { - return devices.filter(function (device) { - return device.kind === 'videoinput'; +function fromCamera(constraints) { + var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + target = _ref5.target, + _ref5$scope = _ref5.scope, + scope = _ref5$scope === undefined ? __WEBPACK_IMPORTED_MODULE_5__SourceScope__["a" /* Scope */].EXTERNAL : _ref5$scope; + + var _adjustWithZoom = adjustWithZoom(constraints), + videoConstraints = _adjustWithZoom.video, + zoom = _adjustWithZoom.zoom; + + var video = getOrCreateVideo(target); + return __WEBPACK_IMPORTED_MODULE_2__camera_access__["a" /* default */].request(video, videoConstraints).then(function (mediastream) { + var track = mediastream.getVideoTracks()[0]; + return Object.assign(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__SourceInterface__["a" /* generateSourceInterface */])(), { + type: "CAMERA", + getDimensions: function getDimensions() { + var viewport = { + x: 0, + y: 0, + width: video.videoWidth, + height: video.videoHeight + }; + if (zoom > 1) { + viewport.width = Math.floor(video.videoWidth / zoom); + viewport.height = Math.floor(video.videoHeight / zoom); + viewport.x = Math.floor((video.videoWidth - viewport.width) / 2); + viewport.y = Math.floor((video.videoHeight - viewport.height) / 2); + } + + return { + viewport: viewport, + canvas: { + width: viewport.width, // AR + height: viewport.height } + }; + }, + getConstraints: function getConstraints() { + return videoConstraints; + }, + getDrawable: function getDrawable() { + return video; + }, + applyConstraints: function applyConstraints(newConstraints) { + track.stop(); + constraints = newConstraints; + var adjustment = adjustWithZoom(constraints); + videoConstraints = adjustment.video; + zoom = adjustment.zoom; + return __WEBPACK_IMPORTED_MODULE_2__camera_access__["a" /* default */].request(video, videoConstraints).then(function (stream) { + mediastream = stream; + track = mediastream.getVideoTracks()[0]; + }); + }, + getLabel: function getLabel() { + return track.label; + }, + stop: function stop() { + track.stop(); + }, + waitUntilReady: function waitUntilReady() { + if (track.readyState === "live") { + return Promise.resolve(); + } + return this.applyConstraints(constraints); + }, + getScope: function getScope() { + return scope; + } }); }); } -/* harmony default export */ __webpack_exports__["a"] = { - request: function request(video, videoConstraints) { - return pickConstraints(videoConstraints).then(initCamera.bind(null, video)); - }, - release: function release() { - var tracks = streamRef && streamRef.getVideoTracks(); - if (tracks && tracks.length) { - tracks[0].stop(); - } - streamRef = null; - }, - enumerateVideoDevices: enumerateVideoDevices, - getActiveStreamLabel: function getActiveStreamLabel() { - if (streamRef) { - var tracks = streamRef.getVideoTracks(); - if (tracks && tracks.length) { - return tracks[0].label; - } - } - } -}; - /***/ }), -/* 84 */ +/* 91 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_isEmpty__ = __webpack_require__(199); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_isEmpty___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash_isEmpty__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_lodash_omitBy__ = __webpack_require__(203); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_lodash_omitBy___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_lodash_omitBy__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_lodash_pick__ = __webpack_require__(70); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_lodash_pick___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_lodash_pick__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_lodash_merge__ = __webpack_require__(15); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_lodash_merge___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_lodash_merge__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_dom_helper__ = __webpack_require__(75); -/* harmony export (immutable) */ __webpack_exports__["a"] = createConfigFromSource; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__exif_helper__ = __webpack_require__(94); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__SourceInterface__ = __webpack_require__(50); +/* harmony export (immutable) */ __webpack_exports__["a"] = fromImage; +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; +var ImageSource = function (_Source) { + _inherits(ImageSource, _Source); + function ImageSource() { + _classCallCheck(this, ImageSource); -var isDataURL = { regex: /^\s*data:([a-z]+\/[a-z0-9\-\+]+(;[a-z\-]+\=[a-z0-9\-]+)?)?(;base64)?,[a-z0-9\!\$\&\'\,\(\)\*\+\,\;\=\-\.\_\~\:\@\/\?\%\s]*\s*$/i }, - // eslint-disable-line max-len -isBlobURL = { regex: /^\s*blob:(.*)$/i }, - isMediaURL = { regex: /^(?:(?:http[s]?|ftp):\/)?\/?(?:(?:[^:\/\s]+)(?:(?:\/\w+)*\/))?([\w\-]+\.([^#?\s]+))(?:.*)?(?:#[\w\-]+)?$/i }, - // eslint-disable-line max-len -isImageExt = { regex: /(jpe?g|png|gif|tiff)(?:\s+|$)/i }, - isVideoExt = { regex: /(webm|ogg|mp4|m4v)/i }; - -function createConfigFromSource(config, sourceConfig, source) { - if (source instanceof __WEBPACK_IMPORTED_MODULE_4__common_dom_helper__["a" /* default */].MediaStream) { - return createConfigForStream(config, sourceConfig, { srcObject: source }); - } else if (source instanceof __WEBPACK_IMPORTED_MODULE_4__common_dom_helper__["a" /* default */].HTMLImageElement) { - throw new Error('Source "HTMLImageElement": not yet supported'); - // return createConfigForImage(config, inputConfig, {image: source}); - } else if (source instanceof __WEBPACK_IMPORTED_MODULE_4__common_dom_helper__["a" /* default */].HTMLVideoElement) { - throw new Error('Source "HTMLVideoElement": not yet supported'); - // return createConfigForVideo(config, inputConfig, {video: source}); - } else if (source instanceof __WEBPACK_IMPORTED_MODULE_4__common_dom_helper__["a" /* default */].HTMLCanvasElement) { - return createConfigForCanvas(config, sourceConfig, { canvas: source }); - } else if (source instanceof __WEBPACK_IMPORTED_MODULE_4__common_dom_helper__["a" /* default */].FileList) { - if (source.length > 0) { - return createConfigForFile(config, sourceConfig, source[0]); - } - } else if (source instanceof __WEBPACK_IMPORTED_MODULE_4__common_dom_helper__["a" /* default */].File) { - return createConfigForFile(config, sourceConfig, source); - } else if (typeof source === 'string') { - return createConfigForString(config, sourceConfig, source); - } else if ((typeof source === 'undefined' ? 'undefined' : _typeof(source)) === 'object' && (typeof source.constraints !== 'undefined' || typeof source.area !== 'undefined')) { - return createConfigForLiveStream(config, source); - } else { - throw new Error("No source given!"); + var _this = _possibleConstructorReturn(this, _Source.call(this, "IMAGE")); + + _this._$image = null; + _this._src = null; + _this.tags = null; + _this.colorChannels = 3; + return _this; } -} -function createConfigForImage(config, source) { - var inputConfig = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + ImageSource.prototype.applyConstraints = function applyConstraints(newConstraints) { + var _this2 = this; - var staticImageConfig = { - inputStream: __WEBPACK_IMPORTED_MODULE_3_lodash_merge___default()({ - type: "ImageStream", - sequence: false, - size: 800 - }, source), - numOfWorkers: true && config.debug ? 0 : 1 + this.constraints = newConstraints; + this.colorChannels = this.constraints.channels || this.colorChannels; + return this._applyInput(this.constraints.src)._loadResource().then(function () { + return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__exif_helper__["a" /* findTagsInObjectURL */])(_this2._src, ['orientation']); + }).then(function (tags) { + _this2.tags = tags; + }).then(this._determineDimensions.bind(this)).then(function () { + return _this2; + }); }; - return __WEBPACK_IMPORTED_MODULE_3_lodash_merge___default()(config, staticImageConfig, { numOfWorkers: typeof config.numOfWorkers === 'number' && config.numOfWorkers > 0 ? 1 : 0 }, { inputStream: __WEBPACK_IMPORTED_MODULE_1_lodash_omitBy___default()(__WEBPACK_IMPORTED_MODULE_2_lodash_pick___default()(config.inputStream, ['size']), __WEBPACK_IMPORTED_MODULE_0_lodash_isEmpty___default.a) }, { inputStream: inputConfig }); -} -function createConfigForMimeType(config, inputConfig, _ref) { - var src = _ref.src, - mime = _ref.mime; + ImageSource.prototype._loadResource = function _loadResource() { + var _this3 = this; - var _ref2 = mime.match(/^(video|image)\/(.*)$/i) || [], - type = _ref2[1]; + return new Promise(function (resolve, reject) { + if (_this3._src || !_this3._$image.complete) { + _this3._$image.addEventListener('load', resolve, false); + _this3._$image.addEventListener('error', reject, false); + if (_this3._src) { + console.log('Setting src = ' + _this3._src); + _this3._$image.src = _this3._src; + } + } else { + return resolve(); + } + }); + }; - if (type === 'video') { - return createConfigForVideo(config, { src: src }, inputConfig); - } else if (type === 'image') { - return createConfigForImage(config, { src: src }, inputConfig); - } - throw new Error('Source with mimetype: "' + type + '" not supported'); + ImageSource.prototype._applyInput = function _applyInput(input) { + if (typeof input === 'string') { + // data or url, or queryString + this._$image = new Image(); + this._src = input; + } else if (input instanceof HTMLImageElement) { + this._$image = input; + } else if (input instanceof File) { + this._$image = new Image(); + this._src = URL.createObjectURL(input); + } else { + throw new Error("fromImage needs a src, HTMLImageElement or File"); + } + return this; + }; + + ImageSource.prototype._determineDimensions = function _determineDimensions() { + var width = this._$image.naturalWidth; + var height = this._$image.naturalHeight; + var desiredWidth = this.constraints.width; + if (this.tags && this.tags.orientation) { + switch (this.tags.orientation) { + case 6: + case 8: + width = this._$image.naturalHeight; + height = this._$image.naturalWidth; + } + } + + var imageAR = width / height; + var calculatedWidth = imageAR > 1 ? desiredWidth : Math.floor(imageAR * desiredWidth); + var calculatedHeight = imageAR > 1 ? Math.floor(1 / imageAR * desiredWidth) : desiredWidth; + + this._dimensions = { + viewport: { + width: width, // AR + height: height, // AR + x: 0, // AR + y: 0 }, + canvas: { + width: calculatedWidth, // AR + height: calculatedHeight } + }; + }; + + ImageSource.prototype.getDimensions = function getDimensions() { + return this._dimensions; + }; + + ImageSource.prototype.getDrawable = function getDrawable() { + return this._$image; + }; + + ImageSource.prototype.getLabel = function getLabel() { + return this._$image.src; + }; + + return ImageSource; +}(__WEBPACK_IMPORTED_MODULE_1__SourceInterface__["b" /* Source */]); + +function fromImage() { + var constraints = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { width: 800, height: 800, channels: 3 }; + + var imageSource = new ImageSource(); + return imageSource.applyConstraints(constraints); } -function createConfigForFile(config, inputConfig, file) { - var src = __WEBPACK_IMPORTED_MODULE_4__common_dom_helper__["a" /* default */].URL.createObjectURL(file); - return createConfigForMimeType(config, inputConfig, { - src: src, - mime: file.type - }); +/***/ }), +/* 92 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common_cv_utils__ = __webpack_require__(25); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_utils__ = __webpack_require__(27); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_buffers__ = __webpack_require__(46); +/* harmony export (immutable) */ __webpack_exports__["a"] = fromSource; + + + + + +var TO_RADIANS = Math.PI / 180; + +function adjustCanvasSize(input, canvas) { + if (input instanceof HTMLVideoElement) { + if (canvas.height !== input.videoHeight || canvas.width !== input.videoWidth) { + console.log('adjusting canvas size', input.videoHeight, input.videoWidth); + canvas.height = input.videoHeight; + canvas.width = input.videoWidth; + return true; + } + return false; + } else if (typeof input.width !== 'undefined') { + if (canvas.height !== input.height || canvas.width !== input.width) { + console.log('adjusting canvas size', input.height, input.width); + canvas.height = input.height; + canvas.width = input.width; + return true; + } + return false; + } else { + throw new Error('Not a video element!'); + } } -function createConfigForString(config) { - var inputConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var source = arguments[2]; +function getOrCreateCanvas(source, target) { + var $viewport = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__common_utils__["a" /* getViewport */])(target); + var $canvas = null; + if ($viewport) { + $canvas = $viewport.querySelector("canvas.imgBuffer"); + } - var _ref3 = source.match(isDataURL.regex) || [], - mime = _ref3[1]; + if (!$canvas) { + $canvas = document.createElement("canvas"); + $canvas.className = "imgBuffer"; + if ($viewport && source.type === "IMAGE") { + $viewport.appendChild($canvas); + } + } + return $canvas; +} - if (mime) { - return createConfigForMimeType(config, inputConfig, { src: source, mime: mime }); +function drawImage(canvasSize, ctx, source, drawable) { + var drawAngle = 0; + if (source.type === 'IMAGE') { + if (source.tags && source.tags.orientation) { + switch (source.tags.orientation) { + case 6: + drawAngle = 90 * TO_RADIANS; + break; + case 8: + drawAngle = -90 * TO_RADIANS; + break; + } + } } - var blobURL = source.match(isBlobURL.regex); - if (blobURL) { - throw new Error('Source "objectURL": not supported'); + + for (var _len = arguments.length, drawImageArgs = Array(_len > 4 ? _len - 4 : 0), _key = 4; _key < _len; _key++) { + drawImageArgs[_key - 4] = arguments[_key]; } - var _ref4 = source.match(isMediaURL.regex) || [], - ext = _ref4[2]; + var dWidth = drawImageArgs[6], + dHeight = drawImageArgs[7]; - if (ext) { - return createConfigForMediaExtension(config, inputConfig, { src: source, ext: ext }); + if (drawAngle !== 0) { + ctx.translate(canvasSize.width / 2, canvasSize.height / 2); + ctx.rotate(drawAngle); + ctx.drawImage(drawable, -dHeight / 2, -dWidth / 2, dHeight, dWidth); + ctx.rotate(-drawAngle); + ctx.translate(-canvasSize.width / 2, -canvasSize.height / 2); + } else { + ctx.drawImage.apply(ctx, [drawable].concat(drawImageArgs)); } - throw new Error('Source "' + source + '": not recognized'); } -function createConfigForMediaExtension(config, inputConfig, _ref5) { - var src = _ref5.src, - ext = _ref5.ext; +function fromSource(source) { + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref$target = _ref.target, + target = _ref$target === undefined ? "#interactive.viewport" : _ref$target; + + var drawable = source.getDrawable(); + var $canvas = null; + var ctx = null; - if (ext.match(isImageExt.regex)) { - return createConfigForImage(config, { src: src }, inputConfig); - } else if (ext.match(isVideoExt.regex)) { - return createConfigForVideo(config, { src: src }, inputConfig); + if (drawable instanceof HTMLVideoElement || drawable instanceof HTMLImageElement) { + $canvas = getOrCreateCanvas(source, target); + ctx = $canvas.getContext('2d'); + } + + if (drawable instanceof HTMLCanvasElement) { + $canvas = drawable; + ctx = drawable.getContext('2d'); } - throw new Error('Source "MediaString": not recognized'); -} -function createConfigForCanvas(config, _ref6) { - var canvas = _ref6.canvas; - var inputConfig = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + function nextAvailableBuffer(bytesRequired) { + return new Uint8Array(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__common_buffers__["a" /* aquire */])(bytesRequired)); + } - // TODO: adjust stream & frame-grabber - // once/continous - throw new Error('Source "Canvas": not implemented!'); -} + return { + grabFrameData: function grabFrameData() { + var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + clipping = _ref2.clipping; + + var frame = source.getDrawable(); + + var _source$getDimensions = source.getDimensions(), + viewport = _source$getDimensions.viewport, + canvasSize = _source$getDimensions.canvas; + + var sx = viewport.x; + var sy = viewport.y; + var sWidth = viewport.width; + var sHeight = viewport.height; + var dx = 0; + var dy = 0; + var dWidth = canvasSize.width; + var dHeight = canvasSize.height; + var _source$colorChannels = source.colorChannels, + colorChannels = _source$colorChannels === undefined ? 3 : _source$colorChannels; + + + clipping = clipping ? clipping(canvasSize) : { + x: 0, + y: 0, + width: canvasSize.width, + height: canvasSize.height + }; -function createConfigForVideo(config, source) { - var inputConfig = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + adjustCanvasSize(canvasSize, $canvas); + if ($canvas.height < 10 || $canvas.width < 10) { + return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__common_utils__["b" /* sleep */])(100).then(grabFrameData); + } - return __WEBPACK_IMPORTED_MODULE_3_lodash_merge___default()({}, config, { - inputStream: __WEBPACK_IMPORTED_MODULE_3_lodash_merge___default()({ - type: "VideoStream" - }, source) - }, { - inputStream: inputConfig - }); + if (!(frame instanceof HTMLCanvasElement)) { + drawImage(canvasSize, ctx, source, frame, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight); + } + var imageData = ctx.getImageData(clipping.x, clipping.y, clipping.width, clipping.height).data; + var imageBuffer = nextAvailableBuffer(clipping.width * clipping.height); + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__common_cv_utils__["b" /* computeGray */])(imageData, imageBuffer, { singleChannel: colorChannels === 1 }); + return Promise.resolve({ + width: clipping.width, + height: clipping.height, + dimensions: { + viewport: viewport, + canvas: canvasSize, + clipping: clipping + }, + data: imageBuffer + }); + }, + getSource: function getSource() { + return source; + }, + getCanvas: function getCanvas() { + return $canvas; + }, + getCaptureSize: function getCaptureSize() { + return source.getDimensions().canvas; + } + }; } -function createConfigForStream(config, _ref7) { - var srcObject = _ref7.srcObject; - var inputConfig = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; +/***/ }), +/* 93 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - // TODO: attach to